// AUTO-GENERATED by scripts/generate-wrappers.mjs — do not edit by hand.
// Source: packages/core/manifest.json (component "choice").
import type { ElementType, ReactNode } from 'react';
import { Switch as SwitchController, type SwitchOptions } from '@42/core/choice';
import { C42 } from '../C42';

const DEFAULT_HTML: string | null = "Notifications";

export interface SwitchProps extends Partial<SwitchOptions> {
  /** Element/tag rendered as the controller root. Defaults to `"button"`. */
  as?: ElementType;
  className?: string;
  children?: ReactNode;
  /** Fired on `switch:change` — detail: `{ checked }` */
  onChange?: (detail: unknown, event: CustomEvent) => void;
  /** Extra props are forwarded to the rendered `<button>` element. */
  [key: string]: unknown;
}

export function Switch(props: SwitchProps) {
  const { as, className, children, onChange, checked, indeterminate, disabled, ...rest } = props;
  const options = { checked, indeterminate, disabled } as SwitchOptions;

  return (
    <C42
      controller={SwitchController}
      options={options}
      deps={[checked, indeterminate, disabled]}
      events={{
        'switch:change': onChange,
      }}
      as={(as as ElementType) ?? 'button'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-switch': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
