@tinkerlandai/longplay-sdk 0.10.85 → 0.10.87
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 +9 -0
- package/README.md +2 -1
- package/dist/check-response-XGOTG3KL.js +1 -0
- package/dist/{chunk-5O6YRAHQ.js → chunk-2OBXRQMW.js} +1 -1
- package/dist/{chunk-4SDB3T2F.js → chunk-2OSK33BH.js} +1 -1
- package/dist/{chunk-F54HTDAC.js → chunk-3532HSBP.js} +1 -1
- package/dist/{chunk-52G77TMV.js → chunk-3Z4QDEFB.js} +2 -2
- package/dist/{chunk-ZMDKCBLI.js → chunk-67WFVDTV.js} +1 -1
- package/dist/{chunk-JTCS63ER.js → chunk-6VVQWTHV.js} +1 -1
- package/dist/{chunk-ZAD5WJWS.js → chunk-6XRQR43F.js} +1 -1
- package/dist/{chunk-XMZ2FNYA.js → chunk-7CZEXBQY.js} +1 -1
- package/dist/chunk-7J6YKR2G.js +1 -0
- package/dist/{chunk-E6ND7YQW.js → chunk-7QPCNDIY.js} +1 -1
- package/dist/{chunk-45PGU2HW.js → chunk-7ZAM4YRK.js} +1 -1
- package/dist/{chunk-DJTZR2NR.js → chunk-A5WUQLAO.js} +1 -1
- package/dist/{chunk-U2JO7MX2.js → chunk-BOT6ZDLK.js} +1 -1
- package/dist/{chunk-MDNT2TC3.js → chunk-BT7IC765.js} +1 -1
- package/dist/{chunk-AJHLDSPG.js → chunk-C4KLIT5L.js} +1 -1
- package/dist/{chunk-F53UXSUI.js → chunk-C5HYPVGK.js} +1 -1
- package/dist/{chunk-YEUQXQWK.js → chunk-CHRNCOXJ.js} +1 -1
- package/dist/{chunk-2FDRWKO4.js → chunk-CKMSSBJM.js} +1 -1
- package/dist/{chunk-TORHBU45.js → chunk-CO6HDNOC.js} +1 -1
- package/dist/{chunk-MMAMK7OQ.js → chunk-DUS5V65Z.js} +1 -1
- package/dist/{chunk-WFRZHLIV.js → chunk-EQUVI5QU.js} +1 -1
- package/dist/{chunk-3IDEYQBG.js → chunk-F4AIEI5N.js} +1 -1
- package/dist/{chunk-DT2OMMAT.js → chunk-FPJ3FE26.js} +1 -1
- package/dist/{chunk-VPT5MFDG.js → chunk-FYMVNLQN.js} +2 -2
- package/dist/{chunk-FGAIHKFS.js → chunk-FYUMVOCV.js} +1 -1
- package/dist/chunk-HZP36Y7Y.js +1 -0
- package/dist/{chunk-BQUSJPMG.js → chunk-IVKB6I5Y.js} +1 -1
- package/dist/{chunk-7SQPGOJV.js → chunk-JS4K6SZB.js} +1 -1
- package/dist/{chunk-HSNAFHCP.js → chunk-KCUE2VFJ.js} +1 -1
- package/dist/{chunk-533YCYLO.js → chunk-KNGQEGBC.js} +1 -1
- package/dist/{chunk-MGVWCLVQ.js → chunk-KX67ZM7H.js} +1 -1
- package/dist/{chunk-CQYEM7U6.js → chunk-LFR2LWYC.js} +1 -1
- package/dist/{chunk-7C4OOGQX.js → chunk-LQV7EC5H.js} +1 -1
- package/dist/{chunk-MEBCS2JG.js → chunk-ME6QTD5Y.js} +1 -1
- package/dist/{chunk-MUU6LV3R.js → chunk-MOIVJERE.js} +1 -1
- package/dist/{chunk-LIWSSQAG.js → chunk-OQQXGPUR.js} +1 -1
- package/dist/{chunk-FBHEBXK4.js → chunk-PUDTOCQF.js} +1 -1
- package/dist/chunk-QF6EJUHM.js +1 -0
- package/dist/{chunk-WJDHBJGU.js → chunk-RRNE6CMG.js} +1 -1
- package/dist/{chunk-BZ7HAITJ.js → chunk-S2S4ROGY.js} +1 -1
- package/dist/{chunk-RGXNLSFL.js → chunk-SX7U2ONB.js} +1 -1
- package/dist/{chunk-Y7Z6F6Y3.js → chunk-UCZXFMP4.js} +1 -1
- package/dist/{chunk-AECGOS7O.js → chunk-UGATOG2T.js} +1 -1
- package/dist/{chunk-JUI7TMIM.js → chunk-V6NZ2HM7.js} +1 -1
- package/dist/{chunk-EXHNZVTM.js → chunk-VXNN3RV3.js} +1 -1
- package/dist/{chunk-7ROXL6N2.js → chunk-XLGNBPGF.js} +1 -1
- package/dist/{chunk-OKHCU6ET.js → chunk-Y3W5G4BF.js} +1 -1
- package/dist/{chunk-HMT4SHIK.js → chunk-Y55OBV7D.js} +1 -1
- package/dist/{chunk-4HCUQJOA.js → chunk-Y6KA56V2.js} +1 -1
- package/dist/{chunk-KICIH4PE.js → chunk-ZQXLD2OW.js} +1 -1
- package/dist/{content-KXWLR6IG.js → content-FYROIKHN.js} +1 -1
- package/dist/{funnel-host-purchase-IT23CWX7.js → funnel-host-purchase-2ESNHIY3.js} +1 -1
- package/dist/funnel-host-recovery-paywall-4SU6YXVQ.js +1 -0
- package/dist/{funnel-paywall-copies-LZZILAWG.js → funnel-paywall-copies-LPOTYSTS.js} +1 -1
- package/dist/funnel-paywall-prerender-RV5HA4BG.js +1 -0
- package/dist/funnel-route-prediction-Q4HMRAVQ.js +1 -0
- package/dist/funnel-route-source-HYWJWEM3.js +1 -0
- package/dist/funnel-runtime-host-RDKBIW3H.js +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-OIYML3DE.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-YJM6772C.js +1 -0
- package/dist/page.js +1 -1
- package/dist/paywall-TMWAGLJC.js +1 -0
- package/dist/paywall-content-LX3QA6EA.js +1 -0
- package/dist/paywall-session-2FKLMAZX.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-HJOKBOZH.js +1 -0
- package/dist/server.js +1 -1
- package/dist/{visual-dom-5LUN4AHO.js → visual-dom-KUABNJV6.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/check-response-SOTWWQ3J.js +0 -1
- package/dist/chunk-JJEOS374.js +0 -1
- package/dist/chunk-OT6DGH5B.js +0 -1
- package/dist/chunk-YQ2TU6TG.js +0 -1
- package/dist/funnel-host-recovery-paywall-QGH574CM.js +0 -1
- package/dist/funnel-paywall-prerender-BKPL2SLY.js +0 -1
- package/dist/funnel-route-prediction-7B5FGESC.js +0 -1
- package/dist/funnel-route-source-F5OML4HC.js +0 -1
- package/dist/funnel-runtime-host-7UOEQRZV.js +0 -1
- package/dist/merchant-bridge-contracts-47PO4USZ.js +0 -1
- package/dist/operation-contracts-EDUVKUPX.js +0 -1
- package/dist/paywall-GUW4NI2B.js +0 -1
- package/dist/paywall-content-HMUHTWWL.js +0 -1
- package/dist/paywall-session-NJHRHCKM.js +0 -1
- package/dist/screen-renderer-XJDNUC7B.js +0 -1
- /package/dist/{chunk-52G77TMV.js.LEGAL.txt → chunk-3Z4QDEFB.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-CILM5XMH.js → chunk-FRK6322O.js} +0 -0
- /package/dist/{chunk-VPT5MFDG.js.LEGAL.txt → chunk-FYMVNLQN.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-OJM6ORHE.js → chunk-KV5MZ4NI.js} +0 -0
- /package/dist/{chunk-ZL247MPX.js → chunk-W22ESUYY.js} +0 -0
package/dist/openrouter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-Y6KA56V2.js";import"./chunk-SX7U2ONB.js";import"./chunk-KNGQEGBC.js";import"./chunk-KCUE2VFJ.js";import{a as i}from"./chunk-UGATOG2T.js";import"./chunk-LFR2LWYC.js";import"./chunk-RRNE6CMG.js";import"./chunk-5MRSFLQA.js";import{b as A}from"./chunk-W22ESUYY.js";import"./chunk-WOT6VMZA.js";var c=A.number().int().min(0).max(1e9);function R(e,o){let a=c.parse(e.promptTokens),p=c.parse(e.completionTokens),s=c.parse(e.promptTokensDetails?.cachedTokens??0),t=c.parse(e.promptTokensDetails?.cacheWriteTokens??0),r=c.parse(e.promptTokensDetails?.audioTokens??0),l=c.parse(e.completionTokensDetails?.audioTokens??0),n=c.parse(e.completionTokensDetails?.reasoningTokens??0);if(c.parse(e.totalTokens)!==a+p||s+t+r>a||n+l>p||(e.promptTokensDetails?.videoTokens??0)>0)throw new i("AI_USAGE_UNAVAILABLE","Token pools must conserve usage; video needs an explicit token mapper");return{input:a-s-t-r,output:p-l-(o==="separate"?n:0),cache_read:s,cache_write:t,input_audio:r,output_audio:l,reasoning:o==="separate"?n:0}}function I(e){if(!Number.isFinite(e)||e<0)throw new i("AI_USAGE_UNAVAILABLE","Provider cost must be a nonnegative USD amount");let o=String(e),a=o.includes("e")?e.toFixed(18).replace(/0+$/,"").replace(/\.$/,""):o;if(!/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/.test(a)||Number(a)!==e)throw new i("AI_USAGE_UNAVAILABLE","Provider cost exceeds the supported precision");return a}async function f(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning)||!e.modelId||!e.generationId)throw new i("INVALID_REQUEST","Actual model, generation ID and reasoning pricing are required");let o={context:e.context,generationId:e.generationId,modelId:`openrouter/${e.modelId}`,usage:e.usage,tokens:null,quote:null,receipt:null,phase:"captured"};await e.persist(o);let a=e.mapTokens?e.mapTokens(e.usage):R(e.usage,e.reasoning),p=e.usage.cost==null?void 0:I(e.usage.cost),s=e.quote??await e.pricing.quoteTokens({modelId:o.modelId,tokens:a});if(s.pricing.modelId!==o.modelId||Object.keys(a).some(l=>a[l]!==s.tokens[l]))throw new i("INVALID_REQUEST","Saved quote must match the provider model and token pools");await e.persist({...o,tokens:a,quote:s,phase:"quoted"});let t=await e.pricing.trackTokens(e.client,{...e.context,quote:s,providerCostUsd:p,generationId:e.generationId});if(!t.receipt.accepted)throw new i("AI_BALANCE_REJECTED","OpenRouter usage was saved but the balance request was rejected");let r={...o,tokens:a,quote:s,receipt:t,phase:"settled"};return await e.persist(r),r}function T(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning))throw new i("INVALID_REQUEST","Reasoning pricing is required");let o=e.openRouter.chat;async function a(t){if(!t.usage||!t.modelId||!t.generationId)throw new i("AI_USAGE_UNAVAILABLE","OpenRouter did not return final usage and the actual model");await f({...e,context:t.context,generationId:t.generationId,modelId:t.modelId.slice(11),usage:t.usage})}let p=async(t,r)=>{let n={context:await e.context(),generationId:null,modelId:null,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"},d;try{d=await o.send(t,r)}catch(g){throw await e.persist(n),g}if(!(d instanceof ReadableStream)){if(n={...n,generationId:d.id,modelId:d.model?`openrouter/${d.model}`:null,usage:d.usage??null},!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter omitted final accounting");return await a(n),d}let w=d.getReader(),m=!1;return new ReadableStream({async pull(g){try{let{value:u,done:k}=await w.read();if(k){if(m=!0,!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter stream ended without final accounting");await a(n),g.close();return}if(u.error)throw new i("AI_PROVIDER_ERROR",u.error.message);u.usage&&(n={...n,generationId:u.id,modelId:u.model?`openrouter/${u.model}`:null,usage:u.usage}),g.enqueue(u)}catch(u){m||(m=!0,await e.persist(n)),await w.cancel(u),g.error(u)}},async cancel(g){m||(m=!0,await e.persist(n)),await w.cancel(g)}})},s=new Proxy(o,{get(t,r){return r==="send"?p:Reflect.get(t,r,t)}});return new Proxy(e.openRouter,{get(t,r){return r==="chat"?s:Reflect.get(t,r,t)}})}export{T as createOpenRouterUsageClient,f as trackOpenRouterUsage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as o}from"./chunk-CKMSSBJM.js";import"./chunk-FPJ3FE26.js";import"./chunk-2OBXRQMW.js";import"./chunk-7QPCNDIY.js";import"./chunk-BT7IC765.js";import"./chunk-ME6QTD5Y.js";import"./chunk-6XRQR43F.js";import"./chunk-3532HSBP.js";import"./chunk-67WFVDTV.js";import"./chunk-6VVQWTHV.js";import"./chunk-VILB5M4X.js";import"./chunk-SX7U2ONB.js";import"./chunk-KCUE2VFJ.js";import"./chunk-Y3W5G4BF.js";import"./chunk-FYUMVOCV.js";import"./chunk-DUS5V65Z.js";import"./chunk-BOT6ZDLK.js";import"./chunk-A5WUQLAO.js";import"./chunk-LFR2LWYC.js";import"./chunk-W22ESUYY.js";import"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
|
package/dist/page.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as o,e as r,f as e,g as f}from"./chunk-
|
|
1
|
+
import{d as o,e as r,f as e,g as f}from"./chunk-3Z4QDEFB.js";import"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-RRNE6CMG.js";import"./chunk-5MRSFLQA.js";import"./chunk-DSPLGTQI.js";import"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-JS4K6SZB.js";import"./chunk-CHRNCOXJ.js";import"./chunk-W32FI2A2.js";import"./chunk-CO6HDNOC.js";import"./chunk-Y55OBV7D.js";import"./chunk-MOIVJERE.js";import"./chunk-6XRQR43F.js";import"./chunk-3532HSBP.js";import"./chunk-67WFVDTV.js";import"./chunk-VILB5M4X.js";import"./chunk-KNGQEGBC.js";import"./chunk-KCUE2VFJ.js";import"./chunk-Y3W5G4BF.js";import"./chunk-FYUMVOCV.js";import"./chunk-DUS5V65Z.js";import"./chunk-BOT6ZDLK.js";import"./chunk-A5WUQLAO.js";import"./chunk-UGATOG2T.js";import"./chunk-LFR2LWYC.js";import"./chunk-RRNE6CMG.js";import"./chunk-5MRSFLQA.js";import"./chunk-W22ESUYY.js";import"./chunk-DSPLGTQI.js";import"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";export{a as showPaywall};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as a}from"./chunk-UCZXFMP4.js";import"./chunk-7QPCNDIY.js";import"./chunk-BT7IC765.js";import"./chunk-ME6QTD5Y.js";import"./chunk-6XRQR43F.js";import"./chunk-3532HSBP.js";import"./chunk-67WFVDTV.js";import"./chunk-6VVQWTHV.js";import"./chunk-VILB5M4X.js";import"./chunk-KNGQEGBC.js";import"./chunk-KCUE2VFJ.js";import"./chunk-Y3W5G4BF.js";import"./chunk-FYUMVOCV.js";import"./chunk-DUS5V65Z.js";import"./chunk-BOT6ZDLK.js";import"./chunk-A5WUQLAO.js";import"./chunk-UGATOG2T.js";import"./chunk-LFR2LWYC.js";import"./chunk-3VUPVXAV.js";import"./chunk-RRNE6CMG.js";import"./chunk-5MRSFLQA.js";import"./chunk-W22ESUYY.js";import"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-ZQXLD2OW.js";import"./chunk-CKMSSBJM.js";import"./chunk-FPJ3FE26.js";import"./chunk-S2S4ROGY.js";import"./chunk-Y55OBV7D.js";import"./chunk-MOIVJERE.js";import"./chunk-2OBXRQMW.js";import"./chunk-PUDTOCQF.js";import"./chunk-UCZXFMP4.js";import"./chunk-7QPCNDIY.js";import"./chunk-BT7IC765.js";import"./chunk-ME6QTD5Y.js";import"./chunk-6XRQR43F.js";import"./chunk-3532HSBP.js";import"./chunk-67WFVDTV.js";import"./chunk-6VVQWTHV.js";import"./chunk-VILB5M4X.js";import"./chunk-SX7U2ONB.js";import"./chunk-KNGQEGBC.js";import"./chunk-KCUE2VFJ.js";import"./chunk-Y3W5G4BF.js";import"./chunk-FYUMVOCV.js";import"./chunk-DUS5V65Z.js";import"./chunk-BOT6ZDLK.js";import"./chunk-A5WUQLAO.js";import"./chunk-UGATOG2T.js";import"./chunk-LFR2LWYC.js";import"./chunk-3VUPVXAV.js";import"./chunk-RRNE6CMG.js";import"./chunk-5MRSFLQA.js";import"./chunk-W22ESUYY.js";import"./chunk-DSPLGTQI.js";import"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
|
package/dist/popup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as _,b as z,c as M,d as U,e as W,f as q,g as V,h as j,i as S}from"./chunk-
|
|
1
|
+
import{a as _,b as z,c as M,d as U,e as W,f as q,g as V,h as j,i as S}from"./chunk-LQV7EC5H.js";import{a as H,b as x,d as y,f as C,g as A,m as E}from"./chunk-CO6HDNOC.js";import"./chunk-Y3W5G4BF.js";import{D as b}from"./chunk-FYUMVOCV.js";import"./chunk-DUS5V65Z.js";import"./chunk-BOT6ZDLK.js";import"./chunk-A5WUQLAO.js";import"./chunk-UGATOG2T.js";import"./chunk-LFR2LWYC.js";import"./chunk-W22ESUYY.js";import{a as p}from"./chunk-DSPLGTQI.js";import"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";function O(m,r,n){let d=m.ownerDocument,s=d.defaultView;if(!s)throw new Error("Preview container has no browser window");let l=!1,u=!1,f=0,c,i=d.createElement("div");i.style.cssText="width:100%;min-width:0";let v=(e,F)=>{c=S(e,{mode:"live",rendererUrl:n.rendererUrl,title:n.title??r.name,onPageChange:n.onPageChange,onAction:(R,I)=>p(n.onAction,R,I),onError:n.onError,...F}),c.update(r,n.locale,{capabilities:n.capabilities,customerData:n.customerData})},h=r.presentation;if(h.type==="inline")return m.append(i),v(i,{onContentHeight(e){f=e,p(n.onContentHeight,e,m.clientHeight)}}),{presentation:"inline",inspect:()=>c?.inspect?.()??Promise.resolve(null),destroy(){l||(l=!0,c?.destroy(),i.remove())}};let t=d.createElement("dialog");t.lang=n.locale,t.dir=b(n.locale)?"rtl":"ltr",t.setAttribute("aria-label",r.name),t.style.cssText=H(n.host,h,r.theme);let a=d.createElement("button");a.type="button",a.textContent="×",a.setAttribute("aria-label",n.closeLabel),A(a,r.theme);let g=e=>{u&&!l&&p(n.onDismiss,e)};a.addEventListener("click",()=>g("close_button"));let D=()=>c?.resizeViewport(s.innerHeight||800,s.innerWidth||1024),o;if(n.host==="funnel"){let e=d.createElement("section");e.style.cssText="min-width:0;display:flex;flex-direction:column;min-height:100%",i.style.cssText+=";flex:1 0 auto;display:flex;flex-direction:column;justify-content:center",e.append(i),t.append(a,e),o=y(t,r,D)}else i.setAttribute("aria-label",r.name),o=y(t,r,D),t.append(i),t.prepend(a);let L=n.host==="content"&&o.responsive?x(t,()=>g("close_button"),()=>!0,n.closeLabel):void 0;t.addEventListener("cancel",e=>{e.preventDefault(),g("escape")});let w=e=>s.requestAnimationFrame?s.requestAnimationFrame(e):s.setTimeout(e,0),P=()=>{u&&!l&&p(n.onContentHeight,f,t.clientHeight)},T=E(t);return m.append(t),v(i,{viewportHeight:o.responsive?s.innerHeight||800:void 0,...o.responsive?{viewportWidth:s.innerWidth||1024,hostPresentation:()=>o.type}:{},...n.host!=="content"?{closeActions:n.closeActions??r.actions.filter(e=>e.close).map(e=>e.id),onAuthoredClose(e){a.hidden=e}}:{},onResize(e){o.responsive&&(i.style.height=`${e}px`,i.style.overflow="clip",o.setContentHeight(e)),w(P)},onContentHeight(e){f=e},onRendered(e){e&&t.setAttribute("aria-label",e),!(u||l)&&(u=!0,T(),o.latch(),t.showModal(),o.responsive&&t.focus({preventScroll:!0}),C(t,o.type,o.responsive),w(P))},onEscape:()=>g("escape")}),{get presentation(){return o.type},inspect:()=>c?.inspect?.()??Promise.resolve(null),destroy(){l||(l=!0,c?.destroy(),L?.(),o.destroy(),t.open&&t.close(),t.remove())}}}export{q as formatCustomerDecimal,z as hostedRendererScript,_ as hostedRendererShell,U as inspectCustomHtml,O as mountDialogPreview,S as mountScreenPreview,j as preparePopup,W as prepareScreen,M as sanitizeCustomHtml,V as showPopup};
|
package/dist/react-native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as S,c as E,d as T}from"./chunk-
|
|
1
|
+
import{b as S,c as E,d as T}from"./chunk-IVKB6I5Y.js";import"./chunk-XLGNBPGF.js";import{a as A}from"./chunk-ZQXLD2OW.js";import{e as P}from"./chunk-CKMSSBJM.js";import"./chunk-FPJ3FE26.js";import{h as b,i as x,k as L}from"./chunk-C5HYPVGK.js";import{E as C}from"./chunk-2OSK33BH.js";import"./chunk-F4AIEI5N.js";import"./chunk-S2S4ROGY.js";import"./chunk-Y55OBV7D.js";import"./chunk-MOIVJERE.js";import"./chunk-2OBXRQMW.js";import"./chunk-PUDTOCQF.js";import"./chunk-UCZXFMP4.js";import"./chunk-7QPCNDIY.js";import"./chunk-BT7IC765.js";import"./chunk-ME6QTD5Y.js";import"./chunk-6XRQR43F.js";import"./chunk-3532HSBP.js";import"./chunk-67WFVDTV.js";import"./chunk-KX67ZM7H.js";import"./chunk-6VVQWTHV.js";import"./chunk-VILB5M4X.js";import"./chunk-SX7U2ONB.js";import"./chunk-KNGQEGBC.js";import"./chunk-KCUE2VFJ.js";import"./chunk-Y3W5G4BF.js";import"./chunk-FYUMVOCV.js";import"./chunk-DUS5V65Z.js";import"./chunk-BOT6ZDLK.js";import"./chunk-A5WUQLAO.js";import{a as r}from"./chunk-UGATOG2T.js";import{h as R}from"./chunk-LFR2LWYC.js";import"./chunk-3VUPVXAV.js";import"./chunk-RRNE6CMG.js";import"./chunk-5MRSFLQA.js";import"./chunk-W22ESUYY.js";import"./chunk-DSPLGTQI.js";import"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";function k(t,d){let n,a=0,m=-1,l,i=!1,y=()=>{if(i)throw new r("CLOSED","Native host was destroyed");if(!t.nativeModule)throw new r("CAPABILITY_UNAVAILABLE","Link IndianaBridge and supply nativeModule");return t.nativeModule},o=()=>new r("IDENTITY_CHANGED","Customer identity changed during the native operation"),h=d.subscribeIdentity(()=>{a++,m=-1;let e=a;n&&t.nativeModule&&n.then(c=>t.nativeModule.reset(c,e)).catch(()=>{})}),I=t.nativeEvents?.(e=>{!n||!t.nativeModule||typeof e?.requestId!="string"||(async()=>{let c=await n;if(e.instanceId!==c)return;if(e.kind==="credential"){let w=a,f=null;try{if(!i&&e.revision===w){let N=await d.access();!i&&a===w&&(f=N)}}finally{await t.nativeModule.provideCredential(c,e.requestId,f)}return}let s=!1,u=a;try{if(i||e.revision!==u||!t.onNativeAction)throw o();await t.onNativeAction(e.action),s=!i&&a===u}finally{await t.nativeModule.acknowledge(c,e.requestId,s)}})().catch(()=>{})});async function p(e,c={}){let s=y();if(d.snapshot()&&!t.nativeEvents)throw new r("CAPABILITY_UNAVAILABLE","Supply nativeEvents to share credential refresh with the native host");let u=a,w=await d.access();if(i||a!==u)throw o();if(!n){let v=s.create(JSON.stringify({baseUrl:t.baseUrl??"https://api.longplayai.com",scope:t.scope,timeout:(t.timeoutMs??15e3)/1e3,credentialEvents:!!t.nativeEvents}));n=v,v.catch(()=>{n===v&&(n=void 0)})}let f=await n;if(i||a!==u)throw o();if(m!==u){if(!l||l.epoch!==u){let O=(async()=>{if(await s.identify(f,JSON.stringify({revision:u,credentials:w})),i||a!==u)throw await s.reset(f,u),o();m=u})();l={epoch:u,task:O}}let v=l;try{await v.task}finally{l===v&&(l=void 0)}}let N=await s.invoke(f,e,JSON.stringify(c));if(i||a!==u)throw o();try{return JSON.parse(N)}catch{throw new r("INVALID_RESPONSE","Native host returned invalid JSON")}}async function g(e,c){let s=await p(e,c);if(!s||typeof s!="object"||Array.isArray(s)||s.status!=="complete"&&s.status!=="dismissed")throw new r("INVALID_RESPONSE","Native presentation returned an invalid result");return s}return{showFunnel(e){return g("showFunnel",{runToken:e})},showPaywall(e){return g("showPaywall",e)},showContent(e){return g("showContent",e)},purchaseSubscription(e,c){return p("purchaseSubscription",{operationId:e,accepted:c})},switchSubscription(e,c){return p("switchSubscription",{operationId:e,accepted:c})},restorePurchases(){return p("restorePurchases")},manageSubscriptions(e){return p("manageSubscriptions",e?{productId:e}:{})},async dismiss(){a++,m=-1,n&&await y().reset(await n,a)},async destroy(){i||(i=!0,a++,h(),I?.(),n&&t.nativeModule&&await t.nativeModule.destroy(await n))}}}var M=P.trackUsage.request.shape.command,U=P.trackUsage.response;function F(t){let d=R.parse(t.scope),n=S({...t,scope:d}),a={...t,scope:d,session:n.session},m=k(t,n.session),l=0,i=!1;n.subscribeIdentity(()=>{l++});let y=()=>{if(i)throw new r("CLOSED","SDK client was destroyed");let o=n.session.peek();if(!o)throw new r("UNAUTHENTICATED","Identify the Customer first");return o};return{...n,native:m,async destroy(){i||(i=!0,l++,n.destroy(),await m.destroy())},funnel(){return E({...a,customerToken:y()})},resumeFunnel(o){return y(),C({...a,runToken:o})},paywall(o){return A(a,{...o,customerToken:y()})},async trackUsage(o){if(y(),!t.usageReporter)throw new r("INVALID_REQUEST","Configure your authenticated backend usageReporter");let h=M.parse(o),I=l,p;try{p=await t.usageReporter(h)}catch(e){throw I!==l?new r("IDENTITY_CHANGED","Customer identity changed during usage reporting"):e}if(I!==l)throw new r("IDENTITY_CHANGED","Customer identity changed during usage reporting");let g=U.parse(p);if(g.scope.projectId!==d.projectId||g.scope.environment!==d.environment)throw new r("INVALID_RESPONSE","Usage response scope differs");return g}}}export{r as LongplayError,x as createConfigurationSync,b as createFeatureClient,T as createFunnelProcess,L as createLocalFunnelClient,F as createLongplayReactNative};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i}from"./chunk-LQV7EC5H.js";import"./chunk-CO6HDNOC.js";import"./chunk-Y3W5G4BF.js";import"./chunk-FYUMVOCV.js";import"./chunk-DUS5V65Z.js";import"./chunk-BOT6ZDLK.js";import"./chunk-A5WUQLAO.js";import"./chunk-UGATOG2T.js";import"./chunk-LFR2LWYC.js";import"./chunk-W22ESUYY.js";import"./chunk-DSPLGTQI.js";import"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";export{f as formatCustomerDecimal,b as hostedRendererScript,a as hostedRendererShell,d as inspectCustomHtml,i as mountScreenPreview,h as preparePopup,e as prepareScreen,c as sanitizeCustomHtml,g as showPopup};
|
package/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as pn}from"./chunk-
|
|
1
|
+
import{a as pn}from"./chunk-HZP36Y7Y.js";import{a as I}from"./chunk-EQUVI5QU.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-Y6KA56V2.js";import{a as xt}from"./chunk-ZQXLD2OW.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-CKMSSBJM.js";import"./chunk-FPJ3FE26.js";import{a as Te,b as ae,c as yt,d as It,e as wt,f as xe,g as vt,h as Me,i as dn,j as ln,k as mn}from"./chunk-C5HYPVGK.js";import{B as V,C as N,d as ft,e as ht,k as gt,l as z,m as St,p as Ct,q as Rt,r as bt,s as At,t as Ot,y as pe,z as Tt}from"./chunk-2OSK33BH.js";import"./chunk-F4AIEI5N.js";import{c as h}from"./chunk-S2S4ROGY.js";import"./chunk-Y55OBV7D.js";import"./chunk-MOIVJERE.js";import"./chunk-2OBXRQMW.js";import{a as Et,b as _e}from"./chunk-PUDTOCQF.js";import"./chunk-UCZXFMP4.js";import"./chunk-7QPCNDIY.js";import{e as at}from"./chunk-BT7IC765.js";import{B as pt,C as de,D as Z,E as lt,J as mt,a as et,e as q,j as Re,k as st,l as ct,q as ut,r as dt,s as be,t as Ae}from"./chunk-ME6QTD5Y.js";import"./chunk-6XRQR43F.js";import"./chunk-3532HSBP.js";import{A as W,B as oe,C as tt,D as Se,E as ie,G as se,H as Ce,M as j,O as ce,P as nt,R as Ee,S as rt,T as ot,f as Ge,g as je,j as we,r as ze,s as Ke,u as an,v as sn,y as cn,z as X}from"./chunk-67WFVDTV.js";import{b as Oe}from"./chunk-KX67ZM7H.js";import{e as ve,i as Ze,l as it}from"./chunk-6VVQWTHV.js";import"./chunk-VILB5M4X.js";import"./chunk-SX7U2ONB.js";import"./chunk-KNGQEGBC.js";import{a as Ne,b as Le}from"./chunk-KCUE2VFJ.js";import{o as ue}from"./chunk-Y3W5G4BF.js";import"./chunk-FYUMVOCV.js";import{i as un,k as $e,l as Qe,m as Je}from"./chunk-DUS5V65Z.js";import{c as Ie}from"./chunk-BOT6ZDLK.js";import{e as Xe,h as We}from"./chunk-A5WUQLAO.js";import{a as c}from"./chunk-UGATOG2T.js";import{h as Y}from"./chunk-LFR2LWYC.js";import"./chunk-3VUPVXAV.js";import"./chunk-RRNE6CMG.js";import"./chunk-5MRSFLQA.js";import{b as u}from"./chunk-W22ESUYY.js";import"./chunk-DSPLGTQI.js";import{a as Ye}from"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";var _t=4,Mt=[...tt,"requirement_checks","native_offers","preparations","benefit_claims","authorizations","business_results","checkout_termination"],In=u.enum(Mt),ee=(e,n)=>u.array(e).max(n).refine(t=>new Set(t).size===t.length,"Declarations must be unique"),ke=u.strictObject({...se.shape,bridgeVersion:u.literal(_t),capabilities:ee(In,Mt.length),checkKinds:ee(u.enum(["access","metered","credit"]),3),preparationActions:ee(u.enum(["purchase","subscription_change","refund"]),3),authorizationKinds:ee(u.enum(["auto_topup"]),1),nextActionTypes:ee(u.enum(["redirect","authenticate"]),2),resultEvents:ee(u.enum(["benefit.claimed","authorization.updated"]),2)}).superRefine((e,n)=>{e.capabilities.includes("catalog")!==(e.catalog!=="none")&&n.addIssue({code:"custom",path:["catalog"],message:"Catalog declaration differs from its capability"}),(e.capabilities.includes("billing_records")!==e.billingEvents.length>0||new Set(e.billingEvents).size!==e.billingEvents.length)&&n.addIssue({code:"custom",path:["billingEvents"],message:"Declare unique supported billing events"});let t=r=>e.capabilities.includes(r),o=(r,a)=>n.addIssue({code:"custom",path:[r],message:a});t("requirement_checks")!==e.checkKinds.length>0&&o("checkKinds","Declare the supported Check kinds"),t("preparations")!==e.preparationActions.length>0&&o("preparationActions","Declare the supported preparation actions"),t("authorizations")!==e.authorizationKinds.length>0&&o("authorizationKinds","Declare the supported authorization kinds"),t("business_results")!==e.resultEvents.length>0&&o("resultEvents","Declare the supported non-financial results");for(let[r,a,s]of[["purchases","purchase","purchase.completed"],["subscription_changes","subscription_change","subscription.change.completed"],["refunds","refund","refund.updated"]])t(r)&&(!t("operation_status")||!t("billing_records")||!t("preparations")||!e.preparationActions.includes(a)||!e.billingEvents.includes(s))&&o("capabilities",`${r} requires preparation, original lookup and its billing result`);t("purchases")&&!e.billingEvents.includes("purchase.closed")&&o("billingEvents","Purchase execution requires its terminal closure result"),t("checkout_termination")&&(!t("operation_status")||!t("billing_records")||!e.billingEvents.includes("purchase.closed"))&&o("capabilities","Checkout termination requires original lookup and purchase.closed"),t("subscription_changes")&&!e.billingEvents.includes("subscription.change.closed")&&o("billingEvents","Subscription change execution requires its terminal closure result");for(let[r,a]of[["benefit_claims","benefit.claimed"],["authorizations","authorization.updated"]])t(r)&&(!t("operation_status")||!t("business_results")||!e.resultEvents.includes(a))&&o("capabilities",`${r} requires original lookup and its non-financial result`)}),K={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":u.strictObject({}),"requirement.check":$e,"operation.prepare":ze,"benefit.claim":Ue,"operation.read":qe,"purchase.terminate":j},wn={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":ke,"requirement.check":Qe,"operation.prepare":Ke,"benefit.claim":Ve,"operation.read":He,"purchase.terminate":j.extend({outcome:u.enum(["requested","already_paid"])})},Gn=u.enum(["bridge.ping","bridge.describe","requirement.check","operation.prepare","benefit.claim","operation.read","purchase.terminate"]);function $(e,n){return u.strictObject({bridgeVersion:u.literal(_t),requestId:u.uuid(),scope:Ce,command:u.literal(e),data:n})}var kt=u.discriminatedUnion("command",[$("bridge.ping",K["bridge.ping"]),$("bridge.describe",K["bridge.describe"]),$("requirement.check",K["requirement.check"]),$("operation.prepare",K["operation.prepare"]),$("benefit.claim",K["benefit.claim"]),$("operation.read",K["operation.read"]),$("purchase.terminate",K["purchase.terminate"])]),Be=u.strictObject({code:u.string().regex(/^MERCHANT_BRIDGE_[A-Z_]+$/),message:u.string().min(1).max(500),retryable:u.boolean(),recovery:u.string().min(1).max(80),effect:u.enum(["none","unknown"])}).refine(e=>e.effect!=="unknown"||!e.retryable&&e.recovery==="recover_operation","Unknown effects require original-operation recovery");function Bt(e){let n={bridgeVersion:u.literal(4),requestId:u.uuid(),scope:Ce,command:u.literal(e)};return u.union([u.strictObject({...n,data:wn[e]}),u.strictObject({...n,error:Be})])}var Pt="X-Indiana-Bridge-Signature",Q="X-Indiana-Bridge-Key-Id";function vn(e){return new TextEncoder().encode(e)}function Dt(e){return Uint8Array.from(atob(e.replaceAll("-","+").replaceAll("_","/")),n=>n.charCodeAt(0))}function Ft(e,n,t,o){return vn(`indiana-merchant-bridge:${o}
|
|
2
2
|
${n}
|
|
3
3
|
POST
|
|
4
4
|
${W}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a,c as b}from"./chunk-
|
|
1
|
+
import{b as a,c as b}from"./chunk-KV5MZ4NI.js";import"./chunk-J6KIN4RH.js";import"./chunk-WOT6VMZA.js";export{b as applyVisualVariation,a as safeVisualMutation};
|
package/dist/visual.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as pe,c as fe}from"./chunk-
|
|
1
|
+
import{a as pe,c as fe}from"./chunk-KV5MZ4NI.js";import{b as le}from"./chunk-J6KIN4RH.js";import{a as Ve,b as ce,c as de,d as ue}from"./chunk-SLUA7ABW.js";import{a as J,b as F,c as ge,e as me}from"./chunk-3Z4QDEFB.js";import{a as re,b as ae,c as se,d as oe}from"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-RRNE6CMG.js";import"./chunk-5MRSFLQA.js";import{b as o}from"./chunk-W22ESUYY.js";import"./chunk-DSPLGTQI.js";import{c as te,e as ie,g as M}from"./chunk-FYMVNLQN.js";import"./chunk-FRK6322O.js";import"./chunk-WOT6VMZA.js";var K="indiana-visual-diagnostics-v1",Ae=o.strictObject({environmentId:o.string().uuid(),release:o.string().regex(/^[a-f0-9]{64}$/).nullable(),generation:o.string().regex(/^[a-f0-9]{64}$/).nullable(),publishedGeneration:o.string().regex(/^[a-f0-9]{64}$/).nullable(),checkedAt:o.string().datetime(),origin:o.string().url(),pathname:o.string().max(2048),urlMatches:o.boolean(),stopped:o.boolean(),rows:o.array(o.strictObject({changeId:o.string().regex(/^[a-f0-9]{64}$/),experimentKey:o.string().max(256),variationKey:o.string().max(256),inExperiment:o.boolean(),fingerprint:o.string().regex(/^[a-f0-9]{64}$/),status:o.enum(["inactive","waiting","partial","applied","mismatch","no_changes","unavailable","error"]),total:o.number().int().min(0).max(600),applied:o.number().int().min(0).max(600)})).max(100)});function ye(e){let l=n=>Array.isArray(n)?"["+n.map(l).join(",")+"]":n&&typeof n=="object"?"{"+Object.entries(n).filter(([,c])=>c!==void 0).sort(([c],[y])=>c.localeCompare(y)).map(([c,y])=>JSON.stringify(c)+":"+l(y)).join(",")+"}":JSON.stringify(n);return l({css:e.css,js:e.js,domMutations:e.domMutations,...e.renderGuard?{renderGuard:e.renderGuard}:{}})}function he(e){let l=new URL(e.baseUrl),n=l.origin==="https://api.longplayai.com"||l.origin==="https://api.dev.longplayai.com"?l.hostname.slice(4):void 0,c=e.origins??(n?[`https://console.${n}`]:[]),y=new Set(c.filter(t=>{try{let i=new URL(t);return i.origin===t&&(i.protocol==="https:"||i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))}catch{return!1}})),v=!1,I=!1,k=0,T=async t=>{if(v||I||!t.source||!y.has(t.origin)||!t.data||typeof t.data!="object")return;let i=t.data;if(!(i.channel!==K||i.type!=="inspect"||i.environmentId!==e.environmentId||typeof i.nonce!="string"||!/^[a-f0-9-]{36}$/i.test(i.nonce)||typeof i.changeId!="string"||!/^[a-f0-9]{64}$/.test(i.changeId)||typeof i.url!="string"||i.url.length>2048||Date.now()-k<250)){try{if(new URL(i.url).origin!==location.origin)return}catch{return}I=!0,k=Date.now();try{let x=await e.inspect(i.changeId,i.url);!v&&x.rows.some(S=>S.changeId===i.changeId)&&t.source.postMessage({channel:K,type:"result",nonce:i.nonce,snapshot:x},t.origin)}finally{I=!1}}},u=t=>{T(t).catch(()=>{})};return window.addEventListener("message",u),()=>{v=!0,window.removeEventListener("message",u)}}var R=e=>!!e&&typeof e=="object"&&!Array.isArray(e),E=(e,l)=>typeof e=="string"&&e.length<=l,Ee=e=>typeof e=="string"&&(["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(e)||/^(aria|data)-[a-z0-9_-]+$/.test(e));function ke(e){if(!R(e)||!E(e.css??"",1e5)||!E(e.js??"",1e5)||!Array.isArray(e.domMutations??[])||Array.isArray(e.domMutations)&&e.domMutations.length>200)throw new Error("Invalid visual variation");let l=e.domMutations??[];for(let n of l)if(!R(n)||!E(n.selector,2048)||!n.selector||!Ee(n.attribute)||!["set","append","remove"].includes(String(n.action))||n.value!==void 0&&!E(n.value,5e4)||n.parentSelector!==void 0&&!E(n.parentSelector,2048)||n.insertBeforeSelector!==void 0&&!E(n.insertBeforeSelector,2048))throw new Error("Invalid visual mutation");return{css:e.css??"",js:e.js??"",domMutations:l,...e.renderGuard===void 0?{}:{renderGuard:le(e.renderGuard)}}}function q(e){if(!R(e)||typeof e.environmentId!="string"||typeof e.trackExposures!="boolean"||!/^[-a-f0-9]{36}$/i.test(e.environmentId)||typeof e.generation!="string"||!/^[a-f0-9]{64}$/.test(e.generation)||!Array.isArray(e.experiments)||e.experiments.length>100||!R(e.savedGroups))throw new Error("Invalid visual experiment payload");let l=e.experiments.map(n=>{if(!R(n)||!["key","changeId"].every(c=>typeof n[c]=="string"&&n[c])||!/^[a-f0-9]{64}$/.test(String(n.changeId))||["namespace","status","groups","url"].some(c=>Object.hasOwn(n,c))||n.hashVersion!==void 0&&n.hashVersion!==2||!Array.isArray(n.variations)||n.variations.length<2||n.variations.length>20||n.urlPatterns!==void 0&&!Array.isArray(n.urlPatterns))throw new Error("Invalid visual experiment");return{...n,variations:n.variations.map(ke)}});return{...e,experiments:l}}var ve=6e4;function qe(e){let l=se(e.baseUrl);if(e.appManifestRelease!==void 0&&!/^[a-f0-9]{64}$/.test(e.appManifestRelease))throw new Error("Invalid IAM manifest digest");if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("Invalid App environment ID");let n=e.fetch??globalThis.fetch.bind(globalThis),c=F(n),y=F(n),v=`${l}/api/v1/visual-experiments/${e.environmentId}`,I=e.appManifestRelease?`${v}?iam=${e.appManifestRelease}`:v,k=re(e.deviceIdCookie??"indiana_did"),T=ae(),u=null,t=!1,i=!1,x="",S={...e.attributes??{}},G,B,D=0,H=-1/0,$,m=new Map,O=new Map,C=new Set,z=ge({endpoint:`${v}/events`,fetch:n,log:e.log,label:"Visual exposure"}),P=z.flush,W,b;function j(){clearTimeout(W),b?.remove(),b=void 0}function Y(s,d){let f=M(s,d);C.has(f)||e.trackExposures===!1||u?.trackExposures===!1||t||(C.add(f),z.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:k,...T?{sessionId:T}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:s.key,variationKey:d.key}))}function we(s){if(!u||t)return;let d=new Set,f={onExperimentViewed:(r,p)=>{d.add(M(r,p))},url:location.href,attributes:{...me(k,location),...S,indianaAppManifestRelease:e.appManifestRelease??null},savedGroups:te(u.savedGroups),log:e.log},h=new Set;for(let r of u.experiments){if(de(`${e.environmentId}:${r.key}`))continue;let p=r;try{let a=ie(p,f);if(O.set(r.changeId,a),!a.inExperiment)continue;h.add(r.changeId);let w=JSON.stringify([a.key,a.value]),U=m.get(r.changeId);if(U?.signature===w){d.has(M(p,a))&&s.push(()=>{U.applied()&&Y(p,a)});continue}m.get(r.changeId)?.revert(),m.delete(r.changeId);let A=fe(a.value,{requireUniqueTargets:!!e.appManifestRelease&&Array.isArray(r.condition?.$and)&&r.condition.$and.some(g=>g!==null&&typeof g=="object"&&!Array.isArray(g)&&g.indianaAppManifestRelease===e.appManifestRelease),boundVariations:r.variations,allowJs:e.disableJsInjection===!1,nonce:e.nonce,onApplied:()=>{d.has(M(p,a))&&Y(p,a)},onError:g=>e.log?.("Visual experiment stopped",{experiment:r.key,changeId:r.changeId,variation:a.key,error:String(g)}),onTargetStatus:e.log?g=>e.log?.("Visual target status changed",{experiment:r.key,changeId:r.changeId,variation:a.key,...g}):void 0});m.set(r.changeId,{signature:w,revert:A.revert,applied:()=>A.applied,inspect:()=>A.inspect()})}catch(a){e.log?.("Skipping visual experiment",{experiment:r.key,error:String(a)})}}for(let[r,p]of m)h.has(r)||(p.revert(),m.delete(r));j()}let V=()=>{let s=[];pe(()=>we(s));for(let d of s)d()};async function _(){let s=++D,d;try{d=await c.read(I,J)}catch(h){if(t||s!==D)return!1;throw h}let f=q(d);if(f.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Visual payload scope changed");return t||s!==D?!1:(u=f,H=performance.now(),!0)}async function Q(){!await _()||t||(N(),V())}function L(){clearTimeout($),$=setTimeout(()=>{if(document.visibilityState==="hidden")return L();Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()})},ve)}let X=()=>{t||document.visibilityState==="hidden"||performance.now()-H<ve||(clearTimeout($),Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()}))},Ie=()=>{x!==location.href&&(x=location.href,V())},Z=()=>{P(!0)},N=()=>{G||t||(G=oe(Ie),addEventListener("pagehide",Z),x=location.href)};async function ee(s,d){let f=location.href,h=u,r=[],p=null;if(!t)try{let a=q(await y.read(I,J));a.environmentId===e.environmentId&&(p=a.generation)}catch{}for(let a of h?.experiments??[]){if(s&&a.changeId!==s)continue;let w=O.get(a.changeId);if(!w)continue;let U=new TextEncoder().encode(ye(w.value)),A=[...new Uint8Array(await crypto.subtle.digest("SHA-256",U))].map(be=>be.toString(16).padStart(2,"0")).join(""),g=m.get(a.changeId)?.inspect()??{status:"inactive",total:0,applied:0};r.push({changeId:a.changeId,experimentKey:a.key,variationKey:w.key,inExperiment:w.inExperiment,fingerprint:A,...g})}return{environmentId:e.environmentId,release:e.appManifestRelease??null,generation:h?.generation??null,publishedGeneration:p,checkedAt:new Date().toISOString(),origin:location.origin,pathname:location.pathname,urlMatches:location.href===f&&(!d||d===f)&&h===u,stopped:t,rows:r}}let ne,xe=ue(()=>{i&&!t&&V()});return{async start(){if(!(i||t)){i=!0,e.appManifestRelease&&(B=ce(e.appManifestRelease)),e.antiFlicker&&(b=document.createElement("style"),e.nonce&&(b.nonce=e.nonce),b.textContent="body { visibility: hidden !important }",document.head.append(b),W=setTimeout(j,Math.min(3e3,Math.max(0,e.antiFlickerTimeout??1e3))));try{if(!await _()||t)return;N(),V()}finally{j(),t||(L(),document.addEventListener("visibilitychange",X),ne=he({environmentId:e.environmentId,baseUrl:l,origins:e.diagnosticsOrigins,inspect:ee}))}}},async refresh(){t||await _()&&(i&&N(),V())},setAttributes(s){S={...s},V()},flush:()=>P(),getDiagnostics:ee,getResults(){return new Map(O)},get generation(){return u?.generation??null},destroy(){t=!0,clearTimeout($),document.removeEventListener("visibilitychange",X),xe(),ne?.(),D++,c.destroy(),y.destroy(),G?.(),B?.destroy(),removeEventListener("pagehide",Z),j();for(let s of m.values())s.revert();m.clear(),P(!0),u=null,O.clear(),C.clear(),S={}}}}export{qe as createVisualExperiments,Ve as loadAppManifestRelease};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-FBHEBXK4.js";import"./chunk-MMAMK7OQ.js";import"./chunk-U2JO7MX2.js";import"./chunk-AECGOS7O.js";import"./chunk-CQYEM7U6.js";import"./chunk-ZL247MPX.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as validateEntitlementCheck,b as validateResourceCheck};
|
package/dist/chunk-JJEOS374.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as ve,b as be}from"./chunk-XMZ2FNYA.js";import{d as Le,e as ne}from"./chunk-MUU6LV3R.js";import{a as qe}from"./chunk-AECGOS7O.js";import{a as R}from"./chunk-DSPLGTQI.js";var $e=5*6e4,Qe=15e3,Te=new WeakMap;function tn(s){return Te.get(s)}var k=s=>Array.isArray(s)?s.map(k):s&&typeof s=="object"?Object.fromEntries(Object.keys(s).sort().map(n=>[n,k(s[n])])):s,T=(s,n)=>JSON.stringify(k(s))===JSON.stringify(k(n)),re=s=>JSON.stringify(k([s.funnelId,s.locale??null,s.parameters??{}])),Ye=["onObservationChange","onPurchaseIntent","onPurchase","onCheckoutUrl","resumeCheckout","allowNewPurchase","checkoutNavigation","terminateCheckout","beforeCheckoutReplacement","purchaseConfirmation","confirmOnHostedCheckout","resolveOfferId","prepareSubscriptionChange","resolveSubscriptionChange","onOpenUrl","onEvent","onAction","onComplete","onError"];function Ze(s,n,S){let O=e=>structuredClone({funnelId:e.funnelId,locale:e.locale,parameters:e.parameters}),m,_="",E=n.start instanceof Promise?void 0:O(n.start),ae=e=>e?.parameters?.commerce,j=Promise.resolve(n.start).then(e=>e?O(e):void 0),te=n.maxAgeMs??$e,Ie=new AbortController,g=AbortSignal.any([Ie.signal,n.client.identitySignal,...n.signal?[n.signal]:[]]),oe=()=>d("released","aborted"),a="preparing",Se,J,le=()=>{},U=0,b=null,v=null,C=null,w=null,h,x,V,Ce=new Map,P=null,W=new Set,F=new Map,ie,Ae=new Promise(e=>ie=e),G,se=new Promise(e=>G=e),ce,je=new Promise(e=>ce=e);function K(e,r){a!==e&&(a=e,Se=r,R(n.onState,e))}function Je(){g.removeEventListener("abort",oe),X(),v?.destroy(),v=null,b?.remove(),b=null,C=null}function d(e,r){["adopted","unavailable","released","closed"].includes(a)||(K(e,r),Je(),ie(!1),G(!1),B(!1),ce(null))}function N(e){a!=="shown"&&d("unavailable",e)}let f,ue=!1,D=n.client.paywallCopies,de,Re=new Promise(e=>de=e),fe=!1,M=!1,ke,z=n.whenPurchasePending==="recover"&&!S,B,Ue=new Promise(e=>B=e);function We(e){if(!z||f||!e||!w||!V||!A(w,V.commerce)||!["preparing","ready","shown"].includes(a))return!1;let r={savedAt:Date.now(),funnelId:e,context:V,resolution:structuredClone(w)};return f=r,we(r),Z(),!0}function pe(e){return!z||!f||!["preparing","ready","shown"].includes(a)?!1:(M=!0,ke=e,a==="shown"&&_e(),!0)}function _e(){let e=f?.context.locale??n.locale??"";v?.setPurchaseRecovery(e.startsWith("zh")?"正在查询原订单…":"Checking your purchase…")}function we(e){Re.then(r=>{r&&D&&D.write(r,e).catch(()=>{})})}function Ee(e){Re.then(async r=>{if(!r||!D)return;let l=await D.read(r);ue||l&&"presented"in l||await D.write(r,e)}).catch(()=>{})}let ye=e=>`error:${e?.code??e?.name??"unknown"}`,me=s.ownerDocument.defaultView,q=!S,Ve=null,H=!1,Ge=e=>e.storageArea===me?.localStorage&&(e.key===null||e.key.startsWith("indiana.funnel.purchases.")),Fe=e=>{Ge(e)&&$()},Ke=S?()=>{}:n.client.subscribe(()=>$());function X(){q&&(q=!1,me?.removeEventListener("storage",Fe),Ke(),le())}let ge=()=>q&&(a==="ready"||a==="preparing");function he(e){(a==="ready"||a==="preparing")&&d("unavailable",e)}function $(){if(a==="ready"&&Date.now()-U>=te)return X();H=!0,Ve??=(async()=>{for(;H&&m&&!M&&ge();){H=!1;try{await n.client.retained()==="pending"&&!pe("purchase_pending")&&he("purchase_pending")}catch(e){g.aborted?d("released","aborted"):he(ye(e))}}})().finally(()=>{Ve=null,H&&m&&!M&&ge()&&$()})}S||me?.addEventListener("storage",Fe),g.addEventListener("abort",oe,{once:!0});let De=S?Promise.resolve("none"):n.client.findPurchase();De.catch(()=>{});let Q;function Y(e){let r=Q?.paywallVersionId??n.paywallVersionId??f?.resolution.id??w?.id,l=JSON.stringify(k([r??null,e])),i=Ce.get(l);return i||(i=n.client.readPaywall({paywallVersionId:r,...r?{}:{paywallId:Q?.paywallId??n.paywallId},...e}),Ce.set(l,i)),i}function A(e,r){let l=Object.values(e.capabilities.plans),i=Object.values(e.document.buttons).some(t=>t.type==="checkout");return i&&l.length===0?!1:r.intent==="subscription_change"&&i?l.some(t=>t.available):l.every(t=>t.available)}function Pe(e,r){if(w&&!ne(e,w))return d("unavailable","paywall_changed"),!1;w=e,V=r,B(!0);for(let l of F.keys())R(l,structuredClone(e));return!0}function He(e,r){if(!(!w||!["preparing","ready","shown"].includes(a))){if(!ne(e,w))return N("paywall_changed");if(!A(e,r.commerce))return N("plan_unavailable");Pe(e,r)}}async function L(){let e=await je;if(!e)throw new qe("PURCHASE_PENDING","The purchase did not start; open it again");return e}let ze={get view(){return P?P.view:w},get signal(){return P?.signal??n.client.identitySignal},get quote(){return P?.quote??null},get operation(){return P?.operation??null},webViewUrl:"bundled",get canReselect(){return P?.canReselect},get recovery(){return P?.recovery},get pendingCancellation(){return P?.pendingCancellation},subscribe(e){return F.set(e,P?.subscribe?.(e)??(()=>{})),()=>{F.get(e)?.(),F.delete(e)}},refresh:async()=>P?P.refresh():structuredClone(w),preview:async e=>(await L()).preview(e),confirm:async()=>(await L()).confirm(),cancel:async()=>(await L()).cancel(),read:async()=>(await L()).read(),destroy(){P?.destroy()}},Oe=n.onPurchaseIntent&&(e=>n.onPurchaseIntent(e)),p={options:{},handoff:{}},xe={loading:"host",focusAtReveal:!0,settleMotionAtReveal:!0,signal:n.client.identitySignal,start:async()=>ze,canInteract:()=>p.options.canInteract?p.options.canInteract():!["unavailable","released","closed"].includes(a),async beforeAction(e){if(e?.purchaseIntent&&a!=="adopted"&&Oe)return;let r=a!=="adopted",l=w?.capabilities,i=await L();if(r&&!T(i.view?.capabilities,l))throw new Le;await p.options.beforeAction?.()}};for(let e of Ye)Object.defineProperty(xe,e,{enumerable:!0,get:()=>e==="onPurchaseIntent"?p.options.onPurchaseIntent??Oe:p.options[e]});function Z(){a!=="preparing"||!C||!v||!f&&(!m||!T(V?.commerce,ae(m))||V?.locale!==m.locale)||(K("ready"),ie(!0))}let Ne={present(e){if(p.handoff.present)return p.handoff.present(e);a==="preparing"&&(C=e,U=Date.now(),Z())},async dismiss(){if(p.handoff.dismiss)return p.handoff.dismiss();d("closed");for(let e of[...W])R(e)},async closeAction(e){if(p.handoff.closeAction)return p.handoff.closeAction(e);p.options.onAction?await p.options.onAction(e):await Ne.dismiss()},quoteError(e){p.handoff.quoteError?p.handoff.quoteError(e):R(p.options.onError,e)}};async function Be(){if(n.paywallVersionId||n.paywallId)return{paywallVersionId:n.paywallVersionId,paywallId:n.paywallId};let e=n.configuration;if(!e)return d("unavailable","paywall_missing"),null;let r=await Promise.resolve(n.start).catch(()=>null);if(!r||a!=="preparing")return null;let l=()=>ve(e,{funnelId:r.funnelId,customerId:n.client.customerId,parameters:r.parameters??{}});if(J=await l(),a!=="preparing")return null;let i=J;if(i.type!=="paywall")return d("unavailable",be(i)??"route"),null;let t=!1;return le=e.subscribe(()=>{t||!ge()||(t=!0,l().then(c=>{!(c.type==="unavailable"&&!["funnel_stopped","route_unavailable"].includes(c.reason))&&(c.type!=="paywall"||c.paywallVersionId!==i.paywallVersionId)&&he("route_changed")}).finally(()=>t=!1))}),q||le(),{paywallVersionId:i.paywallVersionId}}(async()=>{try{let[{showPaywall:e},r]=await Promise.all([import("./paywall-GUW4NI2B.js"),Be()]),l=n.commerce??ae(E),i=n.locale??E?.locale,t=r&&l&&i?JSON.stringify(k([r.paywallVersionId??null,r.paywallId??null,{commerce:l,locale:i}])):null;if(de(t),g.throwIfAborted(),a!=="preparing"||!r)return;if(!l)return d("unavailable","commerce_missing");if(!i)return d("unavailable","locale_missing");Q=r;let c={commerce:l,locale:i},y=t?await D?.read(t).catch(()=>null):null;if(fe=!!y&&"presented"in y&&(!E||y.funnelId===E.funnelId),g.throwIfAborted(),a!=="preparing"||fe)return;y&&!("presented"in y)&&(!E||y.funnelId===E.funnelId)&&A(y.resolution,y.context.commerce)&&(f=y),G(!!f);let o;if(f){let ee=f.context;c=ee,o=structuredClone(f.resolution),Y(ee).then(Xe=>He(Xe,ee),()=>{})}else o=await Y(c);if(g.throwIfAborted(),a!=="preparing"||(!A(o,c.commerce)&&n.start instanceof Promise&&!h&&await j,!f&&h&&!T(c,h)&&(c=h,o=await Y(c)),g.throwIfAborted(),a!=="preparing"))return;if(!A(o,c.commerce))return d("unavailable","plan_unavailable");if(!Pe(o,c))return;b=s.ownerDocument.createElement("div"),s.append(b);let u=setTimeout(()=>a==="preparing"&&d("unavailable","timeout"),Qe);Ae.then(()=>clearTimeout(u));let I=await e(b,xe,Ne);if(!I.host||g.aborted||a!=="preparing"){I.host?.destroy(),d(g.aborted?"released":"unavailable","error");return}v=I.host,Z()}catch(e){d(g.aborted?"released":"unavailable",ye(e))}finally{de(null),G(!1),B(!1)}})(),j.then(async e=>{let r=o=>{Ee(null),N(o)},l=async()=>{let o=await De;return o==="pending"?"purchase_pending":o==="found"?"original_purchase":o==="blocked"?"purchase_blocked":void 0},i=async o=>!o||o==="purchase_blocked"||!z?!1:(await se,pe(o)?!0:await Ue&&We(e?.funnelId??await n.client.pendingFunnel().catch(()=>null)??void 0)&&pe(o));if(!e)return z&&await i(await l().catch(()=>{}))?void 0:r("gated");let t=e,c=ae(t),y=n.commerce??c;if(!T(c&&{...c,intent:void 0},y&&{...y,intent:void 0})||n.locale!==void 0&&t.locale!==n.locale)return r("start_mismatch");if(!c)return r("commerce_missing");h={commerce:c,locale:t.locale},x=t,f&&["preparing","ready","shown"].includes(a)&&(m=t,_=re(t));try{let o=await l();if(await i(o)){m=void 0,_="";return}if(o)return r(o);if(!["preparing","ready","shown"].includes(a))return;if(n.configuration&&(n.paywallId||n.paywallVersionId)){let u=await ve(n.configuration,{funnelId:t.funnelId,customerId:n.client.customerId,parameters:t.parameters??{}});g.throwIfAborted();let I=u.type==="unknown"||u.type==="unavailable"&&u.reason!=="funnel_stopped";if(u.type==="paywall"?f?u.paywallId!==f.resolution.paywallId:n.paywallVersionId?u.paywallVersionId!==n.paywallVersionId:u.paywallId!==n.paywallId:!I)return r(be(u)??"route_changed")}if(q&&(H=!1,await n.client.retained()==="pending")){if(await i("purchase_pending")){m=void 0,_="";return}return r("purchase_pending")}if(await se,fe){m=t,_=re(t);return}if(Q||n.paywallId||n.paywallVersionId||w){let u=await Y(h);if(g.throwIfAborted(),Ee(A(u,h.commerce)?{savedAt:Date.now(),funnelId:t.funnelId,context:h,resolution:u}:null),f)He(u,h);else{if(a!=="preparing")return;if(w){if(!A(u,h.commerce))return d("unavailable","plan_unavailable");if(!Pe(u,h))return}}}}catch(o){return g.aborted?d("released","aborted"):N(ye(o))}["preparing","ready","shown"].includes(a)&&(m=t,_=re(t),Z(),H&&$())},()=>N("gated"));let Me={get state(){return a},get reason(){return Se??ke},ready:Ae,local:se,get start(){return m},get prediction(){return J?structuredClone(J):void 0},matches:e=>m?re(e)===_:!!f&&e.funnelId===f.funnelId&&e.locale===f.context.locale,open(){if(a==="preparing")return"pending";if(a!=="ready"||!C)return!1;if(Date.now()-U>=te)return d("unavailable","expired"),!1;let e=C;return C=null,X(),K("shown"),M&&_e(),e(),"shown"},destroy(){Ie.abort()}};return Te.set(Me,{onClose(e){return a==="closed"?(R(e),()=>{}):(W.add(e),()=>{W.delete(e)})},claim(){X()},remember(e){ue=!0;let r=structuredClone(e);j.then(()=>{!x||!h||we({savedAt:Date.now(),funnelId:x.funnelId,context:h,resolution:r})},()=>{})},withhold(){ue=!0,j.then(()=>{x&&we({savedAt:Date.now(),funnelId:x.funnelId,presented:"nothing"})},()=>{})},async adopt(e,r){let l=e.paywall?.resolution,i=e.paywall&&!e.paywall.quote&&!e.paywall.operation&&!e.paywall.purchaseRequestId&&!(e.paywall.selectionGeneration??0);if(a!=="shown"||!v||!w||!l||!i||e.source.id!==m?.funnelId||e.locale!==m?.locale||!T(e.parameters??{},m?.parameters??{})||!["running","waiting"].includes(e.status)||!ne(l,w))return null;let t;try{t=await r.start()}catch{return null}if(a!=="shown"||!v)return t.destroy(),null;P=t,p.options=r.options,p.handoff=r.handoff;for(let[o]of F)F.set(o,t.subscribe?.(o)??(()=>{})),t.view&&R(o,structuredClone(t.view));g.removeEventListener("abort",oe),K("adopted"),ce(t),W.clear();let c=v,y=b;return v=null,b=null,C=null,new Proxy(c,{get(o,u){return u==="destroy"?()=>{o.destroy(),y?.remove()}:u==="retainPurchaseDialog"?()=>{let I=o.retainPurchaseDialog();if(I)return{dialog:I.dialog,release(){I.release(),y?.remove()}}}:Reflect.get(o,u,o)}})},retainPurchaseDialog(){if(a!=="shown")return;let e=v?.retainPurchaseDialog();if(!e)return;let r=b;return v=null,b=null,d("released"),{dialog:e.dialog,release(){e.release(),r?.remove()}}},get modal(){return w?.document.presentation.type!=="inline"},get revealable(){return a==="ready"&&!!C&&Date.now()-U<te},get recovering(){return M},release(){d("released")}}),Me}function on(s,n){let S=n.run.parameters??{},O=S?.commerce;return Ze(s,{client:n.client,start:{funnelId:n.run.source.id,locale:n.run.locale,parameters:S},paywallVersionId:n.paywallVersionId,...O&&{commerce:O},locale:n.run.locale,signal:n.signal},{run:!0})}export{$e as a,tn as b,Ze as c,on as d};
|
package/dist/chunk-OT6DGH5B.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as n,r as t}from"./chunk-4SDB3T2F.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
|
package/dist/chunk-YQ2TU6TG.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as Le}from"./chunk-7ROXL6N2.js";import{a as X}from"./chunk-WFRZHLIV.js";import{D as W,F as Be,c as Te,e as B,j as De,u as Me,v as Ge,x as ze,z as Qe}from"./chunk-4SDB3T2F.js";import{a as je,b as xe,c as Ue}from"./chunk-BZ7HAITJ.js";import{b as ue}from"./chunk-HMT4SHIK.js";import{i as ce}from"./chunk-MUU6LV3R.js";import{K as Q}from"./chunk-MEBCS2JG.js";import{A as se,B as $,C as z,E as Ne}from"./chunk-F54HTDAC.js";import{x as ge}from"./chunk-ZMDKCBLI.js";import{b as He}from"./chunk-533YCYLO.js";import{a as l}from"./chunk-AECGOS7O.js";import{h as ie}from"./chunk-CQYEM7U6.js";import{a as Ve}from"./chunk-5MRSFLQA.js";import{b as r}from"./chunk-ZL247MPX.js";import{a as Pe}from"./chunk-DSPLGTQI.js";var C=Q.options,ct=r.discriminatedUnion("operation",[C[1].omit({customerToken:!0}),C[2].omit({customerToken:!0}),C[3].omit({customerToken:!0}),C[4].omit({customerToken:!0}),C[5].omit({customerToken:!0}),C[6].omit({customerToken:!0}),C[7].omit({customerToken:!0}),C[8].omit({customerToken:!0}),De.omit({customerToken:!0})]),ve=r.strictObject({receiptId:r.uuid(),operationId:r.uuid()}),Pt=r.discriminatedUnion("operation",[r.strictObject({operation:r.literal("find_purchase")}),r.strictObject({operation:r.literal("recover_start"),intent:r.enum(["lookup","resume","start"]),start:r.strictObject({requestId:C[0].shape.requestId,funnelId:C[0].shape.funnelId,locale:C[0].shape.locale,parameters:C[0].shape.parameters})}),r.strictObject({operation:r.literal("recover_run"),runId:r.uuid(),funnelId:r.uuid()}),r.strictObject({operation:r.literal("recover_purchase"),runId:r.uuid(),funnelId:r.uuid(),purchase:ve,includePaywallVersion:r.literal(!0).optional()}),r.strictObject({operation:r.literal("terminate_checkout"),runId:r.uuid(),funnelId:r.uuid(),purchase:ve,intent:r.literal("expire_unconfirmed_quote").optional()}),r.strictObject({operation:r.literal("settle_command"),runId:r.uuid(),funnelId:r.uuid(),requestId:r.uuid(),command:r.discriminatedUnion("operation",[C[3].omit({customerToken:!0}),C[4].omit({customerToken:!0}),C[5].omit({customerToken:!0}),C[6].omit({customerToken:!0}),C[7].omit({customerToken:!0})]).optional()}).refine(s=>!s.command||s.requestId===s.command.requestId),r.strictObject({operation:r.literal("run_command"),runId:r.uuid(),funnelId:r.uuid(),command:ct})]),le=r.strictObject({runId:r.uuid(),funnelId:r.uuid(),versionId:r.uuid(),startRequestId:r.uuid(),runExpiresAt:r.iso.datetime({offset:!0}),status:B.shape.run.shape.status}),M={scope:ie,customerId:r.uuid()},Ye=r.discriminatedUnion("outcome",[r.strictObject({...M,outcome:r.literal("unknown"),target:r.null(),view:r.null(),access:r.null()}),r.strictObject({...M,outcome:r.literal("resolved"),target:le,view:B.shape.run.nullable(),access:r.discriminatedUnion("type",[r.strictObject({type:r.literal("customer")}),r.strictObject({type:r.literal("operation_only"),cause:r.enum(["run_terminal","run_expired","run_revoked","issuer_unavailable"])})])})]).superRefine((s,d)=>{s.outcome==="resolved"&&(s.access.type==="customer"!=(s.view!==null)||s.view&&(s.view.id!==s.target.runId||s.view.source.id!==s.target.funnelId||s.view.source.versionId!==s.target.versionId||s.view.status!==s.target.status||s.view.runExpiresAt!==s.target.runExpiresAt||s.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Recovery view and original Run binding differ"})}),Je=r.strictObject({...M,target:le,view:B.shape.run.nullable(),settlement:r.strictObject({requestId:r.uuid(),state:r.enum(["pending","unknown","settled"]),acceptance:r.enum(["accepted","not_accepted","unknown"]),receiptPhase:r.enum(["accepted","processing","done"]).nullable(),basis:r.enum(["receipt","run_terminal","position_advanced","none"]),receiptId:r.uuid().nullable(),operationId:r.uuid().nullable()}),purchase:B.shape.purchase.unwrap().nullable()}).superRefine((s,d)=>{let f=s.settlement;(f.acceptance==="accepted"!=(f.receiptPhase!==null)||f.acceptance==="accepted"&&f.basis!=="receipt"||f.acceptance==="unknown"&&(f.state!=="unknown"||f.basis!=="none")||f.acceptance!=="accepted"&&(f.operationId!==null||f.receiptId!==null)||f.acceptance==="not_accepted"&&(f.state!=="settled"||!["run_terminal","position_advanced"].includes(f.basis))||s.purchase&&(s.purchase.receiptId!==f.receiptId||s.purchase.operation&&s.purchase.operation.operationId!==f.operationId||s.purchase.quote&&s.purchase.quote.operationId!==f.operationId)||s.view&&(s.view.id!==s.target.runId||s.view.source.id!==s.target.funnelId||s.view.source.versionId!==s.target.versionId||s.view.status!==s.target.status||s.view.runExpiresAt!==s.target.runExpiresAt||s.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Original command settlement binding differs"})}),Ke=r.strictObject({...M,target:le,purchase:B.shape.purchase.unwrap(),paywallVersionId:r.uuid().optional()}).superRefine((s,d)=>{(!s.purchase.operation||typeof s.purchase.canReselect!="boolean"||s.purchase.quote&&s.purchase.quote.operationId!==s.purchase.operation.operationId)&&d.addIssue({code:"custom",message:"Original purchase proof is incomplete"})}),$e=r.discriminatedUnion("outcome",[r.strictObject({...M,outcome:r.literal("none")}),r.strictObject({...M,outcome:r.literal("blocked")}),r.strictObject({...M,outcome:r.literal("found"),target:le,start:r.strictObject({locale:C[0].shape.locale,parameters:C[0].shape.parameters}),purchase:ve})]);var lt=Q.options[0].refine(s=>!s.customer&&!s.customerData),dt=r.strictObject({receiptId:r.uuid(),operationId:r.uuid(),terminal:r.enum(["complete","native"]).nullable()}),We=r.strictObject({schemaVersion:r.literal(1),baseUrl:r.url(),scope:ie,customerId:r.uuid(),sessionId:r.uuid(),start:lt,allowed:r.array(r.enum(["merchant","record_only","indiana","native"])),run:r.strictObject({id:r.uuid(),versionId:r.uuid(),status:Te.shape.status,revision:r.number().int().nonnegative(),runExpiresAt:r.iso.datetime({offset:!0}).optional()}).optional(),purchases:r.array(dt).max(100),operationCommand:r.strictObject({operationId:r.uuid(),intent:r.literal("confirm")}).optional(),journal:r.strictObject({revision:r.number().int().nonnegative(),entry:Me.nullable()})});function Xe(s){return ze({...s,namespace:"purchases",identity:[s.scope.projectId,s.scope.environment,s.customerId]})}function Ze(s){let d=new URL(s.baseUrl??Ve).href,f=()=>new l("PURCHASE_STORAGE_INVALID","Purchase recovery storage is unavailable or invalid; native fallback is not authorized");async function R(){s.assertCurrent();try{let S=await s.storage.read();if(s.assertCurrent(),!Number.isSafeInteger(S.revision)||S.revision<0)throw f();let c=S.entry===null?null:We.parse(S.entry);if(c&&(c.baseUrl!==d||c.customerId!==s.customerId||c.scope.projectId!==s.scope.projectId||c.scope.environment!==s.scope.environment))throw new l("SCOPE_MISMATCH","Purchase recovery belongs to another Customer or environment");if(c?.journal.entry&&(c.journal.entry.scope.projectId!==c.scope.projectId||c.journal.entry.scope.environment!==c.scope.environment||c.journal.entry.funnelId!==c.start.funnelId||c.journal.entry.runId!==c.run?.id||c.journal.entry.versionId!==c.run?.versionId)||c?.operationCommand&&!c.purchases.some(k=>k.operationId===c.operationCommand?.operationId))throw f();return{revision:S.revision,entry:c}}catch(S){throw S instanceof l?S:f()}}async function Z(S){for(let c=0;c<8;c++){let k=await R(),O=S(structuredClone(k.entry));if(JSON.stringify(O)===JSON.stringify(k.entry))return O;O&&We.parse(O),s.assertCurrent();let x;try{x=await s.storage.write(k.revision,O)}catch{throw f()}if(s.assertCurrent(),x!==null){if(!Number.isSafeInteger(x)||x<=k.revision)throw f();return O}}throw new l("PURCHASE_STORAGE_CONFLICT","Another consumer changed this purchase; recover the original attempt")}return{read:R,update:Z,baseUrl:d}}var pt=5*6e4,mt=2e3;function ft(s,d){let f=s.purchases.find(R=>R.type==="checkout");if(!s.actions.includes("continue_checkout")||f?.type!=="checkout"||d!==void 0&&f.operationId!==d)throw new l("PURCHASE_PENDING","No single resumable Checkout is confirmed");return f.checkoutUrl}function Yt(s){let d={...s,scope:{...s.scope},executionPolicy:structuredClone(s.executionPolicy)},f=d.session.snapshot();if(!f)throw new l("CUSTOMER_SESSION_REQUIRED","Purchase recovery requires a verified Customer session");let{customerId:R,sessionId:Z}=f,S=!1,c=null,k,O,x=null,F=!1,U,ee,te,_={mode:"idle",status:"idle",actions:["start"],purchases:[]},g=new Map,Ce=new Map,T=new Map,de=new AbortController,ne=new Set,Y=He(d),re=Le(Y.request);function J(e){return{code:e instanceof l?e.code:"PURCHASE_RECOVERY_BLOCKED",message:e instanceof Error?e.message:"The original purchase requires server confirmation",...e instanceof l&&e.status!==void 0?{status:e.status}:{}}}function P(){if(S||d.session.snapshot()?.customerId!==R)throw new l("IDENTITY_CHANGED","The original purchase Customer changed")}let w=Ze({...d,customerId:R,assertCurrent:P,storage:d.storage??Xe({baseUrl:d.baseUrl,scope:d.scope,customerId:R})}),et,Re=()=>et??=import("./funnel-paywall-copies-LZZILAWG.js").then(({createPaywallCopies:e})=>e({baseUrl:d.baseUrl,scope:d.scope,customerId:R})),tt={read:async e=>(await Re()).read(e),write:async(e,t)=>(await Re()).write(e,t)},nt=d.session.subscribeIdentity(Se);function Se(){S||(S=!0,clearTimeout(te),de.abort(new l("IDENTITY_CHANGED","Purchase consumer was destroyed")),nt(),c?.reset(),c=null,x=null,Y.dispose(),ne.clear(),g.clear(),T.clear())}function v(e){P();let t=JSON.stringify(e)!==JSON.stringify(_);_=e,clearTimeout(te),(e.mode==="operation"||e.mode==="run"&&!e.actions.includes("close"))&&["waiting_result","fulfillment","recording"].includes(e.status)&&(te=setTimeout(()=>{G().catch(()=>{})},5e3)),t&&Pe(d.onRecovery,structuredClone(e));for(let n of t?ne:[]){if(S)break;Pe(n,structuredClone(e))}return structuredClone(e)}function y(e){if(P(),!e||e.start.requestId!==O)throw new l("PURCHASE_STORAGE_CONFLICT","This purchase was superseded; the old consumer cannot dispatch")}function Ee(e){return!e.run&&!E(e).length&&!e.journal.entry&&!e.operationCommand}function be(e){let t=e.journal.entry;return!E(e).length&&!e.operationCommand&&!t?.closeCommand&&(!t?.command||t.command.operation==="close")}function E(e){let t=[...e.purchases],n=e.journal.entry?.purchase;return n&&!t.some(o=>o.operationId===n.operationId)&&t.push({receiptId:n.receiptId,operationId:n.operationId,terminal:null}),t}function N(e){let t=E(e),n=F&&t.length>0&&t.every(o=>o.terminal==="native"&&V(g.get(o.operationId))==="native")&&t.some(o=>{let i=g.get(o.operationId);return!i||T.get(o.operationId)!==!0?!1:z(i)?!0:i.status==="cancelled"&&i.confirmedAt===null&&!i.quoteFinalized&&!i.merchantExecution&&!i.problem&&!!i.quote&&Date.parse(i.quote.expiresAt)<=Date.now()});return e.run&&(n||!["running","waiting"].includes(e.run.status))&&!e.journal.entry?.command&&!e.journal.entry?.closeCommand&&!e.operationCommand&&t.every(o=>o.terminal!==null)}function A(e,t){let n=e.journal.entry?.command??e.journal.entry?.closeCommand,o=E(e).map(I=>{let b=g.get(I.operationId),L=ue({quote:b?.quote??null,operation:b??null,requestId:n?.requestId??null,pending:!1,destroyed:!1,canReselect:T.get(I.operationId)===!0});return I.terminal&&(L.type==="checkout"||L.type==="recover"||L.type==="cancel")?{type:I.terminal,operationId:I.operationId}:L}),i=o.filter(I=>!["complete","native"].includes(I.type)),u=i[0],a=i.length===1&&u?.operationId?g.get(u.operationId):void 0;if(a&&(u?.type==="checkout"||u?.type==="cancel"))try{W({allowed:e.allowed.filter(I=>d.executionPolicy.allowed.includes(I))},a.quote)}catch(I){return{mode:t,status:"blocked",actions:["refresh",...t==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[]],purchases:o,error:J(I)}}let m;if(t==="operation"&&!n&&u?.type==="cancel"&&a?.quote&&!a.problem&&!a.confirmedAt)try{W({allowed:e.allowed.filter(I=>d.executionPolicy.allowed.includes(I))},a.quote),Date.parse(a.quote.expiresAt)>Date.now()&&(m={operationId:a.operationId,quote:a.quote})}catch{}let p=o.length>0&&i.length===0,h=N(e)||t==="operation"&&p&&!n&&!e.operationCommand?"complete":u?.type==="checkout"?"checkout":u?.type==="fulfillment"?"fulfillment":u?.type==="recording"?"recording":n||e.operationCommand||u&&u.type!=="cancel"||t==="operation"&&!m?"waiting_result":"ready";return{mode:t,status:h,purchases:o,...m?{confirmation:structuredClone(m)}:{},actions:["refresh",...N(e)?["start"]:[],...t==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[],...e.operationCommand?["retry"]:m?["confirm"]:[],...i.length===1&&u?.type==="checkout"?["continue_checkout"]:[]]}}function V(e){let t=ue({quote:e?.quote??null,operation:e??null,requestId:null,pending:!1,destroyed:!1,canReselect:e&&T.get(e.operationId)===!0});return t.type==="complete"||t.type==="native"?t.type:null}function pe(e){if(!e.operation)return;let t=se.parse({...e.operation,...e.operation.quote?{}:e.quote?{quote:e.quote}:{}});if(t.merchantExecution&&t.merchantExecution.customerId!==R)throw new l("SCOPE_MISMATCH","Purchase execution belongs to another Customer");let n=ce(g.get(t.operationId)??null,t);g.set(t.operationId,n),n===t&&T.set(t.operationId,e.canReselect===!0)}async function rt(e){P();for(let n of[e.purchase,e.run.paywall])n&&pe(n);let t=await w.update(n=>{if(y(n),n.run&&(n.run.id!==e.run.id||n.run.versionId!==e.run.source.versionId))throw new l("SCOPE_MISMATCH","The original purchase Run changed");let o=E(n);for(let i of[e.purchase,e.run.paywall]){let u=i?.operation?.operationId??i?.quote?.operationId;if(!i||!u)continue;let a=o.find(p=>p.operationId===u);if(a&&a.receiptId!==i.receiptId)throw new l("INVALID_RESPONSE","The original purchase Receipt changed");let m=V(g.get(u));a?a.terminal??=m:o.push({receiptId:i.receiptId,operationId:u,terminal:m})}return{...n,purchases:o,run:n.run&&(n.run.revision>e.run.revision||!["running","waiting"].includes(n.run.status)&&["running","waiting"].includes(e.run.status))?n.run:{id:e.run.id,versionId:e.run.source.versionId,status:e.run.status,revision:e.run.revision,runExpiresAt:e.run.runExpiresAt}}});y(t),t.run&&!["running","waiting"].includes(t.run.status)&&E(t).some(n=>!n.terminal)&&(t=await H(t,!t.journal.entry?.command&&!t.journal.entry?.closeCommand,new Set([e.purchase?.operation?.operationId,e.run.paywall?.operation?.operationId].filter(n=>!!n)))),y(t),v(A(t,"run"))}function ot(){return{async read(){let{entry:e}=await w.read();return y(e),structuredClone(e.journal)},async write(e,t){let n=null;return await w.update(o=>{if(y(o),o.operationCommand&&t?.command&&t.command.operation!=="close")throw new l("PURCHASE_PENDING","Recover the original Operation command before dispatching a Run mutation");return n=null,o.journal.revision!==e?o:(n=e+1,{...o,journal:{revision:n,entry:t}})}),n}}}async function H(e,t=!1,n=new Set){y(e);let o=E(e);for(let u of o){if(u.terminal)continue;let a=n.has(u.operationId)?g.get(u.operationId):void 0;if(a??=await D(e,u),P(),a.operationId!==u.operationId)throw new l("INVALID_RESPONSE","Original Operation changed");if(a.merchantExecution&&a.merchantExecution.customerId!==R)throw new l("SCOPE_MISMATCH","Purchase execution belongs to another Customer");if(t&&!e.operationCommand&&ue({quote:a.quote??null,operation:a,requestId:null,pending:!1,destroyed:!1}).type==="cancel"){let m=z(a)?await re.update({operationId:u.operationId,intent:"cancel"}):await re.attach({operationId:u.operationId,intent:"cancel"});if(a=se.parse(m.operation),P(),a.operationId!==u.operationId)throw new l("INVALID_RESPONSE","Original cancellation Operation changed");a=await D(e,u)}g.set(u.operationId,ce(g.get(u.operationId)??null,a))}let i=await w.update(u=>{y(u);let a=u.operationCommand&&g.get(u.operationCommand.operationId);return{...u,...a&&(a.confirmedAt||a.merchantExecution||!Ne(a))?{operationCommand:void 0}:{},purchases:E(u).map(m=>({...m,terminal:m.terminal??V(g.get(m.operationId))}))}});return y(i),i}async function K(e){P();let t=await Y.request("funnels",e);return P(),t}async function at(e){try{return await K(e)}catch(t){if(e.operation!=="recover_start"||e.intent!=="start"||!(t instanceof l)||t.status!==400||t.code!=="INVALID_REQUEST")throw t;return K({...e,intent:"resume"})}}async function it(){let e=X($e,await K({operation:"find_purchase"}));if(e.customerId!==R||e.scope.projectId!==d.scope.projectId||e.scope.environment!==d.scope.environment)throw new l("SCOPE_MISMATCH","Recovery Customer or environment changed");if(e.outcome!=="found")return e.outcome;let{target:t,purchase:n}=e;return await w.update(o=>o&&!N(o)?o:{schemaVersion:1,baseUrl:w.baseUrl,scope:d.scope,customerId:R,sessionId:Z,start:{operation:"start",requestId:t.startRequestId,funnelId:t.funnelId,...e.start},allowed:[...d.executionPolicy.allowed],run:{id:t.runId,versionId:t.versionId,status:t.status,revision:0,runExpiresAt:t.runExpiresAt},purchases:[{...n,terminal:null}],journal:{revision:0,entry:null}}),"found"}let oe;function me(e){let t=oe;if(t&&(!t.outcome||e&&t.outcome==="none"&&Date.now()-t.at<pt))return t.job;let n={at:Date.now(),job:it().then(o=>(n.outcome=o,n.at=Date.now(),o),o=>{throw oe===n&&(oe=void 0),o})};return oe=n,n.job}async function D(e,t,n="recover_purchase",o=!1){let i={runId:e.run.id,funnelId:e.start.funnelId,purchase:{receiptId:t.receiptId,operationId:t.operationId}},u=n==="recover_purchase"?{...i,operation:n,...o?{includePaywallVersion:!0}:{}}:{...i,operation:"terminate_checkout",...n==="expire_unconfirmed_quote"?{intent:n}:{}},a=X(Ke,await K(u));if(fe(e,a),a.purchase.receiptId!==t.receiptId||a.purchase.operation?.operationId!==t.operationId)throw new l("INVALID_RESPONSE","Original purchase reference changed");return pe(a.purchase),o&&a.paywallVersionId&&Ce.set(t.operationId,a.paywallVersionId),g.get(t.operationId)}async function _e(e){for(let t of[e.journal.entry?.command,e.journal.entry?.closeCommand]){if(!t)continue;let n=X(Je,await K({operation:"settle_command",runId:e.run.id,funnelId:e.start.funnelId,requestId:t.requestId,...t.operation==="resume"?{}:{command:t}}));if(fe(e,n),n.settlement.requestId!==t.requestId)throw new l("INVALID_RESPONSE","Original command settlement changed");n.purchase&&pe(n.purchase);let o=await w.update(i=>{y(i);let u=E(i),{receiptId:a,operationId:m}=n.settlement;if(a&&m){let h=u.find(I=>I.operationId===m);if(h&&h.receiptId!==a)throw new l("INVALID_RESPONSE","Original Receipt changed");h||u.push({receiptId:a,operationId:m,terminal:V(g.get(m))})}let p=n.settlement.state==="settled"?Ge(i.journal.entry,t.requestId):i.journal.entry;return{...i,purchases:u,journal:p===i.journal.entry?i.journal:{revision:i.journal.revision+1,entry:p}}});y(o),e=o}return e}function fe(e,t){if(t.customerId!==R||t.scope.projectId!==d.scope.projectId||t.scope.environment!==d.scope.environment||t.target.funnelId!==e.start.funnelId||t.target.startRequestId!==e.start.requestId||e.run&&(t.target.runId!==e.run.id||t.target.versionId!==e.run.versionId))throw new l("SCOPE_MISMATCH","The original recovery binding changed")}async function he(e,t){if(y(e),e.run&&(e=await _e(e)),!E(e).length&&N(e))return v(A(e,"operation"));if(be(e)){let i=e.start.requestId;if(!await w.update(a=>a&&a.start.requestId===i&&be(a)?null:a))return c?.reset(),c=null,F=!1,v({mode:"idle",status:"idle",actions:["start"],purchases:[]})}if(!E(e).length)return v({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:J(t)});F=!0;let n=E(e);if(e.run&&["running","waiting"].includes(e.run.status)&&n.every(i=>i.terminal==="native"))for(let i of n)V(g.get(i.operationId))!=="native"&&await D(e,i);let o=await st(await H(e));return v(A(o,"operation"))}async function st(e){if(e.journal.entry?.command||e.journal.entry?.closeCommand||e.operationCommand)return e;let t=E(e).filter(u=>!u.terminal),n=t[0];if(!n||t.length!==1)return e;let o=g.get(n.operationId),i=o?.quote;if(!o||z(o)||!i||$(i)||i.provider!=="merchant"||o.status!=="pending"||o.confirmedAt!==null||o.quoteFinalized||o.checkoutUrl||o.nativePurchase||o.merchantExecution||o.problem||Date.parse(i.expiresAt)>Date.now())return e;try{await D(e,n,"expire_unconfirmed_quote")}catch{return P(),e}return H(e,!1,new Set([n.operationId]))}async function ae(e,t=!1,n=!0,o=!1){if(O=e.start.requestId,x=structuredClone({requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}),!c){let i=e.run?{operation:"recover_run",runId:e.run.id,funnelId:e.start.funnelId}:{operation:"recover_start",intent:t?"start":"lookup",start:{requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}},u;try{u=await at(i)}catch(h){if(!e.run&&h instanceof l&&(h.status===void 0||h.status>=500))return v({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:_.purchases,error:J(h)});throw h}let a=X(Ye,u);if(a.customerId!==R||a.scope.projectId!==d.scope.projectId||a.scope.environment!==d.scope.environment)throw new l("SCOPE_MISMATCH","Recovery Customer or environment changed");if(a.outcome==="unknown"){if(!t&&Ee(e)){let h=e.start.requestId;if(!await w.update(b=>b&&b.start.requestId===h&&Ee(b)?null:b))return v({mode:"idle",status:"idle",actions:["start"],purchases:[]})}return v({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:_.purchases,error:{code:"RESULT_UNKNOWN",message:"The original Start outcome remains unknown; retry only its original input"}})}fe(e,a);let m=await w.update(h=>(y(h),{...h,run:{id:a.target.runId,versionId:a.target.versionId,status:a.target.status,revision:a.view?.revision??h.run?.revision??0,runExpiresAt:a.target.runExpiresAt}}));if(y(m),e=m,a.access.type==="operation_only")return he(e,new l("RUN_RECONCILIATION_REQUIRED","Only the original command and Operation can be recovered"));e=await _e(e);let p=a.view;if(p.locale!==e.start.locale||!Qe(p.parameters,e.start.parameters))throw new l("INVALID_RESPONSE","The original Start input changed");c=Be({...d,customerRun:{runId:a.target.runId,customerId:R,startRequestId:e.start.requestId},funnelId:e.start.funnelId,funnelExecutionPolicy:{allowed:e.allowed.filter(h=>d.executionPolicy.allowed.includes(h))},funnelCommandStorage:ot(),onAcceptedResponse:rt},{scope:a.scope,run:p})}try{let i=o&&k?.controller===c?performance.now()-k.at:1/0;(i>=mt||c.pendingCommands?.length||(c.viewAgeMs??0)<i)&&(k=void 0,await c.get(),k={controller:c,at:performance.now()}),c.view?.pendingRequest?.requestId===e.start.requestId&&!c.pendingCommands?.length&&await c.resume(c.view.pendingRequest.requestId);for(let a of c.pendingCommands??[])a.operation!=="close"&&await c.settle?.(a.requestId);c.pendingCommands?.length&&await c.retry(),P();let u=(await w.read()).entry;return y(u),v(A(u,"run"))}catch(i){if(P(),n&&i instanceof l&&(i.status===401||i.status===409&&i.reason==="STATE_CHANGED")){c.reset(),c=null;let u=(await w.read()).entry;return y(u),ae(u,!1,!1,!1)}throw i}}function j(e,t="read",n){if(P(),U)return t==="read"||t===ee?U:U.then(()=>j(e,t,n),()=>j(e,t,n));clearTimeout(te);let o=e().catch(i=>{throw!S&&!n?.(i)&&v({mode:"blocked",status:"blocked",actions:["refresh"],purchases:_.purchases,error:J(i)}),i});return U=o,ee=t,o.then(()=>{U===o&&(U=void 0,ee=void 0)},()=>{U===o&&(U=void 0,ee=void 0)}),o}function G(e){let t=e?.reuseRecentRead===!0;return j(async()=>{let{entry:n}=await w.read();if(!n||N(n)){if(await me(!1)==="blocked")return qe();({entry:n}=await w.read())}return n?(O&&n.start.requestId!==O&&(c?.reset(),c=null,g.clear(),T.clear(),F=!1),F&&O===n.start.requestId?he(n,_.error):ae(n,!1,!0,t)):v({mode:"idle",status:"idle",actions:["start"],purchases:[]})})}function qe(){return v({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:J(new l("PURCHASE_PENDING","Check the outstanding purchases before starting another"))})}async function Oe(){let e=await G();return e.mode==="operation"&&!e.actions.includes("confirm")&&!e.actions.includes("retry")?e:j(async()=>{let t=(await w.read()).entry;if(y(t),!F){if(!c?.view?.paywall?.quote)throw new l("PURCHASE_PENDING","Read the original quote before confirming");let p=c.view.paywall.operation;if(p?.confirmedAt||p?.merchantExecution||p&&!(z(p)?["prepared","quoted"].includes(p.status):p.status==="pending"))return v(A(t,"run"));if(c.pendingCommands?.length)await c.retry();else{let I=c.view;await c.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:I.nodeId,visit:I.visit,revision:I.revision,input:{type:"paywall_confirm",operationId:I.paywall.quote.operationId,...I.paywall.quote.merchantTerms?{merchantConfirmation:ge(I.paywall.quote.merchantTerms)}:{}}})}let h=(await w.read()).entry;return y(h),v(A(h,"run"))}let n=t.operationCommand?.operationId??_.confirmation?.operationId,o=n&&g.get(n);if(!n||!o||t.journal.entry?.command||t.journal.entry?.closeCommand)throw new l("PURCHASE_PENDING","The original Run command must be settled before Operation confirmation");W({allowed:t.allowed.filter(p=>d.executionPolicy.allowed.includes(p))},o.quote),await w.update(p=>{if(y(p),p.journal.entry?.command||p.journal.entry?.closeCommand||p.operationCommand&&p.operationCommand.operationId!==n)throw new l("PURCHASE_PENDING","Another original command is pending");return{...p,operationCommand:{operationId:n,intent:"confirm"}}});let i={operationId:n,intent:"confirm",...o.quote?.merchantTerms?{merchantConfirmation:ge(o.quote.merchantTerms)}:{}},u=z(o)?await re.update(i):await re.attach(i),a=se.parse(u.operation);if(P(),u.operation.operationId!==n)throw new l("INVALID_RESPONSE","Original confirmation Operation changed");g.set(n,ce(o,a));let m=(await w.read()).entry;return y(m),v(A(await H(m,!1,new Set([n])),"operation"))},"confirm")}function ut(e){let t=e?.quote;return t&&$(t)&&t.timing==="immediate"&&t.execution.provider==="merchant"&&(e.confirmedAt||e.merchantExecution)?t:null}function ke(){if(_.mode!=="operation"||_.status==="blocked")return null;let e=_.purchases.filter(({type:n})=>n!=="complete"&&n!=="native"),t=e.length===1&&e[0]?.operationId;return t?ut(g.get(t)):null}async function Fe(){P();let{entry:e}=await w.read();return e?N(e)?"finished":"pending":"none"}return{get controller(){return c},get recovery(){return structuredClone(_)},get attempt(){return P(),structuredClone(x)},get identitySignal(){return de.signal},get customerId(){return R},retained:Fe,async pendingFunnel(){P();let{entry:e}=await w.read();return e&&!N(e)?e.start.funnelId:null},get paywallCopies(){return tt},async findPurchase(){let e=await Fe();if(e==="pending")return e;let t=await me(!0);return P(),t==="none"?e:t},async readPaywall(e){P();let t=je(e),[n,{readPaywallContent:o},{validateResourceCheck:i}]=await Promise.all([xe(Y.request,"resolvePaywall"),import("./paywall-content-HMUHTWWL.js"),import("./check-response-SOTWWQ3J.js")]);P();let u=n.request.parse({selector:t.paywallVersionId?{type:"version",versionId:t.paywallVersionId}:{type:"paywall",paywallId:t.paywallId},commerce:t.commerce,locale:t.locale}),a=await Ue(Y.request,n,u);i(u,a.paywall.check,a.scope);let m=await o(d,a.paywall);if(P(),t.paywallVersionId?m.id!==t.paywallVersionId:m.paywallId!==t.paywallId)throw new l("INVALID_RESPONSE","The requested Paywall changed");return m},get canRestoreUpgradePaywall(){return ke()!==null},recoverUpgradePaywall(){let e=ke();return e?this.recoverPurchasePaywall(void 0,e.operationId):Promise.resolve(null)},async recoverPurchasePaywall(e,t){if(_.mode!=="operation"||_.status==="blocked")return null;let{entry:n}=await w.read();if(!n?.run)return null;y(n);let o=E(n),i=o.filter(q=>!q.terminal),u=o.filter(q=>q.terminal==="complete"),a=i.length===1?i[0]:i.length?void 0:u.find(q=>e&&e.runId===n.run?.id&&q.receiptId===e.receiptId)??(u.length===1?u[0]:void 0);if(!a||t&&a.operationId!==t)return null;let m=e?.runId===n.run.id&&e.receiptId===a.receiptId?e.view:void 0,p;try{p=await D(n,a,"recover_purchase",!0)}catch(q){if(!(q instanceof l&&q.status===400&&q.code==="INVALID_REQUEST"))throw q;if(!m)return null;p=await D(n,a)}let h=p.quote;if(!h||$(h)&&(h.timing!=="immediate"||h.execution.provider!=="merchant")||!(p.confirmedAt||p.merchantExecution||p.checkoutUrl||V(p)==="complete"))return null;V(p)!=="complete"&&W({allowed:n.allowed.filter(q=>d.executionPolicy.allowed.includes(q))},h);let I=Ce.get(a.operationId),b=n.start.parameters?.commerce,L=n.start.locale??"en",we=m;if(I){if(typeof b!="object"||!b||!("provider"in b)||typeof b.provider!="string"||!("currency"in b)||typeof b.currency!="string")return null;we=await this.readPaywall({paywallVersionId:I,locale:L,commerce:{provider:b.provider,currency:b.currency,...$(h)?{intent:"subscription_change"}:{}}})}if(!we)return null;P();let Ae=we,Ie=!1,ye=async()=>{throw new l("PURCHASE_PENDING","Only the original purchase can be recovered")};return{signal:de.signal,view:Ae,quote:h,locale:L,get operation(){return p},get canReselect(){return T.get(a.operationId)===!0},async refresh(){return Ae},preview:ye,confirm:ye,cancel:ye,async read(){if(Ie)throw new DOMException("Purchase view closed","AbortError");p=await D(n,a);let q=await H(n,!1,new Set([a.operationId]));return Ie||v(A(q,"operation")),structuredClone(p)},destroy(){Ie=!0}}},start(e){let t=Q.parse({...structuredClone(e),operation:"start",requestId:e.requestId??crypto.randomUUID()});if(t.operation!=="start"||t.customer||t.customerData)throw new l("INVALID_REQUEST","A Customer-owned Funnel start is required");return j(async()=>{let n=(await w.read()).entry;if((!n||N(n))&&await me(!0)==="blocked")return qe();let o=await w.update(i=>{if(i&&!N(i)){if(i.start.funnelId!==t.funnelId)throw new l("PURCHASE_PENDING","Recover the original Funnel before starting another purchase");return i}return{schemaVersion:1,baseUrl:w.baseUrl,scope:d.scope,customerId:R,sessionId:Z,start:t,allowed:[...d.executionPolicy.allowed],purchases:[],journal:{revision:0,entry:null}}});if(!o)throw new l("PURCHASE_STORAGE_INVALID","Original start was not retained");return O!==o.start.requestId&&(c?.reset(),c=null,g.clear(),T.clear(),F=!1),F?he(o,_.error):ae(o,!0,!0,!0)},`start:${t.funnelId}`)},refresh:G,confirm:Oe,retry:()=>F?Oe():j(async()=>{let{entry:e}=await w.read();return e?ae(e,!0):v({mode:"idle",status:"idle",actions:["start"],purchases:[]})},"retry"),async close(){return c?.view?j(async()=>{if(!c?.view)throw new l("PURCHASE_PENDING","Recover the original Run before closing");if(c.pendingCommands?.find(n=>n.operation==="close"))await c.retry();else if(["running","waiting"].includes(c.view.status)){let n=c.view;await c.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:n.revision})}let t=(await w.read()).entry;return y(t),v(A(t,"run"))},"close"):G()},async continueCheckout(e,t){let n=t?await j(async()=>{let{entry:o}=await w.read();if(y(o),!o.run||!E(o).some(u=>u.operationId===t&&!u.terminal))throw new l("PURCHASE_PENDING","The original Checkout changed");let i=await H(o);return v(A(i,F?"operation":"run"))},`continue:${t}`,o=>o instanceof l&&o.code==="PURCHASE_PENDING"):await G();P(),await e(ft(n,t))},async terminateCheckout(e){let t=n=>n.actions.includes("continue_checkout")&&n.purchases.some(o=>o.type==="checkout"&&o.operationId===e);if(!t(_)&&!t(await G()))throw new l("PURCHASE_PENDING","The original Checkout has changed");return j(async()=>{let{entry:n}=await w.read();y(n);let o=E(n).find(u=>u.operationId===e&&!u.terminal);if(!o||!n.run)throw new l("PURCHASE_PENDING","The original Checkout has changed");await D(n,o,"terminate_checkout");let i=await H(n,!1,new Set([e]));return v(A(i,F?"operation":"run"))},`terminate:${e}`,n=>n instanceof l&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(n.code))},subscribe(e){return ne.add(e),()=>{ne.delete(e)}},destroy:Se}}export{Xe as a,ft as b,Yt as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-LIWSSQAG.js";import"./chunk-7SQPGOJV.js";import"./chunk-AJHLDSPG.js";import"./chunk-YEUQXQWK.js";import"./chunk-AEQUKR4O.js";import"./chunk-W32FI2A2.js";import"./chunk-TORHBU45.js";import"./chunk-HMT4SHIK.js";import"./chunk-MUU6LV3R.js";import"./chunk-MEBCS2JG.js";import"./chunk-ZAD5WJWS.js";import"./chunk-F54HTDAC.js";import"./chunk-ZMDKCBLI.js";import"./chunk-JTCS63ER.js";import"./chunk-VILB5M4X.js";import"./chunk-533YCYLO.js";import"./chunk-HSNAFHCP.js";import"./chunk-OKHCU6ET.js";import"./chunk-FGAIHKFS.js";import"./chunk-MMAMK7OQ.js";import"./chunk-U2JO7MX2.js";import"./chunk-DJTZR2NR.js";import"./chunk-AECGOS7O.js";import"./chunk-CQYEM7U6.js";import"./chunk-WJDHBJGU.js";import"./chunk-5MRSFLQA.js";import"./chunk-ZL247MPX.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as mountFunnelRecoveryPaywall,b as replaceableOriginalSession};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d}from"./chunk-JJEOS374.js";import"./chunk-XMZ2FNYA.js";import"./chunk-EXHNZVTM.js";import"./chunk-MUU6LV3R.js";import"./chunk-F54HTDAC.js";import"./chunk-ZMDKCBLI.js";import"./chunk-MGVWCLVQ.js";import"./chunk-JTCS63ER.js";import"./chunk-VILB5M4X.js";import"./chunk-HSNAFHCP.js";import"./chunk-FGAIHKFS.js";import"./chunk-MMAMK7OQ.js";import"./chunk-U2JO7MX2.js";import"./chunk-DJTZR2NR.js";import"./chunk-AECGOS7O.js";import"./chunk-CQYEM7U6.js";import"./chunk-ZL247MPX.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as PRERENDER_MAX_AGE_MS,b as preparedInternals,c as prerenderFunnelPurchase,d as prerenderRunPaywall};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c}from"./chunk-XMZ2FNYA.js";import"./chunk-EXHNZVTM.js";import"./chunk-MGVWCLVQ.js";import"./chunk-JTCS63ER.js";import"./chunk-VILB5M4X.js";import"./chunk-DJTZR2NR.js";import"./chunk-ZL247MPX.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as predictFunnelStart,c as predictedPaywallLoadingDocument,b as predictionRefusal};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as e,b as o,c as n}from"./chunk-EXHNZVTM.js";import"./chunk-MGVWCLVQ.js";import"./chunk-JTCS63ER.js";import"./chunk-VILB5M4X.js";import"./chunk-DJTZR2NR.js";import"./chunk-ZL247MPX.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{e as FUNNEL_ROUTE_LIMITS,o as funnelRouteSchema,n as projectFunnelRoute};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-JUI7TMIM.js";import"./chunk-JJEOS374.js";import"./chunk-AJHLDSPG.js";import"./chunk-YEUQXQWK.js";import"./chunk-XMZ2FNYA.js";import"./chunk-EXHNZVTM.js";import"./chunk-45PGU2HW.js";import"./chunk-AEQUKR4O.js";import"./chunk-W32FI2A2.js";import"./chunk-TORHBU45.js";import"./chunk-3IDEYQBG.js";import"./chunk-HMT4SHIK.js";import"./chunk-MUU6LV3R.js";import"./chunk-MEBCS2JG.js";import"./chunk-ZAD5WJWS.js";import"./chunk-F54HTDAC.js";import"./chunk-ZMDKCBLI.js";import"./chunk-MGVWCLVQ.js";import"./chunk-JTCS63ER.js";import"./chunk-VILB5M4X.js";import"./chunk-533YCYLO.js";import"./chunk-HSNAFHCP.js";import"./chunk-OKHCU6ET.js";import"./chunk-FGAIHKFS.js";import"./chunk-MMAMK7OQ.js";import"./chunk-U2JO7MX2.js";import"./chunk-DJTZR2NR.js";import"./chunk-AECGOS7O.js";import"./chunk-CQYEM7U6.js";import"./chunk-SLUA7ABW.js";import"./chunk-MB2U2GWJ.js";import"./chunk-WJDHBJGU.js";import"./chunk-5MRSFLQA.js";import"./chunk-ZL247MPX.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{P as r,Q as m,j as e}from"./chunk-ZMDKCBLI.js";import"./chunk-HSNAFHCP.js";import"./chunk-U2JO7MX2.js";import"./chunk-CQYEM7U6.js";import"./chunk-ZL247MPX.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{m as merchantBridgeCommerceSchema,r as merchantBridgeOperationSchema,e as merchantOperationLookupSchema};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as o}from"./chunk-2FDRWKO4.js";import"./chunk-DT2OMMAT.js";import"./chunk-5O6YRAHQ.js";import"./chunk-E6ND7YQW.js";import"./chunk-MDNT2TC3.js";import"./chunk-MEBCS2JG.js";import"./chunk-ZAD5WJWS.js";import"./chunk-F54HTDAC.js";import"./chunk-ZMDKCBLI.js";import"./chunk-JTCS63ER.js";import"./chunk-VILB5M4X.js";import"./chunk-RGXNLSFL.js";import"./chunk-HSNAFHCP.js";import"./chunk-OKHCU6ET.js";import"./chunk-FGAIHKFS.js";import"./chunk-MMAMK7OQ.js";import"./chunk-U2JO7MX2.js";import"./chunk-DJTZR2NR.js";import"./chunk-CQYEM7U6.js";import"./chunk-ZL247MPX.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
|
package/dist/paywall-GUW4NI2B.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-7SQPGOJV.js";import"./chunk-YEUQXQWK.js";import"./chunk-W32FI2A2.js";import"./chunk-TORHBU45.js";import"./chunk-HMT4SHIK.js";import"./chunk-MUU6LV3R.js";import"./chunk-ZAD5WJWS.js";import"./chunk-F54HTDAC.js";import"./chunk-ZMDKCBLI.js";import"./chunk-VILB5M4X.js";import"./chunk-533YCYLO.js";import"./chunk-HSNAFHCP.js";import"./chunk-OKHCU6ET.js";import"./chunk-FGAIHKFS.js";import"./chunk-MMAMK7OQ.js";import"./chunk-U2JO7MX2.js";import"./chunk-DJTZR2NR.js";import"./chunk-AECGOS7O.js";import"./chunk-CQYEM7U6.js";import"./chunk-WJDHBJGU.js";import"./chunk-5MRSFLQA.js";import"./chunk-ZL247MPX.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as showPaywall};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as a}from"./chunk-Y7Z6F6Y3.js";import"./chunk-E6ND7YQW.js";import"./chunk-MDNT2TC3.js";import"./chunk-MEBCS2JG.js";import"./chunk-ZAD5WJWS.js";import"./chunk-F54HTDAC.js";import"./chunk-ZMDKCBLI.js";import"./chunk-JTCS63ER.js";import"./chunk-VILB5M4X.js";import"./chunk-533YCYLO.js";import"./chunk-HSNAFHCP.js";import"./chunk-OKHCU6ET.js";import"./chunk-FGAIHKFS.js";import"./chunk-MMAMK7OQ.js";import"./chunk-U2JO7MX2.js";import"./chunk-DJTZR2NR.js";import"./chunk-AECGOS7O.js";import"./chunk-CQYEM7U6.js";import"./chunk-3VUPVXAV.js";import"./chunk-WJDHBJGU.js";import"./chunk-5MRSFLQA.js";import"./chunk-ZL247MPX.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-KICIH4PE.js";import"./chunk-2FDRWKO4.js";import"./chunk-DT2OMMAT.js";import"./chunk-BZ7HAITJ.js";import"./chunk-HMT4SHIK.js";import"./chunk-MUU6LV3R.js";import"./chunk-5O6YRAHQ.js";import"./chunk-FBHEBXK4.js";import"./chunk-Y7Z6F6Y3.js";import"./chunk-E6ND7YQW.js";import"./chunk-MDNT2TC3.js";import"./chunk-MEBCS2JG.js";import"./chunk-ZAD5WJWS.js";import"./chunk-F54HTDAC.js";import"./chunk-ZMDKCBLI.js";import"./chunk-JTCS63ER.js";import"./chunk-VILB5M4X.js";import"./chunk-RGXNLSFL.js";import"./chunk-533YCYLO.js";import"./chunk-HSNAFHCP.js";import"./chunk-OKHCU6ET.js";import"./chunk-FGAIHKFS.js";import"./chunk-MMAMK7OQ.js";import"./chunk-U2JO7MX2.js";import"./chunk-DJTZR2NR.js";import"./chunk-AECGOS7O.js";import"./chunk-CQYEM7U6.js";import"./chunk-3VUPVXAV.js";import"./chunk-WJDHBJGU.js";import"./chunk-5MRSFLQA.js";import"./chunk-ZL247MPX.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i}from"./chunk-7C4OOGQX.js";import"./chunk-TORHBU45.js";import"./chunk-OKHCU6ET.js";import"./chunk-FGAIHKFS.js";import"./chunk-MMAMK7OQ.js";import"./chunk-U2JO7MX2.js";import"./chunk-DJTZR2NR.js";import"./chunk-AECGOS7O.js";import"./chunk-CQYEM7U6.js";import"./chunk-ZL247MPX.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{f as formatCustomerDecimal,b as hostedRendererScript,a as hostedRendererShell,d as inspectCustomHtml,i as mountScreenPreview,h as preparePopup,e as prepareScreen,c as sanitizeCustomHtml,g as showPopup};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|