@wix/himalaya-cli 0.1324.0 → 0.1326.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 (177) hide show
  1. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/checkout/src/index.d.ts +6 -10
  2. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/order-refs.d.ts +1 -0
  3. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/iap-checkout/src/purchase-fields.d.ts +1 -0
  4. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/flows/screens/src/index.d.ts +9 -35
  5. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/stdlib/wix-sdk/stores-v1/src/display.d.ts +1 -0
  6. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/checkout.mjs +30 -13
  7. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap-checkout.mjs +20 -2
  8. package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/screens.mjs +2890 -54
  9. package/dist/cli.mjs +4 -5
  10. package/fixtures/wix-canned.json +61 -6
  11. package/guides/iap-pricing.md +9 -0
  12. package/guides/iap-screen-adoption.md +77 -0
  13. package/guides/importable-sdks.md +2 -0
  14. package/guides/index.json +6 -0
  15. package/guides/sdk-reference.json +339 -1
  16. package/package.json +2 -2
  17. package/templates/beauty-salon/config.ts +1 -1
  18. package/templates/beauty-salon/dev/index.ts +46 -18
  19. package/templates/beauty-salon/tier5-src/_shared/collection-contract.ts +1 -1
  20. package/templates/beauty-salon/tier5-src/_shared/collection-service.ts +3 -2
  21. package/templates/beauty-salon/tier5-src/_shared/himi-store-collection.ts +1 -1
  22. package/templates/beauty-salon/tier5-src/_shared/home-service.ts +2 -1
  23. package/templates/beauty-salon/tier5-src/_shared/iap-presentation.ts +53 -0
  24. package/templates/beauty-salon/tier5-src/_shared/iap-worker.ts +42 -0
  25. package/templates/beauty-salon/tier5-src/himi-branded-lite-cart/index.ts +48 -1
  26. package/templates/beauty-salon/tier5-src/himi-branded-lite-home/index.ts +16 -2
  27. package/templates/beauty-salon/tier5-src/himi-branded-lite-order/index.ts +24 -3
  28. package/templates/beauty-salon/tier5-src/himi-branded-lite-plans/index.ts +153 -64
  29. package/templates/beauty-salon/tier5-src/himi-store-product/index.ts +24 -3
  30. package/templates/beauty-salon/tier5-src/himi-store-saved/index.ts +8 -3
  31. package/templates/beauty-salon/tier5-src/himi-store-shop/index.ts +10 -0
  32. package/templates/beauty-salon/tier5-src/wix-spaces-plan-detail/index.ts +8 -3
  33. package/templates/beauty-salon-owner/tier5-src/_shared/collection-contract.ts +1 -1
  34. package/templates/beauty-salon-owner/tier5-src/_shared/collection-service.ts +3 -2
  35. package/templates/beauty-salon-owner/tier5-src/_shared/home-service.ts +2 -1
  36. package/templates/branded-lite/config.ts +1 -1
  37. package/templates/branded-lite/dev/index.ts +46 -18
  38. package/templates/branded-lite/tier5-src/_shared/collection-contract.ts +1 -1
  39. package/templates/branded-lite/tier5-src/_shared/collection-service.ts +3 -2
  40. package/templates/branded-lite/tier5-src/_shared/himi-store-collection.ts +1 -1
  41. package/templates/branded-lite/tier5-src/_shared/home-service.ts +2 -1
  42. package/templates/branded-lite/tier5-src/_shared/iap-presentation.ts +53 -0
  43. package/templates/branded-lite/tier5-src/himi-branded-lite-cart/index.ts +48 -1
  44. package/templates/branded-lite/tier5-src/himi-branded-lite-home/index.ts +16 -2
  45. package/templates/branded-lite/tier5-src/himi-branded-lite-order/index.ts +24 -3
  46. package/templates/branded-lite/tier5-src/himi-branded-lite-plans/index.ts +153 -64
  47. package/templates/branded-lite/tier5-src/himi-store-product/index.ts +24 -3
  48. package/templates/branded-lite/tier5-src/himi-store-saved/index.ts +8 -3
  49. package/templates/branded-lite/tier5-src/himi-store-shop/index.ts +10 -0
  50. package/templates/branded-lite/tier5-src/wix-spaces-plan-detail/index.ts +8 -3
  51. package/templates/community-club/config.ts +1 -1
  52. package/templates/community-club/dev/index.ts +3 -1
  53. package/templates/community-club/tier5-src/_shared/collection-contract.ts +1 -1
  54. package/templates/community-club/tier5-src/_shared/collection-service.ts +3 -2
  55. package/templates/community-club/tier5-src/_shared/home-service.ts +2 -1
  56. package/templates/community-club/tier5-src/_shared/iap-presentation.ts +53 -0
  57. package/templates/community-club/tier5-src/_shared/iap-worker.ts +42 -0
  58. package/templates/community-club/tier5-src/himi-branded-lite-home/index.ts +16 -2
  59. package/templates/community-club-owner/tier5-src/_shared/collection-contract.ts +1 -1
  60. package/templates/community-club-owner/tier5-src/_shared/collection-service.ts +3 -2
  61. package/templates/community-club-owner/tier5-src/_shared/home-service.ts +2 -1
  62. package/templates/events-meetups/config.ts +1 -1
  63. package/templates/events-meetups/dev/index.ts +3 -1
  64. package/templates/events-meetups/tier5-src/_shared/collection-contract.ts +1 -1
  65. package/templates/events-meetups/tier5-src/_shared/collection-service.ts +3 -2
  66. package/templates/events-meetups/tier5-src/_shared/home-service.ts +2 -1
  67. package/templates/events-meetups/tier5-src/_shared/iap-presentation.ts +53 -0
  68. package/templates/events-meetups/tier5-src/_shared/iap-worker.ts +42 -0
  69. package/templates/events-meetups/tier5-src/himi-branded-lite-home/index.ts +16 -2
  70. package/templates/events-meetups-owner/tier5-src/_shared/collection-contract.ts +1 -1
  71. package/templates/events-meetups-owner/tier5-src/_shared/collection-service.ts +3 -2
  72. package/templates/events-meetups-owner/tier5-src/_shared/home-service.ts +2 -1
  73. package/templates/gym-fitness/config.ts +1 -1
  74. package/templates/gym-fitness/dev/index.ts +46 -18
  75. package/templates/gym-fitness/tier5-src/_shared/collection-contract.ts +1 -1
  76. package/templates/gym-fitness/tier5-src/_shared/collection-service.ts +3 -2
  77. package/templates/gym-fitness/tier5-src/_shared/himi-store-collection.ts +1 -1
  78. package/templates/gym-fitness/tier5-src/_shared/home-service.ts +2 -1
  79. package/templates/gym-fitness/tier5-src/_shared/iap-presentation.ts +53 -0
  80. package/templates/gym-fitness/tier5-src/_shared/iap-worker.ts +42 -0
  81. package/templates/gym-fitness/tier5-src/himi-branded-lite-cart/index.ts +48 -1
  82. package/templates/gym-fitness/tier5-src/himi-branded-lite-home/index.ts +16 -2
  83. package/templates/gym-fitness/tier5-src/himi-branded-lite-order/index.ts +24 -3
  84. package/templates/gym-fitness/tier5-src/himi-branded-lite-plans/index.ts +153 -64
  85. package/templates/gym-fitness/tier5-src/himi-store-product/index.ts +24 -3
  86. package/templates/gym-fitness/tier5-src/himi-store-saved/index.ts +8 -3
  87. package/templates/gym-fitness/tier5-src/himi-store-shop/index.ts +10 -0
  88. package/templates/gym-fitness/tier5-src/wix-spaces-plan-detail/index.ts +8 -3
  89. package/templates/gym-fitness-owner/tier5-src/_shared/collection-contract.ts +1 -1
  90. package/templates/gym-fitness-owner/tier5-src/_shared/collection-service.ts +3 -2
  91. package/templates/gym-fitness-owner/tier5-src/_shared/home-service.ts +2 -1
  92. package/templates/nonprofit-cause/config.ts +1 -1
  93. package/templates/nonprofit-cause/dev/index.ts +29 -13
  94. package/templates/nonprofit-cause/tier5-src/_shared/collection-contract.ts +1 -1
  95. package/templates/nonprofit-cause/tier5-src/_shared/collection-service.ts +3 -2
  96. package/templates/nonprofit-cause/tier5-src/_shared/home-service.ts +2 -1
  97. package/templates/nonprofit-cause/tier5-src/_shared/iap-presentation.ts +53 -0
  98. package/templates/nonprofit-cause/tier5-src/_shared/iap-worker.ts +42 -0
  99. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-home/index.ts +16 -2
  100. package/templates/nonprofit-cause/tier5-src/himi-branded-lite-plans/index.ts +153 -64
  101. package/templates/nonprofit-cause/tier5-src/wix-spaces-plan-detail/index.ts +8 -3
  102. package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-contract.ts +1 -1
  103. package/templates/nonprofit-cause-owner/tier5-src/_shared/collection-service.ts +3 -2
  104. package/templates/nonprofit-cause-owner/tier5-src/_shared/home-service.ts +2 -1
  105. package/templates/owner-lite/tier5-src/_shared/collection-contract.ts +1 -1
  106. package/templates/owner-lite/tier5-src/_shared/collection-service.ts +3 -2
  107. package/templates/owner-lite/tier5-src/_shared/home-service.ts +2 -1
  108. package/templates/podcast-creator/config.ts +1 -1
  109. package/templates/podcast-creator/dev/index.ts +29 -13
  110. package/templates/podcast-creator/tier5-src/_shared/collection-contract.ts +1 -1
  111. package/templates/podcast-creator/tier5-src/_shared/collection-service.ts +3 -2
  112. package/templates/podcast-creator/tier5-src/_shared/home-service.ts +2 -1
  113. package/templates/podcast-creator/tier5-src/_shared/iap-presentation.ts +53 -0
  114. package/templates/podcast-creator/tier5-src/_shared/iap-worker.ts +42 -0
  115. package/templates/podcast-creator/tier5-src/himi-branded-lite-home/index.ts +16 -2
  116. package/templates/podcast-creator/tier5-src/himi-branded-lite-plans/index.ts +153 -64
  117. package/templates/podcast-creator/tier5-src/wix-spaces-plan-detail/index.ts +8 -3
  118. package/templates/podcast-creator-owner/tier5-src/_shared/collection-contract.ts +1 -1
  119. package/templates/podcast-creator-owner/tier5-src/_shared/collection-service.ts +3 -2
  120. package/templates/podcast-creator-owner/tier5-src/_shared/home-service.ts +2 -1
  121. package/templates/portfolio-creative/config.ts +1 -1
  122. package/templates/portfolio-creative/dev/index.ts +20 -6
  123. package/templates/portfolio-creative/tier5-src/_shared/collection-contract.ts +1 -1
  124. package/templates/portfolio-creative/tier5-src/_shared/collection-service.ts +3 -2
  125. package/templates/portfolio-creative/tier5-src/_shared/himi-store-collection.ts +1 -1
  126. package/templates/portfolio-creative/tier5-src/_shared/home-service.ts +2 -1
  127. package/templates/portfolio-creative/tier5-src/_shared/iap-presentation.ts +53 -0
  128. package/templates/portfolio-creative/tier5-src/_shared/iap-worker.ts +42 -0
  129. package/templates/portfolio-creative/tier5-src/himi-branded-lite-cart/index.ts +48 -1
  130. package/templates/portfolio-creative/tier5-src/himi-branded-lite-home/index.ts +16 -2
  131. package/templates/portfolio-creative/tier5-src/himi-branded-lite-order/index.ts +24 -3
  132. package/templates/portfolio-creative/tier5-src/himi-store-product/index.ts +24 -3
  133. package/templates/portfolio-creative/tier5-src/himi-store-saved/index.ts +8 -3
  134. package/templates/portfolio-creative/tier5-src/himi-store-shop/index.ts +10 -0
  135. package/templates/portfolio-creative-owner/tier5-src/_shared/collection-contract.ts +1 -1
  136. package/templates/portfolio-creative-owner/tier5-src/_shared/collection-service.ts +3 -2
  137. package/templates/portfolio-creative-owner/tier5-src/_shared/home-service.ts +2 -1
  138. package/templates/restaurant/config.ts +1 -1
  139. package/templates/restaurant/dev/index.ts +3 -1
  140. package/templates/restaurant/tier5-src/_shared/collection-contract.ts +1 -1
  141. package/templates/restaurant/tier5-src/_shared/collection-service.ts +3 -2
  142. package/templates/restaurant/tier5-src/_shared/home-service.ts +2 -1
  143. package/templates/restaurant/tier5-src/_shared/iap-presentation.ts +53 -0
  144. package/templates/restaurant/tier5-src/_shared/iap-worker.ts +42 -0
  145. package/templates/restaurant/tier5-src/himi-branded-lite-home/index.ts +16 -2
  146. package/templates/restaurant-owner/tier5-src/_shared/collection-contract.ts +1 -1
  147. package/templates/restaurant-owner/tier5-src/_shared/collection-service.ts +3 -2
  148. package/templates/restaurant-owner/tier5-src/_shared/home-service.ts +2 -1
  149. package/templates/retail-store/config.ts +1 -1
  150. package/templates/retail-store/dev/index.ts +20 -6
  151. package/templates/retail-store/tier5-src/_shared/collection-contract.ts +1 -1
  152. package/templates/retail-store/tier5-src/_shared/collection-service.ts +3 -2
  153. package/templates/retail-store/tier5-src/_shared/himi-store-collection.ts +1 -1
  154. package/templates/retail-store/tier5-src/_shared/home-service.ts +2 -1
  155. package/templates/retail-store/tier5-src/_shared/iap-presentation.ts +53 -0
  156. package/templates/retail-store/tier5-src/_shared/iap-worker.ts +42 -0
  157. package/templates/retail-store/tier5-src/himi-branded-lite-cart/index.ts +48 -1
  158. package/templates/retail-store/tier5-src/himi-branded-lite-home/index.ts +16 -2
  159. package/templates/retail-store/tier5-src/himi-branded-lite-order/index.ts +24 -3
  160. package/templates/retail-store/tier5-src/himi-store-product/index.ts +24 -3
  161. package/templates/retail-store/tier5-src/himi-store-saved/index.ts +8 -3
  162. package/templates/retail-store/tier5-src/himi-store-shop/index.ts +10 -0
  163. package/templates/retail-store-owner/tier5-src/_shared/collection-contract.ts +1 -1
  164. package/templates/retail-store-owner/tier5-src/_shared/collection-service.ts +3 -2
  165. package/templates/retail-store-owner/tier5-src/_shared/home-service.ts +2 -1
  166. package/templates/yoga-studio/config.ts +1 -1
  167. package/templates/yoga-studio/dev/index.ts +29 -13
  168. package/templates/yoga-studio/tier5-src/_shared/collection-contract.ts +1 -1
  169. package/templates/yoga-studio/tier5-src/_shared/collection-service.ts +3 -2
  170. package/templates/yoga-studio/tier5-src/_shared/home-service.ts +2 -1
  171. package/templates/yoga-studio/tier5-src/_shared/iap-presentation.ts +53 -0
  172. package/templates/yoga-studio/tier5-src/himi-branded-lite-home/index.ts +16 -2
  173. package/templates/yoga-studio/tier5-src/himi-branded-lite-plans/index.ts +153 -64
  174. package/templates/yoga-studio/tier5-src/wix-spaces-plan-detail/index.ts +8 -3
  175. package/templates/yoga-studio-owner/tier5-src/_shared/collection-contract.ts +1 -1
  176. package/templates/yoga-studio-owner/tier5-src/_shared/collection-service.ts +3 -2
  177. package/templates/yoga-studio-owner/tier5-src/_shared/home-service.ts +2 -1
@@ -11,6 +11,8 @@ export interface Entitlement {
11
11
  * rather than offering to sell it to them again. "" when not entitled. */
12
12
  planId: string;
13
13
  }
14
+ /** Active plan ids for one member-scoped catalog scan. An incomplete scan rejects so callers cannot offer a duplicate purchase. */
15
+ export declare function activePlanIds(): Promise<string[]>;
14
16
  /**
15
17
  * Does the signed-in member hold a plan that grants access right now?
16
18
  *
@@ -23,16 +25,10 @@ export interface Entitlement {
23
25
  * the wrong (owner) endpoint is so dangerous: the 403 is indistinguishable from
24
26
  * an honest "no orders". Use this function and that cannot happen.
25
27
  *
26
- * The status filter is SERVER-SIDE, and that is load-bearing rather than tidy.
27
- * The endpoint answers with one page of at most 50 orders and no cursor, while a
28
- * member collects a `DRAFT` order every time they abandon a checkout. Asking for
29
- * everything and scanning it means the DRAFTs eventually crowd the single ACTIVE
30
- * order off the page — and because this function fails closed, that reads as
31
- * "never paid" and locks a paying member out with no error anywhere. Asking only
32
- * for ACTIVE makes the page hold nothing but access, so the count of abandoned
33
- * checkouts cannot decide whether someone gets what they bought.
28
+ * ACTIVE is filtered server-side so abandoned checkouts cannot crowd access
29
+ * off the page. When `planId` is supplied, page until that exact plan is found.
34
30
  */
35
- export declare function entitlement(): Promise<Entitlement>;
31
+ export declare function entitlement(planId?: string): Promise<Entitlement>;
36
32
  /** Shorthand for the common gate. Fails closed, like `entitlement`. */
37
33
  export declare function isEntitled(): Promise<boolean>;
38
34
  export type PayOutcome =
@@ -68,7 +64,7 @@ export interface PayRequest {
68
64
  cashierUrl?: () => Promise<string | undefined>;
69
65
  /** Re-read immediately before money moves (the wallet charge, the cashier opening). The caller's
70
66
  * own route can change while a rail is being chosen; false stops the flow with nothing charged. */
71
- mayCharge?: () => boolean;
67
+ mayCharge?: () => boolean | Promise<boolean>;
72
68
  }
73
69
  /**
74
70
  * Collect payment through the two sanctioned rails, in order.
@@ -14,4 +14,5 @@ export declare function pruneExpiredHolds(partition: OrderRefPartition, now: num
14
14
  /** References one member keeps at once. When full, the oldest reference from before Apple's sheet
15
15
  * is evicted; a partition full of handed-over payments refuses new sales instead. */
16
16
  export declare const MAX_ORDER_REFS = 16;
17
+ /** Persists unfinished orders per app and member, using the host KV unless storage is supplied. */
17
18
  export declare function createWorkerOrderRefStore(storage?: KeyValueStorage): OrderRefStore;
@@ -1,4 +1,5 @@
1
1
  import type { IapItemView } from "@wix/himalaya/iap";
2
2
  import type { AppleIapCheckoutState } from "./apple-iap-contract.js";
3
3
  import type { IapPurchaseCopy, IapPurchaseFields, IapPurchaseReadiness } from "./commerce-contract.js";
4
+ /** Projects a shared checkout into customer-facing action fields; a price alone never grants access. */
4
5
  export declare function iapPurchaseFields(view: IapItemView, state: AppleIapCheckoutState, readiness: IapPurchaseReadiness, copy: IapPurchaseCopy): IapPurchaseFields;
@@ -126,38 +126,9 @@ export interface PlanRow {
126
126
  joinedLabel: string;
127
127
  /** Per-row CTA, so the template needs no conditional of its own. */
128
128
  cta: string;
129
- }
130
- interface CheckoutState {
131
- status: "loading" | "ready" | "error";
132
- isLoading: boolean;
133
- notLoading: boolean;
134
- rows: PlanRow[];
135
- hasRows: boolean;
136
- noRows: boolean;
137
- /** Ready, and the site sells nothing. Distinct from `noRows`, which is also
138
- * true while still loading — showing "no plans" during the first fetch would
139
- * flash the wrong answer. `hiddenPath` binds a single path, so this decision
140
- * is made HERE rather than by combining flags in the descriptor. */
141
- emptyCatalog: boolean;
142
- notEmptyCatalog: boolean;
143
- headline: string;
144
- subhead: string;
145
- /** Result banner after a join attempt. */
146
- notice: string;
147
- noNotice: boolean;
148
- error: string;
149
- noError: boolean;
150
- /** True once the member holds any access-granting plan. */
151
- entitled: boolean;
152
- notEntitled: boolean;
153
- /** True ONLY when the current notice is "you must sign in". Distinct from
154
- * `noNotice`: a successful join, a cancellation, a handoff and a backend
155
- * failure all set a notice too, and routing any of those to a sign-in screen
156
- * sends the member somewhere that cannot help them. Every action sets this
157
- * explicitly rather than inheriting it, so a stale `true` cannot survive the
158
- * next attempt. */
159
- needsSignIn: boolean;
160
- notNeedsSignIn: boolean;
129
+ appleSupported: boolean;
130
+ joinDisabled: boolean;
131
+ joinNote: string;
161
132
  }
162
133
  /** Every user-facing string on the paywall. Override any subset. */
163
134
  export interface CheckoutCopy {
@@ -199,11 +170,14 @@ export interface CheckoutServiceOptions {
199
170
  * const svc = createCheckoutService({ returnTo: "myapp://screen/library" });
200
171
  * export default svc; export { svc };
201
172
  */
202
- export declare function createCheckoutService(opts?: CheckoutServiceOptions): import("@wix/himalaya/state", { with: { "resolution-mode": "import" } }).ServiceHandle<CheckoutState> & {
203
- load: (...args: never[]) => Promise<CheckoutState>;
173
+ export declare function createCheckoutService(opts?: CheckoutServiceOptions): import("@wix/himalaya/state", { with: { "resolution-mode": "import" } }).ServiceHandle<any> & {
174
+ pricingPublish: () => Promise<any>;
175
+ pricingRefresh: (...args: never[]) => Promise<any>;
176
+ iapPoll: (...args: never[]) => Promise<any>;
177
+ load: (...args: never[]) => Promise<any>;
204
178
  join: (input?: {
205
179
  id?: string;
206
- }) => Promise<CheckoutState>;
180
+ }) => Promise<any>;
207
181
  };
208
182
  export interface CheckoutScreenOptions {
209
183
  /** Where the built worker bundle is served from. */
@@ -26,6 +26,7 @@ export type WixMediaSlot = string | {
26
26
  export declare function mediaSlotUrl(value: WixMediaSlot | undefined, size?: WixImageSize | null): string;
27
27
  export interface StoreProduct {
28
28
  id?: string;
29
+ productType?: string;
29
30
  name?: string;
30
31
  slug?: string;
31
32
  description?: string;
@@ -104,20 +104,36 @@ function listMyPlanOrders(opts = {}) {
104
104
 
105
105
  // ../../stdlib/flows/checkout/src/index.ts
106
106
  var GRANTS_ACCESS = "ACTIVE";
107
- async function entitlement() {
107
+ async function activePlanIds() {
108
+ const ids = /* @__PURE__ */ new Set();
109
+ const pages = /* @__PURE__ */ new Set();
110
+ for (let offset = 0; ; offset += 50) {
111
+ const response = await listMyPlanOrders({ statuses: [GRANTS_ACCESS], limit: 50, offset });
112
+ const orders = response.orders ?? [];
113
+ const signature = JSON.stringify(orders);
114
+ if (pages.has(signature)) throw new Error("Active plan order pagination did not advance.");
115
+ pages.add(signature);
116
+ for (const order of orders) if (order.status === GRANTS_ACCESS && order.planId) ids.add(order.planId);
117
+ if (orders.length < 50) break;
118
+ }
119
+ return [...ids];
120
+ }
121
+ async function entitlement(planId) {
108
122
  try {
109
- const res = await listMyPlanOrders({ statuses: [GRANTS_ACCESS], limit: 50 });
110
- const active = (res.orders ?? []).find(
111
- (o) => (o.status ?? "").toUpperCase() === GRANTS_ACCESS
112
- );
113
- return {
114
- entitled: !!active,
115
- planName: active?.planName ?? "",
116
- planId: active?.planId ?? ""
117
- };
123
+ const pages = /* @__PURE__ */ new Set();
124
+ for (let offset = 0; ; offset += 50) {
125
+ const res = await listMyPlanOrders({ statuses: [GRANTS_ACCESS], limit: 50, offset });
126
+ const orders = res.orders ?? [];
127
+ const page = JSON.stringify(orders.map((order) => [order.id, order.planId, order.status]));
128
+ if (orders.length === 50 && pages.has(page)) break;
129
+ pages.add(page);
130
+ const active = orders.find((order) => order.status === GRANTS_ACCESS && (!planId || order.planId === planId));
131
+ if (active) return { entitled: true, planName: active.planName ?? "", planId: active.planId ?? "" };
132
+ if (orders.length < 50) break;
133
+ }
118
134
  } catch {
119
- return { entitled: false, planName: "", planId: "" };
120
135
  }
136
+ return { entitled: false, planName: "", planId: "" };
121
137
  }
122
138
  async function isEntitled() {
123
139
  return (await entitlement()).entitled;
@@ -129,7 +145,7 @@ async function payOrder(req) {
129
145
  }
130
146
  const availability = await isAvailable().catch(() => "unavailable");
131
147
  if (availability === "full" && req.snapshotId) {
132
- if (req.mayCharge?.() === false) return WITHDRAWN;
148
+ if (await req.mayCharge?.() === false) return WITHDRAWN;
133
149
  const r = await proceedToPayment({
134
150
  appId: req.appId,
135
151
  snapshotId: req.snapshotId,
@@ -150,7 +166,7 @@ async function payOrder(req) {
150
166
  if (req.cashierUrl) {
151
167
  const url = await req.cashierUrl().catch(() => void 0);
152
168
  if (url) {
153
- if (req.mayCharge?.() === false) return WITHDRAWN;
169
+ if (await req.mayCharge?.() === false) return WITHDRAWN;
154
170
  const opened = await open(url, "in_app_browser").catch(() => ({ opened: false }));
155
171
  if (opened.opened) return { kind: "handoff" };
156
172
  }
@@ -162,6 +178,7 @@ async function payOrder(req) {
162
178
  }
163
179
  export {
164
180
  GRANTS_ACCESS,
181
+ activePlanIds,
165
182
  entitlement,
166
183
  isEntitled,
167
184
  payOrder as payCashierOrder,
@@ -2779,8 +2779,26 @@ var pricingPlanOrders = {
2779
2779
  eligibility: (item) => singleUnitOf(KIND2, item),
2780
2780
  openOrder: openOrder2,
2781
2781
  reopenOrder: reopenOrder2,
2782
- readAccess: readAccess2
2782
+ readAccess: readAccess2,
2783
+ currentAccess: currentAccess2
2783
2784
  };
2785
+ async function currentAccess2(item, bridge) {
2786
+ let pending = false;
2787
+ const pages = /* @__PURE__ */ new Set();
2788
+ for (let offset = 0; ; offset += 50) {
2789
+ const answer = await bridge.call("GET", `${MEMBER_ORDERS}?orderStatuses=ACTIVE&orderStatuses=PENDING&orderStatuses=DRAFT&limit=50&offset=${offset}`);
2790
+ if (isRefusal(answer)) return accessRefused(answer);
2791
+ const orders = answer.body?.orders;
2792
+ if (!Array.isArray(orders)) return "unavailable";
2793
+ const page = JSON.stringify(orders.map((order) => [order.id, order.planId, order.status]));
2794
+ if (orders.length === 50 && pages.has(page)) return "unavailable";
2795
+ pages.add(page);
2796
+ const selected = orders.filter((order) => order.planId === item.reference.id);
2797
+ if (selected.some((order) => order.status === "ACTIVE")) return "granted";
2798
+ pending || (pending = selected.some((order) => order.status === "PENDING" || order.status === "DRAFT"));
2799
+ if (orders.length < 50) return pending ? "pending" : "none";
2800
+ }
2801
+ }
2784
2802
  async function openOrder2(item, bridge) {
2785
2803
  const planId = item.reference.id;
2786
2804
  const preview = await bridge.call("POST", `${CHECKOUT}/preview-online`, { planId });
@@ -2805,7 +2823,7 @@ async function readAccess2(verticalRef, bridge) {
2805
2823
  }
2806
2824
  function accessOf2(order) {
2807
2825
  if (order.status === "ACTIVE") return "granted";
2808
- if (order.status === "PENDING") return order.lastPaymentStatus === "PAID" ? "granted" : "pending";
2826
+ if (order.status === "PENDING") return "pending";
2809
2827
  if (order.status === "DRAFT") return "pending";
2810
2828
  return NO_ACCESS.has(String(order.status)) ? "none" : "unavailable";
2811
2829
  }