{"version":3,"file":"ng-primitives-portal.mjs","sources":["../../../../packages/ng-primitives/portal/src/control-container.ts","../../../../packages/ng-primitives/portal/src/flip.ts","../../../../packages/ng-primitives/portal/src/offset.ts","../../../../packages/ng-primitives/portal/src/overlay-registry.ts","../../../../packages/ng-primitives/portal/src/overlay-cooldown.ts","../../../../packages/ng-primitives/portal/src/overlay-token.ts","../../../../packages/ng-primitives/portal/src/portal.ts","../../../../packages/ng-primitives/portal/src/scroll-strategy.ts","../../../../packages/ng-primitives/portal/src/overlay.ts","../../../../packages/ng-primitives/portal/src/overlay-arrow-state.ts","../../../../packages/ng-primitives/portal/src/shift.ts","../../../../packages/ng-primitives/portal/src/ng-primitives-portal.ts"],"sourcesContent":["import { Provider } from '@angular/core';\nimport { ControlContainer } from '@angular/forms';\n\n/**\n * Provide a null `ControlContainer` at the element level of an overlay-content root directive\n * (e.g. `NgpPopover`, `NgpTooltip`, `NgpMenu`).\n *\n * Overlay content is portaled but its template is often declared inside a form, so its\n * element-injector chain can reach that outer form's `ControlContainer` and leak it into the\n * overlay (ngp#677 / angular#57390). This backstop resolves `ControlContainer` to `null` at the\n * content root: a form declared *inside* the content sits closer in the injector chain and still\n * wins, while a control with no inner form resolves to `null` here instead of escaping to the\n * outer form.\n *\n * Pairs with the `EmbeddedViewInjector` in `overlay.ts`, which returns `notFoundValue` for the\n * `Host`/`SkipSelf` `ControlContainer` lookup so the element-injector walk runs and reaches this.\n */\nexport function provideControlContainerIsolation(): Provider {\n  return { provide: ControlContainer, useValue: null };\n}\n","import { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { isNil, isObject } from 'ng-primitives/utils';\nimport { NgpBoundary, NgpPlacement, NgpRootBoundary } from './positioning';\n\n/**\n * Options for configuring flip behavior to keep the floating element in view.\n * The flip middleware ensures the floating element flips to the opposite side\n * when it would otherwise overflow the viewport.\n */\nexport interface NgpFlipOptions {\n  /**\n   * The minimum padding between the floating element and the viewport edges.\n   * Prevents the floating element from touching the edges of the viewport.\n   * @default 0\n   */\n  padding?: number;\n\n  /**\n   * Placements to try sequentially if the preferred placement does not fit.\n   * @default [oppositePlacement] (computed)\n   */\n  fallbackPlacements?: NgpPlacement[];\n\n  /**\n   * The clipping area the floating element is kept within. Pass an element (or elements)\n   * to constrain the overlay to a container rather than its clipping ancestors.\n   * @default 'clippingAncestors'\n   */\n  boundary?: NgpBoundary;\n\n  /**\n   * The root clipping area the floating element is kept within.\n   * @default 'viewport'\n   */\n  rootBoundary?: NgpRootBoundary;\n\n  /**\n   * Whether to measure overflow against the trigger's clipping ancestors rather than the\n   * panel's. The panel is portalled to the body, so its own clipping ancestors are\n   * effectively the viewport - set this when the trigger sits in a scroll container.\n   *\n   * Applies only while `boundary` is left at its default; an explicit boundary always wins.\n   * @default false\n   */\n  altBoundary?: boolean;\n\n  /**\n   * Whether overflow along the alignment axis is checked when deciding to flip.\n   * `'alignment'` checks it for alignment flipping only.\n   * @default true\n   */\n  crossAxis?: boolean | 'alignment';\n}\n\n/**\n * Type representing all valid flip values.\n * Can be a boolean (enable/disable), undefined, or an object with detailed options.\n */\nexport type NgpFlip = boolean | NgpFlipOptions | undefined;\n\n/**\n * Input type for flip that also accepts string representations of booleans\n */\nexport type NgpFlipInput = NgpFlip | string;\n\n/**\n * Transform function to coerce flip input values to the correct type\n * @param value The input value to coerce\n * @returns The coerced flip value\n */\nexport function coerceFlip(value: NgpFlipInput | null | undefined): NgpFlip {\n  if (isNil(value)) {\n    return undefined;\n  }\n\n  if (isObject(value)) {\n    return value;\n  }\n\n  // Handle boolean values\n  if (typeof value === 'boolean') {\n    return value;\n  }\n\n  // Handle empty attribute values (Angular boolean attribute semantics)\n  if (value === '') {\n    return true;\n  }\n\n  // Handle string boolean values\n  if (value === 'true') {\n    return true;\n  }\n\n  if (value === 'false') {\n    return false;\n  }\n\n  // Handle string number values for padding shorthand\n  const numValue = coerceNumberProperty(value, null);\n  if (numValue !== null && !isNaN(numValue)) {\n    return { padding: numValue };\n  }\n\n  return undefined;\n}\n","import { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { isObject, isNil } from 'ng-primitives/utils';\n\n/**\n * Options for configuring offset between a floating element and its reference element.\n * Can be a single number for uniform offset or an object for axis-specific control.\n */\nexport interface NgpOffsetOptions {\n  /**\n   * The offset along the main axis (the axis that runs along the side of the floating element).\n   * Represents the distance between the floating element and the reference element.\n   * @default 0\n   */\n  mainAxis?: number;\n\n  /**\n   * The offset along the cross axis (the axis that runs along the alignment of the floating element).\n   * Represents the skidding between the floating element and the reference element.\n   * @default 0\n   */\n  crossAxis?: number;\n\n  /**\n   * Same axis as crossAxis but applies only to aligned placements and inverts the end alignment.\n   * When set to a number, it overrides the crossAxis value.\n   * @default null\n   */\n  alignmentAxis?: number | null;\n}\n\n/**\n * Type representing all valid offset values.\n * Can be a number (applies to mainAxis) or an object with axis-specific offsets.\n */\nexport type NgpOffset = number | NgpOffsetOptions;\n\n/**\n * Input type for offset that also accepts string representations of numbers\n */\nexport type NgpOffsetInput = NgpOffset | string;\n\n/**\n * Transform function to coerce offset input values to the correct type\n * @param value The input value to coerce\n * @returns The coerced offset value\n */\nexport function coerceOffset(value: NgpOffsetInput | null | undefined): NgpOffset {\n  if (isNil(value)) {\n    return 0;\n  }\n\n  if (isObject(value)) {\n    return value;\n  }\n\n  // Use CDK's coerceNumberProperty for consistent number coercion\n  // This handles strings, numbers, and other input types just like Angular CDK inputs\n  return coerceNumberProperty(value, 0);\n}\n","import { FocusOrigin } from '@angular/cdk/a11y';\nimport { DOCUMENT } from '@angular/common';\nimport { inject, Injectable, isSignal, NgZone, Signal } from '@angular/core';\nimport { NgpEscapeKeyClaims } from 'ng-primitives/internal';\nimport { Subject } from 'rxjs';\n\n/**\n * A dismiss guard can be a boolean or a callback that returns a boolean (sync or async).\n * - `true` → always dismiss\n * - `false` → never dismiss\n * - `(target) => boolean | Promise<boolean>` → custom logic per interaction\n */\nexport type NgpDismissGuard<T = Element> = boolean | ((target: T) => boolean | Promise<boolean>);\n\n/**\n * Input type for dismiss guard inputs, accepting booleans, string booleans, or guard functions.\n */\nexport type NgpDismissGuardInput<T = Element> = NgpDismissGuard<T> | string;\n\n/**\n * Transform function for dismiss guard inputs.\n * Coerces string boolean values ('', 'true', 'false') while passing through\n * actual booleans and guard functions unchanged.\n */\nexport function dismissGuardAttribute<T>(value: NgpDismissGuardInput<T>): NgpDismissGuard<T> {\n  if (typeof value === 'function') {\n    return value;\n  }\n  if (typeof value === 'boolean') {\n    return value;\n  }\n  // String coercion: '' (attribute present) and 'true' → true, 'false' → false\n  return value !== 'false';\n}\n\n/**\n * Dismiss policy for an overlay entry.\n * Determines how the overlay responds to outside clicks and escape key presses.\n * @internal\n */\nexport interface NgpDismissPolicy {\n  /** Whether clicking outside should close this overlay, or a guard function */\n  outsidePress: NgpDismissGuard<Element>;\n  /** Whether pressing Escape should close this overlay, or a guard function */\n  escapeKey: NgpDismissGuard<KeyboardEvent>;\n}\n\n/**\n * An entry in the overlay registry representing a single visible overlay.\n * @internal\n */\nexport interface NgpOverlayEntry {\n  /** Unique overlay ID */\n  id: string;\n  /** Parent overlay ID, null for root overlays */\n  parentId: string | null;\n  /** Reference to the overlay instance for calling hide()/hideImmediate() */\n  overlay: NgpOverlayRef;\n  /** Function that returns the portal DOM elements */\n  getElements: () => HTMLElement[];\n  /** The trigger element */\n  triggerElement: HTMLElement;\n  /**\n   * Optional anchor element. Pass a signal when the anchor can change while the overlay\n   * is open - an entry is registered once per open and is not re-registered on a change.\n   */\n  anchorElement?: HTMLElement | null | Signal<HTMLElement | null | undefined>;\n  /** Per-instance dismiss configuration */\n  dismissPolicy: NgpDismissPolicy;\n  /** If true, clicks on the trigger element are treated as outside clicks */\n  treatTriggerClickAsOutside?: boolean;\n  /** Optional subject that receives pointer events that occur outside the overlay */\n  outsidePointerEvents$?: Subject<MouseEvent>;\n  /**\n   * Whether closing the parent overlay also closes this one. Defaults to true.\n   * Set it false for an overlay that does not depend on its parent for position - a\n   * dialog is positioned against the viewport, an anchored overlay loses its anchor.\n   */\n  cascadeClose?: boolean;\n}\n\n/**\n * Minimal overlay reference needed by the registry.\n * This avoids a circular dependency with NgpOverlay.\n * @internal\n */\nexport interface NgpOverlayRef {\n  hide(options?: { immediate?: boolean; origin?: FocusOrigin }): void;\n  hideImmediate(): void;\n}\n\n/**\n * Singleton registry that tracks all visible overlays in open order and\n * provides centralized dismiss routing (outside-click and escape-key).\n *\n * Document listeners are attached when the first overlay registers and\n * detached when the last deregisters, avoiding permanent global listeners.\n * @internal\n */\n@Injectable({ providedIn: 'root' })\nexport class NgpOverlayRegistry {\n  private readonly document = inject(DOCUMENT);\n  private readonly ngZone = inject(NgZone);\n  private readonly escapeKeyClaims = inject(NgpEscapeKeyClaims);\n\n  /** Ordered list of visible overlay entries (oldest first, newest/topmost last) */\n  private readonly entries: NgpOverlayEntry[] = [];\n\n  /** Set of overlay IDs currently evaluating an async dismiss guard */\n  private readonly pendingGuardIds = new Set<string>();\n\n  /** Cleanup functions for the centralized document listeners */\n  private removeOutsideClickListener?: () => void;\n  private removeEscapeKeyListener?: () => void;\n  private removeOutsidePointerListeners?: () => void;\n\n  /** Tracks the pointerdown target for CDK-compatible outside pointer event dispatch */\n  private pointerDownTarget: EventTarget | null = null;\n\n  /** Composed path of the last pointerdown, so a press that starts inside an overlay keeps it open */\n  private pressPath: EventTarget[] | null = null;\n\n  /** Open order of each entry, parallel to `entries`, which stays sorted by it. */\n  private readonly orders = new Map<string, number>();\n\n  /** The order the next freshly opened entry receives. */\n  private nextOrder = 0;\n\n  /**\n   * Register an overlay as visible. Attaches document listeners if this is the first entry.\n   * @param order The value a previous `register()` returned, to put the entry back where it\n   * was in the stack. Omit it to register the entry as the topmost overlay.\n   * @returns The entry's open order.\n   */\n  register(entry: NgpOverlayEntry, order?: number): number {\n    // Avoid double-registration\n    const existing = this.orders.get(entry.id);\n    if (existing !== undefined) {\n      return existing;\n    }\n\n    const entryOrder = order ?? this.nextOrder++;\n    const index = this.entries.findIndex(e => this.orders.get(e.id)! > entryOrder);\n    this.entries.splice(index === -1 ? this.entries.length : index, 0, entry);\n    this.orders.set(entry.id, entryOrder);\n\n    // Attach listeners when the first overlay registers\n    if (this.entries.length === 1) {\n      this.attachListeners();\n    }\n\n    return entryOrder;\n  }\n\n  /**\n   * Remove an overlay from the registry.\n   * Detaches document listeners if no entries remain.\n   */\n  deregister(id: string): void {\n    const index = this.entries.findIndex(e => e.id === id);\n    if (index !== -1) {\n      this.entries.splice(index, 1);\n      this.orders.delete(id);\n      this.pendingGuardIds.delete(id);\n    }\n\n    // Detach listeners when the last overlay deregisters\n    if (this.entries.length === 0) {\n      this.detachListeners();\n    }\n  }\n\n  /**\n   * Close all descendants of the given overlay.\n   * Called by NgpOverlay when it hides to cascade the close to children.\n   */\n  closeDescendants(id: string): void {\n    const descendants = this.getCascadingDescendants(id);\n    // Close deepest first to avoid re-entrant issues\n    for (let i = descendants.length - 1; i >= 0; i--) {\n      descendants[i].overlay.hideImmediate();\n    }\n  }\n\n  /**\n   * Descendants of `id` that close along with it. The walk stops at an entry that opted\n   * out, leaving its own subtree open too.\n   */\n  private getCascadingDescendants(id: string): NgpOverlayEntry[] {\n    return this.collectDescendants(id, entry => entry.cascadeClose !== false);\n  }\n\n  /**\n   * Breadth-first walk of `id`'s subtree, so the result is parent-before-child whatever\n   * order `entries` is in. `include` prunes an entry and its subtree.\n   */\n  private collectDescendants(\n    id: string,\n    include: (entry: NgpOverlayEntry) => boolean = () => true,\n  ): NgpOverlayEntry[] {\n    const childrenByParent = new Map<string, NgpOverlayEntry[]>();\n\n    for (const entry of this.entries) {\n      if (entry.parentId === null) {\n        continue;\n      }\n      const siblings = childrenByParent.get(entry.parentId);\n      if (siblings) {\n        siblings.push(entry);\n      } else {\n        childrenByParent.set(entry.parentId, [entry]);\n      }\n    }\n\n    const descendants: NgpOverlayEntry[] = [];\n    const queue = [id];\n    const seen = new Set<string>([id]);\n\n    while (queue.length > 0) {\n      for (const child of childrenByParent.get(queue.shift()!) ?? []) {\n        if (seen.has(child.id) || !include(child)) {\n          continue;\n        }\n        seen.add(child.id);\n        descendants.push(child);\n        queue.push(child.id);\n      }\n    }\n\n    return descendants;\n  }\n\n  /**\n   * Get all registered entries.\n   */\n  getEntries(): readonly NgpOverlayEntry[] {\n    return this.entries;\n  }\n\n  /**\n   * Get the topmost (most recently opened) overlay entry, or null if none.\n   */\n  getTopmost(): NgpOverlayEntry | null {\n    return this.entries.length > 0 ? this.entries[this.entries.length - 1] : null;\n  }\n\n  /**\n   * Find the overlay whose elements contain the given DOM element.\n   * Returns the ID of the most recently opened (topmost) containing overlay, or null.\n   */\n  findContainingOverlay(element: HTMLElement): string | null {\n    // Walk from topmost to oldest so we find the nearest containing overlay\n    for (let i = this.entries.length - 1; i >= 0; i--) {\n      const entry = this.entries[i];\n      const elements = entry.getElements();\n      if (elements.some(el => el.contains(element))) {\n        return entry.id;\n      }\n    }\n    return null;\n  }\n\n  /**\n   * Check whether overlay `ancestorId` is an ancestor of overlay `descendantId`\n   * by walking the parentId chain.\n   */\n  isAncestorOf(ancestorId: string, descendantId: string): boolean {\n    let currentId: string | null = descendantId;\n\n    while (currentId !== null) {\n      const entry = this.entries.find(e => e.id === currentId);\n      if (!entry) {\n        return false;\n      }\n      if (entry.parentId === ancestorId) {\n        return true;\n      }\n      currentId = entry.parentId;\n    }\n\n    return false;\n  }\n\n  /**\n   * Get all descendants of the given overlay (children, grandchildren, etc.)\n   * by walking parentId chains of all entries.\n   */\n  getDescendants(id: string): NgpOverlayEntry[] {\n    return this.collectDescendants(id);\n  }\n\n  /**\n   * Attach centralized document listeners for outside-click and escape-key.\n   * Runs outside Angular zone to avoid unnecessary change detection on every\n   * mouse/keyboard event.\n   */\n  private attachListeners(): void {\n    this.ngZone.runOutsideAngular(() => {\n      const onMouseUp = (event: MouseEvent) => this.handleOutsideClick(event);\n      const onKeyDown = (event: KeyboardEvent) => this.handleEscapeKey(event);\n\n      this.document.addEventListener('mouseup', onMouseUp, true);\n      this.document.addEventListener('keydown', onKeyDown, true);\n\n      this.removeOutsideClickListener = () =>\n        this.document.removeEventListener('mouseup', onMouseUp, true);\n      this.removeEscapeKeyListener = () =>\n        this.document.removeEventListener('keydown', onKeyDown, true);\n\n      // CDK-compatible outside pointer event dispatch:\n      // Track pointerdown origin, then emit click/auxclick/contextmenu events\n      // to entries that have an outsidePointerEvents$ subject.\n      const onPointerDown = (event: PointerEvent) => {\n        this.pointerDownTarget = this.getComposedTarget(event);\n        this.pressPath = event.composedPath();\n      };\n\n      // A cancelled press (e.g. a touch that turns into a scroll) gets no mouseup to consume it\n      const onPointerCancel = () => (this.pressPath = null);\n\n      const onPointerEvent = (event: MouseEvent) => this.handleOutsidePointerEvent(event);\n\n      this.document.addEventListener('pointerdown', onPointerDown, true);\n      this.document.addEventListener('pointercancel', onPointerCancel, true);\n      this.document.addEventListener('click', onPointerEvent, true);\n      this.document.addEventListener('auxclick', onPointerEvent, true);\n      this.document.addEventListener('contextmenu', onPointerEvent, true);\n\n      this.removeOutsidePointerListeners = () => {\n        this.document.removeEventListener('pointerdown', onPointerDown, true);\n        this.document.removeEventListener('pointercancel', onPointerCancel, true);\n        this.document.removeEventListener('click', onPointerEvent, true);\n        this.document.removeEventListener('auxclick', onPointerEvent, true);\n        this.document.removeEventListener('contextmenu', onPointerEvent, true);\n      };\n    });\n  }\n\n  /**\n   * Detach centralized document listeners.\n   */\n  private detachListeners(): void {\n    this.removeOutsideClickListener?.();\n    this.removeOutsideClickListener = undefined;\n    this.removeEscapeKeyListener?.();\n    this.removeEscapeKeyListener = undefined;\n    this.removeOutsidePointerListeners?.();\n    this.removeOutsidePointerListeners = undefined;\n    this.pointerDownTarget = null;\n    this.pressPath = null;\n  }\n\n  /**\n   * Outside-click dismiss: checks all overlays (not just the topmost) and\n   * dismisses every overlay tree where the click landed outside.\n   *\n   * This handles the case where a non-dismissable overlay (e.g. a tooltip) is\n   * topmost but other overlays (e.g. a popover) should still be dismissed.\n   */\n  private handleOutsideClick(event: MouseEvent): void {\n    const pressPath = this.pressPath;\n    // While other buttons are still held (chording), the press that set the path is not over yet\n    if (event.buttons === 0) {\n      this.pressPath = null;\n    }\n\n    if (this.entries.length === 0) {\n      return;\n    }\n\n    // Ignore right-click mouseup — right-clicks open context menus via the\n    // `contextmenu` event, and the corresponding mouseup should never dismiss\n    // an overlay. If the user right-clicks elsewhere, the new `contextmenu`\n    // event on that target will handle repositioning or reopening.\n    if (event.button === 2) {\n      return;\n    }\n\n    // Ignore scrollbar clicks — the click lands outside the viewport's client area.\n    const { clientWidth, clientHeight } = this.document.documentElement;\n    if (\n      clientWidth > 0 &&\n      clientHeight > 0 &&\n      (event.clientX >= clientWidth || event.clientY >= clientHeight)\n    ) {\n      return;\n    }\n\n    const path = event.composedPath();\n\n    // Step 1: Build a set of overlay IDs where the press started or ended \"inside\",\n    // so dragging out of an overlay (e.g. selecting text) does not dismiss it\n    const insideIds = new Set<string>();\n    for (const entry of this.entries) {\n      if (\n        !this.isClickOutsideEntry(entry, path) ||\n        (pressPath && !this.isClickOutsideEntry(entry, pressPath))\n      ) {\n        insideIds.add(entry.id);\n      }\n    }\n\n    // Step 2: Expand insideIds to include all ancestors of inside entries.\n    // If a child contains the click, its entire parent chain is protected.\n    for (const id of insideIds) {\n      let currentId = this.entries.find(e => e.id === id)?.parentId ?? null;\n      while (currentId !== null) {\n        if (insideIds.has(currentId)) break; // already protected\n        insideIds.add(currentId);\n        currentId = this.entries.find(e => e.id === currentId)?.parentId ?? null;\n      }\n    }\n\n    // Step 3: For each entry that is outside, find the highest dismissable ancestor\n    // and collect unique roots to dismiss.\n    const toDismiss = new Map<string, NgpOverlayEntry>();\n    const coveredIds = new Set<string>(); // entries covered by an ancestor we'll dismiss\n\n    // Walk from topmost to oldest\n    for (let i = this.entries.length - 1; i >= 0; i--) {\n      const entry = this.entries[i];\n\n      // Skip entries where the click was inside\n      if (insideIds.has(entry.id)) continue;\n      // Skip entries with pending guards\n      if (this.pendingGuardIds.has(entry.id)) continue;\n      // Skip entries already covered by an ancestor we're about to dismiss\n      if (coveredIds.has(entry.id)) continue;\n\n      // Walk up parent chain to find the highest dismissable ancestor\n      let highest = entry;\n      let currentId = entry.parentId;\n\n      while (currentId !== null) {\n        const parent = this.entries.find(e => e.id === currentId);\n        if (!parent) break;\n        if (insideIds.has(parent.id)) break;\n        if (parent.dismissPolicy.outsidePress === false) break;\n        if (this.pendingGuardIds.has(parent.id)) break;\n\n        highest = parent;\n        currentId = parent.parentId;\n      }\n\n      toDismiss.set(highest.id, highest);\n\n      // Mark all descendants as covered\n      for (const desc of this.getDescendants(highest.id)) {\n        coveredIds.add(desc.id);\n      }\n    }\n\n    // Derive a proper Element from the composed path for guard evaluation\n    const target =\n      (path.find((node): node is Element => node instanceof Element) as Element) ??\n      this.document.documentElement;\n\n    // Step 4: Dismiss each root\n    for (const [id, entry] of toDismiss) {\n      this.evaluateGuardAndDismiss(id, entry.dismissPolicy.outsidePress, target, () =>\n        this.ngZone.run(() => entry.overlay.hide()),\n      );\n    }\n  }\n\n  /**\n   * Check if a click (represented by its composedPath) is outside an entry's\n   * elements, trigger, and anchor.\n   */\n  private isClickOutsideEntry(entry: NgpOverlayEntry, path: EventTarget[]): boolean {\n    const isInsideElements = entry.getElements().some(el => path.includes(el));\n    const isInsideTrigger =\n      !entry.treatTriggerClickAsOutside && path.includes(entry.triggerElement);\n    const anchorElement = isSignal(entry.anchorElement)\n      ? entry.anchorElement()\n      : entry.anchorElement;\n    const isInsideAnchor = anchorElement ? path.includes(anchorElement) : false;\n    return !(isInsideElements || isInsideTrigger || isInsideAnchor);\n  }\n\n  /**\n   * Escape-key dismiss: only the topmost overlay responds.\n   */\n  private handleEscapeKey(event: KeyboardEvent): void {\n    if (event.key !== 'Escape' || event.isComposing) {\n      return;\n    }\n\n    const topmost = this.getTopmost();\n    if (!topmost || this.pendingGuardIds.has(topmost.id)) {\n      return;\n    }\n\n    // a control inside the overlay will handle this Escape itself\n    const path = event.composedPath();\n    if (\n      topmost.getElements().some(el => path.includes(el)) &&\n      this.escapeKeyClaims.isClaimed(event)\n    ) {\n      return;\n    }\n\n    this.evaluateGuardAndDismiss(topmost.id, topmost.dismissPolicy.escapeKey, event, () =>\n      this.ngZone.run(() => topmost.overlay.hide({ origin: 'keyboard', immediate: true })),\n    );\n  }\n\n  /**\n   * CDK-compatible outside pointer event dispatch.\n   * Iterates overlays from topmost to oldest (like CDK's OverlayOutsideClickDispatcher).\n   * For each overlay with an outsidePointerEvents$ subject, emits the event if the\n   * click was outside its elements. Stops iterating when an overlay contains the click.\n   */\n  private handleOutsidePointerEvent(event: MouseEvent): void {\n    const target = this.getComposedTarget(event);\n    // For click events, use the pointerdown origin to handle drag scenarios\n    const origin =\n      event.type === 'click' && this.pointerDownTarget ? this.pointerDownTarget : target;\n    this.pointerDownTarget = null;\n\n    // Iterate from topmost to oldest (like CDK)\n    const overlays = this.entries.slice();\n    for (let i = overlays.length - 1; i >= 0; i--) {\n      const entry = overlays[i];\n\n      if (!entry.outsidePointerEvents$?.observers.length) {\n        continue;\n      }\n\n      const elements = entry.getElements();\n      if (this.containsElement(elements, target) || this.containsElement(elements, origin)) {\n        break;\n      }\n\n      this.ngZone.run(() => entry.outsidePointerEvents$!.next(event));\n    }\n  }\n\n  /**\n   * Get the composed event target, piercing shadow DOM boundaries.\n   */\n  private getComposedTarget(event: Event): EventTarget | null {\n    return event.composedPath?.()?.[0] ?? event.target;\n  }\n\n  /**\n   * Check whether any of the given elements contain the target, piercing shadow DOM.\n   */\n  private containsElement(elements: HTMLElement[], target: EventTarget | null): boolean {\n    if (!target || !(target instanceof Node)) {\n      return false;\n    }\n    return elements.some(el => {\n      let current: Node | null = target;\n      while (current) {\n        if (current === el) return true;\n        current =\n          typeof ShadowRoot !== 'undefined' && current instanceof ShadowRoot\n            ? current.host\n            : current.parentNode;\n      }\n      return false;\n    });\n  }\n\n  /**\n   * Evaluate a dismiss guard and call the dismiss function if allowed.\n   * Supports boolean values and sync/async guard functions.\n   */\n  private evaluateGuardAndDismiss<T>(\n    overlayId: string,\n    guard: NgpDismissGuard<T>,\n    target: T,\n    dismiss: () => void,\n  ): void {\n    if (guard === true || guard === undefined) {\n      dismiss();\n      return;\n    }\n\n    if (guard === false) {\n      return;\n    }\n\n    // Function guard → evaluate\n    let result: boolean | Promise<boolean>;\n    try {\n      result = guard(target);\n    } catch (error) {\n      console.error('NgpOverlayRegistry: dismiss guard threw', error);\n      return;\n    }\n\n    if (typeof result === 'boolean') {\n      if (result) {\n        dismiss();\n      }\n    } else {\n      // Promise — track as pending to prevent re-triggering\n      this.pendingGuardIds.add(overlayId);\n      result\n        .then(shouldDismiss => {\n          if (shouldDismiss) {\n            dismiss();\n          }\n        })\n        .catch(error => {\n          console.error('NgpOverlayRegistry: dismiss guard rejected', error);\n        })\n        .finally(() => {\n          this.pendingGuardIds.delete(overlayId);\n        });\n    }\n  }\n}\n","import { Injectable, WritableSignal, inject } from '@angular/core';\nimport { NgpOverlayRegistry } from './overlay-registry';\n\n/** Interface for overlays that can be closed immediately */\nexport interface CooldownOverlay {\n  /** The registry id, which is how ancestry between overlays is resolved. */\n  id(): string;\n  hideImmediate(options?: { skipExitAnimation?: boolean }): void;\n  /** Optional signal to mark the transition as instant due to cooldown */\n  instantTransition?: WritableSignal<boolean>;\n}\n\n/**\n * Singleton service that tracks close timestamps and active overlays per overlay type.\n * This enables the cooldown feature where quickly moving between triggers\n * of the same overlay type (e.g., tooltip to tooltip) shows the second\n * overlay immediately without the showDelay, and closes the first immediately.\n * @internal\n */\n@Injectable({ providedIn: 'root' })\nexport class NgpOverlayCooldownManager {\n  private readonly registry = inject(NgpOverlayRegistry);\n  private readonly lastCloseTimestamps = new Map<string, number>();\n  /**\n   * Active overlays per type, stored as a stack ordered oldest-first / topmost-last.\n   * Most types only ever hold a single overlay, but when an overlay is nested inside\n   * another of the same type (e.g. a popover whose trigger lives inside another\n   * popover) the child is pushed on top of its ancestor instead of evicting it.\n   * Closing the child then restores the ancestor as the active overlay.\n   */\n  private readonly activeOverlays = new Map<string, CooldownOverlay[]>();\n\n  /**\n   * Record the close timestamp for an overlay type.\n   * @param overlayType The type identifier for the overlay group\n   */\n  recordClose(overlayType: string): void {\n    this.lastCloseTimestamps.set(overlayType, Date.now());\n  }\n\n  /**\n   * Check if the overlay type is within its cooldown period.\n   * @param overlayType The type identifier for the overlay group\n   * @param duration The cooldown duration in milliseconds\n   * @returns true if within cooldown period, false otherwise\n   */\n  isWithinCooldown(overlayType: string, duration: number): boolean {\n    const lastClose = this.lastCloseTimestamps.get(overlayType);\n    if (lastClose === undefined) {\n      return false;\n    }\n    return Date.now() - lastClose < duration;\n  }\n\n  /**\n   * Register an overlay as active for its type.\n   *\n   * Any existing overlay of the same type is closed immediately so that only one\n   * overlay of each type is open at a time - *unless* it is an ancestor of the\n   * overlay being registered. A nested overlay (its trigger rendered inside an\n   * ancestor overlay's content) is stacked on top of its ancestor instead of\n   * evicting it, allowing legitimate nesting to coexist while sibling overlays\n   * still replace one another. Ancestry comes from NgpOverlayRegistry.\n   *\n   * @param overlayType The type identifier for the overlay group\n   * @param overlay The overlay instance\n   * @param cooldown The cooldown duration - if > 0, enables instant transitions\n   */\n  registerActive(overlayType: string, overlay: CooldownOverlay, cooldown: number): void {\n    const stack = this.activeOverlays.get(overlayType) ?? [];\n\n    if (stack.includes(overlay)) {\n      return;\n    }\n\n    // Evict overlays from the top of the stack until we reach the overlay itself\n    // or one of its ancestors (or the stack empties). Ancestors are preserved so\n    // nested same-type overlays can coexist; peers are closed immediately.\n    while (stack.length > 0) {\n      const top = stack[stack.length - 1];\n      if (this.isDescendant(overlay, top)) {\n        break;\n      }\n      if (this.isDescendant(top, overlay)) {\n        const firstDescendantIndex = stack.findIndex(entry => this.isDescendant(entry, overlay));\n        stack.splice(firstDescendantIndex, 0, overlay);\n        this.activeOverlays.set(overlayType, stack);\n        return;\n      }\n      stack.pop();\n      // Enable instant transition only if cooldown is active. The same condition\n      // decides whether an overlay already animating out is cut short: within a\n      // cooldown the swap should read as one movement, without one the outgoing\n      // overlay keeps the exit animation it was given.\n      const isInstant = cooldown > 0;\n      if (isInstant) {\n        top.instantTransition?.set(true);\n      }\n      top.hideImmediate({ skipExitAnimation: isInstant });\n    }\n\n    // Push as the topmost active overlay, avoiding a duplicate entry if it is\n    // already there (e.g. re-registering after a cancelled destruction).\n    if (stack[stack.length - 1] !== overlay) {\n      stack.push(overlay);\n    }\n\n    this.activeOverlays.set(overlayType, stack);\n  }\n\n  /**\n   * Unregister an overlay when it closes.\n   * @param overlayType The type identifier for the overlay group\n   * @param overlay The overlay instance to remove\n   */\n  unregisterActive(overlayType: string, overlay: CooldownOverlay): void {\n    const stack = this.activeOverlays.get(overlayType);\n    if (!stack) {\n      return;\n    }\n\n    const index = stack.indexOf(overlay);\n    if (index !== -1) {\n      stack.splice(index, 1);\n    }\n\n    if (stack.length === 0) {\n      this.activeOverlays.delete(overlayType);\n    }\n  }\n\n  /** Whether `overlay` sits inside `ancestor`, according to the registry. */\n  private isDescendant(overlay: CooldownOverlay, ancestor: CooldownOverlay): boolean {\n    return this.registry.isAncestorOf(ancestor.id(), overlay.id());\n  }\n\n  /**\n   * Check if there's an active overlay of the given type.\n   * @param overlayType The type identifier for the overlay group\n   * @returns true if there's an active overlay, false otherwise\n   */\n  hasActiveOverlay(overlayType: string): boolean {\n    const stack = this.activeOverlays.get(overlayType);\n    return stack !== undefined && stack.length > 0;\n  }\n}\n","import { inject, InjectionToken, Signal, ValueProvider } from '@angular/core';\n\nconst NgpOverlayContextToken = new InjectionToken<unknown>('NgpOverlayContextToken');\n\n/**\n * Injects the context for the overlay.\n * @internal\n */\nexport function injectOverlayContext<T>(): Signal<T> {\n  return inject(NgpOverlayContextToken) as Signal<T>;\n}\n\n/**\n * Provides the context for the overlay.\n * @param value The value to provide as the context.\n * @internal\n */\nexport function provideOverlayContext<T>(value: Signal<T | undefined> | undefined): ValueProvider {\n  return { provide: NgpOverlayContextToken, useValue: value };\n}\n","import { VERSION } from '@angular/cdk';\nimport { ComponentPortal, DomPortalOutlet, TemplatePortal } from '@angular/cdk/portal';\nimport {\n  ApplicationRef,\n  ComponentRef,\n  EmbeddedViewRef,\n  Injector,\n  TemplateRef,\n  Type,\n  ViewContainerRef,\n} from '@angular/core';\nimport { NgpExitAnimationRef, setupExitAnimation } from 'ng-primitives/internal';\n\nexport interface NgpPortalAttachOptions {\n  /** If true, skip enter animation delay and set enter state immediately. */\n  immediate?: boolean;\n}\n\nexport interface NgpPortalDetachOptions {\n  /** If true, skip exit animations and remove immediately. */\n  immediate?: boolean;\n  /**\n   * If true, remove the root nodes from the DOM but keep the underlying view/component\n   * instance alive instead of destroying it, so `reattach()` can cheaply re-insert it\n   * later without the content being re-created.\n   */\n  keepMounted?: boolean;\n}\n\n/**\n * Clear the animation state a previous attach cycle left on a node. Re-inserting an element\n * restarts its CSS animations, so a kept-mounted node still marked `data-exit` would replay\n * its exit animation; a fresh attach starts with neither attribute set.\n */\nfunction clearAnimationState(node: Node): void {\n  if (node instanceof HTMLElement) {\n    node.removeAttribute('data-enter');\n    node.removeAttribute('data-exit');\n  }\n}\n\nexport abstract class NgpPortal {\n  constructor(\n    protected readonly viewContainerRef: ViewContainerRef | null,\n    protected readonly injector: Injector,\n  ) {}\n\n  /**\n   * Get the elements of the portal.\n   */\n  abstract getElements(): HTMLElement[];\n\n  /**\n   * Detect changes in the portal.\n   */\n  abstract detectChanges(): void;\n\n  /**\n   * Whether the portal is attached to a DOM element.\n   */\n  abstract getAttached(): boolean;\n\n  /**\n   * Attach the portal to a DOM element.\n   * @param container The DOM element to attach the portal to.\n   * @param options Optional attach configuration\n   */\n  abstract attach(container: HTMLElement, options?: NgpPortalAttachOptions): this;\n\n  /**\n   * Detach the portal from the DOM.\n   * @param options Optional detach configuration\n   */\n  abstract detach(options?: NgpPortalDetachOptions): Promise<void>;\n\n  /**\n   * Cancel an in-progress detach operation. If exit animations are running,\n   * they are cancelled and the portal transitions back to the enter state.\n   */\n  abstract cancelDetach(): void;\n\n  /**\n   * End an in-progress detach now, skipping the rest of any exit animation, so\n   * the pending `detach()` resolves and tears the view down.\n   *\n   * Concrete rather than abstract: `NgpPortal` is exported, so an abstract\n   * member added here would stop any subclass outside this repo compiling.\n   * Doing nothing is the honest default for a portal that doesn't animate.\n   */\n  finishDetach(): void {\n    // no-op\n  }\n\n  /**\n   * Re-insert a previously detached-but-kept-mounted portal's root nodes into a container.\n   * Only valid after a `detach({ keepMounted: true })` call that left the underlying view alive.\n   * @param container The DOM element to reattach the portal to.\n   * @param options Optional attach configuration\n   */\n  abstract reattach(container: HTMLElement, options?: NgpPortalAttachOptions): void;\n\n  /**\n   * Destroy the underlying view, releasing the content instance. Safe to call more than\n   * once, and the only way to release a portal left alive by `detach({ keepMounted: true })`.\n   */\n  abstract destroyView(): void;\n\n  /**\n   * Angular v20 removes `_unusedComponentFactoryResolver` and `_document` from DomPortalOutlet's\n   * constructor signature as they have been deprecated since v18, and replaced with optional\n   * `_appRef` and `_defaultInjector` params.\n   * This temporary change ensures consistent behaviour for consumers using ng v20+.\n   * @see {@link https://github.com/angular/components/pull/24504 The implementing PR} for the new implementation.\n   * @see {@link https://github.com/angular/components/blob/732a0d7ab69ec25925cc06a0fb17b0fb16a4b0ae/src/cdk/portal/dom-portal-outlet.ts#L27 The latest v20 version comments}\n   * describe the importance of passing the `_appRef` and `_defaultInjector` when it comes to component portals\n   */\n  // todo: remove this compat fix once support for v19 is dropped when v21 is released\n  //  - should aim to add appRef also to prevent unforeseen issues in certain edge cases\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  protected _getDomPortalOutletCtorParamsCompat(): (ApplicationRef | Injector | undefined | any)[] {\n    return Number(VERSION.major) >= 20 ? [this.injector] : [undefined, this.injector];\n  }\n}\n\nexport class NgpComponentPortal<T> extends NgpPortal {\n  private readonly componentPortal: ComponentPortal<T>;\n  private viewRef: ComponentRef<T> | null = null;\n  private isDestroying = false;\n  private detachCancelled = false;\n  private exitAnimationRef: NgpExitAnimationRef | null = null;\n\n  constructor(component: Type<T>, viewContainerRef: ViewContainerRef | null, injector: Injector) {\n    super(viewContainerRef, injector);\n    this.componentPortal = new ComponentPortal(component, viewContainerRef, injector);\n  }\n\n  /**\n   * Attach the portal to a DOM element.\n   * @param container The DOM element to attach the portal to.\n   * @param options Optional attach configuration\n   */\n  attach(container: HTMLElement, options?: NgpPortalAttachOptions): this {\n    const appRef = this.injector.get(ApplicationRef);\n    const domOutlet =\n      Number(VERSION.major) >= 20\n        ? new DomPortalOutlet(container, appRef, this.injector)\n        : // @ts-expect-error: Compatibility for Angular versions < 20\n          new DomPortalOutlet(container, undefined, appRef, this.injector);\n\n    this.viewRef = domOutlet.attach(this.componentPortal);\n\n    const element = this.viewRef.location.nativeElement as HTMLElement;\n\n    this.exitAnimationRef = setupExitAnimation({ element, immediate: options?.immediate });\n\n    return this;\n  }\n\n  /**\n   * Get the root elements of the portal.\n   */\n  getElements(): HTMLElement[] {\n    return this.viewRef ? [this.viewRef.location.nativeElement] : [];\n  }\n\n  /**\n   * Detect changes in the portal.\n   */\n  detectChanges(): void {\n    this.viewRef?.changeDetectorRef.detectChanges();\n  }\n\n  /**\n   * Whether the portal is attached to a DOM element.\n   */\n  getAttached(): boolean {\n    return !!this.viewRef && (this.viewRef.location.nativeElement as HTMLElement).isConnected;\n  }\n\n  /**\n   * Cancel an in-progress detach operation.\n   */\n  cancelDetach(): void {\n    if (this.isDestroying) {\n      this.detachCancelled = true;\n      this.exitAnimationRef?.cancel();\n      this.isDestroying = false;\n    }\n  }\n\n  /**\n   * End an in-progress detach now, skipping the rest of any exit animation.\n   */\n  override finishDetach(): void {\n    if (this.isDestroying) {\n      this.exitAnimationRef?.finish();\n    }\n  }\n\n  /**\n   * Detach the portal from the DOM.\n   * @param options Optional detach configuration\n   */\n  async detach({ immediate, keepMounted }: NgpPortalDetachOptions = {}): Promise<void> {\n    if (this.isDestroying) {\n      return;\n    }\n    this.isDestroying = true;\n    this.detachCancelled = false;\n\n    // Only wait for exit animation if not immediate\n    if (!immediate) {\n      await this.exitAnimationRef?.exit();\n    }\n\n    // If cancelled during exit animation, don't destroy\n    if (this.detachCancelled) {\n      this.detachCancelled = false;\n      return;\n    }\n\n    if (!keepMounted) {\n      this.destroyView();\n      return;\n    }\n\n    if (this.viewRef) {\n      (this.viewRef.location.nativeElement as HTMLElement).remove();\n      // Reusable for a future detach() cycle once reattach() is called.\n      this.isDestroying = false;\n    }\n  }\n\n  /**\n   * Re-insert a previously detached-but-kept-mounted component's root element into a container.\n   */\n  reattach(container: HTMLElement, options?: NgpPortalAttachOptions): void {\n    if (!this.viewRef) {\n      throw new Error('Cannot reattach a component portal that has been destroyed.');\n    }\n\n    const element = this.viewRef.location.nativeElement as HTMLElement;\n    clearAnimationState(element);\n    container.appendChild(element);\n    this.exitAnimationRef = setupExitAnimation({ element, immediate: options?.immediate });\n  }\n\n  /**\n   * Destroy the underlying view. Safe to call more than once.\n   */\n  destroyView(): void {\n    if (this.viewRef) {\n      this.viewRef.destroy();\n      this.viewRef = null;\n    }\n  }\n}\n\nexport class NgpTemplatePortal<T> extends NgpPortal {\n  private readonly templatePortal: TemplatePortal<T>;\n  private viewRef: EmbeddedViewRef<T> | null = null;\n  private exitAnimationRefs: NgpExitAnimationRef[] = [];\n  private isDestroying = false;\n  private detachCancelled = false;\n\n  constructor(\n    template: TemplateRef<T>,\n    viewContainerRef: ViewContainerRef,\n    injector: Injector,\n    context?: T,\n  ) {\n    super(viewContainerRef, injector);\n    this.templatePortal = new TemplatePortal(template, viewContainerRef, context, injector);\n  }\n\n  /**\n   * Attach the portal to a DOM element.\n   * @param container The DOM element to attach the portal to.\n   * @param options Optional attach configuration\n   */\n  attach(container: HTMLElement, options?: NgpPortalAttachOptions): this {\n    const domOutlet = new DomPortalOutlet(\n      container,\n      undefined,\n      ...this._getDomPortalOutletCtorParamsCompat(),\n    );\n    this.viewRef = domOutlet.attach(this.templatePortal);\n\n    for (const rootNode of this.viewRef.rootNodes) {\n      if (rootNode instanceof HTMLElement) {\n        // Setup exit animation for each root node\n        const exitAnimationRef = setupExitAnimation({\n          element: rootNode,\n          immediate: options?.immediate,\n        });\n        this.exitAnimationRefs.push(exitAnimationRef);\n      }\n    }\n\n    return this;\n  }\n\n  /**\n   * Get the root elements of the portal.\n   */\n  getElements(): HTMLElement[] {\n    return this.viewRef ? this.viewRef.rootNodes : [];\n  }\n\n  /**\n   * Detect changes in the portal.\n   */\n  detectChanges(): void {\n    this.viewRef?.detectChanges();\n  }\n\n  /**\n   * Whether the portal is attached to a DOM element.\n   */\n  getAttached(): boolean {\n    // A kept-mounted view still has its root nodes, so being in the document is what counts.\n    return !!this.viewRef && this.viewRef.rootNodes.some((node: Node) => node.isConnected);\n  }\n\n  /**\n   * Cancel an in-progress detach operation.\n   */\n  cancelDetach(): void {\n    if (this.isDestroying) {\n      this.detachCancelled = true;\n      for (const ref of this.exitAnimationRefs) {\n        ref.cancel();\n      }\n      this.isDestroying = false;\n    }\n  }\n\n  /**\n   * End an in-progress detach now, skipping the rest of any exit animation.\n   */\n  override finishDetach(): void {\n    if (this.isDestroying) {\n      for (const ref of this.exitAnimationRefs) {\n        ref.finish();\n      }\n    }\n  }\n\n  /**\n   * Detach the portal from the DOM.\n   * @param options Optional detach configuration\n   */\n  async detach({ immediate, keepMounted }: NgpPortalDetachOptions = {}): Promise<void> {\n    if (this.isDestroying) {\n      return;\n    }\n\n    this.isDestroying = true;\n    this.detachCancelled = false;\n\n    // Only wait for exit animations if not immediate\n    if (!immediate) {\n      await Promise.all(this.exitAnimationRefs.map(ref => ref.exit()));\n    }\n\n    // If cancelled during exit animation, don't destroy\n    if (this.detachCancelled) {\n      this.detachCancelled = false;\n      return;\n    }\n\n    if (!keepMounted) {\n      this.destroyView();\n      return;\n    }\n\n    if (this.viewRef) {\n      for (const node of this.viewRef.rootNodes) {\n        node.parentNode?.removeChild(node);\n      }\n      // Reusable for a future detach() cycle once reattach() is called.\n      this.isDestroying = false;\n    }\n  }\n\n  /**\n   * Re-insert a previously detached-but-kept-mounted embedded view's root nodes into a container.\n   */\n  reattach(container: HTMLElement, options?: NgpPortalAttachOptions): void {\n    if (!this.viewRef) {\n      throw new Error('Cannot reattach a template portal that has been destroyed.');\n    }\n\n    for (const node of this.viewRef.rootNodes) {\n      clearAnimationState(node);\n      container.appendChild(node);\n    }\n\n    this.exitAnimationRefs = this.viewRef.rootNodes\n      .filter((node): node is HTMLElement => node instanceof HTMLElement)\n      .map(element => setupExitAnimation({ element, immediate: options?.immediate }));\n  }\n\n  /**\n   * Destroy the underlying view. Safe to call more than once.\n   */\n  destroyView(): void {\n    if (this.viewRef) {\n      this.viewRef.destroy();\n      this.viewRef = null;\n    }\n  }\n}\n\nexport function createPortal<T>(\n  componentOrTemplate: Type<T> | TemplateRef<T>,\n  viewContainerRef: ViewContainerRef | null,\n  injector: Injector,\n  context?: T,\n): NgpPortal {\n  if (componentOrTemplate instanceof TemplateRef) {\n    if (!viewContainerRef) {\n      throw new Error('A ViewContainerRef is required to create a TemplatePortal.');\n    }\n\n    return new NgpTemplatePortal(componentOrTemplate, viewContainerRef, injector, context);\n  } else {\n    return new NgpComponentPortal(componentOrTemplate, viewContainerRef, injector);\n  }\n}\n","/**\n * Originally based on Angular CDK's scroll strategy.\n * Modified to be fully standalone with no CDK overlay dependency.\n */\nimport { coerceCssPixelValue } from '@angular/cdk/coercion';\nimport { ViewportRuler } from '@angular/cdk/scrolling';\nimport { getOverflowAncestors } from '@floating-ui/dom';\nimport { isFunction, isObject } from 'ng-primitives/utils';\n\nexport interface ScrollStrategy {\n  enable(): void;\n  disable(): void;\n}\n\n/** Cached result of the check that indicates whether the browser supports scroll behaviors. */\nlet scrollBehaviorSupported: boolean | undefined;\n\nexport function supportsScrollBehavior(): boolean {\n  if (scrollBehaviorSupported != null) {\n    return scrollBehaviorSupported;\n  }\n\n  // If we're not in the browser, it can't be supported. Also check for `Element`, because\n  // some projects stub out the global `document` during SSR which can throw us off.\n  if (!isObject(document) || !document || !isFunction(Element) || !Element) {\n    return (scrollBehaviorSupported = false);\n  }\n\n  // If the element can have a `scrollBehavior` style, we can be sure that it's supported.\n  if ('scrollBehavior' in document.documentElement!.style) {\n    return (scrollBehaviorSupported = true);\n  }\n\n  // Check if scrollTo is supported and if it's been polyfilled\n  const scrollToFunction = Element.prototype.scrollTo;\n  if (!scrollToFunction) {\n    return (scrollBehaviorSupported = false);\n  }\n\n  // We can detect if the function has been polyfilled by calling `toString` on it. Native\n  // functions are obfuscated using `[native code]`, whereas if it was overwritten we'd get\n  // the actual function source. Via https://davidwalsh.name/detect-native-function. Consider\n  // polyfilled functions as supporting scroll behavior.\n  return (scrollBehaviorSupported = !/\\{\\s*\\[native code\\]\\s*\\}/.test(scrollToFunction.toString()));\n}\n\ninterface HTMLStyles {\n  top: string;\n  left: string;\n  position: string;\n  overflowY: string;\n  width: string;\n}\n\nexport class BlockScrollStrategy implements ScrollStrategy {\n  private readonly previousHTMLStyles: HTMLStyles = {\n    top: '',\n    left: '',\n    position: '',\n    overflowY: '',\n    width: '',\n  };\n  private previousScrollPosition = { top: 0, left: 0 };\n  private isEnabled = false;\n\n  constructor(\n    private readonly viewportRuler: ViewportRuler,\n    private readonly document: Document,\n  ) {}\n\n  /** Blocks page-level scroll while the attached overlay is open. */\n  enable() {\n    if (this.canBeEnabled()) {\n      const root = this.document.documentElement!;\n\n      this.previousScrollPosition = this.viewportRuler.getViewportScrollPosition();\n\n      // Cache the previous inline styles in case the user had set them.\n      this.previousHTMLStyles.left = root.style.left || '';\n      this.previousHTMLStyles.top = root.style.top || '';\n      this.previousHTMLStyles.position = root.style.position || '';\n      this.previousHTMLStyles.overflowY = root.style.overflowY || '';\n      this.previousHTMLStyles.width = root.style.width || '';\n\n      // Set the styles to block scrolling.\n      root.style.position = 'fixed';\n\n      // Necessary for the content not to lose its width. Note that we're using 100%, instead of\n      // 100vw, because 100vw includes the width plus the scrollbar, whereas 100% is the width\n      // that the element had before we made it `fixed`.\n      root.style.width = '100%';\n\n      // Note: this will always add a scrollbar to whatever element it is on, which can\n      // potentially result in double scrollbars. It shouldn't be an issue, because we won't\n      // block scrolling on a page that doesn't have a scrollbar in the first place.\n      root.style.overflowY = 'scroll';\n\n      // Note: we're using the `html` node, instead of the `body`, because the `body` may\n      // have the user agent margin, whereas the `html` is guaranteed not to have one.\n      root.style.left = coerceCssPixelValue(-this.previousScrollPosition.left);\n      root.style.top = coerceCssPixelValue(-this.previousScrollPosition.top);\n      root.setAttribute('data-scrollblock', '');\n      this.isEnabled = true;\n    }\n  }\n\n  /** Unblocks page-level scroll while the attached overlay is open. */\n  disable(): void {\n    if (this.isEnabled) {\n      const html = this.document.documentElement!;\n      const body = this.document.body!;\n      const htmlStyle = html.style;\n      const bodyStyle = body.style;\n      const previousHtmlScrollBehavior = htmlStyle.scrollBehavior || '';\n      const previousBodyScrollBehavior = bodyStyle.scrollBehavior || '';\n\n      this.isEnabled = false;\n\n      htmlStyle.left = this.previousHTMLStyles.left;\n      htmlStyle.top = this.previousHTMLStyles.top;\n      htmlStyle.position = this.previousHTMLStyles.position;\n      htmlStyle.overflowY = this.previousHTMLStyles.overflowY;\n      htmlStyle.width = this.previousHTMLStyles.width;\n      html.removeAttribute('data-scrollblock');\n\n      // Disable user-defined smooth scrolling temporarily while we restore the scroll position.\n      // See https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior\n      // Note that we don't mutate the property if the browser doesn't support `scroll-behavior`,\n      // because it can throw off feature detections in `supportsScrollBehavior` which\n      // checks for `'scrollBehavior' in documentElement.style`.\n      if (supportsScrollBehavior()) {\n        htmlStyle.scrollBehavior = bodyStyle.scrollBehavior = 'auto';\n      }\n\n      window.scroll(this.previousScrollPosition.left, this.previousScrollPosition.top);\n\n      if (supportsScrollBehavior()) {\n        htmlStyle.scrollBehavior = previousHtmlScrollBehavior;\n        bodyStyle.scrollBehavior = previousBodyScrollBehavior;\n      }\n    }\n  }\n\n  private canBeEnabled(): boolean {\n    const html = this.document.documentElement!;\n\n    if (\n      html.classList.contains('cdk-global-scrollblock') ||\n      html.hasAttribute('data-scrollblock') ||\n      this.isEnabled\n    ) {\n      return false;\n    }\n\n    const viewport = this.viewportRuler.getViewportSize();\n    return html.scrollHeight > viewport.height || html.scrollWidth > viewport.width;\n  }\n}\n\nexport class CloseScrollStrategy implements ScrollStrategy {\n  private cleanups: (() => void)[] = [];\n\n  constructor(\n    private readonly triggerElement: HTMLElement,\n    private readonly onClose: () => void,\n    private readonly overlayElements: () => HTMLElement[],\n  ) {}\n\n  enable(): void {\n    // Guard against double-enable: remove any existing listeners first\n    this.disable();\n\n    const ancestors = getOverflowAncestors(this.triggerElement);\n\n    const handler = (event: Event) => {\n      const target = event.target;\n\n      // Don't close if the scroll happened inside the overlay\n      if (target instanceof Node) {\n        const elements = this.overlayElements();\n        if (elements.some(el => el.contains(target))) {\n          return;\n        }\n      }\n\n      // Stop listening immediately to prevent redundant close calls from rapid scroll events\n      this.disable();\n      this.onClose();\n    };\n\n    for (const ancestor of ancestors) {\n      ancestor.addEventListener('scroll', handler, { passive: true });\n      this.cleanups.push(() => ancestor.removeEventListener('scroll', handler));\n    }\n  }\n\n  disable(): void {\n    for (const cleanup of this.cleanups) {\n      cleanup();\n    }\n    this.cleanups = [];\n  }\n}\n\nexport class NoopScrollStrategy implements ScrollStrategy {\n  enable(): void {\n    // No operation for enabling\n  }\n\n  disable(): void {\n    // No operation for disabling\n  }\n}\n","import { FocusMonitor, FocusOrigin } from '@angular/cdk/a11y';\nimport { ViewportRuler } from '@angular/cdk/scrolling';\nimport { DOCUMENT } from '@angular/common';\nimport {\n  DestroyRef,\n  Injector,\n  Provider,\n  Signal,\n  TemplateRef,\n  Type,\n  ViewContainerRef,\n  computed,\n  inject,\n  isSignal,\n  runInInjectionContext,\n  signal,\n} from '@angular/core';\nimport { ControlContainer } from '@angular/forms';\nimport {\n  VirtualElement,\n  arrow,\n  autoUpdate,\n  computePosition,\n  flip,\n  offset,\n  shift,\n  size,\n} from '@floating-ui/dom';\nimport { explicitEffect, fromResizeEvent } from 'ng-primitives/internal';\nimport { injectDisposables, safeTakeUntilDestroyed, uniqueId } from 'ng-primitives/utils';\nimport { Subject, Subscription } from 'rxjs';\nimport { NgpFlip, NgpFlipOptions } from './flip';\nimport { NgpOffset } from './offset';\nimport { CooldownOverlay, NgpOverlayCooldownManager } from './overlay-cooldown';\nimport { NgpDismissGuard, NgpOverlayRegistry } from './overlay-registry';\nimport { provideOverlayContext } from './overlay-token';\nimport { NgpPortal, createPortal } from './portal';\nimport { NgpPosition } from './position';\nimport { NgpMiddleware, NgpPlacement, NgpPositioningStrategy } from './positioning';\nimport {\n  BlockScrollStrategy,\n  CloseScrollStrategy,\n  NoopScrollStrategy,\n  ScrollStrategy,\n} from './scroll-strategy';\nimport { NgpShift, NgpShiftOptions } from './shift';\n\n/**\n * Bit values of the internal inject flags used by Angular's DI system. These are\n * part of Angular's ABI and are stable across versions 19+.\n * @see InjectFlags / InternalInjectFlags\n */\nconst HOST_FLAG = 1;\nconst SKIP_SELF_FLAG = 4;\n\n/**\n * Check whether the given inject flags include `Host` or `SkipSelf` - the flags a\n * form directive uses when resolving its parent `ControlContainer`. Angular 20 and\n * earlier tagged `FormControlName`/`FormGroupName` lookups with `SkipSelf`; Angular\n * 21 tags them with `Host` instead (the flag `NgModel` has always used). Either flag\n * means \"resolve the ancestor control container\", the lookup the overlay intercepts.\n */\nfunction hasHostOrSkipSelfFlag(flags: unknown): boolean {\n  if (typeof flags === 'number') {\n    return (flags & (HOST_FLAG | SKIP_SELF_FLAG)) !== 0;\n  }\n  if (flags != null && typeof flags === 'object') {\n    return !!(flags as { host?: unknown }).host || !!(flags as { skipSelf?: unknown }).skipSelf;\n  }\n  return false;\n}\n\n/**\n * An injector wrapper that intercepts `ControlContainer` lookups carrying the\n * `Host` or `SkipSelf` flag and short-circuits them to `notFoundValue`.\n *\n * ## Why this is needed\n *\n * Angular's `lookupTokenUsingEmbeddedInjector` consults the embedded view's injector\n * before the element-injector walk for these lookups. A form directive resolving its\n * parent `ControlContainer` (`FormControlName`, `FormGroupName`, `NgModel`) reaches\n * this injector; if it returns the delegate's `ControlContainer: null` record, that\n * `null` short-circuits the lookup and the element-injector walk never runs, so a\n * `formControlName` declared inside an inner form within the overlay can no longer\n * find that inner form and throws NG01050.\n *\n * Angular 20 and earlier tagged `FormControlName`/`FormGroupName` lookups with\n * `SkipSelf`; Angular 21 tags them with `Host` (the flag `NgModel` has always used),\n * so the intercept must cover both flags.\n *\n * ## The fix\n *\n * For `ControlContainer` + `Host`/`SkipSelf`, return `notFoundValue` so the\n * element-injector walk runs and finds an inner form's `ControlContainer` when one\n * exists. To stop a control with **no** inner form from escaping to the *outer*\n * form, each overlay-content root directive (`NgpPopover`, `NgpTooltip`, `NgpMenu`,\n * …) applies `provideControlContainerIsolation()` (a `ControlContainer: null` at\n * element level): an inner form sits closer in the injector chain and still wins,\n * while a bare control resolves to `null` there instead of leaking the outer form.\n *\n * @see https://github.com/angular/angular/issues/57390\n * @see https://github.com/ng-primitives/ng-primitives/issues/677\n * @internal\n */\nclass EmbeddedViewInjector extends Injector {\n  constructor(private readonly delegate: Injector) {\n    super();\n  }\n\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  get(token: any, notFoundValue?: any, flags?: any): any {\n    if (token === ControlContainer && hasHostOrSkipSelfFlag(flags)) {\n      return notFoundValue;\n    }\n    return this.delegate.get(token, notFoundValue, flags);\n  }\n}\n\n/**\n * Normalise a `boolean | options | undefined` middleware config to its options object, or\n * `undefined` when the middleware is disabled. Both middleware are enabled by default.\n */\nfunction resolveOverflowOptions<T extends NgpFlipOptions | NgpShiftOptions>(\n  config: boolean | T | undefined,\n): T | undefined {\n  if (config === false) {\n    return undefined;\n  }\n\n  return config === true || config === undefined ? ({} as T) : config;\n}\n\n/**\n * Configuration options for creating an overlay\n * @internal\n */\nexport interface NgpOverlayConfig<T = unknown> {\n  /**\n   * Content to display in the overlay (component or template). Read whenever the\n   * overlay opens, and while it is open a change swaps the rendered content, so a\n   * trigger can hand over an input signal and let it change.\n   *\n   * Clearing it closes the overlay immediately - there is nothing left to render, so\n   * neither the hide delay nor the exit animation applies - and an overlay with no\n   * content will not open.\n   */\n  content: Signal<NgpOverlayContent<T> | null | undefined>;\n\n  /** The element that triggers the overlay */\n  triggerElement: HTMLElement;\n\n  /**\n   * The element to use for positioning the overlay (if different from trigger).\n   *\n   * Pass a signal to re-anchor an overlay that is already open - a plain element is\n   * read once, when the overlay is created, and never revisited.\n   */\n  anchorElement?: HTMLElement | null | Signal<HTMLElement | null | undefined>;\n\n  /** The injector to use for creating the portal */\n  injector: Injector;\n  /** ViewContainerRef to use for creating the portal */\n  viewContainerRef: ViewContainerRef;\n\n  /** Context data to pass to the overlay content */\n  context?: Signal<T | undefined>;\n\n  /**\n   * Container element or selector to attach the overlay to (defaults to document.body).\n   * A signal is re-resolved each time the overlay opens; an open overlay is not moved.\n   */\n  container?: HTMLElement | string | null | Signal<HTMLElement | string | null | undefined>;\n\n  /** Preferred placement of the overlay relative to the trigger. */\n  placement?: Signal<NgpPlacement>;\n\n  /** Offset distance between the overlay and trigger. Can be a number or an object with axis-specific offsets */\n  offset?: NgpOffset;\n\n  /** Shift configuration to keep the overlay in view. Can be a boolean, an object with options, or undefined */\n  shift?: NgpShift;\n\n  /** Whether to enable flip behavior when space is limited, or an object with flip options */\n  flip?: NgpFlip;\n\n  /** Delay before showing the overlay in milliseconds */\n  showDelay?: number;\n\n  /** Delay before hiding the overlay in milliseconds */\n  hideDelay?: number;\n\n  /** Whether the overlay should be positioned with fixed or absolute strategy */\n  strategy?: NgpPositioningStrategy;\n\n  /** The scroll strategy to use for the overlay */\n  scrollBehaviour?: 'reposition' | 'block' | 'close';\n  /** Whether to close the overlay when clicking outside, or a guard function */\n  closeOnOutsideClick?: NgpDismissGuard<Element>;\n  /** Whether to close the overlay when pressing escape, or a guard function */\n  closeOnEscape?: NgpDismissGuard<KeyboardEvent>;\n  /**\n   * Whether to restore focus to the trigger element when hiding the overlay.\n   * Can be a boolean or a signal that returns a boolean.\n   */\n  restoreFocus?: boolean | Signal<boolean>;\n\n  /**\n   * Optional callback to update an external close origin signal.\n   * Called when the overlay is hidden with the focus origin.\n   * @internal\n   */\n  onClose?: (origin: FocusOrigin) => void;\n  /** Additional middleware for floating UI positioning */\n  additionalMiddleware?: NgpMiddleware[];\n\n  /** Additional providers */\n  providers?: Provider[];\n\n  /** Whether to track the trigger element position on every animation frame. Useful for moving elements like slider thumbs. */\n  trackPosition?: boolean;\n\n  /**\n   * Programmatic position for the overlay. When provided, the overlay will be positioned\n   * at these coordinates instead of anchoring to the trigger element.\n   * Use with trackPosition for smooth cursor following.\n   */\n  position?: Signal<NgpPosition | null>;\n\n  /**\n   * If true, clicks on the trigger element count as outside clicks for dismiss purposes.\n   * Useful for context menus where the trigger area is large and clicks on it should dismiss the menu.\n   */\n  treatTriggerClickAsOutside?: boolean;\n\n  /**\n   * Overlay type identifier for cooldown grouping.\n   * When set, overlays of the same type share a cooldown period.\n   * For example, 'tooltip' ensures quickly moving between tooltips shows\n   * the second one immediately without the showDelay.\n   */\n  overlayType?: string;\n\n  /**\n   * When true, hiding the overlay removes its content from the DOM but keeps the\n   * underlying component/view instance alive in memory instead of destroying it -\n   * a later `show()` re-inserts the same instance rather than creating a new one, so\n   * the content is not re-instantiated and any one-time setup is not repeated.\n   * The kept-alive view stays attached to change detection while it is hidden.\n   *\n   * Read on each hide, so a trigger can hand over an input signal and let it change.\n   * @default false\n   */\n  keepMounted?: Signal<boolean>;\n\n  /**\n   * Cooldown duration in milliseconds.\n   * When moving from one overlay of the same type to another within this duration,\n   * the showDelay is skipped for the new overlay.\n   * @default 300\n   */\n  cooldown?: number;\n}\n\n/** Type for overlay content which can be either a template or component */\nexport type NgpOverlayContent<T> = TemplateRef<NgpOverlayTemplateContext<T>> | Type<unknown>;\n\n/** Context for template-based overlays */\nexport type NgpOverlayTemplateContext<T> = {\n  $implicit: T;\n};\n\n/**\n * NgpOverlay manages the lifecycle and positioning of overlay UI elements.\n * It abstracts the common behavior shared by tooltips, popovers, menus, etc.\n * @internal\n */\nexport class NgpOverlay<T = unknown> implements CooldownOverlay {\n  private readonly disposables = injectDisposables();\n  private readonly document = inject(DOCUMENT);\n  private readonly viewportRuler = inject(ViewportRuler);\n  private readonly destroyRef = inject(DestroyRef);\n  private readonly viewContainerRef: ViewContainerRef;\n  private readonly focusMonitor = inject(FocusMonitor);\n  private readonly cooldownManager = inject(NgpOverlayCooldownManager);\n  private readonly registry = inject(NgpOverlayRegistry);\n  /** Access any parent overlays */\n  private readonly parentOverlay = inject(NgpOverlay, { optional: true });\n  /** Signal tracking the portal instance */\n  private readonly portal = signal<NgpPortal | null>(null);\n  /** The dedicated outlet element registered by the overlay directive (e.g. NgpMenu) */\n  private registeredOutletElement: HTMLElement | null = null;\n  /** The content the current portal was built from, to tell a real change from a repeat */\n  private renderedContent: NgpOverlayContent<T> | null = null;\n\n  /** Signal tracking the overlay position */\n  readonly position = signal<{ x: number | undefined; y: number | undefined }>({\n    x: undefined,\n    y: undefined,\n  });\n\n  /**\n   * Determine if the overlay has been positioned\n   * @internal\n   */\n  readonly isPositioned = computed(\n    () => this.position().x !== undefined && this.position().y !== undefined,\n  );\n\n  /** Signal tracking the trigger element width */\n  readonly triggerWidth = signal<number | null>(null);\n\n  /** The transform origin for the overlay */\n  readonly transformOrigin = signal<string>('center center');\n\n  /** Signal tracking the available width before the overlay overflows the viewport */\n  readonly availableWidth = signal<number | null>(null);\n\n  /** Signal tracking the available height before the overlay overflows the viewport */\n  readonly availableHeight = signal<number | null>(null);\n\n  private availableSizePrefix: string | null = null;\n\n  /** Signal tracking the final placement of the overlay */\n  readonly finalPlacement = signal<NgpPlacement | undefined>(undefined);\n\n  /** Function to dispose the positioning auto-update */\n  private disposePositioning?: () => void;\n\n  /** Timeout handle for showing the overlay */\n  private openTimeout?: () => void;\n\n  /**\n   * Resolvers for every caller awaiting a scheduled open - the one that started it and\n   * any that joined while it was pending. Without these, a `show()` returned a promise\n   * that never settled, so anything chained onto it - e.g. moving focus into a menu once\n   * it has opened - never ran.\n   */\n  private pendingShowResolvers: (() => void)[] = [];\n\n  /** Timeout handle for hiding the overlay */\n  private closeTimeout?: () => void;\n\n  /** Portal currently being destroyed (for cancel support during exit animations) */\n  private destroyingPortal: NgpPortal | null = null;\n\n  /**\n   * Portal kept alive (detached from the DOM but not destroyed) after a keepMounted hide,\n   * with the content it was built from so a later show can check it is still reusable.\n   * The registered outlet is kept too: the reused view does not construct its directive\n   * again, so nothing would re-register it.\n   */\n  private keptMounted: {\n    portal: NgpPortal;\n    content: NgpOverlayContent<T>;\n    outletElement: HTMLElement | null;\n  } | null = null;\n\n  /**\n   * The container the current open attached into. A content swap while open re-attaches\n   * here rather than re-resolving `config.container`, so a container change never moves\n   * an open overlay - it takes effect on the next open.\n   */\n  private openContainer: HTMLElement | null = null;\n\n  /** This overlay's place in the registry stack, restored when a close is interrupted. */\n  private registryOrder?: number;\n\n  /**\n   * Whether the overlay itself has been torn down. A hide already in flight when that happens\n   * finishes on its own clock, so it checks this before keeping its view mounted for reuse.\n   */\n  private forceDestroyed = false;\n\n  /** Signal tracking whether the overlay is open */\n  readonly isOpen = signal(false);\n\n  /** A unique id for the overlay */\n  readonly id = signal<string>(uniqueId('ngp-overlay'));\n\n  /**\n   * Signal tracking the focus origin used to close the overlay.\n   * Updated when hide() is called.\n   * @internal\n   */\n  readonly closeOrigin = signal<FocusOrigin>('program');\n\n  /** The aria-describedby attribute for accessibility */\n  readonly ariaDescribedBy = computed(() => (this.isOpen() ? this.id() : undefined));\n\n  /** The scroll strategy */\n  private scrollStrategy = new NoopScrollStrategy();\n\n  /** An observable that emits when the overlay is closing */\n  readonly closing = new Subject<void>();\n\n  /**\n   * Signal tracking whether the current transition is instant due to cooldown.\n   * When true, CSS can skip animations using the data-instant attribute.\n   */\n  readonly instantTransition = signal(false);\n\n  /**\n   * The configured anchor as given, kept in a signal of its own so `updateConfig()`\n   * can replace it wholesale - including swapping between an element and a signal.\n   */\n  private readonly anchorSource = signal<NgpOverlayConfig<T>['anchorElement']>(undefined);\n\n  /**\n   * The anchor resolved to an element, so a caller passing an element, a caller passing\n   * a signal, and a later `updateConfig()` are all handled the same way downstream.\n   */\n  private readonly anchorElement = computed(() => {\n    const source = this.anchorSource();\n    return isSignal(source) ? source() : source;\n  });\n\n  /**\n   * Resize monitoring for the current reference element. Held so it can be moved to a\n   * new element when the anchor changes.\n   */\n  private resizeSubscription?: Subscription;\n\n  /** The element resizeSubscription is currently watching. */\n  private monitoredElement?: HTMLElement;\n\n  /**\n   * The reference the anchor-bound bindings were last built against. Kept apart from\n   * `monitoredElement` so that whether the anchor has moved is not answered by where the\n   * resize observer happens to be pointed - they agree today, and a second reason to move\n   * the observer would silently stop anchor changes being noticed at all.\n   */\n  private boundReference?: HTMLElement;\n\n  /** Store the arrow element */\n  private arrowElement: HTMLElement | null = null;\n\n  /** Store the arrow padding signal */\n  private arrowPadding: Signal<number | undefined> | undefined = undefined;\n\n  /** @internal The position of the arrow */\n  readonly arrowPosition = signal<{ x: number | undefined; y: number | undefined }>({\n    x: undefined,\n    y: undefined,\n  });\n\n  /**\n   * Creates a new overlay instance\n   * @param config Initial configuration for the overlay\n   * @param destroyRef Reference for automatic cleanup\n   */\n  constructor(private config: NgpOverlayConfig<T>) {\n    // we cannot inject the viewContainerRef as this can throw an error during hydration in SSR\n    this.viewContainerRef = config.viewContainerRef;\n\n    this.anchorSource.set(config.anchorElement);\n\n    // Listen for placement signal changes to update position\n    // eslint-disable-next-line @angular-eslint/no-uncalled-signals -- checking whether the optional signal was provided, not its value\n    if (config.placement !== undefined) {\n      explicitEffect([config.placement], () => this.updatePosition());\n    }\n\n    // Listen for position signal changes to update position\n    // eslint-disable-next-line @angular-eslint/no-uncalled-signals -- checking whether the optional signal was provided, not its value\n    if (config.position !== undefined) {\n      explicitEffect([config.position], () => this.updatePosition());\n    }\n\n    // Listen for content changes to re-render what is on screen. A closed overlay needs\n    // nothing here - it reads the content when it opens.\n    explicitEffect([config.content], () => this.replaceContent());\n\n    // this must be done after the config is set\n    this.transformOrigin.set(this.getTransformOrigin());\n\n    // Monitor trigger element resize\n    this.monitorReferenceResize();\n\n    // The anchor can change while the overlay is open, and everything bound to the\n    // previous element has to follow it - not just the computed position. Seeded with the\n    // reference monitored above, so the effect's first run - which carries the initial\n    // anchor, not a change - has nothing to move.\n    this.boundReference = this.referenceElement;\n    explicitEffect([this.anchorElement], () => this.handleAnchorChange());\n\n    // Ensure cleanup on destroy\n    this.destroyRef.onDestroy(() => {\n      this.destroy();\n    });\n  }\n\n  /**\n   * Watch the reference element for resizes, replacing any previous subscription so a\n   * changed anchor is measured instead of the element it replaced.\n   */\n  private monitorReferenceResize(): void {\n    const element = this.referenceElement;\n\n    // Re-running for the same element would restart the zero-measurement guard below,\n    // which is what keeps a trigger that has not been laid out yet from closing itself.\n    if (this.monitoredElement === element) {\n      return;\n    }\n\n    this.monitoredElement = element;\n    this.resizeSubscription?.unsubscribe();\n\n    let hasMeasuredNonZeroReference = false;\n    // An anchor change reaches this from an effect, where there is no injection context.\n    this.resizeSubscription = fromResizeEvent(element, { injector: this.config.injector })\n      .pipe(safeTakeUntilDestroyed(this.destroyRef))\n      .subscribe(({ width, height }) => {\n        this.triggerWidth.set(width);\n\n        if (width !== 0 && height !== 0) {\n          hasMeasuredNonZeroReference = true;\n          return;\n        }\n\n        // If the element *has been* hidden, hide immediately. That means a transition\n        // from a real size to none — not merely a zero reading, of which there can be\n        // several before the trigger ever has a box (an empty inline trigger measures\n        // 0x0, and both the initial measurement and the observer's first callback\n        // report it). Closing on those tears down an overlay that was only just\n        // opened, and the trigger may still be about to grow.\n        if (hasMeasuredNonZeroReference) {\n          this.hideImmediate();\n        }\n      });\n  }\n\n  /**\n   * Move everything bound to the previous anchor across to the new one. The resize\n   * observer, the close-scroll strategy's overflow ancestors and floating-ui's\n   * `autoUpdate` reference all capture the element when they are created, so a changed\n   * anchor has to rebuild them rather than just recompute the position.\n   */\n  private handleAnchorChange(): void {\n    const reference = this.referenceElement;\n\n    // A controlled input can notify without the resolved element differing. Rebuilding for\n    // a reference that has not moved would tear down `autoUpdate` under an overlay\n    // mid-flight for nothing.\n    if (this.boundReference === reference) {\n      return;\n    }\n\n    this.boundReference = reference;\n    this.monitorReferenceResize();\n\n    // `isOpen` stays true for the length of the exit animation, but the portal is\n    // cleared and the scroll strategy disabled as soon as teardown begins. Rebuilding\n    // either of them in that window installs listeners nothing disables again, so the\n    // live portal - not `isOpen` - is what says there is something to move.\n    const portal = this.portal();\n\n    if (!portal || !this.isOpen()) {\n      return;\n    }\n\n    // CloseScrollStrategy resolves the reference's overflow ancestors in enable().\n    if (this.config.scrollBehaviour === 'close') {\n      this.scrollStrategy.disable();\n      this.scrollStrategy = this.createScrollStrategy();\n      this.scrollStrategy.enable();\n    }\n\n    const outletElement = this.findOutletElement(portal);\n\n    if (outletElement && this.disposePositioning) {\n      this.disposePositioning();\n      // `autoUpdate` positions once as it binds, so the overlay is already over the new\n      // anchor - repositioning again here would compute a second time and run change\n      // detection over the portal twice for one anchor change.\n      this.setupPositioning(outletElement);\n      return;\n    }\n\n    this.updatePosition();\n  }\n\n  /**\n   * The element the overlay is positioned and tracked against - the anchor when one is\n   * configured, otherwise the trigger.\n   */\n  private get referenceElement(): HTMLElement {\n    return this.anchorElement() ?? this.config.triggerElement;\n  }\n\n  /**\n   * Show the overlay with the specified delay\n   * @param options Optional options for showing the overlay\n   */\n  show(options?: { skipCooldown?: boolean }): Promise<void> {\n    return new Promise<void>(resolve => {\n      // If closing is in progress, cancel it\n      if (this.closeTimeout) {\n        this.closeTimeout();\n        this.closeTimeout = undefined;\n      }\n\n      // If destruction is in progress (exit animation running), cancel it\n      // and reuse the existing overlay instead of creating a new one.\n      if (this.destroyingPortal) {\n        this.cancelDestruction();\n        resolve();\n        return;\n      }\n\n      // Already shown - settle immediately.\n      if (this.isOpen()) {\n        resolve();\n        return;\n      }\n\n      // An open is already scheduled: join it rather than starting a second one, so\n      // this caller settles when that open completes (or when it is cancelled).\n      if (this.openTimeout) {\n        this.pendingShowResolvers.push(resolve);\n        return;\n      }\n\n      // Use the provided delay or fall back to config\n      let delay = this.config.showDelay ?? 0;\n      let isInstantDueToCooldown = false;\n\n      // Check cooldown regardless of delay value - we need to detect instant transitions\n      // even when showDelay is 0, so CSS can skip animations via data-instant attribute.\n      // However, if cooldown is explicitly set to 0, disable cooldown behavior entirely.\n      // Skip cooldown detection entirely when skipCooldown is true (e.g. programmatic show).\n      if (!options?.skipCooldown && this.config.overlayType) {\n        const cooldownDuration = this.config.cooldown ?? 300;\n        if (\n          cooldownDuration > 0 &&\n          (this.cooldownManager.isWithinCooldown(this.config.overlayType, cooldownDuration) ||\n            this.cooldownManager.hasActiveOverlay(this.config.overlayType))\n        ) {\n          delay = 0; // Skip delay (no-op if already 0)\n          isInstantDueToCooldown = true;\n        }\n      }\n\n      // Set instant transition flag based on whether delay was skipped due to cooldown\n      this.instantTransition.set(isInstantDueToCooldown);\n\n      // Queue this caller alongside any that join while the open is scheduled, so a\n      // cancelled open settles the caller that started it as well as the joiners.\n      this.pendingShowResolvers.push(resolve);\n\n      this.openTimeout = this.disposables.setTimeout(() => {\n        this.openTimeout = undefined;\n\n        try {\n          this.createOverlay(options?.skipCooldown);\n        } finally {\n          // Settle even if creating the overlay threw, so callers are never left hanging.\n          this.settlePendingShows();\n        }\n      }, delay);\n    });\n  }\n\n  /**\n   * Settle everyone who awaited a show that was already scheduled. Called both when the\n   * open completes and when it is cancelled - the promise means \"the show attempt has\n   * finished\", so callers should check `isOpen()` rather than assume success.\n   */\n  private settlePendingShows(): void {\n    const resolvers = this.pendingShowResolvers;\n    this.pendingShowResolvers = [];\n\n    for (const resolve of resolvers) {\n      resolve();\n    }\n  }\n\n  /**\n   * Stop any pending close operation. This is useful for example, if we move the mouse from the tooltip trigger to the tooltip itself.\n   * This will prevent the tooltip from closing immediately when the mouse leaves the trigger.\n   * @internal\n   */\n  cancelPendingClose(): void {\n    if (this.closeTimeout) {\n      this.closeTimeout();\n      this.closeTimeout = undefined;\n    }\n\n    // Also cancel in-progress destruction (exit animation running)\n    if (this.destroyingPortal) {\n      this.cancelDestruction();\n    }\n  }\n\n  /**\n   * Cancel an in-progress overlay destruction. This cancels exit animations,\n   * restores the portal, and re-enables positioning and scroll strategy.\n   * Used when show() or cancelPendingClose() is called during exit animation.\n   */\n  private cancelDestruction(): void {\n    const portal = this.destroyingPortal;\n\n    // Teardown is terminal - a destroyed overlay must not be brought back, and its portal\n    // stays on the destroy path so the view is released when the detach settles.\n    if (!portal || this.forceDestroyed) {\n      return;\n    }\n\n    this.destroyingPortal = null;\n    portal.cancelDetach();\n\n    // An immediate keepMounted detach has already pulled the live view out of the DOM.\n    const reattachTo =\n      portal.getElements().length > 0 && !portal.getAttached() ? this.openContainer : null;\n    if (reattachTo) {\n      portal.reattach(reattachTo, { immediate: true });\n    }\n\n    // Restore the portal\n    this.portal.set(portal);\n\n    // Re-setup positioning\n    const outletElement = this.findOutletElement(portal);\n    if (outletElement) {\n      this.setupPositioning(outletElement);\n    }\n\n    // Re-enable scroll strategy\n    this.scrollStrategy = this.createScrollStrategy();\n    this.scrollStrategy.enable();\n\n    // destroyOverlay() deregistered before the exit animation started. An immediate detach\n    // leaves nothing on screen to route dismissals to. The stack mirrors the DOM: a view that\n    // never left keeps its place, a reattached one is now last in its container.\n    if (portal.getElements().length > 0) {\n      this.registerWithRegistry(reattachTo ? undefined : this.registryOrder);\n    }\n\n    // Re-register with cooldown if needed\n    if (this.config.overlayType) {\n      this.cooldownManager.registerActive(this.config.overlayType, this, this.config.cooldown ?? 0);\n    }\n\n    // Content changes are skipped while a close is under way, so the restored portal can\n    // be rendering content the trigger has already moved on from.\n    this.replaceContent();\n  }\n\n  /**\n   * Hide the overlay with the specified delay\n   * @param options Optional options for hiding the overlay\n   */\n  hide(options?: OverlayTriggerOptions): void {\n    // If opening is in progress, cancel it\n    if (this.openTimeout) {\n      this.openTimeout();\n      this.openTimeout = undefined;\n      this.settlePendingShows();\n    }\n\n    // Don't proceed if already closing or closed unless immediate is true\n    if ((this.closeTimeout && !options?.immediate) || !this.isOpen()) {\n      return;\n    }\n\n    // If immediate and there's a pending close, cancel it first\n    // (we'll dispose immediately instead of waiting for the old timeout)\n    if (options?.immediate && this.closeTimeout) {\n      this.closeTimeout();\n      this.closeTimeout = undefined;\n    }\n\n    this.closing.next();\n\n    // Check cooldown BEFORE recording, then record for the next overlay\n    let delay = this.config.hideDelay ?? 0;\n    if (this.config.overlayType) {\n      // Skip delay if within cooldown period for this overlay type\n      if (delay > 0) {\n        const cooldownDuration = this.config.cooldown ?? 300;\n        if (this.cooldownManager.isWithinCooldown(this.config.overlayType, cooldownDuration)) {\n          delay = 0;\n        }\n      }\n      // Record close timestamp so the next overlay of the same type can see it\n      this.cooldownManager.recordClose(this.config.overlayType);\n    }\n\n    const dispose = async () => {\n      this.closeTimeout = undefined;\n\n      // If show() was called while we were waiting, abort the close\n      if (this.openTimeout) {\n        return;\n      }\n\n      const origin = options?.origin ?? 'program';\n\n      // Update the close origin signal so computed signals can react\n      this.closeOrigin.set(origin);\n\n      // Call the onClose callback if provided (for external signal updates)\n      this.config.onClose?.(origin);\n\n      // Determine if focus should be restored\n      const shouldRestoreFocus =\n        typeof this.config.restoreFocus === 'function'\n          ? this.config.restoreFocus()\n          : (this.config.restoreFocus ?? false);\n\n      if (shouldRestoreFocus) {\n        this.focusMonitor.focusVia(this.config.triggerElement, options?.origin ?? 'program', {\n          preventScroll: true,\n        });\n      }\n\n      await this.destroyOverlay();\n    };\n\n    if (options?.immediate) {\n      // If immediate, dispose right away\n      dispose();\n    } else {\n      // Reset instant transition for normal closes so exit animations can play.\n      // When being replaced by another overlay during cooldown, hideImmediate()\n      // is called instead (which doesn't come through here), and registerActive\n      // sets instantTransition to true before that call. The `data-instant`\n      // attribute itself is dropped later, as the element switches to its exit\n      // state - see clearInstantAttribute().\n      this.instantTransition.set(false);\n      this.closeTimeout = this.disposables.setTimeout(dispose, delay);\n    }\n  }\n\n  /**\n   * Render the current content. The portal captures its content when it is created, so\n   * content that changes while the overlay is on screen has to rebuild it; a closed\n   * overlay needs nothing, as opening reads the content afresh.\n   */\n  private replaceContent(): void {\n    // A close that is already under way owns the current portal - rebuilding it here\n    // would put the overlay back on screen after it was dismissed.\n    if (!this.isOpen() || this.closeTimeout || this.destroyingPortal) {\n      return;\n    }\n\n    const portal = this.portal();\n\n    if (!portal) {\n      return;\n    }\n\n    const content = this.config.content();\n\n    // Already rendering this content. The effect runs for its initial value too, and\n    // this is also reached from cancelDestruction, so neither costs an open overlay its\n    // DOM when nothing actually changed.\n    if (content === this.renderedContent) {\n      return;\n    }\n\n    // Nothing left to render - close rather than leave the previous content on screen.\n    if (!content) {\n      this.hideImmediate();\n      return;\n    }\n\n    this.portal.set(null);\n    this.disposePositioning?.();\n    this.disposePositioning = undefined;\n    this.registeredOutletElement = null;\n\n    // Immediate on both sides: the exit animation belongs to the content being\n    // replaced, and replaying the entrance would read as a close and reopen rather\n    // than a content change.\n    portal.detach({ immediate: true });\n    this.attachPortal(content, true, this.openContainer ?? undefined);\n  }\n\n  /**\n   * Update the configuration of this overlay\n   * @param config New configuration (partial)\n   */\n  updateConfig(config: Partial<NgpOverlayConfig<T>>): void {\n    this.config = { ...this.config, ...config };\n\n    // Everything anchor-bound reads the resolved signal rather than the config, so a\n    // replacement anchor has to reach it or the overlay keeps using the original.\n    if ('anchorElement' in config) {\n      this.anchorSource.set(config.anchorElement);\n    }\n\n    // If the overlay is already open, update its position\n    if (this.isOpen()) {\n      this.updatePosition();\n    }\n  }\n\n  /**\n   * Immediately hide the overlay without any delay.\n   * When called during cooldown transitions, this destroys the overlay\n   * immediately without exit animations.\n   * @param options Optional hide configuration\n   */\n  hideImmediate(options?: OverlayHideImmediateOptions): void {\n    // An exit already under way owns the portal - `portal()` is nulled the\n    // moment destroyOverlay starts - so ending it is the only way an immediate\n    // hide reaches an overlay that has begun animating out. Opt-in, because a\n    // plain close still owes the caller the exit animation it asked for.\n    if (options?.skipExitAnimation) {\n      this.destroyingPortal?.finishDetach();\n    }\n\n    // Cancel any pending operations\n    if (this.openTimeout) {\n      this.openTimeout();\n      this.openTimeout = undefined;\n      this.settlePendingShows();\n    }\n    if (this.closeTimeout) {\n      this.closeTimeout();\n      this.closeTimeout = undefined;\n    }\n\n    // Only fire close events if the overlay is still mounted. `portal()` is\n    // nulled synchronously at the start of destroyOverlay, so on a second\n    // hideImmediate() (e.g. when both a caller's destroy and the overlay's\n    // own destroyRef.onDestroy both fire) we skip re-emitting - `isOpen()`\n    // alone is not enough because it's only flipped after destroyOverlay's\n    // `await portal.detach()`, leaving a window where it lies.\n    if (this.isOpen() && this.portal() !== null) {\n      // Emit closing event\n      this.closing.next();\n\n      // Update close origin and call callback (default to 'program' for immediate closes)\n      this.closeOrigin.set('program');\n      this.config.onClose?.('program');\n    }\n    this.destroyOverlay({ immediate: true, forceDestroy: options?.forceDestroy });\n  }\n\n  /**\n   * Toggle the overlay open/closed state\n   */\n  toggle(): void {\n    if (this.isOpen()) {\n      this.hide();\n    } else {\n      this.show();\n    }\n  }\n\n  /**\n   * Force update the position of the overlay\n   */\n  updatePosition(): void {\n    const portal = this.portal();\n\n    if (!portal) {\n      return;\n    }\n\n    const outletElement = this.findOutletElement(portal);\n\n    if (!outletElement) {\n      return;\n    }\n\n    // Compute new position\n    this.computePosition(outletElement);\n  }\n\n  /**\n   * Completely destroy this overlay instance\n   */\n  destroy(): void {\n    this.hideImmediate({ forceDestroy: true });\n    this.disposePositioning?.();\n    this.scrollStrategy.disable();\n  }\n\n  /**\n   * Get the elements of the overlay\n   */\n  getElements(): HTMLElement[] {\n    return this.portal()?.getElements() ?? [];\n  }\n\n  /**\n   * Register the dedicated outlet element for positioning.\n   * Called by overlay directives (e.g. NgpMenu) during construction to ensure\n   * the correct element is used for floating-ui positioning, even when the\n   * directive is on a nested child component rather than the portal root.\n   * @internal\n   */\n  registerOutletElement(element: HTMLElement): void {\n    this.registeredOutletElement = element;\n\n    // If positioning is already set up with the wrong element, re-setup with the correct one\n    if (this.isOpen() && this.disposePositioning) {\n      this.disposePositioning();\n      this.setupPositioning(element);\n    }\n  }\n\n  /**\n   * Register the custom property prefix (e.g. `--ngp-popover`) the `size` middleware writes\n   * `<prefix>-available-width` and `<prefix>-available-height` under.\n   * @internal\n   */\n  registerAvailableSizePrefix(prefix: string): void {\n    this.availableSizePrefix = prefix;\n  }\n\n  /**\n   * Find the dedicated outlet element within the portal.\n   * Uses the registered outlet element if available, otherwise looks for an element\n   * with `data-overlay` attribute on the portal root elements.\n   * Falls back to the first portal element if no dedicated outlet is found.\n   */\n  private findOutletElement(portal: NgpPortal): HTMLElement | null {\n    if (this.registeredOutletElement) {\n      return this.registeredOutletElement;\n    }\n\n    const elements = portal.getElements();\n\n    if (elements.length === 0) {\n      return null;\n    }\n\n    return elements.find(el => el.hasAttribute('data-overlay')) ?? elements[0];\n  }\n\n  /** Add this overlay to the registry. Idempotent, so an interrupted close can re-run it. */\n  private registerWithRegistry(order?: number): void {\n    this.registryOrder = this.registry.register(\n      {\n        id: this.id(),\n        parentId: this.resolveParentId(),\n        overlay: this,\n        getElements: () => this.getElements(),\n        triggerElement: this.config.triggerElement,\n        anchorElement: this.anchorElement,\n        dismissPolicy: {\n          outsidePress: this.config.closeOnOutsideClick ?? false,\n          escapeKey: this.config.closeOnEscape ?? false,\n        },\n        treatTriggerClickAsOutside: this.config.treatTriggerClickAsOutside,\n      },\n      order,\n    );\n  }\n\n  /**\n   * The overlay this one was opened from: the nearest registered overlay containing the\n   * trigger in the DOM, else the injected one. The injector chain alone would skip a dialog,\n   * whose injector descends from its trigger's.\n   */\n  private resolveParentId(): string | null {\n    const trigger = this.config.triggerElement;\n    const containing = trigger ? this.registry.findContainingOverlay(trigger) : null;\n    return containing ?? this.parentOverlay?.id() ?? null;\n  }\n\n  /**\n   * Internal method to create the overlay\n   * @param skipCooldown If true, skip registering with the cooldown manager\n   */\n  private createOverlay(skipCooldown?: boolean): void {\n    const content = this.config.content();\n\n    // Nothing to render: either the trigger never had content, or it was cleared while\n    // the show delay was running. Either way there is nothing to open with.\n    if (!content) {\n      return;\n    }\n\n    // Skip the enter animation delay if this is an instant transition\n    this.attachPortal(content, this.instantTransition());\n\n    // Mark as open\n    this.isOpen.set(true);\n\n    // Register with the overlay registry for centralized dismiss routing\n    this.registerWithRegistry();\n\n    // Register as active overlay for this type (skip when cooldown is bypassed)\n    if (this.config.overlayType && !skipCooldown) {\n      this.cooldownManager.registerActive(this.config.overlayType, this, this.config.cooldown ?? 0);\n    }\n\n    this.scrollStrategy = this.createScrollStrategy();\n    this.scrollStrategy.enable();\n  }\n\n  /**\n   * Create the portal for the current content, attach it to the container and start\n   * positioning it. Shared by the initial open and by content swaps.\n   * @param content The content to render\n   * @param immediate If true, skip the enter animation\n   * @param container The container to attach into; resolved from the config when omitted\n   */\n  private attachPortal(\n    content: NgpOverlayContent<T>,\n    immediate: boolean,\n    container: HTMLElement = this.resolveContainer(),\n  ): void {\n    this.renderedContent = content;\n    this.openContainer = container;\n\n    let portal: NgpPortal;\n    const keptMounted = this.keptMounted;\n\n    if (keptMounted?.content === content) {\n      // Reuse the portal kept alive from a previous keepMounted hide - re-inserts its\n      // existing DOM nodes rather than creating a new view/component instance, so the\n      // content is not re-instantiated and its one-time setup does not re-run.\n      this.keptMounted = null;\n      this.registeredOutletElement = keptMounted.outletElement;\n      portal = keptMounted.portal;\n      portal.reattach(container, { immediate });\n    } else {\n      // A kept-mounted portal from a previous hide no longer matches the current\n      // content (e.g. the overlay's content input changed while it was hidden) -\n      // it can't be reused, so its view is destroyed instead of leaking.\n      this.discardKeptMounted();\n\n      // Create a new portal with context.\n      // The injector is wrapped in EmbeddedViewInjector to work around an Angular 19 bug\n      // where @SkipSelf() causes the embedded view injector's ControlContainer: null to be\n      // bypassed. See https://github.com/angular/angular/issues/57390\n      portal = createPortal(\n        content,\n        this.viewContainerRef,\n        new EmbeddedViewInjector(\n          Injector.create({\n            parent: this.config.injector,\n            providers: [\n              ...(this.config.providers || []),\n              { provide: NgpOverlay, useValue: this },\n              provideOverlayContext<T>(this.config.context),\n              { provide: ControlContainer, useValue: null },\n            ],\n          }),\n        ),\n        { $implicit: this.config.context } as NgpOverlayTemplateContext<T>,\n      );\n\n      // Attach portal to container\n      portal.attach(container, { immediate });\n    }\n\n    // Update portal signal\n    this.portal.set(portal);\n\n    // If instant transition is active, set data-instant attribute synchronously\n    // so CSS can use it for styling purposes\n    if (this.instantTransition()) {\n      for (const element of portal.getElements()) {\n        element.setAttribute('data-instant', '');\n      }\n    }\n\n    // Ensure view is up to date\n    portal.detectChanges();\n\n    // find a dedicated outlet element\n    // this is the element that has the `data-overlay` attribute\n    // if no such element exists, we use the first element in the portal\n    const outletElement = this.findOutletElement(portal);\n\n    if (!outletElement) {\n      throw new Error('Overlay element is not available.');\n    }\n\n    // Set up positioning\n    this.setupPositioning(outletElement);\n  }\n\n  /**\n   * Create the appropriate scroll strategy based on the configuration.\n   */\n  private createScrollStrategy(): ScrollStrategy {\n    switch (this.config.scrollBehaviour) {\n      case 'block':\n        return new BlockScrollStrategy(this.viewportRuler, this.document);\n      case 'close':\n        return new CloseScrollStrategy(\n          this.referenceElement,\n          () => this.hide({ immediate: true }),\n          () => this.getElements(),\n        );\n      default:\n        return new NoopScrollStrategy();\n    }\n  }\n\n  /**\n   * Internal method to setup positioning of the overlay\n   */\n  private setupPositioning(overlayElement: HTMLElement): void {\n    // Get the reference for auto-update - use trigger element for resize/scroll tracking\n    // even when using programmatic position (the virtual element is created dynamically in computePosition)\n    // Setup auto-update for positioning\n    this.disposePositioning = autoUpdate(\n      this.referenceElement,\n      overlayElement,\n      () => this.computePosition(overlayElement),\n      { animationFrame: this.config.trackPosition ?? false },\n    );\n  }\n\n  /**\n   * Determine the positioning strategy from the overlay element's computed CSS.\n   *\n   * Resolved per pass so every caller agrees: `updatePosition()` used to reach\n   * `computePosition()` without one and take the `absolute` default, which offsets a\n   * `fixed` panel by the page scroll.\n   */\n  private resolveStrategy(overlayElement: HTMLElement): NgpPositioningStrategy {\n    return getComputedStyle(overlayElement).position === 'fixed'\n      ? 'fixed'\n      : this.config.strategy || 'absolute';\n  }\n\n  /**\n   * Compute the overlay position using floating-ui\n   */\n  private async computePosition(overlayElement: HTMLElement): Promise<void> {\n    const strategy = this.resolveStrategy(overlayElement);\n\n    // Create middleware array\n    // Order matters: offset → flip → shift → size → arrow (per Floating UI docs)\n    const middleware: NgpMiddleware[] = [offset(this.config.offset ?? 0)];\n\n    // Resolved before the middleware are added so `size` can reuse the overflow boundary.\n    const flipOptions = resolveOverflowOptions(this.config.flip);\n    const shiftOptions = resolveOverflowOptions(this.config.shift);\n\n    // Add flip middleware if requested\n    // Flip must come before shift so that shift doesn't prevent flip from triggering\n    if (flipOptions) {\n      middleware.push(flip(flipOptions));\n    }\n\n    // Add shift middleware (enabled by default for backward compatibility)\n    // Shift keeps the overlay in view by shifting it along its axis when it would otherwise overflow the viewport\n    if (shiftOptions) {\n      middleware.push(shift(shiftOptions));\n    }\n\n    // Add size middleware to expose available dimensions. It measures the space before the\n    // overlay overflows, so it has to read against the same boundary that keeps the overlay\n    // in view: flip's when flip sets one, otherwise shift's. Enabled-by-default flip resolves\n    // to `{}`, so the test is whether it names a boundary rather than whether it exists -\n    // `{}` would otherwise mask a boundary set on shift. Taken together, so the fields can't\n    // be composed from different middleware into a region neither measures against.\n    // Padding is deliberately not shared: adopting it would shrink the reported dimensions\n    // for anyone already setting it on flip or shift.\n    const overflowOptions =\n      flipOptions?.boundary !== undefined ||\n      flipOptions?.rootBoundary !== undefined ||\n      flipOptions?.altBoundary !== undefined\n        ? flipOptions\n        : shiftOptions;\n\n    middleware.push(\n      size({\n        boundary: overflowOptions?.boundary,\n        rootBoundary: overflowOptions?.rootBoundary,\n        altBoundary: overflowOptions?.altBoundary,\n        apply: ({ availableWidth, availableHeight, elements }) => {\n          this.availableWidth.set(availableWidth);\n          this.availableHeight.set(availableHeight);\n\n          // Written now rather than by the element's bindings on the next render: `size`\n          // re-measures the element after `apply` and starts over when its size changed, so\n          // the position is computed for the size the element is capped to.\n          const prefix = this.availableSizePrefix;\n          if (prefix) {\n            elements.floating.style.setProperty(`${prefix}-available-width`, `${availableWidth}px`);\n            elements.floating.style.setProperty(\n              `${prefix}-available-height`,\n              `${availableHeight}px`,\n            );\n          }\n        },\n      }),\n    );\n\n    // Add any additional middleware\n    if (this.config.additionalMiddleware) {\n      middleware.push(...this.config.additionalMiddleware);\n    }\n\n    // If the arrow element is registered, add arrow middleware\n    if (this.arrowElement) {\n      middleware.push(arrow({ element: this.arrowElement, padding: this.arrowPadding?.() }));\n    }\n\n    // Compute the position\n    const placement = this.config.placement?.() ?? 'top';\n\n    // Use programmatic position if provided, otherwise use anchor/trigger element\n    const referenceElement = this.getPositionReference();\n\n    const position = await computePosition(referenceElement, overlayElement, {\n      placement,\n      middleware,\n      strategy,\n    });\n\n    // Update position signal\n    this.position.set({ x: position.x, y: position.y });\n\n    // Update final placement signal\n    this.finalPlacement.set(position.placement);\n    this.transformOrigin.set(this.getTransformOrigin(position.placement));\n\n    // Update arrow position if available\n    if (this.arrowElement) {\n      this.arrowPosition.set({\n        x: position.middlewareData.arrow?.x,\n        y: position.middlewareData.arrow?.y,\n      });\n    }\n\n    // Ensure view is updated\n    this.portal()?.detectChanges();\n  }\n\n  /**\n   * Get the reference element for positioning. When a programmatic position is provided,\n   * creates a virtual element at that position. Otherwise returns the anchor or trigger element.\n   */\n  private getPositionReference(): HTMLElement | VirtualElement {\n    const pos = this.config.position?.();\n    if (pos) {\n      // Create virtual element that reads position fresh on each call\n      return {\n        getBoundingClientRect: () => {\n          const currentPos = this.config.position?.() ?? pos;\n          return new DOMRect(currentPos.x, currentPos.y, 0, 0);\n        },\n        contextElement: this.config.triggerElement,\n      };\n    }\n    return this.referenceElement;\n  }\n\n  /**\n   * Internal method to destroy the overlay portal\n   * @param options Optional destroy configuration\n   */\n  private async destroyOverlay({\n    immediate,\n    forceDestroy,\n  }: OverlayDestroyOptions = {}): Promise<void> {\n    if (forceDestroy) {\n      this.forceDestroyed = true;\n    }\n\n    const portal = this.portal();\n\n    if (!portal) {\n      // Nothing currently shown - but if a kept-mounted portal is sitting hidden from a\n      // previous close and we're being force-destroyed (overlay itself torn down), its\n      // underlying view still needs to be destroyed too.\n      if (forceDestroy) {\n        this.discardKeptMounted();\n      }\n      return;\n    }\n\n    // Close any descendant overlays before destroying this one\n    this.registry.closeDescendants(this.id());\n\n    // Deregister from the overlay registry\n    this.registry.deregister(this.id());\n\n    // Clear portal reference to prevent double destruction\n    this.portal.set(null);\n\n    // Clean up positioning\n    this.disposePositioning?.();\n    this.disposePositioning = undefined;\n\n    // Track the destroying portal so cancelDestruction() can restore it\n    // if show() is called during the exit animation.\n    this.destroyingPortal = portal;\n\n    // disable scroll strategy\n    this.scrollStrategy.disable();\n    this.scrollStrategy = new NoopScrollStrategy();\n\n    // The content the portal was built from, captured up front because it is cleared below\n    // but is needed to hand the portal back for reuse. It is the single source of truth for\n    // whether to keep the view alive, so the flag `detach()` is given cannot drift from the\n    // one acted on after the await.\n    const reusableContent =\n      !forceDestroy && (this.config.keepMounted?.() ?? false) ? this.renderedContent : null;\n\n    // Captured up front for the same reason: `updateConfig()` can replace the\n    // config while the exit animation runs, and unregistering under a new type\n    // would leave this overlay registered under its old one forever.\n    const overlayType = this.config.overlayType;\n\n    // Synchronous with the switch to the exit state below, so the element never\n    // renders a frame in its enter state without it.\n    this.clearInstantAttribute(portal);\n\n    // Detach the portal (waits for exit animations unless immediate).\n    // During this await, cancelDestruction() may be called if the user\n    // re-hovers the trigger. (See: https://github.com/ng-primitives/ng-primitives/issues/681)\n    // When keeping the content mounted, this removes the DOM nodes but leaves the underlying\n    // view/component instance alive so attachPortal() can reuse it later.\n    await portal.detach({ immediate, keepMounted: reusableContent !== null });\n\n    // Only complete destruction if it was not cancelled during exit animation.\n    // finalPlacement and instantTransition are intentionally cleared here\n    // (not before the await) so they remain valid if destruction is cancelled.\n    if (this.destroyingPortal === portal) {\n      const outletElement = this.registeredOutletElement;\n      this.destroyingPortal = null;\n      this.registeredOutletElement = null;\n      this.openContainer = null;\n\n      if (reusableContent) {\n        // The overlay was torn down while this hide was still awaiting its exit animation,\n        // so there is nothing left to reuse the view - release it rather than keeping it\n        // alive past the teardown that already ran.\n        if (this.forceDestroyed) {\n          portal.destroyView();\n        } else {\n          this.keptMounted = { portal, content: reusableContent, outletElement };\n        }\n      }\n\n      // Unregister only once the overlay is really gone. An exit animation\n      // leaves it on screen for a while yet, and a same-type overlay opening in\n      // that window has to be able to replace it rather than fade in over it.\n      // Skipped when destruction was cancelled - it is live again.\n      if (overlayType) {\n        this.cooldownManager.unregisterActive(overlayType, this);\n      }\n\n      this.renderedContent = null;\n      this.isOpen.set(false);\n      this.finalPlacement.set(undefined);\n      this.instantTransition.set(false);\n    }\n  }\n\n  /**\n   * Drop `data-instant` as the element goes into its exit state, so a normal\n   * close still animates out.\n   *\n   * The timing is the whole point. Consumers opt out of instant transitions with\n   * `[data-instant][data-enter] { animation: none }`, so an element left in its\n   * enter state without the attribute matches its entrance rule again and\n   * replays that animation from its opening frame - the panel blinks out and\n   * back before it exits. Removing it here keeps that window closed: the exit\n   * state is applied synchronously by the `detach()` that follows.\n   */\n  private clearInstantAttribute(portal: NgpPortal): void {\n    for (const element of portal.getElements()) {\n      element.removeAttribute('data-instant');\n    }\n  }\n\n  /**\n   * Destroy the view of a portal kept alive by `keepMounted`, if there is one. Used when it\n   * can no longer be reused (the content changed) or when the overlay itself is torn down.\n   */\n  private discardKeptMounted(): void {\n    this.keptMounted?.portal.destroyView();\n    this.keptMounted = null;\n  }\n\n  /**\n   * Get the transform origin for the overlay\n   */\n  private getTransformOrigin(placement = this.config.placement?.() ?? 'top'): string {\n    const basePlacement = placement.split('-')[0]; // Extract \"top\", \"bottom\", etc.\n    const alignment = placement.split('-')[1]; // Extract \"start\" or \"end\"\n\n    const map: Record<string, string> = {\n      top: 'bottom',\n      bottom: 'top',\n      left: 'right',\n      right: 'left',\n    };\n\n    let x = 'center';\n    let y = 'center';\n\n    if (basePlacement === 'top' || basePlacement === 'bottom') {\n      y = map[basePlacement];\n      if (alignment === 'start') x = 'left';\n      else if (alignment === 'end') x = 'right';\n    } else {\n      x = map[basePlacement];\n      if (alignment === 'start') y = 'top';\n      else if (alignment === 'end') y = 'bottom';\n    }\n\n    return `${y} ${x}`;\n  }\n\n  /**\n   * Register the arrow element for positioning\n   * @param arrowElement The arrow element\n   * @param padding Optional padding signal between the arrow and the edges of the floating element\n   * @internal\n   */\n  registerArrow(arrowElement: HTMLElement | null, padding?: Signal<number | undefined>): void {\n    this.arrowElement = arrowElement;\n    this.arrowPadding = padding;\n  }\n\n  /**\n   * Remove the registered arrow element\n   * @internal\n   */\n  unregisterArrow(): void {\n    this.arrowElement = null;\n    this.arrowPadding = undefined;\n  }\n\n  /**\n   * Resolve the container element from the configuration\n   * @internal\n   */\n  private resolveContainer(): HTMLElement {\n    const rawContainer = isSignal(this.config.container)\n      ? this.config.container()\n      : this.config.container;\n\n    if (!rawContainer) {\n      return this.document.body;\n    }\n\n    if (typeof rawContainer === 'string') {\n      const element = this.document.querySelector(rawContainer);\n      if (!element) {\n        // Fallback to document.body if the container is not found\n        console.warn(\n          `NgPrimitives: Container element with selector \"${rawContainer}\" not found. Falling back to document.body.`,\n        );\n        return this.document.body;\n      }\n\n      return element as HTMLElement;\n    }\n\n    return rawContainer;\n  }\n}\n\n/**\n * Helper function to create an overlay in a single call\n * @internal\n */\nexport function createOverlay<T>(config: NgpOverlayConfig<T>): NgpOverlay<T> {\n  // we run the overlay creation in the injector context to ensure that it can call the inject function\n  return runInInjectionContext(config.injector, () => new NgpOverlay<T>(config));\n}\n\n/**\n * Helper function to inject the NgpOverlay instance\n * @internal\n */\nexport function injectOverlay<T>(): NgpOverlay<T> {\n  return inject(NgpOverlay);\n}\n\nexport interface OverlayHideImmediateOptions {\n  /**\n   * When true, bypass `keepMounted` and fully destroy any kept-alive portal - used when the\n   * overlay itself is being torn down (see `destroy()`), not just hidden.\n   */\n  forceDestroy?: boolean;\n  /**\n   * When true, end an exit animation that is already running instead of letting it play out.\n   * Used when another overlay of the same type is replacing this one during its cooldown, so\n   * the swap reads as one movement rather than a cross-fade.\n   */\n  skipExitAnimation?: boolean;\n}\n\ninterface OverlayDestroyOptions extends OverlayHideImmediateOptions {\n  /** If true, skip exit animations and remove immediately. */\n  immediate?: boolean;\n}\n\nexport interface OverlayTriggerOptions {\n  /**\n   * Whether the visibility change should be immediate.\n   */\n  immediate?: boolean;\n  /**\n   * The origin of the focus event that triggered the visibility change.\n   */\n  origin?: FocusOrigin;\n}\n","import { computed, signal, Signal, WritableSignal } from '@angular/core';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport {\n  controlled,\n  createPrimitive,\n  dataBinding,\n  onDestroy,\n  styleBinding,\n} from 'ng-primitives/state';\nimport { injectOverlay } from './overlay';\n\n/**\n * The state interface for the overlay arrow.\n */\nexport interface NgpOverlayArrowState {\n  /**\n   * The x position of the arrow.\n   */\n  readonly x: Signal<number | undefined>;\n  /**\n   * The y position of the arrow.\n   */\n  readonly y: Signal<number | undefined>;\n  /**\n   * The final placement of the overlay.\n   */\n  readonly placement: Signal<string | undefined>;\n  /**\n   * The padding between the arrow and the edges of the floating element.\n   */\n  readonly padding: WritableSignal<number | undefined>;\n  /**\n   * Set the padding between the arrow and the edges of the floating element.\n   * @param value The padding value in pixels\n   */\n  setPadding(value: number | undefined): void;\n}\n\n/**\n * The props interface for the overlay arrow.\n */\nexport interface NgpOverlayArrowProps {\n  /**\n   * Padding between the arrow and the edges of the floating element.\n   * This prevents the arrow from overflowing the rounded corners.\n   */\n  readonly padding?: Signal<number | undefined>;\n}\n\nexport const [\n  NgpOverlayArrowStateToken,\n  ngpOverlayArrow,\n  injectOverlayArrowState,\n  provideOverlayArrowState,\n] = createPrimitive(\n  'NgpOverlayArrow',\n  ({ padding: _padding = signal(undefined) }: NgpOverlayArrowProps) => {\n    const overlay = injectOverlay();\n    const element = injectElementRef();\n    const padding = controlled(_padding);\n\n    // register the arrow element with the overlay\n    overlay.registerArrow(element.nativeElement, padding);\n\n    // cleanup the arrow element on destroy\n    onDestroy(() => overlay.unregisterArrow());\n\n    const x = computed(() => overlay.arrowPosition().x);\n    const y = computed(() => overlay.arrowPosition().y);\n    const placement = computed(() => overlay.finalPlacement());\n\n    // bind the arrow position styles\n    styleBinding(element, 'inset-inline-start.px', () => x() ?? null);\n    styleBinding(element, 'inset-block-start.px', () => y() ?? null);\n    dataBinding(element, 'data-placement', () => placement() ?? null);\n\n    function setPadding(value: number | undefined): void {\n      padding.set(value);\n    }\n\n    return {\n      x,\n      y,\n      placement,\n      padding,\n      setPadding,\n    } satisfies NgpOverlayArrowState;\n  },\n);\n","import { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { isNil, isObject } from 'ng-primitives/utils';\nimport { NgpBoundary, NgpRootBoundary } from './positioning';\n\n/**\n * Options for configuring shift behavior to keep the floating element in view.\n * The shift middleware ensures the floating element stays visible by shifting it\n * within the viewport when it would otherwise overflow.\n */\nexport interface NgpShiftOptions {\n  /**\n   * The minimum padding between the floating element and the viewport edges.\n   * Prevents the floating element from touching the edges of the viewport.\n   * @default 0\n   */\n  padding?: number;\n\n  /**\n   * The limiter function that determines how much the floating element can shift.\n   * Common limiters from @floating-ui/dom include:\n   * - limitShift: Limits shifting to prevent the reference element from being obscured\n   * @default undefined\n   */\n  limiter?: {\n    fn: (state: unknown) => { x: number; y: number };\n    options?: unknown;\n  };\n\n  /**\n   * The clipping area the floating element is kept within. Pass an element (or elements)\n   * to constrain the overlay to a container rather than its clipping ancestors.\n   * @default 'clippingAncestors'\n   */\n  boundary?: NgpBoundary;\n\n  /**\n   * The root clipping area the floating element is kept within.\n   * @default 'viewport'\n   */\n  rootBoundary?: NgpRootBoundary;\n\n  /**\n   * Whether to measure overflow against the trigger's clipping ancestors rather than the\n   * panel's. The panel is portalled to the body, so its own clipping ancestors are\n   * effectively the viewport - set this when the trigger sits in a scroll container.\n   *\n   * Applies only while `boundary` is left at its default; an explicit boundary always wins.\n   * @default false\n   */\n  altBoundary?: boolean;\n\n  /**\n   * Whether overflow along the side axis - the one the placement points along - is also\n   * checked when shifting. `mainAxis` covers the alignment axis and is on by default.\n   * @default false\n   */\n  crossAxis?: boolean;\n}\n\n/**\n * Type representing all valid shift values.\n * Can be a boolean (enable/disable), undefined, or an object with detailed options.\n */\nexport type NgpShift = boolean | NgpShiftOptions | undefined;\n\n/**\n * Input type for shift that also accepts string representations of booleans\n */\nexport type NgpShiftInput = NgpShift | string;\n\n/**\n * Transform function to coerce shift input values to the correct type\n * @param value The input value to coerce\n * @returns The coerced shift value\n */\nexport function coerceShift(value: NgpShiftInput | null | undefined): NgpShift {\n  if (isNil(value)) {\n    return undefined;\n  }\n\n  if (isObject(value)) {\n    return value;\n  }\n\n  // Handle boolean values\n  if (typeof value === 'boolean') {\n    return value;\n  }\n\n  // Handle string boolean values\n  if (value === 'true') {\n    return true;\n  }\n\n  if (value === 'false') {\n    return false;\n  }\n\n  // Handle string number values for padding shorthand\n  const numValue = coerceNumberProperty(value, null);\n  if (numValue !== null && !isNaN(numValue)) {\n    return { padding: numValue };\n  }\n\n  return undefined;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAGA;;;;;;;;;;;;;AAaG;SACa,gCAAgC,GAAA;IAC9C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,IAAI,EAAE;AACtD;;AC8CA;;;;AAIG;AACG,SAAU,UAAU,CAAC,KAAsC,EAAA;AAC/D,IAAA,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;AAChB,QAAA,OAAO,SAAS;IAClB;AAEA,IAAA,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;AACnB,QAAA,OAAO,KAAK;IACd;;AAGA,IAAA,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;AAC9B,QAAA,OAAO,KAAK;IACd;;AAGA,IAA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