import { useState as C, useMemo as z } from "react";
const b = (f) => {
  const { value: e, onChange: s, error: a, disabled: n, isSkeleton: r, currentSize: u, variant: d } = f, [m, h] = C(null), [t, l] = C(
    e ?? void 0
  ), g = (o) => {
    r || n || (l(e ?? void 0), h(o.currentTarget));
  }, i = () => {
    h(null);
  }, k = (o) => {
    r || n || l(o.hex);
  }, p = () => {
    r || n || (t !== e && (s(t ?? null), l(t)), i());
  }, v = (o) => {
    if (r || n)
      return;
    const c = o ?? null;
    c !== e && s(c), l(c ?? void 0), i();
  }, S = () => {
    i();
  }, x = z(
    () => ({
      size: u,
      disabled: r || n,
      value: e,
      error: !!a,
      variant: d
    }),
    [u, r, n, e, a, d]
  );
  return {
    anchorEl: m,
    tempColor: t,
    triggerOwnerState: x,
    handleOpenPicker: g,
    handleClosePicker: i,
    handleColorChange: k,
    handleConfirm: p,
    handleQuickColorSelect: v,
    handleCancel: S
  };
};
export {
  b as useColorPicker
};
