// 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 { Checkbox as CheckboxController, type CheckboxOptions } from '@42/core/choice';
import { C42 } from '../C42';

const DEFAULT_HTML: string | null = "Accept";

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

export function Checkbox(props: CheckboxProps) {
  const { as, className, children, onChange, checked, indeterminate, disabled, ...rest } = props;
  const options = { checked, indeterminate, disabled } as CheckboxOptions;

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