@tinkerlandai/longplay-sdk 0.10.38 → 0.10.39
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 +5 -0
- package/dist/check-response-MNFEOKKE.js +1 -0
- package/dist/{chunk-BDC7B4KM.js → chunk-2Y5SGDC6.js} +1 -1
- package/dist/{chunk-UD7XPHE4.js → chunk-3JD3U45R.js} +1 -1
- package/dist/{chunk-Q7K66FTS.js → chunk-3S25TLC3.js} +1 -1
- package/dist/{chunk-JXTJT2EW.js → chunk-525K7BPJ.js} +1 -1
- package/dist/chunk-73ISTR7P.js +1 -0
- package/dist/{chunk-HJVEVJXS.js → chunk-BIT6YWM7.js} +1 -1
- package/dist/{chunk-UFTLA3ZI.js → chunk-CBZ5GW4J.js} +1 -1
- package/dist/{chunk-64ETX3AY.js → chunk-CE5MAAIR.js} +1 -1
- package/dist/{chunk-TLV3NVUU.js → chunk-CEMHQQAJ.js} +1 -1
- package/dist/{chunk-WQZOT22S.js → chunk-CKVAV2W5.js} +1 -1
- package/dist/{chunk-7PXJUHDS.js → chunk-DPIQ3SV7.js} +1 -1
- package/dist/{chunk-H2I37CQ4.js → chunk-GDD26ZDV.js} +1 -1
- package/dist/{chunk-6WEHTOED.js → chunk-GGYBZWWY.js} +1 -1
- package/dist/{chunk-5IGASP6C.js → chunk-GNAMACMK.js} +1 -1
- package/dist/{chunk-WP3SZU24.js → chunk-HFD4CLCJ.js} +1 -1
- package/dist/{chunk-KTBXAATX.js → chunk-HX36OZPQ.js} +1 -1
- package/dist/{chunk-4E326NPY.js → chunk-IGANLTKS.js} +1 -1
- package/dist/{chunk-KQF4BVOL.js → chunk-IYHXEKAD.js} +1 -1
- package/dist/{chunk-NK55HFFF.js → chunk-JAZHNQKO.js} +1 -1
- package/dist/{chunk-EEYDOVVS.js → chunk-JBVZ6A6V.js} +1 -1
- package/dist/{chunk-DTWSDNYI.js → chunk-KIPUBMU3.js} +1 -1
- package/dist/{chunk-XBCKVHOT.js → chunk-LJBTEB2Q.js} +1 -1
- package/dist/{chunk-DK5PHPSO.js → chunk-LZBJHWVH.js} +1 -1
- package/dist/{chunk-UAJTQ23E.js → chunk-MTIOLSVM.js} +1 -1
- package/dist/{chunk-G7Y7LPOB.js → chunk-N774V4SQ.js} +1 -1
- package/dist/chunk-NSAEHRIT.js +1 -0
- package/dist/{chunk-PLOUC66F.js → chunk-O2D3A4CS.js} +1 -1
- package/dist/{chunk-GEPX4AUR.js → chunk-ONMIBSOC.js} +1 -1
- package/dist/{chunk-IV6LKRYM.js → chunk-PFPMK4IO.js} +1 -1
- package/dist/{chunk-6QOJRLVM.js → chunk-QCMFCK7Z.js} +1 -1
- package/dist/{chunk-DSLJUN3P.js → chunk-QXOUDODX.js} +1 -1
- package/dist/{chunk-JBDNNV3P.js → chunk-TA4W6SXG.js} +1 -1
- package/dist/{chunk-RK7XOT3F.js → chunk-TLRRBUGP.js} +1 -1
- package/dist/{chunk-O5VA3E5D.js → chunk-TPXRO63H.js} +1 -1
- package/dist/{chunk-YYXINZ4A.js → chunk-U7XD4ZR5.js} +1 -1
- package/dist/{chunk-L54MODP5.js → chunk-UKVWANDE.js} +1 -1
- package/dist/{chunk-SY7AYEDO.js → chunk-VYI6QRJW.js} +1 -1
- package/dist/{chunk-Y5RT7PAD.js → chunk-W3G4YIM5.js} +1 -1
- package/dist/{chunk-QZRJ3ZXU.js → chunk-YJS6NNIO.js} +1 -1
- package/dist/{chunk-K3VQKR4G.js → chunk-YURGISSB.js} +1 -1
- package/dist/{chunk-IHB275C3.js → chunk-ZORZA4WG.js} +1 -1
- package/dist/{content-B4CC4O23.js → content-HSMBQFM3.js} +1 -1
- package/dist/{funnel-host-purchase-AGBJG3RK.js → funnel-host-purchase-4KOOLMXV.js} +1 -1
- package/dist/funnel-paywall-prerender-NX6ZQ7EU.js +1 -0
- package/dist/funnel-runtime-host-6XYYLVCI.js +1 -0
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-ACGAMHU6.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-H27WHXQC.js +1 -0
- package/dist/page.js +1 -1
- package/dist/paywall-ZGG6DXO3.js +1 -0
- package/dist/paywall-content-ZQBE2EZP.js +1 -0
- package/dist/paywall-session-DBTBLLWI.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-5SJCTMJH.js +1 -0
- package/dist/server.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/check-response-Q7GOBUGJ.js +0 -1
- package/dist/chunk-2LND3R7K.js +0 -1
- package/dist/chunk-I7QTCEYR.js +0 -1
- package/dist/funnel-paywall-prerender-HHAQBIIB.js +0 -1
- package/dist/funnel-runtime-host-IJDKXLST.js +0 -1
- package/dist/merchant-bridge-contracts-KVOFRPKV.js +0 -1
- package/dist/operation-contracts-G4C7ZLEH.js +0 -1
- package/dist/paywall-TVCH6VQT.js +0 -1
- package/dist/paywall-content-QSTCRYU5.js +0 -1
- package/dist/paywall-session-UBQYU5XD.js +0 -1
- package/dist/screen-renderer-Q3VSMB2N.js +0 -1
- /package/dist/{chunk-42UXYMRZ.js → chunk-NOOIJXRN.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Mn,b as Un,c as un,d as dn,e as Me,f as $n,h as xn,i as Gn,j as Qn,k as Jn}from"./chunk-JXTJT2EW.js";import{b as zn}from"./chunk-JBDNNV3P.js";import{b as qn,c as Bn}from"./chunk-L54MODP5.js";import{a as On}from"./chunk-W32FI2A2.js";import{c as Sn,e as _n,f as Ln,h as Hn,i as Se,j as Ze,k as Vn,l as Ke}from"./chunk-DTWSDNYI.js";import{aa as Xe}from"./chunk-KQF4BVOL.js";import{a as Ve,d as Dn}from"./chunk-3NCMYTNG.js";import{b as Rn}from"./chunk-64ETX3AY.js";import{b as kn,d as Tn,e as An,f as Nn,g as Fn}from"./chunk-SY7AYEDO.js";import{F as Pn,ea as En}from"./chunk-HJVEVJXS.js";import{a as y}from"./chunk-O5VA3E5D.js";import{a as Ce}from"./chunk-DSPLGTQI.js";async function cn(t){let{session:v,load:C}=it(t);try{return await C(),v}catch(e){throw v.destroy(),e}}function it(t){let v=t.view;if(!v?.paywall)throw new y("INVALID_REQUEST","The current node is not a Paywall");let C=v.paywall.receiptId,e=v.nodeId,w=v.visit,N=v.paywall.resolution,s=v.paywall,_="document"in N?{document:N.document,offering:N.offering,capabilities:N.capabilities}:null;function d(){let i=s.resolution;return"document"in i?i:_&&{...i,document:_.document,offering:_.offering,capabilities:kn(i.capabilities,_.capabilities)}}function I(i){if(!Tn(i,N))throw new y("INVALID_RESPONSE","The pinned Paywall binding changed")}let P=!1,$=new Set,ne=null;function m(){let i=d();if(i&&!P)for(let l of $)Ce(l,structuredClone(i))}async function V(){O();let i=d();if(i)return structuredClone(i);if(!ne){let l=(async()=>{if("document"in s.resolution||!t.resolvePaywall)throw new y("INVALID_RESPONSE","Public Paywall reader is unavailable");let b=await qn(t,s.resolution);return O(),I(b),_={document:b.document,offering:b.offering,capabilities:b.capabilities},m(),d()})();ne=l;let a=()=>{ne===l&&(ne=null)};l.then(a,a)}return ne.then(l=>structuredClone(l))}let o=new AbortController,k=(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).find(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===w&&i.input.type==="paywall_quote")?.requestId??v.paywall.purchaseRequestId,Y=0,J=null,Q=new Set,E=null,z=new Map;function T(i){if(i.purchase&&i.purchase.receiptId!==C)throw new y("INVALID_RESPONSE","Purchase receipt changed");let l=i.run.paywall;return i.purchase??(l?.receiptId===C?l:null)}function O(){if(P)throw new y("IDENTITY_CHANGED","Paywall presentation has closed")}function S(i,l,a){if(O(),l!==Y||a!==void 0&&s.quote?.operationId!==a)return!1;let b=s.selectionGeneration??0,c=i.run.paywall;if(c?.receiptId===C){if((c.selectionGeneration??0)<(s.selectionGeneration??0))return!1;I(c.resolution)}let u=T(i),q=c?.receiptId===C&&(c.selectionGeneration??0)>b,L=q?u?.quote??null:u?.quote??s.quote,B=u?.operation??(L?.operationId===s.quote?.operationId?s.operation:null);return L&&B&&An(B,{operationId:L.operationId},"Purchase operation changed"),(q||L?.operationId!==s.quote?.operationId)&&(Y++,c?.receiptId===C&&(k=c.purchaseRequestId)),c?.canReselect===!0&&c.purchaseRequestId===E&&!(t.pendingCommands??[t.pendingCommand]).some(M=>M?.requestId===E)&&(E=null),s={...s,...c?.receiptId===C?c:{},...a!==void 0&&!q&&u?.canReselect!==void 0?{canReselect:u.canReselect}:{},quote:L,operation:Fn(s.operation,B,!0)},m(),!0}function ce(i,l,a){return new Promise((b,c)=>{let u=!1,q=()=>{clearTimeout(Ee),o.signal.removeEventListener("abort",M)},L=Re=>{u||(u=!0,q(),b(Re))},B=Re=>{u||(u=!0,q(),c(Re))},M=()=>B(new y("IDENTITY_CHANGED","Paywall presentation has closed")),Ee=setTimeout(()=>B(new y("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a)),Math.max(0,l-Date.now()));o.signal.addEventListener("abort",M,{once:!0}),o.signal.aborted&&M(),i.then(L,B)})}function Pe(i){return new Promise(l=>{let a=()=>{clearTimeout(b),o.signal.removeEventListener("abort",a),l()},b=setTimeout(a,i);o.signal.addEventListener("abort",a,{once:!0}),o.signal.aborted&&a()})}function se(i,l){O();let a=z.get(i)??t.pendingCommands?.find(u=>u.requestId===i)??t.pendingCommand;if(a?.operation==="submit"&&a.requestId===i&&a.nodeId===e&&a.visit===w){l.type==="paywall_quote"&&a.input.type==="paywall_quote"&&a.input.predecessor&&!l.predecessor&&(l={...l,predecessor:a.input.predecessor});let u=Xe.parse(a),q=Xe.parse({...a,input:l});if(u.operation!=="submit"||q.operation!=="submit"||JSON.stringify(u.input)!==JSON.stringify(q.input))throw new y("CONFLICT","A purchase request cannot change its input");return z.set(i,u),u}let b=t.view;if(!b||b.nodeId!==e||b.visit!==w||b.paywall?.receiptId!==C)throw new y("PRECONDITION_FAILED","The Paywall visit has changed");let c=Xe.parse({operation:"submit",requestId:i,nodeId:e,visit:w,revision:b.revision,input:structuredClone(l)});if(c.operation!=="submit")throw new y("INVALID_REQUEST","A purchase submission is required");return z.set(i,c),c}async function te(i,l){O();let{requestId:a,input:b}=i,c=Date.now()+3e4;Q.add(a);try{let u=await ce(t.submit(i),c,a);for(;u.run.pendingRequest?.requestId===a&&Date.now()<c&&!P&&(await Pe(Math.min(1e3,c-Date.now())),!(P||Date.now()>=c));)u=await ce(t.resume(a),c,a);if(P)throw new y("IDENTITY_CHANGED","Paywall presentation has closed");if(u.run.pendingRequest?.requestId===a)throw new y("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a);if(!S(u,l,b.type==="paywall_confirm"||b.type==="paywall_cancel"?b.operationId:void 0))throw new y("PRECONDITION_FAILED","The purchase selection has changed");E===a&&(E=null)}catch(u){if(E=a,b.type==="paywall_quote"&&t.settle&&!P&&u instanceof y&&u.status!==void 0&&![401,425].includes(u.status)&&!u.retryable&&u.recovery!=="recover_operation")try{if((await ce(t.settle(a),c,a)).settlement?.state==="settled"){let L=await ce(t.get(),c,a);S(L,l)&&L.run.paywall?.purchaseRequestId===a&&s.canReselect===!0&&z.delete(a)}}catch{}throw u instanceof y&&u.code==="COMMAND_PENDING"&&u.status===void 0&&z.delete(a),u}finally{Q.delete(a)}}async function me(i){if(!s.quote)throw new y("INVALID_REQUEST","A quoted purchase is required");let l=i==="confirm"?"paywall_confirm":"paywall_cancel",a=[...z.values(),...t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])].find(c=>c.operation==="submit"&&c.input.type===l&&"operationId"in c.input&&c.input.operationId===s.quote.operationId),b=a?.operation==="submit"&&a.input.type===l&&"operationId"in a.input&&a.input.operationId===s.quote.operationId?a.requestId:crypto.randomUUID();if(await te(se(b,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:s.quote.operationId}),Y),!s.operation)throw new y("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(s.operation)}let G={get view(){return structuredClone(d())},get quote(){return s.quote?structuredClone(s.quote):null},get operation(){return s.operation?structuredClone(s.operation):null},get webViewUrl(){return t.webViewUrl},get locale(){return t.view?.locale??v.locale},get canReselect(){return s.canReselect===!0&&E===null},get recovery(){let i=t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[]),l=t.pendingPurchase;if(l&&(l.receiptId!==C||l.operationId!==s.quote?.operationId))return{type:"recover",operationId:l.operationId,requestId:i[0]?.requestId??null};let a=Ve({quote:s.quote,operation:s.operation,requestId:i[0]?.requestId??E??k,pending:Q.size>0||i.length>0||E!==null,destroyed:P,canReselect:s.canReselect});return a.type==="recover"&&a.requestId===null&&!P&&t.hasDurableJournal===!0&&!s.quote&&!s.operation&&(s.selectionGeneration??0)===0&&!l&&!i.length&&!Q.size&&!k?{type:"native",operationId:null}:a},get pendingCancellation(){return!P&&(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).some(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===w&&i.input.type==="paywall_cancel"&&i.input.operationId===s.quote?.operationId)},subscribe(i){return P?()=>{}:($.add(i),()=>$.delete(i))},async refresh(){O();let i=Y,l=await t.get();if(S(l,i),l.run.paywall?.receiptId!==C)throw new y("PRECONDITION_FAILED","Paywall presentation has changed");return V()},preview(i){let l=d();if(!l)return Promise.reject(new y("PRECONDITION_FAILED","Load the Paywall presentation first"));if(k&&k!==i.requestId&&(J||s.canReselect!==!0))return Promise.reject(new y("COMMAND_PENDING","Retry the original purchase before starting another"));let a=l.document.buttons[i.actionId],b=a?.type==="checkout"?Rn(a.product,i.selection,l.capabilities):null;if(!b)return Promise.reject(new y("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let c=En(l.document.screen,b,i.selection,l.capabilities),u=k!==i.requestId&&(s.selectionGeneration??0)>0?{operationId:s.quote?.operationId??null,generation:s.selectionGeneration??0}:void 0;if(u&&s.canReselect!==!0)return Promise.reject(new y("COMMAND_PENDING","Original purchase requires authoritative termination"));let q;try{q=se(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:b,...Object.keys(c).length?{featureQuantities:c}:{},...u?{predecessor:u}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{}})}catch(M){return Promise.reject(M)}if(k===i.requestId&&J)return J;k!==i.requestId&&Y++;let L=Y;k=i.requestId;let B=(async()=>{if(await te(q,L),!s.quote)throw new y("INVALID_RESPONSE","The accepted quote is missing");return Nn(s.quote,{productVersionId:b,featureQuantities:c},"The selected purchase changed"),structuredClone(s.quote)})();return J=B,B.then(()=>{J===B&&(J=null)},M=>{J===B&&(J=null),k===i.requestId&&t.pendingCommand?.requestId!==i.requestId&&M instanceof y&&M.status!==void 0&&M.status<500&&![401,425].includes(M.status)&&(k=null)}),B},confirm:()=>me("confirm"),cancel:()=>me("cancel"),async read(){if(O(),!s.quote)throw new y("INVALID_REQUEST","A quoted purchase is required");let i=s.quote.operationId,l=Y,a=t.pendingCommands?.find(L=>L.operation==="submit"&&(L.input.type==="paywall_confirm"||L.input.type==="paywall_cancel")&&L.input.operationId===i)??t.pendingCommand;a?.operation==="submit"&&(a.input.type==="paywall_confirm"||a.input.type==="paywall_cancel")&&a.input.operationId===i&&await t.settle?.(a.requestId);let b=await t.get(void 0,{receiptId:C,operationId:i});O();let c=T(b);if(c?.quote&&c.quote.operationId!==i||c?.operation&&c.operation.operationId!==i)throw new y("INVALID_RESPONSE","Purchase operation changed");let u=S(b,l,i),q=u?s.operation:c?.operation;if(!q)throw new y("INVALID_RESPONSE","The current purchase result is missing");return u&&Q.size===0&&!(t.pendingCommands?.length??(t.pendingCommand?1:0))&&(E=null),structuredClone(q)},destroy(){P=!0,A(),$.clear(),o.abort(),z.clear()}},A=t.subscribe(i=>{P||i.nodeId!==e||i.visit!==w||i.paywall?.receiptId!==C||(i.paywall.selectionGeneration??0)<(s.selectionGeneration??0)||(I(i.paywall.resolution),s={...s,resolution:i.paywall.resolution},m())});return{session:G,load:V}}function jn(t){let v=new Set,C=new Set,e=null;async function w(d,I){let P=!1;for(;!t.stopped&&t.key===d&&t.client.pendingCommand?.requestId===I;){if(!t.client.settle)throw new y("COMMAND_PENDING","The original display acknowledgement is still pending");await t.client.settle(I),P=!0,t.client.pendingCommand?.requestId===I&&await new Promise($=>setTimeout($,1500))}t.stopped||t.key!==d||(P&&await t.client.get(),!(t.stopped||t.key!==d)&&v.add(d))}function N(d,I){e=I;let P=()=>{e===I&&(e=null),C.delete(d)};return I.then(P,$=>{P(),t.busy||t.fail($)}),I}function s(d){if(t.reviewing||v.has(d)||C.has(d)||t.stopped)return;C.add(d);let I=async()=>{if(t.reviewing||t.stopped||t.key!==d||v.has(d)){C.delete(d);return}if(t.busy||t.client.pendingCommand){setTimeout(()=>{I()},250);return}let P=(async()=>{if(t.staleRead){if(await t.staleRead,t.stopped||t.key!==d)return;if(t.client.pendingCommand){setTimeout(()=>{I()},250);return}}let $=t.client.view,ne=t.expected(),m=ne.requestId;try{await t.client.submit({operation:"shown",...ne})}catch(V){if(!(V instanceof y)||V.code!=="CONFLICT"||V.status!==409||t.client.pendingCommand)throw V;await t.client.get();let o=t.client.view;if(t.stopped||t.reviewing||t.key!==d||!o||!$||o.id!==$.id||o.source.versionId!==$.source.versionId||o.nodeId!==ne.nodeId||o.visit!==ne.visit||o.revision<=ne.revision||o.stopped||!o.screen&&(!o.paywall||o.paywall.receiptId!==$.paywall?.receiptId)||!["running","waiting"].includes(o.status)||t.client.pendingCommand)throw V;let R=t.expected();m=R.requestId,await t.client.submit({operation:"shown",...R})}await w(d,m)})();N(d,P)};I()}function _(){if(e)return e;let d=t.client.pendingCommand;if(d?.operation!=="shown")return null;let I=t.key;return C.add(I),N(I,(async()=>{await t.client.retry(),await w(I,d.requestId)})())}return{report:s,settled:_,get inFlight(){return e}}}function Wn(t){let v={},C=new Map;async function e(w){let N=t.client.view,s=N?.screen,_=s?.customerData.nodes[w.nodeId];if(t.stopped||t.busy||!N||!s||!_)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(w.action)){let V=t.document,o=V?Pn(V,w.nodeId):null,R=o?.type==="customer_data"?o.data.outputs?.[w.action]:void 0;R&&s.outputs.includes(R)?await t.perform(()=>t.client.submit({operation:"submit",...t.expected(),input:{type:"screen",output:R,answers:t.answers,selection:w.value?{[w.nodeId]:w.value}:{}}})):await t.onIntent?.(w,N);return}let I=w.action.startsWith("sources_")?_.resources.find(V=>V.key===w.value):null;if(w.action.startsWith("sources_")&&!I)throw new y("INVALID_REQUEST","Choose a current resource");let P=`${N.visit}:${w.nodeId}:${I?.key??""}`,$=C.get(P)??[null],m=v[w.nodeId]??{page:1,after:null,filter:"all",...I?{resourceKey:I.key}:{}};if(w.action==="filter"){let V=w.value;if(!V||!(_.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(V))throw new y("INVALID_REQUEST","Unknown data filter");m={page:1,after:null,filter:V},$.splice(0,$.length,null)}else if(w.action==="next"||w.action==="sources_next"){let V=I?.sources.at(-1),o=I?V?{kind:"ledger",cursor:{at:V.detail[0],id:V.id,type:"source"}}:null:s.dataCursors[w.nodeId];if(!o||!I&&!_.hasNext)return;$[m.page]=o,m={...m,page:m.page+1,after:o}}else if(w.action==="previous"||w.action==="sources_previous"){if(m.page<=1)return;m={...m,page:m.page-1,after:$[m.page-2]??null}}C.set(P,$),v={...v,[w.nodeId]:m},await t.perform(()=>t.client.get({nodeId:N.nodeId,visit:N.visit,revision:N.revision,components:v}))}return{get queries(){return v},intent:e,reset(){v={},C.clear()}}}function Yn(t){let{doc:v,holder:C,reviewHolder:e,mountScreenPreview:w}=t,N=!1,s,_=0,d=null,I="",P,$=new Map,ne=o=>o?`${o.id}:${o.nodeId}:${o.visit}:${o.revision}:${o.paywall?.quote?.operationId??""}`:"";async function m(o){if(t.stopped||!t.client.review||N&&o===s&&P?.active)return;let R=!N||o!==s;N||(I=ne(t.client.view),$.set(I,structuredClone(t.answers))),N=!0,s=o,C.hidden=!0,t.suspend(!0),e.hidden=!1;let k=++_;R&&(P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),P=Ze(e,t.loadingOptions,"funnel",()=>{V()}));let Y=R?P:void 0;try{if(Y?.start(!1,t.client.view?.locale),k!==_||t.stopped)return;let J=t.client.review(o),Q=await(Y?.wait(J,Se)??J);if(t.stopped||k!==_||!N)return;if(!Q.review)throw new y("INVALID_RESPONSE","Historical projection is missing");d?.destroy(),d=null,Y||e.replaceChildren();let E=v.createElement("div"),z=Y?Ke(E,e):()=>{};e.append(E);let T=Q.run.locale.startsWith("zh"),O=t.chrome;E.style.cssText=O.history;let S=v.createElement("p");S.textContent=T?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",S.style.cssText=O.historyTitle,E.append(S);let ce=v.createElement("p");ce.style.cssText=O.historyNote,ce.textContent=Q.review.pages.length?T?"\u9009\u62E9\u4E00\u9875\u67E5\u770B\u5F53\u65F6\u7684\u5185\u5BB9\uFF0C\u56DE\u770B\u4E0D\u4F1A\u6539\u52A8\u4EFB\u4F55\u4FE1\u606F\u3002":"Choose a page to see it as it was. Nothing here can be changed.":T?"\u8FD8\u6CA1\u6709\u53EF\u56DE\u770B\u7684\u9875\u9762\u3002":"There are no earlier pages yet.",E.append(ce);let Pe=Q.review.page?.receiptId,se=v.createElement("div");se.style.cssText=O.historyPages;for(let[G,A]of Q.review.pages.entries()){let i=v.createElement("button");i.type="button",i.textContent=T?`\u7B2C ${G+1} \u9875`:`Page ${G+1}`;let l=Pe!==void 0&&A.receiptId===Pe;i.style.cssText=l?O.primary:O.secondary,l&&i.setAttribute("aria-current","page"),Me(i,()=>t.chrome.focus),i.onclick=()=>{m(A.receiptId)},se.append(i)}if(se.childElementCount&&E.append(se),Q.review.page){let G=Q.review.page,A=v.createElement("div");A.inert=!0,A.style.cssText=O.historyPage,E.append(A),d=w(A,{mode:"live",rendererUrl:t.client.webViewUrl,title:G.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{k===_&&!t.stopped&&Y?.present(z)},onError:l=>{if(k!==_||t.stopped)return;let a=new Error(l);Y?.finish("error",a),d?.destroy(),d=null,E.remove(),t.fail(a)},onEscape:()=>{V()}});let i=d;if(i.update(G.document,Q.run.locale,{serverInput:{bindings:G.inputs,answers:G.answers,values:G.values}}),await i.ready,t.stopped||k!==_||!N)return}let te=T?{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"},me=v.createElement("div");me.style.cssText=O.historyRecords;for(let G of[...Q.review.coupons.map((A,i)=>`${T?"\u4F18\u60E0\u5238":"Coupon"} ${i+1}: ${te[A.status]}`),...Q.review.purchases.map((A,i)=>`${T?"\u8D2D\u4E70":"Purchase"} ${i+1}: ${Jn(A.status,T)}`)]){let A=v.createElement("p");A.textContent=G,A.style.margin="0",me.append(A)}me.childElementCount&&E.append(me),Q.review.page||Y?.present(z),t.client.view&&await t.enqueue(t.client.view)}catch(J){if(k!==_||t.stopped)return;Y?.finish("error",J),d?.destroy(),d=null,e.replaceChildren(),t.fail(J)}}async function V(){if(!N||t.stopped||!t.client.review)return;let o=++_;P?.finish("dismissed");try{if(await t.client.review(),t.stopped||o!==_)return;N=!1,_++,P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),e.hidden=!0,C.hidden=!1;let R=t.client.view;ne(R)!==I?($.set(I,structuredClone(t.answers)),t.resetScreen()):($.delete(I),t.suspend(!1)),R&&await t.enqueue(R)}catch(R){if(o!==_||t.stopped)return;d?.destroy(),d=null,e.replaceChildren(),t.fail(R)}}return{get active(){return N},get receipt(){return s},open:m,exit:V,get drafts(){return new Map([...$].map(([o,R])=>[o,structuredClone(R)]))},stop(){N=!1,_++,P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),e.hidden=!0,C.hidden=!1}}}var pn=5e3;async function rt(t,v,C){let e=v,w=e.prepared&&zn(e.prepared),N=()=>{};function s(){e.prepared&&e.prepared.state!=="adopted"&&w?.release()}let _=()=>e.prepared?.state==="shown"&&!!w?.modal,d=e.client.identitySignal,I;try{I=await Promise.all([import("./screen-renderer-Q3VSMB2N.js"),import("./paywall-TVCH6VQT.js")]),e.signal?.throwIfAborted(),d?.throwIfAborted()}catch(n){throw s(),n}let[{mountScreenPreview:P},{showPaywall:$}]=I,ne=(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&e.appManifestRelease?Bn({client:e.client,appManifestRelease:e.appManifestRelease,onError:e.onError}):void 0;ne?.start();let m=t.ownerDocument,V=Hn(m),o=m.createElement("section"),R=m.createElement("div"),k=m.createElement("div"),Y=m.createElement("div"),J=m.createElement("button");Y.hidden=!0,J.type="button";let Q=m.createElement("p"),E=m.createElement("p"),z=m.createElement("button"),T=m.createElement("button"),O=m.createElement("button"),S=m.createElement("dialog"),ce,Pe=!1;o.dataset.indianaFunnel="",o.dataset.longplayCloseOwner="sdk",o.setAttribute("aria-busy","false"),Q.setAttribute("role","status"),E.setAttribute("role","alert"),E.hidden=!0,z.type=T.type=O.type="button",k.append(z,J,Q,E,O,T),o.append(R,Y,k),t.append(o);let se=Un,te=un(se),me="",G=(m.documentElement.lang||"").startsWith("zh"),A,i="",l;for(let n of[z,J,O,T])Me(n,()=>te.focus);function a(){let n=G?"\u5173\u95ED":"Close";T.parentElement===S?(T.textContent="\xD7",T.setAttribute("aria-label",n),Ln(T,se)):(T.textContent=n,T.removeAttribute("aria-label"),T.style.cssText=te.link+";margin-inline-start:auto")}function b(n){let r=n?.screen?.content.document.theme??se,p=JSON.stringify([r.primary,r.background,r.text,r.radius,r.font,T.parentElement===S]);if(p===me)return;me=p,se=r;let H=T.parentElement===S;te=un(se,H),o.style.cssText=te.root+";min-width:0"+(H?";display:flex;flex-direction:column;min-height:100%":""),k.style.cssText=te.bar+(H?";margin-top:auto":""),k.hidden&&(k.style.display="none"),z.style.cssText=J.style.cssText=te.secondary,O.style.cssText=te.primary,Q.style.cssText=te.status,E.style.cssText=te.alert,a(),dn(z)}function c(){k.hidden=z.hidden&&J.hidden&&O.hidden&&E.hidden&&!Q.textContent&&(T.hidden||T.parentElement!==k),k.style.display=k.hidden?"none":"flex",A?.responsive&&l!==void 0&&A.setContentHeight(l+k.getBoundingClientRect().height)}b();let u=null,q=null,L=null,B="",M="",Ee=!1,Re="",en="",Ue="",h=!1,le=0,$e=!1,fn="",nn=null,tn=Promise.resolve(),mn=!e.client.view,j=C,Te,_e,xe="",Ge,ue=!1,qe=null,he=!1,Qe=()=>e.client.pendingCommand?.operation==="close",de=null,X=null,wn=On({document:m,run:async()=>{(!q?.observing||e.client.pendingCommand)&&await on()},delay:()=>{if(!(h||!L||!["running","waiting"].includes(L.status)&&!e.client.pendingCommand)&&!(q?.observing&&!e.client.pendingCommand))return L.pendingRequest||e.client.pendingCommand?1500:pn},hiddenDelay:()=>!h&&e.client.pendingCommand?15e3:void 0}),K=null;function rn(){return X&&e.client.hasDurableJournal===!0&&K?.acknowledged===!0&&K.operationId===X.operationId&&e.client.view?.id===K.runId&&e.client.view?.status==="closed"&&e.client.view.revision===K.revision+1&&!(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0))&&!e.client.pendingPurchase?X:null}function yn(n){let r=n.run.paywall;if(K&&n.settlement?.requestId===K.requestId&&n.settlement.state==="settled"&&n.settlement.operationId===null&&n.run.id===K.runId&&n.run.status==="closed"&&!n.run.pendingRequest&&n.run.revision===K.revision+1&&n.run.nodeId===K.nodeId&&n.run.visit===K.visit&&r?.receiptId===K.receiptId&&r.selectionGeneration===K.selectionGeneration&&(r.quote?.operationId??null)===K.operationId&&(r.operation?.operationId??r.quote?.operationId??null)===K.operationId){let p=K.operationId===null&&r.selectionGeneration===0&&!r.quote&&!r.operation&&!r.purchaseRequestId,H=Ve({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect});(p||r.canReselect===!0&&H.type==="native")&&(K.acknowledged=!0)}}let De=null,Je=new Set,we={},Ae=!1,pe=(n,r=null)=>{h||(De=r,Ae=!1,E.textContent=$n(n,G),E.hidden=!1,O.hidden=e.client.pendingCommand===null,c(),Ce(e.onError,n))},gn=()=>{h||(De=null,E.textContent=Gn(G),E.hidden=!1,O.hidden=!0,c())};function ke(){let n=e.client.view;if(!n)throw new y("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:n.revision}}let F=Yn({client:e.client,doc:m,holder:R,reviewHolder:Y,mountScreenPreview:P,loadingOptions:e,get chrome(){return te},get stopped(){return h},get answers(){return we},suspend(n){q?.setSuspended(n)},resetScreen(){B="",M="",Re=""},enqueue:ye,fail:pe}),Le=jn({client:e.client,expected:ke,fail:pe,get stopped(){return h},get reviewing(){return F.active},get key(){return B},get busy(){return le},get staleRead(){return nn}}),ze=Wn({client:e.client,expected:ke,perform:Fe,onIntent:e.onCustomerDataIntent,get stopped(){return h},get busy(){return le},get document(){return u?.document},get answers(){return we}}),Be=n=>`${n.id}:${n.nodeId}:${n.visit}`,Ne=n=>n&&(n.screen||n.paywall)?Be(n):"";function ve(){let n=e.client.view;z.disabled=!F.active&&(le>0||!!e.client.pendingCommand||!n?.canBack||n.stopped||!["running","waiting"].includes(n.status)||!Ne(n)||M!==Ne(n)),z.hidden=!F.active&&!n?.canBack,dn(z);let r=!!q&&!F.active;T.hidden=r&&!j?.active||Pe&&!F.active,J.hidden=!e.client.review||!F.active&&!n?.canBack,r&&(Q.textContent=""),c()}async function hn(n){if(!n)return;let r=e.client.view;await n;let p=e.client.view;if(!r||!p||p.id!==r.id||p.nodeId!==r.nodeId||p.visit!==r.visit||p.stopped||!["running","waiting"].includes(p.status))throw new y("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function Fe(n,r=!1,p){if(!((le||he||de||X)&&!r||h||F.active&&!r)){le++,o.setAttribute("aria-busy","true"),E.hidden=!0,De=null,Ae=!1,ve();try{if(r||await hn(Le.inFlight),h)return;let H=await n();h||await ye(e.client.view??H.run)}catch(H){p?.(H)&&e.client.pendingCommand===null?gn():pe(H,e.client.pendingCommand?.requestId??null)}finally{le=Math.max(0,le-1),o.setAttribute("aria-busy",String(le>0)),h||(O.hidden=e.client.pendingCommand===null,ve())}}}function He(){wn.schedule()}async function on(){if(!(h||$e||le)){if(F.active){await F.open(F.receipt);return}$e=!0;try{let n=e.client.pendingCommand;n&&e.client.settle&&await e.client.settle(n.requestId);let r=e.client.view,p=ze.queries,H=await e.client.get(r?.screen&&Object.keys(p).length?{nodeId:r.nodeId,visit:r.visit,revision:r.revision,components:p}:void 0);Ae&&!h&&(Ae=!1,E.hidden=!0,c()),!h&&p===ze.queries&&await ye(e.client.view??H.run)}catch(n){pe(n),Ae=!h}finally{$e=!1}}}function je(n,r,p){if(j?.active){let ae=j;return ae.setDismissHandler(()=>vn(ae)),ae}let H=Ze(t,e,"funnel",()=>vn(H),Mn);return j=H,H.start(n,r,p),H}function vn(n){h||ue||(ue=!0,n.finish("dismissed"),Ie(),o.hidden=!0,e.client.view?be().finally(ie):ie())}function sn(){clearTimeout(Ge?.timeout),Ge=void 0}function Ie(){Pe=!1,sn(),Te?.abort(),Te=void 0,u?.destroy(),u=null,q?.destroy(),q=null,_e?.(),_e=void 0,S.open&&S.close(),R.replaceChildren(),R.style.cssText="",l=void 0,B="",M="",Ee=!1,Re="",Ue=""}function In(){let n=m.defaultView;A?.responsive&&n&&u?.resizeViewport?.(n.innerHeight,n.innerWidth)}function an(){A?.destroy(),A=void 0,i=""}function We(n){let r=n.screen?.presentation;if(!r||r.type==="inline"){S.open&&S.close(),an(),T.parentElement!==k&&k.append(T),o.parentElement!==t&&t.append(o);for(let ae of["flex","display","flex-direction","justify-content"])R.style.removeProperty(ae);b(n),c();return}o.parentElement!==S&&(S.append(T,o),t.append(S)),R.style.flex="1 0 auto",R.style.display="flex",R.style.flexDirection="column",R.style.justifyContent="center",b(n);let p=n.screen.content.document,H=JSON.stringify([r,me]);if(H!==i){an(),i=H;let ae={sm:420,md:640,lg:900},ge="size"in r&&!r.backdrop?",0 0 0 100vmax #16142566":"";S.style.cssText=`box-sizing:border-box;padding:0;border:0;overflow:auto;background:${se.background};color:${se.text};`+(r.type==="fullscreen"?"width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border-radius:0":`width:${ae[r.size]}px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 24px 80px #0003${ge};`+(r.type==="sheet"?"margin:auto auto 0;border-radius:14px 14px 0 0":"border-radius:14px")),A=Sn(S,{presentation:r,theme:p.theme,pages:p.pages},In),A.latch()}c(),S.setAttribute("aria-label",(ce?.screen===n.screen?.content.document.name?ce?.label:void 0)??u?.document?.name??n.screen?.content.document.name??"Funnel")}async function Xn(n){if(h||ue||he&&(Qe()||["running","waiting"].includes(n.status))||(L=n,De&&e.client.pendingCommand?.requestId!==De&&(E.hidden=!0,De=null),G=n.locale.startsWith("zh"),J.textContent=G?"\u56DE\u770B":"History",z.textContent=F.active?G?"\u8FD4\u56DE\u5F53\u524D":"Return to current":G?"\u8FD4\u56DE":"Back",a(),O.textContent=G?"\u91CD\u8BD5":"Retry",O.hidden=e.client.pendingCommand===null,Q.textContent=n.pendingRequest?G?"\u6B63\u5728\u5904\u7406":"Processing":n.instruction?.type==="wait"?G?"\u7B49\u5F85\u4E2D":"Waiting":"",ve(),fn!==`${n.revision}:${n.visit}:${n.status}:${n.stopped}`&&(fn=`${n.revision}:${n.visit}:${n.status}:${n.stopped}`,Ce(e.onState,structuredClone(n))),h||ue))return;if((!n.pendingRequest||he&&n.status==="closed")&&["closed","ineligible","failed"].includes(n.status)){ie();return}if(n.stopped&&_()){ie();return}if(n.stopped||e.client.configurationReady===!1){F.stop(),s(),Ie(),j?.finish("skipped"),o.hidden=!0,He();return}if(o.hidden=!1,F.active){He();return}let r=Ne(n),p=e.client.view;if(p&&p.revision>n.revision&&Ne(p)!==r)return;let H=!n.instruction&&!n.pendingRequest&&n.nodeType==="screen"&&["running","waiting"].includes(n.status);r!==B&&(B&&j?.finish("dismissed"),Ie(),B=r,we={...n.answers},ze.reset());let ae=Be(n);if(xe===ae){o.hidden=!0;return}if(H&&!r){o.hidden=!0;let U=e.prepared?.state==="shown"?null:je(!0,n.locale);!h&&!ue&&Ge?.key!==ae&&(sn(),Ge={key:ae,timeout:setTimeout(()=>{let g=e.client.view;if(h||!U?.active&&e.prepared?.state!=="shown"||!g||Be(g)!==ae)return;xe=ae;let W=new Error("Funnel screen preparation timed out");U?.finish("error",W),s(),Ie(),pe(W)},Se)}),He();return}sn();let Z=U=>{let g=e.client.view;return!h&&!ue&&!qe&&!U.aborted&&e.client.configurationReady!==!1&&!!g&&!g.stopped&&!["closed","ineligible","failed"].includes(g.status)&&Ne(g)===r},ge=(U,g)=>{Z(g)&&(xe=r,j?.finish("error",U),Ie(),o.hidden=!0,pe(U))};if(r||((n.instruction&&n.instruction.type!=="evaluate_segment"||!["running","waiting"].includes(n.status))&&s(),We(n),n.instruction?.type!=="event"&&n.instruction?.type!=="open_url"&&j?.finish("skipped")),n.screen){s();let U=n.screen.content;if(!u){let x=n.screen.presentation.type!=="inline",re=je(x,n.locale);if(h||ue)return;let ee=(Te=new AbortController).signal;We(n),_e=x?Vn(S):Ke(o,t),u=P(R,{mode:"live",closeActions:Array.from(new Set([...e.closeActions??[],...U.document.actions.filter(f=>f.type==="event"&&f.close).map(f=>f.id)])),onAuthoredClose(f){Z(ee)&&(Pe=f,ve())},rendererUrl:e.client.webViewUrl,title:U.document.name,...x?{hostPresentation:()=>A?.type??n.screen.presentation.type}:{},onResize:f=>{l=f,A?.responsive&&A.setContentHeight(f+k.getBoundingClientRect().height)},onAction(f,fe={},tt={}){if(F.active||!Z(ee)||M!==r)return;we={...we,...tt};let ln=n.screen?.inputs??[],Cn=Object.fromEntries(ln.filter(({variable:Oe})=>Object.hasOwn(we,Oe)).map(({variable:Oe})=>[Oe,we[Oe]]));if(Qn(ln,Cn).length){gn();return}Fe(()=>e.client.submit({operation:"submit",...ke(),input:{type:"screen",output:f,answers:Cn,selection:fe}}),!1,Oe=>xn(Oe,ln))},onAnswers:f=>{F.active||!Z(ee)||M!==r||(we={...we,...f})},onCustomerDataIntent:f=>{F.active||!Z(ee)||M!==r||ze.intent(f).catch(pe)},onEscape:()=>{!Z(ee)||M!==r||F.active||de||X||be()},onError:f=>{let fe=new Error(f);M===r?pe(fe):ge(fe,ee)},onRendered:f=>{if(!(!Z(ee)||M===r))try{re.present(fe=>{_e?.(),_e=void 0,f&&(ce={screen:U.document.name,label:f},S.setAttribute("aria-label",f)),x&&(S.showModal(),A?.responsive&&S.focus({preventScroll:!0}),!fe&&e.loading!=="host"&&_n(S,A?.type??n.screen.presentation.type,A?.responsive)),M=r,Ee=x,ve()}),Z(ee)&&Le.report(r)}catch(fe){ge(fe,ee)}}}),In()}let g={capabilities:n.screen.capabilities,customerData:n.screen.customerData,parameters:n.parameters,serverInput:{bindings:n.screen.inputs,answers:we,values:n.screen.values}},W=JSON.stringify([U,n.locale,g.parameters,n.screen.inputs,n.screen.values]);if(W!==Re)u.update(U.document,n.locale,g),Re=W,en=JSON.stringify(g.capabilities),Ue=JSON.stringify(g.customerData);else{let x=JSON.stringify(g.capabilities);x!==en&&(u.updateCapabilities(g.capabilities),en=x),JSON.stringify(g.customerData)!==Ue&&(u.updateCustomerData(g.customerData),Ue=JSON.stringify(g.customerData))}let oe=u;if(oe)try{await(j?.wait(oe.ready)??oe.ready)}catch(x){Te&&ge(x,Te.signal)}}else if(n.paywall&&!q){let U=n.paywall.resolution,g="document"in U?U.document:null,W=w,oe=null,x=(Te=new AbortController).signal,re={loading:"host",signal:x,canInteract:()=>Z(x)&&!F.active&&!de&&!X,beforeAction:async()=>{le++;try{await hn(Le.settled()),E.hidden=!0,De=null,Ae=!1,c()}finally{le=Math.max(0,le-1)}},start:()=>cn(e.client),onObservationChange:He,onPurchase:e.onPurchase,onCheckoutUrl:e.onCheckoutUrl,resumeCheckout:e.resumeCheckout,allowNewPurchase:e.allowNewPurchase,checkoutNavigation:e.checkoutNavigation,terminateCheckout:e.terminateCheckout,confirmOnHostedCheckout:e.confirmOnHostedCheckout,resolveOfferId:e.resolveOfferId,claimCoupon:e.claimCoupon,onEvent:e.onEvent,onOpenUrl:f=>e.onOpenUrl?e.onOpenUrl({receiptId:n.paywall.receiptId,url:f,openIn:"same_window"}):m.defaultView?.location.assign(f),onAction:async f=>{if(F.active)return;let fe=await e.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:e.client.view?.revision??n.revision,input:{type:"screen",output:f,answers:{}}});await ye(e.client.view??fe.run)},onError:f=>{M===r?pe(f):ge(f,x)}},ee={quoteError:f=>Ce(e.onError,f),present(f){Z(x)&&(oe?.present(()=>{f(),M=r,Ee=!!R.querySelector("dialog[open]"),ve()}),Z(x)&&Le.report(r))},async dismiss(){if(!(h||x.aborted||F.active||de||X||!he&&!Z(x))){if(he=!0,(e.resumeCheckout||e.terminateCheckout)&&nt()){L=e.client.view,ie();return}await be()}}};if(W){let f=await W.adopt(n,{options:re,handoff:ee,start:()=>cn(e.client)});f&&Z(x)&&!h?(We(n),q=f,j?.active&&j.present(()=>{}),M=r,Ee=W.modal,ve(),Le.report(r),F.active&&q.setSuspended(!0)):(f?.destroy(),s())}if(h||ue)return;if(!q){if(oe=je(!0,n.locale,g),h||ue)return;We(n);let f=await $(R,re,ee).catch(fe=>(ge(fe,x),null));!Z(x)&&!(he&&!h&&!x.aborted)?f?.host?.destroy():f&&(q=f.host,q?.setSuspended(F.active))}}if(h||ue)return;ve();let D=n.instruction;if(D&&(D.type==="open_url"||D.type==="event")&&!Je.has(D.receiptId)){let U=m.createElement("button");U.type="button",U.style.cssText=te.primary,Me(U,()=>te.focus),R.style.cssText=te.stage,U.textContent=D.type==="open_url"?`${G?"\u524D\u5F80":"Continue to"} ${new URL(D.url).host}`:G?"\u7EE7\u7EED":"Continue",U.onclick=()=>{let g=ke(),W=D.type==="open_url"&&!e.onOpenUrl&&D.openIn==="new_window"?Zn(D.url):null;Fe(async()=>{let oe="success";if(D.type==="open_url")if(e.onOpenUrl)try{oe=await e.onOpenUrl({receiptId:D.receiptId,url:D.url,openIn:D.openIn})===!1?"failed":"opened"}catch(re){Ce(e.onError,re),oe="failed"}else oe=D.openIn==="new_window"&&!W?"failed":"opened";if(D.type==="event"){if(!e.onEvent)throw new y("EVENT_HANDLER_REQUIRED","Provide the event handler");await e.onEvent(D.event)}if(h||e.client.view?.nodeId!==g.nodeId||e.client.view.visit!==g.visit)throw new y("PRECONDITION_FAILED","The client action visit changed");let x=await e.client.submit({operation:"submit",...g,input:{type:"client_action",receiptId:D.receiptId,outcome:oe}});return Je.add(D.receiptId),D.type==="open_url"&&!e.onOpenUrl&&D.openIn==="same_window"&&m.defaultView?.location.assign(D.url),x})},j?.active?j.present(()=>R.replaceChildren(U)):R.replaceChildren(U)}!n.pendingRequest&&n.status==="completed"&&!Je.has(`complete:${n.id}`)&&(Je.add(`complete:${n.id}`),Ce(e.onComplete,structuredClone(n))),He()}function Zn(n){let r=m.defaultView?.open(n,"_blank")??null;return r&&(r.opener=null),r}function ye(n){return ve(),tn=tn.catch(()=>{}).then(async()=>{try{await Xn(n)}catch(r){throw j?.active&&(xe=Be(n),j.finish("error",r),Ie(),o.hidden=!0),r}}),tn}let Kn=e.client.subscribe(n=>{if(!mn){if(n.stopped&&(Ee||_())&&!he){L=n,ie();return}!he&&(n.stopped||e.client.configurationReady===!1||B&&M!==B&&(Ne(n)!==B||["closed","ineligible","failed"].includes(n.status)))&&(Ie(),j?.finish("dismissed"),o.hidden=!0),ye(n).catch(pe)}}),et=e.client.subscribeError?.(pe);function nt(){let n=e.client.view,r=n?.paywall;return!!r?.operation&&!!n&&["running","waiting"].includes(n.status)&&Dn(Ve({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect}))}function be(n){if(qe)return qe;if(h||!n&&(de||X))return Promise.resolve();let r=!n&&Qe();return!r&&e.client.view&&!["running","waiting"].includes(e.client.view.status)?(L=e.client.view,ie(),Promise.resolve()):(qe=Fe(async()=>{let p=r?await e.client.retry():await e.client.submit({operation:"close",...n??ke()});return n&&yn(p),p},!0).then(()=>{let p=e.client.view;p?.status==="closed"&&!Qe()&&(L=p,ie())}).finally(()=>{qe=null}),qe)}function ie(){ne?.destroy(),!h&&(h=!0,N(),s(),e.signal?.removeEventListener("abort",ie),d?.removeEventListener("abort",ie),j?.finish("dismissed"),wn.destroy(),Kn(),et?.(),Ie(),an(),F.stop(),S.remove(),o.remove(),V(),Ce(e.onDismiss,L?structuredClone(L):null))}z.onclick=()=>{if(!z.disabled){if(F.active){F.exit();return}Fe(()=>e.client.submit({operation:"back",...ke()}))}},J.onclick=()=>{F.open()},T.onclick=()=>{j?.active?j.dismiss():de||be()},O.onclick=()=>{Qe()?be():Fe(()=>e.client.retry())},S.addEventListener("cancel",n=>{n.preventDefault(),j?.active?j.dismiss():de||be()}),e.signal?.addEventListener("abort",ie,{once:!0}),d?.addEventListener("abort",ie,{once:!0});let Ye=!1;w&&(N=w.onClose(()=>{h||ue||(ue=!0,j?.finish("dismissed"),Ie(),o.hidden=!0,e.client.view?be().finally(ie):Ye=!0)}));let bn={destroy:ie,refresh:on,get recovery(){let n=rn();if(n)return n;if(!h&&!le&&!he&&!de&&q){let r=q.recovery;if(r.type!=="native")return r}return{type:"recover",operationId:e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??X?.operationId??null,requestId:e.client.pendingCommand?.requestId??null}},prepareFallback(){if(de)return de;let n=rn();if(n)return Promise.resolve(n);let r=e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??X?.operationId??null,p=()=>({type:"recover",operationId:r,requestId:e.client.pendingCommand?.requestId??null});if(e.client.hasDurableJournal!==!0){let D=q?.recovery;return Promise.resolve(D&&D.type!=="native"&&D.type!=="cancel"?D:p())}let H=(e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[])).some(D=>D.operation==="close");if(h&&!(H||X&&e.client.view?.status==="closed")||le||$e||qe||F.active||!q&&!X&&!H)return Promise.resolve(p());let ae=q,Z=(async()=>{try{if(!X&&H){let g=await e.client.retry();return await ye(e.client.view??g.run),p()}if(!X){let g=await ae.prepareFallback();if(g.type!=="native")return g;if(e.client.hasDurableJournal!==!0)return p();X=g}let D=e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[]);if(D.length){let g=D.find(oe=>oe.operation==="close");if(!g||!K||g.requestId!==K.requestId)return p();let W=await e.client.retry();yn(W),await ye(e.client.view??W.run)}else{let g=e.client.view,W=g?.paywall;if(!g||!W||W.selectionGeneration===void 0||(W.quote?.operationId??null)!==X.operationId||X.operationId!==null&&W.canReselect!==!0)return p();let oe=W.selectionGeneration,x=await e.client.get();await ye(e.client.view??x.run);let re=e.client.view,ee=re?.paywall;if(!re||!ee||!["running","waiting"].includes(re.status)||re.stopped||re.id!==g.id||re.nodeId!==g.nodeId||re.visit!==g.visit||ee.receiptId!==W.receiptId||ee.selectionGeneration!==oe||(ee.quote?.operationId??null)!==X.operationId||X.operationId!==null&&ee.canReselect!==!0||e.client.pendingPurchase||(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0)))return p();let f=ke();K={runId:re.id,operationId:X.operationId,revision:f.revision,requestId:f.requestId,nodeId:re.nodeId,visit:re.visit,receiptId:ee.receiptId,selectionGeneration:oe,acknowledged:!1},await be(f)}let U=rn();return U?(ie(),U):p()}catch(D){return pe(D),p()}})();de=Z;let ge=()=>{de===Z&&(de=null)};return Z.then(ge,ge),Z},review:F.open,exitReview:F.exit,get unappliedDrafts(){return F.drafts}};try{let n=e.client.view;if(n)((e.client.viewAgeMs??pn)>=pn||n.instruction?.type==="evaluate_segment")&&(nn=on().finally(()=>{nn=null})),await ye(n);else{if(o.hidden=!0,h)throw new DOMException("Presentation cancelled","AbortError");let r=Ye||e.prepared?.state==="shown"?null:je(e.client.view?.screen?.presentation.type!=="inline",e.client.view?.locale);if(h||ue&&!Ye)throw new DOMException("Presentation cancelled","AbortError");let p=e.client.get(),H=await(r?r.wait(p,Se):ot(p,Se));if(mn=!1,Ye)return h||await be().finally(ie),bn;await ye(e.client.view??H.run)}}catch(n){throw j?.finish("error",n),ie(),n}return bn}function ot(t,v){let C;return Promise.race([t,new Promise((e,w)=>{C=setTimeout(()=>w(new Error("Presentation data timed out")),v)})]).finally(()=>clearTimeout(C))}function Gt(t,v,C){return rt(t,v,C)}export{rt as a,Gt as b};
|
|
1
|
+
import{a as Mn,b as Un,c as un,d as dn,e as Me,f as $n,h as xn,i as Gn,j as Qn,k as Jn}from"./chunk-525K7BPJ.js";import{b as zn}from"./chunk-TA4W6SXG.js";import{b as qn,c as Bn}from"./chunk-UKVWANDE.js";import{a as On}from"./chunk-W32FI2A2.js";import{c as Sn,e as _n,f as Ln,h as Hn,i as Se,j as Ze,k as Vn,l as Ke}from"./chunk-KIPUBMU3.js";import{aa as Xe}from"./chunk-IYHXEKAD.js";import{a as Ve,d as Dn}from"./chunk-3NCMYTNG.js";import{b as Rn}from"./chunk-CE5MAAIR.js";import{b as kn,d as Tn,e as An,f as Nn,g as Fn}from"./chunk-VYI6QRJW.js";import{F as Pn,ea as En}from"./chunk-BIT6YWM7.js";import{a as y}from"./chunk-TPXRO63H.js";import{a as Ce}from"./chunk-DSPLGTQI.js";async function cn(t){let{session:v,load:C}=it(t);try{return await C(),v}catch(e){throw v.destroy(),e}}function it(t){let v=t.view;if(!v?.paywall)throw new y("INVALID_REQUEST","The current node is not a Paywall");let C=v.paywall.receiptId,e=v.nodeId,w=v.visit,N=v.paywall.resolution,s=v.paywall,_="document"in N?{document:N.document,offering:N.offering,capabilities:N.capabilities}:null;function d(){let i=s.resolution;return"document"in i?i:_&&{...i,document:_.document,offering:_.offering,capabilities:kn(i.capabilities,_.capabilities)}}function I(i){if(!Tn(i,N))throw new y("INVALID_RESPONSE","The pinned Paywall binding changed")}let P=!1,$=new Set,ne=null;function m(){let i=d();if(i&&!P)for(let l of $)Ce(l,structuredClone(i))}async function V(){O();let i=d();if(i)return structuredClone(i);if(!ne){let l=(async()=>{if("document"in s.resolution||!t.resolvePaywall)throw new y("INVALID_RESPONSE","Public Paywall reader is unavailable");let b=await qn(t,s.resolution);return O(),I(b),_={document:b.document,offering:b.offering,capabilities:b.capabilities},m(),d()})();ne=l;let a=()=>{ne===l&&(ne=null)};l.then(a,a)}return ne.then(l=>structuredClone(l))}let o=new AbortController,k=(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).find(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===w&&i.input.type==="paywall_quote")?.requestId??v.paywall.purchaseRequestId,Y=0,J=null,Q=new Set,E=null,z=new Map;function T(i){if(i.purchase&&i.purchase.receiptId!==C)throw new y("INVALID_RESPONSE","Purchase receipt changed");let l=i.run.paywall;return i.purchase??(l?.receiptId===C?l:null)}function O(){if(P)throw new y("IDENTITY_CHANGED","Paywall presentation has closed")}function S(i,l,a){if(O(),l!==Y||a!==void 0&&s.quote?.operationId!==a)return!1;let b=s.selectionGeneration??0,c=i.run.paywall;if(c?.receiptId===C){if((c.selectionGeneration??0)<(s.selectionGeneration??0))return!1;I(c.resolution)}let u=T(i),q=c?.receiptId===C&&(c.selectionGeneration??0)>b,L=q?u?.quote??null:u?.quote??s.quote,B=u?.operation??(L?.operationId===s.quote?.operationId?s.operation:null);return L&&B&&An(B,{operationId:L.operationId},"Purchase operation changed"),(q||L?.operationId!==s.quote?.operationId)&&(Y++,c?.receiptId===C&&(k=c.purchaseRequestId)),c?.canReselect===!0&&c.purchaseRequestId===E&&!(t.pendingCommands??[t.pendingCommand]).some(M=>M?.requestId===E)&&(E=null),s={...s,...c?.receiptId===C?c:{},...a!==void 0&&!q&&u?.canReselect!==void 0?{canReselect:u.canReselect}:{},quote:L,operation:Fn(s.operation,B,!0)},m(),!0}function ce(i,l,a){return new Promise((b,c)=>{let u=!1,q=()=>{clearTimeout(Ee),o.signal.removeEventListener("abort",M)},L=Re=>{u||(u=!0,q(),b(Re))},B=Re=>{u||(u=!0,q(),c(Re))},M=()=>B(new y("IDENTITY_CHANGED","Paywall presentation has closed")),Ee=setTimeout(()=>B(new y("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a)),Math.max(0,l-Date.now()));o.signal.addEventListener("abort",M,{once:!0}),o.signal.aborted&&M(),i.then(L,B)})}function Pe(i){return new Promise(l=>{let a=()=>{clearTimeout(b),o.signal.removeEventListener("abort",a),l()},b=setTimeout(a,i);o.signal.addEventListener("abort",a,{once:!0}),o.signal.aborted&&a()})}function se(i,l){O();let a=z.get(i)??t.pendingCommands?.find(u=>u.requestId===i)??t.pendingCommand;if(a?.operation==="submit"&&a.requestId===i&&a.nodeId===e&&a.visit===w){l.type==="paywall_quote"&&a.input.type==="paywall_quote"&&a.input.predecessor&&!l.predecessor&&(l={...l,predecessor:a.input.predecessor});let u=Xe.parse(a),q=Xe.parse({...a,input:l});if(u.operation!=="submit"||q.operation!=="submit"||JSON.stringify(u.input)!==JSON.stringify(q.input))throw new y("CONFLICT","A purchase request cannot change its input");return z.set(i,u),u}let b=t.view;if(!b||b.nodeId!==e||b.visit!==w||b.paywall?.receiptId!==C)throw new y("PRECONDITION_FAILED","The Paywall visit has changed");let c=Xe.parse({operation:"submit",requestId:i,nodeId:e,visit:w,revision:b.revision,input:structuredClone(l)});if(c.operation!=="submit")throw new y("INVALID_REQUEST","A purchase submission is required");return z.set(i,c),c}async function te(i,l){O();let{requestId:a,input:b}=i,c=Date.now()+3e4;Q.add(a);try{let u=await ce(t.submit(i),c,a);for(;u.run.pendingRequest?.requestId===a&&Date.now()<c&&!P&&(await Pe(Math.min(1e3,c-Date.now())),!(P||Date.now()>=c));)u=await ce(t.resume(a),c,a);if(P)throw new y("IDENTITY_CHANGED","Paywall presentation has closed");if(u.run.pendingRequest?.requestId===a)throw new y("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a);if(!S(u,l,b.type==="paywall_confirm"||b.type==="paywall_cancel"?b.operationId:void 0))throw new y("PRECONDITION_FAILED","The purchase selection has changed");E===a&&(E=null)}catch(u){if(E=a,b.type==="paywall_quote"&&t.settle&&!P&&u instanceof y&&u.status!==void 0&&![401,425].includes(u.status)&&!u.retryable&&u.recovery!=="recover_operation")try{if((await ce(t.settle(a),c,a)).settlement?.state==="settled"){let L=await ce(t.get(),c,a);S(L,l)&&L.run.paywall?.purchaseRequestId===a&&s.canReselect===!0&&z.delete(a)}}catch{}throw u instanceof y&&u.code==="COMMAND_PENDING"&&u.status===void 0&&z.delete(a),u}finally{Q.delete(a)}}async function me(i){if(!s.quote)throw new y("INVALID_REQUEST","A quoted purchase is required");let l=i==="confirm"?"paywall_confirm":"paywall_cancel",a=[...z.values(),...t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])].find(c=>c.operation==="submit"&&c.input.type===l&&"operationId"in c.input&&c.input.operationId===s.quote.operationId),b=a?.operation==="submit"&&a.input.type===l&&"operationId"in a.input&&a.input.operationId===s.quote.operationId?a.requestId:crypto.randomUUID();if(await te(se(b,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:s.quote.operationId}),Y),!s.operation)throw new y("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(s.operation)}let G={get view(){return structuredClone(d())},get quote(){return s.quote?structuredClone(s.quote):null},get operation(){return s.operation?structuredClone(s.operation):null},get webViewUrl(){return t.webViewUrl},get locale(){return t.view?.locale??v.locale},get canReselect(){return s.canReselect===!0&&E===null},get recovery(){let i=t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[]),l=t.pendingPurchase;if(l&&(l.receiptId!==C||l.operationId!==s.quote?.operationId))return{type:"recover",operationId:l.operationId,requestId:i[0]?.requestId??null};let a=Ve({quote:s.quote,operation:s.operation,requestId:i[0]?.requestId??E??k,pending:Q.size>0||i.length>0||E!==null,destroyed:P,canReselect:s.canReselect});return a.type==="recover"&&a.requestId===null&&!P&&t.hasDurableJournal===!0&&!s.quote&&!s.operation&&(s.selectionGeneration??0)===0&&!l&&!i.length&&!Q.size&&!k?{type:"native",operationId:null}:a},get pendingCancellation(){return!P&&(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).some(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===w&&i.input.type==="paywall_cancel"&&i.input.operationId===s.quote?.operationId)},subscribe(i){return P?()=>{}:($.add(i),()=>$.delete(i))},async refresh(){O();let i=Y,l=await t.get();if(S(l,i),l.run.paywall?.receiptId!==C)throw new y("PRECONDITION_FAILED","Paywall presentation has changed");return V()},preview(i){let l=d();if(!l)return Promise.reject(new y("PRECONDITION_FAILED","Load the Paywall presentation first"));if(k&&k!==i.requestId&&(J||s.canReselect!==!0))return Promise.reject(new y("COMMAND_PENDING","Retry the original purchase before starting another"));let a=l.document.buttons[i.actionId],b=a?.type==="checkout"?Rn(a.product,i.selection,l.capabilities):null;if(!b)return Promise.reject(new y("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let c=En(l.document.screen,b,i.selection,l.capabilities),u=k!==i.requestId&&(s.selectionGeneration??0)>0?{operationId:s.quote?.operationId??null,generation:s.selectionGeneration??0}:void 0;if(u&&s.canReselect!==!0)return Promise.reject(new y("COMMAND_PENDING","Original purchase requires authoritative termination"));let q;try{q=se(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:b,...Object.keys(c).length?{featureQuantities:c}:{},...u?{predecessor:u}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{}})}catch(M){return Promise.reject(M)}if(k===i.requestId&&J)return J;k!==i.requestId&&Y++;let L=Y;k=i.requestId;let B=(async()=>{if(await te(q,L),!s.quote)throw new y("INVALID_RESPONSE","The accepted quote is missing");return Nn(s.quote,{productVersionId:b,featureQuantities:c},"The selected purchase changed"),structuredClone(s.quote)})();return J=B,B.then(()=>{J===B&&(J=null)},M=>{J===B&&(J=null),k===i.requestId&&t.pendingCommand?.requestId!==i.requestId&&M instanceof y&&M.status!==void 0&&M.status<500&&![401,425].includes(M.status)&&(k=null)}),B},confirm:()=>me("confirm"),cancel:()=>me("cancel"),async read(){if(O(),!s.quote)throw new y("INVALID_REQUEST","A quoted purchase is required");let i=s.quote.operationId,l=Y,a=t.pendingCommands?.find(L=>L.operation==="submit"&&(L.input.type==="paywall_confirm"||L.input.type==="paywall_cancel")&&L.input.operationId===i)??t.pendingCommand;a?.operation==="submit"&&(a.input.type==="paywall_confirm"||a.input.type==="paywall_cancel")&&a.input.operationId===i&&await t.settle?.(a.requestId);let b=await t.get(void 0,{receiptId:C,operationId:i});O();let c=T(b);if(c?.quote&&c.quote.operationId!==i||c?.operation&&c.operation.operationId!==i)throw new y("INVALID_RESPONSE","Purchase operation changed");let u=S(b,l,i),q=u?s.operation:c?.operation;if(!q)throw new y("INVALID_RESPONSE","The current purchase result is missing");return u&&Q.size===0&&!(t.pendingCommands?.length??(t.pendingCommand?1:0))&&(E=null),structuredClone(q)},destroy(){P=!0,A(),$.clear(),o.abort(),z.clear()}},A=t.subscribe(i=>{P||i.nodeId!==e||i.visit!==w||i.paywall?.receiptId!==C||(i.paywall.selectionGeneration??0)<(s.selectionGeneration??0)||(I(i.paywall.resolution),s={...s,resolution:i.paywall.resolution},m())});return{session:G,load:V}}function jn(t){let v=new Set,C=new Set,e=null;async function w(d,I){let P=!1;for(;!t.stopped&&t.key===d&&t.client.pendingCommand?.requestId===I;){if(!t.client.settle)throw new y("COMMAND_PENDING","The original display acknowledgement is still pending");await t.client.settle(I),P=!0,t.client.pendingCommand?.requestId===I&&await new Promise($=>setTimeout($,1500))}t.stopped||t.key!==d||(P&&await t.client.get(),!(t.stopped||t.key!==d)&&v.add(d))}function N(d,I){e=I;let P=()=>{e===I&&(e=null),C.delete(d)};return I.then(P,$=>{P(),t.busy||t.fail($)}),I}function s(d){if(t.reviewing||v.has(d)||C.has(d)||t.stopped)return;C.add(d);let I=async()=>{if(t.reviewing||t.stopped||t.key!==d||v.has(d)){C.delete(d);return}if(t.busy||t.client.pendingCommand){setTimeout(()=>{I()},250);return}let P=(async()=>{if(t.staleRead){if(await t.staleRead,t.stopped||t.key!==d)return;if(t.client.pendingCommand){setTimeout(()=>{I()},250);return}}let $=t.client.view,ne=t.expected(),m=ne.requestId;try{await t.client.submit({operation:"shown",...ne})}catch(V){if(!(V instanceof y)||V.code!=="CONFLICT"||V.status!==409||t.client.pendingCommand)throw V;await t.client.get();let o=t.client.view;if(t.stopped||t.reviewing||t.key!==d||!o||!$||o.id!==$.id||o.source.versionId!==$.source.versionId||o.nodeId!==ne.nodeId||o.visit!==ne.visit||o.revision<=ne.revision||o.stopped||!o.screen&&(!o.paywall||o.paywall.receiptId!==$.paywall?.receiptId)||!["running","waiting"].includes(o.status)||t.client.pendingCommand)throw V;let R=t.expected();m=R.requestId,await t.client.submit({operation:"shown",...R})}await w(d,m)})();N(d,P)};I()}function _(){if(e)return e;let d=t.client.pendingCommand;if(d?.operation!=="shown")return null;let I=t.key;return C.add(I),N(I,(async()=>{await t.client.retry(),await w(I,d.requestId)})())}return{report:s,settled:_,get inFlight(){return e}}}function Wn(t){let v={},C=new Map;async function e(w){let N=t.client.view,s=N?.screen,_=s?.customerData.nodes[w.nodeId];if(t.stopped||t.busy||!N||!s||!_)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(w.action)){let V=t.document,o=V?Pn(V,w.nodeId):null,R=o?.type==="customer_data"?o.data.outputs?.[w.action]:void 0;R&&s.outputs.includes(R)?await t.perform(()=>t.client.submit({operation:"submit",...t.expected(),input:{type:"screen",output:R,answers:t.answers,selection:w.value?{[w.nodeId]:w.value}:{}}})):await t.onIntent?.(w,N);return}let I=w.action.startsWith("sources_")?_.resources.find(V=>V.key===w.value):null;if(w.action.startsWith("sources_")&&!I)throw new y("INVALID_REQUEST","Choose a current resource");let P=`${N.visit}:${w.nodeId}:${I?.key??""}`,$=C.get(P)??[null],m=v[w.nodeId]??{page:1,after:null,filter:"all",...I?{resourceKey:I.key}:{}};if(w.action==="filter"){let V=w.value;if(!V||!(_.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(V))throw new y("INVALID_REQUEST","Unknown data filter");m={page:1,after:null,filter:V},$.splice(0,$.length,null)}else if(w.action==="next"||w.action==="sources_next"){let V=I?.sources.at(-1),o=I?V?{kind:"ledger",cursor:{at:V.detail[0],id:V.id,type:"source"}}:null:s.dataCursors[w.nodeId];if(!o||!I&&!_.hasNext)return;$[m.page]=o,m={...m,page:m.page+1,after:o}}else if(w.action==="previous"||w.action==="sources_previous"){if(m.page<=1)return;m={...m,page:m.page-1,after:$[m.page-2]??null}}C.set(P,$),v={...v,[w.nodeId]:m},await t.perform(()=>t.client.get({nodeId:N.nodeId,visit:N.visit,revision:N.revision,components:v}))}return{get queries(){return v},intent:e,reset(){v={},C.clear()}}}function Yn(t){let{doc:v,holder:C,reviewHolder:e,mountScreenPreview:w}=t,N=!1,s,_=0,d=null,I="",P,$=new Map,ne=o=>o?`${o.id}:${o.nodeId}:${o.visit}:${o.revision}:${o.paywall?.quote?.operationId??""}`:"";async function m(o){if(t.stopped||!t.client.review||N&&o===s&&P?.active)return;let R=!N||o!==s;N||(I=ne(t.client.view),$.set(I,structuredClone(t.answers))),N=!0,s=o,C.hidden=!0,t.suspend(!0),e.hidden=!1;let k=++_;R&&(P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),P=Ze(e,t.loadingOptions,"funnel",()=>{V()}));let Y=R?P:void 0;try{if(Y?.start(!1,t.client.view?.locale),k!==_||t.stopped)return;let J=t.client.review(o),Q=await(Y?.wait(J,Se)??J);if(t.stopped||k!==_||!N)return;if(!Q.review)throw new y("INVALID_RESPONSE","Historical projection is missing");d?.destroy(),d=null,Y||e.replaceChildren();let E=v.createElement("div"),z=Y?Ke(E,e):()=>{};e.append(E);let T=Q.run.locale.startsWith("zh"),O=t.chrome;E.style.cssText=O.history;let S=v.createElement("p");S.textContent=T?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",S.style.cssText=O.historyTitle,E.append(S);let ce=v.createElement("p");ce.style.cssText=O.historyNote,ce.textContent=Q.review.pages.length?T?"\u9009\u62E9\u4E00\u9875\u67E5\u770B\u5F53\u65F6\u7684\u5185\u5BB9\uFF0C\u56DE\u770B\u4E0D\u4F1A\u6539\u52A8\u4EFB\u4F55\u4FE1\u606F\u3002":"Choose a page to see it as it was. Nothing here can be changed.":T?"\u8FD8\u6CA1\u6709\u53EF\u56DE\u770B\u7684\u9875\u9762\u3002":"There are no earlier pages yet.",E.append(ce);let Pe=Q.review.page?.receiptId,se=v.createElement("div");se.style.cssText=O.historyPages;for(let[G,A]of Q.review.pages.entries()){let i=v.createElement("button");i.type="button",i.textContent=T?`\u7B2C ${G+1} \u9875`:`Page ${G+1}`;let l=Pe!==void 0&&A.receiptId===Pe;i.style.cssText=l?O.primary:O.secondary,l&&i.setAttribute("aria-current","page"),Me(i,()=>t.chrome.focus),i.onclick=()=>{m(A.receiptId)},se.append(i)}if(se.childElementCount&&E.append(se),Q.review.page){let G=Q.review.page,A=v.createElement("div");A.inert=!0,A.style.cssText=O.historyPage,E.append(A),d=w(A,{mode:"live",rendererUrl:t.client.webViewUrl,title:G.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{k===_&&!t.stopped&&Y?.present(z)},onError:l=>{if(k!==_||t.stopped)return;let a=new Error(l);Y?.finish("error",a),d?.destroy(),d=null,E.remove(),t.fail(a)},onEscape:()=>{V()}});let i=d;if(i.update(G.document,Q.run.locale,{serverInput:{bindings:G.inputs,answers:G.answers,values:G.values}}),await i.ready,t.stopped||k!==_||!N)return}let te=T?{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"},me=v.createElement("div");me.style.cssText=O.historyRecords;for(let G of[...Q.review.coupons.map((A,i)=>`${T?"\u4F18\u60E0\u5238":"Coupon"} ${i+1}: ${te[A.status]}`),...Q.review.purchases.map((A,i)=>`${T?"\u8D2D\u4E70":"Purchase"} ${i+1}: ${Jn(A.status,T)}`)]){let A=v.createElement("p");A.textContent=G,A.style.margin="0",me.append(A)}me.childElementCount&&E.append(me),Q.review.page||Y?.present(z),t.client.view&&await t.enqueue(t.client.view)}catch(J){if(k!==_||t.stopped)return;Y?.finish("error",J),d?.destroy(),d=null,e.replaceChildren(),t.fail(J)}}async function V(){if(!N||t.stopped||!t.client.review)return;let o=++_;P?.finish("dismissed");try{if(await t.client.review(),t.stopped||o!==_)return;N=!1,_++,P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),e.hidden=!0,C.hidden=!1;let R=t.client.view;ne(R)!==I?($.set(I,structuredClone(t.answers)),t.resetScreen()):($.delete(I),t.suspend(!1)),R&&await t.enqueue(R)}catch(R){if(o!==_||t.stopped)return;d?.destroy(),d=null,e.replaceChildren(),t.fail(R)}}return{get active(){return N},get receipt(){return s},open:m,exit:V,get drafts(){return new Map([...$].map(([o,R])=>[o,structuredClone(R)]))},stop(){N=!1,_++,P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),e.hidden=!0,C.hidden=!1}}}var pn=5e3;async function rt(t,v,C){let e=v,w=e.prepared&&zn(e.prepared),N=()=>{};function s(){e.prepared&&e.prepared.state!=="adopted"&&w?.release()}let _=()=>e.prepared?.state==="shown"&&!!w?.modal,d=e.client.identitySignal,I;try{I=await Promise.all([import("./screen-renderer-5SJCTMJH.js"),import("./paywall-ZGG6DXO3.js")]),e.signal?.throwIfAborted(),d?.throwIfAborted()}catch(n){throw s(),n}let[{mountScreenPreview:P},{showPaywall:$}]=I,ne=(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&e.appManifestRelease?Bn({client:e.client,appManifestRelease:e.appManifestRelease,onError:e.onError}):void 0;ne?.start();let m=t.ownerDocument,V=Hn(m),o=m.createElement("section"),R=m.createElement("div"),k=m.createElement("div"),Y=m.createElement("div"),J=m.createElement("button");Y.hidden=!0,J.type="button";let Q=m.createElement("p"),E=m.createElement("p"),z=m.createElement("button"),T=m.createElement("button"),O=m.createElement("button"),S=m.createElement("dialog"),ce,Pe=!1;o.dataset.indianaFunnel="",o.dataset.longplayCloseOwner="sdk",o.setAttribute("aria-busy","false"),Q.setAttribute("role","status"),E.setAttribute("role","alert"),E.hidden=!0,z.type=T.type=O.type="button",k.append(z,J,Q,E,O,T),o.append(R,Y,k),t.append(o);let se=Un,te=un(se),me="",G=(m.documentElement.lang||"").startsWith("zh"),A,i="",l;for(let n of[z,J,O,T])Me(n,()=>te.focus);function a(){let n=G?"\u5173\u95ED":"Close";T.parentElement===S?(T.textContent="\xD7",T.setAttribute("aria-label",n),Ln(T,se)):(T.textContent=n,T.removeAttribute("aria-label"),T.style.cssText=te.link+";margin-inline-start:auto")}function b(n){let r=n?.screen?.content.document.theme??se,p=JSON.stringify([r.primary,r.background,r.text,r.radius,r.font,T.parentElement===S]);if(p===me)return;me=p,se=r;let H=T.parentElement===S;te=un(se,H),o.style.cssText=te.root+";min-width:0"+(H?";display:flex;flex-direction:column;min-height:100%":""),k.style.cssText=te.bar+(H?";margin-top:auto":""),k.hidden&&(k.style.display="none"),z.style.cssText=J.style.cssText=te.secondary,O.style.cssText=te.primary,Q.style.cssText=te.status,E.style.cssText=te.alert,a(),dn(z)}function c(){k.hidden=z.hidden&&J.hidden&&O.hidden&&E.hidden&&!Q.textContent&&(T.hidden||T.parentElement!==k),k.style.display=k.hidden?"none":"flex",A?.responsive&&l!==void 0&&A.setContentHeight(l+k.getBoundingClientRect().height)}b();let u=null,q=null,L=null,B="",M="",Ee=!1,Re="",en="",Ue="",h=!1,le=0,$e=!1,fn="",nn=null,tn=Promise.resolve(),mn=!e.client.view,j=C,Te,_e,xe="",Ge,ue=!1,qe=null,he=!1,Qe=()=>e.client.pendingCommand?.operation==="close",de=null,X=null,wn=On({document:m,run:async()=>{(!q?.observing||e.client.pendingCommand)&&await on()},delay:()=>{if(!(h||!L||!["running","waiting"].includes(L.status)&&!e.client.pendingCommand)&&!(q?.observing&&!e.client.pendingCommand))return L.pendingRequest||e.client.pendingCommand?1500:pn},hiddenDelay:()=>!h&&e.client.pendingCommand?15e3:void 0}),K=null;function rn(){return X&&e.client.hasDurableJournal===!0&&K?.acknowledged===!0&&K.operationId===X.operationId&&e.client.view?.id===K.runId&&e.client.view?.status==="closed"&&e.client.view.revision===K.revision+1&&!(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0))&&!e.client.pendingPurchase?X:null}function yn(n){let r=n.run.paywall;if(K&&n.settlement?.requestId===K.requestId&&n.settlement.state==="settled"&&n.settlement.operationId===null&&n.run.id===K.runId&&n.run.status==="closed"&&!n.run.pendingRequest&&n.run.revision===K.revision+1&&n.run.nodeId===K.nodeId&&n.run.visit===K.visit&&r?.receiptId===K.receiptId&&r.selectionGeneration===K.selectionGeneration&&(r.quote?.operationId??null)===K.operationId&&(r.operation?.operationId??r.quote?.operationId??null)===K.operationId){let p=K.operationId===null&&r.selectionGeneration===0&&!r.quote&&!r.operation&&!r.purchaseRequestId,H=Ve({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect});(p||r.canReselect===!0&&H.type==="native")&&(K.acknowledged=!0)}}let De=null,Je=new Set,we={},Ae=!1,pe=(n,r=null)=>{h||(De=r,Ae=!1,E.textContent=$n(n,G),E.hidden=!1,O.hidden=e.client.pendingCommand===null,c(),Ce(e.onError,n))},gn=()=>{h||(De=null,E.textContent=Gn(G),E.hidden=!1,O.hidden=!0,c())};function ke(){let n=e.client.view;if(!n)throw new y("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:n.revision}}let F=Yn({client:e.client,doc:m,holder:R,reviewHolder:Y,mountScreenPreview:P,loadingOptions:e,get chrome(){return te},get stopped(){return h},get answers(){return we},suspend(n){q?.setSuspended(n)},resetScreen(){B="",M="",Re=""},enqueue:ye,fail:pe}),Le=jn({client:e.client,expected:ke,fail:pe,get stopped(){return h},get reviewing(){return F.active},get key(){return B},get busy(){return le},get staleRead(){return nn}}),ze=Wn({client:e.client,expected:ke,perform:Fe,onIntent:e.onCustomerDataIntent,get stopped(){return h},get busy(){return le},get document(){return u?.document},get answers(){return we}}),Be=n=>`${n.id}:${n.nodeId}:${n.visit}`,Ne=n=>n&&(n.screen||n.paywall)?Be(n):"";function ve(){let n=e.client.view;z.disabled=!F.active&&(le>0||!!e.client.pendingCommand||!n?.canBack||n.stopped||!["running","waiting"].includes(n.status)||!Ne(n)||M!==Ne(n)),z.hidden=!F.active&&!n?.canBack,dn(z);let r=!!q&&!F.active;T.hidden=r&&!j?.active||Pe&&!F.active,J.hidden=!e.client.review||!F.active&&!n?.canBack,r&&(Q.textContent=""),c()}async function hn(n){if(!n)return;let r=e.client.view;await n;let p=e.client.view;if(!r||!p||p.id!==r.id||p.nodeId!==r.nodeId||p.visit!==r.visit||p.stopped||!["running","waiting"].includes(p.status))throw new y("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function Fe(n,r=!1,p){if(!((le||he||de||X)&&!r||h||F.active&&!r)){le++,o.setAttribute("aria-busy","true"),E.hidden=!0,De=null,Ae=!1,ve();try{if(r||await hn(Le.inFlight),h)return;let H=await n();h||await ye(e.client.view??H.run)}catch(H){p?.(H)&&e.client.pendingCommand===null?gn():pe(H,e.client.pendingCommand?.requestId??null)}finally{le=Math.max(0,le-1),o.setAttribute("aria-busy",String(le>0)),h||(O.hidden=e.client.pendingCommand===null,ve())}}}function He(){wn.schedule()}async function on(){if(!(h||$e||le)){if(F.active){await F.open(F.receipt);return}$e=!0;try{let n=e.client.pendingCommand;n&&e.client.settle&&await e.client.settle(n.requestId);let r=e.client.view,p=ze.queries,H=await e.client.get(r?.screen&&Object.keys(p).length?{nodeId:r.nodeId,visit:r.visit,revision:r.revision,components:p}:void 0);Ae&&!h&&(Ae=!1,E.hidden=!0,c()),!h&&p===ze.queries&&await ye(e.client.view??H.run)}catch(n){pe(n),Ae=!h}finally{$e=!1}}}function je(n,r,p){if(j?.active){let ae=j;return ae.setDismissHandler(()=>vn(ae)),ae}let H=Ze(t,e,"funnel",()=>vn(H),Mn);return j=H,H.start(n,r,p),H}function vn(n){h||ue||(ue=!0,n.finish("dismissed"),Ie(),o.hidden=!0,e.client.view?be().finally(ie):ie())}function sn(){clearTimeout(Ge?.timeout),Ge=void 0}function Ie(){Pe=!1,sn(),Te?.abort(),Te=void 0,u?.destroy(),u=null,q?.destroy(),q=null,_e?.(),_e=void 0,S.open&&S.close(),R.replaceChildren(),R.style.cssText="",l=void 0,B="",M="",Ee=!1,Re="",Ue=""}function In(){let n=m.defaultView;A?.responsive&&n&&u?.resizeViewport?.(n.innerHeight,n.innerWidth)}function an(){A?.destroy(),A=void 0,i=""}function We(n){let r=n.screen?.presentation;if(!r||r.type==="inline"){S.open&&S.close(),an(),T.parentElement!==k&&k.append(T),o.parentElement!==t&&t.append(o);for(let ae of["flex","display","flex-direction","justify-content"])R.style.removeProperty(ae);b(n),c();return}o.parentElement!==S&&(S.append(T,o),t.append(S)),R.style.flex="1 0 auto",R.style.display="flex",R.style.flexDirection="column",R.style.justifyContent="center",b(n);let p=n.screen.content.document,H=JSON.stringify([r,me]);if(H!==i){an(),i=H;let ae={sm:420,md:640,lg:900},ge="size"in r&&!r.backdrop?",0 0 0 100vmax #16142566":"";S.style.cssText=`box-sizing:border-box;padding:0;border:0;overflow:auto;background:${se.background};color:${se.text};`+(r.type==="fullscreen"?"width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border-radius:0":`width:${ae[r.size]}px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 24px 80px #0003${ge};`+(r.type==="sheet"?"margin:auto auto 0;border-radius:14px 14px 0 0":"border-radius:14px")),A=Sn(S,{presentation:r,theme:p.theme,pages:p.pages},In),A.latch()}c(),S.setAttribute("aria-label",(ce?.screen===n.screen?.content.document.name?ce?.label:void 0)??u?.document?.name??n.screen?.content.document.name??"Funnel")}async function Xn(n){if(h||ue||he&&(Qe()||["running","waiting"].includes(n.status))||(L=n,De&&e.client.pendingCommand?.requestId!==De&&(E.hidden=!0,De=null),G=n.locale.startsWith("zh"),J.textContent=G?"\u56DE\u770B":"History",z.textContent=F.active?G?"\u8FD4\u56DE\u5F53\u524D":"Return to current":G?"\u8FD4\u56DE":"Back",a(),O.textContent=G?"\u91CD\u8BD5":"Retry",O.hidden=e.client.pendingCommand===null,Q.textContent=n.pendingRequest?G?"\u6B63\u5728\u5904\u7406":"Processing":n.instruction?.type==="wait"?G?"\u7B49\u5F85\u4E2D":"Waiting":"",ve(),fn!==`${n.revision}:${n.visit}:${n.status}:${n.stopped}`&&(fn=`${n.revision}:${n.visit}:${n.status}:${n.stopped}`,Ce(e.onState,structuredClone(n))),h||ue))return;if((!n.pendingRequest||he&&n.status==="closed")&&["closed","ineligible","failed"].includes(n.status)){ie();return}if(n.stopped&&_()){ie();return}if(n.stopped||e.client.configurationReady===!1){F.stop(),s(),Ie(),j?.finish("skipped"),o.hidden=!0,He();return}if(o.hidden=!1,F.active){He();return}let r=Ne(n),p=e.client.view;if(p&&p.revision>n.revision&&Ne(p)!==r)return;let H=!n.instruction&&!n.pendingRequest&&n.nodeType==="screen"&&["running","waiting"].includes(n.status);r!==B&&(B&&j?.finish("dismissed"),Ie(),B=r,we={...n.answers},ze.reset());let ae=Be(n);if(xe===ae){o.hidden=!0;return}if(H&&!r){o.hidden=!0;let U=e.prepared?.state==="shown"?null:je(!0,n.locale);!h&&!ue&&Ge?.key!==ae&&(sn(),Ge={key:ae,timeout:setTimeout(()=>{let g=e.client.view;if(h||!U?.active&&e.prepared?.state!=="shown"||!g||Be(g)!==ae)return;xe=ae;let W=new Error("Funnel screen preparation timed out");U?.finish("error",W),s(),Ie(),pe(W)},Se)}),He();return}sn();let Z=U=>{let g=e.client.view;return!h&&!ue&&!qe&&!U.aborted&&e.client.configurationReady!==!1&&!!g&&!g.stopped&&!["closed","ineligible","failed"].includes(g.status)&&Ne(g)===r},ge=(U,g)=>{Z(g)&&(xe=r,j?.finish("error",U),Ie(),o.hidden=!0,pe(U))};if(r||((n.instruction&&n.instruction.type!=="evaluate_segment"||!["running","waiting"].includes(n.status))&&s(),We(n),n.instruction?.type!=="event"&&n.instruction?.type!=="open_url"&&j?.finish("skipped")),n.screen){s();let U=n.screen.content;if(!u){let x=n.screen.presentation.type!=="inline",re=je(x,n.locale);if(h||ue)return;let ee=(Te=new AbortController).signal;We(n),_e=x?Vn(S):Ke(o,t),u=P(R,{mode:"live",closeActions:Array.from(new Set([...e.closeActions??[],...U.document.actions.filter(f=>f.type==="event"&&f.close).map(f=>f.id)])),onAuthoredClose(f){Z(ee)&&(Pe=f,ve())},rendererUrl:e.client.webViewUrl,title:U.document.name,...x?{hostPresentation:()=>A?.type??n.screen.presentation.type}:{},onResize:f=>{l=f,A?.responsive&&A.setContentHeight(f+k.getBoundingClientRect().height)},onAction(f,fe={},tt={}){if(F.active||!Z(ee)||M!==r)return;we={...we,...tt};let ln=n.screen?.inputs??[],Cn=Object.fromEntries(ln.filter(({variable:Oe})=>Object.hasOwn(we,Oe)).map(({variable:Oe})=>[Oe,we[Oe]]));if(Qn(ln,Cn).length){gn();return}Fe(()=>e.client.submit({operation:"submit",...ke(),input:{type:"screen",output:f,answers:Cn,selection:fe}}),!1,Oe=>xn(Oe,ln))},onAnswers:f=>{F.active||!Z(ee)||M!==r||(we={...we,...f})},onCustomerDataIntent:f=>{F.active||!Z(ee)||M!==r||ze.intent(f).catch(pe)},onEscape:()=>{!Z(ee)||M!==r||F.active||de||X||be()},onError:f=>{let fe=new Error(f);M===r?pe(fe):ge(fe,ee)},onRendered:f=>{if(!(!Z(ee)||M===r))try{re.present(fe=>{_e?.(),_e=void 0,f&&(ce={screen:U.document.name,label:f},S.setAttribute("aria-label",f)),x&&(S.showModal(),A?.responsive&&S.focus({preventScroll:!0}),!fe&&e.loading!=="host"&&_n(S,A?.type??n.screen.presentation.type,A?.responsive)),M=r,Ee=x,ve()}),Z(ee)&&Le.report(r)}catch(fe){ge(fe,ee)}}}),In()}let g={capabilities:n.screen.capabilities,customerData:n.screen.customerData,parameters:n.parameters,serverInput:{bindings:n.screen.inputs,answers:we,values:n.screen.values}},W=JSON.stringify([U,n.locale,g.parameters,n.screen.inputs,n.screen.values]);if(W!==Re)u.update(U.document,n.locale,g),Re=W,en=JSON.stringify(g.capabilities),Ue=JSON.stringify(g.customerData);else{let x=JSON.stringify(g.capabilities);x!==en&&(u.updateCapabilities(g.capabilities),en=x),JSON.stringify(g.customerData)!==Ue&&(u.updateCustomerData(g.customerData),Ue=JSON.stringify(g.customerData))}let oe=u;if(oe)try{await(j?.wait(oe.ready)??oe.ready)}catch(x){Te&&ge(x,Te.signal)}}else if(n.paywall&&!q){let U=n.paywall.resolution,g="document"in U?U.document:null,W=w,oe=null,x=(Te=new AbortController).signal,re={loading:"host",signal:x,canInteract:()=>Z(x)&&!F.active&&!de&&!X,beforeAction:async()=>{le++;try{await hn(Le.settled()),E.hidden=!0,De=null,Ae=!1,c()}finally{le=Math.max(0,le-1)}},start:()=>cn(e.client),onObservationChange:He,onPurchase:e.onPurchase,onCheckoutUrl:e.onCheckoutUrl,resumeCheckout:e.resumeCheckout,allowNewPurchase:e.allowNewPurchase,checkoutNavigation:e.checkoutNavigation,terminateCheckout:e.terminateCheckout,confirmOnHostedCheckout:e.confirmOnHostedCheckout,resolveOfferId:e.resolveOfferId,claimCoupon:e.claimCoupon,onEvent:e.onEvent,onOpenUrl:f=>e.onOpenUrl?e.onOpenUrl({receiptId:n.paywall.receiptId,url:f,openIn:"same_window"}):m.defaultView?.location.assign(f),onAction:async f=>{if(F.active)return;let fe=await e.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:e.client.view?.revision??n.revision,input:{type:"screen",output:f,answers:{}}});await ye(e.client.view??fe.run)},onError:f=>{M===r?pe(f):ge(f,x)}},ee={quoteError:f=>Ce(e.onError,f),present(f){Z(x)&&(oe?.present(()=>{f(),M=r,Ee=!!R.querySelector("dialog[open]"),ve()}),Z(x)&&Le.report(r))},async dismiss(){if(!(h||x.aborted||F.active||de||X||!he&&!Z(x))){if(he=!0,(e.resumeCheckout||e.terminateCheckout)&&nt()){L=e.client.view,ie();return}await be()}}};if(W){let f=await W.adopt(n,{options:re,handoff:ee,start:()=>cn(e.client)});f&&Z(x)&&!h?(We(n),q=f,j?.active&&j.present(()=>{}),M=r,Ee=W.modal,ve(),Le.report(r),F.active&&q.setSuspended(!0)):(f?.destroy(),s())}if(h||ue)return;if(!q){if(oe=je(!0,n.locale,g),h||ue)return;We(n);let f=await $(R,re,ee).catch(fe=>(ge(fe,x),null));!Z(x)&&!(he&&!h&&!x.aborted)?f?.host?.destroy():f&&(q=f.host,q?.setSuspended(F.active))}}if(h||ue)return;ve();let D=n.instruction;if(D&&(D.type==="open_url"||D.type==="event")&&!Je.has(D.receiptId)){let U=m.createElement("button");U.type="button",U.style.cssText=te.primary,Me(U,()=>te.focus),R.style.cssText=te.stage,U.textContent=D.type==="open_url"?`${G?"\u524D\u5F80":"Continue to"} ${new URL(D.url).host}`:G?"\u7EE7\u7EED":"Continue",U.onclick=()=>{let g=ke(),W=D.type==="open_url"&&!e.onOpenUrl&&D.openIn==="new_window"?Zn(D.url):null;Fe(async()=>{let oe="success";if(D.type==="open_url")if(e.onOpenUrl)try{oe=await e.onOpenUrl({receiptId:D.receiptId,url:D.url,openIn:D.openIn})===!1?"failed":"opened"}catch(re){Ce(e.onError,re),oe="failed"}else oe=D.openIn==="new_window"&&!W?"failed":"opened";if(D.type==="event"){if(!e.onEvent)throw new y("EVENT_HANDLER_REQUIRED","Provide the event handler");await e.onEvent(D.event)}if(h||e.client.view?.nodeId!==g.nodeId||e.client.view.visit!==g.visit)throw new y("PRECONDITION_FAILED","The client action visit changed");let x=await e.client.submit({operation:"submit",...g,input:{type:"client_action",receiptId:D.receiptId,outcome:oe}});return Je.add(D.receiptId),D.type==="open_url"&&!e.onOpenUrl&&D.openIn==="same_window"&&m.defaultView?.location.assign(D.url),x})},j?.active?j.present(()=>R.replaceChildren(U)):R.replaceChildren(U)}!n.pendingRequest&&n.status==="completed"&&!Je.has(`complete:${n.id}`)&&(Je.add(`complete:${n.id}`),Ce(e.onComplete,structuredClone(n))),He()}function Zn(n){let r=m.defaultView?.open(n,"_blank")??null;return r&&(r.opener=null),r}function ye(n){return ve(),tn=tn.catch(()=>{}).then(async()=>{try{await Xn(n)}catch(r){throw j?.active&&(xe=Be(n),j.finish("error",r),Ie(),o.hidden=!0),r}}),tn}let Kn=e.client.subscribe(n=>{if(!mn){if(n.stopped&&(Ee||_())&&!he){L=n,ie();return}!he&&(n.stopped||e.client.configurationReady===!1||B&&M!==B&&(Ne(n)!==B||["closed","ineligible","failed"].includes(n.status)))&&(Ie(),j?.finish("dismissed"),o.hidden=!0),ye(n).catch(pe)}}),et=e.client.subscribeError?.(pe);function nt(){let n=e.client.view,r=n?.paywall;return!!r?.operation&&!!n&&["running","waiting"].includes(n.status)&&Dn(Ve({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect}))}function be(n){if(qe)return qe;if(h||!n&&(de||X))return Promise.resolve();let r=!n&&Qe();return!r&&e.client.view&&!["running","waiting"].includes(e.client.view.status)?(L=e.client.view,ie(),Promise.resolve()):(qe=Fe(async()=>{let p=r?await e.client.retry():await e.client.submit({operation:"close",...n??ke()});return n&&yn(p),p},!0).then(()=>{let p=e.client.view;p?.status==="closed"&&!Qe()&&(L=p,ie())}).finally(()=>{qe=null}),qe)}function ie(){ne?.destroy(),!h&&(h=!0,N(),s(),e.signal?.removeEventListener("abort",ie),d?.removeEventListener("abort",ie),j?.finish("dismissed"),wn.destroy(),Kn(),et?.(),Ie(),an(),F.stop(),S.remove(),o.remove(),V(),Ce(e.onDismiss,L?structuredClone(L):null))}z.onclick=()=>{if(!z.disabled){if(F.active){F.exit();return}Fe(()=>e.client.submit({operation:"back",...ke()}))}},J.onclick=()=>{F.open()},T.onclick=()=>{j?.active?j.dismiss():de||be()},O.onclick=()=>{Qe()?be():Fe(()=>e.client.retry())},S.addEventListener("cancel",n=>{n.preventDefault(),j?.active?j.dismiss():de||be()}),e.signal?.addEventListener("abort",ie,{once:!0}),d?.addEventListener("abort",ie,{once:!0});let Ye=!1;w&&(N=w.onClose(()=>{h||ue||(ue=!0,j?.finish("dismissed"),Ie(),o.hidden=!0,e.client.view?be().finally(ie):Ye=!0)}));let bn={destroy:ie,refresh:on,get recovery(){let n=rn();if(n)return n;if(!h&&!le&&!he&&!de&&q){let r=q.recovery;if(r.type!=="native")return r}return{type:"recover",operationId:e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??X?.operationId??null,requestId:e.client.pendingCommand?.requestId??null}},prepareFallback(){if(de)return de;let n=rn();if(n)return Promise.resolve(n);let r=e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??X?.operationId??null,p=()=>({type:"recover",operationId:r,requestId:e.client.pendingCommand?.requestId??null});if(e.client.hasDurableJournal!==!0){let D=q?.recovery;return Promise.resolve(D&&D.type!=="native"&&D.type!=="cancel"?D:p())}let H=(e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[])).some(D=>D.operation==="close");if(h&&!(H||X&&e.client.view?.status==="closed")||le||$e||qe||F.active||!q&&!X&&!H)return Promise.resolve(p());let ae=q,Z=(async()=>{try{if(!X&&H){let g=await e.client.retry();return await ye(e.client.view??g.run),p()}if(!X){let g=await ae.prepareFallback();if(g.type!=="native")return g;if(e.client.hasDurableJournal!==!0)return p();X=g}let D=e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[]);if(D.length){let g=D.find(oe=>oe.operation==="close");if(!g||!K||g.requestId!==K.requestId)return p();let W=await e.client.retry();yn(W),await ye(e.client.view??W.run)}else{let g=e.client.view,W=g?.paywall;if(!g||!W||W.selectionGeneration===void 0||(W.quote?.operationId??null)!==X.operationId||X.operationId!==null&&W.canReselect!==!0)return p();let oe=W.selectionGeneration,x=await e.client.get();await ye(e.client.view??x.run);let re=e.client.view,ee=re?.paywall;if(!re||!ee||!["running","waiting"].includes(re.status)||re.stopped||re.id!==g.id||re.nodeId!==g.nodeId||re.visit!==g.visit||ee.receiptId!==W.receiptId||ee.selectionGeneration!==oe||(ee.quote?.operationId??null)!==X.operationId||X.operationId!==null&&ee.canReselect!==!0||e.client.pendingPurchase||(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0)))return p();let f=ke();K={runId:re.id,operationId:X.operationId,revision:f.revision,requestId:f.requestId,nodeId:re.nodeId,visit:re.visit,receiptId:ee.receiptId,selectionGeneration:oe,acknowledged:!1},await be(f)}let U=rn();return U?(ie(),U):p()}catch(D){return pe(D),p()}})();de=Z;let ge=()=>{de===Z&&(de=null)};return Z.then(ge,ge),Z},review:F.open,exitReview:F.exit,get unappliedDrafts(){return F.drafts}};try{let n=e.client.view;if(n)((e.client.viewAgeMs??pn)>=pn||n.instruction?.type==="evaluate_segment")&&(nn=on().finally(()=>{nn=null})),await ye(n);else{if(o.hidden=!0,h)throw new DOMException("Presentation cancelled","AbortError");let r=Ye||e.prepared?.state==="shown"?null:je(e.client.view?.screen?.presentation.type!=="inline",e.client.view?.locale);if(h||ue&&!Ye)throw new DOMException("Presentation cancelled","AbortError");let p=e.client.get(),H=await(r?r.wait(p,Se):ot(p,Se));if(mn=!1,Ye)return h||await be().finally(ie),bn;await ye(e.client.view??H.run)}}catch(n){throw j?.finish("error",n),ie(),n}return bn}function ot(t,v){let C;return Promise.race([t,new Promise((e,w)=>{C=setTimeout(()=>w(new Error("Presentation data timed out")),v)})]).finally(()=>clearTimeout(C))}function Gt(t,v,C){return rt(t,v,C)}export{rt as a,Gt as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as o}from"./chunk-
|
|
1
|
+
import{b as o}from"./chunk-NOOIJXRN.js";var s=["input","output","cache_read","cache_write","reasoning","input_audio","output_audio"],n=o.string().regex(/.+\/.+/),e=o.number().min(-100),t=o.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),p=o.strictObject({input:t,output:t,cache_read:t.optional(),cache_write:t.optional(),reasoning:t.optional(),input_audio:t.optional(),output_audio:t.optional()}),i=(r,a)=>o.record(r,a).refine(c=>Object.keys(c).length<=100,"At most 100 AI overrides"),d=o.strictObject({defaultMarkup:e,providerMarkups:i(o.string().min(1),e),modelMarkups:i(n,e),customModels:i(n,p.partial())});export{s as a,n as b,e as c,p as d,d as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as et,B as fe,F as tt,c as Be,d as Je,e as we,i as qe,j as He,k as $e,o as Ke,r as We}from"./chunk-G7Y7LPOB.js";import{a as Xe}from"./chunk-GEPX4AUR.js";import{c as Fe,d as Ne,e as Te,f as _e,g as Le,i as De,m as Me,n as k,o as ke,q as ye,r as N,t as Ge,u as je,v as ze}from"./chunk-Y5RT7PAD.js";import{I as he,J as Ve,aa as D,u as Ue}from"./chunk-KQF4BVOL.js";import{a as de,b as Qe}from"./chunk-WP3SZU24.js";import{a as ce}from"./chunk-4E326NPY.js";import{J as le}from"./chunk-HJVEVJXS.js";import{b as oe}from"./chunk-K3VQKR4G.js";import{a as L}from"./chunk-O5VA3E5D.js";import{b as Ze}from"./chunk-3VUPVXAV.js";import{b as Ye}from"./chunk-EEYDOVVS.js";import{b as e}from"./chunk-42UXYMRZ.js";import{c as Ae,f as Pe}from"./chunk-O4KXODTJ.js";var G=e.literal(Ue),ft=e.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/),Ie=e.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),nt=e.discriminatedUnion("type",[e.strictObject({type:e.literal("guest"),guestToken:Ie}),e.strictObject({type:e.literal("customer"),customer:he,customerData:Ve.optional()})]),ve=e.strictObject({id:e.uuid(),runId:e.uuid(),customerId:e.uuid(),requestId:e.uuid(),acceptedAt:e.iso.datetime({offset:!0})}),mt=e.strictObject({participantId:e.uuid(),startedAs:e.enum(["guest","identified"]),binding:ve.omit({runId:!0,requestId:!0}).nullable()}),pt=e.union([Be,e.strictObject({type:e.literal("authentication_required"),reason:e.enum(["customer_required","customer_experiment_required"]),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative()})]),gt=Je.omit({authenticated:!0}).extend({identity:mt,instruction:pt.nullable()}),ht=e.discriminatedUnion("operation",[D.options[2].omit({customerToken:!0}),D.options[3].omit({customerToken:!0}),D.options[4].omit({customerToken:!0}),D.options[5].omit({customerToken:!0}),D.options[6].omit({customerToken:!0}),D.options[7].omit({customerToken:!0})]),me={contract:G,customerToken:e.string().regex(ce)},rt={contract:G,requestId:e.uuid(),runToken:ft,externalUserId:he.options[1].shape.value},ot=e.discriminatedUnion("operation",[e.strictObject({contract:G,operation:e.literal("describe")}),e.strictObject({contract:G,operation:e.literal("start"),source:nt,funnelId:D.options[0].shape.funnelId,requestId:e.uuid(),locale:D.options[0].shape.locale,parameters:D.options[0].shape.parameters}),qe.omit({operation:!0}).extend({contract:G,operation:e.literal("entry_start"),source:nt}),e.strictObject({...rt,operation:e.literal("bind_customer"),guestToken:Ie,claimRequestId:e.uuid(),expectedBindingId:e.null()}),e.strictObject({...rt,operation:e.literal("binding_status"),guestToken:Ie.optional()}),D.options[1].omit({operation:!0,customerToken:!0}).extend({...me,operation:e.literal("get"),settlementBindingId:e.uuid().nullable().optional()}),D.options[8].omit({operation:!0,customerToken:!0}).extend({...me,operation:e.literal("review")}),$e.omit({customerToken:!0}).extend(me),e.strictObject({...me,operation:e.literal("command"),identity:e.strictObject({bindingId:e.uuid().nullable()}),command:ht})]),yt=we.omit({run:!0}).extend({contract:G,run:gt,settlement:we.shape.settlement.unwrap().extend({accepted:e.boolean().nullable().optional()}).optional()}),Nt=He.extend({contract:G}),Tt=e.discriminatedUnion("operation",[ot.options[1].omit({contract:!0,source:!0,requestId:!0}),ot.options[2].omit({contract:!0,source:!0,requestId:!0})]),_t=yt.extend({binding:ve,outcome:e.enum(["bound","already_bound"]),replayed:e.boolean()}),Lt=e.discriminatedUnion("state",[e.strictObject({contract:G,scope:oe,state:e.literal("not_accepted")}),e.strictObject({contract:G,scope:oe,state:e.literal("conflict")}),e.strictObject({contract:G,scope:oe,state:e.literal("bound"),binding:ve})]),Dt=e.strictObject({contract:G,scope:oe,keyId:e.uuid(),operations:e.array(e.string()).max(20)});var it=e.string().regex(/^[a-f0-9]{64}$/),wt=Fe.omit({variations:!0,active:!0}).extend({changeId:it,variations:e.array(e.strictObject({urlRedirect:e.string().max(2048)})).min(2).max(20)}),at=e.strictObject({environmentId:e.uuid(),trackExposures:e.boolean(),generation:it,experiments:e.array(wt).max(100),savedGroups:Ne}),It=e.strictObject({eventUuid:e.uuid(),timestamp:e.iso.datetime({offset:!0}).optional(),deviceId:e.string().min(1).max(128),sessionId:e.string().min(1).max(128).optional(),url:e.url().max(2048),pageTitle:e.string().max(512).optional(),experimentKey:e.string().min(1).max(255),variationKey:e.string().min(1).max(64)}),kt=e.strictObject({events:e.array(It).min(1).max(20)}),Gt=e.strictObject({inserted:e.number().int().nonnegative(),duplicates:e.number().int().nonnegative(),skipped:e.number().int().nonnegative(),rejected:e.array(e.strictObject({index:e.number().int().nonnegative(),reason:e.string()}))});function Ht(r){let o=null,f=null,E=0,b=0,C=new Set,c=null,y=null,d=new Set,v=()=>{for(let s of d)try{s()}catch{}},l={attributes:le.parse(r.attributes??{}),onFeatureUsage:r.onFeatureUsage?(s,w)=>{!C.has(s)&&o&&(!("analyticsConfig"in o)||o.analyticsConfig.featureUsageEnabled)&&r.onFeatureUsage(s,structuredClone(w),structuredClone(l.attributes),o.generation)}:void 0,onExperimentViewed:r.onExperimentViewed?(s,w)=>o&&(!("analyticsConfig"in o)||o.analyticsConfig.experimentViewsEnabled)&&r.onExperimentViewed(structuredClone(s),structuredClone(w),structuredClone(l.attributes),o.generation):void 0,stickyBucketAssignmentDocs:structuredClone(r.stickyBucketAssignmentDocs),saveStickyBucketAssignmentDoc:r.saveStickyBucketAssignmentDoc?s=>r.saveStickyBucketAssignmentDoc(structuredClone(s)):void 0,trackedFeatureUsage:{},trackedExperiments:new Set},S=()=>({value:null,source:"unknownFeature",on:!1,off:!0,ruleId:""});function p(s,w=new Set){return C.has(s)?!c||!c.features[s]||["unknownFeature","cyclicPrerequisite"].includes(c.features[s].source):w.has(s)?!1:(w.add(s),(o?.features[s]?.rules??[]).some(O=>[...O.parentConditions??[],...(O.tracks??[]).flatMap(A=>A.experiment.parentConditions??[])].some(A=>p(A.id,w))))}let x=s=>{if(r.assertUsable?.(o?.generation),!o)throw new Error("Initialize the Feature client before evaluation");if(o.expiresAt&&Date.parse(o.expiresAt)<=Date.now())throw new Error("Feature configuration expired; refresh before evaluation");return c?.expiresAt&&Date.parse(c.expiresAt)<=Date.now()&&(c=null,l.features=o.features),C.has(s)?!c||c.expiresAt&&Date.parse(c.expiresAt)<=Date.now()?S():structuredClone(c.features[s]??S()):r.evaluateRemote&&(l.attributes?.merchandise||l.attributes?.merchandiseId)&&!c||p(s)?S():structuredClone(Pe(s,l))};async function U(){if(!o||!C.size&&!l.attributes?.merchandise&&!l.attributes?.merchandiseId)return;if(!r.evaluateRemote){if(C.size)throw new Error("Remote Feature evaluation requires a server loader");return}let s=b;if(y?.revision===s)return y.loading;let w=E,O=o,A=[...C],R=(async()=>{let h=De.parse(await r.evaluateRemote({attributes:structuredClone(l.attributes),features:A}));if(!(w!==E||s!==b||O!==o)){if(r.assertUsable?.(O.generation),h.generation!==O.generation)throw new Error("Feature configuration changed; refresh before evaluation");if(A.some(P=>!Object.hasOwn(h.features,P))||Object.keys(h.features).some(P=>!C.has(P)))throw new Error("Invalid remote Feature results");if(l.attributes?.merchandise||l.attributes?.merchandiseId){if(!h.merchandiseContext)throw new Error("Server did not resolve merchandise context");l.attributes=le.parse({...l.attributes,...h.merchandiseContext})}c=structuredClone(h),l.features={...O.features,...Object.fromEntries(Object.entries(c.features).map(([P,z])=>[P,{defaultValue:z.value}]))},v()}})();y={revision:s,loading:R};try{await R}finally{y?.loading===R&&(y=null)}}function T(){U().catch(s=>{try{r.onError?.(s)}catch{}})}async function M(){if(f)return f;let s=E,w=(async()=>{let O=await r.load(),A="remoteFeatures"in O?_e.parse(O):null,R=A??Te.parse(O);if(R.scope.projectId!==r.scope.projectId||R.scope.environment!==r.scope.environment)throw new Error("Feature payload scope changed");if(s!==E)throw new Error("Feature client was reset");if(r.assertUsable&&o?.generation===R.generation){let{evaluatedAt:P,expiresAt:z,...ie}=o,{evaluatedAt:Y,expiresAt:pe,...j}=R;if(N(ie)!==N(j))throw new Error("Immutable Feature generation changed content");return o.evaluatedAt=R.evaluatedAt,o.expiresAt=R.expiresAt,v(),(!c||c.expiresAt&&Date.parse(c.expiresAt)<=Date.now())&&T(),structuredClone(o)}let h=new Set(A?.remoteFeatures??[]);if([...h].some(P=>Object.hasOwn(R.features,P)))throw new Error("Remote Feature definitions must not be delivered locally");return o&&"analyticsConfig"in o&&"analyticsConfig"in R&&!o.analyticsConfig.experimentViewsEnabled&&A?.analyticsConfig.experimentViewsEnabled&&l.trackedExperiments?.clear(),o=structuredClone(R),C=h,c=null,y=null,b++,l.features=o.features,l.savedGroups=Ae(o.savedGroups),l.trackedFeatureUsage={},v(),T(),structuredClone(o)})();f=w;try{return await w}finally{f===w&&(f=null)}}return{init:M,refresh:M,refreshRemote:U,get generation(){return o?.generation??null},get expiresAt(){return o?.expiresAt??null},subscribe(s){return d.add(s),()=>{d.delete(s)}},setAttributes(s){let w=le.parse(s);(l.attributes?.merchandise||l.attributes?.merchandiseId||s.merchandise||s.merchandiseId)&&l.trackedExperiments?.clear(),l.attributes=w,b++,c=null,y=null,l.features=o?.features??{},l.trackedFeatureUsage={},v(),T()},evalFeature:x,isOn(s){return x(s).on},isOff(s){return x(s).off},getFeatureValue(s,w){let O=x(s).value;return structuredClone(O===null?w:O)},reset(){E++,b++,f=null,y=null,o=null,c=null,C.clear(),l.features={},l.savedGroups={},l.stickyBucketAssignmentDocs={},l.attributes={},l.trackedFeatureUsage={},l.trackedExperiments?.clear(),v()}}}var vt=e.record(e.string().regex(/^[a-f0-9]{64}$/),e.strictObject({at:e.number(),text:e.string()})),K=2*1048576,bt=100;function St(){try{return typeof window>"u"?void 0:window.localStorage}catch{return}}function st(r,o){let f=o===void 0?St():o,E=new Map,b=0,C=!1,c=!1,y,d;async function v(S){if(!f)return null;let p;try{let x=await Promise.race([Promise.resolve().then(()=>f.getItem(S)),new Promise(U=>{p=setTimeout(()=>U(null),bt)})]);return typeof x=="string"&&x.length<=K&&new TextEncoder().encode(x).byteLength<=K?x:null}catch{return null}finally{clearTimeout(p)}}function l(){if(d)return d;let S=(async()=>{try{let p=await v(`${r}:artifacts`);if(p)return vt.parse(JSON.parse(p))}catch{}return{}})();return d=S,S.finally(()=>{d===S&&(d=void 0)}),S}return{async readManifest(){return v(r)},writeManifest(S){!f||S.length>K||new TextEncoder().encode(S).byteLength>K||(y=S,!c&&(c=!0,Promise.resolve().then(async()=>{try{for(;y!==void 0;){let p=y;try{await f.setItem(r,p)}catch{}y===p&&(y=void 0)}}finally{c=!1}})))},async readArtifact(S){let p=(await l())[S],x=Date.now();return p&&x>=p.at&&x-p.at<=k.retentionMs?p.text:void 0},writeArtifact(S,p){if(!f||p.length>K)return;let x=E.get(S);if(x?.text===p||!x&&E.size>=128)return;let U=new TextEncoder().encode(p).byteLength;b-(x?.byteLength??0)+U>K||(E.set(S,{text:p,byteLength:U}),b+=U-(x?.byteLength??0),!C&&(C=!0,Promise.resolve().then(async()=>{try{for(;E.size;){let T=new Map(E);try{let M={...await l()},s=Date.now();for(let[R,h]of T)M[R]={at:s,text:h.text};let w={},O=2,A=0;for(let[R,h]of Object.entries(M).sort(([,P],[,z])=>z.at-P.at)){if(h.at>s||s-h.at>k.retentionMs)continue;let P=new TextEncoder().encode(JSON.stringify({[R]:h})).byteLength;O+P>K||A>=128||(w[R]=h,O+=P,A++)}await f.setItem(`${r}:artifacts`,JSON.stringify(w))}catch{}finally{for(let[M,s]of T)E.get(M)===s&&(E.delete(M),b-=s.byteLength)}}}finally{C=!1}})))}}}var u=(r,o)=>new L(r,o),q=()=>performance.now(),ut=r=>{typeof r=="object"&&"unref"in r&&r.unref()};function ln(r){let o=ke.parse(r.scope),f=new de(r.origin??Ye);if(f.username||f.password||f.search||f.hash||f.pathname!=="/"||f.protocol!=="https:"&&!(f.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(f.hostname)))throw u("INVALID_URL","Configuration requires a trusted HTTPS origin");let E=new Set([f.origin,...(r.assetOrigins??[]).map(n=>{let t=new de(n);if(t.protocol!=="https:"||t.username||t.password||t.search||t.hash||t.pathname!=="/")throw u("INVALID_URL","Invalid configuration asset origin");return t.origin})]),b=r.fetch??globalThis.fetch.bind(globalThis),C=`/api/v1/configuration/${o.environmentId}`,c=`indiana:configuration:1:${f.origin}:${N(o)}`,y=st(c,r.storage),d,v=0,l=0,S=!1,p=!1,x=0,U=0,T,M,s,w,O=0,A=new Set,R=new Set,h=new Map,P=new Map,z=0,ie=!1;function Y(){for(let n of A)try{n()}catch{}}function pe(n){try{r.onError?.(n)}catch{}}let j=()=>!p&&!S&&!!d&&q()<v&&Date.now()<l;function ne(){if(!j())throw u("CONFIGURATION_EXPIRED","Refresh configuration before using it")}function be(n,t,i){if(!h.has(n)){for(;h.size&&(h.size>=128||z+i>k.maxCacheBytes);){let a=h.entries().next().value;z-=a[1].byteLength,h.delete(a[0])}h.set(n,{text:t,byteLength:i}),z+=i}}function Se(n,t,i){return Ze(n,t,{signal:i,error:a=>u("INVALID_RESPONSE",a==="missing"?"Configuration body is missing":"Configuration exceeds its byte limit")})}function xe(n){let t=new de(n,f);if(!E.has(t.origin)||t.username||t.password||t.hash||t.search)throw u("INVALID_URL","Configuration artifact origin is not trusted");return t.href}async function ge(n,t,i=!1){let a=await b(xe(n),{method:"GET",credentials:"omit",redirect:"error",cache:i?"default":"no-cache",signal:t,headers:{}});if(a.status===429){let g=a.headers.get("retry-after")??"";O=/^\d+$/.test(g)?Number(g)*1e3:Math.max(0,Date.parse(g)-Date.now())||15e3}if(!a.ok&&a.status!==304)throw u(`CONFIGURATION_HTTP_${a.status}`,"Configuration synchronization failed");return a}function lt(n,t,i){let a=Date.parse(n.headers.get("x-indiana-config-validated-at")??""),g=Date.parse(n.headers.get("x-indiana-config-valid-until")??""),I=Date.parse(n.headers.get("date")??""),m=n.headers.get("age"),V=m!==null&&/^\d+(\.\d+)?$/.test(m)?Number(m)*1e3:NaN;if(![a,g,I,V].every(Number.isFinite)||g<=a||g-a>k.maxControlAgeMs||a>I+1e3)throw u("INVALID_RESPONSE","Configuration freshness evidence is invalid");let F=Math.min(g-a,i.maxControlAgeSeconds*1e3,k.maxControlAgeMs)-Math.max(V,I-a,0)-(q()-t);if(F<=0)throw u("CONFIGURATION_EXPIRED","Configuration validation expired in transit");return q()+F}function ae(){if(clearTimeout(s),clearTimeout(w),p||!A.size||(j()&&(w=setTimeout(()=>{j()?ae():Y()},Math.max(1,v-q())),ut(w)),typeof document<"u"&&document.visibilityState==="hidden"))return;let n=U?Math.min(15e3,1e3*2**Math.min(U-1,4)):Math.min(15e3,(d?.policy.refreshIntervalSeconds??15)*1e3);s=setTimeout(()=>{Q().catch(pe)},Math.max(O,n*(.8+Math.random()*.2))),ut(s)}async function Q(){if(p)throw u("CONFIGURATION_DISPOSED","Configuration manager was destroyed");if(T)return T;let n=x,t=new AbortController;M=t;let i=(async()=>{if(!ie){ie=!0;try{let ue=await y.readManifest();if(ue&&!d){let J=ye.parse(JSON.parse(ue));N(J.scope)===N(o)&&(d=J)}}catch{}}t.signal.throwIfAborted();let m=d,V=q(),_=await ge(C,t.signal);_.status===304&&(!m||!_.headers.has("x-indiana-config-validated-at")||!_.headers.has("x-indiana-config-valid-until")||!_.headers.has("age"))&&(_=await ge(C,t.signal));let F=_.status===304?m:ye.parse(JSON.parse(await Se(_,k.maxManifestBytes,t.signal))),{generation:ee,...te}=F,B=_.headers.get("etag");if(N(F.scope)!==N(o)||Ge(te)!==ee||B!==`"${ee}"`&&B!==`W/"${ee}"`)throw u("INVALID_RESPONSE","Configuration scope or content identity changed");if(m&&(F.revision<m.revision||F.revision===m.revision&&F.generation!==m.generation))throw u("INVALID_RESPONSE","Configuration revision moved backwards or changed identity");for(let[ue,J]of Object.entries(m?.funnels??{})){let $=F.funnels[ue];if($&&($.controlRevision<J.controlRevision||$.evaluationRevision<J.evaluationRevision||$.controlRevision===J.controlRevision&&$.state!==J.state||$.evaluationRevision===J.evaluationRevision&&$.evaluationMode!==J.evaluationMode))throw u("INVALID_RESPONSE","Funnel control revision changed identity")}let H=lt(_,V,F.policy);if(t.signal.throwIfAborted(),n!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return d=F,v=H,l=Date.now()+Math.max(0,H-q()),S=!1,U=0,O=0,y.writeManifest(N(F)),Y(),structuredClone(F)})(),a=setTimeout(()=>t.abort(u("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),k.initializationMs),g=new Promise((m,V)=>t.signal.addEventListener("abort",()=>V(t.signal.reason),{once:!0})),I=Promise.race([i,g]).catch(m=>{throw U++,(m instanceof e.ZodError||m instanceof SyntaxError||m instanceof L&&["CONFIGURATION_HTTP_404","CONFIGURATION_HTTP_410","INVALID_RESPONSE"].includes(m.code))&&(v=0,S=!0,Y()),m}).finally(()=>{clearTimeout(a),T===I&&(T=void 0),ae()});return T=I,I}async function se(n){let t=n.sha256,i=te=>Xe(te,n);xe(n.url);let a=h.get(t);if(a){if(a.byteLength!==n.byteLength)throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return h.delete(t),h.set(t,a),a.text}let g=P.get(t);if(g){if(g.byteLength!==n.byteLength)throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return g.promise}let I=new AbortController;R.add(I);let m=x,V=(async()=>{try{let H=await y.readArtifact(t);if(H&&i(H)){if(I.signal.throwIfAborted(),p||m!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return be(t,H,n.byteLength),H}}catch{}I.signal.throwIfAborted();let te=await ge(n.url,I.signal,!0),B=await Se(te,n.byteLength,I.signal);if(!i(B))throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");if(p||m!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return be(t,B,n.byteLength),y.writeArtifact(t,B),B})(),_=setTimeout(()=>I.abort(u("CONFIGURATION_UNAVAILABLE","Configuration artifact timed out")),k.initializationMs),F=new Promise((te,B)=>I.signal.addEventListener("abort",()=>B(I.signal.reason),{once:!0})),ee=Promise.race([V,F]).finally(()=>{clearTimeout(_),R.delete(I),P.delete(t)});return P.set(t,{promise:ee,byteLength:n.byteLength}),ee}async function re(){return j()||await Q(),ne(),d}async function W(n){let t,i=new Promise((a,g)=>{t=setTimeout(()=>g(u("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),k.initializationMs)});try{return await Promise.race([n(),i])}finally{clearTimeout(t)}}function Z(n,t){if(ne(),d?.generation!==n.generation)throw u("CONFIGURATION_CHANGED","Configuration changed while preparing a snapshot");if(t&&d.funnels[t]?.state!=="active")throw u("FUNNEL_STOPPED","Funnel is paused or unavailable")}async function Ee(n){let t=n.gb.features;if(!t)throw u("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");let i=n.artifacts[t];if(i.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Unsupported public GB configuration format");let a=Le.parse(JSON.parse(await se(i)));if(N(a.scope)!==N({projectId:o.projectId,environment:o.environment})||a.generation!==i.generation||a.remoteFeatures.some(g=>Object.hasOwn(a.features,g)))throw u("INVALID_RESPONSE","Public GB configuration scope or generation is invalid");return Z(n),{...a,evaluatedAt:new Date().toISOString(),expiresAt:new Date(Date.now()+Math.max(0,v-q())).toISOString()}}async function Ce(n,t){let i=await re(),a=i.funnels[n];t&&(!a||a.evaluationMode==="local"&&!a.versions[t])&&(T&&await T,i=await Q()),Z(i,n);let g=i.funnels[n];if(g.evaluationMode!=="local")throw u("EVALUATION_MODE","This Funnel executes at Longplay; public graph loading is disabled");let I=t??g.currentVersionId,m=g.versions[I];if(!m)throw u("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable");if(i.artifacts[m.artifact].formatVersion!==3)throw u("UNSUPPORTED_SCHEMA","Unsupported public Funnel format");let[V,_]=await Promise.all([se(i.artifacts[m.artifact]).then(F=>ze(JSON.parse(F))),g.evaluationMode==="local"?Ee(i):void 0]);if(_&&N(je(V,_))!==N(m.dependencies))throw u("INVALID_RESPONSE","Funnel and GB dependency contract do not match");return Z(i,n),{document:V,growth:_,versionId:I,control:structuredClone(g),manifest:structuredClone(i)}}async function Re(n,t){try{return await Ce(n,t)}catch(i){if(!(i instanceof L)||!(i.code==="CONFIGURATION_CHANGED"||i.code==="CONFIGURATION_HTTP_404"&&j()))throw i;let a=d?.generation;if(T&&await T,await Q(),i.code!=="CONFIGURATION_CHANGED"&&d?.generation===a)throw i;return Ce(n,t)}}function X(){if(j()||Y(),typeof document<"u"&&document.visibilityState==="hidden"){ae();return}Q().catch(pe)}function dt(n){if(p)throw u("CONFIGURATION_DISPOSED","Configuration manager was destroyed");return A.add(n),A.size===1&&(typeof window<"u"&&(window.addEventListener("online",X),window.addEventListener("focus",X),document.addEventListener("visibilitychange",X)),ae()),()=>{A.delete(n),A.size||(clearTimeout(s),clearTimeout(w),Oe())}}function Oe(){typeof window<"u"&&(window.removeEventListener("online",X),window.removeEventListener("focus",X),document.removeEventListener("visibilitychange",X))}return{scope:Object.freeze({...o}),refresh:Q,subscribe:dt,assertFresh:ne,assertFeatures(n){ne();let t=d.gb.features;if(!t)throw u("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");if(n!==void 0&&d.artifacts[t].generation!==n)throw u("CONFIGURATION_CHANGED","Refresh changed Feature configuration before evaluation")},get fresh(){return j()},get snapshot(){return d?structuredClone(d):null},get remainingMs(){return j()?Math.max(0,v-q()):0},async features(){return W(async()=>Ee(await re()))},pageExperiments:()=>W(async()=>{let n=await re(),t=n.gb.pageExperiments;if(!t)throw u("CONFIGURATION_UNAVAILABLE","Public page experiments are disabled");let i=n.artifacts[t];if(i.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Unsupported page experiment format");let a=at.parse(JSON.parse(await se(i)));if(a.environmentId!==o.environmentId||a.generation!==i.generation)throw u("INVALID_RESPONSE","Page experiment scope or generation changed");return Z(n),a}),funnel:(n,t)=>W(()=>Re(n,t)),funnelControl:n=>W(async()=>{let t=await re();return Z(t,n),structuredClone(t.funnels[n])}),paywall:(n,t)=>W(async()=>{let i=await re(),a=i.paywalls?.[n];if(!a||!t&&a.state!=="published")throw u("PAYWALL_UNAVAILABLE","Published Paywall is unavailable");let g=t??a.currentVersionId,I=a.versions[g],m=I&&i.artifacts[I.artifact];if(!m||m.kind!=="paywall"||m.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Public Paywall format is unavailable");let V=Me.parse(JSON.parse(await se(m)));return Z(i),{document:V,versionId:g,version:I.version,control:structuredClone(a),manifest:structuredClone(i)}}),async localFunnel(n,t){let i=await W(()=>Re(n,t));if(!i.growth)throw u("EVALUATION_MODE","This Funnel requires remote execution");let{analyticsConfig:a,remoteFeatures:g,...I}=i.growth;return Ke({scope:{projectId:o.projectId,environment:o.environment},funnelId:n,versionId:i.versionId,evaluationMode:"local",evaluationRevision:i.control.evaluationRevision,document:i.document,payload:I})},assertFunnel(n,t,i){ne();let a=d.funnels[n];if(!a||a.state!=="active")throw u("FUNNEL_STOPPED","Funnel is paused or unavailable");if(a.evaluationMode!=="local")throw u("EVALUATION_MODE","This Funnel now executes at Longplay");if(t!==void 0&&a.controlRevision!==t)throw u("RUN_RECONCILIATION_REQUIRED","Reconcile the original Run after a control change");if(i!==void 0&&!a.versions[i])throw u("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable")},destroy(){if(!p){p=!0,x++,v=0,M?.abort(u("CONFIGURATION_DISPOSED","Configuration manager was destroyed")),clearTimeout(s),clearTimeout(w),Oe(),Y(),A.clear();for(let n of R)n.abort(u("CONFIGURATION_DISPOSED","Configuration manager was destroyed"));h.clear(),z=0}}}}function ct(r){let o=ce.test(r.apiKey);if(typeof window<"u"&&!o)throw new L("SERVER_ONLY","Funnel starts are issued by your backend");if(!o&&!fe.test(r.apiKey))throw new L("INVALID_TOKEN","A customer credential or server API key is required");return{async start(f){let E=D.safeParse({...f,operation:"start"});if(!E.success||E.data.operation!=="start"||(o?E.data.customer!==void 0:E.data.customer===void 0))throw new L("INVALID_REQUEST","Invalid current Funnel start");let b=E.data,C=Qe({...r,timeoutMs:r.timeoutMs??35e3});try{r.session||C.identify(r.apiKey);let c=We(r,await C.request("funnels",b));if(!c.runToken)throw new L("INVALID_RESPONSE","Funnel start credentials are missing");if(c.run.source.id!==b.funnelId||c.run.locale!==(b.locale??"en")||!et(c.run.parameters,b.parameters??{})||(b.customer?!c.customerId||b.customer.type==="id"&&c.customerId!==b.customer.value:c.customerId!==void 0))throw new L("INVALID_RESPONSE","Funnel start contract changed");return{...c,runToken:c.runToken}}finally{C.dispose()}}}}async function En(r){r={...r};let o=r.configuration;if(!o)throw new L("CONFIGURATION_UNAVAILABLE","Local conditions require public configuration");let f={projectId:o.scope.projectId,environment:o.scope.environment};if(r.scope&&N(f)!==N(r.scope))throw new L("SCOPE_MISMATCH","Configuration and transport scopes differ");if((await o.funnelControl(r.funnelId)).evaluationMode!=="local")throw new L("EVALUATION_MODE","This Funnel uses Remote evaluation");let b=fe.test(r.credential);if(b?!r.customerId:r.customerId!==void 0)throw new L("INVALID_REQUEST","Only Server-Key starts name their Customer");let C=ct({...r,scope:f,apiKey:r.credential}),c=(y,d)=>{let v=tt({...r,scope:f,runToken:y,initialResponse:d,...b?{serverKey:r.credential}:{}});return b||v.identify(r.credential),v};return{async start(y){let d=await C.start({...y,funnelId:r.funnelId,...b?{customer:{type:"id",value:r.customerId}}:{}}),v=c(d.runToken,d),l=await v.get();return{...d,...l,controller:v}},async restore(y){let d=c(y),v=await d.get();if(v.run.source.id!==r.funnelId)throw d.reset(),new L("SCOPE_MISMATCH","Run belongs to another Funnel");return{...v,runToken:y,controller:d}}}}export{ot as a,yt as b,Nt as c,Tt as d,_t as e,Lt as f,Dt as g,Ht as h,ln as i,ct as j,En as k};
|
|
1
|
+
import{A as et,B as fe,F as tt,c as Be,d as Je,e as we,i as qe,j as He,k as $e,o as Ke,r as We}from"./chunk-N774V4SQ.js";import{a as Xe}from"./chunk-ONMIBSOC.js";import{c as Fe,d as Ne,e as Te,f as _e,g as Le,i as De,m as Me,n as k,o as ke,q as ye,r as N,t as Ge,u as je,v as ze}from"./chunk-W3G4YIM5.js";import{I as he,J as Ve,aa as D,u as Ue}from"./chunk-IYHXEKAD.js";import{a as de,b as Qe}from"./chunk-HFD4CLCJ.js";import{a as ce}from"./chunk-IGANLTKS.js";import{J as le}from"./chunk-BIT6YWM7.js";import{b as oe}from"./chunk-YURGISSB.js";import{a as L}from"./chunk-TPXRO63H.js";import{b as Ze}from"./chunk-3VUPVXAV.js";import{b as Ye}from"./chunk-JBVZ6A6V.js";import{b as e}from"./chunk-NOOIJXRN.js";import{c as Ae,f as Pe}from"./chunk-O4KXODTJ.js";var G=e.literal(Ue),ft=e.string().regex(/^gg_fr_[A-Za-z0-9_-]{43}$/),Ie=e.string().regex(/^gg_gc_[A-Za-z0-9_-]{43}$/),nt=e.discriminatedUnion("type",[e.strictObject({type:e.literal("guest"),guestToken:Ie}),e.strictObject({type:e.literal("customer"),customer:he,customerData:Ve.optional()})]),ve=e.strictObject({id:e.uuid(),runId:e.uuid(),customerId:e.uuid(),requestId:e.uuid(),acceptedAt:e.iso.datetime({offset:!0})}),mt=e.strictObject({participantId:e.uuid(),startedAs:e.enum(["guest","identified"]),binding:ve.omit({runId:!0,requestId:!0}).nullable()}),pt=e.union([Be,e.strictObject({type:e.literal("authentication_required"),reason:e.enum(["customer_required","customer_experiment_required"]),nodeId:e.string().min(1).max(64),visit:e.number().int().nonnegative()})]),gt=Je.omit({authenticated:!0}).extend({identity:mt,instruction:pt.nullable()}),ht=e.discriminatedUnion("operation",[D.options[2].omit({customerToken:!0}),D.options[3].omit({customerToken:!0}),D.options[4].omit({customerToken:!0}),D.options[5].omit({customerToken:!0}),D.options[6].omit({customerToken:!0}),D.options[7].omit({customerToken:!0})]),me={contract:G,customerToken:e.string().regex(ce)},rt={contract:G,requestId:e.uuid(),runToken:ft,externalUserId:he.options[1].shape.value},ot=e.discriminatedUnion("operation",[e.strictObject({contract:G,operation:e.literal("describe")}),e.strictObject({contract:G,operation:e.literal("start"),source:nt,funnelId:D.options[0].shape.funnelId,requestId:e.uuid(),locale:D.options[0].shape.locale,parameters:D.options[0].shape.parameters}),qe.omit({operation:!0}).extend({contract:G,operation:e.literal("entry_start"),source:nt}),e.strictObject({...rt,operation:e.literal("bind_customer"),guestToken:Ie,claimRequestId:e.uuid(),expectedBindingId:e.null()}),e.strictObject({...rt,operation:e.literal("binding_status"),guestToken:Ie.optional()}),D.options[1].omit({operation:!0,customerToken:!0}).extend({...me,operation:e.literal("get"),settlementBindingId:e.uuid().nullable().optional()}),D.options[8].omit({operation:!0,customerToken:!0}).extend({...me,operation:e.literal("review")}),$e.omit({customerToken:!0}).extend(me),e.strictObject({...me,operation:e.literal("command"),identity:e.strictObject({bindingId:e.uuid().nullable()}),command:ht})]),yt=we.omit({run:!0}).extend({contract:G,run:gt,settlement:we.shape.settlement.unwrap().extend({accepted:e.boolean().nullable().optional()}).optional()}),Nt=He.extend({contract:G}),Tt=e.discriminatedUnion("operation",[ot.options[1].omit({contract:!0,source:!0,requestId:!0}),ot.options[2].omit({contract:!0,source:!0,requestId:!0})]),_t=yt.extend({binding:ve,outcome:e.enum(["bound","already_bound"]),replayed:e.boolean()}),Lt=e.discriminatedUnion("state",[e.strictObject({contract:G,scope:oe,state:e.literal("not_accepted")}),e.strictObject({contract:G,scope:oe,state:e.literal("conflict")}),e.strictObject({contract:G,scope:oe,state:e.literal("bound"),binding:ve})]),Dt=e.strictObject({contract:G,scope:oe,keyId:e.uuid(),operations:e.array(e.string()).max(20)});var it=e.string().regex(/^[a-f0-9]{64}$/),wt=Fe.omit({variations:!0,active:!0}).extend({changeId:it,variations:e.array(e.strictObject({urlRedirect:e.string().max(2048)})).min(2).max(20)}),at=e.strictObject({environmentId:e.uuid(),trackExposures:e.boolean(),generation:it,experiments:e.array(wt).max(100),savedGroups:Ne}),It=e.strictObject({eventUuid:e.uuid(),timestamp:e.iso.datetime({offset:!0}).optional(),deviceId:e.string().min(1).max(128),sessionId:e.string().min(1).max(128).optional(),url:e.url().max(2048),pageTitle:e.string().max(512).optional(),experimentKey:e.string().min(1).max(255),variationKey:e.string().min(1).max(64)}),kt=e.strictObject({events:e.array(It).min(1).max(20)}),Gt=e.strictObject({inserted:e.number().int().nonnegative(),duplicates:e.number().int().nonnegative(),skipped:e.number().int().nonnegative(),rejected:e.array(e.strictObject({index:e.number().int().nonnegative(),reason:e.string()}))});function Ht(r){let o=null,f=null,E=0,b=0,C=new Set,c=null,y=null,d=new Set,v=()=>{for(let s of d)try{s()}catch{}},l={attributes:le.parse(r.attributes??{}),onFeatureUsage:r.onFeatureUsage?(s,w)=>{!C.has(s)&&o&&(!("analyticsConfig"in o)||o.analyticsConfig.featureUsageEnabled)&&r.onFeatureUsage(s,structuredClone(w),structuredClone(l.attributes),o.generation)}:void 0,onExperimentViewed:r.onExperimentViewed?(s,w)=>o&&(!("analyticsConfig"in o)||o.analyticsConfig.experimentViewsEnabled)&&r.onExperimentViewed(structuredClone(s),structuredClone(w),structuredClone(l.attributes),o.generation):void 0,stickyBucketAssignmentDocs:structuredClone(r.stickyBucketAssignmentDocs),saveStickyBucketAssignmentDoc:r.saveStickyBucketAssignmentDoc?s=>r.saveStickyBucketAssignmentDoc(structuredClone(s)):void 0,trackedFeatureUsage:{},trackedExperiments:new Set},S=()=>({value:null,source:"unknownFeature",on:!1,off:!0,ruleId:""});function p(s,w=new Set){return C.has(s)?!c||!c.features[s]||["unknownFeature","cyclicPrerequisite"].includes(c.features[s].source):w.has(s)?!1:(w.add(s),(o?.features[s]?.rules??[]).some(O=>[...O.parentConditions??[],...(O.tracks??[]).flatMap(A=>A.experiment.parentConditions??[])].some(A=>p(A.id,w))))}let x=s=>{if(r.assertUsable?.(o?.generation),!o)throw new Error("Initialize the Feature client before evaluation");if(o.expiresAt&&Date.parse(o.expiresAt)<=Date.now())throw new Error("Feature configuration expired; refresh before evaluation");return c?.expiresAt&&Date.parse(c.expiresAt)<=Date.now()&&(c=null,l.features=o.features),C.has(s)?!c||c.expiresAt&&Date.parse(c.expiresAt)<=Date.now()?S():structuredClone(c.features[s]??S()):r.evaluateRemote&&(l.attributes?.merchandise||l.attributes?.merchandiseId)&&!c||p(s)?S():structuredClone(Pe(s,l))};async function U(){if(!o||!C.size&&!l.attributes?.merchandise&&!l.attributes?.merchandiseId)return;if(!r.evaluateRemote){if(C.size)throw new Error("Remote Feature evaluation requires a server loader");return}let s=b;if(y?.revision===s)return y.loading;let w=E,O=o,A=[...C],R=(async()=>{let h=De.parse(await r.evaluateRemote({attributes:structuredClone(l.attributes),features:A}));if(!(w!==E||s!==b||O!==o)){if(r.assertUsable?.(O.generation),h.generation!==O.generation)throw new Error("Feature configuration changed; refresh before evaluation");if(A.some(P=>!Object.hasOwn(h.features,P))||Object.keys(h.features).some(P=>!C.has(P)))throw new Error("Invalid remote Feature results");if(l.attributes?.merchandise||l.attributes?.merchandiseId){if(!h.merchandiseContext)throw new Error("Server did not resolve merchandise context");l.attributes=le.parse({...l.attributes,...h.merchandiseContext})}c=structuredClone(h),l.features={...O.features,...Object.fromEntries(Object.entries(c.features).map(([P,z])=>[P,{defaultValue:z.value}]))},v()}})();y={revision:s,loading:R};try{await R}finally{y?.loading===R&&(y=null)}}function T(){U().catch(s=>{try{r.onError?.(s)}catch{}})}async function M(){if(f)return f;let s=E,w=(async()=>{let O=await r.load(),A="remoteFeatures"in O?_e.parse(O):null,R=A??Te.parse(O);if(R.scope.projectId!==r.scope.projectId||R.scope.environment!==r.scope.environment)throw new Error("Feature payload scope changed");if(s!==E)throw new Error("Feature client was reset");if(r.assertUsable&&o?.generation===R.generation){let{evaluatedAt:P,expiresAt:z,...ie}=o,{evaluatedAt:Y,expiresAt:pe,...j}=R;if(N(ie)!==N(j))throw new Error("Immutable Feature generation changed content");return o.evaluatedAt=R.evaluatedAt,o.expiresAt=R.expiresAt,v(),(!c||c.expiresAt&&Date.parse(c.expiresAt)<=Date.now())&&T(),structuredClone(o)}let h=new Set(A?.remoteFeatures??[]);if([...h].some(P=>Object.hasOwn(R.features,P)))throw new Error("Remote Feature definitions must not be delivered locally");return o&&"analyticsConfig"in o&&"analyticsConfig"in R&&!o.analyticsConfig.experimentViewsEnabled&&A?.analyticsConfig.experimentViewsEnabled&&l.trackedExperiments?.clear(),o=structuredClone(R),C=h,c=null,y=null,b++,l.features=o.features,l.savedGroups=Ae(o.savedGroups),l.trackedFeatureUsage={},v(),T(),structuredClone(o)})();f=w;try{return await w}finally{f===w&&(f=null)}}return{init:M,refresh:M,refreshRemote:U,get generation(){return o?.generation??null},get expiresAt(){return o?.expiresAt??null},subscribe(s){return d.add(s),()=>{d.delete(s)}},setAttributes(s){let w=le.parse(s);(l.attributes?.merchandise||l.attributes?.merchandiseId||s.merchandise||s.merchandiseId)&&l.trackedExperiments?.clear(),l.attributes=w,b++,c=null,y=null,l.features=o?.features??{},l.trackedFeatureUsage={},v(),T()},evalFeature:x,isOn(s){return x(s).on},isOff(s){return x(s).off},getFeatureValue(s,w){let O=x(s).value;return structuredClone(O===null?w:O)},reset(){E++,b++,f=null,y=null,o=null,c=null,C.clear(),l.features={},l.savedGroups={},l.stickyBucketAssignmentDocs={},l.attributes={},l.trackedFeatureUsage={},l.trackedExperiments?.clear(),v()}}}var vt=e.record(e.string().regex(/^[a-f0-9]{64}$/),e.strictObject({at:e.number(),text:e.string()})),K=2*1048576,bt=100;function St(){try{return typeof window>"u"?void 0:window.localStorage}catch{return}}function st(r,o){let f=o===void 0?St():o,E=new Map,b=0,C=!1,c=!1,y,d;async function v(S){if(!f)return null;let p;try{let x=await Promise.race([Promise.resolve().then(()=>f.getItem(S)),new Promise(U=>{p=setTimeout(()=>U(null),bt)})]);return typeof x=="string"&&x.length<=K&&new TextEncoder().encode(x).byteLength<=K?x:null}catch{return null}finally{clearTimeout(p)}}function l(){if(d)return d;let S=(async()=>{try{let p=await v(`${r}:artifacts`);if(p)return vt.parse(JSON.parse(p))}catch{}return{}})();return d=S,S.finally(()=>{d===S&&(d=void 0)}),S}return{async readManifest(){return v(r)},writeManifest(S){!f||S.length>K||new TextEncoder().encode(S).byteLength>K||(y=S,!c&&(c=!0,Promise.resolve().then(async()=>{try{for(;y!==void 0;){let p=y;try{await f.setItem(r,p)}catch{}y===p&&(y=void 0)}}finally{c=!1}})))},async readArtifact(S){let p=(await l())[S],x=Date.now();return p&&x>=p.at&&x-p.at<=k.retentionMs?p.text:void 0},writeArtifact(S,p){if(!f||p.length>K)return;let x=E.get(S);if(x?.text===p||!x&&E.size>=128)return;let U=new TextEncoder().encode(p).byteLength;b-(x?.byteLength??0)+U>K||(E.set(S,{text:p,byteLength:U}),b+=U-(x?.byteLength??0),!C&&(C=!0,Promise.resolve().then(async()=>{try{for(;E.size;){let T=new Map(E);try{let M={...await l()},s=Date.now();for(let[R,h]of T)M[R]={at:s,text:h.text};let w={},O=2,A=0;for(let[R,h]of Object.entries(M).sort(([,P],[,z])=>z.at-P.at)){if(h.at>s||s-h.at>k.retentionMs)continue;let P=new TextEncoder().encode(JSON.stringify({[R]:h})).byteLength;O+P>K||A>=128||(w[R]=h,O+=P,A++)}await f.setItem(`${r}:artifacts`,JSON.stringify(w))}catch{}finally{for(let[M,s]of T)E.get(M)===s&&(E.delete(M),b-=s.byteLength)}}}finally{C=!1}})))}}}var u=(r,o)=>new L(r,o),q=()=>performance.now(),ut=r=>{typeof r=="object"&&"unref"in r&&r.unref()};function ln(r){let o=ke.parse(r.scope),f=new de(r.origin??Ye);if(f.username||f.password||f.search||f.hash||f.pathname!=="/"||f.protocol!=="https:"&&!(f.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(f.hostname)))throw u("INVALID_URL","Configuration requires a trusted HTTPS origin");let E=new Set([f.origin,...(r.assetOrigins??[]).map(n=>{let t=new de(n);if(t.protocol!=="https:"||t.username||t.password||t.search||t.hash||t.pathname!=="/")throw u("INVALID_URL","Invalid configuration asset origin");return t.origin})]),b=r.fetch??globalThis.fetch.bind(globalThis),C=`/api/v1/configuration/${o.environmentId}`,c=`indiana:configuration:1:${f.origin}:${N(o)}`,y=st(c,r.storage),d,v=0,l=0,S=!1,p=!1,x=0,U=0,T,M,s,w,O=0,A=new Set,R=new Set,h=new Map,P=new Map,z=0,ie=!1;function Y(){for(let n of A)try{n()}catch{}}function pe(n){try{r.onError?.(n)}catch{}}let j=()=>!p&&!S&&!!d&&q()<v&&Date.now()<l;function ne(){if(!j())throw u("CONFIGURATION_EXPIRED","Refresh configuration before using it")}function be(n,t,i){if(!h.has(n)){for(;h.size&&(h.size>=128||z+i>k.maxCacheBytes);){let a=h.entries().next().value;z-=a[1].byteLength,h.delete(a[0])}h.set(n,{text:t,byteLength:i}),z+=i}}function Se(n,t,i){return Ze(n,t,{signal:i,error:a=>u("INVALID_RESPONSE",a==="missing"?"Configuration body is missing":"Configuration exceeds its byte limit")})}function xe(n){let t=new de(n,f);if(!E.has(t.origin)||t.username||t.password||t.hash||t.search)throw u("INVALID_URL","Configuration artifact origin is not trusted");return t.href}async function ge(n,t,i=!1){let a=await b(xe(n),{method:"GET",credentials:"omit",redirect:"error",cache:i?"default":"no-cache",signal:t,headers:{}});if(a.status===429){let g=a.headers.get("retry-after")??"";O=/^\d+$/.test(g)?Number(g)*1e3:Math.max(0,Date.parse(g)-Date.now())||15e3}if(!a.ok&&a.status!==304)throw u(`CONFIGURATION_HTTP_${a.status}`,"Configuration synchronization failed");return a}function lt(n,t,i){let a=Date.parse(n.headers.get("x-indiana-config-validated-at")??""),g=Date.parse(n.headers.get("x-indiana-config-valid-until")??""),I=Date.parse(n.headers.get("date")??""),m=n.headers.get("age"),V=m!==null&&/^\d+(\.\d+)?$/.test(m)?Number(m)*1e3:NaN;if(![a,g,I,V].every(Number.isFinite)||g<=a||g-a>k.maxControlAgeMs||a>I+1e3)throw u("INVALID_RESPONSE","Configuration freshness evidence is invalid");let F=Math.min(g-a,i.maxControlAgeSeconds*1e3,k.maxControlAgeMs)-Math.max(V,I-a,0)-(q()-t);if(F<=0)throw u("CONFIGURATION_EXPIRED","Configuration validation expired in transit");return q()+F}function ae(){if(clearTimeout(s),clearTimeout(w),p||!A.size||(j()&&(w=setTimeout(()=>{j()?ae():Y()},Math.max(1,v-q())),ut(w)),typeof document<"u"&&document.visibilityState==="hidden"))return;let n=U?Math.min(15e3,1e3*2**Math.min(U-1,4)):Math.min(15e3,(d?.policy.refreshIntervalSeconds??15)*1e3);s=setTimeout(()=>{Q().catch(pe)},Math.max(O,n*(.8+Math.random()*.2))),ut(s)}async function Q(){if(p)throw u("CONFIGURATION_DISPOSED","Configuration manager was destroyed");if(T)return T;let n=x,t=new AbortController;M=t;let i=(async()=>{if(!ie){ie=!0;try{let ue=await y.readManifest();if(ue&&!d){let J=ye.parse(JSON.parse(ue));N(J.scope)===N(o)&&(d=J)}}catch{}}t.signal.throwIfAborted();let m=d,V=q(),_=await ge(C,t.signal);_.status===304&&(!m||!_.headers.has("x-indiana-config-validated-at")||!_.headers.has("x-indiana-config-valid-until")||!_.headers.has("age"))&&(_=await ge(C,t.signal));let F=_.status===304?m:ye.parse(JSON.parse(await Se(_,k.maxManifestBytes,t.signal))),{generation:ee,...te}=F,B=_.headers.get("etag");if(N(F.scope)!==N(o)||Ge(te)!==ee||B!==`"${ee}"`&&B!==`W/"${ee}"`)throw u("INVALID_RESPONSE","Configuration scope or content identity changed");if(m&&(F.revision<m.revision||F.revision===m.revision&&F.generation!==m.generation))throw u("INVALID_RESPONSE","Configuration revision moved backwards or changed identity");for(let[ue,J]of Object.entries(m?.funnels??{})){let $=F.funnels[ue];if($&&($.controlRevision<J.controlRevision||$.evaluationRevision<J.evaluationRevision||$.controlRevision===J.controlRevision&&$.state!==J.state||$.evaluationRevision===J.evaluationRevision&&$.evaluationMode!==J.evaluationMode))throw u("INVALID_RESPONSE","Funnel control revision changed identity")}let H=lt(_,V,F.policy);if(t.signal.throwIfAborted(),n!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return d=F,v=H,l=Date.now()+Math.max(0,H-q()),S=!1,U=0,O=0,y.writeManifest(N(F)),Y(),structuredClone(F)})(),a=setTimeout(()=>t.abort(u("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),k.initializationMs),g=new Promise((m,V)=>t.signal.addEventListener("abort",()=>V(t.signal.reason),{once:!0})),I=Promise.race([i,g]).catch(m=>{throw U++,(m instanceof e.ZodError||m instanceof SyntaxError||m instanceof L&&["CONFIGURATION_HTTP_404","CONFIGURATION_HTTP_410","INVALID_RESPONSE"].includes(m.code))&&(v=0,S=!0,Y()),m}).finally(()=>{clearTimeout(a),T===I&&(T=void 0),ae()});return T=I,I}async function se(n){let t=n.sha256,i=te=>Xe(te,n);xe(n.url);let a=h.get(t);if(a){if(a.byteLength!==n.byteLength)throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return h.delete(t),h.set(t,a),a.text}let g=P.get(t);if(g){if(g.byteLength!==n.byteLength)throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return g.promise}let I=new AbortController;R.add(I);let m=x,V=(async()=>{try{let H=await y.readArtifact(t);if(H&&i(H)){if(I.signal.throwIfAborted(),p||m!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return be(t,H,n.byteLength),H}}catch{}I.signal.throwIfAborted();let te=await ge(n.url,I.signal,!0),B=await Se(te,n.byteLength,I.signal);if(!i(B))throw u("INVALID_RESPONSE","Configuration artifact digest or size mismatch");if(p||m!==x)throw u("CONFIGURATION_DISPOSED","Configuration scope changed");return be(t,B,n.byteLength),y.writeArtifact(t,B),B})(),_=setTimeout(()=>I.abort(u("CONFIGURATION_UNAVAILABLE","Configuration artifact timed out")),k.initializationMs),F=new Promise((te,B)=>I.signal.addEventListener("abort",()=>B(I.signal.reason),{once:!0})),ee=Promise.race([V,F]).finally(()=>{clearTimeout(_),R.delete(I),P.delete(t)});return P.set(t,{promise:ee,byteLength:n.byteLength}),ee}async function re(){return j()||await Q(),ne(),d}async function W(n){let t,i=new Promise((a,g)=>{t=setTimeout(()=>g(u("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),k.initializationMs)});try{return await Promise.race([n(),i])}finally{clearTimeout(t)}}function Z(n,t){if(ne(),d?.generation!==n.generation)throw u("CONFIGURATION_CHANGED","Configuration changed while preparing a snapshot");if(t&&d.funnels[t]?.state!=="active")throw u("FUNNEL_STOPPED","Funnel is paused or unavailable")}async function Ee(n){let t=n.gb.features;if(!t)throw u("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");let i=n.artifacts[t];if(i.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Unsupported public GB configuration format");let a=Le.parse(JSON.parse(await se(i)));if(N(a.scope)!==N({projectId:o.projectId,environment:o.environment})||a.generation!==i.generation||a.remoteFeatures.some(g=>Object.hasOwn(a.features,g)))throw u("INVALID_RESPONSE","Public GB configuration scope or generation is invalid");return Z(n),{...a,evaluatedAt:new Date().toISOString(),expiresAt:new Date(Date.now()+Math.max(0,v-q())).toISOString()}}async function Ce(n,t){let i=await re(),a=i.funnels[n];t&&(!a||a.evaluationMode==="local"&&!a.versions[t])&&(T&&await T,i=await Q()),Z(i,n);let g=i.funnels[n];if(g.evaluationMode!=="local")throw u("EVALUATION_MODE","This Funnel executes at Longplay; public graph loading is disabled");let I=t??g.currentVersionId,m=g.versions[I];if(!m)throw u("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable");if(i.artifacts[m.artifact].formatVersion!==3)throw u("UNSUPPORTED_SCHEMA","Unsupported public Funnel format");let[V,_]=await Promise.all([se(i.artifacts[m.artifact]).then(F=>ze(JSON.parse(F))),g.evaluationMode==="local"?Ee(i):void 0]);if(_&&N(je(V,_))!==N(m.dependencies))throw u("INVALID_RESPONSE","Funnel and GB dependency contract do not match");return Z(i,n),{document:V,growth:_,versionId:I,control:structuredClone(g),manifest:structuredClone(i)}}async function Re(n,t){try{return await Ce(n,t)}catch(i){if(!(i instanceof L)||!(i.code==="CONFIGURATION_CHANGED"||i.code==="CONFIGURATION_HTTP_404"&&j()))throw i;let a=d?.generation;if(T&&await T,await Q(),i.code!=="CONFIGURATION_CHANGED"&&d?.generation===a)throw i;return Ce(n,t)}}function X(){if(j()||Y(),typeof document<"u"&&document.visibilityState==="hidden"){ae();return}Q().catch(pe)}function dt(n){if(p)throw u("CONFIGURATION_DISPOSED","Configuration manager was destroyed");return A.add(n),A.size===1&&(typeof window<"u"&&(window.addEventListener("online",X),window.addEventListener("focus",X),document.addEventListener("visibilitychange",X)),ae()),()=>{A.delete(n),A.size||(clearTimeout(s),clearTimeout(w),Oe())}}function Oe(){typeof window<"u"&&(window.removeEventListener("online",X),window.removeEventListener("focus",X),document.removeEventListener("visibilitychange",X))}return{scope:Object.freeze({...o}),refresh:Q,subscribe:dt,assertFresh:ne,assertFeatures(n){ne();let t=d.gb.features;if(!t)throw u("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");if(n!==void 0&&d.artifacts[t].generation!==n)throw u("CONFIGURATION_CHANGED","Refresh changed Feature configuration before evaluation")},get fresh(){return j()},get snapshot(){return d?structuredClone(d):null},get remainingMs(){return j()?Math.max(0,v-q()):0},async features(){return W(async()=>Ee(await re()))},pageExperiments:()=>W(async()=>{let n=await re(),t=n.gb.pageExperiments;if(!t)throw u("CONFIGURATION_UNAVAILABLE","Public page experiments are disabled");let i=n.artifacts[t];if(i.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Unsupported page experiment format");let a=at.parse(JSON.parse(await se(i)));if(a.environmentId!==o.environmentId||a.generation!==i.generation)throw u("INVALID_RESPONSE","Page experiment scope or generation changed");return Z(n),a}),funnel:(n,t)=>W(()=>Re(n,t)),funnelControl:n=>W(async()=>{let t=await re();return Z(t,n),structuredClone(t.funnels[n])}),paywall:(n,t)=>W(async()=>{let i=await re(),a=i.paywalls?.[n];if(!a||!t&&a.state!=="published")throw u("PAYWALL_UNAVAILABLE","Published Paywall is unavailable");let g=t??a.currentVersionId,I=a.versions[g],m=I&&i.artifacts[I.artifact];if(!m||m.kind!=="paywall"||m.formatVersion!==1)throw u("UNSUPPORTED_SCHEMA","Public Paywall format is unavailable");let V=Me.parse(JSON.parse(await se(m)));return Z(i),{document:V,versionId:g,version:I.version,control:structuredClone(a),manifest:structuredClone(i)}}),async localFunnel(n,t){let i=await W(()=>Re(n,t));if(!i.growth)throw u("EVALUATION_MODE","This Funnel requires remote execution");let{analyticsConfig:a,remoteFeatures:g,...I}=i.growth;return Ke({scope:{projectId:o.projectId,environment:o.environment},funnelId:n,versionId:i.versionId,evaluationMode:"local",evaluationRevision:i.control.evaluationRevision,document:i.document,payload:I})},assertFunnel(n,t,i){ne();let a=d.funnels[n];if(!a||a.state!=="active")throw u("FUNNEL_STOPPED","Funnel is paused or unavailable");if(a.evaluationMode!=="local")throw u("EVALUATION_MODE","This Funnel now executes at Longplay");if(t!==void 0&&a.controlRevision!==t)throw u("RUN_RECONCILIATION_REQUIRED","Reconcile the original Run after a control change");if(i!==void 0&&!a.versions[i])throw u("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable")},destroy(){if(!p){p=!0,x++,v=0,M?.abort(u("CONFIGURATION_DISPOSED","Configuration manager was destroyed")),clearTimeout(s),clearTimeout(w),Oe(),Y(),A.clear();for(let n of R)n.abort(u("CONFIGURATION_DISPOSED","Configuration manager was destroyed"));h.clear(),z=0}}}}function ct(r){let o=ce.test(r.apiKey);if(typeof window<"u"&&!o)throw new L("SERVER_ONLY","Funnel starts are issued by your backend");if(!o&&!fe.test(r.apiKey))throw new L("INVALID_TOKEN","A customer credential or server API key is required");return{async start(f){let E=D.safeParse({...f,operation:"start"});if(!E.success||E.data.operation!=="start"||(o?E.data.customer!==void 0:E.data.customer===void 0))throw new L("INVALID_REQUEST","Invalid current Funnel start");let b=E.data,C=Qe({...r,timeoutMs:r.timeoutMs??35e3});try{r.session||C.identify(r.apiKey);let c=We(r,await C.request("funnels",b));if(!c.runToken)throw new L("INVALID_RESPONSE","Funnel start credentials are missing");if(c.run.source.id!==b.funnelId||c.run.locale!==(b.locale??"en")||!et(c.run.parameters,b.parameters??{})||(b.customer?!c.customerId||b.customer.type==="id"&&c.customerId!==b.customer.value:c.customerId!==void 0))throw new L("INVALID_RESPONSE","Funnel start contract changed");return{...c,runToken:c.runToken}}finally{C.dispose()}}}}async function En(r){r={...r};let o=r.configuration;if(!o)throw new L("CONFIGURATION_UNAVAILABLE","Local conditions require public configuration");let f={projectId:o.scope.projectId,environment:o.scope.environment};if(r.scope&&N(f)!==N(r.scope))throw new L("SCOPE_MISMATCH","Configuration and transport scopes differ");if((await o.funnelControl(r.funnelId)).evaluationMode!=="local")throw new L("EVALUATION_MODE","This Funnel uses Remote evaluation");let b=fe.test(r.credential);if(b?!r.customerId:r.customerId!==void 0)throw new L("INVALID_REQUEST","Only Server-Key starts name their Customer");let C=ct({...r,scope:f,apiKey:r.credential}),c=(y,d)=>{let v=tt({...r,scope:f,runToken:y,initialResponse:d,...b?{serverKey:r.credential}:{}});return b||v.identify(r.credential),v};return{async start(y){let d=await C.start({...y,funnelId:r.funnelId,...b?{customer:{type:"id",value:r.customerId}}:{}}),v=c(d.runToken,d),l=await v.get();return{...d,...l,controller:v}},async restore(y){let d=c(y),v=await d.get();if(v.run.source.id!==r.funnelId)throw d.reset(),new L("SCOPE_MISMATCH","Run belongs to another Funnel");return{...v,runToken:y,controller:d}}}}export{ot as a,yt as b,Nt as c,Tt as d,_t as e,Lt as f,Dt as g,Ht as h,ln as i,ct as j,En as k};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as o}from"./chunk-
|
|
1
|
+
import{m as o}from"./chunk-2Y5SGDC6.js";import{a as i}from"./chunk-TPXRO63H.js";function m(t,e,n,r){if(!o(t,e)||n!==void 0&&e.observation&&e.observation.subject.customerId!==n||r!==void 0&&e.observation!==void 0&&(e.observation.subject.scope.projectId!==r.projectId||e.observation.subject.scope.environment!==r.environment))throw new i("INVALID_RESPONSE","The access requirement or Customer changed");return e}function d(t,e,n){if(t.requirement){if(!e)throw new i("INVALID_RESPONSE","The requested access check is missing");m(t.requirement,e,t.customerId,n)}}export{m as a,d as b};
|