import { jsxs as _, jsx as e, Fragment as Se } from "react/jsx-runtime";
import { _ as xe, $ as Re, k as Ie, c as He, l as $e, m as Ve, b as je, V as Ae, p as Ke, r as Te, G as Xe, a as Ye } from "./core-DJ4NPp2B.js";
import Ge, { forwardRef as Me, useCallback as ne, useMemo as oe, useState as ue, useRef as Fe, useLayoutEffect as qe, useEffect as ze } from "react";
import Je from "react-dom";
const Qe = Me(
  ({
    label: l,
    helperText: h,
    error: t,
    required: d,
    disabled: i,
    readOnly: n,
    size: a = "md",
    name: $,
    id: u,
    className: o,
    style: f,
    accessMode: D,
    displayStyle: G,
    variant: m,
    value: x,
    defaultValue: R,
    onChange: p,
    onBlur: Q,
    onKeyDown: E,
    placeholder: k,
    type: S = "text",
    maxLength: g,
    prefix: I,
    suffix: V,
    clearable: L,
    autoFocus: A,
    submitOnEnter: w,
    onSubmit: B,
    showKeyboardHints: K,
    labelPlacement: F,
    errorPlacement: O,
    loading: re,
    labelWidth: se,
    controlWidth: z,
    displayMode: X,
    ...pe
  }, b) => {
    const N = xe(D, u), j = N === "hidden";
    N === "disabled" && (i = !0), N === "readOnly" && (n = !0);
    const { t: H } = Re(), M = Ie(u), W = He("input", G), ae = $e("input", G), he = m === "filled" ? "filled" : m === "underlined" ? "underlined" : "", J = ne(() => p?.(""), [p]), Y = Ve({ enabled: X, readOnly: n, disabled: i }), de = je({
      enabled: w,
      onSubmit: B
    }), ie = ne(
      (v) => {
        de(v), E?.(v);
      },
      [de, E]
    ), r = oe(() => {
      const v = [];
      return w && v.push({ key: "Enter", description: H("shortcuts.submit", "Submit") }), L && v.push({ key: "Escape", description: H("shortcuts.clear", "Clear") }), v;
    }, [w, L, H]);
    return j ? null : /* @__PURE__ */ _(
      "div",
      {
        className: `nice-field nice-field--${a} ${F === "left" ? "nice-field--label-left" : ""} ${F === "inside" ? "nice-field--label-inside" : ""} ${re ? "nice-field--loading" : ""} ${o || ""}`,
        style: {
          ...f,
          ...se != null && {
            "--nice-field-label-width": typeof se == "number" ? `${se}px` : se
          },
          ...z != null && {
            "--nice-field-control-width": typeof z == "number" ? `${z}px` : z
          }
        },
        "aria-busy": re || void 0,
        "data-floating": F === "inside" && x ? "true" : void 0,
        children: [
          l && F !== "inside" && /* @__PURE__ */ _(
            "label",
            {
              htmlFor: M,
              className: `nice-field__label ${d ? "nice-field__label--required" : ""}`,
              children: [
                l,
                K && r.length > 0 && /* @__PURE__ */ e(Ae, { shortcuts: r, size: "sm" })
              ]
            }
          ),
          /* @__PURE__ */ _("div", { className: "nice-field__control", children: [
            Y.isDisplay ? /* @__PURE__ */ e(
              Ke,
              {
                value: x ?? R ?? "",
                placeholder: k,
                disabled: i,
                readOnly: n,
                onActivate: Y.enterEdit,
                ariaLabel: l
              }
            ) : /* @__PURE__ */ _(
              "div",
              {
                className: `nice-input nice-input--${a} nice-input--ds-${he || ae} ${t ? "nice-input--error" : ""} ${i ? "nice-input--disabled" : ""} ${n ? "nice-input--readonly" : ""}`,
                style: m ? void 0 : W,
                children: [
                  I && /* @__PURE__ */ e("span", { className: "nice-input__icon", children: I }),
                  /* @__PURE__ */ e(
                    "input",
                    {
                      ref: (v) => {
                        typeof b == "function" ? b(v) : b && (b.current = v), Y.autoFocusRef(v);
                      },
                      id: M,
                      className: "nice-input__native",
                      type: S,
                      name: $,
                      value: x,
                      defaultValue: R,
                      placeholder: k,
                      disabled: i || re,
                      readOnly: n,
                      maxLength: g,
                      autoFocus: A,
                      "aria-invalid": !!t,
                      "aria-describedby": t ? `${M}-error` : h ? `${M}-helper` : void 0,
                      onChange: (v) => p?.(v.target.value),
                      onBlur: (v) => {
                        X && Y.exitEdit(), Q?.(v);
                      },
                      onKeyDown: ie,
                      ...pe
                    }
                  ),
                  L && x && /* @__PURE__ */ e(
                    "button",
                    {
                      type: "button",
                      className: "nice-input__clear",
                      onClick: J,
                      "aria-label": H("controls.clear", "Clear"),
                      children: "✕"
                    }
                  ),
                  V && /* @__PURE__ */ e("span", { className: "nice-input__icon", children: V }),
                  l && F === "inside" && /* @__PURE__ */ e(
                    "label",
                    {
                      htmlFor: M,
                      className: `nice-input__floating-label ${d ? "nice-input__floating-label--required" : ""}`,
                      children: l
                    }
                  )
                ]
              }
            ),
            re && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
            O === "right" && t && /* @__PURE__ */ e("div", { id: `${M}-error`, className: "nice-field__error", role: "alert", children: t }),
            O === "right" && !t && h && /* @__PURE__ */ e("div", { id: `${M}-helper`, className: "nice-field__helper", children: h })
          ] }),
          O !== "right" && t && /* @__PURE__ */ e("div", { id: `${M}-error`, className: "nice-field__error", role: "alert", children: t }),
          O !== "right" && !t && h && /* @__PURE__ */ e("div", { id: `${M}-helper`, className: "nice-field__helper", children: h })
        ]
      }
    );
  }
);
Qe.displayName = "NiceTextInput";
const Ze = Me(
  ({
    label: l,
    helperText: h,
    error: t,
    required: d,
    disabled: i,
    readOnly: n,
    size: a = "md",
    name: $,
    id: u,
    className: o,
    style: f,
    accessMode: D,
    displayStyle: G,
    value: m,
    onChange: x,
    onBlur: R,
    onKeyDown: p,
    placeholder: Q,
    min: E,
    max: k,
    step: S = 1,
    precision: g,
    prefix: I,
    prefixType: V = "label",
    prefixOptions: L,
    prefixValue: A,
    onPrefixChange: w,
    suffix: B,
    showStepper: K = !0,
    submitOnEnter: F,
    onSubmit: O,
    showKeyboardHints: re,
    labelPlacement: se,
    errorPlacement: z,
    loading: X,
    labelWidth: pe,
    controlWidth: b,
    formatPreset: N,
    format: j,
    suffixType: H = "label",
    suffixOptions: M,
    suffixValue: W,
    onSuffixChange: ae,
    displayMode: he
  }, J) => {
    const Y = xe(D, u), de = Y === "hidden";
    Y === "disabled" && (i = !0), Y === "readOnly" && (n = !0);
    const { t: ie } = Re(), r = Ie(u), v = He("input", G), q = $e("input", G), [C, Z] = ue(!1), [P, be] = ue(null), Ne = Ve({ enabled: he, readOnly: n, disabled: i }), fe = oe(() => {
      let c = 3;
      return k != null && (c = String(Math.abs(Math.floor(k))).length), E != null && E < 0 && (c += 1), g && (c += g + 1), Math.max(3, c) + 1;
    }, [k, E, g]), Ce = ne(
      (c) => {
        if (j)
          return j(c);
        if (!N)
          return g != null ? c.toFixed(g) : String(c);
        switch (N) {
          case "integer":
            return Math.round(c).toLocaleString();
          case "decimal":
            return c.toLocaleString(void 0, {
              minimumFractionDigits: g ?? 2,
              maximumFractionDigits: g ?? 2
            });
          case "money":
            return c.toLocaleString(void 0, {
              minimumFractionDigits: g ?? 2,
              maximumFractionDigits: g ?? 2,
              useGrouping: !0
            });
          case "percent":
            return (c * 100).toLocaleString(void 0, {
              minimumFractionDigits: g ?? 0,
              maximumFractionDigits: g ?? 2
            }) + "%";
          default:
            return String(c);
        }
      },
      [j, N, g]
    ), De = oe(() => C && P !== null ? P : m == null ? "" : C ? g != null ? m.toFixed(g) : String(m) : Ce(m), [m, C, P, Ce, g]), me = m != null && m < 0, te = !!(I || V === "select" && L && L.length > 0), ee = me && te && !C, Be = ee ? De.replace(/^[-−]/, "") : De, _e = ne(
      (c) => {
        let y = c;
        return E !== void 0 && (y = Math.max(E, y)), k !== void 0 && (y = Math.min(k, y)), g !== void 0 && (y = parseFloat(y.toFixed(g))), y;
      },
      [E, k, g]
    ), Ue = ne(
      (c) => {
        const y = c.target.value;
        if (be(y), y === "" || y === "-" || y === "." || y === "-.") {
          y === "" && x?.(null);
          return;
        }
        const le = parseFloat(y);
        if (!isNaN(le)) {
          let ge = le;
          E !== void 0 && (ge = Math.max(E, ge)), k !== void 0 && (ge = Math.min(k, ge)), x?.(ge);
        }
      },
      [x, E, k]
    ), ye = ne(() => {
      const c = ke.current, y = _e((c ?? 0) + S);
      ke.current = y, x?.(y);
    }, [S, x, _e]), Le = ne(() => {
      const c = ke.current, y = _e((c ?? 0) - S);
      ke.current = y, x?.(y);
    }, [S, x, _e]), ke = Fe(m);
    ke.current = m;
    const s = Fe(null), T = ne(() => {
      s.current && (clearTimeout(s.current), s.current = null);
    }, []), U = ne(
      (c) => {
        T();
        let y = 300;
        const le = () => {
          c(), y = Math.max(30, y * 0.82), s.current = setTimeout(le, y);
        };
        s.current = setTimeout(le, 400);
      },
      [T]
    ), ve = je({
      enabled: F,
      onSubmit: O
    }), Ee = ne(
      (c) => {
        ve(c), c.key === "ArrowUp" ? (c.preventDefault(), ye()) : c.key === "ArrowDown" && (c.preventDefault(), Le()), p?.(c);
      },
      [ve, p, ye, Le]
    ), ce = oe(() => {
      const c = [];
      return F && c.push(Te.submit), K && (c.push({ key: "ArrowUp", description: ie("shortcuts.increment", "Increase value") }), c.push({ key: "ArrowDown", description: ie("shortcuts.decrement", "Decrease value") })), c;
    }, [F, K, ie]);
    return de ? null : /* @__PURE__ */ _(
      "div",
      {
        className: `nice-field nice-field--${a} ${se === "left" ? "nice-field--label-left" : ""} ${X ? "nice-field--loading" : ""} ${o || ""}`,
        style: {
          ...f,
          ...pe != null && {
            "--nice-field-label-width": typeof pe == "number" ? `${pe}px` : pe
          },
          ...b != null && {
            "--nice-field-control-width": typeof b == "number" ? `${b}px` : b
          }
        },
        "aria-busy": X || void 0,
        children: [
          l && /* @__PURE__ */ _(
            "label",
            {
              htmlFor: r,
              className: `nice-field__label ${d ? "nice-field__label--required" : ""}`,
              children: [
                l,
                re && ce.length > 0 && /* @__PURE__ */ e(Ae, { shortcuts: ce, size: "sm" })
              ]
            }
          ),
          /* @__PURE__ */ _("div", { className: "nice-field__control", children: [
            Ne.isDisplay ? /* @__PURE__ */ e(
              Ke,
              {
                value: m == null ? "" : I ? /* @__PURE__ */ _(Se, { children: [
                  I,
                  De
                ] }) : De,
                placeholder: Q,
                disabled: i,
                readOnly: n,
                onActivate: Ne.enterEdit,
                ariaLabel: l
              }
            ) : /* @__PURE__ */ e(Se, { children: /* @__PURE__ */ _(
              "div",
              {
                className: `nice-input nice-input--number nice-input--${a} nice-input--ds-${q} ${t ? "nice-input--error" : ""} ${i ? "nice-input--disabled" : ""} ${n ? "nice-input--readonly" : ""}`,
                style: v,
                children: [
                  K && !n && /* @__PURE__ */ e(
                    "button",
                    {
                      type: "button",
                      className: "nice-input__clear nice-input__minus",
                      onClick: Le,
                      onMouseDown: () => U(Le),
                      onMouseUp: T,
                      onMouseLeave: T,
                      disabled: i,
                      "aria-label": ie("controls.decrement", "Decrement"),
                      children: "−"
                    }
                  ),
                  V === "select" && L && L.length > 0 ? /* @__PURE__ */ _(Se, { children: [
                    ee && /* @__PURE__ */ e("span", { className: "nice-input__sign", children: "−" }),
                    /* @__PURE__ */ e(
                      "select",
                      {
                        className: "nice-input__suffix-select nice-input__icon--prefix",
                        value: A ?? L[0]?.value,
                        disabled: i,
                        onChange: (c) => {
                          const y = c.target.value, le = L.find(
                            (we) => we.value === (A ?? L[0]?.value)
                          ), ge = L.find((we) => we.value === y);
                          w?.(y, le?.weight, ge?.weight);
                        },
                        children: L.map((c) => /* @__PURE__ */ e("option", { value: c.value, children: c.label }, c.value))
                      }
                    )
                  ] }) : I ? /* @__PURE__ */ _("span", { className: "nice-input__icon nice-input__icon--prefix", children: [
                    ee && /* @__PURE__ */ e("span", { className: "nice-input__sign", children: "−" }),
                    I
                  ] }) : null,
                  /* @__PURE__ */ e(
                    "input",
                    {
                      ref: (c) => {
                        typeof J == "function" ? J(c) : J && (J.current = c), Ne.autoFocusRef(c);
                      },
                      id: r,
                      className: "nice-input__native",
                      type: !C && (j || N) ? "text" : "number",
                      name: $,
                      value: Be,
                      placeholder: Q,
                      min: E,
                      max: k,
                      step: S,
                      disabled: i || X,
                      readOnly: n,
                      "aria-invalid": !!t,
                      onChange: Ue,
                      onFocus: (c) => {
                        Z(!0), be(null), c.target.select();
                      },
                      onBlur: (c) => {
                        if (Z(!1), be(null), m != null && g !== void 0) {
                          const y = parseFloat(m.toFixed(g));
                          y !== m && x?.(y);
                        }
                        he && Ne.exitEdit(), R?.(c);
                      },
                      onKeyDown: Ee,
                      style: { width: `${fe}ch` }
                    }
                  ),
                  H === "select" && M && M.length > 0 ? /* @__PURE__ */ e(
                    "select",
                    {
                      className: "nice-input__suffix-select nice-input__icon--suffix",
                      value: W ?? M[0]?.value,
                      disabled: i,
                      onChange: (c) => {
                        const y = c.target.value, le = M.find(
                          (we) => we.value === (W ?? M[0]?.value)
                        ), ge = M.find((we) => we.value === y);
                        ae?.(y, le?.weight, ge?.weight);
                      },
                      children: M.map((c) => /* @__PURE__ */ e("option", { value: c.value, children: c.label }, c.value))
                    }
                  ) : B ? /* @__PURE__ */ e("span", { className: "nice-input__icon nice-input__icon--suffix", children: B }) : null,
                  K && !n && /* @__PURE__ */ e(
                    "button",
                    {
                      type: "button",
                      className: "nice-input__clear nice-input__plus",
                      onClick: ye,
                      onMouseDown: () => U(ye),
                      onMouseUp: T,
                      onMouseLeave: T,
                      disabled: i,
                      "aria-label": ie("controls.increment", "Increment"),
                      children: "+"
                    }
                  )
                ]
              }
            ) }),
            X && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
            z === "right" && t && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: t }),
            z === "right" && !t && h && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: h })
          ] }),
          z !== "right" && t && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: t }),
          z !== "right" && !t && h && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: h })
        ]
      }
    );
  }
);
Ze.displayName = "NiceNumberInput";
const Pe = Me(
  ({
    label: l,
    helperText: h,
    error: t,
    required: d,
    disabled: i,
    size: n = "md",
    name: a,
    id: $,
    className: u,
    style: o,
    accessMode: f,
    displayStyle: D,
    options: G,
    value: m,
    onChange: x,
    placeholder: R,
    multiple: p = !1,
    searchable: Q = !1,
    clearable: E = !1,
    emptyText: k,
    maxHeight: S = 240,
    optionsSource: g,
    valueField: I,
    labelField: V,
    virtualScroll: L,
    optionHeight: A = 36,
    onSearch: w,
    loading: B,
    renderOption: K,
    multipleAutosize: F = !1,
    showKeyboardHints: O,
    labelPlacement: re,
    errorPlacement: se,
    labelWidth: z,
    controlWidth: X,
    displayMode: pe
  }, b) => {
    const N = xe(f, $), j = N === "hidden";
    (N === "disabled" || N === "readOnly") && (i = !0);
    const { t: H } = Re(), M = He("input", D), W = $e("input", D), ae = Ie($), he = Ve({ enabled: pe, disabled: i }), [J, Y] = ue(!1), [de, ie] = ue(""), [r, v] = ue(-1), [q, C] = ue(0), Z = Fe(null), P = Fe(null), [be, Ne] = ue(null);
    qe(() => {
      !B && P.current && Ne(P.current.offsetWidth);
    }, [B, m, D]);
    const [fe, Ce] = ue(null);
    qe(() => {
      p && !F && P.current && fe == null && Ce(P.current.offsetWidth);
    }, [p, F, fe]);
    const De = Xe(
      g ?? null,
      I ?? g?.keyField ?? "id",
      V ?? "name"
    ), me = g ? De.options : (G ?? []).map(
      (s) => typeof s == "string" ? { value: s, label: s } : s
    );
    Ye(Z, () => {
      Y(!1), ie("");
    });
    const te = oe(() => m ? Array.isArray(m) ? m : [m] : [], [m]), ee = oe(() => {
      if (!de && !w || w)
        return me;
      const s = de.toLowerCase();
      return me.filter(
        (T) => T.label.toLowerCase().includes(s) || String(T.value).toLowerCase().includes(s)
      );
    }, [me, de, w]), Be = oe(() => {
      const s = /* @__PURE__ */ new Map();
      for (const T of ee) {
        const U = T.group || "";
        s.has(U) || s.set(U, []), s.get(U).push(T);
      }
      return s;
    }, [ee]), _e = ne(
      (s) => {
        if (p) {
          const T = te.includes(s) ? te.filter((U) => U !== s) : [...te, s];
          x?.(T);
        } else
          x?.(s), Y(!1), ie("");
      },
      [p, te, x]
    ), Ue = ne(
      (s) => {
        if (s.key === "Escape") {
          Y(!1), ie("");
          return;
        }
        if (s.key === "Enter" || s.key === " ") {
          if (!J) {
            Y(!0), s.preventDefault();
            return;
          }
          r >= 0 && ee[r] && (_e(ee[r].value), s.preventDefault());
          return;
        }
        s.key === "ArrowDown" && (s.preventDefault(), v((T) => Math.min(T + 1, ee.length - 1))), s.key === "ArrowUp" && (s.preventDefault(), v((T) => Math.max(T - 1, 0)));
      },
      [J, r, ee, _e]
    ), ye = oe(() => te.length === 0 ? null : p ? te.map((s) => me.find((T) => T.value === s)?.label || s).join(", ") : me.find((s) => s.value === te[0])?.label || te[0], [te, me, p]), Le = ne(
      (s) => {
        s.stopPropagation(), x?.(p ? [] : "");
      },
      [x, p]
    ), ke = oe(
      () => [
        { key: "Enter", description: H("shortcuts.select", "Select") },
        { key: "Space", description: H("shortcuts.openDropdown", "Open dropdown") },
        Te.moveUp,
        Te.moveDown,
        Te.cancel
      ],
      [H]
    );
    return j ? null : /* @__PURE__ */ _(
      "div",
      {
        className: `nice-field ${X == null ? "nice-field--select-auto" : ""} nice-field--${n} ${re === "left" ? "nice-field--label-left" : ""} ${B ? "nice-field--loading" : ""} ${u || ""}`,
        style: {
          ...o,
          ...z != null && {
            "--nice-field-label-width": typeof z == "number" ? `${z}px` : z
          },
          ...X != null && {
            "--nice-field-control-width": typeof X == "number" ? `${X}px` : X
          },
          ...B && be != null && { "--nice-select-locked-width": `${be}px` }
        },
        "aria-busy": B || void 0,
        children: [
          l && /* @__PURE__ */ _(
            "label",
            {
              htmlFor: ae,
              className: `nice-field__label ${d ? "nice-field__label--required" : ""}`,
              children: [
                l,
                O && /* @__PURE__ */ e(Ae, { shortcuts: ke, size: "sm" })
              ]
            }
          ),
          /* @__PURE__ */ _("div", { className: "nice-field__control", children: [
            he.isDisplay ? /* @__PURE__ */ e(
              Ke,
              {
                value: ye,
                placeholder: R || H("controls.select", "Select..."),
                disabled: i,
                onActivate: () => {
                  he.enterEdit(), Y(!0);
                },
                ariaLabel: l
              }
            ) : /* @__PURE__ */ _("div", { className: "nice-select", ref: Z, children: [
              /* @__PURE__ */ _(
                "button",
                {
                  ref: (s) => {
                    P.current = s, typeof b == "function" ? b(s) : b && (b.current = s);
                  },
                  type: "button",
                  id: ae,
                  role: "combobox",
                  "aria-expanded": J,
                  "aria-haspopup": "listbox",
                  "aria-invalid": !!t,
                  className: `nice-select__trigger nice-select__trigger--${n} nice-select--ds-${W} ${J ? "nice-select__trigger--open" : ""} ${t ? "nice-select__trigger--error" : ""} ${i ? "nice-select__trigger--disabled" : ""}`,
                  style: {
                    ...M,
                    ...p && !F && fe != null ? {
                      width: fe,
                      maxWidth: fe,
                      overflow: "hidden"
                    } : {}
                  },
                  disabled: i,
                  onClick: () => Y(!J),
                  onKeyDown: Ue,
                  children: [
                    ye ? /* @__PURE__ */ e(
                      "span",
                      {
                        style: p && !F ? {
                          flex: 1,
                          minWidth: 0,
                          overflow: "hidden",
                          textOverflow: "ellipsis",
                          whiteSpace: "nowrap"
                        } : void 0,
                        children: ye
                      }
                    ) : /* @__PURE__ */ e("span", { className: "nice-select__placeholder", children: R || H("controls.select", "Select...") }),
                    /* @__PURE__ */ _("span", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
                      E && te.length > 0 && /* @__PURE__ */ e(
                        "span",
                        {
                          className: "nice-input__clear",
                          onClick: Le,
                          role: "button",
                          "aria-label": H("controls.clear", "Clear"),
                          children: "✕"
                        }
                      ),
                      /* @__PURE__ */ e(
                        "svg",
                        {
                          className: `nice-select__chevron ${J ? "nice-select__chevron--open" : ""}`,
                          viewBox: "0 0 20 20",
                          fill: "currentColor",
                          children: /* @__PURE__ */ e(
                            "path",
                            {
                              fillRule: "evenodd",
                              d: "M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",
                              clipRule: "evenodd"
                            }
                          )
                        }
                      )
                    ] })
                  ]
                }
              ),
              J && /* @__PURE__ */ _(
                "div",
                {
                  className: "nice-select__dropdown",
                  role: "listbox",
                  style: { maxHeight: S },
                  onScroll: L ? (s) => C(s.currentTarget.scrollTop) : void 0,
                  children: [
                    (Q || w) && /* @__PURE__ */ e("div", { className: "nice-select__search", children: /* @__PURE__ */ e(
                      "input",
                      {
                        type: "text",
                        value: de,
                        onChange: (s) => {
                          ie(s.target.value), v(0), w?.(s.target.value);
                        },
                        placeholder: H("controls.search", "Search..."),
                        autoFocus: !0
                      }
                    ) }),
                    B && /* @__PURE__ */ e("div", { className: "nice-select__loading", children: /* @__PURE__ */ e(
                      "div",
                      {
                        className: "nice-spinner nice-spinner--sm",
                        style: { margin: "8px auto" }
                      }
                    ) }),
                    !B && ee.length === 0 ? /* @__PURE__ */ e("div", { className: "nice-select__empty", children: k || H("controls.noResults", "No results found") }) : L && !Array.from(Be.keys()).some((s) => s !== "") ? (() => {
                      const T = ee.length * A, U = Math.max(
                        0,
                        Math.floor(q / A) - 3
                      ), ve = Math.min(
                        ee.length,
                        Math.ceil((q + S) / A) + 3
                      ), Ee = ee.slice(U, ve);
                      return /* @__PURE__ */ e("div", { style: { height: T, position: "relative" }, children: Ee.map((ce, c) => {
                        const y = U + c, le = te.includes(ce.value);
                        return /* @__PURE__ */ e(
                          "div",
                          {
                            role: "option",
                            "aria-selected": le,
                            className: `nice-select__option ${le ? "nice-select__option--selected" : ""} ${y === r ? "nice-select__option--highlighted" : ""} ${ce.disabled ? "nice-select__option--disabled" : ""}`,
                            style: {
                              position: "absolute",
                              top: y * A,
                              left: 0,
                              right: 0,
                              height: A,
                              display: "flex",
                              alignItems: "center",
                              padding: "0 12px"
                            },
                            onClick: () => !ce.disabled && _e(String(ce.value)),
                            onMouseEnter: () => v(y),
                            children: K ? K(ce, le) : /* @__PURE__ */ _(Se, { children: [
                              ce.icon && /* @__PURE__ */ e("span", { children: ce.icon }),
                              /* @__PURE__ */ _("div", { style: { flex: 1 }, children: [
                                /* @__PURE__ */ e("div", { children: ce.label }),
                                ce.description && /* @__PURE__ */ e("div", { className: "nice-select__option-desc", children: ce.description })
                              ] }),
                              le && /* @__PURE__ */ e(
                                "svg",
                                {
                                  className: "nice-select__option-check",
                                  viewBox: "0 0 20 20",
                                  fill: "currentColor",
                                  children: /* @__PURE__ */ e(
                                    "path",
                                    {
                                      fillRule: "evenodd",
                                      d: "M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",
                                      clipRule: "evenodd"
                                    }
                                  )
                                }
                              )
                            ] })
                          },
                          ce.value
                        );
                      }) });
                    })() : Array.from(Be.entries()).map(([s, T]) => /* @__PURE__ */ _(Ge.Fragment, { children: [
                      s && /* @__PURE__ */ e("div", { className: "nice-select__group-label", children: s }),
                      T.map((U) => {
                        const ve = te.includes(U.value), Ee = ee.indexOf(U);
                        return /* @__PURE__ */ e(
                          "div",
                          {
                            role: "option",
                            "aria-selected": ve,
                            className: `nice-select__option ${ve ? "nice-select__option--selected" : ""} ${Ee === r ? "nice-select__option--highlighted" : ""} ${U.disabled ? "nice-select__option--disabled" : ""}`,
                            onClick: () => !U.disabled && _e(String(U.value)),
                            onMouseEnter: () => v(Ee),
                            children: K ? K(U, ve) : /* @__PURE__ */ _(Se, { children: [
                              U.icon && /* @__PURE__ */ e("span", { children: U.icon }),
                              /* @__PURE__ */ _("div", { style: { flex: 1 }, children: [
                                /* @__PURE__ */ e("div", { children: U.label }),
                                U.description && /* @__PURE__ */ e("div", { className: "nice-select__option-desc", children: U.description })
                              ] }),
                              ve && /* @__PURE__ */ e(
                                "svg",
                                {
                                  className: "nice-select__option-check",
                                  viewBox: "0 0 20 20",
                                  fill: "currentColor",
                                  children: /* @__PURE__ */ e(
                                    "path",
                                    {
                                      fillRule: "evenodd",
                                      d: "M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z",
                                      clipRule: "evenodd"
                                    }
                                  )
                                }
                              )
                            ] })
                          },
                          U.value
                        );
                      })
                    ] }, s))
                  ]
                }
              )
            ] }),
            B && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
            se === "right" && t && /* @__PURE__ */ e("div", { id: `${ae}-error`, className: "nice-field__error", role: "alert", children: t }),
            se === "right" && !t && h && /* @__PURE__ */ e("div", { id: `${ae}-helper`, className: "nice-field__helper", children: h })
          ] }),
          se !== "right" && t && /* @__PURE__ */ e("div", { id: `${ae}-error`, className: "nice-field__error", role: "alert", children: t }),
          se !== "right" && !t && h && /* @__PURE__ */ e("div", { id: `${ae}-helper`, className: "nice-field__helper", children: h })
        ]
      }
    );
  }
);
Pe.displayName = "NiceSelect";
const Oe = Me(
  ({
    label: l,
    checked: h = !1,
    indeterminate: t = !1,
    onChange: d,
    disabled: i,
    readOnly: n,
    loading: a,
    required: $,
    size: u = "md",
    name: o,
    id: f,
    className: D,
    style: G,
    error: m,
    helperText: x,
    accessMode: R,
    displayStyle: p,
    showKeyboardHints: Q,
    labelPlacement: E,
    errorPlacement: k,
    labelWidth: S,
    controlWidth: g
  }, I) => {
    const V = xe(R, f), L = V === "hidden";
    (V === "disabled" || V === "readOnly") && (i = !0);
    const { t: A } = Re(), w = Ie(f);
    $e("toggle", p);
    const B = oe(
      () => [{ key: "Space", description: A("shortcuts.toggle", "Toggle") }],
      [A]
    ), K = Ge.useCallback(
      (F) => {
        F && (F.indeterminate = t), typeof I == "function" ? I(F) : I && (I.current = F);
      },
      [t, I]
    );
    return L ? null : /* @__PURE__ */ _(
      "div",
      {
        className: `nice-field nice-field--inline nice-field--${u} ${E === "left" ? "nice-field--label-left" : ""} ${k === "right" ? "nice-field--error-right" : ""} ${a ? "nice-field--loading" : ""} ${D || ""}`,
        style: {
          ...G,
          ...S != null && {
            "--nice-field-label-width": typeof S == "number" ? `${S}px` : S
          },
          ...g != null && {
            "--nice-field-control-width": typeof g == "number" ? `${g}px` : g
          }
        },
        "aria-busy": a || void 0,
        children: [
          E === "left" && l && /* @__PURE__ */ e("span", { className: `nice-field__label ${$ ? "nice-field__label--required" : ""}`, children: l }),
          /* @__PURE__ */ _("div", { className: "nice-field__control", children: [
            /* @__PURE__ */ _(
              "label",
              {
                className: `nice-checkbox ${u !== "md" ? `nice-checkbox--${u}` : ""} ${i || a ? "nice-checkbox--disabled" : ""}`,
                htmlFor: w,
                children: [
                  /* @__PURE__ */ e(
                    "input",
                    {
                      ref: K,
                      id: w,
                      type: "checkbox",
                      className: "nice-checkbox__input",
                      name: o,
                      checked: h,
                      disabled: i || a,
                      readOnly: n,
                      "aria-invalid": !!m,
                      onChange: (F) => {
                        n || a || d?.(F.target.checked);
                      }
                    }
                  ),
                  /* @__PURE__ */ e("span", { className: "nice-checkbox__box", children: /* @__PURE__ */ e(
                    "svg",
                    {
                      viewBox: "0 0 12 12",
                      fill: "none",
                      stroke: "currentColor",
                      strokeWidth: "2",
                      strokeLinecap: "round",
                      strokeLinejoin: "round",
                      children: t ? /* @__PURE__ */ e("line", { x1: "2", y1: "6", x2: "10", y2: "6" }) : /* @__PURE__ */ e("polyline", { points: "2 6 5 9 10 3" })
                    }
                  ) }),
                  E !== "left" && l && /* @__PURE__ */ e("span", { children: l }),
                  Q && /* @__PURE__ */ e(Ae, { shortcuts: B, size: "sm" })
                ]
              }
            ),
            a && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
            k === "right" && m && /* @__PURE__ */ e("div", { id: `${w}-error`, className: "nice-field__error", role: "alert", children: m }),
            k === "right" && !m && x && /* @__PURE__ */ e("div", { id: `${w}-helper`, className: "nice-field__helper", children: x })
          ] }),
          k !== "right" && m && /* @__PURE__ */ e("div", { id: `${w}-error`, className: "nice-field__error", role: "alert", children: m }),
          k !== "right" && !m && x && /* @__PURE__ */ e("div", { id: `${w}-helper`, className: "nice-field__helper", children: x })
        ]
      }
    );
  }
);
Oe.displayName = "NiceCheckbox";
const We = Me(
  ({
    label: l,
    checked: h = !1,
    onChange: t,
    disabled: d,
    readOnly: i,
    loading: n,
    required: a,
    size: $ = "md",
    name: u,
    id: o,
    className: f,
    style: D,
    accessMode: G,
    displayStyle: m,
    showKeyboardHints: x,
    error: R,
    helperText: p,
    labelPlacement: Q,
    errorPlacement: E,
    labelWidth: k,
    controlWidth: S
  }, g) => {
    const I = xe(G, o), V = I === "hidden";
    (I === "disabled" || I === "readOnly") && (d = !0);
    const { t: L } = Re(), A = Ie(o);
    He("toggle", m);
    const w = $e("toggle", m), B = oe(
      () => [{ key: "Space", description: L("shortcuts.toggle", "Toggle on/off") }],
      [L]
    );
    return V ? null : /* @__PURE__ */ _(
      "div",
      {
        className: `nice-field nice-field--inline nice-field--${$} ${Q === "left" ? "nice-field--label-left" : ""} ${n ? "nice-field--loading" : ""} ${f || ""}`,
        style: {
          ...D,
          ...k != null && {
            "--nice-field-label-width": typeof k == "number" ? `${k}px` : k
          },
          ...S != null && {
            "--nice-field-control-width": typeof S == "number" ? `${S}px` : S
          }
        },
        "aria-busy": n || void 0,
        children: [
          Q === "left" && l && /* @__PURE__ */ e("span", { className: `nice-field__label ${a ? "nice-field__label--required" : ""}`, children: l }),
          /* @__PURE__ */ _("div", { className: "nice-field__control", children: [
            /* @__PURE__ */ _(
              "label",
              {
                className: `nice-toggle nice-toggle--ds-${w} ${$ !== "md" ? `nice-toggle--${$}` : ""} ${d || n ? "nice-toggle--disabled" : ""}`,
                htmlFor: A,
                children: [
                  /* @__PURE__ */ e(
                    "input",
                    {
                      ref: g,
                      id: A,
                      type: "checkbox",
                      className: "nice-toggle__input",
                      name: u,
                      checked: h,
                      disabled: d || n,
                      readOnly: i,
                      role: "switch",
                      "aria-checked": h,
                      "aria-invalid": !!R,
                      onChange: (K) => {
                        i || n || t?.(K.target.checked);
                      }
                    }
                  ),
                  /* @__PURE__ */ e("span", { className: "nice-toggle__track", children: /* @__PURE__ */ e("span", { className: "nice-toggle__thumb" }) }),
                  Q !== "left" && l && /* @__PURE__ */ e("span", { children: l }),
                  x && /* @__PURE__ */ e(Ae, { shortcuts: B, size: "sm" })
                ]
              }
            ),
            n && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
            E === "right" && R && /* @__PURE__ */ e("div", { id: `${A}-error`, className: "nice-field__error", role: "alert", children: R }),
            E === "right" && !R && p && /* @__PURE__ */ e("div", { id: `${A}-helper`, className: "nice-field__helper", children: p })
          ] }),
          E !== "right" && R && /* @__PURE__ */ e("div", { id: `${A}-error`, className: "nice-field__error", role: "alert", children: R }),
          E !== "right" && !R && p && /* @__PURE__ */ e("div", { id: `${A}-helper`, className: "nice-field__helper", children: p })
        ]
      }
    );
  }
);
We.displayName = "NiceToggle";
const en = [
  "var(--nice-danger, #ef4444)",
  "var(--nice-warning, #f97316)",
  "var(--nice-warning, #f59e0b)",
  "var(--nice-success, #84cc16)",
  "var(--nice-success, #10b981)",
  "var(--nice-info, #06b6d4)",
  "var(--nice-primary, #3b82f6)",
  "var(--nice-info, #6366f1)",
  "var(--nice-accent, #8b5cf6)",
  "var(--nice-accent-pink, #ec4899)",
  "var(--nice-text-secondary, #64748b)",
  "var(--nice-text, #1e293b)"
];
function nn() {
  return "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0");
}
function tn(l, h, t) {
  const d = l / 255, i = h / 255, n = t / 255, a = Math.max(d, i, n), $ = Math.min(d, i, n), u = (a + $) / 2;
  let o = 0, f = 0;
  if (a !== $) {
    const D = a - $;
    switch (f = u > 0.5 ? D / (2 - a - $) : D / (a + $), a) {
      case d:
        o = (i - n) / D + (i < n ? 6 : 0);
        break;
      case i:
        o = (n - d) / D + 2;
        break;
      case n:
        o = (d - i) / D + 4;
        break;
    }
    o *= 60;
  }
  return { h: Math.round(o), s: Math.round(f * 100), l: Math.round(u * 100) };
}
function cn(l, h, t) {
  const d = h / 100, i = t / 100, n = (1 - Math.abs(2 * i - 1)) * d, a = n * (1 - Math.abs(l / 60 % 2 - 1)), $ = i - n / 2;
  let u = 0, o = 0, f = 0;
  return l < 60 ? [u, o, f] = [n, a, 0] : l < 120 ? [u, o, f] = [a, n, 0] : l < 180 ? [u, o, f] = [0, n, a] : l < 240 ? [u, o, f] = [0, a, n] : l < 300 ? [u, o, f] = [a, 0, n] : [u, o, f] = [n, 0, a], {
    r: Math.round((u + $) * 255),
    g: Math.round((o + $) * 255),
    b: Math.round((f + $) * 255)
  };
}
function ln(l, h, t) {
  const d = l / 255, i = h / 255, n = t / 255, a = Math.max(d, i, n), $ = Math.min(d, i, n), u = a - $;
  let o = 0;
  u !== 0 && (a === d ? o = (i - n) / u % 6 : a === i ? o = (n - d) / u + 2 : o = (d - i) / u + 4, o *= 60, o < 0 && (o += 360));
  const f = a === 0 ? 0 : u / a;
  return { h: Math.round(o), s: Math.round(f * 100), v: Math.round(a * 100) };
}
function sn(l, h, t) {
  const d = h / 100, i = t / 100, n = i * d, a = n * (1 - Math.abs(l / 60 % 2 - 1)), $ = i - n;
  let u = 0, o = 0, f = 0;
  return l < 60 ? [u, o, f] = [n, a, 0] : l < 120 ? [u, o, f] = [a, n, 0] : l < 180 ? [u, o, f] = [0, n, a] : l < 240 ? [u, o, f] = [0, a, n] : l < 300 ? [u, o, f] = [a, 0, n] : [u, o, f] = [n, 0, a], {
    r: Math.round((u + $) * 255),
    g: Math.round((o + $) * 255),
    b: Math.round((f + $) * 255)
  };
}
function rn(l) {
  const h = /^#?([0-9a-f]{6})$/i.exec(l.trim()), t = /^#?([0-9a-f]{8})$/i.exec(l.trim());
  if (t) {
    const d = t[1];
    return {
      r: parseInt(d.slice(0, 2), 16),
      g: parseInt(d.slice(2, 4), 16),
      b: parseInt(d.slice(4, 6), 16),
      a: parseInt(d.slice(6, 8), 16) / 255
    };
  }
  if (h) {
    const d = parseInt(h[1], 16);
    return { r: d >> 16 & 255, g: d >> 8 & 255, b: d & 255, a: 1 };
  }
  return { r: 0, g: 0, b: 0, a: 1 };
}
function an(l, h, t, d, i) {
  const n = ($) => Math.max(0, Math.min(255, Math.round($))).toString(16).padStart(2, "0"), a = `#${n(l)}${n(h)}${n(t)}`;
  return i ? `${a}${n(d * 255)}` : a;
}
const on = Me(
  ({
    label: l,
    helperText: h,
    error: t,
    required: d,
    disabled: i,
    id: n,
    className: a,
    style: $,
    accessMode: u,
    displayStyle: o,
    value: f = "var(--nice-primary, #3b82f6)",
    onChange: D,
    presets: G = en,
    showInput: m = !0,
    showRandom: x = !0,
    withAlpha: R = !1,
    showKeyboardHints: p,
    size: Q = "md",
    labelPlacement: E,
    errorPlacement: k,
    labelWidth: S,
    controlWidth: g,
    loading: I
  }, V) => {
    const L = xe(u, n), A = L === "hidden";
    (L === "disabled" || L === "readOnly") && (i = !0);
    const { t: w } = Re(), B = Ie(n);
    $e("input", o);
    const K = ne(() => {
      i || D?.(nn());
    }, [i, D]), [F, O] = ue(!1), [re, se] = ue(null), z = Fe(null), X = Fe(null);
    qe(() => {
      if (!F || !X.current)
        return;
      const b = () => {
        const N = X.current?.getBoundingClientRect();
        if (!N)
          return;
        const j = 280, H = 360;
        let M = N.left, W = N.bottom + 6;
        M + j > window.innerWidth - 8 && (M = Math.max(8, window.innerWidth - j - 8)), W + H > window.innerHeight - 8 && (W = Math.max(8, N.top - H - 6)), se({ left: M, top: W });
      };
      return b(), window.addEventListener("scroll", b, !0), window.addEventListener("resize", b), () => {
        window.removeEventListener("scroll", b, !0), window.removeEventListener("resize", b);
      };
    }, [F]), ze(() => {
      if (!F)
        return;
      const b = (j) => {
        const H = j.target;
        z.current?.contains(H) || X.current?.contains(H) || O(!1);
      }, N = (j) => {
        j.key === "Escape" && O(!1);
      };
      return document.addEventListener("mousedown", b), document.addEventListener("keydown", N), () => {
        document.removeEventListener("mousedown", b), document.removeEventListener("keydown", N);
      };
    }, [F]);
    const pe = oe(
      () => [
        { key: "Enter", description: w("shortcuts.openPicker", "Open color picker") },
        { key: "Arrow keys", description: w("shortcuts.navigatePresets", "Navigate presets") }
      ],
      [w]
    );
    return A ? null : /* @__PURE__ */ _(
      "div",
      {
        className: `nice-field nice-field--${Q} ${E === "left" ? "nice-field--label-left" : ""} ${I ? "nice-field--loading" : ""} ${a || ""}`,
        style: {
          ...$,
          ...S != null && {
            "--nice-field-label-width": typeof S == "number" ? `${S}px` : S
          },
          ...g != null && {
            "--nice-field-control-width": typeof g == "number" ? `${g}px` : g
          }
        },
        "aria-busy": I || void 0,
        children: [
          l && /* @__PURE__ */ _(
            "label",
            {
              htmlFor: B,
              className: `nice-field__label ${d ? "nice-field__label--required" : ""}`,
              children: [
                l,
                p && /* @__PURE__ */ e(Ae, { shortcuts: pe, size: "sm" })
              ]
            }
          ),
          /* @__PURE__ */ e("div", { className: "nice-field__control", children: /* @__PURE__ */ _("div", { className: "nice-color-picker", children: [
            /* @__PURE__ */ _("div", { className: "nice-color-picker__preview-row", children: [
              /* @__PURE__ */ e(
                "div",
                {
                  ref: X,
                  className: "nice-color-picker__swatch",
                  id: B,
                  style: { background: f },
                  onClick: (b) => {
                    b.stopPropagation(), i || O((N) => !N);
                  },
                  onKeyDown: (b) => {
                    !i && (b.key === "Enter" || b.key === " ") && (b.preventDefault(), O((N) => !N));
                  },
                  role: "button",
                  tabIndex: 0,
                  "aria-label": w("colorPicker.openPalette", "Open color palette"),
                  "aria-haspopup": "dialog",
                  "aria-expanded": F,
                  children: /* @__PURE__ */ e(
                    "input",
                    {
                      ref: (b) => {
                        typeof V == "function" ? V(b) : V && (V.current = b);
                      },
                      type: "hidden",
                      value: f,
                      disabled: i,
                      readOnly: !0
                    }
                  )
                }
              ),
              m && /* @__PURE__ */ e("div", { className: "nice-input nice-input--sm", style: { width: 100 }, children: /* @__PURE__ */ e(
                "input",
                {
                  className: "nice-input__native",
                  type: "text",
                  value: f,
                  disabled: i,
                  onChange: (b) => D?.(b.target.value),
                  maxLength: 7
                }
              ) }),
              x && /* @__PURE__ */ e(
                "button",
                {
                  type: "button",
                  className: "nice-btn nice-btn--outline nice-btn--sm nice-color-picker__random",
                  onClick: K,
                  disabled: i,
                  title: w("colorPicker.random", "Random"),
                  "aria-label": w("colorPicker.random", "Random"),
                  style: {
                    fontSize: "0.65rem",
                    textTransform: "uppercase",
                    letterSpacing: "0.05em"
                  },
                  children: w("colorPicker.random", "Random")
                }
              ),
              I && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
              k === "right" && t && /* @__PURE__ */ e("div", { id: `${B}-error`, className: "nice-field__error", role: "alert", children: t }),
              k === "right" && !t && h && /* @__PURE__ */ e("div", { id: `${B}-helper`, className: "nice-field__helper", children: h })
            ] }),
            F && re && typeof document < "u" && Je.createPortal(
              /* @__PURE__ */ e(
                "div",
                {
                  ref: z,
                  className: "nice-color-picker__popup nice-color-picker__popup--portal",
                  role: "dialog",
                  "aria-label": w("colorPicker.palette", "Color palette"),
                  style: { position: "fixed", left: re.left, top: re.top },
                  onClick: (b) => b.stopPropagation(),
                  children: (() => {
                    const b = rn(f), N = { r: b.r, g: b.g, b: b.b }, j = R ? b.a : 1, H = tn(N.r, N.g, N.b), M = ln(N.r, N.g, N.b), W = (r, v, q, C = j) => D?.(an(r, v, q, C, R)), ae = (r, v, q) => W(r, v, q), he = (r, v, q) => {
                      const C = cn(r, v, q);
                      W(C.r, C.g, C.b);
                    }, J = (r, v, q) => {
                      const C = sn(r, v, q);
                      W(C.r, C.g, C.b);
                    }, Y = (r) => W(N.r, N.g, N.b, r), de = (r) => {
                      if (i)
                        return;
                      const v = r.currentTarget, q = (Z) => {
                        const P = v.getBoundingClientRect(), be = Math.max(0, Math.min(P.width, Z.clientX - P.left)), Ne = Math.max(0, Math.min(P.height, Z.clientY - P.top)), fe = Math.round(be / P.width * 100), Ce = 100 - Math.round(Ne / P.height * 100);
                        J(M.h, fe, Ce);
                      };
                      q(r);
                      const C = () => {
                        document.removeEventListener("pointermove", q), document.removeEventListener("pointerup", C);
                      };
                      document.addEventListener("pointermove", q), document.addEventListener("pointerup", C);
                    }, ie = `hsl(${M.h}, 100%, 50%)`;
                    return /* @__PURE__ */ _(Se, { children: [
                      /* @__PURE__ */ e("div", { className: "nice-color-picker__popup-header", children: /* @__PURE__ */ e(
                        "input",
                        {
                          type: "text",
                          className: "nice-input__native nice-color-picker__popup-hex",
                          value: f,
                          disabled: i,
                          onChange: (r) => D?.(r.target.value),
                          maxLength: R ? 9 : 7,
                          "aria-label": w("colorPicker.hexValue", "Hex value")
                        }
                      ) }),
                      /* @__PURE__ */ e(
                        "input",
                        {
                          type: "range",
                          min: 0,
                          max: 360,
                          value: M.h,
                          disabled: i,
                          onChange: (r) => J(Number(r.target.value), M.s, M.v),
                          className: "nice-color-picker__hue-slider",
                          "aria-label": w("colorPicker.hue", "Hue")
                        }
                      ),
                      /* @__PURE__ */ e(
                        "div",
                        {
                          className: "nice-color-picker__sv",
                          style: {
                            background: `linear-gradient(to top, var(--nice-text, #000), transparent), linear-gradient(to right, var(--nice-bg, #FFF), ${ie})`
                          },
                          onPointerDown: de,
                          role: "application",
                          "aria-label": w("colorPicker.svPalette", "Saturation/value palette"),
                          children: /* @__PURE__ */ e(
                            "span",
                            {
                              className: "nice-color-picker__sv-marker",
                              style: { left: `${M.s}%`, top: `${100 - M.v}%` }
                            }
                          )
                        }
                      ),
                      /* @__PURE__ */ _("div", { className: "nice-color-picker__sliders", children: [
                        /* @__PURE__ */ e("div", { className: "nice-color-picker__slider-col", children: ["h", "s", "l"].map((r) => {
                          const v = r === "h" ? 360 : 100, q = H[r], C = (Z) => he(
                            r === "h" ? Z : H.h,
                            r === "s" ? Z : H.s,
                            r === "l" ? Z : H.l
                          );
                          return /* @__PURE__ */ _("div", { className: "nice-color-picker__slider-row", children: [
                            /* @__PURE__ */ e("label", { className: "nice-color-picker__slider-label", children: r.toUpperCase() }),
                            /* @__PURE__ */ e(
                              "input",
                              {
                                type: "range",
                                min: 0,
                                max: v,
                                value: q,
                                disabled: i,
                                onChange: (Z) => C(Number(Z.target.value))
                              }
                            ),
                            /* @__PURE__ */ e(
                              "input",
                              {
                                type: "number",
                                min: 0,
                                max: v,
                                value: q,
                                disabled: i,
                                onChange: (Z) => C(Number(Z.target.value) || 0),
                                className: "nice-input__native nice-color-picker__slider-num"
                              }
                            )
                          ] }, r);
                        }) }),
                        /* @__PURE__ */ e("div", { className: "nice-color-picker__slider-col", children: ["r", "g", "b"].map((r) => {
                          const v = N[r], q = (C) => ae(
                            r === "r" ? C : N.r,
                            r === "g" ? C : N.g,
                            r === "b" ? C : N.b
                          );
                          return /* @__PURE__ */ _("div", { className: "nice-color-picker__slider-row", children: [
                            /* @__PURE__ */ e("label", { className: "nice-color-picker__slider-label", children: r.toUpperCase() }),
                            /* @__PURE__ */ e(
                              "input",
                              {
                                type: "range",
                                min: 0,
                                max: 255,
                                value: v,
                                disabled: i,
                                onChange: (C) => q(Number(C.target.value))
                              }
                            ),
                            /* @__PURE__ */ e(
                              "input",
                              {
                                type: "number",
                                min: 0,
                                max: 255,
                                value: v,
                                disabled: i,
                                onChange: (C) => q(Number(C.target.value) || 0),
                                className: "nice-input__native nice-color-picker__slider-num"
                              }
                            )
                          ] }, r);
                        }) })
                      ] }),
                      R && /* @__PURE__ */ _("div", { className: "nice-color-picker__alpha-row", children: [
                        /* @__PURE__ */ e("label", { className: "nice-color-picker__slider-label", children: "A" }),
                        /* @__PURE__ */ e(
                          "input",
                          {
                            type: "range",
                            min: 0,
                            max: 100,
                            value: Math.round(j * 100),
                            disabled: i,
                            onChange: (r) => Y(Number(r.target.value) / 100),
                            className: "nice-color-picker__alpha-slider",
                            style: {
                              background: `linear-gradient(to right, transparent, rgb(${N.r},${N.g},${N.b}))`
                            },
                            "aria-label": w("colorPicker.alpha", "Alpha")
                          }
                        ),
                        /* @__PURE__ */ e(
                          "input",
                          {
                            type: "number",
                            min: 0,
                            max: 100,
                            value: Math.round(j * 100),
                            disabled: i,
                            onChange: (r) => Y((Number(r.target.value) || 0) / 100),
                            className: "nice-input__native nice-color-picker__slider-num"
                          }
                        )
                      ] }),
                      G.length > 0 && /* @__PURE__ */ e("div", { className: "nice-color-picker__popup-presets", children: G.map((r) => /* @__PURE__ */ e(
                        "div",
                        {
                          className: `nice-color-picker__preset ${f === r ? "nice-color-picker__preset--active" : ""}`,
                          style: { background: r },
                          onClick: () => {
                            D?.(r), O(!1);
                          },
                          role: "button",
                          tabIndex: 0,
                          "aria-label": r,
                          onKeyDown: (v) => {
                            (v.key === "Enter" || v.key === " ") && (v.preventDefault(), D?.(r), O(!1));
                          }
                        },
                        r
                      )) })
                    ] });
                  })()
                }
              ),
              document.body
            )
          ] }) }),
          k !== "right" && t && /* @__PURE__ */ e("div", { id: `${B}-error`, className: "nice-field__error", role: "alert", children: t }),
          k !== "right" && !t && h && /* @__PURE__ */ e("div", { id: `${B}-helper`, className: "nice-field__helper", children: h })
        ]
      }
    );
  }
);
on.displayName = "NiceColorPicker";
const dn = Me(
  ({
    children: l,
    variant: h = "primary",
    size: t = "md",
    type: d = "button",
    disabled: i,
    loading: n,
    fullWidth: a,
    onClick: $,
    leftIcon: u,
    rightIcon: o,
    error: f,
    errorPlacement: D = "bottom",
    className: G,
    style: m,
    id: x,
    accessMode: R,
    displayStyle: p,
    ...Q
  }, E) => {
    const k = xe(R, x), S = k === "hidden";
    (k === "disabled" || k === "readOnly") && (i = !0);
    const g = He("button", p), I = $e("button", p), V = h !== "primary" ? (({ background: w, color: B, ...K }) => K)(
      g
    ) : g, L = /* @__PURE__ */ _(
      "button",
      {
        ref: E,
        type: d,
        id: x,
        className: `nice-btn nice-btn--${h} nice-btn--${t} nice-btn--ds-${I} ${a ? "nice-btn--full-width" : ""} ${n ? "nice-btn--loading" : ""} ${f && !D ? "nice-btn--has-error" : ""} ${G || ""}`,
        style: { ...V, ...m },
        disabled: i || n,
        "aria-busy": n || void 0,
        "aria-disabled": i || n || void 0,
        onClick: $,
        ...Q,
        children: [
          n && /* @__PURE__ */ e(
            "svg",
            {
              className: "nice-btn__spinner",
              viewBox: "0 0 24 24",
              fill: "none",
              stroke: "currentColor",
              strokeWidth: "3",
              "aria-hidden": "true",
              children: /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10", strokeDasharray: "31.4 31.4", strokeLinecap: "round" })
            }
          ),
          !n && u && /* @__PURE__ */ e("span", { "aria-hidden": "true", children: u }),
          !n && /* @__PURE__ */ e("span", { children: l }),
          n && /* @__PURE__ */ e("span", { style: { visibility: "hidden" }, "aria-hidden": "true", children: l }),
          !n && o && /* @__PURE__ */ e("span", { "aria-hidden": "true", children: o })
        ]
      }
    );
    if (S)
      return null;
    if (!f)
      return L;
    const A = /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: f });
    return D === "right" ? /* @__PURE__ */ _(
      "span",
      {
        className: `nice-btn-field nice-btn-field--right nice-field--${t}`,
        style: {
          display: "inline-flex",
          flexDirection: "row",
          alignItems: "center",
          gap: "8px",
          width: "fit-content"
        },
        children: [
          L,
          A
        ]
      }
    ) : S ? null : /* @__PURE__ */ _(
      "span",
      {
        className: `nice-btn-field nice-btn-field--bottom nice-field--${t}`,
        style: {
          display: "inline-flex",
          flexDirection: "column",
          alignItems: "flex-start",
          gap: "4px",
          width: "fit-content"
        },
        children: [
          L,
          A
        ]
      }
    );
  }
);
dn.displayName = "NiceButton";
const mn = ({
  tabs: l,
  activeTab: h,
  onChange: t,
  variant: d = "default",
  vertical: i,
  size: n = "md",
  className: a,
  style: $,
  displayStyle: u
}) => {
  const o = He("tab", u), f = $e("tab", u), [D, G] = ue(h || l[0]?.id), m = h ?? D, x = ne(
    (p) => {
      G(p), t?.(p);
    },
    [t]
  ), R = l.find((p) => p.id === m)?.content;
  return /* @__PURE__ */ _(
    "div",
    {
      className: `nice-tabs nice-tabs--${n} nice-tabs--ds-${f} ${a || ""}`,
      style: { ...o, ...$, ...i ? { display: "flex", gap: 16 } : {} },
      children: [
        /* @__PURE__ */ e(
          "div",
          {
            className: `nice-tabs__list ${d !== "default" ? `nice-tabs__list--${d}` : ""} ${i ? "nice-tabs__list--vertical" : ""}`,
            role: "tablist",
            children: l.map((p) => /* @__PURE__ */ _(
              "button",
              {
                type: "button",
                role: "tab",
                "aria-selected": m === p.id,
                className: `nice-tabs__tab ${m === p.id ? "nice-tabs__tab--active" : ""} ${p.disabled ? "nice-tabs__tab--disabled" : ""}`,
                disabled: p.disabled,
                onClick: () => x(p.id),
                children: [
                  p.icon,
                  /* @__PURE__ */ e("span", { children: p.label }),
                  p.badge !== void 0 && /* @__PURE__ */ e("span", { className: "nice-tabs__badge", children: p.badge })
                ]
              },
              p.id
            ))
          }
        ),
        R && /* @__PURE__ */ e("div", { className: "nice-tabs__panel", role: "tabpanel", children: R })
      ]
    }
  );
};
export {
  Oe as N,
  on as a,
  Ze as b,
  Pe as c,
  Qe as d,
  We as e,
  mn as f,
  dn as g
};
