@tinkerlandai/longplay-sdk 0.10.36 → 0.10.38

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 (87) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +8 -0
  3. package/README.zh-CN.md +8 -0
  4. package/dist/check-response-Q7GOBUGJ.js +1 -0
  5. package/dist/chunk-2LND3R7K.js +1 -0
  6. package/dist/{chunk-ZYF6TRJ3.js → chunk-4E326NPY.js} +1 -1
  7. package/dist/chunk-5IGASP6C.js +10 -0
  8. package/dist/{chunk-35VG2IYD.js → chunk-64ETX3AY.js} +1 -1
  9. package/dist/{chunk-5XIKN35D.js → chunk-6QOJRLVM.js} +1 -1
  10. package/dist/{chunk-BTPEXSNY.js → chunk-6WEHTOED.js} +1 -1
  11. package/dist/{chunk-RHWZRHK7.js → chunk-7PXJUHDS.js} +1 -1
  12. package/dist/{chunk-XE7GU6FZ.js → chunk-BDC7B4KM.js} +1 -1
  13. package/dist/{chunk-M3GGR53D.js → chunk-DK5PHPSO.js} +1 -1
  14. package/dist/{chunk-BL7E4RZ2.js → chunk-DSLJUN3P.js} +1 -1
  15. package/dist/{chunk-YQX27SBG.js → chunk-DTWSDNYI.js} +1 -1
  16. package/dist/{chunk-RHF4NFCZ.js → chunk-EEYDOVVS.js} +1 -1
  17. package/dist/chunk-G7Y7LPOB.js +1 -0
  18. package/dist/{chunk-R3YVDRTB.js → chunk-GEPX4AUR.js} +1 -1
  19. package/dist/{chunk-HS56A4IK.js → chunk-H2I37CQ4.js} +1 -1
  20. package/dist/{chunk-QHJWVLJC.js → chunk-HJVEVJXS.js} +1 -1
  21. package/dist/chunk-I7QTCEYR.js +1 -0
  22. package/dist/{chunk-MHWPEMX7.js → chunk-IHB275C3.js} +1 -1
  23. package/dist/{chunk-UVUFJO2V.js → chunk-IV6LKRYM.js} +1 -1
  24. package/dist/chunk-JBDNNV3P.js +1 -0
  25. package/dist/{chunk-I6D25FWU.js → chunk-JXTJT2EW.js} +1 -1
  26. package/dist/{chunk-DHT3AWJQ.js → chunk-K3VQKR4G.js} +1 -1
  27. package/dist/chunk-KQF4BVOL.js +1 -0
  28. package/dist/{chunk-5XKFUFXK.js → chunk-KTBXAATX.js} +1 -1
  29. package/dist/{chunk-VWMFR22O.js → chunk-L54MODP5.js} +1 -1
  30. package/dist/{chunk-XQTCEQXI.js → chunk-NK55HFFF.js} +1 -1
  31. package/dist/{chunk-TIQS5DUF.js → chunk-O5VA3E5D.js} +1 -1
  32. package/dist/{chunk-UHTTCVSL.js → chunk-PLOUC66F.js} +1 -1
  33. package/dist/chunk-Q7K66FTS.js +1 -0
  34. package/dist/{chunk-LVG5ED52.js → chunk-QZRJ3ZXU.js} +1 -1
  35. package/dist/{chunk-VKG6BB3Z.js → chunk-RK7XOT3F.js} +1 -1
  36. package/dist/chunk-SY7AYEDO.js +1 -0
  37. package/dist/{chunk-U4WUX3WB.js → chunk-TLV3NVUU.js} +1 -1
  38. package/dist/{chunk-2KKLY323.js → chunk-UAJTQ23E.js} +1 -1
  39. package/dist/{chunk-LAGGWYH3.js → chunk-UD7XPHE4.js} +1 -1
  40. package/dist/{chunk-IOBB6KFK.js → chunk-UFTLA3ZI.js} +1 -1
  41. package/dist/{chunk-HVVJGLYZ.js → chunk-WP3SZU24.js} +1 -1
  42. package/dist/chunk-WQZOT22S.js +1 -0
  43. package/dist/{chunk-MYBUQFTC.js → chunk-XBCKVHOT.js} +1 -1
  44. package/dist/chunk-Y5RT7PAD.js +1 -0
  45. package/dist/{chunk-2HSD2SEU.js → chunk-YYXINZ4A.js} +1 -1
  46. package/dist/content-B4CC4O23.js +1 -0
  47. package/dist/{funnel-host-purchase-M7MM33EC.js → funnel-host-purchase-AGBJG3RK.js} +1 -1
  48. package/dist/funnel-paywall-prerender-HHAQBIIB.js +1 -0
  49. package/dist/funnel-runtime-host-IJDKXLST.js +1 -0
  50. package/dist/index.d.ts +23 -3
  51. package/dist/index.js +1 -1
  52. package/dist/merchant-bridge-contracts-KVOFRPKV.js +1 -0
  53. package/dist/native-shell.js +1 -1
  54. package/dist/openrouter.js +1 -1
  55. package/dist/operation-contracts-G4C7ZLEH.js +1 -0
  56. package/dist/page.js +1 -1
  57. package/dist/paywall-TVCH6VQT.js +1 -0
  58. package/dist/paywall-content-QSTCRYU5.js +1 -0
  59. package/dist/paywall-session-UBQYU5XD.js +1 -0
  60. package/dist/popup.d.ts +1 -1
  61. package/dist/popup.js +1 -1
  62. package/dist/react-native.js +1 -1
  63. package/dist/screen-renderer-Q3VSMB2N.js +1 -0
  64. package/dist/server.js +1 -1
  65. package/dist/visual.js +1 -1
  66. package/package.json +10 -9
  67. package/dist/check-response-DHY6T5Z2.js +0 -1
  68. package/dist/chunk-7ZEXY4GC.js +0 -1
  69. package/dist/chunk-C4GBV32U.js +0 -10
  70. package/dist/chunk-CGXNU5BC.js +0 -1
  71. package/dist/chunk-DB4EO3JG.js +0 -1
  72. package/dist/chunk-GLYFT5WW.js +0 -1
  73. package/dist/chunk-HYE2YQYM.js +0 -1
  74. package/dist/chunk-JOIPLLHK.js +0 -1
  75. package/dist/chunk-OL2AI6DA.js +0 -1
  76. package/dist/chunk-W3K5ARMY.js +0 -1
  77. package/dist/chunk-WRLVPHPE.js +0 -1
  78. package/dist/content-RGKTEV23.js +0 -1
  79. package/dist/funnel-paywall-prerender-OSBI4VMY.js +0 -1
  80. package/dist/funnel-runtime-host-AMJXEASH.js +0 -1
  81. package/dist/merchant-bridge-contracts-GJQVKEAG.js +0 -1
  82. package/dist/operation-contracts-MFK2KORK.js +0 -1
  83. package/dist/paywall-ATZ2IZPS.js +0 -1
  84. package/dist/paywall-content-XERXGNND.js +0 -1
  85. package/dist/paywall-session-EMMF6IYS.js +0 -1
  86. package/dist/screen-renderer-B7LUTPTJ.js +0 -1
  87. /package/dist/{chunk-ZYN4CRHS.js → chunk-42UXYMRZ.js} +0 -0
@@ -0,0 +1 @@
1
+ import{$ as se,d as ee,k as te,o as ne,p as re,q as oe,t as O,v as ie,z as ae}from"./chunk-KQF4BVOL.js";import{a as F}from"./chunk-64ETX3AY.js";import{A as Q,C as k,F as Y,I as h,J as D,K as C,L as A,da as ce,e as J,j as Z,l as W,p as I,q as S,s as R,v as X,w as H,y as w,z as P}from"./chunk-HJVEVJXS.js";import{a as T,f as K}from"./chunk-BDC7B4KM.js";import{b as j}from"./chunk-K3VQKR4G.js";import{b as e}from"./chunk-42UXYMRZ.js";import{a as L,b as U}from"./chunk-CILM5XMH.js";var V=e.strictObject({eventsEnabled:e.boolean(),experimentViewsEnabled:e.boolean(),featureUsageEnabled:e.boolean()}),Ze=Object.freeze({eventsEnabled:!0,experimentViewsEnabled:!0,featureUsageEnabled:!0});function We(t,r){return r==="experiment_exposure"?t.experimentViewsEnabled:r==="feature_usage"?t.featureUsageEnabled:t.eventsEnabled}var z=e.tuple([e.number().min(0).max(1),e.number().min(0).max(1)]).refine(([t,r])=>t<=r),Se=e.strictObject({attribute:e.string().optional(),seed:e.string(),hashVersion:e.literal(2),ranges:e.array(z).max(100)}),we=e.strictObject({id:e.string().min(1).max(255),condition:C,gate:e.boolean().optional()}),Oe=e.strictObject({key:e.string().optional(),name:e.string().optional(),passthrough:e.boolean().optional()}),ue={condition:C.optional(),parentConditions:e.array(we).max(100).optional(),weights:e.array(e.number().min(0).max(1)).max(20).optional(),coverage:e.number().min(0).max(1).optional(),hashAttribute:e.string().optional(),fallbackAttribute:e.string().optional(),hashVersion:e.literal(2).optional(),disableStickyBucketing:e.boolean().optional(),bucketVersion:e.number().int().nonnegative().optional(),minBucketVersion:e.number().int().nonnegative().optional(),filters:e.array(Se).max(100).optional(),ranges:e.array(z).max(20).optional(),meta:e.array(Oe).max(20).optional(),seed:e.string().optional(),name:e.string().optional(),phase:e.string().optional()},pe=e.strictObject({...ue,key:e.string().min(1).max(255),variations:e.tuple([h,h]).rest(h).refine(t=>t.length<=20),urlPatterns:e.array(e.strictObject({include:e.boolean(),type:e.enum(["regex","simple"]),pattern:e.string()})).max(100).optional(),force:e.number().int().nonnegative().optional(),active:e.boolean().optional(),persistQueryString:e.boolean().optional()}),G=e.strictObject({value:h,variationId:e.number().int(),key:e.string(),name:e.string().optional(),bucket:e.number().optional(),passthrough:e.boolean().optional(),inExperiment:e.boolean(),hashUsed:e.boolean().optional(),hashAttribute:e.string(),hashValue:e.string(),featureId:e.string().nullable(),stickyBucketUsed:e.boolean().optional()}),je=e.strictObject({...ue,id:e.string().max(255).optional(),force:h.optional(),variations:e.array(h).min(2).max(20).optional(),key:e.string().optional(),range:z.optional(),tracks:e.array(e.strictObject({experiment:pe,result:G})).max(100).optional()}),Ie=e.strictObject({defaultValue:h.optional(),rules:e.array(je).max(500).optional()}),Pe=e.record(e.string(),e.union([e.strictObject({type:e.literal("hashed"),attributeKey:e.string(),values:e.array(e.string().regex(/^[a-f0-9]{64}$/))}),e.strictObject({type:e.literal("list"),attributeKey:e.string(),values:e.array(e.union([e.string(),e.number()]))}),e.strictObject({type:e.literal("condition"),condition:C})])),v=e.strictObject({scope:j,generation:e.string().regex(/^[a-f0-9]{64}$/),evaluatedAt:e.iso.datetime({offset:!0}),expiresAt:e.iso.datetime({offset:!0}).nullable(),features:e.record(e.string(),Ie),savedGroups:Pe,experiments:e.record(e.uuid(),pe)});var ke=v.extend({analyticsConfig:V,remoteFeatures:e.array(e.string().min(1).max(255)).max(500)}),it=ke.omit({evaluatedAt:!0,expiresAt:!0}).superRefine((t,r)=>{for(let a of t.remoteFeatures)Object.hasOwn(t.features,a)&&r.addIssue({code:"custom",path:["features",a],message:"Remote Feature definitions cannot be public"});for(let[a,o]of Object.entries(t.savedGroups))o.type==="list"&&r.addIssue({code:"custom",path:["savedGroups",a],message:"Raw Saved Group lists cannot be public"})}),at=e.strictObject({attributes:D,features:e.array(e.string().min(1).max(255)).max(500).optional(),customerId:e.uuid().optional()}),me=e.strictObject({value:h,source:e.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),on:e.boolean(),off:e.boolean(),ruleId:e.string(),experimentResult:G.optional()}),st=e.strictObject({generation:v.shape.generation,evaluatedAt:v.shape.evaluatedAt,expiresAt:v.shape.expiresAt,features:e.record(e.string(),me),merchandiseContext:e.strictObject({merchandiseId:e.uuid(),merchandise:D}).optional()}),de={eventUuid:e.uuid(),timestamp:e.iso.datetime({offset:!0}),merchandise:te.optional(),deviceId:e.string().min(1).max(255).optional(),sessionId:e.string().min(1).max(255).optional()},le={...de,generation:v.shape.generation},Ce=e.discriminatedUnion("kind",[e.strictObject({...de,kind:e.literal("custom"),name:e.string().min(1).max(255),properties:e.record(e.string(),h).default({})}),e.strictObject({...le,kind:e.literal("experiment_exposure"),experimentId:e.string().min(1).max(255),variationId:e.string().min(1).max(255)}),e.strictObject({...le,kind:e.literal("feature_usage"),feature:e.string().min(1).max(255),value:h,source:me.shape.source,ruleId:e.string().max(255),variationId:e.string().min(1).max(255).optional()})]),ct=e.strictObject({customerId:e.uuid().optional(),events:e.array(Ce).min(1).max(100)}),Ae=e.strictObject({eventUuid:e.uuid(),reason:e.enum(["invalid_event","invalid_merchandise","not_delivered","reserved_name"])}),ut=e.strictObject({inserted:e.number().int().nonnegative(),duplicates:e.number().int().nonnegative(),rejected:e.number().int().nonnegative(),skipped:e.number().int().nonnegative(),rejections:e.array(Ae).max(100),analyticsConfig:V});function fe(t,r){let a=new Set,o=new Set,c=new Set,p=[],g=new Map,f=new Map,d=new Map;function m(s){for(let n of A(s))i(n)}function i(s){if(c.has(s)||!Object.hasOwn(r.savedGroups,s))return;let n=r.savedGroups[s];n&&(c.add(s),d.set(s,n),p.push(()=>{!Array.isArray(n)&&n.type==="condition"&&m(n.condition)}))}function u(s){for(let n of["hashAttribute","fallbackAttribute"])if(s[n]!==void 0&&ae(s[n]))throw new Error(`Funnel GB ${n} uses a reserved flow namespace`);m(s.condition);for(let n of s.parentConditions??[])l(n.id),m(n.condition)}function l(s,n=!1){let b=Object.hasOwn(r.features,s)?r.features[s]:void 0;if(!b){if(n)throw new Error("Required GB Feature is unavailable");return}a.has(s)||(a.add(s),g.set(s,b),p.push(()=>{for(let x of b.rules??[]){u(x);for(let ve of x.tracks??[])u(ve.experiment)}}))}function y(s){let n=Object.hasOwn(r.experiments,s)?r.experiments[s]:void 0;if(!n)throw new Error("Required GB Experiment is unavailable");o.has(s)||(o.add(s),f.set(s,n),p.push(()=>u(n)))}for(let s of t.graph.nodes){s.type==="feature"&&l(s.featureKey,!0),s.type==="split"&&y(s.experimentId),s.type==="condition"&&s.cases.forEach(b=>m(b.condition)),s.type==="offering"&&s.configuration.source==="feature"&&l(s.configuration.featureKey,!0);let n=s.type==="output"?s.value:s.type==="end"?s.output:null;n?.type==="feature"&&l(n.featureKey,!0)}for(let s of p)s();return{...r,features:Object.fromEntries(g),experiments:Object.fromEntries(f),savedGroups:Object.fromEntries(d)}}var ge=e.object({defaultLocale:R,locales:e.record(R,e.object({name:e.string().max(80),description:e.string().max(500)}).strict())}).strict().superRefine((t,r)=>{let a=Object.keys(t.locales);(!a.length||a.length>20||!t.locales[t.defaultLocale])&&r.addIssue({code:"custom",message:"Invalid content languages"}),new TextEncoder().encode(JSON.stringify(t)).length>5e4&&r.addIssue({code:"custom",message:"Content exceeds 50 KB"})});var M=e.discriminatedUnion("type",[e.strictObject({type:e.literal("event"),event:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/)}),e.strictObject({type:e.literal("open_url"),url:e.url().refine(t=>new URL(t).protocol==="https:")})]),Fe=P,Ee=e.discriminatedUnion("type",[e.object({type:e.literal("checkout"),product:I}).strict(),e.object({type:e.literal("close")}).strict(),e.object({type:e.literal("action"),action:M}).strict()]),E=e.object({schemaVersion:e.literal(3),kind:e.literal("paywall"),name:e.string().trim().min(1).max(80),presentation:S,requirement:K.optional(),products:F,offeringVersionId:e.uuid().nullable(),offeringId:e.uuid(),screen:Fe,buttons:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Ee)}).strict(),Pt=E.superRefine((t,r)=>{(t.screen.surface!=="paywall"||t.screen.actions.some(o=>!["event","navigate"].includes(o.type)||o.close))&&r.addIssue({code:"custom",message:"Paywall screen is incomplete"});for(let o of Re(t))r.addIssue({code:"custom",message:o});for(let o of _e(t))r.addIssue({code:"custom",message:o});for(let o of t.screen.actions){let c=o.properties.closeControl;c!==void 0&&(c!=="content"||t.buttons[o.id]?.type!=="close")&&r.addIssue({code:"custom",path:["screen","actions",o.id],message:'Only a close button can carry closeControl, and its value is "content"'})}for(let o of t.screen.actions){let c=o.properties.couponBinding;c!==void 0&&(typeof c!="string"||!X.safeParse(c).success||t.buttons[o.id]?.type!=="checkout"||Y(t.screen,c)?.type!=="text")&&r.addIssue({code:"custom",path:["screen","actions",o.id],message:"Choose a Coupon text binding for this checkout action"})}k(t.screen).some(o=>!o.complete)&&r.addIssue({code:"custom",message:"Paywall needs complete local content"}),(Object.keys(t.buttons).length!==t.screen.actions.filter(o=>o.type!=="navigate").length||t.screen.actions.some(o=>o.type!=="navigate"&&!Object.hasOwn(t.buttons,o.id)))&&r.addIssue({code:"custom",message:"Paywall buttons require matching node policies"}),Object.values(t.buttons).some(o=>o.type==="checkout")||r.addIssue({code:"custom",message:"A paywall requires a purchase or membership change button"})});function _e(t){let r=t.products.items.map(p=>p.productVersionId),a=Z(t.screen),o=new Set,c=[];(!r.length||!t.products.defaultProductVersionId||!r.includes(t.products.defaultProductVersionId))&&c.push("products"),t.offeringVersionId||c.push("offering"),t.products.grouping&&(!W(t.products.grouping,r)||t.products.grouping.tiers.some(p=>!t.products.grouping.assignments.some(g=>g.tierId===p.id)))&&c.push("grouping");for(let p of Object.values(t.buttons))if(p.type==="checkout"){let g=p.product;if(g.type==="fixed")o.add(g.productVersionId);else{g.allowedProductVersionIds.forEach(m=>o.add(m));let f=!1,d=a[g.pickerId];d&&(f=!0,(g.allowedProductVersionIds.some(m=>!d.ids.includes(m))||d.ids.some(m=>!g.allowedProductVersionIds.includes(m)))&&c.push("picker")),w(t.screen,m=>{if(m.id!==g.pickerId||m.type!=="plan_picker")return;f=!0,(JSON.stringify(m.planIds)!==JSON.stringify(r)||JSON.stringify(g.allowedProductVersionIds)!==JSON.stringify(r)||m.defaultPlan!==t.products.defaultProductVersionId)&&c.push("picker");let i=m.grouping?{tiers:m.grouping.tiers,assignments:m.grouping.assignments}:void 0;JSON.stringify(i)!==JSON.stringify(t.products.grouping)&&c.push("grouping")}),f||c.push("picker")}}return(!o.size||[...o].some(p=>!r.includes(p)))&&c.push("purchase"),w(t.screen,p=>{p.type==="stack"&&p.productSlot&&!p.bind?.plan&&c.push(`productBinding:${p.id}`),(p.type==="stack"||p.type==="button")&&p.bind?.plan&&!r.includes(p.bind.plan)&&c.push("binding"),p.type==="plan_picker"&&(!p.planIds?.length||p.planIds.some(g=>!r.includes(g)))&&c.push("binding")}),[...new Set(c)]}function Re(t){let r=[],a=t.screen.pages.at(-1),o=new Map;for(let f of t.screen.pages)o.set(f.id,[]),Q(f.root,d=>{let m=d.type==="button"?d.action:d.type==="stack"?d.purchaseAction:void 0;if(m){let i=t.screen.actions.find(l=>l.id===m);i?.type==="navigate"&&o.get(f.id).push(i.pageId);let u=t.buttons[m];f.id!==a.id&&u&&u.type!=="close"&&r.push(`purchaseScreen:${d.id}`)}f.id!==a.id&&(d.type==="plan_picker"||d.type==="stack"&&d.productSlot)&&r.push(`packageScreen:${d.id}`)});let c=new Set;function p(f){if(!c.has(f)){c.add(f);for(let d of o.get(f)??[])p(d)}}let g=t.screen.initialPageId??t.screen.pages[0]?.id;g?p(g):r.push("initialPage");for(let f of t.screen.pages)c.has(f.id)||r.push(`unreachableScreen:${f.id}`);return[...new Set(r)]}var ye=e.object({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),revision:e.number().int().nonnegative(),state:e.enum(["active","archived"]),publishedVersionId:e.uuid().nullable(),updatedAt:e.iso.datetime({offset:!0}),draft:E}).strict(),kt=e.object({rows:e.array(ye).max(200),nextCursor:e.uuid().nullable()}).strict(),Ct=ye.omit({draft:!0}).extend({name:e.string(),productCount:e.number().int().nonnegative()}).strict(),At=e.discriminatedUnion("action",[e.object({action:e.literal("save"),id:e.uuid().nullable(),revision:e.number().int().nonnegative(),document:E}).strict(),e.object({action:e.enum(["publish","archive"]),id:e.uuid(),revision:e.number().int().nonnegative()}).strict()]),Ft=e.object({paywalls:e.array(e.object({id:e.uuid(),paywallId:e.uuid(),version:e.number().int().positive(),name:e.string().min(1).max(80),presentation:S,buttons:E.shape.buttons}).strict()).max(500),limited:e.boolean()}).strict();var De=["customer_data","coupon_code"],be=e.string().min(1).max(255).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/),Ve=e.string().min(1).max(255).regex(/^[a-z0-9][a-z0-9-]*$/),_=(t,r)=>new Set(t.map(r)).size===t.length,ze=e.strictObject({currency:T,amountMinor:e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER)}),Ge=e.strictObject({featureId:e.uuid(),name:e.string().trim().min(1).max(120),allowance:e.string().max(40).nullable(),access:e.boolean()}),Me=e.strictObject({stripe:e.strictObject({prices:e.array(ze).min(1).max(50)}).optional(),apple:e.strictObject({productIds:e.array(be).min(1).max(10)}).optional(),google:e.strictObject({products:e.array(e.strictObject({productId:be,basePlanId:Ve.nullable()})).min(1).max(10)}).optional()}).superRefine((t,r)=>{(t.stripe&&!_(t.stripe.prices,a=>a.currency)||t.apple&&!_(t.apple.productIds,a=>a)||t.google&&!_(t.google.products,a=>`${a.productId}:${a.basePlanId}`))&&r.addIssue({code:"custom",message:"Duplicate channel entry"})}),qe=e.strictObject({name:e.string().trim().min(1).max(80),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(100),trial:e.strictObject({days:e.number().int().min(1).max(730),cardRequired:e.boolean()}).nullable(),benefits:e.array(Ge).max(50).refine(t=>_(t,r=>r.featureId),"Duplicate benefit"),channels:Me,prepaid:e.array(J).max(100).optional()}),Be=e.strictObject({digest:O,content:e.strictObject({discount:ne,duration:re,appliesTo:oe,displayCopy:ge.nullable(),firstPurchaseOnly:e.boolean(),qualificationRequired:e.boolean(),startsAt:e.iso.datetime().nullable(),endsAt:e.iso.datetime().nullable(),grantWindowHours:e.number().int().positive(),perCustomerLimit:e.number().int().positive()})}),Ne=e.discriminatedUnion("type",[e.strictObject({type:e.literal("checkout"),product:I}),e.strictObject({type:e.literal("close")}),e.strictObject({type:e.literal("action"),action:M})]),Lt=e.strictObject({kind:e.literal("paywall"),formatVersion:e.literal(1),name:e.string().trim().min(1).max(80),offeringVersionId:e.uuid(),presentation:S,screen:P,products:F,catalog:e.record(e.uuid(),qe),buttons:e.record(H,Ne),coupons:e.record(e.uuid(),Be)}).superRefine((t,r)=>{let a=n=>r.addIssue({code:"custom",message:n}),{screen:o}=t;ce(o,t.catalog).forEach(a),o.surface!=="paywall"&&a("Screen must be a Paywall"),ie(o,De).forEach(a),k(o).some(n=>!n.complete)&&a("Every published locale must be complete");let c=new Set,p=new Set,g=new Set;w(o,n=>{let b="bind"in n?n.bind:void 0;b?.promotionCode&&a("Promotion codes must not be published"),b?.plan&&c.add(b.plan),b?.coupon&&p.add(b.coupon),n.type==="plan_picker"&&(n.planIds?.forEach(x=>c.add(x)),n.defaultPlan&&c.add(n.defaultPlan)),n.type==="text"&&n.feature&&g.add(n.feature.id)});let f=t.products.items.map(n=>n.productVersionId),d=Object.keys(t.catalog);(f.length!==d.length||f.some(n=>!Object.hasOwn(t.catalog,n)))&&a("Catalog must contain exactly the displayed Products");let m=new Set(f);t.products.defaultProductVersionId!==null&&!m.has(t.products.defaultProductVersionId)&&a("Default Product must be displayed");for(let n of c)m.has(n)||a("Screen references a Product that is not displayed");for(let n of Object.values(t.catalog))!n.channels.stripe&&!n.channels.apple&&!n.channels.google&&a("A displayed Product needs at least one sales channel");let i=new Set(Object.values(t.catalog).flatMap(n=>n.benefits.map(b=>b.featureId)));for(let n of g)i.has(n)||a("Feature text must read a displayed benefit");let u=o.actions.filter(n=>n.type!=="navigate");o.actions.some(n=>n.type!=="event"&&n.type!=="navigate")&&a("Paywall actions are events or navigation"),(Object.keys(t.buttons).length!==u.length||u.some(n=>!Object.hasOwn(t.buttons,n.id)))&&a("Buttons must match the screen's actions");let y=!1;for(let n of Object.values(t.buttons)){if(n.type!=="checkout")continue;y=!0,(n.product.type==="fixed"?[n.product.productVersionId]:n.product.allowedProductVersionIds).some(x=>!m.has(x))&&a("Checkout may only sell displayed Products")}y||a("A Paywall needs a checkout button");let s=Object.keys(t.coupons);(s.length!==p.size||s.some(n=>!p.has(n)))&&a("Coupons must be exactly the bound Coupons")}),he=e.strictObject({state:e.enum(["published","archived"]),controlRevision:e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),currentVersionId:e.uuid(),versions:e.record(e.uuid(),e.strictObject({version:e.number().int().positive(),artifact:e.string().min(1),sourceDigest:e.string().regex(/^[a-f0-9]{64}$/)}))}).refine(t=>Object.keys(t.versions).length>0,"Reviewed Paywall Versions are required");var $e={manifestCdnSeconds:15,maxControlAgeMs:6e4,initializationMs:5e3,maxArtifactBytes:1048576,maxManifestBytes:524288,maxCacheBytes:32*1048576,retentionMs:7*864e5},q=e.string().regex(/^[a-f0-9]{64}$/),B=e.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER),Le=j.extend({environmentId:e.uuid()}),xe=e.strictObject({features:e.array(e.string()).max(500),experiments:e.record(e.uuid(),e.array(e.string()).max(20)),savedGroups:e.array(e.string()).max(1e3)}),Ue=e.strictObject({kind:e.enum(["funnel","paywall","gb_features","gb_page_experiments"]),formatVersion:e.number().int().positive(),url:e.string().min(1).max(2048),sha256:q,byteLength:e.number().int().positive().max($e.maxArtifactBytes),generation:q.optional()}),Te=e.strictObject({state:e.enum(["active","paused","archived"]),controlRevision:B,evaluationMode:e.enum(["local","remote"]),evaluationRevision:B,currentVersionId:e.uuid(),versions:e.record(e.uuid(),e.strictObject({artifact:e.string(),dependencies:xe,definitionDigest:O.optional(),couponDigests:e.record(e.uuid(),O).optional()}))}),en=e.strictObject({kind:e.literal("sdk_configuration"),schemaVersion:e.literal(1),scope:Le,revision:B,generation:q,policy:e.strictObject({refreshIntervalSeconds:e.number().positive().max(15),maxControlAgeSeconds:e.number().positive().max(60)}),gb:e.strictObject({features:e.string().nullable(),pageExperiments:e.string().nullable()}),artifacts:e.record(e.string(),Ue),funnels:e.record(e.uuid(),Te),paywalls:e.record(e.uuid(),he).optional()}).superRefine((t,r)=>{let a=(o,c)=>{o!==null&&t.artifacts[o]?.kind!==c&&r.addIssue({code:"custom",message:"Missing or wrong-kind configuration artifact"})};a(t.gb.features,"gb_features"),a(t.gb.pageExperiments,"gb_page_experiments");for(let o of Object.values(t.paywalls??{}))for(let c of Object.values(o.versions))a(c.artifact,"paywall");for(let o of Object.values(t.funnels)){o.evaluationMode==="remote"&&Object.keys(o.versions).length&&r.addIssue({code:"custom",message:"Remote Funnel graphs cannot be public"}),o.evaluationMode==="local"&&!o.versions[o.currentVersionId]&&r.addIssue({code:"custom",message:"Current Funnel Version is not retained"});for(let c of Object.values(o.versions))a(c.artifact,"funnel")}});function N(t){if(Array.isArray(t))return`[${t.map(N).join(",")}]`;if(t!==null&&typeof t=="object")return`{${Object.entries(t).sort(([a],[o])=>a<o?-1:a>o?1:0).map(([a,o])=>`${JSON.stringify(a)}:${N(o)}`).join(",")}}`;let r=JSON.stringify(t);if(r===void 0)throw new Error("Configuration must contain JSON values");return r}function Je(t){return L(U(typeof t=="string"?new TextEncoder().encode(t):t))}function tn(t){return Je(N(t))}var $=class extends Error{constructor(a,o){super(a);this.dependency=o}dependency};function nn(t,r){let a=i=>i.type==="feature"?i.featureKey:i.type==="end"&&i.output?.type==="feature"?i.output.featureKey:i.type==="output"&&i.value.type==="feature"?i.value.featureKey:void 0,o=(i,u)=>t.graph.nodes.find(l=>i==="experiment"?l.type==="split"&&l.experimentId===u:i==="feature"&&a(l)===u)?.name,c=(i,u,l=o(u.type,u.resource))=>new $(i,{...u,...l?{step:l}:{}});for(let i of Object.values(t.references)){let u=i.type==="flag"?!Object.hasOwn(r.features,i.key)||r.remoteFeatures.includes(i.key)?{type:"feature",resource:i.key}:null:i.type==="experiment"?Object.hasOwn(r.experiments,i.id)?null:{type:"experiment",resource:i.id}:i.type==="saved_group"&&!Object.hasOwn(r.savedGroups,i.id)?{type:"saved_group",resource:i.id}:null;if(u)throw c("Funnel dependency is absent from GB public delivery",{reason:"unavailable",...u})}let p=fe(t,{...r,evaluatedAt:new Date(0).toISOString(),expiresAt:null}),g=new Set(r.remoteFeatures);for(let i of t.graph.nodes){let u=a(i);if(!u)continue;let l=p.features[u],y=i.type==="feature"?t.variables[i.writes.value]:t.outputSchema,s={type:"feature",resource:u};if(!l||!y)throw c("Required public Feature declaration is unavailable",{reason:"unavailable",...s},i.name);if([l.defaultValue,...(l.rules??[]).flatMap(b=>[...Object.hasOwn(b,"force")?[b.force]:[],...b.variations??[],...(b.tracks??[]).flatMap(x=>x.experiment.variations)])].some(b=>b===void 0||!ee(y,b)))throw c("GB Feature values violate the Funnel type contract",{reason:"value_type",...s},i.name)}let f=new Set,d=(i,u)=>{for(let l of A(i)){if(f.has(l))continue;let y=r.savedGroups[l];if(!y)throw c("Required public Saved Group is unavailable",{reason:"unavailable",type:"saved_group",resource:l},u);f.add(l),!Array.isArray(y)&&y.type==="condition"&&d(y.condition,u)}},m=(i,u)=>{if(g.has(i)||!r.features[i])throw c("Local Funnel requires public Local prerequisites",{reason:"unavailable",type:"feature",resource:i},u)};for(let i of t.graph.nodes)if(i.type==="condition")for(let u of i.cases)d(u.condition,i.name);for(let[i,u]of Object.entries(p.features)){let l=o("feature",i);for(let y of u.rules??[]){d(y.condition,l);for(let s of[...y.parentConditions??[],...(y.tracks??[]).flatMap(n=>n.experiment.parentConditions??[])])m(s.id,l),d(s.condition,l);for(let s of y.tracks??[])d(s.experiment.condition,l)}}for(let[i,u]of Object.entries(p.experiments)){let l=o("experiment",i);d(u.condition,l);for(let y of u.parentConditions??[])m(y.id,l),d(y.condition,l)}for(let i of t.graph.nodes)if(i.type==="split"){let u=p.experiments[i.experimentId],l={type:"experiment",resource:i.experimentId};if(!u)throw c("Local Funnel requires a public Experiment",{reason:"unavailable",...l},i.name);for(let y of u.variations)if(typeof y!="string"||!Object.hasOwn(i.routes,y))throw c("Experiment variation has no declared Funnel route",{reason:"variation_route",...l},i.name)}return xe.parse({features:Object.keys(p.features).sort(),experiments:Object.fromEntries(Object.entries(p.experiments).map(([i,u])=>[i,u.variations.map(String)])),savedGroups:[...f].sort()})}function rn(t){return se.parse(t)}export{E as a,We as b,pe as c,Pe as d,v as e,ke as f,it as g,at as h,st as i,ct as j,ut as k,fe as l,Lt as m,$e as n,Le as o,Ue as p,en as q,N as r,Je as s,tn as t,nn as u,rn as v};
@@ -1 +1 @@
1
- import{b as e}from"./chunk-ZYN4CRHS.js";var r=e.number().int().min(1).max(Number.MAX_SAFE_INTEGER),m=e.enum(["unknown","denied","provisional","granted"]),d=e.enum(["ios","android"]),i=e.strictObject({installationId:e.uuid(),publicKey:e.string().regex(/^[A-Za-z0-9_-]{80,200}$/),issuedAt:e.iso.datetime({offset:!0}),signature:e.string().regex(/^[A-Za-z0-9_-]{86}$/)}),a=e.string().regex(/^[a-f0-9]{64}$/),p=i.extend({sequence:r,platform:d,credentialDigest:a}),f=i.extend({credentialDigest:a}),x=i.extend({sequence:r,platform:d}),l=i.extend({sequence:r,credentialDigest:a,connectionId:e.uuid().nullable(),kind:e.enum(["fcm_token","apns_token"]).nullable(),token:e.string().regex(/^[\x21-\x7e]{16,4096}$/).nullable(),permission:m}),g=l,b=l.extend({challenge:e.string().regex(/^[A-Za-z0-9_-]{100,3500}$/)}),S=e.strictObject({requested:e.literal(!0),expiresAt:e.iso.datetime({offset:!0})}),A=e.strictObject({installationId:e.uuid(),bound:e.boolean(),identitySeq:r,bindingGeneration:r,addressSeq:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),addressRevision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),connectionId:e.uuid().nullable(),addressStatus:e.enum(["active","invalid"]).nullable(),permission:m}),I=e.strictObject({channel:e.enum(["email","sms","voice","push"]),state:e.enum(["unknown","allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:e.iso.datetime({offset:!0}).nullable()}),P=e.strictObject({state:e.enum(["allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)});function y(s,c,t){let n=["indiana_push_v1",s,c.projectId,c.environment,t.installationId,t.publicKey,t.issuedAt];s==="bind"?n.push(t.sequence,t.platform,t.credentialDigest):s==="detach"?n.push(t.sequence,t.platform):s==="read"?n.push(t.credentialDigest):n.push(t.sequence,t.credentialDigest,t.connectionId,t.kind,t.token,t.permission),s==="recovery_confirm"&&n.push(t.challenge);let u=JSON.stringify(n);if([...u].some(o=>o.charCodeAt(0)>127))throw new Error("Push proof fields must be ASCII");return Uint8Array.from(u,o=>o.charCodeAt(0))}export{p as a,f as b,x as c,l as d,g as e,b as f,S as g,A as h,I as i,y as j};
1
+ import{b as e}from"./chunk-42UXYMRZ.js";var r=e.number().int().min(1).max(Number.MAX_SAFE_INTEGER),m=e.enum(["unknown","denied","provisional","granted"]),d=e.enum(["ios","android"]),i=e.strictObject({installationId:e.uuid(),publicKey:e.string().regex(/^[A-Za-z0-9_-]{80,200}$/),issuedAt:e.iso.datetime({offset:!0}),signature:e.string().regex(/^[A-Za-z0-9_-]{86}$/)}),a=e.string().regex(/^[a-f0-9]{64}$/),p=i.extend({sequence:r,platform:d,credentialDigest:a}),f=i.extend({credentialDigest:a}),x=i.extend({sequence:r,platform:d}),l=i.extend({sequence:r,credentialDigest:a,connectionId:e.uuid().nullable(),kind:e.enum(["fcm_token","apns_token"]).nullable(),token:e.string().regex(/^[\x21-\x7e]{16,4096}$/).nullable(),permission:m}),g=l,b=l.extend({challenge:e.string().regex(/^[A-Za-z0-9_-]{100,3500}$/)}),S=e.strictObject({requested:e.literal(!0),expiresAt:e.iso.datetime({offset:!0})}),A=e.strictObject({installationId:e.uuid(),bound:e.boolean(),identitySeq:r,bindingGeneration:r,addressSeq:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),addressRevision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),connectionId:e.uuid().nullable(),addressStatus:e.enum(["active","invalid"]).nullable(),permission:m}),I=e.strictObject({channel:e.enum(["email","sms","voice","push"]),state:e.enum(["unknown","allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:e.iso.datetime({offset:!0}).nullable()}),P=e.strictObject({state:e.enum(["allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)});function y(s,c,t){let n=["indiana_push_v1",s,c.projectId,c.environment,t.installationId,t.publicKey,t.issuedAt];s==="bind"?n.push(t.sequence,t.platform,t.credentialDigest):s==="detach"?n.push(t.sequence,t.platform):s==="read"?n.push(t.credentialDigest):n.push(t.sequence,t.credentialDigest,t.connectionId,t.kind,t.token,t.permission),s==="recovery_confirm"&&n.push(t.challenge);let u=JSON.stringify(n);if([...u].some(o=>o.charCodeAt(0)>127))throw new Error("Push proof fields must be ASCII");return Uint8Array.from(u,o=>o.charCodeAt(0))}export{p as a,f as b,x as c,l as d,g as e,b as f,S as g,A as h,I as i,y as j};
@@ -0,0 +1 @@
1
+ import{i as ie}from"./chunk-5IGASP6C.js";import{a as Z,c as ee,e as te,f as ne,h as N,j as re,k as oe,l as se}from"./chunk-DTWSDNYI.js";import{b as X}from"./chunk-NK55HFFF.js";import{r as V}from"./chunk-Y5RT7PAD.js";import"./chunk-KQF4BVOL.js";import"./chunk-2LND3R7K.js";import"./chunk-64ETX3AY.js";import"./chunk-WP3SZU24.js";import"./chunk-4E326NPY.js";import{$ as Y,D as G,I as R,aa as K,r as $}from"./chunk-HJVEVJXS.js";import"./chunk-BDC7B4KM.js";import"./chunk-UD7XPHE4.js";import"./chunk-K3VQKR4G.js";import{a as p}from"./chunk-O5VA3E5D.js";import"./chunk-Q7K66FTS.js";import"./chunk-EEYDOVVS.js";import{b as u}from"./chunk-42UXYMRZ.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var z=new WeakMap;function ce(s){let t={string:u.string(),number:u.number().finite(),boolean:u.boolean(),strings:u.array(u.string()),json:R}[s.type];return s.nullable?t.nullable():t}function ae(s,t){let f=u.record(u.string(),R).parse(s);if(Object.keys(f).length>40)throw new p("INVALID_REQUEST","Too many content inputs");for(let[m,r]of Object.entries(f))Y.parse({[m]:r});if(Object.keys(f).some(m=>!Object.hasOwn(t.inputs,m)))throw new p("INVALID_REQUEST","Undeclared content input");for(let[m,r]of Object.entries(t.inputs))if(Object.hasOwn(f,m))ce(r).parse(f[m]);else if(r.required)throw new p("INVALID_REQUEST",`Missing content input ${m}`);return f}async function Ae(s,t){return le(s,t,!1)}async function Se(s,t){return le(s,t,!0)}async function le(s,t,f){t.signal?.throwIfAborted();let m=X.parse(t.content),r=m.document;if(t.closeControl==="content"&&!r.screen.actions.some(e=>e.type==="event"&&e.close))throw new p("INVALID_REQUEST","An authored Close control requires a declared Close action");if(z.has(s))throw new p("CONFLICT","Content is already mounted in this container");let y=ae(t.inputs??{},r.contract),T=new Set(u.array(u.string()).max(40).parse(t.mutableInputs??[]));if(T.size!==(t.mutableInputs?.length??0)||[...T].some(e=>!Object.hasOwn(r.contract.inputs,e)))throw new p("INVALID_REQUEST","Mutable content inputs must name unique declared inputs");for(let e of Object.keys(r.contract.outputs))if(typeof t.actions[e]!="function")throw new p("INVALID_REQUEST",`Missing host handler for ${e}`);let M=K.parse(t.bindings??[]),d=s.ownerDocument,ue=s.clientHeight||d.defaultView?.innerHeight||800,P,w,a,_,x=r.kind==="popup",n=x?d.createElement("dialog"):null,c=d.createElement("div");if(c.dataset.indianaContent=r.kind,c.setAttribute("aria-label",r.name),c.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",r.name);let e=r.screen.presentation;n.style.cssText="box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto",e.type==="modal"||e.type==="sheet"?(n.style.width=`${$[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",a=ee(n,r.screen,()=>{w?.resizeViewport(d.defaultView?.innerHeight||800,d.defaultView?.innerWidth||1024)}),n.append(c),s.append(n)}else s.append(c);let i=!1,A=!1,E=!1,S=!1,de=n?oe(n):se(c,s),D=re(s,t,r.kind,()=>{k()&&(b(),h(t.onDismiss))}),q,H,L=new Promise((e,o)=>{q=e,H=o});L.catch(()=>{});let g=null,I=structuredClone(r.screen),W=G(I,[t.locale,...d.defaultView?.navigator.languages??[]]),j=t.capabilities;I.actions=I.actions.map(e=>e.type==="event"?{...e,close:!1}:e);function b(){i||(i=!0,t.signal?.removeEventListener("abort",b),D.finish("dismissed"),H(new Error("Content preparation cancelled")),a?.destroy(),_?.(),w?.destroy(),n?.close(),n?.remove(),c.remove(),z.delete(s),n&&P?.())}let v=()=>{!E||!k()||(b(),h(t.onDismiss))};function k(){try{return t.canDismiss?.()!==!1}catch(e){return h(t.onError,e),!1}}if(n&&t.closeControl!=="content"){let e=d.createElement("button");e.type="button",e.textContent="\xD7",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),ne(e,r.screen.theme),e.addEventListener("click",v),n.prepend(e)}n&&a?.responsive&&(_=Z(n,v,k,t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),n.addEventListener("click",e=>{if(e.target!==n)return;let o=n.getBoundingClientRect();(e.clientX<o.left||e.clientX>o.right||e.clientY<o.top||e.clientY>o.bottom)&&v()})),n?.addEventListener("cancel",e=>{e.preventDefault(),v()}),n?.addEventListener("keydown",e=>{e.key==="Escape"&&(e.preventDefault(),v())});async function F(){if(i||!E||A||!g)return;let e=g;A=!0,c.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),g=null}catch(o){i||h(t.onError,o)}finally{A=!1,i||c.removeAttribute("aria-busy")}}function J(){if(i)throw new p("CONFLICT","Content host has been destroyed");E||!S||(P??=N(d),D.present(e=>{de(),n&&(a?.latch(),n.showModal(),a?.responsive&&n.focus({preventScroll:!0}),!e&&t.loading!=="host"&&te(n,a?.type??r.screen.presentation.type,a?.responsive)),E=!0}))}function U(e){D.finish("error",e),H(e instanceof Error?e:new Error(String(e))),b()}let Q={destroy:b,show:J,get pendingAction(){return g?structuredClone(g):null},retryAction:F,updateInputs(e){if(i)throw new p("CONFLICT","Content host has been destroyed");let o=u.record(u.string(),R).parse(e),C=ae({...y,...o},r.contract);for(let l of Object.keys(o))if(!T.has(l)&&(!Object.hasOwn(y,l)||V(y[l])!==V(C[l])))throw new p("PRECONDITION_FAILED","This content input is frozen; prepare a new presentation");V(y)!==V(C)&&(w?.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:C}}),y=C)},updateCapabilities(e){if(i)return;let o=structuredClone(e);w?.updateCapabilities(o),j=o}};z.set(s,Q),t.signal?.addEventListener("abort",b,{once:!0});try{if(t.signal?.throwIfAborted(),f||(P=N(d),D.start(x,t.locale??r.screen.strings.defaultLocale),i&&await L),w=ie(c,{mode:"live",rendererUrl:t.rendererUrl,title:r.name,viewportHeight:r.kind==="page"?ue:a?.responsive?d.defaultView?.innerHeight||800:void 0,...a?.responsive?{viewportWidth:d.defaultView?.innerWidth||1024,hostPresentation:()=>a.type}:{},onResize:e=>{i||a?.responsive&&(c.style.height=`${e}px`,c.style.overflow="clip",a.setContentHeight(e))},onRendered:e=>{if(!i&&(e&&n?.setAttribute("aria-label",e),!S))try{S=!0,f||J(),q()}catch(o){U(o),h(t.onError,o)}},onError:e=>{if(i)return;let o=new Error(e);S||U(o),h(t.onError,o)},onEscape:x?v:void 0,onAction:(e,o,C)=>{if(i||!E||A||g)return;let l=r.screen.actions.find(O=>O.id===e),B=r.contract.outputs[e];if(!(l?.type!=="event"||!B)&&!(l.close&&!k()))try{let O=ce(B).parse(Object.hasOwn(l.properties,"value")?l.properties.value:l.properties);g=structuredClone({requestId:crypto.randomUUID(),contentVersionId:m.id,actionId:e,event:l.event,value:O,selection:o??{},answers:C??{},requestedClose:l.close}),F()}catch(O){h(t.onError,O)}}}),w.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:y}}),await Promise.race([w.ready,L]),f&&await L,i)throw new Error("Content preparation cancelled");return Q}catch(e){throw U(e),e}}export{Ae as mountContent,Se as prepareContent};
@@ -1 +1 @@
1
- import{b as B}from"./chunk-OL2AI6DA.js";import{a as z}from"./chunk-I6D25FWU.js";import{b as S}from"./chunk-DB4EO3JG.js";import{b as V}from"./chunk-BL7E4RZ2.js";import"./chunk-VWMFR22O.js";import"./chunk-W32FI2A2.js";import{i as W,j}from"./chunk-YQX27SBG.js";import"./chunk-M3GGR53D.js";import"./chunk-UVUFJO2V.js";import"./chunk-HYE2YQYM.js";import"./chunk-MHWPEMX7.js";import"./chunk-5XKFUFXK.js";import"./chunk-2KKLY323.js";import"./chunk-R3YVDRTB.js";import"./chunk-U4WUX3WB.js";import"./chunk-JOIPLLHK.js";import"./chunk-GLYFT5WW.js";import"./chunk-WRLVPHPE.js";import"./chunk-3NCMYTNG.js";import"./chunk-35VG2IYD.js";import"./chunk-CGXNU5BC.js";import"./chunk-HVVJGLYZ.js";import"./chunk-ZYF6TRJ3.js";import"./chunk-QHJWVLJC.js";import"./chunk-XE7GU6FZ.js";import"./chunk-LAGGWYH3.js";import"./chunk-DHT3AWJQ.js";import{a as v}from"./chunk-TIQS5DUF.js";import"./chunk-7ZEXY4GC.js";import"./chunk-SLUA7ABW.js";import"./chunk-LVG5ED52.js";import"./chunk-3VUPVXAV.js";import"./chunk-RHF4NFCZ.js";import"./chunk-ZYN4CRHS.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as u}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var m=new WeakMap,I=new WeakMap,H=new WeakSet;function re(C,e){let s=e.prepared,N=()=>{s&&!H.has(s)&&S(s)?.release()},R=m.get(e.client);if(R)return N(),R;let c=e.allowNewPurchase===!1||!e.start?void 0:{...e.start,requestId:e.start.requestId??crypto.randomUUID()};c&&s?.state==="ready"&&s.matches(c)&&s.open();let i=c&&s&&(s.state==="preparing"||["shown","closed"].includes(s.state)&&s.matches(c))?s:void 0;i?H.add(i):N();let d=i&&S(i);d?.claim();let b=Promise.resolve().then(async()=>{let r=!1,w,E,U=!1,T=()=>{},L=()=>{},y,M=!1,O=!1,f,_=!1,n=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,P=()=>{m.get(e.client)===b&&m.delete(e.client),n.removeEventListener("abort",A),T(),L(),i&&H.delete(i),d?.release()};function x(){if(f)return f;let l=new Promise(h=>f=h);return I.set(e.client,l),l.then(()=>{I.get(e.client)===l&&I.delete(e.client)}),m.get(e.client)===b&&m.delete(e.client),f}let a=j(C,e,"funnel",()=>F(),z);function A(){F()}function F(l=!1){if(!r){if(r=!0,a.finish("dismissed"),w){w.destroy();return}if(l&&y){let h=x();_=!0,y.then(async g=>{g.mode==="run"&&g.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===c?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{h(),u(e.onDismiss,null)}),P();return}P(),u(e.onDismiss,null)}}n.addEventListener("abort",A,{once:!0}),d&&(L=d.onClose(()=>{M?r||x():F(!0)}));try{let k=function(){!r&&!n.aborted&&!U&&E&&e.client.recovery.status==="complete"&&(U=!0,u(e.onComplete,structuredClone(E)))},D=function(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(t):C.ownerDocument.defaultView?.location.assign(t)};var J=k,K=D;n.throwIfAborted();let l=e.client.controller?.view?.paywall?.resolution,h=l&&"document"in l?l.document:e.loadingDocument;a.start(!0,c?.locale??e.client.attempt?.locale??h?.screen.strings.defaultLocale,h??null),i?.state==="shown"?(O=!0,a.present(()=>{})):i?.state==="preparing"&&i.ready.then(t=>{if(t){if(r||!a.active||!i.matches(c)||!d?.revealable)return d?.release();a.present(()=>{i.open()==="shown"?O=!0:d.release()})}});let g=I.get(e.client);if(g&&await a.wait(g),r)return null;n.throwIfAborted(),y=c?e.client.start(c):e.client.refresh();let q=await a.wait(y,W);if(r)return null;n.throwIfAborted();let G=e.client.controller;return q.mode!=="run"||q.status==="blocked"||!G?(a.finish("skipped"),P(),O&&u(e.onDismiss,null),null):(n.removeEventListener("abort",A),M=!0,T=e.client.subscribe(k),w=await B(C,{...e,prepared:i,client:G,signal:n,checkoutNavigation:"after_confirmation",resumeCheckout:t=>e.client.continueCheckout(D,t),terminateCheckout:e.allowNewPurchase===!1?void 0:t=>e.client.terminateCheckout(t),async onCheckoutUrl(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let o=e.client.recovery;if((!o.actions.includes("continue_checkout")||!o.purchases.some(p=>p.type==="checkout"&&p.checkoutUrl===t))&&(o=await e.client.refresh(),n.throwIfAborted(),r))throw new DOMException("Presentation dismissed","AbortError");if(V(o)!==t)throw new v("PURCHASE_PENDING","Checkout differs from the original recovery proof");return D(t)},async resolveOfferId(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let o=e.client.attempt;if(!o)throw new v("PURCHASE_PENDING","Read the original Start before selecting an offer");let p=await e.resolveOfferId?.(t,o);if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==o.requestId)throw new v("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return p},onComplete(t){E=t,k()},onError(t){u(e.onError,t),t instanceof v&&t.status===401&&!n.aborted&&e.client.refresh().catch(o=>u(e.onError,o))},onDismiss(t){r=!0,P(),f?.(),u(e.onDismiss,t)}},a),r||n.aborted?(w.destroy(),null):w)}catch(l){if(_||f?.(),r)return null;throw a.finish("error",l),P(),u(e.onError,l),l}});return m.set(e.client,b),b}export{re as showFunnelPurchase};
1
+ import{b as B}from"./chunk-WQZOT22S.js";import{a as z}from"./chunk-JXTJT2EW.js";import{b as S}from"./chunk-JBDNNV3P.js";import{b as V}from"./chunk-DSLJUN3P.js";import"./chunk-L54MODP5.js";import"./chunk-W32FI2A2.js";import{i as W,j}from"./chunk-DTWSDNYI.js";import"./chunk-DK5PHPSO.js";import"./chunk-IV6LKRYM.js";import"./chunk-G7Y7LPOB.js";import"./chunk-IHB275C3.js";import"./chunk-KTBXAATX.js";import"./chunk-UAJTQ23E.js";import"./chunk-GEPX4AUR.js";import"./chunk-TLV3NVUU.js";import"./chunk-Y5RT7PAD.js";import"./chunk-KQF4BVOL.js";import"./chunk-2LND3R7K.js";import"./chunk-3NCMYTNG.js";import"./chunk-64ETX3AY.js";import"./chunk-SY7AYEDO.js";import"./chunk-WP3SZU24.js";import"./chunk-4E326NPY.js";import"./chunk-HJVEVJXS.js";import"./chunk-BDC7B4KM.js";import"./chunk-UD7XPHE4.js";import"./chunk-K3VQKR4G.js";import{a as v}from"./chunk-O5VA3E5D.js";import"./chunk-Q7K66FTS.js";import"./chunk-SLUA7ABW.js";import"./chunk-QZRJ3ZXU.js";import"./chunk-3VUPVXAV.js";import"./chunk-EEYDOVVS.js";import"./chunk-42UXYMRZ.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as u}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var m=new WeakMap,I=new WeakMap,H=new WeakSet;function re(C,e){let s=e.prepared,N=()=>{s&&!H.has(s)&&S(s)?.release()},R=m.get(e.client);if(R)return N(),R;let c=e.allowNewPurchase===!1||!e.start?void 0:{...e.start,requestId:e.start.requestId??crypto.randomUUID()};c&&s?.state==="ready"&&s.matches(c)&&s.open();let i=c&&s&&(s.state==="preparing"||["shown","closed"].includes(s.state)&&s.matches(c))?s:void 0;i?H.add(i):N();let d=i&&S(i);d?.claim();let b=Promise.resolve().then(async()=>{let r=!1,w,E,U=!1,T=()=>{},L=()=>{},y,M=!1,O=!1,f,_=!1,n=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,P=()=>{m.get(e.client)===b&&m.delete(e.client),n.removeEventListener("abort",A),T(),L(),i&&H.delete(i),d?.release()};function x(){if(f)return f;let l=new Promise(h=>f=h);return I.set(e.client,l),l.then(()=>{I.get(e.client)===l&&I.delete(e.client)}),m.get(e.client)===b&&m.delete(e.client),f}let a=j(C,e,"funnel",()=>F(),z);function A(){F()}function F(l=!1){if(!r){if(r=!0,a.finish("dismissed"),w){w.destroy();return}if(l&&y){let h=x();_=!0,y.then(async g=>{g.mode==="run"&&g.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===c?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{h(),u(e.onDismiss,null)}),P();return}P(),u(e.onDismiss,null)}}n.addEventListener("abort",A,{once:!0}),d&&(L=d.onClose(()=>{M?r||x():F(!0)}));try{let k=function(){!r&&!n.aborted&&!U&&E&&e.client.recovery.status==="complete"&&(U=!0,u(e.onComplete,structuredClone(E)))},D=function(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(t):C.ownerDocument.defaultView?.location.assign(t)};var J=k,K=D;n.throwIfAborted();let l=e.client.controller?.view?.paywall?.resolution,h=l&&"document"in l?l.document:e.loadingDocument;a.start(!0,c?.locale??e.client.attempt?.locale??h?.screen.strings.defaultLocale,h??null),i?.state==="shown"?(O=!0,a.present(()=>{})):i?.state==="preparing"&&i.ready.then(t=>{if(t){if(r||!a.active||!i.matches(c)||!d?.revealable)return d?.release();a.present(()=>{i.open()==="shown"?O=!0:d.release()})}});let g=I.get(e.client);if(g&&await a.wait(g),r)return null;n.throwIfAborted(),y=c?e.client.start(c):e.client.refresh();let q=await a.wait(y,W);if(r)return null;n.throwIfAborted();let G=e.client.controller;return q.mode!=="run"||q.status==="blocked"||!G?(a.finish("skipped"),P(),O&&u(e.onDismiss,null),null):(n.removeEventListener("abort",A),M=!0,T=e.client.subscribe(k),w=await B(C,{...e,prepared:i,client:G,signal:n,checkoutNavigation:"after_confirmation",resumeCheckout:t=>e.client.continueCheckout(D,t),terminateCheckout:e.allowNewPurchase===!1?void 0:t=>e.client.terminateCheckout(t),async onCheckoutUrl(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let o=e.client.recovery;if((!o.actions.includes("continue_checkout")||!o.purchases.some(p=>p.type==="checkout"&&p.checkoutUrl===t))&&(o=await e.client.refresh(),n.throwIfAborted(),r))throw new DOMException("Presentation dismissed","AbortError");if(V(o)!==t)throw new v("PURCHASE_PENDING","Checkout differs from the original recovery proof");return D(t)},async resolveOfferId(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let o=e.client.attempt;if(!o)throw new v("PURCHASE_PENDING","Read the original Start before selecting an offer");let p=await e.resolveOfferId?.(t,o);if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==o.requestId)throw new v("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return p},onComplete(t){E=t,k()},onError(t){u(e.onError,t),t instanceof v&&t.status===401&&!n.aborted&&e.client.refresh().catch(o=>u(e.onError,o))},onDismiss(t){r=!0,P(),f?.(),u(e.onDismiss,t)}},a),r||n.aborted?(w.destroy(),null):w)}catch(l){if(_||f?.(),r)return null;throw a.finish("error",l),P(),u(e.onError,l),l}});return m.set(e.client,b),b}export{re as showFunnelPurchase};
@@ -0,0 +1 @@
1
+ import{a,b,c}from"./chunk-JBDNNV3P.js";import"./chunk-SY7AYEDO.js";import"./chunk-O5VA3E5D.js";import"./chunk-Q7K66FTS.js";import"./chunk-42UXYMRZ.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as PRERENDER_MAX_AGE_MS,b as preparedInternals,c as prerenderFunnelPurchase};
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-WQZOT22S.js";import"./chunk-JXTJT2EW.js";import"./chunk-JBDNNV3P.js";import"./chunk-L54MODP5.js";import"./chunk-W32FI2A2.js";import"./chunk-DTWSDNYI.js";import"./chunk-KQF4BVOL.js";import"./chunk-2LND3R7K.js";import"./chunk-3NCMYTNG.js";import"./chunk-64ETX3AY.js";import"./chunk-SY7AYEDO.js";import"./chunk-WP3SZU24.js";import"./chunk-4E326NPY.js";import"./chunk-HJVEVJXS.js";import"./chunk-BDC7B4KM.js";import"./chunk-UD7XPHE4.js";import"./chunk-K3VQKR4G.js";import"./chunk-O5VA3E5D.js";import"./chunk-Q7K66FTS.js";import"./chunk-SLUA7ABW.js";import"./chunk-QZRJ3ZXU.js";import"./chunk-EEYDOVVS.js";import"./chunk-42UXYMRZ.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
package/dist/index.d.ts CHANGED
@@ -5,10 +5,10 @@ import { J as JsonValue } from './growth-rules-B4YYy64R.js';
5
5
  import { S as StackNode, a as ScreenSelection } from './screen-qUBRsUi9.js';
6
6
  import { P as PaywallSession, S as SubscriptionOperation, F as FunnelCommandStorage, s as scopeSchema, a as FunnelStartInput, I as IndianaOptions, b as SessionCredentials, c as FunnelExecutionPolicy, d as PaywallRecovery, e as SubscriptionAttachQuote, f as FunnelRunController, g as PaywallResolution, h as FunnelRunView, i as IamFunnelEntryDelivery, j as FunnelProcessRunView, k as createPaywallSession$1 } from './funnel-local-client-DR8OpKGU.js';
7
7
  export { C as CustomerSession, l as FeatureClient, m as FeatureClientOptions, n as FunnelControllerResponse, o as FunnelPendingEntry, p as FunnelPurchaseRecovery, q as FunnelRuntimeResponse, r as FunnelSegmentPrediction, L as LocalFunnelClient, t as LocalFunnelClientOptions, u as LongplayError, v as PaywallPurchaseInput, w as PaywallStartInput, x as PushHost, y as PushJournal, z as createFeatureClient, A as createFunnelRunController, B as createLocalFunnelClient, D as getPaywallRecovery, E as preparePaywallFallback } from './funnel-local-client-DR8OpKGU.js';
8
+ import { C as CouponInput, O as Offer } from './coupon-kfkIVf9n.js';
9
+ export { a as OfferUnavailableReason } from './coupon-kfkIVf9n.js';
8
10
  import { E as EntitlementCheckResult, M as MerchantBridgeManifest } from './funnel-node-evaluation-COxXtZEQ.js';
9
11
  export { a as EntitlementCheckInput, b as EntitlementCheckObservation, c as EntitlementRequirement, F as FunnelNodeEvaluationContext, e as evaluateFunnelNode } from './funnel-node-evaluation-COxXtZEQ.js';
10
- import { C as CouponInput } from './coupon-kfkIVf9n.js';
11
- export { O as Offer, a as OfferUnavailableReason } from './coupon-kfkIVf9n.js';
12
12
  import { c as createFunnelProcess } from './funnel-process-client-C87U4r_G.js';
13
13
  export { F as FunnelProcessAdapter, a as FunnelProcessOptions, b as FunnelResourceSource, I as LongplayFeatureOptions, d as createFunnelClient, e as createLongplay } from './funnel-process-client-C87U4r_G.js';
14
14
  export { C as ConfigurationStorage, a as ConfigurationSync, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-BHrAf-ql.js';
@@ -304,6 +304,8 @@ type PaywallPurchaseIntent = {
304
304
  featureQuantities: Record<string, number>;
305
305
  };
306
306
  type PaywallHostOptions = PresentationLoadingOptions & {
307
+ /** Mount host controls inside this Paywall. Return synchronous teardown for destroy, cancellation or failure. */
308
+ mountControls?: (container: HTMLElement) => void | (() => void);
307
309
  /** An already available Paywall design for the first frame. */
308
310
  loadingDocument?: PaywallLoadingDocument;
309
311
  /** Coordinates presentation reads with an enclosing host. */
@@ -344,6 +346,13 @@ type PaywallHostOptions = PresentationLoadingOptions & {
344
346
  productVersionId: string;
345
347
  featureQuantities: Readonly<Record<string, number>>;
346
348
  }) => string | undefined | Promise<string | undefined>;
349
+ /**
350
+ * Opt in to the Coupon an authored purchase button is bound to: the SDK claims it for the
351
+ * Customer at the click and quotes with that offer instead of calling `resolveOfferId`.
352
+ */
353
+ claimCoupon?: (couponId: string, requestId: string) => Promise<{
354
+ offer: Offer | null;
355
+ }>;
347
356
  onOpenUrl?: (url: string) => unknown;
348
357
  onEvent?: (name: string) => unknown;
349
358
  /** An authored non-purchase button completed its action. */
@@ -1611,6 +1620,7 @@ declare function prerenderFunnelPurchase$1(container: HTMLElement, input: {
1611
1620
 
1612
1621
  type FunnelHostOptions = PresentationLoadingOptions & {
1613
1622
  client: FunnelRunController;
1623
+ closeActions?: readonly string[];
1614
1624
  /**
1615
1625
  * A pre-rendered Paywall, handed to the SDK: revealed, the first Paywall takes it over when it is
1616
1626
  * the same and untouched; otherwise it is released. Closed before the takeover, the Run closes.
@@ -1631,6 +1641,7 @@ type FunnelHostOptions = PresentationLoadingOptions & {
1631
1641
  terminateCheckout?: PaywallHostOptions["terminateCheckout"];
1632
1642
  confirmOnHostedCheckout?: PaywallHostOptions["confirmOnHostedCheckout"];
1633
1643
  resolveOfferId?: PaywallHostOptions["resolveOfferId"];
1644
+ claimCoupon?: PaywallHostOptions["claimCoupon"];
1634
1645
  /**
1635
1646
  * Opens an external page or a Paywall link. Return `false` (or throw) when the page could not be
1636
1647
  * opened; an external page then takes its `failed` route. Without a handler, `same_window` navigates
@@ -2407,6 +2418,8 @@ declare function showPaywall(container: HTMLElement, options: PaywallHostOptions
2407
2418
  }>;
2408
2419
  };
2409
2420
  }>;
2421
+ /** Load presentation code without starting a session; return the public Paywall factory. */
2422
+ declare function preloadPaywall(): Promise<typeof showPaywall>;
2410
2423
  declare function createPaywallSession(...args: Parameters<typeof createPaywallSession$1>): Promise<PaywallSession>;
2411
2424
 
2412
2425
  /** Loading customer API clients does not initialize the UI renderer. */
@@ -2438,6 +2451,13 @@ declare function showFunnelPurchase(...args: Parameters<typeof showFunnelPurchas
2438
2451
  * `locale` are required while `start` is a promise.
2439
2452
  */
2440
2453
  declare function prerenderFunnelPurchase(...args: Parameters<typeof prerenderFunnelPurchase$1>): Promise<PreparedFunnelPurchase>;
2454
+ /**
2455
+ * Loads the code a Funnel purchase presents with, before any Customer is known: the pre-render,
2456
+ * the purchase host, the Paywall and its renderer. No session, request or DOM. Call it as soon as
2457
+ * the page can spare the download, so a later `prerenderFunnelPurchase` reads its Paywall at once
2458
+ * instead of waiting for these chunks one after another.
2459
+ */
2460
+ declare function preloadFunnelPurchase(): Promise<void>;
2441
2461
 
2442
2462
  declare function mountContent(...args: Parameters<typeof mountContent$1>): Promise<{
2443
2463
  destroy: () => void;
@@ -2457,4 +2477,4 @@ declare function prepareContent(...args: Parameters<typeof prepareContent$1>): P
2457
2477
  updateCapabilities(data: SurfaceData): void;
2458
2478
  }>;
2459
2479
 
2460
- export { type ContentActionIntent, type ContentHostOptions, EntitlementCheckResult, FunnelCommandStorage, FunnelExecutionPolicy, type FunnelHostOptions, type FunnelPurchaseAttempt, type FunnelPurchaseClient, type FunnelPurchaseEntry, type FunnelPurchaseHostOptions, type FunnelPurchaseOptions, type FunnelPurchaseStart, type FunnelPurchaseState, type FunnelPurchaseStorage, FunnelRunController, type IamFunnelEntriesOptions, type IamFunnelProcessEntriesOptions, IndianaOptions as LongplayOptions, MerchantBridgeError, type MerchantBridgeOptions, type PaywallHostOptions, PaywallLoadingDocument, type PaywallPurchaseIntent, PaywallRecovery, PaywallSession, type PreparedFunnelPurchase, type PreparedState, PresentationLoadingOptions, SessionCredentials, createBrowserFunnelCommandStorage, createBrowserFunnelPurchaseStorage, createFunnelPageExperiments, createFunnelProcess, createFunnelPurchaseClient, createIamFunnelEntries, createIamFunnelProcessEntries, createMerchantBridge, createPaywallSession, formatCouponDiscount, formatCouponMoney, formatCouponTerms, mountContent, prepareContent, prerenderFunnelPurchase, showFunnelPurchase, showFunnelRun, showPaywall };
2480
+ export { type ContentActionIntent, type ContentHostOptions, EntitlementCheckResult, FunnelCommandStorage, FunnelExecutionPolicy, type FunnelHostOptions, type FunnelPurchaseAttempt, type FunnelPurchaseClient, type FunnelPurchaseEntry, type FunnelPurchaseHostOptions, type FunnelPurchaseOptions, type FunnelPurchaseStart, type FunnelPurchaseState, type FunnelPurchaseStorage, FunnelRunController, type IamFunnelEntriesOptions, type IamFunnelProcessEntriesOptions, IndianaOptions as LongplayOptions, MerchantBridgeError, type MerchantBridgeOptions, Offer, type PaywallHostOptions, PaywallLoadingDocument, type PaywallPurchaseIntent, PaywallRecovery, PaywallSession, type PreparedFunnelPurchase, type PreparedState, PresentationLoadingOptions, SessionCredentials, createBrowserFunnelCommandStorage, createBrowserFunnelPurchaseStorage, createFunnelPageExperiments, createFunnelProcess, createFunnelPurchaseClient, createIamFunnelEntries, createIamFunnelProcessEntries, createMerchantBridge, createPaywallSession, formatCouponDiscount, formatCouponMoney, formatCouponTerms, mountContent, preloadFunnelPurchase, preloadPaywall, prepareContent, prerenderFunnelPurchase, showFunnelPurchase, showFunnelRun, showPaywall };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as gn,c as vn}from"./chunk-BL7E4RZ2.js";import{a as We,c as En}from"./chunk-VWMFR22O.js";import{a as Ie}from"./chunk-W32FI2A2.js";import{a as ln,c as hn,d as In}from"./chunk-VKG6BB3Z.js";import"./chunk-M3GGR53D.js";import{a as yn}from"./chunk-W3K5ARMY.js";import"./chunk-UVUFJO2V.js";import{h as dn,i as pn,k as wn}from"./chunk-HS56A4IK.js";import{F as Ce,e as Xe,g as Ye,h as ge,i as ve,j as Ze,x as un}from"./chunk-HYE2YQYM.js";import{a as ze}from"./chunk-MHWPEMX7.js";import"./chunk-2HSD2SEU.js";import"./chunk-5XKFUFXK.js";import"./chunk-BTPEXSNY.js";import{B as He,D as qe,E as Ue,G as Ve,H as je,I as Ge,J as Je,K as Te,L as $e,x as _e,y as Le,z as Be}from"./chunk-2KKLY323.js";import"./chunk-R3YVDRTB.js";import"./chunk-U4WUX3WB.js";import"./chunk-JOIPLLHK.js";import{aa as Ke,l as an,m as sn,n as cn}from"./chunk-GLYFT5WW.js";import"./chunk-WRLVPHPE.js";import{c as fn,e as mn}from"./chunk-3NCMYTNG.js";import"./chunk-35VG2IYD.js";import"./chunk-CGXNU5BC.js";import{b as Ae}from"./chunk-HVVJGLYZ.js";import"./chunk-ZYF6TRJ3.js";import"./chunk-QHJWVLJC.js";import"./chunk-XE7GU6FZ.js";import"./chunk-LAGGWYH3.js";import"./chunk-DHT3AWJQ.js";import{a as G}from"./chunk-TIQS5DUF.js";import"./chunk-7ZEXY4GC.js";import"./chunk-SLUA7ABW.js";import{a as be,c as de}from"./chunk-J6KIN4RH.js";import{c as we,d as Ee}from"./chunk-LVG5ED52.js";import"./chunk-3VUPVXAV.js";import"./chunk-RHF4NFCZ.js";import{b as U}from"./chunk-ZYN4CRHS.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as Q}from"./chunk-DSPLGTQI.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 bn(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 Sn(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 R(m,s,E,_,M){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 N=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:M??(E===void 0?{}:{operationId:E})})}),J=await bn(N,o);if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(!N.ok){let O=$e.safeParse(J);throw!O.success||O.data.scope.projectId!==n.scope.projectId||O.data.scope.environment!==n.scope.environment||O.data.scope.environmentId!==n.scope.environmentId||O.data.requestId!==g||O.data.command!==S.command?new I("MERCHANT_BRIDGE_INVALID_RESPONSE",N.status):new I(O.data.error.code,N.status,O.data.error.retryable,O.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",N.status);let $=s.safeParse(c.data.data);if(!$.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",N.status);return $.data}function P(){if(!w)throw new I("MERCHANT_BRIDGE_UNAUTHENTICATED",401);return w}async function B(m,s,E,_){let M=P();if(_!==void 0&&Te.parse({operationId:_,customerId:M}),!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,N)=>{o=()=>N(l.reason),l.addEventListener("abort",o,{once:!0})});try{let N=E(async()=>{let c=await import("./merchant-bridge-contracts-GJQVKEAG.js");if(l.throwIfAborted(),S!==h||w!==M)throw new DOMException("Merchant identity changed","AbortError");return c},l),J=await Promise.race([N,T]);return l.throwIfAborted(),J}finally{l.removeEventListener("abort",o)}}async function z(m,s,E,_){let M=P(),S=Te.parse({operationId:E,customerId:M}),l=await R(m,s,S.operationId,_,S);if(l.customerId!==M||l.operationId!==S.operationId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return l}return{async readPresentation(m){let s=await R("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 R("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=P(),_=Je.parse(m);if(!t||t.customerId!==E||t.decisionId!==_.decisionId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return R("presentation_events",U.strictObject({queued:U.literal(!0)}),void 0,s,_)},async readCustomerCommerce(m){let s=P(),E=await B("customer_commerce",m,async(_,M)=>{let[S,l]=await Promise.all([_(),R("customer_commerce",U.unknown(),void 0,M)]),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(_,M)=>z("purchases",(await _()).merchantBridgeOperationSchema,m,M),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(_,M)=>z("subscription_changes",(await _()).merchantBridgeOperationSchema,m,M),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:Ye,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),Qe=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 Qe.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(Qe.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,Me=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,R=!1){if(u!==void 0)try{let P=n.binding();if(!P)throw Error("Entry delivery identity is unavailable");let B={storage:n.storage??globalThis.sessionStorage,key:"indiana.funnel.delivery.v1."+JSON.stringify([...P,i,t]),requestId:y},z=b(B);if(Me.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!R&&!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=Me.get(t.storage);u||Me.set(t.storage,u=new Set),u.add(t.key),f()}finally{h(t)}},release:h}}function Re(){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 Pe=n=>["running","waiting"].includes(n.status)&&!n.pendingRequest&&(n.stopped||!n.screen&&!n.paywall&&n.instruction?.type==="wait"&&n.instruction.kind!=="operation");function Rn(n){let d=we(n.baseUrl),f=n.scope,b=Ae(n),w=n.fetch??globalThis.fetch.bind(globalThis),h,t=!1,i=!1,u=0,y=0,R="",P=0,B=0,z=0,m=!1,s,E=!0,_,M,S,l,o,T=-1,g,N=e=>{g===e&&(O.release(e.deliveryTicket),g=void 0,k())},J=new Set,c=(e,a)=>Q(n.onStatus,e,a),$=Re(),O=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")}),Z=e=>te.forget(e.storageKey,e.command.requestId);function Y(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(),k()}let le=()=>$.active||g!==void 0||o!==void 0&&!o.background;function me(e,a){if(o?.client!==e)return;Y(o.recovery,a);let p=Pe(a);o.slot.hidden=p,p!==o.background&&(o.background=p,p?c("run_background",o.entryId):T=y,k())}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=Ae({...n,session:void 0});j.requestWithCredential("funnels",K,e.runToken,{keepalive:p}).then(()=>Z(e.recovery)).catch(()=>{}).finally(()=>j.dispose())}let ae=()=>{o&&pe(o,n.session.peek(),!0)},r=()=>Date.now()<B&&performance.now()<z;function A(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!==P||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=P,p=y;$.start(e.delivery?.delaySeconds??0,()=>!t&&a===P&&p===y&&document.visibilityState!=="hidden"&&A(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(C=>C.command.funnelId===e.funnelId&&(!C.expiresAt||Date.parse(C.expiresAt)>Date.now()));if(p){if(!X(p)){c("recovery_pending",e.id);return}let C={...p,storageKey:a.key,epoch:P,visit:y};ee.add(C.command.requestId),g=C,await F(C);return}let v=crypto.randomUUID(),K=O.claim(e.id,e.funnelId,e.delivery?.maxPerSession,v);if(K===!1){c("frequency",e.id),k();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:P,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(C){if(e.epoch!==P)return;let D=C.view;if(!(e.storageKey&&D&&(Pe(D)||D.paywall||D.pendingRequest))&&D&&["running","waiting"].includes(D.status))try{await C.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:D.nodeId,visit:D.visit,revision:D.revision}),Z(e)}catch(x){if(!(x instanceof G&&x.code==="FORBIDDEN"))throw x}}try{if(!e.deliveryTicket&&e.deliveryLimit!==void 0){let q=O.claim(e.command.entryId,e.command.funnelId,e.deliveryLimit,e.command.requestId,!0);q!==!1&&(e.deliveryTicket=q)}Y(e),c("starting",e.command.entryId);let C=await b.request("funnels",e.command),D=Ze.safeParse(C);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===P&&c(D.data.reason,e.command.entryId),Z(e),N(e);return}let x=Xe.parse(C);if(!x.runToken||x.scope.projectId!==f.projectId||x.scope.environment!==f.environment||x.run.source.type!=="funnel"||x.run.source.id!==e.command.funnelId||x.run.source.versionId!==e.command.versionId||e.runId!==void 0&&x.run.id!==e.runId)throw new G("INVALID_RESPONSE","Invalid entry Run");if(O.accept(e.deliveryTicket,x.run.id),e.epoch!==P){N(e),c("identity_changed",e.command.entryId);return}Y(e,x.run);let L=Ce({...n,runToken:x.runToken,funnelId:e.command.funnelId,initialResponse:a?C:void 0});p=L,K=!0,await L.get(),K=!1;let ne=L.view;if(!ne||ne.id!==x.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)){Z(e),N(e),c("run_ended",e.command.entryId);return}let{showFunnelRun:fe}=await import("./funnel-runtime-host-AMJXEASH.js");if(!H(e)){await j(L),c("left_screen",e.command.entryId),N(e);return}let Fe=!1,ke=!1;if(o&&!o.background){await j(L),c("in_progress",e.command.entryId),N(e);return}o&&re();let ie=document.createElement("div");ie.hidden=Pe(ne),n.container.append(ie);let xe=await fe(ie,{...n.host,client:L,appManifestRelease:n.appManifestRelease,onState(q){me(L,q),Q(n.host?.onState,q)},onDismiss(q){Fe=!0,ie.remove(),q&&!["running","waiting"].includes(q.status)&&Z(e),o?.client===L&&(o=void 0,L.reset(),k(),q&&q.status!=="completed"&&c("run_ended",e.command.entryId)),Q(n.host?.onDismiss,q)},onComplete(q){ke=!0,Z(e),o?.client===L&&re(),Q(n.host?.onComplete,q)},onError(q){Q(n.host?.onError,q),o?.client===L&&q instanceof G&&q.code==="FORBIDDEN"&&(Z(e),re(),c("run_ended",e.command.entryId))}}).catch(q=>{throw ie.remove(),q});if(!H(e)||Fe||ke){xe.destroy(),ie.remove(),H(e)||await j(L),N(e);return}let he=Pe(L.view??ne);ie.hidden=he,o={host:xe,client:L,slot:ie,entryId:e.command.entryId,background:he,runToken:x.runToken,owner:n.session.peek(),recovery:e},he||(T=e.visit),v=!0,N(e),c("started",e.command.entryId),he&&c("run_background",e.command.entryId)}catch(C){C instanceof G&&(!p||K&&C.code==="FORBIDDEN")&&C.status!==void 0&&C.status>=400&&C.status<500&&!C.retryable&&(Z(e),N(e)),e.epoch===P&&!t&&(c("start_failed",e.command.entryId),Q(n.host?.onError,C))}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:P,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)||!A(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 k=()=>{!m&&!t&&(m=!0,queueMicrotask(ue))};function se(){let e=location.origin+location.pathname;return e===R?!1:(R=e,y++,$.cancel(),E=!0,J.clear(),ee.clear(),!0)}function oe(){se()&&k()}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||!A(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 Ne(){if(t)return;if(s)return s;let e=++u,a=new AbortController;_=a;let p,v=new Promise((C,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 C=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([C(),v]),x=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()||x>Date.now()+5e3||L-x>6e4||L<=x)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)&&k()})();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 Ne()}catch{t||c("configuration_unavailable")}k()}}let Oe=Ie({document,run:on,delay:()=>i&&!t?15e3:void 0});return{async start(){i||t||(i=!0,R=location.origin+location.pathname,M=Ee(oe),S=n.session.subscribeIdentity(()=>{P++,$.cancel(),O.release(g?.deliveryTicket),E=!0,g=void 0,J.clear(),T=-1,ee.clear(),o&&pe(o,o.owner,!1),re(),k()}),l=new MutationObserver(k),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",k),addEventListener("pagehide",ae),await Oe.refresh())},refresh:Ne,async retry(){g&&!t&&g.epoch===P&&await F(g)},destroy(){t=!0,u++,$.cancel(),O.release(g?.deliveryTicket),Oe.destroy(),_?.abort(),l?.disconnect(),M?.(),S?.(),document.removeEventListener("click",ce,!0),document.removeEventListener("visibilitychange",k),removeEventListener("pagehide",ae),ae(),re(),b.dispose(),h=void 0}}}function Pn(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,R=0,P=-1,B=!1,z="",m,s,E,_,M=new Set,S,l,o,T=(r,A)=>Q(n.onStatus,r,A),g=Re(),N=()=>{try{return n.deliveryIdentity?.()}catch{return}},J=()=>JSON.stringify(N()),c=Se({storage:n.deliveryStorage,binding:()=>{let r=N();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 O(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 A=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-AMJXEASH.js");if(t||A!==y||l!==r)return;let V=document.createElement("div");n.container.append(V),P=R;let F=await W(V,{...n.host,client:H.controller,appManifestRelease:n.appManifestRelease,onDismiss(X){o?.process===r.process&&(o=void 0,V.remove()),Q(n.host?.onDismiss,X)}});if(t||A!==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||A!==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),Y()):T("entry_unavailable",r.entry.id)}finally{r.dispatching=!1}}function Z(r){if(t||i||l||o||S||g.active||P===R||!O(r))return;let A=`${R}:${r.id}`;if(M.has(A))return;M.add(A);let H=R,W=y,V=J();g.start(r.delivery?.delaySeconds??0,()=>!t&&y===W&&R===H&&J()===V&&document.visibilityState!=="hidden"&&O(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),Y();return}try{let X={entry:r,process:n.createProcess(r),visit:R,deliveryTicket:F};l=X,te(X)}catch(X){c.release(F),T("entry_unavailable",r.id),Q(n.host?.onError,X)}},()=>{M.delete(A)})}function Y(){B||t||(B=!0,queueMicrotask(()=>{if(B=!1,g.recheck(),!(t||i||document.visibilityState==="hidden"||!$()||l||o||S||g.active||P===R)){for(let r of b?.entries??[])if(r.event==="screen_enter"&&!M.has(`${R}:${r.id}`)&&O(r)){Z(r);break}}}))}function re(r){if(!r.isTrusted||r.defaultPrevented||!(r.target instanceof Element)||l||o||S||P===R)return;let A=be(document,()=>{});for(let H of b?.entries??[]){let W=H.target.button;if(H.event!=="button_click"||!W||!O(H))continue;let V=r.target.closest(W.selector);if(!(!V||V.tagName.toLowerCase()!==W.tag||A(W.selector)!==1||V.matches(":disabled")||V.closest('[inert],[hidden],[aria-hidden="true"]'))){Z(H);break}}}let le=()=>{let r=location.origin+location.pathname;r!==z&&(z=r,R++,g.cancel(),M.clear(),Y())};async function me(){if(t)return;if(s)return s;let r=y,A=new AbortController;m=A;let H,W=new Promise((ye,ue)=>{H=ue}),V=()=>H(new G("TIMEOUT","Funnel entry read cancelled"));A.signal.addEventListener("abort",V,{once:!0});let F=setTimeout(()=>A.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:A.signal});if(!ce.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",ce.status);return ge.parse(await ce.json())},k=await Promise.race([ue(),W]),se=Date.parse(k.validatedAt),oe=Date.parse(k.validUntil);if(k.scope.projectId!==n.scope.projectId||k.scope.environment!==n.scope.environment||k.scope.environmentId!==n.environmentId||k.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=k,w=oe,h=performance.now()+Math.min(oe-Date.now(),6e4),g.recheck(),Y())})();s=X;try{await X}finally{clearTimeout(F),A.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(Y),_.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",Y),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,Y();return}try{let A=await r.process.syncIdentity();return i=!1,S===r&&(l={...r,visit:R},S=void 0,await te(l)),A}catch(A){throw r.process.view||(S={...r,visit:R},l=void 0,ee()),A}},async detach(){i=!0,y++,g.cancel(),m?.abort();let r=o??l??S;r&&(S={...r,visit:R}),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",Y);let r=o??l??S;c.release(r?.deliveryTicket),l=void 0,S=void 0,ee(),r?.process.destroy(),b=void 0}}}async function it(n,d){return(await import("./paywall-ATZ2IZPS.js")).showPaywall(n,d)}async function ot(...n){return n[1]=ze(n[1]),(await import("./paywall-session-EMMF6IYS.js")).createPaywallSession(...n)}async function at(...n){let d=n[1].signal?.aborted?void 0:We(n[1].client);try{return import("./screen-renderer-B7LUTPTJ.js").catch(()=>{}),import("./paywall-ATZ2IZPS.js").catch(()=>{}),await(await rn(()=>import("./funnel-runtime-host-AMJXEASH.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-OSBI4VMY.js").then(b=>b.preparedInternals(d)?.release(),()=>{}),f}}async function st(...n){return import("./screen-renderer-B7LUTPTJ.js").catch(()=>{}),import("./paywall-ATZ2IZPS.js").catch(()=>{}),(await rn(()=>import("./funnel-host-purchase-M7MM33EC.js"),n[1].prepared)).showFunnelPurchase(...n)}async function ct(...n){return import("./funnel-host-purchase-M7MM33EC.js").catch(()=>{}),import("./screen-renderer-B7LUTPTJ.js").catch(()=>{}),(await import("./funnel-paywall-prerender-OSBI4VMY.js")).prerenderFunnelPurchase(...n)}async function dt(...n){return(await import("./content-RGKTEV23.js")).mountContent(...n)}async function lt(...n){return(await import("./content-RGKTEV23.js")).prepareContent(...n)}export{G as LongplayError,I as MerchantBridgeError,un as createBrowserFunnelCommandStorage,gn as createBrowserFunnelPurchaseStorage,pn as createConfigurationSync,dn as createFeatureClient,hn as createFunnelClient,En as createFunnelPageExperiments,In as createFunnelProcess,vn as createFunnelPurchaseClient,Ce as createFunnelRunController,Rn as createIamFunnelEntries,Pn as createIamFunnelProcessEntries,wn as createLocalFunnelClient,ln as createLongplay,Sn as createMerchantBridge,ot as createPaywallSession,yn as evaluateFunnelNode,sn as formatCouponDiscount,an as formatCouponMoney,cn as formatCouponTerms,fn as getPaywallRecovery,dt as mountContent,lt as prepareContent,mn as preparePaywallFallback,ct as prerenderFunnelPurchase,st as showFunnelPurchase,at as showFunnelRun,it as showPaywall};
1
+ import{a as gn,c as vn}from"./chunk-DSLJUN3P.js";import{a as We,c as En}from"./chunk-L54MODP5.js";import{a as Ie}from"./chunk-W32FI2A2.js";import{a as ln,c as hn,d as In}from"./chunk-RK7XOT3F.js";import"./chunk-DK5PHPSO.js";import{a as yn}from"./chunk-I7QTCEYR.js";import"./chunk-IV6LKRYM.js";import{h as dn,i as pn,k as wn}from"./chunk-H2I37CQ4.js";import{F as Ce,e as Xe,g as Ye,h as ge,i as ve,j as Ze,x as un}from"./chunk-G7Y7LPOB.js";import{a as ze}from"./chunk-IHB275C3.js";import"./chunk-YYXINZ4A.js";import"./chunk-KTBXAATX.js";import"./chunk-6WEHTOED.js";import{B as He,D as qe,E as Ue,G as Ve,H as je,I as Ge,J as Je,K as Te,L as $e,x as _e,y as Le,z as Be}from"./chunk-UAJTQ23E.js";import"./chunk-GEPX4AUR.js";import"./chunk-TLV3NVUU.js";import"./chunk-Y5RT7PAD.js";import{aa as Ke,l as an,m as sn,n as cn}from"./chunk-KQF4BVOL.js";import"./chunk-2LND3R7K.js";import{c as fn,e as mn}from"./chunk-3NCMYTNG.js";import"./chunk-64ETX3AY.js";import"./chunk-SY7AYEDO.js";import{b as Ae}from"./chunk-WP3SZU24.js";import"./chunk-4E326NPY.js";import"./chunk-HJVEVJXS.js";import"./chunk-BDC7B4KM.js";import"./chunk-UD7XPHE4.js";import"./chunk-K3VQKR4G.js";import{a as G}from"./chunk-O5VA3E5D.js";import"./chunk-Q7K66FTS.js";import"./chunk-SLUA7ABW.js";import{a as be,c as de}from"./chunk-J6KIN4RH.js";import{c as we,d as Ee}from"./chunk-QZRJ3ZXU.js";import"./chunk-3VUPVXAV.js";import"./chunk-EEYDOVVS.js";import{b as U}from"./chunk-42UXYMRZ.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as Q}from"./chunk-DSPLGTQI.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 bn(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 Sn(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 R(m,s,E,_,M){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 N=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:M??(E===void 0?{}:{operationId:E})})}),J=await bn(N,o);if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(!N.ok){let O=$e.safeParse(J);throw!O.success||O.data.scope.projectId!==n.scope.projectId||O.data.scope.environment!==n.scope.environment||O.data.scope.environmentId!==n.scope.environmentId||O.data.requestId!==g||O.data.command!==S.command?new I("MERCHANT_BRIDGE_INVALID_RESPONSE",N.status):new I(O.data.error.code,N.status,O.data.error.retryable,O.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",N.status);let $=s.safeParse(c.data.data);if(!$.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",N.status);return $.data}function P(){if(!w)throw new I("MERCHANT_BRIDGE_UNAUTHENTICATED",401);return w}async function B(m,s,E,_){let M=P();if(_!==void 0&&Te.parse({operationId:_,customerId:M}),!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,N)=>{o=()=>N(l.reason),l.addEventListener("abort",o,{once:!0})});try{let N=E(async()=>{let c=await import("./merchant-bridge-contracts-KVOFRPKV.js");if(l.throwIfAborted(),S!==h||w!==M)throw new DOMException("Merchant identity changed","AbortError");return c},l),J=await Promise.race([N,T]);return l.throwIfAborted(),J}finally{l.removeEventListener("abort",o)}}async function z(m,s,E,_){let M=P(),S=Te.parse({operationId:E,customerId:M}),l=await R(m,s,S.operationId,_,S);if(l.customerId!==M||l.operationId!==S.operationId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return l}return{async readPresentation(m){let s=await R("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 R("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=P(),_=Je.parse(m);if(!t||t.customerId!==E||t.decisionId!==_.decisionId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return R("presentation_events",U.strictObject({queued:U.literal(!0)}),void 0,s,_)},async readCustomerCommerce(m){let s=P(),E=await B("customer_commerce",m,async(_,M)=>{let[S,l]=await Promise.all([_(),R("customer_commerce",U.unknown(),void 0,M)]),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(_,M)=>z("purchases",(await _()).merchantBridgeOperationSchema,m,M),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(_,M)=>z("subscription_changes",(await _()).merchantBridgeOperationSchema,m,M),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:Ye,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),Qe=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 Qe.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(Qe.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,Me=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,R=!1){if(u!==void 0)try{let P=n.binding();if(!P)throw Error("Entry delivery identity is unavailable");let B={storage:n.storage??globalThis.sessionStorage,key:"indiana.funnel.delivery.v1."+JSON.stringify([...P,i,t]),requestId:y},z=b(B);if(Me.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!R&&!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=Me.get(t.storage);u||Me.set(t.storage,u=new Set),u.add(t.key),f()}finally{h(t)}},release:h}}function Re(){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 Pe=n=>["running","waiting"].includes(n.status)&&!n.pendingRequest&&(n.stopped||!n.screen&&!n.paywall&&n.instruction?.type==="wait"&&n.instruction.kind!=="operation");function Rn(n){let d=we(n.baseUrl),f=n.scope,b=Ae(n),w=n.fetch??globalThis.fetch.bind(globalThis),h,t=!1,i=!1,u=0,y=0,R="",P=0,B=0,z=0,m=!1,s,E=!0,_,M,S,l,o,T=-1,g,N=e=>{g===e&&(O.release(e.deliveryTicket),g=void 0,k())},J=new Set,c=(e,a)=>Q(n.onStatus,e,a),$=Re(),O=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")}),Z=e=>te.forget(e.storageKey,e.command.requestId);function Y(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(),k()}let le=()=>$.active||g!==void 0||o!==void 0&&!o.background;function me(e,a){if(o?.client!==e)return;Y(o.recovery,a);let p=Pe(a);o.slot.hidden=p,p!==o.background&&(o.background=p,p?c("run_background",o.entryId):T=y,k())}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=Ae({...n,session:void 0});j.requestWithCredential("funnels",K,e.runToken,{keepalive:p}).then(()=>Z(e.recovery)).catch(()=>{}).finally(()=>j.dispose())}let ae=()=>{o&&pe(o,n.session.peek(),!0)},r=()=>Date.now()<B&&performance.now()<z;function A(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!==P||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=P,p=y;$.start(e.delivery?.delaySeconds??0,()=>!t&&a===P&&p===y&&document.visibilityState!=="hidden"&&A(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(C=>C.command.funnelId===e.funnelId&&(!C.expiresAt||Date.parse(C.expiresAt)>Date.now()));if(p){if(!X(p)){c("recovery_pending",e.id);return}let C={...p,storageKey:a.key,epoch:P,visit:y};ee.add(C.command.requestId),g=C,await F(C);return}let v=crypto.randomUUID(),K=O.claim(e.id,e.funnelId,e.delivery?.maxPerSession,v);if(K===!1){c("frequency",e.id),k();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:P,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(C){if(e.epoch!==P)return;let D=C.view;if(!(e.storageKey&&D&&(Pe(D)||D.paywall||D.pendingRequest))&&D&&["running","waiting"].includes(D.status))try{await C.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:D.nodeId,visit:D.visit,revision:D.revision}),Z(e)}catch(x){if(!(x instanceof G&&x.code==="FORBIDDEN"))throw x}}try{if(!e.deliveryTicket&&e.deliveryLimit!==void 0){let q=O.claim(e.command.entryId,e.command.funnelId,e.deliveryLimit,e.command.requestId,!0);q!==!1&&(e.deliveryTicket=q)}Y(e),c("starting",e.command.entryId);let C=await b.request("funnels",e.command),D=Ze.safeParse(C);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===P&&c(D.data.reason,e.command.entryId),Z(e),N(e);return}let x=Xe.parse(C);if(!x.runToken||x.scope.projectId!==f.projectId||x.scope.environment!==f.environment||x.run.source.type!=="funnel"||x.run.source.id!==e.command.funnelId||x.run.source.versionId!==e.command.versionId||e.runId!==void 0&&x.run.id!==e.runId)throw new G("INVALID_RESPONSE","Invalid entry Run");if(O.accept(e.deliveryTicket,x.run.id),e.epoch!==P){N(e),c("identity_changed",e.command.entryId);return}Y(e,x.run);let L=Ce({...n,runToken:x.runToken,funnelId:e.command.funnelId,initialResponse:a?C:void 0});p=L,K=!0,await L.get(),K=!1;let ne=L.view;if(!ne||ne.id!==x.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)){Z(e),N(e),c("run_ended",e.command.entryId);return}let{showFunnelRun:fe}=await import("./funnel-runtime-host-IJDKXLST.js");if(!H(e)){await j(L),c("left_screen",e.command.entryId),N(e);return}let Fe=!1,ke=!1;if(o&&!o.background){await j(L),c("in_progress",e.command.entryId),N(e);return}o&&re();let ie=document.createElement("div");ie.hidden=Pe(ne),n.container.append(ie);let xe=await fe(ie,{...n.host,client:L,appManifestRelease:n.appManifestRelease,onState(q){me(L,q),Q(n.host?.onState,q)},onDismiss(q){Fe=!0,ie.remove(),q&&!["running","waiting"].includes(q.status)&&Z(e),o?.client===L&&(o=void 0,L.reset(),k(),q&&q.status!=="completed"&&c("run_ended",e.command.entryId)),Q(n.host?.onDismiss,q)},onComplete(q){ke=!0,Z(e),o?.client===L&&re(),Q(n.host?.onComplete,q)},onError(q){Q(n.host?.onError,q),o?.client===L&&q instanceof G&&q.code==="FORBIDDEN"&&(Z(e),re(),c("run_ended",e.command.entryId))}}).catch(q=>{throw ie.remove(),q});if(!H(e)||Fe||ke){xe.destroy(),ie.remove(),H(e)||await j(L),N(e);return}let he=Pe(L.view??ne);ie.hidden=he,o={host:xe,client:L,slot:ie,entryId:e.command.entryId,background:he,runToken:x.runToken,owner:n.session.peek(),recovery:e},he||(T=e.visit),v=!0,N(e),c("started",e.command.entryId),he&&c("run_background",e.command.entryId)}catch(C){C instanceof G&&(!p||K&&C.code==="FORBIDDEN")&&C.status!==void 0&&C.status>=400&&C.status<500&&!C.retryable&&(Z(e),N(e)),e.epoch===P&&!t&&(c("start_failed",e.command.entryId),Q(n.host?.onError,C))}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:P,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)||!A(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 k=()=>{!m&&!t&&(m=!0,queueMicrotask(ue))};function se(){let e=location.origin+location.pathname;return e===R?!1:(R=e,y++,$.cancel(),E=!0,J.clear(),ee.clear(),!0)}function oe(){se()&&k()}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||!A(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 Ne(){if(t)return;if(s)return s;let e=++u,a=new AbortController;_=a;let p,v=new Promise((C,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 C=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([C(),v]),x=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()||x>Date.now()+5e3||L-x>6e4||L<=x)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)&&k()})();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 Ne()}catch{t||c("configuration_unavailable")}k()}}let Oe=Ie({document,run:on,delay:()=>i&&!t?15e3:void 0});return{async start(){i||t||(i=!0,R=location.origin+location.pathname,M=Ee(oe),S=n.session.subscribeIdentity(()=>{P++,$.cancel(),O.release(g?.deliveryTicket),E=!0,g=void 0,J.clear(),T=-1,ee.clear(),o&&pe(o,o.owner,!1),re(),k()}),l=new MutationObserver(k),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",k),addEventListener("pagehide",ae),await Oe.refresh())},refresh:Ne,async retry(){g&&!t&&g.epoch===P&&await F(g)},destroy(){t=!0,u++,$.cancel(),O.release(g?.deliveryTicket),Oe.destroy(),_?.abort(),l?.disconnect(),M?.(),S?.(),document.removeEventListener("click",ce,!0),document.removeEventListener("visibilitychange",k),removeEventListener("pagehide",ae),ae(),re(),b.dispose(),h=void 0}}}function Pn(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,R=0,P=-1,B=!1,z="",m,s,E,_,M=new Set,S,l,o,T=(r,A)=>Q(n.onStatus,r,A),g=Re(),N=()=>{try{return n.deliveryIdentity?.()}catch{return}},J=()=>JSON.stringify(N()),c=Se({storage:n.deliveryStorage,binding:()=>{let r=N();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 O(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 A=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-IJDKXLST.js");if(t||A!==y||l!==r)return;let V=document.createElement("div");n.container.append(V),P=R;let F=await W(V,{...n.host,client:H.controller,appManifestRelease:n.appManifestRelease,onDismiss(X){o?.process===r.process&&(o=void 0,V.remove()),Q(n.host?.onDismiss,X)}});if(t||A!==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||A!==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),Y()):T("entry_unavailable",r.entry.id)}finally{r.dispatching=!1}}function Z(r){if(t||i||l||o||S||g.active||P===R||!O(r))return;let A=`${R}:${r.id}`;if(M.has(A))return;M.add(A);let H=R,W=y,V=J();g.start(r.delivery?.delaySeconds??0,()=>!t&&y===W&&R===H&&J()===V&&document.visibilityState!=="hidden"&&O(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),Y();return}try{let X={entry:r,process:n.createProcess(r),visit:R,deliveryTicket:F};l=X,te(X)}catch(X){c.release(F),T("entry_unavailable",r.id),Q(n.host?.onError,X)}},()=>{M.delete(A)})}function Y(){B||t||(B=!0,queueMicrotask(()=>{if(B=!1,g.recheck(),!(t||i||document.visibilityState==="hidden"||!$()||l||o||S||g.active||P===R)){for(let r of b?.entries??[])if(r.event==="screen_enter"&&!M.has(`${R}:${r.id}`)&&O(r)){Z(r);break}}}))}function re(r){if(!r.isTrusted||r.defaultPrevented||!(r.target instanceof Element)||l||o||S||P===R)return;let A=be(document,()=>{});for(let H of b?.entries??[]){let W=H.target.button;if(H.event!=="button_click"||!W||!O(H))continue;let V=r.target.closest(W.selector);if(!(!V||V.tagName.toLowerCase()!==W.tag||A(W.selector)!==1||V.matches(":disabled")||V.closest('[inert],[hidden],[aria-hidden="true"]'))){Z(H);break}}}let le=()=>{let r=location.origin+location.pathname;r!==z&&(z=r,R++,g.cancel(),M.clear(),Y())};async function me(){if(t)return;if(s)return s;let r=y,A=new AbortController;m=A;let H,W=new Promise((ye,ue)=>{H=ue}),V=()=>H(new G("TIMEOUT","Funnel entry read cancelled"));A.signal.addEventListener("abort",V,{once:!0});let F=setTimeout(()=>A.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:A.signal});if(!ce.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",ce.status);return ge.parse(await ce.json())},k=await Promise.race([ue(),W]),se=Date.parse(k.validatedAt),oe=Date.parse(k.validUntil);if(k.scope.projectId!==n.scope.projectId||k.scope.environment!==n.scope.environment||k.scope.environmentId!==n.environmentId||k.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=k,w=oe,h=performance.now()+Math.min(oe-Date.now(),6e4),g.recheck(),Y())})();s=X;try{await X}finally{clearTimeout(F),A.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(Y),_.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",Y),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,Y();return}try{let A=await r.process.syncIdentity();return i=!1,S===r&&(l={...r,visit:R},S=void 0,await te(l)),A}catch(A){throw r.process.view||(S={...r,visit:R},l=void 0,ee()),A}},async detach(){i=!0,y++,g.cancel(),m?.abort();let r=o??l??S;r&&(S={...r,visit:R}),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",Y);let r=o??l??S;c.release(r?.deliveryTicket),l=void 0,S=void 0,ee(),r?.process.destroy(),b=void 0}}}async function _n(n,d){return(await import("./paywall-TVCH6VQT.js")).showPaywall(n,d)}async function ot(){return await Promise.all([import("./paywall-TVCH6VQT.js"),import("./screen-renderer-Q3VSMB2N.js")]),_n}async function at(...n){return n[1]=ze(n[1]),(await import("./paywall-session-UBQYU5XD.js")).createPaywallSession(...n)}async function st(...n){let d=n[1].signal?.aborted?void 0:We(n[1].client);try{return import("./screen-renderer-Q3VSMB2N.js").catch(()=>{}),import("./paywall-TVCH6VQT.js").catch(()=>{}),await(await rn(()=>import("./funnel-runtime-host-IJDKXLST.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-HHAQBIIB.js").then(b=>b.preparedInternals(d)?.release(),()=>{}),f}}async function ct(...n){return import("./screen-renderer-Q3VSMB2N.js").catch(()=>{}),import("./paywall-TVCH6VQT.js").catch(()=>{}),(await rn(()=>import("./funnel-host-purchase-AGBJG3RK.js"),n[1].prepared)).showFunnelPurchase(...n)}async function dt(...n){return import("./funnel-host-purchase-AGBJG3RK.js").catch(()=>{}),import("./screen-renderer-Q3VSMB2N.js").catch(()=>{}),(await import("./funnel-paywall-prerender-HHAQBIIB.js")).prerenderFunnelPurchase(...n)}async function lt(){await Promise.all([import("./funnel-paywall-prerender-HHAQBIIB.js"),import("./funnel-host-purchase-AGBJG3RK.js"),import("./paywall-TVCH6VQT.js"),import("./screen-renderer-Q3VSMB2N.js"),import("./paywall-content-QSTCRYU5.js"),import("./check-response-Q7GOBUGJ.js"),import("./operation-contracts-G4C7ZLEH.js")])}async function ut(...n){return(await import("./content-B4CC4O23.js")).mountContent(...n)}async function ft(...n){return(await import("./content-B4CC4O23.js")).prepareContent(...n)}export{G as LongplayError,I as MerchantBridgeError,un as createBrowserFunnelCommandStorage,gn as createBrowserFunnelPurchaseStorage,pn as createConfigurationSync,dn as createFeatureClient,hn as createFunnelClient,En as createFunnelPageExperiments,In as createFunnelProcess,vn as createFunnelPurchaseClient,Ce as createFunnelRunController,Rn as createIamFunnelEntries,Pn as createIamFunnelProcessEntries,wn as createLocalFunnelClient,ln as createLongplay,Sn as createMerchantBridge,at as createPaywallSession,yn as evaluateFunnelNode,sn as formatCouponDiscount,an as formatCouponMoney,cn as formatCouponTerms,fn as getPaywallRecovery,ut as mountContent,lt as preloadFunnelPurchase,ot as preloadPaywall,ft as prepareContent,mn as preparePaywallFallback,dt as prerenderFunnelPurchase,ct as showFunnelPurchase,st as showFunnelRun,_n as showPaywall};
@@ -0,0 +1 @@
1
+ import{N as r,O as m,h as e}from"./chunk-UAJTQ23E.js";import"./chunk-2LND3R7K.js";import"./chunk-4E326NPY.js";import"./chunk-UD7XPHE4.js";import"./chunk-K3VQKR4G.js";import"./chunk-Q7K66FTS.js";import"./chunk-42UXYMRZ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{m as merchantBridgeCommerceSchema,r as merchantBridgeOperationSchema,e as merchantOperationLookupSchema};