{"version":3,"file":"types.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { ZitadelProject } from \"@zitadel/api/config\";\nimport type {\n  CreateFlow201Step,\n  CreateFlow201StepComplete,\n  CreateFlowBodyPurpose,\n} from \"@zitadel/api/generated/model\";\n\n/** Re-exported so consumers can type the `purpose` prop without a deep import. */\nexport type { CreateFlowBodyPurpose } from \"@zitadel/api/generated/model\";\n\n/**\n * The SPA widget contract shared by every SPA SDK (`sdk-react`, `sdk-vue`,\n * `sdk-angular`, `sdk-solid`, `sdk-svelte`, `sdk-qwik`): the widget event detail\n * types plus the config/handler/props types derived from them. Each SPA SDK\n * re-exports these from its own public surface so consumers don't need a direct\n * `sdk-core` dependency. The middleware-layer types (`sdk-next`, `sdk-nuxt`) now\n * live in `@zitadel/sdk-core/middleware`.\n */\n\n/** Payload of the `zitadel-flow-step` event. */\nexport interface ZitadelFlowStepDetail {\n  readonly step: CreateFlow201Step;\n}\n\n/** Payload of the `zitadel-flow-input` event. */\nexport interface ZitadelFlowInputDetail {\n  readonly name: string;\n  readonly value: string;\n}\n\n/**\n * Carried by the events after which the widget navigates. A listener whose work\n * must finish first (an async handler, a lazily loaded callback) passes its\n * promise to `waitUntil`; the widget navigates once every promise has settled,\n * or after a short timeout.\n */\nexport interface ZitadelNavigationDetail {\n  readonly waitUntil: (work: unknown) => void;\n}\n\n/** Payload of the `zitadel-flow-complete` event. */\nexport interface ZitadelFlowCompleteDetail extends ZitadelNavigationDetail {\n  readonly behavior: CreateFlow201StepComplete;\n  readonly redirect_uri?: string;\n  readonly handoff_token?: string;\n  readonly handoff_token_expires_at?: string;\n}\n\n/**\n * Payload of the `zitadel-flow-redirect` event — the widget is handing the\n * browser to an identity provider. Distinct from `zitadel-flow-complete`:\n * nobody is signed in yet, and the flow resumes when the provider returns.\n */\nexport interface ZitadelFlowRedirectDetail extends ZitadelNavigationDetail {\n  readonly redirect_url: string;\n  readonly step: CreateFlow201Step;\n}\n\n/** Payload of the `zitadel-flow-error` event. */\nexport interface ZitadelFlowErrorDetail {\n  readonly message: string;\n}\n\n/** Payload of the `zitadel-signout` event. */\nexport interface ZitadelSignoutDetail extends ZitadelNavigationDetail {\n  /** The signed-out user's display rendering (\"\" when none was resolved). */\n  readonly display: string;\n  /** The signed-out user's login identifier (\"\" when none was resolved). */\n  readonly identifier: string;\n}\n\n/* ───────────────────────────  SPA widget contract  ───────────────────────\n * Single source of truth shared by every SPA SDK (react, vue, angular, solid,\n * svelte, qwik). The event maps below declare which widget events exist and\n * what each carries; the config/handler/props types and the runtime name lists\n * are all derived from them. Adding or removing an event here is the ONE edit\n * that ripples to every SDK — the compile-time assertions in this file, the\n * `@zitadel/components` emit-conformance test, and each SDK's contract-driven\n * forwarding test all fail until every wrapper is brought back into line.\n * ───────────────────────────────────────────────────────────────────────── */\n\n/** Events emitted by `<zitadel-login>`, keyed to their detail payload. */\nexport interface ZitadelLoginEventMap {\n  \"zitadel-flow-step\": ZitadelFlowStepDetail;\n  \"zitadel-flow-input\": ZitadelFlowInputDetail;\n  \"zitadel-flow-complete\": ZitadelFlowCompleteDetail;\n  \"zitadel-flow-redirect\": ZitadelFlowRedirectDetail;\n  \"zitadel-flow-error\": ZitadelFlowErrorDetail;\n}\n\n/** Events emitted by `<zitadel-logout>`, keyed to their detail payload. */\nexport interface ZitadelLogoutEventMap {\n  \"zitadel-signout\": ZitadelSignoutDetail;\n}\n\n/**\n * Events emitted by `<zitadel-session>`, keyed to their detail payload.\n * `zitadel-signout` reuses {@link ZitadelSignoutDetail} so the post-sign-in\n * card and the avatar menu speak the same sign-out contract.\n */\nexport interface ZitadelSessionEventMap {\n  \"zitadel-signout\": ZitadelSignoutDetail;\n}\n\n/**\n * Maps each `<zitadel-login>` event to the callback prop the SDKs expose. The\n * `satisfies Record<keyof ZitadelLoginEventMap, …>` is the drift lock: every\n * event needs exactly one handler entry — a missing one, or an extra one left\n * behind for a removed event, fails `tsc`. Everything below derives from this.\n */\nexport const ZITADEL_LOGIN_EVENT_HANDLERS = {\n  \"zitadel-flow-step\": \"onFlowStep\",\n  \"zitadel-flow-input\": \"onFlowInput\",\n  \"zitadel-flow-complete\": \"onFlowComplete\",\n  \"zitadel-flow-redirect\": \"onFlowRedirect\",\n  \"zitadel-flow-error\": \"onFlowError\",\n} as const satisfies Record<keyof ZitadelLoginEventMap, `on${string}`>;\n\n/** Maps the `<zitadel-logout>` event to the callback prop the SDKs expose. */\nexport const ZITADEL_LOGOUT_EVENT_HANDLERS = {\n  \"zitadel-signout\": \"onSignout\",\n} as const satisfies Record<keyof ZitadelLogoutEventMap, `on${string}`>;\n\n/** Maps the `<zitadel-session>` event to the callback prop the SDKs expose. */\nexport const ZITADEL_SESSION_EVENT_HANDLERS = {\n  \"zitadel-signout\": \"onSignout\",\n} as const satisfies Record<keyof ZitadelSessionEventMap, `on${string}`>;\n\n/** Runtime list of `<zitadel-login>` event names (drives wiring + drift tests). */\nexport const ZITADEL_LOGIN_EVENTS = Object.keys(\n  ZITADEL_LOGIN_EVENT_HANDLERS,\n) as (keyof ZitadelLoginEventMap)[];\n\n/** Runtime list of `<zitadel-logout>` event names. */\nexport const ZITADEL_LOGOUT_EVENTS = Object.keys(\n  ZITADEL_LOGOUT_EVENT_HANDLERS,\n) as (keyof ZitadelLogoutEventMap)[];\n\n/** Runtime list of `<zitadel-session>` event names. */\nexport const ZITADEL_SESSION_EVENTS = Object.keys(\n  ZITADEL_SESSION_EVENT_HANDLERS,\n) as (keyof ZitadelSessionEventMap)[];\n\n/** Configuration props shared by every `ZitadelLogin` wrapper. */\nexport interface ZitadelLoginConfig {\n  /** The SDK handle from `configureZitadel(...)`. */\n  readonly project?: ZitadelProject;\n  /** Discrete project id, read when no {@link project} handle is supplied. */\n  readonly projectId?: string;\n  /** Reverse-proxy path prefix the widget calls. */\n  readonly proxyPath?: string;\n  /**\n   * Sizing/chrome mode. `widget` (default) is content-sized and paints no\n   * page chrome — for embedding inside an existing layout. `page` claims\n   * the viewport, paints the surface background, loads the brand font, and\n   * focuses the first field — for dedicated login routes.\n   * @default \"widget\"\n   */\n  readonly variant?: \"widget\" | \"page\";\n  /**\n   * Colour mode. Unset defers to the tenant's `branding.theme.mode`, then to\n   * the variant default — `dark` for `page`, `auto` (follow\n   * `prefers-color-scheme`) for `widget`. Set it when your app's surface is\n   * fixed so the widget doesn't render a dark card on a light page.\n   */\n  readonly theme?: \"light\" | \"dark\" | \"auto\";\n  /**\n   * Visually hide the widget's own heading block while keeping it in the\n   * accessibility tree — for embeds whose page already carries the heading\n   * (a brand-voice title above the card) so the card doesn't repeat it.\n   * @default false\n   */\n  readonly suppressHeader?: boolean;\n  /**\n   * Hide the show/hide button on password fields. The button is shown by\n   * default, as NIST SP 800-63B recommends.\n   * @default false\n   */\n  readonly suppressPasswordToggle?: boolean;\n  /** Flow purpose. @default \"login\" */\n  readonly purpose?: CreateFlowBodyPurpose;\n  /**\n   * Selects a specific flow definition by its `name` (the `name` field in\n   * the flow file). Omit to run the project's default flow for the purpose.\n   */\n  readonly flowName?: string;\n  /**\n   * Where to navigate after a completed sign-in. When the page's `next` query\n   * parameter names a path on the same origin, the widget returns there\n   * instead: the server SDKs' middleware sends a signed-out request for a\n   * protected route to the login page with `?next=<path>`.\n   */\n  readonly postSignInUrl?: string;\n  /**\n   * Go to {@link postSignInUrl} even when the page's `next` query parameter\n   * names a path, for a page that uses `next` for something of its own.\n   * @default false\n   */\n  readonly forcePostSignInUrl?: boolean;\n  /**\n   * An existing flow's id to resume instead of starting a new flow, for\n   * example one kept across a reload. Unset or `null` falls back to the `flow` query\n   * parameter a provider callback brings back; an id that no longer resolves\n   * starts a new flow.\n   */\n  readonly resumeFlowId?: string | null;\n  /**\n   * Copy overrides merged over the builtin locale dictionaries, keyed by\n   * primary language subtag. Each dictionary may be partial — the widget\n   * merges it over the builtin copy — so presets like the components'\n   * `businessLocales` overlay are directly assignable. This is how custom\n   * flow steps and actions get labels (keys follow `<step>.title`,\n   * `<step>.action.<name>`, `<step>.field.<field>`):\n   *\n   * ```tsx\n   * <ZitadelLogin locales={{ en: { \"identifier.title\": \"Welcome back\" } }} />\n   * ```\n   */\n  readonly locales?: Record<string, Partial<Record<string, string>>>;\n  /** BCP-47 language override; defaults to the browser language. */\n  readonly lang?: string;\n}\n\n/** Configuration props shared by every `ZitadelLogout` wrapper. */\nexport interface ZitadelLogoutConfig {\n  /** The SDK handle from `configureZitadel(...)`. */\n  readonly project?: ZitadelProject;\n  /** Discrete project id, read when no {@link project} handle is supplied. */\n  readonly projectId?: string;\n  /** Reverse-proxy path prefix the widget calls. */\n  readonly proxyPath?: string;\n  /** Where to navigate after sign-out. */\n  readonly postSignOutUrl?: string;\n  /**\n   * Colour mode. Unset defaults to `auto` (follow `prefers-color-scheme`) —\n   * the control lives inside the app's own chrome. Set it when the\n   * surrounding surface is fixed.\n   */\n  readonly theme?: \"light\" | \"dark\" | \"auto\";\n}\n\n/** Configuration props shared by every `ZitadelSession` wrapper. */\nexport interface ZitadelSessionConfig {\n  /** The SDK handle from `configureZitadel(...)`. */\n  readonly project?: ZitadelProject;\n  /** Discrete project id, read when no {@link project} handle is supplied. */\n  readonly projectId?: string;\n  /** Reverse-proxy path prefix the widget calls. */\n  readonly proxyPath?: string;\n  /** Where to navigate after sign-out. */\n  readonly postSignOutUrl?: string;\n  /** Heading text override. */\n  readonly heading?: string;\n  /** Logout action label override. */\n  readonly logoutLabel?: string;\n  /**\n   * Sizing/chrome mode. `widget` (default) is content-sized and paints no\n   * page chrome — for embedding the signed-in card inside an existing\n   * layout. `page` claims the viewport and paints the surface background —\n   * for dedicated signed-in routes.\n   * @default \"widget\"\n   */\n  readonly variant?: \"widget\" | \"page\";\n  /**\n   * Colour mode. Unset defers to the variant default — `dark` for `page`,\n   * `auto` (follow `prefers-color-scheme`) for `widget`. Set it when your\n   * app's surface is fixed so the card doesn't render dark on a light page.\n   */\n  readonly theme?: \"light\" | \"dark\" | \"auto\";\n  /**\n   * Visually hide the widget's own heading block while keeping it in the\n   * accessibility tree — for embeds whose page already carries the heading\n   * (a brand-voice title above the card) so the card doesn't repeat it.\n   * @default false\n   */\n  readonly suppressHeader?: boolean;\n}\n\n/**\n * Plain-callback handlers for the `<zitadel-login>` events, derived from\n * {@link ZitadelLoginEventMap} and {@link ZITADEL_LOGIN_EVENT_HANDLERS} so the\n * prop set can never drift from the events it forwards.\n */\nexport type ZitadelLoginHandlers = {\n  readonly [E in keyof ZitadelLoginEventMap as (typeof ZITADEL_LOGIN_EVENT_HANDLERS)[E]]?: (\n    detail: ZitadelLoginEventMap[E],\n  ) => ZitadelLoginEventMap[E] extends ZitadelNavigationDetail ? unknown : void;\n};\n\n/** Plain-callback handler for the `<zitadel-logout>` event (derived, as above). */\nexport type ZitadelLogoutHandlers = {\n  readonly [E in keyof ZitadelLogoutEventMap as (typeof ZITADEL_LOGOUT_EVENT_HANDLERS)[E]]?: (\n    detail: ZitadelLogoutEventMap[E],\n  ) => ZitadelLogoutEventMap[E] extends ZitadelNavigationDetail ? unknown : void;\n};\n\n/** Plain-callback handlers for the `<zitadel-session>` events (derived, as above). */\nexport type ZitadelSessionHandlers = {\n  readonly [E in keyof ZitadelSessionEventMap as (typeof ZITADEL_SESSION_EVENT_HANDLERS)[E]]?: (\n    detail: ZitadelSessionEventMap[E],\n  ) => ZitadelSessionEventMap[E] extends ZitadelNavigationDetail ? unknown : void;\n};\n\n/** Full prop set for a `ZitadelLogin` wrapper (config + plain-callback handlers). */\nexport type ZitadelLoginProps = ZitadelLoginConfig & ZitadelLoginHandlers;\n\n/** Full prop set for a `ZitadelLogout` wrapper (config + plain-callback handlers). */\nexport type ZitadelLogoutProps = ZitadelLogoutConfig & ZitadelLogoutHandlers;\n\n/** Full prop set for a `ZitadelSession` wrapper (config + plain-callback handlers). */\nexport type ZitadelSessionProps = ZitadelSessionConfig & ZitadelSessionHandlers;\n\n/* ───────────────────────  Standard element attributes  ───────────────────────\n * The one definition of which props a wrapper hands to the widget element\n * besides its own, shared by every SPA SDK except Angular (whose component tag\n * already carries them). The set and every widget prop are disjoint, which the\n * contract spec checks, so a wrapper can pass the result to the element without\n * a widget prop ever being shadowed.\n * ───────────────────────────────────────────────────────────────────────── */\n\n/** The names every framework applies to an element itself, so none of them takes a prefix. */\nconst NATIVE_NAMES = [\"class\", \"className\", \"style\"] as const;\ntype NativeName = (typeof NATIVE_NAMES)[number];\n\nconst STANDARD_NAMES = [\n  ...NATIVE_NAMES,\n  \"id\",\n  \"title\",\n  \"slot\",\n  \"hidden\",\n  \"role\",\n  \"tabindex\",\n  \"tabIndex\",\n] as const;\n\n/**\n * The name of a standard HTML attribute: the fixed ones (`className` and\n * `tabIndex` are the spellings React and Qwik use), `data-*` and `aria-*`.\n * Matching is exact and case-sensitive.\n */\nexport type StandardAttributeName =\n  | (typeof STANDARD_NAMES)[number]\n  | `data-${string}`\n  | `aria-${string}`;\n\n/**\n * The standard attributes among the props `Props`, each name with `Prefix`\n * before it, except the native names. Every value keeps the type it has in\n * `Props`.\n */\nexport type StandardAttributes<Props extends object, Prefix extends string = \"\"> = {\n  [Name in keyof Props & StandardAttributeName as Name extends NativeName\n    ? Name\n    : `${Prefix}${Name}`]?: Props[Name];\n};\n\n/**\n * What a wrapper's props type adds to the widget's own: the standard attributes\n * of the framework's element attributes type `Attributes`, and nothing else, so\n * no prop the type accepts is dropped.\n */\nexport type StandardAttributeProps<Attributes extends object> = Pick<\n  Attributes,\n  Extract<keyof Attributes, StandardAttributeName>\n>;\n\n/**\n * Whether `name` is the name of a standard HTML attribute (see\n * {@link StandardAttributeName}). A wrapper that needs to keep such a name away\n * from a property binding of its own asks this rather than listing the names.\n */\nexport function isStandardAttributeName(name: string): name is StandardAttributeName {\n  return (\n    STANDARD_NAMES.some((standard) => standard === name) ||\n    (name.startsWith(\"data-\") && name.length > \"data-\".length) ||\n    (name.startsWith(\"aria-\") && name.length > \"aria-\".length)\n  );\n}\n\nconst isEnumerated = (name: string): boolean =>\n  name.startsWith(\"aria-\") || name.startsWith(\"data-\");\n\n// Only a boolean attribute is absent when false; `aria-hidden=\"false\"` and `data-open=\"false\"` mean something.\nconst isOmitted = (name: string, value: unknown): boolean =>\n  value == null || (value === false && !isEnumerated(name));\n\n/**\n * The standard HTML attributes among the given props: `class`, `style`, `id`,\n * `title`, `slot`, `hidden`, `role`, `tabindex`, `data-*` and `aria-*`. A widget\n * element takes these as plain DOM attributes, so a wrapper passes the result to\n * the element. Anything else is left out, so no stray prop can reach the\n * widget's configuration. A value of `undefined` or `null` is left out, and so\n * is `false` except for `aria-*` and `data-*`, which render as the string\n * `\"false\"`. A framework that needs the names marked (Solid writes `attr:id` as\n * an attribute) passes the `prefix` to put before each name except the native\n * ones (`class`, `className` and `style`).\n */\nexport function standardAttributes<Props extends object, Prefix extends string = \"\">(\n  props: Props,\n  prefix?: Prefix,\n): StandardAttributes<Props, Prefix>;\n// The one place the record is typed loosely: the overload above is the type callers get.\nexport function standardAttributes(props: object, prefix = \"\"): Record<string, unknown> {\n  const record: Record<string, unknown> = {};\n  for (const [name, value] of Object.entries(props)) {\n    if (isStandardAttributeName(name) && !isOmitted(name, value)) {\n      const native = NATIVE_NAMES.some((nativeName) => nativeName === name);\n      // An `aria-*` or `data-*` boolean is written out, since not every framework renders `false`.\n      record[native ? name : `${prefix}${name}`] =\n        typeof value === \"boolean\" && isEnumerated(name) ? String(value) : value;\n    }\n  }\n  return record;\n}\n\n/* ───────────────────────────────  Widget names  ───────────────────────────────\n * The widgets and the tag names of their elements, defined once.\n * ───────────────────────────────────────────────────────────────────────── */\n\n/** Every widget name, for code that loops over the widgets. */\nexport const widgetNames = [\"login\", \"logout\", \"session\"] as const;\n\n/** The name of a widget. */\nexport type WidgetName = (typeof widgetNames)[number];\n\n/**\n * The tag names of the widget elements. The elements register under these\n * names, and every SDK wrapper, spec and guard reads them from here rather than\n * spelling them out. The type ties each tag to its widget name.\n */\nexport const widgetTags = {\n  login: \"zitadel-login\",\n  logout: \"zitadel-logout\",\n  session: \"zitadel-session\",\n} as const satisfies Record<WidgetName, `zitadel-${Widg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