@evelan/jexity-widget 0.13.1 → 0.15.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/dist/index.mjs +4778 -2242
- package/dist/index.mjs.map +1 -1
- package/dist/react.mjs +5346 -2810
- package/dist/react.mjs.map +1 -1
- package/dist/types/features/chat/components/MagiclineFormMessage.d.ts +34 -0
- package/dist/types/features/chat/components/MagiclineFormMessage.d.ts.map +1 -0
- package/dist/types/features/chat/components/MessageList.d.ts.map +1 -1
- package/dist/types/features/chat/components/magicline/ContractCreationForm.d.ts +34 -0
- package/dist/types/features/chat/components/magicline/ContractCreationForm.d.ts.map +1 -0
- package/dist/types/features/chat/components/magicline/TrialSessionBookingForm.d.ts +34 -0
- package/dist/types/features/chat/components/magicline/TrialSessionBookingForm.d.ts.map +1 -0
- package/dist/types/features/chat/components/magicline/buildWizardSteps.d.ts +26 -0
- package/dist/types/features/chat/components/magicline/buildWizardSteps.d.ts.map +1 -0
- package/dist/types/features/chat/components/magicline/formUtils.d.ts +105 -0
- package/dist/types/features/chat/components/magicline/formUtils.d.ts.map +1 -0
- package/dist/types/features/chat/components/magicline/magiclineConstants.d.ts +21 -0
- package/dist/types/features/chat/components/magicline/magiclineConstants.d.ts.map +1 -0
- package/dist/types/features/chat/components/magicline/useContractCreationState.d.ts +152 -0
- package/dist/types/features/chat/components/magicline/useContractCreationState.d.ts.map +1 -0
- package/dist/types/features/chat/components/magicline/useTrialBookingState.d.ts +87 -0
- package/dist/types/features/chat/components/magicline/useTrialBookingState.d.ts.map +1 -0
- package/dist/types/features/chat/hooks/useMagicline.d.ts +308 -0
- package/dist/types/features/chat/hooks/useMagicline.d.ts.map +1 -0
- package/dist/types/i18n/locales/de.d.ts.map +1 -1
- package/dist/types/i18n/locales/en.d.ts +149 -0
- package/dist/types/i18n/locales/en.d.ts.map +1 -1
- package/dist/widget.js +40 -39
- package/dist/widget.js.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Doc, Id } from '@repo/backend/convex/_generated/dataModel';
|
|
2
|
+
interface MagiclineFormMessageProps {
|
|
3
|
+
message: Doc<'conversations'>;
|
|
4
|
+
sessionId: Id<'contactSessions'>;
|
|
5
|
+
visitorId: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Inline Magicline integration form rendered inside the chat thread.
|
|
9
|
+
*
|
|
10
|
+
* Three states driven by `message.magiclineForm.status`:
|
|
11
|
+
* - `submitted` → read-only success card (NOT re-submittable).
|
|
12
|
+
* - `failed` → read-only failure card.
|
|
13
|
+
* - `open` → renders the interactive form: `trialSessionBooking` →
|
|
14
|
+
* TrialSessionBookingForm, `contractCreation` → ContractCreationForm. The
|
|
15
|
+
* dormant `leadApplication` action is intentionally NOT routed (the file stays
|
|
16
|
+
* on disk but is no longer imported).
|
|
17
|
+
*
|
|
18
|
+
* `contractCreation` is routed for EVERY status (not just `open`): its submit
|
|
19
|
+
* action flips the row to `submitted` at claim time, so the form must stay
|
|
20
|
+
* mounted to render its own result envelope (customer number / terminal notice).
|
|
21
|
+
*
|
|
22
|
+
* 409 retry: when a `slot_unavailable` 409 reopens the form (status flips
|
|
23
|
+
* back to `open` while the linked submission carries `errorCode === "slot_unavailable"`),
|
|
24
|
+
* the form shows a "pick another time" notice and reloads slots. This is detected
|
|
25
|
+
* by reading `getSubmissionStatus` only when the form is `open` AND a
|
|
26
|
+
* `submissionId` is present (otherwise the query is skipped).
|
|
27
|
+
*
|
|
28
|
+
* Mirrors FormMessage (escalation): reads the row, renders read-only when the
|
|
29
|
+
* backend has flipped the status, otherwise renders the interactive form. The
|
|
30
|
+
* form's own submit handler additionally guards against double-submit.
|
|
31
|
+
*/
|
|
32
|
+
export declare function MagiclineFormMessage({ message, sessionId, visitorId }: MagiclineFormMessageProps): import("preact").JSX.Element | null;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=MagiclineFormMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MagiclineFormMessage.d.ts","sourceRoot":"","sources":["../../../../../src/features/chat/components/MagiclineFormMessage.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,2CAA2C,CAAA;AAExE,UAAU,yBAAyB;IACjC,OAAO,EAAE,GAAG,CAAC,eAAe,CAAC,CAAA;IAC7B,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAA;IAChC,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,yBAAyB,uCAgGhG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../../../src/features/chat/components/MessageList.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MessageList.d.ts","sourceRoot":"","sources":["../../../../../src/features/chat/components/MessageList.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,2CAA2C,CAAA;AAgBxE,UAAU,gBAAgB;IACxB,aAAa,EAAE,GAAG,CAAC,eAAe,CAAC,EAAE,GAAG,SAAS,CAAA;IACjD,QAAQ,EAAE,MAAM,CAAA;IAChB,8DAA8D;IAC9D,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,oEAAoE;IACpE,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,IAAI,CAAA;IACzB,iDAAiD;IACjD,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAA;IACvC,iDAAiD;IACjD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;CACzB;AAED,gFAAgF;AAChF,wBAAgB,WAAW,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,gBAAgB,gCA6J3I"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Id } from '@repo/backend/convex/_generated/dataModel';
|
|
2
|
+
interface ContractCreationFormProps {
|
|
3
|
+
formMessageId: Id<'conversations'>;
|
|
4
|
+
sessionId: Id<'contactSessions'>;
|
|
5
|
+
visitorId: string;
|
|
6
|
+
projectId: Id<'projects'>;
|
|
7
|
+
/**
|
|
8
|
+
* The reactive form-row status. The submit flips this to `submitted` at claim
|
|
9
|
+
* time, so the LIVE result envelope (held in component state) always wins; this
|
|
10
|
+
* is only consulted when there is no live result — i.e. a resumed/cold session
|
|
11
|
+
* landing on an already-terminal row.
|
|
12
|
+
*/
|
|
13
|
+
formStatus: 'open' | 'submitted' | 'failed';
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Inline Magicline membership-signup STEP WIZARD. Renders the contract-creation
|
|
17
|
+
* flow as internal steps inside ONE chat card:
|
|
18
|
+
*
|
|
19
|
+
* Offer → Personal → Address → Payment → Review
|
|
20
|
+
*
|
|
21
|
+
* All form state (offers, selected term, personal/address/payment fields,
|
|
22
|
+
* consents, server preview) lives in `useContractCreationState`, mounted ONCE
|
|
23
|
+
* here above the step switch so navigating steps never refetches offers.
|
|
24
|
+
*
|
|
25
|
+
* The submit action is synchronous and authoritative: it claims the submission
|
|
26
|
+
* (which flips the form row to `submitted` reactively), then dispatches and
|
|
27
|
+
* returns a result envelope. Because the reactive flip would otherwise unmount
|
|
28
|
+
* this form mid-await, the component owns its OWN `submitResult` and renders the
|
|
29
|
+
* success / terminal UI from the returned envelope — `MagiclineFormMessage`
|
|
30
|
+
* keeps this form mounted while it owns a live result.
|
|
31
|
+
*/
|
|
32
|
+
export declare function ContractCreationForm({ formMessageId, sessionId, visitorId, projectId, formStatus, }: ContractCreationFormProps): import("preact").JSX.Element;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=ContractCreationForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContractCreationForm.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chat/components/magicline/ContractCreationForm.tsx"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,2CAA2C,CAAA;AAuBnE,UAAU,yBAAyB;IACjC,aAAa,EAAE,EAAE,CAAC,eAAe,CAAC,CAAA;IAClC,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAA;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,EAAE,CAAC,UAAU,CAAC,CAAA;IACzB;;;;;OAKG;IACH,UAAU,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAA;CAC5C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,aAAa,EACb,SAAS,EACT,SAAS,EACT,SAAS,EACT,UAAU,GACX,EAAE,yBAAyB,gCAqb3B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Id } from '@repo/backend/convex/_generated/dataModel';
|
|
2
|
+
interface TrialSessionBookingFormProps {
|
|
3
|
+
formMessageId: Id<'conversations'>;
|
|
4
|
+
sessionId: Id<'contactSessions'>;
|
|
5
|
+
visitorId: string;
|
|
6
|
+
/** Set when the form was reopened after a `slot_unavailable` 409. */
|
|
7
|
+
slotUnavailable?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* True while the 409 retry-status query is still resolving. The Slot
|
|
10
|
+
* step waits for this to clear before deciding its UI so a reopened form
|
|
11
|
+
* doesn't flash "no slots" before the slot-unavailable notice resolves.
|
|
12
|
+
*/
|
|
13
|
+
retryPending?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Inline Magicline trial-session booking STEP WIZARD. Renders the
|
|
17
|
+
* dynamic per-studio form as internal steps inside ONE chat card:
|
|
18
|
+
*
|
|
19
|
+
* Trainer → Slot → Personal → Address → Confirm
|
|
20
|
+
*
|
|
21
|
+
* Steps with no visible fields are auto-skipped (see `buildWizardSteps`). The
|
|
22
|
+
* trainer step is shown only when the studio allows trainer-free bookings.
|
|
23
|
+
*
|
|
24
|
+
* State (config, slots, all field values) is lifted into `useTrialBookingState`
|
|
25
|
+
* which is mounted ONCE here, above the step switch — so navigating between
|
|
26
|
+
* steps never refetches config or slots. Config is fetched once on open;
|
|
27
|
+
* slots are fetched on open and whenever the trainer choice changes.
|
|
28
|
+
*
|
|
29
|
+
* The selected slot's `startDateTime` is sent as the `slotId` field — the
|
|
30
|
+
* backend transformer maps `slotId` → Magicline `startDateTime`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function TrialSessionBookingForm({ formMessageId, sessionId, visitorId, slotUnavailable, retryPending, }: TrialSessionBookingFormProps): import("preact").JSX.Element;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=TrialSessionBookingForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TrialSessionBookingForm.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chat/components/magicline/TrialSessionBookingForm.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,2CAA2C,CAAA;AAEnE,UAAU,4BAA4B;IACpC,aAAa,EAAE,EAAE,CAAC,eAAe,CAAC,CAAA;IAClC,SAAS,EAAE,EAAE,CAAC,iBAAiB,CAAC,CAAA;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,qEAAqE;IACrE,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAKD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,aAAa,EACb,SAAS,EACT,SAAS,EACT,eAAuB,EACvB,YAAoB,GACrB,EAAE,4BAA4B,gCA2C9B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TrialConfigPlan } from '../../hooks/useMagicline';
|
|
2
|
+
/**
|
|
3
|
+
* Ordered wizard step identifiers. The widget renders these as internal steps
|
|
4
|
+
* inside ONE card (not one chat message per step).
|
|
5
|
+
*/
|
|
6
|
+
export type WizardStep = 'trainer' | 'slot' | 'personal' | 'address' | 'confirm';
|
|
7
|
+
/**
|
|
8
|
+
* Pure helper — resolves the ordered list of VISIBLE wizard steps for a studio
|
|
9
|
+
* plan. Steps with no visible fields are skipped so the visitor never lands on
|
|
10
|
+
* an empty page and the "Step n of N" counter shrinks accordingly.
|
|
11
|
+
*
|
|
12
|
+
* Skip rules:
|
|
13
|
+
* - `trainer` — skipped unless the studio allows trainer-free bookings
|
|
14
|
+
* (`bookingWithoutTrainerAllowed === true`); otherwise the choice is forced
|
|
15
|
+
* and there is nothing to ask.
|
|
16
|
+
* - `slot` — always shown (a slot is mandatory).
|
|
17
|
+
* - `personal` — always shown (firstname/lastname are always visible+required).
|
|
18
|
+
* - `address` — skipped when neither the address group nor the zip field is
|
|
19
|
+
* visible per the plan.
|
|
20
|
+
* - `confirm` — always shown (note + consent + summary + submit).
|
|
21
|
+
*
|
|
22
|
+
* Visibility is derived ONLY from the same `plan` the fields use — no second
|
|
23
|
+
* source of truth.
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildWizardSteps(plan: TrialConfigPlan, bookingWithoutTrainerAllowed: boolean): WizardStep[];
|
|
26
|
+
//# sourceMappingURL=buildWizardSteps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildWizardSteps.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chat/components/magicline/buildWizardSteps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE/D;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAA;AAEhF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,eAAe,EACrB,4BAA4B,EAAE,OAAO,GACpC,UAAU,EAAE,CAYd"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { WidgetStrings } from '../../../../i18n/locales/en';
|
|
2
|
+
export declare function isValidEmail(value: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Whole-years age from an ISO `YYYY-MM-DD` date-of-birth string at `now`.
|
|
5
|
+
* Returns `null` when the value is empty or unparseable (callers treat a null
|
|
6
|
+
* age as "not yet entered", deferring to required-field handling). Client-side
|
|
7
|
+
* UX only — the backend re-validates minimum age against the studio plan.
|
|
8
|
+
*
|
|
9
|
+
* The Y/M/D parts are parsed manually via `split('-')` instead of
|
|
10
|
+
* `new Date('YYYY-MM-DD')`. The string form is parsed as UTC midnight, so
|
|
11
|
+
* comparing it with LOCAL getters (`now.getDate()` etc.) shifts the day by one
|
|
12
|
+
* in negative-offset timezones and mis-gates min-age on the birthday boundary.
|
|
13
|
+
* Parsing the parts directly keeps the comparison purely calendar-based.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ageFromIsoDate(isoDate: string, now?: Date): number | null;
|
|
16
|
+
/** Today's date as an ISO `YYYY-MM-DD` string in LOCAL time (for `<input max>`). */
|
|
17
|
+
export declare function todayIsoDate(now?: Date): string;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve the privacy-policy URL the same way FormMessage does: prefer the
|
|
20
|
+
* org-configured URL when it is absolute, otherwise fall back to the platform
|
|
21
|
+
* default.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolvePrivacyUrl(): string;
|
|
24
|
+
/** Strip whitespace and uppercase — the canonical IBAN form for validation. */
|
|
25
|
+
export declare function normalizeIban(raw: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Client-side IBAN check mirroring the backend `validateIban` exactly:
|
|
28
|
+
* 1. length against the per-country table (or the generic 15–34 bound);
|
|
29
|
+
* 2. the ISO 13616 mod-97 check (move first 4 chars to the end, expand
|
|
30
|
+
* letters A=10..Z=35, chunked reduction to stay in safe-integer range).
|
|
31
|
+
*
|
|
32
|
+
* Pure UX gate — the backend re-validates. The raw IBAN is never logged here.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isValidIban(raw: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Mask an IBAN for the review summary: show the first 4 and last 4 characters
|
|
37
|
+
* of the normalized value, bullets in between, regrouped into 4-char blocks.
|
|
38
|
+
* e.g. `DE89 3704 0044 0532 0130 00` → `DE89 •••• •••• •••• •••• 00`. Used for
|
|
39
|
+
* display ONLY — the raw IBAN never leaves component memory through this path.
|
|
40
|
+
*/
|
|
41
|
+
export declare function maskIban(raw: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* Format a Magicline money amount with its currency code, localised to the
|
|
44
|
+
* widget locale. Magicline rate-bundle / flat-fee prices are decimal MAJOR
|
|
45
|
+
* units (e.g. `29` → "29,00 €"), so the value is rendered as-is — never divided.
|
|
46
|
+
* Falls back to a bare numeric string when the currency code is unsupported by
|
|
47
|
+
* the runtime's `Intl`.
|
|
48
|
+
*/
|
|
49
|
+
export declare function formatContractMoney(amount: number, currencyCode: string, widgetLocale: 'en' | 'de'): string;
|
|
50
|
+
/**
|
|
51
|
+
* Localised "{value} {unit}" period label, e.g. "12 months" / "12 Monate". The
|
|
52
|
+
* Magicline period unit is an uppercase enum (`DAY` / `WEEK` / `MONTH` / `YEAR`);
|
|
53
|
+
* unknown units fall back to a lowercased raw unit so the label degrades safely.
|
|
54
|
+
*/
|
|
55
|
+
export declare function formatContractPeriod(value: number, unit: string, widgetLocale: 'en' | 'de'): string;
|
|
56
|
+
/**
|
|
57
|
+
* Format an ISO date (`YYYY-MM-DD` or a full datetime) for display in the
|
|
58
|
+
* review summary, localised to the widget locale. Falls back to the raw value
|
|
59
|
+
* when unparseable so a malformed start date never blanks the summary row.
|
|
60
|
+
*/
|
|
61
|
+
export declare function formatContractDate(isoDate: string, widgetLocale: 'en' | 'de'): string;
|
|
62
|
+
/**
|
|
63
|
+
* Recurring-price frequency suffix for a rate-bundle term price, e.g.
|
|
64
|
+
* "per week" / "pro Woche" (value === 1) or "every 3 weeks" / "alle 3 Wochen"
|
|
65
|
+
* (value > 1). Used as a suffix after a formatted money amount in offer cards
|
|
66
|
+
* and the review base-price line.
|
|
67
|
+
*
|
|
68
|
+
* Supported units: DAY / WEEK / MONTH / YEAR (Magicline uppercase enum).
|
|
69
|
+
* Unknown units fall back to a lowercased raw unit so the label degrades safely.
|
|
70
|
+
*/
|
|
71
|
+
export declare function formatPaymentFrequency(value: number, unit: string, widgetLocale: 'en' | 'de'): string;
|
|
72
|
+
/**
|
|
73
|
+
* Formatted price label for an optional module, combining the money amount with
|
|
74
|
+
* the appropriate frequency or type suffix. Mirrors Fit Inn's formatPriceLabel.
|
|
75
|
+
*
|
|
76
|
+
* paymentFrequencyType values:
|
|
77
|
+
* "TERM_BASED" → "{money} per term"
|
|
78
|
+
* "RECURRING" → "{money} " + formatPaymentFrequency(1, recurringUnit)
|
|
79
|
+
* "NON_RECURRING" → "{money} one-time"
|
|
80
|
+
* "MONTH_DAY" → "{money} one-time"
|
|
81
|
+
* "FREE" → "included"
|
|
82
|
+
* null / other → bare money string
|
|
83
|
+
*/
|
|
84
|
+
export declare function formatModulePrice(amount: number, currencyCode: string, paymentFrequencyType: string | null, recurringUnit: string | null, widgetLocale: 'en' | 'de'): string;
|
|
85
|
+
/**
|
|
86
|
+
* Localize a raw Magicline flat-fee name. When the normalized name is in the
|
|
87
|
+
* known-fee map, the locale string for that key is returned. Otherwise the
|
|
88
|
+
* original raw name is returned unchanged so unmapped fees degrade safely.
|
|
89
|
+
*/
|
|
90
|
+
export declare function localizeFeeName(rawName: string, t: WidgetStrings): string;
|
|
91
|
+
/**
|
|
92
|
+
* Renewal label for an optional module extension type. Returns an empty string
|
|
93
|
+
* when the type produces no visible renewal line (SUBSEQUENT_RATE_DETAIL, null).
|
|
94
|
+
*
|
|
95
|
+
* extensionType values:
|
|
96
|
+
* "NONE" → "No automatic renewal"
|
|
97
|
+
* "TERM_EXTENSION" → "Renewal: {n} {unit}" (via the period table)
|
|
98
|
+
* "SUBSEQUENT_RATE_DETAIL"→ "" (no line rendered)
|
|
99
|
+
* null → "" (no line rendered)
|
|
100
|
+
*/
|
|
101
|
+
export declare function formatModuleRenewal(extensionType: string | null, termExtension: {
|
|
102
|
+
value: number;
|
|
103
|
+
unit: string;
|
|
104
|
+
} | null, widgetLocale: 'en' | 'de'): string;
|
|
105
|
+
//# sourceMappingURL=formUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chat/components/magicline/formUtils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAQhE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,GAAE,IAAiB,GAAG,MAAM,GAAG,IAAI,CA8BrF;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,GAAG,GAAE,IAAiB,GAAG,MAAM,CAK3D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAG1C;AA4BD,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAgChD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAS5C;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,IAAI,GAAG,IAAI,GACxB,MAAM,CAUR;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,IAAI,GAAG,IAAI,GACxB,MAAM,CAcR;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,GAAG,IAAI,GAAG,MAAM,CAWrF;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,IAAI,GAAG,IAAI,GACxB,MAAM,CAuBR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,oBAAoB,EAAE,MAAM,GAAG,IAAI,EACnC,aAAa,EAAE,MAAM,GAAG,IAAI,EAC5B,YAAY,EAAE,IAAI,GAAG,IAAI,GACxB,MAAM,CAmBR;AAeD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,GAAG,MAAM,CAOzE;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,MAAM,GAAG,IAAI,EAC5B,aAAa,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,EACrD,YAAY,EAAE,IAAI,GAAG,IAAI,GACxB,MAAM,CAYR"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widget-side Magicline constants. The widget cannot import the backend
|
|
3
|
+
* `model.ts` (it is bundled separately), so the controlled `<select>` enums are
|
|
4
|
+
* mirrored here. Every value below is a member of the backend `GENDER_ENUM` /
|
|
5
|
+
* `COUNTRY_ENUM` so a submission re-validates server-side without surprises.
|
|
6
|
+
*/
|
|
7
|
+
/** Magicline gender enum (controlled select). Mirrors backend `GENDER_ENUM`. */
|
|
8
|
+
export declare const GENDER_VALUES: readonly ["MALE", "FEMALE", "UNISEX"];
|
|
9
|
+
export type GenderValue = (typeof GENDER_VALUES)[number];
|
|
10
|
+
/**
|
|
11
|
+
* Curated subset of the backend `COUNTRY_ENUM` for the country `<select>`.
|
|
12
|
+
* Magicline's full enum has 250+ ISO codes; surfacing all of them in a widget
|
|
13
|
+
* dropdown is poor UX. We ship the DACH region plus common neighbours — every
|
|
14
|
+
* code here is a valid `COUNTRY_ENUM` member, so the server-side check passes.
|
|
15
|
+
*/
|
|
16
|
+
export interface CountryOption {
|
|
17
|
+
code: string;
|
|
18
|
+
label: string;
|
|
19
|
+
}
|
|
20
|
+
export declare const COUNTRY_OPTIONS: readonly CountryOption[];
|
|
21
|
+
//# sourceMappingURL=magiclineConstants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"magiclineConstants.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chat/components/magicline/magiclineConstants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,gFAAgF;AAChF,eAAO,MAAM,aAAa,uCAAwC,CAAA;AAClE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAA;AAExD;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd;AAED,eAAO,MAAM,eAAe,EAAE,SAAS,aAAa,EAgB1C,CAAA"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { type ContractFlatFee, type ContractPeriod, type ContractPreviewModule, type ContractVolume, type RateBundleTermCard } from '../../hooks/useMagicline';
|
|
2
|
+
import type { Id } from '@repo/backend/convex/_generated/dataModel';
|
|
3
|
+
/**
|
|
4
|
+
* Offers lifecycle. `empty` (healthy, zero eligible terms) is split from
|
|
5
|
+
* `error` (unavailable / network rejection) so the Offer step shows a friendly
|
|
6
|
+
* no-offers message on `empty` and a Retry affordance on `error`.
|
|
7
|
+
*/
|
|
8
|
+
export type OffersState = {
|
|
9
|
+
phase: 'loading';
|
|
10
|
+
} | {
|
|
11
|
+
phase: 'ready';
|
|
12
|
+
terms: RateBundleTermCard[];
|
|
13
|
+
} | {
|
|
14
|
+
phase: 'empty';
|
|
15
|
+
} | {
|
|
16
|
+
phase: 'error';
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Server-resolved pricing for the Review step. Fetched on entering Review and
|
|
20
|
+
* re-fetched after a `price_changed` outcome. The `fingerprint` is replayed to
|
|
21
|
+
* the submit action so the backend can confirm the price the visitor saw.
|
|
22
|
+
*/
|
|
23
|
+
export interface ContractPricing {
|
|
24
|
+
basePrice: number;
|
|
25
|
+
preUseCharge: number;
|
|
26
|
+
currencyCode: string;
|
|
27
|
+
flatFees: ContractFlatFee[];
|
|
28
|
+
modules: ContractPreviewModule[];
|
|
29
|
+
contractVolume: ContractVolume | null;
|
|
30
|
+
startDate: string;
|
|
31
|
+
/** Payment frequency of the revalidated term; renders the base-price period. */
|
|
32
|
+
paymentFrequency: ContractPeriod;
|
|
33
|
+
fingerprint: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Preview lifecycle. `idle` is the pre-Review state (no fetch yet). A non-ok
|
|
37
|
+
* preview status is surfaced as the `error` phase carrying the status code so
|
|
38
|
+
* the view can route an `offer_unavailable` back to the Offer step.
|
|
39
|
+
*/
|
|
40
|
+
export type PreviewState = {
|
|
41
|
+
phase: 'idle';
|
|
42
|
+
} | {
|
|
43
|
+
phase: 'loading';
|
|
44
|
+
} | {
|
|
45
|
+
phase: 'ready';
|
|
46
|
+
pricing: ContractPricing;
|
|
47
|
+
} | {
|
|
48
|
+
phase: 'error';
|
|
49
|
+
code: 'consent_required' | 'invalid_fields' | 'offer_unavailable' | 'unavailable';
|
|
50
|
+
};
|
|
51
|
+
/** Personal detail fields — all required by the backend. */
|
|
52
|
+
export interface ContractPersonalFields {
|
|
53
|
+
firstName: string;
|
|
54
|
+
lastName: string;
|
|
55
|
+
email: string;
|
|
56
|
+
dateOfBirth: string;
|
|
57
|
+
gender: string;
|
|
58
|
+
phone: string;
|
|
59
|
+
}
|
|
60
|
+
/** Address fields — country is a static "Deutschland"/"Germany", not collected. */
|
|
61
|
+
export interface ContractAddressFields {
|
|
62
|
+
street: string;
|
|
63
|
+
houseNumber: string;
|
|
64
|
+
zipCode: string;
|
|
65
|
+
city: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Payment fields. `accountHolderTouched` tracks whether the visitor has edited
|
|
69
|
+
* the account holder so the firstname+lastname prefill only auto-fills once and
|
|
70
|
+
* never clobbers a manual edit. The IBAN lives ONLY here, in memory — it is
|
|
71
|
+
* never persisted to sessionStorage and never logged.
|
|
72
|
+
*/
|
|
73
|
+
export interface ContractPaymentFields {
|
|
74
|
+
accountHolder: string;
|
|
75
|
+
accountHolderTouched: boolean;
|
|
76
|
+
iban: string;
|
|
77
|
+
}
|
|
78
|
+
/** Consent flags — both must be accepted before submit. */
|
|
79
|
+
export interface ContractConsentFields {
|
|
80
|
+
privacy: boolean;
|
|
81
|
+
sepa: boolean;
|
|
82
|
+
}
|
|
83
|
+
export interface ContractFormFields {
|
|
84
|
+
termId: number | null;
|
|
85
|
+
/** Chosen paid optional-module ids for the current term. */
|
|
86
|
+
selectedModuleIds: number[];
|
|
87
|
+
/**
|
|
88
|
+
* Acceptance of required confirmations, keyed by ackKey. Carries both contract
|
|
89
|
+
* text-block acknowledgements and selected-module consents — a single source
|
|
90
|
+
* of truth for every gating tick across the wizard.
|
|
91
|
+
*/
|
|
92
|
+
acknowledgedBlocks: Record<string, boolean>;
|
|
93
|
+
personal: ContractPersonalFields;
|
|
94
|
+
address: ContractAddressFields;
|
|
95
|
+
payment: ContractPaymentFields;
|
|
96
|
+
consents: ContractConsentFields;
|
|
97
|
+
}
|
|
98
|
+
export interface UseContractCreationStateOptions {
|
|
99
|
+
sessionId: Id<'contactSessions'>;
|
|
100
|
+
visitorId: string;
|
|
101
|
+
}
|
|
102
|
+
export interface ContractCreationState {
|
|
103
|
+
fields: ContractFormFields;
|
|
104
|
+
offersState: OffersState;
|
|
105
|
+
previewState: PreviewState;
|
|
106
|
+
/** The currently selected term card (or null when none is chosen). */
|
|
107
|
+
selectedTerm: RateBundleTermCard | null;
|
|
108
|
+
/**
|
|
109
|
+
* ackKeys that MUST be acknowledged before submit for the current term:
|
|
110
|
+
* required text blocks ∪ the consents of SELECTED modules that carry one.
|
|
111
|
+
*/
|
|
112
|
+
requiredAckKeys: string[];
|
|
113
|
+
/** True when every `requiredAckKeys` entry is currently acknowledged. */
|
|
114
|
+
allAcknowledged: boolean;
|
|
115
|
+
setTermId: (termId: number) => void;
|
|
116
|
+
setPersonal: (key: keyof ContractPersonalFields, value: string) => void;
|
|
117
|
+
setAddress: (key: keyof ContractAddressFields, value: string) => void;
|
|
118
|
+
/**
|
|
119
|
+
* Add/remove a paid optional module from the current term. Pass the module's
|
|
120
|
+
* consent ackKey so deselecting clears its acknowledgement in one dispatch.
|
|
121
|
+
*/
|
|
122
|
+
toggleModule: (moduleId: number, selected: boolean, consentAckKey?: string) => void;
|
|
123
|
+
/** Set the acknowledgement for a contract block or module consent by ackKey. */
|
|
124
|
+
setBlockAck: (ackKey: string, value: boolean) => void;
|
|
125
|
+
setAccountHolder: (value: string) => void;
|
|
126
|
+
setIban: (value: string) => void;
|
|
127
|
+
setConsent: (key: keyof ContractConsentFields, value: boolean) => void;
|
|
128
|
+
clearIban: () => void;
|
|
129
|
+
/** Clears the selected term so a stale selection does not survive an offer refetch. */
|
|
130
|
+
clearTermId: () => void;
|
|
131
|
+
/** Re-run the offers fetch (Retry button + `offer_unavailable` recovery). */
|
|
132
|
+
refetchOffers: () => void;
|
|
133
|
+
/** Fetch the server pricing for the selected term (called entering Review). */
|
|
134
|
+
fetchPreview: () => void;
|
|
135
|
+
/** Reset the preview back to idle (e.g. when leaving Review). */
|
|
136
|
+
resetPreview: () => void;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Single fetch-once container for the membership-signup wizard.
|
|
140
|
+
*
|
|
141
|
+
* - Offers are fetched ONCE on mount and again on `refetchOffers` (Retry /
|
|
142
|
+
* `offer_unavailable` recovery). A `offersKey` counter drives the effect.
|
|
143
|
+
* - The preview is NOT fetched until `fetchPreview` runs (entering Review). A
|
|
144
|
+
* `previewKey` counter re-runs it for `price_changed` recovery.
|
|
145
|
+
* - The account holder auto-prefills from firstname+lastname the first time both
|
|
146
|
+
* are present and the field is still untouched.
|
|
147
|
+
*
|
|
148
|
+
* The IBAN is held only in this hook's in-memory reducer state — it is never
|
|
149
|
+
* written to sessionStorage and never logged.
|
|
150
|
+
*/
|
|
151
|
+
export declare function useContractCreationState({ sessionId, visitorId, }: UseContractCreationStateOptions): ContractCreationState;
|
|
152
|
+
//# sourceMappingURL=useContractCreationState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useContractCreationState.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chat/components/magicline/useContractCreationState.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAE1B,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACxB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,2CAA2C,CAAA;AAEnE;;;;GAIG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GACpB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,kBAAkB,EAAE,CAAA;CAAE,GAC/C;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,GAClB;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,CAAA;AAEt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AM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACrD,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACzC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,qBAAqB,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACtE,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,uFAAuF;IACvF,WAAW,EAAE,MAAM,IAAI,CAAA;IACvB,6EAA6E;IAC7E,aAAa,EAAE,MAAM,IAAI,CAAA;IACzB,+EAA+E;IAC/E,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,iEAAiE;IACjE,YAAY,EAAE,MAAM,IAAI,CAAA;CACzB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,SAAS,EACT,SAAS,GACV,EAAE,+BAA+B,GAAG,qBAAqB,CAqPzD"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type TrialConfigPlan, type TrialSlot } from '../../hooks/useMagicline';
|
|
2
|
+
import type { Id } from '@repo/backend/convex/_generated/dataModel';
|
|
3
|
+
/** Resolved per-studio config (only present once the fetch succeeds). */
|
|
4
|
+
export interface ResolvedConfig {
|
|
5
|
+
plan: TrialConfigPlan;
|
|
6
|
+
minimumAge: number;
|
|
7
|
+
bookingWithoutTrainerAllowed: boolean;
|
|
8
|
+
/** Studio IANA timezone (or null) — used to display bare-UTC slot times. */
|
|
9
|
+
studioZoneId: string | null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Config status as a CODE, not a resolved message. The view resolves the
|
|
13
|
+
* code to a localised string at render time so a locale toggle mid-fill never
|
|
14
|
+
* re-runs the config fetch and never nukes the filled form to an error card.
|
|
15
|
+
*/
|
|
16
|
+
export type ConfigStatusCode = 'unsupported' | 'inconsistent' | 'unavailable';
|
|
17
|
+
export type ConfigState = {
|
|
18
|
+
phase: 'loading';
|
|
19
|
+
} | {
|
|
20
|
+
phase: 'ready';
|
|
21
|
+
config: ResolvedConfig;
|
|
22
|
+
} | {
|
|
23
|
+
phase: 'error';
|
|
24
|
+
code: ConfigStatusCode;
|
|
25
|
+
backendMessage: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Slots lifecycle. `empty` (healthy, zero availability) is split from
|
|
29
|
+
* `error` (unavailable / network_error / rejection) so the Slot step can show
|
|
30
|
+
* a Retry affordance on `error` and a no-slots message on `empty`.
|
|
31
|
+
*/
|
|
32
|
+
export type SlotsState = {
|
|
33
|
+
phase: 'loading';
|
|
34
|
+
} | {
|
|
35
|
+
phase: 'ready';
|
|
36
|
+
slots: TrialSlot[];
|
|
37
|
+
} | {
|
|
38
|
+
phase: 'empty';
|
|
39
|
+
} | {
|
|
40
|
+
phase: 'error';
|
|
41
|
+
};
|
|
42
|
+
/** The flat field bag — all controlled inputs default to "". */
|
|
43
|
+
export interface TrialFormFields {
|
|
44
|
+
firstName: string;
|
|
45
|
+
lastName: string;
|
|
46
|
+
email: string;
|
|
47
|
+
phone: string;
|
|
48
|
+
birthDate: string;
|
|
49
|
+
gender: string;
|
|
50
|
+
street: string;
|
|
51
|
+
houseNumber: string;
|
|
52
|
+
zip: string;
|
|
53
|
+
city: string;
|
|
54
|
+
country: string;
|
|
55
|
+
note: string;
|
|
56
|
+
slotId: string;
|
|
57
|
+
consent: boolean;
|
|
58
|
+
/** Trainer required defaults to TRUE (safest); preselected "with trainer". */
|
|
59
|
+
trainerRequired: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface UseTrialBookingStateOptions {
|
|
62
|
+
sessionId: Id<'contactSessions'>;
|
|
63
|
+
visitorId: string;
|
|
64
|
+
}
|
|
65
|
+
export interface TrialBookingState {
|
|
66
|
+
fields: TrialFormFields;
|
|
67
|
+
setField: (key: keyof TrialFormFields, value: string | boolean) => void;
|
|
68
|
+
setTrainerRequired: (trainerRequired: boolean) => void;
|
|
69
|
+
configState: ConfigState;
|
|
70
|
+
slotsState: SlotsState;
|
|
71
|
+
/** Re-fetch slots with the current `trainerRequired` (Retry button). */
|
|
72
|
+
refetchSlots: () => void;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Single fetch-once container for the trial-booking wizard.
|
|
76
|
+
*
|
|
77
|
+
* - Config is fetched ONCE on mount. A locale toggle does NOT re-fetch it
|
|
78
|
+
* (no `t` in deps; status stored as a code).
|
|
79
|
+
* - Slots are fetched once config is ready and again whenever `trainerRequired`
|
|
80
|
+
* flips OR `refetchSlots` is called. A `refreshKey` counter drives the slot
|
|
81
|
+
* effect so the Retry button can re-run it without other deps changing.
|
|
82
|
+
* - Wizard STEP components read this shared state — mounting a step never
|
|
83
|
+
* re-fetches config or slots (the fetches live on this single hook instance,
|
|
84
|
+
* which is mounted once by the container, above the step switch).
|
|
85
|
+
*/
|
|
86
|
+
export declare function useTrialBookingState({ sessionId, visitorId, }: UseTrialBookingStateOptions): TrialBookingState;
|
|
87
|
+
//# sourceMappingURL=useTrialBookingState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrialBookingState.d.ts","sourceRoot":"","sources":["../../../../../../src/features/chat/components/magicline/useTrialBookingState.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,eAAe,EACpB,KAAK,SAAS,EACf,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,2CAA2C,CAAA;AAEnE,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,eAAe,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,4BAA4B,EAAE,OAAO,CAAA;IACrC,4EAA4E;IAC5E,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAED;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,cAAc,GAAG,aAAa,CAAA;AAE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