@guideai/react-native 0.2.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui.mjs CHANGED
@@ -1,761 +1,9 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import React, { useRef, useState, useEffect, useCallback, useMemo, useContext, createContext } from "react";
3
- import { View, StyleSheet, Text, ScrollView, Linking, KeyboardAvoidingView, Pressable, Alert, FlatList, ActivityIndicator, TextInput, Platform, StatusBar, Animated, Easing, Dimensions, PanResponder, Modal } from "react-native";
4
- import { r as requireConfigured, b as useGuideAI, c as useOnboarding, E as EP } from "./useOnboarding-DAEGoYSs.js";
5
- function parseInline(text) {
6
- const spans = [];
7
- const pattern = /(`[^`]+`)|(\*\*[^*]+\*\*)|(__[^_]+__)|(\*[^*\n]+\*)|(_[^_\n]+_)|(\[[^\]]+\]\([^)]+\))/g;
8
- let cursor = 0;
9
- let match;
10
- while ((match = pattern.exec(text)) !== null) {
11
- if (match.index > cursor) {
12
- spans.push({ text: text.slice(cursor, match.index) });
13
- }
14
- const token = match[0];
15
- if (token.startsWith("`")) {
16
- spans.push({ text: token.slice(1, -1), code: true });
17
- } else if (token.startsWith("**") || token.startsWith("__")) {
18
- spans.push({ text: token.slice(2, -2), bold: true });
19
- } else if (token.startsWith("[")) {
20
- const split = token.indexOf("](");
21
- spans.push({
22
- text: token.slice(1, split),
23
- href: token.slice(split + 2, -1)
24
- });
25
- } else {
26
- spans.push({ text: token.slice(1, -1), italic: true });
27
- }
28
- cursor = match.index + token.length;
29
- }
30
- if (cursor < text.length) spans.push({ text: text.slice(cursor) });
31
- return spans.length ? spans : [{ text }];
32
- }
33
- function tableCells(line) {
34
- return line.replace(/^\s*\|/, "").replace(/\|\s*$/, "").split("|").map((cell) => parseInline(cell.trim()));
35
- }
36
- const TABLE_DIVIDER = /^\s*\|?[\s:-]*-[\s|:-]*\|?\s*$/;
37
- function parseMarkdown(source) {
38
- var _a, _b;
39
- const blocks = [];
40
- const lines = source.replace(/\r\n/g, "\n").split("\n");
41
- let index = 0;
42
- while (index < lines.length) {
43
- const line = lines[index];
44
- const trimmed = line.trim();
45
- if (!trimmed) {
46
- index += 1;
47
- continue;
48
- }
49
- const fence = /^```(\w+)?/.exec(trimmed);
50
- if (fence) {
51
- const language = fence[1];
52
- const body = [];
53
- index += 1;
54
- while (index < lines.length && !lines[index].trim().startsWith("```")) {
55
- body.push(lines[index]);
56
- index += 1;
57
- }
58
- index += 1;
59
- blocks.push({ type: "code", text: body.join("\n"), language });
60
- continue;
61
- }
62
- if (trimmed.includes("|") && index + 1 < lines.length && TABLE_DIVIDER.test(lines[index + 1])) {
63
- const header = tableCells(trimmed);
64
- const rows = [];
65
- index += 2;
66
- while (index < lines.length && lines[index].includes("|") && lines[index].trim()) {
67
- rows.push(tableCells(lines[index]));
68
- index += 1;
69
- }
70
- blocks.push({ type: "table", header, rows });
71
- continue;
72
- }
73
- const heading = /^(#{1,6})\s+(.*)$/.exec(trimmed);
74
- if (heading) {
75
- const level = Math.min(heading[1].length, 3);
76
- blocks.push({ type: "heading", level, spans: parseInline(heading[2]) });
77
- index += 1;
78
- continue;
79
- }
80
- if (/^(\*\s*){3,}$|^(-\s*){3,}$|^(_\s*){3,}$/.test(trimmed)) {
81
- blocks.push({ type: "rule" });
82
- index += 1;
83
- continue;
84
- }
85
- const quote = /^>\s?(.*)$/.exec(trimmed);
86
- if (quote) {
87
- blocks.push({ type: "quote", spans: parseInline(quote[1]) });
88
- index += 1;
89
- continue;
90
- }
91
- const indent = (_b = (_a = /^(\s*)/.exec(line)) == null ? void 0 : _a[1].length) != null ? _b : 0;
92
- const depth = Math.floor(indent / 2);
93
- const bullet = /^[-*+]\s+(.*)$/.exec(trimmed);
94
- if (bullet) {
95
- blocks.push({ type: "bullet", spans: parseInline(bullet[1]), depth });
96
- index += 1;
97
- continue;
98
- }
99
- const ordered = /^(\d+)[.)]\s+(.*)$/.exec(trimmed);
100
- if (ordered) {
101
- blocks.push({
102
- type: "ordered",
103
- spans: parseInline(ordered[2]),
104
- index: Number(ordered[1]),
105
- depth
106
- });
107
- index += 1;
108
- continue;
109
- }
110
- const paragraph = [trimmed];
111
- index += 1;
112
- while (index < lines.length) {
113
- const nextLine = lines[index].trim();
114
- if (!nextLine || /^(#{1,6})\s/.test(nextLine) || /^[-*+]\s/.test(nextLine) || /^\d+[.)]\s/.test(nextLine) || nextLine.startsWith("```") || nextLine.startsWith(">") || nextLine.includes("|")) break;
115
- paragraph.push(nextLine);
116
- index += 1;
117
- }
118
- blocks.push({ type: "paragraph", spans: parseInline(paragraph.join(" ")) });
119
- }
120
- return blocks;
121
- }
122
- function Spans({ spans, style, accentColor }) {
123
- return /* @__PURE__ */ jsx(Fragment, { children: spans.map((span, index) => {
124
- if (span.href) {
125
- return /* @__PURE__ */ jsx(
126
- Text,
127
- {
128
- style: [style, { color: accentColor, textDecorationLine: "underline" }],
129
- onPress: () => {
130
- void Linking.openURL(span.href);
131
- },
132
- accessibilityRole: "link",
133
- children: span.text
134
- },
135
- index
136
- );
137
- }
138
- return /* @__PURE__ */ jsx(
139
- Text,
140
- {
141
- style: [
142
- style,
143
- span.bold ? styles$3.bold : null,
144
- span.italic ? styles$3.italic : null,
145
- span.code ? styles$3.inlineCode : null
146
- ],
147
- children: span.text
148
- },
149
- index
150
- );
151
- }) });
152
- }
153
- function Markdown({
154
- children,
155
- color = "#0f172a",
156
- accentColor = "#2563eb",
157
- fontSize = 15
158
- }) {
159
- const blocks = React.useMemo(() => parseMarkdown(children), [children]);
160
- const body = { color, fontSize, lineHeight: fontSize * 1.45 };
161
- return /* @__PURE__ */ jsx(View, { style: styles$3.container, children: blocks.map((block, index) => /* @__PURE__ */ jsx(
162
- Block,
163
- {
164
- block,
165
- body,
166
- color,
167
- accentColor,
168
- fontSize
169
- },
170
- index
171
- )) });
172
- }
173
- function Block({ block, body, color, accentColor, fontSize }) {
174
- switch (block.type) {
175
- case "heading": {
176
- const sizes = { 1: fontSize + 6, 2: fontSize + 3, 3: fontSize + 1 };
177
- return /* @__PURE__ */ jsx(Text, { style: [styles$3.heading, { color, fontSize: sizes[block.level] }], children: /* @__PURE__ */ jsx(
178
- Spans,
179
- {
180
- spans: block.spans,
181
- accentColor,
182
- style: { color, fontSize: sizes[block.level], fontWeight: "700" }
183
- }
184
- ) });
185
- }
186
- case "paragraph":
187
- return /* @__PURE__ */ jsx(Text, { style: styles$3.paragraph, children: /* @__PURE__ */ jsx(Spans, { spans: block.spans, style: body, accentColor }) });
188
- case "bullet":
189
- return /* @__PURE__ */ jsxs(View, { style: [styles$3.listRow, { marginLeft: block.depth * 14 }], children: [
190
- /* @__PURE__ */ jsx(Text, { style: [body, { color: accentColor }], children: "•" }),
191
- /* @__PURE__ */ jsx(Text, { style: styles$3.listText, children: /* @__PURE__ */ jsx(Spans, { spans: block.spans, style: body, accentColor }) })
192
- ] });
193
- case "ordered":
194
- return /* @__PURE__ */ jsxs(View, { style: [styles$3.listRow, { marginLeft: block.depth * 14 }], children: [
195
- /* @__PURE__ */ jsxs(Text, { style: [body, { color: accentColor, fontVariant: ["tabular-nums"] }], children: [
196
- block.index,
197
- "."
198
- ] }),
199
- /* @__PURE__ */ jsx(Text, { style: styles$3.listText, children: /* @__PURE__ */ jsx(Spans, { spans: block.spans, style: body, accentColor }) })
200
- ] });
201
- case "code":
202
- return /* @__PURE__ */ jsx(View, { style: styles$3.codeBlock, children: /* @__PURE__ */ jsx(Text, { style: [styles$3.codeText, { fontSize: fontSize - 2 }], children: block.text }) });
203
- case "quote":
204
- return /* @__PURE__ */ jsx(View, { style: [styles$3.quote, { borderLeftColor: accentColor }], children: /* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx(
205
- Spans,
206
- {
207
- spans: block.spans,
208
- accentColor,
209
- style: { ...body, color: "#475569", fontStyle: "italic" }
210
- }
211
- ) }) });
212
- case "rule":
213
- return /* @__PURE__ */ jsx(View, { style: styles$3.rule });
214
- case "table": {
215
- const columns = Math.max(block.header.length, ...block.rows.map((r) => r.length), 1);
216
- const scrolls = columns > 3;
217
- const table = /* @__PURE__ */ jsxs(View, { style: [styles$3.table, scrolls ? { minWidth: columns * 116 } : null], children: [
218
- /* @__PURE__ */ jsx(View, { style: [styles$3.tableRow, styles$3.tableHeaderRow], children: block.header.map((cell, index) => /* @__PURE__ */ jsx(View, { style: styles$3.tableCell, children: /* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx(
219
- Spans,
220
- {
221
- spans: cell,
222
- accentColor,
223
- style: { ...body, fontWeight: "700", fontSize: fontSize - 1 }
224
- }
225
- ) }) }, index)) }),
226
- block.rows.map((row, rowIndex) => /* @__PURE__ */ jsx(View, { style: styles$3.tableRow, children: row.map((cell, cellIndex) => /* @__PURE__ */ jsx(View, { style: styles$3.tableCell, children: /* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx(
227
- Spans,
228
- {
229
- spans: cell,
230
- accentColor,
231
- style: { ...body, fontSize: fontSize - 1 }
232
- }
233
- ) }) }, cellIndex)) }, rowIndex))
234
- ] });
235
- return scrolls ? /* @__PURE__ */ jsx(
236
- ScrollView,
237
- {
238
- horizontal: true,
239
- showsHorizontalScrollIndicator: false,
240
- alwaysBounceHorizontal: false,
241
- children: table
242
- }
243
- ) : table;
244
- }
245
- default:
246
- return null;
247
- }
248
- }
249
- const mono = { fontFamily: "Menlo" };
250
- const styles$3 = StyleSheet.create({
251
- container: { gap: 6 },
252
- heading: { fontWeight: "700", marginTop: 4 },
253
- paragraph: {},
254
- listRow: { flexDirection: "row", gap: 8, alignItems: "flex-start" },
255
- listText: { flex: 1 },
256
- bold: { fontWeight: "700" },
257
- italic: { fontStyle: "italic" },
258
- inlineCode: {
259
- ...mono,
260
- backgroundColor: "rgba(100,116,139,0.14)",
261
- color: "#0f172a"
262
- },
263
- codeBlock: {
264
- backgroundColor: "#0f172a",
265
- borderRadius: 10,
266
- padding: 12,
267
- marginVertical: 2
268
- },
269
- codeText: { ...mono, color: "#e2e8f0" },
270
- quote: { borderLeftWidth: 3, paddingLeft: 10, paddingVertical: 2 },
271
- rule: { height: StyleSheet.hairlineWidth, backgroundColor: "#cbd5e1", marginVertical: 6 },
272
- table: {
273
- borderWidth: StyleSheet.hairlineWidth,
274
- borderColor: "#cbd5e1",
275
- borderRadius: 8,
276
- overflow: "hidden"
277
- },
278
- tableRow: {
279
- flexDirection: "row",
280
- borderBottomWidth: StyleSheet.hairlineWidth,
281
- borderBottomColor: "#e2e8f0"
282
- },
283
- tableHeaderRow: { backgroundColor: "rgba(100,116,139,0.10)" },
284
- tableCell: { flex: 1, padding: 8 }
285
- });
286
- const darkTheme = {
287
- background: "#0B0713",
288
- surface: "rgba(255,255,255,0.06)",
289
- surfaceRaised: "#1C1626",
290
- text: "#F5F3FF",
291
- textMuted: "#8B85A0",
292
- accent: "#7C5CFF",
293
- onAccent: "#FFFFFF",
294
- userBubble: "#7C5CFF",
295
- onUserBubble: "#FFFFFF",
296
- error: "rgba(248,113,113,0.16)",
297
- border: "rgba(255,255,255,0.10)",
298
- radius: 22,
299
- fontSize: 15
300
- };
301
- const lightTheme = {
302
- background: "#FFFFFF",
303
- surface: "#F1F5F9",
304
- surfaceRaised: "#FFFFFF",
305
- text: "#0F172A",
306
- textMuted: "#64748B",
307
- accent: "#7C5CFF",
308
- onAccent: "#FFFFFF",
309
- userBubble: "#7C5CFF",
310
- onUserBubble: "#FFFFFF",
311
- error: "#FEE2E2",
312
- border: "#E2E8F0",
313
- radius: 22,
314
- fontSize: 15
315
- };
316
- function resolveTheme(overrides, base = lightTheme) {
317
- return overrides ? { ...base, ...overrides } : base;
318
- }
319
- function PersonIcon({ color }) {
320
- return /* @__PURE__ */ jsxs(View, { style: styles$2.iconWrap, children: [
321
- /* @__PURE__ */ jsx(View, { style: [styles$2.iconBand, { borderColor: color }] }),
322
- /* @__PURE__ */ jsx(View, { style: [styles$2.iconCup, styles$2.iconCupLeft, { backgroundColor: color }] }),
323
- /* @__PURE__ */ jsx(View, { style: [styles$2.iconCup, styles$2.iconCupRight, { backgroundColor: color }] })
324
- ] });
325
- }
326
- function Orb({ theme, active }) {
327
- const pulse = useRef(new Animated.Value(0)).current;
328
- React.useEffect(() => {
329
- if (!active) {
330
- pulse.stopAnimation();
331
- Animated.timing(pulse, { toValue: 0, duration: 240, useNativeDriver: true }).start();
332
- return;
333
- }
334
- const loop = Animated.loop(
335
- Animated.sequence([
336
- Animated.timing(pulse, {
337
- toValue: 1,
338
- duration: 900,
339
- easing: Easing.inOut(Easing.quad),
340
- useNativeDriver: true
341
- }),
342
- Animated.timing(pulse, {
343
- toValue: 0,
344
- duration: 900,
345
- easing: Easing.inOut(Easing.quad),
346
- useNativeDriver: true
347
- })
348
- ])
349
- );
350
- loop.start();
351
- return () => loop.stop();
352
- }, [active, pulse]);
353
- const scale = pulse.interpolate({ inputRange: [0, 1], outputRange: [1, 1.18] });
354
- const glow = pulse.interpolate({ inputRange: [0, 1], outputRange: [0.35, 0.7] });
355
- return /* @__PURE__ */ jsxs(View, { style: styles$2.orbWrap, children: [
356
- /* @__PURE__ */ jsx(
357
- Animated.View,
358
- {
359
- style: [
360
- styles$2.orbGlow,
361
- { backgroundColor: theme.accent, opacity: glow, transform: [{ scale }] }
362
- ]
363
- }
364
- ),
365
- /* @__PURE__ */ jsx(View, { style: [styles$2.orbCore, { backgroundColor: theme.accent }] })
366
- ] });
367
- }
368
- function Bubble$1({ message, theme, onTalkToHuman }) {
369
- if (message.role === "user") {
370
- return /* @__PURE__ */ jsx(View, { style: [styles$2.row, styles$2.rowUser], children: /* @__PURE__ */ jsx(View, { style: [
371
- styles$2.bubble,
372
- { backgroundColor: theme.userBubble, borderRadius: theme.radius },
373
- message.error ? { backgroundColor: theme.error } : null
374
- ], children: /* @__PURE__ */ jsx(Text, { style: {
375
- color: theme.onUserBubble,
376
- fontSize: theme.fontSize,
377
- lineHeight: theme.fontSize * 1.4
378
- }, children: message.content }) }) });
379
- }
380
- return /* @__PURE__ */ jsx(View, { style: [styles$2.row, styles$2.rowAssistant], children: /* @__PURE__ */ jsxs(View, { style: [
381
- styles$2.assistantBody,
382
- message.error ? { backgroundColor: theme.error, borderRadius: theme.radius, padding: 12 } : null
383
- ], children: [
384
- message.content ? /* @__PURE__ */ jsx(Markdown, { color: theme.text, accentColor: theme.accent, fontSize: theme.fontSize, children: message.content }) : (
385
- // A streaming message with no text yet would be an empty box.
386
- /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize }, children: message.streaming ? "…" : "" })
387
- ),
388
- message.error && onTalkToHuman ? /* @__PURE__ */ jsxs(
389
- Pressable,
390
- {
391
- onPress: onTalkToHuman,
392
- accessibilityRole: "button",
393
- accessibilityLabel: "Talk to a person",
394
- style: [styles$2.errorAction, { borderColor: theme.accent }],
395
- hitSlop: 6,
396
- children: [
397
- /* @__PURE__ */ jsx(PersonIcon, { color: theme.accent }),
398
- /* @__PURE__ */ jsx(Text, { style: [styles$2.humanText, {
399
- color: theme.accent,
400
- fontSize: theme.fontSize - 1
401
- }], children: "Talk to a human" })
402
- ]
403
- }
404
- ) : null
405
- ] }) });
406
- }
407
- function resolveTopInset(explicit) {
408
- var _a;
409
- if (explicit !== void 0) return explicit;
410
- if (Platform.OS === "android") return (_a = StatusBar.currentHeight) != null ? _a : 24;
411
- return 8;
412
- }
413
- function useHumanHandover(onTalkToHuman, available) {
414
- const [reachable, setReachable] = useState(false);
415
- useEffect(() => {
416
- if (!onTalkToHuman || available !== void 0) return;
417
- let cancelled = false;
418
- void (async () => {
419
- try {
420
- const { api } = requireConfigured();
421
- const status = await api.get(
422
- EP.supportStatus()
423
- );
424
- if (!cancelled) setReachable(!!(status == null ? void 0 : status.enabled));
425
- } catch {
426
- }
427
- })();
428
- return () => {
429
- cancelled = true;
430
- };
431
- }, [onTalkToHuman, available]);
432
- if (!onTalkToHuman) return false;
433
- return available != null ? available : reachable;
434
- }
435
- function GuideAIChat({
436
- theme: overrides,
437
- placeholder = "Ask me anything",
438
- greeting = "Ask me anything",
439
- emptyState,
440
- showMic = false,
441
- leadingAccessory,
442
- title,
443
- onClose,
444
- onTalkToHuman,
445
- humanHandoverAvailable,
446
- topInset
447
- }) {
448
- const { harness, debug } = requireConfigured();
449
- const {
450
- messages,
451
- input,
452
- setInput,
453
- send,
454
- busy,
455
- canSend,
456
- status
457
- } = useGuideAI({ harness, trace: debug });
458
- const theme = resolveTheme(overrides);
459
- const listRef = useRef(null);
460
- const showHuman = useHumanHandover(onTalkToHuman, humanHandoverAvailable);
461
- const { checklist, dismiss } = useOnboarding();
462
- const nextSetupStep = checklist == null ? void 0 : checklist.steps.find((step) => step.state === "available");
463
- const headerTop = resolveTopInset(topInset);
464
- const submit = () => {
465
- void send();
466
- };
467
- return /* @__PURE__ */ jsxs(
468
- KeyboardAvoidingView,
469
- {
470
- style: [styles$2.container, { backgroundColor: theme.background }],
471
- behavior: Platform.OS === "ios" ? "padding" : void 0,
472
- children: [
473
- title || onClose || showHuman ? /* @__PURE__ */ jsxs(View, { style: [
474
- styles$2.header,
475
- { borderBottomColor: theme.border, paddingTop: headerTop + 14 }
476
- ], children: [
477
- /* @__PURE__ */ jsx(View, { style: styles$2.headerSide, children: title ? /* @__PURE__ */ jsx(
478
- Text,
479
- {
480
- numberOfLines: 1,
481
- style: [styles$2.title, { color: theme.text, fontSize: theme.fontSize + 1 }],
482
- children: title
483
- }
484
- ) : null }),
485
- /* @__PURE__ */ jsxs(View, { style: styles$2.headerActions, children: [
486
- showHuman ? /* @__PURE__ */ jsxs(
487
- Pressable,
488
- {
489
- onPress: onTalkToHuman,
490
- accessibilityRole: "button",
491
- accessibilityLabel: "Talk to a person",
492
- style: [styles$2.human, {
493
- backgroundColor: theme.surface,
494
- borderColor: theme.border
495
- }],
496
- hitSlop: 8,
497
- children: [
498
- /* @__PURE__ */ jsx(PersonIcon, { color: theme.accent }),
499
- /* @__PURE__ */ jsx(Text, { style: [styles$2.humanText, {
500
- color: theme.accent,
501
- fontSize: theme.fontSize - 2
502
- }], children: "Talk to human" })
503
- ]
504
- }
505
- ) : null,
506
- onClose ? /* @__PURE__ */ jsx(
507
- Pressable,
508
- {
509
- onPress: onClose,
510
- accessibilityRole: "button",
511
- accessibilityLabel: "Close assistant",
512
- style: [styles$2.close, { backgroundColor: theme.surface }],
513
- hitSlop: 10,
514
- children: /* @__PURE__ */ jsx(Text, { style: [styles$2.closeIcon, { color: theme.text }], children: "✕" })
515
- }
516
- ) : null
517
- ] })
518
- ] }) : null,
519
- checklist && !checklist.completed && !checklist.dismissed ? /* @__PURE__ */ jsxs(View, { style: { margin: 14, padding: 14, borderRadius: 12, borderWidth: 1, borderColor: theme.border, backgroundColor: theme.surface }, accessibilityLabel: "Setup checklist", children: [
520
- /* @__PURE__ */ jsx(Text, { style: { color: theme.text, fontWeight: "700", fontSize: theme.fontSize + 2 }, children: checklist.title }),
521
- /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, marginTop: 3 }, children: checklist.goal }),
522
- /* @__PURE__ */ jsxs(Text, { style: { color: theme.textMuted, marginTop: 8 }, children: [
523
- checklist.completed_required,
524
- " of ",
525
- checklist.total_required,
526
- " required steps complete"
527
- ] }),
528
- checklist.steps.map((step) => /* @__PURE__ */ jsxs(Text, { style: { color: step.state === "locked" ? theme.textMuted : theme.text, marginTop: 5 }, children: [
529
- step.state === "complete" ? "✓" : step.state === "locked" ? "–" : "○",
530
- " ",
531
- step.title
532
- ] }, step.id)),
533
- nextSetupStep ? /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: `Help with ${nextSetupStep.title}`, onPress: () => void send(`Help me with ${nextSetupStep.title}`), style: { alignSelf: "flex-start", marginTop: 10, padding: 10, borderRadius: 8, backgroundColor: theme.accent }, children: /* @__PURE__ */ jsx(Text, { style: { color: theme.onAccent, fontWeight: "600" }, children: "Continue setup" }) }) : null,
534
- checklist.allow_dismissal ? /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "I don't need this setup", onPress: () => Alert.alert("Stop showing setup?", "This checklist will not appear again on future visits.", [
535
- { text: "Keep setup", style: "cancel" },
536
- { text: "I don't need it", onPress: () => {
537
- void dismiss().catch(() => Alert.alert("Could not dismiss setup", "Please try again."));
538
- } }
539
- ]), style: { alignSelf: "flex-start", marginTop: 10, padding: 10 }, children: /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, textDecorationLine: "underline" }, children: "I don't need this setup" }) }) : null
540
- ] }) : null,
541
- messages.length === 0 ? /* @__PURE__ */ jsx(View, { style: styles$2.empty, children: emptyState != null ? emptyState : /* @__PURE__ */ jsxs(View, { style: styles$2.greetingRow, children: [
542
- /* @__PURE__ */ jsx(Orb, { theme, active: busy }),
543
- /* @__PURE__ */ jsx(Text, { style: [
544
- styles$2.greeting,
545
- { color: theme.textMuted, fontSize: theme.fontSize + 3 }
546
- ], children: greeting })
547
- ] }) }) : /* @__PURE__ */ jsx(
548
- FlatList,
549
- {
550
- ref: listRef,
551
- data: messages,
552
- keyExtractor: (message) => message.id,
553
- renderItem: ({ item }) => /* @__PURE__ */ jsx(Bubble$1, { message: item, theme, onTalkToHuman }),
554
- contentContainerStyle: styles$2.list,
555
- onContentSizeChange: () => {
556
- var _a;
557
- return (_a = listRef.current) == null ? void 0 : _a.scrollToEnd({ animated: true });
558
- },
559
- keyboardShouldPersistTaps: "handled"
560
- }
561
- ),
562
- status ? /* @__PURE__ */ jsxs(View, { style: styles$2.status, children: [
563
- /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: theme.accent }),
564
- /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize - 2 }, children: status })
565
- ] }) : null,
566
- /* @__PURE__ */ jsxs(View, { style: styles$2.composerRow, children: [
567
- /* @__PURE__ */ jsxs(View, { style: [
568
- styles$2.composer,
569
- {
570
- backgroundColor: theme.surface,
571
- borderRadius: theme.radius + 6,
572
- borderColor: theme.border
573
- }
574
- ], children: [
575
- leadingAccessory ? /* @__PURE__ */ jsx(View, { style: styles$2.leading, children: leadingAccessory }) : null,
576
- /* @__PURE__ */ jsx(
577
- TextInput,
578
- {
579
- style: [styles$2.input, { color: theme.text, fontSize: theme.fontSize }],
580
- value: input,
581
- onChangeText: setInput,
582
- placeholder: checklist && !checklist.completed && checklist.chat_policy === "setup_only" ? "Ask about your setup" : placeholder,
583
- placeholderTextColor: theme.textMuted,
584
- editable: !busy,
585
- onSubmitEditing: submit,
586
- returnKeyType: "send",
587
- multiline: true,
588
- accessibilityLabel: placeholder
589
- }
590
- ),
591
- /* @__PURE__ */ jsx(
592
- Pressable,
593
- {
594
- onPress: submit,
595
- disabled: !canSend,
596
- accessibilityRole: "button",
597
- accessibilityLabel: "Send",
598
- style: [styles$2.send, { backgroundColor: canSend ? theme.accent : theme.border }],
599
- hitSlop: 6,
600
- children: /* @__PURE__ */ jsx(Text, { style: [
601
- styles$2.sendIcon,
602
- { color: canSend ? theme.onAccent : theme.textMuted }
603
- ], children: "↑" })
604
- }
605
- )
606
- ] }),
607
- showMic ? /* @__PURE__ */ jsx(
608
- Pressable,
609
- {
610
- accessibilityRole: "button",
611
- accessibilityLabel: "Voice input",
612
- style: [styles$2.mic, { backgroundColor: theme.surface, borderColor: theme.border }],
613
- children: /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, fontSize: 18 }, children: "🎤" })
614
- }
615
- ) : null
616
- ] })
617
- ]
618
- }
619
- );
620
- }
621
- const styles$2 = StyleSheet.create({
622
- container: { flex: 1 },
623
- header: {
624
- flexDirection: "row",
625
- alignItems: "center",
626
- justifyContent: "space-between",
627
- // paddingTop is set inline from the status-bar inset; only the
628
- // bottom half of the navbar's breathing room lives here.
629
- paddingHorizontal: 16,
630
- paddingBottom: 14,
631
- borderBottomWidth: StyleSheet.hairlineWidth
632
- },
633
- headerSide: { flex: 1, minWidth: 0 },
634
- headerActions: { flexDirection: "row", alignItems: "center", gap: 8 },
635
- title: { fontWeight: "600" },
636
- human: {
637
- flexDirection: "row",
638
- alignItems: "center",
639
- gap: 6,
640
- paddingHorizontal: 10,
641
- paddingVertical: 6,
642
- borderRadius: 999,
643
- borderWidth: StyleSheet.hairlineWidth
644
- },
645
- humanText: { fontWeight: "600" },
646
- errorAction: {
647
- flexDirection: "row",
648
- alignItems: "center",
649
- gap: 6,
650
- alignSelf: "flex-start",
651
- marginTop: 10,
652
- paddingHorizontal: 12,
653
- paddingVertical: 7,
654
- borderRadius: 999,
655
- borderWidth: StyleSheet.hairlineWidth
656
- },
657
- iconWrap: { width: 14, height: 14, alignItems: "center", justifyContent: "center" },
658
- iconBand: {
659
- position: "absolute",
660
- top: 1,
661
- width: 12,
662
- height: 9,
663
- borderWidth: 1.6,
664
- borderBottomWidth: 0,
665
- borderTopLeftRadius: 6,
666
- borderTopRightRadius: 6
667
- },
668
- iconCup: { position: "absolute", bottom: 1, width: 3.5, height: 6, borderRadius: 1.5 },
669
- iconCupLeft: { left: 0 },
670
- iconCupRight: { right: 0 },
671
- close: {
672
- width: 32,
673
- height: 32,
674
- borderRadius: 16,
675
- alignItems: "center",
676
- justifyContent: "center"
677
- },
678
- closeIcon: { fontSize: 15, fontWeight: "600", lineHeight: 18 },
679
- list: { padding: 16, paddingBottom: 8, gap: 14 },
680
- empty: {
681
- // Centred, not pinned near the top: before the first message the
682
- // greeting is the only thing on screen, and hanging it under the
683
- // navbar leaves the rest of the display empty.
684
- flex: 1,
685
- alignItems: "center",
686
- justifyContent: "center",
687
- paddingHorizontal: 24,
688
- paddingBottom: 24
689
- },
690
- greetingRow: { flexDirection: "row", alignItems: "center", gap: 14 },
691
- greeting: { fontWeight: "400", textAlign: "center", flexShrink: 1 },
692
- orbWrap: { width: 34, height: 34, alignItems: "center", justifyContent: "center" },
693
- orbGlow: { position: "absolute", width: 34, height: 34, borderRadius: 17 },
694
- orbCore: { width: 20, height: 20, borderRadius: 10 },
695
- row: { flexDirection: "row" },
696
- rowUser: { justifyContent: "flex-end" },
697
- rowAssistant: { justifyContent: "flex-start" },
698
- // The user's bubble hugs its text: a three-word question drawn as a
699
- // full-width block reads as a paragraph, not a chat message. It is
700
- // capped at 80% so a long one still leaves the reply side legible.
701
- bubble: { maxWidth: "80%", paddingHorizontal: 16, paddingVertical: 11 },
702
- // The assistant's body does NOT hug its content, and that is the whole
703
- // point of `width` here rather than `maxWidth` alone.
704
- //
705
- // A View with only maxWidth shrink-wraps — React Native's equivalent of
706
- // width: fit-content. For a paragraph that looks fine, because the text
707
- // fills the measure anyway. For anything that lays itself out against
708
- // its parent — a table whose cells are `flex: 1`, a fenced code block,
709
- // a numbered list — the parent has collapsed to nothing by the time the
710
- // child is measured, so the table renders as an empty sliver and every
711
- // reply ends up a different width.
712
- //
713
- // Fixing it here rather than on the table keeps every block type
714
- // consistent: one column, the same measure for prose, code and tables.
715
- assistantBody: { width: "80%" },
716
- status: {
717
- flexDirection: "row",
718
- alignItems: "center",
719
- gap: 8,
720
- paddingHorizontal: 22,
721
- paddingBottom: 8
722
- },
723
- composerRow: {
724
- flexDirection: "row",
725
- alignItems: "flex-end",
726
- gap: 10,
727
- paddingHorizontal: 14,
728
- paddingBottom: Platform.OS === "ios" ? 10 : 14,
729
- paddingTop: 4
730
- },
731
- composer: {
732
- flex: 1,
733
- flexDirection: "row",
734
- alignItems: "center",
735
- paddingLeft: 8,
736
- paddingRight: 6,
737
- paddingVertical: 6,
738
- borderWidth: StyleSheet.hairlineWidth,
739
- gap: 6
740
- },
741
- leading: { paddingLeft: 4 },
742
- input: {
743
- flex: 1,
744
- paddingHorizontal: 8,
745
- paddingVertical: Platform.OS === "ios" ? 8 : 4,
746
- maxHeight: 120
747
- },
748
- send: { width: 34, height: 34, borderRadius: 17, alignItems: "center", justifyContent: "center" },
749
- sendIcon: { fontSize: 17, fontWeight: "700", lineHeight: 20 },
750
- mic: {
751
- width: 46,
752
- height: 46,
753
- borderRadius: 23,
754
- alignItems: "center",
755
- justifyContent: "center",
756
- borderWidth: StyleSheet.hairlineWidth
757
- }
758
- });
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { useState, useRef, useEffect, useCallback, useMemo, useContext, createContext } from "react";
3
+ import { Platform, StatusBar, KeyboardAvoidingView, View, Text, Pressable, ScrollView, TextInput, ActivityIndicator, FlatList, StyleSheet, Dimensions, Animated, PanResponder, Modal, Easing } from "react-native";
4
+ import { r as resolveTheme, G as GuideAIChat } from "./GuideAIChat-DLtQYk2N.js";
5
+ import { D, a, b, c, d, M, e, l } from "./GuideAIChat-DLtQYk2N.js";
6
+ import { r as requireConfigured, E as EP, d as useOnboarding } from "./useConversations-B4WYG2Qz.js";
759
7
  const POLL_INTERVAL_MS = 3e3;
760
8
  const CONVERSATION_KEY = "guideai_support_conversation";
761
9
  function useStoredConversation() {
@@ -1512,13 +760,18 @@ const styles = StyleSheet.create({
1512
760
  nudgeText: { lineHeight: 19 }
1513
761
  });
1514
762
  export {
763
+ D as DEFAULT_LANGUAGE_PICKER_LABELS,
764
+ a as DEFAULT_LIVE_VOICE_LABELS,
1515
765
  GuideAIButton,
1516
766
  GuideAIChat,
767
+ b as GuideAILanguagePicker,
1517
768
  GuideAILauncher,
769
+ c as GuideAILiveVoice,
1518
770
  GuideAISupportChat,
1519
- Markdown,
1520
- darkTheme,
1521
- lightTheme,
771
+ d as GuideAIWhiteboard,
772
+ M as Markdown,
773
+ e as darkTheme,
774
+ l as lightTheme,
1522
775
  resolveTheme,
1523
776
  useGuideAISheet
1524
777
  };