@wix/himalaya-cli 0.1722.0 → 0.1724.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/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-config.d.ts +1 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-module.d.ts +2 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/godot/src/index.d.ts +3 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/attendance-classifier.d.ts +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/wix-payments-contract.d.ts +3 -39
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/define-app.d.ts +10 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/index.d.ts +2 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/preview-surfaces.d.ts +24 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-web-sdk.d.ts +37 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-web-sdk.generated.d.ts +1 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/wrapped-app-link.d.ts +13 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/checkout-source.d.ts +2 -3
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-order-backend.d.ts +0 -2
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/attendance.d.ts +2 -8
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/index.d.ts +4 -13
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +175 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap-checkout.mjs +46 -502
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap.mjs +5 -26
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +64 -648
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +1 -0
- package/dist/browser-plane/assets.json +5 -5
- package/dist/browser-plane/package-reader.js +4 -4
- package/dist/browser-plane/preview-deferred/{74e5b76ecf38392d7eb3f9a9512d60a0675de85d411c9c56293e123152b3f70b.bin → a6e25c06d2a17ab2b5e34bf2b5965fa3ddd76ce3da32a036e546a60938130d7b.bin} +1 -1
- package/dist/browser-plane/sw.js +9 -9
- package/dist/cli.mjs +1325 -422
- package/dist/preview-assets.generated.bin +0 -0
- package/guides/himi-json-output.md +6 -2
- package/guides/iap-screen-adoption.md +4 -4
- package/guides/sdk-reference.json +11 -74
- package/guides/webview-page-sdk.md +14 -0
- package/guides/wix-business-context.md +24 -0
- package/guides/wix-site-to-himi-app.md +2 -1
- package/package.json +2 -2
- package/templates/beauty-salon/tier5-src/himi-store-account/index.ts +2 -2
- package/templates/beauty-salon/tier5-src/himi-store-product/index.ts +5 -8
- package/templates/beauty-salon-owner/config.ts +1 -1
- package/templates/branded-lite/tier5-src/himi-store-account/index.ts +2 -2
- package/templates/branded-lite/tier5-src/himi-store-product/index.ts +5 -8
- package/templates/brandy/README.md +14 -1
- package/templates/brandy/config.ts +71 -5
- package/templates/brandy/dev/index.ts +522 -8
- package/templates/brandy/himalaya.content.json +1 -1
- package/templates/brandy/himalaya.template.json +1 -1
- package/templates/brandy/tier5-src/himi-brandy-base44-account/index.ts +187 -0
- package/templates/community-club/tier5-src/himi-store-account/index.ts +2 -2
- package/templates/community-club-owner/config.ts +1 -1
- package/templates/conference/tier5-src/himi-store-account/index.ts +2 -2
- package/templates/events-meetups/tier5-src/himi-store-account/index.ts +2 -2
- package/templates/events-meetups-owner/config.ts +1 -1
- package/templates/gym-fitness/tier5-src/himi-store-account/index.ts +2 -2
- package/templates/gym-fitness/tier5-src/himi-store-product/index.ts +5 -8
- package/templates/gym-fitness-owner/config.ts +1 -1
- package/templates/nonprofit-cause/tier5-src/himi-store-account/index.ts +2 -2
- package/templates/nonprofit-cause-owner/config.ts +1 -1
- package/templates/owner-lite/config.ts +1 -1
- package/templates/podcast-creator/tier5-src/himi-store-account/index.ts +2 -2
- package/templates/podcast-creator-owner/config.ts +1 -1
- package/templates/portfolio-creative/tier5-src/himi-store-account/index.ts +2 -2
- package/templates/portfolio-creative/tier5-src/himi-store-product/index.ts +5 -8
- package/templates/portfolio-creative-owner/config.ts +1 -1
- package/templates/restaurant/tier5-src/himi-store-account/index.ts +2 -2
- package/templates/restaurant-owner/config.ts +1 -1
- package/templates/retail-store/tier5-src/himi-store-account/index.ts +2 -2
- package/templates/retail-store/tier5-src/himi-store-product/index.ts +5 -8
- package/templates/retail-store-owner/config.ts +1 -1
- package/templates/salon-spa/tier5-src/himi-store-account/index.ts +2 -2
- package/templates/wholesale-store/tier5-src/himi-store-account/index.ts +2 -2
- package/templates/wholesale-store/tier5-src/himi-store-product/index.ts +5 -8
- package/templates/yoga-studio/tier5-src/himi-store-account/index.ts +2 -2
- package/templates/yoga-studio-owner/config.ts +1 -1
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/attendance-orders.d.ts +0 -10
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/online-programs-orders.d.ts +0 -2
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/pricing-plans-orders.d.ts +0 -2
|
@@ -161,17 +161,17 @@ function businessContactPoint(contact) {
|
|
|
161
161
|
return contact.isPhysical !== false && p && typeof p.latitude === "number" && Number.isFinite(p.latitude) && Math.abs(p.latitude) <= 90 && typeof p.longitude === "number" && Number.isFinite(p.longitude) && Math.abs(p.longitude) <= 180 ? { latitude: p.latitude, longitude: p.longitude } : void 0;
|
|
162
162
|
}
|
|
163
163
|
function businessContactLink(kind, value) {
|
|
164
|
-
const
|
|
165
|
-
if (!
|
|
164
|
+
const text2 = clean(value);
|
|
165
|
+
if (!text2 || /[\u0000-\u001f\u007f]/.test(text2)) return "";
|
|
166
166
|
switch (kind) {
|
|
167
167
|
case "website":
|
|
168
|
-
return /^https?:\/\/[^\s/@]+(?:[/:?#]|$)/i.test(
|
|
168
|
+
return /^https?:\/\/[^\s/@]+(?:[/:?#]|$)/i.test(text2) && !/\s/.test(text2) && !/^https?:\/\/[^/]*@/i.test(text2) ? text2 : "";
|
|
169
169
|
case "phone":
|
|
170
|
-
return /^\+?[\d ()\-.]+$/.test(
|
|
170
|
+
return /^\+?[\d ()\-.]+$/.test(text2) && /\d/.test(text2) ? `tel:${text2.replace(/[ ()\-.]/g, "")}` : "";
|
|
171
171
|
case "email":
|
|
172
|
-
return /^[^\s@?&#]+@[^\s@?&#]+\.[^\s@?&#]+$/.test(
|
|
172
|
+
return /^[^\s@?&#]+@[^\s@?&#]+\.[^\s@?&#]+$/.test(text2) ? `mailto:${encodeURIComponent(text2)}` : "";
|
|
173
173
|
case "directions":
|
|
174
|
-
return `https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(
|
|
174
|
+
return `https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(text2)}`;
|
|
175
175
|
default:
|
|
176
176
|
return "";
|
|
177
177
|
}
|
|
@@ -183,7 +183,7 @@ function businessContactSection(opts = {}) {
|
|
|
183
183
|
const copy = { title: "Get in touch", message: "Message", directions: "Directions", unavailable: "Contact details unavailable", memberCountUnavailable: "Member count unavailable", member: "member", members: "members", ...opts.copy };
|
|
184
184
|
const service = opts.service ?? "businessContact";
|
|
185
185
|
const children = [];
|
|
186
|
-
const
|
|
186
|
+
const text2 = (key, value, style = "body") => node(`${id2}.${key}`, "Text", { text: value, style, collapseWhenEmpty: true });
|
|
187
187
|
const link = (key, label, value) => {
|
|
188
188
|
if (businessContactLink(key, value)) children.push(node(`${id2}.${key}`, "Button", {
|
|
189
189
|
title: label,
|
|
@@ -192,10 +192,10 @@ function businessContactSection(opts = {}) {
|
|
|
192
192
|
action: { actionId: `tier5.${service}.open`, params: { kind: key, value, failureLabel: copy.unavailable } }
|
|
193
193
|
}));
|
|
194
194
|
};
|
|
195
|
-
if (settings.isDescriptionVisible && clean(contact.description)) children.push(
|
|
195
|
+
if (settings.isDescriptionVisible && clean(contact.description)) children.push(text2("description", clean(contact.description)));
|
|
196
196
|
if (settings.isGetInTouchVisible && opts.chatScreenId) {
|
|
197
|
-
children.push(
|
|
198
|
-
if (clean(settings.getInTouchDescription)) children.push(
|
|
197
|
+
children.push(text2("title", clean(settings.getInTouchTitle) || copy.title, "title3"));
|
|
198
|
+
if (clean(settings.getInTouchDescription)) children.push(text2("subtitle", clean(settings.getInTouchDescription)));
|
|
199
199
|
children.push(node(`${id2}.message`, "Button", {
|
|
200
200
|
title: clean(settings.getInTouchButton) || copy.message,
|
|
201
201
|
style: "primary",
|
|
@@ -208,7 +208,7 @@ function businessContactSection(opts = {}) {
|
|
|
208
208
|
if (settings.isEmailVisible === true) link("email", clean(contact.email), clean(contact.email));
|
|
209
209
|
if (settings.isAddressVisible) {
|
|
210
210
|
const address = clean(contact.address);
|
|
211
|
-
if (address) children.push(
|
|
211
|
+
if (address) children.push(text2("address", address));
|
|
212
212
|
const point = businessContactPoint(contact);
|
|
213
213
|
if (settings.showMap && point) children.push(node(`${id2}.map`, "Map", {
|
|
214
214
|
...point,
|
|
@@ -221,9 +221,9 @@ function businessContactSection(opts = {}) {
|
|
|
221
221
|
}
|
|
222
222
|
const hasContent = children.length > 0;
|
|
223
223
|
if (!(settings.isAddressVisible && clean(contact.address) && contact.isPhysical !== false)) {
|
|
224
|
-
children.push({ ...
|
|
224
|
+
children.push({ ...text2("directions_copy", copy.directions), modifiers: { hidden: true } });
|
|
225
225
|
}
|
|
226
|
-
const unavailable2 =
|
|
226
|
+
const unavailable2 = text2("unavailable", copy.unavailable);
|
|
227
227
|
if (hasContent) unavailable2.modifiers = { hidden: true };
|
|
228
228
|
children.push(unavailable2);
|
|
229
229
|
if (opts.showMemberCount !== void 0) {
|
|
@@ -231,8 +231,8 @@ function businessContactSection(opts = {}) {
|
|
|
231
231
|
spacing: 4,
|
|
232
232
|
alignment: "center",
|
|
233
233
|
children: [
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
text2(`count_${key}`, `$service:${service}.memberCount`, "footnote"),
|
|
235
|
+
text2(`unit_${key}`, unit, "footnote")
|
|
236
236
|
]
|
|
237
237
|
});
|
|
238
238
|
const count = node(`${id2}.member_count`, "FragmentSlot", {
|
|
@@ -241,13 +241,13 @@ function businessContactSection(opts = {}) {
|
|
|
241
241
|
cases: [
|
|
242
242
|
{ id: "one", content: ready("one", copy.member) },
|
|
243
243
|
{ id: "other", content: ready("other", copy.members) },
|
|
244
|
-
{ id: "unavailable", content:
|
|
244
|
+
{ id: "unavailable", content: text2("members_unavailable", copy.memberCountUnavailable, "footnote") }
|
|
245
245
|
]
|
|
246
246
|
});
|
|
247
247
|
if (opts.showMemberCount === false) count.modifiers = { hidden: true };
|
|
248
248
|
children.push(count);
|
|
249
249
|
}
|
|
250
|
-
children.push(
|
|
250
|
+
children.push(text2("feedback", `$service:${service}.message`, "footnote"));
|
|
251
251
|
return node(id2, "VStack", { spacing: 12, alignment: "leading", children });
|
|
252
252
|
}
|
|
253
253
|
|
|
@@ -482,8 +482,8 @@ function ricosToPlainText(doc) {
|
|
|
482
482
|
const blocks = (nodes) => nodes.flatMap((node3) => node3.type === "PARAGRAPH" || node3.type === "HEADING" || node3.type === "TEXT" ? [inline(node3)] : blocks(kids(node3.nodes)));
|
|
483
483
|
return blocks(kids(doc?.nodes)).join("\n\n");
|
|
484
484
|
}
|
|
485
|
-
function plainTextToRicos(
|
|
486
|
-
return { nodes:
|
|
485
|
+
function plainTextToRicos(text2) {
|
|
486
|
+
return { nodes: text2.split("\n\n").map((t) => ({ type: "PARAGRAPH", nodes: [{ type: "TEXT", textData: { text: t, decorations: [] } }] })) };
|
|
487
487
|
}
|
|
488
488
|
function encodeRichContent(doc, opts = {}) {
|
|
489
489
|
if (doc === null || doc === void 0) return { json: "" };
|
|
@@ -699,13 +699,13 @@ function draftDocument(value) {
|
|
|
699
699
|
const block2 = object(raw);
|
|
700
700
|
if (typeof block2.text !== "string") return invalid();
|
|
701
701
|
if (block2.depth !== void 0 && block2.depth !== 0) return unsupported();
|
|
702
|
-
const
|
|
702
|
+
const text2 = block2.text;
|
|
703
703
|
const styles = block2.inlineStyleRanges ?? [];
|
|
704
704
|
const ranges = block2.entityRanges ?? [];
|
|
705
705
|
if (!Array.isArray(styles) || !Array.isArray(ranges) || styles.length + ranges.length > 500) return invalid();
|
|
706
706
|
const spans = [...styles.map((v) => ({ ...object(v), kind: "style" })), ...ranges.map((v) => ({ ...object(v), kind: "entity" }))];
|
|
707
707
|
for (const span of spans) {
|
|
708
|
-
if (!Number.isInteger(span.offset) || !Number.isInteger(span.length) || Number(span.offset) < 0 || Number(span.length) < 0 || Number(span.offset) + Number(span.length) >
|
|
708
|
+
if (!Number.isInteger(span.offset) || !Number.isInteger(span.length) || Number(span.offset) < 0 || Number(span.length) < 0 || Number(span.offset) + Number(span.length) > text2.length) return invalid();
|
|
709
709
|
}
|
|
710
710
|
if (block2.type === "atomic") {
|
|
711
711
|
if (ranges.length !== 1) return unsupported();
|
|
@@ -717,7 +717,7 @@ function draftDocument(value) {
|
|
|
717
717
|
nodes.push({ type: "IMAGE", imageData: { image: { src: { url }, ...typeof data.width === "number" ? { width: data.width } : {}, ...typeof data.height === "number" ? { height: data.height } : {} }, ...typeof data.alt === "string" ? { altText: data.alt } : {} } });
|
|
718
718
|
continue;
|
|
719
719
|
}
|
|
720
|
-
const cuts = [.../* @__PURE__ */ new Set([0,
|
|
720
|
+
const cuts = [.../* @__PURE__ */ new Set([0, text2.length, ...spans.flatMap((s2) => [Number(s2.offset), Number(s2.offset) + Number(s2.length)])])].sort((a, b) => a - b);
|
|
721
721
|
const runs = [];
|
|
722
722
|
for (let i = 1; i < cuts.length; i++) {
|
|
723
723
|
const start = cuts[i - 1], end = cuts[i];
|
|
@@ -732,7 +732,7 @@ function draftDocument(value) {
|
|
|
732
732
|
decorations.push({ type: "LINK", linkData: { link: { url: object(entity.data).url } } });
|
|
733
733
|
}
|
|
734
734
|
}
|
|
735
|
-
runs.push({ type: "TEXT", textData: { text:
|
|
735
|
+
runs.push({ type: "TEXT", textData: { text: text2.slice(start, end), decorations } });
|
|
736
736
|
}
|
|
737
737
|
const paragraph = { type: "PARAGRAPH", nodes: runs };
|
|
738
738
|
if (block2.type === "unordered-list-item" || block2.type === "ordered-list-item") {
|
|
@@ -1810,9 +1810,9 @@ function createPurchaseCoordinator(deps) {
|
|
|
1810
1810
|
if (session.kind !== "member") return requireSignIn();
|
|
1811
1811
|
if (listing === "listed") clearReconcileProblem();
|
|
1812
1812
|
const now = deps.clock.now();
|
|
1813
|
-
const
|
|
1814
|
-
|
|
1815
|
-
await settleDelivery(session, await deliver(session,
|
|
1813
|
+
const eligible = itemsWhere((item) => isAwaitingDelivery(item) && (item.state.nextAttemptAt === null || item.state.nextAttemptAt <= now));
|
|
1814
|
+
eligible.forEach(restartAttemptBudget);
|
|
1815
|
+
await settleDelivery(session, await deliver(session, eligible));
|
|
1816
1816
|
}
|
|
1817
1817
|
async function settleDelivery(session, delivered) {
|
|
1818
1818
|
applyDelivered(delivered);
|
|
@@ -2362,33 +2362,25 @@ var sameReference = (value, reference) => isObject2(value) && value.kind === ref
|
|
|
2362
2362
|
|
|
2363
2363
|
// ../../core/sdk/iap/src/wix-payments-contract.ts
|
|
2364
2364
|
var HIMALAYA_SERVE_IAP_ROUTE = { prefix: "/himalaya-serve/v1/iap" };
|
|
2365
|
-
var BOOKINGS_APPLE_SALES_ENABLED = true;
|
|
2366
|
-
var EVENTS_APPLE_SALES_ENABLED = true;
|
|
2367
2365
|
var ATTENDANCE_SALE_RULE = { appProductId: (id2) => id2, productType: "CONSUMABLE" };
|
|
2368
|
-
var STORES_APPLE_SALES_ENABLED = true;
|
|
2369
2366
|
var STORES_PRODUCT_SALE_RULE = { appProductId: (id2) => id2, productType: "NON_CONSUMABLE" };
|
|
2370
2367
|
var ONLINE_PROGRAM_SALE_RULE = { appProductId: (id2) => id2, productType: "NON_CONSUMABLE" };
|
|
2371
|
-
var PRICING_PLAN_APPLE_SALES_ENABLED = true;
|
|
2372
2368
|
var PRICING_PLAN_SALE_RULE = { appProductId: (id2) => id2, productType: "NON_CONSUMABLE" };
|
|
2373
2369
|
var VIDEOS_APPLE_SALES_ENABLED = false;
|
|
2374
|
-
var PRICING_PLAN_ITEM_PAYMENT_ENABLED = false;
|
|
2375
|
-
var CANCEL_PAYMENT_ENABLED = false;
|
|
2376
2370
|
var VIDEO_SALE_RULE = { appProductId: (id2) => id2, productType: "NON_CONSUMABLE" };
|
|
2377
2371
|
function appleSaleRules(options = {}) {
|
|
2378
2372
|
return {
|
|
2379
2373
|
onlineProgram: ONLINE_PROGRAM_SALE_RULE,
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2374
|
+
storesProduct: STORES_PRODUCT_SALE_RULE,
|
|
2375
|
+
pricingPlan: PRICING_PLAN_SALE_RULE,
|
|
2376
|
+
bookingsService: ATTENDANCE_SALE_RULE,
|
|
2377
|
+
eventsTicket: ATTENDANCE_SALE_RULE,
|
|
2384
2378
|
...options.videosAppleSalesEnabled ?? VIDEOS_APPLE_SALES_ENABLED ? { wixVideo: VIDEO_SALE_RULE } : {}
|
|
2385
2379
|
};
|
|
2386
2380
|
}
|
|
2387
2381
|
var APPLE_SALE_RULES = appleSaleRules();
|
|
2388
2382
|
var APPLE_PROVISIONING_RULES = {
|
|
2389
2383
|
...APPLE_SALE_RULES,
|
|
2390
|
-
bookingsService: ATTENDANCE_SALE_RULE,
|
|
2391
|
-
eventsTicket: ATTENDANCE_SALE_RULE,
|
|
2392
2384
|
wixVideo: VIDEO_SALE_RULE
|
|
2393
2385
|
};
|
|
2394
2386
|
var APPLE_PRICING_RULES = { ...APPLE_SALE_RULES, wixVideo: VIDEO_SALE_RULE };
|
|
@@ -3136,131 +3128,6 @@ var COMPLETE_PAYMENT_CODES = [
|
|
|
3136
3128
|
];
|
|
3137
3129
|
var GET_PAYMENT_CODES = ["NOT_FOUND"];
|
|
3138
3130
|
|
|
3139
|
-
// ../../core/sdk/iap/src/attendance-classifier.ts
|
|
3140
|
-
function classifyForApple(item, currency) {
|
|
3141
|
-
if (item.hidden !== false || item.attendance === "hybrid") return "decide";
|
|
3142
|
-
if (item.kind === "bookingsService") return bookingRoute(item, currency);
|
|
3143
|
-
return ticketRoute(item, currency);
|
|
3144
|
-
}
|
|
3145
|
-
var ADDRESSLESS_CUSTOM = "CUSTOM_WITHOUT_ADDRESS";
|
|
3146
|
-
var PHYSICAL_LOCATIONS = ["BUSINESS", "CUSTOMER", "CUSTOM", ADDRESSLESS_CUSTOM];
|
|
3147
|
-
function bookingRoute(item, currency) {
|
|
3148
|
-
if (item.onlineBooking !== true) return "decide";
|
|
3149
|
-
if (item.conferencing === false && item.locations?.length && item.locations.every((type) => PHYSICAL_LOCATIONS.includes(type))) {
|
|
3150
|
-
return item.attendance === "online" ? "decide" : "wixPayments";
|
|
3151
|
-
}
|
|
3152
|
-
if (item.conferencing !== true || item.attendance === "physical") return "decide";
|
|
3153
|
-
const addressed = item.locations?.filter((type) => type !== ADDRESSLESS_CUSTOM);
|
|
3154
|
-
if (item.attendance !== "online" && (!addressed || addressed.length > 0)) return "decide";
|
|
3155
|
-
if (item.type === "APPOINTMENT") {
|
|
3156
|
-
return item.capacity === 1 && item.maxParticipantsPerBooking === 1 ? "wixPayments" : "decide";
|
|
3157
|
-
}
|
|
3158
|
-
if (item.type !== "CLASS" && item.type !== "COURSE" || !item.capacity || item.capacity <= 1) return "decide";
|
|
3159
|
-
if (item.priceType === "NO_FEE" || zeroPrice(item.amount)) return "wixPayments";
|
|
3160
|
-
if (item.onlinePayment !== true || item.deposit !== false || item.priceType !== "FIXED") return "decide";
|
|
3161
|
-
return fixedPriceRoute(item, currency);
|
|
3162
|
-
}
|
|
3163
|
-
function ticketRoute(item, currency) {
|
|
3164
|
-
if (item.location === "VENUE") return item.attendance === "online" ? "decide" : "wixPayments";
|
|
3165
|
-
if (item.location !== "ONLINE" || item.attendance === "physical" || item.registration !== "TICKETING") return "decide";
|
|
3166
|
-
if (item.eventStatus !== "UPCOMING" && item.eventStatus !== "STARTED") return "decide";
|
|
3167
|
-
if (item.saleStatus !== "SALE_STARTED") return "decide";
|
|
3168
|
-
if (zeroPrice(item.amount)) return "wixPayments";
|
|
3169
|
-
return item.priceType === "STANDARD" ? fixedPriceRoute(item, currency) : "decide";
|
|
3170
|
-
}
|
|
3171
|
-
function fixedPriceRoute(item, currency) {
|
|
3172
|
-
const amount = item.amount;
|
|
3173
|
-
return typeof amount === "string" && /^\d+(?:\.\d+)?$/.test(amount) && Number.isFinite(Number(amount)) && Number(amount) > 0 && /^[A-Z]{3}$/.test(currency) && item.currency === currency ? "appleIap" : "decide";
|
|
3174
|
-
}
|
|
3175
|
-
function bookingAttendanceOf(raw) {
|
|
3176
|
-
const s2 = object3(raw);
|
|
3177
|
-
const payment = object3(s2.payment);
|
|
3178
|
-
const fixed = object3(payment.fixed);
|
|
3179
|
-
const price = object3(fixed.price);
|
|
3180
|
-
const options = object3(payment.options);
|
|
3181
|
-
const policy = object3(object3(s2.bookingPolicy).participantsPolicy);
|
|
3182
|
-
return {
|
|
3183
|
-
kind: "bookingsService",
|
|
3184
|
-
type: text(s2.type),
|
|
3185
|
-
capacity: numeric(s2.defaultCapacity),
|
|
3186
|
-
maxParticipantsPerBooking: policy.enabled === true ? numeric(policy.maxParticipantsPerBooking) : void 0,
|
|
3187
|
-
hidden: boolean(s2.hidden),
|
|
3188
|
-
conferencing: boolean(object3(s2.conferencing).enabled),
|
|
3189
|
-
locations: Array.isArray(s2.locations) ? s2.locations.map(locationType) : void 0,
|
|
3190
|
-
onlineBooking: boolean(object3(s2.onlineBooking).enabled),
|
|
3191
|
-
onlinePayment: boolean(options.online),
|
|
3192
|
-
deposit: options.deposit === true || fixed.deposit !== void 0,
|
|
3193
|
-
priceType: text(payment.rateType),
|
|
3194
|
-
amount: text(price.value),
|
|
3195
|
-
currency: text(price.currency)
|
|
3196
|
-
};
|
|
3197
|
-
}
|
|
3198
|
-
function locationType(raw) {
|
|
3199
|
-
const location = object3(raw);
|
|
3200
|
-
const type = text(location.type) ?? "UNKNOWN";
|
|
3201
|
-
const addresses = [object3(location.custom).address, location.calculatedAddress].map(object3);
|
|
3202
|
-
return type === "CUSTOM" && addresses.every(describesNoPlace) ? ADDRESSLESS_CUSTOM : type;
|
|
3203
|
-
}
|
|
3204
|
-
function describesNoPlace(address) {
|
|
3205
|
-
const parts = ["country", "subdivision", "city", "postalCode", "addressLine2", "streetAddress", "location"];
|
|
3206
|
-
if (parts.some((key) => address[key] !== void 0 && address[key] !== "")) return false;
|
|
3207
|
-
return [address.addressLine, address.formattedAddress].every((value) => {
|
|
3208
|
-
if (value !== void 0 && typeof value !== "string") return false;
|
|
3209
|
-
const description = value?.trim() ?? "";
|
|
3210
|
-
return description === "" || ONLINE_LABEL.test(description);
|
|
3211
|
-
});
|
|
3212
|
-
}
|
|
3213
|
-
var ONLINE_LABEL = /^(online|virtual)(\s+(class|classes|classroom|course|session|sessions|meeting|lesson|training|workshop|event))?$/i;
|
|
3214
|
-
function ticketAttendanceOf(event, definition) {
|
|
3215
|
-
const e = object3(event);
|
|
3216
|
-
const t = object3(definition);
|
|
3217
|
-
const pricing = object3(t.pricingMethod);
|
|
3218
|
-
const price = object3(pricing.fixedPrice);
|
|
3219
|
-
const registration = object3(e.registration);
|
|
3220
|
-
const type = text(registration.type) ?? text(registration.initialType) ?? text(e.eventType);
|
|
3221
|
-
const status = text(e.status) ?? text(e.eventStatus);
|
|
3222
|
-
return {
|
|
3223
|
-
kind: "eventsTicket",
|
|
3224
|
-
location: text(object3(e.location).type),
|
|
3225
|
-
registration: type === "TICKETS" || type === "RSVP_AND_TICKETS" ? "TICKETING" : type,
|
|
3226
|
-
eventStatus: status === "SCHEDULED" ? "UPCOMING" : status,
|
|
3227
|
-
saleStatus: text(t.saleStatus),
|
|
3228
|
-
hidden: boolean(t.hidden),
|
|
3229
|
-
priceType: text(pricing.pricingType),
|
|
3230
|
-
amount: text(price.value),
|
|
3231
|
-
currency: text(price.currency)
|
|
3232
|
-
};
|
|
3233
|
-
}
|
|
3234
|
-
function availableTicketAttendanceOf(event, ticket) {
|
|
3235
|
-
const e = object3(event);
|
|
3236
|
-
const t = object3(ticket);
|
|
3237
|
-
const v3 = t.pricingMethod !== void 0;
|
|
3238
|
-
const pricing = object3(v3 ? t.pricingMethod : t.pricing);
|
|
3239
|
-
const fixed = object3(pricing.fixedPrice);
|
|
3240
|
-
const amount = v3 ? fixed.value : fixed.amount;
|
|
3241
|
-
const price = object3(t.price);
|
|
3242
|
-
const listed = v3 ? t.hidden === false && t.state === void 0 : Array.isArray(t.state) && t.state.length === 0;
|
|
3243
|
-
const visible = listed && object3(t.dashboard).hidden !== true && typeof t.id === "string" && t.id.length > 0 && typeof e.id === "string" && e.id.length > 0 && t.eventId === e.id;
|
|
3244
|
-
const fixedPrice = t.free === false && (!v3 || pricing.free === false) && pricing.pricingType === "STANDARD" && sameTicketAmount(amount, price.amount) && fixed.currency === price.currency;
|
|
3245
|
-
return ticketAttendanceOf(e, {
|
|
3246
|
-
hidden: visible ? false : void 0,
|
|
3247
|
-
saleStatus: t.saleStatus,
|
|
3248
|
-
pricingMethod: { pricingType: fixedPrice ? "STANDARD" : void 0, fixedPrice: { value: amount, currency: fixed.currency } }
|
|
3249
|
-
});
|
|
3250
|
-
}
|
|
3251
|
-
function sameTicketAmount(left, right) {
|
|
3252
|
-
const valid = (value) => typeof value === "string" && /^\d+(?:\.\d+)?$/.test(value);
|
|
3253
|
-
const normalized = (value) => value.replace(/^0+(?=\d)/, "").replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
3254
|
-
return valid(left) && valid(right) && normalized(left) === normalized(right);
|
|
3255
|
-
}
|
|
3256
|
-
function object3(value) {
|
|
3257
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
3258
|
-
}
|
|
3259
|
-
var text = (value) => typeof value === "string" ? value : void 0;
|
|
3260
|
-
var numeric = (value) => typeof value === "number" ? value : void 0;
|
|
3261
|
-
var boolean = (value) => typeof value === "boolean" ? value : void 0;
|
|
3262
|
-
var zeroPrice = (value) => typeof value === "string" && /^0+(?:\.0+)?$/.test(value);
|
|
3263
|
-
|
|
3264
3131
|
// ../../core/sdk/iap/src/index.ts
|
|
3265
3132
|
async function storefrontCountryCode() {
|
|
3266
3133
|
try {
|
|
@@ -3632,11 +3499,11 @@ function partitionKey(key) {
|
|
|
3632
3499
|
return `${PREFIX}.${key.purchasesAppId}.${key.siteId}.${memberKey(key.memberId)}`;
|
|
3633
3500
|
}
|
|
3634
3501
|
function memberKey(memberId) {
|
|
3635
|
-
const
|
|
3502
|
+
const text2 = memberId.toLowerCase();
|
|
3636
3503
|
let h1 = 3735928559;
|
|
3637
3504
|
let h2 = 1103547991;
|
|
3638
|
-
for (let i = 0; i <
|
|
3639
|
-
const code =
|
|
3505
|
+
for (let i = 0; i < text2.length; i++) {
|
|
3506
|
+
const code = text2.charCodeAt(i);
|
|
3640
3507
|
h1 = Math.imul(h1 ^ code, 2654435761);
|
|
3641
3508
|
h2 = Math.imul(h2 ^ code, 1597334677);
|
|
3642
3509
|
}
|
|
@@ -3719,10 +3586,10 @@ function isLiveHost(bridge) {
|
|
|
3719
3586
|
}
|
|
3720
3587
|
function refusalOf(error) {
|
|
3721
3588
|
const message = error?.message;
|
|
3722
|
-
const
|
|
3723
|
-
if (BRIDGE_REFUSAL2.test(
|
|
3724
|
-
if (PRINCIPAL_CHANGED2.test(
|
|
3725
|
-
const http = /^HTTP (\d{3})(?: \[([^\]]+)\])?:/.exec(
|
|
3589
|
+
const text2 = typeof message === "string" ? message : "";
|
|
3590
|
+
if (BRIDGE_REFUSAL2.test(text2)) return { status: "notEnabled" };
|
|
3591
|
+
if (PRINCIPAL_CHANGED2.test(text2)) return SESSION_CHANGED;
|
|
3592
|
+
const http = /^HTTP (\d{3})(?: \[([^\]]+)\])?:/.exec(text2);
|
|
3726
3593
|
if (!http) return { status: "unavailable" };
|
|
3727
3594
|
return httpRefusal(Number(http[1]), http[2] ?? "");
|
|
3728
3595
|
}
|
|
@@ -4162,7 +4029,7 @@ function createWixOrderBackend(deps) {
|
|
|
4162
4029
|
if (ref?.stage !== "started" || !ref.paymentId) return;
|
|
4163
4030
|
const adapter = adapterFor(ref.kind);
|
|
4164
4031
|
if (!adapter || !paidByItem(adapter)) return;
|
|
4165
|
-
if (
|
|
4032
|
+
if (adapter.reusesPayment) {
|
|
4166
4033
|
const current = refAt(partition, catalogRef);
|
|
4167
4034
|
if (current?.stage === "started" && current.paymentId === ref.paymentId && current.updatedAt === ref.updatedAt) handBackToGuard(partition, adapter, ref);
|
|
4168
4035
|
return;
|
|
@@ -4480,7 +4347,7 @@ function enabledCheckout(deps) {
|
|
|
4480
4347
|
if (!isCurrent(session)) return;
|
|
4481
4348
|
if (ref.stage === "needsSupport") setPayment(ref.key, "needsSupport");
|
|
4482
4349
|
if (ref.stage === "fulfilled" && !options.dueOnly) {
|
|
4483
|
-
const access = await
|
|
4350
|
+
const access = await accessOf(session, ref);
|
|
4484
4351
|
if (!isCurrent(session)) return;
|
|
4485
4352
|
if (access === "granted") setPayment(ref.key, "granted");
|
|
4486
4353
|
else if (access === "none") payments.delete(ref.key);
|
|
@@ -4540,7 +4407,7 @@ function enabledCheckout(deps) {
|
|
|
4540
4407
|
if (isFinalRefusal(payment.status)) return markNeedsSupport(partition, ref);
|
|
4541
4408
|
if (payment.status !== "approved") return backOff(partition, ref, false);
|
|
4542
4409
|
if (!ref.kind) return settleUnassociated(partition, ref);
|
|
4543
|
-
const access = await
|
|
4410
|
+
const access = await accessOf(session, ref);
|
|
4544
4411
|
if (!isCurrent(session)) return;
|
|
4545
4412
|
if (access === "granted") return grant(partition, ref);
|
|
4546
4413
|
backOff(partition, ref, access === "none");
|
|
@@ -4556,7 +4423,7 @@ function enabledCheckout(deps) {
|
|
|
4556
4423
|
partition.remove(ref.key);
|
|
4557
4424
|
setPayment(ref.key, "accessUnknown");
|
|
4558
4425
|
}
|
|
4559
|
-
async function
|
|
4426
|
+
async function accessOf(session, ref) {
|
|
4560
4427
|
const adapter = deps.adapters.find((candidate) => candidate.kind === ref.kind);
|
|
4561
4428
|
if (!adapter || !ref.verticalRef) return "unavailable";
|
|
4562
4429
|
return adapter.readAccess(ref.verticalRef, bindBridge(session, deps.session, bridge));
|
|
@@ -5053,20 +4920,6 @@ function isNonEmpty3(value) {
|
|
|
5053
4920
|
return typeof value === "string" && value.length > 0;
|
|
5054
4921
|
}
|
|
5055
4922
|
var UNSUPPORTED = { eligible: false, reason: "unsupportedItem" };
|
|
5056
|
-
var ORDER_REFUSED = { status: "refused", reason: "orderRefused" };
|
|
5057
|
-
var ORDER_CLOSED = { status: "refused", reason: "orderClosed" };
|
|
5058
|
-
var GRANTED = { status: "granted" };
|
|
5059
|
-
async function ecomOrderAccess(orderId, bridge) {
|
|
5060
|
-
if (!isNonEmpty3(orderId)) return "unavailable";
|
|
5061
|
-
const answer = await bridge.call("GET", `/ecom/v1/orders/${encodeURIComponent(orderId)}`);
|
|
5062
|
-
if (isRefusal(answer)) return accessRefused(answer);
|
|
5063
|
-
const status = String(bodyObject(answer, "order")?.paymentStatus);
|
|
5064
|
-
if (status === "PAID") return "granted";
|
|
5065
|
-
if (ECOM_PAYMENT_UNDER_WAY.has(status)) return "pending";
|
|
5066
|
-
return ECOM_NO_ACCESS.has(status) ? "none" : "unavailable";
|
|
5067
|
-
}
|
|
5068
|
-
var ECOM_PAYMENT_UNDER_WAY = /* @__PURE__ */ new Set(["NOT_PAID", "PENDING", "PENDING_MERCHANT", "PARTIALLY_PAID"]);
|
|
5069
|
-
var ECOM_NO_ACCESS = /* @__PURE__ */ new Set(["FULLY_REFUNDED", "PARTIALLY_REFUNDED", "CANCELED", "DECLINED", "VOIDED"]);
|
|
5070
4923
|
|
|
5071
4924
|
// ../../stdlib/flows/iap-checkout/src/iap-verticals/pricing-plans.ts
|
|
5072
4925
|
var KIND = "pricingPlan";
|
|
@@ -5109,445 +4962,8 @@ async function planAccess(planId, bridge) {
|
|
|
5109
4962
|
}
|
|
5110
4963
|
}
|
|
5111
4964
|
|
|
5112
|
-
// ../../stdlib/flows/iap-checkout/src/iap-verticals/pricing-plans-orders.ts
|
|
5113
|
-
var KIND2 = "pricingPlan";
|
|
5114
|
-
var CHECKOUT = "/pricing-plans/v2/checkout/orders";
|
|
5115
|
-
var MEMBER_ORDERS2 = "/pricing-plans/v2/member/orders";
|
|
5116
|
-
var pricingPlanClientOrders = {
|
|
5117
|
-
kind: KIND2,
|
|
5118
|
-
eligibility: (item) => singleUnitOf(KIND2, item),
|
|
5119
|
-
openOrder,
|
|
5120
|
-
reopenOrder,
|
|
5121
|
-
readAccess,
|
|
5122
|
-
currentAccess
|
|
5123
|
-
};
|
|
5124
|
-
async function currentAccess(item, bridge) {
|
|
5125
|
-
let pending = false;
|
|
5126
|
-
const pages = /* @__PURE__ */ new Set();
|
|
5127
|
-
for (let offset = 0; ; offset += 50) {
|
|
5128
|
-
const answer = await bridge.call("GET", `${MEMBER_ORDERS2}?orderStatuses=ACTIVE&orderStatuses=PENDING&orderStatuses=DRAFT&limit=50&offset=${offset}`);
|
|
5129
|
-
if (isRefusal(answer)) return accessRefused(answer);
|
|
5130
|
-
const orders = answer.body?.orders;
|
|
5131
|
-
if (!Array.isArray(orders)) return "unavailable";
|
|
5132
|
-
const page = JSON.stringify(orders.map((order) => [order.id, order.planId, order.status]));
|
|
5133
|
-
if (orders.length === 50 && pages.has(page)) return "unavailable";
|
|
5134
|
-
pages.add(page);
|
|
5135
|
-
const selected = orders.filter((order) => order.planId === item.reference.id);
|
|
5136
|
-
if (selected.some((order) => order.status === "ACTIVE")) return "granted";
|
|
5137
|
-
pending || (pending = selected.some((order) => order.status === "PENDING" || order.status === "DRAFT"));
|
|
5138
|
-
if (orders.length < 50) return pending ? "pending" : "none";
|
|
5139
|
-
}
|
|
5140
|
-
}
|
|
5141
|
-
async function openOrder(item, bridge) {
|
|
5142
|
-
const planId = item.reference.id;
|
|
5143
|
-
const preview = await bridge.call("POST", `${CHECKOUT}/preview-online`, { planId });
|
|
5144
|
-
if (isRefusal(preview)) return attemptRefused(preview);
|
|
5145
|
-
if (!isOneTimeUnlimited(bodyObject(preview, "order"))) return { status: "refused", reason: "unsupportedItem" };
|
|
5146
|
-
const created = await bridge.call("POST", `${CHECKOUT}/online`, { planId });
|
|
5147
|
-
if (isRefusal(created)) return attemptRefused(created);
|
|
5148
|
-
return orderOf(bodyObject(created, "order"), planId);
|
|
5149
|
-
}
|
|
5150
|
-
async function reopenOrder(order, bridge) {
|
|
5151
|
-
const read2 = await memberOrder(order.verticalRef.orderId, bridge);
|
|
5152
|
-
if ("attempt" in read2) return read2.attempt;
|
|
5153
|
-
const attempt4 = orderOf(read2.order, order.verticalRef.planId ?? "");
|
|
5154
|
-
return attempt4.status === "open" && attempt4.cashierOrderId !== order.cashierOrderId ? ORDER_CLOSED : attempt4;
|
|
5155
|
-
}
|
|
5156
|
-
async function readAccess(verticalRef, bridge) {
|
|
5157
|
-
if (!isNonEmpty3(verticalRef.orderId)) return isNonEmpty3(verticalRef.planId) ? planAccess(verticalRef.planId, bridge) : "unavailable";
|
|
5158
|
-
const answer = await bridge.call("GET", `${MEMBER_ORDERS2}/${encodeURIComponent(verticalRef.orderId)}`);
|
|
5159
|
-
if (isRefusal(answer)) return accessRefused(answer);
|
|
5160
|
-
const order = bodyObject(answer, "order");
|
|
5161
|
-
return order ? accessOf(order) : "unavailable";
|
|
5162
|
-
}
|
|
5163
|
-
function accessOf(order) {
|
|
5164
|
-
if (order.status === "ACTIVE") return "granted";
|
|
5165
|
-
if (order.status === "PENDING") return "pending";
|
|
5166
|
-
if (order.status === "DRAFT") return "pending";
|
|
5167
|
-
return NO_ACCESS.has(String(order.status)) ? "none" : "unavailable";
|
|
5168
|
-
}
|
|
5169
|
-
var NO_ACCESS = /* @__PURE__ */ new Set(["CANCELED", "ENDED", "PAUSED"]);
|
|
5170
|
-
function orderOf(order, planId) {
|
|
5171
|
-
if (!order || !isNonEmpty3(order.id)) return ORDER_REFUSED;
|
|
5172
|
-
if (accessOf(order) === "granted") return GRANTED;
|
|
5173
|
-
if (order.status === "PENDING") return { status: "refused", reason: "paymentInProgress" };
|
|
5174
|
-
if (order.status !== "DRAFT") return ORDER_CLOSED;
|
|
5175
|
-
if (!isNonEmpty3(order.wixPayOrderId)) return ORDER_REFUSED;
|
|
5176
|
-
return { status: "open", cashierOrderId: order.wixPayOrderId, verticalRef: { orderId: order.id, planId } };
|
|
5177
|
-
}
|
|
5178
|
-
async function memberOrder(orderId, bridge) {
|
|
5179
|
-
if (!isNonEmpty3(orderId)) return { attempt: ORDER_CLOSED };
|
|
5180
|
-
const answer = await bridge.call("GET", `${MEMBER_ORDERS2}/${encodeURIComponent(orderId)}`);
|
|
5181
|
-
if (isRefusal(answer)) return { attempt: answer.status === "http" && answer.httpStatus === 404 ? ORDER_CLOSED : attemptRefused(answer) };
|
|
5182
|
-
return { order: bodyObject(answer, "order") };
|
|
5183
|
-
}
|
|
5184
|
-
function isOneTimeUnlimited(order) {
|
|
5185
|
-
const pricing = order?.pricing;
|
|
5186
|
-
return pricing?.singlePaymentUnlimited === true;
|
|
5187
|
-
}
|
|
5188
|
-
|
|
5189
|
-
// ../../stdlib/flows/iap-checkout/src/iap-verticals/attendance.ts
|
|
5190
|
-
var BOOKING = "bookingsService";
|
|
5191
|
-
var TICKET = "eventsTicket";
|
|
5192
|
-
var NOT_ENABLED = { status: "refused", reason: "notEnabled" };
|
|
5193
|
-
var WIX_BOOKINGS_APP = "13d21c63-b5ec-5912-8397-c3a5ddb27a97";
|
|
5194
|
-
var CHANGED = { status: "refused", reason: "productChanged" };
|
|
5195
|
-
var WIX_EVENTS_APP = "140603ad-af8d-84a5-2c80-a0f60cb47351";
|
|
5196
|
-
var RELEASE_MARGIN_MS = 3e5;
|
|
5197
|
-
var PAYMENT_TAKEN = ["PAID", "PARTIALLY_PAID", "EXEMPT", "REFUNDED"];
|
|
5198
|
-
var HAS_OFFSET = /(?:Z|[+-]\d{2}:?\d{2})$/i;
|
|
5199
|
-
var LATEST_ZONE_MS = 432e5;
|
|
5200
|
-
function attendanceOrdersWith(options) {
|
|
5201
|
-
return {
|
|
5202
|
-
bookingOrders: {
|
|
5203
|
-
kind: BOOKING,
|
|
5204
|
-
repeatable: true,
|
|
5205
|
-
eligibility: (item) => eligible(item, BOOKING, options.bookingsEnabled),
|
|
5206
|
-
itemPayment: (item, bridge, beforeCreate, afterCreate) => options.bookingsEnabled ? bookingPayment(item, bridge, beforeCreate, afterCreate) : NOT_ENABLED,
|
|
5207
|
-
resolveOpening: resolveBookingOpening,
|
|
5208
|
-
readAccess: bookingAccess
|
|
5209
|
-
},
|
|
5210
|
-
eventTicketOrders: {
|
|
5211
|
-
kind: TICKET,
|
|
5212
|
-
repeatable: true,
|
|
5213
|
-
eligibility: (item) => eligible(item, TICKET, options.eventsEnabled),
|
|
5214
|
-
itemPayment: ticketPayment,
|
|
5215
|
-
readAccess: ticketAccess
|
|
5216
|
-
}
|
|
5217
|
-
};
|
|
5218
|
-
}
|
|
5219
|
-
var { bookingOrders: bookingItemPayments, eventTicketOrders: eventTicketItemPayments } = /* @__PURE__ */ attendanceOrdersWith({ bookingsEnabled: BOOKINGS_APPLE_SALES_ENABLED, eventsEnabled: EVENTS_APPLE_SALES_ENABLED });
|
|
5220
|
-
function eligible(item, kind, enabled) {
|
|
5221
|
-
if (!enabled) return { eligible: false, reason: "notEnabled" };
|
|
5222
|
-
if (!singleUnitOf(kind, item).eligible || !isNonEmpty3(item.attemptId) || !item.attendance) return UNSUPPORTED;
|
|
5223
|
-
if (kind === TICKET) return isNonEmpty3(item.attendance.ticket?.eventId) ? { eligible: true } : UNSUPPORTED;
|
|
5224
|
-
return item.attendance.booking ? { eligible: true } : UNSUPPORTED;
|
|
5225
|
-
}
|
|
5226
|
-
async function bookingPayment(item, bridge, beforeCreate, afterCreate) {
|
|
5227
|
-
if (!eligible(item, BOOKING, true).eligible) return notCreated(ORDER_REFUSED);
|
|
5228
|
-
const selected = item.attendance.booking;
|
|
5229
|
-
if (selected.slot.serviceId !== item.reference.id || !isNonEmpty3(selected.slot.startDate) || !isNonEmpty3(selected.slot.endDate)) return notCreated(ORDER_REFUSED);
|
|
5230
|
-
const read2 = await bridge.call("GET", `/bookings/v2/services/${encodeURIComponent(item.reference.id)}`);
|
|
5231
|
-
if (isRefusal(read2)) return notCreated(attemptRefused(read2));
|
|
5232
|
-
const service = bodyObject(read2, "service");
|
|
5233
|
-
const metadata = bookingAttendanceOf(service);
|
|
5234
|
-
if (classifyForApple(metadata, item.attendance.currency) !== "appleIap" || !samePrice({ amount: metadata.amount, currency: metadata.currency }, item)) return notCreated(CHANGED);
|
|
5235
|
-
if (isObject7(service?.onlineBooking) && service.onlineBooking.requireManualApproval === true) return notCreated({ status: "refused", reason: "approvalRequired" });
|
|
5236
|
-
const availability2 = await bridge.call("POST", "/bookings/v1/availability/query", { query: { filter: { serviceId: [item.reference.id], startDate: selected.slot.startDate, endDate: selected.slot.endDate, bookable: true } } });
|
|
5237
|
-
if (isRefusal(availability2)) return notCreated(attemptRefused(availability2));
|
|
5238
|
-
const entries = isObject7(availability2.body) ? availability2.body.availabilityEntries : void 0;
|
|
5239
|
-
if (!Array.isArray(entries) || !entries.some((entry) => isObject7(entry) && entry.bookable === true && matchesSlot(entry.slot, selected.slot))) return notCreated(CHANGED);
|
|
5240
|
-
if (beforeCreate && !beforeCreate(slotGuard(selected.slot))) return notCreated({ status: "refused", reason: "storageUnavailable" });
|
|
5241
|
-
const created = await bridge.call("POST", "/bookings/v2/bookings", { booking: { bookedEntity: { slot: selected.slot }, contactDetails: selected.contactDetails, totalParticipants: 1, selectedPaymentOption: "ONLINE", ...selected.formInfo ? { formInfo: selected.formInfo } : {} } });
|
|
5242
|
-
if (isRefusal(created)) return creationRefused(created);
|
|
5243
|
-
const bookingId = bodyObject(created, "booking")?.id;
|
|
5244
|
-
if (!isNonEmpty3(bookingId)) return ORDER_REFUSED;
|
|
5245
|
-
if (afterCreate?.({ verticalRef: { bookingId } }) === false) return { status: "unavailable" };
|
|
5246
|
-
const serviceId = item.reference.id;
|
|
5247
|
-
return {
|
|
5248
|
-
catalogItem: { catalogItemId: serviceId, catalogAppId: WIX_BOOKINGS_APP, options: { bookingId } },
|
|
5249
|
-
verticalRefOf: ({ ecomOrderId }) => ecomOrderId ? { serviceId, bookingId, orderId: ecomOrderId } : null
|
|
5250
|
-
};
|
|
5251
|
-
}
|
|
5252
|
-
function slotGuard(slot) {
|
|
5253
|
-
const verticalRef = {};
|
|
5254
|
-
for (const key of ["sessionId", "startDate"]) if (isNonEmpty3(slot[key])) verticalRef[key] = slot[key];
|
|
5255
|
-
const ends = latestInstant(String(slot.endDate));
|
|
5256
|
-
return Number.isFinite(ends) ? { verticalRef, releaseAt: ends + RELEASE_MARGIN_MS } : { verticalRef };
|
|
5257
|
-
}
|
|
5258
|
-
function latestInstant(value) {
|
|
5259
|
-
if (HAS_OFFSET.test(value)) return Date.parse(value);
|
|
5260
|
-
return Date.parse(`${value}Z`) + LATEST_ZONE_MS;
|
|
5261
|
-
}
|
|
5262
|
-
async function resolveBookingOpening(guard, item, bridge, options) {
|
|
5263
|
-
const scope = sameSlot(guard.verticalRef, item?.attendance?.booking?.slot) ? "held" : "unrelated";
|
|
5264
|
-
const bookingId = guard.verticalRef?.bookingId;
|
|
5265
|
-
if (!bookingId || !options.settled) return scope;
|
|
5266
|
-
const released2 = await releaseBooking(bookingId, bridge, options.claim);
|
|
5267
|
-
return released2 === "held" || released2 === "unavailable" && scope === "unrelated" ? scope : released2;
|
|
5268
|
-
}
|
|
5269
|
-
async function releaseBooking(bookingId, bridge, claim) {
|
|
5270
|
-
const read2 = await bridge.call("POST", "/bookings/v2/bookings/query", { query: { filter: { id: { $eq: bookingId } } } });
|
|
5271
|
-
if (isRefusal(read2)) return read2.status === "http" && read2.httpStatus === 404 ? "released" : openingRefused(read2);
|
|
5272
|
-
const rows = isObject7(read2.body) ? read2.body.bookings : void 0;
|
|
5273
|
-
const booking = Array.isArray(rows) ? rows.find((b) => isObject7(b) && b.id === bookingId) : void 0;
|
|
5274
|
-
if (!isObject7(booking)) return "held";
|
|
5275
|
-
if (["CANCELED", "CANCELLED", "DECLINED"].includes(String(booking.status)) || PAYMENT_TAKEN.includes(String(booking.paymentStatus))) return "released";
|
|
5276
|
-
if (booking.status !== "CREATED" || !claim()) return "held";
|
|
5277
|
-
const cancelled = await bridge.call("POST", `/bookings/v2/bookings/${encodeURIComponent(bookingId)}/cancel`, { participantNotification: { notifyParticipants: false }, revision: booking.revision });
|
|
5278
|
-
return isRefusal(cancelled) ? openingRefused(cancelled) : "released";
|
|
5279
|
-
}
|
|
5280
|
-
function openingRefused(refusal) {
|
|
5281
|
-
if (refusal.status === "sessionChanged") return "sessionChanged";
|
|
5282
|
-
return refusal.status === "unavailable" ? "unavailable" : "held";
|
|
5283
|
-
}
|
|
5284
|
-
function sameSlot(guarded, slot) {
|
|
5285
|
-
if (!guarded || !slot) return true;
|
|
5286
|
-
return guarded.sessionId === slot.sessionId && Date.parse(guarded.startDate ?? "") === Date.parse(String(slot.startDate));
|
|
5287
|
-
}
|
|
5288
|
-
async function bookingAccess(ref, bridge) {
|
|
5289
|
-
if (!ref.bookingId || !ref.orderId) return "unavailable";
|
|
5290
|
-
const order = await bridge.call("GET", `/ecom/v1/orders/${encodeURIComponent(ref.orderId)}`);
|
|
5291
|
-
if (isRefusal(order)) return accessRefused(order);
|
|
5292
|
-
const payment = bodyObject(order, "order")?.paymentStatus;
|
|
5293
|
-
if (payment === "FULLY_REFUNDED" || payment === "PARTIALLY_REFUNDED") return "none";
|
|
5294
|
-
const read2 = await bridge.call("POST", "/bookings/v2/bookings/query", { query: { filter: { id: { $eq: ref.bookingId } } } });
|
|
5295
|
-
if (isRefusal(read2)) return accessRefused(read2);
|
|
5296
|
-
const rows = isObject7(read2.body) ? read2.body.bookings : void 0;
|
|
5297
|
-
const booking = Array.isArray(rows) ? rows.find((b) => isObject7(b) && b.id === ref.bookingId) : void 0;
|
|
5298
|
-
if (!isObject7(booking)) return "unavailable";
|
|
5299
|
-
if (booking.status === "CANCELED" || booking.status === "CANCELLED" || booking.status === "DECLINED") return "none";
|
|
5300
|
-
return payment === "PAID" && booking.status === "CONFIRMED" && booking.paymentStatus === "PAID" ? "granted" : "pending";
|
|
5301
|
-
}
|
|
5302
|
-
async function ticketAccess(ref, bridge) {
|
|
5303
|
-
if (isNonEmpty3(ref.orderId)) return ecomOrderAccess(ref.orderId, bridge);
|
|
5304
|
-
if (!ref.eventId || !ref.orderNumber || !ref.ticketDefinitionId) return "unavailable";
|
|
5305
|
-
const read2 = await bridge.call("GET", `/events/v1/events/${encodeURIComponent(ref.eventId)}/orders/${encodeURIComponent(ref.orderNumber)}?fieldset=DETAILS&fieldset=TICKETS`);
|
|
5306
|
-
if (isRefusal(read2)) return accessRefused(read2);
|
|
5307
|
-
const order = bodyObject(read2, "order");
|
|
5308
|
-
if (order?.status === "CANCELED" || order?.status === "CANCELLED" || order?.status === "REFUNDED") return "none";
|
|
5309
|
-
const issued = Array.isArray(order?.tickets) && order.tickets.some((t) => isObject7(t) && isNonEmpty3(t.ticketNumber) && t.orderStatus === "PAID" && t.ticketDefinitionId === ref.ticketDefinitionId);
|
|
5310
|
-
return order?.status === "PAID" && issued ? "granted" : order ? "pending" : "unavailable";
|
|
5311
|
-
}
|
|
5312
|
-
function ticketPayment(item) {
|
|
5313
|
-
const eventId = item.attendance.ticket.eventId;
|
|
5314
|
-
const ticketDefinitionId = item.reference.id;
|
|
5315
|
-
return {
|
|
5316
|
-
catalogItem: { catalogItemId: ticketDefinitionId, catalogAppId: WIX_EVENTS_APP, options: { eventId } },
|
|
5317
|
-
// eCom checkout: the eCom order. Classic checkout (catalyst-server #24882): the Events order number.
|
|
5318
|
-
verticalRefOf: ({ ecomOrderId, eventsOrderNumber }) => {
|
|
5319
|
-
if (ecomOrderId) return { orderId: ecomOrderId, eventId, ticketDefinitionId };
|
|
5320
|
-
return eventsOrderNumber ? { orderNumber: eventsOrderNumber, eventId, ticketDefinitionId } : null;
|
|
5321
|
-
}
|
|
5322
|
-
};
|
|
5323
|
-
}
|
|
5324
|
-
function samePrice(value, item) {
|
|
5325
|
-
return isObject7(value) && value.currency === item.attendance?.currency && decimal(value.amount) !== null && decimal(value.amount) === decimal(item.attendance?.amount);
|
|
5326
|
-
}
|
|
5327
|
-
function decimal(value) {
|
|
5328
|
-
if (typeof value !== "string" || !/^\d+(?:\.\d+)?$/.test(value)) return null;
|
|
5329
|
-
return value.replace(/^0+(?=\d)/, "").replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
5330
|
-
}
|
|
5331
|
-
function matchesSlot(value, selected) {
|
|
5332
|
-
return isObject7(value) && ["serviceId", "sessionId"].every((key) => value[key] === selected[key]) && ["startDate", "endDate"].every((key) => typeof value[key] === "string" && Date.parse(value[key]) === Date.parse(String(selected[key])));
|
|
5333
|
-
}
|
|
5334
|
-
function creationRefused(refusal) {
|
|
5335
|
-
const attempt4 = attemptRefused(refusal);
|
|
5336
|
-
return refusal.status === "http" && [400, 401, 403, 404, 405, 409, 410, 415, 422].includes(refusal.httpStatus) ? notCreated(attempt4) : attempt4;
|
|
5337
|
-
}
|
|
5338
|
-
function notCreated(attempt4) {
|
|
5339
|
-
return { ...attempt4, noOrderCreated: true };
|
|
5340
|
-
}
|
|
5341
|
-
|
|
5342
|
-
// ../../stdlib/flows/iap-checkout/src/iap-verticals/attendance-orders.ts
|
|
5343
|
-
var BOOKING2 = "bookingsService";
|
|
5344
|
-
var TICKET2 = "eventsTicket";
|
|
5345
|
-
var NOT_ENABLED2 = { status: "refused", reason: "notEnabled" };
|
|
5346
|
-
var CHANGED2 = { status: "refused", reason: "productChanged" };
|
|
5347
|
-
var MINUTE_MS = 6e4;
|
|
5348
|
-
var RELEASE_MARGIN_MS2 = 3e5;
|
|
5349
|
-
var DEFAULT_RESERVATION_MINUTES = 60;
|
|
5350
|
-
var PAYMENT_TAKEN2 = ["PAID", "PARTIALLY_PAID", "EXEMPT", "REFUNDED"];
|
|
5351
|
-
var HAS_OFFSET2 = /(?:Z|[+-]\d{2}:?\d{2})$/i;
|
|
5352
|
-
var LATEST_ZONE_MS2 = 432e5;
|
|
5353
|
-
function attendanceClientOrdersWith(options) {
|
|
5354
|
-
const now = options.now ?? Date.now;
|
|
5355
|
-
return {
|
|
5356
|
-
bookingOrders: {
|
|
5357
|
-
kind: BOOKING2,
|
|
5358
|
-
repeatable: true,
|
|
5359
|
-
eligibility: (item) => eligible2(item, BOOKING2, options.bookingsEnabled),
|
|
5360
|
-
openOrder: (item, bridge, beforeCreate, afterCreate) => options.bookingsEnabled ? openBooking(item, bridge, beforeCreate, afterCreate) : Promise.resolve(NOT_ENABLED2),
|
|
5361
|
-
resolveOpening: resolveBookingOpening2,
|
|
5362
|
-
readAccess: bookingAccess2,
|
|
5363
|
-
reopenOrder: (order, bridge) => reopen(order, bridge, bookingAccess2)
|
|
5364
|
-
},
|
|
5365
|
-
eventTicketOrders: {
|
|
5366
|
-
kind: TICKET2,
|
|
5367
|
-
repeatable: true,
|
|
5368
|
-
eligibility: (item) => eligible2(item, TICKET2, options.eventsEnabled),
|
|
5369
|
-
openOrder: (item, bridge, beforeCreate, afterCreate) => options.eventsEnabled ? openTicket(item, bridge, now, beforeCreate, afterCreate) : Promise.resolve(NOT_ENABLED2),
|
|
5370
|
-
readAccess: ticketAccess2,
|
|
5371
|
-
reopenOrder: (order, bridge) => reopen(order, bridge, ticketAccess2, now)
|
|
5372
|
-
}
|
|
5373
|
-
};
|
|
5374
|
-
}
|
|
5375
|
-
var { bookingOrders: bookingClientOrders, eventTicketOrders: eventTicketClientOrders } = /* @__PURE__ */ attendanceClientOrdersWith({ bookingsEnabled: BOOKINGS_APPLE_SALES_ENABLED, eventsEnabled: EVENTS_APPLE_SALES_ENABLED });
|
|
5376
|
-
function eligible2(item, kind, enabled) {
|
|
5377
|
-
if (!enabled) return { eligible: false, reason: "notEnabled" };
|
|
5378
|
-
if (!singleUnitOf(kind, item).eligible || !isNonEmpty3(item.attemptId) || !item.attendance) return UNSUPPORTED;
|
|
5379
|
-
const selection = kind === BOOKING2 ? item.attendance.booking : item.attendance.ticket;
|
|
5380
|
-
return selection ? { eligible: true } : UNSUPPORTED;
|
|
5381
|
-
}
|
|
5382
|
-
async function openBooking(item, bridge, beforeCreate, afterCreate) {
|
|
5383
|
-
if (!eligible2(item, BOOKING2, true).eligible) return notCreated2(ORDER_REFUSED);
|
|
5384
|
-
const selected = item.attendance.booking;
|
|
5385
|
-
if (selected.slot.serviceId !== item.reference.id || !isNonEmpty3(selected.slot.startDate) || !isNonEmpty3(selected.slot.endDate)) return notCreated2(ORDER_REFUSED);
|
|
5386
|
-
const read2 = await bridge.call("GET", `/bookings/v2/services/${encodeURIComponent(item.reference.id)}`);
|
|
5387
|
-
if (isRefusal(read2)) return notCreated2(attemptRefused(read2));
|
|
5388
|
-
const service = bodyObject(read2, "service");
|
|
5389
|
-
const metadata = bookingAttendanceOf(service);
|
|
5390
|
-
if (classifyForApple(metadata, item.attendance.currency) !== "appleIap" || !samePrice2({ amount: metadata.amount, currency: metadata.currency }, item)) return notCreated2(CHANGED2);
|
|
5391
|
-
if (isObject7(service?.onlineBooking) && service.onlineBooking.requireManualApproval === true) return notCreated2({ status: "refused", reason: "approvalRequired" });
|
|
5392
|
-
const availability2 = await bridge.call("POST", "/bookings/v1/availability/query", { query: { filter: { serviceId: [item.reference.id], startDate: selected.slot.startDate, endDate: selected.slot.endDate, bookable: true } } });
|
|
5393
|
-
if (isRefusal(availability2)) return notCreated2(attemptRefused(availability2));
|
|
5394
|
-
const entries = isObject7(availability2.body) ? availability2.body.availabilityEntries : void 0;
|
|
5395
|
-
if (!Array.isArray(entries) || !entries.some((entry) => isObject7(entry) && entry.bookable === true && matchesSlot2(entry.slot, selected.slot))) return notCreated2(CHANGED2);
|
|
5396
|
-
if (beforeCreate && !beforeCreate(slotGuard2(selected.slot))) return notCreated2({ status: "refused", reason: "storageUnavailable" });
|
|
5397
|
-
const created = await bridge.call("POST", "/bookings/v2/bookings", { booking: { bookedEntity: { slot: selected.slot }, contactDetails: selected.contactDetails, totalParticipants: 1, selectedPaymentOption: "ONLINE", ...selected.formInfo ? { formInfo: selected.formInfo } : {} } });
|
|
5398
|
-
if (isRefusal(created)) return creationRefused2(created);
|
|
5399
|
-
const bookingId = bodyObject(created, "booking")?.id;
|
|
5400
|
-
if (!isNonEmpty3(bookingId)) return ORDER_REFUSED;
|
|
5401
|
-
if (afterCreate?.({ verticalRef: { bookingId } }) === false) return { status: "unavailable" };
|
|
5402
|
-
return bookingCheckout(item, bookingId, bridge);
|
|
5403
|
-
}
|
|
5404
|
-
function slotGuard2(slot) {
|
|
5405
|
-
const verticalRef = {};
|
|
5406
|
-
for (const key of ["sessionId", "startDate"]) if (isNonEmpty3(slot[key])) verticalRef[key] = slot[key];
|
|
5407
|
-
const ends = latestInstant2(String(slot.endDate));
|
|
5408
|
-
return Number.isFinite(ends) ? { verticalRef, releaseAt: ends + RELEASE_MARGIN_MS2 } : { verticalRef };
|
|
5409
|
-
}
|
|
5410
|
-
function latestInstant2(value) {
|
|
5411
|
-
if (HAS_OFFSET2.test(value)) return Date.parse(value);
|
|
5412
|
-
return Date.parse(`${value}Z`) + LATEST_ZONE_MS2;
|
|
5413
|
-
}
|
|
5414
|
-
async function resolveBookingOpening2(guard, item, bridge, options) {
|
|
5415
|
-
const scope = sameSlot2(guard.verticalRef, item?.attendance?.booking?.slot) ? "held" : "unrelated";
|
|
5416
|
-
const bookingId = guard.verticalRef?.bookingId;
|
|
5417
|
-
if (!bookingId || !options.settled) return scope;
|
|
5418
|
-
const released2 = await releaseBooking2(bookingId, bridge, options.claim);
|
|
5419
|
-
return released2 === "held" || released2 === "unavailable" && scope === "unrelated" ? scope : released2;
|
|
5420
|
-
}
|
|
5421
|
-
async function releaseBooking2(bookingId, bridge, claim) {
|
|
5422
|
-
const read2 = await bridge.call("POST", "/bookings/v2/bookings/query", { query: { filter: { id: { $eq: bookingId } } } });
|
|
5423
|
-
if (isRefusal(read2)) return read2.status === "http" && read2.httpStatus === 404 ? "released" : openingRefused2(read2);
|
|
5424
|
-
const rows = isObject7(read2.body) ? read2.body.bookings : void 0;
|
|
5425
|
-
const booking = Array.isArray(rows) ? rows.find((b) => isObject7(b) && b.id === bookingId) : void 0;
|
|
5426
|
-
if (!isObject7(booking)) return "held";
|
|
5427
|
-
if (["CANCELED", "CANCELLED", "DECLINED"].includes(String(booking.status)) || PAYMENT_TAKEN2.includes(String(booking.paymentStatus))) return "released";
|
|
5428
|
-
if (booking.status !== "CREATED" || !claim()) return "held";
|
|
5429
|
-
const cancelled = await bridge.call("POST", `/bookings/v2/bookings/${encodeURIComponent(bookingId)}/cancel`, { participantNotification: { notifyParticipants: false }, revision: booking.revision });
|
|
5430
|
-
return isRefusal(cancelled) ? openingRefused2(cancelled) : "released";
|
|
5431
|
-
}
|
|
5432
|
-
function openingRefused2(refusal) {
|
|
5433
|
-
if (refusal.status === "sessionChanged") return "sessionChanged";
|
|
5434
|
-
return refusal.status === "unavailable" ? "unavailable" : "held";
|
|
5435
|
-
}
|
|
5436
|
-
function sameSlot2(guarded, slot) {
|
|
5437
|
-
if (!guarded || !slot) return true;
|
|
5438
|
-
return guarded.sessionId === slot.sessionId && Date.parse(guarded.startDate ?? "") === Date.parse(String(slot.startDate));
|
|
5439
|
-
}
|
|
5440
|
-
async function bookingCheckout(item, bookingId, bridge) {
|
|
5441
|
-
const checkout = await bridge.call("POST", "/ecom/v1/checkouts", { lineItems: [{ quantity: 1, catalogReference: { appId: "13d21c63-b5ec-5912-8397-c3a5ddb27a97", catalogItemId: bookingId } }], channelType: "OTHER_PLATFORM" });
|
|
5442
|
-
if (isRefusal(checkout)) return attemptRefused(checkout);
|
|
5443
|
-
const entity = bodyObject(checkout, "checkout");
|
|
5444
|
-
const total = isObject7(entity?.priceSummary) ? entity.priceSummary.total : void 0;
|
|
5445
|
-
if (!isObject7(total) || !samePrice2({ amount: total.amount, currency: entity?.currency }, item)) return CHANGED2;
|
|
5446
|
-
if (!isNonEmpty3(entity?.id)) return ORDER_REFUSED;
|
|
5447
|
-
const placed = await bridge.call("POST", `/ecom/v1/checkouts/${encodeURIComponent(entity.id)}/create-order`, {});
|
|
5448
|
-
if (isRefusal(placed)) return attemptRefused(placed);
|
|
5449
|
-
const body = placed.body;
|
|
5450
|
-
if (!isObject7(body) || !isNonEmpty3(body.orderId) || !isNonEmpty3(body.paymentGatewayOrderId)) return ORDER_REFUSED;
|
|
5451
|
-
return { status: "open", cashierOrderId: body.paymentGatewayOrderId, verticalRef: { serviceId: item.reference.id, bookingId, orderId: body.orderId } };
|
|
5452
|
-
}
|
|
5453
|
-
async function bookingAccess2(ref, bridge) {
|
|
5454
|
-
if (!ref.bookingId || !ref.orderId) return "unavailable";
|
|
5455
|
-
const order = await bridge.call("GET", `/ecom/v1/orders/${encodeURIComponent(ref.orderId)}`);
|
|
5456
|
-
if (isRefusal(order)) return accessRefused(order);
|
|
5457
|
-
const payment = bodyObject(order, "order")?.paymentStatus;
|
|
5458
|
-
if (payment === "FULLY_REFUNDED" || payment === "PARTIALLY_REFUNDED") return "none";
|
|
5459
|
-
const read2 = await bridge.call("POST", "/bookings/v2/bookings/query", { query: { filter: { id: { $eq: ref.bookingId } } } });
|
|
5460
|
-
if (isRefusal(read2)) return accessRefused(read2);
|
|
5461
|
-
const rows = isObject7(read2.body) ? read2.body.bookings : void 0;
|
|
5462
|
-
const booking = Array.isArray(rows) ? rows.find((b) => isObject7(b) && b.id === ref.bookingId) : void 0;
|
|
5463
|
-
if (!isObject7(booking)) return "unavailable";
|
|
5464
|
-
if (booking.status === "CANCELED" || booking.status === "CANCELLED" || booking.status === "DECLINED") return "none";
|
|
5465
|
-
return payment === "PAID" && booking.status === "CONFIRMED" && booking.paymentStatus === "PAID" ? "granted" : "pending";
|
|
5466
|
-
}
|
|
5467
|
-
async function openTicket(item, bridge, now, beforeCreate, afterCreate) {
|
|
5468
|
-
if (!eligible2(item, TICKET2, true).eligible) return notCreated2(ORDER_REFUSED);
|
|
5469
|
-
const selected = item.attendance.ticket;
|
|
5470
|
-
if (!isNonEmpty3(selected.eventId)) return notCreated2(ORDER_REFUSED);
|
|
5471
|
-
const read2 = await bridge.call("GET", `/events/v3/events/${encodeURIComponent(selected.eventId)}?fields=REGISTRATION&fields=DETAILS&fields=FORM`);
|
|
5472
|
-
if (isRefusal(read2)) return notCreated2(attemptRefused(read2));
|
|
5473
|
-
const available = await bridge.call("POST", "/events/v1/checkout/available-tickets/query", { filter: { eventId: selected.eventId }, limit: 100, offset: 0 });
|
|
5474
|
-
if (isRefusal(available)) return notCreated2(attemptRefused(available));
|
|
5475
|
-
const definitions = isObject7(available.body) ? available.body.definitions : void 0;
|
|
5476
|
-
const live = Array.isArray(definitions) ? definitions.find((t) => isObject7(t) && t.id === item.reference.id && t.saleStatus === "SALE_STARTED") : void 0;
|
|
5477
|
-
if (!isObject7(live) || !samePrice2(live.price, item)) return notCreated2(CHANGED2);
|
|
5478
|
-
const event = bodyObject(read2, "event");
|
|
5479
|
-
if (live.eventId !== selected.eventId || classifyForApple(availableTicketAttendanceOf(event, live), item.attendance.currency) !== "appleIap") return notCreated2(ORDER_REFUSED);
|
|
5480
|
-
if (beforeCreate && !beforeCreate({ releaseAt: now() + reservationMinutes(event) * MINUTE_MS + RELEASE_MARGIN_MS2 })) return notCreated2({ status: "refused", reason: "storageUnavailable" });
|
|
5481
|
-
return reserveTicket(item, bridge, now, afterCreate);
|
|
5482
|
-
}
|
|
5483
|
-
function reservationMinutes(event) {
|
|
5484
|
-
const registration = isObject7(event?.registration) ? event.registration : void 0;
|
|
5485
|
-
const minutes = isObject7(registration?.tickets) ? registration.tickets.reservationDurationInMinutes : void 0;
|
|
5486
|
-
return typeof minutes === "number" && minutes > 0 ? minutes : DEFAULT_RESERVATION_MINUTES;
|
|
5487
|
-
}
|
|
5488
|
-
async function reserveTicket(item, bridge, now, afterCreate) {
|
|
5489
|
-
const selected = item.attendance.ticket;
|
|
5490
|
-
const held = await bridge.call("POST", "/events/v1/checkout/reservations", { eventId: selected.eventId, ticketQuantities: [{ ticketDefinitionId: item.reference.id, quantity: 1 }], ignoreLimits: false, allowHiddenTickets: false });
|
|
5491
|
-
if (isRefusal(held)) return creationRefused2(held);
|
|
5492
|
-
const reservation = held.body;
|
|
5493
|
-
if (!isObject7(reservation) || !isNonEmpty3(reservation.id) || !future(reservation.expires, now)) return ORDER_CLOSED;
|
|
5494
|
-
if (afterCreate?.({ verticalRef: { reservationId: reservation.id }, releaseAt: Date.parse(reservation.expires) + RELEASE_MARGIN_MS2 }) === false) return { status: "unavailable" };
|
|
5495
|
-
if (!heldAsSelected(reservation, item)) return CHANGED2;
|
|
5496
|
-
const placed = await bridge.call("POST", "/events/v1/checkout", { eventId: selected.eventId, reservationId: reservation.id, buyer: selected.buyer, ...selected.guests ? { guests: selected.guests } : {}, ...selected.buyerSubmission ? { buyerSubmission: selected.buyerSubmission } : {}, ...selected.guestSubmissions ? { guestSubmissions: selected.guestSubmissions } : {}, options: { silent: false, payInPerson: false, ignoreFormValidation: false, markAsPaid: false } });
|
|
5497
|
-
if (isRefusal(placed)) return attemptRefused(placed);
|
|
5498
|
-
const order = bodyObject(placed, "order");
|
|
5499
|
-
if (!samePrice2(order?.totalPrice, item)) return CHANGED2;
|
|
5500
|
-
const expires = isObject7(placed.body) && placed.body.expires || reservation.expires;
|
|
5501
|
-
if (!future(expires, now) || !isNonEmpty3(order?.snapshotId) || !isNonEmpty3(order?.orderNumber)) return ORDER_CLOSED;
|
|
5502
|
-
return { status: "open", cashierOrderId: order.snapshotId, verticalRef: { eventId: selected.eventId, ticketDefinitionId: item.reference.id, reservationId: reservation.id, orderNumber: order.orderNumber, expires: String(expires) } };
|
|
5503
|
-
}
|
|
5504
|
-
async function ticketAccess2(ref, bridge) {
|
|
5505
|
-
if (isNonEmpty3(ref.orderId)) return ecomOrderAccess(ref.orderId, bridge);
|
|
5506
|
-
if (!ref.eventId || !ref.orderNumber || !ref.ticketDefinitionId) return "unavailable";
|
|
5507
|
-
const read2 = await bridge.call("GET", `/events/v1/events/${encodeURIComponent(ref.eventId)}/orders/${encodeURIComponent(ref.orderNumber)}?fieldset=DETAILS&fieldset=TICKETS`);
|
|
5508
|
-
if (isRefusal(read2)) return accessRefused(read2);
|
|
5509
|
-
const order = bodyObject(read2, "order");
|
|
5510
|
-
if (order?.status === "CANCELED" || order?.status === "CANCELLED" || order?.status === "REFUNDED") return "none";
|
|
5511
|
-
const issued = Array.isArray(order?.tickets) && order.tickets.some((t) => isObject7(t) && isNonEmpty3(t.ticketNumber) && t.orderStatus === "PAID" && t.ticketDefinitionId === ref.ticketDefinitionId);
|
|
5512
|
-
return order?.status === "PAID" && issued ? "granted" : order ? "pending" : "unavailable";
|
|
5513
|
-
}
|
|
5514
|
-
async function reopen(order, bridge, accessOf2, now) {
|
|
5515
|
-
const access = await accessOf2(order.verticalRef, bridge);
|
|
5516
|
-
if (access === "granted") return GRANTED;
|
|
5517
|
-
if (access === "unavailable" || access === "sessionChanged") return { status: access };
|
|
5518
|
-
if (access === "none" || now && !future(order.verticalRef.expires, now)) return ORDER_CLOSED;
|
|
5519
|
-
return { status: "open", ...order };
|
|
5520
|
-
}
|
|
5521
|
-
function heldAsSelected(reservation, item) {
|
|
5522
|
-
if (isObject7(reservation.invoice)) return samePrice2(reservation.invoice.grandTotal ?? reservation.invoice.total, item);
|
|
5523
|
-
const lines = reservation.reservations;
|
|
5524
|
-
if (!Array.isArray(lines) || lines.length !== 1 || !isObject7(lines[0]) || lines[0].quantity !== 1) return false;
|
|
5525
|
-
const held = lines[0].ticket;
|
|
5526
|
-
return isObject7(held) && held.id === item.reference.id && samePrice2(held.price, item);
|
|
5527
|
-
}
|
|
5528
|
-
function samePrice2(value, item) {
|
|
5529
|
-
return isObject7(value) && value.currency === item.attendance?.currency && decimal2(value.amount) !== null && decimal2(value.amount) === decimal2(item.attendance?.amount);
|
|
5530
|
-
}
|
|
5531
|
-
function decimal2(value) {
|
|
5532
|
-
if (typeof value !== "string" || !/^\d+(?:\.\d+)?$/.test(value)) return null;
|
|
5533
|
-
return value.replace(/^0+(?=\d)/, "").replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
|
|
5534
|
-
}
|
|
5535
|
-
function future(value, now) {
|
|
5536
|
-
return typeof value === "string" && Number.isFinite(Date.parse(value)) && Date.parse(value) > now();
|
|
5537
|
-
}
|
|
5538
|
-
function matchesSlot2(value, selected) {
|
|
5539
|
-
return isObject7(value) && ["serviceId", "sessionId"].every((key) => value[key] === selected[key]) && ["startDate", "endDate"].every((key) => typeof value[key] === "string" && Date.parse(value[key]) === Date.parse(String(selected[key])));
|
|
5540
|
-
}
|
|
5541
|
-
function creationRefused2(refusal) {
|
|
5542
|
-
const attempt4 = attemptRefused(refusal);
|
|
5543
|
-
return refusal.status === "http" && [400, 401, 403, 404, 405, 409, 410, 415, 422].includes(refusal.httpStatus) ? notCreated2(attempt4) : attempt4;
|
|
5544
|
-
}
|
|
5545
|
-
function notCreated2(attempt4) {
|
|
5546
|
-
return { ...attempt4, noOrderCreated: true };
|
|
5547
|
-
}
|
|
5548
|
-
|
|
5549
4965
|
// ../../stdlib/flows/iap-checkout/src/iap-verticals/index.ts
|
|
5550
|
-
var pricingPlanOrders =
|
|
4966
|
+
var pricingPlanOrders = pricingPlanItemPayments;
|
|
5551
4967
|
|
|
5552
4968
|
// ../../stdlib/wix-sdk/redirects-v1/src/index.ts
|
|
5553
4969
|
function wixCallHeaders(opts) {
|
|
@@ -5599,7 +5015,7 @@ var hideWhen = (n, path) => ({
|
|
|
5599
5015
|
...n,
|
|
5600
5016
|
modifiers: { ...n.modifiers ?? {}, hiddenPath: path }
|
|
5601
5017
|
});
|
|
5602
|
-
var
|
|
5018
|
+
var text = (id2, value, style = "body") => node2(id2, "Text", { text: value, style });
|
|
5603
5019
|
var vstack = (id2, children, spacing = 12, alignment = "leading") => node2(id2, "VStack", { spacing, alignment, children });
|
|
5604
5020
|
var button = (id2, title, action2, style = "primary") => node2(id2, "Button", { title, style, fullWidth: true, action: action2 });
|
|
5605
5021
|
var openScreen = (screenId) => ({ actionId: "himi.open", params: { screenId } });
|
|
@@ -5624,7 +5040,7 @@ function detailedHeader(opts) {
|
|
|
5624
5040
|
spacing: 8,
|
|
5625
5041
|
alignment: "center",
|
|
5626
5042
|
children: [
|
|
5627
|
-
|
|
5043
|
+
text(`${id2}.location`, opts.locationLabel, "caption"),
|
|
5628
5044
|
node2(`${id2}.location.action`, "Button", {
|
|
5629
5045
|
title: opts.locationAction.label,
|
|
5630
5046
|
style: opts.locationAction.style ?? "plain",
|
|
@@ -5634,7 +5050,7 @@ function detailedHeader(opts) {
|
|
|
5634
5050
|
]
|
|
5635
5051
|
}));
|
|
5636
5052
|
} else {
|
|
5637
|
-
identity.push(
|
|
5053
|
+
identity.push(text(`${id2}.location`, opts.locationLabel, "caption"));
|
|
5638
5054
|
}
|
|
5639
5055
|
}
|
|
5640
5056
|
cardChildren.push(node2(`${id2}.identity`, "HStack", { spacing: 12, alignment: "center", children: identity }));
|
|
@@ -5702,9 +5118,9 @@ function authScreen(opts) {
|
|
|
5702
5118
|
...extra
|
|
5703
5119
|
});
|
|
5704
5120
|
const children = [
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
hideWhen(
|
|
5121
|
+
text(`${s2}.headline`, `$service:${s2}.headline`, "title1"),
|
|
5122
|
+
text(`${s2}.subhead`, `$service:${s2}.subhead`),
|
|
5123
|
+
hideWhen(text(`${s2}.notice`, `$service:${s2}.notice`, "bodyEmphasis"), `$service:${s2}.noNotice`),
|
|
5708
5124
|
hideWhen(
|
|
5709
5125
|
field("email", c.emailLabel ?? "Email", `tier5.${s2}.setEmail`, { keyboard: "email" }),
|
|
5710
5126
|
`$service:${s2}.signedIn`
|
|
@@ -6187,18 +5603,18 @@ function checkoutScreen(opts) {
|
|
|
6187
5603
|
const row = vstack(
|
|
6188
5604
|
`${s2}.row`,
|
|
6189
5605
|
[
|
|
6190
|
-
hideWhen(
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
hideWhen(
|
|
6197
|
-
hideWhen(
|
|
6198
|
-
hideWhen(
|
|
5606
|
+
hideWhen(text(`${s2}.row_badge`, "$item.badge", "caption1"), "$item.noBadge"),
|
|
5607
|
+
text(`${s2}.row_name`, "$item.name", "title2"),
|
|
5608
|
+
text(`${s2}.row_price`, "$item.priceLine", "title1"),
|
|
5609
|
+
text(`${s2}.row_period`, "$item.periodLine", "caption1"),
|
|
5610
|
+
text(`${s2}.row_desc`, "$item.description"),
|
|
5611
|
+
text(`${s2}.row_note`, "$item.joinNote", "caption1"),
|
|
5612
|
+
hideWhen(text(`${s2}.row_perk1`, "$item.perk1"), "$item.noPerk1"),
|
|
5613
|
+
hideWhen(text(`${s2}.row_perk2`, "$item.perk2"), "$item.noPerk2"),
|
|
5614
|
+
hideWhen(text(`${s2}.row_perk3`, "$item.perk3"), "$item.noPerk3"),
|
|
6199
5615
|
// The plan the member already holds shows a label, not a button. Selling
|
|
6200
5616
|
// someone the thing they are currently paying for is the obvious next bug.
|
|
6201
|
-
hideWhen(
|
|
5617
|
+
hideWhen(text(`${s2}.row_joined`, "$item.joinedLabel", "bodyEmphasis"), "$item.notJoined"),
|
|
6202
5618
|
hideWhen(
|
|
6203
5619
|
node2(`${s2}.row_join`, "Button", {
|
|
6204
5620
|
title: "$item.cta",
|
|
@@ -6213,21 +5629,21 @@ function checkoutScreen(opts) {
|
|
|
6213
5629
|
6
|
|
6214
5630
|
);
|
|
6215
5631
|
const children = [
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
hideWhen(
|
|
5632
|
+
text(`${s2}.headline`, `$service:${s2}.headline`, "title1"),
|
|
5633
|
+
text(`${s2}.subhead`, `$service:${s2}.subhead`),
|
|
5634
|
+
hideWhen(text(`${s2}.loading`, c.loadingText ?? "Loading plans\u2026"), `$service:${s2}.notLoading`),
|
|
6219
5635
|
// A site with no plans is a real state, not an impossible one, and hiding the
|
|
6220
5636
|
// list alone leaves a headline over blank space. Bound to a flag the SERVICE
|
|
6221
5637
|
// computes: `hiddenPath` is a single path, so nesting two hideWhen calls to
|
|
6222
5638
|
// mean "ready AND empty" just overwrites the inner one and shows this line
|
|
6223
5639
|
// during the first load.
|
|
6224
5640
|
hideWhen(
|
|
6225
|
-
|
|
5641
|
+
text(`${s2}.empty`, c.emptyText ?? "No plans are available right now."),
|
|
6226
5642
|
`$service:${s2}.notEmptyCatalog`
|
|
6227
5643
|
),
|
|
6228
|
-
hideWhen(
|
|
5644
|
+
hideWhen(text(`${s2}.error`, `$service:${s2}.error`), `$service:${s2}.noError`),
|
|
6229
5645
|
// Result of a join attempt — never a dead button.
|
|
6230
|
-
hideWhen(
|
|
5646
|
+
hideWhen(text(`${s2}.notice`, `$service:${s2}.notice`, "bodyEmphasis"), `$service:${s2}.noNotice`)
|
|
6231
5647
|
];
|
|
6232
5648
|
if (opts.signInScreenId) {
|
|
6233
5649
|
children.push(
|