@tinkerlandai/longplay-sdk 0.10.78 → 0.10.80
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 +11 -0
- package/dist/check-response-XGOTG3KL.js +1 -0
- package/dist/{chunk-IB6BBGLM.js → chunk-2OBXRQMW.js} +1 -1
- package/dist/{chunk-DLLC7CRI.js → chunk-3532HSBP.js} +1 -1
- package/dist/{chunk-HXXUZ6RR.js → chunk-4UD5K5UD.js} +2 -2
- package/dist/{chunk-CDFRRXSQ.js → chunk-523S4AFJ.js} +1 -1
- package/dist/chunk-5VWKCHAB.js +1 -0
- package/dist/{chunk-CW7MTKXP.js → chunk-67WFVDTV.js} +1 -1
- package/dist/{chunk-HEPQNLR2.js → chunk-6VVQWTHV.js} +1 -1
- package/dist/{chunk-LZYQA3Q4.js → chunk-6XRQR43F.js} +1 -1
- package/dist/{chunk-XLOCTL2Y.js → chunk-7CZEXBQY.js} +1 -1
- package/dist/{chunk-JXVZK3RZ.js → chunk-7QPCNDIY.js} +1 -1
- package/dist/{chunk-45PGU2HW.js → chunk-7ZAM4YRK.js} +1 -1
- package/dist/{chunk-TJRXWGKB.js → chunk-A5WUQLAO.js} +1 -1
- package/dist/chunk-AXFFDCHY.js +1 -0
- package/dist/{chunk-LWIBARE4.js → chunk-BOT6ZDLK.js} +1 -1
- package/dist/{chunk-6NDL2ELB.js → chunk-BT7IC765.js} +1 -1
- package/dist/{chunk-VEGGHQTQ.js → chunk-CHRNCOXJ.js} +1 -1
- package/dist/{chunk-CAOUMQZ6.js → chunk-CKMSSBJM.js} +1 -1
- package/dist/{chunk-FWM3577O.js → chunk-CO6HDNOC.js} +1 -1
- package/dist/{chunk-T44KC4GO.js → chunk-DUS5V65Z.js} +1 -1
- package/dist/{chunk-ZP5XCBBK.js → chunk-E5B2TEKP.js} +1 -1
- package/dist/{chunk-7RBU7UEU.js → chunk-EMOKR3UA.js} +1 -1
- package/dist/{chunk-SQMA5YYI.js → chunk-EQBJNU6R.js} +1 -1
- package/dist/{chunk-BSPJMJDI.js → chunk-EQUVI5QU.js} +1 -1
- package/dist/{chunk-D7SPHHSF.js → chunk-F4AIEI5N.js} +1 -1
- package/dist/{chunk-N6RBDJ5Y.js → chunk-FPJ3FE26.js} +1 -1
- package/dist/{chunk-YXD5B3UB.js → chunk-FV7BUKOJ.js} +1 -1
- package/dist/{chunk-VPT5MFDG.js → chunk-FYMVNLQN.js} +2 -2
- package/dist/{chunk-2HIWXIJE.js → chunk-FYUMVOCV.js} +1 -1
- package/dist/{chunk-NJNENW5L.js → chunk-HMOKLBID.js} +1 -1
- package/dist/chunk-J6ATQION.js +1 -0
- package/dist/{chunk-LUYWRWJ2.js → chunk-KCUE2VFJ.js} +1 -1
- package/dist/{chunk-VZMLPENL.js → chunk-KX67ZM7H.js} +1 -1
- package/dist/{chunk-XX5O7H6R.js → chunk-LFR2LWYC.js} +1 -1
- package/dist/{chunk-FVYB2P6Y.js → chunk-LQV7EC5H.js} +1 -1
- package/dist/{chunk-ABLGIN4X.js → chunk-LXAOFLCO.js} +1 -1
- package/dist/chunk-M5TCDVMJ.js +1 -0
- package/dist/{chunk-6FWT2BXF.js → chunk-ME6QTD5Y.js} +1 -1
- package/dist/{chunk-BN6UIKEV.js → chunk-MOIVJERE.js} +1 -1
- package/dist/{chunk-L6XCRIR2.js → chunk-MXI4ANML.js} +1 -1
- package/dist/{chunk-IHAMRL3F.js → chunk-PPG76HUS.js} +1 -1
- package/dist/{chunk-OZ32ZMZZ.js → chunk-PUDTOCQF.js} +1 -1
- package/dist/{chunk-5MPALDJL.js → chunk-S2S4ROGY.js} +1 -1
- package/dist/chunk-SVRKXSZR.js +1 -0
- package/dist/{chunk-HXWWH644.js → chunk-SX7U2ONB.js} +1 -1
- package/dist/{chunk-5X7PTCI4.js → chunk-UGATOG2T.js} +1 -1
- package/dist/{chunk-IXDARDPI.js → chunk-VXNN3RV3.js} +1 -1
- package/dist/{chunk-ZBV6DOEY.js → chunk-XLGNBPGF.js} +1 -1
- package/dist/{chunk-EDZJ2IGA.js → chunk-Y3W5G4BF.js} +1 -1
- package/dist/{chunk-R4ETTZ2H.js → chunk-Y6KA56V2.js} +1 -1
- package/dist/{chunk-IEKRWGRV.js → chunk-Z4OHCMV7.js} +1 -1
- package/dist/{content-AD7CZRT4.js → content-MWQH43G6.js} +1 -1
- package/dist/{funnel-host-purchase-45TUH4H2.js → funnel-host-purchase-CZHW32EF.js} +1 -1
- package/dist/funnel-host-recovery-paywall-SWOGVUIF.js +1 -0
- package/dist/{funnel-local-client-2Yx0Q_lF.d.ts → funnel-local-client-CsWyDEBw.d.ts} +57 -0
- package/dist/{funnel-paywall-copies-BPHMFJ2K.js → funnel-paywall-copies-LPOTYSTS.js} +1 -1
- package/dist/funnel-paywall-prerender-7VOZ3RG3.js +1 -0
- package/dist/{funnel-process-client-BTusJtqx.d.ts → funnel-process-client-CVqSkdSl.d.ts} +1 -1
- package/dist/funnel-route-prediction-Q4HMRAVQ.js +1 -0
- package/dist/funnel-route-source-HYWJWEM3.js +1 -0
- package/dist/funnel-runtime-host-SYN546TS.js +1 -0
- package/dist/index.d.ts +50 -6
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-OIYML3DE.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-YJM6772C.js +1 -0
- package/dist/page.js +1 -1
- package/dist/paywall-TID3CHRR.js +1 -0
- package/dist/paywall-content-OIQDGYFI.js +1 -0
- package/dist/paywall-session-CIJK4MRJ.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +4 -4
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-HJOKBOZH.js +1 -0
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -1
- package/dist/{visual-dom-5LUN4AHO.js → visual-dom-KUABNJV6.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/check-response-DO2R3PE6.js +0 -1
- package/dist/chunk-4CJUGCMG.js +0 -1
- package/dist/chunk-CZ33YJWK.js +0 -1
- package/dist/chunk-E773KSFH.js +0 -1
- package/dist/chunk-HOX2FQQE.js +0 -1
- package/dist/chunk-PX7APKZR.js +0 -1
- package/dist/funnel-host-recovery-paywall-JQWNXDLS.js +0 -1
- package/dist/funnel-paywall-prerender-RSXERNQ3.js +0 -1
- package/dist/funnel-route-prediction-G4OKIQGD.js +0 -1
- package/dist/funnel-route-source-W4R62B7H.js +0 -1
- package/dist/funnel-runtime-host-TQAFDG3X.js +0 -1
- package/dist/merchant-bridge-contracts-ADLTLAJJ.js +0 -1
- package/dist/operation-contracts-WLKY7HAO.js +0 -1
- package/dist/paywall-3P5YKZRE.js +0 -1
- package/dist/paywall-content-JJCSFM6J.js +0 -1
- package/dist/paywall-session-AWH5GSKC.js +0 -1
- package/dist/screen-renderer-TZIU775B.js +0 -1
- /package/dist/{chunk-HXXUZ6RR.js.LEGAL.txt → chunk-4UD5K5UD.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-CILM5XMH.js → chunk-FRK6322O.js} +0 -0
- /package/dist/{chunk-VPT5MFDG.js.LEGAL.txt → chunk-FYMVNLQN.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-OJM6ORHE.js → chunk-KV5MZ4NI.js} +0 -0
- /package/dist/{chunk-J6MYX7WY.js → chunk-W22ESUYY.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as Rn}from"./chunk-HOX2FQQE.js";import{a as Pn}from"./chunk-4CJUGCMG.js";import{a as jn,b as Zn,c as Cn,d as bn,e as Be,f as Kn,h as et,i as nt,j as tt,k as it}from"./chunk-VEGGHQTQ.js";import{a as rt}from"./chunk-45PGU2HW.js";import{a as Jn}from"./chunk-W32FI2A2.js";import{a as zn,d as Gn,f as Qn,g as Wn,j as Yn,k as _e,l as sn,m as Xn,n as an}from"./chunk-FWM3577O.js";import{b as xn}from"./chunk-D7SPHHSF.js";import{a as In,d as Bn}from"./chunk-SQMA5YYI.js";import{C as $n}from"./chunk-2HIWXIJE.js";import{a as ne}from"./chunk-5X7PTCI4.js";import{a as ke}from"./chunk-DSPLGTQI.js";function ot(i){let E=new Set,q=new Set,n=null;async function u(o,p){let A=!1;for(;!i.stopped&&i.key===o&&i.client.pendingCommand?.requestId===p;){if(!i.client.settle)throw new ne("COMMAND_PENDING","The original display acknowledgement is still pending");await i.client.settle(p),A=!0,i.client.pendingCommand?.requestId===p&&await new Promise(v=>setTimeout(v,1500))}i.stopped||i.key!==o||(A&&await i.client.get(),!(i.stopped||i.key!==o)&&E.add(o))}function y(o,p){n=p;let A=()=>{n===p&&(n=null),q.delete(o)};return p.then(A,v=>{A(),i.busy||i.fail(v)}),p}function W(o){if(i.reviewing||E.has(o)||q.has(o)||i.stopped)return;q.add(o);let p=async()=>{if(i.reviewing||i.stopped||i.key!==o||E.has(o)){q.delete(o);return}if(i.busy||i.client.pendingCommand){setTimeout(()=>{p()},250);return}let A=(async()=>{if(i.staleRead){if(await i.staleRead,i.stopped||i.key!==o)return;if(i.client.pendingCommand){setTimeout(()=>{p()},250);return}}let v=i.client.view,de=i.expected(),O=de.requestId;try{await i.client.submit({operation:"shown",...de})}catch(k){if(!(k instanceof ne)||k.code!=="CONFLICT"||k.status!==409||i.client.pendingCommand)throw k;await i.client.get();let c=i.client.view;if(i.stopped||i.reviewing||i.key!==o||!c||!v||c.id!==v.id||c.source.versionId!==v.source.versionId||c.nodeId!==de.nodeId||c.visit!==de.visit||c.revision<=de.revision||c.stopped||!c.screen&&(!c.paywall||c.paywall.receiptId!==v.paywall?.receiptId)||!["running","waiting"].includes(c.status)||i.client.pendingCommand)throw k;let _=i.expected();O=_.requestId,await i.client.submit({operation:"shown",..._})}await u(o,O)})();y(o,A)};p()}function R(){if(n)return n;let o=i.client.pendingCommand;if(o?.operation!=="shown")return null;let p=i.key;return q.add(p),y(p,(async()=>{await i.client.retry(),await u(p,o.requestId)})())}return{report:W,settled:R,get inFlight(){return n}}}function st(i){let E={},q=new Map;async function n(u){let y=i.client.view,W=y?.screen,R=W?.customerData.nodes[u.nodeId];if(i.stopped||i.busy||!y||!W||!R)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(u.action)){let k=i.document,c=k?$n(k,u.nodeId):null,_=c?.type==="customer_data"?c.data.outputs?.[u.action]:void 0;_&&W.outputs.includes(_)?await i.perform(()=>i.client.submit({operation:"submit",...i.expected(),input:{type:"screen",output:_,answers:i.answers,selection:u.value?{[u.nodeId]:u.value}:{}}})):await i.onIntent?.(u,y);return}let p=u.action.startsWith("sources_")?R.resources.find(k=>k.key===u.value):null;if(u.action.startsWith("sources_")&&!p)throw new ne("INVALID_REQUEST","Choose a current resource");let A=`${y.visit}:${u.nodeId}:${p?.key??""}`,v=q.get(A)??[null],O=E[u.nodeId]??{page:1,after:null,filter:"all",...p?{resourceKey:p.key}:{}};if(u.action==="filter"){let k=u.value;if(!k||!(R.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(k))throw new ne("INVALID_REQUEST","Unknown data filter");O={page:1,after:null,filter:k},v.splice(0,v.length,null)}else if(u.action==="next"||u.action==="sources_next"){let k=p?.sources.at(-1),c=p?k?{kind:"ledger",cursor:{at:k.detail[0],id:k.id,type:"source"}}:null:W.dataCursors[u.nodeId];if(!c||!p&&!R.hasNext)return;v[O.page]=c,O={...O,page:O.page+1,after:c}}else if(u.action==="previous"||u.action==="sources_previous"){if(O.page<=1)return;O={...O,page:O.page-1,after:v[O.page-2]??null}}q.set(A,v),E={...E,[u.nodeId]:O},await i.perform(()=>i.client.get({nodeId:y.nodeId,visit:y.visit,revision:y.revision,components:E}))}return{get queries(){return E},intent:n,reset(){E={},q.clear()}}}function at(i){let{doc:E,holder:q,reviewHolder:n,mountScreenPreview:u}=i,y=!1,W,R=0,o=null,p="",A,v=new Map,de=c=>c?`${c.id}:${c.nodeId}:${c.visit}:${c.revision}:${c.paywall?.quote?.operationId??""}`:"";async function O(c){if(i.stopped||!i.client.review||y&&c===W&&A?.active)return;let _=!y||c!==W;y||(p=de(i.client.view),v.set(p,structuredClone(i.answers))),y=!0,W=c,q.hidden=!0,i.suspend(!0),n.hidden=!1;let ve=++R;_&&(A?.finish("dismissed"),o?.destroy(),o=null,n.replaceChildren(),A=sn(n,i.loadingOptions,"funnel",()=>{k()}));let g=_?A:void 0;try{if(g?.start(!1,i.client.view?.locale),ve!==R||i.stopped)return;let Ie=i.client.review(c),V=await(g?.wait(Ie,_e)??Ie);if(i.stopped||ve!==R||!y)return;if(!V.review)throw new ne("INVALID_RESPONSE","Historical projection is missing");o?.destroy(),o=null,g||n.replaceChildren();let d=E.createElement("div"),x=g?an(d,n):()=>{};n.append(d);let F=V.run.locale.startsWith("zh"),te=i.chrome;d.style.cssText=te.history;let ie=E.createElement("p");ie.textContent=F?"只读回看":"Read-only history",ie.style.cssText=te.historyTitle,d.append(ie);let me=E.createElement("p");me.style.cssText=te.historyNote,me.textContent=V.review.pages.length?F?"选择一页查看当时的内容,回看不会改动任何信息。":"Choose a page to see it as it was. Nothing here can be changed.":F?"还没有可回看的页面。":"There are no earlier pages yet.",d.append(me);let j=V.review.page?.receiptId,B=E.createElement("div");B.style.cssText=te.historyPages;for(let[m,U]of V.review.pages.entries()){let J=E.createElement("button");J.type="button",J.textContent=F?`第 ${m+1} 页`:`Page ${m+1}`;let ue=j!==void 0&&U.receiptId===j;J.style.cssText=ue?te.primary:te.secondary,ue&&J.setAttribute("aria-current","page"),Be(J,()=>i.chrome.focus),J.onclick=()=>{O(U.receiptId)},B.append(J)}if(B.childElementCount&&d.append(B),V.review.page){let m=V.review.page,U=E.createElement("div");U.inert=!0,U.style.cssText=te.historyPage,d.append(U),o=u(U,{mode:"live",rendererUrl:i.client.webViewUrl,title:m.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{ve===R&&!i.stopped&&g?.present(x)},onError:ue=>{if(ve!==R||i.stopped)return;let X=new Error(ue);g?.finish("error",X),o?.destroy(),o=null,d.remove(),i.fail(X)},onEscape:()=>{k()}});let J=o;if(J.update(m.document,V.run.locale,{serverInput:{bindings:m.inputs,answers:m.answers,values:m.values}}),await J.ready,i.stopped||ve!==R||!y)return}let D=F?{issued:"已领取",reserved:"已预留",redeemed:"已使用",expired:"已过期",revoked:"已撤销",unknown:"状态待确认"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"},Y=E.createElement("div");Y.style.cssText=te.historyRecords;for(let m of[...V.review.coupons.map((U,J)=>`${F?"优惠券":"Coupon"} ${J+1}: ${D[U.status]}`),...V.review.purchases.map((U,J)=>`${F?"购买":"Purchase"} ${J+1}: ${it(U.status,F)}`)]){let U=E.createElement("p");U.textContent=m,U.style.margin="0",Y.append(U)}Y.childElementCount&&d.append(Y),V.review.page||g?.present(x),i.client.view&&await i.enqueue(i.client.view)}catch(Ie){if(ve!==R||i.stopped)return;g?.finish("error",Ie),o?.destroy(),o=null,n.replaceChildren(),i.fail(Ie)}}async function k(){if(!y||i.stopped||!i.client.review)return;let c=++R;A?.finish("dismissed");try{if(await i.client.review(),i.stopped||c!==R)return;y=!1,R++,A?.finish("dismissed"),o?.destroy(),o=null,n.replaceChildren(),n.hidden=!0,q.hidden=!1;let _=i.client.view;de(_)!==p?(v.set(p,structuredClone(i.answers)),i.resetScreen()):(v.delete(p),i.suspend(!1)),_&&await i.enqueue(_)}catch(_){if(c!==R||i.stopped)return;o?.destroy(),o=null,n.replaceChildren(),i.fail(_)}}return{get active(){return y},get receipt(){return W},open:O,exit:k,get drafts(){return new Map([...v].map(([c,_])=>[c,structuredClone(_)]))},stop(){y=!1,R++,A?.finish("dismissed"),o?.destroy(),o=null,n.replaceChildren(),n.hidden=!0,q.hidden=!1}}}var En=5e3,ft="position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap";async function mt(i,E,q){let n=E,u=n.prepared,y=u&&Rn(u),W=()=>{},R,o;function p(e){for(let t of R?.copies.values()??[])t!==e&&t.destroy();R=void 0}let A;function v(){u&&u.state!=="adopted"&&y?.release()}let de=()=>u?.state==="shown"&&!!y?.modal,O=n.client.identitySignal,k;try{k=await Promise.all([import("./screen-renderer-TZIU775B.js"),import("./paywall-3P5YKZRE.js")]),n.signal?.throwIfAborted(),O?.throwIfAborted()}catch(e){throw v(),e}let[{mountScreenPreview:c},{showPaywall:_}]=k,ve=(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&n.appManifestRelease?rt({client:n.client,appManifestRelease:n.appManifestRelease,onError:n.onError}):void 0;ve?.start();let g=i.ownerDocument,Ie=Yn(g),V=!1,d=g.createElement("section"),x=g.createElement("div"),F=g.createElement("div"),te=g.createElement("div"),ie=g.createElement("button");te.hidden=!0,ie.type="button";let me=g.createElement("p"),j=g.createElement("p"),B=g.createElement("button"),D=g.createElement("button"),Y=g.createElement("button"),m=g.createElement("dialog"),U,J=!1;d.dataset.indianaFunnel="",d.dataset.longplayCloseOwner="sdk",d.setAttribute("aria-busy","false"),me.setAttribute("role","status"),j.setAttribute("role","alert"),j.hidden=!0,B.type=D.type=Y.type="button",F.append(B,ie,me,j,Y,D),d.append(x,te,F),i.append(d);let ue=Zn,X=Cn(ue),ln="",we=(g.documentElement.lang||"").startsWith("zh"),K,dn="",Je,kn=!1,un=!1;for(let e of[B,ie,Y,D])Be(e,()=>X.focus);function Fn(){let e=we?"关闭":"Close";D.parentElement===m?(D.textContent="×",D.setAttribute("aria-label",e),Wn(D,ue)):(D.textContent=e,D.removeAttribute("aria-label"),D.style.cssText=X.link+";margin-inline-start:auto")}function ze(e){let t=e?.screen?.content.document.theme??ue,r=JSON.stringify([t.primary,t.background,t.text,t.radius,t.font,D.parentElement===m]);if(r===ln)return;ln=r,ue=t;let b=D.parentElement===m;X=Cn(ue,b),d.style.cssText=X.root+";min-width:0"+(b?";display:flex;flex-direction:column;min-height:100%":""),F.style.cssText=Dn(),F.hidden&&(F.style.display="none"),B.style.cssText=ie.style.cssText=X.secondary,Y.style.cssText=X.primary,me.style.cssText=X.status,j.style.cssText=X.alert,Fn(),bn(B)}function Dn(){let e=D.parentElement===m,t=e&&K?.responsive===!0;return X.bar+(e?";margin-top:auto":"")+(t?`;position:sticky;bottom:0;z-index:1;background:${ue.background}`:"")+(un?`;${ft}`:"")}function Tn(){return F.hidden||un?0:F.getBoundingClientRect().height}function Fe(){let e=D.parentElement===m,t=B.hidden&&ie.hidden&&Y.hidden&&j.hidden&&(D.hidden||D.parentElement!==F);un=e&&kn&&!!t,F.hidden=t&&!me.textContent,F.style.cssText=Dn(),F.style.display=F.hidden?"none":"flex",K?.responsive&&Je!==void 0&&K.setContentHeight(Je+Tn())}ze();let pe=null,C=null,re=null,Ce="",ee="",De=!1,Ge="",cn="",Qe="",s=!1,G=0,We=!1,An="",pn=null,fn=Promise.resolve(),Sn=!n.client.view,Ve,mn=!1,T=q,je=n.hostPaywallTarget,Ne,Ue,Ye="",Xe,oe=!1,Te=null,ye=!1,Ze=()=>n.client.pendingCommand?.operation==="close",se=null,H=null,wn=Jn({document:g,run:async()=>{(!C?.observing||n.client.pendingCommand)&&await gn()},delay:()=>{if(!ae.pending&&!(s||!re||!["running","waiting"].includes(re.status)&&!n.client.pendingCommand)&&!(C?.observing&&!n.client.pendingCommand))return re.pendingRequest||n.client.pendingCommand?1500:En},hiddenDelay:()=>!s&&!ae.pending&&n.client.pendingCommand?15e3:void 0}),M=null;function yn(){return H&&n.client.hasDurableJournal===!0&&M?.acknowledged===!0&&M.operationId===H.operationId&&n.client.view?.id===M.runId&&n.client.view?.status==="closed"&&n.client.view.revision===M.revision+1&&!(n.client.pendingCommands?.length??(n.client.pendingCommand?1:0))&&!n.client.pendingPurchase?H:null}function On(e){let t=e.run.paywall;if(M&&e.settlement?.requestId===M.requestId&&e.settlement.state==="settled"&&e.settlement.operationId===null&&e.run.id===M.runId&&e.run.status==="closed"&&!e.run.pendingRequest&&e.run.revision===M.revision+1&&e.run.nodeId===M.nodeId&&e.run.visit===M.visit&&t?.receiptId===M.receiptId&&t.selectionGeneration===M.selectionGeneration&&(t.quote?.operationId??null)===M.operationId&&(t.operation?.operationId??t.quote?.operationId??null)===M.operationId){let r=M.operationId===null&&t.selectionGeneration===0&&!t.quote&&!t.operation&&!t.purchaseRequestId,b=In({quote:t.quote,operation:t.operation,requestId:t.purchaseRequestId,pending:!1,destroyed:!1,canReselect:t.canReselect});(r||t.canReselect===!0&&b.type==="native")&&(M.acknowledged=!0)}}let Ae=null,Me=new Set,ge={},qe=!1,Z=(e,t=null)=>{s||(e instanceof ne&&e.status===409&&e.reason==="STATE_CHANGED"&&e.recovery==="recover_operation"&&wn.destroy(),Ae=t,qe=!1,j.textContent=Kn(e,we),j.hidden=!1,Y.hidden=n.client.pendingCommand===null,Fe(),ke(n.onError,e))},ae=xn({client:n.client,document:g,conceal(){s||(he(),T?.finish("dismissed"),d.hidden=!0,V||(V=!0,Ie()))},async receive(e){s||await ce(n.client.view??e.run)},failed(e){if(!s){if(!ae.pending){ye=!1;let t=n.client.view;t&&ce(t).then(()=>Z(e),Z);return}tn(),d.parentElement!==i&&i.append(d),d.hidden=!1,B.hidden=ie.hidden=D.hidden=!0,me.textContent="",ze(),Z(e,n.client.pendingCommand?.requestId??null)}}}),Nn=()=>{s||(Ae=null,j.textContent=nt(we),j.hidden=!1,Y.hidden=!0,Fe())};function Se(){let e=n.client.view;if(!e)throw new ne("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:e.revision}}let h=at({client:n.client,doc:g,holder:x,reviewHolder:te,mountScreenPreview:c,loadingOptions:n,get chrome(){return X},get stopped(){return s},get answers(){return ge},suspend(e){C?.setSuspended(e)},resetScreen(){Ce="",ee="",Ge=""},enqueue:ce,fail:Z}),$e=ot({client:n.client,expected:Se,fail:Z,get stopped(){return s},get reviewing(){return h.active},get key(){return Ce},get busy(){return G},get staleRead(){return pn}}),Ke=st({client:n.client,expected:Se,perform:He,onIntent:n.onCustomerDataIntent,get stopped(){return s},get busy(){return G},get document(){return pe?.document},get answers(){return ge}}),en=e=>`${e.id}:${e.nodeId}:${e.visit}`,Oe=e=>e&&(e.screen||e.paywall)?en(e):"";function be(){let e=n.client.view;B.disabled=!h.active&&(G>0||!!n.client.pendingCommand||!e?.canBack||e.stopped||!["running","waiting"].includes(e.status)||!Oe(e)||ee!==Oe(e)),B.hidden=!h.active&&!e?.canBack,bn(B);let t=!!C&&!h.active;D.hidden=t&&!T?.active||J&&!h.active,ie.hidden=!n.client.review||!h.active&&!e?.canBack;let r=e?.locale.startsWith("zh");kn=!t&&(G>0||!!e?.pendingRequest),me.textContent=t?"":G>0||e?.pendingRequest?r?"正在处理":"Processing":e?.instruction?.type==="wait"?r?"等待中":"Waiting":"",Fe()}async function qn(e){if(!e)return;let t=n.client.view;await e;let r=n.client.view;if(!t||!r||r.id!==t.id||r.nodeId!==t.nodeId||r.visit!==t.visit||r.stopped||!["running","waiting"].includes(r.status))throw new ne("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function He(e,t=!1,r){if(!((G||ye||se||H)&&!t||s||h.active&&!t)){G++,d.setAttribute("aria-busy","true"),j.hidden=!0,Ae=null,qe=!1,be();try{if(t||await qn($e.inFlight),s)return;let b=await e();s||await ce(n.client.view??b.run)}catch(b){r?.(b)&&n.client.pendingCommand===null?Nn():ae.pending||Z(b,n.client.pendingCommand?.requestId??null)}finally{G=Math.max(0,G-1),d.setAttribute("aria-busy",String(G>0)),s||(Y.hidden=n.client.pendingCommand===null,be())}}}function Le(){wn.schedule()}async function gn(){if(!(s||We||G)&&!ae.pending){if(h.active){await h.open(h.receipt);return}We=!0;try{let e=n.client.pendingCommand;e&&n.client.settle&&await n.client.settle(e.requestId);let t=n.client.view,r=Ke.queries,b=await n.client.get(t?.screen&&Object.keys(r).length?{nodeId:t.nodeId,visit:t.visit,revision:t.revision,components:r}:void 0);qe&&!s&&(qe=!1,j.hidden=!0,Fe()),!s&&r===Ke.queries&&await ce(n.client.view??b.run)}catch(e){Z(e),qe=!s}finally{We=!1}}}function nn(e,t,r){if(T?.active){let le=T;return le.setDismissHandler(()=>Hn(le)),le}let b=sn(i,n,"funnel",()=>Hn(b),jn);return T=b,b.start(e,t,r),b}function Hn(e){s||oe||(oe=!0,e.finish("dismissed"),he(),d.hidden=!0,n.client.view?Pe().finally(z):z())}function hn(){clearTimeout(Xe?.timeout),Xe=void 0}function he(e){J=!1,hn(),Ne?.abort(),Ne=void 0,pe?.destroy(),pe=null,C?.destroy(),C=null,Ve=void 0,Ue?.(),Ue=void 0,m.open&&m.close();for(let t of Array.from(x.children))(!e||!t.contains(e))&&t.remove();x.style.cssText="",Je=void 0,Ce="",ee="",De=!1,Ge="",Qe=""}function Ln(){let e=g.defaultView;K?.responsive&&e&&pe?.resizeViewport?.(e.innerHeight,e.innerWidth)}function tn(){K?.destroy(),K=void 0,dn=""}function rn(e){let t=e.screen?.presentation;if(!t||t.type==="inline"){m.open&&m.close(),tn(),D.parentElement!==F&&F.append(D),d.parentElement!==i&&i.append(d);for(let le of["flex","display","flex-direction","justify-content"])x.style.removeProperty(le);ze(e),Fe();return}d.parentElement!==m&&(m.append(D,d),i.append(m)),x.style.flex="1 0 auto",x.style.display="flex",x.style.flexDirection="column",x.style.justifyContent="center",ze(e);let r=e.screen.content.document,b=JSON.stringify([t,ln]);b!==dn&&(tn(),dn=b,m.style.cssText=zn("funnel",t,ue),K=Gn(m,{presentation:t,theme:r.theme,pages:r.pages},Ln),K.latch()),Fe(),m.setAttribute("aria-label",(U?.screen===e.screen?.content.document.name?U?.label:void 0)??pe?.document?.name??e.screen?.content.document.name??"Funnel")}async function lt(e){if(s||oe)return;if(ae.observe(),ae.pending){re=e;return}if(ye&&(Ze()||["running","waiting"].includes(e.status))||(re=e,Ae&&n.client.pendingCommand?.requestId!==Ae&&(j.hidden=!0,Ae=null),we=e.locale.startsWith("zh"),ie.textContent=we?"回看":"History",B.textContent=h.active?we?"返回当前":"Return to current":we?"返回":"Back",Fn(),Y.textContent=we?"重试":"Retry",Y.hidden=n.client.pendingCommand===null,be(),An!==`${e.revision}:${e.visit}:${e.status}:${e.stopped}`&&(An=`${e.revision}:${e.visit}:${e.status}:${e.stopped}`,ke(n.onState,structuredClone(e))),s||oe))return;if((!e.pendingRequest||ye&&e.status==="closed")&&["closed","ineligible","failed"].includes(e.status)){z();return}if(e.stopped&&de()){z();return}if(e.stopped||n.client.configurationReady===!1){h.stop(),v(),he(),T?.finish("skipped"),d.hidden=!0,Le();return}if(d.hidden=!1,h.active){Le();return}if(e.status==="completed"&&C?.subscriptionUpgradeActive){Le();return}let t=Oe(e),r=n.client.view;if(r&&r.revision>e.revision&&Oe(r)!==t)return;let b=!e.instruction&&!e.pendingRequest&&e.nodeType==="screen"&&["running","waiting"].includes(e.status);t!==Ce&&(Ce&&T?.finish("dismissed"),he(),Ce=t,ge={...e.answers},Ke.reset());let le=en(e);if(Ye===le){d.hidden=!0;return}if(b&&!t){d.hidden=!0;let P=u?.state==="shown"?null:nn(!0,e.locale);!s&&!oe&&Xe?.key!==le&&(hn(),Xe={key:le,timeout:setTimeout(()=>{let l=n.client.view;if(s||!P?.active&&u?.state!=="shown"||!l||en(l)!==le)return;Ye=le;let S=new Error("Funnel screen preparation timed out");P?.finish("error",S),v(),he(),Z(S)},_e)}),Le();return}hn();let $=P=>{let l=n.client.view;return!s&&!oe&&!Te&&!P.aborted&&n.client.configurationReady!==!1&&!!l&&!l.stopped&&!["closed","ineligible","failed"].includes(l.status)&&(Oe(l)===t||l.status==="completed"&&C?.subscriptionUpgradeActive===!0)},Ee=(P,l)=>{$(l)&&(Ye=t,T?.finish("error",P),he(),d.hidden=!0,Z(P))};if(t||((e.instruction&&e.instruction.type!=="evaluate_segment"||!["running","waiting"].includes(e.status))&&v(),rn(e),e.instruction?.type!=="event"&&e.instruction?.type!=="open_url"&&T?.finish("skipped")),e.screen){if(mn=!0,je=void 0,v(),n.prepareNextPaywall&&R?.key!==t){p();let L=new Map;for(let[I,N]of Object.entries(e.screen.nextPaywalls??{})){if(!e.screen.outputs.includes(I))continue;let f=n.prepareNextPaywall({run:e,paywallVersionId:N.paywallVersionId});f&&L.set(I,f)}R={key:t,copies:L}}let P=e.screen.content;if(!pe){let L=e.screen.presentation.type!=="inline",I=nn(L,e.locale);if(s||oe)return;let N=(Ne=new AbortController).signal;rn(e),Ue=L?Xn(m):an(d,i),pe=c(x,{mode:"live",closeActions:Array.from(new Set([...n.closeActions??[],...P.document.actions.filter(f=>f.type==="event"&&f.close).map(f=>f.id)])),onAuthoredClose(f){$(N)&&(J=f,be())},rendererUrl:n.client.webViewUrl,title:P.document.name,...L?{hostPresentation:()=>K?.type??e.screen.presentation.type}:{},onResize:f=>{Je=f,K?.responsive&&K.setContentHeight(f+Tn())},onAction(f,a={},fe={}){if(h.active||!$(N)||ee!==t)return;ge={...ge,...fe};let vn=e.screen?.inputs??[],Mn=Object.fromEntries(vn.filter(({variable:Re})=>Object.hasOwn(ge,Re)).map(({variable:Re})=>[Re,ge[Re]]));if(tt(vn,Mn).length){Nn();return}let xe=!G&&R?.key===t?R.copies.get(f):void 0;xe?.state==="ready"&&xe.open()==="shown"&&(p(xe),v(),W(),u=xe,y=Rn(xe),W=y?.onClose(Vn)??(()=>{}),o=t),He(()=>n.client.submit({operation:"submit",...Se(),input:{type:"screen",output:f,answers:Mn,selection:a}}),!1,Re=>et(Re,vn)).finally(()=>{let Re=n.client.view;o===t&&(!Re||Oe(Re)===t)&&(o=void 0,v())})},onAnswers:f=>{h.active||!$(N)||ee!==t||(ge={...ge,...f})},onCustomerDataIntent:f=>{h.active||!$(N)||ee!==t||Ke.intent(f).catch(Z)},onEscape:()=>{!$(N)||ee!==t||h.active||se||H||Pe()},onError:f=>{let a=new Error(f);ee===t?Z(a):Ee(a,N)},onRendered:f=>{if(!(!$(N)||ee===t))try{I.present(a=>{Ue?.(),Ue=void 0,f&&(U={screen:P.document.name,label:f},m.setAttribute("aria-label",f)),L&&(m.showModal(),V=!1,K?.responsive&&m.focus({preventScroll:!0}),!a&&n.loading!=="host"&&Qn(m,K?.type??e.screen.presentation.type,K?.responsive)),ee=t,De=L,be()}),$(N)&&$e.report(t)}catch(a){Ee(a,N)}}}),Ln()}let l={capabilities:e.screen.capabilities,customerData:e.screen.customerData,parameters:e.parameters,serverInput:{bindings:e.screen.inputs,answers:ge,values:e.screen.values}},S=JSON.stringify([P,e.locale,l.parameters,e.screen.inputs,e.screen.values]);if(S!==Ge)pe.update(P.document,e.locale,l),Ge=S,cn=JSON.stringify(l.capabilities),Qe=JSON.stringify(l.customerData);else{let L=JSON.stringify(l.capabilities);L!==cn&&(pe.updateCapabilities(l.capabilities),cn=L),JSON.stringify(l.customerData)!==Qe&&(pe.updateCustomerData(l.customerData),Qe=JSON.stringify(l.customerData))}let Q=pe;if(Q)try{await(T?.wait(Q.ready)??Q.ready)}catch(L){Ne&&Ee(L,Ne.signal)}}else if(e.paywall&&!C){mn=!0,p();let P=e.paywall.resolution,l="document"in P?P.document:null,S=y,Q=n.mountPaywallControls,L=null,I=(Ne=new AbortController).signal,N={loading:"host",signal:I,...Q&&{mountControls:a=>Q(a,e)},canInteract:()=>$(I)&&!h.active&&!se&&!H,beforeAction:async()=>{G++;try{await qn($e.settled()),j.hidden=!0,Ae=null,qe=!1,Fe()}finally{G=Math.max(0,G-1)}},start:async()=>{let a=await Pn(n.client),fe=A;return A=void 0,a.view&&fe?.(a.view),a},onObservationChange:Le,...n.onPurchaseIntent&&{onPurchaseIntent:a=>n.onPurchaseIntent(a,structuredClone(e))},onPurchase:n.onPurchase,onCheckoutUrl:n.onCheckoutUrl,resumeCheckout:n.resumeCheckout,allowNewPurchase:n.allowNewPurchase,checkoutNavigation:n.checkoutNavigation,terminateCheckout:n.terminateCheckout,beforeCheckoutReplacement:n.beforeCheckoutReplacement,purchaseConfirmation:n.purchaseConfirmation,confirmOnHostedCheckout:n.confirmOnHostedCheckout,resolveOfferId:n.resolveOfferId,prepareSubscriptionChange:n.prepareSubscriptionChange,resolveSubscriptionChange:n.resolveSubscriptionChange,claimCoupon:n.claimCoupon,onEvent:n.onEvent,onOpenUrl:a=>n.onOpenUrl?n.onOpenUrl({receiptId:e.paywall.receiptId,url:a,openIn:"same_window"}):g.defaultView?.location.assign(a),onAction:async a=>{if(h.active)return;let fe=await n.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:n.client.view?.revision??e.revision,input:{type:"screen",output:a,answers:{}}});await ce(n.client.view??fe.run)},onError:a=>{ee===t?Z(a):Ee(a,I)}},f={quoteError:a=>ke(n.onError,a),present(a){$(I)&&(L?.present(fe=>{a(fe),ee=t,De=f.retainedDialog?.dialog.open??!!x.querySelector("dialog[open]"),De&&(V=!1),be()}),$(I)&&$e.report(t))},async closeAction(a){s||h.active||await ae.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:n.client.view?.revision??e.revision,input:{type:"screen",output:a,answers:{}}})},async dismiss(){if(s||I.aborted||h.active||se||H||!ye&&!$(I))return;ye=!0;let a=n.client.view;if(a?.status==="completed"&&C?.subscriptionUpgradeActive){Me.add(`complete:${a.id}`),ke(n.onComplete,structuredClone(a)),z();return}if((n.resumeCheckout||n.terminateCheckout)&&pt()){re=n.client.view,z();return}await Pe()}};if(S&&Q)v();else if(S){let a=await S.adopt(e,{options:N,handoff:f,start:()=>Pn(n.client)});o=void 0,a&&$(I)&&!s?(rn(e),C=a,Ve={runId:e.id,receiptId:e.paywall.receiptId},T?.active&&T.present(()=>{}),ee=t,De=S.modal,De&&(V=!1),be(),$e.report(t),h.active&&C.setSuspended(!0)):(a?.destroy(),v(),A=fe=>y?.remember(fe))}if(s||oe)return;if(!C){if(L=nn(!0,e.locale,l),s||oe)return;(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&n.loading==="host"&&je?.ownerDocument===g&&(f.hostPaywallTarget=je),je=void 0,rn(e);let a=await _(x,N,f).catch(fe=>(Ee(fe,I),null));!$(I)&&!(ye&&!s&&!I.aborted)?a?.host?.destroy():a&&(C=a.host,C&&(Ve={runId:e.id,receiptId:e.paywall.receiptId}),C?.setSuspended(h.active))}}if(s||oe)return;be();let w=e.instruction;if(w&&(w.type==="open_url"||w.type==="event")&&!Me.has(w.receiptId)){let P=g.createElement("button");P.type="button",P.style.cssText=X.primary,Be(P,()=>X.focus),x.style.cssText=X.stage,P.textContent=w.type==="open_url"?`${we?"前往":"Continue to"} ${new URL(w.url).host}`:we?"继续":"Continue",P.onclick=()=>{let l=Se(),S=w.type==="open_url"&&!n.onOpenUrl&&w.openIn==="new_window"?dt(w.url):null;He(async()=>{let Q="success";if(w.type==="open_url")if(n.onOpenUrl)try{Q=await n.onOpenUrl({receiptId:w.receiptId,url:w.url,openIn:w.openIn})===!1?"failed":"opened"}catch(I){ke(n.onError,I),Q="failed"}else Q=w.openIn==="new_window"&&!S?"failed":"opened";if(w.type==="event"){if(!n.onEvent)throw new ne("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(w.event)}if(s||n.client.view?.nodeId!==l.nodeId||n.client.view.visit!==l.visit)throw new ne("PRECONDITION_FAILED","The client action visit changed");let L=await n.client.submit({operation:"submit",...l,input:{type:"client_action",receiptId:w.receiptId,outcome:Q}});return Me.add(w.receiptId),w.type==="open_url"&&!n.onOpenUrl&&w.openIn==="same_window"&&g.defaultView?.location.assign(w.url),L})},T?.active?T.present(()=>x.replaceChildren(P)):x.replaceChildren(P)}!e.pendingRequest&&e.status==="completed"&&!Me.has(`complete:${e.id}`)&&(Me.add(`complete:${e.id}`),ke(n.onComplete,structuredClone(e))),Le()}function dt(e){let t=g.defaultView?.open(e,"_blank")??null;return t&&(t.opener=null),t}function ce(e){return be(),fn=fn.catch(()=>{}).then(async()=>{try{await lt(e)}catch(t){throw T?.active&&(Ye=en(e),T.finish("error",t),he(),d.hidden=!0),t}}),fn}let ut=n.client.subscribe(e=>{if(!Sn){if(e.stopped&&(De||de())&&!ye){re=e,z();return}!ye&&(e.stopped||n.client.configurationReady===!1||Ce&&ee!==Ce&&(Oe(e)!==Ce||["closed","ineligible","failed"].includes(e.status)))&&(he(),T?.finish("dismissed"),d.hidden=!0),ce(e).catch(Z)}}),ct=n.client.subscribeError?.(e=>{ae.pending||Z(e)});function pt(){let e=n.client.view,t=e?.paywall;return!!t?.operation&&!!e&&["running","waiting"].includes(e.status)&&Bn(In({quote:t.quote,operation:t.operation,requestId:t.purchaseRequestId,pending:!1,destroyed:!1,canReselect:t.canReselect}))}function Pe(e){if(Te)return Te;if(s||!e&&(se||H))return Promise.resolve();let t=!e&&Ze();return!t&&n.client.view&&!["running","waiting"].includes(n.client.view.status)?(re=n.client.view,z(),Promise.resolve()):(Te=He(async()=>{let r=t?await n.client.retry():await(e?n.client.submit.bind(n.client):ae.submit)({operation:"close",...e??Se()});return e&&On(r),r},!0).then(()=>{let r=n.client.view;r?.status==="closed"&&!Ze()&&(re=r,z())}).finally(()=>{Te=null}),Te)}function z(){_n()}function _n(e){ve?.destroy(),!s&&(s=!0,ae.destroy(),W(),p(),!mn&&(re?.status==="ineligible"||re?.status==="completed")&&y?.withhold(),v(),n.signal?.removeEventListener("abort",z),O?.removeEventListener("abort",z),T?.finish("dismissed"),wn.destroy(),ut(),ct?.(),he(e),tn(),h.stop(),m.remove(),!e||!d.contains(e)?d.remove():(F.remove(),te.remove()),!e&&!V&&Ie(),ke(n.onDismiss,re?structuredClone(re):null))}B.onclick=()=>{if(!B.disabled){if(h.active){h.exit();return}He(()=>n.client.submit({operation:"back",...Se()}))}},ie.onclick=()=>{h.open()},D.onclick=()=>{T?.active?T.dismiss():se||Pe()},Y.onclick=()=>{ae.pending?ae.retry().catch(()=>{}):Ze()?Pe():He(()=>n.client.retry())},m.addEventListener("cancel",e=>{e.preventDefault(),T?.active?T.dismiss():se||Pe()}),n.signal?.addEventListener("abort",z,{once:!0}),O?.addEventListener("abort",z,{once:!0});let on=!1;function Vn(){s||oe||(oe=!0,T?.finish("dismissed"),he(),d.hidden=!0,n.client.view?Pe().finally(z):on=!0)}y&&(W=y.onClose(Vn));let Un={destroy:z,refresh:gn,get recoveryPaywall(){if(C&&Ve)return{...Ve,view:C.currentResolution}},setPurchaseRecovery(e,t){return C?.setPurchaseRecovery(e,t),C!==null},retainPurchaseDialog(){let e=C?.retainPurchaseDialog();if(e)return C=null,_n(e.dialog),{dialog:e.dialog,release(){e.release(),d.remove(),V||Ie()}}},get recovery(){let e=yn();if(e)return e;if(!s&&!G&&!ye&&!se&&C){let t=C.recovery;if(t.type!=="native")return t}return{type:"recover",operationId:n.client.pendingPurchase?.operationId??n.client.view?.paywall?.quote?.operationId??H?.operationId??null,requestId:n.client.pendingCommand?.requestId??null}},prepareFallback(){if(se)return se;let e=yn();if(e)return Promise.resolve(e);let t=n.client.pendingPurchase?.operationId??n.client.view?.paywall?.quote?.operationId??H?.operationId??null,r=()=>({type:"recover",operationId:t,requestId:n.client.pendingCommand?.requestId??null});if(n.client.hasDurableJournal!==!0){let w=C?.recovery;return Promise.resolve(w&&w.type!=="native"&&w.type!=="cancel"?w:r())}let b=(n.client.pendingCommands??(n.client.pendingCommand?[n.client.pendingCommand]:[])).some(w=>w.operation==="close");if(s&&!(b||H&&n.client.view?.status==="closed")||G||We||Te||h.active||!C&&!H&&!b)return Promise.resolve(r());let le=C,$=(async()=>{try{if(!H&&b){let l=await n.client.retry();return await ce(n.client.view??l.run),r()}if(!H){let l=await le.prepareFallback();if(l.type!=="native")return l;if(n.client.hasDurableJournal!==!0)return r();H=l}let w=n.client.pendingCommands??(n.client.pendingCommand?[n.client.pendingCommand]:[]);if(w.length){let l=w.find(Q=>Q.operation==="close");if(!l||!M||l.requestId!==M.requestId)return r();let S=await n.client.retry();On(S),await ce(n.client.view??S.run)}else{let l=n.client.view,S=l?.paywall;if(!l||!S||S.selectionGeneration===void 0||(S.quote?.operationId??null)!==H.operationId||H.operationId!==null&&S.canReselect!==!0)return r();let Q=S.selectionGeneration,L=await n.client.get();await ce(n.client.view??L.run);let I=n.client.view,N=I?.paywall;if(!I||!N||!["running","waiting"].includes(I.status)||I.stopped||I.id!==l.id||I.nodeId!==l.nodeId||I.visit!==l.visit||N.receiptId!==S.receiptId||N.selectionGeneration!==Q||(N.quote?.operationId??null)!==H.operationId||H.operationId!==null&&N.canReselect!==!0||n.client.pendingPurchase||(n.client.pendingCommands?.length??(n.client.pendingCommand?1:0)))return r();let f=Se();M={runId:I.id,operationId:H.operationId,revision:f.revision,requestId:f.requestId,nodeId:I.nodeId,visit:I.visit,receiptId:N.receiptId,selectionGeneration:Q,acknowledged:!1},await Pe(f)}let P=yn();return P?(z(),P):r()}catch(w){return Z(w),r()}})();se=$;let Ee=()=>{se===$&&(se=null)};return $.then(Ee,Ee),$},review:h.open,exitReview:h.exit,get unappliedDrafts(){return h.drafts}};try{let e=n.client.view;if(e)((n.client.viewAgeMs??En)>=En||e.instruction?.type==="evaluate_segment")&&(pn=gn().finally(()=>{pn=null})),await ce(e);else{if(d.hidden=!0,s)throw new DOMException("Presentation cancelled","AbortError");let t=on||u?.state==="shown"?null:nn(n.client.view?.screen?.presentation.type!=="inline",n.client.view?.locale);if(s||oe&&!on)throw new DOMException("Presentation cancelled","AbortError");let r=n.client.get(),b=await(t?t.wait(r,_e):wt(r,_e));if(Sn=!1,on)return s||await Pe().finally(z),Un;await ce(n.client.view??b.run)}}catch(e){throw T?.finish("error",e),z(),e}return Un}function wt(i,E){let q;return Promise.race([i,new Promise((n,u)=>{q=setTimeout(()=>u(new Error("Presentation data timed out")),E)})]).finally(()=>clearTimeout(q))}function zt(i,E,q){return mt(i,E,q)}export{mt as a,zt as b};
|
|
1
|
+
import{b as Rn}from"./chunk-J6ATQION.js";import{a as Pn}from"./chunk-M5TCDVMJ.js";import{a as jn,b as Zn,c as Cn,d as bn,e as Be,f as Kn,h as et,i as nt,j as tt,k as it}from"./chunk-CHRNCOXJ.js";import{a as rt}from"./chunk-7ZAM4YRK.js";import{a as Jn}from"./chunk-W32FI2A2.js";import{a as zn,d as Gn,f as Qn,g as Wn,j as Yn,k as _e,l as sn,m as Xn,n as an}from"./chunk-CO6HDNOC.js";import{b as xn}from"./chunk-F4AIEI5N.js";import{a as In,d as Bn}from"./chunk-EQBJNU6R.js";import{C as $n}from"./chunk-FYUMVOCV.js";import{a as ne}from"./chunk-UGATOG2T.js";import{a as ke}from"./chunk-DSPLGTQI.js";function ot(i){let E=new Set,q=new Set,n=null;async function u(o,p){let A=!1;for(;!i.stopped&&i.key===o&&i.client.pendingCommand?.requestId===p;){if(!i.client.settle)throw new ne("COMMAND_PENDING","The original display acknowledgement is still pending");await i.client.settle(p),A=!0,i.client.pendingCommand?.requestId===p&&await new Promise(v=>setTimeout(v,1500))}i.stopped||i.key!==o||(A&&await i.client.get(),!(i.stopped||i.key!==o)&&E.add(o))}function y(o,p){n=p;let A=()=>{n===p&&(n=null),q.delete(o)};return p.then(A,v=>{A(),i.busy||i.fail(v)}),p}function W(o){if(i.reviewing||E.has(o)||q.has(o)||i.stopped)return;q.add(o);let p=async()=>{if(i.reviewing||i.stopped||i.key!==o||E.has(o)){q.delete(o);return}if(i.busy||i.client.pendingCommand){setTimeout(()=>{p()},250);return}let A=(async()=>{if(i.staleRead){if(await i.staleRead,i.stopped||i.key!==o)return;if(i.client.pendingCommand){setTimeout(()=>{p()},250);return}}let v=i.client.view,de=i.expected(),O=de.requestId;try{await i.client.submit({operation:"shown",...de})}catch(k){if(!(k instanceof ne)||k.code!=="CONFLICT"||k.status!==409||i.client.pendingCommand)throw k;await i.client.get();let c=i.client.view;if(i.stopped||i.reviewing||i.key!==o||!c||!v||c.id!==v.id||c.source.versionId!==v.source.versionId||c.nodeId!==de.nodeId||c.visit!==de.visit||c.revision<=de.revision||c.stopped||!c.screen&&(!c.paywall||c.paywall.receiptId!==v.paywall?.receiptId)||!["running","waiting"].includes(c.status)||i.client.pendingCommand)throw k;let _=i.expected();O=_.requestId,await i.client.submit({operation:"shown",..._})}await u(o,O)})();y(o,A)};p()}function R(){if(n)return n;let o=i.client.pendingCommand;if(o?.operation!=="shown")return null;let p=i.key;return q.add(p),y(p,(async()=>{await i.client.retry(),await u(p,o.requestId)})())}return{report:W,settled:R,get inFlight(){return n}}}function st(i){let E={},q=new Map;async function n(u){let y=i.client.view,W=y?.screen,R=W?.customerData.nodes[u.nodeId];if(i.stopped||i.busy||!y||!W||!R)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(u.action)){let k=i.document,c=k?$n(k,u.nodeId):null,_=c?.type==="customer_data"?c.data.outputs?.[u.action]:void 0;_&&W.outputs.includes(_)?await i.perform(()=>i.client.submit({operation:"submit",...i.expected(),input:{type:"screen",output:_,answers:i.answers,selection:u.value?{[u.nodeId]:u.value}:{}}})):await i.onIntent?.(u,y);return}let p=u.action.startsWith("sources_")?R.resources.find(k=>k.key===u.value):null;if(u.action.startsWith("sources_")&&!p)throw new ne("INVALID_REQUEST","Choose a current resource");let A=`${y.visit}:${u.nodeId}:${p?.key??""}`,v=q.get(A)??[null],O=E[u.nodeId]??{page:1,after:null,filter:"all",...p?{resourceKey:p.key}:{}};if(u.action==="filter"){let k=u.value;if(!k||!(R.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(k))throw new ne("INVALID_REQUEST","Unknown data filter");O={page:1,after:null,filter:k},v.splice(0,v.length,null)}else if(u.action==="next"||u.action==="sources_next"){let k=p?.sources.at(-1),c=p?k?{kind:"ledger",cursor:{at:k.detail[0],id:k.id,type:"source"}}:null:W.dataCursors[u.nodeId];if(!c||!p&&!R.hasNext)return;v[O.page]=c,O={...O,page:O.page+1,after:c}}else if(u.action==="previous"||u.action==="sources_previous"){if(O.page<=1)return;O={...O,page:O.page-1,after:v[O.page-2]??null}}q.set(A,v),E={...E,[u.nodeId]:O},await i.perform(()=>i.client.get({nodeId:y.nodeId,visit:y.visit,revision:y.revision,components:E}))}return{get queries(){return E},intent:n,reset(){E={},q.clear()}}}function at(i){let{doc:E,holder:q,reviewHolder:n,mountScreenPreview:u}=i,y=!1,W,R=0,o=null,p="",A,v=new Map,de=c=>c?`${c.id}:${c.nodeId}:${c.visit}:${c.revision}:${c.paywall?.quote?.operationId??""}`:"";async function O(c){if(i.stopped||!i.client.review||y&&c===W&&A?.active)return;let _=!y||c!==W;y||(p=de(i.client.view),v.set(p,structuredClone(i.answers))),y=!0,W=c,q.hidden=!0,i.suspend(!0),n.hidden=!1;let ve=++R;_&&(A?.finish("dismissed"),o?.destroy(),o=null,n.replaceChildren(),A=sn(n,i.loadingOptions,"funnel",()=>{k()}));let g=_?A:void 0;try{if(g?.start(!1,i.client.view?.locale),ve!==R||i.stopped)return;let Ie=i.client.review(c),V=await(g?.wait(Ie,_e)??Ie);if(i.stopped||ve!==R||!y)return;if(!V.review)throw new ne("INVALID_RESPONSE","Historical projection is missing");o?.destroy(),o=null,g||n.replaceChildren();let d=E.createElement("div"),x=g?an(d,n):()=>{};n.append(d);let F=V.run.locale.startsWith("zh"),te=i.chrome;d.style.cssText=te.history;let ie=E.createElement("p");ie.textContent=F?"只读回看":"Read-only history",ie.style.cssText=te.historyTitle,d.append(ie);let me=E.createElement("p");me.style.cssText=te.historyNote,me.textContent=V.review.pages.length?F?"选择一页查看当时的内容,回看不会改动任何信息。":"Choose a page to see it as it was. Nothing here can be changed.":F?"还没有可回看的页面。":"There are no earlier pages yet.",d.append(me);let j=V.review.page?.receiptId,B=E.createElement("div");B.style.cssText=te.historyPages;for(let[m,U]of V.review.pages.entries()){let J=E.createElement("button");J.type="button",J.textContent=F?`第 ${m+1} 页`:`Page ${m+1}`;let ue=j!==void 0&&U.receiptId===j;J.style.cssText=ue?te.primary:te.secondary,ue&&J.setAttribute("aria-current","page"),Be(J,()=>i.chrome.focus),J.onclick=()=>{O(U.receiptId)},B.append(J)}if(B.childElementCount&&d.append(B),V.review.page){let m=V.review.page,U=E.createElement("div");U.inert=!0,U.style.cssText=te.historyPage,d.append(U),o=u(U,{mode:"live",rendererUrl:i.client.webViewUrl,title:m.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{ve===R&&!i.stopped&&g?.present(x)},onError:ue=>{if(ve!==R||i.stopped)return;let X=new Error(ue);g?.finish("error",X),o?.destroy(),o=null,d.remove(),i.fail(X)},onEscape:()=>{k()}});let J=o;if(J.update(m.document,V.run.locale,{serverInput:{bindings:m.inputs,answers:m.answers,values:m.values}}),await J.ready,i.stopped||ve!==R||!y)return}let D=F?{issued:"已领取",reserved:"已预留",redeemed:"已使用",expired:"已过期",revoked:"已撤销",unknown:"状态待确认"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"},Y=E.createElement("div");Y.style.cssText=te.historyRecords;for(let m of[...V.review.coupons.map((U,J)=>`${F?"优惠券":"Coupon"} ${J+1}: ${D[U.status]}`),...V.review.purchases.map((U,J)=>`${F?"购买":"Purchase"} ${J+1}: ${it(U.status,F)}`)]){let U=E.createElement("p");U.textContent=m,U.style.margin="0",Y.append(U)}Y.childElementCount&&d.append(Y),V.review.page||g?.present(x),i.client.view&&await i.enqueue(i.client.view)}catch(Ie){if(ve!==R||i.stopped)return;g?.finish("error",Ie),o?.destroy(),o=null,n.replaceChildren(),i.fail(Ie)}}async function k(){if(!y||i.stopped||!i.client.review)return;let c=++R;A?.finish("dismissed");try{if(await i.client.review(),i.stopped||c!==R)return;y=!1,R++,A?.finish("dismissed"),o?.destroy(),o=null,n.replaceChildren(),n.hidden=!0,q.hidden=!1;let _=i.client.view;de(_)!==p?(v.set(p,structuredClone(i.answers)),i.resetScreen()):(v.delete(p),i.suspend(!1)),_&&await i.enqueue(_)}catch(_){if(c!==R||i.stopped)return;o?.destroy(),o=null,n.replaceChildren(),i.fail(_)}}return{get active(){return y},get receipt(){return W},open:O,exit:k,get drafts(){return new Map([...v].map(([c,_])=>[c,structuredClone(_)]))},stop(){y=!1,R++,A?.finish("dismissed"),o?.destroy(),o=null,n.replaceChildren(),n.hidden=!0,q.hidden=!1}}}var En=5e3,ft="position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap";async function mt(i,E,q){let n=E,u=n.prepared,y=u&&Rn(u),W=()=>{},R,o;function p(e){for(let t of R?.copies.values()??[])t!==e&&t.destroy();R=void 0}let A;function v(){u&&u.state!=="adopted"&&y?.release()}let de=()=>u?.state==="shown"&&!!y?.modal,O=n.client.identitySignal,k;try{k=await Promise.all([import("./screen-renderer-HJOKBOZH.js"),import("./paywall-TID3CHRR.js")]),n.signal?.throwIfAborted(),O?.throwIfAborted()}catch(e){throw v(),e}let[{mountScreenPreview:c},{showPaywall:_}]=k,ve=(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&n.appManifestRelease?rt({client:n.client,appManifestRelease:n.appManifestRelease,onError:n.onError}):void 0;ve?.start();let g=i.ownerDocument,Ie=Yn(g),V=!1,d=g.createElement("section"),x=g.createElement("div"),F=g.createElement("div"),te=g.createElement("div"),ie=g.createElement("button");te.hidden=!0,ie.type="button";let me=g.createElement("p"),j=g.createElement("p"),B=g.createElement("button"),D=g.createElement("button"),Y=g.createElement("button"),m=g.createElement("dialog"),U,J=!1;d.dataset.indianaFunnel="",d.dataset.longplayCloseOwner="sdk",d.setAttribute("aria-busy","false"),me.setAttribute("role","status"),j.setAttribute("role","alert"),j.hidden=!0,B.type=D.type=Y.type="button",F.append(B,ie,me,j,Y,D),d.append(x,te,F),i.append(d);let ue=Zn,X=Cn(ue),ln="",we=(g.documentElement.lang||"").startsWith("zh"),K,dn="",Je,kn=!1,un=!1;for(let e of[B,ie,Y,D])Be(e,()=>X.focus);function Fn(){let e=we?"关闭":"Close";D.parentElement===m?(D.textContent="×",D.setAttribute("aria-label",e),Wn(D,ue)):(D.textContent=e,D.removeAttribute("aria-label"),D.style.cssText=X.link+";margin-inline-start:auto")}function ze(e){let t=e?.screen?.content.document.theme??ue,r=JSON.stringify([t.primary,t.background,t.text,t.radius,t.font,D.parentElement===m]);if(r===ln)return;ln=r,ue=t;let b=D.parentElement===m;X=Cn(ue,b),d.style.cssText=X.root+";min-width:0"+(b?";display:flex;flex-direction:column;min-height:100%":""),F.style.cssText=Dn(),F.hidden&&(F.style.display="none"),B.style.cssText=ie.style.cssText=X.secondary,Y.style.cssText=X.primary,me.style.cssText=X.status,j.style.cssText=X.alert,Fn(),bn(B)}function Dn(){let e=D.parentElement===m,t=e&&K?.responsive===!0;return X.bar+(e?";margin-top:auto":"")+(t?`;position:sticky;bottom:0;z-index:1;background:${ue.background}`:"")+(un?`;${ft}`:"")}function Tn(){return F.hidden||un?0:F.getBoundingClientRect().height}function Fe(){let e=D.parentElement===m,t=B.hidden&&ie.hidden&&Y.hidden&&j.hidden&&(D.hidden||D.parentElement!==F);un=e&&kn&&!!t,F.hidden=t&&!me.textContent,F.style.cssText=Dn(),F.style.display=F.hidden?"none":"flex",K?.responsive&&Je!==void 0&&K.setContentHeight(Je+Tn())}ze();let pe=null,C=null,re=null,Ce="",ee="",De=!1,Ge="",cn="",Qe="",s=!1,G=0,We=!1,An="",pn=null,fn=Promise.resolve(),Sn=!n.client.view,Ve,mn=!1,T=q,je=n.hostPaywallTarget,Ne,Ue,Ye="",Xe,oe=!1,Te=null,ye=!1,Ze=()=>n.client.pendingCommand?.operation==="close",se=null,H=null,wn=Jn({document:g,run:async()=>{(!C?.observing||n.client.pendingCommand)&&await gn()},delay:()=>{if(!ae.pending&&!(s||!re||!["running","waiting"].includes(re.status)&&!n.client.pendingCommand)&&!(C?.observing&&!n.client.pendingCommand))return re.pendingRequest||n.client.pendingCommand?1500:En},hiddenDelay:()=>!s&&!ae.pending&&n.client.pendingCommand?15e3:void 0}),M=null;function yn(){return H&&n.client.hasDurableJournal===!0&&M?.acknowledged===!0&&M.operationId===H.operationId&&n.client.view?.id===M.runId&&n.client.view?.status==="closed"&&n.client.view.revision===M.revision+1&&!(n.client.pendingCommands?.length??(n.client.pendingCommand?1:0))&&!n.client.pendingPurchase?H:null}function On(e){let t=e.run.paywall;if(M&&e.settlement?.requestId===M.requestId&&e.settlement.state==="settled"&&e.settlement.operationId===null&&e.run.id===M.runId&&e.run.status==="closed"&&!e.run.pendingRequest&&e.run.revision===M.revision+1&&e.run.nodeId===M.nodeId&&e.run.visit===M.visit&&t?.receiptId===M.receiptId&&t.selectionGeneration===M.selectionGeneration&&(t.quote?.operationId??null)===M.operationId&&(t.operation?.operationId??t.quote?.operationId??null)===M.operationId){let r=M.operationId===null&&t.selectionGeneration===0&&!t.quote&&!t.operation&&!t.purchaseRequestId,b=In({quote:t.quote,operation:t.operation,requestId:t.purchaseRequestId,pending:!1,destroyed:!1,canReselect:t.canReselect});(r||t.canReselect===!0&&b.type==="native")&&(M.acknowledged=!0)}}let Ae=null,Me=new Set,ge={},qe=!1,Z=(e,t=null)=>{s||(e instanceof ne&&e.status===409&&e.reason==="STATE_CHANGED"&&e.recovery==="recover_operation"&&wn.destroy(),Ae=t,qe=!1,j.textContent=Kn(e,we),j.hidden=!1,Y.hidden=n.client.pendingCommand===null,Fe(),ke(n.onError,e))},ae=xn({client:n.client,document:g,conceal(){s||(he(),T?.finish("dismissed"),d.hidden=!0,V||(V=!0,Ie()))},async receive(e){s||await ce(n.client.view??e.run)},failed(e){if(!s){if(!ae.pending){ye=!1;let t=n.client.view;t&&ce(t).then(()=>Z(e),Z);return}tn(),d.parentElement!==i&&i.append(d),d.hidden=!1,B.hidden=ie.hidden=D.hidden=!0,me.textContent="",ze(),Z(e,n.client.pendingCommand?.requestId??null)}}}),Nn=()=>{s||(Ae=null,j.textContent=nt(we),j.hidden=!1,Y.hidden=!0,Fe())};function Se(){let e=n.client.view;if(!e)throw new ne("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:e.revision}}let h=at({client:n.client,doc:g,holder:x,reviewHolder:te,mountScreenPreview:c,loadingOptions:n,get chrome(){return X},get stopped(){return s},get answers(){return ge},suspend(e){C?.setSuspended(e)},resetScreen(){Ce="",ee="",Ge=""},enqueue:ce,fail:Z}),$e=ot({client:n.client,expected:Se,fail:Z,get stopped(){return s},get reviewing(){return h.active},get key(){return Ce},get busy(){return G},get staleRead(){return pn}}),Ke=st({client:n.client,expected:Se,perform:He,onIntent:n.onCustomerDataIntent,get stopped(){return s},get busy(){return G},get document(){return pe?.document},get answers(){return ge}}),en=e=>`${e.id}:${e.nodeId}:${e.visit}`,Oe=e=>e&&(e.screen||e.paywall)?en(e):"";function be(){let e=n.client.view;B.disabled=!h.active&&(G>0||!!n.client.pendingCommand||!e?.canBack||e.stopped||!["running","waiting"].includes(e.status)||!Oe(e)||ee!==Oe(e)),B.hidden=!h.active&&!e?.canBack,bn(B);let t=!!C&&!h.active;D.hidden=t&&!T?.active||J&&!h.active,ie.hidden=!n.client.review||!h.active&&!e?.canBack;let r=e?.locale.startsWith("zh");kn=!t&&(G>0||!!e?.pendingRequest),me.textContent=t?"":G>0||e?.pendingRequest?r?"正在处理":"Processing":e?.instruction?.type==="wait"?r?"等待中":"Waiting":"",Fe()}async function qn(e){if(!e)return;let t=n.client.view;await e;let r=n.client.view;if(!t||!r||r.id!==t.id||r.nodeId!==t.nodeId||r.visit!==t.visit||r.stopped||!["running","waiting"].includes(r.status))throw new ne("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function He(e,t=!1,r){if(!((G||ye||se||H)&&!t||s||h.active&&!t)){G++,d.setAttribute("aria-busy","true"),j.hidden=!0,Ae=null,qe=!1,be();try{if(t||await qn($e.inFlight),s)return;let b=await e();s||await ce(n.client.view??b.run)}catch(b){r?.(b)&&n.client.pendingCommand===null?Nn():ae.pending||Z(b,n.client.pendingCommand?.requestId??null)}finally{G=Math.max(0,G-1),d.setAttribute("aria-busy",String(G>0)),s||(Y.hidden=n.client.pendingCommand===null,be())}}}function Le(){wn.schedule()}async function gn(){if(!(s||We||G)&&!ae.pending){if(h.active){await h.open(h.receipt);return}We=!0;try{let e=n.client.pendingCommand;e&&n.client.settle&&await n.client.settle(e.requestId);let t=n.client.view,r=Ke.queries,b=await n.client.get(t?.screen&&Object.keys(r).length?{nodeId:t.nodeId,visit:t.visit,revision:t.revision,components:r}:void 0);qe&&!s&&(qe=!1,j.hidden=!0,Fe()),!s&&r===Ke.queries&&await ce(n.client.view??b.run)}catch(e){Z(e),qe=!s}finally{We=!1}}}function nn(e,t,r){if(T?.active){let le=T;return le.setDismissHandler(()=>Hn(le)),le}let b=sn(i,n,"funnel",()=>Hn(b),jn);return T=b,b.start(e,t,r),b}function Hn(e){s||oe||(oe=!0,e.finish("dismissed"),he(),d.hidden=!0,n.client.view?Pe().finally(z):z())}function hn(){clearTimeout(Xe?.timeout),Xe=void 0}function he(e){J=!1,hn(),Ne?.abort(),Ne=void 0,pe?.destroy(),pe=null,C?.destroy(),C=null,Ve=void 0,Ue?.(),Ue=void 0,m.open&&m.close();for(let t of Array.from(x.children))(!e||!t.contains(e))&&t.remove();x.style.cssText="",Je=void 0,Ce="",ee="",De=!1,Ge="",Qe=""}function Ln(){let e=g.defaultView;K?.responsive&&e&&pe?.resizeViewport?.(e.innerHeight,e.innerWidth)}function tn(){K?.destroy(),K=void 0,dn=""}function rn(e){let t=e.screen?.presentation;if(!t||t.type==="inline"){m.open&&m.close(),tn(),D.parentElement!==F&&F.append(D),d.parentElement!==i&&i.append(d);for(let le of["flex","display","flex-direction","justify-content"])x.style.removeProperty(le);ze(e),Fe();return}d.parentElement!==m&&(m.append(D,d),i.append(m)),x.style.flex="1 0 auto",x.style.display="flex",x.style.flexDirection="column",x.style.justifyContent="center",ze(e);let r=e.screen.content.document,b=JSON.stringify([t,ln]);b!==dn&&(tn(),dn=b,m.style.cssText=zn("funnel",t,ue),K=Gn(m,{presentation:t,theme:r.theme,pages:r.pages},Ln),K.latch()),Fe(),m.setAttribute("aria-label",(U?.screen===e.screen?.content.document.name?U?.label:void 0)??pe?.document?.name??e.screen?.content.document.name??"Funnel")}async function lt(e){if(s||oe)return;if(ae.observe(),ae.pending){re=e;return}if(ye&&(Ze()||["running","waiting"].includes(e.status))||(re=e,Ae&&n.client.pendingCommand?.requestId!==Ae&&(j.hidden=!0,Ae=null),we=e.locale.startsWith("zh"),ie.textContent=we?"回看":"History",B.textContent=h.active?we?"返回当前":"Return to current":we?"返回":"Back",Fn(),Y.textContent=we?"重试":"Retry",Y.hidden=n.client.pendingCommand===null,be(),An!==`${e.revision}:${e.visit}:${e.status}:${e.stopped}`&&(An=`${e.revision}:${e.visit}:${e.status}:${e.stopped}`,ke(n.onState,structuredClone(e))),s||oe))return;if((!e.pendingRequest||ye&&e.status==="closed")&&["closed","ineligible","failed"].includes(e.status)){z();return}if(e.stopped&&de()){z();return}if(e.stopped||n.client.configurationReady===!1){h.stop(),v(),he(),T?.finish("skipped"),d.hidden=!0,Le();return}if(d.hidden=!1,h.active){Le();return}if(e.status==="completed"&&C?.subscriptionUpgradeActive){Le();return}let t=Oe(e),r=n.client.view;if(r&&r.revision>e.revision&&Oe(r)!==t)return;let b=!e.instruction&&!e.pendingRequest&&e.nodeType==="screen"&&["running","waiting"].includes(e.status);t!==Ce&&(Ce&&T?.finish("dismissed"),he(),Ce=t,ge={...e.answers},Ke.reset());let le=en(e);if(Ye===le){d.hidden=!0;return}if(b&&!t){d.hidden=!0;let P=u?.state==="shown"?null:nn(!0,e.locale);!s&&!oe&&Xe?.key!==le&&(hn(),Xe={key:le,timeout:setTimeout(()=>{let l=n.client.view;if(s||!P?.active&&u?.state!=="shown"||!l||en(l)!==le)return;Ye=le;let S=new Error("Funnel screen preparation timed out");P?.finish("error",S),v(),he(),Z(S)},_e)}),Le();return}hn();let $=P=>{let l=n.client.view;return!s&&!oe&&!Te&&!P.aborted&&n.client.configurationReady!==!1&&!!l&&!l.stopped&&!["closed","ineligible","failed"].includes(l.status)&&(Oe(l)===t||l.status==="completed"&&C?.subscriptionUpgradeActive===!0)},Ee=(P,l)=>{$(l)&&(Ye=t,T?.finish("error",P),he(),d.hidden=!0,Z(P))};if(t||((e.instruction&&e.instruction.type!=="evaluate_segment"||!["running","waiting"].includes(e.status))&&v(),rn(e),e.instruction?.type!=="event"&&e.instruction?.type!=="open_url"&&T?.finish("skipped")),e.screen){if(mn=!0,je=void 0,v(),n.prepareNextPaywall&&R?.key!==t){p();let L=new Map;for(let[I,N]of Object.entries(e.screen.nextPaywalls??{})){if(!e.screen.outputs.includes(I))continue;let f=n.prepareNextPaywall({run:e,paywallVersionId:N.paywallVersionId});f&&L.set(I,f)}R={key:t,copies:L}}let P=e.screen.content;if(!pe){let L=e.screen.presentation.type!=="inline",I=nn(L,e.locale);if(s||oe)return;let N=(Ne=new AbortController).signal;rn(e),Ue=L?Xn(m):an(d,i),pe=c(x,{mode:"live",closeActions:Array.from(new Set([...n.closeActions??[],...P.document.actions.filter(f=>f.type==="event"&&f.close).map(f=>f.id)])),onAuthoredClose(f){$(N)&&(J=f,be())},rendererUrl:n.client.webViewUrl,title:P.document.name,...L?{hostPresentation:()=>K?.type??e.screen.presentation.type}:{},onResize:f=>{Je=f,K?.responsive&&K.setContentHeight(f+Tn())},onAction(f,a={},fe={}){if(h.active||!$(N)||ee!==t)return;ge={...ge,...fe};let vn=e.screen?.inputs??[],Mn=Object.fromEntries(vn.filter(({variable:Re})=>Object.hasOwn(ge,Re)).map(({variable:Re})=>[Re,ge[Re]]));if(tt(vn,Mn).length){Nn();return}let xe=!G&&R?.key===t?R.copies.get(f):void 0;xe?.state==="ready"&&xe.open()==="shown"&&(p(xe),v(),W(),u=xe,y=Rn(xe),W=y?.onClose(Vn)??(()=>{}),o=t),He(()=>n.client.submit({operation:"submit",...Se(),input:{type:"screen",output:f,answers:Mn,selection:a}}),!1,Re=>et(Re,vn)).finally(()=>{let Re=n.client.view;o===t&&(!Re||Oe(Re)===t)&&(o=void 0,v())})},onAnswers:f=>{h.active||!$(N)||ee!==t||(ge={...ge,...f})},onCustomerDataIntent:f=>{h.active||!$(N)||ee!==t||Ke.intent(f).catch(Z)},onEscape:()=>{!$(N)||ee!==t||h.active||se||H||Pe()},onError:f=>{let a=new Error(f);ee===t?Z(a):Ee(a,N)},onRendered:f=>{if(!(!$(N)||ee===t))try{I.present(a=>{Ue?.(),Ue=void 0,f&&(U={screen:P.document.name,label:f},m.setAttribute("aria-label",f)),L&&(m.showModal(),V=!1,K?.responsive&&m.focus({preventScroll:!0}),!a&&n.loading!=="host"&&Qn(m,K?.type??e.screen.presentation.type,K?.responsive)),ee=t,De=L,be()}),$(N)&&$e.report(t)}catch(a){Ee(a,N)}}}),Ln()}let l={capabilities:e.screen.capabilities,customerData:e.screen.customerData,parameters:e.parameters,serverInput:{bindings:e.screen.inputs,answers:ge,values:e.screen.values}},S=JSON.stringify([P,e.locale,l.parameters,e.screen.inputs,e.screen.values]);if(S!==Ge)pe.update(P.document,e.locale,l),Ge=S,cn=JSON.stringify(l.capabilities),Qe=JSON.stringify(l.customerData);else{let L=JSON.stringify(l.capabilities);L!==cn&&(pe.updateCapabilities(l.capabilities),cn=L),JSON.stringify(l.customerData)!==Qe&&(pe.updateCustomerData(l.customerData),Qe=JSON.stringify(l.customerData))}let Q=pe;if(Q)try{await(T?.wait(Q.ready)??Q.ready)}catch(L){Ne&&Ee(L,Ne.signal)}}else if(e.paywall&&!C){mn=!0,p();let P=e.paywall.resolution,l="document"in P?P.document:null,S=y,Q=n.mountPaywallControls,L=null,I=(Ne=new AbortController).signal,N={loading:"host",signal:I,...Q&&{mountControls:a=>Q(a,e)},canInteract:()=>$(I)&&!h.active&&!se&&!H,beforeAction:async()=>{G++;try{await qn($e.settled()),j.hidden=!0,Ae=null,qe=!1,Fe()}finally{G=Math.max(0,G-1)}},start:async()=>{let a=await Pn(n.client),fe=A;return A=void 0,a.view&&fe?.(a.view),a},onObservationChange:Le,...n.onPurchaseIntent&&{onPurchaseIntent:a=>n.onPurchaseIntent(a,structuredClone(e))},onPurchase:n.onPurchase,onCheckoutUrl:n.onCheckoutUrl,resumeCheckout:n.resumeCheckout,allowNewPurchase:n.allowNewPurchase,checkoutNavigation:n.checkoutNavigation,terminateCheckout:n.terminateCheckout,beforeCheckoutReplacement:n.beforeCheckoutReplacement,purchaseConfirmation:n.purchaseConfirmation,confirmOnHostedCheckout:n.confirmOnHostedCheckout,resolveOfferId:n.resolveOfferId,prepareSubscriptionChange:n.prepareSubscriptionChange,resolveSubscriptionChange:n.resolveSubscriptionChange,claimCoupon:n.claimCoupon,onEvent:n.onEvent,onOpenUrl:a=>n.onOpenUrl?n.onOpenUrl({receiptId:e.paywall.receiptId,url:a,openIn:"same_window"}):g.defaultView?.location.assign(a),onAction:async a=>{if(h.active)return;let fe=await n.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:n.client.view?.revision??e.revision,input:{type:"screen",output:a,answers:{}}});await ce(n.client.view??fe.run)},onError:a=>{ee===t?Z(a):Ee(a,I)}},f={quoteError:a=>ke(n.onError,a),present(a){$(I)&&(L?.present(fe=>{a(fe),ee=t,De=f.retainedDialog?.dialog.open??!!x.querySelector("dialog[open]"),De&&(V=!1),be()}),$(I)&&$e.report(t))},async closeAction(a){s||h.active||await ae.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:n.client.view?.revision??e.revision,input:{type:"screen",output:a,answers:{}}})},async dismiss(){if(s||I.aborted||h.active||se||H||!ye&&!$(I))return;ye=!0;let a=n.client.view;if(a?.status==="completed"&&C?.subscriptionUpgradeActive){Me.add(`complete:${a.id}`),ke(n.onComplete,structuredClone(a)),z();return}if((n.resumeCheckout||n.terminateCheckout)&&pt()){re=n.client.view,z();return}await Pe()}};if(S&&Q)v();else if(S){let a=await S.adopt(e,{options:N,handoff:f,start:()=>Pn(n.client)});o=void 0,a&&$(I)&&!s?(rn(e),C=a,Ve={runId:e.id,receiptId:e.paywall.receiptId},T?.active&&T.present(()=>{}),ee=t,De=S.modal,De&&(V=!1),be(),$e.report(t),h.active&&C.setSuspended(!0)):(a?.destroy(),v(),A=fe=>y?.remember(fe))}if(s||oe)return;if(!C){if(L=nn(!0,e.locale,l),s||oe)return;(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&n.loading==="host"&&je?.ownerDocument===g&&(f.hostPaywallTarget=je),je=void 0,rn(e);let a=await _(x,N,f).catch(fe=>(Ee(fe,I),null));!$(I)&&!(ye&&!s&&!I.aborted)?a?.host?.destroy():a&&(C=a.host,C&&(Ve={runId:e.id,receiptId:e.paywall.receiptId}),C?.setSuspended(h.active))}}if(s||oe)return;be();let w=e.instruction;if(w&&(w.type==="open_url"||w.type==="event")&&!Me.has(w.receiptId)){let P=g.createElement("button");P.type="button",P.style.cssText=X.primary,Be(P,()=>X.focus),x.style.cssText=X.stage,P.textContent=w.type==="open_url"?`${we?"前往":"Continue to"} ${new URL(w.url).host}`:we?"继续":"Continue",P.onclick=()=>{let l=Se(),S=w.type==="open_url"&&!n.onOpenUrl&&w.openIn==="new_window"?dt(w.url):null;He(async()=>{let Q="success";if(w.type==="open_url")if(n.onOpenUrl)try{Q=await n.onOpenUrl({receiptId:w.receiptId,url:w.url,openIn:w.openIn})===!1?"failed":"opened"}catch(I){ke(n.onError,I),Q="failed"}else Q=w.openIn==="new_window"&&!S?"failed":"opened";if(w.type==="event"){if(!n.onEvent)throw new ne("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(w.event)}if(s||n.client.view?.nodeId!==l.nodeId||n.client.view.visit!==l.visit)throw new ne("PRECONDITION_FAILED","The client action visit changed");let L=await n.client.submit({operation:"submit",...l,input:{type:"client_action",receiptId:w.receiptId,outcome:Q}});return Me.add(w.receiptId),w.type==="open_url"&&!n.onOpenUrl&&w.openIn==="same_window"&&g.defaultView?.location.assign(w.url),L})},T?.active?T.present(()=>x.replaceChildren(P)):x.replaceChildren(P)}!e.pendingRequest&&e.status==="completed"&&!Me.has(`complete:${e.id}`)&&(Me.add(`complete:${e.id}`),ke(n.onComplete,structuredClone(e))),Le()}function dt(e){let t=g.defaultView?.open(e,"_blank")??null;return t&&(t.opener=null),t}function ce(e){return be(),fn=fn.catch(()=>{}).then(async()=>{try{await lt(e)}catch(t){throw T?.active&&(Ye=en(e),T.finish("error",t),he(),d.hidden=!0),t}}),fn}let ut=n.client.subscribe(e=>{if(!Sn){if(e.stopped&&(De||de())&&!ye){re=e,z();return}!ye&&(e.stopped||n.client.configurationReady===!1||Ce&&ee!==Ce&&(Oe(e)!==Ce||["closed","ineligible","failed"].includes(e.status)))&&(he(),T?.finish("dismissed"),d.hidden=!0),ce(e).catch(Z)}}),ct=n.client.subscribeError?.(e=>{ae.pending||Z(e)});function pt(){let e=n.client.view,t=e?.paywall;return!!t?.operation&&!!e&&["running","waiting"].includes(e.status)&&Bn(In({quote:t.quote,operation:t.operation,requestId:t.purchaseRequestId,pending:!1,destroyed:!1,canReselect:t.canReselect}))}function Pe(e){if(Te)return Te;if(s||!e&&(se||H))return Promise.resolve();let t=!e&&Ze();return!t&&n.client.view&&!["running","waiting"].includes(n.client.view.status)?(re=n.client.view,z(),Promise.resolve()):(Te=He(async()=>{let r=t?await n.client.retry():await(e?n.client.submit.bind(n.client):ae.submit)({operation:"close",...e??Se()});return e&&On(r),r},!0).then(()=>{let r=n.client.view;r?.status==="closed"&&!Ze()&&(re=r,z())}).finally(()=>{Te=null}),Te)}function z(){_n()}function _n(e){ve?.destroy(),!s&&(s=!0,ae.destroy(),W(),p(),!mn&&(re?.status==="ineligible"||re?.status==="completed")&&y?.withhold(),v(),n.signal?.removeEventListener("abort",z),O?.removeEventListener("abort",z),T?.finish("dismissed"),wn.destroy(),ut(),ct?.(),he(e),tn(),h.stop(),m.remove(),!e||!d.contains(e)?d.remove():(F.remove(),te.remove()),!e&&!V&&Ie(),ke(n.onDismiss,re?structuredClone(re):null))}B.onclick=()=>{if(!B.disabled){if(h.active){h.exit();return}He(()=>n.client.submit({operation:"back",...Se()}))}},ie.onclick=()=>{h.open()},D.onclick=()=>{T?.active?T.dismiss():se||Pe()},Y.onclick=()=>{ae.pending?ae.retry().catch(()=>{}):Ze()?Pe():He(()=>n.client.retry())},m.addEventListener("cancel",e=>{e.preventDefault(),T?.active?T.dismiss():se||Pe()}),n.signal?.addEventListener("abort",z,{once:!0}),O?.addEventListener("abort",z,{once:!0});let on=!1;function Vn(){s||oe||(oe=!0,T?.finish("dismissed"),he(),d.hidden=!0,n.client.view?Pe().finally(z):on=!0)}y&&(W=y.onClose(Vn));let Un={destroy:z,refresh:gn,get recoveryPaywall(){if(C&&Ve)return{...Ve,view:C.currentResolution}},setPurchaseRecovery(e,t){return C?.setPurchaseRecovery(e,t),C!==null},retainPurchaseDialog(){let e=C?.retainPurchaseDialog();if(e)return C=null,_n(e.dialog),{dialog:e.dialog,release(){e.release(),d.remove(),V||Ie()}}},get recovery(){let e=yn();if(e)return e;if(!s&&!G&&!ye&&!se&&C){let t=C.recovery;if(t.type!=="native")return t}return{type:"recover",operationId:n.client.pendingPurchase?.operationId??n.client.view?.paywall?.quote?.operationId??H?.operationId??null,requestId:n.client.pendingCommand?.requestId??null}},prepareFallback(){if(se)return se;let e=yn();if(e)return Promise.resolve(e);let t=n.client.pendingPurchase?.operationId??n.client.view?.paywall?.quote?.operationId??H?.operationId??null,r=()=>({type:"recover",operationId:t,requestId:n.client.pendingCommand?.requestId??null});if(n.client.hasDurableJournal!==!0){let w=C?.recovery;return Promise.resolve(w&&w.type!=="native"&&w.type!=="cancel"?w:r())}let b=(n.client.pendingCommands??(n.client.pendingCommand?[n.client.pendingCommand]:[])).some(w=>w.operation==="close");if(s&&!(b||H&&n.client.view?.status==="closed")||G||We||Te||h.active||!C&&!H&&!b)return Promise.resolve(r());let le=C,$=(async()=>{try{if(!H&&b){let l=await n.client.retry();return await ce(n.client.view??l.run),r()}if(!H){let l=await le.prepareFallback();if(l.type!=="native")return l;if(n.client.hasDurableJournal!==!0)return r();H=l}let w=n.client.pendingCommands??(n.client.pendingCommand?[n.client.pendingCommand]:[]);if(w.length){let l=w.find(Q=>Q.operation==="close");if(!l||!M||l.requestId!==M.requestId)return r();let S=await n.client.retry();On(S),await ce(n.client.view??S.run)}else{let l=n.client.view,S=l?.paywall;if(!l||!S||S.selectionGeneration===void 0||(S.quote?.operationId??null)!==H.operationId||H.operationId!==null&&S.canReselect!==!0)return r();let Q=S.selectionGeneration,L=await n.client.get();await ce(n.client.view??L.run);let I=n.client.view,N=I?.paywall;if(!I||!N||!["running","waiting"].includes(I.status)||I.stopped||I.id!==l.id||I.nodeId!==l.nodeId||I.visit!==l.visit||N.receiptId!==S.receiptId||N.selectionGeneration!==Q||(N.quote?.operationId??null)!==H.operationId||H.operationId!==null&&N.canReselect!==!0||n.client.pendingPurchase||(n.client.pendingCommands?.length??(n.client.pendingCommand?1:0)))return r();let f=Se();M={runId:I.id,operationId:H.operationId,revision:f.revision,requestId:f.requestId,nodeId:I.nodeId,visit:I.visit,receiptId:N.receiptId,selectionGeneration:Q,acknowledged:!1},await Pe(f)}let P=yn();return P?(z(),P):r()}catch(w){return Z(w),r()}})();se=$;let Ee=()=>{se===$&&(se=null)};return $.then(Ee,Ee),$},review:h.open,exitReview:h.exit,get unappliedDrafts(){return h.drafts}};try{let e=n.client.view;if(e)((n.client.viewAgeMs??En)>=En||e.instruction?.type==="evaluate_segment")&&(pn=gn().finally(()=>{pn=null})),await ce(e);else{if(d.hidden=!0,s)throw new DOMException("Presentation cancelled","AbortError");let t=on||u?.state==="shown"?null:nn(n.client.view?.screen?.presentation.type!=="inline",n.client.view?.locale);if(s||oe&&!on)throw new DOMException("Presentation cancelled","AbortError");let r=n.client.get(),b=await(t?t.wait(r,_e):wt(r,_e));if(Sn=!1,on)return s||await Pe().finally(z),Un;await ce(n.client.view??b.run)}}catch(e){throw T?.finish("error",e),z(),e}return Un}function wt(i,E){let q;return Promise.race([i,new Promise((n,u)=>{q=setTimeout(()=>u(new Error("Presentation data timed out")),E)})]).finally(()=>clearTimeout(q))}function zt(i,E,q){return mt(i,E,q)}export{mt as a,zt as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as
|
|
1
|
+
import{e as y}from"./chunk-CKMSSBJM.js";import{c as g}from"./chunk-S2S4ROGY.js";import{a as $}from"./chunk-EQBJNU6R.js";import{e as Y,f as X,g as Z,h as ee,i as re}from"./chunk-MOIVJERE.js";import{b as B}from"./chunk-PUDTOCQF.js";import{b as F}from"./chunk-FV7BUKOJ.js";import{b as j}from"./chunk-6XRQR43F.js";import{A as J,B as R,E as H,z as x}from"./chunk-3532HSBP.js";import{x as G}from"./chunk-67WFVDTV.js";import{b as W}from"./chunk-MXI4ANML.js";import{a as L}from"./chunk-KCUE2VFJ.js";import{t as K}from"./chunk-Y3W5G4BF.js";import{a}from"./chunk-UGATOG2T.js";import{a as z}from"./chunk-DSPLGTQI.js";function ae(I){let t=[...new Set(I.map(({path:s})=>{let c=s.map(String).join(".");return c.startsWith("selector")?"paywallId or paywallVersionId":c||"input"}))],O=t.includes("locale")?` Pass locale, the Customer's language such as "en" or "zh-CN".`:"";return new a("INVALID_REQUEST",`createPaywallSession input is invalid: ${t.join(", ")}.${O}`)}async function Ie(I,t){if(!L.test(t.customerToken))throw new a("INVALID_TOKEN","A verified Customer credential is required");if(I.session&&I.session.peek()!==t.customerToken)throw new a("SCOPE_MISMATCH","Paywall credential does not match the shared session");let O=y.resolvePaywall.request.safeParse({funnelId:t.funnelId,funnelVersionId:t.funnelVersionId,selector:t.paywallVersionId?{type:"version",versionId:t.paywallVersionId}:{type:"paywall",paywallId:t.paywallId},commerce:t.commerce,locale:t.locale,...t.requirement?{requirement:t.requirement}:{}});if(!O.success)throw ae(O.error.issues);let s=O.data,c=W(I);I.session||c.identify(t.customerToken);let n=null,b=!1,k=new AbortController,u=null,d=null,v=null,P=null,T=null,w=null,m=null,A=0,q=null,U="",D=0,C=new Map,E=new Set;function S(){if(b)throw new a("IDENTITY_CHANGED","Paywall is closed")}function M(){let e=JSON.stringify([A,m!==null]);if(!q||e!==U){U=e;let r=te(++D);q=r;let i=()=>{q===r&&(q=null)};r.then(i,i)}return q.then(r=>structuredClone(r))}async function te(e){S();let r=y.resolvePaywall,i=await g(c.request,r,{...s,selector:n?{type:"version",versionId:n.id}:s.selector});B(s,i.paywall.check,i.scope);let l=await F(I,i.paywall);if(S(),t.paywallVersionId?l.id!==t.paywallVersionId:l.paywallId!==t.paywallId)throw new a("INVALID_RESPONSE","The requested Paywall changed");if(n&&(!Y(l,n)||l.paywallId!==n.paywallId))throw new a("INVALID_RESPONSE","The pinned Paywall or Offering Version changed");if(e!==D)return structuredClone(n??l);n=l;for(let h of E)z(h,structuredClone(n));return structuredClone(n)}async function Q(e){if(S(),P&&e!=="read")throw new a("COMMAND_PENDING","Wait for the original quote");if(!u)throw new a("INVALID_REQUEST","A quoted purchase is required");let r=u;if(e!=="read"){if(m){if(w===e)return m;throw new a("COMMAND_PENDING","Wait for the original purchase command")}if(w&&w!==e)throw new a("COMMAND_PENDING","Read the original purchase before changing an uncertain command");w=e,A++,D++}let i=w,l=A,h=e==="read"&&m===null,f=JSON.stringify([r.operationId,l,m!==null]);if(e==="read"&&C.has(f))return C.get(f).then(o=>structuredClone(o));let p=(async()=>{let o={operationId:r.operationId,...e==="read"?{}:{intent:e},...e==="confirm"&&r.merchantTerms?{merchantConfirmation:G(r.merchantTerms)}:{}},V=R(r)?e==="read"?await g(c.request,y.readSubscriptionUpdate,o):await g(c.request,y.update,o):e==="read"?await g(c.request,y.readSubscriptionOperation,o):await g(c.request,y.attach,o),N=J.parse(V.operation);return N.quote&&ee(r,N.quote),X(N,{operationId:r.operationId,currency:s.commerce.currency,membershipId:R(r)?r.membershipId:null,...R(r)?{featureQuantities:r.featureQuantities??{}}:{}},"The purchase operation changed"),S(),u?.operationId!==r.operationId?structuredClone(N):(d=re(d,N),(e!=="read"||h&&m===null)&&A===l&&w===i&&(w=null),structuredClone(d))})();if(e!=="read"){m=p;let o=()=>{m===p&&(m=null)};p.then(o,o)}else{C.set(f,p);let o=()=>{C.get(f)===p&&C.delete(f)};p.then(o,o)}return p.then(o=>structuredClone(o))}let _={signal:k.signal,get view(){return n?structuredClone(n):null},get quote(){return u?structuredClone(u):null},get operation(){return d?structuredClone(d):null},get webViewUrl(){return"bundled"},get locale(){return s.locale},get recovery(){return $({quote:u,operation:d,requestId:T,pending:P!==null||w!==null,destroyed:b})},get pendingCancellation(){return!b&&w==="cancel"},refresh:M,subscribe(e){return b?()=>{}:(E.add(e),()=>E.delete(e))},async preview(e){if(S(),!n)throw new a("INVALID_REQUEST","Load the Paywall first");let r=n.document.buttons[e.actionId];if(r?.type!=="checkout")throw new a("INVALID_REQUEST","Choose an authored purchase action");let i=j(r.product,e.selection,n.capabilities);if(!i)throw new a("PRODUCT_UNAVAILABLE","Choose an available Product");let l=K(n.document.screen,i,e.selection,n.capabilities);if(s.commerce.intent==="subscription_change"&&!e.subscriptionChange)throw new a("INVALID_REQUEST","Choose the existing membership for this subscription change");if(e.subscriptionChange&&e.nativeOffer)throw new a("INVALID_REQUEST","A web membership change cannot include a store offer");let h=e.subscriptionChange?y.previewUpdate.request.parse({requestId:e.requestId,...e.subscriptionChange,change:{type:"plan",productVersionId:i,...Object.keys(l).length?{featureQuantities:l}:{}},...e.offerId?{offerId:e.offerId}:{}}):y.previewAttach.request.parse({funnelId:s.funnelId,funnelVersionId:s.funnelVersionId,requestId:e.requestId,plans:[{productVersionId:i,...Object.keys(l).length?{featureQuantities:l}:{}}],provider:s.commerce.provider,currency:s.commerce.currency,...e.offerId?{offerId:e.offerId}:{},...e.nativeOffer?{nativeOffer:e.nativeOffer}:{}}),f=JSON.stringify(h);if(v&&v!==f&&(P||w||!d||H(d)))throw new a("COMMAND_PENDING","Finish or cancel the original purchase before changing it");if(v===f){if(P)return P;if(u)return structuredClone(u)}v!==f&&(u=null,d=null),v=f,T=h.requestId;let p=(async()=>{let o="membershipId"in h?await g(c.request,y.previewUpdate,h):await g(c.request,y.previewAttach,h),V=x.parse(o.quote);return S(),Z(V,{productVersionId:i,featureQuantities:l,currency:s.commerce.currency,provider:s.commerce.provider,subscriptionChange:e.subscriptionChange},"The purchase quote changed its selected Product or presentment"),u=V,d=null,structuredClone(u)})();P=p;try{return await p}finally{P===p&&(P=null)}},confirm:()=>Q("confirm"),cancel:()=>Q("cancel"),read:()=>Q("read"),destroy(){b||(b=!0,k.abort(),E.clear(),C.clear(),ne?.(),c.dispose(),n=null,u=null,d=null,v=null,T=null)}},ne=I.session?.subscribeIdentity(_.destroy);try{return await M(),_}catch(e){throw _.destroy(),e}}export{Ie as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as d,D as u}from"./chunk-
|
|
1
|
+
import{C as d,D as u}from"./chunk-3532HSBP.js";function f(r){let{quote:o,operation:e,requestId:s}=r,a={type:"recover",operationId:e?.operationId??o?.operationId??null,requestId:s};if(r.destroyed||r.pending)return a;if(!e)return o?{type:"cancel",operationId:o.operationId}:a;let t=e.merchantExecution;if(d(e)){if(t&&t.type!=="subscription_change")return a;if(t?.type==="subscription_change"){if(["applied","scheduled"].includes(t.status))return!["applied","not_applicable"].includes(t.fulfillmentStatus)||e.problem?.phase==="fulfillment"||t.problem?.phase==="fulfillment"?{type:"fulfillment",operationId:e.operationId}:{type:t.recordingStatus==="accepted"&&u(e)&&!e.problem&&!t.problem?"complete":"recording",operationId:e.operationId};if(e.status==="pending"&&!e.problem&&!t.problem&&t.nextAction?.type==="redirect"&&(!e.checkoutUrl||t.nextAction.url===e.checkoutUrl)&&Date.parse(t.nextAction.expiresAt)>Date.now()&&t.status==="pending")return{type:"checkout",operationId:e.operationId,checkoutUrl:t.nextAction.url}}if(!e.problem&&!t?.problem&&u(e)&&e.executor!=="merchant")return{type:"complete",operationId:e.operationId};if(e.executor==="indiana"&&e.status==="pending"&&e.checkoutUrl&&!e.problem&&(!o||Date.parse(o.expiresAt)>Date.now()))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl};let n=p=>!p||p.phase==="execution"&&p.reason==="STATE_CHANGED";return r.canReselect===!0&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&n(e.problem)&&n(t?.problem)&&(!t||t.status==="failed"&&t.recordingStatus==="accepted"&&t.fulfillmentStatus==="not_applicable")?{type:"native",operationId:e.operationId}:["prepared","quoted"].includes(e.status)&&!e.confirmedAt&&!t&&!e.checkoutUrl&&!e.problem?{type:"cancel",operationId:e.operationId}:a}if(t?.type==="purchase"){if(["succeeded","not_required"].includes(t.paymentStatus))return!["applied","not_applicable"].includes(t.fulfillmentStatus)||e.problem?.phase==="fulfillment"||t.problem?.phase==="fulfillment"?{type:"fulfillment",operationId:e.operationId}:{type:t.recordingStatus==="accepted"&&e.status==="complete"&&!e.problem&&!t.problem?"complete":"recording",operationId:e.operationId};if(e.status==="pending"&&e.checkoutUrl&&!e.problem&&!t.problem&&t.checkoutUrl===e.checkoutUrl&&t.checkoutExpiresAt&&Date.parse(t.checkoutExpiresAt)>Date.now()&&["not_started","pending"].includes(t.paymentStatus))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl}}if(e.executor==="indiana"&&e.status==="pending"&&e.checkoutUrl&&!e.problem&&!e.nativePurchase&&(!o||Date.parse(o.expiresAt)>Date.now()))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl};let c=[e.problem,t?.problem],i=c.every(n=>!n||n.phase==="execution"&&n.reason!=="RESULT_UNKNOWN"),y=e.status==="cancelled"&&!c.some(Boolean)&&t?.type==="purchase"&&["pending","not_started","expired"].includes(t.paymentStatus)&&["not_started","not_applicable"].includes(t.fulfillmentStatus);return r.canReselect===!0&&i&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase&&(e.executor!=="merchant"||!t||t.type==="purchase"&&!["succeeded","not_required"].includes(t.paymentStatus)&&(y||t.recordingStatus==="accepted"&&t.fulfillmentStatus==="not_applicable"))?{type:"native",operationId:e.operationId}:!c.some(Boolean)&&e.status==="complete"&&e.executor!=="merchant"?{type:"complete",operationId:e.operationId}:i&&r.canReselect!==!1&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase&&(e.executor!=="merchant"?!e.confirmedAt&&(e.status==="cancelled"||!e.quoteFinalized):!t&&!e.quoteFinalized||t?.type==="purchase"&&["failed","expired"].includes(t.paymentStatus)&&t.fulfillmentStatus==="not_applicable"&&t.recordingStatus==="accepted")?{type:"native",operationId:e.operationId}:e.status==="pending"&&i&&!e.quoteFinalized&&!t&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase?{type:"cancel",operationId:e.operationId}:a}function h(r,o=!0){if(!r)return!1;let e=f({quote:r.quote??null,operation:r,requestId:null,pending:!1,destroyed:!1,canReselect:o});return e.type==="complete"||e.type==="native"}function l(r){return r.recovery??{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}}function b(r){return!!(r?.operationId&&(r.type==="checkout"||r.type==="recover"||r.type==="fulfillment"||r.type==="recording"))}async function g(r){let o=l(r);if(o.type==="recover"&&r.quote)try{await r.read(),o=l(r)}catch{return o}if(o.type!=="cancel"&&!(o.type==="recover"&&r.pendingCancellation))return o;try{await r.cancel();let e=l(r);return e.type==="cancel"?{type:"recover",operationId:o.operationId,requestId:null}:e}catch{let e=l(r);return e.type==="recover"?e:{type:"recover",operationId:o.operationId,requestId:null}}}export{f as a,h as b,l as c,b as d,g as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n}from"./chunk-
|
|
1
|
+
import{a as n}from"./chunk-UGATOG2T.js";function o(r,e){try{return r.parse(e)}catch{throw new n("INVALID_RESPONSE","Invalid gateway response")}}export{o as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-UGATOG2T.js";var p=new WeakMap;function P(i,n){p.set(i,n)}function v(i){let n,l=!1,d=new AbortController,u=e=>(i.client.pendingCommands??(i.client.pendingCommand?[i.client.pendingCommand]:[])).some(r=>r.requestId===e.command.requestId),m=()=>i.document.defaultView?.navigator.onLine!==!1,C=e=>new Promise((r,t)=>{let o=()=>{clearTimeout(c),d.signal.removeEventListener("abort",a),r()},a=()=>{clearTimeout(c),d.signal.removeEventListener("abort",a),t(new s("IDENTITY_CHANGED","Closing presentation was released"))},c=setTimeout(o,e);d.signal.addEventListener("abort",a,{once:!0}),d.signal.aborted&&a()});async function b(e,r){try{let t;for(let o=0;o<3;o++){if(l)throw new s("IDENTITY_CHANGED","Closing presentation was released");if(o&&(!m()||(await C(o===1?500:2e3),!m())))break;try{let a=p.get(i.client),c=r&&o===0?await(a?a(e.command,()=>{l||n!==e||(e.retained=!0,i.conceal())}):i.client.submit(e.command)):await i.client.retry();if(l)return c;if(!e.retained||!u(e))return n===e&&(n=void 0),await i.receive(c),c;t=new s("COMMAND_PENDING","Closing is still being confirmed. Retry the original request.")}catch(a){if(t=a,!e.retained||!u(e))throw a}}throw t??new s("COMMAND_PENDING","Closing is still being confirmed. Retry the original request.")}catch(t){throw!u(e)&&n===e&&(n=void 0),!l&&e.retained&&i.failed(t),t}}function f(e,r){if(e.flight)return e.flight;let t=b(e,r);e.flight=t;let o=()=>{e.flight===t&&(e.flight=void 0)};return t.then(o,o),t}function g(){if(l)return Promise.reject(new s("IDENTITY_CHANGED","Closing presentation was released"));let e=n;return!e||!u(e)?Promise.reject(new s("INVALID_REQUEST","No closing command is pending")):(!e.flight&&e.retained&&i.conceal(),f(e,!1))}let w=()=>{!l&&n?.retained&&!n.flight&&u(n)&&g().catch(()=>{})};return i.document.defaultView?.addEventListener("online",w),{get pending(){return n?.retained===!0},observe(){n&&!n.flight&&!u(n)&&(n=void 0)},submit(e){if(e.operation==="submit"&&e.input.type!=="screen")return Promise.reject(new s("INVALID_REQUEST","Presentation closure cannot execute a purchase"));if(l)return Promise.reject(new s("IDENTITY_CHANGED","Closing presentation was released"));if(n&&u(n)){let t=n.command;return t.operation===e.operation&&t.nodeId===e.nodeId&&t.visit===e.visit&&(t.operation==="close"||t.operation==="submit"&&e.operation==="submit"&&JSON.stringify(t.input)===JSON.stringify(e.input))?f(n,!n.retained):Promise.reject(new s("COMMAND_PENDING","Recover the original closing command"))}let r={command:e,retained:!1};return n=r,f(r,!0)},retry:g,destroy(){l=!0,d.abort(),i.document.defaultView?.removeEventListener("online",w)}}}export{P as a,v as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as p,c as d}from"./chunk-
|
|
1
|
+
import{b as p,c as d}from"./chunk-ME6QTD5Y.js";import{t as a,w as u,z as m}from"./chunk-FYUMVOCV.js";import{b as e}from"./chunk-W22ESUYY.js";var s=e.enum(["page","popup","banner"]),y=3e5,f=e.strictObject({type:e.enum(["string","number","boolean","strings","json"]),nullable:e.boolean()}),h=e.strictObject({inputs:e.record(a,f.extend({required:e.boolean()})).refine(t=>Object.keys(t).length<=40,"Too many content inputs"),outputs:e.record(a,f).refine(t=>Object.keys(t).length<=40,"Too many content outputs")}),g=e.strictObject({kind:s,schemaVersion:e.literal(1),name:e.string().trim().min(1).max(80),screen:u,contract:h}),c=g.superRefine((t,r)=>{let n=(o,b)=>r.addIssue({code:"custom",message:o,path:b});t.screen.surface!==t.kind&&n("Content surface must match its domain",["screen","surface"]),t.screen.name!==t.name&&n("Content has one editable name",["screen","name"]),t.kind==="banner"&&t.screen.presentation.type!=="inline"&&n("Banner requires an inline container",["screen","presentation"]),t.kind!=="banner"&&t.screen.presentation.type==="inline"&&n("Inline presentation belongs to Banner",["screen","presentation"]),t.screen.actions.some(o=>o.type!=="event"&&o.type!=="navigate")&&n("Content actions must emit host intents or navigate locally",["screen","actions"]);let i=new Set(t.screen.actions.filter(o=>o.type==="event").map(o=>o.id));(Object.keys(t.contract.outputs).some(o=>!i.has(o))||[...i].some(o=>!Object.hasOwn(t.contract.outputs,o)))&&n("Every event needs exactly one output declaration",["contract","outputs"]),d(t)>y&&n("Content document exceeds its byte budget",[])});function S(t,r){if(t===null)return r.nullable;switch(r.type){case"json":return!0;case"string":return typeof t=="string";case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"strings":return Array.isArray(t)&&t.every(n=>typeof n=="string")}}var x=c.superRefine((t,r)=>{for(let n of p(t.screen))Object.keys(t.contract.inputs).some(i=>n===i||n.startsWith(i+"."))||r.addIssue({code:"custom",path:["contract","inputs"],message:"Declare every reusable input read"});for(let n of t.screen.actions){if(n.type!=="event")continue;let i=t.contract.outputs[n.id],o=Object.hasOwn(n.properties,"value")?n.properties.value:n.properties;i&&!S(o,i)&&r.addIssue({code:"custom",path:["contract","outputs",n.id],message:"Action value differs from its declared type"})}m(t.screen).some(n=>!n.complete)&&r.addIssue({code:"custom",path:["screen","strings"],message:"Content needs complete localized copy"})}),l=e.strictObject({id:e.uuid(),kind:s,projectId:e.uuid(),environmentId:e.uuid(),name:e.string(),revision:e.number().int().nonnegative(),status:e.enum(["draft","published","archived"]),publishedVersionId:e.uuid().nullable(),createdAt:e.iso.datetime({offset:!0}),updatedAt:e.iso.datetime({offset:!0})}),D=l.extend({draft:c}),I=e.strictObject({rows:e.array(l).max(200),nextCursor:e.uuid().nullable()}),v=e.strictObject({id:e.uuid(),kind:s,resourceId:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),version:e.number().int().positive(),sourceRevision:e.number().int().nonnegative(),document:x,createdAt:e.iso.datetime({offset:!0})}),z=v.omit({document:!0}),V=e.discriminatedUnion("action",[e.strictObject({action:e.literal("create"),kind:s,id:e.uuid(),document:c}),e.strictObject({action:e.literal("save"),kind:s,id:e.uuid(),revision:e.number().int().nonnegative(),document:c}),e.strictObject({action:e.enum(["publish","archive"]),kind:s,id:e.uuid(),revision:e.number().int().nonnegative()})]).superRefine((t,r)=>{"document"in t&&t.document.kind!==t.kind&&r.addIssue({code:"custom",path:["document","kind"],message:"Content cannot change domain"})});export{s as a,v as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as w,f as b}from"./chunk-
|
|
1
|
+
import{e as w,f as b}from"./chunk-7QPCNDIY.js";import{n as h,s as u}from"./chunk-BT7IC765.js";import{a as y}from"./chunk-MXI4ANML.js";import{a as n}from"./chunk-UGATOG2T.js";import{a as g}from"./chunk-3VUPVXAV.js";import{a as f}from"./chunk-5MRSFLQA.js";function p(r,s){let a=typeof r=="string"?new TextEncoder().encode(r):r;return a.byteLength===s.byteLength&&u(a)===s.sha256}async function _(r,s){let a=w.parse(s),{artifact:i,environmentId:P}=a.content,m=new y(r.baseUrl??f).origin,e=new y(i.url,m);if(e.origin!==m||e.username||e.password||e.search||e.hash||e.pathname!==`/api/v1/configuration/${P}/artifacts/${i.sha256}`)throw new n("INVALID_RESPONSE","Public Paywall locator is not trusted");let o=new AbortController,d,I=new Promise((t,l)=>{d=setTimeout(()=>{let c=new n("TIMEOUT","Public Paywall read timed out");o.abort(c),l(c)},h.initializationMs)}),E=(async()=>{let t=await(r.fetch??globalThis.fetch)(e,{method:"GET",credentials:"omit",redirect:"error",cache:"default",signal:o.signal});if(o.signal.aborted&&(t.body?.cancel().catch(()=>{}),o.signal.throwIfAborted()),!t.ok||!t.headers.get("content-type")?.toLowerCase().startsWith("application/json")||Number(t.headers.get("content-length"))>i.byteLength)throw t.body?.cancel().catch(()=>{}),new n("INVALID_RESPONSE","Public Paywall is unavailable");let l=await g(t,i.byteLength,{signal:o.signal,error:c=>new n("INVALID_RESPONSE",c==="missing"?"Public Paywall body is missing":"Public Paywall exceeds its byte limit")});if(!p(l,i))throw new n("INVALID_RESPONSE","Public Paywall digest or size changed");return b(a,JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(l)))})();try{return await Promise.race([E,I])}finally{clearTimeout(d)}}export{p as a,_ as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as I,b as L}from"./chunk-CILM5XMH.js";function M(e){try{let n=e.replace(/([^\\])\//g,"$1\\/");return new RegExp(n)}catch{return}}function j(e,n){if(!n.length)return!1;let t=!1,r=!1;for(let o of n){let s=pe(e,o.type,o.pattern);if(o.include===!1){if(s)return!1}else t=!0,s&&(r=!0)}return r||!t}function he(e,n,t){try{let r=n.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(r="\\/?"+r.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+r+"$","i").test(e)}catch{return!1}}function be(e,n){try{let t=new URL(n.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),r=[[e.host,t.host,!1],[e.pathname,t.pathname,!0]];return t.hash&&r.push([e.hash,t.hash,!1]),t.searchParams.forEach((o,s)=>{r.push([e.searchParams.get(s)||"",o,!1])}),!r.some(o=>!he(o[0],o[1],o[2]))}catch{return!1}}function pe(e,n,t){try{let r=new URL(e,"https://_");if(n==="regex"){let o=M(t);return o?o.test(r.href)||o.test(r.href.substring(r.origin.length)):!1}else if(n==="simple")return be(r,t);return!1}catch{return!1}}function K(e){for(let t of["namespace","status","url","groups"])if(Object.hasOwn(e,t))throw new TypeError(`Retired experiment field: ${t}`);let n=e;if(n.hashVersion!==void 0&&n.hashVersion!==2)throw new TypeError("Only hash version 2 is supported");if(n.filters?.some(t=>t.hashVersion!==2))throw new TypeError("Only hash version 2 is supported")}function T(e){for(let n of Object.values(e)){if(Array.isArray(n))throw new TypeError("Saved groups require typed list or condition entries");if(n&&Object.hasOwn(n,"useEmptyListGroup"))throw new TypeError("Retired saved group field: useEmptyListGroup")}}function H(e){for(let n of["overrides","groups"])if(Object.hasOwn(e,n))throw new TypeError(`Retired evaluation context field: ${n}`);T(e.savedGroups??{})}function J(e){let n=2166136261,t=e.length;for(let r=0;r<t;r++)n^=e.charCodeAt(r),n+=(n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24);return n>>>0}function C(e,n,t){return t===2?J(J(e+n)+"")%1e4/1e4:null}function me(e){return e<=0?[]:new Array(e).fill(1/e)}function $(e,n){return e>=n[0]&&e<n[1]}function W(e,n){for(let[t,r]of n.entries())if($(e,r))return t;return-1}function Q(e,n,t){n=n===void 0?1:n,n<0?n=0:n>1&&(n=1);let r=me(e);t=t||r,t.length!==e&&(t=r);let o=t.reduce((a,u)=>u+a,0);(o<.99||o>1.01)&&(t=r);let s=0,i=n;return t.map(a=>{let u=s;return s+=a,[u,u+i*a]})}function z(e,n,t){if(!n)return null;let r=n.split("?")[1];if(!r)return null;let s=r.replace(/#.*/,"").split("&").map(i=>i.split("=",2)).filter(([i])=>i===e).map(([,i])=>i===void 0?NaN:parseInt(i))[0];return s!==void 0&&s>=0&&s<t?s:null}function X(e){try{return e()}catch{return!1}}function E(e){return typeof e=="string"?e:JSON.stringify(e)}function y(e){typeof e=="number"&&(e=e+""),(!e||typeof e!="string")&&(e="0");let n=e.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return n.length===3&&n.push("~"),n.map(t=>t.match(/^[0-9]+$/)?t.padStart(5," "):t).join("-")}var Y=new Map,D=32,Z=new WeakMap,ee=new WeakMap;function Se(e){return I(L(new TextEncoder().encode(String(e))))}var B=e=>Array.isArray(e)?e.map(B):typeof e=="string"||typeof e=="number"?Se(e):null,O=e=>typeof e=="string"?e.toLowerCase():e;function oe(e){let n=Z.get(e);return n||(n=new Set(e),Z.set(e,n)),n}function ve(e){let n=ee.get(e);return n||(n=new Set(e.map(O)),ee.set(e,n)),n}function Ae(e){T(e);for(let n of Object.values(e)){let t=n?.type==="list"||n?.type==="hashed"?n.values:null;t&&t.length>=D&&oe(t)}return e}function h(e,n,t,r){t=t||{},r||T(t),r=r||new Set;for(let[o,s]of Object.entries(n))switch(o){case"$or":if(!ie(e,s,t,r))return!1;break;case"$nor":if(ie(e,s,t,r))return!1;break;case"$and":if(!Fe(e,s,t,r))return!1;break;case"$not":if(h(e,s,t,r))return!1;break;case"$savedGroup":if(!we(e,s,t,r))return!1;break;default:if(!V(s,se(e,o),t,!1,r))return!1}return!0}function we(e,n,t,r){if(!n||typeof n!="object"||Array.isArray(n))return!1;let{id:o,attributeKey:s}=n;if(typeof o!="string"||r.has(o)||s!==void 0&&typeof s!="string")return!1;let i=t[o];if(!i||Array.isArray(i)||typeof i!="object")return!1;let a=new Set(r).add(o);if(i.type==="list"||i.type==="hashed"){let u=s??i.attributeKey;if(typeof u!="string"||!Array.isArray(i.values))return!1;let f=se(e,u);return S(i.type==="hashed"?B(f):f,i.values)}return i.type==="condition"?!i.condition||typeof i.condition!="object"?!1:h(e,i.condition,t,a):!1}function se(e,n){let t=n.split("."),r=e;for(let o of t)if(r&&typeof r=="object"&&o in r)r=r[o];else return null;return r}function ne(e,n=!1){let t=`${e}${n?"/i":""}`,r=Y.get(t);return r||(r=new RegExp(e.replace(/([^\\])\//g,"$1\\/"),n?"i":void 0),Y.set(t,r)),r}function V(e,n,t,r=!1,o=new Set){if(typeof e=="string")return r?String(n).toLowerCase()===e.toLowerCase():n+""===e;if(typeof e=="number")return n*1===e;if(typeof e=="boolean")return n!==null&&!!n===e;if(e===null)return n===null;if(Array.isArray(e)||!ae(e))return JSON.stringify(n)===JSON.stringify(e);let s=e;for(let i in s)if(!Re(i,n,s[i],t,o))return!1;return!0}function ae(e){let n=Object.keys(e);return n.length>0&&n.filter(t=>t[0]==="$").length===n.length}function Ee(e){if(e===null)return"null";if(Array.isArray(e))return"array";let n=typeof e;return["string","number","boolean","object","undefined"].includes(n)?n:"unknown"}function Ve(e,n,t,r){if(!Array.isArray(e))return!1;let o=ae(n)?s=>V(n,s,t,!1,r):s=>h(s,n,t,r);for(let s=0;s<e.length;s++)if((e[s]??null)!==null&&o(e[s]))return!0;return!1}function S(e,n,t=!1){if(t){let o;if(n.length>=D){let s=ve(n);o=i=>{let a=O(i);return!(typeof a=="number"&&Number.isNaN(a))&&s.has(a)}}else o=s=>n.some(i=>O(s)===O(i));return Array.isArray(e)?e.some(s=>o(s)):o(e)}let r=n.length>=D?(o=>s=>o.has(s))(oe(n)):o=>n.includes(o);return Array.isArray(e)?e.some(o=>r(o)):r(e)}function te(e){return e===void 0?[]:e&&typeof e=="object"&&(e.type==="list"||e.type==="hashed")&&Array.isArray(e.values)?e.values:null}function re(e,n,t,r=!1,o=new Set){if(!Array.isArray(e))return!1;for(let s=0;s<n.length;s++){let i=!1;for(let a=0;a<e.length;a++)if(V(n[s],e[a],t,r,o)){i=!0;break}if(!i)return!1}return!0}function Re(e,n,t,r,o=new Set){let s=n,i=t;switch(e){case"$veq":return y(n)===y(t);case"$vne":return y(n)!==y(t);case"$vgt":return y(n)>y(t);case"$vgte":return y(n)>=y(t);case"$vlt":return y(n)<y(t);case"$vlte":return y(n)<=y(t);case"$eq":return n===t;case"$ne":return n!==t;case"$lt":return s<i;case"$lte":return s<=i;case"$gt":return s>i;case"$gte":return s>=i;case"$exists":return t?n!=null:n==null;case"$in":return Array.isArray(t)?S(n,t):!1;case"$ini":return Array.isArray(t)?S(n,t,!0):!1;case"$inGroup":{let a=r[t],u=te(a);return u===null?!1:S(a?.type==="hashed"?B(n):n,u)}case"$notInGroup":{let a=r[t],u=te(a);return u===null?!1:!S(a?.type==="hashed"?B(n):n,u)}case"$nin":return Array.isArray(t)?!S(n,t):!1;case"$nini":return Array.isArray(t)?!S(n,t,!0):!1;case"$not":return!V(t,n,r,!1,o);case"$size":return Array.isArray(n)?V(t,n.length,r,!1,o):!1;case"$elemMatch":return Ve(n,t,r,o);case"$all":return Array.isArray(t)?re(n,t,r,!1,o):!1;case"$alli":return Array.isArray(t)?re(n,t,r,!0,o):!1;case"$regex":try{return ne(t).test(n)}catch{return!1}case"$regexi":try{return ne(t,!0).test(n)}catch{return!1}case"$type":return Ee(n)===t;default:return!1}}function ie(e,n,t,r){if(!n.length)return!0;for(let o of n)if(h(e,o,t,r))return!0;return!1}function Fe(e,n,t,r){for(let o of n)if(!h(e,o,t,r))return!1;return!0}function ue(e){return Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}function U(e){return H(e),{context:e,stack:{evaluatedFeatures:new Set}}}function _(e){return{...e.attributes,...e.attributeOverrides}}function p(e,n,t){let r=n||"id",o="",s=_(e);return s[r]&&(o=s[r]),!o&&t&&(s[t]&&(o=s[t]),o&&(r=t)),{hashAttribute:r,hashValue:o}}function l(e,n,t){e.context.log?.(n,t)}function x(e,n){return n=n||0,`${e}__${n}`}function q(e,n){return`${e}||${n}`}function Te(e,n,t){let r=e.stickyBucketAssignmentDocs;if(!r)return{};let{hashAttribute:o,hashValue:s}=p(e,n),i=q(o,E(s)),{hashAttribute:a,hashValue:u}=p(e,t),f=u?q(a,E(u)):null,c={};return f&&r[f]&&Object.assign(c,r[f].assignments||{}),r[i]&&Object.assign(c,r[i].assignments||{}),c}function le({context:e,expKey:n,expBucketVersion:t,expHashAttribute:r,expFallbackAttribute:o,expMinBucketVersion:s,expMeta:i}){t=t||0,s=s||0,r=r||"id",i=i||[];let a=x(n,t),u=Te(e,r,o);if(s>0)for(let d=0;d<s;d++){let k=x(n,d);if(u[k]!==void 0)return{variation:-1,versionIsBlocked:!0}}let f=u[a];if(f===void 0)return{variation:-1};let c=i.findIndex(d=>d.key===f);return c<0?{variation:-1}:{variation:c}}function fe(e,n,t,r){let o=q(n,t),s=e.stickyBucketAssignmentDocs,i=s&&s[o]?s[o].assignments||{}:{},a={...i,...r},u=JSON.stringify(i)!==JSON.stringify(a);return{key:o,doc:{attributeName:n,attributeValue:t,assignments:a},changed:u}}function Ce(e,n){let t=U(n),r=ge(e,null,t);return n.onExperimentEval?.(e,r),r}function $e(e,n){return N(e,U(n))}function Oe(e){return e.forcedVariations||{}}function ce(e,n,t){let{context:r}=e;if(r.trackedExperiments){let o=ke(n,t);if(r.trackedExperiments.has(o))return;r.trackedExperiments.add(o)}G(()=>r.onExperimentViewed?.(n,t))}function Be(e,n,t){let{context:r}=e;if(r.trackedFeatureUsage){let o=JSON.stringify(t.value);if(r.trackedFeatureUsage[n]===o)return;r.trackedFeatureUsage[n]=o}G(()=>r.onFeatureUsage?.(n,t))}function G(e){try{let n=e();n&&typeof n.catch=="function"&&n.catch(()=>{})}catch{}}function N(e,n){let{context:t}=n;if(n.stack.evaluatedFeatures.has(e))return l(n,`evalFeature: circular dependency detected: ${n.stack.id} -> ${e}`,{from:n.stack.id,to:e}),m(n,e,null,"cyclicPrerequisite");n.stack.evaluatedFeatures.add(e),n.stack.id=e;let r=t.features?.[e];for(let s of r?.rules??[])K(s);let o=t.forcedFeatureValues;if(o&&o.has(e))return l(n,"Global override",{id:e,value:o.get(e)}),m(n,e,o.get(e),"override");if(!r)return l(n,"Unknown feature",{id:e}),m(n,e,null,"unknownFeature");if(r.rules){let s=new Set(n.stack.evaluatedFeatures);e:for(let i of r.rules){if(i.parentConditions)for(let f of i.parentConditions){n.stack.evaluatedFeatures=new Set(s);let c=N(f.id,n);if(c.source==="cyclicPrerequisite")return m(n,e,null,"cyclicPrerequisite");let d={value:c.value};if(!h(d,f.condition||{},t.savedGroups||{})){if(f.gate)return l(n,"Feature blocked by prerequisite",{id:e,rule:i}),m(n,e,null,"prerequisite");l(n,"Skip rule because prerequisite evaluation fails",{id:e,rule:i});continue e}}if(i.filters&&ye(i.filters,n)){l(n,"Skip rule because of filters",{id:e,rule:i});continue}if("force"in i){if(i.condition&&!de(i.condition,n)){l(n,"Skip rule because of condition ff",{id:e,rule:i});continue}if(!xe(n,i.seed||e,i.hashAttribute,t.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion)){l(n,"Skip rule because user not included in rollout",{id:e,rule:i});continue}return l(n,"Force value from rule",{id:e,rule:i}),i.tracks&&i.tracks.forEach(f=>{ce(n,f.experiment,f.result)}),m(n,e,i.force,"force",i.id)}if(!i.variations){l(n,"Skip invalid rule",{id:e,rule:i});continue}let a={variations:i.variations,key:i.key||e};"coverage"in i&&(a.coverage=i.coverage),i.weights&&(a.weights=i.weights),i.hashAttribute&&(a.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(a.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(a.disableStickyBucketing=i.disableStickyBucketing),i.bucketVersion!==void 0&&(a.bucketVersion=i.bucketVersion),i.minBucketVersion!==void 0&&(a.minBucketVersion=i.minBucketVersion),i.meta&&(a.meta=i.meta),i.ranges&&(a.ranges=i.ranges),i.name&&(a.name=i.name),i.phase&&(a.phase=i.phase),i.seed&&(a.seed=i.seed),i.hashVersion&&(a.hashVersion=i.hashVersion),i.filters&&(a.filters=i.filters),i.condition&&(a.condition=i.condition);let u=ge(a,e,n);if(t.onExperimentEval?.(a,u),u.inExperiment&&!u.passthrough)return m(n,e,u.value,"experiment",i.id,a,u)}}return l(n,"Use default value",{id:e,value:r.defaultValue}),m(n,e,r.defaultValue===void 0?null:r.defaultValue,"defaultValue")}function ge(e,n,t){let{context:r}=t;K(e);let o=e.key,s=e.variations.length;if(s<2)return l(t,"Invalid experiment",{id:o}),g(t,e,-1,!1,n);if(r.enabled===!1)return l(t,"Context disabled",{id:o}),g(t,e,-1,!1,n);if(e.urlPatterns&&!j(r.url||"",e.urlPatterns))return l(t,"Skip because of url targeting",{id:o}),g(t,e,-1,!1,n);let i=z(o,r.url||"",s);if(i!==null)return l(t,"Force via querystring",{id:o,variation:i}),g(t,e,i,!1,n);let u=Oe(r)[o];if(u!==void 0)return l(t,"Force via dev tools",{id:o,variation:u}),g(t,e,u,!1,n);if(e.active===!1)return l(t,"Skip because inactive",{id:o}),g(t,e,-1,!1,n);let{hashAttribute:f,hashValue:c}=p(r,e.hashAttribute,r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0);if(!c)return l(t,"Skip because missing hashAttribute",{id:o}),g(t,e,-1,!1,n);let d=-1,k=!1,R=!1;if(r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{variation:b,versionIsBlocked:v}=le(ue({context:r,expKey:e.key,expBucketVersion:e.bucketVersion,expHashAttribute:e.hashAttribute,expFallbackAttribute:e.fallbackAttribute,expMinBucketVersion:e.minBucketVersion,expMeta:e.meta}));k=b>=0,d=b,R=!!v}if(!k){if(e.filters&&ye(e.filters,t))return l(t,"Skip because of filters",{id:o}),g(t,e,-1,!1,n);if(e.include&&!X(e.include))return l(t,"Skip because of include function",{id:o}),g(t,e,-1,!1,n);if(e.condition&&!de(e.condition,t))return l(t,"Skip because of condition exp",{id:o}),g(t,e,-1,!1,n);if(e.parentConditions){let b=new Set(t.stack.evaluatedFeatures);for(let v of e.parentConditions){t.stack.evaluatedFeatures=new Set(b);let w=N(v.id,t);if(w.source==="cyclicPrerequisite")return g(t,e,-1,!1,n);let P={value:w.value};if(!h(P,v.condition||{},r.savedGroups||{}))return l(t,"Skip because prerequisite evaluation fails",{id:o}),g(t,e,-1,!1,n)}}}let A=C(e.seed||o,c,e.hashVersion??2);if(A===null)return l(t,"Skip because of invalid hash version",{id:o}),g(t,e,-1,!1,n);if(!k){let b=e.ranges||Q(s,e.coverage===void 0?1:e.coverage,e.weights);d=W(A,b)}if(R)return l(t,"Skip because sticky bucket version is blocked",{id:o}),g(t,e,-1,!1,n,void 0,!0);if(d<0)return l(t,"Skip because of coverage",{id:o}),g(t,e,-1,!1,n);if("force"in e)return l(t,"Force variation",{id:o,variation:e.force}),g(t,e,e.force===void 0?-1:e.force,!1,n);if(r.qaMode)return l(t,"Skip because QA mode",{id:o}),g(t,e,-1,!1,n);let F=g(t,e,d,!0,n,A,k);if(r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{changed:b,key:v,doc:w}=fe(r,f,E(c),{[x(e.key,e.bucketVersion)]:F.key});if(b){r.stickyBucketAssignmentDocs=r.stickyBucketAssignmentDocs||{},r.stickyBucketAssignmentDocs[v]=w;let P=r.saveStickyBucketAssignmentDoc;G(()=>P(w))}}return ce(t,e,F),l(t,"In experiment",{id:o,variation:F.variationId}),F}function m(e,n,t,r,o,s,i){let a={value:t,on:!!t,off:!t,source:r,ruleId:o||""};return s&&(a.experiment=s),i&&(a.experimentResult=i),r!=="override"&&Be(e,n,a),a}function de(e,n){return h(_(n.context),e,n.context.savedGroups||{})}function ye(e,n){return e.some(t=>{let{hashValue:r}=p(n.context,t.attribute);if(!r)return!0;let o=C(t.seed,r,t.hashVersion||2);return o===null?!0:!t.ranges.some(s=>$(o,s))})}function xe(e,n,t,r,o,s,i){if(!o&&s===void 0)return!0;if(!o&&s===0)return!1;let{hashValue:a}=p(e.context,t,r);if(!a)return!1;let u=C(n,a,i??2);return u===null?!1:o?$(u,o):s!==void 0?u<=s:!0}function g(e,n,t,r,o,s,i){let a=!0;(t<0||t>=n.variations.length)&&(t=0,a=!1);let{hashAttribute:u,hashValue:f}=p(e.context,n.hashAttribute,e.context.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0),c=n.meta?.[t]??{},d=n.variations[0];for(let[R,A]of n.variations.entries())if(R===t){d=A;break}let k={key:c.key||""+t,featureId:o,inExperiment:a,hashUsed:r,variationId:t,value:d,hashAttribute:u,hashValue:f,stickyBucketUsed:!!i};return c.name&&(k.name=c.name),s!==void 0&&(k.bucket=s),c.passthrough&&(k.passthrough=c.passthrough),k}function ke(e,n){return n.hashAttribute+n.hashValue+e.key+n.variationId}export{E as a,j as b,Ae as c,h as d,Ce as e,$e as f,ke as g};
|
|
2
|
-
/*! For license information please see chunk-
|
|
1
|
+
import{a as I,b as L}from"./chunk-FRK6322O.js";function M(e){try{let n=e.replace(/([^\\])\//g,"$1\\/");return new RegExp(n)}catch{return}}function j(e,n){if(!n.length)return!1;let t=!1,r=!1;for(let o of n){let s=pe(e,o.type,o.pattern);if(o.include===!1){if(s)return!1}else t=!0,s&&(r=!0)}return r||!t}function he(e,n,t){try{let r=n.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(r="\\/?"+r.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+r+"$","i").test(e)}catch{return!1}}function be(e,n){try{let t=new URL(n.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),r=[[e.host,t.host,!1],[e.pathname,t.pathname,!0]];return t.hash&&r.push([e.hash,t.hash,!1]),t.searchParams.forEach((o,s)=>{r.push([e.searchParams.get(s)||"",o,!1])}),!r.some(o=>!he(o[0],o[1],o[2]))}catch{return!1}}function pe(e,n,t){try{let r=new URL(e,"https://_");if(n==="regex"){let o=M(t);return o?o.test(r.href)||o.test(r.href.substring(r.origin.length)):!1}else if(n==="simple")return be(r,t);return!1}catch{return!1}}function K(e){for(let t of["namespace","status","url","groups"])if(Object.hasOwn(e,t))throw new TypeError(`Retired experiment field: ${t}`);let n=e;if(n.hashVersion!==void 0&&n.hashVersion!==2)throw new TypeError("Only hash version 2 is supported");if(n.filters?.some(t=>t.hashVersion!==2))throw new TypeError("Only hash version 2 is supported")}function T(e){for(let n of Object.values(e)){if(Array.isArray(n))throw new TypeError("Saved groups require typed list or condition entries");if(n&&Object.hasOwn(n,"useEmptyListGroup"))throw new TypeError("Retired saved group field: useEmptyListGroup")}}function H(e){for(let n of["overrides","groups"])if(Object.hasOwn(e,n))throw new TypeError(`Retired evaluation context field: ${n}`);T(e.savedGroups??{})}function J(e){let n=2166136261,t=e.length;for(let r=0;r<t;r++)n^=e.charCodeAt(r),n+=(n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24);return n>>>0}function C(e,n,t){return t===2?J(J(e+n)+"")%1e4/1e4:null}function me(e){return e<=0?[]:new Array(e).fill(1/e)}function $(e,n){return e>=n[0]&&e<n[1]}function W(e,n){for(let[t,r]of n.entries())if($(e,r))return t;return-1}function Q(e,n,t){n=n===void 0?1:n,n<0?n=0:n>1&&(n=1);let r=me(e);t=t||r,t.length!==e&&(t=r);let o=t.reduce((a,u)=>u+a,0);(o<.99||o>1.01)&&(t=r);let s=0,i=n;return t.map(a=>{let u=s;return s+=a,[u,u+i*a]})}function z(e,n,t){if(!n)return null;let r=n.split("?")[1];if(!r)return null;let s=r.replace(/#.*/,"").split("&").map(i=>i.split("=",2)).filter(([i])=>i===e).map(([,i])=>i===void 0?NaN:parseInt(i))[0];return s!==void 0&&s>=0&&s<t?s:null}function X(e){try{return e()}catch{return!1}}function E(e){return typeof e=="string"?e:JSON.stringify(e)}function y(e){typeof e=="number"&&(e=e+""),(!e||typeof e!="string")&&(e="0");let n=e.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return n.length===3&&n.push("~"),n.map(t=>t.match(/^[0-9]+$/)?t.padStart(5," "):t).join("-")}var Y=new Map,D=32,Z=new WeakMap,ee=new WeakMap;function Se(e){return I(L(new TextEncoder().encode(String(e))))}var B=e=>Array.isArray(e)?e.map(B):typeof e=="string"||typeof e=="number"?Se(e):null,O=e=>typeof e=="string"?e.toLowerCase():e;function oe(e){let n=Z.get(e);return n||(n=new Set(e),Z.set(e,n)),n}function ve(e){let n=ee.get(e);return n||(n=new Set(e.map(O)),ee.set(e,n)),n}function Ae(e){T(e);for(let n of Object.values(e)){let t=n?.type==="list"||n?.type==="hashed"?n.values:null;t&&t.length>=D&&oe(t)}return e}function h(e,n,t,r){t=t||{},r||T(t),r=r||new Set;for(let[o,s]of Object.entries(n))switch(o){case"$or":if(!ie(e,s,t,r))return!1;break;case"$nor":if(ie(e,s,t,r))return!1;break;case"$and":if(!Fe(e,s,t,r))return!1;break;case"$not":if(h(e,s,t,r))return!1;break;case"$savedGroup":if(!we(e,s,t,r))return!1;break;default:if(!V(s,se(e,o),t,!1,r))return!1}return!0}function we(e,n,t,r){if(!n||typeof n!="object"||Array.isArray(n))return!1;let{id:o,attributeKey:s}=n;if(typeof o!="string"||r.has(o)||s!==void 0&&typeof s!="string")return!1;let i=t[o];if(!i||Array.isArray(i)||typeof i!="object")return!1;let a=new Set(r).add(o);if(i.type==="list"||i.type==="hashed"){let u=s??i.attributeKey;if(typeof u!="string"||!Array.isArray(i.values))return!1;let f=se(e,u);return S(i.type==="hashed"?B(f):f,i.values)}return i.type==="condition"?!i.condition||typeof i.condition!="object"?!1:h(e,i.condition,t,a):!1}function se(e,n){let t=n.split("."),r=e;for(let o of t)if(r&&typeof r=="object"&&o in r)r=r[o];else return null;return r}function ne(e,n=!1){let t=`${e}${n?"/i":""}`,r=Y.get(t);return r||(r=new RegExp(e.replace(/([^\\])\//g,"$1\\/"),n?"i":void 0),Y.set(t,r)),r}function V(e,n,t,r=!1,o=new Set){if(typeof e=="string")return r?String(n).toLowerCase()===e.toLowerCase():n+""===e;if(typeof e=="number")return n*1===e;if(typeof e=="boolean")return n!==null&&!!n===e;if(e===null)return n===null;if(Array.isArray(e)||!ae(e))return JSON.stringify(n)===JSON.stringify(e);let s=e;for(let i in s)if(!Re(i,n,s[i],t,o))return!1;return!0}function ae(e){let n=Object.keys(e);return n.length>0&&n.filter(t=>t[0]==="$").length===n.length}function Ee(e){if(e===null)return"null";if(Array.isArray(e))return"array";let n=typeof e;return["string","number","boolean","object","undefined"].includes(n)?n:"unknown"}function Ve(e,n,t,r){if(!Array.isArray(e))return!1;let o=ae(n)?s=>V(n,s,t,!1,r):s=>h(s,n,t,r);for(let s=0;s<e.length;s++)if((e[s]??null)!==null&&o(e[s]))return!0;return!1}function S(e,n,t=!1){if(t){let o;if(n.length>=D){let s=ve(n);o=i=>{let a=O(i);return!(typeof a=="number"&&Number.isNaN(a))&&s.has(a)}}else o=s=>n.some(i=>O(s)===O(i));return Array.isArray(e)?e.some(s=>o(s)):o(e)}let r=n.length>=D?(o=>s=>o.has(s))(oe(n)):o=>n.includes(o);return Array.isArray(e)?e.some(o=>r(o)):r(e)}function te(e){return e===void 0?[]:e&&typeof e=="object"&&(e.type==="list"||e.type==="hashed")&&Array.isArray(e.values)?e.values:null}function re(e,n,t,r=!1,o=new Set){if(!Array.isArray(e))return!1;for(let s=0;s<n.length;s++){let i=!1;for(let a=0;a<e.length;a++)if(V(n[s],e[a],t,r,o)){i=!0;break}if(!i)return!1}return!0}function Re(e,n,t,r,o=new Set){let s=n,i=t;switch(e){case"$veq":return y(n)===y(t);case"$vne":return y(n)!==y(t);case"$vgt":return y(n)>y(t);case"$vgte":return y(n)>=y(t);case"$vlt":return y(n)<y(t);case"$vlte":return y(n)<=y(t);case"$eq":return n===t;case"$ne":return n!==t;case"$lt":return s<i;case"$lte":return s<=i;case"$gt":return s>i;case"$gte":return s>=i;case"$exists":return t?n!=null:n==null;case"$in":return Array.isArray(t)?S(n,t):!1;case"$ini":return Array.isArray(t)?S(n,t,!0):!1;case"$inGroup":{let a=r[t],u=te(a);return u===null?!1:S(a?.type==="hashed"?B(n):n,u)}case"$notInGroup":{let a=r[t],u=te(a);return u===null?!1:!S(a?.type==="hashed"?B(n):n,u)}case"$nin":return Array.isArray(t)?!S(n,t):!1;case"$nini":return Array.isArray(t)?!S(n,t,!0):!1;case"$not":return!V(t,n,r,!1,o);case"$size":return Array.isArray(n)?V(t,n.length,r,!1,o):!1;case"$elemMatch":return Ve(n,t,r,o);case"$all":return Array.isArray(t)?re(n,t,r,!1,o):!1;case"$alli":return Array.isArray(t)?re(n,t,r,!0,o):!1;case"$regex":try{return ne(t).test(n)}catch{return!1}case"$regexi":try{return ne(t,!0).test(n)}catch{return!1}case"$type":return Ee(n)===t;default:return!1}}function ie(e,n,t,r){if(!n.length)return!0;for(let o of n)if(h(e,o,t,r))return!0;return!1}function Fe(e,n,t,r){for(let o of n)if(!h(e,o,t,r))return!1;return!0}function ue(e){return Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}function U(e){return H(e),{context:e,stack:{evaluatedFeatures:new Set}}}function _(e){return{...e.attributes,...e.attributeOverrides}}function p(e,n,t){let r=n||"id",o="",s=_(e);return s[r]&&(o=s[r]),!o&&t&&(s[t]&&(o=s[t]),o&&(r=t)),{hashAttribute:r,hashValue:o}}function l(e,n,t){e.context.log?.(n,t)}function x(e,n){return n=n||0,`${e}__${n}`}function q(e,n){return`${e}||${n}`}function Te(e,n,t){let r=e.stickyBucketAssignmentDocs;if(!r)return{};let{hashAttribute:o,hashValue:s}=p(e,n),i=q(o,E(s)),{hashAttribute:a,hashValue:u}=p(e,t),f=u?q(a,E(u)):null,c={};return f&&r[f]&&Object.assign(c,r[f].assignments||{}),r[i]&&Object.assign(c,r[i].assignments||{}),c}function le({context:e,expKey:n,expBucketVersion:t,expHashAttribute:r,expFallbackAttribute:o,expMinBucketVersion:s,expMeta:i}){t=t||0,s=s||0,r=r||"id",i=i||[];let a=x(n,t),u=Te(e,r,o);if(s>0)for(let d=0;d<s;d++){let k=x(n,d);if(u[k]!==void 0)return{variation:-1,versionIsBlocked:!0}}let f=u[a];if(f===void 0)return{variation:-1};let c=i.findIndex(d=>d.key===f);return c<0?{variation:-1}:{variation:c}}function fe(e,n,t,r){let o=q(n,t),s=e.stickyBucketAssignmentDocs,i=s&&s[o]?s[o].assignments||{}:{},a={...i,...r},u=JSON.stringify(i)!==JSON.stringify(a);return{key:o,doc:{attributeName:n,attributeValue:t,assignments:a},changed:u}}function Ce(e,n){let t=U(n),r=ge(e,null,t);return n.onExperimentEval?.(e,r),r}function $e(e,n){return N(e,U(n))}function Oe(e){return e.forcedVariations||{}}function ce(e,n,t){let{context:r}=e;if(r.trackedExperiments){let o=ke(n,t);if(r.trackedExperiments.has(o))return;r.trackedExperiments.add(o)}G(()=>r.onExperimentViewed?.(n,t))}function Be(e,n,t){let{context:r}=e;if(r.trackedFeatureUsage){let o=JSON.stringify(t.value);if(r.trackedFeatureUsage[n]===o)return;r.trackedFeatureUsage[n]=o}G(()=>r.onFeatureUsage?.(n,t))}function G(e){try{let n=e();n&&typeof n.catch=="function"&&n.catch(()=>{})}catch{}}function N(e,n){let{context:t}=n;if(n.stack.evaluatedFeatures.has(e))return l(n,`evalFeature: circular dependency detected: ${n.stack.id} -> ${e}`,{from:n.stack.id,to:e}),m(n,e,null,"cyclicPrerequisite");n.stack.evaluatedFeatures.add(e),n.stack.id=e;let r=t.features?.[e];for(let s of r?.rules??[])K(s);let o=t.forcedFeatureValues;if(o&&o.has(e))return l(n,"Global override",{id:e,value:o.get(e)}),m(n,e,o.get(e),"override");if(!r)return l(n,"Unknown feature",{id:e}),m(n,e,null,"unknownFeature");if(r.rules){let s=new Set(n.stack.evaluatedFeatures);e:for(let i of r.rules){if(i.parentConditions)for(let f of i.parentConditions){n.stack.evaluatedFeatures=new Set(s);let c=N(f.id,n);if(c.source==="cyclicPrerequisite")return m(n,e,null,"cyclicPrerequisite");let d={value:c.value};if(!h(d,f.condition||{},t.savedGroups||{})){if(f.gate)return l(n,"Feature blocked by prerequisite",{id:e,rule:i}),m(n,e,null,"prerequisite");l(n,"Skip rule because prerequisite evaluation fails",{id:e,rule:i});continue e}}if(i.filters&&ye(i.filters,n)){l(n,"Skip rule because of filters",{id:e,rule:i});continue}if("force"in i){if(i.condition&&!de(i.condition,n)){l(n,"Skip rule because of condition ff",{id:e,rule:i});continue}if(!xe(n,i.seed||e,i.hashAttribute,t.saveStickyBucketAssignmentDoc&&!i.disableStickyBucketing?i.fallbackAttribute:void 0,i.range,i.coverage,i.hashVersion)){l(n,"Skip rule because user not included in rollout",{id:e,rule:i});continue}return l(n,"Force value from rule",{id:e,rule:i}),i.tracks&&i.tracks.forEach(f=>{ce(n,f.experiment,f.result)}),m(n,e,i.force,"force",i.id)}if(!i.variations){l(n,"Skip invalid rule",{id:e,rule:i});continue}let a={variations:i.variations,key:i.key||e};"coverage"in i&&(a.coverage=i.coverage),i.weights&&(a.weights=i.weights),i.hashAttribute&&(a.hashAttribute=i.hashAttribute),i.fallbackAttribute&&(a.fallbackAttribute=i.fallbackAttribute),i.disableStickyBucketing&&(a.disableStickyBucketing=i.disableStickyBucketing),i.bucketVersion!==void 0&&(a.bucketVersion=i.bucketVersion),i.minBucketVersion!==void 0&&(a.minBucketVersion=i.minBucketVersion),i.meta&&(a.meta=i.meta),i.ranges&&(a.ranges=i.ranges),i.name&&(a.name=i.name),i.phase&&(a.phase=i.phase),i.seed&&(a.seed=i.seed),i.hashVersion&&(a.hashVersion=i.hashVersion),i.filters&&(a.filters=i.filters),i.condition&&(a.condition=i.condition);let u=ge(a,e,n);if(t.onExperimentEval?.(a,u),u.inExperiment&&!u.passthrough)return m(n,e,u.value,"experiment",i.id,a,u)}}return l(n,"Use default value",{id:e,value:r.defaultValue}),m(n,e,r.defaultValue===void 0?null:r.defaultValue,"defaultValue")}function ge(e,n,t){let{context:r}=t;K(e);let o=e.key,s=e.variations.length;if(s<2)return l(t,"Invalid experiment",{id:o}),g(t,e,-1,!1,n);if(r.enabled===!1)return l(t,"Context disabled",{id:o}),g(t,e,-1,!1,n);if(e.urlPatterns&&!j(r.url||"",e.urlPatterns))return l(t,"Skip because of url targeting",{id:o}),g(t,e,-1,!1,n);let i=z(o,r.url||"",s);if(i!==null)return l(t,"Force via querystring",{id:o,variation:i}),g(t,e,i,!1,n);let u=Oe(r)[o];if(u!==void 0)return l(t,"Force via dev tools",{id:o,variation:u}),g(t,e,u,!1,n);if(e.active===!1)return l(t,"Skip because inactive",{id:o}),g(t,e,-1,!1,n);let{hashAttribute:f,hashValue:c}=p(r,e.hashAttribute,r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0);if(!c)return l(t,"Skip because missing hashAttribute",{id:o}),g(t,e,-1,!1,n);let d=-1,k=!1,R=!1;if(r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{variation:b,versionIsBlocked:v}=le(ue({context:r,expKey:e.key,expBucketVersion:e.bucketVersion,expHashAttribute:e.hashAttribute,expFallbackAttribute:e.fallbackAttribute,expMinBucketVersion:e.minBucketVersion,expMeta:e.meta}));k=b>=0,d=b,R=!!v}if(!k){if(e.filters&&ye(e.filters,t))return l(t,"Skip because of filters",{id:o}),g(t,e,-1,!1,n);if(e.include&&!X(e.include))return l(t,"Skip because of include function",{id:o}),g(t,e,-1,!1,n);if(e.condition&&!de(e.condition,t))return l(t,"Skip because of condition exp",{id:o}),g(t,e,-1,!1,n);if(e.parentConditions){let b=new Set(t.stack.evaluatedFeatures);for(let v of e.parentConditions){t.stack.evaluatedFeatures=new Set(b);let w=N(v.id,t);if(w.source==="cyclicPrerequisite")return g(t,e,-1,!1,n);let P={value:w.value};if(!h(P,v.condition||{},r.savedGroups||{}))return l(t,"Skip because prerequisite evaluation fails",{id:o}),g(t,e,-1,!1,n)}}}let A=C(e.seed||o,c,e.hashVersion??2);if(A===null)return l(t,"Skip because of invalid hash version",{id:o}),g(t,e,-1,!1,n);if(!k){let b=e.ranges||Q(s,e.coverage===void 0?1:e.coverage,e.weights);d=W(A,b)}if(R)return l(t,"Skip because sticky bucket version is blocked",{id:o}),g(t,e,-1,!1,n,void 0,!0);if(d<0)return l(t,"Skip because of coverage",{id:o}),g(t,e,-1,!1,n);if("force"in e)return l(t,"Force variation",{id:o,variation:e.force}),g(t,e,e.force===void 0?-1:e.force,!1,n);if(r.qaMode)return l(t,"Skip because QA mode",{id:o}),g(t,e,-1,!1,n);let F=g(t,e,d,!0,n,A,k);if(r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{changed:b,key:v,doc:w}=fe(r,f,E(c),{[x(e.key,e.bucketVersion)]:F.key});if(b){r.stickyBucketAssignmentDocs=r.stickyBucketAssignmentDocs||{},r.stickyBucketAssignmentDocs[v]=w;let P=r.saveStickyBucketAssignmentDoc;G(()=>P(w))}}return ce(t,e,F),l(t,"In experiment",{id:o,variation:F.variationId}),F}function m(e,n,t,r,o,s,i){let a={value:t,on:!!t,off:!t,source:r,ruleId:o||""};return s&&(a.experiment=s),i&&(a.experimentResult=i),r!=="override"&&Be(e,n,a),a}function de(e,n){return h(_(n.context),e,n.context.savedGroups||{})}function ye(e,n){return e.some(t=>{let{hashValue:r}=p(n.context,t.attribute);if(!r)return!0;let o=C(t.seed,r,t.hashVersion||2);return o===null?!0:!t.ranges.some(s=>$(o,s))})}function xe(e,n,t,r,o,s,i){if(!o&&s===void 0)return!0;if(!o&&s===0)return!1;let{hashValue:a}=p(e.context,t,r);if(!a)return!1;let u=C(n,a,i??2);return u===null?!1:o?$(u,o):s!==void 0?u<=s:!0}function g(e,n,t,r,o,s,i){let a=!0;(t<0||t>=n.variations.length)&&(t=0,a=!1);let{hashAttribute:u,hashValue:f}=p(e.context,n.hashAttribute,e.context.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0),c=n.meta?.[t]??{},d=n.variations[0];for(let[R,A]of n.variations.entries())if(R===t){d=A;break}let k={key:c.key||""+t,featureId:o,inExperiment:a,hashUsed:r,variationId:t,value:d,hashAttribute:u,hashValue:f,stickyBucketUsed:!!i};return c.name&&(k.name=c.name),s!==void 0&&(k.bucket=s),c.passthrough&&(k.passthrough=c.passthrough),k}function ke(e,n){return n.hashAttribute+n.hashValue+e.key+n.variationId}export{E as a,j as b,Ae as c,h as d,Ce as e,$e as f,ke as g};
|
|
2
|
+
/*! For license information please see chunk-FYMVNLQN.js.LEGAL.txt */
|