/**
 * `<date-range-picker-ui>` — Compound form primitive for selecting a start + end date pair with optional named preset shortcuts ("Today", "Last 7 days", "This month", ...). Default presentation is a trigger button showing the formatted range; on activation a popover opens with two synchronized calendar panes + a preset side rail. Composes <calendar-picker-ui> twice; emits {from, to} ISO 8601 dates. Optional comparison-range mode emits a secondary range for analytics surfaces.
 *
 * @see https://ui-kit.exe.xyz/site/components/date-range-picker
 *
 * 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 DateRangePickerChangeEventDetail {
  compareValue: string;
  presetLabel: string;
  value: string;
}

export type DateRangePickerChangeEvent = CustomEvent<DateRangePickerChangeEventDetail>;
export interface DateRangePickerCloseEventDetail {
  reason: string;
}

export type DateRangePickerCloseEvent = CustomEvent<DateRangePickerCloseEventDetail>;
export interface DateRangePickerInputEventDetail {
  value: string;
}

export type DateRangePickerInputEvent = CustomEvent<DateRangePickerInputEventDetail>;
export interface DateRangePickerInvalidEventDetail {
  reason: string;
  value: string;
}

export type DateRangePickerInvalidEvent = CustomEvent<DateRangePickerInvalidEventDetail>;
export interface DateRangePickerOpenEventDetail {
  trigger: string;
}

export type DateRangePickerOpenEvent = CustomEvent<DateRangePickerOpenEventDetail>;

export class UIDateRangePicker extends UIElement {
  /** Required for validation when inside a `<form>`. */
  required: boolean;
  /** Comparison range when `[comparison]` is set. Same `{from, to}` shape as `value`. */
  compareValue: string;
  /** Enable comparison-range mode. Renders a second preset cluster and emits a secondary range under `<name>-compare`. */
  comparison: boolean;
  /** Block all interaction. Trigger remains rendered but does not open the popover. */
  disabled: boolean;
  /** Trigger button date format. `short`: `Jan 1, 2026`; `long`: `January 1, 2026`; `iso`: `2026-01-01`. */
  format: 'short' | 'long' | 'iso';
  /** Latest selectable ISO date (inclusive). Days after are disabled in both panes. */
  max: string;
  /** Earliest selectable ISO date (inclusive). Days before are disabled in both panes. */
  min: string;
  /** Form field name for form data submission. The selected range serializes as JSON `{"from":"...","to":"..."}` under this key. */
  name: string;
  /** Hide the preset side rail. */
  noPresets: boolean;
  /** Whether the popover is currently open. */
  open: boolean;
  /** Text shown in the trigger when the value is empty. */
  placeholder: string;
  /** Block edits; allow keyboard navigation for screen-reader inspection. */
  readonly: boolean;
  /** Selected range as `{from, to}` ISO 8601 dates. Null when empty. Emitted on commit. */
  value: string;

  addEventListener<K extends keyof HTMLElementEventMap>(
    type: K,
    listener: (this: UIDateRangePicker, ev: HTMLElementEventMap[K]) => unknown,
    options?: boolean | AddEventListenerOptions,
  ): void;
  addEventListener(type: 'change', listener: (ev: DateRangePickerChangeEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  addEventListener(type: 'close', listener: (ev: DateRangePickerCloseEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  addEventListener(type: 'input', listener: (ev: DateRangePickerInputEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  addEventListener(type: 'invalid', listener: (ev: DateRangePickerInvalidEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  addEventListener(type: 'open', listener: (ev: DateRangePickerOpenEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
}
