@flamingo-stack/openframe-frontend-core 0.0.828 → 0.0.830

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 (166) hide show
  1. package/dist/build/export-map.json +1 -1
  2. package/dist/{chunk-DU6AF77X.cjs → chunk-2BGLALP5.cjs} +14 -14
  3. package/dist/{chunk-QMQWXGCH.cjs → chunk-56EP4QM2.cjs} +29 -25
  4. package/dist/{chunk-4ZH7RPEA.cjs → chunk-5KSPG3TV.cjs} +388 -388
  5. package/dist/{chunk-BGT6JFMP.cjs → chunk-5LED4QHZ.cjs} +527 -434
  6. package/dist/{chunk-6ZLCEIIC.cjs → chunk-CAGQAMJ6.cjs} +23 -23
  7. package/dist/{chunk-ALRX2VIY.cjs → chunk-D2LXFMZI.cjs} +26 -26
  8. package/dist/{chunk-VAIML6YU.cjs → chunk-DUGOOTER.cjs} +13 -13
  9. package/dist/{chunk-XPF74L76.cjs → chunk-E6W4YDPS.cjs} +2 -2
  10. package/dist/{chunk-UULSSD56.cjs → chunk-FFFN4IY2.cjs} +5 -5
  11. package/dist/{chunk-UWGPYAB3.cjs → chunk-HYCMMECU.cjs} +51 -51
  12. package/dist/{chunk-DR4P7AEU.cjs → chunk-HYGWRUEM.cjs} +3 -3
  13. package/dist/chunk-IX2E3AN7.cjs +77 -0
  14. package/dist/{chunk-YKUL6JBI.cjs → chunk-M75723HD.cjs} +46 -34
  15. package/dist/{chunk-RPKWEBHC.cjs → chunk-PUXYAHH3.cjs} +3 -3
  16. package/dist/{chunk-3B6ZE4EZ.cjs → chunk-QTLWU6FY.cjs} +5 -5
  17. package/dist/{chunk-3WKQ2GCR.cjs → chunk-RRPID7Z7.cjs} +6 -8
  18. package/dist/{chunk-6SFCI6D4.cjs → chunk-SAW7V7CU.cjs} +14 -16
  19. package/dist/{chunk-B5H7RKFF.cjs → chunk-TUMSVFVS.cjs} +4 -4
  20. package/dist/{chunk-7VC5FVWT.cjs → chunk-ULF4ZOUM.cjs} +65 -65
  21. package/dist/{chunk-ZT7JHN7G.cjs → chunk-WCCE4WF3.cjs} +57 -62
  22. package/dist/{chunk-7PZQ7SHB.cjs → chunk-WWDNLMB7.cjs} +16 -16
  23. package/dist/{chunk-K6X7VP2Y.cjs → chunk-WZYBUJJG.cjs} +43 -43
  24. package/dist/{chunk-SVCTAOJR.cjs → chunk-X425BGXS.cjs} +2 -2
  25. package/dist/{chunk-BIG3O33P.cjs → chunk-YJZ7R3W5.cjs} +28 -2
  26. package/dist/{cloud-tenants-LKTWIZNS.cjs → cloud-tenants-4KQQPXPM.cjs} +12 -11
  27. package/dist/components/case-studies/index.cjs +24 -23
  28. package/dist/components/chat/assistant-ask-prompts.d.ts +5 -1
  29. package/dist/components/chat/assistant-ask-prompts.d.ts.map +1 -1
  30. package/dist/components/chat/assistant-ask-prompts.js +3 -1
  31. package/dist/components/chat/embeddable-chat.d.ts +3 -3
  32. package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
  33. package/dist/components/chat/embeddable-chat.js +22 -14
  34. package/dist/components/chat/guide-welcome.d.ts +14 -16
  35. package/dist/components/chat/guide-welcome.d.ts.map +1 -1
  36. package/dist/components/chat/guide-welcome.js +9 -24
  37. package/dist/components/chat/hooks/use-empty-state-config.d.ts +13 -3
  38. package/dist/components/chat/hooks/use-empty-state-config.d.ts.map +1 -1
  39. package/dist/components/chat/hooks/use-empty-state-config.js +10 -2
  40. package/dist/components/chat/index.cjs +13 -5
  41. package/dist/components/chat/mingo-quick-action-wall.d.ts +42 -16
  42. package/dist/components/chat/mingo-quick-action-wall.d.ts.map +1 -1
  43. package/dist/components/chat/mingo-quick-action-wall.js +105 -19
  44. package/dist/components/chat/mingo-welcome.d.ts +6 -13
  45. package/dist/components/chat/mingo-welcome.d.ts.map +1 -1
  46. package/dist/components/chat/mingo-welcome.js +5 -9
  47. package/dist/components/chat/quick-action-chip.d.ts +8 -2
  48. package/dist/components/chat/quick-action-chip.d.ts.map +1 -1
  49. package/dist/components/chat/quick-action-chip.js +18 -8
  50. package/dist/components/contact/index.cjs +13 -12
  51. package/dist/components/docs/index.cjs +16 -15
  52. package/dist/components/embeds/index.cjs +13 -12
  53. package/dist/components/faq/faq-ask-card.d.ts +2 -13
  54. package/dist/components/faq/faq-ask-card.d.ts.map +1 -1
  55. package/dist/components/faq/faq-ask-card.js +1 -2
  56. package/dist/components/faq/faq-document-page.d.ts +2 -4
  57. package/dist/components/faq/faq-document-page.d.ts.map +1 -1
  58. package/dist/components/faq/faq-document-page.js +0 -2
  59. package/dist/components/faq/faq-section.d.ts +16 -29
  60. package/dist/components/faq/faq-section.d.ts.map +1 -1
  61. package/dist/components/faq/faq-section.js +23 -15
  62. package/dist/components/faq/index.cjs +14 -13
  63. package/dist/components/faq/index.d.ts +1 -1
  64. package/dist/components/faq/index.d.ts.map +1 -1
  65. package/dist/components/faq/index.js +2 -2
  66. package/dist/components/features/index.cjs +12 -11
  67. package/dist/components/help-center-pages/delivery-page.d.ts +1 -8
  68. package/dist/components/help-center-pages/delivery-page.d.ts.map +1 -1
  69. package/dist/components/help-center-pages/delivery-page.js +4 -16
  70. package/dist/components/help-center-pages/download-apps-page.d.ts +1 -8
  71. package/dist/components/help-center-pages/download-apps-page.d.ts.map +1 -1
  72. package/dist/components/help-center-pages/download-apps-page.js +3 -4
  73. package/dist/components/help-center-pages/index.cjs +123 -171
  74. package/dist/components/help-center-pages/onboarding-guides-catalog-page.d.ts +1 -8
  75. package/dist/components/help-center-pages/onboarding-guides-catalog-page.d.ts.map +1 -1
  76. package/dist/components/help-center-pages/onboarding-guides-catalog-page.js +14 -26
  77. package/dist/components/help-center-pages/product-releases-list-page.d.ts +1 -8
  78. package/dist/components/help-center-pages/product-releases-list-page.d.ts.map +1 -1
  79. package/dist/components/help-center-pages/product-releases-list-page.js +12 -24
  80. package/dist/components/help-center-pages/roadmap-page.d.ts +1 -8
  81. package/dist/components/help-center-pages/roadmap-page.d.ts.map +1 -1
  82. package/dist/components/help-center-pages/roadmap-page.js +13 -25
  83. package/dist/components/help-center-pages/trust-center-page.d.ts +1 -1
  84. package/dist/components/help-center-pages/trust-center-page.d.ts.map +1 -1
  85. package/dist/components/index.cjs +58 -49
  86. package/dist/components/index.d.ts +1 -0
  87. package/dist/components/index.d.ts.map +1 -1
  88. package/dist/components/index.js +1 -0
  89. package/dist/components/meeting-scheduler/index.cjs +50 -49
  90. package/dist/components/navigation/index.cjs +15 -14
  91. package/dist/components/onboarding-guides/index.cjs +14 -13
  92. package/dist/components/page-topic-label.d.ts +13 -0
  93. package/dist/components/page-topic-label.d.ts.map +1 -0
  94. package/dist/components/page-topic-label.js +20 -0
  95. package/dist/components/product-demo/index.cjs +23 -22
  96. package/dist/components/shared/dev-section/dev-section-page.d.ts +1 -8
  97. package/dist/components/shared/dev-section/dev-section-page.d.ts.map +1 -1
  98. package/dist/components/shared/dev-section/dev-section-page.js +2 -3
  99. package/dist/components/shared/legal-document/legal-document-page.d.ts +2 -10
  100. package/dist/components/shared/legal-document/legal-document-page.d.ts.map +1 -1
  101. package/dist/components/shared/legal-document/legal-document-page.js +2 -5
  102. package/dist/components/shared/legal-document/use-legal-documents.d.ts +0 -2
  103. package/dist/components/shared/legal-document/use-legal-documents.d.ts.map +1 -1
  104. package/dist/components/shared/legal-document/use-legal-documents.js +0 -1
  105. package/dist/components/tickets/index.cjs +17 -16
  106. package/dist/components/ui/actions-menu.d.ts.map +1 -1
  107. package/dist/components/ui/actions-menu.js +27 -1
  108. package/dist/components/ui/index.cjs +18 -11
  109. package/dist/contexts/endpoints-runtime-context.d.ts +5 -0
  110. package/dist/contexts/endpoints-runtime-context.d.ts.map +1 -1
  111. package/dist/contexts/index.cjs +10 -1
  112. package/dist/contexts/index.d.ts +1 -0
  113. package/dist/contexts/index.d.ts.map +1 -1
  114. package/dist/contexts/index.js +4 -0
  115. package/dist/contexts/page-topics-context.d.ts +30 -0
  116. package/dist/contexts/page-topics-context.d.ts.map +1 -0
  117. package/dist/contexts/page-topics-context.js +27 -0
  118. package/dist/{devices-JWG72ANF.cjs → devices-H6C4NMIY.cjs} +13 -12
  119. package/dist/{embeddable-chat-5UT6UHEO.cjs → embeddable-chat-KUESE7P6.cjs} +107 -97
  120. package/dist/hooks/index.cjs +3 -3
  121. package/dist/index.cjs +33 -15
  122. package/dist/{knowledge-DQXVSHME.cjs → knowledge-O6IBO5Y5.cjs} +13 -12
  123. package/dist/{logs-Z33VBTVX.cjs → logs-Y2UCF24Z.cjs} +19 -18
  124. package/dist/{policies-XE4UMH6Z.cjs → policies-J6O3RLJT.cjs} +16 -15
  125. package/dist/{remote-session-QGFG5WAL.cjs → remote-session-RVTFWSU4.cjs} +5 -5
  126. package/dist/{scripts-MECQG5GG.cjs → scripts-N67MM4T2.cjs} +19 -18
  127. package/dist/{software-update-PCSIA6BP.cjs → software-update-HB7F6KNG.cjs} +16 -15
  128. package/dist/{tickets-board-KCH6ITUV.cjs → tickets-board-2K3PBCNW.cjs} +8 -8
  129. package/dist/utils/index.cjs +46 -0
  130. package/dist/utils/index.d.ts +1 -0
  131. package/dist/utils/index.d.ts.map +1 -1
  132. package/dist/utils/index.js +12 -0
  133. package/dist/utils/page-topics.cjs +48 -0
  134. package/dist/utils/page-topics.d.ts +34 -0
  135. package/dist/utils/page-topics.d.ts.map +1 -0
  136. package/dist/utils/page-topics.js +46 -0
  137. package/package.json +7 -1
  138. package/src/components/chat/assistant-ask-prompts.tsx +8 -2
  139. package/src/components/chat/embeddable-chat.tsx +32 -45
  140. package/src/components/chat/guide-welcome.tsx +28 -49
  141. package/src/components/chat/hooks/use-empty-state-config.ts +22 -5
  142. package/src/components/chat/mingo-quick-action-wall.tsx +166 -31
  143. package/src/components/chat/mingo-welcome.tsx +16 -35
  144. package/src/components/chat/quick-action-chip.tsx +32 -8
  145. package/src/components/faq/faq-ask-card.tsx +2 -12
  146. package/src/components/faq/faq-document-page.tsx +1 -5
  147. package/src/components/faq/faq-section.tsx +47 -50
  148. package/src/components/faq/index.ts +1 -2
  149. package/src/components/help-center-pages/delivery-page.tsx +1 -16
  150. package/src/components/help-center-pages/download-apps-page.tsx +2 -9
  151. package/src/components/help-center-pages/onboarding-guides-catalog-page.tsx +1 -16
  152. package/src/components/help-center-pages/product-releases-list-page.tsx +1 -16
  153. package/src/components/help-center-pages/roadmap-page.tsx +1 -16
  154. package/src/components/help-center-pages/trust-center-page.tsx +1 -1
  155. package/src/components/index.ts +1 -0
  156. package/src/components/page-topic-label.tsx +30 -0
  157. package/src/components/shared/dev-section/dev-section-page.tsx +2 -9
  158. package/src/components/shared/legal-document/legal-document-page.tsx +3 -13
  159. package/src/components/shared/legal-document/use-legal-documents.ts +0 -3
  160. package/src/components/ui/actions-menu.tsx +35 -1
  161. package/src/contexts/endpoints-runtime-context.tsx +5 -0
  162. package/src/contexts/index.ts +1 -0
  163. package/src/contexts/page-topics-context.tsx +68 -0
  164. package/src/utils/index.ts +8 -0
  165. package/src/utils/page-topics.ts +81 -0
  166. package/dist/{chunk-IKWQW3YJ.cjs → chunk-AY6XJOIN.cjs} +4 -4
@@ -190,7 +190,7 @@ const MenuItem: React.FC<MenuItemProps> = ({ item, onItemClick }) => {
190
190
  ROW_CLASSES,
191
191
  item.disabled
192
192
  ? 'pointer-events-none cursor-not-allowed text-ods-text-secondary opacity-60'
193
- : 'text-ods-text-primary hover:bg-ods-bg-hover',
193
+ : 'text-ods-text-primary hover:bg-ods-bg-hover focus-visible:bg-ods-bg-hover',
194
194
  );
195
195
 
196
196
  const subTriggerClasses = cn(itemClasses, 'focus:bg-ods-bg-hover data-[state=open]:bg-ods-bg-active');
@@ -306,6 +306,20 @@ const MenuItem: React.FC<MenuItemProps> = ({ item, onItemClick }) => {
306
306
  );
307
307
  };
308
308
 
309
+ /** The rows a keyboard moves between in an open menu: every enabled `menuitem` (plain, radio, submenu trigger). */
310
+ function menuRows(content: HTMLElement | null): HTMLElement[] {
311
+ if (!content) return [];
312
+ return [...content.querySelectorAll<HTMLElement>('[role^="menuitem"]:not([aria-disabled="true"])')];
313
+ }
314
+
315
+ /** The menu-button keys (WAI-ARIA APG, "Menu Button"): ↓/↑ move between rows (wrapping), Home/End jump to the ends. */
316
+ const MENU_ROW_KEYS: Record<string, (index: number, count: number) => number> = {
317
+ ArrowDown: (index, count) => (index + 1) % count,
318
+ ArrowUp: (index, count) => (index - 1 + count) % count,
319
+ Home: () => 0,
320
+ End: (_index, count) => count - 1,
321
+ };
322
+
309
323
  const GroupSeparator: React.FC = () => <div className="h-[3px] w-full bg-ods-bg-surface" />;
310
324
 
311
325
  export const ActionsMenu: React.FC<ActionsMenuProps> = ({ groups, className = '', onItemClick, header }) => {
@@ -407,6 +421,14 @@ export const ActionsMenuDropdown: React.FC<ActionsMenuDropdownProps> = ({
407
421
  // momentum and the ~1px settle after opening don't close the menu the
408
422
  // user is reaching for.
409
423
  const triggerRef = React.useRef<HTMLButtonElement | null>(null);
424
+ const contentRef = React.useRef<HTMLDivElement | null>(null);
425
+ // On open, focus goes to the first row (WAI-ARIA APG, "Menu Button"). The rows are not Radix items, so Radix only
426
+ // focuses the menu itself; one frame later, once it has, the first row takes focus.
427
+ React.useEffect(() => {
428
+ if (!open) return undefined;
429
+ const frame = requestAnimationFrame(() => menuRows(contentRef.current)[0]?.focus());
430
+ return () => cancelAnimationFrame(frame);
431
+ }, [open]);
410
432
  React.useEffect(() => {
411
433
  if (!open) return undefined;
412
434
  if (typeof document === 'undefined') return undefined;
@@ -461,9 +483,21 @@ export const ActionsMenuDropdown: React.FC<ActionsMenuDropdownProps> = ({
461
483
  {triggerNode}
462
484
  </DropdownMenuTrigger>
463
485
  <DropdownMenuContent
486
+ ref={contentRef}
464
487
  align={align}
465
488
  side={side}
466
489
  sideOffset={sideOffset}
490
+ // The rows are this menu's own, not Radix items, so Radix does not move between them: the menu-button
491
+ // pattern's keys are done here, and the first row takes focus on open (the effect above).
492
+ onKeyDown={event => {
493
+ const move = MENU_ROW_KEYS[event.key];
494
+ if (!move) return;
495
+ const rows = menuRows(contentRef.current);
496
+ if (rows.length === 0) return;
497
+ event.preventDefault();
498
+ const current = rows.indexOf(document.activeElement as HTMLElement);
499
+ rows[move(Math.max(current, 0), rows.length)]?.focus();
500
+ }}
467
501
  onCloseAutoFocus={onCloseAutoFocus}
468
502
  className={cn('overflow-visible border-0 bg-transparent p-0 shadow-none', contentClassName)}
469
503
  >
@@ -45,6 +45,11 @@ export interface EndpointsRuntime {
45
45
  * without the proxy simply omits it and claude embeds fall back to
46
46
  * claude.ai — no probing happens. */
47
47
  storageViewBaseUrl?: string;
48
+ /** GET the host's FAQ list (the hub's `/api/faqs`). Every `FaqSection` reads its questions from it, and a shared
49
+ * page of the lib (roadmap, delivery, releases, onboarding guides, downloads, legal documents) draws its own FAQ
50
+ * block from it, for the page's topic (`usePageTopic`). OPTIONAL: a host whose layout draws every page's FAQ itself
51
+ * (the hub) leaves it unset, and `FaqSection` then asks the same-origin `/api/faqs`. */
52
+ faqsUrl?: string;
48
53
  }
49
54
 
50
55
  export const EndpointsRuntimeContext = createContext<EndpointsRuntime | null>(null);
@@ -38,5 +38,6 @@ export {
38
38
  type AssistantOpenRequest,
39
39
  type AssistantRuntime,
40
40
  } from './assistant-runtime-context';
41
+ export { PageTopicsProvider, usePageTopic, usePageTopicStamp } from './page-topics-context';
41
42
 
42
43
  export { useOuterOrDefault } from './use-outer-or-default';
@@ -0,0 +1,68 @@
1
+ 'use client';
2
+
3
+ import { createContext, useContext, useMemo, type ReactNode } from 'react';
4
+ import { usePathname } from '../embed-shims/next-navigation';
5
+ import { pageTopicFor } from '../utils/page-topics';
6
+
7
+ /**
8
+ * Page topics for a host (`utils/page-topics`): a page's topic is its own path,
9
+ * so a host gives no map, only where it mounts the hub's pages, ONCE at the
10
+ * root. Every surface that offers something for "this page" (the FAQ block, its
11
+ * ask card, the chat's quick actions) reads the page's topic from the address
12
+ * through it (`usePageTopic`); none takes a topic prop.
13
+ */
14
+ interface PageTopicsValue {
15
+ /** Where the host mounts the hub's pages (`/help-center`). */
16
+ basePath?: string;
17
+ /** The address to read, where the router's answer is not the page's. */
18
+ pathname?: string;
19
+ /** Whether surfaces print the page's topic stamp (`PageTopicLabel`) by default. */
20
+ showTopic: boolean;
21
+ }
22
+
23
+ const PageTopicsContext = createContext<PageTopicsValue | null>(null);
24
+
25
+ export interface PageTopicsProviderProps {
26
+ /**
27
+ * Where the host mounts the hub's pages (`/help-center`): a page under it asks
28
+ * with its path without the mount, the hub page it mirrors. Absent: the
29
+ * enclosing provider's, else the pages sit at the root.
30
+ */
31
+ basePath?: string;
32
+ /**
33
+ * The page's address, for a subtree the router answers another path for (a
34
+ * layout slot prerendered for one page and shown on another until it
35
+ * hydrates). Absent: the router's (`usePathname`).
36
+ */
37
+ pathname?: string;
38
+ /**
39
+ * Print the page's topic stamp (`PageTopicLabel`) on every surface that can
40
+ * show it (the FAQ block, the chat's quick actions), for whoever edits FAQs
41
+ * and quick actions. ONE host decision, made at the root; a surface's own
42
+ * `showTopic` prop still overrides it. Absent: the enclosing provider's
43
+ * choice, else off.
44
+ */
45
+ showTopic?: boolean;
46
+ children: ReactNode;
47
+ }
48
+
49
+ export function PageTopicsProvider({ basePath, pathname, showTopic, children }: PageTopicsProviderProps) {
50
+ const inherited = useContext(PageTopicsContext);
51
+ const base = basePath ?? inherited?.basePath;
52
+ const stamp = showTopic ?? inherited?.showTopic ?? false;
53
+ const value = useMemo(() => ({ basePath: base, pathname, showTopic: stamp }), [base, pathname, stamp]);
54
+ return <PageTopicsContext.Provider value={value}>{children}</PageTopicsContext.Provider>;
55
+ }
56
+
57
+ /** The topic of the page on screen: its path (`pageTopicFor`). Undefined where the host gave no provider. */
58
+ export function usePageTopic(): string | undefined {
59
+ const value = useContext(PageTopicsContext);
60
+ const routerPathname = usePathname();
61
+ if (!value) return undefined;
62
+ return pageTopicFor(value.pathname ?? routerPathname ?? '/', { basePath: value.basePath });
63
+ }
64
+
65
+ /** Whether the host asked surfaces to print the page's topic stamp (`PageTopicsProvider showTopic`). */
66
+ export function usePageTopicStamp(): boolean {
67
+ return useContext(PageTopicsContext)?.showTopic ?? false;
68
+ }
@@ -378,6 +378,14 @@ export { buildListUrl, canonicalContentRefType } from './list-url';
378
378
  // zero drift across page + chat + future consumers.
379
379
  export { faqSectionSlug, faqItemAnchor, parseFaqHash } from './faq-anchor';
380
380
  export type { FaqHashTarget } from './faq-anchor';
381
+ export {
382
+ deepestTopic,
383
+ isPagePathTopic,
384
+ pageTopicFor,
385
+ type PageTopicOptions,
386
+ topicCandidates,
387
+ topicMatchesPath,
388
+ } from './page-topics';
381
389
 
382
390
  // Content-ref group registry (labels/order/layout per rail type) + list-API
383
391
  // response normalizers + the shared suggestion-fetch URL composer — all
@@ -0,0 +1,81 @@
1
+ /**
2
+ * THE topic of a page is its own path: one rule for every surface that offers
3
+ * something "for this page" (the FAQ block, its "ask the assistant" card, the
4
+ * chat's quick actions). No host keeps a route to topic map: FAQs and quick
5
+ * actions are tagged with the paths of the pages they are written for.
6
+ *
7
+ * - A page asks with its path: query and hash dropped, trailing slash dropped,
8
+ * lowercased, decoded (`/Blog/My-Post/?x` asks `/blog/my-post`).
9
+ * - A host that mounts the hub's pages under a path states it (`basePath`):
10
+ * `/help-center/roadmap` asks `/roadmap`, the hub page it mirrors. A path
11
+ * outside the mount is asked as it is (`/devices`).
12
+ * - A tag is written for a page when it is the page's path or a parent of it
13
+ * (`/blog` is written for `/blog` and `/blog/my-post`); `/` only for the home
14
+ * page. A page takes its DEEPEST matching tag (`deepestTopic`), so a record
15
+ * page shares its list page's topic until something is tagged for it alone.
16
+ *
17
+ * A zero-import leaf: a server read and the browser resolve through the same
18
+ * functions.
19
+ */
20
+
21
+ const HOME_PATH = '/';
22
+
23
+ /** A path segment decoded, or as written when its escapes are malformed (`%E0`): an address never throws. */
24
+ function decodeSegment(segment: string): string {
25
+ try {
26
+ return decodeURIComponent(segment);
27
+ } catch {
28
+ return segment;
29
+ }
30
+ }
31
+
32
+ /** A path in the one form topics are compared in: leading slash, no trailing slash, lowercased, decoded. */
33
+ function normalizePath(pathname: string): string {
34
+ const segments = (pathname.split(/[?#]/)[0] ?? '')
35
+ .split('/')
36
+ .filter(Boolean)
37
+ .map(segment => decodeSegment(segment).toLowerCase());
38
+ return segments.length === 0 ? HOME_PATH : `/${segments.join('/')}`;
39
+ }
40
+
41
+ export interface PageTopicOptions {
42
+ /** Where the host mounts the hub's pages (`/help-center`): a path under it is asked without it. */
43
+ basePath?: string;
44
+ }
45
+
46
+ /** The topic the page at `pathname` asks with: its path, without the host's mount. */
47
+ export function pageTopicFor(pathname: string, options: PageTopicOptions = {}): string {
48
+ const path = normalizePath(pathname);
49
+ const base = options.basePath ? normalizePath(options.basePath) : HOME_PATH;
50
+ if (base === HOME_PATH) return path;
51
+ if (path === base) return HOME_PATH;
52
+ return path.startsWith(`${base}/`) ? path.slice(base.length) : path;
53
+ }
54
+
55
+ /** Whether a tag names a page (a path), as opposed to a section of a page (a word). */
56
+ export function isPagePathTopic(tag: string): boolean {
57
+ return tag.startsWith(HOME_PATH);
58
+ }
59
+
60
+ /** Whether `tag` is written for the page at `path` (`pageTopicFor`'s answer): the path itself or a parent of it. */
61
+ export function topicMatchesPath(tag: string, path: string): boolean {
62
+ if (!isPagePathTopic(tag)) return tag === path;
63
+ if (tag === HOME_PATH || path === HOME_PATH) return tag === path;
64
+ return path === tag || path.startsWith(`${tag}/`);
65
+ }
66
+
67
+ /** Every tag that can be written for the page at `path`, deepest first: what a host queries its rows by. */
68
+ export function topicCandidates(path: string): string[] {
69
+ if (!isPagePathTopic(path) || path === HOME_PATH) return [path];
70
+ const segments = path.split('/').filter(Boolean);
71
+ return segments.map((_, i) => `/${segments.slice(0, segments.length - i).join('/')}`);
72
+ }
73
+
74
+ /** The deepest of `tags` written for the page at `path`, or null when none is. */
75
+ export function deepestTopic(tags: Iterable<string>, path: string): string | null {
76
+ let best: string | null = null;
77
+ for (const tag of tags) {
78
+ if (topicMatchesPath(tag, path) && (best === null || tag.length > best.length)) best = tag;
79
+ }
80
+ return best;
81
+ }
@@ -5,10 +5,6 @@ var _chunkAPOMNC7Hcjs = require('./chunk-APOMNC7H.cjs');
5
5
 
6
6
 
7
7
 
8
- var _chunk7DNL734Scjs = require('./chunk-7DNL734S.cjs');
9
-
10
-
11
-
12
8
  var _chunkMZ4KBSH7cjs = require('./chunk-MZ4KBSH7.cjs');
13
9
 
14
10
 
@@ -59,6 +55,10 @@ var _chunkSKI6NKOEcjs = require('./chunk-SKI6NKOE.cjs');
59
55
 
60
56
 
61
57
 
58
+ var _chunk7DNL734Scjs = require('./chunk-7DNL734S.cjs');
59
+
60
+
61
+
62
62
 
63
63
 
64
64
  var _chunkBLH2SFOOcjs = require('./chunk-BLH2SFOO.cjs');