vdb-ai-chat 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/10.chat-widget.js +2 -0
- package/dist/10.chat-widget.js.LICENSE.txt +1 -0
- package/dist/104.chat-widget.js +1 -0
- package/dist/50.chat-widget.js +1 -0
- package/dist/521.chat-widget.js +1 -0
- package/dist/538.chat-widget.js +1 -1
- package/dist/572.chat-widget.js +1 -0
- package/dist/694.chat-widget.js +1 -0
- package/dist/chat-widget.js +1 -1
- package/lib/commonjs/api.js +4 -3
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/components/BetaNotice.js +38 -0
- package/lib/commonjs/components/BetaNotice.js.map +1 -0
- package/lib/commonjs/components/ChatHeader.js +27 -20
- package/lib/commonjs/components/ChatHeader.js.map +1 -1
- package/lib/commonjs/components/ChatInput.js +20 -21
- package/lib/commonjs/components/ChatInput.js.map +1 -1
- package/lib/commonjs/components/ChatWidget.js +165 -92
- package/lib/commonjs/components/ChatWidget.js.map +1 -1
- package/lib/commonjs/components/LazyProductsFetcher.js +47 -0
- package/lib/commonjs/components/LazyProductsFetcher.js.map +1 -0
- package/lib/commonjs/components/MessageBubble.js +26 -90
- package/lib/commonjs/components/MessageBubble.js.map +1 -1
- package/lib/commonjs/components/MessageMetaRow.js +113 -0
- package/lib/commonjs/components/MessageMetaRow.js.map +1 -0
- package/lib/commonjs/components/ProductsGrid.js +139 -0
- package/lib/commonjs/components/ProductsGrid.js.map +1 -0
- package/lib/commonjs/components/ProductsList.js +22 -126
- package/lib/commonjs/components/ProductsList.js.map +1 -1
- package/lib/commonjs/components/ProductsListView.js +139 -0
- package/lib/commonjs/components/ProductsListView.js.map +1 -0
- package/lib/commonjs/components/SuggestionsRow.js +50 -27
- package/lib/commonjs/components/SuggestionsRow.js.map +1 -1
- package/lib/commonjs/components/utils.js +4 -3
- package/lib/commonjs/components/utils.js.map +1 -1
- package/lib/commonjs/hooks/useInViewport.js +42 -0
- package/lib/commonjs/hooks/useInViewport.js.map +1 -0
- package/lib/commonjs/index.web.js +86 -29
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/theme.js +4 -4
- package/lib/commonjs/theme.js.map +1 -1
- package/lib/module/api.js +4 -3
- package/lib/module/api.js.map +1 -1
- package/lib/module/components/BetaNotice.js +30 -0
- package/lib/module/components/BetaNotice.js.map +1 -0
- package/lib/module/components/ChatHeader.js +27 -20
- package/lib/module/components/ChatHeader.js.map +1 -1
- package/lib/module/components/ChatInput.js +20 -21
- package/lib/module/components/ChatInput.js.map +1 -1
- package/lib/module/components/ChatWidget.js +166 -93
- package/lib/module/components/ChatWidget.js.map +1 -1
- package/lib/module/components/LazyProductsFetcher.js +40 -0
- package/lib/module/components/LazyProductsFetcher.js.map +1 -0
- package/lib/module/components/MessageBubble.js +26 -92
- package/lib/module/components/MessageBubble.js.map +1 -1
- package/lib/module/components/MessageMetaRow.js +105 -0
- package/lib/module/components/MessageMetaRow.js.map +1 -0
- package/lib/module/components/ProductsGrid.js +133 -0
- package/lib/module/components/ProductsGrid.js.map +1 -0
- package/lib/module/components/ProductsList.js +21 -126
- package/lib/module/components/ProductsList.js.map +1 -1
- package/lib/module/components/ProductsListView.js +132 -0
- package/lib/module/components/ProductsListView.js.map +1 -0
- package/lib/module/components/SuggestionsRow.js +51 -28
- package/lib/module/components/SuggestionsRow.js.map +1 -1
- package/lib/module/components/utils.js +4 -3
- package/lib/module/components/utils.js.map +1 -1
- package/lib/module/hooks/useInViewport.js +36 -0
- package/lib/module/hooks/useInViewport.js.map +1 -0
- package/lib/module/index.web.js +86 -29
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/theme.js +4 -4
- package/lib/module/theme.js.map +1 -1
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/components/BetaNotice.d.ts +5 -0
- package/lib/typescript/components/BetaNotice.d.ts.map +1 -0
- package/lib/typescript/components/ChatHeader.d.ts +5 -2
- package/lib/typescript/components/ChatHeader.d.ts.map +1 -1
- package/lib/typescript/components/ChatInput.d.ts.map +1 -1
- package/lib/typescript/components/ChatWidget.d.ts.map +1 -1
- package/lib/typescript/components/LazyProductsFetcher.d.ts +9 -0
- package/lib/typescript/components/LazyProductsFetcher.d.ts.map +1 -0
- package/lib/typescript/components/MessageBubble.d.ts +7 -3
- package/lib/typescript/components/MessageBubble.d.ts.map +1 -1
- package/lib/typescript/components/MessageMetaRow.d.ts +14 -0
- package/lib/typescript/components/MessageMetaRow.d.ts.map +1 -0
- package/lib/typescript/components/ProductsGrid.d.ts +10 -0
- package/lib/typescript/components/ProductsGrid.d.ts.map +1 -0
- package/lib/typescript/components/ProductsList.d.ts +4 -2
- package/lib/typescript/components/ProductsList.d.ts.map +1 -1
- package/lib/typescript/components/ProductsListView.d.ts +10 -0
- package/lib/typescript/components/ProductsListView.d.ts.map +1 -0
- package/lib/typescript/components/SuggestionsRow.d.ts +2 -0
- package/lib/typescript/components/SuggestionsRow.d.ts.map +1 -1
- package/lib/typescript/components/utils.d.ts +1 -0
- package/lib/typescript/components/utils.d.ts.map +1 -1
- package/lib/typescript/hooks/useInViewport.d.ts +5 -0
- package/lib/typescript/hooks/useInViewport.d.ts.map +1 -0
- package/lib/typescript/index.web.d.ts +1 -1
- package/lib/typescript/index.web.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +3 -1
- package/lib/typescript/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +4 -3
- package/src/components/BetaNotice.tsx +32 -0
- package/src/components/ChatHeader.tsx +32 -18
- package/src/components/ChatInput.tsx +23 -21
- package/src/components/ChatWidget.tsx +249 -159
- package/src/components/LazyProductsFetcher.tsx +41 -0
- package/src/components/MessageBubble.tsx +46 -148
- package/src/components/MessageMetaRow.tsx +199 -0
- package/src/components/ProductsGrid.tsx +163 -0
- package/src/components/ProductsList.tsx +20 -146
- package/src/components/ProductsListView.tsx +149 -0
- package/src/components/SuggestionsRow.tsx +61 -32
- package/src/components/utils.ts +6 -4
- package/src/hooks/useInViewport.ts +38 -0
- package/src/index.web.tsx +87 -32
- package/src/theme.ts +4 -4
- package/src/types.ts +3 -2
- package/dist/751.chat-widget.js +0 -1
- package/lib/commonjs/contexts/SegmentClientContext.js +0 -19
- package/lib/commonjs/contexts/SegmentClientContext.js.map +0 -1
- package/lib/module/contexts/SegmentClientContext.js +0 -10
- package/lib/module/contexts/SegmentClientContext.js.map +0 -1
- package/lib/typescript/contexts/SegmentClientContext.d.ts +0 -9
- package/lib/typescript/contexts/SegmentClientContext.d.ts.map +0 -1
- package/src/contexts/SegmentClientContext.tsx +0 -20
|
@@ -1,37 +1,29 @@
|
|
|
1
1
|
import React, { memo } from "react";
|
|
2
|
-
import { View, Text, StyleSheet
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
// Use expo-image on native if available, fallback to RN Image
|
|
6
|
-
let ImageComponent = Image;
|
|
7
|
-
if (Platform.OS !== "web") {
|
|
8
|
-
try {
|
|
9
|
-
const ExpoImage = require("expo-image").Image;
|
|
10
|
-
if (ExpoImage) ImageComponent = ExpoImage;
|
|
11
|
-
} catch {
|
|
12
|
-
// expo-image not installed, use React Native Image
|
|
13
|
-
}
|
|
14
|
-
}
|
|
2
|
+
import { View, Text, StyleSheet } from "react-native";
|
|
3
|
+
import SuggestionsRow from "./SuggestionsRow";
|
|
15
4
|
const MessageBubbleComponent = ({
|
|
16
5
|
message,
|
|
17
6
|
theme,
|
|
18
|
-
|
|
7
|
+
priceMode,
|
|
19
8
|
handleFeedbackAction,
|
|
20
9
|
onReloadResults,
|
|
21
10
|
reloading,
|
|
22
|
-
hasResults
|
|
11
|
+
hasResults,
|
|
12
|
+
totalResults,
|
|
13
|
+
shownResults,
|
|
14
|
+
onSuggestionSelect,
|
|
15
|
+
isLatest,
|
|
16
|
+
isTyping
|
|
23
17
|
}) => {
|
|
24
18
|
const isUser = message.role === "user";
|
|
25
|
-
const isValidMessageId = typeof message.id === "string" && message.id.length > 0 && !message.id.startsWith("bot-loading-");
|
|
26
|
-
const canFeedback = message.role === "assistant" && !message.isLoading && isValidMessageId && !!conversationId;
|
|
27
19
|
return /*#__PURE__*/React.createElement(View, {
|
|
28
20
|
style: [styles.container, isUser ? styles.alignRight : styles.alignLeft]
|
|
29
21
|
}, /*#__PURE__*/React.createElement(View, {
|
|
30
22
|
style: [styles.bubble, {
|
|
31
23
|
backgroundColor: isUser ? theme.userBubbleColor : theme.botBubbleColor,
|
|
32
|
-
borderRadius: theme.borderRadius ||
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
borderRadius: theme.borderRadius || 8,
|
|
25
|
+
borderBottomRightRadius: isUser ? 0 : theme.borderRadius,
|
|
26
|
+
borderBottomLeftRadius: isUser ? theme.borderRadius : 0
|
|
35
27
|
}]
|
|
36
28
|
}, /*#__PURE__*/React.createElement(Text, {
|
|
37
29
|
style: [styles.text, {
|
|
@@ -39,61 +31,13 @@ const MessageBubbleComponent = ({
|
|
|
39
31
|
fontFamily: theme.fontFamily,
|
|
40
32
|
fontSize: theme.fontSize
|
|
41
33
|
}]
|
|
42
|
-
}, message.text || "")), (
|
|
43
|
-
style: styles.
|
|
44
|
-
}, /*#__PURE__*/React.createElement(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
alignItems: "center",
|
|
50
|
-
gap: 6
|
|
51
|
-
}
|
|
52
|
-
}, /*#__PURE__*/React.createElement(ActivityIndicator, {
|
|
53
|
-
size: "small",
|
|
54
|
-
color: "#1a73e8"
|
|
55
|
-
}), /*#__PURE__*/React.createElement(Text, {
|
|
56
|
-
style: {
|
|
57
|
-
fontSize: 12,
|
|
58
|
-
color: "#1a73e8",
|
|
59
|
-
textDecorationLine: "underline"
|
|
60
|
-
}
|
|
61
|
-
}, "Loading\u2026")) : /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
62
|
-
onPress: () => onReloadResults?.(message),
|
|
63
|
-
disabled: reloading
|
|
64
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
65
|
-
style: {
|
|
66
|
-
fontSize: 12,
|
|
67
|
-
color: "#1a73e8",
|
|
68
|
-
textDecorationLine: "underline"
|
|
69
|
-
}
|
|
70
|
-
}, "Reload Results"))), /*#__PURE__*/React.createElement(View, {
|
|
71
|
-
style: styles.likeDislikeContainer
|
|
72
|
-
}, /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
73
|
-
onPress: () => handleFeedbackAction(FeedbackAction.LIKE, String(conversationId), message.id),
|
|
74
|
-
disabled: !canFeedback
|
|
75
|
-
}, /*#__PURE__*/React.createElement(ImageComponent, {
|
|
76
|
-
source: {
|
|
77
|
-
uri: message.reaction === FeedbackAction.LIKE ? "https://cdn.vdbapp.com/ai/chat-widget/assets/img/like-filled.svg" : "https://cdn.vdbapp.com/ai/chat-widget/assets/img/like.svg"
|
|
78
|
-
},
|
|
79
|
-
resizeMode: "contain",
|
|
80
|
-
style: {
|
|
81
|
-
width: 16,
|
|
82
|
-
height: 16
|
|
83
|
-
}
|
|
84
|
-
})), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
85
|
-
onPress: () => handleFeedbackAction(FeedbackAction.DISLIKE, String(conversationId), message.id),
|
|
86
|
-
disabled: !canFeedback
|
|
87
|
-
}, /*#__PURE__*/React.createElement(ImageComponent, {
|
|
88
|
-
source: {
|
|
89
|
-
uri: message.reaction === FeedbackAction.DISLIKE ? "https://cdn.vdbapp.com/ai/chat-widget/assets/img/dislike-filled.svg" : "https://cdn.vdbapp.com/ai/chat-widget/assets/img/dislike.svg"
|
|
90
|
-
},
|
|
91
|
-
resizeMode: "contain",
|
|
92
|
-
style: {
|
|
93
|
-
width: 16,
|
|
94
|
-
height: 16
|
|
95
|
-
}
|
|
96
|
-
})))));
|
|
34
|
+
}, message.text || "", message.role === "assistant" && hasResults && typeof totalResults === "number" ? ` Found ${Number(totalResults).toLocaleString()} diamonds (showing first ${shownResults})` : null), message.role === "assistant" && Array.isArray(message.suggestions) && message.suggestions.length > 0 && isLatest && !isTyping && !(message.search_payload && typeof message.search_payload === "object" && Object.keys(message.search_payload).length > 0) && /*#__PURE__*/React.createElement(View, {
|
|
35
|
+
style: styles.suggestionsWrapper
|
|
36
|
+
}, /*#__PURE__*/React.createElement(SuggestionsRow, {
|
|
37
|
+
suggestions: message.suggestions,
|
|
38
|
+
onSelect: v => onSuggestionSelect?.(v),
|
|
39
|
+
variant: "inline"
|
|
40
|
+
}))));
|
|
97
41
|
};
|
|
98
42
|
|
|
99
43
|
// Memoize to prevent re-renders when parent re-renders
|
|
@@ -101,21 +45,9 @@ export const MessageBubble = /*#__PURE__*/memo(MessageBubbleComponent);
|
|
|
101
45
|
const styles = StyleSheet.create({
|
|
102
46
|
container: {
|
|
103
47
|
paddingHorizontal: 8,
|
|
104
|
-
marginVertical:
|
|
48
|
+
marginVertical: 0,
|
|
105
49
|
width: "100%"
|
|
106
50
|
},
|
|
107
|
-
rowContainer: {
|
|
108
|
-
flexDirection: "row",
|
|
109
|
-
justifyContent: "space-between",
|
|
110
|
-
alignItems: "center",
|
|
111
|
-
gap: 12,
|
|
112
|
-
marginTop: 8,
|
|
113
|
-
marginBottom: 8
|
|
114
|
-
},
|
|
115
|
-
likeDislikeContainer: {
|
|
116
|
-
flexDirection: "row",
|
|
117
|
-
gap: 12
|
|
118
|
-
},
|
|
119
51
|
alignRight: {
|
|
120
52
|
alignItems: "flex-end"
|
|
121
53
|
},
|
|
@@ -130,11 +62,13 @@ const styles = StyleSheet.create({
|
|
|
130
62
|
text: {
|
|
131
63
|
lineHeight: 20
|
|
132
64
|
},
|
|
133
|
-
|
|
134
|
-
fontSize: 12,
|
|
135
|
-
color: "#666",
|
|
65
|
+
resultsInfo: {
|
|
136
66
|
marginTop: 4,
|
|
137
|
-
|
|
67
|
+
fontSize: 12,
|
|
68
|
+
color: "#666"
|
|
69
|
+
},
|
|
70
|
+
suggestionsWrapper: {
|
|
71
|
+
marginTop: 8
|
|
138
72
|
}
|
|
139
73
|
});
|
|
140
74
|
//# sourceMappingURL=MessageBubble.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","memo","View","Text","StyleSheet","
|
|
1
|
+
{"version":3,"names":["React","memo","View","Text","StyleSheet","SuggestionsRow","MessageBubbleComponent","message","theme","priceMode","handleFeedbackAction","onReloadResults","reloading","hasResults","totalResults","shownResults","onSuggestionSelect","isLatest","isTyping","isUser","role","createElement","style","styles","container","alignRight","alignLeft","bubble","backgroundColor","userBubbleColor","botBubbleColor","borderRadius","borderBottomRightRadius","borderBottomLeftRadius","text","color","userTextColor","botTextColor","fontFamily","fontSize","Number","toLocaleString","Array","isArray","suggestions","length","search_payload","Object","keys","suggestionsWrapper","onSelect","v","variant","MessageBubble","create","paddingHorizontal","marginVertical","width","alignItems","maxWidth","paddingVertical","lineHeight","resultsInfo","marginTop"],"sourceRoot":"../../../src","sources":["components/MessageBubble.tsx"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,IAAI,QAAQ,OAAO;AACnC,SAASC,IAAI,EAAEC,IAAI,EAAEC,UAAU,QAAQ,cAAc;AACrD,OAAOC,cAAc,MAAM,kBAAkB;AAkB7C,MAAMC,sBAAuC,GAAGA,CAAC;EAC/CC,OAAO;EACPC,KAAK;EACLC,SAAS;EACTC,oBAAoB;EACpBC,eAAe;EACfC,SAAS;EACTC,UAAU;EACVC,YAAY;EACZC,YAAY;EACZC,kBAAkB;EAClBC,QAAQ;EACRC;AACF,CAAC,KAAK;EACJ,MAAMC,MAAM,GAAGZ,OAAO,CAACa,IAAI,KAAK,MAAM;EAEtC,oBACEpB,KAAA,CAAAqB,aAAA,CAACnB,IAAI;IACHoB,KAAK,EAAE,CAACC,MAAM,CAACC,SAAS,EAAEL,MAAM,GAAGI,MAAM,CAACE,UAAU,GAAGF,MAAM,CAACG,SAAS;EAAE,gBAEzE1B,KAAA,CAAAqB,aAAA,CAACnB,IAAI;IACHoB,KAAK,EAAE,CACLC,MAAM,CAACI,MAAM,EACb;MACEC,eAAe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aAAA,CAAChB,cAAc;IACbuC,WAAW,EAAErC,OAAO,CAACqC,WAAY;IACjCM,QAAQ,EAAGC,CAAC,IAAKnC,kBAAkB,GAAGmC,CAAC,CAAE;IACzCC,OAAO,EAAC;EAAQ,CACjB,CACG,CAEN,CACJ,CAAC;AACR,CAAC;;AAEF;AACA,OAAO,MAAMC,aAAa,gBAAGpD,IAAI,CAACK,sBAAsB,CAAC;AAEzD,MAAMiB,MAAM,GAAGnB,UAAU,CAACkD,MAAM,CAAC;EAC/B9B,SAAS,EAAE;IACT+B,iBAAiB,EAAE,CAAC;IACpBC,cAAc,EAAE,CAAC;IACjBC,KAAK,EAAE;EACT,CAAC;EAEDhC,UAAU,EAAE;IACViC,UAAU,EAAE;EACd,CAAC;EACDhC,SAAS,EAAE;IACTgC,UAAU,EAAE;EACd,CAAC;EACD/B,MAAM,EAAE;IACNgC,QAAQ,EAAE,KAAK;IACfJ,iBAAiB,EAAE,EAAE;IACrBK,eAAe,EAAE;EACnB,CAAC;EACD1B,IAAI,EAAE;IACJ2B,UAAU,EAAE;EACd,CAAC;EACDC,WAAW,EAAE;IACXC,SAAS,EAAE,CAAC;IACZxB,QAAQ,EAAE,EAAE;IACZJ,KAAK,EAAE;EACT,CAAC;EACDc,kBAAkB,EAAE;IAClBc,SAAS,EAAE;EACb;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, Text, StyleSheet, Image, Platform, Pressable } from "react-native";
|
|
3
|
+
import { FeedbackAction, fetchConversationId, formatToTime } from "./utils";
|
|
4
|
+
let ImageComponent = Image;
|
|
5
|
+
if (Platform.OS !== "web") {
|
|
6
|
+
try {
|
|
7
|
+
const ExpoImage = require("expo-image").Image;
|
|
8
|
+
if (ExpoImage) ImageComponent = ExpoImage;
|
|
9
|
+
} catch {}
|
|
10
|
+
}
|
|
11
|
+
export const MessageMetaRow = ({
|
|
12
|
+
message,
|
|
13
|
+
priceMode,
|
|
14
|
+
handleFeedbackAction,
|
|
15
|
+
onReloadResults,
|
|
16
|
+
reloading,
|
|
17
|
+
hasResults
|
|
18
|
+
}) => {
|
|
19
|
+
const isUser = message.role === "user";
|
|
20
|
+
const [conversationId, setConversationId] = React.useState(null);
|
|
21
|
+
React.useEffect(() => {
|
|
22
|
+
const fetchId = async () => {
|
|
23
|
+
const id = await fetchConversationId(priceMode);
|
|
24
|
+
setConversationId(id);
|
|
25
|
+
};
|
|
26
|
+
fetchId();
|
|
27
|
+
}, [priceMode]);
|
|
28
|
+
const isValidMessageId = typeof message.id === "string" && message.id.length > 0 && !message.id.startsWith("bot-loading-");
|
|
29
|
+
const canFeedback = message.role === "assistant" && !message.isLoading && isValidMessageId && !!conversationId;
|
|
30
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
31
|
+
style: [styles.rowContainer, isUser ? styles.alignRight : styles.alignLeft]
|
|
32
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
33
|
+
style: styles.timeContainer
|
|
34
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
35
|
+
style: styles.timeText
|
|
36
|
+
}, formatToTime(message.createdAt))), canFeedback ? /*#__PURE__*/React.createElement(View, {
|
|
37
|
+
style: styles.likeDislikeContainer
|
|
38
|
+
}, /*#__PURE__*/React.createElement(Pressable, {
|
|
39
|
+
style: state => [styles.borderButton, state?.hovered && styles.borderButtonHover],
|
|
40
|
+
onPress: () => handleFeedbackAction(FeedbackAction.LIKE, String(conversationId), message.id),
|
|
41
|
+
disabled: !canFeedback
|
|
42
|
+
}, /*#__PURE__*/React.createElement(ImageComponent, {
|
|
43
|
+
source: {
|
|
44
|
+
uri: message.reaction === FeedbackAction.LIKE ? "https://cdn.vdbapp.com/ai/chat-widget/assets/img/like-filled.svg" : "https://cdn.vdbapp.com/ai/chat-widget/assets/img/like.svg"
|
|
45
|
+
},
|
|
46
|
+
resizeMode: "contain",
|
|
47
|
+
style: {
|
|
48
|
+
width: 16,
|
|
49
|
+
height: 16
|
|
50
|
+
}
|
|
51
|
+
})), /*#__PURE__*/React.createElement(Pressable, {
|
|
52
|
+
style: state => [styles.borderButton, state?.hovered && styles.borderButtonHover],
|
|
53
|
+
onPress: () => handleFeedbackAction(FeedbackAction.DISLIKE, String(conversationId), message.id),
|
|
54
|
+
disabled: !canFeedback
|
|
55
|
+
}, /*#__PURE__*/React.createElement(ImageComponent, {
|
|
56
|
+
source: {
|
|
57
|
+
uri: message.reaction === FeedbackAction.DISLIKE ? "https://cdn.vdbapp.com/ai/chat-widget/assets/img/dislike-filled.svg" : "https://cdn.vdbapp.com/ai/chat-widget/assets/img/dislike.svg"
|
|
58
|
+
},
|
|
59
|
+
resizeMode: "contain",
|
|
60
|
+
style: {
|
|
61
|
+
width: 16,
|
|
62
|
+
height: 16
|
|
63
|
+
}
|
|
64
|
+
}))) : null);
|
|
65
|
+
};
|
|
66
|
+
const styles = StyleSheet.create({
|
|
67
|
+
rowContainer: {
|
|
68
|
+
flexDirection: "row",
|
|
69
|
+
justifyContent: "space-between",
|
|
70
|
+
alignItems: "center",
|
|
71
|
+
gap: 6,
|
|
72
|
+
marginHorizontal: 8,
|
|
73
|
+
marginTop: 0,
|
|
74
|
+
marginBottom: 12
|
|
75
|
+
},
|
|
76
|
+
alignRight: {
|
|
77
|
+
alignSelf: "flex-end"
|
|
78
|
+
},
|
|
79
|
+
alignLeft: {
|
|
80
|
+
alignSelf: "flex-start"
|
|
81
|
+
},
|
|
82
|
+
likeDislikeContainer: {
|
|
83
|
+
flexDirection: "row",
|
|
84
|
+
gap: 6
|
|
85
|
+
},
|
|
86
|
+
timeContainer: {
|
|
87
|
+
margin: 0
|
|
88
|
+
},
|
|
89
|
+
borderButton: {
|
|
90
|
+
borderWidth: 1,
|
|
91
|
+
borderColor: "#D5D5DC",
|
|
92
|
+
borderRadius: 8,
|
|
93
|
+
paddingHorizontal: 4,
|
|
94
|
+
paddingVertical: 4
|
|
95
|
+
},
|
|
96
|
+
borderButtonHover: {
|
|
97
|
+
backgroundColor: "#EDEDF2"
|
|
98
|
+
},
|
|
99
|
+
timeText: {
|
|
100
|
+
fontSize: 12,
|
|
101
|
+
color: "#666"
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
export default MessageMetaRow;
|
|
105
|
+
//# sourceMappingURL=MessageMetaRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","View","Text","StyleSheet","Image","Platform","Pressable","FeedbackAction","fetchConversationId","formatToTime","ImageComponent","OS","ExpoImage","require","MessageMetaRow","message","priceMode","handleFeedbackAction","onReloadResults","reloading","hasResults","isUser","role","conversationId","setConversationId","useState","useEffect","fetchId","id","isValidMessageId","length","startsWith","canFeedback","isLoading","createElement","style","styles","rowContainer","alignRight","alignLeft","timeContainer","timeText","createdAt","likeDislikeContainer","state","borderButton","hovered","borderButtonHover","onPress","LIKE","String","disabled","source","uri","reaction","resizeMode","width","height","DISLIKE","create","flexDirection","justifyContent","alignItems","gap","marginHorizontal","marginTop","marginBottom","alignSelf","margin","borderWidth","borderColor","borderRadius","paddingHorizontal","paddingVertical","backgroundColor","fontSize","color"],"sourceRoot":"../../../src","sources":["components/MessageMetaRow.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SACEC,IAAI,EACJC,IAAI,EACJC,UAAU,EACVC,KAAK,EACLC,QAAQ,EAERC,SAAS,QACJ,cAAc;AAErB,SAASC,cAAc,EAAEC,mBAAmB,EAAEC,YAAY,QAAQ,SAAS;AAE3E,IAAIC,cAA4B,GAAGN,KAAK;AACxC,IAAIC,QAAQ,CAACM,EAAE,KAAK,KAAK,EAAE;EACzB,IAAI;IACF,MAAMC,SAAS,GAAGC,OAAO,CAAC,YAAY,CAAC,CAACT,KAAK;IAC7C,IAAIQ,SAAS,EAAEF,cAAc,GAAGE,SAAS;EAC3C,CAAC,CAAC,MAAM,CAAC;AACX;AAeA,OAAO,MAAME,cAA+B,GAAGA,CAAC;EAC9CC,OAAO;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AAG;EAAE,CAClC,CACQ,CACP,CAAC,GACL,IA2BA,CAAC;AAEX,CAAC;AAED,MAAMrB,MAAM,GAAGjC,UAAU,CAACwD,MAAM,CAAC;EAC/BtB,YAAY,EAAE;IACZuB,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE,eAAe;IAC/BC,UAAU,EAAE,QAAQ;IACpBC,GAAG,EAAE,CAAC;IACNC,gBAAgB,EAAE,CAAC;IACnBC,SAAS,EAAE,CAAC;IACZC,YAAY,EAAE;EAChB,CAAC;EACD5B,UAAU,EAAE;IACV6B,SAAS,EAAE;EACb,CAAC;EACD5B,SAAS,EAAE;IACT4B,SAAS,EAAE;EACb,CAAC;EACDxB,oBAAoB,EAAE;IACpBiB,aAAa,EAAE,KAAK;IACpBG,GAAG,EAAE;EACP,CAAC;EACDvB,aAAa,EAAE;IACb4B,MAAM,EAAE;EACV,CAAC;EACDvB,YAAY,EAAE;IACZwB,WAAW,EAAE,CAAC;IACdC,WAAW,EAAE,SAAS;IACtBC,YAAY,EAAE,CAAC;IACfC,iBAAiB,EAAE,CAAC;IACpBC,eAAe,EAAE;EACnB,CAAC;EACD1B,iBAAiB,EAAE;IACjB2B,eAAe,EAAE;EACnB,CAAC;EACDjC,QAAQ,EAAE;IACRkC,QAAQ,EAAE,EAAE;IACZC,KAAK,EAAE;EACT;AACF,CAAC,CAAC;AAEF,eAAe9D,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { View, Image, StyleSheet, Text, ScrollView, TouchableOpacity, Platform } from "react-native";
|
|
2
|
+
import React, { memo } from "react";
|
|
3
|
+
|
|
4
|
+
// Use expo-image on native if available, fallback to RN Image
|
|
5
|
+
let ImageComponent = Image;
|
|
6
|
+
if (Platform.OS !== "web") {
|
|
7
|
+
try {
|
|
8
|
+
const ExpoImage = require("expo-image").Image;
|
|
9
|
+
if (ExpoImage) ImageComponent = ExpoImage;
|
|
10
|
+
} catch {
|
|
11
|
+
// expo-image not installed, use React Native Image
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const ProductsGridComponent = ({
|
|
15
|
+
data,
|
|
16
|
+
onViewAll,
|
|
17
|
+
onItemPress
|
|
18
|
+
}) => {
|
|
19
|
+
if (!data || !data.length) return null;
|
|
20
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
21
|
+
style: styles.wrapper
|
|
22
|
+
}, /*#__PURE__*/React.createElement(ScrollView, {
|
|
23
|
+
horizontal: true,
|
|
24
|
+
showsHorizontalScrollIndicator: false,
|
|
25
|
+
contentContainerStyle: styles.listContent
|
|
26
|
+
}, data.map(item => /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
27
|
+
key: item.id,
|
|
28
|
+
onPress: () => {
|
|
29
|
+
onItemPress?.(item);
|
|
30
|
+
}
|
|
31
|
+
}, /*#__PURE__*/React.createElement(View, {
|
|
32
|
+
key: item.id,
|
|
33
|
+
style: styles.card
|
|
34
|
+
}, item.image_thumb_url ? /*#__PURE__*/React.createElement(ImageComponent, {
|
|
35
|
+
style: styles.image,
|
|
36
|
+
source: {
|
|
37
|
+
uri: item.image_thumb_url
|
|
38
|
+
}
|
|
39
|
+
}) : null, /*#__PURE__*/React.createElement(View, {
|
|
40
|
+
style: styles.content
|
|
41
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
42
|
+
numberOfLines: 2,
|
|
43
|
+
style: styles.title
|
|
44
|
+
}, item.short_title), /*#__PURE__*/React.createElement(Text, {
|
|
45
|
+
style: styles.price
|
|
46
|
+
}, "$", item.total_sales_price)))))), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
47
|
+
style: styles.button,
|
|
48
|
+
activeOpacity: 0.8,
|
|
49
|
+
onPress: onViewAll
|
|
50
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
51
|
+
style: styles.buttonText
|
|
52
|
+
}, "View All ", ">>")));
|
|
53
|
+
};
|
|
54
|
+
const styles = StyleSheet.create({
|
|
55
|
+
wrapper: {
|
|
56
|
+
paddingHorizontal: 12,
|
|
57
|
+
marginHorizontal: 12,
|
|
58
|
+
marginBottom: 12,
|
|
59
|
+
paddingTop: 6,
|
|
60
|
+
paddingBottom: 14,
|
|
61
|
+
backgroundColor: "#fff",
|
|
62
|
+
borderRadius: 8,
|
|
63
|
+
borderWidth: 1,
|
|
64
|
+
borderColor: "#e8e8e8",
|
|
65
|
+
elevation: 3,
|
|
66
|
+
shadowColor: "#000",
|
|
67
|
+
shadowOpacity: 0.08,
|
|
68
|
+
shadowOffset: {
|
|
69
|
+
width: 0,
|
|
70
|
+
height: 2
|
|
71
|
+
},
|
|
72
|
+
shadowRadius: 6
|
|
73
|
+
},
|
|
74
|
+
listContent: {
|
|
75
|
+
gap: 12,
|
|
76
|
+
paddingVertical: 6
|
|
77
|
+
},
|
|
78
|
+
card: {
|
|
79
|
+
width: 150,
|
|
80
|
+
backgroundColor: "#fff",
|
|
81
|
+
borderRadius: 14,
|
|
82
|
+
overflow: "hidden",
|
|
83
|
+
borderColor: "#e8e8e8",
|
|
84
|
+
borderWidth: 1,
|
|
85
|
+
elevation: 3,
|
|
86
|
+
shadowColor: "#000",
|
|
87
|
+
shadowOpacity: 0.08,
|
|
88
|
+
shadowOffset: {
|
|
89
|
+
width: 0,
|
|
90
|
+
height: 2
|
|
91
|
+
},
|
|
92
|
+
shadowRadius: 6
|
|
93
|
+
},
|
|
94
|
+
image: {
|
|
95
|
+
width: "100%",
|
|
96
|
+
height: 120,
|
|
97
|
+
borderBottomWidth: 1,
|
|
98
|
+
borderBottomColor: "#e8e8e8"
|
|
99
|
+
},
|
|
100
|
+
content: {
|
|
101
|
+
padding: 10,
|
|
102
|
+
gap: 4
|
|
103
|
+
},
|
|
104
|
+
title: {
|
|
105
|
+
fontSize: 13,
|
|
106
|
+
color: "#222",
|
|
107
|
+
fontWeight: "500"
|
|
108
|
+
},
|
|
109
|
+
price: {
|
|
110
|
+
marginTop: 4,
|
|
111
|
+
fontSize: 14,
|
|
112
|
+
fontWeight: "700",
|
|
113
|
+
color: "#000"
|
|
114
|
+
},
|
|
115
|
+
button: {
|
|
116
|
+
marginTop: 12,
|
|
117
|
+
alignSelf: "center",
|
|
118
|
+
paddingHorizontal: 20,
|
|
119
|
+
paddingVertical: 8,
|
|
120
|
+
backgroundColor: "#804195",
|
|
121
|
+
borderRadius: 20,
|
|
122
|
+
width: 300,
|
|
123
|
+
alignItems: "center"
|
|
124
|
+
},
|
|
125
|
+
buttonText: {
|
|
126
|
+
color: "#fff",
|
|
127
|
+
fontSize: 14,
|
|
128
|
+
fontWeight: "600"
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
const ProductsGrid = /*#__PURE__*/memo(ProductsGridComponent);
|
|
132
|
+
export default ProductsGrid;
|
|
133
|
+
//# sourceMappingURL=ProductsGrid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["View","Image","StyleSheet","Text","ScrollView","TouchableOpacity","Platform","React","memo","ImageComponent","OS","ExpoImage","require","ProductsGridComponent","data","onViewAll","onItemPress","length","createElement","style","styles","wrapper","horizontal","showsHorizontalScrollIndicator","contentContainerStyle","listContent","map","item","key","id","onPress","card","image_thumb_url","image","source","uri","content","numberOfLines","title","short_title","price","total_sales_price","button","activeOpacity","buttonText","create","paddingHorizontal","marginHorizontal","marginBottom","paddingTop","paddingBottom","backgroundColor","borderRadius","borderWidth","borderColor","elevation","shadowColor","shadowOpacity","shadowOffset","width","height","shadowRadius","gap","paddingVertical","overflow","borderBottomWidth","borderBottomColor","padding","fontSize","color","fontWeight","marginTop","alignSelf","alignItems","ProductsGrid"],"sourceRoot":"../../../src","sources":["components/ProductsGrid.tsx"],"mappings":"AAAA,SACEA,IAAI,EACJC,KAAK,EACLC,UAAU,EACVC,IAAI,EACJC,UAAU,EACVC,gBAAgB,EAChBC,QAAQ,QACH,cAAc;AACrB,OAAOC,KAAK,IAAIC,IAAI,QAAQ,OAAO;;AAEnC;AACA,IAAIC,cAA4B,GAAGR,KAAK;AACxC,I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AC;IACZC,WAAW,EAAE,MAAM;IACnBC,aAAa,EAAE,IAAI;IACnBC,YAAY,EAAE;MAAEC,KAAK,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAE,CAAC;IACrCC,YAAY,EAAE;EAChB,CAAC;EAED5B,KAAK,EAAE;IACL0B,KAAK,EAAE,MAAM;IACbC,MAAM,EAAE,GAAG;IACXK,iBAAiB,EAAE,CAAC;IACpBC,iBAAiB,EAAE;EACrB,CAAC;EAED9B,OAAO,EAAE;IACP+B,OAAO,EAAE,EAAE;IACXL,GAAG,EAAE;EACP,CAAC;EAEDxB,KAAK,EAAE;IACL8B,QAAQ,EAAE,EAAE;IACZC,KAAK,EAAE,MAAM;IACbC,UAAU,EAAE;EACd,CAAC;EAED9B,KAAK,EAAE;IACL+B,SAAS,EAAE,CAAC;IACZH,QAAQ,EAAE,EAAE;IACZE,UAAU,EAAE,KAAK;IACjBD,KAAK,EAAE;EACT,CAAC;EAED3B,MAAM,EAAE;IACN6B,SAAS,EAAE,EAAE;IACbC,SAAS,EAAE,QAAQ;IACnB1B,iBAAiB,EAAE,EAAE;IACrBiB,eAAe,EAAE,CAAC;IAClBZ,eAAe,EAAE,SAAS;IAC1BC,YAAY,EAAE,EAAE;IAChBO,KAAK,EAAE,GAAG;IACVc,UAAU,EAAE;EACd,CAAC;EAED7B,UAAU,EAAE;IACVyB,KAAK,EAAE,MAAM;IACbD,QAAQ,EAAE,EAAE;IACZE,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAEF,MAAMI,YAAY,gBAAGlE,IAAI,CAACK,qBAAqB,CAAC;AAChD,eAAe6D,YAAY","ignoreList":[]}
|
|
@@ -1,133 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
let ImageComponent = Image;
|
|
6
|
-
if (Platform.OS !== "web") {
|
|
7
|
-
try {
|
|
8
|
-
const ExpoImage = require("expo-image").Image;
|
|
9
|
-
if (ExpoImage) ImageComponent = ExpoImage;
|
|
10
|
-
} catch {
|
|
11
|
-
// expo-image not installed, use React Native Image
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
const ProductsListComponent = ({
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ProductsGrid from "./ProductsGrid";
|
|
3
|
+
import ProductsListView from "./ProductsListView";
|
|
4
|
+
const ProductsList = ({
|
|
15
5
|
data,
|
|
16
6
|
onViewAll,
|
|
17
|
-
onItemPress
|
|
7
|
+
onItemPress,
|
|
8
|
+
variant = "list",
|
|
9
|
+
totalResults
|
|
18
10
|
}) => {
|
|
19
11
|
if (!data || !data.length) return null;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
key: item.id,
|
|
28
|
-
onPress: () => {
|
|
29
|
-
onItemPress?.(item);
|
|
30
|
-
}
|
|
31
|
-
}, /*#__PURE__*/React.createElement(View, {
|
|
32
|
-
key: item.id,
|
|
33
|
-
style: styles.card
|
|
34
|
-
}, item.image_thumb_url ? /*#__PURE__*/React.createElement(ImageComponent, {
|
|
35
|
-
style: styles.image,
|
|
36
|
-
source: {
|
|
37
|
-
uri: item.image_thumb_url
|
|
38
|
-
}
|
|
39
|
-
}) : null, /*#__PURE__*/React.createElement(View, {
|
|
40
|
-
style: styles.content
|
|
41
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
42
|
-
numberOfLines: 2,
|
|
43
|
-
style: styles.title
|
|
44
|
-
}, item.short_title), /*#__PURE__*/React.createElement(Text, {
|
|
45
|
-
style: styles.price
|
|
46
|
-
}, "$", item.total_sales_price)))))), /*#__PURE__*/React.createElement(TouchableOpacity, {
|
|
47
|
-
style: styles.button,
|
|
48
|
-
activeOpacity: 0.8,
|
|
49
|
-
onPress: onViewAll
|
|
50
|
-
}, /*#__PURE__*/React.createElement(Text, {
|
|
51
|
-
style: styles.buttonText
|
|
52
|
-
}, "View All ", ">>")));
|
|
53
|
-
};
|
|
54
|
-
const styles = StyleSheet.create({
|
|
55
|
-
wrapper: {
|
|
56
|
-
paddingHorizontal: 12,
|
|
57
|
-
marginHorizontal: 12,
|
|
58
|
-
marginBottom: 12,
|
|
59
|
-
paddingTop: 6,
|
|
60
|
-
paddingBottom: 14,
|
|
61
|
-
backgroundColor: "#fff",
|
|
62
|
-
borderRadius: 8,
|
|
63
|
-
borderWidth: 1,
|
|
64
|
-
borderColor: "#e8e8e8",
|
|
65
|
-
elevation: 3,
|
|
66
|
-
shadowColor: "#000",
|
|
67
|
-
shadowOpacity: 0.08,
|
|
68
|
-
shadowOffset: {
|
|
69
|
-
width: 0,
|
|
70
|
-
height: 2
|
|
71
|
-
},
|
|
72
|
-
shadowRadius: 6
|
|
73
|
-
},
|
|
74
|
-
listContent: {
|
|
75
|
-
gap: 12,
|
|
76
|
-
paddingVertical: 6
|
|
77
|
-
},
|
|
78
|
-
card: {
|
|
79
|
-
width: 150,
|
|
80
|
-
backgroundColor: "#fff",
|
|
81
|
-
borderRadius: 14,
|
|
82
|
-
overflow: "hidden",
|
|
83
|
-
borderColor: "#e8e8e8",
|
|
84
|
-
borderWidth: 1,
|
|
85
|
-
elevation: 3,
|
|
86
|
-
shadowColor: "#000",
|
|
87
|
-
shadowOpacity: 0.08,
|
|
88
|
-
shadowOffset: {
|
|
89
|
-
width: 0,
|
|
90
|
-
height: 2
|
|
91
|
-
},
|
|
92
|
-
shadowRadius: 6
|
|
93
|
-
},
|
|
94
|
-
image: {
|
|
95
|
-
width: "100%",
|
|
96
|
-
height: 120,
|
|
97
|
-
borderBottomWidth: 1,
|
|
98
|
-
borderBottomColor: "#e8e8e8"
|
|
99
|
-
},
|
|
100
|
-
content: {
|
|
101
|
-
padding: 10,
|
|
102
|
-
gap: 4
|
|
103
|
-
},
|
|
104
|
-
title: {
|
|
105
|
-
fontSize: 13,
|
|
106
|
-
color: "#222",
|
|
107
|
-
fontWeight: "500"
|
|
108
|
-
},
|
|
109
|
-
price: {
|
|
110
|
-
marginTop: 4,
|
|
111
|
-
fontSize: 14,
|
|
112
|
-
fontWeight: "700",
|
|
113
|
-
color: "#000"
|
|
114
|
-
},
|
|
115
|
-
button: {
|
|
116
|
-
marginTop: 12,
|
|
117
|
-
alignSelf: "center",
|
|
118
|
-
paddingHorizontal: 20,
|
|
119
|
-
paddingVertical: 8,
|
|
120
|
-
backgroundColor: "#804195",
|
|
121
|
-
borderRadius: 20,
|
|
122
|
-
width: 300,
|
|
123
|
-
alignItems: "center"
|
|
124
|
-
},
|
|
125
|
-
buttonText: {
|
|
126
|
-
color: "#fff",
|
|
127
|
-
fontSize: 14,
|
|
128
|
-
fontWeight: "600"
|
|
12
|
+
if (variant === "list") {
|
|
13
|
+
return /*#__PURE__*/React.createElement(ProductsListView, {
|
|
14
|
+
data: data,
|
|
15
|
+
onViewAll: onViewAll,
|
|
16
|
+
onItemPress: onItemPress,
|
|
17
|
+
totalResults: totalResults
|
|
18
|
+
});
|
|
129
19
|
}
|
|
130
|
-
|
|
131
|
-
|
|
20
|
+
return /*#__PURE__*/React.createElement(ProductsGrid, {
|
|
21
|
+
data: data,
|
|
22
|
+
onViewAll: onViewAll,
|
|
23
|
+
onItemPress: onItemPress,
|
|
24
|
+
totalResults: totalResults
|
|
25
|
+
});
|
|
26
|
+
};
|
|
132
27
|
export default ProductsList;
|
|
133
28
|
//# sourceMappingURL=ProductsList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["React","ProductsGrid","ProductsListView","ProductsList","data","onViewAll","onItemPress","variant","totalResults","length","createElement"],"sourceRoot":"../../../src","sources":["components/ProductsList.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,YAAY,MAAM,gBAAgB;AACzC,OAAOC,gBAAgB,MAAM,oBAAoB;AAUjD,MAAMC,YAAyC,GAAGA,CAAC;EACjDC,IAAI;EACJC,SAAS;EACTC,WAAW;EACXC,OAAO,GAAG,MAAM;EAChBC;AACF,CAAC,KAAK;EACJ,IAAI,CAACJ,IAAI,IAAI,CAACA,IAAI,CAACK,MAAM,EAAE,OAAO,IAAI;EACtC,IAAIF,OAAO,KAAK,MAAM,EAAE;IACtB,oBACEP,KAAA,CAAAU,aAAA,CAACR,gBAAgB;MACfE,IAAI,EAAEA,IAAK;MACXC,SAAS,EAAEA,SAAU;MACrBC,WAAW,EAAEA,WAAY;MACzBE,YAAY,EAAEA;IAAa,CAC5B,CAAC;EAEN;EACA,oBACER,KAAA,CAAAU,aAAA,CAACT,YAAY;IAACG,IAAI,EAAEA,IAAK;IAACC,SAAS,EAAEA,SAAU;IAACC,WAAW,EAAEA,WAAY;IAACE,YAAY,EAAEA;EAAa,CAAE,CAAC;AAE5G,CAAC;AAED,eAAeL,YAAY","ignoreList":[]}
|