@tinkerlandai/longplay-sdk 0.10.51 → 0.10.52
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.
- package/CHANGELOG.md +6 -0
- package/dist/check-response-AVQ7PY5I.js +1 -0
- package/dist/{chunk-IDDPWGQE.js → chunk-2MDJ3JE5.js} +1 -1
- package/dist/{chunk-SZZIYCXK.js → chunk-3LWZFXLN.js} +1 -1
- package/dist/{chunk-TIOPNTMP.js → chunk-3TV3CVNP.js} +1 -1
- package/dist/{chunk-7GU34JD4.js → chunk-4CRUNNTC.js} +1 -1
- package/dist/{chunk-TIUD3N72.js → chunk-4OSW2Y67.js} +1 -1
- package/dist/{chunk-IVXYLNAF.js → chunk-5YQZEJBM.js} +1 -1
- package/dist/{chunk-FN462OVO.js → chunk-7LHRBNSH.js} +1 -1
- package/dist/{chunk-3ITNAFAH.js → chunk-7Q25R5GL.js} +1 -1
- package/dist/{chunk-LE32WTZ7.js → chunk-7UXQJJFZ.js} +1 -1
- package/dist/{chunk-N3PZMMOO.js → chunk-AFZB2AYU.js} +1 -1
- package/dist/{chunk-US65SQX4.js → chunk-AN7CPDBU.js} +1 -1
- package/dist/{chunk-JDIFYMSA.js → chunk-BBA64POP.js} +1 -1
- package/dist/{chunk-ZDIWOE4Q.js → chunk-BYHBBZIO.js} +1 -1
- package/dist/{chunk-HYX3EDZS.js → chunk-CBOIDISB.js} +1 -1
- package/dist/{chunk-KSME3N3A.js → chunk-CJUVMNDB.js} +1 -1
- package/dist/{chunk-4NO6U4X6.js → chunk-DJYLJBU2.js} +1 -1
- package/dist/{chunk-PJAZ2UP4.js → chunk-EDV6ZNPQ.js} +1 -1
- package/dist/chunk-EJAF6OGO.js +1 -0
- package/dist/{chunk-FRRKTQNZ.js → chunk-FAMPOY6L.js} +1 -1
- package/dist/{chunk-GJSQZGBE.js → chunk-FKC7TJWM.js} +1 -1
- package/dist/{chunk-W3B4GT74.js → chunk-I643NVMZ.js} +1 -1
- package/dist/{chunk-HP6OV6WF.js → chunk-JRHJO4BR.js} +1 -1
- package/dist/{chunk-Y2ASROJH.js → chunk-K644WUOE.js} +1 -1
- package/dist/{chunk-YFLVGOCJ.js → chunk-KVIGHX2B.js} +1 -1
- package/dist/{chunk-VKFLQEW4.js → chunk-KXSZTBAG.js} +1 -1
- package/dist/chunk-L66EXWTK.js +1 -0
- package/dist/{chunk-FYD7CMS7.js → chunk-LDLS2VL2.js} +1 -1
- package/dist/{chunk-67LPUJMN.js → chunk-NVHRWZIZ.js} +1 -1
- package/dist/{chunk-IXXVMGMF.js → chunk-OEUA65JK.js} +1 -1
- package/dist/{chunk-HYCLLEFU.js → chunk-PGZZKX5K.js} +1 -1
- package/dist/{chunk-MQ5LJEWV.js → chunk-POX2ELNS.js} +1 -1
- package/dist/{chunk-3Z3HL42M.js → chunk-PZZLYHKR.js} +2 -2
- package/dist/chunk-QIY6PCYC.js +1 -0
- package/dist/{chunk-OPUIFAQS.js → chunk-RUMGXXVJ.js} +1 -1
- package/dist/{chunk-RFWVXTZ7.js → chunk-S4YBFFFY.js} +1 -1
- package/dist/{chunk-VPYKAEHU.js → chunk-S6MXUFVF.js} +1 -1
- package/dist/{chunk-EGFVGCDG.js → chunk-TSBXPDUQ.js} +1 -1
- package/dist/{chunk-LSHIR6QM.js → chunk-UCDQJB53.js} +1 -1
- package/dist/{chunk-2I2S5ZIH.js → chunk-USM6HOXG.js} +1 -1
- package/dist/{chunk-B4SM2KRI.js → chunk-VGEH7B6S.js} +1 -1
- package/dist/{chunk-A5KU4MMN.js → chunk-VPT5MFDG.js} +2 -2
- package/dist/{chunk-DB5S72HJ.js → chunk-W3V7DTPC.js} +1 -1
- package/dist/{chunk-KCN6OGYG.js → chunk-XI2NNZBS.js} +1 -1
- package/dist/{chunk-3TSFGU4T.js → chunk-XO6GV6O7.js} +1 -1
- package/dist/{chunk-2LEDTNKQ.js → chunk-YGOXUDDF.js} +1 -1
- package/dist/{chunk-PF6PRPRO.js → chunk-YJRO7NXN.js} +1 -1
- package/dist/{chunk-2G23BYBI.js → chunk-ZNOVEJLM.js} +1 -1
- package/dist/{chunk-TNPBYYAX.js → chunk-ZVLZLBDA.js} +1 -1
- package/dist/chunk-ZY4YDPSI.js +1 -0
- package/dist/{content-VTHRQSFT.js → content-2EEYM7U7.js} +1 -1
- package/dist/funnel-host-purchase-UONTZRRJ.js +1 -0
- package/dist/funnel-paywall-prerender-AT4BXZIY.js +1 -0
- package/dist/funnel-route-prediction-Z3J2HSHI.js +1 -0
- package/dist/funnel-route-source-LFE6GSHU.js +1 -0
- package/dist/funnel-runtime-host-7ROIR7CU.js +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-O6WIWC7T.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-H7NKQ373.js +1 -0
- package/dist/page.js +1 -1
- package/dist/paywall-25MAYQ4B.js +1 -0
- package/dist/paywall-content-7KTEQLRN.js +1 -0
- package/dist/paywall-session-7HGW5IKN.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-XZWKIJWF.js +1 -0
- package/dist/server.js +1 -1
- package/dist/{visual-dom-IN6DRNX3.js → visual-dom-5LUN4AHO.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/check-response-MCT5RGOM.js +0 -1
- package/dist/chunk-CGJZIDG3.js +0 -1
- package/dist/chunk-MVUNV5XR.js +0 -1
- package/dist/chunk-TM72XBM5.js +0 -1
- package/dist/funnel-host-purchase-HBQOWEES.js +0 -1
- package/dist/funnel-paywall-prerender-MD4UI2AP.js +0 -1
- package/dist/funnel-route-prediction-XNIKDJIM.js +0 -1
- package/dist/funnel-route-source-EUIA4M3Y.js +0 -1
- package/dist/funnel-runtime-host-NZAV6C5O.js +0 -1
- package/dist/merchant-bridge-contracts-7EHDNPJJ.js +0 -1
- package/dist/operation-contracts-C6CMAO6S.js +0 -1
- package/dist/paywall-DKTGQZDJ.js +0 -1
- package/dist/paywall-content-SML4CL2Q.js +0 -1
- package/dist/paywall-session-YKE2CHHI.js +0 -1
- package/dist/screen-renderer-HW2WXDTR.js +0 -1
- /package/dist/{chunk-WPFTSHP2.js → chunk-CILM5XMH.js} +0 -0
- /package/dist/{chunk-RA7GZ67U.js → chunk-OJM6ORHE.js} +0 -0
- /package/dist/{chunk-XVCSRZX4.js → chunk-PY3AC5KD.js} +0 -0
- /package/dist/{chunk-3Z3HL42M.js.LEGAL.txt → chunk-PZZLYHKR.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-A5KU4MMN.js.LEGAL.txt → chunk-VPT5MFDG.js.LEGAL.txt} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as Ae}from"./chunk-7Q25R5GL.js";import{a as B}from"./chunk-USM6HOXG.js";import{D as Q,F as Ue,c as Oe,e as H,j as _e,u as Fe,v as Ne,x as je,z as Te}from"./chunk-XO6GV6O7.js";import{a as Ee,b as Re,c as be}from"./chunk-K644WUOE.js";import{K as V}from"./chunk-7UXQJJFZ.js";import{a as re}from"./chunk-UCDQJB53.js";import{i as oe}from"./chunk-RUMGXXVJ.js";import{A as te,B as ve,C as ne,E as Ce}from"./chunk-TSBXPDUQ.js";import{x as me}from"./chunk-KVIGHX2B.js";import{b as ke}from"./chunk-7LHRBNSH.js";import{a as l}from"./chunk-BYHBBZIO.js";import{h as ee}from"./chunk-LDLS2VL2.js";import{b as qe}from"./chunk-VGEH7B6S.js";import{b as n}from"./chunk-PY3AC5KD.js";import{a as fe}from"./chunk-DSPLGTQI.js";var g=V.options,$e=n.discriminatedUnion("operation",[g[1].omit({customerToken:!0}),g[2].omit({customerToken:!0}),g[3].omit({customerToken:!0}),g[4].omit({customerToken:!0}),g[5].omit({customerToken:!0}),g[6].omit({customerToken:!0}),g[7].omit({customerToken:!0}),g[8].omit({customerToken:!0}),_e.omit({customerToken:!0})]),he=n.strictObject({receiptId:n.uuid(),operationId:n.uuid()}),it=n.discriminatedUnion("operation",[n.strictObject({operation:n.literal("find_purchase")}),n.strictObject({operation:n.literal("recover_start"),intent:n.enum(["lookup","resume","start"]),start:n.strictObject({requestId:g[0].shape.requestId,funnelId:g[0].shape.funnelId,locale:g[0].shape.locale,parameters:g[0].shape.parameters})}),n.strictObject({operation:n.literal("recover_run"),runId:n.uuid(),funnelId:n.uuid()}),n.strictObject({operation:n.literal("recover_purchase"),runId:n.uuid(),funnelId:n.uuid(),purchase:he,includePaywallVersion:n.literal(!0).optional()}),n.strictObject({operation:n.literal("terminate_checkout"),runId:n.uuid(),funnelId:n.uuid(),purchase:he}),n.strictObject({operation:n.literal("settle_command"),runId:n.uuid(),funnelId:n.uuid(),requestId:n.uuid(),command:n.discriminatedUnion("operation",[g[3].omit({customerToken:!0}),g[4].omit({customerToken:!0}),g[5].omit({customerToken:!0}),g[6].omit({customerToken:!0}),g[7].omit({customerToken:!0})]).optional()}).refine(a=>!a.command||a.requestId===a.command.requestId),n.strictObject({operation:n.literal("run_command"),runId:n.uuid(),funnelId:n.uuid(),command:$e})]),ae=n.strictObject({runId:n.uuid(),funnelId:n.uuid(),versionId:n.uuid(),startRequestId:n.uuid(),runExpiresAt:n.iso.datetime({offset:!0}),status:H.shape.run.shape.status}),U={scope:ee,customerId:n.uuid()},xe=n.discriminatedUnion("outcome",[n.strictObject({...U,outcome:n.literal("unknown"),target:n.null(),view:n.null(),access:n.null()}),n.strictObject({...U,outcome:n.literal("resolved"),target:ae,view:H.shape.run.nullable(),access:n.discriminatedUnion("type",[n.strictObject({type:n.literal("customer")}),n.strictObject({type:n.literal("operation_only"),cause:n.enum(["run_terminal","run_expired","run_revoked","issuer_unavailable"])})])})]).superRefine((a,d)=>{a.outcome==="resolved"&&(a.access.type==="customer"!=(a.view!==null)||a.view&&(a.view.id!==a.target.runId||a.view.source.id!==a.target.funnelId||a.view.source.versionId!==a.target.versionId||a.view.status!==a.target.status||a.view.runExpiresAt!==a.target.runExpiresAt||a.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Recovery view and original Run binding differ"})}),De=n.strictObject({...U,target:ae,view:H.shape.run.nullable(),settlement:n.strictObject({requestId:n.uuid(),state:n.enum(["pending","unknown","settled"]),acceptance:n.enum(["accepted","not_accepted","unknown"]),receiptPhase:n.enum(["accepted","processing","done"]).nullable(),basis:n.enum(["receipt","run_terminal","position_advanced","none"]),receiptId:n.uuid().nullable(),operationId:n.uuid().nullable()}),purchase:H.shape.purchase.unwrap().nullable()}).superRefine((a,d)=>{let f=a.settlement;(f.acceptance==="accepted"!=(f.receiptPhase!==null)||f.acceptance==="accepted"&&f.basis!=="receipt"||f.acceptance==="unknown"&&(f.state!=="unknown"||f.basis!=="none")||f.acceptance!=="accepted"&&(f.operationId!==null||f.receiptId!==null)||f.acceptance==="not_accepted"&&(f.state!=="settled"||!["run_terminal","position_advanced"].includes(f.basis))||a.purchase&&(a.purchase.receiptId!==f.receiptId||a.purchase.operation&&a.purchase.operation.operationId!==f.operationId||a.purchase.quote&&a.purchase.quote.operationId!==f.operationId)||a.view&&(a.view.id!==a.target.runId||a.view.source.id!==a.target.funnelId||a.view.source.versionId!==a.target.versionId||a.view.status!==a.target.status||a.view.runExpiresAt!==a.target.runExpiresAt||a.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Original command settlement binding differs"})}),Ve=n.strictObject({...U,target:ae,purchase:H.shape.purchase.unwrap(),paywallVersionId:n.uuid().optional()}).superRefine((a,d)=>{(!a.purchase.operation||typeof a.purchase.canReselect!="boolean"||a.purchase.quote&&a.purchase.quote.operationId!==a.purchase.operation.operationId)&&d.addIssue({code:"custom",message:"Original purchase proof is incomplete"})}),He=n.discriminatedUnion("outcome",[n.strictObject({...U,outcome:n.literal("none")}),n.strictObject({...U,outcome:n.literal("blocked")}),n.strictObject({...U,outcome:n.literal("found"),target:ae,start:n.strictObject({locale:g[0].shape.locale,parameters:g[0].shape.parameters}),purchase:he})]);var We=V.options[0].refine(a=>!a.customer&&!a.customerData),Xe=n.strictObject({receiptId:n.uuid(),operationId:n.uuid(),terminal:n.enum(["complete","native"]).nullable()}),Le=n.strictObject({schemaVersion:n.literal(1),baseUrl:n.url(),scope:ee,customerId:n.uuid(),sessionId:n.uuid(),start:We,allowed:n.array(n.enum(["merchant","record_only","indiana","native"])),run:n.strictObject({id:n.uuid(),versionId:n.uuid(),status:Oe.shape.status,revision:n.number().int().nonnegative(),runExpiresAt:n.iso.datetime({offset:!0}).optional()}).optional(),purchases:n.array(Xe).max(100),operationCommand:n.strictObject({operationId:n.uuid(),intent:n.literal("confirm")}).optional(),journal:n.strictObject({revision:n.number().int().nonnegative(),entry:Fe.nullable()})});function Ge(a){return je({...a,namespace:"purchases",identity:[a.scope.projectId,a.scope.environment,a.customerId]})}function Me(a){let d=new URL(a.baseUrl??qe).href,f=()=>new l("PURCHASE_STORAGE_INVALID","Purchase recovery storage is unavailable or invalid; native fallback is not authorized");async function v(){a.assertCurrent();try{let C=await a.storage.read();if(a.assertCurrent(),!Number.isSafeInteger(C.revision)||C.revision<0)throw f();let u=C.entry===null?null:Le.parse(C.entry);if(u&&(u.baseUrl!==d||u.customerId!==a.customerId||u.scope.projectId!==a.scope.projectId||u.scope.environment!==a.scope.environment))throw new l("SCOPE_MISMATCH","Purchase recovery belongs to another Customer or environment");if(u?.journal.entry&&(u.journal.entry.scope.projectId!==u.scope.projectId||u.journal.entry.scope.environment!==u.scope.environment||u.journal.entry.funnelId!==u.start.funnelId||u.journal.entry.runId!==u.run?.id||u.journal.entry.versionId!==u.run?.versionId)||u?.operationCommand&&!u.purchases.some(b=>b.operationId===u.operationCommand?.operationId))throw f();return{revision:C.revision,entry:u}}catch(C){throw C instanceof l?C:f()}}async function Y(C){for(let u=0;u<8;u++){let b=await v(),A=C(structuredClone(b.entry));if(JSON.stringify(A)===JSON.stringify(b.entry))return A;A&&Le.parse(A),a.assertCurrent();let E;try{E=await a.storage.write(b.revision,A)}catch{throw f()}if(a.assertCurrent(),E!==null){if(!Number.isSafeInteger(E)||E<=b.revision)throw f();return A}}throw new l("PURCHASE_STORAGE_CONFLICT","Another consumer changed this purchase; recover the original attempt")}return{read:v,update:Y,baseUrl:d}}var Ze=5*6e4;function et(a,d){let f=a.purchases.find(v=>v.type==="checkout");if(!a.actions.includes("continue_checkout")||f?.type!=="checkout"||d!==void 0&&f.operationId!==d)throw new l("PURCHASE_PENDING","No single resumable Checkout is confirmed");return f.checkoutUrl}function Nt(a){let d={...a,scope:{...a.scope},executionPolicy:structuredClone(a.executionPolicy)},f=d.session.snapshot();if(!f)throw new l("CUSTOMER_SESSION_REQUIRED","Purchase recovery requires a verified Customer session");let{customerId:v,sessionId:Y}=f,C=!1,u=null,b,A=null,E=!1,N,J,K,O={mode:"idle",status:"idle",actions:["start"],purchases:[]},P=new Map,Ie=new Map,T=new Map,ie=new AbortController,$=new Set,L=ke(d),W=Ae(L.request);function G(e){return{code:e instanceof l?e.code:"PURCHASE_RECOVERY_BLOCKED",message:e instanceof Error?e.message:"The original purchase requires server confirmation",...e instanceof l&&e.status!==void 0?{status:e.status}:{}}}function y(){if(C||d.session.snapshot()?.customerId!==v)throw new l("IDENTITY_CHANGED","The original purchase Customer changed")}let I=Me({...d,customerId:v,assertCurrent:y,storage:d.storage??Ge({baseUrl:d.baseUrl,scope:d.scope,customerId:v})}),ze=d.session.subscribeIdentity(we);function we(){C||(C=!0,clearTimeout(K),ie.abort(new l("IDENTITY_CHANGED","Purchase consumer was destroyed")),ze(),u?.reset(),u=null,A=null,L.dispose(),$.clear(),P.clear(),T.clear())}function S(e){y();let t=JSON.stringify(e)!==JSON.stringify(O);O=e,clearTimeout(K),(e.mode==="operation"||e.mode==="run"&&!e.actions.includes("close"))&&["waiting_result","fulfillment","recording"].includes(e.status)&&(K=setTimeout(()=>{D().catch(()=>{})},5e3)),t&&fe(d.onRecovery,structuredClone(e));for(let r of t?$:[]){if(C)break;fe(r,structuredClone(e))}return structuredClone(e)}function w(e){if(y(),!e||e.start.requestId!==b)throw new l("PURCHASE_STORAGE_CONFLICT","This purchase was superseded; the old consumer cannot dispatch")}function _(e){let t=[...e.purchases],r=e.journal.entry?.purchase;return r&&!t.some(o=>o.operationId===r.operationId)&&t.push({receiptId:r.receiptId,operationId:r.operationId,terminal:null}),t}function j(e){return e.run&&!["running","waiting"].includes(e.run.status)&&!e.journal.entry?.command&&!e.journal.entry?.closeCommand&&!e.operationCommand&&_(e).every(t=>t.terminal!==null)}function k(e,t){let r=e.journal.entry?.command??e.journal.entry?.closeCommand,o=_(e).map(h=>{let R=P.get(h.operationId);return h.terminal&&!R?{type:h.terminal,operationId:h.operationId}:re({quote:R?.quote??null,operation:R??null,requestId:r?.requestId??null,pending:!1,destroyed:!1,canReselect:T.get(h.operationId)===!0})}),s=o.filter(h=>!["complete","native"].includes(h.type)),i=s[0],c=s.length===1&&i?.operationId?P.get(i.operationId):void 0;if(c&&(i?.type==="checkout"||i?.type==="cancel"))try{Q({allowed:e.allowed.filter(h=>d.executionPolicy.allowed.includes(h))},c.quote)}catch(h){return{mode:t,status:"blocked",actions:["refresh",...t==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[]],purchases:o,error:G(h)}}let m;if(t==="operation"&&!r&&i?.type==="cancel"&&c?.quote&&!c.problem&&!c.confirmedAt)try{Q({allowed:e.allowed.filter(h=>d.executionPolicy.allowed.includes(h))},c.quote),Date.parse(c.quote.expiresAt)>Date.now()&&(m={operationId:c.operationId,quote:c.quote})}catch{}let p=o.length>0&&s.length===0,q=j(e)||t==="operation"&&p&&!r&&!e.operationCommand?"complete":i?.type==="checkout"?"checkout":i?.type==="fulfillment"?"fulfillment":i?.type==="recording"?"recording":r||e.operationCommand||i&&i.type!=="cancel"||t==="operation"&&!m?"waiting_result":"ready";return{mode:t,status:q,purchases:o,...m?{confirmation:structuredClone(m)}:{},actions:["refresh",...j(e)?["start"]:[],...t==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[],...e.operationCommand?["retry"]:m?["confirm"]:[],...s.length===1&&i?.type==="checkout"?["continue_checkout"]:[]]}}function se(e){let t=re({quote:e?.quote??null,operation:e??null,requestId:null,pending:!1,destroyed:!1,canReselect:e&&T.get(e.operationId)===!0});return t.type==="complete"||t.type==="native"?t.type:null}function ue(e){if(!e.operation)return;let t=te.parse({...e.operation,...e.operation.quote?{}:e.quote?{quote:e.quote}:{}});if(t.merchantExecution&&t.merchantExecution.customerId!==v)throw new l("SCOPE_MISMATCH","Purchase execution belongs to another Customer");let r=oe(P.get(t.operationId)??null,t);P.set(t.operationId,r),r===t&&T.set(t.operationId,e.canReselect===!0)}async function Qe(e){y();for(let r of[e.purchase,e.run.paywall])r&&ue(r);let t=await I.update(r=>{if(w(r),r.run&&(r.run.id!==e.run.id||r.run.versionId!==e.run.source.versionId))throw new l("SCOPE_MISMATCH","The original purchase Run changed");let o=_(r);for(let s of[e.purchase,e.run.paywall]){let i=s?.operation?.operationId??s?.quote?.operationId;if(!s||!i)continue;let c=o.find(p=>p.operationId===i);if(c&&c.receiptId!==s.receiptId)throw new l("INVALID_RESPONSE","The original purchase Receipt changed");let m=se(P.get(i));c?c.terminal??=m:o.push({receiptId:s.receiptId,operationId:i,terminal:m})}return{...r,purchases:o,run:r.run&&(r.run.revision>e.run.revision||!["running","waiting"].includes(r.run.status)&&["running","waiting"].includes(e.run.status))?r.run:{id:e.run.id,versionId:e.run.source.versionId,status:e.run.status,revision:e.run.revision,runExpiresAt:e.run.runExpiresAt}}});w(t),t.run&&!["running","waiting"].includes(t.run.status)&&_(t).some(r=>!r.terminal)&&(t=await x(t,!t.journal.entry?.command&&!t.journal.entry?.closeCommand,new Set([e.purchase?.operation?.operationId,e.run.paywall?.operation?.operationId].filter(r=>!!r)))),w(t),S(k(t,"run"))}function Be(){return{async read(){let{entry:e}=await I.read();return w(e),structuredClone(e.journal)},async write(e,t){let r=null;return await I.update(o=>{if(w(o),o.operationCommand&&t?.command&&t.command.operation!=="close")throw new l("PURCHASE_PENDING","Recover the original Operation command before dispatching a Run mutation");return r=null,o.journal.revision!==e?o:(r=e+1,{...o,journal:{revision:r,entry:t}})}),r}}}async function x(e,t=!1,r=new Set){w(e);let o=_(e);for(let i of o){if(i.terminal)continue;let c=r.has(i.operationId)?P.get(i.operationId):void 0;if(c??=await z(e,i),y(),c.operationId!==i.operationId)throw new l("INVALID_RESPONSE","Original Operation changed");if(c.merchantExecution&&c.merchantExecution.customerId!==v)throw new l("SCOPE_MISMATCH","Purchase execution belongs to another Customer");if(t&&!e.operationCommand&&re({quote:c.quote??null,operation:c,requestId:null,pending:!1,destroyed:!1}).type==="cancel"){let m=ne(c)?await W.update({operationId:i.operationId,intent:"cancel"}):await W.attach({operationId:i.operationId,intent:"cancel"});if(c=te.parse(m.operation),y(),c.operationId!==i.operationId)throw new l("INVALID_RESPONSE","Original cancellation Operation changed");c=await z(e,i)}P.set(i.operationId,oe(P.get(i.operationId)??null,c))}let s=await I.update(i=>{w(i);let c=i.operationCommand&&P.get(i.operationCommand.operationId);return{...i,...c&&(c.confirmedAt||c.merchantExecution||!Ce(c))?{operationCommand:void 0}:{},purchases:_(i).map(m=>({...m,terminal:m.terminal??se(P.get(m.operationId))}))}});return w(s),s}async function M(e){y();let t=await L.request("funnels",e);return y(),t}async function Ye(e){try{return await M(e)}catch(t){if(e.operation!=="recover_start"||e.intent!=="start"||!(t instanceof l)||t.status!==400||t.code!=="INVALID_REQUEST")throw t;return M({...e,intent:"resume"})}}async function Je(){let e=B(He,await M({operation:"find_purchase"}));if(e.customerId!==v||e.scope.projectId!==d.scope.projectId||e.scope.environment!==d.scope.environment)throw new l("SCOPE_MISMATCH","Recovery Customer or environment changed");if(e.outcome!=="found")return e.outcome;let{target:t,purchase:r}=e;return await I.update(o=>o&&!j(o)?o:{schemaVersion:1,baseUrl:I.baseUrl,scope:d.scope,customerId:v,sessionId:Y,start:{operation:"start",requestId:t.startRequestId,funnelId:t.funnelId,...e.start},allowed:[...d.executionPolicy.allowed],run:{id:t.runId,versionId:t.versionId,status:t.status,revision:0,runExpiresAt:t.runExpiresAt},purchases:[{...r,terminal:null}],journal:{revision:0,entry:null}}),"found"}let X;function ce(e){let t=X;if(t&&(!t.outcome||e&&t.outcome==="none"&&Date.now()-t.at<Ze))return t.job;let r={at:Date.now(),job:Je().then(o=>(r.outcome=o,r.at=Date.now(),o),o=>{throw X===r&&(X=void 0),o})};return X=r,r.job}async function z(e,t,r="recover_purchase",o=!1){let s=B(Ve,await M({operation:r,runId:e.run.id,funnelId:e.start.funnelId,purchase:{receiptId:t.receiptId,operationId:t.operationId},...o?{includePaywallVersion:!0}:{}}));if(le(e,s),s.purchase.receiptId!==t.receiptId||s.purchase.operation?.operationId!==t.operationId)throw new l("INVALID_RESPONSE","Original purchase reference changed");return ue(s.purchase),o&&s.paywallVersionId&&Ie.set(t.operationId,s.paywallVersionId),P.get(t.operationId)}async function ye(e){for(let t of[e.journal.entry?.command,e.journal.entry?.closeCommand]){if(!t)continue;let r=B(De,await M({operation:"settle_command",runId:e.run.id,funnelId:e.start.funnelId,requestId:t.requestId,...t.operation==="resume"?{}:{command:t}}));if(le(e,r),r.settlement.requestId!==t.requestId)throw new l("INVALID_RESPONSE","Original command settlement changed");r.purchase&&ue(r.purchase);let o=await I.update(s=>{w(s);let i=_(s),{receiptId:c,operationId:m}=r.settlement;if(c&&m){let q=i.find(h=>h.operationId===m);if(q&&q.receiptId!==c)throw new l("INVALID_RESPONSE","Original Receipt changed");q||i.push({receiptId:c,operationId:m,terminal:se(P.get(m))})}let p=r.settlement.state==="settled"?Ne(s.journal.entry,t.requestId):s.journal.entry;return{...s,purchases:i,journal:p===s.journal.entry?s.journal:{revision:s.journal.revision+1,entry:p}}});w(o),e=o}return e}function le(e,t){if(t.customerId!==v||t.scope.projectId!==d.scope.projectId||t.scope.environment!==d.scope.environment||t.target.funnelId!==e.start.funnelId||t.target.startRequestId!==e.start.requestId||e.run&&(t.target.runId!==e.run.id||t.target.versionId!==e.run.versionId))throw new l("SCOPE_MISMATCH","The original recovery binding changed")}async function de(e,t){if(w(e),e.run&&(e=await ye(e)),!_(e).length&&j(e))return S(k(e,"operation"));if(!_(e).length)return S({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:G(t)});E=!0;let r=await x(e);return S(k(r,"operation"))}async function Z(e,t=!1,r=!0){if(b=e.start.requestId,A=structuredClone({requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}),!u){let o=e.run?{operation:"recover_run",runId:e.run.id,funnelId:e.start.funnelId}:{operation:"recover_start",intent:t?"start":"lookup",start:{requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}},s;try{s=await Ye(o)}catch(p){if(!e.run&&p instanceof l&&(p.status===void 0||p.status>=500))return S({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:O.purchases,error:G(p)});throw p}let i=B(xe,s);if(i.customerId!==v||i.scope.projectId!==d.scope.projectId||i.scope.environment!==d.scope.environment)throw new l("SCOPE_MISMATCH","Recovery Customer or environment changed");if(i.outcome==="unknown")return S({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:O.purchases,error:{code:"RESULT_UNKNOWN",message:"The original Start outcome remains unknown; retry only its original input"}});le(e,i);let c=await I.update(p=>(w(p),{...p,run:{id:i.target.runId,versionId:i.target.versionId,status:i.target.status,revision:i.view?.revision??p.run?.revision??0,runExpiresAt:i.target.runExpiresAt}}));if(w(c),e=c,i.access.type==="operation_only")return de(e,new l("RUN_RECONCILIATION_REQUIRED","Only the original command and Operation can be recovered"));e=await ye(e);let m=i.view;if(m.locale!==e.start.locale||!Te(m.parameters,e.start.parameters))throw new l("INVALID_RESPONSE","The original Start input changed");u=Ue({...d,customerRun:{runId:i.target.runId,customerId:v,startRequestId:e.start.requestId},funnelId:e.start.funnelId,funnelExecutionPolicy:{allowed:e.allowed.filter(p=>d.executionPolicy.allowed.includes(p))},funnelCommandStorage:Be(),onAcceptedResponse:Qe},{scope:i.scope,run:m})}try{await u.get(),u.view?.pendingRequest?.requestId===e.start.requestId&&!u.pendingCommands?.length&&await u.resume(u.view.pendingRequest.requestId);for(let s of u.pendingCommands??[])s.operation!=="close"&&await u.settle?.(s.requestId);u.pendingCommands?.length&&await u.retry(),y();let o=(await I.read()).entry;return w(o),S(k(o,"run"))}catch(o){if(y(),r&&o instanceof l&&(o.status===401||o.status===409&&o.reason==="STATE_CHANGED")){u.reset(),u=null;let s=(await I.read()).entry;return w(s),Z(s,!1,!1)}throw o}}function F(e,t="read",r){if(y(),N)return t==="read"||t===J?N:N.then(()=>F(e,t,r),()=>F(e,t,r));clearTimeout(K);let o=e().catch(s=>{throw!C&&!r?.(s)&&S({mode:"blocked",status:"blocked",actions:["refresh"],purchases:O.purchases,error:G(s)}),s});return N=o,J=t,o.then(()=>{N===o&&(N=void 0,J=void 0)},()=>{N===o&&(N=void 0,J=void 0)}),o}function D(){return F(async()=>{let{entry:e}=await I.read();if(!e||j(e)){if(await ce(!1)==="blocked")return ge();({entry:e}=await I.read())}return e?(b&&e.start.requestId!==b&&(u?.reset(),u=null,P.clear(),T.clear(),E=!1),E&&b===e.start.requestId?de(e,O.error):Z(e)):S({mode:"idle",status:"idle",actions:["start"],purchases:[]})})}function ge(){return S({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:G(new l("PURCHASE_PENDING","Check the outstanding purchases before starting another"))})}async function Pe(){let e=await D();return e.mode==="operation"&&!e.actions.includes("confirm")&&!e.actions.includes("retry")?e:F(async()=>{let t=(await I.read()).entry;if(w(t),!E){if(!u?.view?.paywall?.quote)throw new l("PURCHASE_PENDING","Read the original quote before confirming");let p=u.view.paywall.operation;if(p?.confirmedAt||p?.merchantExecution||p&&!(ne(p)?["prepared","quoted"].includes(p.status):p.status==="pending"))return S(k(t,"run"));if(u.pendingCommands?.length)await u.retry();else{let h=u.view;await u.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:h.nodeId,visit:h.visit,revision:h.revision,input:{type:"paywall_confirm",operationId:h.paywall.quote.operationId,...h.paywall.quote.merchantTerms?{merchantConfirmation:me(h.paywall.quote.merchantTerms)}:{}}})}let q=(await I.read()).entry;return w(q),S(k(q,"run"))}let r=t.operationCommand?.operationId??O.confirmation?.operationId,o=r&&P.get(r);if(!r||!o||t.journal.entry?.command||t.journal.entry?.closeCommand)throw new l("PURCHASE_PENDING","The original Run command must be settled before Operation confirmation");Q({allowed:t.allowed.filter(p=>d.executionPolicy.allowed.includes(p))},o.quote),await I.update(p=>{if(w(p),p.journal.entry?.command||p.journal.entry?.closeCommand||p.operationCommand&&p.operationCommand.operationId!==r)throw new l("PURCHASE_PENDING","Another original command is pending");return{...p,operationCommand:{operationId:r,intent:"confirm"}}});let s={operationId:r,intent:"confirm",...o.quote?.merchantTerms?{merchantConfirmation:me(o.quote.merchantTerms)}:{}},i=ne(o)?await W.update(s):await W.attach(s),c=te.parse(i.operation);if(y(),i.operation.operationId!==r)throw new l("INVALID_RESPONSE","Original confirmation Operation changed");P.set(r,oe(o,c));let m=(await I.read()).entry;return w(m),S(k(await x(m,!1,new Set([r])),"operation"))},"confirm")}function Ke(e){let t=e?.quote;return t&&ve(t)&&t.timing==="immediate"&&t.execution.provider==="merchant"&&(e.confirmedAt||e.merchantExecution)?t:null}function pe(){if(O.mode!=="operation"||O.status==="blocked")return null;let e=O.purchases.filter(({type:r})=>r!=="complete"&&r!=="native"),t=e.length===1&&e[0]?.operationId;return t?Ke(P.get(t)):null}async function Se(){y();let{entry:e}=await I.read();return e?j(e)?"finished":"pending":"none"}return{get controller(){return u},get recovery(){return structuredClone(O)},get attempt(){return y(),structuredClone(A)},get identitySignal(){return ie.signal},get customerId(){return v},retained:Se,async findPurchase(){let e=await Se();if(e==="pending")return e;let t=await ce(!0);return y(),t==="none"?e:t},async readPaywall(e){y();let t=Ee(e),[r,{readPaywallContent:o},{validateResourceCheck:s}]=await Promise.all([Re(L.request,"resolvePaywall"),import("./paywall-content-7KTEQLRN.js"),import("./check-response-AVQ7PY5I.js")]);y();let i=r.request.parse({selector:t.paywallVersionId?{type:"version",versionId:t.paywallVersionId}:{type:"paywall",paywallId:t.paywallId},commerce:t.commerce,locale:t.locale}),c=await be(L.request,r,i);s(i,c.paywall.check,c.scope);let m=await o(d,c.paywall);if(y(),t.paywallVersionId?m.id!==t.paywallVersionId:m.paywallId!==t.paywallId)throw new l("INVALID_RESPONSE","The requested Paywall changed");return m},get canRestoreUpgradePaywall(){return pe()!==null},async recoverUpgradePaywall(){let e=pe();if(!e)return null;let{entry:t}=await I.read();if(!t?.run||pe()?.operationId!==e.operationId)return null;let r=_(t).filter(R=>!R.terminal),o=r[0];if(r.length!==1||o?.operationId!==e.operationId)return null;let s;Q({allowed:t.allowed.filter(R=>d.executionPolicy.allowed.includes(R))},e);try{s=await z(t,o,"recover_purchase",!0)}catch(R){if(R instanceof l&&R.status===400&&R.code==="INVALID_REQUEST")return null;throw R}let i=Ie.get(o.operationId),c=t.start.parameters?.commerce;if(!i||typeof c!="object"||!c||!("provider"in c)||typeof c.provider!="string"||!("currency"in c)||typeof c.currency!="string")return null;let m=t.start.locale??"en",p=await this.readPaywall({paywallVersionId:i,locale:m,commerce:{provider:c.provider,currency:c.currency,intent:"subscription_change"}});y();let q=!1,h=async()=>{throw new l("PURCHASE_PENDING","Only the original upgrade can be recovered")};return{signal:ie.signal,view:p,quote:e,locale:m,get operation(){return s??null},get canReselect(){return T.get(o.operationId)===!0},async refresh(){return p},preview:h,confirm:h,cancel:h,async read(){if(q)throw new DOMException("Upgrade view closed","AbortError");s=await z(t,o);let R=await x(t,!1,new Set([o.operationId]));return q||S(k(R,"operation")),structuredClone(s)},destroy(){q=!0}}},start(e){let t=V.parse({...structuredClone(e),operation:"start",requestId:e.requestId??crypto.randomUUID()});if(t.operation!=="start"||t.customer||t.customerData)throw new l("INVALID_REQUEST","A Customer-owned Funnel start is required");return F(async()=>{let r=(await I.read()).entry;if((!r||j(r))&&await ce(!0)==="blocked")return ge();let o=await I.update(s=>{if(s&&!j(s)){if(s.start.funnelId!==t.funnelId)throw new l("PURCHASE_PENDING","Recover the original Funnel before starting another purchase");return s}return{schemaVersion:1,baseUrl:I.baseUrl,scope:d.scope,customerId:v,sessionId:Y,start:t,allowed:[...d.executionPolicy.allowed],purchases:[],journal:{revision:0,entry:null}}});if(!o)throw new l("PURCHASE_STORAGE_INVALID","Original start was not retained");return b!==o.start.requestId&&(u?.reset(),u=null,P.clear(),T.clear(),E=!1),E?de(o,O.error):Z(o,!0)},`start:${t.funnelId}`)},refresh:D,confirm:Pe,retry:()=>E?Pe():F(async()=>{let{entry:e}=await I.read();return e?Z(e,!0):S({mode:"idle",status:"idle",actions:["start"],purchases:[]})},"retry"),async close(){return u?.view?F(async()=>{if(!u?.view)throw new l("PURCHASE_PENDING","Recover the original Run before closing");if(u.pendingCommands?.find(r=>r.operation==="close"))await u.retry();else if(["running","waiting"].includes(u.view.status)){let r=u.view;await u.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:r.nodeId,visit:r.visit,revision:r.revision})}let t=(await I.read()).entry;return w(t),S(k(t,"run"))},"close"):D()},async continueCheckout(e,t){let r=t?await F(async()=>{let{entry:o}=await I.read();if(w(o),!o.run||!_(o).some(i=>i.operationId===t&&!i.terminal))throw new l("PURCHASE_PENDING","The original Checkout changed");let s=await x(o);return S(k(s,E?"operation":"run"))},`continue:${t}`,o=>o instanceof l&&o.code==="PURCHASE_PENDING"):await D();y(),await e(et(r,t))},async terminateCheckout(e){let t=await D();if(!t.purchases.find(o=>o.type==="checkout"&&o.operationId===e)||!t.actions.includes("continue_checkout"))throw new l("PURCHASE_PENDING","The original Checkout has changed");return F(async()=>{let{entry:o}=await I.read();w(o);let s=_(o).find(c=>c.operationId===e&&!c.terminal);if(!s||!o.run)throw new l("PURCHASE_PENDING","The original Checkout has changed");await z(o,s,"terminate_checkout");let i=await x(o,!1,new Set([e]));return S(k(i,E?"operation":"run"))},`terminate:${e}`,o=>o instanceof l&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(o.code))},subscribe(e){return $.add(e),()=>{$.delete(e)}},destroy:we}}export{Ge as a,et as b,Nt as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as ie}from"./chunk-
|
|
1
|
+
import{i as ie}from"./chunk-NVHRWZIZ.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-ZNOVEJLM.js";import{b as X}from"./chunk-JRHJO4BR.js";import{r as V}from"./chunk-CJUVMNDB.js";import"./chunk-7UXQJJFZ.js";import"./chunk-2MDJ3JE5.js";import"./chunk-CBOIDISB.js";import"./chunk-TSBXPDUQ.js";import"./chunk-KVIGHX2B.js";import"./chunk-VILB5M4X.js";import"./chunk-7LHRBNSH.js";import"./chunk-FAMPOY6L.js";import{o as Y,p as K}from"./chunk-POX2ELNS.js";import{A as G}from"./chunk-BBA64POP.js";import"./chunk-ZVLZLBDA.js";import"./chunk-XI2NNZBS.js";import{c as $,d as R}from"./chunk-YJRO7NXN.js";import{a as p}from"./chunk-BYHBBZIO.js";import"./chunk-LDLS2VL2.js";import"./chunk-VGEH7B6S.js";import{b as u}from"./chunk-PY3AC5KD.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.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="×",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"关闭":"Close"),ne(e,r.screen.theme),e.addEventListener("click",v),n.prepend(e)}n&&a?.responsive&&(_=Z(n,v,k,t.locale?.startsWith("zh")?"关闭":"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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as ae}from"./chunk-EJAF6OGO.js";import{b as Q}from"./chunk-OEUA65JK.js";import"./chunk-AFZB2AYU.js";import"./chunk-YGOXUDDF.js";import{a as ne}from"./chunk-QIY6PCYC.js";import{a as K}from"./chunk-4CRUNNTC.js";import{b as ee}from"./chunk-ZY4YDPSI.js";import"./chunk-4OSW2Y67.js";import"./chunk-W32FI2A2.js";import{f as te,h as re,i as z,j as J}from"./chunk-ZNOVEJLM.js";import"./chunk-7Q25R5GL.js";import"./chunk-USM6HOXG.js";import"./chunk-XO6GV6O7.js";import"./chunk-I643NVMZ.js";import"./chunk-K644WUOE.js";import"./chunk-AN7CPDBU.js";import"./chunk-PGZZKX5K.js";import"./chunk-CJUVMNDB.js";import"./chunk-7UXQJJFZ.js";import"./chunk-3LWZFXLN.js";import"./chunk-2MDJ3JE5.js";import"./chunk-UCDQJB53.js";import"./chunk-RUMGXXVJ.js";import"./chunk-CBOIDISB.js";import"./chunk-TSBXPDUQ.js";import"./chunk-KVIGHX2B.js";import"./chunk-VILB5M4X.js";import"./chunk-7LHRBNSH.js";import"./chunk-FAMPOY6L.js";import"./chunk-POX2ELNS.js";import"./chunk-BBA64POP.js";import"./chunk-ZVLZLBDA.js";import"./chunk-XI2NNZBS.js";import"./chunk-YJRO7NXN.js";import{a as T}from"./chunk-BYHBBZIO.js";import"./chunk-LDLS2VL2.js";import"./chunk-SLUA7ABW.js";import"./chunk-FKC7TJWM.js";import"./chunk-3VUPVXAV.js";import"./chunk-VGEH7B6S.js";import"./chunk-PY3AC5KD.js";import{a as g}from"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";function ie(x,e){let s=x.ownerDocument,b=(e.locale??s.documentElement.lang).startsWith("zh"),G=re(s),m=e.retained?.dialog??s.createElement("dialog"),I=s.createElement("section"),w=s.createElement("h2"),h=s.createElement("p"),f=s.createElement("button"),C=s.createElement("button"),t=s.createElement("button");w.textContent=e.retained?.dialog.getAttribute("aria-label")||(b?"购买状态":e.retained?"Purchase status":"Your purchase"),w.style.cssText="margin:0;font-size:20px;line-height:1.3",m.setAttribute("aria-label",w.textContent),e.retained||(m.style.cssText="box-sizing:border-box;width:min(640px,calc(100% - 32px));max-height:calc(100dvh - 32px);border:0;border-radius:16px;background:Canvas;color:CanvasText;padding:0"),I.style.cssText="padding:24px 56px 24px 24px;font:14px/1.5 system-ui,sans-serif",f.textContent="×",f.setAttribute("aria-label",b?"关闭":"Close"),te(f,{background:"Canvas",text:"CanvasText"}),h.setAttribute("role","status"),t.textContent=b?"查询状态":"Check status";for(let u of[f,C,t])u.type="button";for(let u of[C,t])u.style.cssText="min-height:44px;padding:8px 14px;margin-inline-end:8px;border:1px solid ButtonBorder;border-radius:8px;font:inherit;cursor:pointer";I.append(w,f,h,C,t),m.append(I);let o=!1,p=!1,P=e.checking===!0,F=!1,v=e.initialState;function A(u){if(o)return;v=u;let i=v.actions.includes("continue_checkout"),_=e.allowConfirm&&v.actions.includes("confirm");C.hidden=P||!i&&!_,C.disabled=t.disabled=p||P,C.textContent=i?b?"继续付款":"Continue checkout":b?"确认购买":"Confirm purchase",h.textContent=P?b?"正在核对购买状态…":"Checking your purchase…":F||v.status==="blocked"?b?"暂时无法确认购买状态。请重试。":"We couldn’t check your purchase. Try again.":v.status==="complete"?b?"购买已处理。":"Your purchase has been processed.":i?b?"可以继续原订单付款。":"You can continue your original checkout.":b?"正在核对购买状态…":"Checking your purchase…"}async function R(u){if(!(o||p)){p=!0,F=!1,A(v);try{await u()}catch(i){o||(F=!0,g(e.onError,i))}finally{p=!1,A(e.client.recovery)}}}let N=()=>R(e.refresh),L=e.client.subscribe(A);function O(){return o?!1:(o=!0,e.signal.removeEventListener("abort",k),s.removeEventListener("visibilitychange",q),L(),m.removeEventListener("cancel",a),I.remove(),!0)}function U(){e.retained?e.retained.release():(m.remove(),G())}function k(){O()&&(U(),e.onDismiss())}function q(){s.visibilityState==="visible"&&N()}f.onclick=k;function a(u){u.preventDefault(),k()}m.addEventListener("cancel",a),t.onclick=()=>{N()},C.onclick=()=>{R(async()=>{v.actions.includes("continue_checkout")?await e.client.continueCheckout(u=>{if(e.signal.throwIfAborted(),!o)return e.onCheckoutUrl?e.onCheckoutUrl(u):s.defaultView?.location.assign(u)}):e.allowConfirm&&v.actions.includes("confirm")&&await e.client.confirm()})},e.signal.addEventListener("abort",k,{once:!0}),s.addEventListener("visibilitychange",q),A(v);function E(){o||e.signal.aborted||(e.retained||(x.append(m),m.showModal?m.showModal():m.open=!0),f.focus({preventScroll:!0}))}return e.loading?.active?e.loading.present(E):E(),{destroy:k,retainPurchaseDialog(){if(!(!m.open||!O()))return{dialog:m,release:U}},refresh:N,update(u){P=!1,A(u)},get recovery(){let u=v.purchases.filter(i=>!["native","complete"].includes(i.type));return structuredClone(u.length===1?u[0]:{type:"recover",operationId:null,requestId:null})},async prepareFallback(){return{type:"recover",operationId:null,requestId:null}},async review(){},async exitReview(){},get unappliedDrafts(){return new Map}}}var M=new WeakMap,V=new WeakMap,X=new WeakSet;function ye(x,e){let s=e.prepared,b=()=>{s&&!X.has(s)&&Q(s)?.release()},G=M.get(e.client);if(G)return b(),G;let m=t=>({...t,requestId:t.requestId??crypto.randomUUID()}),I=e.allowNewPurchase!==!1&&e.start instanceof Promise?e.start:void 0,w=e.allowNewPurchase===!1||!e.start||e.start instanceof Promise?void 0:m(e.start);w&&s?.state==="ready"&&s.matches(w)&&s.open();let h=s&&(w&&(s.state==="preparing"||["shown","closed"].includes(s.state)&&s.matches(w))||I&&["preparing","ready"].includes(s.state))?s:void 0;h?X.add(h):b();let f=h&&Q(h);f?.claim();let C=Promise.resolve().then(async()=>{let t=!1,o,p,P=0,F,v,A=!1,R=()=>{},N=()=>{},L,O=!1,U=!1,k,q=!1,a=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,E=()=>{M.get(e.client)===C&&M.delete(e.client),a.removeEventListener("abort",_),R(),N(),h&&X.delete(h),f?.release()};function u(){if(k)return k;let r=new Promise(d=>k=d);return V.set(e.client,r),r.then(()=>{V.get(e.client)===r&&V.delete(e.client)}),M.get(e.client)===C&&M.delete(e.client),k}let i=J(x,e,"funnel",()=>H(),K);function _(){H()}function H(r=!1){if(!t){if(t=!0,i.finish("dismissed"),o){o.destroy();return}if(r&&L){let d=u();q=!0,L.then(async l=>{l.mode==="run"&&l.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===w?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{d(),g(e.onDismiss,null)}),E();return}E(),g(e.onDismiss,null)}}let W={destroy:()=>H(),refresh:()=>o?.refresh()??F??Promise.resolve(),get recovery(){return o?.recovery??{type:"recover",operationId:null,requestId:null}},prepareFallback:()=>o?.prepareFallback()??Promise.resolve({type:"recover",operationId:null,requestId:null}),review:(...r)=>o?.review(...r)??Promise.resolve(),exitReview:(...r)=>o?.exitReview(...r)??Promise.resolve(),get unappliedDrafts(){return o?.unappliedDrafts??new Map}};a.addEventListener("abort",_,{once:!0}),f&&(N=f.onClose(()=>{O?t||u():H(!0)}));try{a.throwIfAborted();let r=e.client.controller?.view?.paywall?.resolution,d=r&&"document"in r?r.document:e.loadingDocument;i.start(!0,w?.locale??e.client.attempt?.locale??d?.screen.strings.defaultLocale,d??null);let l=I?i.wait(I.then(n=>n?m(n):null,()=>null),z):Promise.resolve(w??null);l.catch(()=>{}),h?.state==="shown"?(U=!0,i.present(()=>{})):h&&["preparing","ready"].includes(h.state)&&Promise.all([h.ready,l.catch(()=>null)]).then(([n,c])=>{if(n){if(t||!i.active||!c||!h.matches(c)||!f?.revealable)return f?.release();i.present(()=>{h.open()==="shown"?U=!0:f.release()})}});let y=V.get(e.client);if(y&&await i.wait(y),t)return null;if(a.throwIfAborted(),I){let n=await l;if(t)return null;if(a.throwIfAborted(),!n)return i.finish("skipped"),E(),null;w=n}L=w?e.client.start(w):e.client.refresh();let D=await i.wait(L,z);return t?null:(a.throwIfAborted(),await Y(D,i))}catch(r){if(q||k?.(),t)return null;throw i.finish("error",r),E(),g(e.onError,r),r}function B(r=!1){P++;let d=o;o=void 0,p=void 0,R(),R=()=>{};let l=r?d?.retainPurchaseDialog?.():void 0;return d?.destroy(),a.addEventListener("abort",_,{once:!0}),l}function Z(r,d,l=!1){if(t||a.aborted){d?.release();return}let y=++P;o=p=ie(x,{client:e.client,signal:a,loading:i,retained:d,checking:l,locale:e.client.attempt?.locale,onCheckoutUrl:e.onCheckoutUrl,onError:e.onError,refresh:$,initialState:r,allowConfirm:e.allowNewPurchase!==!1,onDismiss(){y===P&&(t=!0,E(),g(e.onDismiss,null))}})}function $(){if(F)return F;if(t||a.aborted)return Promise.resolve();if(!p){let l=B(!0)??f?.retainPurchaseDialog?.();l?Z(e.client.recovery,l,!0):(i=J(x,e,"funnel",()=>H(),K),i.start(!0,e.client.attempt?.locale))}let r=Promise.resolve().then(async()=>{try{let l=await e.client.refresh();!t&&!a.aborted&&await Y(l,i)}catch(l){!t&&!a.aborted&&(g(e.onError,l),await Y({...e.client.recovery,mode:"blocked",status:"blocked"},i))}});F=r;let d=()=>{F===r&&(F=void 0)};return r.then(d,d),r}async function Y(r,d){let l=e.client.controller;if(r.mode==="run"&&r.status!=="blocked"&&l)return p&&B(),se(l,d?.active?d:void 0);if(r.mode==="operation"){let y=await i.wait(e.client.recoverUpgradePaywall().then(D=>((t||a.aborted)&&D?.destroy(),D)),z);if(y){if(t||a.aborted)return y.destroy(),null;let D=p?.retainPurchaseDialog()??f?.retainPurchaseDialog?.()??i.retainPurchaseDialog();p&&B(),f?.release();let n=await ne(x,{signal:a,loading:"host",start:async()=>y,checkoutNavigation:"after_confirmation",allowNewPurchase:!1,resumeCheckout:S=>e.client.continueCheckout(j,S),onError:e.onError,onDismiss:()=>{t||H()}},{retainedDialog:D,present(S){i.active?i.present(S):S(!!D)},async dismiss(){H()}});if(!n.host||t||a.aborted)return n.host?.destroy(),D?.release(),E(),null;let c=n.host;return o={destroy(){c.destroy(),E(),g(e.onDismiss,null)},refresh:async()=>{await c.refresh()},get recovery(){return c.recovery},prepareFallback:()=>c.prepareFallback(),review:async()=>{},exitReview:async()=>{},unappliedDrafts:new Map},W}}return r.purchases.length||r.status==="blocked"&&O?(p?p.update(r):Z(r,f?.retainPurchaseDialog?.()??i.retainPurchaseDialog()),W):p?(H(),null):(i.finish("skipped"),E(),(U||O)&&(t=!0,g(e.onDismiss,null)),null)}function j(r){if(a.throwIfAborted(),t)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(r):x.ownerDocument.defaultView?.location.assign(r)}async function se(r,d){a.removeEventListener("abort",_),O=!0;function l(){!t&&!a.aborted&&!A&&v&&e.client.recovery.status==="complete"&&(A=!0,g(e.onComplete,structuredClone(v)))}R(),R=e.client.subscribe(l);let y=++P,D=await ae(x,{...e,prepared:h,client:r,signal:a,checkoutNavigation:"after_confirmation",resumeCheckout:n=>e.client.continueCheckout(j,n),terminateCheckout:e.allowNewPurchase===!1?void 0:n=>e.client.terminateCheckout(n),async onCheckoutUrl(n){if(a.throwIfAborted(),t)throw new DOMException("Presentation dismissed","AbortError");let c=e.client.recovery;if((!c.actions.includes("continue_checkout")||!c.purchases.some(S=>S.type==="checkout"&&S.checkoutUrl===n))&&(c=await e.client.refresh(),a.throwIfAborted(),t))throw new DOMException("Presentation dismissed","AbortError");if(ee(c)!==n)throw new T("PURCHASE_PENDING","Checkout differs from the original recovery proof");return j(n)},async resolveOfferId(n){if(a.throwIfAborted(),t)throw new DOMException("Presentation dismissed","AbortError");let c=e.client.attempt;if(!c)throw new T("PURCHASE_PENDING","Read the original Start before selecting an offer");let S=await e.resolveOfferId?.(n,c);if(a.throwIfAborted(),t)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==c.requestId)throw new T("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return S},async resolveSubscriptionChange(n){a.throwIfAborted();let c=e.client.attempt;if(t||!c)throw new T("PURCHASE_PENDING","Read the original Start before selecting a membership");let S=await e.resolveSubscriptionChange?.(n);if(a.throwIfAborted(),t||e.client.attempt?.requestId!==c.requestId)throw new T("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting a membership");return S},onPresentationState(n){y===P&&g(e.onPresentationState,n)},onComplete(n){y===P&&(v=n,l())},onError(n){y===P&&(g(e.onError,n),n instanceof T&&(n.status===401||n.status===409&&n.reason==="STATE_CHANGED"&&n.recovery==="recover_operation")&&!a.aborted&&$().catch(c=>g(e.onError,c)))},onDismiss(n){y===P&&(t=!0,E(),k?.(),g(e.onDismiss,n))}},d);return y!==P||t||a.aborted?(D.destroy(),t||a.aborted?null:W):(o=D,W)}});return M.set(e.client,C),C}export{ye as showFunnelPurchase};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c}from"./chunk-OEUA65JK.js";import"./chunk-AFZB2AYU.js";import"./chunk-YGOXUDDF.js";import"./chunk-3LWZFXLN.js";import"./chunk-2MDJ3JE5.js";import"./chunk-RUMGXXVJ.js";import"./chunk-TSBXPDUQ.js";import"./chunk-KVIGHX2B.js";import"./chunk-VILB5M4X.js";import"./chunk-FAMPOY6L.js";import"./chunk-BBA64POP.js";import"./chunk-ZVLZLBDA.js";import"./chunk-XI2NNZBS.js";import"./chunk-YJRO7NXN.js";import"./chunk-BYHBBZIO.js";import"./chunk-LDLS2VL2.js";import"./chunk-PY3AC5KD.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.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,c}from"./chunk-AFZB2AYU.js";import"./chunk-YGOXUDDF.js";import"./chunk-3LWZFXLN.js";import"./chunk-2MDJ3JE5.js";import"./chunk-VILB5M4X.js";import"./chunk-YJRO7NXN.js";import"./chunk-PY3AC5KD.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as predictFunnelStart,c as predictedPaywallLoadingDocument,b as predictionRefusal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,b as o,c as n}from"./chunk-YGOXUDDF.js";import"./chunk-3LWZFXLN.js";import"./chunk-2MDJ3JE5.js";import"./chunk-VILB5M4X.js";import"./chunk-YJRO7NXN.js";import"./chunk-PY3AC5KD.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{e as FUNNEL_ROUTE_LIMITS,o as funnelRouteSchema,n as projectFunnelRoute};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk-EJAF6OGO.js";import"./chunk-OEUA65JK.js";import"./chunk-AFZB2AYU.js";import"./chunk-YGOXUDDF.js";import"./chunk-4CRUNNTC.js";import"./chunk-4OSW2Y67.js";import"./chunk-W32FI2A2.js";import"./chunk-ZNOVEJLM.js";import"./chunk-I643NVMZ.js";import"./chunk-7UXQJJFZ.js";import"./chunk-3LWZFXLN.js";import"./chunk-2MDJ3JE5.js";import"./chunk-UCDQJB53.js";import"./chunk-RUMGXXVJ.js";import"./chunk-CBOIDISB.js";import"./chunk-TSBXPDUQ.js";import"./chunk-KVIGHX2B.js";import"./chunk-VILB5M4X.js";import"./chunk-7LHRBNSH.js";import"./chunk-FAMPOY6L.js";import"./chunk-POX2ELNS.js";import"./chunk-BBA64POP.js";import"./chunk-ZVLZLBDA.js";import"./chunk-XI2NNZBS.js";import"./chunk-YJRO7NXN.js";import"./chunk-BYHBBZIO.js";import"./chunk-LDLS2VL2.js";import"./chunk-SLUA7ABW.js";import"./chunk-FKC7TJWM.js";import"./chunk-VGEH7B6S.js";import"./chunk-PY3AC5KD.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
|
package/dist/index.d.ts
CHANGED
|
@@ -1756,6 +1756,10 @@ declare function createFunnelPurchaseClient(input: FunnelPurchaseOptions): {
|
|
|
1756
1756
|
};
|
|
1757
1757
|
locale: string;
|
|
1758
1758
|
}): Promise<PaywallResolution>;
|
|
1759
|
+
/** Whether the last verified read can restore a pending upgrade's Paywall. */
|
|
1760
|
+
readonly canRestoreUpgradePaywall: boolean;
|
|
1761
|
+
/** Mounts an accepted upgrade in its authorized Paywall without a live Run. */
|
|
1762
|
+
recoverUpgradePaywall(): Promise<PaywallSession | null>;
|
|
1759
1763
|
start(start: FunnelPurchaseStart): Promise<FunnelPurchaseState>;
|
|
1760
1764
|
refresh: () => Promise<FunnelPurchaseState>;
|
|
1761
1765
|
confirm: () => Promise<FunnelPurchaseState>;
|
|
@@ -2295,6 +2299,7 @@ declare function showPaywall(container: HTMLElement, options: PaywallHostOptions
|
|
|
2295
2299
|
} | undefined;
|
|
2296
2300
|
} | null;
|
|
2297
2301
|
host: {
|
|
2302
|
+
readonly subscriptionUpgradeActive: boolean;
|
|
2298
2303
|
readonly observing: boolean;
|
|
2299
2304
|
readonly recovery: PaywallRecovery;
|
|
2300
2305
|
prepareFallback(): Promise<PaywallRecovery>;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as En,c as bn}from"./chunk-MVUNV5XR.js";import{a as We,c as Rn}from"./chunk-TIUD3N72.js";import{a as Ie}from"./chunk-W32FI2A2.js";import{a as pn,c as wn,d as Sn}from"./chunk-4NO6U4X6.js";import"./chunk-3ITNAFAH.js";import{a as In}from"./chunk-TM72XBM5.js";import"./chunk-2I2S5ZIH.js";import{h as mn,i as vn,k as Pn}from"./chunk-DB5S72HJ.js";import{E as Ae,d as Xe,f as Qe,g as ge,h as ve,i as Ye,w as yn}from"./chunk-3TSFGU4T.js";import"./chunk-W3B4GT74.js";import{a as ze}from"./chunk-Y2ASROJH.js";import"./chunk-TIOPNTMP.js";import"./chunk-RFWVXTZ7.js";import"./chunk-US65SQX4.js";import"./chunk-HYCLLEFU.js";import"./chunk-KSME3N3A.js";import{K as Ke}from"./chunk-LE32WTZ7.js";import"./chunk-SZZIYCXK.js";import"./chunk-IDDPWGQE.js";import{c as hn,e as gn}from"./chunk-LSHIR6QM.js";import"./chunk-OPUIFAQS.js";import"./chunk-HYX3EDZS.js";import{B as dn,C as ln,D as un,E as fn,c as an,d as sn,e as cn}from"./chunk-EGFVGCDG.js";import{A as Le,B as Be,D as He,F as qe,G as Ue,I as Ve,J as je,K as Ge,L as Je,M as Te,N as $e,z as _e}from"./chunk-YFLVGOCJ.js";import"./chunk-VILB5M4X.js";import{b as Ce}from"./chunk-FN462OVO.js";import"./chunk-FRRKTQNZ.js";import"./chunk-MQ5LJEWV.js";import"./chunk-JDIFYMSA.js";import"./chunk-TNPBYYAX.js";import"./chunk-KCN6OGYG.js";import"./chunk-PF6PRPRO.js";import{a as G}from"./chunk-ZDIWOE4Q.js";import"./chunk-FYD7CMS7.js";import{a as be,c as de}from"./chunk-J6KIN4RH.js";import"./chunk-SLUA7ABW.js";import{c as we,d as Ee}from"./chunk-GJSQZGBE.js";import"./chunk-3VUPVXAV.js";import"./chunk-B4SM2KRI.js";import{b as U}from"./chunk-XVCSRZX4.js";import{a as Z}from"./chunk-DSPLGTQI.js";import"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";var I=class extends Error{constructor(f,b=0,w=!1,h="fix_request"){super(f);this.code=f;this.status=b;this.retryable=w;this.recovery=h;this.name="MerchantBridgeError"}code;status;retryable;recovery};async function _n(n,d){if(!n.headers.get("content-type")?.split(";",1)[0].trim().match(/^application\/(?:json|[a-z0-9.+-]+\+json)$/i))throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");let f=n.body?.getReader();if(!f)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");let b=()=>{f.cancel().catch(()=>{})};d.addEventListener("abort",b,{once:!0});let w=0,h="",t=new TextDecoder("utf-8",{fatal:!0});try{for(d.throwIfAborted();;){let i=await f.read();if(d.throwIfAborted(),i.done)break;if(w+=i.value.byteLength,w>262144)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");h+=t.decode(i.value,{stream:!0})}return h+=t.decode(),JSON.parse(h)}catch(i){throw d.throwIfAborted(),i instanceof I?i:new I("MERCHANT_BRIDGE_INVALID_RESPONSE")}finally{d.removeEventListener("abort",b),await f.cancel().catch(()=>{}),f.releaseLock()}}function Tn(n){let d=qe.parse(n.origin),f=Ue.parse(n.manifest),b={projectId:n.scope.projectId,environmentId:n.scope.environmentId,environment:n.scope.environment};for(let m of["projectId","environmentId","environment"])if(f[m]!==n.scope[m])throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");let w=n.customerId===void 0?null:U.uuid().parse(n.customerId),h=0,t=null,i=null,u=new AbortController,y=n.fetch??globalThis.fetch;async function P(m,s,E,_,O){if(!f.capabilities.includes(m))throw new I("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let S=He[m];if(["merchant_catalog_reader","merchant_refund_authority","indiana_server_key"].includes(S.authority))throw new I("MERCHANT_BRIDGE_FORBIDDEN",403);let l=h,o=AbortSignal.any([u.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],..._?[_]:[]]);o.throwIfAborted();let T=new Headers(await n.headers?.());if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(/\bgg_(?:sk|ct|rt)_/.test(T.get("authorization")??"")||T.has("X-Indiana-Bridge-Signature")||T.has("X-Indiana-Bridge-Key-Id"))throw new I("MERCHANT_BRIDGE_FORBIDDEN",403);T.set(Be,String(_e)),T.set("Accept","application/json");let g=crypto.randomUUID();T.set("X-Request-Id",g),T.set("Content-Type","application/json");let M=await y(d+Le,{method:"POST",credentials:"include",redirect:"error",cache:"no-store",headers:T,signal:o,body:JSON.stringify({bridgeVersion:_e,requestId:g,command:S.command,scope:b,data:O??(E===void 0?{}:{operationId:E})})}),J=await _n(M,o);if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(!M.ok){let N=$e.safeParse(J);throw!N.success||N.data.scope.projectId!==n.scope.projectId||N.data.scope.environment!==n.scope.environment||N.data.scope.environmentId!==n.scope.environmentId||N.data.requestId!==g||N.data.command!==S.command?new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status):new I(N.data.error.code,M.status,N.data.error.retryable,N.data.error.recovery)}let c=Ve(U.unknown()).safeParse(J);if(!c.success||c.data.scope.projectId!==n.scope.projectId||c.data.scope.environment!==n.scope.environment||c.data.scope.environmentId!==n.scope.environmentId||c.data.requestId!==g||c.data.command!==S.command)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status);let $=s.safeParse(c.data.data);if(!$.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status);return $.data}function R(){if(!w)throw new I("MERCHANT_BRIDGE_UNAUTHENTICATED",401);return w}async function B(m,s,E,_){let O=R();if(_!==void 0&&Te.parse({operationId:_,customerId:O}),!f.capabilities.includes(m))throw new I("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let S=h,l=AbortSignal.any([u.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...s?[s]:[]]);l.throwIfAborted();let o,T=new Promise((g,M)=>{o=()=>M(l.reason),l.addEventListener("abort",o,{once:!0})});try{let M=E(async()=>{let c=await import("./merchant-bridge-contracts-7EHDNPJJ.js");if(l.throwIfAborted(),S!==h||w!==O)throw new DOMException("Merchant identity changed","AbortError");return c},l),J=await Promise.race([M,T]);return l.throwIfAborted(),J}finally{l.removeEventListener("abort",o)}}async function z(m,s,E,_){let O=R(),S=Te.parse({operationId:E,customerId:O}),l=await P(m,s,S.operationId,_,S);if(l.customerId!==O||l.operationId!==S.operationId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return l}return{async readPresentation(m){let s=await P("presentation",Ge,void 0,m);if(i!==null&&i!==s.nativeUserId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(s.presentation&&w!==null&&s.presentation.customerId!==w)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return i=s.nativeUserId,t=s.presentation,s},async createSession(m){let s=await P("session",je,void 0,m);if(i!==null&&i!==s.nativeUserId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(w!==null&&w!==s.session.customerId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(t&&t.customerId!==s.session.customerId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return w=s.session.customerId,i=s.nativeUserId,s.session},async reportPresentation(m,s){let E=R(),_=Je.parse(m);if(!t||t.customerId!==E||t.decisionId!==_.decisionId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return P("presentation_events",U.strictObject({queued:U.literal(!0)}),void 0,s,_)},async readCustomerCommerce(m){let s=R(),E=await B("customer_commerce",m,async(_,O)=>{let[S,l]=await Promise.all([_(),P("customer_commerce",U.unknown(),void 0,O)]),o=S.merchantBridgeCommerceSchema.safeParse(l);if(!o.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return o.data});if(E.customerId!==s)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return E},async executePurchase(m,s){let E=await B("purchases",s,async(_,O)=>z("purchases",(await _()).merchantBridgeOperationSchema,m,O),m);if(E.type!=="purchase")throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return E},readOperation:(m,s)=>B("operation_status",s,async(E,_)=>z("operation_status",(await E()).merchantOperationLookupSchema,m,_),m),async executeSubscriptionChange(m,s){let E=await B("subscription_changes",s,async(_,O)=>z("subscription_changes",(await _()).merchantBridgeOperationSchema,m,O),m);if(E.type!=="subscription_change")throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return E},reset(){h++,u.abort(),u=new AbortController,w=null,t=null,i=null}}}var en=U.strictObject({command:ve,target:Qe,runId:U.uuid().optional(),expiresAt:U.iso.datetime({offset:!0}).optional(),deliveryLimit:U.number().int().min(1).max(100).optional()}).refine(n=>n.command.release===n.target.release),Ze=U.strictObject({schemaVersion:U.literal(1),entries:U.array(en).max(4e3)});function nn(n){let d=!1,f=()=>{d||n.unavailable(),d=!0};function b(){return n.storage===!1?void 0:n.storage??globalThis.sessionStorage}function w(t){let i=b()?.getItem(t);if(!i)return[];if(i.length>1048576)throw Error("Entry recovery is too large");return Ze.parse(JSON.parse(i)).entries}function h(t,i){let u=b();if(!u)return;if(!i.length)return u.removeItem(t);let y=JSON.stringify(Ze.parse({schemaVersion:1,entries:i}));if(y.length>1048576)throw Error("Entry recovery is too large");u.setItem(t,y)}return{load(){try{let t=n.binding();if(!t||n.storage===!1)return;let i="indiana.funnel.entries.v1."+JSON.stringify(t);return{key:i,entries:w(i)}}catch{f();return}},retain(t,i){if(t)try{let u=en.parse(i);h(t,[...w(t).filter(y=>y.command.funnelId!==u.command.funnelId),u])}catch{f()}},forget(t,i){if(t)try{h(t,w(t).filter(u=>u.command.requestId!==i))}catch{f()}}}}var tn=U.strictObject({version:U.literal(1),runs:U.array(U.uuid()).max(100)}),De=new WeakMap,Oe=new WeakMap;function Se(n){let d=!1;function f(){d||n.unavailable(),d=!0}function b(t){let i=t.storage.getItem(t.key);if(!i)return[];if(i.length>8192)throw Error("Invalid entry delivery record");return tn.parse(JSON.parse(i)).runs}function w(t){let i=De.get(t.storage);i||De.set(t.storage,i=new Map);let u=i.get(t.key);return u||i.set(t.key,u=new Set),u}function h(t){if(!t)return;let i=De.get(t.storage),u=i?.get(t.key);u?.delete(t.requestId),u?.size===0&&i?.delete(t.key)}return{claim(t,i,u,y,P=!1){if(u!==void 0)try{let R=n.binding();if(!R)throw Error("Entry delivery identity is unavailable");let B={storage:n.storage??globalThis.sessionStorage,key:"indiana.funnel.delivery.v1."+JSON.stringify([...R,i,t]),requestId:y},z=b(B);if(Oe.get(B.storage)?.has(B.key))throw Error("Entry delivery storage is unavailable");B.storage.setItem(B.key,JSON.stringify({version:1,runs:z}));let m=w(B);return!P&&!m.has(y)&&z.length+m.size>=u?!1:(m.add(y),B)}catch{return f(),!1}},accept(t,i){if(t)try{let u=b(t);u.includes(i)||t.storage.setItem(t.key,JSON.stringify(tn.parse({version:1,runs:[...u,i].slice(-100)})))}catch{let u=Oe.get(t.storage);u||Oe.set(t.storage,u=new Set),u.add(t.key),f()}finally{h(t)}},release:h}}function Pe(){let n,d,f=()=>{clearTimeout(n),n=void 0;let b=d;d=void 0,b?.cancelled()};return{get active(){return d!==void 0},start(b,w,h,t){if(d)return;if(b===0){w()?h():t();return}let i={valid:w,cancelled:t};d=i,n=setTimeout(()=>{d===i&&(d=void 0,n=void 0,w()?h():t())},b*1e3)},recheck(){d&&!d.valid()&&f()},cancel:f}}var Re=n=>["running","waiting"].includes(n.status)&&!n.pendingRequest&&(n.stopped||!n.screen&&!n.paywall&&n.instruction?.type==="wait"&&n.instruction.kind!=="operation");function Cn(n){let d=we(n.baseUrl),f=n.scope,b=Ce(n),w=n.fetch??globalThis.fetch.bind(globalThis),h,t=!1,i=!1,u=0,y=0,P="",R=0,B=0,z=0,m=!1,s,E=!0,_,O,S,l,o,T=-1,g,M=e=>{g===e&&(N.release(e.deliveryTicket),g=void 0,x())},J=new Set,c=(e,a)=>Z(n.onStatus,e,a),$=Pe(),N=Se({storage:n.deliveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[d,f.projectId,f.environment,n.environmentId,"customer",e]:void 0},unavailable:()=>c("delivery_unavailable")}),ee=new Set,te=nn({storage:n.recoveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[d,f.projectId,f.environment,n.environmentId,n.appManifestRelease,e]:void 0},unavailable:()=>c("recovery_unavailable")}),Y=e=>te.forget(e.storageKey,e.command.requestId);function Q(e,a){a&&(e.runId=a.id,e.expiresAt=a.runExpiresAt),te.retain(e.storageKey,{command:e.command,target:e.target,...e.runId&&{runId:e.runId},...e.expiresAt&&{expiresAt:e.expiresAt},...e.deliveryLimit!==void 0&&{deliveryLimit:e.deliveryLimit}})}function re(){let e=o;o=void 0,e?.host.destroy(),e?.slot.remove(),e?.client.reset(),x()}let le=()=>$.active||g!==void 0||o!==void 0&&!o.background;function me(e,a){if(o?.client!==e)return;Q(o.recovery,a);let p=Re(a);o.slot.hidden=p,p!==o.background&&(o.background=p,p?c("run_background",o.entryId):T=y,x())}function pe(e,a,p){let v=e.client.view;if(!a||e.background||!v?.screen||v.paywall||v.pendingRequest||v.stopped||v.status!=="waiting")return;let K=Ke.parse({operation:"close",requestId:crypto.randomUUID(),nodeId:v.nodeId,visit:v.visit,revision:v.revision,customerToken:a}),j=Ce({...n,session:void 0});j.requestWithCredential("funnels",K,e.runToken,{keepalive:p}).then(()=>Y(e.recovery)).catch(()=>{}).finally(()=>j.dispose())}let ae=()=>{o&&pe(o,n.session.peek(),!0)},r=()=>Date.now()<B&&performance.now()<z;function C(e){if(e.target.release!==n.appManifestRelease||!r())return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return c("incompatible",e.id),!1}}function H(e){if(t||e.epoch!==R||e.visit!==y||document.visibilityState==="hidden")return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function W(e){if(le()){c("in_progress",e.id);return}let a=R,p=y;$.start(e.delivery?.delaySeconds??0,()=>!t&&a===R&&p===y&&document.visibilityState!=="hidden"&&C(e)&&h?.entries.some(v=>v.id===e.id&&v.funnelId===e.funnelId&&v.versionId===e.versionId&&v.event===e.event&&JSON.stringify(v.target)===JSON.stringify(e.target)&&JSON.stringify(v.delivery)===JSON.stringify(e.delivery))===!0,()=>{V(e)},()=>{J.delete(`${e.funnelId}:${e.id}`)})}async function V(e){if(le()){c("in_progress",e.id);return}if(!n.session.peek()){c("identity_required",e.id);return}let a=te.load(),p=a?.entries.find(A=>A.command.funnelId===e.funnelId&&(!A.expiresAt||Date.parse(A.expiresAt)>Date.now()));if(p){if(!X(p)){c("recovery_pending",e.id);return}let A={...p,storageKey:a.key,epoch:R,visit:y};ee.add(A.command.requestId),g=A,await F(A);return}let v=crypto.randomUUID(),K=N.claim(e.id,e.funnelId,e.delivery?.maxPerSession,v);if(K===!1){c("frequency",e.id),x();return}let j={freshStart:!0,deliveryLimit:e.delivery?.maxPerSession,deliveryTicket:K,command:ve.parse({operation:"entry_start",entryId:e.id,funnelId:e.funnelId,versionId:e.versionId,release:n.appManifestRelease,requestId:v,locale:document.documentElement.lang||"en"}),epoch:R,visit:y,target:e.target,storageKey:a?.key};ee.add(j.command.requestId),g=j,await F(j)}async function F(e){if(e.dispatching)return;e.dispatching=!0;let a=e.freshStart===!0;e.freshStart=!1;let p,v=!1,K=!1;async function j(A){if(e.epoch!==R)return;let D=A.view;if(!(e.storageKey&&D&&(Re(D)||D.paywall||D.pendingRequest))&&D&&["running","waiting"].includes(D.status))try{await A.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:D.nodeId,visit:D.visit,revision:D.revision}),Y(e)}catch(k){if(!(k instanceof G&&k.code==="FORBIDDEN"))throw k}}try{if(!e.deliveryTicket&&e.deliveryLimit!==void 0){let q=N.claim(e.command.entryId,e.command.funnelId,e.deliveryLimit,e.command.requestId,!0);q!==!1&&(e.deliveryTicket=q)}Q(e),c("starting",e.command.entryId);let A=await b.request("funnels",e.command),D=Ye.safeParse(A);if(D.success){if(D.data.scope.projectId!==f.projectId||D.data.scope.environment!==f.environment)throw new G("SCOPE_MISMATCH","Entry scope changed");e.epoch===R&&c(D.data.reason,e.command.entryId),Y(e),M(e);return}let k=Xe.parse(A);if(!k.runToken||k.scope.projectId!==f.projectId||k.scope.environment!==f.environment||k.run.source.type!=="funnel"||k.run.source.id!==e.command.funnelId||k.run.source.versionId!==e.command.versionId||e.runId!==void 0&&k.run.id!==e.runId)throw new G("INVALID_RESPONSE","Invalid entry Run");if(N.accept(e.deliveryTicket,k.run.id),e.epoch!==R){M(e),c("identity_changed",e.command.entryId);return}Q(e,k.run);let L=Ae({...n,runToken:k.runToken,funnelId:e.command.funnelId,initialResponse:a?A:void 0});p=L,K=!0,await L.get(),K=!1;let ne=L.view;if(!ne||ne.id!==k.run.id||ne.source.type!=="funnel"||ne.source.id!==e.command.funnelId||ne.source.versionId!==e.command.versionId)throw new G("INVALID_RESPONSE","Entry Run version changed");if(!["running","waiting"].includes(ne.status)){Y(e),M(e),c("run_ended",e.command.entryId);return}let{showFunnelRun:fe}=await import("./funnel-runtime-host-NZAV6C5O.js");if(!H(e)){await j(L),c("left_screen",e.command.entryId),M(e);return}let Fe=!1,xe=!1;if(o&&!o.background){await j(L),c("in_progress",e.command.entryId),M(e);return}o&&re();let ie=document.createElement("div");ie.hidden=Re(ne),n.container.append(ie);let ke=await fe(ie,{...n.host,client:L,appManifestRelease:n.appManifestRelease,onState(q){me(L,q),Z(n.host?.onState,q)},onDismiss(q){Fe=!0,ie.remove(),q&&!["running","waiting"].includes(q.status)&&Y(e),o?.client===L&&(o=void 0,L.reset(),x(),q&&q.status!=="completed"&&c("run_ended",e.command.entryId)),Z(n.host?.onDismiss,q)},onComplete(q){xe=!0,Y(e),o?.client===L&&re(),Z(n.host?.onComplete,q)},onError(q){Z(n.host?.onError,q),o?.client===L&&q instanceof G&&q.code==="FORBIDDEN"&&(Y(e),re(),c("run_ended",e.command.entryId))}}).catch(q=>{throw ie.remove(),q});if(!H(e)||Fe||xe){ke.destroy(),ie.remove(),H(e)||await j(L),M(e);return}let he=Re(L.view??ne);ie.hidden=he,o={host:ke,client:L,slot:ie,entryId:e.command.entryId,background:he,runToken:k.runToken,owner:n.session.peek(),recovery:e},he||(T=e.visit),v=!0,M(e),c("started",e.command.entryId),he&&c("run_background",e.command.entryId)}catch(A){A instanceof G&&(!p||K&&A.code==="FORBIDDEN")&&A.status!==void 0&&A.status>=400&&A.status<500&&!A.retryable&&(Y(e),M(e)),e.epoch===R&&!t&&(c("start_failed",e.command.entryId),Z(n.host?.onError,A))}finally{v||p?.reset(),e.dispatching=!1}}function X(e){if(e.command.release!==n.appManifestRelease||e.target.release!==n.appManifestRelease)return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function ye(){if(le())return!1;let e=te.load();for(let a of e?.entries??[]){if(a.expiresAt&&Date.parse(a.expiresAt)<=Date.now()){te.forget(e.key,a.command.requestId);continue}if(a.command.requestId===o?.recovery.command.requestId||ee.has(a.command.requestId)||!X(a))continue;ee.add(a.command.requestId);let p={...a,storageKey:e.key,epoch:R,visit:y};return g=p,F(p),!0}return!1}function ue(){if(m=!1,$.recheck(),t||!i||document.visibilityState==="hidden")return;se();let e=o!==void 0&&!o.background;if(e&&(T=y),!ye()){if(!r()){E=!0;return}E=!1;for(let a of h?.entries??[]){let p=`${a.funnelId}:${a.id}`;if(!(a.event!=="screen_enter"||J.has(p)||!C(a))){if(!n.session.peek()){c("identity_required",a.id);continue}if(T===y){J.add(p),e&&c("in_progress",a.id);continue}if(g||$.active){c("in_progress",a.id);return}J.add(p),W(a);break}}}}let x=()=>{!m&&!t&&(m=!0,queueMicrotask(ue))};function se(){let e=location.origin+location.pathname;return e===P?!1:(P=e,y++,$.cancel(),E=!0,J.clear(),ee.clear(),!0)}function oe(){se()&&x()}function ce(e){if(!e.isTrusted||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||document.visibilityState==="hidden")return;let a=e.target;if(!(a instanceof Element)||a.closest("[data-indiana-funnel]"))return;let p=a.closest("button,a,input");if(!(!p||p.matches(":disabled,[aria-disabled='true']")||p.closest("[hidden],[inert],[aria-hidden='true']")))for(let v of h?.entries??[]){let K=v.target.button;if(!(v.event!=="button_click"||!K||!C(v))){try{let j=be(document);if(!p.matches(K.selector)||j(K.selector,p)!==1)continue}catch{c("incompatible",v.id);continue}W(v);break}}}async function Me(){if(t)return;if(s)return s;let e=++u,a=new AbortController;_=a;let p,v=new Promise((A,D)=>{p=()=>D(new G("TIMEOUT","Funnel entry configuration read cancelled or timed out")),a.signal.addEventListener("abort",p,{once:!0})}),K=setTimeout(()=>a.abort(),n.timeoutMs??5e3),j=(async()=>{let A=async()=>{let fe=await w(`${d}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:a.signal});if(!fe.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",fe.status);return ge.parse(await fe.json())},D=await Promise.race([A(),v]),k=Date.parse(D.validatedAt),L=Date.parse(D.validUntil);if(D.scope.projectId!==f.projectId||D.scope.environment!==f.environment||D.scope.environmentId!==n.environmentId||D.release!==n.appManifestRelease||L<=Date.now()||k>Date.now()+5e3||L-k>6e4||L<=k)throw new G("INVALID_RESPONSE","Entry configuration scope or deadline changed");if(t||e!==u)return;let ne=h===void 0;h=D,B=L,z=performance.now()+Math.min(L-Date.now(),6e4),$.recheck(),(ne||E)&&x()})();s=j;try{await j}finally{clearTimeout(K),a.signal.removeEventListener("abort",p),s===j&&(s=void 0)}}async function on(){if(!(!i||t)){try{await Me()}catch{t||c("configuration_unavailable")}x()}}let Ne=Ie({document,run:on,delay:()=>i&&!t?15e3:void 0});return{async start(){i||t||(i=!0,P=location.origin+location.pathname,O=Ee(oe),S=n.session.subscribeIdentity(()=>{R++,$.cancel(),N.release(g?.deliveryTicket),E=!0,g=void 0,J.clear(),T=-1,ee.clear(),o&&pe(o,o.owner,!1),re(),x()}),l=new MutationObserver(x),l.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",ce,!0),document.addEventListener("visibilitychange",x),addEventListener("pagehide",ae),await Ne.refresh())},refresh:Me,async retry(){g&&!t&&g.epoch===R&&await F(g)},destroy(){t=!0,u++,$.cancel(),N.release(g?.deliveryTicket),Ne.destroy(),_?.abort(),l?.disconnect(),O?.(),S?.(),document.removeEventListener("click",ce,!0),document.removeEventListener("visibilitychange",x),removeEventListener("pagehide",ae),ae(),re(),b.dispose(),h=void 0}}}function An(n){let d=we(n.baseUrl),f=n.fetch??globalThis.fetch.bind(globalThis),b,w=0,h=0,t=!1,i=!1,u=!1,y=0,P=0,R=-1,B=!1,z="",m,s,E,_,O=new Set,S,l,o,T=(r,C)=>Z(n.onStatus,r,C),g=Pe(),M=()=>{try{return n.deliveryIdentity?.()}catch{return}},J=()=>JSON.stringify(M()),c=Se({storage:n.deliveryStorage,binding:()=>{let r=M();return r?.id?[d,n.scope.projectId,n.scope.environment,n.environmentId,r.type,r.id]:void 0},unavailable:()=>T("delivery_unavailable")}),$=()=>Date.now()<w&&performance.now()<h;function N(r){try{return $()&&r.target.release===n.appManifestRelease&&de(r.target.render,document,location.pathname,()=>{})}catch{return T("incompatible",r.id),!1}}function ee(){let r=o;o=void 0,r?.host.destroy(),r?.slot.remove()}async function te(r){if(r.dispatching)return;r.dispatching=!0;let C=y;try{let H=await r.process.open({operation:"entry_start",funnelId:r.entry.funnelId,versionId:r.entry.versionId,entryId:r.entry.id,release:n.appManifestRelease,locale:n.locale??"en"});c.accept(r.deliveryTicket,H.run.id);let{showFunnelRun:W}=await import("./funnel-runtime-host-NZAV6C5O.js");if(t||C!==y||l!==r)return;let V=document.createElement("div");n.container.append(V),R=P;let F=await W(V,{...n.host,client:H.controller,appManifestRelease:n.appManifestRelease,onDismiss(X){o?.process===r.process&&(o=void 0,V.remove()),Z(n.host?.onDismiss,X)}});if(t||C!==y||l!==r){F.destroy(),V.remove();return}o={entry:r.entry,process:r.process,host:F,slot:V,deliveryTicket:r.deliveryTicket},l=void 0,T("run_presented",r.entry.id)}catch(H){if(t||C!==y||l!==r)return;H instanceof G&&"result"in H?(c.release(r.deliveryTicket),l=void 0,r.process.destroy(),T("suppressed",r.entry.id),Q()):T("entry_unavailable",r.entry.id)}finally{r.dispatching=!1}}function Y(r){if(t||i||l||o||S||g.active||R===P||!N(r))return;let C=`${P}:${r.id}`;if(O.has(C))return;O.add(C);let H=P,W=y,V=J();g.start(r.delivery?.delaySeconds??0,()=>!t&&y===W&&P===H&&J()===V&&document.visibilityState!=="hidden"&&N(r)&&b?.entries.some(F=>F.id===r.id&&F.funnelId===r.funnelId&&F.versionId===r.versionId&&F.event===r.event&&JSON.stringify(F.target)===JSON.stringify(r.target)&&JSON.stringify(F.delivery)===JSON.stringify(r.delivery))===!0,()=>{let F=c.claim(r.id,r.funnelId,r.delivery?.maxPerSession,crypto.randomUUID());if(F===!1){T("frequency",r.id),Q();return}try{let X={entry:r,process:n.createProcess(r),visit:P,deliveryTicket:F};l=X,te(X)}catch(X){c.release(F),T("entry_unavailable",r.id),Z(n.host?.onError,X)}},()=>{O.delete(C)})}function Q(){B||t||(B=!0,queueMicrotask(()=>{if(B=!1,g.recheck(),!(t||i||document.visibilityState==="hidden"||!$()||l||o||S||g.active||R===P)){for(let r of b?.entries??[])if(r.event==="screen_enter"&&!O.has(`${P}:${r.id}`)&&N(r)){Y(r);break}}}))}function re(r){if(!r.isTrusted||r.defaultPrevented||!(r.target instanceof Element)||l||o||S||R===P)return;let C=be(document,()=>{});for(let H of b?.entries??[]){let W=H.target.button;if(H.event!=="button_click"||!W||!N(H))continue;let V=r.target.closest(W.selector);if(!(!V||V.tagName.toLowerCase()!==W.tag||C(W.selector)!==1||V.matches(":disabled")||V.closest('[inert],[hidden],[aria-hidden="true"]'))){Y(H);break}}}let le=()=>{let r=location.origin+location.pathname;r!==z&&(z=r,P++,g.cancel(),O.clear(),Q())};async function me(){if(t)return;if(s)return s;let r=y,C=new AbortController;m=C;let H,W=new Promise((ye,ue)=>{H=ue}),V=()=>H(new G("TIMEOUT","Funnel entry read cancelled"));C.signal.addEventListener("abort",V,{once:!0});let F=setTimeout(()=>C.abort(),n.timeoutMs??5e3),X=(async()=>{let ye=encodeURIComponent(JSON.stringify(["funnel-process/1"])),ue=async()=>{let ce=await f(`${d}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}&executionContracts=${ye}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:C.signal});if(!ce.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",ce.status);return ge.parse(await ce.json())},x=await Promise.race([ue(),W]),se=Date.parse(x.validatedAt),oe=Date.parse(x.validUntil);if(x.scope.projectId!==n.scope.projectId||x.scope.environment!==n.scope.environment||x.scope.environmentId!==n.environmentId||x.release!==n.appManifestRelease||oe<=Date.now()||se>Date.now()+5e3||oe<=se||oe-se>6e4)throw new G("INVALID_RESPONSE","Entry scope or deadline changed");t||r!==y||(b=x,w=oe,h=performance.now()+Math.min(oe-Date.now(),6e4),g.recheck(),Q())})();s=X;try{await X}finally{clearTimeout(F),C.signal.removeEventListener("abort",V),s===X&&(s=void 0)}}async function pe(){if(!(!u||t))try{await me()}catch{t||T("configuration_unavailable")}}let ae=Ie({document,run:pe,delay:()=>u&&!t?15e3:void 0});return{async start(){u||t||(u=!0,z=location.origin+location.pathname,E=Ee(le),_=new MutationObserver(Q),_.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",re,!0),document.addEventListener("visibilitychange",Q),await ae.refresh())},refresh:me,async retry(){l&&!t&&await te(l)},async syncIdentity(){g.cancel();let r=o??l??S;if(!r){i=!1,Q();return}try{let C=await r.process.syncIdentity();return i=!1,S===r&&(l={...r,visit:P},S=void 0,await te(l)),C}catch(C){throw r.process.view||(S={...r,visit:P},l=void 0,ee()),C}},async detach(){i=!0,y++,g.cancel(),m?.abort();let r=o??l??S;r&&(S={...r,visit:P}),l=void 0,ee(),r&&await r.process.detach()},destroy(){t=!0,y++,g.cancel(),ae.destroy(),m?.abort(),_?.disconnect(),E?.(),document.removeEventListener("click",re,!0),document.removeEventListener("visibilitychange",Q);let r=o??l??S;c.release(r?.deliveryTicket),l=void 0,S=void 0,ee(),r?.process.destroy(),b=void 0}}}async function Dn(n,d){return(await import("./paywall-DKTGQZDJ.js")).showPaywall(n,d)}async function dt(){return await Promise.all([import("./paywall-DKTGQZDJ.js"),import("./screen-renderer-HW2WXDTR.js")]),Dn}async function lt(...n){return n[1]=ze(n[1]),(await import("./paywall-session-YKE2CHHI.js")).createPaywallSession(...n)}async function ut(...n){let d=n[1].signal?.aborted?void 0:We(n[1].client);try{return import("./screen-renderer-HW2WXDTR.js").catch(()=>{}),import("./paywall-DKTGQZDJ.js").catch(()=>{}),await(await rn(()=>import("./funnel-runtime-host-NZAV6C5O.js"),n[1].prepared)).showFunnelRun(...n)}finally{d?.()}}async function rn(n,d){try{return await n()}catch(f){throw d&&d.state!=="adopted"&&await import("./funnel-paywall-prerender-MD4UI2AP.js").then(b=>b.preparedInternals(d)?.release(),()=>{}),f}}async function ft(...n){return import("./screen-renderer-HW2WXDTR.js").catch(()=>{}),import("./paywall-DKTGQZDJ.js").catch(()=>{}),(await rn(()=>import("./funnel-host-purchase-HBQOWEES.js"),n[1].prepared)).showFunnelPurchase(...n)}async function mt(...n){return import("./funnel-host-purchase-HBQOWEES.js").catch(()=>{}),import("./screen-renderer-HW2WXDTR.js").catch(()=>{}),(await import("./funnel-paywall-prerender-MD4UI2AP.js")).prerenderFunnelPurchase(...n)}async function pt(){await Promise.all([import("./funnel-paywall-prerender-MD4UI2AP.js"),import("./funnel-host-purchase-HBQOWEES.js"),import("./paywall-DKTGQZDJ.js"),import("./screen-renderer-HW2WXDTR.js"),import("./paywall-content-SML4CL2Q.js"),import("./check-response-MCT5RGOM.js"),import("./operation-contracts-C6CMAO6S.js")])}async function yt(...n){return(await import("./funnel-route-prediction-XNIKDJIM.js")).predictFunnelStart(...n)}async function ht(...n){return(await import("./funnel-route-prediction-XNIKDJIM.js")).predictedPaywallLoadingDocument(...n)}async function gt(...n){return(await import("./content-VTHRQSFT.js")).mountContent(...n)}async function vt(...n){return(await import("./content-VTHRQSFT.js")).prepareContent(...n)}export{G as LongplayError,I as MerchantBridgeError,yn as createBrowserFunnelCommandStorage,En as createBrowserFunnelPurchaseStorage,vn as createConfigurationSync,mn as createFeatureClient,wn as createFunnelClient,Rn as createFunnelPageExperiments,Sn as createFunnelProcess,bn as createFunnelPurchaseClient,Ae as createFunnelRunController,Cn as createIamFunnelEntries,An as createIamFunnelProcessEntries,Pn as createLocalFunnelClient,pn as createLongplay,Tn as createMerchantBridge,lt as createPaywallSession,In as evaluateFunnelNode,sn as formatCouponDiscount,an as formatCouponMoney,cn as formatCouponTerms,hn as getPaywallRecovery,un as isPaywallOperationComplete,fn as isPaywallOperationPending,ln as isPaywallUpdateOperation,dn as isPaywallUpdateQuote,gt as mountContent,yt as predictFunnelStart,ht as predictedPaywallLoadingDocument,pt as preloadFunnelPurchase,dt as preloadPaywall,vt as prepareContent,gn as preparePaywallFallback,mt as prerenderFunnelPurchase,ft as showFunnelPurchase,ut as showFunnelRun,Dn as showPaywall};
|
|
1
|
+
import{a as En,c as bn}from"./chunk-ZY4YDPSI.js";import{a as We,c as Rn}from"./chunk-4OSW2Y67.js";import{a as Ie}from"./chunk-W32FI2A2.js";import{a as pn,c as wn,d as Sn}from"./chunk-DJYLJBU2.js";import"./chunk-7Q25R5GL.js";import{a as In}from"./chunk-L66EXWTK.js";import"./chunk-USM6HOXG.js";import{h as mn,i as vn,k as Pn}from"./chunk-W3V7DTPC.js";import{E as Ae,d as Xe,f as Qe,g as ge,h as ve,i as Ye,w as yn}from"./chunk-XO6GV6O7.js";import"./chunk-I643NVMZ.js";import{a as ze}from"./chunk-K644WUOE.js";import"./chunk-3TV3CVNP.js";import"./chunk-S4YBFFFY.js";import"./chunk-AN7CPDBU.js";import"./chunk-PGZZKX5K.js";import"./chunk-CJUVMNDB.js";import{K as Ke}from"./chunk-7UXQJJFZ.js";import"./chunk-3LWZFXLN.js";import"./chunk-2MDJ3JE5.js";import{c as hn,e as gn}from"./chunk-UCDQJB53.js";import"./chunk-RUMGXXVJ.js";import"./chunk-CBOIDISB.js";import{B as dn,C as ln,D as un,E as fn,c as an,d as sn,e as cn}from"./chunk-TSBXPDUQ.js";import{A as Le,B as Be,D as He,F as qe,G as Ue,I as Ve,J as je,K as Ge,L as Je,M as Te,N as $e,z as _e}from"./chunk-KVIGHX2B.js";import"./chunk-VILB5M4X.js";import{b as Ce}from"./chunk-7LHRBNSH.js";import"./chunk-FAMPOY6L.js";import"./chunk-POX2ELNS.js";import"./chunk-BBA64POP.js";import"./chunk-ZVLZLBDA.js";import"./chunk-XI2NNZBS.js";import"./chunk-YJRO7NXN.js";import{a as G}from"./chunk-BYHBBZIO.js";import"./chunk-LDLS2VL2.js";import{a as be,c as de}from"./chunk-J6KIN4RH.js";import"./chunk-SLUA7ABW.js";import{c as we,d as Ee}from"./chunk-FKC7TJWM.js";import"./chunk-3VUPVXAV.js";import"./chunk-VGEH7B6S.js";import{b as U}from"./chunk-PY3AC5KD.js";import{a as Z}from"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var I=class extends Error{constructor(f,b=0,w=!1,h="fix_request"){super(f);this.code=f;this.status=b;this.retryable=w;this.recovery=h;this.name="MerchantBridgeError"}code;status;retryable;recovery};async function _n(n,d){if(!n.headers.get("content-type")?.split(";",1)[0].trim().match(/^application\/(?:json|[a-z0-9.+-]+\+json)$/i))throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");let f=n.body?.getReader();if(!f)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");let b=()=>{f.cancel().catch(()=>{})};d.addEventListener("abort",b,{once:!0});let w=0,h="",t=new TextDecoder("utf-8",{fatal:!0});try{for(d.throwIfAborted();;){let i=await f.read();if(d.throwIfAborted(),i.done)break;if(w+=i.value.byteLength,w>262144)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");h+=t.decode(i.value,{stream:!0})}return h+=t.decode(),JSON.parse(h)}catch(i){throw d.throwIfAborted(),i instanceof I?i:new I("MERCHANT_BRIDGE_INVALID_RESPONSE")}finally{d.removeEventListener("abort",b),await f.cancel().catch(()=>{}),f.releaseLock()}}function Tn(n){let d=qe.parse(n.origin),f=Ue.parse(n.manifest),b={projectId:n.scope.projectId,environmentId:n.scope.environmentId,environment:n.scope.environment};for(let m of["projectId","environmentId","environment"])if(f[m]!==n.scope[m])throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");let w=n.customerId===void 0?null:U.uuid().parse(n.customerId),h=0,t=null,i=null,u=new AbortController,y=n.fetch??globalThis.fetch;async function P(m,s,E,_,O){if(!f.capabilities.includes(m))throw new I("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let S=He[m];if(["merchant_catalog_reader","merchant_refund_authority","indiana_server_key"].includes(S.authority))throw new I("MERCHANT_BRIDGE_FORBIDDEN",403);let l=h,o=AbortSignal.any([u.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],..._?[_]:[]]);o.throwIfAborted();let T=new Headers(await n.headers?.());if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(/\bgg_(?:sk|ct|rt)_/.test(T.get("authorization")??"")||T.has("X-Indiana-Bridge-Signature")||T.has("X-Indiana-Bridge-Key-Id"))throw new I("MERCHANT_BRIDGE_FORBIDDEN",403);T.set(Be,String(_e)),T.set("Accept","application/json");let g=crypto.randomUUID();T.set("X-Request-Id",g),T.set("Content-Type","application/json");let M=await y(d+Le,{method:"POST",credentials:"include",redirect:"error",cache:"no-store",headers:T,signal:o,body:JSON.stringify({bridgeVersion:_e,requestId:g,command:S.command,scope:b,data:O??(E===void 0?{}:{operationId:E})})}),J=await _n(M,o);if(o.throwIfAborted(),l!==h)throw new DOMException("Merchant identity changed","AbortError");if(!M.ok){let N=$e.safeParse(J);throw!N.success||N.data.scope.projectId!==n.scope.projectId||N.data.scope.environment!==n.scope.environment||N.data.scope.environmentId!==n.scope.environmentId||N.data.requestId!==g||N.data.command!==S.command?new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status):new I(N.data.error.code,M.status,N.data.error.retryable,N.data.error.recovery)}let c=Ve(U.unknown()).safeParse(J);if(!c.success||c.data.scope.projectId!==n.scope.projectId||c.data.scope.environment!==n.scope.environment||c.data.scope.environmentId!==n.scope.environmentId||c.data.requestId!==g||c.data.command!==S.command)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status);let $=s.safeParse(c.data.data);if(!$.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE",M.status);return $.data}function R(){if(!w)throw new I("MERCHANT_BRIDGE_UNAUTHENTICATED",401);return w}async function B(m,s,E,_){let O=R();if(_!==void 0&&Te.parse({operationId:_,customerId:O}),!f.capabilities.includes(m))throw new I("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let S=h,l=AbortSignal.any([u.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...s?[s]:[]]);l.throwIfAborted();let o,T=new Promise((g,M)=>{o=()=>M(l.reason),l.addEventListener("abort",o,{once:!0})});try{let M=E(async()=>{let c=await import("./merchant-bridge-contracts-O6WIWC7T.js");if(l.throwIfAborted(),S!==h||w!==O)throw new DOMException("Merchant identity changed","AbortError");return c},l),J=await Promise.race([M,T]);return l.throwIfAborted(),J}finally{l.removeEventListener("abort",o)}}async function z(m,s,E,_){let O=R(),S=Te.parse({operationId:E,customerId:O}),l=await P(m,s,S.operationId,_,S);if(l.customerId!==O||l.operationId!==S.operationId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return l}return{async readPresentation(m){let s=await P("presentation",Ge,void 0,m);if(i!==null&&i!==s.nativeUserId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(s.presentation&&w!==null&&s.presentation.customerId!==w)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return i=s.nativeUserId,t=s.presentation,s},async createSession(m){let s=await P("session",je,void 0,m);if(i!==null&&i!==s.nativeUserId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(w!==null&&w!==s.session.customerId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(t&&t.customerId!==s.session.customerId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return w=s.session.customerId,i=s.nativeUserId,s.session},async reportPresentation(m,s){let E=R(),_=Je.parse(m);if(!t||t.customerId!==E||t.decisionId!==_.decisionId)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return P("presentation_events",U.strictObject({queued:U.literal(!0)}),void 0,s,_)},async readCustomerCommerce(m){let s=R(),E=await B("customer_commerce",m,async(_,O)=>{let[S,l]=await Promise.all([_(),P("customer_commerce",U.unknown(),void 0,O)]),o=S.merchantBridgeCommerceSchema.safeParse(l);if(!o.success)throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return o.data});if(E.customerId!==s)throw new I("MERCHANT_BRIDGE_SCOPE_MISMATCH");return E},async executePurchase(m,s){let E=await B("purchases",s,async(_,O)=>z("purchases",(await _()).merchantBridgeOperationSchema,m,O),m);if(E.type!=="purchase")throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return E},readOperation:(m,s)=>B("operation_status",s,async(E,_)=>z("operation_status",(await E()).merchantOperationLookupSchema,m,_),m),async executeSubscriptionChange(m,s){let E=await B("subscription_changes",s,async(_,O)=>z("subscription_changes",(await _()).merchantBridgeOperationSchema,m,O),m);if(E.type!=="subscription_change")throw new I("MERCHANT_BRIDGE_INVALID_RESPONSE");return E},reset(){h++,u.abort(),u=new AbortController,w=null,t=null,i=null}}}var en=U.strictObject({command:ve,target:Qe,runId:U.uuid().optional(),expiresAt:U.iso.datetime({offset:!0}).optional(),deliveryLimit:U.number().int().min(1).max(100).optional()}).refine(n=>n.command.release===n.target.release),Ze=U.strictObject({schemaVersion:U.literal(1),entries:U.array(en).max(4e3)});function nn(n){let d=!1,f=()=>{d||n.unavailable(),d=!0};function b(){return n.storage===!1?void 0:n.storage??globalThis.sessionStorage}function w(t){let i=b()?.getItem(t);if(!i)return[];if(i.length>1048576)throw Error("Entry recovery is too large");return Ze.parse(JSON.parse(i)).entries}function h(t,i){let u=b();if(!u)return;if(!i.length)return u.removeItem(t);let y=JSON.stringify(Ze.parse({schemaVersion:1,entries:i}));if(y.length>1048576)throw Error("Entry recovery is too large");u.setItem(t,y)}return{load(){try{let t=n.binding();if(!t||n.storage===!1)return;let i="indiana.funnel.entries.v1."+JSON.stringify(t);return{key:i,entries:w(i)}}catch{f();return}},retain(t,i){if(t)try{let u=en.parse(i);h(t,[...w(t).filter(y=>y.command.funnelId!==u.command.funnelId),u])}catch{f()}},forget(t,i){if(t)try{h(t,w(t).filter(u=>u.command.requestId!==i))}catch{f()}}}}var tn=U.strictObject({version:U.literal(1),runs:U.array(U.uuid()).max(100)}),De=new WeakMap,Oe=new WeakMap;function Se(n){let d=!1;function f(){d||n.unavailable(),d=!0}function b(t){let i=t.storage.getItem(t.key);if(!i)return[];if(i.length>8192)throw Error("Invalid entry delivery record");return tn.parse(JSON.parse(i)).runs}function w(t){let i=De.get(t.storage);i||De.set(t.storage,i=new Map);let u=i.get(t.key);return u||i.set(t.key,u=new Set),u}function h(t){if(!t)return;let i=De.get(t.storage),u=i?.get(t.key);u?.delete(t.requestId),u?.size===0&&i?.delete(t.key)}return{claim(t,i,u,y,P=!1){if(u!==void 0)try{let R=n.binding();if(!R)throw Error("Entry delivery identity is unavailable");let B={storage:n.storage??globalThis.sessionStorage,key:"indiana.funnel.delivery.v1."+JSON.stringify([...R,i,t]),requestId:y},z=b(B);if(Oe.get(B.storage)?.has(B.key))throw Error("Entry delivery storage is unavailable");B.storage.setItem(B.key,JSON.stringify({version:1,runs:z}));let m=w(B);return!P&&!m.has(y)&&z.length+m.size>=u?!1:(m.add(y),B)}catch{return f(),!1}},accept(t,i){if(t)try{let u=b(t);u.includes(i)||t.storage.setItem(t.key,JSON.stringify(tn.parse({version:1,runs:[...u,i].slice(-100)})))}catch{let u=Oe.get(t.storage);u||Oe.set(t.storage,u=new Set),u.add(t.key),f()}finally{h(t)}},release:h}}function Pe(){let n,d,f=()=>{clearTimeout(n),n=void 0;let b=d;d=void 0,b?.cancelled()};return{get active(){return d!==void 0},start(b,w,h,t){if(d)return;if(b===0){w()?h():t();return}let i={valid:w,cancelled:t};d=i,n=setTimeout(()=>{d===i&&(d=void 0,n=void 0,w()?h():t())},b*1e3)},recheck(){d&&!d.valid()&&f()},cancel:f}}var Re=n=>["running","waiting"].includes(n.status)&&!n.pendingRequest&&(n.stopped||!n.screen&&!n.paywall&&n.instruction?.type==="wait"&&n.instruction.kind!=="operation");function Cn(n){let d=we(n.baseUrl),f=n.scope,b=Ce(n),w=n.fetch??globalThis.fetch.bind(globalThis),h,t=!1,i=!1,u=0,y=0,P="",R=0,B=0,z=0,m=!1,s,E=!0,_,O,S,l,o,T=-1,g,M=e=>{g===e&&(N.release(e.deliveryTicket),g=void 0,x())},J=new Set,c=(e,a)=>Z(n.onStatus,e,a),$=Pe(),N=Se({storage:n.deliveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[d,f.projectId,f.environment,n.environmentId,"customer",e]:void 0},unavailable:()=>c("delivery_unavailable")}),ee=new Set,te=nn({storage:n.recoveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[d,f.projectId,f.environment,n.environmentId,n.appManifestRelease,e]:void 0},unavailable:()=>c("recovery_unavailable")}),Y=e=>te.forget(e.storageKey,e.command.requestId);function Q(e,a){a&&(e.runId=a.id,e.expiresAt=a.runExpiresAt),te.retain(e.storageKey,{command:e.command,target:e.target,...e.runId&&{runId:e.runId},...e.expiresAt&&{expiresAt:e.expiresAt},...e.deliveryLimit!==void 0&&{deliveryLimit:e.deliveryLimit}})}function re(){let e=o;o=void 0,e?.host.destroy(),e?.slot.remove(),e?.client.reset(),x()}let le=()=>$.active||g!==void 0||o!==void 0&&!o.background;function me(e,a){if(o?.client!==e)return;Q(o.recovery,a);let p=Re(a);o.slot.hidden=p,p!==o.background&&(o.background=p,p?c("run_background",o.entryId):T=y,x())}function pe(e,a,p){let v=e.client.view;if(!a||e.background||!v?.screen||v.paywall||v.pendingRequest||v.stopped||v.status!=="waiting")return;let K=Ke.parse({operation:"close",requestId:crypto.randomUUID(),nodeId:v.nodeId,visit:v.visit,revision:v.revision,customerToken:a}),j=Ce({...n,session:void 0});j.requestWithCredential("funnels",K,e.runToken,{keepalive:p}).then(()=>Y(e.recovery)).catch(()=>{}).finally(()=>j.dispose())}let ae=()=>{o&&pe(o,n.session.peek(),!0)},r=()=>Date.now()<B&&performance.now()<z;function C(e){if(e.target.release!==n.appManifestRelease||!r())return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return c("incompatible",e.id),!1}}function H(e){if(t||e.epoch!==R||e.visit!==y||document.visibilityState==="hidden")return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function W(e){if(le()){c("in_progress",e.id);return}let a=R,p=y;$.start(e.delivery?.delaySeconds??0,()=>!t&&a===R&&p===y&&document.visibilityState!=="hidden"&&C(e)&&h?.entries.some(v=>v.id===e.id&&v.funnelId===e.funnelId&&v.versionId===e.versionId&&v.event===e.event&&JSON.stringify(v.target)===JSON.stringify(e.target)&&JSON.stringify(v.delivery)===JSON.stringify(e.delivery))===!0,()=>{V(e)},()=>{J.delete(`${e.funnelId}:${e.id}`)})}async function V(e){if(le()){c("in_progress",e.id);return}if(!n.session.peek()){c("identity_required",e.id);return}let a=te.load(),p=a?.entries.find(A=>A.command.funnelId===e.funnelId&&(!A.expiresAt||Date.parse(A.expiresAt)>Date.now()));if(p){if(!X(p)){c("recovery_pending",e.id);return}let A={...p,storageKey:a.key,epoch:R,visit:y};ee.add(A.command.requestId),g=A,await F(A);return}let v=crypto.randomUUID(),K=N.claim(e.id,e.funnelId,e.delivery?.maxPerSession,v);if(K===!1){c("frequency",e.id),x();return}let j={freshStart:!0,deliveryLimit:e.delivery?.maxPerSession,deliveryTicket:K,command:ve.parse({operation:"entry_start",entryId:e.id,funnelId:e.funnelId,versionId:e.versionId,release:n.appManifestRelease,requestId:v,locale:document.documentElement.lang||"en"}),epoch:R,visit:y,target:e.target,storageKey:a?.key};ee.add(j.command.requestId),g=j,await F(j)}async function F(e){if(e.dispatching)return;e.dispatching=!0;let a=e.freshStart===!0;e.freshStart=!1;let p,v=!1,K=!1;async function j(A){if(e.epoch!==R)return;let D=A.view;if(!(e.storageKey&&D&&(Re(D)||D.paywall||D.pendingRequest))&&D&&["running","waiting"].includes(D.status))try{await A.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:D.nodeId,visit:D.visit,revision:D.revision}),Y(e)}catch(k){if(!(k instanceof G&&k.code==="FORBIDDEN"))throw k}}try{if(!e.deliveryTicket&&e.deliveryLimit!==void 0){let q=N.claim(e.command.entryId,e.command.funnelId,e.deliveryLimit,e.command.requestId,!0);q!==!1&&(e.deliveryTicket=q)}Q(e),c("starting",e.command.entryId);let A=await b.request("funnels",e.command),D=Ye.safeParse(A);if(D.success){if(D.data.scope.projectId!==f.projectId||D.data.scope.environment!==f.environment)throw new G("SCOPE_MISMATCH","Entry scope changed");e.epoch===R&&c(D.data.reason,e.command.entryId),Y(e),M(e);return}let k=Xe.parse(A);if(!k.runToken||k.scope.projectId!==f.projectId||k.scope.environment!==f.environment||k.run.source.type!=="funnel"||k.run.source.id!==e.command.funnelId||k.run.source.versionId!==e.command.versionId||e.runId!==void 0&&k.run.id!==e.runId)throw new G("INVALID_RESPONSE","Invalid entry Run");if(N.accept(e.deliveryTicket,k.run.id),e.epoch!==R){M(e),c("identity_changed",e.command.entryId);return}Q(e,k.run);let L=Ae({...n,runToken:k.runToken,funnelId:e.command.funnelId,initialResponse:a?A:void 0});p=L,K=!0,await L.get(),K=!1;let ne=L.view;if(!ne||ne.id!==k.run.id||ne.source.type!=="funnel"||ne.source.id!==e.command.funnelId||ne.source.versionId!==e.command.versionId)throw new G("INVALID_RESPONSE","Entry Run version changed");if(!["running","waiting"].includes(ne.status)){Y(e),M(e),c("run_ended",e.command.entryId);return}let{showFunnelRun:fe}=await import("./funnel-runtime-host-7ROIR7CU.js");if(!H(e)){await j(L),c("left_screen",e.command.entryId),M(e);return}let Fe=!1,xe=!1;if(o&&!o.background){await j(L),c("in_progress",e.command.entryId),M(e);return}o&&re();let ie=document.createElement("div");ie.hidden=Re(ne),n.container.append(ie);let ke=await fe(ie,{...n.host,client:L,appManifestRelease:n.appManifestRelease,onState(q){me(L,q),Z(n.host?.onState,q)},onDismiss(q){Fe=!0,ie.remove(),q&&!["running","waiting"].includes(q.status)&&Y(e),o?.client===L&&(o=void 0,L.reset(),x(),q&&q.status!=="completed"&&c("run_ended",e.command.entryId)),Z(n.host?.onDismiss,q)},onComplete(q){xe=!0,Y(e),o?.client===L&&re(),Z(n.host?.onComplete,q)},onError(q){Z(n.host?.onError,q),o?.client===L&&q instanceof G&&q.code==="FORBIDDEN"&&(Y(e),re(),c("run_ended",e.command.entryId))}}).catch(q=>{throw ie.remove(),q});if(!H(e)||Fe||xe){ke.destroy(),ie.remove(),H(e)||await j(L),M(e);return}let he=Re(L.view??ne);ie.hidden=he,o={host:ke,client:L,slot:ie,entryId:e.command.entryId,background:he,runToken:k.runToken,owner:n.session.peek(),recovery:e},he||(T=e.visit),v=!0,M(e),c("started",e.command.entryId),he&&c("run_background",e.command.entryId)}catch(A){A instanceof G&&(!p||K&&A.code==="FORBIDDEN")&&A.status!==void 0&&A.status>=400&&A.status<500&&!A.retryable&&(Y(e),M(e)),e.epoch===R&&!t&&(c("start_failed",e.command.entryId),Z(n.host?.onError,A))}finally{v||p?.reset(),e.dispatching=!1}}function X(e){if(e.command.release!==n.appManifestRelease||e.target.release!==n.appManifestRelease)return!1;try{return de(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function ye(){if(le())return!1;let e=te.load();for(let a of e?.entries??[]){if(a.expiresAt&&Date.parse(a.expiresAt)<=Date.now()){te.forget(e.key,a.command.requestId);continue}if(a.command.requestId===o?.recovery.command.requestId||ee.has(a.command.requestId)||!X(a))continue;ee.add(a.command.requestId);let p={...a,storageKey:e.key,epoch:R,visit:y};return g=p,F(p),!0}return!1}function ue(){if(m=!1,$.recheck(),t||!i||document.visibilityState==="hidden")return;se();let e=o!==void 0&&!o.background;if(e&&(T=y),!ye()){if(!r()){E=!0;return}E=!1;for(let a of h?.entries??[]){let p=`${a.funnelId}:${a.id}`;if(!(a.event!=="screen_enter"||J.has(p)||!C(a))){if(!n.session.peek()){c("identity_required",a.id);continue}if(T===y){J.add(p),e&&c("in_progress",a.id);continue}if(g||$.active){c("in_progress",a.id);return}J.add(p),W(a);break}}}}let x=()=>{!m&&!t&&(m=!0,queueMicrotask(ue))};function se(){let e=location.origin+location.pathname;return e===P?!1:(P=e,y++,$.cancel(),E=!0,J.clear(),ee.clear(),!0)}function oe(){se()&&x()}function ce(e){if(!e.isTrusted||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||document.visibilityState==="hidden")return;let a=e.target;if(!(a instanceof Element)||a.closest("[data-indiana-funnel]"))return;let p=a.closest("button,a,input");if(!(!p||p.matches(":disabled,[aria-disabled='true']")||p.closest("[hidden],[inert],[aria-hidden='true']")))for(let v of h?.entries??[]){let K=v.target.button;if(!(v.event!=="button_click"||!K||!C(v))){try{let j=be(document);if(!p.matches(K.selector)||j(K.selector,p)!==1)continue}catch{c("incompatible",v.id);continue}W(v);break}}}async function Me(){if(t)return;if(s)return s;let e=++u,a=new AbortController;_=a;let p,v=new Promise((A,D)=>{p=()=>D(new G("TIMEOUT","Funnel entry configuration read cancelled or timed out")),a.signal.addEventListener("abort",p,{once:!0})}),K=setTimeout(()=>a.abort(),n.timeoutMs??5e3),j=(async()=>{let A=async()=>{let fe=await w(`${d}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:a.signal});if(!fe.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",fe.status);return ge.parse(await fe.json())},D=await Promise.race([A(),v]),k=Date.parse(D.validatedAt),L=Date.parse(D.validUntil);if(D.scope.projectId!==f.projectId||D.scope.environment!==f.environment||D.scope.environmentId!==n.environmentId||D.release!==n.appManifestRelease||L<=Date.now()||k>Date.now()+5e3||L-k>6e4||L<=k)throw new G("INVALID_RESPONSE","Entry configuration scope or deadline changed");if(t||e!==u)return;let ne=h===void 0;h=D,B=L,z=performance.now()+Math.min(L-Date.now(),6e4),$.recheck(),(ne||E)&&x()})();s=j;try{await j}finally{clearTimeout(K),a.signal.removeEventListener("abort",p),s===j&&(s=void 0)}}async function on(){if(!(!i||t)){try{await Me()}catch{t||c("configuration_unavailable")}x()}}let Ne=Ie({document,run:on,delay:()=>i&&!t?15e3:void 0});return{async start(){i||t||(i=!0,P=location.origin+location.pathname,O=Ee(oe),S=n.session.subscribeIdentity(()=>{R++,$.cancel(),N.release(g?.deliveryTicket),E=!0,g=void 0,J.clear(),T=-1,ee.clear(),o&&pe(o,o.owner,!1),re(),x()}),l=new MutationObserver(x),l.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",ce,!0),document.addEventListener("visibilitychange",x),addEventListener("pagehide",ae),await Ne.refresh())},refresh:Me,async retry(){g&&!t&&g.epoch===R&&await F(g)},destroy(){t=!0,u++,$.cancel(),N.release(g?.deliveryTicket),Ne.destroy(),_?.abort(),l?.disconnect(),O?.(),S?.(),document.removeEventListener("click",ce,!0),document.removeEventListener("visibilitychange",x),removeEventListener("pagehide",ae),ae(),re(),b.dispose(),h=void 0}}}function An(n){let d=we(n.baseUrl),f=n.fetch??globalThis.fetch.bind(globalThis),b,w=0,h=0,t=!1,i=!1,u=!1,y=0,P=0,R=-1,B=!1,z="",m,s,E,_,O=new Set,S,l,o,T=(r,C)=>Z(n.onStatus,r,C),g=Pe(),M=()=>{try{return n.deliveryIdentity?.()}catch{return}},J=()=>JSON.stringify(M()),c=Se({storage:n.deliveryStorage,binding:()=>{let r=M();return r?.id?[d,n.scope.projectId,n.scope.environment,n.environmentId,r.type,r.id]:void 0},unavailable:()=>T("delivery_unavailable")}),$=()=>Date.now()<w&&performance.now()<h;function N(r){try{return $()&&r.target.release===n.appManifestRelease&&de(r.target.render,document,location.pathname,()=>{})}catch{return T("incompatible",r.id),!1}}function ee(){let r=o;o=void 0,r?.host.destroy(),r?.slot.remove()}async function te(r){if(r.dispatching)return;r.dispatching=!0;let C=y;try{let H=await r.process.open({operation:"entry_start",funnelId:r.entry.funnelId,versionId:r.entry.versionId,entryId:r.entry.id,release:n.appManifestRelease,locale:n.locale??"en"});c.accept(r.deliveryTicket,H.run.id);let{showFunnelRun:W}=await import("./funnel-runtime-host-7ROIR7CU.js");if(t||C!==y||l!==r)return;let V=document.createElement("div");n.container.append(V),R=P;let F=await W(V,{...n.host,client:H.controller,appManifestRelease:n.appManifestRelease,onDismiss(X){o?.process===r.process&&(o=void 0,V.remove()),Z(n.host?.onDismiss,X)}});if(t||C!==y||l!==r){F.destroy(),V.remove();return}o={entry:r.entry,process:r.process,host:F,slot:V,deliveryTicket:r.deliveryTicket},l=void 0,T("run_presented",r.entry.id)}catch(H){if(t||C!==y||l!==r)return;H instanceof G&&"result"in H?(c.release(r.deliveryTicket),l=void 0,r.process.destroy(),T("suppressed",r.entry.id),Q()):T("entry_unavailable",r.entry.id)}finally{r.dispatching=!1}}function Y(r){if(t||i||l||o||S||g.active||R===P||!N(r))return;let C=`${P}:${r.id}`;if(O.has(C))return;O.add(C);let H=P,W=y,V=J();g.start(r.delivery?.delaySeconds??0,()=>!t&&y===W&&P===H&&J()===V&&document.visibilityState!=="hidden"&&N(r)&&b?.entries.some(F=>F.id===r.id&&F.funnelId===r.funnelId&&F.versionId===r.versionId&&F.event===r.event&&JSON.stringify(F.target)===JSON.stringify(r.target)&&JSON.stringify(F.delivery)===JSON.stringify(r.delivery))===!0,()=>{let F=c.claim(r.id,r.funnelId,r.delivery?.maxPerSession,crypto.randomUUID());if(F===!1){T("frequency",r.id),Q();return}try{let X={entry:r,process:n.createProcess(r),visit:P,deliveryTicket:F};l=X,te(X)}catch(X){c.release(F),T("entry_unavailable",r.id),Z(n.host?.onError,X)}},()=>{O.delete(C)})}function Q(){B||t||(B=!0,queueMicrotask(()=>{if(B=!1,g.recheck(),!(t||i||document.visibilityState==="hidden"||!$()||l||o||S||g.active||R===P)){for(let r of b?.entries??[])if(r.event==="screen_enter"&&!O.has(`${P}:${r.id}`)&&N(r)){Y(r);break}}}))}function re(r){if(!r.isTrusted||r.defaultPrevented||!(r.target instanceof Element)||l||o||S||R===P)return;let C=be(document,()=>{});for(let H of b?.entries??[]){let W=H.target.button;if(H.event!=="button_click"||!W||!N(H))continue;let V=r.target.closest(W.selector);if(!(!V||V.tagName.toLowerCase()!==W.tag||C(W.selector)!==1||V.matches(":disabled")||V.closest('[inert],[hidden],[aria-hidden="true"]'))){Y(H);break}}}let le=()=>{let r=location.origin+location.pathname;r!==z&&(z=r,P++,g.cancel(),O.clear(),Q())};async function me(){if(t)return;if(s)return s;let r=y,C=new AbortController;m=C;let H,W=new Promise((ye,ue)=>{H=ue}),V=()=>H(new G("TIMEOUT","Funnel entry read cancelled"));C.signal.addEventListener("abort",V,{once:!0});let F=setTimeout(()=>C.abort(),n.timeoutMs??5e3),X=(async()=>{let ye=encodeURIComponent(JSON.stringify(["funnel-process/1"])),ue=async()=>{let ce=await f(`${d}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}&executionContracts=${ye}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:C.signal});if(!ce.ok)throw new G("SERVICE_UNAVAILABLE","Funnel entries unavailable",ce.status);return ge.parse(await ce.json())},x=await Promise.race([ue(),W]),se=Date.parse(x.validatedAt),oe=Date.parse(x.validUntil);if(x.scope.projectId!==n.scope.projectId||x.scope.environment!==n.scope.environment||x.scope.environmentId!==n.environmentId||x.release!==n.appManifestRelease||oe<=Date.now()||se>Date.now()+5e3||oe<=se||oe-se>6e4)throw new G("INVALID_RESPONSE","Entry scope or deadline changed");t||r!==y||(b=x,w=oe,h=performance.now()+Math.min(oe-Date.now(),6e4),g.recheck(),Q())})();s=X;try{await X}finally{clearTimeout(F),C.signal.removeEventListener("abort",V),s===X&&(s=void 0)}}async function pe(){if(!(!u||t))try{await me()}catch{t||T("configuration_unavailable")}}let ae=Ie({document,run:pe,delay:()=>u&&!t?15e3:void 0});return{async start(){u||t||(u=!0,z=location.origin+location.pathname,E=Ee(le),_=new MutationObserver(Q),_.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",re,!0),document.addEventListener("visibilitychange",Q),await ae.refresh())},refresh:me,async retry(){l&&!t&&await te(l)},async syncIdentity(){g.cancel();let r=o??l??S;if(!r){i=!1,Q();return}try{let C=await r.process.syncIdentity();return i=!1,S===r&&(l={...r,visit:P},S=void 0,await te(l)),C}catch(C){throw r.process.view||(S={...r,visit:P},l=void 0,ee()),C}},async detach(){i=!0,y++,g.cancel(),m?.abort();let r=o??l??S;r&&(S={...r,visit:P}),l=void 0,ee(),r&&await r.process.detach()},destroy(){t=!0,y++,g.cancel(),ae.destroy(),m?.abort(),_?.disconnect(),E?.(),document.removeEventListener("click",re,!0),document.removeEventListener("visibilitychange",Q);let r=o??l??S;c.release(r?.deliveryTicket),l=void 0,S=void 0,ee(),r?.process.destroy(),b=void 0}}}async function Dn(n,d){return(await import("./paywall-25MAYQ4B.js")).showPaywall(n,d)}async function dt(){return await Promise.all([import("./paywall-25MAYQ4B.js"),import("./screen-renderer-XZWKIJWF.js")]),Dn}async function lt(...n){return n[1]=ze(n[1]),(await import("./paywall-session-7HGW5IKN.js")).createPaywallSession(...n)}async function ut(...n){let d=n[1].signal?.aborted?void 0:We(n[1].client);try{return import("./screen-renderer-XZWKIJWF.js").catch(()=>{}),import("./paywall-25MAYQ4B.js").catch(()=>{}),await(await rn(()=>import("./funnel-runtime-host-7ROIR7CU.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-AT4BXZIY.js").then(b=>b.preparedInternals(d)?.release(),()=>{}),f}}async function ft(...n){return import("./screen-renderer-XZWKIJWF.js").catch(()=>{}),import("./paywall-25MAYQ4B.js").catch(()=>{}),(await rn(()=>import("./funnel-host-purchase-UONTZRRJ.js"),n[1].prepared)).showFunnelPurchase(...n)}async function mt(...n){return import("./funnel-host-purchase-UONTZRRJ.js").catch(()=>{}),import("./screen-renderer-XZWKIJWF.js").catch(()=>{}),(await import("./funnel-paywall-prerender-AT4BXZIY.js")).prerenderFunnelPurchase(...n)}async function pt(){await Promise.all([import("./funnel-paywall-prerender-AT4BXZIY.js"),import("./funnel-host-purchase-UONTZRRJ.js"),import("./paywall-25MAYQ4B.js"),import("./screen-renderer-XZWKIJWF.js"),import("./paywall-content-7KTEQLRN.js"),import("./check-response-AVQ7PY5I.js"),import("./operation-contracts-H7NKQ373.js")])}async function yt(...n){return(await import("./funnel-route-prediction-Z3J2HSHI.js")).predictFunnelStart(...n)}async function ht(...n){return(await import("./funnel-route-prediction-Z3J2HSHI.js")).predictedPaywallLoadingDocument(...n)}async function gt(...n){return(await import("./content-2EEYM7U7.js")).mountContent(...n)}async function vt(...n){return(await import("./content-2EEYM7U7.js")).prepareContent(...n)}export{G as LongplayError,I as MerchantBridgeError,yn as createBrowserFunnelCommandStorage,En as createBrowserFunnelPurchaseStorage,vn as createConfigurationSync,mn as createFeatureClient,wn as createFunnelClient,Rn as createFunnelPageExperiments,Sn as createFunnelProcess,bn as createFunnelPurchaseClient,Ae as createFunnelRunController,Cn as createIamFunnelEntries,An as createIamFunnelProcessEntries,Pn as createLocalFunnelClient,pn as createLongplay,Tn as createMerchantBridge,lt as createPaywallSession,In as evaluateFunnelNode,sn as formatCouponDiscount,an as formatCouponMoney,cn as formatCouponTerms,hn as getPaywallRecovery,un as isPaywallOperationComplete,fn as isPaywallOperationPending,ln as isPaywallUpdateOperation,dn as isPaywallUpdateQuote,gt as mountContent,yt as predictFunnelStart,ht as predictedPaywallLoadingDocument,pt as preloadFunnelPurchase,dt as preloadPaywall,vt as prepareContent,gn as preparePaywallFallback,mt as prerenderFunnelPurchase,ft as showFunnelPurchase,ut as showFunnelRun,Dn as showPaywall};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{P as r,Q as m,j as e}from"./chunk-KVIGHX2B.js";import"./chunk-FAMPOY6L.js";import"./chunk-XI2NNZBS.js";import"./chunk-LDLS2VL2.js";import"./chunk-PY3AC5KD.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{m as merchantBridgeCommerceSchema,r as merchantBridgeOperationSchema,e as merchantOperationLookupSchema};
|