import { o as G } from "./rolldown-runtime.js";
import { i as L, t as M } from "./vendor/react.js";
import { n as $, t as k } from "./spinner.js";
import { t as d } from "./utils.js";
import { t as H } from "./FieldTooltip.js";
import { n as J, t as K } from "./field-props.js";
import { t as S } from "./Input.js";
import { a as Q, c as U, i as V, l as W, n as X, o as Y, r as Z, s as A, t as ee } from "./Field.js";
var q = /* @__PURE__ */ G(L(), 1), e = M(), P = {
  xs: "h-[26px] px-3 py-0.5 text-sm",
  sm: "h-8 px-3 py-1 text-sm",
  md: "h-9 px-3 py-1 text-base md:text-sm",
  lg: "h-10 px-3 py-1 text-base"
}, se = {
  rounded: "rounded-xl",
  round: "rounded-full"
}, re = {
  default: "",
  success: "border-success ring-success/20 ring-[3px]",
  destructive: "border-destructive ring-destructive/20 ring-[3px]"
}, T = {
  xs: "[&>svg]:size-4",
  sm: "[&>svg]:size-4",
  md: "[&>svg]:size-5",
  lg: "[&>svg]:size-5"
}, C = q.forwardRef(({ className: p, type: l, state: s = "default", shape: v = "rounded", startIcon: c, endIcon: x, startAddon: u, endAddon: o, hasOutline: f, size: r = "md", disabled: t, appearance: a = "default", animated: j, loading: i, onFocus: n, onBlur: m, ...b }, h) => {
  const g = a === "ai", [z, I] = q.useState(!1), B = g ? j ?? i : !1, E = g ? (F) => {
    I(!0), n?.(F);
  } : n, D = g ? (F) => {
    I(!1), m?.(F);
  } : m;
  if (g) return /* @__PURE__ */ (0, e.jsx)($, {
    animated: B,
    focused: z,
    disabled: t,
    className: d("motion-reduce:animate-none", p),
    children: /* @__PURE__ */ (0, e.jsxs)("div", {
      "data-slot": "input",
      className: "relative flex items-center w-full",
      children: [/* @__PURE__ */ (0, e.jsx)("input", {
        ref: h,
        type: l,
        disabled: t,
        onFocus: E,
        onBlur: D,
        className: d("w-full bg-transparent outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50", P[r], i && "pe-10"),
        ...b
      }), i && /* @__PURE__ */ (0, e.jsx)("span", {
        className: "absolute end-3 top-1/2 -translate-y-1/2 text-quaternary-foreground",
        "aria-hidden": "true",
        children: /* @__PURE__ */ (0, e.jsx)(k, { className: "motion-reduce:animate-none" })
      })]
    })
  });
  const y = u || o, N = !!c, w = !!x, O = N || w || y, R = s === "destructive", _ = d("bg-extra-shadow border-input focus-visible:border-ring focus-visible:ring-ring/50 border shadow-xs transition-[color,box-shadow] duration-200 ease-smooth motion-reduce:transition-none file:h-7 file:text-sm file:font-medium focus-visible:ring-[3px] file:text-foreground placeholder:text-muted-foreground w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 disabled:bg-muted read-only:bg-muted read-only:border-border read-only:cursor-default", P[r], se[v], re[s], f && "border-border ring-1 ring-border focus-visible:ring-2 focus-visible:ring-ring", N && "ps-11", w && "pe-11", y && u && "rounded-s-none", y && o && "rounded-e-none");
  return O ? /* @__PURE__ */ (0, e.jsxs)("div", {
    "data-slot": "input",
    "data-state": s,
    className: d("relative flex", p),
    children: [
      u && /* @__PURE__ */ (0, e.jsx)("span", {
        className: "inline-flex items-center rounded-s-xl border border-e-0 border-border bg-muted px-3 text-base text-muted-foreground",
        children: u
      }),
      /* @__PURE__ */ (0, e.jsxs)("div", {
        className: "relative flex-1",
        children: [
          N && /* @__PURE__ */ (0, e.jsx)("span", {
            className: d("absolute start-3.5 top-1/2 -translate-y-1/2 text-quaternary-foreground pointer-events-none", T[r]),
            children: c
          }),
          /* @__PURE__ */ (0, e.jsx)(S, {
            ref: h,
            type: l,
            "data-slot": "input-element",
            "data-state": s,
            "aria-invalid": R || void 0,
            disabled: t,
            onFocus: n,
            onBlur: m,
            className: _,
            ...b
          }),
          w && /* @__PURE__ */ (0, e.jsx)("span", {
            className: d("absolute end-3.5 top-1/2 -translate-y-1/2 text-quaternary-foreground pointer-events-none", T[r]),
            children: x
          })
        ]
      }),
      o && /* @__PURE__ */ (0, e.jsx)("span", {
        className: "inline-flex items-center rounded-e-xl border border-s-0 border-border bg-muted px-3 text-base text-muted-foreground",
        children: o
      })
    ]
  }) : /* @__PURE__ */ (0, e.jsx)(S, {
    ref: h,
    type: l,
    "data-slot": "input",
    "data-state": s,
    "aria-invalid": R || void 0,
    disabled: t,
    onFocus: n,
    onBlur: m,
    className: d(_, p),
    ...b
  });
});
C.displayName = "InputControl";
var te = q.forwardRef((p, l) => {
  const [s, v] = J(p);
  if (!K(s)) return /* @__PURE__ */ (0, e.jsx)(C, {
    ref: l,
    ...v,
    required: s.required
  });
  const { label: c, required: x, labelIcon: u, tooltip: o, topRight: f, description: r, bottomRight: t, error: a, fieldClassName: j } = s, i = v, n = a ? "destructive" : i.state, m = c || f, b = r || t || a;
  return /* @__PURE__ */ (0, e.jsxs)(ee, {
    state: n,
    disabled: i.disabled,
    className: j,
    children: [
      m && /* @__PURE__ */ (0, e.jsxs)(U, { children: [c && /* @__PURE__ */ (0, e.jsxs)(A, {
        required: x,
        labelIcon: u,
        children: [c, o && /* @__PURE__ */ (0, e.jsx)(H, { content: o })]
      }), f && /* @__PURE__ */ (0, e.jsx)(W, { children: f })] }),
      /* @__PURE__ */ (0, e.jsx)(V, { children: (h) => /* @__PURE__ */ (0, e.jsx)(C, {
        ref: l,
        ...i,
        ...h,
        required: x,
        state: n
      }) }),
      b && /* @__PURE__ */ (0, e.jsxs)(X, { children: [
        a && /* @__PURE__ */ (0, e.jsx)(Y, { children: a }),
        !a && r && /* @__PURE__ */ (0, e.jsx)(Q, { children: r }),
        t && /* @__PURE__ */ (0, e.jsx)(Z, {
          className: "ms-auto",
          children: t
        })
      ] })
    ]
  });
});
te.displayName = "Input";
export {
  re as n,
  te as t
};

//# sourceMappingURL=Input2.js.map