@nivaro/react 0.2.54 → 0.2.55

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 (150) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +99 -98
  3. package/dist/index.d.ts +339 -2
  4. package/dist/index.js +644 -618
  5. package/dist/layout-editor.d.ts +4 -0
  6. package/dist/shared/components/BackgroundRunOffer.js +117 -0
  7. package/dist/shared/components/BroadcastView.js +214 -213
  8. package/dist/shared/components/CollectionBrowserView.js +2592 -2695
  9. package/dist/shared/components/ItemEditForm.js +4066 -3832
  10. package/dist/shared/components/JobsTray.js +100 -55
  11. package/dist/shared/components/MyWorkView.js +91 -89
  12. package/dist/shared/components/NotificationBell.js +80 -79
  13. package/dist/shared/components/ProfileView.js +568 -520
  14. package/dist/shared/components/RecordCompare.js +254 -0
  15. package/dist/shared/components/RecordReadView.js +599 -552
  16. package/dist/shared/components/ReportView.js +578 -543
  17. package/dist/shared/components/RowPresence.js +91 -0
  18. package/dist/shared/components/WidgetSlot.js +474 -458
  19. package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
  20. package/dist/shared/components/ai/AskPanel.js +139 -119
  21. package/dist/shared/components/ai/FirstWeekCard.js +126 -0
  22. package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
  23. package/dist/shared/components/bulk/bulk-field-options.js +45 -0
  24. package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
  25. package/dist/shared/components/chat/ChannelArchive.js +326 -0
  26. package/dist/shared/components/chat/ChannelExtras.js +141 -121
  27. package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
  28. package/dist/shared/components/chat/ChatPanel.js +1695 -1733
  29. package/dist/shared/components/chat/Composer.js +357 -303
  30. package/dist/shared/components/chat/MessageActions.js +92 -0
  31. package/dist/shared/components/chat/MessageFormat.js +290 -264
  32. package/dist/shared/components/chat/OutboxBubbles.js +146 -0
  33. package/dist/shared/components/chat/RequestIdCard.js +135 -0
  34. package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
  35. package/dist/shared/components/chat/RoomParts.js +213 -274
  36. package/dist/shared/components/chat/ScreenClip.js +184 -0
  37. package/dist/shared/components/chat/chat-core.js +402 -483
  38. package/dist/shared/components/chat/chat-drafts.js +59 -0
  39. package/dist/shared/components/chat/chat-emoji.js +348 -0
  40. package/dist/shared/components/chat/chat-local-time.js +41 -0
  41. package/dist/shared/components/chat/chat-outbox.js +303 -0
  42. package/dist/shared/components/chat/chat-window.js +163 -0
  43. package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
  44. package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
  45. package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
  46. package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
  47. package/dist/shared/components/help-videos/api.js +76 -73
  48. package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
  49. package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
  50. package/dist/shared/components/item-edit/FieldAffordances.js +2 -2
  51. package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
  52. package/dist/shared/components/item-edit/FieldRow.js +292 -279
  53. package/dist/shared/components/item-edit/GroupSection.js +698 -574
  54. package/dist/shared/components/item-edit/InlineTableField.js +3 -1
  55. package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
  56. package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
  57. package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
  58. package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
  59. package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
  60. package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
  61. package/dist/shared/components/item-edit/lazy-sections.js +36 -0
  62. package/dist/shared/components/item-edit/lock-why.js +39 -32
  63. package/dist/shared/components/item-edit/picker-miss.js +26 -0
  64. package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
  65. package/dist/shared/components/item-edit/useFormUsageBeacon.js +51 -45
  66. package/dist/shared/components/layout-editor/AddPanel.js +134 -117
  67. package/dist/shared/components/layout-editor/ChangeNote.js +25 -24
  68. package/dist/shared/components/layout-editor/CollabParts.js +80 -75
  69. package/dist/shared/components/layout-editor/DesignNode.js +126 -120
  70. package/dist/shared/components/layout-editor/EditorCanvas.js +30 -27
  71. package/dist/shared/components/layout-editor/EditorTopBar.js +203 -192
  72. package/dist/shared/components/layout-editor/HistoryPanel.js +120 -104
  73. package/dist/shared/components/layout-editor/LayoutEditor.js +768 -671
  74. package/dist/shared/components/layout-editor/RestorePiece.js +143 -0
  75. package/dist/shared/components/layout-editor/StagedChip.js +22 -0
  76. package/dist/shared/components/layout-editor/StructureMenu.js +237 -186
  77. package/dist/shared/components/layout-editor/collab/FormFollowShare.js +149 -103
  78. package/dist/shared/components/layout-editor/collab/collab-api.js +29 -26
  79. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +81 -80
  80. package/dist/shared/components/layout-editor/dnd/node.js +69 -57
  81. package/dist/shared/components/layout-editor/draft-recovery.js +113 -43
  82. package/dist/shared/components/layout-editor/entry/PlacementPresets.js +149 -0
  83. package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
  84. package/dist/shared/components/layout-editor/entry/presets.js +71 -0
  85. package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
  86. package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -0
  87. package/dist/shared/components/layout-editor/grid-guides.js +142 -0
  88. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +402 -0
  89. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +61 -57
  90. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +247 -151
  91. package/dist/shared/components/layout-editor/inspector/Inspector.js +176 -155
  92. package/dist/shared/components/layout-editor/inspector/LookTab.js +167 -116
  93. package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
  94. package/dist/shared/components/layout-editor/inspector/PickerTab.js +84 -82
  95. package/dist/shared/components/layout-editor/inspector/RulesTab.js +66 -62
  96. package/dist/shared/components/layout-editor/inspector/kit.js +69 -68
  97. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +254 -0
  98. package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
  99. package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
  100. package/dist/shared/components/layout-editor/overview/describe-conditions.js +6 -0
  101. package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
  102. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  103. package/dist/shared/components/layout-editor/restore-piece.js +192 -0
  104. package/dist/shared/components/layout-editor/section-structure.js +241 -0
  105. package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
  106. package/dist/shared/components/layout-editor/settings/FormSettings.js +41 -39
  107. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
  108. package/dist/shared/components/layout-editor/settings/ToolsSection.js +147 -111
  109. package/dist/shared/components/layout-editor/settings/WhoSection.js +29 -26
  110. package/dist/shared/components/layout-editor/settings/settings-registry.js +114 -17
  111. package/dist/shared/components/layout-editor/staged-api.js +64 -0
  112. package/dist/shared/components/layout-editor/structure-ops.js +81 -77
  113. package/dist/shared/components/layout-editor/testing/TestingPanels.js +65 -60
  114. package/dist/shared/components/layout-editor/testing/testing-model.js +198 -185
  115. package/dist/shared/components/layout-editor/toolbar-kit.js +11 -11
  116. package/dist/shared/components/layout-editor/usage/AbTestSection.js +355 -0
  117. package/dist/shared/components/layout-editor/usage/UsagePanel.js +144 -70
  118. package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
  119. package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -0
  120. package/dist/shared/components/layout-editor/useLayoutDraft.js +25 -24
  121. package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
  122. package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
  123. package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
  124. package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
  125. package/dist/shared/components/profile/AgentsPanel.js +479 -0
  126. package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
  127. package/dist/shared/components/support/SupportAnalytics.js +171 -0
  128. package/dist/shared/components/support/SupportView.js +75 -73
  129. package/dist/shared/lib/background-runs.js +150 -0
  130. package/dist/shared/lib/delivery-ack.js +9 -0
  131. package/dist/shared/lib/entry-badge-style.js +13 -0
  132. package/dist/shared/lib/entry-config.js +71 -0
  133. package/dist/shared/lib/form-sections.js +64 -0
  134. package/dist/shared/lib/form-structure.js +99 -0
  135. package/dist/shared/lib/form-usage-beacon.js +101 -52
  136. package/dist/shared/lib/jobs-tray.js +25 -23
  137. package/dist/shared/lib/keyset-pager.js +37 -0
  138. package/dist/shared/lib/layout-ops.js +84 -82
  139. package/dist/shared/lib/layout-resolve.js +113 -0
  140. package/dist/shared/lib/placement-behaviour.js +144 -0
  141. package/dist/shared/lib/prefetch.js +149 -0
  142. package/dist/shared/lib/presence-hooks.js +199 -0
  143. package/dist/shared/lib/record-outbox.js +82 -81
  144. package/dist/shared/lib/replay-socket.js +93 -0
  145. package/dist/shared/lib/request-gate.js +51 -50
  146. package/dist/shared/lib/room-gaps.js +96 -0
  147. package/dist/shared/lib/search-log.js +27 -0
  148. package/dist/shared/lib/socket-realtime.js +101 -80
  149. package/dist/shared/lib/worker-socket.js +200 -0
  150. package/package.json +1 -1
@@ -1,123 +1,134 @@
1
- import { jsx as o, Fragment as C, jsxs as m } from "react/jsx-runtime";
2
- import { useQuery as L } from "@tanstack/react-query";
3
- import { X as E, PlayCircle as U, ExternalLink as j, ListChecks as I, LayoutDashboard as M, Gauge as P, Table2 as O, Sparkles as Z } from "lucide-react";
4
- import { useMemo as T, Fragment as g } from "react";
5
- import { useNivaroClient as q, useNavigation as z, useApiFetchConfig as B } from "../../context.js";
6
- import { get as F } from "../../lib/commands.js";
7
- import { cn as b, getDisplayTimezone as W } from "../../lib/utils.js";
8
- import { formatDuration as y } from "../help-videos/viewer/format.js";
9
- import { parseMomentUrl as K } from "../help-videos/viewer/moments.js";
10
- import { splitMessageTokens as V } from "./chat-core.js";
11
- import { useLinkPreview as X } from "./chat-hooks.js";
12
- import { OpsProposalCard as H } from "./OpsProposalCard.js";
13
- const R = /\bhttps?:\/\/[^\s<>()"'`]+[^\s<>()"'`.,;:!?*_~]/gi, S = /`([^`\n]+)`/g, G = new RegExp("(\\*\\*[^*\\n]+?\\*\\*|~~[^~\\n]+?~~|(?<![\\w*])\\*(?!\\s)[^*\\n]+?(?<!\\s)\\*(?![\\w*])|(?<![\\w_])_(?!\\s)[^_\\n]+?(?<!\\s)_(?![\\w_]))", "g");
14
- function D(s) {
1
+ import { jsx as l, Fragment as L, jsxs as m } from "react/jsx-runtime";
2
+ import { useQuery as R } from "@tanstack/react-query";
3
+ import { X as I, PlayCircle as S, ExternalLink as U, ListChecks as M, LayoutDashboard as P, Gauge as O, Database as Z, Table2 as z, Sparkles as V } from "lucide-react";
4
+ import { useMemo as v, Fragment as k } from "react";
5
+ import { useNivaroClient as T, useNavigation as B, useApiFetchConfig as W } from "../../context.js";
6
+ import { get as j } from "../../lib/commands.js";
7
+ import { cn as g, getDisplayTimezone as K } from "../../lib/utils.js";
8
+ import { formatDuration as N } from "../help-videos/viewer/format.js";
9
+ import { parseMomentUrl as X } from "../help-videos/viewer/moments.js";
10
+ import { splitMessageTokens as H } from "./chat-core.js";
11
+ import { useEmojiUrls as G, withCustomEmoji as Q } from "./chat-emoji.js";
12
+ import { useLinkPreview as J } from "./chat-hooks.js";
13
+ import { useNearViewport as Y } from "./chat-window.js";
14
+ import { OpsProposalCard as ee } from "./OpsProposalCard.js";
15
+ import { extractRequestIds as te, RequestIdCard as re, RequestCardView as se } from "./RequestIdCard.js";
16
+ const E = /\bhttps?:\/\/[^\s<>()"'`]+[^\s<>()"'`.,;:!?*_~]/gi, D = /`([^`\n]+)`/g, ne = new RegExp("(\\*\\*[^*\\n]+?\\*\\*|~~[^~\\n]+?~~|(?<![\\w*])\\*(?!\\s)[^*\\n]+?(?<!\\s)\\*(?![\\w*])|(?<![\\w_])_(?!\\s)[^_\\n]+?(?<!\\s)_(?![\\w_]))", "g");
17
+ function F(s) {
15
18
  if (s.startsWith("/")) return s;
16
19
  try {
17
20
  if (typeof window > "u") return null;
18
- const e = new URL(s);
19
- if (e.origin === window.location.origin) return `${e.pathname}${e.search}${e.hash}`;
21
+ const t = new URL(s);
22
+ if (t.origin === window.location.origin) return `${t.pathname}${t.search}${t.hash}`;
20
23
  } catch {
21
24
  return null;
22
25
  }
23
26
  return null;
24
27
  }
25
- function Q(s) {
26
- const e = [], c = s.replace(/```[\s\S]*?```/g, " ").replace(S, " ");
27
- for (const t of c.matchAll(R)) e.includes(t[0]) || e.push(t[0]);
28
- return e;
28
+ function ae(s) {
29
+ const t = [], o = s.replace(/```[\s\S]*?```/g, " ").replace(D, " ");
30
+ for (const e of o.matchAll(E)) t.includes(e[0]) || t.push(e[0]);
31
+ return t;
29
32
  }
30
- function J({ text: s, at: e, mine: c }) {
31
- const t = new Date(e), l = W() ?? Intl.DateTimeFormat().resolvedOptions().timeZone;
32
- let n = s, i = "";
33
+ function le({ text: s, at: t, mine: o }) {
34
+ const e = new Date(t), i = K() ?? Intl.DateTimeFormat().resolvedOptions().timeZone;
35
+ let a = s, c = "";
33
36
  try {
34
- const a = /* @__PURE__ */ new Date(), r = (p) => new Intl.DateTimeFormat("en-CA", { timeZone: l, dateStyle: "short" }).format(p), d = new Date(a.getTime() + 864e5), h = new Intl.DateTimeFormat("en-US", {
35
- timeZone: l,
37
+ const n = /* @__PURE__ */ new Date(), r = (h) => new Intl.DateTimeFormat("en-CA", { timeZone: i, dateStyle: "short" }).format(h), d = new Date(n.getTime() + 864e5), f = new Intl.DateTimeFormat("en-US", {
38
+ timeZone: i,
36
39
  hour: "numeric",
37
40
  minute: "2-digit"
38
- }).format(t), u = r(t) === r(a) ? "today" : r(t) === r(d) ? "tomorrow" : new Intl.DateTimeFormat("en-US", {
39
- timeZone: l,
41
+ }).format(e), p = r(e) === r(n) ? "today" : r(e) === r(d) ? "tomorrow" : new Intl.DateTimeFormat("en-US", {
42
+ timeZone: i,
40
43
  weekday: "short",
41
44
  month: "short",
42
45
  day: "numeric"
43
- }).format(t);
44
- n = `${h} ${u}`, i = new Intl.DateTimeFormat("en-US", {
45
- timeZone: l,
46
+ }).format(e);
47
+ a = `${f} ${p}`, c = new Intl.DateTimeFormat("en-US", {
48
+ timeZone: i,
46
49
  weekday: "long",
47
50
  month: "long",
48
51
  day: "numeric",
49
52
  hour: "numeric",
50
53
  minute: "2-digit",
51
54
  timeZoneName: "short"
52
- }).format(t);
55
+ }).format(e);
53
56
  } catch {
54
57
  }
55
58
  return /* @__PURE__ */ m(
56
59
  "span",
57
60
  {
58
- className: b(
61
+ className: g(
59
62
  "inline-flex items-center gap-1 rounded px-1 font-medium",
60
- c ? "bg-black/15" : "bg-slate-200/70 text-slate-800 dark:bg-white/10 dark:text-slate-100"
63
+ o ? "bg-black/15" : "bg-slate-200/70 text-slate-800 dark:bg-white/10 dark:text-slate-100"
61
64
  ),
62
- title: `“${s}” — ${i} (your time)`,
65
+ title: `“${s}” — ${c} (your time)`,
63
66
  "data-chat-time-chip": !0,
64
67
  children: [
65
- /* @__PURE__ */ o("span", { "aria-hidden": !0, children: "🕒" }),
66
- n
68
+ /* @__PURE__ */ l("span", { "aria-hidden": !0, children: "🕒" }),
69
+ a
67
70
  ]
68
71
  }
69
72
  );
70
73
  }
71
- function w(s, e, c) {
72
- const t = [], l = e.timeRefs.filter((a) => a.text && s.includes(a.text));
73
- if (l.length === 0)
74
- return V(s, e.entityPattern).forEach(
75
- (a, r) => t.push(/* @__PURE__ */ o(g, { children: e.renderToken(a, `${c}.${r}`) }, `${c}.${r}`))
76
- ), t;
77
- let n = s, i = 0;
78
- for (; n.length; ) {
79
- let a = null;
80
- for (const r of l) {
81
- const d = n.indexOf(r.text);
82
- d >= 0 && (!a || d < a.idx) && (a = { idx: d, ref: r });
74
+ function w(s, t, o) {
75
+ const e = [];
76
+ if (t.emoji && t.emoji.size > 0 && s.includes(":")) {
77
+ const n = Q(s, t.emoji, o);
78
+ if (n.length > 1 || typeof n[0] != "string")
79
+ return n.forEach(
80
+ (r, d) => typeof r == "string" ? e.push(...w(r, { ...t, emoji: void 0 }, `${o}.m${d}`)) : e.push(r)
81
+ ), e;
82
+ }
83
+ const i = t.timeRefs.filter((n) => n.text && s.includes(n.text));
84
+ if (i.length === 0)
85
+ return H(s, t.entityPattern).forEach(
86
+ (n, r) => e.push(/* @__PURE__ */ l(k, { children: t.renderToken(n, `${o}.${r}`) }, `${o}.${r}`))
87
+ ), e;
88
+ let a = s, c = 0;
89
+ for (; a.length; ) {
90
+ let n = null;
91
+ for (const r of i) {
92
+ const d = a.indexOf(r.text);
93
+ d >= 0 && (!n || d < n.idx) && (n = { idx: d, ref: r });
83
94
  }
84
- if (!a) {
85
- t.push(...w(n, { ...e, timeRefs: [] }, `${c}.t${i++}`));
95
+ if (!n) {
96
+ e.push(...w(a, { ...t, timeRefs: [] }, `${o}.t${c++}`));
86
97
  break;
87
98
  }
88
- a.idx > 0 && t.push(...w(n.slice(0, a.idx), { ...e, timeRefs: [] }, `${c}.t${i++}`)), t.push(
89
- /* @__PURE__ */ o(J, { text: a.ref.text, at: a.ref.at, mine: e.mine }, `${c}.c${i++}`)
90
- ), n = n.slice(a.idx + a.ref.text.length);
99
+ n.idx > 0 && e.push(...w(a.slice(0, n.idx), { ...t, timeRefs: [] }, `${o}.t${c++}`)), e.push(
100
+ /* @__PURE__ */ l(le, { text: n.ref.text, at: n.ref.at, mine: t.mine }, `${o}.c${c++}`)
101
+ ), a = a.slice(n.idx + n.ref.text.length);
91
102
  }
92
- return t;
103
+ return e;
93
104
  }
94
- function x(s, e, c) {
95
- const t = [];
96
- let l = 0, n = 0;
97
- for (const i of s.matchAll(G)) {
98
- const a = i.index ?? 0;
99
- a > l && t.push(...w(s.slice(l, a), e, `${c}.p${n}`));
100
- const r = i[0], d = `${c}.e${n++}`;
101
- r.startsWith("**") ? t.push(/* @__PURE__ */ o("strong", { children: x(r.slice(2, -2), e, d) }, d)) : r.startsWith("~~") ? t.push(/* @__PURE__ */ o("s", { children: x(r.slice(2, -2), e, d) }, d)) : t.push(/* @__PURE__ */ o("em", { children: x(r.slice(1, -1), e, d) }, d)), l = a + r.length;
105
+ function x(s, t, o) {
106
+ const e = [];
107
+ let i = 0, a = 0;
108
+ for (const c of s.matchAll(ne)) {
109
+ const n = c.index ?? 0;
110
+ n > i && e.push(...w(s.slice(i, n), t, `${o}.p${a}`));
111
+ const r = c[0], d = `${o}.e${a++}`;
112
+ r.startsWith("**") ? e.push(/* @__PURE__ */ l("strong", { children: x(r.slice(2, -2), t, d) }, d)) : r.startsWith("~~") ? e.push(/* @__PURE__ */ l("s", { children: x(r.slice(2, -2), t, d) }, d)) : e.push(/* @__PURE__ */ l("em", { children: x(r.slice(1, -1), t, d) }, d)), i = n + r.length;
102
113
  }
103
- return l < s.length && t.push(...w(s.slice(l), e, `${c}.z`)), t;
114
+ return i < s.length && e.push(...w(s.slice(i), t, `${o}.z`)), e;
104
115
  }
105
- function v(s, e, c) {
106
- const t = [];
107
- let l = 0, n = 0;
108
- for (const i of s.matchAll(R)) {
109
- const a = i.index ?? 0;
110
- a > l && t.push(...x(s.slice(l, a), e, `${c}.u${n}`));
111
- const r = i[0], d = D(r), h = `${c}.l${n++}`;
112
- t.push(
116
+ function C(s, t, o) {
117
+ const e = [];
118
+ let i = 0, a = 0;
119
+ for (const c of s.matchAll(E)) {
120
+ const n = c.index ?? 0;
121
+ n > i && e.push(...x(s.slice(i, n), t, `${o}.u${a}`));
122
+ const r = c[0], d = F(r), f = `${o}.l${a++}`;
123
+ e.push(
113
124
  /* @__PURE__ */ m(
114
125
  "a",
115
126
  {
116
127
  href: r,
117
128
  target: d ? void 0 : "_blank",
118
129
  rel: "noopener noreferrer",
119
- onClick: (u) => {
120
- d && e.navigate && (u.preventDefault(), e.navigate(d));
130
+ onClick: (p) => {
131
+ d && t.navigate && (p.preventDefault(), t.navigate(d));
121
132
  },
122
133
  className: "break-all underline underline-offset-2 hover:opacity-80",
123
134
  "data-chat-link": !0,
@@ -126,314 +137,328 @@ function v(s, e, c) {
126
137
  r.length > 90 ? "…" : ""
127
138
  ]
128
139
  },
129
- h
140
+ f
130
141
  )
131
- ), l = a + r.length;
142
+ ), i = n + r.length;
132
143
  }
133
- return l < s.length && t.push(...x(s.slice(l), e, `${c}.y`)), t;
144
+ return i < s.length && e.push(...x(s.slice(i), t, `${o}.y`)), e;
134
145
  }
135
- function f(s, e, c) {
136
- const t = [];
137
- let l = 0, n = 0;
138
- for (const i of s.matchAll(S)) {
139
- const a = i.index ?? 0;
140
- a > l && t.push(...v(s.slice(l, a), e, `${c}.s${n}`)), t.push(
141
- /* @__PURE__ */ o(
146
+ function b(s, t, o) {
147
+ const e = [];
148
+ let i = 0, a = 0;
149
+ for (const c of s.matchAll(D)) {
150
+ const n = c.index ?? 0;
151
+ n > i && e.push(...C(s.slice(i, n), t, `${o}.s${a}`)), e.push(
152
+ /* @__PURE__ */ l(
142
153
  "code",
143
154
  {
144
- className: b(
155
+ className: g(
145
156
  "rounded px-1 py-px font-mono text-[11.5px]",
146
- e.mine ? "bg-black/20" : "bg-slate-200/80 dark:bg-white/10"
157
+ t.mine ? "bg-black/20" : "bg-slate-200/80 dark:bg-white/10"
147
158
  ),
148
- children: i[1]
159
+ children: c[1]
149
160
  },
150
- `${c}.c${n++}`
161
+ `${o}.c${a++}`
151
162
  )
152
- ), l = a + i[0].length;
163
+ ), i = n + c[0].length;
153
164
  }
154
- return l < s.length && t.push(...v(s.slice(l), e, `${c}.x`)), t;
165
+ return i < s.length && e.push(...C(s.slice(i), t, `${o}.x`)), e;
155
166
  }
156
- const k = 25, N = 10;
157
- function _(s) {
158
- return s.trim().replace(/^\|/, "").replace(/\|$/, "").split("|").map((e) => e.trim());
167
+ const $ = 25, _ = 10;
168
+ function q(s) {
169
+ return s.trim().replace(/^\|/, "").replace(/\|$/, "").split("|").map((t) => t.trim());
159
170
  }
160
- function Y(s) {
161
- const e = s.replace(/\r\n?/g, `
171
+ function oe(s) {
172
+ const t = s.replace(/\r\n?/g, `
162
173
  `).split(`
163
- `), c = [];
164
- let t = [];
165
- const l = () => {
166
- t.length && c.push({ t: "p", lines: t }), t = [];
174
+ `), o = [];
175
+ let e = [];
176
+ const i = () => {
177
+ e.length && o.push({ t: "p", lines: e }), e = [];
167
178
  };
168
- for (let n = 0; n < e.length; n++) {
169
- const i = e[n];
170
- if (/^```/.test(i.trim())) {
171
- l();
179
+ for (let a = 0; a < t.length; a++) {
180
+ const c = t[a];
181
+ if (/^```/.test(c.trim())) {
182
+ i();
172
183
  const r = [];
173
- for (n++; n < e.length && !/^```/.test(e[n].trim()); ) r.push(e[n++]);
174
- c.push({ t: "code", text: r.join(`
184
+ for (a++; a < t.length && !/^```/.test(t[a].trim()); ) r.push(t[a++]);
185
+ o.push({ t: "code", text: r.join(`
175
186
  `) });
176
187
  continue;
177
188
  }
178
- if (/^\s*\|.*\|\s*$/.test(i) && n + 1 < e.length && /^\s*\|?\s*:?-{2,}/.test(e[n + 1])) {
179
- l();
180
- const r = _(i).slice(0, N), d = [];
181
- for (n += 2; n < e.length && /^\s*\|.*\|\s*$/.test(e[n]); )
182
- d.length < k && d.push(_(e[n]).slice(0, N)), n++;
183
- n--, c.push({ t: "table", head: r, rows: d });
189
+ if (/^\s*\|.*\|\s*$/.test(c) && a + 1 < t.length && /^\s*\|?\s*:?-{2,}/.test(t[a + 1])) {
190
+ i();
191
+ const r = q(c).slice(0, _), d = [];
192
+ for (a += 2; a < t.length && /^\s*\|.*\|\s*$/.test(t[a]); )
193
+ d.length < $ && d.push(q(t[a]).slice(0, _)), a++;
194
+ a--, o.push({ t: "table", head: r, rows: d });
184
195
  continue;
185
196
  }
186
- if (/^>\s?/.test(i)) {
187
- l();
197
+ if (/^>\s?/.test(c)) {
198
+ i();
188
199
  const r = [];
189
- for (; n < e.length && /^>\s?/.test(e[n]); ) r.push(e[n++].replace(/^>\s?/, ""));
190
- n--, c.push({ t: "quote", lines: r });
200
+ for (; a < t.length && /^>\s?/.test(t[a]); ) r.push(t[a++].replace(/^>\s?/, ""));
201
+ a--, o.push({ t: "quote", lines: r });
191
202
  continue;
192
203
  }
193
- if (/^\s*[-*•]\s+/.test(i)) {
194
- l();
204
+ if (/^\s*[-*•]\s+/.test(c)) {
205
+ i();
195
206
  const r = [];
196
- for (; n < e.length && /^\s*[-*•]\s+/.test(e[n]); )
197
- r.push(e[n++].replace(/^\s*[-*•]\s+/, ""));
198
- n--, c.push({ t: "ul", items: r });
207
+ for (; a < t.length && /^\s*[-*•]\s+/.test(t[a]); )
208
+ r.push(t[a++].replace(/^\s*[-*•]\s+/, ""));
209
+ a--, o.push({ t: "ul", items: r });
199
210
  continue;
200
211
  }
201
- const a = i.match(/^\s*(\d{1,3})[.)]\s+/);
202
- if (a) {
203
- l();
212
+ const n = c.match(/^\s*(\d{1,3})[.)]\s+/);
213
+ if (n) {
214
+ i();
204
215
  const r = [];
205
- for (; n < e.length && /^\s*\d{1,3}[.)]\s+/.test(e[n]); )
206
- r.push(e[n++].replace(/^\s*\d{1,3}[.)]\s+/, ""));
207
- n--, c.push({ t: "ol", items: r, start: Number(a[1]) });
216
+ for (; a < t.length && /^\s*\d{1,3}[.)]\s+/.test(t[a]); )
217
+ r.push(t[a++].replace(/^\s*\d{1,3}[.)]\s+/, ""));
218
+ a--, o.push({ t: "ol", items: r, start: Number(n[1]) });
208
219
  continue;
209
220
  }
210
- if (i.trim() === "") {
211
- l();
221
+ if (c.trim() === "") {
222
+ i();
212
223
  continue;
213
224
  }
214
- t.push(i);
225
+ e.push(c);
215
226
  }
216
- return l(), c;
227
+ return i(), o;
217
228
  }
218
- function be({
229
+ function qe({
219
230
  text: s,
220
- mine: e,
221
- renderToken: c,
222
- entityPattern: t,
223
- timeRefs: l,
224
- navigate: n
231
+ mine: t,
232
+ renderToken: o,
233
+ entityPattern: e,
234
+ timeRefs: i,
235
+ navigate: a
225
236
  }) {
226
- const i = T(() => Y(s), [s]), a = { mine: e, renderToken: c, entityPattern: t, timeRefs: l ?? [], navigate: n };
227
- if (i.length === 1 && i[0].t === "p") {
228
- const r = i[0];
229
- return /* @__PURE__ */ o(C, { children: r.lines.map((d, h) => /* @__PURE__ */ m(g, { children: [
230
- h > 0 && /* @__PURE__ */ o("br", {}),
231
- f(d, a, `l${h}`)
232
- ] }, h)) });
237
+ const c = v(() => oe(s), [s]), r = { emoji: G(), mine: t, renderToken: o, entityPattern: e, timeRefs: i ?? [], navigate: a };
238
+ if (c.length === 1 && c[0].t === "p") {
239
+ const d = c[0];
240
+ return /* @__PURE__ */ l(L, { children: d.lines.map((f, p) => /* @__PURE__ */ m(k, { children: [
241
+ p > 0 && /* @__PURE__ */ l("br", {}),
242
+ b(f, r, `l${p}`)
243
+ ] }, p)) });
233
244
  }
234
- return /* @__PURE__ */ o("div", { className: "space-y-1.5", "data-chat-formatted": !0, children: i.map((r, d) => {
235
- const h = `b${d}`;
236
- switch (r.t) {
245
+ return /* @__PURE__ */ l("div", { className: "space-y-1.5", "data-chat-formatted": !0, children: c.map((d, f) => {
246
+ const p = `b${f}`;
247
+ switch (d.t) {
237
248
  case "p":
238
- return /* @__PURE__ */ o("p", { children: r.lines.map((u, p) => /* @__PURE__ */ m(g, { children: [
239
- p > 0 && /* @__PURE__ */ o("br", {}),
240
- f(u, a, `${h}.${p}`)
241
- ] }, p)) }, h);
249
+ return /* @__PURE__ */ l("p", { children: d.lines.map((h, u) => /* @__PURE__ */ m(k, { children: [
250
+ u > 0 && /* @__PURE__ */ l("br", {}),
251
+ b(h, r, `${p}.${u}`)
252
+ ] }, u)) }, p);
242
253
  case "code":
243
- return /* @__PURE__ */ o(
254
+ return /* @__PURE__ */ l(
244
255
  "pre",
245
256
  {
246
- className: b(
257
+ className: g(
247
258
  "max-w-full overflow-x-auto whitespace-pre rounded-md px-2 py-1.5 font-mono text-[11.5px] leading-snug",
248
- e ? "bg-black/20" : "bg-slate-200/80 dark:bg-black/30"
259
+ t ? "bg-black/20" : "bg-slate-200/80 dark:bg-black/30"
249
260
  ),
250
- children: r.text
261
+ children: d.text
251
262
  },
252
- h
263
+ p
253
264
  );
254
265
  case "quote":
255
- return /* @__PURE__ */ o(
266
+ return /* @__PURE__ */ l(
256
267
  "blockquote",
257
268
  {
258
- className: b(
269
+ className: g(
259
270
  "border-l-2 pl-2",
260
- e ? "border-white/60" : "border-slate-300 text-slate-600 dark:border-slate-500 dark:text-slate-300"
271
+ t ? "border-white/60" : "border-slate-300 text-slate-600 dark:border-slate-500 dark:text-slate-300"
261
272
  ),
262
- children: r.lines.map((u, p) => /* @__PURE__ */ m(g, { children: [
263
- p > 0 && /* @__PURE__ */ o("br", {}),
264
- f(u, a, `${h}.${p}`)
265
- ] }, p))
273
+ children: d.lines.map((h, u) => /* @__PURE__ */ m(k, { children: [
274
+ u > 0 && /* @__PURE__ */ l("br", {}),
275
+ b(h, r, `${p}.${u}`)
276
+ ] }, u))
266
277
  },
267
- h
278
+ p
268
279
  );
269
280
  case "ul":
270
- return /* @__PURE__ */ o("ul", { className: "list-disc space-y-0.5 pl-4", children: r.items.map((u, p) => /* @__PURE__ */ o("li", { children: f(u, a, `${h}.${p}`) }, p)) }, h);
281
+ return /* @__PURE__ */ l("ul", { className: "list-disc space-y-0.5 pl-4", children: d.items.map((h, u) => /* @__PURE__ */ l("li", { children: b(h, r, `${p}.${u}`) }, u)) }, p);
271
282
  case "ol":
272
- return /* @__PURE__ */ o("ol", { start: r.start, className: "list-decimal space-y-0.5 pl-5", children: r.items.map((u, p) => /* @__PURE__ */ o("li", { children: f(u, a, `${h}.${p}`) }, p)) }, h);
283
+ return /* @__PURE__ */ l("ol", { start: d.start, className: "list-decimal space-y-0.5 pl-5", children: d.items.map((h, u) => /* @__PURE__ */ l("li", { children: b(h, r, `${p}.${u}`) }, u)) }, p);
273
284
  case "table":
274
- return /* @__PURE__ */ o("div", { className: "max-w-full overflow-x-auto", "data-chat-table": !0, children: /* @__PURE__ */ m("table", { className: "border-collapse text-[11.5px] tabular-nums", children: [
275
- /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ o("tr", { children: r.head.map((u, p) => /* @__PURE__ */ o(
285
+ return /* @__PURE__ */ l("div", { className: "max-w-full overflow-x-auto", "data-chat-table": !0, children: /* @__PURE__ */ m("table", { className: "border-collapse text-[11.5px] tabular-nums", children: [
286
+ /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ l("tr", { children: d.head.map((h, u) => /* @__PURE__ */ l(
276
287
  "th",
277
288
  {
278
- className: b(
289
+ className: g(
279
290
  "border px-1.5 py-0.5 text-left font-semibold",
280
- e ? "border-white/30" : "border-slate-300 dark:border-slate-600"
291
+ t ? "border-white/30" : "border-slate-300 dark:border-slate-600"
281
292
  ),
282
- children: f(u, a, `${h}.h${p}`)
293
+ children: b(h, r, `${p}.h${u}`)
283
294
  },
284
- p
295
+ u
285
296
  )) }) }),
286
- /* @__PURE__ */ o("tbody", { children: r.rows.map((u, p) => /* @__PURE__ */ o("tr", { children: r.head.map((se, $) => /* @__PURE__ */ o(
297
+ /* @__PURE__ */ l("tbody", { children: d.rows.map((h, u) => /* @__PURE__ */ l("tr", { children: d.head.map((pe, y) => /* @__PURE__ */ l(
287
298
  "td",
288
299
  {
289
- className: b(
300
+ className: g(
290
301
  "border px-1.5 py-0.5 align-top",
291
- e ? "border-white/30" : "border-slate-300 dark:border-slate-600"
302
+ t ? "border-white/30" : "border-slate-300 dark:border-slate-600"
292
303
  ),
293
- children: f(u[$] ?? "", a, `${h}.${p}.${$}`)
304
+ children: b(h[y] ?? "", r, `${p}.${u}.${y}`)
294
305
  },
295
- $
296
- )) }, p)) })
297
- ] }) }, h);
306
+ y
307
+ )) }, u)) })
308
+ ] }) }, p);
298
309
  }
299
310
  }) });
300
311
  }
301
- function xe(s) {
302
- const e = s.replace(/\r\n?/g, `
312
+ function Ae(s) {
313
+ const t = s.replace(/\r\n?/g, `
303
314
  `).replace(/\n+$/, "").split(`
304
315
  `);
305
- if (e.length < 2 || !e.every((i) => i.includes(" "))) return null;
306
- const c = e.slice(0, k + 1).map(
307
- (i) => i.split(" ").slice(0, N).map((a) => a.replace(/\|/g, "/").trim())
308
- ), t = Math.max(...c.map((i) => i.length));
309
- if (t < 2) return null;
310
- const l = (i) => `| ${Array.from({ length: t }, (a, r) => i[r] ?? "").join(" | ")} |`, n = [l(c[0]), `| ${Array.from({ length: t }, () => "---").join(" | ")} |`];
311
- for (const i of c.slice(1)) n.push(l(i));
312
- return e.length > k + 1 && n.push(`
313
- _…${e.length - k - 1} more rows_`), n.join(`
316
+ if (t.length < 2 || !t.every((c) => c.includes(" "))) return null;
317
+ const o = t.slice(0, $ + 1).map(
318
+ (c) => c.split(" ").slice(0, _).map((n) => n.replace(/\|/g, "/").trim())
319
+ ), e = Math.max(...o.map((c) => c.length));
320
+ if (e < 2) return null;
321
+ const i = (c) => `| ${Array.from({ length: e }, (n, r) => c[r] ?? "").join(" | ")} |`, a = [i(o[0]), `| ${Array.from({ length: e }, () => "---").join(" | ")} |`];
322
+ for (const c of o.slice(1)) a.push(i(c));
323
+ return t.length > $ + 1 && a.push(`
324
+ _…${t.length - $ - 1} more rows_`), a.join(`
314
325
  `);
315
326
  }
316
- function ee({
327
+ function ie({
317
328
  data: s,
318
- path: e,
319
- navigate: c
329
+ path: t,
330
+ navigate: o
320
331
  }) {
321
332
  return /* @__PURE__ */ m(
322
333
  "button",
323
334
  {
324
335
  type: "button",
325
- onClick: () => c == null ? void 0 : c(e),
336
+ onClick: () => o == null ? void 0 : o(t),
326
337
  className: "block w-full max-w-[360px] rounded-lg border border-slate-200 bg-white px-2.5 py-2 text-left text-slate-700 hover:border-slate-300 dark:border-border dark:bg-card dark:text-slate-200",
327
338
  "data-chat-app-card": "ask",
328
339
  children: [
329
340
  /* @__PURE__ */ m("span", { className: "flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: [
330
- /* @__PURE__ */ o(Z, { className: "h-3 w-3" }),
341
+ /* @__PURE__ */ l(V, { className: "h-3 w-3" }),
331
342
  " Ask AI · ",
332
343
  s.owner_name,
333
344
  (s.turns ?? 0) > 1 && ` · ${s.turns} questions`
334
345
  ] }),
335
- /* @__PURE__ */ o("span", { className: "mt-0.5 block line-clamp-2 text-[12.5px] font-medium", children: s.question ?? s.name }),
336
- s.answer ? /* @__PURE__ */ o("span", { className: "mt-0.5 block line-clamp-3 text-[11.5px] text-slate-600 dark:text-slate-300", children: s.answer }) : s.answer_hidden ? /* @__PURE__ */ m("span", { className: "mt-0.5 block text-[11px] italic text-slate-500 dark:text-slate-400", children: [
346
+ /* @__PURE__ */ l("span", { className: "mt-0.5 block line-clamp-2 text-[12.5px] font-medium", children: s.question ?? s.name }),
347
+ s.answer ? /* @__PURE__ */ l("span", { className: "mt-0.5 block line-clamp-3 text-[11.5px] text-slate-600 dark:text-slate-300", children: s.answer }) : s.answer_hidden ? /* @__PURE__ */ m("span", { className: "mt-0.5 block text-[11px] italic text-slate-500 dark:text-slate-400", children: [
337
348
  "Answered with ",
338
349
  s.owner_name,
339
350
  "’s access — open it to get the answer with yours."
340
351
  ] }) : null,
341
- /* @__PURE__ */ o("span", { className: "mt-1 block text-[11px] font-medium text-nvr-navy dark:text-nvr-cyan", children: "Open conversation" })
352
+ /* @__PURE__ */ l("span", { className: "mt-1 block text-[11px] font-medium text-nvr-navy dark:text-nvr-cyan", children: "Open conversation" })
342
353
  ]
343
354
  }
344
355
  );
345
356
  }
346
- function te({ path: s, navigate: e }) {
347
- const c = q(), { data: t } = L({
357
+ function ce({ path: s, navigate: t }) {
358
+ const o = T(), { data: e } = R({
348
359
  queryKey: ["nvr-chat-app-card", s],
349
- queryFn: () => c.request(F("/chat/app-card", { path: s })).then((r) => r.data ?? null),
360
+ queryFn: () => o.request(j("/chat/app-card", { path: s })).then((r) => r.data ?? null),
350
361
  staleTime: 6e4,
351
362
  retry: !1
352
363
  });
353
- if (!t) return null;
354
- if (t.kind === "ops-proposal")
355
- return /* @__PURE__ */ o(H, { path: s, card: t });
356
- if (t.kind === "ask")
357
- return /* @__PURE__ */ o(ee, { data: t, path: s, navigate: e });
358
- const l = t.kind === "queue" ? I : t.kind === "dashboard" ? M : t.kind === "report" ? P : O, n = t.kind === "record" ? t.label ?? t.id : t.name ?? t.id, i = t.kind === "record" ? t.collection_label ?? "Record" : t.kind === "view" ? "Saved view" : t.kind.charAt(0).toUpperCase() + t.kind.slice(1), a = [];
359
- return t.total != null && a.push(`${t.total.toLocaleString()} ${t.total === 1 ? "item" : "items"}`), t.breached && a.push(`${t.breached} past SLA`), t.widgets != null && a.push(`${t.widgets} ${t.widgets === 1 ? "widget" : "widgets"}`), /* @__PURE__ */ m(
364
+ if (!e) return null;
365
+ if (e.kind === "ops-proposal")
366
+ return /* @__PURE__ */ l(ee, { path: s, card: e });
367
+ if (e.kind === "ask")
368
+ return /* @__PURE__ */ l(ie, { data: e, path: s, navigate: t });
369
+ if (e.kind === "request")
370
+ return /* @__PURE__ */ l(se, { card: e, navigate: t });
371
+ const i = e.kind === "queue" ? M : e.kind === "dashboard" ? P : e.kind === "report" ? O : e.kind === "custom-query" ? Z : z, a = e.kind === "record" ? e.label ?? e.id : e.name ?? e.id, c = e.kind === "record" ? e.collection_label ?? "Record" : e.kind === "view" ? `Saved view${e.collection_label ? ` of ${e.collection_label}` : ""}` : e.kind === "custom-query" ? "Custom query" : e.kind.charAt(0).toUpperCase() + e.kind.slice(1), n = [];
372
+ return e.widgets != null && n.push(`${e.widgets} ${e.widgets === 1 ? "widget" : "widgets"}`), e.sources && n.push(`${e.sources} ${e.sources === 1 ? "source" : "sources"}`), e.kind === "custom-query" && e.params != null && n.push(
373
+ e.params === 0 ? "No parameters" : `${e.params} ${e.params === 1 ? "parameter" : "parameters"}`
374
+ ), /* @__PURE__ */ m(
360
375
  "button",
361
376
  {
362
377
  type: "button",
363
- onClick: () => e == null ? void 0 : e(s),
378
+ onClick: () => t == null ? void 0 : t(s),
364
379
  className: "flex w-full max-w-[320px] items-center gap-2 rounded-lg border border-slate-200 bg-white px-2.5 py-1.5 text-left text-slate-700 hover:border-slate-300 dark:border-border dark:bg-card dark:text-slate-200",
365
- "data-chat-app-card": t.kind,
380
+ "data-chat-app-card": e.kind,
366
381
  children: [
367
- /* @__PURE__ */ o(l, { className: "h-4 w-4 shrink-0 text-slate-400" }),
382
+ /* @__PURE__ */ l(i, { className: "h-4 w-4 shrink-0 text-slate-400" }),
368
383
  /* @__PURE__ */ m("span", { className: "min-w-0 flex-1", children: [
369
- /* @__PURE__ */ o("span", { className: "block text-[10px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: i }),
370
- /* @__PURE__ */ o("span", { className: "block truncate text-[12px] font-medium", children: n }),
371
- a.length > 0 && /* @__PURE__ */ o("span", { className: "block text-[11px] text-slate-500 dark:text-slate-400", children: a.join(" · ") })
384
+ /* @__PURE__ */ m("span", { className: "block truncate text-[11px] text-slate-500 dark:text-slate-400", children: [
385
+ c,
386
+ n.length > 0 && ` · ${n.join(" · ")}`
387
+ ] }),
388
+ /* @__PURE__ */ l("span", { className: "block truncate text-[12px] font-medium", children: a }),
389
+ e.description && /* @__PURE__ */ l(
390
+ "span",
391
+ {
392
+ className: "line-clamp-2 text-[11px] text-slate-600 dark:text-slate-300",
393
+ "data-chat-app-card-description": !0,
394
+ children: e.description
395
+ }
396
+ )
372
397
  ] }),
373
- t.state && /* @__PURE__ */ o(
398
+ e.state && /* @__PURE__ */ l(
374
399
  "span",
375
400
  {
376
401
  className: "shrink-0 rounded-full px-1.5 py-px text-[10px] font-semibold",
377
402
  style: {
378
- backgroundColor: t.state.color ? `${t.state.color}26` : "rgba(100,116,139,.15)",
379
- color: t.state.color ?? void 0
403
+ backgroundColor: e.state.color ? `${e.state.color}26` : "rgba(100,116,139,.15)",
404
+ color: e.state.color ?? void 0
380
405
  },
381
- children: t.state.label
406
+ children: e.state.label
382
407
  }
383
408
  )
384
409
  ]
385
410
  }
386
411
  );
387
412
  }
388
- function re({
413
+ function de({
389
414
  search: s,
390
- navigate: e,
391
- fallback: c
415
+ navigate: t,
416
+ fallback: o
392
417
  }) {
393
- const t = q(), l = z(), { apiBase: n } = B(), i = n.replace(/\/api$/, ""), a = `${l.helpVideosPath ?? "/help-videos"}${s}`, { data: r, isFetched: d } = L({
394
- queryKey: ["nvr-chat-app-card", a],
395
- queryFn: () => t.request(F("/chat/app-card", { path: a })).then((u) => {
396
- var p;
397
- return ((p = u.data) == null ? void 0 : p.kind) === "help-video" ? u.data : null;
418
+ const e = T(), i = B(), { apiBase: a } = W(), c = a.replace(/\/api$/, ""), n = `${i.helpVideosPath ?? "/help-videos"}${s}`, { data: r, isFetched: d } = R({
419
+ queryKey: ["nvr-chat-app-card", n],
420
+ queryFn: () => e.request(j("/chat/app-card", { path: n })).then((p) => {
421
+ var h;
422
+ return ((h = p.data) == null ? void 0 : h.kind) === "help-video" ? p.data : null;
398
423
  }),
399
424
  staleTime: 6e4,
400
425
  retry: !1
401
426
  });
402
- if (!r) return d ? /* @__PURE__ */ o(C, { children: c }) : null;
403
- const h = r.chapter != null ? `Starts at ${r.chapter.title} (${y(r.start_ms)})` : r.start_ms >= 1e3 ? `Starts at ${y(r.start_ms)}` : null;
427
+ if (!r) return d ? /* @__PURE__ */ l(L, { children: o }) : null;
428
+ const f = r.chapter != null ? `Starts at ${r.chapter.title} (${N(r.start_ms)})` : r.start_ms >= 1e3 ? `Starts at ${N(r.start_ms)}` : null;
404
429
  return /* @__PURE__ */ m(
405
430
  "button",
406
431
  {
407
432
  type: "button",
408
- onClick: () => e ? e(a) : l.navigate(a),
433
+ onClick: () => t ? t(n) : i.navigate(n),
409
434
  className: "flex w-full max-w-[320px] items-center gap-2.5 rounded-lg border border-slate-200 bg-white p-1.5 pr-2.5 text-left text-slate-700 hover:border-slate-300 dark:border-border dark:bg-card dark:text-slate-200",
410
435
  "data-chat-app-card": "help-video",
411
436
  "data-chat-help-video": r.id,
412
437
  children: [
413
438
  /* @__PURE__ */ m("span", { className: "relative h-12 w-20 shrink-0 overflow-hidden rounded bg-[#0b0f17]", children: [
414
- r.poster_url && /* @__PURE__ */ o(
439
+ r.poster_url && /* @__PURE__ */ l(
415
440
  "img",
416
441
  {
417
- src: `${i}${r.poster_url}`,
442
+ src: `${c}${r.poster_url}`,
418
443
  alt: "",
419
444
  className: "h-full w-full object-cover",
420
445
  loading: "lazy"
421
446
  }
422
447
  ),
423
- /* @__PURE__ */ o(U, { className: "absolute left-1/2 top-1/2 h-5 w-5 -translate-x-1/2 -translate-y-1/2 text-white drop-shadow" })
448
+ /* @__PURE__ */ l(S, { className: "absolute left-1/2 top-1/2 h-5 w-5 -translate-x-1/2 -translate-y-1/2 text-white drop-shadow" })
424
449
  ] }),
425
450
  /* @__PURE__ */ m("span", { className: "min-w-0 flex-1", children: [
426
451
  /* @__PURE__ */ m("span", { className: "block text-[10px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: [
427
452
  "Video",
428
- r.duration_ms ? ` · ${y(r.duration_ms)}` : ""
453
+ r.duration_ms ? ` · ${N(r.duration_ms)}` : ""
429
454
  ] }),
430
- /* @__PURE__ */ o("span", { className: "block truncate text-[12px] font-medium", children: r.title || "Untitled video" }),
431
- h && /* @__PURE__ */ o(
455
+ /* @__PURE__ */ l("span", { className: "block truncate text-[12px] font-medium", children: r.title || "Untitled video" }),
456
+ f && /* @__PURE__ */ l(
432
457
  "span",
433
458
  {
434
459
  className: "block truncate text-[11px] text-slate-500 dark:text-slate-400",
435
460
  "data-chat-help-video-start": r.start_ms,
436
- children: h
461
+ children: f
437
462
  }
438
463
  )
439
464
  ] })
@@ -442,8 +467,8 @@ function re({
442
467
  );
443
468
  }
444
469
  function A({ url: s }) {
445
- const e = X(s);
446
- return e != null && e.ok ? /* @__PURE__ */ m(
470
+ const t = J(s);
471
+ return t != null && t.ok ? /* @__PURE__ */ m(
447
472
  "a",
448
473
  {
449
474
  href: s,
@@ -453,54 +478,55 @@ function A({ url: s }) {
453
478
  "data-chat-link-preview": !0,
454
479
  children: [
455
480
  /* @__PURE__ */ m("span", { className: "flex items-center gap-1 text-[10.5px] text-slate-500 dark:text-slate-400", children: [
456
- /* @__PURE__ */ o(j, { className: "h-3 w-3" }),
481
+ /* @__PURE__ */ l(U, { className: "h-3 w-3" }),
457
482
  " ",
458
- e.site
483
+ t.site
459
484
  ] }),
460
- /* @__PURE__ */ o("span", { className: "block truncate text-[12px] font-semibold text-slate-800 dark:text-slate-100", children: e.title }),
461
- e.description && /* @__PURE__ */ o("span", { className: "line-clamp-2 text-[11px] text-slate-600 dark:text-slate-300", children: e.description })
485
+ /* @__PURE__ */ l("span", { className: "block truncate text-[12px] font-semibold text-slate-800 dark:text-slate-100", children: t.title }),
486
+ t.description && /* @__PURE__ */ l("span", { className: "line-clamp-2 text-[11px] text-slate-600 dark:text-slate-300", children: t.description })
462
487
  ]
463
488
  }
464
489
  ) : null;
465
490
  }
466
- function ge({
491
+ function Le({
467
492
  text: s,
468
- navigate: e,
469
- onDismiss: c
493
+ navigate: t,
494
+ onDismiss: o
470
495
  }) {
471
- const t = T(() => Q(s).slice(0, 3), [s]);
472
- return t.length === 0 ? null : /* @__PURE__ */ m("div", { className: "group/prev relative mt-1 space-y-1", "data-chat-previews": !0, children: [
473
- t.map((l) => {
474
- const n = D(l), i = K(l);
475
- return i ? /* @__PURE__ */ o(
476
- re,
496
+ const e = v(() => ae(s).slice(0, 3), [s]), i = v(() => te(s), [s]), [a, c] = Y();
497
+ return e.length === 0 && i.length === 0 ? null : c ? /* @__PURE__ */ m("div", { className: "group/prev relative mt-1 space-y-1", "data-chat-previews": !0, children: [
498
+ i.map((n) => /* @__PURE__ */ l(re, { id: n, navigate: t }, n)),
499
+ e.map((n) => {
500
+ const r = F(n), d = X(n);
501
+ return d ? /* @__PURE__ */ l(
502
+ de,
477
503
  {
478
- search: i.search,
479
- navigate: e,
480
- fallback: n ? null : /* @__PURE__ */ o(A, { url: l })
504
+ search: d.search,
505
+ navigate: t,
506
+ fallback: r ? null : /* @__PURE__ */ l(A, { url: n })
481
507
  },
482
- l
483
- ) : n ? /* @__PURE__ */ o(te, { path: n, navigate: e }, l) : /* @__PURE__ */ o(A, { url: l }, l);
508
+ n
509
+ ) : r ? /* @__PURE__ */ l(ce, { path: r, navigate: t }, n) : /* @__PURE__ */ l(A, { url: n }, n);
484
510
  }),
485
- c && /* @__PURE__ */ o(
511
+ o && /* @__PURE__ */ l(
486
512
  "button",
487
513
  {
488
514
  type: "button",
489
- onClick: c,
515
+ onClick: o,
490
516
  className: "absolute -right-1.5 -top-1.5 hidden rounded-full border border-slate-200 bg-white p-0.5 text-slate-500 shadow-sm hover:text-slate-800 group-hover/prev:block dark:border-border dark:bg-card",
491
517
  title: "Remove the preview (for everyone)",
492
518
  "aria-label": "Remove link preview",
493
519
  "data-chat-preview-dismiss": !0,
494
- children: /* @__PURE__ */ o(E, { className: "h-3 w-3" })
520
+ children: /* @__PURE__ */ l(I, { className: "h-3 w-3" })
495
521
  }
496
522
  )
497
- ] });
523
+ ] }) : /* @__PURE__ */ l("div", { ref: a, "data-chat-previews-pending": !0 });
498
524
  }
499
525
  export {
500
- be as FormattedMessage,
501
- ge as LinkPreviews,
502
- D as appPath,
503
- Q as extractUrls,
504
- Y as parseBlocks,
505
- xe as tsvToTable
526
+ qe as FormattedMessage,
527
+ Le as LinkPreviews,
528
+ F as appPath,
529
+ ae as extractUrls,
530
+ oe as parseBlocks,
531
+ Ae as tsvToTable
506
532
  };