import { ak as T, f as D, al as N, am as O, an as w, ao as I, ap as z, aq as A, ar as B, as as C, at as _ } from "./Toggle-B5c5wLIa.js";
import { j as t } from "./jsx-runtime-B6kdoens.js";
import { m as S, w as k } from "./aggregator-J7DZKy5x.js";
import { useState as q } from "react";
import { C as i, g as E } from "./css-BHfxGWOW.js";
import { S as y } from "./Pack-CcDPYCmE.js";
const M = ({
  value: s,
  onChange: a,
  onBlur: e,
  onlyChangeOnBlur: l,
  ...p
}) => {
  const [c, o] = q(null), m = (r, x = !1) => {
    let n = r.toString();
    o(n);
    let u = new S(r, "UTC");
    n.length < 23 && (n += ".000"), u = u.add(
      BigInt(
        S.now().date().getTimezoneOffset() - u.date().getTimezoneOffset()
      ) * k.MINUTE.valueOf()
    );
    let j = !1;
    try {
      j = u.fString("ISO", "local").slice(0, -1) === n;
    } catch (h) {
      console.error(h);
    }
    j && !l && (a(Number(u.valueOf())), o(null)), x && (j && a(Number(u.valueOf())), o(null));
  }, g = (r) => {
    m(r.target.value, !0), o(null), e == null || e(r);
  }, f = (r) => {
    l && r.key === "Enter" && r.currentTarget.blur();
  }, d = new S(s, "UTC").fString("ISO", "local").slice(0, -1);
  return /* @__PURE__ */ t.jsx(
    T,
    {
      type: "datetime-local",
      onBlur: g,
      required: !1,
      onKeyDown: f,
      value: c ?? d,
      onChange: m,
      ...p
    }
  );
}, b = ({
  className: s,
  variant: a = "error",
  ...e
}) => /* @__PURE__ */ t.jsx(
  D,
  {
    className: i(
      i.B("input-help-text"),
      i.BM("input-help-text", a),
      s
    ),
    level: "small",
    ...e
  }
), v = ({
  className: s,
  required: a = !1,
  children: e,
  ...l
}) => /* @__PURE__ */ t.jsxs("label", { className: i(i.B("input-label"), s), ...l, children: [
  e,
  " ",
  a && /* @__PURE__ */ t.jsx("span", { className: i.B("required-indicator"), children: "*" })
] }), U = (s, a = "x") => s ?? (E.construct(a) === "y" ? "stretch" : "center"), V = ({
  label: s,
  showLabel: a = !0,
  helpText: e,
  direction: l = "y",
  className: p,
  children: c,
  required: o,
  align: m,
  size: g = "small",
  padHelpText: f = !1,
  helpTextVariant: d,
  showHelpText: r = !0,
  ...x
}) => {
  let n;
  return r === !1 && a === !1 ? /* @__PURE__ */ t.jsx(t.Fragment, { children: c }) : (l === "x" ? n = /* @__PURE__ */ t.jsxs(y, { direction: "y", size: "small", children: [
    c,
    (f || e != null && e.length > 0) && /* @__PURE__ */ t.jsx(b, { variant: d, children: e })
  ] }) : n = /* @__PURE__ */ t.jsxs(y, { direction: "y", size: 1 / 3, children: [
    c,
    (f || e != null && e.length > 0) && /* @__PURE__ */ t.jsx(b, { variant: d, children: e })
  ] }), /* @__PURE__ */ t.jsxs(
    y,
    {
      className: i(i.B("input-item"), p),
      direction: l,
      size: g,
      align: U(m, l),
      ...x,
      children: [
        a && /* @__PURE__ */ t.jsx(v, { required: o, children: s }),
        n
      ]
    }
  ));
}, G = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Date: N,
  DateTime: M,
  DragButton: O,
  HelpText: b,
  Item: V,
  Label: v,
  Numeric: w,
  Switch: I,
  Text: T,
  TextArea: z,
  Time: A,
  combineDateAndTimeValue: B,
  useDate: C,
  useTime: _
}, Symbol.toStringTag, { value: "Module" }));
export {
  V as I,
  G as e
};
