@vinaverse/react-native 0.1.0-alpha.11 → 0.1.0-alpha.13
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/README.md +16 -3
- package/dist/ask.cjs +10 -5
- package/dist/ask.d.cts +35 -5
- package/dist/ask.d.ts +35 -5
- package/dist/ask.js +3 -2
- package/dist/chat.cjs +69 -69
- package/dist/chat.d.cts +44 -8
- package/dist/chat.d.ts +44 -8
- package/dist/chat.js +3 -3
- package/dist/{chunk-XAG2P447.cjs → chunk-272ACDLI.cjs} +248 -104
- package/dist/chunk-272ACDLI.cjs.map +1 -0
- package/dist/{chunk-EFEXTVIT.js → chunk-35A77CNF.js} +11 -3
- package/dist/chunk-35A77CNF.js.map +1 -0
- package/dist/{chunk-NMKJ7LIJ.cjs → chunk-35T5QPMT.cjs} +31 -7
- package/dist/chunk-35T5QPMT.cjs.map +1 -0
- package/dist/{chunk-7KPCO443.js → chunk-GFD4T3IA.js} +28 -4
- package/dist/chunk-GFD4T3IA.js.map +1 -0
- package/dist/{chunk-2J2LIJLW.js → chunk-MCVW6TZD.js} +113 -33
- package/dist/chunk-MCVW6TZD.js.map +1 -0
- package/dist/{chunk-KSHDF3MG.js → chunk-QSMMC4RZ.js} +216 -74
- package/dist/chunk-QSMMC4RZ.js.map +1 -0
- package/dist/{chunk-POJP52GE.js → chunk-TY4TISCR.js} +4 -4
- package/dist/chunk-TY4TISCR.js.map +1 -0
- package/dist/{chunk-6QYDPGRS.cjs → chunk-UMCOOQT6.cjs} +11 -3
- package/dist/chunk-UMCOOQT6.cjs.map +1 -0
- package/dist/{chunk-MG32E4JI.cjs → chunk-VWAAUCE3.cjs} +11 -11
- package/dist/chunk-VWAAUCE3.cjs.map +1 -0
- package/dist/{chunk-4PXQ7DEY.cjs → chunk-YVCMKSJG.cjs} +140 -60
- package/dist/chunk-YVCMKSJG.cjs.map +1 -0
- package/dist/{context-gHCLFsJh.d.ts → context-B4ctXjm5.d.cts} +22 -1
- package/dist/{context-gHCLFsJh.d.cts → context-B4ctXjm5.d.ts} +22 -1
- package/dist/history.cjs +52 -48
- package/dist/history.cjs.map +1 -1
- package/dist/history.d.cts +12 -3
- package/dist/history.d.ts +12 -3
- package/dist/history.js +13 -9
- package/dist/history.js.map +1 -1
- package/dist/index.cjs +83 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/launcher.cjs +10 -10
- package/dist/launcher.js +2 -2
- package/package.json +7 -7
- package/dist/chunk-2J2LIJLW.js.map +0 -1
- package/dist/chunk-4PXQ7DEY.cjs.map +0 -1
- package/dist/chunk-6QYDPGRS.cjs.map +0 -1
- package/dist/chunk-7KPCO443.js.map +0 -1
- package/dist/chunk-EFEXTVIT.js.map +0 -1
- package/dist/chunk-KSHDF3MG.js.map +0 -1
- package/dist/chunk-MG32E4JI.cjs.map +0 -1
- package/dist/chunk-NMKJ7LIJ.cjs.map +0 -1
- package/dist/chunk-POJP52GE.js.map +0 -1
- package/dist/chunk-XAG2P447.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkUMCOOQT6_cjs = require('./chunk-UMCOOQT6.cjs');
|
|
4
4
|
var react = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var reactNative = require('react-native');
|
|
@@ -9,6 +9,7 @@ var conversation = require('@vinaverse/client/conversation');
|
|
|
9
9
|
var agent = require('@vinaverse/client/agent');
|
|
10
10
|
var flashList = require('@shopify/flash-list');
|
|
11
11
|
var tokens = require('@vinaverse/tokens');
|
|
12
|
+
var copy = require('@vinaverse/tokens/copy');
|
|
12
13
|
|
|
13
14
|
var ChatContext = /* @__PURE__ */ react.createContext(
|
|
14
15
|
null
|
|
@@ -25,7 +26,7 @@ function useChat() {
|
|
|
25
26
|
return value;
|
|
26
27
|
}
|
|
27
28
|
var Button = /* @__PURE__ */ react.memo(function Button2(props) {
|
|
28
|
-
const { colors, radius, space, size: size2, font } =
|
|
29
|
+
const { colors, radius, space, size: size2, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
29
30
|
const variant = props.variant ?? "secondary";
|
|
30
31
|
const inactive = props.disabled === true || props.busy === true;
|
|
31
32
|
const filled = variant === "primary" || props.selected === true;
|
|
@@ -83,7 +84,7 @@ function cardOf(held) {
|
|
|
83
84
|
return held.card;
|
|
84
85
|
}
|
|
85
86
|
function CardFrame(props) {
|
|
86
|
-
const { colors, radius, space } =
|
|
87
|
+
const { colors, radius, space } = chunkUMCOOQT6_cjs.useTheme();
|
|
87
88
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
88
89
|
reactNative.View,
|
|
89
90
|
{
|
|
@@ -111,7 +112,7 @@ function CardFrame(props) {
|
|
|
111
112
|
);
|
|
112
113
|
}
|
|
113
114
|
function Title(props) {
|
|
114
|
-
const { colors, font } =
|
|
115
|
+
const { colors, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
115
116
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
116
117
|
reactNative.Text,
|
|
117
118
|
{
|
|
@@ -128,12 +129,12 @@ function Title(props) {
|
|
|
128
129
|
);
|
|
129
130
|
}
|
|
130
131
|
function Body(props) {
|
|
131
|
-
const { colors, font } =
|
|
132
|
+
const { colors, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
132
133
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
133
134
|
reactNative.Text,
|
|
134
135
|
{
|
|
135
136
|
style: {
|
|
136
|
-
color: props.danger ? colors.danger : props.muted ? colors.
|
|
137
|
+
color: props.danger ? colors.danger : props.muted ? colors.textSecondary : colors.text,
|
|
137
138
|
fontSize: props.muted ? font.size.sm : font.size.md,
|
|
138
139
|
lineHeight: (props.muted ? font.size.sm : font.size.md) * font.lineHeight,
|
|
139
140
|
...font.family ? { fontFamily: font.family } : {}
|
|
@@ -171,7 +172,7 @@ function InfoCard(props) {
|
|
|
171
172
|
const card = cardOf(props.card);
|
|
172
173
|
const { locale, t } = react$1.useCopy();
|
|
173
174
|
const { slots, timeZone, handlers } = useChat();
|
|
174
|
-
const { colors, radius, space, font } =
|
|
175
|
+
const { colors, radius, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
175
176
|
const image = safeImage(card.image_url);
|
|
176
177
|
const Img = slots.Image ?? reactNative.Image;
|
|
177
178
|
const money = card.price ?? card.price_from;
|
|
@@ -208,7 +209,7 @@ function InfoCard(props) {
|
|
|
208
209
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: { flex: 1, gap: space.xxs }, children: [
|
|
209
210
|
/* @__PURE__ */ jsxRuntime.jsx(Title, { numberOfLines: 2, children: card.title }),
|
|
210
211
|
card.subtitle ? /* @__PURE__ */ jsxRuntime.jsx(Body, { muted: true, children: card.subtitle }) : null,
|
|
211
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.
|
|
212
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.textSecondary, fontSize: font.size.sm }, children: [
|
|
212
213
|
rating && `\u2605 ${rating}${card.rating ? ` (${card.rating.count})` : ""}`,
|
|
213
214
|
price,
|
|
214
215
|
when
|
|
@@ -245,7 +246,7 @@ function InfoCard(props) {
|
|
|
245
246
|
);
|
|
246
247
|
}
|
|
247
248
|
function Badges(props) {
|
|
248
|
-
const { colors, radius, space, font } =
|
|
249
|
+
const { colors, radius, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
249
250
|
if (!props.badges?.length) return null;
|
|
250
251
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: { flexDirection: "row", flexWrap: "wrap", gap: space.xs }, children: props.badges.map((b) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
251
252
|
reactNative.Text,
|
|
@@ -265,7 +266,7 @@ function Badges(props) {
|
|
|
265
266
|
}
|
|
266
267
|
function CardActions(props) {
|
|
267
268
|
const card = cardOf(props.card);
|
|
268
|
-
const { space } =
|
|
269
|
+
const { space } = chunkUMCOOQT6_cjs.useTheme();
|
|
269
270
|
if (!card.actions?.length) return null;
|
|
270
271
|
return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: { flexDirection: "row", flexWrap: "wrap", gap: space.sm }, children: card.actions.map((a) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
271
272
|
Action,
|
|
@@ -332,7 +333,7 @@ function ListingCard(props) {
|
|
|
332
333
|
const card = cardOf(props.card);
|
|
333
334
|
const { locale, t } = react$1.useCopy();
|
|
334
335
|
const { slots, timeZone, handlers, imagePolicy } = useChat();
|
|
335
|
-
const { colors, radius, space, font } =
|
|
336
|
+
const { colors, radius, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
336
337
|
const [failed, setFailed] = react.useState(null);
|
|
337
338
|
const photoUrl = allowedImage(
|
|
338
339
|
card.images?.[0]?.url ?? card.image_url,
|
|
@@ -395,7 +396,7 @@ function ListingCard(props) {
|
|
|
395
396
|
reactNative.Text,
|
|
396
397
|
{
|
|
397
398
|
style: {
|
|
398
|
-
color: colors.
|
|
399
|
+
color: colors.textSecondary,
|
|
399
400
|
fontSize: font.size.xl,
|
|
400
401
|
fontWeight: "600"
|
|
401
402
|
},
|
|
@@ -522,7 +523,7 @@ function ProposalCard(props) {
|
|
|
522
523
|
const proposal = card.proposal;
|
|
523
524
|
const { t, locale } = react$1.useCopy();
|
|
524
525
|
const { store, handlers, timeZone } = useChat();
|
|
525
|
-
const { colors, space, font } =
|
|
526
|
+
const { colors, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
526
527
|
const edit = useLink(proposal?.edit_deep_link, props.card);
|
|
527
528
|
if (!proposal) return null;
|
|
528
529
|
const settled = outcomeText(t, props.card.outcome, proposal.status);
|
|
@@ -567,7 +568,7 @@ function ProposalCard(props) {
|
|
|
567
568
|
reactNative.Text,
|
|
568
569
|
{
|
|
569
570
|
style: {
|
|
570
|
-
color: colors.
|
|
571
|
+
color: colors.textSecondary,
|
|
571
572
|
fontSize: font.size.sm,
|
|
572
573
|
minWidth: 72
|
|
573
574
|
},
|
|
@@ -586,7 +587,7 @@ function ProposalCard(props) {
|
|
|
586
587
|
reactNative.Text,
|
|
587
588
|
{
|
|
588
589
|
style: {
|
|
589
|
-
color: props.card.outcome === "confirmed" || proposal.status === "confirmed" ? colors.success : colors.
|
|
590
|
+
color: props.card.outcome === "confirmed" || proposal.status === "confirmed" ? colors.success : colors.textSecondary,
|
|
590
591
|
fontSize: font.size.sm,
|
|
591
592
|
fontWeight: "600"
|
|
592
593
|
},
|
|
@@ -648,7 +649,7 @@ function QuestionCard(props) {
|
|
|
648
649
|
const question = held.question;
|
|
649
650
|
const { store, handlers } = useChat();
|
|
650
651
|
const { t, locale } = react$1.useCopy();
|
|
651
|
-
const { colors, font, space } =
|
|
652
|
+
const { colors, font, space } = chunkUMCOOQT6_cjs.useTheme();
|
|
652
653
|
const needsSocket = react$1.useConversationSelector(
|
|
653
654
|
store,
|
|
654
655
|
(v) => v.answersNeedWebSocket
|
|
@@ -674,7 +675,7 @@ function QuestionCard(props) {
|
|
|
674
675
|
restored: props.restored,
|
|
675
676
|
testID: `vinaverse-question-${held.id}`,
|
|
676
677
|
children: [
|
|
677
|
-
question.progress ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.
|
|
678
|
+
question.progress ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.textSecondary, fontSize: font.size.xs }, children: t("questionStep", {
|
|
678
679
|
step: question.progress.step,
|
|
679
680
|
total: question.progress.total
|
|
680
681
|
}) }) : null,
|
|
@@ -708,7 +709,7 @@ function QuestionCard(props) {
|
|
|
708
709
|
function Answer(props) {
|
|
709
710
|
const { question, send, enabled } = props;
|
|
710
711
|
const { t } = react$1.useCopy();
|
|
711
|
-
const { space } =
|
|
712
|
+
const { space } = chunkUMCOOQT6_cjs.useTheme();
|
|
712
713
|
const { handlers } = useChat();
|
|
713
714
|
const [draft, setDraft] = react.useState({});
|
|
714
715
|
const kind = question.kind;
|
|
@@ -820,7 +821,7 @@ function ChoiceAnswer(props) {
|
|
|
820
821
|
const { question, draft, onChange, enabled } = props;
|
|
821
822
|
const { t } = react$1.useCopy();
|
|
822
823
|
const { slots } = useChat();
|
|
823
|
-
const { colors, radius, space, font } =
|
|
824
|
+
const { colors, radius, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
824
825
|
const [search, setSearch] = react.useState("");
|
|
825
826
|
const multi = question.kind === "multi_choice" || question.kind === "image_choice";
|
|
826
827
|
const values = draft.values ?? [];
|
|
@@ -832,7 +833,7 @@ function ChoiceAnswer(props) {
|
|
|
832
833
|
const q = search.trim().toLowerCase();
|
|
833
834
|
return list && q ? all.filter((o) => o.label.toLowerCase().includes(q)) : all;
|
|
834
835
|
}, [question.options, search, list]);
|
|
835
|
-
const
|
|
836
|
+
const shown2 = list ? options.slice(0, 50) : options;
|
|
836
837
|
const pick = (value) => {
|
|
837
838
|
if (none && value === none.value) return onChange({ values: [value] });
|
|
838
839
|
const rest = values.filter((v) => v !== none?.value);
|
|
@@ -865,7 +866,7 @@ function ChoiceAnswer(props) {
|
|
|
865
866
|
}
|
|
866
867
|
}
|
|
867
868
|
) : null,
|
|
868
|
-
|
|
869
|
+
shown2.map((o) => {
|
|
869
870
|
const image = question.kind === "image_choice" ? safeImage(o.image_url) : null;
|
|
870
871
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
871
872
|
Button,
|
|
@@ -926,7 +927,7 @@ function ChoiceAnswer(props) {
|
|
|
926
927
|
] });
|
|
927
928
|
}
|
|
928
929
|
function ChoiceLabel(props) {
|
|
929
|
-
const { colors, font } =
|
|
930
|
+
const { colors, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
930
931
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
931
932
|
reactNative.Text,
|
|
932
933
|
{
|
|
@@ -941,7 +942,7 @@ function ChoiceLabel(props) {
|
|
|
941
942
|
}
|
|
942
943
|
function OtherText(props) {
|
|
943
944
|
const { t } = react$1.useCopy();
|
|
944
|
-
const { colors, radius, space, font } =
|
|
945
|
+
const { colors, radius, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
945
946
|
const on = props.value !== void 0;
|
|
946
947
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: { gap: space.xs }, children: [
|
|
947
948
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -980,14 +981,14 @@ function OtherText(props) {
|
|
|
980
981
|
}
|
|
981
982
|
function CharactersLeft(props) {
|
|
982
983
|
const { t } = react$1.useCopy();
|
|
983
|
-
const { colors, font } =
|
|
984
|
+
const { colors, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
984
985
|
const left = props.max - conversation.codePoints(props.text);
|
|
985
986
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
986
987
|
reactNative.Text,
|
|
987
988
|
{
|
|
988
989
|
accessibilityLiveRegion: left < 20 ? "polite" : "none",
|
|
989
990
|
style: {
|
|
990
|
-
color: left < 0 ? colors.danger : colors.
|
|
991
|
+
color: left < 0 ? colors.danger : colors.textSecondary,
|
|
991
992
|
fontSize: font.size.xs
|
|
992
993
|
},
|
|
993
994
|
children: t("questionCharactersLeft", { count: left })
|
|
@@ -995,7 +996,7 @@ function CharactersLeft(props) {
|
|
|
995
996
|
);
|
|
996
997
|
}
|
|
997
998
|
function TextAnswer(props) {
|
|
998
|
-
const { colors, radius, space, font } =
|
|
999
|
+
const { colors, radius, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
999
1000
|
const long = props.question.kind === "long_text";
|
|
1000
1001
|
const max = props.question.text?.max_length ?? (long ? 2e3 : 200);
|
|
1001
1002
|
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: { gap: space.xs }, children: [
|
|
@@ -1026,10 +1027,10 @@ function TextAnswer(props) {
|
|
|
1026
1027
|
}
|
|
1027
1028
|
function NumberAnswer(props) {
|
|
1028
1029
|
const range = props.question.number ?? { min: 0, max: 100, step: 1 };
|
|
1029
|
-
const { colors, space, font } =
|
|
1030
|
+
const { colors, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
1030
1031
|
const value = props.value ?? range.min;
|
|
1031
1032
|
const clamp = (n) => Math.min(range.max, Math.max(range.min, Number(n.toFixed(6))));
|
|
1032
|
-
const
|
|
1033
|
+
const shown2 = `${value}${props.question.number?.unit ? ` ${props.question.number.unit}` : ""}`;
|
|
1033
1034
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1034
1035
|
reactNative.View,
|
|
1035
1036
|
{
|
|
@@ -1040,7 +1041,7 @@ function NumberAnswer(props) {
|
|
|
1040
1041
|
min: range.min,
|
|
1041
1042
|
max: range.max,
|
|
1042
1043
|
now: value,
|
|
1043
|
-
text:
|
|
1044
|
+
text: shown2
|
|
1044
1045
|
},
|
|
1045
1046
|
accessibilityActions: [{ name: "increment" }, { name: "decrement" }],
|
|
1046
1047
|
testID: "vinaverse-question-number",
|
|
@@ -1068,7 +1069,7 @@ function NumberAnswer(props) {
|
|
|
1068
1069
|
minWidth: 64,
|
|
1069
1070
|
textAlign: "center"
|
|
1070
1071
|
},
|
|
1071
|
-
children:
|
|
1072
|
+
children: shown2
|
|
1072
1073
|
}
|
|
1073
1074
|
),
|
|
1074
1075
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1085,7 +1086,7 @@ function NumberAnswer(props) {
|
|
|
1085
1086
|
}
|
|
1086
1087
|
function ScaleAnswer(props) {
|
|
1087
1088
|
const scale = props.question.scale;
|
|
1088
|
-
const { colors, space, font } =
|
|
1089
|
+
const { colors, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
1089
1090
|
if (!scale) return null;
|
|
1090
1091
|
const points = [];
|
|
1091
1092
|
for (let n = scale.min; n <= scale.max && points.length < 21; n += scale.step)
|
|
@@ -1102,15 +1103,15 @@ function ScaleAnswer(props) {
|
|
|
1102
1103
|
n
|
|
1103
1104
|
)) }),
|
|
1104
1105
|
/* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: { flexDirection: "row", justifyContent: "space-between" }, children: [
|
|
1105
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.
|
|
1106
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.
|
|
1106
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.textSecondary, fontSize: font.size.xs }, children: scale.min_label }),
|
|
1107
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: colors.textSecondary, fontSize: font.size.xs }, children: scale.max_label })
|
|
1107
1108
|
] })
|
|
1108
1109
|
] });
|
|
1109
1110
|
}
|
|
1110
1111
|
var iso = (y, m, d) => `${String(y).padStart(4, "0")}-${String(m + 1).padStart(2, "0")}-${String(d).padStart(2, "0")}`;
|
|
1111
1112
|
function DateAnswer(props) {
|
|
1112
1113
|
const { locale } = react$1.useCopy();
|
|
1113
|
-
const { colors, space, font } =
|
|
1114
|
+
const { colors, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
1114
1115
|
const bounds = props.question.date;
|
|
1115
1116
|
const start = props.value ?? bounds?.min ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
1116
1117
|
const [month, setMonth] = react.useState(() => ({
|
|
@@ -1194,7 +1195,7 @@ function DateAnswer(props) {
|
|
|
1194
1195
|
function RateEach(props) {
|
|
1195
1196
|
const { question } = props;
|
|
1196
1197
|
const { t } = react$1.useCopy();
|
|
1197
|
-
const { colors, space, font } =
|
|
1198
|
+
const { colors, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
1198
1199
|
const answered = new Map(
|
|
1199
1200
|
(question.row_answers ?? []).map((r) => [
|
|
1200
1201
|
r.question_id,
|
|
@@ -1275,7 +1276,7 @@ function TimeSlotsCard(props) {
|
|
|
1275
1276
|
const card = cardOf(props.card);
|
|
1276
1277
|
const { locale } = react$1.useCopy();
|
|
1277
1278
|
const { timeZone } = useChat();
|
|
1278
|
-
const { colors, radius, space, font } =
|
|
1279
|
+
const { colors, radius, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
1279
1280
|
const slots = (card.slots ?? []).map(
|
|
1280
1281
|
(s) => react$1.formatTimeRange(s.start, s.end, locale, timeZone)
|
|
1281
1282
|
);
|
|
@@ -1366,7 +1367,7 @@ function CardCarousel(props) {
|
|
|
1366
1367
|
var ActivityLine = /* @__PURE__ */ react.memo(function ActivityLine2() {
|
|
1367
1368
|
const { store } = useChat();
|
|
1368
1369
|
const { t } = react$1.useCopy();
|
|
1369
|
-
const { colors, space, font } =
|
|
1370
|
+
const { colors, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
1370
1371
|
const activity = react$1.useConversationSelector(store, (v) => v.activity);
|
|
1371
1372
|
const waiting = react$1.useConversationSelector(
|
|
1372
1373
|
store,
|
|
@@ -1386,7 +1387,7 @@ var ActivityLine = /* @__PURE__ */ react.memo(function ActivityLine2() {
|
|
|
1386
1387
|
);
|
|
1387
1388
|
});
|
|
1388
1389
|
var Avatar = /* @__PURE__ */ react.memo(function Avatar2(props) {
|
|
1389
|
-
const { colors, size: size2, font } =
|
|
1390
|
+
const { colors, size: size2, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
1390
1391
|
const { slots } = useChat();
|
|
1391
1392
|
const box = {
|
|
1392
1393
|
width: size2.avatar,
|
|
@@ -1432,7 +1433,7 @@ var Avatar = /* @__PURE__ */ react.memo(function Avatar2(props) {
|
|
|
1432
1433
|
);
|
|
1433
1434
|
});
|
|
1434
1435
|
function DefaultHeader(props) {
|
|
1435
|
-
const { colors, space, font } =
|
|
1436
|
+
const { colors, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
1436
1437
|
const { t } = react$1.useCopy();
|
|
1437
1438
|
const person = props.takeoverBy !== null;
|
|
1438
1439
|
const subtitle = person ? t("staffLabel", { by: props.takeoverBy || t("staffFallbackRole") }) : t("agentLabel");
|
|
@@ -1498,9 +1499,10 @@ var ChatHeader = /* @__PURE__ */ react.memo(function ChatHeader2() {
|
|
|
1498
1499
|
return Header ? /* @__PURE__ */ jsxRuntime.jsx(Header, { ...props, Default: DefaultHeader }) : /* @__PURE__ */ jsxRuntime.jsx(DefaultHeader, { ...props });
|
|
1499
1500
|
});
|
|
1500
1501
|
var DisclosureBar = /* @__PURE__ */ react.memo(function DisclosureBar2() {
|
|
1501
|
-
const { store } = useChat();
|
|
1502
|
+
const { store, disclosure: given } = useChat();
|
|
1503
|
+
const held = given && copy.isDisclosure(given) ? given : void 0;
|
|
1502
1504
|
const { t } = react$1.useCopy();
|
|
1503
|
-
const theme =
|
|
1505
|
+
const theme = chunkUMCOOQT6_cjs.useTheme();
|
|
1504
1506
|
const { space, font } = theme;
|
|
1505
1507
|
const disclosure = react$1.useConversationSelector(store, (v) => v.disclosure);
|
|
1506
1508
|
const [open, setOpen] = react.useState(false);
|
|
@@ -1509,12 +1511,20 @@ var DisclosureBar = /* @__PURE__ */ react.memo(function DisclosureBar2() {
|
|
|
1509
1511
|
theme.colors.disclosureBackground
|
|
1510
1512
|
) >= 4.5;
|
|
1511
1513
|
const pair = legible ? theme.colors : tokens.colors(theme.scheme);
|
|
1512
|
-
const text = disclosure ?? t("disclosureFallback");
|
|
1513
|
-
|
|
1514
|
+
const text = disclosure ?? held ?? t("disclosureFallback");
|
|
1515
|
+
const { rest, brand } = splitBrand(text);
|
|
1516
|
+
const centered = {
|
|
1517
|
+
color: pair.disclosureText,
|
|
1518
|
+
// never below the disclosure's minimum, whatever the tenant's type scale
|
|
1519
|
+
fontSize: Math.max(font.size.xs, tokens.size.disclosureFontMin),
|
|
1520
|
+
lineHeight: Math.max(font.size.xs, tokens.size.disclosureFontMin) * font.lineHeight,
|
|
1521
|
+
textAlign: "center"
|
|
1522
|
+
};
|
|
1523
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1514
1524
|
reactNative.Pressable,
|
|
1515
1525
|
{
|
|
1516
1526
|
accessibilityRole: "text",
|
|
1517
|
-
accessibilityLabel: text,
|
|
1527
|
+
accessibilityLabel: brand ? [rest, `${brand}.`].filter(Boolean).join(" ") : text,
|
|
1518
1528
|
onPress: () => setOpen((o) => !o),
|
|
1519
1529
|
testID: "vinaverse-disclosure",
|
|
1520
1530
|
style: {
|
|
@@ -1522,24 +1532,43 @@ var DisclosureBar = /* @__PURE__ */ react.memo(function DisclosureBar2() {
|
|
|
1522
1532
|
paddingHorizontal: space.lg,
|
|
1523
1533
|
paddingVertical: space.xs
|
|
1524
1534
|
},
|
|
1525
|
-
children:
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1535
|
+
children: [
|
|
1536
|
+
rest ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1537
|
+
reactNative.Text,
|
|
1538
|
+
{
|
|
1539
|
+
numberOfLines: open ? void 0 : 2,
|
|
1540
|
+
style: held && !open ? [centered, { minHeight: 2 * centered.lineHeight }] : centered,
|
|
1541
|
+
children: rest
|
|
1542
|
+
}
|
|
1543
|
+
) : null,
|
|
1544
|
+
brand ? (
|
|
1545
|
+
// Its own line, one unit that never breaks ("Powered by / Vinaverse"), the brand's name in emphasis.
|
|
1546
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1547
|
+
reactNative.Text,
|
|
1548
|
+
{
|
|
1549
|
+
numberOfLines: 1,
|
|
1550
|
+
adjustsFontSizeToFit: true,
|
|
1551
|
+
minimumFontScale: tokens.size.disclosureFontMin / centered.fontSize,
|
|
1552
|
+
style: centered,
|
|
1553
|
+
testID: "vinaverse-powered-by",
|
|
1554
|
+
children: [
|
|
1555
|
+
nobreak(brand.slice(0, -9)),
|
|
1556
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { fontWeight: "600" }, children: "Vinaverse" })
|
|
1557
|
+
]
|
|
1558
|
+
}
|
|
1559
|
+
)
|
|
1560
|
+
) : null
|
|
1561
|
+
]
|
|
1538
1562
|
}
|
|
1539
1563
|
);
|
|
1540
1564
|
});
|
|
1565
|
+
var nobreak = (s) => s.replace(/ /g, "\xA0");
|
|
1566
|
+
function splitBrand(text) {
|
|
1567
|
+
const m = /^([\s\S]*?[.!?])?\s*([^.!?]*Vinaverse)[.!]?$/.exec(text.trim());
|
|
1568
|
+
return m ? { rest: m[1] ?? "", brand: m[2].trim() } : { rest: text.trim(), brand: "" };
|
|
1569
|
+
}
|
|
1541
1570
|
var ChatSkeleton = /* @__PURE__ */ react.memo(function ChatSkeleton2() {
|
|
1542
|
-
const { colors, radius, space } =
|
|
1571
|
+
const { colors, radius, space } = chunkUMCOOQT6_cjs.useTheme();
|
|
1543
1572
|
const row = (width, end) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1544
1573
|
reactNative.View,
|
|
1545
1574
|
{
|
|
@@ -1570,7 +1599,7 @@ var ChatSkeleton = /* @__PURE__ */ react.memo(function ChatSkeleton2() {
|
|
|
1570
1599
|
);
|
|
1571
1600
|
});
|
|
1572
1601
|
function DefaultBubble(props) {
|
|
1573
|
-
const { colors, radius, space, font } =
|
|
1602
|
+
const { colors, radius, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
1574
1603
|
const role = props.item.role;
|
|
1575
1604
|
const [background, foreground] = role === "person" ? [colors.personBubble, colors.personText] : role === "staff" ? [colors.staffBubble, colors.staffText] : [colors.agentBubble, colors.agentText];
|
|
1576
1605
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1623,10 +1652,11 @@ var StreamingBubble = /* @__PURE__ */ react.memo(
|
|
|
1623
1652
|
);
|
|
1624
1653
|
function Frame(props) {
|
|
1625
1654
|
const { item, text } = props;
|
|
1626
|
-
const { store, slots } = useChat();
|
|
1627
|
-
const { t } = react$1.useCopy();
|
|
1628
|
-
const { colors, space, font } =
|
|
1655
|
+
const { store, slots, timeZone, messageTimes } = useChat();
|
|
1656
|
+
const { t, locale } = react$1.useCopy();
|
|
1657
|
+
const { colors, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
1629
1658
|
const author = useAuthor(item);
|
|
1659
|
+
const when = item.at && messageTimes !== null ? react$1.formatDateTime(item.at, locale, timeZone) : null;
|
|
1630
1660
|
const mine = item.role === "person";
|
|
1631
1661
|
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;
|
|
1632
1662
|
const Bubble = slots.MessageBubble;
|
|
@@ -1635,7 +1665,7 @@ function Frame(props) {
|
|
|
1635
1665
|
reactNative.View,
|
|
1636
1666
|
{
|
|
1637
1667
|
accessible: true,
|
|
1638
|
-
accessibilityLabel: [author, text, status].filter(Boolean).join(". "),
|
|
1668
|
+
accessibilityLabel: [author, text, status, when].filter(Boolean).join(". "),
|
|
1639
1669
|
style: {
|
|
1640
1670
|
alignSelf: mine ? "flex-end" : "flex-start",
|
|
1641
1671
|
maxWidth: "85%",
|
|
@@ -1648,7 +1678,7 @@ function Frame(props) {
|
|
|
1648
1678
|
reactNative.Text,
|
|
1649
1679
|
{
|
|
1650
1680
|
style: {
|
|
1651
|
-
color: item.role === "staff" ? colors.staffAccent : colors.
|
|
1681
|
+
color: item.role === "staff" ? colors.staffAccent : colors.textSecondary,
|
|
1652
1682
|
fontSize: font.size.xs,
|
|
1653
1683
|
marginBottom: space.xxs
|
|
1654
1684
|
},
|
|
@@ -1671,7 +1701,7 @@ function Frame(props) {
|
|
|
1671
1701
|
reactNative.Text,
|
|
1672
1702
|
{
|
|
1673
1703
|
style: {
|
|
1674
|
-
color: item.state === "not_sent" ? colors.danger : colors.
|
|
1704
|
+
color: item.state === "not_sent" ? colors.danger : colors.textSecondary,
|
|
1675
1705
|
fontSize: font.size.xs
|
|
1676
1706
|
},
|
|
1677
1707
|
children: status
|
|
@@ -1767,7 +1797,7 @@ function DefaultTurnFailed(props) {
|
|
|
1767
1797
|
] });
|
|
1768
1798
|
}
|
|
1769
1799
|
function Line(props) {
|
|
1770
|
-
const { colors, space, font } =
|
|
1800
|
+
const { colors, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
1771
1801
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1772
1802
|
reactNative.View,
|
|
1773
1803
|
{
|
|
@@ -1793,7 +1823,7 @@ function Line(props) {
|
|
|
1793
1823
|
);
|
|
1794
1824
|
}
|
|
1795
1825
|
var Welcome = /* @__PURE__ */ react.memo(function Welcome2(props) {
|
|
1796
|
-
const { colors, radius, space, font } =
|
|
1826
|
+
const { colors, radius, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
1797
1827
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1798
1828
|
reactNative.View,
|
|
1799
1829
|
{
|
|
@@ -1829,6 +1859,34 @@ var Welcome = /* @__PURE__ */ react.memo(function Welcome2(props) {
|
|
|
1829
1859
|
}
|
|
1830
1860
|
);
|
|
1831
1861
|
});
|
|
1862
|
+
function messageTimeLabel(at, locale, timeZone, now) {
|
|
1863
|
+
return Number.isNaN(Date.parse(at)) ? "" : react$1.formatDayTime(at, TODAY, locale, timeZone, now);
|
|
1864
|
+
}
|
|
1865
|
+
var TODAY = { today: "{time}", tomorrow: "" };
|
|
1866
|
+
var MessageTime = /* @__PURE__ */ react.memo(function MessageTime2(props) {
|
|
1867
|
+
const { slots, timeZone } = useChat();
|
|
1868
|
+
const { locale } = react$1.useCopy();
|
|
1869
|
+
const { colors, space, font } = chunkUMCOOQT6_cjs.useTheme();
|
|
1870
|
+
const label = messageTimeLabel(props.at, locale, timeZone);
|
|
1871
|
+
if (!label) return null;
|
|
1872
|
+
const Slot = slots.MessageTime;
|
|
1873
|
+
if (Slot) return /* @__PURE__ */ jsxRuntime.jsx(Slot, { at: props.at, label });
|
|
1874
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1875
|
+
reactNative.Text,
|
|
1876
|
+
{
|
|
1877
|
+
accessibilityElementsHidden: true,
|
|
1878
|
+
importantForAccessibility: "no",
|
|
1879
|
+
testID: "vinaverse-message-time",
|
|
1880
|
+
style: {
|
|
1881
|
+
alignSelf: "center",
|
|
1882
|
+
color: colors.textSecondary,
|
|
1883
|
+
fontSize: font.size.xs,
|
|
1884
|
+
marginTop: space.md
|
|
1885
|
+
},
|
|
1886
|
+
children: label
|
|
1887
|
+
}
|
|
1888
|
+
);
|
|
1889
|
+
});
|
|
1832
1890
|
var keyOf2 = (item) => item.key;
|
|
1833
1891
|
function itemType(item) {
|
|
1834
1892
|
if (item.type === "card") return `card:${item.card.kind}`;
|
|
@@ -1836,6 +1894,16 @@ function itemType(item) {
|
|
|
1836
1894
|
return item.state === "streaming" ? "streaming" : `message:${item.role}`;
|
|
1837
1895
|
return "system";
|
|
1838
1896
|
}
|
|
1897
|
+
function timeOver(items, index, gap) {
|
|
1898
|
+
const item = items[index];
|
|
1899
|
+
if (gap === null || item?.type !== "message") return void 0;
|
|
1900
|
+
let before;
|
|
1901
|
+
for (let i = index - 1; i >= 0 && !before; i--) {
|
|
1902
|
+
const earlier = items[i];
|
|
1903
|
+
if (earlier?.type === "message") before = earlier.at;
|
|
1904
|
+
}
|
|
1905
|
+
return item.at && (!before || Date.parse(item.at) - Date.parse(before) > (gap ?? 10) * 6e4) ? item.at : void 0;
|
|
1906
|
+
}
|
|
1839
1907
|
function authorOf(item) {
|
|
1840
1908
|
return item?.type === "message" ? item.role : null;
|
|
1841
1909
|
}
|
|
@@ -1872,30 +1940,79 @@ var Row = /* @__PURE__ */ react.memo(function Row2(props) {
|
|
|
1872
1940
|
if (props.run && Group) return /* @__PURE__ */ jsxRuntime.jsx(Group, { items: props.run });
|
|
1873
1941
|
if (item.type === "card") return /* @__PURE__ */ jsxRuntime.jsx(CardView, { item });
|
|
1874
1942
|
if (item.type === "system") return /* @__PURE__ */ jsxRuntime.jsx(SystemRow, { item });
|
|
1875
|
-
|
|
1943
|
+
const bubble = item.state === "streaming" ? /* @__PURE__ */ jsxRuntime.jsx(StreamingBubble, { item, showAuthor: props.showAuthor }) : /* @__PURE__ */ jsxRuntime.jsx(MessageBubble, { item, showAuthor: props.showAuthor });
|
|
1944
|
+
return props.time ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1945
|
+
/* @__PURE__ */ jsxRuntime.jsx(MessageTime, { at: props.time }),
|
|
1946
|
+
bubble
|
|
1947
|
+
] }) : bubble;
|
|
1876
1948
|
});
|
|
1949
|
+
var opened = /* @__PURE__ */ new WeakSet();
|
|
1950
|
+
var shown = /* @__PURE__ */ new WeakMap();
|
|
1951
|
+
var looked = /* @__PURE__ */ new WeakMap();
|
|
1877
1952
|
var MessageList = /* @__PURE__ */ react.memo(function MessageList2() {
|
|
1878
|
-
const {
|
|
1953
|
+
const {
|
|
1954
|
+
store,
|
|
1955
|
+
slots,
|
|
1956
|
+
starters,
|
|
1957
|
+
handlers,
|
|
1958
|
+
imagePolicy,
|
|
1959
|
+
welcomeChips,
|
|
1960
|
+
messageTimes,
|
|
1961
|
+
listHeader
|
|
1962
|
+
} = useChat();
|
|
1879
1963
|
const { t } = react$1.useCopy();
|
|
1880
|
-
const { space } =
|
|
1881
|
-
const reducedMotion =
|
|
1964
|
+
const { space } = chunkUMCOOQT6_cjs.useTheme();
|
|
1965
|
+
const reducedMotion = chunkUMCOOQT6_cjs.useReducedMotion();
|
|
1882
1966
|
const items = react$1.useConversationSelector(store, (v) => v.items);
|
|
1883
|
-
usePrefetchPhotos(
|
|
1884
|
-
|
|
1967
|
+
usePrefetchPhotos(
|
|
1968
|
+
store,
|
|
1969
|
+
items,
|
|
1970
|
+
handlers.current?.prefetchImage,
|
|
1971
|
+
imagePolicy?.hosts
|
|
1972
|
+
);
|
|
1973
|
+
const restoring = react$1.useConversationSelector(
|
|
1974
|
+
store,
|
|
1975
|
+
(v) => v.history === "restoring"
|
|
1976
|
+
);
|
|
1977
|
+
const fetching = react$1.useConversationSelector(
|
|
1978
|
+
store,
|
|
1979
|
+
(v) => v.status === "starting" || v.status === "connecting" || v.status === "reconnecting"
|
|
1980
|
+
);
|
|
1981
|
+
const live = react$1.useConversationSelector(
|
|
1982
|
+
store,
|
|
1983
|
+
(v) => v.status === "ready" || v.status === "sse"
|
|
1984
|
+
);
|
|
1985
|
+
const over = react$1.useConversationSelector(
|
|
1885
1986
|
store,
|
|
1886
|
-
(v) => v.status === "
|
|
1987
|
+
(v) => v.status === "ended" || v.status === "closed"
|
|
1887
1988
|
);
|
|
1989
|
+
const [settled, setSettled] = react.useState(null);
|
|
1990
|
+
react.useEffect(() => setSettled(store), [store]);
|
|
1991
|
+
const waiting = restoring || fetching || !live && !over && settled !== store;
|
|
1992
|
+
if (live) opened.add(store);
|
|
1888
1993
|
const agentName = react$1.useConversationSelector(store, (v) => v.agent.name);
|
|
1889
1994
|
const served = react$1.useConversationSelector(store, (v) => v.welcome);
|
|
1890
|
-
const welcome = react.useMemo(
|
|
1891
|
-
()
|
|
1995
|
+
const welcome = react.useMemo(() => {
|
|
1996
|
+
const w = restoring ? null : served && opened.has(store) ? served : waiting ? null : served ?? {
|
|
1892
1997
|
text: t("welcomeFallback", {
|
|
1893
1998
|
agent: agentName ?? t("agentFallbackName")
|
|
1894
1999
|
}),
|
|
1895
|
-
chips: [...starters]
|
|
1896
|
-
}
|
|
1897
|
-
|
|
1898
|
-
|
|
2000
|
+
chips: starters ? [...starters] : []
|
|
2001
|
+
};
|
|
2002
|
+
return w && welcomeChips === false ? { ...w, chips: [] } : w;
|
|
2003
|
+
}, [
|
|
2004
|
+
store,
|
|
2005
|
+
live,
|
|
2006
|
+
restoring,
|
|
2007
|
+
served,
|
|
2008
|
+
waiting,
|
|
2009
|
+
starters,
|
|
2010
|
+
t,
|
|
2011
|
+
agentName,
|
|
2012
|
+
welcomeChips
|
|
2013
|
+
]);
|
|
2014
|
+
if (welcome) shown.set(store, welcome);
|
|
2015
|
+
const said = welcome ?? shown.get(store) ?? null;
|
|
1899
2016
|
useAnnounceReplies(items);
|
|
1900
2017
|
const Group = slots.CardGroup;
|
|
1901
2018
|
const runsRef = react.useRef(/* @__PURE__ */ new Map());
|
|
@@ -1908,6 +2025,8 @@ var MessageList = /* @__PURE__ */ react.memo(function MessageList2() {
|
|
|
1908
2025
|
itemsRef.current = items;
|
|
1909
2026
|
const groupingRef = react.useRef(grouping);
|
|
1910
2027
|
groupingRef.current = grouping;
|
|
2028
|
+
const gapRef = react.useRef(messageTimes);
|
|
2029
|
+
gapRef.current = messageTimes;
|
|
1911
2030
|
const renderItem = react.useCallback(
|
|
1912
2031
|
({ item, index }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1913
2032
|
Row,
|
|
@@ -1915,7 +2034,8 @@ var MessageList = /* @__PURE__ */ react.memo(function MessageList2() {
|
|
|
1915
2034
|
item,
|
|
1916
2035
|
showAuthor: authorOf(item) !== authorOf(itemsRef.current[index - 1]),
|
|
1917
2036
|
run: groupingRef.current?.runs.get(item.key),
|
|
1918
|
-
inside: groupingRef.current?.inside.has(item.key) === true
|
|
2037
|
+
inside: groupingRef.current?.inside.has(item.key) === true,
|
|
2038
|
+
time: timeOver(itemsRef.current, index, gapRef.current)
|
|
1919
2039
|
}
|
|
1920
2040
|
),
|
|
1921
2041
|
[]
|
|
@@ -1923,20 +2043,23 @@ var MessageList = /* @__PURE__ */ react.memo(function MessageList2() {
|
|
|
1923
2043
|
const onChip = react.useCallback(
|
|
1924
2044
|
(message) => {
|
|
1925
2045
|
store.send(message);
|
|
1926
|
-
const chip =
|
|
2046
|
+
const chip = said?.chips.find((c) => c.message === message);
|
|
1927
2047
|
if (chip) handlers.current?.onChip?.(chip);
|
|
1928
2048
|
},
|
|
1929
|
-
[store,
|
|
2049
|
+
[store, said, handlers]
|
|
1930
2050
|
);
|
|
1931
2051
|
const Empty = slots.EmptyState;
|
|
1932
|
-
const empty =
|
|
1933
|
-
Empty
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
2052
|
+
const empty = react.useMemo(
|
|
2053
|
+
() => !said ? /* @__PURE__ */ jsxRuntime.jsx(ChatSkeleton, {}) : Empty ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2054
|
+
Empty,
|
|
2055
|
+
{
|
|
2056
|
+
agentName: agentName ?? t("agentFallbackName"),
|
|
2057
|
+
welcome: said,
|
|
2058
|
+
onChip
|
|
2059
|
+
}
|
|
2060
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(Welcome, { welcome: said, onChip }),
|
|
2061
|
+
[said, Empty, agentName, t, onChip]
|
|
2062
|
+
);
|
|
1940
2063
|
const props = react.useMemo(
|
|
1941
2064
|
() => ({
|
|
1942
2065
|
data: items,
|
|
@@ -1948,30 +2071,49 @@ var MessageList = /* @__PURE__ */ react.memo(function MessageList2() {
|
|
|
1948
2071
|
autoscrollToBottomThreshold: 0.2,
|
|
1949
2072
|
animateAutoScrollToBottom: !reducedMotion
|
|
1950
2073
|
},
|
|
2074
|
+
ListHeaderComponent: listHeader ?? null,
|
|
1951
2075
|
ListFooterComponent: /* @__PURE__ */ jsxRuntime.jsx(ActivityLine, {}),
|
|
1952
2076
|
ListEmptyComponent: empty,
|
|
1953
2077
|
keyboardShouldPersistTaps: "handled",
|
|
1954
|
-
contentContainerStyle: { paddingVertical: space.sm }
|
|
2078
|
+
contentContainerStyle: { paddingVertical: space.sm },
|
|
2079
|
+
extraData: messageTimes
|
|
1955
2080
|
}),
|
|
1956
|
-
[
|
|
2081
|
+
[
|
|
2082
|
+
items,
|
|
2083
|
+
renderItem,
|
|
2084
|
+
reducedMotion,
|
|
2085
|
+
empty,
|
|
2086
|
+
space.sm,
|
|
2087
|
+
messageTimes,
|
|
2088
|
+
listHeader
|
|
2089
|
+
]
|
|
1957
2090
|
);
|
|
1958
2091
|
const List = slots.ListComponent;
|
|
1959
|
-
return
|
|
2092
|
+
return react.useMemo(
|
|
2093
|
+
() => List ? /* @__PURE__ */ jsxRuntime.jsx(List, { ...props }) : /* @__PURE__ */ jsxRuntime.jsx(flashList.FlashList, { ...props }),
|
|
2094
|
+
[List, props]
|
|
2095
|
+
);
|
|
1960
2096
|
});
|
|
1961
|
-
|
|
1962
|
-
|
|
2097
|
+
var PREFETCH_ON_OPENING = 3;
|
|
2098
|
+
function usePrefetchPhotos(store, items, prefetch, hosts) {
|
|
1963
2099
|
react.useEffect(() => {
|
|
1964
2100
|
if (!prefetch) return;
|
|
1965
|
-
|
|
1966
|
-
|
|
2101
|
+
const seen = looked.get(store) ?? /* @__PURE__ */ new Set();
|
|
2102
|
+
looked.set(store, seen);
|
|
2103
|
+
let left = seen.size ? Number.POSITIVE_INFINITY : PREFETCH_ON_OPENING;
|
|
2104
|
+
for (let i = items.length - 1; i >= 0 && left > 0; i--) {
|
|
2105
|
+
const item = items[i];
|
|
2106
|
+
if (item?.type !== "card") continue;
|
|
2107
|
+
if (seen.has(item.key)) break;
|
|
2108
|
+
seen.add(item.key);
|
|
1967
2109
|
const card = item.card.card;
|
|
1968
2110
|
const url = allowedImage(card.images?.[0]?.url ?? card.image_url, hosts);
|
|
1969
|
-
if (url
|
|
1970
|
-
done.current.add(url);
|
|
2111
|
+
if (url) {
|
|
1971
2112
|
prefetch(url);
|
|
2113
|
+
left--;
|
|
1972
2114
|
}
|
|
1973
2115
|
}
|
|
1974
|
-
}, [items, prefetch, hosts]);
|
|
2116
|
+
}, [store, items, prefetch, hosts]);
|
|
1975
2117
|
}
|
|
1976
2118
|
function useAnnounceReplies(items) {
|
|
1977
2119
|
const seen = react.useRef(void 0);
|
|
@@ -1989,12 +2131,13 @@ function useAnnounceReplies(items) {
|
|
|
1989
2131
|
const author = last.role === "staff" ? t("staffLabel", {
|
|
1990
2132
|
by: store.getSnapshot().takeover?.by || t("staffFallbackRole")
|
|
1991
2133
|
}) : store.getSnapshot().agent.name ?? t("agentFallbackName");
|
|
1992
|
-
(handlers.current?.announce ??
|
|
2134
|
+
(handlers.current?.announce ?? chunkUMCOOQT6_cjs.announce)(`${author}: ${last.text}`);
|
|
1993
2135
|
}, [items, t, store, handlers]);
|
|
1994
2136
|
}
|
|
1995
2137
|
|
|
1996
2138
|
exports.ActivityLine = ActivityLine;
|
|
1997
2139
|
exports.Avatar = Avatar;
|
|
2140
|
+
exports.Body = Body;
|
|
1998
2141
|
exports.Button = Button;
|
|
1999
2142
|
exports.CardActions = CardActions;
|
|
2000
2143
|
exports.CardCarousel = CardCarousel;
|
|
@@ -2021,6 +2164,7 @@ exports.Row = Row;
|
|
|
2021
2164
|
exports.StreamingBubble = StreamingBubble;
|
|
2022
2165
|
exports.SystemRow = SystemRow;
|
|
2023
2166
|
exports.TimeSlotsCard = TimeSlotsCard;
|
|
2167
|
+
exports.Title = Title;
|
|
2024
2168
|
exports.Welcome = Welcome;
|
|
2025
2169
|
exports.allowedImage = allowedImage;
|
|
2026
2170
|
exports.answerText = answerText;
|
|
@@ -2031,5 +2175,5 @@ exports.itemType = itemType;
|
|
|
2031
2175
|
exports.monogram = monogram;
|
|
2032
2176
|
exports.ratingText = ratingText;
|
|
2033
2177
|
exports.useChat = useChat;
|
|
2034
|
-
//# sourceMappingURL=chunk-
|
|
2035
|
-
//# sourceMappingURL=chunk-
|
|
2178
|
+
//# sourceMappingURL=chunk-272ACDLI.cjs.map
|
|
2179
|
+
//# sourceMappingURL=chunk-272ACDLI.cjs.map
|