@glomopay/react-native-sdk 3.0.1 → 4.0.0
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/CHANGELOG.md +38 -2
- package/MIGRATION.md +129 -0
- package/README.md +176 -126
- package/lib/glomo-checkout.d.ts +2 -1
- package/lib/glomo-checkout.d.ts.map +1 -1
- package/lib/glomo-checkout.js +25 -3
- package/lib/glomo-lrs-checkout.d.ts +1 -1
- package/lib/glomo-lrs-checkout.d.ts.map +1 -1
- package/lib/glomo-standard-checkout.d.ts +20 -0
- package/lib/glomo-standard-checkout.d.ts.map +1 -1
- package/lib/glomo-standard-checkout.js +15 -6
- package/lib/glomo-subscriptions-checkout.d.ts +8 -0
- package/lib/glomo-subscriptions-checkout.d.ts.map +1 -0
- package/lib/glomo-subscriptions-checkout.js +85 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -3
- package/lib/types/checkout.d.ts +33 -22
- package/lib/types/checkout.d.ts.map +1 -1
- package/lib/types/checkout.js +12 -1
- package/lib/types/standard-checkout.d.ts +3 -7
- package/lib/types/standard-checkout.d.ts.map +1 -1
- package/lib/types/subscriptions-checkout.d.ts +29 -0
- package/lib/types/subscriptions-checkout.d.ts.map +1 -0
- package/lib/types/subscriptions-checkout.js +3 -0
- package/lib/use-glomo-checkout.d.ts +34 -4
- package/lib/use-glomo-checkout.d.ts.map +1 -1
- package/lib/use-glomo-checkout.js +92 -13
- package/lib/use-lrs-checkout.d.ts +1 -1
- package/lib/use-lrs-checkout.d.ts.map +1 -1
- package/lib/use-standard-checkout.d.ts +14 -9
- package/lib/use-standard-checkout.d.ts.map +1 -1
- package/lib/use-standard-checkout.js +74 -85
- package/lib/utils/analytics.d.ts +86 -3
- package/lib/utils/analytics.d.ts.map +1 -1
- package/lib/utils/analytics.js +344 -22
- package/lib/utils/device-compliance.d.ts.map +1 -1
- package/lib/utils/device-compliance.js +0 -1
- package/package.json +15 -4
- package/src/glomo-checkout.tsx +65 -9
- package/src/glomo-lrs-checkout.tsx +1 -1
- package/src/glomo-standard-checkout.tsx +35 -10
- package/src/glomo-subscriptions-checkout.tsx +83 -0
- package/src/index.ts +5 -5
- package/src/types/checkout.ts +28 -20
- package/src/types/standard-checkout.ts +3 -5
- package/src/types/subscriptions-checkout.ts +31 -0
- package/src/use-glomo-checkout.tsx +158 -17
- package/src/use-lrs-checkout.tsx +1 -1
- package/src/use-standard-checkout.tsx +94 -153
- package/src/utils/analytics.ts +469 -31
- package/src/utils/device-compliance.ts +0 -1
|
@@ -9,19 +9,51 @@ const react_1 = require("react");
|
|
|
9
9
|
const order_type_fetcher_1 = require("./services/order-type-fetcher");
|
|
10
10
|
const validation_1 = require("./utils/validation");
|
|
11
11
|
const analytics_1 = require("./utils/analytics");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*/
|
|
16
|
-
function useGlomoCheckout(props) {
|
|
17
|
-
const { server, publicKey, orderId, onSdkError, devMode = false } = props;
|
|
12
|
+
function useGlomoCheckout(props, internalOptions) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const { server, publicKey, orderId, subscriptionId, onSdkError, devMode = false } = props;
|
|
18
15
|
// Order type resolved from the API - null until detection completes
|
|
19
16
|
const [orderType, setOrderType] = (0, react_1.useState)(null);
|
|
20
17
|
// Whether order type detection is in progress
|
|
21
18
|
const [detecting, setDetecting] = (0, react_1.useState)(false);
|
|
22
|
-
//
|
|
19
|
+
// Whether the props have a mutual exclusion error
|
|
20
|
+
const [propsError, setPropsError] = (0, react_1.useState)(false);
|
|
21
|
+
// Stabilizing onSdkError ref to avoid re-running effects on inline callback changes
|
|
22
|
+
const onSdkErrorRef = (0, react_1.useRef)(onSdkError);
|
|
23
|
+
onSdkErrorRef.current = onSdkError;
|
|
24
|
+
// One-time deprecation warning for direct merchant usage
|
|
25
|
+
const suppressWarning = (_a = internalOptions === null || internalOptions === void 0 ? void 0 : internalOptions._suppressDeprecationWarning) !== null && _a !== void 0 ? _a : false;
|
|
26
|
+
const mockMode = (_b = publicKey === null || publicKey === void 0 ? void 0 : publicKey.toLowerCase().startsWith("test_")) !== null && _b !== void 0 ? _b : false;
|
|
27
|
+
const hasWarnedRef = (0, react_1.useRef)(false);
|
|
28
|
+
(0, react_1.useEffect)(() => {
|
|
29
|
+
if (!hasWarnedRef.current && !suppressWarning) {
|
|
30
|
+
hasWarnedRef.current = true;
|
|
31
|
+
console.warn("[Glomo-RN-SDK] useGlomoCheckout is deprecated and will be removed in a future major version. " +
|
|
32
|
+
"Use the GlomoCheckout component with a ref instead. " +
|
|
33
|
+
"This hook does not provide reactive state - getStatus() is a point-in-time snapshot, not a reactive value.");
|
|
34
|
+
(0, analytics_1.trackUseOfUnsupportedFunctionality)("useGlomoCheckout", orderId !== null && orderId !== void 0 ? orderId : subscriptionId, publicKey, devMode, mockMode, "");
|
|
35
|
+
}
|
|
36
|
+
}, [suppressWarning, orderId, subscriptionId, publicKey, devMode, mockMode]);
|
|
37
|
+
// Refs for the inner LRS, Standard, and Subscriptions checkout components
|
|
23
38
|
const innerLrsRef = (0, react_1.useRef)(null);
|
|
24
39
|
const innerStandardRef = (0, react_1.useRef)(null);
|
|
40
|
+
const innerSubscriptionsRef = (0, react_1.useRef)(null);
|
|
41
|
+
/** Mutual exclusion guard - firing onSdkError if both or neither id is provided */
|
|
42
|
+
(0, react_1.useEffect)(() => {
|
|
43
|
+
const hasBoth = Boolean(orderId) && Boolean(subscriptionId);
|
|
44
|
+
const hasNeither = !orderId && !subscriptionId;
|
|
45
|
+
if (hasBoth) {
|
|
46
|
+
setPropsError(true);
|
|
47
|
+
(0, validation_1.safeCallback)(onSdkErrorRef.current, [[{ type: "validation_error", message: "Provide either orderId or subscriptionId, not both" }]], "onSdkError", devMode);
|
|
48
|
+
}
|
|
49
|
+
else if (hasNeither) {
|
|
50
|
+
setPropsError(true);
|
|
51
|
+
(0, validation_1.safeCallback)(onSdkErrorRef.current, [[{ type: "validation_error", message: "Provide orderId or subscriptionId" }]], "onSdkError", devMode);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
setPropsError(false);
|
|
55
|
+
}
|
|
56
|
+
}, [orderId, subscriptionId, devMode]);
|
|
25
57
|
/**
|
|
26
58
|
* Tracking whether start() has been called and the inner component needs to be auto-started.
|
|
27
59
|
* This bridges the gap between order type resolution (async) and inner component mount (next render).
|
|
@@ -51,6 +83,9 @@ function useGlomoCheckout(props) {
|
|
|
51
83
|
if (orderType === "standard" && innerStandardRef.current) {
|
|
52
84
|
return innerStandardRef.current.getStatus();
|
|
53
85
|
}
|
|
86
|
+
if (orderType === "subscriptions" && innerSubscriptionsRef.current) {
|
|
87
|
+
return innerSubscriptionsRef.current.getStatus();
|
|
88
|
+
}
|
|
54
89
|
return "ready";
|
|
55
90
|
}, [detecting, orderType]);
|
|
56
91
|
/**
|
|
@@ -66,6 +101,13 @@ function useGlomoCheckout(props) {
|
|
|
66
101
|
if (devMode) {
|
|
67
102
|
console.log("[Glomo-RN-SDK] start() called");
|
|
68
103
|
}
|
|
104
|
+
// Aborting if mutual exclusion guard detected a props error
|
|
105
|
+
if (propsError) {
|
|
106
|
+
if (devMode) {
|
|
107
|
+
console.error("[Glomo-RN-SDK] start() aborted: invalid orderId/subscriptionId combination");
|
|
108
|
+
}
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
69
111
|
// Validating inputs before making the API call
|
|
70
112
|
const errors = [];
|
|
71
113
|
if (!(0, validation_1.isValidPublicKey)(publicKey)) {
|
|
@@ -75,7 +117,11 @@ function useGlomoCheckout(props) {
|
|
|
75
117
|
field: "publicKey",
|
|
76
118
|
});
|
|
77
119
|
}
|
|
78
|
-
|
|
120
|
+
/**
|
|
121
|
+
* For subscriptions flow, skipping orderId validation entirely - GlomoSubscriptionsCheckout
|
|
122
|
+
* owns subscriptionId validation (trim, empty, prefix). For order flow, validating orderId.
|
|
123
|
+
*/
|
|
124
|
+
if (!subscriptionId && !(0, validation_1.isValidOrderId)(orderId)) {
|
|
79
125
|
errors.push({
|
|
80
126
|
type: "validation_error",
|
|
81
127
|
message: "Invalid orderId: must start with 'order_' and be a valid string",
|
|
@@ -90,6 +136,23 @@ function useGlomoCheckout(props) {
|
|
|
90
136
|
(0, validation_1.safeCallback)(onSdkError, [errors], "onSdkError", devMode);
|
|
91
137
|
return false;
|
|
92
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* For subscriptions, orderType is already "subscriptions" and the inner component is mounted.
|
|
141
|
+
* Calling start() directly - no promise/effect bridge needed since no async detection occurs.
|
|
142
|
+
*/
|
|
143
|
+
if (subscriptionId) {
|
|
144
|
+
if (innerSubscriptionsRef.current) {
|
|
145
|
+
const started = innerSubscriptionsRef.current.start();
|
|
146
|
+
if (devMode) {
|
|
147
|
+
console.log(`[Glomo-RN-SDK] Subscriptions inner start() returned: ${started}`);
|
|
148
|
+
}
|
|
149
|
+
return started;
|
|
150
|
+
}
|
|
151
|
+
if (devMode) {
|
|
152
|
+
console.error("[Glomo-RN-SDK] Subscriptions component not mounted");
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
93
156
|
// Detecting order type via the API
|
|
94
157
|
setDetecting(true);
|
|
95
158
|
const thisGeneration = ++fetchGenerationRef.current;
|
|
@@ -97,7 +160,7 @@ function useGlomoCheckout(props) {
|
|
|
97
160
|
console.log("[Glomo-RN-SDK] Detecting order type...");
|
|
98
161
|
}
|
|
99
162
|
(0, analytics_1.trackOrderTypeDetectionStarted)(orderId, publicKey, devMode);
|
|
100
|
-
const result = await (0, order_type_fetcher_1.fetchOrderType)({ orderId, publicKey, server, devMode });
|
|
163
|
+
const result = await (0, order_type_fetcher_1.fetchOrderType)({ orderId: orderId, publicKey, server, devMode });
|
|
101
164
|
// Discarding stale result if props changed while the fetch was in flight
|
|
102
165
|
if (thisGeneration !== fetchGenerationRef.current) {
|
|
103
166
|
if (devMode) {
|
|
@@ -126,7 +189,7 @@ function useGlomoCheckout(props) {
|
|
|
126
189
|
pendingStartResolveRef.current = resolve;
|
|
127
190
|
pendingStartRef.current = true;
|
|
128
191
|
});
|
|
129
|
-
}, [devMode, publicKey, orderId, server, onSdkError]);
|
|
192
|
+
}, [devMode, publicKey, orderId, subscriptionId, server, onSdkError, propsError]);
|
|
130
193
|
/**
|
|
131
194
|
* Auto-starting the inner component after order type is resolved and the component has rendered.
|
|
132
195
|
* The pendingStartRef bridges the async gap: start() sets it, and this effect fires after
|
|
@@ -152,13 +215,23 @@ function useGlomoCheckout(props) {
|
|
|
152
215
|
console.log(`[Glomo-RN-SDK] Standard inner start() returned: ${started}`);
|
|
153
216
|
}
|
|
154
217
|
}
|
|
218
|
+
else if (orderType === "subscriptions") {
|
|
219
|
+
// No-op: subscription start() calls the inner component directly (not via this effect bridge).
|
|
220
|
+
// If we reach here, pendingStartRef was set unexpectedly - resolve false defensively.
|
|
221
|
+
pendingStartRef.current = false;
|
|
222
|
+
}
|
|
155
223
|
// Resolving the merchant's awaited start() promise with the inner component's result
|
|
156
224
|
if (pendingStartResolveRef.current) {
|
|
157
225
|
pendingStartResolveRef.current(started);
|
|
158
226
|
pendingStartResolveRef.current = null;
|
|
159
227
|
}
|
|
160
228
|
}, [orderType, devMode]);
|
|
161
|
-
|
|
229
|
+
/**
|
|
230
|
+
* Resetting order type state when orderId, subscriptionId, or publicKey changes.
|
|
231
|
+
* For subscriptions, setting orderType to "subscriptions" directly (no API call needed).
|
|
232
|
+
* For orders, resetting to null to force re-detection on next start().
|
|
233
|
+
* Single effect owns all orderType transitions to avoid race conditions.
|
|
234
|
+
*/
|
|
162
235
|
(0, react_1.useEffect)(() => {
|
|
163
236
|
// Invalidating any in-flight fetchOrderType call so its stale result is discarded
|
|
164
237
|
fetchGenerationRef.current++;
|
|
@@ -166,10 +239,15 @@ function useGlomoCheckout(props) {
|
|
|
166
239
|
pendingStartResolveRef.current(false);
|
|
167
240
|
pendingStartResolveRef.current = null;
|
|
168
241
|
}
|
|
169
|
-
setOrderType(null);
|
|
170
242
|
setDetecting(false);
|
|
171
243
|
pendingStartRef.current = false;
|
|
172
|
-
|
|
244
|
+
if (subscriptionId && !orderId) {
|
|
245
|
+
setOrderType("subscriptions");
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
setOrderType(null);
|
|
249
|
+
}
|
|
250
|
+
}, [orderId, subscriptionId, publicKey]);
|
|
173
251
|
return {
|
|
174
252
|
orderType,
|
|
175
253
|
detecting,
|
|
@@ -177,6 +255,7 @@ function useGlomoCheckout(props) {
|
|
|
177
255
|
getStatus,
|
|
178
256
|
innerLrsRef,
|
|
179
257
|
innerStandardRef,
|
|
258
|
+
innerSubscriptionsRef,
|
|
180
259
|
props,
|
|
181
260
|
};
|
|
182
261
|
}
|
|
@@ -32,7 +32,7 @@ export interface UseLrsCheckoutOptions {
|
|
|
32
32
|
onPaymentFailure: (payload: GlomoLrsCheckoutPayload) => void;
|
|
33
33
|
onConnectionError?: (error: unknown) => void;
|
|
34
34
|
onPaymentTerminate?: () => void;
|
|
35
|
-
onSdkError
|
|
35
|
+
onSdkError: (error: Array<SdkError>) => void;
|
|
36
36
|
devMode?: boolean;
|
|
37
37
|
}
|
|
38
38
|
/** The return values for the useLrsCheckout hook */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-lrs-checkout.d.ts","sourceRoot":"","sources":["../src/use-lrs-checkout.tsx"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,EAAY,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEnE,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAItG,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAGtE,OAAO,EAcH,KAAK,QAAQ,EAChB,MAAM,mBAAmB,CAAC;AAE3B,4BAA4B;AAC5B,MAAM,MAA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,2BAA2B,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACtD,wBAAwB,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC/D,wBAAwB,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC/D,qCAAqC,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC5E,WAAW,EAAE,CACT,cAAc,EAAE,oBAAoB,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,KAC7F,IAAI,CAAC;IACV,eAAe,EAAE,CAAC,cAAc,EAAE,oBAAoB,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,KAAK,IAAI,CAAC;IAC9G,2BAA2B,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACnE,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yBAAyB,CAAC,EAAE,MAAM,CAAC;CACtC;AAED,2DAA2D;AAC3D,wBAAgB,cAAc,CAC1B,EACI,MAAM,EACN,SAAS,EACT,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,OAAe,GAClB,EAAE,qBAAqB,EACxB,QAAQ,EAAE,OAAO,GAClB,oBAAoB,CA02BtB"}
|
|
@@ -3,8 +3,8 @@ import React from "react";
|
|
|
3
3
|
import { type NativeSyntheticEvent } from "react-native";
|
|
4
4
|
import { type WebViewNavigation, type WebViewMessageEvent, type WebView } from "react-native-webview";
|
|
5
5
|
import { type GlomoServer } from "./config/base";
|
|
6
|
-
import { type SdkError } from "./utils/analytics";
|
|
7
|
-
import { type
|
|
6
|
+
import { type SdkError, type CheckoutAnalyticsTrackers } from "./utils/analytics";
|
|
7
|
+
import { type GlomoUserJourneyCompletedPayload } from "./types/checkout";
|
|
8
8
|
import { type StandardCheckoutStatus, type GlomoStandardCheckoutPayload } from "./types/standard-checkout";
|
|
9
9
|
/** Android-only WebView permission request, not yet in react-native-webview type definitions */
|
|
10
10
|
export interface WebViewPermissionRequest {
|
|
@@ -23,12 +23,8 @@ export interface UseStandardCheckoutOptions {
|
|
|
23
23
|
onPaymentFailure: (payload: GlomoStandardCheckoutPayload) => void;
|
|
24
24
|
onConnectionError?: (error: unknown) => void;
|
|
25
25
|
onPaymentTerminate?: () => void;
|
|
26
|
-
onSdkError
|
|
27
|
-
|
|
28
|
-
onPayViaBankCompleted?: (payload: {
|
|
29
|
-
status: string;
|
|
30
|
-
}) => void;
|
|
31
|
-
onPayViaBankBankConnectionSuccessful?: (payload: GlomoPayViaBankConnectionPayload | null | undefined) => void;
|
|
26
|
+
onSdkError: (error: Array<SdkError>) => void;
|
|
27
|
+
onUserJourneyCompleted?: (payload: GlomoUserJourneyCompletedPayload) => void;
|
|
32
28
|
onUserRefusedCameraPermissions?: () => void;
|
|
33
29
|
devMode?: boolean;
|
|
34
30
|
}
|
|
@@ -60,6 +56,15 @@ export interface UseStandardCheckoutReturn {
|
|
|
60
56
|
injectedMain?: string;
|
|
61
57
|
injectedFlow?: string;
|
|
62
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Internal options for useStandardCheckout.
|
|
61
|
+
* Used by subscription checkout to inject subscription-specific analytics trackers.
|
|
62
|
+
* Not exported to merchants.
|
|
63
|
+
*/
|
|
64
|
+
export interface UseStandardCheckoutInternalOptions {
|
|
65
|
+
analyticsTrackers?: CheckoutAnalyticsTrackers;
|
|
66
|
+
_skipOrderIdValidation?: boolean;
|
|
67
|
+
}
|
|
63
68
|
/** The main SDK hook for the GlomoPay Standard Checkout flow */
|
|
64
|
-
export declare function useStandardCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymentFailure, onConnectionError, onPaymentTerminate, onSdkError,
|
|
69
|
+
export declare function useStandardCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymentFailure, onConnectionError, onPaymentTerminate, onSdkError, onUserJourneyCompleted, onUserRefusedCameraPermissions, devMode, }: UseStandardCheckoutOptions, mockMode: boolean, internalOptions?: UseStandardCheckoutInternalOptions): UseStandardCheckoutReturn;
|
|
65
70
|
//# sourceMappingURL=use-standard-checkout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-standard-checkout.d.ts","sourceRoot":"","sources":["../src/use-standard-checkout.tsx"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,EAAgC,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEvF,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAItG,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAGtE,OAAO,
|
|
1
|
+
{"version":3,"file":"use-standard-checkout.d.ts","sourceRoot":"","sources":["../src/use-standard-checkout.tsx"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,EAAgC,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEvF,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAItG,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAGtE,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,yBAAyB,EAA4B,MAAM,mBAAmB,CAAC;AAE5G,OAAO,EAAwB,KAAK,gCAAgC,EAAE,MAA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