/**
 * `<integration-card-ui>` — Single-tile primitive representing one third-party integration (Slack, GitHub, Stripe, …). Shows the provider logo + name + description + status pill + a single primary action button whose label and variant are derived from `status`. Composes into a grid via the SPEC-063 integrations-page composite. One tile = one provider; the button variant is computed from `status`, not a separate prop. Distinct from <option-card-ui> (a single-select radio with no status / async action) and <card-ui> (the generic bordered surface this specializes).
 *
 * @see https://ui-kit.exe.xyz/site/components/integration-card
 *
 * 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 IntegrationCardConfigureEventDetail {
  /** The provider key for this card. */
  provider: string;
}

export type IntegrationCardConfigureEvent = CustomEvent<IntegrationCardConfigureEventDetail>;
export interface IntegrationCardConnectEventDetail {
  /** The provider key for this card. */
  provider: string;
}

export type IntegrationCardConnectEvent = CustomEvent<IntegrationCardConnectEventDetail>;
export interface IntegrationCardDisconnectEventDetail {
  /** The provider key for this card. */
  provider: string;
}

export type IntegrationCardDisconnectEvent = CustomEvent<IntegrationCardDisconnectEventDetail>;
export interface IntegrationCardRetryEventDetail {
  /** The provider key for this card. */
  provider: string;
}

export type IntegrationCardRetryEvent = CustomEvent<IntegrationCardRetryEventDetail>;

export class UIIntegrationCard extends UIElement {
  /** One-line description of what the integration does. */
  description: string;
  /** Disables the action button. */
  disabled: boolean;
  /** Logo URL (preferred — renders as <img>) or icon name (renders as <icon-ui>). URLs are sniffed by presence of `/`. */
  logo: string;
  /** Display name shown as the card title. Required. */
  name: string;
  /** Provider key — `slack`, `github`, etc. — used for analytics + a11y label. Required. */
  provider: string;
  /** Current connection state — drives the button label, variant, and visibility. `available` shows a primary `Connect`; `connected` shows an outline `Configure`; `error` shows an outline `Retry`; `pending` shows a non-interactive spinner; `coming-soon` hides the button. */
  status: string;

  addEventListener<K extends keyof HTMLElementEventMap>(
    type: K,
    listener: (this: UIIntegrationCard, ev: HTMLElementEventMap[K]) => unknown,
    options?: boolean | AddEventListenerOptions,
  ): void;
  addEventListener(type: 'configure', listener: (ev: IntegrationCardConfigureEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  addEventListener(type: 'connect', listener: (ev: IntegrationCardConnectEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  addEventListener(type: 'disconnect', listener: (ev: IntegrationCardDisconnectEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
  addEventListener(type: 'retry', listener: (ev: IntegrationCardRetryEvent) => unknown, options?: boolean | AddEventListenerOptions): void;
}
