@flamingo-stack/openframe-frontend-core 0.0.271 → 0.0.272

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 (78) hide show
  1. package/dist/{chunk-3DYASQEL.js → chunk-4SNHFZQT.js} +3 -3
  2. package/dist/{chunk-CICK3FUU.cjs → chunk-7NJUPRN6.cjs} +7 -2
  3. package/dist/chunk-7NJUPRN6.cjs.map +1 -0
  4. package/dist/{chunk-ICOMPUMX.js → chunk-BSOHVQ7X.js} +6 -1
  5. package/dist/chunk-BSOHVQ7X.js.map +1 -0
  6. package/dist/{chunk-YH74UZRG.cjs → chunk-EEMZBQ7O.cjs} +25 -25
  7. package/dist/{chunk-YH74UZRG.cjs.map → chunk-EEMZBQ7O.cjs.map} +1 -1
  8. package/dist/{chunk-FC6YVRUW.cjs → chunk-IXRPEMZP.cjs} +15 -15
  9. package/dist/{chunk-FC6YVRUW.cjs.map → chunk-IXRPEMZP.cjs.map} +1 -1
  10. package/dist/{chunk-J35EWU2W.js → chunk-MCCYGAPE.js} +2 -2
  11. package/dist/{chunk-P7JHUX4X.js → chunk-N5MCKGAB.js} +2 -2
  12. package/dist/{chunk-5CTV435G.cjs → chunk-Q32JUFIK.cjs} +880 -810
  13. package/dist/chunk-Q32JUFIK.cjs.map +1 -0
  14. package/dist/{chunk-56V4MC32.js → chunk-UQCB2CP7.js} +35 -6
  15. package/dist/chunk-UQCB2CP7.js.map +1 -0
  16. package/dist/{chunk-LELTRQZV.cjs → chunk-V5OZQF4B.cjs} +69 -40
  17. package/dist/chunk-V5OZQF4B.cjs.map +1 -0
  18. package/dist/{chunk-BCPLTDRW.js → chunk-VFMMVGA4.js} +3280 -3210
  19. package/dist/chunk-VFMMVGA4.js.map +1 -0
  20. package/dist/{chunk-AA77CC2Y.cjs → chunk-XDGDCO3I.cjs} +12 -12
  21. package/dist/{chunk-AA77CC2Y.cjs.map → chunk-XDGDCO3I.cjs.map} +1 -1
  22. package/dist/components/chat/entity-cards/index.d.ts +2 -0
  23. package/dist/components/chat/entity-cards/index.d.ts.map +1 -1
  24. package/dist/components/chat/entity-cards/what-i-shipped-card.d.ts +43 -0
  25. package/dist/components/chat/entity-cards/what-i-shipped-card.d.ts.map +1 -0
  26. package/dist/components/chat/index.cjs +7 -3
  27. package/dist/components/chat/index.cjs.map +1 -1
  28. package/dist/components/chat/index.js +6 -2
  29. package/dist/components/contact/index.cjs +4 -4
  30. package/dist/components/contact/index.js +3 -3
  31. package/dist/components/features/index.cjs +3 -3
  32. package/dist/components/features/index.js +2 -2
  33. package/dist/components/form.d.ts +3 -1
  34. package/dist/components/form.d.ts.map +1 -1
  35. package/dist/components/index.cjs +88 -98
  36. package/dist/components/index.cjs.map +1 -1
  37. package/dist/components/index.js +10 -20
  38. package/dist/components/index.js.map +1 -1
  39. package/dist/components/navigation/index.cjs +3 -3
  40. package/dist/components/navigation/index.js +2 -2
  41. package/dist/components/onboarding-guides/index.cjs +22 -22
  42. package/dist/components/onboarding-guides/index.js +2 -2
  43. package/dist/components/related-content/index.cjs +4 -4
  44. package/dist/components/related-content/index.js +3 -3
  45. package/dist/components/related-content/related-content-section.d.ts +13 -1
  46. package/dist/components/related-content/related-content-section.d.ts.map +1 -1
  47. package/dist/components/tickets/index.cjs +62 -62
  48. package/dist/components/tickets/index.js +4 -4
  49. package/dist/components/ui/index.cjs +7 -3
  50. package/dist/components/ui/index.cjs.map +1 -1
  51. package/dist/components/ui/index.js +6 -2
  52. package/dist/index.cjs +9 -3
  53. package/dist/index.cjs.map +1 -1
  54. package/dist/index.js +8 -2
  55. package/dist/utils/format.d.ts +8 -0
  56. package/dist/utils/format.d.ts.map +1 -1
  57. package/dist/utils/index.cjs +5 -0
  58. package/dist/utils/index.cjs.map +1 -1
  59. package/dist/utils/index.d.ts +1 -1
  60. package/dist/utils/index.d.ts.map +1 -1
  61. package/dist/utils/index.js +5 -1
  62. package/dist/utils/index.js.map +1 -1
  63. package/package.json +1 -1
  64. package/src/components/chat/chat-container.tsx +1 -1
  65. package/src/components/chat/entity-cards/index.ts +2 -0
  66. package/src/components/chat/entity-cards/what-i-shipped-card.tsx +109 -0
  67. package/src/components/related-content/related-content-section.tsx +70 -4
  68. package/src/utils/format.ts +15 -0
  69. package/src/utils/index.ts +1 -0
  70. package/dist/chunk-56V4MC32.js.map +0 -1
  71. package/dist/chunk-5CTV435G.cjs.map +0 -1
  72. package/dist/chunk-BCPLTDRW.js.map +0 -1
  73. package/dist/chunk-CICK3FUU.cjs.map +0 -1
  74. package/dist/chunk-ICOMPUMX.js.map +0 -1
  75. package/dist/chunk-LELTRQZV.cjs.map +0 -1
  76. /package/dist/{chunk-3DYASQEL.js.map → chunk-4SNHFZQT.js.map} +0 -0
  77. /package/dist/{chunk-J35EWU2W.js.map → chunk-MCCYGAPE.js.map} +0 -0
  78. /package/dist/{chunk-P7JHUX4X.js.map → chunk-N5MCKGAB.js.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flamingo-stack/openframe-frontend-core",
3
- "version": "0.0.271",
3
+ "version": "0.0.272",
4
4
  "description": "Shared design system and components for all Flamingo platforms",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -102,7 +102,7 @@ const ChatHeader = React.forwardRef<HTMLDivElement, ChatHeaderProps>(
102
102
  <Avatar
103
103
  src={userAvatar}
104
104
  alt={userName}
105
- fallback="F"
105
+ fallback={userName}
106
106
  size="xl"
107
107
  variant="round"
108
108
  className="bg-ods-flamingo-pink"
@@ -17,6 +17,8 @@ export {
17
17
  } from './entity-author-card'
18
18
  export { BlogImagePlaceholder } from './blog-image-placeholder'
19
19
  export { AdminContentCard } from './admin-content-card'
20
+ export { WhatIShippedCard, WhatIShippedCardSkeleton } from './what-i-shipped-card'
21
+ export type { WhatIShippedCardData, WhatIShippedCardProps } from './what-i-shipped-card'
20
22
 
21
23
  // Moved-into-subdir flat cards
22
24
  export { BlockCard, type BlockCardProps } from './block-card'
@@ -0,0 +1,109 @@
1
+ import React from 'react'
2
+ import { AdminContentCard } from './admin-content-card'
3
+ import { formatEntryMonthUTC } from '../../../utils/format'
4
+ import { getProxiedImageUrl } from '../../../utils/image-proxy-stub'
5
+
6
+ /** Minimal row shape the card renders. Both the hub dashboard entry and the
7
+ * related-content hydrated row satisfy it structurally. */
8
+ export interface WhatIShippedCardData {
9
+ title?: string | null
10
+ summary?: string | null
11
+ status?: string | null
12
+ featured_image?: string | null
13
+ main_video_thumbnail?: string | null
14
+ entry_month?: string | null
15
+ author?: { full_name?: string | null; avatar_url?: string | null } | null
16
+ }
17
+
18
+ export interface WhatIShippedCardProps {
19
+ entry: WhatIShippedCardData
20
+ /** OG fallback cover. Caller computes it (hub: `useOgPlaceholder`; related
21
+ * rail: `extras.buildOgPlaceholderUrl`). */
22
+ placeholderUrl?: string | null
23
+ /** Owner action row (dashboard). Omit for a read-only card. */
24
+ actions?: React.ReactNode
25
+ /** When provided, the WHOLE card becomes a link (related-rail click-through).
26
+ * Don't combine with `actions` (nested interactive). */
27
+ anchorProps?: React.AnchorHTMLAttributes<HTMLAnchorElement>
28
+ className?: string
29
+ }
30
+
31
+ const STATUS_BADGE_CLASS: Record<string, string> = {
32
+ published: 'bg-ods-success-secondary text-ods-success',
33
+ draft: 'bg-ods-warning-secondary text-ods-warning',
34
+ archived: 'bg-ods-border text-ods-text-secondary',
35
+ }
36
+
37
+ /**
38
+ * THE single "What I Shipped" card. Wraps `AdminContentCard` with the canonical
39
+ * mapping (cover = featured_image || main_video_thumbnail, OG placeholder
40
+ * fallback, title, 140-char summary, status badge, author avatar+name +
41
+ * reporting month). Used by BOTH the people-hub dashboard (with owner `actions`)
42
+ * and the related-content rail (with `anchorProps` for click-through), so the
43
+ * card is byte-identical everywhere — one component, one mapping, no drift.
44
+ */
45
+ export function WhatIShippedCard({ entry, placeholderUrl, actions, anchorProps, className }: WhatIShippedCardProps) {
46
+ const month = formatEntryMonthUTC(entry.entry_month, 'short')
47
+ const card = (
48
+ <AdminContentCard
49
+ imageUrl={entry.featured_image || entry.main_video_thumbnail}
50
+ placeholderUrl={placeholderUrl}
51
+ title={entry.title || 'Untitled entry'}
52
+ summary={(entry.summary ?? '').slice(0, 140) || 'No description'}
53
+ badges={
54
+ entry.status ? (
55
+ <span
56
+ className={`px-2 py-1 rounded text-xs font-medium ${
57
+ STATUS_BADGE_CLASS[entry.status] ?? 'bg-ods-card border border-ods-border text-ods-text-secondary'
58
+ }`}
59
+ >
60
+ {entry.status}
61
+ </span>
62
+ ) : null
63
+ }
64
+ meta={
65
+ <>
66
+ <span className="flex items-center gap-2 min-w-0">
67
+ {entry.author?.avatar_url ? (
68
+ <img src={getProxiedImageUrl(entry.author.avatar_url) ?? entry.author.avatar_url} alt="" className="h-5 w-5 rounded-full object-cover shrink-0" />
69
+ ) : null}
70
+ <span className="truncate">{entry.author?.full_name ?? ''}</span>
71
+ </span>
72
+ {month ? <span>{month}</span> : null}
73
+ </>
74
+ }
75
+ actions={actions}
76
+ className={className}
77
+ />
78
+ )
79
+ return anchorProps ? (
80
+ <a {...anchorProps} className="block h-full">
81
+ {card}
82
+ </a>
83
+ ) : (
84
+ card
85
+ )
86
+ }
87
+
88
+ /** Loading skeleton matching WhatIShippedCard's AdminContentCard shape (3:2 cover
89
+ * + title / summary / meta lines). Used by the related-content rail while a
90
+ * group hydrates so there's no shape jump when the real card lands. */
91
+ export function WhatIShippedCardSkeleton({ className }: { className?: string }) {
92
+ // Same convention as BlogCardSkeleton et al.: animate-pulse on the container,
93
+ // `bg-ods-bg` placeholder blocks, flex-grow body with an `mt-auto` avatar+name
94
+ // row. Shape mirrors WhatIShippedCard's AdminContentCard (rounded-2xl, 3:2 cover).
95
+ return (
96
+ <div className={`group bg-ods-card border border-ods-border rounded-2xl overflow-hidden h-full flex flex-col animate-pulse ${className ?? ''}`}>
97
+ <div className="aspect-[3/2] bg-ods-bg" />
98
+ <div className="p-4 flex flex-col flex-grow space-y-3">
99
+ <div className="h-5 w-3/4 bg-ods-bg rounded" />
100
+ <div className="h-3 w-full bg-ods-bg/60 rounded" />
101
+ <div className="h-3 w-4/5 bg-ods-bg/60 rounded" />
102
+ <div className="mt-auto flex items-center gap-2">
103
+ <div className="h-8 w-8 rounded-full bg-ods-bg" />
104
+ <div className="h-3 w-24 bg-ods-bg/60 rounded" />
105
+ </div>
106
+ </div>
107
+ </div>
108
+ )
109
+ }
@@ -64,6 +64,7 @@ import { decideNewTab } from '../chat/utils/decide-new-tab';
64
64
  // guarantee that matters here is the RUNTIME one: nothing on this path ever
65
65
  // instantiates a QueryClient, so embedders need NO QueryClientProvider.
66
66
  import { BlogCard, BlogCardSkeleton } from '../chat/entity-cards/blog-card';
67
+ import { WhatIShippedCard, WhatIShippedCardSkeleton } from '../chat/entity-cards/what-i-shipped-card';
67
68
  import { CaseStudyCard, CaseStudyCardSkeleton } from '../chat/entity-cards/case-study-card';
68
69
  import { CustomerInterviewCard, CustomerInterviewCardSkeleton } from '../chat/entity-cards/customer-interview-card';
69
70
  import { ProductReleaseCard, ProductReleaseCardSkeleton } from '../chat/entity-cards/product-release-card';
@@ -163,6 +164,9 @@ function renderSkeletonForType(
163
164
  // the step-numbered 'default' variant is for the guide detail page's
164
165
  // "More in section" rail, not this full-width row.
165
166
  return <OnboardingGuideCardSkeleton size={size === 'sm' ? 'sm' : 'catalog'} />;
167
+ case 'what_i_shipped':
168
+ // Matches the WhatIShippedCard (AdminContentCard 3:2) shape.
169
+ return <WhatIShippedCardSkeleton />;
166
170
  case 'marketing_campaign':
167
171
  return adminCampaignCard ? <adminCampaignCard.Skeleton size={legacySize} /> : null;
168
172
  case 'roadmap_item':
@@ -273,6 +277,25 @@ function CardForType({
273
277
  // Catalog variant (see skeleton note) — full-width rich card with a
274
278
  // line-clamped description instead of the step-numbered rail card.
275
279
  return <OnboardingGuideCard guide={item} size={size === 'sm' ? 'sm' : 'catalog'} href={href} targetPlatform={targetPlatform} placeholderUrl={placeholderUrl} {...anchorAttrs} />;
280
+ case 'what_i_shipped':
281
+ // THE single What I Shipped card — same lib component the people-hub
282
+ // dashboard renders, so the card is identical in the rail and the
283
+ // dashboard. `anchorProps` makes the whole card a click-through link
284
+ // (rail is read-only — no owner actions).
285
+ return (
286
+ <WhatIShippedCard
287
+ entry={item}
288
+ placeholderUrl={placeholderUrl}
289
+ // Only pass anchorProps when there's a REAL href — a fallback object
290
+ // with `href: undefined` is still truthy and would make WhatIShippedCard
291
+ // wrap the card in a dead <a> (no URL). Mirrors the ProductReleaseCard
292
+ // `linkProps ?? undefined` pattern above.
293
+ anchorProps={
294
+ linkProps ??
295
+ (href ? ({ href, ...anchorAttrs } as React.AnchorHTMLAttributes<HTMLAnchorElement>) : undefined)
296
+ }
297
+ />
298
+ );
276
299
  case 'marketing_campaign':
277
300
  return adminCampaignCard ? <adminCampaignCard.Card campaign={item} /> : null;
278
301
  case 'roadmap_item':
@@ -586,6 +609,18 @@ export interface RelatedContentSectionProps {
586
609
  /** Renderer pair for the admin-only `marketing_campaign` type. Absent →
587
610
  * the type renders nothing. */
588
611
  adminCampaignCard?: AdminCampaignCardSlot;
612
+ /** When true, render the section shell (title + an empty-state line) even
613
+ * with ZERO refs, instead of returning null. Default false (the original
614
+ * behavior — empty rail = no shell). Opt-in per host page (e.g. people-hub's
615
+ * "What I Shipped", where the section should always be present). */
616
+ showWhenEmpty?: boolean;
617
+ /** Empty-state copy shown under the title when `showWhenEmpty` and no refs.
618
+ * Default: "No related content yet." */
619
+ emptyStateText?: string;
620
+ /** Custom empty-state node (e.g. a hub `<EmptyState/>`) rendered under the
621
+ * title when `showWhenEmpty` and there are no refs — overrides
622
+ * `emptyStateText`. Lets a host match its canonical empty state. */
623
+ emptyState?: React.ReactNode;
589
624
  }
590
625
 
591
626
  export function RelatedContentSection({
@@ -606,6 +641,9 @@ export function RelatedContentSection({
606
641
  buildListUrl,
607
642
  LinkProvider = DefaultLinkPropsProvider,
608
643
  adminCampaignCard,
644
+ showWhenEmpty = false,
645
+ emptyStateText = 'No related content yet.',
646
+ emptyState,
609
647
  }: RelatedContentSectionProps) {
610
648
  // ── Hooks above EVERY early return (the original `if (!contentRefs.length)
611
649
  // return null` guard moved below them). ──
@@ -660,7 +698,7 @@ export function RelatedContentSection({
660
698
  () => (!suggestionsDisabled && initialItems ? { refs: initialItems } : undefined),
661
699
  [initialItems, suggestionsDisabled],
662
700
  );
663
- const { data } = useSelfFetch<RelatedContentResponse>(suggestUrl, { initialData });
701
+ const { data, isLoading } = useSelfFetch<RelatedContentResponse>(suggestUrl, { initialData });
664
702
 
665
703
  // Default group fetcher: the lib's byte-parity-tested builder, prefixed for
666
704
  // embeds. Memoized so group-fetch URLs stay value-stable across renders.
@@ -677,9 +715,37 @@ export function RelatedContentSection({
677
715
  // IS the mechanism in controlled mode (original behavior).
678
716
  const exclude = new Set(excludeTypes || []);
679
717
  const visibleRefs = exclude.size > 0 ? refs.filter((r) => !exclude.has(r.type)) : refs;
680
- // Zero refs (still loading in suggestion mode, or genuinely empty) → no
681
- // empty shell.
682
- if (!visibleRefs.length) return null;
718
+ // Zero refs (still loading in suggestion mode, or genuinely empty). Default:
719
+ // no empty shell. Opt-in (`showWhenEmpty`): render the title + an empty-state
720
+ // line so the section is always present (e.g. people-hub "What I Shipped").
721
+ if (!visibleRefs.length) {
722
+ if (!showWhenEmpty) return null; // non-showWhenEmpty consumers stay blank (unchanged)
723
+ // Client-fetch loading (author/suggestion mode, no SSR initialItems): render a
724
+ // SKELETON grid — reserves height + matches the rest of the app's loading, so
725
+ // there's no blank-then-pop jump (the prior `return null` collapsed the tab to
726
+ // zero height during the fetch). SSR controlled mode has isLoading=false → it
727
+ // skips straight to the empty state below. Skeleton type = the requested rail
728
+ // type (author mode passes a single `includeTypes`).
729
+ if (isLoading) {
730
+ const skeletonType = includeTypes?.[0] ?? entityType ?? 'blog_post_existing';
731
+ return (
732
+ <div className="space-y-8">
733
+ <h2 className="text-2xl font-bold text-ods-text-primary">{title}</h2>
734
+ <div className={gridClassFor(columns)}>
735
+ {Array.from({ length: 3 }).map((_, i) => (
736
+ <div key={i}>{renderSkeletonForType(skeletonType, 'default', adminCampaignCard)}</div>
737
+ ))}
738
+ </div>
739
+ </div>
740
+ );
741
+ }
742
+ return (
743
+ <div className="space-y-8">
744
+ <h2 className="text-2xl font-bold text-ods-text-primary">{title}</h2>
745
+ {emptyState ?? <p className="text-ods-text-secondary">{emptyStateText}</p>}
746
+ </div>
747
+ );
748
+ }
683
749
 
684
750
  const grouped: Record<string, ContentRef[]> = {};
685
751
  for (const ref of visibleRefs) {
@@ -311,6 +311,21 @@ export function formatDateUTC(
311
311
  })
312
312
  }
313
313
 
314
+ /**
315
+ * Format a reporting-month value (`entry_month`) as "Mon YYYY" / "Month YYYY",
316
+ * always anchored to UTC. THE single home for the "What I Shipped" month label —
317
+ * both the lib card (`'short'`) and the hub detail page (`'long'`) call this, so
318
+ * the React #418 UTC-pin convention lives in exactly one place. Returns `null`
319
+ * for empty input (callers omit the label entirely).
320
+ */
321
+ export function formatEntryMonthUTC(
322
+ entryMonth: string | null | undefined,
323
+ style: 'short' | 'long' = 'short',
324
+ ): string | null {
325
+ if (!entryMonth) return null
326
+ return new Date(entryMonth).toLocaleDateString('en-US', { month: style, year: 'numeric', timeZone: 'UTC' })
327
+ }
328
+
314
329
  /**
315
330
  * Format a date string as `MM/DD/YYYY` for legal-document display
316
331
  * (privacy policy, terms of service). Locale-stable: always en-US.
@@ -84,6 +84,7 @@ export {
84
84
  formatDurationFromRange,
85
85
  type FormatDateUTCOptions,
86
86
  formatDateUTC,
87
+ formatEntryMonthUTC,
87
88
  formatCurrency,
88
89
  formatPercent,
89
90
  formatWholeDollars,
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/related-content/related-content-section.tsx"],"sourcesContent":["\"use client\";\n\n/**\n * RelatedContentSection\n *\n * Renders content references grouped by type using the canonical card\n * components. MOVED from the hub (`components/shared/related-content-card.tsx`)\n * so any consuming app can embed it; the hub keeps a thin wrapper that\n * pre-binds its host-specific injections (nav hook, URL recomposition,\n * program configs, admin campaign card).\n *\n * THREE data modes (precedence top-down):\n * 1. CONTROLLED — `contentRefs` provided (even `[]`): render exactly those\n * refs, no suggestion fetch (the original investor-update behavior).\n * 2. SUGGESTION — `entityType` + `entityId` provided: self-fetch\n * `GET {apiBaseUrl}/api/related-content?entityType&entityId[&count][&excludeTypes]`\n * (the generic 5-tier engine's second web service). `minResults` maps to\n * `count`; absent → param not sent (server default applies). Each ref\n * carries a `reason` (data-only — never rendered, matching the\n * FaqSection/FaqWithReason precedent).\n * 3. SSR-HYDRATED suggestion — also pass `initialItems` (the server page\n * called the engine directly); the first client fetch is skipped per the\n * `useSelfFetch` initialData contract.\n *\n * Group layout (list vs grid) + card size (lg vs default) come from\n * `CONTENT_REF_GROUPS` in `../../utils/content-ref-groups` — single source of\n * truth, no per-type logic in this file. Skeletons come from\n * `renderSkeletonForType` so the placeholder height matches the loaded card\n * exactly (zero layout shift on resolve).\n *\n * One API call per content type via the shared list-URL builder\n * (`buildListUrl` — injectable; defaults to the lib's byte-parity-tested\n * builder prefixed with `apiBaseUrl`). Fetching uses `useSelfFetch` (plain\n * fetch, NO react-query) so third-party embedders need no QueryClientProvider;\n * cards are imported via DEEP module paths (not the chat barrel) so this\n * chunk never reaches `@tanstack/react-query`.\n *\n * LOCKSTEP NOTE: this file's per-type card/skeleton dispatch is the SIZED\n * sibling of the chat-side `CHAT_CARD_REGISTRY` (`../chat/entity-cards/\n * dispatch.tsx`), which renders compact `size='sm'` cards wired to the chat\n * runtime. Two dispatchers by design — when registering a new fetch-mode\n * content type, add it BOTH there and here (cards + skeleton + list URL).\n */\n\nimport React, { useEffect, useMemo, useRef, useState } from 'react';\nimport {\n CONTENT_REF_GROUPS,\n getContentRefLabelOrTitleCase,\n orderContentRefTypes,\n type ContentRefGroupConfig,\n} from '../../utils/content-ref-groups';\nimport type { ContentRef, ContentRefWithReason } from '../../types/content-ref';\nimport { useSelfFetch } from '../../hooks/use-self-fetch';\nimport { Pagination } from '../pagination';\nimport { extractItems, extractItemId } from '../../utils/extract-items';\nimport { buildListUrl as libBuildListUrl, canonicalContentRefType } from '../../utils/list-url';\nimport { buildSuggestionUrl } from '../../utils/suggestion-url';\nimport { decideNewTab } from '../chat/utils/decide-new-tab';\n// DEEP card imports — NOT the `../chat` barrel (the barrel statically reaches\n// @tanstack/react-query via embeddable-chat + its hooks). Deep paths keep this\n// component's SOURCE graph react-query-free. Note: tsup's shared-chunk\n// splitting may still colocate the cards with chat hooks in one dist chunk\n// (react-query is a required peerDep, so resolution always succeeds) — the\n// guarantee that matters here is the RUNTIME one: nothing on this path ever\n// instantiates a QueryClient, so embedders need NO QueryClientProvider.\nimport { BlogCard, BlogCardSkeleton } from '../chat/entity-cards/blog-card';\nimport { CaseStudyCard, CaseStudyCardSkeleton } from '../chat/entity-cards/case-study-card';\nimport { CustomerInterviewCard, CustomerInterviewCardSkeleton } from '../chat/entity-cards/customer-interview-card';\nimport { ProductReleaseCard, ProductReleaseCardSkeleton } from '../chat/entity-cards/product-release-card';\nimport { buildProductReleaseCardProps } from '../chat/entity-cards/product-release-card-defaults';\nimport { ProgramCard, ProgramCardSkeleton } from '../chat/entity-cards/program-card';\nimport { InvestorUpdateCard, InvestorUpdateCardSkeleton } from '../chat/entity-cards/investor-update-card';\nimport { OnboardingGuideCard, OnboardingGuideCardSkeleton } from '../chat/entity-cards/onboarding-guide-card';\nimport { RoadmapCard, RoadmapCardSkeleton } from '../chat/entity-cards/roadmap-card';\n// Type-only — erased at build, no runtime dependency on the dispatch module.\nimport type { ChatCardDispatchExtras } from '../chat/entity-cards/dispatch';\n\ntype CardSize = 'lg' | 'default' | 'sm';\n\n/** Anchor prop bundle the per-card link surface receives — same shape the\n * hub's `useNavLink` returns and the chat dispatcher's anchor builders\n * produce. `null` = non-anchor mode (no URL). */\nexport interface CardLinkAnchorProps {\n href: string;\n target?: '_blank';\n rel?: 'noopener noreferrer';\n onClick?: (e: React.MouseEvent<HTMLAnchorElement>) => void;\n}\n\n/** Render-prop component injection for the navigation decision — keeps hook\n * calls legal (hooks live INSIDE the injected component; `CardForType`\n * itself calls zero hooks). The hub injects a `useNavLink`-backed provider;\n * the default is hook-free (pure `decideNewTab`). MUST be defined at module\n * scope by hosts — an inline arrow would remount every card each render. */\nexport interface CardLinkProviderProps {\n href: string | null;\n targetPlatform: string | null;\n children: (linkProps: CardLinkAnchorProps | null) => React.ReactElement | null;\n}\nexport type CardLinkProvider = React.ComponentType<CardLinkProviderProps>;\n\n/** Default link provider for standalone embeds: relative/-same-origin hrefs\n * stay same-tab, cross-origin pops a new tab (pure `decideNewTab` with no\n * platform context — `currentSource: ''` falls through to the origin\n * check). No router integration, no hooks. */\nfunction DefaultLinkPropsProvider({ href, targetPlatform, children }: CardLinkProviderProps): React.ReactElement | null {\n if (!href) return children(null);\n const newTab = decideNewTab({ href, targetPlatform, currentSource: '' });\n return children(\n newTab\n ? { href, target: '_blank', rel: 'noopener noreferrer' }\n : { href },\n );\n}\n\n/** Default href resolution: trust the ref's stored url/targetPlatform as the\n * API composed them. The hub overrides this with its `buildContentURL`\n * re-composition so dev gets localhost and prod gets platform domains. */\nfunction defaultResolveHref(ref: ContentRef): { href: string | null; targetPlatform: string | null } {\n return { href: ref.url || null, targetPlatform: ref.targetPlatform ?? null };\n}\n\n/** Host-injected renderer pair for the admin-only `marketing_campaign` type.\n * Absent (every non-hub embed) → the type renders nothing (its list URL\n * hits `/api/admin`, unreachable outside the hub anyway). */\nexport interface AdminCampaignCardSlot {\n Card: React.ComponentType<{ campaign: any }>;\n Skeleton: React.ComponentType<{ size?: 'default' | 'sm' }>;\n}\n\n/**\n * Per-type skeleton dispatch — returns the SAME colocated skeleton the\n * resolved card renders, sized to match (zero layout shift on resolve).\n * The chat-side `CHAT_CARD_REGISTRY` already does this via\n * `entry.skeleton()`; this surface exposes the same discipline to the\n * related-content rail.\n */\nfunction renderSkeletonForType(\n type: string,\n size: CardSize,\n adminCampaignCard?: AdminCampaignCardSlot,\n): React.ReactNode {\n // Most card skeletons accept only `{default, sm}`. `'lg'` collapses to\n // `'default'`. ProductReleaseCardSkeleton uses lg/sm pair.\n const legacySize: 'default' | 'sm' = size === 'sm' ? 'sm' : 'default';\n switch (type) {\n case 'blog_post_existing':\n return <BlogCardSkeleton size={legacySize} />;\n case 'case_study':\n return <CaseStudyCardSkeleton size={legacySize} />;\n case 'customer_interview':\n return <CustomerInterviewCardSkeleton size={legacySize} />;\n case 'product_release':\n return <ProductReleaseCardSkeleton size={size === 'sm' ? 'sm' : 'lg'} />;\n case 'podcast':\n case 'webinar':\n case 'event':\n return <ProgramCardSkeleton size={legacySize} />;\n case 'investor_update':\n return <InvestorUpdateCardSkeleton size={legacySize} />;\n case 'onboarding_guide':\n // The rich catalog variant (hero + author grid, clamped description) —\n // the step-numbered 'default' variant is for the guide detail page's\n // \"More in section\" rail, not this full-width row.\n return <OnboardingGuideCardSkeleton size={size === 'sm' ? 'sm' : 'catalog'} />;\n case 'marketing_campaign':\n return adminCampaignCard ? <adminCampaignCard.Skeleton size={legacySize} /> : null;\n case 'roadmap_item':\n case 'delivery_item':\n case 'internal_task':\n return <RoadmapCardSkeleton size={legacySize} />;\n default:\n return null;\n }\n}\n\n/**\n * Per-type card dispatch — renders the right card with the right size.\n * Sized cards (`'lg'` / `'default'`) are unique to this rail — the chat\n * dispatcher only renders `'sm'`, so we go directly through the per-type\n * cards here.\n *\n * PURE FUNCTION COMPONENT WITH ZERO HOOK CALLS: the placeholder comes from a\n * plain `extras.buildOgPlaceholderUrl` call (the chat `dispatch.tsx`\n * pattern) and the anchor-prop bundle arrives via the `LinkProvider`\n * render-prop from the parent — so per-card hook legality is owned by the\n * injected provider component, not by this switch.\n *\n * `href` comes from the host's `resolveHref(ref)` (hub: live\n * `buildContentURL` recomposition; default: the ref's stored url).\n */\nfunction CardForType({\n type,\n item,\n size,\n href,\n targetPlatform,\n linkProps,\n extras,\n adminCampaignCard,\n}: {\n type: string;\n item: any;\n size: CardSize;\n href: string;\n targetPlatform: string | null;\n linkProps: CardLinkAnchorProps | null;\n extras?: ChatCardDispatchExtras;\n adminCampaignCard?: AdminCampaignCardSlot;\n}): React.ReactNode {\n // Most card variants accept only `{default, sm}`. `'lg'` collapses to\n // `'default'` for those. ProductReleaseCard uses its own lg/sm pair.\n const legacySize: 'default' | 'sm' = size === 'sm' ? 'sm' : 'default';\n // OG placeholder URL — injected into the pure-presentation cards so they\n // render a branded fallback when the row's featured image is null. Plain\n // function call (NOT a hook). Title is the universal field across all card\n // item shapes used here.\n const placeholderUrl =\n extras?.buildOgPlaceholderUrl?.((item?.title as string | undefined) ?? '') ?? undefined;\n\n // Top-level target/rel for cards that take them as separate props\n // (BlogCard, CaseStudyCard, …). ProductReleaseCard takes the bundle as a\n // single `anchorProps={...}` and uses `linkProps` directly. When the host\n // didn't surface a URL, `linkProps` is null and the card stays in\n // non-anchor mode.\n const anchorAttrs: Pick<CardLinkAnchorProps, 'target' | 'rel'> = linkProps\n ? { target: linkProps.target, rel: linkProps.rel }\n : {};\n\n switch (type) {\n case 'blog_post_existing':\n return <BlogCard post={item} size={legacySize} href={href} targetPlatform={targetPlatform} placeholderUrl={placeholderUrl} {...anchorAttrs} />;\n case 'case_study':\n return <CaseStudyCard study={item} size={legacySize} href={href} targetPlatform={targetPlatform} placeholderUrl={placeholderUrl} {...anchorAttrs} />;\n case 'customer_interview':\n return <CustomerInterviewCard interview={item} size={legacySize} href={href} targetPlatform={targetPlatform} placeholderUrl={placeholderUrl} {...anchorAttrs} />;\n case 'product_release': {\n // Anchor-prop pattern: build product-release lg-variant props from the\n // shared `buildProductReleaseCardProps` so this rail and the /releases\n // catalog page render byte-identically. The card wraps in\n // `<a {...anchorProps}>` ONLY when `anchorProps.href` is set — pass\n // `undefined` (not an empty object) when href is empty so the card\n // stays in non-anchor mode without rendering a dead <a> tag.\n const releaseSize = size === 'sm' ? 'sm' : 'lg';\n const buildReleaseProps = extras?.buildProductReleaseCardProps ?? buildProductReleaseCardProps;\n const releaseProps = buildReleaseProps(item);\n return (\n <ProductReleaseCard\n size={releaseSize}\n title={item.title}\n summary={item.summary}\n version={item.version}\n {...releaseProps}\n anchorProps={linkProps ?? undefined}\n />\n );\n }\n case 'podcast':\n return extras?.programConfigs?.podcast\n ? <ProgramCard config={extras.programConfigs.podcast} item={item} size={legacySize} href={href} targetPlatform={targetPlatform} placeholderUrl={placeholderUrl} {...anchorAttrs} />\n : null;\n case 'webinar':\n return extras?.programConfigs?.webinar\n ? <ProgramCard config={extras.programConfigs.webinar} item={item} size={legacySize} href={href} targetPlatform={targetPlatform} placeholderUrl={placeholderUrl} {...anchorAttrs} />\n : null;\n case 'event':\n return extras?.programConfigs?.event\n ? <ProgramCard config={extras.programConfigs.event} item={item} size={legacySize} href={href} targetPlatform={targetPlatform} placeholderUrl={placeholderUrl} {...anchorAttrs} />\n : null;\n case 'investor_update':\n return <InvestorUpdateCard update={item} size={legacySize} href={href} targetPlatform={targetPlatform} placeholderUrl={placeholderUrl} {...anchorAttrs} />;\n case 'onboarding_guide':\n // Catalog variant (see skeleton note) — full-width rich card with a\n // line-clamped description instead of the step-numbered rail card.\n return <OnboardingGuideCard guide={item} size={size === 'sm' ? 'sm' : 'catalog'} href={href} targetPlatform={targetPlatform} placeholderUrl={placeholderUrl} {...anchorAttrs} />;\n case 'marketing_campaign':\n return adminCampaignCard ? <adminCampaignCard.Card campaign={item} /> : null;\n case 'roadmap_item':\n case 'delivery_item':\n case 'internal_task':\n return (\n <RoadmapCard\n item={item}\n href={href ?? ''}\n targetPlatform={targetPlatform}\n userVote={null}\n onVote={() => {}}\n size={legacySize}\n cardType={type as 'roadmap_item' | 'delivery_item' | 'internal_task'}\n {...anchorAttrs}\n />\n );\n default:\n return null;\n }\n}\n\n// =============================================================================\n// Fetch all items for a type in ONE server-sorted call, via the injectable\n// list-URL builder. `useSelfFetch` (URL = cache key) replaces the hub's old\n// react-query usage: `enabled` ≙ `url === null`, `!res.ok`/network error ≙\n// `error → items null → group renders nothing`. Accepted deltas vs\n// react-query: no retry/backoff, no focus refetch, no cross-mount cache.\n// =============================================================================\n\nfunction useGroupItems(\n type: string,\n refs: ContentRef[],\n buildUrl: (type: string, ids: string[]) => string | null,\n) {\n const ids = refs.map((r) => r.id);\n const url = ids.length > 0 ? buildUrl(type, ids) : null;\n const { data, isLoading } = useSelfFetch<unknown>(url);\n const items = data != null ? extractItems(data) : null;\n return { items, isLoading };\n}\n\n// =============================================================================\n// Per-group renderer — one API call, server-sorted, then render cards via the\n// dispatcher with per-type skeletons + per-type layout from CONTENT_REF_GROUPS.\n// =============================================================================\n\n/** Map columns prop → tailwind grid class. Only consulted for grid-layout\n * groups; list-layout groups stack vertically. */\nfunction gridClassFor(columns: 2 | 3): string {\n return columns === 3\n ? 'grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6'\n : 'grid grid-cols-1 sm:grid-cols-2 gap-6';\n}\n\n/** Resolve the group config for a type, falling back to a grid layout with\n * the default card size for unregistered types so the section still renders\n * rather than silently dropping them. The `label` field on the fallback is\n * intentionally a placeholder — the section heading goes through\n * `getContentRefLabelOrTitleCase(type)` instead so cross-surface labels\n * stay consistent between this rail and the investor-email builder. */\nfunction resolveGroupConfig(type: string): ContentRefGroupConfig {\n return CONTENT_REF_GROUPS[type] ?? {\n label: type,\n order: 999,\n layout: 'grid',\n gridSize: 'default',\n };\n}\n\n/** Items per page within one type group. Groups larger than this paginate\n * with the standard Pagination control (NO nested scrolling — a bounded\n * scrollbox inside the page traps wheel events and hides the sections\n * below it). MUST stay at or above the largest suggestion fill\n * (RELATED_SAME_TYPE_COUNT in the hub's lib/constants/suggestions.ts) so\n * current rails never paginate — only genuinely big groups (author pages)\n * do. Exported through the subpath barrel for the hub's module-load\n * assertion of that relation (entity-suggestion-sections.tsx). */\nexport const GROUP_PAGE_SIZE = 12;\n\nfunction ContentGroup({\n type,\n refs,\n columns,\n buildUrl,\n resolveHref,\n LinkProvider,\n extras,\n adminCampaignCard,\n heading,\n}: {\n type: string;\n refs: ContentRef[];\n columns: 2 | 3;\n buildUrl: (type: string, ids: string[]) => string | null;\n resolveHref: (ref: ContentRef) => { href: string | null; targetPlatform: string | null };\n LinkProvider: CardLinkProvider;\n extras?: ChatCardDispatchExtras;\n adminCampaignCard?: AdminCampaignCardSlot;\n /** Group heading, rendered INSIDE the group so a group that resolves to\n * nothing (fetch miss / unsupported type / missing program config) drops\n * its heading too — no orphaned titles. */\n heading: React.ReactNode;\n}) {\n const { items, isLoading } = useGroupItems(type, refs, buildUrl);\n const config = resolveGroupConfig(type);\n const isListLayout = config.layout === 'list';\n const cardSize = config.gridSize;\n\n // Per-group pagination for big groups (author pages): GROUP_PAGE_SIZE items\n // per page with the standard Pagination control below the group. Client-side\n // slicing — useGroupItems already fetched every row in one batched call, so\n // page flips are instant. Hooks live above every early return (file\n // convention). Page is clamped so a shrinking refs array (suggestion\n // refetch) can never strand the view past the last page, and RESET when the\n // ref set actually changes (shrink→grow must not return to a stale page).\n const [page, setPage] = useState(1);\n const refsKey = refs.map((r) => r.id).join('|');\n const prevRefsKeyRef = useRef(refsKey);\n useEffect(() => {\n if (prevRefsKeyRef.current !== refsKey) {\n prevRefsKeyRef.current = refsKey;\n setPage(1);\n }\n }, [refsKey]);\n const totalGroupPages = Math.max(1, Math.ceil(refs.length / GROUP_PAGE_SIZE));\n const safePage = Math.min(page, totalGroupPages);\n const visibleGroupRefs =\n refs.length > GROUP_PAGE_SIZE\n ? refs.slice((safePage - 1) * GROUP_PAGE_SIZE, safePage * GROUP_PAGE_SIZE)\n : refs;\n const groupPagination =\n totalGroupPages > 1 ? (\n <Pagination currentPage={safePage} totalPages={totalGroupPages} onPageChange={setPage} />\n ) : null;\n\n // Skeleton gate: `isLoading && !items` — SSR HTML and the client's first\n // paint render identical skeletons (useSelfFetch starts isLoading=true on\n // both sides), and once items exist they are never replaced by skeletons.\n if (isLoading && !items) {\n const skeletons = visibleGroupRefs.map((r) => (\n <div key={r.id}>{renderSkeletonForType(type, cardSize, adminCampaignCard)}</div>\n ));\n return (\n <div className=\"space-y-4\">\n {heading}\n {isListLayout ? (\n <div className=\"space-y-4\">{skeletons}</div>\n ) : (\n <div className={gridClassFor(columns)}>{skeletons}</div>\n )}\n </div>\n );\n }\n\n if (!items || items.length === 0) return null;\n\n // Index fetched rows by id, then render in REF order — refs carry the\n // intended sequence (suggestion mode: the engine's tier order, so\n // same-platform/tag-matched items lead; controlled mode: the curated\n // display_order). The list APIs return rows date-sorted, which would\n // otherwise scramble that ordering (same-platform items sinking below\n // newer cross-platform ones).\n // Shared extractor (NOT raw `.id`) — some API shapes key items differently\n // (e.g. external_id types); raw access would silently drop valid items.\n const itemById = new Map(\n (items as any[]).map((it) => [extractItemId(type, it) ?? String((it as any)?.id), it]),\n );\n\n const cards = visibleGroupRefs\n .map((contentRef) => {\n const itemId = String(contentRef.id);\n const item = itemById.get(itemId);\n if (!item) return null;\n // Re-compose the URL via the host's resolver (hub: buildContentURL so\n // dev gets localhost and prod the right platform domain; default: the\n // ref's stored url as the API composed it).\n const resolved = resolveHref(contentRef);\n const href = resolved.href ?? '';\n const targetPlatform = resolved.targetPlatform ?? contentRef.targetPlatform ?? null;\n return (\n <div key={itemId}>\n <LinkProvider href={href || null} targetPlatform={targetPlatform}>\n {(linkProps) => (\n <CardForType\n type={type}\n item={item}\n size={cardSize}\n href={href}\n targetPlatform={targetPlatform}\n linkProps={linkProps}\n extras={extras}\n adminCampaignCard={adminCampaignCard}\n />\n )}\n </LinkProvider>\n </div>\n );\n })\n .filter(Boolean);\n\n if (cards.length === 0) {\n // Current PAGE resolved zero cards (rows deleted between the ref fetch\n // and the group fetch, or a stricter list-API gate dropped them). When a\n // pager exists the user must keep the controls to navigate back —\n // dropping the whole group would strand them. A genuinely empty group\n // (no pager) still vanishes with its heading.\n if (groupPagination) {\n return (\n <div className=\"space-y-4\">\n {heading}\n {groupPagination}\n </div>\n );\n }\n return null;\n }\n\n return (\n <div className=\"space-y-4\">\n {heading}\n {isListLayout ? (\n <div className=\"space-y-4\">{cards}</div>\n ) : (\n <div className={gridClassFor(columns)}>{cards}</div>\n )}\n {groupPagination}\n </div>\n );\n}\n\n// =============================================================================\n// Main component\n// =============================================================================\n\ninterface RelatedContentResponse {\n refs: ContentRefWithReason[];\n}\n\nexport interface RelatedContentSectionProps {\n /** CONTROLLED mode (the original behavior). When defined — even `[]` — no\n * suggestion fetch runs and exactly these refs render. */\n contentRefs?: ContentRef[];\n /** SUGGESTION mode (with `entityId`): self-fetch suggestions for this host\n * entity from `{apiBaseUrl}/api/related-content`. Ignored when\n * `contentRefs` is provided. */\n entityType?: string;\n entityId?: number | string;\n /** AUTHOR mode: self-fetch ALL published content authored by this profile\n * from `{apiBaseUrl}/api/related-content?authorId=…` (grouped per type,\n * endless within each group). Ignored when `contentRefs` is provided;\n * takes precedence over the entityType/entityId suggestion scope.\n * SSR-hydrate via `initialItems`, same as suggestion mode. */\n authorId?: string;\n /** Maps to the suggestion API's `count` param — the PER-TYPE fill target\n * for every candidate type EXCEPT the host's own. Absent → param not sent\n * (server default applies). */\n minResults?: number;\n /** Maps to the suggestion API's `sameTypeCount` param — the budget for the\n * candidate type MATCHING the host's own `entityType` (same-type boost:\n * a blog post's rail leads with more blog posts). Absent → param not\n * sent (host's type uses the server's `count`). */\n sameTypeMinResults?: number;\n /** SSR hydrate for suggestion mode — the server page ran the engine and\n * drills the refs here; the first client fetch is skipped (useSelfFetch\n * initialData contract). */\n initialItems?: ContentRefWithReason[];\n /** Section title (default: \"Related Content\") */\n title?: string;\n /**\n * Grid columns at desktop. 2 = denser cards / wider summary (original\n * investor-update layout); 3 = more cards per row for dashboards.\n * Only consulted for grid-layout groups. Default: 2.\n */\n columns?: 2 | 3;\n /**\n * ContentRef.type values to exclude. Honored in ALL modes — controlled\n * mode post-filters (original behavior); suggestion mode ALSO forwards the\n * list verbatim as the API's `excludeTypes=` param so excluded types never\n * consume engine fill slots (`minResults` stays honored). The subtraction\n * happens SERVER-side — this component never mirrors the hub's candidate\n * list.\n */\n excludeTypes?: string[];\n /**\n * SUGGESTION-mode allow-list (rail vocabulary): which content types\n * participate in this rail. Sent verbatim as the API's `types=` param —\n * the SERVER intersects it with its own allowed candidate set, and\n * platform policy gates (e.g. internal-only types) ALWAYS win: the client\n * cannot request its way past them. Absent → all server-side candidates.\n */\n includeTypes?: string[];\n /** Fetch-URL prefix for third-party embeds / reverse proxies\n * ('' = same-origin). Applied to BOTH the suggestion fetch and the\n * default per-group list fetches. */\n apiBaseUrl?: string;\n /** Host injection bundle — REUSES the chat dispatcher's\n * `ChatCardDispatchExtras` (programConfigs, buildOgPlaceholderUrl,\n * buildProductReleaseCardProps override). Program groups render nothing\n * when their config is absent. */\n extras?: ChatCardDispatchExtras;\n /** Hub injects its `buildContentURL` recomposition; default uses the\n * ref's stored `url`/`targetPlatform` as the API composed them. */\n resolveHref?: (ref: ContentRef) => { href: string | null; targetPlatform: string | null };\n /** Hub injects its registry-driven entity-list-api builder; default = the\n * lib's `buildListUrl(type, ids, apiBaseUrl)`. */\n buildListUrl?: (type: string, ids: string[]) => string | null;\n /** Hub injects a `useNavLink`-backed render-prop provider; default = pure\n * anchor via `decideNewTab`. MUST be a module-scope component. */\n LinkProvider?: CardLinkProvider;\n /** Renderer pair for the admin-only `marketing_campaign` type. Absent →\n * the type renders nothing. */\n adminCampaignCard?: AdminCampaignCardSlot;\n}\n\nexport function RelatedContentSection({\n contentRefs,\n entityType,\n entityId,\n authorId,\n minResults,\n sameTypeMinResults,\n includeTypes,\n initialItems,\n title = 'Related Content',\n columns = 2,\n excludeTypes,\n apiBaseUrl = '',\n extras,\n resolveHref = defaultResolveHref,\n buildListUrl,\n LinkProvider = DefaultLinkPropsProvider,\n adminCampaignCard,\n}: RelatedContentSectionProps) {\n // ── Hooks above EVERY early return (the original `if (!contentRefs.length)\n // return null` guard moved below them). ──\n\n // Suggestion-mode fetch URL — null in controlled mode (contentRefs defined,\n // even []) or when the entity scope is incomplete.\n // `includeTypes: []` is an explicit \"nothing participates\" — skip the fetch\n // entirely (an empty-string `types=` param would be dropped by the URL\n // builder and read server-side as \"all candidates\") AND ignore SSR refs.\n const suggestionsDisabled = includeTypes?.length === 0;\n // Shared type-filter params — one spelling for both fetch modes so a future\n // normalization (trim/dedupe) can't diverge between them.\n const typeFilterParams = {\n types: includeTypes !== undefined ? includeTypes.join(',') : undefined,\n excludeTypes: excludeTypes && excludeTypes.length > 0 ? excludeTypes.join(',') : undefined,\n };\n // AUTHOR mode beats suggestion mode: when `authorId` is set the rail lists\n // everything that profile authored (the server returns ALL, no count).\n const authorUrl =\n contentRefs === undefined && authorId && !suggestionsDisabled\n ? buildSuggestionUrl('/api/related-content', {\n apiBaseUrl,\n extraParams: { authorId, ...typeFilterParams },\n })\n : null;\n const suggestUrl =\n authorUrl ??\n (contentRefs === undefined &&\n entityType &&\n entityId !== undefined &&\n entityId !== null &&\n entityId !== '' &&\n !suggestionsDisabled\n ? buildSuggestionUrl('/api/related-content', {\n apiBaseUrl,\n entityType,\n entityId,\n count: minResults,\n extraParams: {\n sameTypeCount: sameTypeMinResults !== undefined ? String(sameTypeMinResults) : undefined,\n ...typeFilterParams,\n },\n })\n : null);\n // Memoize the initialData wrapper — useSelfFetch re-syncs on [initialData],\n // and a fresh per-render object would loop setState under re-rendering\n // parents (the latent FaqSection bug, fixed there in the same change).\n const initialData = useMemo<RelatedContentResponse | undefined>(\n // An explicitly disabled rail (includeTypes: []) must ignore SSR-hydrated\n // refs too — otherwise useSelfFetch(null, {initialData}) keeps serving\n // initialItems and the \"nothing participates\" contract silently breaks.\n () => (!suggestionsDisabled && initialItems ? { refs: initialItems } : undefined),\n [initialItems, suggestionsDisabled],\n );\n const { data } = useSelfFetch<RelatedContentResponse>(suggestUrl, { initialData });\n\n // Default group fetcher: the lib's byte-parity-tested builder, prefixed for\n // embeds. Memoized so group-fetch URLs stay value-stable across renders.\n const effectiveBuildListUrl = useMemo(\n () => buildListUrl ?? ((type: string, ids: string[]) => libBuildListUrl(type, ids, apiBaseUrl)),\n [buildListUrl, apiBaseUrl],\n );\n\n const refs: ContentRef[] = contentRefs ?? data?.refs ?? [];\n\n // Per-consumer type gating — drops refs whose `type` is in the exclude\n // list. In suggestion mode the server already subtracted these (the param\n // is forwarded above); the client filter stays as an idempotent guard and\n // IS the mechanism in controlled mode (original behavior).\n const exclude = new Set(excludeTypes || []);\n const visibleRefs = exclude.size > 0 ? refs.filter((r) => !exclude.has(r.type)) : refs;\n // Zero refs (still loading in suggestion mode, or genuinely empty) → no\n // empty shell.\n if (!visibleRefs.length) return null;\n\n const grouped: Record<string, ContentRef[]> = {};\n for (const ref of visibleRefs) {\n if (!grouped[ref.type]) grouped[ref.type] = [];\n grouped[ref.type].push(ref);\n }\n\n // Registered types in CONTENT_REF_GROUPS order, then any unregistered\n // types appended (same shape the investor-email builder uses — both\n // consume `orderContentRefTypes` so cross-surface ordering matches).\n // SAME-TYPE FIRST: when a host entityType is known (suggestion / SSR\n // modes), its own content-type group is hoisted to the top — a blog\n // post's rail leads with blog posts. Rail group keys are compared via\n // the shared alias canonicalizer (blog_post_existing ↔ blog_post).\n let orderedTypes = orderContentRefTypes(Object.keys(grouped));\n if (entityType) {\n // Canonicalize BOTH sides — hosts pass registry vocab ('blog_post') but\n // rail-vocab aliases ('blog_post_existing') are also legal inputs; a raw\n // comparison would silently lose the same-type-first hoist for aliases.\n const canonicalEntityType = canonicalContentRefType(entityType);\n const sameType = orderedTypes.filter((t) => canonicalContentRefType(t) === canonicalEntityType);\n if (sameType.length > 0) {\n orderedTypes = [...sameType, ...orderedTypes.filter((t) => canonicalContentRefType(t) !== canonicalEntityType)];\n }\n }\n\n return (\n <div className=\"space-y-8\">\n <h2 className=\"text-2xl font-bold text-ods-text-primary\">{title}</h2>\n {orderedTypes.map((type) => (\n <ContentGroup\n key={type}\n type={type}\n refs={grouped[type]}\n columns={columns}\n buildUrl={effectiveBuildListUrl}\n resolveHref={resolveHref}\n LinkProvider={LinkProvider}\n extras={extras}\n adminCampaignCard={adminCampaignCard}\n heading={\n <h3 className=\"font-['Azeret_Mono'] text-[14px] font-semibold uppercase text-ods-text-secondary tracking-wider\">\n {getContentRefLabelOrTitleCase(type)}\n </h3>\n }\n />\n ))}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,SAAgB,WAAW,SAAS,QAAQ,gBAAgB;AAS5D;AA8Fa,cAgRP,YAhRO;AA1Cb,SAAS,yBAAyB,EAAE,MAAM,gBAAgB,SAAS,GAAqD;AACtH,MAAI,CAAC,KAAM,QAAO,SAAS,IAAI;AAC/B,QAAM,SAAS,aAAa,EAAE,MAAM,gBAAgB,eAAe,GAAG,CAAC;AACvE,SAAO;AAAA,IACL,SACI,EAAE,MAAM,QAAQ,UAAU,KAAK,sBAAsB,IACrD,EAAE,KAAK;AAAA,EACb;AACF;AAKA,SAAS,mBAAmB,KAAyE;AACnG,SAAO,EAAE,MAAM,IAAI,OAAO,MAAM,gBAAgB,IAAI,kBAAkB,KAAK;AAC7E;AAiBA,SAAS,sBACP,MACA,MACA,mBACiB;AAGjB,QAAM,aAA+B,SAAS,OAAO,OAAO;AAC5D,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO,oBAAC,oBAAiB,MAAM,YAAY;AAAA,IAC7C,KAAK;AACH,aAAO,oBAAC,yBAAsB,MAAM,YAAY;AAAA,IAClD,KAAK;AACH,aAAO,oBAAC,iCAA8B,MAAM,YAAY;AAAA,IAC1D,KAAK;AACH,aAAO,oBAAC,8BAA2B,MAAM,SAAS,OAAO,OAAO,MAAM;AAAA,IACxE,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,oBAAC,uBAAoB,MAAM,YAAY;AAAA,IAChD,KAAK;AACH,aAAO,oBAAC,8BAA2B,MAAM,YAAY;AAAA,IACvD,KAAK;AAIH,aAAO,oBAAC,+BAA4B,MAAM,SAAS,OAAO,OAAO,WAAW;AAAA,IAC9E,KAAK;AACH,aAAO,oBAAoB,oBAA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