import { jsx as f } from "react/jsx-runtime";
import { useMemo as d, useState as k, useCallback as b, useEffect as m } from "react";
import { g as x, S as C, j as I, v as L } from "./social.D59qnHFn.js";
import { a as T } from "./TextInput.63vMRxAK.js";
import { a as h } from "./SocialIcon.B0ronCv9.js";
const N = (i) => d(() => x(i || C.UNKNOWN), [i]), w = ({
  type: i,
  value: r,
  autoDetect: s,
  validate: e,
  onChange: t,
  onSocialLinkDetected: n,
  onValidate: l,
  disabled: g
}) => {
  const u = N(i), [a, S] = k(!0), p = b(
    (o) => {
      t(o.target.value);
    },
    [t, i]
  );
  m(() => {
    if (!s || !n) return;
    const o = I(r);
    o !== i && n(o);
  }, [r, s, n, i]), m(() => {
    if (e) {
      const o = !!L(i, r);
      o !== a && l(o), S(o);
    }
  }, [r, e, l]);
  const c = d(() => r.trim() === "" || s ? !0 : a, [a, s, r]);
  return /* @__PURE__ */ f(
    T,
    {
      label: u.label,
      prefixIcon: /* @__PURE__ */ f(h, { social: i, mode: "color" }),
      value: r,
      onChange: p,
      isError: !c,
      helper: c ? "" : "Please enter a valid link",
      isDisabled: g
    }
  );
};
export {
  w as S
};
