@vinaverse/react-native 0.1.0-alpha.10 → 0.1.0-alpha.12

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.
@@ -1,14 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  var chunk6QYDPGRS_cjs = require('./chunk-6QYDPGRS.cjs');
4
- var agent = require('@vinaverse/react/agent');
5
- var flashList = require('@shopify/flash-list');
6
- var react$1 = require('@vinaverse/react');
7
- var reactNative = require('react-native');
8
- var agent$1 = require('@vinaverse/client/agent');
9
4
  var react = require('react');
10
5
  var jsxRuntime = require('react/jsx-runtime');
6
+ var reactNative = require('react-native');
7
+ var react$1 = require('@vinaverse/react');
11
8
  var conversation = require('@vinaverse/client/conversation');
9
+ var agent = require('@vinaverse/client/agent');
10
+ var flashList = require('@shopify/flash-list');
12
11
  var tokens = require('@vinaverse/tokens');
13
12
 
14
13
  var ChatContext = /* @__PURE__ */ react.createContext(
@@ -1325,7 +1324,7 @@ var CardView = /* @__PURE__ */ react.memo(function CardView2(props) {
1325
1324
  const { card, busy } = props.item;
1326
1325
  const Default = defaultCard(card.kind);
1327
1326
  const Custom = slots.cards?.[card.kind];
1328
- const read = react.useMemo(() => agent$1.readCard(card.card), [card]);
1327
+ const read = react.useMemo(() => agent.readCard(card.card), [card]);
1329
1328
  const own = {
1330
1329
  card,
1331
1330
  read,
@@ -1498,106 +1497,6 @@ var ChatHeader = /* @__PURE__ */ react.memo(function ChatHeader2() {
1498
1497
  };
1499
1498
  return Header ? /* @__PURE__ */ jsxRuntime.jsx(Header, { ...props, Default: DefaultHeader }) : /* @__PURE__ */ jsxRuntime.jsx(DefaultHeader, { ...props });
1500
1499
  });
1501
- function DefaultComposer(props) {
1502
- const { t, direction } = react$1.useCopy();
1503
- const { colors, radius, space, font, size: size2 } = chunk6QYDPGRS_cjs.useTheme();
1504
- const [text, setText] = react.useState("");
1505
- const length = conversation.codePoints(text);
1506
- const canSend = text.trim().length > 0 && length <= conversation.MAX_TEXT;
1507
- const send = () => {
1508
- if (!canSend) return;
1509
- props.onSend(text);
1510
- setText("");
1511
- };
1512
- return /* @__PURE__ */ jsxRuntime.jsxs(
1513
- reactNative.View,
1514
- {
1515
- style: {
1516
- flexDirection: "row",
1517
- alignItems: "flex-end",
1518
- gap: space.sm,
1519
- paddingHorizontal: space.lg,
1520
- paddingVertical: space.sm,
1521
- borderTopWidth: 1,
1522
- borderTopColor: colors.divider,
1523
- backgroundColor: colors.background
1524
- },
1525
- children: [
1526
- /* @__PURE__ */ jsxRuntime.jsx(
1527
- reactNative.TextInput,
1528
- {
1529
- value: text,
1530
- onChangeText: setText,
1531
- placeholder: props.placeholder,
1532
- placeholderTextColor: colors.textMuted,
1533
- accessibilityLabel: props.placeholder,
1534
- multiline: true,
1535
- maxLength: conversation.MAX_TEXT * 2,
1536
- testID: "vinaverse-composer-input",
1537
- style: {
1538
- flex: 1,
1539
- minHeight: size2.touchTarget,
1540
- maxHeight: 140,
1541
- paddingHorizontal: space.md,
1542
- paddingVertical: space.sm,
1543
- borderRadius: radius.lg,
1544
- borderWidth: 1,
1545
- borderColor: colors.border,
1546
- color: colors.text,
1547
- backgroundColor: colors.surface,
1548
- fontSize: font.size.md,
1549
- textAlign: direction === "rtl" ? "right" : "left",
1550
- writingDirection: direction,
1551
- ...font.family ? { fontFamily: font.family } : {}
1552
- }
1553
- }
1554
- ),
1555
- props.responding && !text ? /* @__PURE__ */ jsxRuntime.jsx(
1556
- Button,
1557
- {
1558
- label: t("stop"),
1559
- onPress: props.onStop,
1560
- testID: "vinaverse-stop"
1561
- }
1562
- ) : /* @__PURE__ */ jsxRuntime.jsx(
1563
- Button,
1564
- {
1565
- label: t("send"),
1566
- variant: "primary",
1567
- disabled: !canSend,
1568
- onPress: send,
1569
- testID: "vinaverse-send"
1570
- }
1571
- )
1572
- ]
1573
- }
1574
- );
1575
- }
1576
- var Composer = /* @__PURE__ */ react.memo(function Composer2(props) {
1577
- const { store, slots } = useChat();
1578
- const { t } = react$1.useCopy();
1579
- const takeover = react$1.useConversationSelector(store, (v) => v.takeover);
1580
- const name = react$1.useConversationSelector(store, (v) => v.agent.name);
1581
- const responding = react$1.useConversationSelector(store, (v) => v.responding);
1582
- const { onError } = props;
1583
- const onSend = react.useCallback(
1584
- (text) => {
1585
- try {
1586
- store.send(text);
1587
- } catch (error) {
1588
- onError?.(error);
1589
- }
1590
- },
1591
- [store, onError]
1592
- );
1593
- const onStop = react.useCallback(() => store.cancel(), [store]);
1594
- const placeholder = takeover ? t("composerPlaceholderTakeover", {
1595
- by: takeover.by || t("staffFallbackRole")
1596
- }) : t("composerPlaceholder", { agent: name ?? t("agentFallbackName") });
1597
- const Slot = slots.Composer;
1598
- const own = { placeholder, responding, onSend, onStop };
1599
- return Slot ? /* @__PURE__ */ jsxRuntime.jsx(Slot, { ...own, Default: DefaultComposer }) : /* @__PURE__ */ jsxRuntime.jsx(DefaultComposer, { ...own });
1600
- });
1601
1500
  var DisclosureBar = /* @__PURE__ */ react.memo(function DisclosureBar2() {
1602
1501
  const { store } = useChat();
1603
1502
  const { t } = react$1.useCopy();
@@ -1729,7 +1628,7 @@ function Frame(props) {
1729
1628
  const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
1730
1629
  const author = useAuthor(item);
1731
1630
  const mine = item.role === "person";
1732
- const status = item.state === "sending" ? t("messageSending") : item.state === "held" ? t("messageHeld") : item.state === "not_sent" ? item.rejection?.message || t("messageNotSent") : item.state === "delivered" ? t("messageDelivered") : item.partial ? t("messageCutOff") : null;
1631
+ const status = item.state === "sending" ? t("messageSending") : item.state === "held" ? t("messageHeld") : item.state === "not_sent" ? item.rejection?.message || t("messageNotSent") : item.state === "delivered" ? t("messageDelivered") : item.partial ? t("messageCutOff") : item.refusal && mine ? t("messageRefused") : null;
1733
1632
  const Bubble = slots.MessageBubble;
1734
1633
  const bubble = Bubble ? /* @__PURE__ */ jsxRuntime.jsx(Bubble, { item, text, Default: DefaultBubble }) : /* @__PURE__ */ jsxRuntime.jsx(DefaultBubble, { item, text });
1735
1634
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1742,7 +1641,7 @@ function Frame(props) {
1742
1641
  maxWidth: "85%",
1743
1642
  marginHorizontal: space.lg,
1744
1643
  marginTop: props.showAuthor ? space.md : space.xs,
1745
- opacity: item.state === "sending" || item.state === "held" ? 0.75 : 1
1644
+ opacity: item.state === "sending" || item.state === "held" || item.refusal ? 0.75 : 1
1746
1645
  },
1747
1646
  children: [
1748
1647
  props.showAuthor && !mine ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -2093,582 +1992,23 @@ function useAnnounceReplies(items) {
2093
1992
  (handlers.current?.announce ?? chunk6QYDPGRS_cjs.announce)(`${author}: ${last.text}`);
2094
1993
  }, [items, t, store, handlers]);
2095
1994
  }
2096
- var CONNECTING_DELAY = tokens.motion.bannerDelay;
2097
- var StatusBanner = /* @__PURE__ */ react.memo(function StatusBanner2() {
2098
- const { store, slots } = useChat();
2099
- const { t } = react$1.useCopy();
2100
- const banner = react$1.useConversationSelector(store, (v) => v.banner);
2101
- const status = react$1.useConversationSelector(store, (v) => v.status);
2102
- const conversationId = react$1.useConversationSelector(
2103
- store,
2104
- (v) => v.conversationId
2105
- );
2106
- const unavailable = react.useMemo(
2107
- () => ({
2108
- kind: "unavailable",
2109
- reason: status,
2110
- retry: () => store.start(),
2111
- conversationId
2112
- }),
2113
- [store, status, conversationId]
2114
- );
2115
- const [late, setLate] = react.useState(false);
2116
- react.useEffect(() => {
2117
- setLate(false);
2118
- if (banner !== "connecting") return;
2119
- const timer = setTimeout(() => setLate(true), CONNECTING_DELAY);
2120
- return () => clearTimeout(timer);
2121
- }, [banner]);
2122
- if (banner === null || banner === "connecting" && !late) return null;
2123
- if (banner === "unavailable")
2124
- return /* @__PURE__ */ jsxRuntime.jsx(
2125
- FailureSlot,
2126
- {
2127
- slot: slots.Unavailable,
2128
- state: unavailable,
2129
- Default: DefaultUnavailable
2130
- }
2131
- );
2132
- const text = {
2133
- connecting: t("bannerConnecting"),
2134
- reconnecting: t("bannerReconnecting"),
2135
- offline: t("bannerOffline"),
2136
- continued_elsewhere: t("bannerContinuedElsewhere")
2137
- }[banner];
2138
- const action = banner === "continued_elsewhere" ? /* @__PURE__ */ jsxRuntime.jsx(
2139
- Button,
2140
- {
2141
- label: t("continueHere"),
2142
- variant: "text",
2143
- onPress: () => void store.continueHere()
2144
- }
2145
- ) : banner === "offline" ? /* @__PURE__ */ jsxRuntime.jsx(
2146
- Button,
2147
- {
2148
- label: t("tryAgain"),
2149
- variant: "text",
2150
- onPress: () => store.start()
2151
- }
2152
- ) : null;
2153
- return /* @__PURE__ */ jsxRuntime.jsx(Banner, { text, children: action });
2154
- });
2155
- function DefaultUnavailable(props) {
2156
- const { t } = react$1.useCopy();
2157
- const { retry } = props.state;
2158
- return /* @__PURE__ */ jsxRuntime.jsxs(Banner, { text: t("bannerUnavailable"), children: [
2159
- retry ? /* @__PURE__ */ jsxRuntime.jsx(Button, { label: t("tryAgain"), variant: "text", onPress: retry }) : null,
2160
- /* @__PURE__ */ jsxRuntime.jsx(FailureActionButton, { state: props.state })
2161
- ] });
2162
- }
2163
- function Banner(props) {
2164
- const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
2165
- return /* @__PURE__ */ jsxRuntime.jsxs(
2166
- reactNative.View,
2167
- {
2168
- accessibilityLiveRegion: "polite",
2169
- accessibilityRole: "alert",
2170
- style: {
2171
- flexDirection: "row",
2172
- alignItems: "center",
2173
- justifyContent: "space-between",
2174
- gap: space.sm,
2175
- paddingHorizontal: space.lg,
2176
- paddingVertical: space.xs,
2177
- backgroundColor: colors.surface,
2178
- borderBottomWidth: 1,
2179
- borderBottomColor: colors.divider
2180
- },
2181
- children: [
2182
- /* @__PURE__ */ jsxRuntime.jsx(
2183
- reactNative.Text,
2184
- {
2185
- style: { color: colors.text, fontSize: font.size.sm, flexShrink: 1 },
2186
- children: props.text
2187
- }
2188
- ),
2189
- props.children
2190
- ]
2191
- }
2192
- );
2193
- }
2194
- function VinaverseChatProvider(props) {
2195
- const {
2196
- conversation,
2197
- components,
2198
- agentAvatar,
2199
- timeZone,
2200
- starters,
2201
- imagePolicy
2202
- } = props;
2203
- const handlers = react.useRef(props);
2204
- handlers.current = props;
2205
- const slots = useStableSlots(components);
2206
- const hasAction = props.failureAction !== void 0;
2207
- const actionLabel = props.failureAction?.label;
2208
- const failureAction = react.useMemo(
2209
- () => hasAction ? { label: actionLabel } : null,
2210
- [hasAction, actionLabel]
2211
- );
2212
- const value = react.useMemo(
2213
- () => ({
2214
- store: conversation,
2215
- handlers,
2216
- slots,
2217
- agentAvatar,
2218
- timeZone,
2219
- failureAction,
2220
- starters,
2221
- imagePolicy
2222
- }),
2223
- [
2224
- conversation,
2225
- slots,
2226
- agentAvatar,
2227
- timeZone,
2228
- failureAction,
2229
- starters,
2230
- imagePolicy
2231
- ]
2232
- );
2233
- chunk6QYDPGRS_cjs.useNativeLifecycle(conversation);
2234
- react.useEffect(() => {
2235
- conversation.start();
2236
- }, [conversation]);
2237
- const { onWarning, theme, copy } = props;
2238
- react.useEffect(() => {
2239
- if (!onWarning) return;
2240
- for (const problem of chunk6QYDPGRS_cjs.themeProblems(theme))
2241
- onWarning(`Vinaverse theme: ${problem}`, { code: "theme" });
2242
- for (const key of react$1.bannedWordsIn(copy ?? {}))
2243
- onWarning(
2244
- `Vinaverse copy: "${key}" says assistant, bot or crew; the copy says agent.`,
2245
- { code: "copy" }
2246
- );
2247
- }, [onWarning, theme, copy]);
2248
- return /* @__PURE__ */ jsxRuntime.jsx(react$1.CopyProvider, { locale: props.locale, copy: props.copy, children: /* @__PURE__ */ jsxRuntime.jsx(chunk6QYDPGRS_cjs.ThemeProvider, { theme: props.theme, colorScheme: props.colorScheme, children: /* @__PURE__ */ jsxRuntime.jsx(ChatContextProvider, { value, children: props.children }) }) });
2249
- }
2250
- function VinaverseChat(props) {
2251
- return /* @__PURE__ */ jsxRuntime.jsx(VinaverseChatProvider, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
2252
- Layout,
2253
- {
2254
- hideHeader: props.hideHeader === true,
2255
- keyboardVerticalOffset: props.keyboardVerticalOffset ?? 0,
2256
- keyboardBehavior: props.keyboardBehavior ?? (reactNative.Platform.OS === "ios" ? "padding" : "none"),
2257
- style: props.style,
2258
- onError: props.onWarning,
2259
- suggestion: props.suggestion ?? null,
2260
- suggestionTestID: props.suggestionTestID ?? "vinaverse-suggestion",
2261
- footer: props.footer
2262
- }
2263
- ) });
2264
- }
2265
- function Layout(props) {
2266
- const { colors } = chunk6QYDPGRS_cjs.useTheme();
2267
- const { direction } = react$1.useCopy();
2268
- const { onError } = props;
2269
- const reportError = react.useMemo(
2270
- () => onError ? (e) => onError(String(e), { code: "send_failed" }) : void 0,
2271
- [onError]
2272
- );
2273
- return /* @__PURE__ */ jsxRuntime.jsxs(
2274
- reactNative.KeyboardAvoidingView,
2275
- {
2276
- ...props.keyboardBehavior === "none" ? { enabled: false } : { behavior: props.keyboardBehavior },
2277
- keyboardVerticalOffset: props.keyboardVerticalOffset,
2278
- style: [
2279
- { flex: 1, backgroundColor: colors.background, direction },
2280
- props.style
2281
- ],
2282
- children: [
2283
- props.hideHeader ? null : /* @__PURE__ */ jsxRuntime.jsx(ChatHeader, {}),
2284
- /* @__PURE__ */ jsxRuntime.jsx(DisclosureBar, {}),
2285
- /* @__PURE__ */ jsxRuntime.jsx(StatusBanner, {}),
2286
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: { flex: 1 }, children: /* @__PURE__ */ jsxRuntime.jsx(MessageList, {}) }),
2287
- props.suggestion ? /* @__PURE__ */ jsxRuntime.jsx(Suggestion, { chip: props.suggestion, testID: props.suggestionTestID }) : null,
2288
- /* @__PURE__ */ jsxRuntime.jsx(Composer, { ...reportError ? { onError: reportError } : {} }),
2289
- props.footer
2290
- ]
2291
- }
2292
- );
2293
- }
2294
- function Suggestion(props) {
2295
- const { store, handlers } = useChat();
2296
- const { space } = chunk6QYDPGRS_cjs.useTheme();
2297
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: { paddingHorizontal: space.lg, alignItems: "flex-start" }, children: /* @__PURE__ */ jsxRuntime.jsx(
2298
- Button,
2299
- {
2300
- label: props.chip.label,
2301
- testID: props.testID,
2302
- onPress: () => {
2303
- store.send(props.chip.message);
2304
- handlers.current?.onChip?.(props.chip);
2305
- }
2306
- }
2307
- ) });
2308
- }
2309
- function useStableSlots(slots) {
2310
- const held = react.useRef({});
2311
- const next = slots ?? {};
2312
- if (!sameSlots(held.current, next)) held.current = next;
2313
- return held.current;
2314
- }
2315
- function sameSlots(a, b) {
2316
- const keys = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]);
2317
- for (const key of keys) {
2318
- if (key === "cards") {
2319
- const ca = a.cards ?? {};
2320
- const cb = b.cards ?? {};
2321
- const kinds = /* @__PURE__ */ new Set([...Object.keys(ca), ...Object.keys(cb)]);
2322
- for (const kind of kinds) if (ca[kind] !== cb[kind]) return false;
2323
- } else if (a[key] !== b[key]) return false;
2324
- }
2325
- return true;
2326
- }
2327
- function AgentChat(props) {
2328
- const {
2329
- agentKey,
2330
- place,
2331
- entryPoint,
2332
- askAbout,
2333
- onContact,
2334
- onOpenPrivacy,
2335
- components,
2336
- agentName,
2337
- opener,
2338
- openerTestID,
2339
- ...chat
2340
- } = props;
2341
- const runtime = agent.useAgentRuntime();
2342
- chunk6QYDPGRS_cjs.useAgentSweep(runtime);
2343
- const { conversation, state, startNew } = agent.useAgentConversation(agentKey, {
2344
- place: place ?? null,
2345
- entryPoint: entryPoint ?? null
2346
- });
2347
- const store = conversation.store;
2348
- const spoke = react$1.useConversationSelector(
2349
- store,
2350
- (v) => v.items.some((i) => i.type === "message" && i.role === "person")
2351
- );
2352
- const { Ended, Unreachable, UnavailableScreen, Footer, ...slots } = components ?? {};
2353
- const copy = react.useMemo(
2354
- () => agentName ? { ...props.copy, agentFallbackName: agentName } : props.copy,
2355
- [agentName, props.copy]
2356
- );
2357
- const events = {
2358
- onOpenTarget: chat.onOpenTarget ? (target, card) => {
2359
- runtime.emit({
2360
- type: "target_opened",
2361
- key: conversation.key,
2362
- cardId: card.id,
2363
- kind: target.type
2364
- });
2365
- chat.onOpenTarget?.(target, card);
2366
- } : void 0,
2367
- onOpenLink: chat.onOpenLink ? (link, card) => {
2368
- runtime.emit({
2369
- type: "link_opened",
2370
- key: conversation.key,
2371
- cardId: card.id,
2372
- kind: card.kind
2373
- });
2374
- chat.onOpenLink?.(link, card);
2375
- } : void 0,
2376
- onChip: (chip) => {
2377
- runtime.emit({ type: "chip_tapped", key: conversation.key });
2378
- chat.onChip?.(chip);
2379
- }
2380
- };
2381
- const shared = {
2382
- ...chat,
2383
- ...events.onOpenTarget ? { onOpenTarget: events.onOpenTarget } : {},
2384
- ...events.onOpenLink ? { onOpenLink: events.onOpenLink } : {},
2385
- onChip: events.onChip,
2386
- ...copy ? { copy } : {},
2387
- ...onContact && !chat.failureAction ? { failureAction: { onPress: () => onContact() } } : {},
2388
- conversation: store,
2389
- components: slots
2390
- };
2391
- if (state.failure === "ended") {
2392
- const own = {
2393
- onStartNew: startNew,
2394
- reason: state.reason,
2395
- code: state.code,
2396
- onContact
2397
- };
2398
- return /* @__PURE__ */ jsxRuntime.jsx(VinaverseChatProvider, { ...shared, children: /* @__PURE__ */ jsxRuntime.jsx(Centered, { children: Ended ? /* @__PURE__ */ jsxRuntime.jsx(Ended, { ...own, Default: DefaultEnded }) : /* @__PURE__ */ jsxRuntime.jsx(DefaultEnded, { ...own }) }) });
2399
- }
2400
- if (state.failure === "unreachable") {
2401
- const own = {
2402
- onRetry: conversation.retry,
2403
- reason: state.reason,
2404
- onContact
2405
- };
2406
- return /* @__PURE__ */ jsxRuntime.jsx(VinaverseChatProvider, { ...shared, children: /* @__PURE__ */ jsxRuntime.jsx(Centered, { children: Unreachable ? /* @__PURE__ */ jsxRuntime.jsx(Unreachable, { ...own, Default: DefaultUnreachable }) : /* @__PURE__ */ jsxRuntime.jsx(DefaultUnreachable, { ...own }) }) });
2407
- }
2408
- if (state.failure === "unavailable") {
2409
- const own = {
2410
- reason: state.reason,
2411
- code: state.code,
2412
- onContact,
2413
- onRetry: conversation.retry
2414
- };
2415
- return /* @__PURE__ */ jsxRuntime.jsx(VinaverseChatProvider, { ...shared, children: /* @__PURE__ */ jsxRuntime.jsx(Centered, { children: UnavailableScreen ? /* @__PURE__ */ jsxRuntime.jsx(UnavailableScreen, { ...own, Default: DefaultUnavailableScreen }) : /* @__PURE__ */ jsxRuntime.jsx(DefaultUnavailableScreen, { ...own }) }) });
2416
- }
2417
- const offered = opener && !spoke ? opener : null;
2418
- return /* @__PURE__ */ jsxRuntime.jsx(
2419
- VinaverseChat,
2420
- {
2421
- ...shared,
2422
- suggestion: offered ?? (state.moved && askAbout ? { label: askAbout, message: askAbout } : null),
2423
- ...offered ? { suggestionTestID: openerTestID ?? "vinaverse-opener" } : {},
2424
- footer: Footer === null ? null : /* @__PURE__ */ jsxRuntime.jsx(
2425
- FooterFor,
2426
- {
2427
- store,
2428
- state,
2429
- rate: conversation.rate,
2430
- canRate: conversation.canRate,
2431
- Footer,
2432
- onOpenPrivacy
2433
- }
2434
- )
2435
- }
2436
- );
2437
- }
2438
- function FooterFor(props) {
2439
- const newest = react$1.useConversationSelector(props.store, newestWholeReply);
2440
- const turnId = newest && props.canRate(newest) ? newest : null;
2441
- const own = {
2442
- turnId,
2443
- rating: turnId ? props.state.ratings.get(turnId) : void 0,
2444
- onRate: (rating) => {
2445
- if (turnId) props.rate(turnId, rating);
2446
- },
2447
- onOpenPrivacy: props.onOpenPrivacy
2448
- };
2449
- const { Footer } = props;
2450
- return Footer ? /* @__PURE__ */ jsxRuntime.jsx(Footer, { ...own, Default: AgentFooter }) : /* @__PURE__ */ jsxRuntime.jsx(AgentFooter, { ...own });
2451
- }
2452
- function newestWholeReply(view) {
2453
- for (let i = view.items.length - 1; i >= 0; i--) {
2454
- const item = view.items[i];
2455
- if (item?.type !== "message" || item.role !== "agent") continue;
2456
- const whole = item.state === "sent" && !item.partial && !item.refusal && item.key.startsWith("a:");
2457
- return whole ? item.key.slice(2) : null;
2458
- }
2459
- return null;
2460
- }
2461
- function Centered(props) {
2462
- const { colors, space } = chunk6QYDPGRS_cjs.useTheme();
2463
- return /* @__PURE__ */ jsxRuntime.jsx(
2464
- reactNative.View,
2465
- {
2466
- style: {
2467
- flex: 1,
2468
- alignItems: "center",
2469
- justifyContent: "center",
2470
- padding: space.xl,
2471
- backgroundColor: colors.background
2472
- },
2473
- children: props.children
2474
- }
2475
- );
2476
- }
2477
- function Notice(props) {
2478
- const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
2479
- return /* @__PURE__ */ jsxRuntime.jsxs(
2480
- reactNative.View,
2481
- {
2482
- accessibilityRole: "alert",
2483
- style: { alignItems: "center", gap: space.md },
2484
- children: [
2485
- /* @__PURE__ */ jsxRuntime.jsx(
2486
- reactNative.Text,
2487
- {
2488
- style: {
2489
- color: colors.text,
2490
- fontSize: font.size.lg,
2491
- fontWeight: "600",
2492
- textAlign: "center"
2493
- },
2494
- children: props.title
2495
- }
2496
- ),
2497
- /* @__PURE__ */ jsxRuntime.jsx(
2498
- reactNative.Text,
2499
- {
2500
- style: {
2501
- color: colors.textMuted,
2502
- fontSize: font.size.md,
2503
- textAlign: "center"
2504
- },
2505
- children: props.body
2506
- }
2507
- ),
2508
- props.action && props.onPress ? /* @__PURE__ */ jsxRuntime.jsx(
2509
- Button,
2510
- {
2511
- label: props.action,
2512
- variant: "primary",
2513
- onPress: props.onPress
2514
- }
2515
- ) : null
2516
- ]
2517
- }
2518
- );
2519
- }
2520
- function DefaultEnded(props) {
2521
- const { t } = react$1.useCopy();
2522
- return /* @__PURE__ */ jsxRuntime.jsx(
2523
- Notice,
2524
- {
2525
- title: t("agentEnded"),
2526
- body: t("agentEndedBody"),
2527
- action: t("agentStartOver"),
2528
- onPress: props.onStartNew
2529
- }
2530
- );
2531
- }
2532
- function DefaultUnavailableScreen(props) {
2533
- const { t } = react$1.useCopy();
2534
- const name = agent.useAgentName(t("agentFallbackName"));
2535
- const title = t("agentOff", { agent: name });
2536
- return /* @__PURE__ */ jsxRuntime.jsx(
2537
- Notice,
2538
- {
2539
- title: title.charAt(0).toUpperCase() + title.slice(1),
2540
- body: t("agentOffBody"),
2541
- ...props.onContact ? { action: t("talkToPerson"), onPress: props.onContact } : {}
2542
- }
2543
- );
2544
- }
2545
- function DefaultUnreachable(props) {
2546
- const { t } = react$1.useCopy();
2547
- const name = agent.useAgentName(t("agentFallbackName"));
2548
- return /* @__PURE__ */ jsxRuntime.jsx(
2549
- Notice,
2550
- {
2551
- title: t("agentUnreachable", { agent: name }),
2552
- body: t("agentUnreachableBody"),
2553
- action: t("tryAgain"),
2554
- onPress: props.onRetry
2555
- }
2556
- );
2557
- }
2558
- function AgentFooter(props) {
2559
- const { t } = react$1.useCopy();
2560
- const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
2561
- const muted = { color: colors.textMuted, fontSize: font.size.sm };
2562
- return /* @__PURE__ */ jsxRuntime.jsxs(
2563
- reactNative.View,
2564
- {
2565
- style: {
2566
- flexDirection: "row",
2567
- flexWrap: "wrap",
2568
- alignItems: "center",
2569
- gap: space.xs,
2570
- paddingHorizontal: space.lg
2571
- },
2572
- children: [
2573
- props.turnId === null ? null : props.rating ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: muted, children: t("helpfulThanks") }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2574
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: muted, children: t("helpful") }),
2575
- /* @__PURE__ */ jsxRuntime.jsx(
2576
- Button,
2577
- {
2578
- label: t("helpfulYes"),
2579
- variant: "text",
2580
- onPress: () => props.onRate("up")
2581
- }
2582
- ),
2583
- /* @__PURE__ */ jsxRuntime.jsx(
2584
- Button,
2585
- {
2586
- label: t("helpfulNo"),
2587
- variant: "text",
2588
- onPress: () => props.onRate("down")
2589
- }
2590
- )
2591
- ] }),
2592
- props.onOpenPrivacy ? /* @__PURE__ */ jsxRuntime.jsx(
2593
- Button,
2594
- {
2595
- label: t("privacy"),
2596
- variant: "text",
2597
- role: "link",
2598
- onPress: props.onOpenPrivacy
2599
- }
2600
- ) : null
2601
- ]
2602
- }
2603
- );
2604
- }
2605
1995
 
2606
- Object.defineProperty(exports, "AgentRuntimeProvider", {
2607
- enumerable: true,
2608
- get: function () { return agent.AgentRuntimeProvider; }
2609
- });
2610
- Object.defineProperty(exports, "forgetGreeting", {
2611
- enumerable: true,
2612
- get: function () { return agent.forgetGreeting; }
2613
- });
2614
- Object.defineProperty(exports, "greetedKey", {
2615
- enumerable: true,
2616
- get: function () { return agent.greetedKey; }
2617
- });
2618
- Object.defineProperty(exports, "useAgentConversation", {
2619
- enumerable: true,
2620
- get: function () { return agent.useAgentConversation; }
2621
- });
2622
- Object.defineProperty(exports, "useAgentFeatures", {
2623
- enumerable: true,
2624
- get: function () { return agent.useAgentFeatures; }
2625
- });
2626
- Object.defineProperty(exports, "useAgentLauncher", {
2627
- enumerable: true,
2628
- get: function () { return agent.useAgentLauncher; }
2629
- });
2630
- Object.defineProperty(exports, "useAgentName", {
2631
- enumerable: true,
2632
- get: function () { return agent.useAgentName; }
2633
- });
2634
- Object.defineProperty(exports, "useAgentProfile", {
2635
- enumerable: true,
2636
- get: function () { return agent.useAgentProfile; }
2637
- });
2638
- Object.defineProperty(exports, "useAgentRuntime", {
2639
- enumerable: true,
2640
- get: function () { return agent.useAgentRuntime; }
2641
- });
2642
- Object.defineProperty(exports, "useAgentStatus", {
2643
- enumerable: true,
2644
- get: function () { return agent.useAgentStatus; }
2645
- });
2646
- Object.defineProperty(exports, "useAgentStatusState", {
2647
- enumerable: true,
2648
- get: function () { return agent.useAgentStatusState; }
2649
- });
2650
1996
  exports.ActivityLine = ActivityLine;
2651
- exports.AgentChat = AgentChat;
2652
- exports.AgentFooter = AgentFooter;
2653
1997
  exports.Avatar = Avatar;
2654
1998
  exports.Button = Button;
2655
1999
  exports.CardActions = CardActions;
2656
2000
  exports.CardCarousel = CardCarousel;
2657
2001
  exports.CardFrame = CardFrame;
2658
2002
  exports.CardView = CardView;
2003
+ exports.ChatContextProvider = ChatContextProvider;
2659
2004
  exports.ChatHeader = ChatHeader;
2660
2005
  exports.ChatSkeleton = ChatSkeleton;
2661
- exports.Composer = Composer;
2662
2006
  exports.DefaultBubble = DefaultBubble;
2663
- exports.DefaultComposer = DefaultComposer;
2664
- exports.DefaultEnded = DefaultEnded;
2665
2007
  exports.DefaultHeader = DefaultHeader;
2666
2008
  exports.DefaultTurnFailed = DefaultTurnFailed;
2667
- exports.DefaultUnavailable = DefaultUnavailable;
2668
- exports.DefaultUnavailableScreen = DefaultUnavailableScreen;
2669
- exports.DefaultUnreachable = DefaultUnreachable;
2670
2009
  exports.DisclosureBar = DisclosureBar;
2671
2010
  exports.FailureActionButton = FailureActionButton;
2011
+ exports.FailureSlot = FailureSlot;
2672
2012
  exports.InfoCard = InfoCard;
2673
2013
  exports.LinksCard = LinksCard;
2674
2014
  exports.ListingCard = ListingCard;
@@ -2678,12 +2018,9 @@ exports.NextStepCard = NextStepCard;
2678
2018
  exports.ProposalCard = ProposalCard;
2679
2019
  exports.QuestionCard = QuestionCard;
2680
2020
  exports.Row = Row;
2681
- exports.StatusBanner = StatusBanner;
2682
2021
  exports.StreamingBubble = StreamingBubble;
2683
2022
  exports.SystemRow = SystemRow;
2684
2023
  exports.TimeSlotsCard = TimeSlotsCard;
2685
- exports.VinaverseChat = VinaverseChat;
2686
- exports.VinaverseChatProvider = VinaverseChatProvider;
2687
2024
  exports.Welcome = Welcome;
2688
2025
  exports.allowedImage = allowedImage;
2689
2026
  exports.answerText = answerText;
@@ -2692,8 +2029,7 @@ exports.defaultCard = defaultCard;
2692
2029
  exports.fieldText = fieldText;
2693
2030
  exports.itemType = itemType;
2694
2031
  exports.monogram = monogram;
2695
- exports.newestWholeReply = newestWholeReply;
2696
2032
  exports.ratingText = ratingText;
2697
2033
  exports.useChat = useChat;
2698
- //# sourceMappingURL=chunk-NRYNK7E4.cjs.map
2699
- //# sourceMappingURL=chunk-NRYNK7E4.cjs.map
2034
+ //# sourceMappingURL=chunk-XAG2P447.cjs.map
2035
+ //# sourceMappingURL=chunk-XAG2P447.cjs.map