import * as t from "react";
import d from "../../../../../../../../../_virtual/index9.js";
import { composeRefs as F } from "../../../../../../../@radix-ui_react-compose-refs@1.1.0_@types_react@18.3.3_react@18.3.0-canary-3d9b20132-20240124/node_modules/@radix-ui/react-compose-refs/dist/index.js";
import { textFieldRootPropDefs as R, textFieldSlotPropDefs as S } from "./text-field.props.js";
import { extractProps as m } from "../helpers/extract-props.js";
import { marginPropDefs as T } from "../props/margin.props.js";
const N = t.forwardRef((r, a) => {
  const e = t.useRef(null), { children: s, className: l, color: i, radius: f, style: p, ...u } = m(r, R, T);
  return t.createElement("div", { "data-accent-color": i, "data-radius": f, style: p, className: d("rt-TextFieldRoot", l), onPointerDown: (x) => {
    const c = x.target;
    if (c.closest("input, button, a")) return;
    const o = e.current;
    if (!o) return;
    const n = c.closest(`
            .rt-TextFieldSlot[data-side='right'],
            .rt-TextFieldSlot:not([data-side='right']) ~ .rt-TextFieldSlot:not([data-side='left'])
          `) ? o.value.length : 0;
    requestAnimationFrame(() => {
      try {
        o.setSelectionRange(n, n);
      } catch {
      }
      o.focus();
    });
  } }, t.createElement("input", { spellCheck: "false", ...u, ref: F(e, a), className: "rt-reset rt-TextFieldInput" }), s);
});
N.displayName = "TextField.Root";
const g = t.forwardRef((r, a) => {
  const { className: e, color: s, side: l, ...i } = m(r, S);
  return t.createElement("div", { "data-accent-color": s, "data-side": l, ...i, ref: a, className: d("rt-TextFieldSlot", e) });
});
g.displayName = "TextField.Slot";
export {
  N as Root,
  g as Slot
};
//# sourceMappingURL=text-field.js.map
