import { jsxs as c, jsx as e, Fragment as E } from "react/jsx-runtime";
import { useState as R, useCallback as z } from "react";
import { InputContainer as T, AffixContainer as A, BadgeContainer as I, BaseInput as U } from "./InputPrimitive.js";
import V from "../label/Label.js";
import { c as t } from "../../index-BtlgVD4m.js";
import S from "../icon/components/icon-extend/IconExtend.js";
import W from "../icon/Icon.js";
import X from "../error-message/ErrorMessage.js";
const Y = ({
  ref: g,
  layout: j = "vertical",
  label: o,
  id: f,
  type: a = "text",
  value: k,
  inputMode: B = "text",
  description: x,
  disabled: p = !1,
  readOnly: u = !1,
  name: F,
  placeholder: O,
  onChange: r,
  onFocus: P,
  onBlur: D,
  leftIcon: v,
  rightIcon: N,
  prefix: d,
  suffix: n,
  maxLength: L,
  autoComplete: q,
  errorMessage: m,
  notice: s,
  isNoticeRight: b = !1,
  size: y = "default",
  isError: G,
  ...H
}) => {
  const [h, J] = R(null), w = u && !p, l = p || u, K = z(
    (i) => {
      a === "file" ? r == null || r(i.target.files) : r == null || r(i.target.value);
    },
    [r, a]
  ), Q = z(() => {
    J((i) => i === null ? "text" : null);
  }, []);
  return /* @__PURE__ */ c(
    "div",
    {
      className: t("flex", "relative", j === "horizontal" ? "flex-row items-center gap-[var(--spacing-2)]" : "flex-col gap-[var(--spacing-2)]"),
      children: [
        o && /* @__PURE__ */ e(V, { htmlFor: f, variant: "field", className: t(!!m && "text-[var(--base-danger-text)]"), children: o }),
        /* @__PURE__ */ c(
          T,
          {
            error: !!m || G,
            readOnly: w,
            className: t(
              "flex items-center",
              a === "file" && "p-0",
              d && "pl-0",
              n && "pr-0",
              l && "pointer-events-none"
            ),
            size: y,
            children: [
              a !== "file" && /* @__PURE__ */ c(E, { children: [
                d && /* @__PURE__ */ e(A, { text: d }),
                s && !b && /* @__PURE__ */ e("div", { className: t("flex items-center"), children: /* @__PURE__ */ e(I, { text: s }) }),
                v && /* @__PURE__ */ e("div", { className: t("flex items-center text-[var(--base-muted-foreground)]"), children: /* @__PURE__ */ e(S, { icon: v, size: 16 }) })
              ] }),
              /* @__PURE__ */ e(
                U,
                {
                  ref: g,
                  id: f,
                  type: h || a,
                  name: F,
                  inputMode: B,
                  disabled: l,
                  className: t(w && "disabled:cursor-default disabled:opacity-100"),
                  placeholder: O,
                  maxLength: L,
                  autoComplete: q,
                  onChange: K,
                  onFocus: P,
                  onBlur: D,
                  ...a !== "file" && { value: k },
                  ...H
                }
              ),
              a === "password" && /* @__PURE__ */ e(
                "div",
                {
                  className: t("text-inherit", !l && "cursor-pointer"),
                  onClick: l ? void 0 : Q,
                  children: /* @__PURE__ */ e(W, { name: h === "text" ? "Eye" : "EyeOff", size: 16 })
                }
              ),
              a !== "file" && /* @__PURE__ */ c(E, { children: [
                N && /* @__PURE__ */ e("div", { className: t("flex items-center text-[var(--base-muted-foreground)]"), children: /* @__PURE__ */ e(S, { icon: N, size: 16 }) }),
                s && b && /* @__PURE__ */ e("div", { className: t("flex items-center"), children: /* @__PURE__ */ e(I, { text: s }) }),
                n && /* @__PURE__ */ e(A, { text: n, isSuffix: !0 })
              ] })
            ]
          }
        ),
        x && /* @__PURE__ */ e("div", { className: "flex text-sm", children: /* @__PURE__ */ e("p", { className: "text-[var(--base-muted-foreground)]", children: x }) }),
        /* @__PURE__ */ e(X, { message: m })
      ]
    }
  );
};
Y.displayName = "Input";
export {
  Y as default
};
//# sourceMappingURL=Input.js.map
