/**
 * `<command-ui>` — Searchable command palette primitive — combobox-style search input
plus a scrollable list of <option value> items grouped by
<optgroup label>. Content-only; does NOT own the dialog or the
Cmd+K shortcut. For canonical Cmd+K palettes wrap in <admin-command>
at the shell tier, which provides the native <dialog> + focus
management + cross-platform Cmd+K listener. Distinct from <menu-ui>
(small popover action menu, not searchable) and <modal-ui> (generic
centered dialog).

 *
 * @see https://ui-kit.exe.xyz/site/components/command
 *
 * Type declarations generated by scripts/build/dts-codegen.mjs from
 * the component's `.a2ui.json` sidecar(s). Edit the source `.yaml`,
 * run `npm run build:components`, then `npm run codegen:dts` to
 * regenerate; or hand-author this file fully if rich event types are
 * needed beyond what the yaml `events:` block can express.
 */

import { UIElement } from '../../core/element.js';

export type CommandDismissEvent = CustomEvent<unknown>;
export interface CommandSelectEventDetail {
  /** Parent optgroup label (empty string when item has no group). */
  category: string;
  /** Item label text. */
  label: string;
  /** Item value attribute. */
  value: string;
}

export type CommandSelectEvent = CustomEvent<CommandSelectEventDetail>;

export class UICommand extends UIElement {
  /** Whether the command palette is visible */
  open: boolean;
  /** Placeholder text for the search input */
  placeholder: string;

  addEventListener<K extends keyof HTMLElementEventMap>(
    type: K,
    listener: (this: UICommand, ev: HTMLElementEventMap[K]) => unknown,
    options?: boolean | AddEventListenerOptions,
  ): void;
  addEventListener(type: 'dismiss', listener: (ev: CommandDismissEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  addEventListener(type: 'select', listener: (ev: CommandSelectEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
}
