import { jsx as a, Fragment as _, jsxs as k } from "react/jsx-runtime";
import { a as F } from "./index.CfQlFjZU.js";
import { c as U } from "./Dropdown.CMeTYQwB.js";
import { l as P } from "./lodash.xuulwbEa.js";
import { t as E, a as g, n as H, b as O } from "./index.CS_Iwobh.js";
import { f as z } from "./format.CRlSnSc-.js";
import { useState as M } from "react";
import { a as S } from "./message.CHKnnsjy.js";
import { M as h } from "./shared.EdGf6tcG.js";
import { D as G } from "./Datepicker.B0OFWzLp.js";
import { n as I } from "./index.B0wX8xO7.js";
function Y(e, s, o) {
  if (typeof e == "string" && !e.match(E))
    return g(e, { ...o, timeZone: s });
  e = g(e, o);
  const r = H(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds()).getTime(), i = O(s, new Date(r));
  return new Date(r + i);
}
const j = "creator_step_Ow2WM", A = "creator_form_ho3o-", R = "creator_fieldGroup_DaC-5", W = "creator_fieldHeader_kNdts", n = { step: j, form: A, fieldGroup: R, fieldHeader: W }, t = { text: "ET", variant: "default" }, Z = [
  {
    label: "2:00 PM",
    value: "14:00",
    suffixTagProps: t
  },
  {
    label: "2:15 PM",
    value: "14:15",
    suffixTagProps: t
  },
  {
    label: "2:30 PM",
    value: "14:30",
    suffixTagProps: t
  },
  {
    label: "2:45 PM",
    value: "14:45",
    suffixTagProps: t
  },
  {
    label: "3:00 PM",
    value: "15:00",
    suffixTagProps: t
  },
  {
    label: "3:15 PM",
    value: "15:15",
    suffixTagProps: t
  },
  {
    label: "3:30 PM",
    value: "15:30",
    suffixTagProps: t
  },
  {
    label: "3:45 PM",
    value: "15:45",
    suffixTagProps: t
  },
  {
    label: "4:00 PM",
    value: "16:00",
    suffixTagProps: t
  },
  {
    label: "4:15 PM",
    value: "16:15",
    suffixTagProps: t
  },
  {
    label: "4:30 PM",
    value: "16:30",
    suffixTagProps: t
  },
  {
    label: "4:45 PM",
    value: "16:45",
    suffixTagProps: t
  },
  {
    label: "5:00 PM",
    value: "17:00",
    suffixTagProps: t
  },
  {
    label: "5:15 PM",
    value: "17:15",
    suffixTagProps: t
  },
  {
    label: "5:30 PM",
    value: "17:30",
    suffixTagProps: t
  },
  {
    label: "5:45 PM",
    value: "17:45",
    suffixTagProps: t
  },
  {
    label: "6:00 PM",
    value: "18:00",
    suffixTagProps: t
  },
  {
    label: "6:15 PM",
    value: "18:15",
    suffixTagProps: t
  },
  {
    label: "6:30 PM",
    value: "18:30",
    suffixTagProps: t
  }
];
function $(e) {
  if (e === void 0)
    return { scheduledDate: void 0, scheduledTime: "" };
  const s = new Date(e), r = new Intl.DateTimeFormat("en-US", {
    timeZone: "America/New_York",
    hour: "2-digit",
    minute: "2-digit",
    hour12: !1
  }).format(s);
  return { scheduledDate: s, scheduledTime: r };
}
function q(e, s) {
  const o = "America/New_York", i = `${z(e, "yyyy-MM-dd")}T${s}:00`;
  return Y(i, o);
}
const B = (e) => ({
  stepClassName: n.step,
  formClassName: n.form,
  fieldGroupClassName: n.fieldGroup,
  fieldHeaderClassName: n.fieldHeader,
  ...e
}), V = ({
  stepClassName: e,
  formClassName: s,
  fieldGroupClassName: o,
  fieldHeaderClassName: r,
  timeSelectOptions: i = Z,
  scheduleTimeStamp: c,
  isPhoneRegistered: m,
  scheduleError: u,
  onFieldUpdate: b
}) => {
  const { scheduledDate: v, scheduledTime: x } = $(c), [f, D] = M(x), [p, w] = M(v), N = (l) => {
    D(l), d(p, l);
  }, y = (l) => {
    w(l), d(l, f);
  }, d = (l, T) => {
    if (l && T) {
      const C = q(l, T).getTime();
      b({ scheduleTimeStamp: C });
    }
  };
  return /* @__PURE__ */ a(_, { children: /* @__PURE__ */ a("div", { className: e, children: /* @__PURE__ */ a("div", { className: s, children: /* @__PURE__ */ k("div", { className: o, children: [
    /* @__PURE__ */ a("div", { className: r, children: " Schedule send " }),
    /* @__PURE__ */ a(
      S,
      {
        text: "To comply with telemarketing regulations, SMS may not be sent during quiet hours. To support compliance, SMS messages can only be sent 2 - 6:30 PM ET.",
        semantic: h.INFO
      }
    ),
    /* @__PURE__ */ a("div", { className: o, children: /* @__PURE__ */ a(
      G,
      {
        selectedDate: p,
        onDateChange: y,
        label: "Date",
        dropdownPlaceholder: "Select a date",
        disablePastDates: !0,
        dropdownDisabled: !m
      }
    ) }),
    /* @__PURE__ */ a(
      U,
      {
        disabled: !m,
        onClick: P.noop,
        onSelect: P.noop,
        onChange: N,
        value: f,
        items: i,
        label: "Time",
        placeholder: "Select time",
        helper: "Times are displayed in ET"
      }
    ),
    /* @__PURE__ */ a(
      I,
      {
        value: !!u,
        then: /* @__PURE__ */ a(
          S,
          {
            text: u,
            semantic: h.ERROR
          }
        )
      }
    )
  ] }) }) }) });
}, ie = F(V, B, "ScheduleStep");
export {
  ie as S
};
