/**
 * `<check-ui>` — Checkbox (boolean-semantic form control).
 *
 * @see https://ui-kit.exe.xyz/site/components/check
 */

import { UIFormElement } from '../../core/form.js';

export interface CheckChangeEventDetail {
  /** Submitted value (defaults to `"on"` when checked). */
  value: string;
  /** Current checked state. */
  checked: boolean;
}
export type CheckChangeEvent = CustomEvent<CheckChangeEventDetail>;

export class UICheck extends UIFormElement {
  /** Checked state — reflected, toggles on click/Space/Enter. */
  checked: boolean;
  /** Indeterminate (mixed) state — visual only; cleared on click. */
  indeterminate: boolean;
  label: string;

  addEventListener<K extends keyof HTMLElementEventMap>(
    type: K,
    listener: (this: UICheck, ev: HTMLElementEventMap[K]) => unknown,
    options?: boolean | AddEventListenerOptions,
  ): void;
  addEventListener(type: 'change', listener: (ev: CheckChangeEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
}
