import { $ as I } from "./mergeProps-B-cqsBhL.es.js";
import { $ as E } from "./filterDOMProps-Cxz9cAAv.es.js";
import { $ as M } from "./useFormReset-Dl03QHFW.es.js";
import { $ as S } from "./useControlledState-3TGZUXux.es.js";
import V, { useState as D } from "react";
import { $ as R } from "./useField-BxLfE_kx.es.js";
import { $ as q } from "./useFocusable-C4Re42UX.es.js";
import { $ as B, a as L } from "./useFormValidation-Cx9rG8-b.es.js";
function j(e, a) {
  let { inputElementType: u = "input", isDisabled: c = !1, isRequired: n = !1, isReadOnly: f = !1, type: m = "text", validationBehavior: r = "aria" } = e, [t, l] = S(e.value, e.defaultValue || "", e.onChange), { focusableProps: $ } = q(e, a), d = B({
    ...e,
    value: t
  }), { isInvalid: i, validationErrors: s, validationDetails: b } = d.displayValidation, { labelProps: v, fieldProps: C, descriptionProps: P, errorMessageProps: h } = R({
    ...e,
    isInvalid: i,
    errorMessage: e.errorMessage || s
  }), y = E(e, {
    labelable: !0
  });
  const g = {
    type: m,
    pattern: e.pattern
  };
  let [p] = D(t);
  var o;
  return M(a, (o = e.defaultValue) !== null && o !== void 0 ? o : p, l), L(e, d, a), {
    labelProps: v,
    inputProps: I(y, u === "input" ? g : void 0, {
      disabled: c,
      readOnly: f,
      required: n && r === "native",
      "aria-required": n && r === "aria" || void 0,
      "aria-invalid": i || void 0,
      "aria-errormessage": e["aria-errormessage"],
      "aria-activedescendant": e["aria-activedescendant"],
      "aria-autocomplete": e["aria-autocomplete"],
      "aria-haspopup": e["aria-haspopup"],
      "aria-controls": e["aria-controls"],
      value: t,
      onChange: (x) => l(x.target.value),
      autoComplete: e.autoComplete,
      autoCapitalize: e.autoCapitalize,
      maxLength: e.maxLength,
      minLength: e.minLength,
      name: e.name,
      form: e.form,
      placeholder: e.placeholder,
      inputMode: e.inputMode,
      autoCorrect: e.autoCorrect,
      spellCheck: e.spellCheck,
      [parseInt(V.version, 10) >= 17 ? "enterKeyHint" : "enterkeyhint"]: e.enterKeyHint,
      // Clipboard events
      onCopy: e.onCopy,
      onCut: e.onCut,
      onPaste: e.onPaste,
      // Composition events
      onCompositionEnd: e.onCompositionEnd,
      onCompositionStart: e.onCompositionStart,
      onCompositionUpdate: e.onCompositionUpdate,
      // Selection events
      onSelect: e.onSelect,
      // Input events
      onBeforeInput: e.onBeforeInput,
      onInput: e.onInput,
      ...$,
      ...C
    }),
    descriptionProps: P,
    errorMessageProps: h,
    isInvalid: i,
    validationErrors: s,
    validationDetails: b
  };
}
export {
  j as $
};
//# sourceMappingURL=useTextField-Def10i_1.es.js.map
