@arbidocs/react 0.4.2 → 0.4.3

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.
@@ -1,13 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkRZQACYNQ_cjs = require('./chunk-RZQACYNQ.cjs');
4
+ var React = require('react');
5
+ var reactDom = require('react-dom');
4
6
  var jsxRuntime = require('react/jsx-runtime');
5
- var React2 = require('react');
6
- var Markdown = require('react-markdown');
7
- var remarkGfm = require('remark-gfm');
8
- var rehypeRaw = require('rehype-raw');
9
7
  var lucideReact = require('lucide-react');
10
- var reactDom = require('react-dom');
11
8
  var AvatarPrimitive = require('@radix-ui/react-avatar');
12
9
  var classVarianceAuthority = require('class-variance-authority');
13
10
  var reactSlot = require('@radix-ui/react-slot');
@@ -26,6 +23,9 @@ var DialogPrimitive = require('@radix-ui/react-dialog');
26
23
  var PopoverPrimitive = require('@radix-ui/react-popover');
27
24
  var SelectPrimitive = require('@radix-ui/react-select');
28
25
  var cmdk = require('cmdk');
26
+ var Markdown = require('react-markdown');
27
+ var remarkGfm = require('remark-gfm');
28
+ var rehypeRaw = require('rehype-raw');
29
29
 
30
30
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
31
31
 
@@ -47,10 +47,7 @@ function _interopNamespace(e) {
47
47
  return Object.freeze(n);
48
48
  }
49
49
 
50
- var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
51
- var Markdown__default = /*#__PURE__*/_interopDefault(Markdown);
52
- var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
53
- var rehypeRaw__default = /*#__PURE__*/_interopDefault(rehypeRaw);
50
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
54
51
  var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
55
52
  var HoverCardPrimitive__namespace = /*#__PURE__*/_interopNamespace(HoverCardPrimitive);
56
53
  var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
@@ -66,263 +63,55 @@ var ToggleGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(ToggleGroup
66
63
  var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
67
64
  var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
68
65
  var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
66
+ var Markdown__default = /*#__PURE__*/_interopDefault(Markdown);
67
+ var remarkGfm__default = /*#__PURE__*/_interopDefault(remarkGfm);
68
+ var rehypeRaw__default = /*#__PURE__*/_interopDefault(rehypeRaw);
69
69
 
70
- var markdownBaseComponents = {
71
- h1: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", "data-testid": "markdown-heading-1", ...props, children }),
72
- h2: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-semibold text-base", "data-testid": "markdown-heading-2", ...props, children }),
73
- h3: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold text-base", "data-testid": "markdown-heading-3", ...props, children }),
74
- h4: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "font-semibold text-base", ...props, children }),
75
- h5: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h5", { className: "font-medium", ...props, children }),
76
- strong: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "font-semibold", ...props, children }),
77
- blockquote: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("blockquote", { className: "border-l-2 border-primary pl-4", ...props, children }),
78
- ol: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "list-decimal space-y-2 pl-6", "data-testid": "markdown-ordered-list", ...props, children }),
79
- ul: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "list-none space-y-2 pl-6", "data-testid": "markdown-unordered-list", ...props, children }),
80
- li: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "my-1.5", ...props, children }),
81
- table: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("table", { "data-testid": "markdown-table", ...props, children }),
82
- th: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("th", { ...props, children }),
83
- td: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("td", { ...props, children }),
84
- tr: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("tr", { ...props, children }),
85
- p: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("p", { className: "whitespace-pre-wrap", ...props, children }),
86
- hr: (props) => /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-foreground/20", ...props }),
87
- sup: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("sup", { className: "text-xs", ...props, children }),
88
- sub: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("sub", { className: "text-xs", ...props, children }),
89
- div: ({ children, className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className, ...props, children }),
90
- br: (props) => /* @__PURE__ */ jsxRuntime.jsx("br", { ...props }),
91
- kbd: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
92
- "kbd",
93
- {
94
- className: "px-1.5 py-0.5 text-xs font-mono bg-muted border border-border rounded",
95
- ...props,
96
- children
97
- }
98
- ),
99
- abbr: ({ children, title, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("abbr", { title, className: "underline decoration-dotted cursor-help", ...props, children }),
100
- cite: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("cite", { className: "italic", ...props, children })
101
- };
102
- var MarkdownStreamingContext = React2.createContext(false);
103
-
104
- // src/ai/split-markdown-blocks.ts
105
- var LIST_ITEM_RE = /^\s*([-*+]|\d+[.)])\s/;
106
- var BLOCKQUOTE_RE = /^\s*>/;
107
- function splitMarkdownBlocks(content) {
108
- if (!content) return [];
109
- const blocks = [];
110
- let start = 0;
111
- let inFence = false;
112
- let i = 0;
113
- while (i < content.length) {
114
- if (content.startsWith("```", i)) {
115
- inFence = !inFence;
116
- i += 3;
117
- continue;
118
- }
119
- if (!inFence && content[i] === "\n" && content[i + 1] === "\n") {
120
- const before = content.slice(start, i);
121
- const lastLine = before.slice(before.lastIndexOf("\n") + 1);
122
- const afterStart = i + 2;
123
- const nextNewline = content.indexOf("\n", afterStart);
124
- const nextLine = content.slice(afterStart, nextNewline === -1 ? void 0 : nextNewline);
125
- const bothListItems = LIST_ITEM_RE.test(lastLine) && LIST_ITEM_RE.test(nextLine);
126
- const bothBlockquotes = BLOCKQUOTE_RE.test(lastLine) && BLOCKQUOTE_RE.test(nextLine);
127
- if (bothListItems || bothBlockquotes) {
128
- i += 2;
129
- continue;
130
- }
131
- blocks.push(content.slice(start, afterStart));
132
- start = afterStart;
133
- i = afterStart;
134
- continue;
135
- }
136
- i++;
137
- }
138
- if (start < content.length) blocks.push(content.slice(start));
139
- return blocks;
140
- }
141
- function CodeBlock({ language, code }) {
142
- const [copied, setCopied] = React2.useState(false);
143
- const handleCopy = async () => {
144
- try {
145
- await navigator.clipboard.writeText(code);
146
- setCopied(true);
147
- setTimeout(() => setCopied(false), 2e3);
148
- } catch {
149
- }
150
- };
151
- return /* @__PURE__ */ jsxRuntime.jsxs(
152
- "div",
153
- {
154
- className: "code-block relative my-3 overflow-hidden rounded-md border border-border bg-muted",
155
- "data-testid": "markdown-code-block",
156
- children: [
157
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border-b border-border px-3 py-1.5", children: [
158
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-xs text-muted-foreground", children: language || "code" }),
159
- /* @__PURE__ */ jsxRuntime.jsxs(
160
- "button",
161
- {
162
- type: "button",
163
- onClick: handleCopy,
164
- className: "flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",
165
- title: copied ? "Copied!" : "Copy code",
166
- children: [
167
- copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { size: 12 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { size: 12 }),
168
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: copied ? "Copied" : "Copy" })
169
- ]
170
- }
171
- )
172
- ] }),
173
- /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "overflow-x-auto p-3 text-sm leading-relaxed", children: /* @__PURE__ */ jsxRuntime.jsx("code", { className: chunkRZQACYNQ_cjs.cn("font-mono text-foreground", language && `language-${language}`), children: code }) })
174
- ]
175
- }
176
- );
177
- }
178
- var defaultComponents = {
179
- ...markdownBaseComponents,
180
- a: ({ href, children, ...props }) => {
181
- const isInternal = !href || href.startsWith("#") || href.startsWith("cite:");
182
- return /* @__PURE__ */ jsxRuntime.jsx(
183
- "a",
184
- {
185
- className: "text-primary underline underline-offset-2",
186
- href,
187
- ...isInternal ? {} : { target: "_blank", rel: "noopener noreferrer" },
188
- ...props,
189
- children
190
- }
191
- );
192
- },
193
- em: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("em", { className: "italic", ...props, children }),
194
- code: function MarkdownCode({
195
- className,
196
- children,
197
- ...props
198
- }) {
199
- const match = /language-(\w+)/.exec(className || "");
200
- if (!match) {
201
- return /* @__PURE__ */ jsxRuntime.jsx(
202
- "code",
203
- {
204
- className: "rounded bg-muted px-1 py-0.5 font-mono text-[0.9em]",
205
- "data-testid": "markdown-inline-code",
206
- ...props,
207
- children
208
- }
209
- );
210
- }
211
- return /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, { language: match[1], code: String(children).replace(/\n$/, "") });
212
- },
213
- // The CodeBlock renders its own <pre>; unwrap react-markdown's wrapper so we
214
- // don't nest <pre><pre>.
215
- pre: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }),
216
- blockquote: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("blockquote", { className: "border-l-2 border-border pl-4 italic text-muted-foreground", ...props, children }),
217
- table: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-3 overflow-x-auto rounded-lg border border-border", children: /* @__PURE__ */ jsxRuntime.jsx("table", { "data-testid": "markdown-table", className: "w-full border-collapse text-sm", ...props, children }) }),
218
- thead: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-muted", ...props, children }),
219
- th: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
220
- "th",
221
- {
222
- className: "border-b border-border px-3 py-2 text-left font-semibold text-foreground",
223
- ...props,
224
- children
225
- }
226
- ),
227
- td: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("td", { className: "border-b border-border px-3 py-2 align-top", ...props, children }),
228
- // General emphasis marks (GFM `~~strikethrough~~` → <del>, raw <ins>/<mark>).
229
- del: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("del", { className: "text-muted-foreground line-through", ...props, children }),
230
- ins: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("ins", { className: "underline decoration-primary/60", ...props, children }),
231
- mark: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("mark", { className: "rounded bg-primary/15 px-0.5 text-foreground", ...props, children })
232
- };
233
- var remarkPlugins = [remarkGfm__default.default];
234
- var rehypePlugins = [rehypeRaw__default.default];
235
- var MemoizedBlock = React2__namespace.default.memo(function MarkdownBlock({
236
- content,
237
- components
238
- }) {
239
- return /* @__PURE__ */ jsxRuntime.jsx(Markdown__default.default, { remarkPlugins, rehypePlugins, components, children: content });
240
- });
241
- var MarkdownErrorBoundary = class extends React2__namespace.default.Component {
242
- state = { hasError: false };
243
- static getDerivedStateFromError() {
244
- return { hasError: true };
245
- }
246
- render() {
247
- return this.state.hasError ? this.props.fallback : this.props.children;
248
- }
249
- };
250
- function MarkdownRendererComponent({
251
- children,
252
- components: customComponents,
253
- isStreaming = false,
254
- className,
255
- testId = "markdown-renderer"
256
- }) {
257
- const components = React2.useMemo(
258
- () => customComponents ? { ...defaultComponents, ...customComponents } : defaultComponents,
259
- [customComponents]
260
- );
261
- const blocks = React2.useMemo(() => splitMarkdownBlocks(children), [children]);
262
- return /* @__PURE__ */ jsxRuntime.jsx(
263
- MarkdownErrorBoundary,
264
- {
265
- fallback: /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkRZQACYNQ_cjs.cn("whitespace-pre-wrap break-words text-foreground", className), children }),
266
- children: /* @__PURE__ */ jsxRuntime.jsx(MarkdownStreamingContext.Provider, { value: isStreaming, children: /* @__PURE__ */ jsxRuntime.jsx(
267
- "div",
268
- {
269
- className: chunkRZQACYNQ_cjs.cn(
270
- "markdown-content space-y-3 break-words leading-relaxed text-foreground",
271
- className
272
- ),
273
- "data-testid": testId,
274
- children: blocks.map((block, index) => /* @__PURE__ */ jsxRuntime.jsx(MemoizedBlock, { content: block, components }, index))
275
- }
276
- ) })
277
- }
278
- );
279
- }
280
- var MarkdownRenderer = React2__namespace.default.memo(MarkdownRendererComponent);
281
- var TooltipContext = React2__namespace.createContext(null);
70
+ var TooltipContext = React__namespace.createContext(null);
282
71
  var DEFAULT_DELAY = 300;
283
- var TooltipConfigContext = React2__namespace.createContext({
72
+ var TooltipConfigContext = React__namespace.createContext({
284
73
  delayDuration: DEFAULT_DELAY
285
74
  });
286
75
  var TooltipProvider = ({ children, delayDuration = DEFAULT_DELAY }) => {
287
- const value = React2__namespace.useMemo(() => ({ delayDuration }), [delayDuration]);
76
+ const value = React__namespace.useMemo(() => ({ delayDuration }), [delayDuration]);
288
77
  return /* @__PURE__ */ jsxRuntime.jsx(TooltipConfigContext.Provider, { value, children });
289
78
  };
290
79
  function Tooltip({ children, delayDuration }) {
291
- const config = React2__namespace.useContext(TooltipConfigContext);
80
+ const config = React__namespace.useContext(TooltipConfigContext);
292
81
  const delay = delayDuration ?? config.delayDuration;
293
- const [open, setOpen] = React2__namespace.useState(false);
294
- const triggerRef = React2__namespace.useRef(null);
295
- const timer = React2__namespace.useRef(null);
296
- const contentId = React2__namespace.useId();
82
+ const [open, setOpen] = React__namespace.useState(false);
83
+ const triggerRef = React__namespace.useRef(null);
84
+ const timer = React__namespace.useRef(null);
85
+ const contentId = React__namespace.useId();
297
86
  const clearTimer = () => {
298
87
  if (timer.current) {
299
88
  clearTimeout(timer.current);
300
89
  timer.current = null;
301
90
  }
302
91
  };
303
- const suppressed = React2__namespace.useRef(false);
304
- const show = React2__namespace.useCallback(() => {
92
+ const suppressed = React__namespace.useRef(false);
93
+ const show = React__namespace.useCallback(() => {
305
94
  clearTimer();
306
95
  if (suppressed.current) return;
307
96
  timer.current = setTimeout(() => setOpen(true), delay);
308
97
  }, [delay]);
309
- const hide = React2__namespace.useCallback(() => {
98
+ const hide = React__namespace.useCallback(() => {
310
99
  clearTimer();
311
100
  setOpen(false);
312
101
  }, []);
313
- const suppress = React2__namespace.useCallback(() => {
102
+ const suppress = React__namespace.useCallback(() => {
314
103
  suppressed.current = true;
315
104
  clearTimer();
316
105
  setOpen(false);
317
106
  }, []);
318
- const release = React2__namespace.useCallback(() => {
107
+ const release = React__namespace.useCallback(() => {
319
108
  suppressed.current = false;
320
109
  }, []);
321
- const setTrigger = React2__namespace.useCallback((el) => {
110
+ const setTrigger = React__namespace.useCallback((el) => {
322
111
  triggerRef.current = el;
323
112
  }, []);
324
- React2__namespace.useEffect(() => () => clearTimer(), []);
325
- const value = React2__namespace.useMemo(
113
+ React__namespace.useEffect(() => () => clearTimer(), []);
114
+ const value = React__namespace.useMemo(
326
115
  () => ({ open, show, hide, suppress, release, setTrigger, triggerRef, contentId }),
327
116
  [open, show, hide, suppress, release, setTrigger, contentId]
328
117
  );
@@ -346,7 +135,7 @@ function showsOwnText(el) {
346
135
  return /\p{L}{2,}/u.test(visible);
347
136
  }
348
137
  function TooltipTrigger({ asChild, children, ...props }) {
349
- const ctx = React2__namespace.useContext(TooltipContext);
138
+ const ctx = React__namespace.useContext(TooltipContext);
350
139
  if (!ctx) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
351
140
  const triggerHandlers = {
352
141
  onPointerEnter: (e) => {
@@ -362,7 +151,7 @@ function TooltipTrigger({ asChild, children, ...props }) {
362
151
  },
363
152
  onPointerDown: (e) => {
364
153
  props.onPointerDown?.(e);
365
- (asChild && React2__namespace.isValidElement(children) ? children.props.onPointerDown : void 0)?.(e);
154
+ (asChild && React__namespace.isValidElement(children) ? children.props.onPointerDown : void 0)?.(e);
366
155
  ctx.suppress();
367
156
  },
368
157
  onFocus: (e) => {
@@ -376,9 +165,9 @@ function TooltipTrigger({ asChild, children, ...props }) {
376
165
  "aria-describedby": ctx.open ? ctx.contentId : void 0,
377
166
  "data-state": ctx.open ? "open" : "closed"
378
167
  };
379
- if (asChild && React2__namespace.isValidElement(children)) {
168
+ if (asChild && React__namespace.isValidElement(children)) {
380
169
  const child = children;
381
- return React2__namespace.cloneElement(child, {
170
+ return React__namespace.cloneElement(child, {
382
171
  ...props,
383
172
  ...triggerHandlers,
384
173
  ref: ctx.setTrigger
@@ -401,12 +190,12 @@ var TRANSFORM_BY_SIDE = {
401
190
  left: "translate(-100%, -50%)",
402
191
  right: "translate(0, -50%)"
403
192
  };
404
- var TooltipContent = React2__namespace.forwardRef(
193
+ var TooltipContent = React__namespace.forwardRef(
405
194
  ({ className, side = "top", sideOffset = 4, collisionPadding = 8, style, ...props }, ref) => {
406
- const ctx = React2__namespace.useContext(TooltipContext);
407
- const innerRef = React2__namespace.useRef(null);
408
- const [coords, setCoords] = React2__namespace.useState(null);
409
- React2__namespace.useLayoutEffect(() => {
195
+ const ctx = React__namespace.useContext(TooltipContext);
196
+ const innerRef = React__namespace.useRef(null);
197
+ const [coords, setCoords] = React__namespace.useState(null);
198
+ React__namespace.useLayoutEffect(() => {
410
199
  if (!ctx?.open || !ctx.triggerRef.current) {
411
200
  setCoords(null);
412
201
  return;
@@ -542,7 +331,7 @@ function IconToggle({
542
331
  ] }) : button
543
332
  ] });
544
333
  }
545
- var DictateContext = React2.createContext(null);
334
+ var DictateContext = React.createContext(null);
546
335
  function DictateProvider({
547
336
  transcribe,
548
337
  onError,
@@ -551,9 +340,9 @@ function DictateProvider({
551
340
  return /* @__PURE__ */ jsxRuntime.jsx(DictateContext.Provider, { value: { transcribe, onError }, children });
552
341
  }
553
342
  function useDictateContext() {
554
- return React2.useContext(DictateContext);
343
+ return React.useContext(DictateContext);
555
344
  }
556
- var Avatar = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
345
+ var Avatar = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
557
346
  AvatarPrimitive__namespace.Root,
558
347
  {
559
348
  ref,
@@ -562,7 +351,7 @@ var Avatar = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @
562
351
  }
563
352
  ));
564
353
  Avatar.displayName = AvatarPrimitive__namespace.Root.displayName;
565
- var AvatarImage = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
354
+ var AvatarImage = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
566
355
  AvatarPrimitive__namespace.Image,
567
356
  {
568
357
  ref,
@@ -571,7 +360,7 @@ var AvatarImage = React2__namespace.forwardRef(({ className, ...props }, ref) =>
571
360
  }
572
361
  ));
573
362
  AvatarImage.displayName = AvatarPrimitive__namespace.Image.displayName;
574
- var AvatarFallback = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
363
+ var AvatarFallback = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
575
364
  AvatarPrimitive__namespace.Fallback,
576
365
  {
577
366
  ref,
@@ -634,7 +423,7 @@ var buttonVariants = classVarianceAuthority.cva(
634
423
  }
635
424
  }
636
425
  );
637
- var Button = React2__namespace.forwardRef(
426
+ var Button = React__namespace.forwardRef(
638
427
  ({ className, variant, size, asChild = false, ...props }, ref) => {
639
428
  const Comp = asChild ? reactSlot.Slot : "button";
640
429
  return /* @__PURE__ */ jsxRuntime.jsx(Comp, { className: chunkRZQACYNQ_cjs.cn(buttonVariants({ variant, size, className })), ref, ...props });
@@ -643,7 +432,7 @@ var Button = React2__namespace.forwardRef(
643
432
  Button.displayName = "Button";
644
433
  var HoverCard = HoverCardPrimitive__namespace.Root;
645
434
  var HoverCardTrigger = HoverCardPrimitive__namespace.Trigger;
646
- var HoverCardContent = React2__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(HoverCardPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
435
+ var HoverCardContent = React__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(HoverCardPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
647
436
  HoverCardPrimitive__namespace.Content,
648
437
  {
649
438
  ref,
@@ -670,7 +459,7 @@ var cardVariants = classVarianceAuthority.cva("rounded-lg bg-card text-card-fore
670
459
  variant: "flat"
671
460
  }
672
461
  });
673
- var Card = React2__namespace.forwardRef(
462
+ var Card = React__namespace.forwardRef(
674
463
  ({ className, variant, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
675
464
  "div",
676
465
  {
@@ -682,7 +471,7 @@ var Card = React2__namespace.forwardRef(
682
471
  )
683
472
  );
684
473
  Card.displayName = "Card";
685
- var CardHeader = React2__namespace.forwardRef(
474
+ var CardHeader = React__namespace.forwardRef(
686
475
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
687
476
  "div",
688
477
  {
@@ -694,7 +483,7 @@ var CardHeader = React2__namespace.forwardRef(
694
483
  )
695
484
  );
696
485
  CardHeader.displayName = "CardHeader";
697
- var CardTitle = React2__namespace.forwardRef(
486
+ var CardTitle = React__namespace.forwardRef(
698
487
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
699
488
  "div",
700
489
  {
@@ -706,7 +495,7 @@ var CardTitle = React2__namespace.forwardRef(
706
495
  )
707
496
  );
708
497
  CardTitle.displayName = "CardTitle";
709
- var CardDescription = React2__namespace.forwardRef(
498
+ var CardDescription = React__namespace.forwardRef(
710
499
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
711
500
  "div",
712
501
  {
@@ -718,11 +507,11 @@ var CardDescription = React2__namespace.forwardRef(
718
507
  )
719
508
  );
720
509
  CardDescription.displayName = "CardDescription";
721
- var CardContent = React2__namespace.forwardRef(
510
+ var CardContent = React__namespace.forwardRef(
722
511
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, "data-slot": "card-content", className: chunkRZQACYNQ_cjs.cn("p-6 pt-0", className), ...props })
723
512
  );
724
513
  CardContent.displayName = "CardContent";
725
- var CardFooter = React2__namespace.forwardRef(
514
+ var CardFooter = React__namespace.forwardRef(
726
515
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
727
516
  "div",
728
517
  {
@@ -754,23 +543,23 @@ function classifyMediaError(err, kind) {
754
543
  // src/documents/useAudioRecorder.ts
755
544
  var LEVEL_UPDATE_INTERVAL_MS = 50;
756
545
  function useAudioRecorder() {
757
- const [state, setState] = React2.useState("idle");
758
- const [level, setLevel] = React2.useState(0);
759
- const [elapsedMs, setElapsedMs] = React2.useState(0);
760
- const [blob, setBlob] = React2.useState(null);
761
- const [mimeType, setMimeType] = React2.useState(null);
762
- const [error, setError] = React2.useState(null);
763
- const mediaRecorderRef = React2.useRef(null);
764
- const chunksRef = React2.useRef([]);
765
- const streamRef = React2.useRef(null);
766
- const stateRef = React2.useRef("idle");
546
+ const [state, setState] = React.useState("idle");
547
+ const [level, setLevel] = React.useState(0);
548
+ const [elapsedMs, setElapsedMs] = React.useState(0);
549
+ const [blob, setBlob] = React.useState(null);
550
+ const [mimeType, setMimeType] = React.useState(null);
551
+ const [error, setError] = React.useState(null);
552
+ const mediaRecorderRef = React.useRef(null);
553
+ const chunksRef = React.useRef([]);
554
+ const streamRef = React.useRef(null);
555
+ const stateRef = React.useRef("idle");
767
556
  stateRef.current = state;
768
- const segmentStartRef = React2.useRef(0);
769
- const accumulatedMsRef = React2.useRef(0);
770
- const audioContextRef = React2.useRef(null);
771
- const analyserRef = React2.useRef(null);
772
- const levelRafRef = React2.useRef(null);
773
- const stopMeter = React2.useCallback(() => {
557
+ const segmentStartRef = React.useRef(0);
558
+ const accumulatedMsRef = React.useRef(0);
559
+ const audioContextRef = React.useRef(null);
560
+ const analyserRef = React.useRef(null);
561
+ const levelRafRef = React.useRef(null);
562
+ const stopMeter = React.useCallback(() => {
774
563
  if (levelRafRef.current !== null) cancelAnimationFrame(levelRafRef.current);
775
564
  levelRafRef.current = null;
776
565
  analyserRef.current = null;
@@ -778,7 +567,7 @@ function useAudioRecorder() {
778
567
  });
779
568
  audioContextRef.current = null;
780
569
  }, []);
781
- const startMeter = React2.useCallback((stream) => {
570
+ const startMeter = React.useCallback((stream) => {
782
571
  const audioContext = new AudioContext();
783
572
  const source = audioContext.createMediaStreamSource(stream);
784
573
  const analyser = audioContext.createAnalyser();
@@ -807,18 +596,18 @@ function useAudioRecorder() {
807
596
  };
808
597
  levelRafRef.current = requestAnimationFrame(tick);
809
598
  }, []);
810
- const stopTracks = React2.useCallback(() => {
599
+ const stopTracks = React.useCallback(() => {
811
600
  streamRef.current?.getTracks().forEach((t) => t.stop());
812
601
  streamRef.current = null;
813
602
  }, []);
814
- React2.useEffect(
603
+ React.useEffect(
815
604
  () => () => {
816
605
  stopTracks();
817
606
  stopMeter();
818
607
  },
819
608
  [stopTracks, stopMeter]
820
609
  );
821
- const start = React2.useCallback(async () => {
610
+ const start = React.useCallback(async () => {
822
611
  if (stateRef.current === "recording" || stateRef.current === "paused") return;
823
612
  setError(null);
824
613
  try {
@@ -843,7 +632,7 @@ function useAudioRecorder() {
843
632
  setError(classifyMediaError(err, "microphone"));
844
633
  }
845
634
  }, [startMeter, stopTracks]);
846
- const pause = React2.useCallback(() => {
635
+ const pause = React.useCallback(() => {
847
636
  const recorder = mediaRecorderRef.current;
848
637
  if (!recorder || recorder.state !== "recording") return;
849
638
  recorder.pause();
@@ -852,7 +641,7 @@ function useAudioRecorder() {
852
641
  setLevel(0);
853
642
  setState("paused");
854
643
  }, [stopMeter]);
855
- const resume = React2.useCallback(() => {
644
+ const resume = React.useCallback(() => {
856
645
  const recorder = mediaRecorderRef.current;
857
646
  if (!recorder || recorder.state !== "paused") return;
858
647
  recorder.resume();
@@ -860,7 +649,7 @@ function useAudioRecorder() {
860
649
  setState("recording");
861
650
  if (streamRef.current) startMeter(streamRef.current);
862
651
  }, [startMeter]);
863
- const stop = React2.useCallback(() => {
652
+ const stop = React.useCallback(() => {
864
653
  const recorder = mediaRecorderRef.current;
865
654
  if (!recorder || recorder.state === "inactive") return;
866
655
  const finalElapsed = recorder.state === "paused" ? accumulatedMsRef.current : accumulatedMsRef.current + (performance.now() - segmentStartRef.current);
@@ -875,7 +664,7 @@ function useAudioRecorder() {
875
664
  };
876
665
  recorder.stop();
877
666
  }, [stopMeter, stopTracks]);
878
- const reset = React2.useCallback(() => {
667
+ const reset = React.useCallback(() => {
879
668
  setState("idle");
880
669
  setBlob(null);
881
670
  setElapsedMs(0);
@@ -987,13 +776,13 @@ function InlineMicButton({
987
776
  className
988
777
  }) {
989
778
  const recorder = useAudioRecorder();
990
- const [isTranscribing, setIsTranscribing] = React2.useState(false);
991
- const [latched, setLatched] = React2.useState(false);
992
- const pressedAtRef = React2.useRef(0);
993
- React2.useEffect(() => {
779
+ const [isTranscribing, setIsTranscribing] = React.useState(false);
780
+ const [latched, setLatched] = React.useState(false);
781
+ const pressedAtRef = React.useRef(0);
782
+ React.useEffect(() => {
994
783
  if (recorder.error) onError?.(recorder.error);
995
784
  }, [recorder.error]);
996
- React2.useEffect(() => {
785
+ React.useEffect(() => {
997
786
  if (recorder.state !== "stopped" || !recorder.blob) return;
998
787
  const blob = recorder.blob;
999
788
  setIsTranscribing(true);
@@ -1059,12 +848,12 @@ function InlineMicButton({
1059
848
  )
1060
849
  ] });
1061
850
  }
1062
- var Input = React2__namespace.forwardRef(
851
+ var Input = React__namespace.forwardRef(
1063
852
  ({ className, type, dictate, onFocus, onBlur, ...props }, forwardedRef) => {
1064
853
  const dictateCtx = useDictateContext();
1065
- const [focused, setFocused] = React2__namespace.useState(false);
1066
- const innerRef = React2__namespace.useRef(null);
1067
- React2__namespace.useImperativeHandle(forwardedRef, () => innerRef.current);
854
+ const [focused, setFocused] = React__namespace.useState(false);
855
+ const innerRef = React__namespace.useRef(null);
856
+ React__namespace.useImperativeHandle(forwardedRef, () => innerRef.current);
1068
857
  const showDictate = dictate && !!dictateCtx && !props.disabled && !props.readOnly;
1069
858
  const input = /* @__PURE__ */ jsxRuntime.jsx(
1070
859
  "input",
@@ -1115,7 +904,7 @@ var Input = React2__namespace.forwardRef(
1115
904
  }
1116
905
  );
1117
906
  Input.displayName = "Input";
1118
- var Label = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
907
+ var Label = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1119
908
  "label",
1120
909
  {
1121
910
  ref,
@@ -1124,7 +913,7 @@ var Label = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @_
1124
913
  }
1125
914
  ));
1126
915
  Label.displayName = "Label";
1127
- var Separator = React2__namespace.forwardRef(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
916
+ var Separator = React__namespace.forwardRef(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1128
917
  SeparatorPrimitive__namespace.Root,
1129
918
  {
1130
919
  ref,
@@ -1139,12 +928,12 @@ var Separator = React2__namespace.forwardRef(({ className, orientation = "horizo
1139
928
  }
1140
929
  ));
1141
930
  Separator.displayName = SeparatorPrimitive__namespace.Root.displayName;
1142
- var Textarea = React2__namespace.forwardRef(
931
+ var Textarea = React__namespace.forwardRef(
1143
932
  ({ className, dictate, onFocus, onBlur, ...props }, forwardedRef) => {
1144
933
  const dictateCtx = useDictateContext();
1145
- const [focused, setFocused] = React2__namespace.useState(false);
1146
- const innerRef = React2__namespace.useRef(null);
1147
- React2__namespace.useImperativeHandle(forwardedRef, () => innerRef.current);
934
+ const [focused, setFocused] = React__namespace.useState(false);
935
+ const innerRef = React__namespace.useRef(null);
936
+ React__namespace.useImperativeHandle(forwardedRef, () => innerRef.current);
1148
937
  const showDictate = dictate && !!dictateCtx && !props.disabled && !props.readOnly;
1149
938
  const textarea = /* @__PURE__ */ jsxRuntime.jsx(
1150
939
  "textarea",
@@ -1196,7 +985,7 @@ Textarea.displayName = "Textarea";
1196
985
  var Collapsible = CollapsiblePrimitive__namespace.Root;
1197
986
  var CollapsibleTrigger2 = CollapsiblePrimitive__namespace.CollapsibleTrigger;
1198
987
  var CollapsibleContent2 = CollapsiblePrimitive__namespace.CollapsibleContent;
1199
- var Progress = React2__namespace.forwardRef(({ className, value, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
988
+ var Progress = React__namespace.forwardRef(({ className, value, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1200
989
  ProgressPrimitive__namespace.Root,
1201
990
  {
1202
991
  ref,
@@ -1212,11 +1001,11 @@ var Progress = React2__namespace.forwardRef(({ className, value, ...props }, ref
1212
1001
  }
1213
1002
  ));
1214
1003
  Progress.displayName = ProgressPrimitive__namespace.Root.displayName;
1215
- var RadioGroup = React2__namespace.forwardRef(({ className, ...props }, ref) => {
1004
+ var RadioGroup = React__namespace.forwardRef(({ className, ...props }, ref) => {
1216
1005
  return /* @__PURE__ */ jsxRuntime.jsx(RadioGroupPrimitive__namespace.Root, { className: chunkRZQACYNQ_cjs.cn("grid gap-2", className), ...props, ref });
1217
1006
  });
1218
1007
  RadioGroup.displayName = RadioGroupPrimitive__namespace.Root.displayName;
1219
- var RadioGroupItem = React2__namespace.forwardRef(({ className, ...props }, ref) => {
1008
+ var RadioGroupItem = React__namespace.forwardRef(({ className, ...props }, ref) => {
1220
1009
  return /* @__PURE__ */ jsxRuntime.jsx(
1221
1010
  RadioGroupPrimitive__namespace.Item,
1222
1011
  {
@@ -1231,7 +1020,7 @@ var RadioGroupItem = React2__namespace.forwardRef(({ className, ...props }, ref)
1231
1020
  );
1232
1021
  });
1233
1022
  RadioGroupItem.displayName = RadioGroupPrimitive__namespace.Item.displayName;
1234
- var Checkbox = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1023
+ var Checkbox = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1235
1024
  CheckboxPrimitive__namespace.Root,
1236
1025
  {
1237
1026
  ref,
@@ -1244,7 +1033,7 @@ var Checkbox = React2__namespace.forwardRef(({ className, ...props }, ref) => /*
1244
1033
  }
1245
1034
  ));
1246
1035
  Checkbox.displayName = CheckboxPrimitive__namespace.Root.displayName;
1247
- var Switch = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1036
+ var Switch = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1248
1037
  SwitchPrimitives__namespace.Root,
1249
1038
  {
1250
1039
  className: chunkRZQACYNQ_cjs.cn(
@@ -1265,7 +1054,7 @@ var Switch = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @
1265
1054
  ));
1266
1055
  Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
1267
1056
  var Tabs = TabsPrimitive__namespace.Root;
1268
- var TabsList = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1057
+ var TabsList = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1269
1058
  TabsPrimitive__namespace.List,
1270
1059
  {
1271
1060
  ref,
@@ -1277,7 +1066,7 @@ var TabsList = React2__namespace.forwardRef(({ className, ...props }, ref) => /*
1277
1066
  }
1278
1067
  ));
1279
1068
  TabsList.displayName = TabsPrimitive__namespace.List.displayName;
1280
- var TabsTrigger = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1069
+ var TabsTrigger = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1281
1070
  TabsPrimitive__namespace.Trigger,
1282
1071
  {
1283
1072
  ref,
@@ -1289,7 +1078,7 @@ var TabsTrigger = React2__namespace.forwardRef(({ className, ...props }, ref) =>
1289
1078
  }
1290
1079
  ));
1291
1080
  TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
1292
- var TabsContent = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1081
+ var TabsContent = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1293
1082
  TabsPrimitive__namespace.Content,
1294
1083
  {
1295
1084
  ref,
@@ -1301,15 +1090,15 @@ var TabsContent = React2__namespace.forwardRef(({ className, ...props }, ref) =>
1301
1090
  }
1302
1091
  ));
1303
1092
  TabsContent.displayName = TabsPrimitive__namespace.Content.displayName;
1304
- var Table = React2__namespace.forwardRef(
1093
+ var Table = React__namespace.forwardRef(
1305
1094
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx("table", { ref, className: chunkRZQACYNQ_cjs.cn("w-full caption-bottom text-sm", className), ...props }) })
1306
1095
  );
1307
1096
  Table.displayName = "Table";
1308
- var TableHeader = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: chunkRZQACYNQ_cjs.cn("[&_tr]:border-b", className), ...props }));
1097
+ var TableHeader = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: chunkRZQACYNQ_cjs.cn("[&_tr]:border-b", className), ...props }));
1309
1098
  TableHeader.displayName = "TableHeader";
1310
- var TableBody = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tbody", { ref, className: chunkRZQACYNQ_cjs.cn("[&_tr:last-child]:border-0", className), ...props }));
1099
+ var TableBody = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("tbody", { ref, className: chunkRZQACYNQ_cjs.cn("[&_tr:last-child]:border-0", className), ...props }));
1311
1100
  TableBody.displayName = "TableBody";
1312
- var TableFooter = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1101
+ var TableFooter = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1313
1102
  "tfoot",
1314
1103
  {
1315
1104
  ref,
@@ -1318,7 +1107,7 @@ var TableFooter = React2__namespace.forwardRef(({ className, ...props }, ref) =>
1318
1107
  }
1319
1108
  ));
1320
1109
  TableFooter.displayName = "TableFooter";
1321
- var TableRow = React2__namespace.forwardRef(
1110
+ var TableRow = React__namespace.forwardRef(
1322
1111
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1323
1112
  "tr",
1324
1113
  {
@@ -1332,7 +1121,7 @@ var TableRow = React2__namespace.forwardRef(
1332
1121
  )
1333
1122
  );
1334
1123
  TableRow.displayName = "TableRow";
1335
- var TableHead = React2__namespace.forwardRef(
1124
+ var TableHead = React__namespace.forwardRef(
1336
1125
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1337
1126
  "th",
1338
1127
  {
@@ -1346,7 +1135,7 @@ var TableHead = React2__namespace.forwardRef(
1346
1135
  )
1347
1136
  );
1348
1137
  TableHead.displayName = "TableHead";
1349
- var TableCell = React2__namespace.forwardRef(
1138
+ var TableCell = React__namespace.forwardRef(
1350
1139
  ({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1351
1140
  "td",
1352
1141
  {
@@ -1360,9 +1149,9 @@ var TableCell = React2__namespace.forwardRef(
1360
1149
  )
1361
1150
  );
1362
1151
  TableCell.displayName = "TableCell";
1363
- var TableCaption = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("caption", { ref, className: chunkRZQACYNQ_cjs.cn("mt-4 text-sm text-muted-foreground", className), ...props }));
1152
+ var TableCaption = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("caption", { ref, className: chunkRZQACYNQ_cjs.cn("mt-4 text-sm text-muted-foreground", className), ...props }));
1364
1153
  TableCaption.displayName = "TableCaption";
1365
- var Slider = React2__namespace.forwardRef(
1154
+ var Slider = React__namespace.forwardRef(
1366
1155
  ({ className, rangeClassName, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1367
1156
  SliderPrimitive__namespace.Root,
1368
1157
  {
@@ -1397,7 +1186,7 @@ var toggleVariants = classVarianceAuthority.cva(
1397
1186
  }
1398
1187
  }
1399
1188
  );
1400
- var Toggle = React2__namespace.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1189
+ var Toggle = React__namespace.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1401
1190
  TogglePrimitive__namespace.Root,
1402
1191
  {
1403
1192
  ref,
@@ -1406,11 +1195,11 @@ var Toggle = React2__namespace.forwardRef(({ className, variant, size, ...props
1406
1195
  }
1407
1196
  ));
1408
1197
  Toggle.displayName = TogglePrimitive__namespace.Root.displayName;
1409
- var ToggleGroupContext = React2__namespace.createContext({
1198
+ var ToggleGroupContext = React__namespace.createContext({
1410
1199
  size: "default",
1411
1200
  variant: "default"
1412
1201
  });
1413
- var ToggleGroup = React2__namespace.forwardRef(({ className, variant, size, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1202
+ var ToggleGroup = React__namespace.forwardRef(({ className, variant, size, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1414
1203
  ToggleGroupPrimitive__namespace.Root,
1415
1204
  {
1416
1205
  ref,
@@ -1420,8 +1209,8 @@ var ToggleGroup = React2__namespace.forwardRef(({ className, variant, size, chil
1420
1209
  }
1421
1210
  ));
1422
1211
  ToggleGroup.displayName = ToggleGroupPrimitive__namespace.Root.displayName;
1423
- var ToggleGroupItem = React2__namespace.forwardRef(({ className, children, variant, size, ...props }, ref) => {
1424
- const context = React2__namespace.useContext(ToggleGroupContext);
1212
+ var ToggleGroupItem = React__namespace.forwardRef(({ className, children, variant, size, ...props }, ref) => {
1213
+ const context = React__namespace.useContext(ToggleGroupContext);
1425
1214
  return /* @__PURE__ */ jsxRuntime.jsx(
1426
1215
  ToggleGroupPrimitive__namespace.Item,
1427
1216
  {
@@ -1450,7 +1239,7 @@ var Dialog = DialogPrimitive__namespace.Root;
1450
1239
  var DialogTrigger = DialogPrimitive__namespace.Trigger;
1451
1240
  var DialogPortal = DialogPrimitive__namespace.Portal;
1452
1241
  var DialogClose = DialogPrimitive__namespace.Close;
1453
- var DialogOverlay = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1242
+ var DialogOverlay = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1454
1243
  DialogPrimitive__namespace.Overlay,
1455
1244
  {
1456
1245
  ref,
@@ -1467,7 +1256,7 @@ var PHONE_PRESENTATION = {
1467
1256
  sheet: "max-sm:top-auto max-sm:bottom-0 max-sm:left-0 max-sm:w-full max-sm:max-w-full max-sm:border-x-0 max-sm:border-b-0 max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-xl max-sm:pb-[max(1.5rem,env(safe-area-inset-bottom))] max-sm:max-h-[calc(100dvh-env(safe-area-inset-top,0px)-2.5rem)] max-sm:data-[state=open]:slide-in-from-bottom-10 max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:zoom-out-100",
1468
1257
  full: "max-sm:top-auto max-sm:bottom-0 max-sm:left-0 max-sm:border-x-0 max-sm:border-b-0 max-sm:h-[calc(100dvh-env(safe-area-inset-top,0px)-1rem)] max-sm:w-full max-sm:max-w-full max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-xl max-sm:pb-[max(1.5rem,env(safe-area-inset-bottom))] max-sm:max-h-none max-sm:data-[state=open]:slide-in-from-bottom-10 max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:zoom-out-100"
1469
1258
  };
1470
- var DialogContent = React2__namespace.forwardRef(
1259
+ var DialogContent = React__namespace.forwardRef(
1471
1260
  ({ className, children, hideCloseButton, presentation = "center", onInteractOutside, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { children: [
1472
1261
  /* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
1473
1262
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1521,7 +1310,7 @@ var DialogFooter = ({ className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
1521
1310
  }
1522
1311
  );
1523
1312
  DialogFooter.displayName = "DialogFooter";
1524
- var DialogTitle = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1313
+ var DialogTitle = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1525
1314
  DialogPrimitive__namespace.Title,
1526
1315
  {
1527
1316
  ref,
@@ -1530,7 +1319,7 @@ var DialogTitle = React2__namespace.forwardRef(({ className, ...props }, ref) =>
1530
1319
  }
1531
1320
  ));
1532
1321
  DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
1533
- var DialogDescription = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1322
+ var DialogDescription = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1534
1323
  DialogPrimitive__namespace.Description,
1535
1324
  {
1536
1325
  ref,
@@ -1542,7 +1331,7 @@ DialogDescription.displayName = DialogPrimitive__namespace.Description.displayNa
1542
1331
  var Popover = PopoverPrimitive__namespace.Root;
1543
1332
  var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
1544
1333
  var PopoverAnchor = PopoverPrimitive__namespace.Anchor;
1545
- var PopoverContent = React2__namespace.forwardRef(({ className, align = "center", sideOffset = 4, container, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { container: container ?? void 0, children: /* @__PURE__ */ jsxRuntime.jsx(
1334
+ var PopoverContent = React__namespace.forwardRef(({ className, align = "center", sideOffset = 4, container, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { container: container ?? void 0, children: /* @__PURE__ */ jsxRuntime.jsx(
1546
1335
  PopoverPrimitive__namespace.Content,
1547
1336
  {
1548
1337
  ref,
@@ -1593,15 +1382,15 @@ function MarkMenu({
1593
1382
  onKeyDown,
1594
1383
  ...rest
1595
1384
  }) {
1596
- const [open, setOpen] = React2.useState(false);
1597
- const [side, setSide] = React2.useState("bottom");
1598
- const menuId = React2.useId();
1599
- const triggerRef = React2.useRef(null);
1600
- const contentRef = React2.useRef(null);
1601
- const timer = React2.useRef(null);
1602
- const mode = React2.useRef("hover");
1603
- const lastPointer = React2.useRef("mouse");
1604
- const focusFirstOnOpen = React2.useRef(false);
1385
+ const [open, setOpen] = React.useState(false);
1386
+ const [side, setSide] = React.useState("bottom");
1387
+ const menuId = React.useId();
1388
+ const triggerRef = React.useRef(null);
1389
+ const contentRef = React.useRef(null);
1390
+ const timer = React.useRef(null);
1391
+ const mode = React.useRef("hover");
1392
+ const lastPointer = React.useRef("mouse");
1393
+ const focusFirstOnOpen = React.useRef(false);
1605
1394
  const isEmpty = items.length === 0 && !preview;
1606
1395
  const ordered = [...items].sort((a, b) => Number(!!b.primary) - Number(!!a.primary));
1607
1396
  const primary = ordered[0];
@@ -1609,7 +1398,7 @@ function MarkMenu({
1609
1398
  if (timer.current) clearTimeout(timer.current);
1610
1399
  timer.current = null;
1611
1400
  };
1612
- React2.useEffect(() => clearTimer, []);
1401
+ React.useEffect(() => clearTimer, []);
1613
1402
  const rows = () => Array.from(contentRef.current?.querySelectorAll('[role="menuitem"]') ?? []);
1614
1403
  const firstItem = () => rows()[0];
1615
1404
  const openWith = (next, focusFirst = false) => {
@@ -1718,7 +1507,7 @@ function MarkMenu({
1718
1507
  close(wasKey);
1719
1508
  item.onSelect?.();
1720
1509
  };
1721
- const setTriggerRef = React2.useCallback(
1510
+ const setTriggerRef = React.useCallback(
1722
1511
  (el) => {
1723
1512
  triggerRef.current = el;
1724
1513
  if (typeof externalRef === "function") externalRef(el);
@@ -1818,7 +1607,7 @@ function MarkMenu({
1818
1607
  var Select = SelectPrimitive__namespace.Root;
1819
1608
  var SelectGroup = SelectPrimitive__namespace.Group;
1820
1609
  var SelectValue = SelectPrimitive__namespace.Value;
1821
- var SelectTrigger = React2__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1610
+ var SelectTrigger = React__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1822
1611
  SelectPrimitive__namespace.Trigger,
1823
1612
  {
1824
1613
  ref,
@@ -1834,7 +1623,7 @@ var SelectTrigger = React2__namespace.forwardRef(({ className, children, ...prop
1834
1623
  }
1835
1624
  ));
1836
1625
  SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
1837
- var SelectScrollUpButton = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1626
+ var SelectScrollUpButton = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1838
1627
  SelectPrimitive__namespace.ScrollUpButton,
1839
1628
  {
1840
1629
  ref,
@@ -1844,7 +1633,7 @@ var SelectScrollUpButton = React2__namespace.forwardRef(({ className, ...props }
1844
1633
  }
1845
1634
  ));
1846
1635
  SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
1847
- var SelectScrollDownButton = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1636
+ var SelectScrollDownButton = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1848
1637
  SelectPrimitive__namespace.ScrollDownButton,
1849
1638
  {
1850
1639
  ref,
@@ -1854,7 +1643,7 @@ var SelectScrollDownButton = React2__namespace.forwardRef(({ className, ...props
1854
1643
  }
1855
1644
  ));
1856
1645
  SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
1857
- var SelectContent = React2__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
1646
+ var SelectContent = React__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
1858
1647
  SelectPrimitive__namespace.Content,
1859
1648
  {
1860
1649
  ref,
@@ -1883,7 +1672,7 @@ var SelectContent = React2__namespace.forwardRef(({ className, children, positio
1883
1672
  }
1884
1673
  ) }));
1885
1674
  SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
1886
- var SelectLabel = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1675
+ var SelectLabel = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1887
1676
  SelectPrimitive__namespace.Label,
1888
1677
  {
1889
1678
  ref,
@@ -1892,7 +1681,7 @@ var SelectLabel = React2__namespace.forwardRef(({ className, ...props }, ref) =>
1892
1681
  }
1893
1682
  ));
1894
1683
  SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
1895
- var SelectItem = React2__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1684
+ var SelectItem = React__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
1896
1685
  SelectPrimitive__namespace.Item,
1897
1686
  {
1898
1687
  ref,
@@ -1908,7 +1697,7 @@ var SelectItem = React2__namespace.forwardRef(({ className, children, ...props }
1908
1697
  }
1909
1698
  ));
1910
1699
  SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
1911
- var SelectSeparator = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1700
+ var SelectSeparator = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1912
1701
  SelectPrimitive__namespace.Separator,
1913
1702
  {
1914
1703
  ref,
@@ -1917,7 +1706,7 @@ var SelectSeparator = React2__namespace.forwardRef(({ className, ...props }, ref
1917
1706
  }
1918
1707
  ));
1919
1708
  SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
1920
- var Command = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1709
+ var Command = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1921
1710
  cmdk.Command,
1922
1711
  {
1923
1712
  ref,
@@ -1932,7 +1721,7 @@ Command.displayName = cmdk.Command.displayName;
1932
1721
  var CommandDialog = ({ children, ...props }) => {
1933
1722
  return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(DialogContent, { className: "overflow-hidden p-0", children: /* @__PURE__ */ jsxRuntime.jsx(Command, { className: "[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5", children }) }) });
1934
1723
  };
1935
- var CommandInput = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center border-b px-3", "data-cmdk-input-wrapper": "", children: [
1724
+ var CommandInput = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center border-b px-3", "data-cmdk-input-wrapper": "", children: [
1936
1725
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
1937
1726
  /* @__PURE__ */ jsxRuntime.jsx(
1938
1727
  cmdk.Command.Input,
@@ -1947,7 +1736,7 @@ var CommandInput = React2__namespace.forwardRef(({ className, ...props }, ref) =
1947
1736
  )
1948
1737
  ] }));
1949
1738
  CommandInput.displayName = cmdk.Command.Input.displayName;
1950
- var CommandList = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1739
+ var CommandList = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1951
1740
  cmdk.Command.List,
1952
1741
  {
1953
1742
  ref,
@@ -1956,9 +1745,9 @@ var CommandList = React2__namespace.forwardRef(({ className, ...props }, ref) =>
1956
1745
  }
1957
1746
  ));
1958
1747
  CommandList.displayName = cmdk.Command.List.displayName;
1959
- var CommandEmpty = React2__namespace.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command.Empty, { ref, className: "py-6 text-center text-sm", ...props }));
1748
+ var CommandEmpty = React__namespace.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(cmdk.Command.Empty, { ref, className: "py-6 text-center text-sm", ...props }));
1960
1749
  CommandEmpty.displayName = cmdk.Command.Empty.displayName;
1961
- var CommandGroup = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1750
+ var CommandGroup = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1962
1751
  cmdk.Command.Group,
1963
1752
  {
1964
1753
  ref,
@@ -1970,7 +1759,7 @@ var CommandGroup = React2__namespace.forwardRef(({ className, ...props }, ref) =
1970
1759
  }
1971
1760
  ));
1972
1761
  CommandGroup.displayName = cmdk.Command.Group.displayName;
1973
- var CommandSeparator = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1762
+ var CommandSeparator = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1974
1763
  cmdk.Command.Separator,
1975
1764
  {
1976
1765
  ref,
@@ -1979,7 +1768,7 @@ var CommandSeparator = React2__namespace.forwardRef(({ className, ...props }, re
1979
1768
  }
1980
1769
  ));
1981
1770
  CommandSeparator.displayName = cmdk.Command.Separator.displayName;
1982
- var CommandItem = React2__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1771
+ var CommandItem = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
1983
1772
  cmdk.Command.Item,
1984
1773
  {
1985
1774
  ref,
@@ -2001,6 +1790,299 @@ var CommandShortcut = ({ className, ...props }) => {
2001
1790
  );
2002
1791
  };
2003
1792
  CommandShortcut.displayName = "CommandShortcut";
1793
+ var markdownBaseComponents = {
1794
+ h1: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold", "data-testid": "markdown-heading-1", ...props, children }),
1795
+ h2: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-semibold text-base", "data-testid": "markdown-heading-2", ...props, children }),
1796
+ h3: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold text-base", "data-testid": "markdown-heading-3", ...props, children }),
1797
+ h4: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "font-semibold text-base", ...props, children }),
1798
+ h5: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("h5", { className: "font-medium", ...props, children }),
1799
+ strong: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("strong", { className: "font-semibold", ...props, children }),
1800
+ blockquote: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("blockquote", { className: "border-l-2 border-primary pl-4", ...props, children }),
1801
+ ol: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "list-decimal space-y-2 pl-6", "data-testid": "markdown-ordered-list", ...props, children }),
1802
+ ul: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "list-none space-y-2 pl-6", "data-testid": "markdown-unordered-list", ...props, children }),
1803
+ li: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "my-1.5", ...props, children }),
1804
+ table: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("table", { "data-testid": "markdown-table", ...props, children }),
1805
+ th: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("th", { ...props, children }),
1806
+ td: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("td", { ...props, children }),
1807
+ tr: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("tr", { ...props, children }),
1808
+ p: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("p", { className: "whitespace-pre-wrap", ...props, children }),
1809
+ hr: (props) => /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "border-foreground/20", ...props }),
1810
+ sup: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("sup", { className: "text-xs", ...props, children }),
1811
+ sub: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("sub", { className: "text-xs", ...props, children }),
1812
+ div: ({ children, className, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className, ...props, children }),
1813
+ br: (props) => /* @__PURE__ */ jsxRuntime.jsx("br", { ...props }),
1814
+ kbd: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx(
1815
+ "kbd",
1816
+ {
1817
+ className: "px-1.5 py-0.5 text-xs font-mono bg-muted border border-border rounded",
1818
+ ...props,
1819
+ children
1820
+ }
1821
+ ),
1822
+ abbr: ({ children, title, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("abbr", { title, className: "underline decoration-dotted cursor-help", ...props, children }),
1823
+ cite: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("cite", { className: "italic", ...props, children })
1824
+ };
1825
+ var MarkdownStreamingContext = React.createContext(false);
1826
+
1827
+ // src/ai/split-markdown-blocks.ts
1828
+ var LIST_ITEM_RE = /^\s*([-*+]|\d+[.)])\s/;
1829
+ var BLOCKQUOTE_RE = /^\s*>/;
1830
+ function splitMarkdownBlocks(content) {
1831
+ if (!content) return [];
1832
+ const blocks = [];
1833
+ let start = 0;
1834
+ let inFence = false;
1835
+ let i = 0;
1836
+ while (i < content.length) {
1837
+ if (content.startsWith("```", i)) {
1838
+ inFence = !inFence;
1839
+ i += 3;
1840
+ continue;
1841
+ }
1842
+ if (!inFence && content[i] === "\n" && content[i + 1] === "\n") {
1843
+ const before = content.slice(start, i);
1844
+ const lastLine = before.slice(before.lastIndexOf("\n") + 1);
1845
+ const afterStart = i + 2;
1846
+ const nextNewline = content.indexOf("\n", afterStart);
1847
+ const nextLine = content.slice(afterStart, nextNewline === -1 ? void 0 : nextNewline);
1848
+ const bothListItems = LIST_ITEM_RE.test(lastLine) && LIST_ITEM_RE.test(nextLine);
1849
+ const bothBlockquotes = BLOCKQUOTE_RE.test(lastLine) && BLOCKQUOTE_RE.test(nextLine);
1850
+ if (bothListItems || bothBlockquotes) {
1851
+ i += 2;
1852
+ continue;
1853
+ }
1854
+ blocks.push(content.slice(start, afterStart));
1855
+ start = afterStart;
1856
+ i = afterStart;
1857
+ continue;
1858
+ }
1859
+ i++;
1860
+ }
1861
+ if (start < content.length) blocks.push(content.slice(start));
1862
+ return blocks;
1863
+ }
1864
+
1865
+ // src/ai/normalize-citations.ts
1866
+ var CITE_LINK = /\[([^\]\n]+)\]\((#cite-[\w-]+)\)/g;
1867
+ var BLOCK_MARKER = /^(?:[-*+]|\d{1,9}[.)]|#{1,6})[ \t]+/;
1868
+ var LEADING_EMPHASIS = /^(?:\*\*|__|\*|_)+/;
1869
+ var TRAILING_EMPHASIS = /(\*\*|__|\*|_)(:?)$/;
1870
+ function countToken(text, token) {
1871
+ const double = token + token;
1872
+ if (token.length === 2) return text.split(token).length - 1;
1873
+ const withoutDouble = text.split(double).join("");
1874
+ return withoutDouble.split(token).length - 1;
1875
+ }
1876
+ function emphasisTokens(run) {
1877
+ const char = run[0];
1878
+ const tokens = [];
1879
+ let rest = run;
1880
+ while (rest.length > 0) {
1881
+ const size = rest.length >= 2 ? 2 : 1;
1882
+ tokens.push(char.repeat(size));
1883
+ rest = rest.slice(size);
1884
+ }
1885
+ return tokens;
1886
+ }
1887
+ function hoistFromLink(text, before, after) {
1888
+ let body = text;
1889
+ let prefix = "";
1890
+ let suffix = "";
1891
+ if (before.trim() === "") {
1892
+ const marker = BLOCK_MARKER.exec(body);
1893
+ if (marker) {
1894
+ prefix += marker[0];
1895
+ body = body.slice(marker[0].length);
1896
+ }
1897
+ }
1898
+ const leading = LEADING_EMPHASIS.exec(body);
1899
+ if (leading) {
1900
+ let kept = "";
1901
+ let rest = body.slice(leading[0].length);
1902
+ for (const token of emphasisTokens(leading[0]).reverse()) {
1903
+ if (countToken(rest, token) % 2 === 1) {
1904
+ kept = token + kept;
1905
+ continue;
1906
+ }
1907
+ if (countToken(after, token) % 2 === 1) prefix += token;
1908
+ else kept = token + kept;
1909
+ }
1910
+ body = kept + rest;
1911
+ rest = "";
1912
+ }
1913
+ const trailing = TRAILING_EMPHASIS.exec(body);
1914
+ if (trailing) {
1915
+ const token = trailing[1];
1916
+ const inner = body.slice(0, body.length - trailing[0].length);
1917
+ const openedBefore = countToken(before + prefix, token) % 2 === 1;
1918
+ if (countToken(inner, token) % 2 === 0 && openedBefore) {
1919
+ body = inner;
1920
+ suffix = trailing[0];
1921
+ }
1922
+ }
1923
+ return [prefix, body, suffix];
1924
+ }
1925
+ function normalizeLine(line) {
1926
+ if (!line.includes("](#cite-")) return line;
1927
+ return line.replace(CITE_LINK, (match, text, href, offset) => {
1928
+ const before = line.slice(0, offset);
1929
+ const after = line.slice(offset + match.length);
1930
+ const [prefix, body, suffix] = hoistFromLink(text, before, after);
1931
+ if (!prefix && !suffix && body === text) return match;
1932
+ return `${prefix}[${body}](${href})${suffix}`;
1933
+ });
1934
+ }
1935
+ function normalizeCitationMarkup(markdown) {
1936
+ if (!markdown.includes("](#cite-")) return markdown;
1937
+ let inFence = false;
1938
+ return markdown.split("\n").map((line) => {
1939
+ if (/^\s*(```|~~~)/.test(line)) {
1940
+ inFence = !inFence;
1941
+ return line;
1942
+ }
1943
+ return inFence ? line : normalizeLine(line);
1944
+ }).join("\n");
1945
+ }
1946
+ function CodeBlock({ language, code }) {
1947
+ const [copied, setCopied] = React.useState(false);
1948
+ const handleCopy = async () => {
1949
+ try {
1950
+ await navigator.clipboard.writeText(code);
1951
+ setCopied(true);
1952
+ setTimeout(() => setCopied(false), 2e3);
1953
+ } catch {
1954
+ }
1955
+ };
1956
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1957
+ "div",
1958
+ {
1959
+ className: "code-block relative my-3 overflow-hidden rounded-md border border-current/20 bg-current/5",
1960
+ "data-testid": "markdown-code-block",
1961
+ children: [
1962
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between border-b border-current/20 px-3 py-1.5", children: [
1963
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-xs text-muted-foreground", children: language || "code" }),
1964
+ /* @__PURE__ */ jsxRuntime.jsxs(
1965
+ "button",
1966
+ {
1967
+ type: "button",
1968
+ onClick: handleCopy,
1969
+ className: "flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground",
1970
+ title: copied ? "Copied!" : "Copy code",
1971
+ children: [
1972
+ copied ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { size: 12 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Copy, { size: 12 }),
1973
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: copied ? "Copied" : "Copy" })
1974
+ ]
1975
+ }
1976
+ )
1977
+ ] }),
1978
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "overflow-x-auto p-3 text-sm leading-relaxed", children: /* @__PURE__ */ jsxRuntime.jsx("code", { className: chunkRZQACYNQ_cjs.cn("font-mono", language && `language-${language}`), children: code }) })
1979
+ ]
1980
+ }
1981
+ );
1982
+ }
1983
+ var defaultComponents = {
1984
+ ...markdownBaseComponents,
1985
+ a: ({ href, children, ...props }) => {
1986
+ if (href?.startsWith("#cite-")) {
1987
+ return /* @__PURE__ */ jsxRuntime.jsx(
1988
+ "span",
1989
+ {
1990
+ className: "cited-text underline decoration-dotted underline-offset-4",
1991
+ "data-cite": href.slice(6),
1992
+ children
1993
+ }
1994
+ );
1995
+ }
1996
+ const isInternal = !href || href.startsWith("#") || href.startsWith("cite:");
1997
+ return /* @__PURE__ */ jsxRuntime.jsx(
1998
+ "a",
1999
+ {
2000
+ className: "text-primary underline underline-offset-2",
2001
+ href,
2002
+ ...isInternal ? {} : { target: "_blank", rel: "noopener noreferrer" },
2003
+ ...props,
2004
+ children
2005
+ }
2006
+ );
2007
+ },
2008
+ em: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("em", { className: "italic", ...props, children }),
2009
+ code: function MarkdownCode({
2010
+ className,
2011
+ children,
2012
+ ...props
2013
+ }) {
2014
+ const match = /language-(\w+)/.exec(className || "");
2015
+ if (!match) {
2016
+ return /* @__PURE__ */ jsxRuntime.jsx(
2017
+ "code",
2018
+ {
2019
+ className: "rounded bg-current/10 px-1 py-0.5 font-mono text-[0.9em]",
2020
+ "data-testid": "markdown-inline-code",
2021
+ ...props,
2022
+ children
2023
+ }
2024
+ );
2025
+ }
2026
+ return /* @__PURE__ */ jsxRuntime.jsx(CodeBlock, { language: match[1], code: String(children).replace(/\n$/, "") });
2027
+ },
2028
+ // The CodeBlock renders its own <pre>; unwrap react-markdown's wrapper so we
2029
+ // don't nest <pre><pre>.
2030
+ pre: ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }),
2031
+ blockquote: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("blockquote", { className: "border-l-2 border-border pl-4 italic text-muted-foreground", ...props, children }),
2032
+ table: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "my-3 overflow-x-auto rounded-lg border border-border", children: /* @__PURE__ */ jsxRuntime.jsx("table", { "data-testid": "markdown-table", className: "w-full border-collapse text-sm", ...props, children }) }),
2033
+ thead: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-current/10", ...props, children }),
2034
+ th: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("th", { className: "border-b border-border px-3 py-2 text-left font-semibold", ...props, children }),
2035
+ td: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("td", { className: "border-b border-border px-3 py-2 align-top", ...props, children }),
2036
+ // General emphasis marks (GFM `~~strikethrough~~` → <del>, raw <ins>/<mark>).
2037
+ del: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("del", { className: "text-muted-foreground line-through", ...props, children }),
2038
+ ins: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("ins", { className: "underline decoration-primary/60", ...props, children }),
2039
+ mark: ({ children, ...props }) => /* @__PURE__ */ jsxRuntime.jsx("mark", { className: "rounded bg-primary/15 px-0.5 text-inherit", ...props, children })
2040
+ };
2041
+ var remarkPlugins = [remarkGfm__default.default];
2042
+ var rehypePlugins = [rehypeRaw__default.default];
2043
+ var MemoizedBlock = React__namespace.default.memo(function MarkdownBlock({
2044
+ content,
2045
+ components
2046
+ }) {
2047
+ return /* @__PURE__ */ jsxRuntime.jsx(Markdown__default.default, { remarkPlugins, rehypePlugins, components, children: content });
2048
+ });
2049
+ var MarkdownErrorBoundary = class extends React__namespace.default.Component {
2050
+ state = { hasError: false };
2051
+ static getDerivedStateFromError() {
2052
+ return { hasError: true };
2053
+ }
2054
+ render() {
2055
+ return this.state.hasError ? this.props.fallback : this.props.children;
2056
+ }
2057
+ };
2058
+ function MarkdownRendererComponent({
2059
+ children,
2060
+ components: customComponents,
2061
+ isStreaming = false,
2062
+ className,
2063
+ testId = "markdown-renderer"
2064
+ }) {
2065
+ const components = React.useMemo(
2066
+ () => customComponents ? { ...defaultComponents, ...customComponents } : defaultComponents,
2067
+ [customComponents]
2068
+ );
2069
+ const blocks = React.useMemo(() => splitMarkdownBlocks(normalizeCitationMarkup(children)), [children]);
2070
+ return /* @__PURE__ */ jsxRuntime.jsx(
2071
+ MarkdownErrorBoundary,
2072
+ {
2073
+ fallback: /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkRZQACYNQ_cjs.cn("whitespace-pre-wrap break-words", className), children }),
2074
+ children: /* @__PURE__ */ jsxRuntime.jsx(MarkdownStreamingContext.Provider, { value: isStreaming, children: /* @__PURE__ */ jsxRuntime.jsx(
2075
+ "div",
2076
+ {
2077
+ className: chunkRZQACYNQ_cjs.cn("markdown-content space-y-3 break-words leading-relaxed", className),
2078
+ "data-testid": testId,
2079
+ children: blocks.map((block, index) => /* @__PURE__ */ jsxRuntime.jsx(MemoizedBlock, { content: block, components }, index))
2080
+ }
2081
+ ) })
2082
+ }
2083
+ );
2084
+ }
2085
+ var MarkdownRenderer = React__namespace.default.memo(MarkdownRendererComponent);
2004
2086
  var AI_COMPONENTS = {
2005
2087
  a: (p) => /* @__PURE__ */ jsxRuntime.jsx(
2006
2088
  "a",
@@ -2025,7 +2107,7 @@ function AiMarkdown({
2025
2107
  return /* @__PURE__ */ jsxRuntime.jsx(
2026
2108
  MarkdownRenderer,
2027
2109
  {
2028
- className: className ?? "text-sm text-foreground",
2110
+ className: className ?? "text-sm",
2029
2111
  components: AI_COMPONENTS,
2030
2112
  isStreaming,
2031
2113
  testId: "ai-markdown",
@@ -2033,7 +2115,7 @@ function AiMarkdown({
2033
2115
  }
2034
2116
  );
2035
2117
  }
2036
- var EntityPill = React2.forwardRef(function EntityPill2({
2118
+ var EntityPill = React.forwardRef(function EntityPill2({
2037
2119
  icon,
2038
2120
  label,
2039
2121
  secondaryText,
@@ -2738,7 +2820,7 @@ var EmlIcon = ({ size = 16, className = "" }) => {
2738
2820
  );
2739
2821
  };
2740
2822
  var ArbiBotHeadIcon = ({ size = 24, className = "" }) => {
2741
- const maskId = React2.useId();
2823
+ const maskId = React.useId();
2742
2824
  return /* @__PURE__ */ jsxRuntime.jsxs(
2743
2825
  "svg",
2744
2826
  {
@@ -2952,7 +3034,7 @@ var presenceColorClasses = {
2952
3034
  error: "bg-status-busy",
2953
3035
  hidden: "bg-status-offline"
2954
3036
  };
2955
- var UserEntity = React2.memo(function UserEntity2({
3037
+ var UserEntity = React.memo(function UserEntity2({
2956
3038
  size = "md",
2957
3039
  variant = "pill",
2958
3040
  className,
@@ -3464,7 +3546,7 @@ var getEntityLabel = (entityType, form = "SINGULAR") => {
3464
3546
  };
3465
3547
  var EntityIcon = ({ entityType, variant = "DEFAULT", ...props }) => {
3466
3548
  const IconComponent = getEntityIcon(entityType, variant);
3467
- return IconComponent ? React2__namespace.default.createElement(IconComponent, props) : null;
3549
+ return IconComponent ? React__namespace.default.createElement(IconComponent, props) : null;
3468
3550
  };
3469
3551
  var VISIBILITY_ICONS = {
3470
3552
  PRIVATE: lucideReact.MessageSquareLock,
@@ -3475,7 +3557,7 @@ var VisibilityIcon = ({
3475
3557
  ...props
3476
3558
  }) => {
3477
3559
  const IconComponent = isShared ? VISIBILITY_ICONS.SHARED : VISIBILITY_ICONS.PRIVATE;
3478
- return React2__namespace.default.createElement(IconComponent, props);
3560
+ return React__namespace.default.createElement(IconComponent, props);
3479
3561
  };
3480
3562
 
3481
3563
  // src/entities/colors.ts
@@ -3642,7 +3724,7 @@ function UserMenu({
3642
3724
  )
3643
3725
  ] }),
3644
3726
  /* @__PURE__ */ jsxRuntime.jsx(chunkRZQACYNQ_cjs.DropdownMenuSeparator, {}),
3645
- items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(React2.Fragment, { children: [
3727
+ items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
3646
3728
  item.separatorBefore && /* @__PURE__ */ jsxRuntime.jsx(chunkRZQACYNQ_cjs.DropdownMenuSeparator, {}),
3647
3729
  /* @__PURE__ */ jsxRuntime.jsxs(
3648
3730
  chunkRZQACYNQ_cjs.DropdownMenuItem,
@@ -3740,7 +3822,7 @@ function RenameField({
3740
3822
  onCancel,
3741
3823
  testId
3742
3824
  }) {
3743
- const done = React2__namespace.default.useRef(false);
3825
+ const done = React__namespace.default.useRef(false);
3744
3826
  const commit = (value) => {
3745
3827
  if (done.current) return;
3746
3828
  done.current = true;
@@ -3828,8 +3910,8 @@ function DocumentCard({
3828
3910
  const normalised = (status ?? "").toLowerCase();
3829
3911
  const isProcessing = ACTIVE_STATUSES.has(normalised);
3830
3912
  const showStatusMarker = !isProcessing && TERMINAL_STATUSES.has(normalised);
3831
- const [thumbFailed, setThumbFailed] = React2__namespace.default.useState(false);
3832
- const [thumbLandscape, setThumbLandscape] = React2__namespace.default.useState(false);
3913
+ const [thumbFailed, setThumbFailed] = React__namespace.default.useState(false);
3914
+ const [thumbLandscape, setThumbLandscape] = React__namespace.default.useState(false);
3833
3915
  const showThumbnail = !!thumbnailUrl && !thumbFailed && !isProcessing;
3834
3916
  return /* @__PURE__ */ jsxRuntime.jsxs(
3835
3917
  "div",
@@ -4053,8 +4135,9 @@ exports.getTagTypeIcon = getTagTypeIcon;
4053
4135
  exports.getTagTypeLabel = getTagTypeLabel;
4054
4136
  exports.getWorkspaceColor = getWorkspaceColor;
4055
4137
  exports.markdownBaseComponents = markdownBaseComponents;
4138
+ exports.normalizeCitationMarkup = normalizeCitationMarkup;
4056
4139
  exports.splitMarkdownBlocks = splitMarkdownBlocks;
4057
4140
  exports.toggleVariants = toggleVariants;
4058
4141
  exports.useAudioRecorder = useAudioRecorder;
4059
- //# sourceMappingURL=chunk-OU2QLIKS.cjs.map
4060
- //# sourceMappingURL=chunk-OU2QLIKS.cjs.map
4142
+ //# sourceMappingURL=chunk-ORKGCXG3.cjs.map
4143
+ //# sourceMappingURL=chunk-ORKGCXG3.cjs.map