{"version":3,"file":"styloviz-core-nav.mjs","names":[],"sources":["../../../../projects/core/nav/link-adapter.ts","../../../../projects/core/nav/nav-location.ts","../../../../projects/core/nav/close-on-navigation.ts","../../../../projects/core/nav/fragment-href.ts","../../../../projects/core/nav/nav-telemetry.ts"],"sourcesContent":["import {\n  InjectionToken,\n  type EnvironmentProviders,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { svWarnOnce } from '@styloviz/core/dev';\nimport { svIsSafeUrl } from '@styloviz/core/security';\n\n/**\n * ============================================================================\n *  The link seam — `NV-03-M1`, second half\n * ============================================================================\n *\n * `SvNavLocation` is a keyed store: it answers *\"where does this component's\n * state live?\"*. This answers a different question — *\"how does this component\n * render a link to somewhere else, and who navigates when it is clicked?\"* — and\n * no amount of stretching makes one do the other's job. A breadcrumb owns no\n * key; its state **is** the route.\n *\n * ── Why it exists ───────────────────────────────────────────────────────────\n * `docs/navigation-routing-adr.md` names the problem and names the proof:\n * `sv-breadcrumb` and `sv-sidebar` both imported `{ RouterLink } from\n * '@angular/router'`, which is precisely why neither could be dropped into a\n * consumer's app that routes some other way — a hybrid app, a non-routed widget,\n * another framework's shell. The adapter is their migration path (`sv-breadcrumb`\n * and `sv-sidebar-nav` have taken it; `sv-sidebar` still imports `RouterLink`),\n * so like {@link SvNavLocation} it cannot itself depend on the thing they need to\n * escape.\n *\n * ── What `RouterLink` actually provided, and how this replaces it ───────────\n * Two things, and they are separable, which is the whole insight:\n *\n *   1. **An `href` on the anchor.** That is what makes middle-click, ⌘-click,\n *      \"copy link address\" and the status bar work, and it is plain string work\n *      no router is needed for.\n *   2. **Click interception**, so the app transitions instead of reloading.\n *      That one genuinely needs the router — so it is the ten lines the\n *      *consumer* writes.\n *\n * Splitting them means a component with no adapter still renders real,\n * shareable, right-clickable links. It just reloads the page when one is\n * followed, which is what a component with no router can honestly do.\n *\n * ── ★ The same rule as `sv-mega-menu`'s, and deliberately so ────────────────\n * **The component cancels the browser's navigation exactly when the adapter says\n * it took it.** `navigate` returning `false` means \"I did not handle this\" and\n * the anchor is left alone; returning `true` means the adapter is navigating and\n * the browser must not also. One event, one navigation — the defect `NV-07-I12`\n * names, avoided here before it can be written.\n */\n\n/**\n * Where a link points, in whatever shape the consumer's router uses.\n *\n * A string is a path. An array is the segment form Angular's router takes —\n * kept because that is what every `BreadcrumbItem` in the wild already holds,\n * and renaming a public field to tidy a type is a migration nobody asked for.\n */\nexport type SvLinkTarget = string | readonly string[];\n\n/** How a component turns a target into a link, and who navigates. */\nexport interface SvLinkAdapter {\n  /** Names the implementation, for diagnostics only. */\n  readonly kind: string;\n\n  /**\n   * The `href` to put on the anchor, or `null` for \"this is not a link\".\n   *\n   * Always rendered, even when {@link navigate} will cancel the click. An anchor\n   * with no `href` is not a link to the browser, to assistive technology, or to\n   * the person trying to open it in a new tab.\n   *\n   * Components bind the result as-is, so the adapter is where an unsafe scheme\n   * (`javascript:`, `data:`) must be refused — return `null` for it, as\n   * {@link svHrefLinkAdapter} does via {@link svIsSafeUrl}.\n   */\n  href(target: SvLinkTarget): string | null;\n\n  /**\n   * Navigate to `target`. Return `true` when this adapter handled it, so the\n   * component cancels the browser's own navigation; `false` to let the anchor\n   * be followed normally.\n   */\n  navigate(target: SvLinkTarget): boolean;\n}\n\n/** Join the array form into a path, and leave a string alone. */\nfunction toPath(target: SvLinkTarget): string {\n  if (typeof target === 'string') return target;\n  if (!target.length) return '';\n  const joined = target\n    .map((segment, i) => (i === 0 ? segment : segment.replace(/^\\//, '')))\n    .join('/')\n    .replace(/([^:])\\/{2,}/g, '$1/');\n  return joined;\n}\n\n/**\n * The default: render the `href`, let the browser follow it.\n *\n * ★ **It warns, once, the first time a link is actually rendered through it in a\n * dev build.** Silence here would be the worst outcome of this whole change: an\n * app that upgrades and starts doing full page loads on every breadcrumb click\n * still *works*, so nothing fails, nothing logs, and the regression is found\n * weeks later by somebody wondering why the app feels slow. The warning names\n * the one provider call that fixes it.\n *\n * ★ **An unsafe scheme is not a link.** Targets usually come from data — a\n * breadcrumb trail built from a CMS, a menu from a config file — so a\n * `javascript:` or `data:` target is an injection, not a destination. `href`\n * runs every path through {@link svIsSafeUrl} (the same resolve-with-`new URL`\n * check the HTML sanitizer uses, so ` JaVaScRiPt:` and tab-split schemes are\n * caught too) and returns `null` — \"this is not a link\" — for anything that\n * fails it. Relative paths, `http(s):`, `mailto:` and `tel:` pass.\n */\nexport function svHrefLinkAdapter(): SvLinkAdapter {\n  return {\n    kind: 'href',\n\n    href(target) {\n      const path = toPath(target);\n      if (path === '') return null;\n      if (!svIsSafeUrl(path, false)) {\n        svWarnOnce(\n          `sv-link-adapter/unsafe:${path.slice(0, 40)}`,\n          `A navigation link target uses a scheme that is not allowed (\"${path.slice(0, 40)}\"), ` +\n            'so it is rendered without an href. Only relative paths, http(s):, mailto: and tel: ' +\n            'are linked by the default adapter.',\n        );\n        return null;\n      }\n      return path;\n    },\n\n    navigate() {\n      svWarnOnce(\n        'sv-link-adapter/default',\n        'No link adapter is provided, so links in navigation components are followed by ' +\n          'the browser — a full page load rather than a router transition. Wire one up with ' +\n          'provideSvLinkAdapter(() => ({ kind: \"router\", href: …, navigate: … })); see ' +\n          'docs/navigation-routing-adr.md for the ten-line Angular version.',\n      );\n      return false;\n    },\n  };\n}\n\n/**\n * Where components look for their link adapter.\n *\n * Defaults to {@link svHrefLinkAdapter}, so a component works — renders real\n * links, navigates, is shareable — with nothing provided at all.\n */\nexport const SV_LINK_ADAPTER = new InjectionToken<SvLinkAdapter>('SvLinkAdapter', {\n  providedIn: 'root',\n  factory: svHrefLinkAdapter,\n});\n\n/**\n * Wire a link adapter in — as a value, or as a factory when it needs injection.\n *\n * ★ **The factory form is the one a real adapter needs, and the value form is a\n * trap worth naming.** Every useful adapter reaches a router, and `inject()`\n * inside `href` or `navigate` runs when a template calls it — outside any\n * injection context — which throws `NG0203` at click time rather than at\n * startup. Passing a factory means the injection happens once, where it is\n * legal, and the returned closure just uses what it captured.\n *\n * @example\n * // app.config.ts — the Angular router version, in ten lines.\n * providers: [\n *   provideSvLinkAdapter(() => {\n *     const router = inject(Router);\n *     const tree = (t: SvLinkTarget) => (typeof t === 'string' ? router.parseUrl(t) : router.createUrlTree([...t]));\n *     return {\n *       kind: 'angular-router',\n *       href: (t) => router.serializeUrl(tree(t)),\n *       navigate: (t) => { void router.navigateByUrl(tree(t)); return true; },\n *     };\n *   }),\n * ]\n */\nexport function provideSvLinkAdapter(\n  adapter: SvLinkAdapter | (() => SvLinkAdapter),\n): EnvironmentProviders {\n  return makeEnvironmentProviders([\n    typeof adapter === 'function'\n      ? { provide: SV_LINK_ADAPTER, useFactory: adapter }\n      : { provide: SV_LINK_ADAPTER, useValue: adapter },\n  ]);\n}\n\n/**\n * Whether a click is the browser's own gesture rather than a plain activation.\n *\n * ★ Shared so the answer cannot drift between components. Cancelling a\n * ⌘/Ctrl/Shift/Alt or middle click takes \"open in a new tab\" away from a\n * navigation control, which is where people use it most — `sv-mega-menu` reached\n * this conclusion independently and this is the same rule, in one place.\n */\nexport function svIsModifiedClick(event: Event): boolean {\n  const mouse = event as MouseEvent;\n  return Boolean(\n    mouse.metaKey || mouse.ctrlKey || mouse.shiftKey || mouse.altKey || mouse.button === 1,\n  );\n}\n","import {\n  DestroyRef,\n  InjectionToken,\n  type EnvironmentProviders,\n  type Signal,\n  computed,\n  inject,\n  makeEnvironmentProviders,\n  signal,\n} from '@angular/core';\nimport { svWarn } from '@styloviz/core/dev';\n\ndeclare const ngDevMode: boolean | undefined;\n\n/**\n * ============================================================================\n *  The navigation location seam — `X-8`\n * ============================================================================\n *\n * Five navigation families independently ask for the same thing: put my state in\n * the URL. Tabs (`NV-06-M3`), Breadcrumb (`NV-03-M1`), Pagination (`NV-04-M4`),\n * Stepper (`NV-05-M2`) and Mega Menu (`NV-07-M4`), plus Accordion (`NV-01-M1`)\n * and Anchor (`NV-02-M2`) wanting the hash half. Seven implementations of one\n * idea is how seven subtly different answers to \"does back undo this?\" get\n * shipped.\n *\n * ── Why a seam and not a router dependency ──────────────────────────────────\n * **Optional is the load-bearing word.** A kit that hard-depends on\n * `@angular/router` is unusable in a hybrid app, in a non-routed widget, or\n * inside another framework's shell — and we had the proof in-tree: `sv-sidebar`\n * imports `RouterLink` directly (as `sv-breadcrumb` and `sv-sidebar-nav` did\n * until they moved to `SvLinkAdapter`), which is exactly why it cannot be\n * dropped into a consumer's app that routes some other way.\n *\n * So `@styloviz/core` deliberately does **not** import `@angular/router`. The\n * router implementation is fifteen lines the consumer writes, and it is in the\n * documentation rather than in this package. What ships here is the seam plus\n * the three implementations that need no router at all.\n *\n * ── Why the default does nothing ────────────────────────────────────────────\n * {@link svNoopNavLocation} is the default, and that is not laziness. A\n * component that starts writing to the address bar because the consumer upgraded\n * a package has changed their app's behaviour without being asked — their\n * analytics see new URLs, their back button gains entries, and a shared link\n * means something different than it did last week. Addressability is opt-in.\n *\n * ── Why `replace` is the default write mode ─────────────────────────────────\n * `NV-02-I3` is the cautionary case: a scrollspy that pushes a history entry for\n * every section the reader scrolls past fills the back stack until back stops\n * being a way out of the page. That is the single most common defect in this\n * category in the wild. Pushing is a deliberate act — \"this was a navigation the\n * user should be able to undo\" — so it has to be asked for.\n */\n\n/** What a write does to browser history. */\nexport type SvNavWriteMode =\n  /** Rewrite the current entry. The default: no new back-stack entry. */\n  | 'replace'\n  /** Add an entry, so the browser's back button undoes this change. */\n  | 'push';\n\n/**\n * Where a component reads and writes its addressable state.\n *\n * Implementations are keyed stores over *something the browser already has* — a\n * query string, the hash, a router's state. They are deliberately synchronous\n * and string-valued: a component that needs a number parses it, because the URL\n * only ever held text.\n */\nexport interface SvNavLocation {\n  /** Names the implementation, for diagnostics only. */\n  readonly kind: string;\n\n  /**\n   * The current value for `key`, or `null` when absent.\n   *\n   * Returns `null` on the server for every browser-backed implementation, which\n   * is the answer to `X-9`'s \"what renders before any measurement runs\": the\n   * component's own default, not a guess at the URL.\n   */\n  read(key: string): string | null;\n\n  /**\n   * Store `value` under `key`; `null` removes the key entirely.\n   *\n   * Removing rather than storing an empty string matters — `?tab=` and no `tab`\n   * at all are different URLs, and only one of them is what \"no selection\"\n   * means.\n   */\n  write(key: string, value: string | null, mode?: SvNavWriteMode): void;\n\n  /**\n   * Observe changes made by anything else — the back button, another component\n   * sharing this location, or the consumer's own router. Returns the\n   * unsubscribe.\n   *\n   * Listeners fire on external navigation **and** on {@link write}, so two\n   * components sharing one location cannot drift apart. That makes a listener's\n   * job idempotent by design: read the value, compare, do nothing if unchanged.\n   */\n  subscribe(listener: () => void): () => void;\n}\n\n/** True only in a browser with a usable History API. */\nfunction browserHistoryAvailable(): boolean {\n  return (\n    typeof window !== 'undefined' &&\n    typeof window.history !== 'undefined' &&\n    typeof window.location !== 'undefined'\n  );\n}\n\n/**\n * A listener registry shared by the browser-backed implementations.\n *\n * `popstate` fires for back and forward but **not** for `pushState` or\n * `replaceState`, so a location that only forwarded `popstate` would let two\n * components on one page disagree the moment either of them wrote. Writes\n * notify too.\n */\nfunction createListeners(): {\n  add(listener: () => void): () => void;\n  notify(): void;\n  readonly size: () => number;\n} {\n  const listeners = new Set<() => void>();\n  return {\n    add(listener) {\n      listeners.add(listener);\n      return () => listeners.delete(listener);\n    },\n    notify() {\n      // Copied, so a listener that unsubscribes during notification cannot\n      // shorten the set mid-iteration and skip the next one.\n      for (const listener of [...listeners]) listener();\n    },\n    size: () => listeners.size,\n  };\n}\n\n/**\n * The default: reads nothing, writes nothing, notifies nobody.\n *\n * Every component that adopts the seam works with this in place — which is the\n * test that the seam is genuinely optional. If a component only behaves\n * correctly with a real location wired up, it has made routing mandatory\n * through the back door.\n */\nexport function svNoopNavLocation(): SvNavLocation {\n  return {\n    kind: 'noop',\n    read: () => null,\n    write: () => undefined,\n    subscribe: () => () => undefined,\n  };\n}\n\n/**\n * Query-string state: `?tab=billing&page=3`.\n *\n * The general-purpose implementation, and the right one for anything that is one\n * of several independent pieces of state on a page. Multiple components share it\n * safely because each owns its own key.\n */\nexport function svQueryParamNavLocation(): SvNavLocation {\n  const listeners = createListeners();\n  let detach: (() => void) | null = null;\n\n  const params = (): URLSearchParams =>\n    new URLSearchParams(browserHistoryAvailable() ? window.location.search : '');\n\n  return {\n    kind: 'query',\n\n    read(key) {\n      return params().get(key);\n    },\n\n    write(key, value, mode = 'replace') {\n      if (!browserHistoryAvailable()) return;\n\n      const next = params();\n      if (value === null) next.delete(key);\n      else next.set(key, value);\n\n      const query = next.toString();\n      const url =\n        window.location.pathname + (query ? `?${query}` : '') + window.location.hash;\n\n      // Same URL, same history: writing it again would add a duplicate back\n      // entry for a change that did not happen.\n      if (url === window.location.pathname + window.location.search + window.location.hash) {\n        return;\n      }\n\n      if (mode === 'push') window.history.pushState(window.history.state, '', url);\n      else window.history.replaceState(window.history.state, '', url);\n\n      listeners.notify();\n    },\n\n    subscribe(listener) {\n      const remove = listeners.add(listener);\n\n      if (browserHistoryAvailable() && !detach) {\n        const onPopState = () => listeners.notify();\n        window.addEventListener('popstate', onPopState);\n        detach = () => window.removeEventListener('popstate', onPopState);\n      }\n\n      return () => {\n        remove();\n        if (listeners.size() === 0 && detach) {\n          detach();\n          detach = null;\n        }\n      };\n    },\n  };\n}\n\n/**\n * Hash state: `#installation`.\n *\n * ★ **The hash is one slot, so this location owns exactly one key.** That is a\n * fact about URLs, not a limitation of this implementation: `#a` and `#b` cannot\n * both be true. An accordion deep-link and an anchor rail on the same page are\n * competing for the same slot, and the honest answer is that one of them owns it\n * — which is why `boundKey` is required rather than inferred. `read` and `write`\n * ignore any other key, so a second component wired here fails visibly instead\n * of silently stealing the first one's state.\n *\n * Use it for the thing a reader would paste into a message: a section, an FAQ\n * answer. Anything else belongs in {@link svQueryParamNavLocation}.\n */\nexport function svHashNavLocation(boundKey: string): SvNavLocation {\n  const listeners = createListeners();\n  let detach: (() => void) | null = null;\n\n  const warnForeignKey = (key: string): void => {\n    if (typeof ngDevMode !== 'undefined' && ngDevMode) {\n      svWarn(\n        `[styloviz] svHashNavLocation is bound to \"${boundKey}\" and was asked for ` +\n          `\"${key}\". The hash holds one value, so one component owns it — give the ` +\n          `other one svQueryParamNavLocation() instead.`,\n      );\n    }\n  };\n\n  return {\n    kind: `hash:${boundKey}`,\n\n    read(key) {\n      if (key !== boundKey) {\n        warnForeignKey(key);\n        return null;\n      }\n      if (!browserHistoryAvailable()) return null;\n      const raw = window.location.hash.replace(/^#/, '');\n      if (raw === '') return null;\n      // ★ The hash is typed by people and pasted from chat, so a malformed\n      //   escape (`#%E0%A4`) is ordinary input. `decodeURIComponent` throws\n      //   `URIError` on it — inside the `computed` of every `svNavParam` bound\n      //   here — so the raw text is returned instead of taking the page down.\n      try {\n        return decodeURIComponent(raw);\n      } catch {\n        return raw;\n      }\n    },\n\n    write(key, value, mode = 'replace') {\n      if (key !== boundKey) {\n        warnForeignKey(key);\n        return;\n      }\n      if (!browserHistoryAvailable()) return;\n\n      const hash = value === null ? '' : `#${encodeURIComponent(value)}`;\n      const url = window.location.pathname + window.location.search + hash;\n      if (hash === window.location.hash) return;\n\n      if (mode === 'push') window.history.pushState(window.history.state, '', url);\n      else window.history.replaceState(window.history.state, '', url);\n\n      listeners.notify();\n    },\n\n    subscribe(listener) {\n      const remove = listeners.add(listener);\n\n      if (browserHistoryAvailable() && !detach) {\n        const onChange = () => listeners.notify();\n        // Both: `hashchange` covers a user editing the address bar or following\n        // a plain `#` link, `popstate` covers back and forward.\n        window.addEventListener('hashchange', onChange);\n        window.addEventListener('popstate', onChange);\n        detach = () => {\n          window.removeEventListener('hashchange', onChange);\n          window.removeEventListener('popstate', onChange);\n        };\n      }\n\n      return () => {\n        remove();\n        if (listeners.size() === 0 && detach) {\n          detach();\n          detach = null;\n        }\n      };\n    },\n  };\n}\n\n/**\n * Where components look for their location.\n *\n * Defaults to {@link svNoopNavLocation}, so nothing touches the URL until a\n * consumer asks. Provided once at the root, which is also what lets two\n * components share one location and stay in step.\n */\nexport const SV_NAV_LOCATION = new InjectionToken<SvNavLocation>('SvNavLocation', {\n  providedIn: 'root',\n  factory: svNoopNavLocation,\n});\n\n/**\n * Wire a location in — as a value, or as a factory when it needs injection.\n *\n * ★ **The factory form is the one a router adapter needs.** `inject()` inside\n * `read`, `write` or `subscribe` runs when a component calls them, which is\n * outside any injection context, and throws `NG0203` at interaction time rather\n * than at startup. A factory injects once, where it is legal, and the returned\n * closure uses what it captured. (The first draft of the example below got this\n * wrong, which is why the note is here rather than in a changelog.)\n *\n * @example\n * // app.config.ts — put tab, page and step state in the query string\n * providers: [provideSvNavLocation(svQueryParamNavLocation())]\n *\n * @example\n * // Your own router adapter. `@styloviz/core` cannot import `@angular/router`,\n * // which is the whole point — so this lives in your app, in fifteen lines.\n * providers: [\n *   provideSvNavLocation(() => {\n *     const router = inject(Router);\n *     return {\n *       kind: 'angular-router',\n *       read: (key) => router.parseUrl(router.url).queryParams[key] ?? null,\n *       write: (key, value, mode) => {\n *         void router.navigate([], {\n *           queryParams: { [key]: value },\n *           queryParamsHandling: 'merge',\n *           replaceUrl: mode !== 'push',\n *         });\n *       },\n *       subscribe: (fn) => { const s = router.events.subscribe(fn); return () => s.unsubscribe(); },\n *     };\n *   }),\n * ]\n */\nexport function provideSvNavLocation(\n  location: SvNavLocation | (() => SvNavLocation),\n): EnvironmentProviders {\n  return makeEnvironmentProviders([\n    typeof location === 'function'\n      ? { provide: SV_NAV_LOCATION, useFactory: location }\n      : { provide: SV_NAV_LOCATION, useValue: location },\n  ]);\n}\n\n/** Options for {@link svNavParam}. */\nexport interface SvNavParamOptions {\n  /**\n   * History behaviour for writes from this parameter. Default `'replace'`.\n   *\n   * A single write can override it — see {@link SvNavParam.set} — for the case\n   * where the same key means \"the user navigated\" from one call site and \"the\n   * view drifted\" from another.\n   */\n  readonly mode?: SvNavWriteMode;\n}\n\n/**\n * The key a parameter is bound to.\n *\n * A plain string for state the component always owns. A function when the key\n * comes from an `input()` — which is the normal case, because **the key has to be\n * per-instance.** Two paginators on one page cannot both own `?page`, and a\n * component that hard-coded its key would make the second one a collision the\n * consumer cannot fix. `null` means \"do not synchronise\", which is the default a\n * component should ship: the location being wired up says the app opted in, and\n * the key says *this instance* did.\n */\nexport type SvNavKey = string | (() => string | null);\n\n/** One piece of addressable state, as a signal plus a setter. */\nexport interface SvNavParam {\n  /** The current value, `null` when the location does not hold it or no key is set. */\n  readonly value: Signal<string | null>;\n  /**\n   * Store a value, or `null` to remove it. A no-op when not {@link addressable}.\n   *\n   * `mode` overrides this parameter's configured write mode for one call.\n   *\n   * ★ It exists because **one key can honestly have two write modes**, decided\n   * per write rather than per parameter. `sv-anchor` is the case that named it:\n   * reflecting the scroll position must `replace`, or the back stack fills with\n   * every section the reader scrolled past — `NV-02-I3`'s defect exactly — while\n   * a *click* on \"API reference\" in the same nav is a navigation the reader\n   * expects back to undo. Same key, same parameter, two different claims about\n   * what the user did, and only the call site knows which one it is.\n   */\n  set(value: string | null, mode?: SvNavWriteMode): void;\n  /**\n   * Whether this parameter actually reaches a URL — a real location is provided\n   * *and* this instance has a key. A component can branch on it to skip work it\n   * would only need in order to synchronise.\n   */\n  readonly addressable: Signal<boolean>;\n}\n\n/**\n * Bind one key of the injected location to a signal.\n *\n * Call it in a field initializer, inside an injection context:\n *\n * ```ts\n * // Key from an input, so each instance owns its own parameter.\n * urlKey = input<string | null>(null);\n * private readonly pageParam = svNavParam(() => this.urlKey(), { mode: 'push' });\n * ```\n *\n * It exists so the seven families do not each write the same `subscribe` /\n * `read` / cleanup dance seven slightly different ways.\n *\n * ── Why a `computed` over a revision counter ────────────────────────────────\n * The obvious shape — a writable signal seeded from `location.read()` and\n * updated from `subscribe` — cannot read an `input()`. A field initializer runs\n * before inputs are set, so it would capture the *default* key and bind to the\n * wrong parameter forever, silently.\n *\n * Deriving instead means the key is read at the moment the value is, so an\n * input-driven key works with no lifecycle hook, and the first read is still\n * synchronous — which is the deep-link case arriving for free. The counter is\n * what turns an imperative notification back into something a `computed` can\n * depend on.\n *\n * An external change to somebody else's key does bump the counter and recompute\n * this value, but `computed` only propagates when the result actually differs —\n * so nothing downstream wakes for a parameter that did not change.\n *\n * ── ★ A parameter is a PROJECTION, not storage ──────────────────────────────\n * `value` reads the location. It is not a cache of what was last `set`, and with\n * the no-op location in place it stays `null` no matter how often it is written.\n *\n * That is the correct shape, and getting it wrong is how the seam would stop\n * being optional. A component keeps its own state — Pagination has\n * `currentPage`, Tabs has `activeId` — and the parameter is the *projection* of\n * that state into the URL. If the parameter held the value itself, a component\n * would read its own state back out of a location that may not exist, and with\n * the default no-op it would read `null` and break. Optional means the component\n * still works when nothing is listening, so the state has to live in the\n * component and the parameter has to be a mirror.\n */\nexport function svNavParam(key: SvNavKey, options: SvNavParamOptions = {}): SvNavParam {\n  const location = inject(SV_NAV_LOCATION);\n  const mode = options.mode ?? 'replace';\n  const resolveKey = typeof key === 'function' ? key : () => key;\n\n  /** Bumped by anything that changes the location, so `value` can depend on it. */\n  const revision = signal(0);\n\n  const value = computed<string | null>(() => {\n    const k = resolveKey();\n    revision();\n    return k === null ? null : location.read(k);\n  });\n\n  const addressable = computed(() => location.kind !== 'noop' && resolveKey() !== null);\n\n  const unsubscribe = location.subscribe(() => revision.update((n) => n + 1));\n  inject(DestroyRef).onDestroy(unsubscribe);\n\n  return {\n    value,\n    addressable,\n    set(next, override) {\n      const k = resolveKey();\n      if (k === null) return;\n      location.write(k, next, override ?? mode);\n      // A no-op location never notifies, so nothing would recompute without this.\n      revision.update((n) => n + 1);\n    },\n  };\n}\n","import { DestroyRef, inject } from '@angular/core';\nimport { SV_NAV_LOCATION } from './nav-location';\n\n/**\n * ============================================================================\n *  Closing a floating panel when the page underneath changes — `NV-03-I5`, `NV-07-I7`\n * ============================================================================\n *\n * A breadcrumb's sibling-page menu and a mega menu's panel both live in\n * `document.body`, outside the component that owns them and outside whatever the\n * router swaps. So a navigation that replaces the page leaves them **hanging over\n * the new one** — a menu of links to a section the user has already left, drawn on\n * top of where they just arrived.\n *\n * ── ⚠️ `SvOverlayStackService` does not do this, despite the backlog saying so ──\n * The stack service owns z-index bands and `inert` marking. It has no idea what a\n * route is and nothing in it observes navigation. Reaching for it would have\n * produced a change that compiles, reads plausibly, and closes nothing.\n *\n * ── What \"a navigation happened\" means without importing a router ───────────\n * Three signals, and the third is the only one that needs wiring:\n *\n *   · **`popstate`** — back and forward. Always available.\n *   · **`hashchange`** — following a plain `#` link. Always available.\n *   · **{@link SV_NAV_LOCATION}** — whatever the app told us about. An adapter\n *     over the Angular router notifies on every `NavigationEnd`.\n *\n * ★ **`pushState` fires nothing**, which is the whole difficulty: an SPA\n * navigation is invisible to the platform. That is why the location seam is in\n * the list — it is the one channel an app can use to say *\"the page changed\"*\n * without this package importing a router. With the default no-op location the\n * first two still work, so back and forward close the panel in every app, and an\n * app that provides a location gets SPA navigation too.\n *\n * The honest statement of the gap: **a component cannot detect a navigation it\n * was never told about**, and the fix is one `provideSvNavLocation(…)` call.\n *\n * ── ★ A location notification is not, by itself, a navigation ──────────────\n * `SvNavLocation.subscribe` fires on external changes **and on every\n * write** — which includes the kit's own. `sv-anchor` rewriting the hash as the\n * reader scrolls, a tab change mirrored into `?tab=`, an accordion deep-link:\n * each is an `svNavParam.set` on the SAME page, and each notifies. Closing on\n * all of them meant scrolling the page shut an open breadcrumb menu.\n *\n * So the location channel is filtered by **path**: a notification closes only\n * when `location.pathname` differs from the last one this helper saw. A\n * query-only or hash-only write is the page describing itself, not leaving;\n * an SPA route change moves the path, and that closes. The two platform events\n * stay unfiltered — `popstate` and `hashchange` are only ever raised by the\n * browser (back/forward, a followed `#` link, an edited address bar), never by\n * `pushState`/`replaceState`, so they cannot be the kit talking to itself.\n *\n * ⚠️ The cost, stated: an app navigation that changes ONLY the query string\n * (`/search?q=a` → `/search?q=b`) through the location seam does not close the\n * panel. That is the same shape as a kit write and cannot be told apart from\n * one without a router; the owner closes explicitly if it matters.\n *\n * On the server there is no path to compare, so every notification closes —\n * the previous behaviour, and harmless, since nothing is open there.\n */\n\n/**\n * Call `close` whenever the page underneath appears to have changed.\n *\n * Call it in a field initializer, inside an injection context; the listeners are\n * released with the component.\n *\n * ```ts\n * private readonly closeOnNav = svCloseOnNavigation(() => this.close());\n * ```\n *\n * `close` must be idempotent — it is called for every signal that arrives, and\n * two of them can describe the same navigation.\n *\n * Location notifications close only when the path changed; `popstate` and\n * `hashchange` always close. See the note above for why.\n */\nexport function svCloseOnNavigation(close: () => void): void {\n  const location = inject(SV_NAV_LOCATION);\n  const destroyRef = inject(DestroyRef);\n\n  if (typeof window === 'undefined') {\n    destroyRef.onDestroy(location.subscribe(close));\n    return;\n  }\n\n  let lastPath = window.location.pathname;\n\n  const onLocation = (): void => {\n    const path = window.location.pathname;\n    if (path === lastPath) return; // a query- or hash-only write: same page\n    lastPath = path;\n    close();\n  };\n\n  const onBrowserNavigation = (): void => {\n    // Re-baselined so the location notification that usually follows the\n    // same `popstate` is not counted as a second navigation.\n    lastPath = window.location.pathname;\n    close();\n  };\n\n  const unsubscribe = location.subscribe(onLocation);\n  window.addEventListener('popstate', onBrowserNavigation);\n  window.addEventListener('hashchange', onBrowserNavigation);\n\n  destroyRef.onDestroy(() => {\n    unsubscribe();\n    window.removeEventListener('popstate', onBrowserNavigation);\n    window.removeEventListener('hashchange', onBrowserNavigation);\n  });\n}\n","/**\n * ============================================================================\n *  An in-page link that stays on the page — FL-J3-NV-03 (`X-19`)\n * ============================================================================\n *\n * A bare `href=\"#section\"` resolves against the document's BASE URL, not the\n * page. Every Angular app ships `<base href=\"/\">`, so on `/docs/anchor` the link\n * `#section` means `/#section` — the home page. With JavaScript the kit's click\n * handlers scroll instead and nobody notices; without it (a prerendered page\n * before hydration, a reader with scripting off) the link leaves the page.\n *\n * The fix is to write the page's own path in front of the fragment. That resolves\n * to the same document under any base, so the browser just scrolls.\n *\n * ★ Read from the document's location, which `@angular/platform-server` sets to\n *   the request URL — so a server-rendered link already carries the right path.\n *   With no location (a detached document) it falls back to the bare fragment.\n */\nexport function svFragmentHref(doc: Document | null | undefined, id: string): string {\n  const loc = doc?.location;\n  if (!loc || !loc.pathname) return `#${id}`;\n  return `${loc.pathname}${loc.search}#${id}`;\n}\n","import {\n  InjectionToken,\n  inject,\n  makeEnvironmentProviders,\n  type EnvironmentProviders,\n} from '@angular/core';\nimport { svWarnOnce } from '@styloviz/core/dev';\n\ndeclare const ngDevMode: boolean | undefined;\n\n/**\n * ============================================================================\n *  Navigation analytics with source and intent — `X-15`\n * ============================================================================\n *\n * The seven navigation families between them emit eleven differently-shaped\n * \"the user moved\" events, and **not one of them says where the move came from\n * or what kind of move it was.** A host that wants to answer \"are people\n * reaching settings through the sidebar or through search?\" has to correlate\n * `(tabChange)`, `(pageChange)`, `(stepChange)`, `(itemToggled)` and four more\n * by hand, in its own vocabulary, and re-do it for every component it adds.\n *\n * `sv-stepper` is the exception and the model: it already emits a dedicated\n * `telemetry` stream with a `type`, a step id and a branch. `X-15` is that\n * stream generalized so the other six can share it.\n *\n * ── ★★★ \"INTENT\" IS INFERRED FROM THE GESTURE, AND THIS FILE SAYS SO OUT LOUD ─\n * The backlog asks for \"what the user appeared to be looking for\". A component\n * cannot know that. What it knows exactly is **what kind of move the gesture\n * was** — stepping forward one, jumping past the middle, opening a panel to\n * look — and that is what {@link SvNavIntent} names. The distinction matters\n * because the alternative is a field called `intent` that a host reads as a\n * statement about a person's goal when it is a statement about a click.\n * `explore` means a panel was opened, not that somebody was browsing.\n *\n * ── ★★ TWO CONSTRAINTS, AND BOTH ARE MECHANISMS RATHER THAN NOTES ────────────\n * The item names two, and a note in a README enforces neither:\n *\n *   1. **Consent gates every event, checked at emit time.** Not at construction\n *      — a user who withdraws consent mid-session must stop being recorded on\n *      the next click, not on the next page load. And the gate lives HERE, so a\n *      component cannot forget it; {@link svNavRecorder} is the only way in.\n *\n *   2. **A key is stripped unless a retention policy was declared.** `key` is\n *      whatever the family navigates by — a tab id, a step id, a page number —\n *      and in a real app those are record identifiers: `orders/8814` is a tab\n *      id and a customer's order. So a sink that does not state a retention\n *      window never receives one. See {@link SvNavRetention}.\n *\n * ── ⚠️ There is no tour telemetry to share a flag with ───────────────────────\n * The item says to \"gate it behind the same consent flag as the tour\n * telemetry\". **There is no such flag in this tree** — `projects/product-tour`\n * emits no telemetry and nothing in `core` holds a consent state; the only\n * privacy contract that exists is `SvAiPrivacyPolicy`, which governs masking\n * rendered content and answers a different question. So the flag is defined\n * here, as part of the sink, rather than imported from somewhere it does not\n * exist — and a tour that later wants telemetry has one to adopt.\n */\n\n// ─── Vocabulary ──────────────────────────────────────────────────────────────\n\n/**\n * Which navigation surface the move came from.\n *\n * The seven shipped families plus the two surfaces that are not components —\n * `link` for a plain anchor a host instruments itself, and `address` for a move\n * that arrived from the URL rather than from anything on screen.\n *\n * ★ Open to a host's own strings on purpose. A dashboard's command palette and\n *   its global search are navigation surfaces too, and the point of the stream\n *   is to compare them against the kit's; a closed union would make the\n *   comparison impossible in exactly the app that most wants it.\n */\nexport type SvNavSurface =\n  | 'tabs'\n  | 'stepper'\n  | 'pagination'\n  | 'breadcrumb'\n  | 'anchor'\n  | 'mega-menu'\n  | 'accordion'\n  | 'jump-menu'\n  | 'sidebar'\n  | 'link'\n  | 'address'\n  | (string & {});\n\n/**\n * What KIND of move the gesture was. Eight values, closed, and each one is\n * something a component can observe rather than guess.\n *\n * - `advance` — one forward through an ordered set. Next, arrow-right, the\n *   Continue button.\n * - `retreat` — one backward through the same set.\n * - `jump` — straight to a named destination, skipping whatever is between. A\n *   page number, a step click, a breadcrumb crumb, an anchor link.\n * - `explore` — a surface was opened to see what is in it, with nothing yet\n *   chosen. A mega-menu panel, an overflow menu, an accordion header.\n * - `resume` — the position came from the address or from restored state, not\n *   from a gesture. A deep link, a back button, a restored wizard.\n * - `refine` — the same set, presented differently. A page-size change.\n * - `escape` — the surface was left without a destination. Escape, a backdrop\n *   click, a dismissal.\n * - `blocked` — the move was asked for and refused. A linear gate, a guard\n *   rule, a disabled step.\n *\n * ★★ `blocked` IS THE ONE THAT PAYS FOR THE REST. Every other value has a\n *    rough equivalent somewhere in a host's existing analytics, because a\n *    successful navigation leaves a trail. A refusal leaves nothing at all: the\n *    user pressed something, nothing happened, and no page view was recorded.\n *    A wizard whose linear gate is misconfigured is invisible to conventional\n *    analytics and obvious in this stream.\n */\nexport type SvNavIntent =\n  | 'advance'\n  | 'retreat'\n  | 'jump'\n  | 'explore'\n  | 'resume'\n  | 'refine'\n  | 'escape'\n  | 'blocked';\n\n/**\n * How long the sink keeps what it is sent — a **documented** window, or `none`.\n *\n * ★★★ `'none'` IS THE DEFAULT AND IT IS LOAD-BEARING, NOT A PLACEHOLDER. A sink\n *     that declares `'none'` still receives every event; what it does not\n *     receive is {@link SvNavEvent.key} or {@link SvNavEvent.label}, because\n *     those are the two fields that can carry a record identifier. Counting how\n *     often people use the sidebar needs no identifier at all, so the default\n *     is the useful analytics with none of the liability.\n *\n * ⚠️ `surfaceId` and `reason` are NOT stripped — \"which surface\" is the point\n *    of the stream. That makes them static by contract: a surface name and a\n *    fixed reason word, never a record id. A dev build warns when a\n *    `surfaceId` sent to a `'none'` sink looks like one.\n *\n * Anything else is a string the host writes and is accountable for — `'30d'`,\n * `'session'`, `'per privacy policy §4'`. It is never parsed and never\n * enforced: this package cannot delete rows in somebody's warehouse. What it\n * can do is make the field impossible to omit, so \"we never decided\" stops\n * being expressible.\n */\nexport type SvNavRetention = 'none' | (string & {});\n\n/**\n * One navigation, as recorded.\n *\n * ⚠️ `key` and `label` are `null` whenever the sink's retention is `'none'`,\n *    whatever the component passed. See {@link SvNavRetention}.\n */\nexport interface SvNavEvent {\n  /** Which family or host surface the move came from. */\n  readonly surface: SvNavSurface;\n  /**\n   * Which instance, when a page has more than one. `null` when the host did\n   * not name it — two sidebars are still both `'sidebar'`.\n   *\n   * ★ **A static surface name — `'primary-nav'`, `'settings-tabs'` — never a\n   *   record id.** It is sent under every retention, `'none'` included, so an\n   *   id built from data (`'order-8814-tabs'`, a UUID) would carry exactly what\n   *   the retention strip exists to keep out. A dev build warns when one looks\n   *   like that.\n   */\n  readonly surfaceId: string | null;\n  /** What kind of move it was. See {@link SvNavIntent}. */\n  readonly intent: SvNavIntent;\n  /** What the family navigates by — a tab id, a step id, a page number. */\n  readonly key: string | null;\n  /** The human-readable label of the destination, when the surface has one. */\n  readonly label: string | null;\n  /** Position within the set, when the set is ordered. */\n  readonly index: number | null;\n  /**\n   * Why, for the intents that have a why. `blocked` carries the gate that\n   * refused (`'linear'`, `'guard'`, `'disabled'`); `escape` carries how the\n   * surface was left.\n   *\n   * A fixed vocabulary word, like `surfaceId` never stripped — so never\n   * user or record data.\n   */\n  readonly reason: string | null;\n  /** `Date.now()` at the moment the event was recorded. */\n  readonly at: number;\n}\n\n/**\n * What a component passes. The surface and the timestamp are the recorder's, so\n * the only required field is the one thing a component alone can know.\n */\nexport interface SvNavEventDraft {\n  readonly intent: SvNavIntent;\n  readonly key?: string | null;\n  readonly label?: string | null;\n  readonly index?: number | null;\n  readonly reason?: string | null;\n}\n\n// ─── The sink ────────────────────────────────────────────────────────────────\n\n/** Where navigation events go, and under what terms. */\nexport interface SvNavTelemetry {\n  /** Names the implementation, for diagnostics only. */\n  readonly kind: string;\n  /**\n   * How long this sink keeps an identifier. `'none'` strips `key` and `label`\n   * before the sink sees them. See {@link SvNavRetention}.\n   */\n  readonly retention: SvNavRetention;\n  /**\n   * May anything be recorded right now?\n   *\n   * ★ A function, not a boolean, and consulted per event — a consent banner\n   *   answered halfway through a session has to take effect on the next click.\n   */\n  consent(): boolean;\n  /** Receive one event. Never called when {@link consent} returns `false`. */\n  record(event: SvNavEvent): void;\n}\n\n/**\n * The default: nothing is collected.\n *\n * ★ And unlike the default link adapter it does **not** warn. A missing link\n *   adapter is a regression the host cannot see; a missing telemetry sink is\n *   the correct state for every app that did not ask for analytics, which is\n *   most of them. Nagging about not collecting data has the ethics backwards.\n */\nexport function svNoopNavTelemetry(): SvNavTelemetry {\n  return {\n    kind: 'noop',\n    retention: 'none',\n    consent: () => false,\n    record: () => undefined,\n  };\n}\n\nexport const SV_NAV_TELEMETRY = new InjectionToken<SvNavTelemetry>('SV_NAV_TELEMETRY', {\n  providedIn: 'root',\n  factory: svNoopNavTelemetry,\n});\n\n/**\n * Provide a sink for the whole app.\n *\n * ```ts\n * provideSvNavTelemetry(() => {\n *   const consent = inject(ConsentService);\n *   return {\n *     kind: 'segment',\n *     retention: '30d',\n *     consent: () => consent.analytics(),\n *     record: (e) => analytics.track('navigation', e),\n *   };\n * })\n * ```\n */\nexport function provideSvNavTelemetry(factory: () => SvNavTelemetry): EnvironmentProviders {\n  return makeEnvironmentProviders([{ provide: SV_NAV_TELEMETRY, useFactory: factory }]);\n}\n\n// ─── What a component holds ──────────────────────────────────────────────────\n\n/** A component's handle on the stream. One per component instance. */\nexport interface SvNavRecorder {\n  /** True when a sink is present AND consent is currently granted. */\n  enabled(): boolean;\n  /** Record one move. A no-op when {@link enabled} is false. */\n  record(draft: SvNavEventDraft): void;\n}\n\n/**\n * Get a recorder for one surface. Call in an injection context.\n *\n * ```ts\n * private readonly nav = svNavRecorder('stepper', () => this.surfaceId());\n * …\n * this.nav.record({ intent: 'blocked', key: step.item.id, index: step.index, reason });\n * ```\n *\n * ★★ THE CONSENT CHECK HAPPENS BEFORE THE PAYLOAD IS BUILT, and that ordering\n *    is the difference between a rule and a mechanism. Building the object and\n *    then dropping it would mean the identifier had already been read out of\n *    the host's data — harmless in-process, but it leaves the retention rule\n *    with nowhere to be enforced and makes the cheap path (no consent) do all\n *    the work of the expensive one. Here a withheld consent costs one call.\n */\nexport function svNavRecorder(\n  surface: SvNavSurface,\n  surfaceId?: () => string | null | undefined,\n): SvNavRecorder {\n  const sink = inject(SV_NAV_TELEMETRY);\n  return svNavRecorderFrom(sink, surface, surfaceId);\n}\n\n/**\n * Does `surfaceId` look like it was built from a record rather than named?\n *\n * A heuristic for a dev warning, not a filter: a UUID, a long hex run (an\n * ObjectId, a hash), four or more digits in a row (`order-8814`), or a\n * digits-only path segment (`orders/42`). Short ordinals like `'tabs-2'` pass —\n * numbering two instances on a page is what the field is for.\n */\nconst RECORD_ID_PATTERN =\n  /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[0-9a-f]{16,}|\\d{4,}|(?:^|[/:])\\d+(?:[/:]|$)/i;\n\n/**\n * The same thing without the injection context — for tests, and for a host\n * composing a recorder around a sink it already holds.\n */\nexport function svNavRecorderFrom(\n  sink: SvNavTelemetry,\n  surface: SvNavSurface,\n  surfaceId?: () => string | null | undefined,\n): SvNavRecorder {\n  const keepsIdentifiers = sink.retention !== 'none';\n\n  if (keepsIdentifiers && sink.kind !== 'noop') {\n    // Not an error — a stated window is exactly what the contract asks for.\n    // The warning exists because `retention` is a promise made to a user by a\n    // host that may have typed a string to get past a required field.\n    svWarnOnce(\n      `sv-nav-telemetry/${sink.kind}`,\n      `Navigation telemetry sink \"${sink.kind}\" declares retention \"${sink.retention}\", so ` +\n        'navigation keys and labels are sent to it. Those can be record identifiers ' +\n        '(a tab id is often a route segment). Confirm the window is one your privacy ' +\n        'policy states, or set retention: \"none\" to have them stripped.',\n    );\n  }\n\n  return {\n    enabled: () => sink.consent(),\n\n    record(draft: SvNavEventDraft): void {\n      // ★ Consent first, before anything is read or allocated.\n      if (!sink.consent()) return;\n\n      const id = surfaceId?.() ?? null;\n      if (\n        !keepsIdentifiers &&\n        id !== null &&\n        typeof ngDevMode !== 'undefined' &&\n        ngDevMode &&\n        RECORD_ID_PATTERN.test(id)\n      ) {\n        svWarnOnce(\n          `sv-nav-telemetry/surface-id/${surface}`,\n          `Navigation telemetry surfaceId \"${id}\" (surface \"${surface}\") looks like a record ` +\n            'identifier. surfaceId is sent even under retention \"none\", so it must be a static ' +\n            'surface name (\"settings-tabs\"), never an id built from data.',\n        );\n      }\n\n      sink.record({\n        surface,\n        surfaceId: id,\n        intent: draft.intent,\n        // ★★ The strip. A component passes the key unconditionally — it cannot\n        //    be expected to know the sink's terms — and the terms are applied\n        //    in exactly one place.\n        key: keepsIdentifiers ? (draft.key ?? null) : null,\n        label: keepsIdentifiers ? (draft.label ?? null) : null,\n        index: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