@guideai/react-native 0.7.0 → 0.9.0

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 (37) hide show
  1. package/README.md +20 -1
  2. package/dist/GuideAIChat-BFu10t6D.cjs +2794 -0
  3. package/dist/GuideAIChat-BFu10t6D.cjs.map +1 -0
  4. package/dist/GuideAIChat-BQQ8lUKs.js +2795 -0
  5. package/dist/GuideAIChat-BQQ8lUKs.js.map +1 -0
  6. package/dist/GuideAIChat-Ba6n1ePs.js +2795 -0
  7. package/dist/GuideAIChat-Ba6n1ePs.js.map +1 -0
  8. package/dist/GuideAIChat-CNmEo5bZ.cjs +2794 -0
  9. package/dist/GuideAIChat-CNmEo5bZ.cjs.map +1 -0
  10. package/dist/GuideAIChat-SU0CVNby.js +2795 -0
  11. package/dist/GuideAIChat-SU0CVNby.js.map +1 -0
  12. package/dist/GuideAIChat-W8KQ4Y6i.cjs +2794 -0
  13. package/dist/GuideAIChat-W8KQ4Y6i.cjs.map +1 -0
  14. package/dist/index.cjs +1 -1
  15. package/dist/index.d.ts +91 -6
  16. package/dist/index.mjs +2 -2
  17. package/dist/ui.cjs +2 -2
  18. package/dist/ui.d.ts +11 -5
  19. package/dist/ui.mjs +3 -3
  20. package/dist/useConversations-C-OmzdeA.js +4300 -0
  21. package/dist/useConversations-C-OmzdeA.js.map +1 -0
  22. package/dist/useConversations-CJEaVqch.cjs +4290 -0
  23. package/dist/useConversations-CJEaVqch.cjs.map +1 -0
  24. package/dist/useConversations-Chn_GKOz.cjs +4299 -0
  25. package/dist/useConversations-Chn_GKOz.cjs.map +1 -0
  26. package/dist/useConversations-Ckyqbxqi.cjs +4299 -0
  27. package/dist/useConversations-Ckyqbxqi.cjs.map +1 -0
  28. package/dist/useConversations-DzhYCIiY.js +4300 -0
  29. package/dist/useConversations-DzhYCIiY.js.map +1 -0
  30. package/dist/useConversations-SbhtYN_R.js +4291 -0
  31. package/dist/useConversations-SbhtYN_R.js.map +1 -0
  32. package/dist/voice.cjs +2835 -19
  33. package/dist/voice.cjs.map +1 -1
  34. package/dist/voice.d.ts +12 -6
  35. package/dist/voice.mjs +2836 -20
  36. package/dist/voice.mjs.map +1 -1
  37. package/package.json +6 -2
@@ -0,0 +1,2795 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import React, { useReducer, useState, useRef, useMemo, useEffect } from "react";
3
+ import { View, StyleSheet, Text, ScrollView, Linking, AccessibilityInfo, Modal, ActivityIndicator, Pressable, Platform, Animated, Easing, KeyboardAvoidingView, Alert, FlatList, TextInput, StatusBar } from "react-native";
4
+ import { m as motionTarget, B as BOARD_W, e as useWhiteboard, G as GuideAI, r as requireConfigured, f as BOARD_H, c as useGuideAI, d as useOnboarding, E as EP, b as useConversations } from "./useConversations-SbhtYN_R.js";
5
+ import { Svg, G, Path, Defs, ClipPath, Rect, Image } from "react-native-svg";
6
+ function parseInline(text) {
7
+ const spans = [];
8
+ const pattern = /(`[^`]+`)|(\*\*[^*]+\*\*)|(__[^_]+__)|(\*[^*\n]+\*)|(_[^_\n]+_)|(\[[^\]]+\]\([^)]+\))/g;
9
+ let cursor = 0;
10
+ let match;
11
+ while ((match = pattern.exec(text)) !== null) {
12
+ if (match.index > cursor) {
13
+ spans.push({ text: text.slice(cursor, match.index) });
14
+ }
15
+ const token = match[0];
16
+ if (token.startsWith("`")) {
17
+ spans.push({ text: token.slice(1, -1), code: true });
18
+ } else if (token.startsWith("**") || token.startsWith("__")) {
19
+ spans.push({ text: token.slice(2, -2), bold: true });
20
+ } else if (token.startsWith("[")) {
21
+ const split = token.indexOf("](");
22
+ spans.push({
23
+ text: token.slice(1, split),
24
+ href: token.slice(split + 2, -1)
25
+ });
26
+ } else {
27
+ spans.push({ text: token.slice(1, -1), italic: true });
28
+ }
29
+ cursor = match.index + token.length;
30
+ }
31
+ if (cursor < text.length) spans.push({ text: text.slice(cursor) });
32
+ return spans.length ? spans : [{ text }];
33
+ }
34
+ function tableCells(line) {
35
+ return line.replace(/^\s*\|/, "").replace(/\|\s*$/, "").split("|").map((cell) => parseInline(cell.trim()));
36
+ }
37
+ const TABLE_DIVIDER = /^\s*\|?[\s:-]*-[\s|:-]*\|?\s*$/;
38
+ function parseMarkdown(source) {
39
+ var _a, _b;
40
+ const blocks = [];
41
+ const lines = source.replace(/\r\n/g, "\n").split("\n");
42
+ let index = 0;
43
+ while (index < lines.length) {
44
+ const line = lines[index];
45
+ const trimmed = line.trim();
46
+ if (!trimmed) {
47
+ index += 1;
48
+ continue;
49
+ }
50
+ const fence = /^```(\w+)?/.exec(trimmed);
51
+ if (fence) {
52
+ const language = fence[1];
53
+ const body = [];
54
+ index += 1;
55
+ while (index < lines.length && !lines[index].trim().startsWith("```")) {
56
+ body.push(lines[index]);
57
+ index += 1;
58
+ }
59
+ index += 1;
60
+ blocks.push({ type: "code", text: body.join("\n"), language });
61
+ continue;
62
+ }
63
+ if (trimmed.includes("|") && index + 1 < lines.length && TABLE_DIVIDER.test(lines[index + 1])) {
64
+ const header = tableCells(trimmed);
65
+ const rows = [];
66
+ index += 2;
67
+ while (index < lines.length && lines[index].includes("|") && lines[index].trim()) {
68
+ rows.push(tableCells(lines[index]));
69
+ index += 1;
70
+ }
71
+ blocks.push({ type: "table", header, rows });
72
+ continue;
73
+ }
74
+ const heading = /^(#{1,6})\s+(.*)$/.exec(trimmed);
75
+ if (heading) {
76
+ const level = Math.min(heading[1].length, 3);
77
+ blocks.push({ type: "heading", level, spans: parseInline(heading[2]) });
78
+ index += 1;
79
+ continue;
80
+ }
81
+ if (/^(\*\s*){3,}$|^(-\s*){3,}$|^(_\s*){3,}$/.test(trimmed)) {
82
+ blocks.push({ type: "rule" });
83
+ index += 1;
84
+ continue;
85
+ }
86
+ const quote = /^>\s?(.*)$/.exec(trimmed);
87
+ if (quote) {
88
+ blocks.push({ type: "quote", spans: parseInline(quote[1]) });
89
+ index += 1;
90
+ continue;
91
+ }
92
+ const indent = (_b = (_a = /^(\s*)/.exec(line)) == null ? void 0 : _a[1].length) != null ? _b : 0;
93
+ const depth = Math.floor(indent / 2);
94
+ const bullet = /^[-*+]\s+(.*)$/.exec(trimmed);
95
+ if (bullet) {
96
+ blocks.push({ type: "bullet", spans: parseInline(bullet[1]), depth });
97
+ index += 1;
98
+ continue;
99
+ }
100
+ const ordered = /^(\d+)[.)]\s+(.*)$/.exec(trimmed);
101
+ if (ordered) {
102
+ blocks.push({
103
+ type: "ordered",
104
+ spans: parseInline(ordered[2]),
105
+ index: Number(ordered[1]),
106
+ depth
107
+ });
108
+ index += 1;
109
+ continue;
110
+ }
111
+ const paragraph = [trimmed];
112
+ index += 1;
113
+ while (index < lines.length) {
114
+ const nextLine = lines[index].trim();
115
+ if (!nextLine || /^(#{1,6})\s/.test(nextLine) || /^[-*+]\s/.test(nextLine) || /^\d+[.)]\s/.test(nextLine) || nextLine.startsWith("```") || nextLine.startsWith(">") || nextLine.includes("|")) break;
116
+ paragraph.push(nextLine);
117
+ index += 1;
118
+ }
119
+ blocks.push({ type: "paragraph", spans: parseInline(paragraph.join(" ")) });
120
+ }
121
+ return blocks;
122
+ }
123
+ function Spans({ spans, style, accentColor }) {
124
+ return /* @__PURE__ */ jsx(Fragment, { children: spans.map((span, index) => {
125
+ if (span.href) {
126
+ return /* @__PURE__ */ jsx(
127
+ Text,
128
+ {
129
+ style: [style, { color: accentColor, textDecorationLine: "underline" }],
130
+ onPress: () => {
131
+ void Linking.openURL(span.href);
132
+ },
133
+ accessibilityRole: "link",
134
+ children: span.text
135
+ },
136
+ index
137
+ );
138
+ }
139
+ return /* @__PURE__ */ jsx(
140
+ Text,
141
+ {
142
+ style: [
143
+ style,
144
+ span.bold ? styles$4.bold : null,
145
+ span.italic ? styles$4.italic : null,
146
+ span.code ? styles$4.inlineCode : null
147
+ ],
148
+ children: span.text
149
+ },
150
+ index
151
+ );
152
+ }) });
153
+ }
154
+ function Markdown({
155
+ children,
156
+ color = "#0f172a",
157
+ accentColor = "#2563eb",
158
+ fontSize = 15
159
+ }) {
160
+ const blocks = React.useMemo(() => parseMarkdown(children), [children]);
161
+ const body = { color, fontSize, lineHeight: fontSize * 1.45 };
162
+ return /* @__PURE__ */ jsx(View, { style: styles$4.container, children: blocks.map((block, index) => /* @__PURE__ */ jsx(
163
+ Block,
164
+ {
165
+ block,
166
+ body,
167
+ color,
168
+ accentColor,
169
+ fontSize
170
+ },
171
+ index
172
+ )) });
173
+ }
174
+ function Block({ block, body, color, accentColor, fontSize }) {
175
+ switch (block.type) {
176
+ case "heading": {
177
+ const sizes = { 1: fontSize + 6, 2: fontSize + 3, 3: fontSize + 1 };
178
+ return /* @__PURE__ */ jsx(Text, { style: [styles$4.heading, { color, fontSize: sizes[block.level] }], children: /* @__PURE__ */ jsx(
179
+ Spans,
180
+ {
181
+ spans: block.spans,
182
+ accentColor,
183
+ style: { color, fontSize: sizes[block.level], fontWeight: "700" }
184
+ }
185
+ ) });
186
+ }
187
+ case "paragraph":
188
+ return /* @__PURE__ */ jsx(Text, { style: styles$4.paragraph, children: /* @__PURE__ */ jsx(Spans, { spans: block.spans, style: body, accentColor }) });
189
+ case "bullet":
190
+ return /* @__PURE__ */ jsxs(View, { style: [styles$4.listRow, { marginLeft: block.depth * 14 }], children: [
191
+ /* @__PURE__ */ jsx(Text, { style: [body, { color: accentColor }], children: "•" }),
192
+ /* @__PURE__ */ jsx(Text, { style: styles$4.listText, children: /* @__PURE__ */ jsx(Spans, { spans: block.spans, style: body, accentColor }) })
193
+ ] });
194
+ case "ordered":
195
+ return /* @__PURE__ */ jsxs(View, { style: [styles$4.listRow, { marginLeft: block.depth * 14 }], children: [
196
+ /* @__PURE__ */ jsxs(Text, { style: [body, { color: accentColor, fontVariant: ["tabular-nums"] }], children: [
197
+ block.index,
198
+ "."
199
+ ] }),
200
+ /* @__PURE__ */ jsx(Text, { style: styles$4.listText, children: /* @__PURE__ */ jsx(Spans, { spans: block.spans, style: body, accentColor }) })
201
+ ] });
202
+ case "code":
203
+ return /* @__PURE__ */ jsx(View, { style: styles$4.codeBlock, children: /* @__PURE__ */ jsx(Text, { style: [styles$4.codeText, { fontSize: fontSize - 2 }], children: block.text }) });
204
+ case "quote":
205
+ return /* @__PURE__ */ jsx(View, { style: [styles$4.quote, { borderLeftColor: accentColor }], children: /* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx(
206
+ Spans,
207
+ {
208
+ spans: block.spans,
209
+ accentColor,
210
+ style: { ...body, color: "#475569", fontStyle: "italic" }
211
+ }
212
+ ) }) });
213
+ case "rule":
214
+ return /* @__PURE__ */ jsx(View, { style: styles$4.rule });
215
+ case "table": {
216
+ const columns = Math.max(block.header.length, ...block.rows.map((r) => r.length), 1);
217
+ const scrolls = columns > 3;
218
+ const table = /* @__PURE__ */ jsxs(View, { style: [styles$4.table, scrolls ? { minWidth: columns * 116 } : null], children: [
219
+ /* @__PURE__ */ jsx(View, { style: [styles$4.tableRow, styles$4.tableHeaderRow], children: block.header.map((cell, index) => /* @__PURE__ */ jsx(View, { style: styles$4.tableCell, children: /* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx(
220
+ Spans,
221
+ {
222
+ spans: cell,
223
+ accentColor,
224
+ style: { ...body, fontWeight: "700", fontSize: fontSize - 1 }
225
+ }
226
+ ) }) }, index)) }),
227
+ block.rows.map((row, rowIndex) => /* @__PURE__ */ jsx(View, { style: styles$4.tableRow, children: row.map((cell, cellIndex) => /* @__PURE__ */ jsx(View, { style: styles$4.tableCell, children: /* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx(
228
+ Spans,
229
+ {
230
+ spans: cell,
231
+ accentColor,
232
+ style: { ...body, fontSize: fontSize - 1 }
233
+ }
234
+ ) }) }, cellIndex)) }, rowIndex))
235
+ ] });
236
+ return scrolls ? /* @__PURE__ */ jsx(
237
+ ScrollView,
238
+ {
239
+ horizontal: true,
240
+ showsHorizontalScrollIndicator: false,
241
+ alwaysBounceHorizontal: false,
242
+ children: table
243
+ }
244
+ ) : table;
245
+ }
246
+ default:
247
+ return null;
248
+ }
249
+ }
250
+ const mono = { fontFamily: "Menlo" };
251
+ const styles$4 = StyleSheet.create({
252
+ container: { gap: 6 },
253
+ heading: { fontWeight: "700", marginTop: 4 },
254
+ paragraph: {},
255
+ listRow: { flexDirection: "row", gap: 8, alignItems: "flex-start" },
256
+ listText: { flex: 1 },
257
+ bold: { fontWeight: "700" },
258
+ italic: { fontStyle: "italic" },
259
+ inlineCode: {
260
+ ...mono,
261
+ backgroundColor: "rgba(100,116,139,0.14)",
262
+ color: "#0f172a"
263
+ },
264
+ codeBlock: {
265
+ backgroundColor: "#0f172a",
266
+ borderRadius: 10,
267
+ padding: 12,
268
+ marginVertical: 2
269
+ },
270
+ codeText: { ...mono, color: "#e2e8f0" },
271
+ quote: { borderLeftWidth: 3, paddingLeft: 10, paddingVertical: 2 },
272
+ rule: { height: StyleSheet.hairlineWidth, backgroundColor: "#cbd5e1", marginVertical: 6 },
273
+ table: {
274
+ borderWidth: StyleSheet.hairlineWidth,
275
+ borderColor: "#cbd5e1",
276
+ borderRadius: 8,
277
+ overflow: "hidden"
278
+ },
279
+ tableRow: {
280
+ flexDirection: "row",
281
+ borderBottomWidth: StyleSheet.hairlineWidth,
282
+ borderBottomColor: "#e2e8f0"
283
+ },
284
+ tableHeaderRow: { backgroundColor: "rgba(100,116,139,0.10)" },
285
+ tableCell: { flex: 1, padding: 8 }
286
+ });
287
+ const STEP_GAP_MS = 450;
288
+ function readTime(text) {
289
+ const words = text.trim().split(/\s+/).filter(Boolean).length;
290
+ return Math.min(6500, Math.max(1500, words * 280));
291
+ }
292
+ const SPEEDS = [0.75, 1, 1.5, 2];
293
+ class Player {
294
+ constructor(steps, hooks, reducedMotion = false) {
295
+ var _a, _b, _c;
296
+ this.steps = steps;
297
+ this.hooks = hooks;
298
+ this.reducedMotion = reducedMotion;
299
+ this.state = "idle";
300
+ this.speed = 1;
301
+ this.stepIndex = -1;
302
+ this.opIndex = 0;
303
+ this.opElapsed = 0;
304
+ this.stepElapsed = 0;
305
+ this.holdElapsed = 0;
306
+ this.spoken = null;
307
+ this.narrationToken = 0;
308
+ this.frame = null;
309
+ this.last = 0;
310
+ this.requestFrame = (_a = hooks.requestFrame) != null ? _a : ((cb) => requestAnimationFrame(cb));
311
+ this.cancelFrame = (_b = hooks.cancelFrame) != null ? _b : ((id) => cancelAnimationFrame(id));
312
+ this.now = (_c = hooks.now) != null ? _c : (() => performance.now());
313
+ }
314
+ get current() {
315
+ return this.stepIndex;
316
+ }
317
+ get status() {
318
+ return this.state;
319
+ }
320
+ get rate() {
321
+ return this.speed;
322
+ }
323
+ setSpeed(speed) {
324
+ this.speed = Math.min(3, Math.max(0.25, speed));
325
+ }
326
+ play() {
327
+ if (this.state === "playing") return;
328
+ if (this.state === "done" || this.state === "idle") {
329
+ this.restart();
330
+ return;
331
+ }
332
+ this.setState("playing");
333
+ this.schedule();
334
+ }
335
+ pause() {
336
+ if (this.state !== "playing") return;
337
+ this.setState("paused");
338
+ this.unschedule();
339
+ if (this.spoken === null) {
340
+ this.narrationToken += 1;
341
+ this.hooks.stopNarration();
342
+ this.spoken = false;
343
+ }
344
+ }
345
+ replay() {
346
+ this.restart();
347
+ }
348
+ /**
349
+ * Jump to step *index*, as a scrubber does: the board is rebuilt with every
350
+ * step before it already drawn, then playback carries on from there.
351
+ */
352
+ seek(index) {
353
+ const target = Math.max(0, Math.min(this.steps.length - 1, Math.floor(index)));
354
+ this.unschedule();
355
+ this.narrationToken += 1;
356
+ this.hooks.stopNarration();
357
+ this.hooks.reset();
358
+ for (let i = 0; i < target; i += 1) {
359
+ const step = this.steps[i];
360
+ step.enter();
361
+ for (const op of step.ops) op.run(1);
362
+ }
363
+ this.stepIndex = -1;
364
+ this.setState("playing");
365
+ this.enterStep(target);
366
+ this.schedule();
367
+ }
368
+ /** Stop for good: no frames, no voice. */
369
+ destroy() {
370
+ this.unschedule();
371
+ this.narrationToken += 1;
372
+ this.hooks.stopNarration();
373
+ this.state = "done";
374
+ }
375
+ restart() {
376
+ this.unschedule();
377
+ this.narrationToken += 1;
378
+ this.hooks.stopNarration();
379
+ this.hooks.reset();
380
+ this.stepIndex = -1;
381
+ this.setState("playing");
382
+ this.enterStep(0);
383
+ this.schedule();
384
+ }
385
+ setState(state) {
386
+ var _a, _b;
387
+ if (this.state === state) return;
388
+ this.state = state;
389
+ (_b = (_a = this.hooks).onState) == null ? void 0 : _b.call(_a, state);
390
+ }
391
+ enterStep(index) {
392
+ var _a, _b;
393
+ const step = this.steps[index];
394
+ if (!step) {
395
+ this.unschedule();
396
+ this.setState("done");
397
+ return;
398
+ }
399
+ this.stepIndex = index;
400
+ this.opIndex = 0;
401
+ this.opElapsed = 0;
402
+ this.stepElapsed = 0;
403
+ this.holdElapsed = 0;
404
+ this.spoken = null;
405
+ step.enter();
406
+ (_b = (_a = this.hooks).onStep) == null ? void 0 : _b.call(_a, index, step);
407
+ const token = ++this.narrationToken;
408
+ this.hooks.narrate(step.say).then(
409
+ (said) => {
410
+ if (token === this.narrationToken) this.spoken = said;
411
+ },
412
+ () => {
413
+ if (token === this.narrationToken) this.spoken = false;
414
+ }
415
+ );
416
+ if (this.reducedMotion) {
417
+ for (const op of step.ops) op.run(1);
418
+ this.opIndex = step.ops.length;
419
+ }
420
+ }
421
+ schedule() {
422
+ if (this.frame !== null || this.state !== "playing") return;
423
+ this.last = this.now();
424
+ this.frame = this.requestFrame((t) => this.tick(t));
425
+ }
426
+ unschedule() {
427
+ if (this.frame !== null) this.cancelFrame(this.frame);
428
+ this.frame = null;
429
+ }
430
+ /** One frame. Public so tests can drive time by hand. */
431
+ tick(now) {
432
+ this.frame = null;
433
+ if (this.state !== "playing") return;
434
+ const dt = Math.max(0, Math.min(100, now - this.last)) * this.speed;
435
+ this.last = now;
436
+ this.advance(dt);
437
+ if (this.state === "playing") this.frame = this.requestFrame((t) => this.tick(t));
438
+ }
439
+ advance(dt) {
440
+ const step = this.steps[this.stepIndex];
441
+ if (!step) return;
442
+ this.stepElapsed += dt;
443
+ let left = dt;
444
+ while (this.opIndex < step.ops.length && left > 0) {
445
+ const op = step.ops[this.opIndex];
446
+ const remaining = op.duration - this.opElapsed;
447
+ if (op.duration <= 0 || left >= remaining) {
448
+ op.run(1);
449
+ left -= Math.max(0, remaining);
450
+ this.opIndex += 1;
451
+ this.opElapsed = 0;
452
+ } else {
453
+ this.opElapsed += left;
454
+ op.run(this.opElapsed / op.duration);
455
+ left = 0;
456
+ }
457
+ }
458
+ while (this.opIndex < step.ops.length && step.ops[this.opIndex].duration <= 0) {
459
+ step.ops[this.opIndex].run(1);
460
+ this.opIndex += 1;
461
+ }
462
+ if (this.opIndex < step.ops.length || this.spoken === null) return;
463
+ const hold = this.spoken ? 0 : readTime(step.say);
464
+ if (this.stepElapsed < hold) return;
465
+ this.holdElapsed += dt;
466
+ if (this.holdElapsed < STEP_GAP_MS) return;
467
+ this.enterStep(this.stepIndex + 1);
468
+ }
469
+ }
470
+ const STORYBOARD_ICON_STROKES = {
471
+ phone: [
472
+ "M 32 6 Q 24 6 24 14 L 24 86 Q 24 94 32 94 L 68 94 Q 76 94 76 86 L 76 14 Q 76 6 68 6 Z",
473
+ "M 43 13 L 57 13",
474
+ "M 41 88 L 59 88"
475
+ ],
476
+ screen: [
477
+ "M 8 18 L 92 18 L 92 66 L 8 66 Z",
478
+ "M 42 66 L 38 84 L 62 84 L 58 66",
479
+ "M 30 84 L 70 84"
480
+ ],
481
+ window: [
482
+ "M 6 16 L 94 16 L 94 84 L 6 84 Z",
483
+ "M 6 32 L 94 32",
484
+ "M 11 24 a 3 3 0 1 0 6 0 a 3 3 0 1 0 -6 0 M 23 24 a 3 3 0 1 0 6 0 a 3 3 0 1 0 -6 0 M 35 24 a 3 3 0 1 0 6 0 a 3 3 0 1 0 -6 0"
485
+ ],
486
+ video: [
487
+ "M 8 20 L 92 20 L 92 80 L 8 80 Z",
488
+ "M 20 20 L 20 80 M 80 20 L 80 80",
489
+ "M 42 40 L 64 50 L 42 60 Z"
490
+ ],
491
+ play: [
492
+ "M 8 50 a 42 42 0 1 0 84 0 a 42 42 0 1 0 -84 0",
493
+ "M 40 32 L 70 50 L 40 68 Z"
494
+ ],
495
+ input: [
496
+ "M 6 36 L 94 36 L 94 64 L 6 64 Z",
497
+ "M 18 43 L 18 57",
498
+ "M 28 50 L 66 50"
499
+ ],
500
+ cursor: [
501
+ "M 24 12 L 24 74 L 39 60 L 49 82 L 60 77 L 50 56 L 70 55 Z"
502
+ ],
503
+ document: [
504
+ "M 24 8 L 62 8 L 78 26 L 78 92 L 24 92 Z",
505
+ "M 62 8 L 62 26 L 78 26",
506
+ "M 36 44 L 66 44 M 36 58 L 66 58 M 36 72 L 54 72"
507
+ ],
508
+ image: [
509
+ "M 10 20 L 90 20 L 90 80 L 10 80 Z",
510
+ "M 10 68 L 36 44 L 56 64 L 68 54 L 90 74",
511
+ "M 61 34 a 7 7 0 1 0 14 0 a 7 7 0 1 0 -14 0"
512
+ ],
513
+ gear: [
514
+ "M 50.0 17.0 L 58.8 5.9 L 67.2 8.4 L 68.3 22.6 L 73.3 26.7 L 87.4 25.0 L 91.6 32.8 L 82.4 43.6 L 83.0 50.0 L 94.1 58.8 L 91.6 67.2 L 77.4 68.3 L 73.3 73.3 L 75.0 87.4 L 67.2 91.6 L 56.4 82.4 L 50.0 83.0 L 41.2 94.1 L 32.8 91.6 L 31.7 77.4 L 26.7 73.3 L 12.6 75.0 L 8.4 67.2 L 17.6 56.4 L 17.0 50.0 L 5.9 41.2 L 8.4 32.8 L 22.6 31.7 L 26.7 26.7 L 25.0 12.6 L 32.8 8.4 L 43.6 17.6 Z",
515
+ "M 39 50 a 11 11 0 1 0 22 0 a 11 11 0 1 0 -22 0"
516
+ ],
517
+ cloud: [
518
+ "M 28 74 Q 8 74 8 58 Q 8 44 24 42 Q 28 22 48 22 Q 68 22 72 42 Q 92 44 92 58 Q 92 74 74 74 Z"
519
+ ],
520
+ database: [
521
+ "M 18 24 a 32 10 0 1 0 64 0 a 32 10 0 1 0 -64 0",
522
+ "M 18 24 L 18 76 Q 18 88 50 88 Q 82 88 82 76 L 82 24",
523
+ "M 18 50 Q 18 62 50 62 Q 82 62 82 50"
524
+ ],
525
+ user: [
526
+ "M 33 31 a 17 17 0 1 0 34 0 a 17 17 0 1 0 -34 0",
527
+ "M 16 88 Q 16 56 50 56 Q 84 56 84 88"
528
+ ],
529
+ sparkle: [
530
+ "M 50 6 Q 56 40 90 50 Q 56 60 50 94 Q 44 60 10 50 Q 44 40 50 6 Z"
531
+ ],
532
+ check: [
533
+ "M 16 54 L 40 78 L 86 22"
534
+ ],
535
+ clock: [
536
+ "M 8 50 a 42 42 0 1 0 84 0 a 42 42 0 1 0 -84 0",
537
+ "M 50 26 L 50 52 L 70 62"
538
+ ],
539
+ lock: [
540
+ "M 22 46 L 78 46 L 78 90 L 22 90 Z",
541
+ "M 34 46 L 34 30 Q 34 12 50 12 Q 66 12 66 30 L 66 46",
542
+ "M 50 62 L 50 74"
543
+ ],
544
+ chat: [
545
+ "M 10 20 L 90 20 L 90 68 L 46 68 L 26 86 L 28 68 L 10 68 Z",
546
+ "M 28 38 L 72 38 M 28 52 L 60 52"
547
+ ],
548
+ cross: [
549
+ "M 22 22 L 78 78",
550
+ "M 78 22 L 22 78"
551
+ ],
552
+ server: [
553
+ "M 16 10 L 84 10 L 84 34 L 16 34 Z",
554
+ "M 16 38 L 84 38 L 84 62 L 16 62 Z",
555
+ "M 16 66 L 84 66 L 84 90 L 16 90 Z",
556
+ "M 26 22 L 32 22 M 26 50 L 32 50 M 26 78 L 32 78",
557
+ "M 54 22 L 74 22 M 54 50 L 74 50 M 54 78 L 74 78"
558
+ ],
559
+ queue: [
560
+ "M 6 32 L 94 32 M 6 68 L 94 68",
561
+ "M 14 40 L 30 40 L 30 60 L 14 60 Z",
562
+ "M 38 40 L 54 40 L 54 60 L 38 60 Z",
563
+ "M 62 40 L 78 40 L 78 60 L 62 60 Z",
564
+ "M 82 50 L 94 50 M 88 44 L 94 50 L 88 56"
565
+ ],
566
+ globe: [
567
+ "M 8 50 a 42 42 0 1 0 84 0 a 42 42 0 1 0 -84 0",
568
+ "M 50 8 Q 22 50 50 92 Q 78 50 50 8",
569
+ "M 8 50 L 92 50",
570
+ "M 16 28 L 84 28 M 16 72 L 84 72"
571
+ ],
572
+ balancer: [
573
+ "M 36 8 L 64 8 L 64 30 L 36 30 Z",
574
+ "M 50 30 L 50 46 M 18 46 L 82 46 M 18 46 L 18 62 M 50 46 L 50 62 M 82 46 L 82 62",
575
+ "M 8 62 L 28 62 L 28 86 L 8 86 Z",
576
+ "M 40 62 L 60 62 L 60 86 L 40 86 Z",
577
+ "M 72 62 L 92 62 L 92 86 L 72 86 Z"
578
+ ],
579
+ cache: [
580
+ "M 58 6 L 24 54 L 48 54 L 40 94 L 78 40 L 54 40 Z"
581
+ ],
582
+ container: [
583
+ "M 50 8 L 88 28 L 88 72 L 50 92 L 12 72 L 12 28 Z",
584
+ "M 12 28 L 50 48 L 88 28",
585
+ "M 50 48 L 50 92"
586
+ ]
587
+ };
588
+ function storyboardIconStrokes(icon) {
589
+ var _a;
590
+ return (_a = STORYBOARD_ICON_STROKES[icon]) != null ? _a : [];
591
+ }
592
+ const SHEET_W$1 = 1600;
593
+ const SHEET_H$1 = 1e3;
594
+ const sx = (x) => x * (SHEET_W$1 / 160);
595
+ const sy = (y) => y * (SHEET_H$1 / 100);
596
+ function seeded(seed) {
597
+ let s = seed >>> 0 || 1;
598
+ return () => {
599
+ s ^= s << 13;
600
+ s ^= s >>> 17;
601
+ s ^= s << 5;
602
+ return (s >>> 0) % 1e4 / 1e4;
603
+ };
604
+ }
605
+ function strokeLength(stroke) {
606
+ let length = 0;
607
+ for (let i = 1; i < stroke.length; i += 1) {
608
+ length += Math.hypot(stroke[i].x - stroke[i - 1].x, stroke[i].y - stroke[i - 1].y);
609
+ }
610
+ return length;
611
+ }
612
+ function totalLength(strokes) {
613
+ return strokes.reduce((sum, s) => sum + strokeLength(s), 0);
614
+ }
615
+ function bounds(strokes) {
616
+ let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
617
+ for (const s of strokes) for (const p of s) {
618
+ x0 = Math.min(x0, p.x);
619
+ y0 = Math.min(y0, p.y);
620
+ x1 = Math.max(x1, p.x);
621
+ y1 = Math.max(y1, p.y);
622
+ }
623
+ return Number.isFinite(x0) ? { x0, y0, x1, y1 } : null;
624
+ }
625
+ function handLine(a, b, rand, steps = 14) {
626
+ const length = Math.hypot(b.x - a.x, b.y - a.y) || 1;
627
+ const nx = -(b.y - a.y) / length;
628
+ const ny = (b.x - a.x) / length;
629
+ const bow = (rand() - 0.5) * Math.min(18, length * 0.04);
630
+ const out = [];
631
+ for (let i = 0; i <= steps; i += 1) {
632
+ const t = i / steps;
633
+ const lift = Math.sin(Math.PI * t) * bow + (rand() - 0.5) * 1.6;
634
+ out.push({ x: a.x + (b.x - a.x) * t + nx * lift, y: a.y + (b.y - a.y) * t + ny * lift });
635
+ }
636
+ return out;
637
+ }
638
+ function handEllipse(b, rand) {
639
+ const cx = sx(b[0] + b[2] / 2);
640
+ const cy = sy(b[1] + b[3] / 2);
641
+ const rx = sx(b[2]) / 2 + 8;
642
+ const ry = sy(b[3]) / 2 + 8;
643
+ const start = -Math.PI * (0.55 + rand() * 0.2);
644
+ const sweep = Math.PI * 2 * (1.06 + rand() * 0.05);
645
+ const out = [];
646
+ const n = 48;
647
+ for (let i = 0; i <= n; i += 1) {
648
+ const t = i / n;
649
+ const a = start + sweep * t;
650
+ const grow = 1 + (t - 0.5) * 0.06 + (rand() - 0.5) * 0.012;
651
+ out.push({ x: cx + Math.cos(a) * rx * grow, y: cy + Math.sin(a) * ry * grow });
652
+ }
653
+ return out;
654
+ }
655
+ function smooth$1(points, per = 8) {
656
+ if (points.length < 3) return points;
657
+ const out = [];
658
+ for (let i = 0; i < points.length - 1; i += 1) {
659
+ const p0 = points[Math.max(0, i - 1)];
660
+ const p1 = points[i];
661
+ const p2 = points[i + 1];
662
+ const p3 = points[Math.min(points.length - 1, i + 2)];
663
+ for (let j = 0; j < per; j += 1) {
664
+ const t = j / per;
665
+ const t2 = t * t;
666
+ const t3 = t2 * t;
667
+ out.push({
668
+ x: 0.5 * (2 * p1.x + (-p0.x + p2.x) * t + (2 * p0.x - 5 * p1.x + 4 * p2.x - p3.x) * t2 + (-p0.x + 3 * p1.x - 3 * p2.x + p3.x) * t3),
669
+ y: 0.5 * (2 * p1.y + (-p0.y + p2.y) * t + (2 * p0.y - 5 * p1.y + 4 * p2.y - p3.y) * t2 + (-p0.y + 3 * p1.y - 3 * p2.y + p3.y) * t3)
670
+ });
671
+ }
672
+ }
673
+ out.push(points[points.length - 1]);
674
+ return out;
675
+ }
676
+ function arrowHead(from, to, rand) {
677
+ const angle = Math.atan2(to.y - from.y, to.x - from.x);
678
+ const size = 26 + rand() * 6;
679
+ const spread = 0.45;
680
+ return [
681
+ { x: to.x - size * Math.cos(angle - spread), y: to.y - size * Math.sin(angle - spread) },
682
+ to,
683
+ { x: to.x - size * Math.cos(angle + spread), y: to.y - size * Math.sin(angle + spread) }
684
+ ];
685
+ }
686
+ const corner = (b) => {
687
+ const x0 = sx(b[0]), y0 = sy(b[1]), x1 = sx(b[0] + b[2]), y1 = sy(b[1] + b[3]);
688
+ return [{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x1, y: y1 }, { x: x0, y: y1 }];
689
+ };
690
+ function handPoly(points, closed, rand) {
691
+ const corners = closed ? [...points, points[0]] : points;
692
+ const out = [];
693
+ for (let i = 1; i < corners.length; i += 1) {
694
+ const length = Math.hypot(corners[i].x - corners[i - 1].x, corners[i].y - corners[i - 1].y);
695
+ const segment = handLine(corners[i - 1], corners[i], rand, Math.max(6, Math.min(24, Math.round(length / 30))));
696
+ out.push(...i === 1 ? segment : segment.slice(1));
697
+ }
698
+ return out;
699
+ }
700
+ function handOval(b, rand) {
701
+ const cx = sx(b[0] + b[2] / 2);
702
+ const cy = sy(b[1] + b[3] / 2);
703
+ const rx = sx(b[2]) / 2;
704
+ const ry = sy(b[3]) / 2;
705
+ const start = -Math.PI * (0.6 + rand() * 0.2);
706
+ const sweep = Math.PI * 2 * (1.03 + rand() * 0.03);
707
+ const n = Math.max(32, Math.round((rx + ry) / 6));
708
+ const out = [];
709
+ for (let i = 0; i <= n; i += 1) {
710
+ const a = start + sweep * i / n;
711
+ const wobble = 1 + (rand() - 0.5) * 0.012;
712
+ out.push({ x: cx + Math.cos(a) * rx * wobble, y: cy + Math.sin(a) * ry * wobble });
713
+ }
714
+ return out;
715
+ }
716
+ const unit = (from, to) => {
717
+ const d = Math.hypot(to.x - from.x, to.y - from.y) || 1;
718
+ return { x: (to.x - from.x) / d, y: (to.y - from.y) / d };
719
+ };
720
+ function rightAngle(a, v, b, rand) {
721
+ const size = Math.min(44, 0.3 * Math.min(Math.hypot(a.x - v.x, a.y - v.y), Math.hypot(b.x - v.x, b.y - v.y)));
722
+ const ua = unit(v, a);
723
+ const ub = unit(v, b);
724
+ const p1 = { x: v.x + ua.x * size, y: v.y + ua.y * size };
725
+ const p2 = { x: p1.x + ub.x * size, y: p1.y + ub.y * size };
726
+ const p3 = { x: v.x + ub.x * size, y: v.y + ub.y * size };
727
+ return handPoly([p1, p2, p3], false, rand);
728
+ }
729
+ function angleArc(a, v, b, rand) {
730
+ const r = Math.min(70, 0.3 * Math.min(Math.hypot(a.x - v.x, a.y - v.y), Math.hypot(b.x - v.x, b.y - v.y)));
731
+ const from = Math.atan2(a.y - v.y, a.x - v.x);
732
+ let delta = Math.atan2(b.y - v.y, b.x - v.x) - from;
733
+ while (delta > Math.PI) delta -= 2 * Math.PI;
734
+ while (delta < -Math.PI) delta += 2 * Math.PI;
735
+ const n = 18;
736
+ const out = [];
737
+ for (let i = 0; i <= n; i += 1) {
738
+ const t = from + delta * i / n;
739
+ const rr = r * (1 + (rand() - 0.5) * 0.03);
740
+ out.push({ x: v.x + Math.cos(t) * rr, y: v.y + Math.sin(t) * rr });
741
+ }
742
+ return out;
743
+ }
744
+ function handDot(c) {
745
+ const out = [];
746
+ for (let i = 0; i <= 14; i += 1) {
747
+ const t = i / 14 * Math.PI * 4;
748
+ const r = 7 * (1 - i / 16);
749
+ out.push({ x: c.x + Math.cos(t) * r, y: c.y + Math.sin(t) * r });
750
+ }
751
+ return out;
752
+ }
753
+ function roughen(strokes, seed, amount = 2.2) {
754
+ const rand = seeded(seed);
755
+ return strokes.map((stroke) => {
756
+ let dx = 0;
757
+ let dy = 0;
758
+ return stroke.map((p) => {
759
+ dx = dx * 0.6 + (rand() - 0.5) * amount;
760
+ dy = dy * 0.6 + (rand() - 0.5) * amount;
761
+ return { x: p.x + dx, y: p.y + dy };
762
+ });
763
+ });
764
+ }
765
+ function inkStrokes(kind, geometry, seed) {
766
+ var _a, _b, _c;
767
+ const rand = seeded(seed);
768
+ const p = (q) => ({ x: sx(q[0]), y: sy(q[1]) });
769
+ const pts = (_b = (_a = geometry.pts) == null ? void 0 : _a.map(p)) != null ? _b : [];
770
+ switch (kind) {
771
+ case "line":
772
+ case "arrow": {
773
+ if (!geometry.at || geometry.at.length !== 2 || !geometry.to) return [];
774
+ const a = p(geometry.at);
775
+ const b2 = p(geometry.to);
776
+ const shaft = handLine(a, b2, rand);
777
+ return kind === "arrow" ? [shaft, arrowHead((_c = shaft[shaft.length - 2]) != null ? _c : a, b2, rand)] : [shaft];
778
+ }
779
+ case "free":
780
+ case "curve":
781
+ return pts.length >= 2 ? [smooth$1(pts)] : [];
782
+ case "poly":
783
+ return pts.length >= 2 ? [handPoly(pts, !!geometry.closed && pts.length > 2, rand)] : [];
784
+ case "corner":
785
+ return pts.length === 3 ? [rightAngle(pts[0], pts[1], pts[2], rand)] : [];
786
+ case "arc":
787
+ return pts.length === 3 ? [angleArc(pts[0], pts[1], pts[2], rand)] : [];
788
+ case "dot":
789
+ return geometry.at && geometry.at.length === 2 ? [handDot(p(geometry.at))] : [];
790
+ }
791
+ const b = geometry.at && geometry.at.length === 4 ? geometry.at : null;
792
+ if (!b) return [];
793
+ const [tl, tr, br, bl] = corner(b);
794
+ switch (kind) {
795
+ case "oval":
796
+ return [handOval(b, rand)];
797
+ case "circle":
798
+ return [handEllipse(b, rand)];
799
+ case "box":
800
+ return [handLine(tl, tr, rand, 10), handLine(tr, br, rand, 8), handLine(br, bl, rand, 10), handLine(bl, tl, rand, 8)];
801
+ case "underline": {
802
+ const y = br.y + 6;
803
+ return [handLine({ x: bl.x - 4, y }, { x: br.x + 4, y: y + (rand() - 0.5) * 6 }, rand, 18)];
804
+ }
805
+ case "cross":
806
+ return [handLine(tl, br, rand, 10), handLine(tr, bl, rand, 10)];
807
+ case "tick": {
808
+ const mid = { x: tl.x + (br.x - tl.x) * 0.38, y: br.y };
809
+ return [[...handLine({ x: tl.x, y: tl.y + (br.y - tl.y) * 0.55 }, mid, rand, 6), ...handLine(mid, tr, rand, 10).slice(1)]];
810
+ }
811
+ case "bracket": {
812
+ const x = tr.x;
813
+ const mid = (tr.y + br.y) / 2;
814
+ return [smooth$1([{ x: x - 14, y: tr.y }, { x, y: tr.y + 12 }, { x, y: mid - 12 }, { x: x + 14, y: mid }, { x, y: mid + 12 }, { x, y: br.y - 12 }, { x: x - 14, y: br.y }], 5)];
815
+ }
816
+ default:
817
+ return [];
818
+ }
819
+ }
820
+ const TOKEN = /([MmLlHhVvCcSsQqTtAaZz])|(-?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/g;
821
+ function flattenPath(d, curveSteps = 8) {
822
+ var _a;
823
+ const tokens = [];
824
+ for (const m of d.matchAll(TOKEN)) tokens.push((_a = m[1]) != null ? _a : Number(m[2]));
825
+ const strokes = [];
826
+ let current = [];
827
+ let x = 0, y = 0, startX = 0, startY = 0;
828
+ let lastCtrl = null;
829
+ let lastQuad = null;
830
+ let cmd = "";
831
+ let i = 0;
832
+ const next = () => {
833
+ const v = tokens[i++];
834
+ return typeof v === "number" ? v : NaN;
835
+ };
836
+ const hasNumber = () => typeof tokens[i] === "number";
837
+ const push = (px, py) => {
838
+ current.push({ x: px, y: py });
839
+ };
840
+ const finish = () => {
841
+ if (current.length > 1) strokes.push(current);
842
+ current = [];
843
+ };
844
+ const cubic = (c1, c2, end) => {
845
+ const sx0 = x, sy0 = y;
846
+ for (let s = 1; s <= curveSteps; s += 1) {
847
+ const t = s / curveSteps;
848
+ const u = 1 - t;
849
+ push(
850
+ u * u * u * sx0 + 3 * u * u * t * c1.x + 3 * u * t * t * c2.x + t * t * t * end.x,
851
+ u * u * u * sy0 + 3 * u * u * t * c1.y + 3 * u * t * t * c2.y + t * t * t * end.y
852
+ );
853
+ }
854
+ x = end.x;
855
+ y = end.y;
856
+ };
857
+ const quad = (c, end) => {
858
+ const sx0 = x, sy0 = y;
859
+ for (let s = 1; s <= curveSteps; s += 1) {
860
+ const t = s / curveSteps;
861
+ const u = 1 - t;
862
+ push(u * u * sx0 + 2 * u * t * c.x + t * t * end.x, u * u * sy0 + 2 * u * t * c.y + t * t * end.y);
863
+ }
864
+ x = end.x;
865
+ y = end.y;
866
+ };
867
+ while (i < tokens.length) {
868
+ if (typeof tokens[i] === "string") cmd = tokens[i++];
869
+ else if (!cmd) {
870
+ i += 1;
871
+ continue;
872
+ }
873
+ const rel = cmd === cmd.toLowerCase();
874
+ const ox = rel ? x : 0;
875
+ const oy = rel ? y : 0;
876
+ switch (cmd.toUpperCase()) {
877
+ case "M": {
878
+ finish();
879
+ x = ox + next();
880
+ y = oy + next();
881
+ startX = x;
882
+ startY = y;
883
+ push(x, y);
884
+ cmd = rel ? "l" : "L";
885
+ lastCtrl = lastQuad = null;
886
+ break;
887
+ }
888
+ case "L":
889
+ x = ox + next();
890
+ y = oy + next();
891
+ push(x, y);
892
+ lastCtrl = lastQuad = null;
893
+ break;
894
+ case "H":
895
+ x = ox + next();
896
+ push(x, y);
897
+ lastCtrl = lastQuad = null;
898
+ break;
899
+ case "V":
900
+ y = oy + next();
901
+ push(x, y);
902
+ lastCtrl = lastQuad = null;
903
+ break;
904
+ case "C": {
905
+ const c1 = { x: ox + next(), y: oy + next() };
906
+ const c2 = { x: ox + next(), y: oy + next() };
907
+ const end = { x: ox + next(), y: oy + next() };
908
+ cubic(c1, c2, end);
909
+ lastCtrl = c2;
910
+ lastQuad = null;
911
+ break;
912
+ }
913
+ case "S": {
914
+ const c1 = lastCtrl ? { x: 2 * x - lastCtrl.x, y: 2 * y - lastCtrl.y } : { x, y };
915
+ const c2 = { x: ox + next(), y: oy + next() };
916
+ const end = { x: ox + next(), y: oy + next() };
917
+ cubic(c1, c2, end);
918
+ lastCtrl = c2;
919
+ lastQuad = null;
920
+ break;
921
+ }
922
+ case "Q": {
923
+ const c = { x: ox + next(), y: oy + next() };
924
+ const end = { x: ox + next(), y: oy + next() };
925
+ quad(c, end);
926
+ lastQuad = c;
927
+ lastCtrl = null;
928
+ break;
929
+ }
930
+ case "T": {
931
+ const c = lastQuad ? { x: 2 * x - lastQuad.x, y: 2 * y - lastQuad.y } : { x, y };
932
+ const end = { x: ox + next(), y: oy + next() };
933
+ quad(c, end);
934
+ lastQuad = c;
935
+ lastCtrl = null;
936
+ break;
937
+ }
938
+ case "A": {
939
+ const rx = next(), ry = next(), rotation = next(), large = next(), sweep = next();
940
+ const end = { x: ox + next(), y: oy + next() };
941
+ for (const p of arcPoints({ x, y }, end, rx, ry, rotation, large !== 0, sweep !== 0, curveSteps * 2)) push(p.x, p.y);
942
+ x = end.x;
943
+ y = end.y;
944
+ lastCtrl = lastQuad = null;
945
+ break;
946
+ }
947
+ case "Z":
948
+ push(startX, startY);
949
+ x = startX;
950
+ y = startY;
951
+ finish();
952
+ current = [{ x, y }];
953
+ lastCtrl = lastQuad = null;
954
+ if (hasNumber()) cmd = rel ? "l" : "L";
955
+ else cmd = "";
956
+ break;
957
+ default:
958
+ i += 1;
959
+ }
960
+ if (Number.isNaN(x) || Number.isNaN(y)) return strokes;
961
+ }
962
+ finish();
963
+ return strokes;
964
+ }
965
+ function arcPoints(from, to, rx, ry, degrees, large, sweep, steps) {
966
+ if (!rx || !ry || from.x === to.x && from.y === to.y) return [to];
967
+ const phi = degrees * Math.PI / 180;
968
+ const cos = Math.cos(phi), sin = Math.sin(phi);
969
+ const dx = (from.x - to.x) / 2, dy = (from.y - to.y) / 2;
970
+ const x1 = cos * dx + sin * dy, y1 = -sin * dx + cos * dy;
971
+ let rxa = Math.abs(rx), rya = Math.abs(ry);
972
+ const scale = x1 * x1 / (rxa * rxa) + y1 * y1 / (rya * rya);
973
+ if (scale > 1) {
974
+ rxa *= Math.sqrt(scale);
975
+ rya *= Math.sqrt(scale);
976
+ }
977
+ const num = rxa * rxa * rya * rya - rxa * rxa * y1 * y1 - rya * rya * x1 * x1;
978
+ const den = rxa * rxa * y1 * y1 + rya * rya * x1 * x1;
979
+ const k = (large === sweep ? -1 : 1) * Math.sqrt(Math.max(0, num / den));
980
+ const cx1 = k * rxa * y1 / rya, cy1 = -k * rya * x1 / rxa;
981
+ const cx = cos * cx1 - sin * cy1 + (from.x + to.x) / 2;
982
+ const cy = sin * cx1 + cos * cy1 + (from.y + to.y) / 2;
983
+ const angle = (ux, uy, vx, vy) => Math.atan2(ux * vy - uy * vx, ux * vx + uy * vy);
984
+ const start = angle(1, 0, (x1 - cx1) / rxa, (y1 - cy1) / rya);
985
+ let delta = angle((x1 - cx1) / rxa, (y1 - cy1) / rya, (-x1 - cx1) / rxa, (-y1 - cy1) / rya);
986
+ if (!sweep && delta > 0) delta -= 2 * Math.PI;
987
+ if (sweep && delta < 0) delta += 2 * Math.PI;
988
+ const out = [];
989
+ for (let i = 1; i <= steps; i += 1) {
990
+ const t = start + delta * i / steps;
991
+ out.push({ x: cx + rxa * Math.cos(t) * cos - rya * Math.sin(t) * sin, y: cy + rxa * Math.cos(t) * sin + rya * Math.sin(t) * cos });
992
+ }
993
+ out[out.length - 1] = to;
994
+ return out;
995
+ }
996
+ function parseTransform(transform) {
997
+ const t = /translate\(\s*(-?[\d.]+)(?:[\s,]+(-?[\d.]+))?/.exec(transform);
998
+ const s = /scale\(\s*(-?[\d.]+)(?:[\s,]+(-?[\d.]+))?/.exec(transform);
999
+ const kx = s ? Number(s[1]) : 1;
1000
+ return {
1001
+ tx: t ? Number(t[1]) : 0,
1002
+ ty: t && t[2] !== void 0 ? Number(t[2]) : 0,
1003
+ kx,
1004
+ ky: s && s[2] !== void 0 ? Number(s[2]) : kx
1005
+ };
1006
+ }
1007
+ function fit(strokes, viewBox, transform, b) {
1008
+ const [vx, vy, vw, vh] = viewBox.split(/[\s,]+/).map(Number);
1009
+ const w = vw > 0 ? vw : 100;
1010
+ const h = vh > 0 ? vh : 100;
1011
+ const { tx, ty, kx, ky } = parseTransform(transform);
1012
+ const bx = sx(b[0]), by = sy(b[1]), bw = sx(b[2]), bh = sy(b[3]);
1013
+ const k = Math.min(bw / w, bh / h);
1014
+ const offX = bx + (bw - w * k) / 2;
1015
+ const offY = by + (bh - h * k) / 2;
1016
+ return strokes.map((stroke) => stroke.map((p) => ({
1017
+ x: offX + (tx + kx * p.x - (vx || 0)) * k,
1018
+ y: offY + (ty + ky * p.y - (vy || 0)) * k
1019
+ })));
1020
+ }
1021
+ function artStrokes(ink, b, seed = 1) {
1022
+ if ("icon" in ink) {
1023
+ const paths = storyboardIconStrokes(ink.icon);
1024
+ return roughen(fit(paths.flatMap((d) => flattenPath(d, 14)), "0 0 100 100", "", b), seed);
1025
+ }
1026
+ return fit(ink.contours.flatMap((d) => flattenPath(d, 6)), ink.view_box, ink.transform, b);
1027
+ }
1028
+ function pointAlong(strokes, length) {
1029
+ let left = length;
1030
+ for (const s of strokes) {
1031
+ for (let i = 1; i < s.length; i += 1) {
1032
+ const seg = Math.hypot(s[i].x - s[i - 1].x, s[i].y - s[i - 1].y);
1033
+ if (left <= seg) {
1034
+ const t = seg ? left / seg : 1;
1035
+ return { x: s[i - 1].x + (s[i].x - s[i - 1].x) * t, y: s[i - 1].y + (s[i].y - s[i - 1].y) * t };
1036
+ }
1037
+ left -= seg;
1038
+ }
1039
+ }
1040
+ const last = strokes[strokes.length - 1];
1041
+ return last ? last[last.length - 1] : null;
1042
+ }
1043
+ const STILL = { dx: 0, dy: 0, turn: 0, grow: 1 };
1044
+ const posed = (pose) => !!pose && (pose.dx !== 0 || pose.dy !== 0 || pose.turn % 360 !== 0 || pose.grow !== 1);
1045
+ const ease = (t) => 0.5 - Math.cos(Math.PI * Math.min(1, Math.max(0, t))) / 2;
1046
+ const FLOW_MS = 2400;
1047
+ const PULSE_MS = 800;
1048
+ const COUNT_MS = 1500;
1049
+ const MOVE_PER_MS = 0.55;
1050
+ const FLOW_GAP = 90;
1051
+ const FLOW_DASH = 34;
1052
+ function motionDuration(item) {
1053
+ switch (item.kind) {
1054
+ case "move": {
1055
+ let length = 0;
1056
+ item.path.reduce((a, b) => {
1057
+ if (a) length += Math.hypot(sx(b[0] - a[0]), sy(b[1] - a[1]));
1058
+ return b;
1059
+ }, null);
1060
+ return Math.min(3200, Math.max(900, (length + 400) / MOVE_PER_MS));
1061
+ }
1062
+ case "turn":
1063
+ return Math.min(3200, Math.max(900, Math.abs(item.by) * 4));
1064
+ case "pulse":
1065
+ return PULSE_MS;
1066
+ case "count":
1067
+ return COUNT_MS;
1068
+ default:
1069
+ return FLOW_MS;
1070
+ }
1071
+ }
1072
+ function smooth(pts) {
1073
+ if (pts.length < 3) return pts;
1074
+ const out = [];
1075
+ for (let i = 0; i < pts.length - 1; i += 1) {
1076
+ const p0 = pts[Math.max(0, i - 1)];
1077
+ const p1 = pts[i];
1078
+ const p2 = pts[i + 1];
1079
+ const p3 = pts[Math.min(pts.length - 1, i + 2)];
1080
+ for (let k = 0; k < 12; k += 1) {
1081
+ const t = k / 12;
1082
+ const t2 = t * t;
1083
+ const t3 = t2 * t;
1084
+ const f = (a, b, c, d) => 0.5 * (2 * b + (c - a) * t + (2 * a - 5 * b + 4 * c - d) * t2 + (3 * b - a - 3 * c + d) * t3);
1085
+ out.push({ x: f(p0.x, p1.x, p2.x, p3.x), y: f(p0.y, p1.y, p2.y, p3.y) });
1086
+ }
1087
+ }
1088
+ out.push(pts[pts.length - 1]);
1089
+ return out;
1090
+ }
1091
+ function along(pts, at) {
1092
+ const lengths = pts.slice(1).map((b, i) => Math.hypot(b.x - pts[i].x, b.y - pts[i].y));
1093
+ let left = lengths.reduce((a, b) => a + b, 0) * at;
1094
+ for (let i = 0; i < lengths.length; i += 1) {
1095
+ if (left <= lengths[i]) {
1096
+ const t = lengths[i] ? left / lengths[i] : 1;
1097
+ return { x: pts[i].x + (pts[i + 1].x - pts[i].x) * t, y: pts[i].y + (pts[i + 1].y - pts[i].y) * t };
1098
+ }
1099
+ left -= lengths[i];
1100
+ }
1101
+ return pts[pts.length - 1];
1102
+ }
1103
+ function movePath(item, centre, from) {
1104
+ return smooth([{ x: centre.x + from.dx, y: centre.y + from.dy }, ...item.path.map(([x, y]) => ({ x: sx(x), y: sy(y) }))]);
1105
+ }
1106
+ function poseAt(item, from, centre, path, t) {
1107
+ switch (item.kind) {
1108
+ case "move": {
1109
+ const at = along(path, ease(t));
1110
+ return { ...from, dx: at.x - centre.x, dy: at.y - centre.y };
1111
+ }
1112
+ case "turn":
1113
+ return { ...from, turn: from.turn + item.by * ease(t) };
1114
+ case "pulse":
1115
+ return { ...from, grow: from.grow * (1 + 0.16 * Math.sin(Math.PI * Math.min(1, t))) };
1116
+ default:
1117
+ return from;
1118
+ }
1119
+ }
1120
+ function placed(p, centre, pose) {
1121
+ const a = pose.turn * Math.PI / 180;
1122
+ const cos = Math.cos(a) * pose.grow;
1123
+ const sin = Math.sin(a) * pose.grow;
1124
+ const x = p.x - centre.x;
1125
+ const y = p.y - centre.y;
1126
+ return { x: centre.x + pose.dx + x * cos - y * sin, y: centre.y + pose.dy + x * sin + y * cos };
1127
+ }
1128
+ const markFade = (t) => Math.min(1, Math.min(t, 1 - t) * 6);
1129
+ function flowDashes(strokes, run) {
1130
+ const stroke = strokes.reduce((best, s) => strokeLength(s) > strokeLength(best) ? s : best, []);
1131
+ const length = strokeLength(stroke);
1132
+ if (length < 2) return [];
1133
+ const dashes = [];
1134
+ for (let at = run % FLOW_GAP; at < length; at += FLOW_GAP) {
1135
+ const a = pointAlong([stroke], at);
1136
+ const b = pointAlong([stroke], Math.min(length, at + FLOW_DASH));
1137
+ if (a && b) dashes.push([a, b]);
1138
+ }
1139
+ return dashes;
1140
+ }
1141
+ const flowRun = (t, duration) => t * duration * 0.22;
1142
+ function spinArrows(c, r, angle, dir) {
1143
+ const sweep = 70 * Math.PI / 180;
1144
+ const out = [];
1145
+ for (const half of [0, Math.PI]) {
1146
+ const a0 = angle + half;
1147
+ const a1 = a0 + sweep * dir;
1148
+ const arc = [];
1149
+ for (let k = 0; k <= 14; k += 1) {
1150
+ const a = a0 + (a1 - a0) * k / 14;
1151
+ arc.push({ x: c.x + r * Math.cos(a), y: c.y + r * Math.sin(a) });
1152
+ }
1153
+ out.push(arc);
1154
+ const tip = arc[arc.length - 1];
1155
+ const heading = a1 + Math.PI / 2 * dir;
1156
+ for (const side of [-0.5, 0.5]) {
1157
+ out.push([tip, { x: tip.x - 22 * Math.cos(heading + side), y: tip.y - 22 * Math.sin(heading + side) }]);
1158
+ }
1159
+ }
1160
+ return out;
1161
+ }
1162
+ const spinAngle = (turned) => -Math.PI / 2 + turned * Math.PI / 180;
1163
+ const NUMBER = /-?\d[\d,]*(?:\.\d+)?/;
1164
+ const parseNumber = (text) => Number(text.replace(/,/g, ""));
1165
+ function counted(start, value, t) {
1166
+ var _a;
1167
+ if (t >= 1) return value;
1168
+ const goal = value.match(NUMBER);
1169
+ if (!goal) return value;
1170
+ const first = start.match(NUMBER);
1171
+ const a = first ? parseNumber(first[0]) : 0;
1172
+ const b = parseNumber(goal[0]);
1173
+ if (!Number.isFinite(a) || !Number.isFinite(b)) return value;
1174
+ const decimals = ((_a = goal[0].split(".")[1]) != null ? _a : "").length;
1175
+ const n = a + (b - a) * ease(t);
1176
+ const shown = goal[0].includes(",") ? n.toLocaleString("en-GB", { minimumFractionDigits: decimals, maximumFractionDigits: decimals }) : n.toFixed(decimals);
1177
+ return value.replace(goal[0], shown);
1178
+ }
1179
+ const INK = { ink: "#1f2937", blue: "#2563eb", red: "#dc2626", green: "#059669" };
1180
+ const MARKER = "rgba(250, 204, 21, 0.42)";
1181
+ const TEXT_SIZE = { s: 2.3, m: 3.1, l: 4.3 };
1182
+ const TRAVEL_MS = 200;
1183
+ const TABLE_ROW_H = 5.8;
1184
+ class BoardModel {
1185
+ constructor(options) {
1186
+ this.options = options;
1187
+ this.inks = [];
1188
+ this.pictures = [];
1189
+ this.credit = null;
1190
+ this.words = [];
1191
+ this.marks = [];
1192
+ this.pen = null;
1193
+ this.caption = "";
1194
+ this.step = -1;
1195
+ this.player = null;
1196
+ this.scene = null;
1197
+ this.nextKey = 1;
1198
+ this.epoch = 0;
1199
+ }
1200
+ snapshot() {
1201
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1202
+ return {
1203
+ inks: this.inks,
1204
+ pictures: this.pictures,
1205
+ credit: this.credit,
1206
+ words: this.words,
1207
+ marks: this.marks,
1208
+ pen: this.pen,
1209
+ caption: this.caption,
1210
+ step: this.step,
1211
+ steps: (_b = (_a = this.scene) == null ? void 0 : _a.steps.length) != null ? _b : 0,
1212
+ state: (_d = (_c = this.player) == null ? void 0 : _c.status) != null ? _d : "idle",
1213
+ title: (_f = (_e = this.scene) == null ? void 0 : _e.title) != null ? _f : "",
1214
+ sample: (_h = (_g = this.scene) == null ? void 0 : _g.sample) != null ? _h : false
1215
+ };
1216
+ }
1217
+ play(scene) {
1218
+ var _a, _b, _c, _d, _e;
1219
+ this.destroy();
1220
+ this.scene = scene;
1221
+ const steps = scene.steps.map((step, index) => this.buildStep(step, index));
1222
+ this.player = new Player(steps, {
1223
+ narrate: (_a = this.options.narrate) != null ? _a : (async () => false),
1224
+ stopNarration: () => {
1225
+ var _a2, _b2;
1226
+ return (_b2 = (_a2 = this.options).stopNarration) == null ? void 0 : _b2.call(_a2);
1227
+ },
1228
+ reset: () => this.wipe(),
1229
+ onStep: (index, step) => {
1230
+ this.step = index;
1231
+ this.caption = step.say;
1232
+ this.changed();
1233
+ },
1234
+ onState: () => this.changed(),
1235
+ requestFrame: (_b = this.options.requestFrame) != null ? _b : ((cb) => requestAnimationFrame(cb)),
1236
+ cancelFrame: (_c = this.options.cancelFrame) != null ? _c : ((id) => cancelAnimationFrame(id)),
1237
+ now: (_d = this.options.now) != null ? _d : (() => Date.now())
1238
+ }, (_e = this.options.reducedMotion) != null ? _e : false);
1239
+ this.player.play();
1240
+ }
1241
+ /** Pause, or carry on from where it was. */
1242
+ toggle() {
1243
+ if (!this.player) return;
1244
+ if (this.player.status === "playing") this.player.pause();
1245
+ else this.player.play();
1246
+ }
1247
+ replay() {
1248
+ var _a;
1249
+ (_a = this.player) == null ? void 0 : _a.replay();
1250
+ }
1251
+ seek(step) {
1252
+ var _a;
1253
+ (_a = this.player) == null ? void 0 : _a.seek(step);
1254
+ }
1255
+ setSpeed(speed) {
1256
+ var _a;
1257
+ (_a = this.player) == null ? void 0 : _a.setSpeed(speed);
1258
+ }
1259
+ get speed() {
1260
+ var _a, _b;
1261
+ return (_b = (_a = this.player) == null ? void 0 : _a.rate) != null ? _b : 1;
1262
+ }
1263
+ /** Stop for good: no frames, nothing on the board. */
1264
+ destroy() {
1265
+ var _a;
1266
+ (_a = this.player) == null ? void 0 : _a.destroy();
1267
+ this.player = null;
1268
+ this.scene = null;
1269
+ this.wipe();
1270
+ this.step = -1;
1271
+ this.caption = "";
1272
+ }
1273
+ changed() {
1274
+ this.options.onChange();
1275
+ }
1276
+ wipe() {
1277
+ this.epoch += 1;
1278
+ this.marks = [];
1279
+ this.inks = [];
1280
+ this.pictures = [];
1281
+ this.credit = null;
1282
+ this.words = [];
1283
+ this.pen = null;
1284
+ this.changed();
1285
+ }
1286
+ // ------------------------------------------------------------- steps → ops
1287
+ buildStep(step, index) {
1288
+ return {
1289
+ say: step.say,
1290
+ enter: () => {
1291
+ if (step.clear) this.wipe();
1292
+ },
1293
+ ops: this.stepOps(step.draw, index)
1294
+ };
1295
+ }
1296
+ /** One op per item, except that motion items side by side become one op that plays them together. */
1297
+ stepOps(draw, index) {
1298
+ const ops = [];
1299
+ let group = [];
1300
+ const flush = () => {
1301
+ if (group.length === 1) ops.push(group[0]);
1302
+ else if (group.length) {
1303
+ const parts = group;
1304
+ ops.push({ duration: Math.max(...parts.map((op) => op.duration)), run: (p) => {
1305
+ for (const op of parts) op.run(p);
1306
+ } });
1307
+ }
1308
+ group = [];
1309
+ };
1310
+ draw.forEach((item, i) => {
1311
+ const op = this.opFor(item, index * 100 + i + 1);
1312
+ if (motionTarget(item) !== null) {
1313
+ group.push(op);
1314
+ return;
1315
+ }
1316
+ flush();
1317
+ ops.push(op);
1318
+ });
1319
+ flush();
1320
+ return ops;
1321
+ }
1322
+ opFor(item, seed) {
1323
+ var _a, _b, _c, _d;
1324
+ switch (item.kind) {
1325
+ case "ink":
1326
+ return this.inkOp(item.id, inkStrokes(item.ink, item, seed), INK[item.tone], item.ink === "dot" ? 9 : 7, item.ink === "dot" ? 250 : 350, 2600, 1.1);
1327
+ case "art": {
1328
+ const ink = (_a = this.scene) == null ? void 0 : _a.art[item.art];
1329
+ if (!ink) {
1330
+ const [x, y, w, h] = item.at;
1331
+ return this.textOp({ kind: "text", id: item.id, text: item.art, at: [x + 1, y + h / 2], size: w < 15 ? "s" : "m", tone: item.tone });
1332
+ }
1333
+ return this.inkOp(item.id, artStrokes(ink, item.at, seed), INK[item.tone], "icon" in ink ? 7 : 4, 1100, 4500, 2.6);
1334
+ }
1335
+ case "photo": {
1336
+ const pic = (_c = (_b = this.scene) == null ? void 0 : _b.photos) == null ? void 0 : _c[item.photo];
1337
+ if (!pic) {
1338
+ const [x, y, w, h] = item.at;
1339
+ return this.textOp({ kind: "text", id: item.id, text: item.photo, at: [x + 1, y + h / 2], size: w < 15 ? "s" : "m", tone: "ink" });
1340
+ }
1341
+ return this.photoOp(item, pic.url, (_d = pic.credit) != null ? _d : null);
1342
+ }
1343
+ case "text":
1344
+ return this.textOp(item);
1345
+ case "table":
1346
+ return this.tableOp(item);
1347
+ case "mark":
1348
+ return this.markOp(item.mark);
1349
+ case "erase":
1350
+ return this.eraseOp(item.erase);
1351
+ case "move":
1352
+ case "flow":
1353
+ case "turn":
1354
+ case "pulse":
1355
+ case "count":
1356
+ return this.motionOp(item);
1357
+ default:
1358
+ return { duration: 0, run: () => void 0 };
1359
+ }
1360
+ }
1361
+ inkOp(id, strokes, color, width, min, max, perMs, marker = false) {
1362
+ const length = totalLength(strokes);
1363
+ const duration = Math.min(max, Math.max(min, length / perMs)) + TRAVEL_MS;
1364
+ const share = TRAVEL_MS / duration;
1365
+ let obj = null;
1366
+ let made = -1;
1367
+ return {
1368
+ duration,
1369
+ run: (progress) => {
1370
+ var _a, _b;
1371
+ if (!obj || made !== this.epoch) {
1372
+ made = this.epoch;
1373
+ obj = { key: this.nextKey++, id, strokes, length, color, width, marker, drawn: 0 };
1374
+ this.inks = [...this.inks, obj];
1375
+ }
1376
+ if (!length) return;
1377
+ const drawn = progress >= 1 ? 1 : Math.max(0, (progress - share) / (1 - share));
1378
+ obj.drawn = drawn;
1379
+ this.pen = drawn > 0 ? pointAlong(strokes, length * drawn) : (_b = (_a = strokes[0]) == null ? void 0 : _a[0]) != null ? _b : this.pen;
1380
+ this.changed();
1381
+ }
1382
+ };
1383
+ }
1384
+ photoOp(item, url, credit) {
1385
+ const duration = 1400 + TRAVEL_MS;
1386
+ const [x, y, w, h] = item.at;
1387
+ let pic = null;
1388
+ let made = -1;
1389
+ return {
1390
+ duration,
1391
+ run: (progress) => {
1392
+ if (!pic || made !== this.epoch) {
1393
+ made = this.epoch;
1394
+ pic = { key: this.nextKey++, id: item.id, url, alt: item.photo, at: item.at, shown: 0, marked: false };
1395
+ this.pictures = [...this.pictures, pic];
1396
+ if (credit) this.credit = credit;
1397
+ }
1398
+ const shown = progress >= 1 ? 1 : Math.max(0, (progress * duration - TRAVEL_MS) / (duration - TRAVEL_MS));
1399
+ pic.shown = shown;
1400
+ this.pen = shown < 1 ? { x: sx(x + w * shown), y: sy(y + h * (0.5 + 0.35 * Math.sin(shown * 9))) } : this.pen;
1401
+ this.changed();
1402
+ }
1403
+ };
1404
+ }
1405
+ textOp(item) {
1406
+ const duration = Math.min(2e3, Math.max(350, item.text.length * 60)) + TRAVEL_MS;
1407
+ let word = null;
1408
+ let made = -1;
1409
+ return {
1410
+ duration,
1411
+ run: (progress) => {
1412
+ if (!word || made !== this.epoch) {
1413
+ made = this.epoch;
1414
+ word = { key: this.nextKey++, id: item.id, kind: "text", text: item.text, at: item.at, size: item.size, color: INK[item.tone], shown: 0, marked: false, gone: false };
1415
+ this.words = [...this.words, word];
1416
+ }
1417
+ word.shown = progress >= 1 ? 1 : Math.max(0, (progress * duration - TRAVEL_MS) / (duration - TRAVEL_MS));
1418
+ const height = TEXT_SIZE[item.size] / 100 * BOARD_W;
1419
+ this.pen = { x: sx(item.at[0] + item.text.length * height * 0.55 * word.shown), y: sy(item.at[1]) };
1420
+ this.changed();
1421
+ }
1422
+ };
1423
+ }
1424
+ tableOp(item) {
1425
+ let table = null;
1426
+ let made = -1;
1427
+ return {
1428
+ duration: item.rows.length * 450 + TRAVEL_MS,
1429
+ run: (progress) => {
1430
+ if (!table || made !== this.epoch) {
1431
+ made = this.epoch;
1432
+ table = { key: this.nextKey++, id: item.id, kind: "table", rows: item.rows, at: item.at, color: INK[item.tone], rowsShown: 0, marked: false, gone: false };
1433
+ this.words = [...this.words, table];
1434
+ }
1435
+ table.rowsShown = progress >= 1 ? item.rows.length : Math.max(progress > 0 ? 1 : 0, Math.floor(progress * item.rows.length));
1436
+ this.pen = { x: sx(item.at[0] + item.at[2]), y: sy(item.at[1]) };
1437
+ this.changed();
1438
+ }
1439
+ };
1440
+ }
1441
+ markOp(id) {
1442
+ let done = false;
1443
+ let made = -1;
1444
+ return {
1445
+ duration: 650,
1446
+ run: () => {
1447
+ var _a;
1448
+ if (made !== this.epoch) {
1449
+ made = this.epoch;
1450
+ done = false;
1451
+ }
1452
+ if (done) return;
1453
+ done = true;
1454
+ const thing = (_a = this.words.find((w) => w.id === id)) != null ? _a : this.pictures.find((p) => p.id === id);
1455
+ if (thing) {
1456
+ thing.marked = true;
1457
+ this.changed();
1458
+ return;
1459
+ }
1460
+ const ink = this.inks.find((obj) => obj.id === id && !obj.marker);
1461
+ const where = ink == null ? void 0 : ink.placed;
1462
+ const shape = ink && where && posed(where.pose) ? ink.strokes.map((st) => st.map((p) => placed(p, where.centre, where.pose))) : ink == null ? void 0 : ink.strokes;
1463
+ const box = shape ? bounds(shape) : null;
1464
+ if (!ink || !shape || !box) return;
1465
+ const tall = box.y1 - box.y0;
1466
+ const mid = (box.y0 + box.y1) / 2;
1467
+ const strokes = tall <= 120 ? [[{ x: box.x0 - 14, y: mid }, { x: box.x1 + 14, y: mid }]] : shape;
1468
+ this.inks = [{
1469
+ key: this.nextKey++,
1470
+ strokes,
1471
+ length: totalLength(strokes),
1472
+ color: MARKER,
1473
+ width: tall <= 120 ? Math.max(24, tall * 0.6) : 26,
1474
+ marker: true,
1475
+ drawn: 1
1476
+ }, ...this.inks];
1477
+ this.changed();
1478
+ }
1479
+ };
1480
+ }
1481
+ eraseOp(id) {
1482
+ return {
1483
+ duration: 350,
1484
+ run: (progress) => {
1485
+ if (progress < 1) return;
1486
+ this.words = this.words.filter((w) => w.id !== id);
1487
+ this.pictures = this.pictures.filter((p) => p.id !== id);
1488
+ this.inks = this.inks.filter((obj) => obj.id !== id);
1489
+ this.changed();
1490
+ }
1491
+ };
1492
+ }
1493
+ // ------------------------------------------------------------- motion
1494
+ find(id) {
1495
+ var _a, _b, _c;
1496
+ return (_c = (_b = (_a = this.words.find((w) => w.id === id)) != null ? _a : this.pictures.find((p) => p.id === id)) != null ? _b : this.inks.find((obj) => obj.id === id && !obj.marker)) != null ? _c : null;
1497
+ }
1498
+ /** A thing's centre and size where it was drawn, in sheet units (before any motion). */
1499
+ frame(thing) {
1500
+ var _a;
1501
+ if ("strokes" in thing) {
1502
+ const box = (_a = bounds(thing.strokes)) != null ? _a : { x0: 0, y0: 0, x1: 0, y1: 0 };
1503
+ return { centre: { x: (box.x0 + box.x1) / 2, y: (box.y0 + box.y1) / 2 }, w: box.x1 - box.x0, h: box.y1 - box.y0 };
1504
+ }
1505
+ if ("url" in thing) {
1506
+ const [x, y, w, h] = thing.at;
1507
+ return { centre: { x: sx(x + w / 2), y: sy(y + h / 2) }, w: sx(w), h: sy(h) };
1508
+ }
1509
+ if (thing.kind === "text") {
1510
+ const tall = TEXT_SIZE[thing.size] / 100 * BOARD_W;
1511
+ const wide = thing.text.length * tall * 0.55;
1512
+ return { centre: { x: sx(thing.at[0] + wide / 2), y: sy(thing.at[1]) }, w: sx(wide), h: sy(tall) };
1513
+ }
1514
+ const high = thing.rows.length * TABLE_ROW_H;
1515
+ return { centre: { x: sx(thing.at[0] + thing.at[2] / 2), y: sy(thing.at[1] + high / 2) }, w: sx(thing.at[2]), h: sy(high) };
1516
+ }
1517
+ /**
1518
+ * Motion on something already drawn. The target is found when the op
1519
+ * starts (once per playthrough); one that is not on the board is skipped.
1520
+ * Run with 1 alone (a jump, reduced motion), it lands at the end.
1521
+ */
1522
+ motionOp(item) {
1523
+ var _a;
1524
+ const id = (_a = motionTarget(item)) != null ? _a : "";
1525
+ const duration = motionDuration(item);
1526
+ let made = -1;
1527
+ let thing = null;
1528
+ let from = STILL;
1529
+ let centre = { x: 0, y: 0 };
1530
+ let path = [];
1531
+ let mark = null;
1532
+ let size = 0;
1533
+ let text = "";
1534
+ return {
1535
+ duration,
1536
+ run: (progress) => {
1537
+ var _a2, _b, _c, _d;
1538
+ if (made !== this.epoch) {
1539
+ made = this.epoch;
1540
+ mark = null;
1541
+ thing = this.find(id);
1542
+ if (!thing) return;
1543
+ const frame = this.frame(thing);
1544
+ centre = (_b = (_a2 = thing.placed) == null ? void 0 : _a2.centre) != null ? _b : frame.centre;
1545
+ from = { ...(_d = (_c = thing.placed) == null ? void 0 : _c.pose) != null ? _d : STILL };
1546
+ size = Math.max(frame.w, frame.h);
1547
+ if (item.kind === "move") path = movePath(item, centre, from);
1548
+ if (item.kind === "count" && "kind" in thing && thing.kind === "text") text = thing.text;
1549
+ if (item.kind === "flow" && "strokes" in thing || item.kind === "turn") {
1550
+ mark = { key: this.nextKey++, strokes: [], color: "color" in thing ? thing.color : INK.ink, width: 6, opacity: 0 };
1551
+ if (item.kind === "flow" && "strokes" in thing) mark.width = thing.width * 2.4;
1552
+ this.marks = [...this.marks, mark];
1553
+ }
1554
+ }
1555
+ if (!thing) return;
1556
+ const t = Math.min(1, progress);
1557
+ if (item.kind === "move" || item.kind === "turn" || item.kind === "pulse") {
1558
+ const pose = poseAt(item, from, centre, path, t);
1559
+ thing.placed = { pose, centre };
1560
+ if (mark) {
1561
+ mark.strokes = spinArrows({ x: centre.x + from.dx, y: centre.y + from.dy }, size / 2 * from.grow + 30, spinAngle(pose.turn - from.turn), item.kind === "turn" && item.by < 0 ? -1 : 1);
1562
+ mark.opacity = markFade(t) * 0.85;
1563
+ }
1564
+ } else if (item.kind === "count" && "kind" in thing && thing.kind === "text") {
1565
+ thing.text = counted(text, item.value, t);
1566
+ } else if (mark && "strokes" in thing) {
1567
+ mark.strokes = flowDashes(thing.strokes, flowRun(t, duration));
1568
+ mark.opacity = markFade(t);
1569
+ mark.placed = thing.placed;
1570
+ }
1571
+ if (progress >= 1 && mark) {
1572
+ const done = mark;
1573
+ this.marks = this.marks.filter((m) => m !== done);
1574
+ mark = null;
1575
+ }
1576
+ this.changed();
1577
+ }
1578
+ };
1579
+ }
1580
+ }
1581
+ function inkPath(strokes, length, upTo) {
1582
+ let left = length * upTo;
1583
+ const parts = [];
1584
+ for (const stroke of strokes) {
1585
+ if (left <= 0 || stroke.length < 2) break;
1586
+ let d = `M${stroke[0].x.toFixed(1)} ${stroke[0].y.toFixed(1)}`;
1587
+ for (let i = 1; i < stroke.length; i += 1) {
1588
+ const a = stroke[i - 1];
1589
+ const b = stroke[i];
1590
+ const seg = Math.hypot(b.x - a.x, b.y - a.y);
1591
+ if (seg >= left) {
1592
+ const t = seg ? left / seg : 1;
1593
+ d += `L${(a.x + (b.x - a.x) * t).toFixed(1)} ${(a.y + (b.y - a.y) * t).toFixed(1)}`;
1594
+ left = 0;
1595
+ break;
1596
+ }
1597
+ d += `L${b.x.toFixed(1)} ${b.y.toFixed(1)}`;
1598
+ left -= seg;
1599
+ }
1600
+ parts.push(d);
1601
+ }
1602
+ return parts.join("");
1603
+ }
1604
+ function strokesPath(strokes) {
1605
+ return strokes.filter((st) => st.length > 1).map((st) => st.map((p, i) => `${i ? "L" : "M"}${p.x.toFixed(1)} ${p.y.toFixed(1)}`).join("")).join("");
1606
+ }
1607
+ function poseTransform(where) {
1608
+ if (!where || !posed(where.pose)) return void 0;
1609
+ const { pose, centre: c } = where;
1610
+ return `translate(${(c.x + pose.dx).toFixed(1)} ${(c.y + pose.dy).toFixed(1)}) rotate(${pose.turn.toFixed(1)}) scale(${pose.grow.toFixed(3)}) translate(${(-c.x).toFixed(1)} ${(-c.y).toFixed(1)})`;
1611
+ }
1612
+ const darkTheme = {
1613
+ background: "#0B0713",
1614
+ surface: "rgba(255,255,255,0.06)",
1615
+ surfaceRaised: "#1C1626",
1616
+ text: "#F5F3FF",
1617
+ textMuted: "#8B85A0",
1618
+ accent: "#7C5CFF",
1619
+ onAccent: "#FFFFFF",
1620
+ userBubble: "#7C5CFF",
1621
+ onUserBubble: "#FFFFFF",
1622
+ error: "rgba(248,113,113,0.16)",
1623
+ border: "rgba(255,255,255,0.10)",
1624
+ radius: 22,
1625
+ fontSize: 15
1626
+ };
1627
+ const lightTheme = {
1628
+ background: "#FFFFFF",
1629
+ surface: "#F1F5F9",
1630
+ surfaceRaised: "#FFFFFF",
1631
+ text: "#0F172A",
1632
+ textMuted: "#64748B",
1633
+ accent: "#7C5CFF",
1634
+ onAccent: "#FFFFFF",
1635
+ userBubble: "#7C5CFF",
1636
+ onUserBubble: "#FFFFFF",
1637
+ error: "#FEE2E2",
1638
+ border: "#E2E8F0",
1639
+ radius: 22,
1640
+ fontSize: 15
1641
+ };
1642
+ function resolveTheme(overrides, base = lightTheme) {
1643
+ return overrides ? { ...base, ...overrides } : base;
1644
+ }
1645
+ const SHEET_W = 1600;
1646
+ const SHEET_H = 1e3;
1647
+ const HAND = Platform.select({ ios: "Bradley Hand", android: "casual", default: void 0 });
1648
+ const PEN = "M0 0 L-5 -22 L22 -70 L32 -63 L5 -16 Z";
1649
+ function GuideAIWhiteboard({ theme: overrides }) {
1650
+ const theme = resolveTheme(overrides);
1651
+ const { state, close, retry } = useWhiteboard();
1652
+ const [, repaint] = useReducer((n) => n + 1, 0);
1653
+ const [width, setWidth] = useState(0);
1654
+ const [expanded, setExpanded] = useState(false);
1655
+ const motion = useRef({ reduced: false });
1656
+ const speech = GuideAI.isConfigured() ? requireConfigured().speech : null;
1657
+ const [muted, setMuted] = useState(false);
1658
+ const voice = useRef({ muted: false });
1659
+ voice.current.muted = muted;
1660
+ const model = useMemo(() => new BoardModel({
1661
+ onChange: () => repaint(),
1662
+ get reducedMotion() {
1663
+ return motion.current.reduced;
1664
+ },
1665
+ narrate: async (text) => speech && !voice.current.muted ? speech.say(text) : false,
1666
+ stopNarration: () => speech == null ? void 0 : speech.stop()
1667
+ }), [speech]);
1668
+ const toggleVoice = () => {
1669
+ if (!muted) speech == null ? void 0 : speech.stop();
1670
+ setMuted((on) => !on);
1671
+ };
1672
+ useEffect(() => {
1673
+ var _a, _b;
1674
+ void ((_b = (_a = AccessibilityInfo).isReduceMotionEnabled) == null ? void 0 : _b.call(_a).then((on) => {
1675
+ motion.current.reduced = on;
1676
+ }, () => void 0));
1677
+ }, []);
1678
+ useEffect(() => {
1679
+ if (state.status === "playing" && state.scene) model.play(state.scene);
1680
+ else model.destroy();
1681
+ }, [model, state.status, state.scene]);
1682
+ useEffect(() => () => model.destroy(), [model]);
1683
+ if (state.status === "closed") return null;
1684
+ const board = model.snapshot();
1685
+ const height = width / (BOARD_W / BOARD_H);
1686
+ const unit2 = width / 100;
1687
+ const playing = board.state === "playing";
1688
+ const title = state.status === "playing" ? board.title : state.question;
1689
+ const shut = () => {
1690
+ model.destroy();
1691
+ close();
1692
+ };
1693
+ return /* @__PURE__ */ jsx(Modal, { visible: true, transparent: true, animationType: "fade", onRequestClose: shut, supportedOrientations: ["portrait", "landscape"], children: /* @__PURE__ */ jsx(View, { style: [styles$3.backdrop, expanded ? styles$3.centre : null], pointerEvents: "box-none", children: /* @__PURE__ */ jsxs(
1694
+ View,
1695
+ {
1696
+ style: [styles$3.card, { backgroundColor: theme.surfaceRaised, borderColor: theme.border, maxWidth: expanded ? 1040 : 540 }],
1697
+ accessibilityViewIsModal: true,
1698
+ accessibilityLabel: `Whiteboard: ${title}`,
1699
+ children: [
1700
+ /* @__PURE__ */ jsxs(View, { style: styles$3.head, children: [
1701
+ /* @__PURE__ */ jsx(Text, { style: [styles$3.title, { color: theme.text }], numberOfLines: 1, children: title || "Whiteboard" }),
1702
+ board.sample && state.status === "playing" ? /* @__PURE__ */ jsx(Text, { style: styles$3.badge, accessibilityHint: "This board uses example numbers.", children: "Example" }) : null,
1703
+ speech ? /* @__PURE__ */ jsx(IconButton, { label: muted ? "Read the board aloud" : "Mute the board", glyph: muted ? "🔇" : "🔈", color: theme.textMuted, onPress: toggleVoice }) : null,
1704
+ /* @__PURE__ */ jsx(IconButton, { label: expanded ? "Collapse whiteboard" : "Expand whiteboard", glyph: expanded ? "⤡" : "⤢", color: theme.textMuted, onPress: () => setExpanded((v) => !v) }),
1705
+ /* @__PURE__ */ jsx(IconButton, { label: "Close whiteboard", glyph: "✕", color: theme.textMuted, onPress: shut })
1706
+ ] }),
1707
+ /* @__PURE__ */ jsxs(View, { style: styles$3.sheet, onLayout: (e) => setWidth(e.nativeEvent.layout.width), children: [
1708
+ width > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
1709
+ /* @__PURE__ */ jsxs(Svg, { width, height, viewBox: `0 0 ${SHEET_W} ${SHEET_H}`, children: [
1710
+ board.pictures.map((pic) => /* @__PURE__ */ jsx(Picture, { pic }, pic.key)),
1711
+ board.inks.filter((obj) => obj.marker).map((obj) => /* @__PURE__ */ jsx(Ink, { obj }, obj.key)),
1712
+ board.inks.filter((obj) => !obj.marker).map((obj) => /* @__PURE__ */ jsx(Ink, { obj }, obj.key)),
1713
+ board.marks.map((mark) => /* @__PURE__ */ jsx(Mark, { mark }, mark.key)),
1714
+ board.pen && playing && !motion.current.reduced ? /* @__PURE__ */ jsx(G, { transform: `translate(${board.pen.x.toFixed(1)} ${board.pen.y.toFixed(1)})`, children: /* @__PURE__ */ jsx(Path, { d: PEN, fill: "#fde68a", stroke: "#1f2937", strokeWidth: 3, strokeLinejoin: "round" }) }) : null
1715
+ ] }),
1716
+ board.words.map((word) => /* @__PURE__ */ jsx(Word, { word, width, height, unit: unit2 }, word.key)),
1717
+ board.credit ? /* @__PURE__ */ jsxs(Text, { style: styles$3.credit, numberOfLines: 1, children: [
1718
+ "Picture: ",
1719
+ board.credit
1720
+ ] }) : null
1721
+ ] }) : null,
1722
+ state.status === "loading" ? /* @__PURE__ */ jsxs(View, { style: styles$3.status, accessibilityLiveRegion: "polite", children: [
1723
+ /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.accent }),
1724
+ /* @__PURE__ */ jsx(Text, { style: styles$3.statusText, children: "Drawing your board…" })
1725
+ ] }) : null,
1726
+ state.status === "error" ? /* @__PURE__ */ jsxs(View, { style: styles$3.status, accessibilityLiveRegion: "assertive", children: [
1727
+ /* @__PURE__ */ jsx(Text, { style: styles$3.statusText, children: state.error }),
1728
+ /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: retry, style: [styles$3.retry, { backgroundColor: theme.accent }], children: /* @__PURE__ */ jsx(Text, { style: { color: theme.onAccent, fontWeight: "600" }, children: "Try again" }) })
1729
+ ] }) : null
1730
+ ] }),
1731
+ state.status === "playing" ? /* @__PURE__ */ jsxs(Fragment, { children: [
1732
+ /* @__PURE__ */ jsx(Text, { style: [styles$3.caption, { color: theme.text }], accessibilityLiveRegion: "polite", children: board.caption }),
1733
+ board.steps > 1 ? /* @__PURE__ */ jsx(View, { style: styles$3.track, accessibilityLabel: "Steps", children: Array.from({ length: board.steps }, (_, i) => /* @__PURE__ */ jsx(
1734
+ Pressable,
1735
+ {
1736
+ accessibilityRole: "button",
1737
+ accessibilityLabel: `Go to step ${i + 1}`,
1738
+ accessibilityState: { selected: i === board.step },
1739
+ onPress: () => model.seek(i),
1740
+ hitSlop: 8,
1741
+ style: [styles$3.segment, { backgroundColor: i <= board.step ? theme.accent : theme.border }]
1742
+ },
1743
+ i
1744
+ )) }) : null,
1745
+ /* @__PURE__ */ jsxs(View, { style: styles$3.bar, children: [
1746
+ /* @__PURE__ */ jsx(
1747
+ IconButton,
1748
+ {
1749
+ label: playing ? "Pause" : board.state === "done" ? "Play again" : "Resume",
1750
+ glyph: playing ? "❚❚" : board.state === "done" ? "↻" : "▶",
1751
+ color: theme.text,
1752
+ onPress: () => model.toggle()
1753
+ }
1754
+ ),
1755
+ /* @__PURE__ */ jsx(IconButton, { label: "Replay from the start", glyph: "↺", color: theme.text, onPress: () => model.replay() }),
1756
+ /* @__PURE__ */ jsx(Text, { style: [styles$3.step, { color: theme.textMuted }], children: board.step >= 0 ? `Step ${board.step + 1} of ${board.steps}` : "" }),
1757
+ /* @__PURE__ */ jsx(
1758
+ Pressable,
1759
+ {
1760
+ accessibilityRole: "button",
1761
+ accessibilityLabel: `Speed ${model.speed} times. Change speed`,
1762
+ onPress: () => {
1763
+ const at = SPEEDS.indexOf(model.speed);
1764
+ model.setSpeed(SPEEDS[(at + 1) % SPEEDS.length]);
1765
+ repaint();
1766
+ },
1767
+ style: [styles$3.speed, { borderColor: theme.border }],
1768
+ children: /* @__PURE__ */ jsxs(Text, { style: { color: theme.text, fontSize: 12 }, children: [
1769
+ model.speed,
1770
+ "×"
1771
+ ] })
1772
+ }
1773
+ )
1774
+ ] })
1775
+ ] }) : null
1776
+ ]
1777
+ }
1778
+ ) }) });
1779
+ }
1780
+ function Ink({ obj }) {
1781
+ if (obj.drawn <= 0) return null;
1782
+ return /* @__PURE__ */ jsx(G, { transform: poseTransform(obj.placed), children: /* @__PURE__ */ jsx(
1783
+ Path,
1784
+ {
1785
+ d: inkPath(obj.strokes, obj.length, obj.drawn),
1786
+ stroke: obj.color,
1787
+ strokeWidth: obj.width,
1788
+ fill: "none",
1789
+ strokeLinecap: "round",
1790
+ strokeLinejoin: "round"
1791
+ }
1792
+ ) });
1793
+ }
1794
+ function Mark({ mark }) {
1795
+ if (mark.opacity <= 0 || !mark.strokes.length) return null;
1796
+ return /* @__PURE__ */ jsx(G, { transform: poseTransform(mark.placed), opacity: mark.opacity, children: /* @__PURE__ */ jsx(Path, { d: strokesPath(mark.strokes), stroke: mark.color, strokeWidth: mark.width, fill: "none", strokeLinecap: "round", strokeLinejoin: "round" }) });
1797
+ }
1798
+ function moved(where, k) {
1799
+ if (!where) return void 0;
1800
+ const { pose } = where;
1801
+ return [
1802
+ { translateX: pose.dx * k },
1803
+ { translateY: pose.dy * k },
1804
+ { rotate: `${pose.turn.toFixed(1)}deg` },
1805
+ { scale: pose.grow }
1806
+ ];
1807
+ }
1808
+ function Picture({ pic }) {
1809
+ if (pic.shown <= 0) return null;
1810
+ const x = pic.at[0] / BOARD_W * SHEET_W;
1811
+ const y = pic.at[1] / BOARD_H * SHEET_H;
1812
+ const w = pic.at[2] / BOARD_W * SHEET_W;
1813
+ const h = pic.at[3] / BOARD_H * SHEET_H;
1814
+ const clip = `wb-pic-${pic.key}`;
1815
+ return /* @__PURE__ */ jsxs(G, { transform: poseTransform(pic.placed), children: [
1816
+ /* @__PURE__ */ jsx(Defs, { children: /* @__PURE__ */ jsx(ClipPath, { id: clip, children: /* @__PURE__ */ jsx(Rect, { x, y, width: w * pic.shown, height: h }) }) }),
1817
+ pic.marked ? /* @__PURE__ */ jsx(Rect, { x: x - 12, y: y - 12, width: w + 24, height: h + 24, rx: 14, fill: MARKER }) : null,
1818
+ /* @__PURE__ */ jsx(Image, { href: { uri: pic.url }, x, y, width: w, height: h, preserveAspectRatio: "xMidYMid meet", clipPath: `url(#${clip})` })
1819
+ ] });
1820
+ }
1821
+ function Word({ word, width, height, unit: unit2 }) {
1822
+ const left = word.at[0] / BOARD_W * width;
1823
+ const top = word.at[1] / BOARD_H * height;
1824
+ const transform = moved(word.placed, width / SHEET_W);
1825
+ if (word.kind === "text") {
1826
+ const size2 = unit2 * TEXT_SIZE[word.size];
1827
+ const shown = word.text.slice(0, Math.ceil(word.text.length * word.shown));
1828
+ if (!shown) return null;
1829
+ return /* @__PURE__ */ jsx(
1830
+ Text,
1831
+ {
1832
+ style: [styles$3.word, {
1833
+ left,
1834
+ top: top - size2 * 0.62,
1835
+ fontSize: size2,
1836
+ color: word.color,
1837
+ fontFamily: HAND,
1838
+ backgroundColor: word.marked ? MARKER : "transparent",
1839
+ transform
1840
+ }],
1841
+ accessibilityLabel: word.text,
1842
+ children: shown
1843
+ }
1844
+ );
1845
+ }
1846
+ if (word.rowsShown <= 0) return null;
1847
+ const size = unit2 * 2.2;
1848
+ return /* @__PURE__ */ jsx(View, { style: [styles$3.table, { left, top, width: word.at[2] / BOARD_W * width, borderColor: word.color, backgroundColor: word.marked ? MARKER : "transparent", transform }], children: word.rows.slice(0, word.rowsShown).map((row, r) => /* @__PURE__ */ jsx(View, { style: styles$3.row, children: row.map((cell, c) => /* @__PURE__ */ jsx(
1849
+ Text,
1850
+ {
1851
+ style: [styles$3.cell, { fontSize: size, color: word.color, borderColor: word.color, fontFamily: HAND, fontWeight: r === 0 ? "700" : "400" }],
1852
+ children: cell
1853
+ },
1854
+ c
1855
+ )) }, r)) });
1856
+ }
1857
+ function IconButton({ label, glyph, color, onPress }) {
1858
+ return /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: label, onPress, hitSlop: 8, style: styles$3.icon, children: /* @__PURE__ */ jsx(Text, { style: { color, fontSize: 16 }, children: glyph }) });
1859
+ }
1860
+ const styles$3 = StyleSheet.create({
1861
+ backdrop: { flex: 1, justifyContent: "flex-end", alignItems: "center", padding: 12 },
1862
+ centre: { justifyContent: "center" },
1863
+ card: {
1864
+ width: "100%",
1865
+ borderRadius: 16,
1866
+ borderWidth: StyleSheet.hairlineWidth,
1867
+ overflow: "hidden",
1868
+ shadowColor: "#0f172a",
1869
+ shadowOpacity: 0.25,
1870
+ shadowRadius: 24,
1871
+ shadowOffset: { width: 0, height: 12 },
1872
+ elevation: 12
1873
+ },
1874
+ head: { flexDirection: "row", alignItems: "center", paddingHorizontal: 12, paddingVertical: 8, gap: 6 },
1875
+ title: { flex: 1, fontSize: 14, fontWeight: "600" },
1876
+ badge: { fontSize: 11, fontWeight: "600", color: "#92400e", backgroundColor: "#fef3c7", borderRadius: 999, paddingHorizontal: 8, paddingVertical: 2, overflow: "hidden" },
1877
+ sheet: { width: "100%", aspectRatio: BOARD_W / BOARD_H, backgroundColor: "#fcfcfd" },
1878
+ status: { ...StyleSheet.absoluteFillObject, alignItems: "center", justifyContent: "center", gap: 10, backgroundColor: "rgba(252,252,253,0.92)", padding: 16 },
1879
+ statusText: { color: "#475569", fontSize: 13, textAlign: "center" },
1880
+ retry: { paddingHorizontal: 14, paddingVertical: 8, borderRadius: 8 },
1881
+ caption: { paddingHorizontal: 14, paddingTop: 10, fontSize: 14, lineHeight: 20, minHeight: 46 },
1882
+ track: { flexDirection: "row", gap: 4, paddingHorizontal: 14, paddingTop: 4 },
1883
+ segment: { flex: 1, height: 6, borderRadius: 3 },
1884
+ bar: { flexDirection: "row", alignItems: "center", paddingHorizontal: 8, paddingVertical: 6, gap: 4 },
1885
+ step: { flex: 1, fontSize: 12, marginLeft: 4 },
1886
+ speed: { borderWidth: 1, borderRadius: 8, paddingHorizontal: 8, paddingVertical: 4 },
1887
+ icon: { width: 34, height: 34, alignItems: "center", justifyContent: "center" },
1888
+ word: { position: "absolute", fontWeight: "600" },
1889
+ credit: { position: "absolute", right: 6, bottom: 3, fontSize: 9, color: "#94a3b8", maxWidth: "60%" },
1890
+ table: { position: "absolute", borderWidth: 1.5 },
1891
+ row: { flexDirection: "row" },
1892
+ cell: { flex: 1, borderWidth: 0.75, paddingHorizontal: 6, paddingVertical: 3 }
1893
+ });
1894
+ const DEFAULT_LIVE_VOICE_LABELS = {
1895
+ eyebrow: "Live conversation",
1896
+ listeningTitle: "Listening — go ahead",
1897
+ listeningText: "Speak naturally. Pause when you are ready for an answer.",
1898
+ hearingTitle: "You’re speaking…",
1899
+ hearingText: "I’m listening. Pause when you’re done.",
1900
+ thinkingTitle: "Thinking…",
1901
+ thinkingText: "I’m working on your answer.",
1902
+ speakingTitle: "Speaking…",
1903
+ speakingText: "Tap the circle to interrupt.",
1904
+ end: "End",
1905
+ language: "Language"
1906
+ };
1907
+ const ORB = 96;
1908
+ const CORE = ORB - 24;
1909
+ function useLoop(make, key) {
1910
+ useEffect(() => {
1911
+ if (!key) return void 0;
1912
+ const animation = Animated.loop(make());
1913
+ animation.start();
1914
+ return () => animation.stop();
1915
+ }, [key]);
1916
+ }
1917
+ function Ring({ color, running, duration, delay = 0 }) {
1918
+ const t = useRef(new Animated.Value(0)).current;
1919
+ useLoop(() => Animated.sequence([
1920
+ Animated.delay(delay),
1921
+ Animated.timing(t, { toValue: 1, duration, easing: Easing.out(Easing.quad), useNativeDriver: true }),
1922
+ Animated.timing(t, { toValue: 0, duration: 0, useNativeDriver: true })
1923
+ ]), running ? "on" : false);
1924
+ useEffect(() => {
1925
+ if (!running) t.setValue(0);
1926
+ }, [running, t]);
1927
+ return /* @__PURE__ */ jsx(
1928
+ Animated.View,
1929
+ {
1930
+ pointerEvents: "none",
1931
+ style: [styles$2.ring, {
1932
+ borderColor: color,
1933
+ opacity: t.interpolate({ inputRange: [0, 0.1, 1], outputRange: [0, 0.55, 0] }),
1934
+ transform: [{ scale: t.interpolate({ inputRange: [0, 1], outputRange: [1, 1.55] }) }]
1935
+ }]
1936
+ }
1937
+ );
1938
+ }
1939
+ function Wave({ color }) {
1940
+ const bars = useRef([0, 1, 2, 3, 4, 5, 6].map(() => new Animated.Value(0))).current;
1941
+ useEffect(() => {
1942
+ const delays = [0, 230, 380, 560, 380, 230, 0];
1943
+ const loops = bars.map((bar, i) => Animated.loop(Animated.sequence([
1944
+ Animated.delay(delays[i]),
1945
+ Animated.timing(bar, { toValue: 1, duration: 340, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),
1946
+ Animated.timing(bar, { toValue: 0, duration: 340, easing: Easing.inOut(Easing.ease), useNativeDriver: true })
1947
+ ])));
1948
+ loops.forEach((loop) => loop.start());
1949
+ return () => loops.forEach((loop) => loop.stop());
1950
+ }, [bars]);
1951
+ return /* @__PURE__ */ jsx(View, { style: styles$2.wave, children: bars.map((bar, i) => /* @__PURE__ */ jsx(
1952
+ Animated.View,
1953
+ {
1954
+ style: [styles$2.bar, {
1955
+ backgroundColor: color,
1956
+ transform: [{ scaleY: bar.interpolate({ inputRange: [0, 1], outputRange: [0.32, 1] }) }]
1957
+ }]
1958
+ },
1959
+ i
1960
+ )) });
1961
+ }
1962
+ function Dots({ color }) {
1963
+ const dots = useRef([0, 1, 2].map(() => new Animated.Value(0))).current;
1964
+ useEffect(() => {
1965
+ const loops = dots.map((dot, i) => Animated.loop(Animated.sequence([
1966
+ Animated.delay(i * 150),
1967
+ Animated.timing(dot, { toValue: 1, duration: 450, useNativeDriver: true }),
1968
+ Animated.timing(dot, { toValue: 0, duration: 450, useNativeDriver: true }),
1969
+ Animated.delay((2 - i) * 150)
1970
+ ])));
1971
+ loops.forEach((loop) => loop.start());
1972
+ return () => loops.forEach((loop) => loop.stop());
1973
+ }, [dots]);
1974
+ return /* @__PURE__ */ jsx(View, { style: styles$2.dots, children: dots.map((dot, i) => /* @__PURE__ */ jsx(
1975
+ Animated.View,
1976
+ {
1977
+ style: [styles$2.dot, {
1978
+ backgroundColor: color,
1979
+ opacity: dot.interpolate({ inputRange: [0, 1], outputRange: [0.35, 1] }),
1980
+ transform: [{ translateY: dot.interpolate({ inputRange: [0, 1], outputRange: [0, -4] }) }]
1981
+ }]
1982
+ },
1983
+ i
1984
+ )) });
1985
+ }
1986
+ function GuideAILiveVoice({ live, theme: overrides, labels: given }) {
1987
+ const theme = resolveTheme(overrides);
1988
+ const labels = { ...DEFAULT_LIVE_VOICE_LABELS, ...given };
1989
+ const breathe = useRef(new Animated.Value(0)).current;
1990
+ const level = useRef(new Animated.Value(0)).current;
1991
+ const { state } = live;
1992
+ const breathing = state === "listening" || state === "speaking";
1993
+ useLoop(() => Animated.sequence([
1994
+ Animated.timing(breathe, { toValue: 1, duration: state === "speaking" ? 450 : 1200, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),
1995
+ Animated.timing(breathe, { toValue: 0, duration: state === "speaking" ? 450 : 1200, easing: Easing.inOut(Easing.ease), useNativeDriver: true })
1996
+ ]), breathing ? state : false);
1997
+ useEffect(() => {
1998
+ Animated.timing(level, { toValue: state === "hearing" ? live.level : 0, duration: 110, useNativeDriver: true }).start();
1999
+ }, [live.level, state, level]);
2000
+ if (!live.active) return null;
2001
+ const [title, text] = {
2002
+ off: ["", ""],
2003
+ listening: [labels.listeningTitle, labels.listeningText],
2004
+ hearing: [labels.hearingTitle, labels.hearingText],
2005
+ thinking: [labels.thinkingTitle, labels.thinkingText],
2006
+ speaking: [labels.speakingTitle, labels.speakingText]
2007
+ }[state];
2008
+ const coreScale = Animated.add(
2009
+ breathe.interpolate({ inputRange: [0, 1], outputRange: [1, breathing ? 1.06 : 1] }),
2010
+ level.interpolate({ inputRange: [0, 1], outputRange: [state === "hearing" ? 0.04 : 0, 0.22] })
2011
+ );
2012
+ return /* @__PURE__ */ jsxs(
2013
+ View,
2014
+ {
2015
+ accessibilityRole: "summary",
2016
+ accessibilityLabel: `${labels.eyebrow}: ${title}`,
2017
+ style: [styles$2.panel, { borderColor: theme.border, backgroundColor: theme.surface }],
2018
+ children: [
2019
+ /* @__PURE__ */ jsxs(
2020
+ Pressable,
2021
+ {
2022
+ onPress: state === "speaking" ? live.interrupt : void 0,
2023
+ accessibilityRole: state === "speaking" ? "button" : void 0,
2024
+ accessibilityLabel: state === "speaking" ? labels.speakingText : void 0,
2025
+ style: styles$2.orb,
2026
+ children: [
2027
+ /* @__PURE__ */ jsx(Ring, { color: theme.accent, running: state === "listening", duration: 2400 }),
2028
+ /* @__PURE__ */ jsx(Ring, { color: theme.accent, running: state === "hearing", duration: 1100 }),
2029
+ /* @__PURE__ */ jsx(Ring, { color: theme.accent, running: state === "hearing", duration: 1100, delay: 550 }),
2030
+ /* @__PURE__ */ jsx(
2031
+ Animated.View,
2032
+ {
2033
+ style: [styles$2.core, {
2034
+ backgroundColor: theme.accent,
2035
+ shadowColor: theme.accent,
2036
+ opacity: state === "thinking" ? 0.85 : 1,
2037
+ transform: [{ scale: coreScale }]
2038
+ }]
2039
+ }
2040
+ ),
2041
+ state === "speaking" ? /* @__PURE__ */ jsx(Wave, { color: theme.onAccent }) : null,
2042
+ state === "thinking" ? /* @__PURE__ */ jsx(Dots, { color: theme.onAccent }) : null
2043
+ ]
2044
+ }
2045
+ ),
2046
+ /* @__PURE__ */ jsx(Text, { style: [styles$2.eyebrow, { color: theme.textMuted, fontSize: theme.fontSize - 3 }], children: labels.eyebrow }),
2047
+ /* @__PURE__ */ jsx(Text, { style: [styles$2.title, { color: theme.text, fontSize: theme.fontSize + 2 }], children: title }),
2048
+ /* @__PURE__ */ jsx(Text, { style: [styles$2.text, { color: theme.textMuted, fontSize: theme.fontSize - 1 }], children: text }),
2049
+ /* @__PURE__ */ jsxs(View, { style: styles$2.actions, children: [
2050
+ live.language ? /* @__PURE__ */ jsx(
2051
+ Pressable,
2052
+ {
2053
+ onPress: live.changeLanguage,
2054
+ accessibilityRole: "button",
2055
+ style: [styles$2.chip, { borderColor: theme.border }],
2056
+ hitSlop: 6,
2057
+ children: /* @__PURE__ */ jsxs(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize - 2 }, children: [
2058
+ labels.language,
2059
+ ": ",
2060
+ /* @__PURE__ */ jsx(Text, { style: { color: theme.text, fontWeight: "600" }, children: live.language.label })
2061
+ ] })
2062
+ }
2063
+ ) : null,
2064
+ /* @__PURE__ */ jsx(
2065
+ Pressable,
2066
+ {
2067
+ onPress: live.stop,
2068
+ accessibilityRole: "button",
2069
+ accessibilityLabel: labels.end,
2070
+ style: [styles$2.end, { backgroundColor: theme.error }],
2071
+ hitSlop: 6,
2072
+ children: /* @__PURE__ */ jsxs(Text, { style: [styles$2.endText, { fontSize: theme.fontSize - 1 }], children: [
2073
+ "✆ ",
2074
+ labels.end
2075
+ ] })
2076
+ }
2077
+ )
2078
+ ] })
2079
+ ]
2080
+ }
2081
+ );
2082
+ }
2083
+ const styles$2 = StyleSheet.create({
2084
+ panel: {
2085
+ alignItems: "center",
2086
+ paddingTop: 18,
2087
+ paddingBottom: 14,
2088
+ paddingHorizontal: 16,
2089
+ borderTopWidth: StyleSheet.hairlineWidth,
2090
+ borderBottomWidth: StyleSheet.hairlineWidth
2091
+ },
2092
+ orb: { width: ORB, height: ORB, alignItems: "center", justifyContent: "center", marginBottom: 8 },
2093
+ core: {
2094
+ position: "absolute",
2095
+ width: CORE,
2096
+ height: CORE,
2097
+ borderRadius: CORE / 2,
2098
+ shadowOffset: { width: 0, height: 8 },
2099
+ shadowOpacity: 0.35,
2100
+ shadowRadius: 12,
2101
+ elevation: 6
2102
+ },
2103
+ ring: { position: "absolute", width: CORE, height: CORE, borderRadius: CORE / 2, borderWidth: 2 },
2104
+ wave: { flexDirection: "row", alignItems: "center", gap: 3, height: 26 },
2105
+ bar: { width: 3, height: 26, borderRadius: 2 },
2106
+ dots: { flexDirection: "row", alignItems: "center", gap: 6 },
2107
+ dot: { width: 7, height: 7, borderRadius: 4 },
2108
+ eyebrow: { fontWeight: "500", marginBottom: 2 },
2109
+ title: { fontWeight: "700", textAlign: "center" },
2110
+ text: { textAlign: "center", marginTop: 3, lineHeight: 19 },
2111
+ actions: { flexDirection: "row", alignItems: "center", gap: 10, marginTop: 12 },
2112
+ chip: { borderWidth: 1, borderRadius: 999, paddingHorizontal: 12, paddingVertical: 7 },
2113
+ end: { borderRadius: 999, paddingHorizontal: 18, paddingVertical: 9 },
2114
+ endText: { color: "#FFFFFF", fontWeight: "700" }
2115
+ });
2116
+ const DEFAULT_LANGUAGE_PICKER_LABELS = {
2117
+ title: "Which language will you speak?",
2118
+ hint: "The assistant listens in this language. You can change it any time.",
2119
+ cancel: "Cancel"
2120
+ };
2121
+ function GuideAILanguagePicker({ voice, theme: overrides, labels: given }) {
2122
+ if (!voice.choosingLanguage) return null;
2123
+ const theme = resolveTheme(overrides);
2124
+ const labels = { ...DEFAULT_LANGUAGE_PICKER_LABELS, ...given };
2125
+ return /* @__PURE__ */ jsx(Modal, { visible: true, transparent: true, animationType: "fade", onRequestClose: voice.cancelLanguage, children: /* @__PURE__ */ jsxs(View, { style: styles$1.backdrop, children: [
2126
+ /* @__PURE__ */ jsx(Pressable, { style: StyleSheet.absoluteFill, onPress: voice.cancelLanguage, accessibilityLabel: labels.cancel }),
2127
+ /* @__PURE__ */ jsxs(View, { style: [styles$1.card, { backgroundColor: theme.surfaceRaised, borderColor: theme.border, borderRadius: theme.radius + 6 }], children: [
2128
+ /* @__PURE__ */ jsx(Text, { style: [styles$1.title, { color: theme.text, fontSize: theme.fontSize + 3 }], children: labels.title }),
2129
+ /* @__PURE__ */ jsx(Text, { style: [styles$1.hint, { color: theme.textMuted, fontSize: theme.fontSize - 1 }], children: labels.hint }),
2130
+ /* @__PURE__ */ jsx(ScrollView, { style: styles$1.list, contentContainerStyle: styles$1.listContent, children: voice.languages.map((lang) => {
2131
+ var _a;
2132
+ const on = ((_a = voice.language) == null ? void 0 : _a.code) === lang.code;
2133
+ return /* @__PURE__ */ jsxs(
2134
+ Pressable,
2135
+ {
2136
+ accessibilityRole: "button",
2137
+ accessibilityState: { selected: on },
2138
+ onPress: () => {
2139
+ void voice.chooseLanguage(lang.code);
2140
+ },
2141
+ style: ({ pressed }) => [styles$1.row, {
2142
+ borderColor: on ? theme.accent : theme.border,
2143
+ backgroundColor: on ? theme.accent : pressed ? theme.surface : "transparent",
2144
+ borderRadius: theme.radius
2145
+ }],
2146
+ children: [
2147
+ /* @__PURE__ */ jsx(Text, { style: { color: on ? theme.onAccent : theme.text, fontSize: theme.fontSize + 1, fontWeight: on ? "700" : "500" }, children: lang.label }),
2148
+ on ? /* @__PURE__ */ jsx(Text, { style: { color: theme.onAccent, fontSize: theme.fontSize }, children: "✓" }) : null
2149
+ ]
2150
+ },
2151
+ lang.code
2152
+ );
2153
+ }) }),
2154
+ /* @__PURE__ */ jsx(Pressable, { onPress: voice.cancelLanguage, accessibilityRole: "button", style: styles$1.cancel, hitSlop: 8, children: /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize, fontWeight: "600" }, children: labels.cancel }) })
2155
+ ] })
2156
+ ] }) });
2157
+ }
2158
+ const styles$1 = StyleSheet.create({
2159
+ backdrop: { flex: 1, justifyContent: "center", padding: 22, backgroundColor: "rgba(0,0,0,0.45)" },
2160
+ card: { borderWidth: StyleSheet.hairlineWidth, padding: 20, maxHeight: "80%" },
2161
+ title: { fontWeight: "700" },
2162
+ hint: { marginTop: 6, marginBottom: 14, lineHeight: 19 },
2163
+ list: { flexGrow: 0 },
2164
+ listContent: { gap: 8 },
2165
+ row: {
2166
+ flexDirection: "row",
2167
+ alignItems: "center",
2168
+ justifyContent: "space-between",
2169
+ borderWidth: 1,
2170
+ paddingVertical: 13,
2171
+ paddingHorizontal: 16
2172
+ },
2173
+ cancel: { alignSelf: "center", marginTop: 14, paddingVertical: 4, paddingHorizontal: 12 }
2174
+ });
2175
+ function PersonIcon({ color }) {
2176
+ return /* @__PURE__ */ jsxs(View, { style: styles.iconWrap, children: [
2177
+ /* @__PURE__ */ jsx(View, { style: [styles.iconBand, { borderColor: color }] }),
2178
+ /* @__PURE__ */ jsx(View, { style: [styles.iconCup, styles.iconCupLeft, { backgroundColor: color }] }),
2179
+ /* @__PURE__ */ jsx(View, { style: [styles.iconCup, styles.iconCupRight, { backgroundColor: color }] })
2180
+ ] });
2181
+ }
2182
+ function Orb({ theme, active }) {
2183
+ const pulse = useRef(new Animated.Value(0)).current;
2184
+ React.useEffect(() => {
2185
+ if (!active) {
2186
+ pulse.stopAnimation();
2187
+ Animated.timing(pulse, { toValue: 0, duration: 240, useNativeDriver: true }).start();
2188
+ return;
2189
+ }
2190
+ const loop = Animated.loop(
2191
+ Animated.sequence([
2192
+ Animated.timing(pulse, {
2193
+ toValue: 1,
2194
+ duration: 900,
2195
+ easing: Easing.inOut(Easing.quad),
2196
+ useNativeDriver: true
2197
+ }),
2198
+ Animated.timing(pulse, {
2199
+ toValue: 0,
2200
+ duration: 900,
2201
+ easing: Easing.inOut(Easing.quad),
2202
+ useNativeDriver: true
2203
+ })
2204
+ ])
2205
+ );
2206
+ loop.start();
2207
+ return () => loop.stop();
2208
+ }, [active, pulse]);
2209
+ const scale = pulse.interpolate({ inputRange: [0, 1], outputRange: [1, 1.18] });
2210
+ const glow = pulse.interpolate({ inputRange: [0, 1], outputRange: [0.35, 0.7] });
2211
+ return /* @__PURE__ */ jsxs(View, { style: styles.orbWrap, children: [
2212
+ /* @__PURE__ */ jsx(
2213
+ Animated.View,
2214
+ {
2215
+ style: [
2216
+ styles.orbGlow,
2217
+ { backgroundColor: theme.accent, opacity: glow, transform: [{ scale }] }
2218
+ ]
2219
+ }
2220
+ ),
2221
+ /* @__PURE__ */ jsx(View, { style: [styles.orbCore, { backgroundColor: theme.accent }] })
2222
+ ] });
2223
+ }
2224
+ function Bubble({ message, theme, onTalkToHuman, onWhiteboard }) {
2225
+ if (message.role === "user") {
2226
+ return /* @__PURE__ */ jsx(View, { style: [styles.row, styles.rowUser], children: /* @__PURE__ */ jsx(View, { style: [
2227
+ styles.bubble,
2228
+ { backgroundColor: theme.userBubble, borderRadius: theme.radius },
2229
+ message.error ? { backgroundColor: theme.error } : null
2230
+ ], children: /* @__PURE__ */ jsx(Text, { style: {
2231
+ color: theme.onUserBubble,
2232
+ fontSize: theme.fontSize,
2233
+ lineHeight: theme.fontSize * 1.4
2234
+ }, children: message.content }) }) });
2235
+ }
2236
+ return /* @__PURE__ */ jsx(View, { style: [styles.row, styles.rowAssistant], children: /* @__PURE__ */ jsxs(View, { style: [
2237
+ styles.assistantBody,
2238
+ message.error ? { backgroundColor: theme.error, borderRadius: theme.radius, padding: 12 } : null
2239
+ ], children: [
2240
+ /* @__PURE__ */ jsx(Markdown, { color: theme.text, accentColor: theme.accent, fontSize: theme.fontSize, children: message.content }),
2241
+ onWhiteboard ? /* @__PURE__ */ jsx(
2242
+ Pressable,
2243
+ {
2244
+ onPress: onWhiteboard,
2245
+ accessibilityRole: "button",
2246
+ accessibilityLabel: "Explain on whiteboard",
2247
+ style: [styles.errorAction, { borderColor: theme.accent }],
2248
+ hitSlop: 6,
2249
+ children: /* @__PURE__ */ jsx(Text, { style: [styles.humanText, { color: theme.accent, fontSize: theme.fontSize - 1 }], children: "✎ Explain on whiteboard" })
2250
+ }
2251
+ ) : null,
2252
+ message.error && onTalkToHuman ? /* @__PURE__ */ jsxs(
2253
+ Pressable,
2254
+ {
2255
+ onPress: onTalkToHuman,
2256
+ accessibilityRole: "button",
2257
+ accessibilityLabel: "Talk to a person",
2258
+ style: [styles.errorAction, { borderColor: theme.accent }],
2259
+ hitSlop: 6,
2260
+ children: [
2261
+ /* @__PURE__ */ jsx(PersonIcon, { color: theme.accent }),
2262
+ /* @__PURE__ */ jsx(Text, { style: [styles.humanText, {
2263
+ color: theme.accent,
2264
+ fontSize: theme.fontSize - 1
2265
+ }], children: "Talk to a human" })
2266
+ ]
2267
+ }
2268
+ ) : null
2269
+ ] }) });
2270
+ }
2271
+ function HistoryPanel({ theme, onClose }) {
2272
+ const { conversations, activeId, newConversation, openConversation, deleteConversation } = useConversations();
2273
+ return /* @__PURE__ */ jsxs(Modal, { visible: true, transparent: true, animationType: "fade", onRequestClose: onClose, children: [
2274
+ /* @__PURE__ */ jsx(Pressable, { style: styles.sheetBackdrop, onPress: onClose, accessibilityLabel: "Close chat history" }),
2275
+ /* @__PURE__ */ jsxs(View, { style: [styles.sheet, { backgroundColor: theme.background, borderColor: theme.border }], children: [
2276
+ /* @__PURE__ */ jsx(Text, { style: [styles.sheetTitle, { color: theme.text, fontSize: theme.fontSize + 2 }], children: "Chats" }),
2277
+ /* @__PURE__ */ jsx(
2278
+ Pressable,
2279
+ {
2280
+ accessibilityRole: "button",
2281
+ onPress: () => {
2282
+ newConversation();
2283
+ onClose();
2284
+ },
2285
+ style: [styles.sheetRow, { borderColor: theme.accent }],
2286
+ children: /* @__PURE__ */ jsx(Text, { style: { color: theme.accent, fontWeight: "600", fontSize: theme.fontSize }, children: "+ New chat" })
2287
+ }
2288
+ ),
2289
+ /* @__PURE__ */ jsx(
2290
+ FlatList,
2291
+ {
2292
+ data: conversations,
2293
+ keyExtractor: (c) => c.id,
2294
+ ListEmptyComponent: /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, padding: 12 }, children: "No previous chats yet." }),
2295
+ renderItem: ({ item }) => /* @__PURE__ */ jsxs(View, { style: [styles.historyItem, { backgroundColor: item.id === activeId ? theme.surface : void 0 }], children: [
2296
+ /* @__PURE__ */ jsx(
2297
+ Pressable,
2298
+ {
2299
+ accessibilityRole: "button",
2300
+ style: { flex: 1 },
2301
+ onPress: () => {
2302
+ openConversation(item.id);
2303
+ onClose();
2304
+ },
2305
+ children: /* @__PURE__ */ jsx(Text, { numberOfLines: 2, style: { color: theme.text, fontSize: theme.fontSize }, children: item.title })
2306
+ }
2307
+ ),
2308
+ /* @__PURE__ */ jsx(
2309
+ Pressable,
2310
+ {
2311
+ accessibilityRole: "button",
2312
+ accessibilityLabel: `Delete ${item.title}`,
2313
+ hitSlop: 8,
2314
+ onPress: () => deleteConversation(item.id),
2315
+ children: /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize }, children: "✕" })
2316
+ }
2317
+ )
2318
+ ] })
2319
+ }
2320
+ )
2321
+ ] })
2322
+ ] });
2323
+ }
2324
+ function resolveTopInset(explicit) {
2325
+ var _a;
2326
+ if (explicit !== void 0) return explicit;
2327
+ if (Platform.OS === "android") return (_a = StatusBar.currentHeight) != null ? _a : 24;
2328
+ return 8;
2329
+ }
2330
+ function useHumanHandover(onTalkToHuman, available) {
2331
+ const [reachable, setReachable] = useState(false);
2332
+ useEffect(() => {
2333
+ if (!onTalkToHuman || available !== void 0) return;
2334
+ let cancelled = false;
2335
+ void (async () => {
2336
+ try {
2337
+ const { api } = requireConfigured();
2338
+ const status = await api.get(
2339
+ EP.supportStatus()
2340
+ );
2341
+ if (!cancelled) setReachable(!!(status == null ? void 0 : status.enabled));
2342
+ } catch {
2343
+ }
2344
+ })();
2345
+ return () => {
2346
+ cancelled = true;
2347
+ };
2348
+ }, [onTalkToHuman, available]);
2349
+ if (!onTalkToHuman) return false;
2350
+ return available != null ? available : reachable;
2351
+ }
2352
+ function GuideAIChat({
2353
+ theme: overrides,
2354
+ placeholder = "Ask me anything",
2355
+ greeting = "Ask me anything",
2356
+ emptyState,
2357
+ showMic = true,
2358
+ showHistory = true,
2359
+ useVoice,
2360
+ leadingAccessory,
2361
+ title,
2362
+ onClose,
2363
+ onTalkToHuman,
2364
+ humanHandoverAvailable,
2365
+ topInset
2366
+ }) {
2367
+ const { harness, debug } = requireConfigured();
2368
+ const chat = useGuideAI({ harness, trace: debug });
2369
+ const {
2370
+ messages,
2371
+ input,
2372
+ setInput,
2373
+ send,
2374
+ busy,
2375
+ canSend,
2376
+ status,
2377
+ typing,
2378
+ followUps,
2379
+ explainOnWhiteboard
2380
+ } = chat;
2381
+ const voice = useVoice ? useVoice(chat) : null;
2382
+ const [historyOpen, setHistoryOpen] = useState(false);
2383
+ const theme = resolveTheme(overrides);
2384
+ const listRef = useRef(null);
2385
+ const showHuman = useHumanHandover(onTalkToHuman, humanHandoverAvailable);
2386
+ const { checklist, dismiss } = useOnboarding();
2387
+ const nextSetupStep = checklist == null ? void 0 : checklist.steps.find((step) => step.state === "available");
2388
+ const headerTop = resolveTopInset(topInset);
2389
+ const submit = () => {
2390
+ void send();
2391
+ };
2392
+ return /* @__PURE__ */ jsxs(
2393
+ KeyboardAvoidingView,
2394
+ {
2395
+ style: [styles.container, { backgroundColor: theme.background }],
2396
+ behavior: Platform.OS === "ios" ? "padding" : void 0,
2397
+ children: [
2398
+ title || onClose || showHuman || showHistory ? /* @__PURE__ */ jsxs(View, { style: [
2399
+ styles.header,
2400
+ { borderBottomColor: theme.border, paddingTop: headerTop + 14 }
2401
+ ], children: [
2402
+ /* @__PURE__ */ jsx(View, { style: styles.headerSide, children: title ? /* @__PURE__ */ jsx(
2403
+ Text,
2404
+ {
2405
+ numberOfLines: 1,
2406
+ style: [styles.title, { color: theme.text, fontSize: theme.fontSize + 1 }],
2407
+ children: title
2408
+ }
2409
+ ) : null }),
2410
+ /* @__PURE__ */ jsxs(View, { style: styles.headerActions, children: [
2411
+ showHistory ? /* @__PURE__ */ jsx(
2412
+ Pressable,
2413
+ {
2414
+ onPress: () => setHistoryOpen(true),
2415
+ accessibilityRole: "button",
2416
+ accessibilityLabel: "Chat history",
2417
+ style: [styles.close, { backgroundColor: theme.surface }],
2418
+ hitSlop: 8,
2419
+ children: /* @__PURE__ */ jsx(Text, { style: [styles.closeIcon, { color: theme.text }], children: "☰" })
2420
+ }
2421
+ ) : null,
2422
+ showHuman ? /* @__PURE__ */ jsxs(
2423
+ Pressable,
2424
+ {
2425
+ onPress: onTalkToHuman,
2426
+ accessibilityRole: "button",
2427
+ accessibilityLabel: "Talk to a person",
2428
+ style: [styles.human, {
2429
+ backgroundColor: theme.surface,
2430
+ borderColor: theme.border
2431
+ }],
2432
+ hitSlop: 8,
2433
+ children: [
2434
+ /* @__PURE__ */ jsx(PersonIcon, { color: theme.accent }),
2435
+ /* @__PURE__ */ jsx(Text, { style: [styles.humanText, {
2436
+ color: theme.accent,
2437
+ fontSize: theme.fontSize - 2
2438
+ }], children: "Talk to human" })
2439
+ ]
2440
+ }
2441
+ ) : null,
2442
+ onClose ? /* @__PURE__ */ jsx(
2443
+ Pressable,
2444
+ {
2445
+ onPress: onClose,
2446
+ accessibilityRole: "button",
2447
+ accessibilityLabel: "Close assistant",
2448
+ style: [styles.close, { backgroundColor: theme.surface }],
2449
+ hitSlop: 10,
2450
+ children: /* @__PURE__ */ jsx(Text, { style: [styles.closeIcon, { color: theme.text }], children: "✕" })
2451
+ }
2452
+ ) : null
2453
+ ] })
2454
+ ] }) : null,
2455
+ checklist && !checklist.completed && !checklist.dismissed ? /* @__PURE__ */ jsxs(View, { style: { margin: 14, padding: 14, borderRadius: 12, borderWidth: 1, borderColor: theme.border, backgroundColor: theme.surface }, accessibilityLabel: "Setup checklist", children: [
2456
+ /* @__PURE__ */ jsx(Text, { style: { color: theme.text, fontWeight: "700", fontSize: theme.fontSize + 2 }, children: checklist.title }),
2457
+ /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, marginTop: 3 }, children: checklist.goal }),
2458
+ /* @__PURE__ */ jsxs(Text, { style: { color: theme.textMuted, marginTop: 8 }, children: [
2459
+ checklist.completed_required,
2460
+ " of ",
2461
+ checklist.total_required,
2462
+ " required steps complete"
2463
+ ] }),
2464
+ checklist.steps.map((step) => /* @__PURE__ */ jsxs(Text, { style: { color: step.state === "locked" ? theme.textMuted : theme.text, marginTop: 5 }, children: [
2465
+ step.state === "complete" ? "✓" : step.state === "locked" ? "–" : "○",
2466
+ " ",
2467
+ step.title
2468
+ ] }, step.id)),
2469
+ nextSetupStep ? /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: `Help with ${nextSetupStep.title}`, onPress: () => void send(`Help me with ${nextSetupStep.title}`), style: { alignSelf: "flex-start", marginTop: 10, padding: 10, borderRadius: 8, backgroundColor: theme.accent }, children: /* @__PURE__ */ jsx(Text, { style: { color: theme.onAccent, fontWeight: "600" }, children: "Continue setup" }) }) : null,
2470
+ checklist.allow_dismissal ? /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "I don't need this setup", onPress: () => Alert.alert("Stop showing setup?", "This checklist will not appear again on future visits.", [
2471
+ { text: "Keep setup", style: "cancel" },
2472
+ { text: "I don't need it", onPress: () => {
2473
+ void dismiss().catch(() => Alert.alert("Could not dismiss setup", "Please try again."));
2474
+ } }
2475
+ ]), style: { alignSelf: "flex-start", marginTop: 10, padding: 10 }, children: /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, textDecorationLine: "underline" }, children: "I don't need this setup" }) }) : null
2476
+ ] }) : null,
2477
+ messages.length === 0 ? /* @__PURE__ */ jsx(View, { style: styles.empty, children: emptyState != null ? emptyState : /* @__PURE__ */ jsxs(View, { style: styles.greetingRow, children: [
2478
+ /* @__PURE__ */ jsx(Orb, { theme, active: busy }),
2479
+ /* @__PURE__ */ jsx(Text, { style: [
2480
+ styles.greeting,
2481
+ { color: theme.textMuted, fontSize: theme.fontSize + 3 }
2482
+ ], children: greeting })
2483
+ ] }) }) : /* @__PURE__ */ jsx(
2484
+ FlatList,
2485
+ {
2486
+ ref: listRef,
2487
+ data: messages,
2488
+ keyExtractor: (message) => message.id,
2489
+ renderItem: ({ item }) => /* @__PURE__ */ jsx(
2490
+ Bubble,
2491
+ {
2492
+ message: item,
2493
+ theme,
2494
+ onTalkToHuman,
2495
+ onWhiteboard: item.whiteboard ? () => {
2496
+ void explainOnWhiteboard(item.id);
2497
+ } : void 0
2498
+ }
2499
+ ),
2500
+ ListFooterComponent: typing || followUps.length ? /* @__PURE__ */ jsxs(View, { style: styles.footer, children: [
2501
+ typing ? /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize }, children: "…" }) : null,
2502
+ followUps.map((label) => /* @__PURE__ */ jsx(
2503
+ Pressable,
2504
+ {
2505
+ onPress: () => {
2506
+ void send(label);
2507
+ },
2508
+ accessibilityRole: "button",
2509
+ style: [styles.chip, { borderColor: theme.accent, borderRadius: theme.radius }],
2510
+ hitSlop: 4,
2511
+ children: /* @__PURE__ */ jsx(Text, { style: { color: theme.accent, fontSize: theme.fontSize - 1 }, children: label })
2512
+ },
2513
+ label
2514
+ ))
2515
+ ] }) : null,
2516
+ contentContainerStyle: styles.list,
2517
+ onContentSizeChange: () => {
2518
+ var _a;
2519
+ return (_a = listRef.current) == null ? void 0 : _a.scrollToEnd({ animated: true });
2520
+ },
2521
+ keyboardShouldPersistTaps: "handled"
2522
+ }
2523
+ ),
2524
+ voice ? /* @__PURE__ */ jsx(GuideAILiveVoice, { live: voice.live, theme: overrides }) : null,
2525
+ (voice == null ? void 0 : voice.live.error) || (voice == null ? void 0 : voice.mic.error) ? /* @__PURE__ */ jsx(Text, { style: [styles.voiceError, { color: theme.textMuted, fontSize: theme.fontSize - 2 }], children: voice.live.error || voice.mic.error }) : null,
2526
+ status ? /* @__PURE__ */ jsxs(View, { style: styles.status, children: [
2527
+ /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: theme.accent }),
2528
+ /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize - 2 }, children: status })
2529
+ ] }) : null,
2530
+ /* @__PURE__ */ jsxs(View, { style: styles.composerRow, children: [
2531
+ /* @__PURE__ */ jsxs(View, { style: [
2532
+ styles.composer,
2533
+ {
2534
+ backgroundColor: theme.surface,
2535
+ borderRadius: theme.radius + 6,
2536
+ borderColor: theme.border
2537
+ }
2538
+ ], children: [
2539
+ leadingAccessory ? /* @__PURE__ */ jsx(View, { style: styles.leading, children: leadingAccessory }) : null,
2540
+ /* @__PURE__ */ jsx(
2541
+ TextInput,
2542
+ {
2543
+ style: [styles.input, { color: theme.text, fontSize: theme.fontSize }],
2544
+ value: input,
2545
+ onChangeText: setInput,
2546
+ placeholder: checklist && !checklist.completed && checklist.chat_policy === "setup_only" ? "Ask about your setup" : placeholder,
2547
+ placeholderTextColor: theme.textMuted,
2548
+ editable: !busy,
2549
+ onSubmitEditing: submit,
2550
+ returnKeyType: "send",
2551
+ multiline: true,
2552
+ accessibilityLabel: placeholder
2553
+ }
2554
+ ),
2555
+ /* @__PURE__ */ jsx(
2556
+ Pressable,
2557
+ {
2558
+ onPress: submit,
2559
+ disabled: !canSend,
2560
+ accessibilityRole: "button",
2561
+ accessibilityLabel: "Send",
2562
+ style: [styles.send, { backgroundColor: canSend ? theme.accent : theme.border }],
2563
+ hitSlop: 6,
2564
+ children: /* @__PURE__ */ jsx(Text, { style: [
2565
+ styles.sendIcon,
2566
+ { color: canSend ? theme.onAccent : theme.textMuted }
2567
+ ], children: "↑" })
2568
+ }
2569
+ )
2570
+ ] }),
2571
+ showMic && voice ? /* @__PURE__ */ jsxs(Fragment, { children: [
2572
+ /* @__PURE__ */ jsx(
2573
+ Pressable,
2574
+ {
2575
+ onPress: () => {
2576
+ void voice.mic.toggle();
2577
+ },
2578
+ disabled: busy || voice.mic.transcribing || voice.live.active,
2579
+ accessibilityRole: "button",
2580
+ accessibilityLabel: voice.mic.recording ? "Stop and send" : "Speak a message",
2581
+ style: [styles.mic, {
2582
+ backgroundColor: voice.mic.recording ? theme.error : theme.surface,
2583
+ borderColor: theme.border
2584
+ }],
2585
+ children: voice.mic.transcribing ? /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: theme.accent }) : /* @__PURE__ */ jsx(Text, { style: { color: voice.mic.recording ? theme.onAccent : theme.text, fontSize: 18 }, children: voice.mic.recording ? "■" : "🎤" })
2586
+ }
2587
+ ),
2588
+ /* @__PURE__ */ jsx(
2589
+ Pressable,
2590
+ {
2591
+ onPress: () => {
2592
+ if (voice.live.active) voice.live.stop();
2593
+ else void voice.live.start();
2594
+ },
2595
+ disabled: voice.mic.recording,
2596
+ accessibilityRole: "button",
2597
+ accessibilityLabel: voice.live.active ? "End live voice" : "Talk live",
2598
+ style: [styles.mic, {
2599
+ backgroundColor: voice.live.active ? theme.accent : theme.surface,
2600
+ borderColor: theme.border
2601
+ }],
2602
+ children: /* @__PURE__ */ jsx(Text, { style: { color: voice.live.active ? theme.onAccent : theme.text, fontSize: 16 }, children: voice.live.active ? "✕" : "◉" })
2603
+ }
2604
+ )
2605
+ ] }) : null
2606
+ ] }),
2607
+ (voice == null ? void 0 : voice.mic.language) && showMic ? /* @__PURE__ */ jsx(Pressable, { onPress: voice.mic.changeLanguage, accessibilityRole: "button", style: styles.languageChip, hitSlop: 6, children: /* @__PURE__ */ jsxs(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize - 3 }, children: [
2608
+ "🎙 ",
2609
+ voice.mic.language.label
2610
+ ] }) }) : null,
2611
+ voice ? /* @__PURE__ */ jsx(GuideAILanguagePicker, { voice: voice.mic, theme: overrides }) : null,
2612
+ historyOpen ? /* @__PURE__ */ jsx(HistoryPanel, { theme, onClose: () => setHistoryOpen(false) }) : null,
2613
+ /* @__PURE__ */ jsx(GuideAIWhiteboard, { theme: overrides })
2614
+ ]
2615
+ }
2616
+ );
2617
+ }
2618
+ const styles = StyleSheet.create({
2619
+ container: { flex: 1 },
2620
+ header: {
2621
+ flexDirection: "row",
2622
+ alignItems: "center",
2623
+ justifyContent: "space-between",
2624
+ // paddingTop is set inline from the status-bar inset; only the
2625
+ // bottom half of the navbar's breathing room lives here.
2626
+ paddingHorizontal: 16,
2627
+ paddingBottom: 14,
2628
+ borderBottomWidth: StyleSheet.hairlineWidth
2629
+ },
2630
+ headerSide: { flex: 1, minWidth: 0 },
2631
+ headerActions: { flexDirection: "row", alignItems: "center", gap: 8 },
2632
+ title: { fontWeight: "600" },
2633
+ human: {
2634
+ flexDirection: "row",
2635
+ alignItems: "center",
2636
+ gap: 6,
2637
+ paddingHorizontal: 10,
2638
+ paddingVertical: 6,
2639
+ borderRadius: 999,
2640
+ borderWidth: StyleSheet.hairlineWidth
2641
+ },
2642
+ humanText: { fontWeight: "600" },
2643
+ errorAction: {
2644
+ flexDirection: "row",
2645
+ alignItems: "center",
2646
+ gap: 6,
2647
+ alignSelf: "flex-start",
2648
+ marginTop: 10,
2649
+ paddingHorizontal: 12,
2650
+ paddingVertical: 7,
2651
+ borderRadius: 999,
2652
+ borderWidth: StyleSheet.hairlineWidth
2653
+ },
2654
+ iconWrap: { width: 14, height: 14, alignItems: "center", justifyContent: "center" },
2655
+ iconBand: {
2656
+ position: "absolute",
2657
+ top: 1,
2658
+ width: 12,
2659
+ height: 9,
2660
+ borderWidth: 1.6,
2661
+ borderBottomWidth: 0,
2662
+ borderTopLeftRadius: 6,
2663
+ borderTopRightRadius: 6
2664
+ },
2665
+ iconCup: { position: "absolute", bottom: 1, width: 3.5, height: 6, borderRadius: 1.5 },
2666
+ iconCupLeft: { left: 0 },
2667
+ iconCupRight: { right: 0 },
2668
+ close: {
2669
+ width: 32,
2670
+ height: 32,
2671
+ borderRadius: 16,
2672
+ alignItems: "center",
2673
+ justifyContent: "center"
2674
+ },
2675
+ closeIcon: { fontSize: 15, fontWeight: "600", lineHeight: 18 },
2676
+ list: { padding: 16, paddingBottom: 8, gap: 14 },
2677
+ empty: {
2678
+ // Centred, not pinned near the top: before the first message the
2679
+ // greeting is the only thing on screen, and hanging it under the
2680
+ // navbar leaves the rest of the display empty.
2681
+ flex: 1,
2682
+ alignItems: "center",
2683
+ justifyContent: "center",
2684
+ paddingHorizontal: 24,
2685
+ paddingBottom: 24
2686
+ },
2687
+ greetingRow: { flexDirection: "row", alignItems: "center", gap: 14 },
2688
+ greeting: { fontWeight: "400", textAlign: "center", flexShrink: 1 },
2689
+ orbWrap: { width: 34, height: 34, alignItems: "center", justifyContent: "center" },
2690
+ orbGlow: { position: "absolute", width: 34, height: 34, borderRadius: 17 },
2691
+ orbCore: { width: 20, height: 20, borderRadius: 10 },
2692
+ row: { flexDirection: "row" },
2693
+ rowUser: { justifyContent: "flex-end" },
2694
+ rowAssistant: { justifyContent: "flex-start" },
2695
+ // The user's bubble hugs its text: a three-word question drawn as a
2696
+ // full-width block reads as a paragraph, not a chat message. It is
2697
+ // capped at 80% so a long one still leaves the reply side legible.
2698
+ bubble: { maxWidth: "80%", paddingHorizontal: 16, paddingVertical: 11 },
2699
+ // The assistant's body does NOT hug its content, and that is the whole
2700
+ // point of `width` here rather than `maxWidth` alone.
2701
+ //
2702
+ // A View with only maxWidth shrink-wraps — React Native's equivalent of
2703
+ // width: fit-content. For a paragraph that looks fine, because the text
2704
+ // fills the measure anyway. For anything that lays itself out against
2705
+ // its parent — a table whose cells are `flex: 1`, a fenced code block,
2706
+ // a numbered list — the parent has collapsed to nothing by the time the
2707
+ // child is measured, so the table renders as an empty sliver and every
2708
+ // reply ends up a different width.
2709
+ //
2710
+ // Fixing it here rather than on the table keeps every block type
2711
+ // consistent: one column, the same measure for prose, code and tables.
2712
+ assistantBody: { width: "80%" },
2713
+ status: {
2714
+ flexDirection: "row",
2715
+ alignItems: "center",
2716
+ gap: 8,
2717
+ paddingHorizontal: 22,
2718
+ paddingBottom: 8
2719
+ },
2720
+ composerRow: {
2721
+ flexDirection: "row",
2722
+ alignItems: "flex-end",
2723
+ gap: 10,
2724
+ paddingHorizontal: 14,
2725
+ paddingBottom: Platform.OS === "ios" ? 10 : 14,
2726
+ paddingTop: 4
2727
+ },
2728
+ composer: {
2729
+ flex: 1,
2730
+ flexDirection: "row",
2731
+ alignItems: "center",
2732
+ paddingLeft: 8,
2733
+ paddingRight: 6,
2734
+ paddingVertical: 6,
2735
+ borderWidth: StyleSheet.hairlineWidth,
2736
+ gap: 6
2737
+ },
2738
+ leading: { paddingLeft: 4 },
2739
+ input: {
2740
+ flex: 1,
2741
+ paddingHorizontal: 8,
2742
+ paddingVertical: Platform.OS === "ios" ? 8 : 4,
2743
+ maxHeight: 120
2744
+ },
2745
+ send: { width: 34, height: 34, borderRadius: 17, alignItems: "center", justifyContent: "center" },
2746
+ sendIcon: { fontSize: 17, fontWeight: "700", lineHeight: 20 },
2747
+ footer: {
2748
+ flexDirection: "row",
2749
+ flexWrap: "wrap",
2750
+ gap: 8,
2751
+ paddingTop: 4
2752
+ },
2753
+ chip: {
2754
+ borderWidth: 1,
2755
+ paddingHorizontal: 12,
2756
+ paddingVertical: 7
2757
+ },
2758
+ languageChip: { alignSelf: "flex-end", paddingHorizontal: 16, paddingBottom: 6 },
2759
+ voiceError: { paddingHorizontal: 16, paddingBottom: 6 },
2760
+ sheetBackdrop: { ...StyleSheet.absoluteFillObject, backgroundColor: "rgba(0,0,0,0.4)" },
2761
+ sheet: {
2762
+ position: "absolute",
2763
+ left: 16,
2764
+ right: 16,
2765
+ top: "18%",
2766
+ maxHeight: "64%",
2767
+ borderRadius: 16,
2768
+ borderWidth: StyleSheet.hairlineWidth,
2769
+ padding: 16
2770
+ },
2771
+ sheetTitle: { fontWeight: "700", marginBottom: 12 },
2772
+ sheetRow: { borderWidth: 1, borderRadius: 12, paddingVertical: 11, paddingHorizontal: 14, marginBottom: 8 },
2773
+ historyItem: { flexDirection: "row", alignItems: "center", gap: 10, paddingVertical: 10, paddingHorizontal: 8, borderRadius: 10 },
2774
+ mic: {
2775
+ width: 46,
2776
+ height: 46,
2777
+ borderRadius: 23,
2778
+ alignItems: "center",
2779
+ justifyContent: "center",
2780
+ borderWidth: StyleSheet.hairlineWidth
2781
+ }
2782
+ });
2783
+ export {
2784
+ DEFAULT_LANGUAGE_PICKER_LABELS as D,
2785
+ GuideAIChat as G,
2786
+ Markdown as M,
2787
+ DEFAULT_LIVE_VOICE_LABELS as a,
2788
+ GuideAILanguagePicker as b,
2789
+ GuideAILiveVoice as c,
2790
+ GuideAIWhiteboard as d,
2791
+ darkTheme as e,
2792
+ lightTheme as l,
2793
+ resolveTheme as r
2794
+ };
2795
+ //# sourceMappingURL=GuideAIChat-Ba6n1ePs.js.map