@tagadapay/headless-sdk 1.17.0 → 1.19.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/README.md +22 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/modules/customer.d.ts +26 -4
- package/dist/core/modules/customer.d.ts.map +1 -1
- package/dist/core/modules/customer.js +50 -16
- package/dist/core/modules/customer.js.map +1 -1
- package/dist/core/modules/rx.d.ts +91 -4
- package/dist/core/modules/rx.d.ts.map +1 -1
- package/dist/core/modules/rx.js +74 -2
- package/dist/core/modules/rx.js.map +1 -1
- package/dist/core/version.d.ts +1 -1
- package/dist/core/version.js +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/provider.d.ts +13 -2
- package/dist/react/provider.d.ts.map +1 -1
- package/dist/react/provider.js +35 -7
- package/dist/react/provider.js.map +1 -1
- package/dist/tagada-headless-commerce.min.js +2 -2
- package/dist/tagada-headless-commerce.min.js.map +4 -4
- package/dist/tagada-headless-react.min.js +2 -2
- package/dist/tagada-headless-react.min.js.map +3 -3
- package/dist/tagada-headless.js +68 -7
- package/dist/tagada-headless.min.js +2 -2
- package/dist/tagada-headless.min.js.map +3 -3
- package/dist/tagada-pixels.min.js +1 -1
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -182,6 +182,26 @@ email, and promotion code are sourced from the loaded `CheckoutSession`.
|
|
|
182
182
|
| `tagada.customer` | CRM data — profile, orders, subscriptions |
|
|
183
183
|
| `tagada.catalog` | Product browsing — list products, variants, prices |
|
|
184
184
|
| `tagada.funnel` | Funnel navigation — bootstrap session and redirect into a funnel step |
|
|
185
|
+
| `tagada.track` | Coded funnels — report steps and events, fire the pixels bound on the canvas |
|
|
186
|
+
| `tagada.portal` | Customer portal — email-code login, subscriptions, cancel flow, addresses, cards, credits |
|
|
187
|
+
| `tagada.rx` | Tagada Rx — telehealth intake, cases, activation status |
|
|
188
|
+
|
|
189
|
+
## Coded Funnels
|
|
190
|
+
|
|
191
|
+
Declare the steps of a funnel you code in `tagada.funnel.ts` (with `@tagadapay/node-sdk`), push it with
|
|
192
|
+
`npx tagada funnel push`, and report each step from the browser. The steps appear as cards on the CRM
|
|
193
|
+
canvas, where you bind your pixels; the SDK loads and fires them.
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
const tagada = createHeadlessClient({ storeId: 'store_abc123', funnel: 'main' });
|
|
197
|
+
|
|
198
|
+
tagada.track.step('quiz'); // or useStep('quiz') in React
|
|
199
|
+
tagada.track.event('quiz_completed', { goal: 'sleep' });
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Nothing is sent and no pixel loads until the first `track.step()`. `InitiateCheckout` and `Purchase`
|
|
203
|
+
fire on their own from the checkout and payment modules. Guide:
|
|
204
|
+
[docs.tagada.io/developer-tools/headless-sdk/coded-funnels](https://docs.tagada.io/developer-tools/headless-sdk/coded-funnels).
|
|
185
205
|
|
|
186
206
|
## React Hooks
|
|
187
207
|
|
|
@@ -195,6 +215,7 @@ One hook per page of a typical storefront:
|
|
|
195
215
|
| `useOrder(orderId)` | Thank-you page — the order + `relatedOrders` from accepted upsells (watched automatically) |
|
|
196
216
|
| `useCustomer(customerId?)` | Account dashboard — profile, orders, subscriptions |
|
|
197
217
|
| `useCatalog()` | Product pages — products, variants, prices |
|
|
218
|
+
| `useStep(stepId, data?)` | Any step of a coded funnel — reports it and fires its pixels |
|
|
198
219
|
|
|
199
220
|
## CDN Usage
|
|
200
221
|
|
|
@@ -227,6 +248,7 @@ A complete React checkout app is available as a live demo and open-source refere
|
|
|
227
248
|
|------------|--------------|
|
|
228
249
|
| `@tagadapay/headless-sdk` | Core client + all modules |
|
|
229
250
|
| `@tagadapay/headless-sdk/react` | React hooks + provider |
|
|
251
|
+
| `@tagadapay/headless-sdk/stripe` | Stripe Express Checkout (`StripeExpressButton`, `useStripeExpress`, `StripeExpressCheckout`); needs `@tagadapay/core-js` |
|
|
230
252
|
|
|
231
253
|
## License
|
|
232
254
|
|
package/dist/core/index.d.ts
CHANGED
|
@@ -8,10 +8,10 @@ export { CustomerPortalModule } from './modules/portal/index.js';
|
|
|
8
8
|
export type * as PortalTypes from './modules/portal/types.js';
|
|
9
9
|
export { CatalogModule } from './modules/catalog.js';
|
|
10
10
|
export { FunnelModule } from './modules/funnel.js';
|
|
11
|
-
export { RxModule } from './modules/rx.js';
|
|
11
|
+
export { RxModule, isQuestionActive, toIntakeAnswers } from './modules/rx.js';
|
|
12
12
|
export { TrackModule } from './modules/track.js';
|
|
13
13
|
export type { StepData, EventData, TrackIdentity, TrackHealth } from './modules/track.js';
|
|
14
|
-
export type { RxCaseStatus, RxRequiredForProduct, RxStorefrontPatient, RxIntakeAnswer, RxClinicalQuestion, RxQuestionsForProduct, RxSubmitCaseInput, RxSubmitCaseResult, RxCaseSummary, RxActivationStatus, RxActivationStepKey, RxActivationMissingItem, } from './modules/rx.js';
|
|
14
|
+
export type { RxCaseStatus, RxRequiredForProduct, RxStorefrontPatient, RxIntakeAnswer, RxClinicalQuestion, RxClinicalQuestionRule, RxQuestionAnswers, RxIntakeContext, RxIntakeIssue, RxValidateIntakeInput, RxQuestionsForProduct, RxSubmitCaseInput, RxSubmitCaseResult, RxCaseSummary, RxActivationStatus, RxActivationStepKey, RxActivationMissingItem, } from './modules/rx.js';
|
|
15
15
|
export { HttpClient } from './http.js';
|
|
16
16
|
export { TagadaError, TagadaAuthError, TagadaValidationError, TagadaNotFoundError, TagadaRateLimitError, TagadaPaymentError, TagadaNetworkError, } from './errors.js';
|
|
17
17
|
export { GoogleAutocompleteCore, loadGoogleMapsScript, ISODataCore, AVAILABLE_LANGUAGES, CurrencyUtils, formatMoney, ensureGeoDataLoaded, getCountries, getStatesForCountry, isLanguageLoaded, } from './helpers/index.js';
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,KAAK,WAAW,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,KAAK,WAAW,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,M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c,EACd,WAAW,EACX,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,KAAK,EACL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,KAAK,EACL,SAAS,EACT,YAAY,EACZ,cAAc,EACd,cAAc,EACd,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,oBAAoB,GACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/core/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export { CustomerModule } from './modules/customer.js';
|
|
|
7
7
|
export { CustomerPortalModule } from './modules/portal/index.js';
|
|
8
8
|
export { CatalogModule } from './modules/catalog.js';
|
|
9
9
|
export { FunnelModule } from './modules/funnel.js';
|
|
10
|
-
export { RxModule } from './modules/rx.js';
|
|
10
|
+
export { RxModule, isQuestionActive, toIntakeAnswers } from './modules/rx.js';
|
|
11
11
|
export { TrackModule } from './modules/track.js';
|
|
12
12
|
export { HttpClient } from './http.js';
|
|
13
13
|
export { TagadaError, TagadaAuthError, TagadaValidationError, TagadaNotFoundError, TagadaRateLimitError, TagadaPaymentError, TagadaNetworkError, } from './errors.js';
|
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;A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,EACX,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AA2D5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -11,14 +11,27 @@ export declare class CustomerModule {
|
|
|
11
11
|
constructor(http: HttpClient, storeId: string);
|
|
12
12
|
/** Get customer profile by ID. */
|
|
13
13
|
getProfile(customerId: string): Promise<Customer>;
|
|
14
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Not available: no route finds a customer by email for a storefront session. The only email
|
|
16
|
+
* search (`POST /api/v1/customers/search`) needs a secret API key of the whole account, which a
|
|
17
|
+
* storefront must never ship. Always rejects with a `TagadaError` of code `not_supported`, without
|
|
18
|
+
* sending a request. For the logged-in customer use `portal.getMe()` (Subscriptions V3 stores) or
|
|
19
|
+
* `getProfile(customerId)`.
|
|
20
|
+
*
|
|
21
|
+
* @deprecated There is no API route behind it.
|
|
22
|
+
*/
|
|
15
23
|
getByEmail(email: string): Promise<Customer | null>;
|
|
16
24
|
/**
|
|
17
25
|
* Update the customer's email (`POST /api/v1/customers/:id`, the checkout's email step): the
|
|
18
26
|
* route stores the email only. A portal customer's name and phone go through `portal.updateProfile`.
|
|
19
27
|
*/
|
|
20
28
|
updateProfile(customerId: string, data: Partial<Pick<Customer, 'email' | 'firstName' | 'lastName' | 'phone' | 'metadata'>>): Promise<Customer>;
|
|
21
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* The customer's orders on this store, newest first (`GET /api/v1/orders/customer/:customerId`).
|
|
31
|
+
* Needs a session of that customer: the checkout session, or a portal login
|
|
32
|
+
* (`portal.verifyCode`). Another customer's id rejects with `TagadaNotFoundError`. The route sends
|
|
33
|
+
* every order at once: `limit` and `offset` slice them here, `total` counts them all.
|
|
34
|
+
*/
|
|
22
35
|
getOrders(customerId: string, opts?: {
|
|
23
36
|
limit?: number;
|
|
24
37
|
offset?: number;
|
|
@@ -54,9 +67,18 @@ export declare class CustomerModule {
|
|
|
54
67
|
/** Delay between polls in ms. Default: 2000. */
|
|
55
68
|
intervalMs?: number;
|
|
56
69
|
}): Promise<Order>;
|
|
57
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* The customer's subscriptions on this store, newest first (`GET /api/v1/subscriptions`). The
|
|
72
|
+
* route answers for the customer of the session: the checkout session, or a portal login
|
|
73
|
+
* (`portal.verifyCode`), which a Subscriptions V3 store requires. Another customer's id gets `[]`.
|
|
74
|
+
* Only the 20 most recent come back: the route's page size cannot travel in a query string.
|
|
75
|
+
*/
|
|
58
76
|
getSubscriptions(customerId: string): Promise<Subscription[]>;
|
|
59
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* One subscription of the session's customer. No route reads a subscription by id: this picks it
|
|
79
|
+
* from `getSubscriptions`' route, so it needs the same session and finds only the 20 most recent.
|
|
80
|
+
* Rejects with `TagadaNotFoundError` when it is not among them.
|
|
81
|
+
*/
|
|
60
82
|
getSubscription(subscriptionId: string): Promise<Subscription>;
|
|
61
83
|
/** Pause billing. `resumeAt` (ISO date) resumes it on that day. */
|
|
62
84
|
pauseSubscription(subscriptionId: string, opts?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customer.d.ts","sourceRoot":"","sources":["../../../src/core/modules/customer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"customer.d.ts","sourceRoot":"","sources":["../../../src/core/modules/customer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA2BjE;;;;GAIG;AACH,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBADP,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,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|
2
|
+
function toSubscription(row, storeId) {
|
|
3
|
+
return {
|
|
4
|
+
...row,
|
|
5
|
+
storeId,
|
|
6
|
+
amount: row.priceCurrencyOptions?.[row.currency]?.amount ?? 0,
|
|
7
|
+
interval: row.priceInterval ?? '',
|
|
8
|
+
intervalCount: row.priceIntervalCount ?? 1,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
1
11
|
/**
|
|
2
12
|
* Customer data -- profile, orders, subscriptions.
|
|
3
13
|
*
|
|
@@ -13,15 +23,17 @@ export class CustomerModule {
|
|
|
13
23
|
const res = await this.http.get(`/api/v1/customers/${customerId}`, { params: { storeId: this.storeId } });
|
|
14
24
|
return res.customer;
|
|
15
25
|
}
|
|
16
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Not available: no route finds a customer by email for a storefront session. The only email
|
|
28
|
+
* search (`POST /api/v1/customers/search`) needs a secret API key of the whole account, which a
|
|
29
|
+
* storefront must never ship. Always rejects with a `TagadaError` of code `not_supported`, without
|
|
30
|
+
* sending a request. For the logged-in customer use `portal.getMe()` (Subscriptions V3 stores) or
|
|
31
|
+
* `getProfile(customerId)`.
|
|
32
|
+
*
|
|
33
|
+
* @deprecated There is no API route behind it.
|
|
34
|
+
*/
|
|
17
35
|
async getByEmail(email) {
|
|
18
|
-
|
|
19
|
-
const res = await this.http.get('/api/v1/customers/by-email', { params: { email, storeId: this.storeId } });
|
|
20
|
-
return res.customer;
|
|
21
|
-
}
|
|
22
|
-
catch {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
36
|
+
throw new TagadaError('customer.getByEmail is not available: no API route finds a customer by email for a storefront session.', 'not_supported');
|
|
25
37
|
}
|
|
26
38
|
/**
|
|
27
39
|
* Update the customer's email (`POST /api/v1/customers/:id`, the checkout's email step): the
|
|
@@ -31,9 +43,19 @@ export class CustomerModule {
|
|
|
31
43
|
await this.http.post(`/api/v1/customers/${customerId}`, { customerId, data: { email: data.email } });
|
|
32
44
|
return this.getProfile(customerId);
|
|
33
45
|
}
|
|
34
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* The customer's orders on this store, newest first (`GET /api/v1/orders/customer/:customerId`).
|
|
48
|
+
* Needs a session of that customer: the checkout session, or a portal login
|
|
49
|
+
* (`portal.verifyCode`). Another customer's id rejects with `TagadaNotFoundError`. The route sends
|
|
50
|
+
* every order at once: `limit` and `offset` slice them here, `total` counts them all.
|
|
51
|
+
*/
|
|
35
52
|
async getOrders(customerId, opts) {
|
|
36
|
-
|
|
53
|
+
const { orders } = await this.http.get(`/api/v1/orders/customer/${customerId}`, {
|
|
54
|
+
params: { storeId: this.storeId },
|
|
55
|
+
});
|
|
56
|
+
const start = opts?.offset ?? 0;
|
|
57
|
+
const end = opts?.limit === undefined ? undefined : start + opts.limit;
|
|
58
|
+
return { orders: orders.slice(start, end), total: orders.length };
|
|
37
59
|
}
|
|
38
60
|
/**
|
|
39
61
|
* Get a single order by ID.
|
|
@@ -76,15 +98,27 @@ export class CustomerModule {
|
|
|
76
98
|
}
|
|
77
99
|
return order;
|
|
78
100
|
}
|
|
79
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* The customer's subscriptions on this store, newest first (`GET /api/v1/subscriptions`). The
|
|
103
|
+
* route answers for the customer of the session: the checkout session, or a portal login
|
|
104
|
+
* (`portal.verifyCode`), which a Subscriptions V3 store requires. Another customer's id gets `[]`.
|
|
105
|
+
* Only the 20 most recent come back: the route's page size cannot travel in a query string.
|
|
106
|
+
*/
|
|
80
107
|
async getSubscriptions(customerId) {
|
|
81
|
-
const
|
|
82
|
-
return
|
|
108
|
+
const { items } = await this.http.get('/api/v1/subscriptions');
|
|
109
|
+
return items.filter((row) => row.customerId === customerId).map((row) => toSubscription(row, this.storeId));
|
|
83
110
|
}
|
|
84
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* One subscription of the session's customer. No route reads a subscription by id: this picks it
|
|
113
|
+
* from `getSubscriptions`' route, so it needs the same session and finds only the 20 most recent.
|
|
114
|
+
* Rejects with `TagadaNotFoundError` when it is not among them.
|
|
115
|
+
*/
|
|
85
116
|
async getSubscription(subscriptionId) {
|
|
86
|
-
const
|
|
87
|
-
|
|
117
|
+
const { items } = await this.http.get('/api/v1/subscriptions');
|
|
118
|
+
const row = items.find((item) => item.id === subscriptionId);
|
|
119
|
+
if (!row)
|
|
120
|
+
throw new TagadaNotFoundError('Subscription', subscriptionId);
|
|
121
|
+
return toSubscription(row, this.storeId);
|
|
88
122
|
}
|
|
89
123
|
// ---------------------------------------------------------------------------
|
|
90
124
|
// Subscription actions of the logged-in customer (customer portal session).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customer.js","sourceRoot":"","sources":["../../../src/core/modules/customer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"customer.js","sourceRoot":"","sources":["../../../src/core/modules/customer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAmBhE,SAAS,cAAc,CAAC,GAA4B,EAAE,OAAe;IACnE,OAAO;QACL,GAAG,GAAG;QACN,OAAO;QACP,MAAM,EAAE,GAAG,CAAC,oBAAoB,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;QAC7D,QAAQ,EAAE,GAAG,CAAC,aAAa,IAAI,EAAE;QACjC,aAAa,EAAE,GAAG,CAAC,kBAAkB,IAAI,CAAC;KAC3C,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,cAAc;IACzB,YACmB,IAAgB,EAChB,OAAe;QADf,SAAI,GAAJ,IAAI,CAAY;QAChB,YAAO,GAAP,OAAO,CAAQ;IAC/B,CAAC;IAEJ,kCAAkC;IAClC,KAAK,CAAC,UAAU,CAAC,UAAkB;QACjC,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAC7B,qBAAqB,UAAU,EAAE,EACjC,EAAE,MAAM,EAAE,EAAE,OAAO,E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}
|
|
@@ -16,14 +16,26 @@ import type { HttpClient } from '../http.js';
|
|
|
16
16
|
* (productId is public; case routes require the checkoutToken the
|
|
17
17
|
* storefront already received when it bootstrapped the checkout).
|
|
18
18
|
*
|
|
19
|
+
* Rules: the server enforces the clinical network's contract on every
|
|
20
|
+
* submit (US address and phone, required questions, offered options, MDI
|
|
21
|
+
* demographics). Use `validateIntake` before payment and `isQuestionActive`
|
|
22
|
+
* / `toIntakeAnswers` to render and send the questionnaire the same way.
|
|
23
|
+
*
|
|
19
24
|
* @example
|
|
20
25
|
* ```ts
|
|
21
26
|
* const { required } = await tagada.rx.isRequiredForProduct(productId);
|
|
22
27
|
* if (required) {
|
|
23
|
-
*
|
|
28
|
+
* // Before payment: US address, phone, ZIP, age.
|
|
29
|
+
* const pre = await tagada.rx.validateIntake({ productId, patient });
|
|
30
|
+
* if (!pre.valid) return showErrors(pre.issues);
|
|
31
|
+
* // After payment: render the network questionnaire.
|
|
32
|
+
* const { questions } = await tagada.rx.getQuestionsForProduct(productId, variantId);
|
|
33
|
+
* const ctx = { state: patient.address.state, sexAtBirth: patient.sexAtBirth };
|
|
34
|
+
* const shown = questions.filter((q) => isQuestionActive(q, answers, ctx));
|
|
35
|
+
* // …collect `answers` keyed by externalQuestionId…
|
|
24
36
|
* const res = await tagada.rx.submitCase({
|
|
25
37
|
* orderId, checkoutToken, productId,
|
|
26
|
-
* patient, intakeAnswers:
|
|
38
|
+
* patient, intakeAnswers: toIntakeAnswers(questions, answers, ctx),
|
|
27
39
|
* });
|
|
28
40
|
* router.push(`/thank-you?rxCase=${res.rxCaseId}`);
|
|
29
41
|
* }
|
|
@@ -83,6 +95,16 @@ export interface RxIntakeAnswer {
|
|
|
83
95
|
/** Options presented for MCQ questions. */
|
|
84
96
|
displayedOptions?: string[];
|
|
85
97
|
}
|
|
98
|
+
/** Display rule copied from the clinical network (see `isQuestionActive`). */
|
|
99
|
+
export interface RxClinicalQuestionRule {
|
|
100
|
+
op: 'and' | 'or';
|
|
101
|
+
requirements: Array<{
|
|
102
|
+
/** `question`: answer to another question; `state`: shipping state; `other` + `patient_sex`: sex at birth. */
|
|
103
|
+
basedOn: 'question' | 'state' | 'other';
|
|
104
|
+
questionId: string | null;
|
|
105
|
+
answer: string | null;
|
|
106
|
+
}>;
|
|
107
|
+
}
|
|
86
108
|
export interface RxClinicalQuestion {
|
|
87
109
|
externalQuestionId: string;
|
|
88
110
|
title: string;
|
|
@@ -94,7 +116,59 @@ export interface RxClinicalQuestion {
|
|
|
94
116
|
options: {
|
|
95
117
|
value: string;
|
|
96
118
|
label: string;
|
|
119
|
+
important?: boolean;
|
|
120
|
+
critical?: boolean;
|
|
97
121
|
}[];
|
|
122
|
+
/** `false` = clinician-side question: never show it, never ask it. */
|
|
123
|
+
visible?: boolean;
|
|
124
|
+
/** Show the question only when one rule matches (`isQuestionActive`). */
|
|
125
|
+
rules?: RxClinicalQuestionRule[];
|
|
126
|
+
important?: boolean;
|
|
127
|
+
critical?: boolean;
|
|
128
|
+
label?: string | null;
|
|
129
|
+
/** Value the network fills itself for hidden questions; send it as is. */
|
|
130
|
+
defaultValue?: string | null;
|
|
131
|
+
}
|
|
132
|
+
/** Answers keyed by `externalQuestionId`, as a storefront collects them. */
|
|
133
|
+
export type RxQuestionAnswers = Record<string, string | number | boolean | string[] | undefined>;
|
|
134
|
+
export interface RxIntakeContext {
|
|
135
|
+
/** Shipping state, 2-letter code. */
|
|
136
|
+
state?: string;
|
|
137
|
+
sexAtBirth?: 'male' | 'female' | 'unspecified';
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Whether the patient must see (and answer) a question. Same rules the
|
|
141
|
+
* server enforces on `submitCase`: hidden and file questions are never
|
|
142
|
+
* shown; a question with rules shows when one rule matches the answers so
|
|
143
|
+
* far, the shipping state or the patient's sex (e.g. "Drug Allergies" only
|
|
144
|
+
* after "Yes", pregnancy only for women).
|
|
145
|
+
*/
|
|
146
|
+
export declare function isQuestionActive(question: RxClinicalQuestion, answers: RxQuestionAnswers, context?: RxIntakeContext): boolean;
|
|
147
|
+
/**
|
|
148
|
+
* Turn the answers a storefront collected into the `intakeAnswers` to
|
|
149
|
+
* submit: active questions only, keyed by title (what the clinician
|
|
150
|
+
* reads), with the options that were shown, and the network's default for
|
|
151
|
+
* hidden questions. Plug and play with `submitCase` / `validateIntake`.
|
|
152
|
+
*/
|
|
153
|
+
export declare function toIntakeAnswers(questions: RxClinicalQuestion[], answers: RxQuestionAnswers, context?: RxIntakeContext): RxIntakeAnswer[];
|
|
154
|
+
export interface RxIntakeIssue {
|
|
155
|
+
field: string;
|
|
156
|
+
message: string;
|
|
157
|
+
}
|
|
158
|
+
export interface RxValidateIntakeInput {
|
|
159
|
+
productId: string;
|
|
160
|
+
variantId?: string;
|
|
161
|
+
patient: {
|
|
162
|
+
phone?: string | null;
|
|
163
|
+
dateOfBirth: string;
|
|
164
|
+
sexAtBirth: 'male' | 'female' | 'unspecified';
|
|
165
|
+
address: {
|
|
166
|
+
state: string;
|
|
167
|
+
zip: string;
|
|
168
|
+
country: string;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
intakeAnswers?: RxIntakeAnswer[];
|
|
98
172
|
}
|
|
99
173
|
export interface RxQuestionsForProduct {
|
|
100
174
|
required: boolean;
|
|
@@ -185,8 +259,21 @@ export declare class RxModule {
|
|
|
185
259
|
*/
|
|
186
260
|
submitCase(input: RxSubmitCaseInput): Promise<RxSubmitCaseResult>;
|
|
187
261
|
/**
|
|
188
|
-
*
|
|
189
|
-
*
|
|
262
|
+
* Check the patient (and, once filled, the intake) against the clinical
|
|
263
|
+
* network rules before paying / submitting: US address in the 50 states
|
|
264
|
+
* or DC, US phone, 5 digit ZIP, adult, every active required question
|
|
265
|
+
* answered with an offered option. `submitCase` enforces the same rules
|
|
266
|
+
* and fails with 422 otherwise. Nothing is created.
|
|
267
|
+
*/
|
|
268
|
+
validateIntake(input: RxValidateIntakeInput): Promise<{
|
|
269
|
+
valid: boolean;
|
|
270
|
+
issues: RxIntakeIssue[];
|
|
271
|
+
}>;
|
|
272
|
+
/**
|
|
273
|
+
* Fetch the network-authored intake questions for a product. Render
|
|
274
|
+
* every question for which `isQuestionActive` is true, build the payload
|
|
275
|
+
* with `toIntakeAnswers`. Empty `questions` means the product has no
|
|
276
|
+
* clinical questionnaire: never replace a network questionnaire with your own.
|
|
190
277
|
*/
|
|
191
278
|
getQuestionsForProduct(productId: string, variantId?: string): Promise<RxQuestionsForProduct>;
|
|
192
279
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rx.d.ts","sourceRoot":"","sources":["../../../src/core/modules/rx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"rx.d.ts","sourceRoot":"","sources":["../../../src/core/modules/rx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,MAAM,YAAY,GACpB,WAAW,GACX,WAAW,GACX,WAAW,GACX,UAAU,GACV,SAAS,GACT,WAAW,GACX,UAAU,GACV,WAAW,GACX,OAAO,CAAC;AAEZ,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,EAAE,OAAO,CAAC;IACtB,sBAAsB,EAAE,OAAO,CAAC;IAChC,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,2BAA2B;IAC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M,YAAA;IAGnC;;;;;;OAMG;IACG,mBAAmB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAQxE;;;;;;OAMG;IACG,oBAAoB,CACxB,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE;QAAE,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAAE,GACpC,OAAO,CAAC,oBAAoB,CAAC;IAShC;;;;OAIG;IACG,gBAAgB,CAAC,KAAK,EAAE;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;KACvB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;IAOvC;;;;OAIG;IACG,UAAU,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAIvE;;;;;;OAMG;IACG,cAAc,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;IAIxG;;;;;OAKG;IACG,sBAAsB,CAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,qBAAqB,CAAC;CAKlC"}
|
package/dist/core/modules/rx.js
CHANGED
|
@@ -1,3 +1,63 @@
|
|
|
1
|
+
const sameText = (a, b) => b !== null && String(a).trim().toLowerCase() === b.trim().toLowerCase();
|
|
2
|
+
/**
|
|
3
|
+
* Whether the patient must see (and answer) a question. Same rules the
|
|
4
|
+
* server enforces on `submitCase`: hidden and file questions are never
|
|
5
|
+
* shown; a question with rules shows when one rule matches the answers so
|
|
6
|
+
* far, the shipping state or the patient's sex (e.g. "Drug Allergies" only
|
|
7
|
+
* after "Yes", pregnancy only for women).
|
|
8
|
+
*/
|
|
9
|
+
export function isQuestionActive(question, answers, context = {}) {
|
|
10
|
+
if (question.visible === false || question.type === 'file')
|
|
11
|
+
return false;
|
|
12
|
+
const rules = question.rules ?? [];
|
|
13
|
+
if (rules.length === 0)
|
|
14
|
+
return true;
|
|
15
|
+
return rules.some((rule) => {
|
|
16
|
+
const check = (req) => {
|
|
17
|
+
if (req.basedOn === 'state')
|
|
18
|
+
return sameText(context.state ?? '', req.answer);
|
|
19
|
+
if (req.basedOn === 'other' && req.questionId === 'patient_sex')
|
|
20
|
+
return sameText(context.sexAtBirth ?? '', req.answer);
|
|
21
|
+
if (req.basedOn === 'question' && req.questionId) {
|
|
22
|
+
const v = answers[req.questionId];
|
|
23
|
+
if (v === undefined)
|
|
24
|
+
return false;
|
|
25
|
+
return Array.isArray(v) ? v.some((x) => sameText(x, req.answer)) : sameText(v, req.answer);
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
};
|
|
29
|
+
return rule.op === 'and' ? rule.requirements.every(check) : rule.requirements.some(check);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Turn the answers a storefront collected into the `intakeAnswers` to
|
|
34
|
+
* submit: active questions only, keyed by title (what the clinician
|
|
35
|
+
* reads), with the options that were shown, and the network's default for
|
|
36
|
+
* hidden questions. Plug and play with `submitCase` / `validateIntake`.
|
|
37
|
+
*/
|
|
38
|
+
export function toIntakeAnswers(questions, answers, context = {}) {
|
|
39
|
+
const out = [];
|
|
40
|
+
for (const q of questions) {
|
|
41
|
+
if (q.visible === false) {
|
|
42
|
+
if (q.defaultValue)
|
|
43
|
+
out.push({ questionId: q.title, question: q.title, value: q.defaultValue, type: 'string' });
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (!isQuestionActive(q, answers, context))
|
|
47
|
+
continue;
|
|
48
|
+
const value = answers[q.externalQuestionId];
|
|
49
|
+
if (value === undefined || (typeof value === 'string' && value.trim() === ''))
|
|
50
|
+
continue;
|
|
51
|
+
out.push({
|
|
52
|
+
questionId: q.title,
|
|
53
|
+
question: q.title,
|
|
54
|
+
value,
|
|
55
|
+
type: q.type === 'number' ? 'number' : q.type === 'boolean' ? 'boolean' : 'string',
|
|
56
|
+
...(q.options.length > 0 ? { displayedOptions: q.options.map((o) => o.label) } : {}),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
1
61
|
export class RxModule {
|
|
2
62
|
constructor(http, storeId) {
|
|
3
63
|
this.http = http;
|
|
@@ -50,8 +110,20 @@ export class RxModule {
|
|
|
50
110
|
return this.http.post('/api/public/v1/rx/cases/submit', input);
|
|
51
111
|
}
|
|
52
112
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
113
|
+
* Check the patient (and, once filled, the intake) against the clinical
|
|
114
|
+
* network rules before paying / submitting: US address in the 50 states
|
|
115
|
+
* or DC, US phone, 5 digit ZIP, adult, every active required question
|
|
116
|
+
* answered with an offered option. `submitCase` enforces the same rules
|
|
117
|
+
* and fails with 422 otherwise. Nothing is created.
|
|
118
|
+
*/
|
|
119
|
+
async validateIntake(input) {
|
|
120
|
+
return this.http.post('/api/public/v1/rx/intake/validate', input);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Fetch the network-authored intake questions for a product. Render
|
|
124
|
+
* every question for which `isQuestionActive` is true, build the payload
|
|
125
|
+
* with `toIntakeAnswers`. Empty `questions` means the product has no
|
|
126
|
+
* clinical questionnaire: never replace a network questionnaire with your own.
|
|
55
127
|
*/
|
|
56
128
|
async getQuestionsForProduct(productId, variantId) {
|
|
57
129
|
return this.http.get('/api/public/v1/rx/questions-for-product', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rx.js","sourceRoot":"","sources":["../../../src/core/modules/rx.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rx.js","sourceRoot":"","sources":["../../../src/core/modules/rx.ts"],"names":[],"mappings":"AAuJA,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAE,CAAgB,EAAW,EAAE,CACzD,CAAC,KAAK,IAAI,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AI,CACnB,gCAAgC,EAChC,KAAK,CACN,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,UAAU,CAAC,KAAwB;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAqB,gCAAgC,EAAE,KAAK,CAAC,CAAC;IACrF,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,cAAc,CAAC,KAA4B;QAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAA8C,mCAAmC,EAAE,KAAK,CAAC,CAAC;IACjH,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,sBAAsB,CAC1B,SAAiB,EACjB,SAAkB;QAElB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAwB,yCAAyC,EAAE;YACrF,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE;SAC7D,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/core/version.d.ts
CHANGED
package/dist/core/version.js
CHANGED
package/dist/react/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { TagadaHeadlessProvider, useHeadlessClient } from './provider.js';
|
|
2
|
-
export type { TagadaHeadlessProviderProps } from './provider.js';
|
|
2
|
+
export type { TagadaHeadlessProviderProps, TagadaHeadlessProviderConfigProps } from './provider.js';
|
|
3
3
|
export { useCheckout } from './hooks/useCheckout.js';
|
|
4
4
|
export type { UseCheckoutReturn } from './hooks/useCheckout.js';
|
|
5
5
|
export { usePayment } from './hooks/usePayment.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC1E,YAAY,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version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AAM,uBAAuB,CAAC;AAG9D,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,SAAS,EACT,QAAQ,GACT,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGjI,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEjE,YAAY,EACV,cAAc,EACd,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,OAAO,EACP,YAAY,EACZ,QAAQ,EACR,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,WAAW,EACX,SAAS,EACT,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACpB,KAAK,EACL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,KAAK,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,YAAY,EACZ,cAAc,EACd,oBAAoB,GACrB,MAAM,kBAAkB,CAAC"}
|
package/dist/react/provider.d.ts
CHANGED
|
@@ -14,18 +14,29 @@ export interface TagadaHeadlessProviderProps {
|
|
|
14
14
|
config?: HeadlessConfig;
|
|
15
15
|
children: React.ReactNode;
|
|
16
16
|
}
|
|
17
|
+
/** Props when the whole config is passed: it replaces `storeId`, `environment`, `apiKey` and `baseUrl`. */
|
|
18
|
+
export interface TagadaHeadlessProviderConfigProps {
|
|
19
|
+
/** Full config object. The only way to pass `funnel`, `accountId`, `timeout` or `bootstrap`. */
|
|
20
|
+
config: HeadlessConfig;
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
}
|
|
17
23
|
/**
|
|
18
24
|
* Root provider for the TagadaPay Headless SDK React integration.
|
|
19
|
-
* Creates a single HeadlessClient and shares it via context.
|
|
25
|
+
* Creates a single HeadlessClient and shares it via context. The client is rebuilt only
|
|
26
|
+
* when a config value changes, so an inline `config` object keeps the same client.
|
|
20
27
|
*
|
|
21
28
|
* @example
|
|
22
29
|
* ```tsx
|
|
23
30
|
* <TagadaHeadlessProvider storeId="store_abc123" environment="production">
|
|
24
31
|
* <App />
|
|
25
32
|
* </TagadaHeadlessProvider>
|
|
33
|
+
*
|
|
34
|
+
* <TagadaHeadlessProvider config={{ storeId: 'store_abc123', funnel: 'main' }}>
|
|
35
|
+
* <App />
|
|
36
|
+
* </TagadaHeadlessProvider>
|
|
26
37
|
* ```
|
|
27
38
|
*/
|
|
28
|
-
export declare function TagadaHeadlessProvider(
|
|
39
|
+
export declare function TagadaHeadlessProvider(props: TagadaHeadlessProviderProps | TagadaHeadlessProviderConfigProps): import("react/jsx-runtime.js").JSX.Element;
|
|
29
40
|
/** Access the HeadlessClient from context. Throws if used outside the provider. */
|
|
30
41
|
export declare function useHeadlessClient(): HeadlessClient;
|
|
31
42
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,cAAc,EAAwB,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQpE,MAAM,WAAW,2BAA2B;IAC1C,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,6CAA6C;IAC7C,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED
|
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