@djangocfg/ui-tools 2.1.385 → 2.1.389

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 (80) hide show
  1. package/README.md +25 -11
  2. package/dist/ChatRoot-EFNXQXXN.cjs +15 -0
  3. package/dist/{ChatRoot-JVR3M3H2.mjs.map → ChatRoot-EFNXQXXN.cjs.map} +1 -1
  4. package/dist/ChatRoot-FITF5RVP.mjs +6 -0
  5. package/dist/{ChatRoot-LXIUBOXF.cjs.map → ChatRoot-FITF5RVP.mjs.map} +1 -1
  6. package/dist/{DocsLayout-2P3ONDWJ.mjs → DocsLayout-EKASBSP7.mjs} +3 -3
  7. package/dist/{DocsLayout-2P3ONDWJ.mjs.map → DocsLayout-EKASBSP7.mjs.map} +1 -1
  8. package/dist/{DocsLayout-2YZNS5VK.cjs → DocsLayout-OURFYWQE.cjs} +8 -8
  9. package/dist/{DocsLayout-2YZNS5VK.cjs.map → DocsLayout-OURFYWQE.cjs.map} +1 -1
  10. package/dist/MapContainer-AKIPABJK.mjs +4 -0
  11. package/dist/MapContainer-AKIPABJK.mjs.map +1 -0
  12. package/dist/MapContainer-STVDMC36.cjs +17 -0
  13. package/dist/MapContainer-STVDMC36.cjs.map +1 -0
  14. package/dist/{chunk-HIK6BPL7.mjs → chunk-2NG4SXEP.mjs} +6 -5
  15. package/dist/chunk-2NG4SXEP.mjs.map +1 -0
  16. package/dist/chunk-4LFB7I5K.cjs +1387 -0
  17. package/dist/chunk-4LFB7I5K.cjs.map +1 -0
  18. package/dist/{MapContainer-76YL2JXL.cjs → chunk-5D2OCOPQ.cjs} +3 -2
  19. package/dist/chunk-5D2OCOPQ.cjs.map +1 -0
  20. package/dist/chunk-6ZX2G25W.mjs +1361 -0
  21. package/dist/chunk-6ZX2G25W.mjs.map +1 -0
  22. package/dist/{MapContainer-7HXBI3OH.mjs → chunk-7CWGZPO3.mjs} +3 -3
  23. package/dist/chunk-7CWGZPO3.mjs.map +1 -0
  24. package/dist/{chunk-FIRK5CEH.cjs → chunk-7IYXZUJO.cjs} +8 -4
  25. package/dist/chunk-7IYXZUJO.cjs.map +1 -0
  26. package/dist/{chunk-PEKBT75W.mjs → chunk-DMX7W4XZ.mjs} +53 -1387
  27. package/dist/chunk-DMX7W4XZ.mjs.map +1 -0
  28. package/dist/chunk-NTVBIIUD.mjs +1439 -0
  29. package/dist/chunk-NTVBIIUD.mjs.map +1 -0
  30. package/dist/{chunk-HPK3EWBF.cjs → chunk-TBSHZO5R.cjs} +50 -1409
  31. package/dist/chunk-TBSHZO5R.cjs.map +1 -0
  32. package/dist/chunk-W75B7Y6C.cjs +1478 -0
  33. package/dist/chunk-W75B7Y6C.cjs.map +1 -0
  34. package/dist/index.cjs +1269 -1790
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +660 -623
  37. package/dist/index.d.ts +660 -623
  38. package/dist/index.mjs +856 -1427
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/launcher-5Y42OBSN.mjs +6 -0
  41. package/dist/launcher-5Y42OBSN.mjs.map +1 -0
  42. package/dist/launcher-PMW2YB24.cjs +59 -0
  43. package/dist/launcher-PMW2YB24.cjs.map +1 -0
  44. package/package.json +23 -18
  45. package/src/components/index.ts +2 -2
  46. package/src/index.ts +20 -2
  47. package/src/tools/AudioPlayer/lazy.tsx +100 -0
  48. package/src/tools/Chat/README.md +85 -1
  49. package/src/tools/Chat/components/MessageBubble.tsx +1 -1
  50. package/src/tools/Chat/context/ChatProvider.tsx +42 -0
  51. package/src/tools/Chat/index.ts +1 -1
  52. package/src/tools/Chat/lazy.tsx +300 -1
  53. package/src/tools/CodeEditor/lazy.tsx +70 -0
  54. package/src/tools/Map/lazy.tsx +38 -1
  55. package/src/tools/MarkdownEditor/lazy.tsx +42 -0
  56. package/src/{components/markdown → tools}/MarkdownMessage/CodeBlock.tsx +1 -1
  57. package/src/{components/markdown → tools}/MarkdownMessage/CollapseToggle.tsx +1 -1
  58. package/src/{components/markdown → tools}/MarkdownMessage/MarkdownMessage.tsx +1 -1
  59. package/src/{components/markdown → tools}/MarkdownMessage/components.tsx +2 -2
  60. package/src/tools/OpenapiViewer/components/DocsLayout/ApiIntroSection.tsx +1 -1
  61. package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Header/index.tsx +1 -1
  62. package/src/tools/SpeechRecognition/README.md +48 -0
  63. package/dist/ChatRoot-JVR3M3H2.mjs +0 -5
  64. package/dist/ChatRoot-LXIUBOXF.cjs +0 -14
  65. package/dist/MapContainer-76YL2JXL.cjs.map +0 -1
  66. package/dist/MapContainer-7HXBI3OH.mjs.map +0 -1
  67. package/dist/chunk-FIRK5CEH.cjs.map +0 -1
  68. package/dist/chunk-HIK6BPL7.mjs.map +0 -1
  69. package/dist/chunk-HPK3EWBF.cjs.map +0 -1
  70. package/dist/chunk-PEKBT75W.mjs.map +0 -1
  71. package/src/components/markdown/index.ts +0 -19
  72. /package/src/{components/markdown → hooks}/useCollapsibleContent.ts +0 -0
  73. /package/src/{components/markdown → tools}/MarkdownMessage/ActionRow.tsx +0 -0
  74. /package/src/{components/markdown → tools}/MarkdownMessage/ChatMessageRow.tsx +0 -0
  75. /package/src/{components/markdown → tools}/MarkdownMessage/README.md +0 -0
  76. /package/src/{components/markdown → tools}/MarkdownMessage/index.ts +0 -0
  77. /package/src/{components/markdown → tools}/MarkdownMessage/linkRules.ts +0 -0
  78. /package/src/{components/markdown → tools}/MarkdownMessage/plainText.ts +0 -0
  79. /package/src/{components/markdown → tools}/MarkdownMessage/sanitize.ts +0 -0
  80. /package/src/{components/markdown → tools}/MarkdownMessage/types.ts +0 -0
@@ -0,0 +1,1478 @@
1
+ 'use strict';
2
+
3
+ var chunkADEN3UA4_cjs = require('./chunk-ADEN3UA4.cjs');
4
+ var chunkOLISEQHS_cjs = require('./chunk-OLISEQHS.cjs');
5
+ var lucideReact = require('lucide-react');
6
+ var hooks = require('@djangocfg/ui-core/hooks');
7
+ var lib = require('@djangocfg/ui-core/lib');
8
+ var jsxRuntime = require('react/jsx-runtime');
9
+ var React = require('react');
10
+ var components = require('@djangocfg/ui-core/components');
11
+ var i18n = require('@djangocfg/i18n');
12
+
13
+ function _interopNamespace(e) {
14
+ if (e && e.__esModule) return e;
15
+ var n = Object.create(null);
16
+ if (e) {
17
+ Object.keys(e).forEach(function (k) {
18
+ if (k !== 'default') {
19
+ var d = Object.getOwnPropertyDescriptor(e, k);
20
+ Object.defineProperty(n, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: function () { return e[k]; }
23
+ });
24
+ }
25
+ });
26
+ }
27
+ n.default = e;
28
+ return Object.freeze(n);
29
+ }
30
+
31
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
32
+
33
+ var SIZE_PX = { sm: 44, md: 56, lg: 64 };
34
+ var ICON_PX = { sm: 18, md: 22, lg: 26 };
35
+ function useEffectiveFABSize(size, inline) {
36
+ const isPhone = hooks.useIsPhone();
37
+ const isBelowDesktop = hooks.useIsTabletOrBelow();
38
+ if (size !== "responsive") return size;
39
+ if (inline) return "md";
40
+ if (isPhone) return "sm";
41
+ if (isBelowDesktop) return "md";
42
+ return "lg";
43
+ }
44
+ chunkOLISEQHS_cjs.__name(useEffectiveFABSize, "useEffectiveFABSize");
45
+ function positionStyle(position, offset) {
46
+ const [vert, horiz] = position.split("-");
47
+ return { [vert]: offset, [horiz]: offset };
48
+ }
49
+ chunkOLISEQHS_cjs.__name(positionStyle, "positionStyle");
50
+ function tooltipSideClasses(position) {
51
+ return position.endsWith("right") ? "right-full mr-3 origin-right" : "left-full ml-3 origin-left";
52
+ }
53
+ chunkOLISEQHS_cjs.__name(tooltipSideClasses, "tooltipSideClasses");
54
+ function Badge({ value }) {
55
+ const display = value > 9 ? "9+" : String(value);
56
+ return /* @__PURE__ */ jsxRuntime.jsx(
57
+ "span",
58
+ {
59
+ "aria-hidden": "true",
60
+ className: lib.cn(
61
+ "absolute -right-1 -top-1 inline-flex min-w-[18px] h-[18px] items-center justify-center",
62
+ "rounded-full bg-destructive px-1 text-[10px] font-semibold leading-none text-destructive-foreground",
63
+ "ring-2 ring-background"
64
+ ),
65
+ children: display
66
+ }
67
+ );
68
+ }
69
+ chunkOLISEQHS_cjs.__name(Badge, "Badge");
70
+ function PulseDot() {
71
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "absolute right-1 top-1", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "relative inline-flex h-2.5 w-2.5", children: [
72
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute inset-0 rounded-full bg-destructive opacity-75 animate-ping" }),
73
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "relative inline-flex h-2.5 w-2.5 rounded-full bg-destructive ring-2 ring-background" })
74
+ ] }) });
75
+ }
76
+ chunkOLISEQHS_cjs.__name(PulseDot, "PulseDot");
77
+ function Tooltip({ text, side }) {
78
+ return /* @__PURE__ */ jsxRuntime.jsx(
79
+ "span",
80
+ {
81
+ role: "tooltip",
82
+ className: lib.cn(
83
+ "pointer-events-none absolute top-1/2 -translate-y-1/2 whitespace-nowrap",
84
+ "rounded-md bg-popover px-2.5 py-1 text-xs font-medium text-popover-foreground shadow-md",
85
+ "border border-border opacity-0 scale-95 transition-all duration-150",
86
+ "group-hover:opacity-100 group-hover:scale-100",
87
+ "group-focus-within:opacity-100 group-focus-within:scale-100",
88
+ side
89
+ ),
90
+ children: text
91
+ }
92
+ );
93
+ }
94
+ chunkOLISEQHS_cjs.__name(Tooltip, "Tooltip");
95
+ function ChatFAB({
96
+ onClick,
97
+ ariaLabel = "Open chat",
98
+ icon,
99
+ variant = "simple",
100
+ size = "responsive",
101
+ position = "bottom-right",
102
+ offset = 24,
103
+ zIndex = 9999,
104
+ pulse = false,
105
+ badge,
106
+ tooltip,
107
+ inline = false,
108
+ className,
109
+ style
110
+ }) {
111
+ const effectiveSize = useEffectiveFABSize(size, inline);
112
+ const px = SIZE_PX[effectiveSize];
113
+ const iconPx = ICON_PX[effectiveSize];
114
+ const renderedIcon = icon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Bot, { size: iconPx });
115
+ const baseButton = lib.cn(
116
+ "relative grid place-items-center rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
117
+ "transition-transform hover:scale-105"
118
+ );
119
+ return /* @__PURE__ */ jsxRuntime.jsxs(
120
+ "div",
121
+ {
122
+ className: lib.cn("group", inline ? "relative inline-flex" : "fixed"),
123
+ style: inline ? void 0 : { ...positionStyle(position, offset), zIndex },
124
+ children: [
125
+ variant === "animated" && /* @__PURE__ */ jsxRuntime.jsx(
126
+ AnimatedFAB,
127
+ {
128
+ ariaLabel,
129
+ onClick,
130
+ size: px,
131
+ className,
132
+ style,
133
+ children: renderedIcon
134
+ }
135
+ ),
136
+ variant === "glass" && /* @__PURE__ */ jsxRuntime.jsxs(
137
+ "button",
138
+ {
139
+ type: "button",
140
+ "aria-label": ariaLabel,
141
+ onClick,
142
+ className: lib.cn(
143
+ baseButton,
144
+ "border border-border/40 bg-background/60 text-foreground shadow-lg backdrop-blur-xl",
145
+ "hover:bg-background/80",
146
+ className
147
+ ),
148
+ style: { width: px, height: px, ...style },
149
+ children: [
150
+ renderedIcon,
151
+ badge !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(Badge, { value: badge }) : pulse ? /* @__PURE__ */ jsxRuntime.jsx(PulseDot, {}) : null
152
+ ]
153
+ }
154
+ ),
155
+ variant === "simple" && /* @__PURE__ */ jsxRuntime.jsxs(
156
+ "button",
157
+ {
158
+ type: "button",
159
+ "aria-label": ariaLabel,
160
+ onClick,
161
+ className: lib.cn(
162
+ baseButton,
163
+ "bg-primary text-primary-foreground hover:bg-primary/90 shadow-2xl",
164
+ className
165
+ ),
166
+ style: { width: px, height: px, ...style },
167
+ children: [
168
+ renderedIcon,
169
+ badge !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(Badge, { value: badge }) : pulse ? /* @__PURE__ */ jsxRuntime.jsx(PulseDot, {}) : null
170
+ ]
171
+ }
172
+ ),
173
+ tooltip && /* @__PURE__ */ jsxRuntime.jsx(Tooltip, { text: tooltip, side: tooltipSideClasses(position) })
174
+ ]
175
+ }
176
+ );
177
+ }
178
+ chunkOLISEQHS_cjs.__name(ChatFAB, "ChatFAB");
179
+ function AnimatedFAB({ ariaLabel, onClick, size, className, style, children }) {
180
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
181
+ /* @__PURE__ */ jsxRuntime.jsx("style", { children: ANIMATED_CSS }),
182
+ /* @__PURE__ */ jsxRuntime.jsx(
183
+ "div",
184
+ {
185
+ className: lib.cn("cmdop-fab-anim", className),
186
+ style: { width: size, height: size, ...style },
187
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cmdop-fab-anim-glow", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "cmdop-fab-anim-wrap", children: [
188
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cmdop-fab-anim-grad cmdop-fab-anim-grad-1" }),
189
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cmdop-fab-anim-grad cmdop-fab-anim-grad-2" }),
190
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "cmdop-fab-anim-inner" }),
191
+ /* @__PURE__ */ jsxRuntime.jsx(
192
+ "button",
193
+ {
194
+ type: "button",
195
+ "aria-label": ariaLabel,
196
+ onClick,
197
+ className: "cmdop-fab-anim-btn",
198
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "cmdop-fab-anim-icon", children })
199
+ }
200
+ )
201
+ ] }) })
202
+ }
203
+ )
204
+ ] });
205
+ }
206
+ chunkOLISEQHS_cjs.__name(AnimatedFAB, "AnimatedFAB");
207
+ var ANIMATED_CSS = `
208
+ .cmdop-fab-anim {
209
+ position: relative;
210
+ pointer-events: auto;
211
+ }
212
+ .cmdop-fab-anim-glow {
213
+ width: 100%; height: 100%;
214
+ border-radius: 50%;
215
+ overflow: hidden;
216
+ animation:
217
+ cmdop-fab-entrance 0.6s cubic-bezier(0.34, 1.45, 0.64, 1) forwards,
218
+ cmdop-fab-glow-shift 8s ease-in-out 0.6s infinite;
219
+ }
220
+ .cmdop-fab-anim-wrap {
221
+ position: relative; width: 100%; height: 100%;
222
+ border-radius: 50%; overflow: hidden;
223
+ }
224
+ .cmdop-fab-anim-grad { position: absolute; inset: 0; border-radius: 50%; }
225
+ .cmdop-fab-anim-grad-1 {
226
+ background: conic-gradient(
227
+ from 0deg,
228
+ #fbbf24 0%, rgba(251,191,36,0) 15%,
229
+ rgba(168,85,247,0) 20%, #a855f7 35%, rgba(168,85,247,0) 50%,
230
+ rgba(20,184,166,0) 55%, #14b8a6 70%, rgba(20,184,166,0) 85%,
231
+ rgba(236,72,153,0) 88%, #ec4899 97%, #fbbf24 100%
232
+ );
233
+ animation: cmdop-fab-rotate 7s linear infinite;
234
+ filter: blur(1px); opacity: 0.95;
235
+ }
236
+ .cmdop-fab-anim-grad-2 {
237
+ inset: 1px;
238
+ background: conic-gradient(
239
+ from 180deg,
240
+ #a855f7 0%, rgba(168,85,247,0) 20%,
241
+ rgba(20,184,166,0) 30%, #14b8a6 50%, rgba(20,184,166,0) 70%,
242
+ rgba(251,191,36,0) 75%, #fbbf24 95%, #a855f7 100%
243
+ );
244
+ animation: cmdop-fab-rotate-rev 9s linear infinite;
245
+ filter: blur(0.75px); opacity: 0.7;
246
+ }
247
+ .cmdop-fab-anim-inner {
248
+ position: absolute; inset: 3px; border-radius: 50%;
249
+ background: rgba(10, 10, 10, 0.65);
250
+ backdrop-filter: blur(12px) saturate(1.8);
251
+ -webkit-backdrop-filter: blur(12px) saturate(1.8);
252
+ animation: cmdop-fab-inner-glow 5s ease-in-out infinite;
253
+ }
254
+ .cmdop-fab-anim-btn {
255
+ position: absolute; inset: 2px;
256
+ border-radius: 50%; border: none; background: transparent;
257
+ cursor: pointer; display: flex; align-items: center; justify-content: center;
258
+ transition: transform 0.2s;
259
+ }
260
+ .cmdop-fab-anim-btn:hover { transform: scale(1.06); }
261
+ .cmdop-fab-anim-icon {
262
+ color: #fbbf24; display: flex;
263
+ filter: drop-shadow(0 0 6px rgba(251,191,36,0.8));
264
+ animation: cmdop-fab-icon-pulse 2.5s ease-in-out infinite;
265
+ }
266
+ @keyframes cmdop-fab-rotate { to { transform: rotate(360deg); } }
267
+ @keyframes cmdop-fab-rotate-rev { to { transform: rotate(-360deg); } }
268
+ @keyframes cmdop-fab-entrance {
269
+ 0% { transform: scale(0); }
270
+ 50% { transform: scale(1.08); }
271
+ 70% { transform: scale(0.98); }
272
+ 100% { transform: scale(1); }
273
+ }
274
+ @keyframes cmdop-fab-glow-shift {
275
+ 0%, 100% { box-shadow: 0 0 20px rgba(251,191,36,0.5), 0 0 40px rgba(168,85,247,0.3); }
276
+ 33% { box-shadow: 0 0 20px rgba(168,85,247,0.5), 0 0 40px rgba(20,184,166,0.3); }
277
+ 66% { box-shadow: 0 0 20px rgba(20,184,166,0.5), 0 0 40px rgba(236,72,153,0.3); }
278
+ }
279
+ @keyframes cmdop-fab-icon-pulse {
280
+ 0%, 100% { opacity: 1; transform: scale(1); }
281
+ 50% { opacity: 0.85; transform: scale(1.15); }
282
+ }
283
+ @keyframes cmdop-fab-inner-glow {
284
+ 0%, 100% { box-shadow: inset 0 0 20px rgba(251,191,36,0.25), inset 0 0 40px rgba(168,85,247,0.15); }
285
+ 50% { box-shadow: inset 0 0 25px rgba(168,85,247,0.3), inset 0 0 45px rgba(20,184,166,0.2); }
286
+ }
287
+ `;
288
+ function ChatHeader({
289
+ title,
290
+ icon,
291
+ actions,
292
+ showClose = true,
293
+ onClose,
294
+ closeLabel = "Close",
295
+ closeSlot,
296
+ className
297
+ }) {
298
+ return /* @__PURE__ */ jsxRuntime.jsxs(
299
+ "header",
300
+ {
301
+ className: lib.cn(
302
+ "border-border bg-muted/30 flex shrink-0 items-center justify-between border-b px-4 py-2.5",
303
+ className
304
+ ),
305
+ children: [
306
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 items-center gap-2 text-sm font-semibold", children: [
307
+ icon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Bot, { className: "text-primary h-4 w-4 shrink-0" }),
308
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: title })
309
+ ] }),
310
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-0.5", children: [
311
+ actions,
312
+ closeSlot ?? (showClose && onClose && /* @__PURE__ */ jsxRuntime.jsx(
313
+ components.Button,
314
+ {
315
+ variant: "ghost",
316
+ size: "sm",
317
+ onClick: onClose,
318
+ "aria-label": closeLabel,
319
+ className: "-mr-1 h-7 w-7 p-0",
320
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" })
321
+ }
322
+ ))
323
+ ] })
324
+ ]
325
+ }
326
+ );
327
+ }
328
+ chunkOLISEQHS_cjs.__name(ChatHeader, "ChatHeader");
329
+ function useChatPresence(open, exitDurationMs = 200) {
330
+ const [phase, setPhase] = React.useState("hidden");
331
+ const timerRef = React.useRef(null);
332
+ React.useEffect(() => {
333
+ if (timerRef.current) clearTimeout(timerRef.current);
334
+ if (open) {
335
+ setPhase("entering");
336
+ timerRef.current = setTimeout(() => setPhase("visible"), 16);
337
+ } else {
338
+ setPhase("leaving");
339
+ timerRef.current = setTimeout(() => setPhase("hidden"), exitDurationMs);
340
+ }
341
+ return () => {
342
+ if (timerRef.current) clearTimeout(timerRef.current);
343
+ };
344
+ }, [open, exitDurationMs]);
345
+ return phase;
346
+ }
347
+ chunkOLISEQHS_cjs.__name(useChatPresence, "useChatPresence");
348
+ function dockPositionStyle(position, horizontal, vertical) {
349
+ const [vert, horiz] = position.split("-");
350
+ return { [vert]: vertical, [horiz]: horizontal };
351
+ }
352
+ chunkOLISEQHS_cjs.__name(dockPositionStyle, "dockPositionStyle");
353
+ function ChatDock({
354
+ open,
355
+ onClose,
356
+ children,
357
+ mode = "popover",
358
+ side = "right",
359
+ title = "Chat",
360
+ icon,
361
+ headerActions,
362
+ hideHeader = false,
363
+ closeLabel,
364
+ width,
365
+ height = 720,
366
+ position = "bottom-right",
367
+ offset,
368
+ exitDurationMs = 200,
369
+ zIndex = 1e4,
370
+ ariaLabel,
371
+ className,
372
+ mobileFullscreen = true,
373
+ disablePortal = false,
374
+ inline = false,
375
+ reserveBodySpace
376
+ }) {
377
+ const phase = useChatPresence(open, exitDurationMs);
378
+ const isMobile = hooks.useIsMobile();
379
+ const isBelowDesktop = hooks.useIsTabletOrBelow();
380
+ const effectiveMode = mode === "side" && !isBelowDesktop ? "side" : "popover";
381
+ const fullscreen = mobileFullscreen && isMobile;
382
+ const wantsReserve = !inline && !fullscreen && effectiveMode === "side" && (reserveBodySpace ?? true);
383
+ const resolvedSideWidth = width ?? 420;
384
+ React.useEffect(() => {
385
+ if (!wantsReserve || phase === "hidden") return;
386
+ const body = document.body;
387
+ if (!body) return;
388
+ const cssVar = `${resolvedSideWidth}px`;
389
+ const padKey = side === "right" ? "paddingRight" : "paddingLeft";
390
+ const prevPad = body.style[padKey];
391
+ const prevVar = body.style.getPropertyValue("--chat-dock-reserve");
392
+ body.style[padKey] = cssVar;
393
+ body.style.setProperty("--chat-dock-reserve", cssVar);
394
+ return () => {
395
+ body.style[padKey] = prevPad;
396
+ if (prevVar) body.style.setProperty("--chat-dock-reserve", prevVar);
397
+ else body.style.removeProperty("--chat-dock-reserve");
398
+ };
399
+ }, [wantsReserve, phase, side, resolvedSideWidth]);
400
+ if (phase === "hidden") return null;
401
+ const animating = phase === "entering" || phase === "leaving";
402
+ const horizontal = offset?.horizontal ?? 24;
403
+ const vertical = offset?.vertical ?? 96;
404
+ const resolvedWidth = width ?? (effectiveMode === "side" ? resolvedSideWidth : 480);
405
+ let containerStyle;
406
+ let cornerClass;
407
+ const dynVH = "100dvh";
408
+ if (inline) {
409
+ containerStyle = {
410
+ position: "relative",
411
+ width: resolvedWidth,
412
+ height,
413
+ maxHeight: `calc(${dynVH} - 16px)`,
414
+ pointerEvents: phase === "visible" ? "auto" : "none"
415
+ };
416
+ cornerClass = "rounded-xl border";
417
+ } else if (fullscreen) {
418
+ containerStyle = {
419
+ position: "fixed",
420
+ top: 0,
421
+ [side === "left" ? "left" : "right"]: 0,
422
+ width: "100vw",
423
+ height: dynVH,
424
+ zIndex,
425
+ pointerEvents: phase === "visible" ? "auto" : "none"
426
+ };
427
+ cornerClass = "rounded-none border-0";
428
+ } else if (effectiveMode === "side") {
429
+ containerStyle = {
430
+ position: "fixed",
431
+ top: 0,
432
+ [side]: 0,
433
+ height: dynVH,
434
+ zIndex,
435
+ width: `min(${resolvedWidth}px, 100vw)`,
436
+ pointerEvents: phase === "visible" ? "auto" : "none"
437
+ };
438
+ cornerClass = side === "right" ? "rounded-none border-l" : "rounded-none border-r";
439
+ } else {
440
+ const heightCap = `calc(${dynVH} - ${vertical + 24}px)`;
441
+ containerStyle = {
442
+ position: "fixed",
443
+ ...dockPositionStyle(position, horizontal, vertical),
444
+ zIndex,
445
+ width: `min(${resolvedWidth}px, calc(100vw - 32px))`,
446
+ height: `min(${height}px, ${heightCap})`,
447
+ minHeight: `min(320px, ${heightCap})`,
448
+ pointerEvents: phase === "visible" ? "auto" : "none"
449
+ };
450
+ cornerClass = "rounded-xl border";
451
+ }
452
+ const enterClass = (() => {
453
+ if (fullscreen) return "opacity-0";
454
+ if (effectiveMode === "side") {
455
+ return side === "right" ? "opacity-0 translate-x-4" : "opacity-0 -translate-x-4";
456
+ }
457
+ return "opacity-0 scale-95 translate-y-2";
458
+ })();
459
+ const visibleClass = "opacity-100 scale-100 translate-y-0 translate-x-0";
460
+ return /* @__PURE__ */ jsxRuntime.jsx(components.Portal, { disablePortal: disablePortal || inline, children: /* @__PURE__ */ jsxRuntime.jsxs(
461
+ "div",
462
+ {
463
+ role: "dialog",
464
+ "aria-label": ariaLabel ?? (typeof title === "string" ? title : "Chat"),
465
+ "aria-hidden": phase === "leaving",
466
+ className: lib.cn(
467
+ "bg-popover text-popover-foreground border-border",
468
+ "flex flex-col overflow-hidden shadow-2xl",
469
+ cornerClass,
470
+ "transition-all duration-200 ease-out",
471
+ animating ? enterClass : visibleClass,
472
+ className
473
+ ),
474
+ style: containerStyle,
475
+ children: [
476
+ !hideHeader && /* @__PURE__ */ jsxRuntime.jsx(
477
+ ChatHeader,
478
+ {
479
+ title,
480
+ icon,
481
+ actions: headerActions,
482
+ onClose,
483
+ closeLabel
484
+ }
485
+ ),
486
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-h-0 min-w-0 flex-1 overflow-hidden", children })
487
+ ]
488
+ }
489
+ ) });
490
+ }
491
+ chunkOLISEQHS_cjs.__name(ChatDock, "ChatDock");
492
+ var ChatHeaderActionButton = React.forwardRef(
493
+ /* @__PURE__ */ chunkOLISEQHS_cjs.__name(function ChatHeaderActionButton2({ icon, ariaLabel, badge, destructive, loading, disabled, className, ...rest }, ref) {
494
+ return /* @__PURE__ */ jsxRuntime.jsxs(
495
+ "button",
496
+ {
497
+ ref,
498
+ type: "button",
499
+ "aria-label": ariaLabel,
500
+ title: ariaLabel,
501
+ disabled: disabled || loading,
502
+ className: lib.cn(
503
+ "relative inline-flex h-7 w-7 items-center justify-center rounded-md",
504
+ "text-muted-foreground transition-colors",
505
+ "hover:bg-accent hover:text-foreground",
506
+ "focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
507
+ "disabled:opacity-50 disabled:cursor-not-allowed",
508
+ destructive && "hover:bg-destructive/15 hover:text-destructive",
509
+ loading && "animate-pulse",
510
+ className
511
+ ),
512
+ ...rest,
513
+ children: [
514
+ icon,
515
+ badge !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
516
+ "span",
517
+ {
518
+ "aria-hidden": "true",
519
+ className: "absolute -right-0.5 -top-0.5 inline-flex min-w-[14px] h-[14px] items-center justify-center rounded-full bg-destructive px-1 text-[9px] font-semibold leading-none text-destructive-foreground ring-2 ring-background",
520
+ children: badge > 9 ? "9+" : badge
521
+ }
522
+ )
523
+ ]
524
+ }
525
+ );
526
+ }, "ChatHeaderActionButton")
527
+ );
528
+ function ChatHeaderModeToggle({
529
+ mode,
530
+ onToggle,
531
+ expandLabel = "Dock to side",
532
+ collapseLabel = "Back to popover",
533
+ forceVisible = false
534
+ }) {
535
+ const isBelowDesktop = hooks.useIsTabletOrBelow();
536
+ if (isBelowDesktop && !forceVisible) return null;
537
+ const isSide = mode === "side";
538
+ return /* @__PURE__ */ jsxRuntime.jsx(
539
+ ChatHeaderActionButton,
540
+ {
541
+ icon: isSide ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelRightClose, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelRightOpen, { className: "h-3.5 w-3.5" }),
542
+ ariaLabel: isSide ? collapseLabel : expandLabel,
543
+ onClick: onToggle
544
+ }
545
+ );
546
+ }
547
+ chunkOLISEQHS_cjs.__name(ChatHeaderModeToggle, "ChatHeaderModeToggle");
548
+ function ChatHeaderAudioToggle({
549
+ muted,
550
+ onToggle,
551
+ unmuteLabel = "Unmute notifications",
552
+ muteLabel = "Mute notifications"
553
+ }) {
554
+ return /* @__PURE__ */ jsxRuntime.jsx(
555
+ ChatHeaderActionButton,
556
+ {
557
+ icon: muted ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.VolumeX, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Volume2, { className: "h-3.5 w-3.5" }),
558
+ ariaLabel: muted ? unmuteLabel : muteLabel,
559
+ onClick: onToggle
560
+ }
561
+ );
562
+ }
563
+ chunkOLISEQHS_cjs.__name(ChatHeaderAudioToggle, "ChatHeaderAudioToggle");
564
+ function useChatReset(opts) {
565
+ const { onReset, onSuccess, onError } = opts;
566
+ const [isResetting, setIsResetting] = React.useState(false);
567
+ const reset = React.useCallback(async () => {
568
+ if (isResetting) return false;
569
+ setIsResetting(true);
570
+ try {
571
+ const ok = await onReset();
572
+ if (ok) onSuccess?.();
573
+ else onError?.();
574
+ return ok;
575
+ } catch (err) {
576
+ onError?.(err);
577
+ return false;
578
+ } finally {
579
+ setIsResetting(false);
580
+ }
581
+ }, [isResetting, onReset, onSuccess, onError]);
582
+ return { reset, isResetting };
583
+ }
584
+ chunkOLISEQHS_cjs.__name(useChatReset, "useChatReset");
585
+ var DEFAULT_TITLE = "Clear conversation?";
586
+ var DEFAULT_MESSAGE = "The assistant will forget this session and start a new one. This cannot be undone.";
587
+ var DEFAULT_LABEL = "Clear conversation";
588
+ function ChatHeaderResetButton({
589
+ onReset,
590
+ onSuccess,
591
+ onError,
592
+ confirm = true,
593
+ confirmTitle = DEFAULT_TITLE,
594
+ confirmMessage = DEFAULT_MESSAGE,
595
+ ariaLabel = DEFAULT_LABEL
596
+ }) {
597
+ const { reset, isResetting } = useChatReset({ onReset, onSuccess, onError });
598
+ const handleClick = /* @__PURE__ */ chunkOLISEQHS_cjs.__name(async () => {
599
+ if (confirm) {
600
+ const api = typeof window !== "undefined" ? window.dialog : void 0;
601
+ if (api?.confirm) {
602
+ const ok = await api.confirm({
603
+ title: confirmTitle,
604
+ message: confirmMessage,
605
+ variant: "destructive",
606
+ confirmText: "Clear",
607
+ cancelText: "Cancel"
608
+ });
609
+ if (!ok) return;
610
+ } else if (typeof window !== "undefined" && typeof window.confirm === "function") {
611
+ const ok = window.confirm(`${confirmTitle}
612
+
613
+ ${confirmMessage}`);
614
+ if (!ok) return;
615
+ }
616
+ }
617
+ await reset();
618
+ }, "handleClick");
619
+ return /* @__PURE__ */ jsxRuntime.jsx(
620
+ ChatHeaderActionButton,
621
+ {
622
+ icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RotateCcw, { className: "h-3.5 w-3.5" }),
623
+ ariaLabel,
624
+ onClick: handleClick,
625
+ loading: isResetting,
626
+ destructive: true
627
+ }
628
+ );
629
+ }
630
+ chunkOLISEQHS_cjs.__name(ChatHeaderResetButton, "ChatHeaderResetButton");
631
+
632
+ // src/tools/SpeechRecognition/core/languages-catalog.ts
633
+ var WEB_SPEECH_LANGUAGES = [
634
+ { name: "Afrikaans", iso: "af", englishName: "afrikaans", dialects: [{ code: "af-ZA", region: "South Africa" }] },
635
+ { name: "\u12A0\u121B\u122D\u129B", iso: "am", englishName: "amharic", dialects: [{ code: "am-ET", region: "Ethiopia" }] },
636
+ { name: "Az\u0259rbaycanca", iso: "az", englishName: "azerbaijani", dialects: [{ code: "az-AZ", region: "Azerbaijan" }] },
637
+ {
638
+ name: "\u09AC\u09BE\u0982\u09B2\u09BE",
639
+ iso: "bn",
640
+ englishName: "bengali",
641
+ dialects: [
642
+ { code: "bn-BD", region: "Bangladesh" },
643
+ { code: "bn-IN", region: "India" }
644
+ ]
645
+ },
646
+ { name: "Bahasa Indonesia", iso: "id", englishName: "indonesian", dialects: [{ code: "id-ID", region: "Indonesia" }] },
647
+ { name: "Bahasa Melayu", iso: "ms", englishName: "malay", dialects: [{ code: "ms-MY", region: "Malaysia" }] },
648
+ { name: "Catal\xE0", iso: "ca", englishName: "catalan", dialects: [{ code: "ca-ES", region: "Spain" }] },
649
+ { name: "\u010Ce\u0161tina", iso: "cs", englishName: "czech", dialects: [{ code: "cs-CZ", region: "Czechia" }] },
650
+ { name: "Dansk", iso: "da", englishName: "danish", dialects: [{ code: "da-DK", region: "Denmark" }] },
651
+ { name: "Deutsch", iso: "de", englishName: "german", dialects: [{ code: "de-DE", region: "Germany" }] },
652
+ {
653
+ name: "English",
654
+ iso: "en",
655
+ englishName: "english",
656
+ dialects: [
657
+ { code: "en-US", region: "United States" },
658
+ { code: "en-GB", region: "United Kingdom" },
659
+ { code: "en-AU", region: "Australia" },
660
+ { code: "en-CA", region: "Canada" },
661
+ { code: "en-IN", region: "India" },
662
+ { code: "en-NZ", region: "New Zealand" },
663
+ { code: "en-PH", region: "Philippines" },
664
+ { code: "en-ZA", region: "South Africa" },
665
+ { code: "en-NG", region: "Nigeria" },
666
+ { code: "en-GH", region: "Ghana" },
667
+ { code: "en-KE", region: "Kenya" },
668
+ { code: "en-TZ", region: "Tanzania" }
669
+ ]
670
+ },
671
+ {
672
+ name: "Espa\xF1ol",
673
+ iso: "es",
674
+ englishName: "spanish",
675
+ dialects: [
676
+ { code: "es-ES", region: "Espa\xF1a" },
677
+ { code: "es-MX", region: "M\xE9xico" },
678
+ { code: "es-US", region: "Estados Unidos" },
679
+ { code: "es-AR", region: "Argentina" },
680
+ { code: "es-CL", region: "Chile" },
681
+ { code: "es-CO", region: "Colombia" },
682
+ { code: "es-PE", region: "Per\xFA" },
683
+ { code: "es-VE", region: "Venezuela" },
684
+ { code: "es-EC", region: "Ecuador" },
685
+ { code: "es-GT", region: "Guatemala" },
686
+ { code: "es-CR", region: "Costa Rica" },
687
+ { code: "es-PA", region: "Panam\xE1" },
688
+ { code: "es-DO", region: "Rep. Dominicana" },
689
+ { code: "es-UY", region: "Uruguay" },
690
+ { code: "es-PY", region: "Paraguay" },
691
+ { code: "es-BO", region: "Bolivia" },
692
+ { code: "es-SV", region: "El Salvador" },
693
+ { code: "es-HN", region: "Honduras" },
694
+ { code: "es-NI", region: "Nicaragua" },
695
+ { code: "es-PR", region: "Puerto Rico" }
696
+ ]
697
+ },
698
+ { name: "Euskara", iso: "eu", englishName: "basque", dialects: [{ code: "eu-ES", region: "Spain" }] },
699
+ { name: "Filipino", iso: "fil", englishName: "filipino tagalog", dialects: [{ code: "fil-PH", region: "Philippines" }] },
700
+ { name: "Fran\xE7ais", iso: "fr", englishName: "french", dialects: [{ code: "fr-FR", region: "France" }] },
701
+ { name: "Basa Jawa", iso: "jv", englishName: "javanese", dialects: [{ code: "jv-ID", region: "Indonesia" }] },
702
+ { name: "Galego", iso: "gl", englishName: "galician", dialects: [{ code: "gl-ES", region: "Spain" }] },
703
+ { name: "\u0A97\u0AC1\u0A9C\u0AB0\u0ABE\u0AA4\u0AC0", iso: "gu", englishName: "gujarati", dialects: [{ code: "gu-IN", region: "India" }] },
704
+ { name: "Hrvatski", iso: "hr", englishName: "croatian", dialects: [{ code: "hr-HR", region: "Croatia" }] },
705
+ { name: "IsiZulu", iso: "zu", englishName: "zulu", dialects: [{ code: "zu-ZA", region: "South Africa" }] },
706
+ { name: "\xCDslenska", iso: "is", englishName: "icelandic", dialects: [{ code: "is-IS", region: "Iceland" }] },
707
+ {
708
+ name: "Italiano",
709
+ iso: "it",
710
+ englishName: "italian",
711
+ dialects: [
712
+ { code: "it-IT", region: "Italia" },
713
+ { code: "it-CH", region: "Svizzera" }
714
+ ]
715
+ },
716
+ { name: "\u0C95\u0CA8\u0CCD\u0CA8\u0CA1", iso: "kn", englishName: "kannada", dialects: [{ code: "kn-IN", region: "India" }] },
717
+ { name: "\u1797\u17B6\u179F\u17B6\u1781\u17D2\u1798\u17C2\u179A", iso: "km", englishName: "khmer cambodian", dialects: [{ code: "km-KH", region: "Cambodia" }] },
718
+ { name: "Latvie\u0161u", iso: "lv", englishName: "latvian", dialects: [{ code: "lv-LV", region: "Latvia" }] },
719
+ { name: "Lietuvi\u0173", iso: "lt", englishName: "lithuanian", dialects: [{ code: "lt-LT", region: "Lithuania" }] },
720
+ { name: "\u0D2E\u0D32\u0D2F\u0D3E\u0D33\u0D02", iso: "ml", englishName: "malayalam", dialects: [{ code: "ml-IN", region: "India" }] },
721
+ { name: "\u092E\u0930\u093E\u0920\u0940", iso: "mr", englishName: "marathi", dialects: [{ code: "mr-IN", region: "India" }] },
722
+ { name: "Magyar", iso: "hu", englishName: "hungarian", dialects: [{ code: "hu-HU", region: "Hungary" }] },
723
+ { name: "\u0EA5\u0EB2\u0EA7", iso: "lo", englishName: "lao laotian", dialects: [{ code: "lo-LA", region: "Laos" }] },
724
+ { name: "Nederlands", iso: "nl", englishName: "dutch", dialects: [{ code: "nl-NL", region: "Netherlands" }] },
725
+ { name: "\u0928\u0947\u092A\u093E\u0932\u0940 \u092D\u093E\u0937\u093E", iso: "ne", englishName: "nepali", dialects: [{ code: "ne-NP", region: "Nepal" }] },
726
+ { name: "Norsk bokm\xE5l", iso: "nb", englishName: "norwegian bokmal", dialects: [{ code: "nb-NO", region: "Norway" }] },
727
+ { name: "Polski", iso: "pl", englishName: "polish", dialects: [{ code: "pl-PL", region: "Poland" }] },
728
+ {
729
+ name: "Portugu\xEAs",
730
+ iso: "pt",
731
+ englishName: "portuguese",
732
+ dialects: [
733
+ { code: "pt-BR", region: "Brasil" },
734
+ { code: "pt-PT", region: "Portugal" }
735
+ ]
736
+ },
737
+ { name: "Rom\xE2n\u0103", iso: "ro", englishName: "romanian", dialects: [{ code: "ro-RO", region: "Romania" }] },
738
+ { name: "\u0DC3\u0DD2\u0D82\u0DC4\u0DBD", iso: "si", englishName: "sinhala sinhalese", dialects: [{ code: "si-LK", region: "Sri Lanka" }] },
739
+ { name: "Sloven\u0161\u010Dina", iso: "sl", englishName: "slovenian", dialects: [{ code: "sl-SI", region: "Slovenia" }] },
740
+ { name: "Basa Sunda", iso: "su", englishName: "sundanese", dialects: [{ code: "su-ID", region: "Indonesia" }] },
741
+ { name: "Sloven\u010Dina", iso: "sk", englishName: "slovak", dialects: [{ code: "sk-SK", region: "Slovakia" }] },
742
+ { name: "Suomi", iso: "fi", englishName: "finnish", dialects: [{ code: "fi-FI", region: "Finland" }] },
743
+ { name: "Svenska", iso: "sv", englishName: "swedish", dialects: [{ code: "sv-SE", region: "Sweden" }] },
744
+ {
745
+ name: "Kiswahili",
746
+ iso: "sw",
747
+ englishName: "swahili",
748
+ dialects: [
749
+ { code: "sw-TZ", region: "Tanzania" },
750
+ { code: "sw-KE", region: "Kenya" }
751
+ ]
752
+ },
753
+ { name: "\u10E5\u10D0\u10E0\u10D7\u10E3\u10DA\u10D8", iso: "ka", englishName: "georgian", dialects: [{ code: "ka-GE", region: "Georgia" }] },
754
+ { name: "\u0540\u0561\u0575\u0565\u0580\u0565\u0576", iso: "hy", englishName: "armenian", dialects: [{ code: "hy-AM", region: "Armenia" }] },
755
+ {
756
+ name: "\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD",
757
+ iso: "ta",
758
+ englishName: "tamil",
759
+ dialects: [
760
+ { code: "ta-IN", region: "\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE" },
761
+ { code: "ta-SG", region: "\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD" },
762
+ { code: "ta-LK", region: "\u0B87\u0BB2\u0B99\u0BCD\u0B95\u0BC8" },
763
+ { code: "ta-MY", region: "\u0BAE\u0BB2\u0BC7\u0B9A\u0BBF\u0BAF\u0BBE" }
764
+ ]
765
+ },
766
+ { name: "\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41", iso: "te", englishName: "telugu", dialects: [{ code: "te-IN", region: "India" }] },
767
+ { name: "Ti\u1EBFng Vi\u1EC7t", iso: "vi", englishName: "vietnamese", dialects: [{ code: "vi-VN", region: "Vietnam" }] },
768
+ { name: "T\xFCrk\xE7e", iso: "tr", englishName: "turkish", dialects: [{ code: "tr-TR", region: "T\xFCrkiye" }] },
769
+ {
770
+ name: "\u0627\u064F\u0631\u062F\u064F\u0648",
771
+ iso: "ur",
772
+ englishName: "urdu",
773
+ dialects: [
774
+ { code: "ur-PK", region: "\u067E\u0627\u06A9\u0633\u062A\u0627\u0646" },
775
+ { code: "ur-IN", region: "\u0628\u06BE\u0627\u0631\u062A" }
776
+ ]
777
+ },
778
+ { name: "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC", iso: "el", englishName: "greek", dialects: [{ code: "el-GR", region: "Greece" }] },
779
+ { name: "\u0431\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438", iso: "bg", englishName: "bulgarian", dialects: [{ code: "bg-BG", region: "Bulgaria" }] },
780
+ { name: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439", iso: "ru", englishName: "russian", dialects: [{ code: "ru-RU", region: "Russia" }] },
781
+ { name: "\u0421\u0440\u043F\u0441\u043A\u0438", iso: "sr", englishName: "serbian", dialects: [{ code: "sr-RS", region: "Serbia" }] },
782
+ { name: "\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430", iso: "uk", englishName: "ukrainian", dialects: [{ code: "uk-UA", region: "Ukraine" }] },
783
+ { name: "\uD55C\uAD6D\uC5B4", iso: "ko", englishName: "korean", dialects: [{ code: "ko-KR", region: "Korea" }] },
784
+ {
785
+ name: "\u4E2D\u6587",
786
+ iso: "cmn",
787
+ englishName: "chinese mandarin cantonese",
788
+ dialects: [
789
+ { code: "cmn-Hans-CN", region: "\u666E\u901A\u8BDD (\u4E2D\u56FD\u5927\u9646)" },
790
+ { code: "cmn-Hans-HK", region: "\u666E\u901A\u8BDD (\u9999\u6E2F)" },
791
+ { code: "cmn-Hant-TW", region: "\u4E2D\u6587 (\u53F0\u7063)" },
792
+ { code: "yue-Hant-HK", region: "\u7CB5\u8A9E (\u9999\u6E2F)" }
793
+ ]
794
+ },
795
+ { name: "\u65E5\u672C\u8A9E", iso: "ja", englishName: "japanese", dialects: [{ code: "ja-JP", region: "Japan" }] },
796
+ { name: "\u0939\u093F\u0928\u094D\u0926\u0940", iso: "hi", englishName: "hindi", dialects: [{ code: "hi-IN", region: "India" }] },
797
+ { name: "\u0E20\u0E32\u0E29\u0E32\u0E44\u0E17\u0E22", iso: "th", englishName: "thai", dialects: [{ code: "th-TH", region: "Thailand" }] }
798
+ ];
799
+ WEB_SPEECH_LANGUAGES.flatMap(
800
+ (l) => l.dialects.map((d) => d.code)
801
+ );
802
+ function findSpeechLanguage(tag) {
803
+ if (!tag) return null;
804
+ const lower = tag.toLowerCase();
805
+ for (const language of WEB_SPEECH_LANGUAGES) {
806
+ for (const dialect of language.dialects) {
807
+ if (dialect.code.toLowerCase() === lower) return { language, dialect };
808
+ }
809
+ }
810
+ return null;
811
+ }
812
+ chunkOLISEQHS_cjs.__name(findSpeechLanguage, "findSpeechLanguage");
813
+ function countryFromTag(tag) {
814
+ if (!tag) return null;
815
+ const parts = tag.split("-");
816
+ for (let i = parts.length - 1; i >= 0; i -= 1) {
817
+ const p = parts[i];
818
+ if (p.length === 2 && /^[A-Za-z]{2}$/.test(p)) return p.toUpperCase();
819
+ }
820
+ return null;
821
+ }
822
+ chunkOLISEQHS_cjs.__name(countryFromTag, "countryFromTag");
823
+ chunkADEN3UA4_cjs.getSpeechLogger();
824
+ React.createContext(null);
825
+ function Spinner({ className }) {
826
+ const t = i18n.useAppT();
827
+ const loadingLabel = t("ui.states.loading");
828
+ return /* @__PURE__ */ jsxRuntime.jsx(
829
+ "div",
830
+ {
831
+ className: lib.cn(
832
+ "inline-block h-8 w-8 animate-spin rounded-full",
833
+ "border-4 border-solid border-current border-r-transparent",
834
+ "align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]",
835
+ className
836
+ ),
837
+ role: "status",
838
+ "aria-label": loadingLabel
839
+ }
840
+ );
841
+ }
842
+ chunkOLISEQHS_cjs.__name(Spinner, "Spinner");
843
+ function LoadingFallback({
844
+ minHeight = 200,
845
+ showText = true,
846
+ text,
847
+ className
848
+ }) {
849
+ const t = i18n.useAppT();
850
+ const loadingText = text ?? t("ui.form.loading");
851
+ const height = typeof minHeight === "number" ? `${minHeight}px` : minHeight;
852
+ return /* @__PURE__ */ jsxRuntime.jsx(
853
+ "div",
854
+ {
855
+ className: lib.cn(
856
+ "flex items-center justify-center bg-muted/30 rounded-lg",
857
+ className
858
+ ),
859
+ style: { minHeight: height },
860
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
861
+ /* @__PURE__ */ jsxRuntime.jsx(Spinner, { className: "text-primary" }),
862
+ showText && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-3 text-sm text-muted-foreground", children: loadingText })
863
+ ] })
864
+ }
865
+ );
866
+ }
867
+ chunkOLISEQHS_cjs.__name(LoadingFallback, "LoadingFallback");
868
+ function CardLoadingFallback({
869
+ title,
870
+ description,
871
+ minHeight = 200,
872
+ className
873
+ }) {
874
+ const t = i18n.useAppT();
875
+ const cardTitle = title ?? t("ui.states.loading");
876
+ const height = typeof minHeight === "number" ? `${minHeight}px` : minHeight;
877
+ return /* @__PURE__ */ jsxRuntime.jsxs(
878
+ "div",
879
+ {
880
+ className: lib.cn(
881
+ "relative bg-card rounded-lg border border-border overflow-hidden",
882
+ className
883
+ ),
884
+ children: [
885
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4 border-b border-border bg-muted/50", children: [
886
+ /* @__PURE__ */ jsxRuntime.jsx("h6", { className: "text-sm font-semibold text-foreground", children: cardTitle }),
887
+ description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground mt-1", children: description })
888
+ ] }),
889
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxRuntime.jsx(
890
+ "div",
891
+ {
892
+ className: "flex justify-center items-center",
893
+ style: { minHeight: height },
894
+ children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { className: "text-primary" })
895
+ }
896
+ ) })
897
+ ]
898
+ }
899
+ );
900
+ }
901
+ chunkOLISEQHS_cjs.__name(CardLoadingFallback, "CardLoadingFallback");
902
+ function MapLoadingFallback({
903
+ minHeight = 400,
904
+ className
905
+ }) {
906
+ const t = i18n.useAppT();
907
+ const loadingText = t("ui.form.loading");
908
+ const height = typeof minHeight === "number" ? `${minHeight}px` : minHeight;
909
+ return /* @__PURE__ */ jsxRuntime.jsx(
910
+ "div",
911
+ {
912
+ className: lib.cn(
913
+ "relative bg-muted/50 rounded-lg overflow-hidden",
914
+ "flex items-center justify-center",
915
+ className
916
+ ),
917
+ style: { minHeight: height },
918
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
919
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
920
+ /* @__PURE__ */ jsxRuntime.jsx(Spinner, { className: "text-primary h-10 w-10" }),
921
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs(
922
+ "svg",
923
+ {
924
+ className: "h-5 w-5 text-muted-foreground",
925
+ fill: "none",
926
+ viewBox: "0 0 24 24",
927
+ stroke: "currentColor",
928
+ children: [
929
+ /* @__PURE__ */ jsxRuntime.jsx(
930
+ "path",
931
+ {
932
+ strokeLinecap: "round",
933
+ strokeLinejoin: "round",
934
+ strokeWidth: 2,
935
+ d: "M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"
936
+ }
937
+ ),
938
+ /* @__PURE__ */ jsxRuntime.jsx(
939
+ "path",
940
+ {
941
+ strokeLinecap: "round",
942
+ strokeLinejoin: "round",
943
+ strokeWidth: 2,
944
+ d: "M15 11a3 3 0 11-6 0 3 3 0 016 0z"
945
+ }
946
+ )
947
+ ]
948
+ }
949
+ ) })
950
+ ] }),
951
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-3 text-sm text-muted-foreground", children: loadingText })
952
+ ] })
953
+ }
954
+ );
955
+ }
956
+ chunkOLISEQHS_cjs.__name(MapLoadingFallback, "MapLoadingFallback");
957
+ function LazyWrapper({
958
+ children,
959
+ fallback,
960
+ card = false,
961
+ cardTitle,
962
+ cardDescription,
963
+ minHeight = 200,
964
+ className
965
+ }) {
966
+ const defaultFallback = card ? /* @__PURE__ */ jsxRuntime.jsx(
967
+ CardLoadingFallback,
968
+ {
969
+ title: cardTitle,
970
+ description: cardDescription,
971
+ minHeight,
972
+ className
973
+ }
974
+ ) : /* @__PURE__ */ jsxRuntime.jsx(LoadingFallback, { minHeight, className });
975
+ return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: fallback ?? defaultFallback, children });
976
+ }
977
+ chunkOLISEQHS_cjs.__name(LazyWrapper, "LazyWrapper");
978
+ function createLazyComponent(loader, options = {}) {
979
+ const LazyComponent = React__namespace.lazy(loader);
980
+ const WrappedComponent = /* @__PURE__ */ chunkOLISEQHS_cjs.__name((props) => {
981
+ const fallback = typeof options.fallback === "function" ? options.fallback(props) : options.fallback ?? /* @__PURE__ */ jsxRuntime.jsx(LoadingFallback, {});
982
+ return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback, children: /* @__PURE__ */ jsxRuntime.jsx(LazyComponent, { ...props }) });
983
+ }, "WrappedComponent");
984
+ WrappedComponent.displayName = options.displayName ?? "LazyComponent";
985
+ return WrappedComponent;
986
+ }
987
+ chunkOLISEQHS_cjs.__name(createLazyComponent, "createLazyComponent");
988
+ createLazyComponent(
989
+ () => import('./DictationField-AS2F33WI.cjs').then((mod) => ({
990
+ default: mod.DictationField
991
+ })),
992
+ {
993
+ displayName: "LazyDictationField",
994
+ fallback: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-border/60 bg-card px-3 py-2 text-xs text-muted-foreground", children: "Loading dictation\u2026" })
995
+ }
996
+ );
997
+ function ChatHeaderLanguageButton({
998
+ ariaLabel = "Speech language",
999
+ allowedTags,
1000
+ hideFallbackIcon,
1001
+ className
1002
+ }) {
1003
+ const prefs = chunkADEN3UA4_cjs.useSpeechPrefs();
1004
+ const active = chunkADEN3UA4_cjs.useResolvedLanguage();
1005
+ const options = React.useMemo(() => {
1006
+ const allow = allowedTags ? new Set(allowedTags) : null;
1007
+ const out = [];
1008
+ for (const lang of WEB_SPEECH_LANGUAGES) {
1009
+ for (const d of lang.dialects) {
1010
+ if (allow && !allow.has(d.code)) continue;
1011
+ out.push({
1012
+ value: d.code,
1013
+ // "Русский" / "Español — Argentina" / "English — United States"
1014
+ label: lang.dialects.length === 1 ? lang.name : `${lang.name} \u2014 ${d.region}`,
1015
+ // Search-only index: English name, BCP-47 tag, ISO, region.
1016
+ // Lets users type "russian" / "ru-RU" / "ru" / "argentina"
1017
+ // and still find the row regardless of native script.
1018
+ description: `${lang.englishName} ${d.code} ${lang.iso} ${d.region}`.toLowerCase()
1019
+ });
1020
+ }
1021
+ }
1022
+ return out;
1023
+ }, [allowedTags]);
1024
+ return /* @__PURE__ */ jsxRuntime.jsx(
1025
+ components.Combobox,
1026
+ {
1027
+ options,
1028
+ value: prefs.language ?? active,
1029
+ onValueChange: (v) => prefs.setLanguage(v || null),
1030
+ placeholder: ariaLabel,
1031
+ searchPlaceholder: "Search language\u2026",
1032
+ filterFunction: (opt, search) => {
1033
+ const s = search.toLowerCase();
1034
+ return opt.label.toLowerCase().includes(s) || opt.value.toLowerCase().includes(s) || (opt.description?.includes(s) ?? false);
1035
+ },
1036
+ contentClassName: "w-[280px]",
1037
+ contentStyle: { zIndex: 10001 },
1038
+ renderOption: (option) => {
1039
+ const country = countryFromTag(option.value);
1040
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
1041
+ country ? /* @__PURE__ */ jsxRuntime.jsx(
1042
+ components.Flag,
1043
+ {
1044
+ countryCode: country,
1045
+ className: "h-4 w-5 shrink-0 overflow-hidden rounded-[2px] border border-border/60 ring-1 ring-black/5"
1046
+ }
1047
+ ) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Globe, { className: "h-4 w-4 shrink-0 text-muted-foreground", "aria-hidden": true }),
1048
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-sm", children: option.label })
1049
+ ] });
1050
+ },
1051
+ renderTrigger: (selected, open) => {
1052
+ const tag = selected?.value ?? active;
1053
+ const country = countryFromTag(tag);
1054
+ const found = findSpeechLanguage(tag);
1055
+ const tooltipLabel = found ? `${found.language.name}${found.language.dialects.length > 1 ? ` \u2014 ${found.dialect.region}` : ""} \xB7 ${tag}` : tag;
1056
+ return /* @__PURE__ */ jsxRuntime.jsx(
1057
+ "button",
1058
+ {
1059
+ type: "button",
1060
+ "aria-label": `${ariaLabel}: ${tooltipLabel}`,
1061
+ "aria-expanded": open,
1062
+ title: tooltipLabel,
1063
+ className: lib.cn(
1064
+ "inline-flex h-7 w-7 items-center justify-center rounded-md",
1065
+ "text-muted-foreground transition-colors",
1066
+ "hover:bg-accent hover:text-foreground",
1067
+ "focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1068
+ className
1069
+ ),
1070
+ children: country ? /* @__PURE__ */ jsxRuntime.jsx(
1071
+ components.Flag,
1072
+ {
1073
+ countryCode: country,
1074
+ className: "h-4 w-5 overflow-hidden rounded-[2px] border border-border/60 ring-1 ring-black/5"
1075
+ }
1076
+ ) : hideFallbackIcon ? null : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Globe, { className: "h-3.5 w-3.5", "aria-hidden": true })
1077
+ }
1078
+ );
1079
+ }
1080
+ }
1081
+ );
1082
+ }
1083
+ chunkOLISEQHS_cjs.__name(ChatHeaderLanguageButton, "ChatHeaderLanguageButton");
1084
+ function anchorStyle(position, fabOffset, fabClearance) {
1085
+ const [vert, horiz] = position.split("-");
1086
+ return { [vert]: fabClearance, [horiz]: fabOffset };
1087
+ }
1088
+ chunkOLISEQHS_cjs.__name(anchorStyle, "anchorStyle");
1089
+ function originClass(position) {
1090
+ if (position === "bottom-right") return "origin-bottom-right";
1091
+ if (position === "bottom-left") return "origin-bottom-left";
1092
+ if (position === "top-right") return "origin-top-right";
1093
+ return "origin-top-left";
1094
+ }
1095
+ chunkOLISEQHS_cjs.__name(originClass, "originClass");
1096
+ function ChatGreeting({
1097
+ open,
1098
+ children,
1099
+ onClick,
1100
+ onDismiss,
1101
+ position = "bottom-right",
1102
+ fabOffset = 24,
1103
+ fabClearance = 96,
1104
+ delayMs = 1500,
1105
+ zIndex = 9998,
1106
+ className,
1107
+ style,
1108
+ avatar,
1109
+ senderName,
1110
+ dismissLabel = "Dismiss",
1111
+ inline = false
1112
+ }) {
1113
+ const [delayed, setDelayed] = React.useState(delayMs <= 0);
1114
+ React.useEffect(() => {
1115
+ if (!open || delayMs <= 0) return;
1116
+ const t = setTimeout(() => setDelayed(true), delayMs);
1117
+ return () => clearTimeout(t);
1118
+ }, [open, delayMs]);
1119
+ const shouldShow = open && delayed;
1120
+ const phase = useChatPresence(shouldShow, 220);
1121
+ if (phase === "hidden") return null;
1122
+ const animating = phase === "entering" || phase === "leaving";
1123
+ const clickable = !!onClick;
1124
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1125
+ "div",
1126
+ {
1127
+ role: clickable ? "button" : "status",
1128
+ "aria-live": "polite",
1129
+ tabIndex: clickable ? 0 : -1,
1130
+ onClick: clickable ? onClick : void 0,
1131
+ onKeyDown: clickable ? (e) => {
1132
+ if (e.key === "Enter" || e.key === " ") {
1133
+ e.preventDefault();
1134
+ onClick?.();
1135
+ }
1136
+ } : void 0,
1137
+ className: lib.cn(
1138
+ inline ? "relative inline-flex" : "fixed",
1139
+ "flex items-start gap-2.5 max-w-[280px]",
1140
+ "rounded-2xl border border-border bg-popover text-popover-foreground",
1141
+ "px-3.5 py-2.5 shadow-2xl transition-all duration-200 ease-out",
1142
+ clickable && "cursor-pointer hover:bg-accent/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1143
+ originClass(position),
1144
+ animating ? "opacity-0 scale-95 translate-y-1" : "opacity-100 scale-100 translate-y-0",
1145
+ className
1146
+ ),
1147
+ style: {
1148
+ ...inline ? {} : anchorStyle(position, fabOffset, fabClearance),
1149
+ ...inline ? {} : { zIndex },
1150
+ pointerEvents: phase === "visible" ? "auto" : "none",
1151
+ ...style
1152
+ },
1153
+ children: [
1154
+ avatar && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-0.5 shrink-0", children: avatar }),
1155
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1 text-sm leading-snug", children: [
1156
+ senderName && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-0.5 text-[11px] font-medium text-muted-foreground", children: senderName }),
1157
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-foreground", children })
1158
+ ] }),
1159
+ onDismiss && /* @__PURE__ */ jsxRuntime.jsx(
1160
+ "button",
1161
+ {
1162
+ type: "button",
1163
+ "aria-label": dismissLabel,
1164
+ onClick: (e) => {
1165
+ e.stopPropagation();
1166
+ onDismiss();
1167
+ },
1168
+ className: lib.cn(
1169
+ "-mr-1 -mt-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-full",
1170
+ "text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",
1171
+ "focus:outline-none focus-visible:ring-2 focus-visible:ring-ring"
1172
+ ),
1173
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-3.5 w-3.5" })
1174
+ }
1175
+ )
1176
+ ]
1177
+ }
1178
+ );
1179
+ }
1180
+ chunkOLISEQHS_cjs.__name(ChatGreeting, "ChatGreeting");
1181
+ var TIME_FORMAT = new Intl.DateTimeFormat(void 0, {
1182
+ hour: "2-digit",
1183
+ minute: "2-digit"
1184
+ });
1185
+ function anchorStyle2(position, fabOffset, fabClearance) {
1186
+ const [vert, horiz] = position.split("-");
1187
+ return { [vert]: fabClearance, [horiz]: fabOffset };
1188
+ }
1189
+ chunkOLISEQHS_cjs.__name(anchorStyle2, "anchorStyle");
1190
+ function originClass2(position) {
1191
+ if (position === "bottom-right") return "origin-bottom-right";
1192
+ if (position === "bottom-left") return "origin-bottom-left";
1193
+ if (position === "top-right") return "origin-top-right";
1194
+ return "origin-top-left";
1195
+ }
1196
+ chunkOLISEQHS_cjs.__name(originClass2, "originClass");
1197
+ function deriveAvatar(persona, name) {
1198
+ const initials = persona?.initials ?? (name ?? persona?.name ?? "?").split(/\s+/).map((p) => p[0]).filter(Boolean).slice(0, 2).join("").toUpperCase();
1199
+ return /* @__PURE__ */ jsxRuntime.jsxs(components.Avatar, { className: "h-9 w-9", children: [
1200
+ persona?.avatarUrl ? /* @__PURE__ */ jsxRuntime.jsx(components.AvatarImage, { src: persona.avatarUrl }) : null,
1201
+ /* @__PURE__ */ jsxRuntime.jsx(components.AvatarFallback, { children: initials || "?" })
1202
+ ] });
1203
+ }
1204
+ chunkOLISEQHS_cjs.__name(deriveAvatar, "deriveAvatar");
1205
+ function ChatUnreadPreview({
1206
+ open,
1207
+ message,
1208
+ onClick,
1209
+ onDismiss,
1210
+ position = "bottom-right",
1211
+ fabOffset = 24,
1212
+ fabClearance = 96,
1213
+ truncate = 2,
1214
+ zIndex = 9998,
1215
+ inline = false,
1216
+ className,
1217
+ style,
1218
+ dismissLabel = "Mark as read",
1219
+ avatar,
1220
+ senderName
1221
+ }) {
1222
+ const shouldShow = open && !!message;
1223
+ const phase = useChatPresence(shouldShow, 200);
1224
+ if (phase === "hidden" || !message) return null;
1225
+ const animating = phase === "entering" || phase === "leaving";
1226
+ const clickable = !!onClick;
1227
+ const displayName = senderName ?? message.sender?.name ?? "New message";
1228
+ const stamp = TIME_FORMAT.format(new Date(message.createdAt));
1229
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1230
+ "div",
1231
+ {
1232
+ role: clickable ? "button" : "status",
1233
+ "aria-live": "polite",
1234
+ tabIndex: clickable ? 0 : -1,
1235
+ onClick: clickable ? onClick : void 0,
1236
+ onKeyDown: clickable ? (e) => {
1237
+ if (e.key === "Enter" || e.key === " ") {
1238
+ e.preventDefault();
1239
+ onClick?.();
1240
+ }
1241
+ } : void 0,
1242
+ className: lib.cn(
1243
+ inline ? "relative inline-flex" : "fixed",
1244
+ "flex items-start gap-2.5 max-w-[300px]",
1245
+ "rounded-2xl border border-border bg-popover text-popover-foreground",
1246
+ "px-3.5 py-2.5 shadow-2xl transition-all duration-200 ease-out",
1247
+ clickable && "cursor-pointer hover:bg-accent/40 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1248
+ originClass2(position),
1249
+ animating ? "opacity-0 scale-95 translate-y-1" : "opacity-100 scale-100 translate-y-0",
1250
+ className
1251
+ ),
1252
+ style: {
1253
+ ...inline ? {} : anchorStyle2(position, fabOffset, fabClearance),
1254
+ ...inline ? {} : { zIndex },
1255
+ pointerEvents: phase === "visible" ? "auto" : "none",
1256
+ ...style
1257
+ },
1258
+ children: [
1259
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-0.5 shrink-0", children: avatar ?? deriveAvatar(message.sender, displayName) }),
1260
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1 text-sm leading-snug", children: [
1261
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-baseline justify-between gap-2", children: [
1262
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "truncate text-[12px] font-semibold text-foreground", children: displayName }),
1263
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shrink-0 text-[10px] text-muted-foreground", children: stamp })
1264
+ ] }),
1265
+ /* @__PURE__ */ jsxRuntime.jsx(
1266
+ "div",
1267
+ {
1268
+ className: "text-foreground/90 mt-0.5 break-words",
1269
+ style: {
1270
+ display: "-webkit-box",
1271
+ WebkitLineClamp: truncate,
1272
+ WebkitBoxOrient: "vertical",
1273
+ overflow: "hidden"
1274
+ },
1275
+ children: message.content
1276
+ }
1277
+ )
1278
+ ] }),
1279
+ onDismiss ? /* @__PURE__ */ jsxRuntime.jsx(
1280
+ "button",
1281
+ {
1282
+ type: "button",
1283
+ "aria-label": dismissLabel,
1284
+ onClick: (e) => {
1285
+ e.stopPropagation();
1286
+ onDismiss();
1287
+ },
1288
+ className: lib.cn(
1289
+ "-mr-1 -mt-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-full",
1290
+ "text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",
1291
+ "focus:outline-none focus-visible:ring-2 focus-visible:ring-ring"
1292
+ ),
1293
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-3.5 w-3.5" })
1294
+ }
1295
+ ) : null
1296
+ ]
1297
+ }
1298
+ );
1299
+ }
1300
+ chunkOLISEQHS_cjs.__name(ChatUnreadPreview, "ChatUnreadPreview");
1301
+ function readDismissed(storageKey) {
1302
+ if (!storageKey) return false;
1303
+ if (typeof window === "undefined") return false;
1304
+ try {
1305
+ return window.localStorage.getItem(storageKey) === "1";
1306
+ } catch {
1307
+ return false;
1308
+ }
1309
+ }
1310
+ chunkOLISEQHS_cjs.__name(readDismissed, "readDismissed");
1311
+ function writeDismissed(storageKey) {
1312
+ if (!storageKey) return;
1313
+ if (typeof window === "undefined") return;
1314
+ try {
1315
+ window.localStorage.setItem(storageKey, "1");
1316
+ } catch {
1317
+ }
1318
+ }
1319
+ chunkOLISEQHS_cjs.__name(writeDismissed, "writeDismissed");
1320
+ function ChatLauncher({
1321
+ children,
1322
+ fab,
1323
+ dock,
1324
+ greeting,
1325
+ hotkey,
1326
+ defaultOpen = false,
1327
+ open: controlledOpen,
1328
+ onOpenChange,
1329
+ autoFocusComposerOnOpen = true,
1330
+ closeOnEscape = true,
1331
+ unreadMessage,
1332
+ onMarkRead,
1333
+ unreadPreview,
1334
+ audio,
1335
+ hideAudioToggle = false
1336
+ }) {
1337
+ const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);
1338
+ const isControlled = controlledOpen !== void 0;
1339
+ const open = isControlled ? controlledOpen : uncontrolledOpen;
1340
+ const dockContentRef = React.useRef(null);
1341
+ React.useEffect(() => {
1342
+ if (!autoFocusComposerOnOpen || !open) return;
1343
+ const t = setTimeout(() => {
1344
+ const root = dockContentRef.current;
1345
+ if (!root) return;
1346
+ const target = root.querySelector(
1347
+ 'textarea:not([disabled]):not([readonly]), input[type="text"]:not([disabled]):not([readonly])'
1348
+ );
1349
+ target?.focus();
1350
+ }, 120);
1351
+ return () => clearTimeout(t);
1352
+ }, [open, autoFocusComposerOnOpen]);
1353
+ const setOpen = React.useCallback(
1354
+ (next) => {
1355
+ if (!isControlled) setUncontrolledOpen(next);
1356
+ onOpenChange?.(next);
1357
+ },
1358
+ [isControlled, onOpenChange]
1359
+ );
1360
+ const toggleOpen = React.useCallback(() => setOpen(!open), [open, setOpen]);
1361
+ hooks.useHotkey(
1362
+ "escape",
1363
+ (e) => {
1364
+ const target = e?.target ?? null;
1365
+ const inEditable = !!target && (target.matches?.('input, textarea, [contenteditable="true"]') ?? false);
1366
+ if (inEditable) {
1367
+ target.blur();
1368
+ return;
1369
+ }
1370
+ setOpen(false);
1371
+ },
1372
+ { enabled: closeOnEscape && open }
1373
+ );
1374
+ const greetingConfig = greeting === void 0 ? null : typeof greeting === "string" ? { content: greeting } : greeting;
1375
+ const [dismissed, setDismissed] = React.useState(
1376
+ () => readDismissed(greetingConfig?.dismissStorageKey)
1377
+ );
1378
+ React.useEffect(() => {
1379
+ if (!hotkey) return;
1380
+ const handler = /* @__PURE__ */ chunkOLISEQHS_cjs.__name((e) => {
1381
+ const metaOk = hotkey.meta ? e.metaKey || e.ctrlKey : !e.metaKey && !e.ctrlKey;
1382
+ const shiftOk = hotkey.shift ? e.shiftKey : !e.shiftKey;
1383
+ const altOk = hotkey.alt ? e.altKey : !e.altKey;
1384
+ if (!metaOk || !shiftOk || !altOk) return;
1385
+ if (e.key !== hotkey.key) return;
1386
+ e.preventDefault();
1387
+ setOpen(!open);
1388
+ }, "handler");
1389
+ window.addEventListener("keydown", handler);
1390
+ return () => window.removeEventListener("keydown", handler);
1391
+ }, [hotkey?.key, hotkey?.meta, hotkey?.shift, hotkey?.alt, open, setOpen, hotkey]);
1392
+ const greetingOpen = !!greetingConfig && !dismissed && (greetingConfig.hideOnOpen === false || !open);
1393
+ const fabPosition = fab?.position ?? "bottom-right";
1394
+ const fabOffset = fab?.offset ?? 24;
1395
+ const handleGreetingDismiss = /* @__PURE__ */ chunkOLISEQHS_cjs.__name(() => {
1396
+ setDismissed(true);
1397
+ writeDismissed(greetingConfig?.dismissStorageKey);
1398
+ }, "handleGreetingDismiss");
1399
+ const handleGreetingClick = /* @__PURE__ */ chunkOLISEQHS_cjs.__name(() => {
1400
+ setOpen(true);
1401
+ setDismissed(true);
1402
+ writeDismissed(greetingConfig?.dismissStorageKey);
1403
+ }, "handleGreetingClick");
1404
+ React.useEffect(() => {
1405
+ if (open && unreadMessage) onMarkRead?.();
1406
+ }, [open, unreadMessage, onMarkRead]);
1407
+ const unreadOpen = !open && !!unreadMessage;
1408
+ const handleUnreadClick = /* @__PURE__ */ chunkOLISEQHS_cjs.__name(() => {
1409
+ setOpen(true);
1410
+ onMarkRead?.();
1411
+ }, "handleUnreadClick");
1412
+ const handleUnreadDismiss = /* @__PURE__ */ chunkOLISEQHS_cjs.__name(() => {
1413
+ onMarkRead?.();
1414
+ }, "handleUnreadDismiss");
1415
+ const resolvedFab = unreadMessage && fab?.badge === void 0 ? { ...fab, badge: 1 } : fab;
1416
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1417
+ /* @__PURE__ */ jsxRuntime.jsx(ChatFAB, { ...resolvedFab, onClick: toggleOpen }),
1418
+ unreadMessage ? /* @__PURE__ */ jsxRuntime.jsx(
1419
+ ChatUnreadPreview,
1420
+ {
1421
+ ...unreadPreview,
1422
+ open: unreadOpen,
1423
+ message: unreadMessage,
1424
+ onClick: handleUnreadClick,
1425
+ onDismiss: handleUnreadDismiss,
1426
+ position: fabPosition,
1427
+ fabOffset
1428
+ }
1429
+ ) : greetingConfig ? /* @__PURE__ */ jsxRuntime.jsx(
1430
+ ChatGreeting,
1431
+ {
1432
+ ...greetingConfig,
1433
+ open: greetingOpen,
1434
+ onClick: handleGreetingClick,
1435
+ onDismiss: handleGreetingDismiss,
1436
+ position: fabPosition,
1437
+ fabOffset,
1438
+ children: greetingConfig.content
1439
+ }
1440
+ ) : null,
1441
+ /* @__PURE__ */ jsxRuntime.jsx(
1442
+ ChatDock,
1443
+ {
1444
+ ...dock,
1445
+ open,
1446
+ onClose: () => setOpen(false),
1447
+ headerActions: audio && !audio.isSilent && !hideAudioToggle || dock?.headerActions ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1448
+ dock?.headerActions,
1449
+ audio && !audio.isSilent && !hideAudioToggle ? /* @__PURE__ */ jsxRuntime.jsx(ChatHeaderAudioToggle, { muted: audio.muted, onToggle: audio.toggleMute }) : null
1450
+ ] }) : void 0,
1451
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: dockContentRef, className: "flex h-full min-h-0 min-w-0 flex-col", children })
1452
+ }
1453
+ )
1454
+ ] });
1455
+ }
1456
+ chunkOLISEQHS_cjs.__name(ChatLauncher, "ChatLauncher");
1457
+
1458
+ exports.CardLoadingFallback = CardLoadingFallback;
1459
+ exports.ChatDock = ChatDock;
1460
+ exports.ChatFAB = ChatFAB;
1461
+ exports.ChatGreeting = ChatGreeting;
1462
+ exports.ChatHeader = ChatHeader;
1463
+ exports.ChatHeaderActionButton = ChatHeaderActionButton;
1464
+ exports.ChatHeaderAudioToggle = ChatHeaderAudioToggle;
1465
+ exports.ChatHeaderLanguageButton = ChatHeaderLanguageButton;
1466
+ exports.ChatHeaderModeToggle = ChatHeaderModeToggle;
1467
+ exports.ChatHeaderResetButton = ChatHeaderResetButton;
1468
+ exports.ChatLauncher = ChatLauncher;
1469
+ exports.ChatUnreadPreview = ChatUnreadPreview;
1470
+ exports.LazyWrapper = LazyWrapper;
1471
+ exports.LoadingFallback = LoadingFallback;
1472
+ exports.MapLoadingFallback = MapLoadingFallback;
1473
+ exports.Spinner = Spinner;
1474
+ exports.createLazyComponent = createLazyComponent;
1475
+ exports.useChatPresence = useChatPresence;
1476
+ exports.useChatReset = useChatReset;
1477
+ //# sourceMappingURL=chunk-W75B7Y6C.cjs.map
1478
+ //# sourceMappingURL=chunk-W75B7Y6C.cjs.map