/**
 * `<nav-group-ui>` — Collapsible labeled group of <nav-item-ui> children inside <nav-ui>.
Consolidates the prior `app-nav-group-ui` + `section-nav-group-ui`
per ADR-0015 § Nav consolidation.

When the parent <nav-ui> is collapsed (primary variant), clicking the
group opens a popover with its children instead of toggling inline
expansion. Inline click + keyboard (Enter/Space) toggle is supported
when [collapsible] (default true).

 *
 * @see https://ui-kit.exe.xyz/site/components/nav-group
 *
 * 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 interface NavGroupGroupToggleEventDetail {
  /** Whether the group is now open. */
  open: boolean;
  /** Group label text. */
  text: string;
}

export type NavGroupGroupToggleEvent = CustomEvent<NavGroupGroupToggleEventDetail>;

export class UINavGroup extends UIElement {
  /** Optional trailing badge (count, label). */
  badge: string;
  /** When true, the header row toggles the open state on click/keyboard. */
  collapsible: boolean;
  /** Optional leading icon name (resolved via <icon-ui>). */
  icon: string;
  /** Inline-expanded state. Toggled by header click when [collapsible]. */
  open: boolean;
  /** Visible group label. */
  text: string;
  /** Visual treatment. Default ('') renders as a primary-rail group (icon row, caret, collapsible). 'section' renders the header as a static kicker label with always-visible children. When the parent <nav-ui> carries variant="section", this group inherits it via CSS cascade unless an explicit variant is set on the group. */
  variant: '' | 'section';

  addEventListener<K extends keyof HTMLElementEventMap>(
    type: K,
    listener: (this: UINavGroup, ev: HTMLElementEventMap[K]) => unknown,
    options?: boolean | AddEventListenerOptions,
  ): void;
  addEventListener(type: 'group-toggle', listener: (ev: NavGroupGroupToggleEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
}
