@tinkerlandai/longplay-sdk 0.10.8 → 0.10.11
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 +15 -0
- package/README.md +38 -2
- package/README.zh-CN.md +2 -0
- package/dist/{ai-usage-Btwg1nD7.d.ts → ai-usage-C-OZBxgW.d.ts} +1 -1
- package/dist/{api-5gAz4-Sb.d.ts → api-Bf_aRlXs.d.ts} +82 -0
- package/dist/chunk-33FQUT3Z.js +179 -0
- package/dist/chunk-4B5G3ZVV.js +4 -0
- package/dist/chunk-4C5XH3T3.js +1 -0
- package/dist/chunk-7DUOIHRD.js +6 -0
- package/dist/chunk-7RDYCTR4.js +1 -0
- package/dist/chunk-CDG7GM4C.js +1 -0
- package/dist/chunk-GDFBOM3V.js +1 -0
- package/dist/chunk-JGFAFQKK.js +1 -0
- package/dist/chunk-OZZMZH7X.js +1 -0
- package/dist/chunk-PYIHBK7E.js +1 -0
- package/dist/chunk-QHJAF5T2.js +1 -0
- package/dist/chunk-VSJOHWDL.js +17 -0
- package/dist/chunk-VSMITXQD.js +1 -0
- package/dist/chunk-ZYQPKGJM.js +1 -0
- package/dist/{configuration-sync-CywDxRkX.d.ts → configuration-sync-D2n_gGj6.d.ts} +1 -0
- package/dist/content-YQ7IJ47M.js +1 -0
- package/dist/{funnel-local-client-B4Z3dvNf.d.ts → funnel-local-client-DJq2K7an.d.ts} +8869 -93
- package/dist/{funnel-node-evaluation-P5B4fPfJ.d.ts → funnel-node-evaluation-CJSkUkbv.d.ts} +36 -0
- package/dist/{funnel-resource-client-BhbXsB2q.d.ts → funnel-process-client-C_UhTH8g.d.ts} +5132 -41
- package/dist/funnel-runtime-host-K2SXD2R2.js +1 -0
- package/dist/index.d.ts +102 -77
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +2 -2
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +1 -1
- package/dist/page.js +1 -1
- package/dist/paywall-PJEMTVSZ.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +109 -106
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-NHJ6OQTF.js +1 -0
- package/dist/server.d.ts +10677 -25
- package/dist/server.js +1 -1
- package/dist/{visual-dom-OIXANRP3.js → visual-dom-7IF7ITAK.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +10 -9
- package/dist/chunk-5JJZSH23.js +0 -179
- package/dist/chunk-5ZS3TNC4.js +0 -1
- package/dist/chunk-7DXL3LHT.js +0 -1
- package/dist/chunk-7XVAFQEE.js +0 -1
- package/dist/chunk-ACF2FBUB.js +0 -1
- package/dist/chunk-CBVZUTNH.js +0 -1
- package/dist/chunk-DCV6IS2Z.js +0 -4
- package/dist/chunk-EI2VRDYJ.js +0 -1
- package/dist/chunk-G56XGVMS.js +0 -1
- package/dist/chunk-GJRXHH6G.js +0 -1
- package/dist/chunk-R26BYN3U.js +0 -1
- package/dist/chunk-RP2P3FU4.js +0 -1
- package/dist/chunk-SBPTOOYB.js +0 -1
- package/dist/chunk-U4UEOR5W.js +0 -6
- package/dist/chunk-XSVQHPQT.js +0 -17
- package/dist/content-XXVHMKKL.js +0 -1
- package/dist/funnel-runtime-host-PBJ63LOE.js +0 -1
- package/dist/paywall-CDR4GZMX.js +0 -1
- package/dist/screen-renderer-NLB3FAQJ.js +0 -1
- /package/dist/{chunk-AK3IJ6FZ.js → chunk-OJM6ORHE.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Ie}from"./chunk-MOWYD2TV.js";import{a as we,b as ye,c as ge,d as ve,e as he}from"./chunk-VSMITXQD.js";import{a as w}from"./chunk-OZZMZH7X.js";import{b as be,e as Ee}from"./chunk-SLUA7ABW.js";import{d as Ce}from"./chunk-QHJAF5T2.js";import{a as J}from"./chunk-DSPLGTQI.js";import{R as fe,da as se}from"./chunk-7DUOIHRD.js";import{Ca as me,s as de,sa as pe}from"./chunk-VSJOHWDL.js";function Pe(e){let R=e.view;if(!R?.paywall)throw new w("INVALID_REQUEST","The current node is not a Paywall");let n=R.paywall.receiptId,b=R.nodeId,d=R.visit,p=R.paywall.resolution,r=R.paywall,h="document"in p?{document:p.document,offering:p.offering,capabilities:p.capabilities}:null;function l(){let o=r.resolution;return"document"in o?o:h&&{...o,document:h.document,offering:h.offering,capabilities:we(o.capabilities,h.capabilities)}}function y(o){if(!ye(o,p))throw new w("INVALID_RESPONSE","The pinned Paywall binding changed")}let q=!1,v=new AbortController,S=R.paywall.purchaseRequestId,m=0,s=null,f=new Map;function N(o){if(o.purchase&&o.purchase.receiptId!==n)throw new w("INVALID_RESPONSE","Purchase receipt changed");let c=o.run.paywall;return o.purchase??(c?.receiptId===n?c:null)}function k(){if(q)throw new w("IDENTITY_CHANGED","Paywall presentation has closed")}function C(o,c,a){if(k(),c!==m||a!==void 0&&r.quote?.operationId!==a)return!1;let g=r.selectionGeneration??0,i=o.run.paywall;if(i?.receiptId===n){if((i.selectionGeneration??0)<(r.selectionGeneration??0))return!1;y(i.resolution)}let u=N(o),D=i?.receiptId===n&&(i.selectionGeneration??0)>g,Q=D?u?.quote??null:u?.quote??r.quote,A=u?.operation??(Q?.operationId===r.quote?.operationId?r.operation:null);return Q&&A&&ge(A,{operationId:Q.operationId},"Purchase operation changed"),(D||Q?.operationId!==r.quote?.operationId)&&(m++,i?.receiptId===n&&(S=i.purchaseRequestId)),r={...r,...i?.receiptId===n?i:{},quote:Q,operation:he(r.operation,A,!0)},!0}function O(o,c,a){return new Promise((g,i)=>{let u=!1,D=()=>{clearTimeout(j),v.signal.removeEventListener("abort",L)},Q=x=>{u||(u=!0,D(),g(x))},A=x=>{u||(u=!0,D(),i(x))},L=()=>A(new w("IDENTITY_CHANGED","Paywall presentation has closed")),j=setTimeout(()=>A(new w("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a)),Math.max(0,c-Date.now()));v.signal.addEventListener("abort",L,{once:!0}),v.signal.aborted&&L(),o.then(Q,A)})}function F(o){return new Promise(c=>{let a=()=>{clearTimeout(g),v.signal.removeEventListener("abort",a),c()},g=setTimeout(a,o);v.signal.addEventListener("abort",a,{once:!0}),v.signal.aborted&&a()})}function E(o,c){k();let a=f.get(o)??e.pendingCommands?.find(u=>u.requestId===o)??e.pendingCommand;if(a?.operation==="submit"&&a.requestId===o&&a.nodeId===b&&a.visit===d){c.type==="paywall_quote"&&a.input.type==="paywall_quote"&&a.input.predecessor&&!c.predecessor&&(c={...c,predecessor:a.input.predecessor});let u=se.parse(a),D=se.parse({...a,input:c});if(u.operation!=="submit"||D.operation!=="submit"||JSON.stringify(u.input)!==JSON.stringify(D.input))throw new w("CONFLICT","A purchase request cannot change its input");return f.set(o,u),u}let g=e.view;if(!g||g.nodeId!==b||g.visit!==d||g.paywall?.receiptId!==n)throw new w("PRECONDITION_FAILED","The Paywall visit has changed");let i=se.parse({operation:"submit",requestId:o,nodeId:b,visit:d,revision:g.revision,input:structuredClone(c)});if(i.operation!=="submit")throw new w("INVALID_REQUEST","A purchase submission is required");return f.set(o,i),i}async function T(o,c){k();let{requestId:a,input:g}=o,i=Date.now()+3e4,u=await O(e.submit(o),i,a);for(;u.run.pendingRequest?.requestId===a&&Date.now()<i&&!q&&(await F(Math.min(1e3,i-Date.now())),!(q||Date.now()>=i));)u=await O(e.resume(a),i,a);if(q)throw new w("IDENTITY_CHANGED","Paywall presentation has closed");if(u.run.pendingRequest?.requestId===a)throw new w("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a);if(!C(u,c,g.type==="paywall_confirm"||g.type==="paywall_cancel"?g.operationId:void 0))throw new w("PRECONDITION_FAILED","The purchase selection has changed")}async function _(o){if(!r.quote)throw new w("INVALID_REQUEST","A quoted purchase is required");let c=o==="confirm"?"paywall_confirm":"paywall_cancel",a=[...f.values(),...e.pendingCommands??(e.pendingCommand?[e.pendingCommand]:[])].find(i=>i.operation==="submit"&&i.input.type===c&&"operationId"in i.input&&i.input.operationId===r.quote.operationId),g=a?.operation==="submit"&&a.input.type===c&&"operationId"in a.input&&a.input.operationId===r.quote.operationId?a.requestId:crypto.randomUUID();if(await T(E(g,{type:o==="confirm"?"paywall_confirm":"paywall_cancel",operationId:r.quote.operationId}),m),!r.operation)throw new w("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(r.operation)}return{get view(){return structuredClone(l())},get quote(){return r.quote?structuredClone(r.quote):null},get operation(){return r.operation?structuredClone(r.operation):null},get webViewUrl(){return e.webViewUrl},get canReselect(){return r.canReselect===!0},async refresh(){k();let o=m,c=await e.get();if(C(c,o),c.run.paywall?.receiptId!==n)throw new w("PRECONDITION_FAILED","Paywall presentation has changed");if(!l()){if("document"in r.resolution||!e.resolvePaywall)throw new w("INVALID_RESPONSE","Public Paywall reader is unavailable");let a=await e.resolvePaywall(r.resolution);k(),y(a),h={document:a.document,offering:a.offering,capabilities:a.capabilities}}return structuredClone(l())},preview(o){let c=l();if(!c)return Promise.reject(new w("PRECONDITION_FAILED","Load the Paywall presentation first"));if(S&&S!==o.requestId&&(s||r.canReselect!==!0))return Promise.reject(new w("COMMAND_PENDING","Retry the original purchase before starting another"));let a=c.document.buttons[o.actionId],g=a?.type==="checkout"?fe(a.product,o.selection,c.capabilities):null;if(!g)return Promise.reject(new w("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let i=me(c.document.screen,g,o.selection,c.capabilities),u=S!==o.requestId&&(r.selectionGeneration??0)>0?{operationId:r.quote?.operationId??null,generation:r.selectionGeneration??0}:void 0;if(u&&r.canReselect!==!0)return Promise.reject(new w("COMMAND_PENDING","Original purchase requires authoritative termination"));let D;try{D=E(o.requestId,{type:"paywall_quote",actionId:o.actionId,productVersionId:g,...Object.keys(i).length?{featureQuantities:i}:{},...u?{predecessor:u}:{},...o.offerId?{offerId:o.offerId}:{},...o.nativeOffer?{nativeOffer:o.nativeOffer}:{}})}catch(L){return Promise.reject(L)}if(S===o.requestId&&s)return s;S!==o.requestId&&m++;let Q=m;S=o.requestId;let A=(async()=>{if(await T(D,Q),!r.quote)throw new w("INVALID_RESPONSE","The accepted quote is missing");return ve(r.quote,{productVersionId:g,featureQuantities:i},"The selected purchase changed"),structuredClone(r.quote)})();return s=A,A.then(()=>{s===A&&(s=null)},L=>{s===A&&(s=null),S===o.requestId&&e.pendingCommand?.requestId!==o.requestId&&L instanceof w&&L.status!==void 0&&L.status<500&&![401,425].includes(L.status)&&(S=null)}),A},confirm:()=>_("confirm"),cancel:()=>_("cancel"),async read(){if(k(),!r.quote)throw new w("INVALID_REQUEST","A quoted purchase is required");let o=r.quote.operationId,c=m,a=e.pendingCommands?.find(D=>D.operation==="submit"&&(D.input.type==="paywall_confirm"||D.input.type==="paywall_cancel")&&D.input.operationId===o)??e.pendingCommand;a?.operation==="submit"&&(a.input.type==="paywall_confirm"||a.input.type==="paywall_cancel")&&a.input.operationId===o&&await e.settle?.(a.requestId);let g=await e.get(void 0,{receiptId:n,operationId:o});k();let i=N(g);if(i?.quote&&i.quote.operationId!==o||i?.operation&&i.operation.operationId!==o)throw new w("INVALID_RESPONSE","Purchase operation changed");let u=C(g,c,o)?r.operation:i?.operation;if(!u)throw new w("INVALID_RESPONSE","The current purchase result is missing");return structuredClone(u)},destroy(){q=!0,v.abort(),f.clear()}}}function Re(e){let R=new Set,n=new Set,b=null;function d(p){if(e.reviewing||R.has(p)||n.has(p)||e.stopped)return;n.add(p);let r=async()=>{if(e.reviewing||e.stopped||e.key!==p){n.delete(p);return}if(e.busy||e.client.pendingCommand){setTimeout(()=>{r()},250);return}let h=(async()=>{let y=e.client.view,q=e.expected(),v=q.requestId,S=!1;try{await e.client.submit({operation:"shown",...q})}catch(m){if(!(m instanceof w)||m.code!=="CONFLICT"||m.status!==409||e.client.pendingCommand)throw m;await e.client.get();let s=e.client.view;if(e.stopped||e.reviewing||e.key!==p||!s||!y||s.id!==y.id||s.source.versionId!==y.source.versionId||s.nodeId!==q.nodeId||s.visit!==q.visit||s.revision<=q.revision||s.stopped||!s.screen||!["running","waiting"].includes(s.status)||e.client.pendingCommand)throw m;let f=e.expected();v=f.requestId,await e.client.submit({operation:"shown",...f})}for(;!e.stopped&&e.key===p&&e.client.pendingCommand?.requestId===v;){if(!e.client.settle)throw new w("COMMAND_PENDING","The original display acknowledgement is still pending");await e.client.settle(v),S=!0,e.client.pendingCommand?.requestId===v&&await new Promise(m=>setTimeout(m,1500))}e.stopped||e.key!==p||(S&&await e.client.get(),!(e.stopped||e.key!==p)&&R.add(p))})();b=h;let l=()=>{b===h&&(b=null),n.delete(p)};h.then(l,y=>{l(),e.busy||e.fail(y)})};r()}return{report:d,get inFlight(){return b}}}function De(e){let R={},n=new Map;async function b(d){let p=e.client.view,r=p?.screen,h=r?.customerData.nodes[d.nodeId];if(e.stopped||e.busy||!p||!r||!h)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(d.action)){let s=e.document,f=s?pe(s,d.nodeId):null,N=f?.type==="customer_data"?f.data.outputs?.[d.action]:void 0;N&&r.outputs.includes(N)?await e.perform(()=>e.client.submit({operation:"submit",...e.expected(),input:{type:"screen",output:N,answers:e.answers,selection:d.value?{[d.nodeId]:d.value}:{}}})):await e.onIntent?.(d,p);return}let y=d.action.startsWith("sources_")?h.resources.find(s=>s.key===d.value):null;if(d.action.startsWith("sources_")&&!y)throw new w("INVALID_REQUEST","Choose a current resource");let q=`${p.visit}:${d.nodeId}:${y?.key??""}`,v=n.get(q)??[null],m=R[d.nodeId]??{page:1,after:null,filter:"all",...y?{resourceKey:y.key}:{}};if(d.action==="filter"){let s=d.value;if(!s||!(h.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(s))throw new w("INVALID_REQUEST","Unknown data filter");m={page:1,after:null,filter:s},v.splice(0,v.length,null)}else if(d.action==="next"||d.action==="sources_next"){let s=y?.sources.at(-1),f=y?s?{kind:"ledger",cursor:{at:s.detail[0],id:s.id,type:"source"}}:null:r.dataCursors[d.nodeId];if(!f||!y&&!h.hasNext)return;v[m.page]=f,m={...m,page:m.page+1,after:f}}else if(d.action==="previous"||d.action==="sources_previous"){if(m.page<=1)return;m={...m,page:m.page-1,after:v[m.page-2]??null}}n.set(q,v),R={...R,[d.nodeId]:m},await e.perform(()=>e.client.get({nodeId:p.nodeId,visit:p.visit,revision:p.revision,components:R}))}return{get queries(){return R},intent:b,reset(){R={},n.clear()}}}function qe(e){let{doc:R,holder:n,reviewHolder:b,mountScreenPreview:d}=e,p=!1,r,h=0,l=null,y="",q=new Map,v=s=>s?`${s.id}:${s.nodeId}:${s.visit}:${s.revision}:${s.paywall?.quote?.operationId??""}`:"";async function S(s){if(e.stopped||!e.client.review)return;p||(y=v(e.client.view),q.set(y,structuredClone(e.answers))),p=!0,r=s,n.hidden=!0,e.suspend(!0),b.hidden=!1;let f=++h;try{let N=await e.client.review(s);if(e.stopped||f!==h||!p)return;if(!N.review)throw new w("INVALID_RESPONSE","Historical projection is missing");l?.destroy(),l=null,b.replaceChildren();let k=N.run.locale.startsWith("zh"),C=R.createElement("p");C.textContent=k?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",b.append(C);for(let[E,T]of N.review.pages.entries()){let _=R.createElement("button");_.type="button",_.textContent=k?`\u7B2C ${E+1} \u9875`:`Page ${E+1}`,_.onclick=()=>{S(T.receiptId)},b.append(_)}if(N.review.page){let E=N.review.page,T=R.createElement("div");if(T.inert=!0,b.append(T),l=d(T,{mode:"live",rendererUrl:e.client.webViewUrl,title:E.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{},onEscape:()=>{m()}}),l.update(E.document,N.run.locale,{serverInput:{bindings:E.inputs,answers:E.answers,values:E.values}}),await l.ready,e.stopped||f!==h||!p)return}let O=k?{issued:"\u5DF2\u9886\u53D6",reserved:"\u5DF2\u9884\u7559",redeemed:"\u5DF2\u4F7F\u7528",expired:"\u5DF2\u8FC7\u671F",revoked:"\u5DF2\u64A4\u9500",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"},F=k?{pending:"\u5904\u7406\u4E2D",complete:"\u5DF2\u5B8C\u6210",cancelled:"\u5DF2\u53D6\u6D88",failed:"\u5931\u8D25",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{pending:"Processing",complete:"Completed",cancelled:"Cancelled",failed:"Failed",unknown:"Status unconfirmed"};for(let E of[...N.review.coupons.map((T,_)=>`${k?"\u4F18\u60E0\u5238":"Coupon"} ${_+1}: ${O[T.status]}`),...N.review.purchases.map((T,_)=>`${k?"\u8D2D\u4E70":"Purchase"} ${_+1}: ${F[T.status]}`)]){let T=R.createElement("p");T.textContent=E,b.append(T)}e.client.view&&await e.enqueue(e.client.view)}catch(N){if(f!==h||e.stopped)return;l?.destroy(),l=null,b.replaceChildren(),e.fail(N)}}async function m(){if(!p||e.stopped||!e.client.review)return;let s=++h;try{if(await e.client.review(),e.stopped||s!==h)return;p=!1,h++,l?.destroy(),l=null,b.replaceChildren(),b.hidden=!0,n.hidden=!1;let f=e.client.view;v(f)!==y?(q.set(y,structuredClone(e.answers)),e.resetScreen()):(q.delete(y),e.suspend(!1)),f&&await e.enqueue(f)}catch(f){if(s!==h||e.stopped)return;l?.destroy(),l=null,b.replaceChildren(),e.fail(f)}}return{get active(){return p},get receipt(){return r},open:S,exit:m,get drafts(){return new Map([...q].map(([s,f])=>[s,structuredClone(f)]))},stop(){p=!1,h++,l?.destroy(),l=null,b.replaceChildren(),b.hidden=!0,n.hidden=!1}}}function Fe(e){if(!e.client.pageExperiments)throw new Error("The Run controller does not support page experiments");let R=e.client.pageExperiments.bind(e.client),n=!1,b=!1,d=0,p=!1,r=!1,h,l=new Map,y=new Set,q={},v=new Map,S=be(e.appManifestRelease),m=()=>{for(let O of l.values())O.effect.revert();l.clear();for(let O of v.values())O();v.clear()};function s(O){if(n||y.has(O))return;y.add(O);let F=d;R(e.appManifestRelease,[O]).catch(E=>{y.delete(O),!n&&F===d&&J(e.onError,E)})}async function f(){if(n)return;let O=e.client.view;if(!O||O.stopped||!["running","waiting"].includes(O.status)){d++,m();return}if(p){r=!0;return}p=!0;let F=++d,E=`${O.id}:${O.visit}:${O.revision}`,T=location.href;try{let[_,{applyVisualVariation:o}]=await Promise.all([R(e.appManifestRelease),import("./visual-dom-7IF7ITAK.js")]),c=e.client.view;if(n||F!==d||!c||c.stopped||!["running","waiting"].includes(c.status)||`${c.id}:${c.visit}:${c.revision}`!==E||location.href!==T)return;let a=new Set,g=new Set;for(let i of _.assignments){let u=`${_.payload.environmentId}:${i.experimentKey}`;if(g.add(u),v.has(u)||v.set(u,Ee(u,q)),!!i.inExperiment)for(let D of _.payload.experiments){if(D.key!==i.experimentKey||!de(location.href,D.urlPatterns??[]))continue;let Q=D.meta?.findIndex(G=>G.key===i.variationKey)??-1,A=D.variations[Q];if(!A?.renderGuard)continue;let L=i.receiptId+":"+D.changeId,j=JSON.stringify([i.variationKey,A]);a.add(L);let x=l.get(L);if(x?.signature===j){x.effect.applied&&s(i.receiptId);continue}l.get(L)?.effect.revert(),l.delete(L);let B=o(A,{requireUniqueTargets:!0,boundVariations:D.variations,allowJs:!1,onApplied:()=>s(i.receiptId),onError:G=>J(e.onError,G)});l.set(L,{signature:j,effect:B}),B.applied&&s(i.receiptId)}}for(let[i,u]of l)a.has(i)||(u.effect.revert(),l.delete(i));for(let[i,u]of v)g.has(i)||(u(),v.delete(i))}catch(_){F===d&&m(),!n&&F===d&&J(e.onError,_)}finally{p=!1,r&&!n&&(r=!1,f())}}let N=e.client.subscribe(()=>{d++,f()}),k=Ce(()=>{d++,m(),f()}),C=async()=>{await f(),n||(h=setTimeout(()=>{C()},15e3))};return{async start(){b||n||(b=!0,await C())},refresh:f,destroy(){n=!0,d++,clearTimeout(h),N(),k(),m(),S.destroy()}}}async function an(e,R){let n=R,{mountScreenPreview:b}=await import("./screen-renderer-NHJ6OQTF.js"),{showPaywall:d}=await import("./paywall-PJEMTVSZ.js"),p=n.appManifestRelease?Fe({client:n.client,appManifestRelease:n.appManifestRelease,onError:n.onError}):void 0;p?.start();let r=e.ownerDocument,h=r.activeElement,l=r.createElement("section"),y=r.createElement("div"),q=r.createElement("div"),v=r.createElement("div"),S=r.createElement("button");v.hidden=!0,S.type="button";let m=r.createElement("p"),s=r.createElement("p"),f=r.createElement("button"),N=r.createElement("button"),k=r.createElement("button"),C=r.createElement("dialog"),O;l.dataset.indianaFunnel="",l.setAttribute("aria-busy","false"),l.style.cssText="box-sizing:border-box;width:100%;min-width:0;font:14px/1.5 system-ui,sans-serif;color:#172033;background:#fff",q.style.cssText="display:flex;gap:12px;align-items:center;flex-wrap:wrap;padding:12px 20px",m.setAttribute("role","status"),s.setAttribute("role","alert"),s.hidden=!0,f.type=N.type=k.type="button",q.append(f,m,s,k,S,N),l.append(y,v,q),e.append(l);let F=null,E=null,T=null,_="",o="",c="",a="",g="",i=!1,u=0,D=!1,Q="",A=null,L=Promise.resolve(),j=null,x=null,B=new Set,G={},z=(t,I=null)=>{i||(x=I,s.textContent=t instanceof Error?t.message:"Request failed",s.hidden=!1,k.hidden=n.client.pendingCommand===null,J(n.onError,t))};function W(){let t=n.client.view;if(!t)throw new w("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision}}let V=qe({client:n.client,doc:r,holder:y,reviewHolder:v,mountScreenPreview:b,get stopped(){return i},get answers(){return G},suspend(t){E?.setSuspended(t)},resetScreen(){_="",o="",c=""},enqueue:K,fail:z}),Z=Re({client:n.client,expected:W,fail:z,get stopped(){return i},get reviewing(){return V.active},get key(){return _},get busy(){return u}}),te=De({client:n.client,expected:W,perform:Y,onIntent:n.onCustomerDataIntent,get stopped(){return i},get busy(){return u},get document(){return F?.document},get answers(){return G}}),ae=t=>t&&(t.screen||t.paywall)?`${t.id}:${t.nodeId}:${t.visit}`:"";function ee(){let t=n.client.view;f.disabled=!V.active&&(u>0||!!n.client.pendingCommand||!t?.canBack||t.stopped||!["running","waiting"].includes(t.status)||!ae(t)||o!==ae(t))}async function Y(t,I=!1){if(!(u&&!I||i||V.active&&!I)){u++,l.setAttribute("aria-busy","true"),ee(),s.hidden=!0,x=null;try{if(!I&&Z.inFlight){let P=n.client.view;await Z.inFlight;let $=n.client.view;if(!P||!$||$.id!==P.id||$.nodeId!==P.nodeId||$.visit!==P.visit||$.stopped||!["running","waiting"].includes($.status))throw new w("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}if(i)return;let H=await t();i||await K(n.client.view??H.run)}catch(H){z(H,n.client.pendingCommand?.requestId??null)}finally{u=Math.max(0,u-1),l.setAttribute("aria-busy",String(u>0)),i||(k.hidden=n.client.pendingCommand===null,ee())}}}function ie(){A&&clearTimeout(A),!(i||!T||!["running","waiting"].includes(T.status)&&!n.client.pendingCommand)&&(A=setTimeout(()=>{A=null,ce().finally(ie)},T.pendingRequest||n.client.pendingCommand?1500:5e3))}async function ce(){if(!(i||D||u)){if(V.active){await V.open(V.receipt);return}D=!0;try{let t=n.client.pendingCommand;t&&n.client.settle&&await n.client.settle(t.requestId);let I=n.client.view,H=te.queries,P=await n.client.get(I?.screen&&Object.keys(H).length?{nodeId:I.nodeId,visit:I.visit,revision:I.revision,components:H}:void 0);!i&&H===te.queries&&await K(n.client.view??P.run)}catch(t){z(t)}finally{D=!1}}}function Se(t){let I=t.screen?.presentation;if(!I||I.type==="inline"){C.open&&C.close(),l.parentElement!==e&&e.append(l);return}l.parentElement!==C&&(C.append(l),e.append(C));let H={sm:420,md:640,lg:900};C.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in I?H[I.size]+"px":"100vw"}`,C.setAttribute("aria-label",(O?.screen===t.screen?.content.document.name?O?.label:void 0)??F?.document?.name??t.screen?.content.document.name??"Funnel"),C.open||(C.showModal(),Ie(C,I.type))}async function Ne(t){if(i)return;T=t,x&&n.client.pendingCommand?.requestId!==x&&(s.hidden=!0,x=null);let I=t.locale.startsWith("zh");if(S.textContent=I?"\u56DE\u770B":"History",S.hidden=!n.client.review,f.textContent=V.active?I?"\u8FD4\u56DE\u5F53\u524D":"Return to current":I?"\u8FD4\u56DE":"Back",N.textContent=I?"\u5173\u95ED":"Close",k.textContent=I?"\u91CD\u8BD5":"Retry",ee(),k.hidden=n.client.pendingCommand===null,m.textContent=t.pendingRequest?I?"\u6B63\u5728\u5904\u7406":"Processing":t.instruction?.type==="wait"?I?"\u7B49\u5F85\u4E2D":"Waiting":"",Q!==`${t.revision}:${t.visit}:${t.status}:${t.stopped}`&&(Q=`${t.revision}:${t.visit}:${t.status}:${t.stopped}`,J(n.onState,structuredClone(t))),!t.pendingRequest&&["closed","ineligible","failed"].includes(t.status)){ne();return}if(t.stopped||n.client.configurationReady===!1){V.stop(),F?.destroy(),F=null,E?.destroy(),E=null,y.replaceChildren(),_="",o="",c="",g="",C.open&&C.close(),l.hidden=!0,ie();return}if(l.hidden=!1,V.active){ie();return}let H=ae(t);if(H!==_&&(o="",F?.destroy(),F=null,E?.destroy(),E=null,y.replaceChildren(),_=H,c="",g="",G={...t.answers},te.reset()),Se(t),t.screen){let $=t.screen.content;F||(F=b(y,{mode:"live",rendererUrl:n.client.webViewUrl,title:$.document.name,onAction(U,le={},ue={}){if(V.active)return;G={...G,...ue};let _e=Object.fromEntries((t.screen?.inputs??[]).filter(({variable:oe})=>Object.hasOwn(G,oe)).map(({variable:oe})=>[oe,G[oe]]));Y(()=>n.client.submit({operation:"submit",...W(),input:{type:"screen",output:U,answers:_e,selection:le}}))},onAnswers:U=>{V.active||(G={...G,...U})},onCustomerDataIntent:U=>{V.active||te.intent(U).catch(z)},onEscape:()=>{V.active||re()},onError:U=>z(new Error(U)),onRendered:U=>{if(!U)return Z.report(H);O={screen:$.document.name,label:U},C.open&&C.setAttribute("aria-label",U),Z.report(H)}}));let M={capabilities:t.screen.capabilities,customerData:t.screen.customerData,parameters:t.parameters,serverInput:{bindings:t.screen.inputs,answers:G,values:t.screen.values}},X=JSON.stringify([$,t.locale,M.parameters,t.screen.inputs,t.screen.values]);if(X!==c)F.update($.document,t.locale,M),c=X,a=JSON.stringify(M.capabilities),g=JSON.stringify(M.customerData);else{let U=JSON.stringify(M.capabilities);U!==a&&(F.updateCapabilities(M.capabilities),a=U),JSON.stringify(M.customerData)!==g&&(F.updateCustomerData(M.customerData),g=JSON.stringify(M.customerData))}await F.ready}else if(t.paywall&&!E){let $=await d(y,{canInteract:()=>!V.active&&!i,start:async()=>Pe(n.client),onPurchase:n.onPurchase,onCheckoutUrl:n.onCheckoutUrl,resolveOfferId:n.resolveOfferId,onEvent:n.onEvent,onOpenUrl:M=>n.onOpenUrl?n.onOpenUrl({receiptId:t.paywall.receiptId,url:M,openIn:"same_window"}):r.defaultView?.location.assign(M),onAction:async M=>{if(V.active)return;let X=await n.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision,input:{type:"screen",output:M,answers:{}}});await K(n.client.view??X.run)},onError:z,onDismiss:()=>{!V.active&&!i&&n.client.view?.visit===t.visit&&re()}});i?$.host?.destroy():(E=$.host,E?.setSuspended(V.active)),Z.report(H)}if(i)return;o=H,ee();let P=t.instruction;if(P&&(P.type==="open_url"||P.type==="event")&&!B.has(P.receiptId)){let $=r.createElement("button");$.type="button",$.textContent=P.type==="open_url"?`${I?"\u524D\u5F80":"Continue to"} ${new URL(P.url).host}`:I?"\u7EE7\u7EED":"Continue",$.onclick=()=>{let M=W(),X=P.type==="open_url"&&!n.onOpenUrl&&P.openIn==="new_window"?ke(P.url):null;Y(async()=>{let U="success";if(P.type==="open_url")if(n.onOpenUrl)try{U=await n.onOpenUrl({receiptId:P.receiptId,url:P.url,openIn:P.openIn})===!1?"failed":"opened"}catch(ue){J(n.onError,ue),U="failed"}else U=P.openIn==="new_window"&&!X?"failed":"opened";if(P.type==="event"){if(!n.onEvent)throw new w("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(P.event)}if(i||n.client.view?.nodeId!==M.nodeId||n.client.view.visit!==M.visit)throw new w("PRECONDITION_FAILED","The client action visit changed");let le=await n.client.submit({operation:"submit",...M,input:{type:"client_action",receiptId:P.receiptId,outcome:U}});return B.add(P.receiptId),P.type==="open_url"&&!n.onOpenUrl&&P.openIn==="same_window"&&r.defaultView?.location.assign(P.url),le})},y.replaceChildren($)}!t.pendingRequest&&t.status==="completed"&&!B.has(`complete:${t.id}`)&&(B.add(`complete:${t.id}`),J(n.onComplete,structuredClone(t))),ie()}function ke(t){let I=r.defaultView?.open(t,"_blank")??null;return I&&(I.opener=null),I}function K(t){return ee(),L=L.catch(()=>{}).then(()=>Ne(t)),L}let Oe=n.client.subscribe(t=>{n.client.configurationReady===!1&&(l.hidden=!0,F?.destroy(),F=null,E?.destroy(),E=null,y.replaceChildren(),_="",o="",c="",g="",C.open&&C.close()),K(t).catch(z)}),Te=n.client.subscribeError?.(z);function re(){return j||(i?Promise.resolve():n.client.view&&!["running","waiting"].includes(n.client.view.status)?(ne(),Promise.resolve()):(j=Y(()=>n.client.submit({operation:"close",...W()}),!0).then(()=>{n.client.view?.status==="closed"&&ne()}).finally(()=>{j=null}),j))}function ne(){p?.destroy(),!i&&(i=!0,A&&clearTimeout(A),Oe(),Te?.(),F?.destroy(),V.stop(),E?.destroy(),C.close(),C.remove(),l.remove(),h instanceof HTMLElement&&h.isConnected&&h.focus(),J(n.onDismiss,T?structuredClone(T):null))}f.onclick=()=>{if(!f.disabled){if(V.active){V.exit();return}Y(()=>n.client.submit({operation:"back",...W()}))}},S.onclick=()=>{V.open()},N.onclick=()=>{re()},k.onclick=()=>{Y(()=>n.client.retry())},C.addEventListener("cancel",t=>{t.preventDefault(),re()});try{let t=await n.client.get();await K(n.client.view??t.run)}catch(t){throw ne(),t}return{destroy:ne,refresh:ce,review:V.open,exitReview:V.exit,get unappliedDrafts(){return V.drafts}}}export{Fe as a,an as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as P}from"./chunk-OZZMZH7X.js";import{a as sA,bb as zA,cb as FA,h as pA,i as xA,j as gA,o as $A}from"./chunk-7DUOIHRD.js";import{a as MA,d as jA,e as UA,f as _A}from"./chunk-VSJOHWDL.js";function S(A){return typeof A=="string"?A:String(A)}var ye=/[\ud800-\udbff](?![\udc00-\udfff])|(^|[^\ud800-\udbff])[\udc00-\udfff]/g;function Pe(A){return A.replace(ye,"$1\uFFFD")}function PA(A,e){if(typeof A!="object"||A==null){let t="";throw t+="The provided value is not an object",new TypeError(t)}return A}function ZA(A){if(A!=null&&(typeof A=="object"||typeof A=="function")){let e=A[Symbol.iterator];if(e==null)return;if(typeof e!="function")throw new TypeError("The provided value is not iterable");let t=e.call(A);if(!t||typeof t!="object")throw new TypeError("Result of the Symbol.iterator method is not an object");return t}}function QA(A){let e;if(Array.isArray(A)){let t=A.map(S);if(t.length===2)return t}else if((e=ZA(A))!=null){let t=PA(e.next()),n=PA(e.next());if(!t.done&&!n.done)return[S(t.value),S(n.value)]}throw new TypeError("Each query pair must be an iterable [name, value] tuple")}var GA="0123456789ABCDEF",De=/(?:%[0-9A-Fa-f]{2})+/g;function U(A){return`%${GA[A>>4&15]}${GA[15&A]}`}function Ae(A,e,t=!1){return A>=55296&&A<=57343&&(A=65533),A<=127?t&&A===32?"+":e(A)?U(A):String.fromCharCode(A):A<=2047?U(192|A>>6)+U(128|63&A):A<=65535?U(224|A>>12)+U(128|A>>6&63)+U(128|63&A):U(240|A>>18)+U(128|A>>12&63)+U(128|A>>6&63)+U(128|63&A)}function DA(A){return A>=48&&A<=57?A-48:A>=65&&A<=70?A-65+10:A>=97&&A<=102?A-97+10:-1}function bA(A,e=!1){let t=0;for(;t<A.length;t++){let n=A.charCodeAt(t);if(n===37||e&&n===43)break}return t===A.length?A:(e?A.replace(/\+/g," "):A).replace(De,n=>{try{return decodeURIComponent(n)}catch{return"\uFFFD".repeat(n.length/3)}})}function AA(A){return A<=31||A>126}function be(A){switch(A){case 32:case 34:case 60:case 62:case 96:return!0;default:return AA(A)}}function qA(A){switch(A){case 32:case 34:case 35:case 60:case 62:return!0;default:return AA(A)}}function Se(A){return qA(A)||A===39}function SA(A){switch(A){case 63:case 94:case 96:case 123:case 125:return!0;default:return qA(A)}}function cA(A){switch(A){case 47:case 58:case 59:case 61:case 64:case 91:case 92:case 93:case 124:return!0;default:return SA(A)}}function YA(A){switch(A){case 33:case 39:case 40:case 41:case 126:return!0;default:return(function(t){switch(t){case 36:case 37:case 38:case 43:case 44:return!0;default:return cA(t)}})(A)}}function ee(A,e){return Ae(A=A||0,e)}function _(A,e,t=!1){let n=0;for(;n<A.length;n++){let u=A.charCodeAt(n);if(u>=128||t&&u===32||e(u))break}if(n===A.length)return A;let r=A.slice(0,n);for(;n<A.length;n++){let u=A.charCodeAt(n),l=u;if(u>=55296&&u<=56319&&n+1<A.length){let a=A.charCodeAt(n+1);a>=56320&&a<=57343&&(l=(u-55296<<10)+a-56320+65536,n++)}r+=Ae(l,e,t)}return r}function NA(A){let e=[],t=0,n=0;for(;n<=A.length;){if(n=A.indexOf("&",t),n<0&&(n=A.length),n!==t){let r=A.slice(t,n),u=r.indexOf("=");u<0&&(u=r.length),e.push([bA(r.slice(0,u),!0),bA(r.slice(u+1),!0)])}if(t=n+1,n===A.length)break}return e}function CA(A){let e="";for(let t=0;t<A.length;t++){let n=_(A[t][0],YA,!0),r=_(A[t][1],YA,!0);e+=t!==0?`&${n}=${r}`:`${n}=${r}`}return e}var Ce=[2191,2191,3164,3164,3292,3292,6863,6877,6880,6891,8385,8385,11158,11158,42958,42959,42962,42962,42964,42964,42993,42993,64451,64466,64912,64913,64968,64974,67904,67929,69317,69319,69328,69336,69370,69371,72544,72551,73136,73179,73184,73193,93856,93880,93883,93907,94194,94198,100344,100351,101641,101662,101760,101874,118010,118012,118458,118480,118496,118512,124608,124638,124640,124661,124670,124671,128728,128728,128887,128890,129232,129240,129620,129623,129674,129674,129678,129678,129736,129736,129741,129741,129770,129770,129775,129775,130042,130042,177978,177983,183970,183981,205744,210041],Ie=[7296,7297,7298,7299,7300,7301,7302,7303,7304,42958,42962,42964,42993],Ee=["\u0432","\u0434","\u043E","\u0441","\u0442","\u0442","\u044A","\u0463","\uA64B","\uA7CF","\uA7D3","\uA7D5","s"],ve=[2381,2381,2509,2509,2637,2637,2765,2765,2893,2893,3021,3021,3149,3149,3277,3277,3387,3388,3405,3405,3530,3530,3642,3642,3770,3770,3972,3972,4153,4154,5908,5909,5940,5940,6098,6098,6752,6752,6980,6980,7082,7083,7154,7155,11647,11647,43014,43014,43052,43052,43204,43204,43347,43347,43456,43456,43766,43766,44013,44013,68159,68159,69702,69702,69744,69744,69759,69759,69817,69817,69939,69940,70080,70080,70197,70197,70378,70378,70477,70477,70606,70608,70722,70722,70850,70850,71103,71103,71231,71231,71350,71350,71467,71467,71737,71737,71997,71998,72160,72160,72244,72244,72263,72263,72345,72345,72767,72767,73028,73029,73111,73111,73537,73538,90415,90415];function Te(A){for(let e=0;e<A.length;e++){let t=A.codePointAt(e);if(t>65535&&e++,t<=32||t===37||t===127||t>=55296&&t<=57343||t>=128&&t<=159||t>=64976&&t<=65007||!(65534&~t)||t===65533)return!0}return!1}var[qe,Ne,Oe,VA]=[[[],"0,6,7,8,m,w,10,1b,1d,1f,72,73,7k,8k,dt,2rk","AAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAA/AAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAADAAABwfwAAAAAAAMADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhAAAAQAAAAAAAAQCAAABAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgACAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAP///////////////wAAAAAAAAAAAAAAAAAAAAA="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAEF9+P/+BwAAAMAA//8AAPz/////BlADAAAAAJwAAPz///8AAADA//H/5+X8AAAAAAAAAAAA/P///wcAAAAAAAAAAAAAPv0vAD0BAABA/gAA/5/5/f8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8g+N8B+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAYAAAAAAAAAAAAAD/////CwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANgAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/HgwAAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAP3////+BwAAAMDu//////////////8vAADAAJwAAP3///8AAADg////////AAAAAAAAAAAA/P///wcAAAAAAAAAAAAA////Ab0H//9H/gAA/9////8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL/G//8T+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAfgAAAAAAAAAAAAD+////DwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANwAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/Hg4AAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"0,3,4,5,6,7,8,9,a,b,c,d,e,f,g,j,n,o,p,q,r,s,t,w,18,19,1c,4m,4o,4p,4q,4r,6z,72,73,75,76,77,7e,7h,7i,7j,7k,7l,7m,7n,7o,7p,7q,7r,7s,7t,7u,7v,7w,7x,7y,7z,8k,9t,a2,a3,a7,cc,cv,cx,cy,d6,dc,dd,de,dg,dh,di,dk,dl,2rk,2rl","AAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAD//////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/v////+/tgAAAAAAAAAAAP8XAAAAAAD4//8AAAEAAAAAAAAAAAAAAMCfnz0AAACAAgAAAP///wcAAAAAAAAAAAAAwP8BAAAAAAAA+A8gAADA++8+AAAAAAAOAAAAAAAAgP8AAAAAAPz///v///8HAAAAAAAAFP4h/gAMAAAAAgAAAAAAABAeIAAADAAAQAYAAAAAAAAQhjkCAAAAIwAGAAAAAAAAEL4hAAAMAAD8AgAAAAAAAJAeIGAADAAAAAQAAAAAAAAAASAAAAAAAAARAAAAAAAA0ME9YAAMAAAAAgAAAAAAAJBAMAAADAAAAAMAAAAAAAAYHiAAAAwAAAACAAAAAAAAAAAEXAAAAAAAAAAAAAAA8geAfwAAAAAAAAAAAAAAAPIfAH8AAAAAAAAAAAADAACgAgAAAAAAAP5/3+D//v///x9AAAAAAAAAAAAAAAAA4P1mAAAAwwEAHgBkIAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAMAAAADAAAAAwAAAAAAAAAsD9A/g8gAAAAAAC4AAAAAAAAAAAAAAAAAABgAAAAAAIAAAAAAAAAAAAAAAAAAIcBBA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAJAAAAAAAAQH/lH/ifAAAAAAAA//////8//w8AAA8AAAAAANAXBAAAAAD4DwADAAAAPDsAAAAAAABAowMAAAAAAADwzwAAAAAAAAAAAAAAAAAAAAAAAAD3//0hEAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wDIAAAAfAAAAAAAAB/8AAAAAAAAAAAAAAAA/////wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAwAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAA/////wAAAAAAPAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAID3PwAAAMAAAAAAAAAAAAAAAwBECAAAYBAAAAAAAAAAAAAAAAAAAAAAAAAwAAAA//8DgAAAAADAPwAAgP8DAAAAAAAHAAAAAADIMwAAAAAgAAAAAAAAAAB+ZgAIEAAAAAAAEAAAAAAAAJ3BAgAAAAAwQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICEAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAP//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAMAHAAAAAAAAAAAAAAAAAAAAAG7wAAAAAACHAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAPAAAAAAAAAAAD4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAA/AAAAAAAAAAAwP8BAAAAAAA8AAAAAAAAAAAAAAAAAAAAAgAAAAAAAP9/AAAAAAAZgAMAAAAAAHgGBAAAAAAAAAAHAAAAgO8fAAAAAAAAAAgAAwAAAAAAwH8AngAAAAAAAAAAAAAAgNNAAgAAAAAAAAAAAAAAAAAAAAAAAID4BwAAAwAAAAAAABgBAAAAwB8fAAAAAAAAAAD4AUAFAAYAAAAAAAAAAAAA/1wAAEAAAAAAAAAAAAAA+IUNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8sAEAADAAAAAAAAAAAAAA+KcBAAAAAAAAAAAAAAAAKL8AAAAAAAAAAAAAAACgvA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgP8GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFgIAAAAAAAAAAAAAAAAAAAAAADwDAEAAAD+BwAAAAD4eYAAfg4AAAAAAPx/AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf78AAAAAAAAAAAAA/P///G0AAAAAAAAAAAAAAAAAAAB+tL8AAAAAAAAAAACjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAwAcFAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//4H/PwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMD/4wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHwAAAAAAAAB/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAcAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAPAAAAAAAAAAAAAAD//////z///38AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAD+P/nDwAAADwAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////9/+P//////HyAAEAAA+P7/AAAAAAAAAAAAAH////nbBwAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASMAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAADwDwAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAA////////////////AAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////wAA"]].map(function([e,t,n]){return[e,t.split(",").map(r=>parseInt(r,36)),Uint8Array.from(atob(n),r=>r.charCodeAt(0))]});function Re(A,e){return e===931||e===1010||e===120531||e===120589||e===120647||e===120705||e===120763?"\u03C3":e>=5112&&e<=5117?String.fromCodePoint(e-8):e>=43888&&e<=43967?String.fromCodePoint(e-38864):e>=93856&&e<=93880?String.fromCodePoint(e+27):e===837||e===890||e>=8064&&e<=8111||e>=8114&&e<=8188?A.normalize("NFD").replace(/\u0345/g,"\u03B9").normalize("NFC").toLowerCase():""}function te(A,e){for(let t=0;t<A.length;t+=2)if(e>=A[t]&&e<=A[t+1])return!0;return!1}function X(A,e){let[t,n,r]=A,u=e>>8;for(let f=0;f<t.length;f+=2)if(u>=t[f]&&u<=t[f+1])return!0;let l=n.indexOf(u);if(l<0)return!1;let a=255&e;return!!(r[32*l+(a>>3)]&1<<(7&a))}function ke(A){let e=Array.from(A,t=>t.codePointAt(0));for(let t=0;t<e.length;t++){let n=e[t];if(n!==8204&&n!==8205||t>0&&te(ve,e[t-1]))continue;if(n===8205)return!1;let r=t-1;for(;r>=0&&X(VA,e[r]);)r--;let u=t+1;for(;u<e.length&&X(VA,e[u]);)u++;if(!(r>=0&&u<e.length&&X(Ne,e[r])&&X(Oe,e[u])))return!1}return!0}var Le=/(?![\p{Mark}\p{Decimal_Number}])[\p{Script=Arabic}\p{Script=Hebrew}]/u,Be=/\p{Script=Latin}/u;function He(A){return!Le.test(A)||!Be.test(A)}var F=36,iA=1,IA=26,Me=38,je=700,Ue=72,_e=128,xe=2147483647;function KA(A){return String.fromCharCode(A+22+75*+(A<26))}function $e(A,e,t){let n=0;for(A=t?Math.floor(A/je):A>>1,A+=Math.floor(A/e);A>(F-iA)*IA>>1;n+=F)A=Math.floor(A/(F-iA));return Math.floor(n+(F-iA+1)*A/(A+Me))}function ze(A){let e=Array.from(A,f=>f.codePointAt(0)),t="",n=0;for(let f=0;f<e.length;f++){let h=e[f];h<128&&(t+=String.fromCharCode(h),n++)}let r=n;r&&(t+="-");let u=_e,l=0,a=Ue;for(;n<e.length;){let f=xe;for(let h=0;h<e.length;h++){let w=e[h];w>=u&&w<f&&(f=w)}l+=(f-u)*(n+1),u=f;for(let h=0;h<e.length;h++){let w=e[h];if(w<u&&l++,w===u){let p=l;for(let m=F;;m+=F){let y=m<=a?iA:m>=a+IA?IA:m-a;if(p<y)break;t+=KA(y+(p-y)%(F-y)),p=Math.floor((p-y)/(F-y))}t+=KA(p),a=$e(l,n+1,n===r),l=0,n++}}l++,u++}return t}function wA(A){let e=10;if(A.length>=2&&A[0]==="0"&&(A[1]==="x"||A[1]==="X"))A=A.slice(2),e=16;else if(A.length>=2&&A[0]==="0")A=A.slice(1),e=8;else if(A==="")return-1;let t=0;for(let n=0;n<A.length;n++){let r=DA(A.charCodeAt(n));if(r>=e||r<0)return-1;t=t*e+r}return t}function JA(A){switch(A){case".":case"%2e":case"%2E":return!0;default:return!1}}function ne(A,e){return(A>=65&&A<=90||A>=97&&A<=122)&&(e===58||e===124)}function re(A){return A.length===2&&ne(A.codePointAt(0),A.codePointAt(1))}function WA(A){return A.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u)!==-1}function I(A){switch(A){case"ftp":case"http":case"https":case"ws":case"wss":case"file":return!0;default:return!1}}function se(A){switch(A){case"ftp":return 21;case"http":case"ws":return 80;case"https":case"wss":return 443;default:return null}}function EA(A,e){if(A[0]==="[")return A[A.length-1]==="]"?(function(n){let r=[0,0,0,0,0,0,0,0],u=null,l=0,a=0,f=Array.from(n,h=>h.codePointAt(0));if(f[a]===58){if(f[a+1]!==58)return null;a+=2,l++,u=l}for(;a<f.length;){if(l===8)return null;if(f[a]===58){if(u!==null)return null;a++,l++,u=l;continue}let h=0,w=0,p=0;for(;p<4&&(h=DA(f[a]))>=0;)w=(w<<4)+h,a++,p++;if(f[a]===46){if(p===0||l>6)return null;a-=p;let m=0;for(;f[a]!==void 0;){let y=0;if(m>0)if(f[a]===46&&m<4)a++;else return null;if(f[a]==null||f[a]<48||f[a]>57)return null;for(;f[a]>=48&&f[a]<=57;){if(y=10*y+DA(f[a]),y>255)return null;a++}r[l]=256*r[l]+y,m++,m%2==0&&l++}if(m!==4)return null;break}else if(f[a]===58){if(f[++a]===void 0)return null}else if(f[a]!==void 0)return null;r[l]=w,l++}if(u!==null){let h=l-u;for(l=7;l!==0&&h>0;){let w=r[u+h-1];r[u+h-1]=r[l],r[l]=w,l--,h--}}else if(u===null&&l!==8)return null;return r})(A.substring(1,A.length-1)):null;if(e)return(function(n){return WA(n)?null:_(n,AA)})(A);{let t=(function(r){let u=!1,l=!1;for(let f=0;f<r.length;f++){let h=r.charCodeAt(f);if(h<=32||h===37||h===127)return null;if(h>=128){u=!0;break}h>=65&&h<=90&&(l=!0)}if(!u)return r!==""?l?r.toLowerCase():r:null;if((function(h){for(let w of h){let p=w.codePointAt(0);if(/[\p{Cn}\p{Co}\p{Cs}\p{Noncharacter_Code_Point}]/u.test(w)&&!te(Ce,p)||X(qe,p))return!0}return!1})(r))return null;let a=(r=(function(h){let w="";for(let p of h){let m=p.codePointAt(0);if(m!==8204&&m!==8205&&/\p{Default_Ignorable_Code_Point}/u.test(p))continue;let y=Re(p,m);if(y){w+=y;continue}let N=Ie.indexOf(m);w+=N<0?p:Ee[N]}return w})(r).normalize("NFKC").replace(/[\u3002\uff0e\uff61]/g,".").toLowerCase()).split(".");for(let f=0;f<a.length;f++){let h=a[f];if(h==="")continue;let w=/[^\0-\x7f]/.test(h);if(Te(h)||w&&(/^\p{Mark}/u.test(h)||!ke(h)||!He(h)||h.startsWith("xn--")))return null;w&&(a[f]=`xn--${ze(h)}`)}return(r=a.join("."))!==""?r:null})(A.indexOf("%")===-1?A:bA(A));return t===null||WA(t)?null:(function(r){let u=r.length,l=r.lastIndexOf(".",u-2)+1;if(r.charCodeAt(u-1)===46&&u--,u<=l)return!1;if(wA(r.slice(l,u))>=0)return!0;for(;l<u;l++){let a=r.charCodeAt(l);if(a<48||a>57)return!1}return!0})(t)?(function(r){let u=r.split("."),l=u.length;if(u[l-1]||l--,l>4)return null;let a=0;for(let h=0;h<l-1;h++){let w=wA(u[h]);if(w<0||w>255)return null;a+=w*(1<<8*(3-h))}let f=wA(u[l-1]);return f<0||f>=256**(5-l)?null:(a+=f,a)})(t):t}}function vA(A){return typeof A=="number"?(function(t){let r="";return r+=`${(t>>>24&255).toString(10)}.`,r+=`${(t>>>16&255).toString(10)}.`,r+=`${(t>>>8&255).toString(10)}.`,r+=(t&255).toString(10),r})(A):Array.isArray(A)?`[${(function(t){let n=(function(a){let f=-1,h=-1,w=1,p=0;for(let m=0;m<a.length;++m)a[m]!==0?(p>w&&(f=h,w=p),h=-1,p=0):(h===-1&&(h=m),++p);return p>w?h:f})(t),r="",u=!1;for(let l=0;l<=7;++l)if(!(u&&t[l]===0)){if(u&&(u=!1),n===l){r+=l===0?"::":":",u=!0;continue}r+=t[l].toString(16),l!==7&&(r+=":")}return r})(A)}]`:A}function oe(A){A.path.length>0&&(A.path.length!==1||A.scheme!=="file"||!(function(t){return/^[A-Za-z]:$/u.test(t)})(A.path[0]))&&A.path.pop()}function ie(A){return A.username!==""||A.password!==""}function mA(A){return A.host===null||A.host===""||A.scheme==="file"}var s=0,o="",g="",D=null,i,lA=!1,uA=!1,G=!1,E;function B(A,e,t,n){e||(A=(function(l){let a=0,f=l.length;for(;a<f&&!(l.charCodeAt(a)>32);++a);for(;f>a&&!(l.charCodeAt(f-1)>32);--f);return l.substring(a,f)})(A)),A=(function(l){let a=0;for(;a<l.length;a++){let h=l.charCodeAt(a);if(h===9||h===10||h===13)break}if(a===l.length)return l;let f=l.slice(0,a);for(;a<l.length;a++){let h=l.charCodeAt(a);h!==9&&h!==10&&h!==13&&(f+=l[a])}return f})(A),s=0,o=A,g="",D=t||null,i=e||{scheme:"",username:"",password:"",host:null,port:null,path:[],query:null,fragment:null,opaquePath:!1},lA=!1,uA=!1,G=!1,E=n||0;let r=Fe;switch(n){case 3:case 4:r=aA;break;case 5:r=RA;break;case 6:r=Y;break;case 7:r=Q;break;case 8:r=x}return r(c(A,s))!==1?i:null}function d(A,e){return s+=s===A?M(e):1,s<=o.length}function c(A,e){return e<A.length?A.codePointAt(e):void 0}function M(A){return A!=null&&A>65535?2:1}function le(A){return A==null?"":A<=65535?String.fromCharCode(A):String.fromCodePoint(A)}var Fe=A=>{let e=s;if(A!=null&&(A>=65&&A<=90||A>=97&&A<=122)){let t=s+1;for(A=o.charCodeAt(t);A===43||A===45||A===46||A>=65&&A<=90||A>=97&&A<=122||A>=48&&A<=57;)t++,A=o.charCodeAt(t);return g=o.slice(s,t).toLowerCase(),s=t,Qe(t<o.length?A:void 0)}else return E?1:(--s,d(e,A)?ue(c(o,s)):0)},Qe=A=>{let e=s;if(A===58){if(E){if(I(i.scheme)!==I(g))return 0;if((ie(i)||i.port!==null)&&g==="file")return 0;if(i.scheme==="file"&&i.host==="")return 0}return i.scheme=g,E?(i.port===se(i.scheme)&&(i.port=null),0):(g="",i.scheme==="file"?d(e,A)?kA(c(o,s)):0:I(i.scheme)&&D!==null&&D.scheme===i.scheme?d(e,A)?Ge(c(o,s)):0:I(i.scheme)?d(e,A)?Ve(c(o,s)):0:c(o,s+1)===47?(s++,d(e,A)?Ye(c(o,s)):0):(i.path=[""],i.opaquePath=!0,d(e,A)?ae(c(o,s)):0))}else return E?1:(g="",s=-1,d(e,A)?ue(c(o,s)):0)},ue=A=>{let e=s;return D===null||D.opaquePath&&A!==35?1:D.opaquePath&&A===35?(i.scheme=D.scheme,i.path=D.path.slice(),i.opaquePath=D.opaquePath,i.query=D.query,i.fragment="",d(e,A)?x(c(o,s)):0):D.scheme==="file"?(s--,d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?OA(c(o,s)):0)},Ge=A=>{let e=s;return A===47&&c(o,s+1)===47?(++s,d(e,A)?hA(c(o,s)):0):(s--,d(e,A)?OA(c(o,s)):0)},Ye=A=>{let e=s;return A===47?d(e,A)?W(c(o,s)):0:(s--,d(e,A)?j(c(o,s)):0)},OA=A=>{let e=s;return i.scheme=D.scheme,A===47||I(i.scheme)&&A===92?d(e,A)?XA(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,i.path=D.path.slice(),i.query=D.query,A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?x(c(o,s)):0):A!=null?(i.query=null,i.path.pop(),s--,d(e,A)?j(c(o,s)):0):d(e,A)?OA(c(o,s)):0)},XA=A=>{let e=s;return I(i.scheme)&&(A===47||A===92)?d(e,A)?hA(c(o,s)):0:A===47?d(e,A)?W(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,s--,d(e,A)?j(c(o,s)):0)},Ve=A=>{let e=s;return A===47&&c(o,s+1)===47?s++:s--,d(e,A)?hA(c(o,s)):0},hA=A=>{let e=s;return A!==47&&A!==92?(s--,d(e,A)?W(c(o,s)):0):d(e,A)?hA(c(o,s)):0},W=A=>{let e=s;if(A!=null&&A!==64&&A!==35&&A!==47&&A!==63&&(A!==92||!I(i.scheme))){let t=s+M(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===64||n===35||n===47||n===63||n===92&&I(i.scheme))break;t+=M(n)}return g+=o.slice(s,t),s=t-1,d(e,A)?W(c(o,s)):0}if(A===64){lA&&(g=`%40${g}`),lA=!0;for(let t=0;t<g.length;t++){let n=g.codePointAt(t);if(n===58&&!uA){uA=!0;continue}let r=ee(n,cA);uA?i.password+=r:i.username+=r,n!=null&&n>65535&&t++}return g="",d(e,A)?W(c(o,s)):0}else return A==null||A===35||A===47||A===63||A===92&&I(i.scheme)?lA&&g===""?1:(s-=g.length+1,g="",d(e,A)?aA(c(o,s)):0):(g+=le(A),d(e,A)?W(c(o,s)):0)},aA=A=>{let e=s;if(E&&i.scheme==="file")return s--,d(e,A)?LA(c(o,s)):0;if(A!=null&&A!==58&&A!==35&&A!==47&&A!==63&&(A!==92||!I(i.scheme))){let t=s+M(A);for(A===91?G=!0:A===93&&(G=!1);t<o.length;){let n=c(o,t);if(n==null||!G&&n===58||n===35||n===47||n===63||n===92&&I(i.scheme))break;n===91?G=!0:n===93&&(G=!1),t+=M(n)}return g+=o.slice(s,t),s=t-1,d(e,A)?aA(c(o,s)):0}else if(A===58&&!G){if(g===""||E===4)return 1;let t=EA(g,!I(i.scheme));return t===null?1:(i.host=vA(t),g="",d(e,A)?RA(c(o,s)):0)}else if(A==null||A===35||A===47||A===63||A===92&&I(i.scheme)){if(s--,I(i.scheme)&&g==="")return 1;if(E&&g===""&&(ie(i)||i.port!==null))return 1;let t=EA(g,!I(i.scheme));return t===null?1:(i.host=vA(t),g="",E?0:d(e,A)?Y(c(o,s)):0)}else return g+=le(A),d(e,A)?aA(c(o,s)):0},RA=A=>{let e=s;if(A!=null&&A>=48&&A<=57){let t=s+1;for(;t<o.length;){let n=o.charCodeAt(t);if(n<48||n>57)break;t++}return g+=o.slice(s,t),s=t-1,d(e,A)?RA(c(o,s)):0}else if(E||A==null||A===35||A===47||A===63||A===92&&I(i.scheme)){if(g!==""){let t=parseInt(g,10);if(t>65535)return 1;if(i.port=t===se(i.scheme)?null:t,g="",E)return 0}return E?1:(s--,d(e,A)?Y(c(o,s)):0)}else return 1};function ce(A,e){let t=A.length-e;if(t<2)return!1;if(ne(c(A,e),c(A,e+1))){if(t===2)return!0;{let n=c(A,e+2);return n===47||n===92||n===63||n===35}}else return!1}var kA=A=>{let e=s;return i.scheme="file",i.host="",A===47||A===92?d(e,A)?Ke(c(o,s)):0:D?.scheme==="file"?(i.host=D.host,i.path=D.path.slice(),i.opaquePath=D.opaquePath,i.query=D.query,A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?x(c(o,s)):0):A!=null?(i.query=null,ce(o,s)?i.path=[]:oe(i),s--,d(e,A)?j(c(o,s)):0):d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?j(c(o,s)):0)},Ke=A=>{let e=s;return A===47||A===92?d(e,A)?LA(c(o,s)):0:(D!==null&&D.scheme==="file"&&(!ce(o,s)&&(function(n){if(n.length===2){let r=n.codePointAt(0),u=n.codePointAt(1);return(r>=65&&r<=90||r>=97&&r<=122)&&u===58}else return!1})(D.path[0])&&i.path.push(D.path[0]),i.host=D.host),s--,d(e,A)?j(c(o,s)):0)},LA=A=>{let e=s;if(A!=null&&A!==47&&A!==92&&A!==63&&A!==35){let t=s+M(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||n===92||n===63||n===35)break;t+=M(n)}return g+=o.slice(s,t),s=t-1,d(e,A)?LA(c(o,s)):0}else if(A==null||A===47||A===92||A===63||A===35){if(s--,!E&&re(g))return d(e,A)?j(c(o,s)):0;if(g==="")return i.host="",E?0:d(e,A)?Y(c(o,s)):0;{let t=EA(g,!I(i.scheme));return t===null?1:(t==="localhost"&&(t=""),i.host=vA(t),g="",E?0:d(e,A)?Y(c(o,s)):0)}}return 1},Y=A=>{let e=s;return I(i.scheme)?(A!==92&&A!==47&&s--,d(e,A)?j(c(o,s)):0):!E&&A===63?(i.query="",d(e,A)?Q(c(o,s)):0):!E&&A===35?(i.fragment="",d(e,A)?x(c(o,s)):0):A!=null?(A!==47&&s--,d(e,A)?j(c(o,s)):0):(E&&i.host===null&&i.path.push(""),d(e,A)?Y(c(o,s)):0)},j=A=>{let e=s;if(A!=null&&A!==47&&(!I(i.scheme)||A!==92)&&(E||A!==63&&A!==35)){let t=s+M(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||I(i.scheme)&&n===92||!E&&(n===63||n===35))break;t+=M(n)}g+=_(o.slice(s,t),SA),s=t,A=c(o,t)}if(A==null||A===47||I(i.scheme)&&A===92||!E&&(A===63||A===35)){let t=I(i.scheme)&&A===92;return(function(r){switch(r){case"..":case"%2e.":case"%2E.":case".%2e":case".%2E":case"%2e%2e":case"%2E%2e":case"%2e%2E":case"%2E%2E":return!0;default:return!1}})(g)?(oe(i),A!==47&&!t&&i.path.push("")):JA(g)&&A!==47&&!t?i.path.push(""):JA(g)||(i.scheme==="file"&&i.path.length===0&&re(g)&&(g=`${g[0]}:`),i.path.push(g)),g="",A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?x(c(o,s)):0):d(e,A)?j(c(o,s)):0}else return g+=ee(A,SA),d(e,A)?j(c(o,s)):0},ae=A=>{let e=s;if(A===63)return i.query="",d(e,A)?Q(c(o,s)):0;if(A===35)return i.fragment="",d(e,A)?x(c(o,s)):0;if(A!=null){let t=s+M(A);for(;t<o.length;){let r=c(o,t);if(r===63||r===35)break;t+=M(r)}let n=o.slice(s,t);if(t<o.length&&n.charCodeAt(n.length-1)===32?i.path[0]+=_(n.slice(0,-1),AA)+"%20":i.path[0]+=_(n,AA),s=t,(A=c(o,t))===63)return i.query="",d(e,A)?Q(c(o,s)):0;if(A===35)return i.fragment="",d(e,A)?x(c(o,s)):0}return d(e,A)?ae(c(o,s)):0},Q=A=>{let e=s,t=s;if(A!=null){if(E)t=o.length;else{let r=o.indexOf("#",s);t=r===-1?o.length:r}let n=I(i.scheme)?Se:qA;i.query+=_(o.slice(s,t),n)}return s=t,c(o,t)===35&&!E?(i.fragment="",d(e,A)?x(c(o,s)):0):d(e,A)?Q(c(o,s)):0},x=A=>{let e=s;return A!=null&&(i.fragment+=_(o.slice(s),be),s=o.length),d(e,A)?x(c(o,s)):0};function TA(A){if(A.opaquePath)return A.path[0];{let e="";for(let t of A.path)e+=`/${t}`;return e}}function fe(A){switch(A.scheme){case"blob":{let e=B(TA(A),null,null,0);return e===null||e.scheme!=="http"&&e.scheme!=="https"?"null":fe(e)}case"ftp":case"http":case"https":case"ws":case"wss":return(function(t){let n=`${t.scheme}://`;return n+=t.host,t.port!==null&&(n+=`:${t.port}`),n})(A);default:return"null"}}var b=Symbol("URLImpl"),eA=class A{constructor(e,t){if(e===void 0&&t===void 0)throw new TypeError('The "url" argument must be specified.');e=S(e),t!=null&&(t=S(t));let n=null;if(t!=null&&(n=B(t,null,null,0),n==null))throw new TypeError(`Invalid base URL: ${t}`);let r=B(e,null,n,0);if(r==null)throw new TypeError(`Invalid URL: ${e}`);this[b]={url:r,query:null}}static createObjectURL(e){throw new TypeError("URL.createObjetURL is unsupported")}static revokeObjectURL(e){}static parse(e,t){e=S(e),t!==void 0&&(t=S(t));try{return new A(e,t)}catch{return null}}static canParse(e,t){e=S(e),t!==void 0&&(t=S(t));let n=null;return t!=null&&(n=B(t,null,null,0),n==null)?!1:B(e,null,n,0)!=null}get href(){return(function(t){let n=`${t.scheme}:`;return t.host!==null&&(n+="//",(t.username!==""||t.password!=="")&&(n+=t.username,t.password!==""&&(n+=`:${t.password}`),n+="@"),n+=t.host,t.port!==null&&(n+=`:${t.port}`)),t.host===null&&!t.opaquePath&&t.path.length>1&&t.path[0]===""&&(n+="/."),n+=TA(t),t.query!==null&&(n+=`?${t.query}`),t.fragment!==null&&(n+=`#${t.fragment}`),n})(this[b].url)}set href(e){let t=B(e=S(e),null,null,0);if(t==null)throw new TypeError(`Invalid URL: ${e}`);this[b].url=t,this[b].query&&yA(this[b].query,t.query)}get origin(){return fe(this[b].url)}get protocol(){return`${this[b].url.scheme}:`}set protocol(e){B(`${e=S(e)}:`,this[b].url,null,2)}get username(){return this[b].url.username}set username(e){e=S(e),mA(this[b].url)||(function(n,r){n.username=_(r,cA)})(this[b].url,e)}get password(){return this[b].url.password}set password(e){e=S(e),mA(this[b].url)||(function(n,r){n.password=_(r,cA)})(this[b].url,e)}get host(){let{url:e}=this[b];return e.host==null?"":e.port==null?e.host:`${e.host}:${e.port}`}set host(e){e=S(e),this[b].url.opaquePath||B(e,this[b].url,null,3)}get hostname(){let{url:e}=this[b];return e.host!=null?e.host:""}set hostname(e){e=S(e),this[b].url.opaquePath||B(e,this[b].url,null,4)}get port(){let{url:e}=this[b];return e.port!=null?`${e.port}`:""}set port(e){e=S(e);let{url:t}=this[b];mA(t)||(e?B(e,t,null,5):t.port=null)}get pathname(){return TA(this[b].url)}set pathname(e){e=S(e);let{url:t}=this[b];t.opaquePath||(t.path=[],B(e,t,null,6))}get search(){let{url:e}=this[b];return e.query?`?${e.query}`:""}set search(e){e=S(e);let{url:t,query:n}=this[b];if(!e)t.query=null,n&&yA(n,null);else{let r=e[0]==="?"?e.substring(1):e;t.query="",B(r,t,null,7),n&&yA(n,t.query)}}get searchParams(){let e=this[b],t=e.query;return t==null&&(t=e.query=(function(r,u){let l=new fA;return l[C].url=r,l[C].serialized=u==null,u&&(l[C].list=NA(u)),l})(this,e.url.query)),t}get hash(){let{url:e}=this[b];return e.fragment?`#${e.fragment}`:""}set hash(e){e=S(e);let{url:t}=this[b];if(!e)t.fragment=null;else{let n=e[0]==="#"?e.substring(1):e;t.fragment="",B(n,t,null,8)}}toJSON(){return this.href}toString(){return this.href}};Object.defineProperty(eA.prototype,Symbol.toStringTag,{value:"URL",configurable:!0});var C=Symbol("URLSearchParamsImpl"),Je=Symbol.dispose||Symbol.for("dispose");function yA(A,e){e?A[C].list=NA(e):A[C].list.length=0,A[C].serialized=e==null}function oA(A){if(A.url){let e=CA(A.list);(function(n,r){n[b].url.query=r})(A.url,e||null),A.serialized=!0}}var We=typeof Iterator<"u"?Iterator:Object,Z=class extends We{constructor(e,t){super(),this[C]={ptr:e,map:t,index:0}}next(){let e=this[C];return e.index<e.ptr.list.length?{value:e.map(e.ptr.list[e.index++]),done:!1}:{value:void 0,done:!0}}[Symbol.iterator](){return this}[Je](){}},fA=class{constructor(e){let t=this[C]={list:[],url:null,serialized:!0},n;if(Array.isArray(e))for(let r=0;r<e.length;r++)t.list.push(QA(e[r]));else if((n=ZA(e))!=null){let r;for(;!(r=PA(n.next())).done;)t.list.push(QA(r.value))}else if((typeof e=="object"||typeof e=="function")&&e!=null){let r=Object.keys(e);for(let u=0;u<r.length;u++){let l=r[u],a=Pe(l),f=S(e[l]),h=t.list.find(w=>w[0]===a);h?h[1]=f:t.list.push([a,f])}}else if(e!==void 0){let r=S(e);r=r[0]==="?"?r.substring(1):r,t.list=NA(r)}}get size(){return this[C].list.length}append(e,t){e=S(e),t=S(t),this[C].list.push([e,t]);let n=this[C];n.url&&n.serialized?(function(u,l){let a=u[b].url;a.query=a.query?`${a.query}&${l}`:l})(n.url,CA([[e,t]])):oA(n)}delete(e,t){e=S(e),t=t!=null?S(t):void 0;let{list:n}=this[C],r=0;for(;r<n.length;)n[r][0]===e&&(t==null||n[r][1]===t)?n.splice(r,1):r++;oA(this[C])}get(e){e=S(e);let{list:t}=this[C];for(let n=0;n<t.length;n++)if(t[n][0]===e)return t[n][1];return null}getAll(e){e=S(e);let t=[],{list:n}=this[C];for(let r=0;r<n.length;r++)n[r][0]===e&&t.push(n[r][1]);return t}has(e,t){e=S(e),t=t!=null?S(t):void 0;let{list:n}=this[C];for(let r=0;r<n.length;r++)if(n[r][0]===e&&(t==null||n[r][1]===t))return!0;return!1}set(e,t){e=S(e),t=S(t);let{list:n}=this[C],r=!1,u=!1,l=0;for(;l<n.length;)n[l][0]===e?r?(n.splice(l,1),u=!0):(r=!0,n[l][1]!==t&&(n[l][1]=t,u=!0),l++):l++;r||(n.push([e,t]),u=!0),u&&oA(this[C])}sort(){this[C].list.sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:0),oA(this[C])}forEach(e,t){if(typeof e!="function")throw new TypeError('The "callback" argument must be of type function');let{list:n}=this[C];for(let r=0;r<n.length;r++)e.call(t,n[r][1],n[r][0],this)}entries(){return new Z(this[C],e=>e)}keys(){return new Z(this[C],e=>e[0])}values(){return new Z(this[C],e=>e[1])}toString(){return CA(this[C].list)}[Symbol.iterator](){return this.entries()}};Object.defineProperty(fA.prototype,Symbol.toStringTag,{value:"URLSearchParams",configurable:!0});function he(A){let e,t=()=>typeof e=="string"?e:e?.accessToken,n=0,r,u=new Map,l=()=>{for(let p of[...u.keys()])try{p()}catch{}};function a(p){let m=++n;r=void 0,e=void 0;for(let y of[...u.values()])try{y?.()}catch{}m===n&&(e=p,l())}let f=()=>a();function h(p,m=!1){let y=$A.safeParse(p);if(!y.success||m&&Date.parse(y.data.expiresAt)<=Date.now()||Date.parse(y.data.refreshExpiresAt)<=Date.now()||Date.parse(y.data.refreshExpiresAt)<Date.parse(y.data.expiresAt))throw new P("INVALID_RESPONSE","Invalid customer session credentials");return y.data}async function w(){if(r)return r;let p=typeof e=="object"?e:void 0,m=n;if(!p||Date.parse(p.refreshExpiresAt)<=Date.now())throw p&&f(),new P("UNAUTHENTICATED","Customer authentication is required",401);let y=(async()=>{try{let N=await A(p.refreshToken);if(m!==n)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");let V=h(N,!0);if(V.customerId!==p.customerId||V.sessionId!==p.sessionId)throw new P("SCOPE_MISMATCH","Refresh changed the customer session");return e=V,{...V}}catch(N){throw m!==n?new P("IDENTITY_CHANGED","Customer identity changed during refresh"):(N instanceof P&&N.status===401&&f(),N)}})();r=y;try{return await y}finally{r===y&&(r=void 0)}}return{identify(p){let m=typeof p=="string"?p:h(p),y=typeof m=="string"?m:m.accessToken;if(!y.trim()||/\s/.test(y)||y.length>4096)throw new P("INVALID_TOKEN","A server-issued token is required");a(m)},reset:f,subscribeIdentity(p,m){return u.set(p,m),()=>{u.delete(p)}},access(){let p=typeof e=="object"?e:void 0;if(p&&Date.parse(p.expiresAt)<=Date.now()+3e4){let y=n;return w().then(()=>{let N=t();if(y!==n||!N)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");return N})}let m=t();if(!m)throw new P("NOT_IDENTIFIED","Identify a customer session before making a request");return m},peek:t,snapshot:()=>typeof e=="object"?{...e}:void 0,refresh:w}}var de=Symbol("IndianaNoContent");function ut(A,e,t=eA){let n=A.configuration?.scope,r=A.scope??(n&&{projectId:n.projectId,environment:n.environment}),u=r?sA.parse(r):void 0;if(u&&n&&(u.projectId!==n.projectId||u.environment!==n.environment))throw new P("SCOPE_MISMATCH","Configuration belongs to another App/environment");let l=new t(A.baseUrl??FA);if(l.username||l.password||l.search||l.hash)throw new P("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(l.protocol!=="https:"&&!(l.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(l.hostname)))throw new P("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let a=A.fetch??globalThis.fetch.bind(globalThis),f=A.timeoutMs??1e4;if(!Number.isFinite(f)||f<1||f>12e4)throw new P("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let h=!1,w=0,p=null,m=new Set,y=A.session??he(async q=>{let O=await tA("customer-sessions/refresh",{},"POST",{},q);if(!O||typeof O!="object")throw new P("INVALID_RESPONSE","Invalid refresh response");let{requestId:$,scope:H,...K}=O;return K});function N(){w+=1,p=null;for(let q of m)q.abort();m.clear()}let V=y.subscribeIdentity(N);function pe(){h||y.reset()}async function tA(q,O={},$="POST",H={},K){let k=H.installationDetach===!0;if(k&&(q!=="push/installations/detach"||$!=="POST"))throw new P("INVALID_REQUEST","Installation authority only detaches this installation");if(!K&&!k)throw new P("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let J=w,L=new AbortController;k||m.add(L);let nA=()=>!k&&J!==w?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new P("TIMEOUT","Longplay request timed out"),dA,ge=new Promise((T,R)=>{dA=()=>R(nA()),L.signal.addEventListener("abort",dA,{once:!0})}),we=setTimeout(()=>L.abort(),H.timeoutMs??f),me=async()=>{let T=await a(`${l.href.replace(/\/$/,"")}/api/v1/${q}`,{method:$,headers:{...H.headers,"Content-Type":"application/json",...k?{}:{Authorization:`Bearer ${K}`},[pA]:gA.current,[xA]:zA.version,...u?{"X-Indiana-Project":u.projectId,"X-Indiana-Environment":u.environment}:{}},body:$==="POST"?JSON.stringify(O):void 0,signal:L.signal,credentials:"omit",cache:"no-store",redirect:"error",...H.keepalive?{keepalive:!0}:{}});if(L.signal.aborted)throw nA();let R;try{R=T.status===204?de:await T.json()}catch{throw L.signal.aborted?nA():new P(T.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",T.status,T.headers.get("X-Request-Id")??void 0)}if(L.signal.aborted)throw nA();if(!k&&J!==w)throw new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!T.ok){let v=UA.safeParse(R),z=v.success&&(!MA.safeParse(v.data.error.code).success||jA(v.data.error.code,T.status)),BA=z?v.data.error.code:"HTTP_ERROR",HA=_A(BA,T.status,{retryAfter:T.headers.get("Retry-After"),recovery:z?v.data.error.recovery:void 0,reason:z?v.data.error.reason:void 0});throw new P(BA,z?v.data.error.message:"Longplay request failed",T.status,T.headers.get("X-Request-Id")??(v.success?v.data.requestId:void 0),{...HA,...v.success&&v.data.error.retryable===!1?{retryable:!1}:{},...HA.retryAfterSeconds===void 0&&v.success&&v.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:v.data.error.retryAfterSeconds}:{}})}if(T.headers.get(pA)!==gA.current)throw new P("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(u&&R!==de){let v=R&&typeof R=="object"&&"scope"in R?R:R&&typeof R=="object"&&"configuration"in R?R.configuration:null;if(!v||typeof v!="object"||!("scope"in v))throw new P("INVALID_RESPONSE","Response is missing its App/environment scope");let z=sA.safeParse(v.scope);if(!z.success||z.data.projectId!==u.projectId||z.data.environment!==u.environment)throw new P("SCOPE_MISMATCH","Response scope does not match this SDK instance")}let rA=T.headers.get("X-Indiana-Telemetry-Subject");if(rA){if(!/^[a-f0-9]{64}$/.test(rA))throw new P("INVALID_RESPONSE","Invalid telemetry identity");p!==rA&&(p=rA,e?.(p))}return R};try{return await Promise.race([me(),ge])}catch(T){throw!k&&J!==w?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):T instanceof P?T:new P(L.signal.aborted?"TIMEOUT":"NETWORK_ERROR",L.signal.aborted?"Longplay request timed out":"Unable to read the Longplay response")}finally{clearTimeout(we),L.signal.removeEventListener("abort",dA),m.delete(L)}}return{session:y,requestWithCredential(q,O,$,H={}){return h?Promise.reject(new P("CLOSED","SDK client was destroyed")):tA(q,O,"POST",H,$)},subjectKey:()=>p,identify(q){if(h)throw new P("CLOSED","SDK client was destroyed");if(u&&typeof q=="object"&&"scope"in q){let O=sA.safeParse(q.scope);if(!O.success||O.data.projectId!==u.projectId||O.data.environment!==u.environment)throw new P("SCOPE_MISMATCH","Customer session belongs to another App/environment")}y.identify(q)},reset:pe,dispose(){h||(h=!0,V(),N())},request(q,O={},$="POST",H={}){if(h)return Promise.reject(new P("CLOSED","SDK client was destroyed"));if(H.installationDetach)return tA(q,O,$,H);let K=w;try{let k=y.access(),J=L=>{if(K!==w)throw new P("IDENTITY_CHANGED","Customer identity changed before dispatch");return tA(q,O,$,H,L)};return typeof k=="string"?J(k):k.then(J)}catch(k){return Promise.reject(k)}}}}export{eA as a,ut as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as d,b as ee,l as B,o as te}from"./chunk-JGFAFQKK.js";import{b as Z}from"./chunk-CDG7GM4C.js";import{a as s}from"./chunk-OZZMZH7X.js";import{a as G}from"./chunk-DSPLGTQI.js";import{Ha as $,S as X,a as z,b as Y,c as K,d as Q,e as j,f as M,g as W,n as L,ua as a,wa as H}from"./chunk-7DUOIHRD.js";var U=t=>{if(!Number.isSafeInteger(t)||t<0||t>=Number.MAX_SAFE_INTEGER)throw new s("INVALID_STATE","Installation sequence exhausted");return t+1},he=async t=>[...new Uint8Array(await crypto.subtle.digest("SHA-256",Uint8Array.from(t,e=>e.charCodeAt(0))))].map(e=>e.toString(16).padStart(2,"0")).join("");function _(t,e){return t.transaction(n=>{if(!Number.isSafeInteger(n.identitySeq)||n.identitySeq<0||!Number.isSafeInteger(n.addressSeq)||n.addressSeq<0||n.detachSeq!==null&&(!Number.isSafeInteger(n.detachSeq)||n.detachSeq<1||n.detachSeq>n.identitySeq))throw new s("INVALID_STATE","Installation journal is invalid");return e({...n})})}function ne(t,e,n){let i=null,c=0,o=0,l=0,y=Promise.resolve(),P=!1;if(t&&(!n||z.parse(t.scope).projectId!==n.projectId||t.scope.environment!==n.environment))throw new s("SCOPE_MISMATCH","Push installation belongs to another scope");let g=()=>{if(P)throw new s("CLOSED","SDK client was destroyed");if(!t)throw new s("NOT_CONFIGURED","Configure this client's native Push host first");return t},b=r=>{if(r!==c)throw new s("IDENTITY_CHANGED","Identity changed during Push operation")};async function D(r){let u=g();if(!u.sha256&&!globalThis.crypto?.subtle)throw new s("NOT_CONFIGURED","Configure native SHA-256 for this Push host");let p=u.sha256?await u.sha256(Uint8Array.from(r,I=>I.charCodeAt(0))):await he(r);if(!/^[a-f0-9]{64}$/.test(p))throw new s("INVALID_STATE","Push credential digest is invalid");return p}function m(r){let u=M.parse(r);if(u.installationId.toLowerCase()!==g().installationId.toLowerCase())throw new s("INVALID_RESPONSE","Push response belongs to another installation");return u}async function C(r,u){let p=g(),I={installationId:p.installationId,publicKey:p.publicKey,issuedAt:new Date().toISOString(),...u},S=await p.sign(W(r,p.scope,I));return{...I,signature:S}}let f=(r,u,p)=>e.requestWithCredential?e.requestWithCredential(r,u,p):e.request(r,u);async function w(){let r=g(),u=c,p=i?await(e.session?.access()??i):null,I=_(r,v=>v),S;if(I.detachSeq!==null){let v=I.detachSeq,V=Y.parse(await C("detach",{sequence:v,platform:r.platform}));try{let N=await e.request("push/installations/detach",{...r.scope,...V},"POST",{installationDetach:!0});if(!N||typeof N!="object"||!("installation"in N))throw new s("INVALID_RESPONSE","Push detach acknowledgement is invalid");let F=m(N.installation);if(F.bound||F.identitySeq!==v)throw new s("INVALID_RESPONSE","Push detach acknowledgement does not match its intent")}catch(N){if(N instanceof s&&N.status===404)S=N;else if(!(N instanceof s)||N.status!==412)throw N}S||_(r,N=>({...N,detachSeq:N.detachSeq===v?null:N.detachSeq}))}if(b(u),!p){if(S)throw S;return null}let q=a.bindPushInstallation,k=q.request.parse(await C("bind",{sequence:l,platform:r.platform,credentialDigest:await D(p)}));b(u);let R=q.response.parse(await f(q.path,k,p));b(u);let T=m(R.installation);if(!T.bound||T.identitySeq!==l)throw new s("INVALID_RESPONSE","Push binding acknowledgement does not match its intent");return S&&I.detachSeq!==null&&l>I.detachSeq&&_(r,v=>({...v,detachSeq:v.detachSeq===I.detachSeq?null:v.detachSeq})),T}async function E(){g();let r=c,u=i?await(e.session?.access()??i):null;if(!u)throw new s("NOT_IDENTIFIED","Identify before reading this installation");let p=a.readPushInstallation,I=p.request.parse(await C("read",{credentialDigest:await D(u)}));b(r);let S=p.response.parse(await f(p.path,I,u));return b(r),m(S.installation)}function h(r=w){let u=y.catch(()=>{}).then(r);return y=u,u.catch(p=>{try{t?.onError?.(p instanceof Error?p:new Error("Push synchronization failed"))}catch{}}),u}async function O(r,u,p){let I=g(),S=u.identity,q=u.observation,k=i?await(e.session?.access()??i):null;if(b(S),q!==o)throw new s("INVALID_STATE","Push observation changed during recovery");if(!k)throw new s("NOT_IDENTIFIED","Identify before recovering a Push address");if(!r.connectionId||!r.kind||!r.token||!["granted","provisional"].includes(r.permission))throw new s("INVALID_REQUEST","Recovery needs a provider token and notification permission");return await h(async()=>{if(b(S),await w(),b(S),q!==o)throw new s("INVALID_STATE","Push observation changed during recovery");let R=_(I,F=>p?F:{...F,addressSeq:U(F.addressSeq)}),v=await C(p?"recovery_confirm":"recovery_request",{...r,sequence:R.addressSeq,credentialDigest:await D(k),...p?{challenge:p}:{}}),V=p?Q.parse(v):K.parse(v);if(b(S),q!==o)throw new s("INVALID_STATE","Push observation changed during recovery");let N=await f(`push/installations/recovery/${p?"confirm":"request"}`,V,k);if(b(S),q!==o||_(I,F=>F).addressSeq!==R.addressSeq)throw new s("INVALID_STATE","Push observation changed during recovery");if(p){let F=a.updatePushAddress.response.parse(N),x=m(F.installation);if(!x.bound||x.identitySeq!==l||x.addressSeq!==R.addressSeq||x.connectionId!==r.connectionId||x.addressStatus!=="active")throw new s("INVALID_RESPONSE","Push recovery acknowledgement does not match its intent");return x}if(!N||typeof N!="object"||!("recovery"in N))throw new s("INVALID_RESPONSE","Push recovery acknowledgement is invalid");return j.parse(N.recovery)})}return{recoveryObserver(){g();let r={identity:c,observation:++o};return{async request(u){return j.parse(await O(u,r))},async confirm(u,p){return M.parse(await O(p,r,u))}}},identify(r){if(!t)return;l=_(t,p=>({...p,identitySeq:U(p.identitySeq)})).identitySeq,i=r,c++,o++},reset(){if(t)try{_(t,r=>{let u=U(r.identitySeq);return{...r,identitySeq:u,detachSeq:u}})}finally{i=null,c++,o++}},start(){t&&!P&&h()},destroy(){P=!0,i=null,c++,o++},async sync(){return await h()},read:E,async recover(){let r=g(),u=c,p=l;return o++,await h(async()=>{b(u);let I=await E();return b(u),l=_(r,q=>{if(q.identitySeq!==p)throw new s("IDENTITY_CHANGED","A newer installation intent exists");return{...q,identitySeq:U(Math.max(q.identitySeq,I.identitySeq)),addressSeq:Math.max(q.addressSeq,I.addressSeq)}}).identitySeq,await w()})},tokenObserver(){g();let r=++o,u=c;return async p=>{if(r!==o||u!==c)return null;let I=g(),S=i?await(e.session?.access()??i):null;if(!S)throw new s("NOT_IDENTIFIED","Identify before registering a Push token");if(await h(),b(u),r!==o)return null;let q=_(I,v=>({...v,addressSeq:U(v.addressSeq)})),k=a.updatePushAddress,R=k.request.parse(await C("address",{...p,sequence:q.addressSeq,credentialDigest:await D(S)}));if(b(u),r!==o)return null;let T=await f(k.path,R,S);return b(u),r!==o||_(I,v=>v).addressSeq!==q.addressSeq?null:m(k.response.parse(T).installation)}}}}function re(t,e){let n={async preference(i){let c=a.readMessagingPreference;return(await d(t,c,{channel:i})).preference},async setPreference(i){let c=a.setMessagingPreference;return(await d(t,c,i)).preference}};return{messaging:n,push:{sync:e.sync,read:e.read,recover:e.recover,tokenObserver:e.tokenObserver,recoveryObserver:e.recoveryObserver,async preference(){return n.preference("push")},async setPreference(i){return n.setPreference({...i,channel:"push"})}}}}function ie(t,e,n={}){let i=!1;function c(){if(i)throw new s("CLOSED","SDK client was destroyed")}let o=new Set,l=P=>{for(let g of o)try{g(P)}catch{}},y=t.session.subscribeIdentity(()=>{l(!!t.session.peek()),n.afterChange?.()},()=>{e()});return{assertActive:c,isIdentified:()=>!i&&!!t.session.peek(),methods:{subscribeIdentity(P){return c(),o.add(P),()=>{o.delete(P)}},identify(P){c();let g=typeof P=="string"?P:P.accessToken;if(!L.test(g))throw new s("INVALID_TOKEN","Browser SDK requires a customer session");n.beforeIdentify?.(g),t.identify(P)},reset(){if(!i)try{n.beforeReset?.()}finally{t.reset()}},destroy(){if(!i){i=!0,y(),o.clear();try{n.beforeDestroy?.(),e()}finally{t.dispose()}}}}}}function A(t){if(t!==null&&typeof t=="object"&&"customerId"in t)throw new s("INVALID_REQUEST","Customer requests use the verified session identity")}var ge={...a.readHoldings,request:a.readHoldings.request.omit({customerId:!0})};function se(t){return{async checkEntitlement(e){A(e);let n=a.checkEntitlement;return d(t,n,e)},async readHoldings(e={}){return d(t,ge,e)}}}function oe(t){return{async readLedger(e){let n=a.readLedger;return d(t,n,{query:e})},async readCreditStatement(e){A(e);let n=a.readCreditStatement;return d(t,n,e)},async quoteBalance(e){A(e);let n=a.quoteBalance;return d(t,n,{command:e})}}}function ae(t){return{async setupPayment(e){A(e);let n=a.setupPayment;return d(t,n,e)},async readPaymentSetup(e){A(e);let n=a.readPaymentSetup;return d(t,n,e)},async readBillingInvoice(e){A(e);let n=a.readBillingInvoice;return d(t,n,e)},async readBillingControls(e={}){A(e);let n=a.readBillingControls;return d(t,n,e)},async prepareBillingAuthorization(e){A(e);let n=a.prepareBillingAuthorization;return d(t,n,e)},async confirmBillingAuthorization(e){A(e);let n=a.confirmBillingAuthorization;return d(t,n,e)},async setBillingCoupons(e){A(e);let n=a.setBillingCoupons;return d(t,n,e,{request:"Invalid billing coupon list",response:"Invalid billing coupon receipt"})},async revokeBillingAuthorization(e){A(e);let n=a.revokeBillingAuthorization;return d(t,n,e)},async listBillingInvoices(e={after:null,limit:25}){A(e);let n=a.listBillingInvoices;return d(t,n,e)},async confirmBillingAdjustment(e){A(e);let n=a.confirmBillingAdjustment;return d(t,n,e)}}}function ce(t){return{async previewUpdate(e){A(e);let n=a.previewUpdate;return d(t,n,e)},async update(e){A(e);let n=a.update;return d(t,n,e)},async readSubscriptionUpdate(e){A(e);let n=a.readSubscriptionUpdate;return d(t,n,e)},async restoreNativePurchase(e){A(e);let n=a.restoreNativePurchase;return d(t,n,e)},async previewAttach(e){A(e);let n=a.previewAttach;return d(t,n,e)},async attach(e){A(e);let n=a.attach;return d(t,n,e)},async readSubscriptionOperation(e){A(e);let n=a.readSubscriptionOperation;return d(t,n,e)}}}function ue(t){return{async redeemReward(e){return A(e),(await d(t,a.redeemReward,{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid reward redemption",response:"Invalid reward receipt"})).redemption},async claimRewardProduct(e){return A(e),(await d(t,a.claimRewardProduct,e,{request:"Invalid reward product claim",response:"Invalid reward product checkout"})).checkout},async createReferralCode(e){return A(e),(await d(t,a.createReferralCode,{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid referral program",response:"Invalid referral code"})).referralCode},async redeemCoupon(e,n=crypto.randomUUID()){let i=await d(t,a.redeemCoupon,{code:e,requestId:n},{request:"Invalid coupon code",response:"Invalid Coupon receipt"});return{offer:i.offer,reason:i.reason}},async claimCoupon(e,n=crypto.randomUUID()){let i=await d(t,a.grantOffer,{couponId:e,requestId:n},{request:"Invalid Coupon claim",response:"Invalid Coupon receipt"});return{offer:i.offer,reason:i.reason}},async listOffers(){return(await d(t,a.listOffers,{},{response:"Invalid offers response"})).offers}}}function de(t){return{...se(t),...oe(t),...ae(t),...ce(t),...ue(t)}}function pe(t){return{async resolveContent(e){A(e);let n=a.resolveContent;return d(t,n,e)},async resolvePaywall(e){A(e);let n=a.resolvePaywall;return d(t,n,e)},async resolveOffering(e){A(e);let n=a.resolveOffering;return d(t,n,e)}}}var J=t=>new TextEncoder().encode(JSON.stringify(t)).length,le=16384;function fe(t,e){let n=0,i,c=f=>{i={config:structuredClone(f),until:Date.now()+3e4}},o=[],l=null,y;function P(){if(!e())throw new s("NOT_IDENTIFIED","Call identify before using Features or events")}function g(){y||!o.length||(y=setTimeout(()=>{y=void 0,D().catch(()=>{}).finally(g)},5e3),typeof y=="object"&&"unref"in y&&y.unref())}function b(f,w={},E={}){if(P(),i&&Date.now()<i.until&&!X(i.config,f))return;C();let h=a.trackEvents.request.parse({events:[{eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),name:f,properties:w,...E}]}).events[0];if(J({events:[h]})>le)throw new s("INVALID_REQUEST","Event exceeds the delivery size limit");if(o.length>=500)throw new s("EVENT_QUEUE_FULL","Flush pending events before tracking more");o.push(structuredClone(h)),g()}async function D(f=!1){if(P(),l)return l;let w=n,E=(async()=>{let h={inserted:0,duplicates:0,rejected:0,skipped:0},O=o.length;for(;O&&w===n;){let r=[],u=J({events:[]});for(let S of o.slice(0,Math.min(O,100))){let q=J(S)+(r.length?1:0);if(r.length&&u+q>le)break;r.push(S),u+=q}let p=a.trackEvents,I=await d(t,p,{events:r},void 0,{keepalive:f});if(w!==n)throw new s("IDENTITY_CHANGED","Event identity changed during delivery");if(I.inserted+I.duplicates+I.rejected+I.skipped!==r.length)throw new s("INVALID_RESPONSE","Incomplete event acknowledgement");c(I.analyticsConfig),o.splice(0,r.length),O-=r.length,h.inserted+=I.inserted,h.duplicates+=I.duplicates,h.rejected+=I.rejected,h.skipped+=I.skipped}return h})();l=E;try{return await E}finally{l===E&&(l=null)}}let m;function C(){if(m||typeof document>"u")return;let f=()=>{document.visibilityState==="hidden"&&e()&&o.length&&D(!0).catch(()=>{})};document.addEventListener("visibilitychange",f),m=()=>document.removeEventListener("visibilitychange",f)}return{rememberConfiguration:c,track:b,flush:D,reset(){n++,i=void 0,clearTimeout(y),y=void 0,o=[],l=null},detachVisibility(){m?.(),m=void 0}}}function me(t){let e=t.merchandise;if(typeof t.merchandiseId=="string")return{internalId:t.merchandiseId};if(!(!e||typeof e!="object"||Array.isArray(e))){if(typeof e.internalId=="string")return{internalId:e.internalId};if(typeof e.externalId=="string")return{id:e.externalId};if(typeof e.id=="string")return{id:e.id}}}function we(t){let e=me(t),{merchandiseId:n,merchandise:i,...c}=t;return{...c,...e?{merchandise:e}:{}}}function ye(t,e,n,i,c){if(c&&i&&(c.scope.projectId!==i.projectId||c.scope.environment!==i.environment))throw new s("SCOPE_MISMATCH","Configuration belongs to another App/environment");let o=0,l=new Set;function y(){if(!e())throw new s("NOT_IDENTIFIED","Call identify before using Features or events")}async function P(g={}){c||y();let b=o,D=!1,m=async()=>{if(D||b!==o)throw new s("IDENTITY_CHANGED","Feature identity changed");let R=a.getFeatures,T=c?{scope:{projectId:c.scope.projectId,environment:c.scope.environment},payload:await c.features()}:await d(t,R,{});if(b!==o)throw new s("IDENTITY_CHANGED","Feature identity changed");if(i&&(T.scope.projectId!==i.projectId||T.scope.environment!==i.environment))throw new s("INVALID_RESPONSE","Feature response scope changed");return n.rememberConfiguration(T.payload.analyticsConfig),T},C=await m(),f=!0,w,E=R=>{try{g.onError?.(R)}catch{}},h=(R,T,v)=>{try{let V=me(v);n.track(R,T,V?{merchandise:V}:{})}catch(V){E(V)}},O=ee({assertUsable:c?.assertFeatures,scope:C.scope,attributes:g.attributes,onError:g.onError,load:async()=>f?(f=!1,C.payload):(await m()).payload,evaluateRemote:async R=>{if(b!==o)throw new s("IDENTITY_CHANGED","Feature identity changed");let T=a.evaluateFeatures,v=await d(t,T,{...R,attributes:we(R.attributes)});if(v.scope.projectId!==C.scope.projectId||v.scope.environment!==C.scope.environment)throw new s("INVALID_RESPONSE","Remote Feature response scope changed");return{generation:v.generation,evaluatedAt:v.evaluatedAt,expiresAt:v.expiresAt,features:v.features,...v.merchandiseContext?{merchandiseContext:v.merchandiseContext}:{}}},onExperimentViewed:(R,T,v)=>h("Experiment Viewed",{experimentId:R.key,variationId:T.key},v),onFeatureUsage:(R,T,v)=>h("Feature Evaluated",{feature:R,value:T.value,source:T.source,ruleId:T.ruleId,...T.experimentResult?{variationId:T.experimentResult.key}:{}},v)}),r=O.refresh;function u(){clearTimeout(w),!c&&(D||b!==o||!O.expiresAt||(w=setTimeout(()=>{p().catch(E)},Math.min(2147483647,Math.max(1e3,Date.parse(O.expiresAt)-Date.now()))),typeof w=="object"&&"unref"in w&&w.unref()))}async function p(){try{return await r()}finally{u()}}let I=()=>{D||p().catch(E)},S=O.subscribe(u),q=c?.subscribe(()=>{!D&&c.fresh&&p().catch(E)});function k(){D||(D=!0,clearTimeout(w),typeof window<"u"&&window.removeEventListener("focus",I),S(),q?.(),O.reset(),l.delete(k))}l.add(k);try{await O.init(),(g.attributes?.merchandise||g.attributes?.merchandiseId)&&await O.refreshRemote()}catch(R){throw k(),R}return u(),!c&&typeof window<"u"&&window.addEventListener("focus",I),Object.assign(O,{refresh:p,destroy:k})}return{features:P,reset(g){o++,g();for(let b of l)b()}}}import{z as ve}from"zod";function Ie(t,e){let n="source"in e?{funnelId:e.source.id,funnelVersionId:e.source.versionId}:"versionId"in e?{funnelId:e.funnelId,funnelVersionId:e.versionId}:e,i=ve.object({funnelId:H.shape.id,funnelVersionId:H.shape.versionId.optional()}).safeParse(n);if(!i.success)throw new s("INVALID_REQUEST","A valid Funnel source is required");let c=Object.freeze(i.data);function o(l){if("customerId"in l)throw new s("INVALID_REQUEST","Customer identity cannot be overridden");if("funnelId"in l&&l.funnelId!==void 0&&l.funnelId!==c.funnelId||"funnelVersionId"in l&&l.funnelVersionId!==void 0&&l.funnelVersionId!==c.funnelVersionId)throw new s("SCOPE_MISMATCH","The original Funnel source cannot change");return{...l,...c}}return{async claimCoupon(l,y=crypto.randomUUID()){let P=a.grantOffer,g=await d(t,P,o({couponId:l,requestId:y}));return{offer:g.offer,reason:g.reason}},async resolveOffering(l){let y=a.resolveOffering;return d(t,y,o(l))},async resolvePaywall(l){let y=a.resolvePaywall;return d(t,y,o(l))},async previewAttach(l){let y=a.previewAttach;return d(t,y,o(l))}}}function Dt(t){return Ae(t)}function Ae(t){let e=Z(t),n=e.request,i;try{i=ne(t.push,e,t.scope??t.configuration?.scope)}catch(y){throw e.dispose(),y}let c=ie(e,()=>{l.reset(o.reset),o.detachVisibility()},{beforeIdentify:i.identify,beforeReset:i.reset,afterChange:i.start,beforeDestroy:i.destroy}),o=fe(n,c.isIdentified),l=ye(n,c.isIdentified,o,t.scope,t.configuration);return{session:e.session,...re(n,i),...de(n),...pe(n),forFunnel(y){return c.assertActive(),Ie(n,y)},async features(y={}){return c.assertActive(),l.features(y)},track(y,P,g={}){return o.track(y,P,g)},flush(){return o.flush()},...c.methods}}function Ut(t){if(!L.test(t.customerToken))throw new s("INVALID_TOKEN","A customer credential is required");if(!t.scope)throw new s("INVALID_REQUEST","An explicit App and environment scope is required");let e=te({...t,scope:t.scope,apiKey:t.customerToken});return{async start(n){let i=await e.start(n),c=B({...t,runToken:i.runToken});c.identify(t.customerToken);let o=i.run.instruction?.type==="evaluate_segment"?await c.get():i;return{...i,...o,controller:c}}}}function Gt(t){if(!t.scope)throw new s("INVALID_CONFIGURATION","An explicit process App/environment scope is required");if(t.session!==void 0)throw new s("INVALID_CONFIGURATION","The merchant process adapter owns the session");let e=null,n,i=0,c=new Set,o=new Map,l=new Map;async function y(m){let C,f=new Promise((w,E)=>{C=setTimeout(()=>E(new s("TIMEOUT","Process bridge request timed out")),t.timeoutMs??35e3)});try{return await Promise.race([Promise.resolve().then(m),f])}finally{clearTimeout(C)}}function P(m){throw m instanceof s&&(m.status===401||m.reason==="CUSTOMER_BINDING_CONFLICT")&&(i++,n?.reset(),n=void 0,e=null,o.clear(),l.clear()),m}function g(m,C){if(C!==i)throw new s("IDENTITY_CHANGED","Process was detached during a request");let f=$.parse(m);if(f.scope.projectId!==t.scope.projectId||f.scope.environment!==t.scope.environment)throw new s("SCOPE_MISMATCH","Process response belongs to another App/environment");if(e&&(e.run.id!==f.run.id||e.run.source.versionId!==f.run.source.versionId||e.run.source.id!==f.run.source.id||e.run.runExpiresAt!==f.run.runExpiresAt||e.run.identity.startedAs!==f.run.identity.startedAs||e.run.identity.participantId!==f.run.identity.participantId||e.run.identity.binding&&f.run.identity.binding&&e.run.identity.binding.id!==f.run.identity.binding.id))throw new s("INVALID_RESPONSE","The process changed its Run or Customer binding");if(!e||f.run.revision>=e.run.revision){if(e?.run.identity.binding&&!f.run.identity.binding)throw new s("INVALID_RESPONSE","The process lost its Customer binding");e=f;for(let I of c)G(I,f.run);f.run.instruction?.type==="authentication_required"&&G(t.onAuthenticationRequired,f.run)}f.settlement?.accepted!==void 0&&l.set(f.settlement.requestId,f.settlement.accepted);let{identity:w,instruction:E,...h}=f.run,{contract:O,settlement:r,...u}=f,p=r&&(({accepted:I,...S})=>S)(r);return{...u,run:{...h,authenticated:w.binding!==null,instruction:E?.type==="authentication_required"?null:E},...p?{settlement:p}:{}}}let b=m=>(o.has(m)||o.set(m,e?.run.identity.binding?.id??null),o.get(m));async function D(m){let C=i,f=e?.run.identity.binding?.id??null,w=h=>{if(f!==(e?.run.identity.binding?.id??null))throw h;return P(h)};if(m.operation==="page_experiments"){if(!t.adapter.pageExperiments)throw new s("CAPABILITY_UNAVAILABLE","Process page experiments are unavailable",501);return y(()=>t.adapter.pageExperiments(m.release,m.usedReceiptIds)).catch(w)}let E;if(m.operation==="get"){let{operation:h,customerToken:O,...r}=m;E=await y(()=>t.adapter.get({...r,...r.settlementRequestId?{settlementBindingId:b(r.settlementRequestId)}:{}})).catch(w)}else if(m.operation==="review")E=await y(()=>t.adapter.review(m.receiptId)).catch(w);else{if(m.operation==="start")throw new s("INVALID_REQUEST","Use process.open for entry");{let{customerToken:h,...O}=m;E=await y(()=>t.adapter.command(O,b(O.requestId))).catch(w)}}return g(E,C)}return{get view(){return e?.run??null},get controller(){return n},async open(m){let C=i,f=await y(()=>t.adapter.open(m)).catch(P);if(g(f,C),!n){n=B({...t,runToken:f.runToken,process:{request:D,binding:b,restore(h){for(let[O,r]of Object.entries(h))o.set(O,r)}}});let w=n,E=w.submit;w.submit=async h=>{try{return await E(h)}catch(O){if(!(O instanceof s)||O.reason!=="IDENTITY_CONTEXT_CHANGED"||h.operation!=="submit"||h.input.type!=="screen"||o.get(h.requestId)!==null)throw O;await w.settle?.(h.requestId),await w.get();let r=w.view;if(l.get(h.requestId)!==!1||!r||r.id!==e?.run.id||r.nodeId!==h.nodeId||r.visit!==h.visit||!e?.run.identity.binding)throw O;return E({...h,requestId:crypto.randomUUID(),revision:r.revision})}}}await n.get();for(let w of n.pendingCommands??[])o.has(w.requestId)&&o.get(w.requestId)!==(e?.run.identity.binding?.id??null)&&await n.settle?.(w.requestId);return{run:e.run,controller:n}},async syncIdentity(){let m=i;g(await y(()=>t.adapter.syncIdentity()).catch(P),m),await n?.get();for(let C of n?.pendingCommands??[])o.has(C.requestId)&&o.get(C.requestId)!==(e?.run.identity.binding?.id??null)&&await n?.settle?.(C.requestId);return e.run},async detach(){i++,n?.reset(),n=void 0,e=null,o.clear(),l.clear(),await y(()=>t.adapter.detach())},forProcess(m){if(!e?.run.identity.binding)throw new s("UNAUTHENTICATED","Sign in before a commercial operation",401);return{runId:e.run.id,bindingId:e.run.identity.binding.id,receiptId:m}},subscribe(m){return c.add(m),()=>{c.delete(m)}},destroy(){i++,n?.reset(),n=void 0,e=null,o.clear(),l.clear(),c.clear()}}}export{Dt as a,Ae as b,Ut as c,Gt as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as dn,c as fn,d as mn,e as pn}from"./chunk-VSMITXQD.js";import{a as te,b as Y}from"./chunk-CDG7GM4C.js";import{a as m}from"./chunk-OZZMZH7X.js";import{a as ln,b as cn,c as Ce}from"./chunk-4C5XH3T3.js";import{$a as un,Ea as Te,Fa as tn,R as Ge,T as Re,Ta as rn,U as Be,Ua as on,V as je,W as Je,Xa as an,Ya as sn,a as Ue,cb as le,da as Q,ea as ze,fa as B,ga as Ke,ha as Oe,ia as L,ka as Qe,la as Ye,ma as $e,n as ue,na as We,oa as Ze,ua as ne,va as Xe,ya as en,za as nn}from"./chunk-7DUOIHRD.js";import{B as ve,Ca as He,v as qe,y as ke}from"./chunk-VSJOHWDL.js";function Mn(e){let n=null,r=null,s=0,l=0,y=new Set,f=null,i=null,p=new Set,a=()=>{for(let o of p)try{o()}catch{}},u={attributes:ve.parse(e.attributes??{}),onFeatureUsage:e.onFeatureUsage?(o,t)=>{!y.has(o)&&(!n||!("analyticsConfig"in n)||n.analyticsConfig.featureUsageEnabled)&&e.onFeatureUsage(o,structuredClone(t),structuredClone(u.attributes))}:void 0,onExperimentViewed:e.onExperimentViewed?(o,t)=>(!n||!("analyticsConfig"in n)||n.analyticsConfig.experimentViewsEnabled)&&e.onExperimentViewed(structuredClone(o),structuredClone(t),structuredClone(u.attributes)):void 0,stickyBucketAssignmentDocs:structuredClone(e.stickyBucketAssignmentDocs),saveStickyBucketAssignmentDoc:e.saveStickyBucketAssignmentDoc?o=>e.saveStickyBucketAssignmentDoc(structuredClone(o)):void 0,trackedFeatureUsage:{},trackedExperiments:new Set},c=()=>({value:null,source:"unknownFeature",on:!1,off:!0,ruleId:""});function d(o,t=new Set){return y.has(o)?!f||!f.features[o]||["unknownFeature","cyclicPrerequisite"].includes(f.features[o].source):t.has(o)?!1:(t.add(o),(n?.features[o]?.rules??[]).some(I=>[...I.parentConditions??[],...(I.tracks??[]).flatMap(b=>b.experiment.parentConditions??[])].some(b=>d(b.id,t))))}let h=o=>{if(e.assertUsable?.(n?.generation),!n)throw new Error("Initialize the Feature client before evaluation");if(n.expiresAt&&Date.parse(n.expiresAt)<=Date.now())throw new Error("Feature configuration expired; refresh before evaluation");return f?.expiresAt&&Date.parse(f.expiresAt)<=Date.now()&&(f=null,u.features=n.features),y.has(o)?!f||f.expiresAt&&Date.parse(f.expiresAt)<=Date.now()?c():structuredClone(f.features[o]??c()):e.evaluateRemote&&(u.attributes?.merchandise||u.attributes?.merchandiseId)&&!f||d(o)?c():structuredClone(ke(o,u))};async function A(){if(!n||!y.size&&!u.attributes?.merchandise&&!u.attributes?.merchandiseId)return;if(!e.evaluateRemote){if(y.size)throw new Error("Remote Feature evaluation requires a server loader");return}let o=l;if(i?.revision===o)return i.loading;let t=s,I=n,b=[...y],S=(async()=>{let P=Je.parse(await e.evaluateRemote({attributes:structuredClone(u.attributes),features:b}));if(!(t!==s||o!==l||I!==n)){if(e.assertUsable?.(I.generation),P.generation!==I.generation)throw new Error("Feature configuration changed; refresh before evaluation");if(b.some(v=>!Object.hasOwn(P.features,v))||Object.keys(P.features).some(v=>!y.has(v)))throw new Error("Invalid remote Feature results");if(u.attributes?.merchandise||u.attributes?.merchandiseId){if(!P.merchandiseContext)throw new Error("Server did not resolve merchandise context");u.attributes=ve.parse({...u.attributes,...P.merchandiseContext})}f=structuredClone(P),u.features={...I.features,...Object.fromEntries(Object.entries(f.features).map(([v,D])=>[v,{defaultValue:D.value}]))},a()}})();i={revision:o,loading:S};try{await S}finally{i?.loading===S&&(i=null)}}function F(){A().catch(o=>{try{e.onError?.(o)}catch{}})}async function T(){if(r)return r;let o=s,t=(async()=>{let I=await e.load(),b="remoteFeatures"in I?Be.parse(I):null,S=b??Re.parse(I);if(S.scope.projectId!==e.scope.projectId||S.scope.environment!==e.scope.environment)throw new Error("Feature payload scope changed");if(o!==s)throw new Error("Feature client was reset");if(e.assertUsable&&n?.generation===S.generation){let{evaluatedAt:v,expiresAt:D,...V}=n,{evaluatedAt:M,expiresAt:H,...k}=S;if(L(V)!==L(k))throw new Error("Immutable Feature generation changed content");return n.evaluatedAt=S.evaluatedAt,n.expiresAt=S.expiresAt,a(),(!f||f.expiresAt&&Date.parse(f.expiresAt)<=Date.now())&&F(),structuredClone(n)}let P=new Set(b?.remoteFeatures??[]);if([...P].some(v=>Object.hasOwn(S.features,v)))throw new Error("Remote Feature definitions must not be delivered locally");return n&&"analyticsConfig"in n&&"analyticsConfig"in S&&!n.analyticsConfig.experimentViewsEnabled&&b?.analyticsConfig.experimentViewsEnabled&&u.trackedExperiments?.clear(),n=structuredClone(S),y=P,f=null,i=null,l++,u.features=n.features,u.savedGroups=qe(n.savedGroups),u.trackedFeatureUsage={},a(),F(),structuredClone(n)})();r=t;try{return await t}finally{r===t&&(r=null)}}return{init:T,refresh:T,refreshRemote:A,get generation(){return n?.generation??null},get expiresAt(){return n?.expiresAt??null},subscribe(o){return p.add(o),()=>{p.delete(o)}},setAttributes(o){let t=ve.parse(o);(u.attributes?.merchandise||u.attributes?.merchandiseId||o.merchandise||o.merchandiseId)&&u.trackedExperiments?.clear(),u.attributes=t,l++,f=null,i=null,u.features=n?.features??{},u.trackedFeatureUsage={},a(),F()},evalFeature:h,isOn(o){return h(o).on},isOff(o){return h(o).off},getFeatureValue(o,t){let I=h(o).value;return structuredClone(I===null?t:I)},reset(){s++,l++,r=null,i=null,n=null,f=null,y.clear(),u.features={},u.savedGroups={},u.stickyBucketAssignmentDocs={},u.attributes={},u.trackedFeatureUsage={},u.trackedExperiments?.clear(),a()}}}function gn(e){let n,r,s=()=>new m("COMMAND_STORAGE_INVALID","Durable command storage is unavailable"),l=Promise.resolve().then(async()=>{if(n=e.storage??globalThis.localStorage,r=e.locks??globalThis.navigator?.locks,!n||!r||!globalThis.crypto?.subtle)throw s();let i=new TextEncoder().encode(JSON.stringify([new URL(e.baseUrl??le).href,e.runToken])),p=new Uint8Array(await crypto.subtle.digest("SHA-256",i));return"indiana.funnel.commands.v1."+Array.from(p,a=>a.toString(16).padStart(2,"0")).join("")});l.catch(()=>{});async function y(i){try{let p=await l;return await r.request(p,{mode:"exclusive"},()=>i(p))}catch(p){throw p instanceof m?p:s()}}function f(i){let p=n.getItem(i);if(p===null)return{revision:0,entry:null};if(p.length>1048576)throw s();let a=JSON.parse(p);if(!a||typeof a!="object"||!("revision"in a)||!("entry"in a)||!Number.isSafeInteger(a.revision)||Number(a.revision)<0)throw s();return{revision:Number(a.revision),entry:a.entry}}return{read:()=>y(f),write:(i,p)=>y(a=>{if(f(a).revision!==i)return null;if(!Number.isSafeInteger(i+1))throw s();return n.setItem(a,JSON.stringify({revision:i+1,entry:p})),i+1})}}function be(e,n){let r=en.safeParse(n);if(!r.success)throw new m("INVALID_RESPONSE","Funnel response contract changed");let s=r.data;if(e.scope&&(s.scope.projectId!==e.scope.projectId||s.scope.environment!==e.scope.environment))throw new m("SCOPE_MISMATCH","Funnel scope changed");return s}async function Pe(e,n){let r=We.parse(n),{artifact:s,environmentId:l}=r.content,y=new te(e.baseUrl??le).origin,f=new te(s.url,y);if(f.origin!==y||f.username||f.password||f.search||f.hash||f.pathname!==`/api/v1/configuration/${l}/artifacts/${s.sha256}`)throw new m("INVALID_RESPONSE","Public Paywall locator is not trusted");let i=new AbortController,p,a=new Promise((c,d)=>{p=setTimeout(()=>{let h=new m("TIMEOUT","Public Paywall read timed out");i.abort(h),d(h)},B.initializationMs)}),u=(async()=>{let c=await(e.fetch??globalThis.fetch)(f,{method:"GET",credentials:"omit",redirect:"error",cache:"default",signal:i.signal});if(i.signal.aborted&&(c.body?.cancel().catch(()=>{}),i.signal.throwIfAborted()),!c.ok||!c.headers.get("content-type")?.toLowerCase().startsWith("application/json")||Number(c.headers.get("content-length"))>s.byteLength)throw c.body?.cancel().catch(()=>{}),new m("INVALID_RESPONSE","Public Paywall is unavailable");let d=await ln(c,s.byteLength,{signal:i.signal,error:h=>new m("INVALID_RESPONSE",h==="missing"?"Public Paywall body is missing":"Public Paywall exceeds its byte limit")});if(!Ce(d,s))throw new m("INVALID_RESPONSE","Public Paywall digest or size changed");return Ze(r,JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(d)))})();try{return await Promise.race([u,a])}finally{clearTimeout(p)}}var _e=(e,n)=>new m(e,n);function Xn(e){return sn(e,_e)}async function De(e,n,{predict:r=!0}={}){let s=n.instruction;if(s?.type!=="evaluate_segment")throw new Error("Local segment instruction required");if(!e)throw new m("CONFIGURATION_UNAVAILABLE","Local execution requires public configuration");if(e.scope.environmentId!==s.environmentId)throw new m("SCOPE_MISMATCH","Evaluation environment changed");let l=null,y;if(r)try{let f=await e.funnel(n.source.id,n.source.versionId);y=f.manifest.generation,l=An(e,n,f)}catch{l=null}return y??=e.snapshot?.generation??(await e.refresh()).generation,{advance:{policyRevision:s.policyRevision,generation:y},prediction:l}}function An(e,n,r){let s=n.instruction;if(s?.type!=="evaluate_segment"||!r.growth||r.control.evaluationMode!=="local"||r.control.evaluationRevision!==s.policyRevision)return null;let{analyticsConfig:l,remoteFeatures:y,...f}=r.growth,i=rn({scope:{projectId:e.scope.projectId,environment:e.scope.environment},funnelId:n.source.id,versionId:n.source.versionId,evaluationMode:"local",evaluationRevision:s.policyRevision,document:r.document,payload:Re.parse(f)}),p=Nn(i,r.document,{...n,...s}),a=p.steps.at(-1),u=p.boundary??(a?.result.port==="value"?{nodeId:a.nodeId,visit:n.visit+p.steps.length-1}:null);return u?{runId:n.id,from:{nodeId:n.nodeId,visit:n.visit,revision:n.revision},nodeId:u.nodeId,visit:u.visit,terminal:!p.boundary}:null}function Nn(e,n,r){return un(e,n,r,_e)}import{z as j}from"zod";var yn=Q.refine(e=>!["start","get","review"].includes(e.operation)&&!("customerToken"in e),"Persist only the original mutation, without credentials").transform(e=>{if(e.operation==="start"||e.operation==="get"||e.operation==="review")throw new m("COMMAND_STORAGE_INVALID","Stored mutation required");return e}),wn=j.strictObject({schemaVersion:j.literal(1),scope:Ue,runId:j.uuid(),funnelId:j.uuid(),versionId:j.uuid(),processBindingIds:j.record(j.uuid(),j.uuid().nullable()).optional(),command:yn.optional(),closeCommand:yn.refine(e=>e.operation==="close").optional(),purchase:j.strictObject({receiptId:j.uuid(),operationId:j.uuid(),generation:j.number().int().nonnegative()}).optional(),closed:j.literal(!0).optional()}).refine(e=>!e.closeCommand||e.command&&e.command.operation!=="close"&&e.command.requestId!==e.closeCommand.requestId,"Close requires a separate request identity").refine(e=>e.command!==void 0||e.purchase!==void 0,"A recovery record requires an original obligation"),q=()=>new m("COMMAND_STORAGE_CONFLICT","Another host changed this Run's pending command"),Se=(e,n)=>JSON.stringify(e)===JSON.stringify(n);function In(e){let n=0,r=null,s=a=>JSON.stringify([a.scope,a.runId,a.funnelId,a.versionId]),l=Promise.resolve();async function y(){let a=await e.read();if(!Number.isSafeInteger(a.revision)||a.revision<0)throw new m("COMMAND_STORAGE_INVALID","Invalid command storage revision");return{revision:a.revision,entry:a.entry===null?null:wn.parse(a.entry)}}function f(a){let u=l.then(a);return l=u.catch(()=>{}),u}async function i(a){for(let u=0;u<4;u++){let c=await y();if(c.entry&&r!==null&&s(c.entry)!==r)throw q();let d=a(c.entry,c.revision);if(Se(c.entry,d)){n=c.revision;return}let h=await e.write(c.revision,d);if(h!==null){if(!Number.isSafeInteger(h)||h<=c.revision)throw q();n=h;return}}throw q()}function p(a,u){if(!a||!u)return a;if(a.processBindingIds&&Object.hasOwn(a.processBindingIds,u)){let c={...a.processBindingIds};delete c[u],a={...a,processBindingIds:c}}return a.command?.requestId===u?a.closeCommand?{...a,command:a.closeCommand,closeCommand:void 0}:a.purchase?{...a,command:void 0}:null:a.closeCommand?.requestId===u?{...a,closeCommand:void 0}:a}return{bind(a){let u=JSON.stringify([a.scope,a.runId,a.funnelId,a.versionId]);if(r!==null&&r!==u)throw q();r=u},async load(){let a=await y();return n=a.revision,r=a.entry?s(a.entry):null,a.entry},retain(a){let u=wn.parse(a),c=u.command;return!c||r!==null&&s(u)!==r?Promise.reject(q()):(r??=s(u),f(()=>i((d,h)=>{if(d&&!Se(s(d),s(u)))throw q();if(d&&u.processBindingIds){for(let[A,F]of Object.entries(u.processBindingIds))if(d.processBindingIds&&Object.hasOwn(d.processBindingIds,A)&&d.processBindingIds[A]!==F)throw q();d={...d,processBindingIds:{...d.processBindingIds,...u.processBindingIds}}}if(!d){if(h!==n&&c.operation!=="close")throw q();return u}if(!d.command)return{...d,command:c,...c.operation==="close"?{closed:!0}:{}};if(c.operation==="close"&&d.command.operation!=="close"){if(d.command.requestId===c.requestId||d.closeCommand&&!Se(d.closeCommand,c))throw q();return{...d,closeCommand:c,closed:!0}}if(!Se(d.command,c))throw q();return d})))},observePurchase(a,u,c,d){return f(()=>i((h,A)=>{if(!h&&A!==n||h&&s(h)!==s({...a,schemaVersion:1}))throw q();if(h?.purchase&&h.purchase.generation>u.generation)return p(h,d);if(h?.purchase&&h.purchase.generation===u.generation&&h.purchase.operationId!==u.operationId)throw q();return c?!h?.purchase||h.purchase.operationId!==u.operationId?p(h,d):p(h.command?{...h,purchase:void 0}:null,d):p({schemaVersion:1,...a,...h,purchase:u},d)}))},settle(a){return f(()=>i(u=>p(u,a)))}}}function lt(e,n){return n.type==="id"?e.customerId===n.value:e.externalUserId===n.value}function ce(e,n){if(e===n)return!0;if(Array.isArray(e)||Array.isArray(n))return Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((l,y)=>ce(l,n[y]));if(!e||!n||typeof e!="object"||typeof n!="object")return!1;let r=Object.entries(e),s=Object.entries(n);return r.length===s.length&&r.every(([l,y])=>Object.hasOwn(n,l)&&ce(y,Reflect.get(n,l)))}function hn(e,n){let r=n&&{...n},s=null,l=0,y=new AbortController;function f(){l++,y.abort(new m("IDENTITY_CHANGED","Run identity changed")),y=new AbortController}let i=!1,p,a=0,u=new Set;return{get scope(){return r},bindScope(c){if(r&&(r.projectId!==c.projectId||r.environment!==c.environment))throw new m("SCOPE_MISMATCH","Run scope changed");r??={...c}},get view(){return s},get generation(){return l},get signal(){return y.signal},get disposed(){return i},get customerToken(){return p},get readSequence(){return a},nextRead(){return++a},assertCurrent(c,d="Run identity changed during the request"){if(c!==l||i)throw new m("IDENTITY_CHANGED",d)},assertRun(c){if(s&&(c.id!==s.id||c.source.type!==s.source.type||c.source.id!==s.source.id||c.source.versionId!==s.source.versionId||c.locale!==s.locale||!ce(c.parameters,s.parameters)))throw new m("INVALID_RESPONSE","Run version changed");if(e&&c.source.id!==e)throw new m("INVALID_RESPONSE","Run belongs to another Funnel")},publish(c,d,h,A,F){if(!(c.operation==="review"&&s&&s!==h&&d.run.revision<=s.revision)&&!(s&&d.run.revision===s.revision&&A!==void 0&&A<a)&&(c.operation==="review"&&!d.run.stopped&&["running","waiting"].includes(d.run.status)&&s&&d.run.nodeId===s.nodeId&&d.run.visit===s.visit&&d.run.revision===s.revision&&(d.run.screen=s.screen,(s.paywall?.quote?.operationId===d.review?.activeOperationId||!s.paywall?.quote&&d.review?.activeOperationId===null)&&(d.run.paywall=s.paywall)),!(s?.paywall&&d.run.paywall&&s.paywall.receiptId===d.run.paywall.receiptId&&(d.run.paywall.selectionGeneration??0)<(s.paywall.selectionGeneration??0)))){if(!s||d.run.revision>=s.revision)s=d.run;else if(!F)return;if(s)for(let T of u)try{T(structuredClone(s))}catch{}}},identify(c){if(i)throw new m("IDENTITY_CHANGED","Controller was reset");if(!ue.test(c))throw new m("INVALID_TOKEN","Customer credential required");f(),p=c},subscribe(c){return u.add(c),()=>u.delete(c)},reset(){i||(i=!0,f(),p=void 0,s=null,u.clear())}}}var re=/^gg_sk_[A-Za-z0-9_-]{32,128}$/;function yt(e,n,r="A server API key is required"){if(typeof window<"u")throw new m("SERVER_ONLY",n);if(!re.test(e))throw new m("INVALID_TOKEN",r)}function wt(e){let n=Y(e);return n.identify(e.apiKey),n}function $(e){let{customerToken:n,...r}=e;return r}var On=e=>!(e instanceof m)||e.status===void 0||e.status>=500||[401,425].includes(e.status)||e.recovery==="recover_operation";function vn({journal:e,state:n,call:r,processIdentity:s}){let l=null,y=null,f=!1,i={command:null,close:null},p=new Set,a,u=null,c=e?e.load().then(o=>{if(n.disposed)throw new m("IDENTITY_CHANGED","Controller was reset during command restoration");if(u=o,!o)return;if(s){if([o.command,o.closeCommand].some(I=>I&&!Object.hasOwn(o.processBindingIds??{},I.requestId)))throw new m("COMMAND_STORAGE_INVALID","The original process identity is missing");s.restore(o.processBindingIds??{})}if(n.scope&&(o.scope.projectId!==n.scope.projectId||o.scope.environment!==n.scope.environment))throw new m("SCOPE_MISMATCH","Pending command belongs to another scope");if(a=o.purchase,f=o.closed===!0,!o.command)return;let t=o.command;l=t.operation==="close"?null:t,y=t.operation==="close"?t:o.closeCommand?.operation==="close"?o.closeCommand:null,y&&(f=!0);for(let I of[l,y])I&&p.add(I.requestId)}):Promise.resolve();c.catch(()=>{});async function d(o){e&&await c;let t=n.generation;if(e){if(!n.view||!n.scope)throw new m("COMMAND_STORAGE_INVALID","Read the original scoped Run before persisting a mutation");await e.retain({schemaVersion:1,scope:n.scope,runId:n.view.id,funnelId:n.view.source.id,versionId:n.view.source.versionId,command:$(o),...s?{processBindingIds:{[o.requestId]:s.binding(o.requestId)}}:{}})}if(t!==n.generation||l!==o&&y!==o)throw new m("IDENTITY_CHANGED","Run changed before command dispatch");let I=p.has(o.requestId);p.add(o.requestId);try{return await r(o)}catch(b){throw t===n.generation&&(l===o||y===o)&&!I&&!On(b)&&(e&&await e.settle(o.requestId),t===n.generation&&T(o)),b}}function h(o){let t=Q.parse(o);if(t.operation==="start"||t.operation==="get"||t.operation==="review")throw new m("INVALID_REQUEST","Mutation required");if(f&&t.operation!=="close"){if(l?.requestId===t.requestId)return F(t.requestId);throw new m("COMMAND_PENDING","Close preserves the original recovery record; settle it by identity")}if(t.operation==="close"){if(l?.requestId===t.requestId)throw new m("INVALID_REQUEST","Close requires its own request identity");if(f=!0,y&&JSON.stringify($(y))!==JSON.stringify($(t)))throw new m("COMMAND_PENDING","Retry the original Close");return y??=t,i.close?i.close:A(y,"close")}if(l){if(JSON.stringify($(l))!==JSON.stringify($(t)))throw new m("COMMAND_PENDING","Retry the original command before sending another");if(i.command)return i.command}else l=t;return A(l,"command")}function A(o,t){let I=d(o);i[t]=I;let b=()=>{i[t]===I&&(i[t]=null)};return I.then(b,b),I}function F(o){return r({operation:"get",settlementRequestId:o})}function T(o){return!o||l!==o&&y!==o?!1:(l===o&&(l=null),y===o&&(y=null),p.delete(o.requestId),!l&&!y&&(u=null),!0)}return{ready:c,get pending(){return l},get closing(){return y},get closeRequested(){return f},get inFlight(){return i.command},get closeFlight(){return i.close},get purchase(){return a},assertBinding(o){if(u&&(o.run.id!==u.runId||o.run.source.id!==u.funnelId||o.run.source.versionId!==u.versionId))throw new m("SCOPE_MISMATCH","Stored command belongs to another Run or Version")},async observe(o,t,I,b){let S=o.operation==="get"?o.settlementRequestId:"requestId"in o&&o.operation!=="start"?o.requestId:void 0,P=S&&t.settlement?.state==="settled"&&t.run.pendingRequest?.requestId!==S&&(o.operation==="get"||!f||o.operation==="close"||!["running","waiting"].includes(t.run.status))?S:void 0,v=l?.requestId===P?l:y?.requestId===P?y:void 0;e?.bind({scope:t.scope,runId:t.run.id,funnelId:t.run.source.id,versionId:t.run.source.versionId});let D=t.run.paywall,V=D??t.purchase,M=V?.operation,H=t.settlement&&(!D||D.purchaseRequestId===t.settlement.requestId)&&(!a||a.operationId===t.settlement.operationId)?t.settlement:void 0,k=M?.operationId??V?.quote?.operationId??H?.operationId,J=V?.receiptId??H?.receiptId,de=D?.selectionGeneration??a?.generation??0;if(e&&k&&J&&o.operation!=="review"&&(!n.view||t.run.revision>=n.view.revision)&&(b===void 0||b>=n.readSequence)&&(!a||de>=a.generation)){let Z={receiptId:J,operationId:k,generation:de},fe=M?.status==="complete"||V?.canReselect===!0;await e.observePurchase({scope:t.scope,runId:t.run.id,funnelId:t.run.source.id,versionId:t.run.source.versionId},Z,fe,P),n.assertCurrent(I),(!a||Z.generation>=a.generation)&&(b===void 0||b>=n.readSequence)&&(fe?a?.operationId===Z.operationId&&(a=void 0):a=Z)}else e&&P&&await e.settle(P);return n.assertCurrent(I),P?T(v):!1},stop(){f=!0},submit:h,settle:F,reset(){f=!0,l=null,y=null,a=void 0,u=null,i.close=null,p.clear(),i.command=null}}}function Rn(e){if(e={...e},typeof e.runToken!="string"||!/^gg_fr_[A-Za-z0-9_-]{43}$/.test(e.runToken))throw new m("INVALID_TOKEN","Run credential required");if(e.serverKey&&(typeof window<"u"||!re.test(e.serverKey)))throw new m("SERVER_ONLY","Run Server-Key proof belongs to the merchant backend");if(e.serverKey&&e.session)throw new m("INVALID_REQUEST","Choose Customer session or Server-Key proof for this Run");let n=Y({...e,session:void 0,timeoutMs:e.timeoutMs??35e3}),r=hn(e.funnelId,e.scope??e.configuration?.scope),s=e.session?.subscribeIdentity(a),l=null,y=e.funnelCommandStorage??(typeof window<"u"&&window.isSecureContext?gn(e):void 0),f=y&&In(y),i=vn({journal:f,state:r,call:u,processIdentity:e.process});async function p(t){if(e.process)return e.process.request(t);let I=r.generation;r.assertCurrent(I);let b=performance.now()+(e.timeoutMs??35e3),S=r.customerToken??("customerToken"in t?t.customerToken:void 0);if(e.session){let D=r.signal,V,M=()=>{},H=new Promise((k,J)=>{M=()=>J(D.reason),D.addEventListener("abort",M,{once:!0}),V=setTimeout(()=>J(new m("TIMEOUT","Longplay request timed out")),Math.max(1,b-performance.now()))});try{S=await Promise.race([Promise.resolve().then(()=>(r.assertCurrent(I),e.session.access())),H])}finally{clearTimeout(V),D.removeEventListener("abort",M)}}r.assertCurrent(I);let P={...t,...S?{customerToken:S}:{}},v=t.operation==="page_experiments"?Te.parse(P):Q.parse(P);return n.requestWithCredential("funnels",v,e.runToken,{headers:e.serverKey&&!S?{[nn]:e.serverKey}:void 0,timeoutMs:Math.max(1,b-performance.now())})}function a(){s?.(),r.reset(),i.reset(),l=null,n.dispose()}async function u(t,I){let b=r.generation,S=()=>r.assertCurrent(b);f&&await i.ready,S();let P=r.view,v=be(e,await p(t));if(t.operation==="review"&&!v.review)throw new m("INVALID_RESPONSE","Historical projection is missing");if(S(),v.runToken&&v.runToken!==e.runToken)throw new m("INVALID_RESPONSE","Run credential changed");let D=t.operation==="get"?t.settlementRequestId:"requestId"in t&&t.operation!=="start"?t.requestId:void 0;if(D&&v.settlement?.requestId!==D)throw new m("INVALID_RESPONSE","Exact command settlement is missing or belongs to another command");i.assertBinding(v),r.assertRun(v.run),r.bindScope(v.scope);let V=await i.observe(t,v,b,I);return!v.run.stopped&&["running","waiting"].includes(v.run.status)&&t.operation==="get"&&t.settlementRequestId||(S(),["running","waiting"].includes(v.run.status)||i.stop(),r.publish(t,v,P,I,V)),v}let c=i.submit,d=null,h=new WeakMap;function A(t){let I=h.get(t);if(I)return I;let b=T(t);return h.set(t,b),b}let F=!1;async function T(t){let I=await t;if(I.run.instruction?.type!=="evaluate_segment")return I;if(d)return d;F=!0;let b=r.generation,S=(async()=>{for(let P=0;P<32&&I.run.instruction?.type==="evaluate_segment";P++){if(i.pending||i.closeRequested)return I;let v=I.run;if(I.run.instruction?.type==="evaluate_segment"){let{advance:V}=await De(e.configuration,v,{predict:!1});if(b!==r.generation)throw new m("IDENTITY_CHANGED","Run identity changed during segment calculation");if(i.pending||i.closeRequested)return I;if(r.view&&(r.view.revision!==v.revision||r.view.visit!==v.visit||r.view.nodeId!==v.nodeId))return u({operation:"get"});let M=!0;De(e.configuration,v).then(({prediction:H})=>{M&&b===r.generation&&!i.closeRequested&&r.view?.id===v.id&&!r.view.stopped&&r.view.nodeId===v.nodeId&&r.view.visit===v.visit&&r.view.revision===v.revision&&(l=H)}).catch(()=>{});try{I=await c({operation:"commit_segment",requestId:Xe(v.id,v.visit,`segment:${v.revision}`),nodeId:v.nodeId,visit:v.visit,revision:v.revision,...V})}finally{M=!1,l=null}}}return I})();d=S;try{return await S}finally{d===S&&(d=null)}}let o={get configuration(){return F?e.configuration:void 0},get configurationReady(){return!0},get view(){return r.view?structuredClone(r.view):null},get pendingCommand(){let t=i.closing??i.pending;return t?structuredClone($(t)):null},get pendingCommands(){return[i.pending,i.closing].filter(t=>t!==null).map(t=>structuredClone($(t)))},get pendingPurchase(){return i.purchase?structuredClone(i.purchase):null},get prediction(){let t=r.view;return l&&t&&!t.stopped&&["running","waiting"].includes(t.status)&&t.id===l.runId&&t.nodeId===l.from.nodeId&&t.visit===l.from.visit&&t.revision===l.from.revision&&!i.closeRequested?structuredClone(l):null},settle:i.settle,get webViewUrl(){return"bundled"},resolvePaywall(t){return Pe(e,t)},async pageExperiments(t,I=[]){let b=r.generation;r.assertCurrent(b);let S=r.view?.id;if(!S)throw new m("INVALID_REQUEST","Read the Run before its page experiments");let P=tn.parse(await p(Te.parse({operation:"page_experiments",release:t,usedReceiptIds:I})));if(r.assertCurrent(b),P.runId!==S||P.scope.projectId!==r.scope?.projectId||P.scope.environment!==r.scope?.environment)throw new m("SCOPE_MISMATCH","Page experiment Run changed");return P},review(t){return u({operation:"review",...t?{receiptId:t}:{}},r.nextRead())},async get(t,I){f&&await i.ready,I??=i.purchase&&{receiptId:i.purchase.receiptId,operationId:i.purchase.operationId};let b=r.nextRead();return A(u({operation:"get",...t?{data:t}:{},...I?{purchase:I}:{}},b))},resume(t=r.view?.pendingRequest?.requestId){return t?i.closeRequested?o.settle(t):i.pending?.requestId===t?A(c(i.pending)):A(c({operation:"resume",requestId:t})):Promise.reject(new m("INVALID_REQUEST","No interrupted command is available"))},submit(t){return A(c(t))},retry(){return i.closeFlight?i.closeFlight:i.closing?c(i.closing):i.closeRequested&&i.pending?o.settle(i.pending.requestId):i.inFlight?A(i.inFlight):i.pending?A(c(i.pending)):Promise.reject(new m("INVALID_REQUEST","No command is pending"))},identify(t){r.identify(t),l=null,n.reset()},subscribe:r.subscribe,reset:a};return o}import{ZodError as Tn}from"zod";function Cn(e,n,r,s){try{return e.parse(n)}catch(l){throw s&&l instanceof Tn?new m(r,s):l}}async function Ee(e,n,r,s={},l){let y=typeof s=="function"?{}:s,f=Cn(n.request,r,"INVALID_REQUEST",y.request);try{let i=await e(n.path,f,n.method,l),p=typeof s=="function"?s:s.parseResponse;return p?p(n.response,i):Cn(n.response,i,"INVALID_RESPONSE",y.response)}catch(i){throw i instanceof m&&f!==null&&typeof f=="object"&&"requestId"in f&&typeof f.requestId=="string"&&(i.commandRequestId??=f.requestId),i}}async function jt(e,n){if(!ue.test(n.customerToken))throw new m("INVALID_TOKEN","A verified Customer credential is required");if(e.session&&e.session.peek()!==n.customerToken)throw new m("SCOPE_MISMATCH","Paywall credential does not match the shared session");let r=ne.resolvePaywall.request.parse({funnelId:n.funnelId,funnelVersionId:n.funnelVersionId,selector:n.paywallVersionId?{type:"version",versionId:n.paywallVersionId}:{type:"paywall",paywallId:n.paywallId},commerce:n.commerce,locale:n.locale,...n.requirement?{requirement:n.requirement}:{}}),s=Y(e);e.session||s.identify(n.customerToken);let l=null,y=!1,f=null,i=null,p=null,a=null;function u(){if(y)throw new m("IDENTITY_CHANGED","Paywall is closed")}async function c(){u();let F=ne.resolvePaywall,T=await Ee(s.request,F,{...r,selector:l?{type:"version",versionId:l.id}:r.selector}),o=await Pe(e,T.paywall);if(u(),n.paywallVersionId?o.id!==n.paywallVersionId:o.paywallId!==n.paywallId)throw new m("INVALID_RESPONSE","The requested Paywall changed");if(l&&(!dn(o,l)||o.paywallId!==l.paywallId))throw new m("INVALID_RESPONSE","The pinned Paywall or Offering Version changed");return l=o,structuredClone(l)}async function d(F){if(u(),a&&F!=="read")throw new m("COMMAND_PENDING","Wait for the original quote");if(!f)throw new m("INVALID_REQUEST","A quoted purchase is required");let T=f,o=F==="read"?ne.readSubscriptionOperation:ne.attach,t=await Ee(s.request,o,{operationId:T.operationId,...F==="read"?{}:{intent:F}});return fn(t.operation,{operationId:T.operationId,currency:r.commerce.currency},"The purchase operation changed"),u(),f?.operationId!==T.operationId?structuredClone(t.operation):(i=pn(i,t.operation),structuredClone(i))}let h={get view(){return l?structuredClone(l):null},get quote(){return f?structuredClone(f):null},get operation(){return i?structuredClone(i):null},get webViewUrl(){return"bundled"},refresh:c,async preview(F){if(u(),!l)throw new m("INVALID_REQUEST","Load the Paywall first");let T=l.document.buttons[F.actionId];if(T?.type!=="checkout")throw new m("INVALID_REQUEST","Choose an authored purchase action");let o=Ge(T.product,F.selection,l.capabilities);if(!o)throw new m("PRODUCT_UNAVAILABLE","Choose an available Product");let t=He(l.document.screen,o,F.selection,l.capabilities),I=ne.previewAttach.request.parse({funnelId:r.funnelId,funnelVersionId:r.funnelVersionId,requestId:F.requestId,plans:[{productVersionId:o,...Object.keys(t).length?{featureQuantities:t}:{}}],provider:r.commerce.provider,currency:r.commerce.currency,...F.offerId?{offerId:F.offerId}:{},...F.nativeOffer?{nativeOffer:F.nativeOffer}:{}}),b=JSON.stringify(I);if(p&&p!==b&&(a||!i||i.status==="pending"))throw new m("COMMAND_PENDING","Finish or cancel the original purchase before changing it");if(p===b){if(a)return a;if(f)return structuredClone(f)}p!==b&&(f=null,i=null),p=b;let S=(async()=>{let P=ne.previewAttach,v=await Ee(s.request,P,I);return u(),mn(v.quote,{productVersionId:o,featureQuantities:t,currency:r.commerce.currency,provider:r.commerce.provider},"The purchase quote changed its selected Product or presentment"),f=v.quote,i=null,structuredClone(f)})();a=S;try{return await S}finally{a===S&&(a=null)}},confirm:()=>d("confirm"),cancel:()=>d("cancel"),read:()=>d("read"),destroy(){y||(y=!0,A?.(),s.dispose(),l=null,f=null,i=null,p=null)}},A=e.session?.subscribeIdentity(h.destroy);try{return await c(),h}catch(F){throw h.destroy(),F}}import{z as Ln}from"zod";import{z as ge}from"zod";var _n=ge.record(ge.string().regex(/^[a-f0-9]{64}$/),ge.strictObject({at:ge.number(),text:ge.string()})),oe=2*1048576,Dn=100;function xn(){try{return typeof window>"u"?void 0:window.localStorage}catch{return}}function bn(e,n){let r=n===void 0?xn():n,s=new Map,l=0,y=!1,f=!1,i,p;async function a(c){if(!r)return null;let d;try{let h=await Promise.race([Promise.resolve().then(()=>r.getItem(c)),new Promise(A=>{d=setTimeout(()=>A(null),Dn)})]);return typeof h=="string"&&h.length<=oe&&new TextEncoder().encode(h).byteLength<=oe?h:null}catch{return null}finally{clearTimeout(d)}}function u(){if(p)return p;let c=(async()=>{try{let d=await a(`${e}:artifacts`);if(d)return _n.parse(JSON.parse(d))}catch{}return{}})();return p=c,c.finally(()=>{p===c&&(p=void 0)}),c}return{async readManifest(){return a(e)},writeManifest(c){!r||c.length>oe||new TextEncoder().encode(c).byteLength>oe||(i=c,!f&&(f=!0,Promise.resolve().then(async()=>{try{for(;i!==void 0;){let d=i;try{await r.setItem(e,d)}catch{}i===d&&(i=void 0)}}finally{f=!1}})))},async readArtifact(c){let d=(await u())[c],h=Date.now();return d&&h>=d.at&&h-d.at<=B.retentionMs?d.text:void 0},writeArtifact(c,d){if(!r||d.length>oe)return;let h=s.get(c);if(h?.text===d||!h&&s.size>=128)return;let A=new TextEncoder().encode(d).byteLength;l-(h?.byteLength??0)+A>oe||(s.set(c,{text:d,byteLength:A}),l+=A-(h?.byteLength??0),!y&&(y=!0,Promise.resolve().then(async()=>{try{for(;s.size;){let F=new Map(s);try{let T={...await u()},o=Date.now();for(let[S,P]of F)T[S]={at:o,text:P.text};let t={},I=2,b=0;for(let[S,P]of Object.entries(T).sort(([,v],[,D])=>D.at-v.at)){if(P.at>o||o-P.at>B.retentionMs)continue;let v=new TextEncoder().encode(JSON.stringify({[S]:P})).byteLength;I+v>oe||b>=128||(t[S]=P,I+=v,b++)}await r.setItem(`${e}:artifacts`,JSON.stringify(t))}catch{}finally{for(let[T,o]of F)s.get(T)===o&&(s.delete(T),l-=o.byteLength)}}}finally{y=!1}})))}}}var E=(e,n)=>new m(e,n),W=()=>performance.now(),Pn=e=>{typeof e=="object"&&"unref"in e&&e.unref()};function nr(e){let n=Ke.parse(e.scope),r=new te(e.origin??le);if(r.username||r.password||r.search||r.hash||r.pathname!=="/"||r.protocol!=="https:"&&!(r.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(r.hostname)))throw E("INVALID_URL","Configuration requires a trusted HTTPS origin");let s=new Set([r.origin,...(e.assetOrigins??[]).map(w=>{let g=new te(w);if(g.protocol!=="https:"||g.username||g.password||g.search||g.hash||g.pathname!=="/")throw E("INVALID_URL","Invalid configuration asset origin");return g.origin})]),l=e.fetch??globalThis.fetch.bind(globalThis),y=`/api/v1/configuration/${n.environmentId}`,f=`indiana:configuration:1:${r.origin}:${L(n)}`,i=bn(f,e.storage),p,a=0,u=0,c=!1,d=!1,h=0,A=0,F,T,o,t,I=0,b=new Set,S=new Set,P=new Map,v=new Map,D=0,V=!1;function M(){for(let w of b)try{w()}catch{}}function H(w){try{e.onError?.(w)}catch{}}let k=()=>!d&&!c&&!!p&&W()<a&&Date.now()<u;function J(){if(!k())throw E("CONFIGURATION_EXPIRED","Refresh configuration before using it")}function de(w,g,R){if(!P.has(w)){for(;P.size&&(P.size>=128||D+R>B.maxCacheBytes);){let C=P.entries().next().value;D-=C[1].byteLength,P.delete(C[0])}P.set(w,{text:g,byteLength:R}),D+=R}}function Z(w,g,R){return cn(w,g,{signal:R,error:C=>E("INVALID_RESPONSE",C==="missing"?"Configuration body is missing":"Configuration exceeds its byte limit")})}function fe(w){let g=new te(w,r);if(!s.has(g.origin)||g.username||g.password||g.hash||g.search)throw E("INVALID_URL","Configuration artifact origin is not trusted");return g.href}async function Fe(w,g,R=!1){let C=await l(fe(w),{method:"GET",credentials:"omit",redirect:"error",cache:R?"default":"no-cache",signal:g,headers:{}});if(C.status===429){let O=C.headers.get("retry-after")??"";I=/^\d+$/.test(O)?Number(O)*1e3:Math.max(0,Date.parse(O)-Date.now())||15e3}if(!C.ok&&C.status!==304)throw E(`CONFIGURATION_HTTP_${C.status}`,"Configuration synchronization failed");return C}function En(w,g,R){let C=Date.parse(w.headers.get("x-indiana-config-validated-at")??""),O=Date.parse(w.headers.get("x-indiana-config-valid-until")??""),_=Date.parse(w.headers.get("date")??""),N=w.headers.get("age"),G=N!==null&&/^\d+(\.\d+)?$/.test(N)?Number(N)*1e3:NaN;if(![C,O,_,G].every(Number.isFinite)||O<=C||O-C>B.maxControlAgeMs||C>_+1e3)throw E("INVALID_RESPONSE","Configuration freshness evidence is invalid");let x=Math.min(O-C,R.maxControlAgeSeconds*1e3,B.maxControlAgeMs)-Math.max(G,_-C,0)-(W()-g);if(x<=0)throw E("CONFIGURATION_EXPIRED","Configuration validation expired in transit");return W()+x}function Ae(){if(clearTimeout(o),clearTimeout(t),d||!b.size)return;k()&&(t=setTimeout(()=>{k()?Ae():M()},Math.max(1,a-W())),Pn(t));let w=A?Math.min(15e3,1e3*2**Math.min(A-1,4)):Math.min(15e3,(p?.policy.refreshIntervalSeconds??15)*1e3);o=setTimeout(()=>{ie().catch(H)},Math.max(I,w*(.8+Math.random()*.2))),Pn(o)}async function ie(){if(d)throw E("CONFIGURATION_DISPOSED","Configuration manager was destroyed");if(F)return F;let w=h,g=new AbortController;T=g;let R=(async()=>{if(!V){V=!0;try{let he=await i.readManifest();if(he&&!p){let K=Oe.parse(JSON.parse(he));L(K.scope)===L(n)&&(p=K)}}catch{}}g.signal.throwIfAborted();let N=p,G=W(),U=await Fe(y,g.signal);U.status===304&&(!N||!U.headers.has("x-indiana-config-validated-at")||!U.headers.has("x-indiana-config-valid-until")||!U.headers.has("age"))&&(U=await Fe(y,g.signal));let x=U.status===304?N:Oe.parse(JSON.parse(await Z(U,B.maxManifestBytes,g.signal))),{generation:ae,...se}=x,z=U.headers.get("etag");if(L(x.scope)!==L(n)||Qe(se)!==ae||z!==`"${ae}"`&&z!==`W/"${ae}"`)throw E("INVALID_RESPONSE","Configuration scope or content identity changed");if(N&&(x.revision<N.revision||x.revision===N.revision&&x.generation!==N.generation))throw E("INVALID_RESPONSE","Configuration revision moved backwards or changed identity");for(let[he,K]of Object.entries(N?.funnels??{})){let ee=x.funnels[he];if(ee&&(ee.controlRevision<K.controlRevision||ee.evaluationRevision<K.evaluationRevision||ee.controlRevision===K.controlRevision&&ee.state!==K.state||ee.evaluationRevision===K.evaluationRevision&&ee.evaluationMode!==K.evaluationMode))throw E("INVALID_RESPONSE","Funnel control revision changed identity")}let X=En(U,G,x.policy);if(g.signal.throwIfAborted(),w!==h)throw E("CONFIGURATION_DISPOSED","Configuration scope changed");return p=x,a=X,u=Date.now()+Math.max(0,X-W()),c=!1,A=0,I=0,i.writeManifest(L(x)),M(),structuredClone(x)})(),C=setTimeout(()=>g.abort(E("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),B.initializationMs),O=new Promise((N,G)=>g.signal.addEventListener("abort",()=>G(g.signal.reason),{once:!0})),_=Promise.race([R,O]).catch(N=>{throw A++,(N instanceof Ln.ZodError||N instanceof SyntaxError||N instanceof m&&["CONFIGURATION_HTTP_404","CONFIGURATION_HTTP_410","INVALID_RESPONSE"].includes(N.code))&&(a=0,c=!0,M()),N}).finally(()=>{clearTimeout(C),F===_&&(F=void 0),Ae()});return F=_,_}async function ye(w){let g=w.sha256,R=se=>Ce(se,w);fe(w.url);let C=P.get(g);if(C){if(C.byteLength!==w.byteLength)throw E("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return P.delete(g),P.set(g,C),C.text}let O=v.get(g);if(O){if(O.byteLength!==w.byteLength)throw E("INVALID_RESPONSE","Configuration artifact digest or size mismatch");return O.promise}let _=new AbortController;S.add(_);let N=h,G=(async()=>{try{let X=await i.readArtifact(g);if(X&&R(X)){if(_.signal.throwIfAborted(),d||N!==h)throw E("CONFIGURATION_DISPOSED","Configuration scope changed");return de(g,X,w.byteLength),X}}catch{}_.signal.throwIfAborted();let se=await Fe(w.url,_.signal,!0),z=await Z(se,w.byteLength,_.signal);if(!R(z))throw E("INVALID_RESPONSE","Configuration artifact digest or size mismatch");if(d||N!==h)throw E("CONFIGURATION_DISPOSED","Configuration scope changed");return de(g,z,w.byteLength),i.writeArtifact(g,z),z})(),U=setTimeout(()=>_.abort(E("CONFIGURATION_UNAVAILABLE","Configuration artifact timed out")),B.initializationMs),x=new Promise((se,z)=>_.signal.addEventListener("abort",()=>z(_.signal.reason),{once:!0})),ae=Promise.race([G,x]).finally(()=>{clearTimeout(U),S.delete(_),v.delete(g)});return v.set(g,{promise:ae,byteLength:w.byteLength}),ae}async function we(){return k()||await ie(),J(),p}async function me(w){let g,R=new Promise((C,O)=>{g=setTimeout(()=>O(E("CONFIGURATION_UNAVAILABLE","Configuration initialization timed out")),B.initializationMs)});try{return await Promise.race([w(),R])}finally{clearTimeout(g)}}function pe(w,g){if(J(),p?.generation!==w.generation)throw E("CONFIGURATION_CHANGED","Configuration changed while preparing a snapshot");if(g&&p.funnels[g]?.state!=="active")throw E("FUNNEL_STOPPED","Funnel is paused or unavailable")}async function xe(w){let g=w.gb.features;if(!g)throw E("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");let R=w.artifacts[g];if(R.formatVersion!==1)throw E("UNSUPPORTED_SCHEMA","Unsupported public GB configuration format");let C=je.parse(JSON.parse(await ye(R)));if(L(C.scope)!==L({projectId:n.projectId,environment:n.environment})||C.generation!==R.generation||C.remoteFeatures.some(O=>Object.hasOwn(C.features,O)))throw E("INVALID_RESPONSE","Public GB configuration scope or generation is invalid");return pe(w),{...C,evaluatedAt:new Date().toISOString(),expiresAt:new Date(Date.now()+Math.max(0,a-W())).toISOString()}}async function Le(w,g){let R=await we(),C=R.funnels[w];g&&(!C||C.evaluationMode==="local"&&!C.versions[g])&&(F&&await F,R=await ie()),pe(R,w);let O=R.funnels[w];if(O.evaluationMode!=="local")throw E("EVALUATION_MODE","This Funnel executes at Longplay; public graph loading is disabled");let _=g??O.currentVersionId,N=O.versions[_];if(!N)throw E("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable");if(R.artifacts[N.artifact].formatVersion!==3)throw E("UNSUPPORTED_SCHEMA","Unsupported public Funnel format");let[G,U]=await Promise.all([ye(R.artifacts[N.artifact]).then(x=>$e(JSON.parse(x))),O.evaluationMode==="local"?xe(R):void 0]);if(U&&L(Ye(G,U))!==L(N.dependencies))throw E("INVALID_RESPONSE","Funnel and GB dependency contract do not match");return pe(R,w),{document:G,growth:U,versionId:_,control:structuredClone(O),manifest:structuredClone(R)}}async function Ve(w,g){try{return await Le(w,g)}catch(R){if(!(R instanceof m)||!(R.code==="CONFIGURATION_CHANGED"||R.code==="CONFIGURATION_HTTP_404"&&k()))throw R;let C=p?.generation;if(F&&await F,await ie(),R.code!=="CONFIGURATION_CHANGED"&&p?.generation===C)throw R;return Le(w,g)}}function Ne(){c=!0,M(),ie().catch(H)}let Ie=()=>{(typeof document>"u"||document.visibilityState==="visible")&&Ne()};function Fn(w){if(d)throw E("CONFIGURATION_DISPOSED","Configuration manager was destroyed");return b.add(w),b.size===1&&(typeof window<"u"&&(window.addEventListener("online",Ne),window.addEventListener("focus",Ie),document.addEventListener("visibilitychange",Ie)),Ae()),()=>{b.delete(w),b.size||(clearTimeout(o),clearTimeout(t),Me())}}function Me(){typeof window<"u"&&(window.removeEventListener("online",Ne),window.removeEventListener("focus",Ie),document.removeEventListener("visibilitychange",Ie))}return{scope:Object.freeze({...n}),refresh:ie,subscribe:Fn,assertFresh:J,assertFeatures(w){J();let g=p.gb.features;if(!g)throw E("CONFIGURATION_UNAVAILABLE","Public Feature delivery is disabled");if(w!==void 0&&p.artifacts[g].generation!==w)throw E("CONFIGURATION_CHANGED","Refresh changed Feature configuration before evaluation")},get fresh(){return k()},get snapshot(){return p?structuredClone(p):null},get remainingMs(){return k()?Math.max(0,a-W()):0},async features(){return me(async()=>xe(await we()))},pageExperiments:()=>me(async()=>{let w=await we(),g=w.gb.pageExperiments;if(!g)throw E("CONFIGURATION_UNAVAILABLE","Public page experiments are disabled");let R=w.artifacts[g];if(R.formatVersion!==1)throw E("UNSUPPORTED_SCHEMA","Unsupported page experiment format");let C=an.parse(JSON.parse(await ye(R)));if(C.environmentId!==n.environmentId||C.generation!==R.generation)throw E("INVALID_RESPONSE","Page experiment scope or generation changed");return pe(w),C}),funnel:(w,g)=>me(()=>Ve(w,g)),paywall:(w,g)=>me(async()=>{let R=await we(),C=R.paywalls?.[w];if(!C||!g&&C.state!=="published")throw E("PAYWALL_UNAVAILABLE","Published Paywall is unavailable");let O=g??C.currentVersionId,_=C.versions[O],N=_&&R.artifacts[_.artifact];if(!N||N.kind!=="paywall"||N.formatVersion!==1)throw E("UNSUPPORTED_SCHEMA","Public Paywall format is unavailable");let G=ze.parse(JSON.parse(await ye(N)));return pe(R),{document:G,versionId:O,version:_.version,control:structuredClone(C),manifest:structuredClone(R)}}),async localFunnel(w,g){let R=await me(()=>Ve(w,g));if(!R.growth)throw E("EVALUATION_MODE","This Funnel requires remote execution");let{analyticsConfig:C,remoteFeatures:O,..._}=R.growth;return on({scope:{projectId:n.projectId,environment:n.environment},funnelId:w,versionId:R.versionId,evaluationMode:"local",evaluationRevision:R.control.evaluationRevision,document:R.document,payload:_})},assertFunnel(w,g,R){J();let C=p.funnels[w];if(!C||C.state!=="active")throw E("FUNNEL_STOPPED","Funnel is paused or unavailable");if(C.evaluationMode!=="local")throw E("EVALUATION_MODE","This Funnel now executes at Longplay");if(g!==void 0&&C.controlRevision!==g)throw E("RUN_RECONCILIATION_REQUIRED","Reconcile the original Run after a control change");if(R!==void 0&&!C.versions[R])throw E("CONFIGURATION_UNAVAILABLE","Pinned Funnel Version is unavailable")},destroy(){if(!d){d=!0,h++,a=0,T?.abort(E("CONFIGURATION_DISPOSED","Configuration manager was destroyed")),clearTimeout(o),clearTimeout(t),Me(),M(),b.clear();for(let w of S)w.abort(E("CONFIGURATION_DISPOSED","Configuration manager was destroyed"));P.clear(),D=0}}}}function Sn(e){let n=ue.test(e.apiKey);if(typeof window<"u"&&!n)throw new m("SERVER_ONLY","Funnel starts are issued by your backend");if(!n&&!re.test(e.apiKey))throw new m("INVALID_TOKEN","A customer credential or server API key is required");return{async start(r){let s=Q.safeParse({...r,operation:"start"});if(!s.success||s.data.operation!=="start"||(n?s.data.customer!==void 0:s.data.customer===void 0))throw new m("INVALID_REQUEST","Invalid current Funnel start");let l=s.data,y=Y({...e,timeoutMs:e.timeoutMs??35e3});try{e.session||y.identify(e.apiKey);let f=be(e,await y.request("funnels",l));if(!f.runToken)throw new m("INVALID_RESPONSE","Funnel start credentials are missing");if(f.run.source.id!==l.funnelId||f.run.locale!==(l.locale??"en")||!ce(f.run.parameters,l.parameters??{})||(l.customer?!f.customerId||l.customer.type==="id"&&f.customerId!==l.customer.value:f.customerId!==void 0))throw new m("INVALID_RESPONSE","Funnel start contract changed");return{...f,runToken:f.runToken}}finally{y.dispose()}}}}async function pr(e){e={...e};let n=e.configuration;if(!n)throw new m("CONFIGURATION_UNAVAILABLE","Local conditions require public configuration");let r={projectId:n.scope.projectId,environment:n.scope.environment};if(e.scope&&L(r)!==L(e.scope))throw new m("SCOPE_MISMATCH","Configuration and transport scopes differ");if((await n.funnel(e.funnelId)).control.evaluationMode!=="local")throw new m("EVALUATION_MODE","This Funnel uses Remote evaluation");let l=re.test(e.credential);if(l?!e.customerId:e.customerId!==void 0)throw new m("INVALID_REQUEST","Only Server-Key starts name their Customer");let y=Sn({...e,scope:r,apiKey:e.credential}),f=i=>{let p=Rn({...e,scope:r,runToken:i,...l?{serverKey:e.credential}:{}});return l||p.identify(e.credential),p};return{async start(i){let p=await y.start({...i,funnelId:e.funnelId,...l?{customer:{type:"id",value:e.customerId}}:{}}),a=f(p.runToken),u=await a.get();return{...p,...u,controller:a}},async restore(i){let p=f(i),a=await p.get();if(a.run.source.id!==e.funnelId)throw p.reset(),new m("SCOPE_MISMATCH","Run belongs to another Funnel");return{...a,runToken:i,controller:p}}}}export{Ee as a,Mn as b,be as c,_e as d,Xn as e,Nn as f,gn as g,lt as h,ce as i,yt as j,wt as k,Rn as l,jt as m,nr as n,Sn as o,pr as p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as o}from"./chunk-VSJOHWDL.js";var n=class extends Error{constructor(t,s,y,i,r){super(s);this.code=t;this.status=y;this.requestId=i;this.name="IndianaError",this.reason=r?.reason;let e=o(t,y??0,{...r,retryAfter:r?.retryAfterSeconds===void 0?void 0:String(r.retryAfterSeconds)});this.retryable=e.retryable,this.recovery=e.recovery,this.retryAfterSeconds=e.retryAfterSeconds}code;status;requestId;commandRequestId;retryable;recovery;retryAfterSeconds;reason};export{n as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as t}from"./chunk-JGFAFQKK.js";import{Za as n}from"./chunk-7DUOIHRD.js";function r(e,o,a){return n(e,o,a,t)}export{r as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as u}from"./chunk-DSPLGTQI.js";import{cb as d}from"./chunk-7DUOIHRD.js";function m(e){if(!/^[A-Za-z0-9_-]{1,64}$/.test(e))throw new Error("Invalid device cookie name");let t="";for(let i of document.cookie.split(";"))if(i.trim().startsWith(`${e}=`))try{t=decodeURIComponent(i.trim().slice(e.length+1))}catch{}return/^[A-Za-z0-9_-]{8,128}$/.test(t)||(t=crypto.randomUUID(),document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${400*24*3600}; SameSite=Lax`),t}function y(){try{let e=sessionStorage.getItem("indiana_sid");return e||(e=crypto.randomUUID(),sessionStorage.setItem("indiana_sid",e)),e}catch{return}}function g(e=d){let t=new URL(e);if(t.protocol!=="https:"&&!(t.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(t.hostname))||t.username||t.password||t.search||t.hash)throw new Error("baseUrl must be an https origin without credentials");return t.origin}var o=new Set,s;function S(e){let t=()=>e();if(o.add(t),!s){let i=!0,a=history.pushState,p=history.replaceState,r=()=>{if(i)for(let n of[...o])o.has(n)&&u(n)},c=function(...n){a.apply(this,n),r()},h=function(...n){p.apply(this,n),r()};history.pushState=c,history.replaceState=h,addEventListener("popstate",r),addEventListener("hashchange",r),s=()=>{i=!1,history.pushState===c&&(history.pushState=a),history.replaceState===h&&(history.replaceState=p),removeEventListener("popstate",r),removeEventListener("hashchange",r)}}return()=>{o.delete(t)&&(o.size||(s?.(),s=void 0))}}export{m as a,y as b,g as c,S as d};
|