import { e as b, F as v, ag as j, ah as B, ai as U, aj as w, ak as D, al as _, am as z, an as A, ao as N, ap as V } from "./Toggle-E-Bsru_F.js";
import { j as r } from "./jsx-runtime-NmMXPjeo.js";
import { C as u, d as k, T as S, h as F } from "./css-fOi2x-55.js";
import { useCallback as M, useState as C } from "react";
import { S as x } from "./Center-c6LFuqp8.js";
import "./aggregator-BIN9LAqD.js";
import { useController as $, useFormContext as E } from "react-hook-form";
const T = ({
  className: e,
  variant: t = "error",
  ...s
}) => /* @__PURE__ */ r.jsx(
  b,
  {
    className: u(
      u.B("input-help-text"),
      u.BM("input-help-text", t),
      e
    ),
    level: "small",
    ...s
  }
), I = ({ className: e, ...t }) => /* @__PURE__ */ r.jsx("label", { className: u(u.B("input-label"), e), ...t }), H = (e) => e.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUpperCase()), P = (e, t = "x") => e ?? (k.construct(t) === "y" ? "stretch" : "center"), O = ({
  label: e,
  showLabel: t = !0,
  helpText: s,
  direction: m = "y",
  className: a,
  children: f,
  align: l,
  size: p = "small",
  padHelpText: o = !1,
  ...g
}) => {
  let n;
  return m === "x" ? n = /* @__PURE__ */ r.jsxs(x, { direction: "y", size: "small", children: [
    f,
    (o || s != null && s.length > 0) && /* @__PURE__ */ r.jsx(T, { children: s })
  ] }) : n = /* @__PURE__ */ r.jsxs(x, { direction: "y", size: 1 / 3, children: [
    f,
    (o || s != null && s.length > 0) && /* @__PURE__ */ r.jsx(T, { children: s })
  ] }), /* @__PURE__ */ r.jsxs(
    x,
    {
      className: u(u.B("input-item"), a),
      direction: m,
      size: p,
      align: P(l, m),
      ...g,
      children: [
        t && /* @__PURE__ */ r.jsx(I, { children: e }),
        n
      ]
    }
  );
}, R = v(j), q = ({
  name: e,
  rules: t,
  shouldUnregister: s,
  defaultValue: m,
  label: a,
  children: f = R,
  alsoValidate: l,
  padHelpText: p = !0,
  ref: o,
  ...g
}) => {
  var h;
  const { field: n, fieldState: d } = $({
    rules: t,
    name: e
  }), { trigger: i } = E();
  a == null && (a = H(e));
  const c = M(() => {
    n.onBlur(), l != null && i(l);
  }, [n.onBlur, i, l, e]);
  return /* @__PURE__ */ r.jsx(
    O,
    {
      label: a,
      padHelpText: p,
      helpText: (h = d.error) == null ? void 0 : h.message,
      ...g,
      children: f({
        onChange: n.onChange,
        value: n.value,
        onBlur: c
      })
    }
  );
}, L = ({ value: e, onChange: t, onBlur: s, ...m }) => {
  const a = new S(e, "UTC"), [f, l] = C(
    a.fString("ISO", "local").slice(0, -1)
  ), [p, o] = C(!0), g = (d) => {
    let i = d.toString();
    l(i);
    let c = new S(d, "UTC");
    i.length < 23 && (i += ".000"), c = c.add(
      (S.now().date().getTimezoneOffset() - c.date().getTimezoneOffset()) * F.MINUTE.valueOf()
    );
    let h = !1;
    try {
      h = c.fString("ISO", "local").slice(0, -1) === i;
    } catch {
      console.error("e");
    }
    if (!h) {
      o(!1);
      return;
    }
    t(c.valueOf()), o(!0);
  }, n = (d) => {
    o(!0), l(new S(e, "UTC").fString("ISO", "local").slice(0, -1)), s == null || s(d);
  };
  return /* @__PURE__ */ r.jsx(
    j,
    {
      type: "datetime-local",
      onBlur: n,
      required: !1,
      value: p ? new S(e, "UTC").fString("ISO", "local").slice(0, -1) : f,
      onChange: g,
      ...m
    }
  );
}, Y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Date: B,
  DateTime: L,
  DragButton: U,
  HFItem: q,
  HelpText: T,
  Item: O,
  Label: I,
  Numeric: w,
  Switch: D,
  Text: j,
  TextArea: _,
  Time: z,
  combineDateAndTimeValue: A,
  useDate: N,
  useTime: V
}, Symbol.toStringTag, { value: "Module" }));
export {
  O as I,
  Y as e
};
//# sourceMappingURL=external-lpROAQBM.js.map
