@vinaverse/react-native 0.1.0-alpha.6 → 0.1.0-alpha.8

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 (47) hide show
  1. package/README.md +36 -17
  2. package/dist/ask.cjs +9 -5
  3. package/dist/ask.d.cts +16 -3
  4. package/dist/ask.d.ts +16 -3
  5. package/dist/ask.js +3 -3
  6. package/dist/chat.cjs +76 -73
  7. package/dist/chat.d.cts +31 -8
  8. package/dist/chat.d.ts +31 -8
  9. package/dist/chat.js +2 -3
  10. package/dist/{chunk-OWUKWVEZ.cjs → chunk-6QYDPGRS.cjs} +46 -2
  11. package/dist/chunk-6QYDPGRS.cjs.map +1 -0
  12. package/dist/{chunk-Y7P7DDHD.js → chunk-7KPCO443.js} +13 -12
  13. package/dist/chunk-7KPCO443.js.map +1 -0
  14. package/dist/chunk-EFEXTVIT.js +88 -0
  15. package/dist/chunk-EFEXTVIT.js.map +1 -0
  16. package/dist/{chunk-H2Y2YW2Q.cjs → chunk-EXN5TNLU.cjs} +85 -80
  17. package/dist/chunk-EXN5TNLU.cjs.map +1 -0
  18. package/dist/{chunk-OGPMGGYS.cjs → chunk-MG32E4JI.cjs} +20 -13
  19. package/dist/chunk-MG32E4JI.cjs.map +1 -0
  20. package/dist/{chunk-643GOUTG.cjs → chunk-NMKJ7LIJ.cjs} +14 -13
  21. package/dist/chunk-NMKJ7LIJ.cjs.map +1 -0
  22. package/dist/{chunk-SF6LJTVJ.js → chunk-NXGLI4Y7.js} +39 -38
  23. package/dist/chunk-NXGLI4Y7.js.map +1 -0
  24. package/dist/{chunk-NJWRZ55G.js → chunk-POJP52GE.js} +16 -9
  25. package/dist/chunk-POJP52GE.js.map +1 -0
  26. package/dist/index.cjs +86 -83
  27. package/dist/index.d.cts +3 -3
  28. package/dist/index.d.ts +3 -3
  29. package/dist/index.js +4 -5
  30. package/dist/launcher.cjs +14 -11
  31. package/dist/launcher.d.cts +4 -3
  32. package/dist/launcher.d.ts +4 -3
  33. package/dist/launcher.js +3 -4
  34. package/package.json +22 -5
  35. package/dist/chunk-643GOUTG.cjs.map +0 -1
  36. package/dist/chunk-H2Y2YW2Q.cjs.map +0 -1
  37. package/dist/chunk-NJWRZ55G.js.map +0 -1
  38. package/dist/chunk-OGPMGGYS.cjs.map +0 -1
  39. package/dist/chunk-OWUKWVEZ.cjs.map +0 -1
  40. package/dist/chunk-PRXHS57U.js +0 -40
  41. package/dist/chunk-PRXHS57U.js.map +0 -1
  42. package/dist/chunk-PYPO6F7L.cjs +0 -44
  43. package/dist/chunk-PYPO6F7L.cjs.map +0 -1
  44. package/dist/chunk-SF6LJTVJ.js.map +0 -1
  45. package/dist/chunk-WKRCCPSN.js +0 -48
  46. package/dist/chunk-WKRCCPSN.js.map +0 -1
  47. package/dist/chunk-Y7P7DDHD.js.map +0 -1
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkPYPO6F7L_cjs = require('./chunk-PYPO6F7L.cjs');
4
- var chunkOWUKWVEZ_cjs = require('./chunk-OWUKWVEZ.cjs');
3
+ var chunk6QYDPGRS_cjs = require('./chunk-6QYDPGRS.cjs');
5
4
  var agent = require('@vinaverse/react/agent');
6
5
  var flashList = require('@shopify/flash-list');
7
6
  var react$1 = require('@vinaverse/react');
@@ -27,7 +26,7 @@ function useChat() {
27
26
  return value;
28
27
  }
29
28
  var Button = /* @__PURE__ */ react.memo(function Button2(props) {
30
- const { colors, radius, space, size: size2, font } = chunkOWUKWVEZ_cjs.useTheme();
29
+ const { colors, radius, space, size: size2, font } = chunk6QYDPGRS_cjs.useTheme();
31
30
  const variant = props.variant ?? "secondary";
32
31
  const inactive = props.disabled === true || props.busy === true;
33
32
  const filled = variant === "primary" || props.selected === true;
@@ -85,7 +84,7 @@ function cardOf(held) {
85
84
  return held.card;
86
85
  }
87
86
  function CardFrame(props) {
88
- const { colors, radius, space } = chunkOWUKWVEZ_cjs.useTheme();
87
+ const { colors, radius, space } = chunk6QYDPGRS_cjs.useTheme();
89
88
  return /* @__PURE__ */ jsxRuntime.jsx(
90
89
  reactNative.View,
91
90
  {
@@ -113,7 +112,7 @@ function CardFrame(props) {
113
112
  );
114
113
  }
115
114
  function Title(props) {
116
- const { colors, font } = chunkOWUKWVEZ_cjs.useTheme();
115
+ const { colors, font } = chunk6QYDPGRS_cjs.useTheme();
117
116
  return /* @__PURE__ */ jsxRuntime.jsx(
118
117
  reactNative.Text,
119
118
  {
@@ -130,7 +129,7 @@ function Title(props) {
130
129
  );
131
130
  }
132
131
  function Body(props) {
133
- const { colors, font } = chunkOWUKWVEZ_cjs.useTheme();
132
+ const { colors, font } = chunk6QYDPGRS_cjs.useTheme();
134
133
  return /* @__PURE__ */ jsxRuntime.jsx(
135
134
  reactNative.Text,
136
135
  {
@@ -173,7 +172,7 @@ function InfoCard(props) {
173
172
  const card = cardOf(props.card);
174
173
  const { locale, t } = react$1.useCopy();
175
174
  const { slots, timeZone } = useChat();
176
- const { colors, radius, space, font } = chunkOWUKWVEZ_cjs.useTheme();
175
+ const { colors, radius, space, font } = chunk6QYDPGRS_cjs.useTheme();
177
176
  const image = safeImage(card.image_url);
178
177
  const Img = slots.Image ?? reactNative.Image;
179
178
  const money = card.price ?? card.price_from;
@@ -227,7 +226,7 @@ function InfoCard(props) {
227
226
  );
228
227
  }
229
228
  function Badges(props) {
230
- const { colors, radius, space, font } = chunkOWUKWVEZ_cjs.useTheme();
229
+ const { colors, radius, space, font } = chunk6QYDPGRS_cjs.useTheme();
231
230
  if (!props.badges?.length) return null;
232
231
  return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: { flexDirection: "row", flexWrap: "wrap", gap: space.xs }, children: props.badges.map((b) => /* @__PURE__ */ jsxRuntime.jsx(
233
232
  reactNative.Text,
@@ -247,7 +246,7 @@ function Badges(props) {
247
246
  }
248
247
  function CardActions(props) {
249
248
  const card = cardOf(props.card);
250
- const { space } = chunkOWUKWVEZ_cjs.useTheme();
249
+ const { space } = chunk6QYDPGRS_cjs.useTheme();
251
250
  if (!card.actions?.length) return null;
252
251
  return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: { flexDirection: "row", flexWrap: "wrap", gap: space.sm }, children: card.actions.map((a) => /* @__PURE__ */ jsxRuntime.jsx(
253
252
  Action,
@@ -314,7 +313,7 @@ function ListingCard(props) {
314
313
  const card = cardOf(props.card);
315
314
  const { locale, t } = react$1.useCopy();
316
315
  const { slots, timeZone, handlers, imagePolicy } = useChat();
317
- const { colors, radius, space, font } = chunkOWUKWVEZ_cjs.useTheme();
316
+ const { colors, radius, space, font } = chunk6QYDPGRS_cjs.useTheme();
318
317
  const [failed, setFailed] = react.useState(null);
319
318
  const photoUrl = allowedImage(
320
319
  card.images?.[0]?.url ?? card.image_url,
@@ -322,7 +321,7 @@ function ListingCard(props) {
322
321
  );
323
322
  const hero = photoUrl === failed ? null : photoUrl;
324
323
  const Img = slots.Image ?? reactNative.Image;
325
- const rating = card.rating ? `\u2605 ${ratingText(card.rating.value_ppm, locale)} (${card.rating.count})` : null;
324
+ const rating = card.rating ? `\u2605 ${ratingText(card.rating.value_ppm, locale)} (${card.rating.count})` : t("ratingNone") || null;
326
325
  const price = card.price_from ? t("priceFrom", {
327
326
  price: react$1.formatMoney(
328
327
  card.price_from.amount,
@@ -351,7 +350,7 @@ function ListingCard(props) {
351
350
  accessible: false,
352
351
  testID: `vinaverse-photo-${card.id}`
353
352
  }
354
- ) : imagePolicy?.Placeholder ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: photo, testID: `vinaverse-placeholder-${card.id}`, children: /* @__PURE__ */ jsxRuntime.jsx(imagePolicy.Placeholder, { title: card.title }) }) : /* @__PURE__ */ jsxRuntime.jsx(
353
+ ) : imagePolicy?.Placeholder ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: photo, testID: `vinaverse-placeholder-${card.id}`, children: /* @__PURE__ */ jsxRuntime.jsx(imagePolicy.Placeholder, { title: card.title, kind: card.kind }) }) : /* @__PURE__ */ jsxRuntime.jsx(
355
354
  reactNative.View,
356
355
  {
357
356
  accessible: false,
@@ -494,7 +493,7 @@ function ProposalCard(props) {
494
493
  const proposal = card.proposal;
495
494
  const { t, locale } = react$1.useCopy();
496
495
  const { store, handlers, timeZone } = useChat();
497
- const { colors, space, font } = chunkOWUKWVEZ_cjs.useTheme();
496
+ const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
498
497
  const edit = useLink(proposal?.edit_deep_link, props.card);
499
498
  if (!proposal) return null;
500
499
  const settled = outcomeText(t, props.card.outcome, proposal.status);
@@ -506,7 +505,9 @@ function ProposalCard(props) {
506
505
  props.card.id,
507
506
  () => onProposal(props.card, decision)
508
507
  ).catch(
509
- (error) => handlers.current?.onWarning?.(`Vinaverse proposal: ${String(error)}`)
508
+ (error) => handlers.current?.onWarning?.(`Vinaverse proposal: ${String(error)}`, {
509
+ code: "proposal_failed"
510
+ })
510
511
  );
511
512
  };
512
513
  const fields = proposal.fields.map((f) => {
@@ -618,7 +619,7 @@ function QuestionCard(props) {
618
619
  const question = held.question;
619
620
  const { store, handlers } = useChat();
620
621
  const { t, locale } = react$1.useCopy();
621
- const { colors, font, space } = chunkOWUKWVEZ_cjs.useTheme();
622
+ const { colors, font, space } = chunk6QYDPGRS_cjs.useTheme();
622
623
  const needsSocket = react$1.useConversationSelector(
623
624
  store,
624
625
  (v) => v.answersNeedWebSocket
@@ -628,7 +629,9 @@ function QuestionCard(props) {
628
629
  try {
629
630
  store.answer(held.id, questionId, answer);
630
631
  } catch (error) {
631
- handlers.current?.onWarning?.(`Vinaverse answer: ${String(error)}`);
632
+ handlers.current?.onWarning?.(`Vinaverse answer: ${String(error)}`, {
633
+ code: "answer_failed"
634
+ });
632
635
  }
633
636
  };
634
637
  const locked = held.locked.includes(question.question_id);
@@ -676,7 +679,7 @@ function QuestionCard(props) {
676
679
  function Answer(props) {
677
680
  const { question, send, enabled } = props;
678
681
  const { t } = react$1.useCopy();
679
- const { space } = chunkOWUKWVEZ_cjs.useTheme();
682
+ const { space } = chunk6QYDPGRS_cjs.useTheme();
680
683
  const { handlers } = useChat();
681
684
  const [draft, setDraft] = react.useState({});
682
685
  const kind = question.kind;
@@ -739,7 +742,8 @@ function Answer(props) {
739
742
  if (picked) send({ upload_ref: picked.upload_ref });
740
743
  }).catch(
741
744
  (error) => handlers.current?.onWarning?.(
742
- `Vinaverse photo: ${String(error)}`
745
+ `Vinaverse photo: ${String(error)}`,
746
+ { code: "photo_failed" }
743
747
  )
744
748
  );
745
749
  }
@@ -787,7 +791,7 @@ function ChoiceAnswer(props) {
787
791
  const { question, draft, onChange, enabled } = props;
788
792
  const { t } = react$1.useCopy();
789
793
  const { slots } = useChat();
790
- const { colors, radius, space, font } = chunkOWUKWVEZ_cjs.useTheme();
794
+ const { colors, radius, space, font } = chunk6QYDPGRS_cjs.useTheme();
791
795
  const [search, setSearch] = react.useState("");
792
796
  const multi = question.kind === "multi_choice" || question.kind === "image_choice";
793
797
  const values = draft.values ?? [];
@@ -893,7 +897,7 @@ function ChoiceAnswer(props) {
893
897
  ] });
894
898
  }
895
899
  function ChoiceLabel(props) {
896
- const { colors, font } = chunkOWUKWVEZ_cjs.useTheme();
900
+ const { colors, font } = chunk6QYDPGRS_cjs.useTheme();
897
901
  return /* @__PURE__ */ jsxRuntime.jsx(
898
902
  reactNative.Text,
899
903
  {
@@ -908,7 +912,7 @@ function ChoiceLabel(props) {
908
912
  }
909
913
  function OtherText(props) {
910
914
  const { t } = react$1.useCopy();
911
- const { colors, radius, space, font } = chunkOWUKWVEZ_cjs.useTheme();
915
+ const { colors, radius, space, font } = chunk6QYDPGRS_cjs.useTheme();
912
916
  const on = props.value !== void 0;
913
917
  return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: { gap: space.xs }, children: [
914
918
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -947,7 +951,7 @@ function OtherText(props) {
947
951
  }
948
952
  function CharactersLeft(props) {
949
953
  const { t } = react$1.useCopy();
950
- const { colors, font } = chunkOWUKWVEZ_cjs.useTheme();
954
+ const { colors, font } = chunk6QYDPGRS_cjs.useTheme();
951
955
  const left = props.max - conversation.codePoints(props.text);
952
956
  return /* @__PURE__ */ jsxRuntime.jsx(
953
957
  reactNative.Text,
@@ -962,7 +966,7 @@ function CharactersLeft(props) {
962
966
  );
963
967
  }
964
968
  function TextAnswer(props) {
965
- const { colors, radius, space, font } = chunkOWUKWVEZ_cjs.useTheme();
969
+ const { colors, radius, space, font } = chunk6QYDPGRS_cjs.useTheme();
966
970
  const long = props.question.kind === "long_text";
967
971
  const max = props.question.text?.max_length ?? (long ? 2e3 : 200);
968
972
  return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: { gap: space.xs }, children: [
@@ -993,7 +997,7 @@ function TextAnswer(props) {
993
997
  }
994
998
  function NumberAnswer(props) {
995
999
  const range = props.question.number ?? { min: 0, max: 100, step: 1 };
996
- const { colors, space, font } = chunkOWUKWVEZ_cjs.useTheme();
1000
+ const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
997
1001
  const value = props.value ?? range.min;
998
1002
  const clamp = (n) => Math.min(range.max, Math.max(range.min, Number(n.toFixed(6))));
999
1003
  const shown = `${value}${props.question.number?.unit ? ` ${props.question.number.unit}` : ""}`;
@@ -1052,7 +1056,7 @@ function NumberAnswer(props) {
1052
1056
  }
1053
1057
  function ScaleAnswer(props) {
1054
1058
  const scale = props.question.scale;
1055
- const { colors, space, font } = chunkOWUKWVEZ_cjs.useTheme();
1059
+ const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
1056
1060
  if (!scale) return null;
1057
1061
  const points = [];
1058
1062
  for (let n = scale.min; n <= scale.max && points.length < 21; n += scale.step)
@@ -1077,7 +1081,7 @@ function ScaleAnswer(props) {
1077
1081
  var iso = (y, m, d) => `${String(y).padStart(4, "0")}-${String(m + 1).padStart(2, "0")}-${String(d).padStart(2, "0")}`;
1078
1082
  function DateAnswer(props) {
1079
1083
  const { locale } = react$1.useCopy();
1080
- const { colors, space, font } = chunkOWUKWVEZ_cjs.useTheme();
1084
+ const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
1081
1085
  const bounds = props.question.date;
1082
1086
  const start = props.value ?? bounds?.min ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
1083
1087
  const [month, setMonth] = react.useState(() => ({
@@ -1161,7 +1165,7 @@ function DateAnswer(props) {
1161
1165
  function RateEach(props) {
1162
1166
  const { question } = props;
1163
1167
  const { t } = react$1.useCopy();
1164
- const { colors, space, font } = chunkOWUKWVEZ_cjs.useTheme();
1168
+ const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
1165
1169
  const answered = new Map(
1166
1170
  (question.row_answers ?? []).map((r) => [
1167
1171
  r.question_id,
@@ -1242,7 +1246,7 @@ function TimeSlotsCard(props) {
1242
1246
  const card = cardOf(props.card);
1243
1247
  const { locale } = react$1.useCopy();
1244
1248
  const { timeZone } = useChat();
1245
- const { colors, radius, space, font } = chunkOWUKWVEZ_cjs.useTheme();
1249
+ const { colors, radius, space, font } = chunk6QYDPGRS_cjs.useTheme();
1246
1250
  const slots = (card.slots ?? []).map(
1247
1251
  (s) => react$1.formatTimeRange(s.start, s.end, locale, timeZone)
1248
1252
  );
@@ -1327,7 +1331,7 @@ function CardCarousel(props) {
1327
1331
  var ActivityLine = /* @__PURE__ */ react.memo(function ActivityLine2() {
1328
1332
  const { store } = useChat();
1329
1333
  const { t } = react$1.useCopy();
1330
- const { colors, space, font } = chunkOWUKWVEZ_cjs.useTheme();
1334
+ const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
1331
1335
  const activity = react$1.useConversationSelector(store, (v) => v.activity);
1332
1336
  const waiting = react$1.useConversationSelector(
1333
1337
  store,
@@ -1347,7 +1351,7 @@ var ActivityLine = /* @__PURE__ */ react.memo(function ActivityLine2() {
1347
1351
  );
1348
1352
  });
1349
1353
  var Avatar = /* @__PURE__ */ react.memo(function Avatar2(props) {
1350
- const { colors, size: size2, font } = chunkOWUKWVEZ_cjs.useTheme();
1354
+ const { colors, size: size2, font } = chunk6QYDPGRS_cjs.useTheme();
1351
1355
  const { slots } = useChat();
1352
1356
  const box = {
1353
1357
  width: size2.avatar,
@@ -1393,7 +1397,7 @@ var Avatar = /* @__PURE__ */ react.memo(function Avatar2(props) {
1393
1397
  );
1394
1398
  });
1395
1399
  function DefaultHeader(props) {
1396
- const { colors, space, font } = chunkOWUKWVEZ_cjs.useTheme();
1400
+ const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
1397
1401
  const { t } = react$1.useCopy();
1398
1402
  const person = props.takeoverBy !== null;
1399
1403
  const subtitle = person ? t("staffLabel", { by: props.takeoverBy || t("staffFallbackRole") }) : t("agentLabel");
@@ -1460,7 +1464,7 @@ var ChatHeader = /* @__PURE__ */ react.memo(function ChatHeader2() {
1460
1464
  });
1461
1465
  function DefaultComposer(props) {
1462
1466
  const { t, direction } = react$1.useCopy();
1463
- const { colors, radius, space, font, size: size2 } = chunkOWUKWVEZ_cjs.useTheme();
1467
+ const { colors, radius, space, font, size: size2 } = chunk6QYDPGRS_cjs.useTheme();
1464
1468
  const [text, setText] = react.useState("");
1465
1469
  const length = conversation.codePoints(text);
1466
1470
  const canSend = text.trim().length > 0 && length <= conversation.MAX_TEXT;
@@ -1561,7 +1565,7 @@ var Composer = /* @__PURE__ */ react.memo(function Composer2(props) {
1561
1565
  var DisclosureBar = /* @__PURE__ */ react.memo(function DisclosureBar2() {
1562
1566
  const { store } = useChat();
1563
1567
  const { t } = react$1.useCopy();
1564
- const theme = chunkOWUKWVEZ_cjs.useTheme();
1568
+ const theme = chunk6QYDPGRS_cjs.useTheme();
1565
1569
  const { space, font } = theme;
1566
1570
  const disclosure = react$1.useConversationSelector(store, (v) => v.disclosure);
1567
1571
  const [open, setOpen] = react.useState(false);
@@ -1600,7 +1604,7 @@ var DisclosureBar = /* @__PURE__ */ react.memo(function DisclosureBar2() {
1600
1604
  );
1601
1605
  });
1602
1606
  var ChatSkeleton = /* @__PURE__ */ react.memo(function ChatSkeleton2() {
1603
- const { colors, radius, space } = chunkOWUKWVEZ_cjs.useTheme();
1607
+ const { colors, radius, space } = chunk6QYDPGRS_cjs.useTheme();
1604
1608
  const row = (width, end) => /* @__PURE__ */ jsxRuntime.jsx(
1605
1609
  reactNative.View,
1606
1610
  {
@@ -1631,7 +1635,7 @@ var ChatSkeleton = /* @__PURE__ */ react.memo(function ChatSkeleton2() {
1631
1635
  );
1632
1636
  });
1633
1637
  function DefaultBubble(props) {
1634
- const { colors, radius, space, font } = chunkOWUKWVEZ_cjs.useTheme();
1638
+ const { colors, radius, space, font } = chunk6QYDPGRS_cjs.useTheme();
1635
1639
  const role = props.item.role;
1636
1640
  const [background, foreground] = role === "person" ? [colors.personBubble, colors.personText] : role === "staff" ? [colors.staffBubble, colors.staffText] : [colors.agentBubble, colors.agentText];
1637
1641
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -1686,7 +1690,7 @@ function Frame(props) {
1686
1690
  const { item, text } = props;
1687
1691
  const { store, slots } = useChat();
1688
1692
  const { t } = react$1.useCopy();
1689
- const { colors, space, font } = chunkOWUKWVEZ_cjs.useTheme();
1693
+ const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
1690
1694
  const author = useAuthor(item);
1691
1695
  const mine = item.role === "person";
1692
1696
  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;
@@ -1828,7 +1832,7 @@ function DefaultTurnFailed(props) {
1828
1832
  ] });
1829
1833
  }
1830
1834
  function Line(props) {
1831
- const { colors, space, font } = chunkOWUKWVEZ_cjs.useTheme();
1835
+ const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
1832
1836
  return /* @__PURE__ */ jsxRuntime.jsx(
1833
1837
  reactNative.View,
1834
1838
  {
@@ -1854,7 +1858,7 @@ function Line(props) {
1854
1858
  );
1855
1859
  }
1856
1860
  var Welcome = /* @__PURE__ */ react.memo(function Welcome2(props) {
1857
- const { colors, radius, space, font } = chunkOWUKWVEZ_cjs.useTheme();
1861
+ const { colors, radius, space, font } = chunk6QYDPGRS_cjs.useTheme();
1858
1862
  return /* @__PURE__ */ jsxRuntime.jsxs(
1859
1863
  reactNative.View,
1860
1864
  {
@@ -1940,8 +1944,8 @@ var Row = /* @__PURE__ */ react.memo(function Row2(props) {
1940
1944
  var MessageList = /* @__PURE__ */ react.memo(function MessageList2() {
1941
1945
  const { store, slots, starters, handlers, imagePolicy } = useChat();
1942
1946
  const { t } = react$1.useCopy();
1943
- const { space } = chunkOWUKWVEZ_cjs.useTheme();
1944
- const reducedMotion = chunkPYPO6F7L_cjs.useReducedMotion();
1947
+ const { space } = chunk6QYDPGRS_cjs.useTheme();
1948
+ const reducedMotion = chunk6QYDPGRS_cjs.useReducedMotion();
1945
1949
  const items = react$1.useConversationSelector(store, (v) => v.items);
1946
1950
  usePrefetchPhotos(items, handlers.current?.prefetchImage, imagePolicy?.hosts);
1947
1951
  const opening = react$1.useConversationSelector(
@@ -2052,7 +2056,7 @@ function useAnnounceReplies(items) {
2052
2056
  const author = last.role === "staff" ? t("staffLabel", {
2053
2057
  by: store.getSnapshot().takeover?.by || t("staffFallbackRole")
2054
2058
  }) : store.getSnapshot().agent.name ?? t("agentFallbackName");
2055
- (handlers.current?.announce ?? chunkPYPO6F7L_cjs.announce)(`${author}: ${last.text}`);
2059
+ (handlers.current?.announce ?? chunk6QYDPGRS_cjs.announce)(`${author}: ${last.text}`);
2056
2060
  }, [items, t, store, handlers]);
2057
2061
  }
2058
2062
  var CONNECTING_DELAY = tokens.motion.bannerDelay;
@@ -2123,7 +2127,7 @@ function DefaultUnavailable(props) {
2123
2127
  ] });
2124
2128
  }
2125
2129
  function Banner(props) {
2126
- const { colors, space, font } = chunkOWUKWVEZ_cjs.useTheme();
2130
+ const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
2127
2131
  return /* @__PURE__ */ jsxRuntime.jsxs(
2128
2132
  reactNative.View,
2129
2133
  {
@@ -2192,21 +2196,22 @@ function VinaverseChatProvider(props) {
2192
2196
  imagePolicy
2193
2197
  ]
2194
2198
  );
2195
- chunkPYPO6F7L_cjs.useNativeLifecycle(conversation);
2199
+ chunk6QYDPGRS_cjs.useNativeLifecycle(conversation);
2196
2200
  react.useEffect(() => {
2197
2201
  conversation.start();
2198
2202
  }, [conversation]);
2199
2203
  const { onWarning, theme, copy } = props;
2200
2204
  react.useEffect(() => {
2201
2205
  if (!onWarning) return;
2202
- for (const problem of chunkOWUKWVEZ_cjs.themeProblems(theme))
2203
- onWarning(`Vinaverse theme: ${problem}`);
2206
+ for (const problem of chunk6QYDPGRS_cjs.themeProblems(theme))
2207
+ onWarning(`Vinaverse theme: ${problem}`, { code: "theme" });
2204
2208
  for (const key of react$1.bannedWordsIn(copy ?? {}))
2205
2209
  onWarning(
2206
- `Vinaverse copy: "${key}" says assistant, bot or crew; the copy says agent.`
2210
+ `Vinaverse copy: "${key}" says assistant, bot or crew; the copy says agent.`,
2211
+ { code: "copy" }
2207
2212
  );
2208
2213
  }, [onWarning, theme, copy]);
2209
- return /* @__PURE__ */ jsxRuntime.jsx(react$1.CopyProvider, { locale: props.locale, copy: props.copy, children: /* @__PURE__ */ jsxRuntime.jsx(chunkOWUKWVEZ_cjs.ThemeProvider, { theme: props.theme, colorScheme: props.colorScheme, children: /* @__PURE__ */ jsxRuntime.jsx(ChatContextProvider, { value, children: props.children }) }) });
2214
+ 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 }) }) });
2210
2215
  }
2211
2216
  function VinaverseChat(props) {
2212
2217
  return /* @__PURE__ */ jsxRuntime.jsx(VinaverseChatProvider, { ...props, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2223,11 +2228,11 @@ function VinaverseChat(props) {
2223
2228
  ) });
2224
2229
  }
2225
2230
  function Layout(props) {
2226
- const { colors } = chunkOWUKWVEZ_cjs.useTheme();
2231
+ const { colors } = chunk6QYDPGRS_cjs.useTheme();
2227
2232
  const { direction } = react$1.useCopy();
2228
2233
  const { onError } = props;
2229
2234
  const reportError = react.useMemo(
2230
- () => onError ? (e) => onError(String(e)) : void 0,
2235
+ () => onError ? (e) => onError(String(e), { code: "send_failed" }) : void 0,
2231
2236
  [onError]
2232
2237
  );
2233
2238
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -2253,7 +2258,7 @@ function Layout(props) {
2253
2258
  }
2254
2259
  function Suggestion(props) {
2255
2260
  const { store, handlers } = useChat();
2256
- const { space } = chunkOWUKWVEZ_cjs.useTheme();
2261
+ const { space } = chunk6QYDPGRS_cjs.useTheme();
2257
2262
  return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: { paddingHorizontal: space.lg, alignItems: "flex-start" }, children: /* @__PURE__ */ jsxRuntime.jsx(
2258
2263
  Button,
2259
2264
  {
@@ -2297,6 +2302,7 @@ function AgentChat(props) {
2297
2302
  ...chat
2298
2303
  } = props;
2299
2304
  const runtime = agent.useAgentRuntime();
2305
+ chunk6QYDPGRS_cjs.useAgentSweep(runtime);
2300
2306
  const { conversation, state, startNew } = agent.useAgentConversation(agentKey, {
2301
2307
  place: place ?? null,
2302
2308
  entryPoint: entryPoint ?? null
@@ -2345,30 +2351,23 @@ function AgentChat(props) {
2345
2351
  conversation: store,
2346
2352
  components: slots
2347
2353
  };
2348
- if (state.failure === "ended")
2349
- return /* @__PURE__ */ jsxRuntime.jsx(VinaverseChatProvider, { ...shared, children: /* @__PURE__ */ jsxRuntime.jsx(Centered, { children: Ended ? /* @__PURE__ */ jsxRuntime.jsx(
2350
- Ended,
2351
- {
2352
- onStartNew: startNew,
2353
- code: state.code,
2354
- Default: DefaultEnded
2355
- }
2356
- ) : /* @__PURE__ */ jsxRuntime.jsx(DefaultEnded, { onStartNew: startNew, code: state.code }) }) });
2357
- if (state.failure === "unreachable")
2358
- return /* @__PURE__ */ jsxRuntime.jsx(VinaverseChatProvider, { ...shared, children: /* @__PURE__ */ jsxRuntime.jsx(Centered, { children: Unreachable ? /* @__PURE__ */ jsxRuntime.jsx(
2359
- Unreachable,
2360
- {
2361
- onRetry: conversation.retry,
2362
- reason: state.reason,
2363
- Default: DefaultUnreachable
2364
- }
2365
- ) : /* @__PURE__ */ jsxRuntime.jsx(
2366
- DefaultUnreachable,
2367
- {
2368
- onRetry: conversation.retry,
2369
- reason: state.reason
2370
- }
2371
- ) }) });
2354
+ if (state.failure === "ended") {
2355
+ const own = {
2356
+ onStartNew: startNew,
2357
+ reason: state.reason,
2358
+ code: state.code,
2359
+ onContact
2360
+ };
2361
+ 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 }) }) });
2362
+ }
2363
+ if (state.failure === "unreachable") {
2364
+ const own = {
2365
+ onRetry: conversation.retry,
2366
+ reason: state.reason,
2367
+ onContact
2368
+ };
2369
+ 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 }) }) });
2370
+ }
2372
2371
  if (state.failure === "unavailable") {
2373
2372
  const own = {
2374
2373
  reason: state.reason,
@@ -2389,6 +2388,7 @@ function AgentChat(props) {
2389
2388
  store,
2390
2389
  state,
2391
2390
  rate: conversation.rate,
2391
+ canRate: conversation.canRate,
2392
2392
  Footer,
2393
2393
  onOpenPrivacy
2394
2394
  }
@@ -2397,7 +2397,8 @@ function AgentChat(props) {
2397
2397
  );
2398
2398
  }
2399
2399
  function FooterFor(props) {
2400
- const turnId = react$1.useConversationSelector(props.store, newestWholeReply);
2400
+ const newest = react$1.useConversationSelector(props.store, newestWholeReply);
2401
+ const turnId = newest && props.canRate(newest) ? newest : null;
2401
2402
  const own = {
2402
2403
  turnId,
2403
2404
  rating: turnId ? props.state.ratings.get(turnId) : void 0,
@@ -2419,7 +2420,7 @@ function newestWholeReply(view) {
2419
2420
  return null;
2420
2421
  }
2421
2422
  function Centered(props) {
2422
- const { colors, space } = chunkOWUKWVEZ_cjs.useTheme();
2423
+ const { colors, space } = chunk6QYDPGRS_cjs.useTheme();
2423
2424
  return /* @__PURE__ */ jsxRuntime.jsx(
2424
2425
  reactNative.View,
2425
2426
  {
@@ -2435,7 +2436,7 @@ function Centered(props) {
2435
2436
  );
2436
2437
  }
2437
2438
  function Notice(props) {
2438
- const { colors, space, font } = chunkOWUKWVEZ_cjs.useTheme();
2439
+ const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
2439
2440
  return /* @__PURE__ */ jsxRuntime.jsxs(
2440
2441
  reactNative.View,
2441
2442
  {
@@ -2517,7 +2518,7 @@ function DefaultUnreachable(props) {
2517
2518
  }
2518
2519
  function AgentFooter(props) {
2519
2520
  const { t } = react$1.useCopy();
2520
- const { colors, space, font } = chunkOWUKWVEZ_cjs.useTheme();
2521
+ const { colors, space, font } = chunk6QYDPGRS_cjs.useTheme();
2521
2522
  const muted = { color: colors.textMuted, fontSize: font.size.sm };
2522
2523
  return /* @__PURE__ */ jsxRuntime.jsxs(
2523
2524
  reactNative.View,
@@ -2567,6 +2568,10 @@ Object.defineProperty(exports, "AgentRuntimeProvider", {
2567
2568
  enumerable: true,
2568
2569
  get: function () { return agent.AgentRuntimeProvider; }
2569
2570
  });
2571
+ Object.defineProperty(exports, "forgetGreeting", {
2572
+ enumerable: true,
2573
+ get: function () { return agent.forgetGreeting; }
2574
+ });
2570
2575
  Object.defineProperty(exports, "greetedKey", {
2571
2576
  enumerable: true,
2572
2577
  get: function () { return agent.greetedKey; }
@@ -2647,5 +2652,5 @@ exports.monogram = monogram;
2647
2652
  exports.newestWholeReply = newestWholeReply;
2648
2653
  exports.ratingText = ratingText;
2649
2654
  exports.useChat = useChat;
2650
- //# sourceMappingURL=chunk-H2Y2YW2Q.cjs.map
2651
- //# sourceMappingURL=chunk-H2Y2YW2Q.cjs.map
2655
+ //# sourceMappingURL=chunk-EXN5TNLU.cjs.map
2656
+ //# sourceMappingURL=chunk-EXN5TNLU.cjs.map