import { jsxs, jsx } from "react/jsx-runtime";
import { a as $64fa3d84918910a7$export$29f1550f4b0d4415, l as $df56164dff5785e2$export$4338b53315abf666, m as $5dc95899b306f630$export$c9058316764c140e, g as $64fa3d84918910a7$export$ef03459518577ad4, h as $64fa3d84918910a7$export$4d86445c2cf5e3, b as $3ef42575df84b30b$export$9d1611c77c2fe928 } from "../../utils-cvK1vxO7.js";
import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-D2C6R0DK.js";
import React__default, { forwardRef, createContext } from "react";
import { $ as $3017fa7ffdddec74$export$8042c6c013fd5226 } from "../../useToggleState-CiAradXs.js";
import { $ as $d2c8e2b0480f3f34$export$cbe85ee05b554577 } from "../../useToggle-C8CedY6Z.js";
import { a as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-CUxgjvAY.js";
import { w as $6179b936705e76d3$export$ae780daf29e6d456 } from "../../useHover-LmGemtHE.js";
import { $ as $5c3e21d68f1c4674$export$439d29a4e110a164 } from "../../VisuallyHidden-X6SggVVO.js";
import { c as clsx } from "../../lite-DVmmD_-j.js";
function $b418ec0c85c52f27$export$d853f7095ae95f88(props, state, ref) {
  let { labelProps, inputProps, isSelected, isPressed, isDisabled, isReadOnly } = $d2c8e2b0480f3f34$export$cbe85ee05b554577(props, state, ref);
  return {
    labelProps,
    inputProps: {
      ...inputProps,
      role: "switch",
      checked: isSelected
    },
    isSelected,
    isPressed,
    isDisabled,
    isReadOnly
  };
}
const $8e59e948500a8fe1$export$8699e3b644d5a28a = /* @__PURE__ */ createContext(null);
const $8e59e948500a8fe1$export$b5d5cf8927ab7262 = /* @__PURE__ */ forwardRef(function Switch(props, ref) {
  let { inputRef: userProvidedInputRef = null, ...otherProps } = props;
  [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(otherProps, ref, $8e59e948500a8fe1$export$8699e3b644d5a28a);
  let inputRef = $df56164dff5785e2$export$4338b53315abf666($5dc95899b306f630$export$c9058316764c140e(userProvidedInputRef, props.inputRef !== void 0 ? props.inputRef : null));
  let state = $3017fa7ffdddec74$export$8042c6c013fd5226(props);
  let { labelProps, inputProps, isSelected, isDisabled, isReadOnly, isPressed } = $b418ec0c85c52f27$export$d853f7095ae95f88({
    ...$64fa3d84918910a7$export$ef03459518577ad4(props),
    // ReactNode type doesn't allow function children.
    children: typeof props.children === "function" ? true : props.children
  }, state, inputRef);
  let { isFocused, isFocusVisible, focusProps } = $f7dceffc5ad7768b$export$4e328f61c538687f();
  let isInteractionDisabled = props.isDisabled || props.isReadOnly;
  let { hoverProps, isHovered } = $6179b936705e76d3$export$ae780daf29e6d456({
    ...props,
    isDisabled: isInteractionDisabled
  });
  let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
    ...props,
    defaultClassName: "react-aria-Switch",
    values: {
      isSelected,
      isPressed,
      isHovered,
      isFocused,
      isFocusVisible,
      isDisabled,
      isReadOnly,
      state
    }
  });
  let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, {
    global: true
  });
  delete DOMProps.id;
  delete DOMProps.onClick;
  return /* @__PURE__ */ React__default.createElement("label", {
    ...$3ef42575df84b30b$export$9d1611c77c2fe928(DOMProps, labelProps, hoverProps, renderProps),
    ref,
    slot: props.slot || void 0,
    "data-selected": isSelected || void 0,
    "data-pressed": isPressed || void 0,
    "data-hovered": isHovered || void 0,
    "data-focused": isFocused || void 0,
    "data-focus-visible": isFocusVisible || void 0,
    "data-disabled": isDisabled || void 0,
    "data-readonly": isReadOnly || void 0
  }, /* @__PURE__ */ React__default.createElement($5c3e21d68f1c4674$export$439d29a4e110a164, {
    elementType: "span"
  }, /* @__PURE__ */ React__default.createElement("input", {
    ...$3ef42575df84b30b$export$9d1611c77c2fe928(inputProps, focusProps),
    ref: inputRef
  })), renderProps.children);
});
/**
 * A toggle switch.
 *
 * @component
 * @param {Object} props - Component props.
 * @param {boolean} props.checked - Whether the switch is checked.
 * @param {Function} props.onChange - Function to call when the switch is toggled.
 * @param {boolean} [props.disabled] - Whether the switch is disabled.
 * @param {string} [props.id] - The ID of the switch.
 * @param {string} [props.className] - Classes to pass to the switch.
 * @param {boolean} [props.isIndeterminate] - If `true`, the switch will render in an indeterminate state.
 * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
 *
 * @returns {JSX.Element} The Switch component.
 *
 * @example
 * const [checked, setChecked] = useState(false);
 *
 * <Switch
 * 	checked={checked}
 * 	onChange={() => setChecked(!checked)}
 * />
 *
 * @preserve
 */
const Switch2 = (props) => {
  const { checked, onChange, disabled, id, children, className, isIndeterminate, hidden, ...rest } = props;
  if (hidden) {
    return null;
  }
  return /* @__PURE__ */ jsxs(
    $8e59e948500a8fe1$export$b5d5cf8927ab7262,
    {
      id,
      isDisabled: disabled,
      isSelected: checked ?? false,
      onChange,
      className: "es:group es:flex es:items-center es:justify-between es:gap-2 es:any-focus:outline-hidden",
      ...rest,
      children: [
        children,
        /* @__PURE__ */ jsx("div", { className: clsx("es:flex es:shrink-0 es:items-center es:justify-center es:min-h-6.5", className), children: /* @__PURE__ */ jsx(
          "div",
          {
            className: clsx(
              "es:shrink-0 es:group-not-disabled:cursor-pointer es:no-webkit-highlight",
              "es:h-5 es:w-9 es:p-[0.1875rem] es:rounded-full",
              "es:bg-radial-[circle_at_75%_50%]",
              "es:border es:inset-ring es:inset-shadow-xs",
              "es:transition",
              "es:group-focus-visible:ring-2 es:group-focus-visible:ring-accent-500/50 es:group-focus-visible:border-accent-600",
              !checked && !disabled && "es:border-secondary-400 es:inset-ring-secondary-100 es:from-white es:to-secondary-100",
              checked && !disabled && "es:border-accent-700/75 es:inset-ring-accent-500 es:to-accent-500 es:from-accent-600 es:shadow-accent-600/30",
              disabled && "es:cursor-default es:border-secondary-300 es:from-white es:to-secondary-50 es:inset-ring-0 es:inset-shadow-secondary-100",
              !disabled && "es:shadow-sm"
            ),
            children: /* @__PURE__ */ jsx(
              "span",
              {
                className: clsx(
                  "es:block es:size-3 es:rounded-full es:border es:will-change-transform es:bg-radial",
                  "es:transition es:motion-ease-spring-bouncy es:ease-[var(--motion-spring-bouncy)] es:duration-200",
                  !checked && "es:scale-95",
                  !checked && !disabled && "es:border-secondary-500 es:from-secondary-500 es:to-secondary-600",
                  checked && "es:translate-x-4",
                  checked && !disabled && "es:border-accent-600/20 es:from-white es:to-accent-500/30 es:from-40% es:bg-white es:shadow-sm es:shadow-accent-900/60",
                  disabled && "es:border-secondary-300",
                  checked && disabled && "es:bg-secondary-200",
                  isIndeterminate && "es:translate-x-2 es:scale-100"
                )
              }
            )
          }
        ) })
      ]
    }
  );
};
export {
  Switch2 as Switch
};
