@flamingo-stack/openframe-frontend-core 0.0.405 → 0.0.406-snapshot.20260711131925

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.
Files changed (136) hide show
  1. package/dist/{chunk-3KEBI6TP.cjs → chunk-2B6773QM.cjs} +1 -1
  2. package/dist/chunk-2B6773QM.cjs.map +1 -0
  3. package/dist/{chunk-RIGB7LP7.js → chunk-43H2WOAW.js} +3 -3
  4. package/dist/{chunk-QYTGHN2T.js → chunk-4UZH3MT2.js} +4 -4
  5. package/dist/{chunk-LREN3G7R.cjs → chunk-5M5W6XDY.cjs} +7 -7
  6. package/dist/{chunk-LREN3G7R.cjs.map → chunk-5M5W6XDY.cjs.map} +1 -1
  7. package/dist/{chunk-WEZIVLCO.cjs → chunk-74FWQI73.cjs} +18 -18
  8. package/dist/{chunk-WEZIVLCO.cjs.map → chunk-74FWQI73.cjs.map} +1 -1
  9. package/dist/{chunk-E6YHDT3D.js → chunk-7Q52HP45.js} +2 -2
  10. package/dist/chunk-7Q52HP45.js.map +1 -0
  11. package/dist/{chunk-3XCNFTFV.js → chunk-7XVFSGQA.js} +3 -3
  12. package/dist/{chunk-QAFRLO5N.cjs → chunk-CUN4CJUN.cjs} +10 -11
  13. package/dist/chunk-CUN4CJUN.cjs.map +1 -0
  14. package/dist/{chunk-ICJRSNBM.js → chunk-CVYSW33D.js} +199 -189
  15. package/dist/chunk-CVYSW33D.js.map +1 -0
  16. package/dist/{chunk-FOJRR647.cjs → chunk-DOBNDDNE.cjs} +75 -75
  17. package/dist/{chunk-FOJRR647.cjs.map → chunk-DOBNDDNE.cjs.map} +1 -1
  18. package/dist/{chunk-FFYEDIAG.cjs → chunk-GGDM5J4B.cjs} +332 -322
  19. package/dist/chunk-GGDM5J4B.cjs.map +1 -0
  20. package/dist/{chunk-UN2BJ7XW.js → chunk-GJSLKATJ.js} +2 -2
  21. package/dist/{chunk-GT7AJXKH.js → chunk-GMZL4T7C.js} +3 -3
  22. package/dist/{chunk-BK7QCB5J.js → chunk-H66L2265.js} +6 -6
  23. package/dist/{chunk-F3YLM5PO.js → chunk-HB63TQQO.js} +2 -2
  24. package/dist/{chunk-5XZEY34X.js → chunk-HJIRG7R6.js} +4 -4
  25. package/dist/{chunk-NA7XJRWB.js → chunk-KFQXO7QB.js} +1 -1
  26. package/dist/chunk-KFQXO7QB.js.map +1 -0
  27. package/dist/{chunk-Q2KKEE6W.js → chunk-KLBEIJVZ.js} +7 -7
  28. package/dist/{chunk-M6BGJVDY.cjs → chunk-LC6RRLFA.cjs} +15 -15
  29. package/dist/{chunk-M6BGJVDY.cjs.map → chunk-LC6RRLFA.cjs.map} +1 -1
  30. package/dist/{chunk-VFWEFR3Q.cjs → chunk-LPC3C7MG.cjs} +40 -40
  31. package/dist/{chunk-VFWEFR3Q.cjs.map → chunk-LPC3C7MG.cjs.map} +1 -1
  32. package/dist/{chunk-PNJ5LMVK.js → chunk-NO2KT42M.js} +9 -10
  33. package/dist/{chunk-PNJ5LMVK.js.map → chunk-NO2KT42M.js.map} +1 -1
  34. package/dist/{chunk-RC35ITSR.js → chunk-NSF7JUXF.js} +7 -7
  35. package/dist/{chunk-V4MOB3AD.cjs → chunk-PRKMOF2U.cjs} +14 -14
  36. package/dist/{chunk-V4MOB3AD.cjs.map → chunk-PRKMOF2U.cjs.map} +1 -1
  37. package/dist/{chunk-DHIYBC5Z.cjs → chunk-Q2MC3CBI.cjs} +35 -35
  38. package/dist/{chunk-DHIYBC5Z.cjs.map → chunk-Q2MC3CBI.cjs.map} +1 -1
  39. package/dist/{chunk-BS6O4HLJ.cjs → chunk-R4MXLJUS.cjs} +42 -42
  40. package/dist/{chunk-BS6O4HLJ.cjs.map → chunk-R4MXLJUS.cjs.map} +1 -1
  41. package/dist/{chunk-CCIBZ7TO.cjs → chunk-STGWQFYT.cjs} +5 -5
  42. package/dist/chunk-STGWQFYT.cjs.map +1 -0
  43. package/dist/{chunk-6OQ7YOX5.cjs → chunk-SY3QS2E5.cjs} +29 -29
  44. package/dist/{chunk-6OQ7YOX5.cjs.map → chunk-SY3QS2E5.cjs.map} +1 -1
  45. package/dist/{chunk-ELLTTMPE.cjs → chunk-WCPUJA3Y.cjs} +7 -7
  46. package/dist/{chunk-ELLTTMPE.cjs.map → chunk-WCPUJA3Y.cjs.map} +1 -1
  47. package/dist/{chunk-UIAQXIA6.js → chunk-XFP43YKG.js} +6 -6
  48. package/dist/{chunk-ACJ4CM6H.cjs → chunk-YX7C5JD7.cjs} +77 -77
  49. package/dist/{chunk-ACJ4CM6H.cjs.map → chunk-YX7C5JD7.cjs.map} +1 -1
  50. package/dist/components/announcement-bar.d.ts.map +1 -1
  51. package/dist/components/case-studies/index.cjs +10 -10
  52. package/dist/components/case-studies/index.js +4 -4
  53. package/dist/components/chat/index.cjs +4 -4
  54. package/dist/components/chat/index.js +3 -3
  55. package/dist/components/contact/index.cjs +5 -5
  56. package/dist/components/contact/index.js +4 -4
  57. package/dist/components/docs/index.cjs +7 -7
  58. package/dist/components/docs/index.js +6 -6
  59. package/dist/components/embeds/index.cjs +5 -5
  60. package/dist/components/embeds/index.js +4 -4
  61. package/dist/components/faq/index.cjs +6 -6
  62. package/dist/components/faq/index.js +5 -5
  63. package/dist/components/features/index.cjs +4 -4
  64. package/dist/components/features/index.js +3 -3
  65. package/dist/components/help-center-pages/index.cjs +23 -23
  66. package/dist/components/help-center-pages/index.js +14 -14
  67. package/dist/components/index.cjs +185 -179
  68. package/dist/components/index.cjs.map +1 -1
  69. package/dist/components/index.js +38 -32
  70. package/dist/components/index.js.map +1 -1
  71. package/dist/components/navigation/index.cjs +4 -4
  72. package/dist/components/navigation/index.js +3 -3
  73. package/dist/components/onboarding-guides/index.cjs +8 -8
  74. package/dist/components/onboarding-guides/index.js +7 -7
  75. package/dist/components/related-content/index.cjs +6 -6
  76. package/dist/components/related-content/index.js +5 -5
  77. package/dist/components/tickets/index.cjs +7 -7
  78. package/dist/components/tickets/index.js +6 -6
  79. package/dist/components/ui/index.cjs +4 -4
  80. package/dist/components/ui/index.js +3 -3
  81. package/dist/contexts/endpoints-runtime-context.d.ts +1 -1
  82. package/dist/contexts/endpoints-runtime-context.d.ts.map +1 -1
  83. package/dist/contexts/index.cjs +2 -2
  84. package/dist/contexts/index.js +1 -1
  85. package/dist/hooks/index.cjs +3 -3
  86. package/dist/hooks/index.js +2 -2
  87. package/dist/hooks/use-self-fetch.d.ts.map +1 -1
  88. package/dist/index.cjs +4 -4
  89. package/dist/index.cjs.map +1 -1
  90. package/dist/index.js +5 -5
  91. package/dist/types/announcement.cjs.map +1 -1
  92. package/dist/types/announcement.d.ts +0 -6
  93. package/dist/types/announcement.d.ts.map +1 -1
  94. package/dist/types/announcement.js.map +1 -1
  95. package/dist/types/index.cjs.map +1 -1
  96. package/dist/types/index.js.map +1 -1
  97. package/dist/utils/announcement-storage.d.ts +3 -0
  98. package/dist/utils/announcement-storage.d.ts.map +1 -1
  99. package/dist/utils/app-config.d.ts.map +1 -1
  100. package/dist/utils/color-analysis.d.ts +0 -4
  101. package/dist/utils/color-analysis.d.ts.map +1 -1
  102. package/dist/utils/index.cjs +186 -177
  103. package/dist/utils/index.cjs.map +1 -1
  104. package/dist/utils/index.js +185 -176
  105. package/dist/utils/index.js.map +1 -1
  106. package/dist/utils/ods-color-utils.d.ts +2 -1
  107. package/dist/utils/ods-color-utils.d.ts.map +1 -1
  108. package/package.json +1 -1
  109. package/src/components/announcement-bar.tsx +38 -21
  110. package/src/components/features/video.tsx +8 -0
  111. package/src/contexts/endpoints-runtime-context.tsx +1 -1
  112. package/src/hooks/use-self-fetch.ts +10 -9
  113. package/src/stories/AnnouncementBar.stories.tsx +8 -14
  114. package/src/types/announcement.ts +0 -8
  115. package/src/utils/announcement-storage.ts +17 -0
  116. package/src/utils/app-config.ts +3 -2
  117. package/src/utils/color-analysis.ts +5 -2
  118. package/src/utils/ods-color-utils.ts +4 -7
  119. package/dist/chunk-3KEBI6TP.cjs.map +0 -1
  120. package/dist/chunk-CCIBZ7TO.cjs.map +0 -1
  121. package/dist/chunk-E6YHDT3D.js.map +0 -1
  122. package/dist/chunk-FFYEDIAG.cjs.map +0 -1
  123. package/dist/chunk-ICJRSNBM.js.map +0 -1
  124. package/dist/chunk-NA7XJRWB.js.map +0 -1
  125. package/dist/chunk-QAFRLO5N.cjs.map +0 -1
  126. /package/dist/{chunk-RIGB7LP7.js.map → chunk-43H2WOAW.js.map} +0 -0
  127. /package/dist/{chunk-QYTGHN2T.js.map → chunk-4UZH3MT2.js.map} +0 -0
  128. /package/dist/{chunk-3XCNFTFV.js.map → chunk-7XVFSGQA.js.map} +0 -0
  129. /package/dist/{chunk-UN2BJ7XW.js.map → chunk-GJSLKATJ.js.map} +0 -0
  130. /package/dist/{chunk-GT7AJXKH.js.map → chunk-GMZL4T7C.js.map} +0 -0
  131. /package/dist/{chunk-BK7QCB5J.js.map → chunk-H66L2265.js.map} +0 -0
  132. /package/dist/{chunk-F3YLM5PO.js.map → chunk-HB63TQQO.js.map} +0 -0
  133. /package/dist/{chunk-5XZEY34X.js.map → chunk-HJIRG7R6.js.map} +0 -0
  134. /package/dist/{chunk-Q2KKEE6W.js.map → chunk-KLBEIJVZ.js.map} +0 -0
  135. /package/dist/{chunk-RC35ITSR.js.map → chunk-NSF7JUXF.js.map} +0 -0
  136. /package/dist/{chunk-UIAQXIA6.js.map → chunk-XFP43YKG.js.map} +0 -0
@@ -75,7 +75,8 @@ export declare function usePlatformColors(platform?: Platform): {
75
75
  };
76
76
  /**
77
77
  * Picks a near-black or near-white text color with adequate contrast on `hex`.
78
- * Uses Rec. 601 luminance.
78
+ * Thin wrapper over `pickReadableTextColor` (color-analysis.ts) ONE
79
+ * light-or-dark decision formula (WCAG relative luminance) for the whole lib.
79
80
  */
80
81
  export declare function getReadableTextColor(hex: string): string;
81
82
  export declare const HEX_PATTERN: RegExp;
@@ -1 +1 @@
1
- {"version":3,"file":"ods-color-utils.d.ts","sourceRoot":"","sources":["../../src/utils/ods-color-ut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IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAgB7F;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAyB7F;;;;;;;;;;;;;;;;AAED,wBAcE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flamingo-stack/openframe-frontend-core",
3
- "version": "0.0.405",
3
+ "version": "0.0.406-snapshot.20260711131925",
4
4
  "description": "Shared design system and components for all Flamingo platforms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { useEffect, useMemo, useState } from 'react';
3
+ import { useEffect, useMemo, useRef, useState } from 'react';
4
4
  import { X } from 'lucide-react';
5
5
  import { Button } from './ui/button';
6
6
  import { EntityIcon } from './icon-display';
@@ -9,7 +9,7 @@ import {
9
9
  isAnnouncementDismissed,
10
10
  clearLegacyAnnouncementCache,
11
11
  } from '../utils/announcement-storage';
12
- import type { AnnouncementBarProps, AnnouncementResponse } from '../types/announcement';
12
+ import type { Announcement, AnnouncementBarProps, AnnouncementResponse } from '../types/announcement';
13
13
  import { getAppType } from '../utils/app-config';
14
14
  import { useEndpointsRuntime } from '../contexts/endpoints-runtime-context';
15
15
  import { useSelfFetch } from '../hooks/use-self-fetch';
@@ -71,6 +71,15 @@ export function AnnouncementBar({
71
71
  });
72
72
  const announcement = data?.announcement ?? null;
73
73
 
74
+ // Hold the last non-null announcement so DEACTIVATION (a revalidation that
75
+ // returns null) collapses with the same 1fr->0fr animation as dismissal
76
+ // instead of unmounting in place (a hard 44px jump).
77
+ const lastAnnouncementRef = useRef<Announcement | null>(initialAnnouncement ?? null);
78
+ useEffect(() => {
79
+ if (announcement) lastAnnouncementRef.current = announcement;
80
+ }, [announcement]);
81
+ const displayAnnouncement = announcement ?? lastAnnouncementRef.current;
82
+
74
83
  // Expanded (height) state — initial value is a pure function of props so
75
84
  // the SSR HTML and the hydration render agree for every cohort.
76
85
  const [expandedState, setExpandedState] = useState<boolean>(() => initialAnnouncement != null);
@@ -109,6 +118,10 @@ export function AnnouncementBar({
109
118
  const handleDismiss = () => {
110
119
  if (previewMode || !announcement) return;
111
120
  dismissAnnouncement(platform, announcement.id);
121
+ // Release focus BEFORE the wrapper goes aria-hidden — a focused descendant
122
+ // inside an aria-hidden subtree strands screen-reader focus (and Chrome
123
+ // refuses to apply the attribute).
124
+ (document.activeElement as HTMLElement | null)?.blur?.();
112
125
  setExpandedState(false);
113
126
  };
114
127
 
@@ -119,7 +132,9 @@ export function AnnouncementBar({
119
132
  // via location.href / window.open (stored XSS).
120
133
  let safeUrl: string;
121
134
  try {
122
- const parsed = new URL(announcement.cta_url, window.location.origin);
135
+ // Resolve against the CURRENT page (not the origin) so path-relative and
136
+ // fragment CTAs keep their pre-guard semantics.
137
+ const parsed = new URL(announcement.cta_url, window.location.href);
123
138
  if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') return;
124
139
  safeUrl = parsed.href;
125
140
  } catch {
@@ -130,10 +145,10 @@ export function AnnouncementBar({
130
145
  : (window.location.href = safeUrl);
131
146
  };
132
147
 
133
- // Nothing to show (and nothing to animate around): render nothing. The
134
- // dismissed/deactivated case keeps the element mounted at 0fr so the
135
- // collapse animates.
136
- if (!announcement) return null;
148
+ // Never had anything to show: render nothing. Dismissal AND deactivation
149
+ // keep the element mounted (displayAnnouncement holds the last content) at
150
+ // 0fr so the collapse animates.
151
+ if (!displayAnnouncement) return null;
137
152
 
138
153
  // Contrast is solved with the ODS THEME system, not color literals: the
139
154
  // admin background's tone selects which ODS theme scopes the bar's content
@@ -141,7 +156,7 @@ export function AnnouncementBar({
141
156
  // dark-toned needs the dark theme's). `.theme-light` / `.theme-dark` are
142
157
  // the design system's own scoping classes (ods-colors.css) and flip every
143
158
  // Tier-1 `--ods-*` primitive for descendants.
144
- const themeScope = pickReadableTextColor(announcement.background_color) === 'dark' ? 'theme-light' : 'theme-dark';
159
+ const themeScope = pickReadableTextColor(displayAnnouncement.background_color) === 'dark' ? 'theme-light' : 'theme-dark';
145
160
 
146
161
  // Inside the scope, colors reference Tier-1 theme primitives directly
147
162
  // (Tier-2 `--color-*` aliases resolve once at :root and do NOT re-resolve
@@ -152,7 +167,7 @@ export function AnnouncementBar({
152
167
  const barButtonClasses =
153
168
  'text-[color:var(--ods-system-greys-white)] hover:bg-[var(--ods-system-greys-black-hover)] active:bg-[var(--ods-system-greys-black-action)]';
154
169
 
155
- const hasCta = Boolean(announcement.cta_enabled && announcement.cta_url);
170
+ const hasCta = Boolean(displayAnnouncement.cta_enabled && displayAnnouncement.cta_url && displayAnnouncement.cta_text);
156
171
 
157
172
  return (
158
173
  <div
@@ -171,9 +186,11 @@ export function AnnouncementBar({
171
186
  compact CTA on the right, and a ghost-icon dismiss (design-system
172
187
  icon-sm: 32px target, >= the 24px WCAG 2.2 SC 2.5.8 AA floor).
173
188
  */}
174
- <div className={`min-h-0 overflow-hidden ${themeScope}`} style={{ backgroundColor: announcement.background_color }}>
189
+ <div className={`min-h-0 overflow-hidden ${themeScope}`} style={{ backgroundColor: displayAnnouncement.background_color }}>
175
190
  <div className="flex items-center w-full max-w-full min-h-11 text-[color:var(--ods-system-greys-white)]">
176
- {/* Mobile: Clickable content area, Desktop: Regular content */}
191
+ {/* Mobile: whole-bar tap target (touch-first by design; the CTA
192
+ Button below is the keyboard/AT path and is CSS-hidden < md —
193
+ known tradeoff carried from the original bar). */}
177
194
  <div
178
195
  className={`flex flex-row gap-2 md:gap-3 items-center pl-4 md:pl-6 py-1.5 flex-1 min-w-0 ${
179
196
  hasCta ? 'md:cursor-default cursor-pointer' : ''
@@ -190,9 +207,9 @@ export function AnnouncementBar({
190
207
  wins, else a library glyph by name (+ props), via <EntityIcon>. */}
191
208
  <EntityIcon
192
209
  icon={{
193
- name: announcement.icon_name || 'openframe-logo',
194
- url: announcement.icon_url,
195
- props: announcement.icon_props,
210
+ name: displayAnnouncement.icon_name || 'openframe-logo',
211
+ url: displayAnnouncement.icon_url,
212
+ props: displayAnnouncement.icon_props,
196
213
  }}
197
214
  size={24}
198
215
  className="relative shrink-0 w-5 h-5 md:w-6 md:h-6"
@@ -202,9 +219,9 @@ export function AnnouncementBar({
202
219
  truncating as one unit. Separator is a middot (house rule: no
203
220
  en/em dashes in copy). */}
204
221
  <p className="font-body flex-1 min-w-0 max-w-full text-[13px] md:text-sm leading-snug truncate mb-0">
205
- <span className="font-semibold">{announcement.title}</span>
206
- {announcement.description && (
207
- <span className="hidden sm:inline opacity-80"> · {announcement.description}</span>
222
+ <span className="font-semibold">{displayAnnouncement.title}</span>
223
+ {displayAnnouncement.description && (
224
+ <span className="hidden sm:inline opacity-80"> · {displayAnnouncement.description}</span>
208
225
  )}
209
226
  </p>
210
227
 
@@ -214,7 +231,7 @@ export function AnnouncementBar({
214
231
  admin color. The admin cta_button_* colors are NOT applied:
215
232
  they were designed for the legacy bespoke treatment. Hidden
216
233
  on mobile, where the whole bar is the tap target. */}
217
- {hasCta && announcement.cta_text && (
234
+ {hasCta && displayAnnouncement.cta_text && (
218
235
  <div className="hidden md:flex flex-shrink-0 ml-1">
219
236
  <Button
220
237
  onClick={handleCtaClick}
@@ -223,10 +240,10 @@ export function AnnouncementBar({
223
240
  className={barButtonClasses}
224
241
  tabIndex={expanded ? 0 : -1}
225
242
  leftIcon={
226
- announcement.cta_show_icon && announcement.cta_icon_name
243
+ displayAnnouncement.cta_show_icon && displayAnnouncement.cta_icon_name
227
244
  ? (
228
245
  <EntityIcon
229
- icon={{ name: announcement.cta_icon_name, props: announcement.cta_icon_props }}
246
+ icon={{ name: displayAnnouncement.cta_icon_name, props: displayAnnouncement.cta_icon_props }}
230
247
  size={14}
231
248
  className="w-3.5 h-3.5"
232
249
  />
@@ -234,7 +251,7 @@ export function AnnouncementBar({
234
251
  : undefined
235
252
  }
236
253
  >
237
- {announcement.cta_text}
254
+ {displayAnnouncement.cta_text}
238
255
  </Button>
239
256
  </div>
240
257
  )}
@@ -892,6 +892,14 @@ function YouTubeFacadeInner({
892
892
  src={embedUrl}
893
893
  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
894
894
  allowFullScreen
895
+ // YouTube verifies the embedding domain from the Referer header. When the
896
+ // host page runs under a strict `Referrer-Policy: no-referrer` (common on
897
+ // deployed environments behind a gateway/CDN), the iframe would otherwise
898
+ // inherit it, send no referrer, and YouTube rejects playback with
899
+ // "Error 153 — Video player configuration error". Pin the policy to the
900
+ // value YouTube's own recommended embed code uses so the origin is always
901
+ // sent and embedding is authorized.
902
+ referrerPolicy="strict-origin-when-cross-origin"
895
903
  title={title}
896
904
  className="absolute inset-0 w-full h-full border-0 rounded-lg"
897
905
  />
@@ -24,7 +24,7 @@
24
24
  import { createContext, useContext } from 'react'
25
25
 
26
26
  export interface EndpointsRuntime {
27
- /** GET active announcement (used by `<AnnouncementBar>` polling). */
27
+ /** GET active announcement (used by `<AnnouncementBar>` mount fetch + refocus revalidation). */
28
28
  announcementsUrl: string
29
29
  accessCode: {
30
30
  /** POST validate access code. */
@@ -112,6 +112,13 @@ export function useSelfFetch<T>(
112
112
  // `url` folds in every query param; `reloadKey` drives retry.
113
113
  }, [url, reloadKey])
114
114
 
115
+ // ONE force-refetch mechanic shared by reload() and the visibility
116
+ // revalidation: clear the held-url skip, bump the effect key.
117
+ const forceReload = () => {
118
+ dataUrlRef.current = null
119
+ setReloadKey((k) => k + 1)
120
+ }
121
+
115
122
  // Opt-in visibility-driven revalidation. Registered only when the option is
116
123
  // set and fetching is enabled; SSR-safe (effects don't run on the server)
117
124
  // and StrictMode-safe (idempotent listener, cleaned up per mount cycle).
@@ -120,9 +127,7 @@ export function useSelfFetch<T>(
120
127
  const onVisible = () => {
121
128
  if (document.visibilityState !== 'visible') return
122
129
  if (Date.now() - dataAtRef.current < revalidateOnVisibleAfterMs) return
123
- // Same mechanics as reload(): clear the held-url skip, bump the key.
124
- dataUrlRef.current = null
125
- setReloadKey((k) => k + 1)
130
+ forceReload()
126
131
  }
127
132
  document.addEventListener('visibilitychange', onVisible)
128
133
  return () => document.removeEventListener('visibilitychange', onVisible)
@@ -133,11 +138,7 @@ export function useSelfFetch<T>(
133
138
  setData,
134
139
  isLoading,
135
140
  error,
136
- // Force a re-fetch of the current url: clear the held-url ref so the skip above
137
- // doesn't short-circuit, then bump the effect key.
138
- reload: () => {
139
- dataUrlRef.current = null
140
- setReloadKey((k) => k + 1)
141
- },
141
+ // Force a re-fetch of the current url (error-retry affordance).
142
+ reload: forceReload,
142
143
  }
143
144
  }
@@ -1,7 +1,7 @@
1
1
  import type { Meta, StoryObj } from '@storybook/nextjs-vite'
2
2
  import type { Announcement } from '../types/announcement'
3
3
  import { AnnouncementBar } from '../components/announcement-bar'
4
- import { announcementDismissCookieName } from '../utils/announcement-storage'
4
+ import { clearAnnouncementDismissals } from '../utils/announcement-storage'
5
5
  import { getAppType } from '../utils/app-config'
6
6
  import { EndpointsRuntimeContext, type EndpointsRuntime } from '../contexts/endpoints-runtime-context'
7
7
 
@@ -12,13 +12,7 @@ import { EndpointsRuntimeContext, type EndpointsRuntime } from '../contexts/endp
12
12
  * by a previous interaction so every story starts visible.
13
13
  */
14
14
  function clearDismissals() {
15
- const platform = getAppType()
16
- document.cookie = `${announcementDismissCookieName(platform)}=; path=/; max-age=0`
17
- Object.keys(localStorage).forEach((key) => {
18
- if (key.includes('-announcement-') && key.endsWith('-dismissed')) {
19
- localStorage.removeItem(key)
20
- }
21
- })
15
+ clearAnnouncementDismissals(getAppType())
22
16
  }
23
17
 
24
18
  const now = new Date().toISOString()
@@ -110,7 +104,7 @@ export const WithCTASameTab: Story = {
110
104
  }
111
105
 
112
106
  /**
113
- * Dark background text flips to the light shade via pickReadableTextColor.
107
+ * Dark background: text flips to the light shade via pickReadableTextColor.
114
108
  */
115
109
  export const DarkBackground: Story = {
116
110
  args: {
@@ -217,7 +211,7 @@ export const LongContent: Story = {
217
211
  }
218
212
 
219
213
  /**
220
- * previewMode the admin live-preview path: render-only, inert dismiss,
214
+ * previewMode, the admin live-preview path: render-only, inert dismiss,
221
215
  * no fetch and no storage side effects.
222
216
  */
223
217
  export const PreviewMode: Story = {
@@ -233,7 +227,7 @@ export const PreviewMode: Story = {
233
227
  }
234
228
 
235
229
  /**
236
- * No active announcement the bar renders nothing.
230
+ * No active announcement: the bar renders nothing.
237
231
  */
238
232
  export const NoAnnouncement: Story = {
239
233
  args: { initialAnnouncement: null },
@@ -241,8 +235,8 @@ export const NoAnnouncement: Story = {
241
235
  (Story) => (
242
236
  <div>
243
237
  <Story />
244
- <p className="p-4 text-sm text-gray-500">
245
- No announcement is active the bar renders nothing above this text.
238
+ <p className="p-4 text-sm text-ods-text-secondary">
239
+ No announcement is active. The bar renders nothing above this text.
246
240
  </p>
247
241
  </div>
248
242
  ),
@@ -250,7 +244,7 @@ export const NoAnnouncement: Story = {
250
244
  }
251
245
 
252
246
  /**
253
- * Client-only mode (no SSR) the react-embedding-example structure: the
247
+ * Client-only mode (no SSR), the react-embedding-example structure: the
254
248
  * embedder mounts an EndpointsRuntime provider (announcementsUrl is a fixed
255
249
  * suffix under its one content base) and drops in a PROP-LESS bar. No
256
250
  * platform knob anywhere on the client: the proxied server resolves its own
@@ -220,14 +220,6 @@ export interface AnnouncementValidation {
220
220
  // Import unified platform configuration (removed duplicate definition)
221
221
  export type { PlatformConfig } from './platform';
222
222
 
223
- // Admin Dashboard Types
224
- export interface AnnouncementStats {
225
- total_announcements: number;
226
- active_announcements: number;
227
- announcements_by_platform: Record<LegacyPlatform, number>;
228
- recent_announcements: Announcement[];
229
- }
230
-
231
223
  // Component Props Types
232
224
  export interface AnnouncementBarProps {
233
225
  /**
@@ -70,6 +70,23 @@ export function isAnnouncementDismissed(platform: string, id: string): boolean {
70
70
  }
71
71
  }
72
72
 
73
+ /** Remove ALL dismissal state for a platform (cookie + legacy localStorage
74
+ * keys) — test/story helper so callers never restate the key encoding. */
75
+ export function clearAnnouncementDismissals(platform: string): void {
76
+ if (typeof document === 'undefined') return
77
+ document.cookie = `${announcementDismissCookieName(platform)}=; path=/; max-age=0`
78
+ try {
79
+ const prefix = `${platform}-announcement-`
80
+ Object.keys(localStorage).forEach((key) => {
81
+ if (key.startsWith(prefix) && key.endsWith('-dismissed')) {
82
+ localStorage.removeItem(key)
83
+ }
84
+ })
85
+ } catch {
86
+ // ignore storage errors
87
+ }
88
+ }
89
+
73
90
  /** One-time cleanup of pre-refactor storage: the orphaned announcement cache
74
91
  * (the old "instant paint" blob) — called from the bar's mount effect. */
75
92
  export function clearLegacyAnnouncementCache(platform: string): void {
@@ -19,8 +19,9 @@ export function getAppType() {
19
19
  // The exact `process.env.NEXT_PUBLIC_APP_TYPE` member expression is kept so
20
20
  // Next/webpack can statically inline it. The try/catch makes the call safe
21
21
  // in non-Next React hosts (Vite/CRA embeds) where `process` does not exist
22
- // at runtime — those hosts fall back to 'openmsp' or pass an explicit
23
- // platform where it matters (e.g. AnnouncementBar's `platform` prop).
22
+ // at runtime — those hosts get the 'openmsp' fallback, which is fine for
23
+ // embeds: dismissal cookies are domain-scoped and an embed domain serves
24
+ // one platform's announcements.
24
25
  try {
25
26
  return process.env.NEXT_PUBLIC_APP_TYPE || 'openmsp';
26
27
  } catch {
@@ -17,7 +17,10 @@ export const DESIGN_PALETTE: ColorPalette[] = [
17
17
  * Convert hex color to RGB
18
18
  */
19
19
  export function hexToRgb(hex: string): [number, number, number] {
20
- const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
20
+ // Expand shorthand (#fc0 -> #ffcc00) so legacy/hand-entered values classify
21
+ // by their real color instead of falling through to black.
22
+ const normalized = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (_, r, g, b) => `${r}${r}${g}${g}${b}${b}`);
23
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(normalized);
21
24
  return result
22
25
  ? [parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)]
23
26
  : [0, 0, 0];
@@ -26,7 +29,7 @@ export function hexToRgb(hex: string): [number, number, number] {
26
29
  /**
27
30
  * Calculate relative luminance for contrast calculations
28
31
  */
29
- export function getLuminance(rgb: [number, number, number]): number {
32
+ function getLuminance(rgb: [number, number, number]): number {
30
33
  const [r, g, b] = rgb.map(c => {
31
34
  c = c / 255;
32
35
  return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
@@ -4,6 +4,7 @@
4
4
  * Provides runtime utilities for working with ODS color tokens
5
5
  */
6
6
 
7
+ import { pickReadableTextColor } from './color-analysis';
7
8
  import { colorTokens as odsTokens } from './ods-color-tokens-stub';
8
9
 
9
10
  export type Platform = 'openmsp' | 'openframe' | 'flamingo';
@@ -292,15 +293,11 @@ export function usePlatformColors(platform?: Platform) {
292
293
 
293
294
  /**
294
295
  * Picks a near-black or near-white text color with adequate contrast on `hex`.
295
- * Uses Rec. 601 luminance.
296
+ * Thin wrapper over `pickReadableTextColor` (color-analysis.ts) ONE
297
+ * light-or-dark decision formula (WCAG relative luminance) for the whole lib.
296
298
  */
297
299
  export function getReadableTextColor(hex: string): string {
298
- const n = parseInt(hex.replace('#', ''), 16)
299
- const r = (n >> 16) & 0xff
300
- const g = (n >> 8) & 0xff
301
- const b = n & 0xff
302
- const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255
303
- return luminance > 0.5 ? '#212121' : '#fafafa'
300
+ return pickReadableTextColor(hex) === 'dark' ? '#212121' : '#fafafa'
304
301
  }
305
302
 
306
303
  // Hex <-> RGB <-> HSL. Hex is #rrggbb lowercase; hexToRgb returns null on invalid.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/chunk-3KEBI6TP.cjs","../src/contexts/endpoints-runtime-context.tsx","../src/contexts/chat-runtime-context.tsx"],"names":["createContext","useContext"],"mappings":"AAAA,qFAAY;AACZ;AACA;ACqBA,8BAA0C;AAenC,IAAM,wBAAA,EAA0B,kCAAA,IAA2C,CAAA;AAO3E,SAAS,mBAAA,CAAA,EAA+C;AAC7D,EAAA,OAAO,+BAAA,uBAAkC,CAAA;AAC3C;AASO,SAAS,2BAAA,CAAA,EAAgD;AAC9D,EAAA,MAAM,EAAA,EAAI,+BAAA,uBAAkC,CAAA;AAC5C,EAAA,GAAA,CAAI,CAAC,CAAA,EAAG;AACN,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,IAIF,CAAA;AAAA,EACF;AACA,EAAA,OAAO,CAAA;AACT;ADlDA;AACA;AEiBA;AA0MO,IAAM,mBAAA,EAAqBA,kCAAAA,IAAsC,CAAA;AAQjE,SAAS,cAAA,CAAA,EAAqC;AACnD,EAAA,OAAOC,+BAAAA,kBAA6B,CAAA;AACtC;AAUO,SAAS,sBAAA,CAAA,EAAsC;AACpD,EAAA,MAAM,EAAA,EAAIA,+BAAAA,kBAA6B,CAAA;AACvC,EAAA,GAAA,CAAI,CAAC,CAAA,EAAG;AACN,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,IAMF,CAAA;AAAA,EACF;AACA,EAAA,OAAO,CAAA;AACT;AF7OA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACF,mUAAC","file":"/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/chunk-3KEBI6TP.cjs","sourcesContent":[null,"'use client'\n\n/**\n * Endpoints runtime — sibling of ChatRuntime. Carries the API path\n * literals consumed by oss-lib components/hooks/utils so a host\n * application can override them (e.g. when running behind a reverse\n * proxy as `user1.openframe.ai` → `/api/mingo-guide/*`).\n *\n * The hub mounts `<HubRuntimeProvider>` at root with the\n * canonical hub paths; an embedded app mounts its own provider with\n * remapped paths. The pattern mirrors ChatRuntimeContext exactly:\n *\n * - `useEndpointsRuntime()` returns null when no provider is mounted.\n * For optional consumers that should gracefully no-op without one.\n * - `useRequiredEndpointsRuntime()` throws on missing provider — for\n * hooks/components that cannot function without endpoints.\n *\n * IMPORTANT for embedders: memoize the value passed to\n * `<EndpointsRuntimeContext.Provider value={...}>` (e.g. React.useMemo).\n * Reference changes invalidate downstream effect dependency arrays and\n * trigger unnecessary re-fetches.\n */\n\nimport { createContext, useContext } from 'react'\n\nexport interface EndpointsRuntime {\n /** GET active announcement (used by `<AnnouncementBar>` polling). */\n announcementsUrl: string\n accessCode: {\n /** POST validate access code. */\n validateUrl: string\n /** POST consume / redeem access code after registration. */\n consumeUrl: string\n }\n /** POST contact-form submission. */\n contactUrl: string\n}\n\nexport const EndpointsRuntimeContext = createContext<EndpointsRuntime | null>(null)\n\n/**\n * Optional read — returns null when no provider is mounted. Use for\n * surfaces that should silently skip the fetch (e.g. announcement\n * polling on a page rendered outside the provider tree).\n */\nexport function useEndpointsRuntime(): EndpointsRuntime | null {\n return useContext(EndpointsRuntimeContext)\n}\n\n/**\n * Strict variant — throws on missing provider. Use for consumers that\n * cannot function without an endpoint (form submission, code\n * validation). In tests/Storybook, wrap with the hub's\n * `<HubRuntimeProvider>` or a stub\n * `<EndpointsRuntimeContext.Provider value={mockedEndpoints}>`.\n */\nexport function useRequiredEndpointsRuntime(): EndpointsRuntime {\n const v = useContext(EndpointsRuntimeContext)\n if (!v) {\n throw new Error(\n '[endpoints-runtime] hook called outside an <EndpointsRuntimeContext.Provider>. ' +\n 'Hub: mount <HubRuntimeProvider> in your providers tree. ' +\n 'Embedded app: mount your own provider with proxied URLs at the tree root. ' +\n 'Tests/Storybook: wrap render() in <EndpointsRuntimeContext.Provider value={mocked}>.',\n )\n }\n return v\n}\n","'use client'\n\n/**\n * Chat runtime context — single seam for embedding the chat panel in a\n * different host (e.g. user1.openframe.ai reverse-proxying API calls\n * under /api/mingo-guide/* to hub.openframe.ai/api/*).\n *\n * Three concerns, one context:\n * 1. API endpoints: chatStreamUrl / approvalToolUrl / commandsUrl /\n * buildListUrl + attachment endpoints + chat-identity. The chat\n * reads them from runtime; hub vs embedded app supply different\n * strings via different providers.\n * 2. Navigation mode + callbacks: 'host' or 'embed' mode. Host wires\n * its own router/docNav via the optional `navigate` callback\n * (plain function, NOT a hook); embed forces new-tab via\n * `defaultContentOrigin` + lib's `resolveExternalNavigation`.\n * 3. Identity context: only `source` (required for localStorage\n * namespacing). The display identity (greeting first-name etc.)\n * comes from the server via `useChatIdentity()` — never injected\n * client-side, so it always matches the server-resolved auth.\n *\n * Sibling of EndpointsRuntimeContext (announcement bar, contact form,\n * access codes). Each runtime stays an independent React context so\n * embedders can opt into either feature without forcing the other.\n *\n * IMPORTANT for embedders: memoize the value passed to\n * `<ChatRuntimeContext.Provider value={...}>` (e.g. via React.useMemo).\n * Every change to its reference identity invalidates downstream\n * `useMemo` consumers (the chat input's slash-commands binding,\n * useNavLink's embed-resolution memo, useDocChat's streamFn factory).\n * The hub's `<HubRuntimeProvider>` already memoizes correctly with\n * stable deps. Embedded apps that build the value inline on each render\n * will pay an avoidable re-render cost across the entire chat tree.\n */\n\nimport { createContext, useContext, type ReactNode } from 'react'\n\nimport type { ComposeContentUrl } from '../utils/content-href'\n\n/**\n * Runtime config consumed by the chat panel.\n */\nexport interface ChatRuntime {\n endpoints: {\n /** POST streaming chat. Hub: '/api/docs/chat'. */\n chatStreamUrl: string\n /** POST agent approve/reject. Hub: '/api/chat/agent/confirm-tool'. */\n approvalToolUrl: string\n /** Customer-ticket agent endpoints (Help Center). OPTIONAL — when unset,\n * the ticket hooks fall back to the bare hub paths\n * (`/api/chat/agent/{find-ticket,ticket-action,list-engagements}`).\n * Embedders behind a reverse proxy set these to their proxied paths\n * (e.g. `/content/api/chat/agent/...`) so tickets route through the SAME\n * endpoint config + proxy as every other endpoint. */\n findTicketUrl?: string\n ticketActionUrl?: string\n listEngagementsUrl?: string\n /** GET slash-command catalog. Hub: '/api/docs/commands'. */\n commandsUrl: string\n /** GET RAG-search endpoint behind `<DocSearchBar>` (the in-source search\n * bar mounted by `<DocViewer>` / `<DocsHubPage>` when `showAIChat` is on).\n * Hub: '/api/docs/search'. OPTIONAL — falls back to the hub path so\n * same-origin Next.js hosts don't need to set it. Cross-origin embedders\n * set their proxied path so the search bar routes through the same\n * reverse proxy as everything else. Same pattern as `findTicketUrl`. */\n docsSearchUrl?: string\n /** POST internal-link resolver. The in-source markdown renderer (lib or\n * custom) calls `<DocViewer>`'s `handlers.onResolveLink(href, currentPath)`\n * for relative hrefs like `./getting-started/intro.md` — that callback\n * posts to this URL with `{ link, currentPath, source }` and expects a\n * `ResolveLinkResult` back. Hub: '/api/docs/resolve-link'. OPTIONAL — same\n * fall-back chain as `docsSearchUrl`: prop override → runtime → default. */\n docsResolveLinkUrl?: string\n /** GET per-platform empty-state config (admin-edited in\n * `/admin/chat-config`): `{ greeting, enabledRagTableIds, suggestedQueries }`.\n * Hub: '/api/docs/empty-state'. OPTIONAL — the in-app (host-mode) chat\n * injects these values as SSR props instead, so it leaves this unset.\n * Cross-origin EMBEDDERS (no server hop) set it to their proxied path\n * (e.g. '/content/api/docs/empty-state') so `<EmbeddableChat>` can fetch\n * the greeting / quick-action chips / RAG-source filter at runtime. When\n * unset, the chat falls back to the explicit `emptyStateGreeting` /\n * `suggestedQueries` / `enabledRagTableIds` props (or in-code defaults). */\n emptyStateUrl?: string\n /** Build the per-agent display-config URL for an OpenFrame AI agent\n * (Fae/Mingo). OPTIONAL. The returned endpoint MUST be byte-compatible\n * with the empty-state wire shape ({ greeting, suggestedQueries,\n * enabledRagTableIds }). When set AND `EmbeddableChat` receives an\n * `activeAgentSlug` in embed mode, the chat fetches THIS url instead of\n * `emptyStateUrl` to render the selected agent's greeting + suggested\n * prompts (the \"agent mode\" URL override). Hub: `(slug) =>\n * '/api/ai-agents/' + encodeURIComponent(slug)`. */\n aiAgentConfigUrl?: (slug: string) => string\n /** Build entity-card list URL for a content type + ids. Hub delegates\n * to the rag-table-config registry; embedded app provides its own\n * per-type URL builder against the reverse proxy. Returns null when\n * the type has no list endpoint (caller skips rendering). */\n buildListUrl: (type: string, ids: string[]) => string | null\n /** Chat-attachment endpoints — added for the v2 attachment feature.\n *\n * Three concerns:\n * - `attachmentUploadUrl` — POSTed by the chat-attachment hook\n * to mint a Supabase signed-upload-URL + HMAC view token.\n * - `attachmentViewUrlPrefix` — embedded in markdown URLs the\n * chat hosts in user message bubbles (`![]()` / `[Attached]`).\n * Stored in chat history; chosen at SEND time. In host mode the\n * relative `/api/storage/view/chat-attachments/` is sufficient\n * (same-origin); embedders supply an absolute hub URL so the\n * browser can fetch cross-origin.\n * - `identityUrl` — GET endpoint the `useChatIdentity` hook\n * hits to learn the `{authTier, source, attachmentsEnabled}`\n * capability bag for the current session. Used beyond chat\n * (tickets / contact form / any embedded surface that needs\n * to identify the proxied customer), so the name has no\n * \"chat\" prefix even though the consuming hook still does. */\n attachmentUploadUrl: string\n attachmentViewUrlPrefix: string\n identityUrl: string\n /** Optional URL prefix for the image proxy (`<prefix>?url=<external>`).\n * When unset, lib's `getProxiedImageUrl` returns the original URL\n * unchanged. Hub default: '/api/image-proxy'. Embedders that don't\n * host an image-proxy route leave this undefined → images load\n * directly cross-origin (CORS-permitting). */\n imageProxyUrlPrefix?: string\n /** Optional list of hostnames that should bypass the image proxy\n * (rendered direct). Hub uses ['openmsp.ai']; embedders typically\n * leave it unset. Matches the `skipDomains` parameter of\n * `getProxiedImageUrl`. */\n imageProxySkipDomains?: string[]\n /** Optional base URL for the branded og-placeholder image route — the\n * DEFAULT cover-image fallback for entity cards with no image. The lib\n * appends `?title=…` (+ `w`/`h` for square slots) itself, so this is\n * the base, NOT a full URL: relative (`/api/og-placeholder`) for same-\n * origin hosts, or the proxied path (`/content/api/og-placeholder`) for\n * cross-origin embedders. May carry baked-in query params (preserved when\n * the lib layers `title`/dimensions on top) — but per-platform brand\n * colors are NO LONGER baked here; the `/api/og-placeholder` route\n * resolves them server-side from the platform. Most hosts leave this unset\n * and let the lib derive the base from `imageProxyUrlPrefix`.\n *\n * OPTIONAL — when unset the lib derives the base from the sibling\n * `imageProxyUrlPrefix` (same API base, route name swapped), then falls\n * back to the relative `/api/og-placeholder`. So an embedder that already\n * proxies images needs NO og-placeholder wiring. See\n * `resolveOgPlaceholderBase` / `buildOgPlaceholderUrl` in `../utils`. */\n ogPlaceholderUrl?: string\n /** Supabase storage origin (e.g. `https://xyz.supabase.co`) — used\n * by `useVideoWarmup` to scope the `<link rel=\"preload\" as=\"video\">`\n * hint to MP4s the deployment actually hosts. Hub wires it via\n * `getSupabaseStorageOrigin()`; embedders without a Supabase\n * storage origin leave it unset (preload is then skipped; Mux/\n * YouTube preconnect still fires). */\n supabaseStorageOrigin?: string\n }\n navigation: {\n /** ONE knob, two behaviors:\n * - 'host' = use the host page's existing click-routing untouched.\n * The chat panel calls `navigate?.()` for in-app routing.\n * - 'embed' = guest inside another app: short-circuit at the top\n * of click handlers to force new-tab + absolutize via\n * resolveExternalNavigation. */\n mode: 'host' | 'embed'\n /** Embed-only fallback origin for relative URLs whose target platform\n * can't be inferred. Used by resolveExternalNavigation when\n * `targetPlatform` is null — without this, a relative `/foo` href would\n * window.open against the embedder's origin, which is WRONG.\n * Set to your content host (e.g. 'https://hub.openframe.ai').\n * Required by the embedded app whenever mode='embed'. */\n defaultContentOrigin?: string\n /** Override for opening external URLs. MUST BE SYNCHRONOUS —\n * Safari/Firefox block popups opened outside a direct user gesture.\n * Default: window.open(href, '_blank', 'noopener,noreferrer'). */\n openExternal?: (href: string) => void\n /** Optional in-app navigation callback (host-mode only).\n * Returns `true` if the host handled the click in-app\n * (router.push + docNav.navigate); returns `false`, `undefined`,\n * or `void` → lib falls back to window.location.assign(href).\n * Hub wires this via HubRuntimeProvider's HubNavigationWiring;\n * embedders not in Next.js leave it undefined. */\n navigate?: (input: { href: string; path?: string | null; targetPlatform?: string | null }) => boolean | void\n /** Optional new-tab decision callback. Returns true → lib opens in\n * new tab; false → same tab via `navigate`. Hub wires the existing\n * `decideNewTab` logic from use-nav-link.tsx (re-imports the pure\n * helper from lib). Embedders may omit; lib defaults to:\n * same-origin/same-platform → same tab, else new tab. */\n decideNewTab?: (args: { href: string; targetPlatform?: string | null }) => boolean\n }\n /** Optional content-URL composer. Returns the platform-aware href +\n * target-platform tuple for a content entity. Hub wires this to its\n * `buildContentURL(type, slug, extractPrimaryPlatform(platforms))`\n * pipeline so the lib catalog/detail views can derive cross-\n * platform hrefs without knowing the hub's platform topology\n * (openmsp.ai / openframe.app / flamingo.run / tmcg).\n *\n * THE single content-href authority for every embeddable surface — page\n * views (onboarding catalog/detail, releases) AND chat cards / chips /\n * search results all resolve content links through this one seam, so a\n * given type lands in the SAME place regardless of where it's rendered.\n * Embedders wire `makeComposeContentUrl({ hostedTypes, contentOrigin })`;\n * omit it and lib views fall back to a same-origin relative path\n * (`buildDefaultHref`).\n *\n * Takes a single `ComposeContentUrlInput`: `type` + `identifier` (page\n * views pass the slug; chat rows pass the id + `externalUrl`, whose path\n * yields the slug for in-app routing) + optional `platforms` /\n * `externalUrl` / `targetPlatform`. */\n composeContentUrl?: ComposeContentUrl\n /** Per-`documentType` doc-viewer targets — the UNIFIED, DYNAMIC replacement for\n * the single `chipBasePlatform` prop. Maps a doc-table documentType\n * (`'markdown'`, `'data_room_doc'`, …) → `{ platform, basePath }` for the PUBLIC\n * doc viewer that hosts it. Doc chips with no `externalUrl` resolve PER ROW to\n * `getBaseUrl(platform)/<basePath>/<path>`, so a chat mixing several doc sources\n * sends EACH to its own home (markdown→flamingo/knowledge-base,\n * data_room_doc→company-hub/data-room) instead of one static fallback. The hub\n * may keep using `chipBasePlatform` (one doc source per platform); embedders that\n * surface multiple doc sources wire this. Threaded into `resolveSourceRowCTA`. */\n docPlatformTargets?: Record<string, { platform: string; basePath: string }>\n /** Chat source / platform identifier — OPTIONAL. The hub sets it from\n * `currentPlatform()`; EMBEDDERS leave it unset and stay platform-agnostic.\n *\n * It is NOT required for chat to work. The wire resolves source server-side\n * (`/docs/chat|search|commands` reject any client `source`); the\n * same-tab-vs-new-tab link decision falls back to an origin comparison when\n * it's absent (`decideNewTab` → `isCrossOriginUrl`); and the localStorage\n * history namespace falls back to a stable constant. Set it only where the\n * client legitimately needs to know its platform a priori — i.e. the hub,\n * where several platforms share related origins so \"same platform\" can't be\n * inferred from a URL alone. */\n source?: string\n // NOTE: No `user` field. The chat's display identity (greeting\n // first-name, etc.) comes from the SERVER-resolved auth via\n // `useChatIdentity()` — the same identity the server uses to\n // authorize requests. Letting embedders pass a client-side `user`\n // would let it desync from the actual auth tier, causing greetings\n // like \"Hey Bob\" while the server treats the session as\n // alice@example.com. Single source of truth: the server.\n}\n\nexport const ChatRuntimeContext = createContext<ChatRuntime | null>(null)\n\n/**\n * Returns the active runtime, or null when no provider is mounted.\n * NULL is a first-class value — it signals \"no chat runtime configured.\"\n * Optional consumers fall back to no-op behavior; strict consumers\n * use `useRequiredChatRuntime` (below).\n */\nexport function useChatRuntime(): ChatRuntime | null {\n return useContext(ChatRuntimeContext)\n}\n\n/**\n * Strict variant used INSIDE the chat panel. Throws if no provider.\n * The hub guarantees one exists by mounting `<HubRuntimeProvider>` at\n * root; the embedded app mounts its own `<ChatRuntimeContext.Provider>`\n * at the tree root. In Jest / Storybook tests that render chat\n * internals directly, wrap with `<HubRuntimeProvider>` (hub defaults)\n * or supply `<ChatRuntimeContext.Provider value={mockedRuntime}>`.\n */\nexport function useRequiredChatRuntime(): ChatRuntime {\n const v = useContext(ChatRuntimeContext)\n if (!v) {\n throw new Error(\n '[chat-runtime] hook called outside a <ChatRuntimeContext.Provider>. ' +\n 'The hub mounts <HubRuntimeProvider> at root — this only fires when ' +\n 'chat internals are rendered above the provider tree. ' +\n 'Fix: ensure the rendering subtree descends from the runtime provider. ' +\n 'In tests/Storybook: wrap with <HubRuntimeProvider> or supply ' +\n 'a <ChatRuntimeContext.Provider value={mockedRuntime}>.',\n )\n }\n return v\n}\n"]}