import { jsxs as M, jsx as p } from "react/jsx-runtime";
/* empty css                      */
import { classNames as O } from "./index-classNames.js";
import { formatHours as u, getHourFormat as V } from "./index-format-utils.js";
import { generateHoursList as j } from "./index-hours-list.js";
import { ComponentContainer as y } from "./index-ComponentContainer.js";
import { Select as q } from "./index-Select.js";
import i from "./index-moment.js";
import { useState as f, useEffect as d } from "react";
import { Icon as w } from "./index-Icon.js";
import { IconNames as B } from "./index-IconNames.js";
const Z = (h) => {
  var n;
  const {
    onChange: k,
    label: v,
    value: t,
    hourListType: x,
    containerClassName: C,
    min: r,
    max: s,
    showAmPm: e,
    id: N,
    testId: b,
    formconfig: o,
    freeSolo: F
  } = h, [I, L] = f(u(t ?? ((n = o == null ? void 0 : o.getValue) == null ? void 0 : n.call(o)) ?? "", e));
  d(() => {
    t && L(u(t, e));
  }, [t, e]);
  const [P, S] = f([]);
  return d(() => {
    const T = j(x, e).map((m, g) => {
      let l = !1;
      if (r || s) {
        const a = V(e), c = i(m, a), A = i(r, a), H = i(s, a);
        l = A.isAfter(c) || H.isBefore(c);
      }
      return {
        key: g,
        value: m,
        title: m,
        disabled: l
      };
    });
    S(T);
  }, [r, s, e]), M(y, {
    className: O("TimePicker-container", C),
    testId: b,
    children: [p(w, {
      className: "TimePicker-icon",
      color: "--n500",
      children: B.clock
    }), p(q, {
      formconfig: o,
      id: N,
      label: v,
      value: I,
      valueAsDefaultValue: !1,
      onChange: k,
      options: P,
      freeSolo: F,
      required: !0,
      translateOptions: !1
    })]
  });
};
export {
  Z as TimePicker
};
