@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.
Files changed (52) hide show
  1. package/CHANGELOG.md +38 -2
  2. package/MIGRATION.md +129 -0
  3. package/README.md +176 -126
  4. package/lib/glomo-checkout.d.ts +2 -1
  5. package/lib/glomo-checkout.d.ts.map +1 -1
  6. package/lib/glomo-checkout.js +25 -3
  7. package/lib/glomo-lrs-checkout.d.ts +1 -1
  8. package/lib/glomo-lrs-checkout.d.ts.map +1 -1
  9. package/lib/glomo-standard-checkout.d.ts +20 -0
  10. package/lib/glomo-standard-checkout.d.ts.map +1 -1
  11. package/lib/glomo-standard-checkout.js +15 -6
  12. package/lib/glomo-subscriptions-checkout.d.ts +8 -0
  13. package/lib/glomo-subscriptions-checkout.d.ts.map +1 -0
  14. package/lib/glomo-subscriptions-checkout.js +85 -0
  15. package/lib/index.d.ts +3 -3
  16. package/lib/index.d.ts.map +1 -1
  17. package/lib/index.js +5 -3
  18. package/lib/types/checkout.d.ts +33 -22
  19. package/lib/types/checkout.d.ts.map +1 -1
  20. package/lib/types/checkout.js +12 -1
  21. package/lib/types/standard-checkout.d.ts +3 -7
  22. package/lib/types/standard-checkout.d.ts.map +1 -1
  23. package/lib/types/subscriptions-checkout.d.ts +29 -0
  24. package/lib/types/subscriptions-checkout.d.ts.map +1 -0
  25. package/lib/types/subscriptions-checkout.js +3 -0
  26. package/lib/use-glomo-checkout.d.ts +34 -4
  27. package/lib/use-glomo-checkout.d.ts.map +1 -1
  28. package/lib/use-glomo-checkout.js +92 -13
  29. package/lib/use-lrs-checkout.d.ts +1 -1
  30. package/lib/use-lrs-checkout.d.ts.map +1 -1
  31. package/lib/use-standard-checkout.d.ts +14 -9
  32. package/lib/use-standard-checkout.d.ts.map +1 -1
  33. package/lib/use-standard-checkout.js +74 -85
  34. package/lib/utils/analytics.d.ts +86 -3
  35. package/lib/utils/analytics.d.ts.map +1 -1
  36. package/lib/utils/analytics.js +344 -22
  37. package/lib/utils/device-compliance.d.ts.map +1 -1
  38. package/lib/utils/device-compliance.js +0 -1
  39. package/package.json +15 -4
  40. package/src/glomo-checkout.tsx +65 -9
  41. package/src/glomo-lrs-checkout.tsx +1 -1
  42. package/src/glomo-standard-checkout.tsx +35 -10
  43. package/src/glomo-subscriptions-checkout.tsx +83 -0
  44. package/src/index.ts +5 -5
  45. package/src/types/checkout.ts +28 -20
  46. package/src/types/standard-checkout.ts +3 -5
  47. package/src/types/subscriptions-checkout.ts +31 -0
  48. package/src/use-glomo-checkout.tsx +158 -17
  49. package/src/use-lrs-checkout.tsx +1 -1
  50. package/src/use-standard-checkout.tsx +94 -153
  51. package/src/utils/analytics.ts +469 -31
  52. package/src/utils/device-compliance.ts +0 -1
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  /**
3
- * The unified GlomoPay Checkout Component (v3).
3
+ * The unified GlomoPay Checkout Component (v4).
4
4
  * Detects order type (LRS vs Standard) and delegates rendering to the appropriate inner component.
5
+ * Enforces error handling via `onSdkError()` as a mandatory prop.
5
6
  */
6
7
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
8
  if (k2 === undefined) k2 = k;
@@ -40,23 +41,44 @@ Object.defineProperty(exports, "__esModule", { value: true });
40
41
  exports.GlomoCheckout = void 0;
41
42
  const react_1 = __importStar(require("react"));
42
43
  const use_glomo_checkout_1 = require("./use-glomo-checkout");
44
+ const analytics_1 = require("./utils/analytics");
43
45
  const glomo_lrs_checkout_1 = require("./glomo-lrs-checkout");
44
46
  const glomo_standard_checkout_1 = require("./glomo-standard-checkout");
47
+ const glomo_subscriptions_checkout_1 = require("./glomo-subscriptions-checkout");
45
48
  function GlomoCheckoutComponent(props, ref) {
49
+ var _a;
46
50
  // useGlomoCheckout handles order type detection and exposes start/getStatus for the ref
47
- const { orderType, start, getStatus, innerLrsRef, innerStandardRef, props: passedProps } = (0, use_glomo_checkout_1.useGlomoCheckout)(props);
51
+ const { orderType, start, getStatus, innerLrsRef, innerStandardRef, innerSubscriptionsRef, props: passedProps, } = (0, use_glomo_checkout_1.useGlomoCheckout)(props, { _suppressDeprecationWarning: true });
48
52
  // Exposing start() and getStatus() via the forwarded ref for the merchant to call
49
53
  (0, react_1.useImperativeHandle)(ref, () => ({
50
54
  start,
51
55
  getStatus,
52
56
  }));
57
+ // Tracking unsupported callback props on subscription flows (fires once per mount)
58
+ const hasTrackedUnsupportedRef = (0, react_1.useRef)(false);
59
+ const devMode = (_a = passedProps.devMode) !== null && _a !== void 0 ? _a : false;
60
+ const mockMode = (0, react_1.useMemo)(() => { var _a, _b; return (_b = (_a = passedProps.publicKey) === null || _a === void 0 ? void 0 : _a.toLowerCase().startsWith("test_")) !== null && _b !== void 0 ? _b : false; }, [passedProps.publicKey]);
61
+ // Extracting stable boolean for the tracking effect to avoid depending on passedProps object
62
+ const hasUserJourneyCallback = !!passedProps.onUserJourneyCompleted;
63
+ (0, react_1.useEffect)(() => {
64
+ if (orderType !== "subscriptions" || hasTrackedUnsupportedRef.current)
65
+ return;
66
+ hasTrackedUnsupportedRef.current = true;
67
+ if (hasUserJourneyCallback) {
68
+ (0, analytics_1.trackUseOfUnsupportedFunctionality)("onUserJourneyCompleted", passedProps.subscriptionId, passedProps.publicKey, devMode, mockMode, "");
69
+ }
70
+ }, [orderType, hasUserJourneyCallback, passedProps.subscriptionId, passedProps.publicKey, devMode, mockMode]);
53
71
  // Delegating to the LRS checkout component once order type is resolved as LRS
54
72
  if (orderType === "lrs") {
55
73
  return (<glomo_lrs_checkout_1.GlomoLrsCheckout ref={innerLrsRef} server={passedProps.server} publicKey={passedProps.publicKey} orderId={passedProps.orderId} onPaymentSuccess={passedProps.onPaymentSuccess} onPaymentFailure={passedProps.onPaymentFailure} onConnectionError={passedProps.onConnectionError} onPaymentTerminate={passedProps.onPaymentTerminate} onSdkError={passedProps.onSdkError} devMode={passedProps.devMode}/>);
56
74
  }
57
75
  // Delegating to the Standard checkout component once order type is resolved as Standard
58
76
  if (orderType === "standard") {
59
- return (<glomo_standard_checkout_1.GlomoStandardCheckout ref={innerStandardRef} server={passedProps.server} publicKey={passedProps.publicKey} orderId={passedProps.orderId} onPaymentSuccess={passedProps.onPaymentSuccess} onPaymentFailure={passedProps.onPaymentFailure} onConnectionError={passedProps.onConnectionError} onPaymentTerminate={passedProps.onPaymentTerminate} onSdkError={passedProps.onSdkError} onBankTransferSubmitted={passedProps.onBankTransferSubmitted} onPayViaBankCompleted={passedProps.onPayViaBankCompleted} onPayViaBankBankConnectionSuccessful={passedProps.onPayViaBankBankConnectionSuccessful} onUserRefusedCameraPermissions={passedProps.onUserRefusedCameraPermissions} devMode={passedProps.devMode}/>);
77
+ return (<glomo_standard_checkout_1.GlomoStandardCheckout ref={innerStandardRef} server={passedProps.server} publicKey={passedProps.publicKey} orderId={passedProps.orderId} onPaymentSuccess={passedProps.onPaymentSuccess} onPaymentFailure={passedProps.onPaymentFailure} onConnectionError={passedProps.onConnectionError} onPaymentTerminate={passedProps.onPaymentTerminate} onSdkError={passedProps.onSdkError} onUserJourneyCompleted={passedProps.onUserJourneyCompleted} onUserRefusedCameraPermissions={passedProps.onUserRefusedCameraPermissions} devMode={passedProps.devMode}/>);
78
+ }
79
+ // Delegating to the Subscriptions checkout component when subscriptionId is provided (no API call)
80
+ if (orderType === "subscriptions") {
81
+ return (<glomo_subscriptions_checkout_1.GlomoSubscriptionsCheckout ref={innerSubscriptionsRef} server={passedProps.server} publicKey={passedProps.publicKey} subscriptionId={passedProps.subscriptionId} onPaymentSuccess={passedProps.onPaymentSuccess} onPaymentFailure={passedProps.onPaymentFailure} onConnectionError={passedProps.onConnectionError} onPaymentTerminate={passedProps.onPaymentTerminate} onSdkError={passedProps.onSdkError} onUserJourneyCompleted={passedProps.onUserJourneyCompleted} onUserRefusedCameraPermissions={passedProps.onUserRefusedCameraPermissions} devMode={passedProps.devMode}/>);
60
82
  }
61
83
  /**
62
84
  * No modal for detecting state - avoids iOS pageSheet conflict where
@@ -4,7 +4,7 @@ import { type UseLrsCheckoutOptions, type LrsCheckoutStatus } from "./use-lrs-ch
4
4
  import { type SdkError } from "./utils/analytics";
5
5
  export interface GlomoLrsCheckoutProps extends UseLrsCheckoutOptions {
6
6
  visible?: boolean;
7
- onSdkError?: (error: Array<SdkError>) => void;
7
+ onSdkError: (error: Array<SdkError>) => void;
8
8
  }
9
9
  export interface GlomoLrsCheckoutRef {
10
10
  start: () => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"glomo-lrs-checkout.d.ts","sourceRoot":"","sources":["../src/glomo-lrs-checkout.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAE1C,OAAO,KAAmD,MAAM,OAAO,CAAC;AAIxE,OAAO,EAAkB,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxG,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAChE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;CACjD;AAED,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,iBAAiB,CAAC;CACtC;AA2WD,eAAO,MAAM,gBAAgB,mGAAoF,CAAC"}
1
+ {"version":3,"file":"glomo-lrs-checkout.d.ts","sourceRoot":"","sources":["../src/glomo-lrs-checkout.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAE1C,OAAO,KAAmD,MAAM,OAAO,CAAC;AAIxE,OAAO,EAAkB,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxG,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAChE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;CAChD;AAED,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,iBAAiB,CAAC;CACtC;AA2WD,eAAO,MAAM,gBAAgB,mGAAoF,CAAC"}
@@ -1,5 +1,25 @@
1
1
  /** The GlomoPay Standard Checkout Component */
2
2
  import React from "react";
3
3
  import { type GlomoStandardCheckoutRef, type GlomoStandardCheckoutProps } from "./types/standard-checkout";
4
+ import { type CheckoutAnalyticsTrackers } from "./utils/analytics";
5
+ /**
6
+ * Internal-only props for GlomoStandardCheckout.
7
+ * Used by GlomoSubscriptionsCheckout to inject subscription analytics trackers.
8
+ * Not exported to merchants via index.ts.
9
+ */
10
+ export interface GlomoStandardCheckoutInternalProps extends GlomoStandardCheckoutProps {
11
+ _analyticsTrackers?: CheckoutAnalyticsTrackers;
12
+ _skipOrderIdValidation?: boolean;
13
+ }
14
+ /**
15
+ * Widening the internal type to GlomoStandardCheckoutInternalProps for internal SDK use,
16
+ * then narrowing the public export to GlomoStandardCheckoutProps so merchants cannot
17
+ * pass internal-only props like _analyticsTrackers.
18
+ */
4
19
  export declare const GlomoStandardCheckout: React.ForwardRefExoticComponent<GlomoStandardCheckoutProps & React.RefAttributes<GlomoStandardCheckoutRef>>;
20
+ /**
21
+ * Internal reference - accepts GlomoStandardCheckoutInternalProps.
22
+ * Not re-exported from index.ts.
23
+ */
24
+ export declare const GlomoStandardCheckoutInternal: React.ForwardRefExoticComponent<GlomoStandardCheckoutInternalProps & React.RefAttributes<GlomoStandardCheckoutRef>>;
5
25
  //# sourceMappingURL=glomo-standard-checkout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"glomo-standard-checkout.d.ts","sourceRoot":"","sources":["../src/glomo-standard-checkout.tsx"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C,OAAO,KAAmD,MAAM,OAAO,CAAC;AAKxE,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAiQ3G,eAAO,MAAM,qBAAqB,6GAEjC,CAAC"}
1
+ {"version":3,"file":"glomo-standard-checkout.d.ts","sourceRoot":"","sources":["../src/glomo-standard-checkout.tsx"],"names":[],"mappings":"AAAA,+CAA+C;AAE/C,OAAO,KAAmD,MAAM,OAAO,CAAC;AAKxE,OAAO,EAAE,KAAK,wBAAwB,EAAE,KAAK,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AAC3G,OAAO,EAAE,KAAK,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAGnE;;;;GAIG;AACH,MAAM,WAAW,kCAAmC,SAAQ,0BAA0B;IAClF,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;IAC/C,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC;AA+PD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAiD,KAAK,CAAC,yBAAyB,CAC9G,0BAA0B,GAAG,KAAK,CAAC,aAAa,CAAC,wBAAwB,CAAC,CAC7E,CAAC;AAIF;;;GAGG;AACH,eAAO,MAAM,6BAA6B,qHAEzC,CAAC"}
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  };
35
35
  })();
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.GlomoStandardCheckout = void 0;
37
+ exports.GlomoStandardCheckoutInternal = exports.GlomoStandardCheckout = void 0;
38
38
  const react_1 = __importStar(require("react"));
39
39
  const react_native_1 = require("react-native");
40
40
  const react_native_webview_1 = require("react-native-webview");
@@ -57,7 +57,7 @@ const validation_1 = require("./utils/validation");
57
57
  * @param ref - The ref for the component
58
58
  * @param devMode - Turn on to see all logs, warnings, and errors in the console. Off by default
59
59
  */
60
- function GlomoStandardCheckoutComponent({ server, publicKey, orderId, onPaymentSuccess, onPaymentFailure, onConnectionError, onPaymentTerminate, onSdkError, onBankTransferSubmitted, onPayViaBankCompleted, onPayViaBankBankConnectionSuccessful, onUserRefusedCameraPermissions, devMode = false, }, ref) {
60
+ function GlomoStandardCheckoutComponent({ server, publicKey, orderId, onPaymentSuccess, onPaymentFailure, onConnectionError, onPaymentTerminate, onSdkError, onUserJourneyCompleted, onUserRefusedCameraPermissions, devMode = false, _analyticsTrackers, _skipOrderIdValidation, }, ref) {
61
61
  // Computing mockMode based on the publicKey prefix
62
62
  const mockMode = (0, react_1.useMemo)(() => {
63
63
  var _a;
@@ -76,12 +76,10 @@ function GlomoStandardCheckoutComponent({ server, publicKey, orderId, onPaymentS
76
76
  onConnectionError,
77
77
  onPaymentTerminate,
78
78
  onSdkError,
79
- onBankTransferSubmitted,
80
- onPayViaBankCompleted,
81
- onPayViaBankBankConnectionSuccessful,
79
+ onUserJourneyCompleted,
82
80
  onUserRefusedCameraPermissions,
83
81
  devMode,
84
- }, mockMode);
82
+ }, mockMode, { analyticsTrackers: _analyticsTrackers, _skipOrderIdValidation });
85
83
  // Exposing the start() and getStatus() methods via the ref
86
84
  (0, react_1.useImperativeHandle)(ref, () => ({
87
85
  start,
@@ -160,8 +158,19 @@ function GlomoStandardCheckoutComponent({ server, publicKey, orderId, onPaymentS
160
158
  </react_native_1.View>
161
159
  </ModalComponent>);
162
160
  }
161
+ /**
162
+ * Widening the internal type to GlomoStandardCheckoutInternalProps for internal SDK use,
163
+ * then narrowing the public export to GlomoStandardCheckoutProps so merchants cannot
164
+ * pass internal-only props like _analyticsTrackers.
165
+ */
163
166
  exports.GlomoStandardCheckout = (0, react_1.forwardRef)(GlomoStandardCheckoutComponent);
164
167
  exports.GlomoStandardCheckout.displayName = "GlomoStandardCheckout";
168
+ /**
169
+ * Internal reference - accepts GlomoStandardCheckoutInternalProps.
170
+ * Not re-exported from index.ts.
171
+ */
172
+ exports.GlomoStandardCheckoutInternal = (0, react_1.forwardRef)(GlomoStandardCheckoutComponent);
173
+ exports.GlomoStandardCheckoutInternal.displayName = "GlomoStandardCheckoutInternal";
165
174
  const styles = react_native_1.StyleSheet.create({
166
175
  modalContainer: {
167
176
  flex: 1,
@@ -0,0 +1,8 @@
1
+ /**
2
+ * GlomoSubscriptionsCheckout - thin wrapper around GlomoStandardCheckout
3
+ * that accepts a subscriptionId (sub_*) instead of an orderId (order_*).
4
+ */
5
+ import React from "react";
6
+ import { type GlomoSubscriptionsCheckoutProps, type GlomoSubscriptionsCheckoutRef } from "./types/subscriptions-checkout";
7
+ export declare const GlomoSubscriptionsCheckout: React.ForwardRefExoticComponent<GlomoSubscriptionsCheckoutProps & React.RefAttributes<GlomoSubscriptionsCheckoutRef>>;
8
+ //# sourceMappingURL=glomo-subscriptions-checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glomo-subscriptions-checkout.d.ts","sourceRoot":"","sources":["../src/glomo-subscriptions-checkout.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAA6D,MAAM,OAAO,CAAC;AAIlF,OAAO,EACH,KAAK,+BAA+B,EACpC,KAAK,6BAA6B,EACrC,MAAM,gCAAgC,CAAC;AAkExC,eAAO,MAAM,0BAA0B,uHAEtC,CAAC"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ /**
3
+ * GlomoSubscriptionsCheckout - thin wrapper around GlomoStandardCheckout
4
+ * that accepts a subscriptionId (sub_*) instead of an orderId (order_*).
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.GlomoSubscriptionsCheckout = void 0;
41
+ const react_1 = __importStar(require("react"));
42
+ const glomo_standard_checkout_1 = require("./glomo-standard-checkout");
43
+ const analytics_1 = require("./utils/analytics");
44
+ const validation_1 = require("./utils/validation");
45
+ function GlomoSubscriptionsCheckoutComponent(props, ref) {
46
+ const { subscriptionId: rawSubscriptionId, onSdkError, devMode = false, ...rest } = props;
47
+ const innerRef = (0, react_1.useRef)(null);
48
+ const onSdkErrorRef = (0, react_1.useRef)(onSdkError);
49
+ onSdkErrorRef.current = onSdkError;
50
+ const subscriptionId = rawSubscriptionId.trim();
51
+ /** Validating subscriptionId - firing onSdkError via useEffect to avoid side effects during render */
52
+ const validationError = (() => {
53
+ if (subscriptionId.length === 0) {
54
+ return "subscriptionId must not be empty";
55
+ }
56
+ if (!subscriptionId.startsWith("sub_")) {
57
+ return "subscriptionId must start with 'sub_'";
58
+ }
59
+ return null;
60
+ })();
61
+ (0, react_1.useEffect)(() => {
62
+ if (validationError) {
63
+ (0, validation_1.safeCallback)(onSdkErrorRef.current, [[{ type: "validation_error", message: validationError }]], "onSdkError", devMode);
64
+ }
65
+ }, [validationError, devMode]);
66
+ (0, react_1.useImperativeHandle)(ref, () => ({
67
+ start: () => {
68
+ var _a, _b;
69
+ if (validationError) {
70
+ return false;
71
+ }
72
+ return (_b = (_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.start()) !== null && _b !== void 0 ? _b : false;
73
+ },
74
+ getStatus: () => {
75
+ var _a, _b;
76
+ return (_b = (_a = innerRef.current) === null || _a === void 0 ? void 0 : _a.getStatus()) !== null && _b !== void 0 ? _b : "ready";
77
+ },
78
+ }));
79
+ if (validationError) {
80
+ return null;
81
+ }
82
+ return (<glomo_standard_checkout_1.GlomoStandardCheckoutInternal ref={innerRef} {...rest} orderId={subscriptionId} onSdkError={onSdkError} devMode={devMode} _analyticsTrackers={analytics_1.subscriptionCheckoutTrackers} _skipOrderIdValidation={true}/>);
83
+ }
84
+ exports.GlomoSubscriptionsCheckout = (0, react_1.forwardRef)(GlomoSubscriptionsCheckoutComponent);
85
+ exports.GlomoSubscriptionsCheckout.displayName = "GlomoSubscriptionsCheckout";
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- /** The GlomoPay RN SDK v3 exports */
1
+ /** The GlomoPay RN SDK v4 exports */
2
2
  export { GlomoCheckout } from "./glomo-checkout";
3
- export { type GlomoCheckoutRef, type GlomoCheckoutProps, type GlomoCheckoutPayload, type CheckoutStatus, type GlomoBankTransferPayload, type GlomoPayViaBankConnectionPayload, } from "./types/checkout";
3
+ export { type GlomoCheckoutRef, type GlomoCheckoutProps, type GlomoCheckoutPayload, type CheckoutStatus, type GlomoUserJourneyCompletedPayload, ASYNC_PAYMENT_EVENTS, } from "./types/checkout";
4
4
  export { type GlomoServer } from "./config/base";
5
5
  export { type SdkError } from "./utils/analytics";
6
- export { useGlomoCheckout } from "./use-glomo-checkout";
6
+ export { useGlomoCheckout, type UseGlomoCheckoutReturn } from "./use-glomo-checkout";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAGrC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,gCAAgC,GACxC,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qCAAqC;AAGrC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,gCAAgC,EACrC,oBAAoB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC"}
package/lib/index.js CHANGED
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
- /** The GlomoPay RN SDK v3 exports */
2
+ /** The GlomoPay RN SDK v4 exports */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.useGlomoCheckout = exports.GlomoCheckout = void 0;
5
- // v3 public API - unified checkout
4
+ exports.useGlomoCheckout = exports.ASYNC_PAYMENT_EVENTS = exports.GlomoCheckout = void 0;
5
+ // v4 public API - unified checkout
6
6
  var glomo_checkout_1 = require("./glomo-checkout");
7
7
  Object.defineProperty(exports, "GlomoCheckout", { enumerable: true, get: function () { return glomo_checkout_1.GlomoCheckout; } });
8
+ var checkout_1 = require("./types/checkout");
9
+ Object.defineProperty(exports, "ASYNC_PAYMENT_EVENTS", { enumerable: true, get: function () { return checkout_1.ASYNC_PAYMENT_EVENTS; } });
8
10
  var use_glomo_checkout_1 = require("./use-glomo-checkout");
9
11
  Object.defineProperty(exports, "useGlomoCheckout", { enumerable: true, get: function () { return use_glomo_checkout_1.useGlomoCheckout; } });
@@ -1,4 +1,4 @@
1
- /** Unified v3 type definitions for GlomoCheckout */
1
+ /** Unified v4 type definitions for GlomoCheckout */
2
2
  import { type GlomoServer } from "../config/base";
3
3
  import { type SdkError } from "../utils/analytics";
4
4
  /** The payload for a successful or failed payment (unified across LRS and standard) */
@@ -7,19 +7,22 @@ export interface GlomoCheckoutPayload {
7
7
  paymentId: string;
8
8
  signature: string;
9
9
  }
10
- /** The payload for a bank transfer submission */
11
- export interface GlomoBankTransferPayload {
12
- orderId: string;
13
- senderAccountNumber: string;
14
- transactionReference: string;
10
+ /**
11
+ * Enum of asynchronous payment events that trigger the
12
+ * onUserJourneyCompleted callback. New events will be added
13
+ * here as additional flows are supported.
14
+ */
15
+ export declare enum ASYNC_PAYMENT_EVENTS {
16
+ BANK_TRANSFER_SUBMITTED = "bank_transfer_submitted",
17
+ PAY_VIA_BANK_COMPLETED = "pay_via_bank_completed"
15
18
  }
16
- /** The payload for a pay via bank - bank connection successful event */
17
- export interface GlomoPayViaBankConnectionPayload {
18
- bankIdentifier: string;
19
- cooldownPeriodInMinutes: number;
20
- bankName: string;
21
- bankImageSrc: string;
22
- bankImageAlt: string;
19
+ /** The payload for the onUserJourneyCompleted callback */
20
+ export interface GlomoUserJourneyCompletedPayload {
21
+ journeyType: ASYNC_PAYMENT_EVENTS;
22
+ orderId?: string;
23
+ status?: string;
24
+ senderAccountNumber?: string;
25
+ transactionReference?: string;
23
26
  }
24
27
  /** Unified checkout statuses - superset of LRS + standard statuses */
25
28
  export type CheckoutStatus = "ready" | "detecting_order_type" | "payment_in_progress" | "payment_successful" | "payment_failed" | "payment_cancelled" | "bank_transfer_submitted" | "pay_via_bank_completed";
@@ -32,22 +35,30 @@ export interface GlomoCheckoutRef {
32
35
  start: () => Promise<boolean>;
33
36
  getStatus: () => CheckoutStatus;
34
37
  }
35
- /** Props for the unified checkout component */
36
- export interface GlomoCheckoutProps {
38
+ /** Shared callback and configuration props for the unified checkout component */
39
+ interface GlomoCheckoutBaseProps {
37
40
  server?: GlomoServer;
38
41
  publicKey: string;
39
- orderId: string;
40
42
  onPaymentSuccess: (payload: GlomoCheckoutPayload) => void;
41
43
  onPaymentFailure: (payload: GlomoCheckoutPayload) => void;
42
44
  onConnectionError?: (error: unknown) => void;
43
45
  onPaymentTerminate?: () => void;
44
- onSdkError?: (error: Array<SdkError>) => void;
45
- onBankTransferSubmitted?: (payload: GlomoBankTransferPayload | null | undefined) => void;
46
- onPayViaBankCompleted?: (payload: {
47
- status: string;
48
- }) => void;
49
- onPayViaBankBankConnectionSuccessful?: (payload: GlomoPayViaBankConnectionPayload | null | undefined) => void;
46
+ onSdkError: (error: Array<SdkError>) => void;
47
+ onUserJourneyCompleted?: (payload: GlomoUserJourneyCompletedPayload) => void;
50
48
  onUserRefusedCameraPermissions?: () => void;
51
49
  devMode?: boolean;
52
50
  }
51
+ /**
52
+ * Props for the unified checkout component.
53
+ * Exactly one of orderId or subscriptionId must be provided.
54
+ * TypeScript enforces this at compile time; a runtime guard in useGlomoCheckout catches JS consumers.
55
+ */
56
+ export type GlomoCheckoutProps = GlomoCheckoutBaseProps & ({
57
+ orderId: string;
58
+ subscriptionId?: never;
59
+ } | {
60
+ subscriptionId: string;
61
+ orderId?: never;
62
+ });
63
+ export {};
53
64
  //# sourceMappingURL=checkout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/types/checkout.ts"],"names":[],"mappings":"AAAA,oDAAoD;AAE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,GACtB,qBAAqB,GACrB,oBAAoB,GACpB,gBAAgB,GAChB,mBAAmB,GACnB,yBAAyB,GACzB,wBAAwB,CAAC;AAE/B;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAC7B,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,SAAS,EAAE,MAAM,cAAc,CAAC;CACnC;AAED,iFAAiF;AACjF,UAAU,sBAAsB;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC1D,gBAAgB,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC1D,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IAC7C,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,gCAAgC,KAAK,IAAI,CAAC;IAC7E,8BAA8B,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,sBAAsB,GACnD,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC,CAAC"}
@@ -1,3 +1,14 @@
1
1
  "use strict";
2
- /** Unified v3 type definitions for GlomoCheckout */
2
+ /** Unified v4 type definitions for GlomoCheckout */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ASYNC_PAYMENT_EVENTS = void 0;
5
+ /**
6
+ * Enum of asynchronous payment events that trigger the
7
+ * onUserJourneyCompleted callback. New events will be added
8
+ * here as additional flows are supported.
9
+ */
10
+ var ASYNC_PAYMENT_EVENTS;
11
+ (function (ASYNC_PAYMENT_EVENTS) {
12
+ ASYNC_PAYMENT_EVENTS["BANK_TRANSFER_SUBMITTED"] = "bank_transfer_submitted";
13
+ ASYNC_PAYMENT_EVENTS["PAY_VIA_BANK_COMPLETED"] = "pay_via_bank_completed";
14
+ })(ASYNC_PAYMENT_EVENTS || (exports.ASYNC_PAYMENT_EVENTS = ASYNC_PAYMENT_EVENTS = {}));
@@ -1,7 +1,7 @@
1
1
  /** Type definitions for the Standard Checkout flow */
2
2
  import { type GlomoServer } from "../config/base";
3
3
  import { type SdkError } from "../utils/analytics";
4
- import { type GlomoBankTransferPayload, type GlomoPayViaBankConnectionPayload } from "./checkout";
4
+ import { type GlomoUserJourneyCompletedPayload } from "./checkout";
5
5
  /** Standard checkout statuses */
6
6
  export type StandardCheckoutStatus = "ready" | "payment_in_progress" | "payment_successful" | "payment_failed" | "payment_cancelled" | "bank_transfer_submitted" | "pay_via_bank_completed";
7
7
  /** The payload for a successful or failed standard payment */
@@ -28,12 +28,8 @@ export interface GlomoStandardCheckoutProps {
28
28
  onPaymentFailure: (payload: GlomoStandardCheckoutPayload) => void;
29
29
  onConnectionError?: (error: unknown) => void;
30
30
  onPaymentTerminate?: () => void;
31
- onSdkError?: (error: Array<SdkError>) => void;
32
- onBankTransferSubmitted?: (payload: GlomoBankTransferPayload | null | undefined) => void;
33
- onPayViaBankCompleted?: (payload: {
34
- status: string;
35
- }) => void;
36
- onPayViaBankBankConnectionSuccessful?: (payload: GlomoPayViaBankConnectionPayload | null | undefined) => void;
31
+ onSdkError: (error: Array<SdkError>) => void;
32
+ onUserJourneyCompleted?: (payload: GlomoUserJourneyCompletedPayload) => void;
37
33
  onUserRefusedCameraPermissions?: () => void;
38
34
  devMode?: boolean;
39
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"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C;IAClE,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IAC7C,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,gCAAgC,KAAK,IAAI,CAAC;IAC7E,8BAA8B,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB"}
@@ -0,0 +1,29 @@
1
+ /** Type definitions for the Subscriptions Checkout flow */
2
+ import { type GlomoServer } from "../config/base";
3
+ import { type SdkError } from "../utils/analytics";
4
+ import { type GlomoCheckoutPayload, type GlomoUserJourneyCompletedPayload } from "./checkout";
5
+ import { type StandardCheckoutStatus } from "./standard-checkout";
6
+ /** Props for the subscriptions checkout component */
7
+ export interface GlomoSubscriptionsCheckoutProps {
8
+ server?: GlomoServer;
9
+ publicKey: string;
10
+ subscriptionId: string;
11
+ onPaymentSuccess: (payload: GlomoCheckoutPayload) => void;
12
+ onPaymentFailure: (payload: GlomoCheckoutPayload) => void;
13
+ onConnectionError?: (error: unknown) => void;
14
+ onPaymentTerminate?: () => void;
15
+ onSdkError: (error: Array<SdkError>) => void;
16
+ onUserJourneyCompleted?: (payload: GlomoUserJourneyCompletedPayload) => void;
17
+ onUserRefusedCameraPermissions?: () => void;
18
+ devMode?: boolean;
19
+ }
20
+ /**
21
+ * Ref handle for the subscriptions checkout component.
22
+ * Same type as GlomoStandardCheckoutRef - start() is async at the unified level
23
+ * but delegates to the synchronous standard checkout start() internally.
24
+ */
25
+ export interface GlomoSubscriptionsCheckoutRef {
26
+ start: () => boolean;
27
+ getStatus: () => StandardCheckoutStatus;
28
+ }
29
+ //# sourceMappingURL=subscriptions-checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriptions-checkout.d.ts","sourceRoot":"","sources":["../../src/types/subscriptions-checkout.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAE3D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,gCAAgC,EAAE,MAAM,YAAY,CAAC;AAC9F,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,qDAAqD;AACrD,MAAM,WAAW,+BAA+B;IAC5C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC1D,gBAAgB,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC1D,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IAC7C,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,gCAAgC,KAAK,IAAI,CAAC;IAC7E,8BAA8B,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC1C,KAAK,EAAE,MAAM,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,sBAAsB,CAAC;CAC3C"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ /** Type definitions for the Subscriptions Checkout flow */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -5,20 +5,50 @@
5
5
  import { type GlomoCheckoutProps, type CheckoutStatus } from "./types/checkout";
6
6
  import { type GlomoLrsCheckoutRef } from "./glomo-lrs-checkout";
7
7
  import { type GlomoStandardCheckoutRef } from "./types/standard-checkout";
8
+ import { type GlomoSubscriptionsCheckoutRef } from "./types/subscriptions-checkout";
8
9
  import { type OrderType } from "./services/order-type-fetcher";
9
- /** The return values for the useGlomoCheckout hook */
10
+ /** Extended order type including subscriptions */
11
+ type ExtendedOrderType = OrderType | "subscriptions";
12
+ /**
13
+ * Public return type for useGlomoCheckout.
14
+ * Exposes only start() and getStatus() - no internal refs or state.
15
+ */
10
16
  export interface UseGlomoCheckoutReturn {
11
- orderType: OrderType | null;
17
+ start: () => Promise<boolean>;
18
+ getStatus: () => CheckoutStatus;
19
+ }
20
+ /**
21
+ * Internal return type - used by GlomoCheckout component.
22
+ * Not exported from the public API.
23
+ */
24
+ export interface UseGlomoCheckoutInternalReturn {
25
+ orderType: ExtendedOrderType | null;
12
26
  detecting: boolean;
13
27
  start: () => Promise<boolean>;
14
28
  getStatus: () => CheckoutStatus;
15
29
  innerLrsRef: React.RefObject<GlomoLrsCheckoutRef>;
16
30
  innerStandardRef: React.RefObject<GlomoStandardCheckoutRef>;
31
+ innerSubscriptionsRef: React.RefObject<GlomoSubscriptionsCheckoutRef>;
17
32
  props: GlomoCheckoutProps;
18
33
  }
19
34
  /**
20
- * The main unified checkout hook.
21
- * Validates inputs, detects order type via API, then auto-starts the resolved inner component.
35
+ * @deprecated Legacy hook - will be removed in a future major version.
36
+ *
37
+ * This hook does not provide reactive state. `getStatus()` returns a
38
+ * point-in-time snapshot and does not trigger re-renders on status changes.
39
+ * `start()` returns a promise identical to `GlomoCheckoutRef.start()`.
40
+ *
41
+ * Use the `GlomoCheckout` component with a ref instead:
42
+ *
43
+ * ```tsx
44
+ * const ref = useRef<GlomoCheckoutRef>(null);
45
+ * const started = await ref.current?.start();
46
+ * const status = ref.current?.getStatus();
47
+ * ```
22
48
  */
23
49
  export declare function useGlomoCheckout(props: GlomoCheckoutProps): UseGlomoCheckoutReturn;
50
+ export declare function useGlomoCheckout(props: GlomoCheckoutProps, internalOptions: {
51
+ _suppressDeprecationWarning: true;
52
+ }): UseGlomoCheckoutInternalReturn;
53
+ export {};
24
54
  //# sourceMappingURL=use-glomo-checkout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-glomo-checkout.d.ts","sourceRoot":"","sources":["../src/use-glomo-checkout.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,KAAK,SAAS,EAAkB,MAAM,+BAA+B,CAAC;AAS/E,sDAAsD;AACtD,MAAM,WAAW,sBAAsB;IACnC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,SAAS,EAAE,MAAM,cAAc,CAAC;IAChC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAClD,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAC5D,KAAK,EAAE,kBAAkB,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,GAAG,sBAAsB,CAiMlF"}
1
+ {"version":3,"file":"use-glomo-checkout.d.ts","sourceRoot":"","sources":["../src/use-glomo-checkout.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE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