"use client";
import { jsx as s, jsxs as O, Fragment as $ } from "react/jsx-runtime";
import P, { createContext as T, Children as _, isValidElement as E, useContext as V, forwardRef as m, cloneElement as H, useId as J, useMemo as Q } from "react";
import { c as l } from "./cn-ct4n7r74mh8y0f48.js";
import { I as W, i as A } from "./input-lpa5fc75tgrraafv.js";
import { F as C } from "./field-lnj619xpe8zjd26r.js";
import { B as X } from "./button-6by9ntsa3nj553mq.js";
import { T as Y } from "./tooltip-odudhkxe282wxinq.js";
const G = {
  xs: {
    inputOuter: "px-1.5",
    addonOuterStart: "pl-1.5",
    addonOuterEnd: "pr-1.5",
    addonButtonOuterStart: "pl-1",
    addonButtonOuterEnd: "pr-1",
    suffixPad: "pr-1.5",
    fontSize: "text-xs",
    iconSize: 10
  },
  sm: {
    inputOuter: "px-2",
    addonOuterStart: "pl-1.5",
    addonOuterEnd: "pr-1.5",
    addonButtonOuterStart: "pl-1",
    addonButtonOuterEnd: "pr-1",
    suffixPad: "pr-2",
    fontSize: "text-xs",
    iconSize: 13
  },
  base: {
    inputOuter: "px-3",
    addonOuterStart: "pl-2",
    addonOuterEnd: "pr-2",
    addonButtonOuterStart: "pl-1",
    addonButtonOuterEnd: "pr-1",
    suffixPad: "pr-3",
    fontSize: "text-base",
    iconSize: 18
  },
  lg: {
    inputOuter: "px-4",
    addonOuterStart: "pl-2.5",
    addonOuterEnd: "pr-2.5",
    addonButtonOuterStart: "pl-1.5",
    addonButtonOuterEnd: "pr-1.5",
    suffixPad: "pr-4",
    fontSize: "text-base",
    iconSize: 20
  }
}, U = {
  xs: [
    "has-[[data-slot=input-group-addon-start]]:[&_input]:pl-1",
    "has-[[data-slot=input-group-addon-end]]:[&_input]:pr-1"
  ].join(" "),
  sm: [
    "has-[[data-slot=input-group-addon-start]]:[&_input]:pl-1.5",
    "has-[[data-slot=input-group-addon-end]]:[&_input]:pr-1.5"
  ].join(" "),
  base: [
    "has-[[data-slot=input-group-addon-start]]:[&_input]:pl-2",
    "has-[[data-slot=input-group-addon-end]]:[&_input]:pr-2"
  ].join(" "),
  lg: [
    "has-[[data-slot=input-group-addon-start]]:[&_input]:pl-2.5",
    "has-[[data-slot=input-group-addon-end]]:[&_input]:pr-2.5"
  ].join(" ")
}, N = T(
  null
), j = T(!1);
function S(t) {
  const n = V(N);
  return process.env.NODE_ENV !== "production" && !n && console.warn(
    `<InputGroup.${t}> must be used within <InputGroup>. Falling back to default values.`
  ), n;
}
function q(t) {
  const n = [], o = [];
  return _.forEach(t, (e) => {
    E(e) && e.type?.displayName === "InputGroup.Button" ? o.push(e) : n.push(e);
  }), { containerZone: n, individualZone: o };
}
function tt(t) {
  let n = !1, o = !1;
  return _.forEach(t, (e) => {
    if (!E(e)) return;
    const i = e.type, u = typeof i == "function" || typeof i == "object" ? i.displayName : void 0;
    if (u === "InputGroup.Addon") {
      o = !0;
      return;
    }
    if (u !== "InputGroup.Button") return;
    const r = e.props.variant;
    r !== void 0 && r !== "ghost" && (n = !0);
  }), n && o ? "hybrid" : n ? "individual" : "container";
}
const D = m(
  (t, n) => {
    const o = S("Input");
    process.env.NODE_ENV !== "production" && o && (t.size !== void 0 && console.warn(
      "InputGroup.Input: Set `size` on <InputGroup> instead of <InputGroup.Input>."
    ), t.disabled !== void 0 && console.warn(
      "InputGroup.Input: Set `disabled` on <InputGroup> instead of <InputGroup.Input>."
    ), t.label !== void 0 && console.warn(
      "InputGroup.Input: Use the `label` prop on <InputGroup> instead of <InputGroup.Input>."
    ), t.description !== void 0 && console.warn(
      "InputGroup.Input: Use <InputGroup.Suffix> instead of passing `description` to <InputGroup.Input>."
    ));
    const e = o?.size ?? "base", i = G[e], u = o?.focusMode === "individual", r = !!o?.error, a = t.id ?? o?.inputId;
    return /* @__PURE__ */ s(
      W,
      {
        ref: n,
        size: o?.size,
        disabled: o?.disabled || t.disabled,
        "aria-invalid": r || t["aria-invalid"],
        ...t,
        id: a,
        className: l(
          // Base input layout: fill height, allow shrinking, strip native border/radius
          "flex h-full min-w-0 grow items-center rounded-none border-0 bg-transparent font-sans",
          // Always use full outer padding — the container's has-[] rules reduce
          // pl/pr to inputSeam on sides that touch an addon.
          i.inputOuter,
          // Truncate overflowing text with "…" instead of expanding the input
          "text-ellipsis",
          // Individual mode: each element owns its own border instead of sharing a container ring
          u ? [
            // Own border replaces the container's shared ring
            "relative ring-0 border border-kumo-line",
            // Inherit border-radius only on outer edges; inner edges are flat
            "first:rounded-l-[inherit] last:rounded-r-[inherit]",
            // Collapse double borders between adjacent elements
            "not-first:border-l-0",
            // Hovered element renders above idle siblings to show full border
            "hover:z-[1] hover:border-kumo-line",
            // Focused element renders above hovered siblings for focus indicator
            "focus:z-[2] focus:border-kumo-line focus:outline focus:-outline-offset-1"
          ].join(" ") : (
            // Container mode: kill all focus indicators — the container handles them
            // z-[1] lifts the input above the invisible label overlay so cursor/selection work
            "relative z-[1] ring-0! shadow-none outline-none focus:ring-0! focus:outline-none"
          ),
          t.className
        )
      }
    );
  }
);
D.displayName = "InputGroup.Input";
const nt = {
  xs: "xs",
  sm: "xs",
  base: "sm",
  lg: "base"
}, w = m(
  ({
    children: t,
    className: n,
    variant: o,
    size: e,
    disabled: i,
    tooltip: u,
    tooltipSide: r = "bottom",
    icon: a,
    ...f
  }, p) => {
    const d = S("Button"), x = V(j), c = i ?? d?.disabled, b = d?.focusMode === "individual" || d?.focusMode === "hybrid", h = o ?? "ghost";
    process.env.NODE_ENV !== "production" && d && h === "ghost" && !x && console.warn(
      "InputGroup.Button: Ghost buttons should be wrapped in <InputGroup.Addon> for correct spacing."
    ), process.env.NODE_ENV !== "production" && d && e !== void 0 && console.warn(
      "InputGroup.Button: Set `size` on <InputGroup> instead of <InputGroup.Button>."
    );
    const v = typeof u == "string" && !f["aria-label"] ? u : void 0, I = d ? G[d.size ?? "base"].iconSize : void 0, g = a && I && (typeof a == "function" || typeof a == "object" && a !== null && !P.isValidElement(a)) ? P.createElement(a, {
      size: I
    }) : a, z = /* @__PURE__ */ s(
      X,
      {
        ref: p,
        type: "button",
        disabled: c,
        "aria-label": v,
        ...f,
        icon: g,
        variant: o ?? "ghost",
        size: e ?? (b ? d?.size ?? "sm" : nt[d?.size ?? "base"] ?? "sm"),
        className: l(
          // Ensure clicks register even when parent has pointer-events-none (e.g. disabled overlay)
          "pointer-events-auto",
          // Individual mode: each button owns its own border and focus indicator
          b && [
            // Own border replaces the container's shared ring; force full height
            "relative h-full! rounded-none ring-0 border border-kumo-line",
            // Inherit border-radius only on outer edges; inner edges are flat
            "first:rounded-l-[inherit] last:rounded-r-[inherit]",
            // Collapse double borders between adjacent elements
            "not-first:border-l-0",
            // Hovered element renders above idle siblings to show full border
            "hover:z-[1]",
            // Focused element renders above hovered siblings for focus indicator
            "focus:z-[2] focus:border-kumo-line focus:outline focus:-outline-offset-1",
            // Suppress the base Button's focus ring so only our outline shows
            "focus-visible:ring-2 focus-visible:ring-kumo-focus",
            // Match the group's disabled visual treatment
            "disabled:bg-kumo-overlay disabled:text-kumo-inactive!"
          ],
          n
        ),
        children: t
      }
    );
    return u ? /* @__PURE__ */ s(Y, { content: u, side: r, asChild: !0, children: z }) : z;
  }
);
w.displayName = "InputGroup.Button";
const y = m(
  ({ align: t = "start", className: n, children: o }, e) => {
    const u = S("Addon")?.size ?? "base", r = G[u];
    let a = !1;
    const f = _.map(o, (p) => E(p) ? p.type === w ? (a = !0, p) : p.props.size !== void 0 ? p : H(p, {
      size: r.iconSize
    }) : p);
    return /* @__PURE__ */ s(
      "div",
      {
        ref: e,
        "data-slot": t === "start" ? "input-group-addon-start" : "input-group-addon-end",
        className: l(
          "relative z-[1] pointer-events-none flex shrink-0 items-center gap-1.5",
          "text-kumo-subtle",
          r.fontSize,
          "*:pointer-events-auto",
          t === "start" ? l(
            "-order-1",
            a ? r.addonButtonOuterStart : r.addonOuterStart,
            "pr-0"
          ) : l(
            "order-1",
            "pl-0",
            a ? r.addonButtonOuterEnd : r.addonOuterEnd
          ),
          n
        ),
        children: /* @__PURE__ */ s(j.Provider, { value: !0, children: f })
      }
    );
  }
);
y.displayName = "InputGroup.Addon";
const B = m(
  ({ className: t, children: n }, o) => {
    const i = S("Suffix")?.size ?? "base", u = G[i];
    return /* @__PURE__ */ s(
      "div",
      {
        ref: o,
        "data-slot": "input-group-suffix",
        className: l(
          "pointer-events-none flex min-w-0 grow select-none items-center text-kumo-subtle",
          u.fontSize,
          u.suffixPad,
          t
        ),
        children: /* @__PURE__ */ s("span", { className: "truncate", children: n })
      }
    );
  }
);
B.displayName = "InputGroup.Suffix";
const dt = {
  size: {
    xs: {
      classes: "h-6 text-xs",
      description: "Extra small size."
    },
    sm: {
      classes: "h-7 text-xs",
      description: "Small size."
    },
    base: {
      classes: "h-9 text-base",
      description: "Default size."
    },
    lg: {
      classes: "h-11 text-base",
      description: "Large size."
    }
  }
}, pt = {
  size: "base"
}, M = m(
  ({
    size: t = "base",
    children: n,
    className: o,
    disabled: e = !1,
    label: i,
    description: u,
    error: r,
    required: a,
    labelTooltip: f,
    ...p
  }, d) => {
    const x = J(), c = tt(n), b = Q(
      () => ({
        size: t,
        focusMode: c,
        disabled: e,
        error: r,
        inputId: x
      }),
      [t, c, e, r, x]
    ), h = l(
      // Establish positioning context and make the whole area a click target
      "relative w-full cursor-text",
      // inputVariants provides base ring-kumo-line; must come before state overrides
      A({ size: t }),
      // Subtle drop shadow to separate the group from the page surface
      "shadow-xs",
      // Disabled state: prevent interaction and dim the entire group
      "data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
      // Container mode: clip children to rounded corners and show a shared focus ring
      // Individual mode: disable container ring/shadow so each child owns its own border
      c === "container" ? [
        "overflow-hidden",
        // Focus state must come AFTER inputVariants to override ring-kumo-line
        "focus-within:ring-kumo-focus"
      ] : (
        // isolate creates a new stacking context so z-index in children doesn't leak out
        "isolate overflow-visible ring-0 shadow-none"
      ),
      // Error state must also come after inputVariants
      "has-[input[aria-invalid=true]]:ring-kumo-danger",
      // Reset horizontal padding — children handle their own spacing
      "px-0",
      // Horizontal layout with no gap — children control their own internal spacing
      "flex items-center gap-0",
      // When a suffix is present, let the input shrink to its content width
      // so the suffix stays visually adjacent
      "has-[[data-slot=input-group-suffix]]:[&_input]:[field-sizing:content]",
      "has-[[data-slot=input-group-suffix]]:[&_input]:max-w-full",
      "has-[[data-slot=input-group-suffix]]:[&_input]:grow-0",
      "has-[[data-slot=input-group-suffix]]:[&_input]:pr-0",
      // Size-specific padding adjustments when addons or suffixes are present
      U[t],
      // Reset bottom margin to avoid inherited spacing from parent <label> styles
      "!mb-0",
      o
    ), v = {
      "data-slot": "input-group",
      "data-focus-mode": c,
      "data-disabled": e ? "" : void 0
    };
    if (c === "hybrid") {
      const { containerZone: z, individualZone: Z } = q(n), R = {
        ...b,
        focusMode: "container"
      }, K = /* @__PURE__ */ O($, { children: [
        /* @__PURE__ */ s(N.Provider, { value: R, children: /* @__PURE__ */ O(
          "div",
          {
            "data-slot": "input-group-container-zone",
            className: l(
              // Base input sizing/shape from shared variant function
              A({ size: t }),
              // Clip children to rounded corners within the zone
              "overflow-hidden",
              // Show red ring on validation error
              "has-[input[aria-invalid=true]]:ring-kumo-danger",
              // Reset horizontal padding — children handle their own spacing
              "px-0",
              // Fill available width but allow shrinking when sibling buttons are present
              "flex min-w-0 flex-1 items-center gap-0",
              // Use a clean 1px CSS border instead of ring+shadow from inputVariants
              // so the zone matches adjacent individual-mode buttons exactly.
              "ring-0 shadow-none",
              "border border-kumo-line",
              "focus-within:ring-1 focus-within:ring-kumo-focus",
              // Collapse double borders between zone and adjacent individual-mode button
              "not-first:border-l-0",
              // Inherit border-radius from the outer container on outer edges only;
              // inner edges are flat so they butt cleanly against sibling buttons
              "first:rounded-l-[inherit] last:rounded-r-[inherit] rounded-none",
              // Size-specific padding adjustments when addons or suffixes are present
              U[t],
              // When a suffix is present, let the input shrink to its content width
              "has-[[data-slot=input-group-suffix]]:[&_input]:[field-sizing:content]",
              "has-[[data-slot=input-group-suffix]]:[&_input]:max-w-full",
              "has-[[data-slot=input-group-suffix]]:[&_input]:grow-0",
              "has-[[data-slot=input-group-suffix]]:[&_input]:pr-0"
            ),
            children: [
              i && // eslint-disable-next-line jsx-a11y/label-has-associated-control -- invisible overlay for click-to-focus; the visible Field label handles a11y
              /* @__PURE__ */ s(
                "label",
                {
                  htmlFor: x,
                  className: "absolute inset-0 z-0 cursor-text !mb-0",
                  "aria-hidden": "true"
                }
              ),
              z
            ]
          }
        ) }),
        Z
      ] }), k = /* @__PURE__ */ s(N.Provider, { value: b, children: /* @__PURE__ */ s(
        "div",
        {
          ref: d,
          ...v,
          className: h,
          ...p,
          children: K
        }
      ) });
      return i ? /* @__PURE__ */ s(
        C,
        {
          label: i,
          description: u,
          error: r,
          required: a,
          labelTooltip: f,
          children: k
        }
      ) : k;
    }
    const I = !i && c === "container", g = /* @__PURE__ */ s(N.Provider, { value: b, children: i ? /* @__PURE__ */ O(
      "div",
      {
        ref: d,
        ...v,
        className: h,
        ...p,
        children: [
          /* @__PURE__ */ s(
            "label",
            {
              htmlFor: x,
              className: "absolute inset-0 z-0 !mb-0",
              "aria-hidden": "true"
            }
          ),
          n
        ]
      }
    ) : I ? (
      // Standalone container mode: <label> enables click-to-focus on empty space.
      /* @__PURE__ */ s(
        "label",
        {
          ref: d,
          ...v,
          className: l(h, "!mb-0"),
          ...p,
          children: n
        }
      )
    ) : (
      // Individual mode: <div> avoids :hover propagating to the first labelable sibling.
      /* @__PURE__ */ s(
        "div",
        {
          ref: d,
          ...v,
          className: h,
          ...p,
          children: n
        }
      )
    ) });
    return i ? /* @__PURE__ */ s(
      C,
      {
        label: i,
        description: u,
        error: r,
        required: a,
        labelTooltip: f,
        children: g
      }
    ) : g;
  }
);
M.displayName = "InputGroup";
const F = m((t, n) => /* @__PURE__ */ s(y, { ref: n, align: "start", ...t }));
F.displayName = "InputGroup.Label";
const L = m((t, n) => /* @__PURE__ */ s(B, { ref: n, ...t }));
L.displayName = "InputGroup.Description";
const lt = Object.assign(M, {
  Input: D,
  Button: w,
  Addon: y,
  Suffix: B,
  /** @deprecated Use `InputGroup.Addon` instead. */
  Label: F,
  /** @deprecated Use `InputGroup.Suffix` instead. */
  Description: L
});
export {
  lt as I,
  dt as K,
  pt as a
};
//# sourceMappingURL=input-group-dh4pg8p20rh4mdi0.js.map
