@guideai/react-native 0.2.0 → 0.6.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.
@@ -0,0 +1,2439 @@
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 { 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-B4WYG2Qz.js";
5
+ import { Svg, G, Path } 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(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(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([{ 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 INK = { ink: "#1f2937", blue: "#2563eb", red: "#dc2626", green: "#059669" };
1044
+ const MARKER = "rgba(250, 204, 21, 0.42)";
1045
+ const TEXT_SIZE = { s: 2.3, m: 3.1, l: 4.3 };
1046
+ const TRAVEL_MS = 200;
1047
+ class BoardModel {
1048
+ constructor(options) {
1049
+ this.options = options;
1050
+ this.inks = [];
1051
+ this.words = [];
1052
+ this.pen = null;
1053
+ this.caption = "";
1054
+ this.step = -1;
1055
+ this.player = null;
1056
+ this.scene = null;
1057
+ this.nextKey = 1;
1058
+ }
1059
+ snapshot() {
1060
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1061
+ return {
1062
+ inks: this.inks,
1063
+ words: this.words,
1064
+ pen: this.pen,
1065
+ caption: this.caption,
1066
+ step: this.step,
1067
+ steps: (_b = (_a = this.scene) == null ? void 0 : _a.steps.length) != null ? _b : 0,
1068
+ state: (_d = (_c = this.player) == null ? void 0 : _c.status) != null ? _d : "idle",
1069
+ title: (_f = (_e = this.scene) == null ? void 0 : _e.title) != null ? _f : "",
1070
+ sample: (_h = (_g = this.scene) == null ? void 0 : _g.sample) != null ? _h : false
1071
+ };
1072
+ }
1073
+ play(scene) {
1074
+ var _a, _b, _c, _d, _e;
1075
+ this.destroy();
1076
+ this.scene = scene;
1077
+ const steps = scene.steps.map((step, index) => this.buildStep(step, index));
1078
+ this.player = new Player(steps, {
1079
+ narrate: (_a = this.options.narrate) != null ? _a : (async () => false),
1080
+ stopNarration: () => {
1081
+ var _a2, _b2;
1082
+ return (_b2 = (_a2 = this.options).stopNarration) == null ? void 0 : _b2.call(_a2);
1083
+ },
1084
+ reset: () => this.wipe(),
1085
+ onStep: (index, step) => {
1086
+ this.step = index;
1087
+ this.caption = step.say;
1088
+ this.changed();
1089
+ },
1090
+ onState: () => this.changed(),
1091
+ requestFrame: (_b = this.options.requestFrame) != null ? _b : ((cb) => requestAnimationFrame(cb)),
1092
+ cancelFrame: (_c = this.options.cancelFrame) != null ? _c : ((id) => cancelAnimationFrame(id)),
1093
+ now: (_d = this.options.now) != null ? _d : (() => Date.now())
1094
+ }, (_e = this.options.reducedMotion) != null ? _e : false);
1095
+ this.player.play();
1096
+ }
1097
+ /** Pause, or carry on from where it was. */
1098
+ toggle() {
1099
+ if (!this.player) return;
1100
+ if (this.player.status === "playing") this.player.pause();
1101
+ else this.player.play();
1102
+ }
1103
+ replay() {
1104
+ var _a;
1105
+ (_a = this.player) == null ? void 0 : _a.replay();
1106
+ }
1107
+ seek(step) {
1108
+ var _a;
1109
+ (_a = this.player) == null ? void 0 : _a.seek(step);
1110
+ }
1111
+ setSpeed(speed) {
1112
+ var _a;
1113
+ (_a = this.player) == null ? void 0 : _a.setSpeed(speed);
1114
+ }
1115
+ get speed() {
1116
+ var _a, _b;
1117
+ return (_b = (_a = this.player) == null ? void 0 : _a.rate) != null ? _b : 1;
1118
+ }
1119
+ /** Stop for good: no frames, nothing on the board. */
1120
+ destroy() {
1121
+ var _a;
1122
+ (_a = this.player) == null ? void 0 : _a.destroy();
1123
+ this.player = null;
1124
+ this.scene = null;
1125
+ this.wipe();
1126
+ this.step = -1;
1127
+ this.caption = "";
1128
+ }
1129
+ changed() {
1130
+ this.options.onChange();
1131
+ }
1132
+ wipe() {
1133
+ this.inks = [];
1134
+ this.words = [];
1135
+ this.pen = null;
1136
+ this.changed();
1137
+ }
1138
+ // ------------------------------------------------------------- steps → ops
1139
+ buildStep(step, index) {
1140
+ return {
1141
+ say: step.say,
1142
+ enter: () => {
1143
+ if (step.clear) this.wipe();
1144
+ },
1145
+ ops: step.draw.map((item, i) => this.opFor(item, index * 100 + i + 1))
1146
+ };
1147
+ }
1148
+ opFor(item, seed) {
1149
+ var _a;
1150
+ switch (item.kind) {
1151
+ case "ink":
1152
+ 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);
1153
+ case "art": {
1154
+ const ink = (_a = this.scene) == null ? void 0 : _a.art[item.art];
1155
+ if (!ink) {
1156
+ const [x, y, w, h] = item.at;
1157
+ 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 });
1158
+ }
1159
+ return this.inkOp(item.id, artStrokes(ink, item.at, seed), INK[item.tone], "icon" in ink ? 7 : 4, 1100, 4500, 2.6);
1160
+ }
1161
+ case "text":
1162
+ return this.textOp(item);
1163
+ case "table":
1164
+ return this.tableOp(item);
1165
+ case "mark":
1166
+ return this.markOp(item.mark);
1167
+ case "erase":
1168
+ return this.eraseOp(item.erase);
1169
+ default:
1170
+ return { duration: 0, run: () => void 0 };
1171
+ }
1172
+ }
1173
+ inkOp(id, strokes, color, width, min, max, perMs, marker = false) {
1174
+ const length = totalLength(strokes);
1175
+ const duration = Math.min(max, Math.max(min, length / perMs)) + TRAVEL_MS;
1176
+ const share = TRAVEL_MS / duration;
1177
+ let obj = null;
1178
+ return {
1179
+ duration,
1180
+ run: (progress) => {
1181
+ var _a, _b;
1182
+ if (!obj) {
1183
+ obj = { key: this.nextKey++, id, strokes, length, color, width, marker, drawn: 0 };
1184
+ this.inks = [...this.inks, obj];
1185
+ }
1186
+ if (!length) return;
1187
+ const drawn = progress >= 1 ? 1 : Math.max(0, (progress - share) / (1 - share));
1188
+ obj.drawn = drawn;
1189
+ this.pen = drawn > 0 ? pointAlong(strokes, length * drawn) : (_b = (_a = strokes[0]) == null ? void 0 : _a[0]) != null ? _b : this.pen;
1190
+ this.changed();
1191
+ }
1192
+ };
1193
+ }
1194
+ textOp(item) {
1195
+ const duration = Math.min(2e3, Math.max(350, item.text.length * 60)) + TRAVEL_MS;
1196
+ let word = null;
1197
+ return {
1198
+ duration,
1199
+ run: (progress) => {
1200
+ if (!word) {
1201
+ 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 };
1202
+ this.words = [...this.words, word];
1203
+ }
1204
+ word.shown = progress >= 1 ? 1 : Math.max(0, (progress * duration - TRAVEL_MS) / (duration - TRAVEL_MS));
1205
+ const height = TEXT_SIZE[item.size] / 100 * BOARD_W;
1206
+ this.pen = { x: sx(item.at[0] + item.text.length * height * 0.55 * word.shown), y: sy(item.at[1]) };
1207
+ this.changed();
1208
+ }
1209
+ };
1210
+ }
1211
+ tableOp(item) {
1212
+ let table = null;
1213
+ return {
1214
+ duration: item.rows.length * 450 + TRAVEL_MS,
1215
+ run: (progress) => {
1216
+ if (!table) {
1217
+ 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 };
1218
+ this.words = [...this.words, table];
1219
+ }
1220
+ table.rowsShown = progress >= 1 ? item.rows.length : Math.max(progress > 0 ? 1 : 0, Math.floor(progress * item.rows.length));
1221
+ this.pen = { x: sx(item.at[0] + item.at[2]), y: sy(item.at[1]) };
1222
+ this.changed();
1223
+ }
1224
+ };
1225
+ }
1226
+ markOp(id) {
1227
+ let done = false;
1228
+ return {
1229
+ duration: 650,
1230
+ run: () => {
1231
+ if (done) return;
1232
+ done = true;
1233
+ const word = this.words.find((w) => w.id === id);
1234
+ if (word) {
1235
+ word.marked = true;
1236
+ this.changed();
1237
+ return;
1238
+ }
1239
+ const ink = this.inks.find((obj) => obj.id === id && !obj.marker);
1240
+ const box = ink ? bounds(ink.strokes) : null;
1241
+ if (!box) return;
1242
+ const mid = (box.y0 + box.y1) / 2;
1243
+ const swipe = [{ x: box.x0 - 14, y: mid }, { x: box.x1 + 14, y: mid }];
1244
+ this.inks = [{
1245
+ key: this.nextKey++,
1246
+ strokes: [swipe],
1247
+ length: totalLength([swipe]),
1248
+ color: MARKER,
1249
+ width: Math.max(24, (box.y1 - box.y0) * 0.6),
1250
+ marker: true,
1251
+ drawn: 1
1252
+ }, ...this.inks];
1253
+ this.changed();
1254
+ }
1255
+ };
1256
+ }
1257
+ eraseOp(id) {
1258
+ return {
1259
+ duration: 350,
1260
+ run: (progress) => {
1261
+ if (progress < 1) return;
1262
+ this.words = this.words.filter((w) => w.id !== id);
1263
+ this.inks = this.inks.filter((obj) => obj.id !== id);
1264
+ this.changed();
1265
+ }
1266
+ };
1267
+ }
1268
+ }
1269
+ function inkPath(strokes, length, upTo) {
1270
+ let left = length * upTo;
1271
+ const parts = [];
1272
+ for (const stroke of strokes) {
1273
+ if (left <= 0 || stroke.length < 2) break;
1274
+ let d = `M${stroke[0].x.toFixed(1)} ${stroke[0].y.toFixed(1)}`;
1275
+ for (let i = 1; i < stroke.length; i += 1) {
1276
+ const a = stroke[i - 1];
1277
+ const b = stroke[i];
1278
+ const seg = Math.hypot(b.x - a.x, b.y - a.y);
1279
+ if (seg >= left) {
1280
+ const t = seg ? left / seg : 1;
1281
+ d += `L${(a.x + (b.x - a.x) * t).toFixed(1)} ${(a.y + (b.y - a.y) * t).toFixed(1)}`;
1282
+ left = 0;
1283
+ break;
1284
+ }
1285
+ d += `L${b.x.toFixed(1)} ${b.y.toFixed(1)}`;
1286
+ left -= seg;
1287
+ }
1288
+ parts.push(d);
1289
+ }
1290
+ return parts.join("");
1291
+ }
1292
+ const darkTheme = {
1293
+ background: "#0B0713",
1294
+ surface: "rgba(255,255,255,0.06)",
1295
+ surfaceRaised: "#1C1626",
1296
+ text: "#F5F3FF",
1297
+ textMuted: "#8B85A0",
1298
+ accent: "#7C5CFF",
1299
+ onAccent: "#FFFFFF",
1300
+ userBubble: "#7C5CFF",
1301
+ onUserBubble: "#FFFFFF",
1302
+ error: "rgba(248,113,113,0.16)",
1303
+ border: "rgba(255,255,255,0.10)",
1304
+ radius: 22,
1305
+ fontSize: 15
1306
+ };
1307
+ const lightTheme = {
1308
+ background: "#FFFFFF",
1309
+ surface: "#F1F5F9",
1310
+ surfaceRaised: "#FFFFFF",
1311
+ text: "#0F172A",
1312
+ textMuted: "#64748B",
1313
+ accent: "#7C5CFF",
1314
+ onAccent: "#FFFFFF",
1315
+ userBubble: "#7C5CFF",
1316
+ onUserBubble: "#FFFFFF",
1317
+ error: "#FEE2E2",
1318
+ border: "#E2E8F0",
1319
+ radius: 22,
1320
+ fontSize: 15
1321
+ };
1322
+ function resolveTheme(overrides, base = lightTheme) {
1323
+ return overrides ? { ...base, ...overrides } : base;
1324
+ }
1325
+ const SHEET_W = 1600;
1326
+ const SHEET_H = 1e3;
1327
+ const HAND = Platform.select({ ios: "Bradley Hand", android: "casual", default: void 0 });
1328
+ const PEN = "M0 0 L-5 -22 L22 -70 L32 -63 L5 -16 Z";
1329
+ function GuideAIWhiteboard({ theme: overrides }) {
1330
+ const theme = resolveTheme(overrides);
1331
+ const { state, close, retry } = useWhiteboard();
1332
+ const [, repaint] = useReducer((n) => n + 1, 0);
1333
+ const [width, setWidth] = useState(0);
1334
+ const [expanded, setExpanded] = useState(false);
1335
+ const motion = useRef({ reduced: false });
1336
+ const speech = GuideAI.isConfigured() ? requireConfigured().speech : null;
1337
+ const [muted, setMuted] = useState(false);
1338
+ const voice = useRef({ muted: false });
1339
+ voice.current.muted = muted;
1340
+ const model = useMemo(() => new BoardModel({
1341
+ onChange: () => repaint(),
1342
+ get reducedMotion() {
1343
+ return motion.current.reduced;
1344
+ },
1345
+ narrate: async (text) => speech && !voice.current.muted ? speech.say(text) : false,
1346
+ stopNarration: () => speech == null ? void 0 : speech.stop()
1347
+ }), [speech]);
1348
+ const toggleVoice = () => {
1349
+ if (!muted) speech == null ? void 0 : speech.stop();
1350
+ setMuted((on) => !on);
1351
+ };
1352
+ useEffect(() => {
1353
+ var _a, _b;
1354
+ void ((_b = (_a = AccessibilityInfo).isReduceMotionEnabled) == null ? void 0 : _b.call(_a).then((on) => {
1355
+ motion.current.reduced = on;
1356
+ }, () => void 0));
1357
+ }, []);
1358
+ useEffect(() => {
1359
+ if (state.status === "playing" && state.scene) model.play(state.scene);
1360
+ else model.destroy();
1361
+ }, [model, state.status, state.scene]);
1362
+ useEffect(() => () => model.destroy(), [model]);
1363
+ if (state.status === "closed") return null;
1364
+ const board = model.snapshot();
1365
+ const height = width / (BOARD_W / BOARD_H);
1366
+ const unit2 = width / 100;
1367
+ const playing = board.state === "playing";
1368
+ const title = state.status === "playing" ? board.title : state.question;
1369
+ const shut = () => {
1370
+ model.destroy();
1371
+ close();
1372
+ };
1373
+ 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(
1374
+ View,
1375
+ {
1376
+ style: [styles$3.card, { backgroundColor: theme.surfaceRaised, borderColor: theme.border, maxWidth: expanded ? 1040 : 540 }],
1377
+ accessibilityViewIsModal: true,
1378
+ accessibilityLabel: `Whiteboard: ${title}`,
1379
+ children: [
1380
+ /* @__PURE__ */ jsxs(View, { style: styles$3.head, children: [
1381
+ /* @__PURE__ */ jsx(Text, { style: [styles$3.title, { color: theme.text }], numberOfLines: 1, children: title || "Whiteboard" }),
1382
+ board.sample && state.status === "playing" ? /* @__PURE__ */ jsx(Text, { style: styles$3.badge, accessibilityHint: "This board uses example numbers.", children: "Example" }) : null,
1383
+ speech ? /* @__PURE__ */ jsx(IconButton, { label: muted ? "Read the board aloud" : "Mute the board", glyph: muted ? "🔇" : "🔈", color: theme.textMuted, onPress: toggleVoice }) : null,
1384
+ /* @__PURE__ */ jsx(IconButton, { label: expanded ? "Collapse whiteboard" : "Expand whiteboard", glyph: expanded ? "⤡" : "⤢", color: theme.textMuted, onPress: () => setExpanded((v) => !v) }),
1385
+ /* @__PURE__ */ jsx(IconButton, { label: "Close whiteboard", glyph: "✕", color: theme.textMuted, onPress: shut })
1386
+ ] }),
1387
+ /* @__PURE__ */ jsxs(View, { style: styles$3.sheet, onLayout: (e) => setWidth(e.nativeEvent.layout.width), children: [
1388
+ width > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
1389
+ /* @__PURE__ */ jsxs(Svg, { width, height, viewBox: `0 0 ${SHEET_W} ${SHEET_H}`, children: [
1390
+ board.inks.filter((obj) => obj.marker).map((obj) => /* @__PURE__ */ jsx(Ink, { obj }, obj.key)),
1391
+ board.inks.filter((obj) => !obj.marker).map((obj) => /* @__PURE__ */ jsx(Ink, { obj }, obj.key)),
1392
+ 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
1393
+ ] }),
1394
+ board.words.map((word) => /* @__PURE__ */ jsx(Word, { word, width, height, unit: unit2 }, word.key))
1395
+ ] }) : null,
1396
+ state.status === "loading" ? /* @__PURE__ */ jsxs(View, { style: styles$3.status, accessibilityLiveRegion: "polite", children: [
1397
+ /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.accent }),
1398
+ /* @__PURE__ */ jsx(Text, { style: styles$3.statusText, children: "Drawing your board…" })
1399
+ ] }) : null,
1400
+ state.status === "error" ? /* @__PURE__ */ jsxs(View, { style: styles$3.status, accessibilityLiveRegion: "assertive", children: [
1401
+ /* @__PURE__ */ jsx(Text, { style: styles$3.statusText, children: state.error }),
1402
+ /* @__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" }) })
1403
+ ] }) : null
1404
+ ] }),
1405
+ state.status === "playing" ? /* @__PURE__ */ jsxs(Fragment, { children: [
1406
+ /* @__PURE__ */ jsx(Text, { style: [styles$3.caption, { color: theme.text }], accessibilityLiveRegion: "polite", children: board.caption }),
1407
+ board.steps > 1 ? /* @__PURE__ */ jsx(View, { style: styles$3.track, accessibilityLabel: "Steps", children: Array.from({ length: board.steps }, (_, i) => /* @__PURE__ */ jsx(
1408
+ Pressable,
1409
+ {
1410
+ accessibilityRole: "button",
1411
+ accessibilityLabel: `Go to step ${i + 1}`,
1412
+ accessibilityState: { selected: i === board.step },
1413
+ onPress: () => model.seek(i),
1414
+ hitSlop: 8,
1415
+ style: [styles$3.segment, { backgroundColor: i <= board.step ? theme.accent : theme.border }]
1416
+ },
1417
+ i
1418
+ )) }) : null,
1419
+ /* @__PURE__ */ jsxs(View, { style: styles$3.bar, children: [
1420
+ /* @__PURE__ */ jsx(
1421
+ IconButton,
1422
+ {
1423
+ label: playing ? "Pause" : board.state === "done" ? "Play again" : "Resume",
1424
+ glyph: playing ? "❚❚" : board.state === "done" ? "↻" : "▶",
1425
+ color: theme.text,
1426
+ onPress: () => model.toggle()
1427
+ }
1428
+ ),
1429
+ /* @__PURE__ */ jsx(IconButton, { label: "Replay from the start", glyph: "↺", color: theme.text, onPress: () => model.replay() }),
1430
+ /* @__PURE__ */ jsx(Text, { style: [styles$3.step, { color: theme.textMuted }], children: board.step >= 0 ? `Step ${board.step + 1} of ${board.steps}` : "" }),
1431
+ /* @__PURE__ */ jsx(
1432
+ Pressable,
1433
+ {
1434
+ accessibilityRole: "button",
1435
+ accessibilityLabel: `Speed ${model.speed} times. Change speed`,
1436
+ onPress: () => {
1437
+ const at = SPEEDS.indexOf(model.speed);
1438
+ model.setSpeed(SPEEDS[(at + 1) % SPEEDS.length]);
1439
+ repaint();
1440
+ },
1441
+ style: [styles$3.speed, { borderColor: theme.border }],
1442
+ children: /* @__PURE__ */ jsxs(Text, { style: { color: theme.text, fontSize: 12 }, children: [
1443
+ model.speed,
1444
+ "×"
1445
+ ] })
1446
+ }
1447
+ )
1448
+ ] })
1449
+ ] }) : null
1450
+ ]
1451
+ }
1452
+ ) }) });
1453
+ }
1454
+ function Ink({ obj }) {
1455
+ if (obj.drawn <= 0) return null;
1456
+ return /* @__PURE__ */ jsx(
1457
+ Path,
1458
+ {
1459
+ d: inkPath(obj.strokes, obj.length, obj.drawn),
1460
+ stroke: obj.color,
1461
+ strokeWidth: obj.width,
1462
+ fill: "none",
1463
+ strokeLinecap: "round",
1464
+ strokeLinejoin: "round"
1465
+ }
1466
+ );
1467
+ }
1468
+ function Word({ word, width, height, unit: unit2 }) {
1469
+ const left = word.at[0] / BOARD_W * width;
1470
+ const top = word.at[1] / BOARD_H * height;
1471
+ if (word.kind === "text") {
1472
+ const size2 = unit2 * TEXT_SIZE[word.size];
1473
+ const shown = word.text.slice(0, Math.ceil(word.text.length * word.shown));
1474
+ if (!shown) return null;
1475
+ return /* @__PURE__ */ jsx(
1476
+ Text,
1477
+ {
1478
+ style: [styles$3.word, {
1479
+ left,
1480
+ top: top - size2 * 0.62,
1481
+ fontSize: size2,
1482
+ color: word.color,
1483
+ fontFamily: HAND,
1484
+ backgroundColor: word.marked ? MARKER : "transparent"
1485
+ }],
1486
+ accessibilityLabel: word.text,
1487
+ children: shown
1488
+ }
1489
+ );
1490
+ }
1491
+ if (word.rowsShown <= 0) return null;
1492
+ const size = unit2 * 2.2;
1493
+ 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" }], children: word.rows.slice(0, word.rowsShown).map((row, r) => /* @__PURE__ */ jsx(View, { style: styles$3.row, children: row.map((cell, c) => /* @__PURE__ */ jsx(
1494
+ Text,
1495
+ {
1496
+ style: [styles$3.cell, { fontSize: size, color: word.color, borderColor: word.color, fontFamily: HAND, fontWeight: r === 0 ? "700" : "400" }],
1497
+ children: cell
1498
+ },
1499
+ c
1500
+ )) }, r)) });
1501
+ }
1502
+ function IconButton({ label, glyph, color, onPress }) {
1503
+ 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 }) });
1504
+ }
1505
+ const styles$3 = StyleSheet.create({
1506
+ backdrop: { flex: 1, justifyContent: "flex-end", alignItems: "center", padding: 12 },
1507
+ centre: { justifyContent: "center" },
1508
+ card: {
1509
+ width: "100%",
1510
+ borderRadius: 16,
1511
+ borderWidth: StyleSheet.hairlineWidth,
1512
+ overflow: "hidden",
1513
+ shadowColor: "#0f172a",
1514
+ shadowOpacity: 0.25,
1515
+ shadowRadius: 24,
1516
+ shadowOffset: { width: 0, height: 12 },
1517
+ elevation: 12
1518
+ },
1519
+ head: { flexDirection: "row", alignItems: "center", paddingHorizontal: 12, paddingVertical: 8, gap: 6 },
1520
+ title: { flex: 1, fontSize: 14, fontWeight: "600" },
1521
+ badge: { fontSize: 11, fontWeight: "600", color: "#92400e", backgroundColor: "#fef3c7", borderRadius: 999, paddingHorizontal: 8, paddingVertical: 2, overflow: "hidden" },
1522
+ sheet: { width: "100%", aspectRatio: BOARD_W / BOARD_H, backgroundColor: "#fcfcfd" },
1523
+ status: { ...StyleSheet.absoluteFillObject, alignItems: "center", justifyContent: "center", gap: 10, backgroundColor: "rgba(252,252,253,0.92)", padding: 16 },
1524
+ statusText: { color: "#475569", fontSize: 13, textAlign: "center" },
1525
+ retry: { paddingHorizontal: 14, paddingVertical: 8, borderRadius: 8 },
1526
+ caption: { paddingHorizontal: 14, paddingTop: 10, fontSize: 14, lineHeight: 20, minHeight: 46 },
1527
+ track: { flexDirection: "row", gap: 4, paddingHorizontal: 14, paddingTop: 4 },
1528
+ segment: { flex: 1, height: 6, borderRadius: 3 },
1529
+ bar: { flexDirection: "row", alignItems: "center", paddingHorizontal: 8, paddingVertical: 6, gap: 4 },
1530
+ step: { flex: 1, fontSize: 12, marginLeft: 4 },
1531
+ speed: { borderWidth: 1, borderRadius: 8, paddingHorizontal: 8, paddingVertical: 4 },
1532
+ icon: { width: 34, height: 34, alignItems: "center", justifyContent: "center" },
1533
+ word: { position: "absolute", fontWeight: "600" },
1534
+ table: { position: "absolute", borderWidth: 1.5 },
1535
+ row: { flexDirection: "row" },
1536
+ cell: { flex: 1, borderWidth: 0.75, paddingHorizontal: 6, paddingVertical: 3 }
1537
+ });
1538
+ const DEFAULT_LIVE_VOICE_LABELS = {
1539
+ eyebrow: "Live conversation",
1540
+ listeningTitle: "Listening — go ahead",
1541
+ listeningText: "Speak naturally. Pause when you are ready for an answer.",
1542
+ hearingTitle: "You’re speaking…",
1543
+ hearingText: "I’m listening. Pause when you’re done.",
1544
+ thinkingTitle: "Thinking…",
1545
+ thinkingText: "I’m working on your answer.",
1546
+ speakingTitle: "Speaking…",
1547
+ speakingText: "Tap the circle to interrupt.",
1548
+ end: "End",
1549
+ language: "Language"
1550
+ };
1551
+ const ORB = 96;
1552
+ const CORE = ORB - 24;
1553
+ function useLoop(make, key) {
1554
+ useEffect(() => {
1555
+ if (!key) return void 0;
1556
+ const animation = Animated.loop(make());
1557
+ animation.start();
1558
+ return () => animation.stop();
1559
+ }, [key]);
1560
+ }
1561
+ function Ring({ color, running, duration, delay = 0 }) {
1562
+ const t = useRef(new Animated.Value(0)).current;
1563
+ useLoop(() => Animated.sequence([
1564
+ Animated.delay(delay),
1565
+ Animated.timing(t, { toValue: 1, duration, easing: Easing.out(Easing.quad), useNativeDriver: true }),
1566
+ Animated.timing(t, { toValue: 0, duration: 0, useNativeDriver: true })
1567
+ ]), running ? "on" : false);
1568
+ useEffect(() => {
1569
+ if (!running) t.setValue(0);
1570
+ }, [running, t]);
1571
+ return /* @__PURE__ */ jsx(
1572
+ Animated.View,
1573
+ {
1574
+ pointerEvents: "none",
1575
+ style: [styles$2.ring, {
1576
+ borderColor: color,
1577
+ opacity: t.interpolate({ inputRange: [0, 0.1, 1], outputRange: [0, 0.55, 0] }),
1578
+ transform: [{ scale: t.interpolate({ inputRange: [0, 1], outputRange: [1, 1.55] }) }]
1579
+ }]
1580
+ }
1581
+ );
1582
+ }
1583
+ function Wave({ color }) {
1584
+ const bars = useRef([0, 1, 2, 3, 4, 5, 6].map(() => new Animated.Value(0))).current;
1585
+ useEffect(() => {
1586
+ const delays = [0, 230, 380, 560, 380, 230, 0];
1587
+ const loops = bars.map((bar, i) => Animated.loop(Animated.sequence([
1588
+ Animated.delay(delays[i]),
1589
+ Animated.timing(bar, { toValue: 1, duration: 340, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),
1590
+ Animated.timing(bar, { toValue: 0, duration: 340, easing: Easing.inOut(Easing.ease), useNativeDriver: true })
1591
+ ])));
1592
+ loops.forEach((loop) => loop.start());
1593
+ return () => loops.forEach((loop) => loop.stop());
1594
+ }, [bars]);
1595
+ return /* @__PURE__ */ jsx(View, { style: styles$2.wave, children: bars.map((bar, i) => /* @__PURE__ */ jsx(
1596
+ Animated.View,
1597
+ {
1598
+ style: [styles$2.bar, {
1599
+ backgroundColor: color,
1600
+ transform: [{ scaleY: bar.interpolate({ inputRange: [0, 1], outputRange: [0.32, 1] }) }]
1601
+ }]
1602
+ },
1603
+ i
1604
+ )) });
1605
+ }
1606
+ function Dots({ color }) {
1607
+ const dots = useRef([0, 1, 2].map(() => new Animated.Value(0))).current;
1608
+ useEffect(() => {
1609
+ const loops = dots.map((dot, i) => Animated.loop(Animated.sequence([
1610
+ Animated.delay(i * 150),
1611
+ Animated.timing(dot, { toValue: 1, duration: 450, useNativeDriver: true }),
1612
+ Animated.timing(dot, { toValue: 0, duration: 450, useNativeDriver: true }),
1613
+ Animated.delay((2 - i) * 150)
1614
+ ])));
1615
+ loops.forEach((loop) => loop.start());
1616
+ return () => loops.forEach((loop) => loop.stop());
1617
+ }, [dots]);
1618
+ return /* @__PURE__ */ jsx(View, { style: styles$2.dots, children: dots.map((dot, i) => /* @__PURE__ */ jsx(
1619
+ Animated.View,
1620
+ {
1621
+ style: [styles$2.dot, {
1622
+ backgroundColor: color,
1623
+ opacity: dot.interpolate({ inputRange: [0, 1], outputRange: [0.35, 1] }),
1624
+ transform: [{ translateY: dot.interpolate({ inputRange: [0, 1], outputRange: [0, -4] }) }]
1625
+ }]
1626
+ },
1627
+ i
1628
+ )) });
1629
+ }
1630
+ function GuideAILiveVoice({ live, theme: overrides, labels: given }) {
1631
+ const theme = resolveTheme(overrides);
1632
+ const labels = { ...DEFAULT_LIVE_VOICE_LABELS, ...given };
1633
+ const breathe = useRef(new Animated.Value(0)).current;
1634
+ const level = useRef(new Animated.Value(0)).current;
1635
+ const { state } = live;
1636
+ const breathing = state === "listening" || state === "speaking";
1637
+ useLoop(() => Animated.sequence([
1638
+ Animated.timing(breathe, { toValue: 1, duration: state === "speaking" ? 450 : 1200, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),
1639
+ Animated.timing(breathe, { toValue: 0, duration: state === "speaking" ? 450 : 1200, easing: Easing.inOut(Easing.ease), useNativeDriver: true })
1640
+ ]), breathing ? state : false);
1641
+ useEffect(() => {
1642
+ Animated.timing(level, { toValue: state === "hearing" ? live.level : 0, duration: 110, useNativeDriver: true }).start();
1643
+ }, [live.level, state, level]);
1644
+ if (!live.active) return null;
1645
+ const [title, text] = {
1646
+ off: ["", ""],
1647
+ listening: [labels.listeningTitle, labels.listeningText],
1648
+ hearing: [labels.hearingTitle, labels.hearingText],
1649
+ thinking: [labels.thinkingTitle, labels.thinkingText],
1650
+ speaking: [labels.speakingTitle, labels.speakingText]
1651
+ }[state];
1652
+ const coreScale = Animated.add(
1653
+ breathe.interpolate({ inputRange: [0, 1], outputRange: [1, breathing ? 1.06 : 1] }),
1654
+ level.interpolate({ inputRange: [0, 1], outputRange: [state === "hearing" ? 0.04 : 0, 0.22] })
1655
+ );
1656
+ return /* @__PURE__ */ jsxs(
1657
+ View,
1658
+ {
1659
+ accessibilityRole: "summary",
1660
+ accessibilityLabel: `${labels.eyebrow}: ${title}`,
1661
+ style: [styles$2.panel, { borderColor: theme.border, backgroundColor: theme.surface }],
1662
+ children: [
1663
+ /* @__PURE__ */ jsxs(
1664
+ Pressable,
1665
+ {
1666
+ onPress: state === "speaking" ? live.interrupt : void 0,
1667
+ accessibilityRole: state === "speaking" ? "button" : void 0,
1668
+ accessibilityLabel: state === "speaking" ? labels.speakingText : void 0,
1669
+ style: styles$2.orb,
1670
+ children: [
1671
+ /* @__PURE__ */ jsx(Ring, { color: theme.accent, running: state === "listening", duration: 2400 }),
1672
+ /* @__PURE__ */ jsx(Ring, { color: theme.accent, running: state === "hearing", duration: 1100 }),
1673
+ /* @__PURE__ */ jsx(Ring, { color: theme.accent, running: state === "hearing", duration: 1100, delay: 550 }),
1674
+ /* @__PURE__ */ jsx(
1675
+ Animated.View,
1676
+ {
1677
+ style: [styles$2.core, {
1678
+ backgroundColor: theme.accent,
1679
+ shadowColor: theme.accent,
1680
+ opacity: state === "thinking" ? 0.85 : 1,
1681
+ transform: [{ scale: coreScale }]
1682
+ }]
1683
+ }
1684
+ ),
1685
+ state === "speaking" ? /* @__PURE__ */ jsx(Wave, { color: theme.onAccent }) : null,
1686
+ state === "thinking" ? /* @__PURE__ */ jsx(Dots, { color: theme.onAccent }) : null
1687
+ ]
1688
+ }
1689
+ ),
1690
+ /* @__PURE__ */ jsx(Text, { style: [styles$2.eyebrow, { color: theme.textMuted, fontSize: theme.fontSize - 3 }], children: labels.eyebrow }),
1691
+ /* @__PURE__ */ jsx(Text, { style: [styles$2.title, { color: theme.text, fontSize: theme.fontSize + 2 }], children: title }),
1692
+ /* @__PURE__ */ jsx(Text, { style: [styles$2.text, { color: theme.textMuted, fontSize: theme.fontSize - 1 }], children: text }),
1693
+ /* @__PURE__ */ jsxs(View, { style: styles$2.actions, children: [
1694
+ live.language ? /* @__PURE__ */ jsx(
1695
+ Pressable,
1696
+ {
1697
+ onPress: live.changeLanguage,
1698
+ accessibilityRole: "button",
1699
+ style: [styles$2.chip, { borderColor: theme.border }],
1700
+ hitSlop: 6,
1701
+ children: /* @__PURE__ */ jsxs(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize - 2 }, children: [
1702
+ labels.language,
1703
+ ": ",
1704
+ /* @__PURE__ */ jsx(Text, { style: { color: theme.text, fontWeight: "600" }, children: live.language.label })
1705
+ ] })
1706
+ }
1707
+ ) : null,
1708
+ /* @__PURE__ */ jsx(
1709
+ Pressable,
1710
+ {
1711
+ onPress: live.stop,
1712
+ accessibilityRole: "button",
1713
+ accessibilityLabel: labels.end,
1714
+ style: [styles$2.end, { backgroundColor: theme.error }],
1715
+ hitSlop: 6,
1716
+ children: /* @__PURE__ */ jsxs(Text, { style: [styles$2.endText, { fontSize: theme.fontSize - 1 }], children: [
1717
+ "✆ ",
1718
+ labels.end
1719
+ ] })
1720
+ }
1721
+ )
1722
+ ] })
1723
+ ]
1724
+ }
1725
+ );
1726
+ }
1727
+ const styles$2 = StyleSheet.create({
1728
+ panel: {
1729
+ alignItems: "center",
1730
+ paddingTop: 18,
1731
+ paddingBottom: 14,
1732
+ paddingHorizontal: 16,
1733
+ borderTopWidth: StyleSheet.hairlineWidth,
1734
+ borderBottomWidth: StyleSheet.hairlineWidth
1735
+ },
1736
+ orb: { width: ORB, height: ORB, alignItems: "center", justifyContent: "center", marginBottom: 8 },
1737
+ core: {
1738
+ position: "absolute",
1739
+ width: CORE,
1740
+ height: CORE,
1741
+ borderRadius: CORE / 2,
1742
+ shadowOffset: { width: 0, height: 8 },
1743
+ shadowOpacity: 0.35,
1744
+ shadowRadius: 12,
1745
+ elevation: 6
1746
+ },
1747
+ ring: { position: "absolute", width: CORE, height: CORE, borderRadius: CORE / 2, borderWidth: 2 },
1748
+ wave: { flexDirection: "row", alignItems: "center", gap: 3, height: 26 },
1749
+ bar: { width: 3, height: 26, borderRadius: 2 },
1750
+ dots: { flexDirection: "row", alignItems: "center", gap: 6 },
1751
+ dot: { width: 7, height: 7, borderRadius: 4 },
1752
+ eyebrow: { fontWeight: "500", marginBottom: 2 },
1753
+ title: { fontWeight: "700", textAlign: "center" },
1754
+ text: { textAlign: "center", marginTop: 3, lineHeight: 19 },
1755
+ actions: { flexDirection: "row", alignItems: "center", gap: 10, marginTop: 12 },
1756
+ chip: { borderWidth: 1, borderRadius: 999, paddingHorizontal: 12, paddingVertical: 7 },
1757
+ end: { borderRadius: 999, paddingHorizontal: 18, paddingVertical: 9 },
1758
+ endText: { color: "#FFFFFF", fontWeight: "700" }
1759
+ });
1760
+ const DEFAULT_LANGUAGE_PICKER_LABELS = {
1761
+ title: "Which language will you speak?",
1762
+ hint: "The assistant listens in this language. You can change it any time.",
1763
+ cancel: "Cancel"
1764
+ };
1765
+ function GuideAILanguagePicker({ voice, theme: overrides, labels: given }) {
1766
+ if (!voice.choosingLanguage) return null;
1767
+ const theme = resolveTheme(overrides);
1768
+ const labels = { ...DEFAULT_LANGUAGE_PICKER_LABELS, ...given };
1769
+ return /* @__PURE__ */ jsx(Modal, { visible: true, transparent: true, animationType: "fade", onRequestClose: voice.cancelLanguage, children: /* @__PURE__ */ jsxs(View, { style: styles$1.backdrop, children: [
1770
+ /* @__PURE__ */ jsx(Pressable, { style: StyleSheet.absoluteFill, onPress: voice.cancelLanguage, accessibilityLabel: labels.cancel }),
1771
+ /* @__PURE__ */ jsxs(View, { style: [styles$1.card, { backgroundColor: theme.surfaceRaised, borderColor: theme.border, borderRadius: theme.radius + 6 }], children: [
1772
+ /* @__PURE__ */ jsx(Text, { style: [styles$1.title, { color: theme.text, fontSize: theme.fontSize + 3 }], children: labels.title }),
1773
+ /* @__PURE__ */ jsx(Text, { style: [styles$1.hint, { color: theme.textMuted, fontSize: theme.fontSize - 1 }], children: labels.hint }),
1774
+ /* @__PURE__ */ jsx(ScrollView, { style: styles$1.list, contentContainerStyle: styles$1.listContent, children: voice.languages.map((lang) => {
1775
+ var _a;
1776
+ const on = ((_a = voice.language) == null ? void 0 : _a.code) === lang.code;
1777
+ return /* @__PURE__ */ jsxs(
1778
+ Pressable,
1779
+ {
1780
+ accessibilityRole: "button",
1781
+ accessibilityState: { selected: on },
1782
+ onPress: () => {
1783
+ void voice.chooseLanguage(lang.code);
1784
+ },
1785
+ style: ({ pressed }) => [styles$1.row, {
1786
+ borderColor: on ? theme.accent : theme.border,
1787
+ backgroundColor: on ? theme.accent : pressed ? theme.surface : "transparent",
1788
+ borderRadius: theme.radius
1789
+ }],
1790
+ children: [
1791
+ /* @__PURE__ */ jsx(Text, { style: { color: on ? theme.onAccent : theme.text, fontSize: theme.fontSize + 1, fontWeight: on ? "700" : "500" }, children: lang.label }),
1792
+ on ? /* @__PURE__ */ jsx(Text, { style: { color: theme.onAccent, fontSize: theme.fontSize }, children: "✓" }) : null
1793
+ ]
1794
+ },
1795
+ lang.code
1796
+ );
1797
+ }) }),
1798
+ /* @__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 }) })
1799
+ ] })
1800
+ ] }) });
1801
+ }
1802
+ const styles$1 = StyleSheet.create({
1803
+ backdrop: { flex: 1, justifyContent: "center", padding: 22, backgroundColor: "rgba(0,0,0,0.45)" },
1804
+ card: { borderWidth: StyleSheet.hairlineWidth, padding: 20, maxHeight: "80%" },
1805
+ title: { fontWeight: "700" },
1806
+ hint: { marginTop: 6, marginBottom: 14, lineHeight: 19 },
1807
+ list: { flexGrow: 0 },
1808
+ listContent: { gap: 8 },
1809
+ row: {
1810
+ flexDirection: "row",
1811
+ alignItems: "center",
1812
+ justifyContent: "space-between",
1813
+ borderWidth: 1,
1814
+ paddingVertical: 13,
1815
+ paddingHorizontal: 16
1816
+ },
1817
+ cancel: { alignSelf: "center", marginTop: 14, paddingVertical: 4, paddingHorizontal: 12 }
1818
+ });
1819
+ function PersonIcon({ color }) {
1820
+ return /* @__PURE__ */ jsxs(View, { style: styles.iconWrap, children: [
1821
+ /* @__PURE__ */ jsx(View, { style: [styles.iconBand, { borderColor: color }] }),
1822
+ /* @__PURE__ */ jsx(View, { style: [styles.iconCup, styles.iconCupLeft, { backgroundColor: color }] }),
1823
+ /* @__PURE__ */ jsx(View, { style: [styles.iconCup, styles.iconCupRight, { backgroundColor: color }] })
1824
+ ] });
1825
+ }
1826
+ function Orb({ theme, active }) {
1827
+ const pulse = useRef(new Animated.Value(0)).current;
1828
+ React.useEffect(() => {
1829
+ if (!active) {
1830
+ pulse.stopAnimation();
1831
+ Animated.timing(pulse, { toValue: 0, duration: 240, useNativeDriver: true }).start();
1832
+ return;
1833
+ }
1834
+ const loop = Animated.loop(
1835
+ Animated.sequence([
1836
+ Animated.timing(pulse, {
1837
+ toValue: 1,
1838
+ duration: 900,
1839
+ easing: Easing.inOut(Easing.quad),
1840
+ useNativeDriver: true
1841
+ }),
1842
+ Animated.timing(pulse, {
1843
+ toValue: 0,
1844
+ duration: 900,
1845
+ easing: Easing.inOut(Easing.quad),
1846
+ useNativeDriver: true
1847
+ })
1848
+ ])
1849
+ );
1850
+ loop.start();
1851
+ return () => loop.stop();
1852
+ }, [active, pulse]);
1853
+ const scale = pulse.interpolate({ inputRange: [0, 1], outputRange: [1, 1.18] });
1854
+ const glow = pulse.interpolate({ inputRange: [0, 1], outputRange: [0.35, 0.7] });
1855
+ return /* @__PURE__ */ jsxs(View, { style: styles.orbWrap, children: [
1856
+ /* @__PURE__ */ jsx(
1857
+ Animated.View,
1858
+ {
1859
+ style: [
1860
+ styles.orbGlow,
1861
+ { backgroundColor: theme.accent, opacity: glow, transform: [{ scale }] }
1862
+ ]
1863
+ }
1864
+ ),
1865
+ /* @__PURE__ */ jsx(View, { style: [styles.orbCore, { backgroundColor: theme.accent }] })
1866
+ ] });
1867
+ }
1868
+ function Bubble({ message, theme, onTalkToHuman, onWhiteboard }) {
1869
+ if (message.role === "user") {
1870
+ return /* @__PURE__ */ jsx(View, { style: [styles.row, styles.rowUser], children: /* @__PURE__ */ jsx(View, { style: [
1871
+ styles.bubble,
1872
+ { backgroundColor: theme.userBubble, borderRadius: theme.radius },
1873
+ message.error ? { backgroundColor: theme.error } : null
1874
+ ], children: /* @__PURE__ */ jsx(Text, { style: {
1875
+ color: theme.onUserBubble,
1876
+ fontSize: theme.fontSize,
1877
+ lineHeight: theme.fontSize * 1.4
1878
+ }, children: message.content }) }) });
1879
+ }
1880
+ return /* @__PURE__ */ jsx(View, { style: [styles.row, styles.rowAssistant], children: /* @__PURE__ */ jsxs(View, { style: [
1881
+ styles.assistantBody,
1882
+ message.error ? { backgroundColor: theme.error, borderRadius: theme.radius, padding: 12 } : null
1883
+ ], children: [
1884
+ /* @__PURE__ */ jsx(Markdown, { color: theme.text, accentColor: theme.accent, fontSize: theme.fontSize, children: message.content }),
1885
+ onWhiteboard ? /* @__PURE__ */ jsx(
1886
+ Pressable,
1887
+ {
1888
+ onPress: onWhiteboard,
1889
+ accessibilityRole: "button",
1890
+ accessibilityLabel: "Explain on whiteboard",
1891
+ style: [styles.errorAction, { borderColor: theme.accent }],
1892
+ hitSlop: 6,
1893
+ children: /* @__PURE__ */ jsx(Text, { style: [styles.humanText, { color: theme.accent, fontSize: theme.fontSize - 1 }], children: "✎ Explain on whiteboard" })
1894
+ }
1895
+ ) : null,
1896
+ message.error && onTalkToHuman ? /* @__PURE__ */ jsxs(
1897
+ Pressable,
1898
+ {
1899
+ onPress: onTalkToHuman,
1900
+ accessibilityRole: "button",
1901
+ accessibilityLabel: "Talk to a person",
1902
+ style: [styles.errorAction, { borderColor: theme.accent }],
1903
+ hitSlop: 6,
1904
+ children: [
1905
+ /* @__PURE__ */ jsx(PersonIcon, { color: theme.accent }),
1906
+ /* @__PURE__ */ jsx(Text, { style: [styles.humanText, {
1907
+ color: theme.accent,
1908
+ fontSize: theme.fontSize - 1
1909
+ }], children: "Talk to a human" })
1910
+ ]
1911
+ }
1912
+ ) : null
1913
+ ] }) });
1914
+ }
1915
+ function HistoryPanel({ theme, onClose }) {
1916
+ const { conversations, activeId, newConversation, openConversation, deleteConversation } = useConversations();
1917
+ return /* @__PURE__ */ jsxs(Modal, { visible: true, transparent: true, animationType: "fade", onRequestClose: onClose, children: [
1918
+ /* @__PURE__ */ jsx(Pressable, { style: styles.sheetBackdrop, onPress: onClose, accessibilityLabel: "Close chat history" }),
1919
+ /* @__PURE__ */ jsxs(View, { style: [styles.sheet, { backgroundColor: theme.background, borderColor: theme.border }], children: [
1920
+ /* @__PURE__ */ jsx(Text, { style: [styles.sheetTitle, { color: theme.text, fontSize: theme.fontSize + 2 }], children: "Chats" }),
1921
+ /* @__PURE__ */ jsx(
1922
+ Pressable,
1923
+ {
1924
+ accessibilityRole: "button",
1925
+ onPress: () => {
1926
+ newConversation();
1927
+ onClose();
1928
+ },
1929
+ style: [styles.sheetRow, { borderColor: theme.accent }],
1930
+ children: /* @__PURE__ */ jsx(Text, { style: { color: theme.accent, fontWeight: "600", fontSize: theme.fontSize }, children: "+ New chat" })
1931
+ }
1932
+ ),
1933
+ /* @__PURE__ */ jsx(
1934
+ FlatList,
1935
+ {
1936
+ data: conversations,
1937
+ keyExtractor: (c) => c.id,
1938
+ ListEmptyComponent: /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, padding: 12 }, children: "No previous chats yet." }),
1939
+ renderItem: ({ item }) => /* @__PURE__ */ jsxs(View, { style: [styles.historyItem, { backgroundColor: item.id === activeId ? theme.surface : void 0 }], children: [
1940
+ /* @__PURE__ */ jsx(
1941
+ Pressable,
1942
+ {
1943
+ accessibilityRole: "button",
1944
+ style: { flex: 1 },
1945
+ onPress: () => {
1946
+ openConversation(item.id);
1947
+ onClose();
1948
+ },
1949
+ children: /* @__PURE__ */ jsx(Text, { numberOfLines: 2, style: { color: theme.text, fontSize: theme.fontSize }, children: item.title })
1950
+ }
1951
+ ),
1952
+ /* @__PURE__ */ jsx(
1953
+ Pressable,
1954
+ {
1955
+ accessibilityRole: "button",
1956
+ accessibilityLabel: `Delete ${item.title}`,
1957
+ hitSlop: 8,
1958
+ onPress: () => deleteConversation(item.id),
1959
+ children: /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize }, children: "✕" })
1960
+ }
1961
+ )
1962
+ ] })
1963
+ }
1964
+ )
1965
+ ] })
1966
+ ] });
1967
+ }
1968
+ function resolveTopInset(explicit) {
1969
+ var _a;
1970
+ if (explicit !== void 0) return explicit;
1971
+ if (Platform.OS === "android") return (_a = StatusBar.currentHeight) != null ? _a : 24;
1972
+ return 8;
1973
+ }
1974
+ function useHumanHandover(onTalkToHuman, available) {
1975
+ const [reachable, setReachable] = useState(false);
1976
+ useEffect(() => {
1977
+ if (!onTalkToHuman || available !== void 0) return;
1978
+ let cancelled = false;
1979
+ void (async () => {
1980
+ try {
1981
+ const { api } = requireConfigured();
1982
+ const status = await api.get(
1983
+ EP.supportStatus()
1984
+ );
1985
+ if (!cancelled) setReachable(!!(status == null ? void 0 : status.enabled));
1986
+ } catch {
1987
+ }
1988
+ })();
1989
+ return () => {
1990
+ cancelled = true;
1991
+ };
1992
+ }, [onTalkToHuman, available]);
1993
+ if (!onTalkToHuman) return false;
1994
+ return available != null ? available : reachable;
1995
+ }
1996
+ function GuideAIChat({
1997
+ theme: overrides,
1998
+ placeholder = "Ask me anything",
1999
+ greeting = "Ask me anything",
2000
+ emptyState,
2001
+ showMic = true,
2002
+ showHistory = true,
2003
+ useVoice,
2004
+ leadingAccessory,
2005
+ title,
2006
+ onClose,
2007
+ onTalkToHuman,
2008
+ humanHandoverAvailable,
2009
+ topInset
2010
+ }) {
2011
+ const { harness, debug } = requireConfigured();
2012
+ const chat = useGuideAI({ harness, trace: debug });
2013
+ const {
2014
+ messages,
2015
+ input,
2016
+ setInput,
2017
+ send,
2018
+ busy,
2019
+ canSend,
2020
+ status,
2021
+ typing,
2022
+ followUps,
2023
+ explainOnWhiteboard
2024
+ } = chat;
2025
+ const voice = useVoice ? useVoice(chat) : null;
2026
+ const [historyOpen, setHistoryOpen] = useState(false);
2027
+ const theme = resolveTheme(overrides);
2028
+ const listRef = useRef(null);
2029
+ const showHuman = useHumanHandover(onTalkToHuman, humanHandoverAvailable);
2030
+ const { checklist, dismiss } = useOnboarding();
2031
+ const nextSetupStep = checklist == null ? void 0 : checklist.steps.find((step) => step.state === "available");
2032
+ const headerTop = resolveTopInset(topInset);
2033
+ const submit = () => {
2034
+ void send();
2035
+ };
2036
+ return /* @__PURE__ */ jsxs(
2037
+ KeyboardAvoidingView,
2038
+ {
2039
+ style: [styles.container, { backgroundColor: theme.background }],
2040
+ behavior: Platform.OS === "ios" ? "padding" : void 0,
2041
+ children: [
2042
+ title || onClose || showHuman || showHistory ? /* @__PURE__ */ jsxs(View, { style: [
2043
+ styles.header,
2044
+ { borderBottomColor: theme.border, paddingTop: headerTop + 14 }
2045
+ ], children: [
2046
+ /* @__PURE__ */ jsx(View, { style: styles.headerSide, children: title ? /* @__PURE__ */ jsx(
2047
+ Text,
2048
+ {
2049
+ numberOfLines: 1,
2050
+ style: [styles.title, { color: theme.text, fontSize: theme.fontSize + 1 }],
2051
+ children: title
2052
+ }
2053
+ ) : null }),
2054
+ /* @__PURE__ */ jsxs(View, { style: styles.headerActions, children: [
2055
+ showHistory ? /* @__PURE__ */ jsx(
2056
+ Pressable,
2057
+ {
2058
+ onPress: () => setHistoryOpen(true),
2059
+ accessibilityRole: "button",
2060
+ accessibilityLabel: "Chat history",
2061
+ style: [styles.close, { backgroundColor: theme.surface }],
2062
+ hitSlop: 8,
2063
+ children: /* @__PURE__ */ jsx(Text, { style: [styles.closeIcon, { color: theme.text }], children: "☰" })
2064
+ }
2065
+ ) : null,
2066
+ showHuman ? /* @__PURE__ */ jsxs(
2067
+ Pressable,
2068
+ {
2069
+ onPress: onTalkToHuman,
2070
+ accessibilityRole: "button",
2071
+ accessibilityLabel: "Talk to a person",
2072
+ style: [styles.human, {
2073
+ backgroundColor: theme.surface,
2074
+ borderColor: theme.border
2075
+ }],
2076
+ hitSlop: 8,
2077
+ children: [
2078
+ /* @__PURE__ */ jsx(PersonIcon, { color: theme.accent }),
2079
+ /* @__PURE__ */ jsx(Text, { style: [styles.humanText, {
2080
+ color: theme.accent,
2081
+ fontSize: theme.fontSize - 2
2082
+ }], children: "Talk to human" })
2083
+ ]
2084
+ }
2085
+ ) : null,
2086
+ onClose ? /* @__PURE__ */ jsx(
2087
+ Pressable,
2088
+ {
2089
+ onPress: onClose,
2090
+ accessibilityRole: "button",
2091
+ accessibilityLabel: "Close assistant",
2092
+ style: [styles.close, { backgroundColor: theme.surface }],
2093
+ hitSlop: 10,
2094
+ children: /* @__PURE__ */ jsx(Text, { style: [styles.closeIcon, { color: theme.text }], children: "✕" })
2095
+ }
2096
+ ) : null
2097
+ ] })
2098
+ ] }) : null,
2099
+ 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: [
2100
+ /* @__PURE__ */ jsx(Text, { style: { color: theme.text, fontWeight: "700", fontSize: theme.fontSize + 2 }, children: checklist.title }),
2101
+ /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, marginTop: 3 }, children: checklist.goal }),
2102
+ /* @__PURE__ */ jsxs(Text, { style: { color: theme.textMuted, marginTop: 8 }, children: [
2103
+ checklist.completed_required,
2104
+ " of ",
2105
+ checklist.total_required,
2106
+ " required steps complete"
2107
+ ] }),
2108
+ checklist.steps.map((step) => /* @__PURE__ */ jsxs(Text, { style: { color: step.state === "locked" ? theme.textMuted : theme.text, marginTop: 5 }, children: [
2109
+ step.state === "complete" ? "✓" : step.state === "locked" ? "–" : "○",
2110
+ " ",
2111
+ step.title
2112
+ ] }, step.id)),
2113
+ 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,
2114
+ 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.", [
2115
+ { text: "Keep setup", style: "cancel" },
2116
+ { text: "I don't need it", onPress: () => {
2117
+ void dismiss().catch(() => Alert.alert("Could not dismiss setup", "Please try again."));
2118
+ } }
2119
+ ]), 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
2120
+ ] }) : null,
2121
+ messages.length === 0 ? /* @__PURE__ */ jsx(View, { style: styles.empty, children: emptyState != null ? emptyState : /* @__PURE__ */ jsxs(View, { style: styles.greetingRow, children: [
2122
+ /* @__PURE__ */ jsx(Orb, { theme, active: busy }),
2123
+ /* @__PURE__ */ jsx(Text, { style: [
2124
+ styles.greeting,
2125
+ { color: theme.textMuted, fontSize: theme.fontSize + 3 }
2126
+ ], children: greeting })
2127
+ ] }) }) : /* @__PURE__ */ jsx(
2128
+ FlatList,
2129
+ {
2130
+ ref: listRef,
2131
+ data: messages,
2132
+ keyExtractor: (message) => message.id,
2133
+ renderItem: ({ item }) => /* @__PURE__ */ jsx(
2134
+ Bubble,
2135
+ {
2136
+ message: item,
2137
+ theme,
2138
+ onTalkToHuman,
2139
+ onWhiteboard: item.whiteboard ? () => {
2140
+ void explainOnWhiteboard(item.id);
2141
+ } : void 0
2142
+ }
2143
+ ),
2144
+ ListFooterComponent: typing || followUps.length ? /* @__PURE__ */ jsxs(View, { style: styles.footer, children: [
2145
+ typing ? /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize }, children: "…" }) : null,
2146
+ followUps.map((label) => /* @__PURE__ */ jsx(
2147
+ Pressable,
2148
+ {
2149
+ onPress: () => {
2150
+ void send(label);
2151
+ },
2152
+ accessibilityRole: "button",
2153
+ style: [styles.chip, { borderColor: theme.accent, borderRadius: theme.radius }],
2154
+ hitSlop: 4,
2155
+ children: /* @__PURE__ */ jsx(Text, { style: { color: theme.accent, fontSize: theme.fontSize - 1 }, children: label })
2156
+ },
2157
+ label
2158
+ ))
2159
+ ] }) : null,
2160
+ contentContainerStyle: styles.list,
2161
+ onContentSizeChange: () => {
2162
+ var _a;
2163
+ return (_a = listRef.current) == null ? void 0 : _a.scrollToEnd({ animated: true });
2164
+ },
2165
+ keyboardShouldPersistTaps: "handled"
2166
+ }
2167
+ ),
2168
+ voice ? /* @__PURE__ */ jsx(GuideAILiveVoice, { live: voice.live, theme: overrides }) : null,
2169
+ (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,
2170
+ status ? /* @__PURE__ */ jsxs(View, { style: styles.status, children: [
2171
+ /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: theme.accent }),
2172
+ /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize - 2 }, children: status })
2173
+ ] }) : null,
2174
+ /* @__PURE__ */ jsxs(View, { style: styles.composerRow, children: [
2175
+ /* @__PURE__ */ jsxs(View, { style: [
2176
+ styles.composer,
2177
+ {
2178
+ backgroundColor: theme.surface,
2179
+ borderRadius: theme.radius + 6,
2180
+ borderColor: theme.border
2181
+ }
2182
+ ], children: [
2183
+ leadingAccessory ? /* @__PURE__ */ jsx(View, { style: styles.leading, children: leadingAccessory }) : null,
2184
+ /* @__PURE__ */ jsx(
2185
+ TextInput,
2186
+ {
2187
+ style: [styles.input, { color: theme.text, fontSize: theme.fontSize }],
2188
+ value: input,
2189
+ onChangeText: setInput,
2190
+ placeholder: checklist && !checklist.completed && checklist.chat_policy === "setup_only" ? "Ask about your setup" : placeholder,
2191
+ placeholderTextColor: theme.textMuted,
2192
+ editable: !busy,
2193
+ onSubmitEditing: submit,
2194
+ returnKeyType: "send",
2195
+ multiline: true,
2196
+ accessibilityLabel: placeholder
2197
+ }
2198
+ ),
2199
+ /* @__PURE__ */ jsx(
2200
+ Pressable,
2201
+ {
2202
+ onPress: submit,
2203
+ disabled: !canSend,
2204
+ accessibilityRole: "button",
2205
+ accessibilityLabel: "Send",
2206
+ style: [styles.send, { backgroundColor: canSend ? theme.accent : theme.border }],
2207
+ hitSlop: 6,
2208
+ children: /* @__PURE__ */ jsx(Text, { style: [
2209
+ styles.sendIcon,
2210
+ { color: canSend ? theme.onAccent : theme.textMuted }
2211
+ ], children: "↑" })
2212
+ }
2213
+ )
2214
+ ] }),
2215
+ showMic && voice ? /* @__PURE__ */ jsxs(Fragment, { children: [
2216
+ /* @__PURE__ */ jsx(
2217
+ Pressable,
2218
+ {
2219
+ onPress: () => {
2220
+ void voice.mic.toggle();
2221
+ },
2222
+ disabled: busy || voice.mic.transcribing || voice.live.active,
2223
+ accessibilityRole: "button",
2224
+ accessibilityLabel: voice.mic.recording ? "Stop and send" : "Speak a message",
2225
+ style: [styles.mic, {
2226
+ backgroundColor: voice.mic.recording ? theme.error : theme.surface,
2227
+ borderColor: theme.border
2228
+ }],
2229
+ 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 ? "■" : "🎤" })
2230
+ }
2231
+ ),
2232
+ /* @__PURE__ */ jsx(
2233
+ Pressable,
2234
+ {
2235
+ onPress: () => {
2236
+ if (voice.live.active) voice.live.stop();
2237
+ else void voice.live.start();
2238
+ },
2239
+ disabled: voice.mic.recording,
2240
+ accessibilityRole: "button",
2241
+ accessibilityLabel: voice.live.active ? "End live voice" : "Talk live",
2242
+ style: [styles.mic, {
2243
+ backgroundColor: voice.live.active ? theme.accent : theme.surface,
2244
+ borderColor: theme.border
2245
+ }],
2246
+ children: /* @__PURE__ */ jsx(Text, { style: { color: voice.live.active ? theme.onAccent : theme.text, fontSize: 16 }, children: voice.live.active ? "✕" : "◉" })
2247
+ }
2248
+ )
2249
+ ] }) : null
2250
+ ] }),
2251
+ (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: [
2252
+ "🎙 ",
2253
+ voice.mic.language.label
2254
+ ] }) }) : null,
2255
+ voice ? /* @__PURE__ */ jsx(GuideAILanguagePicker, { voice: voice.mic, theme: overrides }) : null,
2256
+ historyOpen ? /* @__PURE__ */ jsx(HistoryPanel, { theme, onClose: () => setHistoryOpen(false) }) : null,
2257
+ /* @__PURE__ */ jsx(GuideAIWhiteboard, { theme: overrides })
2258
+ ]
2259
+ }
2260
+ );
2261
+ }
2262
+ const styles = StyleSheet.create({
2263
+ container: { flex: 1 },
2264
+ header: {
2265
+ flexDirection: "row",
2266
+ alignItems: "center",
2267
+ justifyContent: "space-between",
2268
+ // paddingTop is set inline from the status-bar inset; only the
2269
+ // bottom half of the navbar's breathing room lives here.
2270
+ paddingHorizontal: 16,
2271
+ paddingBottom: 14,
2272
+ borderBottomWidth: StyleSheet.hairlineWidth
2273
+ },
2274
+ headerSide: { flex: 1, minWidth: 0 },
2275
+ headerActions: { flexDirection: "row", alignItems: "center", gap: 8 },
2276
+ title: { fontWeight: "600" },
2277
+ human: {
2278
+ flexDirection: "row",
2279
+ alignItems: "center",
2280
+ gap: 6,
2281
+ paddingHorizontal: 10,
2282
+ paddingVertical: 6,
2283
+ borderRadius: 999,
2284
+ borderWidth: StyleSheet.hairlineWidth
2285
+ },
2286
+ humanText: { fontWeight: "600" },
2287
+ errorAction: {
2288
+ flexDirection: "row",
2289
+ alignItems: "center",
2290
+ gap: 6,
2291
+ alignSelf: "flex-start",
2292
+ marginTop: 10,
2293
+ paddingHorizontal: 12,
2294
+ paddingVertical: 7,
2295
+ borderRadius: 999,
2296
+ borderWidth: StyleSheet.hairlineWidth
2297
+ },
2298
+ iconWrap: { width: 14, height: 14, alignItems: "center", justifyContent: "center" },
2299
+ iconBand: {
2300
+ position: "absolute",
2301
+ top: 1,
2302
+ width: 12,
2303
+ height: 9,
2304
+ borderWidth: 1.6,
2305
+ borderBottomWidth: 0,
2306
+ borderTopLeftRadius: 6,
2307
+ borderTopRightRadius: 6
2308
+ },
2309
+ iconCup: { position: "absolute", bottom: 1, width: 3.5, height: 6, borderRadius: 1.5 },
2310
+ iconCupLeft: { left: 0 },
2311
+ iconCupRight: { right: 0 },
2312
+ close: {
2313
+ width: 32,
2314
+ height: 32,
2315
+ borderRadius: 16,
2316
+ alignItems: "center",
2317
+ justifyContent: "center"
2318
+ },
2319
+ closeIcon: { fontSize: 15, fontWeight: "600", lineHeight: 18 },
2320
+ list: { padding: 16, paddingBottom: 8, gap: 14 },
2321
+ empty: {
2322
+ // Centred, not pinned near the top: before the first message the
2323
+ // greeting is the only thing on screen, and hanging it under the
2324
+ // navbar leaves the rest of the display empty.
2325
+ flex: 1,
2326
+ alignItems: "center",
2327
+ justifyContent: "center",
2328
+ paddingHorizontal: 24,
2329
+ paddingBottom: 24
2330
+ },
2331
+ greetingRow: { flexDirection: "row", alignItems: "center", gap: 14 },
2332
+ greeting: { fontWeight: "400", textAlign: "center", flexShrink: 1 },
2333
+ orbWrap: { width: 34, height: 34, alignItems: "center", justifyContent: "center" },
2334
+ orbGlow: { position: "absolute", width: 34, height: 34, borderRadius: 17 },
2335
+ orbCore: { width: 20, height: 20, borderRadius: 10 },
2336
+ row: { flexDirection: "row" },
2337
+ rowUser: { justifyContent: "flex-end" },
2338
+ rowAssistant: { justifyContent: "flex-start" },
2339
+ // The user's bubble hugs its text: a three-word question drawn as a
2340
+ // full-width block reads as a paragraph, not a chat message. It is
2341
+ // capped at 80% so a long one still leaves the reply side legible.
2342
+ bubble: { maxWidth: "80%", paddingHorizontal: 16, paddingVertical: 11 },
2343
+ // The assistant's body does NOT hug its content, and that is the whole
2344
+ // point of `width` here rather than `maxWidth` alone.
2345
+ //
2346
+ // A View with only maxWidth shrink-wraps — React Native's equivalent of
2347
+ // width: fit-content. For a paragraph that looks fine, because the text
2348
+ // fills the measure anyway. For anything that lays itself out against
2349
+ // its parent — a table whose cells are `flex: 1`, a fenced code block,
2350
+ // a numbered list — the parent has collapsed to nothing by the time the
2351
+ // child is measured, so the table renders as an empty sliver and every
2352
+ // reply ends up a different width.
2353
+ //
2354
+ // Fixing it here rather than on the table keeps every block type
2355
+ // consistent: one column, the same measure for prose, code and tables.
2356
+ assistantBody: { width: "80%" },
2357
+ status: {
2358
+ flexDirection: "row",
2359
+ alignItems: "center",
2360
+ gap: 8,
2361
+ paddingHorizontal: 22,
2362
+ paddingBottom: 8
2363
+ },
2364
+ composerRow: {
2365
+ flexDirection: "row",
2366
+ alignItems: "flex-end",
2367
+ gap: 10,
2368
+ paddingHorizontal: 14,
2369
+ paddingBottom: Platform.OS === "ios" ? 10 : 14,
2370
+ paddingTop: 4
2371
+ },
2372
+ composer: {
2373
+ flex: 1,
2374
+ flexDirection: "row",
2375
+ alignItems: "center",
2376
+ paddingLeft: 8,
2377
+ paddingRight: 6,
2378
+ paddingVertical: 6,
2379
+ borderWidth: StyleSheet.hairlineWidth,
2380
+ gap: 6
2381
+ },
2382
+ leading: { paddingLeft: 4 },
2383
+ input: {
2384
+ flex: 1,
2385
+ paddingHorizontal: 8,
2386
+ paddingVertical: Platform.OS === "ios" ? 8 : 4,
2387
+ maxHeight: 120
2388
+ },
2389
+ send: { width: 34, height: 34, borderRadius: 17, alignItems: "center", justifyContent: "center" },
2390
+ sendIcon: { fontSize: 17, fontWeight: "700", lineHeight: 20 },
2391
+ footer: {
2392
+ flexDirection: "row",
2393
+ flexWrap: "wrap",
2394
+ gap: 8,
2395
+ paddingTop: 4
2396
+ },
2397
+ chip: {
2398
+ borderWidth: 1,
2399
+ paddingHorizontal: 12,
2400
+ paddingVertical: 7
2401
+ },
2402
+ languageChip: { alignSelf: "flex-end", paddingHorizontal: 16, paddingBottom: 6 },
2403
+ voiceError: { paddingHorizontal: 16, paddingBottom: 6 },
2404
+ sheetBackdrop: { ...StyleSheet.absoluteFillObject, backgroundColor: "rgba(0,0,0,0.4)" },
2405
+ sheet: {
2406
+ position: "absolute",
2407
+ left: 16,
2408
+ right: 16,
2409
+ top: "18%",
2410
+ maxHeight: "64%",
2411
+ borderRadius: 16,
2412
+ borderWidth: StyleSheet.hairlineWidth,
2413
+ padding: 16
2414
+ },
2415
+ sheetTitle: { fontWeight: "700", marginBottom: 12 },
2416
+ sheetRow: { borderWidth: 1, borderRadius: 12, paddingVertical: 11, paddingHorizontal: 14, marginBottom: 8 },
2417
+ historyItem: { flexDirection: "row", alignItems: "center", gap: 10, paddingVertical: 10, paddingHorizontal: 8, borderRadius: 10 },
2418
+ mic: {
2419
+ width: 46,
2420
+ height: 46,
2421
+ borderRadius: 23,
2422
+ alignItems: "center",
2423
+ justifyContent: "center",
2424
+ borderWidth: StyleSheet.hairlineWidth
2425
+ }
2426
+ });
2427
+ export {
2428
+ DEFAULT_LANGUAGE_PICKER_LABELS as D,
2429
+ GuideAIChat as G,
2430
+ Markdown as M,
2431
+ DEFAULT_LIVE_VOICE_LABELS as a,
2432
+ GuideAILanguagePicker as b,
2433
+ GuideAILiveVoice as c,
2434
+ GuideAIWhiteboard as d,
2435
+ darkTheme as e,
2436
+ lightTheme as l,
2437
+ resolveTheme as r
2438
+ };
2439
+ //# sourceMappingURL=GuideAIChat-DLtQYk2N.js.map