import {
  useFieldContext
} from "./HRY5AU2J.jsx";
import {
  createSplitProps
} from "./6WEDGJKQ.jsx";
import {
  useEnvironmentContext
} from "./HDGILMRT.jsx";
import {
  useLocaleContext
} from "./HOPBYFHD.jsx";
import {
  runIfFn
} from "./KGOB2IMX.jsx";
import {
  ark
} from "./UFYZ7HLU.jsx";
import {
  createContext
} from "./UZJJWJQM.jsx";
import {
  __export
} from "./7IUG3E2V.jsx";

// src/components/switch/use-switch-context.ts
var [SwitchProvider, useSwitchContext] = createContext({
  hookName: "useSwitchContext",
  providerName: "<SwitchProvider />"
});

// src/components/switch/switch-context.tsx
var SwitchContext = (props) => props.children(useSwitchContext());

// src/components/switch/switch-control.tsx
import { mergeProps } from "@zag-js/solid";
var SwitchControl = (props) => {
  const api = useSwitchContext();
  const mergedProps = mergeProps(() => api().getControlProps(), props);
  return <ark.span {...mergedProps} />;
};

// src/components/switch/switch-hidden-input.tsx
import { mergeProps as mergeProps2 } from "@zag-js/solid";
var SwitchHiddenInput = (props) => {
  const api = useSwitchContext();
  const mergedProps = mergeProps2(() => api().getHiddenInputProps(), props);
  const field = useFieldContext();
  return <ark.input aria-describedby={field?.().ariaDescribedby} {...mergedProps} />;
};

// src/components/switch/switch-label.tsx
import { mergeProps as mergeProps3 } from "@zag-js/solid";
var SwitchLabel = (props) => {
  const api = useSwitchContext();
  const mergedProps = mergeProps3(() => api().getLabelProps(), props);
  return <ark.span {...mergedProps} />;
};

// src/components/switch/switch-root.tsx
import { mergeProps as mergeProps4 } from "@zag-js/solid";

// src/components/switch/use-switch.ts
import { normalizeProps, useMachine } from "@zag-js/solid";
import * as zagSwitch from "@zag-js/switch";
import { createMemo, createUniqueId } from "solid-js";
var useSwitch = (props) => {
  const id = createUniqueId();
  const locale = useLocaleContext();
  const environment = useEnvironmentContext();
  const field = useFieldContext();
  const machineProps = createMemo(() => ({
    id,
    ids: {
      label: field?.().ids.label,
      hiddenInput: field?.().ids.control
    },
    disabled: field?.().disabled,
    readOnly: field?.().readOnly,
    invalid: field?.().invalid,
    required: field?.().required,
    dir: locale().dir,
    getRootNode: environment().getRootNode,
    ...runIfFn(props)
  }));
  const service = useMachine(zagSwitch.machine, machineProps);
  return createMemo(() => zagSwitch.connect(service, normalizeProps));
};

// src/components/switch/switch-root.tsx
var SwitchRoot = (props) => {
  const [switchProps, localProps] = createSplitProps()(props, [
    "checked",
    "defaultChecked",
    "disabled",
    "form",
    "id",
    "ids",
    "invalid",
    "label",
    "name",
    "onCheckedChange",
    "readOnly",
    "required",
    "value"
  ]);
  const api = useSwitch(switchProps);
  const mergedProps = mergeProps4(() => api().getRootProps(), localProps);
  return <SwitchProvider value={api}>
      <ark.label {...mergedProps} />
    </SwitchProvider>;
};

// src/components/switch/switch-root-provider.tsx
import { mergeProps as mergeProps5 } from "@zag-js/solid";
var SwitchRootProvider = (props) => {
  const [{ value: api }, localProps] = createSplitProps()(props, ["value"]);
  const mergedProps = mergeProps5(() => api().getRootProps(), localProps);
  return <SwitchProvider value={api}>
      <ark.label {...mergedProps} />
    </SwitchProvider>;
};

// src/components/switch/switch-thumb.tsx
import { mergeProps as mergeProps6 } from "@zag-js/solid";
var SwitchThumb = (props) => {
  const api = useSwitchContext();
  const mergedProps = mergeProps6(() => api().getThumbProps(), props);
  return <ark.span {...mergedProps} />;
};

// src/components/switch/switch.ts
var switch_exports = {};
__export(switch_exports, {
  Context: () => SwitchContext,
  Control: () => SwitchControl,
  HiddenInput: () => SwitchHiddenInput,
  Label: () => SwitchLabel,
  Root: () => SwitchRoot,
  RootProvider: () => SwitchRootProvider,
  Thumb: () => SwitchThumb
});

export {
  useSwitchContext,
  SwitchContext,
  SwitchControl,
  SwitchHiddenInput,
  SwitchLabel,
  useSwitch,
  SwitchRoot,
  SwitchRootProvider,
  SwitchThumb,
  switch_exports
};
