@wix/himalaya-cli 0.1723.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.
Files changed (59) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-config.d.ts +1 -0
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/dev-server/src/app-module.d.ts +2 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/godot/src/index.d.ts +3 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/attendance-classifier.d.ts +1 -1
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/wix-payments-contract.d.ts +3 -39
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/define-app.d.ts +10 -0
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/index.d.ts +2 -0
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/preview-surfaces.d.ts +24 -0
  9. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-web-sdk.d.ts +37 -0
  10. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/site-web-sdk.generated.d.ts +1 -0
  11. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/ts/src/wrapped-app-link.d.ts +13 -0
  12. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/checkout-source.d.ts +2 -3
  13. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-order-backend.d.ts +0 -2
  14. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/attendance.d.ts +2 -8
  15. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/index.d.ts +4 -13
  16. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/core.mjs +175 -1
  17. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap-checkout.mjs +46 -502
  18. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap.mjs +5 -26
  19. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +64 -648
  20. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/sdui.mjs +1 -0
  21. package/dist/browser-plane/assets.json +5 -5
  22. package/dist/browser-plane/package-reader.js +4 -4
  23. package/dist/browser-plane/preview-deferred/{74e5b76ecf38392d7eb3f9a9512d60a0675de85d411c9c56293e123152b3f70b.bin → a6e25c06d2a17ab2b5e34bf2b5965fa3ddd76ce3da32a036e546a60938130d7b.bin} +1 -1
  24. package/dist/browser-plane/sw.js +9 -9
  25. package/dist/cli.mjs +1275 -408
  26. package/dist/preview-assets.generated.bin +0 -0
  27. package/guides/himi-json-output.md +6 -2
  28. package/guides/iap-screen-adoption.md +4 -4
  29. package/guides/sdk-reference.json +11 -74
  30. package/guides/webview-page-sdk.md +14 -0
  31. package/guides/wix-business-context.md +24 -0
  32. package/guides/wix-site-to-himi-app.md +2 -1
  33. package/package.json +2 -2
  34. package/templates/beauty-salon/tier5-src/himi-store-account/index.ts +2 -2
  35. package/templates/beauty-salon/tier5-src/himi-store-product/index.ts +5 -8
  36. package/templates/branded-lite/tier5-src/himi-store-account/index.ts +2 -2
  37. package/templates/branded-lite/tier5-src/himi-store-product/index.ts +5 -8
  38. package/templates/brandy/README.md +13 -0
  39. package/templates/brandy/config.ts +15 -1
  40. package/templates/brandy/dev/index.ts +10 -7
  41. package/templates/community-club/tier5-src/himi-store-account/index.ts +2 -2
  42. package/templates/conference/tier5-src/himi-store-account/index.ts +2 -2
  43. package/templates/events-meetups/tier5-src/himi-store-account/index.ts +2 -2
  44. package/templates/gym-fitness/tier5-src/himi-store-account/index.ts +2 -2
  45. package/templates/gym-fitness/tier5-src/himi-store-product/index.ts +5 -8
  46. package/templates/nonprofit-cause/tier5-src/himi-store-account/index.ts +2 -2
  47. package/templates/podcast-creator/tier5-src/himi-store-account/index.ts +2 -2
  48. package/templates/portfolio-creative/tier5-src/himi-store-account/index.ts +2 -2
  49. package/templates/portfolio-creative/tier5-src/himi-store-product/index.ts +5 -8
  50. package/templates/restaurant/tier5-src/himi-store-account/index.ts +2 -2
  51. package/templates/retail-store/tier5-src/himi-store-account/index.ts +2 -2
  52. package/templates/retail-store/tier5-src/himi-store-product/index.ts +5 -8
  53. package/templates/salon-spa/tier5-src/himi-store-account/index.ts +2 -2
  54. package/templates/wholesale-store/tier5-src/himi-store-account/index.ts +2 -2
  55. package/templates/wholesale-store/tier5-src/himi-store-product/index.ts +5 -8
  56. package/templates/yoga-studio/tier5-src/himi-store-account/index.ts +2 -2
  57. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/attendance-orders.d.ts +0 -10
  58. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/iap-verticals/online-programs-orders.d.ts +0 -2
  59. 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,9 +161,9 @@ function createPurchaseCoordinator(deps) {
161
161
  if (session.kind !== "member") return requireSignIn();
162
162
  if (listing === "listed") clearReconcileProblem();
163
163
  const now = deps.clock.now();
164
- const eligible3 = itemsWhere((item) => isAwaitingDelivery(item) && (item.state.nextAttemptAt === null || item.state.nextAttemptAt <= now));
165
- eligible3.forEach(restartAttemptBudget);
166
- await settleDelivery(session, await deliver(session, eligible3));
164
+ const eligible2 = itemsWhere((item) => isAwaitingDelivery(item) && (item.state.nextAttemptAt === null || item.state.nextAttemptAt <= now));
165
+ eligible2.forEach(restartAttemptBudget);
166
+ await settleDelivery(session, await deliver(session, eligible2));
167
167
  }
168
168
  async function settleDelivery(session, delivered) {
169
169
  applyDelivered(delivered);
@@ -713,36 +713,25 @@ var sameReference = (value, reference) => isObject2(value) && value.kind === ref
713
713
 
714
714
  // ../../core/sdk/iap/src/wix-payments-contract.ts
715
715
  var HIMALAYA_SERVE_IAP_ROUTE = { prefix: "/himalaya-serve/v1/iap" };
716
- var BOOKINGS_APPLE_SALES_ENABLED = true;
717
- var EVENTS_APPLE_SALES_ENABLED = true;
718
716
  var ATTENDANCE_SALE_RULE = { appProductId: (id) => id, productType: "CONSUMABLE" };
719
- var STORES_APPLE_SALES_ENABLED = true;
720
717
  var STORES_PRODUCT_SALE_RULE = { appProductId: (id) => id, productType: "NON_CONSUMABLE" };
721
718
  var ONLINE_PROGRAM_SALE_RULE = { appProductId: (id) => id, productType: "NON_CONSUMABLE" };
722
- var PRICING_PLAN_APPLE_SALES_ENABLED = true;
723
719
  var PRICING_PLAN_SALE_RULE = { appProductId: (id) => id, productType: "NON_CONSUMABLE" };
724
720
  var VIDEOS_APPLE_SALES_ENABLED = false;
725
- var PRICING_PLAN_ITEM_PAYMENT_ENABLED = false;
726
- var ONLINE_PROGRAM_ITEM_PAYMENT_ENABLED = false;
727
- var BOOKINGS_ITEM_PAYMENT_ENABLED = false;
728
- var EVENTS_ITEM_PAYMENT_ENABLED = false;
729
- var CANCEL_PAYMENT_ENABLED = false;
730
721
  var VIDEO_SALE_RULE = { appProductId: (id) => id, productType: "NON_CONSUMABLE" };
731
722
  function appleSaleRules(options = {}) {
732
723
  return {
733
724
  onlineProgram: ONLINE_PROGRAM_SALE_RULE,
734
- ...options.storesAppleSalesEnabled ?? STORES_APPLE_SALES_ENABLED ? { storesProduct: STORES_PRODUCT_SALE_RULE } : {},
735
- ...options.pricingPlanAppleSalesEnabled ?? PRICING_PLAN_APPLE_SALES_ENABLED ? { pricingPlan: PRICING_PLAN_SALE_RULE } : {},
736
- ...options.bookingsAppleSalesEnabled ?? BOOKINGS_APPLE_SALES_ENABLED ? { bookingsService: ATTENDANCE_SALE_RULE } : {},
737
- ...options.eventsAppleSalesEnabled ?? EVENTS_APPLE_SALES_ENABLED ? { eventsTicket: ATTENDANCE_SALE_RULE } : {},
725
+ storesProduct: STORES_PRODUCT_SALE_RULE,
726
+ pricingPlan: PRICING_PLAN_SALE_RULE,
727
+ bookingsService: ATTENDANCE_SALE_RULE,
728
+ eventsTicket: ATTENDANCE_SALE_RULE,
738
729
  ...options.videosAppleSalesEnabled ?? VIDEOS_APPLE_SALES_ENABLED ? { wixVideo: VIDEO_SALE_RULE } : {}
739
730
  };
740
731
  }
741
732
  var APPLE_SALE_RULES = appleSaleRules();
742
733
  var APPLE_PROVISIONING_RULES = {
743
734
  ...APPLE_SALE_RULES,
744
- bookingsService: ATTENDANCE_SALE_RULE,
745
- eventsTicket: ATTENDANCE_SALE_RULE,
746
735
  wixVideo: VIDEO_SALE_RULE
747
736
  };
748
737
  var APPLE_PRICING_RULES = { ...APPLE_SALE_RULES, wixVideo: VIDEO_SALE_RULE };
@@ -1541,48 +1530,6 @@ function describesNoPlace(address) {
1541
1530
  });
1542
1531
  }
1543
1532
  var ONLINE_LABEL = /^(online|virtual)(\s+(class|classes|classroom|course|session|sessions|meeting|lesson|training|workshop|event))?$/i;
1544
- function ticketAttendanceOf(event, definition) {
1545
- const e = object(event);
1546
- const t = object(definition);
1547
- const pricing = object(t.pricingMethod);
1548
- const price = object(pricing.fixedPrice);
1549
- const registration = object(e.registration);
1550
- const type = text(registration.type) ?? text(registration.initialType) ?? text(e.eventType);
1551
- const status = text(e.status) ?? text(e.eventStatus);
1552
- return {
1553
- kind: "eventsTicket",
1554
- location: text(object(e.location).type),
1555
- registration: type === "TICKETS" || type === "RSVP_AND_TICKETS" ? "TICKETING" : type,
1556
- eventStatus: status === "SCHEDULED" ? "UPCOMING" : status,
1557
- saleStatus: text(t.saleStatus),
1558
- hidden: boolean(t.hidden),
1559
- priceType: text(pricing.pricingType),
1560
- amount: text(price.value),
1561
- currency: text(price.currency)
1562
- };
1563
- }
1564
- function availableTicketAttendanceOf(event, ticket) {
1565
- const e = object(event);
1566
- const t = object(ticket);
1567
- const v3 = t.pricingMethod !== void 0;
1568
- const pricing = object(v3 ? t.pricingMethod : t.pricing);
1569
- const fixed = object(pricing.fixedPrice);
1570
- const amount = v3 ? fixed.value : fixed.amount;
1571
- const price = object(t.price);
1572
- const listed = v3 ? t.hidden === false && t.state === void 0 : Array.isArray(t.state) && t.state.length === 0;
1573
- const visible = listed && object(t.dashboard).hidden !== true && typeof t.id === "string" && t.id.length > 0 && typeof e.id === "string" && e.id.length > 0 && t.eventId === e.id;
1574
- const fixedPrice = t.free === false && (!v3 || pricing.free === false) && pricing.pricingType === "STANDARD" && sameTicketAmount(amount, price.amount) && fixed.currency === price.currency;
1575
- return ticketAttendanceOf(e, {
1576
- hidden: visible ? false : void 0,
1577
- saleStatus: t.saleStatus,
1578
- pricingMethod: { pricingType: fixedPrice ? "STANDARD" : void 0, fixedPrice: { value: amount, currency: fixed.currency } }
1579
- });
1580
- }
1581
- function sameTicketAmount(left, right) {
1582
- const valid = (value) => typeof value === "string" && /^\d+(?:\.\d+)?$/.test(value);
1583
- const normalized = (value) => value.replace(/^0+(?=\d)/, "").replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
1584
- return valid(left) && valid(right) && normalized(left) === normalized(right);
1585
- }
1586
1533
  function object(value) {
1587
1534
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
1588
1535
  }
@@ -1710,7 +1657,7 @@ function appleIapCheckoutEnabled() {
1710
1657
  return appleIapCheckoutRoutes() !== null;
1711
1658
  }
1712
1659
  function storesAppleSalesEnabled() {
1713
- return STORES_APPLE_SALES_ENABLED;
1660
+ return true;
1714
1661
  }
1715
1662
 
1716
1663
  // ../../stdlib/flows/iap-checkout/src/cashier-charges.ts
@@ -2498,7 +2445,7 @@ function createWixOrderBackend(deps) {
2498
2445
  if (ref?.stage !== "started" || !ref.paymentId) return;
2499
2446
  const adapter = adapterFor(ref.kind);
2500
2447
  if (!adapter || !paidByItem(adapter)) return;
2501
- if (!(deps.cancelPaymentEnabled ?? CANCEL_PAYMENT_ENABLED) || adapter.reusesPayment) {
2448
+ if (adapter.reusesPayment) {
2502
2449
  const current = refAt(partition, catalogRef);
2503
2450
  if (current?.stage === "started" && current.paymentId === ref.paymentId && current.updatedAt === ref.updatedAt) handBackToGuard(partition, adapter, ref);
2504
2451
  return;
@@ -2816,7 +2763,7 @@ function enabledCheckout(deps) {
2816
2763
  if (!isCurrent(session)) return;
2817
2764
  if (ref.stage === "needsSupport") setPayment(ref.key, "needsSupport");
2818
2765
  if (ref.stage === "fulfilled" && !options.dueOnly) {
2819
- const access = await accessOf4(session, ref);
2766
+ const access = await accessOf2(session, ref);
2820
2767
  if (!isCurrent(session)) return;
2821
2768
  if (access === "granted") setPayment(ref.key, "granted");
2822
2769
  else if (access === "none") payments.delete(ref.key);
@@ -2876,7 +2823,7 @@ function enabledCheckout(deps) {
2876
2823
  if (isFinalRefusal(payment.status)) return markNeedsSupport(partition, ref);
2877
2824
  if (payment.status !== "approved") return backOff(partition, ref, false);
2878
2825
  if (!ref.kind) return settleUnassociated(partition, ref);
2879
- const access = await accessOf4(session, ref);
2826
+ const access = await accessOf2(session, ref);
2880
2827
  if (!isCurrent(session)) return;
2881
2828
  if (access === "granted") return grant(partition, ref);
2882
2829
  backOff(partition, ref, access === "none");
@@ -2892,7 +2839,7 @@ function enabledCheckout(deps) {
2892
2839
  partition.remove(ref.key);
2893
2840
  setPayment(ref.key, "accessUnknown");
2894
2841
  }
2895
- async function accessOf4(session, ref) {
2842
+ async function accessOf2(session, ref) {
2896
2843
  const adapter = deps.adapters.find((candidate) => candidate.kind === ref.kind);
2897
2844
  if (!adapter || !ref.verticalRef) return "unavailable";
2898
2845
  return adapter.readAccess(ref.verticalRef, bindBridge(session, deps.session, bridge));
@@ -3383,9 +3330,6 @@ function accessRefused(refusal) {
3383
3330
  function isRefusal(outcome) {
3384
3331
  return outcome.status !== "ok";
3385
3332
  }
3386
- function isHttp(outcome, httpStatus) {
3387
- return outcome.status === "http" && outcome.httpStatus === httpStatus;
3388
- }
3389
3333
  function bodyObject(outcome, name) {
3390
3334
  const body = outcome.body;
3391
3335
  return isObject7(body) && isObject7(body[name]) ? body[name] : null;
@@ -3399,7 +3343,6 @@ function isNonEmpty3(value) {
3399
3343
  var UNSUPPORTED = { eligible: false, reason: "unsupportedItem" };
3400
3344
  var ORDER_REFUSED = { status: "refused", reason: "orderRefused" };
3401
3345
  var ORDER_CLOSED = { status: "refused", reason: "orderClosed" };
3402
- var GRANTED = { status: "granted" };
3403
3346
  async function ecomOrderAccess(orderId, bridge) {
3404
3347
  if (!isNonEmpty3(orderId)) return "unavailable";
3405
3348
  const answer = await bridge.call("GET", `/ecom/v1/orders/${encodeURIComponent(orderId)}`);
@@ -3458,121 +3401,13 @@ var NO_ACCESS_STATUS = /* @__PURE__ */ new Set(["CANCELLED", "DECLINED", "SUSPEN
3458
3401
  var ENDED_STATUS = /* @__PURE__ */ new Set(["CANCELLED", "DECLINED", "SUSPENDED"]);
3459
3402
  var NO_ACCESS_PAYMENT = /* @__PURE__ */ new Set(["PAYMENT_FAILED", "PAYMENT_CANCELED"]);
3460
3403
 
3461
- // ../../stdlib/flows/iap-checkout/src/iap-verticals/online-programs-orders.ts
3462
- var KIND2 = "onlineProgram";
3463
- var BASE2 = "/online-programs/participants/v3/join-applications";
3464
- var onlineProgramClientOrders = {
3465
- kind: KIND2,
3466
- eligibility: (item) => singleUnitOf(KIND2, item),
3467
- openOrder,
3468
- reopenOrder,
3469
- readAccess: readAccess2,
3470
- currentAccess: currentAccess2
3471
- };
3472
- async function openOrder(item, bridge) {
3473
- const found = await currentApplication(item.reference.id, bridge);
3474
- if ("attempt" in found) return found.attempt;
3475
- const read2 = found.application ? { application: found.application } : await createdApplication(item.reference.id, bridge);
3476
- if ("attempt" in read2) return read2.attempt;
3477
- return orderOf(read2.application, bridge, { mayPrepare: true });
3478
- }
3479
- async function reopenOrder(order, bridge) {
3480
- const read2 = await applicationById(order.verticalRef.joinApplicationId, bridge);
3481
- if ("attempt" in read2) return read2.attempt;
3482
- const attempt3 = await orderOf(read2.application, bridge, { mayPrepare: false });
3483
- return attempt3.status === "open" && attempt3.cashierOrderId !== order.cashierOrderId ? ORDER_CLOSED : attempt3;
3484
- }
3485
- async function readAccess2(verticalRef, bridge) {
3486
- if (!isNonEmpty3(verticalRef.joinApplicationId)) return "unavailable";
3487
- const answer = await bridge.call("GET", `${BASE2}/${encodeURIComponent(verticalRef.joinApplicationId)}`);
3488
- if (isRefusal(answer)) return accessRefused(answer);
3489
- const application = bodyObject(answer, "joinApplication");
3490
- return application ? accessOf2(application) : "unavailable";
3491
- }
3492
- async function currentAccess2(item, bridge) {
3493
- const answer = await bridge.call("GET", `${BASE2}/current/${encodeURIComponent(item.reference.id)}`);
3494
- if (isRefusal(answer)) return accessRefused(answer);
3495
- const application = bodyObject(answer, "joinApplication");
3496
- if (!application) return "unavailable";
3497
- const access = accessOf2(application);
3498
- return access !== "granted" && ENDED_STATUS2.has(String(application.status)) ? "none" : access;
3499
- }
3500
- function accessOf2(application) {
3501
- const paid = application.paymentStatus === "PAYMENT_SUCCESSFUL" || application.paymentStatus === "NO_PAYMENT_REQUIRED";
3502
- if (application.status === "APPROVED" && paid && isNonEmpty3(application.participantId)) return "granted";
3503
- if (paid || PAYMENT_UNDER_WAY2.has(String(application.paymentStatus))) return "pending";
3504
- return NO_ACCESS_STATUS2.has(String(application.status)) || NO_ACCESS_PAYMENT2.has(String(application.paymentStatus)) ? "none" : "unavailable";
3505
- }
3506
- async function orderOf(application, bridge, options) {
3507
- if (accessOf2(application) === "granted") return GRANTED;
3508
- if (application.status === "APPROVAL_PENDING" || application.status === "INVITED") return { status: "refused", reason: "approvalRequired" };
3509
- if (application.status !== "APPROVED" && application.status !== "SUSPENDED") return ORDER_CLOSED;
3510
- const payment = String(application.paymentStatus);
3511
- if (payment === "NO_PAYMENT_REQUIRED" || payment === "PAYMENT_SUCCESSFUL") return { status: "refused", reason: "paymentInProgress" };
3512
- if (payment === "PENDING_OWNER_APPROVAL") return { status: "refused", reason: "approvalRequired" };
3513
- if (payment === "PAYMENT_IN_PROGRESS") return inProgressOrder(application);
3514
- if (!PREPARABLE.has(payment) || !options.mayPrepare) return ORDER_CLOSED;
3515
- return preparedOrder(application, bridge);
3516
- }
3517
- function inProgressOrder(application) {
3518
- const info = application.paymentInfo;
3519
- const orderId = info?.paymentOrderId;
3520
- if (!isNonEmpty3(orderId) || !isNonEmpty3(application.id)) return ORDER_REFUSED;
3521
- return { status: "open", cashierOrderId: orderId, verticalRef: { joinApplicationId: application.id, programId: String(application.programId ?? "") } };
3522
- }
3523
- async function preparedOrder(application, bridge) {
3524
- const id = String(application.id ?? "");
3525
- const answer = await bridge.call("POST", `${BASE2}/${encodeURIComponent(id)}/prepare-payment`, { paymentType: "SINGLE_PAYMENT" });
3526
- if (isHttp(answer, 428)) return reopenAfterRace(id, bridge);
3527
- if (isRefusal(answer)) return attemptRefused(answer);
3528
- const prepared = bodyObject(answer, "joinApplication");
3529
- return prepared ? orderOf(prepared, bridge, { mayPrepare: false }) : ORDER_REFUSED;
3530
- }
3531
- async function reopenAfterRace(id, bridge) {
3532
- const read2 = await applicationById(id, bridge);
3533
- return "attempt" in read2 ? read2.attempt : orderOf(read2.application, bridge, { mayPrepare: false });
3534
- }
3535
- async function currentApplication(programId, bridge) {
3536
- const answer = await bridge.call("GET", `${BASE2}/current/${encodeURIComponent(programId)}`);
3537
- if (isHttp(answer, 404)) return { application: null };
3538
- if (isRefusal(answer)) return { attempt: attemptRefused(answer) };
3539
- const application = bodyObject(answer, "joinApplication");
3540
- return application ? { application } : { attempt: ORDER_REFUSED };
3541
- }
3542
- async function createdApplication(programId, bridge) {
3543
- const answer = await bridge.call("POST", BASE2, { joinApplication: { programId } });
3544
- if (isHttp(answer, 409)) {
3545
- const existing = await currentApplication(programId, bridge);
3546
- if ("attempt" in existing) return existing;
3547
- return existing.application ? { application: existing.application } : { attempt: ORDER_REFUSED };
3548
- }
3549
- if (isRefusal(answer)) return { attempt: attemptRefused(answer) };
3550
- return applicationIn(answer);
3551
- }
3552
- async function applicationById(id, bridge) {
3553
- if (!isNonEmpty3(id)) return { attempt: ORDER_CLOSED };
3554
- const answer = await bridge.call("GET", `${BASE2}/${encodeURIComponent(id)}`);
3555
- if (isHttp(answer, 404)) return { attempt: ORDER_CLOSED };
3556
- if (isRefusal(answer)) return { attempt: attemptRefused(answer) };
3557
- return applicationIn(answer);
3558
- }
3559
- function applicationIn(answer) {
3560
- const application = bodyObject(answer, "joinApplication");
3561
- return application ? { application } : { attempt: ORDER_REFUSED };
3562
- }
3563
- var PREPARABLE = /* @__PURE__ */ new Set(["PAYMENT_PENDING", "PAYMENT_FAILED", "PAYMENT_CANCELED"]);
3564
- var PAYMENT_UNDER_WAY2 = /* @__PURE__ */ new Set(["PAYMENT_PENDING", "PAYMENT_IN_PROGRESS", "PENDING_OWNER_APPROVAL"]);
3565
- var NO_ACCESS_STATUS2 = /* @__PURE__ */ new Set(["CANCELLED", "DECLINED", "SUSPENDED", "INVITED", "APPROVAL_PENDING"]);
3566
- var ENDED_STATUS2 = /* @__PURE__ */ new Set(["CANCELLED", "DECLINED", "SUSPENDED"]);
3567
- var NO_ACCESS_PAYMENT2 = /* @__PURE__ */ new Set(["PAYMENT_FAILED", "PAYMENT_CANCELED"]);
3568
-
3569
3404
  // ../../stdlib/flows/iap-checkout/src/iap-verticals/pricing-plans.ts
3570
- var KIND3 = "pricingPlan";
3405
+ var KIND2 = "pricingPlan";
3571
3406
  var PRICING_PLANS_APP = "1522827f-c56c-a5c9-2ac9-00f9e6ae12d3";
3572
3407
  var MEMBER_ORDERS = "/pricing-plans/v2/member/orders";
3573
3408
  var pricingPlanItemPayments = {
3574
- kind: KIND3,
3575
- eligibility: (item) => singleUnitOf(KIND3, item),
3409
+ kind: KIND2,
3410
+ eligibility: (item) => singleUnitOf(KIND2, item),
3576
3411
  itemPayment: itemPayment2,
3577
3412
  readAccess: (verticalRef, bridge) => isNonEmpty3(verticalRef.planId) ? planAccess(verticalRef.planId, bridge) : Promise.resolve("unavailable"),
3578
3413
  currentAccess: (item, bridge) => planAccess(item.reference.id, bridge)
@@ -3607,87 +3442,9 @@ async function planAccess(planId, bridge) {
3607
3442
  }
3608
3443
  }
3609
3444
 
3610
- // ../../stdlib/flows/iap-checkout/src/iap-verticals/pricing-plans-orders.ts
3611
- var KIND4 = "pricingPlan";
3612
- var CHECKOUT = "/pricing-plans/v2/checkout/orders";
3613
- var MEMBER_ORDERS2 = "/pricing-plans/v2/member/orders";
3614
- var pricingPlanClientOrders = {
3615
- kind: KIND4,
3616
- eligibility: (item) => singleUnitOf(KIND4, item),
3617
- openOrder: openOrder2,
3618
- reopenOrder: reopenOrder2,
3619
- readAccess: readAccess3,
3620
- currentAccess: currentAccess3
3621
- };
3622
- async function currentAccess3(item, bridge) {
3623
- let pending = false;
3624
- const pages = /* @__PURE__ */ new Set();
3625
- for (let offset = 0; ; offset += 50) {
3626
- const answer = await bridge.call("GET", `${MEMBER_ORDERS2}?orderStatuses=ACTIVE&orderStatuses=PENDING&orderStatuses=DRAFT&limit=50&offset=${offset}`);
3627
- if (isRefusal(answer)) return accessRefused(answer);
3628
- const orders = answer.body?.orders;
3629
- if (!Array.isArray(orders)) return "unavailable";
3630
- const page = JSON.stringify(orders.map((order) => [order.id, order.planId, order.status]));
3631
- if (orders.length === 50 && pages.has(page)) return "unavailable";
3632
- pages.add(page);
3633
- const selected = orders.filter((order) => order.planId === item.reference.id);
3634
- if (selected.some((order) => order.status === "ACTIVE")) return "granted";
3635
- pending || (pending = selected.some((order) => order.status === "PENDING" || order.status === "DRAFT"));
3636
- if (orders.length < 50) return pending ? "pending" : "none";
3637
- }
3638
- }
3639
- async function openOrder2(item, bridge) {
3640
- const planId = item.reference.id;
3641
- const preview = await bridge.call("POST", `${CHECKOUT}/preview-online`, { planId });
3642
- if (isRefusal(preview)) return attemptRefused(preview);
3643
- if (!isOneTimeUnlimited(bodyObject(preview, "order"))) return { status: "refused", reason: "unsupportedItem" };
3644
- const created = await bridge.call("POST", `${CHECKOUT}/online`, { planId });
3645
- if (isRefusal(created)) return attemptRefused(created);
3646
- return orderOf2(bodyObject(created, "order"), planId);
3647
- }
3648
- async function reopenOrder2(order, bridge) {
3649
- const read2 = await memberOrder(order.verticalRef.orderId, bridge);
3650
- if ("attempt" in read2) return read2.attempt;
3651
- const attempt3 = orderOf2(read2.order, order.verticalRef.planId ?? "");
3652
- return attempt3.status === "open" && attempt3.cashierOrderId !== order.cashierOrderId ? ORDER_CLOSED : attempt3;
3653
- }
3654
- async function readAccess3(verticalRef, bridge) {
3655
- if (!isNonEmpty3(verticalRef.orderId)) return isNonEmpty3(verticalRef.planId) ? planAccess(verticalRef.planId, bridge) : "unavailable";
3656
- const answer = await bridge.call("GET", `${MEMBER_ORDERS2}/${encodeURIComponent(verticalRef.orderId)}`);
3657
- if (isRefusal(answer)) return accessRefused(answer);
3658
- const order = bodyObject(answer, "order");
3659
- return order ? accessOf3(order) : "unavailable";
3660
- }
3661
- function accessOf3(order) {
3662
- if (order.status === "ACTIVE") return "granted";
3663
- if (order.status === "PENDING") return "pending";
3664
- if (order.status === "DRAFT") return "pending";
3665
- return NO_ACCESS.has(String(order.status)) ? "none" : "unavailable";
3666
- }
3667
- var NO_ACCESS = /* @__PURE__ */ new Set(["CANCELED", "ENDED", "PAUSED"]);
3668
- function orderOf2(order, planId) {
3669
- if (!order || !isNonEmpty3(order.id)) return ORDER_REFUSED;
3670
- if (accessOf3(order) === "granted") return GRANTED;
3671
- if (order.status === "PENDING") return { status: "refused", reason: "paymentInProgress" };
3672
- if (order.status !== "DRAFT") return ORDER_CLOSED;
3673
- if (!isNonEmpty3(order.wixPayOrderId)) return ORDER_REFUSED;
3674
- return { status: "open", cashierOrderId: order.wixPayOrderId, verticalRef: { orderId: order.id, planId } };
3675
- }
3676
- async function memberOrder(orderId, bridge) {
3677
- if (!isNonEmpty3(orderId)) return { attempt: ORDER_CLOSED };
3678
- const answer = await bridge.call("GET", `${MEMBER_ORDERS2}/${encodeURIComponent(orderId)}`);
3679
- if (isRefusal(answer)) return { attempt: answer.status === "http" && answer.httpStatus === 404 ? ORDER_CLOSED : attemptRefused(answer) };
3680
- return { order: bodyObject(answer, "order") };
3681
- }
3682
- function isOneTimeUnlimited(order) {
3683
- const pricing = order?.pricing;
3684
- return pricing?.singlePaymentUnlimited === true;
3685
- }
3686
-
3687
3445
  // ../../stdlib/flows/iap-checkout/src/iap-verticals/attendance.ts
3688
3446
  var BOOKING = "bookingsService";
3689
3447
  var TICKET = "eventsTicket";
3690
- var NOT_ENABLED = { status: "refused", reason: "notEnabled" };
3691
3448
  var WIX_BOOKINGS_APP = "13d21c63-b5ec-5912-8397-c3a5ddb27a97";
3692
3449
  var CHANGED = { status: "refused", reason: "productChanged" };
3693
3450
  var WIX_EVENTS_APP = "140603ad-af8d-84a5-2c80-a0f60cb47351";
@@ -3695,34 +3452,28 @@ var RELEASE_MARGIN_MS = 3e5;
3695
3452
  var PAYMENT_TAKEN = ["PAID", "PARTIALLY_PAID", "EXEMPT", "REFUNDED"];
3696
3453
  var HAS_OFFSET = /(?:Z|[+-]\d{2}:?\d{2})$/i;
3697
3454
  var LATEST_ZONE_MS = 432e5;
3698
- function attendanceOrdersWith(options) {
3699
- return {
3700
- bookingOrders: {
3701
- kind: BOOKING,
3702
- repeatable: true,
3703
- eligibility: (item) => eligible(item, BOOKING, options.bookingsEnabled),
3704
- itemPayment: (item, bridge, beforeCreate, afterCreate) => options.bookingsEnabled ? bookingPayment(item, bridge, beforeCreate, afterCreate) : NOT_ENABLED,
3705
- resolveOpening: resolveBookingOpening,
3706
- readAccess: bookingAccess
3707
- },
3708
- eventTicketOrders: {
3709
- kind: TICKET,
3710
- repeatable: true,
3711
- eligibility: (item) => eligible(item, TICKET, options.eventsEnabled),
3712
- itemPayment: ticketPayment,
3713
- readAccess: ticketAccess
3714
- }
3715
- };
3716
- }
3717
- var { bookingOrders: bookingItemPayments, eventTicketOrders: eventTicketItemPayments } = /* @__PURE__ */ attendanceOrdersWith({ bookingsEnabled: BOOKINGS_APPLE_SALES_ENABLED, eventsEnabled: EVENTS_APPLE_SALES_ENABLED });
3718
- function eligible(item, kind, enabled) {
3719
- if (!enabled) return { eligible: false, reason: "notEnabled" };
3455
+ var bookingItemPayments = {
3456
+ kind: BOOKING,
3457
+ repeatable: true,
3458
+ eligibility: (item) => eligible(item, BOOKING),
3459
+ itemPayment: bookingPayment,
3460
+ resolveOpening: resolveBookingOpening,
3461
+ readAccess: bookingAccess
3462
+ };
3463
+ var eventTicketItemPayments = {
3464
+ kind: TICKET,
3465
+ repeatable: true,
3466
+ eligibility: (item) => eligible(item, TICKET),
3467
+ itemPayment: ticketPayment,
3468
+ readAccess: ticketAccess
3469
+ };
3470
+ function eligible(item, kind) {
3720
3471
  if (!singleUnitOf(kind, item).eligible || !isNonEmpty3(item.attemptId) || !item.attendance) return UNSUPPORTED;
3721
3472
  if (kind === TICKET) return isNonEmpty3(item.attendance.ticket?.eventId) ? { eligible: true } : UNSUPPORTED;
3722
3473
  return item.attendance.booking ? { eligible: true } : UNSUPPORTED;
3723
3474
  }
3724
3475
  async function bookingPayment(item, bridge, beforeCreate, afterCreate) {
3725
- if (!eligible(item, BOOKING, true).eligible) return notCreated(ORDER_REFUSED);
3476
+ if (!eligible(item, BOOKING).eligible) return notCreated(ORDER_REFUSED);
3726
3477
  const selected = item.attendance.booking;
3727
3478
  if (selected.slot.serviceId !== item.reference.id || !isNonEmpty3(selected.slot.startDate) || !isNonEmpty3(selected.slot.endDate)) return notCreated(ORDER_REFUSED);
3728
3479
  const read2 = await bridge.call("GET", `/bookings/v2/services/${encodeURIComponent(item.reference.id)}`);
@@ -3837,224 +3588,17 @@ function notCreated(attempt3) {
3837
3588
  return { ...attempt3, noOrderCreated: true };
3838
3589
  }
3839
3590
 
3840
- // ../../stdlib/flows/iap-checkout/src/iap-verticals/attendance-orders.ts
3841
- var BOOKING2 = "bookingsService";
3842
- var TICKET2 = "eventsTicket";
3843
- var NOT_ENABLED2 = { status: "refused", reason: "notEnabled" };
3844
- var CHANGED2 = { status: "refused", reason: "productChanged" };
3845
- var MINUTE_MS = 6e4;
3846
- var RELEASE_MARGIN_MS2 = 3e5;
3847
- var DEFAULT_RESERVATION_MINUTES = 60;
3848
- var PAYMENT_TAKEN2 = ["PAID", "PARTIALLY_PAID", "EXEMPT", "REFUNDED"];
3849
- var HAS_OFFSET2 = /(?:Z|[+-]\d{2}:?\d{2})$/i;
3850
- var LATEST_ZONE_MS2 = 432e5;
3851
- function attendanceClientOrdersWith(options) {
3852
- const now = options.now ?? Date.now;
3853
- return {
3854
- bookingOrders: {
3855
- kind: BOOKING2,
3856
- repeatable: true,
3857
- eligibility: (item) => eligible2(item, BOOKING2, options.bookingsEnabled),
3858
- openOrder: (item, bridge, beforeCreate, afterCreate) => options.bookingsEnabled ? openBooking(item, bridge, beforeCreate, afterCreate) : Promise.resolve(NOT_ENABLED2),
3859
- resolveOpening: resolveBookingOpening2,
3860
- readAccess: bookingAccess2,
3861
- reopenOrder: (order, bridge) => reopen(order, bridge, bookingAccess2)
3862
- },
3863
- eventTicketOrders: {
3864
- kind: TICKET2,
3865
- repeatable: true,
3866
- eligibility: (item) => eligible2(item, TICKET2, options.eventsEnabled),
3867
- openOrder: (item, bridge, beforeCreate, afterCreate) => options.eventsEnabled ? openTicket(item, bridge, now, beforeCreate, afterCreate) : Promise.resolve(NOT_ENABLED2),
3868
- readAccess: ticketAccess2,
3869
- reopenOrder: (order, bridge) => reopen(order, bridge, ticketAccess2, now)
3870
- }
3871
- };
3872
- }
3873
- var { bookingOrders: bookingClientOrders, eventTicketOrders: eventTicketClientOrders } = /* @__PURE__ */ attendanceClientOrdersWith({ bookingsEnabled: BOOKINGS_APPLE_SALES_ENABLED, eventsEnabled: EVENTS_APPLE_SALES_ENABLED });
3874
- function eligible2(item, kind, enabled) {
3875
- if (!enabled) return { eligible: false, reason: "notEnabled" };
3876
- if (!singleUnitOf(kind, item).eligible || !isNonEmpty3(item.attemptId) || !item.attendance) return UNSUPPORTED;
3877
- const selection = kind === BOOKING2 ? item.attendance.booking : item.attendance.ticket;
3878
- return selection ? { eligible: true } : UNSUPPORTED;
3879
- }
3880
- async function openBooking(item, bridge, beforeCreate, afterCreate) {
3881
- if (!eligible2(item, BOOKING2, true).eligible) return notCreated2(ORDER_REFUSED);
3882
- const selected = item.attendance.booking;
3883
- if (selected.slot.serviceId !== item.reference.id || !isNonEmpty3(selected.slot.startDate) || !isNonEmpty3(selected.slot.endDate)) return notCreated2(ORDER_REFUSED);
3884
- const read2 = await bridge.call("GET", `/bookings/v2/services/${encodeURIComponent(item.reference.id)}`);
3885
- if (isRefusal(read2)) return notCreated2(attemptRefused(read2));
3886
- const service = bodyObject(read2, "service");
3887
- const metadata = bookingAttendanceOf(service);
3888
- if (classifyForApple(metadata, item.attendance.currency) !== "appleIap" || !samePrice2({ amount: metadata.amount, currency: metadata.currency }, item)) return notCreated2(CHANGED2);
3889
- if (isObject7(service?.onlineBooking) && service.onlineBooking.requireManualApproval === true) return notCreated2({ status: "refused", reason: "approvalRequired" });
3890
- const availability = await bridge.call("POST", "/bookings/v1/availability/query", { query: { filter: { serviceId: [item.reference.id], startDate: selected.slot.startDate, endDate: selected.slot.endDate, bookable: true } } });
3891
- if (isRefusal(availability)) return notCreated2(attemptRefused(availability));
3892
- const entries = isObject7(availability.body) ? availability.body.availabilityEntries : void 0;
3893
- if (!Array.isArray(entries) || !entries.some((entry) => isObject7(entry) && entry.bookable === true && matchesSlot2(entry.slot, selected.slot))) return notCreated2(CHANGED2);
3894
- if (beforeCreate && !beforeCreate(slotGuard2(selected.slot))) return notCreated2({ status: "refused", reason: "storageUnavailable" });
3895
- 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 } : {} } });
3896
- if (isRefusal(created)) return creationRefused2(created);
3897
- const bookingId = bodyObject(created, "booking")?.id;
3898
- if (!isNonEmpty3(bookingId)) return ORDER_REFUSED;
3899
- if (afterCreate?.({ verticalRef: { bookingId } }) === false) return { status: "unavailable" };
3900
- return bookingCheckout(item, bookingId, bridge);
3901
- }
3902
- function slotGuard2(slot) {
3903
- const verticalRef = {};
3904
- for (const key of ["sessionId", "startDate"]) if (isNonEmpty3(slot[key])) verticalRef[key] = slot[key];
3905
- const ends = latestInstant2(String(slot.endDate));
3906
- return Number.isFinite(ends) ? { verticalRef, releaseAt: ends + RELEASE_MARGIN_MS2 } : { verticalRef };
3907
- }
3908
- function latestInstant2(value) {
3909
- if (HAS_OFFSET2.test(value)) return Date.parse(value);
3910
- return Date.parse(`${value}Z`) + LATEST_ZONE_MS2;
3911
- }
3912
- async function resolveBookingOpening2(guard, item, bridge, options) {
3913
- const scope = sameSlot2(guard.verticalRef, item?.attendance?.booking?.slot) ? "held" : "unrelated";
3914
- const bookingId = guard.verticalRef?.bookingId;
3915
- if (!bookingId || !options.settled) return scope;
3916
- const released2 = await releaseBooking2(bookingId, bridge, options.claim);
3917
- return released2 === "held" || released2 === "unavailable" && scope === "unrelated" ? scope : released2;
3918
- }
3919
- async function releaseBooking2(bookingId, bridge, claim) {
3920
- const read2 = await bridge.call("POST", "/bookings/v2/bookings/query", { query: { filter: { id: { $eq: bookingId } } } });
3921
- if (isRefusal(read2)) return read2.status === "http" && read2.httpStatus === 404 ? "released" : openingRefused2(read2);
3922
- const rows = isObject7(read2.body) ? read2.body.bookings : void 0;
3923
- const booking = Array.isArray(rows) ? rows.find((b) => isObject7(b) && b.id === bookingId) : void 0;
3924
- if (!isObject7(booking)) return "held";
3925
- if (["CANCELED", "CANCELLED", "DECLINED"].includes(String(booking.status)) || PAYMENT_TAKEN2.includes(String(booking.paymentStatus))) return "released";
3926
- if (booking.status !== "CREATED" || !claim()) return "held";
3927
- const cancelled = await bridge.call("POST", `/bookings/v2/bookings/${encodeURIComponent(bookingId)}/cancel`, { participantNotification: { notifyParticipants: false }, revision: booking.revision });
3928
- return isRefusal(cancelled) ? openingRefused2(cancelled) : "released";
3929
- }
3930
- function openingRefused2(refusal) {
3931
- if (refusal.status === "sessionChanged") return "sessionChanged";
3932
- return refusal.status === "unavailable" ? "unavailable" : "held";
3933
- }
3934
- function sameSlot2(guarded, slot) {
3935
- if (!guarded || !slot) return true;
3936
- return guarded.sessionId === slot.sessionId && Date.parse(guarded.startDate ?? "") === Date.parse(String(slot.startDate));
3937
- }
3938
- async function bookingCheckout(item, bookingId, bridge) {
3939
- const checkout = await bridge.call("POST", "/ecom/v1/checkouts", { lineItems: [{ quantity: 1, catalogReference: { appId: "13d21c63-b5ec-5912-8397-c3a5ddb27a97", catalogItemId: bookingId } }], channelType: "OTHER_PLATFORM" });
3940
- if (isRefusal(checkout)) return attemptRefused(checkout);
3941
- const entity = bodyObject(checkout, "checkout");
3942
- const total = isObject7(entity?.priceSummary) ? entity.priceSummary.total : void 0;
3943
- if (!isObject7(total) || !samePrice2({ amount: total.amount, currency: entity?.currency }, item)) return CHANGED2;
3944
- if (!isNonEmpty3(entity?.id)) return ORDER_REFUSED;
3945
- const placed = await bridge.call("POST", `/ecom/v1/checkouts/${encodeURIComponent(entity.id)}/create-order`, {});
3946
- if (isRefusal(placed)) return attemptRefused(placed);
3947
- const body = placed.body;
3948
- if (!isObject7(body) || !isNonEmpty3(body.orderId) || !isNonEmpty3(body.paymentGatewayOrderId)) return ORDER_REFUSED;
3949
- return { status: "open", cashierOrderId: body.paymentGatewayOrderId, verticalRef: { serviceId: item.reference.id, bookingId, orderId: body.orderId } };
3950
- }
3951
- async function bookingAccess2(ref, bridge) {
3952
- if (!ref.bookingId || !ref.orderId) return "unavailable";
3953
- const order = await bridge.call("GET", `/ecom/v1/orders/${encodeURIComponent(ref.orderId)}`);
3954
- if (isRefusal(order)) return accessRefused(order);
3955
- const payment = bodyObject(order, "order")?.paymentStatus;
3956
- if (payment === "FULLY_REFUNDED" || payment === "PARTIALLY_REFUNDED") return "none";
3957
- const read2 = await bridge.call("POST", "/bookings/v2/bookings/query", { query: { filter: { id: { $eq: ref.bookingId } } } });
3958
- if (isRefusal(read2)) return accessRefused(read2);
3959
- const rows = isObject7(read2.body) ? read2.body.bookings : void 0;
3960
- const booking = Array.isArray(rows) ? rows.find((b) => isObject7(b) && b.id === ref.bookingId) : void 0;
3961
- if (!isObject7(booking)) return "unavailable";
3962
- if (booking.status === "CANCELED" || booking.status === "CANCELLED" || booking.status === "DECLINED") return "none";
3963
- return payment === "PAID" && booking.status === "CONFIRMED" && booking.paymentStatus === "PAID" ? "granted" : "pending";
3964
- }
3965
- async function openTicket(item, bridge, now, beforeCreate, afterCreate) {
3966
- if (!eligible2(item, TICKET2, true).eligible) return notCreated2(ORDER_REFUSED);
3967
- const selected = item.attendance.ticket;
3968
- if (!isNonEmpty3(selected.eventId)) return notCreated2(ORDER_REFUSED);
3969
- const read2 = await bridge.call("GET", `/events/v3/events/${encodeURIComponent(selected.eventId)}?fields=REGISTRATION&fields=DETAILS&fields=FORM`);
3970
- if (isRefusal(read2)) return notCreated2(attemptRefused(read2));
3971
- const available = await bridge.call("POST", "/events/v1/checkout/available-tickets/query", { filter: { eventId: selected.eventId }, limit: 100, offset: 0 });
3972
- if (isRefusal(available)) return notCreated2(attemptRefused(available));
3973
- const definitions = isObject7(available.body) ? available.body.definitions : void 0;
3974
- const live = Array.isArray(definitions) ? definitions.find((t) => isObject7(t) && t.id === item.reference.id && t.saleStatus === "SALE_STARTED") : void 0;
3975
- if (!isObject7(live) || !samePrice2(live.price, item)) return notCreated2(CHANGED2);
3976
- const event = bodyObject(read2, "event");
3977
- if (live.eventId !== selected.eventId || classifyForApple(availableTicketAttendanceOf(event, live), item.attendance.currency) !== "appleIap") return notCreated2(ORDER_REFUSED);
3978
- if (beforeCreate && !beforeCreate({ releaseAt: now() + reservationMinutes(event) * MINUTE_MS + RELEASE_MARGIN_MS2 })) return notCreated2({ status: "refused", reason: "storageUnavailable" });
3979
- return reserveTicket(item, bridge, now, afterCreate);
3980
- }
3981
- function reservationMinutes(event) {
3982
- const registration = isObject7(event?.registration) ? event.registration : void 0;
3983
- const minutes = isObject7(registration?.tickets) ? registration.tickets.reservationDurationInMinutes : void 0;
3984
- return typeof minutes === "number" && minutes > 0 ? minutes : DEFAULT_RESERVATION_MINUTES;
3985
- }
3986
- async function reserveTicket(item, bridge, now, afterCreate) {
3987
- const selected = item.attendance.ticket;
3988
- const held = await bridge.call("POST", "/events/v1/checkout/reservations", { eventId: selected.eventId, ticketQuantities: [{ ticketDefinitionId: item.reference.id, quantity: 1 }], ignoreLimits: false, allowHiddenTickets: false });
3989
- if (isRefusal(held)) return creationRefused2(held);
3990
- const reservation = held.body;
3991
- if (!isObject7(reservation) || !isNonEmpty3(reservation.id) || !future(reservation.expires, now)) return ORDER_CLOSED;
3992
- if (afterCreate?.({ verticalRef: { reservationId: reservation.id }, releaseAt: Date.parse(reservation.expires) + RELEASE_MARGIN_MS2 }) === false) return { status: "unavailable" };
3993
- if (!heldAsSelected(reservation, item)) return CHANGED2;
3994
- 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 } });
3995
- if (isRefusal(placed)) return attemptRefused(placed);
3996
- const order = bodyObject(placed, "order");
3997
- if (!samePrice2(order?.totalPrice, item)) return CHANGED2;
3998
- const expires = isObject7(placed.body) && placed.body.expires || reservation.expires;
3999
- if (!future(expires, now) || !isNonEmpty3(order?.snapshotId) || !isNonEmpty3(order?.orderNumber)) return ORDER_CLOSED;
4000
- return { status: "open", cashierOrderId: order.snapshotId, verticalRef: { eventId: selected.eventId, ticketDefinitionId: item.reference.id, reservationId: reservation.id, orderNumber: order.orderNumber, expires: String(expires) } };
4001
- }
4002
- async function ticketAccess2(ref, bridge) {
4003
- if (isNonEmpty3(ref.orderId)) return ecomOrderAccess(ref.orderId, bridge);
4004
- if (!ref.eventId || !ref.orderNumber || !ref.ticketDefinitionId) return "unavailable";
4005
- const read2 = await bridge.call("GET", `/events/v1/events/${encodeURIComponent(ref.eventId)}/orders/${encodeURIComponent(ref.orderNumber)}?fieldset=DETAILS&fieldset=TICKETS`);
4006
- if (isRefusal(read2)) return accessRefused(read2);
4007
- const order = bodyObject(read2, "order");
4008
- if (order?.status === "CANCELED" || order?.status === "CANCELLED" || order?.status === "REFUNDED") return "none";
4009
- const issued = Array.isArray(order?.tickets) && order.tickets.some((t) => isObject7(t) && isNonEmpty3(t.ticketNumber) && t.orderStatus === "PAID" && t.ticketDefinitionId === ref.ticketDefinitionId);
4010
- return order?.status === "PAID" && issued ? "granted" : order ? "pending" : "unavailable";
4011
- }
4012
- async function reopen(order, bridge, accessOf4, now) {
4013
- const access = await accessOf4(order.verticalRef, bridge);
4014
- if (access === "granted") return GRANTED;
4015
- if (access === "unavailable" || access === "sessionChanged") return { status: access };
4016
- if (access === "none" || now && !future(order.verticalRef.expires, now)) return ORDER_CLOSED;
4017
- return { status: "open", ...order };
4018
- }
4019
- function heldAsSelected(reservation, item) {
4020
- if (isObject7(reservation.invoice)) return samePrice2(reservation.invoice.grandTotal ?? reservation.invoice.total, item);
4021
- const lines = reservation.reservations;
4022
- if (!Array.isArray(lines) || lines.length !== 1 || !isObject7(lines[0]) || lines[0].quantity !== 1) return false;
4023
- const held = lines[0].ticket;
4024
- return isObject7(held) && held.id === item.reference.id && samePrice2(held.price, item);
4025
- }
4026
- function samePrice2(value, item) {
4027
- return isObject7(value) && value.currency === item.attendance?.currency && decimal2(value.amount) !== null && decimal2(value.amount) === decimal2(item.attendance?.amount);
4028
- }
4029
- function decimal2(value) {
4030
- if (typeof value !== "string" || !/^\d+(?:\.\d+)?$/.test(value)) return null;
4031
- return value.replace(/^0+(?=\d)/, "").replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
4032
- }
4033
- function future(value, now) {
4034
- return typeof value === "string" && Number.isFinite(Date.parse(value)) && Date.parse(value) > now();
4035
- }
4036
- function matchesSlot2(value, selected) {
4037
- 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])));
4038
- }
4039
- function creationRefused2(refusal) {
4040
- const attempt3 = attemptRefused(refusal);
4041
- return refusal.status === "http" && [400, 401, 403, 404, 405, 409, 410, 415, 422].includes(refusal.httpStatus) ? notCreated2(attempt3) : attempt3;
4042
- }
4043
- function notCreated2(attempt3) {
4044
- return { ...attempt3, noOrderCreated: true };
4045
- }
4046
-
4047
3591
  // ../../stdlib/flows/iap-checkout/src/iap-verticals/stores.ts
4048
- var KIND5 = "storesProduct";
3592
+ var KIND3 = "storesProduct";
4049
3593
  var WIX_STORES_APP = "215238eb-22a5-4c36-9e7b-e7c08025e04e";
4050
3594
  var storesProductOrders = {
4051
- kind: KIND5,
3595
+ kind: KIND3,
4052
3596
  eligibility,
4053
3597
  itemPayment: itemPayment3,
4054
- readAccess: readAccess4
3598
+ readAccess: readAccess2
4055
3599
  };
4056
3600
  function eligibility(item) {
4057
- const single = singleUnitOf(KIND5, item);
3601
+ const single = singleUnitOf(KIND3, item);
4058
3602
  if (!single.eligible) return single;
4059
3603
  const catalog = item.catalogReference;
4060
3604
  const variant = catalog?.options && Object.keys(catalog.options).length > 0;
@@ -4069,19 +3613,19 @@ function classifyCart(lines) {
4069
3613
  if (apple.length === 0) return "regular";
4070
3614
  return lines.length === 1 && apple[0].quantity === 1 ? "appleIap" : "mixedRefused";
4071
3615
  }
4072
- function readAccess4(verticalRef, bridge) {
3616
+ function readAccess2(verticalRef, bridge) {
4073
3617
  return ecomOrderAccess(verticalRef.orderId, bridge);
4074
3618
  }
4075
3619
 
4076
3620
  // ../../stdlib/flows/iap-checkout/src/iap-verticals/videos.ts
4077
- var KIND6 = "wixVideo";
4078
- var NOT_ENABLED3 = { status: "refused", reason: "notEnabled" };
3621
+ var KIND4 = "wixVideo";
3622
+ var NOT_ENABLED = { status: "refused", reason: "notEnabled" };
4079
3623
  var NO_ORDER_STEP = { status: "refused", reason: "notConfigured" };
4080
3624
  function videoOrdersWith(options) {
4081
3625
  return {
4082
- kind: KIND6,
4083
- eligibility: (item) => options.enabled ? singleUnitOf(KIND6, item) : { eligible: false, reason: "notEnabled" },
4084
- openOrder: async () => options.enabled ? NO_ORDER_STEP : NOT_ENABLED3,
3626
+ kind: KIND4,
3627
+ eligibility: (item) => options.enabled ? singleUnitOf(KIND4, item) : { eligible: false, reason: "notEnabled" },
3628
+ openOrder: async () => options.enabled ? NO_ORDER_STEP : NOT_ENABLED,
4085
3629
  reopenOrder: async () => ORDER_CLOSED,
4086
3630
  readAccess: async () => "unavailable"
4087
3631
  };
@@ -4089,10 +3633,10 @@ function videoOrdersWith(options) {
4089
3633
  var wixVideoOrders = /* @__PURE__ */ videoOrdersWith({ enabled: VIDEOS_APPLE_SALES_ENABLED });
4090
3634
 
4091
3635
  // ../../stdlib/flows/iap-checkout/src/iap-verticals/index.ts
4092
- var onlineProgramOrders = ONLINE_PROGRAM_ITEM_PAYMENT_ENABLED ? onlineProgramItemPayments : onlineProgramClientOrders;
4093
- var pricingPlanOrders = PRICING_PLAN_ITEM_PAYMENT_ENABLED ? pricingPlanItemPayments : pricingPlanClientOrders;
4094
- var bookingOrders = BOOKINGS_ITEM_PAYMENT_ENABLED ? bookingItemPayments : bookingClientOrders;
4095
- var eventTicketOrders = EVENTS_ITEM_PAYMENT_ENABLED ? eventTicketItemPayments : eventTicketClientOrders;
3636
+ var onlineProgramOrders = onlineProgramItemPayments;
3637
+ var pricingPlanOrders = pricingPlanItemPayments;
3638
+ var bookingOrders = bookingItemPayments;
3639
+ var eventTicketOrders = eventTicketItemPayments;
4096
3640
  export {
4097
3641
  bookingOrders,
4098
3642
  classifyCart,