@flamingo-stack/openframe-frontend-core 0.0.646 → 0.0.647-snapshot.20260917173248

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 (139) hide show
  1. package/dist/chat-protocol/index.cjs.map +1 -1
  2. package/dist/chat-protocol/index.js.map +1 -1
  3. package/dist/{chunk-ETEM2ZD4.js → chunk-2A4RLR7R.js} +3 -3
  4. package/dist/{chunk-JFBUXYDK.cjs → chunk-2ENDIKKP.cjs} +15 -15
  5. package/dist/{chunk-JFBUXYDK.cjs.map → chunk-2ENDIKKP.cjs.map} +1 -1
  6. package/dist/{chunk-QS55P2TA.js → chunk-2ULLNHL3.js} +6 -6
  7. package/dist/chunk-2ULLNHL3.js.map +1 -0
  8. package/dist/{chunk-DULSS7R6.js → chunk-3ORBE27K.js} +832 -547
  9. package/dist/chunk-3ORBE27K.js.map +1 -0
  10. package/dist/{chunk-ZW2BEEX2.cjs → chunk-4JRBRMKO.cjs} +25 -25
  11. package/dist/{chunk-ZW2BEEX2.cjs.map → chunk-4JRBRMKO.cjs.map} +1 -1
  12. package/dist/{chunk-7UWJMWDH.cjs → chunk-EFPAKLT5.cjs} +784 -499
  13. package/dist/chunk-EFPAKLT5.cjs.map +1 -0
  14. package/dist/{chunk-5C7GMRJU.js → chunk-EKLOXVG2.js} +5 -5
  15. package/dist/{chunk-AYAZU3BO.cjs → chunk-EW3EIPT5.cjs} +5 -5
  16. package/dist/{chunk-AYAZU3BO.cjs.map → chunk-EW3EIPT5.cjs.map} +1 -1
  17. package/dist/{chunk-NKMXFBV5.js → chunk-FQ4TZP6K.js} +4 -4
  18. package/dist/{chunk-5JVN3EVT.cjs → chunk-HN4DLGKP.cjs} +71 -71
  19. package/dist/{chunk-5JVN3EVT.cjs.map → chunk-HN4DLGKP.cjs.map} +1 -1
  20. package/dist/{chunk-WJ7PDBPK.cjs → chunk-HXQWGZYG.cjs} +4 -4
  21. package/dist/{chunk-WJ7PDBPK.cjs.map → chunk-HXQWGZYG.cjs.map} +1 -1
  22. package/dist/{chunk-5MZZFTME.js → chunk-IUHU5BC2.js} +5 -5
  23. package/dist/{chunk-ZGWXD2S3.js → chunk-IWEJCDCB.js} +3 -3
  24. package/dist/{chunk-N2E26OD6.cjs → chunk-LFCMKMHR.cjs} +45 -45
  25. package/dist/{chunk-N2E26OD6.cjs.map → chunk-LFCMKMHR.cjs.map} +1 -1
  26. package/dist/{chunk-XJH5M2B7.js → chunk-M6QCADAT.js} +6 -6
  27. package/dist/{chunk-NWYSHZG7.cjs → chunk-N7AJUG4C.cjs} +22 -22
  28. package/dist/{chunk-NWYSHZG7.cjs.map → chunk-N7AJUG4C.cjs.map} +1 -1
  29. package/dist/{chunk-LDJ4TIDC.cjs → chunk-ODXVLFAQ.cjs} +13 -24
  30. package/dist/chunk-ODXVLFAQ.cjs.map +1 -0
  31. package/dist/{chunk-4GOJFHJY.js → chunk-OLPU5IVF.js} +2 -2
  32. package/dist/{chunk-PD47DDHS.js → chunk-PYAFHT6B.js} +7 -18
  33. package/dist/chunk-PYAFHT6B.js.map +1 -0
  34. package/dist/{chunk-H4FQRA5O.cjs → chunk-RM5MF2N3.cjs} +3 -3
  35. package/dist/{chunk-H4FQRA5O.cjs.map → chunk-RM5MF2N3.cjs.map} +1 -1
  36. package/dist/{chunk-ZDIDA4QG.js → chunk-SBKNMSQR.js} +2 -2
  37. package/dist/{chunk-GBZ3IR3S.js → chunk-SNQ5KWLP.js} +2 -2
  38. package/dist/{chunk-LLT5XMP2.js → chunk-UW7XUQFP.js} +3 -3
  39. package/dist/{chunk-RRSR2XHJ.cjs → chunk-VPEETTUS.cjs} +167 -167
  40. package/dist/chunk-VPEETTUS.cjs.map +1 -0
  41. package/dist/{chunk-UR7BC74V.js → chunk-VTLDEZ5D.js} +3 -3
  42. package/dist/{chunk-XPPGI7SD.js → chunk-WBRO3MX2.js} +2 -2
  43. package/dist/{chunk-NZ66W56D.cjs → chunk-WMKXHOOD.cjs} +10 -10
  44. package/dist/{chunk-NZ66W56D.cjs.map → chunk-WMKXHOOD.cjs.map} +1 -1
  45. package/dist/{chunk-TZO743LD.cjs → chunk-WPNY4XEL.cjs} +3 -3
  46. package/dist/{chunk-TZO743LD.cjs.map → chunk-WPNY4XEL.cjs.map} +1 -1
  47. package/dist/{chunk-XATBOM3X.js → chunk-XE5DNWOR.js} +5 -5
  48. package/dist/{chunk-C6QUB6IS.cjs → chunk-XI3QJD3N.cjs} +22 -22
  49. package/dist/{chunk-C6QUB6IS.cjs.map → chunk-XI3QJD3N.cjs.map} +1 -1
  50. package/dist/{chunk-2V7SCIOG.cjs → chunk-YTOUGDPY.cjs} +33 -33
  51. package/dist/{chunk-2V7SCIOG.cjs.map → chunk-YTOUGDPY.cjs.map} +1 -1
  52. package/dist/{chunk-X2VTQ3TL.cjs → chunk-YUXFHVC2.cjs} +10 -10
  53. package/dist/{chunk-X2VTQ3TL.cjs.map → chunk-YUXFHVC2.cjs.map} +1 -1
  54. package/dist/components/case-studies/index.cjs +14 -14
  55. package/dist/components/case-studies/index.js +3 -3
  56. package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
  57. package/dist/components/chat/index.cjs +2 -2
  58. package/dist/components/chat/index.js +1 -1
  59. package/dist/components/chat/types/message.types.d.ts +5 -0
  60. package/dist/components/chat/types/message.types.d.ts.map +1 -1
  61. package/dist/components/chat/utils/cited-sources.d.ts +5 -0
  62. package/dist/components/chat/utils/cited-sources.d.ts.map +1 -1
  63. package/dist/components/chat/utils/source-row-cta.d.ts +2 -7
  64. package/dist/components/chat/utils/source-row-cta.d.ts.map +1 -1
  65. package/dist/components/contact/index.cjs +4 -4
  66. package/dist/components/contact/index.js +3 -3
  67. package/dist/components/docs/index.cjs +7 -7
  68. package/dist/components/docs/index.js +6 -6
  69. package/dist/components/embeds/index.cjs +4 -4
  70. package/dist/components/embeds/index.js +3 -3
  71. package/dist/components/faq/index.cjs +4 -4
  72. package/dist/components/faq/index.js +3 -3
  73. package/dist/components/features/index.cjs +3 -3
  74. package/dist/components/features/index.js +2 -2
  75. package/dist/components/help-center-pages/index.cjs +23 -23
  76. package/dist/components/help-center-pages/index.js +14 -14
  77. package/dist/components/index.cjs +39 -39
  78. package/dist/components/index.js +13 -13
  79. package/dist/components/meeting-scheduler/index.cjs +24 -24
  80. package/dist/components/meeting-scheduler/index.js +2 -2
  81. package/dist/components/navigation/index.cjs +6 -6
  82. package/dist/components/navigation/index.js +5 -5
  83. package/dist/components/onboarding-guides/index.cjs +6 -6
  84. package/dist/components/onboarding-guides/index.js +5 -5
  85. package/dist/components/shared/doc-search/map-doc-search-results.d.ts.map +1 -1
  86. package/dist/components/tickets/index.cjs +7 -7
  87. package/dist/components/tickets/index.js +6 -6
  88. package/dist/components/ui/data-table/data-table-skeleton.d.ts.map +1 -1
  89. package/dist/components/ui/index.cjs +3 -3
  90. package/dist/components/ui/index.js +2 -2
  91. package/dist/components/ui/markdown/mermaid-diagram.d.ts +31 -9
  92. package/dist/components/ui/markdown/mermaid-diagram.d.ts.map +1 -1
  93. package/dist/index.cjs +19 -7
  94. package/dist/index.cjs.map +1 -1
  95. package/dist/index.js +18 -6
  96. package/dist/index.js.map +1 -1
  97. package/dist/utils/index.cjs +163 -0
  98. package/dist/utils/index.cjs.map +1 -1
  99. package/dist/utils/index.d.ts +1 -0
  100. package/dist/utils/index.d.ts.map +1 -1
  101. package/dist/utils/index.js +158 -1
  102. package/dist/utils/index.js.map +1 -1
  103. package/dist/utils/source-grouping.d.ts +86 -0
  104. package/dist/utils/source-grouping.d.ts.map +1 -0
  105. package/dist/utils/source-icons.d.ts +7 -0
  106. package/dist/utils/source-icons.d.ts.map +1 -1
  107. package/package.json +1 -1
  108. package/src/components/chat/embeddable-chat.tsx +10 -2
  109. package/src/components/chat/types/message.types.ts +5 -0
  110. package/src/components/chat/utils/cited-sources.ts +7 -1
  111. package/src/components/chat/utils/source-row-cta.ts +4 -7
  112. package/src/components/shared/doc-search/__tests__/map-doc-search-results.test.ts +48 -0
  113. package/src/components/shared/doc-search/map-doc-search-results.ts +6 -16
  114. package/src/components/ui/data-table/data-table-skeleton.tsx +15 -7
  115. package/src/components/ui/markdown/__tests__/mermaid-zoom.test.tsx +117 -0
  116. package/src/components/ui/markdown/mermaid-diagram.tsx +279 -59
  117. package/src/utils/__tests__/source-grouping.test.ts +240 -0
  118. package/src/utils/index.ts +11 -0
  119. package/src/utils/source-grouping.ts +215 -0
  120. package/src/utils/source-icons.ts +13 -0
  121. package/dist/chunk-7UWJMWDH.cjs.map +0 -1
  122. package/dist/chunk-DULSS7R6.js.map +0 -1
  123. package/dist/chunk-LDJ4TIDC.cjs.map +0 -1
  124. package/dist/chunk-PD47DDHS.js.map +0 -1
  125. package/dist/chunk-QS55P2TA.js.map +0 -1
  126. package/dist/chunk-RRSR2XHJ.cjs.map +0 -1
  127. /package/dist/{chunk-ETEM2ZD4.js.map → chunk-2A4RLR7R.js.map} +0 -0
  128. /package/dist/{chunk-5C7GMRJU.js.map → chunk-EKLOXVG2.js.map} +0 -0
  129. /package/dist/{chunk-NKMXFBV5.js.map → chunk-FQ4TZP6K.js.map} +0 -0
  130. /package/dist/{chunk-5MZZFTME.js.map → chunk-IUHU5BC2.js.map} +0 -0
  131. /package/dist/{chunk-ZGWXD2S3.js.map → chunk-IWEJCDCB.js.map} +0 -0
  132. /package/dist/{chunk-XJH5M2B7.js.map → chunk-M6QCADAT.js.map} +0 -0
  133. /package/dist/{chunk-4GOJFHJY.js.map → chunk-OLPU5IVF.js.map} +0 -0
  134. /package/dist/{chunk-ZDIDA4QG.js.map → chunk-SBKNMSQR.js.map} +0 -0
  135. /package/dist/{chunk-GBZ3IR3S.js.map → chunk-SNQ5KWLP.js.map} +0 -0
  136. /package/dist/{chunk-LLT5XMP2.js.map → chunk-UW7XUQFP.js.map} +0 -0
  137. /package/dist/{chunk-UR7BC74V.js.map → chunk-VTLDEZ5D.js.map} +0 -0
  138. /package/dist/{chunk-XPPGI7SD.js.map → chunk-WBRO3MX2.js.map} +0 -0
  139. /package/dist/{chunk-XATBOM3X.js.map → chunk-XE5DNWOR.js.map} +0 -0
@@ -1252,7 +1252,7 @@ ContextCompactionDisplay.displayName = "ContextCompactionDisplay";
1252
1252
  import { forwardRef as forwardRef8, useState as useState7 } from "react";
1253
1253
 
1254
1254
  // src/components/ui/markdown/engine.tsx
1255
- import { memo, useMemo as useMemo3 } from "react";
1255
+ import { memo, useMemo as useMemo4 } from "react";
1256
1256
  import ReactMarkdown from "react-markdown";
1257
1257
  import rehypeHighlight from "rehype-highlight";
1258
1258
  import rehypeRaw from "rehype-raw";
@@ -1376,7 +1376,8 @@ function extractText(node) {
1376
1376
  }
1377
1377
 
1378
1378
  // src/components/ui/markdown/mermaid-diagram.tsx
1379
- import { useEffect, useState as useState6 } from "react";
1379
+ import { Maximize2, ZoomIn, ZoomOut } from "lucide-react";
1380
+ import { useCallback, useEffect, useLayoutEffect as useLayoutEffect2, useMemo as useMemo3, useRef, useState as useState6 } from "react";
1380
1381
 
1381
1382
  // src/hooks/ui/use-is-hydrated.ts
1382
1383
  import { useSyncExternalStore } from "react";
@@ -1435,38 +1436,17 @@ async function withRenderTimeout(promise, ms) {
1435
1436
  }
1436
1437
  }
1437
1438
  var mermaidStyles = `
1439
+ /* The pan surface is a scroll region with NO scrollbars: drag, wheel,
1440
+ arrows and the toolbar move it (a canvas, the way dbdiagram, Figma and
1441
+ Excalidraw draw one). Two mechanisms for one motion read as a bug. */
1442
+ .mermaid-frame-pan { scrollbar-width: none; -ms-overflow-style: none; }
1443
+ .mermaid-frame-pan::-webkit-scrollbar { display: none; }
1438
1444
  .mermaid-svg-container svg {
1439
- max-width: 100% !important;
1440
- height: auto !important;
1441
- min-height: 200px;
1445
+ max-width: 100%;
1446
+ height: auto;
1442
1447
  font-family: 'DM Sans', sans-serif !important;
1443
1448
  font-size: 14px !important;
1444
1449
  }
1445
- @media (min-width: 1520px) {
1446
- .mermaid-svg-container svg {
1447
- max-width: 900px !important;
1448
- max-height: 700px !important;
1449
- min-height: 300px;
1450
- font-size: 16px !important;
1451
- }
1452
- }
1453
- @media (min-width: 768px) and (max-width: 1519px) {
1454
- .mermaid-svg-container svg {
1455
- max-width: 700px !important;
1456
- max-height: 600px !important;
1457
- min-height: 250px;
1458
- font-size: 15px !important;
1459
- }
1460
- }
1461
- @media (max-width: 767px) {
1462
- .mermaid-svg-container svg {
1463
- max-width: 90vw !important;
1464
- max-height: 400px !important;
1465
- min-height: 200px;
1466
- font-size: 13px !important;
1467
- }
1468
- }
1469
- .mermaid-svg-container svg[width] { width: 100% !important; }
1470
1450
  .mermaid-svg-container .node rect,
1471
1451
  .mermaid-svg-container .node circle,
1472
1452
  .mermaid-svg-container .node ellipse,
@@ -1481,15 +1461,122 @@ var mermaidStyles = `
1481
1461
  .mermaid-svg-container .edgeLabel text { font-size: 16px !important; }
1482
1462
  }
1483
1463
  `;
1464
+ var MERMAID_ZOOM_MIN = 0.25;
1465
+ var MERMAID_ZOOM_MAX = 4;
1466
+ var MERMAID_ZOOM_STEP = 1.25;
1467
+ var clampZoom = (z) => Math.min(MERMAID_ZOOM_MAX, Math.max(MERMAID_ZOOM_MIN, z));
1484
1468
  var mermaidRenderSeq = 0;
1485
- var MermaidDiagram = ({ chart }) => {
1469
+ var FRAME_CLASS = {
1470
+ content: "min-h-[200px] max-h-[70svh] md:min-h-[250px]",
1471
+ fold: "h-[70svh] min-h-[320px]"
1472
+ };
1473
+ var MermaidDiagram = ({
1474
+ chart,
1475
+ zoomable = true,
1476
+ frame = "content"
1477
+ }) => {
1486
1478
  const [svg, setSvg] = useState6("");
1487
1479
  const [error, setError] = useState6("");
1488
1480
  const [isLoading, setIsLoading] = useState6(true);
1481
+ const [zoom, setZoom] = useState6(1);
1482
+ const [dragging, setDragging] = useState6(false);
1483
+ const empty = !chart.trim();
1484
+ const naturalWidth = useMemo3(() => {
1485
+ const px = Number(svg.match(/max-width:\s*([\d.]+)px/)?.[1]);
1486
+ return Number.isFinite(px) && px > 0 ? Math.ceil(px) : null;
1487
+ }, [svg]);
1488
+ const scrollRef = useRef(null);
1489
+ const pendingAnchor = useRef(null);
1490
+ const applyZoom = useCallback((next, anchor) => {
1491
+ setZoom((current) => {
1492
+ const target = clampZoom(Math.round(next * 100) / 100);
1493
+ if (target === current) return current;
1494
+ const el = scrollRef.current;
1495
+ const ax = anchor?.ax ?? (el ? el.clientWidth / 2 : 0);
1496
+ const ay = anchor?.ay ?? (el ? el.clientHeight / 2 : 0);
1497
+ pendingAnchor.current = { ratio: target / current, ax, ay };
1498
+ return target;
1499
+ });
1500
+ }, []);
1501
+ useLayoutEffect2(() => {
1502
+ const el = scrollRef.current;
1503
+ const pending = pendingAnchor.current;
1504
+ if (!el || !pending) return;
1505
+ pendingAnchor.current = null;
1506
+ el.scrollLeft = (el.scrollLeft + pending.ax) * pending.ratio - pending.ax;
1507
+ el.scrollTop = (el.scrollTop + pending.ay) * pending.ratio - pending.ay;
1508
+ }, [zoom]);
1509
+ const zoomBy = useCallback(
1510
+ (factor, anchor) => applyZoom(zoom * factor, anchor),
1511
+ [applyZoom, zoom]
1512
+ );
1513
+ const fit = useCallback(() => {
1514
+ const el = scrollRef.current;
1515
+ const svgEl = el?.querySelector("svg");
1516
+ if (!el || !svgEl) return;
1517
+ const box = svgEl.getBoundingClientRect();
1518
+ const w = box.width / zoom;
1519
+ const h = box.height / zoom;
1520
+ if (!(w > 0 && h > 0)) return;
1521
+ const next = Math.min(1, el.clientWidth / w, el.clientHeight / h);
1522
+ pendingAnchor.current = null;
1523
+ setZoom(clampZoom(Math.floor(next * 100) / 100));
1524
+ el.scrollTo({ left: 0, top: 0 });
1525
+ }, [zoom]);
1526
+ useEffect(() => {
1527
+ const el = scrollRef.current;
1528
+ if (!el || !zoomable) return void 0;
1529
+ const onWheel = (e) => {
1530
+ if (!(e.ctrlKey || e.metaKey)) return;
1531
+ e.preventDefault();
1532
+ const rect = el.getBoundingClientRect();
1533
+ applyZoom(zoom * Math.exp(-e.deltaY * 25e-4), { ax: e.clientX - rect.left, ay: e.clientY - rect.top });
1534
+ };
1535
+ el.addEventListener("wheel", onWheel, { passive: false });
1536
+ return () => el.removeEventListener("wheel", onWheel);
1537
+ }, [zoomable, svg, zoom, applyZoom]);
1538
+ const drag = useRef(null);
1539
+ const onPointerDown = (e) => {
1540
+ if (!zoomable || e.button !== 0 || e.pointerType === "touch") return;
1541
+ const el = scrollRef.current;
1542
+ if (!el) return;
1543
+ e.preventDefault();
1544
+ drag.current = { x: e.clientX, y: e.clientY, left: el.scrollLeft, top: el.scrollTop };
1545
+ el.setPointerCapture?.(e.pointerId);
1546
+ el.focus({ preventScroll: true });
1547
+ setDragging(true);
1548
+ };
1549
+ const onPointerMove = (e) => {
1550
+ const d = drag.current;
1551
+ const el = scrollRef.current;
1552
+ if (!d || !el) return;
1553
+ el.scrollLeft = d.left - (e.clientX - d.x);
1554
+ el.scrollTop = d.top - (e.clientY - d.y);
1555
+ };
1556
+ const endDrag = (e) => {
1557
+ if (!drag.current) return;
1558
+ drag.current = null;
1559
+ scrollRef.current?.releasePointerCapture?.(e.pointerId);
1560
+ setDragging(false);
1561
+ };
1562
+ const onKeyDown = (e) => {
1563
+ if (!zoomable || !svg) return;
1564
+ if (e.key === "+" || e.key === "=") zoomBy(MERMAID_ZOOM_STEP);
1565
+ else if (e.key === "-") zoomBy(1 / MERMAID_ZOOM_STEP);
1566
+ else if (e.key === "0") applyZoom(1);
1567
+ else if (e.key === "f" || e.key === "F") fit();
1568
+ else return;
1569
+ e.preventDefault();
1570
+ };
1489
1571
  const mounted = useIsHydrated();
1490
1572
  useEffect(() => {
1491
1573
  let cancelled = false;
1492
1574
  const renderId = `mermaid-${mermaidRenderSeq += 1}`;
1575
+ if (empty) {
1576
+ return () => {
1577
+ cancelled = true;
1578
+ };
1579
+ }
1493
1580
  const renderMermaid = async () => {
1494
1581
  try {
1495
1582
  setIsLoading(true);
@@ -1539,6 +1626,8 @@ var MermaidDiagram = ({ chart }) => {
1539
1626
  );
1540
1627
  if (cancelled) return;
1541
1628
  setSvg(renderedSvg);
1629
+ pendingAnchor.current = null;
1630
+ setZoom(1);
1542
1631
  setError("");
1543
1632
  setIsLoading(false);
1544
1633
  } catch (err) {
@@ -1556,33 +1645,110 @@ var MermaidDiagram = ({ chart }) => {
1556
1645
  document.getElementById(`d${renderId}`)?.remove();
1557
1646
  document.getElementById(renderId)?.remove();
1558
1647
  };
1559
- }, [chart, mounted]);
1560
- if (error) {
1561
- return /* @__PURE__ */ jsxs8("div", { className: "error-state my-6 rounded-lg border border-ods-border bg-ods-card p-6", children: [
1562
- /* @__PURE__ */ jsx12("div", { className: "error-icon mb-4 flex justify-center", children: /* @__PURE__ */ jsx12(AlertCircleIcon, { className: "h-12 w-12 text-ods-error" }) }),
1563
- /* @__PURE__ */ jsx12("div", { className: "error-title mb-2 text-center font-sans text-lg font-semibold text-ods-error", children: "Diagram Error" }),
1564
- /* @__PURE__ */ jsx12("div", { className: "error-description mb-4 max-w-full overflow-hidden break-words text-center font-sans text-sm text-ods-text-secondary", children: /* @__PURE__ */ jsx12("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsx12("pre", { className: "whitespace-pre-wrap break-words text-xs", children: error }) }) })
1565
- ] });
1566
- }
1567
- if (isLoading || !svg) {
1568
- return /* @__PURE__ */ jsx12("div", { className: "skeleton-code flex min-h-[120px] items-center justify-center rounded-lg border border-ods-border bg-ods-card p-6", children: /* @__PURE__ */ jsx12("div", { className: "animate-pulse font-sans text-ods-text-tertiary", children: isLoading ? "Loading diagram renderer..." : "Rendering diagram..." }) });
1569
- }
1570
- return /* @__PURE__ */ jsxs8("div", { className: "mermaid-container my-6 overflow-x-auto rounded-lg border border-ods-border bg-ods-card p-4 md:p-6 lg:p-8", children: [
1648
+ }, [chart, empty, mounted]);
1649
+ const frameClass = `${FRAME_CLASS[frame]} flex w-full overflow-auto outline-none focus-visible:ring-1 focus-visible:ring-ods-accent ${zoomable && svg ? `mermaid-frame-pan select-none ${dragging ? "cursor-grabbing" : "cursor-grab"}` : ""}`;
1650
+ const frameStyle = { justifyContent: "safe center", alignItems: "safe center" };
1651
+ const body = error && !empty ? /* @__PURE__ */ jsxs8("div", { className: "error-state m-auto rounded-lg border border-ods-border bg-ods-card p-6", children: [
1652
+ /* @__PURE__ */ jsx12("div", { className: "error-icon mb-4 flex justify-center", children: /* @__PURE__ */ jsx12(AlertCircleIcon, { className: "h-12 w-12 text-ods-error" }) }),
1653
+ /* @__PURE__ */ jsx12("div", { className: "error-title mb-2 text-center font-sans text-lg font-semibold text-ods-error", children: "Diagram Error" }),
1654
+ /* @__PURE__ */ jsx12("div", { className: "error-description mb-4 max-w-full overflow-hidden break-words text-center font-sans text-sm text-ods-text-secondary", children: /* @__PURE__ */ jsx12("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsx12("pre", { className: "whitespace-pre-wrap break-words text-xs", children: error }) }) })
1655
+ ] }) : empty || isLoading || !svg ? /* @__PURE__ */ jsx12("div", { className: "skeleton-code m-auto animate-pulse font-sans text-ods-text-tertiary", children: isLoading ? "Loading diagram renderer..." : "Rendering diagram..." }) : /* @__PURE__ */ jsx12(
1656
+ "div",
1657
+ {
1658
+ className: "mermaid-svg-container flex shrink-0 justify-center",
1659
+ "data-testid": "mermaid-svg-container",
1660
+ "data-zoom": zoom,
1661
+ style: {
1662
+ fontSize: "14px",
1663
+ zoom,
1664
+ width: naturalWidth ? `min(${naturalWidth}px, calc(100% * ${zoom}))` : "100%"
1665
+ },
1666
+ dangerouslySetInnerHTML: { __html: svg }
1667
+ }
1668
+ );
1669
+ return /* @__PURE__ */ jsxs8("div", { className: "mermaid-container relative my-6 rounded-lg border border-ods-border bg-ods-card p-4 md:p-6 lg:p-8", children: [
1571
1670
  /* @__PURE__ */ jsx12("style", { dangerouslySetInnerHTML: { __html: mermaidStyles } }),
1572
- /* @__PURE__ */ jsx12("div", { className: "flex min-h-[200px] w-full items-center justify-center md:min-h-[250px] lg:min-h-[300px]", children: /* @__PURE__ */ jsx12(
1671
+ zoomable && /* @__PURE__ */ jsxs8(
1573
1672
  "div",
1574
1673
  {
1575
- className: "mermaid-svg-container flex w-full max-w-full justify-center",
1576
- "data-testid": "mermaid-svg-container",
1577
- style: { fontSize: "14px" },
1578
- dangerouslySetInnerHTML: {
1579
- __html: svg.replace(
1580
- /<svg[^>]*>/,
1581
- (match) => match.replace(/width="[^"]*"/, 'width="100%"').replace(/height="[^"]*"/, 'height="auto"')
1674
+ className: "absolute right-2 top-2 z-10 flex items-center gap-[var(--spacing-system-xxs)] rounded-md bg-ods-card",
1675
+ role: "group",
1676
+ "aria-label": "Diagram zoom",
1677
+ children: [
1678
+ /* @__PURE__ */ jsx12(
1679
+ Button,
1680
+ {
1681
+ variant: "outline",
1682
+ size: "icon-sm",
1683
+ "aria-label": "Zoom out",
1684
+ title: "Zoom out (\u2212, \u2318/Ctrl + wheel)",
1685
+ disabled: !svg || zoom <= MERMAID_ZOOM_MIN,
1686
+ onClick: () => zoomBy(1 / MERMAID_ZOOM_STEP),
1687
+ children: /* @__PURE__ */ jsx12(ZoomOut, {})
1688
+ }
1689
+ ),
1690
+ /* @__PURE__ */ jsxs8(
1691
+ Button,
1692
+ {
1693
+ variant: "outline",
1694
+ size: "compact",
1695
+ "aria-label": "Reset zoom",
1696
+ title: "Back to 100% (0)",
1697
+ disabled: !svg || zoom === 1,
1698
+ onClick: () => applyZoom(1),
1699
+ children: [
1700
+ Math.round(zoom * 100),
1701
+ "%"
1702
+ ]
1703
+ }
1704
+ ),
1705
+ /* @__PURE__ */ jsx12(
1706
+ Button,
1707
+ {
1708
+ variant: "outline",
1709
+ size: "icon-sm",
1710
+ "aria-label": "Zoom in",
1711
+ title: "Zoom in (+, \u2318/Ctrl + wheel)",
1712
+ disabled: !svg || zoom >= MERMAID_ZOOM_MAX,
1713
+ onClick: () => zoomBy(MERMAID_ZOOM_STEP),
1714
+ children: /* @__PURE__ */ jsx12(ZoomIn, {})
1715
+ }
1716
+ ),
1717
+ /* @__PURE__ */ jsx12(
1718
+ Button,
1719
+ {
1720
+ variant: "outline",
1721
+ size: "icon-sm",
1722
+ "aria-label": "Fit to frame",
1723
+ title: "Fit the whole diagram in the frame (f)",
1724
+ disabled: !svg,
1725
+ onClick: fit,
1726
+ children: /* @__PURE__ */ jsx12(Maximize2, {})
1727
+ }
1582
1728
  )
1583
- }
1729
+ ]
1584
1730
  }
1585
- ) })
1731
+ ),
1732
+ /* @__PURE__ */ jsx12(
1733
+ "div",
1734
+ {
1735
+ ref: scrollRef,
1736
+ className: frameClass,
1737
+ style: frameStyle,
1738
+ "data-testid": "mermaid-frame",
1739
+ "data-frame": frame,
1740
+ tabIndex: zoomable && svg ? 0 : -1,
1741
+ role: zoomable && svg ? "region" : void 0,
1742
+ "aria-label": zoomable && svg ? "Diagram. Drag to pan; Ctrl or Cmd plus wheel, or + and -, to zoom; 0 resets; f fits." : void 0,
1743
+ title: zoomable && svg ? "Drag to pan \xB7 \u2318/Ctrl + wheel to zoom" : void 0,
1744
+ onPointerDown,
1745
+ onPointerMove,
1746
+ onPointerUp: endDrag,
1747
+ onPointerCancel: endDrag,
1748
+ onKeyDown,
1749
+ children: body
1750
+ }
1751
+ )
1586
1752
  ] });
1587
1753
  };
1588
1754
 
@@ -3515,23 +3681,23 @@ var MarkdownEngineImpl = ({
3515
3681
  extraAllowedHtmlTags,
3516
3682
  streaming = false
3517
3683
  }) => {
3518
- const textSizes = useMemo3(() => resolveTextSizeConfig(textSize), [textSize]);
3684
+ const textSizes = useMemo4(() => resolveTextSizeConfig(textSize), [textSize]);
3519
3685
  const extraTagsKey = extraAllowedHtmlTags?.join("|") ?? "";
3520
- const effectiveTags = useMemo3(
3686
+ const effectiveTags = useMemo4(
3521
3687
  () => buildEffectiveTagSet(extraTagsKey ? extraTagsKey.split("|") : void 0),
3522
3688
  [extraTagsKey]
3523
3689
  );
3524
- const processedContent = useMemo3(() => {
3690
+ const processedContent = useMemo4(() => {
3525
3691
  const preprocessed = preprocessContent ? preprocessContent(content) : content;
3526
3692
  const completed = streaming ? completeStreamingTail(preprocessed) : preprocessed;
3527
3693
  return escapeUnknownHtmlTags(completed, effectiveTags);
3528
3694
  }, [preprocessContent, content, effectiveTags, streaming]);
3529
3695
  const headingIds = useHeadingIdMap(processedContent, sectionIds);
3530
- const remarkPlugins = useMemo3(
3696
+ const remarkPlugins = useMemo4(
3531
3697
  () => [remarkGfm, remarkBreaks, ...additionalRemarkPlugins ?? []],
3532
3698
  [additionalRemarkPlugins]
3533
3699
  );
3534
- const rehypePlugins = useMemo3(() => {
3700
+ const rehypePlugins = useMemo4(() => {
3535
3701
  const schema = buildSanitizeSchema({
3536
3702
  extraAllowedHtmlTags: extraTagsKey ? extraTagsKey.split("|") : void 0
3537
3703
  });
@@ -3545,7 +3711,7 @@ var MarkdownEngineImpl = ({
3545
3711
  [rehypeHighlight, { detect: true, ignoreMissing: true }]
3546
3712
  ];
3547
3713
  }, [extraTagsKey]);
3548
- const components = useMemo3(
3714
+ const components = useMemo4(
3549
3715
  () => ({
3550
3716
  ...buildBaseComponents({
3551
3717
  textSizes,
@@ -3561,7 +3727,7 @@ var MarkdownEngineImpl = ({
3561
3727
  }),
3562
3728
  [textSizes, demoteMarkdownH1ToH2, brokenLinks, currentPath, onInternalLinkClick, onResolveLink, componentOverrides]
3563
3729
  );
3564
- const streamingBlocks = useMemo3(
3730
+ const streamingBlocks = useMemo4(
3565
3731
  () => streaming ? splitStreamingBlocks(processedContent) : null,
3566
3732
  [streaming, processedContent]
3567
3733
  );
@@ -4210,7 +4376,7 @@ function hslToRgb(h, s, l) {
4210
4376
  import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
4211
4377
  import { useControllableState } from "@radix-ui/react-use-controllable-state";
4212
4378
  import { Check } from "lucide-react";
4213
- import React, { useCallback } from "react";
4379
+ import React, { useCallback as useCallback2 } from "react";
4214
4380
 
4215
4381
  // src/components/ui/actions-menu-header-context.ts
4216
4382
  import { createContext as createContext2, useContext as useContext2 } from "react";
@@ -4220,7 +4386,7 @@ function useIsInActionsMenuHeader() {
4220
4386
  }
4221
4387
 
4222
4388
  // src/components/ui/overlay-open-registry.tsx
4223
- import { createContext as createContext3, useContext as useContext3, useEffect as useEffect3, useMemo as useMemo4, useRef } from "react";
4389
+ import { createContext as createContext3, useContext as useContext3, useEffect as useEffect3, useMemo as useMemo5, useRef as useRef2 } from "react";
4224
4390
  import { jsx as jsx19 } from "react/jsx-runtime";
4225
4391
  var OverlayOpenRegistryContext = createContext3(null);
4226
4392
  function useOverlayOpenRegistry() {
@@ -4234,12 +4400,12 @@ function useReportOverlayOpen(open) {
4234
4400
  }, [open, registry]);
4235
4401
  }
4236
4402
  function OverlayOpenRegistryProvider({ onOpenChange, children }) {
4237
- const countRef = useRef(0);
4238
- const onOpenChangeRef = useRef(onOpenChange);
4403
+ const countRef = useRef2(0);
4404
+ const onOpenChangeRef = useRef2(onOpenChange);
4239
4405
  useEffect3(() => {
4240
4406
  onOpenChangeRef.current = onOpenChange;
4241
4407
  });
4242
- const registry = useMemo4(
4408
+ const registry = useMemo5(
4243
4409
  () => ({
4244
4410
  acquire: () => {
4245
4411
  countRef.current += 1;
@@ -4265,7 +4431,7 @@ var ROW_CLASSES = "flex flex-1 min-w-0 items-center gap-[var(--spacing-system-xs
4265
4431
  var WRAPPER_CLASSES = "relative flex items-stretch border-b border-ods-border last:border-b-0";
4266
4432
  var SECONDARY_ACTION_CLASSES = "flex p-[var(--spacing-system-s)] shrink-0 items-center justify-center self-stretch border-l border-ods-border transition-colors hover:bg-ods-bg-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ods-focus [&_svg]:w-4 [&_svg]:h-4 md:[&_svg]:w-6 md:[&_svg]:h-6";
4267
4433
  var SecondaryAction = ({ action }) => {
4268
- const handleClick = useCallback(
4434
+ const handleClick = useCallback2(
4269
4435
  (e) => {
4270
4436
  e.stopPropagation();
4271
4437
  if (action.disabled) {
@@ -4313,7 +4479,7 @@ var SecondaryAction = ({ action }) => {
4313
4479
  var MenuItem = ({ item, onItemClick }) => {
4314
4480
  const portalContainer = usePortalContainer();
4315
4481
  const collisionBoundary = useCollisionBoundary();
4316
- const activate = useCallback(() => {
4482
+ const activate = useCallback2(() => {
4317
4483
  if (item.disabled) return;
4318
4484
  if (item.type === "checkbox") {
4319
4485
  item.onClick?.();
@@ -4324,7 +4490,7 @@ var MenuItem = ({ item, onItemClick }) => {
4324
4490
  item.onClick?.();
4325
4491
  onItemClick?.(item);
4326
4492
  }, [item, onItemClick]);
4327
- const handleClick = useCallback(
4493
+ const handleClick = useCallback2(
4328
4494
  (e) => {
4329
4495
  e.stopPropagation();
4330
4496
  e.preventDefault();
@@ -4332,7 +4498,7 @@ var MenuItem = ({ item, onItemClick }) => {
4332
4498
  },
4333
4499
  [activate]
4334
4500
  );
4335
- const handleKeyDown = useCallback(
4501
+ const handleKeyDown = useCallback2(
4336
4502
  (e) => {
4337
4503
  if (e.key !== "Enter" && e.key !== " ") return;
4338
4504
  e.preventDefault();
@@ -4341,7 +4507,7 @@ var MenuItem = ({ item, onItemClick }) => {
4341
4507
  },
4342
4508
  [activate]
4343
4509
  );
4344
- const handleLinkClick = useCallback(
4510
+ const handleLinkClick = useCallback2(
4345
4511
  (e) => {
4346
4512
  if (item.disabled) {
4347
4513
  e.preventDefault();
@@ -4512,7 +4678,7 @@ var ActionsMenuDropdown = ({
4512
4678
  document.addEventListener("scroll", onScroll, { capture: true, passive: true });
4513
4679
  return () => document.removeEventListener("scroll", onScroll, { capture: true });
4514
4680
  }, [open, setOpen]);
4515
- const handleItemClick = useCallback(
4681
+ const handleItemClick = useCallback2(
4516
4682
  (item) => {
4517
4683
  onItemClick?.(item);
4518
4684
  if (item.type !== "checkbox" && item.type !== "submenu" && item.closeOnSelect !== false) {
@@ -5043,12 +5209,12 @@ ChatFooter.displayName = "ChatFooter";
5043
5209
  // src/components/chat/chat-input.tsx
5044
5210
  import {
5045
5211
  useState as useState10,
5046
- useRef as useRef2,
5212
+ useRef as useRef3,
5047
5213
  useImperativeHandle,
5048
5214
  forwardRef as forwardRef14,
5049
- useCallback as useCallback2,
5215
+ useCallback as useCallback3,
5050
5216
  useEffect as useEffect4,
5051
- useMemo as useMemo5
5217
+ useMemo as useMemo6
5052
5218
  } from "react";
5053
5219
  import { renderToStaticMarkup } from "react-dom/server";
5054
5220
 
@@ -5847,15 +6013,15 @@ var ChatInput = forwardRef14((allProps, ref) => {
5847
6013
  const [focused, setFocused] = useState10(false);
5848
6014
  const [isStopping, setIsStopping] = useState10(false);
5849
6015
  const [previewDismissed, setPreviewDismissed] = useState10(false);
5850
- const editorRef = useRef2(null);
5851
- const shouldRefocusRef = useRef2(false);
5852
- const prevSendingRef = useRef2(sending);
5853
- const prevAwaitingResponseRef = useRef2(awaitingResponse);
5854
- const isComposingRef = useRef2(false);
5855
- const valueRef = useRef2(value);
6016
+ const editorRef = useRef3(null);
6017
+ const shouldRefocusRef = useRef3(false);
6018
+ const prevSendingRef = useRef3(sending);
6019
+ const prevAwaitingResponseRef = useRef3(awaitingResponse);
6020
+ const isComposingRef = useRef3(false);
6021
+ const valueRef = useRef3(value);
5856
6022
  valueRef.current = value;
5857
- const metaRef = useRef2(/* @__PURE__ */ new Map());
5858
- const focusEditor = useCallback2(() => {
6023
+ const metaRef = useRef3(/* @__PURE__ */ new Map());
6024
+ const focusEditor = useCallback3(() => {
5859
6025
  if (disabled) return;
5860
6026
  editorRef.current?.focus({ preventScroll: true });
5861
6027
  }, [disabled]);
@@ -5865,7 +6031,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
5865
6031
  useEffect4(() => {
5866
6032
  onValueChange?.(value);
5867
6033
  }, [value, onValueChange]);
5868
- const previewTextRef = useRef2(previewText);
6034
+ const previewTextRef = useRef3(previewText);
5869
6035
  useEffect4(() => {
5870
6036
  previewTextRef.current = previewText;
5871
6037
  });
@@ -5875,7 +6041,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
5875
6041
  useEffect4(() => {
5876
6042
  if (previewTextRef.current) setPreviewDismissed(true);
5877
6043
  }, [value]);
5878
- const applyValue = useCallback2((next, caret = "end") => {
6044
+ const applyValue = useCallback3((next, caret = "end") => {
5879
6045
  const el = editorRef.current;
5880
6046
  if (el) {
5881
6047
  rebuildDom(el, next, metaRef.current);
@@ -5888,7 +6054,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
5888
6054
  valueRef.current = next;
5889
6055
  setValue(next);
5890
6056
  }, []);
5891
- const fire = useCallback2(
6057
+ const fire = useCallback3(
5892
6058
  (message) => {
5893
6059
  const can = (message.length > 0 || allowEmptySend) && !sending && !disabled;
5894
6060
  if (!can || !onSend) return;
@@ -5913,7 +6079,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
5913
6079
  },
5914
6080
  [allowEmptySend, sending, disabled, onSend, focusEditor, applyValue]
5915
6081
  );
5916
- const handleSubmit = useCallback2(() => {
6082
+ const handleSubmit = useCallback3(() => {
5917
6083
  fire(valueRef.current.trim());
5918
6084
  }, [fire]);
5919
6085
  useImperativeHandle(
@@ -5949,7 +6115,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
5949
6115
  [focusEditor, fire, applyValue]
5950
6116
  );
5951
6117
  const mentionEnabled = !!onMentionQueryChange;
5952
- const mentionQuery = useMemo5(() => {
6118
+ const mentionQuery = useMemo6(() => {
5953
6119
  if (!mentionEnabled) return null;
5954
6120
  const m = value.match(MENTION_TRIGGER_AT_END);
5955
6121
  return m ? m[2] ?? "" : null;
@@ -5957,7 +6123,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
5957
6123
  useEffect4(() => {
5958
6124
  if (mentionEnabled) onMentionQueryChange?.(mentionQuery);
5959
6125
  }, [mentionEnabled, mentionQuery, onMentionQueryChange]);
5960
- const slashMatch = useMemo5(() => slashCommands ? value.match(SLASH_INPUT_TRIGGER) : null, [value, slashCommands]);
6126
+ const slashMatch = useMemo6(() => slashCommands ? value.match(SLASH_INPUT_TRIGGER) : null, [value, slashCommands]);
5961
6127
  const slashPrefix = slashMatch ? slashMatch[1] ?? "" : null;
5962
6128
  const [slashSuggestions, setSlashSuggestions] = useState10([]);
5963
6129
  const [highlightedIdx, setHighlightedIdx] = useState10(0);
@@ -5992,7 +6158,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
5992
6158
  clearTimeout(handle);
5993
6159
  };
5994
6160
  }, [slashPrefix, slashCommands]);
5995
- const acceptSuggestion = useCallback2(
6161
+ const acceptSuggestion = useCallback3(
5996
6162
  (cmd) => {
5997
6163
  metaRef.current = /* @__PURE__ */ new Map();
5998
6164
  const next = `/${cmd.id} `;
@@ -6002,17 +6168,17 @@ var ChatInput = forwardRef14((allProps, ref) => {
6002
6168
  },
6003
6169
  [applyValue, focusEditor]
6004
6170
  );
6005
- const syncFromDom = useCallback2(() => {
6171
+ const syncFromDom = useCallback3(() => {
6006
6172
  const el = editorRef.current;
6007
6173
  if (!el) return;
6008
6174
  setHasChips(el.querySelector("[data-token]") !== null);
6009
6175
  setValue(serialize(el));
6010
6176
  }, []);
6011
- const handleInput = useCallback2(() => {
6177
+ const handleInput = useCallback3(() => {
6012
6178
  if (isComposingRef.current) return;
6013
6179
  syncFromDom();
6014
6180
  }, [syncFromDom]);
6015
- const handlePaste = useCallback2(
6181
+ const handlePaste = useCallback3(
6016
6182
  (e) => {
6017
6183
  e.preventDefault();
6018
6184
  const text2 = e.clipboardData.getData("text/plain");
@@ -6022,7 +6188,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
6022
6188
  },
6023
6189
  [syncFromDom]
6024
6190
  );
6025
- const handleKeyDown = useCallback2(
6191
+ const handleKeyDown = useCallback3(
6026
6192
  (e) => {
6027
6193
  if (slashSuggestions.length > 0 && slashPrefix !== null) {
6028
6194
  if (e.key === "Escape") {
@@ -6080,7 +6246,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
6080
6246
  syncFromDom
6081
6247
  ]
6082
6248
  );
6083
- const handleEditorMouseDown = useCallback2(
6249
+ const handleEditorMouseDown = useCallback3(
6084
6250
  (e) => {
6085
6251
  const target = e.target;
6086
6252
  const chip = target.closest("[data-token]");
@@ -6112,7 +6278,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
6112
6278
  const id = requestAnimationFrame(() => focusEditor());
6113
6279
  return () => cancelAnimationFrame(id);
6114
6280
  }, [awaitingResponse, disabled, focusEditor]);
6115
- const handleStop = useCallback2(async () => {
6281
+ const handleStop = useCallback3(async () => {
6116
6282
  if (!onStop || isStopping) return;
6117
6283
  setIsStopping(true);
6118
6284
  try {
@@ -6272,7 +6438,7 @@ var ChatInput = forwardRef14((allProps, ref) => {
6272
6438
  ChatInput.displayName = "ChatInput";
6273
6439
 
6274
6440
  // src/components/chat/chat-message-enhanced.tsx
6275
- import React2, { forwardRef as forwardRef16, memo as memo2, useEffect as useEffect6, useMemo as useMemo8, useRef as useRef4 } from "react";
6441
+ import React2, { forwardRef as forwardRef16, memo as memo2, useEffect as useEffect6, useMemo as useMemo9, useRef as useRef5 } from "react";
6276
6442
 
6277
6443
  // src/chat-protocol/card-marker.ts
6278
6444
  var CARD_TYPE = "[a-zA-Z0-9_-]+";
@@ -6395,10 +6561,10 @@ function createUTCTimestamp() {
6395
6561
 
6396
6562
  // src/components/chat/chat-context-picker.tsx
6397
6563
  import { QueryErrorResetBoundary } from "@tanstack/react-query";
6398
- import { Fragment as Fragment7, Suspense, useCallback as useCallback4, useEffect as useEffect5, useLayoutEffect as useLayoutEffect2, useMemo as useMemo6, useRef as useRef3, useState as useState11 } from "react";
6564
+ import { Fragment as Fragment7, Suspense, useCallback as useCallback5, useEffect as useEffect5, useLayoutEffect as useLayoutEffect3, useMemo as useMemo7, useRef as useRef4, useState as useState11 } from "react";
6399
6565
 
6400
6566
  // src/components/chat/context-items-list.tsx
6401
- import { Component, useCallback as useCallback3 } from "react";
6567
+ import { Component, useCallback as useCallback4 } from "react";
6402
6568
  import { Fragment as Fragment6, jsx as jsx32, jsxs as jsxs22 } from "react/jsx-runtime";
6403
6569
  var itemKey = (i) => `${i.type}:${i.id}`;
6404
6570
  var CONTEXT_ROW_CLASS = "flex w-full items-center gap-2 border-b border-ods-border bg-ods-bg py-3 pl-4 pr-2 text-left outline-none transition-colors last:border-b-0 hover:bg-ods-bg-hover focus-visible:bg-ods-bg-hover [&_svg]:size-4 md:[&_svg]:size-6";
@@ -6455,7 +6621,7 @@ function ContextItemsList({
6455
6621
  emptyLabel = "No results",
6456
6622
  className
6457
6623
  }) {
6458
- const onScroll = useCallback3(
6624
+ const onScroll = useCallback4(
6459
6625
  (e) => {
6460
6626
  if (!hasMore || loadingMore || !onLoadMore) return;
6461
6627
  const el = e.currentTarget;
@@ -6568,12 +6734,12 @@ function ChatContextPicker({
6568
6734
  const [activeType, setActiveType] = useState11(null);
6569
6735
  const [query, setQuery] = useState11("");
6570
6736
  const [debouncedQuery, setDebouncedQuery] = useState11("");
6571
- const rootRef = useRef3(null);
6572
- const searchRef = useRef3(null);
6737
+ const rootRef = useRef4(null);
6738
+ const searchRef = useRef4(null);
6573
6739
  const maxItems = config.maxItems ?? CHAT_CONTEXT_ITEMS_DEFAULT_MAX;
6574
6740
  const atLimit = selectedItems.length >= maxItems;
6575
- const selectedKeys = useMemo6(() => new Set(selectedItems.map(itemKey2)), [selectedItems]);
6576
- const mentionQueryRef = useRef3(mentionQuery);
6741
+ const selectedKeys = useMemo7(() => new Set(selectedItems.map(itemKey2)), [selectedItems]);
6742
+ const mentionQueryRef = useRef4(mentionQuery);
6577
6743
  useEffect5(() => {
6578
6744
  mentionQueryRef.current = mentionQuery;
6579
6745
  });
@@ -6605,7 +6771,7 @@ function ChatContextPicker({
6605
6771
  }, [query]);
6606
6772
  const [measuredMaxH, setAvailMaxH] = useState11(void 0);
6607
6773
  const availMaxH = open ? measuredMaxH : void 0;
6608
- useLayoutEffect2(() => {
6774
+ useLayoutEffect3(() => {
6609
6775
  if (!open) return void 0;
6610
6776
  const measure = () => {
6611
6777
  const el = rootRef.current;
@@ -6631,20 +6797,20 @@ function ChatContextPicker({
6631
6797
  window.removeEventListener("resize", measure);
6632
6798
  };
6633
6799
  }, [open, view]);
6634
- const openType = useCallback4((type) => {
6800
+ const openType = useCallback5((type) => {
6635
6801
  setActiveType(type);
6636
6802
  setQuery("");
6637
6803
  setDebouncedQuery("");
6638
6804
  setView("items");
6639
6805
  }, []);
6640
- const backToTypes = useCallback4(() => {
6806
+ const backToTypes = useCallback5(() => {
6641
6807
  setActiveType(null);
6642
6808
  setQuery("");
6643
6809
  setDebouncedQuery("");
6644
6810
  setView("types");
6645
6811
  }, []);
6646
6812
  const typeFilter = (mentionQuery ?? "").trim().toLowerCase();
6647
- const visibleTypes = useMemo6(
6813
+ const visibleTypes = useMemo7(
6648
6814
  () => typeFilter ? config.entityTypes.filter((t) => t.label.toLowerCase().includes(typeFilter)) : config.entityTypes,
6649
6815
  [config.entityTypes, typeFilter]
6650
6816
  );
@@ -6915,7 +7081,7 @@ var remarkStripCitations = () => {
6915
7081
  };
6916
7082
 
6917
7083
  // src/components/chat/tool-execution-display.tsx
6918
- import { forwardRef as forwardRef15, useMemo as useMemo7, useState as useState12 } from "react";
7084
+ import { forwardRef as forwardRef15, useMemo as useMemo8, useState as useState12 } from "react";
6919
7085
  import { Fragment as Fragment9, jsx as jsx34, jsxs as jsxs24 } from "react/jsx-runtime";
6920
7086
  var COMMAND_BODY_KEYS2 = new Set(COMMAND_BODY_ARG_KEYS);
6921
7087
  var ToolExecutionDisplay = forwardRef15(
@@ -6928,7 +7094,7 @@ var ToolExecutionDisplay = forwardRef15(
6928
7094
  const isExecuted = message.type === "EXECUTED_TOOL";
6929
7095
  const integratedToolType = message.integratedToolType || "OPENFRAME";
6930
7096
  const previewText = variant === "client" ? message.toolExplanation?.trim() : message.toolTitle?.trim();
6931
- const argEntries = useMemo7(() => {
7097
+ const argEntries = useMemo8(() => {
6932
7098
  if (!message.parameters || typeof message.parameters !== "object") return [];
6933
7099
  const entries = Object.entries(message.parameters).filter(([, v]) => v !== null && v !== void 0 && v !== "");
6934
7100
  if (variant === "client") {
@@ -7078,10 +7244,10 @@ var ChatMessageEnhanced = forwardRef16(
7078
7244
  const isError = role === "error";
7079
7245
  const authorType = authorTypeProp ?? (isUser ? "user" : assistantType === "mingo" ? "mingo" : "fae");
7080
7246
  const hasMarkerSupport = !!renderEntityCard;
7081
- const segments = useMemo8(() => normalizeContent(content), [content]);
7082
- const askRuns = useMemo8(() => groupAskRuns(segments), [segments]);
7247
+ const segments = useMemo9(() => normalizeContent(content), [content]);
7248
+ const askRuns = useMemo9(() => groupAskRuns(segments), [segments]);
7083
7249
  const hasMentionSupport = !!renderMention;
7084
- const inlineMentionIds = useMemo8(() => {
7250
+ const inlineMentionIds = useMemo9(() => {
7085
7251
  const ids = /* @__PURE__ */ new Set();
7086
7252
  if (!hasMentionSupport) return ids;
7087
7253
  for (const seg of segments) {
@@ -7090,26 +7256,26 @@ var ChatMessageEnhanced = forwardRef16(
7090
7256
  }
7091
7257
  return ids;
7092
7258
  }, [hasMentionSupport, segments]);
7093
- const stripContextItems = useMemo8(
7259
+ const stripContextItems = useMemo9(
7094
7260
  () => inlineMentionIds.size > 0 && contextItems ? contextItems.filter((it) => !inlineMentionIds.has(it.id)) : contextItems,
7095
7261
  [contextItems, inlineMentionIds]
7096
7262
  );
7097
- const cardRemarkPlugins = useMemo8(
7263
+ const cardRemarkPlugins = useMemo9(
7098
7264
  () => [
7099
7265
  ...hasMarkerSupport ? [remarkCardLinks, remarkStripCitations] : [],
7100
7266
  ...hasMentionSupport ? [remarkMentionChips] : []
7101
7267
  ],
7102
7268
  [hasMarkerSupport, hasMentionSupport]
7103
7269
  );
7104
- const renderedCardNodeCache = useRef4(
7270
+ const renderedCardNodeCache = useRef5(
7105
7271
  /* @__PURE__ */ new Map()
7106
7272
  );
7107
- const refByKey = useMemo8(() => {
7273
+ const refByKey = useMemo9(() => {
7108
7274
  const byKey2 = /* @__PURE__ */ new Map();
7109
7275
  for (const described of refs ?? []) byKey2.set(`${described.type}:${described.id}`, described);
7110
7276
  return byKey2;
7111
7277
  }, [refs]);
7112
- const renderingPlan = useMemo8(() => {
7278
+ const renderingPlan = useMemo9(() => {
7113
7279
  if (!hasMarkerSupport) return null;
7114
7280
  const render2 = renderEntityCard;
7115
7281
  const inlineByKey = /* @__PURE__ */ new Map();
@@ -7183,9 +7349,9 @@ var ChatMessageEnhanced = forwardRef16(
7183
7349
  if (!usedKeys.has(k)) cache.delete(k);
7184
7350
  }
7185
7351
  }, [renderingPlan]);
7186
- const renderingPlanRef = useRef4(renderingPlan);
7352
+ const renderingPlanRef = useRef5(renderingPlan);
7187
7353
  renderingPlanRef.current = renderingPlan;
7188
- const cardComponentOverrides = useMemo8(() => {
7354
+ const cardComponentOverrides = useMemo9(() => {
7189
7355
  if (!hasMarkerSupport && !hasMentionSupport) return void 0;
7190
7356
  return {
7191
7357
  // Override `<a>` to detect `card://` URLs emitted by `remarkCardLinks`.
@@ -7411,13 +7577,13 @@ MemoizedChatMessageEnhanced.displayName = "MemoizedChatMessageEnhanced";
7411
7577
 
7412
7578
  // src/components/chat/chat-message-list.tsx
7413
7579
  import {
7414
- useRef as useRef5,
7580
+ useRef as useRef6,
7415
7581
  useState as useState14,
7416
- useCallback as useCallback5,
7582
+ useCallback as useCallback6,
7417
7583
  useEffect as useEffect8,
7418
- useLayoutEffect as useLayoutEffect3,
7584
+ useLayoutEffect as useLayoutEffect4,
7419
7585
  useImperativeHandle as useImperativeHandle2,
7420
- useMemo as useMemo10,
7586
+ useMemo as useMemo11,
7421
7587
  forwardRef as forwardRef17
7422
7588
  } from "react";
7423
7589
  import { useStickToBottom } from "use-stick-to-bottom";
@@ -7490,7 +7656,7 @@ function ChatMessageListSkeleton({
7490
7656
  }
7491
7657
 
7492
7658
  // src/components/chat/cycling-phrase.tsx
7493
- import { useEffect as useEffect7, useMemo as useMemo9, useState as useState13 } from "react";
7659
+ import { useEffect as useEffect7, useMemo as useMemo10, useState as useState13 } from "react";
7494
7660
  import { jsx as jsx37, jsxs as jsxs27 } from "react/jsx-runtime";
7495
7661
  var BLINK_KEYFRAMES = `
7496
7662
  @keyframes cyclingCursorBlink {
@@ -7504,7 +7670,7 @@ function CyclingPhrase({ words, className, charMs = 60, holdMs = 4500 }) {
7504
7670
  const target = words[wordIndex] ?? "";
7505
7671
  const holding = words.length > 0 && cursor >= Math.max(text2.length, target.length);
7506
7672
  const shownText = holding ? target : text2;
7507
- const placeholder = useMemo9(
7673
+ const placeholder = useMemo10(
7508
7674
  () => words.reduce((longest, w) => w.length > longest.length ? w : longest, ""),
7509
7675
  [words]
7510
7676
  );
@@ -7622,17 +7788,17 @@ var ChatMessageList = forwardRef17(
7622
7788
  resize: "smooth",
7623
7789
  initial: false
7624
7790
  });
7625
- const lastUserMessageIndex = useMemo10(() => {
7791
+ const lastUserMessageIndex = useMemo11(() => {
7626
7792
  for (let i = messages.length - 1; i >= 0; i--) {
7627
7793
  if (messages[i].role === "user") return i;
7628
7794
  }
7629
7795
  return -1;
7630
7796
  }, [messages]);
7631
- const overlayOpenRef = useRef5(false);
7632
- const wasAtBottomOnOpenRef = useRef5(false);
7633
- const isAtBottomRef = useRef5(isAtBottom);
7797
+ const overlayOpenRef = useRef6(false);
7798
+ const wasAtBottomOnOpenRef = useRef6(false);
7799
+ const isAtBottomRef = useRef6(isAtBottom);
7634
7800
  isAtBottomRef.current = isAtBottom;
7635
- const handleOverlayOpenChange = useCallback5(
7801
+ const handleOverlayOpenChange = useCallback6(
7636
7802
  (hasOpenOverlay) => {
7637
7803
  overlayOpenRef.current = hasOpenOverlay;
7638
7804
  if (hasOpenOverlay) {
@@ -7646,17 +7812,17 @@ var ChatMessageList = forwardRef17(
7646
7812
  },
7647
7813
  [scrollToBottom, stopScroll]
7648
7814
  );
7649
- const sentinelRef = useRef5(null);
7650
- const onLoadMoreRef = useRef5(onLoadMore);
7815
+ const sentinelRef = useRef6(null);
7816
+ const onLoadMoreRef = useRef6(onLoadMore);
7651
7817
  onLoadMoreRef.current = onLoadMore;
7652
- const isFetchingRef = useRef5(isFetchingNextPage);
7818
+ const isFetchingRef = useRef6(isFetchingNextPage);
7653
7819
  isFetchingRef.current = isFetchingNextPage;
7654
- const dialogIdRef = useRef5(dialogId);
7820
+ const dialogIdRef = useRef6(dialogId);
7655
7821
  dialogIdRef.current = dialogId;
7656
- const followBottomRef = useRef5(false);
7822
+ const followBottomRef = useRef6(false);
7657
7823
  const [atBottom, setAtBottom] = useState14(true);
7658
- const prevRenderRef = useRef5({ dialogId: void 0, messageCount: 0, lastMessageId: void 0 });
7659
- const loadOlderAnchorRef = useRef5(null);
7824
+ const prevRenderRef = useRef6({ dialogId: void 0, messageCount: 0, lastMessageId: void 0 });
7825
+ const loadOlderAnchorRef = useRef6(null);
7660
7826
  useEffect8(() => {
7661
7827
  if (!autoScroll) return;
7662
7828
  const dialogChanged = dialogId !== prevRenderRef.current.dialogId;
@@ -7786,8 +7952,8 @@ var ChatMessageList = forwardRef17(
7786
7952
  window.removeEventListener("blur", endPointer);
7787
7953
  };
7788
7954
  }, [autoScroll, scrollRef, contentRef, scrollToBottom, stopScroll, isLoading]);
7789
- const pinPrevHeightRef = useRef5(0);
7790
- useLayoutEffect3(() => {
7955
+ const pinPrevHeightRef = useRef6(0);
7956
+ useLayoutEffect4(() => {
7791
7957
  if (!pinBottom) {
7792
7958
  pinPrevHeightRef.current = 0;
7793
7959
  return;
@@ -7798,7 +7964,7 @@ var ChatMessageList = forwardRef17(
7798
7964
  pinPrevHeightRef.current = el.scrollHeight;
7799
7965
  el.scrollTop = el.scrollHeight;
7800
7966
  }, [pinBottom, messages, isTyping, pendingApprovals, scrollRef]);
7801
- useLayoutEffect3(() => {
7967
+ useLayoutEffect4(() => {
7802
7968
  const el = scrollRef.current;
7803
7969
  const anchor = loadOlderAnchorRef.current;
7804
7970
  if (!el || !anchor) return;
@@ -7811,8 +7977,8 @@ var ChatMessageList = forwardRef17(
7811
7977
  loadOlderAnchorRef.current = null;
7812
7978
  el.scrollTop = anchor.scrollTop + addedHeight;
7813
7979
  }, [messages, dialogId, scrollRef]);
7814
- const messageElsRef = useRef5(/* @__PURE__ */ new Map());
7815
- const refCallbacksRef = useRef5(/* @__PURE__ */ new Map());
7980
+ const messageElsRef = useRef6(/* @__PURE__ */ new Map());
7981
+ const refCallbacksRef = useRef6(/* @__PURE__ */ new Map());
7816
7982
  const getRegisterMessageEl = (id) => {
7817
7983
  let cb = refCallbacksRef.current.get(id);
7818
7984
  if (cb) return cb;
@@ -7827,12 +7993,12 @@ var ChatMessageList = forwardRef17(
7827
7993
  refCallbacksRef.current.set(id, cb);
7828
7994
  return cb;
7829
7995
  };
7830
- const scrolledIdsRef = useRef5(null);
7996
+ const scrolledIdsRef = useRef6(null);
7831
7997
  if (scrolledIdsRef.current === null) {
7832
7998
  scrolledIdsRef.current = new Set(messages.filter((m) => hasNonEmptyContent(m.content)).map((m) => m.id));
7833
7999
  }
7834
- const anchorWatcherRef = useRef5(null);
7835
- useLayoutEffect3(() => {
8000
+ const anchorWatcherRef = useRef6(null);
8001
+ useLayoutEffect4(() => {
7836
8002
  if (!autoScroll) return;
7837
8003
  if (overlayOpenRef.current) return;
7838
8004
  const last = messages[messages.length - 1];
@@ -7902,13 +8068,13 @@ var ChatMessageList = forwardRef17(
7902
8068
  return () => observer.disconnect();
7903
8069
  }, [hasNextPage, isFetchingNextPage, scrollRef, isLoading]);
7904
8070
  useImperativeHandle2(ref, () => scrollRef.current, [scrollRef, isLoading]);
7905
- const setScrollRef = useCallback5(
8071
+ const setScrollRef = useCallback6(
7906
8072
  (el) => {
7907
8073
  scrollRef(el);
7908
8074
  },
7909
8075
  [scrollRef]
7910
8076
  );
7911
- const setContentRef = useCallback5(
8077
+ const setContentRef = useCallback6(
7912
8078
  (el) => {
7913
8079
  contentRef(el);
7914
8080
  },
@@ -8320,18 +8486,18 @@ function QuickActionChipFromData({
8320
8486
  }
8321
8487
 
8322
8488
  // src/components/chat/quick-action-marquee.tsx
8323
- import { useMemo as useMemo13 } from "react";
8489
+ import { useMemo as useMemo14 } from "react";
8324
8490
 
8325
8491
  // src/components/chat/quick-action-wall.tsx
8326
- import { useRef as useRef7, useState as useState17, useEffect as useEffect10, useMemo as useMemo12 } from "react";
8492
+ import { useRef as useRef8, useState as useState17, useEffect as useEffect10, useMemo as useMemo13 } from "react";
8327
8493
 
8328
8494
  // src/components/ui/marquee-wall.tsx
8329
8495
  import {
8330
- useCallback as useCallback6,
8496
+ useCallback as useCallback7,
8331
8497
  useEffect as useEffect9,
8332
- useLayoutEffect as useLayoutEffect4,
8333
- useMemo as useMemo11,
8334
- useRef as useRef6,
8498
+ useLayoutEffect as useLayoutEffect5,
8499
+ useMemo as useMemo12,
8500
+ useRef as useRef7,
8335
8501
  useState as useState16,
8336
8502
  useSyncExternalStore as useSyncExternalStore2
8337
8503
  } from "react";
@@ -8465,16 +8631,16 @@ function MarqueeWall({
8465
8631
  sync,
8466
8632
  trackId
8467
8633
  }) {
8468
- const fades = useMemo11(() => normalizeFades(fade), [fade]);
8634
+ const fades = useMemo12(() => normalizeFades(fade), [fade]);
8469
8635
  const axis = axisProp ?? (fades.includes("top") || fades.includes("bottom") ? "y" : "x");
8470
- const containerRef = useRef6(null);
8471
- const trackRef = useRef6(null);
8472
- const copyRef = useRef6(null);
8636
+ const containerRef = useRef7(null);
8637
+ const trackRef = useRef7(null);
8638
+ const copyRef = useRef7(null);
8473
8639
  const reducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)") ?? false;
8474
8640
  const [overflows, setOverflows] = useState16(false);
8475
- const copySizeRef = useRef6(0);
8476
- const wrapSizeRef = useRef6(0);
8477
- const measure = useCallback6(() => {
8641
+ const copySizeRef = useRef7(0);
8642
+ const wrapSizeRef = useRef7(0);
8643
+ const measure = useCallback7(() => {
8478
8644
  const container = containerRef.current;
8479
8645
  const copy = copyRef.current;
8480
8646
  if (!container || !copy) return;
@@ -8507,22 +8673,22 @@ function MarqueeWall({
8507
8673
  io.observe(el);
8508
8674
  return () => io.disconnect();
8509
8675
  }, []);
8510
- const pointerInsideRef = useRef6(false);
8511
- const clearPointerInside = useCallback6(() => {
8676
+ const pointerInsideRef = useRef7(false);
8677
+ const clearPointerInside = useCallback7(() => {
8512
8678
  pointerInsideRef.current = false;
8513
8679
  }, []);
8514
- const onPointerEnter = useCallback6((e) => {
8680
+ const onPointerEnter = useCallback7((e) => {
8515
8681
  if (e.pointerType === "touch") return;
8516
8682
  pointerInsideRef.current = true;
8517
8683
  }, []);
8518
- const onPointerLeave = useCallback6((e) => {
8684
+ const onPointerLeave = useCallback7((e) => {
8519
8685
  if (e.pointerType === "touch") return;
8520
8686
  pointerInsideRef.current = false;
8521
8687
  }, []);
8522
8688
  useResetOnPageHidden(clearPointerInside);
8523
- const draggingRef = useRef6(false);
8524
- const dragSuppressUntilRef = useRef6(0);
8525
- const applyTransform = useCallback6(
8689
+ const draggingRef = useRef7(false);
8690
+ const dragSuppressUntilRef = useRef7(0);
8691
+ const applyTransform = useCallback7(
8526
8692
  (pos) => {
8527
8693
  const track = trackRef.current;
8528
8694
  if (!track) return;
@@ -8538,7 +8704,7 @@ function MarqueeWall({
8538
8704
  },
8539
8705
  [axis, reverse, trackId]
8540
8706
  );
8541
- const applyPos = useCallback6(
8707
+ const applyPos = useCallback7(
8542
8708
  (pos) => {
8543
8709
  if (sync) {
8544
8710
  sync.publish(pos);
@@ -8554,7 +8720,7 @@ function MarqueeWall({
8554
8720
  if (track) track.style.transform = "";
8555
8721
  if (trackId) MARQUEE_TRACK_OFFSETS.set(trackId, ZERO_OFFSET);
8556
8722
  }, [marqueeMounted, trackId]);
8557
- const applyTransformRef = useRef6(applyTransform);
8723
+ const applyTransformRef = useRef7(applyTransform);
8558
8724
  useEffect9(() => {
8559
8725
  applyTransformRef.current = applyTransform;
8560
8726
  });
@@ -8582,7 +8748,7 @@ function MarqueeWall({
8582
8748
  // (engine seeds from readBack on activation) instead of restarting at 0.
8583
8749
  readBack: sync ? () => sync.readPosition() : void 0
8584
8750
  });
8585
- useLayoutEffect4(() => {
8751
+ useLayoutEffect5(() => {
8586
8752
  if (!marqueeMounted) {
8587
8753
  posRef.current = 0;
8588
8754
  return;
@@ -8592,10 +8758,10 @@ function MarqueeWall({
8592
8758
  }
8593
8759
  }, [marqueeMounted, reverse, posRef]);
8594
8760
  const DRAG_RESUME_MS = 1200;
8595
- const dragStartRef = useRef6({ coord: 0, pos: 0 });
8596
- const dragMovedRef = useRef6(false);
8597
- const suppressClickRef = useRef6(false);
8598
- const onDragPointerDown = useCallback6(
8761
+ const dragStartRef = useRef7({ coord: 0, pos: 0 });
8762
+ const dragMovedRef = useRef7(false);
8763
+ const suppressClickRef = useRef7(false);
8764
+ const onDragPointerDown = useCallback7(
8599
8765
  (e) => {
8600
8766
  if (!marqueeMounted) return;
8601
8767
  draggingRef.current = true;
@@ -8605,7 +8771,7 @@ function MarqueeWall({
8605
8771
  },
8606
8772
  [marqueeMounted, axis, posRef]
8607
8773
  );
8608
- const onDragPointerMove = useCallback6(
8774
+ const onDragPointerMove = useCallback7(
8609
8775
  (e) => {
8610
8776
  if (!draggingRef.current) return;
8611
8777
  const delta = (axis === "y" ? e.clientY : e.clientX) - dragStartRef.current.coord;
@@ -8622,7 +8788,7 @@ function MarqueeWall({
8622
8788
  },
8623
8789
  [axis, reverse, wrap, posRef, applyPos]
8624
8790
  );
8625
- const onDragPointerUp = useCallback6((e) => {
8791
+ const onDragPointerUp = useCallback7((e) => {
8626
8792
  if (!draggingRef.current) return;
8627
8793
  draggingRef.current = false;
8628
8794
  if (dragMovedRef.current) suppressClickRef.current = true;
@@ -8634,14 +8800,14 @@ function MarqueeWall({
8634
8800
  }
8635
8801
  }
8636
8802
  }, []);
8637
- const onDragPointerLeave = useCallback6(
8803
+ const onDragPointerLeave = useCallback7(
8638
8804
  (e) => {
8639
8805
  onPointerLeave(e);
8640
8806
  if (draggingRef.current && !dragMovedRef.current) draggingRef.current = false;
8641
8807
  },
8642
8808
  [onPointerLeave]
8643
8809
  );
8644
- const onDragClickCapture = useCallback6((e) => {
8810
+ const onDragClickCapture = useCallback7((e) => {
8645
8811
  if (suppressClickRef.current) {
8646
8812
  suppressClickRef.current = false;
8647
8813
  e.preventDefault();
@@ -8759,7 +8925,7 @@ function QuickActionWall({
8759
8925
  contentClassName,
8760
8926
  sync
8761
8927
  }) {
8762
- const brickRef = useRef7(null);
8928
+ const brickRef = useRef8(null);
8763
8929
  const [brickWidth, setBrickWidth] = useState17(0);
8764
8930
  const [chipWidth, setChipWidth] = useState17(0);
8765
8931
  useEffect10(() => {
@@ -8781,7 +8947,7 @@ function QuickActionWall({
8781
8947
  return () => ro.disconnect();
8782
8948
  }, [chips]);
8783
8949
  const padTarget = rows ? void 0 : minChips;
8784
- const track = useMemo12(() => {
8950
+ const track = useMemo13(() => {
8785
8951
  if (!padTarget || chips.length === 0 || chips.length >= padTarget) return chips;
8786
8952
  const repeats = Math.ceil(padTarget / chips.length);
8787
8953
  return Array.from(
@@ -8887,7 +9053,7 @@ function QuickActionMarquee({
8887
9053
  sync,
8888
9054
  className
8889
9055
  }) {
8890
- const chips = useMemo13(
9056
+ const chips = useMemo14(
8891
9057
  () => items.map((item) => ({
8892
9058
  id: item.id,
8893
9059
  label: item.label,
@@ -8919,12 +9085,12 @@ function QuickActionMarquee({
8919
9085
  import { forwardRef as forwardRef19 } from "react";
8920
9086
 
8921
9087
  // src/components/ui/scroll-fade.tsx
8922
- import { useCallback as useCallback7, useLayoutEffect as useLayoutEffect5, useRef as useRef8, useState as useState18 } from "react";
9088
+ import { useCallback as useCallback8, useLayoutEffect as useLayoutEffect6, useRef as useRef9, useState as useState18 } from "react";
8923
9089
  import { jsx as jsx46, jsxs as jsxs33 } from "react/jsx-runtime";
8924
9090
  function useScrollFade(axis = "vertical") {
8925
- const scrollRef = useRef8(null);
9091
+ const scrollRef = useRef9(null);
8926
9092
  const [fade, setFade] = useState18({ top: false, bottom: false, left: false, right: false });
8927
- const update = useCallback7(() => {
9093
+ const update = useCallback8(() => {
8928
9094
  const el = scrollRef.current;
8929
9095
  if (!el) return;
8930
9096
  setFade((prev) => {
@@ -8937,7 +9103,7 @@ function useScrollFade(axis = "vertical") {
8937
9103
  return prev.top === top && prev.bottom === bottom && prev.left === left && prev.right === right ? prev : { top, bottom, left, right };
8938
9104
  });
8939
9105
  }, [axis]);
8940
- useLayoutEffect5(() => {
9106
+ useLayoutEffect6(() => {
8941
9107
  update();
8942
9108
  const el = scrollRef.current;
8943
9109
  if (!el) return void 0;
@@ -9232,10 +9398,10 @@ function MingoOnboardingListSkeleton({ rows = 6, className }) {
9232
9398
  }
9233
9399
 
9234
9400
  // src/components/chat/mingo-welcome.tsx
9235
- import { useCallback as useCallback8, useMemo as useMemo15, useState as useState20 } from "react";
9401
+ import { useCallback as useCallback9, useMemo as useMemo16, useState as useState20 } from "react";
9236
9402
 
9237
9403
  // src/components/chat/mingo-chat-history.tsx
9238
- import { useState as useState19, useMemo as useMemo14, useRef as useRef9, useEffect as useEffect11 } from "react";
9404
+ import { useState as useState19, useMemo as useMemo15, useRef as useRef10, useEffect as useEffect11 } from "react";
9239
9405
 
9240
9406
  // src/components/chat/chat-list-empty-state.tsx
9241
9407
  import { jsx as jsx50, jsxs as jsxs37 } from "react/jsx-runtime";
@@ -9466,12 +9632,12 @@ function MingoChatHistory({
9466
9632
  onLoadMore,
9467
9633
  className
9468
9634
  }) {
9469
- const groups = useMemo14(() => groupDialogs(dialogs), [dialogs]);
9635
+ const groups = useMemo15(() => groupDialogs(dialogs), [dialogs]);
9470
9636
  const noSearchResults = groups.length === 0 && !!searchQuery?.trim();
9471
9637
  const { scrollRef, fadeTop, fadeBottom, update: updateFade } = useScrollFade();
9472
- const sentinelRef = useRef9(null);
9473
- const onLoadMoreRef = useRef9(onLoadMore);
9474
- const isLoadingMoreRef = useRef9(isLoadingMore);
9638
+ const sentinelRef = useRef10(null);
9639
+ const onLoadMoreRef = useRef10(onLoadMore);
9640
+ const isLoadingMoreRef = useRef10(isLoadingMore);
9475
9641
  useEffect11(() => {
9476
9642
  onLoadMoreRef.current = onLoadMore;
9477
9643
  isLoadingMoreRef.current = isLoadingMore;
@@ -9565,7 +9731,7 @@ function MingoWelcome({
9565
9731
  const resolvedPromo = hasExistingChats ? null : promo === void 0 ? onStartGuideChat ? DEFAULT_PROMO : null : promo;
9566
9732
  const hydrated = useIsHydrated();
9567
9733
  const [dismissedThisSession, setPromoDismissed] = useState20(false);
9568
- const storedDismissed = useMemo15(() => {
9734
+ const storedDismissed = useMemo16(() => {
9569
9735
  if (!hydrated || !resolvedPromo) return false;
9570
9736
  try {
9571
9737
  const store = promoStorage === "session" ? window.sessionStorage : window.localStorage;
@@ -9575,7 +9741,7 @@ function MingoWelcome({
9575
9741
  }
9576
9742
  }, [hydrated, resolvedPromo, promoStorage, promoStorageKey]);
9577
9743
  const promoDismissed = dismissedThisSession || storedDismissed;
9578
- const dismissPromo = useCallback8(() => {
9744
+ const dismissPromo = useCallback9(() => {
9579
9745
  setPromoDismissed(true);
9580
9746
  try {
9581
9747
  const store = promoStorage === "session" ? window.sessionStorage : window.localStorage;
@@ -9690,7 +9856,7 @@ function MingoWelcome({
9690
9856
  }
9691
9857
 
9692
9858
  // src/components/chat/guide-welcome.tsx
9693
- import { useMemo as useMemo16 } from "react";
9859
+ import { useMemo as useMemo17 } from "react";
9694
9860
  import { jsx as jsx53, jsxs as jsxs40 } from "react/jsx-runtime";
9695
9861
  var DEFAULT_TITLE = "Guide Mode Chat";
9696
9862
  function GuideWelcome({
@@ -9707,7 +9873,7 @@ function GuideWelcome({
9707
9873
  className
9708
9874
  }) {
9709
9875
  const { scrollRef, fadeTop, fadeBottom, update: updateScrollFade } = useScrollFade();
9710
- const chipItems = useMemo16(
9876
+ const chipItems = useMemo17(
9711
9877
  () => quickActions.map((action) => ({
9712
9878
  id: action.id,
9713
9879
  label: action.label,
@@ -9974,7 +10140,7 @@ function MingoHistoryRail({
9974
10140
  import { useState as useState22 } from "react";
9975
10141
 
9976
10142
  // src/components/ui/modal-v2.tsx
9977
- import { createContext as createContext4, forwardRef as forwardRef20, useContext as useContext4, useRef as useRef10, useEffect as useEffect12, useState as useState21 } from "react";
10143
+ import { createContext as createContext4, forwardRef as forwardRef20, useContext as useContext4, useRef as useRef11, useEffect as useEffect12, useState as useState21 } from "react";
9978
10144
  import { RemoveScroll } from "react-remove-scroll";
9979
10145
  import { jsx as jsx57, jsxs as jsxs44 } from "react/jsx-runtime";
9980
10146
  var ANIMATION_DURATION = 200;
@@ -9989,9 +10155,9 @@ var isInPortaledLayer = (node) => node instanceof Element && node.closest('[data
9989
10155
  var Modal = forwardRef20(
9990
10156
  ({ isOpen, onClose, children, className, size: size2 = "default" }, ref) => {
9991
10157
  const [isMounted, setIsMounted] = useState21(isOpen);
9992
- const panelRef = useRef10(null);
9993
- const restoreFocusRef = useRef10(null);
9994
- const stackIdRef = useRef10(/* @__PURE__ */ Symbol("modal"));
10158
+ const panelRef = useRef11(null);
10159
+ const restoreFocusRef = useRef11(null);
10160
+ const stackIdRef = useRef11(/* @__PURE__ */ Symbol("modal"));
9995
10161
  useEffect12(() => {
9996
10162
  if (!isOpen) return void 0;
9997
10163
  const stackId = stackIdRef.current;
@@ -10325,7 +10491,7 @@ var ChatHeaderIconButton = forwardRef21(
10325
10491
  ChatHeaderIconButton.displayName = "ChatHeaderIconButton";
10326
10492
 
10327
10493
  // src/components/chat/chat-header-search-field.tsx
10328
- import { useState as useState23, useRef as useRef11, useEffect as useEffect13, useCallback as useCallback9 } from "react";
10494
+ import { useState as useState23, useRef as useRef12, useEffect as useEffect13, useCallback as useCallback10 } from "react";
10329
10495
  import { jsx as jsx60, jsxs as jsxs46 } from "react/jsx-runtime";
10330
10496
  function ChatHeaderSearchField({
10331
10497
  initialValue,
@@ -10336,21 +10502,21 @@ function ChatHeaderSearchField({
10336
10502
  }) {
10337
10503
  const [value, setValue] = useState23(initialValue ?? "");
10338
10504
  const debounced = useDebounce(value, 300);
10339
- const lastEmitted = useRef11(initialValue ?? "");
10505
+ const lastEmitted = useRef12(initialValue ?? "");
10340
10506
  const [exiting, setExiting] = useState23(false);
10341
- const collapsedRef = useRef11(false);
10507
+ const collapsedRef = useRef12(false);
10342
10508
  useEffect13(() => {
10343
10509
  if (exiting) return;
10344
10510
  if (debounced === lastEmitted.current) return;
10345
10511
  lastEmitted.current = debounced;
10346
10512
  onSearchChange(debounced);
10347
10513
  }, [debounced, exiting, onSearchChange]);
10348
- const finishCollapse = useCallback9(() => {
10514
+ const finishCollapse = useCallback10(() => {
10349
10515
  if (collapsedRef.current) return;
10350
10516
  collapsedRef.current = true;
10351
10517
  onCollapse?.();
10352
10518
  }, [onCollapse]);
10353
- const beginCollapse = useCallback9(() => {
10519
+ const beginCollapse = useCallback10(() => {
10354
10520
  setExiting(true);
10355
10521
  }, []);
10356
10522
  useEffect13(() => {
@@ -10585,10 +10751,10 @@ function ChatPanelHeader({
10585
10751
  }
10586
10752
 
10587
10753
  // src/components/chat/chat-composer.tsx
10588
- import { useCallback as useCallback10, useMemo as useMemo18 } from "react";
10754
+ import { useCallback as useCallback11, useMemo as useMemo19 } from "react";
10589
10755
 
10590
10756
  // src/components/chat/chat-attachment-bar.tsx
10591
- import { useEffect as useEffect14, useMemo as useMemo17, useRef as useRef12 } from "react";
10757
+ import { useEffect as useEffect14, useMemo as useMemo18, useRef as useRef13 } from "react";
10592
10758
 
10593
10759
  // src/components/chat/utils/chat-attachment-markdown.ts
10594
10760
  var CHAT_ATTACHMENT_VIEW_URL_PREFIX = "/api/storage/view/chat-attachments/";
@@ -10660,7 +10826,7 @@ function ChatAttachmentAddButton({
10660
10826
  disabled = false,
10661
10827
  size: size2 = "default"
10662
10828
  }) {
10663
- const fileInputRef = useRef12(null);
10829
+ const fileInputRef = useRef13(null);
10664
10830
  const compact = size2 === "compact";
10665
10831
  const boxClass = compact ? "h-6 w-6" : "h-7 w-7";
10666
10832
  if (!attachmentsEnabled) {
@@ -10797,7 +10963,7 @@ function extLabel(fileName) {
10797
10963
  }
10798
10964
  var objectUrlByFile = /* @__PURE__ */ new WeakMap();
10799
10965
  function useObjectUrl(file) {
10800
- const url = useMemo17(() => {
10966
+ const url = useMemo18(() => {
10801
10967
  if (!file || typeof window === "undefined") return null;
10802
10968
  let existing = objectUrlByFile.get(file);
10803
10969
  if (!existing) {
@@ -10817,7 +10983,7 @@ function useObjectUrl(file) {
10817
10983
  }
10818
10984
 
10819
10985
  // src/components/chat/chat-context-memory-bar.tsx
10820
- import { useEffect as useEffect15, useRef as useRef13, useState as useState24 } from "react";
10986
+ import { useEffect as useEffect15, useRef as useRef14, useState as useState24 } from "react";
10821
10987
  import { jsx as jsx64, jsxs as jsxs50 } from "react/jsx-runtime";
10822
10988
  var itemKey3 = (item) => `${item.type}:${item.id}`;
10823
10989
  function ChatContextMemoryBar({
@@ -10828,7 +10994,7 @@ function ChatContextMemoryBar({
10828
10994
  className
10829
10995
  }) {
10830
10996
  const [open, setOpen] = useState24(false);
10831
- const rootRef = useRef13(null);
10997
+ const rootRef = useRef14(null);
10832
10998
  if (items.length === 0 && open) setOpen(false);
10833
10999
  useEffect15(() => {
10834
11000
  if (!open) return void 0;
@@ -11133,12 +11299,12 @@ function ChatComposer({
11133
11299
  const selected = selectedContextItems ?? [];
11134
11300
  const memory = contextMemoryItems ?? [];
11135
11301
  const entityTypes = contextPicker?.entityTypes;
11136
- const iconByType = useMemo18(() => {
11302
+ const iconByType = useMemo19(() => {
11137
11303
  const map = /* @__PURE__ */ new Map();
11138
11304
  for (const t of entityTypes ?? []) map.set(t.type, t.icon);
11139
11305
  return map;
11140
11306
  }, [entityTypes]);
11141
- const resolveContextIcon = useCallback10((item) => iconByType.get(item.type), [iconByType]);
11307
+ const resolveContextIcon = useCallback11((item) => iconByType.get(item.type), [iconByType]);
11142
11308
  const inputNode = /* @__PURE__ */ jsx67(
11143
11309
  ChatInput,
11144
11310
  {
@@ -11297,7 +11463,7 @@ function ChatArchivePage(props) {
11297
11463
  }
11298
11464
 
11299
11465
  // src/components/chat/chat-sidebar.tsx
11300
- import { forwardRef as forwardRef24, useRef as useRef14, useEffect as useEffect16 } from "react";
11466
+ import { forwardRef as forwardRef24, useRef as useRef15, useEffect as useEffect16 } from "react";
11301
11467
 
11302
11468
  // src/components/chat/chat-sidebar-skeleton.tsx
11303
11469
  import { forwardRef as forwardRef23 } from "react";
@@ -11420,11 +11586,11 @@ var ChatSidebar = forwardRef24(
11420
11586
  ...props
11421
11587
  }, ref) => {
11422
11588
  const showEmptyState = dialogs.length === 0 && !children;
11423
- const scrollContainerRef = useRef14(null);
11424
- const loadMoreRef = useRef14(null);
11425
- const onLoadMoreRef = useRef14(onLoadMore);
11589
+ const scrollContainerRef = useRef15(null);
11590
+ const loadMoreRef = useRef15(null);
11591
+ const onLoadMoreRef = useRef15(onLoadMore);
11426
11592
  onLoadMoreRef.current = onLoadMore;
11427
- const isFetchingRef = useRef14(isFetchingNextPage);
11593
+ const isFetchingRef = useRef15(isFetchingNextPage);
11428
11594
  isFetchingRef.current = isFetchingNextPage;
11429
11595
  useEffect16(() => {
11430
11596
  const scrollContainer = scrollContainerRef.current;
@@ -11868,10 +12034,10 @@ var TabsContent = forwardRef25(({ className, ...props }, ref) => /* @__PURE__ */
11868
12034
  TabsContent.displayName = TabsPrimitive.Content.displayName;
11869
12035
 
11870
12036
  // src/components/features/use-captions.ts
11871
- import { useMemo as useMemo19 } from "react";
12037
+ import { useMemo as useMemo20 } from "react";
11872
12038
  function useCaptions() {
11873
12039
  const endpoints = useChatRuntime()?.endpoints ?? null;
11874
- return useMemo19(
12040
+ return useMemo20(
11875
12041
  () => ({
11876
12042
  forEntity: (entityType, entity) => getEntityCaptionUrls(endpoints, entityType, entity),
11877
12043
  forEntityId: (entityType, entityId) => getEntityCaptionUrlsById(endpoints, entityType, entityId),
@@ -11883,7 +12049,7 @@ function useCaptions() {
11883
12049
 
11884
12050
  // src/components/features/video.tsx
11885
12051
  import MuxPlayer from "@mux/mux-player-react";
11886
- import { useCallback as useCallback11, useEffect as useEffect19, useImperativeHandle as useImperativeHandle3, useMemo as useMemo20, useRef as useRef15, useState as useState25 } from "react";
12052
+ import { useCallback as useCallback12, useEffect as useEffect19, useImperativeHandle as useImperativeHandle3, useMemo as useMemo21, useRef as useRef16, useState as useState25 } from "react";
11887
12053
 
11888
12054
  // src/utils/fetch-priority.ts
11889
12055
  import React4 from "react";
@@ -12322,10 +12488,10 @@ function FilePlayer({
12322
12488
  const effectivePreload = preload ?? (saveDataEnabled() ? "none" : "metadata");
12323
12489
  const resolvedCaptionsUrl = useAuthedAssetSrc(captionsUrl, "text/vtt, */*");
12324
12490
  const [hoverMutedFallback, setHoverMutedFallback] = useState25(() => Boolean(startMuted));
12325
- const hoverPlayerRef = useRef15(null);
12491
+ const hoverPlayerRef = useRef16(null);
12326
12492
  const [mutedFallbackBlocked, setMutedFallbackBlocked] = useState25(false);
12327
- const perfListenerRef = useRef15(null);
12328
- const clearPerfListener = useCallback11(() => {
12493
+ const perfListenerRef = useRef16(null);
12494
+ const clearPerfListener = useCallback12(() => {
12329
12495
  if (perfListenerRef.current) {
12330
12496
  try {
12331
12497
  hoverPlayerRef.current?.removeEventListener?.("playing", perfListenerRef.current);
@@ -12335,21 +12501,21 @@ function FilePlayer({
12335
12501
  }
12336
12502
  }, []);
12337
12503
  useEffect19(() => clearPerfListener, [clearPerfListener]);
12338
- const hoverActiveRef = useRef15(false);
12339
- const hoverGenerationRef = useRef15(0);
12340
- const activationWaiterRef = useRef15(null);
12341
- const clearActivationWaiter = useCallback11(() => {
12504
+ const hoverActiveRef = useRef16(false);
12505
+ const hoverGenerationRef = useRef16(0);
12506
+ const activationWaiterRef = useRef16(null);
12507
+ const clearActivationWaiter = useCallback12(() => {
12342
12508
  if (activationWaiterRef.current) {
12343
12509
  activationWaiters.delete(activationWaiterRef.current);
12344
12510
  activationWaiterRef.current = null;
12345
12511
  }
12346
12512
  }, []);
12347
12513
  useEffect19(() => clearActivationWaiter, [clearActivationWaiter]);
12348
- const mutedIntentRef = useRef15(mutedIntent);
12514
+ const mutedIntentRef = useRef16(mutedIntent);
12349
12515
  useEffect19(() => {
12350
12516
  mutedIntentRef.current = mutedIntent;
12351
12517
  });
12352
- const startHoverPlayback = useCallback11(() => {
12518
+ const startHoverPlayback = useCallback12(() => {
12353
12519
  hoverActiveRef.current = true;
12354
12520
  const generation = ++hoverGenerationRef.current;
12355
12521
  const el = hoverPlayerRef.current;
@@ -12412,7 +12578,7 @@ function FilePlayer({
12412
12578
  } catch {
12413
12579
  }
12414
12580
  }, [clearActivationWaiter, clearPerfListener]);
12415
- const stopHoverPlayback = useCallback11(() => {
12581
+ const stopHoverPlayback = useCallback12(() => {
12416
12582
  hoverActiveRef.current = false;
12417
12583
  setHoverMutedFallback(false);
12418
12584
  clearActivationWaiter();
@@ -12422,7 +12588,7 @@ function FilePlayer({
12422
12588
  } catch {
12423
12589
  }
12424
12590
  }, [clearActivationWaiter, clearPerfListener]);
12425
- const unmuteNow = useCallback11((e) => {
12591
+ const unmuteNow = useCallback12((e) => {
12426
12592
  e.stopPropagation();
12427
12593
  e.preventDefault();
12428
12594
  const el = hoverPlayerRef.current;
@@ -12445,7 +12611,7 @@ function FilePlayer({
12445
12611
  }, [hoverControlled, playWhenHovered, startHoverPlayback, stopHoverPlayback]);
12446
12612
  const handleHoverEnter = playOnHover && !hoverControlled ? startHoverPlayback : void 0;
12447
12613
  const handleHoverLeave = playOnHover && !hoverControlled ? stopHoverPlayback : void 0;
12448
- const onMutedFallbackChangeRef = useRef15(onMutedFallbackChange);
12614
+ const onMutedFallbackChangeRef = useRef16(onMutedFallbackChange);
12449
12615
  useEffect19(() => {
12450
12616
  onMutedFallbackChangeRef.current = onMutedFallbackChange;
12451
12617
  });
@@ -12455,7 +12621,7 @@ function FilePlayer({
12455
12621
  blocked: hoverMutedFallback && mutedFallbackBlocked
12456
12622
  });
12457
12623
  }, [hoverMutedFallback, mutedFallbackBlocked]);
12458
- const autoPlayKickedRef = useRef15(false);
12624
+ const autoPlayKickedRef = useRef16(false);
12459
12625
  useEffect19(() => {
12460
12626
  if (autoPlayKickedRef.current) return;
12461
12627
  if (startMuted) {
@@ -12537,7 +12703,7 @@ function FilePlayer({
12537
12703
  }
12538
12704
  };
12539
12705
  }, []);
12540
- const onEndedRef = useRef15(onEnded);
12706
+ const onEndedRef = useRef16(onEnded);
12541
12707
  useEffect19(() => {
12542
12708
  onEndedRef.current = onEnded;
12543
12709
  });
@@ -12598,15 +12764,15 @@ function FilePlayer({
12598
12764
  }
12599
12765
  const monitorHealth = !chromeless;
12600
12766
  const [playbackFailed, setPlaybackFailed] = useState25(false);
12601
- const stallTimerRef = useRef15(null);
12602
- const clearStallTimer = useCallback11(() => {
12767
+ const stallTimerRef = useRef16(null);
12768
+ const clearStallTimer = useCallback12(() => {
12603
12769
  if (stallTimerRef.current !== null) {
12604
12770
  clearTimeout(stallTimerRef.current);
12605
12771
  stallTimerRef.current = null;
12606
12772
  }
12607
12773
  }, []);
12608
12774
  useEffect19(() => clearStallTimer, [clearStallTimer]);
12609
- const failPlayback = useCallback11(
12775
+ const failPlayback = useCallback12(
12610
12776
  (reason) => {
12611
12777
  clearStallTimer();
12612
12778
  setPlaybackFailed(true);
@@ -12614,7 +12780,7 @@ function FilePlayer({
12614
12780
  },
12615
12781
  [clearStallTimer, url]
12616
12782
  );
12617
- const armStallTimer = useCallback11(() => {
12783
+ const armStallTimer = useCallback12(() => {
12618
12784
  if (!monitorHealth) return;
12619
12785
  const el = hoverPlayerRef.current;
12620
12786
  if (!el || el.paused || el.ended) return;
@@ -12624,15 +12790,15 @@ function FilePlayer({
12624
12790
  failPlayback("stall");
12625
12791
  }, VIDEO_STALL_TIMEOUT_MS);
12626
12792
  }, [monitorHealth, failPlayback]);
12627
- const handlePlaybackProgress = useCallback11(() => {
12793
+ const handlePlaybackProgress = useCallback12(() => {
12628
12794
  clearStallTimer();
12629
12795
  setPlaybackFailed(false);
12630
12796
  }, [clearStallTimer]);
12631
- const handleMediaError = useCallback11(() => {
12797
+ const handleMediaError = useCallback12(() => {
12632
12798
  if (!monitorHealth) return;
12633
12799
  failPlayback("error");
12634
12800
  }, [monitorHealth, failPlayback]);
12635
- const retryPlayback = useCallback11(() => {
12801
+ const retryPlayback = useCallback12(() => {
12636
12802
  setPlaybackFailed(false);
12637
12803
  clearStallTimer();
12638
12804
  const el = hoverPlayerRef.current;
@@ -12769,12 +12935,12 @@ function YouTubeFacadeInner({
12769
12935
  const [activated, setActivated] = useState25(Boolean(autoActivate));
12770
12936
  const [failed, setFailed] = useState25(false);
12771
12937
  const [reloadNonce, setReloadNonce] = useState25(0);
12772
- const iframeRef = useRef15(null);
12773
- const retry = useCallback11(() => {
12938
+ const iframeRef = useRef16(null);
12939
+ const retry = useCallback12(() => {
12774
12940
  setFailed(false);
12775
12941
  setReloadNonce((n) => n + 1);
12776
12942
  }, []);
12777
- const embedUrl = useMemo20(() => {
12943
+ const embedUrl = useMemo21(() => {
12778
12944
  const params = new URLSearchParams({
12779
12945
  autoplay: "1",
12780
12946
  rel: "0",
@@ -12851,7 +13017,7 @@ function YouTubeFacadeInner({
12851
13017
  if (blurTimer !== null) clearTimeout(blurTimer);
12852
13018
  };
12853
13019
  }, [activated, failed, reloadNonce, videoId]);
12854
- const prevSuspendedRef = useRef15(false);
13020
+ const prevSuspendedRef = useRef16(false);
12855
13021
  useEffect19(() => {
12856
13022
  const wasSuspended = prevSuspendedRef.current;
12857
13023
  prevSuspendedRef.current = Boolean(suspended);
@@ -12919,7 +13085,7 @@ function YouTubeFacadeInner({
12919
13085
  }
12920
13086
 
12921
13087
  // src/components/features/video-bites-strip.tsx
12922
- import { useMemo as useMemo22, useRef as useRef18, useState as useState28 } from "react";
13088
+ import { useMemo as useMemo23, useRef as useRef19, useState as useState28 } from "react";
12923
13089
 
12924
13090
  // src/components/user-display.tsx
12925
13091
  import { jsx as jsx78, jsxs as jsxs59 } from "react/jsx-runtime";
@@ -12987,7 +13153,7 @@ function CardHitLayer({
12987
13153
  }
12988
13154
 
12989
13155
  // src/components/features/cards-strip.tsx
12990
- import React5, { useCallback as useCallback12, useEffect as useEffect20, useMemo as useMemo21, useRef as useRef16, useState as useState26 } from "react";
13156
+ import React5, { useCallback as useCallback13, useEffect as useEffect20, useMemo as useMemo22, useRef as useRef17, useState as useState26 } from "react";
12991
13157
  import { Fragment as Fragment20, jsx as jsx80, jsxs as jsxs60 } from "react/jsx-runtime";
12992
13158
  var TRACK_GAP_PX = 16;
12993
13159
  var CHEVRON_SUPPRESS_MS = 4e3;
@@ -13035,7 +13201,7 @@ function CardsStrip(props) {
13035
13201
  className
13036
13202
  } = props;
13037
13203
  const childrenMode = props.renderCard === void 0;
13038
- const childItems = useMemo21(
13204
+ const childItems = useMemo22(
13039
13205
  () => childrenMode ? React5.Children.toArray(props.children) : EMPTY_CHILDREN,
13040
13206
  [childrenMode, props.children]
13041
13207
  );
@@ -13057,9 +13223,9 @@ function CardsStrip(props) {
13057
13223
  }
13058
13224
  return React5.isValidElement(item) && item.key != null ? String(item.key) : String(index);
13059
13225
  };
13060
- const wrapperRef = useRef16(null);
13061
- const scrollerRef = useRef16(null);
13062
- const trackRef = useRef16(null);
13226
+ const wrapperRef = useRef17(null);
13227
+ const scrollerRef = useRef17(null);
13228
+ const trackRef = useRef17(null);
13063
13229
  const [reducedMotion, setReducedMotion] = useState26(false);
13064
13230
  const [isTouch, setIsTouch] = useState26(false);
13065
13231
  const [isMobile, setIsMobile] = useState26(false);
@@ -13083,9 +13249,9 @@ function CardsStrip(props) {
13083
13249
  }, []);
13084
13250
  const [overflows, setOverflows] = useState26(false);
13085
13251
  const [marqueeEligible, setMarqueeEligible] = useState26(false);
13086
- const singleCopyWidthRef = useRef16(0);
13252
+ const singleCopyWidthRef = useRef17(0);
13087
13253
  const marqueeActive = autoScroll && !reducedMotion && marqueeEligible && items.length > 0;
13088
- const measure = useCallback12(() => {
13254
+ const measure = useCallback13(() => {
13089
13255
  const scroller = scrollerRef.current;
13090
13256
  const track = trackRef.current;
13091
13257
  if (!scroller || !track) return;
@@ -13105,8 +13271,8 @@ function CardsStrip(props) {
13105
13271
  ro.observe(track);
13106
13272
  return () => ro.disconnect();
13107
13273
  }, [measure, items.length, marqueeActive, isMobile]);
13108
- const chevronSuppressUntilRef = useRef16(0);
13109
- const userScrollSuppressUntilRef = useRef16(0);
13274
+ const chevronSuppressUntilRef = useRef17(0);
13275
+ const userScrollSuppressUntilRef = useRef17(0);
13110
13276
  const [nearViewport, setNearViewport] = useState26(true);
13111
13277
  useEffect20(() => {
13112
13278
  const el = wrapperRef.current;
@@ -13118,18 +13284,18 @@ function CardsStrip(props) {
13118
13284
  return () => io.disconnect();
13119
13285
  }, []);
13120
13286
  const [activeKey, setActiveKey] = useState26(null);
13121
- const activeKeyRef = useRef16(null);
13122
- const activate = useCallback12((key) => {
13287
+ const activeKeyRef = useRef17(null);
13288
+ const activate = useCallback13((key) => {
13123
13289
  activeKeyRef.current = key;
13124
13290
  setActiveKey(key);
13125
13291
  }, []);
13126
- const deactivate = useCallback12((key) => {
13292
+ const deactivate = useCallback13((key) => {
13127
13293
  if (activeKeyRef.current === key) activeKeyRef.current = null;
13128
13294
  setActiveKey((current) => current === key ? null : current);
13129
13295
  }, []);
13130
- const hoverPointerRef = useRef16({ x: 0, y: 0, inside: false });
13131
- const lastHoverSyncScrollRef = useRef16(-1);
13132
- const syncHoverToPointer = useCallback12(() => {
13296
+ const hoverPointerRef = useRef17({ x: 0, y: 0, inside: false });
13297
+ const lastHoverSyncScrollRef = useRef17(-1);
13298
+ const syncHoverToPointer = useCallback13(() => {
13133
13299
  const p = hoverPointerRef.current;
13134
13300
  if (!p.inside) return;
13135
13301
  const el = typeof document !== "undefined" ? document.elementFromPoint(p.x, p.y) : null;
@@ -13141,15 +13307,15 @@ function CardsStrip(props) {
13141
13307
  if (current !== null) deactivate(current);
13142
13308
  if (key !== null) activate(key);
13143
13309
  }, [activate, deactivate]);
13144
- const onHoverPointerEnter = useCallback12((e) => {
13310
+ const onHoverPointerEnter = useCallback13((e) => {
13145
13311
  if (e.pointerType === "touch") return;
13146
13312
  hoverPointerRef.current = { x: e.clientX, y: e.clientY, inside: true };
13147
13313
  }, []);
13148
- const onHoverPointerMove = useCallback12((e) => {
13314
+ const onHoverPointerMove = useCallback13((e) => {
13149
13315
  if (e.pointerType === "touch") return;
13150
13316
  hoverPointerRef.current = { x: e.clientX, y: e.clientY, inside: true };
13151
13317
  }, []);
13152
- const onHoverPointerLeave = useCallback12(
13318
+ const onHoverPointerLeave = useCallback13(
13153
13319
  (e) => {
13154
13320
  if (e.pointerType === "touch") return;
13155
13321
  hoverPointerRef.current.inside = false;
@@ -13158,20 +13324,20 @@ function CardsStrip(props) {
13158
13324
  },
13159
13325
  [deactivate]
13160
13326
  );
13161
- const clearHover = useCallback12(() => {
13327
+ const clearHover = useCallback13(() => {
13162
13328
  hoverPointerRef.current.inside = false;
13163
13329
  const current = activeKeyRef.current;
13164
13330
  if (current !== null) deactivate(current);
13165
13331
  }, [deactivate]);
13166
13332
  useResetOnPageHidden(clearHover);
13167
- const syncHoverIfScrolled = useCallback12(() => {
13333
+ const syncHoverIfScrolled = useCallback13(() => {
13168
13334
  const scroller = scrollerRef.current;
13169
13335
  if (!scroller) return;
13170
13336
  if (scroller.scrollLeft === lastHoverSyncScrollRef.current) return;
13171
13337
  lastHoverSyncScrollRef.current = scroller.scrollLeft;
13172
13338
  syncHoverToPointer();
13173
13339
  }, [syncHoverToPointer]);
13174
- const seamBuffer = useCallback12(() => {
13340
+ const seamBuffer = useCallback13(() => {
13175
13341
  const half = singleCopyWidthRef.current;
13176
13342
  const viewport = scrollerRef.current?.clientWidth ?? 0;
13177
13343
  return Math.max(0, Math.min(200, half / 4, half - viewport - TRACK_GAP_PX - 1));
@@ -13193,9 +13359,9 @@ function CardsStrip(props) {
13193
13359
  onAfterFrame: syncHoverIfScrolled
13194
13360
  });
13195
13361
  const [mountedIdx, setMountedIdx] = useState26(() => /* @__PURE__ */ new Set());
13196
- const cardObserverRef = useRef16(null);
13197
- const cardElIdxRef = useRef16(/* @__PURE__ */ new Map());
13198
- const cardElNearRef = useRef16(/* @__PURE__ */ new Map());
13362
+ const cardObserverRef = useRef17(null);
13363
+ const cardElIdxRef = useRef17(/* @__PURE__ */ new Map());
13364
+ const cardElNearRef = useRef17(/* @__PURE__ */ new Map());
13199
13365
  useEffect20(() => {
13200
13366
  if (typeof IntersectionObserver === "undefined") return void 0;
13201
13367
  const io = new IntersectionObserver(
@@ -13230,7 +13396,7 @@ function CardsStrip(props) {
13230
13396
  };
13231
13397
  }, []);
13232
13398
  const [cardRefFns] = useState26(() => /* @__PURE__ */ new Map());
13233
- const getCardRef = useCallback12(
13399
+ const getCardRef = useCallback13(
13234
13400
  (idx) => {
13235
13401
  let fn = cardRefFns.get(idx);
13236
13402
  if (!fn) {
@@ -13250,11 +13416,11 @@ function CardsStrip(props) {
13250
13416
  },
13251
13417
  [cardRefFns]
13252
13418
  );
13253
- const marqueeActiveRef = useRef16(false);
13419
+ const marqueeActiveRef = useRef17(false);
13254
13420
  useEffect20(() => {
13255
13421
  marqueeActiveRef.current = marqueeActive;
13256
13422
  });
13257
- const scrollByCard = useCallback12(
13423
+ const scrollByCard = useCallback13(
13258
13424
  (dir) => {
13259
13425
  const scroller = scrollerRef.current;
13260
13426
  const track = trackRef.current;
@@ -13270,22 +13436,22 @@ function CardsStrip(props) {
13270
13436
  },
13271
13437
  [glideBy]
13272
13438
  );
13273
- const onUserScrollIntent = useCallback12(() => {
13439
+ const onUserScrollIntent = useCallback13(() => {
13274
13440
  userScrollSuppressUntilRef.current = performance.now() + USER_SCROLL_SUPPRESS_MS;
13275
13441
  }, []);
13276
- const onWheelIntent = useCallback12(
13442
+ const onWheelIntent = useCallback13(
13277
13443
  (e) => {
13278
13444
  if (Math.abs(e.deltaX) > Math.abs(e.deltaY)) onUserScrollIntent();
13279
13445
  },
13280
13446
  [onUserScrollIntent]
13281
13447
  );
13282
- const onPointerDownIntent = useCallback12(
13448
+ const onPointerDownIntent = useCallback13(
13283
13449
  (e) => {
13284
13450
  if (e.pointerType === "touch") onUserScrollIntent();
13285
13451
  },
13286
13452
  [onUserScrollIntent]
13287
13453
  );
13288
- const onSeamWarp = useCallback12(() => {
13454
+ const onSeamWarp = useCallback13(() => {
13289
13455
  const scroller = scrollerRef.current;
13290
13456
  if (!scroller) return;
13291
13457
  syncHoverIfScrolled();
@@ -13398,7 +13564,7 @@ function CardsStrip(props) {
13398
13564
  }
13399
13565
 
13400
13566
  // src/components/features/video-hover-preview.tsx
13401
- import { useEffect as useEffect21, useRef as useRef17, useState as useState27 } from "react";
13567
+ import { useEffect as useEffect21, useRef as useRef18, useState as useState27 } from "react";
13402
13568
  import { Fragment as Fragment21, jsx as jsx81, jsxs as jsxs61 } from "react/jsx-runtime";
13403
13569
  function VideoHoverPreviewSurface({
13404
13570
  url,
@@ -13423,7 +13589,7 @@ function VideoHoverPreviewSurface({
13423
13589
  }) {
13424
13590
  const previewUrl = toMuxPreviewUrl(url);
13425
13591
  const gateControlled = playerMounted !== void 0;
13426
- const rootElRef = useRef17(null);
13592
+ const rootElRef = useRef18(null);
13427
13593
  const [isNear, setIsNear] = useState27(false);
13428
13594
  useEffect21(() => {
13429
13595
  if (gateControlled) return void 0;
@@ -13570,7 +13736,7 @@ function VideoBitesStrip({
13570
13736
  sortComparator = sortBitesByCreatedAtDesc,
13571
13737
  className
13572
13738
  }) {
13573
- const items = useMemo22(() => {
13739
+ const items = useMemo23(() => {
13574
13740
  const filtered = filterPublished ? bites.filter((b) => b.published) : [...bites];
13575
13741
  return filtered.sort(sortComparator);
13576
13742
  }, [bites, filterPublished, sortComparator]);
@@ -13643,7 +13809,7 @@ function VideoBiteCard({
13643
13809
  const isActive = controlled ? !!active : selfActive;
13644
13810
  const activate = () => controlled ? onActivate?.(key) : setSelfActive(true);
13645
13811
  const deactivate = () => controlled ? onDeactivate?.(key) : setSelfActive(false);
13646
- const titleInputRef = useRef18(null);
13812
+ const titleInputRef = useRef19(null);
13647
13813
  useIsomorphicLayoutEffect(() => {
13648
13814
  const el = titleInputRef.current;
13649
13815
  if (!el) return;
@@ -14841,6 +15007,12 @@ var DEFAULT_DOCUMENT_TYPE_TO_TABLE_ID = {
14841
15007
  function defaultTableIdForDocumentType(documentType) {
14842
15008
  return DEFAULT_DOCUMENT_TYPE_TO_TABLE_ID[documentType] ?? null;
14843
15009
  }
15010
+ function defaultDocumentTypeForTableId(tableId) {
15011
+ for (const [documentType, table] of Object.entries(DEFAULT_DOCUMENT_TYPE_TO_TABLE_ID)) {
15012
+ if (table === tableId) return documentType;
15013
+ }
15014
+ return null;
15015
+ }
14844
15016
 
14845
15017
  // src/components/chat/utils/source-row-cta.ts
14846
15018
  import { FileText as FileText3 } from "lucide-react";
@@ -15016,6 +15188,110 @@ if (_orderIdx("flamingo") > _orderIdx("flamingo-teaser") || _orderIdx("flamingo"
15016
15188
  );
15017
15189
  }
15018
15190
 
15191
+ // src/utils/source-grouping.ts
15192
+ var DOC_TABLE_TYPES = ["markdown", "data_room_doc"];
15193
+ function groupsByTable(documentType) {
15194
+ return !DOC_TABLE_TYPES.includes(documentType ?? "");
15195
+ }
15196
+ function recordCountLabel(count) {
15197
+ return `(${count} ${count === 1 ? "record" : "records"})`;
15198
+ }
15199
+ function buildGroupedSource(spec) {
15200
+ const first = spec.rows[0];
15201
+ const externalUrl = spec.externalUrl ?? first?.externalUrl;
15202
+ const targetPlatform = spec.targetPlatform !== void 0 ? spec.targetPlatform : first?.targetPlatform;
15203
+ return {
15204
+ index: spec.index,
15205
+ name: `${getSourceLabel(spec.sourceRepo)} ${recordCountLabel(spec.rows.length)}`,
15206
+ path: first?.path ?? "",
15207
+ documentType: first?.documentType ?? "",
15208
+ ...externalUrl ? { externalUrl } : {},
15209
+ targetPlatform: targetPlatform ?? null,
15210
+ sourceRepo: spec.sourceRepo,
15211
+ items: spec.rows
15212
+ };
15213
+ }
15214
+ function isGroupedChip(source) {
15215
+ return !!source.items && source.items.length > 0;
15216
+ }
15217
+ function typeOf(source) {
15218
+ return source.documentType || defaultDocumentTypeForTableId(source.sourceRepo) || "";
15219
+ }
15220
+ function joinsTableChip(source) {
15221
+ if (!source.sourceRepo) return false;
15222
+ return groupsByTable(typeOf({ ...source, sourceRepo: source.sourceRepo }));
15223
+ }
15224
+ function rowsOf(source) {
15225
+ if (isGroupedChip(source)) return source.items ?? [];
15226
+ return [
15227
+ {
15228
+ index: source.index,
15229
+ id: source.id ?? "",
15230
+ documentType: typeOf(source),
15231
+ name: source.name,
15232
+ ...source.externalUrl ? { externalUrl: source.externalUrl } : {},
15233
+ targetPlatform: source.targetPlatform ?? null,
15234
+ path: source.path || null
15235
+ }
15236
+ ];
15237
+ }
15238
+ function uniqueRows(rows) {
15239
+ const seen = /* @__PURE__ */ new Set();
15240
+ return rows.filter((row) => {
15241
+ if (!row.id) return true;
15242
+ const identity = `${row.documentType}:${row.id}`;
15243
+ if (seen.has(identity)) return false;
15244
+ seen.add(identity);
15245
+ return true;
15246
+ });
15247
+ }
15248
+ function groupSourcesByTable(sources2) {
15249
+ const membersByTable = /* @__PURE__ */ new Map();
15250
+ for (const source of sources2) {
15251
+ if (!joinsTableChip(source)) continue;
15252
+ const members = membersByTable.get(source.sourceRepo) ?? [];
15253
+ members.push(source);
15254
+ membersByTable.set(source.sourceRepo, members);
15255
+ }
15256
+ const emitted = /* @__PURE__ */ new Set();
15257
+ const chips = [];
15258
+ for (const source of sources2) {
15259
+ if (!joinsTableChip(source)) {
15260
+ chips.push(source);
15261
+ continue;
15262
+ }
15263
+ if (emitted.has(source.sourceRepo)) continue;
15264
+ emitted.add(source.sourceRepo);
15265
+ const members = membersByTable.get(source.sourceRepo) ?? [];
15266
+ if (members.length === 1 && isGroupedChip(source)) {
15267
+ chips.push(source);
15268
+ continue;
15269
+ }
15270
+ const serverChip = members.find(isGroupedChip);
15271
+ chips.push(
15272
+ buildGroupedSource({
15273
+ index: source.index,
15274
+ sourceRepo: source.sourceRepo,
15275
+ rows: uniqueRows(members.flatMap(rowsOf)),
15276
+ ...serverChip?.externalUrl ? { externalUrl: serverChip.externalUrl } : {},
15277
+ ...serverChip && serverChip.targetPlatform !== void 0 ? { targetPlatform: serverChip.targetPlatform } : {}
15278
+ })
15279
+ );
15280
+ }
15281
+ return chips;
15282
+ }
15283
+ function formatCitationIndices(indices) {
15284
+ const sorted = [...new Set(indices)].sort((a, b) => a - b);
15285
+ const runs = [];
15286
+ for (let start = 0; start < sorted.length; ) {
15287
+ let end = start;
15288
+ while (end + 1 < sorted.length && sorted[end + 1] === sorted[end] + 1) end++;
15289
+ runs.push(end === start ? `${sorted[start]}` : `${sorted[start]}-${sorted[end]}`);
15290
+ start = end + 1;
15291
+ }
15292
+ return runs.join(", ");
15293
+ }
15294
+
15019
15295
  // src/components/chat/utils/source-row-cta.ts
15020
15296
  function sanitizePath(path) {
15021
15297
  return (path || "").replace(/[^a-zA-Z0-9/_\-.]/g, "");
@@ -15035,7 +15311,6 @@ function pickSourceIcon(sourceRepo, documentType) {
15035
15311
  const iconLabel = documentType ?? "Source";
15036
15312
  return { icon, iconLabel };
15037
15313
  }
15038
- var DOC_TABLE_TYPES = ["markdown", "data_room_doc"];
15039
15314
  function shouldFallbackToPathNav(row) {
15040
15315
  return !!row.documentType && DOC_TABLE_TYPES.includes(row.documentType);
15041
15316
  }
@@ -16346,7 +16621,7 @@ var NETWORK_CONFIG = {
16346
16621
  var EMPTY_DIALOG_CAPABILITIES = Object.freeze({});
16347
16622
 
16348
16623
  // src/components/chat/hooks/use-chunk-catchup.ts
16349
- import { useCallback as useCallback13, useEffect as useEffect22, useRef as useRef19 } from "react";
16624
+ import { useCallback as useCallback14, useEffect as useEffect22, useRef as useRef20 } from "react";
16350
16625
  function makeSeqKey(messageType, chunkType, sequenceId) {
16351
16626
  return `${messageType}:${chunkType}:${sequenceId}`;
16352
16627
  }
@@ -16368,26 +16643,26 @@ function useChunkCatchup({
16368
16643
  chatTypes = [CHAT_TYPE.CLIENT],
16369
16644
  fetchChunks
16370
16645
  }) {
16371
- const processedSequenceKeys = useRef19(/* @__PURE__ */ new Set());
16372
- const lastSequenceId = useRef19(null);
16373
- const lastSequenceIdByType = useRef19(/* @__PURE__ */ new Map());
16374
- const catchupRun = useRef19(null);
16375
- const lastFetchParams = useRef19(null);
16376
- const pendingCatchupRef = useRef19(null);
16377
- const chunkBuffer = useRef19([]);
16378
- const bufferUntilInitialCatchupComplete = useRef19(false);
16379
- const hasCompletedInitialCatchup = useRef19(false);
16380
- const dialogIdRef = useRef19(dialogId);
16381
- const chatTypesRef = useRef19(chatTypes);
16382
- const fetchChunksRef = useRef19(fetchChunks);
16383
- const onChunkReceivedRef = useRef19(onChunkReceived);
16646
+ const processedSequenceKeys = useRef20(/* @__PURE__ */ new Set());
16647
+ const lastSequenceId = useRef20(null);
16648
+ const lastSequenceIdByType = useRef20(/* @__PURE__ */ new Map());
16649
+ const catchupRun = useRef20(null);
16650
+ const lastFetchParams = useRef20(null);
16651
+ const pendingCatchupRef = useRef20(null);
16652
+ const chunkBuffer = useRef20([]);
16653
+ const bufferUntilInitialCatchupComplete = useRef20(false);
16654
+ const hasCompletedInitialCatchup = useRef20(false);
16655
+ const dialogIdRef = useRef20(dialogId);
16656
+ const chatTypesRef = useRef20(chatTypes);
16657
+ const fetchChunksRef = useRef20(fetchChunks);
16658
+ const onChunkReceivedRef = useRef20(onChunkReceived);
16384
16659
  useEffect22(() => {
16385
16660
  dialogIdRef.current = dialogId;
16386
16661
  chatTypesRef.current = chatTypes;
16387
16662
  fetchChunksRef.current = fetchChunks;
16388
16663
  onChunkReceivedRef.current = onChunkReceived;
16389
16664
  });
16390
- const processChunk = useCallback13(
16665
+ const processChunk = useCallback14(
16391
16666
  (chunk, messageType, forceProcess = false) => {
16392
16667
  if (bufferUntilInitialCatchupComplete.current && !forceProcess) {
16393
16668
  chunkBuffer.current.push({ chunk, messageType });
@@ -16409,7 +16684,7 @@ function useChunkCatchup({
16409
16684
  },
16410
16685
  []
16411
16686
  );
16412
- const flushBufferedRealtimeChunks = useCallback13(() => {
16687
+ const flushBufferedRealtimeChunks = useCallback14(() => {
16413
16688
  if (chunkBuffer.current.length === 0) return;
16414
16689
  const buffered = [...chunkBuffer.current];
16415
16690
  chunkBuffer.current = [];
@@ -16422,17 +16697,17 @@ function useChunkCatchup({
16422
16697
  processChunk(chunk, messageType, true);
16423
16698
  });
16424
16699
  }, [processChunk]);
16425
- const completeCatchupWindow = useCallback13(() => {
16700
+ const completeCatchupWindow = useCallback14(() => {
16426
16701
  bufferUntilInitialCatchupComplete.current = false;
16427
16702
  hasCompletedInitialCatchup.current = true;
16428
16703
  }, []);
16429
- const rearmForQueuedCatchup = useCallback13(() => {
16704
+ const rearmForQueuedCatchup = useCallback14(() => {
16430
16705
  hasCompletedInitialCatchup.current = false;
16431
16706
  lastFetchParams.current = null;
16432
16707
  bufferUntilInitialCatchupComplete.current = true;
16433
16708
  }, []);
16434
- const catchUpChunksRef = useRef19(null);
16435
- const catchUpChunks = useCallback13(
16709
+ const catchUpChunksRef = useRef20(null);
16710
+ const catchUpChunks = useCallback14(
16436
16711
  async (fromSequenceId) => {
16437
16712
  const currentDialogId = dialogIdRef.current;
16438
16713
  const currentChatTypes = chatTypesRef.current;
@@ -16611,7 +16886,7 @@ function useChunkCatchup({
16611
16886
  useEffect22(() => {
16612
16887
  catchUpChunksRef.current = catchUpChunks;
16613
16888
  });
16614
- const resetChunkTracking = useCallback13(() => {
16889
+ const resetChunkTracking = useCallback14(() => {
16615
16890
  processedSequenceKeys.current.clear();
16616
16891
  lastSequenceId.current = null;
16617
16892
  lastSequenceIdByType.current.clear();
@@ -16622,16 +16897,16 @@ function useChunkCatchup({
16622
16897
  bufferUntilInitialCatchupComplete.current = false;
16623
16898
  hasCompletedInitialCatchup.current = false;
16624
16899
  }, []);
16625
- const startInitialBuffering = useCallback13(() => {
16900
+ const startInitialBuffering = useCallback14(() => {
16626
16901
  if (!bufferUntilInitialCatchupComplete.current) {
16627
16902
  chunkBuffer.current = [];
16628
16903
  bufferUntilInitialCatchupComplete.current = true;
16629
16904
  }
16630
16905
  hasCompletedInitialCatchup.current = false;
16631
16906
  }, []);
16632
- const isBufferingActive = useCallback13(() => bufferUntilInitialCatchupComplete.current, []);
16633
- const processedCount = useCallback13(() => processedSequenceKeys.current.size, []);
16634
- const resetAndCatchUp = useCallback13(async () => {
16907
+ const isBufferingActive = useCallback14(() => bufferUntilInitialCatchupComplete.current, []);
16908
+ const processedCount = useCallback14(() => processedSequenceKeys.current.size, []);
16909
+ const resetAndCatchUp = useCallback14(async () => {
16635
16910
  if (!dialogIdRef.current) return;
16636
16911
  const fromSeq = lastSequenceId.current;
16637
16912
  hasCompletedInitialCatchup.current = false;
@@ -16689,7 +16964,7 @@ function useScriptedStream(frames, resetKey, enabled = true) {
16689
16964
  }
16690
16965
 
16691
16966
  // src/components/chat/hooks/use-jetstream-dialog-subscription.ts
16692
- import { useCallback as useCallback14, useEffect as useEffect24, useRef as useRef20, useState as useState30 } from "react";
16967
+ import { useCallback as useCallback15, useEffect as useEffect24, useRef as useRef21, useState as useState30 } from "react";
16693
16968
  var DEFAULT_STREAM_NAME = "CHAT_CHUNKS";
16694
16969
  var RESYNC_AFTER_HIDDEN_MS = 1e4;
16695
16970
  var RESYNC_COALESCE_MS = 1e3;
@@ -16718,58 +16993,58 @@ function useJetStreamDialogSubscription({
16718
16993
  const [seqEntry, setSeqEntry] = useState30(null);
16719
16994
  const currentStreamSeq = seqEntry && seqEntry.dialogId === dialogId ? seqEntry.seq : null;
16720
16995
  const isSubscribed = subscriptionLive && enabled && Boolean(dialogId) && isConnected;
16721
- const lastRecoveryReportRef = useRef20(0);
16722
- const resyncTimerRef = useRef20(null);
16723
- const lastResyncSignalRef = useRef20(resyncSignal);
16724
- const resyncSignalRef = useRef20(resyncSignal);
16996
+ const lastRecoveryReportRef = useRef21(0);
16997
+ const resyncTimerRef = useRef21(null);
16998
+ const lastResyncSignalRef = useRef21(resyncSignal);
16999
+ const resyncSignalRef = useRef21(resyncSignal);
16725
17000
  useEffect24(() => {
16726
17001
  resyncSignalRef.current = resyncSignal;
16727
17002
  });
16728
- const clientRef = useRef20(null);
16729
- const subscriptionRef = useRef20(null);
16730
- const highestStreamSeqRef = useRef20(null);
16731
- const onEventRef = useRef20(onEvent);
17003
+ const clientRef = useRef21(null);
17004
+ const subscriptionRef = useRef21(null);
17005
+ const highestStreamSeqRef = useRef21(null);
17006
+ const onEventRef = useRef21(onEvent);
16732
17007
  useEffect24(() => {
16733
17008
  onEventRef.current = onEvent;
16734
17009
  }, [onEvent]);
16735
- const onConnectRef = useRef20(onConnect);
17010
+ const onConnectRef = useRef21(onConnect);
16736
17011
  useEffect24(() => {
16737
17012
  onConnectRef.current = onConnect;
16738
17013
  }, [onConnect]);
16739
- const onDisconnectRef = useRef20(onDisconnect);
17014
+ const onDisconnectRef = useRef21(onDisconnect);
16740
17015
  useEffect24(() => {
16741
17016
  onDisconnectRef.current = onDisconnect;
16742
17017
  }, [onDisconnect]);
16743
- const onSubscribedRef = useRef20(onSubscribed);
17018
+ const onSubscribedRef = useRef21(onSubscribed);
16744
17019
  useEffect24(() => {
16745
17020
  onSubscribedRef.current = onSubscribed;
16746
17021
  }, [onSubscribed]);
16747
- const onBeforeReconnectRef = useRef20(onBeforeReconnect);
17022
+ const onBeforeReconnectRef = useRef21(onBeforeReconnect);
16748
17023
  useEffect24(() => {
16749
17024
  onBeforeReconnectRef.current = onBeforeReconnect;
16750
17025
  }, [onBeforeReconnect]);
16751
- const getNatsWsUrlRef = useRef20(getNatsWsUrl);
17026
+ const getNatsWsUrlRef = useRef21(getNatsWsUrl);
16752
17027
  useEffect24(() => {
16753
17028
  getNatsWsUrlRef.current = getNatsWsUrl;
16754
17029
  }, [getNatsWsUrl]);
16755
- const reconnectionBackoffRef = useRef20(reconnectionBackoff);
17030
+ const reconnectionBackoffRef = useRef21(reconnectionBackoff);
16756
17031
  useEffect24(() => {
16757
17032
  reconnectionBackoffRef.current = reconnectionBackoff;
16758
17033
  }, [reconnectionBackoff]);
16759
- const optStartSeqRef = useRef20(optStartSeq);
17034
+ const optStartSeqRef = useRef21(optStartSeq);
16760
17035
  useEffect24(() => {
16761
17036
  optStartSeqRef.current = optStartSeq;
16762
17037
  }, [optStartSeq]);
16763
- const inactiveThresholdRef = useRef20(inactiveThresholdMs);
17038
+ const inactiveThresholdRef = useRef21(inactiveThresholdMs);
16764
17039
  useEffect24(() => {
16765
17040
  inactiveThresholdRef.current = inactiveThresholdMs;
16766
17041
  }, [inactiveThresholdMs]);
16767
- const hadConnectionBeforeRef = useRef20(false);
16768
- const clientConfigRef = useRef20(clientConfig);
17042
+ const hadConnectionBeforeRef = useRef21(false);
17043
+ const clientConfigRef = useRef21(clientConfig);
16769
17044
  useEffect24(() => {
16770
17045
  clientConfigRef.current = clientConfig;
16771
17046
  }, [clientConfig]);
16772
- const currentWsUrlRef = useRef20("");
17047
+ const currentWsUrlRef = useRef21("");
16773
17048
  const wsUrl = getNatsWsUrl();
16774
17049
  useEffect24(() => {
16775
17050
  if (!enabled || !wsUrl) {
@@ -16862,7 +17137,7 @@ function useJetStreamDialogSubscription({
16862
17137
  }
16863
17138
  };
16864
17139
  }, [dialogId]);
16865
- const requestResync = useCallback14(() => {
17140
+ const requestResync = useCallback15(() => {
16866
17141
  if (resyncTimerRef.current !== null) clearTimeout(resyncTimerRef.current);
16867
17142
  resyncTimerRef.current = setTimeout(() => {
16868
17143
  resyncTimerRef.current = null;
@@ -16991,7 +17266,7 @@ function useJetStreamDialogSubscription({
16991
17266
  }
16992
17267
 
16993
17268
  // src/components/chat/hooks/use-nats-dialog-subscription.ts
16994
- import { useEffect as useEffect25, useRef as useRef21, useState as useState31 } from "react";
17269
+ import { useEffect as useEffect25, useRef as useRef22, useState as useState31 } from "react";
16995
17270
  function useNatsDialogSubscription({
16996
17271
  enabled,
16997
17272
  dialogId,
@@ -17008,45 +17283,45 @@ function useNatsDialogSubscription({
17008
17283
  const [isConnected, setIsConnected] = useState31(false);
17009
17284
  const [isSubscribed, setIsSubscribed] = useState31(false);
17010
17285
  const [reconnectionCount, setReconnectionCount] = useState31(0);
17011
- const clientRef = useRef21(null);
17012
- const subscriptionRefs = useRef21(/* @__PURE__ */ new Map());
17013
- const onEventRef = useRef21(onEvent);
17286
+ const clientRef = useRef22(null);
17287
+ const subscriptionRefs = useRef22(/* @__PURE__ */ new Map());
17288
+ const onEventRef = useRef22(onEvent);
17014
17289
  useEffect25(() => {
17015
17290
  onEventRef.current = onEvent;
17016
17291
  }, [onEvent]);
17017
- const onConnectRef = useRef21(onConnect);
17292
+ const onConnectRef = useRef22(onConnect);
17018
17293
  useEffect25(() => {
17019
17294
  onConnectRef.current = onConnect;
17020
17295
  }, [onConnect]);
17021
- const onDisconnectRef = useRef21(onDisconnect);
17296
+ const onDisconnectRef = useRef22(onDisconnect);
17022
17297
  useEffect25(() => {
17023
17298
  onDisconnectRef.current = onDisconnect;
17024
17299
  }, [onDisconnect]);
17025
- const onSubscribedRef = useRef21(onSubscribed);
17300
+ const onSubscribedRef = useRef22(onSubscribed);
17026
17301
  useEffect25(() => {
17027
17302
  onSubscribedRef.current = onSubscribed;
17028
17303
  }, [onSubscribed]);
17029
- const onBeforeReconnectRef = useRef21(onBeforeReconnect);
17304
+ const onBeforeReconnectRef = useRef22(onBeforeReconnect);
17030
17305
  useEffect25(() => {
17031
17306
  onBeforeReconnectRef.current = onBeforeReconnect;
17032
17307
  }, [onBeforeReconnect]);
17033
- const hadConnectionBeforeRef = useRef21(false);
17034
- const getNatsWsUrlRef = useRef21(getNatsWsUrl);
17308
+ const hadConnectionBeforeRef = useRef22(false);
17309
+ const getNatsWsUrlRef = useRef22(getNatsWsUrl);
17035
17310
  useEffect25(() => {
17036
17311
  getNatsWsUrlRef.current = getNatsWsUrl;
17037
17312
  }, [getNatsWsUrl]);
17038
- const reconnectionBackoffRef = useRef21(reconnectionBackoff);
17313
+ const reconnectionBackoffRef = useRef22(reconnectionBackoff);
17039
17314
  useEffect25(() => {
17040
17315
  reconnectionBackoffRef.current = reconnectionBackoff;
17041
17316
  }, [reconnectionBackoff]);
17042
- const clientConfigRef = useRef21(clientConfig);
17317
+ const clientConfigRef = useRef22(clientConfig);
17043
17318
  useEffect25(() => {
17044
17319
  clientConfigRef.current = clientConfig;
17045
17320
  }, [clientConfig]);
17046
- const currentWsUrlRef = useRef21("");
17321
+ const currentWsUrlRef = useRef22("");
17047
17322
  const wsUrl = getNatsWsUrl();
17048
- const lastSubscribedDialogIdRef = useRef21(null);
17049
- const abortControllerRef = useRef21(null);
17323
+ const lastSubscribedDialogIdRef = useRef22(null);
17324
+ const abortControllerRef = useRef22(null);
17050
17325
  useEffect25(() => {
17051
17326
  if (!enabled || !wsUrl) {
17052
17327
  if (currentWsUrlRef.current && clientRef.current) {
@@ -17129,13 +17404,13 @@ function useNatsDialogSubscription({
17129
17404
  };
17130
17405
  }, [enabled, wsUrl]);
17131
17406
  const topicsKey = topics.join(",");
17132
- const topicsRef = useRef21(topics);
17133
- const isConnectedRef = useRef21(isConnected);
17407
+ const topicsRef = useRef22(topics);
17408
+ const isConnectedRef = useRef22(isConnected);
17134
17409
  useEffect25(() => {
17135
17410
  topicsRef.current = topics;
17136
17411
  isConnectedRef.current = isConnected;
17137
17412
  });
17138
- const currentDialogIdRef = useRef21(null);
17413
+ const currentDialogIdRef = useRef22(null);
17139
17414
  useEffect25(() => {
17140
17415
  currentDialogIdRef.current = dialogId;
17141
17416
  if (!enabled || !dialogId) {
@@ -17392,7 +17667,7 @@ function useEmptyStateConfig(emptyStateUrl, options) {
17392
17667
 
17393
17668
  // src/components/chat/hooks/use-chat-attachments.ts
17394
17669
  import { fileTypeFromBlob } from "file-type";
17395
- import { useCallback as useCallback15, useEffect as useEffect27, useMemo as useMemo23, useRef as useRef22, useState as useState33 } from "react";
17670
+ import { useCallback as useCallback16, useEffect as useEffect27, useMemo as useMemo24, useRef as useRef23, useState as useState33 } from "react";
17396
17671
  var CHAT_ATTACHMENTS_BUCKET = "chat-attachments";
17397
17672
  var CHAT_ATTACHMENTS_FOLDER = "chat";
17398
17673
  var CHAT_ATTACHMENT_MAX_SIZE_BYTES = 25 * 1024 * 1024;
@@ -17460,11 +17735,11 @@ function useChatAttachments() {
17460
17735
  const runtime = useRequiredChatRuntime();
17461
17736
  const uploadUrlEndpoint = runtime.endpoints.attachmentUploadUrl;
17462
17737
  const [attachments, setAttachments] = useState33([]);
17463
- const controllersRef = useRef22(/* @__PURE__ */ new Map());
17464
- const updateOne = useCallback15((id, patch) => {
17738
+ const controllersRef = useRef23(/* @__PURE__ */ new Map());
17739
+ const updateOne = useCallback16((id, patch) => {
17465
17740
  setAttachments((prev) => prev.map((a) => a.id === id ? { ...a, ...patch } : a));
17466
17741
  }, []);
17467
- const removeAttachment = useCallback15((id) => {
17742
+ const removeAttachment = useCallback16((id) => {
17468
17743
  const ctrl = controllersRef.current.get(id);
17469
17744
  if (ctrl) {
17470
17745
  ctrl.abort();
@@ -17472,12 +17747,12 @@ function useChatAttachments() {
17472
17747
  }
17473
17748
  setAttachments((prev) => prev.filter((a) => a.id !== id));
17474
17749
  }, []);
17475
- const clear = useCallback15(() => {
17750
+ const clear = useCallback16(() => {
17476
17751
  for (const ctrl of controllersRef.current.values()) ctrl.abort();
17477
17752
  controllersRef.current.clear();
17478
17753
  setAttachments([]);
17479
17754
  }, []);
17480
- const uploadOne = useCallback15(
17755
+ const uploadOne = useCallback16(
17481
17756
  async (att) => {
17482
17757
  const ctrl = controllersRef.current.get(att.id);
17483
17758
  try {
@@ -17550,11 +17825,11 @@ function useChatAttachments() {
17550
17825
  },
17551
17826
  [uploadUrlEndpoint, updateOne]
17552
17827
  );
17553
- const attachmentsRef = useRef22([]);
17828
+ const attachmentsRef = useRef23([]);
17554
17829
  useEffect27(() => {
17555
17830
  attachmentsRef.current = attachments;
17556
17831
  });
17557
- const addFiles = useCallback15(
17832
+ const addFiles = useCallback16(
17558
17833
  (files) => {
17559
17834
  const arr = Array.from(files);
17560
17835
  if (arr.length === 0) return;
@@ -17601,7 +17876,7 @@ function useChatAttachments() {
17601
17876
  },
17602
17877
  [uploadOne]
17603
17878
  );
17604
- const readyAttachments = useMemo23(
17879
+ const readyAttachments = useMemo24(
17605
17880
  () => attachments.filter(
17606
17881
  (a) => a.status === "ready" && !!a.storagePath && !!a.viewToken
17607
17882
  ).map((a) => ({
@@ -17625,15 +17900,15 @@ function useChatAttachments() {
17625
17900
  }
17626
17901
 
17627
17902
  // src/components/chat/hooks/use-chat-attachment-image-gallery.tsx
17628
- import { useCallback as useCallback16, useEffect as useEffect28, useRef as useRef23, useState as useState34 } from "react";
17903
+ import { useCallback as useCallback17, useEffect as useEffect28, useRef as useRef24, useState as useState34 } from "react";
17629
17904
  import { jsx as jsx95 } from "react/jsx-runtime";
17630
17905
  var CLOSED = { isOpen: false, images: [], initialIndex: 0 };
17631
17906
  function useChatAttachmentImageGallery() {
17632
17907
  const runtime = useRequiredChatRuntime();
17633
17908
  const viewUrlPrefix = runtime.endpoints.attachmentViewUrlPrefix;
17634
- const panelRef = useRef23(null);
17909
+ const panelRef = useRef24(null);
17635
17910
  const [state, setState] = useState34(CLOSED);
17636
- const handleClose = useCallback16(() => setState(CLOSED), []);
17911
+ const handleClose = useCallback17(() => setState(CLOSED), []);
17637
17912
  useEffect28(() => {
17638
17913
  const root = panelRef.current;
17639
17914
  if (!root) return void 0;
@@ -17735,11 +18010,11 @@ function useChatIdentity(enabled = true) {
17735
18010
  }
17736
18011
 
17737
18012
  // src/components/chat/hooks/use-close-on-navigation.ts
17738
- import { useEffect as useEffect30, useRef as useRef24 } from "react";
18013
+ import { useEffect as useEffect30, useRef as useRef25 } from "react";
17739
18014
  function useCloseOnNavigation(close, pathname) {
17740
- const prevPathnameRef = useRef24(null);
17741
- const initializedRef = useRef24(false);
17742
- const closeRef = useRef24(close);
18015
+ const prevPathnameRef = useRef25(null);
18016
+ const initializedRef = useRef25(false);
18017
+ const closeRef = useRef25(close);
17743
18018
  useEffect30(() => {
17744
18019
  closeRef.current = close;
17745
18020
  });
@@ -17757,15 +18032,15 @@ function useCloseOnNavigation(close, pathname) {
17757
18032
  }
17758
18033
 
17759
18034
  // src/components/chat/hooks/use-chat.ts
17760
- import { useState as useState37, useCallback as useCallback18, useEffect as useEffect31, useRef as useRef26 } from "react";
18035
+ import { useState as useState37, useCallback as useCallback19, useEffect as useEffect31, useRef as useRef27 } from "react";
17761
18036
 
17762
18037
  // src/components/chat/hooks/use-sse.ts
17763
- import { useState as useState36, useCallback as useCallback17, useRef as useRef25 } from "react";
18038
+ import { useState as useState36, useCallback as useCallback18, useRef as useRef26 } from "react";
17764
18039
  function useSSE({ streamFn } = {}) {
17765
18040
  const [isStreaming, setIsStreaming] = useState36(false);
17766
18041
  const [error, setError] = useState36(null);
17767
- const abortControllerRef = useRef25(null);
17768
- const streamMessage = useCallback17(
18042
+ const abortControllerRef = useRef26(null);
18043
+ const streamMessage = useCallback18(
17769
18044
  async function* (message, extra) {
17770
18045
  setIsStreaming(true);
17771
18046
  setError(null);
@@ -17800,13 +18075,13 @@ function useSSE({ streamFn } = {}) {
17800
18075
  },
17801
18076
  [streamFn]
17802
18077
  );
17803
- const abort = useCallback17(() => {
18078
+ const abort = useCallback18(() => {
17804
18079
  if (abortControllerRef.current) {
17805
18080
  abortControllerRef.current.abort();
17806
18081
  }
17807
18082
  setIsStreaming(false);
17808
18083
  }, []);
17809
- const reset = useCallback17(() => {
18084
+ const reset = useCallback18(() => {
17810
18085
  }, []);
17811
18086
  return {
17812
18087
  streamMessage,
@@ -17835,8 +18110,8 @@ function useChat({
17835
18110
  } = {}) {
17836
18111
  const [messages, setMessages] = useState37(() => initialMessages ?? []);
17837
18112
  const [isTyping, setIsTyping] = useState37(false);
17838
- const currentAssistantSegmentsRef = useRef26([]);
17839
- const onMessagesChangeRef = useRef26(onMessagesChange);
18113
+ const currentAssistantSegmentsRef = useRef27([]);
18114
+ const onMessagesChangeRef = useRef27(onMessagesChange);
17840
18115
  useEffect31(() => {
17841
18116
  onMessagesChangeRef.current = onMessagesChange;
17842
18117
  });
@@ -17854,10 +18129,10 @@ function useChat({
17854
18129
  debugMode,
17855
18130
  streamFn
17856
18131
  });
17857
- const addMessage = useCallback18((message) => {
18132
+ const addMessage = useCallback19((message) => {
17858
18133
  setMessages((prev) => [...prev, message]);
17859
18134
  }, []);
17860
- const updateLastAssistantMessage = useCallback18((segments) => {
18135
+ const updateLastAssistantMessage = useCallback19((segments) => {
17861
18136
  setMessages((prev) => {
17862
18137
  const newMessages = [...prev];
17863
18138
  const lastMessage = newMessages[newMessages.length - 1];
@@ -17870,7 +18145,7 @@ function useChat({
17870
18145
  return newMessages;
17871
18146
  });
17872
18147
  }, []);
17873
- const sendMessage = useCallback18(
18148
+ const sendMessage = useCallback19(
17874
18149
  async (text2, extra, options) => {
17875
18150
  const userMessage = {
17876
18151
  id: `user-${Date.now()}`,
@@ -18046,21 +18321,21 @@ function useChat({
18046
18321
  },
18047
18322
  [streamMessage, addMessage, updateLastAssistantMessage, assistantName, assistantAvatar]
18048
18323
  );
18049
- const handleQuickAction = useCallback18(
18324
+ const handleQuickAction = useCallback19(
18050
18325
  (actionText) => {
18051
18326
  void sendMessage(actionText);
18052
18327
  },
18053
18328
  [sendMessage]
18054
18329
  );
18055
- const clearMessages = useCallback18(() => {
18330
+ const clearMessages = useCallback19(() => {
18056
18331
  setMessages([]);
18057
18332
  setIsTyping(false);
18058
18333
  reset();
18059
18334
  }, [reset]);
18060
- const hydrateMessages = useCallback18((history) => {
18335
+ const hydrateMessages = useCallback19((history) => {
18061
18336
  setMessages((prev) => prev.length === 0 ? history : [...history, ...prev]);
18062
18337
  }, []);
18063
- const stopMessage = useCallback18(() => {
18338
+ const stopMessage = useCallback19(() => {
18064
18339
  abort();
18065
18340
  setIsTyping(false);
18066
18341
  }, [abort]);
@@ -18079,7 +18354,7 @@ function useChat({
18079
18354
  }
18080
18355
 
18081
18356
  // src/components/chat/hooks/use-sse-chat-adapter.ts
18082
- import { useCallback as useCallback21, useMemo as useMemo26, useRef as useRef29, useState as useState41 } from "react";
18357
+ import { useCallback as useCallback22, useMemo as useMemo27, useRef as useRef30, useState as useState41 } from "react";
18083
18358
 
18084
18359
  // src/chat-protocol/confirm-tool.ts
18085
18360
  function buildConfirmToolBody(request) {
@@ -20628,7 +20903,7 @@ function createChatDialogStore(options = {}) {
20628
20903
  }
20629
20904
 
20630
20905
  // src/components/chat/stream/use-chat-stream-reducer.ts
20631
- import { useCallback as useCallback19, useEffect as useEffect32, useMemo as useMemo24, useState as useState38, useSyncExternalStore as useSyncExternalStore3 } from "react";
20906
+ import { useCallback as useCallback20, useEffect as useEffect32, useMemo as useMemo25, useState as useState38, useSyncExternalStore as useSyncExternalStore3 } from "react";
20632
20907
 
20633
20908
  // src/components/chat/stream/delta-batcher.ts
20634
20909
  var DELTA_FLUSH_FALLBACK_MS = 50;
@@ -20718,12 +20993,12 @@ function useChatStreamReducer({
20718
20993
  createReducerOptions
20719
20994
  }) {
20720
20995
  const reducer = store.getReducer(dialogId, side, () => createReducerOptions?.() ?? {});
20721
- const getSnapshot2 = useCallback19(() => store.getSnapshot(dialogId, side), [store, dialogId, side]);
20722
- const getServerSnapshot2 = useCallback19(() => store.getServerSnapshot(), [store]);
20723
- const subscribe2 = useCallback19((listener) => store.subscribe(listener), [store]);
20996
+ const getSnapshot2 = useCallback20(() => store.getSnapshot(dialogId, side), [store, dialogId, side]);
20997
+ const getServerSnapshot2 = useCallback20(() => store.getServerSnapshot(), [store]);
20998
+ const subscribe2 = useCallback20((listener) => store.subscribe(listener), [store]);
20724
20999
  const state = useSyncExternalStore3(subscribe2, getSnapshot2, getServerSnapshot2);
20725
21000
  useEffect32(() => store.retain(dialogId, side), [store, dialogId, side]);
20726
- const key = useMemo24(() => ({ store, dialogId, side }), [store, dialogId, side]);
21001
+ const key = useMemo25(() => ({ store, dialogId, side }), [store, dialogId, side]);
20727
21002
  const [batcher] = useState38(
20728
21003
  () => createDeltaBatcher({
20729
21004
  applyOne: (event, k) => {
@@ -20731,8 +21006,8 @@ function useChatStreamReducer({
20731
21006
  }
20732
21007
  })
20733
21008
  );
20734
- const flushDeltas = useCallback19(() => batcher.flush(), [batcher]);
20735
- const applyEvent = useCallback19(
21009
+ const flushDeltas = useCallback20(() => batcher.flush(), [batcher]);
21010
+ const applyEvent = useCallback20(
20736
21011
  (event) => {
20737
21012
  if (batcher.push(event, key)) return;
20738
21013
  batcher.flush();
@@ -20741,11 +21016,11 @@ function useChatStreamReducer({
20741
21016
  [batcher, key]
20742
21017
  );
20743
21018
  useEffect32(() => () => batcher.dispose(), [batcher]);
20744
- const mutate = useCallback19(
21019
+ const mutate = useCallback20(
20745
21020
  (fn) => store.mutate(dialogId, side, fn),
20746
21021
  [store, dialogId, side]
20747
21022
  );
20748
- return useMemo24(
21023
+ return useMemo25(
20749
21024
  () => ({ state, applyEvent, flushDeltas, mutate, reducer }),
20750
21025
  [state, applyEvent, flushDeltas, mutate, reducer]
20751
21026
  );
@@ -20900,7 +21175,7 @@ function buildDiscussPrompt(reference, options = {}) {
20900
21175
  }
20901
21176
 
20902
21177
  // src/components/chat/hooks/use-chat-history-hydration.ts
20903
- import { useEffect as useEffect33, useRef as useRef27, useState as useState39 } from "react";
21178
+ import { useEffect as useEffect33, useRef as useRef28, useState as useState39 } from "react";
20904
21179
 
20905
21180
  // src/components/chat/utils/auto-continuation-directive.ts
20906
21181
  var AUTO_CONTINUATION_DIRECTIVE_PREFIX = "[internal-auto-continuation]";
@@ -20929,8 +21204,8 @@ function useChatHistoryHydration({
20929
21204
  onOrphanedConversation
20930
21205
  }) {
20931
21206
  const [isHydratingHistory, setIsHydratingHistory] = useState39(false);
20932
- const hydratedKeyRef = useRef27(null);
20933
- const runIdRef = useRef27(0);
21207
+ const hydratedKeyRef = useRef28(null);
21208
+ const runIdRef = useRef28(0);
20934
21209
  useEffect33(() => {
20935
21210
  if (!active || !conversationId) return () => setIsHydratingHistory(false);
20936
21211
  const key = `${source}:${conversationId}`;
@@ -21003,7 +21278,7 @@ function useChatHistoryHydration({
21003
21278
  }
21004
21279
 
21005
21280
  // src/components/chat/hooks/use-managed-dialog-list.ts
21006
- import { useCallback as useCallback20, useEffect as useEffect34, useMemo as useMemo25, useRef as useRef28, useState as useState40 } from "react";
21281
+ import { useCallback as useCallback21, useEffect as useEffect34, useMemo as useMemo26, useRef as useRef29, useState as useState40 } from "react";
21007
21282
  function useManagedDialogList({
21008
21283
  autoLoad,
21009
21284
  fetchDialogs,
@@ -21026,19 +21301,19 @@ function useManagedDialogList({
21026
21301
  setAutoLoadWas(autoLoad);
21027
21302
  if (autoLoad && fetchDialogs) setSettledSearch(void 0);
21028
21303
  }
21029
- const pendingRef = useRef28(false);
21304
+ const pendingRef = useRef29(false);
21030
21305
  const [dialogsError, setDialogsError] = useState40(false);
21031
- const dialogsRef = useRef28(dialogs);
21306
+ const dialogsRef = useRef29(dialogs);
21032
21307
  useEffect34(() => {
21033
21308
  dialogsRef.current = dialogs;
21034
21309
  });
21035
- const onDialogRemovedRef = useRef28(onDialogRemoved);
21310
+ const onDialogRemovedRef = useRef29(onDialogRemoved);
21036
21311
  useEffect34(() => {
21037
21312
  onDialogRemovedRef.current = onDialogRemoved;
21038
21313
  });
21039
- const initialDialogsLoadedRef = useRef28(false);
21040
- const requestIdRef = useRef28(0);
21041
- const loadDialogsPage = useCallback20(
21314
+ const initialDialogsLoadedRef = useRef29(false);
21315
+ const requestIdRef = useRef29(0);
21316
+ const loadDialogsPage = useCallback21(
21042
21317
  async (cursor) => {
21043
21318
  if (!fetchDialogs) return;
21044
21319
  const requestId = ++requestIdRef.current;
@@ -21080,10 +21355,10 @@ function useManagedDialogList({
21080
21355
  },
21081
21356
  [fetchDialogs, pageSize, search, logTag]
21082
21357
  );
21083
- const reloadDialogs = useCallback20(() => {
21358
+ const reloadDialogs = useCallback21(() => {
21084
21359
  void loadDialogsPage();
21085
21360
  }, [loadDialogsPage]);
21086
- const loadedSearchRef = useRef28(void 0);
21361
+ const loadedSearchRef = useRef29(void 0);
21087
21362
  useEffect34(() => {
21088
21363
  if (!fetchDialogs) return;
21089
21364
  if (!autoLoad) return;
@@ -21092,10 +21367,10 @@ function useManagedDialogList({
21092
21367
  loadedSearchRef.current = search;
21093
21368
  void loadDialogsPage();
21094
21369
  }, [autoLoad, fetchDialogs, search, loadDialogsPage]);
21095
- const removeLocal = useCallback20((id) => {
21370
+ const removeLocal = useCallback21((id) => {
21096
21371
  setDialogs((prev) => prev.filter((d) => d.id !== id));
21097
21372
  }, []);
21098
- const deleteDialog = useCallback20(
21373
+ const deleteDialog = useCallback21(
21099
21374
  async (id) => {
21100
21375
  if (!deleteDialogCallback) return;
21101
21376
  try {
@@ -21109,7 +21384,7 @@ function useManagedDialogList({
21109
21384
  },
21110
21385
  [deleteDialogCallback, removeLocal, logTag]
21111
21386
  );
21112
- const renameDialog = useCallback20(
21387
+ const renameDialog = useCallback21(
21113
21388
  async (id, title) => {
21114
21389
  if (!renameDialogCallback) return;
21115
21390
  const previous = dialogsRef.current.find((d) => d.id === id)?.title;
@@ -21125,7 +21400,7 @@ function useManagedDialogList({
21125
21400
  },
21126
21401
  [renameDialogCallback, logTag]
21127
21402
  );
21128
- const archiveDialog = useCallback20(
21403
+ const archiveDialog = useCallback21(
21129
21404
  async (id) => {
21130
21405
  if (!archiveDialogCallback) return;
21131
21406
  try {
@@ -21139,15 +21414,15 @@ function useManagedDialogList({
21139
21414
  },
21140
21415
  [archiveDialogCallback, removeLocal, logTag]
21141
21416
  );
21142
- const loadMoreDialogs = useCallback20(async () => {
21417
+ const loadMoreDialogs = useCallback21(async () => {
21143
21418
  if (!dialogsNextCursor) return;
21144
21419
  if (pendingRef.current) return;
21145
21420
  await loadDialogsPage(dialogsNextCursor);
21146
21421
  }, [dialogsNextCursor, loadDialogsPage]);
21147
- const upsertDialogTop = useCallback20((item) => {
21422
+ const upsertDialogTop = useCallback21((item) => {
21148
21423
  setDialogs((prev) => [item, ...prev.filter((d) => d.id !== item.id)]);
21149
21424
  }, []);
21150
- const bumpDialogToTop = useCallback20((id) => {
21425
+ const bumpDialogToTop = useCallback21((id) => {
21151
21426
  setDialogs((prev) => {
21152
21427
  const row = prev.find((d) => d.id === id);
21153
21428
  if (!row) return prev;
@@ -21157,7 +21432,7 @@ function useManagedDialogList({
21157
21432
  const hasMoreDialogs = dialogsNextCursor != null;
21158
21433
  const awaitingFirstPage = !!fetchDialogs && settledSearch !== (search ?? null);
21159
21434
  const dialogsLoading = isDialogsLoading || awaitingFirstPage;
21160
- return useMemo25(
21435
+ return useMemo26(
21161
21436
  () => ({
21162
21437
  dialogs,
21163
21438
  dialogsNextCursor,
@@ -21224,10 +21499,10 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21224
21499
  const runtime = useRequiredChatRuntime();
21225
21500
  const source = runtime.source || DEFAULT_CHAT_SOURCE;
21226
21501
  const tableIdForDocumentType = options?.tableIdForDocumentType ?? defaultTableIdForDocumentType;
21227
- const sendMessageRef = useRef29(
21502
+ const sendMessageRef = useRef30(
21228
21503
  () => Promise.resolve(true)
21229
21504
  );
21230
- const cardResolve = useCallback21(
21505
+ const cardResolve = useCallback22(
21231
21506
  (action) => (reqId) => {
21232
21507
  if (!reqId) return void 0;
21233
21508
  return sendMessageRef.current("", {
@@ -21237,32 +21512,32 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21237
21512
  },
21238
21513
  []
21239
21514
  );
21240
- const cardApprove = useMemo26(() => cardResolve("approve"), [cardResolve]);
21241
- const cardReject = useMemo26(() => cardResolve("reject"), [cardResolve]);
21242
- const createReducerOptions = useCallback21(
21515
+ const cardApprove = useMemo27(() => cardResolve("approve"), [cardResolve]);
21516
+ const cardReject = useMemo27(() => cardResolve("reject"), [cardResolve]);
21517
+ const createReducerOptions = useCallback22(
21243
21518
  () => ({
21244
21519
  transport: "sse",
21245
21520
  callbacks: { onApprove: cardApprove, onReject: cardReject }
21246
21521
  }),
21247
21522
  [cardApprove, cardReject]
21248
21523
  );
21249
- const storeRef = useRef29(null);
21524
+ const storeRef = useRef30(null);
21250
21525
  if (storeRef.current === null) storeRef.current = createChatDialogStore();
21251
21526
  const { state, applyEvent, flushDeltas, mutate } = useChatStreamReducer({
21252
21527
  store: storeRef.current,
21253
21528
  dialogId: source,
21254
21529
  createReducerOptions
21255
21530
  });
21256
- const conversationStorage = useMemo26(() => createChatConversationStorage(source), [source]);
21257
- const conversationIdRef = useRef29(null);
21258
- const restoredConversationRef = useRef29(false);
21531
+ const conversationStorage = useMemo27(() => createChatConversationStorage(source), [source]);
21532
+ const conversationIdRef = useRef30(null);
21533
+ const restoredConversationRef = useRef30(false);
21259
21534
  if (!restoredConversationRef.current) {
21260
21535
  restoredConversationRef.current = true;
21261
21536
  pruneStaleChatConversationStorage(source);
21262
21537
  conversationIdRef.current = conversationStorage.load()?.conversationId ?? null;
21263
21538
  }
21264
21539
  const [conversationId, setConversationId] = useState41(() => conversationIdRef.current);
21265
- const commitConversationId = useCallback21(
21540
+ const commitConversationId = useCallback22(
21266
21541
  (id) => {
21267
21542
  conversationIdRef.current = id;
21268
21543
  setConversationId(id);
@@ -21275,7 +21550,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21275
21550
  const { commands: slashCommands } = useSlashCommandRegistry(commandsUrl, {
21276
21551
  enabled: active
21277
21552
  });
21278
- const cmdIdByTableId = useMemo26(() => {
21553
+ const cmdIdByTableId = useMemo27(() => {
21279
21554
  const buckets = /* @__PURE__ */ new Map();
21280
21555
  for (const cmd of slashCommands) {
21281
21556
  if (!cmd.primarySourceId) continue;
@@ -21296,8 +21571,8 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21296
21571
  return map;
21297
21572
  }, [slashCommands]);
21298
21573
  const historyUrl = runtime.endpoints.chatHistoryUrl ?? `${runtime.endpoints.chatStreamUrl.replace(/\/+$/, "")}/history`;
21299
- const hydrationSendCountRef = useRef29(0);
21300
- const hydrateMessages = useCallback21(
21574
+ const hydrationSendCountRef = useRef30(0);
21575
+ const hydrateMessages = useCallback22(
21301
21576
  (history, sourcesSeed) => {
21302
21577
  mutate((r) => {
21303
21578
  const mapped = history.map(historyMessageToReducerMessage);
@@ -21318,9 +21593,9 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21318
21593
  },
21319
21594
  [mutate]
21320
21595
  );
21321
- const messagesLenRef = useRef29(0);
21596
+ const messagesLenRef = useRef30(0);
21322
21597
  messagesLenRef.current = state.messages.length;
21323
- const onOrphanedConversation = useCallback21(
21598
+ const onOrphanedConversation = useCallback22(
21324
21599
  (id) => {
21325
21600
  if (conversationIdRef.current === id && messagesLenRef.current === 0) commitConversationId(null);
21326
21601
  },
@@ -21347,8 +21622,8 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21347
21622
  // the thread they just opened. The live count is read through a ref.
21348
21623
  onOrphanedConversation
21349
21624
  });
21350
- const abortControllerRef = useRef29(null);
21351
- const switchConversation = useCallback21(
21625
+ const abortControllerRef = useRef30(null);
21626
+ const switchConversation = useCallback22(
21352
21627
  (id) => {
21353
21628
  abortControllerRef.current?.abort();
21354
21629
  flushDeltas();
@@ -21360,16 +21635,16 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21360
21635
  [flushDeltas, mutate, hydratedKeyRef, commitConversationId]
21361
21636
  );
21362
21637
  const conversationsUrl = runtime.endpoints.chatConversationsUrl;
21363
- const conversationsApi = useMemo26(
21638
+ const conversationsApi = useMemo27(
21364
21639
  () => conversationsUrl ? createChatConversationsApi(conversationsUrl) : null,
21365
21640
  [conversationsUrl]
21366
21641
  );
21367
21642
  const [dialogSearch, setDialogSearch] = useState41("");
21368
- const fetchActiveDialogs = useMemo26(
21643
+ const fetchActiveDialogs = useMemo27(
21369
21644
  () => conversationsApi ? (params) => conversationsApi.fetchDialogs({ ...params, status: "active" }) : void 0,
21370
21645
  [conversationsApi]
21371
21646
  );
21372
- const fetchArchivedDialogs = useMemo26(
21647
+ const fetchArchivedDialogs = useMemo27(
21373
21648
  () => conversationsApi ? (params) => conversationsApi.fetchDialogs({ ...params, status: "archived" }) : void 0,
21374
21649
  [conversationsApi]
21375
21650
  );
@@ -21398,16 +21673,16 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21398
21673
  if (conversationIdRef.current === id) switchConversation(null);
21399
21674
  }
21400
21675
  });
21401
- const unarchiveDialog = useMemo26(
21676
+ const unarchiveDialog = useMemo27(
21402
21677
  () => conversationsApi ? async (id) => {
21403
21678
  await conversationsApi.unarchiveDialog(id);
21404
21679
  reloadDialogs();
21405
21680
  } : void 0,
21406
21681
  [conversationsApi, reloadDialogs]
21407
21682
  );
21408
- const endpointsRef = useRef29(runtime.endpoints);
21683
+ const endpointsRef = useRef30(runtime.endpoints);
21409
21684
  endpointsRef.current = runtime.endpoints;
21410
- const captureConversationId = useCallback21(
21685
+ const captureConversationId = useCallback22(
21411
21686
  (event) => {
21412
21687
  if (event.type !== "metadata") return false;
21413
21688
  const id = event.conversationId;
@@ -21419,7 +21694,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21419
21694
  },
21420
21695
  [commitConversationId, hydratedKeyRef, source]
21421
21696
  );
21422
- const sendMessage = useCallback21(
21697
+ const sendMessage = useCallback22(
21423
21698
  // Resolves `true` on a clean turn, `false` when the request failed
21424
21699
  // (surfaced to batch approve-all loops via the card callbacks).
21425
21700
  async (text2, sendOptions) => {
@@ -21516,25 +21791,25 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21516
21791
  ]
21517
21792
  );
21518
21793
  sendMessageRef.current = sendMessage;
21519
- const stopMessage = useCallback21(() => {
21794
+ const stopMessage = useCallback22(() => {
21520
21795
  abortControllerRef.current?.abort();
21521
21796
  flushDeltas();
21522
21797
  mutate((r) => r.setPhase("idle"));
21523
21798
  }, [mutate, flushDeltas]);
21524
- const clearMessages = useCallback21(() => {
21799
+ const clearMessages = useCallback22(() => {
21525
21800
  mutate((r) => r.reset());
21526
21801
  commitConversationId(null);
21527
21802
  hydrationSendCountRef.current = 0;
21528
21803
  hydratedKeyRef.current = null;
21529
21804
  }, [mutate, commitConversationId, hydratedKeyRef]);
21530
- const selectDialog = useCallback21(
21805
+ const selectDialog = useCallback22(
21531
21806
  (id) => {
21532
21807
  if (id === conversationIdRef.current) return;
21533
21808
  switchConversation(id);
21534
21809
  },
21535
21810
  [switchConversation]
21536
21811
  );
21537
- const dialogCapabilities = useMemo26(
21812
+ const dialogCapabilities = useMemo27(
21538
21813
  () => conversationsApi ? {
21539
21814
  canRename: true,
21540
21815
  canArchive: true,
@@ -21548,7 +21823,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21548
21823
  } : void 0,
21549
21824
  [conversationsApi, fetchArchivedDialogs, unarchiveDialog, dialogSearch]
21550
21825
  );
21551
- const docMessages = useMemo26(() => {
21826
+ const docMessages = useMemo27(() => {
21552
21827
  const { meta, sources: sourcesMap } = state.turnMeta;
21553
21828
  let sendIdx = -1;
21554
21829
  return state.messages.map((m) => {
@@ -21575,7 +21850,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21575
21850
  };
21576
21851
  });
21577
21852
  }, [state.messages, state.turnMeta]);
21578
- const displayRef = useCallback21(
21853
+ const displayRef = useCallback22(
21579
21854
  (reference) => {
21580
21855
  const tableId = tableIdForDocumentType(reference.type);
21581
21856
  if (!tableId) {
@@ -21597,7 +21872,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21597
21872
  },
21598
21873
  [sendMessage, source, cmdIdByTableId, tableIdForDocumentType]
21599
21874
  );
21600
- const discussRef = useCallback21(
21875
+ const discussRef = useCallback22(
21601
21876
  (reference) => {
21602
21877
  const tableId = tableIdForDocumentType(reference.type);
21603
21878
  if (!tableId) {
@@ -21616,7 +21891,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21616
21891
  },
21617
21892
  [sendMessage, tableIdForDocumentType]
21618
21893
  );
21619
- const latestMeta = useMemo26(() => {
21894
+ const latestMeta = useMemo27(() => {
21620
21895
  const { meta, sendCount } = state.turnMeta;
21621
21896
  return meta.get(sendCount - 1) ?? meta.get(sendCount - 2) ?? null;
21622
21897
  }, [state]);
@@ -21680,7 +21955,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
21680
21955
  }
21681
21956
 
21682
21957
  // src/components/chat/hooks/use-nats-chat-adapter.ts
21683
- import { useCallback as useCallback22, useEffect as useEffect35, useMemo as useMemo27, useRef as useRef30, useState as useState42 } from "react";
21958
+ import { useCallback as useCallback23, useEffect as useEffect35, useMemo as useMemo28, useRef as useRef31, useState as useState42 } from "react";
21684
21959
 
21685
21960
  // src/chat-protocol/nats-decoder.ts
21686
21961
  function str(value) {
@@ -22693,19 +22968,19 @@ function useNatsChatAdapter(config, options = {}) {
22693
22968
  const isManagedMode = fetchDialogs !== void 0;
22694
22969
  const [internalDialogId, setInternalDialogId] = useState42(null);
22695
22970
  const dialogId = isManagedMode ? internalDialogId : controlledDialogId !== void 0 ? controlledDialogId : null;
22696
- const currentDialogIdRef = useRef30(dialogId);
22971
+ const currentDialogIdRef = useRef31(dialogId);
22697
22972
  useEffect35(() => {
22698
22973
  currentDialogIdRef.current = dialogId;
22699
22974
  });
22700
- const handleApproveRef = useRef30(async () => {
22975
+ const handleApproveRef = useRef31(async () => {
22701
22976
  });
22702
- const handleRejectRef = useRef30(async () => {
22977
+ const handleRejectRef = useRef31(async () => {
22703
22978
  });
22704
- const accumApprove = useCallback22((requestId) => {
22979
+ const accumApprove = useCallback23((requestId) => {
22705
22980
  if (!requestId) return void 0;
22706
22981
  return handleApproveRef.current(requestId);
22707
22982
  }, []);
22708
- const accumReject = useCallback22((requestId) => {
22983
+ const accumReject = useCallback23((requestId) => {
22709
22984
  if (!requestId) return void 0;
22710
22985
  return handleRejectRef.current(requestId);
22711
22986
  }, []);
@@ -22758,7 +23033,7 @@ function useNatsChatAdapter(config, options = {}) {
22758
23033
  }
22759
23034
  };
22760
23035
  });
22761
- const processChunk = useCallback22(
23036
+ const processChunk = useCallback23(
22762
23037
  (chunk) => {
22763
23038
  const event = decodeNatsChunk(chunk);
22764
23039
  if (event) applyEvent(event);
@@ -22795,7 +23070,7 @@ function useNatsChatAdapter(config, options = {}) {
22795
23070
  const [messagesNextCursor, setMessagesNextCursor] = useState42(null);
22796
23071
  const [isMessagesLoading, setIsMessagesLoading] = useState42(false);
22797
23072
  const [connectedForDialog, setConnectedForDialog] = useState42(null);
22798
- const hasConnectedOnceRef = useRef30(false);
23073
+ const hasConnectedOnceRef = useRef31(false);
22799
23074
  const {
22800
23075
  processChunk: catchupProcessChunk,
22801
23076
  catchUpChunks,
@@ -22808,8 +23083,8 @@ function useNatsChatAdapter(config, options = {}) {
22808
23083
  onChunkReceived: (chunk) => processChunk(chunk),
22809
23084
  fetchChunks
22810
23085
  });
22811
- const historyLoadSeqRef = useRef30(0);
22812
- const loadDialogHistory = useCallback22(
23086
+ const historyLoadSeqRef = useRef31(0);
23087
+ const loadDialogHistory = useCallback23(
22813
23088
  async (id, cursor) => {
22814
23089
  if (!fetchDialogMessages) return;
22815
23090
  historyLoadSeqRef.current += 1;
@@ -22867,7 +23142,7 @@ function useNatsChatAdapter(config, options = {}) {
22867
23142
  isBufferingActive
22868
23143
  ]
22869
23144
  );
22870
- const prevDialogIdRef = useRef30(void 0);
23145
+ const prevDialogIdRef = useRef31(void 0);
22871
23146
  useEffect35(() => {
22872
23147
  if (prevDialogIdRef.current === dialogId) return;
22873
23148
  prevDialogIdRef.current = dialogId;
@@ -22941,7 +23216,7 @@ function useNatsChatAdapter(config, options = {}) {
22941
23216
  }
22942
23217
  });
22943
23218
  const connectionState = !active || !dialogId ? "connected" : connectedForDialog === dialogId ? "connected" : "connecting";
22944
- const sendMessage = useCallback22(
23219
+ const sendMessage = useCallback23(
22945
23220
  async (text2, sendOptions) => {
22946
23221
  const hidden = sendOptions?.hidden ?? false;
22947
23222
  mutate((r) => r.pushOptimisticSend(text2, hidden));
@@ -22949,7 +23224,7 @@ function useNatsChatAdapter(config, options = {}) {
22949
23224
  },
22950
23225
  [mutate, publishUserMessage, dialogId]
22951
23226
  );
22952
- const stopMessage = useCallback22(() => {
23227
+ const stopMessage = useCallback23(() => {
22953
23228
  mutate((r) => r.setPhase("idle"));
22954
23229
  if (stopGenerationCallback && dialogId) {
22955
23230
  void stopGenerationCallback(dialogId).catch((err) => {
@@ -22957,10 +23232,10 @@ function useNatsChatAdapter(config, options = {}) {
22957
23232
  });
22958
23233
  }
22959
23234
  }, [mutate, stopGenerationCallback, dialogId]);
22960
- const clearMessages = useCallback22(() => {
23235
+ const clearMessages = useCallback23(() => {
22961
23236
  mutate((r) => r.clearThread());
22962
23237
  }, [mutate]);
22963
- const selectDialog = useCallback22(
23238
+ const selectDialog = useCallback23(
22964
23239
  (id) => {
22965
23240
  if (!isManagedMode) {
22966
23241
  return;
@@ -22969,7 +23244,7 @@ function useNatsChatAdapter(config, options = {}) {
22969
23244
  },
22970
23245
  [isManagedMode]
22971
23246
  );
22972
- const startNewDialog = useCallback22(async () => {
23247
+ const startNewDialog = useCallback23(async () => {
22973
23248
  if (!createDialogCallback) return null;
22974
23249
  if (isCreatingDialog) return null;
22975
23250
  try {
@@ -22991,17 +23266,17 @@ function useNatsChatAdapter(config, options = {}) {
22991
23266
  setIsCreatingDialog(false);
22992
23267
  }
22993
23268
  }, [createDialogCallback, isCreatingDialog, isManagedMode, upsertDialogTop]);
22994
- const loadMoreMessages = useCallback22(async () => {
23269
+ const loadMoreMessages = useCallback23(async () => {
22995
23270
  if (!dialogId || !messagesNextCursor) return;
22996
23271
  await loadDialogHistory(dialogId, messagesNextCursor);
22997
23272
  }, [dialogId, messagesNextCursor, loadDialogHistory]);
22998
- const approveRequest = useCallback22(async (requestId) => {
23273
+ const approveRequest = useCallback23(async (requestId) => {
22999
23274
  await handleApproveRef.current(requestId);
23000
23275
  }, []);
23001
- const rejectRequest = useCallback22(async (requestId, reason) => {
23276
+ const rejectRequest = useCallback23(async (requestId, reason) => {
23002
23277
  await handleRejectRef.current(requestId, reason);
23003
23278
  }, []);
23004
- const discussRef = useCallback22(
23279
+ const discussRef = useCallback23(
23005
23280
  (reference) => {
23006
23281
  const prompt = buildDiscussPrompt(reference, { includeReference: true });
23007
23282
  void sendMessage(prompt).catch((err) => {
@@ -23013,7 +23288,7 @@ function useNatsChatAdapter(config, options = {}) {
23013
23288
  const { messages, streamingPhase, dialogTokenUsage = null, liveModel = null } = state;
23014
23289
  const isLoading = streamingPhase !== "idle";
23015
23290
  const hasMoreMessages = messagesNextCursor != null;
23016
- const dialogCapabilities = useMemo27(
23291
+ const dialogCapabilities = useMemo28(
23017
23292
  () => ({
23018
23293
  canRename: isManagedMode && !!renameDialogCallback,
23019
23294
  canArchive: isManagedMode && !!archiveDialogCallback,
@@ -23022,7 +23297,7 @@ function useNatsChatAdapter(config, options = {}) {
23022
23297
  }),
23023
23298
  [isManagedMode, renameDialogCallback, archiveDialogCallback, fetchArchivedDialogs, unarchiveDialog]
23024
23299
  );
23025
- return useMemo27(
23300
+ return useMemo28(
23026
23301
  () => ({
23027
23302
  messages,
23028
23303
  isLoading,
@@ -23121,7 +23396,7 @@ function useStableShallow(value) {
23121
23396
  }
23122
23397
 
23123
23398
  // src/components/chat/hooks/use-unified-chat.ts
23124
- import { useCallback as useCallback23, useEffect as useEffect36, useMemo as useMemo28, useRef as useRef31, useState as useState44 } from "react";
23399
+ import { useCallback as useCallback24, useEffect as useEffect36, useMemo as useMemo29, useRef as useRef32, useState as useState44 } from "react";
23125
23400
  var EMPTY_SSE_OPTIONS = {};
23126
23401
  function createDisabledNatsConfig() {
23127
23402
  return {
@@ -23147,40 +23422,40 @@ function useUnifiedChat(options) {
23147
23422
  const activeStateIsInjected = activeState === mingoStateOverride;
23148
23423
  const stableInjected = useStableShallow(injectedDialogCapabilities);
23149
23424
  const dialogCapabilities = activeStateIsInjected ? activeState.dialogCapabilities ?? stableInjected ?? EMPTY_DIALOG_CAPABILITIES : activeState.dialogCapabilities;
23150
- const activeStateRef = useRef31(activeState);
23425
+ const activeStateRef = useRef32(activeState);
23151
23426
  useEffect36(() => {
23152
23427
  activeStateRef.current = activeState;
23153
23428
  });
23154
- const stopMessage = useCallback23(() => activeStateRef.current.stopMessage(), []);
23155
- const clearMessages = useCallback23(() => activeStateRef.current.clearMessages(), []);
23156
- const sendMessage = useCallback23(
23429
+ const stopMessage = useCallback24(() => activeStateRef.current.stopMessage(), []);
23430
+ const clearMessages = useCallback24(() => activeStateRef.current.clearMessages(), []);
23431
+ const sendMessage = useCallback24(
23157
23432
  (text2, opts) => activeStateRef.current.sendMessage(text2, opts),
23158
23433
  []
23159
23434
  );
23160
- const discussRef = useCallback23(
23435
+ const discussRef = useCallback24(
23161
23436
  (ref) => activeStateRef.current.discussRef(ref),
23162
23437
  []
23163
23438
  );
23164
- const displayRefForward = useCallback23(
23439
+ const displayRefForward = useCallback24(
23165
23440
  (ref) => activeStateRef.current.displayRef?.(ref),
23166
23441
  []
23167
23442
  );
23168
23443
  const displayRef = activeState.displayRef ? displayRefForward : void 0;
23169
- const selectDialog = useCallback23((id) => activeStateRef.current.selectDialog(id), []);
23170
- const startNewDialog = useCallback23(() => activeStateRef.current.startNewDialog(), []);
23171
- const deleteDialog = useCallback23((id) => activeStateRef.current.deleteDialog(id), []);
23172
- const renameDialog = useCallback23((id, title) => activeStateRef.current.renameDialog(id, title), []);
23173
- const archiveDialog = useCallback23((id) => activeStateRef.current.archiveDialog(id), []);
23174
- const loadMoreDialogs = useCallback23(() => activeStateRef.current.loadMoreDialogs(), []);
23175
- const setDialogScope = useCallback23((scope) => activeStateRef.current.setDialogScope?.(scope), []);
23176
- const reloadDialogs = useCallback23(() => activeStateRef.current.reloadDialogs(), []);
23177
- const loadMoreMessages = useCallback23(() => activeStateRef.current.loadMoreMessages(), []);
23178
- const approveRequest = useCallback23((requestId) => activeStateRef.current.approveRequest(requestId), []);
23179
- const rejectRequest = useCallback23(
23444
+ const selectDialog = useCallback24((id) => activeStateRef.current.selectDialog(id), []);
23445
+ const startNewDialog = useCallback24(() => activeStateRef.current.startNewDialog(), []);
23446
+ const deleteDialog = useCallback24((id) => activeStateRef.current.deleteDialog(id), []);
23447
+ const renameDialog = useCallback24((id, title) => activeStateRef.current.renameDialog(id, title), []);
23448
+ const archiveDialog = useCallback24((id) => activeStateRef.current.archiveDialog(id), []);
23449
+ const loadMoreDialogs = useCallback24(() => activeStateRef.current.loadMoreDialogs(), []);
23450
+ const setDialogScope = useCallback24((scope) => activeStateRef.current.setDialogScope?.(scope), []);
23451
+ const reloadDialogs = useCallback24(() => activeStateRef.current.reloadDialogs(), []);
23452
+ const loadMoreMessages = useCallback24(() => activeStateRef.current.loadMoreMessages(), []);
23453
+ const approveRequest = useCallback24((requestId) => activeStateRef.current.approveRequest(requestId), []);
23454
+ const rejectRequest = useCallback24(
23180
23455
  (requestId, reason) => activeStateRef.current.rejectRequest(requestId, reason),
23181
23456
  []
23182
23457
  );
23183
- return useMemo28(
23458
+ return useMemo29(
23184
23459
  () => ({
23185
23460
  messages: activeState.messages,
23186
23461
  isLoading: activeState.isLoading,
@@ -23656,7 +23931,7 @@ import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
23656
23931
  import { usePreventScroll } from "@react-aria/overlays";
23657
23932
  import { isIOS } from "@react-aria/utils";
23658
23933
  import { MessageSquare as MessageSquare3 } from "lucide-react";
23659
- import React10, { useCallback as useCallback27, useEffect as useEffect38, useImperativeHandle as useImperativeHandle4, useMemo as useMemo30, useRef as useRef35, useState as useState48 } from "react";
23934
+ import React10, { useCallback as useCallback28, useEffect as useEffect38, useImperativeHandle as useImperativeHandle4, useMemo as useMemo31, useRef as useRef36, useState as useState48 } from "react";
23660
23935
 
23661
23936
  // src/components/ui/drawer.tsx
23662
23937
  import * as DialogPrimitive from "@radix-ui/react-dialog";
@@ -23664,9 +23939,9 @@ import { cva as cva2 } from "class-variance-authority";
23664
23939
  import { X } from "lucide-react";
23665
23940
  import {
23666
23941
  forwardRef as forwardRef26,
23667
- useCallback as useCallback24,
23942
+ useCallback as useCallback25,
23668
23943
  useEffect as useEffect37,
23669
- useRef as useRef32,
23944
+ useRef as useRef33,
23670
23945
  useState as useState45
23671
23946
  } from "react";
23672
23947
  import { jsx as jsx96, jsxs as jsxs74 } from "react/jsx-runtime";
@@ -23773,7 +24048,7 @@ function viewportSize(isHorizontal) {
23773
24048
  return isHorizontal ? window.innerWidth : window.innerHeight;
23774
24049
  }
23775
24050
  function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize, storageKey }) {
23776
- const clampToViewport = useCallback24(
24051
+ const clampToViewport = useCallback25(
23777
24052
  (value) => {
23778
24053
  const vp = viewportSize(isHorizontal);
23779
24054
  const effectiveMax = vp > 0 ? Math.min(maxSize, vp - 80) : maxSize;
@@ -23781,7 +24056,7 @@ function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize
23781
24056
  },
23782
24057
  [isHorizontal, minSize, maxSize]
23783
24058
  );
23784
- const readInitial = useCallback24(() => {
24059
+ const readInitial = useCallback25(() => {
23785
24060
  if (!enabled) return defaultSize;
23786
24061
  if (typeof window === "undefined") return defaultSize;
23787
24062
  if (!storageKey) return clampToViewport(defaultSize);
@@ -23796,7 +24071,7 @@ function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize
23796
24071
  }
23797
24072
  }, [enabled, storageKey, defaultSize, clampToViewport]);
23798
24073
  const [size2, setSizeRaw] = useState45(readInitial);
23799
- const setSize = useCallback24((next) => setSizeRaw(clampToViewport(next)), [clampToViewport]);
24074
+ const setSize = useCallback25((next) => setSizeRaw(clampToViewport(next)), [clampToViewport]);
23800
24075
  useEffect37(() => {
23801
24076
  if (!enabled || !storageKey || typeof window === "undefined") return;
23802
24077
  try {
@@ -23814,7 +24089,7 @@ function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize
23814
24089
  }
23815
24090
  function DrawerResizeHandle({ side, size: size2, minSize, maxSize, onSize, ariaLabel }) {
23816
24091
  const isHorizontal = HORIZONTAL_SIDES.has(side);
23817
- const startRef = useRef32(null);
24092
+ const startRef = useRef33(null);
23818
24093
  const direction = side === "right" || side === "bottom" ? -1 : 1;
23819
24094
  const handlePointerDown = (e) => {
23820
24095
  if (e.button !== 0 && e.pointerType === "mouse") return;
@@ -24011,7 +24286,7 @@ var DrawerFooter = ({ className, ...props }) => /* @__PURE__ */ jsx96("div", { c
24011
24286
  DrawerFooter.displayName = "DrawerFooter";
24012
24287
 
24013
24288
  // src/components/ui/hover-dropdown.tsx
24014
- import { useState as useState46, useRef as useRef33, useCallback as useCallback25 } from "react";
24289
+ import { useState as useState46, useRef as useRef34, useCallback as useCallback26 } from "react";
24015
24290
  import { Fragment as Fragment33, jsx as jsx97, jsxs as jsxs75 } from "react/jsx-runtime";
24016
24291
  function DefaultAnchor({ href, className, children }) {
24017
24292
  return /* @__PURE__ */ jsx97("a", { href, className, children });
@@ -24025,9 +24300,9 @@ function HoverDropdown({
24025
24300
  renderAnchor
24026
24301
  }) {
24027
24302
  const [open, setOpen] = useState46(false);
24028
- const timeoutRef = useRef33(void 0);
24029
- const containerRef = useRef33(null);
24030
- const panelRef = useRef33(null);
24303
+ const timeoutRef = useRef34(void 0);
24304
+ const containerRef = useRef34(null);
24305
+ const panelRef = useRef34(null);
24031
24306
  useIsomorphicLayoutEffect(() => {
24032
24307
  const el = panelRef.current;
24033
24308
  const container = containerRef.current;
@@ -24055,14 +24330,14 @@ function HoverDropdown({
24055
24330
  }
24056
24331
  }
24057
24332
  });
24058
- const show = useCallback25(() => {
24333
+ const show = useCallback26(() => {
24059
24334
  clearTimeout(timeoutRef.current);
24060
24335
  setOpen(true);
24061
24336
  }, []);
24062
- const hide = useCallback25(() => {
24337
+ const hide = useCallback26(() => {
24063
24338
  timeoutRef.current = setTimeout(() => setOpen(false), hideDelay);
24064
24339
  }, [hideDelay]);
24065
- const toggle = useCallback25((e) => {
24340
+ const toggle = useCallback26((e) => {
24066
24341
  e.stopPropagation();
24067
24342
  clearTimeout(timeoutRef.current);
24068
24343
  setOpen((prev) => !prev);
@@ -24128,7 +24403,7 @@ function HoverDropdown({
24128
24403
  }
24129
24404
 
24130
24405
  // src/components/chat/hooks/use-chat-dialog-manager.ts
24131
- import { useCallback as useCallback26, useMemo as useMemo29, useRef as useRef34, useState as useState47 } from "react";
24406
+ import { useCallback as useCallback27, useMemo as useMemo30, useRef as useRef35, useState as useState47 } from "react";
24132
24407
  function useChatDialogManager({
24133
24408
  dialogs,
24134
24409
  activeDialogId,
@@ -24141,7 +24416,7 @@ function useChatDialogManager({
24141
24416
  }) {
24142
24417
  const [renameTarget, setRenameTarget] = useState47(null);
24143
24418
  const [archiveTarget, setArchiveTarget] = useState47(null);
24144
- const handleConfirmRename = useCallback26(
24419
+ const handleConfirmRename = useCallback27(
24145
24420
  (name) => {
24146
24421
  if (renameTarget) void renameDialog(renameTarget.id, name);
24147
24422
  setRenameTarget(null);
@@ -24149,7 +24424,7 @@ function useChatDialogManager({
24149
24424
  [renameTarget, renameDialog]
24150
24425
  );
24151
24426
  const [openingDialogId, setOpeningDialogId] = useState47(null);
24152
- const handleConfirmArchive = useCallback26(async () => {
24427
+ const handleConfirmArchive = useCallback27(async () => {
24153
24428
  if (archiveTarget) {
24154
24429
  try {
24155
24430
  await archiveDialog(archiveTarget.id);
@@ -24169,8 +24444,8 @@ function useChatDialogManager({
24169
24444
  const [archivedCursor, setArchivedCursor] = useState47(null);
24170
24445
  const [archivedLoading, setArchivedLoading] = useState47(false);
24171
24446
  const [archivedPending, setArchivedPending] = useState47(false);
24172
- const archivedRequestIdRef = useRef34(0);
24173
- const loadArchivedPage = useCallback26(
24447
+ const archivedRequestIdRef = useRef35(0);
24448
+ const loadArchivedPage = useCallback27(
24174
24449
  async (cursor) => {
24175
24450
  if (!fetchArchivedDialogs) return;
24176
24451
  const requestId = ++archivedRequestIdRef.current;
@@ -24203,13 +24478,13 @@ function useChatDialogManager({
24203
24478
  },
24204
24479
  [fetchArchivedDialogs]
24205
24480
  );
24206
- const openArchive = useCallback26(() => {
24481
+ const openArchive = useCallback27(() => {
24207
24482
  setArchiveOpen(true);
24208
24483
  void loadArchivedPage();
24209
24484
  }, [loadArchivedPage]);
24210
- const closeArchive = useCallback26(() => setArchiveOpen(false), []);
24485
+ const closeArchive = useCallback27(() => setArchiveOpen(false), []);
24211
24486
  const [viewingArchivedId, setViewingArchivedId] = useState47(null);
24212
- const handleSelectDialog = useCallback26(
24487
+ const handleSelectDialog = useCallback27(
24213
24488
  (id) => {
24214
24489
  setViewingArchivedId(null);
24215
24490
  setOpeningDialogId(id);
@@ -24218,7 +24493,7 @@ function useChatDialogManager({
24218
24493
  [selectDialog]
24219
24494
  );
24220
24495
  const isOpeningDialog = openingDialogId != null && openingDialogId === activeDialogId;
24221
- const handleArchivedSelect = useCallback26(
24496
+ const handleArchivedSelect = useCallback27(
24222
24497
  (id) => {
24223
24498
  setArchiveOpen(false);
24224
24499
  setOpeningDialogId(null);
@@ -24228,7 +24503,7 @@ function useChatDialogManager({
24228
24503
  [selectDialog]
24229
24504
  );
24230
24505
  const [restoreTarget, setRestoreTarget] = useState47(null);
24231
- const handleConfirmRestore = useCallback26(async () => {
24506
+ const handleConfirmRestore = useCallback27(async () => {
24232
24507
  if (restoreTarget) {
24233
24508
  try {
24234
24509
  await unarchiveDialog?.(restoreTarget.id);
@@ -24242,7 +24517,7 @@ function useChatDialogManager({
24242
24517
  setRestoreTarget(null);
24243
24518
  }, [restoreTarget, unarchiveDialog]);
24244
24519
  const isViewingArchived = viewingArchivedId != null && viewingArchivedId === activeDialogId;
24245
- const handleBack = useCallback26(() => {
24520
+ const handleBack = useCallback27(() => {
24246
24521
  const wasArchived = isViewingArchived;
24247
24522
  setViewingArchivedId(null);
24248
24523
  setOpeningDialogId(null);
@@ -24250,14 +24525,14 @@ function useChatDialogManager({
24250
24525
  clearMessages();
24251
24526
  if (wasArchived) setArchiveOpen(true);
24252
24527
  }, [isViewingArchived, selectDialog, clearMessages]);
24253
- const resetToNewChat = useCallback26(() => {
24528
+ const resetToNewChat = useCallback27(() => {
24254
24529
  setViewingArchivedId(null);
24255
24530
  setOpeningDialogId(null);
24256
24531
  selectDialog(null);
24257
24532
  clearMessages();
24258
24533
  setArchiveOpen(false);
24259
24534
  }, [selectDialog, clearMessages]);
24260
- const activeDialog = useMemo29(
24535
+ const activeDialog = useMemo30(
24261
24536
  () => dialogs.find((d) => d.id === activeDialogId) ?? archivedDialogs.find((d) => d.id === activeDialogId),
24262
24537
  [dialogs, archivedDialogs, activeDialogId]
24263
24538
  );
@@ -24312,7 +24587,7 @@ function splitCitedSources(sources2, content) {
24312
24587
  }
24313
24588
  const cited = sources2.filter((source) => firstMentionAt.has(source.index)).sort((a, b) => (firstMentionAt.get(a.index) ?? 0) - (firstMentionAt.get(b.index) ?? 0));
24314
24589
  const uncited = sources2.filter((source) => !firstMentionAt.has(source.index));
24315
- return { cited, uncited };
24590
+ return { cited: groupSourcesByTable(cited), uncited: groupSourcesByTable(uncited) };
24316
24591
  }
24317
24592
 
24318
24593
  // src/components/chat/utils/host-message.ts
@@ -24498,7 +24773,9 @@ function SourceChip({
24498
24773
  const ItemIcon = itemCta.icon;
24499
24774
  const itemChatRef = itemCta.chatRef;
24500
24775
  return {
24501
- label: item.name,
24776
+ // A client-built group keeps each row's own citation number, so the
24777
+ // `[3]` in the answer is findable inside the dropdown.
24778
+ label: item.index === void 0 ? item.name : `[${item.index}] ${item.name}`,
24502
24779
  icon: /* @__PURE__ */ jsx98(ItemIcon, { className: "h-3.5 w-3.5" }),
24503
24780
  href: itemCta.href ?? void 0,
24504
24781
  targetPlatform: itemCta.targetPlatform,
@@ -24510,6 +24787,8 @@ function SourceChip({
24510
24787
  } : void 0
24511
24788
  };
24512
24789
  });
24790
+ const itemIndices = src.items.flatMap((item) => item.index === void 0 ? [] : [item.index]);
24791
+ const groupIndices = itemIndices.length > 0 ? formatCitationIndices(itemIndices) : `${src.index}`;
24513
24792
  return /* @__PURE__ */ jsx98(
24514
24793
  HoverDropdown,
24515
24794
  {
@@ -24528,7 +24807,7 @@ function SourceChip({
24528
24807
  icon,
24529
24808
  /* @__PURE__ */ jsxs76("span", { className: "max-w-[160px] truncate", children: [
24530
24809
  "[",
24531
- src.index,
24810
+ groupIndices,
24532
24811
  "] ",
24533
24812
  src.name
24534
24813
  ] })
@@ -24734,7 +25013,7 @@ function EmbeddableChatInner({
24734
25013
  return !window.matchMedia("(pointer: coarse)").matches;
24735
25014
  });
24736
25015
  usePreventScroll({ isDisabled: !isOpen || shellLess });
24737
- const navigatingAwayRef = useRef35(false);
25016
+ const navigatingAwayRef = useRef36(false);
24738
25017
  useEffect38(() => {
24739
25018
  if (!isOpen) return void 0;
24740
25019
  if (shellLess) return void 0;
@@ -24761,9 +25040,9 @@ function EmbeddableChatInner({
24761
25040
  window.scrollTo(0, scrollY);
24762
25041
  };
24763
25042
  }, [isOpen, shellLess]);
24764
- const chatInputRef = useRef35(null);
25043
+ const chatInputRef = useRef36(null);
24765
25044
  const [quickActionPreview, setQuickActionPreview] = useState48(null);
24766
- const slashCommandsProp = useMemo30(
25045
+ const slashCommandsProp = useMemo31(
24767
25046
  () => ({
24768
25047
  fetchCommands: (prefix, signal) => fetchSlashCommands(prefix, signal, commandsUrl),
24769
25048
  resolveSourceIcon: (sourceId) => {
@@ -24778,7 +25057,7 @@ function EmbeddableChatInner({
24778
25057
  [commandsUrl]
24779
25058
  );
24780
25059
  const headerUserName = identityUser?.name?.trim() || [identityUser?.firstName, identityUser?.lastName].filter(Boolean).join(" ").trim() || userDisplayName?.trim() || void 0;
24781
- const effectiveModes = useMemo30(() => {
25060
+ const effectiveModes = useMemo31(() => {
24782
25061
  if (modes) return modes;
24783
25062
  const guideOptions = tableIdForDocumentType ? { tableIdForDocumentType } : {};
24784
25063
  return { guide: guideOptions };
@@ -24787,7 +25066,7 @@ function EmbeddableChatInner({
24787
25066
  const initialActiveMode = controlledActiveMode ?? defaultActiveMode ?? (effectiveModes.guide ? "guide" : "mingo");
24788
25067
  const [uncontrolledActiveMode, setUncontrolledActiveMode] = useState48(initialActiveMode);
24789
25068
  const activeMode = controlledActiveMode ?? uncontrolledActiveMode;
24790
- const handleActiveModeChange = useCallback27(
25069
+ const handleActiveModeChange = useCallback28(
24791
25070
  (next) => {
24792
25071
  if (controlledActiveMode === void 0) {
24793
25072
  setUncontrolledActiveMode(next);
@@ -24799,7 +25078,7 @@ function EmbeddableChatInner({
24799
25078
  const { commands: commandsList, loaded: commandsLoaded } = useSlashCommandRegistry(commandsUrl, {
24800
25079
  enabled: activeMode === "guide"
24801
25080
  });
24802
- const commandsById = useMemo30(() => {
25081
+ const commandsById = useMemo31(() => {
24803
25082
  const map = /* @__PURE__ */ new Map();
24804
25083
  for (const cmd of commandsList) map.set(cmd.id, cmd);
24805
25084
  return map;
@@ -24813,7 +25092,7 @@ function EmbeddableChatInner({
24813
25092
  const effectiveGreeting = emptyStateConfig.greeting ?? emptyStateGreeting;
24814
25093
  const effectiveEnabledRagTableIds = emptyStateUrl ? emptyStateConfig.enabledRagTableIds : enabledRagTableIds;
24815
25094
  const effectiveSuggestedQueries = emptyStateUrl ? emptyStateConfig.suggestedQueries : suggestedQueries;
24816
- const effectiveQuickActions = useMemo30(
25095
+ const effectiveQuickActions = useMemo31(
24817
25096
  () => emptyStateUrl ? emptyStateConfig.quickActions : [],
24818
25097
  [emptyStateUrl, emptyStateConfig.quickActions]
24819
25098
  );
@@ -24859,7 +25138,7 @@ function EmbeddableChatInner({
24859
25138
  injectedDialogCapabilities: mingoDialogCapabilities
24860
25139
  });
24861
25140
  const historyListMode = dialogCapabilities !== void 0;
24862
- const mingoCaps = useMemo30(
25141
+ const mingoCaps = useMemo31(
24863
25142
  () => ({
24864
25143
  ...dialogCapabilities,
24865
25144
  canRename: dialogCapabilities?.canRename ?? false,
@@ -24867,7 +25146,7 @@ function EmbeddableChatInner({
24867
25146
  }),
24868
25147
  [dialogCapabilities]
24869
25148
  );
24870
- const guidePromptSentRef = useRef35(false);
25149
+ const guidePromptSentRef = useRef36(false);
24871
25150
  useEffect38(() => {
24872
25151
  if (!guidePendingPrompt) {
24873
25152
  guidePromptSentRef.current = false;
@@ -24894,11 +25173,11 @@ function EmbeddableChatInner({
24894
25173
  const [contextItems, setContextItems] = useState48(NO_CONTEXT_ITEMS);
24895
25174
  const [contextPickerOpen, setContextPickerOpen] = useState48(false);
24896
25175
  const [mentionQuery, setMentionQuery] = useState48(null);
24897
- const mentionActiveRef = useRef35(false);
25176
+ const mentionActiveRef = useRef36(false);
24898
25177
  useEffect38(() => {
24899
25178
  mentionActiveRef.current = mentionQuery !== null;
24900
25179
  }, [mentionQuery]);
24901
- const mentionKeysRef = useRef35(/* @__PURE__ */ new Set());
25180
+ const mentionKeysRef = useRef36(/* @__PURE__ */ new Set());
24902
25181
  const [contextClearedFor, setContextClearedFor] = useState48({ activeDialogId, activeMode });
24903
25182
  if (contextClearedFor.activeDialogId !== activeDialogId || contextClearedFor.activeMode !== activeMode) {
24904
25183
  setContextClearedFor({ activeDialogId, activeMode });
@@ -24908,18 +25187,18 @@ function EmbeddableChatInner({
24908
25187
  useEffect38(() => {
24909
25188
  mentionKeysRef.current.clear();
24910
25189
  }, [activeDialogId, activeMode]);
24911
- const mentionMarkerByType = useMemo30(() => {
25190
+ const mentionMarkerByType = useMemo31(() => {
24912
25191
  const m = /* @__PURE__ */ new Map();
24913
25192
  for (const t of contextPicker?.entityTypes ?? []) if (t.marker) m.set(t.type, t.marker);
24914
25193
  return m;
24915
25194
  }, [contextPicker?.entityTypes]);
24916
25195
  const contextEntityTypes = contextPicker?.entityTypes;
24917
- const resolveContextIcon = useMemo30(() => {
25196
+ const resolveContextIcon = useMemo31(() => {
24918
25197
  const byType = /* @__PURE__ */ new Map();
24919
25198
  for (const t of contextEntityTypes ?? []) byType.set(t.type, t.icon);
24920
25199
  return (item) => byType.get(item.type);
24921
25200
  }, [contextEntityTypes]);
24922
- const toggleContextItem = useCallback27(
25201
+ const toggleContextItem = useCallback28(
24923
25202
  (item) => {
24924
25203
  const key = `${item.type}:${item.id}`;
24925
25204
  if (mentionActiveRef.current) {
@@ -24942,7 +25221,7 @@ function EmbeddableChatInner({
24942
25221
  },
24943
25222
  [contextMaxItems, contextItems, mentionMarkerByType, resolveContextIcon]
24944
25223
  );
24945
- const removeContextItem = useCallback27(
25224
+ const removeContextItem = useCallback28(
24946
25225
  (item) => {
24947
25226
  const key = `${item.type}:${item.id}`;
24948
25227
  setContextItems((prev) => prev.filter((p) => `${p.type}:${p.id}` !== key));
@@ -24955,7 +25234,7 @@ function EmbeddableChatInner({
24955
25234
  },
24956
25235
  [mentionMarkerByType]
24957
25236
  );
24958
- const handleContextValueChange = useCallback27(
25237
+ const handleContextValueChange = useCallback28(
24959
25238
  (value) => {
24960
25239
  for (const key of Array.from(mentionKeysRef.current)) {
24961
25240
  if (!value.includes(`@${mentionTokenOf(key, mentionMarkerByType)}`)) {
@@ -24966,32 +25245,32 @@ function EmbeddableChatInner({
24966
25245
  },
24967
25246
  [mentionMarkerByType]
24968
25247
  );
24969
- const openContextPicker = useCallback27(() => {
25248
+ const openContextPicker = useCallback28(() => {
24970
25249
  setMentionQuery(null);
24971
25250
  setContextPickerOpen(true);
24972
25251
  }, []);
24973
- const closeContextPicker = useCallback27(() => {
25252
+ const closeContextPicker = useCallback28(() => {
24974
25253
  if (mentionActiveRef.current) {
24975
25254
  chatInputRef.current?.removeMentionTrigger();
24976
25255
  }
24977
25256
  setContextPickerOpen(false);
24978
25257
  setMentionQuery(null);
24979
25258
  }, []);
24980
- const handleMentionQueryChange = useCallback27((query) => {
25259
+ const handleMentionQueryChange = useCallback28((query) => {
24981
25260
  setMentionQuery(query);
24982
25261
  setContextPickerOpen(query !== null);
24983
25262
  }, []);
24984
25263
  const resolvedBaseRoute = baseRoute || (source === "flamingo" ? "/knowledge-base" : "/data-room");
24985
- const handleClose = useCallback27(() => setIsOpen(false), [setIsOpen]);
24986
- const handleNavigationClose = useCallback27(() => {
25264
+ const handleClose = useCallback28(() => setIsOpen(false), [setIsOpen]);
25265
+ const handleNavigationClose = useCallback28(() => {
24987
25266
  navigatingAwayRef.current = true;
24988
25267
  setIsOpen(false);
24989
25268
  }, [setIsOpen]);
24990
- const chatPanelHandle = useMemo30(
25269
+ const chatPanelHandle = useMemo31(
24991
25270
  () => ({ closeChat: handleNavigationClose }),
24992
25271
  [handleNavigationClose]
24993
25272
  );
24994
- const renderEntityCard = useCallback27(
25273
+ const renderEntityCard = useCallback28(
24995
25274
  (reference) => renderChatInlineEntityCard(reference, {
24996
25275
  onDiscuss: discussRef,
24997
25276
  onDisplay: displayRef,
@@ -25001,20 +25280,20 @@ function EmbeddableChatInner({
25001
25280
  }),
25002
25281
  [discussRef, displayRef, resolvedBaseRoute, chipBasePlatform, extras]
25003
25282
  );
25004
- const mingoAssistantIcon = useMemo30(
25283
+ const mingoAssistantIcon = useMemo31(
25005
25284
  () => effectiveAssistantIcon ? /* @__PURE__ */ jsx98(EntityIcon, { icon: effectiveAssistantIcon, size: 24 }) : /* @__PURE__ */ jsx98(MingoIcon, { className: "h-6 w-6", cornerColor: "var(--ods-flamingo-cyan-base)" }),
25006
25285
  [effectiveAssistantIcon]
25007
25286
  );
25008
25287
  const [timestampCache] = useState48(() => /* @__PURE__ */ new Map());
25009
25288
  const guideUserName = activeMode === "guide" ? [identityUser?.firstName, identityUser?.lastName].filter(Boolean).join(" ").trim() || identityUser?.name?.trim() || void 0 : void 0;
25010
25289
  const guideUserAvatar = activeMode === "guide" ? identityUser?.avatarUrl?.trim() || void 0 : void 0;
25011
- const messages = useMemo30(() => {
25290
+ const messages = useMemo31(() => {
25012
25291
  const options = { userName: guideUserName, userAvatar: guideUserAvatar, timestampCache };
25013
25292
  const mapped = rawMessages.map((m) => mapHostMessage(m, options));
25014
25293
  pruneTimestampCache(timestampCache, new Set(rawMessages.map((m) => m.id)));
25015
25294
  return mapped;
25016
25295
  }, [rawMessages, guideUserName, guideUserAvatar, timestampCache]);
25017
- const handleSend = useCallback27(
25296
+ const handleSend = useCallback28(
25018
25297
  (text2) => {
25019
25298
  let augmentedText = text2;
25020
25299
  if (readyAttachments.length > 0) {
@@ -25036,7 +25315,7 @@ function EmbeddableChatInner({
25036
25315
  },
25037
25316
  [sendMessage, readyAttachments, viewUrlPrefix, clearAttachments, contextItems]
25038
25317
  );
25039
- const handleAskSelect = useCallback27(
25318
+ const handleAskSelect = useCallback28(
25040
25319
  (label) => {
25041
25320
  void sendMessage(label).catch((err) => {
25042
25321
  console.error("[EmbeddableChat] handleAskSelect send failed:", err);
@@ -25044,7 +25323,7 @@ function EmbeddableChatInner({
25044
25323
  },
25045
25324
  [sendMessage]
25046
25325
  );
25047
- const guideSuggestedActions = useMemo30(() => {
25326
+ const guideSuggestedActions = useMemo31(() => {
25048
25327
  if (effectiveQuickActions.length > 0) {
25049
25328
  return effectiveQuickActions.map((qa) => ({
25050
25329
  id: qa.id,
@@ -25103,7 +25382,7 @@ function EmbeddableChatInner({
25103
25382
  fetchArchivedDialogs: mingoCaps.fetchArchivedDialogs,
25104
25383
  unarchiveDialog: mingoCaps.unarchiveDialog
25105
25384
  });
25106
- const handleOpen = useCallback27(() => setIsOpen(true), [setIsOpen]);
25385
+ const handleOpen = useCallback28(() => setIsOpen(true), [setIsOpen]);
25107
25386
  useCloseOnNavigation(handleNavigationClose, null);
25108
25387
  useEffect38(() => {
25109
25388
  const handler = (e) => {
@@ -25136,11 +25415,11 @@ function EmbeddableChatInner({
25136
25415
  if (!isQuickActionEmpty && quickActionPreview !== null) setQuickActionPreview(null);
25137
25416
  const guideCanReturnToMingo = isGuideEmpty && hasMingoMode;
25138
25417
  const sourceLabel = source === "flamingo" ? "Knowledge Base" : "Data Room";
25139
- const enabledSet = useMemo30(
25418
+ const enabledSet = useMemo31(
25140
25419
  () => effectiveEnabledRagTableIds ? new Set(effectiveEnabledRagTableIds) : null,
25141
25420
  [effectiveEnabledRagTableIds]
25142
25421
  );
25143
- const chipCommands = useMemo30(() => {
25422
+ const chipCommands = useMemo31(() => {
25144
25423
  const out = [];
25145
25424
  for (const cmd of commandsById.values()) {
25146
25425
  if (cmd.displayOrder === void 0) continue;
@@ -25155,7 +25434,7 @@ function EmbeddableChatInner({
25155
25434
  });
25156
25435
  return out;
25157
25436
  }, [commandsById, enabledSet]);
25158
- const renderMessageSources = useCallback27(
25437
+ const renderMessageSources = useCallback28(
25159
25438
  (message, index) => {
25160
25439
  if (message.role !== "assistant") return null;
25161
25440
  if (chatLoading && index === messages.length - 1) return null;
@@ -25187,7 +25466,7 @@ function EmbeddableChatInner({
25187
25466
  ro.observe(panelBoundary);
25188
25467
  return () => ro.disconnect();
25189
25468
  }, [panelBoundary]);
25190
- const setPanelNode = useCallback27((node) => {
25469
+ const setPanelNode = useCallback28((node) => {
25191
25470
  setPanelBoundary(node);
25192
25471
  if (node) setPanelWidth(node.clientWidth);
25193
25472
  }, []);
@@ -25201,7 +25480,7 @@ function EmbeddableChatInner({
25201
25480
  } catch {
25202
25481
  }
25203
25482
  }
25204
- const toggleRailCollapsed = useCallback27(() => {
25483
+ const toggleRailCollapsed = useCallback28(() => {
25205
25484
  setRailCollapsed((prev) => {
25206
25485
  const next = !prev;
25207
25486
  try {
@@ -25237,7 +25516,7 @@ function EmbeddableChatInner({
25237
25516
  const headerPersonName = headerOwner?.name?.trim() || headerUserName;
25238
25517
  const headerPersonAvatarUrl = headerOwner ? headerOwner.avatarUrl?.trim() || void 0 : identityUser?.avatarUrl?.trim() || userAvatarUrl?.trim() || void 0;
25239
25518
  const headerAvatar = headerPersonName || headerPersonAvatarUrl ? { name: headerPersonName, avatarUrl: headerPersonAvatarUrl } : void 0;
25240
- const handleNewChat = useCallback27(() => {
25519
+ const handleNewChat = useCallback28(() => {
25241
25520
  resetToNewChat();
25242
25521
  }, [resetToNewChat]);
25243
25522
  const [pendingDraft, setPendingDraft] = useState48(null);
@@ -25246,7 +25525,7 @@ function EmbeddableChatInner({
25246
25525
  setSeededDraft(pendingDraft);
25247
25526
  setContextItems(pendingDraft.mentions);
25248
25527
  }
25249
- const appliedDraftRef = useRef35(null);
25528
+ const appliedDraftRef = useRef36(null);
25250
25529
  useEffect38(() => {
25251
25530
  const draft = pendingDraft;
25252
25531
  if (!draft || appliedDraftRef.current === draft) return;
@@ -26052,6 +26331,12 @@ export {
26052
26331
  getRequestOrigin,
26053
26332
  resolveRedirectTarget,
26054
26333
  getAllPlatformBaseDomains,
26334
+ DOC_TABLE_TYPES,
26335
+ groupsByTable,
26336
+ recordCountLabel,
26337
+ buildGroupedSource,
26338
+ groupSourcesByTable,
26339
+ formatCitationIndices,
26055
26340
  resolveSourceRowCTA,
26056
26341
  resolveSourceIcon,
26057
26342
  chatCardLabel,
@@ -26138,4 +26423,4 @@ export {
26138
26423
  buildStreamFrames,
26139
26424
  EmbeddableChat
26140
26425
  };
26141
- //# sourceMappingURL=chunk-DULSS7R6.js.map
26426
+ //# sourceMappingURL=chunk-3ORBE27K.js.map