@tinkerlandai/longplay-sdk 0.10.25 → 0.10.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/THIRD_PARTY_NOTICES.md +26 -0
- package/dist/{ai-usage-B6RepnmH.d.ts → ai-usage-E4c9NSJK.d.ts} +1 -1
- package/dist/{api-C9P338XT.d.ts → api-BpeJkr6U.d.ts} +390 -390
- package/dist/chunk-2KOQBV3Y.js +1 -0
- package/dist/chunk-2MTTK3BT.js +1 -0
- package/dist/chunk-3FPYCF7Z.js +1 -0
- package/dist/chunk-3VUPVXAV.js +1 -0
- package/dist/chunk-5RXU57I5.js +1 -0
- package/dist/chunk-6VY4PZZ6.js +1 -0
- package/dist/chunk-7CFF6SWH.js +1 -0
- package/dist/chunk-B5JHPPR4.js +10 -0
- package/dist/chunk-BZSKOOMM.js +1 -0
- package/dist/chunk-C6JRUYKW.js +1 -0
- package/dist/chunk-CILM5XMH.js +1 -0
- package/dist/chunk-CNIBGSVO.js +1 -0
- package/dist/chunk-CZ3H2X7D.js +1 -0
- package/dist/chunk-DCCM7FYR.js +1 -0
- package/dist/chunk-DCIGO3NJ.js +1 -0
- package/dist/chunk-DOJE7VUR.js +1 -0
- package/dist/{chunk-34I23EKZ.js → chunk-ECMWY3G2.js} +1 -1
- package/dist/chunk-G7NSECIG.js +1 -0
- package/dist/chunk-GIV4FOOW.js +1 -0
- package/dist/chunk-HMRIMJ5W.js +1 -0
- package/dist/chunk-JAKOBECD.js +1 -0
- package/dist/{chunk-O3LZPMS4.js → chunk-KRTX4QEH.js} +1 -1
- package/dist/chunk-LPDUK7HT.js +1 -0
- package/dist/chunk-MRFBMFNK.js +1 -0
- package/dist/chunk-MWDR5FEU.js +1 -0
- package/dist/chunk-MYUYN7ZG.js +1 -0
- package/dist/chunk-NMKZ724L.js +1 -0
- package/dist/chunk-O4KXODTJ.js +17 -0
- package/dist/chunk-ORPOCB2J.js +1 -0
- package/dist/chunk-PMCGTXGH.js +1 -0
- package/dist/{chunk-RKREEPCT.js → chunk-PWQ5BHBJ.js} +1 -1
- package/dist/chunk-SMIO7OG5.js +1 -0
- package/dist/chunk-T4GTAH43.js +1 -0
- package/dist/chunk-UBKD6VMS.js +1 -0
- package/dist/chunk-UHI7SPHK.js +1 -0
- package/dist/chunk-WM27UTWT.js +62 -0
- package/dist/chunk-WOT6VMZA.js +1 -0
- package/dist/{chunk-SJNF6JDJ.js → chunk-X7G7JMZ3.js} +1 -1
- package/dist/chunk-YSNMXK4R.js +1 -0
- package/dist/{configuration-sync-eEFj_oKG.d.ts → configuration-sync-DdTRUv7A.d.ts} +17 -17
- package/dist/content-UDP5VQS4.js +1 -0
- package/dist/funnel-host-purchase-5NLPYJRK.js +1 -0
- package/dist/{funnel-local-client-CSA9XoC4.d.ts → funnel-local-client-DoYVcZ1z.d.ts} +1696 -1696
- package/dist/funnel-node-evaluation-COxXtZEQ.d.ts +1003 -0
- package/dist/{funnel-process-client-RXgS2i-R.d.ts → funnel-process-client-DtXNiFQ-.d.ts} +1736 -1736
- package/dist/funnel-runtime-host-ZWUAGDBU.js +1 -0
- package/dist/index.d.ts +70 -69
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-N3Q4W6ZU.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +3 -3
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-VURXKAFX.js +1 -0
- package/dist/page.d.ts +12 -12
- package/dist/page.js +1 -1
- package/dist/paywall-QQ2MC4KO.js +1 -0
- package/dist/paywall-session-WC2WFWBQ.js +1 -0
- package/dist/popup.d.ts +4 -4
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +8 -8
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-G2EWN3WB.js +1 -0
- package/dist/server.d.ts +1752 -23
- package/dist/server.js +6 -1
- package/dist/visual-dom-5LUN4AHO.js +1 -0
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2KI63SPJ.js +0 -10
- package/dist/chunk-2ZJ5CS5Q.js +0 -1
- package/dist/chunk-5HJMAZ7A.js +0 -1
- package/dist/chunk-7AXCG6NU.js +0 -1
- package/dist/chunk-BB5P5HPS.js +0 -1
- package/dist/chunk-C2BODHNY.js +0 -1
- package/dist/chunk-EIYWDWXP.js +0 -1
- package/dist/chunk-LFFBNGXP.js +0 -1
- package/dist/chunk-MHEYMXGZ.js +0 -17
- package/dist/chunk-ML3BIPM6.js +0 -1
- package/dist/chunk-O4535GJR.js +0 -6
- package/dist/chunk-OEH47Y2L.js +0 -1
- package/dist/chunk-THGLNE4K.js +0 -1
- package/dist/chunk-TUYBXAAK.js +0 -1
- package/dist/chunk-ZX2RWS3T.js +0 -1
- package/dist/content-FD2Q6XD6.js +0 -1
- package/dist/funnel-host-purchase-XW7IF52Y.js +0 -1
- package/dist/funnel-node-evaluation-Cg-4tcAs.d.ts +0 -2731
- package/dist/funnel-runtime-host-I6PJXVRC.js +0 -1
- package/dist/paywall-CGBFHFRU.js +0 -1
- package/dist/screen-renderer-WOMWOEYL.js +0 -1
- package/dist/visual-dom-7IF7ITAK.js +0 -1
- package/dist/{coupon-DyKA-BRG.d.ts → coupon-kfkIVf9n.d.ts} +4 -4
- package/dist/{presentation-loading-D0A9G_kT.d.ts → presentation-loading-iSaRiDP2.d.ts} +3 -3
- package/dist/{screen-DRP7nsrQ.d.ts → screen-CGCJ46b1.d.ts} +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Ue,c as un}from"./chunk-JGG4R75K.js";import{d as sn,f as De,g as Ve,h as an,i as Me,k as ln}from"./chunk-CNIBGSVO.js";import{$ as _e}from"./chunk-PMCGTXGH.js";import{a as Le,e as en,f as nn,g as tn,h as rn,i as on}from"./chunk-PWQ5BHBJ.js";import{b as Xe}from"./chunk-HMRIMJ5W.js";import{R as Ye,qa as Ze}from"./chunk-5RXU57I5.js";import{a as I}from"./chunk-X7G7JMZ3.js";import{b as dn,e as pn}from"./chunk-SLUA7ABW.js";import{d as cn}from"./chunk-DCIGO3NJ.js";import{a as oe}from"./chunk-DSPLGTQI.js";import{b as Ke}from"./chunk-O4KXODTJ.js";var Ee=new WeakMap;function Dn(n){let v=n.view,m=v?.paywall?.resolution;if(!v||!["running","waiting"].includes(v.status)||v.stopped||!m||"document"in m||!n.resolvePaywall||n.identitySignal?.aborted)return;let e=JSON.stringify(m);if(Ee.get(n)?.key===e)return;let f=JSON.parse(e),P=n.identitySignal,r=Promise.resolve().then(async()=>{P?.throwIfAborted();let o=await n.resolvePaywall(f);return P?.throwIfAborted(),o}),R={key:e,content:r};return Ee.set(n,R),r.catch(()=>{}),()=>{Ee.get(n)===R&&Ee.delete(n)}}function fn(n,v){let m=Ee.get(n);return Ee.delete(n),m?.key===JSON.stringify(v)?m.content:n.resolvePaywall(v)}async function mn(n){let{session:v,load:m}=En(n);try{return await m(),v}catch(e){throw v.destroy(),e}}function En(n){let v=n.view;if(!v?.paywall)throw new I("INVALID_REQUEST","The current node is not a Paywall");let m=v.paywall.receiptId,e=v.nodeId,f=v.visit,P=v.paywall.resolution,r=v.paywall,R="document"in P?{document:P.document,offering:P.offering,capabilities:P.capabilities}:null;function o(){let i=r.resolution;return"document"in i?i:R&&{...i,document:R.document,offering:R.offering,capabilities:en(i.capabilities,R.capabilities)}}function y(i){if(!nn(i,P))throw new I("INVALID_RESPONSE","The pinned Paywall binding changed")}let d=!1,q=new Set,_=null;function T(){let i=o();if(i&&!d)for(let p of q)oe(p,structuredClone(i))}async function D(){U();let i=o();if(i)return structuredClone(i);if(!_){let p=(async()=>{if("document"in r.resolution||!n.resolvePaywall)throw new I("INVALID_RESPONSE","Public Paywall reader is unavailable");let b=await fn(n,r.resolution);return U(),y(b),R={document:b.document,offering:b.offering,capabilities:b.capabilities},T(),o()})();_=p;let a=()=>{_===p&&(_=null)};p.then(a,a)}return _.then(p=>structuredClone(p))}let c=new AbortController,O=(n.pendingCommands??(n.pendingCommand?[n.pendingCommand]:[])).find(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===f&&i.input.type==="paywall_quote")?.requestId??v.paywall.purchaseRequestId,G=0,M=null,F=new Set,j=null,w=new Map;function A(i){if(i.purchase&&i.purchase.receiptId!==m)throw new I("INVALID_RESPONSE","Purchase receipt changed");let p=i.run.paywall;return i.purchase??(p?.receiptId===m?p:null)}function U(){if(d)throw new I("IDENTITY_CHANGED","Paywall presentation has closed")}function X(i,p,a){if(U(),p!==G||a!==void 0&&r.quote?.operationId!==a)return!1;let b=r.selectionGeneration??0,u=i.run.paywall;if(u?.receiptId===m){if((u.selectionGeneration??0)<(r.selectionGeneration??0))return!1;y(u.resolution)}let h=A(i),Q=u?.receiptId===m&&(u.selectionGeneration??0)>b,J=Q?h?.quote??null:h?.quote??r.quote,K=h?.operation??(J?.operationId===r.quote?.operationId?r.operation:null);return J&&K&&tn(K,{operationId:J.operationId},"Purchase operation changed"),(Q||J?.operationId!==r.quote?.operationId)&&(G++,u?.receiptId===m&&(O=u.purchaseRequestId)),r={...r,...u?.receiptId===m?u:{},quote:J,operation:on(r.operation,K,!0)},T(),!0}function k(i,p,a){return new Promise((b,u)=>{let h=!1,Q=()=>{clearTimeout(ye),c.signal.removeEventListener("abort",W)},J=ae=>{h||(h=!0,Q(),b(ae))},K=ae=>{h||(h=!0,Q(),u(ae))},W=()=>K(new I("IDENTITY_CHANGED","Paywall presentation has closed")),ye=setTimeout(()=>K(new I("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a)),Math.max(0,p-Date.now()));c.signal.addEventListener("abort",W,{once:!0}),c.signal.aborted&&W(),i.then(J,K)})}function x(i){return new Promise(p=>{let a=()=>{clearTimeout(b),c.signal.removeEventListener("abort",a),p()},b=setTimeout(a,i);c.signal.addEventListener("abort",a,{once:!0}),c.signal.aborted&&a()})}function L(i,p){U();let a=w.get(i)??n.pendingCommands?.find(h=>h.requestId===i)??n.pendingCommand;if(a?.operation==="submit"&&a.requestId===i&&a.nodeId===e&&a.visit===f){p.type==="paywall_quote"&&a.input.type==="paywall_quote"&&a.input.predecessor&&!p.predecessor&&(p={...p,predecessor:a.input.predecessor});let h=_e.parse(a),Q=_e.parse({...a,input:p});if(h.operation!=="submit"||Q.operation!=="submit"||JSON.stringify(h.input)!==JSON.stringify(Q.input))throw new I("CONFLICT","A purchase request cannot change its input");return w.set(i,h),h}let b=n.view;if(!b||b.nodeId!==e||b.visit!==f||b.paywall?.receiptId!==m)throw new I("PRECONDITION_FAILED","The Paywall visit has changed");let u=_e.parse({operation:"submit",requestId:i,nodeId:e,visit:f,revision:b.revision,input:structuredClone(p)});if(u.operation!=="submit")throw new I("INVALID_REQUEST","A purchase submission is required");return w.set(i,u),u}async function se(i,p){U();let{requestId:a,input:b}=i,u=Date.now()+3e4;F.add(a);try{let h=await k(n.submit(i),u,a);for(;h.run.pendingRequest?.requestId===a&&Date.now()<u&&!d&&(await x(Math.min(1e3,u-Date.now())),!(d||Date.now()>=u));)h=await k(n.resume(a),u,a);if(d)throw new I("IDENTITY_CHANGED","Paywall presentation has closed");if(h.run.pendingRequest?.requestId===a)throw new I("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a);if(!X(h,p,b.type==="paywall_confirm"||b.type==="paywall_cancel"?b.operationId:void 0))throw new I("PRECONDITION_FAILED","The purchase selection has changed");j===a&&(j=null)}catch(h){throw j=a,h instanceof I&&h.code==="COMMAND_PENDING"&&h.status===void 0&&w.delete(a),h}finally{F.delete(a)}}async function C(i){if(!r.quote)throw new I("INVALID_REQUEST","A quoted purchase is required");let p=i==="confirm"?"paywall_confirm":"paywall_cancel",a=[...w.values(),...n.pendingCommands??(n.pendingCommand?[n.pendingCommand]:[])].find(u=>u.operation==="submit"&&u.input.type===p&&"operationId"in u.input&&u.input.operationId===r.quote.operationId),b=a?.operation==="submit"&&a.input.type===p&&"operationId"in a.input&&a.input.operationId===r.quote.operationId?a.requestId:crypto.randomUUID();if(await se(L(b,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:r.quote.operationId}),G),!r.operation)throw new I("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(r.operation)}let S={get view(){return structuredClone(o())},get quote(){return r.quote?structuredClone(r.quote):null},get operation(){return r.operation?structuredClone(r.operation):null},get webViewUrl(){return n.webViewUrl},get canReselect(){return r.canReselect===!0},get recovery(){let i=n.pendingCommands??(n.pendingCommand?[n.pendingCommand]:[]),p=n.pendingPurchase;if(p&&(p.receiptId!==m||p.operationId!==r.quote?.operationId))return{type:"recover",operationId:p.operationId,requestId:i[0]?.requestId??null};let a=Le({quote:r.quote,operation:r.operation,requestId:i[0]?.requestId??j??O,pending:F.size>0||i.length>0||j!==null,destroyed:d,canReselect:r.canReselect});return a.type==="recover"&&a.requestId===null&&!d&&n.hasDurableJournal===!0&&!r.quote&&!r.operation&&(r.selectionGeneration??0)===0&&!p&&!i.length&&!F.size&&!O?{type:"native",operationId:null}:a},get pendingCancellation(){return!d&&(n.pendingCommands??(n.pendingCommand?[n.pendingCommand]:[])).some(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===f&&i.input.type==="paywall_cancel"&&i.input.operationId===r.quote?.operationId)},subscribe(i){return d?()=>{}:(q.add(i),()=>q.delete(i))},async refresh(){U();let i=G,p=await n.get();if(X(p,i),p.run.paywall?.receiptId!==m)throw new I("PRECONDITION_FAILED","Paywall presentation has changed");return D()},preview(i){let p=o();if(!p)return Promise.reject(new I("PRECONDITION_FAILED","Load the Paywall presentation first"));if(O&&O!==i.requestId&&(M||r.canReselect!==!0))return Promise.reject(new I("COMMAND_PENDING","Retry the original purchase before starting another"));let a=p.document.buttons[i.actionId],b=a?.type==="checkout"?Xe(a.product,i.selection,p.capabilities):null;if(!b)return Promise.reject(new I("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let u=Ze(p.document.screen,b,i.selection,p.capabilities),h=O!==i.requestId&&(r.selectionGeneration??0)>0?{operationId:r.quote?.operationId??null,generation:r.selectionGeneration??0}:void 0;if(h&&r.canReselect!==!0)return Promise.reject(new I("COMMAND_PENDING","Original purchase requires authoritative termination"));let Q;try{Q=L(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:b,...Object.keys(u).length?{featureQuantities:u}:{},...h?{predecessor:h}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{}})}catch(W){return Promise.reject(W)}if(O===i.requestId&&M)return M;O!==i.requestId&&G++;let J=G;O=i.requestId;let K=(async()=>{if(await se(Q,J),!r.quote)throw new I("INVALID_RESPONSE","The accepted quote is missing");return rn(r.quote,{productVersionId:b,featureQuantities:u},"The selected purchase changed"),structuredClone(r.quote)})();return M=K,K.then(()=>{M===K&&(M=null)},W=>{M===K&&(M=null),O===i.requestId&&n.pendingCommand?.requestId!==i.requestId&&W instanceof I&&W.status!==void 0&&W.status<500&&![401,425].includes(W.status)&&(O=null)}),K},confirm:()=>C("confirm"),cancel:()=>C("cancel"),async read(){if(U(),!r.quote)throw new I("INVALID_REQUEST","A quoted purchase is required");let i=r.quote.operationId,p=G,a=n.pendingCommands?.find(J=>J.operation==="submit"&&(J.input.type==="paywall_confirm"||J.input.type==="paywall_cancel")&&J.input.operationId===i)??n.pendingCommand;a?.operation==="submit"&&(a.input.type==="paywall_confirm"||a.input.type==="paywall_cancel")&&a.input.operationId===i&&await n.settle?.(a.requestId);let b=await n.get(void 0,{receiptId:m,operationId:i});U();let u=A(b);if(u?.quote&&u.quote.operationId!==i||u?.operation&&u.operation.operationId!==i)throw new I("INVALID_RESPONSE","Purchase operation changed");let h=X(b,p,i),Q=h?r.operation:u?.operation;if(!Q)throw new I("INVALID_RESPONSE","The current purchase result is missing");return h&&F.size===0&&!(n.pendingCommands?.length??(n.pendingCommand?1:0))&&(j=null),structuredClone(Q)},destroy(){d=!0,ne(),q.clear(),c.abort(),w.clear()}},ne=n.subscribe(i=>{d||i.nodeId!==e||i.visit!==f||i.paywall?.receiptId!==m||(i.paywall.selectionGeneration??0)<(r.selectionGeneration??0)||(y(i.paywall.resolution),r={...r,resolution:i.paywall.resolution},T())});return{session:S,load:D}}function wn(n){let v=new Set,m=new Set,e=null;async function f(o,y){let d=!1;for(;!n.stopped&&n.key===o&&n.client.pendingCommand?.requestId===y;){if(!n.client.settle)throw new I("COMMAND_PENDING","The original display acknowledgement is still pending");await n.client.settle(y),d=!0,n.client.pendingCommand?.requestId===y&&await new Promise(q=>setTimeout(q,1500))}n.stopped||n.key!==o||(d&&await n.client.get(),!(n.stopped||n.key!==o)&&v.add(o))}function P(o,y){e=y;let d=()=>{e===y&&(e=null),m.delete(o)};return y.then(d,q=>{d(),n.busy||n.fail(q)}),y}function r(o){if(n.reviewing||v.has(o)||m.has(o)||n.stopped)return;m.add(o);let y=async()=>{if(n.reviewing||n.stopped||n.key!==o||v.has(o)){m.delete(o);return}if(n.busy||n.client.pendingCommand){setTimeout(()=>{y()},250);return}let d=(async()=>{if(n.staleRead){if(await n.staleRead,n.stopped||n.key!==o)return;if(n.client.pendingCommand){setTimeout(()=>{y()},250);return}}let q=n.client.view,_=n.expected(),T=_.requestId;try{await n.client.submit({operation:"shown",..._})}catch(D){if(!(D instanceof I)||D.code!=="CONFLICT"||D.status!==409||n.client.pendingCommand)throw D;await n.client.get();let c=n.client.view;if(n.stopped||n.reviewing||n.key!==o||!c||!q||c.id!==q.id||c.source.versionId!==q.source.versionId||c.nodeId!==_.nodeId||c.visit!==_.visit||c.revision<=_.revision||c.stopped||!c.screen&&(!c.paywall||c.paywall.receiptId!==q.paywall?.receiptId)||!["running","waiting"].includes(c.status)||n.client.pendingCommand)throw D;let N=n.expected();T=N.requestId,await n.client.submit({operation:"shown",...N})}await f(o,T)})();P(o,d)};y()}function R(){if(e)return e;let o=n.client.pendingCommand;if(o?.operation!=="shown")return null;let y=n.key;return m.add(y),P(y,(async()=>{await n.client.retry(),await f(y,o.requestId)})())}return{report:r,settled:R,get inFlight(){return e}}}function yn(n){let v={},m=new Map;async function e(f){let P=n.client.view,r=P?.screen,R=r?.customerData.nodes[f.nodeId];if(n.stopped||n.busy||!P||!r||!R)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(f.action)){let D=n.document,c=D?Ye(D,f.nodeId):null,N=c?.type==="customer_data"?c.data.outputs?.[f.action]:void 0;N&&r.outputs.includes(N)?await n.perform(()=>n.client.submit({operation:"submit",...n.expected(),input:{type:"screen",output:N,answers:n.answers,selection:f.value?{[f.nodeId]:f.value}:{}}})):await n.onIntent?.(f,P);return}let y=f.action.startsWith("sources_")?R.resources.find(D=>D.key===f.value):null;if(f.action.startsWith("sources_")&&!y)throw new I("INVALID_REQUEST","Choose a current resource");let d=`${P.visit}:${f.nodeId}:${y?.key??""}`,q=m.get(d)??[null],T=v[f.nodeId]??{page:1,after:null,filter:"all",...y?{resourceKey:y.key}:{}};if(f.action==="filter"){let D=f.value;if(!D||!(R.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(D))throw new I("INVALID_REQUEST","Unknown data filter");T={page:1,after:null,filter:D},q.splice(0,q.length,null)}else if(f.action==="next"||f.action==="sources_next"){let D=y?.sources.at(-1),c=y?D?{kind:"ledger",cursor:{at:D.detail[0],id:D.id,type:"source"}}:null:r.dataCursors[f.nodeId];if(!c||!y&&!R.hasNext)return;q[T.page]=c,T={...T,page:T.page+1,after:c}}else if(f.action==="previous"||f.action==="sources_previous"){if(T.page<=1)return;T={...T,page:T.page-1,after:q[T.page-2]??null}}m.set(d,q),v={...v,[f.nodeId]:T},await n.perform(()=>n.client.get({nodeId:P.nodeId,visit:P.visit,revision:P.revision,components:v}))}return{get queries(){return v},intent:e,reset(){v={},m.clear()}}}function gn(n){let{doc:v,holder:m,reviewHolder:e,mountScreenPreview:f}=n,P=!1,r,R=0,o=null,y="",d,q=new Map,_=c=>c?`${c.id}:${c.nodeId}:${c.visit}:${c.revision}:${c.paywall?.quote?.operationId??""}`:"";async function T(c){if(n.stopped||!n.client.review||P&&c===r&&d?.active)return;let N=!P||c!==r;P||(y=_(n.client.view),q.set(y,structuredClone(n.answers))),P=!0,r=c,m.hidden=!0,n.suspend(!0),e.hidden=!1;let O=++R;N&&(d?.finish("dismissed"),o?.destroy(),o=null,e.replaceChildren(),d=Ve(e,n.loadingOptions,"funnel",()=>{D()}));let G=N?d:void 0;try{if(G?.start(!1,n.client.view?.locale),O!==R||n.stopped)return;let M=n.client.review(c),F=await(G?.wait(M,De)??M);if(n.stopped||O!==R||!P)return;if(!F.review)throw new I("INVALID_RESPONSE","Historical projection is missing");o?.destroy(),o=null,G||e.replaceChildren();let j=v.createElement("div"),w=G?Me(j,e):()=>{};e.append(j);let A=F.run.locale.startsWith("zh"),U=v.createElement("p");U.textContent=A?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",j.append(U);for(let[k,x]of F.review.pages.entries()){let L=v.createElement("button");L.type="button",L.textContent=A?`\u7B2C ${k+1} \u9875`:`Page ${k+1}`,L.onclick=()=>{T(x.receiptId)},j.append(L)}if(F.review.page){let k=F.review.page,x=v.createElement("div");x.inert=!0,j.append(x),o=f(x,{mode:"live",rendererUrl:n.client.webViewUrl,title:k.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{O===R&&!n.stopped&&G?.present(w)},onError:se=>{if(O!==R||n.stopped)return;let C=new Error(se);G?.finish("error",C),o?.destroy(),o=null,j.remove(),n.fail(C)},onEscape:()=>{D()}});let L=o;if(L.update(k.document,F.run.locale,{serverInput:{bindings:k.inputs,answers:k.answers,values:k.values}}),await L.ready,n.stopped||O!==R||!P)return}let X=A?{issued:"\u5DF2\u9886\u53D6",reserved:"\u5DF2\u9884\u7559",redeemed:"\u5DF2\u4F7F\u7528",expired:"\u5DF2\u8FC7\u671F",revoked:"\u5DF2\u64A4\u9500",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"};for(let k of[...F.review.coupons.map((x,L)=>`${A?"\u4F18\u60E0\u5238":"Coupon"} ${L+1}: ${X[x.status]}`),...F.review.purchases.map((x,L)=>`${A?"\u8D2D\u4E70":"Purchase"} ${L+1}: ${un(x.status,A)}`)]){let x=v.createElement("p");x.textContent=k,j.append(x)}F.review.page||G?.present(w),n.client.view&&await n.enqueue(n.client.view)}catch(M){if(O!==R||n.stopped)return;G?.finish("error",M),o?.destroy(),o=null,e.replaceChildren(),n.fail(M)}}async function D(){if(!P||n.stopped||!n.client.review)return;let c=++R;d?.finish("dismissed");try{if(await n.client.review(),n.stopped||c!==R)return;P=!1,R++,d?.finish("dismissed"),o?.destroy(),o=null,e.replaceChildren(),e.hidden=!0,m.hidden=!1;let N=n.client.view;_(N)!==y?(q.set(y,structuredClone(n.answers)),n.resetScreen()):(q.delete(y),n.suspend(!1)),N&&await n.enqueue(N)}catch(N){if(c!==R||n.stopped)return;o?.destroy(),o=null,e.replaceChildren(),n.fail(N)}}return{get active(){return P},get receipt(){return r},open:T,exit:D,get drafts(){return new Map([...q].map(([c,N])=>[c,structuredClone(N)]))},stop(){P=!1,R++,d?.finish("dismissed"),o?.destroy(),o=null,e.replaceChildren(),e.hidden=!0,m.hidden=!1}}}function vn(n){if(!n.client.pageExperiments)throw new Error("The Run controller does not support page experiments");let v=n.client.pageExperiments.bind(n.client),m=!1,e=!1,f=0,P=!1,r=!1,R="",o=()=>{let w=n.client.view;return JSON.stringify([w?.id,w?.source.versionId,w?.visit,w?.revision,w?.status,w?.stopped])},y=new Map,d=new Set,q={},_=new Map,T=dn(n.appManifestRelease),D=()=>{for(let w of y.values())w.effect.revert();y.clear()},c=()=>{D();for(let w of _.values())w();_.clear()};function N(w){if(m||d.has(w))return;d.add(w);let A=f;v(n.appManifestRelease,[w]).catch(U=>{d.delete(w),!m&&A===f&&oe(n.onError,U)})}async function O(){if(m)return;R=o();let w=n.client.view;if(!w||w.stopped||!["running","waiting"].includes(w.status)){f++,c();return}if(document.visibilityState==="hidden")return;if(P){r=!0;return}P=!0;let A=++f,U=`${w.id}:${w.visit}:${w.revision}`,X=location.href;try{let[k,{applyVisualVariation:x}]=await Promise.all([v(n.appManifestRelease),import("./visual-dom-5LUN4AHO.js")]),L=n.client.view;if(m||A!==f||!L||L.stopped||!["running","waiting"].includes(L.status)||`${L.id}:${L.visit}:${L.revision}`!==U||location.href!==X)return;let se=new Set,C=new Set;for(let S of k.assignments){let ne=`${k.payload.environmentId}:${S.experimentKey}`;if(C.add(ne),_.has(ne)||_.set(ne,pn(ne,q)),!!S.inExperiment)for(let i of k.payload.experiments){if(i.key!==S.experimentKey||!Ke(location.href,i.urlPatterns??[]))continue;let p=i.meta?.findIndex(J=>J.key===S.variationKey)??-1,a=i.variations[p];if(!a?.renderGuard)continue;let b=S.receiptId+":"+i.changeId,u=JSON.stringify([S.variationKey,a]);se.add(b);let h=y.get(b);if(h?.signature===u){h.effect.applied&&N(S.receiptId);continue}y.get(b)?.effect.revert(),y.delete(b);let Q=x(a,{requireUniqueTargets:!0,boundVariations:i.variations,allowJs:!1,onApplied:()=>N(S.receiptId),onError:J=>oe(n.onError,J)});y.set(b,{signature:u,effect:Q}),Q.applied&&N(S.receiptId)}}for(let[S,ne]of y)se.has(S)||(ne.effect.revert(),y.delete(S));for(let[S,ne]of _)C.has(S)||(ne(),_.delete(S))}catch(k){A===f&&c(),!m&&A===f&&oe(n.onError,k)}finally{P=!1,r&&!m&&(r=!1,O())}}let G=n.client.subscribe(()=>{if(o()===R)return;R=o(),f++;let w=n.client.view;(!w||w.stopped||!["running","waiting"].includes(w.status))&&c(),e&&O()}),M=cn(()=>{f++,c(),e&&O()}),F=()=>{f++,D()};document.addEventListener("visibilitychange",F);let j=Ue({document,run:async()=>{e&&await O()},delay:()=>e&&!m?15e3:void 0});return{async start(){e||m||(e=!0,await j.refresh())},refresh:O,destroy(){m=!0,f++,j.destroy(),document.removeEventListener("visibilitychange",F),G(),M(),c(),T.destroy()}}}var ze=5e3;async function qn(n,v,m){let e=v,[{mountScreenPreview:f},{showPaywall:P}]=await Promise.all([import("./screen-renderer-G2EWN3WB.js"),import("./paywall-QQ2MC4KO.js")]),r=e.client.identitySignal;e.signal?.throwIfAborted(),r?.throwIfAborted();let R=e.appManifestRelease?vn({client:e.client,appManifestRelease:e.appManifestRelease,onError:e.onError}):void 0;R?.start();let o=n.ownerDocument,y=ln(o),d=o.createElement("section"),q=o.createElement("div"),_=o.createElement("div"),T=o.createElement("div"),D=o.createElement("button");T.hidden=!0,D.type="button";let c=o.createElement("p"),N=o.createElement("p"),O=o.createElement("button"),G=o.createElement("button"),M=o.createElement("button"),F=o.createElement("dialog"),j;d.dataset.indianaFunnel="",d.setAttribute("aria-busy","false"),d.style.cssText="box-sizing:border-box;width:100%;min-width:0;font:14px/1.5 system-ui,sans-serif;color:#172033;background:#fff",_.style.cssText="display:flex;gap:12px;align-items:center;flex-wrap:wrap;padding:12px 20px",c.setAttribute("role","status"),N.setAttribute("role","alert"),N.hidden=!0,O.type=G.type=M.type="button",_.append(O,c,N,M,D,G),d.append(q,T,_),n.append(d);let w=null,A=null,U=null,X="",k="",x="",L="",se="",C=!1,S=0,ne=!1,i="",p=null,a=Promise.resolve(),b=!e.client.view,u=m,h,Q,J="",K,W=!1,ye=null,ae=!1,Fe=()=>e.client.pendingCommand?.operation==="close",re=null,B=null,je=Ue({document:o,run:async()=>{(!A?.observing||e.client.pendingCommand)&&await He()},delay:()=>{if(!(C||!U||!["running","waiting"].includes(U.status)&&!e.client.pendingCommand)&&!(A?.observing&&!e.client.pendingCommand))return U.pendingRequest||e.client.pendingCommand?1500:ze},hiddenDelay:()=>!C&&e.client.pendingCommand?15e3:void 0}),Y=null;function $e(){return B&&e.client.hasDurableJournal===!0&&Y?.acknowledged===!0&&Y.operationId===B.operationId&&e.client.view?.id===Y.runId&&e.client.view?.status==="closed"&&e.client.view.revision===Y.revision+1&&!(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0))&&!e.client.pendingPurchase?B:null}function xe(t){let s=t.run.paywall;if(Y&&t.settlement?.requestId===Y.requestId&&t.settlement.state==="settled"&&t.settlement.operationId===null&&t.run.id===Y.runId&&t.run.status==="closed"&&!t.run.pendingRequest&&t.run.revision===Y.revision+1&&t.run.nodeId===Y.nodeId&&t.run.visit===Y.visit&&s?.receiptId===Y.receiptId&&s.selectionGeneration===Y.selectionGeneration&&(s.quote?.operationId??null)===Y.operationId&&(s.operation?.operationId??s.quote?.operationId??null)===Y.operationId){let l=Y.operationId===null&&s.selectionGeneration===0&&!s.quote&&!s.operation&&!s.purchaseRequestId,te=Le({quote:s.quote,operation:s.operation,requestId:s.purchaseRequestId,pending:!1,destroyed:!1,canReselect:s.canReselect});(l||s.canReselect===!0&&te.type==="native")&&(Y.acknowledged=!0)}}let Ce=null,ke=new Set,pe={},le=(t,s=null)=>{C||(Ce=s,N.textContent=t instanceof Error?t.message:"Request failed",N.hidden=!1,M.hidden=e.client.pendingCommand===null,oe(e.onError,t))};function he(){let t=e.client.view;if(!t)throw new I("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision}}let V=gn({client:e.client,doc:o,holder:q,reviewHolder:T,mountScreenPreview:f,loadingOptions:e,get stopped(){return C},get answers(){return pe},suspend(t){A?.setSuspended(t)},resetScreen(){X="",k="",x=""},enqueue:fe,fail:le}),Se=wn({client:e.client,expected:he,fail:le,get stopped(){return C},get reviewing(){return V.active},get key(){return X},get busy(){return S},get staleRead(){return p}}),Ne=yn({client:e.client,expected:he,perform:Re,onIntent:e.onCustomerDataIntent,get stopped(){return C},get busy(){return S},get document(){return w?.document},get answers(){return pe}}),Oe=t=>`${t.id}:${t.nodeId}:${t.visit}`,Pe=t=>t&&(t.screen||t.paywall)?Oe(t):"";function Ie(){let t=e.client.view;O.disabled=!V.active&&(S>0||!!e.client.pendingCommand||!t?.canBack||t.stopped||!["running","waiting"].includes(t.status)||!Pe(t)||k!==Pe(t))}async function We(t){if(!t)return;let s=e.client.view;await t;let l=e.client.view;if(!s||!l||l.id!==s.id||l.nodeId!==s.nodeId||l.visit!==s.visit||l.stopped||!["running","waiting"].includes(l.status))throw new I("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function Re(t,s=!1){if(!((S||ae||re||B)&&!s||C||V.active&&!s)){S++,d.setAttribute("aria-busy","true"),Ie(),N.hidden=!0,Ce=null;try{if(s||await We(Se.inFlight),C)return;let l=await t();C||await fe(e.client.view??l.run)}catch(l){le(l,e.client.pendingCommand?.requestId??null)}finally{S=Math.max(0,S-1),d.setAttribute("aria-busy",String(S>0)),C||(M.hidden=e.client.pendingCommand===null,Ie())}}}function qe(){je.schedule()}async function He(){if(!(C||ne||S)){if(V.active){await V.open(V.receipt);return}ne=!0;try{let t=e.client.pendingCommand;t&&e.client.settle&&await e.client.settle(t.requestId);let s=e.client.view,l=Ne.queries,te=await e.client.get(s?.screen&&Object.keys(l).length?{nodeId:s.nodeId,visit:s.visit,revision:s.revision,components:l}:void 0);!C&&l===Ne.queries&&await fe(e.client.view??te.run)}catch(t){le(t)}finally{ne=!1}}}function Ae(t,s){if(u?.active){let te=u;return te.setDismissHandler(()=>Be(te)),te}let l=Ve(n,e,"funnel",()=>Be(l));return u=l,l.start(t,s),l}function Be(t){C||W||(W=!0,t.finish("dismissed"),ge(),d.hidden=!0,e.client.view?be().finally(ue):ue())}function Ge(){clearTimeout(K?.timeout),K=void 0}function ge(){Ge(),h?.abort(),h=void 0,w?.destroy(),w=null,A?.destroy(),A=null,Q?.(),Q=void 0,F.open&&F.close(),q.replaceChildren(),X="",k="",x="",se=""}function Qe(t){let s=t.screen?.presentation;if(!s||s.type==="inline"){F.open&&F.close(),d.parentElement!==n&&n.append(d);return}d.parentElement!==F&&(F.append(d),n.append(F));let l={sm:420,md:640,lg:900};F.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in s?l[s.size]+"px":"100vw"}`,F.setAttribute("aria-label",(j?.screen===t.screen?.content.document.name?j?.label:void 0)??w?.document?.name??t.screen?.content.document.name??"Funnel")}async function hn(t){if(C||W||ae&&(Fe()||["running","waiting"].includes(t.status)))return;U=t,Ce&&e.client.pendingCommand?.requestId!==Ce&&(N.hidden=!0,Ce=null);let s=t.locale.startsWith("zh");if(D.textContent=s?"\u56DE\u770B":"History",D.hidden=!e.client.review,O.textContent=V.active?s?"\u8FD4\u56DE\u5F53\u524D":"Return to current":s?"\u8FD4\u56DE":"Back",G.textContent=s?"\u5173\u95ED":"Close",M.textContent=s?"\u91CD\u8BD5":"Retry",Ie(),M.hidden=e.client.pendingCommand===null,c.textContent=t.pendingRequest?s?"\u6B63\u5728\u5904\u7406":"Processing":t.instruction?.type==="wait"?s?"\u7B49\u5F85\u4E2D":"Waiting":"",i!==`${t.revision}:${t.visit}:${t.status}:${t.stopped}`&&(i=`${t.revision}:${t.visit}:${t.status}:${t.stopped}`,oe(e.onState,structuredClone(t))),C||W)return;if((!t.pendingRequest||ae&&t.status==="closed")&&["closed","ineligible","failed"].includes(t.status)){ue();return}if(t.stopped||e.client.configurationReady===!1){V.stop(),ge(),u?.finish("skipped"),d.hidden=!0,qe();return}if(d.hidden=!1,V.active){qe();return}let l=Pe(t),te=e.client.view;if(te&&te.revision>t.revision&&Pe(te)!==l)return;let Je=!t.instruction&&!t.pendingRequest&&t.nodeType==="screen"&&["running","waiting"].includes(t.status);l!==X&&(X&&u?.finish("dismissed"),ge(),X=l,pe={...t.answers},Ne.reset());let me=Oe(t);if(J===me){d.hidden=!0;return}if(Je&&!l){d.hidden=!0;let E=Ae(!0,t.locale);!C&&!W&&K?.key!==me&&(Ge(),K={key:me,timeout:setTimeout(()=>{let g=e.client.view;if(!E.active||!g||Oe(g)!==me)return;J=me;let ee=new Error("Funnel screen preparation timed out");E.finish("error",ee),ge(),le(ee)},De)}),qe();return}Ge();let ie=E=>{let g=e.client.view;return!C&&!W&&!ye&&!E.aborted&&e.client.configurationReady!==!1&&!!g&&!g.stopped&&!["closed","ineligible","failed"].includes(g.status)&&Pe(g)===l},Z=(E,g)=>{ie(g)&&(J=l,u?.finish("error",E),ge(),d.hidden=!0,le(E))};if(l||(Qe(t),t.instruction?.type!=="event"&&t.instruction?.type!=="open_url"&&u?.finish("skipped")),t.screen){let E=t.screen.content;if(!w){let z=t.screen.presentation.type!=="inline",we=Ae(z,t.locale);if(C||W)return;let de=(h=new AbortController).signal;Qe(t),Q=z?an(F):Me(d,n),w=f(q,{mode:"live",rendererUrl:e.client.webViewUrl,title:E.document.name,onAction(ce,ve={},Pn={}){if(V.active||!ie(de)||k!==l)return;pe={...pe,...Pn};let Rn=Object.fromEntries((t.screen?.inputs??[]).filter(({variable:Te})=>Object.hasOwn(pe,Te)).map(({variable:Te})=>[Te,pe[Te]]));Re(()=>e.client.submit({operation:"submit",...he(),input:{type:"screen",output:ce,answers:Rn,selection:ve}}))},onAnswers:ce=>{V.active||!ie(de)||k!==l||(pe={...pe,...ce})},onCustomerDataIntent:ce=>{V.active||!ie(de)||k!==l||Ne.intent(ce).catch(le)},onEscape:()=>{!ie(de)||k!==l||V.active||re||B||be()},onError:ce=>{let ve=new Error(ce);k===l?le(ve):Z(ve,de)},onRendered:ce=>{if(!(!ie(de)||k===l))try{we.present(ve=>{Q?.(),Q=void 0,ce&&(j={screen:E.document.name,label:ce},F.setAttribute("aria-label",ce)),z&&(F.showModal(),!ve&&e.loading!=="host"&&sn(F,t.screen.presentation.type)),k=l,Ie()}),ie(de)&&Se.report(l)}catch(ve){Z(ve,de)}}})}let g={capabilities:t.screen.capabilities,customerData:t.screen.customerData,parameters:t.parameters,serverInput:{bindings:t.screen.inputs,answers:pe,values:t.screen.values}},ee=JSON.stringify([E,t.locale,g.parameters,t.screen.inputs,t.screen.values]);if(ee!==x)w.update(E.document,t.locale,g),x=ee,L=JSON.stringify(g.capabilities),se=JSON.stringify(g.customerData);else{let z=JSON.stringify(g.capabilities);z!==L&&(w.updateCapabilities(g.capabilities),L=z),JSON.stringify(g.customerData)!==se&&(w.updateCustomerData(g.customerData),se=JSON.stringify(g.customerData))}let H=w;if(H)try{await(u?.wait(H.ready)??H.ready)}catch(z){h&&Z(z,h.signal)}}else if(t.paywall&&!A){let E=Ae(!0,t.locale);if(C||W)return;let g=(h=new AbortController).signal;Qe(t);let ee=await P(q,{loading:"host",signal:g,canInteract:()=>ie(g)&&!V.active&&!re&&!B,beforeAction:async()=>{S++;try{await We(Se.settled()),N.hidden=!0,Ce=null}finally{S=Math.max(0,S-1)}},start:()=>mn(e.client),onObservationChange:qe,onPurchase:e.onPurchase,onCheckoutUrl:e.onCheckoutUrl,checkoutNavigation:e.checkoutNavigation,resolveOfferId:e.resolveOfferId,onEvent:e.onEvent,onOpenUrl:H=>e.onOpenUrl?e.onOpenUrl({receiptId:t.paywall.receiptId,url:H,openIn:"same_window"}):o.defaultView?.location.assign(H),onAction:async H=>{if(V.active)return;let z=await e.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:e.client.view?.revision??t.revision,input:{type:"screen",output:H,answers:{}}});await fe(e.client.view??z.run)},onError:H=>{k===l?le(H):Z(H,g)}},{quoteError:H=>oe(e.onError,H),present(H){ie(g)&&(E.present(()=>{H(),k=l,Ie()}),ie(g)&&Se.report(l))},async dismiss(){C||g.aborted||V.active||re||B||!ae&&!ie(g)||(ae=!0,await be())}}).catch(H=>(Z(H,g),null));!ie(g)&&!(ae&&!C&&!g.aborted)?ee?.host?.destroy():ee&&(A=ee.host,A?.setSuspended(V.active))}if(C||W)return;Ie();let $=t.instruction;if($&&($.type==="open_url"||$.type==="event")&&!ke.has($.receiptId)){let E=o.createElement("button");E.type="button",E.textContent=$.type==="open_url"?`${s?"\u524D\u5F80":"Continue to"} ${new URL($.url).host}`:s?"\u7EE7\u7EED":"Continue",E.onclick=()=>{let g=he(),ee=$.type==="open_url"&&!e.onOpenUrl&&$.openIn==="new_window"?In($.url):null;Re(async()=>{let H="success";if($.type==="open_url")if(e.onOpenUrl)try{H=await e.onOpenUrl({receiptId:$.receiptId,url:$.url,openIn:$.openIn})===!1?"failed":"opened"}catch(we){oe(e.onError,we),H="failed"}else H=$.openIn==="new_window"&&!ee?"failed":"opened";if($.type==="event"){if(!e.onEvent)throw new I("EVENT_HANDLER_REQUIRED","Provide the event handler");await e.onEvent($.event)}if(C||e.client.view?.nodeId!==g.nodeId||e.client.view.visit!==g.visit)throw new I("PRECONDITION_FAILED","The client action visit changed");let z=await e.client.submit({operation:"submit",...g,input:{type:"client_action",receiptId:$.receiptId,outcome:H}});return ke.add($.receiptId),$.type==="open_url"&&!e.onOpenUrl&&$.openIn==="same_window"&&o.defaultView?.location.assign($.url),z})},u?.active?u.present(()=>q.replaceChildren(E)):q.replaceChildren(E)}!t.pendingRequest&&t.status==="completed"&&!ke.has(`complete:${t.id}`)&&(ke.add(`complete:${t.id}`),oe(e.onComplete,structuredClone(t))),qe()}function In(t){let s=o.defaultView?.open(t,"_blank")??null;return s&&(s.opener=null),s}function fe(t){return Ie(),a=a.catch(()=>{}).then(async()=>{try{await hn(t)}catch(s){throw u?.active&&(J=Oe(t),u.finish("error",s),ge(),d.hidden=!0),s}}),a}let bn=e.client.subscribe(t=>{b||(!ae&&(t.stopped||e.client.configurationReady===!1||X&&k!==X&&(Pe(t)!==X||["closed","ineligible","failed"].includes(t.status)))&&(ge(),u?.finish("dismissed"),d.hidden=!0),fe(t).catch(le))}),Cn=e.client.subscribeError?.(le);function be(t){if(ye)return ye;if(C||!t&&(re||B))return Promise.resolve();let s=!t&&Fe();return!s&&e.client.view&&!["running","waiting"].includes(e.client.view.status)?(U=e.client.view,ue(),Promise.resolve()):(ye=Re(async()=>{let l=s?await e.client.retry():await e.client.submit({operation:"close",...t??he()});return t&&xe(l),l},!0).then(()=>{let l=e.client.view;l?.status==="closed"&&!Fe()&&(U=l,ue())}).finally(()=>{ye=null}),ye)}function ue(){R?.destroy(),!C&&(C=!0,e.signal?.removeEventListener("abort",ue),r?.removeEventListener("abort",ue),u?.finish("dismissed"),je.destroy(),bn(),Cn?.(),ge(),V.stop(),F.remove(),d.remove(),y(),oe(e.onDismiss,U?structuredClone(U):null))}O.onclick=()=>{if(!O.disabled){if(V.active){V.exit();return}Re(()=>e.client.submit({operation:"back",...he()}))}},D.onclick=()=>{V.open()},G.onclick=()=>{u?.active?u.dismiss():re||be()},M.onclick=()=>{Fe()?be():Re(()=>e.client.retry())},F.addEventListener("cancel",t=>{t.preventDefault(),u?.active?u.dismiss():re||be()}),e.signal?.addEventListener("abort",ue,{once:!0}),r?.addEventListener("abort",ue,{once:!0});try{let t=e.client.view;if(t)((e.client.viewAgeMs??ze)>=ze||t.instruction?.type==="evaluate_segment")&&(p=He().finally(()=>{p=null})),await fe(t);else{d.hidden=!0;let s=Ae(e.client.view?.screen?.presentation.type!=="inline",e.client.view?.locale);if(C||W)throw new DOMException("Presentation cancelled","AbortError");let l=await s.wait(e.client.get(),De);b=!1,await fe(e.client.view??l.run)}}catch(t){throw u?.finish("error",t),ue(),t}return{destroy:ue,refresh:He,get recovery(){let t=$e();if(t)return t;if(!C&&!S&&!ae&&!re&&A){let s=A.recovery;if(s.type!=="native")return s}return{type:"recover",operationId:e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??B?.operationId??null,requestId:e.client.pendingCommand?.requestId??null}},prepareFallback(){if(re)return re;let t=$e();if(t)return Promise.resolve(t);let s=e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??B?.operationId??null,l=()=>({type:"recover",operationId:s,requestId:e.client.pendingCommand?.requestId??null});if(e.client.hasDurableJournal!==!0){let Z=A?.recovery;return Promise.resolve(Z&&Z.type!=="native"&&Z.type!=="cancel"?Z:l())}let te=(e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[])).some(Z=>Z.operation==="close");if(C&&!(te||B&&e.client.view?.status==="closed")||S||ne||ye||V.active||!A&&!B&&!te)return Promise.resolve(l());let Je=A,me=(async()=>{try{if(!B&&te){let E=await e.client.retry();return await fe(e.client.view??E.run),l()}if(!B){let E=await Je.prepareFallback();if(E.type!=="native")return E;if(e.client.hasDurableJournal!==!0)return l();B=E}let Z=e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[]);if(Z.length){let E=Z.find(ee=>ee.operation==="close");if(!E||!Y||E.requestId!==Y.requestId)return l();let g=await e.client.retry();xe(g),await fe(e.client.view??g.run)}else{let E=e.client.view,g=E?.paywall;if(!E||!g||g.selectionGeneration===void 0||(g.quote?.operationId??null)!==B.operationId||B.operationId!==null&&g.canReselect!==!0)return l();let ee=g.selectionGeneration,H=await e.client.get();await fe(e.client.view??H.run);let z=e.client.view,we=z?.paywall;if(!z||!we||!["running","waiting"].includes(z.status)||z.stopped||z.id!==E.id||z.nodeId!==E.nodeId||z.visit!==E.visit||we.receiptId!==g.receiptId||we.selectionGeneration!==ee||(we.quote?.operationId??null)!==B.operationId||B.operationId!==null&&we.canReselect!==!0||e.client.pendingPurchase||(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0)))return l();let de=he();Y={runId:z.id,operationId:B.operationId,revision:de.revision,requestId:de.requestId,nodeId:z.nodeId,visit:z.visit,receiptId:we.receiptId,selectionGeneration:ee,acknowledged:!1},await be(de)}let $=$e();return $?(ue(),$):l()}catch(Z){return le(Z),l()}})();re=me;let ie=()=>{re===me&&(re=null)};return me.then(ie,ie),me},review:V.open,exitReview:V.exit,get unappliedDrafts(){return V.drafts}}}function mt(n,v,m){return qn(n,v,m)}export{Dn as a,vn as b,qn as c,mt as d};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { S as StackNode } from './screen-
|
|
2
|
+
import { S as StackNode } from './screen-CGCJ46b1.js';
|
|
3
3
|
|
|
4
4
|
declare const configurationScopeSchema: z.ZodObject<{
|
|
5
5
|
projectId: z.ZodString;
|
|
@@ -342,32 +342,32 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
342
342
|
urlRedirect: string;
|
|
343
343
|
}[];
|
|
344
344
|
name?: string | undefined;
|
|
345
|
-
|
|
346
|
-
filters?: {
|
|
347
|
-
seed: string;
|
|
348
|
-
hashVersion: 2;
|
|
349
|
-
ranges: [number, number][];
|
|
350
|
-
attribute?: string | undefined;
|
|
351
|
-
}[] | undefined;
|
|
345
|
+
coverage?: number | undefined;
|
|
352
346
|
condition?: Record<string, z.core.util.JSONType> | undefined;
|
|
353
|
-
force?: number | undefined;
|
|
354
|
-
hashAttribute?: string | undefined;
|
|
355
347
|
seed?: string | undefined;
|
|
356
348
|
hashVersion?: 2 | undefined;
|
|
357
349
|
ranges?: [number, number][] | undefined;
|
|
350
|
+
force?: number | undefined;
|
|
358
351
|
urlPatterns?: {
|
|
359
352
|
include: boolean;
|
|
360
353
|
type: "regex" | "simple";
|
|
361
354
|
pattern: string;
|
|
362
355
|
}[] | undefined;
|
|
363
356
|
persistQueryString?: boolean | undefined;
|
|
357
|
+
hashAttribute?: string | undefined;
|
|
358
|
+
phase?: string | undefined;
|
|
359
|
+
filters?: {
|
|
360
|
+
seed: string;
|
|
361
|
+
hashVersion: 2;
|
|
362
|
+
ranges: [number, number][];
|
|
363
|
+
attribute?: string | undefined;
|
|
364
|
+
}[] | undefined;
|
|
364
365
|
parentConditions?: {
|
|
365
366
|
id: string;
|
|
366
367
|
condition: Record<string, z.core.util.JSONType>;
|
|
367
368
|
gate?: boolean | undefined;
|
|
368
369
|
}[] | undefined;
|
|
369
370
|
weights?: number[] | undefined;
|
|
370
|
-
coverage?: number | undefined;
|
|
371
371
|
fallbackAttribute?: string | undefined;
|
|
372
372
|
disableStickyBucketing?: boolean | undefined;
|
|
373
373
|
bucketVersion?: number | undefined;
|
|
@@ -700,7 +700,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
700
700
|
} | undefined;
|
|
701
701
|
} | {
|
|
702
702
|
type: "end";
|
|
703
|
-
outcome: "
|
|
703
|
+
outcome: "completed" | "failed" | "closed" | "ineligible";
|
|
704
704
|
id: string;
|
|
705
705
|
name: string;
|
|
706
706
|
output?: {
|
|
@@ -860,18 +860,18 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
860
860
|
couponDigests: Record<string, string>;
|
|
861
861
|
variables: Record<string, Record<string, Partial<Record<"offer.headline" | "offer.name" | "offer.description" | "offer.eligibility" | "offer.validity" | "offer.terms" | "offer.discount" | "offer.months" | "offer.ends_at", string>>>>;
|
|
862
862
|
locales: Record<string, {
|
|
863
|
+
plans: Record<string, never>;
|
|
863
864
|
nodes: Record<string, {
|
|
864
865
|
base: {
|
|
865
866
|
text?: string | undefined;
|
|
866
867
|
label?: string | undefined;
|
|
867
868
|
couponId?: string | undefined;
|
|
868
|
-
alt?: string | undefined;
|
|
869
869
|
html?: string | undefined;
|
|
870
|
+
alt?: string | undefined;
|
|
870
871
|
countdownAt?: string | undefined;
|
|
871
872
|
missing?: string[] | undefined;
|
|
872
873
|
};
|
|
873
874
|
}>;
|
|
874
|
-
plans: Record<string, never>;
|
|
875
875
|
pickers: Record<string, never>;
|
|
876
876
|
diagnostics: {
|
|
877
877
|
nodeId: string;
|
|
@@ -1475,7 +1475,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
1475
1475
|
} | {
|
|
1476
1476
|
type: "merchandise";
|
|
1477
1477
|
scope: {
|
|
1478
|
-
type: "selected" | "
|
|
1478
|
+
type: "selected" | "condition" | "all";
|
|
1479
1479
|
};
|
|
1480
1480
|
};
|
|
1481
1481
|
displayCopy: {
|
|
@@ -1737,7 +1737,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
1737
1737
|
entry: string;
|
|
1738
1738
|
nodes: {
|
|
1739
1739
|
id: string;
|
|
1740
|
-
type: "output" | "action" | "screen" | "end" | "coupon" | "
|
|
1740
|
+
type: "output" | "action" | "screen" | "end" | "coupon" | "condition" | "feature" | "split" | "coupons" | "offering" | "entry" | "external_page" | "wait";
|
|
1741
1741
|
outputs: Record<string, string>;
|
|
1742
1742
|
writes: Record<string, string>;
|
|
1743
1743
|
resources: {
|
|
@@ -1782,7 +1782,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
1782
1782
|
} | undefined;
|
|
1783
1783
|
};
|
|
1784
1784
|
terminals: Record<string, {
|
|
1785
|
-
outcome: "
|
|
1785
|
+
outcome: "completed" | "failed" | "closed" | "ineligible";
|
|
1786
1786
|
output: {
|
|
1787
1787
|
type: "literal";
|
|
1788
1788
|
value: z.core.util.JSONType;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as ie}from"./chunk-B5JHPPR4.js";import{a as Z,c as ee,d as te,e as ne,g as re,h as oe,i as se,k as N}from"./chunk-CNIBGSVO.js";import{b as X}from"./chunk-2KOQBV3Y.js";import{r as V}from"./chunk-MYUYN7ZG.js";import"./chunk-PMCGTXGH.js";import"./chunk-7CFF6SWH.js";import"./chunk-HMRIMJ5W.js";import"./chunk-MWDR5FEU.js";import"./chunk-UBKD6VMS.js";import{E as $,P as G,U as R,la as Y,ma as K}from"./chunk-5RXU57I5.js";import"./chunk-DOJE7VUR.js";import{a as p}from"./chunk-X7G7JMZ3.js";import"./chunk-JAKOBECD.js";import"./chunk-SMIO7OG5.js";import{b as u}from"./chunk-WM27UTWT.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.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="\xD7",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),ne(e,r.screen.theme),e.addEventListener("click",v),n.prepend(e)}n&&a?.responsive&&(_=Z(n,v,k,t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),n.addEventListener("click",e=>{if(e.target!==n)return;let o=n.getBoundingClientRect();(e.clientX<o.left||e.clientX>o.right||e.clientY<o.top||e.clientY>o.bottom)&&v()})),n?.addEventListener("cancel",e=>{e.preventDefault(),v()}),n?.addEventListener("keydown",e=>{e.key==="Escape"&&(e.preventDefault(),v())});async function F(){if(i||!E||A||!g)return;let e=g;A=!0,c.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),g=null}catch(o){i||h(t.onError,o)}finally{A=!1,i||c.removeAttribute("aria-busy")}}function J(){if(i)throw new p("CONFLICT","Content host has been destroyed");E||!S||(P??=N(d),D.present(e=>{de(),n&&(a?.latch(),n.showModal(),a?.responsive&&n.focus({preventScroll:!0}),!e&&t.loading!=="host"&&te(n,a?.type??r.screen.presentation.type,a?.responsive)),E=!0}))}function U(e){D.finish("error",e),H(e instanceof Error?e:new Error(String(e))),b()}let Q={destroy:b,show:J,get pendingAction(){return g?structuredClone(g):null},retryAction:F,updateInputs(e){if(i)throw new p("CONFLICT","Content host has been destroyed");let o=u.record(u.string(),R).parse(e),C=ae({...y,...o},r.contract);for(let l of Object.keys(o))if(!T.has(l)&&(!Object.hasOwn(y,l)||V(y[l])!==V(C[l])))throw new p("PRECONDITION_FAILED","This content input is frozen; prepare a new presentation");V(y)!==V(C)&&(w?.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:C}}),y=C)},updateCapabilities(e){if(i)return;let o=structuredClone(e);w?.updateCapabilities(o),j=o}};z.set(s,Q),t.signal?.addEventListener("abort",b,{once:!0});try{if(t.signal?.throwIfAborted(),f||(P=N(d),D.start(x,t.locale??r.screen.strings.defaultLocale),i&&await L),w=ie(c,{mode:"live",rendererUrl:t.rendererUrl,title:r.name,viewportHeight:r.kind==="page"?ue:a?.responsive?d.defaultView?.innerHeight||800:void 0,...a?.responsive?{viewportWidth:d.defaultView?.innerWidth||1024,hostPresentation:()=>a.type}:{},onResize:e=>{i||a?.responsive&&(c.style.height=`${e}px`,c.style.overflow="clip",a.setContentHeight(e))},onRendered:e=>{if(!i&&(e&&n?.setAttribute("aria-label",e),!S))try{S=!0,f||J(),q()}catch(o){U(o),h(t.onError,o)}},onError:e=>{if(i)return;let o=new Error(e);S||U(o),h(t.onError,o)},onEscape:x?v:void 0,onAction:(e,o,C)=>{if(i||!E||A||g)return;let l=r.screen.actions.find(O=>O.id===e),B=r.contract.outputs[e];if(!(l?.type!=="event"||!B)&&!(l.close&&!k()))try{let O=ce(B).parse(Object.hasOwn(l.properties,"value")?l.properties.value:l.properties);g=structuredClone({requestId:crypto.randomUUID(),contentVersionId:m.id,actionId:e,event:l.event,value:O,selection:o??{},answers:C??{},requestedClose:l.close}),F()}catch(O){h(t.onError,O)}}}),w.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:y}}),await Promise.race([w.ready,L]),f&&await L,i)throw new Error("Content preparation cancelled");return Q}catch(e){throw U(e),e}}export{Ae as mountContent,Se as prepareContent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as y}from"./chunk-DCCM7FYR.js";import{d as A}from"./chunk-YSNMXK4R.js";import"./chunk-JGG4R75K.js";import{f as g,g as I}from"./chunk-CNIBGSVO.js";import"./chunk-3FPYCF7Z.js";import"./chunk-ECMWY3G2.js";import"./chunk-UHI7SPHK.js";import"./chunk-G7NSECIG.js";import"./chunk-GIV4FOOW.js";import"./chunk-MYUYN7ZG.js";import"./chunk-C6JRUYKW.js";import"./chunk-PMCGTXGH.js";import"./chunk-7CFF6SWH.js";import"./chunk-PWQ5BHBJ.js";import"./chunk-HMRIMJ5W.js";import"./chunk-MWDR5FEU.js";import"./chunk-UBKD6VMS.js";import"./chunk-5RXU57I5.js";import"./chunk-DOJE7VUR.js";import{a as c}from"./chunk-X7G7JMZ3.js";import"./chunk-JAKOBECD.js";import"./chunk-SLUA7ABW.js";import"./chunk-DCIGO3NJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-SMIO7OG5.js";import"./chunk-WM27UTWT.js";import{a as i}from"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var d=new WeakMap;function T(h,e){let P=d.get(e.client);if(P)return P;let m=Promise.resolve().then(async()=>{let n=!1,s,w,E=!1,v=()=>{},r=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,u=()=>{d.get(e.client)===m&&d.delete(e.client),r.removeEventListener("abort",f),v()},o=I(h,e,"funnel",f);function f(){n||(n=!0,o.finish("dismissed"),s?s.destroy():(u(),i(e.onDismiss,null)))}r.addEventListener("abort",f,{once:!0});try{let b=function(){!n&&!r.aborted&&!E&&w&&e.client.recovery.status==="complete"&&(E=!0,i(e.onComplete,structuredClone(w)))};var C=b;r.throwIfAborted(),o.start(!0,e.start?.locale);let l=await o.wait(e.start?e.client.start(e.start):e.client.refresh(),g);r.throwIfAborted();let O=e.client.controller;return l.mode!=="run"||l.status==="blocked"||!O?(o.finish("skipped"),u(),null):(r.removeEventListener("abort",f),v=e.client.subscribe(b),s=await A(h,{...e,client:O,signal:r,checkoutNavigation:"after_confirmation",onCheckoutUrl(t){if(r.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");if(y(e.client.recovery)!==t)throw new c("PURCHASE_PENDING","Checkout differs from the original recovery proof");return e.onCheckoutUrl?e.onCheckoutUrl(t):h.ownerDocument.defaultView?.location.assign(t)},async resolveOfferId(t){if(r.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");let a=e.client.attempt;if(!a)throw new c("PURCHASE_PENDING","Read the original Start before selecting an offer");let F=await e.resolveOfferId?.(t,a);if(r.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==a.requestId)throw new c("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return F},onComplete(t){w=t,b()},onError(t){i(e.onError,t),t instanceof c&&t.status===401&&!r.aborted&&e.client.refresh().catch(a=>i(e.onError,a))},onDismiss(t){n=!0,u(),i(e.onDismiss,t)}},o),n||r.aborted?(s.destroy(),null):s)}catch(l){if(n)return null;throw o.finish("error",l),u(),i(e.onError,l),l}});return d.set(e.client,m),m}export{T as showFunnelPurchase};
|