@tinkerlandai/longplay-sdk 0.10.49 → 0.10.51

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 (60) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -1
  4. package/dist/{ai-usage-B-qsCn-k.d.ts → ai-usage-gcDQqLb2.d.ts} +1 -1
  5. package/dist/{api-DpRb_Pd3.d.ts → api-D0Qu0isy.d.ts} +21 -21
  6. package/dist/chunk-2G23BYBI.js +1 -0
  7. package/dist/{chunk-ZV23WM25.js → chunk-3TSFGU4T.js} +1 -1
  8. package/dist/{chunk-JOTTHPSC.js → chunk-3Z3HL42M.js} +2 -2
  9. package/dist/{chunk-QRHCZEV6.js → chunk-4NO6U4X6.js} +1 -1
  10. package/dist/chunk-67LPUJMN.js +10 -0
  11. package/dist/chunk-7GU34JD4.js +1 -0
  12. package/dist/{chunk-CIYPQIPH.js → chunk-B4SM2KRI.js} +1 -1
  13. package/dist/chunk-CGJZIDG3.js +1 -0
  14. package/dist/{chunk-F4X2JSXX.js → chunk-DB5S72HJ.js} +1 -1
  15. package/dist/{chunk-JXWRLNK7.js → chunk-FN462OVO.js} +1 -1
  16. package/dist/{chunk-C5VTYFI7.js → chunk-GJSQZGBE.js} +1 -1
  17. package/dist/chunk-IXXVMGMF.js +1 -0
  18. package/dist/{chunk-KN2QFJOQ.js → chunk-MVUNV5XR.js} +1 -1
  19. package/dist/{chunk-IA66JXF6.js → chunk-TIUD3N72.js} +1 -1
  20. package/dist/chunk-TM72XBM5.js +1 -0
  21. package/dist/{chunk-MOHKDHS2.js → chunk-US65SQX4.js} +1 -1
  22. package/dist/{chunk-AACOUGCH.js → chunk-VPYKAEHU.js} +1 -1
  23. package/dist/{configuration-sync-7ruSsSrL.d.ts → configuration-sync-DObsuVof.d.ts} +3 -3
  24. package/dist/{content-B3RWDOOH.js → content-VTHRQSFT.js} +1 -1
  25. package/dist/funnel-host-purchase-HBQOWEES.js +1 -0
  26. package/dist/{funnel-local-client-BMxDQWE6.d.ts → funnel-local-client-DzRzPX4x.d.ts} +53 -53
  27. package/dist/{funnel-paywall-prerender-SM7FH55U.js → funnel-paywall-prerender-MD4UI2AP.js} +1 -1
  28. package/dist/{funnel-process-client-DNR9nHs8.d.ts → funnel-process-client-DGRmy5KN.d.ts} +28 -28
  29. package/dist/{funnel-runtime-host-T7QZU2NO.js → funnel-runtime-host-NZAV6C5O.js} +1 -1
  30. package/dist/index.d.ts +32 -18
  31. package/dist/index.js +1 -1
  32. package/dist/native-shell.js +1 -1
  33. package/dist/openrouter.d.ts +3 -3
  34. package/dist/openrouter.js +1 -1
  35. package/dist/page.d.ts +2 -2
  36. package/dist/page.js +1 -1
  37. package/dist/paywall-DKTGQZDJ.js +1 -0
  38. package/dist/{paywall-content-MVU3X635.js → paywall-content-SML4CL2Q.js} +1 -1
  39. package/dist/{paywall-session-ISBKCULC.js → paywall-session-YKE2CHHI.js} +1 -1
  40. package/dist/popup.d.ts +7 -3
  41. package/dist/popup.js +1 -1
  42. package/dist/{presentation-loading-mEA1iohf.d.ts → presentation-loading-BWUNotNa.d.ts} +51 -6
  43. package/dist/react-native.d.ts +7 -7
  44. package/dist/react-native.js +1 -1
  45. package/dist/{screen-renderer-HOIWGE5V.js → screen-renderer-HW2WXDTR.js} +1 -1
  46. package/dist/server.d.ts +10 -10
  47. package/dist/server.js +1 -1
  48. package/dist/visual.js +1 -1
  49. package/package.json +1 -1
  50. package/dist/chunk-2UXX62Y4.js +0 -1
  51. package/dist/chunk-CMKMFT4H.js +0 -1
  52. package/dist/chunk-DEJKZZTA.js +0 -318
  53. package/dist/chunk-FEEBBJEK.js +0 -1
  54. package/dist/chunk-L7C5TKKV.js +0 -1
  55. package/dist/chunk-YONZ4NEY.js +0 -1
  56. package/dist/funnel-host-purchase-QRREIXEJ.js +0 -1
  57. package/dist/paywall-6OURDDMJ.js +0 -1
  58. package/dist/{chunk-JOTTHPSC.js.LEGAL.txt → chunk-3Z3HL42M.js.LEGAL.txt} +0 -0
  59. package/dist/{funnel-node-evaluation-COIh1hKs.d.ts → funnel-node-evaluation-CRRTh1je.d.ts} +3 -3
  60. package/dist/{screen-qUBRsUi9.d.ts → screen-CJepeiBT.d.ts} +21 -21
@@ -1,9 +1,9 @@
1
1
  import * as zod from 'zod';
2
2
  import { z } from 'zod';
3
- import { n as FeatureClientOptions, I as IndianaOptions, C as CustomerSession, R as RemoteFeatureResult, O as PushAddressObservation, c as FunnelStartInput, r as FunnelRuntimeResponse, o as FunnelControllerResponse, B as createFunnelRunController, Q as FunnelProcessOpenInput, T as FunnelProcessResponse, U as FunnelCommand, V as FunnelProcessMutation, W as FunnelPageExperimentsResponse, k as FunnelProcessRunView, g as FunnelRunController } from './funnel-local-client-BMxDQWE6.js';
4
- import { A as ApiInput, O as OfferingItem, I as InvoiceModeParams, a as ApiOutput } from './api-DpRb_Pd3.js';
3
+ import { n as FeatureClientOptions, I as IndianaOptions, C as CustomerSession, R as RemoteFeatureResult, O as PushAddressObservation, c as FunnelStartInput, r as FunnelRuntimeResponse, o as FunnelControllerResponse, B as createFunnelRunController, Q as FunnelProcessOpenInput, T as FunnelProcessResponse, U as FunnelCommand, V as FunnelProcessMutation, W as FunnelPageExperimentsResponse, k as FunnelProcessRunView, g as FunnelRunController } from './funnel-local-client-DzRzPX4x.js';
4
+ import { A as ApiInput, O as OfferingItem, I as InvoiceModeParams, a as ApiOutput } from './api-D0Qu0isy.js';
5
5
  import { O as Offer } from './coupon-kfkIVf9n.js';
6
- import { S as StackNode } from './screen-qUBRsUi9.js';
6
+ import { S as StackNode } from './screen-CJepeiBT.js';
7
7
  import { J as JsonValue, F as FeatureResult } from './growth-rules-B4YYy64R.js';
8
8
 
9
9
  /** The store supplies the intent hint. Only verified provider facts prove ownership. */
@@ -1714,7 +1714,7 @@ declare function createIndiana(options: IndianaOptions): {
1714
1714
  type: "forever";
1715
1715
  };
1716
1716
  renewalAmountMinor: number;
1717
- status: "failed" | "paid" | "created" | "pending" | "trialing" | "cancelled";
1717
+ status: "cancelled" | "failed" | "paid" | "created" | "pending" | "trialing";
1718
1718
  url: string | null;
1719
1719
  } | {
1720
1720
  type: "subscription";
@@ -2233,7 +2233,7 @@ declare function createIndiana(options: IndianaOptions): {
2233
2233
  operationId: string;
2234
2234
  membershipId: string;
2235
2235
  productVersionId: string;
2236
- status: "failed" | "pending" | "cancelled" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
2236
+ status: "cancelled" | "failed" | "pending" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
2237
2237
  timing: "immediate" | "renewal";
2238
2238
  effectiveAt: string;
2239
2239
  checkoutUrl: string | null;
@@ -3223,7 +3223,7 @@ declare function createIndiana(options: IndianaOptions): {
3223
3223
  operationId: string;
3224
3224
  membershipId: string;
3225
3225
  productVersionId: string;
3226
- status: "failed" | "pending" | "cancelled" | "prepared" | "effective";
3226
+ status: "cancelled" | "failed" | "pending" | "prepared" | "effective";
3227
3227
  timing: "store";
3228
3228
  effectiveAt: string | null;
3229
3229
  checkoutUrl: null;
@@ -3275,7 +3275,7 @@ declare function createIndiana(options: IndianaOptions): {
3275
3275
  operationId: string;
3276
3276
  membershipId: string;
3277
3277
  productVersionId: string;
3278
- status: "failed" | "pending" | "cancelled" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
3278
+ status: "cancelled" | "failed" | "pending" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
3279
3279
  timing: "immediate" | "renewal";
3280
3280
  effectiveAt: string;
3281
3281
  checkoutUrl: string | null;
@@ -4265,7 +4265,7 @@ declare function createIndiana(options: IndianaOptions): {
4265
4265
  operationId: string;
4266
4266
  membershipId: string;
4267
4267
  productVersionId: string;
4268
- status: "failed" | "pending" | "cancelled" | "prepared" | "effective";
4268
+ status: "cancelled" | "failed" | "pending" | "prepared" | "effective";
4269
4269
  timing: "store";
4270
4270
  effectiveAt: string | null;
4271
4271
  checkoutUrl: null;
@@ -4317,7 +4317,7 @@ declare function createIndiana(options: IndianaOptions): {
4317
4317
  requestId: string;
4318
4318
  orderId: string;
4319
4319
  purchaseIntentId: string;
4320
- status: "failed" | "paid" | "created" | "pending" | "trialing" | "cancelled";
4320
+ status: "cancelled" | "failed" | "paid" | "created" | "pending" | "trialing";
4321
4321
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
4322
4322
  refunded: boolean;
4323
4323
  completion: {
@@ -4752,7 +4752,7 @@ declare function createIndiana(options: IndianaOptions): {
4752
4752
  operation: {
4753
4753
  operationId: string;
4754
4754
  orderId: string;
4755
- status: "failed" | "complete" | "pending" | "cancelled";
4755
+ status: "cancelled" | "failed" | "complete" | "pending";
4756
4756
  executor: "merchant" | "indiana";
4757
4757
  checkoutUrl: string | null;
4758
4758
  execution: {
@@ -5785,7 +5785,7 @@ declare function createIndiana(options: IndianaOptions): {
5785
5785
  operation: {
5786
5786
  operationId: string;
5787
5787
  orderId: string;
5788
- status: "failed" | "complete" | "pending" | "cancelled";
5788
+ status: "cancelled" | "failed" | "complete" | "pending";
5789
5789
  executor: "merchant" | "indiana";
5790
5790
  checkoutUrl: string | null;
5791
5791
  execution: {
@@ -9638,7 +9638,7 @@ declare function createCustomerClient(options: IndianaOptions): {
9638
9638
  type: "forever";
9639
9639
  };
9640
9640
  renewalAmountMinor: number;
9641
- status: "failed" | "paid" | "created" | "pending" | "trialing" | "cancelled";
9641
+ status: "cancelled" | "failed" | "paid" | "created" | "pending" | "trialing";
9642
9642
  url: string | null;
9643
9643
  } | {
9644
9644
  type: "subscription";
@@ -10157,7 +10157,7 @@ declare function createCustomerClient(options: IndianaOptions): {
10157
10157
  operationId: string;
10158
10158
  membershipId: string;
10159
10159
  productVersionId: string;
10160
- status: "failed" | "pending" | "cancelled" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
10160
+ status: "cancelled" | "failed" | "pending" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
10161
10161
  timing: "immediate" | "renewal";
10162
10162
  effectiveAt: string;
10163
10163
  checkoutUrl: string | null;
@@ -11147,7 +11147,7 @@ declare function createCustomerClient(options: IndianaOptions): {
11147
11147
  operationId: string;
11148
11148
  membershipId: string;
11149
11149
  productVersionId: string;
11150
- status: "failed" | "pending" | "cancelled" | "prepared" | "effective";
11150
+ status: "cancelled" | "failed" | "pending" | "prepared" | "effective";
11151
11151
  timing: "store";
11152
11152
  effectiveAt: string | null;
11153
11153
  checkoutUrl: null;
@@ -11199,7 +11199,7 @@ declare function createCustomerClient(options: IndianaOptions): {
11199
11199
  operationId: string;
11200
11200
  membershipId: string;
11201
11201
  productVersionId: string;
11202
- status: "failed" | "pending" | "cancelled" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
11202
+ status: "cancelled" | "failed" | "pending" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
11203
11203
  timing: "immediate" | "renewal";
11204
11204
  effectiveAt: string;
11205
11205
  checkoutUrl: string | null;
@@ -12189,7 +12189,7 @@ declare function createCustomerClient(options: IndianaOptions): {
12189
12189
  operationId: string;
12190
12190
  membershipId: string;
12191
12191
  productVersionId: string;
12192
- status: "failed" | "pending" | "cancelled" | "prepared" | "effective";
12192
+ status: "cancelled" | "failed" | "pending" | "prepared" | "effective";
12193
12193
  timing: "store";
12194
12194
  effectiveAt: string | null;
12195
12195
  checkoutUrl: null;
@@ -12241,7 +12241,7 @@ declare function createCustomerClient(options: IndianaOptions): {
12241
12241
  requestId: string;
12242
12242
  orderId: string;
12243
12243
  purchaseIntentId: string;
12244
- status: "failed" | "paid" | "created" | "pending" | "trialing" | "cancelled";
12244
+ status: "cancelled" | "failed" | "paid" | "created" | "pending" | "trialing";
12245
12245
  currency: "USD" | "EUR" | "CNY" | "GBP" | "JPY" | "CAD" | "AUD" | "NZD" | "CHF" | "HKD" | "SGD" | "KRW" | "INR" | "BRL" | "MXN" | "TWD" | "THB" | "IDR" | "MYR" | "PHP" | "VND" | "ZAR" | "AED" | "SAR" | "SEK" | "NOK" | "DKK" | "PLN" | "CZK" | "HUF" | "ILS" | "TRY" | "RON";
12246
12246
  refunded: boolean;
12247
12247
  completion: {
@@ -12676,7 +12676,7 @@ declare function createCustomerClient(options: IndianaOptions): {
12676
12676
  operation: {
12677
12677
  operationId: string;
12678
12678
  orderId: string;
12679
- status: "failed" | "complete" | "pending" | "cancelled";
12679
+ status: "cancelled" | "failed" | "complete" | "pending";
12680
12680
  executor: "merchant" | "indiana";
12681
12681
  checkoutUrl: string | null;
12682
12682
  execution: {
@@ -13709,7 +13709,7 @@ declare function createCustomerClient(options: IndianaOptions): {
13709
13709
  operation: {
13710
13710
  operationId: string;
13711
13711
  orderId: string;
13712
- status: "failed" | "complete" | "pending" | "cancelled";
13712
+ status: "cancelled" | "failed" | "complete" | "pending";
13713
13713
  executor: "merchant" | "indiana";
13714
13714
  checkoutUrl: string | null;
13715
13715
  execution: {
@@ -17655,7 +17655,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
17655
17655
  operation: {
17656
17656
  operationId: string;
17657
17657
  orderId: string;
17658
- status: "failed" | "complete" | "pending" | "cancelled";
17658
+ status: "cancelled" | "failed" | "complete" | "pending";
17659
17659
  executor: "merchant" | "indiana";
17660
17660
  checkoutUrl: string | null;
17661
17661
  execution: {
@@ -18681,7 +18681,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
18681
18681
  operationId: string;
18682
18682
  membershipId: string;
18683
18683
  productVersionId: string;
18684
- status: "failed" | "pending" | "cancelled" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
18684
+ status: "cancelled" | "failed" | "pending" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
18685
18685
  timing: "immediate" | "renewal";
18686
18686
  effectiveAt: string;
18687
18687
  checkoutUrl: string | null;
@@ -19687,7 +19687,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
19687
19687
  stopped: boolean;
19688
19688
  variables: Record<string, zod.JSONType>;
19689
19689
  visit: number;
19690
- nodeType: "output" | "action" | "screen" | "end" | "coupon" | "condition" | "feature" | "split" | "coupons" | "offering" | "entry" | "external_page" | "wait";
19690
+ nodeType: "output" | "action" | "wait" | "screen" | "end" | "coupon" | "condition" | "feature" | "split" | "coupons" | "offering" | "entry" | "external_page";
19691
19691
  canBack: boolean;
19692
19692
  pendingRequest: {
19693
19693
  requestId: string;
@@ -21467,7 +21467,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
21467
21467
  operation: {
21468
21468
  operationId: string;
21469
21469
  orderId: string;
21470
- status: "failed" | "complete" | "pending" | "cancelled";
21470
+ status: "cancelled" | "failed" | "complete" | "pending";
21471
21471
  executor: "merchant" | "indiana";
21472
21472
  checkoutUrl: string | null;
21473
21473
  execution: {
@@ -22493,7 +22493,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
22493
22493
  operationId: string;
22494
22494
  membershipId: string;
22495
22495
  productVersionId: string;
22496
- status: "failed" | "pending" | "cancelled" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
22496
+ status: "cancelled" | "failed" | "pending" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
22497
22497
  timing: "immediate" | "renewal";
22498
22498
  effectiveAt: string;
22499
22499
  checkoutUrl: string | null;
@@ -23499,7 +23499,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
23499
23499
  stopped: boolean;
23500
23500
  variables: Record<string, zod.JSONType>;
23501
23501
  visit: number;
23502
- nodeType: "output" | "action" | "screen" | "end" | "coupon" | "condition" | "feature" | "split" | "coupons" | "offering" | "entry" | "external_page" | "wait";
23502
+ nodeType: "output" | "action" | "wait" | "screen" | "end" | "coupon" | "condition" | "feature" | "split" | "coupons" | "offering" | "entry" | "external_page";
23503
23503
  canBack: boolean;
23504
23504
  pendingRequest: {
23505
23505
  requestId: string;
@@ -25279,7 +25279,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
25279
25279
  operation: {
25280
25280
  operationId: string;
25281
25281
  orderId: string;
25282
- status: "failed" | "complete" | "pending" | "cancelled";
25282
+ status: "cancelled" | "failed" | "complete" | "pending";
25283
25283
  executor: "merchant" | "indiana";
25284
25284
  checkoutUrl: string | null;
25285
25285
  execution: {
@@ -26305,7 +26305,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
26305
26305
  operationId: string;
26306
26306
  membershipId: string;
26307
26307
  productVersionId: string;
26308
- status: "failed" | "pending" | "cancelled" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
26308
+ status: "cancelled" | "failed" | "pending" | "prepared" | "effective" | "confirmed" | "scheduled" | "quoted";
26309
26309
  timing: "immediate" | "renewal";
26310
26310
  effectiveAt: string;
26311
26311
  checkoutUrl: string | null;
@@ -27311,7 +27311,7 @@ declare function createFunnelProcess(options: FunnelProcessOptions): {
27311
27311
  stopped: boolean;
27312
27312
  variables: Record<string, zod.JSONType>;
27313
27313
  visit: number;
27314
- nodeType: "output" | "action" | "screen" | "end" | "coupon" | "condition" | "feature" | "split" | "coupons" | "offering" | "entry" | "external_page" | "wait";
27314
+ nodeType: "output" | "action" | "wait" | "screen" | "end" | "coupon" | "condition" | "feature" | "split" | "coupons" | "offering" | "entry" | "external_page";
27315
27315
  canBack: boolean;
27316
27316
  pendingRequest: {
27317
27317
  requestId: string;
@@ -1 +1 @@
1
- import{a,b}from"./chunk-YONZ4NEY.js";import"./chunk-FEEBBJEK.js";import"./chunk-N3PZMMOO.js";import"./chunk-2LEDTNKQ.js";import"./chunk-L7C5TKKV.js";import"./chunk-IA66JXF6.js";import"./chunk-W32FI2A2.js";import"./chunk-2UXX62Y4.js";import"./chunk-W3B4GT74.js";import"./chunk-LE32WTZ7.js";import"./chunk-SZZIYCXK.js";import"./chunk-IDDPWGQE.js";import"./chunk-LSHIR6QM.js";import"./chunk-OPUIFAQS.js";import"./chunk-HYX3EDZS.js";import"./chunk-EGFVGCDG.js";import"./chunk-YFLVGOCJ.js";import"./chunk-VILB5M4X.js";import"./chunk-JXWRLNK7.js";import"./chunk-FRRKTQNZ.js";import"./chunk-MQ5LJEWV.js";import"./chunk-JDIFYMSA.js";import"./chunk-TNPBYYAX.js";import"./chunk-KCN6OGYG.js";import"./chunk-PF6PRPRO.js";import"./chunk-ZDIWOE4Q.js";import"./chunk-FYD7CMS7.js";import"./chunk-SLUA7ABW.js";import"./chunk-C5VTYFI7.js";import"./chunk-CIYPQIPH.js";import"./chunk-XVCSRZX4.js";import"./chunk-DSPLGTQI.js";import"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
1
+ import{a,b}from"./chunk-CGJZIDG3.js";import"./chunk-IXXVMGMF.js";import"./chunk-N3PZMMOO.js";import"./chunk-2LEDTNKQ.js";import"./chunk-7GU34JD4.js";import"./chunk-TIUD3N72.js";import"./chunk-W32FI2A2.js";import"./chunk-2G23BYBI.js";import"./chunk-W3B4GT74.js";import"./chunk-LE32WTZ7.js";import"./chunk-SZZIYCXK.js";import"./chunk-IDDPWGQE.js";import"./chunk-LSHIR6QM.js";import"./chunk-OPUIFAQS.js";import"./chunk-HYX3EDZS.js";import"./chunk-EGFVGCDG.js";import"./chunk-YFLVGOCJ.js";import"./chunk-VILB5M4X.js";import"./chunk-FN462OVO.js";import"./chunk-FRRKTQNZ.js";import"./chunk-MQ5LJEWV.js";import"./chunk-JDIFYMSA.js";import"./chunk-TNPBYYAX.js";import"./chunk-KCN6OGYG.js";import"./chunk-PF6PRPRO.js";import"./chunk-ZDIWOE4Q.js";import"./chunk-FYD7CMS7.js";import"./chunk-SLUA7ABW.js";import"./chunk-GJSQZGBE.js";import"./chunk-B4SM2KRI.js";import"./chunk-XVCSRZX4.js";import"./chunk-DSPLGTQI.js";import"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
package/dist/index.d.ts CHANGED
@@ -1,19 +1,19 @@
1
1
  import { z } from 'zod';
2
- import { S as ScreenAnswers, P as PresentationLoadingOptions, s as screenInputBindingsSchema, a as SurfaceData, b as PaywallLoadingDocument, C as CustomerDataIntent, c as createPresentationLoading } from './presentation-loading-mEA1iohf.js';
3
- export { d as PresentationState } from './presentation-loading-mEA1iohf.js';
2
+ import { S as ScreenAnswers, P as PresentationLoadingOptions, s as screenInputBindingsSchema, a as SurfaceData, b as PaywallLoadingDocument, C as CustomerDataIntent, c as createPresentationLoading, R as RetainedPurchaseDialog } from './presentation-loading-BWUNotNa.js';
3
+ export { d as PresentationState } from './presentation-loading-BWUNotNa.js';
4
4
  import { J as JsonValue } from './growth-rules-B4YYy64R.js';
5
- import { S as StackNode, a as ScreenSelection } from './screen-qUBRsUi9.js';
6
- import { C as ConfigurationSync } from './configuration-sync-7ruSsSrL.js';
7
- export { a as ConfigurationStorage, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-7ruSsSrL.js';
8
- import { P as PaywallSession, a as PaywallOperation, b as PaywallSubscriptionChange, F as FunnelCommandStorage, s as scopeSchema, c as FunnelStartInput, I as IndianaOptions, S as SessionCredentials, d as FunnelExecutionPolicy, e as PaywallRecovery, f as PaywallQuote, g as FunnelRunController, h as PaywallResolution, i as FunnelRunView, j as IamFunnelEntryDelivery, k as FunnelProcessRunView, l as createPaywallSession$1 } from './funnel-local-client-BMxDQWE6.js';
9
- export { C as CustomerSession, m as FeatureClient, n as FeatureClientOptions, o as FunnelControllerResponse, p as FunnelPendingEntry, q as FunnelPurchaseRecovery, r as FunnelRuntimeResponse, t as FunnelSegmentPrediction, L as LocalFunnelClient, u as LocalFunnelClientOptions, v as LongplayError, w as PaywallPurchaseInput, x as PaywallStartInput, y as PushHost, z as PushJournal, A as createFeatureClient, B as createFunnelRunController, D as createLocalFunnelClient, E as getPaywallRecovery, G as isPaywallOperationComplete, H as isPaywallOperationPending, J as isPaywallUpdateOperation, K as isPaywallUpdateQuote, M as preparePaywallFallback } from './funnel-local-client-BMxDQWE6.js';
5
+ import { S as StackNode, a as ScreenSelection } from './screen-CJepeiBT.js';
6
+ import { C as ConfigurationSync } from './configuration-sync-DObsuVof.js';
7
+ export { a as ConfigurationStorage, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-DObsuVof.js';
8
+ import { P as PaywallSession, a as PaywallOperation, b as PaywallSubscriptionChange, F as FunnelCommandStorage, s as scopeSchema, c as FunnelStartInput, I as IndianaOptions, S as SessionCredentials, d as FunnelExecutionPolicy, e as PaywallRecovery, f as PaywallQuote, g as FunnelRunController, h as PaywallResolution, i as FunnelRunView, j as IamFunnelEntryDelivery, k as FunnelProcessRunView, l as createPaywallSession$1 } from './funnel-local-client-DzRzPX4x.js';
9
+ export { C as CustomerSession, m as FeatureClient, n as FeatureClientOptions, o as FunnelControllerResponse, p as FunnelPendingEntry, q as FunnelPurchaseRecovery, r as FunnelRuntimeResponse, t as FunnelSegmentPrediction, L as LocalFunnelClient, u as LocalFunnelClientOptions, v as LongplayError, w as PaywallPurchaseInput, x as PaywallStartInput, y as PushHost, z as PushJournal, A as createFeatureClient, B as createFunnelRunController, D as createLocalFunnelClient, E as getPaywallRecovery, G as isPaywallOperationComplete, H as isPaywallOperationPending, J as isPaywallUpdateOperation, K as isPaywallUpdateQuote, M as preparePaywallFallback } from './funnel-local-client-DzRzPX4x.js';
10
10
  import { C as CouponInput, O as Offer } from './coupon-kfkIVf9n.js';
11
11
  export { a as OfferUnavailableReason } from './coupon-kfkIVf9n.js';
12
- import { E as EntitlementCheckResult, M as MerchantBridgeManifest } from './funnel-node-evaluation-COIh1hKs.js';
13
- export { a as EntitlementCheckInput, b as EntitlementCheckObservation, c as EntitlementRequirement, F as FunnelNodeEvaluationContext, e as evaluateFunnelNode } from './funnel-node-evaluation-COIh1hKs.js';
14
- import { c as createFunnelProcess } from './funnel-process-client-DNR9nHs8.js';
15
- export { F as FunnelProcessAdapter, a as FunnelProcessOptions, b as FunnelResourceSource, I as LongplayFeatureOptions, d as createFunnelClient, e as createLongplay } from './funnel-process-client-DNR9nHs8.js';
16
- import './api-DpRb_Pd3.js';
12
+ import { E as EntitlementCheckResult, M as MerchantBridgeManifest } from './funnel-node-evaluation-CRRTh1je.js';
13
+ export { a as EntitlementCheckInput, b as EntitlementCheckObservation, c as EntitlementRequirement, F as FunnelNodeEvaluationContext, e as evaluateFunnelNode } from './funnel-node-evaluation-CRRTh1je.js';
14
+ import { c as createFunnelProcess } from './funnel-process-client-DGRmy5KN.js';
15
+ export { F as FunnelProcessAdapter, a as FunnelProcessOptions, b as FunnelResourceSource, I as LongplayFeatureOptions, d as createFunnelClient, e as createLongplay } from './funnel-process-client-DGRmy5KN.js';
16
+ import './api-D0Qu0isy.js';
17
17
  import 'zod/v4';
18
18
 
19
19
  /** Opt-in geometry; documents without responsive fields retain their host's legacy sizing. */
@@ -1905,6 +1905,10 @@ type FunnelHostOptions = PresentationLoadingOptions & {
1905
1905
  declare function showFunnelRun$1(container: HTMLElement, input: FunnelHostOptions, initialLoading?: ReturnType<typeof createPresentationLoading>): Promise<{
1906
1906
  destroy: () => void;
1907
1907
  refresh: () => Promise<void>;
1908
+ retainPurchaseDialog(): {
1909
+ dialog: HTMLDialogElement;
1910
+ release(): void;
1911
+ } | undefined;
1908
1912
  readonly recovery: PaywallRecovery;
1909
1913
  prepareFallback(): Promise<PaywallRecovery>;
1910
1914
  review: (receiptId?: string) => Promise<void>;
@@ -1915,6 +1919,10 @@ declare function showFunnelRun$1(container: HTMLElement, input: FunnelHostOption
1915
1919
  declare function showObservedFunnelRun(container: HTMLElement, input: FunnelHostOptions, initialLoading?: ReturnType<typeof createPresentationLoading>): Promise<{
1916
1920
  destroy: () => void;
1917
1921
  refresh: () => Promise<void>;
1922
+ retainPurchaseDialog(): {
1923
+ dialog: HTMLDialogElement;
1924
+ release(): void;
1925
+ } | undefined;
1918
1926
  readonly recovery: PaywallRecovery;
1919
1927
  prepareFallback(): Promise<PaywallRecovery>;
1920
1928
  review: (receiptId?: string) => Promise<void>;
@@ -1937,7 +1945,8 @@ type FunnelPurchaseHostOptions = Omit<FunnelHostOptions, "client" | "checkoutNav
1937
1945
  start?: FunnelPurchaseStart | Promise<FunnelPurchaseStart | null | undefined>;
1938
1946
  resolveOfferId?: (purchase: Parameters<NonNullable<FunnelHostOptions["resolveOfferId"]>>[0], attempt: FunnelPurchaseAttempt) => ReturnType<NonNullable<FunnelHostOptions["resolveOfferId"]>>;
1939
1947
  };
1940
- type Host = Awaited<ReturnType<typeof showObservedFunnelRun>>;
1948
+ type RunHost = Awaited<ReturnType<typeof showObservedFunnelRun>>;
1949
+ type Host = Omit<RunHost, "retainPurchaseDialog">;
1941
1950
  /**
1942
1951
  * Same Controller/Host lifecycle; operation-only or blocked recovery goes to onRecovery. An
1943
1952
  * unpaid original Checkout is recovered inside its Run's Paywall (Continue checkout, or another
@@ -1998,7 +2007,7 @@ declare function createMerchantBridge(options: MerchantBridgeOptions): {
1998
2007
  merchantSubscriptionId: string;
1999
2008
  merchantProductId: string;
2000
2009
  productVersionId: string | null;
2001
- status: "active" | "trialing" | "cancelled" | "expired" | "past_due";
2010
+ status: "active" | "cancelled" | "trialing" | "expired" | "past_due";
2002
2011
  currentPeriodStartsAt: string | null;
2003
2012
  currentPeriodEndsAt: string | null;
2004
2013
  cancelAtPeriodEnd: boolean;
@@ -2290,7 +2299,8 @@ declare function showPaywall(container: HTMLElement, options: PaywallHostOptions
2290
2299
  readonly recovery: PaywallRecovery;
2291
2300
  prepareFallback(): Promise<PaywallRecovery>;
2292
2301
  setSuspended(value: boolean): void;
2293
- destroy: (reason?: "destroy" | "dismiss" | "action") => void;
2302
+ destroy: (reason?: "destroy" | "dismiss" | "action", retainDialog?: boolean) => void;
2303
+ retainPurchaseDialog(): RetainedPurchaseDialog | undefined;
2294
2304
  refresh: () => Promise<{
2295
2305
  id: string;
2296
2306
  paywallId: string;
@@ -2676,6 +2686,10 @@ declare function createPaywallSession(...args: Parameters<typeof createPaywallSe
2676
2686
  declare function showFunnelRun(...args: Parameters<typeof showFunnelRun$1>): Promise<{
2677
2687
  destroy: () => void;
2678
2688
  refresh: () => Promise<void>;
2689
+ retainPurchaseDialog(): {
2690
+ dialog: HTMLDialogElement;
2691
+ release(): void;
2692
+ } | undefined;
2679
2693
  readonly recovery: PaywallRecovery;
2680
2694
  prepareFallback(): Promise<PaywallRecovery>;
2681
2695
  review: (receiptId?: string) => Promise<void>;
@@ -2684,10 +2698,10 @@ declare function showFunnelRun(...args: Parameters<typeof showFunnelRun$1>): Pro
2684
2698
  }>;
2685
2699
 
2686
2700
  declare function showFunnelPurchase(...args: Parameters<typeof showFunnelPurchase$1>): Promise<{
2687
- destroy: () => void;
2688
- refresh: () => Promise<void>;
2689
2701
  readonly recovery: PaywallRecovery;
2690
- prepareFallback(): Promise<PaywallRecovery>;
2702
+ refresh: () => Promise<void>;
2703
+ destroy: () => void;
2704
+ prepareFallback: () => Promise<PaywallRecovery>;
2691
2705
  review: (receiptId?: string) => Promise<void>;
2692
2706
  exitReview: () => Promise<void>;
2693
2707
  readonly unappliedDrafts: Map<string, Record<string, string | boolean | string[]>>;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as En,c as bn}from"./chunk-KN2QFJOQ.js";import{a as We,c as Rn}from"./chunk-IA66JXF6.js";import{a as Ie}from"./chunk-W32FI2A2.js";import{a as pn,c as wn,d as Sn}from"./chunk-QRHCZEV6.js";import"./chunk-3ITNAFAH.js";import{a as In}from"./chunk-CMKMFT4H.js";import"./chunk-2I2S5ZIH.js";import{h as mn,i as vn,k as Pn}from"./chunk-F4X2JSXX.js";import{E as Ae,d as Xe,f as Qe,g as ge,h as ve,i as Ye,w as yn}from"./chunk-ZV23WM25.js";import"./chunk-W3B4GT74.js";import{a as ze}from"./chunk-Y2ASROJH.js";import"./chunk-TIOPNTMP.js";import"./chunk-RFWVXTZ7.js";import"./chunk-MOHKDHS2.js";import"./chunk-HYCLLEFU.js";import"./chunk-KSME3N3A.js";import{K as Ke}from"./chunk-LE32WTZ7.js";import"./chunk-SZZIYCXK.js";import"./chunk-IDDPWGQE.js";import{c as hn,e as gn}from"./chunk-LSHIR6QM.js";import"./chunk-OPUIFAQS.js";import"./chunk-HYX3EDZS.js";import{B as dn,C as ln,D as un,E as fn,c as an,d as sn,e as cn}from"./chunk-EGFVGCDG.js";import{A as Le,B as Be,D as He,F as qe,G as Ue,I as Ve,J as je,K as Ge,L as Je,M as Te,N as $e,z as _e}from"./chunk-YFLVGOCJ.js";import"./chunk-VILB5M4X.js";import{b as Ce}from"./chunk-JXWRLNK7.js";import"./chunk-FRRKTQNZ.js";import"./chunk-MQ5LJEWV.js";import"./chunk-JDIFYMSA.js";import"./chunk-TNPBYYAX.js";import"./chunk-KCN6OGYG.js";import"./chunk-PF6PRPRO.js";import{a as G}from"./chunk-ZDIWOE4Q.js";import"./chunk-FYD7CMS7.js";import{a as be,c as de}from"./chunk-J6KIN4RH.js";import"./chunk-SLUA7ABW.js";import{c as we,d as Ee}from"./chunk-C5VTYFI7.js";import"./chunk-3VUPVXAV.js";import"./chunk-CIYPQIPH.js";import{b as U}from"./chunk-XVCSRZX4.js";import{a as Z}from"./chunk-DSPLGTQI.js";import"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";var I=class extends Error{constructor(f,b=0,w=!1,h="fix_request"){super(f);this.code=f;this.status=b;this.retryable=w;this.recovery=h;this.name="MerchantBridgeError"}code;status;retryable;recovery};async function _n(n,d){if(!n.headers.get("content-type")?.split(";",1)[0].trim().match(/^application\/(?:json|[a-z0-9.+-]+\+json)$/i))throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");let f=n.body?.getReader();if(!f)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");let b=()=>{f.cancel().catch(()=>{})};d.addEventListener("abort",b,{once:!0});let w=0,h="",t=new TextDecoder("utf-8",{fatal:!0});try{for(d.throwIfAborted();;){let i=await f.read();if(d.throwIfAborted(),i.done)break;if(w+=i.value.byteLength,w>262144)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");h+=t.decode(i.value,{stream:!0})}return h+=t.decode(),JSON.parse(h)}catch(i){throw d.throwIfAborted(),i instanceof I?i:new I("MERCHANT_BRIDGE_INVALID_RESPONSE")}finally{d.removeEventListener("abort",b),await f.cancel().catch(()=>{}),f.releaseLock()}}function Tn(n){let d=qe.parse(n.origin),f=Ue.parse(n.manifest),b={projectId:n.scope.projectId,environmentId:n.scope.environmentId,environment:n.scope.environment};for(let m of["projectId","environmentId","environment"])if(f[m]!==n.scope[m])throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");let w=n.customerId===void 0?null:U.uuid().parse(n.customerId),h=0,t=null,i=null,u=new AbortController,y=n.fetch??globalThis.fetch;async function P(m,s,E,_,O){if(!f.capabilities.includes(m))throw new I("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let S=He[m];if(["merchant_catalog_reader","merchant_refund_authority","indiana_server_key"].includes(S.authority))throw new I("MERCHANT_BRIDGE_FORBIDDEN",403);let l=h,o=AbortSignal.any([u.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],..._?[_]:[]]);o.throwIfAborted();let T=new Headers(await n.headers?.());if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(/\bgg_(?:sk|ct|rt)_/.test(T.get("authorization")??"")||T.has("X-Indiana-Bridge-Signature")||T.has("X-Indiana-Bridge-Key-Id"))throw new I("MERCHANT_BRIDGE_FORBIDDEN",403);T.set(Be,String(_e)),T.set("Accept","application/json");let g=crypto.randomUUID();T.set("X-Request-Id",g),T.set("Content-Type","application/json");let M=await y(d+Le,{method:"POST",credentials:"include",redirect:"error",cache:"no-store",headers:T,signal:o,body:JSON.stringify({bridgeVersion:_e,requestId:g,command:S.command,scope:b,data:O??(E===void 0?{}:{operationId:E})})}),J=await _n(M,o);if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(!M.ok){let N=$e.safeParse(J);throw!N.success||N.data.scope.projectId!==n.scope.projectId||N.data.scope.environment!==n.scope.environment||N.data.scope.environmentId!==n.scope.environmentId||N.data.requestId!==g||N.data.command!==S.command?new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status):new I(N.data.error.code,M.status,N.data.error.retryable,N.data.error.recovery)}let c=Ve(U.unknown()).safeParse(J);if(!c.success||c.data.scope.projectId!==n.scope.projectId||c.data.scope.environment!==n.scope.environment||c.data.scope.environmentId!==n.scope.environmentId||c.data.requestId!==g||c.data.command!==S.command)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status);let $=s.safeParse(c.data.data);if(!$.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status);return $.data}function R(){if(!w)throw new I("MERCHANT_BRIDGE_UNAUTHENTICATED",401);return w}async function B(m,s,E,_){let O=R();if(_!==void 0&&Te.parse({operationId:_,customerId:O}),!f.capabilities.includes(m))throw new I("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let S=h,l=AbortSignal.any([u.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...s?[s]:[]]);l.throwIfAborted();let o,T=new Promise((g,M)=>{o=()=>M(l.reason),l.addEventListener("abort",o,{once:!0})});try{let M=E(async()=>{let c=await import("./merchant-bridge-contracts-7EHDNPJJ.js");if(l.throwIfAborted(),S!==h||w!==O)throw new DOMException("Merchant identity changed","AbortError");return c},l),J=await Promise.race([M,T]);return l.throwIfAborted(),J}finally{l.removeEventListener("abort",o)}}async function z(m,s,E,_){let O=R(),S=Te.parse({operationId:E,customerId:O}),l=await P(m,s,S.operationId,_,S);if(l.customerId!==O||l.operationId!==S.operationId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return l}return{async readPresentation(m){let s=await P("presentation",Ge,void 0,m);if(i!==null&&i!==s.nativeUserId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(s.presentation&&w!==null&&s.presentation.customerId!==w)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return i=s.nativeUserId,t=s.presentation,s},async createSession(m){let s=await P("session",je,void 0,m);if(i!==null&&i!==s.nativeUserId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(w!==null&&w!==s.session.customerId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(t&&t.customerId!==s.session.customerId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return w=s.session.customerId,i=s.nativeUserId,s.session},async reportPresentation(m,s){let E=R(),_=Je.parse(m);if(!t||t.customerId!==E||t.decisionId!==_.decisionId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return P("presentation_events",U.strictObject({queued:U.literal(!0)}),void 0,s,_)},async readCustomerCommerce(m){let s=R(),E=await B("customer_commerce",m,async(_,O)=>{let[S,l]=await Promise.all([_(),P("customer_commerce",U.unknown(),void 0,O)]),o=S.merchantBridgeCommerceSchema.safeParse(l);if(!o.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return o.data});if(E.customerId!==s)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return E},async executePurchase(m,s){let E=await B("purchases",s,async(_,O)=>z("purchases",(await _()).merchantBridgeOperationSchema,m,O),m);if(E.type!=="purchase")throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return E},readOperation:(m,s)=>B("operation_status",s,async(E,_)=>z("operation_status",(await E()).merchantOperationLookupSchema,m,_),m),async executeSubscriptionChange(m,s){let E=await B("subscription_changes",s,async(_,O)=>z("subscription_changes",(await _()).merchantBridgeOperationSchema,m,O),m);if(E.type!=="subscription_change")throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return E},reset(){h++,u.abort(),u=new AbortController,w=null,t=null,i=null}}}var en=U.strictObject({command:ve,target:Qe,runId:U.uuid().optional(),expiresAt:U.iso.datetime({offset:!0}).optional(),deliveryLimit:U.number().int().min(1).max(100).optional()}).refine(n=>n.command.release===n.target.release),Ze=U.strictObject({schemaVersion:U.literal(1),entries:U.array(en).max(4e3)});function nn(n){let d=!1,f=()=>{d||n.unavailable(),d=!0};function b(){return n.storage===!1?void 0:n.storage??globalThis.sessionStorage}function w(t){let i=b()?.getItem(t);if(!i)return[];if(i.length>1048576)throw Error("Entry recovery is too large");return Ze.parse(JSON.parse(i)).entries}function h(t,i){let u=b();if(!u)return;if(!i.length)return u.removeItem(t);let y=JSON.stringify(Ze.parse({schemaVersion:1,entries:i}));if(y.length>1048576)throw Error("Entry recovery is too large");u.setItem(t,y)}return{load(){try{let t=n.binding();if(!t||n.storage===!1)return;let i="indiana.funnel.entries.v1."+JSON.stringify(t);return{key:i,entries:w(i)}}catch{f();return}},retain(t,i){if(t)try{let u=en.parse(i);h(t,[...w(t).filter(y=>y.command.funnelId!==u.command.funnelId),u])}catch{f()}},forget(t,i){if(t)try{h(t,w(t).filter(u=>u.command.requestId!==i))}catch{f()}}}}var tn=U.strictObject({version:U.literal(1),runs:U.array(U.uuid()).max(100)}),De=new WeakMap,Oe=new WeakMap;function Se(n){let d=!1;function f(){d||n.unavailable(),d=!0}function b(t){let i=t.storage.getItem(t.key);if(!i)return[];if(i.length>8192)throw Error("Invalid entry delivery record");return tn.parse(JSON.parse(i)).runs}function w(t){let i=De.get(t.storage);i||De.set(t.storage,i=new Map);let u=i.get(t.key);return u||i.set(t.key,u=new Set),u}function h(t){if(!t)return;let i=De.get(t.storage),u=i?.get(t.key);u?.delete(t.requestId),u?.size===0&&i?.delete(t.key)}return{claim(t,i,u,y,P=!1){if(u!==void 0)try{let R=n.binding();if(!R)throw Error("Entry delivery identity is unavailable");let B={storage:n.storage??globalThis.sessionStorage,key:"indiana.funnel.delivery.v1."+JSON.stringify([...R,i,t]),requestId:y},z=b(B);if(Oe.get(B.storage)?.has(B.key))throw Error("Entry delivery storage is unavailable");B.storage.setItem(B.key,JSON.stringify({version:1,runs:z}));let m=w(B);return!P&&!m.has(y)&&z.length+m.size>=u?!1:(m.add(y),B)}catch{return f(),!1}},accept(t,i){if(t)try{let u=b(t);u.includes(i)||t.storage.setItem(t.key,JSON.stringify(tn.parse({version:1,runs:[...u,i].slice(-100)})))}catch{let u=Oe.get(t.storage);u||Oe.set(t.storage,u=new Set),u.add(t.key),f()}finally{h(t)}},release:h}}function Pe(){let n,d,f=()=>{clearTimeout(n),n=void 0;let b=d;d=void 0,b?.cancelled()};return{get active(){return d!==void 0},start(b,w,h,t){if(d)return;if(b===0){w()?h():t();return}let i={valid:w,cancelled:t};d=i,n=setTimeout(()=>{d===i&&(d=void 0,n=void 0,w()?h():t())},b*1e3)},recheck(){d&&!d.valid()&&f()},cancel:f}}var Re=n=>["running","waiting"].includes(n.status)&&!n.pendingRequest&&(n.stopped||!n.screen&&!n.paywall&&n.instruction?.type==="wait"&&n.instruction.kind!=="operation");function Cn(n){let d=we(n.baseUrl),f=n.scope,b=Ce(n),w=n.fetch??globalThis.fetch.bind(globalThis),h,t=!1,i=!1,u=0,y=0,P="",R=0,B=0,z=0,m=!1,s,E=!0,_,O,S,l,o,T=-1,g,M=e=>{g===e&&(N.release(e.deliveryTicket),g=void 0,x())},J=new Set,c=(e,a)=>Z(n.onStatus,e,a),$=Pe(),N=Se({storage:n.deliveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[d,f.projectId,f.environment,n.environmentId,"customer",e]:void 0},unavailable:()=>c("delivery_unavailable")}),ee=new Set,te=nn({storage:n.recoveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[d,f.projectId,f.environment,n.environmentId,n.appManifestRelease,e]:void 0},unavailable:()=>c("recovery_unavailable")}),Y=e=>te.forget(e.storageKey,e.command.requestId);function Q(e,a){a&&(e.runId=a.id,e.expiresAt=a.runExpiresAt),te.retain(e.storageKey,{command:e.command,target:e.target,...e.runId&&{runId:e.runId},...e.expiresAt&&{expiresAt:e.expiresAt},...e.deliveryLimit!==void 0&&{deliveryLimit:e.deliveryLimit}})}function re(){let e=o;o=void 0,e?.host.destroy(),e?.slot.remove(),e?.client.reset(),x()}let le=()=>$.active||g!==void 0||o!==void 0&&!o.background;function me(e,a){if(o?.client!==e)return;Q(o.recovery,a);let p=Re(a);o.slot.hidden=p,p!==o.background&&(o.background=p,p?c("run_background",o.entryId):T=y,x())}function pe(e,a,p){let v=e.client.view;if(!a||e.background||!v?.screen||v.paywall||v.pendingRequest||v.stopped||v.status!=="waiting")return;let K=Ke.parse({operation:"close",requestId:crypto.randomUUID(),nodeId:v.nodeId,visit:v.visit,revision:v.revision,customerToken:a}),j=Ce({...n,session:void 0});j.requestWithCredential("funnels",K,e.runToken,{keepalive:p}).then(()=>Y(e.recovery)).catch(()=>{}).finally(()=>j.dispose())}let ae=()=>{o&&pe(o,n.session.peek(),!0)},r=()=>Date.now()<B&&performance.now()<z;function C(e){if(e.target.release!==n.appManifestRelease||!r())return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return c("incompatible",e.id),!1}}function H(e){if(t||e.epoch!==R||e.visit!==y||document.visibilityState==="hidden")return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function W(e){if(le()){c("in_progress",e.id);return}let a=R,p=y;$.start(e.delivery?.delaySeconds??0,()=>!t&&a===R&&p===y&&document.visibilityState!=="hidden"&&C(e)&&h?.entries.some(v=>v.id===e.id&&v.funnelId===e.funnelId&&v.versionId===e.versionId&&v.event===e.event&&JSON.stringify(v.target)===JSON.stringify(e.target)&&JSON.stringify(v.delivery)===JSON.stringify(e.delivery))===!0,()=>{V(e)},()=>{J.delete(`${e.funnelId}:${e.id}`)})}async function V(e){if(le()){c("in_progress",e.id);return}if(!n.session.peek()){c("identity_required",e.id);return}let a=te.load(),p=a?.entries.find(A=>A.command.funnelId===e.funnelId&&(!A.expiresAt||Date.parse(A.expiresAt)>Date.now()));if(p){if(!X(p)){c("recovery_pending",e.id);return}let A={...p,storageKey:a.key,epoch:R,visit:y};ee.add(A.command.requestId),g=A,await F(A);return}let v=crypto.randomUUID(),K=N.claim(e.id,e.funnelId,e.delivery?.maxPerSession,v);if(K===!1){c("frequency",e.id),x();return}let j={freshStart:!0,deliveryLimit:e.delivery?.maxPerSession,deliveryTicket:K,command:ve.parse({operation:"entry_start",entryId:e.id,funnelId:e.funnelId,versionId:e.versionId,release:n.appManifestRelease,requestId:v,locale:document.documentElement.lang||"en"}),epoch:R,visit:y,target:e.target,storageKey:a?.key};ee.add(j.command.requestId),g=j,await F(j)}async function F(e){if(e.dispatching)return;e.dispatching=!0;let a=e.freshStart===!0;e.freshStart=!1;let p,v=!1,K=!1;async function j(A){if(e.epoch!==R)return;let D=A.view;if(!(e.storageKey&&D&&(Re(D)||D.paywall||D.pendingRequest))&&D&&["running","waiting"].includes(D.status))try{await A.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:D.nodeId,visit:D.visit,revision:D.revision}),Y(e)}catch(k){if(!(k instanceof G&&k.code==="FORBIDDEN"))throw k}}try{if(!e.deliveryTicket&&e.deliveryLimit!==void 0){let q=N.claim(e.command.entryId,e.command.funnelId,e.deliveryLimit,e.command.requestId,!0);q!==!1&&(e.deliveryTicket=q)}Q(e),c("starting",e.command.entryId);let A=await b.request("funnels",e.command),D=Ye.safeParse(A);if(D.success){if(D.data.scope.projectId!==f.projectId||D.data.scope.environment!==f.environment)throw new G("SCOPE_MISMATCH","Entry scope changed");e.epoch===R&&c(D.data.reason,e.command.entryId),Y(e),M(e);return}let k=Xe.parse(A);if(!k.runToken||k.scope.projectId!==f.projectId||k.scope.environment!==f.environment||k.run.source.type!=="funnel"||k.run.source.id!==e.command.funnelId||k.run.source.versionId!==e.command.versionId||e.runId!==void 0&&k.run.id!==e.runId)throw new G("INVALID_RESPONSE","Invalid entry Run");if(N.accept(e.deliveryTicket,k.run.id),e.epoch!==R){M(e),c("identity_changed",e.command.entryId);return}Q(e,k.run);let L=Ae({...n,runToken:k.runToken,funnelId:e.command.funnelId,initialResponse:a?A:void 0});p=L,K=!0,await L.get(),K=!1;let ne=L.view;if(!ne||ne.id!==k.run.id||ne.source.type!=="funnel"||ne.source.id!==e.command.funnelId||ne.source.versionId!==e.command.versionId)throw new G("INVALID_RESPONSE","Entry Run version changed");if(!["running","waiting"].includes(ne.status)){Y(e),M(e),c("run_ended",e.command.entryId);return}let{showFunnelRun:fe}=await import("./funnel-runtime-host-T7QZU2NO.js");if(!H(e)){await j(L),c("left_screen",e.command.entryId),M(e);return}let Fe=!1,xe=!1;if(o&&!o.background){await j(L),c("in_progress",e.command.entryId),M(e);return}o&&re();let ie=document.createElement("div");ie.hidden=Re(ne),n.container.append(ie);let ke=await fe(ie,{...n.host,client:L,appManifestRelease:n.appManifestRelease,onState(q){me(L,q),Z(n.host?.onState,q)},onDismiss(q){Fe=!0,ie.remove(),q&&!["running","waiting"].includes(q.status)&&Y(e),o?.client===L&&(o=void 0,L.reset(),x(),q&&q.status!=="completed"&&c("run_ended",e.command.entryId)),Z(n.host?.onDismiss,q)},onComplete(q){xe=!0,Y(e),o?.client===L&&re(),Z(n.host?.onComplete,q)},onError(q){Z(n.host?.onError,q),o?.client===L&&q instanceof G&&q.code==="FORBIDDEN"&&(Y(e),re(),c("run_ended",e.command.entryId))}}).catch(q=>{throw ie.remove(),q});if(!H(e)||Fe||xe){ke.destroy(),ie.remove(),H(e)||await j(L),M(e);return}let he=Re(L.view??ne);ie.hidden=he,o={host:ke,client:L,slot:ie,entryId:e.command.entryId,background:he,runToken:k.runToken,owner:n.session.peek(),recovery:e},he||(T=e.visit),v=!0,M(e),c("started",e.command.entryId),he&&c("run_background",e.command.entryId)}catch(A){A instanceof G&&(!p||K&&A.code==="FORBIDDEN")&&A.status!==void 0&&A.status>=400&&A.status<500&&!A.retryable&&(Y(e),M(e)),e.epoch===R&&!t&&(c("start_failed",e.command.entryId),Z(n.host?.onError,A))}finally{v||p?.reset(),e.dispatching=!1}}function X(e){if(e.command.release!==n.appManifestRelease||e.target.release!==n.appManifestRelease)return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function ye(){if(le())return!1;let e=te.load();for(let a of e?.entries??[]){if(a.expiresAt&&Date.parse(a.expiresAt)<=Date.now()){te.forget(e.key,a.command.requestId);continue}if(a.command.requestId===o?.recovery.command.requestId||ee.has(a.command.requestId)||!X(a))continue;ee.add(a.command.requestId);let p={...a,storageKey:e.key,epoch:R,visit:y};return g=p,F(p),!0}return!1}function ue(){if(m=!1,$.recheck(),t||!i||document.visibilityState==="hidden")return;se();let e=o!==void 0&&!o.background;if(e&&(T=y),!ye()){if(!r()){E=!0;return}E=!1;for(let a of h?.entries??[]){let p=`${a.funnelId}:${a.id}`;if(!(a.event!=="screen_enter"||J.has(p)||!C(a))){if(!n.session.peek()){c("identity_required",a.id);continue}if(T===y){J.add(p),e&&c("in_progress",a.id);continue}if(g||$.active){c("in_progress",a.id);return}J.add(p),W(a);break}}}}let x=()=>{!m&&!t&&(m=!0,queueMicrotask(ue))};function se(){let e=location.origin+location.pathname;return e===P?!1:(P=e,y++,$.cancel(),E=!0,J.clear(),ee.clear(),!0)}function oe(){se()&&x()}function ce(e){if(!e.isTrusted||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||document.visibilityState==="hidden")return;let a=e.target;if(!(a instanceof Element)||a.closest("[data-indiana-funnel]"))return;let p=a.closest("button,a,input");if(!(!p||p.matches(":disabled,[aria-disabled='true']")||p.closest("[hidden],[inert],[aria-hidden='true']")))for(let v of h?.entries??[]){let K=v.target.button;if(!(v.event!=="button_click"||!K||!C(v))){try{let j=be(document);if(!p.matches(K.selector)||j(K.selector,p)!==1)continue}catch{c("incompatible",v.id);continue}W(v);break}}}async function Me(){if(t)return;if(s)return s;let e=++u,a=new AbortController;_=a;let p,v=new Promise((A,D)=>{p=()=>D(new G("TIMEOUT","Funnel entry configuration read cancelled or timed out")),a.signal.addEventListener("abort",p,{once:!0})}),K=setTimeout(()=>a.abort(),n.timeoutMs??5e3),j=(async()=>{let A=async()=>{let fe=await w(`${d}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:a.signal});if(!fe.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",fe.status);return ge.parse(await fe.json())},D=await Promise.race([A(),v]),k=Date.parse(D.validatedAt),L=Date.parse(D.validUntil);if(D.scope.projectId!==f.projectId||D.scope.environment!==f.environment||D.scope.environmentId!==n.environmentId||D.release!==n.appManifestRelease||L<=Date.now()||k>Date.now()+5e3||L-k>6e4||L<=k)throw new G("INVALID_RESPONSE","Entry configuration scope or deadline changed");if(t||e!==u)return;let ne=h===void 0;h=D,B=L,z=performance.now()+Math.min(L-Date.now(),6e4),$.recheck(),(ne||E)&&x()})();s=j;try{await j}finally{clearTimeout(K),a.signal.removeEventListener("abort",p),s===j&&(s=void 0)}}async function on(){if(!(!i||t)){try{await Me()}catch{t||c("configuration_unavailable")}x()}}let Ne=Ie({document,run:on,delay:()=>i&&!t?15e3:void 0});return{async start(){i||t||(i=!0,P=location.origin+location.pathname,O=Ee(oe),S=n.session.subscribeIdentity(()=>{R++,$.cancel(),N.release(g?.deliveryTicket),E=!0,g=void 0,J.clear(),T=-1,ee.clear(),o&&pe(o,o.owner,!1),re(),x()}),l=new MutationObserver(x),l.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",ce,!0),document.addEventListener("visibilitychange",x),addEventListener("pagehide",ae),await Ne.refresh())},refresh:Me,async retry(){g&&!t&&g.epoch===R&&await F(g)},destroy(){t=!0,u++,$.cancel(),N.release(g?.deliveryTicket),Ne.destroy(),_?.abort(),l?.disconnect(),O?.(),S?.(),document.removeEventListener("click",ce,!0),document.removeEventListener("visibilitychange",x),removeEventListener("pagehide",ae),ae(),re(),b.dispose(),h=void 0}}}function An(n){let d=we(n.baseUrl),f=n.fetch??globalThis.fetch.bind(globalThis),b,w=0,h=0,t=!1,i=!1,u=!1,y=0,P=0,R=-1,B=!1,z="",m,s,E,_,O=new Set,S,l,o,T=(r,C)=>Z(n.onStatus,r,C),g=Pe(),M=()=>{try{return n.deliveryIdentity?.()}catch{return}},J=()=>JSON.stringify(M()),c=Se({storage:n.deliveryStorage,binding:()=>{let r=M();return r?.id?[d,n.scope.projectId,n.scope.environment,n.environmentId,r.type,r.id]:void 0},unavailable:()=>T("delivery_unavailable")}),$=()=>Date.now()<w&&performance.now()<h;function N(r){try{return $()&&r.target.release===n.appManifestRelease&&de(r.target.render,document,location.pathname,()=>{})}catch{return T("incompatible",r.id),!1}}function ee(){let r=o;o=void 0,r?.host.destroy(),r?.slot.remove()}async function te(r){if(r.dispatching)return;r.dispatching=!0;let C=y;try{let H=await r.process.open({operation:"entry_start",funnelId:r.entry.funnelId,versionId:r.entry.versionId,entryId:r.entry.id,release:n.appManifestRelease,locale:n.locale??"en"});c.accept(r.deliveryTicket,H.run.id);let{showFunnelRun:W}=await import("./funnel-runtime-host-T7QZU2NO.js");if(t||C!==y||l!==r)return;let V=document.createElement("div");n.container.append(V),R=P;let F=await W(V,{...n.host,client:H.controller,appManifestRelease:n.appManifestRelease,onDismiss(X){o?.process===r.process&&(o=void 0,V.remove()),Z(n.host?.onDismiss,X)}});if(t||C!==y||l!==r){F.destroy(),V.remove();return}o={entry:r.entry,process:r.process,host:F,slot:V,deliveryTicket:r.deliveryTicket},l=void 0,T("run_presented",r.entry.id)}catch(H){if(t||C!==y||l!==r)return;H instanceof G&&"result"in H?(c.release(r.deliveryTicket),l=void 0,r.process.destroy(),T("suppressed",r.entry.id),Q()):T("entry_unavailable",r.entry.id)}finally{r.dispatching=!1}}function Y(r){if(t||i||l||o||S||g.active||R===P||!N(r))return;let C=`${P}:${r.id}`;if(O.has(C))return;O.add(C);let H=P,W=y,V=J();g.start(r.delivery?.delaySeconds??0,()=>!t&&y===W&&P===H&&J()===V&&document.visibilityState!=="hidden"&&N(r)&&b?.entries.some(F=>F.id===r.id&&F.funnelId===r.funnelId&&F.versionId===r.versionId&&F.event===r.event&&JSON.stringify(F.target)===JSON.stringify(r.target)&&JSON.stringify(F.delivery)===JSON.stringify(r.delivery))===!0,()=>{let F=c.claim(r.id,r.funnelId,r.delivery?.maxPerSession,crypto.randomUUID());if(F===!1){T("frequency",r.id),Q();return}try{let X={entry:r,process:n.createProcess(r),visit:P,deliveryTicket:F};l=X,te(X)}catch(X){c.release(F),T("entry_unavailable",r.id),Z(n.host?.onError,X)}},()=>{O.delete(C)})}function Q(){B||t||(B=!0,queueMicrotask(()=>{if(B=!1,g.recheck(),!(t||i||document.visibilityState==="hidden"||!$()||l||o||S||g.active||R===P)){for(let r of b?.entries??[])if(r.event==="screen_enter"&&!O.has(`${P}:${r.id}`)&&N(r)){Y(r);break}}}))}function re(r){if(!r.isTrusted||r.defaultPrevented||!(r.target instanceof Element)||l||o||S||R===P)return;let C=be(document,()=>{});for(let H of b?.entries??[]){let W=H.target.button;if(H.event!=="button_click"||!W||!N(H))continue;let V=r.target.closest(W.selector);if(!(!V||V.tagName.toLowerCase()!==W.tag||C(W.selector)!==1||V.matches(":disabled")||V.closest('[inert],[hidden],[aria-hidden="true"]'))){Y(H);break}}}let le=()=>{let r=location.origin+location.pathname;r!==z&&(z=r,P++,g.cancel(),O.clear(),Q())};async function me(){if(t)return;if(s)return s;let r=y,C=new AbortController;m=C;let H,W=new Promise((ye,ue)=>{H=ue}),V=()=>H(new G("TIMEOUT","Funnel entry read cancelled"));C.signal.addEventListener("abort",V,{once:!0});let F=setTimeout(()=>C.abort(),n.timeoutMs??5e3),X=(async()=>{let ye=encodeURIComponent(JSON.stringify(["funnel-process/1"])),ue=async()=>{let ce=await f(`${d}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}&executionContracts=${ye}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:C.signal});if(!ce.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",ce.status);return ge.parse(await ce.json())},x=await Promise.race([ue(),W]),se=Date.parse(x.validatedAt),oe=Date.parse(x.validUntil);if(x.scope.projectId!==n.scope.projectId||x.scope.environment!==n.scope.environment||x.scope.environmentId!==n.environmentId||x.release!==n.appManifestRelease||oe<=Date.now()||se>Date.now()+5e3||oe<=se||oe-se>6e4)throw new G("INVALID_RESPONSE","Entry scope or deadline changed");t||r!==y||(b=x,w=oe,h=performance.now()+Math.min(oe-Date.now(),6e4),g.recheck(),Q())})();s=X;try{await X}finally{clearTimeout(F),C.signal.removeEventListener("abort",V),s===X&&(s=void 0)}}async function pe(){if(!(!u||t))try{await me()}catch{t||T("configuration_unavailable")}}let ae=Ie({document,run:pe,delay:()=>u&&!t?15e3:void 0});return{async start(){u||t||(u=!0,z=location.origin+location.pathname,E=Ee(le),_=new MutationObserver(Q),_.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",re,!0),document.addEventListener("visibilitychange",Q),await ae.refresh())},refresh:me,async retry(){l&&!t&&await te(l)},async syncIdentity(){g.cancel();let r=o??l??S;if(!r){i=!1,Q();return}try{let C=await r.process.syncIdentity();return i=!1,S===r&&(l={...r,visit:P},S=void 0,await te(l)),C}catch(C){throw r.process.view||(S={...r,visit:P},l=void 0,ee()),C}},async detach(){i=!0,y++,g.cancel(),m?.abort();let r=o??l??S;r&&(S={...r,visit:P}),l=void 0,ee(),r&&await r.process.detach()},destroy(){t=!0,y++,g.cancel(),ae.destroy(),m?.abort(),_?.disconnect(),E?.(),document.removeEventListener("click",re,!0),document.removeEventListener("visibilitychange",Q);let r=o??l??S;c.release(r?.deliveryTicket),l=void 0,S=void 0,ee(),r?.process.destroy(),b=void 0}}}async function Dn(n,d){return(await import("./paywall-6OURDDMJ.js")).showPaywall(n,d)}async function dt(){return await Promise.all([import("./paywall-6OURDDMJ.js"),import("./screen-renderer-HOIWGE5V.js")]),Dn}async function lt(...n){return n[1]=ze(n[1]),(await import("./paywall-session-ISBKCULC.js")).createPaywallSession(...n)}async function ut(...n){let d=n[1].signal?.aborted?void 0:We(n[1].client);try{return import("./screen-renderer-HOIWGE5V.js").catch(()=>{}),import("./paywall-6OURDDMJ.js").catch(()=>{}),await(await rn(()=>import("./funnel-runtime-host-T7QZU2NO.js"),n[1].prepared)).showFunnelRun(...n)}finally{d?.()}}async function rn(n,d){try{return await n()}catch(f){throw d&&d.state!=="adopted"&&await import("./funnel-paywall-prerender-SM7FH55U.js").then(b=>b.preparedInternals(d)?.release(),()=>{}),f}}async function ft(...n){return import("./screen-renderer-HOIWGE5V.js").catch(()=>{}),import("./paywall-6OURDDMJ.js").catch(()=>{}),(await rn(()=>import("./funnel-host-purchase-QRREIXEJ.js"),n[1].prepared)).showFunnelPurchase(...n)}async function mt(...n){return import("./funnel-host-purchase-QRREIXEJ.js").catch(()=>{}),import("./screen-renderer-HOIWGE5V.js").catch(()=>{}),(await import("./funnel-paywall-prerender-SM7FH55U.js")).prerenderFunnelPurchase(...n)}async function pt(){await Promise.all([import("./funnel-paywall-prerender-SM7FH55U.js"),import("./funnel-host-purchase-QRREIXEJ.js"),import("./paywall-6OURDDMJ.js"),import("./screen-renderer-HOIWGE5V.js"),import("./paywall-content-MVU3X635.js"),import("./check-response-MCT5RGOM.js"),import("./operation-contracts-C6CMAO6S.js")])}async function yt(...n){return(await import("./funnel-route-prediction-XNIKDJIM.js")).predictFunnelStart(...n)}async function ht(...n){return(await import("./funnel-route-prediction-XNIKDJIM.js")).predictedPaywallLoadingDocument(...n)}async function gt(...n){return(await import("./content-B3RWDOOH.js")).mountContent(...n)}async function vt(...n){return(await import("./content-B3RWDOOH.js")).prepareContent(...n)}export{G as LongplayError,I as MerchantBridgeError,yn as createBrowserFunnelCommandStorage,En as createBrowserFunnelPurchaseStorage,vn as createConfigurationSync,mn as createFeatureClient,wn as createFunnelClient,Rn as createFunnelPageExperiments,Sn as createFunnelProcess,bn as createFunnelPurchaseClient,Ae as createFunnelRunController,Cn as createIamFunnelEntries,An as createIamFunnelProcessEntries,Pn as createLocalFunnelClient,pn as createLongplay,Tn as createMerchantBridge,lt as createPaywallSession,In as evaluateFunnelNode,sn as formatCouponDiscount,an as formatCouponMoney,cn as formatCouponTerms,hn as getPaywallRecovery,un as isPaywallOperationComplete,fn as isPaywallOperationPending,ln as isPaywallUpdateOperation,dn as isPaywallUpdateQuote,gt as mountContent,yt as predictFunnelStart,ht as predictedPaywallLoadingDocument,pt as preloadFunnelPurchase,dt as preloadPaywall,vt as prepareContent,gn as preparePaywallFallback,mt as prerenderFunnelPurchase,ft as showFunnelPurchase,ut as showFunnelRun,Dn as showPaywall};
1
+ import{a as En,c as bn}from"./chunk-MVUNV5XR.js";import{a as We,c as Rn}from"./chunk-TIUD3N72.js";import{a as Ie}from"./chunk-W32FI2A2.js";import{a as pn,c as wn,d as Sn}from"./chunk-4NO6U4X6.js";import"./chunk-3ITNAFAH.js";import{a as In}from"./chunk-TM72XBM5.js";import"./chunk-2I2S5ZIH.js";import{h as mn,i as vn,k as Pn}from"./chunk-DB5S72HJ.js";import{E as Ae,d as Xe,f as Qe,g as ge,h as ve,i as Ye,w as yn}from"./chunk-3TSFGU4T.js";import"./chunk-W3B4GT74.js";import{a as ze}from"./chunk-Y2ASROJH.js";import"./chunk-TIOPNTMP.js";import"./chunk-RFWVXTZ7.js";import"./chunk-US65SQX4.js";import"./chunk-HYCLLEFU.js";import"./chunk-KSME3N3A.js";import{K as Ke}from"./chunk-LE32WTZ7.js";import"./chunk-SZZIYCXK.js";import"./chunk-IDDPWGQE.js";import{c as hn,e as gn}from"./chunk-LSHIR6QM.js";import"./chunk-OPUIFAQS.js";import"./chunk-HYX3EDZS.js";import{B as dn,C as ln,D as un,E as fn,c as an,d as sn,e as cn}from"./chunk-EGFVGCDG.js";import{A as Le,B as Be,D as He,F as qe,G as Ue,I as Ve,J as je,K as Ge,L as Je,M as Te,N as $e,z as _e}from"./chunk-YFLVGOCJ.js";import"./chunk-VILB5M4X.js";import{b as Ce}from"./chunk-FN462OVO.js";import"./chunk-FRRKTQNZ.js";import"./chunk-MQ5LJEWV.js";import"./chunk-JDIFYMSA.js";import"./chunk-TNPBYYAX.js";import"./chunk-KCN6OGYG.js";import"./chunk-PF6PRPRO.js";import{a as G}from"./chunk-ZDIWOE4Q.js";import"./chunk-FYD7CMS7.js";import{a as be,c as de}from"./chunk-J6KIN4RH.js";import"./chunk-SLUA7ABW.js";import{c as we,d as Ee}from"./chunk-GJSQZGBE.js";import"./chunk-3VUPVXAV.js";import"./chunk-B4SM2KRI.js";import{b as U}from"./chunk-XVCSRZX4.js";import{a as Z}from"./chunk-DSPLGTQI.js";import"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";var I=class extends Error{constructor(f,b=0,w=!1,h="fix_request"){super(f);this.code=f;this.status=b;this.retryable=w;this.recovery=h;this.name="MerchantBridgeError"}code;status;retryable;recovery};async function _n(n,d){if(!n.headers.get("content-type")?.split(";",1)[0].trim().match(/^application\/(?:json|[a-z0-9.+-]+\+json)$/i))throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");let f=n.body?.getReader();if(!f)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");let b=()=>{f.cancel().catch(()=>{})};d.addEventListener("abort",b,{once:!0});let w=0,h="",t=new TextDecoder("utf-8",{fatal:!0});try{for(d.throwIfAborted();;){let i=await f.read();if(d.throwIfAborted(),i.done)break;if(w+=i.value.byteLength,w>262144)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");h+=t.decode(i.value,{stream:!0})}return h+=t.decode(),JSON.parse(h)}catch(i){throw d.throwIfAborted(),i instanceof I?i:new I("MERCHANT_BRIDGE_INVALID_RESPONSE")}finally{d.removeEventListener("abort",b),await f.cancel().catch(()=>{}),f.releaseLock()}}function Tn(n){let d=qe.parse(n.origin),f=Ue.parse(n.manifest),b={projectId:n.scope.projectId,environmentId:n.scope.environmentId,environment:n.scope.environment};for(let m of["projectId","environmentId","environment"])if(f[m]!==n.scope[m])throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");let w=n.customerId===void 0?null:U.uuid().parse(n.customerId),h=0,t=null,i=null,u=new AbortController,y=n.fetch??globalThis.fetch;async function P(m,s,E,_,O){if(!f.capabilities.includes(m))throw new I("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let S=He[m];if(["merchant_catalog_reader","merchant_refund_authority","indiana_server_key"].includes(S.authority))throw new I("MERCHANT_BRIDGE_FORBIDDEN",403);let l=h,o=AbortSignal.any([u.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],..._?[_]:[]]);o.throwIfAborted();let T=new Headers(await n.headers?.());if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(/\bgg_(?:sk|ct|rt)_/.test(T.get("authorization")??"")||T.has("X-Indiana-Bridge-Signature")||T.has("X-Indiana-Bridge-Key-Id"))throw new I("MERCHANT_BRIDGE_FORBIDDEN",403);T.set(Be,String(_e)),T.set("Accept","application/json");let g=crypto.randomUUID();T.set("X-Request-Id",g),T.set("Content-Type","application/json");let M=await y(d+Le,{method:"POST",credentials:"include",redirect:"error",cache:"no-store",headers:T,signal:o,body:JSON.stringify({bridgeVersion:_e,requestId:g,command:S.command,scope:b,data:O??(E===void 0?{}:{operationId:E})})}),J=await _n(M,o);if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(!M.ok){let N=$e.safeParse(J);throw!N.success||N.data.scope.projectId!==n.scope.projectId||N.data.scope.environment!==n.scope.environment||N.data.scope.environmentId!==n.scope.environmentId||N.data.requestId!==g||N.data.command!==S.command?new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status):new I(N.data.error.code,M.status,N.data.error.retryable,N.data.error.recovery)}let c=Ve(U.unknown()).safeParse(J);if(!c.success||c.data.scope.projectId!==n.scope.projectId||c.data.scope.environment!==n.scope.environment||c.data.scope.environmentId!==n.scope.environmentId||c.data.requestId!==g||c.data.command!==S.command)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status);let $=s.safeParse(c.data.data);if(!$.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status);return $.data}function R(){if(!w)throw new I("MERCHANT_BRIDGE_UNAUTHENTICATED",401);return w}async function B(m,s,E,_){let O=R();if(_!==void 0&&Te.parse({operationId:_,customerId:O}),!f.capabilities.includes(m))throw new I("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let S=h,l=AbortSignal.any([u.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...s?[s]:[]]);l.throwIfAborted();let o,T=new Promise((g,M)=>{o=()=>M(l.reason),l.addEventListener("abort",o,{once:!0})});try{let M=E(async()=>{let c=await import("./merchant-bridge-contracts-7EHDNPJJ.js");if(l.throwIfAborted(),S!==h||w!==O)throw new DOMException("Merchant identity changed","AbortError");return c},l),J=await Promise.race([M,T]);return l.throwIfAborted(),J}finally{l.removeEventListener("abort",o)}}async function z(m,s,E,_){let O=R(),S=Te.parse({operationId:E,customerId:O}),l=await P(m,s,S.operationId,_,S);if(l.customerId!==O||l.operationId!==S.operationId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return l}return{async readPresentation(m){let s=await P("presentation",Ge,void 0,m);if(i!==null&&i!==s.nativeUserId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(s.presentation&&w!==null&&s.presentation.customerId!==w)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return i=s.nativeUserId,t=s.presentation,s},async createSession(m){let s=await P("session",je,void 0,m);if(i!==null&&i!==s.nativeUserId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(w!==null&&w!==s.session.customerId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(t&&t.customerId!==s.session.customerId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return w=s.session.customerId,i=s.nativeUserId,s.session},async reportPresentation(m,s){let E=R(),_=Je.parse(m);if(!t||t.customerId!==E||t.decisionId!==_.decisionId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return P("presentation_events",U.strictObject({queued:U.literal(!0)}),void 0,s,_)},async readCustomerCommerce(m){let s=R(),E=await B("customer_commerce",m,async(_,O)=>{let[S,l]=await Promise.all([_(),P("customer_commerce",U.unknown(),void 0,O)]),o=S.merchantBridgeCommerceSchema.safeParse(l);if(!o.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return o.data});if(E.customerId!==s)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return E},async executePurchase(m,s){let E=await B("purchases",s,async(_,O)=>z("purchases",(await _()).merchantBridgeOperationSchema,m,O),m);if(E.type!=="purchase")throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return E},readOperation:(m,s)=>B("operation_status",s,async(E,_)=>z("operation_status",(await E()).merchantOperationLookupSchema,m,_),m),async executeSubscriptionChange(m,s){let E=await B("subscription_changes",s,async(_,O)=>z("subscription_changes",(await _()).merchantBridgeOperationSchema,m,O),m);if(E.type!=="subscription_change")throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return E},reset(){h++,u.abort(),u=new AbortController,w=null,t=null,i=null}}}var en=U.strictObject({command:ve,target:Qe,runId:U.uuid().optional(),expiresAt:U.iso.datetime({offset:!0}).optional(),deliveryLimit:U.number().int().min(1).max(100).optional()}).refine(n=>n.command.release===n.target.release),Ze=U.strictObject({schemaVersion:U.literal(1),entries:U.array(en).max(4e3)});function nn(n){let d=!1,f=()=>{d||n.unavailable(),d=!0};function b(){return n.storage===!1?void 0:n.storage??globalThis.sessionStorage}function w(t){let i=b()?.getItem(t);if(!i)return[];if(i.length>1048576)throw Error("Entry recovery is too large");return Ze.parse(JSON.parse(i)).entries}function h(t,i){let u=b();if(!u)return;if(!i.length)return u.removeItem(t);let y=JSON.stringify(Ze.parse({schemaVersion:1,entries:i}));if(y.length>1048576)throw Error("Entry recovery is too large");u.setItem(t,y)}return{load(){try{let t=n.binding();if(!t||n.storage===!1)return;let i="indiana.funnel.entries.v1."+JSON.stringify(t);return{key:i,entries:w(i)}}catch{f();return}},retain(t,i){if(t)try{let u=en.parse(i);h(t,[...w(t).filter(y=>y.command.funnelId!==u.command.funnelId),u])}catch{f()}},forget(t,i){if(t)try{h(t,w(t).filter(u=>u.command.requestId!==i))}catch{f()}}}}var tn=U.strictObject({version:U.literal(1),runs:U.array(U.uuid()).max(100)}),De=new WeakMap,Oe=new WeakMap;function Se(n){let d=!1;function f(){d||n.unavailable(),d=!0}function b(t){let i=t.storage.getItem(t.key);if(!i)return[];if(i.length>8192)throw Error("Invalid entry delivery record");return tn.parse(JSON.parse(i)).runs}function w(t){let i=De.get(t.storage);i||De.set(t.storage,i=new Map);let u=i.get(t.key);return u||i.set(t.key,u=new Set),u}function h(t){if(!t)return;let i=De.get(t.storage),u=i?.get(t.key);u?.delete(t.requestId),u?.size===0&&i?.delete(t.key)}return{claim(t,i,u,y,P=!1){if(u!==void 0)try{let R=n.binding();if(!R)throw Error("Entry delivery identity is unavailable");let B={storage:n.storage??globalThis.sessionStorage,key:"indiana.funnel.delivery.v1."+JSON.stringify([...R,i,t]),requestId:y},z=b(B);if(Oe.get(B.storage)?.has(B.key))throw Error("Entry delivery storage is unavailable");B.storage.setItem(B.key,JSON.stringify({version:1,runs:z}));let m=w(B);return!P&&!m.has(y)&&z.length+m.size>=u?!1:(m.add(y),B)}catch{return f(),!1}},accept(t,i){if(t)try{let u=b(t);u.includes(i)||t.storage.setItem(t.key,JSON.stringify(tn.parse({version:1,runs:[...u,i].slice(-100)})))}catch{let u=Oe.get(t.storage);u||Oe.set(t.storage,u=new Set),u.add(t.key),f()}finally{h(t)}},release:h}}function Pe(){let n,d,f=()=>{clearTimeout(n),n=void 0;let b=d;d=void 0,b?.cancelled()};return{get active(){return d!==void 0},start(b,w,h,t){if(d)return;if(b===0){w()?h():t();return}let i={valid:w,cancelled:t};d=i,n=setTimeout(()=>{d===i&&(d=void 0,n=void 0,w()?h():t())},b*1e3)},recheck(){d&&!d.valid()&&f()},cancel:f}}var Re=n=>["running","waiting"].includes(n.status)&&!n.pendingRequest&&(n.stopped||!n.screen&&!n.paywall&&n.instruction?.type==="wait"&&n.instruction.kind!=="operation");function Cn(n){let d=we(n.baseUrl),f=n.scope,b=Ce(n),w=n.fetch??globalThis.fetch.bind(globalThis),h,t=!1,i=!1,u=0,y=0,P="",R=0,B=0,z=0,m=!1,s,E=!0,_,O,S,l,o,T=-1,g,M=e=>{g===e&&(N.release(e.deliveryTicket),g=void 0,x())},J=new Set,c=(e,a)=>Z(n.onStatus,e,a),$=Pe(),N=Se({storage:n.deliveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[d,f.projectId,f.environment,n.environmentId,"customer",e]:void 0},unavailable:()=>c("delivery_unavailable")}),ee=new Set,te=nn({storage:n.recoveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[d,f.projectId,f.environment,n.environmentId,n.appManifestRelease,e]:void 0},unavailable:()=>c("recovery_unavailable")}),Y=e=>te.forget(e.storageKey,e.command.requestId);function Q(e,a){a&&(e.runId=a.id,e.expiresAt=a.runExpiresAt),te.retain(e.storageKey,{command:e.command,target:e.target,...e.runId&&{runId:e.runId},...e.expiresAt&&{expiresAt:e.expiresAt},...e.deliveryLimit!==void 0&&{deliveryLimit:e.deliveryLimit}})}function re(){let e=o;o=void 0,e?.host.destroy(),e?.slot.remove(),e?.client.reset(),x()}let le=()=>$.active||g!==void 0||o!==void 0&&!o.background;function me(e,a){if(o?.client!==e)return;Q(o.recovery,a);let p=Re(a);o.slot.hidden=p,p!==o.background&&(o.background=p,p?c("run_background",o.entryId):T=y,x())}function pe(e,a,p){let v=e.client.view;if(!a||e.background||!v?.screen||v.paywall||v.pendingRequest||v.stopped||v.status!=="waiting")return;let K=Ke.parse({operation:"close",requestId:crypto.randomUUID(),nodeId:v.nodeId,visit:v.visit,revision:v.revision,customerToken:a}),j=Ce({...n,session:void 0});j.requestWithCredential("funnels",K,e.runToken,{keepalive:p}).then(()=>Y(e.recovery)).catch(()=>{}).finally(()=>j.dispose())}let ae=()=>{o&&pe(o,n.session.peek(),!0)},r=()=>Date.now()<B&&performance.now()<z;function C(e){if(e.target.release!==n.appManifestRelease||!r())return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return c("incompatible",e.id),!1}}function H(e){if(t||e.epoch!==R||e.visit!==y||document.visibilityState==="hidden")return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function W(e){if(le()){c("in_progress",e.id);return}let a=R,p=y;$.start(e.delivery?.delaySeconds??0,()=>!t&&a===R&&p===y&&document.visibilityState!=="hidden"&&C(e)&&h?.entries.some(v=>v.id===e.id&&v.funnelId===e.funnelId&&v.versionId===e.versionId&&v.event===e.event&&JSON.stringify(v.target)===JSON.stringify(e.target)&&JSON.stringify(v.delivery)===JSON.stringify(e.delivery))===!0,()=>{V(e)},()=>{J.delete(`${e.funnelId}:${e.id}`)})}async function V(e){if(le()){c("in_progress",e.id);return}if(!n.session.peek()){c("identity_required",e.id);return}let a=te.load(),p=a?.entries.find(A=>A.command.funnelId===e.funnelId&&(!A.expiresAt||Date.parse(A.expiresAt)>Date.now()));if(p){if(!X(p)){c("recovery_pending",e.id);return}let A={...p,storageKey:a.key,epoch:R,visit:y};ee.add(A.command.requestId),g=A,await F(A);return}let v=crypto.randomUUID(),K=N.claim(e.id,e.funnelId,e.delivery?.maxPerSession,v);if(K===!1){c("frequency",e.id),x();return}let j={freshStart:!0,deliveryLimit:e.delivery?.maxPerSession,deliveryTicket:K,command:ve.parse({operation:"entry_start",entryId:e.id,funnelId:e.funnelId,versionId:e.versionId,release:n.appManifestRelease,requestId:v,locale:document.documentElement.lang||"en"}),epoch:R,visit:y,target:e.target,storageKey:a?.key};ee.add(j.command.requestId),g=j,await F(j)}async function F(e){if(e.dispatching)return;e.dispatching=!0;let a=e.freshStart===!0;e.freshStart=!1;let p,v=!1,K=!1;async function j(A){if(e.epoch!==R)return;let D=A.view;if(!(e.storageKey&&D&&(Re(D)||D.paywall||D.pendingRequest))&&D&&["running","waiting"].includes(D.status))try{await A.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:D.nodeId,visit:D.visit,revision:D.revision}),Y(e)}catch(k){if(!(k instanceof G&&k.code==="FORBIDDEN"))throw k}}try{if(!e.deliveryTicket&&e.deliveryLimit!==void 0){let q=N.claim(e.command.entryId,e.command.funnelId,e.deliveryLimit,e.command.requestId,!0);q!==!1&&(e.deliveryTicket=q)}Q(e),c("starting",e.command.entryId);let A=await b.request("funnels",e.command),D=Ye.safeParse(A);if(D.success){if(D.data.scope.projectId!==f.projectId||D.data.scope.environment!==f.environment)throw new G("SCOPE_MISMATCH","Entry scope changed");e.epoch===R&&c(D.data.reason,e.command.entryId),Y(e),M(e);return}let k=Xe.parse(A);if(!k.runToken||k.scope.projectId!==f.projectId||k.scope.environment!==f.environment||k.run.source.type!=="funnel"||k.run.source.id!==e.command.funnelId||k.run.source.versionId!==e.command.versionId||e.runId!==void 0&&k.run.id!==e.runId)throw new G("INVALID_RESPONSE","Invalid entry Run");if(N.accept(e.deliveryTicket,k.run.id),e.epoch!==R){M(e),c("identity_changed",e.command.entryId);return}Q(e,k.run);let L=Ae({...n,runToken:k.runToken,funnelId:e.command.funnelId,initialResponse:a?A:void 0});p=L,K=!0,await L.get(),K=!1;let ne=L.view;if(!ne||ne.id!==k.run.id||ne.source.type!=="funnel"||ne.source.id!==e.command.funnelId||ne.source.versionId!==e.command.versionId)throw new G("INVALID_RESPONSE","Entry Run version changed");if(!["running","waiting"].includes(ne.status)){Y(e),M(e),c("run_ended",e.command.entryId);return}let{showFunnelRun:fe}=await import("./funnel-runtime-host-NZAV6C5O.js");if(!H(e)){await j(L),c("left_screen",e.command.entryId),M(e);return}let Fe=!1,xe=!1;if(o&&!o.background){await j(L),c("in_progress",e.command.entryId),M(e);return}o&&re();let ie=document.createElement("div");ie.hidden=Re(ne),n.container.append(ie);let ke=await fe(ie,{...n.host,client:L,appManifestRelease:n.appManifestRelease,onState(q){me(L,q),Z(n.host?.onState,q)},onDismiss(q){Fe=!0,ie.remove(),q&&!["running","waiting"].includes(q.status)&&Y(e),o?.client===L&&(o=void 0,L.reset(),x(),q&&q.status!=="completed"&&c("run_ended",e.command.entryId)),Z(n.host?.onDismiss,q)},onComplete(q){xe=!0,Y(e),o?.client===L&&re(),Z(n.host?.onComplete,q)},onError(q){Z(n.host?.onError,q),o?.client===L&&q instanceof G&&q.code==="FORBIDDEN"&&(Y(e),re(),c("run_ended",e.command.entryId))}}).catch(q=>{throw ie.remove(),q});if(!H(e)||Fe||xe){ke.destroy(),ie.remove(),H(e)||await j(L),M(e);return}let he=Re(L.view??ne);ie.hidden=he,o={host:ke,client:L,slot:ie,entryId:e.command.entryId,background:he,runToken:k.runToken,owner:n.session.peek(),recovery:e},he||(T=e.visit),v=!0,M(e),c("started",e.command.entryId),he&&c("run_background",e.command.entryId)}catch(A){A instanceof G&&(!p||K&&A.code==="FORBIDDEN")&&A.status!==void 0&&A.status>=400&&A.status<500&&!A.retryable&&(Y(e),M(e)),e.epoch===R&&!t&&(c("start_failed",e.command.entryId),Z(n.host?.onError,A))}finally{v||p?.reset(),e.dispatching=!1}}function X(e){if(e.command.release!==n.appManifestRelease||e.target.release!==n.appManifestRelease)return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function ye(){if(le())return!1;let e=te.load();for(let a of e?.entries??[]){if(a.expiresAt&&Date.parse(a.expiresAt)<=Date.now()){te.forget(e.key,a.command.requestId);continue}if(a.command.requestId===o?.recovery.command.requestId||ee.has(a.command.requestId)||!X(a))continue;ee.add(a.command.requestId);let p={...a,storageKey:e.key,epoch:R,visit:y};return g=p,F(p),!0}return!1}function ue(){if(m=!1,$.recheck(),t||!i||document.visibilityState==="hidden")return;se();let e=o!==void 0&&!o.background;if(e&&(T=y),!ye()){if(!r()){E=!0;return}E=!1;for(let a of h?.entries??[]){let p=`${a.funnelId}:${a.id}`;if(!(a.event!=="screen_enter"||J.has(p)||!C(a))){if(!n.session.peek()){c("identity_required",a.id);continue}if(T===y){J.add(p),e&&c("in_progress",a.id);continue}if(g||$.active){c("in_progress",a.id);return}J.add(p),W(a);break}}}}let x=()=>{!m&&!t&&(m=!0,queueMicrotask(ue))};function se(){let e=location.origin+location.pathname;return e===P?!1:(P=e,y++,$.cancel(),E=!0,J.clear(),ee.clear(),!0)}function oe(){se()&&x()}function ce(e){if(!e.isTrusted||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||document.visibilityState==="hidden")return;let a=e.target;if(!(a instanceof Element)||a.closest("[data-indiana-funnel]"))return;let p=a.closest("button,a,input");if(!(!p||p.matches(":disabled,[aria-disabled='true']")||p.closest("[hidden],[inert],[aria-hidden='true']")))for(let v of h?.entries??[]){let K=v.target.button;if(!(v.event!=="button_click"||!K||!C(v))){try{let j=be(document);if(!p.matches(K.selector)||j(K.selector,p)!==1)continue}catch{c("incompatible",v.id);continue}W(v);break}}}async function Me(){if(t)return;if(s)return s;let e=++u,a=new AbortController;_=a;let p,v=new Promise((A,D)=>{p=()=>D(new G("TIMEOUT","Funnel entry configuration read cancelled or timed out")),a.signal.addEventListener("abort",p,{once:!0})}),K=setTimeout(()=>a.abort(),n.timeoutMs??5e3),j=(async()=>{let A=async()=>{let fe=await w(`${d}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:a.signal});if(!fe.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",fe.status);return ge.parse(await fe.json())},D=await Promise.race([A(),v]),k=Date.parse(D.validatedAt),L=Date.parse(D.validUntil);if(D.scope.projectId!==f.projectId||D.scope.environment!==f.environment||D.scope.environmentId!==n.environmentId||D.release!==n.appManifestRelease||L<=Date.now()||k>Date.now()+5e3||L-k>6e4||L<=k)throw new G("INVALID_RESPONSE","Entry configuration scope or deadline changed");if(t||e!==u)return;let ne=h===void 0;h=D,B=L,z=performance.now()+Math.min(L-Date.now(),6e4),$.recheck(),(ne||E)&&x()})();s=j;try{await j}finally{clearTimeout(K),a.signal.removeEventListener("abort",p),s===j&&(s=void 0)}}async function on(){if(!(!i||t)){try{await Me()}catch{t||c("configuration_unavailable")}x()}}let Ne=Ie({document,run:on,delay:()=>i&&!t?15e3:void 0});return{async start(){i||t||(i=!0,P=location.origin+location.pathname,O=Ee(oe),S=n.session.subscribeIdentity(()=>{R++,$.cancel(),N.release(g?.deliveryTicket),E=!0,g=void 0,J.clear(),T=-1,ee.clear(),o&&pe(o,o.owner,!1),re(),x()}),l=new MutationObserver(x),l.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",ce,!0),document.addEventListener("visibilitychange",x),addEventListener("pagehide",ae),await Ne.refresh())},refresh:Me,async retry(){g&&!t&&g.epoch===R&&await F(g)},destroy(){t=!0,u++,$.cancel(),N.release(g?.deliveryTicket),Ne.destroy(),_?.abort(),l?.disconnect(),O?.(),S?.(),document.removeEventListener("click",ce,!0),document.removeEventListener("visibilitychange",x),removeEventListener("pagehide",ae),ae(),re(),b.dispose(),h=void 0}}}function An(n){let d=we(n.baseUrl),f=n.fetch??globalThis.fetch.bind(globalThis),b,w=0,h=0,t=!1,i=!1,u=!1,y=0,P=0,R=-1,B=!1,z="",m,s,E,_,O=new Set,S,l,o,T=(r,C)=>Z(n.onStatus,r,C),g=Pe(),M=()=>{try{return n.deliveryIdentity?.()}catch{return}},J=()=>JSON.stringify(M()),c=Se({storage:n.deliveryStorage,binding:()=>{let r=M();return r?.id?[d,n.scope.projectId,n.scope.environment,n.environmentId,r.type,r.id]:void 0},unavailable:()=>T("delivery_unavailable")}),$=()=>Date.now()<w&&performance.now()<h;function N(r){try{return $()&&r.target.release===n.appManifestRelease&&de(r.target.render,document,location.pathname,()=>{})}catch{return T("incompatible",r.id),!1}}function ee(){let r=o;o=void 0,r?.host.destroy(),r?.slot.remove()}async function te(r){if(r.dispatching)return;r.dispatching=!0;let C=y;try{let H=await r.process.open({operation:"entry_start",funnelId:r.entry.funnelId,versionId:r.entry.versionId,entryId:r.entry.id,release:n.appManifestRelease,locale:n.locale??"en"});c.accept(r.deliveryTicket,H.run.id);let{showFunnelRun:W}=await import("./funnel-runtime-host-NZAV6C5O.js");if(t||C!==y||l!==r)return;let V=document.createElement("div");n.container.append(V),R=P;let F=await W(V,{...n.host,client:H.controller,appManifestRelease:n.appManifestRelease,onDismiss(X){o?.process===r.process&&(o=void 0,V.remove()),Z(n.host?.onDismiss,X)}});if(t||C!==y||l!==r){F.destroy(),V.remove();return}o={entry:r.entry,process:r.process,host:F,slot:V,deliveryTicket:r.deliveryTicket},l=void 0,T("run_presented",r.entry.id)}catch(H){if(t||C!==y||l!==r)return;H instanceof G&&"result"in H?(c.release(r.deliveryTicket),l=void 0,r.process.destroy(),T("suppressed",r.entry.id),Q()):T("entry_unavailable",r.entry.id)}finally{r.dispatching=!1}}function Y(r){if(t||i||l||o||S||g.active||R===P||!N(r))return;let C=`${P}:${r.id}`;if(O.has(C))return;O.add(C);let H=P,W=y,V=J();g.start(r.delivery?.delaySeconds??0,()=>!t&&y===W&&P===H&&J()===V&&document.visibilityState!=="hidden"&&N(r)&&b?.entries.some(F=>F.id===r.id&&F.funnelId===r.funnelId&&F.versionId===r.versionId&&F.event===r.event&&JSON.stringify(F.target)===JSON.stringify(r.target)&&JSON.stringify(F.delivery)===JSON.stringify(r.delivery))===!0,()=>{let F=c.claim(r.id,r.funnelId,r.delivery?.maxPerSession,crypto.randomUUID());if(F===!1){T("frequency",r.id),Q();return}try{let X={entry:r,process:n.createProcess(r),visit:P,deliveryTicket:F};l=X,te(X)}catch(X){c.release(F),T("entry_unavailable",r.id),Z(n.host?.onError,X)}},()=>{O.delete(C)})}function Q(){B||t||(B=!0,queueMicrotask(()=>{if(B=!1,g.recheck(),!(t||i||document.visibilityState==="hidden"||!$()||l||o||S||g.active||R===P)){for(let r of b?.entries??[])if(r.event==="screen_enter"&&!O.has(`${P}:${r.id}`)&&N(r)){Y(r);break}}}))}function re(r){if(!r.isTrusted||r.defaultPrevented||!(r.target instanceof Element)||l||o||S||R===P)return;let C=be(document,()=>{});for(let H of b?.entries??[]){let W=H.target.button;if(H.event!=="button_click"||!W||!N(H))continue;let V=r.target.closest(W.selector);if(!(!V||V.tagName.toLowerCase()!==W.tag||C(W.selector)!==1||V.matches(":disabled")||V.closest('[inert],[hidden],[aria-hidden="true"]'))){Y(H);break}}}let le=()=>{let r=location.origin+location.pathname;r!==z&&(z=r,P++,g.cancel(),O.clear(),Q())};async function me(){if(t)return;if(s)return s;let r=y,C=new AbortController;m=C;let H,W=new Promise((ye,ue)=>{H=ue}),V=()=>H(new G("TIMEOUT","Funnel entry read cancelled"));C.signal.addEventListener("abort",V,{once:!0});let F=setTimeout(()=>C.abort(),n.timeoutMs??5e3),X=(async()=>{let ye=encodeURIComponent(JSON.stringify(["funnel-process/1"])),ue=async()=>{let ce=await f(`${d}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}&executionContracts=${ye}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:C.signal});if(!ce.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",ce.status);return ge.parse(await ce.json())},x=await Promise.race([ue(),W]),se=Date.parse(x.validatedAt),oe=Date.parse(x.validUntil);if(x.scope.projectId!==n.scope.projectId||x.scope.environment!==n.scope.environment||x.scope.environmentId!==n.environmentId||x.release!==n.appManifestRelease||oe<=Date.now()||se>Date.now()+5e3||oe<=se||oe-se>6e4)throw new G("INVALID_RESPONSE","Entry scope or deadline changed");t||r!==y||(b=x,w=oe,h=performance.now()+Math.min(oe-Date.now(),6e4),g.recheck(),Q())})();s=X;try{await X}finally{clearTimeout(F),C.signal.removeEventListener("abort",V),s===X&&(s=void 0)}}async function pe(){if(!(!u||t))try{await me()}catch{t||T("configuration_unavailable")}}let ae=Ie({document,run:pe,delay:()=>u&&!t?15e3:void 0});return{async start(){u||t||(u=!0,z=location.origin+location.pathname,E=Ee(le),_=new MutationObserver(Q),_.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",re,!0),document.addEventListener("visibilitychange",Q),await ae.refresh())},refresh:me,async retry(){l&&!t&&await te(l)},async syncIdentity(){g.cancel();let r=o??l??S;if(!r){i=!1,Q();return}try{let C=await r.process.syncIdentity();return i=!1,S===r&&(l={...r,visit:P},S=void 0,await te(l)),C}catch(C){throw r.process.view||(S={...r,visit:P},l=void 0,ee()),C}},async detach(){i=!0,y++,g.cancel(),m?.abort();let r=o??l??S;r&&(S={...r,visit:P}),l=void 0,ee(),r&&await r.process.detach()},destroy(){t=!0,y++,g.cancel(),ae.destroy(),m?.abort(),_?.disconnect(),E?.(),document.removeEventListener("click",re,!0),document.removeEventListener("visibilitychange",Q);let r=o??l??S;c.release(r?.deliveryTicket),l=void 0,S=void 0,ee(),r?.process.destroy(),b=void 0}}}async function Dn(n,d){return(await import("./paywall-DKTGQZDJ.js")).showPaywall(n,d)}async function dt(){return await Promise.all([import("./paywall-DKTGQZDJ.js"),import("./screen-renderer-HW2WXDTR.js")]),Dn}async function lt(...n){return n[1]=ze(n[1]),(await import("./paywall-session-YKE2CHHI.js")).createPaywallSession(...n)}async function ut(...n){let d=n[1].signal?.aborted?void 0:We(n[1].client);try{return import("./screen-renderer-HW2WXDTR.js").catch(()=>{}),import("./paywall-DKTGQZDJ.js").catch(()=>{}),await(await rn(()=>import("./funnel-runtime-host-NZAV6C5O.js"),n[1].prepared)).showFunnelRun(...n)}finally{d?.()}}async function rn(n,d){try{return await n()}catch(f){throw d&&d.state!=="adopted"&&await import("./funnel-paywall-prerender-MD4UI2AP.js").then(b=>b.preparedInternals(d)?.release(),()=>{}),f}}async function ft(...n){return import("./screen-renderer-HW2WXDTR.js").catch(()=>{}),import("./paywall-DKTGQZDJ.js").catch(()=>{}),(await rn(()=>import("./funnel-host-purchase-HBQOWEES.js"),n[1].prepared)).showFunnelPurchase(...n)}async function mt(...n){return import("./funnel-host-purchase-HBQOWEES.js").catch(()=>{}),import("./screen-renderer-HW2WXDTR.js").catch(()=>{}),(await import("./funnel-paywall-prerender-MD4UI2AP.js")).prerenderFunnelPurchase(...n)}async function pt(){await Promise.all([import("./funnel-paywall-prerender-MD4UI2AP.js"),import("./funnel-host-purchase-HBQOWEES.js"),import("./paywall-DKTGQZDJ.js"),import("./screen-renderer-HW2WXDTR.js"),import("./paywall-content-SML4CL2Q.js"),import("./check-response-MCT5RGOM.js"),import("./operation-contracts-C6CMAO6S.js")])}async function yt(...n){return(await import("./funnel-route-prediction-XNIKDJIM.js")).predictFunnelStart(...n)}async function ht(...n){return(await import("./funnel-route-prediction-XNIKDJIM.js")).predictedPaywallLoadingDocument(...n)}async function gt(...n){return(await import("./content-VTHRQSFT.js")).mountContent(...n)}async function vt(...n){return(await import("./content-VTHRQSFT.js")).prepareContent(...n)}export{G as LongplayError,I as MerchantBridgeError,yn as createBrowserFunnelCommandStorage,En as createBrowserFunnelPurchaseStorage,vn as createConfigurationSync,mn as createFeatureClient,wn as createFunnelClient,Rn as createFunnelPageExperiments,Sn as createFunnelProcess,bn as createFunnelPurchaseClient,Ae as createFunnelRunController,Cn as createIamFunnelEntries,An as createIamFunnelProcessEntries,Pn as createLocalFunnelClient,pn as createLongplay,Tn as createMerchantBridge,lt as createPaywallSession,In as evaluateFunnelNode,sn as formatCouponDiscount,an as formatCouponMoney,cn as formatCouponTerms,hn as getPaywallRecovery,un as isPaywallOperationComplete,fn as isPaywallOperationPending,ln as isPaywallUpdateOperation,dn as isPaywallUpdateQuote,gt as mountContent,yt as predictFunnelStart,ht as predictedPaywallLoadingDocument,pt as preloadFunnelPurchase,dt as preloadPaywall,vt as prepareContent,gn as preparePaywallFallback,mt as prerenderFunnelPurchase,ft as showFunnelPurchase,ut as showFunnelRun,Dn as showPaywall};