@guideai/react-native 0.9.0 → 0.10.0

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