@tinkerlandai/indiana-sdk 0.8.1 → 0.8.4

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 (54) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +44 -3
  3. package/README.zh-CN.md +8 -0
  4. package/dist/{ai-usage-JoM7ZWk-.d.ts → ai-usage-DUlre7JC.d.ts} +1 -1
  5. package/dist/{api-JVC7x2FV.d.ts → api-XDc4pRlN.d.ts} +444 -17
  6. package/dist/chunk-3F2NQOR2.js +1 -0
  7. package/dist/chunk-663UOBHL.js +1 -0
  8. package/dist/chunk-BUDTHBFF.js +173 -0
  9. package/dist/chunk-EJTBSGLV.js +10 -0
  10. package/dist/{chunk-USLZX2ZA.js → chunk-F2GOIBDQ.js} +1 -1
  11. package/dist/{chunk-YWFNWK7C.js → chunk-GRLMT5PR.js} +1 -1
  12. package/dist/chunk-LMR2TM3X.js +1 -0
  13. package/dist/chunk-OBYJWIRB.js +1 -0
  14. package/dist/chunk-RZBZ6LCT.js +4 -0
  15. package/dist/{chunk-6HG7U6AU.js → chunk-SOQO2RDZ.js} +1 -1
  16. package/dist/chunk-SSHUBTT3.js +1 -0
  17. package/dist/chunk-SSLZKIIU.js +1 -0
  18. package/dist/{chunk-KSNOXNTC.js → chunk-VVV3JNS3.js} +1 -1
  19. package/dist/{configuration-sync-BexM2qbg.d.ts → configuration-sync-Ce3dShy7.d.ts} +8 -3
  20. package/dist/content-2FCUY6XX.js +1 -0
  21. package/dist/{customer-page-WUQVK_tp.d.ts → customer-page-9B97Qdt_.d.ts} +21 -1
  22. package/dist/{errors-DrdTlPwf.d.ts → errors-C8lRYZ0n.d.ts} +48 -1
  23. package/dist/{funnel-local-client-D1Fe7CZ6.d.ts → funnel-local-client-CUGavICI.d.ts} +69 -40
  24. package/dist/{funnel-runtime-host-CAMI6BJS.js → funnel-runtime-host-ENRTSXPJ.js} +1 -1
  25. package/dist/index.d.ts +175 -35
  26. package/dist/index.js +1 -1
  27. package/dist/native-shell.js +1 -1
  28. package/dist/openrouter.d.ts +3 -3
  29. package/dist/openrouter.js +1 -1
  30. package/dist/page.d.ts +2 -2
  31. package/dist/page.js +1 -1
  32. package/dist/paywall-734GWAS4.js +1 -0
  33. package/dist/popup.d.ts +15 -5
  34. package/dist/popup.js +1 -1
  35. package/dist/react-native.d.ts +97 -4
  36. package/dist/react-native.js +1 -1
  37. package/dist/screen-renderer-DLXDQQKK.js +1 -0
  38. package/dist/server.d.ts +18 -15
  39. package/dist/server.js +1 -1
  40. package/dist/src-CLEFCTAU.js +1 -0
  41. package/dist/visual.js +2 -2
  42. package/package.json +1 -1
  43. package/dist/chunk-3BQFJANQ.js +0 -1
  44. package/dist/chunk-56AYS7RS.js +0 -1
  45. package/dist/chunk-AE4CUTUE.js +0 -1
  46. package/dist/chunk-AEUFCOFG.js +0 -1
  47. package/dist/chunk-F767CM3T.js +0 -7
  48. package/dist/chunk-X747SY26.js +0 -4
  49. package/dist/chunk-X7JJAEQQ.js +0 -350
  50. package/dist/content-YNL2CRJZ.js +0 -1
  51. package/dist/paywall-MXRMMF3R.js +0 -1
  52. package/dist/screen-renderer-P7MLBHY5.js +0 -1
  53. package/dist/src-G7UQB3QE.js +0 -1
  54. package/dist/{screen-i6eHL11m.d.ts → screen-BpAejkn0.d.ts} +1 -1
package/dist/index.d.ts CHANGED
@@ -1,21 +1,26 @@
1
1
  import * as zod from 'zod';
2
2
  import { z } from 'zod';
3
- import { C as CouponInput, S as ScreenAnswers, s as screenInputBindingsSchema, a as SurfaceData, b as CustomerDataIntent, O as Offer } from './customer-page-WUQVK_tp.js';
4
- export { c as OfferUnavailableReason } from './customer-page-WUQVK_tp.js';
3
+ import { C as CouponInput, S as ScreenAnswers, s as screenInputBindingsSchema, a as SurfaceData, b as CustomerDataIntent, O as Offer } from './customer-page-9B97Qdt_.js';
4
+ export { c as OfferUnavailableReason } from './customer-page-9B97Qdt_.js';
5
5
  import { J as JsonValue, F as FeatureResult } from './growth-rules-B4YYy64R.js';
6
- import { S as StackNode } from './screen-i6eHL11m.js';
7
- import { F as FunnelRuntimeResponse, a as FunnelRunView, b as FunnelMutation, c as FunnelPurchaseRecovery, d as FunnelSegmentPrediction, P as PaywallDelivery, e as PaywallResolution, f as FunnelDataQueries, I as IndianaOptions, g as PaywallSession, S as SubscriptionOperation, h as FeatureClientOptions, R as RemoteFeatureResult, i as FunnelCommandStorage, j as FunnelStartInput } from './funnel-local-client-D1Fe7CZ6.js';
8
- export { k as FeatureClient, l as FunnelNodeEvaluationContext, m as FunnelPendingEntry, L as LocalFunnelClient, n as LocalFunnelClientOptions, o as PaywallPurchaseInput, p as PaywallStartInput, q as createFeatureClient, r as createLocalFunnelClient, s as createPaywallSession, t as evaluateFunnelNode } from './funnel-local-client-D1Fe7CZ6.js';
9
- import { I as InvoiceModeParams, A as ApiInput, O as OfferingItem } from './api-JVC7x2FV.js';
10
- import { C as ConfigurationSync } from './configuration-sync-BexM2qbg.js';
11
- export { a as ConfigurationStorage, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-BexM2qbg.js';
12
- export { I as IndianaError } from './errors-DrdTlPwf.js';
6
+ import { S as StackNode } from './screen-BpAejkn0.js';
7
+ import { F as FunnelRuntimeResponse, a as FunnelRunView, b as FunnelMutation, c as FunnelPurchaseRecovery, d as FunnelSegmentPrediction, P as PaywallDelivery, e as PaywallResolution, f as FunnelDataQueries, I as IndianaOptions, g as PaywallSession, S as SubscriptionOperation, h as FeatureClientOptions, R as RemoteFeatureResult, i as FunnelCommandStorage, j as FunnelStartInput } from './funnel-local-client-CUGavICI.js';
8
+ export { k as FeatureClient, l as FunnelNodeEvaluationContext, m as FunnelPendingEntry, L as LocalFunnelClient, n as LocalFunnelClientOptions, o as PaywallPurchaseInput, p as PaywallStartInput, q as createFeatureClient, r as createLocalFunnelClient, s as createPaywallSession, t as evaluateFunnelNode } from './funnel-local-client-CUGavICI.js';
9
+ import { I as InvoiceModeParams, A as ApiInput, O as OfferingItem } from './api-XDc4pRlN.js';
10
+ import { C as ConfigurationSync } from './configuration-sync-Ce3dShy7.js';
11
+ export { a as ConfigurationStorage, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-Ce3dShy7.js';
12
+ import { P as PushAddressObservation } from './errors-C8lRYZ0n.js';
13
+ export { I as IndianaError, a as PushHost, b as PushJournal } from './errors-C8lRYZ0n.js';
13
14
  import 'zod/v4';
14
15
 
15
16
  /** Currency always comes from business data; locale only controls notation. No currency conversion. */
16
17
  declare function formatCouponMoney(cents: number, currency: string, locale?: string): string;
17
18
  declare function formatCouponDiscount(discount: CouponInput["discount"], locale?: string): string;
18
- declare function formatCouponTerms(coupon: Pick<CouponInput, "discount" | "duration">, locale?: string, billing?: "month" | "year" | "any"): string;
19
+ declare function formatCouponTerms(coupon: Pick<CouponInput, "discount" | "duration"> & {
20
+ appliesTo?: {
21
+ type: CouponInput["appliesTo"]["type"];
22
+ };
23
+ }, locale?: string, billing?: "month" | "year" | "any"): string;
19
24
 
20
25
  declare const funnelOpenInSchema: z.ZodEnum<{
21
26
  same_window: "same_window";
@@ -304,6 +309,8 @@ type ContentActionIntent = {
304
309
  requestedClose: boolean;
305
310
  };
306
311
  type ContentHostOptions = {
312
+ /** Cancel preparation or dispose the presentation on host/identity teardown. */
313
+ signal?: AbortSignal;
307
314
  content: ContentVersion;
308
315
  locale?: string;
309
316
  inputs?: Record<string, JsonValue>;
@@ -316,6 +323,16 @@ type ContentHostOptions = {
316
323
  /** Explicit host mount. Banner never creates an overlay or a blocking Funnel Run. */
317
324
  declare function mountContent$1(container: HTMLElement, options: ContentHostOptions): Promise<{
318
325
  destroy: () => void;
326
+ show: () => void;
327
+ readonly pendingAction: ContentActionIntent | null;
328
+ retryAction: () => Promise<void>;
329
+ updateCapabilities: (data: SurfaceData) => void | undefined;
330
+ }>;
331
+ /** Prepare already-resolved content without displaying it or executing actions.
332
+ * Resolves after the first render. Call show() from the opening click. */
333
+ declare function prepareContent$1(container: HTMLElement, options: ContentHostOptions): Promise<{
334
+ destroy: () => void;
335
+ show: () => void;
319
336
  readonly pendingAction: ContentActionIntent | null;
320
337
  retryAction: () => Promise<void>;
321
338
  updateCapabilities: (data: SurfaceData) => void | undefined;
@@ -921,7 +938,7 @@ declare function createFunnelRunController(options: IndianaOptions & {
921
938
  event: string;
922
939
  } | {
923
940
  type: "api";
924
- operation: "update" | "attach" | "refund" | "readBalanceSource" | "adjustBalance" | "readUsage" | "setUsage" | "manageBalanceGrant" | "listBalanceGrants" | "restoreNativePurchase" | "setupPayment" | "readPaymentSetup" | "verifySubscriptions" | "previewAttach" | "readSubscriptionOperation" | "previewUpdate" | "readSubscriptionUpdate" | "previewRefund" | "readRefund" | "readBillingControls" | "prepareBillingAuthorization" | "confirmBillingAuthorization" | "setBillingCoupons" | "revokeBillingAuthorization" | "listBillingInvoices" | "confirmBillingAdjustment" | "manageBillingLimits" | "manageUsageEntity" | "readUsageAnalytics" | "readCreditAnalytics" | "submitUsageBatch" | "readUsageBatch" | "checkEntitlement" | "resolveOffering" | "readHoldings" | "readLedger" | "readBillingInvoice" | "readCreditStatement" | "quoteBalance" | "trackUsage" | "mutateBalance" | "redeemReward" | "createReferralCode" | "claimRewardProduct" | "readSeats" | "manageSeat" | "redeemCoupon" | "listOffers" | "grantOffer";
941
+ operation: "update" | "attach" | "refund" | "sendMessage" | "readBalanceSource" | "adjustBalance" | "readUsage" | "setUsage" | "manageBalanceGrant" | "listBalanceGrants" | "restoreNativePurchase" | "setupPayment" | "readPaymentSetup" | "verifySubscriptions" | "previewAttach" | "readSubscriptionOperation" | "previewUpdate" | "readSubscriptionUpdate" | "previewRefund" | "readRefund" | "readBillingControls" | "prepareBillingAuthorization" | "confirmBillingAuthorization" | "setBillingCoupons" | "revokeBillingAuthorization" | "listBillingInvoices" | "confirmBillingAdjustment" | "manageBillingLimits" | "manageUsageEntity" | "readUsageAnalytics" | "readCreditAnalytics" | "submitUsageBatch" | "readUsageBatch" | "checkEntitlement" | "resolveOffering" | "readHoldings" | "readLedger" | "readBillingInvoice" | "readCreditStatement" | "quoteBalance" | "trackUsage" | "mutateBalance" | "redeemReward" | "createReferralCode" | "claimRewardProduct" | "readSeats" | "manageSeat" | "redeemCoupon" | "listOffers" | "grantOffer";
925
942
  inputs: Record<string, {
926
943
  source: "literal";
927
944
  value: zod.JSONType;
@@ -1624,6 +1641,11 @@ declare function createFunnelRunController(options: IndianaOptions & {
1624
1641
  } | {
1625
1642
  type: "plans";
1626
1643
  planIds: string[];
1644
+ } | {
1645
+ type: "merchandise";
1646
+ scope: {
1647
+ type: "selected" | "all" | "condition";
1648
+ };
1627
1649
  };
1628
1650
  displayCopy: {
1629
1651
  defaultLocale: string;
@@ -1884,7 +1906,7 @@ declare function createFunnelRunController(options: IndianaOptions & {
1884
1906
  entry: string;
1885
1907
  nodes: {
1886
1908
  id: string;
1887
- type: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
1909
+ type: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
1888
1910
  outputs: Record<string, string>;
1889
1911
  writes: Record<string, string>;
1890
1912
  resources: {
@@ -1958,7 +1980,7 @@ declare function createFunnelRunController(options: IndianaOptions & {
1958
1980
  revision: number;
1959
1981
  visit: number;
1960
1982
  nodeId: string;
1961
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
1983
+ nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
1962
1984
  status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
1963
1985
  stopped: boolean;
1964
1986
  canBack: boolean;
@@ -2991,7 +3013,7 @@ declare function createFunnelRunController(options: IndianaOptions & {
2991
3013
  } | {
2992
3014
  type: "client_action";
2993
3015
  receiptId: string;
2994
- outcome: "success" | "failed" | "cancel" | "failure" | "opened";
3016
+ outcome: "success" | "failed" | "cancel" | "opened" | "failure";
2995
3017
  };
2996
3018
  requestId: string;
2997
3019
  nodeId: string;
@@ -3064,7 +3086,7 @@ declare function createFunnelRunController(options: IndianaOptions & {
3064
3086
  } | {
3065
3087
  type: "client_action";
3066
3088
  receiptId: string;
3067
- outcome: "success" | "failed" | "cancel" | "failure" | "opened";
3089
+ outcome: "success" | "failed" | "cancel" | "opened" | "failure";
3068
3090
  };
3069
3091
  requestId: string;
3070
3092
  nodeId: string;
@@ -3124,7 +3146,7 @@ declare function createFunnelRunController(options: IndianaOptions & {
3124
3146
  revision: number;
3125
3147
  visit: number;
3126
3148
  nodeId: string;
3127
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
3149
+ nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
3128
3150
  status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
3129
3151
  stopped: boolean;
3130
3152
  canBack: boolean;
@@ -4805,7 +4827,7 @@ declare function createFunnelRunController(options: IndianaOptions & {
4805
4827
  revision: number;
4806
4828
  visit: number;
4807
4829
  nodeId: string;
4808
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
4830
+ nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
4809
4831
  status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
4810
4832
  stopped: boolean;
4811
4833
  canBack: boolean;
@@ -6224,7 +6246,7 @@ declare function createFunnelRunController(options: IndianaOptions & {
6224
6246
  revision: number;
6225
6247
  visit: number;
6226
6248
  nodeId: string;
6227
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
6249
+ nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
6228
6250
  status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
6229
6251
  stopped: boolean;
6230
6252
  canBack: boolean;
@@ -7641,7 +7663,7 @@ declare function createFunnelRunController(options: IndianaOptions & {
7641
7663
  revision: number;
7642
7664
  visit: number;
7643
7665
  nodeId: string;
7644
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
7666
+ nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
7645
7667
  status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
7646
7668
  stopped: boolean;
7647
7669
  canBack: boolean;
@@ -9475,10 +9497,15 @@ declare function createIndiana(options: IndianaOptions): {
9475
9497
  } | {
9476
9498
  type: "plans";
9477
9499
  planIds: string[];
9500
+ } | {
9501
+ type: "merchandise";
9502
+ scope: {
9503
+ type: "selected" | "all" | "condition";
9504
+ };
9478
9505
  };
9479
9506
  };
9480
9507
  } | null;
9481
- reason: "unavailable" | "claim_disabled" | "inactive" | "outside_window" | "not_targeted" | "not_first_purchase" | "limit_reached" | "sold_out" | null;
9508
+ reason: "unavailable" | "inactive" | "claim_disabled" | "outside_window" | "not_targeted" | "not_first_purchase" | "limit_reached" | "sold_out" | null;
9482
9509
  }>;
9483
9510
  resolveOffering(input: Omit<ApiInput<"resolveOffering">, "customerId">): Promise<{
9484
9511
  requestId: string;
@@ -10331,7 +10358,7 @@ declare function createIndiana(options: IndianaOptions): {
10331
10358
  }>;
10332
10359
  destroy: () => void;
10333
10360
  }>;
10334
- track(name: string, properties?: Record<string, JsonValue>): void;
10361
+ track(name: string, properties?: Record<string, JsonValue>, context?: Pick<ApiInput<"trackEvents">["events"][number], "merchandise">): void;
10335
10362
  flush(): Promise<{
10336
10363
  inserted: number;
10337
10364
  duplicates: number;
@@ -10723,10 +10750,15 @@ declare function createIndiana(options: IndianaOptions): {
10723
10750
  } | {
10724
10751
  type: "plans";
10725
10752
  planIds: string[];
10753
+ } | {
10754
+ type: "merchandise";
10755
+ scope: {
10756
+ type: "selected" | "all" | "condition";
10757
+ };
10726
10758
  };
10727
10759
  };
10728
10760
  } | null;
10729
- reason: "unavailable" | "claim_disabled" | "inactive" | "outside_window" | "not_targeted" | "not_first_purchase" | "limit_reached" | "sold_out" | null;
10761
+ reason: "unavailable" | "inactive" | "claim_disabled" | "outside_window" | "not_targeted" | "not_first_purchase" | "limit_reached" | "sold_out" | null;
10730
10762
  }>;
10731
10763
  claimCoupon(couponId: string, requestId?: `${string}-${string}-${string}-${string}-${string}`): Promise<{
10732
10764
  offer: {
@@ -10758,10 +10790,15 @@ declare function createIndiana(options: IndianaOptions): {
10758
10790
  } | {
10759
10791
  type: "plans";
10760
10792
  planIds: string[];
10793
+ } | {
10794
+ type: "merchandise";
10795
+ scope: {
10796
+ type: "selected" | "all" | "condition";
10797
+ };
10761
10798
  };
10762
10799
  };
10763
10800
  } | null;
10764
- reason: "unavailable" | "claim_disabled" | "inactive" | "outside_window" | "not_targeted" | "not_first_purchase" | "limit_reached" | "sold_out" | null;
10801
+ reason: "unavailable" | "inactive" | "claim_disabled" | "outside_window" | "not_targeted" | "not_first_purchase" | "limit_reached" | "sold_out" | null;
10765
10802
  }>;
10766
10803
  listOffers(): Promise<Offer[]>;
10767
10804
  previewUpdate(input: Omit<ApiInput<"previewUpdate">, "customerId">): Promise<{
@@ -12511,7 +12548,7 @@ declare function createIndiana(options: IndianaOptions): {
12511
12548
  name: string;
12512
12549
  groupId: string | null;
12513
12550
  membershipType: "addon" | "main";
12514
- status: "unknown" | "pending" | "active" | "expired" | "scheduled" | "trial" | "past_due" | "paused" | "ended" | "trialing";
12551
+ status: "unknown" | "active" | "pending" | "expired" | "scheduled" | "trial" | "past_due" | "paused" | "ended" | "trialing";
12515
12552
  cancelAtPeriodEnd: boolean;
12516
12553
  accessEnabled: boolean;
12517
12554
  renewalChange: {
@@ -12569,6 +12606,95 @@ declare function createIndiana(options: IndianaOptions): {
12569
12606
  balancesLimited: boolean;
12570
12607
  };
12571
12608
  }>;
12609
+ messaging: {
12610
+ preference(channel: "email" | "sms" | "voice" | "push"): Promise<{
12611
+ channel: "email" | "sms" | "voice" | "push";
12612
+ state: "allowed" | "unknown" | "denied";
12613
+ revision: number;
12614
+ updatedAt: string | null;
12615
+ }>;
12616
+ setPreference(input: ApiInput<"setMessagingPreference">): Promise<{
12617
+ channel: "email" | "sms" | "voice" | "push";
12618
+ state: "allowed" | "unknown" | "denied";
12619
+ revision: number;
12620
+ updatedAt: string | null;
12621
+ }>;
12622
+ };
12623
+ push: {
12624
+ sync: () => Promise<{
12625
+ installationId: string;
12626
+ bound: boolean;
12627
+ identitySeq: number;
12628
+ bindingGeneration: number;
12629
+ addressSeq: number;
12630
+ addressRevision: number;
12631
+ connectionId: string | null;
12632
+ addressStatus: "active" | "invalid" | null;
12633
+ permission: "unknown" | "denied" | "provisional" | "granted";
12634
+ } | null>;
12635
+ read: () => Promise<{
12636
+ installationId: string;
12637
+ bound: boolean;
12638
+ identitySeq: number;
12639
+ bindingGeneration: number;
12640
+ addressSeq: number;
12641
+ addressRevision: number;
12642
+ connectionId: string | null;
12643
+ addressStatus: "active" | "invalid" | null;
12644
+ permission: "unknown" | "denied" | "provisional" | "granted";
12645
+ }>;
12646
+ recover: () => Promise<{
12647
+ installationId: string;
12648
+ bound: boolean;
12649
+ identitySeq: number;
12650
+ bindingGeneration: number;
12651
+ addressSeq: number;
12652
+ addressRevision: number;
12653
+ connectionId: string | null;
12654
+ addressStatus: "active" | "invalid" | null;
12655
+ permission: "unknown" | "denied" | "provisional" | "granted";
12656
+ } | null>;
12657
+ tokenObserver: () => (observation: PushAddressObservation) => Promise<{
12658
+ installationId: string;
12659
+ bound: boolean;
12660
+ identitySeq: number;
12661
+ bindingGeneration: number;
12662
+ addressSeq: number;
12663
+ addressRevision: number;
12664
+ connectionId: string | null;
12665
+ addressStatus: "active" | "invalid" | null;
12666
+ permission: "unknown" | "denied" | "provisional" | "granted";
12667
+ } | null>;
12668
+ recoveryObserver: () => {
12669
+ request(observation: PushAddressObservation): Promise<{
12670
+ requested: true;
12671
+ expiresAt: string;
12672
+ }>;
12673
+ confirm(challenge: string, observation: PushAddressObservation): Promise<{
12674
+ installationId: string;
12675
+ bound: boolean;
12676
+ identitySeq: number;
12677
+ bindingGeneration: number;
12678
+ addressSeq: number;
12679
+ addressRevision: number;
12680
+ connectionId: string | null;
12681
+ addressStatus: "active" | "invalid" | null;
12682
+ permission: "unknown" | "denied" | "provisional" | "granted";
12683
+ }>;
12684
+ };
12685
+ preference(): Promise<{
12686
+ channel: "email" | "sms" | "voice" | "push";
12687
+ state: "allowed" | "unknown" | "denied";
12688
+ revision: number;
12689
+ updatedAt: string | null;
12690
+ }>;
12691
+ setPreference(input: Omit<ApiInput<"setMessagingPreference">, "channel">): Promise<{
12692
+ channel: "email" | "sms" | "voice" | "push";
12693
+ state: "allowed" | "unknown" | "denied";
12694
+ revision: number;
12695
+ updatedAt: string | null;
12696
+ }>;
12697
+ };
12572
12698
  };
12573
12699
 
12574
12700
  interface FunnelStorageLocks {
@@ -13151,7 +13277,7 @@ declare function createFunnelClient(options: IndianaOptions & {
13151
13277
  event: string;
13152
13278
  } | {
13153
13279
  type: "api";
13154
- operation: "update" | "attach" | "refund" | "readBalanceSource" | "adjustBalance" | "readUsage" | "setUsage" | "manageBalanceGrant" | "listBalanceGrants" | "restoreNativePurchase" | "setupPayment" | "readPaymentSetup" | "verifySubscriptions" | "previewAttach" | "readSubscriptionOperation" | "previewUpdate" | "readSubscriptionUpdate" | "previewRefund" | "readRefund" | "readBillingControls" | "prepareBillingAuthorization" | "confirmBillingAuthorization" | "setBillingCoupons" | "revokeBillingAuthorization" | "listBillingInvoices" | "confirmBillingAdjustment" | "manageBillingLimits" | "manageUsageEntity" | "readUsageAnalytics" | "readCreditAnalytics" | "submitUsageBatch" | "readUsageBatch" | "checkEntitlement" | "resolveOffering" | "readHoldings" | "readLedger" | "readBillingInvoice" | "readCreditStatement" | "quoteBalance" | "trackUsage" | "mutateBalance" | "redeemReward" | "createReferralCode" | "claimRewardProduct" | "readSeats" | "manageSeat" | "redeemCoupon" | "listOffers" | "grantOffer";
13280
+ operation: "update" | "attach" | "refund" | "sendMessage" | "readBalanceSource" | "adjustBalance" | "readUsage" | "setUsage" | "manageBalanceGrant" | "listBalanceGrants" | "restoreNativePurchase" | "setupPayment" | "readPaymentSetup" | "verifySubscriptions" | "previewAttach" | "readSubscriptionOperation" | "previewUpdate" | "readSubscriptionUpdate" | "previewRefund" | "readRefund" | "readBillingControls" | "prepareBillingAuthorization" | "confirmBillingAuthorization" | "setBillingCoupons" | "revokeBillingAuthorization" | "listBillingInvoices" | "confirmBillingAdjustment" | "manageBillingLimits" | "manageUsageEntity" | "readUsageAnalytics" | "readCreditAnalytics" | "submitUsageBatch" | "readUsageBatch" | "checkEntitlement" | "resolveOffering" | "readHoldings" | "readLedger" | "readBillingInvoice" | "readCreditStatement" | "quoteBalance" | "trackUsage" | "mutateBalance" | "redeemReward" | "createReferralCode" | "claimRewardProduct" | "readSeats" | "manageSeat" | "redeemCoupon" | "listOffers" | "grantOffer";
13155
13281
  inputs: Record<string, {
13156
13282
  source: "literal";
13157
13283
  value: zod.JSONType;
@@ -13854,6 +13980,11 @@ declare function createFunnelClient(options: IndianaOptions & {
13854
13980
  } | {
13855
13981
  type: "plans";
13856
13982
  planIds: string[];
13983
+ } | {
13984
+ type: "merchandise";
13985
+ scope: {
13986
+ type: "selected" | "all" | "condition";
13987
+ };
13857
13988
  };
13858
13989
  displayCopy: {
13859
13990
  defaultLocale: string;
@@ -14114,7 +14245,7 @@ declare function createFunnelClient(options: IndianaOptions & {
14114
14245
  entry: string;
14115
14246
  nodes: {
14116
14247
  id: string;
14117
- type: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
14248
+ type: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
14118
14249
  outputs: Record<string, string>;
14119
14250
  writes: Record<string, string>;
14120
14251
  resources: {
@@ -14188,7 +14319,7 @@ declare function createFunnelClient(options: IndianaOptions & {
14188
14319
  revision: number;
14189
14320
  visit: number;
14190
14321
  nodeId: string;
14191
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
14322
+ nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
14192
14323
  status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
14193
14324
  stopped: boolean;
14194
14325
  canBack: boolean;
@@ -15221,7 +15352,7 @@ declare function createFunnelClient(options: IndianaOptions & {
15221
15352
  } | {
15222
15353
  type: "client_action";
15223
15354
  receiptId: string;
15224
- outcome: "success" | "failed" | "cancel" | "failure" | "opened";
15355
+ outcome: "success" | "failed" | "cancel" | "opened" | "failure";
15225
15356
  };
15226
15357
  requestId: string;
15227
15358
  nodeId: string;
@@ -15294,7 +15425,7 @@ declare function createFunnelClient(options: IndianaOptions & {
15294
15425
  } | {
15295
15426
  type: "client_action";
15296
15427
  receiptId: string;
15297
- outcome: "success" | "failed" | "cancel" | "failure" | "opened";
15428
+ outcome: "success" | "failed" | "cancel" | "opened" | "failure";
15298
15429
  };
15299
15430
  requestId: string;
15300
15431
  nodeId: string;
@@ -15354,7 +15485,7 @@ declare function createFunnelClient(options: IndianaOptions & {
15354
15485
  revision: number;
15355
15486
  visit: number;
15356
15487
  nodeId: string;
15357
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
15488
+ nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
15358
15489
  status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
15359
15490
  stopped: boolean;
15360
15491
  canBack: boolean;
@@ -17035,7 +17166,7 @@ declare function createFunnelClient(options: IndianaOptions & {
17035
17166
  revision: number;
17036
17167
  visit: number;
17037
17168
  nodeId: string;
17038
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
17169
+ nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
17039
17170
  status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
17040
17171
  stopped: boolean;
17041
17172
  canBack: boolean;
@@ -18454,7 +18585,7 @@ declare function createFunnelClient(options: IndianaOptions & {
18454
18585
  revision: number;
18455
18586
  visit: number;
18456
18587
  nodeId: string;
18457
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
18588
+ nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
18458
18589
  status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
18459
18590
  stopped: boolean;
18460
18591
  canBack: boolean;
@@ -19871,7 +20002,7 @@ declare function createFunnelClient(options: IndianaOptions & {
19871
20002
  revision: number;
19872
20003
  visit: number;
19873
20004
  nodeId: string;
19874
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
20005
+ nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
19875
20006
  status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
19876
20007
  stopped: boolean;
19877
20008
  canBack: boolean;
@@ -21291,7 +21422,7 @@ declare function createFunnelClient(options: IndianaOptions & {
21291
21422
  revision: number;
21292
21423
  visit: number;
21293
21424
  nodeId: string;
21294
- nodeType: "output" | "action" | "feature" | "split" | "condition" | "coupon" | "end" | "screen" | "offering" | "coupons" | "entry" | "external_page" | "wait";
21425
+ nodeType: "output" | "action" | "feature" | "split" | "condition" | "entry" | "coupon" | "end" | "screen" | "offering" | "coupons" | "external_page" | "wait";
21295
21426
  status: "failed" | "completed" | "running" | "closed" | "ineligible" | "waiting";
21296
21427
  stopped: boolean;
21297
21428
  canBack: boolean;
@@ -23022,9 +23153,18 @@ declare function showFunnelRun(...args: Parameters<typeof showFunnelRun$1>): Pro
23022
23153
 
23023
23154
  declare function mountContent(...args: Parameters<typeof mountContent$1>): Promise<{
23024
23155
  destroy: () => void;
23156
+ show: () => void;
23157
+ readonly pendingAction: ContentActionIntent | null;
23158
+ retryAction: () => Promise<void>;
23159
+ updateCapabilities: (data: SurfaceData) => void | undefined;
23160
+ }>;
23161
+ /** Load the presentation module and render resolved content before the opening click. */
23162
+ declare function prepareContent(...args: Parameters<typeof prepareContent$1>): Promise<{
23163
+ destroy: () => void;
23164
+ show: () => void;
23025
23165
  readonly pendingAction: ContentActionIntent | null;
23026
23166
  retryAction: () => Promise<void>;
23027
23167
  updateCapabilities: (data: SurfaceData) => void | undefined;
23028
23168
  }>;
23029
23169
 
23030
- export { ConfigurationSync, type ContentActionIntent, type ContentHostOptions, FeatureClientOptions, FunnelCommandStorage, type FunnelControllerResponse, type FunnelHostOptions, FunnelPurchaseRecovery, type FunnelResourceSource, type FunnelRunController, FunnelRuntimeResponse, FunnelSegmentPrediction, type IndianaFeatureOptions, IndianaOptions, Offer, type PaywallHostOptions, PaywallSession, createBrowserFunnelCommandStorage, createFunnelClient, createFunnelRunController, createIndiana, formatCouponDiscount, formatCouponMoney, formatCouponTerms, mountContent, showFunnelRun, showPaywall };
23170
+ export { ConfigurationSync, type ContentActionIntent, type ContentHostOptions, FeatureClientOptions, FunnelCommandStorage, type FunnelControllerResponse, type FunnelHostOptions, FunnelPurchaseRecovery, type FunnelResourceSource, type FunnelRunController, FunnelRuntimeResponse, FunnelSegmentPrediction, type IndianaFeatureOptions, IndianaOptions, Offer, type PaywallHostOptions, PaywallSession, createBrowserFunnelCommandStorage, createFunnelClient, createFunnelRunController, createIndiana, formatCouponDiscount, formatCouponMoney, formatCouponTerms, mountContent, prepareContent, showFunnelRun, showPaywall };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as k,f as te,i as D,j as ne,k as re,l as oe,m as V,n as ie}from"./chunk-56AYS7RS.js";import"./chunk-YWFNWK7C.js";import{a as o}from"./chunk-KSNOXNTC.js";import{a as B}from"./chunk-AEUFCOFG.js";import{ei as r,fe as N,ga as W,ha as X,ia as ee,ri as P}from"./chunk-F767CM3T.js";import{a as p}from"./chunk-6HG7U6AU.js";import"./chunk-3BQFJANQ.js";import"./chunk-AE4CUTUE.js";import"./chunk-EXCPE2XH.js";import"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";function _(t,e){let n=!1,a=new Set,s=u=>{for(let i of a)try{i(u)}catch{}};return{isIdentified:()=>n,methods:{subscribeIdentity(u){return a.add(u),()=>{a.delete(u)}},identify(u){if(!/^gg_ct_[A-Za-z0-9_-]{43}$/.test(u))throw new p("INVALID_TOKEN","Browser SDK requires a customer session");n=!1,t.reset(),e(),t.identify(u),n=!0,s(!0)},reset(){n=!1,t.reset(),e(),s(!1)}}}}function c(t){if(t!==null&&typeof t=="object"&&"customerId"in t)throw new p("INVALID_REQUEST","Customer requests use the verified session identity")}function U(t){return{async checkEntitlement(e){c(e);let n=r.checkEntitlement;return o(t,n,e)},async readHoldings(e={}){let n=r.readHoldings;return o(t,{...n,request:n.request.omit({customerId:!0})},e)}}}function j(t){return{async readLedger(e){let n=r.readLedger;return o(t,n,{query:e})},async readCreditStatement(e){c(e);let n=r.readCreditStatement;return o(t,n,e)},async quoteBalance(e){c(e);let n=r.quoteBalance;return o(t,n,{command:e})}}}function q(t){return{async setupPayment(e){c(e);let n=r.setupPayment;return o(t,n,e)},async readPaymentSetup(e){c(e);let n=r.readPaymentSetup;return o(t,n,e)},async readBillingInvoice(e){c(e);let n=r.readBillingInvoice;return o(t,n,e)},async readBillingControls(e={}){c(e);let n=r.readBillingControls;return o(t,n,e)},async prepareBillingAuthorization(e){c(e);let n=r.prepareBillingAuthorization;return o(t,n,e)},async confirmBillingAuthorization(e){c(e);let n=r.confirmBillingAuthorization;return o(t,n,e)},async setBillingCoupons(e){c(e);let n=r.setBillingCoupons;return o(t,n,e,{request:"Invalid billing coupon list",response:"Invalid billing coupon receipt"})},async revokeBillingAuthorization(e){c(e);let n=r.revokeBillingAuthorization;return o(t,n,e)},async listBillingInvoices(e={after:null,limit:25}){c(e);let n=r.listBillingInvoices;return o(t,n,e)},async confirmBillingAdjustment(e){c(e);let n=r.confirmBillingAdjustment;return o(t,n,e)}}}function L(t){return{async previewUpdate(e){c(e);let n=r.previewUpdate;return o(t,n,e)},async update(e){c(e);let n=r.update;return o(t,n,e)},async readSubscriptionUpdate(e){c(e);let n=r.readSubscriptionUpdate;return o(t,n,e)},async restoreNativePurchase(e){c(e);let n=r.restoreNativePurchase;return o(t,n,e)},async previewAttach(e){c(e);let n=r.previewAttach;return o(t,n,e)},async attach(e){c(e);let n=r.attach;return o(t,n,e)},async readSubscriptionOperation(e){c(e);let n=r.readSubscriptionOperation;return o(t,n,e)}}}function z(t){return{async redeemReward(e){return c(e),(await o(t,r.redeemReward,{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid reward redemption",response:"Invalid reward receipt"})).redemption},async claimRewardProduct(e){return c(e),(await o(t,r.claimRewardProduct,e,{request:"Invalid reward product claim",response:"Invalid reward product checkout"})).checkout},async createReferralCode(e){return c(e),(await o(t,r.createReferralCode,{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid referral program",response:"Invalid referral code"})).referralCode},async redeemCoupon(e,n=crypto.randomUUID()){let a=await o(t,r.redeemCoupon,{code:e,requestId:n},{request:"Invalid coupon code",response:"Invalid Coupon receipt"});return{offer:a.offer,reason:a.reason}},async claimCoupon(e,n=crypto.randomUUID()){let a=await o(t,r.grantOffer,{couponId:e,requestId:n},{request:"Invalid Coupon claim",response:"Invalid Coupon receipt"});return{offer:a.offer,reason:a.reason}},async listOffers(){return(await o(t,r.listOffers,{},{response:"Invalid offers response"})).offers}}}function H(t){return{...U(t),...j(t),...q(t),...L(t),...z(t)}}function J(t){return{async resolveContent(e){c(e);let n=r.resolveContent;return o(t,n,e)},async resolvePaywall(e){c(e);let n=r.resolvePaywall;return o(t,n,e)},async resolveOffering(e){c(e);let n=r.resolveOffering;return o(t,n,e)}}}var M=t=>new TextEncoder().encode(JSON.stringify(t)).length,Q=16384;function G(t,e){let n=0,a,s=m=>{a={config:structuredClone(m),until:Date.now()+3e4}},u=[],i=null,l;function F(){if(!e())throw new p("NOT_IDENTIFIED","Call identify before using Features or events")}function v(){l||!u.length||(l=setTimeout(()=>{l=void 0,h().catch(()=>{}).finally(v)},5e3),typeof l=="object"&&"unref"in l&&l.unref())}function O(m,y={}){if(F(),a&&Date.now()<a.until&&!N(a.config,m))return;b();let w=r.trackEvents.request.parse({events:[{eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),name:m,properties:y}]}).events[0];if(M({events:[w]})>Q)throw new p("INVALID_REQUEST","Event exceeds the delivery size limit");if(u.length>=500)throw new p("EVENT_QUEUE_FULL","Flush pending events before tracking more");u.push(structuredClone(w)),v()}async function h(m=!1){if(F(),i)return i;let y=n,w=(async()=>{let A={inserted:0,duplicates:0,rejected:0,skipped:0},g=u.length;for(;g&&y===n;){let C=[];for(let x of u.slice(0,Math.min(g,100))){if(C.length&&M({events:[...C,x]})>Q)break;C.push(x)}let S=r.trackEvents,f=await o(t,S,{events:C},void 0,{keepalive:m});if(y!==n)throw new p("IDENTITY_CHANGED","Event identity changed during delivery");if(f.inserted+f.duplicates+f.rejected+f.skipped!==C.length)throw new p("INVALID_RESPONSE","Incomplete event acknowledgement");s(f.analyticsConfig),u.splice(0,C.length),g-=C.length,A.inserted+=f.inserted,A.duplicates+=f.duplicates,A.rejected+=f.rejected,A.skipped+=f.skipped}return A})();i=w;try{return await w}finally{i===w&&(i=null)}}let R;function b(){if(R||typeof document>"u")return;let m=()=>{document.visibilityState==="hidden"&&e()&&u.length&&h(!0).catch(()=>{})};document.addEventListener("visibilitychange",m),R=()=>document.removeEventListener("visibilitychange",m)}return{rememberConfiguration:s,track(m,y){return b(),O(m,y)},flush:h,reset(){n++,a=void 0,clearTimeout(l),l=void 0,u=[],i=null},detachVisibility(){R?.(),R=void 0}}}function Y(t,e,n,a,s){if(s&&a&&(s.scope.projectId!==a.projectId||s.scope.environment!==a.environment))throw new p("SCOPE_MISMATCH","Configuration belongs to another App/environment");let u=0,i=new Set;function l(){if(!e())throw new p("NOT_IDENTIFIED","Call identify before using Features or events")}async function F(v={}){s||l();let O=u,h=!1,R=async()=>{if(h||O!==u)throw new p("IDENTITY_CHANGED","Feature identity changed");let I=r.getFeatures,d=s?{scope:{projectId:s.scope.projectId,environment:s.scope.environment},payload:await s.features()}:await o(t,I,{});if(O!==u)throw new p("IDENTITY_CHANGED","Feature identity changed");if(a&&(d.scope.projectId!==a.projectId||d.scope.environment!==a.environment))throw new p("INVALID_RESPONSE","Feature response scope changed");return n.rememberConfiguration(d.payload.analyticsConfig),d},b=await R(),m=!0,y,w=I=>{try{v.onError?.(I)}catch{}},A=(I,d)=>{try{n.track(I,d)}catch(E){w(E)}},g=k({assertUsable:s?.assertFeatures,scope:b.scope,attributes:v.attributes,onError:v.onError,load:async()=>m?(m=!1,b.payload):(await R()).payload,evaluateRemote:async I=>{if(O!==u)throw new p("IDENTITY_CHANGED","Feature identity changed");let d=r.evaluateFeatures,E=await o(t,d,I);if(E.scope.projectId!==b.scope.projectId||E.scope.environment!==b.scope.environment)throw new p("INVALID_RESPONSE","Remote Feature response scope changed");return{generation:E.generation,evaluatedAt:E.evaluatedAt,expiresAt:E.expiresAt,features:E.features}},onExperimentViewed:(I,d)=>A("Experiment Viewed",{experimentId:I.key,variationId:d.key}),onFeatureUsage:(I,d)=>A("Feature Evaluated",{feature:I,value:d.value,source:d.source,ruleId:d.ruleId,...d.experimentResult?{variationId:d.experimentResult.key}:{}})}),C=g.refresh;function S(){clearTimeout(y),!s&&(h||O!==u||!g.expiresAt||(y=setTimeout(()=>{f().catch(w)},Math.min(2147483647,Math.max(1e3,Date.parse(g.expiresAt)-Date.now()))),typeof y=="object"&&"unref"in y&&y.unref()))}async function f(){try{return await C()}finally{S()}}let x=()=>{h||f().catch(w)},Z=g.subscribe(S),$=s?.subscribe(()=>{!h&&s.fresh&&f().catch(w)});function T(){h||(h=!0,clearTimeout(y),typeof window<"u"&&window.removeEventListener("focus",x),Z(),$?.(),g.reset(),i.delete(T))}i.add(T);try{await g.init()}catch(I){throw T(),I}return S(),!s&&typeof window<"u"&&window.addEventListener("focus",x),Object.assign(g,{refresh:f,destroy:T})}return{features:F,reset(v){u++,v();for(let O of i)O()}}}import{z as ae}from"zod";function K(t,e){let n="source"in e?{funnelId:e.source.id,funnelVersionId:e.source.versionId}:"versionId"in e?{funnelId:e.funnelId,funnelVersionId:e.versionId}:e,a=ae.object({funnelId:P.shape.id,funnelVersionId:P.shape.versionId.optional()}).safeParse(n);if(!a.success)throw new p("INVALID_REQUEST","A valid Funnel source is required");let s=Object.freeze(a.data);function u(i){if("customerId"in i)throw new p("INVALID_REQUEST","Customer identity cannot be overridden");if("funnelId"in i&&i.funnelId!==void 0&&i.funnelId!==s.funnelId||"funnelVersionId"in i&&i.funnelVersionId!==void 0&&i.funnelVersionId!==s.funnelVersionId)throw new p("SCOPE_MISMATCH","The original Funnel source cannot change");return{...i,...s}}return{async claimCoupon(i,l=crypto.randomUUID()){let F=r.grantOffer,v=await o(t,F,u({couponId:i,requestId:l}));return{offer:v.offer,reason:v.reason}},async resolveOffering(i){let l=r.resolveOffering;return o(t,l,u(i))},async resolvePaywall(i){let l=r.resolvePaywall;return o(t,l,u(i))},async previewAttach(i){let l=r.previewAttach;return o(t,l,u(i))}}}function se(t){let e=B(t),n=e.request,a=_(e,()=>{u.reset(s.reset),s.detachVisibility()}),s=G(n,a.isIdentified),u=Y(n,a.isIdentified,s,t.scope,t.configuration);return{...H(n),...J(n),forFunnel(i){return K(n,i)},async features(i={}){return u.features(i)},track(i,l){return s.track(i,l)},flush(){return s.flush()},...a.methods}}function ue(t){if(!/^gg_ct_[A-Za-z0-9_-]{32,128}$/.test(t.customerToken))throw new p("INVALID_TOKEN","A customer credential is required");if(!t.scope)throw new p("INVALID_REQUEST","An explicit App and environment scope is required");let e=V({...t,scope:t.scope,apiKey:t.customerToken});return{async start(n){let a=await e.start(n),s=D({...t,runToken:a.runToken});s.identify(t.customerToken);let u=["evaluate","evaluate_segment"].includes(a.run.instruction?.type??"")?await s.get():a;return{...a,...u,controller:s}}}}async function yt(...t){return(await import("./paywall-MXRMMF3R.js")).showPaywall(...t)}async function It(...t){return(await import("./funnel-runtime-host-CAMI6BJS.js")).showFunnelRun(...t)}async function vt(...t){return(await import("./content-YNL2CRJZ.js")).mountContent(...t)}export{p as IndianaError,te as createBrowserFunnelCommandStorage,re as createConfigurationSync,k as createFeatureClient,ue as createFunnelClient,D as createFunnelRunController,se as createIndiana,ie as createLocalFunnelClient,ne as createPaywallSession,oe as evaluateFunnelNode,X as formatCouponDiscount,W as formatCouponMoney,ee as formatCouponTerms,vt as mountContent,It as showFunnelRun,yt as showPaywall};
1
+ import{a as _}from"./chunk-663UOBHL.js";import{a as D,f as oe,i as V,j as ie,k as ae,l as se,m as j,n as ce}from"./chunk-3F2NQOR2.js";import"./chunk-GRLMT5PR.js";import{a as o}from"./chunk-VVV3JNS3.js";import{a as B}from"./chunk-SSHUBTT3.js";import{Ia as te,Ja as ne,Ka as re,Yi as r,_e as N,jj as k}from"./chunk-EJTBSGLV.js";import{a as l}from"./chunk-SOQO2RDZ.js";import"./chunk-LMR2TM3X.js";import"./chunk-OBYJWIRB.js";import"./chunk-EXCPE2XH.js";import"./chunk-RRII2DMC.js";import"./chunk-KQCTDXVD.js";function U(t,e,n={}){let i=!1,c=new Set,p=a=>{for(let s of c)try{s(a)}catch{}};return{isIdentified:()=>i,methods:{subscribeIdentity(a){return c.add(a),()=>{c.delete(a)}},identify(a){if(!/^gg_ct_[A-Za-z0-9_-]{43}$/.test(a))throw new l("INVALID_TOKEN","Browser SDK requires a customer session");n.beforeIdentify?.(a),i=!1,t.reset(),e(),t.identify(a),i=!0,p(!0),n.afterChange?.()},reset(){try{n.beforeReset?.()}finally{i=!1,t.reset(),e(),p(!1),n.afterChange?.()}}}}}function u(t){if(t!==null&&typeof t=="object"&&"customerId"in t)throw new l("INVALID_REQUEST","Customer requests use the verified session identity")}function q(t){return{async checkEntitlement(e){u(e);let n=r.checkEntitlement;return o(t,n,e)},async readHoldings(e={}){let n=r.readHoldings;return o(t,{...n,request:n.request.omit({customerId:!0})},e)}}}function L(t){return{async readLedger(e){let n=r.readLedger;return o(t,n,{query:e})},async readCreditStatement(e){u(e);let n=r.readCreditStatement;return o(t,n,e)},async quoteBalance(e){u(e);let n=r.quoteBalance;return o(t,n,{command:e})}}}function z(t){return{async setupPayment(e){u(e);let n=r.setupPayment;return o(t,n,e)},async readPaymentSetup(e){u(e);let n=r.readPaymentSetup;return o(t,n,e)},async readBillingInvoice(e){u(e);let n=r.readBillingInvoice;return o(t,n,e)},async readBillingControls(e={}){u(e);let n=r.readBillingControls;return o(t,n,e)},async prepareBillingAuthorization(e){u(e);let n=r.prepareBillingAuthorization;return o(t,n,e)},async confirmBillingAuthorization(e){u(e);let n=r.confirmBillingAuthorization;return o(t,n,e)},async setBillingCoupons(e){u(e);let n=r.setBillingCoupons;return o(t,n,e,{request:"Invalid billing coupon list",response:"Invalid billing coupon receipt"})},async revokeBillingAuthorization(e){u(e);let n=r.revokeBillingAuthorization;return o(t,n,e)},async listBillingInvoices(e={after:null,limit:25}){u(e);let n=r.listBillingInvoices;return o(t,n,e)},async confirmBillingAdjustment(e){u(e);let n=r.confirmBillingAdjustment;return o(t,n,e)}}}function M(t){return{async previewUpdate(e){u(e);let n=r.previewUpdate;return o(t,n,e)},async update(e){u(e);let n=r.update;return o(t,n,e)},async readSubscriptionUpdate(e){u(e);let n=r.readSubscriptionUpdate;return o(t,n,e)},async restoreNativePurchase(e){u(e);let n=r.restoreNativePurchase;return o(t,n,e)},async previewAttach(e){u(e);let n=r.previewAttach;return o(t,n,e)},async attach(e){u(e);let n=r.attach;return o(t,n,e)},async readSubscriptionOperation(e){u(e);let n=r.readSubscriptionOperation;return o(t,n,e)}}}function H(t){return{async redeemReward(e){return u(e),(await o(t,r.redeemReward,{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid reward redemption",response:"Invalid reward receipt"})).redemption},async claimRewardProduct(e){return u(e),(await o(t,r.claimRewardProduct,e,{request:"Invalid reward product claim",response:"Invalid reward product checkout"})).checkout},async createReferralCode(e){return u(e),(await o(t,r.createReferralCode,{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid referral program",response:"Invalid referral code"})).referralCode},async redeemCoupon(e,n=crypto.randomUUID()){let i=await o(t,r.redeemCoupon,{code:e,requestId:n},{request:"Invalid coupon code",response:"Invalid Coupon receipt"});return{offer:i.offer,reason:i.reason}},async claimCoupon(e,n=crypto.randomUUID()){let i=await o(t,r.grantOffer,{couponId:e,requestId:n},{request:"Invalid Coupon claim",response:"Invalid Coupon receipt"});return{offer:i.offer,reason:i.reason}},async listOffers(){return(await o(t,r.listOffers,{},{response:"Invalid offers response"})).offers}}}function J(t){return{...q(t),...L(t),...z(t),...M(t),...H(t)}}function Q(t){return{async resolveContent(e){u(e);let n=r.resolveContent;return o(t,n,e)},async resolvePaywall(e){u(e);let n=r.resolvePaywall;return o(t,n,e)},async resolveOffering(e){u(e);let n=r.resolveOffering;return o(t,n,e)}}}var G=t=>new TextEncoder().encode(JSON.stringify(t)).length,Y=16384;function K(t,e){let n=0,i,c=y=>{i={config:structuredClone(y),until:Date.now()+3e4}},p=[],a=null,s;function d(){if(!e())throw new l("NOT_IDENTIFIED","Call identify before using Features or events")}function m(){s||!p.length||(s=setTimeout(()=>{s=void 0,A().catch(()=>{}).finally(m)},5e3),typeof s=="object"&&"unref"in s&&s.unref())}function E(y,v={},w={}){if(d(),i&&Date.now()<i.until&&!N(i.config,y))return;x();let O=r.trackEvents.request.parse({events:[{eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),name:y,properties:v,...w}]}).events[0];if(G({events:[O]})>Y)throw new l("INVALID_REQUEST","Event exceeds the delivery size limit");if(p.length>=500)throw new l("EVENT_QUEUE_FULL","Flush pending events before tracking more");p.push(structuredClone(O)),m()}async function A(y=!1){if(d(),a)return a;let v=n,w=(async()=>{let O={inserted:0,duplicates:0,rejected:0,skipped:0},C=p.length;for(;C&&v===n;){let b=[];for(let P of p.slice(0,Math.min(C,100))){if(b.length&&G({events:[...b,P]})>Y)break;b.push(P)}let F=r.trackEvents,I=await o(t,F,{events:b},void 0,{keepalive:y});if(v!==n)throw new l("IDENTITY_CHANGED","Event identity changed during delivery");if(I.inserted+I.duplicates+I.rejected+I.skipped!==b.length)throw new l("INVALID_RESPONSE","Incomplete event acknowledgement");c(I.analyticsConfig),p.splice(0,b.length),C-=b.length,O.inserted+=I.inserted,O.duplicates+=I.duplicates,O.rejected+=I.rejected,O.skipped+=I.skipped}return O})();a=w;try{return await w}finally{a===w&&(a=null)}}let R;function x(){if(R||typeof document>"u")return;let y=()=>{document.visibilityState==="hidden"&&e()&&p.length&&A(!0).catch(()=>{})};document.addEventListener("visibilitychange",y),R=()=>document.removeEventListener("visibilitychange",y)}return{rememberConfiguration:c,track(y,v,w={}){return x(),E(y,v,w)},flush:A,reset(){n++,i=void 0,clearTimeout(s),s=void 0,p=[],a=null},detachVisibility(){R?.(),R=void 0}}}function Z(t){let e=t.merchandise;if(typeof t.merchandiseId=="string")return{internalId:t.merchandiseId};if(!(!e||typeof e!="object"||Array.isArray(e))){if(typeof e.internalId=="string")return{internalId:e.internalId};if(typeof e.externalId=="string")return{id:e.externalId};if(typeof e.id=="string")return{id:e.id}}}function ue(t){let e=Z(t),{merchandiseId:n,merchandise:i,...c}=t;return{...c,...e?{merchandise:e}:{}}}function $(t,e,n,i,c){if(c&&i&&(c.scope.projectId!==i.projectId||c.scope.environment!==i.environment))throw new l("SCOPE_MISMATCH","Configuration belongs to another App/environment");let p=0,a=new Set;function s(){if(!e())throw new l("NOT_IDENTIFIED","Call identify before using Features or events")}async function d(m={}){c||s();let E=p,A=!1,R=async()=>{if(A||E!==p)throw new l("IDENTITY_CHANGED","Feature identity changed");let h=r.getFeatures,f=c?{scope:{projectId:c.scope.projectId,environment:c.scope.environment},payload:await c.features()}:await o(t,h,{});if(E!==p)throw new l("IDENTITY_CHANGED","Feature identity changed");if(i&&(f.scope.projectId!==i.projectId||f.scope.environment!==i.environment))throw new l("INVALID_RESPONSE","Feature response scope changed");return n.rememberConfiguration(f.payload.analyticsConfig),f},x=await R(),y=!0,v,w=h=>{try{m.onError?.(h)}catch{}},O=(h,f,g)=>{try{let T=Z(g);n.track(h,f,T?{merchandise:T}:{})}catch(T){w(T)}},C=D({assertUsable:c?.assertFeatures,scope:x.scope,attributes:m.attributes,onError:m.onError,load:async()=>y?(y=!1,x.payload):(await R()).payload,evaluateRemote:async h=>{if(E!==p)throw new l("IDENTITY_CHANGED","Feature identity changed");let f=r.evaluateFeatures,g=await o(t,f,{...h,attributes:ue(h.attributes)});if(g.scope.projectId!==x.scope.projectId||g.scope.environment!==x.scope.environment)throw new l("INVALID_RESPONSE","Remote Feature response scope changed");return{generation:g.generation,evaluatedAt:g.evaluatedAt,expiresAt:g.expiresAt,features:g.features,...g.merchandiseContext?{merchandiseContext:g.merchandiseContext}:{}}},onExperimentViewed:(h,f,g)=>O("Experiment Viewed",{experimentId:h.key,variationId:f.key},g),onFeatureUsage:(h,f,g)=>O("Feature Evaluated",{feature:h,value:f.value,source:f.source,ruleId:f.ruleId,...f.experimentResult?{variationId:f.experimentResult.key}:{}},g)}),b=C.refresh;function F(){clearTimeout(v),!c&&(A||E!==p||!C.expiresAt||(v=setTimeout(()=>{I().catch(w)},Math.min(2147483647,Math.max(1e3,Date.parse(C.expiresAt)-Date.now()))),typeof v=="object"&&"unref"in v&&v.unref()))}async function I(){try{return await b()}finally{F()}}let P=()=>{A||I().catch(w)},X=C.subscribe(F),ee=c?.subscribe(()=>{!A&&c.fresh&&I().catch(w)});function S(){A||(A=!0,clearTimeout(v),typeof window<"u"&&window.removeEventListener("focus",P),X(),ee?.(),C.reset(),a.delete(S))}a.add(S);try{await C.init(),(m.attributes?.merchandise||m.attributes?.merchandiseId)&&await C.refreshRemote()}catch(h){throw S(),h}return F(),!c&&typeof window<"u"&&window.addEventListener("focus",P),Object.assign(C,{refresh:I,destroy:S})}return{features:d,reset(m){p++,m();for(let E of a)E()}}}import{z as pe}from"zod";function W(t,e){let n="source"in e?{funnelId:e.source.id,funnelVersionId:e.source.versionId}:"versionId"in e?{funnelId:e.funnelId,funnelVersionId:e.versionId}:e,i=pe.object({funnelId:k.shape.id,funnelVersionId:k.shape.versionId.optional()}).safeParse(n);if(!i.success)throw new l("INVALID_REQUEST","A valid Funnel source is required");let c=Object.freeze(i.data);function p(a){if("customerId"in a)throw new l("INVALID_REQUEST","Customer identity cannot be overridden");if("funnelId"in a&&a.funnelId!==void 0&&a.funnelId!==c.funnelId||"funnelVersionId"in a&&a.funnelVersionId!==void 0&&a.funnelVersionId!==c.funnelVersionId)throw new l("SCOPE_MISMATCH","The original Funnel source cannot change");return{...a,...c}}return{async claimCoupon(a,s=crypto.randomUUID()){let d=r.grantOffer,m=await o(t,d,p({couponId:a,requestId:s}));return{offer:m.offer,reason:m.reason}},async resolveOffering(a){let s=r.resolveOffering;return o(t,s,p(a))},async resolvePaywall(a){let s=r.resolvePaywall;return o(t,s,p(a))},async previewAttach(a){let s=r.previewAttach;return o(t,s,p(a))}}}function le(t){let e=B(t),n=e.request,i=_(t.push,e,t.scope??t.configuration?.scope),c=U(e,()=>{a.reset(p.reset),p.detachVisibility()},{beforeIdentify:i.identify,beforeReset:i.reset,afterChange:i.start}),p=K(n,c.isIdentified),a=$(n,c.isIdentified,p,t.scope,t.configuration);return{messaging:{async preference(s){let d=r.readMessagingPreference;return d.response.parse(await n(d.path,d.request.parse({channel:s}))).preference},async setPreference(s){let d=r.setMessagingPreference;return d.response.parse(await n(d.path,d.request.parse(s))).preference}},push:{sync:i.sync,read:i.read,recover:i.recover,tokenObserver:i.tokenObserver,recoveryObserver:i.recoveryObserver,async preference(){let s=r.readMessagingPreference;return s.response.parse(await n(s.path,{channel:"push"})).preference},async setPreference(s){let d=r.setMessagingPreference;return d.response.parse(await n(d.path,d.request.parse({...s,channel:"push"}))).preference}},...J(n),...Q(n),forFunnel(s){return W(n,s)},async features(s={}){return a.features(s)},track(s,d,m={}){return p.track(s,d,m)},flush(){return p.flush()},...c.methods}}function de(t){if(!/^gg_ct_[A-Za-z0-9_-]{32,128}$/.test(t.customerToken))throw new l("INVALID_TOKEN","A customer credential is required");if(!t.scope)throw new l("INVALID_REQUEST","An explicit App and environment scope is required");let e=j({...t,scope:t.scope,apiKey:t.customerToken});return{async start(n){let i=await e.start(n),c=V({...t,runToken:i.runToken});c.identify(t.customerToken);let p=["evaluate","evaluate_segment"].includes(i.run.instruction?.type??"")?await c.get():i;return{...i,...p,controller:c}}}}async function Ct(...t){return(await import("./paywall-734GWAS4.js")).showPaywall(...t)}async function Ot(...t){return(await import("./funnel-runtime-host-ENRTSXPJ.js")).showFunnelRun(...t)}async function At(...t){return(await import("./content-2FCUY6XX.js")).mountContent(...t)}async function bt(...t){return(await import("./content-2FCUY6XX.js")).prepareContent(...t)}export{l as IndianaError,oe as createBrowserFunnelCommandStorage,ae as createConfigurationSync,D as createFeatureClient,de as createFunnelClient,V as createFunnelRunController,le as createIndiana,ce as createLocalFunnelClient,ie as createPaywallSession,se as evaluateFunnelNode,ne as formatCouponDiscount,te as formatCouponMoney,re as formatCouponTerms,At as mountContent,bt as prepareContent,Ot as showFunnelRun,Ct as showPaywall};