react-native-seel-widget 0.1.4 → 0.1.7

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 (110) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +22 -23
  3. package/lib/module/assets/images/accredited.png +0 -0
  4. package/lib/module/assets/images/background_image.jpg +0 -0
  5. package/lib/module/assets/images/button_close.png +0 -0
  6. package/lib/module/assets/images/button_close_background.png +0 -0
  7. package/lib/module/assets/images/checkbox_normal.png +0 -0
  8. package/lib/module/assets/images/checkbox_selected.png +0 -0
  9. package/lib/module/assets/images/close_white.png +0 -0
  10. package/lib/module/assets/images/ic_launcher.png +0 -0
  11. package/lib/module/assets/images/icon_arrow_left.png +0 -0
  12. package/lib/module/assets/images/icon_bg_select.png +0 -0
  13. package/lib/module/assets/images/icon_check_selected_black.png +0 -0
  14. package/lib/module/assets/images/icon_select.png +0 -0
  15. package/lib/module/assets/images/info_black.png +0 -0
  16. package/lib/module/assets/images/seel_icon.png +0 -0
  17. package/lib/module/assets/images/seel_logo.png +0 -0
  18. package/lib/module/assets/images/seel_word.png +0 -0
  19. package/lib/module/assets/images/tick_small_minor.png +0 -0
  20. package/lib/module/constants/key_value.js +50 -0
  21. package/lib/module/constants/key_value.js.map +1 -0
  22. package/lib/module/constants/network_request_statue_enum.js +17 -0
  23. package/lib/module/constants/network_request_statue_enum.js.map +1 -0
  24. package/lib/module/core/SeelWidgetSDK.js +85 -0
  25. package/lib/module/core/SeelWidgetSDK.js.map +1 -0
  26. package/lib/module/dto/EventsRequest.js +71 -0
  27. package/lib/module/dto/EventsRequest.js.map +1 -0
  28. package/lib/module/dto/EventsResponse.js +15 -0
  29. package/lib/module/dto/EventsResponse.js.map +1 -0
  30. package/lib/module/dto/IEvents.js +31 -0
  31. package/lib/module/dto/IEvents.js.map +1 -0
  32. package/lib/module/dto/IQuotes.js +2 -0
  33. package/lib/module/dto/IQuotes.js.map +1 -0
  34. package/lib/module/dto/IQuotesRequest.js +4 -0
  35. package/lib/module/dto/IQuotesRequest.js.map +1 -0
  36. package/lib/module/dto/IQuotesResponse.js +2 -0
  37. package/lib/module/dto/IQuotesResponse.js.map +1 -0
  38. package/lib/module/index.js +6 -0
  39. package/lib/module/index.js.map +1 -0
  40. package/lib/module/network/request.js +194 -0
  41. package/lib/module/network/request.js.map +1 -0
  42. package/lib/module/package.json +1 -0
  43. package/lib/module/ui/coverage-info-footer.js +170 -0
  44. package/lib/module/ui/coverage-info-footer.js.map +1 -0
  45. package/lib/module/ui/gradient-animation-text.js +116 -0
  46. package/lib/module/ui/gradient-animation-text.js.map +1 -0
  47. package/lib/module/ui/gradient-animation-view.js +110 -0
  48. package/lib/module/ui/gradient-animation-view.js.map +1 -0
  49. package/lib/module/ui/index.js +7 -0
  50. package/lib/module/ui/index.js.map +1 -0
  51. package/lib/module/ui/seel-wfp-info-view.js +312 -0
  52. package/lib/module/ui/seel-wfp-info-view.js.map +1 -0
  53. package/lib/module/ui/seel-wfp-title-view.js +286 -0
  54. package/lib/module/ui/seel-wfp-title-view.js.map +1 -0
  55. package/lib/module/ui/seel-wfp-widget.js +224 -0
  56. package/lib/module/ui/seel-wfp-widget.js.map +1 -0
  57. package/lib/module/utils/format_util.js +107 -0
  58. package/lib/module/utils/format_util.js.map +1 -0
  59. package/lib/module/utils/http_util.js +27 -0
  60. package/lib/module/utils/http_util.js.map +1 -0
  61. package/lib/module/utils/storage_util.js +36 -0
  62. package/lib/module/utils/storage_util.js.map +1 -0
  63. package/lib/module/utils/uuid.js +21 -0
  64. package/lib/module/utils/uuid.js.map +1 -0
  65. package/lib/typescript/package.json +1 -0
  66. package/lib/typescript/src/constants/key_value.d.ts +48 -0
  67. package/lib/typescript/src/constants/key_value.d.ts.map +1 -0
  68. package/lib/typescript/src/constants/network_request_statue_enum.d.ts +13 -0
  69. package/lib/typescript/src/constants/network_request_statue_enum.d.ts.map +1 -0
  70. package/lib/typescript/src/core/SeelWidgetSDK.d.ts +52 -0
  71. package/lib/typescript/src/core/SeelWidgetSDK.d.ts.map +1 -0
  72. package/lib/typescript/src/dto/EventsRequest.d.ts +60 -0
  73. package/lib/typescript/src/dto/EventsRequest.d.ts.map +1 -0
  74. package/lib/typescript/src/dto/EventsResponse.d.ts +11 -0
  75. package/lib/typescript/src/dto/EventsResponse.d.ts.map +1 -0
  76. package/lib/typescript/src/dto/IEvents.d.ts +48 -0
  77. package/lib/typescript/src/dto/IEvents.d.ts.map +1 -0
  78. package/lib/typescript/src/dto/IQuotes.d.ts +36 -0
  79. package/lib/typescript/src/dto/IQuotes.d.ts.map +1 -0
  80. package/lib/typescript/src/dto/IQuotesRequest.d.ts +213 -0
  81. package/lib/typescript/src/dto/IQuotesRequest.d.ts.map +1 -0
  82. package/lib/typescript/src/dto/IQuotesResponse.d.ts +96 -0
  83. package/lib/typescript/src/dto/IQuotesResponse.d.ts.map +1 -0
  84. package/lib/typescript/src/index.d.ts +2 -0
  85. package/lib/typescript/src/index.d.ts.map +1 -0
  86. package/lib/typescript/src/network/request.d.ts +53 -0
  87. package/lib/typescript/src/network/request.d.ts.map +1 -0
  88. package/lib/typescript/src/ui/coverage-info-footer.d.ts +9 -0
  89. package/lib/typescript/src/ui/coverage-info-footer.d.ts.map +1 -0
  90. package/lib/typescript/src/ui/gradient-animation-text.d.ts +40 -0
  91. package/lib/typescript/src/ui/gradient-animation-text.d.ts.map +1 -0
  92. package/lib/typescript/src/ui/gradient-animation-view.d.ts +32 -0
  93. package/lib/typescript/src/ui/gradient-animation-view.d.ts.map +1 -0
  94. package/lib/typescript/src/ui/index.d.ts +5 -0
  95. package/lib/typescript/src/ui/index.d.ts.map +1 -0
  96. package/lib/typescript/src/ui/seel-wfp-info-view.d.ts +13 -0
  97. package/lib/typescript/src/ui/seel-wfp-info-view.d.ts.map +1 -0
  98. package/lib/typescript/src/ui/seel-wfp-title-view.d.ts +68 -0
  99. package/lib/typescript/src/ui/seel-wfp-title-view.d.ts.map +1 -0
  100. package/lib/typescript/src/ui/seel-wfp-widget.d.ts +16 -0
  101. package/lib/typescript/src/ui/seel-wfp-widget.d.ts.map +1 -0
  102. package/lib/typescript/src/utils/format_util.d.ts +2 -0
  103. package/lib/typescript/src/utils/format_util.d.ts.map +1 -0
  104. package/lib/typescript/src/utils/http_util.d.ts +18 -0
  105. package/lib/typescript/src/utils/http_util.d.ts.map +1 -0
  106. package/lib/typescript/src/utils/storage_util.d.ts +6 -0
  107. package/lib/typescript/src/utils/storage_util.d.ts.map +1 -0
  108. package/lib/typescript/src/utils/uuid.d.ts +6 -0
  109. package/lib/typescript/src/utils/uuid.d.ts.map +1 -0
  110. package/package.json +23 -12
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+
3
+ import { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
4
+ import { Modal, Platform, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
5
+ import SeelWFPTitleView from "./seel-wfp-title-view.js";
6
+ import SeelWFPInfoView from "./seel-wfp-info-view.js";
7
+ import { createQuote } from "../utils/http_util.js";
8
+ import { writeOptedIn } from "../utils/storage_util.js";
9
+ import KeyValue from "../constants/key_value.js";
10
+ import { moneyFormat } from "../utils/format_util.js";
11
+ import { NetworkRequestStatueEnum } from "../constants/network_request_statue_enum.js";
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ const SeelWFPWidget = ({
14
+ domain = '',
15
+ onChangeValue = ({
16
+ optedIn,
17
+ quotesResponse
18
+ }) => {
19
+ console.log(optedIn, quotesResponse);
20
+ }
21
+ }, ref) => {
22
+ const [quotesResponse, setQuotesResponse] = useState();
23
+ const [termsUrl, setTermsUrl] = useState('');
24
+ const [privacyPolicyUrl, setPrivacyPolicyUrl] = useState('');
25
+ const [optedIn, setOptedIn] = useState(false);
26
+ const [visible, setVisible] = useState(false);
27
+ const [modalVisible, setModalVisible] = useState(false);
28
+ const [widgetTitle, setWidgetTitle] = useState('');
29
+ const [dictionary, setDictionary] = useState({});
30
+ const [price, setPrice] = useState('');
31
+ const [status, setStatus] = useState('');
32
+ const [loadingStatue, setLoadingStatus] = useState(NetworkRequestStatueEnum.Idle);
33
+ useImperativeHandle(ref, () => ({
34
+ setup(quote) {
35
+ fetchNetworkData(quote);
36
+ }
37
+ }), []);
38
+ async function fetchNetworkData(quote) {
39
+ try {
40
+ setLoadingStatus(NetworkRequestStatueEnum.Loading);
41
+ const response = await createQuote(quote);
42
+ setLoadingStatus(NetworkRequestStatueEnum.Success);
43
+ setQuotesResponse(response);
44
+ setStatus(response.status ?? '');
45
+ setStatus('rejected');
46
+ setOptedIn(response.is_default_on);
47
+ if (response.status === 'accepted') {
48
+ const extraInfo = response.extra_info ?? {};
49
+ const currency = response.currency;
50
+ const _title = extraInfo?.widget_title ?? '';
51
+ const _price = moneyFormat(response.price?.toString(), currency, {});
52
+ const dict = {};
53
+ try {
54
+ (response.extra_info?.i18n?.texts ?? []).forEach(kv => {
55
+ if (kv.key === KeyValue.wfp_title) {
56
+ dict[kv.key] = kv.value.toString().replace('{{title}}', _title).replace('{{price}}', _price);
57
+ } else if (kv.key === KeyValue.powered_by) {
58
+ dict[kv.key] = kv.value.toString().replace('{{seel}}', '');
59
+ } else if (kv.key === KeyValue.pricing_message) {
60
+ dict[kv.key] = kv.value.toString().replace('{{price}}', _price);
61
+ } else {
62
+ dict[kv.key] = kv.value;
63
+ }
64
+ });
65
+ } catch (error) {
66
+ console.warn('error:', error);
67
+ }
68
+ setDictionary(dict);
69
+ setPrice(_price);
70
+ setTermsUrl(response.extra_info?.terms_url ?? '');
71
+ setPrivacyPolicyUrl(response.extra_info?.privacy_policy_url ?? '');
72
+ setWidgetTitle(extraInfo.widget_title && extraInfo.widget_title || '');
73
+ setVisible(true);
74
+ } else {
75
+ setModalVisible(false);
76
+ setVisible(false);
77
+ }
78
+ } catch (error) {
79
+ console.warn(error);
80
+ setLoadingStatus(NetworkRequestStatueEnum.Failed);
81
+ setModalVisible(false);
82
+ setVisible(false);
83
+ }
84
+ }
85
+
86
+ // useEffect(() => {
87
+ // fetchNetworkData();
88
+ // }, [optedIn]);
89
+ useEffect(() => {
90
+ onChangeValue({
91
+ optedIn,
92
+ quotesResponse
93
+ });
94
+ }, [onChangeValue, optedIn, quotesResponse]);
95
+ const renderIneligibleModalView = () => {
96
+ const margin = 12;
97
+ return /*#__PURE__*/_jsx(TouchableOpacity, {
98
+ style: [defaultStyles.ineligibleModalViewContainer],
99
+ onPress: () => {
100
+ setModalVisible(false);
101
+ },
102
+ children: /*#__PURE__*/_jsxs(View, {
103
+ style: [defaultStyles.ineligibleModalView],
104
+ children: [/*#__PURE__*/_jsx(Text, {
105
+ style: [defaultStyles.ineligibleText, {
106
+ marginBottom: margin
107
+ }],
108
+ children: dictionary[KeyValue.ineligible_main_message] || ''
109
+ }), /*#__PURE__*/_jsxs(Text, {
110
+ style: [defaultStyles.ineligibleText],
111
+ children: [dictionary[KeyValue.ineligible_reason_shipping] && ' • ', dictionary[KeyValue.ineligible_reason_shipping] || '']
112
+ }), /*#__PURE__*/_jsxs(Text, {
113
+ style: [defaultStyles.ineligibleText],
114
+ children: [dictionary[KeyValue.ineligible_reason_currency] && ' • ', dictionary[KeyValue.ineligible_reason_currency] || '']
115
+ }), /*#__PURE__*/_jsxs(Text, {
116
+ style: [defaultStyles.ineligibleText],
117
+ children: [dictionary[KeyValue.ineligible_reason_value] && ' • ', dictionary[KeyValue.ineligible_reason_value] || '']
118
+ }), /*#__PURE__*/_jsxs(Text, {
119
+ style: [defaultStyles.ineligibleText],
120
+ children: [dictionary[KeyValue.ineligible_reason_items] && ' • ', dictionary[KeyValue.ineligible_reason_items] || '']
121
+ }), /*#__PURE__*/_jsxs(Text, {
122
+ style: [defaultStyles.ineligibleText],
123
+ children: [dictionary[KeyValue.ineligible_reason_system] && ' • ', dictionary[KeyValue.ineligible_reason_system] || '']
124
+ }), /*#__PURE__*/_jsx(Text, {
125
+ style: [defaultStyles.ineligibleText, {
126
+ marginTop: margin
127
+ }],
128
+ children: dictionary[KeyValue.ineligible_support_message] || ''
129
+ })]
130
+ })
131
+ });
132
+ };
133
+ return /*#__PURE__*/_jsx(View, {
134
+ style: [defaultStyles.container],
135
+ children: visible ? /*#__PURE__*/_jsxs(View, {
136
+ children: [/*#__PURE__*/_jsx(SeelWFPTitleView, {
137
+ status: status,
138
+ title: widgetTitle,
139
+ price: price,
140
+ optedIn: optedIn,
141
+ dictionary: dictionary,
142
+ loadingStatue: loadingStatue,
143
+ onClickInfoIcon: () => {
144
+ setModalVisible(true);
145
+ },
146
+ onChangeOptedInValue: async value => {
147
+ if (status === 'accepted') {
148
+ writeOptedIn(value);
149
+ setOptedIn(value);
150
+ onChangeValue({
151
+ optedIn,
152
+ quotesResponse
153
+ });
154
+ } else {
155
+ setModalVisible(true);
156
+ }
157
+ }
158
+ }), /*#__PURE__*/_jsxs(Modal, {
159
+ animationType: status === 'accepted' ? 'slide' : 'fade',
160
+ transparent: status === 'accepted' ? false : true,
161
+ visible: visible && modalVisible,
162
+ onRequestClose: () => {
163
+ setModalVisible(false);
164
+ },
165
+ children: [status === 'accepted' ? /*#__PURE__*/_jsx(SeelWFPInfoView, {
166
+ widgetTitle: widgetTitle,
167
+ dictionary: dictionary,
168
+ domain: domain,
169
+ termsUrl: termsUrl,
170
+ privacyPolicyUrl: privacyPolicyUrl,
171
+ onClickClose: () => {
172
+ setModalVisible(false);
173
+ },
174
+ onChangeOptedInValue: value => {
175
+ setModalVisible(false);
176
+ if (status === 'accepted') {
177
+ setOptedIn(value);
178
+ onChangeValue({
179
+ optedIn,
180
+ quotesResponse
181
+ });
182
+ } else {
183
+ setOptedIn(false);
184
+ onChangeValue({
185
+ optedIn,
186
+ quotesResponse
187
+ });
188
+ }
189
+ }
190
+ }) : null, status === 'rejected' ? renderIneligibleModalView() : null]
191
+ })]
192
+ }) : /*#__PURE__*/_jsx(View, {})
193
+ });
194
+ };
195
+ const defaultStyles = StyleSheet.create({
196
+ container: {
197
+ width: '100%'
198
+ },
199
+ ineligibleModalViewContainer: {
200
+ // width: '100%',
201
+ height: '100%',
202
+ // flex: 1,
203
+ justifyContent: 'center',
204
+ // alignItems: 'center',
205
+ backgroundColor: 'rgba(0, 0, 0, 0.4)'
206
+ // backgroundColor: 'white',
207
+ },
208
+ ineligibleModalView: {
209
+ padding: 12,
210
+ backgroundColor: 'white'
211
+ },
212
+ ineligibleText: {
213
+ color: '#202223',
214
+ fontFamily: Platform.select({
215
+ ios: 'Inter'
216
+ }),
217
+ fontSize: 12,
218
+ fontStyle: 'normal',
219
+ fontWeight: 400,
220
+ lineHeight: 16
221
+ }
222
+ });
223
+ export default /*#__PURE__*/forwardRef(SeelWFPWidget);
224
+ //# sourceMappingURL=seel-wfp-widget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["forwardRef","useEffect","useImperativeHandle","useState","Modal","Platform","StyleSheet","Text","TouchableOpacity","View","SeelWFPTitleView","SeelWFPInfoView","createQuote","writeOptedIn","KeyValue","moneyFormat","NetworkRequestStatueEnum","jsx","_jsx","jsxs","_jsxs","SeelWFPWidget","domain","onChangeValue","optedIn","quotesResponse","console","log","ref","setQuotesResponse","termsUrl","setTermsUrl","privacyPolicyUrl","setPrivacyPolicyUrl","setOptedIn","visible","setVisible","modalVisible","setModalVisible","widgetTitle","setWidgetTitle","dictionary","setDictionary","price","setPrice","status","setStatus","loadingStatue","setLoadingStatus","Idle","setup","quote","fetchNetworkData","Loading","response","Success","is_default_on","extraInfo","extra_info","currency","_title","widget_title","_price","toString","dict","i18n","texts","forEach","kv","key","wfp_title","value","replace","powered_by","pricing_message","error","warn","terms_url","privacy_policy_url","Failed","renderIneligibleModalView","margin","style","defaultStyles","ineligibleModalViewContainer","onPress","children","ineligibleModalView","ineligibleText","marginBottom","ineligible_main_message","ineligible_reason_shipping","ineligible_reason_currency","ineligible_reason_value","ineligible_reason_items","ineligible_reason_system","marginTop","ineligible_support_message","container","title","onClickInfoIcon","onChangeOptedInValue","animationType","transparent","onRequestClose","onClickClose","create","width","height","justifyContent","backgroundColor","padding","color","fontFamily","select","ios","fontSize","fontStyle","fontWeight","lineHeight"],"sourceRoot":"../../../src","sources":["ui/seel-wfp-widget.tsx"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,SAAS,EAAEC,mBAAmB,EAAEC,QAAQ,QAAQ,OAAO;AAC5E,SACEC,KAAK,EACLC,QAAQ,EACRC,UAAU,EACVC,IAAI,EACJC,gBAAgB,EAChBC,IAAI,QACC,cAAc;AACrB,OAAOC,gBAAgB,MAAM,0BAAuB;AACpD,OAAOC,eAAe,MAAuB,yBAAsB;AACnE,SAASC,WAAW,QAAQ,uBAAoB;AAChD,SAASC,YAAY,QAAQ,0BAAuB;AAEpD,OAAOC,QAAQ,MAAM,2BAAwB;AAE7C,SAASC,WAAW,QAAQ,yBAAsB;AAClD,SAASC,wBAAwB,QAAQ,6CAA0C;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAiBpF,MAAMC,aAAa,GAAGA,CACpB;EACEC,MAAM,GAAG,EAAE;EACXC,aAAa,GAAGA,CAAC;IAAEC,OAAO;IAAEC;EAAe,CAAC,KAAK;IAC/CC,OAAO,CAACC,GAAG,CAACH,OAAO,EAAEC,cAAc,CAAC;EACtC;AACkB,CAAC,EACrBG,GAAQ,KACL;EACH,MAAM,CAACH,cAAc,EAAEI,iBAAiB,CAAC,GAAG1B,QAAQ,CAAkB,CAAC;EACvE,MAAM,CAAC2B,QAAQ,EAAEC,WAAW,CAAC,GAAG5B,QAAQ,CAAC,EAAE,CAAC;EAC5C,MAAM,CAAC6B,gBAAgB,EAAEC,mBAAmB,CAAC,GAAG9B,QAAQ,CAAC,EAAE,CAAC;EAC5D,MAAM,CAACqB,OAAO,EAAEU,UAAU,CAAC,GAAG/B,QAAQ,CAAC,KAAK,CAAC;EAC7C,MAAM,CAACgC,OAAO,EAAEC,UAAU,CAAC,GAAGjC,QAAQ,CAAC,KAAK,CAAC;EAC7C,MAAM,CAACkC,YAAY,EAAEC,eAAe,CA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AQ,EAAE,EAAE;IACZC,SAAS,EAAE,QAAQ;IACnBC,UAAU,EAAE,GAAG;IACfC,UAAU,EAAE;EACd;AACF,CAAC,CAAC;AAEF,4BAAevH,UAAU,CAAuCqB,aAAa,CAAC","ignoreList":[]}
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ export const moneyFormat = (money, currency, options) => {
4
+ try {
5
+ // 解构options参数,提供默认值
6
+ const {
7
+ showCurrency = true,
8
+ locale = '',
9
+ fallbackValue = '-'
10
+ } = options;
11
+ // 如果没传 currency 或者传空串,就认为不需要做货币格式化
12
+ const propsCurrency = currency || '';
13
+ let targetMoney = money;
14
+ // 如果money是null, undefined或空字符串,或者不是数字或者字符串,直接返回 fallbackValue
15
+ if (targetMoney === null || targetMoney === undefined || targetMoney === '') {
16
+ return fallbackValue;
17
+ }
18
+ // 完善判断非数字情况
19
+ if (typeof money === 'string') {
20
+ targetMoney = Number(money); // 或者可以使用 parseFloat(money)
21
+ }
22
+ // 如果转换后的值不是有效的数字,返回 fallbackValue
23
+ if (Number.isNaN(targetMoney)) return fallbackValue;
24
+ // 如果没有传入currency,把原数据返回,如果不是数字则显示 fallbackValue
25
+ if (!propsCurrency) return targetMoney;
26
+ // 检查 Intl.NumberFormat 是否支持
27
+ if (typeof Intl === 'undefined' || typeof Intl.NumberFormat === 'undefined') {
28
+ // 降级处理:简单格式化
29
+ if (showCurrency) {
30
+ return `${targetMoney} ${propsCurrency}`;
31
+ }
32
+ return `${targetMoney}`;
33
+ }
34
+ // 币种locale 映射
35
+ const currencyLocaleMap = {
36
+ USD: 'en-US',
37
+ CAD: 'en-CA',
38
+ AUD: 'en-AU',
39
+ EUR: 'de-DE',
40
+ GBP: 'en-GB',
41
+ NZD: 'en-NZ',
42
+ HKD: 'zh-HK',
43
+ SGD: 'zh-SG',
44
+ DKK: 'da-DK'
45
+ };
46
+ const usedLocale = locale || (propsCurrency.toUpperCase() in currencyLocaleMap ? currencyLocaleMap[propsCurrency.toUpperCase()] : '') || 'en-US';
47
+ const numberFormat = new Intl.NumberFormat(usedLocale, {
48
+ style: 'currency',
49
+ currency: propsCurrency,
50
+ minimumFractionDigits: 2,
51
+ maximumFractionDigits: 2
52
+ });
53
+ // 检查 formatToParts 是否支持
54
+ if (typeof numberFormat.formatToParts !== 'function') {
55
+ // 降级处理:使用 format 方法
56
+ const formatted = numberFormat.format(targetMoney || 0);
57
+ if (showCurrency) {
58
+ return `${formatted} ${propsCurrency}`;
59
+ }
60
+ return formatted;
61
+ }
62
+ // 获取货币格式化后的各个部分,包括货币符号
63
+ const parts = numberFormat.formatToParts(targetMoney || 0);
64
+ // 兼容性处理:避免使用可选链操作符
65
+ const currencyPart = parts.find(part => part.type === 'currency');
66
+ const currencySymbol = currencyPart ? currencyPart.value : '';
67
+ // 特殊处理 HKD 货币,使用 $ 符号而不是 HK$
68
+ if (propsCurrency.toUpperCase() === 'HKD') {
69
+ const formattedNumber = numberFormat.format(targetMoney || 0).replace(currencySymbol, '$').trim();
70
+ if (showCurrency) {
71
+ return `${formattedNumber} ${propsCurrency}`;
72
+ }
73
+ return formattedNumber;
74
+ }
75
+ // 判断货币符号是否与 currency 一致
76
+ if (currencySymbol === propsCurrency) {
77
+ if (showCurrency) {
78
+ return `${targetMoney} ${propsCurrency}`; // 如果符号一致且需要显示货币符号,返回 money + currency
79
+ }
80
+ return `${targetMoney}`; // 如果符号一致但不需要显示货币符号,返回只有 money
81
+ }
82
+ if (showCurrency) {
83
+ return `${numberFormat.format(targetMoney || 0)} ${propsCurrency}`;
84
+ }
85
+ return `${numberFormat.format(targetMoney || 0)}`;
86
+ } catch (error) {
87
+ console.warn('moneyFormat error:', error);
88
+ // 降级处理:返回简单的格式化结果
89
+ const propsCurrency = currency || '';
90
+ const {
91
+ showCurrency = true,
92
+ fallbackValue = '-'
93
+ } = options;
94
+ const targetMoney = money;
95
+ if (targetMoney === null || targetMoney === undefined || targetMoney === '') {
96
+ return fallbackValue;
97
+ }
98
+ const num = typeof targetMoney === 'string' ? Number(targetMoney) : targetMoney;
99
+ if (Number.isNaN(num)) return fallbackValue;
100
+ if (!propsCurrency) return num;
101
+ if (showCurrency) {
102
+ return `${num} ${propsCurrency}`;
103
+ }
104
+ return `${num}`;
105
+ }
106
+ };
107
+ //# sourceMappingURL=format_util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["moneyFormat","money","currency","options","showCurrency","locale","fallbackValue","propsCurrency","targetMoney","undefined","Number","isNaN","Intl","NumberFormat","currencyLocaleMap","USD","CAD","AUD","EUR","GBP","NZD","HKD","SGD","DKK","usedLocale","toUpperCase","numberFormat","style","minimumFractionDigits","maximumFractionDigits","formatToParts","formatted","format","parts","currencyPart","find","part","type","currencySymbol","value","formattedNumber","replace","trim","error","console","warn","num"],"sourceRoot":"../../../src","sources":["utils/format_util.ts"],"mappings":";;AAAA,OAAO,MAAMA,WAAW,GAAGA,CAACC,KAAU,EAAEC,QAAgB,EAAEC,OAAY,KAAK;EACzE,IAAI;IACF;IACA,MAAM;MAAEC,YAAY,GAAG,IAAI;MAAEC,MAAM,GAAG,EAAE;MAAEC,aAAa,GAAG;IAAI,CAAC,GAAGH,OAAO;IACzE;IACA,MAAMI,aAAa,GAAGL,QAAQ,IAAI,EAAE;IACpC,IAAIM,WAAW,GAAGP,KAAK;IACvB;IACA,IACEO,WAAW,KAAK,IAAI,IACpBA,WAAW,KAAKC,SAAS,IACzBD,WAAW,KAAK,EAAE,EAClB;MACA,OAAOF,aAAa;IACtB;IACA;IACA,IAAI,OAAOL,KAAK,KAAK,QAAQ,EAAE;MAC7BO,WAAW,GAAGE,MAAM,CAACT,KAAK,CAAC,CAAC,CAAC;IAC/B;IACA;IACA,IAAIS,MAAM,CAACC,KAAK,CAACH,WAAW,CAAC,EAAE,OAAOF,aAAa;IACnD;IACA,IAAI,CAACC,aAAa,EAAE,OAAOC,WAAW;IACtC;IACA,IACE,OAAOI,IAAI,KAAK,WAAW,IAC3B,OAAOA,IAAI,CAACC,YAAY,KAAK,WAA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AE,OAAOxC,aAAa;IAC3C,IAAI,CAACC,aAAa,EAAE,OAAOuC,GAAG;IAC9B,IAAI1C,YAAY,EAAE;MAChB,OAAO,GAAG0C,GAAG,IAAIvC,aAAa,EAAE;IAClC;IACA,OAAO,GAAGuC,GAAG,EAAE;EACjB;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ import { SeelWidgetSDK } from "../core/SeelWidgetSDK.js";
4
+ import { post } from "../network/request.js";
5
+ export let NetworkErrorEnum = /*#__PURE__*/function (NetworkErrorEnum) {
6
+ NetworkErrorEnum[NetworkErrorEnum["InvalidURL"] = 0] = "InvalidURL";
7
+ NetworkErrorEnum[NetworkErrorEnum["NoData"] = 1] = "NoData";
8
+ NetworkErrorEnum[NetworkErrorEnum["DecodingError"] = 2] = "DecodingError";
9
+ NetworkErrorEnum[NetworkErrorEnum["NetworkError"] = 3] = "NetworkError";
10
+ NetworkErrorEnum[NetworkErrorEnum["ServerError"] = 4] = "ServerError";
11
+ /**
12
+ * Configuration error
13
+ */
14
+ NetworkErrorEnum[NetworkErrorEnum["ConfigError"] = 5] = "ConfigError";
15
+ NetworkErrorEnum[NetworkErrorEnum["Unknown"] = 6] = "Unknown";
16
+ return NetworkErrorEnum;
17
+ }({});
18
+ const defaultBaseURL = SeelWidgetSDK.shared.baseURL;
19
+ export const createQuote = body => {
20
+ const url = defaultBaseURL + '/v1/ecommerce/quotes';
21
+ return post(url, JSON.stringify(body), {});
22
+ };
23
+ export const createEvent = body => {
24
+ const url = defaultBaseURL + '/v1/ecommerce/events';
25
+ return post(url, JSON.stringify(body), {});
26
+ };
27
+ //# sourceMappingURL=http_util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SeelWidgetSDK","post","NetworkErrorEnum","defaultBaseURL","shared","baseURL","createQuote","body","url","JSON","stringify","createEvent"],"sourceRoot":"../../../src","sources":["utils/http_util.ts"],"mappings":";;AAAA,SAASA,aAAa,QAAQ,0BAAuB;AAIrD,SAASC,IAAI,QAAQ,uBAAoB;AAEzC,WAAYC,gBAAgB,0BAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAM1B;AACF;AACA;EARYA,gBAAgB,CAAhBA,gBAAgB;EAAhBA,gBAAgB,CAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA;AAa5B,MAAMC,cAAsB,GAAGH,aAAa,CAACI,MAAM,CAACC,OAAO;AAE3D,OAAO,MAAMC,WAAW,GAAIC,IAAoB,IAAK;EACnD,MAAMC,GAAG,GAAGL,cAAc,GAAG,sBAAsB;EACnD,OAAOF,IAAI,CAAkBO,GAAG,EAAEC,IAAI,CAACC,SAAS,CAACH,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED,OAAO,MAAMI,WAAW,GAAIJ,IAAa,IAAK;EAC5C,MAAMC,GAAG,GAAGL,cAAc,GAAG,sBAAsB;EACnD,OAAOF,IAAI,CAAkBO,GAAG,EAAEC,IAAI,CAACC,SAAS,CAACH,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ import AsyncStorage from '@react-native-async-storage/async-storage';
4
+ const StorageValue = {
5
+ True: '1',
6
+ False: '0'
7
+ };
8
+ export const AsyncStorageKey = {
9
+ OptedIn: 'SeelWFPWidget.OptedIn'
10
+ };
11
+ function logSetError(key, error) {
12
+ console.error('Failed to set [', key, '] error:', error);
13
+ }
14
+ function logGetError(key, error) {
15
+ console.error('Failed to get [', key, '] error:', error);
16
+ }
17
+ export const writeOptedIn = async value => {
18
+ const key = AsyncStorageKey.OptedIn;
19
+ try {
20
+ await AsyncStorage.setItem(key, value ? StorageValue.True : StorageValue.False);
21
+ } catch (error) {
22
+ logSetError(key, error);
23
+ throw error;
24
+ }
25
+ };
26
+ export const readOptedIn = async () => {
27
+ const key = AsyncStorageKey.OptedIn;
28
+ try {
29
+ const value = await AsyncStorage.getItem(key);
30
+ return value !== null && value !== '' && value !== StorageValue.False;
31
+ } catch (error) {
32
+ logGetError(key, error);
33
+ return false;
34
+ }
35
+ };
36
+ //# sourceMappingURL=storage_util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["AsyncStorage","StorageValue","True","False","AsyncStorageKey","OptedIn","logSetError","key","error","console","logGetError","writeOptedIn","value","setItem","readOptedIn","getItem"],"sourceRoot":"../../../src","sources":["utils/storage_util.ts"],"mappings":";;AAAA,OAAOA,YAAY,MAAM,2CAA2C;AAEpE,MAAMC,YAAY,GAAG;EACnBC,IAAI,EAAE,GAAG;EACTC,KAAK,EAAE;AACT,CAAU;AAEV,OAAO,MAAMC,eAAe,GAAG;EAC7BC,OAAO,EAAE;AACX,CAAC;AAED,SAASC,WAAWA,CAACC,GAAW,EAAEC,KAAc,EAAE;EAChDC,OAAO,CAACD,KAAK,CAAC,iBAAiB,EAAED,GAAG,EAAE,UAAU,EAAEC,KAAK,CAAC;AAC1D;AAEA,SAASE,WAAWA,CAACH,GAAW,EAAEC,KAAc,EAAE;EAChDC,OAAO,CAACD,KAAK,CAAC,iBAAiB,EAAED,GAAG,EAAE,UAAU,EAAEC,KAAK,CAAC;AAC1D;AAEA,OAAO,MAAMG,YAAY,GAAG,MAAOC,KAAc,IAAoB;EACnE,MAAML,GAAG,GAAGH,eAAe,CAACC,OAAO;EACnC,IAAI;IACF,MAAML,YAAY,CAACa,OAAO,CACxBN,GAAG,EACHK,KAAK,GAAGX,YAAY,CAACC,IAAI,GAAGD,YAAY,CAACE,KAC3C,CAAC;EACH,CAAC,CAAC,OAAOK,KAAK,EAAE;IACdF,WAAW,CAACC,GAAG,EAAEC,KAAK,CAAC;IACvB,MAAMA,KAAK;EACb;AACF,CAAC;AAED,OAAO,MAAMM,WAAW,GAAG,MAAAA,CAAA,KAA8B;EACvD,MAAMP,GAAG,GAAGH,eAAe,CAACC,OAAO;EACnC,IAAI;IACF,MAAMO,KAAK,GAAG,MAAMZ,YAAY,CAACe,OAAO,CAACR,GAAG,CAAC;IAC7C,OAAOK,KAAK,KAAK,IAAI,IAAIA,KAAK,KAAK,EAAE,IAAIA,KAAK,KAAKX,YAAY,CAACE,KAAK;EACvE,CAAC,CAAC,OAAOK,KAAK,EAAE;IACdE,WAAW,CAACH,GAAG,EAAEC,KAAK,CAAC;IACvB,OAAO,KAAK;EACd;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ /* eslint-disable no-bitwise */
4
+ /**
5
+ * Generate a random UUID (v4)
6
+ * @returns A UUID string in the format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
7
+ */
8
+ export function randomUUID() {
9
+ // Use crypto.randomUUID if available (browser/Node.js 19+)
10
+ if (typeof crypto !== 'undefined' && crypto.randomUUID) {
11
+ return crypto.randomUUID();
12
+ }
13
+
14
+ // Fallback implementation for React Native
15
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
16
+ const r = Math.random() * 16 | 0;
17
+ const v = c === 'x' ? r : r & 0x3 | 0x8;
18
+ return v.toString(16);
19
+ });
20
+ }
21
+ //# sourceMappingURL=uuid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["randomUUID","crypto","replace","c","r","Math","random","v","toString"],"sourceRoot":"../../../src","sources":["utils/uuid.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,UAAUA,CAAA,EAAW;EACnC;EACA,IAAI,OAAOC,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACD,UAAU,EAAE;IACtD,OAAOC,MAAM,CAACD,UAAU,CAAC,CAAC;EAC5B;;EAEA;EACA,OAAO,sCAAsC,CAACE,OAAO,CAAC,OAAO,EAAGC,CAAC,IAAK;IACpE,MAAMC,CAAC,GAAIC,IAAI,CAACC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAI,CAAC;IAClC,MAAMC,CAAC,GAAGJ,CAAC,KAAK,GAAG,GAAGC,CAAC,GAAIA,CAAC,GAAG,GAAG,GAAI,GAAG;IACzC,OAAOG,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC;EACvB,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,48 @@
1
+ declare const KeyValue: {
2
+ wfp_title: string;
3
+ wfp_subtitle: string;
4
+ wfp_description: string;
5
+ powered_by: string;
6
+ ineligible_main_message: string;
7
+ ineligible_reason_shipping: string;
8
+ ineligible_reason_currency: string;
9
+ ineligible_reason_value: string;
10
+ ineligible_reason_items: string;
11
+ ineligible_reason_system: string;
12
+ ineligible_support_message: string;
13
+ ineligible_title: string;
14
+ coverage_title: string;
15
+ pricing_message: string;
16
+ product_name: string;
17
+ whats_covered_title: string;
18
+ standard_coverage_intro: string;
19
+ standard_coverage_not_as_described: string;
20
+ standard_coverage_lost_damaged: string;
21
+ standard_coverage_not_matching: string;
22
+ standard_coverage_quality: string;
23
+ standard_coverage_not_delivered: string;
24
+ additional_coverage_intro: string;
25
+ additional_coverage_extended_return: string;
26
+ additional_coverage_post_delivery: string;
27
+ additional_coverage_delay: string;
28
+ concierge_intro: string;
29
+ concierge_app_access: string;
30
+ concierge_support: string;
31
+ privacy_policy: string;
32
+ terms_of_service: string;
33
+ cta_secure_purchase: string;
34
+ cta_continue_without: string;
35
+ get_full_refund: string;
36
+ lost_in_transit: string;
37
+ item_not_as_described: string;
38
+ item_damaged: string;
39
+ package_stolen: string;
40
+ easy_resolution: string;
41
+ resolve_with_clicks: string;
42
+ complete_peace_of_mind: string;
43
+ zero_risk: string;
44
+ get_refund_promptly: string;
45
+ worry_free_delivery: string;
46
+ };
47
+ export default KeyValue;
48
+ //# sourceMappingURL=key_value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key_value.d.ts","sourceRoot":"","sources":["../../../../src/constants/key_value.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Cb,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare enum NetworkRequestStatueEnum {
2
+ Idle = 1,
3
+ Refreshing = 2,
4
+ LoadingMore = 4,
5
+ Loading = 6,
6
+ RefreshSuccess = 8,
7
+ LoadMoreSuccess = 16,
8
+ Success = 24,
9
+ RefreshFailed = 32,
10
+ LoadMoreFailed = 64,
11
+ Failed = 96
12
+ }
13
+ //# sourceMappingURL=network_request_statue_enum.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"network_request_statue_enum.d.ts","sourceRoot":"","sources":["../../../../src/constants/network_request_statue_enum.ts"],"names":[],"mappings":"AAAA,oBAAY,wBAAwB;IAElC,IAAI,IAAS;IACb,UAAU,IAAS;IACnB,WAAW,IAAS;IACpB,OAAO,IAA2B;IAClC,cAAc,IAAS;IACvB,eAAe,KAAS;IACxB,OAAO,KAAmC;IAC1C,aAAa,KAAS;IACtB,cAAc,KAAS;IACvB,MAAM,KAAiC;CACxC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Environment Enum
3
+ */
4
+ export declare enum SeelEnvironment {
5
+ Development = "development",
6
+ Production = "production"
7
+ }
8
+ interface SeelWidgetSDKProps {
9
+ apiKey: string;
10
+ apiVersion?: string;
11
+ environment?: SeelEnvironment;
12
+ }
13
+ /**
14
+ * SeelWidgetSDK
15
+ * Main SDK class for Seel Widget functionality
16
+ */
17
+ export declare class SeelWidgetSDK {
18
+ private static _shared;
19
+ static get shared(): SeelWidgetSDK;
20
+ private _apiKey;
21
+ private _apiVersion;
22
+ private _environment;
23
+ private constructor();
24
+ /**
25
+ * Configure SeelWidgetSDK
26
+ * @param apiKey API key
27
+ * @param environment Environment (optional, defaults to production)
28
+ */
29
+ configure(props: SeelWidgetSDKProps): void;
30
+ /**
31
+ * Get current API Key
32
+ */
33
+ get apiKey(): string;
34
+ /**
35
+ * Get current API Version
36
+ */
37
+ get apiVersion(): string;
38
+ /**
39
+ * Get current environment
40
+ */
41
+ get environment(): SeelEnvironment;
42
+ /**
43
+ * Get current BaseURL
44
+ */
45
+ get baseURL(): string;
46
+ /**
47
+ * Check if configured
48
+ */
49
+ get isConfigured(): boolean;
50
+ }
51
+ export {};
52
+ //# sourceMappingURL=SeelWidgetSDK.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SeelWidgetSDK.d.ts","sourceRoot":"","sources":["../../../../src/core/SeelWidgetSDK.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,eAAe;IACzB,WAAW,gBAAgB;IAC3B,UAAU,eAAe;CAC1B;AAKD,UAAU,kBAAkB;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED;;;GAGG;AACH,qBAAa,aAAa;IAExB,OAAO,CAAC,MAAM,CAAC,OAAO,CAA8B;IAEpD,WAAkB,MAAM,IAAI,aAAa,CAKxC;IAGD,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,YAAY,CAA2C;IAG/D,OAAO;IAMP;;;;OAIG;IACI,SAAS,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IAMjD;;OAEG;IACH,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,eAAe,CAExC;IAED;;OAEG;IACH,IAAW,OAAO,IAAI,MAAM,CAI3B;IAED;;OAEG;IACH,IAAW,YAAY,IAAI,OAAO,CAEjC;CACF"}
@@ -0,0 +1,60 @@
1
+ import type { IEventInfo, IEvents, EventType } from './IEvents';
2
+ /**
3
+ * Events Request/Response class
4
+ * Converts snake_case API format to camelCase for internal use
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const iRequest: IEvents = {
9
+ * client_ip: '',
10
+ * customer_id: '',
11
+ * session_id: '',
12
+ * event_source: '',
13
+ * event_ts: '',
14
+ * event_type: EventTypeEnum.product_page_exit,
15
+ * };
16
+ *
17
+ * const request: EventsRequest = new EventsRequest(iRequest);
18
+ * ```
19
+ */
20
+ export default class EventsRequest {
21
+ /**
22
+ * Browser IP address
23
+ */
24
+ clientIP: string;
25
+ /**
26
+ * Customer Id
27
+ */
28
+ customerId: string;
29
+ /**
30
+ * Device Id
31
+ */
32
+ deviceId?: string;
33
+ /**
34
+ * Event Id
35
+ */
36
+ eventId?: string;
37
+ /**
38
+ * Event information object
39
+ * Each event_type has its own unique schema. For specific details, please refer to the custom pixel guide.
40
+ */
41
+ eventInfo?: IEventInfo;
42
+ /**
43
+ * Event source
44
+ */
45
+ eventSource: string;
46
+ /**
47
+ * Event created timestamp in milliseconds
48
+ */
49
+ eventTs: string;
50
+ /**
51
+ * Event type
52
+ */
53
+ eventType: EventType;
54
+ /**
55
+ * Session Id
56
+ */
57
+ sessionId: string;
58
+ constructor(props: IEvents);
59
+ }
60
+ //# sourceMappingURL=EventsRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventsRequest.d.ts","sourceRoot":"","sources":["../../../../src/dto/EventsRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEhE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,SAAS,EAAE,SAAS,CAAC;IACrB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;gBAEN,KAAK,EAAE,OAAO;CAW3B"}