@the-portland-company/shell 0.76.15 → 0.77.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/FormColumn.tsx","../src/lib/deprecation.ts","../src/lib/topbarIconSlot.ts","../src/lib/brandGlyphs.tsx","../src/notifications/adapter.ts","../src/native/chromeActions.tsx","../src/speculation/emitRules.ts","../src/speculation/SpeculationRulesScript.tsx"],"names":["jsx","useState","useEffect","lowFuelHintVisible"],"mappings":";;;;;;;AAmBe,SAAR,UAAA,CAA4B,EAAE,QAAA,EAAU,SAAA,EAAU,EAAoB;AAC3E,EAAA,uBACE,GAAA,CAAC,SAAI,wBAAA,EAAuB,EAAA,EAAG,WAAW,IAAA,CAAK,sBAAA,EAAwB,SAAS,CAAA,EAC7E,QAAA,EACH,CAAA;AAEJ;;;ACvBA,IAAM,MAAA,uBAAa,GAAA,EAAY;AAE/B,SAAS,KAAA,GAAiB;AACxB,EAAA,IAAI;AACF,IAAA,OAAO,OAAO,OAAA,KAAY,WAAA,IAAe,OAAA,CAAQ,KAAK,QAAA,KAAa,YAAA;AAAA,EACrE,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAGO,SAAS,cAAA,CAAe,KAAa,OAAA,EAAuB;AACjE,EAAA,IAAI,CAAC,KAAA,EAAM,IAAK,MAAA,CAAO,GAAA,CAAI,GAAG,CAAA,EAAG;AACjC,EAAA,MAAA,CAAO,IAAI,GAAG,CAAA;AACd,EAAA,OAAA,CAAQ,IAAA,CAAK,CAAA,8BAAA,EAAiC,OAAO,CAAA,CAAE,CAAA;AACzD;ACYO,SAAS,uBAAuB,IAAA,EAAqC;AAC1E,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,SAAwB,IAAI,CAAA;AAEpD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,OAAO,WAAW,WAAA,EAA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AO,MAAM,CAAA;AAChD,IAAA,IAAI,IAAA,CAAK,WAAW,CAAA,EAAG;AAEvB,IAAA,MAAM,QAAA,GACJ,OAAQ,MAAA,CACL,mBAAA,KAAwB,UAAA,GACtB,MAAA,CACE,mBAAA,GACH,CAAC,EAAA,KAAmB,UAAA,CAAW,EAAA,EAAI,GAAI,CAAA;AAE7C,IAAA,MAAM,QAA2B,EAAC;AAClC,IAAA,QAAA,CAAS,MAAM;AACb,MAAA,KAAA,MAAW,OAAO,IAAA,EAAM;AACtB,QAAA,IAAI,SAAS,aAAA,CAAc,CAAA,KAAA,EAAQ,aAAa,CAAA,QAAA,EAAW,GAAG,IAAI,CAAA,EAAG;AACrE,QAAA,MAAM,IAAA,GAAO,QAAA,CAAS,aAAA,CAAc,MAAM,CAAA;AAC1C,QAAA,IAAA,CAAK,GAAA,GAAM,UAAA;AACX,QAAA,IAAA,CAAK,IAAA,GAAO,GAAA;AACZ,QAAA,IAAA,CAAK,YAAA,CAAa,eAAe,EAAE,CAAA;AACnC,QAAA,QAAA,CAAS,IAAA,CAAK,YAAY,IAAI,CAAA;AAC9B,QAAA,KAAA,CAAM,KAAK,IAAI,CAAA;AAAA,MACjB;AAAA,IACF,CAAC,CAAA;AACD,IAAA,OAAO,MAAM;AACX,MAAA,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA,KAAM,CAAA,CAAE,QAAQ,CAAA;AAAA,IACjC,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,KAAA,EAAO,MAAM,CAAC,CAAA;AAElB,EAAA,OAAO,IAAA;AACT","file":"chunk-TUK2IEL5.js","sourcesContent":["import type { ReactNode } from 'react';\nimport clsx from 'clsx';\n\ntype FormColumnProps = {\n children: ReactNode;\n className?: string;\n};\n\n/**\n * The ONE constrained layout inside the frame's fluid `<main>` (Brand guideline\n * \"Content width is fluid\"): a single left-aligned column, 960px max, for form\n * and settings pages — single-record edit forms, Organization Settings tabs,\n * My Profile, activation and setup flows. Data surfaces (tables, dashboards,\n * maps) never use it; they take the full fluid width.\n *\n * It adds no gutter of its own — `<main>` already owns the 24px / 16px gutter —\n * and it is never centered. There is no width prop on purpose: a per-page\n * max-width is exactly what the guideline forbids.\n */\nexport default function FormColumn({ children, className }: FormColumnProps) {\n return (\n <div data-shell-form-column=\"\" className={clsx('w-full max-w-[960px]', className)}>\n {children}\n </div>\n );\n}\n","// One-time console warnings for retired shell API, in development only.\n\nconst warned = new Set<string>()\n\nfunction isDev(): boolean {\n try {\n return typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production'\n } catch {\n return false\n }\n}\n\n/** Warn once per `key` in dev; silent in production builds. */\nexport function warnDeprecated(key: string, message: string): void {\n if (!isDev() || warned.has(key)) return\n warned.add(key)\n console.warn(`[@the-portland-company/shell] ${message}`)\n}\n\n/** Test hook: forget which warnings have fired. */\nexport function resetDeprecationWarnings(): void {\n warned.clear()\n}\n","import { useEffect, useState } from 'react'\n\n/**\n * The six canonical top-bar action slots (Reference/Global-Rules v9 → top-bar\n * icons). Each slot's GLYPH is unique and comes from the Brand API\n * `topbarIcons.items.*` tokens, exposed as `--topbar-icon-<slot>` CSS vars\n * whose value is the brand-icon NAME. Every OTHER property — size, gap, color,\n * hover, selected — is universal across all six slots.\n */\nexport type TopBarIconSlot =\n | 'comms-fuel'\n | 'apps'\n | 'notifications'\n | 'alerts'\n | 'support'\n | 'dark-mode'\n\n/**\n * Reads the glyph NAME for a slot from its `--topbar-icon-<slot>` CSS var.\n *\n * Runs in an effect because the Brand stylesheet is appended to <head> at\n * runtime (Global Rules forbids baking it into the build), so the var is not\n * resolvable during SSR or the first synchronous render. The MutationObserver\n * re-reads once the stylesheet lands so the glyph upgrades from the caller's\n * fallback without a reload.\n *\n * Returns null when the slot has no Brand glyph — callers render their own\n * fallback icon in that case.\n */\nexport function useTopBarIconSlotGlyph(slot: TopBarIconSlot): string | null {\n const [name, setName] = useState<string | null>(null)\n\n useEffect(() => {\n if (typeof window === 'undefined') return\n\n const read = () => {\n const raw = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(`--topbar-icon-${slot}`)\n .trim()\n // Brand may emit the name quoted (e.g. \"bell\"); strip the quotes.\n .replace(/^['\"]|['\"]$/g, '')\n setName(raw.length > 0 ? raw : null)\n }\n\n read()\n\n const observer = new MutationObserver(read)\n observer.observe(document.head, { childList: true, subtree: true })\n return () => observer.disconnect()\n }, [slot])\n\n return name\n}\n\n/** Path to a brand-icon SVG in the consuming app's public dir. */\nexport function brandIconSrc(name: string, basePath = '/brand/icons/') {\n return `${basePath}${name}.svg`\n}\n","import type { ComponentType } from 'react'\nimport {\n FiAlertCircle,\n FiBattery,\n FiBatteryCharging,\n FiAlertTriangle,\n FiBell,\n FiGrid,\n FiHelpCircle,\n FiInfo,\n FiLifeBuoy,\n FiMail,\n FiMessageSquare,\n FiMoon,\n FiSettings,\n FiSun,\n FiUser,\n FiZap,\n} from 'react-icons/fi'\n\nexport type GlyphComponent = ComponentType<{ size?: number | string; className?: string }>\n\n/**\n * Brand-glyph registry: maps the icon NAME the Brand API emits (e.g.\n * `--topbar-icon-comms-fuel: bolt`) to a component.\n *\n * These names are Feather/Lucide icon names, NOT asset filenames — there is no\n * `/brand/icons/<name>.svg` for them in any app, and treating them as URLs\n * renders a broken image. Resolving them against the icon library the shell\n * already depends on keeps every app consistent with zero vendored assets.\n *\n * Aliases are included where Brand and Feather disagree on a name (`bolt` vs\n * `zap`, `life-buoy` vs `life-ring`).\n */\nconst GLYPHS: Record<string, GlyphComponent> = {\n // Communications Fuel reads as a LEVEL, so its glyph is a battery. `bolt`/\n // `zap` stay mapped for older Brand values.\n 'battery-charging': FiBatteryCharging,\n battery: FiBattery,\n fuel: FiBatteryCharging,\n bolt: FiZap,\n zap: FiZap,\n grid: FiGrid,\n apps: FiGrid,\n bell: FiBell,\n notification: FiBell,\n 'alert-triangle': FiAlertTriangle,\n alert: FiAlertTriangle,\n 'alert-circle': FiAlertCircle,\n 'life-buoy': FiLifeBuoy,\n 'life-ring': FiLifeBuoy,\n support: FiLifeBuoy,\n 'help-circle': FiHelpCircle,\n moon: FiMoon,\n sun: FiSun,\n info: FiInfo,\n mail: FiMail,\n 'message-square': FiMessageSquare,\n settings: FiSettings,\n user: FiUser,\n}\n\n/**\n * Resolve a Brand glyph name to a component. Returns null for an unknown name\n * so the caller renders its own fallback — an unrecognized token must never\n * produce a broken or empty icon.\n */\nexport function resolveBrandGlyph(name: string | null | undefined): GlyphComponent | null {\n if (!name) return null\n return GLYPHS[name.trim().toLowerCase()] ?? null\n}\n\n/** Names the registry knows — exported for tests and tooling. */\nexport const KNOWN_BRAND_GLYPHS = Object.keys(GLYPHS)\n","// ---------------------------------------------------------------------------\n// NotificationsAdapter — the contract the shell's single Notifications bell is\n// fed by (Specs/System-Communications §6.3 and §12.2; UI-Platform → top bar).\n//\n// The bell never calls the Comms service directly. Reads and writes go through\n// the same-origin chrome API proxy with the viewer's session, so the Comms\n// `GET /v1/me/notifications` and `POST /v1/me/notifications/:id/{read,archive,\n// resolve}` routes (politogy-comms PR #14) are reached as `me/notifications…`\n// relative to the proxy base. The proxy's session cookie or bearer is what\n// Comms verifies (`getSubject`, OIDC `sub`); the shell never sends a token.\n//\n// Degradation contract: a missing session (401), an absent route (404), a\n// network failure or a malformed body all resolve to an EMPTY feed or `false`.\n// The bell then renders \"all caught up\" rather than an error state, and nothing\n// is thrown into the chrome.\n// ---------------------------------------------------------------------------\n\nimport type { NavChromeFetcher } from '../native/chromeActions'\n\nexport type CommsNotificationKind = 'notification' | 'alert'\n\n/** One row of the bell feed, as the shell reads it (camelCased). */\nexport type CommsNotification = {\n id: string\n kind: CommsNotificationKind\n title: string\n body: string\n icon: string | null\n link: string | null\n readAt: string | null\n orgId: string | null\n createdAt: string | null\n}\n\nexport type NotificationsFeed = {\n /** Alerts first, then notifications, newest first (Comms sorts them). */\n notifications: CommsNotification[]\n /** One badge number: unread notifications plus unresolved alerts (Spec §6.3). */\n badge: number\n}\n\nexport type NotificationsAdapter = {\n /** Read the signed-in viewer's feed, scoped to an org when one is active. */\n list(orgId: string | null): Promise<NotificationsFeed>\n /** Mark one row read. Resolves false on any failure, never throws. */\n markRead(id: string): Promise<boolean>\n /** Archive one row (hides it from the feed). Resolves false on failure. */\n archive(id: string): Promise<boolean>\n /** Resolve one alert. Comms rejects this for non-alert rows. */\n resolve(id: string): Promise<boolean>\n}\n\n/** The empty bell: what every degraded path renders. Always a fresh object. */\nexport function emptyNotificationsFeed(): NotificationsFeed {\n return { notifications: [], badge: 0 }\n}\n\nfunction asString(value: unknown): string | null {\n return typeof value === 'string' ? value : null\n}\n\n/**\n * Shape a raw Comms body into the feed. Tolerant on purpose: unknown keys are\n * ignored, rows without an id are dropped, and archived rows are never shown.\n */\nexport function normalizeNotificationsFeed(raw: unknown): NotificationsFeed {\n if (!raw || typeof raw !== 'object') return emptyNotificationsFeed()\n const body = raw as { notifications?: unknown; badge?: unknown }\n const rows = Array.isArray(body.notifications) ? body.notifications : []\n const notifications: CommsNotification[] = []\n for (const row of rows) {\n if (!row || typeof row !== 'object') continue\n const r = row as Record<string, unknown>\n const id = asString(r.id)\n if (!id || asString(r.archived_at)) continue\n notifications.push({\n id,\n kind: r.kind === 'alert' ? 'alert' : 'notification',\n title: asString(r.title) ?? '',\n body: asString(r.body) ?? '',\n icon: asString(r.icon),\n link: asString(r.link),\n readAt: asString(r.read_at),\n orgId: asString(r.org_id),\n createdAt: asString(r.created_at),\n })\n }\n const badge =\n typeof body.badge === 'number' && Number.isFinite(body.badge)\n ? Math.max(0, Math.floor(body.badge))\n : notifications.filter((n) => n.kind === 'alert' || n.readAt === null).length\n return { notifications, badge }\n}\n\n/**\n * Build the comms-backed adapter over the app's chrome fetcher. A null fetcher\n * (no chrome proxy wired) yields the empty bell with no network activity.\n */\nexport function createCommsNotificationsAdapter(\n fetchJson: NavChromeFetcher | null,\n): NotificationsAdapter {\n const act = async (id: string, action: 'read' | 'archive' | 'resolve'): Promise<boolean> => {\n if (!fetchJson || !id) return false\n try {\n await fetchJson(`me/notifications/${encodeURIComponent(id)}/${action}`, { method: 'POST' })\n return true\n } catch {\n return false\n }\n }\n return {\n async list(orgId) {\n if (!fetchJson) return emptyNotificationsFeed()\n try {\n const query = orgId ? `?org_id=${encodeURIComponent(orgId)}` : ''\n return normalizeNotificationsFeed(await fetchJson(`me/notifications${query}`))\n } catch {\n return emptyNotificationsFeed()\n }\n },\n markRead: (id) => act(id, 'read'),\n archive: (id) => act(id, 'archive'),\n resolve: (id) => act(id, 'resolve'),\n }\n}\n\n/**\n * Map a feed onto the panel's payload shape so the existing bell UI (alert\n * rows, read toggles, badge) renders adapter rows without a second renderer.\n */\nexport function notificationsFeedToPayload(\n feed: NotificationsFeed,\n orgId: string | null,\n): {\n organizationId: string\n alerts: { id: string; title: string; description: string; href: string | null; kind: string; read: boolean }[]\n replies: never[]\n badge: number\n} {\n return {\n organizationId: orgId ?? '',\n alerts: feed.notifications.map((n) => ({\n id: n.id,\n title: n.title,\n description: n.body,\n href: n.link,\n kind: n.kind,\n read: n.readAt !== null,\n })),\n replies: [],\n badge: feed.badge,\n }\n}\n","// ---------------------------------------------------------------------------\n// Native chrome actions — Tailwind-only top-bar widgets (Fuel, Notifications,\n// Support, Navigation-display) backed by the shared chrome API\n// (politogy-contacts-api on Railway). Zero Chakra, zero router, zero fetch\n// opinion: the consuming app injects ONE fetcher via <NavChromeProvider> —\n// typically a same-origin proxy route that attaches its own session's Bearer\n// token server-side — and every widget in every app runs this exact code.\n//\n// Data endpoints (paths are relative; the app's fetcher owns the base URL):\n// GET communications/fuel-status (header x-contacts-org: <core org id>)\n// GET notifications (header x-contacts-org: <core org id>)\n// GET orgs\n// POST support { message }\n//\n// Loading states follow Global-Rules \"Loading & Async States\": the chrome\n// (button, popover frame, labels) always renders; only the VALUE area shows a\n// skeleton shimmer — never a spinner, never a blank panel.\n// ---------------------------------------------------------------------------\n\n'use client'\n\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n type ComponentType,\n type ReactNode,\n} from 'react'\nimport { createPortal } from 'react-dom'\n\nimport { useTopBarIconSlotGlyph, type TopBarIconSlot } from '../lib/topbarIconSlot'\nimport { resolveBrandGlyph } from '../lib/brandGlyphs'\nimport {\n createCommsNotificationsAdapter,\n emptyNotificationsFeed,\n notificationsFeedToPayload,\n type NotificationsAdapter,\n} from '../notifications/adapter'\nimport {\n applyThemePreference,\n isThemePreference,\n readThemeCookie,\n writeThemeCookie,\n readPendingThemeChoice,\n markThemeChoicePending,\n clearPendingThemeChoice,\n THEME_STORAGE_KEY,\n type ThemePreference as SharedThemePreference,\n} from '../theme-preference'\n\ntype NavIconLike = ComponentType<{ size?: number; className?: string }>\n\n// ---------------------------------------------------------------------------\n// Core-app deep links. The billing surface lives on the VRM-core app; we would\n// derive its origin from POLITOGY_APPS.vrm, but that registry lives in\n// ../app-chrome which imports THIS module — so pulling it in here would create\n// an import cycle. One local constant instead (kept in step with the registry's\n// `vrm` origin).\n// ---------------------------------------------------------------------------\n\nexport const CORE_APP_ORIGIN = 'https://app.politogyvrm.com'\n/** Text/Email fuel top-up page (SMS Signal + Email Broadcast). */\nexport const CORE_BILLING_PATH = '/organization-settings/subscription-billing/text-email'\nconst CORE_BILLING_URL = `${CORE_APP_ORIGIN}${CORE_BILLING_PATH}`\nconst QUARANTINED_CONTACTS_URL = `https://contacts.politogyvrm.com/duplicates`\n\n/** Specs origin — same env-aware-constant pattern as CORE_APP_ORIGIN. */\nexport const SPECS_ORIGIN = 'https://specs.politogyvrm.com'\n\n/**\n * Stamp the active org onto a cross-app link, the same `?org=<uuid>` selector\n * the nav tree and Mode pill use. A bare link into VRM core drops a multi-org\n * user into whatever org core defaults to, which is a different account than\n * the one whose fuel / quarantine counts they just clicked.\n */\nfunction withOrgParam(url: string, orgId: string | null | undefined): string {\n if (!orgId) return url\n return `${url}${url.includes('?') ? '&' : '?'}org=${orgId}`\n}\n\n/** Scope the quarantined-contacts view to one sender. */\nfunction withPhoneParam(url: string, phone: string | null | undefined): string {\n if (!phone) return url\n return `${url}${url.includes('?') ? '&' : '?'}phone=${encodeURIComponent(phone)}`\n}\n\n/**\n * Resolve an organization logo URL for rendering in ANY app.\n *\n * `organizations.logo_url` is authored by VRM core and stored as a ROOT-RELATIVE\n * core route — `/api/storage/public?bucket=organization-logos&path=<org>/logo.png`\n * (the signed-storage proxy). VRM core renders it correctly because that path\n * resolves against its own origin; every other app resolves it against its own\n * origin (forms.politogyvrm.com/api/storage/public), gets a 404, and shows a\n * broken image. The chrome API passes the stored value through verbatim, so the\n * resolution belongs here — one definition for every app, core included.\n *\n * Absolute URLs (http/https/data/blob) pass through untouched.\n */\nexport function resolveOrgLogoUrl(url: string | null | undefined): string | undefined {\n const raw = url?.trim()\n if (!raw) return undefined\n if (/^(?:[a-z][a-z0-9+.-]*:|\\/\\/)/i.test(raw)) return raw\n return `${CORE_APP_ORIGIN}${raw.startsWith('/') ? '' : '/'}${raw}`\n}\n\n// ---------------------------------------------------------------------------\n// Shared 32×32 circular top-bar button chrome — the ONE definition of the\n// top-bar trigger (Global Rules: no slot hand-rolls its own trigger/badge).\n// NavTopBar's structured actionsList buttons use this same builder.\n// ---------------------------------------------------------------------------\n\n/**\n * Glyph size inside every top-bar icon button — Reference/UI-Platform v30:\n * \"34px buttons / 17px glyph / 6px gap\".\n */\nexport const TOPBAR_GLYPH_SIZE = 17\n\nexport function topBarIconButtonClass(tone: 'default' | 'warning' | 'danger' = 'default'): string {\n const toneClass =\n tone === 'danger' || tone === 'warning'\n ? 'text-[color:var(--chrome-danger)] hover:text-[color:var(--chrome-danger)]'\n : 'text-[color:var(--topbar-icon-color,var(--muted))] hover:text-[color:var(--topbar-icon-hover-color,var(--foreground))] hover:bg-[color:var(--topbar-icon-hover-bg,transparent)]'\n return [\n // `group/tbtip` powers the shared <TopBarTooltip> rendered inside the trigger.\n 'group/tbtip relative flex items-center justify-center rounded-[var(--topbar-icon-button-radius,5px)] border border-transparent transition',\n 'h-[var(--topbar-icon-button-size,34px)] w-[var(--topbar-icon-button-size,34px)]',\n toneClass,\n ].join(' ')\n}\n\n/** The shared count badge — one definition, used by every slot. */\n// ---------------------------------------------------------------------------\n// Top-bar panel registry.\n//\n// The top bar hosts two KINDS of surface: panels (opened deliberately by the\n// user from an icon) and transient nudges (the low-fuel hint, the new-reply\n// toast) that appear on their own. They are separate components under separate\n// triggers, so nothing stopped a nudge from covering an open panel — measured\n// in production: the reply toast over the notifications header, and the\n// low-fuel nudge over the same header from the fuel trigger two icons away.\n//\n// A module-scoped counter is enough: any nudge can ask \"is a panel open?\"\n// without the slots having to know about each other.\n// ---------------------------------------------------------------------------\nlet openPanelCount = 0\nconst panelListeners = new Set<() => void>()\nconst emitPanelChange = () => panelListeners.forEach((l) => l())\n\nfunction setPanelOpenGlobal(open: boolean) {\n openPanelCount = Math.max(0, openPanelCount + (open ? 1 : -1))\n emitPanelChange()\n}\n\n/** True while ANY top-bar panel is open. Nudges use it to stay out of the way. */\nexport function useAnyTopBarPanelOpen() {\n return useSyncExternalStore(\n (cb) => {\n panelListeners.add(cb)\n return () => panelListeners.delete(cb)\n },\n () => openPanelCount > 0,\n () => false,\n )\n}\n\nexport function TopBarCountBadge({ count }: { count: number }) {\n if (!(count > 0)) return null\n return (\n <span className=\"absolute -top-[5px] -right-[5px] flex h-4 min-w-4 items-center justify-center rounded-full bg-[color:var(--chrome-danger)] px-1 text-[10px] font-bold leading-4 text-[#FFFFFF]\">\n {count > 99 ? '99+' : count}\n </span>\n )\n}\n\n/**\n * The shared hover tooltip every top-bar control renders BELOW itself: an\n * up-pointing arrow at the icon, a bold title line and a muted description.\n * Pure CSS (group-hover) so it works on <a>, <button> and <summary> triggers.\n * The trigger must carry `group/tbtip relative` (topBarIconButtonClass does).\n */\nexport function TopBarTooltip({\n title,\n description,\n}: {\n title: string\n description?: ReactNode\n}) {\n // Styled ONLY on the Spec tooltip tokens (shellChrome.button.tooltipBg/Fg ->\n // --app-btn-tooltip-bg/-fg; Brand guideline \"Tooltips point at their\n // trigger\", UI-Platform \"Top-bar tooltips and panels - one shared\n // treatment\"). The literal fallbacks are the v150 token values for a page\n // that has not loaded the runtime token sheet yet. The arrow shares the\n // body's fill and border so the two read as one continuous shape, and the\n // tooltip opens on keyboard focus as well as hover (guideline: hover AND\n // focus); the description is the title color at reduced opacity so it\n // stays legible on whatever the token picks.\n return (\n <span\n role=\"tooltip\"\n className=\"pointer-events-none absolute left-1/2 top-full z-50 mt-2 hidden w-max max-w-56 -translate-x-1/2 flex-col rounded-lg border border-[color:var(--app-btn-tooltip-bg,#2F3136)] bg-[color:var(--app-btn-tooltip-bg,#2F3136)] px-3 py-2 text-left shadow-[var(--shadow-soft)] group-hover/tbtip:flex group-focus-visible/tbtip:flex\"\n >\n {/* Arrow pointing up at the icon - same fill and border as the body. */}\n <span\n aria-hidden\n className=\"absolute -top-[5px] left-1/2 h-2.5 w-2.5 -translate-x-1/2 rotate-45 border-l border-t border-[color:var(--app-btn-tooltip-bg,#2F3136)] bg-[color:var(--app-btn-tooltip-bg,#2F3136)]\"\n />\n <span className=\"text-xs font-semibold text-[color:var(--app-btn-tooltip-fg,#FFFFFF)]\">{title}</span>\n {description ? (\n <span className=\"mt-0.5 text-[11px] leading-snug text-[color:var(--app-btn-tooltip-fg,#FFFFFF)] opacity-75\">\n {description}\n </span>\n ) : null}\n </span>\n )\n}\n\n/**\n * The up-pointing arrow every top-bar panel renders, anchored under its\n * trigger icon (panels are right-aligned, so the arrow sits at the trigger's\n * center: 16px in from the panel's right edge). One definition — every menu\n * points at its own icon identically.\n */\nexport function TopBarPanelArrow() {\n return (\n <span\n aria-hidden\n className=\"absolute -top-[5px] right-[11px] h-2.5 w-2.5 rotate-45 border-l border-t border-[color:var(--line)] bg-[color:var(--panel-elevated)]\"\n />\n )\n}\n\n/**\n * Wrapper for third-party top-bar widgets that ship their own launcher button\n * (e.g. DevNotes). Normalizes the trigger to the universal 32px circular slot\n * (chrome.css `.topbar-widget-slot`) and adds the standard tooltip.\n */\nexport function TopBarWidgetSlot({\n title,\n description,\n children,\n}: {\n title: string\n description?: string\n children: ReactNode\n}) {\n return (\n <span className=\"topbar-widget-slot group/tbtip relative inline-flex\">\n {children}\n <TopBarTooltip title={title} description={description} />\n </span>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Theme control — Light / System / Dark, rendered inside the account menu.\n// Controlled: the app owns persistence (profile + cross-subdomain cookie).\n// ---------------------------------------------------------------------------\n\nexport type ThemePreference = SharedThemePreference\n\nconst THEME_OPTIONS: { value: ThemePreference; label: string }[] = [\n { value: 'light', label: 'Light' },\n]\n\nexport function NavThemeControl({\n value,\n onChange,\n}: {\n value: ThemePreference\n onChange: (next: ThemePreference) => void\n}) {\n return (\n <div className=\"px-4 py-3\">\n <p className=\"mb-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Appearance\n </p>\n <div\n role=\"radiogroup\"\n aria-label=\"Appearance\"\n className=\"flex overflow-hidden rounded-full border border-[color:var(--line)]\"\n >\n {THEME_OPTIONS.map((opt) => (\n <button\n key={opt.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={value === opt.value}\n onClick={() => onChange(opt.value)}\n className={[\n 'flex-1 px-3 py-1.5 text-xs font-semibold transition',\n value === opt.value\n ? 'bg-[color:var(--color-accent-bg-safe,var(--color-accent))] text-[#FFFFFF]'\n : 'text-[color:var(--muted)] hover:bg-[color:var(--panel)] hover:text-[color:var(--foreground)]',\n ].join(' ')}\n >\n {opt.label}\n </button>\n ))}\n </div>\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// Chrome data context — the injected fetcher.\n// ---------------------------------------------------------------------------\n\nexport type NavChromeFetcher = (\n path: string,\n init?: { method?: string; headers?: Record<string, string>; body?: string },\n) => Promise<unknown>\n\n/** GET me — the authenticated user's chrome identity from the shared API.\n * userName prefers the VRM-core profile full name over token claims. */\nexport type ChromeMe = {\n user: string | null\n userName: string | null\n avatarUrl: string | null\n themePreference: string | null\n /** Universal navigation-display choice ('menu'|'tabs'|'both'); null when\n * unset or when the profile column is absent in this environment. */\n navDisplay: string | null\n /** The user's durable active-org preference (full org uuid); null when unset\n * or when the profile column is absent. Adopted only when the request\n * carries no `?org=`/cookie selector — URL → cookie → profile → default. */\n activeOrg?: string | null\n account?: string | null\n accountName?: string | null\n role?: string | null\n /** Contact reply-to, when the profile carries them (optional/tolerant). */\n email?: string | null\n phone?: string | null\n}\n\n/** In-flight-promise + short-TTL cache entry for one (endpoint, orgId) key. */\ntype ChromeFetchCacheEntry = { promise: Promise<unknown>; expiresAt: number }\n\n/** Default freshness window for de-duped chrome reads (orgs/me/notifications/\n * fuel-status). Short enough that a stale value never survives one nav, long\n * enough to collapse every hook mounted on the same page paint into one call. */\nconst CHROME_FETCH_CACHE_TTL_MS = 30_000\n\nfunction chromeCacheKey(path: string, orgId?: string | null): string {\n return orgId === undefined ? path : `${path}::${orgId ?? ''}`\n}\n\n/**\n * A shared read cache scoped to one `<NavChromeProvider>` (one fetcher, one\n * page boot). Every consumer of a given (path, orgId) pair within the TTL\n * window awaits the SAME promise instead of firing its own request — this is\n * what collapsed `/orgs` (2-4x), `/me` (2-3x) and `/notifications` (2-3x) per\n * page load, 1-3.5s each, down to one call apiece (nav-latency-report.md\n * Table 2). Keying by orgId means switching the active org is itself the\n * invalidation: the new org gets a fresh key, never the previous org's cached\n * value. A failed request is evicted immediately so the next consumer retries\n * rather than replaying the same rejection for the rest of the TTL.\n */\nfunction createChromeFetchCache(getFetchJson: () => NavChromeFetcher) {\n const cache = new Map<string, ChromeFetchCacheEntry>()\n\n function dedupedFetch(\n path: string,\n init: Parameters<NavChromeFetcher>[1] | undefined,\n opts: { orgId?: string | null; ttlMs?: number } = {},\n ): Promise<unknown> {\n const key = chromeCacheKey(path, opts.orgId)\n const now = Date.now()\n const hit = cache.get(key)\n if (hit && hit.expiresAt > now) return hit.promise\n // Return the fetcher's own promise (no extra `.catch` hop) so callers see\n // the same microtask depth as a direct fetchJson call; the boot screen's\n // first-tick dismissal (frameBootChrome.test) depends on that.\n const promise = getFetchJson()(path, init)\n promise.catch(() => cache.delete(key))\n cache.set(key, { promise, expiresAt: now + (opts.ttlMs ?? CHROME_FETCH_CACHE_TTL_MS) })\n return promise\n }\n\n /** Force the next read of `path` (any org) to skip the cache. Used after a\n * mutation that changes what an endpoint would return (e.g. marking chrome\n * notifications read server-side, if that ever moves off local storage). */\n function invalidate(path: string) {\n for (const key of cache.keys()) {\n if (key === path || key.startsWith(`${path}::`)) cache.delete(key)\n }\n }\n\n return { dedupedFetch, invalidate }\n}\n\ntype NavChromeContextValue = {\n fetchJson: NavChromeFetcher\n dedupedFetch: ReturnType<typeof createChromeFetchCache>['dedupedFetch']\n invalidateChromeCache: ReturnType<typeof createChromeFetchCache>['invalidate']\n me: ChromeMe | null\n meLoaded: boolean\n /** The bell's feed adapter; null = the legacy contacts-shaped feed. */\n notificationsAdapter: NotificationsAdapter | null\n}\n\nconst NavChromeContext = createContext<NavChromeContextValue | null>(null)\n\nexport function NavChromeProvider({\n fetchJson,\n notificationsAdapter,\n children,\n}: {\n fetchJson: NavChromeFetcher\n /**\n * Omitted: the bell reads the comms feed through the same proxy (default).\n * An app may inject its own adapter; `null` keeps the legacy feed.\n */\n notificationsAdapter?: NotificationsAdapter | null\n children: ReactNode\n}) {\n // The cache outlives re-renders but always calls the LATEST fetchJson (the\n // consuming app may pass a new function identity every render).\n const fetchJsonRef = useRef(fetchJson)\n fetchJsonRef.current = fetchJson\n const cacheRef = useRef<ReturnType<typeof createChromeFetchCache> | null>(null)\n if (!cacheRef.current) {\n cacheRef.current = createChromeFetchCache(() => fetchJsonRef.current)\n }\n const { dedupedFetch, invalidate: invalidateChromeCache } = cacheRef.current\n\n // One stable adapter per provider, built over the latest fetcher.\n const defaultAdapterRef = useRef<NotificationsAdapter | null>(null)\n if (!defaultAdapterRef.current) {\n defaultAdapterRef.current = createCommsNotificationsAdapter((path, init) =>\n fetchJsonRef.current(path, init),\n )\n }\n const adapter = notificationsAdapter === undefined ? defaultAdapterRef.current : notificationsAdapter\n\n // ONE `me` fetch per provider — identity (profile name/avatar) and the\n // theme reconciliation both hang off it.\n const [me, setMe] = useState<ChromeMe | null>(null)\n const [meLoaded, setMeLoaded] = useState(false)\n useEffect(() => {\n let cancelled = false\n dedupedFetch('me', undefined)\n .then((data) => {\n if (!cancelled) setMe(data as ChromeMe)\n })\n .catch(() => {\n /* degraded: session identity stands in */\n })\n .finally(() => {\n if (!cancelled) setMeLoaded(true)\n })\n return () => {\n cancelled = true\n }\n }, [dedupedFetch])\n\n return (\n <NavChromeContext.Provider\n value={{ fetchJson, dedupedFetch, invalidateChromeCache, me, meLoaded, notificationsAdapter: adapter }}\n >\n {children}\n </NavChromeContext.Provider>\n )\n}\n\n/** The authenticated user's chrome identity (profile name / avatar / theme). */\nexport function useChromeMe(): { me: ChromeMe | null; loaded: boolean } {\n const ctx = useContext(NavChromeContext)\n return { me: ctx?.me ?? null, loaded: ctx?.meLoaded ?? false }\n}\n\n/** The provider's de-duped chrome read (null outside <NavChromeProvider>). */\nexport function useNavChromeDedupedFetch(): NavChromeContextValue['dedupedFetch'] | null {\n return useContext(NavChromeContext)?.dedupedFetch ?? null\n}\n\n/** The injected chrome fetcher (null outside <NavChromeProvider>). */\nexport function useNavChromeFetcher(): NavChromeFetcher | null {\n return useContext(NavChromeContext)?.fetchJson ?? null\n}\n\nfunction useNavChrome(component: string): NavChromeContextValue {\n const ctx = useContext(NavChromeContext)\n if (!ctx) {\n throw new Error(\n `${component} must be rendered inside <NavChromeProvider> (inject the chrome API fetcher there).`,\n )\n }\n return ctx\n}\n\n// ---------------------------------------------------------------------------\n// Data shapes (mirror of politogy-contacts-api responses).\n// ---------------------------------------------------------------------------\n\nexport type FuelChannelStatus = {\n remainingUnits: number\n rawBalanceUnits: number\n usedUnits: number\n lowFuel: boolean\n lowFuelThreshold: number\n}\n\nexport type CommunicationsFuelStatus = {\n organizationId: string\n signal: FuelChannelStatus\n broadcast: FuelChannelStatus\n combinedAvailableCredits: number\n}\n\nexport type ChromeNotificationAlert = {\n id: string\n title: string\n description: string\n href: string | null\n kind: string\n /** Server read state (adapter feeds only); the local watermark still applies. */\n read?: boolean\n}\n\nexport type ChromeNotificationReply = {\n id: string\n contactId: string | null\n name: string\n preview: string\n /** Optional deep-link to the conversation; the new-reply toast opens it. */\n href?: string\n /**\n * Optional arrival timestamp. Present, it lets the trigger badge count a\n * reply as \"unseen\" only when it is newer than the last time the panel was\n * opened; absent (older payloads), replies simply don't survive the first\n * open as unseen. Tolerated either way.\n */\n createdAt?: string\n}\n\n/** A running or finished contact import surfaced in the notifications panel. */\nexport type ChromeNotificationImport = {\n id: string\n label: string\n /** 0–100 progress, or null when indeterminate (no bar rendered). */\n percent: number | null\n status: 'active' | 'completed'\n href: string | null\n}\n\n/** A cluster of quarantined contacts sharing one phone number. */\nexport type ChromeNotificationQuarantine = {\n phone: string\n count: number\n /** Upstream may omit it; the row already renders conditionally on it. */\n latestAt: string | null\n}\n\nexport type ChromeNotificationsPayload = {\n organizationId: string\n alerts: ChromeNotificationAlert[]\n replies: ChromeNotificationReply[]\n /** Optional — running/finished imports (tolerant when absent). */\n imports?: ChromeNotificationImport[]\n /** Optional — clustered quarantined contacts (tolerant when absent). */\n quarantined?: ChromeNotificationQuarantine[]\n /** Optional — the server's one badge number (adapter feeds only). */\n badge?: number\n}\n\nexport type ChromeOrgSummary = {\n id: string\n name: string | null\n logoUrl: string | null\n brandColor: string | null\n role: string | null\n /** Un-mapped VRM-core membership role (e.g. \"super_admin\"). */\n rawRole?: string | null\n}\n\n/**\n * Fetch the signed-in user's VRM-core organizations through the injected\n * fetcher. Exposed as a hook so the org switcher in the sidebar and the\n * org-scoped widgets share one request.\n */\nexport function useChromeOrgs({ enabled = true }: { enabled?: boolean } = {}): {\n orgs: ChromeOrgSummary[] | null\n loading: boolean\n error: boolean\n} {\n const { dedupedFetch } = useNavChrome('useChromeOrgs')\n const [orgs, setOrgs] = useState<ChromeOrgSummary[] | null>(null)\n const [loading, setLoading] = useState(enabled)\n const [error, setError] = useState(false)\n\n useEffect(() => {\n // Disabled when the app already holds the org list from its token-backed\n // session (auth-owned active org): no per-request chrome `/api/orgs` call.\n if (!enabled) {\n setLoading(false)\n return\n }\n let cancelled = false\n setLoading(true)\n setError(false)\n dedupedFetch('orgs', undefined)\n .then((data) => {\n if (cancelled) return\n const list = (data as { orgs?: ChromeOrgSummary[] })?.orgs ?? []\n setOrgs(list)\n })\n .catch(() => {\n if (!cancelled) setError(true)\n })\n .finally(() => {\n if (!cancelled) setLoading(false)\n })\n return () => {\n cancelled = true\n }\n }, [dedupedFetch, enabled])\n\n return { orgs, loading, error }\n}\n\n// ---------------------------------------------------------------------------\n// Internal building blocks.\n// ---------------------------------------------------------------------------\n\n/** Value-area skeleton shimmer (chrome/labels stay static per Global Rules). */\nfunction ValueSkeleton({ className }: { className?: string }) {\n return (\n <span\n aria-hidden\n className={[\n 'inline-block animate-pulse rounded bg-[color:var(--panel-elevated)]',\n className ?? 'h-4 w-16',\n ].join(' ')}\n />\n )\n}\n\n/** Slot-driven glyph: Brand-token name when resolvable, fallback otherwise. */\nfunction SlotGlyph({\n slot,\n fallback: Fallback,\n size = TOPBAR_GLYPH_SIZE,\n}: {\n slot?: TopBarIconSlot\n fallback: NavIconLike\n size?: number\n}) {\n const glyphName = useTopBarIconSlotGlyph(slot ?? 'apps')\n const BrandGlyph = slot ? resolveBrandGlyph(glyphName) : null\n const Glyph = BrandGlyph ?? Fallback\n return <Glyph size={size} className=\"text-current\" />\n}\n\n/**\n * A top-bar popover: the shared circular trigger + a right-aligned panel.\n * Closes on outside click / Escape. Purely presentational.\n *\n * EXPORTED so an app with a richer panel than the stock actions can render it\n * inside the SHARED chrome — same 32px trigger, same tooltip, same badge, same\n * panel surface and arrow — instead of hand-rolling a trigger and drifting.\n * This is the enabling step for folding VRM's Fuel breakdown, import-progress,\n * alerts and reply-feed panels into the shared cluster one at a time, without\n * dropping capability (shell-nav-handoff §4; UI-Platform forbids migrating an\n * app to a rendering that loses an element it already ships).\n */\nexport function TopBarPopover({\n label,\n description,\n slot,\n fallbackIcon,\n badge,\n tone,\n onOpen,\n openToken,\n onOpenChange,\n hideTooltip = false,\n children,\n panelClassName,\n}: {\n label: string\n description?: string\n slot?: TopBarIconSlot\n fallbackIcon: NavIconLike\n badge?: number\n tone?: 'default' | 'warning' | 'danger'\n onOpen?: () => void\n /**\n * Imperative \"open\" signal: whenever this number CHANGES the panel opens\n * (and `onOpen` fires). Lets a sibling — e.g. the notifications toast — open\n * the panel without owning the popover's state. Undefined disables it.\n */\n openToken?: number\n /**\n * Notified on every open/close. A sibling surface anchored to the same\n * trigger (e.g. the notifications toast) must know when the panel is open so\n * the two never render on top of each other — Reference/UI-Platform gives\n * every top-bar panel ONE surface anchored to its trigger, so a second\n * surface at the same anchor always occludes it.\n */\n onOpenChange?: (open: boolean) => void\n /**\n * Hide the trigger's hover tooltip while a transient nudge (the new-reply\n * toast, the low-fuel hint) is up under the same trigger. Both are z-50 and\n * anchored to the trigger, so without this the nudge paints over the\n * tooltip (measured on a2p: the reply toast covered \"Alerts &\n * Notifications\"). Reference/UI-Platform: one surface per trigger.\n */\n hideTooltip?: boolean\n children: ReactNode\n panelClassName?: string\n}) {\n const [open, setOpen] = useState(false)\n const onOpenChangeRef = useRef(onOpenChange)\n onOpenChangeRef.current = onOpenChange\n useEffect(() => {\n onOpenChangeRef.current?.(open)\n if (!open) return\n setPanelOpenGlobal(true)\n return () => setPanelOpenGlobal(false)\n }, [open])\n const rootRef = useRef<HTMLDivElement | null>(null)\n const lastOpenTokenRef = useRef(openToken)\n\n // React to external open signals (skips the initial value on mount).\n useEffect(() => {\n if (openToken === undefined) return\n if (openToken === lastOpenTokenRef.current) return\n lastOpenTokenRef.current = openToken\n setOpen((v) => {\n if (!v) onOpen?.()\n return true\n })\n }, [openToken, onOpen])\n\n useEffect(() => {\n if (!open) return\n const onDocClick = (e: MouseEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) setOpen(false)\n }\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') setOpen(false)\n }\n document.addEventListener('mousedown', onDocClick)\n document.addEventListener('keydown', onKey)\n return () => {\n document.removeEventListener('mousedown', onDocClick)\n document.removeEventListener('keydown', onKey)\n }\n }, [open])\n\n return (\n <div ref={rootRef} className=\"relative\">\n <button\n type=\"button\"\n aria-label={label}\n aria-expanded={open}\n className={topBarIconButtonClass(tone)}\n onClick={() => {\n setOpen((v) => {\n const next = !v\n if (next) onOpen?.()\n return next\n })\n }}\n >\n <SlotGlyph slot={slot} fallback={fallbackIcon} />\n {typeof badge === 'number' ? <TopBarCountBadge count={badge} /> : null}\n {!open && !hideTooltip ? <TopBarTooltip title={label} description={description} /> : null}\n </button>\n {open ? (\n <div\n className={[\n 'absolute right-0 z-40 mt-2 rounded-xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] shadow-[var(--shadow-soft)]',\n panelClassName ?? 'w-80',\n ].join(' ')}\n >\n <TopBarPanelArrow />\n <div className=\"overflow-hidden rounded-xl\">{children}</div>\n </div>\n ) : null}\n </div>\n )\n}\n\n// Inline fallback glyphs (Feather-style paths) so the package needs no icon dep.\nfunction BatteryGlyph({ size = TOPBAR_GLYPH_SIZE, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <rect x=\"1\" y=\"6\" width=\"18\" height=\"12\" rx=\"2\" ry=\"2\" />\n <line x1=\"23\" y1=\"10\" x2=\"23\" y2=\"14\" />\n <line x1=\"5\" y1=\"10\" x2=\"5\" y2=\"14\" />\n <line x1=\"9\" y1=\"10\" x2=\"9\" y2=\"14\" />\n </svg>\n )\n}\n\nfunction BellGlyph({ size = TOPBAR_GLYPH_SIZE, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <path d=\"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9\" />\n <path d=\"M13.73 21a2 2 0 0 1-3.46 0\" />\n </svg>\n )\n}\n\nfunction BellOffGlyph({ size = 14, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <path d=\"M13.73 21a2 2 0 0 1-3.46 0\" />\n <path d=\"M18.63 13A17.9 17.9 0 0 1 18 8\" />\n <path d=\"M6.26 6.26A5.86 5.86 0 0 0 6 8c0 7-3 9-3 9h14\" />\n <path d=\"M18 8a6 6 0 0 0-9.33-5\" />\n <line x1=\"1\" y1=\"1\" x2=\"23\" y2=\"23\" />\n </svg>\n )\n}\n\nfunction LifeBuoyGlyph({ size = TOPBAR_GLYPH_SIZE, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <circle cx=\"12\" cy=\"12\" r=\"4\" />\n <line x1=\"4.93\" y1=\"4.93\" x2=\"9.17\" y2=\"9.17\" />\n <line x1=\"14.83\" y1=\"14.83\" x2=\"19.07\" y2=\"19.07\" />\n <line x1=\"14.83\" y1=\"9.17\" x2=\"19.07\" y2=\"4.93\" />\n <line x1=\"4.93\" y1=\"19.07\" x2=\"9.17\" y2=\"14.83\" />\n </svg>\n )\n}\n\nfunction LayoutGlyph({ size = TOPBAR_GLYPH_SIZE, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\" />\n <line x1=\"3\" y1=\"9\" x2=\"21\" y2=\"9\" />\n <line x1=\"9\" y1=\"21\" x2=\"9\" y2=\"9\" />\n </svg>\n )\n}\n\nfunction PlusGlyph({ size = 14, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\" />\n <line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\" />\n </svg>\n )\n}\n\nfunction XGlyph({ size = 14, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n )\n}\n\nfunction CheckGlyph({ size = 14, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <polyline points=\"20 6 9 17 4 12\" />\n </svg>\n )\n}\n\n// ---------------------------------------------------------------------------\n// FuelAction — Communications Fuel balance (battery glyph + popover meters).\n// ---------------------------------------------------------------------------\n\nconst LOW_FUEL_HINT_DISMISSED_KEY = 'politogy_low_fuel_hint_dismissed'\n\nfunction FuelRow({\n label,\n channel,\n loading,\n addHref,\n addLabel,\n}: {\n label: string\n channel: FuelChannelStatus | null\n loading: boolean\n /** Billing deep-link for the small \"+\" top-up button (omit to hide it). */\n addHref?: string\n addLabel?: string\n}) {\n const remaining = channel?.remainingUnits ?? 0\n const total = channel ? Math.max(channel.rawBalanceUnits, channel.remainingUnits) : 0\n const ratio = total > 0 ? Math.min(100, Math.max(0, (remaining / total) * 100)) : 0\n const low = channel?.lowFuel ?? false\n\n return (\n <div className=\"w-full\">\n <div className=\"mb-1 flex items-center justify-between gap-2\">\n <span className=\"text-xs font-semibold text-[color:var(--foreground)]\">{label}</span>\n <div className=\"flex items-center gap-2\">\n {loading ? (\n <ValueSkeleton className=\"h-3.5 w-14\" />\n ) : (\n <span\n className={[\n 'text-xs font-semibold tabular-nums',\n low ? 'text-[color:var(--chrome-danger)]' : 'text-[color:var(--muted)]',\n ].join(' ')}\n >\n {remaining.toLocaleString()} left\n </span>\n )}\n {addHref ? (\n <a\n href={addHref}\n aria-label={addLabel}\n className=\"flex h-5 w-5 items-center justify-center rounded-full border border-[color:var(--line)] text-[color:var(--muted)] transition hover:border-[color:var(--foreground)] hover:text-[color:var(--foreground)]\"\n >\n <PlusGlyph />\n </a>\n ) : null}\n </div>\n </div>\n <div className=\"h-1.5 w-full overflow-hidden rounded-full bg-[color:var(--panel)]\">\n {loading ? (\n <div className=\"h-full w-full animate-pulse bg-[color:var(--line)]\" />\n ) : (\n <div\n className={[\n 'h-full rounded-full transition-[width]',\n low ? 'bg-[color:var(--chrome-danger)]' : 'bg-[color:var(--color-ok,#00783B)]',\n ].join(' ')}\n style={{ width: `${ratio}%` }}\n />\n )}\n </div>\n </div>\n )\n}\n\n// Both the low-fuel nudge and the new-reply toast are wide (240-320px)\n// absolute bubbles anchored to adjacent top-bar icons (Fuel, then\n// Notifications). Anchored-right boxes expand LEFTWARD from their trigger,\n// so a wide toast under the (further-right) bell can reach back over the\n// (further-left) fuel icon's hint, same z-50 — whichever mounted later\n// painted on top and the fuel banner got cut off/hidden (reported on\n// contacts.politogyvrm.com, 2026-10-09). This tiny external store lets the\n// toast learn the hint's visibility without a shared provider, so it can\n// drop below it instead of overlapping: the banner always stacks above the\n// toast, never the other way round.\nlet lowFuelHintVisible = false\nconst lowFuelHintListeners = new Set<() => void>()\nfunction setLowFuelHintVisible(visible: boolean): void {\n if (lowFuelHintVisible === visible) return\n lowFuelHintVisible = visible\n lowFuelHintListeners.forEach((l) => l())\n}\nfunction subscribeLowFuelHintVisible(onChange: () => void): () => void {\n lowFuelHintListeners.add(onChange)\n return () => lowFuelHintListeners.delete(onChange)\n}\nfunction useLowFuelHintVisible(): boolean {\n // Server snapshot: the hint is client-only (sessionStorage), so SSR renders\n // without it. FuelAction reads this during the frame's server render.\n return useSyncExternalStore(\n subscribeLowFuelHintVisible,\n () => lowFuelHintVisible,\n () => false,\n )\n}\n// Height (card + arrow + gap) the toast must clear when the hint is also up.\nconst LOW_FUEL_HINT_CLEARANCE_PX = 96\n\n/**\n * The low-fuel nudge: a small bubble anchored below the fuel trigger (arrow up)\n * with a \"Buy More Fuel\" deep-link. Dismissible; the dismissal persists for the\n * session (sessionStorage) so it never re-appears until a fresh session — and\n * the flag clears once fuel is no longer low, so a later drain can nudge again.\n */\nfunction LowFuelHint({ lowFuel, orgId }: { lowFuel: boolean; orgId: string | null }) {\n const [dismissed, setDismissed] = useState<boolean>(() => {\n if (typeof window === 'undefined') return false\n try {\n return window.sessionStorage.getItem(LOW_FUEL_HINT_DISMISSED_KEY) === '1'\n } catch {\n return false\n }\n })\n\n useEffect(() => {\n if (lowFuel) return\n try {\n window.sessionStorage.removeItem(LOW_FUEL_HINT_DISMISSED_KEY)\n } catch {\n /* unavailable */\n }\n }, [lowFuel])\n\n // Yield to any open panel: the nudge is wider than its own trigger and the\n // panels are right-aligned, so it lands on top of whichever one is open\n // (measured on contacts: it covered the notifications panel's header).\n const panelOpen = useAnyTopBarPanelOpen()\n const showing = lowFuel && !dismissed && !panelOpen\n\n // Published so the new-reply toast (anchored to the adjacent Notifications\n // icon) can drop below this banner instead of racing it for the same\n // on-screen space. Effect, not inline: setting external-store state during\n // render is not allowed.\n useEffect(() => {\n setLowFuelHintVisible(showing)\n return () => setLowFuelHintVisible(false)\n }, [showing])\n\n if (!showing) return null\n\n const dismiss = () => {\n try {\n window.sessionStorage.setItem(LOW_FUEL_HINT_DISMISSED_KEY, '1')\n } catch {\n /* unavailable */\n }\n setDismissed(true)\n }\n\n return (\n <div\n role=\"status\"\n // z-[60]: one tier above the new-reply toast (z-50) so this banner is\n // never the one that gets covered when both are up at once.\n className=\"absolute right-0 top-[calc(100%+10px)] z-[60] w-60 rounded-lg border border-[color:var(--chrome-danger)] bg-[color:var(--chrome-danger)] px-3 py-2 text-[#FFFFFF] shadow-[var(--shadow-soft)]\"\n onClick={(e) => e.stopPropagation()}\n >\n {/* Arrow pointing up at the fuel button (mirrors TopBarPanelArrow's offset). */}\n <span\n aria-hidden\n className=\"absolute -top-[5px] right-[11px] h-2.5 w-2.5 rotate-45 bg-[color:var(--chrome-danger)]\"\n />\n <div className=\"flex items-start gap-2\">\n <div className=\"flex-1\">\n <p className=\"text-sm font-semibold\">You&rsquo;re low on fuel</p>\n <a\n href={withOrgParam(CORE_BILLING_URL, orgId)}\n className=\"mt-1 inline-block text-sm font-bold underline hover:opacity-90\"\n >\n Buy More Fuel\n </a>\n </div>\n <button\n type=\"button\"\n aria-label=\"Dismiss low fuel notice\"\n onClick={dismiss}\n className=\"flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[#FFFFFF]/90 transition hover:bg-[#FFFFFF]/20\"\n >\n <XGlyph />\n </button>\n </div>\n </div>\n )\n}\n\nexport function FuelAction({ orgId }: { orgId: string | null }) {\n const { dedupedFetch } = useNavChrome('FuelAction')\n const [fuel, setFuel] = useState<CommunicationsFuelStatus | null>(null)\n const [loading, setLoading] = useState(true)\n const [error, setError] = useState(false)\n\n useEffect(() => {\n let cancelled = false\n // No org yet: wait for it. A header-less read is a second request for\n // the same widget once the org resolves (twice per page load).\n if (!orgId) {\n setLoading(false)\n return\n }\n setLoading(true)\n setError(false)\n setFuel(null)\n dedupedFetch(\n 'communications/fuel-status',\n { headers: orgId ? { 'x-contacts-org': orgId } : undefined },\n { orgId },\n )\n .then((data) => {\n if (cancelled) return\n setFuel((data as { fuel?: CommunicationsFuelStatus | null })?.fuel ?? null)\n })\n .catch(() => {\n if (!cancelled) setError(true)\n })\n .finally(() => {\n if (!cancelled) setLoading(false)\n })\n return () => {\n cancelled = true\n }\n }, [dedupedFetch, orgId])\n\n const low = !!fuel && (fuel.signal.lowFuel || fuel.broadcast.lowFuel)\n // The low-fuel hint sits under this trigger; the tooltip yields to it.\n const lowFuelHintUp = useLowFuelHintVisible()\n\n return (\n // The nudge anchors to the trigger, so it sits OUTSIDE the popover panel in\n // its own relative wrapper (same shape the VRM widget used).\n <div className=\"relative inline-flex\">\n <TopBarPopover\n label=\"Communications Fuel\"\n description=\"Remaining SMS and email sending balance for the active organization.\"\n slot=\"comms-fuel\"\n fallbackIcon={BatteryGlyph}\n tone={low ? 'warning' : 'default'}\n hideTooltip={lowFuelHintUp}\n >\n <div className=\"px-4 py-3\">\n <p className=\"mb-3 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Communications Fuel\n </p>\n {error || (!loading && !fuel) ? (\n <p className=\"text-sm text-[color:var(--muted)]\">\n Fuel balance is unavailable right now.\n </p>\n ) : (\n <div className=\"flex flex-col gap-3\">\n <FuelRow\n label=\"SMS Signal\"\n channel={fuel?.signal ?? null}\n loading={loading}\n addHref={withOrgParam(CORE_BILLING_URL, orgId)}\n addLabel=\"Add SMS Signal fuel\"\n />\n <FuelRow\n label=\"Email Broadcast\"\n channel={fuel?.broadcast ?? null}\n loading={loading}\n addHref={withOrgParam(CORE_BILLING_URL, orgId)}\n addLabel=\"Add Email Broadcast fuel\"\n />\n </div>\n )}\n </div>\n </TopBarPopover>\n <LowFuelHint lowFuel={low} orgId={orgId} />\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// NotificationsAction — bell + count badge + alerts/replies popover.\n// ---------------------------------------------------------------------------\n\n/** Per-org read/seen state, persisted client-side (localStorage). */\ntype NotifState = {\n readAlertIds: string[]\n lastSeenAt: string | null\n /** Reply ids already surfaced as a toast, so none re-toasts (capped ~50). */\n toastedReplyIds: string[]\n}\n\nfunction notifStateKey(orgId: string | null): string {\n return `politogy_chrome_notif_state:${orgId ?? 'none'}`\n}\n\nfunction readNotifState(orgId: string | null): NotifState {\n const empty: NotifState = { readAlertIds: [], lastSeenAt: null, toastedReplyIds: [] }\n if (typeof window === 'undefined') return empty\n try {\n const raw = window.localStorage.getItem(notifStateKey(orgId))\n if (!raw) return empty\n const parsed = JSON.parse(raw) as Partial<NotifState>\n return {\n readAlertIds: Array.isArray(parsed?.readAlertIds)\n ? parsed.readAlertIds.filter((id): id is string => typeof id === 'string')\n : [],\n lastSeenAt: typeof parsed?.lastSeenAt === 'string' ? parsed.lastSeenAt : null,\n toastedReplyIds: Array.isArray(parsed?.toastedReplyIds)\n ? parsed.toastedReplyIds.filter((id): id is string => typeof id === 'string')\n : [],\n }\n } catch {\n return empty\n }\n}\n\nfunction writeNotifState(orgId: string | null, state: NotifState): void {\n if (typeof window === 'undefined') return\n try {\n window.localStorage.setItem(notifStateKey(orgId), JSON.stringify(state))\n } catch {\n /* unavailable */\n }\n}\n\n/**\n * Session-scoped mute for the rotating new-reply toasts. Session (not local)\n * storage on purpose: silencing is a \"not right now\" gesture, so a reload\n * restores the toasts rather than silently disabling them forever.\n */\nconst TOASTS_MUTED_KEY = 'politogy_chrome_toasts_muted'\n\nfunction readToastsMuted(): boolean {\n if (typeof window === 'undefined') return false\n try {\n return window.sessionStorage.getItem(TOASTS_MUTED_KEY) === '1'\n } catch {\n return false\n }\n}\n\nfunction writeToastsMuted(muted: boolean): void {\n if (typeof window === 'undefined') return\n try {\n if (muted) window.sessionStorage.setItem(TOASTS_MUTED_KEY, '1')\n else window.sessionStorage.removeItem(TOASTS_MUTED_KEY)\n } catch {\n /* unavailable */\n }\n}\n\n/** Format a raw phone into US (XXX) XXX-XXXX; leave anything else as-is. */\nfunction formatPhone(raw: string): string {\n const digits = raw.replace(/\\D/g, '')\n const ten = digits.length === 11 && digits.startsWith('1') ? digits.slice(1) : digits\n if (ten.length === 10) return `(${ten.slice(0, 3)}) ${ten.slice(3, 6)}-${ten.slice(6)}`\n return raw\n}\n\nfunction ImportRow({ imp }: { imp: ChromeNotificationImport }) {\n const pct = imp.percent == null ? null : Math.max(0, Math.min(100, imp.percent))\n return (\n <>\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"truncate text-sm text-[color:var(--foreground)]\">{imp.label}</span>\n {pct != null ? (\n <span className=\"shrink-0 text-xs tabular-nums text-[color:var(--muted)]\">\n {Math.round(pct)}%\n </span>\n ) : null}\n </div>\n {pct != null ? (\n <div className=\"mt-1 h-1 w-full overflow-hidden rounded-full bg-[color:var(--panel)]\">\n <div\n className=\"h-full rounded-full bg-[color:var(--color-accent)] transition-[width]\"\n style={{ width: `${pct}%` }}\n />\n </div>\n ) : null}\n </>\n )\n}\n\n/**\n * Transient \"new reply\" toast anchored below the bell. Dark bubble with an\n * up-arrow, sender + preview; auto-fades after ~12s; clicking activates it.\n * Mirrors VRM's NewTextBellPopup. Purely presentational — the parent owns which\n * reply shows and what a click does.\n */\nfunction NewReplyToast({\n reply,\n onActivate,\n onClose,\n onSilence,\n ttlMs = 12000,\n}: {\n reply: ChromeNotificationReply\n onActivate: () => void\n onClose: () => void\n onSilence: () => void\n ttlMs?: number\n}) {\n const [visible, setVisible] = useState(false)\n const onCloseRef = useRef(onClose)\n onCloseRef.current = onClose\n const lowFuelHintVisible = useLowFuelHintVisible()\n\n useEffect(() => {\n setVisible(true)\n const fadeAt = Math.max(0, ttlMs - 450)\n const t1 = window.setTimeout(() => setVisible(false), fadeAt)\n const t2 = window.setTimeout(() => onCloseRef.current(), ttlMs)\n return () => {\n window.clearTimeout(t1)\n window.clearTimeout(t2)\n }\n }, [ttlMs])\n\n const activate = () => {\n setVisible(false)\n onActivate()\n }\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n aria-label=\"Open new reply\"\n onClick={activate}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n activate()\n }\n }}\n // z-50, below the low-fuel banner's z-[60] — and when that banner is\n // up, pushed down past it so the two stack instead of overlapping\n // (see LOW_FUEL_HINT_CLEARANCE_PX; both bubbles are wide enough to\n // reach across the Fuel ↔ Notifications gap at these icon spacings).\n className=\"absolute right-[-6px] top-[calc(100%+12px)] z-50 min-w-[240px] max-w-[320px] cursor-pointer rounded-xl bg-[#161616] px-4 py-3 text-[#FFFFFF] shadow-[var(--shadow-soft)]\"\n style={{\n top: lowFuelHintVisible ? `calc(100% + 12px + ${LOW_FUEL_HINT_CLEARANCE_PX}px)` : undefined,\n opacity: visible ? 1 : 0,\n transform: visible ? 'translateY(0px)' : 'translateY(-4px)',\n transition: 'opacity 250ms ease, transform 250ms ease',\n }}\n >\n {/* Up-arrow pointing at the bell. */}\n <span\n aria-hidden\n className=\"absolute right-[18px] top-[-7px] h-0 w-0 border-x-[8px] border-x-transparent border-b-[8px] border-b-[#161616]\"\n />\n {/* Dismiss this ONE toast without navigating. The bubble itself is the\n activate target, so the close control has to stop propagation or\n \"get rid of it\" would mean \"open it\" (reported 2026-08-12). */}\n <button\n type=\"button\"\n aria-label=\"Dismiss notification\"\n onClick={(e) => {\n e.stopPropagation()\n setVisible(false)\n onClose()\n }}\n className=\"absolute right-2 top-2 flex h-5 w-5 items-center justify-center rounded-full text-[#FFFFFF] opacity-60 transition hover:bg-[#FFFFFF]/10 hover:opacity-100\"\n >\n <XGlyph size={12} />\n </button>\n <p className=\"truncate pr-6 text-sm font-semibold\">{reply.name}</p>\n <p className=\"mt-1 truncate text-xs opacity-85\">{reply.preview}</p>\n <button\n type=\"button\"\n onClick={(e) => {\n e.stopPropagation()\n setVisible(false)\n onSilence()\n }}\n className=\"mt-2 inline-flex items-center gap-1 text-[11px] font-semibold text-[#FFFFFF] opacity-60 transition hover:opacity-100\"\n >\n <BellOffGlyph size={12} />\n Silence notifications\n </button>\n </div>\n )\n}\n\nexport function NotificationsAction({ orgId }: { orgId: string | null }) {\n const { dedupedFetch, notificationsAdapter } = useNavChrome('NotificationsAction')\n const [payload, setPayload] = useState<ChromeNotificationsPayload | null>(null)\n const [loading, setLoading] = useState(true)\n const [error, setError] = useState(false)\n const [notif, setNotif] = useState<NotifState>(() => readNotifState(orgId))\n const [toastReply, setToastReply] = useState<ChromeNotificationReply | null>(null)\n const [toastsMuted, setToastsMuted] = useState<boolean>(() => readToastsMuted())\n const [openToken, setOpenToken] = useState(0)\n const [panelOpen, setPanelOpen] = useState(false)\n // Bumped after a server write (adapter path) to re-read the feed and badge.\n const [reloadToken, setReloadToken] = useState(0)\n // Also yield to a panel opened from a NEIGHBOURING trigger — the fuel panel\n // is right-aligned and wide enough to sit under the bell.\n const anyPanelOpen = useAnyTopBarPanelOpen()\n\n // Re-hydrate the read/seen watermark whenever the active org changes.\n useEffect(() => {\n setNotif(readNotifState(orgId))\n setToastReply(null)\n }, [orgId])\n\n useEffect(() => {\n let cancelled = false\n // No org yet: wait for it. A header-less read is a second request for\n // the same widget once the org resolves (twice per page load).\n if (!orgId) {\n setLoading(false)\n return\n }\n if (notificationsAdapter) {\n // Comms feed. Never rejects: a missing session or absent route is an\n // empty bell, not an error state.\n setError(false)\n notificationsAdapter\n .list(orgId)\n .then((feed) => {\n if (!cancelled) setPayload(notificationsFeedToPayload(feed, orgId) as ChromeNotificationsPayload)\n })\n .catch(() => {\n if (!cancelled) setPayload(notificationsFeedToPayload(emptyNotificationsFeed(), orgId) as ChromeNotificationsPayload)\n })\n .finally(() => {\n if (!cancelled) setLoading(false)\n })\n return () => {\n cancelled = true\n }\n }\n setLoading(true)\n setError(false)\n setPayload(null)\n dedupedFetch(\n 'notifications',\n { headers: orgId ? { 'x-contacts-org': orgId } : undefined },\n { orgId },\n )\n .then((data) => {\n if (!cancelled) setPayload(data as ChromeNotificationsPayload)\n })\n .catch(() => {\n if (!cancelled) setError(true)\n })\n .finally(() => {\n if (!cancelled) setLoading(false)\n })\n return () => {\n cancelled = true\n }\n }, [dedupedFetch, notificationsAdapter, orgId, reloadToken])\n\n // 10DLC registration alert: surfaced only in the notifications panel/badge\n // (unread state). No auto-redirect — see Decisions in PR for feat/spec-overlay.\n\n const markRead = useCallback(\n (id: string) => {\n // Adapter feeds persist read state on the server, then re-read the feed\n // so the row and the badge reflect it. A failed write is simply a no-op.\n if (notificationsAdapter) {\n void notificationsAdapter.markRead(id).then((ok) => {\n if (ok) setReloadToken((t) => t + 1)\n })\n }\n setNotif((prev) => {\n if (prev.readAlertIds.includes(id)) return prev\n const next = { ...prev, readAlertIds: [...prev.readAlertIds, id] }\n writeNotifState(orgId, next)\n return next\n })\n },\n [orgId, notificationsAdapter],\n )\n\n const markUnread = useCallback(\n (id: string) => {\n setNotif((prev) => {\n if (!prev.readAlertIds.includes(id)) return prev\n const next = { ...prev, readAlertIds: prev.readAlertIds.filter((x) => x !== id) }\n writeNotifState(orgId, next)\n return next\n })\n },\n [orgId],\n )\n\n // Opening the panel advances the \"last seen\" watermark (replies are seen).\n const onOpen = useCallback(() => {\n // The panel shows the reply the toast was previewing, so the toast has\n // nothing left to say — retire it rather than let it cover the panel.\n setToastReply(null)\n setNotif((prev) => {\n const next = { ...prev, lastSeenAt: new Date().toISOString() }\n writeNotifState(orgId, next)\n return next\n })\n }, [orgId])\n\n const alerts = payload?.alerts ?? []\n const replies = payload?.replies ?? []\n const imports = payload?.imports ?? []\n const quarantined = payload?.quarantined ?? []\n\n // New-reply toast: surface the newest reply that is (a) newer than the seen\n // watermark and (b) not already toasted this org. One at a time; the id is\n // recorded so a re-render / re-fetch never re-toasts it (capped at 50).\n useEffect(() => {\n // Silenced for this session — surface nothing new (the badge still counts).\n if (toastsMuted) return\n if (!payload || toastReply || panelOpen) return\n const candidate = replies\n .filter((r) => {\n if (!r.createdAt) return false\n if (notif.lastSeenAt && r.createdAt <= notif.lastSeenAt) return false\n return !notif.toastedReplyIds.includes(r.id)\n })\n .sort((a, b) => (a.createdAt! < b.createdAt! ? 1 : -1))[0]\n if (!candidate) return\n setToastReply(candidate)\n setNotif((prev) => {\n const next = {\n ...prev,\n toastedReplyIds: [candidate.id, ...prev.toastedReplyIds].slice(0, 50),\n }\n writeNotifState(orgId, next)\n return next\n })\n }, [\n payload,\n replies,\n toastReply,\n panelOpen,\n toastsMuted,\n notif.lastSeenAt,\n notif.toastedReplyIds,\n orgId,\n ])\n\n // Toast click: navigate to the reply's href when it carries one; otherwise\n // open the notifications panel (which also advances the seen watermark).\n const setMuted = useCallback((muted: boolean) => {\n writeToastsMuted(muted)\n setToastsMuted(muted)\n }, [])\n\n const onToastSilence = useCallback(() => {\n setMuted(true)\n setToastReply(null)\n }, [setMuted])\n\n const onToastActivate = useCallback(() => {\n const href = toastReply?.href\n setToastReply(null)\n if (href && typeof window !== 'undefined') {\n window.location.assign(href)\n return\n }\n setOpenToken((t) => t + 1)\n }, [toastReply])\n\n // Badge: UNREAD alerts + replies newer than the last-seen watermark. A reply\n // with no timestamp counts before the first open, then is treated as seen.\n const isAlertRead = (a: ChromeNotificationAlert) => a.read === true || notif.readAlertIds.includes(a.id)\n const unreadAlertCount = alerts.filter((a) => !isAlertRead(a)).length\n const unseenReplyCount = replies.filter((r) => {\n if (!notif.lastSeenAt) return true\n if (!r.createdAt) return false\n return r.createdAt > notif.lastSeenAt\n }).length\n // Adapter feeds carry the server's one badge number (unread notifications\n // plus unresolved alerts); the local count is the legacy contacts path only.\n const badgeCount =\n notificationsAdapter && payload?.badge !== undefined\n ? payload.badge\n : unreadAlertCount + unseenReplyCount\n\n const isEmpty =\n alerts.length === 0 && replies.length === 0 && imports.length === 0 && quarantined.length === 0\n\n // The toast yields to any open panel (this one or a neighbour's), and while\n // it is up the bell's hover tooltip yields to it - one surface per trigger.\n const toastVisible = toastReply !== null && !panelOpen && !anyPanelOpen\n\n return (\n // Relative wrapper so the new-reply toast anchors to the bell trigger,\n // outside the popover panel (same pattern as the fuel low-fuel nudge).\n <div className=\"relative inline-flex\">\n <TopBarPopover\n label=\"Alerts & Notifications\"\n description=\"System alerts and recent activity for the active organization.\"\n slot=\"notifications\"\n fallbackIcon={BellGlyph}\n badge={loading ? 0 : badgeCount}\n onOpen={onOpen}\n openToken={openToken}\n onOpenChange={setPanelOpen}\n hideTooltip={toastVisible}\n >\n <div className=\"px-4 py-3\">\n <div className=\"mb-2 flex items-center justify-between gap-2\">\n <p className=\"text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Notifications\n </p>\n {/* Only shown once silenced — the way back, in the same session. */}\n {toastsMuted ? (\n <button\n type=\"button\"\n onClick={() => setMuted(false)}\n className=\"text-[11px] font-semibold text-[color:var(--color-accent-fg,var(--color-accent))] hover:underline\"\n >\n Unsilence\n </button>\n ) : null}\n </div>\n {loading ? (\n <div className=\"flex flex-col gap-2 py-1\">\n <ValueSkeleton className=\"h-4 w-full\" />\n <ValueSkeleton className=\"h-4 w-3/4\" />\n </div>\n ) : error ? (\n <p className=\"text-sm text-[color:var(--muted)]\">\n Notifications are unavailable right now.\n </p>\n ) : isEmpty ? (\n <p className=\"py-1 text-sm text-[color:var(--muted)]\">You&rsquo;re all caught up.</p>\n ) : (\n <div className=\"flex max-h-80 flex-col gap-2 overflow-y-auto\">\n {/* Alerts (with per-item read toggle) + replies — unchanged order. */}\n {alerts.length > 0 || replies.length > 0 ? (\n <ul className=\"flex flex-col gap-1\">\n {alerts.map((a) => {\n const isRead = isAlertRead(a)\n return (\n <li key={a.id} className={isRead ? 'opacity-50' : undefined}>\n <div className=\"flex items-start gap-1 rounded-lg px-2 py-2 hover:bg-[color:var(--panel)]\">\n <a\n href={a.href ?? '#'}\n onClick={() => markRead(a.id)}\n className=\"block min-w-0 flex-1\"\n >\n <p className=\"text-sm font-semibold text-[color:var(--foreground)]\">\n {a.title}\n </p>\n <p className=\"text-xs text-[color:var(--muted)]\">{a.description}</p>\n </a>\n <button\n type=\"button\"\n aria-label={isRead ? 'Mark as unread' : 'Mark as read'}\n onClick={() => (isRead && !notificationsAdapter ? markUnread(a.id) : markRead(a.id))}\n className=\"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[color:var(--muted)] transition hover:bg-[color:var(--panel-elevated)] hover:text-[color:var(--foreground)]\"\n >\n <CheckGlyph />\n </button>\n </div>\n </li>\n )\n })}\n {/* A reply row is a REAL link when it carries a deep-link, so\n the hover highlight leads somewhere: the conversation the\n reply arrived in (reported 2026-08-12). Rows without an\n href stay inert rather than pretending to be clickable. */}\n {replies.map((r) => {\n const body = (\n <>\n <p className=\"text-sm font-semibold text-[color:var(--foreground)]\">\n {r.name}\n </p>\n <p className=\"truncate text-xs text-[color:var(--muted)]\">{r.preview}</p>\n </>\n )\n return (\n <li key={r.id}>\n {r.href ? (\n <a\n href={r.href}\n aria-label={`Open the conversation with ${r.name}`}\n className=\"block rounded-lg px-2 py-2 transition hover:bg-[color:var(--panel)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--color-accent)]\"\n >\n {body}\n </a>\n ) : (\n <div className=\"rounded-lg px-2 py-2\">{body}</div>\n )}\n </li>\n )\n })}\n </ul>\n ) : null}\n\n {/* Imports — running/finished contact imports. */}\n {imports.length > 0 ? (\n <div>\n <p className=\"mb-1 px-2 text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Imports\n </p>\n <ul className=\"flex flex-col gap-1\">\n {imports.map((imp) => (\n <li key={imp.id} className=\"rounded-lg px-2 py-2 hover:bg-[color:var(--panel)]\">\n {imp.href ? (\n <a href={imp.href} className=\"block\">\n <ImportRow imp={imp} />\n </a>\n ) : (\n <ImportRow imp={imp} />\n )}\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n\n {/* Quarantined contact clusters. */}\n {quarantined.length > 0 ? (\n <div>\n <div className=\"mb-1 flex items-center justify-between px-2\">\n <p className=\"text-[11px] font-semibold uppercase tracking-[0.08em] text-[color:var(--muted)]\">\n Quarantined Contacts\n </p>\n <a\n href={withOrgParam(QUARANTINED_CONTACTS_URL, orgId)}\n className=\"text-[11px] font-semibold text-[color:var(--color-accent-fg,var(--color-accent))] hover:underline\"\n >\n View all\n </a>\n </div>\n <ul className=\"flex flex-col gap-1\">\n {/* Each row is a REAL link, not a div with a hover class. It\n used to carry a hover highlight on a non-interactive <li>,\n so the row advertised interactivity and then did nothing\n when clicked (reported 2026-08-03). An affordance has to\n lead somewhere: the row opens the quarantined-contacts\n view filtered to that number — the same destination as\n \"View all\", scoped. Being an <a> makes it keyboard\n focusable and Enter-activatable for free. */}\n {quarantined.map((q) => (\n <li key={q.phone}>\n <a\n href={withPhoneParam(withOrgParam(QUARANTINED_CONTACTS_URL, orgId), q.phone)}\n aria-label={`Review ${q.count} quarantined message${q.count === 1 ? '' : 's'} from ${formatPhone(q.phone)}`}\n className=\"block rounded-lg px-2 py-2 transition hover:bg-[color:var(--nav-row-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[color:var(--color-accent)]\"\n >\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"text-sm font-semibold text-[color:var(--foreground)]\">\n {formatPhone(q.phone)}\n </span>\n {/* Same geometry as the shared TopBarCountBadge (16px\n circle, 10px/400, px-1); it sits in flow rather\n than absolutely on a 32px trigger, because this is\n a list row and not a top-bar icon. */}\n <span className=\"flex h-4 min-w-4 items-center justify-center rounded-full bg-[color:var(--panel)] px-1 text-[10px] font-normal leading-none tabular-nums text-[color:var(--muted)]\">\n {q.count > 99 ? '99+' : q.count}\n </span>\n </div>\n {q.latestAt ? (\n <p className=\"text-xs text-[color:var(--muted)]\">\n {new Date(q.latestAt).toLocaleString()}\n </p>\n ) : null}\n </a>\n </li>\n ))}\n </ul>\n </div>\n ) : null}\n </div>\n )}\n </div>\n </TopBarPopover>\n {/* Only ONE surface at this anchor at a time: the toast yields to the panel\n (both hang off the bell trigger, so rendering both means the toast sits\n on the panel's header — Reference/UI-Platform, one surface per trigger). */}\n {toastVisible && toastReply ? (\n <NewReplyToast\n reply={toastReply}\n onActivate={onToastActivate}\n onClose={() => setToastReply(null)}\n onSilence={onToastSilence}\n />\n ) : null}\n </div>\n )\n}\n\n// ---------------------------------------------------------------------------\n// SupportAction — life-buoy trigger + the shared support-request modal\n// (never a mailto:, never an app-local form — Reference/UI-Platform).\n// ---------------------------------------------------------------------------\n\n/**\n * Compose the delivered support message: the user's note, then a context block\n * carrying the page, URL and active org — plus a Reply-to line when the user\n * had to supply contact details the profile was missing. The upstream contract\n * stays `POST support { message }`; this just enriches the text (VRM parity).\n */\nfunction composeSupportMessage(input: {\n note: string\n pageTitle: string\n url: string\n orgName?: string | null\n replyEmail?: string\n replyPhone?: string\n}): string {\n const ctx = [`Page: ${input.pageTitle || 'Unknown'}`, `URL: ${input.url}`]\n if (input.orgName) ctx.push(`Org: ${input.orgName}`)\n const reply = [input.replyEmail?.trim(), input.replyPhone?.trim()].filter(Boolean).join(' / ')\n if (reply) ctx.push(`Reply-to: ${reply}`)\n return `${input.note.trim()}\\n\\n---\\n${ctx.join('\\n')}`\n}\n\nexport function SupportAction({\n orgId,\n orgs: knownOrgs,\n}: { orgId?: string | null; orgs?: { id: string; name: string | null }[] } = {}) {\n const { fetchJson } = useNavChrome('SupportAction')\n const { me, loaded } = useChromeMe()\n // A caller that already holds the org list skips the chrome `/api/orgs` call.\n const { orgs: fetchedOrgs } = useChromeOrgs({ enabled: !knownOrgs })\n const orgs = knownOrgs ?? fetchedOrgs\n const [open, setOpen] = useState(false)\n const [message, setMessage] = useState('')\n const [email, setEmail] = useState('')\n const [phone, setPhone] = useState('')\n const [showEmailError, setShowEmailError] = useState(false)\n const [state, setState] = useState<'idle' | 'sending' | 'sent' | 'error'>('idle')\n\n // The profile knows email/phone unless the chrome `me` loaded without them —\n // then we collect the missing one(s) in the modal (email required, phone not).\n const meEmail = me?.email ?? null\n const mePhone = me?.phone ?? null\n const missingEmail = loaded && !meEmail\n const missingPhone = loaded && !mePhone\n\n const activeOrg =\n (orgId ? orgs?.find((o) => o.id === orgId) : null) ??\n (orgs && orgs.length === 1 ? orgs[0] : null)\n const orgName = activeOrg?.name ?? null\n\n const close = useCallback(() => {\n setOpen(false)\n setState('idle')\n setMessage('')\n setShowEmailError(false)\n }, [])\n\n // Seed the contact inputs from the profile whenever the modal opens.\n useEffect(() => {\n if (!open) return\n setEmail(meEmail ?? '')\n setPhone(mePhone ?? '')\n setShowEmailError(false)\n }, [open, meEmail, mePhone])\n\n useEffect(() => {\n if (!open) return\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') close()\n }\n document.addEventListener('keydown', onKey)\n return () => document.removeEventListener('keydown', onKey)\n }, [open, close])\n\n const submit = async () => {\n if (!message.trim() || state === 'sending') return\n\n const resolvedEmail = (missingEmail ? email : meEmail ?? '').trim()\n const resolvedPhone = (missingPhone ? phone : mePhone ?? '').trim()\n // Email is required when the profile didn't carry one.\n if (missingEmail && !resolvedEmail) {\n setShowEmailError(true)\n return\n }\n setShowEmailError(false)\n\n const collectedContact = missingEmail || missingPhone\n const fullMessage = composeSupportMessage({\n note: message,\n pageTitle: typeof document !== 'undefined' ? document.title : '',\n url: typeof window !== 'undefined' ? window.location.href : '',\n orgName,\n replyEmail: collectedContact ? resolvedEmail : undefined,\n replyPhone: collectedContact ? resolvedPhone : undefined,\n })\n\n setState('sending')\n try {\n await fetchJson('support', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ message: fullMessage }),\n })\n setState('sent')\n } catch {\n setState('error')\n }\n }\n\n return (\n <>\n <button\n type=\"button\"\n aria-label=\"Support\"\n className={topBarIconButtonClass()}\n onClick={() => setOpen(true)}\n >\n <SlotGlyph slot=\"support\" fallback={LifeBuoyGlyph} />\n <TopBarTooltip\n title=\"Support\"\n description=\"Send a support request to the Politogy team.\"\n />\n </button>\n {open && typeof document !== 'undefined'\n ? createPortal(\n <div\n // Portaled to <body>: the top bar's backdrop-blur creates a CSS\n // containing block, so a fixed-position descendant would center on\n // the HEADER (rendering off-screen) instead of the viewport.\n className=\"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4\"\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Support request\"\n onMouseDown={(e) => {\n if (e.target === e.currentTarget) close()\n }}\n >\n <div className=\"w-full max-w-md rounded-2xl border border-[color:var(--line)] bg-[color:var(--panel-elevated)] p-6 shadow-[var(--shadow-soft)]\">\n <h2 className=\"text-lg font-bold tracking-[-0.01em] text-[color:var(--foreground)]\">\n Contact Support\n </h2>\n {state === 'sent' ? (\n <>\n <p className=\"mt-3 text-sm text-[color:var(--muted)]\">\n Your request was sent. The team will reply by email.\n </p>\n <div className=\"mt-5 flex justify-end\">\n <button\n type=\"button\"\n onClick={close}\n className=\"rounded-full bg-[color:var(--color-accent-bg-safe,var(--color-accent))] px-4 py-2 text-sm font-semibold text-[#FFFFFF] hover:opacity-90\"\n >\n Done\n </button>\n </div>\n </>\n ) : (\n <>\n <p className=\"mt-1 text-sm text-[color:var(--muted)]\">\n Describe the problem or question. Your account details ride along\n automatically.\n </p>\n {missingEmail ? (\n <label className=\"mt-4 block\">\n <span className=\"mb-1 block text-xs font-semibold text-[color:var(--foreground)]\">\n Your email\n </span>\n <input\n type=\"email\"\n value={email}\n onChange={(e) => setEmail(e.target.value)}\n placeholder=\"you@example.com\"\n className=\"w-full rounded-lg border border-[color:var(--line)] bg-[color:var(--panel)] px-3 py-2 text-sm text-[color:var(--foreground)] placeholder:text-[color:var(--muted)] focus:outline-none focus:ring-2 focus:ring-[color:var(--color-accent)]\"\n />\n {showEmailError ? (\n <span className=\"mt-1 block text-xs text-[color:var(--chrome-danger)]\">\n Enter an email so support can reply.\n </span>\n ) : null}\n </label>\n ) : null}\n {missingPhone ? (\n <label className=\"mt-3 block\">\n <span className=\"mb-1 block text-xs font-semibold text-[color:var(--foreground)]\">\n Your phone — optional\n </span>\n <input\n type=\"tel\"\n value={phone}\n onChange={(e) => setPhone(e.target.value)}\n placeholder=\"(503) 555-1212\"\n className=\"w-full rounded-lg border border-[color:var(--line)] bg-[color:var(--panel)] px-3 py-2 text-sm text-[color:var(--foreground)] placeholder:text-[color:var(--muted)] focus:outline-none focus:ring-2 focus:ring-[color:var(--color-accent)]\"\n />\n </label>\n ) : null}\n <textarea\n value={message}\n onChange={(e) => setMessage(e.target.value)}\n rows={5}\n placeholder=\"How can we help?\"\n className=\"mt-4 w-full resize-y rounded-lg border border-[color:var(--line)] bg-[color:var(--panel)] px-3 py-2 text-sm text-[color:var(--foreground)] placeholder:text-[color:var(--muted)] focus:outline-none focus:ring-2 focus:ring-[color:var(--color-accent)]\"\n />\n {state === 'error' ? (\n <p className=\"mt-2 text-sm text-[color:var(--chrome-danger)]\">\n Sending failed — try again.\n </p>\n ) : null}\n <div className=\"mt-4 flex justify-end gap-2\">\n <button\n type=\"button\"\n onClick={close}\n className=\"rounded-full border border-[color:var(--line)] px-4 py-2 text-sm font-semibold text-[color:var(--foreground)] hover:bg-[color:var(--panel)]\"\n >\n Cancel\n </button>\n <button\n type=\"button\"\n onClick={submit}\n disabled={!message.trim() || state === 'sending'}\n className=\"rounded-full bg-[color:var(--color-accent-bg-safe,var(--color-accent))] px-4 py-2 text-sm font-semibold text-[#FFFFFF] transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50\"\n >\n {state === 'sending' ? 'Sending…' : 'Send request'}\n </button>\n </div>\n </>\n )}\n </div>\n </div>,\n document.body,\n )\n : null}\n </>\n )\n}\n\n// ---------------------------------------------------------------------------\n// SpecOverlayAction — Spencer + Ben only. A top-bar \"Spec\" trigger showing\n// the current page's spec compliance / visual-regression status, from the\n// Specs app's overlay API. Renders NOTHING when the viewer isn't allowed —\n// no icon, no badge, no console noise — so this is invisible to every other\n// user. All calls are plain cross-origin fetches with same-site cookies\n// (credentials: 'include'); this does NOT go through the chrome proxy\n// fetchJson, which is same-origin only.\n// ---------------------------------------------------------------------------\n\ntype SpecOverlayAccess = { allowed: boolean; email?: string }\n\ntype SpecOverlayStatus =\n | {\n matched: true\n spec_slug: string\n spec_title: string\n target_id: string\n label: string\n viewport: string\n /** null when there is no finished compare run yet — never coerce to 0. */\n mismatch_pct: number | null\n finished_at: string | null\n passed: boolean | null\n spec_url: string\n compare_url: string\n overlay_url: string\n live_selector?: string | null\n capture_url?: string\n theme?: 'light' | 'dark' | null\n live_source?: 'worker' | 'viewer' | null\n live_size?: { width: number; height: number } | null\n design_size?: { width: number; height: number } | null\n /** Ready-to-paste repair prompt for an AI agent (latest run). */\n prompt?: string | null\n }\n | { matched: false; search_url: string }\n\nconst SPEC_OVERLAY_ACCESS_CACHE_KEY = 'politogy_spec_overlay_access'\n\nfunction readSpecOverlayAccessCache(): SpecOverlayAccess | null {\n if (typeof window === 'undefined') return null\n try {\n const raw = window.sessionStorage.getItem(SPEC_OVERLAY_ACCESS_CACHE_KEY)\n if (!raw) return null\n const parsed = JSON.parse(raw)\n if (typeof parsed?.allowed === 'boolean') return parsed as SpecOverlayAccess\n } catch {\n /* ignore */\n }\n return null\n}\n\nfunction writeSpecOverlayAccessCache(access: SpecOverlayAccess): void {\n if (typeof window === 'undefined') return\n try {\n window.sessionStorage.setItem(SPEC_OVERLAY_ACCESS_CACHE_KEY, JSON.stringify(access))\n } catch {\n /* ignore */\n }\n}\n\n/**\n * Notifies subscribers whenever the URL changes via pushState, replaceState\n * or a back/forward navigation. Patches `history` exactly once per page\n * (module-level guard) no matter how many components subscribe.\n */\ntype LocationChangeListener = () => void\nconst locationChangeListeners = new Set<LocationChangeListener>()\nlet historyPatched = false\n\nfunction ensureHistoryPatched(): void {\n if (historyPatched || typeof window === 'undefined') return\n historyPatched = true\n const notify = () => locationChangeListeners.forEach((fn) => fn())\n const originalPushState = window.history.pushState.bind(window.history)\n const originalReplaceState = window.history.replaceState.bind(window.history)\n window.history.pushState = (...args: Parameters<History['pushState']>) => {\n originalPushState(...args)\n notify()\n }\n window.history.replaceState = (...args: Parameters<History['replaceState']>) => {\n originalReplaceState(...args)\n notify()\n }\n window.addEventListener('popstate', notify)\n}\n\nfunction useLocationHref(): string {\n const [href, setHref] = useState(() =>\n typeof window === 'undefined' ? '' : window.location.href,\n )\n useEffect(() => {\n ensureHistoryPatched()\n const onChange = () => setHref(window.location.href)\n locationChangeListeners.add(onChange)\n return () => {\n locationChangeListeners.delete(onChange)\n }\n }, [])\n return href\n}\n\nfunction specOverlayFetchJson(path: string): Promise<unknown> {\n // Bounded: this hits a cross-origin app (specs.politogyvrm.com) from every\n // page's top bar. An unbounded call here let a stuck access/status check\n // keep the page's network alive indefinitely — which blocks `networkidle`\n // and tripped visual-regression captures' own 45s navigation timeout on\n // the very pages this widget instruments (seen on a2p 2026-10-02).\n return fetch(`${SPECS_ORIGIN}${path}`, { credentials: 'include', signal: AbortSignal.timeout(10_000) }).then((res) => {\n if (!res.ok) throw new Error(`spec overlay ${path}: ${res.status}`)\n return res.json()\n })\n}\n\n/**\n * True when this page is being driven by an automated capture session\n * (Cloudflare Browser Rendering / CDP-controlled Chromium — the Specs\n * design-compare tool, among others) rather than a real Spencer/Ben\n * session. `navigator.webdriver` is the standard CDP automation flag.\n * SpecOverlayAction must never self-trigger a capture loop in this case:\n * doing so competed with the very capture session rendering the page for\n * network activity, keeping `networkidle` from ever being reached.\n */\nfunction isAutomatedCaptureSession(): boolean {\n return typeof navigator !== 'undefined' && navigator.webdriver === true\n}\n\nfunction currentChromeTheme(): 'light' | 'dark' {\n const root = document.documentElement\n if (root.classList.contains('dark') || root.getAttribute('data-theme') === 'dark') return 'dark'\n if (root.classList.contains('light') || root.getAttribute('data-theme') === 'light') return 'light'\n return 'light'\n}\n\n/** Marks the drawer portal so the page raster leaves it out. */\nconst SPEC_OVERLAY_ROOT_ATTR = 'data-spec-overlay-root'\n\n/**\n * The viewer's real view: rasterize THIS page in the browser (DOM → canvas,\n * no permission prompt) at viewport size, without the Spec drawer, and send it\n * to Specs as the LIVE side of a compare. Their org, data and theme are\n * exactly what is on screen, cropped to the content region. Nothing but the PNG\n * and page facts leaves the browser.\n */\nasync function captureMyView(\n status: Extract<SpecOverlayStatus, { matched: true }>,\n orgId: string | null | undefined,\n orgName: string | null | undefined,\n): Promise<void> {\n const { domToCanvas } = await import('modern-screenshot')\n const w = window.innerWidth\n const h = window.innerHeight\n const theme = currentChromeTheme()\n const bg = getComputedStyle(document.body).backgroundColor || (theme === 'dark' ? '#0b0b0c' : '#ffffff')\n const full = await domToCanvas(document.body, {\n width: w,\n height: h,\n scale: 1,\n backgroundColor: bg,\n // Cross-origin images that refuse CORS render blank instead of failing.\n fetch: { requestInit: { mode: 'cors', credentials: 'omit' }, placeholderImage: '' },\n // Drop the Spec drawer and everything fixed (sidebar, toasts, popovers):\n // the design is the page body only, so chrome would only add noise.\n filter: (node) =>\n !(node instanceof Element) ||\n (!node.hasAttribute(SPEC_OVERLAY_ROOT_ATTR) && getComputedStyle(node).position !== 'fixed'),\n style: { transform: `translate(${-window.scrollX}px, ${-window.scrollY}px)` },\n })\n\n // Score the content region only — the target's live_selector, else the\n // shell's content column (below the top bar and beta banner, right of the\n // sidebar) — so LIVE covers the same region as the design export.\n const el =\n (status.live_selector ? document.querySelector(status.live_selector) : null) ??\n document.querySelector('[data-shell-content]')\n let region = { x: 0, y: 0, width: w, height: h }\n if (el) {\n const r = el.getBoundingClientRect()\n const x = Math.max(0, Math.round(r.left))\n const y = Math.max(0, Math.round(r.top))\n region = { x, y, width: Math.min(w - x, Math.round(r.width)), height: Math.min(h - y, Math.round(r.height)) }\n }\n const out = document.createElement('canvas')\n out.width = region.width\n out.height = region.height\n const ctx = out.getContext('2d')\n if (!ctx) throw new Error('page raster failed')\n ctx.drawImage(full, region.x, region.y, region.width, region.height, 0, 0, region.width, region.height)\n const blob = await new Promise<Blob | null>((resolve) => out.toBlob(resolve, 'image/png'))\n if (!blob) throw new Error('page raster failed')\n const form = new FormData()\n form.append('image', blob, 'live.png')\n form.append(\n 'meta',\n JSON.stringify({ url: window.location.href, theme, org_id: orgId ?? null, org_name: orgName ?? null, crop: null }),\n )\n const res = await fetch(status.capture_url ?? `${SPECS_ORIGIN}/api/overlay/capture`, {\n method: 'POST',\n credentials: 'include',\n headers: { 'X-Spec-Capture': '1' },\n body: form,\n signal: AbortSignal.timeout(10_000),\n })\n if (!res.ok) throw new Error(`capture ${res.status}: ${(await res.text()).slice(0, 160)}`)\n}\n\n/** Spinner + LIVE/DIFF skeletons shown while the capture and compare run. */\nexport function SpecCaptureLoading() {\n return (\n <div data-spec-capture-loading=\"\" role=\"status\" aria-live=\"polite\" className=\"flex-1 overflow-hidden px-4 py-4\">\n <div className=\"mb-4 flex items-center gap-3 text-sm text-[color:var(--foreground)]\">\n <span\n aria-hidden=\"true\"\n className=\"inline-block h-5 w-5 animate-spin rounded-full border-2 border-[color:var(--line)] border-t-[color:var(--color-accent)] motion-reduce:animate-none\"\n />\n Capturing your view and comparing…\n </div>\n {['Live — your view', 'Diff'].map((label) => (\n <div key={label} className=\"mb-4\">\n <p className=\"mb-1 text-xs font-semibold uppercase tracking-wide text-[color:var(--muted)]\">{label}</p>\n <div aria-hidden=\"true\" className=\"h-40 w-full animate-pulse rounded border border-[color:var(--line)] bg-[color:var(--panel)] motion-reduce:animate-none\" />\n </div>\n ))}\n </div>\n )\n}\n\n/** Status URL for this page in the viewer's current theme. */\nfunction specOverlayStatusPath(): string {\n return `/api/overlay/status?url=${encodeURIComponent(window.location.href)}&theme=${currentChromeTheme()}`\n}\n\nexport function SpecOverlayAction({ orgId, orgName }: { orgId?: string | null; orgName?: string | null } = {}) {\n const [access, setAccess] = useState<SpecOverlayAccess | null>(() => readSpecOverlayAccessCache())\n const [status, setStatus] = useState<SpecOverlayStatus | null>(null)\n const [open, setOpen] = useState(false)\n const [capture, setCapture] = useState<{ state: 'idle' | 'busy' | 'error'; message?: string }>({ state: 'idle' })\n const [frameKey, setFrameKey] = useState(0)\n const [copied, setCopied] = useState<'idle' | 'copied' | 'failed'>('idle')\n const href = useLocationHref()\n const automated = isAutomatedCaptureSession()\n\n // Resolve access once per session (cached in sessionStorage).\n useEffect(() => {\n if (access || automated) return\n let cancelled = false\n specOverlayFetchJson('/api/overlay/access')\n .then((data) => {\n if (cancelled) return\n const next: SpecOverlayAccess =\n data && typeof (data as SpecOverlayAccess).allowed === 'boolean'\n ? (data as SpecOverlayAccess)\n : { allowed: false }\n setAccess(next)\n writeSpecOverlayAccessCache(next)\n })\n .catch(() => {\n if (cancelled) return\n const next: SpecOverlayAccess = { allowed: false }\n setAccess(next)\n writeSpecOverlayAccessCache(next)\n })\n return () => {\n cancelled = true\n }\n }, [access])\n\n // Fetch status for the current page, debounced 300ms, on every route\n // change and org change. Only once access is known to be allowed.\n useEffect(() => {\n if (automated || !access?.allowed || typeof window === 'undefined') return\n const timer = window.setTimeout(() => {\n specOverlayFetchJson(specOverlayStatusPath())\n .then((data) => setStatus(data as SpecOverlayStatus))\n .catch(() => setStatus(null))\n }, 300)\n return () => window.clearTimeout(timer)\n }, [access?.allowed, href, orgId])\n\n // Opening the drawer captures the viewer's real view automatically — no\n // click, no prompt. The raster runs while the drawer is open; the drawer is\n // filtered out of the frame. One capture per open.\n const captureRun = useRef(0)\n // Live-read access inside the retry loop below: access can be revoked\n // mid-poll (session expiry, org switch), and the loop must stop hitting\n // /api/overlay/status the moment that happens rather than riding out its\n // full 45 × 3s budget regardless.\n const accessRef = useRef(access)\n accessRef.current = access\n const runCapture = async (s: Extract<SpecOverlayStatus, { matched: true }>) => {\n const run = ++captureRun.current\n const before = s.live_source === 'viewer' ? s.finished_at : null\n setCapture({ state: 'busy' })\n try {\n // Let the drawer paint first so the page is idle while we raster.\n await new Promise((r) => setTimeout(r, 150))\n await captureMyView(s, orgId, orgName)\n for (let i = 0; i < 45; i++) {\n await new Promise((r) => setTimeout(r, 3000))\n if (run !== captureRun.current) return\n // Access lost mid-poll: stop, but never leave the spinner up forever.\n if (!accessRef.current?.allowed) {\n setCapture({ state: 'idle' })\n return\n }\n const next = (await specOverlayFetchJson(specOverlayStatusPath()).catch(() => null)) as SpecOverlayStatus | null\n if (next && next.matched && next.live_source === 'viewer' && next.finished_at !== before) {\n setStatus(next)\n setFrameKey((k) => k + 1)\n setCapture({ state: 'idle' })\n return\n }\n }\n setCapture({ state: 'error', message: 'Compare did not finish in 2 min.' })\n } catch (e) {\n if (run === captureRun.current) setCapture({ state: 'error', message: e instanceof Error ? e.message : String(e) })\n }\n }\n useEffect(() => {\n if (automated || !open || !status || !status.matched) return\n void runCapture(status)\n return () => {\n captureRun.current++\n }\n // Only re-run on open / page change, not on every status refresh.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [open, status && status.matched ? status.target_id : null])\n\n\n if (automated || !access?.allowed) return null\n\n const hasScore = status && status.matched && typeof status.mismatch_pct === 'number'\n const badgeLabel =\n hasScore ? `${Math.round((status as Extract<SpecOverlayStatus, { matched: true }>).mismatch_pct as number)}%` : status ? '—' : undefined\n const badgeTone: 'default' | 'warning' | 'danger' =\n hasScore ? (status && status.matched && status.passed ? 'default' : 'danger') : 'default'\n\n return (\n <>\n <button\n type=\"button\"\n aria-label=\"Spec\"\n aria-expanded={open}\n className={topBarIconButtonClass(badgeTone)}\n onClick={() => setOpen(true)}\n >\n <LayoutGlyph size={TOPBAR_GLYPH_SIZE} className=\"text-current\" />\n {badgeLabel ? (\n <span\n className={[\n 'absolute -top-1 -right-1 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] font-normal leading-none text-[#FFFFFF]',\n hasScore\n ? status && status.matched && status.passed\n ? 'bg-[color:var(--chrome-success,#2f855a)]'\n : 'bg-[color:var(--chrome-danger)]'\n : 'bg-[color:var(--muted)]',\n ].join(' ')}\n >\n {badgeLabel}\n </span>\n ) : null}\n {!open ? (\n <TopBarTooltip\n title=\"Spec\"\n description=\"Spec design + visual regression for this page.\"\n />\n ) : null}\n </button>\n {open && typeof document !== 'undefined'\n ? createPortal(\n <div\n className=\"fixed inset-0 z-50 flex justify-end bg-black/40\"\n {...{ [SPEC_OVERLAY_ROOT_ATTR]: '' }}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-label=\"Spec overlay\"\n onMouseDown={(e) => {\n if (e.target === e.currentTarget) setOpen(false)\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape') setOpen(false)\n }}\n >\n <div className=\"flex h-full w-full max-w-[480px] flex-col border-l border-[color:var(--line)] bg-[color:var(--panel-elevated)] shadow-[var(--shadow-soft)]\">\n <div className=\"flex items-center justify-between gap-2 border-b border-[color:var(--line)] px-4 py-3\">\n <h2 className=\"truncate text-sm font-bold tracking-[-0.01em] text-[color:var(--foreground)]\">\n Spec{status && status.matched ? `: ${status.spec_title}` : ''}\n </h2>\n <button\n type=\"button\"\n aria-label=\"Close\"\n onClick={() => setOpen(false)}\n className=\"rounded-full p-1 text-[color:var(--muted)] hover:bg-[color:var(--panel)] hover:text-[color:var(--foreground)]\"\n >\n <CloseGlyph size={16} />\n </button>\n </div>\n {status && status.matched ? (\n <>\n <div className=\"flex items-center gap-3 border-b border-[color:var(--line)] px-4 py-2 text-xs font-semibold\">\n <a\n href={status.spec_url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"text-[color:var(--color-accent-fg,var(--color-accent))] hover:underline\"\n >\n Open spec ↗\n </a>\n <a\n href={status.compare_url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"text-[color:var(--color-accent-fg,var(--color-accent))] hover:underline\"\n >\n Compare tab ↗\n </a>\n <button\n type=\"button\"\n disabled={capture.state === 'busy'}\n onClick={() => void runCapture(status)}\n className=\"ml-auto rounded-md border border-[color:var(--line)] px-2 py-1 text-[color:var(--foreground)] hover:bg-[color:var(--panel)] disabled:opacity-60\"\n title=\"Your view is captured when the drawer opens. Recapture after changing the page.\"\n >\n {capture.state === 'busy' ? 'Capturing…' : 'Recapture'}\n </button>\n <button\n type=\"button\"\n data-spec-copy-prompt=\"\"\n disabled={capture.state === 'busy' || !status.prompt}\n onClick={() => {\n const text = status.prompt\n if (!text) return\n // The prompt is already in hand, so the write stays inside the click gesture.\n navigator.clipboard\n .writeText(text)\n .then(() => setCopied('copied'))\n .catch(() => setCopied('failed'))\n .finally(() => window.setTimeout(() => setCopied('idle'), 2000))\n }}\n className=\"rounded-md border border-[color:var(--line)] px-2 py-1 text-[color:var(--foreground)] hover:bg-[color:var(--panel)] disabled:opacity-60\"\n title=\"Copy a repair prompt for an AI agent: spec, score, image links, top mismatched regions and instructions.\"\n >\n {copied === 'copied' ? 'Copied ✓' : copied === 'failed' ? 'Copy failed' : 'Copy prompt'}\n </button>\n </div>\n {status.live_size && status.design_size && capture.state !== 'busy' ? (\n <p\n data-spec-sizes=\"\"\n className={[\n 'border-b border-[color:var(--line)] px-4 py-1.5 text-xs',\n status.live_size.width === status.design_size.width &&\n status.live_size.height === status.design_size.height\n ? 'text-[color:var(--muted)]'\n : 'font-semibold text-[color:var(--chrome-danger)]',\n ].join(' ')}\n >\n Live {status.live_size.width}×{status.live_size.height} · Design {status.design_size.width}×\n {status.design_size.height}\n {status.live_size.width === status.design_size.width &&\n status.live_size.height === status.design_size.height\n ? ' · sizes match'\n : ' · SIZE MISMATCH'}\n </p>\n ) : null}\n {capture.state === 'error' ? (\n <p className=\"border-b border-[color:var(--line)] px-4 py-2 text-xs text-[color:var(--chrome-danger)]\">\n {capture.message}\n </p>\n ) : null}\n {capture.state === 'busy' ? (\n <SpecCaptureLoading />\n ) : (\n <iframe\n key={frameKey}\n src={status.overlay_url}\n title=\"Spec overlay\"\n className=\"h-full w-full flex-1 border-0\"\n />\n )}\n </>\n ) : status && !status.matched ? (\n <div className=\"p-4 text-sm text-[color:var(--muted)]\">\n <p>No compare target covers this page.</p>\n <a\n href={status.search_url}\n target=\"_blank\"\n rel=\"noreferrer\"\n className=\"mt-2 inline-block font-semibold text-[color:var(--color-accent-fg,var(--color-accent))] hover:underline\"\n >\n Search specs ↗\n </a>\n </div>\n ) : (\n <div className=\"p-4\">\n <ValueSkeleton className=\"h-4 w-full\" />\n </div>\n )}\n </div>\n </div>,\n document.body,\n )\n : null}\n </>\n )\n}\n\nfunction CloseGlyph({ size = 16, className }: { size?: number; className?: string }) {\n return (\n <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" className={className} aria-hidden>\n <line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\" />\n <line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\" />\n </svg>\n )\n}\n\n// ---------------------------------------------------------------------------\n// NavDisplayAction — the Menu / Tabs / Both navigation-display switcher.\n// Controlled: the app owns persistence (localStorage/profile) and layout\n// consequences (sub-menu visibility, tab strip visibility).\n// ---------------------------------------------------------------------------\n\nexport type NavDisplayMode = 'menu' | 'tabs' | 'both'\n\nexport const NAV_DISPLAY_OPTIONS: { value: NavDisplayMode; label: string }[] = [\n { value: 'menu', label: 'Sub Menu' },\n { value: 'tabs', label: 'Tabs Only' },\n { value: 'both', label: 'Both' },\n]\n\nexport function NavDisplayAction({\n value,\n onChange,\n}: {\n value: NavDisplayMode\n onChange: (next: NavDisplayMode) => void\n}) {\n return (\n <TopBarPopover\n label=\"Navigation Display\"\n description=\"Show navigation as a sub-menu, tabs, or both.\"\n fallbackIcon={LayoutGlyph}\n panelClassName=\"w-44\"\n >\n <div className=\"py-1\" role=\"radiogroup\" aria-label=\"Navigation display\">\n {NAV_DISPLAY_OPTIONS.map((opt) => (\n <button\n key={opt.value}\n type=\"button\"\n role=\"radio\"\n aria-checked={value === opt.value}\n onClick={() => onChange(opt.value)}\n className={[\n 'flex w-full items-center justify-between px-4 py-2 text-left text-sm font-medium',\n value === opt.value\n ? 'text-[color:var(--color-accent-fg,var(--color-accent))]'\n : 'text-[color:var(--foreground)] hover:bg-[color:var(--panel)]',\n ].join(' ')}\n >\n {opt.label}\n {value === opt.value ? <span aria-hidden>✓</span> : null}\n </button>\n ))}\n </div>\n </TopBarPopover>\n )\n}\n\n// ---------------------------------------------------------------------------\n// useThemePreference — the cross-app theme state machine (Task: theme derived\n// from the Auth system, live across tabs and apps).\n//\n// boot : cookie → localStorage → \"system\" (the pre-paint script already\n// painted this), then ONCE per session reconcile against the\n// profile value from `GET me` (authoritative) when a fetcher is\n// available.\n// change : apply + localStorage + cross-subdomain cookie + best-effort\n// `PATCH me/preferences { themePreference }`.\n// sync : same-app tabs via the `storage` event; other-app tabs re-read the\n// shared cookie on focus/visibility; `system` follows live OS\n// changes via matchMedia.\n// ---------------------------------------------------------------------------\n\nexport function useThemePreference(): {\n value: ThemePreference\n setValue: (next: ThemePreference) => void\n} {\n const ctx = useContext(NavChromeContext)\n const fetchJson = ctx?.fetchJson ?? null\n const [value, setValueState] = useState<ThemePreference>('system')\n const reconciled = useRef(false)\n\n // Boot: cookie → localStorage → system.\n useEffect(() => {\n const cookie = readThemeCookie()\n let ls: string | null = null\n try {\n ls = localStorage.getItem(THEME_STORAGE_KEY)\n } catch {\n /* unavailable */\n }\n const pref = cookie ?? (isThemePreference(ls) ? ls : null) ?? 'system'\n setValueState(pref)\n applyThemePreference(pref)\n }, [])\n\n // Once per session: converge on the profile's saved choice (authoritative),\n // reusing the provider's single `me` fetch.\n const meCtx = useContext(NavChromeContext)\n useEffect(() => {\n if (reconciled.current) return\n // A choice made where no chrome-API session exists (Politogy ID's login\n // screen) is still only in the cookie. Push it UP rather than pulling the\n // stale profile value DOWN — otherwise the user's fresh pick is silently\n // reverted on the next app they open (HITL 2026-07-23: \"I set System and it\n // keeps switching back to Light\").\n const pending = readPendingThemeChoice()\n if (pending) {\n // Only latch once the profile write has actually been attempted, so a\n // later `me` arrival still gets a chance to persist it.\n if (meCtx?.me) reconciled.current = true\n setValueState(pending)\n applyThemePreference(pending)\n writeThemeCookie(pending)\n try {\n localStorage.setItem(THEME_STORAGE_KEY, pending)\n } catch {\n /* unavailable */\n }\n if (!meCtx?.me) return\n fetchJson?.('me/preferences', {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ themePreference: pending }),\n })\n .then(() => clearPendingThemeChoice())\n .catch(() => {})\n return\n }\n const pref = meCtx?.me?.themePreference\n if (isThemePreference(pref)) {\n reconciled.current = true\n setValueState(pref)\n applyThemePreference(pref)\n writeThemeCookie(pref)\n try {\n localStorage.setItem(THEME_STORAGE_KEY, pref)\n } catch {\n /* unavailable */\n }\n }\n }, [meCtx?.me])\n\n // Live sync: storage events (same-app tabs), focus/visibility cookie\n // re-reads (other-app tabs), and OS changes while on \"system\".\n useEffect(() => {\n const onStorage = (e: StorageEvent) => {\n if (e.key === THEME_STORAGE_KEY && isThemePreference(e.newValue)) {\n setValueState(e.newValue)\n applyThemePreference(e.newValue)\n }\n }\n const onWake = () => {\n const cookie = readThemeCookie()\n if (cookie) {\n setValueState((prev) => {\n if (cookie !== prev) applyThemePreference(cookie)\n return cookie\n })\n }\n }\n window.addEventListener('storage', onStorage)\n window.addEventListener('focus', onWake)\n document.addEventListener('visibilitychange', onWake)\n return () => {\n window.removeEventListener('storage', onStorage)\n window.removeEventListener('focus', onWake)\n document.removeEventListener('visibilitychange', onWake)\n }\n }, [])\n\n\n const setValue = useCallback(\n (next: ThemePreference) => {\n setValueState(next)\n applyThemePreference(next)\n writeThemeCookie(next)\n try {\n localStorage.setItem(THEME_STORAGE_KEY, next)\n } catch {\n /* unavailable */\n }\n // Best-effort profile persistence — a theme toggle never errors. Until it\n // lands, the choice stays marked pending so the next app pushes it up\n // instead of reconciling the stale profile value back down.\n markThemeChoicePending(next)\n fetchJson?.('me/preferences', {\n method: 'PATCH',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ themePreference: next }),\n })\n .then(() => clearPendingThemeChoice())\n .catch(() => {})\n },\n [fetchJson],\n )\n\n return { value, setValue }\n}\n","import type { AppRegistryEntry } from '../types'\nimport type { NavItem } from '../native/index'\n\n/**\n * Build a Speculation Rules JSON payload that prerenders other apps in the\n * registry on moderate eagerness. Returns null when there are no eligible\n * other apps to prerender (e.g., this is the only app in the registry).\n *\n * @deprecated Legacy `AppRegistryEntry[]`-based registry is unused by any\n * current consumer. Cross-app sidebar nav now ships real `NavItem[]` trees\n * (`standardPolitogyNav`) — use `buildNavSpeculationRules` instead, which this\n * now delegates to.\n *\n * The host app is expected to render this as\n * `<script type=\"speculationrules\">{json}</script>` in <head> at runtime.\n */\nexport function buildSpeculationRules(\n currentApp: string,\n registry: AppRegistryEntry[],\n): string | null {\n const others = registry.filter(\n (entry) => entry.id !== currentApp && entry.visible !== false,\n )\n if (others.length === 0) return null\n const payload = {\n prerender: [\n {\n urls: others.map((entry) => entry.path),\n eagerness: 'moderate' as const,\n },\n ],\n }\n return JSON.stringify(payload)\n}\n\n/**\n * Labels the shell will never prerender or prefetch, even if a consumer's nav\n * tree somehow carries an `href` for them (sign-out is normally a footer\n * `onClick`, never a `NavItem.href` — this is a second guard, not the primary\n * one). Case-insensitive substring match against the row's label.\n */\nconst DESTRUCTIVE_LABEL_PATTERNS = ['sign out', 'signout', 'log out', 'logout', 'delete']\n\n/** URL substrings that mark a link as destructive/non-idempotent regardless of label. */\nconst DESTRUCTIVE_PATH_PATTERNS = ['/signout', '/sign-out', '/logout', '/log-out']\n\nfunction isDestructive(item: { label: string; href?: string }): boolean {\n const label = item.label.toLowerCase()\n if (DESTRUCTIVE_LABEL_PATTERNS.some((p) => label.includes(p))) return true\n const href = (item.href ?? '').toLowerCase()\n return DESTRUCTIVE_PATH_PATTERNS.some((p) => href.includes(p))\n}\n\n/**\n * Walk a `NavItem[]` tree (as produced by `standardPolitogyNav`) and collect\n * every absolute, cross-origin, non-destructive, GET-safe link — the\n * candidate set for prerender/prefetch. Sections and action rows (`onClick`,\n * no `href`) are skipped; children are walked too (sub-menu rows like\n * \"Command Center\" / \"New Poll\" are real cross-app destinations).\n */\nexport function collectSiblingAppUrls(items: NavItem[], currentOrigin: string): string[] {\n const urls = new Set<string>()\n const walk = (list: NavItem[]) => {\n for (const item of list) {\n if (item.kind === 'section') continue\n if (item.href && !isDestructive(item)) {\n try {\n const url = new URL(item.href, currentOrigin)\n if (url.origin !== currentOrigin && /^https?:$/.test(url.protocol)) {\n urls.add(url.href)\n }\n } catch {\n // Malformed href — skip rather than throw during nav render.\n }\n }\n if (item.children?.length) walk(item.children)\n }\n }\n walk(items)\n return Array.from(urls)\n}\n\nexport interface NavSpeculationRules {\n prerender: [{ source: 'list'; urls: string[]; eagerness: 'moderate' }]\n}\n\n/**\n * Build the Speculation Rules payload for a consumer's real sidebar nav tree:\n * every sibling `*.politogyvrm.com` app link, `eagerness: \"moderate\"` (the\n * browser's own heuristic — prerender starts on hover/pointerdown of a\n * matching `<a>`, not on page load). Sign-out and other destructive rows are\n * excluded by `collectSiblingAppUrls`. Returns `null` when there is nothing\n * to speculate on (e.g., an empty or single-app tree).\n *\n * Each target origin must opt in by sending\n * `Supports-Loading-Mode: credentialed-prerender` on its responses, per the\n * Speculation Rules cross-origin prerender contract — without it the browser\n * silently falls back to a normal navigation. (Other apps are adding this\n * header separately.)\n */\nexport function buildNavSpeculationRules(\n items: NavItem[],\n currentOrigin: string = typeof window !== 'undefined' ? window.location.origin : '',\n): NavSpeculationRules | null {\n const urls = collectSiblingAppUrls(items, currentOrigin)\n if (urls.length === 0) return null\n return {\n prerender: [{ source: 'list', urls, eagerness: 'moderate' }],\n }\n}\n","import { useEffect, useMemo } from 'react'\nimport type { NavItem } from '../native/index'\nimport { buildNavSpeculationRules, collectSiblingAppUrls } from './emitRules'\n\nconst SCRIPT_ID = 'politogy-speculation-rules'\nconst PREFETCH_ATTR = 'data-politogy-speculation-prefetch'\n\n/**\n * Renders the cross-app Speculation Rules `<script>` for the current\n * consumer's sidebar nav tree, and mounts in every `NavAppShell` — so it is\n * never an opt-in an app has to remember. Browsers that support Speculation\n * Rules prerender a sibling `*.politogyvrm.com` app the moment the user\n * hovers or pointers-down on its sidebar link (`eagerness: \"moderate\"`);\n * browsers that don't fall back, after the page goes idle, to plain\n * `<link rel=\"prefetch\">` tags for the same URLs, so the next click is still\n * warmed by a DNS/TLS/HTML fetch even without a prerendered document.\n *\n * Each sibling origin must send `Supports-Loading-Mode:\n * credentialed-prerender` on its responses for the prerender to actually\n * happen while the user is authenticated (cross-origin prerender is opt-in\n * on the destination). Without it, browsers degrade this to a normal\n * navigation — the hover/click still works, it's just not pre-warmed.\n *\n * Renders nothing visible; this is a side-effecting `<script>` injector.\n */\nexport function SpeculationRulesScript({ items }: { items: NavItem[] }) {\n const origin = typeof window !== 'undefined' ? window.location.origin : ''\n const rules = useMemo(() => buildNavSpeculationRules(items, origin), [items, origin])\n const json = rules ? JSON.stringify(rules) : null\n\n // Native Speculation Rules — covers the hover/pointerdown prerender case in\n // supporting browsers (Chromium). Declarative: no listeners needed, the\n // browser applies its own \"moderate\" heuristic to matching <a> elements.\n useEffect(() => {\n if (!json || typeof document === 'undefined') return\n let el = document.getElementById(SCRIPT_ID) as HTMLScriptElement | null\n if (!el) {\n el = document.createElement('script')\n el.id = SCRIPT_ID\n el.type = 'speculationrules'\n document.head.appendChild(el)\n }\n el.textContent = json\n return () => {\n // Leave the tag in place across route changes within the same app —\n // only strip it if this effect instance's app unmounts entirely with no\n // sibling to replace it.\n }\n }, [json])\n\n // Idle-prefetch fallback for browsers without Speculation Rules support\n // (or where the destination hasn't sent the opt-in header): warm the\n // connection/document via <link rel=\"prefetch\"> once the main thread is\n // idle, so it never competes with first-paint work.\n useEffect(() => {\n if (typeof document === 'undefined' || typeof window === 'undefined') return\n const supportsSpecRules =\n typeof HTMLScriptElement !== 'undefined' &&\n typeof (HTMLScriptElement as unknown as { supports?: (t: string) => boolean }).supports ===\n 'function' &&\n (HTMLScriptElement as unknown as { supports: (t: string) => boolean }).supports(\n 'speculationrules',\n )\n if (supportsSpecRules) return\n const urls = collectSiblingAppUrls(items, origin)\n if (urls.length === 0) return\n\n const schedule: (cb: () => void) => void =\n typeof (window as unknown as { requestIdleCallback?: (cb: () => void) => void })\n .requestIdleCallback === 'function'\n ? (window as unknown as { requestIdleCallback: (cb: () => void) => void })\n .requestIdleCallback\n : (cb: () => void) => setTimeout(cb, 2000)\n\n const added: HTMLLinkElement[] = []\n schedule(() => {\n for (const url of urls) {\n if (document.querySelector(`link[${PREFETCH_ATTR}][href=\"${url}\"]`)) continue\n const link = document.createElement('link')\n link.rel = 'prefetch'\n link.href = url\n link.setAttribute(PREFETCH_ATTR, '')\n document.head.appendChild(link)\n added.push(link)\n }\n })\n return () => {\n added.forEach((l) => l.remove())\n }\n }, [items, origin])\n\n return null\n}\n"]}