@tinkerlandai/longplay-sdk 0.10.59 → 0.10.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -1
  4. package/dist/{ai-usage-DBcYB8ix.d.ts → ai-usage-DM3jAubK.d.ts} +1 -1
  5. package/dist/{api-1Tplv-7M.d.ts → api-KIp0I50M.d.ts} +21 -21
  6. package/dist/{chunk-FBNEQ2K5.js → chunk-2KM537QH.js} +1 -1
  7. package/dist/{chunk-6426YKPK.js → chunk-5QVMWM2X.js} +1 -1
  8. package/dist/chunk-6TETQL5Z.js +1 -0
  9. package/dist/{chunk-WUPNZGE2.js → chunk-7GIP3RNR.js} +1 -1
  10. package/dist/{chunk-J5K4PNII.js → chunk-IM5OXTEH.js} +1 -1
  11. package/dist/{chunk-725CAWOK.js → chunk-J4JJZN24.js} +1 -1
  12. package/dist/chunk-KBST6VBH.js +1 -0
  13. package/dist/{chunk-J7VGTAJ7.js → chunk-QJPH7AFI.js} +1 -1
  14. package/dist/chunk-QXDLOPZK.js +1 -0
  15. package/dist/{chunk-66W37FEV.js → chunk-RUGB7NAN.js} +1 -1
  16. package/dist/{chunk-U2NEVISJ.js → chunk-S24PK62Y.js} +1 -1
  17. package/dist/{chunk-J3RW4GMO.js → chunk-S3QZOIUO.js} +1 -1
  18. package/dist/{chunk-LUDTXNMH.js → chunk-S55446VK.js} +1 -1
  19. package/dist/chunk-TBXHEGSY.js +1 -0
  20. package/dist/{chunk-YB3PQ75M.js → chunk-UM5R4RNN.js} +2 -2
  21. package/dist/{chunk-MZ6NEOOQ.js → chunk-XZLGDFZ4.js} +1 -1
  22. package/dist/{configuration-sync-DeWWW5za.d.ts → configuration-sync-Dad8B5Pv.d.ts} +3 -3
  23. package/dist/{content-5OMLKBPP.js → content-IFXC4OBS.js} +1 -1
  24. package/dist/{funnel-host-purchase-53LYWG4V.js → funnel-host-purchase-NS7FJH2F.js} +1 -1
  25. package/dist/{funnel-host-recovery-paywall-FC3XQU2U.js → funnel-host-recovery-paywall-R4QGRGIJ.js} +1 -1
  26. package/dist/{funnel-local-client-Fxsyl7rh.d.ts → funnel-local-client-Cb9jJGpo.d.ts} +53 -53
  27. package/dist/{funnel-paywall-prerender-YCATKDAY.js → funnel-paywall-prerender-5NVQIQIV.js} +1 -1
  28. package/dist/{funnel-process-client-D9saqPse.d.ts → funnel-process-client-DE650LzB.d.ts} +28 -28
  29. package/dist/{funnel-runtime-host-LQ6X5B6R.js → funnel-runtime-host-6VL6UAF5.js} +1 -1
  30. package/dist/index.d.ts +13 -13
  31. package/dist/index.js +1 -1
  32. package/dist/native-shell.js +1 -1
  33. package/dist/openrouter.d.ts +3 -3
  34. package/dist/openrouter.js +1 -1
  35. package/dist/page.d.ts +2 -2
  36. package/dist/page.js +1 -1
  37. package/dist/{paywall-KQIBPACY.js → paywall-47DXK7WR.js} +1 -1
  38. package/dist/{paywall-content-NQXU3O4D.js → paywall-content-MNMF4QKA.js} +1 -1
  39. package/dist/{paywall-session-W42F6DIF.js → paywall-session-APGD7FZ5.js} +1 -1
  40. package/dist/popup.d.ts +23 -3
  41. package/dist/popup.js +1 -1
  42. package/dist/{presentation-loading-CjljfuJq.d.ts → presentation-loading-B8W6a9WB.d.ts} +10 -46
  43. package/dist/react-native.d.ts +7 -7
  44. package/dist/react-native.js +1 -1
  45. package/dist/{screen-renderer-2ZDV2WYD.js → screen-renderer-3YO6EUWD.js} +1 -1
  46. package/dist/server.d.ts +10 -10
  47. package/dist/server.js +1 -1
  48. package/dist/visual.js +1 -1
  49. package/package.json +1 -1
  50. package/dist/chunk-IMFPRZUY.js +0 -1
  51. package/dist/chunk-O2V4MTM6.js +0 -1
  52. package/dist/chunk-PTNMDAND.js +0 -1
  53. package/dist/chunk-XY2X6YJF.js +0 -1
  54. package/dist/{chunk-YB3PQ75M.js.LEGAL.txt → chunk-UM5R4RNN.js.LEGAL.txt} +0 -0
  55. package/dist/{funnel-node-evaluation-CRRTh1je.d.ts → funnel-node-evaluation-COIh1hKs.d.ts} +3 -3
  56. package/dist/{screen-D2bUmJ4M.d.ts → screen-Pv_pViF6.d.ts} +21 -21
@@ -1 +1 @@
1
- var s={name:"@tinkerlandai/longplay-sdk",version:"0.10.59",description:"Framework-independent Longplay SDK for customer identity, entitlements, credits, offers and growth surfaces.",license:"UNLICENSED",repository:{type:"git",url:"git+https://github.com/tinkerlandai/Indiana.git",directory:"packages/sdk"},engines:{node:">=22"},publishConfig:{access:"public",tag:"beta"},type:"module",sideEffects:!1,files:["dist","README.md","README.zh-CN.md","CHANGELOG.md","THIRD_PARTY_NOTICES.md","native-funnel-host.NOTICES.txt"],exports:{"./react-native":{types:"./dist/react-native.d.ts","react-native":"./dist/react-native.js",import:"./dist/react-native.js",default:"./dist/react-native.js"},".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./popup":{types:"./dist/popup.d.ts",import:"./dist/popup.js"},"./server":{types:"./dist/server.d.ts",import:"./dist/server.js"},"./openrouter":{types:"./dist/openrouter.d.ts",import:"./dist/openrouter.js"},"./native-shell":{types:"./dist/native-shell.d.ts",import:"./dist/native-shell.js"},"./page":{types:"./dist/page.d.ts",import:"./dist/page.js"},"./visual":{types:"./dist/visual.d.ts",import:"./dist/visual.js"}},scripts:{build:"tsup",prepack:"pnpm run build",typecheck:"tsc --noEmit && tsc --noEmit -p tsconfig.test.json",lint:"node ../../scripts/ci/lint.mjs --workspace packages/sdk"},dependencies:{"@ai-sdk/provider":"4.0.26","@types/json-schema":"7.0.15","css-tree":"^3.2.1","dom-mutator":"0.7.0",dompurify:"^3.4.15",zod:"4.6.6"},devDependencies:{"@indiana/contracts":"workspace:*","@openrouter/sdk":"^1.4.25","@types/css-tree":"^3.2.0",ai:"7.0.136",tsup:"^8.5.1",typescript:"^5.9.3","whatwg-url-minimum":"0.2.0"},peerDependencies:{"@openrouter/sdk":"^1.4.25"},peerDependenciesMeta:{"@openrouter/sdk":{optional:!0}}};export{s as a};
1
+ var s={name:"@tinkerlandai/longplay-sdk",version:"0.10.60",description:"Framework-independent Longplay SDK for customer identity, entitlements, credits, offers and growth surfaces.",license:"UNLICENSED",repository:{type:"git",url:"git+https://github.com/tinkerlandai/Indiana.git",directory:"packages/sdk"},engines:{node:">=22"},publishConfig:{access:"public",tag:"beta"},type:"module",sideEffects:!1,files:["dist","README.md","README.zh-CN.md","CHANGELOG.md","THIRD_PARTY_NOTICES.md","native-funnel-host.NOTICES.txt"],exports:{"./react-native":{types:"./dist/react-native.d.ts","react-native":"./dist/react-native.js",import:"./dist/react-native.js",default:"./dist/react-native.js"},".":{types:"./dist/index.d.ts",import:"./dist/index.js"},"./popup":{types:"./dist/popup.d.ts",import:"./dist/popup.js"},"./server":{types:"./dist/server.d.ts",import:"./dist/server.js"},"./openrouter":{types:"./dist/openrouter.d.ts",import:"./dist/openrouter.js"},"./native-shell":{types:"./dist/native-shell.d.ts",import:"./dist/native-shell.js"},"./page":{types:"./dist/page.d.ts",import:"./dist/page.js"},"./visual":{types:"./dist/visual.d.ts",import:"./dist/visual.js"}},scripts:{build:"tsup",prepack:"pnpm run build",typecheck:"tsc --noEmit && tsc --noEmit -p tsconfig.test.json",lint:"node ../../scripts/ci/lint.mjs --workspace packages/sdk"},dependencies:{"@ai-sdk/provider":"4.0.26","@types/json-schema":"7.0.15","css-tree":"^3.2.1","dom-mutator":"0.7.0",dompurify:"^3.4.15",zod:"4.6.6"},devDependencies:{"@indiana/contracts":"workspace:*","@openrouter/sdk":"^1.4.25","@types/css-tree":"^3.2.0",ai:"7.0.136",tsup:"^8.5.1",typescript:"^5.9.3","whatwg-url-minimum":"0.2.0"},peerDependencies:{"@openrouter/sdk":"^1.4.25"},peerDependenciesMeta:{"@openrouter/sdk":{optional:!0}}};export{s as a};
@@ -1 +1 @@
1
- import{e as w,f as b}from"./chunk-BJW4AXFL.js";import{n as h,s as u}from"./chunk-32AEJKJW.js";import{a as y}from"./chunk-J7VGTAJ7.js";import{a as n}from"./chunk-TK3WOD2O.js";import{a as g}from"./chunk-3VUPVXAV.js";import{a as f}from"./chunk-5MRSFLQA.js";function p(r,s){let a=typeof r=="string"?new TextEncoder().encode(r):r;return a.byteLength===s.byteLength&&u(a)===s.sha256}async function _(r,s){let a=w.parse(s),{artifact:i,environmentId:P}=a.content,m=new y(r.baseUrl??f).origin,e=new y(i.url,m);if(e.origin!==m||e.username||e.password||e.search||e.hash||e.pathname!==`/api/v1/configuration/${P}/artifacts/${i.sha256}`)throw new n("INVALID_RESPONSE","Public Paywall locator is not trusted");let o=new AbortController,d,I=new Promise((t,l)=>{d=setTimeout(()=>{let c=new n("TIMEOUT","Public Paywall read timed out");o.abort(c),l(c)},h.initializationMs)}),E=(async()=>{let t=await(r.fetch??globalThis.fetch)(e,{method:"GET",credentials:"omit",redirect:"error",cache:"default",signal:o.signal});if(o.signal.aborted&&(t.body?.cancel().catch(()=>{}),o.signal.throwIfAborted()),!t.ok||!t.headers.get("content-type")?.toLowerCase().startsWith("application/json")||Number(t.headers.get("content-length"))>i.byteLength)throw t.body?.cancel().catch(()=>{}),new n("INVALID_RESPONSE","Public Paywall is unavailable");let l=await g(t,i.byteLength,{signal:o.signal,error:c=>new n("INVALID_RESPONSE",c==="missing"?"Public Paywall body is missing":"Public Paywall exceeds its byte limit")});if(!p(l,i))throw new n("INVALID_RESPONSE","Public Paywall digest or size changed");return b(a,JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(l)))})();try{return await Promise.race([E,I])}finally{clearTimeout(d)}}export{p as a,_ as b};
1
+ import{e as w,f as b}from"./chunk-BJW4AXFL.js";import{n as h,s as u}from"./chunk-32AEJKJW.js";import{a as y}from"./chunk-QJPH7AFI.js";import{a as n}from"./chunk-TK3WOD2O.js";import{a as g}from"./chunk-3VUPVXAV.js";import{a as f}from"./chunk-5MRSFLQA.js";function p(r,s){let a=typeof r=="string"?new TextEncoder().encode(r):r;return a.byteLength===s.byteLength&&u(a)===s.sha256}async function _(r,s){let a=w.parse(s),{artifact:i,environmentId:P}=a.content,m=new y(r.baseUrl??f).origin,e=new y(i.url,m);if(e.origin!==m||e.username||e.password||e.search||e.hash||e.pathname!==`/api/v1/configuration/${P}/artifacts/${i.sha256}`)throw new n("INVALID_RESPONSE","Public Paywall locator is not trusted");let o=new AbortController,d,I=new Promise((t,l)=>{d=setTimeout(()=>{let c=new n("TIMEOUT","Public Paywall read timed out");o.abort(c),l(c)},h.initializationMs)}),E=(async()=>{let t=await(r.fetch??globalThis.fetch)(e,{method:"GET",credentials:"omit",redirect:"error",cache:"default",signal:o.signal});if(o.signal.aborted&&(t.body?.cancel().catch(()=>{}),o.signal.throwIfAborted()),!t.ok||!t.headers.get("content-type")?.toLowerCase().startsWith("application/json")||Number(t.headers.get("content-length"))>i.byteLength)throw t.body?.cancel().catch(()=>{}),new n("INVALID_RESPONSE","Public Paywall is unavailable");let l=await g(t,i.byteLength,{signal:o.signal,error:c=>new n("INVALID_RESPONSE",c==="missing"?"Public Paywall body is missing":"Public Paywall exceeds its byte limit")});if(!p(l,i))throw new n("INVALID_RESPONSE","Public Paywall digest or size changed");return b(a,JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(l)))})();try{return await Promise.race([E,I])}finally{clearTimeout(d)}}export{p as a,_ as b};
@@ -0,0 +1 @@
1
+ import{b as Bn}from"./chunk-6TETQL5Z.js";import{a as wn}from"./chunk-R4CYPCBI.js";import{a as Ln,b as Un,c as fn,d as mn,e as $e,f as Vn,h as $n,i as Mn,j as xn,k as zn}from"./chunk-QXDLOPZK.js";import{a as Jn}from"./chunk-45PGU2HW.js";import{a as Sn}from"./chunk-W32FI2A2.js";import{c as On,e as qn,f as Hn,i as Nn,j as Le,k as nn,l as _n,m as tn}from"./chunk-IM5OXTEH.js";import{b as An}from"./chunk-ZCJEXNJD.js";import{a as pn,d as Dn}from"./chunk-NDNHTG5B.js";import{C as Tn}from"./chunk-ZRGL2CAP.js";import{a as ne}from"./chunk-TK3WOD2O.js";import{a as Ie}from"./chunk-DSPLGTQI.js";function Gn(i){let E=new Set,_=new Set,n=null;async function p(a,f){let H=!1;for(;!i.stopped&&i.key===a&&i.client.pendingCommand?.requestId===f;){if(!i.client.settle)throw new ne("COMMAND_PENDING","The original display acknowledgement is still pending");await i.client.settle(f),H=!0,i.client.pendingCommand?.requestId===f&&await new Promise(L=>setTimeout(L,1500))}i.stopped||i.key!==a||(H&&await i.client.get(),!(i.stopped||i.key!==a)&&E.add(a))}function k(a,f){n=f;let H=()=>{n===f&&(n=null),_.delete(a)};return f.then(H,L=>{H(),i.busy||i.fail(L)}),f}function U(a){if(i.reviewing||E.has(a)||_.has(a)||i.stopped)return;_.add(a);let f=async()=>{if(i.reviewing||i.stopped||i.key!==a||E.has(a)){_.delete(a);return}if(i.busy||i.client.pendingCommand){setTimeout(()=>{f()},250);return}let H=(async()=>{if(i.staleRead){if(await i.staleRead,i.stopped||i.key!==a)return;if(i.client.pendingCommand){setTimeout(()=>{f()},250);return}}let L=i.client.view,oe=i.expected(),u=oe.requestId;try{await i.client.submit({operation:"shown",...oe})}catch(b){if(!(b instanceof ne)||b.code!=="CONFLICT"||b.status!==409||i.client.pendingCommand)throw b;await i.client.get();let s=i.client.view;if(i.stopped||i.reviewing||i.key!==a||!s||!L||s.id!==L.id||s.source.versionId!==L.source.versionId||s.nodeId!==oe.nodeId||s.visit!==oe.visit||s.revision<=oe.revision||s.stopped||!s.screen&&(!s.paywall||s.paywall.receiptId!==L.paywall?.receiptId)||!["running","waiting"].includes(s.status)||i.client.pendingCommand)throw b;let r=i.expected();u=r.requestId,await i.client.submit({operation:"shown",...r})}await p(a,u)})();k(a,H)};f()}function D(){if(n)return n;let a=i.client.pendingCommand;if(a?.operation!=="shown")return null;let f=i.key;return _.add(f),k(f,(async()=>{await i.client.retry(),await p(f,a.requestId)})())}return{report:U,settled:D,get inFlight(){return n}}}function Qn(i){let E={},_=new Map;async function n(p){let k=i.client.view,U=k?.screen,D=U?.customerData.nodes[p.nodeId];if(i.stopped||i.busy||!k||!U||!D)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(p.action)){let b=i.document,s=b?Tn(b,p.nodeId):null,r=s?.type==="customer_data"?s.data.outputs?.[p.action]:void 0;r&&U.outputs.includes(r)?await i.perform(()=>i.client.submit({operation:"submit",...i.expected(),input:{type:"screen",output:r,answers:i.answers,selection:p.value?{[p.nodeId]:p.value}:{}}})):await i.onIntent?.(p,k);return}let f=p.action.startsWith("sources_")?D.resources.find(b=>b.key===p.value):null;if(p.action.startsWith("sources_")&&!f)throw new ne("INVALID_REQUEST","Choose a current resource");let H=`${k.visit}:${p.nodeId}:${f?.key??""}`,L=_.get(H)??[null],u=E[p.nodeId]??{page:1,after:null,filter:"all",...f?{resourceKey:f.key}:{}};if(p.action==="filter"){let b=p.value;if(!b||!(D.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(b))throw new ne("INVALID_REQUEST","Unknown data filter");u={page:1,after:null,filter:b},L.splice(0,L.length,null)}else if(p.action==="next"||p.action==="sources_next"){let b=f?.sources.at(-1),s=f?b?{kind:"ledger",cursor:{at:b.detail[0],id:b.id,type:"source"}}:null:U.dataCursors[p.nodeId];if(!s||!f&&!D.hasNext)return;L[u.page]=s,u={...u,page:u.page+1,after:s}}else if(p.action==="previous"||p.action==="sources_previous"){if(u.page<=1)return;u={...u,page:u.page-1,after:L[u.page-2]??null}}_.set(H,L),E={...E,[p.nodeId]:u},await i.perform(()=>i.client.get({nodeId:k.nodeId,visit:k.visit,revision:k.revision,components:E}))}return{get queries(){return E},intent:n,reset(){E={},_.clear()}}}function Wn(i){let{doc:E,holder:_,reviewHolder:n,mountScreenPreview:p}=i,k=!1,U,D=0,a=null,f="",H,L=new Map,oe=s=>s?`${s.id}:${s.nodeId}:${s.visit}:${s.revision}:${s.paywall?.quote?.operationId??""}`:"";async function u(s){if(i.stopped||!i.client.review||k&&s===U&&H?.active)return;let r=!k||s!==U;k||(f=oe(i.client.view),L.set(f,structuredClone(i.answers))),k=!0,U=s,_.hidden=!0,i.suspend(!0),n.hidden=!1;let S=++D;r&&(H?.finish("dismissed"),a?.destroy(),a=null,n.replaceChildren(),H=nn(n,i.loadingOptions,"funnel",()=>{b()}));let A=r?H:void 0;try{if(A?.start(!1,i.client.view?.locale),S!==D||i.stopped)return;let de=i.client.review(s),N=await(A?.wait(de,Le)??de);if(i.stopped||S!==D||!k)return;if(!N.review)throw new ne("INVALID_RESPONSE","Historical projection is missing");a?.destroy(),a=null,A||n.replaceChildren();let Q=E.createElement("div"),W=A?tn(Q,n):()=>{};n.append(Q);let O=N.run.locale.startsWith("zh"),g=i.chrome;Q.style.cssText=g.history;let j=E.createElement("p");j.textContent=O?"只读回看":"Read-only history",j.style.cssText=g.historyTitle,Q.append(j);let F=E.createElement("p");F.style.cssText=g.historyNote,F.textContent=N.review.pages.length?O?"选择一页查看当时的内容,回看不会改动任何信息。":"Choose a page to see it as it was. Nothing here can be changed.":O?"还没有可回看的页面。":"There are no earlier pages yet.",Q.append(F);let Te=N.review.page?.receiptId,ve=E.createElement("div");ve.style.cssText=g.historyPages;for(let[K,P]of N.review.pages.entries()){let v=E.createElement("button");v.type="button",v.textContent=O?`第 ${K+1} 页`:`Page ${K+1}`;let he=Te!==void 0&&P.receiptId===Te;v.style.cssText=he?g.primary:g.secondary,he&&v.setAttribute("aria-current","page"),$e(v,()=>i.chrome.focus),v.onclick=()=>{u(P.receiptId)},ve.append(v)}if(ve.childElementCount&&Q.append(ve),N.review.page){let K=N.review.page,P=E.createElement("div");P.inert=!0,P.style.cssText=g.historyPage,Q.append(P),a=p(P,{mode:"live",rendererUrl:i.client.webViewUrl,title:K.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{S===D&&!i.stopped&&A?.present(W)},onError:he=>{if(S!==D||i.stopped)return;let Ce=new Error(he);A?.finish("error",Ce),a?.destroy(),a=null,Q.remove(),i.fail(Ce)},onEscape:()=>{b()}});let v=a;if(v.update(K.document,N.run.locale,{serverInput:{bindings:K.inputs,answers:K.answers,values:K.values}}),await v.ready,i.stopped||S!==D||!k)return}let me=O?{issued:"已领取",reserved:"已预留",redeemed:"已使用",expired:"已过期",revoked:"已撤销",unknown:"状态待确认"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"},z=E.createElement("div");z.style.cssText=g.historyRecords;for(let K of[...N.review.coupons.map((P,v)=>`${O?"优惠券":"Coupon"} ${v+1}: ${me[P.status]}`),...N.review.purchases.map((P,v)=>`${O?"购买":"Purchase"} ${v+1}: ${zn(P.status,O)}`)]){let P=E.createElement("p");P.textContent=K,P.style.margin="0",z.append(P)}z.childElementCount&&Q.append(z),N.review.page||A?.present(W),i.client.view&&await i.enqueue(i.client.view)}catch(de){if(S!==D||i.stopped)return;A?.finish("error",de),a?.destroy(),a=null,n.replaceChildren(),i.fail(de)}}async function b(){if(!k||i.stopped||!i.client.review)return;let s=++D;H?.finish("dismissed");try{if(await i.client.review(),i.stopped||s!==D)return;k=!1,D++,H?.finish("dismissed"),a?.destroy(),a=null,n.replaceChildren(),n.hidden=!0,_.hidden=!1;let r=i.client.view;oe(r)!==f?(L.set(f,structuredClone(i.answers)),i.resetScreen()):(L.delete(f),i.suspend(!1)),r&&await i.enqueue(r)}catch(r){if(s!==D||i.stopped)return;a?.destroy(),a=null,n.replaceChildren(),i.fail(r)}}return{get active(){return k},get receipt(){return U},open:u,exit:b,get drafts(){return new Map([...L].map(([s,r])=>[s,structuredClone(r)]))},stop(){k=!1,D++,H?.finish("dismissed"),a?.destroy(),a=null,n.replaceChildren(),n.hidden=!0,_.hidden=!1}}}var yn=5e3;async function et(i,E,_){let n=E,p=n.prepared&&Bn(n.prepared),k=()=>{};function U(){n.prepared&&n.prepared.state!=="adopted"&&p?.release()}let D=()=>n.prepared?.state==="shown"&&!!p?.modal,a=n.client.identitySignal,f;try{f=await Promise.all([import("./screen-renderer-3YO6EUWD.js"),import("./paywall-47DXK7WR.js")]),n.signal?.throwIfAborted(),a?.throwIfAborted()}catch(e){throw U(),e}let[{mountScreenPreview:H},{showPaywall:L}]=f,oe=(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&n.appManifestRelease?Jn({client:n.client,appManifestRelease:n.appManifestRelease,onError:n.onError}):void 0;oe?.start();let u=i.ownerDocument,b=Nn(u),s=!1,r=u.createElement("section"),S=u.createElement("div"),A=u.createElement("div"),de=u.createElement("div"),N=u.createElement("button");de.hidden=!0,N.type="button";let Q=u.createElement("p"),W=u.createElement("p"),O=u.createElement("button"),g=u.createElement("button"),j=u.createElement("button"),F=u.createElement("dialog"),Te,ve=!1;r.dataset.indianaFunnel="",r.dataset.longplayCloseOwner="sdk",r.setAttribute("aria-busy","false"),Q.setAttribute("role","status"),W.setAttribute("role","alert"),W.hidden=!0,O.type=g.type=j.type="button",A.append(O,N,Q,W,j,g),r.append(S,de,A),i.append(r);let me=Un,z=fn(me),K="",P=(u.documentElement.lang||"").startsWith("zh"),v,he="",Ce;for(let e of[O,N,j,g])$e(e,()=>z.focus);function gn(){let e=P?"关闭":"Close";g.parentElement===F?(g.textContent="×",g.setAttribute("aria-label",e),Hn(g,me)):(g.textContent=e,g.removeAttribute("aria-label"),g.style.cssText=z.link+";margin-inline-start:auto")}function Me(e){let t=e?.screen?.content.document.theme??me,o=JSON.stringify([t.primary,t.background,t.text,t.radius,t.font,g.parentElement===F]);if(o===K)return;K=o,me=t;let h=g.parentElement===F;z=fn(me,h),r.style.cssText=z.root+";min-width:0"+(h?";display:flex;flex-direction:column;min-height:100%":""),A.style.cssText=z.bar+(h?";margin-top:auto":""),A.hidden&&(A.style.display="none"),O.style.cssText=N.style.cssText=z.secondary,j.style.cssText=z.primary,Q.style.cssText=z.status,W.style.cssText=z.alert,gn(),mn(O)}function be(){A.hidden=O.hidden&&N.hidden&&j.hidden&&W.hidden&&!Q.textContent&&(g.hidden||g.parentElement!==A),A.style.display=A.hidden?"none":"flex",v?.responsive&&Ce!==void 0&&v.setContentHeight(Ce+A.getBoundingClientRect().height)}Me();let ae=null,I=null,le=null,we="",ee="",Pe=!1,xe="",rn="",ze="",l=!1,X=0,Be=!1,vn="",on=null,sn=Promise.resolve(),hn=!n.client.view,Ne,T=_,Je=n.hostPaywallTarget,Ae,_e,Ge="",Qe,te=!1,Re=null,ue=!1,We=()=>n.client.pendingCommand?.operation==="close",ie=null,V=null,an=Sn({document:u,run:async()=>{(!I?.observing||n.client.pendingCommand)&&await dn()},delay:()=>{if(!re.pending&&!(l||!le||!["running","waiting"].includes(le.status)&&!n.client.pendingCommand)&&!(I?.observing&&!n.client.pendingCommand))return le.pendingRequest||n.client.pendingCommand?1500:yn},hiddenDelay:()=>!l&&!re.pending&&n.client.pendingCommand?15e3:void 0}),M=null;function ln(){return V&&n.client.hasDurableJournal===!0&&M?.acknowledged===!0&&M.operationId===V.operationId&&n.client.view?.id===M.runId&&n.client.view?.status==="closed"&&n.client.view.revision===M.revision+1&&!(n.client.pendingCommands?.length??(n.client.pendingCommand?1:0))&&!n.client.pendingPurchase?V:null}function In(e){let t=e.run.paywall;if(M&&e.settlement?.requestId===M.requestId&&e.settlement.state==="settled"&&e.settlement.operationId===null&&e.run.id===M.runId&&e.run.status==="closed"&&!e.run.pendingRequest&&e.run.revision===M.revision+1&&e.run.nodeId===M.nodeId&&e.run.visit===M.visit&&t?.receiptId===M.receiptId&&t.selectionGeneration===M.selectionGeneration&&(t.quote?.operationId??null)===M.operationId&&(t.operation?.operationId??t.quote?.operationId??null)===M.operationId){let o=M.operationId===null&&t.selectionGeneration===0&&!t.quote&&!t.operation&&!t.purchaseRequestId,h=pn({quote:t.quote,operation:t.operation,requestId:t.purchaseRequestId,pending:!1,destroyed:!1,canReselect:t.canReselect});(o||t.canReselect===!0&&h.type==="native")&&(M.acknowledged=!0)}}let Ee=null,Ue=new Set,ce={},De=!1,Y=(e,t=null)=>{l||(e instanceof ne&&e.status===409&&e.reason==="STATE_CHANGED"&&e.recovery==="recover_operation"&&an.destroy(),Ee=t,De=!1,W.textContent=Vn(e,P),W.hidden=!1,j.hidden=n.client.pendingCommand===null,be(),Ie(n.onError,e))},re=An({client:n.client,document:u,conceal(){l||(pe(),T?.finish("dismissed"),r.hidden=!0,s||(s=!0,b()))},async receive(e){l||await se(n.client.view??e.run)},failed(e){if(!l){if(!re.pending){ue=!1;let t=n.client.view;t&&se(t).then(()=>Y(e),Y);return}Ze(),r.parentElement!==i&&i.append(r),r.hidden=!1,O.hidden=N.hidden=g.hidden=!0,Q.textContent="",Me(),Y(e,n.client.pendingCommand?.requestId??null)}}}),Cn=()=>{l||(Ee=null,W.textContent=Mn(P),W.hidden=!1,j.hidden=!0,be())};function ke(){let e=n.client.view;if(!e)throw new ne("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:e.revision}}let w=Wn({client:n.client,doc:u,holder:S,reviewHolder:de,mountScreenPreview:H,loadingOptions:n,get chrome(){return z},get stopped(){return l},get answers(){return ce},suspend(e){I?.setSuspended(e)},resetScreen(){we="",ee="",xe=""},enqueue:se,fail:Y}),Ve=Gn({client:n.client,expected:ke,fail:Y,get stopped(){return l},get reviewing(){return w.active},get key(){return we},get busy(){return X},get staleRead(){return on}}),je=Qn({client:n.client,expected:ke,perform:Oe,onIntent:n.onCustomerDataIntent,get stopped(){return l},get busy(){return X},get document(){return ae?.document},get answers(){return ce}}),Xe=e=>`${e.id}:${e.nodeId}:${e.visit}`,Se=e=>e&&(e.screen||e.paywall)?Xe(e):"";function ye(){let e=n.client.view;O.disabled=!w.active&&(X>0||!!n.client.pendingCommand||!e?.canBack||e.stopped||!["running","waiting"].includes(e.status)||!Se(e)||ee!==Se(e)),O.hidden=!w.active&&!e?.canBack,mn(O);let t=!!I&&!w.active;g.hidden=t&&!T?.active||ve&&!w.active,N.hidden=!n.client.review||!w.active&&!e?.canBack;let o=e?.locale.startsWith("zh");Q.textContent=t?"":X>0||e?.pendingRequest?o?"正在处理":"Processing":e?.instruction?.type==="wait"?o?"等待中":"Waiting":"",be()}async function bn(e){if(!e)return;let t=n.client.view;await e;let o=n.client.view;if(!t||!o||o.id!==t.id||o.nodeId!==t.nodeId||o.visit!==t.visit||o.stopped||!["running","waiting"].includes(o.status))throw new ne("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function Oe(e,t=!1,o){if(!((X||ue||ie||V)&&!t||l||w.active&&!t)){X++,r.setAttribute("aria-busy","true"),W.hidden=!0,Ee=null,De=!1,ye();try{if(t||await bn(Ve.inFlight),l)return;let h=await e();l||await se(n.client.view??h.run)}catch(h){o?.(h)&&n.client.pendingCommand===null?Cn():re.pending||Y(h,n.client.pendingCommand?.requestId??null)}finally{X=Math.max(0,X-1),r.setAttribute("aria-busy",String(X>0)),l||(j.hidden=n.client.pendingCommand===null,ye())}}}function qe(){an.schedule()}async function dn(){if(!(l||Be||X)&&!re.pending){if(w.active){await w.open(w.receipt);return}Be=!0;try{let e=n.client.pendingCommand;e&&n.client.settle&&await n.client.settle(e.requestId);let t=n.client.view,o=je.queries,h=await n.client.get(t?.screen&&Object.keys(o).length?{nodeId:t.nodeId,visit:t.visit,revision:t.revision,components:o}:void 0);De&&!l&&(De=!1,W.hidden=!0,be()),!l&&o===je.queries&&await se(n.client.view??h.run)}catch(e){Y(e),De=!l}finally{Be=!1}}}function Ye(e,t,o){if(T?.active){let Z=T;return Z.setDismissHandler(()=>Pn(Z)),Z}let h=nn(i,n,"funnel",()=>Pn(h),Ln);return T=h,h.start(e,t,o),h}function Pn(e){l||te||(te=!0,e.finish("dismissed"),pe(),r.hidden=!0,n.client.view?ge().finally(B):B())}function un(){clearTimeout(Qe?.timeout),Qe=void 0}function pe(e){ve=!1,un(),Ae?.abort(),Ae=void 0,ae?.destroy(),ae=null,I?.destroy(),I=null,Ne=void 0,_e?.(),_e=void 0,F.open&&F.close();for(let t of Array.from(S.children))(!e||!t.contains(e))&&t.remove();S.style.cssText="",Ce=void 0,we="",ee="",Pe=!1,xe="",ze=""}function Rn(){let e=u.defaultView;v?.responsive&&e&&ae?.resizeViewport?.(e.innerHeight,e.innerWidth)}function Ze(){v?.destroy(),v=void 0,he=""}function Ke(e){let t=e.screen?.presentation;if(!t||t.type==="inline"){F.open&&F.close(),Ze(),g.parentElement!==A&&A.append(g),r.parentElement!==i&&i.append(r);for(let Z of["flex","display","flex-direction","justify-content"])S.style.removeProperty(Z);Me(e),be();return}r.parentElement!==F&&(F.append(g,r),i.append(F)),S.style.flex="1 0 auto",S.style.display="flex",S.style.flexDirection="column",S.style.justifyContent="center",Me(e);let o=e.screen.content.document,h=JSON.stringify([t,K]);if(h!==he){Ze(),he=h;let Z={sm:420,md:640,lg:900},fe="size"in t&&!t.backdrop?",0 0 0 100vmax #16142566":"";F.style.cssText=`box-sizing:border-box;padding:0;border:0;overflow:auto;background:${me.background};color:${me.text};`+(t.type==="fullscreen"?"width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border-radius:0":`width:${Z[t.size]}px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 24px 80px #0003${fe};`+(t.type==="sheet"?"margin:auto auto 0;border-radius:14px 14px 0 0":"border-radius:14px")),v=On(F,{presentation:t,theme:o.theme,pages:o.pages},Rn),v.latch()}be(),F.setAttribute("aria-label",(Te?.screen===e.screen?.content.document.name?Te?.label:void 0)??ae?.document?.name??e.screen?.content.document.name??"Funnel")}async function jn(e){if(l||te)return;if(re.observe(),re.pending){le=e;return}if(ue&&(We()||["running","waiting"].includes(e.status))||(le=e,Ee&&n.client.pendingCommand?.requestId!==Ee&&(W.hidden=!0,Ee=null),P=e.locale.startsWith("zh"),N.textContent=P?"回看":"History",O.textContent=w.active?P?"返回当前":"Return to current":P?"返回":"Back",gn(),j.textContent=P?"重试":"Retry",j.hidden=n.client.pendingCommand===null,ye(),vn!==`${e.revision}:${e.visit}:${e.status}:${e.stopped}`&&(vn=`${e.revision}:${e.visit}:${e.status}:${e.stopped}`,Ie(n.onState,structuredClone(e))),l||te))return;if((!e.pendingRequest||ue&&e.status==="closed")&&["closed","ineligible","failed"].includes(e.status)){B();return}if(e.stopped&&D()){B();return}if(e.stopped||n.client.configurationReady===!1){w.stop(),U(),pe(),T?.finish("skipped"),r.hidden=!0,qe();return}if(r.hidden=!1,w.active){qe();return}if(e.status==="completed"&&I?.subscriptionUpgradeActive){qe();return}let t=Se(e),o=n.client.view;if(o&&o.revision>e.revision&&Se(o)!==t)return;let h=!e.instruction&&!e.pendingRequest&&e.nodeType==="screen"&&["running","waiting"].includes(e.status);t!==we&&(we&&T?.finish("dismissed"),pe(),we=t,ce={...e.answers},je.reset());let Z=Xe(e);if(Ge===Z){r.hidden=!0;return}if(h&&!t){r.hidden=!0;let C=n.prepared?.state==="shown"?null:Ye(!0,e.locale);!l&&!te&&Qe?.key!==Z&&(un(),Qe={key:Z,timeout:setTimeout(()=>{let d=n.client.view;if(l||!C?.active&&n.prepared?.state!=="shown"||!d||Xe(d)!==Z)return;Ge=Z;let q=new Error("Funnel screen preparation timed out");C?.finish("error",q),U(),pe(),Y(q)},Le)}),qe();return}un();let $=C=>{let d=n.client.view;return!l&&!te&&!Re&&!C.aborted&&n.client.configurationReady!==!1&&!!d&&!d.stopped&&!["closed","ineligible","failed"].includes(d.status)&&(Se(d)===t||d.status==="completed"&&I?.subscriptionUpgradeActive===!0)},fe=(C,d)=>{$(d)&&(Ge=t,T?.finish("error",C),pe(),r.hidden=!0,Y(C))};if(t||((e.instruction&&e.instruction.type!=="evaluate_segment"||!["running","waiting"].includes(e.status))&&U(),Ke(e),e.instruction?.type!=="event"&&e.instruction?.type!=="open_url"&&T?.finish("skipped")),e.screen){Je=void 0,U();let C=e.screen.content;if(!ae){let G=e.screen.presentation.type!=="inline",R=Ye(G,e.locale);if(l||te)return;let x=(Ae=new AbortController).signal;Ke(e),_e=G?_n(F):tn(r,i),ae=H(S,{mode:"live",closeActions:Array.from(new Set([...n.closeActions??[],...C.document.actions.filter(y=>y.type==="event"&&y.close).map(y=>y.id)])),onAuthoredClose(y){$(x)&&(ve=y,ye())},rendererUrl:n.client.webViewUrl,title:C.document.name,...G?{hostPresentation:()=>v?.type??e.screen.presentation.type}:{},onResize:y=>{Ce=y,v?.responsive&&v.setContentHeight(y+A.getBoundingClientRect().height)},onAction(y,c={},Fe={}){if(w.active||!$(x)||ee!==t)return;ce={...ce,...Fe};let cn=e.screen?.inputs??[],Fn=Object.fromEntries(cn.filter(({variable:He})=>Object.hasOwn(ce,He)).map(({variable:He})=>[He,ce[He]]));if(xn(cn,Fn).length){Cn();return}Oe(()=>n.client.submit({operation:"submit",...ke(),input:{type:"screen",output:y,answers:Fn,selection:c}}),!1,He=>$n(He,cn))},onAnswers:y=>{w.active||!$(x)||ee!==t||(ce={...ce,...y})},onCustomerDataIntent:y=>{w.active||!$(x)||ee!==t||je.intent(y).catch(Y)},onEscape:()=>{!$(x)||ee!==t||w.active||ie||V||ge()},onError:y=>{let c=new Error(y);ee===t?Y(c):fe(c,x)},onRendered:y=>{if(!(!$(x)||ee===t))try{R.present(c=>{_e?.(),_e=void 0,y&&(Te={screen:C.document.name,label:y},F.setAttribute("aria-label",y)),G&&(F.showModal(),s=!1,v?.responsive&&F.focus({preventScroll:!0}),!c&&n.loading!=="host"&&qn(F,v?.type??e.screen.presentation.type,v?.responsive)),ee=t,Pe=G,ye()}),$(x)&&Ve.report(t)}catch(c){fe(c,x)}}}),Rn()}let d={capabilities:e.screen.capabilities,customerData:e.screen.customerData,parameters:e.parameters,serverInput:{bindings:e.screen.inputs,answers:ce,values:e.screen.values}},q=JSON.stringify([C,e.locale,d.parameters,e.screen.inputs,e.screen.values]);if(q!==xe)ae.update(C.document,e.locale,d),xe=q,rn=JSON.stringify(d.capabilities),ze=JSON.stringify(d.customerData);else{let G=JSON.stringify(d.capabilities);G!==rn&&(ae.updateCapabilities(d.capabilities),rn=G),JSON.stringify(d.customerData)!==ze&&(ae.updateCustomerData(d.customerData),ze=JSON.stringify(d.customerData))}let J=ae;if(J)try{await(T?.wait(J.ready)??J.ready)}catch(G){Ae&&fe(G,Ae.signal)}}else if(e.paywall&&!I){let C=e.paywall.resolution,d="document"in C?C.document:null,q=p,J=n.mountPaywallControls,G=null,R=(Ae=new AbortController).signal,x={loading:"host",signal:R,...J&&{mountControls:c=>J(c,e)},canInteract:()=>$(R)&&!w.active&&!ie&&!V,beforeAction:async()=>{X++;try{await bn(Ve.settled()),W.hidden=!0,Ee=null,De=!1,be()}finally{X=Math.max(0,X-1)}},start:()=>wn(n.client),onObservationChange:qe,onPurchase:n.onPurchase,onCheckoutUrl:n.onCheckoutUrl,resumeCheckout:n.resumeCheckout,allowNewPurchase:n.allowNewPurchase,checkoutNavigation:n.checkoutNavigation,terminateCheckout:n.terminateCheckout,beforeCheckoutReplacement:n.beforeCheckoutReplacement,purchaseConfirmation:n.purchaseConfirmation,confirmOnHostedCheckout:n.confirmOnHostedCheckout,resolveOfferId:n.resolveOfferId,resolveSubscriptionChange:n.resolveSubscriptionChange,claimCoupon:n.claimCoupon,onEvent:n.onEvent,onOpenUrl:c=>n.onOpenUrl?n.onOpenUrl({receiptId:e.paywall.receiptId,url:c,openIn:"same_window"}):u.defaultView?.location.assign(c),onAction:async c=>{if(w.active)return;let Fe=await n.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:n.client.view?.revision??e.revision,input:{type:"screen",output:c,answers:{}}});await se(n.client.view??Fe.run)},onError:c=>{ee===t?Y(c):fe(c,R)}},y={quoteError:c=>Ie(n.onError,c),present(c){$(R)&&(G?.present(Fe=>{c(Fe),ee=t,Pe=y.retainedDialog?.dialog.open??!!S.querySelector("dialog[open]"),Pe&&(s=!1),ye()}),$(R)&&Ve.report(t))},async closeAction(c){l||w.active||await re.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:n.client.view?.revision??e.revision,input:{type:"screen",output:c,answers:{}}})},async dismiss(){if(l||R.aborted||w.active||ie||V||!ue&&!$(R))return;ue=!0;let c=n.client.view;if(c?.status==="completed"&&I?.subscriptionUpgradeActive){Ue.add(`complete:${c.id}`),Ie(n.onComplete,structuredClone(c)),B();return}if((n.resumeCheckout||n.terminateCheckout)&&Kn()){le=n.client.view,B();return}await ge()}};if(q&&J)U();else if(q){let c=await q.adopt(e,{options:x,handoff:y,start:()=>wn(n.client)});c&&$(R)&&!l?(Ke(e),I=c,Ne={runId:e.id,receiptId:e.paywall.receiptId},T?.active&&T.present(()=>{}),ee=t,Pe=q.modal,Pe&&(s=!1),ye(),Ve.report(t),w.active&&I.setSuspended(!0)):(c?.destroy(),U())}if(l||te)return;if(!I){if(G=Ye(!0,e.locale,d),l||te)return;(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&n.loading==="host"&&Je?.ownerDocument===u&&(y.hostPaywallTarget=Je),Je=void 0,Ke(e);let c=await L(S,x,y).catch(Fe=>(fe(Fe,R),null));!$(R)&&!(ue&&!l&&!R.aborted)?c?.host?.destroy():c&&(I=c.host,I&&(Ne={runId:e.id,receiptId:e.paywall.receiptId}),I?.setSuspended(w.active))}}if(l||te)return;ye();let m=e.instruction;if(m&&(m.type==="open_url"||m.type==="event")&&!Ue.has(m.receiptId)){let C=u.createElement("button");C.type="button",C.style.cssText=z.primary,$e(C,()=>z.focus),S.style.cssText=z.stage,C.textContent=m.type==="open_url"?`${P?"前往":"Continue to"} ${new URL(m.url).host}`:P?"继续":"Continue",C.onclick=()=>{let d=ke(),q=m.type==="open_url"&&!n.onOpenUrl&&m.openIn==="new_window"?Xn(m.url):null;Oe(async()=>{let J="success";if(m.type==="open_url")if(n.onOpenUrl)try{J=await n.onOpenUrl({receiptId:m.receiptId,url:m.url,openIn:m.openIn})===!1?"failed":"opened"}catch(R){Ie(n.onError,R),J="failed"}else J=m.openIn==="new_window"&&!q?"failed":"opened";if(m.type==="event"){if(!n.onEvent)throw new ne("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(m.event)}if(l||n.client.view?.nodeId!==d.nodeId||n.client.view.visit!==d.visit)throw new ne("PRECONDITION_FAILED","The client action visit changed");let G=await n.client.submit({operation:"submit",...d,input:{type:"client_action",receiptId:m.receiptId,outcome:J}});return Ue.add(m.receiptId),m.type==="open_url"&&!n.onOpenUrl&&m.openIn==="same_window"&&u.defaultView?.location.assign(m.url),G})},T?.active?T.present(()=>S.replaceChildren(C)):S.replaceChildren(C)}!e.pendingRequest&&e.status==="completed"&&!Ue.has(`complete:${e.id}`)&&(Ue.add(`complete:${e.id}`),Ie(n.onComplete,structuredClone(e))),qe()}function Xn(e){let t=u.defaultView?.open(e,"_blank")??null;return t&&(t.opener=null),t}function se(e){return ye(),sn=sn.catch(()=>{}).then(async()=>{try{await jn(e)}catch(t){throw T?.active&&(Ge=Xe(e),T.finish("error",t),pe(),r.hidden=!0),t}}),sn}let Yn=n.client.subscribe(e=>{if(!hn){if(e.stopped&&(Pe||D())&&!ue){le=e,B();return}!ue&&(e.stopped||n.client.configurationReady===!1||we&&ee!==we&&(Se(e)!==we||["closed","ineligible","failed"].includes(e.status)))&&(pe(),T?.finish("dismissed"),r.hidden=!0),se(e).catch(Y)}}),Zn=n.client.subscribeError?.(e=>{re.pending||Y(e)});function Kn(){let e=n.client.view,t=e?.paywall;return!!t?.operation&&!!e&&["running","waiting"].includes(e.status)&&Dn(pn({quote:t.quote,operation:t.operation,requestId:t.purchaseRequestId,pending:!1,destroyed:!1,canReselect:t.canReselect}))}function ge(e){if(Re)return Re;if(l||!e&&(ie||V))return Promise.resolve();let t=!e&&We();return!t&&n.client.view&&!["running","waiting"].includes(n.client.view.status)?(le=n.client.view,B(),Promise.resolve()):(Re=Oe(async()=>{let o=t?await n.client.retry():await(e?n.client.submit.bind(n.client):re.submit)({operation:"close",...e??ke()});return e&&In(o),o},!0).then(()=>{let o=n.client.view;o?.status==="closed"&&!We()&&(le=o,B())}).finally(()=>{Re=null}),Re)}function B(){En()}function En(e){oe?.destroy(),!l&&(l=!0,re.destroy(),k(),U(),n.signal?.removeEventListener("abort",B),a?.removeEventListener("abort",B),T?.finish("dismissed"),an.destroy(),Yn(),Zn?.(),pe(e),Ze(),w.stop(),F.remove(),!e||!r.contains(e)?r.remove():(A.remove(),de.remove()),!e&&!s&&b(),Ie(n.onDismiss,le?structuredClone(le):null))}O.onclick=()=>{if(!O.disabled){if(w.active){w.exit();return}Oe(()=>n.client.submit({operation:"back",...ke()}))}},N.onclick=()=>{w.open()},g.onclick=()=>{T?.active?T.dismiss():ie||ge()},j.onclick=()=>{re.pending?re.retry().catch(()=>{}):We()?ge():Oe(()=>n.client.retry())},F.addEventListener("cancel",e=>{e.preventDefault(),T?.active?T.dismiss():ie||ge()}),n.signal?.addEventListener("abort",B,{once:!0}),a?.addEventListener("abort",B,{once:!0});let en=!1;p&&(k=p.onClose(()=>{l||te||(te=!0,T?.finish("dismissed"),pe(),r.hidden=!0,n.client.view?ge().finally(B):en=!0)}));let kn={destroy:B,refresh:dn,get recoveryPaywall(){if(I&&Ne)return{...Ne,view:I.currentResolution}},setPurchaseRecovery(e,t){return I?.setPurchaseRecovery(e,t),I!==null},retainPurchaseDialog(){let e=I?.retainPurchaseDialog();if(e)return I=null,En(e.dialog),{dialog:e.dialog,release(){e.release(),r.remove(),s||b()}}},get recovery(){let e=ln();if(e)return e;if(!l&&!X&&!ue&&!ie&&I){let t=I.recovery;if(t.type!=="native")return t}return{type:"recover",operationId:n.client.pendingPurchase?.operationId??n.client.view?.paywall?.quote?.operationId??V?.operationId??null,requestId:n.client.pendingCommand?.requestId??null}},prepareFallback(){if(ie)return ie;let e=ln();if(e)return Promise.resolve(e);let t=n.client.pendingPurchase?.operationId??n.client.view?.paywall?.quote?.operationId??V?.operationId??null,o=()=>({type:"recover",operationId:t,requestId:n.client.pendingCommand?.requestId??null});if(n.client.hasDurableJournal!==!0){let m=I?.recovery;return Promise.resolve(m&&m.type!=="native"&&m.type!=="cancel"?m:o())}let h=(n.client.pendingCommands??(n.client.pendingCommand?[n.client.pendingCommand]:[])).some(m=>m.operation==="close");if(l&&!(h||V&&n.client.view?.status==="closed")||X||Be||Re||w.active||!I&&!V&&!h)return Promise.resolve(o());let Z=I,$=(async()=>{try{if(!V&&h){let d=await n.client.retry();return await se(n.client.view??d.run),o()}if(!V){let d=await Z.prepareFallback();if(d.type!=="native")return d;if(n.client.hasDurableJournal!==!0)return o();V=d}let m=n.client.pendingCommands??(n.client.pendingCommand?[n.client.pendingCommand]:[]);if(m.length){let d=m.find(J=>J.operation==="close");if(!d||!M||d.requestId!==M.requestId)return o();let q=await n.client.retry();In(q),await se(n.client.view??q.run)}else{let d=n.client.view,q=d?.paywall;if(!d||!q||q.selectionGeneration===void 0||(q.quote?.operationId??null)!==V.operationId||V.operationId!==null&&q.canReselect!==!0)return o();let J=q.selectionGeneration,G=await n.client.get();await se(n.client.view??G.run);let R=n.client.view,x=R?.paywall;if(!R||!x||!["running","waiting"].includes(R.status)||R.stopped||R.id!==d.id||R.nodeId!==d.nodeId||R.visit!==d.visit||x.receiptId!==q.receiptId||x.selectionGeneration!==J||(x.quote?.operationId??null)!==V.operationId||V.operationId!==null&&x.canReselect!==!0||n.client.pendingPurchase||(n.client.pendingCommands?.length??(n.client.pendingCommand?1:0)))return o();let y=ke();M={runId:R.id,operationId:V.operationId,revision:y.revision,requestId:y.requestId,nodeId:R.nodeId,visit:R.visit,receiptId:x.receiptId,selectionGeneration:J,acknowledged:!1},await ge(y)}let C=ln();return C?(B(),C):o()}catch(m){return Y(m),o()}})();ie=$;let fe=()=>{ie===$&&(ie=null)};return $.then(fe,fe),$},review:w.open,exitReview:w.exit,get unappliedDrafts(){return w.drafts}};try{let e=n.client.view;if(e)((n.client.viewAgeMs??yn)>=yn||e.instruction?.type==="evaluate_segment")&&(on=dn().finally(()=>{on=null})),await se(e);else{if(r.hidden=!0,l)throw new DOMException("Presentation cancelled","AbortError");let t=en||n.prepared?.state==="shown"?null:Ye(n.client.view?.screen?.presentation.type!=="inline",n.client.view?.locale);if(l||te&&!en)throw new DOMException("Presentation cancelled","AbortError");let o=n.client.get(),h=await(t?t.wait(o,Le):nt(o,Le));if(hn=!1,en)return l||await ge().finally(B),kn;await se(n.client.view??h.run)}}catch(e){throw T?.finish("error",e),B(),e}return kn}function nt(i,E){let _;return Promise.race([i,new Promise((n,p)=>{_=setTimeout(()=>p(new Error("Presentation data timed out")),E)})]).finally(()=>clearTimeout(_))}function St(i,E,_){return et(i,E,_)}export{et as a,St as b};
@@ -1,2 +1,2 @@
1
- import{a as $,b as N,c as J,d as q}from"./chunk-MB2U2GWJ.js";import{a as P}from"./chunk-3VUPVXAV.js";import{a as D}from"./chunk-J3RW4GMO.js";import{a as _}from"./chunk-DSPLGTQI.js";import{b as C,c as O,e as j}from"./chunk-VPT5MFDG.js";async function B(e,t,o,n={}){let r=n.message??"Invalid SDK JSON response",s=e.headers.get("content-length");if(!e.ok||!/^application\/json(?:;|$)/i.test(e.headers.get("content-type")??"")||s!==null&&(!/^\d+$/.test(s)||Number(s)>t)||!e.body)throw e.body?.cancel().catch(()=>{}),Error(r);let u;try{u=await P(e,t,{signal:o,error:()=>Error(r)})}catch(p){throw o.aborted?Error(r):p}return JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(u))}async function G(e,t){if(!e?.body)return;let o=new AbortController,n=()=>o.abort(t?.reason);t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n();let r=setTimeout(()=>o.abort(Error("Exposure response timeout")),2e3);try{return await P(e,16384,{signal:o.signal,error:()=>Error("Exposure response budget")})}finally{clearTimeout(r),t?.removeEventListener("abort",n)}}var be=2*1024*1024,V=256*1024;async function Y(e,t,o,n){let r=()=>{},s=new Promise((u,p)=>{r=()=>p(n.reason),n.addEventListener("abort",r,{once:!0}),n.aborted&&r()});try{let u=e(t,{...o,signal:n});return u.then(p=>{n.aborted&&p.body?.cancel().catch(()=>{})},()=>{}),await Promise.race([u,s])}finally{n.removeEventListener("abort",r)}}async function M(e,t,o,n=!1){if(new TextEncoder().encode(o).byteLength>65536)throw Error("Exposure request budget");let r=new URL(t);r.searchParams.set("sdkVersion",D.version);let s=new AbortController,u=setTimeout(()=>s.abort(Error("Exposure request timeout")),5e3);try{let p=await Y(e,r.href,{method:"POST",headers:{"Content-Type":"text/plain"},body:o,credentials:"omit",keepalive:n,redirect:"error"},s.signal),a=await G(p,s.signal),c;try{c=a&&JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(a))}catch{}return{response:p,receipt:c}}finally{clearTimeout(u)}}function H(e){let t,o=!1;return{async read(n,r){if(o)throw Error("Experiment client stopped");t?.abort(Error("Experiment request superseded"));let s=new AbortController;t=s;let{signal:u}=s,p=setTimeout(()=>s.abort(Error("Experiment request timeout")),5e3);try{let a=await Y(e,n,{cache:"no-cache",credentials:"omit",redirect:"error"},u),c=await B(a,r,u);return u.throwIfAborted(),c}finally{clearTimeout(p),t===s&&(t=void 0)}},destroy(){o=!0,t?.abort(Error("Experiment client stopped")),t=void 0}}}var Q=20,ie=65536,se=5e3,ae=5,K=e=>new TextEncoder().encode(JSON.stringify(e)).length;function ce(e,t){let o=e,n=r=>Number.isSafeInteger(r)&&r>=0;return!!o&&typeof o=="object"&&n(o.inserted)&&n(o.duplicates)&&n(o.skipped)&&Array.isArray(o.rejected)&&o.inserted+o.duplicates+o.skipped+o.rejected.length===t&&o.rejected.every(r=>!!r&&typeof r=="object"&&n(r.index)&&r.index<t&&typeof r.reason=="string")&&new Set(o.rejected.map(r=>r.index)).size===o.rejected.length}function F(e){let t=[],o,n,r=(a,c)=>{try{e.log?.(`${e.label} ${a}`,c)}catch{}};function s(a){o===void 0&&!n&&t.length&&(o=setTimeout(()=>{p()},a))}async function u(a,c){let g,f;try{({response:g,receipt:f}=await M(e.fetch,e.endpoint,JSON.stringify({events:a}),c))}catch(h){return r("not sent",{error:h}),!1}return g.status===408||g.status===429||g.status>=500?(r("not sent",{status:g.status}),!1):g.ok?ce(f,a.length)?(f.rejected.length&&r("rejected",{rejected:f.rejected}),!0):(r("not acknowledged",{status:g.status}),!1):(r("rejected",{status:g.status,events:a.length}),!0)}function p(a=!0){if(n)return n;clearTimeout(o),o=void 0;let c=[],g=K({events:[]});for(;t.length&&c.length<Q;){let m=K(t[0].event)+(c.length?1:0);if(c.length&&g+m>ie)break;c.push(t.shift()),g+=m}if(!c.length)return Promise.resolve();let f=1e3,h=u(c.map(m=>m.event),a).then(m=>{if(m)return;f=se;let y=c.filter(b=>++b.attempts<ae);y.length<c.length&&r("dropped after retries",{events:c.length-y.length}),t.unshift(...y)}).finally(()=>{n===h&&(n=void 0),s(f)});return n=h,h}return{push(a){t.push({event:structuredClone(a),attempts:0}),t.length>=Q?p():s(1e3)},flush:p}}function ue(e,t){let o,n;try{o=new URL(e),n=new URL(t)}catch{return t}return o.searchParams.forEach((r,s)=>{n.searchParams.has(s)||n.searchParams.set(s,r)}),n.toString()}function de(e,t){let o=navigator.userAgent,n=new URLSearchParams(t.search),r={};for(let s of["source","medium","campaign","term","content"]){let u=n.get(`utm_${s}`);u!==null&&(r[`utm${s[0].toUpperCase()}${s.slice(1)}`]=u)}return{id:e,deviceId:e,url:t.href,path:t.pathname,host:t.host,query:t.search,pageTitle:typeof document>"u"?"":document.title,browser:/Edg/.test(o)?"edge":/Chrome/.test(o)?"chrome":/Firefox/.test(o)?"firefox":/Safari/.test(o)?"safari":"unknown",deviceType:/Mobi/.test(o)?"mobile":"desktop",...r}}function le(e){let t=e;if(!(!!t&&typeof t=="object"&&typeof t.environmentId=="string"&&typeof t.trackExposures=="boolean"&&/^[a-f0-9]{64}$/.test(t.generation??"")&&Array.isArray(t.experiments)&&t.experiments.length<=100&&t.experiments.every(n=>!!n&&!["namespace","status","url","groups"].some(r=>Object.hasOwn(n,r))&&(n.hashVersion===void 0||n.hashVersion===2)&&typeof n.key=="string"&&Array.isArray(n.variations)&&n.variations.length>=2&&n.variations.every(r=>!!r&&typeof r.urlRedirect=="string")&&(n.urlPatterns===void 0||Array.isArray(n.urlPatterns)))&&!!t.savedGroups&&typeof t.savedGroups=="object"&&!Array.isArray(t.savedGroups)))throw new Error("Invalid page experiment payload");return t}function Te(e){if(e.configuration&&e.configuration.scope.environmentId!==e.environmentId)throw new Error("Page configuration belongs to another App environment");let t=J(e.baseUrl);if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("environmentId must be the App environment ID");let o=e.fetch??globalThis.fetch.bind(globalThis),n=H(async(i,d)=>{let l=await o(i,d);if(!l.ok)throw l.body?.cancel().catch(()=>{}),new Error(`Page experiments unavailable (${l.status})`);return l}),r=e.log?(i,d)=>_(e.log,i,d):void 0,s=`${t}/api/v1/page-experiments/${e.environmentId}`,u=$(e.deviceIdCookie??"indiana_did"),p=N(),a=null,c={...e.attributes??{}},g="",f=!1,h=!1,m=0,y=0,b=new Map,S=F({endpoint:`${s}/events`,fetch:o,log:r,label:"Exposure"}),k=S.flush,E={trackedExperiments:new Set,log:r,onExperimentViewed:(i,d)=>{e.trackExposures===!1||a?.trackExposures===!1||S.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:u,...p?{sessionId:p}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:i.key,variationKey:d.key})}},z=()=>{E.url=location.href,E.attributes={...de(u,location),...c}};function W(i){if(!e.disableCrossOriginUrlRedirects)return!1;try{let d=new URL(location.href);return i.variations.some(l=>{if(!l.urlRedirect)return!1;let v=new URL(l.urlRedirect);return v.protocol!==d.protocol||v.host!==d.host})}catch{return!0}}function X(i,d){let l=e.configuration?.snapshot?.generation,v=y,te=location.href;g=i;let re=e.navigate??(w=>location.replace(w)),ne=e.navigateDelay??(e.navigate?0:100),oe=e.maxNavigateDelay??1e3;Promise.all([Promise.race([d,new Promise(w=>setTimeout(w,oe))]),new Promise(w=>setTimeout(w,ne))]).then(()=>{!f&&v===y&&location.href===te&&(!e.configuration||e.configuration.fresh&&e.configuration.snapshot?.generation===l)&&re(i)})}function x(){if(!(!a||f||e.configuration&&!e.configuration.fresh)){z();for(let i of a.experiments){if(W(i)){r?.("Auto experiment blocked",{id:i.key});continue}let d;try{d=j(i,E)}catch(l){r?.("Skipping page experiment",{id:i.key,error:String(l)});continue}if(b.set(i.key,d),!!d.inExperiment){if(d.value.urlRedirect){let l=i.persistQueryString?ue(location.href,d.value.urlRedirect):d.value.urlRedirect;C(l,i.urlPatterns??[])?r?.("Skipping redirect because original URL matches redirect URL",{id:i.key}):l!==g&&X(l,k())}break}}}}let R="",Z=()=>{location.href!==R&&(y++,R=location.href,g="",x())},T,L;function ee(){T??=q(Z),addEventListener("pagehide",I)}let I=()=>{k()};async function A(){if(f)return!1;let i=++m,d;try{d=e.configuration?await e.configuration.pageExperiments():await n.read(s,V)}catch(v){if(f||i!==m)return!1;throw v}if(f||i!==m)return!1;let l=le(d);if(l.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Page experiment payload scope changed");return a?.trackExposures===!1&&l.trackExposures&&E.trackedExperiments?.clear(),a=l,E.savedGroups=O(l.savedGroups),!0}function U(){f||(L??=e.configuration?.subscribe(()=>{!f&&e.configuration?.fresh&&A().then(i=>{i&&x()}).catch(i=>r?.("Page configuration unavailable",{error:String(i)}))}),ee(),R=location.href)}return{async start(){h||f||(h=!0,await A()&&(U(),x()))},async refresh(){await A()&&(y++,h&&U(),g="",x())},setAttributes(i){y++,g="",c={...i},x()},getResults(){return new Map(b)},get generation(){return a?.generation??null},destroy(){f||(f=!0,m++,n.destroy(),L?.(),T?.(),removeEventListener("pagehide",I),a=null,b.clear(),k())}}}export{be as a,H as b,F as c,ue as d,de as e,le as f,Te as g};
2
- /*! For license information please see chunk-YB3PQ75M.js.LEGAL.txt */
1
+ import{a as $,b as N,c as J,d as q}from"./chunk-MB2U2GWJ.js";import{a as P}from"./chunk-3VUPVXAV.js";import{a as D}from"./chunk-S3QZOIUO.js";import{a as _}from"./chunk-DSPLGTQI.js";import{b as C,c as O,e as j}from"./chunk-VPT5MFDG.js";async function B(e,t,o,n={}){let r=n.message??"Invalid SDK JSON response",s=e.headers.get("content-length");if(!e.ok||!/^application\/json(?:;|$)/i.test(e.headers.get("content-type")??"")||s!==null&&(!/^\d+$/.test(s)||Number(s)>t)||!e.body)throw e.body?.cancel().catch(()=>{}),Error(r);let u;try{u=await P(e,t,{signal:o,error:()=>Error(r)})}catch(p){throw o.aborted?Error(r):p}return JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(u))}async function G(e,t){if(!e?.body)return;let o=new AbortController,n=()=>o.abort(t?.reason);t?.addEventListener("abort",n,{once:!0}),t?.aborted&&n();let r=setTimeout(()=>o.abort(Error("Exposure response timeout")),2e3);try{return await P(e,16384,{signal:o.signal,error:()=>Error("Exposure response budget")})}finally{clearTimeout(r),t?.removeEventListener("abort",n)}}var be=2*1024*1024,V=256*1024;async function Y(e,t,o,n){let r=()=>{},s=new Promise((u,p)=>{r=()=>p(n.reason),n.addEventListener("abort",r,{once:!0}),n.aborted&&r()});try{let u=e(t,{...o,signal:n});return u.then(p=>{n.aborted&&p.body?.cancel().catch(()=>{})},()=>{}),await Promise.race([u,s])}finally{n.removeEventListener("abort",r)}}async function M(e,t,o,n=!1){if(new TextEncoder().encode(o).byteLength>65536)throw Error("Exposure request budget");let r=new URL(t);r.searchParams.set("sdkVersion",D.version);let s=new AbortController,u=setTimeout(()=>s.abort(Error("Exposure request timeout")),5e3);try{let p=await Y(e,r.href,{method:"POST",headers:{"Content-Type":"text/plain"},body:o,credentials:"omit",keepalive:n,redirect:"error"},s.signal),a=await G(p,s.signal),c;try{c=a&&JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(a))}catch{}return{response:p,receipt:c}}finally{clearTimeout(u)}}function H(e){let t,o=!1;return{async read(n,r){if(o)throw Error("Experiment client stopped");t?.abort(Error("Experiment request superseded"));let s=new AbortController;t=s;let{signal:u}=s,p=setTimeout(()=>s.abort(Error("Experiment request timeout")),5e3);try{let a=await Y(e,n,{cache:"no-cache",credentials:"omit",redirect:"error"},u),c=await B(a,r,u);return u.throwIfAborted(),c}finally{clearTimeout(p),t===s&&(t=void 0)}},destroy(){o=!0,t?.abort(Error("Experiment client stopped")),t=void 0}}}var Q=20,ie=65536,se=5e3,ae=5,K=e=>new TextEncoder().encode(JSON.stringify(e)).length;function ce(e,t){let o=e,n=r=>Number.isSafeInteger(r)&&r>=0;return!!o&&typeof o=="object"&&n(o.inserted)&&n(o.duplicates)&&n(o.skipped)&&Array.isArray(o.rejected)&&o.inserted+o.duplicates+o.skipped+o.rejected.length===t&&o.rejected.every(r=>!!r&&typeof r=="object"&&n(r.index)&&r.index<t&&typeof r.reason=="string")&&new Set(o.rejected.map(r=>r.index)).size===o.rejected.length}function F(e){let t=[],o,n,r=(a,c)=>{try{e.log?.(`${e.label} ${a}`,c)}catch{}};function s(a){o===void 0&&!n&&t.length&&(o=setTimeout(()=>{p()},a))}async function u(a,c){let g,f;try{({response:g,receipt:f}=await M(e.fetch,e.endpoint,JSON.stringify({events:a}),c))}catch(h){return r("not sent",{error:h}),!1}return g.status===408||g.status===429||g.status>=500?(r("not sent",{status:g.status}),!1):g.ok?ce(f,a.length)?(f.rejected.length&&r("rejected",{rejected:f.rejected}),!0):(r("not acknowledged",{status:g.status}),!1):(r("rejected",{status:g.status,events:a.length}),!0)}function p(a=!0){if(n)return n;clearTimeout(o),o=void 0;let c=[],g=K({events:[]});for(;t.length&&c.length<Q;){let m=K(t[0].event)+(c.length?1:0);if(c.length&&g+m>ie)break;c.push(t.shift()),g+=m}if(!c.length)return Promise.resolve();let f=1e3,h=u(c.map(m=>m.event),a).then(m=>{if(m)return;f=se;let y=c.filter(b=>++b.attempts<ae);y.length<c.length&&r("dropped after retries",{events:c.length-y.length}),t.unshift(...y)}).finally(()=>{n===h&&(n=void 0),s(f)});return n=h,h}return{push(a){t.push({event:structuredClone(a),attempts:0}),t.length>=Q?p():s(1e3)},flush:p}}function ue(e,t){let o,n;try{o=new URL(e),n=new URL(t)}catch{return t}return o.searchParams.forEach((r,s)=>{n.searchParams.has(s)||n.searchParams.set(s,r)}),n.toString()}function de(e,t){let o=navigator.userAgent,n=new URLSearchParams(t.search),r={};for(let s of["source","medium","campaign","term","content"]){let u=n.get(`utm_${s}`);u!==null&&(r[`utm${s[0].toUpperCase()}${s.slice(1)}`]=u)}return{id:e,deviceId:e,url:t.href,path:t.pathname,host:t.host,query:t.search,pageTitle:typeof document>"u"?"":document.title,browser:/Edg/.test(o)?"edge":/Chrome/.test(o)?"chrome":/Firefox/.test(o)?"firefox":/Safari/.test(o)?"safari":"unknown",deviceType:/Mobi/.test(o)?"mobile":"desktop",...r}}function le(e){let t=e;if(!(!!t&&typeof t=="object"&&typeof t.environmentId=="string"&&typeof t.trackExposures=="boolean"&&/^[a-f0-9]{64}$/.test(t.generation??"")&&Array.isArray(t.experiments)&&t.experiments.length<=100&&t.experiments.every(n=>!!n&&!["namespace","status","url","groups"].some(r=>Object.hasOwn(n,r))&&(n.hashVersion===void 0||n.hashVersion===2)&&typeof n.key=="string"&&Array.isArray(n.variations)&&n.variations.length>=2&&n.variations.every(r=>!!r&&typeof r.urlRedirect=="string")&&(n.urlPatterns===void 0||Array.isArray(n.urlPatterns)))&&!!t.savedGroups&&typeof t.savedGroups=="object"&&!Array.isArray(t.savedGroups)))throw new Error("Invalid page experiment payload");return t}function Te(e){if(e.configuration&&e.configuration.scope.environmentId!==e.environmentId)throw new Error("Page configuration belongs to another App environment");let t=J(e.baseUrl);if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("environmentId must be the App environment ID");let o=e.fetch??globalThis.fetch.bind(globalThis),n=H(async(i,d)=>{let l=await o(i,d);if(!l.ok)throw l.body?.cancel().catch(()=>{}),new Error(`Page experiments unavailable (${l.status})`);return l}),r=e.log?(i,d)=>_(e.log,i,d):void 0,s=`${t}/api/v1/page-experiments/${e.environmentId}`,u=$(e.deviceIdCookie??"indiana_did"),p=N(),a=null,c={...e.attributes??{}},g="",f=!1,h=!1,m=0,y=0,b=new Map,S=F({endpoint:`${s}/events`,fetch:o,log:r,label:"Exposure"}),k=S.flush,E={trackedExperiments:new Set,log:r,onExperimentViewed:(i,d)=>{e.trackExposures===!1||a?.trackExposures===!1||S.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:u,...p?{sessionId:p}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:i.key,variationKey:d.key})}},z=()=>{E.url=location.href,E.attributes={...de(u,location),...c}};function W(i){if(!e.disableCrossOriginUrlRedirects)return!1;try{let d=new URL(location.href);return i.variations.some(l=>{if(!l.urlRedirect)return!1;let v=new URL(l.urlRedirect);return v.protocol!==d.protocol||v.host!==d.host})}catch{return!0}}function X(i,d){let l=e.configuration?.snapshot?.generation,v=y,te=location.href;g=i;let re=e.navigate??(w=>location.replace(w)),ne=e.navigateDelay??(e.navigate?0:100),oe=e.maxNavigateDelay??1e3;Promise.all([Promise.race([d,new Promise(w=>setTimeout(w,oe))]),new Promise(w=>setTimeout(w,ne))]).then(()=>{!f&&v===y&&location.href===te&&(!e.configuration||e.configuration.fresh&&e.configuration.snapshot?.generation===l)&&re(i)})}function x(){if(!(!a||f||e.configuration&&!e.configuration.fresh)){z();for(let i of a.experiments){if(W(i)){r?.("Auto experiment blocked",{id:i.key});continue}let d;try{d=j(i,E)}catch(l){r?.("Skipping page experiment",{id:i.key,error:String(l)});continue}if(b.set(i.key,d),!!d.inExperiment){if(d.value.urlRedirect){let l=i.persistQueryString?ue(location.href,d.value.urlRedirect):d.value.urlRedirect;C(l,i.urlPatterns??[])?r?.("Skipping redirect because original URL matches redirect URL",{id:i.key}):l!==g&&X(l,k())}break}}}}let R="",Z=()=>{location.href!==R&&(y++,R=location.href,g="",x())},T,L;function ee(){T??=q(Z),addEventListener("pagehide",I)}let I=()=>{k()};async function A(){if(f)return!1;let i=++m,d;try{d=e.configuration?await e.configuration.pageExperiments():await n.read(s,V)}catch(v){if(f||i!==m)return!1;throw v}if(f||i!==m)return!1;let l=le(d);if(l.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Page experiment payload scope changed");return a?.trackExposures===!1&&l.trackExposures&&E.trackedExperiments?.clear(),a=l,E.savedGroups=O(l.savedGroups),!0}function U(){f||(L??=e.configuration?.subscribe(()=>{!f&&e.configuration?.fresh&&A().then(i=>{i&&x()}).catch(i=>r?.("Page configuration unavailable",{error:String(i)}))}),ee(),R=location.href)}return{async start(){h||f||(h=!0,await A()&&(U(),x()))},async refresh(){await A()&&(y++,h&&U(),g="",x())},setAttributes(i){y++,g="",c={...i},x()},getResults(){return new Map(b)},get generation(){return a?.generation??null},destroy(){f||(f=!0,m++,n.destroy(),L?.(),T?.(),removeEventListener("pagehide",I),a=null,b.clear(),k())}}}export{be as a,H as b,F as c,ue as d,de as e,le as f,Te as g};
2
+ /*! For license information please see chunk-UM5R4RNN.js.LEGAL.txt */
@@ -1 +1 @@
1
- import{a as gn,c as bn,d as Tt,f as Ot,g as Cn,k as vn}from"./chunk-IMFPRZUY.js";import{a as un,b as ze}from"./chunk-W32FI2A2.js";import{d as dn,e as fn,f as pn,g as hn,i as St,j as it,k as mn,l as yn,m as wn}from"./chunk-J5K4PNII.js";import{a as on,c as xt,d as sn,e as ln}from"./chunk-NDNHTG5B.js";import{a as rt,b as ae,d as Rt,f as At,j as cn}from"./chunk-5LNX7MHO.js";import{b as Ie}from"./chunk-4OODZM64.js";import{B as N,C as nt,D as Ge,E as De,y as an}from"./chunk-EB7MIZ4T.js";import{r as Le,t as _e}from"./chunk-VXDVMAS6.js";import{i as rn}from"./chunk-ZRGL2CAP.js";import{c as ge,j as We}from"./chunk-KTWKDR5L.js";import{c as Et}from"./chunk-XCFAKO23.js";import{a as k}from"./chunk-TK3WOD2O.js";import{a as G}from"./chunk-DSPLGTQI.js";async function Pn($,a,E){if(!Ge(a))throw new k("INVALID_RESPONSE","A verified completed purchase is required");let T=$?We.parse($):null;if(await E.onComplete?.(a),!T||!E.check)return;let j=We.parse(await E.check());if(j.internal_feature_id!==T.internal_feature_id||j.quantity!==T.quantity||T.observation!==void 0&&(j.observation===void 0||j.observation.requirementDigest!==T.observation.requirementDigest||j.observation.authority!==T.observation.authority||Et(j.observation.subject)!==Et(T.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");j.allowed&&await E.onAccessGranted?.(j)}function kn($){return Object.entries($.document.buttons).filter(([,a])=>a.type==="checkout"&&a.product.type==="fixed"&&!Ie(a.product,{},$.capabilities)).map(([a])=>a)}function In($,a){let E=N(a)?void 0:a.lines[0];if(!N(a)&&(a.lines.length!==1||!E))return;let T=N(a)?a.productVersionId:E.productVersionId,{screen:j,buttons:oe}=$.document,D=new Map(N(a)?Object.entries(a.featureQuantities??{}):(E?.prepaid??[]).map(b=>[b.internal_feature_id,b.quantity]));function se(b,c){if(b.hidden)return!1;if(b.type==="plan_picker"&&$.capabilities.pickers[b.id]?.options.includes(T))return c[b.id]=T,!0;if(b.type==="quantity_picker"){let te=D.get(b.internalFeatureId);return te!==void 0&&(!b.bind?.plan||b.bind.plan===T)&&(c[b.id]=te),!1}if(b.type==="button"&&b.action){let te=oe[b.action];return te?.type==="checkout"&&te.product.type==="fixed"&&te.product.productVersionId===T}if(b.type!=="stack")return!1;let ee=b.interaction,i=b.bind?.plan===T;for(let[te,p]of b.children.entries()){let ne={},L=se(p,ne);if(ee?.type==="toggle"||ee?.type==="tabs"){if(!L)continue;return c[b.id]=ee.type==="toggle"?te===0:p.id,Object.assign(c,ne),!0}Object.assign(c,ne),L&&(i=!0,ee?.type==="select"&&ee.purpose==="product"&&ee.pickerId&&p.type==="stack"&&p.bind?.plan===T&&(c[b.id]=p.id,c[ee.pickerId]=T))}return i}for(let b of j.pages){let c={__page:b.id};if(se(b.root,c))return c}}async function dr($,a,E){let T=a.focusAtReveal?()=>{}:St($.ownerDocument),j=()=>{D.finish("dismissed"),T()},oe=()=>j(),D=mn($,a,"paywall",()=>{j(),G(a.onDismiss)},gn);a.signal?.throwIfAborted(),a.signal?.addEventListener("abort",oe,{once:!0});let se=null,b,c,ee;try{if(D.start(!0,a.loadingDocument?.screen.strings.defaultLocale,a.loadingDocument??null),D.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(se=a.check?We.parse(await D.wait(a.check(),it)):null,se?.allowed)return D.finish("skipped"),a.signal?.removeEventListener("abort",oe),T(),await a.onAccessGranted?.(se),{check:se,host:null};let[e,t]=await Promise.allSettled([D.wait(import("./screen-renderer-2ZDV2WYD.js")),D.wait(a.start().then(r=>(D.cancelled&&r.destroy(),r)),it)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;ee=e.value,b=t.value,a.signal?.throwIfAborted(),b.signal?.throwIfAborted(),b.signal?.addEventListener("abort",oe,{once:!0});let n=b.view??await D.wait(b.refresh(),it);if(!n)throw new k("INVALID_RESPONSE","Paywall presentation is missing");b.signal?.throwIfAborted(),c=n}catch(e){throw D.finish("error",e),E?.retainedDialog?.release(),a.signal?.removeEventListener("abort",oe),b?.signal?.removeEventListener("abort",oe),b?.destroy(),T(),e}let i=b,{mountScreenPreview:te}=ee,p=$.ownerDocument,ne=new AbortController,L=p.createElement("section"),pe=p.createElement("div"),F=p.createElement("div"),at=a.mountControls,X=at?p.createElement("div"):void 0,d=p.createElement("p"),h=p.createElement("button"),le=p.createElement("button"),O=p.createElement("button");(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&E?.hostPaywallTarget&&!E.retainedDialog&&c.document.presentation.type==="modal"&&(E.retainedDialog=hn(E.hostPaywallTarget));let ce=E?.retainedDialog,R=ce?.dialog??p.createElement("dialog"),Ue=ce&&c.document.presentation.type==="inline"?{type:"modal",size:"md"}:c.document.presentation,re=Ue.type==="inline"?F:p.createElement("div"),ot=i.locale||c.document.screen.strings.defaultLocale,o=ot.toLowerCase().startsWith("zh"),En=o?"正在处理…":"Processing…",xn=o?"正在准备报价…":"Preparing your price…",U=bn(c.document.screen.theme);L.dataset.indianaPaywall="",L.setAttribute("aria-label",c.document.name),L.style.cssText=U.root,F.style.cssText=U.controls,d.style.cssText=U.message,d.setAttribute("role","status"),O.style.cssText=U.link,O.textContent=o?"关闭":"Close",h.style.cssText=U.secondary,h.textContent=o?"重试":"Retry",h.hidden=!0,le.type="button",le.style.cssText=U.primary,le.textContent=o?"继续付款":"Continue payment",le.hidden=!0,re.append(d,le,h),F.append(O),X&&(X.style.cssText="flex:1 0 100%;min-width:0",X.hidden=!0,F.prepend(X)),re!==F&&(re.dataset.indianaPaywallStatus="",re.style.cssText="display:none;padding:0",L.append(re)),L.append(pe,F);let st=()=>{let e=s=>!s.hidden&&(s!==d||!!d.textContent);if(re!==F&&(re.style.cssText=!ie&&[...re.children].some(e)?`${U.controls};padding:12px 64px 12px 20px;flex-shrink:0`:"display:none;padding:0"),X){let s=!X.childElementCount&&!X.textContent?.trim();X.hidden!==s&&(X.hidden=s)}let t=me??F,n=![...t.children].some(e),r=[...t.children].some(s=>s!==O&&e(s));t.style.cssText=n?U.controls.replace(/padding:[^;]+/,"padding:0"):r?`${U.controls};${U.pinned}`:U.controls,ct()},Nt=typeof MutationObserver>"u"?void 0:new MutationObserver(st);Nt?.observe(L,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Rn=Object.entries(c.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),H,Dt,Me=!1,Lt=JSON.stringify(c.capabilities),q;function be(e){let t=kn(e);if(q||he&&!fe||Q&&(C||!Re()||ye))return $e(e).map(({actionId:r})=>r);if(mt()||!C&&Re())return t;let n=C?Ht(e):Qt(e);return[...new Set([...t,...$e(e).map(({actionId:r})=>r).filter(r=>!n.includes(r))])]}function Ve(e){if(g)return;let t=c.id!==e.id;c=e;let n=JSON.stringify(e.capabilities);if(t||n!==Lt){let r=!P&&!i.quote&&!i.operation?rt(e,z,Mt):z;t||JSON.stringify(r)!==JSON.stringify(z)?(z=r,H?.update(e.document.screen,ot,{capabilities:ae(e),unavailableActions:be(e),serverInput:{bindings:[],answers:{}},selection:z})):H?.updateCapabilities(ae(e),be(e)),Lt=n}Sn(e),ve()}let _,lt=0;function _t(){return(me??F).getBoundingClientRect().height+(re===F?0:re.getBoundingClientRect().height)}function ct(){let e=p.defaultView;if(!_?.responsive||!e)return;let t=me??F,n=e.innerHeight-(_.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",lt=Math.max(1,n-_t()),H?.resizeViewport?.(lt,e.innerWidth)}let g=!1,he=!1,P=null,ut,Ye=!1,Ut=!1,Ce=!1,dt,ft=!1,ie,me;function An(){return he||g||ie||ft?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:xt(i)}let I=()=>!g&&!Ye&&!ie&&a.canInteract?.()!==!1,Y,Ee=!1,xe=!1,u=null,ue=null,Ke="",de=()=>a.checkoutNavigation==="after_confirmation"&&!!(a.terminateCheckout||a.resumeCheckout),z={},Mt=new Set,fe,C;function pt(e){return!!e&&N(e)&&e.timing==="immediate"&&e.execution.provider==="merchant"}let ht=o?"正在确认付款…":"Confirming payment…",Q=null,ye,Je,Vt=!1,Re=()=>a.allowNewPurchase!==!1||Vt;function $e(e){return Object.entries(e.document.buttons).flatMap(([t,n])=>n.type==="checkout"?[{actionId:t,policy:n}]:[])}function $t(e){let t=C?.quote;return t?$e(e).filter(({actionId:n,policy:r})=>Ae(t,e,n,r.product,z)).map(({actionId:n})=>n):[]}function Ht(e){return C?.phase==="payment"?$t(e):[]}function mt(){return(C?C.phase==="payment":!Re())&&(Re()||!!a.prepareUpgradeReplacement)&&de()&&!!a.terminateCheckout&&!!i.quote&&i.canReselect===!1&&!!i.operation&&x(i.operation).type==="checkout"}function Qt(e){let t=i.quote;return!de()||Q||!t||!i.operation||x(i.operation).type!=="checkout"?[]:$e(e).filter(({actionId:n,policy:r})=>Ae(t,e,n,r.product,z)).map(({actionId:n})=>n)}function ve(){let e=q?[]:C?Ht(c):Qt(c),t=a.allowNewPurchase===!1&&!!i.operation&&x(i.operation).type==="checkout";if(le.hidden=!!q||(C?C.phase!=="payment":!t)||e.length>0,!de()&&!C||!H?.updateCheckoutControls)return;let n=!q&&C?.phase==="checking"?fe:void 0;H.updateCheckoutControls({actions:$e(c).map(({actionId:r})=>r),resume:n?[n]:e,resumeLabel:n?ht:o?"继续付款":C?"Continue payment":"Continue checkout",busy:fe})}function Bt(){ue?.remove(),ue=null}async function Xe(){if(Q)return;if(a.resumeCheckout&&i.operation){let t=i.operation.operationId;try{await a.resumeCheckout(t)}catch(n){if(!(n instanceof k&&n.code==="PURCHASE_PENDING"))throw n;let r=await i.read();if(!I())return;if(r.operationId!==t||x(r).type==="checkout")throw n;await M(r,!1)}return}let e=await i.read();if(x(e).type!=="checkout")return M(e,!1);I()&&(He.delete(e.operationId),await Qe(e))}function yt(){ye?.destroy(),ye=void 0,Je=void 0}function jt(){let e=Q;if(!e||ye)return;let t=o?"仍在核对原订单,暂时无法更换套餐。":"We’re still checking the original purchase before changing plans.",n=Date.now()+6e5,r=un({document:p,delay:()=>Date.now()<n?5e3:void 0,async run(){if(!I())return;let s=await i.read();if(ye!==r||!I())return;if(s.operationId!==e.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");let f=x(s);f.type==="native"?(yt(),d.textContent=o?"原订单已关闭。你可以继续更换套餐。":"The original checkout is closed. You can continue changing plans.",h.textContent=o?"继续更换套餐":"Continue changing plans",u=()=>Ze(),h.hidden=!1):(f.type==="complete"||f.type==="fulfillment"||f.type==="recording")&&(yt(),Q=null,h.hidden=!0,await M(s,!1))}});ye=r,Je=async()=>{try{await r.refresh()}finally{ye===r&&(d.textContent=t,h.hidden=!1)}},u=Je,h.textContent=o?"查询结果":"Check result",h.hidden=!1,d.textContent=t,r.schedule()}async function Ze(e=!1){let t=Q;if(!t)return;u=()=>Ze(),C&&(h.textContent=o?"查询状态":"Check status"),h.hidden=!0;let n=Date.now()+2e4;for(;I();){let r=await i.read();if(r.operationId!==t.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");if(!I())break;let s=x(r);if(s.type==="native"){if(!Re()&&a.prepareUpgradeReplacement){let f=await a.prepareUpgradeReplacement(t.operationId,t.intent);if(!I())return;Vt=!0,Ve(f)}Q=null,C&&Se(C.quote),Bt(),P=t.selection,Y=t.coupon,Ee=!1,xe=!1,await Fe();return}if(s.type==="complete"||s.type==="fulfillment"||s.type==="recording"){Q=null,C?await Pe(C.quote,r):await M(r,!1);return}if(e&&s.type==="checkout"){e=!1;try{await a.terminateCheckout(t.operationId)}catch(f){G(a.onError,f)}}if(Date.now()>=n){C&&s.type==="checkout"&&(Q=null,await Pe(C.quote,r));break}await ze(1e3,p,ne.signal)}!Q||g||(C?(d.textContent=o?"仍在核对原升级单,暂时无法更换套餐。":"We’re still checking the original upgrade before changing plans.",h.hidden=!1):jt())}async function Ft(e,t,n,r){if(u=()=>Ft(e,t,n,r),await a.beforeCheckoutReplacement?.(structuredClone(r)),!I())return;let s=i.operation;if(s?.operationId!==e||x(s).type!=="checkout"){u=null,s&&await M(s,!1);return}Q={operationId:e,selection:t,coupon:n,intent:r},C&&(d.textContent=o?"正在切换套餐…":"Changing plan…",h.hidden=!0);let f=!1;try{await a.terminateCheckout(e)}catch(l){if(l instanceof k&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(l.code)){Q=null,C&&(u=bt,h.textContent=o?"查询状态":"Check status",h.hidden=!1),d.textContent=o?"请继续原订单,或等待它过期后再更换方案。":"Continue your original checkout, or wait for it to expire before changing plans.",G(a.onError,l);return}f=l instanceof k&&(l.status??0)>=500,G(a.onError,l)}I()&&await Ze(f)}function wt(e,t,n,r,s){let f=ae(e).checkoutCoupons?.[t],l=f?f.products[n]:a.claimCoupon&&s?rn(e.capabilities,s,r):void 0;return l?.couponId&&l.planVersionId===n?{id:l.couponId,offerId:l.offerId}:void 0}function Sn(e){he||P||i.quote||i.operation||Ke&&d.textContent===Ke||(d.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":o?"当前账号暂无可购买的方案。":"No plans are currently available for this account.")}let He=new Map,et=!1;function Ae(e,t,n,r,s,f){let l=N(e),y=!l&&e.lines.length===1?e.lines[0]:void 0,m=Ie(r,s,t.capabilities);if(!m||m!==(l?e.productVersionId:y?.productVersionId))return!1;let A=wt(t,n,m,s,f),K;try{K=_e(t.document.screen,m,s,t.capabilities)}catch{return!1}if(l){let J=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return Object.keys(K).length===Object.keys(e.featureQuantities??{}).length&&Object.entries(K).every(([Ne,It])=>e.featureQuantities?.[Ne]===It)&&(!A||J?.couponId===A.id&&(!A.offerId||J.grantId===A.offerId))}if((A||ae(t).checkoutCoupons?.[n])&&(A?.id??null)!==(e.discount?.couponId??null))return!1;let Z=Object.fromEntries((y?.prepaid??[]).map(J=>[J.internal_feature_id,J.quantity]));return[...new Set([...Object.keys(K),...Object.keys(Z)])].every(J=>(K[J]??0)===(Z[J]??0))}let x=e=>on({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:g,canReselect:i.canReselect});async function Qe(e){let t=e.merchantExecution,n=x(e),r=n.type==="checkout"?n.checkoutUrl:e.checkoutUrl;if(!(!I()||!r||nt(e)&&n.type!=="checkout"||a.checkoutNavigation==="after_confirmation"&&n.type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||He.get(e.operationId)===r)){He.set(e.operationId,r);try{a.onCheckoutUrl?await a.onCheckoutUrl(r):p.defaultView?.location.assign(r)}catch(s){throw He.delete(e.operationId),s}}}let we=(e,t=!1)=>{if(e instanceof Rt)u=null,d.textContent=e.customerMessage(o);else if(Cn(e))u=null,d.textContent=t?o?"当前无法在此购买,付款尚未开始。请联系商户。":"Purchases aren’t available here right now. Payment hasn’t started. Contact the merchant for help.":Ot(e,o);else if(t){let n=e instanceof k?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(u=null,d.textContent=o?"暂时无法为此套餐报价,付款尚未开始。":"Pricing for this plan is unavailable. Payment hasn’t started."):i.canReselect===!0&&!P?d.textContent=o?"未能取得报价,付款尚未开始。请重新选择套餐。":"We couldn’t prepare your price. Payment hasn’t started. Choose a plan again.":n==="COMMAND_PENDING"?d.textContent=o?"仍在准备报价,请重试以查看结果。":"Your price is still being prepared. Retry to check the result.":d.textContent=o?"未能取得报价,付款尚未开始。请重试。":"We couldn’t prepare your price. Payment hasn’t started. Try again."}else d.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?Ot(e,o):e instanceof k?e.message:o?"操作未完成,请重试。":"This action couldn’t be completed. Try again.";h.hidden=u===null,Ke=d.textContent,t&&fe===void 0&&!_?.responsive&&d.scrollIntoView?.({block:"nearest"}),G(t&&E?.quoteError?E.quoteError:a.onError,e)},Be=new WeakMap;function je(e){he=e,h.disabled=e,le.disabled=e,H?.updateCapabilities?.(ae(c),be(c));for(let t of ue?.querySelectorAll("button")??[])e?(Be.has(t)||Be.set(t,t.disabled),t.disabled=!0):Be.has(t)&&(t.disabled=Be.get(t),Be.delete(t)),Tt(t)}function qt(){q&&(d.textContent=q.message,h.textContent=o?"重试":"Retry",h.disabled=!1,h.hidden=!q.retry,le.disabled=!0)}function gt(){d.textContent=o?"暂时无法操作,请稍后重试。":"This action is unavailable right now. Try again in a moment."}async function Tn(e){if(a.beforeAction)try{await a.beforeAction()}catch(t){throw t instanceof Rt?(P=null,Ee=!1,xe=!1,u=null):u=e,t}}async function B(e,t){if(he||g||q)return;if(!I()){gt();return}let n=e===Fe,r=n?xn:En,s=de()&&t!==void 0;fe=s?t:void 0,je(!0),ve(),h.hidden=!0,d.textContent=s?"":r;try{if(e!==Jt&&e!==bt&&e!==Ct&&e!==Je&&(e!==Xe||!a.resumeCheckout)&&await Tn(e),g||q)return;if(!I()){u=e,h.hidden=!1,gt();return}await e()}catch(f){g||we(f,n)}finally{fe=void 0,je(!1),ve(),q?qt():d.textContent===r&&(d.textContent="")}}async function Wt(e){await Pn(se,e,a)}function Se(e,t){C=t?{quote:e,phase:t}:void 0,t==="checking"?(fe??=P?.actionId??$t(c)[0],d.textContent=ht,u=bt,h.textContent=o?"查询状态":"Check status",h.hidden=!0):fe=void 0,H?.updateCapabilities(ae(c),be(c)),ve()}function Gt(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 zt(e,t){At(e,{...t,featureQuantities:t.featureQuantities??{}},"Purchase operation changed")}async function bt(){C&&await Pe(C.quote)}async function Pe(e,t){Se(e,"checking"),Ke="";let n=1e3;Me=!0,G(a.onObservationChange,!0);try{for(let r=t;I();r=void 0){if(!r){try{r=await i.read()}catch(s){if(!Gt(s))throw s}if(!I())return}if(r){zt(r,e);let s=x(r);if(s.type==="checkout"){Se(e,"payment"),d.textContent=o?"请先完成原订单的付款。":"Finish paying for this upgrade.",h.hidden=!1;return}if(s.type==="complete"){Se(e,"complete"),u=null;let f=c.capabilities.plans[e.productVersionId]?.name,l=e.merchantTerms?.subscriptionTerms?.items,y=l?.length===1?l[0].interval:void 0,m=y==="year"?o?"年付":"annual billing":y==="month"?o?"月付":"monthly billing":null;d.textContent=f?o?`已升级到 ${f}${m?" "+m:""}。`:`Upgraded to ${f}${m?" ("+m+")":""}.`:o?"已成功升级。":"Plan upgraded.",await Wt(r);return}if(s.type==="native"&&!De(r)){Se(e),P=null,u=null,d.textContent=o?"付款未完成,请重新选择套餐。":"Payment failed. Choose a plan to start again.",h.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 ze(n,p,ne.signal),n=Math.min(n*1.5,15e3)}}finally{Me=!1,G(a.onObservationChange,!1)}}async function Ct(){let e=C?.quote;if(!e)return;let t=await i.read();if(zt(t,e),x(t).type!=="checkout")return Pe(e,t);if(a.resumeCheckout){await a.resumeCheckout(t.operationId);return}He.delete(t.operationId),await Qe(t)}function Yt(e){return xt(i).type==="recording"||x(e).type==="recording"}function Kt(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],r=t?t.totalMinor:N(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),s=t?n.length===1&&n[0]?.amountMinor===r&&n[0]:!N(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===r&&e.lines[0],f=r===null?ge(t.subtotalMinor-t.discountMinor,e.currency)+(o?" + 待确认税费":" + tax confirmed at checkout"):ge(r,e.currency)+(s?Le(s.interval,o?"zh-CN":"en",s.intervalCount??1):""),l=N(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(y=>y.productName).join(", ");return{label:l?`${l} · ${f}`:f,recurring:s}}async function M(e,t=a.checkoutNavigation!=="after_confirmation"){if(g)return;if(!I()){u=async()=>M(await i.read()),h.hidden=!1;return}let n=e.quote??i.quote;if(pt(n)&&(e.confirmedAt||e.merchantExecution))return Pe(n,e);if(d.textContent=vn(e.status,o),Yt(e)){let m=e.merchantExecution?.recordingStatus==="failed";d.textContent=m?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.",h.textContent=o?"查询记录":"Check recording",u=async()=>M(await i.read()),h.hidden=!1;return}if(e.problem&&x(e).type!=="native"){let m=e.problem;u=Te,h.textContent=o?"检查并恢复原操作":"Check and recover original purchase",we(new k(m.code,m.reason==="RESULT_UNKNOWN"?o?"付款结果尚未确定,请恢复原操作,暂勿重复购买。":"The payment result is unknown. Recover the original purchase before buying again.":m.phase==="fulfillment"?o?"付款已记录,商户权益处理需要核对。":"Payment was recorded. Access fulfillment needs attention.":m.code==="CAPABILITY_UNAVAILABLE"?o?"商户尚不支持本次购买所需的完整能力,请处理后恢复原操作。":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":m.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,m));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)&&(d.textContent=o?"付款已记录,正在等待商户完成处理。":"Payment was recorded. Waiting for merchant fulfillment."),Ge(e)&&x(e).type==="complete"){u=null,await Wt(e);return}if(!De(e)&&x(e).type!=="fulfillment"){if(i.canReselect===!1){d.textContent=o?"正在核对原购买结果":"Checking the original purchase result",h.textContent=o?"查询结果":"Check result",u=async()=>M(await i.read()),h.hidden=!1;return}e.status==="cancelled"?d.textContent=o?"这笔购买已取消,可以重新选择方案。":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(d.textContent=o?"这笔购买未能完成,可以重新选择方案。":"This purchase didn’t go through. Choose a plan to try again."),h.textContent=o?"重试":"Retry",u=null,P=null;return}if(!t&&x(e).type==="checkout"){if(Q){jt();return}if(de()){d.textContent="",et=!1,u=null,h.hidden=!0,H?.updateCapabilities?.(ae(c),be(c)),ve();return}let m=i.quote,A=m?.operationId===e.operationId?Kt(m).label:"";d.textContent=et?A?o?`${A} 尚未付款。再次选择该方案即可继续付款。`:`${A} is still unpaid. Choose it again to continue paying.`:o?"之前的购买尚未付款。再次选择该方案即可继续付款。":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",et=!1,u=null;return}await Qe(e);let r=Date.now(),s=r+6e5,f=2e3,l=x(e).type!=="checkout",y=()=>l&&Date.now()-r<15e3;Me=!0,G(a.onObservationChange,!0);try{for(;!g&&Date.now()<s;){if(await ze(y()?700:f,p,ne.signal),g)return;if(!I()){u=async()=>M(await i.read()),h.hidden=!1;return}let m=await i.read();if(x(m).type==="checkout"&&(l=!1),!t&&x(m).type==="checkout"){await M(m,!1);return}if(!m.problem&&De(m)&&await Qe(m),!De(m)||m.problem||Yt(m)){await M(m);return}y()||(f=Math.min(f*1.5,3e4))}}finally{Me=!1,G(a.onObservationChange,!1)}u=async()=>M(await i.read()),h.hidden=!1}async function vt(e=!1){let t=await i.read();if(g)return;if(!I()){u=()=>vt(e),h.hidden=!1;return}let n=i.quote;if(n&&At(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&(nt(t)?["prepared","quoted"].includes(t.status):t.status==="pending")&&(nt(t)||t.quoteFinalized===!1)&&!t.confirmedAt&&!t.checkoutUrl&&!("nativePurchase"in t&&t.nativePurchase)&&!t.merchantExecution&&!t.problem&&!i.pendingCancellation){if(a.purchaseConfirmation!=="paywall"){e?await Te():u=null;return}setTimeout(Xt,0,n);return}await M(t,e||void 0)}async function Jt(){await vt()}async function On(e){d.textContent=ht;let t=Date.now()+12e3;for(;!g&&Date.now()<t&&(await ze(1500,p,ne.signal),!(g||!I()));){let n;try{n=await i.read()}catch{break}if(n.problem?.reason!=="RESULT_UNKNOWN")return n}return e}async function Te(){if(i.quote&&!(Date.parse(i.quote.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");Bt();let e=i.quote;if(pt(e)){Se(e,"checking");let n;try{n=await i.confirm()}catch(r){if(!Gt(r))throw r;return Pe(e)}return Pe(e,n)}u=Te;let t=await i.confirm();if(!I()){u=Te,h.hidden=!1;return}if(t.problem?.reason==="RESULT_UNKNOWN"&&(t=await On(t)),t.problem){await M(t);return}if(De(t)){if(x(t).type==="checkout")await Qe(t);else if(t.execution&&t.execution.provider!=="merchant"||"nativePurchase"in t&&t.nativePurchase){if(!a.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:t,signal:ne.signal})}}u=async()=>M(await i.read()),await M(t,!0)}function Xt(e){if(g)return;ue?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());d.textContent=t?o?"此报价已过期。请先取消,再重新选择。":"This quote has expired. Cancel it, then choose again.":"";let n=p.createElement("div"),r=p.createElement("button"),s=p.createElement("button"),f=p.createElement("div"),l=p.createElement("p"),y=e.merchantTerms,m=o?"zh-CN":"en",A=y?.subscriptionTerms?.items??[],K=y?y.subscriptionTerms?.trial?.days:N(e)?void 0:e.lines.find(w=>w.trial)?.trial?.days,Z=N(e)?y?y.totalMinor:e.totalMinor:K===void 0?null:y?y.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(w=>w.trial)?0:null,Oe=(w,v)=>o?`${v} 天试用结束后 ${w}`:`Then ${w} after the ${v}-day trial`,{label:J,recurring:Ne}=Kt(e),It=N(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(w=>w.productName).join(", "),tn=Z===null?"":`${o?"今天应付":"Due today"} ${ge(Z,e.currency)}`;l.textContent=tn?[It,tn].filter(Boolean).join(" · "):J,r.textContent=N(e)?o?"确认变更":"Confirm change":o?"确认购买":"Confirm purchase",r.disabled=t,s.textContent=o?"取消":"Cancel",n.style.cssText=U.panel,l.style.cssText=U.summary,f.style.cssText=U.actions,r.style.cssText=U.primary,s.style.cssText=U.secondary,Tt(r),r.onclick=()=>{B(Te)};let nn=async()=>{let w=await i.cancel();g||(n.remove(),ue=null,await M(w))};s.onclick=()=>{u=nn,B(nn)};let W=p.createElement("div");if(W.style.cssText=U.terms,N(e)){for(let[v,S]of Object.entries(e.featureQuantities??{})){let V=i.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(Nn=>Nn.internalFeatureId===v),tt=p.createElement("p");tt.textContent=`${V?.name??v} · ${S} ${o?"份":"packs"}${V?` × ${V.terms.units}`:""}`,W.append(tt)}for(let[v,S]of[[o?"原订阅抵扣":"Unused subscription credit",e.creditMinor],[o?"新套餐费用":"New plan charge",e.debitMinor],[o?"优惠减免":"Offer savings",y?.discountMinor??e.discountMinor],[o?"税费":"Tax",y?y.taxMinor:e.taxMinor]]){let V=p.createElement("p");V.textContent=`${v}: ${S===null?o?"结账时确认":"Confirmed at checkout":ge(S,e.currency)}`,W.append(V)}let w=p.createElement("p");w.textContent=`${o?"生效时间":"Effective"}: ${e.effectiveAt}`,W.append(w)}if(y){for(let v of A){if(Z===null&&v===Ne)continue;let S=p.createElement("p"),V=ge(v.amountMinor,e.currency)+Le(v.interval,m,v.intervalCount);S.textContent=Z!==null&&K!==void 0?Oe(V,K):V,v.amountAfterOfferMinor!==void 0&&(S.textContent+=` · ${o?"优惠结束后":"After the offer"} ${ge(v.amountAfterOfferMinor,e.currency)}${Le(v.interval,m,v.intervalCount)}`),W.append(S)}let w=y.subscriptionTerms?.trial;if(w){let v=p.createElement("p");v.textContent=o?`试用 ${w.days} 天;${w.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${w.days}; ${w.cardRequired?"a payment method is required":"no payment method is required"}`,W.append(v)}for(let v of[...y.expectedEffects.map(S=>S.description),...y.requiredConsents.map(S=>S.summary)]){let S=p.createElement("p");S.textContent=v,W.append(S)}}else if(!N(e)){for(let w of e.lines){if(Z!==null||w!==Ne){let v=p.createElement("p"),S=`${ge(w.catalogAmountMinor,e.currency)}${Le(w.interval,m,w.intervalCount??1)}`;v.textContent=Z!==null&&w.trial?(e.lines.length>1?`${w.productName} · `:"")+Oe(S,w.trial.days):`${w.productName} · ${S}`,W.append(v)}for(let v of w.prepaid??[]){let S=p.createElement("p"),V=i.view?.capabilities.plans[w.productVersionId]?.prepaid?.find(tt=>tt.internalFeatureId===v.internal_feature_id);S.textContent=`${V?.name??v.internal_feature_id} · ${v.quantity} ${o?"份":"packs"} × ${v.terms.units}`,V&&(S.textContent+=Le(V.reset==="week"||V.reset==="month"||V.reset==="year"?V.reset:"one_time",m,V.resetCount)),W.append(S)}if(w.trial){let v=p.createElement("p");v.textContent=o?`试用 ${w.trial.days} 天;${w.trial.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${w.trial.days}; ${w.trial.cardRequired?"a payment method is required":"no payment method is required"}`,W.append(v)}}if(!e.charge){let w=p.createElement("p");w.textContent=o?"目录价格;最终金额以结账时税费和试用规则为准。":"Catalog price; the final charge depends on checkout taxes and trial terms.",W.append(w)}}for(let w of W.children)w.style.margin="0";f.append(r,s),n.append(l,...W.childElementCount?[W]:[],f),F.prepend(n),_?.responsive||n.scrollIntoView?.({block:"nearest"}),r.focus({preventScroll:!0}),ue=n,he&&je(!0),u=null}async function Fe(){if(!P)return;if(u=Fe,!Ee){let n=i.view,r=n?.document.buttons[P.actionId],s=n&&r?.type==="checkout"?Ie(r.product,P.selection,n.capabilities):null;if(!n||!s)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!xe){let l=await a.resolveSubscriptionChange?.({actionId:P.actionId,productVersionId:s,featureQuantities:_e(n.document.screen,s,P.selection,n.capabilities)});if(g)return;l!==void 0&&(P.subscriptionChange=an.parse(l)),xe=!0}let f=Y?.offerId;if(Y&&!f){if(!a.claimCoupon)throw new k("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:l}=await a.claimCoupon(Y.id,P.requestId);if(g)return;if(!l||l.couponId!==Y.id||l.status!=="issued"||!(Date.parse(l.expiresAt)>Date.now()))throw P=null,Y=void 0,u=async()=>{Ve(await i.refresh()),u=null},new k("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");f=l.id}if(!Y&&!n.document.screen.actions.some(l=>l.id===P?.actionId&&typeof l.properties.couponBinding=="string")&&(f=await a.resolveOfferId?.({actionId:P.actionId,productVersionId:s,featureQuantities:_e(n.document.screen,s,P.selection,n.capabilities)})),g)return;f!==void 0&&(P.offerId=f),Ee=!0}if(!I()){h.hidden=!1;return}let e;try{e=await i.preview(P)}catch(n){throw i.canReselect===!0&&(P=null,Ee=!1,xe=!1,Y=void 0,u=null),n}if(Y&&(N(e)?(()=>{let n=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return n?.couponId!==Y.id||n.grantId!==P.offerId})():e.discount?.couponId!==Y.id||e.discount.offerId!==P.offerId))throw new k("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(g)return;let t=e.merchantTerms;if(a.purchaseConfirmation!=="paywall"||a.confirmOnHostedCheckout&&I()&&!N(e)&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){if(!I()){h.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 n=fe?"":o?"正在打开收银台…":"Opening checkout…";d.textContent=n;try{await Te()}catch(r){g||we(r)}finally{d.textContent===n&&(d.textContent="")}return}Xt(e)}function ke(e="destroy",t=!1){if(g)return;g=!0;let n=ut;ut=void 0,G(n),a.signal?.removeEventListener("abort",oe),i.signal?.removeEventListener("abort",oe),D.finish("dismissed"),Dt?.(),yt(),ne.abort(),Nt?.disconnect(),H?.destroy(),i.destroy(),R.removeEventListener("cancel",en),O.remove(),L.remove(),t||Zt(),e==="dismiss"&&G(a.onDismiss)}function Zt(){if(_?.destroy(),ce){ce.release();return}R.open&&R.close(),R.remove(),T()}j=ke;async function qe(){if(!Ce||g||Ye||ie==="closing"||!ie&&!I())return;if(!E){ke("dismiss");return}let e=p.createElement("p");e.setAttribute("role","status"),e.textContent=o?"正在关闭…":"Closing…",me||(me=p.createElement("div"),me.style.cssText=F.style.cssText,F.replaceWith(me),pe.inert=!0),O.hidden=!1,me.replaceChildren(e,O),ie="closing",O.setAttribute("aria-disabled","true"),O.focus({preventScroll:!0});try{await E.dismiss()}catch(t){g||G(a.onError,t)}g||(ie="retry",e.textContent=o?"未能确认关闭,请重试。":"Could not confirm closure. Try again.",O.textContent=o?"重试关闭":"Retry closing",O.removeAttribute("aria-label"),O.removeAttribute("aria-disabled"))}O.onclick=()=>{qe()};function en(e){e.preventDefault(),qe()}R.addEventListener("cancel",en),le.onclick=()=>{B(C?Ct:Xe)},h.onclick=()=>{if(q){q.retry?.();return}u&&B(u)};function Pt(e){D.finish("error",e),ke()}function kt(){if(!(!Ut||Ce||g||Ye||_&&!I()))try{let e=t=>{a.focusAtReveal&&(T=St(p)),H?.setHidden?.(!1),dt?.(),_&&(R.open||R.showModal(),_.responsive&&R.focus({preventScroll:!0}),!t&&a.loading!=="host"&&fn(R,_.type,_.responsive)),t&&a.loading!=="host"&&typeof pe.animate=="function"&&!p.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&pe.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),Ce=!0};E?E.present(t=>D.present(n=>e(t??n))):D.present(e)}catch(e){Pt(e),we(e)}}try{if(Ue.type==="inline"?(st(),dt=wn(L,$),$.append(L)):(R.setAttribute("aria-label",c.document.name),O.textContent="×",O.setAttribute("aria-label",o?"关闭":"Close"),pn(O,c.document.screen.theme),O.hidden=cn(c.document),(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&ce?.content?ce.content.append(O,L):R.replaceChildren(O,L),ce||$.append(R),_=dn(R,{...c.document.screen,presentation:Ue},ct),_.latch(),_.responsive&&(L.style.display="flex",L.style.flexDirection="column",L.style.maxHeight="100%",pe.style.overflow="clip",pe.style.minHeight="0"),ce||(dt=yn(R))),at&&X){let n=at(X);if(typeof n=="function"&&(g?G(n):ut=n),g)throw new DOMException("Presentation cancelled","AbortError");st()}H=te(pe,{mode:"live",loadingLayout:()=>D.getLoadingLayout?.()??E?.loadingLayout?.(),rendererUrl:"bundled",title:c.document.name,closeActions:Rn,onAuthoredClose(n){ie||g||(O.hidden=n)},hostPresentation:()=>_?.type??Ue.type,reportContentHeight:_?.responsive,onResize:n=>{if(!_?.responsive)return;let r=Math.min(n,lt);pe.style.height=`${r}px`,_.setContentHeight(r+_t())},onSelection(n){for(let[r,s]of Object.entries(n))typeof s=="number"&&typeof z[r]=="number"&&z[r]!==s&&Mt.add(r);z=n,ve()},onAction(n,r={},s,f){if(!Ce||g||ie)return;let l=i.view,y=l?.document.buttons[n];if(!y)return;if(q){y.type==="close"&&qe();return}if(y.type==="close"&&E&&a.resumeCheckout&&i.operation&&sn(x(i.operation))){qe();return}if(he)return;if(!I()){gt();return}if(y.type==="close"){B(async()=>{E?.closeAction?await E.closeAction(n):await a.onAction?.(n),ke(a.onAction?"action":"dismiss")});return}if(y.type==="action"){u=async()=>{if(y.action.type==="event"){if(!a.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(y.action.event)}else a.onOpenUrl?await a.onOpenUrl(y.action.url):p.defaultView?.location.assign(y.action.url);await a.onAction?.(n),u=null},B(u);return}if(de()&&Q){!ye&&Q.selection.actionId===n&&B(()=>Ze(!0),n);return}if(C){if(C.phase==="payment"&&l&&Ae(C.quote,l,n,y.product,r,f)){B(Ct,n);return}if(!mt())return}if(!Re()&&!mt()){de()&&l&&i.quote&&i.operation&&x(i.operation).type==="checkout"&&Ae(i.quote,l,n,y.product,r,f)?B(Xe,n):d.textContent=o?"当前只能继续原订单。":"Only your original checkout is available.";return}if(ue&&i.canReselect===!1){d.textContent=o?"请先确认或取消当前购买。":"Confirm or cancel the current purchase first.",_?.responsive||ue.scrollIntoView?.({block:"nearest"}),ue.querySelector("button")?.focus({preventScroll:!0});return}if(de()&&a.terminateCheckout&&l&&i.quote&&i.operation&&i.canReselect===!1&&x(i.operation).type==="checkout"){if(Ae(i.quote,l,n,y.product,r,f)){B(Xe,n);return}let A=Ie(y.product,r,l.capabilities),K;try{if(!A)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");K=_e(l.document.screen,A,r,l.capabilities)}catch(Ne){we(Ne);return}let Z=i.operation.operationId,Oe={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(r)},J=wt(l,n,A,r,f);B(()=>Ft(Z,Oe,J,{actionId:n,productVersionId:A,selection:Oe.selection,featureQuantities:K}),n);return}if((i.quote||P)&&i.canReselect===!1){let A=!!l&&!!i.quote&&Ae(i.quote,l,n,y.product,r,f);et=!!i.quote&&!A,u=i.quote?()=>vt(A):Fe,B(u);return}let m=l&&Ie(y.product,r,l.capabilities);if(!l||!m){we(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){u=null,B(async()=>{let A={actionId:n,productVersionId:m,selection:structuredClone(r),featureQuantities:_e(l.document.screen,m,r,l.capabilities)};ft=!0,await a.onPurchaseIntent(A)});return}if(P&&P.actionId!==n){we(new k("COMMAND_PENDING","Finish the current purchase"));return}P||(Y=wt(l,n,m,r,f),P={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(r)},Ee=!1,xe=!1),B(Fe,n)},onEscape:()=>{qe()},onError:n=>{let r=new Error(n);!Ce&&!g&&Pt(r),we(r)},onRendered:n=>{n&&R.setAttribute("aria-label",n),Ut=!0,kt()}}),H.setHidden?.(!0),ct();let e=de()&&!!i.quote&&!!i.operation&&x(i.operation).type==="checkout";z=i.quote?In(c,i.quote)??rt(c,{}):rt(c,{}),H.update(c.document.screen,ot,{capabilities:ae(c),unavailableActions:be(c),serverInput:{bindings:[],answers:{}},...Object.keys(z).length?{selection:z}:{}}),Dt=i.subscribe?.(Ve),Ve(i.view??c),await D.wait(H.ready);let t=i.operation;(!e||pt(i.quote))&&(i.quote||t&&(t.confirmedAt||t.checkoutUrl||Ge(t)))&&(u=Jt,B(u))}catch(e){throw Pt(e),e}return{check:se,host:{get currentResolution(){return c},setPurchaseRecovery(e,t){q={message:e,retry:t},H?.updateCapabilities?.(ae(c),be(c)),ve(),qt()},get subscriptionUpgradeActive(){return C!==void 0},get observing(){return Me},get recovery(){return An()},async prepareFallback(){if(he||g||ie||ft)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};je(!0);try{let e=await ln(i);return e.type==="native"&&ke(),e}finally{je(!1)}},setSuspended(e){Ye=e,L.hidden=e,e&&R.open?R.close():!e&&!Ce?kt():!e&&!g&&Ce&&Ue.type!=="inline"&&!R.open&&R.showModal()},destroy:ke,retainPurchaseDialog(){if(!(g||!R.open||!R.isConnected))return ke("destroy",!0),{dialog:R,content:ce?.content,release:Zt}},refresh:async()=>{if(!I()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return Ve(e),kt(),e}}}}export{dr as a};
1
+ import{a as mn,c as bn,d as Tt,f as Ot,g as Cn,k as vn}from"./chunk-QXDLOPZK.js";import{a as un,b as ze}from"./chunk-W32FI2A2.js";import{d as dn,e as fn,f as pn,g as hn,i as St,j as it,k as yn,l as wn,m as gn}from"./chunk-IM5OXTEH.js";import{a as on,c as xt,d as sn,e as ln}from"./chunk-NDNHTG5B.js";import{a as rt,b as ae,d as Rt,f as At,j as cn}from"./chunk-5LNX7MHO.js";import{b as Ie}from"./chunk-4OODZM64.js";import{B as N,C as nt,D as Ge,E as De,y as an}from"./chunk-EB7MIZ4T.js";import{r as _e,t as Ue}from"./chunk-VXDVMAS6.js";import{i as rn}from"./chunk-ZRGL2CAP.js";import{c as ge,j as We}from"./chunk-KTWKDR5L.js";import{c as Et}from"./chunk-XCFAKO23.js";import{a as k}from"./chunk-TK3WOD2O.js";import{a as G}from"./chunk-DSPLGTQI.js";async function Pn($,a,E){if(!Ge(a))throw new k("INVALID_RESPONSE","A verified completed purchase is required");let T=$?We.parse($):null;if(await E.onComplete?.(a),!T||!E.check)return;let j=We.parse(await E.check());if(j.internal_feature_id!==T.internal_feature_id||j.quantity!==T.quantity||T.observation!==void 0&&(j.observation===void 0||j.observation.requirementDigest!==T.observation.requirementDigest||j.observation.authority!==T.observation.authority||Et(j.observation.subject)!==Et(T.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");j.allowed&&await E.onAccessGranted?.(j)}function kn($){return Object.entries($.document.buttons).filter(([,a])=>a.type==="checkout"&&a.product.type==="fixed"&&!Ie(a.product,{},$.capabilities)).map(([a])=>a)}function In($,a){let E=N(a)?void 0:a.lines[0];if(!N(a)&&(a.lines.length!==1||!E))return;let T=N(a)?a.productVersionId:E.productVersionId,{screen:j,buttons:oe}=$.document,U=new Map(N(a)?Object.entries(a.featureQuantities??{}):(E?.prepaid??[]).map(b=>[b.internal_feature_id,b.quantity]));function se(b,c){if(b.hidden)return!1;if(b.type==="plan_picker"&&$.capabilities.pickers[b.id]?.options.includes(T))return c[b.id]=T,!0;if(b.type==="quantity_picker"){let te=U.get(b.internalFeatureId);return te!==void 0&&(!b.bind?.plan||b.bind.plan===T)&&(c[b.id]=te),!1}if(b.type==="button"&&b.action){let te=oe[b.action];return te?.type==="checkout"&&te.product.type==="fixed"&&te.product.productVersionId===T}if(b.type!=="stack")return!1;let ee=b.interaction,i=b.bind?.plan===T;for(let[te,p]of b.children.entries()){let ne={},D=se(p,ne);if(ee?.type==="toggle"||ee?.type==="tabs"){if(!D)continue;return c[b.id]=ee.type==="toggle"?te===0:p.id,Object.assign(c,ne),!0}Object.assign(c,ne),D&&(i=!0,ee?.type==="select"&&ee.purpose==="product"&&ee.pickerId&&p.type==="stack"&&p.bind?.plan===T&&(c[b.id]=p.id,c[ee.pickerId]=T))}return i}for(let b of j.pages){let c={__page:b.id};if(se(b.root,c))return c}}async function dr($,a,E){let T=a.focusAtReveal?()=>{}:St($.ownerDocument),j=()=>{U.finish("dismissed"),T()},oe=()=>j(),U=yn($,a,"paywall",()=>{j(),G(a.onDismiss)},mn);a.signal?.throwIfAborted(),a.signal?.addEventListener("abort",oe,{once:!0});let se=null,b,c,ee;try{if(U.start(!0,a.loadingDocument?.screen.strings.defaultLocale,a.loadingDocument??null),U.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(se=a.check?We.parse(await U.wait(a.check(),it)):null,se?.allowed)return U.finish("skipped"),a.signal?.removeEventListener("abort",oe),T(),await a.onAccessGranted?.(se),{check:se,host:null};let[e,t]=await Promise.allSettled([U.wait(import("./screen-renderer-3YO6EUWD.js")),U.wait(a.start().then(r=>(U.cancelled&&r.destroy(),r)),it)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;ee=e.value,b=t.value,a.signal?.throwIfAborted(),b.signal?.throwIfAborted(),b.signal?.addEventListener("abort",oe,{once:!0});let n=b.view??await U.wait(b.refresh(),it);if(!n)throw new k("INVALID_RESPONSE","Paywall presentation is missing");b.signal?.throwIfAborted(),c=n}catch(e){throw U.finish("error",e),E?.retainedDialog?.release(),a.signal?.removeEventListener("abort",oe),b?.signal?.removeEventListener("abort",oe),b?.destroy(),T(),e}let i=b,{mountScreenPreview:te}=ee,p=$.ownerDocument,ne=new AbortController,D=p.createElement("section"),pe=p.createElement("div"),F=p.createElement("div"),at=a.mountControls,X=at?p.createElement("div"):void 0,d=p.createElement("p"),h=p.createElement("button"),le=p.createElement("button"),O=p.createElement("button");(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&E?.hostPaywallTarget&&!E.retainedDialog&&c.document.presentation.type==="modal"&&(E.retainedDialog=hn(E.hostPaywallTarget));let ce=E?.retainedDialog,R=ce?.dialog??p.createElement("dialog"),Le=ce&&c.document.presentation.type==="inline"?{type:"modal",size:"md"}:c.document.presentation,re=Le.type==="inline"?F:p.createElement("div"),ot=i.locale||c.document.screen.strings.defaultLocale,o=ot.toLowerCase().startsWith("zh"),En=o?"正在处理…":"Processing…",xn=o?"正在准备报价…":"Preparing your price…",L=bn(c.document.screen.theme);D.dataset.indianaPaywall="",D.setAttribute("aria-label",c.document.name),D.style.cssText=L.root,F.style.cssText=L.controls,d.style.cssText=L.message,d.setAttribute("role","status"),O.style.cssText=L.link,O.textContent=o?"关闭":"Close",h.style.cssText=L.secondary,h.textContent=o?"重试":"Retry",h.hidden=!0,le.type="button",le.style.cssText=L.primary,le.textContent=o?"继续付款":"Continue payment",le.hidden=!0,re.append(d,le,h),F.append(O),X&&(X.style.cssText="flex:1 0 100%;min-width:0",X.hidden=!0,F.prepend(X)),re!==F&&(re.dataset.indianaPaywallStatus="",re.style.cssText="display:none;padding:0",D.append(re)),D.append(pe,F);let st=()=>{let e=s=>!s.hidden&&(s!==d||!!d.textContent);if(re!==F&&(re.style.cssText=!ie&&[...re.children].some(e)?`${L.controls};padding:12px 64px 12px 20px;flex-shrink:0`:"display:none;padding:0"),X){let s=!X.childElementCount&&!X.textContent?.trim();X.hidden!==s&&(X.hidden=s)}let t=me??F,n=![...t.children].some(e),r=[...t.children].some(s=>s!==O&&e(s));t.style.cssText=n?L.controls.replace(/padding:[^;]+/,"padding:0"):r?`${L.controls};${L.pinned}`:L.controls,ct()},Nt=typeof MutationObserver>"u"?void 0:new MutationObserver(st);Nt?.observe(D,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Rn=Object.entries(c.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),H,Dt,Me=!1,_t=JSON.stringify(c.capabilities),q;function be(e){let t=kn(e);if(q||he&&!fe||Q&&(C||!Re()||ye))return $e(e).map(({actionId:r})=>r);if(mt()||!C&&Re())return t;let n=C?Ht(e):Qt(e);return[...new Set([...t,...$e(e).map(({actionId:r})=>r).filter(r=>!n.includes(r))])]}function Ve(e){if(g)return;let t=c.id!==e.id;c=e;let n=JSON.stringify(e.capabilities);if(t||n!==_t){let r=!P&&!i.quote&&!i.operation?rt(e,z,Mt):z;t||JSON.stringify(r)!==JSON.stringify(z)?(z=r,H?.update(e.document.screen,ot,{capabilities:ae(e),unavailableActions:be(e),serverInput:{bindings:[],answers:{}},selection:z})):H?.updateCapabilities(ae(e),be(e)),_t=n}Sn(e),ve()}let _,lt=0;function Ut(){return(me??F).getBoundingClientRect().height+(re===F?0:re.getBoundingClientRect().height)}function ct(){let e=p.defaultView;if(!_?.responsive||!e)return;let t=me??F,n=e.innerHeight-(_.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",lt=Math.max(1,n-Ut()),H?.resizeViewport?.(lt,e.innerWidth)}let g=!1,he=!1,P=null,ut,Ye=!1,Lt=!1,Ce=!1,dt,ft=!1,ie,me;function An(){return he||g||ie||ft?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:xt(i)}let I=()=>!g&&!Ye&&!ie&&a.canInteract?.()!==!1,Y,Ee=!1,xe=!1,u=null,ue=null,Ke="",de=()=>a.checkoutNavigation==="after_confirmation"&&!!(a.terminateCheckout||a.resumeCheckout),z={},Mt=new Set,fe,C;function pt(e){return!!e&&N(e)&&e.timing==="immediate"&&e.execution.provider==="merchant"}let ht=o?"正在确认付款…":"Confirming payment…",Q=null,ye,Je,Vt=!1,Re=()=>a.allowNewPurchase!==!1||Vt;function $e(e){return Object.entries(e.document.buttons).flatMap(([t,n])=>n.type==="checkout"?[{actionId:t,policy:n}]:[])}function $t(e){let t=C?.quote;return t?$e(e).filter(({actionId:n,policy:r})=>Ae(t,e,n,r.product,z)).map(({actionId:n})=>n):[]}function Ht(e){return C?.phase==="payment"?$t(e):[]}function mt(){return(C?C.phase==="payment":!Re())&&(Re()||!!a.prepareUpgradeReplacement)&&de()&&!!a.terminateCheckout&&!!i.quote&&i.canReselect===!1&&!!i.operation&&x(i.operation).type==="checkout"}function Qt(e){let t=i.quote;return!de()||Q||!t||!i.operation||x(i.operation).type!=="checkout"?[]:$e(e).filter(({actionId:n,policy:r})=>Ae(t,e,n,r.product,z)).map(({actionId:n})=>n)}function ve(){let e=q?[]:C?Ht(c):Qt(c),t=a.allowNewPurchase===!1&&!!i.operation&&x(i.operation).type==="checkout";if(le.hidden=!!q||(C?C.phase!=="payment":!t)||e.length>0,!de()&&!C||!H?.updateCheckoutControls)return;let n=!q&&C?.phase==="checking"?fe:void 0;H.updateCheckoutControls({actions:$e(c).map(({actionId:r})=>r),resume:n?[n]:e,resumeLabel:n?ht:o?"继续付款":C?"Continue payment":"Continue checkout",busy:fe})}function Bt(){ue?.remove(),ue=null}async function Xe(){if(Q)return;if(a.resumeCheckout&&i.operation){let t=i.operation.operationId;try{await a.resumeCheckout(t)}catch(n){if(!(n instanceof k&&n.code==="PURCHASE_PENDING"))throw n;let r=await i.read();if(!I())return;if(r.operationId!==t||x(r).type==="checkout")throw n;await M(r,!1)}return}let e=await i.read();if(x(e).type!=="checkout")return M(e,!1);I()&&(He.delete(e.operationId),await Qe(e))}function yt(){ye?.destroy(),ye=void 0,Je=void 0}function jt(){let e=Q;if(!e||ye)return;let t=o?"仍在核对原订单,暂时无法更换套餐。":"We’re still checking the original purchase before changing plans.",n=Date.now()+6e5,r=un({document:p,delay:()=>Date.now()<n?5e3:void 0,async run(){if(!I())return;let s=await i.read();if(ye!==r||!I())return;if(s.operationId!==e.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");let f=x(s);f.type==="native"?(yt(),d.textContent=o?"原订单已关闭。你可以继续更换套餐。":"The original checkout is closed. You can continue changing plans.",h.textContent=o?"继续更换套餐":"Continue changing plans",u=()=>Ze(),h.hidden=!1):(f.type==="complete"||f.type==="fulfillment"||f.type==="recording")&&(yt(),Q=null,h.hidden=!0,await M(s,!1))}});ye=r,Je=async()=>{try{await r.refresh()}finally{ye===r&&(d.textContent=t,h.hidden=!1)}},u=Je,h.textContent=o?"查询结果":"Check result",h.hidden=!1,d.textContent=t,r.schedule()}async function Ze(e=!1){let t=Q;if(!t)return;u=()=>Ze(),C&&(h.textContent=o?"查询状态":"Check status"),h.hidden=!0;let n=Date.now()+2e4;for(;I();){let r=await i.read();if(r.operationId!==t.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");if(!I())break;let s=x(r);if(s.type==="native"){if(!Re()&&a.prepareUpgradeReplacement){let f=await a.prepareUpgradeReplacement(t.operationId,t.intent);if(!I())return;Vt=!0,Ve(f)}Q=null,C&&Se(C.quote),Bt(),P=t.selection,Y=t.coupon,Ee=!1,xe=!1,await Fe();return}if(s.type==="complete"||s.type==="fulfillment"||s.type==="recording"){Q=null,C?await Pe(C.quote,r):await M(r,!1);return}if(e&&s.type==="checkout"){e=!1;try{await a.terminateCheckout(t.operationId)}catch(f){G(a.onError,f)}}if(Date.now()>=n){C&&s.type==="checkout"&&(Q=null,await Pe(C.quote,r));break}await ze(1e3,p,ne.signal)}!Q||g||(C?(d.textContent=o?"仍在核对原升级单,暂时无法更换套餐。":"We’re still checking the original upgrade before changing plans.",h.hidden=!1):jt())}async function Ft(e,t,n,r){if(u=()=>Ft(e,t,n,r),await a.beforeCheckoutReplacement?.(structuredClone(r)),!I())return;let s=i.operation;if(s?.operationId!==e||x(s).type!=="checkout"){u=null,s&&await M(s,!1);return}Q={operationId:e,selection:t,coupon:n,intent:r},C&&(d.textContent=o?"正在切换套餐…":"Changing plan…",h.hidden=!0);let f=!1;try{await a.terminateCheckout(e)}catch(l){if(l instanceof k&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(l.code)){Q=null,C&&(u=bt,h.textContent=o?"查询状态":"Check status",h.hidden=!1),d.textContent=o?"请继续原订单,或等待它过期后再更换方案。":"Continue your original checkout, or wait for it to expire before changing plans.",G(a.onError,l);return}f=l instanceof k&&(l.status??0)>=500,G(a.onError,l)}I()&&await Ze(f)}function wt(e,t,n,r,s){let f=ae(e).checkoutCoupons?.[t],l=f?f.products[n]:a.claimCoupon&&s?rn(e.capabilities,s,r):void 0;return l?.couponId&&l.planVersionId===n?{id:l.couponId,offerId:l.offerId}:void 0}function Sn(e){he||P||i.quote||i.operation||Ke&&d.textContent===Ke||(d.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":o?"当前账号暂无可购买的方案。":"No plans are currently available for this account.")}let He=new Map,et=!1;function Ae(e,t,n,r,s,f){let l=N(e),y=!l&&e.lines.length===1?e.lines[0]:void 0,m=Ie(r,s,t.capabilities);if(!m||m!==(l?e.productVersionId:y?.productVersionId))return!1;let A=wt(t,n,m,s,f),K;try{K=Ue(t.document.screen,m,s,t.capabilities)}catch{return!1}if(l){let J=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return Object.keys(K).length===Object.keys(e.featureQuantities??{}).length&&Object.entries(K).every(([Ne,It])=>e.featureQuantities?.[Ne]===It)&&(!A||J?.couponId===A.id&&(!A.offerId||J.grantId===A.offerId))}if((A||ae(t).checkoutCoupons?.[n])&&(A?.id??null)!==(e.discount?.couponId??null))return!1;let Z=Object.fromEntries((y?.prepaid??[]).map(J=>[J.internal_feature_id,J.quantity]));return[...new Set([...Object.keys(K),...Object.keys(Z)])].every(J=>(K[J]??0)===(Z[J]??0))}let x=e=>on({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:g,canReselect:i.canReselect});async function Qe(e){let t=e.merchantExecution,n=x(e),r=n.type==="checkout"?n.checkoutUrl:e.checkoutUrl;if(!(!I()||!r||nt(e)&&n.type!=="checkout"||a.checkoutNavigation==="after_confirmation"&&n.type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||He.get(e.operationId)===r)){He.set(e.operationId,r);try{a.onCheckoutUrl?await a.onCheckoutUrl(r):p.defaultView?.location.assign(r)}catch(s){throw He.delete(e.operationId),s}}}let we=(e,t=!1)=>{if(e instanceof Rt)u=null,d.textContent=e.customerMessage(o);else if(Cn(e))u=null,d.textContent=t?o?"当前无法在此购买,付款尚未开始。请联系商户。":"Purchases aren’t available here right now. Payment hasn’t started. Contact the merchant for help.":Ot(e,o);else if(t){let n=e instanceof k?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(u=null,d.textContent=o?"暂时无法为此套餐报价,付款尚未开始。":"Pricing for this plan is unavailable. Payment hasn’t started."):i.canReselect===!0&&!P?d.textContent=o?"未能取得报价,付款尚未开始。请重新选择套餐。":"We couldn’t prepare your price. Payment hasn’t started. Choose a plan again.":n==="COMMAND_PENDING"?d.textContent=o?"仍在准备报价,请重试以查看结果。":"Your price is still being prepared. Retry to check the result.":d.textContent=o?"未能取得报价,付款尚未开始。请重试。":"We couldn’t prepare your price. Payment hasn’t started. Try again."}else d.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?Ot(e,o):e instanceof k?e.message:o?"操作未完成,请重试。":"This action couldn’t be completed. Try again.";h.hidden=u===null,Ke=d.textContent,t&&fe===void 0&&!_?.responsive&&d.scrollIntoView?.({block:"nearest"}),G(t&&E?.quoteError?E.quoteError:a.onError,e)},Be=new WeakMap;function je(e){he=e,h.disabled=e,le.disabled=e,H?.updateCapabilities?.(ae(c),be(c));for(let t of ue?.querySelectorAll("button")??[])e?(Be.has(t)||Be.set(t,t.disabled),t.disabled=!0):Be.has(t)&&(t.disabled=Be.get(t),Be.delete(t)),Tt(t)}function qt(){q&&(d.textContent=q.message,h.textContent=o?"重试":"Retry",h.disabled=!1,h.hidden=!q.retry,le.disabled=!0)}function gt(){d.textContent=o?"暂时无法操作,请稍后重试。":"This action is unavailable right now. Try again in a moment."}async function Tn(e){if(a.beforeAction)try{await a.beforeAction()}catch(t){throw t instanceof Rt?(P=null,Ee=!1,xe=!1,u=null):u=e,t}}async function B(e,t){if(he||g||q)return;if(!I()){gt();return}let n=e===Fe,r=n?xn:En,s=de()&&t!==void 0;fe=s?t:void 0,je(!0),ve(),h.hidden=!0,d.textContent=s?"":r;try{if(e!==Jt&&e!==bt&&e!==Ct&&e!==Je&&(e!==Xe||!a.resumeCheckout)&&await Tn(e),g||q)return;if(!I()){u=e,h.hidden=!1,gt();return}await e()}catch(f){g||we(f,n)}finally{fe=void 0,je(!1),ve(),q?qt():d.textContent===r&&(d.textContent="")}}async function Wt(e){await Pn(se,e,a)}function Se(e,t){C=t?{quote:e,phase:t}:void 0,t==="checking"?(fe??=P?.actionId??$t(c)[0],d.textContent=ht,u=bt,h.textContent=o?"查询状态":"Check status",h.hidden=!0):fe=void 0,H?.updateCapabilities(ae(c),be(c)),ve()}function Gt(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 zt(e,t){At(e,{...t,featureQuantities:t.featureQuantities??{}},"Purchase operation changed")}async function bt(){C&&await Pe(C.quote)}async function Pe(e,t){Se(e,"checking"),Ke="";let n=1e3;Me=!0,G(a.onObservationChange,!0);try{for(let r=t;I();r=void 0){if(!r){try{r=await i.read()}catch(s){if(!Gt(s))throw s}if(!I())return}if(r){zt(r,e);let s=x(r);if(s.type==="checkout"){Se(e,"payment"),d.textContent=o?"请先完成原订单的付款。":"Finish paying for this upgrade.",h.hidden=!1;return}if(s.type==="complete"){Se(e,"complete"),u=null;let f=c.capabilities.plans[e.productVersionId]?.name,l=e.merchantTerms?.subscriptionTerms?.items,y=l?.length===1?l[0].interval:void 0,m=y==="year"?o?"年付":"annual billing":y==="month"?o?"月付":"monthly billing":null;d.textContent=f?o?`已升级到 ${f}${m?" "+m:""}。`:`Upgraded to ${f}${m?" ("+m+")":""}.`:o?"已成功升级。":"Plan upgraded.",await Wt(r);return}if(s.type==="native"&&!De(r)){Se(e),P=null,u=null,d.textContent=o?"付款未完成,请重新选择套餐。":"Payment failed. Choose a plan to start again.",h.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 ze(n,p,ne.signal),n=Math.min(n*1.5,15e3)}}finally{Me=!1,G(a.onObservationChange,!1)}}async function Ct(){let e=C?.quote;if(!e)return;let t=await i.read();if(zt(t,e),x(t).type!=="checkout")return Pe(e,t);if(a.resumeCheckout){await a.resumeCheckout(t.operationId);return}He.delete(t.operationId),await Qe(t)}function Yt(e){return xt(i).type==="recording"||x(e).type==="recording"}function Kt(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],r=t?t.totalMinor:N(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),s=t?n.length===1&&n[0]?.amountMinor===r&&n[0]:!N(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===r&&e.lines[0],f=r===null?ge(t.subtotalMinor-t.discountMinor,e.currency)+(o?" + 待确认税费":" + tax confirmed at checkout"):ge(r,e.currency)+(s?_e(s.interval,o?"zh-CN":"en",s.intervalCount??1):""),l=N(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(y=>y.productName).join(", ");return{label:l?`${l} · ${f}`:f,recurring:s}}async function M(e,t=a.checkoutNavigation!=="after_confirmation"){if(g)return;if(!I()){u=async()=>M(await i.read()),h.hidden=!1;return}let n=e.quote??i.quote;if(pt(n)&&(e.confirmedAt||e.merchantExecution))return Pe(n,e);if(d.textContent=vn(e.status,o),Yt(e)){let m=e.merchantExecution?.recordingStatus==="failed";d.textContent=m?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.",h.textContent=o?"查询记录":"Check recording",u=async()=>M(await i.read()),h.hidden=!1;return}if(e.problem&&x(e).type!=="native"){let m=e.problem;u=Te,h.textContent=o?"检查并恢复原操作":"Check and recover original purchase",we(new k(m.code,m.reason==="RESULT_UNKNOWN"?o?"付款结果尚未确定,请恢复原操作,暂勿重复购买。":"The payment result is unknown. Recover the original purchase before buying again.":m.phase==="fulfillment"?o?"付款已记录,商户权益处理需要核对。":"Payment was recorded. Access fulfillment needs attention.":m.code==="CAPABILITY_UNAVAILABLE"?o?"商户尚不支持本次购买所需的完整能力,请处理后恢复原操作。":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":m.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,m));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)&&(d.textContent=o?"付款已记录,正在等待商户完成处理。":"Payment was recorded. Waiting for merchant fulfillment."),Ge(e)&&x(e).type==="complete"){u=null,await Wt(e);return}if(!De(e)&&x(e).type!=="fulfillment"){if(i.canReselect===!1){d.textContent=o?"正在核对原购买结果":"Checking the original purchase result",h.textContent=o?"查询结果":"Check result",u=async()=>M(await i.read()),h.hidden=!1;return}e.status==="cancelled"?d.textContent=o?"这笔购买已取消,可以重新选择方案。":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(d.textContent=o?"这笔购买未能完成,可以重新选择方案。":"This purchase didn’t go through. Choose a plan to try again."),h.textContent=o?"重试":"Retry",u=null,P=null;return}if(!t&&x(e).type==="checkout"){if(Q){jt();return}if(de()){d.textContent="",et=!1,u=null,h.hidden=!0,H?.updateCapabilities?.(ae(c),be(c)),ve();return}let m=i.quote,A=m?.operationId===e.operationId?Kt(m).label:"";d.textContent=et?A?o?`${A} 尚未付款。再次选择该方案即可继续付款。`:`${A} is still unpaid. Choose it again to continue paying.`:o?"之前的购买尚未付款。再次选择该方案即可继续付款。":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",et=!1,u=null;return}await Qe(e);let r=Date.now(),s=r+6e5,f=2e3,l=x(e).type!=="checkout",y=()=>l&&Date.now()-r<15e3;Me=!0,G(a.onObservationChange,!0);try{for(;!g&&Date.now()<s;){if(await ze(y()?700:f,p,ne.signal),g)return;if(!I()){u=async()=>M(await i.read()),h.hidden=!1;return}let m=await i.read();if(x(m).type==="checkout"&&(l=!1),!t&&x(m).type==="checkout"){await M(m,!1);return}if(!m.problem&&De(m)&&await Qe(m),!De(m)||m.problem||Yt(m)){await M(m);return}y()||(f=Math.min(f*1.5,3e4))}}finally{Me=!1,G(a.onObservationChange,!1)}u=async()=>M(await i.read()),h.hidden=!1}async function vt(e=!1){let t=await i.read();if(g)return;if(!I()){u=()=>vt(e),h.hidden=!1;return}let n=i.quote;if(n&&At(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&(nt(t)?["prepared","quoted"].includes(t.status):t.status==="pending")&&(nt(t)||t.quoteFinalized===!1)&&!t.confirmedAt&&!t.checkoutUrl&&!("nativePurchase"in t&&t.nativePurchase)&&!t.merchantExecution&&!t.problem&&!i.pendingCancellation){if(a.purchaseConfirmation!=="paywall"){e?await Te():u=null;return}setTimeout(Xt,0,n);return}await M(t,e||void 0)}async function Jt(){await vt()}async function On(e){d.textContent=ht;let t=Date.now()+12e3;for(;!g&&Date.now()<t&&(await ze(1500,p,ne.signal),!(g||!I()));){let n;try{n=await i.read()}catch{break}if(n.problem?.reason!=="RESULT_UNKNOWN")return n}return e}async function Te(){if(i.quote&&!(Date.parse(i.quote.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");Bt();let e=i.quote;if(pt(e)){Se(e,"checking");let n;try{n=await i.confirm()}catch(r){if(!Gt(r))throw r;return Pe(e)}return Pe(e,n)}u=Te;let t=await i.confirm();if(!I()){u=Te,h.hidden=!1;return}if(t.problem?.reason==="RESULT_UNKNOWN"&&(t=await On(t)),t.problem){await M(t);return}if(De(t)){if(x(t).type==="checkout")await Qe(t);else if(t.execution&&t.execution.provider!=="merchant"||"nativePurchase"in t&&t.nativePurchase){if(!a.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:t,signal:ne.signal})}}u=async()=>M(await i.read()),await M(t,!0)}function Xt(e){if(g)return;ue?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());d.textContent=t?o?"此报价已过期。请先取消,再重新选择。":"This quote has expired. Cancel it, then choose again.":"";let n=p.createElement("div"),r=p.createElement("button"),s=p.createElement("button"),f=p.createElement("div"),l=p.createElement("p"),y=e.merchantTerms,m=o?"zh-CN":"en",A=y?.subscriptionTerms?.items??[],K=y?y.subscriptionTerms?.trial?.days:N(e)?void 0:e.lines.find(w=>w.trial)?.trial?.days,Z=N(e)?y?y.totalMinor:e.totalMinor:K===void 0?null:y?y.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(w=>w.trial)?0:null,Oe=(w,v)=>o?`${v} 天试用结束后 ${w}`:`Then ${w} after the ${v}-day trial`,{label:J,recurring:Ne}=Kt(e),It=N(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(w=>w.productName).join(", "),tn=Z===null?"":`${o?"今天应付":"Due today"} ${ge(Z,e.currency)}`;l.textContent=tn?[It,tn].filter(Boolean).join(" · "):J,r.textContent=N(e)?o?"确认变更":"Confirm change":o?"确认购买":"Confirm purchase",r.disabled=t,s.textContent=o?"取消":"Cancel",n.style.cssText=L.panel,l.style.cssText=L.summary,f.style.cssText=L.actions,r.style.cssText=L.primary,s.style.cssText=L.secondary,Tt(r),r.onclick=()=>{B(Te)};let nn=async()=>{let w=await i.cancel();g||(n.remove(),ue=null,await M(w))};s.onclick=()=>{u=nn,B(nn)};let W=p.createElement("div");if(W.style.cssText=L.terms,N(e)){for(let[v,S]of Object.entries(e.featureQuantities??{})){let V=i.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(Nn=>Nn.internalFeatureId===v),tt=p.createElement("p");tt.textContent=`${V?.name??v} · ${S} ${o?"份":"packs"}${V?` × ${V.terms.units}`:""}`,W.append(tt)}for(let[v,S]of[[o?"原订阅抵扣":"Unused subscription credit",e.creditMinor],[o?"新套餐费用":"New plan charge",e.debitMinor],[o?"优惠减免":"Offer savings",y?.discountMinor??e.discountMinor],[o?"税费":"Tax",y?y.taxMinor:e.taxMinor]]){let V=p.createElement("p");V.textContent=`${v}: ${S===null?o?"结账时确认":"Confirmed at checkout":ge(S,e.currency)}`,W.append(V)}let w=p.createElement("p");w.textContent=`${o?"生效时间":"Effective"}: ${e.effectiveAt}`,W.append(w)}if(y){for(let v of A){if(Z===null&&v===Ne)continue;let S=p.createElement("p"),V=ge(v.amountMinor,e.currency)+_e(v.interval,m,v.intervalCount);S.textContent=Z!==null&&K!==void 0?Oe(V,K):V,v.amountAfterOfferMinor!==void 0&&(S.textContent+=` · ${o?"优惠结束后":"After the offer"} ${ge(v.amountAfterOfferMinor,e.currency)}${_e(v.interval,m,v.intervalCount)}`),W.append(S)}let w=y.subscriptionTerms?.trial;if(w){let v=p.createElement("p");v.textContent=o?`试用 ${w.days} 天;${w.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${w.days}; ${w.cardRequired?"a payment method is required":"no payment method is required"}`,W.append(v)}for(let v of[...y.expectedEffects.map(S=>S.description),...y.requiredConsents.map(S=>S.summary)]){let S=p.createElement("p");S.textContent=v,W.append(S)}}else if(!N(e)){for(let w of e.lines){if(Z!==null||w!==Ne){let v=p.createElement("p"),S=`${ge(w.catalogAmountMinor,e.currency)}${_e(w.interval,m,w.intervalCount??1)}`;v.textContent=Z!==null&&w.trial?(e.lines.length>1?`${w.productName} · `:"")+Oe(S,w.trial.days):`${w.productName} · ${S}`,W.append(v)}for(let v of w.prepaid??[]){let S=p.createElement("p"),V=i.view?.capabilities.plans[w.productVersionId]?.prepaid?.find(tt=>tt.internalFeatureId===v.internal_feature_id);S.textContent=`${V?.name??v.internal_feature_id} · ${v.quantity} ${o?"份":"packs"} × ${v.terms.units}`,V&&(S.textContent+=_e(V.reset==="week"||V.reset==="month"||V.reset==="year"?V.reset:"one_time",m,V.resetCount)),W.append(S)}if(w.trial){let v=p.createElement("p");v.textContent=o?`试用 ${w.trial.days} 天;${w.trial.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${w.trial.days}; ${w.trial.cardRequired?"a payment method is required":"no payment method is required"}`,W.append(v)}}if(!e.charge){let w=p.createElement("p");w.textContent=o?"目录价格;最终金额以结账时税费和试用规则为准。":"Catalog price; the final charge depends on checkout taxes and trial terms.",W.append(w)}}for(let w of W.children)w.style.margin="0";f.append(r,s),n.append(l,...W.childElementCount?[W]:[],f),F.prepend(n),_?.responsive||n.scrollIntoView?.({block:"nearest"}),r.focus({preventScroll:!0}),ue=n,he&&je(!0),u=null}async function Fe(){if(!P)return;if(u=Fe,!Ee){let n=i.view,r=n?.document.buttons[P.actionId],s=n&&r?.type==="checkout"?Ie(r.product,P.selection,n.capabilities):null;if(!n||!s)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!xe){let l=await a.resolveSubscriptionChange?.({actionId:P.actionId,productVersionId:s,featureQuantities:Ue(n.document.screen,s,P.selection,n.capabilities)});if(g)return;l!==void 0&&(P.subscriptionChange=an.parse(l)),xe=!0}let f=Y?.offerId;if(Y&&!f){if(!a.claimCoupon)throw new k("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:l}=await a.claimCoupon(Y.id,P.requestId);if(g)return;if(!l||l.couponId!==Y.id||l.status!=="issued"||!(Date.parse(l.expiresAt)>Date.now()))throw P=null,Y=void 0,u=async()=>{Ve(await i.refresh()),u=null},new k("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");f=l.id}if(!Y&&!n.document.screen.actions.some(l=>l.id===P?.actionId&&typeof l.properties.couponBinding=="string")&&(f=await a.resolveOfferId?.({actionId:P.actionId,productVersionId:s,featureQuantities:Ue(n.document.screen,s,P.selection,n.capabilities)})),g)return;f!==void 0&&(P.offerId=f),Ee=!0}if(!I()){h.hidden=!1;return}let e;try{e=await i.preview(P)}catch(n){throw i.canReselect===!0&&(P=null,Ee=!1,xe=!1,Y=void 0,u=null),n}if(Y&&(N(e)?(()=>{let n=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return n?.couponId!==Y.id||n.grantId!==P.offerId})():e.discount?.couponId!==Y.id||e.discount.offerId!==P.offerId))throw new k("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(g)return;let t=e.merchantTerms;if(a.purchaseConfirmation!=="paywall"||a.confirmOnHostedCheckout&&I()&&!N(e)&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){if(!I()){h.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 n=fe?"":o?"正在打开收银台…":"Opening checkout…";d.textContent=n;try{await Te()}catch(r){g||we(r)}finally{d.textContent===n&&(d.textContent="")}return}Xt(e)}function ke(e="destroy",t=!1){if(g)return;g=!0;let n=ut;ut=void 0,G(n),a.signal?.removeEventListener("abort",oe),i.signal?.removeEventListener("abort",oe),U.finish("dismissed"),Dt?.(),yt(),ne.abort(),Nt?.disconnect(),H?.destroy(),i.destroy(),R.removeEventListener("cancel",en),O.remove(),D.remove(),t||Zt(),e==="dismiss"&&G(a.onDismiss)}function Zt(){if(_?.destroy(),ce){ce.release();return}R.open&&R.close(),R.remove(),T()}j=ke;async function qe(){if(!Ce||g||Ye||ie==="closing"||!ie&&!I())return;if(!E){ke("dismiss");return}let e=p.createElement("p");e.setAttribute("role","status"),e.textContent=o?"正在关闭…":"Closing…",me||(me=p.createElement("div"),me.style.cssText=F.style.cssText,F.replaceWith(me),pe.inert=!0),O.hidden=!1,me.replaceChildren(e,O),ie="closing",O.setAttribute("aria-disabled","true"),O.focus({preventScroll:!0});try{await E.dismiss()}catch(t){g||G(a.onError,t)}g||(ie="retry",e.textContent=o?"未能确认关闭,请重试。":"Could not confirm closure. Try again.",O.textContent=o?"重试关闭":"Retry closing",O.removeAttribute("aria-label"),O.removeAttribute("aria-disabled"))}O.onclick=()=>{qe()};function en(e){e.preventDefault(),qe()}R.addEventListener("cancel",en),le.onclick=()=>{B(C?Ct:Xe)},h.onclick=()=>{if(q){q.retry?.();return}u&&B(u)};function Pt(e){U.finish("error",e),ke()}function kt(){if(!(!Lt||Ce||g||Ye||_&&!I()))try{let e=t=>{a.focusAtReveal&&(T=St(p)),H?.setHidden?.(!1),dt?.(),_&&(R.open||R.showModal(),_.responsive&&R.focus({preventScroll:!0}),!t&&a.loading!=="host"&&fn(R,_.type,_.responsive)),t&&a.loading!=="host"&&typeof pe.animate=="function"&&!p.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&pe.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),Ce=!0};E?E.present(t=>U.present(n=>e(t??n))):U.present(e)}catch(e){Pt(e),we(e)}}try{if(Le.type==="inline"?(st(),dt=gn(D,$),$.append(D)):(R.setAttribute("aria-label",c.document.name),O.textContent="×",O.setAttribute("aria-label",o?"关闭":"Close"),pn(O,c.document.screen.theme),O.hidden=cn(c.document),(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&ce?.content?ce.content.append(O,D):R.replaceChildren(O,D),ce||$.append(R),_=dn(R,{...c.document.screen,presentation:Le},ct),_.latch(),_.responsive&&(D.style.display="flex",D.style.flexDirection="column",D.style.maxHeight="100%",pe.style.overflow="clip",pe.style.minHeight="0"),ce||(dt=wn(R))),at&&X){let n=at(X);if(typeof n=="function"&&(g?G(n):ut=n),g)throw new DOMException("Presentation cancelled","AbortError");st()}H=te(pe,{mode:"live",rendererUrl:"bundled",title:c.document.name,closeActions:Rn,onAuthoredClose(n){ie||g||(O.hidden=n)},hostPresentation:()=>_?.type??Le.type,reportContentHeight:_?.responsive,onResize:n=>{if(!_?.responsive)return;let r=Math.min(n,lt);pe.style.height=`${r}px`,_.setContentHeight(r+Ut())},onSelection(n){for(let[r,s]of Object.entries(n))typeof s=="number"&&typeof z[r]=="number"&&z[r]!==s&&Mt.add(r);z=n,ve()},onAction(n,r={},s,f){if(!Ce||g||ie)return;let l=i.view,y=l?.document.buttons[n];if(!y)return;if(q){y.type==="close"&&qe();return}if(y.type==="close"&&E&&a.resumeCheckout&&i.operation&&sn(x(i.operation))){qe();return}if(he)return;if(!I()){gt();return}if(y.type==="close"){B(async()=>{E?.closeAction?await E.closeAction(n):await a.onAction?.(n),ke(a.onAction?"action":"dismiss")});return}if(y.type==="action"){u=async()=>{if(y.action.type==="event"){if(!a.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(y.action.event)}else a.onOpenUrl?await a.onOpenUrl(y.action.url):p.defaultView?.location.assign(y.action.url);await a.onAction?.(n),u=null},B(u);return}if(de()&&Q){!ye&&Q.selection.actionId===n&&B(()=>Ze(!0),n);return}if(C){if(C.phase==="payment"&&l&&Ae(C.quote,l,n,y.product,r,f)){B(Ct,n);return}if(!mt())return}if(!Re()&&!mt()){de()&&l&&i.quote&&i.operation&&x(i.operation).type==="checkout"&&Ae(i.quote,l,n,y.product,r,f)?B(Xe,n):d.textContent=o?"当前只能继续原订单。":"Only your original checkout is available.";return}if(ue&&i.canReselect===!1){d.textContent=o?"请先确认或取消当前购买。":"Confirm or cancel the current purchase first.",_?.responsive||ue.scrollIntoView?.({block:"nearest"}),ue.querySelector("button")?.focus({preventScroll:!0});return}if(de()&&a.terminateCheckout&&l&&i.quote&&i.operation&&i.canReselect===!1&&x(i.operation).type==="checkout"){if(Ae(i.quote,l,n,y.product,r,f)){B(Xe,n);return}let A=Ie(y.product,r,l.capabilities),K;try{if(!A)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");K=Ue(l.document.screen,A,r,l.capabilities)}catch(Ne){we(Ne);return}let Z=i.operation.operationId,Oe={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(r)},J=wt(l,n,A,r,f);B(()=>Ft(Z,Oe,J,{actionId:n,productVersionId:A,selection:Oe.selection,featureQuantities:K}),n);return}if((i.quote||P)&&i.canReselect===!1){let A=!!l&&!!i.quote&&Ae(i.quote,l,n,y.product,r,f);et=!!i.quote&&!A,u=i.quote?()=>vt(A):Fe,B(u);return}let m=l&&Ie(y.product,r,l.capabilities);if(!l||!m){we(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){u=null,B(async()=>{let A={actionId:n,productVersionId:m,selection:structuredClone(r),featureQuantities:Ue(l.document.screen,m,r,l.capabilities)};ft=!0,await a.onPurchaseIntent(A)});return}if(P&&P.actionId!==n){we(new k("COMMAND_PENDING","Finish the current purchase"));return}P||(Y=wt(l,n,m,r,f),P={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(r)},Ee=!1,xe=!1),B(Fe,n)},onEscape:()=>{qe()},onError:n=>{let r=new Error(n);!Ce&&!g&&Pt(r),we(r)},onRendered:n=>{n&&R.setAttribute("aria-label",n),Lt=!0,kt()}}),H.setHidden?.(!0),ct();let e=de()&&!!i.quote&&!!i.operation&&x(i.operation).type==="checkout";z=i.quote?In(c,i.quote)??rt(c,{}):rt(c,{}),H.update(c.document.screen,ot,{capabilities:ae(c),unavailableActions:be(c),serverInput:{bindings:[],answers:{}},...Object.keys(z).length?{selection:z}:{}}),Dt=i.subscribe?.(Ve),Ve(i.view??c),await U.wait(H.ready);let t=i.operation;(!e||pt(i.quote))&&(i.quote||t&&(t.confirmedAt||t.checkoutUrl||Ge(t)))&&(u=Jt,B(u))}catch(e){throw Pt(e),e}return{check:se,host:{get currentResolution(){return c},setPurchaseRecovery(e,t){q={message:e,retry:t},H?.updateCapabilities?.(ae(c),be(c)),ve(),qt()},get subscriptionUpgradeActive(){return C!==void 0},get observing(){return Me},get recovery(){return An()},async prepareFallback(){if(he||g||ie||ft)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};je(!0);try{let e=await ln(i);return e.type==="native"&&ke(),e}finally{je(!1)}},setSuspended(e){Ye=e,D.hidden=e,e&&R.open?R.close():!e&&!Ce?kt():!e&&!g&&Ce&&Le.type!=="inline"&&!R.open&&R.showModal()},destroy:ke,retainPurchaseDialog(){if(!(g||!R.open||!R.isConnected))return ke("destroy",!0),{dialog:R,content:ce?.content,release:Zt}},refresh:async()=>{if(!I()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return Ve(e),kt(),e}}}}export{dr as a};
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { S as StackNode } from './screen-D2bUmJ4M.js';
2
+ import { S as StackNode } from './screen-Pv_pViF6.js';
3
3
 
4
4
  declare const configurationScopeSchema: z.ZodObject<{
5
5
  projectId: z.ZodString;
@@ -1346,7 +1346,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1346
1346
  outcome: "completed" | "failed" | "closed" | "ineligible";
1347
1347
  } | {
1348
1348
  type: "server";
1349
- reason: "action" | "wait" | "condition" | "experiment" | "feature" | "resource";
1349
+ reason: "action" | "condition" | "experiment" | "feature" | "resource" | "wait";
1350
1350
  }>;
1351
1351
  };
1352
1352
  control: {
@@ -1895,7 +1895,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
1895
1895
  entry: string;
1896
1896
  nodes: {
1897
1897
  id: string;
1898
- type: "output" | "action" | "wait" | "screen" | "end" | "coupon" | "condition" | "feature" | "split" | "coupons" | "offering" | "entry" | "external_page";
1898
+ type: "output" | "action" | "screen" | "end" | "coupon" | "condition" | "feature" | "split" | "coupons" | "offering" | "entry" | "external_page" | "wait";
1899
1899
  outputs: Record<string, string>;
1900
1900
  writes: Record<string, string>;
1901
1901
  resources: {
@@ -1 +1 @@
1
- import{i as ie}from"./chunk-FBNEQ2K5.js";import{a as Z,c as ee,e as te,f as ne,i as N,k as re,l as oe,m as se}from"./chunk-J5K4PNII.js";import{b as X}from"./chunk-EE6QNOCL.js";import{r as V}from"./chunk-32AEJKJW.js";import"./chunk-EKUDMQXT.js";import"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-J7VGTAJ7.js";import"./chunk-HUYKZH3H.js";import{o as Y,p as K}from"./chunk-VXDVMAS6.js";import{A as G}from"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import{c as $,d as R}from"./chunk-FQMZY5VP.js";import{a as p}from"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-J3RW4GMO.js";import"./chunk-5MRSFLQA.js";import{b as u}from"./chunk-PZTWDJHN.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var z=new WeakMap;function ce(s){let t={string:u.string(),number:u.number().finite(),boolean:u.boolean(),strings:u.array(u.string()),json:R}[s.type];return s.nullable?t.nullable():t}function ae(s,t){let f=u.record(u.string(),R).parse(s);if(Object.keys(f).length>40)throw new p("INVALID_REQUEST","Too many content inputs");for(let[m,r]of Object.entries(f))Y.parse({[m]:r});if(Object.keys(f).some(m=>!Object.hasOwn(t.inputs,m)))throw new p("INVALID_REQUEST","Undeclared content input");for(let[m,r]of Object.entries(t.inputs))if(Object.hasOwn(f,m))ce(r).parse(f[m]);else if(r.required)throw new p("INVALID_REQUEST",`Missing content input ${m}`);return f}async function Ae(s,t){return le(s,t,!1)}async function Se(s,t){return le(s,t,!0)}async function le(s,t,f){t.signal?.throwIfAborted();let m=X.parse(t.content),r=m.document;if(t.closeControl==="content"&&!r.screen.actions.some(e=>e.type==="event"&&e.close))throw new p("INVALID_REQUEST","An authored Close control requires a declared Close action");if(z.has(s))throw new p("CONFLICT","Content is already mounted in this container");let y=ae(t.inputs??{},r.contract),T=new Set(u.array(u.string()).max(40).parse(t.mutableInputs??[]));if(T.size!==(t.mutableInputs?.length??0)||[...T].some(e=>!Object.hasOwn(r.contract.inputs,e)))throw new p("INVALID_REQUEST","Mutable content inputs must name unique declared inputs");for(let e of Object.keys(r.contract.outputs))if(typeof t.actions[e]!="function")throw new p("INVALID_REQUEST",`Missing host handler for ${e}`);let M=K.parse(t.bindings??[]),d=s.ownerDocument,ue=s.clientHeight||d.defaultView?.innerHeight||800,P,w,a,_,x=r.kind==="popup",n=x?d.createElement("dialog"):null,c=d.createElement("div");if(c.dataset.indianaContent=r.kind,c.setAttribute("aria-label",r.name),c.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",r.name);let e=r.screen.presentation;n.style.cssText="box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto",e.type==="modal"||e.type==="sheet"?(n.style.width=`${$[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",a=ee(n,r.screen,()=>{w?.resizeViewport(d.defaultView?.innerHeight||800,d.defaultView?.innerWidth||1024)}),n.append(c),s.append(n)}else s.append(c);let i=!1,A=!1,E=!1,S=!1,de=n?oe(n):se(c,s),D=re(s,t,r.kind,()=>{k()&&(b(),h(t.onDismiss))}),q,H,L=new Promise((e,o)=>{q=e,H=o});L.catch(()=>{});let g=null,I=structuredClone(r.screen),W=G(I,[t.locale,...d.defaultView?.navigator.languages??[]]),j=t.capabilities;I.actions=I.actions.map(e=>e.type==="event"?{...e,close:!1}:e);function b(){i||(i=!0,t.signal?.removeEventListener("abort",b),D.finish("dismissed"),H(new Error("Content preparation cancelled")),a?.destroy(),_?.(),w?.destroy(),n?.close(),n?.remove(),c.remove(),z.delete(s),n&&P?.())}let v=()=>{!E||!k()||(b(),h(t.onDismiss))};function k(){try{return t.canDismiss?.()!==!1}catch(e){return h(t.onError,e),!1}}if(n&&t.closeControl!=="content"){let e=d.createElement("button");e.type="button",e.textContent="×",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"关闭":"Close"),ne(e,r.screen.theme),e.addEventListener("click",v),n.prepend(e)}n&&a?.responsive&&(_=Z(n,v,k,t.locale?.startsWith("zh")?"关闭":"Close"),n.addEventListener("click",e=>{if(e.target!==n)return;let o=n.getBoundingClientRect();(e.clientX<o.left||e.clientX>o.right||e.clientY<o.top||e.clientY>o.bottom)&&v()})),n?.addEventListener("cancel",e=>{e.preventDefault(),v()}),n?.addEventListener("keydown",e=>{e.key==="Escape"&&(e.preventDefault(),v())});async function F(){if(i||!E||A||!g)return;let e=g;A=!0,c.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),g=null}catch(o){i||h(t.onError,o)}finally{A=!1,i||c.removeAttribute("aria-busy")}}function J(){if(i)throw new p("CONFLICT","Content host has been destroyed");E||!S||(P??=N(d),D.present(e=>{de(),n&&(a?.latch(),n.showModal(),a?.responsive&&n.focus({preventScroll:!0}),!e&&t.loading!=="host"&&te(n,a?.type??r.screen.presentation.type,a?.responsive)),E=!0}))}function U(e){D.finish("error",e),H(e instanceof Error?e:new Error(String(e))),b()}let Q={destroy:b,show:J,get pendingAction(){return g?structuredClone(g):null},retryAction:F,updateInputs(e){if(i)throw new p("CONFLICT","Content host has been destroyed");let o=u.record(u.string(),R).parse(e),C=ae({...y,...o},r.contract);for(let l of Object.keys(o))if(!T.has(l)&&(!Object.hasOwn(y,l)||V(y[l])!==V(C[l])))throw new p("PRECONDITION_FAILED","This content input is frozen; prepare a new presentation");V(y)!==V(C)&&(w?.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:C}}),y=C)},updateCapabilities(e){if(i)return;let o=structuredClone(e);w?.updateCapabilities(o),j=o}};z.set(s,Q),t.signal?.addEventListener("abort",b,{once:!0});try{if(t.signal?.throwIfAborted(),f||(P=N(d),D.start(x,t.locale??r.screen.strings.defaultLocale),i&&await L),w=ie(c,{mode:"live",rendererUrl:t.rendererUrl,title:r.name,viewportHeight:r.kind==="page"?ue:a?.responsive?d.defaultView?.innerHeight||800:void 0,...a?.responsive?{viewportWidth:d.defaultView?.innerWidth||1024,hostPresentation:()=>a.type}:{},onResize:e=>{i||a?.responsive&&(c.style.height=`${e}px`,c.style.overflow="clip",a.setContentHeight(e))},onRendered:e=>{if(!i&&(e&&n?.setAttribute("aria-label",e),!S))try{S=!0,f||J(),q()}catch(o){U(o),h(t.onError,o)}},onError:e=>{if(i)return;let o=new Error(e);S||U(o),h(t.onError,o)},onEscape:x?v:void 0,onAction:(e,o,C)=>{if(i||!E||A||g)return;let l=r.screen.actions.find(O=>O.id===e),B=r.contract.outputs[e];if(!(l?.type!=="event"||!B)&&!(l.close&&!k()))try{let O=ce(B).parse(Object.hasOwn(l.properties,"value")?l.properties.value:l.properties);g=structuredClone({requestId:crypto.randomUUID(),contentVersionId:m.id,actionId:e,event:l.event,value:O,selection:o??{},answers:C??{},requestedClose:l.close}),F()}catch(O){h(t.onError,O)}}}),w.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:y}}),await Promise.race([w.ready,L]),f&&await L,i)throw new Error("Content preparation cancelled");return Q}catch(e){throw U(e),e}}export{Ae as mountContent,Se as prepareContent};
1
+ import{i as ie}from"./chunk-2KM537QH.js";import{a as Z,c as ee,e as te,f as ne,i as N,k as re,l as oe,m as se}from"./chunk-IM5OXTEH.js";import{b as X}from"./chunk-EE6QNOCL.js";import{r as V}from"./chunk-32AEJKJW.js";import"./chunk-EKUDMQXT.js";import"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-QJPH7AFI.js";import"./chunk-HUYKZH3H.js";import{o as Y,p as K}from"./chunk-VXDVMAS6.js";import{A as G}from"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import{c as $,d as R}from"./chunk-FQMZY5VP.js";import{a as p}from"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-S3QZOIUO.js";import"./chunk-5MRSFLQA.js";import{b as u}from"./chunk-PZTWDJHN.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var z=new WeakMap;function ce(s){let t={string:u.string(),number:u.number().finite(),boolean:u.boolean(),strings:u.array(u.string()),json:R}[s.type];return s.nullable?t.nullable():t}function ae(s,t){let f=u.record(u.string(),R).parse(s);if(Object.keys(f).length>40)throw new p("INVALID_REQUEST","Too many content inputs");for(let[m,r]of Object.entries(f))Y.parse({[m]:r});if(Object.keys(f).some(m=>!Object.hasOwn(t.inputs,m)))throw new p("INVALID_REQUEST","Undeclared content input");for(let[m,r]of Object.entries(t.inputs))if(Object.hasOwn(f,m))ce(r).parse(f[m]);else if(r.required)throw new p("INVALID_REQUEST",`Missing content input ${m}`);return f}async function Ae(s,t){return le(s,t,!1)}async function Se(s,t){return le(s,t,!0)}async function le(s,t,f){t.signal?.throwIfAborted();let m=X.parse(t.content),r=m.document;if(t.closeControl==="content"&&!r.screen.actions.some(e=>e.type==="event"&&e.close))throw new p("INVALID_REQUEST","An authored Close control requires a declared Close action");if(z.has(s))throw new p("CONFLICT","Content is already mounted in this container");let y=ae(t.inputs??{},r.contract),T=new Set(u.array(u.string()).max(40).parse(t.mutableInputs??[]));if(T.size!==(t.mutableInputs?.length??0)||[...T].some(e=>!Object.hasOwn(r.contract.inputs,e)))throw new p("INVALID_REQUEST","Mutable content inputs must name unique declared inputs");for(let e of Object.keys(r.contract.outputs))if(typeof t.actions[e]!="function")throw new p("INVALID_REQUEST",`Missing host handler for ${e}`);let M=K.parse(t.bindings??[]),d=s.ownerDocument,ue=s.clientHeight||d.defaultView?.innerHeight||800,P,w,a,_,x=r.kind==="popup",n=x?d.createElement("dialog"):null,c=d.createElement("div");if(c.dataset.indianaContent=r.kind,c.setAttribute("aria-label",r.name),c.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",r.name);let e=r.screen.presentation;n.style.cssText="box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto",e.type==="modal"||e.type==="sheet"?(n.style.width=`${$[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",a=ee(n,r.screen,()=>{w?.resizeViewport(d.defaultView?.innerHeight||800,d.defaultView?.innerWidth||1024)}),n.append(c),s.append(n)}else s.append(c);let i=!1,A=!1,E=!1,S=!1,de=n?oe(n):se(c,s),D=re(s,t,r.kind,()=>{k()&&(b(),h(t.onDismiss))}),q,H,L=new Promise((e,o)=>{q=e,H=o});L.catch(()=>{});let g=null,I=structuredClone(r.screen),W=G(I,[t.locale,...d.defaultView?.navigator.languages??[]]),j=t.capabilities;I.actions=I.actions.map(e=>e.type==="event"?{...e,close:!1}:e);function b(){i||(i=!0,t.signal?.removeEventListener("abort",b),D.finish("dismissed"),H(new Error("Content preparation cancelled")),a?.destroy(),_?.(),w?.destroy(),n?.close(),n?.remove(),c.remove(),z.delete(s),n&&P?.())}let v=()=>{!E||!k()||(b(),h(t.onDismiss))};function k(){try{return t.canDismiss?.()!==!1}catch(e){return h(t.onError,e),!1}}if(n&&t.closeControl!=="content"){let e=d.createElement("button");e.type="button",e.textContent="×",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"关闭":"Close"),ne(e,r.screen.theme),e.addEventListener("click",v),n.prepend(e)}n&&a?.responsive&&(_=Z(n,v,k,t.locale?.startsWith("zh")?"关闭":"Close"),n.addEventListener("click",e=>{if(e.target!==n)return;let o=n.getBoundingClientRect();(e.clientX<o.left||e.clientX>o.right||e.clientY<o.top||e.clientY>o.bottom)&&v()})),n?.addEventListener("cancel",e=>{e.preventDefault(),v()}),n?.addEventListener("keydown",e=>{e.key==="Escape"&&(e.preventDefault(),v())});async function F(){if(i||!E||A||!g)return;let e=g;A=!0,c.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),g=null}catch(o){i||h(t.onError,o)}finally{A=!1,i||c.removeAttribute("aria-busy")}}function J(){if(i)throw new p("CONFLICT","Content host has been destroyed");E||!S||(P??=N(d),D.present(e=>{de(),n&&(a?.latch(),n.showModal(),a?.responsive&&n.focus({preventScroll:!0}),!e&&t.loading!=="host"&&te(n,a?.type??r.screen.presentation.type,a?.responsive)),E=!0}))}function U(e){D.finish("error",e),H(e instanceof Error?e:new Error(String(e))),b()}let Q={destroy:b,show:J,get pendingAction(){return g?structuredClone(g):null},retryAction:F,updateInputs(e){if(i)throw new p("CONFLICT","Content host has been destroyed");let o=u.record(u.string(),R).parse(e),C=ae({...y,...o},r.contract);for(let l of Object.keys(o))if(!T.has(l)&&(!Object.hasOwn(y,l)||V(y[l])!==V(C[l])))throw new p("PRECONDITION_FAILED","This content input is frozen; prepare a new presentation");V(y)!==V(C)&&(w?.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:C}}),y=C)},updateCapabilities(e){if(i)return;let o=structuredClone(e);w?.updateCapabilities(o),j=o}};z.set(s,Q),t.signal?.addEventListener("abort",b,{once:!0});try{if(t.signal?.throwIfAborted(),f||(P=N(d),D.start(x,t.locale??r.screen.strings.defaultLocale),i&&await L),w=ie(c,{mode:"live",rendererUrl:t.rendererUrl,title:r.name,viewportHeight:r.kind==="page"?ue:a?.responsive?d.defaultView?.innerHeight||800:void 0,...a?.responsive?{viewportWidth:d.defaultView?.innerWidth||1024,hostPresentation:()=>a.type}:{},onResize:e=>{i||a?.responsive&&(c.style.height=`${e}px`,c.style.overflow="clip",a.setContentHeight(e))},onRendered:e=>{if(!i&&(e&&n?.setAttribute("aria-label",e),!S))try{S=!0,f||J(),q()}catch(o){U(o),h(t.onError,o)}},onError:e=>{if(i)return;let o=new Error(e);S||U(o),h(t.onError,o)},onEscape:x?v:void 0,onAction:(e,o,C)=>{if(i||!E||A||g)return;let l=r.screen.actions.find(O=>O.id===e),B=r.contract.outputs[e];if(!(l?.type!=="event"||!B)&&!(l.close&&!k()))try{let O=ce(B).parse(Object.hasOwn(l.properties,"value")?l.properties.value:l.properties);g=structuredClone({requestId:crypto.randomUUID(),contentVersionId:m.id,actionId:e,event:l.event,value:O,selection:o??{},answers:C??{},requestedClose:l.close}),F()}catch(O){h(t.onError,O)}}}),w.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:y}}),await Promise.race([w.ready,L]),f&&await L,i)throw new Error("Content preparation cancelled");return Q}catch(e){throw U(e),e}}export{Ae as mountContent,Se as prepareContent};
@@ -1 +1 @@
1
- import{b as ne}from"./chunk-O2V4MTM6.js";import{b as j}from"./chunk-PTNMDAND.js";import{a as re}from"./chunk-MZ6NEOOQ.js";import"./chunk-R4CYPCBI.js";import{a as z}from"./chunk-IMFPRZUY.js";import"./chunk-JBSJ3JU2.js";import"./chunk-PGLBFTRK.js";import{b as te}from"./chunk-U2NEVISJ.js";import"./chunk-45PGU2HW.js";import"./chunk-AEQUKR4O.js";import"./chunk-W32FI2A2.js";import{j as A,k as V}from"./chunk-J5K4PNII.js";import"./chunk-77O2O552.js";import"./chunk-PJHTN5NJ.js";import"./chunk-6426YKPK.js";import"./chunk-ZCJEXNJD.js";import"./chunk-VNYUL3PV.js";import"./chunk-NDNHTG5B.js";import"./chunk-5LNX7MHO.js";import"./chunk-LUDTXNMH.js";import"./chunk-BJW4AXFL.js";import"./chunk-32AEJKJW.js";import"./chunk-EKUDMQXT.js";import"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-JEDRJAJ5.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-J7VGTAJ7.js";import"./chunk-HUYKZH3H.js";import"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import{a as C}from"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-SLUA7ABW.js";import"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-J3RW4GMO.js";import"./chunk-5MRSFLQA.js";import"./chunk-PZTWDJHN.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var k=new WeakMap,_=new WeakMap,B=new WeakSet;function he(D,e){let P=e.hostPaywallTarget?void 0:e.prepared,J=()=>{e.prepared&&!B.has(e.prepared)&&j(e.prepared)?.release()},K=k.get(e.client);if(K)return J(),K;let Q=n=>({...n,requestId:n.requestId??crypto.randomUUID()}),O=e.allowNewPurchase!==!1&&e.start instanceof Promise?e.start:void 0,m=e.allowNewPurchase===!1||!e.start||e.start instanceof Promise?void 0:Q(e.start);m&&P?.state==="ready"&&P.matches(m)&&P.open();let f=P&&(m&&(P.state==="preparing"||["shown","closed"].includes(P.state)&&P.matches(m))||O&&["preparing","ready"].includes(P.state))?P:void 0;f?B.add(f):J();let y=f&&j(f);y?.claim();let S=Promise.resolve().then(async()=>{let n=!1,c,p=!1,U,g=0,E,q,X=!1,F=()=>{},Y=()=>{},H,L=!1,M=!1,I,Z=!1,a=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,v=()=>{k.get(e.client)===S&&k.delete(e.client),a.removeEventListener("abort",R),F(),Y(),f&&B.delete(f),y?.release()};function $(){if(I)return I;let t=new Promise(o=>I=o);return _.set(e.client,t),t.then(()=>{_.get(e.client)===t&&_.delete(e.client)}),k.get(e.client)===S&&k.delete(e.client),I}let l=V(D,e,"funnel",()=>b(),z);function R(){b()}function b(t=!1){if(!n){if(n=!0,l.finish("dismissed"),c){c.destroy();return}if(t&&H){let o=$();Z=!0,H.then(async s=>{s.mode==="run"&&s.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===m?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{o(),h(e.onDismiss,null)}),v();return}v(),h(e.onDismiss,null)}}let N={destroy:()=>b(),refresh:()=>E??(p?G():c?.refresh())??Promise.resolve(),get recovery(){return c?.recovery??{type:"recover",operationId:null,requestId:null}},prepareFallback:()=>c?.prepareFallback()??Promise.resolve({type:"recover",operationId:null,requestId:null}),review:(...t)=>c?.review(...t)??Promise.resolve(),exitReview:(...t)=>c?.exitReview(...t)??Promise.resolve(),get unappliedDrafts(){return c?.unappliedDrafts??new Map}};a.addEventListener("abort",R,{once:!0}),y&&(Y=y.onClose(()=>{L?n||$():b(!0)}));try{a.throwIfAborted();let t=e.client.controller?.view?.paywall?.resolution,o=t&&"document"in t?t.document:e.loadingDocument;l.start(!0,m?.locale??e.client.attempt?.locale??o?.screen.strings.defaultLocale,o??null);let s=O?l.wait(O.then(r=>r?Q(r):null,()=>null),A):Promise.resolve(m??null);s.catch(()=>{}),f?.state==="shown"?(M=!0,l.present(()=>{})):f&&["preparing","ready"].includes(f.state)&&Promise.all([f.ready,s.catch(()=>null)]).then(([r,i])=>{if(r){if(n||!l.active||!i||!f.matches(i)||!y?.revealable)return y?.release();l.present(()=>{f.open()==="shown"?M=!0:y.release()})}});let d=_.get(e.client);if(d&&await l.wait(d),n)return null;if(a.throwIfAborted(),O){let r=await s;if(n)return null;if(a.throwIfAborted(),!r)return l.finish("skipped"),v(),null;m=r}H=m?e.client.start(m):e.client.refresh({reuseRecentRead:!0});let u=await l.wait(H,A);return n?null:(a.throwIfAborted(),await ee(u,l))}catch(t){if(Z||I?.(),n)return null;throw l.finish("error",t),v(),h(e.onError,t),t}function x(t=!1){g++;let o=c;c=void 0,F(),F=()=>{};let s=t?o?.retainPurchaseDialog?.():void 0;return o?.destroy(),a.addEventListener("abort",R,{once:!0}),s}function T(t){p=!0;let o=e.client.attempt?.locale??m?.locale,s=o?.startsWith("zh"),d=t?s?"正在查询原订单…":"Checking your purchase…":s?"暂时无法确认原订单,请重试。":"Could not check your original purchase. Try again.",u=t?void 0:()=>{G()};c?.setPurchaseRecovery?.(d,u)||(c&&x(),l.active||(l=V(D,e,"funnel",()=>b(),z),l.start(!0,o,e.loadingDocument??null)),l.setPurchaseRecovery(d,u))}function G(){if(E)return E;if(n||a.aborted)return Promise.resolve();U??=c?.recoveryPaywall,a.addEventListener("abort",R,{once:!0}),T(!0);let t=Promise.resolve().then(async()=>{try{let s=await l.wait(e.client.refresh(),A);!n&&!a.aborted&&await ee(s,l)}catch(s){!n&&!a.aborted&&(h(e.onError,s),T(!1))}});E=t;let o=()=>{E===t&&(E=void 0)};return t.then(o,o),t}async function ee(t,o){let s=e.client.controller;if(t.mode==="run"&&t.status!=="blocked"&&s)return p&&c&&x(),p=!1,U=void 0,ae(s,o?.active?o:void 0);if(t.mode==="operation"&&t.purchases.length){T(!0);let d=await l.wait(e.client.recoverPurchasePaywall(U).then(u=>((n||a.aborted)&&u?.destroy(),u)),A).catch(u=>(!n&&!a.aborted&&h(e.onError,u),null));if(n||a.aborted)return null;if(d){if(n||a.aborted)return d.destroy(),null;let u=x(!0)??y?.retainPurchaseDialog?.()??l.retainPurchaseDialog();y?.release();let r=await re(D,{signal:a,loading:"host",start:async()=>d,checkoutNavigation:"after_confirmation",allowNewPurchase:!1,resumeCheckout:w=>e.client.continueCheckout(W,w),onError:e.onError,onDismiss:()=>{n||b()}},{retainedDialog:u,present(w){l.active?l.present(w):w(!!u)},async dismiss(){b()}});if(!r.host||n||a.aborted)return r.host?.destroy(),u?.release(),v(),null;let i=r.host;return p=!1,c={destroy(){i.destroy(),v(),h(e.onDismiss,null)},refresh:async()=>{await i.refresh()},get recovery(){return i.recovery},prepareFallback:()=>i.prepareFallback(),review:async()=>{},exitReview:async()=>{},unappliedDrafts:new Map},N}}return t.purchases.length||p?(T(!1),N):(l.finish("skipped"),v(),(M||L)&&(n=!0,h(e.onDismiss,null)),null)}function W(t){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(t):D.ownerDocument.defaultView?.location.assign(t)}async function ae(t,o){a.removeEventListener("abort",R),L=!0;function s(){!n&&!a.aborted&&!p&&!X&&q&&e.client.recovery.status==="complete"&&(X=!0,h(e.onComplete,structuredClone(q)))}F(),F=e.client.subscribe(s);let d=++g,u=await ne(D,{...e,prepared:f,client:t,signal:a,checkoutNavigation:"after_confirmation",resumeCheckout:r=>e.client.continueCheckout(W,r),terminateCheckout:e.allowNewPurchase===!1?void 0:r=>e.client.terminateCheckout(r),async onCheckoutUrl(r){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");let i=e.client.recovery;if((!i.actions.includes("continue_checkout")||!i.purchases.some(w=>w.type==="checkout"&&w.checkoutUrl===r))&&(i=await e.client.refresh(),a.throwIfAborted(),n))throw new DOMException("Presentation dismissed","AbortError");if(te(i)!==r)throw new C("PURCHASE_PENDING","Checkout differs from the original recovery proof");return W(r)},async resolveOfferId(r){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");let i=e.client.attempt;if(!i)throw new C("PURCHASE_PENDING","Read the original Start before selecting an offer");let w=await e.resolveOfferId?.(r,i);if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==i.requestId)throw new C("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return w},async resolveSubscriptionChange(r){a.throwIfAborted();let i=e.client.attempt;if(n||!i)throw new C("PURCHASE_PENDING","Read the original Start before selecting a membership");let w=await e.resolveSubscriptionChange?.(r);if(a.throwIfAborted(),n||e.client.attempt?.requestId!==i.requestId)throw new C("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting a membership");return w},onPresentationState(r){d===g&&h(e.onPresentationState,r)},onComplete(r){d===g&&(q=r,s())},onError(r){d===g&&(h(e.onError,r),r instanceof C&&(r.status===401||r.status===409&&r.reason==="STATE_CHANGED"&&r.recovery==="recover_operation")&&!a.aborted&&G().catch(i=>h(e.onError,i)))},onDismiss(r){d===g&&(n=!0,v(),I?.(),h(e.onDismiss,r))}},o);return d!==g||n||a.aborted?(u.destroy(),n||a.aborted?null:N):(c=u,N)}});return k.set(e.client,S),S}export{he as showFunnelPurchase};
1
+ import{b as ne}from"./chunk-TBXHEGSY.js";import{b as j}from"./chunk-6TETQL5Z.js";import{a as re}from"./chunk-XZLGDFZ4.js";import"./chunk-R4CYPCBI.js";import{a as V}from"./chunk-QXDLOPZK.js";import"./chunk-JBSJ3JU2.js";import"./chunk-PGLBFTRK.js";import{b as te}from"./chunk-S24PK62Y.js";import"./chunk-45PGU2HW.js";import"./chunk-AEQUKR4O.js";import"./chunk-W32FI2A2.js";import{j as A,k as z}from"./chunk-IM5OXTEH.js";import"./chunk-77O2O552.js";import"./chunk-PJHTN5NJ.js";import"./chunk-5QVMWM2X.js";import"./chunk-ZCJEXNJD.js";import"./chunk-VNYUL3PV.js";import"./chunk-NDNHTG5B.js";import"./chunk-5LNX7MHO.js";import"./chunk-S55446VK.js";import"./chunk-BJW4AXFL.js";import"./chunk-32AEJKJW.js";import"./chunk-EKUDMQXT.js";import"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-JEDRJAJ5.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-QJPH7AFI.js";import"./chunk-HUYKZH3H.js";import"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import{a as C}from"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-SLUA7ABW.js";import"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-S3QZOIUO.js";import"./chunk-5MRSFLQA.js";import"./chunk-PZTWDJHN.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var k=new WeakMap,_=new WeakMap,B=new WeakSet;function he(D,e){let P=e.hostPaywallTarget?void 0:e.prepared,J=()=>{e.prepared&&!B.has(e.prepared)&&j(e.prepared)?.release()},K=k.get(e.client);if(K)return J(),K;let Q=n=>({...n,requestId:n.requestId??crypto.randomUUID()}),O=e.allowNewPurchase!==!1&&e.start instanceof Promise?e.start:void 0,m=e.allowNewPurchase===!1||!e.start||e.start instanceof Promise?void 0:Q(e.start);m&&P?.state==="ready"&&P.matches(m)&&P.open();let f=P&&(m&&(P.state==="preparing"||["shown","closed"].includes(P.state)&&P.matches(m))||O&&["preparing","ready"].includes(P.state))?P:void 0;f?B.add(f):J();let y=f&&j(f);y?.claim();let S=Promise.resolve().then(async()=>{let n=!1,c,p=!1,U,g=0,E,q,X=!1,F=()=>{},Y=()=>{},H,L=!1,M=!1,I,Z=!1,a=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,v=()=>{k.get(e.client)===S&&k.delete(e.client),a.removeEventListener("abort",R),F(),Y(),f&&B.delete(f),y?.release()};function $(){if(I)return I;let t=new Promise(o=>I=o);return _.set(e.client,t),t.then(()=>{_.get(e.client)===t&&_.delete(e.client)}),k.get(e.client)===S&&k.delete(e.client),I}let l=z(D,e,"funnel",()=>b(),V);function R(){b()}function b(t=!1){if(!n){if(n=!0,l.finish("dismissed"),c){c.destroy();return}if(t&&H){let o=$();Z=!0,H.then(async s=>{s.mode==="run"&&s.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===m?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{o(),h(e.onDismiss,null)}),v();return}v(),h(e.onDismiss,null)}}let N={destroy:()=>b(),refresh:()=>E??(p?G():c?.refresh())??Promise.resolve(),get recovery(){return c?.recovery??{type:"recover",operationId:null,requestId:null}},prepareFallback:()=>c?.prepareFallback()??Promise.resolve({type:"recover",operationId:null,requestId:null}),review:(...t)=>c?.review(...t)??Promise.resolve(),exitReview:(...t)=>c?.exitReview(...t)??Promise.resolve(),get unappliedDrafts(){return c?.unappliedDrafts??new Map}};a.addEventListener("abort",R,{once:!0}),y&&(Y=y.onClose(()=>{L?n||$():b(!0)}));try{a.throwIfAborted();let t=e.client.controller?.view?.paywall?.resolution,o=t&&"document"in t?t.document:e.loadingDocument;l.start(!0,m?.locale??e.client.attempt?.locale??o?.screen.strings.defaultLocale,o??null);let s=O?l.wait(O.then(r=>r?Q(r):null,()=>null),A):Promise.resolve(m??null);s.catch(()=>{}),f?.state==="shown"?(M=!0,l.present(()=>{})):f&&["preparing","ready"].includes(f.state)&&Promise.all([f.ready,s.catch(()=>null)]).then(([r,i])=>{if(r){if(n||!l.active||!i||!f.matches(i)||!y?.revealable)return y?.release();l.present(()=>{f.open()==="shown"?M=!0:y.release()})}});let d=_.get(e.client);if(d&&await l.wait(d),n)return null;if(a.throwIfAborted(),O){let r=await s;if(n)return null;if(a.throwIfAborted(),!r)return l.finish("skipped"),v(),null;m=r}H=m?e.client.start(m):e.client.refresh({reuseRecentRead:!0});let u=await l.wait(H,A);return n?null:(a.throwIfAborted(),await ee(u,l))}catch(t){if(Z||I?.(),n)return null;throw l.finish("error",t),v(),h(e.onError,t),t}function x(t=!1){g++;let o=c;c=void 0,F(),F=()=>{};let s=t?o?.retainPurchaseDialog?.():void 0;return o?.destroy(),a.addEventListener("abort",R,{once:!0}),s}function T(t){p=!0;let o=e.client.attempt?.locale??m?.locale,s=o?.startsWith("zh"),d=t?s?"正在查询原订单…":"Checking your purchase…":s?"暂时无法确认原订单,请重试。":"Could not check your original purchase. Try again.",u=t?void 0:()=>{G()};c?.setPurchaseRecovery?.(d,u)||(c&&x(),l.active||(l=z(D,e,"funnel",()=>b(),V),l.start(!0,o,e.loadingDocument??null)),l.setPurchaseRecovery(d,u))}function G(){if(E)return E;if(n||a.aborted)return Promise.resolve();U??=c?.recoveryPaywall,a.addEventListener("abort",R,{once:!0}),T(!0);let t=Promise.resolve().then(async()=>{try{let s=await l.wait(e.client.refresh(),A);!n&&!a.aborted&&await ee(s,l)}catch(s){!n&&!a.aborted&&(h(e.onError,s),T(!1))}});E=t;let o=()=>{E===t&&(E=void 0)};return t.then(o,o),t}async function ee(t,o){let s=e.client.controller;if(t.mode==="run"&&t.status!=="blocked"&&s)return p&&c&&x(),p=!1,U=void 0,ae(s,o?.active?o:void 0);if(t.mode==="operation"&&t.purchases.length){T(!0);let d=await l.wait(e.client.recoverPurchasePaywall(U).then(u=>((n||a.aborted)&&u?.destroy(),u)),A).catch(u=>(!n&&!a.aborted&&h(e.onError,u),null));if(n||a.aborted)return null;if(d){if(n||a.aborted)return d.destroy(),null;let u=x(!0)??y?.retainPurchaseDialog?.()??l.retainPurchaseDialog();y?.release();let r=await re(D,{signal:a,loading:"host",start:async()=>d,checkoutNavigation:"after_confirmation",allowNewPurchase:!1,resumeCheckout:w=>e.client.continueCheckout(W,w),onError:e.onError,onDismiss:()=>{n||b()}},{retainedDialog:u,present(w){l.active?l.present(w):w(!!u)},async dismiss(){b()}});if(!r.host||n||a.aborted)return r.host?.destroy(),u?.release(),v(),null;let i=r.host;return p=!1,c={destroy(){i.destroy(),v(),h(e.onDismiss,null)},refresh:async()=>{await i.refresh()},get recovery(){return i.recovery},prepareFallback:()=>i.prepareFallback(),review:async()=>{},exitReview:async()=>{},unappliedDrafts:new Map},N}}return t.purchases.length||p?(T(!1),N):(l.finish("skipped"),v(),(M||L)&&(n=!0,h(e.onDismiss,null)),null)}function W(t){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(t):D.ownerDocument.defaultView?.location.assign(t)}async function ae(t,o){a.removeEventListener("abort",R),L=!0;function s(){!n&&!a.aborted&&!p&&!X&&q&&e.client.recovery.status==="complete"&&(X=!0,h(e.onComplete,structuredClone(q)))}F(),F=e.client.subscribe(s);let d=++g,u=await ne(D,{...e,prepared:f,client:t,signal:a,checkoutNavigation:"after_confirmation",resumeCheckout:r=>e.client.continueCheckout(W,r),terminateCheckout:e.allowNewPurchase===!1?void 0:r=>e.client.terminateCheckout(r),async onCheckoutUrl(r){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");let i=e.client.recovery;if((!i.actions.includes("continue_checkout")||!i.purchases.some(w=>w.type==="checkout"&&w.checkoutUrl===r))&&(i=await e.client.refresh(),a.throwIfAborted(),n))throw new DOMException("Presentation dismissed","AbortError");if(te(i)!==r)throw new C("PURCHASE_PENDING","Checkout differs from the original recovery proof");return W(r)},async resolveOfferId(r){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");let i=e.client.attempt;if(!i)throw new C("PURCHASE_PENDING","Read the original Start before selecting an offer");let w=await e.resolveOfferId?.(r,i);if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==i.requestId)throw new C("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return w},async resolveSubscriptionChange(r){a.throwIfAborted();let i=e.client.attempt;if(n||!i)throw new C("PURCHASE_PENDING","Read the original Start before selecting a membership");let w=await e.resolveSubscriptionChange?.(r);if(a.throwIfAborted(),n||e.client.attempt?.requestId!==i.requestId)throw new C("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting a membership");return w},onPresentationState(r){d===g&&h(e.onPresentationState,r)},onComplete(r){d===g&&(q=r,s())},onError(r){d===g&&(h(e.onError,r),r instanceof C&&(r.status===401||r.status===409&&r.reason==="STATE_CHANGED"&&r.recovery==="recover_operation")&&!a.aborted&&G().catch(i=>h(e.onError,i)))},onDismiss(r){d===g&&(n=!0,v(),I?.(),h(e.onDismiss,r))}},o);return d!==g||n||a.aborted?(u.destroy(),n||a.aborted?null:N):(c=u,N)}});return k.set(e.client,S),S}export{he as showFunnelPurchase};
@@ -1 +1 @@
1
- import{a as E}from"./chunk-MZ6NEOOQ.js";import{a as A}from"./chunk-R4CYPCBI.js";import"./chunk-IMFPRZUY.js";import"./chunk-AEQUKR4O.js";import"./chunk-W32FI2A2.js";import{g as S}from"./chunk-J5K4PNII.js";import"./chunk-NDNHTG5B.js";import"./chunk-5LNX7MHO.js";import"./chunk-EKUDMQXT.js";import{b as C}from"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-J7VGTAJ7.js";import"./chunk-HUYKZH3H.js";import{t as k}from"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import{a as i}from"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-J3RW4GMO.js";import"./chunk-5MRSFLQA.js";import"./chunk-PZTWDJHN.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";async function V(d,e){if(!d.closest("dialog")?.open)return null;let r=AbortSignal.any([e.signal,e.client.identitySignal]);r.throwIfAborted();let a=e.operationId?await e.client.recoverPurchasePaywall(void 0,e.operationId):await e.client.recoverPurchasePaywall();if(!a)return null;let w=a.view;if(!w||w.document.presentation.type!=="modal"||r.aborted)return a.destroy(),null;let l=e.upgradeReplacement,c=a,f=c,h,R=l?new Proxy(a,{get(o,t){let s=f[t];return typeof s=="function"?s.bind(f):s}}):a;async function U(o,t){if(r.throwIfAborted(),!l||c.operation?.operationId!==o||!c.canReselect)throw new i("PURCHASE_PENDING","The original upgrade has not been closed");if(!h){let n=await l.start();if(!n)throw new i("PRODUCT_UNAVAILABLE","The selected upgrade is unavailable");if(n.funnelId!==e.client.attempt?.funnelId)throw new i("SCOPE_MISMATCH","The new upgrade belongs to another Funnel");h={...n,requestId:n.requestId??crypto.randomUUID()}}r.throwIfAborted();let s=await e.client.start(h),g=e.client.controller;if(s.mode!=="run"||s.status!=="ready"||!g?.view?.paywall)throw new i("PURCHASE_PENDING","The current Paywall could not be opened for the replacement");let p=await A(g);try{r.throwIfAborted();let n=p.view,b=n?.document.buttons[t.actionId],I=n&&b?.type==="checkout"?C(b.product,t.selection,n.capabilities):null;if(!n||I!==t.productVersionId)throw new i("PRODUCT_UNAVAILABLE","The selected upgrade is no longer available");let v=k(n.document.screen,I,t.selection,n.capabilities);if(Object.keys(v).length!==Object.keys(t.featureQuantities).length||Object.entries(v).some(([T,D])=>t.featureQuantities[T]!==D))throw new i("PRODUCT_UNAVAILABLE","The selected upgrade quantities have changed");return f=p,c.destroy(),n}catch(n){throw p.destroy(),n}}let m=S(d);if(!m)return a.destroy(),null;let u,O=new Promise(o=>{u=o}),y=!1,P=()=>u(!1);r.addEventListener("abort",P,{once:!0});try{let{host:o}=await E(d,{signal:r,start:async()=>R,loading:"host",checkoutNavigation:"after_confirmation",allowNewPurchase:!1,...l&&{beforeCheckoutReplacement:l.beforeCheckoutReplacement,resolveOfferId:l.resolveOfferId,resolveSubscriptionChange:l.resolveSubscriptionChange,terminateCheckout:t=>e.client.terminateCheckout(t),prepareUpgradeReplacement:U},resumeCheckout:t=>e.client.continueCheckout(e.onCheckoutUrl,t),onComplete:e.onComplete,onError(t){y?e.onError?.(t):u(!1)}},{retainedDialog:m,present(t){t(!0),y=!0,u(!0)},async dismiss(){e.onDismiss()}});return!o||!await O||r.aborted?(o?.destroy(),null):{document:w.document,destroy:()=>o.destroy()}}finally{r.removeEventListener("abort",P)}}export{V as mountFunnelRecoveryPaywall};
1
+ import{a as E}from"./chunk-XZLGDFZ4.js";import{a as A}from"./chunk-R4CYPCBI.js";import"./chunk-QXDLOPZK.js";import"./chunk-AEQUKR4O.js";import"./chunk-W32FI2A2.js";import{g as S}from"./chunk-IM5OXTEH.js";import"./chunk-NDNHTG5B.js";import"./chunk-5LNX7MHO.js";import"./chunk-EKUDMQXT.js";import{b as C}from"./chunk-4OODZM64.js";import"./chunk-EB7MIZ4T.js";import"./chunk-S5RM3VO6.js";import"./chunk-DBYRJ4QV.js";import"./chunk-VILB5M4X.js";import"./chunk-QJPH7AFI.js";import"./chunk-HUYKZH3H.js";import{t as k}from"./chunk-VXDVMAS6.js";import"./chunk-ZRGL2CAP.js";import"./chunk-KTWKDR5L.js";import"./chunk-XCFAKO23.js";import"./chunk-FQMZY5VP.js";import{a as i}from"./chunk-TK3WOD2O.js";import"./chunk-RIEWU4MN.js";import"./chunk-S3QZOIUO.js";import"./chunk-5MRSFLQA.js";import"./chunk-PZTWDJHN.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";async function V(d,e){if(!d.closest("dialog")?.open)return null;let r=AbortSignal.any([e.signal,e.client.identitySignal]);r.throwIfAborted();let a=e.operationId?await e.client.recoverPurchasePaywall(void 0,e.operationId):await e.client.recoverPurchasePaywall();if(!a)return null;let w=a.view;if(!w||w.document.presentation.type!=="modal"||r.aborted)return a.destroy(),null;let l=e.upgradeReplacement,c=a,f=c,h,R=l?new Proxy(a,{get(o,t){let s=f[t];return typeof s=="function"?s.bind(f):s}}):a;async function U(o,t){if(r.throwIfAborted(),!l||c.operation?.operationId!==o||!c.canReselect)throw new i("PURCHASE_PENDING","The original upgrade has not been closed");if(!h){let n=await l.start();if(!n)throw new i("PRODUCT_UNAVAILABLE","The selected upgrade is unavailable");if(n.funnelId!==e.client.attempt?.funnelId)throw new i("SCOPE_MISMATCH","The new upgrade belongs to another Funnel");h={...n,requestId:n.requestId??crypto.randomUUID()}}r.throwIfAborted();let s=await e.client.start(h),g=e.client.controller;if(s.mode!=="run"||s.status!=="ready"||!g?.view?.paywall)throw new i("PURCHASE_PENDING","The current Paywall could not be opened for the replacement");let p=await A(g);try{r.throwIfAborted();let n=p.view,b=n?.document.buttons[t.actionId],I=n&&b?.type==="checkout"?C(b.product,t.selection,n.capabilities):null;if(!n||I!==t.productVersionId)throw new i("PRODUCT_UNAVAILABLE","The selected upgrade is no longer available");let v=k(n.document.screen,I,t.selection,n.capabilities);if(Object.keys(v).length!==Object.keys(t.featureQuantities).length||Object.entries(v).some(([T,D])=>t.featureQuantities[T]!==D))throw new i("PRODUCT_UNAVAILABLE","The selected upgrade quantities have changed");return f=p,c.destroy(),n}catch(n){throw p.destroy(),n}}let m=S(d);if(!m)return a.destroy(),null;let u,O=new Promise(o=>{u=o}),y=!1,P=()=>u(!1);r.addEventListener("abort",P,{once:!0});try{let{host:o}=await E(d,{signal:r,start:async()=>R,loading:"host",checkoutNavigation:"after_confirmation",allowNewPurchase:!1,...l&&{beforeCheckoutReplacement:l.beforeCheckoutReplacement,resolveOfferId:l.resolveOfferId,resolveSubscriptionChange:l.resolveSubscriptionChange,terminateCheckout:t=>e.client.terminateCheckout(t),prepareUpgradeReplacement:U},resumeCheckout:t=>e.client.continueCheckout(e.onCheckoutUrl,t),onComplete:e.onComplete,onError(t){y?e.onError?.(t):u(!1)}},{retainedDialog:m,present(t){t(!0),y=!0,u(!0)},async dismiss(){e.onDismiss()}});return!o||!await O||r.aborted?(o?.destroy(),null):{document:w.document,destroy:()=>o.destroy()}}finally{r.removeEventListener("abort",P)}}export{V as mountFunnelRecoveryPaywall};