@tinkerlandai/longplay-sdk 0.10.88 → 0.10.90
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 +9 -0
- package/dist/{chunk-QV5XL3OF.js → chunk-3VDU2U66.js} +1 -1
- package/dist/{chunk-Y625SYGQ.js → chunk-47S2FZV7.js} +1 -1
- package/dist/{chunk-6RWGMM72.js → chunk-4JOYBJQO.js} +1 -1
- package/dist/chunk-6OGBLDKX.js +1 -0
- package/dist/{chunk-LVVQOLB5.js → chunk-AXK24XOE.js} +2 -2
- package/dist/chunk-BQBXK2EG.js +1 -0
- package/dist/{chunk-OYN2KWCV.js → chunk-FYWMUFWC.js} +1 -1
- package/dist/{chunk-OQQXGPUR.js → chunk-KCG7GZXO.js} +1 -1
- package/dist/{chunk-WEJQKYOQ.js → chunk-KEFBS26K.js} +1 -1
- package/dist/{chunk-EKGVIV2L.js → chunk-P3J2GOGH.js} +1 -1
- package/dist/{chunk-5BFRKHW3.js → chunk-X3TJBUFF.js} +1 -1
- package/dist/chunk-XAPMQRVJ.js +1 -0
- package/dist/{chunk-ULRVUKHP.js → chunk-XUKBBAME.js} +1 -1
- package/dist/chunk-XVTH3B5P.js +1 -0
- package/dist/{content-USUJMEAJ.js → content-T47OCROR.js} +1 -1
- package/dist/{funnel-host-purchase-PY4JCK52.js → funnel-host-purchase-U5FSCSJF.js} +1 -1
- package/dist/{funnel-host-recovery-paywall-AGJKYGMI.js → funnel-host-recovery-paywall-VTH7QU2M.js} +1 -1
- package/dist/{funnel-paywall-prerender-XPO6YVDD.js → funnel-paywall-prerender-W3DBHEND.js} +1 -1
- package/dist/{funnel-runtime-host-H7XCTPAM.js → funnel-runtime-host-ZOOBQF3C.js} +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/page.js +1 -1
- package/dist/{paywall-M37XZSJK.js → paywall-GHU6D5SU.js} +1 -1
- package/dist/{paywall-content-5MP2N2SJ.js → paywall-content-EGRO37Y2.js} +1 -1
- package/dist/{paywall-session-DNIZONXB.js → paywall-session-4MJC4RBH.js} +1 -1
- package/dist/react-native.js +1 -1
- package/dist/server.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3BLTEKHB.js +0 -1
- package/dist/chunk-6YGUSY4G.js +0 -1
- package/dist/chunk-FSQUQ3J3.js +0 -1
- package/dist/chunk-JS4K6SZB.js +0 -1
- /package/dist/{chunk-LVVQOLB5.js.LEGAL.txt → chunk-AXK24XOE.js.LEGAL.txt} +0 -0
package/dist/openrouter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-Y6KA56V2.js";import"./chunk-SX7U2ONB.js";import"./chunk-
|
|
1
|
+
import"./chunk-Y6KA56V2.js";import"./chunk-SX7U2ONB.js";import"./chunk-47S2FZV7.js";import"./chunk-KCUE2VFJ.js";import{a as i}from"./chunk-UGATOG2T.js";import"./chunk-LFR2LWYC.js";import"./chunk-XUKBBAME.js";import"./chunk-5MRSFLQA.js";import{b as A}from"./chunk-W22ESUYY.js";import"./chunk-WOT6VMZA.js";var c=A.number().int().min(0).max(1e9);function R(e,o){let a=c.parse(e.promptTokens),p=c.parse(e.completionTokens),s=c.parse(e.promptTokensDetails?.cachedTokens??0),t=c.parse(e.promptTokensDetails?.cacheWriteTokens??0),r=c.parse(e.promptTokensDetails?.audioTokens??0),l=c.parse(e.completionTokensDetails?.audioTokens??0),n=c.parse(e.completionTokensDetails?.reasoningTokens??0);if(c.parse(e.totalTokens)!==a+p||s+t+r>a||n+l>p||(e.promptTokensDetails?.videoTokens??0)>0)throw new i("AI_USAGE_UNAVAILABLE","Token pools must conserve usage; video needs an explicit token mapper");return{input:a-s-t-r,output:p-l-(o==="separate"?n:0),cache_read:s,cache_write:t,input_audio:r,output_audio:l,reasoning:o==="separate"?n:0}}function I(e){if(!Number.isFinite(e)||e<0)throw new i("AI_USAGE_UNAVAILABLE","Provider cost must be a nonnegative USD amount");let o=String(e),a=o.includes("e")?e.toFixed(18).replace(/0+$/,"").replace(/\.$/,""):o;if(!/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/.test(a)||Number(a)!==e)throw new i("AI_USAGE_UNAVAILABLE","Provider cost exceeds the supported precision");return a}async function f(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning)||!e.modelId||!e.generationId)throw new i("INVALID_REQUEST","Actual model, generation ID and reasoning pricing are required");let o={context:e.context,generationId:e.generationId,modelId:`openrouter/${e.modelId}`,usage:e.usage,tokens:null,quote:null,receipt:null,phase:"captured"};await e.persist(o);let a=e.mapTokens?e.mapTokens(e.usage):R(e.usage,e.reasoning),p=e.usage.cost==null?void 0:I(e.usage.cost),s=e.quote??await e.pricing.quoteTokens({modelId:o.modelId,tokens:a});if(s.pricing.modelId!==o.modelId||Object.keys(a).some(l=>a[l]!==s.tokens[l]))throw new i("INVALID_REQUEST","Saved quote must match the provider model and token pools");await e.persist({...o,tokens:a,quote:s,phase:"quoted"});let t=await e.pricing.trackTokens(e.client,{...e.context,quote:s,providerCostUsd:p,generationId:e.generationId});if(!t.receipt.accepted)throw new i("AI_BALANCE_REJECTED","OpenRouter usage was saved but the balance request was rejected");let r={...o,tokens:a,quote:s,receipt:t,phase:"settled"};return await e.persist(r),r}function T(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning))throw new i("INVALID_REQUEST","Reasoning pricing is required");let o=e.openRouter.chat;async function a(t){if(!t.usage||!t.modelId||!t.generationId)throw new i("AI_USAGE_UNAVAILABLE","OpenRouter did not return final usage and the actual model");await f({...e,context:t.context,generationId:t.generationId,modelId:t.modelId.slice(11),usage:t.usage})}let p=async(t,r)=>{let n={context:await e.context(),generationId:null,modelId:null,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"},d;try{d=await o.send(t,r)}catch(g){throw await e.persist(n),g}if(!(d instanceof ReadableStream)){if(n={...n,generationId:d.id,modelId:d.model?`openrouter/${d.model}`:null,usage:d.usage??null},!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter omitted final accounting");return await a(n),d}let w=d.getReader(),m=!1;return new ReadableStream({async pull(g){try{let{value:u,done:k}=await w.read();if(k){if(m=!0,!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter stream ended without final accounting");await a(n),g.close();return}if(u.error)throw new i("AI_PROVIDER_ERROR",u.error.message);u.usage&&(n={...n,generationId:u.id,modelId:u.model?`openrouter/${u.model}`:null,usage:u.usage}),g.enqueue(u)}catch(u){m||(m=!0,await e.persist(n)),await w.cancel(u),g.error(u)}},async cancel(g){m||(m=!0,await e.persist(n)),await w.cancel(g)}})},s=new Proxy(o,{get(t,r){return r==="send"?p:Reflect.get(t,r,t)}});return new Proxy(e.openRouter,{get(t,r){return r==="chat"?s:Reflect.get(t,r,t)}})}export{T as createOpenRouterUsageClient,f as trackOpenRouterUsage};
|
package/dist/page.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as o,e as r,f as e,g as f}from"./chunk-
|
|
1
|
+
import{d as o,e as r,f as e,g as f}from"./chunk-AXK24XOE.js";import"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-XUKBBAME.js";import"./chunk-5MRSFLQA.js";import"./chunk-DSPLGTQI.js";import"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-XAPMQRVJ.js";import"./chunk-CHRNCOXJ.js";import"./chunk-W32FI2A2.js";import"./chunk-CO6HDNOC.js";import"./chunk-Y55OBV7D.js";import"./chunk-MOIVJERE.js";import"./chunk-6XRQR43F.js";import"./chunk-3532HSBP.js";import"./chunk-67WFVDTV.js";import"./chunk-VILB5M4X.js";import"./chunk-47S2FZV7.js";import"./chunk-KCUE2VFJ.js";import"./chunk-Y3W5G4BF.js";import"./chunk-FYUMVOCV.js";import"./chunk-DUS5V65Z.js";import"./chunk-BOT6ZDLK.js";import"./chunk-A5WUQLAO.js";import"./chunk-UGATOG2T.js";import"./chunk-LFR2LWYC.js";import"./chunk-XUKBBAME.js";import"./chunk-5MRSFLQA.js";import"./chunk-W22ESUYY.js";import"./chunk-DSPLGTQI.js";import"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";export{a as showPaywall};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a}from"./chunk-
|
|
1
|
+
import{b as a}from"./chunk-X3TJBUFF.js";import"./chunk-7QPCNDIY.js";import"./chunk-BT7IC765.js";import"./chunk-ME6QTD5Y.js";import"./chunk-6XRQR43F.js";import"./chunk-3532HSBP.js";import"./chunk-67WFVDTV.js";import"./chunk-6VVQWTHV.js";import"./chunk-VILB5M4X.js";import"./chunk-47S2FZV7.js";import"./chunk-KCUE2VFJ.js";import"./chunk-Y3W5G4BF.js";import"./chunk-FYUMVOCV.js";import"./chunk-DUS5V65Z.js";import"./chunk-BOT6ZDLK.js";import"./chunk-A5WUQLAO.js";import"./chunk-UGATOG2T.js";import"./chunk-LFR2LWYC.js";import"./chunk-3VUPVXAV.js";import"./chunk-XUKBBAME.js";import"./chunk-5MRSFLQA.js";import"./chunk-W22ESUYY.js";import"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-3VDU2U66.js";import"./chunk-CKMSSBJM.js";import"./chunk-FPJ3FE26.js";import"./chunk-S2S4ROGY.js";import"./chunk-Y55OBV7D.js";import"./chunk-MOIVJERE.js";import"./chunk-2OBXRQMW.js";import"./chunk-PUDTOCQF.js";import"./chunk-X3TJBUFF.js";import"./chunk-7QPCNDIY.js";import"./chunk-BT7IC765.js";import"./chunk-ME6QTD5Y.js";import"./chunk-6XRQR43F.js";import"./chunk-3532HSBP.js";import"./chunk-67WFVDTV.js";import"./chunk-6VVQWTHV.js";import"./chunk-VILB5M4X.js";import"./chunk-SX7U2ONB.js";import"./chunk-47S2FZV7.js";import"./chunk-KCUE2VFJ.js";import"./chunk-Y3W5G4BF.js";import"./chunk-FYUMVOCV.js";import"./chunk-DUS5V65Z.js";import"./chunk-BOT6ZDLK.js";import"./chunk-A5WUQLAO.js";import"./chunk-UGATOG2T.js";import"./chunk-LFR2LWYC.js";import"./chunk-3VUPVXAV.js";import"./chunk-XUKBBAME.js";import"./chunk-5MRSFLQA.js";import"./chunk-W22ESUYY.js";import"./chunk-DSPLGTQI.js";import"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
|
package/dist/react-native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as S,c as E,d as T}from"./chunk-
|
|
1
|
+
import{b as S,c as E,d as T}from"./chunk-KEFBS26K.js";import"./chunk-XLGNBPGF.js";import{a as A}from"./chunk-3VDU2U66.js";import{e as P}from"./chunk-CKMSSBJM.js";import"./chunk-FPJ3FE26.js";import{h as b,i as x,k as L}from"./chunk-4JOYBJQO.js";import{E as C}from"./chunk-FYWMUFWC.js";import"./chunk-F4AIEI5N.js";import"./chunk-S2S4ROGY.js";import"./chunk-Y55OBV7D.js";import"./chunk-MOIVJERE.js";import"./chunk-2OBXRQMW.js";import"./chunk-PUDTOCQF.js";import"./chunk-X3TJBUFF.js";import"./chunk-7QPCNDIY.js";import"./chunk-BT7IC765.js";import"./chunk-ME6QTD5Y.js";import"./chunk-6XRQR43F.js";import"./chunk-3532HSBP.js";import"./chunk-67WFVDTV.js";import"./chunk-KX67ZM7H.js";import"./chunk-6VVQWTHV.js";import"./chunk-VILB5M4X.js";import"./chunk-SX7U2ONB.js";import"./chunk-47S2FZV7.js";import"./chunk-KCUE2VFJ.js";import"./chunk-Y3W5G4BF.js";import"./chunk-FYUMVOCV.js";import"./chunk-DUS5V65Z.js";import"./chunk-BOT6ZDLK.js";import"./chunk-A5WUQLAO.js";import{a as r}from"./chunk-UGATOG2T.js";import{h as R}from"./chunk-LFR2LWYC.js";import"./chunk-3VUPVXAV.js";import"./chunk-XUKBBAME.js";import"./chunk-5MRSFLQA.js";import"./chunk-W22ESUYY.js";import"./chunk-DSPLGTQI.js";import"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";function k(t,d){let n,a=0,m=-1,l,i=!1,y=()=>{if(i)throw new r("CLOSED","Native host was destroyed");if(!t.nativeModule)throw new r("CAPABILITY_UNAVAILABLE","Link IndianaBridge and supply nativeModule");return t.nativeModule},o=()=>new r("IDENTITY_CHANGED","Customer identity changed during the native operation"),h=d.subscribeIdentity(()=>{a++,m=-1;let e=a;n&&t.nativeModule&&n.then(c=>t.nativeModule.reset(c,e)).catch(()=>{})}),I=t.nativeEvents?.(e=>{!n||!t.nativeModule||typeof e?.requestId!="string"||(async()=>{let c=await n;if(e.instanceId!==c)return;if(e.kind==="credential"){let w=a,f=null;try{if(!i&&e.revision===w){let N=await d.access();!i&&a===w&&(f=N)}}finally{await t.nativeModule.provideCredential(c,e.requestId,f)}return}let s=!1,u=a;try{if(i||e.revision!==u||!t.onNativeAction)throw o();await t.onNativeAction(e.action),s=!i&&a===u}finally{await t.nativeModule.acknowledge(c,e.requestId,s)}})().catch(()=>{})});async function p(e,c={}){let s=y();if(d.snapshot()&&!t.nativeEvents)throw new r("CAPABILITY_UNAVAILABLE","Supply nativeEvents to share credential refresh with the native host");let u=a,w=await d.access();if(i||a!==u)throw o();if(!n){let v=s.create(JSON.stringify({baseUrl:t.baseUrl??"https://api.longplayai.com",scope:t.scope,timeout:(t.timeoutMs??15e3)/1e3,credentialEvents:!!t.nativeEvents}));n=v,v.catch(()=>{n===v&&(n=void 0)})}let f=await n;if(i||a!==u)throw o();if(m!==u){if(!l||l.epoch!==u){let O=(async()=>{if(await s.identify(f,JSON.stringify({revision:u,credentials:w})),i||a!==u)throw await s.reset(f,u),o();m=u})();l={epoch:u,task:O}}let v=l;try{await v.task}finally{l===v&&(l=void 0)}}let N=await s.invoke(f,e,JSON.stringify(c));if(i||a!==u)throw o();try{return JSON.parse(N)}catch{throw new r("INVALID_RESPONSE","Native host returned invalid JSON")}}async function g(e,c){let s=await p(e,c);if(!s||typeof s!="object"||Array.isArray(s)||s.status!=="complete"&&s.status!=="dismissed")throw new r("INVALID_RESPONSE","Native presentation returned an invalid result");return s}return{showFunnel(e){return g("showFunnel",{runToken:e})},showPaywall(e){return g("showPaywall",e)},showContent(e){return g("showContent",e)},purchaseSubscription(e,c){return p("purchaseSubscription",{operationId:e,accepted:c})},switchSubscription(e,c){return p("switchSubscription",{operationId:e,accepted:c})},restorePurchases(){return p("restorePurchases")},manageSubscriptions(e){return p("manageSubscriptions",e?{productId:e}:{})},async dismiss(){a++,m=-1,n&&await y().reset(await n,a)},async destroy(){i||(i=!0,a++,h(),I?.(),n&&t.nativeModule&&await t.nativeModule.destroy(await n))}}}var M=P.trackUsage.request.shape.command,U=P.trackUsage.response;function F(t){let d=R.parse(t.scope),n=S({...t,scope:d}),a={...t,scope:d,session:n.session},m=k(t,n.session),l=0,i=!1;n.subscribeIdentity(()=>{l++});let y=()=>{if(i)throw new r("CLOSED","SDK client was destroyed");let o=n.session.peek();if(!o)throw new r("UNAUTHENTICATED","Identify the Customer first");return o};return{...n,native:m,async destroy(){i||(i=!0,l++,n.destroy(),await m.destroy())},funnel(){return E({...a,customerToken:y()})},resumeFunnel(o){return y(),C({...a,runToken:o})},paywall(o){return A(a,{...o,customerToken:y()})},async trackUsage(o){if(y(),!t.usageReporter)throw new r("INVALID_REQUEST","Configure your authenticated backend usageReporter");let h=M.parse(o),I=l,p;try{p=await t.usageReporter(h)}catch(e){throw I!==l?new r("IDENTITY_CHANGED","Customer identity changed during usage reporting"):e}if(I!==l)throw new r("IDENTITY_CHANGED","Customer identity changed during usage reporting");let g=U.parse(p);if(g.scope.projectId!==d.projectId||g.scope.environment!==d.environment)throw new r("INVALID_RESPONSE","Usage response scope differs");return g}}}export{r as LongplayError,x as createConfigurationSync,b as createFeatureClient,T as createFunnelProcess,L as createLocalFunnelClient,F as createLongplayReactNative};
|
package/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as pn}from"./chunk-
|
|
1
|
+
import{a as pn}from"./chunk-6OGBLDKX.js";import{a as I}from"./chunk-EQUVI5QU.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-Y6KA56V2.js";import{a as xt}from"./chunk-3VDU2U66.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-CKMSSBJM.js";import"./chunk-FPJ3FE26.js";import{a as Te,b as ae,c as yt,d as It,e as wt,f as xe,g as vt,h as Me,i as dn,j as ln,k as mn}from"./chunk-4JOYBJQO.js";import{B as V,C as N,d as ft,e as ht,k as gt,l as z,m as St,p as Ct,q as Rt,r as bt,s as At,t as Ot,y as pe,z as Tt}from"./chunk-FYWMUFWC.js";import"./chunk-F4AIEI5N.js";import{c as h}from"./chunk-S2S4ROGY.js";import"./chunk-Y55OBV7D.js";import"./chunk-MOIVJERE.js";import"./chunk-2OBXRQMW.js";import{a as Et,b as _e}from"./chunk-PUDTOCQF.js";import"./chunk-X3TJBUFF.js";import"./chunk-7QPCNDIY.js";import{e as at}from"./chunk-BT7IC765.js";import{B as pt,C as de,D as Z,E as lt,J as mt,a as et,e as q,j as Re,k as st,l as ct,q as ut,r as dt,s as be,t as Ae}from"./chunk-ME6QTD5Y.js";import"./chunk-6XRQR43F.js";import"./chunk-3532HSBP.js";import{A as W,B as oe,C as tt,D as Se,E as ie,G as se,H as Ce,M as j,O as ce,P as nt,R as Ee,S as rt,T as ot,f as Ge,g as je,j as we,r as ze,s as Ke,u as an,v as sn,y as cn,z as X}from"./chunk-67WFVDTV.js";import{b as Oe}from"./chunk-KX67ZM7H.js";import{e as ve,i as Ze,l as it}from"./chunk-6VVQWTHV.js";import"./chunk-VILB5M4X.js";import"./chunk-SX7U2ONB.js";import"./chunk-47S2FZV7.js";import{a as Ne,b as Le}from"./chunk-KCUE2VFJ.js";import{o as ue}from"./chunk-Y3W5G4BF.js";import"./chunk-FYUMVOCV.js";import{i as un,k as $e,l as Qe,m as Je}from"./chunk-DUS5V65Z.js";import{c as Ie}from"./chunk-BOT6ZDLK.js";import{e as Xe,h as We}from"./chunk-A5WUQLAO.js";import{a as c}from"./chunk-UGATOG2T.js";import{h as Y}from"./chunk-LFR2LWYC.js";import"./chunk-3VUPVXAV.js";import"./chunk-XUKBBAME.js";import"./chunk-5MRSFLQA.js";import{b as u}from"./chunk-W22ESUYY.js";import"./chunk-DSPLGTQI.js";import{a as Ye}from"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";var _t=4,Mt=[...tt,"requirement_checks","native_offers","preparations","benefit_claims","authorizations","business_results","checkout_termination"],In=u.enum(Mt),ee=(e,n)=>u.array(e).max(n).refine(t=>new Set(t).size===t.length,"Declarations must be unique"),ke=u.strictObject({...se.shape,bridgeVersion:u.literal(_t),capabilities:ee(In,Mt.length),checkKinds:ee(u.enum(["access","metered","credit"]),3),preparationActions:ee(u.enum(["purchase","subscription_change","refund"]),3),authorizationKinds:ee(u.enum(["auto_topup"]),1),nextActionTypes:ee(u.enum(["redirect","authenticate"]),2),resultEvents:ee(u.enum(["benefit.claimed","authorization.updated"]),2)}).superRefine((e,n)=>{e.capabilities.includes("catalog")!==(e.catalog!=="none")&&n.addIssue({code:"custom",path:["catalog"],message:"Catalog declaration differs from its capability"}),(e.capabilities.includes("billing_records")!==e.billingEvents.length>0||new Set(e.billingEvents).size!==e.billingEvents.length)&&n.addIssue({code:"custom",path:["billingEvents"],message:"Declare unique supported billing events"});let t=r=>e.capabilities.includes(r),o=(r,a)=>n.addIssue({code:"custom",path:[r],message:a});t("requirement_checks")!==e.checkKinds.length>0&&o("checkKinds","Declare the supported Check kinds"),t("preparations")!==e.preparationActions.length>0&&o("preparationActions","Declare the supported preparation actions"),t("authorizations")!==e.authorizationKinds.length>0&&o("authorizationKinds","Declare the supported authorization kinds"),t("business_results")!==e.resultEvents.length>0&&o("resultEvents","Declare the supported non-financial results");for(let[r,a,s]of[["purchases","purchase","purchase.completed"],["subscription_changes","subscription_change","subscription.change.completed"],["refunds","refund","refund.updated"]])t(r)&&(!t("operation_status")||!t("billing_records")||!t("preparations")||!e.preparationActions.includes(a)||!e.billingEvents.includes(s))&&o("capabilities",`${r} requires preparation, original lookup and its billing result`);t("purchases")&&!e.billingEvents.includes("purchase.closed")&&o("billingEvents","Purchase execution requires its terminal closure result"),t("checkout_termination")&&(!t("operation_status")||!t("billing_records")||!e.billingEvents.includes("purchase.closed"))&&o("capabilities","Checkout termination requires original lookup and purchase.closed"),t("subscription_changes")&&!e.billingEvents.includes("subscription.change.closed")&&o("billingEvents","Subscription change execution requires its terminal closure result");for(let[r,a]of[["benefit_claims","benefit.claimed"],["authorizations","authorization.updated"]])t(r)&&(!t("operation_status")||!t("business_results")||!e.resultEvents.includes(a))&&o("capabilities",`${r} requires original lookup and its non-financial result`)}),K={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":u.strictObject({}),"requirement.check":$e,"operation.prepare":ze,"benefit.claim":Ue,"operation.read":qe,"purchase.terminate":j},wn={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":ke,"requirement.check":Qe,"operation.prepare":Ke,"benefit.claim":Ve,"operation.read":He,"purchase.terminate":j.extend({outcome:u.enum(["requested","already_paid"])})},Gn=u.enum(["bridge.ping","bridge.describe","requirement.check","operation.prepare","benefit.claim","operation.read","purchase.terminate"]);function $(e,n){return u.strictObject({bridgeVersion:u.literal(_t),requestId:u.uuid(),scope:Ce,command:u.literal(e),data:n})}var kt=u.discriminatedUnion("command",[$("bridge.ping",K["bridge.ping"]),$("bridge.describe",K["bridge.describe"]),$("requirement.check",K["requirement.check"]),$("operation.prepare",K["operation.prepare"]),$("benefit.claim",K["benefit.claim"]),$("operation.read",K["operation.read"]),$("purchase.terminate",K["purchase.terminate"])]),Be=u.strictObject({code:u.string().regex(/^MERCHANT_BRIDGE_[A-Z_]+$/),message:u.string().min(1).max(500),retryable:u.boolean(),recovery:u.string().min(1).max(80),effect:u.enum(["none","unknown"])}).refine(e=>e.effect!=="unknown"||!e.retryable&&e.recovery==="recover_operation","Unknown effects require original-operation recovery");function Bt(e){let n={bridgeVersion:u.literal(4),requestId:u.uuid(),scope:Ce,command:u.literal(e)};return u.union([u.strictObject({...n,data:wn[e]}),u.strictObject({...n,error:Be})])}var Pt="X-Indiana-Bridge-Signature",Q="X-Indiana-Bridge-Key-Id";function vn(e){return new TextEncoder().encode(e)}function Dt(e){return Uint8Array.from(atob(e.replaceAll("-","+").replaceAll("_","/")),n=>n.charCodeAt(0))}function Ft(e,n,t,o){return vn(`indiana-merchant-bridge:${o}
|
|
2
2
|
${n}
|
|
3
3
|
POST
|
|
4
4
|
${W}
|
package/dist/visual.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as pe,c as fe}from"./chunk-KV5MZ4NI.js";import{b as le}from"./chunk-J6KIN4RH.js";import{a as Ve,b as ce,c as de,d as ue}from"./chunk-SLUA7ABW.js";import{a as J,b as F,c as ge,e as me}from"./chunk-
|
|
1
|
+
import{a as pe,c as fe}from"./chunk-KV5MZ4NI.js";import{b as le}from"./chunk-J6KIN4RH.js";import{a as Ve,b as ce,c as de,d as ue}from"./chunk-SLUA7ABW.js";import{a as J,b as F,c as ge,e as me}from"./chunk-AXK24XOE.js";import{a as re,b as ae,c as se,d as oe}from"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-XUKBBAME.js";import"./chunk-5MRSFLQA.js";import{b as o}from"./chunk-W22ESUYY.js";import"./chunk-DSPLGTQI.js";import{c as te,e as ie,g as M}from"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";var K="indiana-visual-diagnostics-v1",Ae=o.strictObject({environmentId:o.string().uuid(),release:o.string().regex(/^[a-f0-9]{64}$/).nullable(),generation:o.string().regex(/^[a-f0-9]{64}$/).nullable(),publishedGeneration:o.string().regex(/^[a-f0-9]{64}$/).nullable(),checkedAt:o.string().datetime(),origin:o.string().url(),pathname:o.string().max(2048),urlMatches:o.boolean(),stopped:o.boolean(),rows:o.array(o.strictObject({changeId:o.string().regex(/^[a-f0-9]{64}$/),experimentKey:o.string().max(256),variationKey:o.string().max(256),inExperiment:o.boolean(),fingerprint:o.string().regex(/^[a-f0-9]{64}$/),status:o.enum(["inactive","waiting","partial","applied","mismatch","no_changes","unavailable","error"]),total:o.number().int().min(0).max(600),applied:o.number().int().min(0).max(600)})).max(100)});function ye(e){let l=n=>Array.isArray(n)?"["+n.map(l).join(",")+"]":n&&typeof n=="object"?"{"+Object.entries(n).filter(([,c])=>c!==void 0).sort(([c],[y])=>c.localeCompare(y)).map(([c,y])=>JSON.stringify(c)+":"+l(y)).join(",")+"}":JSON.stringify(n);return l({css:e.css,js:e.js,domMutations:e.domMutations,...e.renderGuard?{renderGuard:e.renderGuard}:{}})}function he(e){let l=new URL(e.baseUrl),n=l.origin==="https://api.longplayai.com"||l.origin==="https://api.dev.longplayai.com"?l.hostname.slice(4):void 0,c=e.origins??(n?[`https://console.${n}`]:[]),y=new Set(c.filter(t=>{try{let i=new URL(t);return i.origin===t&&(i.protocol==="https:"||i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))}catch{return!1}})),v=!1,I=!1,k=0,T=async t=>{if(v||I||!t.source||!y.has(t.origin)||!t.data||typeof t.data!="object")return;let i=t.data;if(!(i.channel!==K||i.type!=="inspect"||i.environmentId!==e.environmentId||typeof i.nonce!="string"||!/^[a-f0-9-]{36}$/i.test(i.nonce)||typeof i.changeId!="string"||!/^[a-f0-9]{64}$/.test(i.changeId)||typeof i.url!="string"||i.url.length>2048||Date.now()-k<250)){try{if(new URL(i.url).origin!==location.origin)return}catch{return}I=!0,k=Date.now();try{let x=await e.inspect(i.changeId,i.url);!v&&x.rows.some(S=>S.changeId===i.changeId)&&t.source.postMessage({channel:K,type:"result",nonce:i.nonce,snapshot:x},t.origin)}finally{I=!1}}},u=t=>{T(t).catch(()=>{})};return window.addEventListener("message",u),()=>{v=!0,window.removeEventListener("message",u)}}var R=e=>!!e&&typeof e=="object"&&!Array.isArray(e),E=(e,l)=>typeof e=="string"&&e.length<=l,Ee=e=>typeof e=="string"&&(["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(e)||/^(aria|data)-[a-z0-9_-]+$/.test(e));function ke(e){if(!R(e)||!E(e.css??"",1e5)||!E(e.js??"",1e5)||!Array.isArray(e.domMutations??[])||Array.isArray(e.domMutations)&&e.domMutations.length>200)throw new Error("Invalid visual variation");let l=e.domMutations??[];for(let n of l)if(!R(n)||!E(n.selector,2048)||!n.selector||!Ee(n.attribute)||!["set","append","remove"].includes(String(n.action))||n.value!==void 0&&!E(n.value,5e4)||n.parentSelector!==void 0&&!E(n.parentSelector,2048)||n.insertBeforeSelector!==void 0&&!E(n.insertBeforeSelector,2048))throw new Error("Invalid visual mutation");return{css:e.css??"",js:e.js??"",domMutations:l,...e.renderGuard===void 0?{}:{renderGuard:le(e.renderGuard)}}}function q(e){if(!R(e)||typeof e.environmentId!="string"||typeof e.trackExposures!="boolean"||!/^[-a-f0-9]{36}$/i.test(e.environmentId)||typeof e.generation!="string"||!/^[a-f0-9]{64}$/.test(e.generation)||!Array.isArray(e.experiments)||e.experiments.length>100||!R(e.savedGroups))throw new Error("Invalid visual experiment payload");let l=e.experiments.map(n=>{if(!R(n)||!["key","changeId"].every(c=>typeof n[c]=="string"&&n[c])||!/^[a-f0-9]{64}$/.test(String(n.changeId))||["namespace","status","groups","url"].some(c=>Object.hasOwn(n,c))||n.hashVersion!==void 0&&n.hashVersion!==2||!Array.isArray(n.variations)||n.variations.length<2||n.variations.length>20||n.urlPatterns!==void 0&&!Array.isArray(n.urlPatterns))throw new Error("Invalid visual experiment");return{...n,variations:n.variations.map(ke)}});return{...e,experiments:l}}var ve=6e4;function qe(e){let l=se(e.baseUrl);if(e.appManifestRelease!==void 0&&!/^[a-f0-9]{64}$/.test(e.appManifestRelease))throw new Error("Invalid IAM manifest digest");if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("Invalid App environment ID");let n=e.fetch??globalThis.fetch.bind(globalThis),c=F(n),y=F(n),v=`${l}/api/v1/visual-experiments/${e.environmentId}`,I=e.appManifestRelease?`${v}?iam=${e.appManifestRelease}`:v,k=re(e.deviceIdCookie??"indiana_did"),T=ae(),u=null,t=!1,i=!1,x="",S={...e.attributes??{}},G,B,D=0,H=-1/0,$,m=new Map,O=new Map,C=new Set,z=ge({endpoint:`${v}/events`,fetch:n,log:e.log,label:"Visual exposure"}),P=z.flush,W,b;function j(){clearTimeout(W),b?.remove(),b=void 0}function Y(s,d){let f=M(s,d);C.has(f)||e.trackExposures===!1||u?.trackExposures===!1||t||(C.add(f),z.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:k,...T?{sessionId:T}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:s.key,variationKey:d.key}))}function we(s){if(!u||t)return;let d=new Set,f={onExperimentViewed:(r,p)=>{d.add(M(r,p))},url:location.href,attributes:{...me(k,location),...S,indianaAppManifestRelease:e.appManifestRelease??null},savedGroups:te(u.savedGroups),log:e.log},h=new Set;for(let r of u.experiments){if(de(`${e.environmentId}:${r.key}`))continue;let p=r;try{let a=ie(p,f);if(O.set(r.changeId,a),!a.inExperiment)continue;h.add(r.changeId);let w=JSON.stringify([a.key,a.value]),U=m.get(r.changeId);if(U?.signature===w){d.has(M(p,a))&&s.push(()=>{U.applied()&&Y(p,a)});continue}m.get(r.changeId)?.revert(),m.delete(r.changeId);let A=fe(a.value,{requireUniqueTargets:!!e.appManifestRelease&&Array.isArray(r.condition?.$and)&&r.condition.$and.some(g=>g!==null&&typeof g=="object"&&!Array.isArray(g)&&g.indianaAppManifestRelease===e.appManifestRelease),boundVariations:r.variations,allowJs:e.disableJsInjection===!1,nonce:e.nonce,onApplied:()=>{d.has(M(p,a))&&Y(p,a)},onError:g=>e.log?.("Visual experiment stopped",{experiment:r.key,changeId:r.changeId,variation:a.key,error:String(g)}),onTargetStatus:e.log?g=>e.log?.("Visual target status changed",{experiment:r.key,changeId:r.changeId,variation:a.key,...g}):void 0});m.set(r.changeId,{signature:w,revert:A.revert,applied:()=>A.applied,inspect:()=>A.inspect()})}catch(a){e.log?.("Skipping visual experiment",{experiment:r.key,error:String(a)})}}for(let[r,p]of m)h.has(r)||(p.revert(),m.delete(r));j()}let V=()=>{let s=[];pe(()=>we(s));for(let d of s)d()};async function _(){let s=++D,d;try{d=await c.read(I,J)}catch(h){if(t||s!==D)return!1;throw h}let f=q(d);if(f.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Visual payload scope changed");return t||s!==D?!1:(u=f,H=performance.now(),!0)}async function Q(){!await _()||t||(N(),V())}function L(){clearTimeout($),$=setTimeout(()=>{if(document.visibilityState==="hidden")return L();Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()})},ve)}let X=()=>{t||document.visibilityState==="hidden"||performance.now()-H<ve||(clearTimeout($),Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()}))},Ie=()=>{x!==location.href&&(x=location.href,V())},Z=()=>{P(!0)},N=()=>{G||t||(G=oe(Ie),addEventListener("pagehide",Z),x=location.href)};async function ee(s,d){let f=location.href,h=u,r=[],p=null;if(!t)try{let a=q(await y.read(I,J));a.environmentId===e.environmentId&&(p=a.generation)}catch{}for(let a of h?.experiments??[]){if(s&&a.changeId!==s)continue;let w=O.get(a.changeId);if(!w)continue;let U=new TextEncoder().encode(ye(w.value)),A=[...new Uint8Array(await crypto.subtle.digest("SHA-256",U))].map(be=>be.toString(16).padStart(2,"0")).join(""),g=m.get(a.changeId)?.inspect()??{status:"inactive",total:0,applied:0};r.push({changeId:a.changeId,experimentKey:a.key,variationKey:w.key,inExperiment:w.inExperiment,fingerprint:A,...g})}return{environmentId:e.environmentId,release:e.appManifestRelease??null,generation:h?.generation??null,publishedGeneration:p,checkedAt:new Date().toISOString(),origin:location.origin,pathname:location.pathname,urlMatches:location.href===f&&(!d||d===f)&&h===u,stopped:t,rows:r}}let ne,xe=ue(()=>{i&&!t&&V()});return{async start(){if(!(i||t)){i=!0,e.appManifestRelease&&(B=ce(e.appManifestRelease)),e.antiFlicker&&(b=document.createElement("style"),e.nonce&&(b.nonce=e.nonce),b.textContent="body { visibility: hidden !important }",document.head.append(b),W=setTimeout(j,Math.min(3e3,Math.max(0,e.antiFlickerTimeout??1e3))));try{if(!await _()||t)return;N(),V()}finally{j(),t||(L(),document.addEventListener("visibilitychange",X),ne=he({environmentId:e.environmentId,baseUrl:l,origins:e.diagnosticsOrigins,inspect:ee}))}}},async refresh(){t||await _()&&(i&&N(),V())},setAttributes(s){S={...s},V()},flush:()=>P(),getDiagnostics:ee,getResults(){return new Map(O)},get generation(){return u?.generation??null},destroy(){t=!0,clearTimeout($),document.removeEventListener("visibilitychange",X),xe(),ne?.(),D++,c.destroy(),y.destroy(),G?.(),B?.destroy(),removeEventListener("pagehide",Z),j();for(let s of m.values())s.revert();m.clear(),P(!0),u=null,O.clear(),C.clear(),S={}}}}export{qe as createVisualExperiments,Ve as loadAppManifestRelease};
|
package/package.json
CHANGED
package/dist/chunk-3BLTEKHB.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as n,r as t}from"./chunk-OYN2KWCV.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
|
package/dist/chunk-6YGUSY4G.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as Me}from"./chunk-XLGNBPGF.js";import{a as Z}from"./chunk-EQUVI5QU.js";import{D as X,F as Ye,c as De,e as Y,j as Ve,u as Ge,v as ze,x as Qe,z as Be}from"./chunk-OYN2KWCV.js";import{a as xe,b as Ue,c as Te}from"./chunk-S2S4ROGY.js";import{b as ce}from"./chunk-Y55OBV7D.js";import{i as le}from"./chunk-MOIVJERE.js";import{K as B}from"./chunk-ME6QTD5Y.js";import{A as ue,B as W,C as Q,E as je}from"./chunk-3532HSBP.js";import{x as ve}from"./chunk-67WFVDTV.js";import{b as Le}from"./chunk-Y625SYGQ.js";import{a as l}from"./chunk-UGATOG2T.js";import{h as se}from"./chunk-LFR2LWYC.js";import{a as He}from"./chunk-5MRSFLQA.js";import{b as o}from"./chunk-W22ESUYY.js";import{a as Ce}from"./chunk-DSPLGTQI.js";var C=B.options,lt=o.discriminatedUnion("operation",[C[1].omit({customerToken:!0}),C[2].omit({customerToken:!0}),C[3].omit({customerToken:!0}),C[4].omit({customerToken:!0}),C[5].omit({customerToken:!0}),C[6].omit({customerToken:!0}),C[7].omit({customerToken:!0}),C[8].omit({customerToken:!0}),Ve.omit({customerToken:!0})]),Re=o.strictObject({receiptId:o.uuid(),operationId:o.uuid()}),vt=o.discriminatedUnion("operation",[o.strictObject({operation:o.literal("find_purchase")}),o.strictObject({operation:o.literal("recover_start"),intent:o.enum(["lookup","resume","start"]),start:o.strictObject({requestId:C[0].shape.requestId,funnelId:C[0].shape.funnelId,locale:C[0].shape.locale,parameters:C[0].shape.parameters})}),o.strictObject({operation:o.literal("recover_run"),runId:o.uuid(),funnelId:o.uuid()}),o.strictObject({operation:o.literal("recover_purchase"),runId:o.uuid(),funnelId:o.uuid(),purchase:Re,includePaywallVersion:o.literal(!0).optional()}),o.strictObject({operation:o.literal("terminate_checkout"),runId:o.uuid(),funnelId:o.uuid(),purchase:Re,intent:o.literal("expire_unconfirmed_quote").optional()}),o.strictObject({operation:o.literal("settle_command"),runId:o.uuid(),funnelId:o.uuid(),requestId:o.uuid(),command:o.discriminatedUnion("operation",[C[3].omit({customerToken:!0}),C[4].omit({customerToken:!0}),C[5].omit({customerToken:!0}),C[6].omit({customerToken:!0}),C[7].omit({customerToken:!0})]).optional()}).refine(s=>!s.command||s.requestId===s.command.requestId),o.strictObject({operation:o.literal("run_command"),runId:o.uuid(),funnelId:o.uuid(),command:lt})]),de=o.strictObject({runId:o.uuid(),funnelId:o.uuid(),versionId:o.uuid(),startRequestId:o.uuid(),runExpiresAt:o.iso.datetime({offset:!0}),status:Y.shape.run.shape.status}),M={scope:se,customerId:o.uuid()},Je=o.discriminatedUnion("outcome",[o.strictObject({...M,outcome:o.literal("unknown"),target:o.null(),view:o.null(),access:o.null()}),o.strictObject({...M,outcome:o.literal("resolved"),target:de,view:Y.shape.run.nullable(),access:o.discriminatedUnion("type",[o.strictObject({type:o.literal("customer")}),o.strictObject({type:o.literal("operation_only"),cause:o.enum(["run_terminal","run_expired","run_revoked","issuer_unavailable"])})])})]).superRefine((s,d)=>{s.outcome==="resolved"&&(s.access.type==="customer"!=(s.view!==null)||s.view&&(s.view.id!==s.target.runId||s.view.source.id!==s.target.funnelId||s.view.source.versionId!==s.target.versionId||s.view.status!==s.target.status||s.view.runExpiresAt!==s.target.runExpiresAt||s.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Recovery view and original Run binding differ"})}),Ke=o.strictObject({...M,target:de,view:Y.shape.run.nullable(),settlement:o.strictObject({requestId:o.uuid(),state:o.enum(["pending","unknown","settled"]),acceptance:o.enum(["accepted","not_accepted","unknown"]),receiptPhase:o.enum(["accepted","processing","done"]).nullable(),basis:o.enum(["receipt","run_terminal","position_advanced","none"]),receiptId:o.uuid().nullable(),operationId:o.uuid().nullable()}),purchase:Y.shape.purchase.unwrap().nullable()}).superRefine((s,d)=>{let f=s.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))||s.purchase&&(s.purchase.receiptId!==f.receiptId||s.purchase.operation&&s.purchase.operation.operationId!==f.operationId||s.purchase.quote&&s.purchase.quote.operationId!==f.operationId)||s.view&&(s.view.id!==s.target.runId||s.view.source.id!==s.target.funnelId||s.view.source.versionId!==s.target.versionId||s.view.status!==s.target.status||s.view.runExpiresAt!==s.target.runExpiresAt||s.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Original command settlement binding differs"})}),$e=o.strictObject({...M,target:de,purchase:Y.shape.purchase.unwrap(),paywallVersionId:o.uuid().optional()}).superRefine((s,d)=>{(!s.purchase.operation||typeof s.purchase.canReselect!="boolean"||s.purchase.quote&&s.purchase.quote.operationId!==s.purchase.operation.operationId)&&d.addIssue({code:"custom",message:"Original purchase proof is incomplete"})}),We=o.discriminatedUnion("outcome",[o.strictObject({...M,outcome:o.literal("none")}),o.strictObject({...M,outcome:o.literal("blocked")}),o.strictObject({...M,outcome:o.literal("found"),target:de,start:o.strictObject({locale:C[0].shape.locale,parameters:C[0].shape.parameters}),purchase:Re})]);var dt=B.options[0].refine(s=>!s.customer&&!s.customerData),pt=o.strictObject({receiptId:o.uuid(),operationId:o.uuid(),terminal:o.enum(["complete","native"]).nullable()}),Xe=o.strictObject({schemaVersion:o.literal(1),baseUrl:o.url(),scope:se,customerId:o.uuid(),sessionId:o.uuid(),start:dt,allowed:o.array(o.enum(["merchant","record_only","indiana","native"])),run:o.strictObject({id:o.uuid(),versionId:o.uuid(),status:De.shape.status,revision:o.number().int().nonnegative(),runExpiresAt:o.iso.datetime({offset:!0}).optional()}).optional(),purchases:o.array(pt).max(100),operationCommand:o.strictObject({operationId:o.uuid(),intent:o.literal("confirm")}).optional(),journal:o.strictObject({revision:o.number().int().nonnegative(),entry:Ge.nullable()})});function Ze(s){return Qe({...s,namespace:"purchases",identity:[s.scope.projectId,s.scope.environment,s.customerId]})}function et(s){let d=new URL(s.baseUrl??He).href,f=()=>new l("PURCHASE_STORAGE_INVALID","Purchase recovery storage is unavailable or invalid; native fallback is not authorized");async function R(){s.assertCurrent();try{let S=await s.storage.read();if(s.assertCurrent(),!Number.isSafeInteger(S.revision)||S.revision<0)throw f();let c=S.entry===null?null:Xe.parse(S.entry);if(c&&(c.baseUrl!==d||c.customerId!==s.customerId||c.scope.projectId!==s.scope.projectId||c.scope.environment!==s.scope.environment))throw new l("SCOPE_MISMATCH","Purchase recovery belongs to another Customer or environment");if(c?.journal.entry&&(c.journal.entry.scope.projectId!==c.scope.projectId||c.journal.entry.scope.environment!==c.scope.environment||c.journal.entry.funnelId!==c.start.funnelId||c.journal.entry.runId!==c.run?.id||c.journal.entry.versionId!==c.run?.versionId)||c?.operationCommand&&!c.purchases.some(F=>F.operationId===c.operationCommand?.operationId))throw f();return{revision:S.revision,entry:c}}catch(S){throw S instanceof l?S:f()}}async function ee(S){for(let c=0;c<8;c++){let F=await R(),O=S(structuredClone(F.entry));if(JSON.stringify(O)===JSON.stringify(F.entry))return O;O&&Xe.parse(O),s.assertCurrent();let x;try{x=await s.storage.write(F.revision,O)}catch{throw f()}if(s.assertCurrent(),x!==null){if(!Number.isSafeInteger(x)||x<=F.revision)throw f();return O}}throw new l("PURCHASE_STORAGE_CONFLICT","Another consumer changed this purchase; recover the original attempt")}return{read:R,update:ee,baseUrl:d}}var mt=5*6e4,ft=2e3;function ht(s,d){let f=s.purchases.find(R=>R.type==="checkout");if(!s.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 Jt(s){let d={...s,scope:{...s.scope},executionPolicy:structuredClone(s.executionPolicy)},f=d.session.snapshot();if(!f)throw new l("CUSTOMER_SESSION_REQUIRED","Purchase recovery requires a verified Customer session");let{customerId:R,sessionId:ee}=f,S=!1,c=null,F,O,x=null,k=!1,U,te,ne,_={mode:"idle",status:"idle",actions:["start"],purchases:[]},g=new Map,Se=new Map,T=new Map,pe=new AbortController,re=new Set,J=Le(d),oe=Me(J.request);function K(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 P(){if(S||d.session.snapshot()?.customerId!==R)throw new l("IDENTITY_CHANGED","The original purchase Customer changed")}let w=et({...d,customerId:R,assertCurrent:P,storage:d.storage??Ze({baseUrl:d.baseUrl,scope:d.scope,customerId:R})}),tt,Ee=()=>tt??=import("./funnel-paywall-copies-LPOTYSTS.js").then(({createPaywallCopies:e})=>e({baseUrl:d.baseUrl,scope:d.scope,customerId:R})),nt={read:async e=>(await Ee()).read(e),write:async(e,t)=>(await Ee()).write(e,t)},rt=d.session.subscribeIdentity(be);function be(){S||(S=!0,clearTimeout(ne),pe.abort(new l("IDENTITY_CHANGED","Purchase consumer was destroyed")),rt(),c?.reset(),c=null,x=null,J.dispose(),re.clear(),g.clear(),T.clear())}function v(e){P();let t=JSON.stringify(e)!==JSON.stringify(_);_=e,clearTimeout(ne),(e.mode==="operation"||e.mode==="run"&&!e.actions.includes("close"))&&["waiting_result","fulfillment","recording"].includes(e.status)&&(ne=setTimeout(()=>{z().catch(()=>{})},5e3)),t&&Ce(d.onRecovery,structuredClone(e));for(let n of t?re:[]){if(S)break;Ce(n,structuredClone(e))}return structuredClone(e)}function y(e){if(P(),!e||e.start.requestId!==O)throw new l("PURCHASE_STORAGE_CONFLICT","This purchase was superseded; the old consumer cannot dispatch")}function _e(e){return!e.run&&!E(e).length&&!e.journal.entry&&!e.operationCommand}function me(e){let t=e.journal.entry,n=r=>!r||r.operation==="close"||r.operation==="back"||r.operation==="shown"||r.operation==="submit"&&r.input.type==="screen";return!E(e).length&&!e.operationCommand&&n(t?.command)&&n(t?.closeCommand)}function G(e){return!!e.run&&me(e)}function E(e){let t=[...e.purchases],n=e.journal.entry?.purchase;return n&&!t.some(r=>r.operationId===n.operationId)&&t.push({receiptId:n.receiptId,operationId:n.operationId,terminal:null}),t}function N(e){let t=E(e),n=k&&t.length>0&&t.every(r=>r.terminal==="native"&&V(g.get(r.operationId))==="native")&&t.some(r=>{let a=g.get(r.operationId);return!a||T.get(r.operationId)!==!0?!1:Q(a)?!0:a.status==="cancelled"&&a.confirmedAt===null&&!a.quoteFinalized&&!a.merchantExecution&&!a.problem&&!!a.quote&&Date.parse(a.quote.expiresAt)<=Date.now()});return e.run&&(n||!["running","waiting"].includes(e.run.status))&&!e.journal.entry?.command&&!e.journal.entry?.closeCommand&&!e.operationCommand&&t.every(r=>r.terminal!==null)}function A(e,t){let n=e.journal.entry?.command??e.journal.entry?.closeCommand,r=E(e).map(I=>{let b=g.get(I.operationId),L=ce({quote:b?.quote??null,operation:b??null,requestId:n?.requestId??null,pending:!1,destroyed:!1,canReselect:T.get(I.operationId)===!0});return I.terminal&&(L.type==="checkout"||L.type==="recover"||L.type==="cancel")?{type:I.terminal,operationId:I.operationId}:L}),a=r.filter(I=>!["complete","native"].includes(I.type)),u=a[0],i=a.length===1&&u?.operationId?g.get(u.operationId):void 0;if(i&&(u?.type==="checkout"||u?.type==="cancel"))try{X({allowed:e.allowed.filter(I=>d.executionPolicy.allowed.includes(I))},i.quote)}catch(I){return{mode:t,status:"blocked",actions:["refresh",...t==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[]],purchases:r,error:K(I)}}let m;if(t==="operation"&&!n&&u?.type==="cancel"&&i?.quote&&!i.problem&&!i.confirmedAt)try{X({allowed:e.allowed.filter(I=>d.executionPolicy.allowed.includes(I))},i.quote),Date.parse(i.quote.expiresAt)>Date.now()&&(m={operationId:i.operationId,quote:i.quote})}catch{}let p=r.length>0&&a.length===0,h=N(e)||t==="operation"&&p&&!n&&!e.operationCommand?"complete":u?.type==="checkout"?"checkout":u?.type==="fulfillment"?"fulfillment":u?.type==="recording"?"recording":n||e.operationCommand||u&&u.type!=="cancel"||t==="operation"&&!m?"waiting_result":"ready";return{mode:t,status:h,purchases:r,...m?{confirmation:structuredClone(m)}:{},actions:["refresh",...N(e)||G(e)?["start"]:[],...t==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[],...e.operationCommand?["retry"]:m?["confirm"]:[],...a.length===1&&u?.type==="checkout"?["continue_checkout"]:[]]}}function V(e){let t=ce({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 fe(e){if(!e.operation)return;let t=ue.parse({...e.operation,...e.operation.quote?{}:e.quote?{quote:e.quote}:{}});if(t.merchantExecution&&t.merchantExecution.customerId!==R)throw new l("SCOPE_MISMATCH","Purchase execution belongs to another Customer");let n=le(g.get(t.operationId)??null,t);g.set(t.operationId,n),n===t&&T.set(t.operationId,e.canReselect===!0)}async function ot(e){P();for(let n of[e.purchase,e.run.paywall])n&&fe(n);let t=await w.update(n=>{if(y(n),n.run&&(n.run.id!==e.run.id||n.run.versionId!==e.run.source.versionId))throw new l("SCOPE_MISMATCH","The original purchase Run changed");let r=E(n);for(let a of[e.purchase,e.run.paywall]){let u=a?.operation?.operationId??a?.quote?.operationId;if(!a||!u)continue;let i=r.find(p=>p.operationId===u);if(i&&i.receiptId!==a.receiptId)throw new l("INVALID_RESPONSE","The original purchase Receipt changed");let m=V(g.get(u));i?i.terminal??=m:r.push({receiptId:a.receiptId,operationId:u,terminal:m})}return{...n,purchases:r,run:n.run&&(n.run.revision>e.run.revision||!["running","waiting"].includes(n.run.status)&&["running","waiting"].includes(e.run.status))?n.run:{id:e.run.id,versionId:e.run.source.versionId,status:e.run.status,revision:e.run.revision,runExpiresAt:e.run.runExpiresAt}}});y(t),t.run&&!["running","waiting"].includes(t.run.status)&&E(t).some(n=>!n.terminal)&&(t=await H(t,!t.journal.entry?.command&&!t.journal.entry?.closeCommand,new Set([e.purchase?.operation?.operationId,e.run.paywall?.operation?.operationId].filter(n=>!!n)))),y(t),v(A(t,"run"))}function at(){return{async read(){let{entry:e}=await w.read();return y(e),structuredClone(e.journal)},async write(e,t){let n=null;return await w.update(r=>{if(y(r),r.operationCommand&&t?.command&&t.command.operation!=="close")throw new l("PURCHASE_PENDING","Recover the original Operation command before dispatching a Run mutation");return n=null,r.journal.revision!==e?r:(n=e+1,{...r,journal:{revision:n,entry:t}})}),n}}}async function H(e,t=!1,n=new Set){y(e);let r=E(e);for(let u of r){if(u.terminal)continue;let i=n.has(u.operationId)?g.get(u.operationId):void 0;if(i??=await D(e,u),P(),i.operationId!==u.operationId)throw new l("INVALID_RESPONSE","Original Operation changed");if(i.merchantExecution&&i.merchantExecution.customerId!==R)throw new l("SCOPE_MISMATCH","Purchase execution belongs to another Customer");if(t&&!e.operationCommand&&ce({quote:i.quote??null,operation:i,requestId:null,pending:!1,destroyed:!1}).type==="cancel"){let m=Q(i)?await oe.update({operationId:u.operationId,intent:"cancel"}):await oe.attach({operationId:u.operationId,intent:"cancel"});if(i=ue.parse(m.operation),P(),i.operationId!==u.operationId)throw new l("INVALID_RESPONSE","Original cancellation Operation changed");i=await D(e,u)}g.set(u.operationId,le(g.get(u.operationId)??null,i))}let a=await w.update(u=>{y(u);let i=u.operationCommand&&g.get(u.operationCommand.operationId);return{...u,...i&&(i.confirmedAt||i.merchantExecution||!je(i))?{operationCommand:void 0}:{},purchases:E(u).map(m=>({...m,terminal:m.terminal??V(g.get(m.operationId))}))}});return y(a),a}async function $(e){P();let t=await J.request("funnels",e);return P(),t}async function it(e){try{return await $(e)}catch(t){if(e.operation!=="recover_start"||e.intent!=="start"||!(t instanceof l)||t.status!==400||t.code!=="INVALID_REQUEST")throw t;return $({...e,intent:"resume"})}}async function st(){let e=Z(We,await $({operation:"find_purchase"}));if(e.customerId!==R||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:n}=e;return await w.update(r=>r&&!N(r)&&!G(r)?r:{schemaVersion:1,baseUrl:w.baseUrl,scope:d.scope,customerId:R,sessionId:ee,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:[{...n,terminal:null}],journal:{revision:0,entry:null}}),"found"}let ae;function he(e){let t=ae;if(t&&(!t.outcome||e&&t.outcome==="none"&&Date.now()-t.at<mt))return t.job;let n={at:Date.now(),job:st().then(r=>(n.outcome=r,n.at=Date.now(),r),r=>{throw ae===n&&(ae=void 0),r})};return ae=n,n.job}async function D(e,t,n="recover_purchase",r=!1){let a={runId:e.run.id,funnelId:e.start.funnelId,purchase:{receiptId:t.receiptId,operationId:t.operationId}},u=n==="recover_purchase"?{...a,operation:n,...r?{includePaywallVersion:!0}:{}}:{...a,operation:"terminate_checkout",...n==="expire_unconfirmed_quote"?{intent:n}:{}},i=Z($e,await $(u));if(we(e,i),i.purchase.receiptId!==t.receiptId||i.purchase.operation?.operationId!==t.operationId)throw new l("INVALID_RESPONSE","Original purchase reference changed");return fe(i.purchase),r&&i.paywallVersionId&&Se.set(t.operationId,i.paywallVersionId),g.get(t.operationId)}async function qe(e){for(let t of[e.journal.entry?.command,e.journal.entry?.closeCommand]){if(!t)continue;let n=Z(Ke,await $({operation:"settle_command",runId:e.run.id,funnelId:e.start.funnelId,requestId:t.requestId,...t.operation==="resume"?{}:{command:t}}));if(we(e,n),n.settlement.requestId!==t.requestId)throw new l("INVALID_RESPONSE","Original command settlement changed");n.purchase&&fe(n.purchase);let r=await w.update(a=>{y(a);let u=E(a),{receiptId:i,operationId:m}=n.settlement;if(i&&m){let h=u.find(I=>I.operationId===m);if(h&&h.receiptId!==i)throw new l("INVALID_RESPONSE","Original Receipt changed");h||u.push({receiptId:i,operationId:m,terminal:V(g.get(m))})}let p=n.settlement.state==="settled"?ze(a.journal.entry,t.requestId):a.journal.entry;return{...a,purchases:u,journal:p===a.journal.entry?a.journal:{revision:a.journal.revision+1,entry:p}}});y(r),e=r}return e}function we(e,t){if(t.customerId!==R||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 Ie(e,t){if(y(e),e.run&&(e=await qe(e)),!E(e).length&&N(e))return v(A(e,"operation"));if(me(e)){let a=e.start.requestId;if(!await w.update(i=>i&&i.start.requestId===a&&me(i)?null:i))return c?.reset(),c=null,k=!1,v({mode:"idle",status:"idle",actions:["start"],purchases:[]})}if(!E(e).length)return v({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:K(t)});k=!0;let n=E(e);if(e.run&&["running","waiting"].includes(e.run.status)&&n.every(a=>a.terminal==="native"))for(let a of n)V(g.get(a.operationId))!=="native"&&await D(e,a);let r=await ut(await H(e));return v(A(r,"operation"))}async function ut(e){if(e.journal.entry?.command||e.journal.entry?.closeCommand||e.operationCommand)return e;let t=E(e).filter(u=>!u.terminal),n=t[0];if(!n||t.length!==1)return e;let r=g.get(n.operationId),a=r?.quote;if(!r||Q(r)||!a||W(a)||a.provider!=="merchant"||r.status!=="pending"||r.confirmedAt!==null||r.quoteFinalized||r.checkoutUrl||r.nativePurchase||r.merchantExecution||r.problem||Date.parse(a.expiresAt)>Date.now())return e;try{await D(e,n,"expire_unconfirmed_quote")}catch{return P(),e}return H(e,!1,new Set([n.operationId]))}async function ie(e,t=!1,n=!0,r=!1){if(O=e.start.requestId,x=structuredClone({requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}),!c){let a=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}},u;try{u=await it(a)}catch(h){if(!e.run&&h instanceof l&&(h.status===void 0||h.status>=500))return v({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:_.purchases,error:K(h)});throw h}let i=Z(Je,u);if(i.customerId!==R||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"){if(!t&&_e(e)){let h=e.start.requestId;if(!await w.update(b=>b&&b.start.requestId===h&&_e(b)?null:b))return v({mode:"idle",status:"idle",actions:["start"],purchases:[]})}return v({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:_.purchases,error:{code:"RESULT_UNKNOWN",message:"The original Start outcome remains unknown; retry only its original input"}})}we(e,i);let m=await w.update(h=>(y(h),{...h,run:{id:i.target.runId,versionId:i.target.versionId,status:i.target.status,revision:i.view?.revision??h.run?.revision??0,runExpiresAt:i.target.runExpiresAt}}));if(y(m),e=m,i.access.type==="operation_only")return Ie(e,new l("RUN_RECONCILIATION_REQUIRED","Only the original command and Operation can be recovered"));e=await qe(e);let p=i.view;if(p.locale!==e.start.locale||!Be(p.parameters,e.start.parameters))throw new l("INVALID_RESPONSE","The original Start input changed");c=Ye({...d,customerRun:{runId:i.target.runId,customerId:R,startRequestId:e.start.requestId},funnelId:e.start.funnelId,funnelExecutionPolicy:{allowed:e.allowed.filter(h=>d.executionPolicy.allowed.includes(h))},funnelCommandStorage:at(),onAcceptedResponse:ot},{scope:i.scope,run:p})}try{let a=r&&F?.controller===c?performance.now()-F.at:1/0;(a>=ft||c.pendingCommands?.length||(c.viewAgeMs??0)<a)&&(F=void 0,await c.get(),F={controller:c,at:performance.now()}),c.view?.pendingRequest?.requestId===e.start.requestId&&!c.pendingCommands?.length&&await c.resume(c.view.pendingRequest.requestId);for(let i of c.pendingCommands??[])i.operation!=="close"&&await c.settle?.(i.requestId);c.pendingCommands?.length&&await c.retry(),P();let u=(await w.read()).entry;return y(u),v(A(u,"run"))}catch(a){if(P(),n&&a instanceof l&&(a.status===401||a.status===409&&a.reason==="STATE_CHANGED")){c.reset(),c=null;let u=(await w.read()).entry;return y(u),ie(u,!1,!1,!1)}throw a}}function j(e,t="read",n){if(P(),U)return t==="read"||t===te?U:U.then(()=>j(e,t,n),()=>j(e,t,n));clearTimeout(ne);let r=e().catch(a=>{throw!S&&!n?.(a)&&v({mode:"blocked",status:"blocked",actions:["refresh"],purchases:_.purchases,error:K(a)}),a});return U=r,te=t,r.then(()=>{U===r&&(U=void 0,te=void 0)},()=>{U===r&&(U=void 0,te=void 0)}),r}function z(e){let t=e?.reuseRecentRead===!0;return j(async()=>{let{entry:n}=await w.read();if(!n||N(n)){if(await he(!1)==="blocked")return Oe();({entry:n}=await w.read())}return n?(O&&n.start.requestId!==O&&(c?.reset(),c=null,g.clear(),T.clear(),k=!1),k&&O===n.start.requestId?Ie(n,_.error):ie(n,!1,!0,t)):v({mode:"idle",status:"idle",actions:["start"],purchases:[]})})}function Oe(){return v({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:K(new l("PURCHASE_PENDING","Check the outstanding purchases before starting another"))})}async function Fe(){let e=await z();return e.mode==="operation"&&!e.actions.includes("confirm")&&!e.actions.includes("retry")?e:j(async()=>{let t=(await w.read()).entry;if(y(t),!k){if(!c?.view?.paywall?.quote)throw new l("PURCHASE_PENDING","Read the original quote before confirming");let p=c.view.paywall.operation;if(p?.confirmedAt||p?.merchantExecution||p&&!(Q(p)?["prepared","quoted"].includes(p.status):p.status==="pending"))return v(A(t,"run"));if(c.pendingCommands?.length)await c.retry();else{let I=c.view;await c.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:I.nodeId,visit:I.visit,revision:I.revision,input:{type:"paywall_confirm",operationId:I.paywall.quote.operationId,...I.paywall.quote.merchantTerms?{merchantConfirmation:ve(I.paywall.quote.merchantTerms)}:{}}})}let h=(await w.read()).entry;return y(h),v(A(h,"run"))}let n=t.operationCommand?.operationId??_.confirmation?.operationId,r=n&&g.get(n);if(!n||!r||t.journal.entry?.command||t.journal.entry?.closeCommand)throw new l("PURCHASE_PENDING","The original Run command must be settled before Operation confirmation");X({allowed:t.allowed.filter(p=>d.executionPolicy.allowed.includes(p))},r.quote),await w.update(p=>{if(y(p),p.journal.entry?.command||p.journal.entry?.closeCommand||p.operationCommand&&p.operationCommand.operationId!==n)throw new l("PURCHASE_PENDING","Another original command is pending");return{...p,operationCommand:{operationId:n,intent:"confirm"}}});let a={operationId:n,intent:"confirm",...r.quote?.merchantTerms?{merchantConfirmation:ve(r.quote.merchantTerms)}:{}},u=Q(r)?await oe.update(a):await oe.attach(a),i=ue.parse(u.operation);if(P(),u.operation.operationId!==n)throw new l("INVALID_RESPONSE","Original confirmation Operation changed");g.set(n,le(r,i));let m=(await w.read()).entry;return y(m),v(A(await H(m,!1,new Set([n])),"operation"))},"confirm")}function ct(e){let t=e?.quote;return t&&W(t)&&t.timing==="immediate"&&t.execution.provider==="merchant"&&(e.confirmedAt||e.merchantExecution)?t:null}function ke(){if(_.mode!=="operation"||_.status==="blocked")return null;let e=_.purchases.filter(({type:n})=>n!=="complete"&&n!=="native"),t=e.length===1&&e[0]?.operationId;return t?ct(g.get(t)):null}async function Ae(){P();let{entry:e}=await w.read();return e?N(e)||G(e)?"finished":"pending":"none"}return{get controller(){return c},get recovery(){return structuredClone(_)},get attempt(){return P(),structuredClone(x)},get identitySignal(){return pe.signal},get customerId(){return R},retained:Ae,async pendingFunnel(){P();let{entry:e}=await w.read();return e&&!N(e)&&!G(e)?e.start.funnelId:null},get paywallCopies(){return nt},async findPurchase(){let e=await Ae();if(e==="pending")return e;let t=await he(!0);return P(),t==="none"?e:t},async readPaywall(e){P();let t=xe(e),[n,{readPaywallContent:r},{validateResourceCheck:a}]=await Promise.all([Ue(J.request,"resolvePaywall"),import("./paywall-content-5MP2N2SJ.js"),import("./check-response-XGOTG3KL.js")]);P();let u=n.request.parse({selector:t.paywallVersionId?{type:"version",versionId:t.paywallVersionId}:{type:"paywall",paywallId:t.paywallId},commerce:t.commerce,locale:t.locale}),i=await Te(J.request,n,u);a(u,i.paywall.check,i.scope);let m=await r(d,i.paywall);if(P(),t.paywallVersionId?m.id!==t.paywallVersionId:m.paywallId!==t.paywallId)throw new l("INVALID_RESPONSE","The requested Paywall changed");return m},get canRestoreUpgradePaywall(){return ke()!==null},recoverUpgradePaywall(){let e=ke();return e?this.recoverPurchasePaywall(void 0,e.operationId):Promise.resolve(null)},async recoverPurchasePaywall(e,t){if(_.mode!=="operation"||_.status==="blocked")return null;let{entry:n}=await w.read();if(!n?.run)return null;y(n);let r=E(n),a=r.filter(q=>!q.terminal),u=r.filter(q=>q.terminal==="complete"),i=a.length===1?a[0]:a.length?void 0:u.find(q=>e&&e.runId===n.run?.id&&q.receiptId===e.receiptId)??(u.length===1?u[0]:void 0);if(!i||t&&i.operationId!==t)return null;let m=e?.runId===n.run.id&&e.receiptId===i.receiptId?e.view:void 0,p;try{p=await D(n,i,"recover_purchase",!0)}catch(q){if(!(q instanceof l&&q.status===400&&q.code==="INVALID_REQUEST"))throw q;if(!m)return null;p=await D(n,i)}let h=p.quote;if(!h||W(h)&&(h.timing!=="immediate"||h.execution.provider!=="merchant")||!(p.confirmedAt||p.merchantExecution||p.checkoutUrl||V(p)==="complete"))return null;V(p)!=="complete"&&X({allowed:n.allowed.filter(q=>d.executionPolicy.allowed.includes(q))},h);let I=Se.get(i.operationId),b=n.start.parameters?.commerce,L=n.start.locale??"en",ye=m;if(I){if(typeof b!="object"||!b||!("provider"in b)||typeof b.provider!="string"||!("currency"in b)||typeof b.currency!="string")return null;ye=await this.readPaywall({paywallVersionId:I,locale:L,commerce:{provider:b.provider,currency:b.currency,...W(h)?{intent:"subscription_change"}:{}}})}if(!ye)return null;P();let Ne=ye,ge=!1,Pe=async()=>{throw new l("PURCHASE_PENDING","Only the original purchase can be recovered")};return{signal:pe.signal,view:Ne,quote:h,locale:L,get operation(){return p},get canReselect(){return T.get(i.operationId)===!0},async refresh(){return Ne},preview:Pe,confirm:Pe,cancel:Pe,async read(){if(ge)throw new DOMException("Purchase view closed","AbortError");p=await D(n,i);let q=await H(n,!1,new Set([i.operationId]));return ge||v(A(q,"operation")),structuredClone(p)},destroy(){ge=!0}}},start(e){let t=B.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 j(async()=>{let n=(await w.read()).entry;if((!n||N(n)||G(n))&&await he(!0)==="blocked")return Oe();let r=await w.update(a=>{if(a&&!N(a)&&!(G(a)&&a.start.requestId!==t.requestId)){if(a.start.funnelId!==t.funnelId)throw new l("PURCHASE_PENDING","Recover the original Funnel before starting another purchase");return a}return{schemaVersion:1,baseUrl:w.baseUrl,scope:d.scope,customerId:R,sessionId:ee,start:t,allowed:[...d.executionPolicy.allowed],purchases:[],journal:{revision:0,entry:null}}});if(!r)throw new l("PURCHASE_STORAGE_INVALID","Original start was not retained");return O!==r.start.requestId&&(c?.reset(),c=null,g.clear(),T.clear(),k=!1),k?Ie(r,_.error):ie(r,!0,!0,!0)},`start:${t.funnelId}`)},refresh:z,confirm:Fe,retry:()=>k?Fe():j(async()=>{let{entry:e}=await w.read();return e?ie(e,!0):v({mode:"idle",status:"idle",actions:["start"],purchases:[]})},"retry"),async close(){return c?.view?j(async()=>{if(!c?.view)throw new l("PURCHASE_PENDING","Recover the original Run before closing");if(c.pendingCommands?.find(n=>n.operation==="close"))await c.retry();else if(["running","waiting"].includes(c.view.status)){let n=c.view;await c.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:n.revision})}let t=(await w.read()).entry;return y(t),v(A(t,"run"))},"close"):z()},async continueCheckout(e,t){let n=t?await j(async()=>{let{entry:r}=await w.read();if(y(r),!r.run||!E(r).some(u=>u.operationId===t&&!u.terminal))throw new l("PURCHASE_PENDING","The original Checkout changed");let a=await H(r);return v(A(a,k?"operation":"run"))},`continue:${t}`,r=>r instanceof l&&r.code==="PURCHASE_PENDING"):await z();P(),await e(ht(n,t))},async terminateCheckout(e){let t=n=>n.actions.includes("continue_checkout")&&n.purchases.some(r=>r.type==="checkout"&&r.operationId===e);if(!t(_)&&!t(await z()))throw new l("PURCHASE_PENDING","The original Checkout has changed");return j(async()=>{let{entry:n}=await w.read();y(n);let r=E(n).find(u=>u.operationId===e&&!u.terminal);if(!r||!n.run)throw new l("PURCHASE_PENDING","The original Checkout has changed");await D(n,r,"terminate_checkout");let a=await H(n,!1,new Set([e]));return v(A(a,k?"operation":"run"))},`terminate:${e}`,n=>n instanceof l&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(n.code))},subscribe(e){return re.add(e),()=>{re.delete(e)}},destroy:be}}export{Ze as a,ht as b,Jt as c};
|
package/dist/chunk-FSQUQ3J3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as ve,b as be}from"./chunk-7CZEXBQY.js";import{d as Le,e as ne}from"./chunk-MOIVJERE.js";import{a as qe}from"./chunk-UGATOG2T.js";import{a as k}from"./chunk-DSPLGTQI.js";var Qe=5*6e4,Ye=15e3,Te=new WeakMap;function on(c){return Te.get(c)}var V=c=>Array.isArray(c)?c.map(V):c&&typeof c=="object"?Object.fromEntries(Object.keys(c).sort().map(n=>[n,V(c[n])])):c,T=(c,n)=>JSON.stringify(V(c))===JSON.stringify(V(n)),re=c=>JSON.stringify(V([c.funnelId,c.locale??null,c.parameters??{}])),Ze=["onObservationChange","onPurchaseIntent","onPurchase","onCheckoutUrl","resumeCheckout","allowNewPurchase","checkoutNavigation","terminateCheckout","beforeCheckoutReplacement","purchaseConfirmation","confirmOnHostedCheckout","resolveOfferId","prepareSubscriptionChange","resolveSubscriptionChange","onOpenUrl","onEvent","onAction","onComplete","onError"];function en(c,n,C){let H=e=>structuredClone({funnelId:e.funnelId,locale:e.locale,parameters:e.parameters}),m,_="",R=n.start instanceof Promise?void 0:H(n.start),te=e=>e?.parameters?.commerce,j=Promise.resolve(n.start).then(e=>e?H(e):void 0),ae=n.maxAgeMs??Qe,Ie=new AbortController,g=AbortSignal.any([Ie.signal,n.client.identitySignal,...n.signal?[n.signal]:[]]),oe=()=>d("released","aborted"),t="preparing",Ce,J,le=()=>{},U=0,b=null,v=null,S=null,w=null,h,x,E,Se=new Map,P=null,W=new Set,F=new Map,ie,Re=new Promise(e=>ie=e),G,se=new Promise(e=>G=e),ce,je=new Promise(e=>ce=e);function z(e,r){t!==e&&(t=e,Ce=r,k(n.onState,e))}function Je(){g.removeEventListener("abort",oe),X(),v?.destroy(),v=null,b?.remove(),b=null,S=null}function d(e,r){["adopted","unavailable","released","closed"].includes(t)||(z(e,r),Je(),ie(!1),G(!1),B(!1),ce(null))}function M(e){t!=="shown"&&d("unavailable",e)}let f,ue=!1,D=n.client.paywallCopies,de,Ae=new Promise(e=>de=e),fe=!1,N=!1,ke,K=n.whenPurchasePending==="recover"&&!C,B,Ue=new Promise(e=>B=e);function We(e){if(!K||f||!e||!w||!E||!A(w,E.commerce)||!["preparing","ready","shown"].includes(t))return!1;let r={savedAt:Date.now(),funnelId:e,context:E,resolution:structuredClone(w)};return f=r,we(r),Z(),!0}function pe(e){return!K||!f||!["preparing","ready","shown"].includes(t)?!1:(N=!0,ke=e,t==="shown"&&Ve(),!0)}function Ve(){let e=f?.context.locale??n.locale??"";v?.setPurchaseRecovery(e.startsWith("zh")?"正在查询原订单…":"Checking your purchase…")}function we(e){Ae.then(r=>{r&&D&&D.write(r,e).catch(()=>{})})}function _e(e){Ae.then(async r=>{if(!r||!D)return;let l=await D.read(r);ue||l&&"presented"in l||await D.write(r,e)}).catch(()=>{})}let ye=e=>`error:${e?.code??e?.name??"unknown"}`,me=c.ownerDocument.defaultView,q=!C,Ee=null,O=!1,Ge=e=>e.storageArea===me?.localStorage&&(e.key===null||e.key.startsWith("indiana.funnel.purchases.")),Fe=e=>{Ge(e)&&$()},ze=C?()=>{}:n.client.subscribe(()=>$());function X(){q&&(q=!1,me?.removeEventListener("storage",Fe),ze(),le())}let ge=()=>q&&(t==="ready"||t==="preparing");function he(e){(t==="ready"||t==="preparing")&&d("unavailable",e)}function $(){if(t==="ready"&&Date.now()-U>=ae)return X();O=!0,Ee??=(async()=>{for(;O&&m&&!N&&ge();){O=!1;try{await n.client.retained()==="pending"&&!pe("purchase_pending")&&he("purchase_pending")}catch(e){g.aborted?d("released","aborted"):he(ye(e))}}})().finally(()=>{Ee=null,O&&m&&!N&&ge()&&$()})}C||me?.addEventListener("storage",Fe),g.addEventListener("abort",oe,{once:!0});let De=C?Promise.resolve("none"):n.client.findPurchase();De.catch(()=>{});let Q;function Y(e){let r=Q?.paywallVersionId??n.paywallVersionId??f?.resolution.id??w?.id,l=JSON.stringify(V([r??null,e])),i=Se.get(l);return i||(i=n.client.readPaywall({paywallVersionId:r,...r?{}:{paywallId:Q?.paywallId??n.paywallId},...e}),Se.set(l,i)),i}function A(e,r){let l=Object.values(e.capabilities.plans),i=Object.values(e.document.buttons).some(a=>a.type==="checkout");return i&&l.length===0?!1:r.intent==="subscription_change"&&i?l.some(a=>a.available):l.every(a=>a.available)}function Pe(e,r){if(w&&!ne(e,w))return d("unavailable","paywall_changed"),!1;w=e,E=r,B(!0);for(let l of F.keys())k(l,structuredClone(e));return!0}function Oe(e,r){if(!(!w||!["preparing","ready","shown"].includes(t))){if(!ne(e,w))return M("paywall_changed");if(!A(e,r.commerce))return M("plan_unavailable");Pe(e,r)}}async function L(){let e=await je;if(!e)throw new qe("PURCHASE_PENDING","The purchase did not start; open it again");return e}let Ke={get view(){return P?P.view:w},get signal(){return P?.signal??n.client.identitySignal},get quote(){return P?.quote??null},get operation(){return P?.operation??null},webViewUrl:"bundled",get canReselect(){return P?.canReselect},get recovery(){return P?.recovery},get pendingCancellation(){return P?.pendingCancellation},subscribe(e){return F.set(e,P?.subscribe?.(e)??(()=>{})),()=>{F.get(e)?.(),F.delete(e)}},refresh:async()=>P?P.refresh():structuredClone(w),preview:async e=>(await L()).preview(e),confirm:async()=>(await L()).confirm(),cancel:async()=>(await L()).cancel(),read:async()=>(await L()).read(),destroy(){P?.destroy()}},He=n.onPurchaseIntent&&(e=>n.onPurchaseIntent(e)),p={options:{},handoff:{}},xe={loading:"host",focusAtReveal:!0,settleMotionAtReveal:!0,signal:n.client.identitySignal,...n.mountControls&&{mountControls:n.mountControls},start:async()=>Ke,canInteract:()=>p.options.canInteract?p.options.canInteract():!["unavailable","released","closed"].includes(t),async beforeAction(e){if(e?.purchaseIntent&&t!=="adopted"&&He)return;let r=t!=="adopted",l=w?.capabilities,i=await L();if(r&&!T(i.view?.capabilities,l))throw new Le;await p.options.beforeAction?.()}};for(let e of Ze)Object.defineProperty(xe,e,{enumerable:!0,get:()=>e==="onPurchaseIntent"?p.options.onPurchaseIntent??He:p.options[e]});function Z(){t!=="preparing"||!S||!v||!f&&(!m||!T(E?.commerce,te(m))||E?.locale!==m.locale)||(z("ready"),ie(!0))}let Me={present(e){if(p.handoff.present)return p.handoff.present(e);t==="preparing"&&(S=e,U=Date.now(),Z())},async dismiss(){if(p.handoff.dismiss)return p.handoff.dismiss();d("closed");for(let e of[...W])k(e)},async closeAction(e){if(p.handoff.closeAction)return p.handoff.closeAction(e);p.options.onAction?await p.options.onAction(e):await Me.dismiss()},quoteError(e){p.handoff.quoteError?p.handoff.quoteError(e):k(p.options.onError,e)}};async function Be(e,r){let l=n.funnelId??R?.funnelId??(await Promise.resolve(n.start).catch(()=>null))?.funnelId;if(l)try{let{route:i}=await e.funnelRoute(l),a=new Set(Object.values(i.nodes).flatMap(s=>s.type==="paywall"&&s.paywallId===r?[s.paywallVersionId]:[]));return a.size===1?[...a][0]:void 0}catch{return}}async function Xe(){if(n.paywallVersionId)return{paywallVersionId:n.paywallVersionId,paywallId:n.paywallId};if(n.paywallId)return{paywallVersionId:n.configuration?await Be(n.configuration,n.paywallId):void 0,paywallId:n.paywallId};let e=n.configuration;if(!e)return d("unavailable","paywall_missing"),null;let r=await Promise.resolve(n.start).catch(()=>null);if(!r||t!=="preparing")return null;let l=()=>ve(e,{funnelId:r.funnelId,customerId:n.client.customerId,parameters:r.parameters??{}});if(J=await l(),t!=="preparing")return null;let i=J;if(i.type!=="paywall")return d("unavailable",be(i)??"route"),null;let a=!1;return le=e.subscribe(()=>{a||!ge()||(a=!0,l().then(s=>{!(s.type==="unavailable"&&!["funnel_stopped","route_unavailable"].includes(s.reason))&&(s.type!=="paywall"||s.paywallVersionId!==i.paywallVersionId)&&he("route_changed")}).finally(()=>a=!1))}),q||le(),{paywallVersionId:i.paywallVersionId}}(async()=>{try{let[{showPaywall:e},r]=await Promise.all([import("./paywall-M37XZSJK.js"),Xe()]),l=n.commerce??te(R),i=n.locale??R?.locale,a=r&&l&&i?JSON.stringify(V([r.paywallVersionId??null,r.paywallId??null,{commerce:l,locale:i}])):null;if(de(a),g.throwIfAborted(),t!=="preparing"||!r)return;if(!l)return d("unavailable","commerce_missing");if(!i)return d("unavailable","locale_missing");Q=r;let s={commerce:l,locale:i},y=a?await D?.read(a).catch(()=>null):null;if(fe=!!y&&"presented"in y&&(!R||y.funnelId===R.funnelId),g.throwIfAborted(),t!=="preparing"||fe)return;y&&!("presented"in y)&&(!R||y.funnelId===R.funnelId)&&A(y.resolution,y.context.commerce)&&(f=y),G(!!f);let o;if(f){let ee=f.context;s=ee,o=structuredClone(f.resolution),Y(ee).then($e=>Oe($e,ee),()=>{})}else o=await Y(s);if(g.throwIfAborted(),t!=="preparing"||(!A(o,s.commerce)&&n.start instanceof Promise&&!h&&await j,!f&&h&&!T(s,h)&&(s=h,o=await Y(s)),g.throwIfAborted(),t!=="preparing"))return;if(!A(o,s.commerce))return d("unavailable","plan_unavailable");if(!Pe(o,s))return;b=c.ownerDocument.createElement("div"),c.append(b);let u=setTimeout(()=>t==="preparing"&&d("unavailable","timeout"),Ye);Re.then(()=>clearTimeout(u));let I=await e(b,xe,Me);if(!I.host||g.aborted||t!=="preparing"){I.host?.destroy(),d(g.aborted?"released":"unavailable","error");return}v=I.host,Z()}catch(e){d(g.aborted?"released":"unavailable",ye(e))}finally{de(null),G(!1),B(!1)}})(),j.then(async e=>{let r=o=>{_e(null),M(o)},l=async()=>{let o=await De;return o==="pending"?"purchase_pending":o==="found"?"original_purchase":o==="blocked"?"purchase_blocked":void 0},i=async o=>!o||o==="purchase_blocked"||!K?!1:(await se,pe(o)?!0:await Ue&&We(e?.funnelId??await n.client.pendingFunnel().catch(()=>null)??void 0)&&pe(o));if(!e)return K&&await i(await l().catch(()=>{}))?void 0:r("gated");let a=e,s=te(a),y=n.commerce??s;if(!T(s&&{...s,intent:void 0},y&&{...y,intent:void 0})||n.locale!==void 0&&a.locale!==n.locale)return r("start_mismatch");if(!s)return r("commerce_missing");h={commerce:s,locale:a.locale},x=a,f&&["preparing","ready","shown"].includes(t)&&(m=a,_=re(a));try{let o=await l();if(await i(o)){m=void 0,_="";return}if(o)return r(o);if(!["preparing","ready","shown"].includes(t))return;if(n.configuration&&(n.paywallId||n.paywallVersionId)){let u=await ve(n.configuration,{funnelId:a.funnelId,customerId:n.client.customerId,parameters:a.parameters??{}});g.throwIfAborted();let I=u.type==="unknown"||u.type==="unavailable"&&u.reason!=="funnel_stopped";if(u.type==="paywall"?f?u.paywallId!==f.resolution.paywallId:n.paywallVersionId?u.paywallVersionId!==n.paywallVersionId:u.paywallId!==n.paywallId:!I)return r(be(u)??"route_changed")}if(q&&(O=!1,await n.client.retained()==="pending")){if(await i("purchase_pending")){m=void 0,_="";return}return r("purchase_pending")}if(await se,fe){m=a,_=re(a);return}if(Q||n.paywallId||n.paywallVersionId||w){let u=await Y(h);if(g.throwIfAborted(),_e(A(u,h.commerce)?{savedAt:Date.now(),funnelId:a.funnelId,context:h,resolution:u}:null),f)Oe(u,h);else{if(t!=="preparing")return;if(w){if(!A(u,h.commerce))return d("unavailable","plan_unavailable");if(!Pe(u,h))return}}}}catch(o){return g.aborted?d("released","aborted"):M(ye(o))}["preparing","ready","shown"].includes(t)&&(m=a,_=re(a),Z(),O&&$())},()=>M("gated"));let Ne={get state(){return t},get reason(){return Ce??ke},ready:Re,local:se,get start(){return m},get prediction(){return J?structuredClone(J):void 0},matches:e=>m?re(e)===_:!!f&&e.funnelId===f.funnelId&&e.locale===f.context.locale,open(){if(t==="preparing")return"pending";if(t!=="ready"||!S)return!1;if(Date.now()-U>=ae)return d("unavailable","expired"),!1;let e=S;return S=null,X(),z("shown"),N&&Ve(),e(),"shown"},destroy(){Ie.abort()}};return Te.set(Ne,{onClose(e){return t==="closed"?(k(e),()=>{}):(W.add(e),()=>{W.delete(e)})},claim(){X()},remember(e){ue=!0;let r=structuredClone(e);j.then(()=>{!x||!h||we({savedAt:Date.now(),funnelId:x.funnelId,context:h,resolution:r})},()=>{})},withhold(){ue=!0,j.then(()=>{x&&we({savedAt:Date.now(),funnelId:x.funnelId,presented:"nothing"})},()=>{})},async adopt(e,r){let l=e.paywall?.resolution,i=e.paywall&&!e.paywall.quote&&!e.paywall.operation&&!e.paywall.purchaseRequestId&&!(e.paywall.selectionGeneration??0);if(t!=="shown"||!v||!w||!l||!i||e.source.id!==m?.funnelId||e.locale!==m?.locale||!T(e.parameters??{},m?.parameters??{})||!["running","waiting"].includes(e.status)||!ne(l,w))return null;let a;try{a=await r.start()}catch{return null}if(t!=="shown"||!v)return a.destroy(),null;P=a,p.options=r.options,p.handoff=r.handoff;for(let[o]of F)F.set(o,a.subscribe?.(o)??(()=>{})),a.view&&k(o,structuredClone(a.view));g.removeEventListener("abort",oe),z("adopted"),ce(a),W.clear();let s=v,y=b;return v=null,b=null,S=null,new Proxy(s,{get(o,u){return u==="destroy"?()=>{o.destroy(),y?.remove()}:u==="retainPurchaseDialog"?()=>{let I=o.retainPurchaseDialog();if(I)return{dialog:I.dialog,release(){I.release(),y?.remove()}}}:Reflect.get(o,u,o)}})},retainPurchaseDialog(){if(t!=="shown")return;let e=v?.retainPurchaseDialog();if(!e)return;let r=b;return v=null,b=null,d("released"),{dialog:e.dialog,release(){e.release(),r?.remove()}}},get modal(){return w?.document.presentation.type!=="inline"},mountsControls:!!n.mountControls,get revealable(){return t==="ready"&&!!S&&Date.now()-U<ae},get recovering(){return N},release(){d("released")}}),Ne}function ln(c,n){let C=n.run.parameters??{},H=C?.commerce;return en(c,{client:n.client,start:{funnelId:n.run.source.id,locale:n.run.locale,parameters:C},paywallVersionId:n.paywallVersionId,...H&&{commerce:H},locale:n.run.locale,signal:n.signal},{run:!0})}export{Qe as a,on as b,en as c,ln as d};
|
package/dist/chunk-JS4K6SZB.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as xn,c as Sn,d as Lt,f as Mt,g as Tn,k as On}from"./chunk-CHRNCOXJ.js";import{a as Cn,b as Ye}from"./chunk-W32FI2A2.js";import{e as Pn,f as vn,g as kn,h as In,j as Ut,k as ct,l as En,m as An,n as Rn}from"./chunk-CO6HDNOC.js";import{a as Ot,b as yn,d as Nt,e as gn,f as wn}from"./chunk-Y55OBV7D.js";import{a as st,b as oe,d as Dt,f as _t,j as bn}from"./chunk-MOIVJERE.js";import{b as ke}from"./chunk-6XRQR43F.js";import{B as L,C as ot,D as Ge,E as Se,y as mn}from"./chunk-3532HSBP.js";import{r as Le,t as Ie}from"./chunk-Y3W5G4BF.js";import{i as hn}from"./chunk-FYUMVOCV.js";import{c as ve,j as We}from"./chunk-DUS5V65Z.js";import{c as Tt}from"./chunk-BOT6ZDLK.js";import{a as k}from"./chunk-UGATOG2T.js";import{a as K}from"./chunk-DSPLGTQI.js";async function Nn(j,a,A){if(!Ge(a))throw new k("INVALID_RESPONSE","A verified completed purchase is required");let N=j?We.parse(j):null;if(await A.onComplete?.(a),!N||!A.check)return;let G=We.parse(await A.check());if(G.internal_feature_id!==N.internal_feature_id||G.quantity!==N.quantity||N.observation!==void 0&&(G.observation===void 0||G.observation.requirementDigest!==N.observation.requirementDigest||G.observation.authority!==N.observation.authority||Tt(G.observation.subject)!==Tt(N.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");G.allowed&&await A.onAccessGranted?.(G)}function Dn(j){return Object.entries(j.document.buttons).filter(([,a])=>a.type==="checkout"&&a.product.type==="fixed"&&!ke(a.product,{},j.capabilities)).map(([a])=>a)}function _n(j,a){let A=L(a)?void 0:a.lines[0];if(!L(a)&&(a.lines.length!==1||!A))return;let N=L(a)?a.productVersionId:A.productVersionId,{screen:G,buttons:se}=j.document,Q=new Map(L(a)?Object.entries(a.featureQuantities??{}):(A?.prepaid??[]).map(C=>[C.internal_feature_id,C.quantity]));function ce(C,d){if(C.hidden)return!1;if(C.type==="plan_picker"&&j.capabilities.pickers[C.id]?.options.includes(N))return d[C.id]=N,!0;if(C.type==="quantity_picker"){let ne=Q.get(C.internalFeatureId);return ne!==void 0&&(!C.bind?.plan||C.bind.plan===N)&&(d[C.id]=ne),!1}if(C.type==="button"&&C.action){let ne=se[C.action];return ne?.type==="checkout"&&ne.product.type==="fixed"&&ne.product.productVersionId===N}if(C.type!=="stack")return!1;let te=C.interaction,i=C.bind?.plan===N;for(let[ne,h]of C.children.entries()){let Z={},M=ce(h,Z);if(te?.type==="toggle"||te?.type==="tabs"){if(!M)continue;return d[C.id]=te.type==="toggle"?ne===0:h.id,Object.assign(d,Z),!0}Object.assign(d,Z),M&&(i=!0,te?.type==="select"&&te.purpose==="product"&&te.pickerId&&h.type==="stack"&&h.bind?.plan===N&&(d[C.id]=h.id,d[te.pickerId]=N))}return i}for(let C of G.pages){let d={__page:C.id};if(ce(C.root,d))return d}}var qn="position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0";async function kr(j,a,A){let N=a.focusAtReveal?()=>{}:Ut(j.ownerDocument),G=()=>{Q.finish("dismissed"),N()},se=()=>G(),Q=En(j,a,"paywall",()=>{G(),K(a.onDismiss)},xn);a.signal?.throwIfAborted(),a.signal?.addEventListener("abort",se,{once:!0});let ce=null,C,d,te;try{if(Q.start(!0,a.loadingDocument?.screen.strings.defaultLocale,a.loadingDocument??null),Q.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(ce=a.check?We.parse(await Q.wait(a.check(),ct)):null,ce?.allowed)return Q.finish("skipped"),a.signal?.removeEventListener("abort",se),N(),await a.onAccessGranted?.(ce),{check:ce,host:null};let[e,n]=await Promise.allSettled([Q.wait(import("./screen-renderer-HJOKBOZH.js")),Q.wait(a.start().then(r=>(Q.cancelled&&r.destroy(),r)),ct)]);if(e.status==="rejected")throw n.status==="fulfilled"&&n.value.destroy(),e.reason;if(n.status==="rejected")throw n.reason;te=e.value,C=n.value,a.signal?.throwIfAborted(),C.signal?.throwIfAborted(),C.signal?.addEventListener("abort",se,{once:!0});let t=C.view??await Q.wait(C.refresh(),ct);if(!t)throw new k("INVALID_RESPONSE","Paywall presentation is missing");C.signal?.throwIfAborted(),d=t}catch(e){throw Q.finish("error",e),A?.retainedDialog?.release(),a.signal?.removeEventListener("abort",se),C?.signal?.removeEventListener("abort",se),C?.destroy(),N(),e}let i=C,{mountScreenPreview:ne}=te,h=j.ownerDocument,Z=new AbortController,M=h.createElement("section"),pe=h.createElement("div"),Y=h.createElement("div"),lt=a.mountControls,ee=lt?h.createElement("div"):void 0,f=h.createElement("p"),y=h.createElement("button"),le=h.createElement("button"),_=h.createElement("button");(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&A?.hostPaywallTarget&&!A.retainedDialog&&d.document.presentation.type==="modal"&&(A.retainedDialog=In(A.hostPaywallTarget));let ue=A?.retainedDialog,S=ue?.dialog??h.createElement("dialog"),Me=ue&&d.document.presentation.type==="inline"?{type:"modal",size:"md"}:d.document.presentation,re=Me.type==="inline"?Y:h.createElement("div"),ut=i.locale||d.document.screen.strings.defaultLocale,o=ut.toLowerCase().startsWith("zh"),Un=o?"正在处理…":"Processing…",Ln=o?"正在准备报价…":"Preparing your price…",U=Sn(d.document.screen.theme);M.dataset.indianaPaywall="",M.setAttribute("aria-label",d.document.name),M.style.cssText=U.root,Y.style.cssText=U.controls,f.style.cssText=U.message,f.setAttribute("role","status"),_.style.cssText=U.link,_.textContent=o?"关闭":"Close",y.style.cssText=U.secondary,y.textContent=o?"重试":"Retry",y.hidden=!0,le.type="button",le.style.cssText=U.primary,le.textContent=o?"继续付款":"Continue payment",le.hidden=!0,re.append(f,le,y),Y.append(_),ee&&(ee.style.cssText="flex:1 0 100%;min-width:0",ee.hidden=!0,Y.prepend(ee)),re!==Y&&(re.dataset.indianaPaywallStatus="",re.style.cssText="display:none;padding:0",M.append(re)),M.append(pe,Y);let dt=()=>{let e=$n();f.style.cssText=e?`${U.message};${qn}`:U.message,Kt();let n=c=>!c.hidden&&(c!==f||!!f.textContent&&!e);if(re!==Y&&(re.style.cssText=!ie&&[...re.children].some(n)?`${U.controls};padding:12px 64px 12px 20px;flex-shrink:0`:e?"padding:0":"display:none;padding:0"),ee){let c=!ee.childElementCount&&!ee.textContent?.trim();ee.hidden!==c&&(ee.hidden=c)}let t=me??Y,r=![...t.children].some(n),l=[...t.children].some(c=>c!==_&&n(c));t.style.cssText=r?U.controls.replace(/padding:[^;]+/,"padding:0"):l?`${U.controls};${U.pinned}`:U.controls,ft()},Vt=typeof MutationObserver>"u"?void 0:new MutationObserver(dt);Vt?.observe(M,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Mn=Object.entries(d.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),D,$t,Ve=!1,Ht=JSON.stringify(d.capabilities),q;function xe(e){let n=Dn(e);if(q||fe&&!ae||F&&(P||!be()||we))return Oe(e).map(({actionId:r})=>r);if(Ct()||!P&&be())return n;let t=P?bt(e):Pt(e);return[...new Set([...n,...Oe(e).map(({actionId:r})=>r).filter(r=>!t.includes(r))])]}function $e(e){if(w)return;let n=d.id!==e.id;d=e;let t=JSON.stringify(e.capabilities);if(n||t!==Ht){let r=!b&&!i.quote&&!i.operation?st(e,J,jt):J;n||JSON.stringify(r)!==JSON.stringify(J)?(J=r,D?.update(e.document.screen,ut,{capabilities:oe(e),unavailableActions:xe(e),serverInput:{bindings:[],answers:{}},selection:J})):D?.updateCapabilities(oe(e),xe(e)),Ht=t}Hn(e),Ee(),Ze()}let V,pt=0;function Qt(){return(me??Y).getBoundingClientRect().height+(re===Y?0:re.getBoundingClientRect().height)}function ft(){let e=h.defaultView;if(!V?.responsive||!e)return;let n=me??Y,t=e.innerHeight-(V.type==="modal"?32:0);n.style.maxHeight=`${Math.max(1,t)}px`,n.style.overflowY="auto",n.style.flexShrink="0",pt=Math.max(1,t-Qt()),D?.resizeViewport?.(pt,e.innerWidth)}let w=!1,fe=!1,b=null,ht,ze=!1,Bt=!1,he=!1,mt,Ke=!1,ie,me;function Vn(){return fe||w||ie||Ke?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:Nt(i)}let E=()=>!w&&!ze&&!ie&&a.canInteract?.()!==!1,$,ye=!1,Te=!1,yt,m=null,de=null,Je="",ge=()=>a.checkoutNavigation==="after_confirmation"&&!!(a.terminateCheckout||a.resumeCheckout),J={},jt=new Set,ae,P;function gt(e){return!!e&&L(e)&&e.timing==="immediate"&&e.execution.provider==="merchant"}let wt=o?"正在确认付款…":"Confirming payment…",F=null,we,Xe,qt=!1,be=()=>a.allowNewPurchase!==!1||qt;function Ft(){return JSON.stringify([d.id,d.capabilities])}function Wt(){let e=yt;return e&&e.read===a.prepareSubscriptionChange&&e.basis===Ft()?e:void 0}function Ze(){let e=a.prepareSubscriptionChange;if(!e||!he||!E()||!be()||a.onPurchaseIntent||h.visibilityState==="hidden"||b||i.quote||i.operation||!Oe(d).length||Wt())return;let n=Z.signal,t=new Promise(r=>{let l=()=>r(void 0);n.addEventListener("abort",l,{once:!0}),Promise.resolve().then(()=>(n.throwIfAborted(),e(n))).then(c=>r(n.aborted?void 0:c),l).finally(()=>n.removeEventListener("abort",l))});yt={read:e,basis:Ft(),result:t}}let Gt=()=>{h.visibilityState==="hidden"?yt=void 0:Ze()};h.addEventListener("visibilitychange",Gt);function Oe(e){return Object.entries(e.document.buttons).flatMap(([n,t])=>t.type==="checkout"?[{actionId:n,policy:t}]:[])}function Yt(e){let n=P?.quote;return n?Oe(e).filter(({actionId:t,policy:r})=>Ne(n,e,t,r.product,J)).map(({actionId:t})=>t):[]}function bt(e){return P?.phase==="payment"?Yt(e):[]}function Ct(){return(P?P.phase==="payment":!be())&&(be()||!!a.prepareUpgradeReplacement)&&ge()&&!!a.terminateCheckout&&!!i.quote&&i.canReselect===!1&&!!i.operation&&R(i.operation).type==="checkout"}function Pt(e){let n=i.quote;return!ge()||F||!n||!i.operation||R(i.operation).type!=="checkout"?[]:Oe(e).filter(({actionId:t,policy:r})=>Ne(n,e,t,r.product,J)).map(({actionId:t})=>t)}function Ee(){let e=q?[]:P?bt(d):Pt(d),n=a.allowNewPurchase===!1&&!!i.operation&&R(i.operation).type==="checkout";le.hidden=!!q||(P?P.phase!=="payment":!n)||e.length>0,Kt(e)}function zt(){if(!(ae===void 0||q))return f.textContent?f.textContent:P?.phase==="checking"?wt:void 0}function $n(){return!!D?.updateCheckoutControls&&!!f.textContent&&zt()!==void 0}let et;function Kt(e=q?[]:P?bt(d):Pt(d)){if(!D?.updateCheckoutControls)return;let n=zt(),t=ge()||!!P;if(!n&&!t&&et?.on!==D)return;let r={actions:Oe(d).map(({actionId:c})=>c),resume:n?[ae]:t?e:[],resumeLabel:n??(o?"继续付款":P?"Continue payment":"Continue checkout"),busy:ae},l=JSON.stringify(r);et?.on===D&&et.key===l||(et={on:D,key:l},D.updateCheckoutControls(r))}function Jt(){de?.remove(),de=null}async function tt(){if(F)return;if(a.resumeCheckout&&i.operation){let n=i.operation.operationId;try{await a.resumeCheckout(n)}catch(t){if(!(t instanceof k&&t.code==="PURCHASE_PENDING"))throw t;let r=await i.read();if(!E())return;if(r.operationId!==n||R(r).type==="checkout")throw t;await H(r,!1)}return}let e=await i.read();if(R(e).type!=="checkout")return H(e,!1);E()&&(He.delete(e.operationId),await Qe(e))}function vt(){we?.destroy(),we=void 0,Xe=void 0}function Xt(){let e=F;if(!e||we)return;let n=o?"仍在核对原订单,暂时无法更换套餐。":"We’re still checking the original purchase before changing plans.",t=Date.now()+6e5,r=Cn({document:h,delay:()=>Date.now()<t?5e3:void 0,async run(){if(!E())return;let l=await i.read();if(we!==r||!E())return;if(l.operationId!==e.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");let c=R(l);c.type==="native"?(vt(),f.textContent=o?"原订单已关闭。你可以继续更换套餐。":"The original checkout is closed. You can continue changing plans.",y.textContent=o?"继续更换套餐":"Continue changing plans",m=()=>nt(),y.hidden=!1):(c.type==="complete"||c.type==="fulfillment"||c.type==="recording")&&(vt(),F=null,y.hidden=!0,await H(l,!1))}});we=r,Xe=async()=>{try{await r.refresh()}finally{we===r&&(f.textContent=n,y.hidden=!1)}},m=Xe,y.textContent=o?"查询结果":"Check result",y.hidden=!1,f.textContent=n,r.schedule()}async function nt(e=!1,n=!1){let t=F;if(!t)return;m=()=>nt(),P&&(y.textContent=o?"查询状态":"Check status"),y.hidden=!0;let r=async()=>{if(!be()&&a.prepareUpgradeReplacement){let c=await a.prepareUpgradeReplacement(t.operationId,t.intent);if(!E())return;qt=!0,$e(c)}F=null,P&&De(P.quote),Jt(),b=t.selection,$=t.coupon,ye=!1,Te=!1,await qe()};if(n&&!be()&&a.prepareUpgradeReplacement)return r();let l=Date.now()+2e4;for(;E();){let c=await i.read();if(c.operationId!==t.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");if(!E())break;let s=R(c);if(s.type==="native"){await r();return}if(s.type==="complete"||s.type==="fulfillment"||s.type==="recording"){F=null,P?await Ae(P.quote,c):await H(c,!1);return}if(e&&s.type==="checkout"){e=!1;try{await a.terminateCheckout(t.operationId)}catch(u){K(a.onError,u)}}if(Date.now()>=l){P&&s.type==="checkout"&&(F=null,await Ae(P.quote,c));break}await Ye(1e3,h,Z.signal)}!F||w||(P?(f.textContent=o?"仍在核对原升级单,暂时无法更换套餐。":"We’re still checking the original upgrade before changing plans.",y.hidden=!1):Xt())}async function Zt(e,n,t,r){if(m=()=>Zt(e,n,t,r),await a.beforeCheckoutReplacement?.(structuredClone(r)),!E())return;let l=i.operation;if(l?.operationId!==e||R(l).type!=="checkout"){m=null,l&&await H(l,!1);return}F={operationId:e,selection:n,coupon:t,intent:r},P&&(f.textContent=o?"正在切换套餐…":"Changing plan…",y.hidden=!0);let c=!1,s=!1;try{let u=await a.terminateCheckout(e);s=(Array.isArray(u?.purchases)?u.purchases:[]).some(p=>p.operationId===e&&p.type==="native")}catch(u){if(u instanceof k&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(u.code)){F=null,P&&(m=It,y.textContent=o?"查询状态":"Check status",y.hidden=!1),f.textContent=o?"请继续原订单,或等待它过期后再更换方案。":"Continue your original checkout, or wait for it to expire before changing plans.",K(a.onError,u);return}c=u instanceof k&&(u.status??0)>=500,K(a.onError,u)}E()&&await nt(c,s)}function rt(e,n,t,r,l){let c=oe(e).checkoutCoupons?.[n],s=c?c.products[t]:a.claimCoupon&&l?hn(e.capabilities,l,r):void 0;return s?.couponId&&s.planVersionId===t?{id:s.couponId,offerId:s.offerId}:void 0}function Hn(e){fe||b||i.quote||i.operation||Je&&f.textContent===Je||(f.textContent=Object.values(e.capabilities.plans).some(n=>n.available)?"":o?"当前账号暂无可购买的方案。":"No plans are currently available for this account.")}let He=new Map,it=!1;function Ne(e,n,t,r,l,c){let s=L(e),u=!s&&e.lines.length===1?e.lines[0]:void 0,I=ke(r,l,n.capabilities);if(!I||I!==(s?e.productVersionId:u?.productVersionId))return!1;let p=rt(n,t,I,l,c),x;try{x=Ie(n.document.screen,I,l,n.capabilities)}catch{return!1}if(s){let X=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return Object.keys(x).length===Object.keys(e.featureQuantities??{}).length&&Object.entries(x).every(([Ue,St])=>e.featureQuantities?.[Ue]===St)&&(!p||X?.couponId===p.id&&(!p.offerId||X.grantId===p.offerId))}if((p||oe(n).checkoutCoupons?.[t])&&(p?.id??null)!==(e.discount?.couponId??null))return!1;let T=Object.fromEntries((u?.prepaid??[]).map(X=>[X.internal_feature_id,X.quantity]));return[...new Set([...Object.keys(x),...Object.keys(T)])].every(X=>(x[X]??0)===(T[X]??0))}let R=e=>yn({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:w,canReselect:i.canReselect});async function Qe(e){let n=e.merchantExecution,t=R(e),r=t.type==="checkout"?t.checkoutUrl:e.checkoutUrl;if(!(!E()||!r||ot(e)&&t.type!=="checkout"||a.checkoutNavigation==="after_confirmation"&&t.type!=="checkout"||n?.type==="purchase"&&!["not_started","pending"].includes(n.paymentStatus)||He.get(e.operationId)===r)){He.set(e.operationId,r);try{a.onCheckoutUrl?await a.onCheckoutUrl(r):h.defaultView?.location.assign(r)}catch(l){throw He.delete(e.operationId),l}}}let Ce=(e,n=!1)=>{if(e instanceof Dt)m=null,f.textContent=e.customerMessage(o);else if(Tn(e))m=null,f.textContent=n?o?"当前无法在此购买,付款尚未开始。请联系商户。":"Purchases aren’t available here right now. Payment hasn’t started. Contact the merchant for help.":Mt(e,o);else if(n){let t=e instanceof k?e.code:void 0;t==="CAPABILITY_UNAVAILABLE"||t==="NOT_CONFIGURED"?(m=null,f.textContent=o?"暂时无法为此套餐报价,付款尚未开始。":"Pricing for this plan is unavailable. Payment hasn’t started."):i.canReselect===!0&&!b?f.textContent=o?"未能取得报价,付款尚未开始。请重新选择套餐。":"We couldn’t prepare your price. Payment hasn’t started. Choose a plan again.":t==="COMMAND_PENDING"?f.textContent=o?"仍在准备报价,请重试以查看结果。":"Your price is still being prepared. Retry to check the result.":f.textContent=o?"未能取得报价,付款尚未开始。请重试。":"We couldn’t prepare your price. Payment hasn’t started. Try again."}else f.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?Mt(e,o):e instanceof k?e.message:o?"操作未完成,请重试。":"This action couldn’t be completed. Try again.";y.hidden=m===null,Je=f.textContent,n&&ae===void 0&&!V?.responsive&&f.scrollIntoView?.({block:"nearest"}),K(n&&A?.quoteError?A.quoteError:a.onError,e)},Be=new WeakMap;function je(e){fe=e,y.disabled=e,le.disabled=e,D?.updateCapabilities?.(oe(d),xe(d));for(let n of de?.querySelectorAll("button")??[])e?(Be.has(n)||Be.set(n,n.disabled),n.disabled=!0):Be.has(n)&&(n.disabled=Be.get(n),Be.delete(n)),Lt(n)}function en(){q&&(f.textContent=q.message,y.textContent=o?"重试":"Retry",y.disabled=!1,y.hidden=!q.retry,le.disabled=!0)}function kt(){f.textContent=o?"暂时无法操作,请稍后重试。":"This action is unavailable right now. Try again in a moment."}let tn=new WeakSet;async function Qn(e){if(a.beforeAction)try{await a.beforeAction({purchaseIntent:tn.has(e)})}catch(n){throw n instanceof Dt?(b=null,ye=!1,Te=!1,m=null):m=e,n}}async function W(e,n){if(fe||w||q)return;if(!E()){kt();return}let t=e===qe,r=t?Ln:Un;ae=n!==void 0&&D?.updateCheckoutControls?n:void 0,f.textContent=r,je(!0),Ee(),y.hidden=!0;try{if(e!==cn&&e!==It&&e!==xt&&e!==Xe&&(e!==tt||!a.resumeCheckout)&&await Qn(e),w||q)return;if(!E()){m=e,y.hidden=!1,kt();return}await e()}catch(l){w||Ce(l,t)}finally{ae=void 0,je(!1),Ee(),q?en():f.textContent===r&&(f.textContent="")}}async function nn(e){await Nn(ce,e,a)}function De(e,n){P=n?{quote:e,phase:n}:void 0,n==="checking"?(ae??=b?.actionId??Yt(d)[0],f.textContent=wt,m=It,y.textContent=o?"查询状态":"Check status",y.hidden=!0):ae=void 0,D?.updateCapabilities(oe(d),xe(d)),Ee()}function rn(e){return e instanceof k&&(e.code==="COMMAND_PENDING"||e.reason==="RESULT_UNKNOWN"||e.code==="NETWORK_ERROR"||e.code==="TIMEOUT"||e.status===429||(e.status??0)>=500)}function an(e,n){_t(e,{...n,featureQuantities:n.featureQuantities??{}},"Purchase operation changed")}async function It(){P&&await Ae(P.quote)}async function Ae(e,n){De(e,"checking"),Je="";let t=1e3;Ve=!0,K(a.onObservationChange,!0);try{for(let r=n;E();r=void 0){if(!r){try{r=await i.read()}catch(l){if(!rn(l))throw l}if(!E())return}if(r){an(r,e);let l=R(r);if(l.type==="checkout"){De(e,"payment"),f.textContent=o?"请先完成原订单的付款。":"Finish paying for this upgrade.",y.hidden=!1;return}if(l.type==="complete"){De(e,"complete"),m=null;let c=d.capabilities.plans[e.productVersionId]?.name,s=e.merchantTerms?.subscriptionTerms?.items,u=s?.length===1?s[0].interval:void 0,I=u==="year"?o?"年付":"annual billing":u==="month"?o?"月付":"monthly billing":null;f.textContent=c?o?`已升级到 ${c}${I?" "+I:""}。`:`Upgraded to ${c}${I?" ("+I+")":""}.`:o?"已成功升级。":"Plan upgraded.",await nn(r);return}if(l.type==="native"&&!Se(r)){De(e),b=null,m=null,f.textContent=o?"付款没有成功,套餐未变更。请检查付款方式后重新选择套餐。":"Your payment didn’t go through, so your plan is unchanged. Check your payment method, then choose a plan again.",y.textContent=o?"重试":"Retry";return}if(r.problem&&!["RESULT_UNKNOWN","STATE_CHANGED"].includes(r.problem.reason??""))throw new k(r.problem.code,o?"暂时无法完成升级。":"The upgrade needs attention.",void 0,void 0,r.problem)}await Ye(t,h,Z.signal),t=Math.min(t*1.5,15e3)}}finally{Ve=!1,K(a.onObservationChange,!1)}}async function xt(){let e=P?.quote;if(!e)return;let n=await i.read();if(an(n,e),R(n).type!=="checkout")return Ae(e,n);if(a.resumeCheckout){await a.resumeCheckout(n.operationId);return}He.delete(n.operationId),await Qe(n)}function on(e){return Nt(i).type==="recording"||R(e).type==="recording"}function sn(e){let n=e.merchantTerms,t=n?.subscriptionTerms?.items??[],r=n?n.totalMinor:L(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),l=n?t.length===1&&t[0]?.amountMinor===r&&t[0]:!L(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===r&&e.lines[0],c=r===null?ve(n.subtotalMinor-n.discountMinor,e.currency)+(o?" + 待确认税费":" + tax confirmed at checkout"):ve(r,e.currency)+(l?Le(l.interval,o?"zh-CN":"en",l.intervalCount??1):""),s=L(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(u=>u.productName).join(", ");return{label:s?`${s} · ${c}`:c,recurring:l}}async function H(e,n=a.checkoutNavigation!=="after_confirmation"){if(w)return;if(!E()){m=async()=>H(await i.read()),y.hidden=!1;return}let t=e.quote??i.quote;if(gt(t)&&(e.confirmedAt||e.merchantExecution))return Ae(t,e);if(f.textContent=On(e.status,o),on(e)){let p=e.merchantExecution?.recordingStatus==="failed";f.textContent=p?o?"付款和商户处理已完成,但交易记录失败。请联系商户修复,勿重复购买。":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":o?"付款和商户处理已完成,正在确认交易记录。请勿重复购买。":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",y.textContent=o?"查询记录":"Check recording",m=async()=>H(await i.read()),y.hidden=!1;return}if(e.problem&&R(e).type!=="native"){let p=e.problem;m=_e,y.textContent=o?"检查并恢复原操作":"Check and recover original purchase",Ce(new k(p.code,p.reason==="RESULT_UNKNOWN"?o?"付款结果尚未确定,请恢复原操作,暂勿重复购买。":"The payment result is unknown. Recover the original purchase before buying again.":p.phase==="fulfillment"?o?"付款已记录,商户权益处理需要核对。":"Payment was recorded. Access fulfillment needs attention.":p.code==="CAPABILITY_UNAVAILABLE"?o?"商户尚不支持本次购买所需的完整能力,请处理后恢复原操作。":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":p.code==="NOT_CONFIGURED"?o?"付款服务连接需要处理,请联系商户后恢复原操作。":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":o?"原购买操作需要处理,请查询或恢复此操作。":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,p));return}if((e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"||e.merchantExecution?.type==="subscription_change"&&e.merchantExecution.status==="applied")&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(f.textContent=o?"付款已记录,正在等待商户完成处理。":"Payment was recorded. Waiting for merchant fulfillment."),Ge(e)&&R(e).type==="complete"){m=null,await nn(e);return}let r=Ot(e);if((r||!Se(e))&&R(e).type!=="fulfillment"){if(i.canReselect===!1||r&&Se(e)&&i.canReselect!==!0){f.textContent=o?"正在核对原购买结果":"Checking the original purchase result",y.textContent=o?"查询结果":"Check result",m=async()=>H(await i.read()),y.hidden=!1;return}r?f.textContent=o?"结账未启动,可以重新选择方案。":"Checkout didn’t start. Choose a plan to try again.":e.status==="cancelled"?f.textContent=o?"这笔购买已取消,可以重新选择方案。":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(f.textContent=o?"这笔购买未能完成,可以重新选择方案。":"This purchase didn’t go through. Choose a plan to try again."),y.textContent=o?"重试":"Retry",m=null,b=null;return}if(!n&&R(e).type==="checkout"){if(F){Xt();return}if(ge()){f.textContent="",it=!1,m=null,y.hidden=!0,D?.updateCapabilities?.(oe(d),xe(d)),Ee();return}let p=i.quote,x=p?.operationId===e.operationId?sn(p).label:"";f.textContent=it?x?o?`${x} 尚未付款。再次选择该方案即可继续付款。`:`${x} is still unpaid. Choose it again to continue paying.`:o?"之前的购买尚未付款。再次选择该方案即可继续付款。":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",it=!1,m=null;return}await Qe(e);let l=Date.now(),c=l+6e5,s=2e3,u=R(e).type!=="checkout",I=()=>u&&Date.now()-l<15e3;Ve=!0,K(a.onObservationChange,!0);try{for(;!w&&Date.now()<c;){if(await Ye(I()?700:s,h,Z.signal),w)return;if(!E()){m=async()=>H(await i.read()),y.hidden=!1;return}let p=await i.read();if(R(p).type==="checkout"&&(u=!1),!n&&R(p).type==="checkout"){await H(p,!1);return}if(!p.problem&&Se(p)&&await Qe(p),!Se(p)||Ot(p)||p.problem||on(p)){await H(p);return}I()||(s=Math.min(s*1.5,3e4))}}finally{Ve=!1,K(a.onObservationChange,!1)}m=async()=>H(await i.read()),y.hidden=!1}async function Et(e=!1){let n=await i.read();if(w)return;if(!E()){m=()=>Et(e),y.hidden=!1;return}let t=i.quote;if(t&&_t(n,{operationId:t.operationId,currency:t.currency},"The original purchase operation changed"),t&&(ot(n)?["prepared","quoted"].includes(n.status):n.status==="pending")&&(ot(n)||n.quoteFinalized===!1)&&!n.confirmedAt&&!n.checkoutUrl&&!("nativePurchase"in n&&n.nativePurchase)&&!n.merchantExecution&&!n.problem&&!i.pendingCancellation){if(a.purchaseConfirmation!=="paywall"){e?await _e():m=null;return}setTimeout(ln,0,t);return}await H(n,e||void 0)}async function cn(){await Et()}async function Bn(e){f.textContent=wt;let n=Date.now()+12e3;for(;!w&&Date.now()<n&&(await Ye(1500,h,Z.signal),!(w||!E()));){let t;try{t=await i.read()}catch{break}if(t.problem?.reason!=="RESULT_UNKNOWN")return t}return e}async function _e(){if(i.quote&&!(Date.parse(i.quote.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");Jt();let e=i.quote;if(gt(e)){De(e,"checking");let t;try{t=await i.confirm()}catch(r){if(!rn(r))throw r;return Ae(e)}return Ae(e,t)}m=_e;let n=await i.confirm();if(!E()){m=_e,y.hidden=!1;return}if(n.problem?.reason==="RESULT_UNKNOWN"&&(n=await Bn(n)),n.problem){await H(n);return}if(Se(n)){if(R(n).type==="checkout")await Qe(n);else if(n.execution&&n.execution.provider!=="merchant"||"nativePurchase"in n&&n.nativePurchase){if(!a.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:n,signal:Z.signal})}}m=async()=>H(await i.read()),await H(n,!0)}function ln(e){if(w)return;de?.remove();let n=!(Date.parse(e.expiresAt)>Date.now());f.textContent=n?o?"此报价已过期。请先取消,再重新选择。":"This quote has expired. Cancel it, then choose again.":"";let t=h.createElement("div"),r=h.createElement("button"),l=h.createElement("button"),c=h.createElement("div"),s=h.createElement("p"),u=e.merchantTerms,I=o?"zh-CN":"en",p=u?.subscriptionTerms?.items??[],x=u?u.subscriptionTerms?.trial?.days:L(e)?void 0:e.lines.find(g=>g.trial)?.trial?.days,T=L(e)?u?u.totalMinor:e.totalMinor:x===void 0?null:u?u.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(g=>g.trial)?0:null,Pe=(g,v)=>o?`${v} 天试用结束后 ${g}`:`Then ${g} after the ${v}-day trial`,{label:X,recurring:Ue}=sn(e),St=L(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(g=>g.productName).join(", "),pn=T===null?"":`${o?"今天应付":"Due today"} ${ve(T,e.currency)}`;s.textContent=pn?[St,pn].filter(Boolean).join(" · "):X,r.textContent=L(e)?o?"确认变更":"Confirm change":o?"确认购买":"Confirm purchase",r.disabled=n,l.textContent=o?"取消":"Cancel",t.style.cssText=U.panel,s.style.cssText=U.summary,c.style.cssText=U.actions,r.style.cssText=U.primary,l.style.cssText=U.secondary,Lt(r),r.onclick=()=>{W(_e)};let fn=async()=>{let g=await i.cancel();w||(t.remove(),de=null,await H(g))};l.onclick=()=>{m=fn,W(fn)};let z=h.createElement("div");if(z.style.cssText=U.terms,L(e)){for(let[v,O]of Object.entries(e.featureQuantities??{})){let B=i.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(jn=>jn.internalFeatureId===v),at=h.createElement("p");at.textContent=`${B?.name??v} · ${O} ${o?"份":"packs"}${B?` × ${B.terms.units}`:""}`,z.append(at)}for(let[v,O]of[[o?"原订阅抵扣":"Unused subscription credit",e.creditMinor],[o?"新套餐费用":"New plan charge",e.debitMinor],[o?"优惠减免":"Offer savings",u?.discountMinor??e.discountMinor],[o?"税费":"Tax",u?u.taxMinor:e.taxMinor]]){let B=h.createElement("p");B.textContent=`${v}: ${O===null?o?"结账时确认":"Confirmed at checkout":ve(O,e.currency)}`,z.append(B)}let g=h.createElement("p");g.textContent=`${o?"生效时间":"Effective"}: ${e.effectiveAt}`,z.append(g)}if(u){for(let v of p){if(T===null&&v===Ue)continue;let O=h.createElement("p"),B=ve(v.amountMinor,e.currency)+Le(v.interval,I,v.intervalCount);O.textContent=T!==null&&x!==void 0?Pe(B,x):B,v.amountAfterOfferMinor!==void 0&&(O.textContent+=` · ${o?"优惠结束后":"After the offer"} ${ve(v.amountAfterOfferMinor,e.currency)}${Le(v.interval,I,v.intervalCount)}`),z.append(O)}let g=u.subscriptionTerms?.trial;if(g){let v=h.createElement("p");v.textContent=o?`试用 ${g.days} 天;${g.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${g.days}; ${g.cardRequired?"a payment method is required":"no payment method is required"}`,z.append(v)}for(let v of[...u.expectedEffects.map(O=>O.description),...u.requiredConsents.map(O=>O.summary)]){let O=h.createElement("p");O.textContent=v,z.append(O)}}else if(!L(e)){for(let g of e.lines){if(T!==null||g!==Ue){let v=h.createElement("p"),O=`${ve(g.catalogAmountMinor,e.currency)}${Le(g.interval,I,g.intervalCount??1)}`;v.textContent=T!==null&&g.trial?(e.lines.length>1?`${g.productName} · `:"")+Pe(O,g.trial.days):`${g.productName} · ${O}`,z.append(v)}for(let v of g.prepaid??[]){let O=h.createElement("p"),B=i.view?.capabilities.plans[g.productVersionId]?.prepaid?.find(at=>at.internalFeatureId===v.internal_feature_id);O.textContent=`${B?.name??v.internal_feature_id} · ${v.quantity} ${o?"份":"packs"} × ${v.terms.units}`,B&&(O.textContent+=Le(B.reset==="week"||B.reset==="month"||B.reset==="year"?B.reset:"one_time",I,B.resetCount)),z.append(O)}if(g.trial){let v=h.createElement("p");v.textContent=o?`试用 ${g.trial.days} 天;${g.trial.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${g.trial.days}; ${g.trial.cardRequired?"a payment method is required":"no payment method is required"}`,z.append(v)}}if(!e.charge){let g=h.createElement("p");g.textContent=o?"目录价格;最终金额以结账时税费和试用规则为准。":"Catalog price; the final charge depends on checkout taxes and trial terms.",z.append(g)}}for(let g of z.children)g.style.margin="0";c.append(r,l),t.append(s,...z.childElementCount?[z]:[],c),Y.prepend(t),V?.responsive||t.scrollIntoView?.({block:"nearest"}),r.focus({preventScroll:!0}),de=t,fe&&je(!0),m=null}async function qe(){if(!b)return;if(a.onPurchaseIntent&&!ye&&!i.quote&&!i.operation){let t=b,r=i.view,l=r?.document.buttons[t.actionId],c=r&&l?.type==="checkout"?ke(l.product,t.selection,r.capabilities):null;if(!r||!c)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let s={actionId:t.actionId,productVersionId:c,selection:structuredClone(t.selection),featureQuantities:Ie(r.document.screen,c,t.selection,r.capabilities),...$&&{coupon:{id:$.id,...$.offerId&&{offerId:$.offerId}}}};b=null,$=void 0,m=null,Ke=!0,await a.onPurchaseIntent(s);return}if(m=qe,!ye){let t=i.view,r=t?.document.buttons[b.actionId],l=t&&r?.type==="checkout"?ke(r.product,b.selection,t.capabilities):null;if(!t||!l)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!Te){let s=Wt(),u=s?await s.result:void 0;if(w)return;let I=a.resolveSubscriptionChange;if(I||u){let p={actionId:b.actionId,productVersionId:l,featureQuantities:Ie(t.document.screen,l,b.selection,t.capabilities)},x=u?[async()=>u(p)]:[],T=I?await I(p,...x):await x[0]?.();if(w)return;T!==void 0&&(b.subscriptionChange=mn.parse(T))}Te=!0}let c=$?.offerId;if($&&!c){if(!a.claimCoupon)throw new k("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:s}=await a.claimCoupon($.id,b.requestId);if(w)return;if(!s||s.couponId!==$.id||s.status!=="issued"||!(Date.parse(s.expiresAt)>Date.now()))throw b=null,$=void 0,m=async()=>{$e(await i.refresh()),m=null},new k("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");c=s.id}if(!$&&!t.document.screen.actions.some(s=>s.id===b?.actionId&&typeof s.properties.couponBinding=="string")&&(c=await a.resolveOfferId?.({actionId:b.actionId,productVersionId:l,featureQuantities:Ie(t.document.screen,l,b.selection,t.capabilities)})),w)return;c!==void 0&&(b.offerId=c),ye=!0}if(!E()){y.hidden=!1;return}let e;try{e=await i.preview(b)}catch(t){throw i.canReselect===!0&&(b=null,ye=!1,Te=!1,$=void 0,m=null),t}if(b.acceptHostedMonthly!==void 0){let t=i.operation;if(!t||t.operationId!==e.operationId||!t.confirmedAt)throw new k("INVALID_RESPONSE","The confirmed Checkout is missing");w||await H(t,!0);return}if($&&(L(e)?(()=>{let t=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return t?.couponId!==$.id||t.grantId!==b.offerId})():e.discount?.couponId!==$.id||e.discount.offerId!==b.offerId))throw new k("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(w)return;let n=e.merchantTerms;if(a.purchaseConfirmation!=="paywall"||a.confirmOnHostedCheckout&&E()&&!L(e)&&e.provider==="merchant"&&e.billingSubscriptionId===null&&n?.request.action==="purchase"&&n.request.mode==="subscription"&&n.subscriptionTerms?.trial===null&&n.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){if(!E()){y.hidden=!1;return}if(!(Date.parse(e.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");let t=ae?"":o?"正在打开收银台…":"Opening checkout…";f.textContent=t;try{await _e()}catch(r){w||Ce(r)}finally{f.textContent===t&&(f.textContent="")}return}ln(e)}function Re(e="destroy",n=!1){if(w)return;w=!0;let t=ht;ht=void 0,K(t),a.signal?.removeEventListener("abort",se),i.signal?.removeEventListener("abort",se),Q.finish("dismissed"),$t?.(),vt(),h.removeEventListener("visibilitychange",Gt),Z.abort(),Vt?.disconnect(),D?.destroy(),i.destroy(),S.removeEventListener("cancel",dn),_.remove(),M.remove(),n||un(),e==="dismiss"&&K(a.onDismiss)}function un(){if(V?.destroy(),ue){ue.release();return}S.open&&S.close(),S.remove(),N()}G=Re;async function Fe(){if(!he||w||ze||ie==="closing"||!ie&&!E())return;if(!A){Re("dismiss");return}let e=h.createElement("p");e.setAttribute("role","status"),e.textContent=o?"正在关闭…":"Closing…",me||(me=h.createElement("div"),me.style.cssText=Y.style.cssText,Y.replaceWith(me),pe.inert=!0),_.hidden=!1,me.replaceChildren(e,_),ie="closing",_.setAttribute("aria-disabled","true"),_.focus({preventScroll:!0});try{await A.dismiss()}catch(n){w||K(a.onError,n)}w||(ie="retry",e.textContent=o?"未能确认关闭,请重试。":"Could not confirm closure. Try again.",_.textContent=o?"重试关闭":"Retry closing",_.removeAttribute("aria-label"),_.removeAttribute("aria-disabled"))}_.onclick=()=>{Fe()};function dn(e){e.preventDefault(),Fe()}S.addEventListener("cancel",dn),le.onclick=()=>{W(P?xt:tt)},y.onclick=()=>{if(q){q.retry?.();return}m&&W(m)};function At(e){Q.finish("error",e),Re()}function Rt(){if(!(!Bt||he||w||ze||V&&!E()))try{let e=n=>{a.focusAtReveal&&(N=Ut(h)),a.settleMotionAtReveal?D?.setHidden?.(!1,!0):D?.setHidden?.(!1),mt?.(),V&&(S.open||S.showModal(),V.responsive&&S.focus({preventScroll:!0}),!n&&a.loading!=="host"&&vn(S,V.type,V.responsive)),n&&a.loading!=="host"&&typeof pe.animate=="function"&&!h.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&pe.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),he=!0,Ze()};A?A.present(n=>Q.present(t=>e(n??t))):Q.present(e)}catch(e){At(e),Ce(e)}}try{if(Me.type==="inline"?(dt(),mt=Rn(M,j),j.append(M)):(S.setAttribute("aria-label",d.document.name),_.textContent="×",_.setAttribute("aria-label",o?"关闭":"Close"),kn(_,d.document.screen.theme),_.hidden=bn(d.document),(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&ue?.content?ue.content.append(_,M):S.replaceChildren(_,M),ue||j.append(S),V=Pn(S,{...d.document.screen,presentation:Me},ft),V.latch(),V.responsive&&(M.style.display="flex",M.style.flexDirection="column",M.style.maxHeight="100%",pe.style.overflow="clip",pe.style.minHeight="0"),ue||(mt=An(S))),lt&&ee){let t=lt(ee);if(typeof t=="function"&&(w?K(t):ht=t),w)throw new DOMException("Presentation cancelled","AbortError");dt()}D=ne(pe,{mode:"live",rendererUrl:"bundled",title:d.document.name,closeActions:Mn,onAuthoredClose(t){ie||w||(_.hidden=t)},hostPresentation:()=>V?.type??Me.type,reportContentHeight:V?.responsive,onResize:t=>{if(!V?.responsive)return;let r=Math.min(t,pt);pe.style.height=`${r}px`,V.setContentHeight(r+Qt())},onSelection(t){for(let[r,l]of Object.entries(t))typeof l=="number"&&typeof J[r]=="number"&&J[r]!==l&&jt.add(r);J=t,Ee(),Ze()},onAction(t,r={},l,c){if(!he||w||ie)return;let s=i.view,u=s?.document.buttons[t];if(!u)return;if(q){u.type==="close"&&Fe();return}if(u.type==="close"&&A&&a.resumeCheckout&&i.operation&&gn(R(i.operation))){Fe();return}if(fe)return;if(!E()){kt();return}if(u.type==="close"){W(async()=>{A?.closeAction?await A.closeAction(t):await a.onAction?.(t),Re(a.onAction?"action":"dismiss")});return}if(u.type==="action"){m=async()=>{if(u.action.type==="event"){if(!a.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(u.action.event)}else a.onOpenUrl?await a.onOpenUrl(u.action.url):h.defaultView?.location.assign(u.action.url);await a.onAction?.(t),m=null},W(m);return}if(ge()&&F){!we&&F.selection.actionId===t&&W(()=>nt(!0),t);return}if(P){if(P.phase==="payment"&&s&&Ne(P.quote,s,t,u.product,r,c)){W(xt,t);return}if(!Ct())return}if(!be()&&!Ct()){ge()&&s&&i.quote&&i.operation&&R(i.operation).type==="checkout"&&Ne(i.quote,s,t,u.product,r,c)?W(tt,t):f.textContent=o?"当前只能继续原订单。":"Only your original checkout is available.";return}if(de&&i.canReselect===!1){f.textContent=o?"请先确认或取消当前购买。":"Confirm or cancel the current purchase first.",V?.responsive||de.scrollIntoView?.({block:"nearest"}),de.querySelector("button")?.focus({preventScroll:!0});return}if(ge()&&a.terminateCheckout&&s&&i.quote&&i.operation&&i.canReselect===!1&&R(i.operation).type==="checkout"){if(Ne(i.quote,s,t,u.product,r,c)){W(tt,t);return}let p=ke(u.product,r,s.capabilities),x;try{if(!p)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");x=Ie(s.document.screen,p,r,s.capabilities)}catch(Ue){Ce(Ue);return}let T=i.operation.operationId,Pe={actionId:t,requestId:crypto.randomUUID(),selection:structuredClone(r)},X=rt(s,t,p,r,c);W(()=>Zt(T,Pe,X,{actionId:t,productVersionId:p,selection:Pe.selection,featureQuantities:x}),t);return}if((i.quote||b)&&i.canReselect===!1){let p=!!s&&!!i.quote&&Ne(i.quote,s,t,u.product,r,c);it=!!i.quote&&!p,m=i.quote?()=>Et(p):qe,W(m,t);return}let I=s&&ke(u.product,r,s.capabilities);if(!s||!I){Ce(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){m=null;let p=async()=>{let x={actionId:t,productVersionId:I,selection:structuredClone(r),featureQuantities:Ie(s.document.screen,I,r,s.capabilities)},T=rt(s,t,I,r,c);T&&(x.coupon={id:T.id,...T.offerId&&{offerId:T.offerId}}),Ke=!0,await a.onPurchaseIntent(x)};tn.add(p),W(p,t);return}if(b&&b.actionId!==t){Ce(new k("COMMAND_PENDING","Finish the current purchase"));return}if(!b){$=rt(s,t,I,r,c),b={requestId:crypto.randomUUID(),actionId:t,selection:structuredClone(r)};let p=s.document.screen.actions.find(Pe=>Pe.id===t)?.properties,x=p?.hostedMonthlyPriceMinor,T=p?.hostedMonthlyAutomaticTax;a.purchaseConfirmation==="purchase_button"&&a.confirmOnHostedCheckout&&i.supportsHostedCheckout===!0&&!$&&u.product.type==="fixed"&&typeof T=="boolean"&&typeof x=="number"&&Number.isSafeInteger(x)&&x>0&&x<=1e8&&Object.keys(Ie(s.document.screen,I,r,s.capabilities)).length===0&&(b.acceptHostedMonthly={amountMinor:x,automaticTax:T}),ye=b.acceptHostedMonthly!==void 0,Te=ye}W(qe,t)},onEscape:()=>{Fe()},onError:t=>{let r=new Error(t);!he&&!w&&At(r),Ce(r)},onRendered:t=>{t&&S.setAttribute("aria-label",t),Bt=!0,Rt()}}),D.setHidden?.(!0),ft();let e=ge()&&!!i.quote&&!!i.operation&&R(i.operation).type==="checkout";J=i.quote?_n(d,i.quote)??st(d,{}):st(d,{}),D.update(d.document.screen,ut,{capabilities:oe(d),unavailableActions:xe(d),serverInput:{bindings:[],answers:{}},...Object.keys(J).length?{selection:J}:{}}),$t=i.subscribe?.($e),$e(i.view??d),await Q.wait(D.ready);let n=i.operation;(!e||gt(i.quote))&&(i.quote||n&&(n.confirmedAt||n.checkoutUrl||Ge(n)))&&(m=cn,W(m))}catch(e){throw At(e),e}return{check:ce,host:{get currentResolution(){return d},setPurchaseRecovery(e,n){q={message:e,retry:n},D?.updateCapabilities?.(oe(d),xe(d)),Ee(),en()},get subscriptionUpgradeActive(){return P!==void 0},get observing(){return Ve},get recovery(){return Vn()},async prepareFallback(){if(fe||w||ie||Ke)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};je(!0);try{let e=await wn(i);return e.type==="native"&&Re(),e}finally{je(!1)}},setSuspended(e){ze=e,M.hidden=e,e&&S.open?S.close():!e&&!he?Rt():!e&&!w&&he&&Me.type!=="inline"&&!S.open&&S.showModal()},destroy:Re,retainPurchaseDialog(){if(!(w||!S.open||!S.isConnected))return Re("destroy",!0),{dialog:S,content:ue?.content,release:un}},refresh:async()=>{if(!E()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return $e(e),Rt(),e}}}}export{kr as a};
|
|
File without changes
|