@tinkerlandai/longplay-sdk 0.10.29 → 0.10.31
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 +12 -0
- package/dist/{chunk-VSWKFI3L.js → chunk-23WNEOK4.js} +1 -1
- package/dist/{chunk-S4JIOALC.js → chunk-2QQZSMTB.js} +1 -1
- package/dist/{chunk-PQJJ5BSY.js → chunk-2TPPGW7V.js} +1 -1
- package/dist/{chunk-TNN4S6VO.js → chunk-4ZVVG5LM.js} +1 -1
- package/dist/{chunk-FDCINOOI.js → chunk-5N7QFF5M.js} +1 -1
- package/dist/{chunk-O4KXODTJ.js → chunk-6BTJNSQQ.js} +1 -1
- package/dist/{chunk-JPHYIUIR.js → chunk-7Z7JT4HE.js} +1 -1
- package/dist/{chunk-AZ53RDWO.js → chunk-ACFQLHJR.js} +1 -1
- package/dist/{chunk-KAXKYBSI.js → chunk-B3KFE57L.js} +1 -1
- package/dist/{chunk-EUVKRGMO.js → chunk-BQLT2LDP.js} +1 -1
- package/dist/{chunk-VKDBROTE.js → chunk-D3UU546S.js} +1 -1
- package/dist/{chunk-Q2TQLDEH.js → chunk-EZ5RCVVY.js} +1 -1
- package/dist/{chunk-HZYCK4XJ.js → chunk-FJGJQGYF.js} +1 -1
- package/dist/{chunk-5X6WAPH3.js → chunk-FVGUBIVT.js} +1 -1
- package/dist/{chunk-7EPE2PUN.js → chunk-HJLGRW4A.js} +1 -1
- package/dist/{chunk-2JTMXZ5M.js → chunk-ITVSLSRM.js} +1 -1
- package/dist/{chunk-TLGKBSXC.js → chunk-J4VTKRH7.js} +1 -1
- package/dist/{chunk-MBKZYWPF.js → chunk-JNSU2AP2.js} +1 -1
- package/dist/{chunk-PNHGULO2.js → chunk-LZV4QJ5E.js} +1 -1
- package/dist/chunk-NH5ML5SB.js +1 -0
- package/dist/chunk-PI25NLDV.js +1 -0
- package/dist/{chunk-UWAZDSWO.js → chunk-QPHT6QHE.js} +1 -1
- package/dist/{chunk-GOYKJHDV.js → chunk-RBMOWJGE.js} +1 -1
- package/dist/{chunk-77GCT2VP.js → chunk-S57HRPT2.js} +1 -1
- package/dist/{chunk-SBSLHDBE.js → chunk-S5H3WJVQ.js} +1 -1
- package/dist/chunk-SJSCROSL.js +1 -0
- package/dist/{chunk-4OBCF5H3.js → chunk-TF2OFTYS.js} +1 -1
- package/dist/{chunk-6QJRT23Q.js → chunk-TMZGZAWM.js} +1 -1
- package/dist/{chunk-K72QA2PO.js → chunk-UWYL2QCF.js} +1 -1
- package/dist/{chunk-PKY55SBA.js → chunk-WK4WQZHK.js} +1 -1
- package/dist/{chunk-4WBIACS2.js → chunk-WRUW2UIJ.js} +1 -1
- package/dist/{chunk-VC2H3LFP.js → chunk-XIP32WI7.js} +1 -1
- package/dist/{chunk-YBX2LLRG.js → chunk-XZEGVBAI.js} +1 -1
- package/dist/chunk-YEXRETKV.js +1 -0
- package/dist/{chunk-CGSZBPSX.js → chunk-YXCEZAQL.js} +1 -1
- package/dist/{chunk-QZG2YXM4.js → chunk-ZYTT7ZAB.js} +1 -1
- package/dist/{content-S5MXIR7Y.js → content-OY5MRXF5.js} +1 -1
- package/dist/{funnel-host-purchase-7BRXGIJX.js → funnel-host-purchase-IRFPNIZY.js} +1 -1
- package/dist/{funnel-local-client-DoYVcZ1z.d.ts → funnel-local-client-D7e3rP5-.d.ts} +1 -1
- package/dist/{funnel-process-client-DtXNiFQ-.d.ts → funnel-process-client-BEPv6guV.d.ts} +1 -1
- package/dist/funnel-runtime-host-CJTPLZ4N.js +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-LJKL7PNJ.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-SP2RZUT3.js +1 -0
- package/dist/page.js +1 -1
- package/dist/paywall-DI62MX5L.js +1 -0
- package/dist/paywall-session-AW6R3PJB.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +4 -4
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-W5MP4KVG.js +1 -0
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -1
- package/dist/{visual-dom-5LUN4AHO.js → visual-dom-32PB6MMP.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3GT4A3TA.js +0 -1
- package/dist/chunk-IDMOAV63.js +0 -1
- package/dist/chunk-JAUJZWYJ.js +0 -1
- package/dist/chunk-MMZR4I5X.js +0 -1
- package/dist/funnel-runtime-host-ITKTYBDS.js +0 -1
- package/dist/merchant-bridge-contracts-JCDMP54Z.js +0 -1
- package/dist/operation-contracts-B7I45NS3.js +0 -1
- package/dist/paywall-BEFHTZW7.js +0 -1
- package/dist/paywall-session-YVGZPSFM.js +0 -1
- package/dist/screen-renderer-ITUUNF4E.js +0 -1
- /package/dist/{chunk-CILM5XMH.js → chunk-PWXN3W4Q.js} +0 -0
- /package/dist/{chunk-OJM6ORHE.js → chunk-RFUXSC52.js} +0 -0
- /package/dist/{chunk-7GD2UTBU.js → chunk-ZY4XAKNQ.js} +0 -0
package/dist/openrouter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-5N7QFF5M.js";import"./chunk-BQLT2LDP.js";import"./chunk-XZEGVBAI.js";import"./chunk-J4VTKRH7.js";import{a as i}from"./chunk-HJLGRW4A.js";import"./chunk-XIP32WI7.js";import"./chunk-FVGUBIVT.js";import{b as A}from"./chunk-ZY4XAKNQ.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-EZ5RCVVY.js";import"./chunk-YXCEZAQL.js";import"./chunk-JNSU2AP2.js";import"./chunk-QPHT6QHE.js";import"./chunk-4ZVVG5LM.js";import"./chunk-LZV4QJ5E.js";import"./chunk-ITVSLSRM.js";import"./chunk-SJSCROSL.js";import"./chunk-ACFQLHJR.js";import"./chunk-BQLT2LDP.js";import"./chunk-J4VTKRH7.js";import"./chunk-WRUW2UIJ.js";import"./chunk-FJGJQGYF.js";import"./chunk-XIP32WI7.js";import"./chunk-ZY4XAKNQ.js";import"./chunk-6BTJNSQQ.js";import"./chunk-PWXN3W4Q.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-S5H3WJVQ.js";import"./chunk-ZYTT7ZAB.js";import"./chunk-3VUPVXAV.js";import"./chunk-FVGUBIVT.js";import"./chunk-DSPLGTQI.js";import"./chunk-6BTJNSQQ.js";import"./chunk-PWXN3W4Q.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as at,c as Ne,e as ot,g as st,h as ct}from"./chunk-UWYL2QCF.js";import{c as Xe,d as Ze,e as et,f as pe,g as tt,h as nt,i as rt,k as it}from"./chunk-RBMOWJGE.js";import{a as Ge,c as Se,d as Ye,g as Je,j as Ke}from"./chunk-B3KFE57L.js";import{b as te}from"./chunk-ACFQLHJR.js";import"./chunk-XZEGVBAI.js";import"./chunk-J4VTKRH7.js";import{c as ee,o as re,oa as ie,qa as Oe}from"./chunk-WRUW2UIJ.js";import{c as Te}from"./chunk-FJGJQGYF.js";import{a as k}from"./chunk-HJLGRW4A.js";import"./chunk-XIP32WI7.js";import"./chunk-FVGUBIVT.js";import"./chunk-ZY4XAKNQ.js";import{a as W}from"./chunk-DSPLGTQI.js";import"./chunk-6BTJNSQQ.js";import"./chunk-PWXN3W4Q.js";import"./chunk-WOT6VMZA.js";async function lt(T,r,D){if(r.status!=="complete")throw new k("INVALID_RESPONSE","A verified completed purchase is required");let O=T?re.parse(T):null;if(await D.onComplete?.(r),!O||!D.check)return;let S=re.parse(await D.check());if(S.internal_feature_id!==O.internal_feature_id||S.quantity!==O.quantity||O.observation!==void 0&&(S.observation===void 0||S.observation.requirementDigest!==O.observation.requirementDigest||S.observation.authority!==O.observation.authority||Te(S.observation.subject)!==Te(O.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");S.allowed&&await D.onAccessGranted?.(S)}function De(T){return Object.entries(T.document.buttons).filter(([,r])=>r.type==="checkout"&&r.product.type==="fixed"&&!te(r.product,{},T.capabilities)).map(([r])=>r)}async function zt(T,r,D){let O=it(T.ownerDocument),S=()=>{C.finish("dismissed"),O()},B=()=>S(),C=tt(T,r,"paywall",()=>{S(),W(r.onDismiss)});r.signal?.throwIfAborted(),r.signal?.addEventListener("abort",B,{once:!0});let G=null,_,h,Le;try{if(C.start(!0),C.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(G=r.check?re.parse(await C.wait(r.check(),pe)):null,G?.allowed)return C.finish("skipped"),r.signal?.removeEventListener("abort",B),O(),await r.onAccessGranted?.(G),{check:G,host:null};let[e,t]=await Promise.allSettled([C.wait(import("./screen-renderer-W5MP4KVG.js")),C.wait(r.start().then(s=>(C.cancelled&&s.destroy(),s)),pe)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;Le=e.value,_=t.value,r.signal?.throwIfAborted(),_.signal?.throwIfAborted(),_.signal?.addEventListener("abort",B,{once:!0});let n=_.view??await C.wait(_.refresh(),pe);if(!n)throw new k("INVALID_RESPONSE","Paywall presentation is missing");_.signal?.throwIfAborted(),h=n}catch(e){throw C.finish("error",e),r.signal?.removeEventListener("abort",B),_?.signal?.removeEventListener("abort",B),_?.destroy(),O(),e}let i=_,{mountScreenPreview:ut}=Le,d=T.ownerDocument,fe=new AbortController,I=d.createElement("section"),Y=d.createElement("div"),U=d.createElement("div"),u=d.createElement("p"),y=d.createElement("button"),b=d.createElement("button"),w=d.createElement("dialog"),a=h.document.screen.strings.defaultLocale.startsWith("zh"),dt=a?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",pt=a?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",P=at(h.document.screen.theme);I.dataset.indianaPaywall="",I.setAttribute("aria-label",h.document.name),I.style.cssText=P.root,U.style.cssText=P.controls,u.style.cssText=P.message,u.setAttribute("role","status"),b.style.cssText=P.link,b.textContent=a?"\u5173\u95ED":"Close",y.style.cssText=P.secondary,y.textContent=a?"\u91CD\u8BD5":"Retry",y.hidden=!0,U.append(u,y,b),I.append(Y,U);let Me=()=>{let e=H??U,t=[...e.children].every(s=>s===u?!u.textContent:s.hidden),n=[...e.children].some(s=>s===b?!1:s===u?!!u.textContent:!s.hidden);e.style.cssText=t?P.controls.replace(/padding:[^;]+/,"padding:0"):n?`${P.controls};${P.pinned}`:P.controls,we()},_e=typeof MutationObserver>"u"?void 0:new MutationObserver(Me);_e?.observe(I,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let J=h.document.presentation,F,Ue,me=!1,$e=JSON.stringify(h.capabilities),qe=e=>K?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):De(e);function he(e){if(p)return;h=e;let t=JSON.stringify(e.capabilities);t!==$e&&(F?.updateCapabilities(e.capabilities,qe(e)),$e=t),mt(e)}let g,ye=0;function we(){let e=d.defaultView;if(!g?.responsive||!e)return;let t=H??U,n=e.innerHeight-(g.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",ye=Math.max(1,n-t.getBoundingClientRect().height),F?.resizeViewport?.(ye,e.innerWidth)}let p=!1,K=!1,E=null,ae=!1,Ve=!1,j=!1,be,ge=!1,V,H;function ft(){return K||p||V||ge?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:Se(i)}let R=()=>!p&&!ae&&!V&&r.canInteract?.()!==!1,oe=!1,l=null,$=null;function mt(e){K||E||i.quote||i.operation||(u.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":a?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let ve=new Map,Ce=!1;function ht(e,t,n,s){let o=e.lines.length===1?e.lines[0]:void 0,m=te(n,s,t.capabilities);if(!o||!m||o.productVersionId!==m)return!1;let x;try{x=Oe(t.document.screen,m,s,t.capabilities)}catch{return!1}let A=Object.fromEntries((o.prepaid??[]).map(z=>[z.internal_feature_id,z.quantity]));return[...new Set([...Object.keys(x),...Object.keys(A)])].every(z=>(x[z]??0)===(A[z]??0))}let se=e=>Ge({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:p,canReselect:i.canReselect});async function Pe(e){let t=e.merchantExecution;if(!(!R()||!e.checkoutUrl||r.checkoutNavigation==="after_confirmation"&&se(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||ve.get(e.operationId)===e.checkoutUrl)){ve.set(e.operationId,e.checkoutUrl);try{r.onCheckoutUrl?await r.onCheckoutUrl(e.checkoutUrl):d.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw ve.delete(e.operationId),n}}}let Q=(e,t=!1)=>{if(t){let n=e instanceof k?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(l=null,u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u4E3A\u6B64\u5957\u9910\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002":"Pricing for this plan is unavailable. Payment hasn\u2019t started."):i.canReselect===!0&&!E?u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u65B0\u9009\u62E9\u5957\u9910\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Choose a plan again.":n==="COMMAND_PENDING"?u.textContent=a?"\u4ECD\u5728\u51C6\u5907\u62A5\u4EF7\uFF0C\u8BF7\u91CD\u8BD5\u4EE5\u67E5\u770B\u7ED3\u679C\u3002":"Your price is still being prepared. Retry to check the result.":u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u8BD5\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Try again."}else u.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?ot(e,a):e instanceof k?e.message:a?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";y.hidden=l===null,t&&!g?.responsive&&u.scrollIntoView?.({block:"nearest"}),W(t&&D?.quoteError?D.quoteError:r.onError,e)},ce=new WeakMap;function le(e){K=e,F?.updateCapabilities?.(h.capabilities,qe(h));for(let t of $?.querySelectorAll("button")??[])e?(ce.set(t,t.disabled),t.disabled=!0):ce.has(t)&&(t.disabled=ce.get(t),ce.delete(t)),Ne(t)}function Ee(){u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"This action is unavailable right now. Try again in a moment."}async function yt(e){if(r.beforeAction)try{await r.beforeAction()}catch(t){throw l=e,t}}async function q(e){if(K||p)return;if(!R()){Ee();return}let t=e===ue,n=t?pt:dt;le(!0),y.hidden=!0,u.textContent=n;try{if(await yt(e),p)return;if(!R()){l=e,y.hidden=!1,Ee();return}await e()}catch(s){p||Q(s,t)}finally{le(!1),u.textContent===n&&(u.textContent="")}}async function wt(e){await lt(G,e,r)}function He(e){return Se(i).type==="recording"||se(e).type==="recording"}function Be(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],s=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),o=t?n.length===1&&n[0]?.amountMinor===s&&n[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===s&&e.lines[0],m=s===null?ee(t.subtotalMinor-t.discountMinor,e.currency)+(a?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):ee(s,e.currency)+(o?ie(o.interval,a?"zh-CN":"en",o.intervalCount??1):""),x=e.lines.map(A=>A.productName).join(", ");return{label:x?`${x} \xB7 ${m}`:m,recurring:o}}async function N(e,t=r.checkoutNavigation!=="after_confirmation"){if(p)return;if(!R()){l=async()=>N(await i.read()),y.hidden=!1;return}if(u.textContent=ct(e.status,a),He(e)){let o=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";u.textContent=o?a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u4F46\u4EA4\u6613\u8BB0\u5F55\u5931\u8D25\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u4FEE\u590D\uFF0C\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u8BB0\u5F55\u3002\u8BF7\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",y.textContent=a?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",l=async()=>N(await i.read()),y.hidden=!1;return}if(e.problem){let o=e.problem;l=ne,y.textContent=a?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",Q(new k(o.code,o.reason==="RESULT_UNKNOWN"?a?"\u4ED8\u6B3E\u7ED3\u679C\u5C1A\u672A\u786E\u5B9A\uFF0C\u8BF7\u6062\u590D\u539F\u64CD\u4F5C\uFF0C\u6682\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"The payment result is unknown. Recover the original purchase before buying again.":o.phase==="fulfillment"?a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":o.code==="CAPABILITY_UNAVAILABLE"?a?"\u5546\u6237\u5C1A\u4E0D\u652F\u6301\u672C\u6B21\u8D2D\u4E70\u6240\u9700\u7684\u5B8C\u6574\u80FD\u529B\uFF0C\u8BF7\u5904\u7406\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":o.code==="NOT_CONFIGURED"?a?"\u4ED8\u6B3E\u670D\u52A1\u8FDE\u63A5\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":a?"\u539F\u8D2D\u4E70\u64CD\u4F5C\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u67E5\u8BE2\u6216\u6062\u590D\u6B64\u64CD\u4F5C\u3002":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,o));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(u.textContent=a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u6B63\u5728\u7B49\u5F85\u5546\u6237\u5B8C\u6210\u5904\u7406\u3002":"Payment was recorded. Waiting for merchant fulfillment."),e.status==="complete"){l=null,await wt(e);return}if(e.status!=="pending"){if(i.canReselect===!1){u.textContent=a?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",y.textContent=a?"\u67E5\u8BE2\u7ED3\u679C":"Check result",l=async()=>N(await i.read()),y.hidden=!1;return}e.status==="cancelled"?u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u5DF2\u53D6\u6D88\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u672A\u80FD\u5B8C\u6210\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase didn\u2019t go through. Choose a plan to try again."),y.textContent=a?"\u91CD\u8BD5":"Retry",l=null,E=null;return}if(!t&&se(e).type==="checkout"){let o=i.quote,m=o?.operationId===e.operationId?Be(o).label:"";u.textContent=Ce?m?a?`${m} \u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002`:`${m} is still unpaid. Choose it again to continue paying.`:a?"\u4E4B\u524D\u7684\u8D2D\u4E70\u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",Ce=!1,l=null;return}await Pe(e);let n=Date.now()+6e5,s=2e3;me=!0,W(r.onObservationChange,!0);try{for(;!p&&Date.now()<n;){if(await st(s,d,fe.signal),p)return;if(!R()){l=async()=>N(await i.read()),y.hidden=!1;return}let o=await i.read();if(!t&&se(o).type==="checkout"){await N(o,!1);return}if(!o.problem&&o.status==="pending"&&await Pe(o),o.status!=="pending"||o.problem||He(o)){await N(o);return}s=Math.min(s*1.5,3e4)}}finally{me=!1,W(r.onObservationChange,!1)}l=async()=>N(await i.read()),y.hidden=!1}async function xe(e=!1){let t=await i.read();if(p)return;if(!R()){l=()=>xe(e),y.hidden=!1;return}let n=i.quote;if(n&&Je(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&t.status==="pending"&&t.quoteFinalized===!1&&!t.confirmedAt&&!t.checkoutUrl&&!t.nativePurchase&&!t.merchantExecution&&!t.problem&&!i.pendingCancellation){Fe(n);return}await N(t,e||void 0)}async function ne(){$?.remove(),$=null,l=ne;let e=await i.confirm();if(!R()){l=ne,y.hidden=!1;return}if(e.problem){await N(e);return}if(e.status==="pending"){if(e.checkoutUrl)await Pe(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!r.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await r.onPurchase({operation:e,signal:fe.signal})}}l=async()=>N(await i.read()),await N(e,!0)}function Fe(e){$?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());u.textContent=t?a?"\u6B64\u62A5\u4EF7\u5DF2\u8FC7\u671F\u3002\u8BF7\u5148\u53D6\u6D88\uFF0C\u518D\u91CD\u65B0\u9009\u62E9\u3002":"This quote has expired. Cancel it, then choose again.":"";let n=d.createElement("div"),s=d.createElement("button"),o=d.createElement("button"),m=d.createElement("div"),x=d.createElement("p"),A=e.merchantTerms,de=a?"zh-CN":"en",z=A?.subscriptionTerms?.items??[],Re=A?A.subscriptionTerms?.trial?.days:e.lines.find(c=>c.trial)?.trial?.days,Z=Re===void 0?null:A?A.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(c=>c.trial)?0:null,je=(c,f)=>a?`${f} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${c}`:`Then ${c} after the ${f}-day trial`,{label:bt,recurring:Qe}=Be(e),gt=e.lines.map(c=>c.productName).join(", "),ze=Z===null?"":`${a?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${ee(Z,e.currency)}`;x.textContent=ze?[gt,ze].filter(Boolean).join(" \xB7 "):bt,s.textContent=a?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",s.disabled=t,o.textContent=a?"\u53D6\u6D88":"Cancel",n.style.cssText=P.panel,x.style.cssText=P.summary,m.style.cssText=P.actions,s.style.cssText=P.primary,o.style.cssText=P.secondary,Ne(s),s.onclick=()=>{q(ne)};let We=async()=>{let c=await i.cancel();p||(n.remove(),$=null,await N(c))};o.onclick=()=>{l=We,q(We)};let L=d.createElement("div");if(L.style.cssText=P.terms,A){for(let f of z){if(Z===null&&f===Qe)continue;let v=d.createElement("p"),M=ee(f.amountMinor,e.currency)+ie(f.interval,de,f.intervalCount);v.textContent=Z!==null&&Re!==void 0?je(M,Re):M,L.append(v)}let c=A.subscriptionTerms?.trial;if(c){let f=d.createElement("p");f.textContent=a?`\u8BD5\u7528 ${c.days} \u5929\uFF1B${c.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${c.days}; ${c.cardRequired?"a payment method is required":"no payment method is required"}`,L.append(f)}for(let f of[...A.expectedEffects.map(v=>v.description),...A.requiredConsents.map(v=>v.summary)]){let v=d.createElement("p");v.textContent=f,L.append(v)}}else{for(let c of e.lines){if(Z!==null||c!==Qe){let f=d.createElement("p"),v=`${ee(c.catalogAmountMinor,e.currency)}${ie(c.interval,de,c.intervalCount??1)}`;f.textContent=Z!==null&&c.trial?(e.lines.length>1?`${c.productName} \xB7 `:"")+je(v,c.trial.days):`${c.productName} \xB7 ${v}`,L.append(f)}for(let f of c.prepaid??[]){let v=d.createElement("p"),M=i.view?.capabilities.plans[c.productVersionId]?.prepaid?.find(vt=>vt.internalFeatureId===f.internal_feature_id);v.textContent=`${M?.name??f.internal_feature_id} \xB7 ${f.quantity} ${a?"\u4EFD":"packs"} \xD7 ${f.terms.units}`,M&&(v.textContent+=ie(M.reset==="week"||M.reset==="month"||M.reset==="year"?M.reset:"one_time",de,M.resetCount)),L.append(v)}if(c.trial){let f=d.createElement("p");f.textContent=a?`\u8BD5\u7528 ${c.trial.days} \u5929\uFF1B${c.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${c.trial.days}; ${c.trial.cardRequired?"a payment method is required":"no payment method is required"}`,L.append(f)}}if(!e.charge){let c=d.createElement("p");c.textContent=a?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",L.append(c)}}for(let c of L.children)c.style.margin="0";m.append(s,o),n.append(x,...L.childElementCount?[L]:[],m),U.prepend(n),g?.responsive||n.scrollIntoView?.({block:"nearest"}),s.focus({preventScroll:!0}),$=n,l=null}async function ue(){if(!E)return;if(l=ue,!oe){let n=i.view,s=n?.document.buttons[E.actionId],o=n&&s?.type==="checkout"?te(s.product,E.selection,n.capabilities):null;if(!o)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let m=await r.resolveOfferId?.({actionId:E.actionId,productVersionId:o});if(p)return;m!==void 0&&(E.offerId=m),oe=!0}if(!R()){y.hidden=!1;return}let e;try{e=await i.preview(E)}catch(n){throw i.canReselect===!0&&(E=null,oe=!1,l=null),n}if(p)return;let t=e.merchantTerms;if(r.confirmOnHostedCheckout&&R()&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){let n=a?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";u.textContent=n;try{await ne()}catch(s){p||Q(s)}finally{u.textContent===n&&(u.textContent="")}return}Fe(e)}function X(e="destroy"){p||(p=!0,r.signal?.removeEventListener("abort",B),i.signal?.removeEventListener("abort",B),C.finish("dismissed"),Ue?.(),fe.abort(),_e?.disconnect(),g?.destroy(),F?.destroy(),i.destroy(),w.open&&w.close(),w.remove(),I.remove(),O(),e==="dismiss"&&W(r.onDismiss))}S=X;async function ke(){if(!j||p||ae||V==="closing"||!V&&!R())return;if(!D){X("dismiss");return}let e=d.createElement("p");e.setAttribute("role","status"),e.textContent=a?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",H||(H=d.createElement("div"),H.style.cssText=U.style.cssText,U.replaceWith(H),Y.inert=!0),b.hidden=!1,H.replaceChildren(e,b),V="closing",b.setAttribute("aria-disabled","true"),b.focus({preventScroll:!0});try{await D.dismiss()}catch(t){p||W(r.onError,t)}p||(V="retry",e.textContent=a?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",b.textContent=a?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",b.removeAttribute("aria-label"),b.removeAttribute("aria-disabled"))}b.onclick=()=>{ke()},w.addEventListener("cancel",e=>{e.preventDefault(),ke()}),y.onclick=()=>{l&&q(l)};function Ie(e){C.finish("error",e),X()}function Ae(){if(!(!Ve||j||p||ae||g&&!R()))try{let e=t=>{be?.(),g&&(w.showModal(),g.responsive&&w.focus({preventScroll:!0}),!t&&r.loading!=="host"&&Ze(w,g.type,g.responsive)),j=!0};D?D.present(()=>C.present(()=>e(!0))):C.present(e)}catch(e){Ie(e),Q(e)}}try{if(J.type==="inline")b.hidden=Object.values(h.document.buttons).some(t=>t.type==="close"),Me(),be=rt(I,T),T.append(I);else{let t={sm:420,md:640,lg:900};w.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in J?t[J.size]+"px":"100vw"}`,w.setAttribute("aria-label",h.document.name),b.textContent="\xD7",b.setAttribute("aria-label",a?"\u5173\u95ED":"Close"),et(b,h.document.screen.theme),Ke(h.document)?(b.hidden=!0,w.append(I)):w.append(b,I),T.append(w),g=Xe(w,{...h.document.screen,presentation:J},we),g.latch(),g.responsive&&(I.style.display="flex",I.style.flexDirection="column",I.style.maxHeight="100%",Y.style.overflow="clip",Y.style.minHeight="0"),be=nt(w)}F=ut(Y,{mode:"live",rendererUrl:i.webViewUrl,title:h.document.name,hostPresentation:()=>g?.type??J.type,reportContentHeight:g?.responsive,onResize:t=>{if(!g?.responsive)return;let n=Math.min(t,ye);Y.style.height=`${n}px`,g.setContentHeight(n+(H??U).getBoundingClientRect().height)},onAction(t,n={}){if(!j||p||V)return;if(!R()){Ee();return}let s=i.view,o=s?.document.buttons[t];if(!o)return;if(o.type==="close"){q(async()=>{await r.onAction?.(t),X(r.onAction?"action":"dismiss")});return}if(o.type==="action"){l=async()=>{if(o.action.type==="event"){if(!r.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await r.onEvent(o.action.event)}else r.onOpenUrl?await r.onOpenUrl(o.action.url):d.defaultView?.location.assign(o.action.url);await r.onAction?.(t),l=null},q(l);return}if($&&i.canReselect===!1){u.textContent=a?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",g?.responsive||$.scrollIntoView?.({block:"nearest"}),$.querySelector("button")?.focus({preventScroll:!0});return}if((i.quote||E)&&i.canReselect===!1){let x=!!s&&!!i.quote&&ht(i.quote,s,o.product,n);Ce=!!i.quote&&!x,l=i.quote?()=>xe(x):ue,q(l);return}let m=s&&te(o.product,n,s.capabilities);if(!s||!m){Q(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(r.onPurchaseIntent){l=null,q(async()=>{let x={actionId:t,productVersionId:m,selection:structuredClone(n),featureQuantities:Oe(s.document.screen,m,n,s.capabilities)};ge=!0,await r.onPurchaseIntent(x)});return}if(E&&E.actionId!==t){Q(new k("COMMAND_PENDING","Finish the current purchase"));return}E||(E={requestId:crypto.randomUUID(),actionId:t,selection:n},oe=!1),q(ue)},onEscape:()=>{ke()},onError:t=>{let n=new Error(t);!j&&!p&&Ie(n),Q(n)},onRendered:t=>{t&&w.setAttribute("aria-label",t),Ve=!0,Ae()}}),we(),F.update(h.document.screen,h.document.screen.strings.defaultLocale,{capabilities:h.capabilities,unavailableActions:De(h),serverInput:{bindings:[],answers:{}}}),Ue=i.subscribe?.(he),he(i.view??h),await C.wait(F.ready);let e=i.operation;(i.quote||e&&(e.confirmedAt||e.checkoutUrl||e.status==="complete"))&&(l=()=>xe(),q(l))}catch(e){throw Ie(e),e}return{check:G,host:{get observing(){return me},get recovery(){return ft()},async prepareFallback(){if(K||p||V||ge)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};le(!0);try{let e=await Ye(i);return e.type==="native"&&X(),e}finally{le(!1)}},setSuspended(e){ae=e,I.hidden=e,e&&w.open?w.close():!e&&!j?Ae():!e&&!p&&j&&J.type!=="inline"&&!w.open&&w.showModal()},destroy:X,refresh:async()=>{if(!R()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return he(e),Ae(),e}}}}export{zt as showPaywall};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-S57HRPT2.js";import"./chunk-EZ5RCVVY.js";import"./chunk-YXCEZAQL.js";import"./chunk-23WNEOK4.js";import"./chunk-JNSU2AP2.js";import"./chunk-WK4WQZHK.js";import"./chunk-QPHT6QHE.js";import"./chunk-4ZVVG5LM.js";import"./chunk-LZV4QJ5E.js";import"./chunk-ITVSLSRM.js";import"./chunk-SJSCROSL.js";import"./chunk-B3KFE57L.js";import"./chunk-ACFQLHJR.js";import"./chunk-BQLT2LDP.js";import"./chunk-XZEGVBAI.js";import"./chunk-J4VTKRH7.js";import"./chunk-WRUW2UIJ.js";import"./chunk-FJGJQGYF.js";import"./chunk-HJLGRW4A.js";import"./chunk-XIP32WI7.js";import"./chunk-3VUPVXAV.js";import"./chunk-FVGUBIVT.js";import"./chunk-ZY4XAKNQ.js";import"./chunk-DSPLGTQI.js";import"./chunk-6BTJNSQQ.js";import"./chunk-PWXN3W4Q.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
|
package/dist/popup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a}from"./chunk-
|
|
1
|
+
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a}from"./chunk-TF2OFTYS.js";import"./chunk-RBMOWJGE.js";import"./chunk-WRUW2UIJ.js";import"./chunk-FJGJQGYF.js";import"./chunk-HJLGRW4A.js";import"./chunk-XIP32WI7.js";import"./chunk-ZY4XAKNQ.js";import"./chunk-DSPLGTQI.js";import"./chunk-6BTJNSQQ.js";import"./chunk-PWXN3W4Q.js";import"./chunk-WOT6VMZA.js";export{p as formatCustomerDecimal,r as hostedRendererScript,o as hostedRendererShell,f as inspectCustomHtml,a as mountScreenPreview,x as preparePopup,m as prepareScreen,e as sanitizeCustomHtml,t as showPopup};
|
package/dist/react-native.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { f as createCustomerClient, d as createFunnelClient } from './funnel-process-client-
|
|
2
|
-
export { F as FunnelProcessAdapter, a as FunnelProcessOptions, c as createFunnelProcess } from './funnel-process-client-
|
|
3
|
-
import { I as IndianaOptions, d as SessionCredentials, E as Scope, z as createFunnelRunController, v as PaywallStartInput, j as createPaywallSession } from './funnel-local-client-
|
|
4
|
-
export { c as FunnelCommandStorage, F as FunnelRunController, r as LocalFunnelClientOptions, t as LongplayError, u as PaywallPurchaseInput, P as PaywallSession, w as PushHost, x as PushJournal, y as createFeatureClient, A as createLocalFunnelClient } from './funnel-local-client-
|
|
1
|
+
import { f as createCustomerClient, d as createFunnelClient } from './funnel-process-client-BEPv6guV.js';
|
|
2
|
+
export { F as FunnelProcessAdapter, a as FunnelProcessOptions, c as createFunnelProcess } from './funnel-process-client-BEPv6guV.js';
|
|
3
|
+
import { I as IndianaOptions, d as SessionCredentials, E as Scope, z as createFunnelRunController, v as PaywallStartInput, j as createPaywallSession } from './funnel-local-client-D7e3rP5-.js';
|
|
4
|
+
export { c as FunnelCommandStorage, F as FunnelRunController, r as LocalFunnelClientOptions, t as LongplayError, u as PaywallPurchaseInput, P as PaywallSession, w as PushHost, x as PushJournal, y as createFeatureClient, A as createLocalFunnelClient } from './funnel-local-client-D7e3rP5-.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { J as JsonValue } from './growth-rules-B4YYy64R.js';
|
|
7
7
|
export { C as ConfigurationStorage, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-DdTRUv7A.js';
|
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-D3UU546S.js";import"./chunk-2TPPGW7V.js";import{a as A}from"./chunk-S57HRPT2.js";import{e as P}from"./chunk-EZ5RCVVY.js";import"./chunk-YXCEZAQL.js";import{h as b,i as x,k as L}from"./chunk-2QQZSMTB.js";import"./chunk-23WNEOK4.js";import"./chunk-JNSU2AP2.js";import{F as C}from"./chunk-7Z7JT4HE.js";import"./chunk-WK4WQZHK.js";import"./chunk-QPHT6QHE.js";import"./chunk-4ZVVG5LM.js";import"./chunk-LZV4QJ5E.js";import"./chunk-ITVSLSRM.js";import"./chunk-SJSCROSL.js";import"./chunk-B3KFE57L.js";import"./chunk-ACFQLHJR.js";import"./chunk-BQLT2LDP.js";import"./chunk-XZEGVBAI.js";import"./chunk-J4VTKRH7.js";import"./chunk-WRUW2UIJ.js";import"./chunk-FJGJQGYF.js";import{a as r}from"./chunk-HJLGRW4A.js";import{h as R}from"./chunk-XIP32WI7.js";import"./chunk-3VUPVXAV.js";import"./chunk-FVGUBIVT.js";import"./chunk-ZY4XAKNQ.js";import"./chunk-DSPLGTQI.js";import"./chunk-6BTJNSQQ.js";import"./chunk-PWXN3W4Q.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-TF2OFTYS.js";import"./chunk-RBMOWJGE.js";import"./chunk-WRUW2UIJ.js";import"./chunk-FJGJQGYF.js";import"./chunk-HJLGRW4A.js";import"./chunk-XIP32WI7.js";import"./chunk-ZY4XAKNQ.js";import"./chunk-DSPLGTQI.js";import"./chunk-6BTJNSQQ.js";import"./chunk-PWXN3W4Q.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.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { F as FoundationApi, I as InvoiceModeParams } from './api-BpeJkr6U.js';
|
|
2
|
-
import { O as IndianaServerOptions, t as IndianaError, Q as FunnelProcessSuppression, T as FunnelProcessCommand, J as FunnelProcessResponse, C as CustomerSession, H as FunnelProcessOpenInput, M as FunnelProcessMutation, v as PaywallStartInput, P as PaywallSession, l as FeatureClientOptions, R as RemoteFeatureResult } from './funnel-local-client-
|
|
3
|
-
export { k as FeatureClient, g as FunnelStartInput, L as LocalFunnelClient, r as LocalFunnelClientOptions, y as createFeatureClient, U as createFunnelStartClient, A as createLocalFunnelClient } from './funnel-local-client-
|
|
2
|
+
import { O as IndianaServerOptions, t as IndianaError, Q as FunnelProcessSuppression, T as FunnelProcessCommand, J as FunnelProcessResponse, C as CustomerSession, H as FunnelProcessOpenInput, M as FunnelProcessMutation, v as PaywallStartInput, P as PaywallSession, l as FeatureClientOptions, R as RemoteFeatureResult } from './funnel-local-client-D7e3rP5-.js';
|
|
3
|
+
export { k as FeatureClient, g as FunnelStartInput, L as LocalFunnelClient, r as LocalFunnelClientOptions, y as createFeatureClient, U as createFunnelStartClient, A as createLocalFunnelClient } from './funnel-local-client-D7e3rP5-.js';
|
|
4
4
|
import * as zod from 'zod';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { S as StackNode } from './screen-CGCJ46b1.js';
|
package/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as pn}from"./chunk-
|
|
1
|
+
import{a as pn}from"./chunk-NH5ML5SB.js";import{a as I}from"./chunk-TMZGZAWM.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-5N7QFF5M.js";import{a as xt}from"./chunk-S57HRPT2.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-EZ5RCVVY.js";import"./chunk-YXCEZAQL.js";import{a as Te,b as oe,c as yt,d as It,e as wt,f as xe,g as vt,h as _e,i as dn,j as ln,k as mn}from"./chunk-2QQZSMTB.js";import{a as Et,b as Me}from"./chunk-23WNEOK4.js";import"./chunk-JNSU2AP2.js";import{A as Tt,C as V,D as N,a as Oe,e as ft,f as ht,l as gt,m as j,n as St,q as Ct,r as Rt,s as bt,t as At,u as Ot,z as pe}from"./chunk-7Z7JT4HE.js";import{c as f}from"./chunk-WK4WQZHK.js";import"./chunk-QPHT6QHE.js";import{e as at}from"./chunk-4ZVVG5LM.js";import{A as tt,B as Se,C as ae,E as ie,F as Ce,K as se,M as ce,N as nt,P as Ee,Q as rt,R as ot,d as Ge,e as je,h as we,p as ze,q as Ke,s as an,t as sn,w as cn,x as Q,y as J,z as re}from"./chunk-LZV4QJ5E.js";import{A as Re,B as st,C as ct,H as ut,I as dt,J as be,K as Ae,S as pt,T as de,U as Y,V as lt,_ as mt,d as ve,f as Ze,g as et,u as q,z as it}from"./chunk-ITVSLSRM.js";import"./chunk-SJSCROSL.js";import"./chunk-B3KFE57L.js";import"./chunk-ACFQLHJR.js";import"./chunk-BQLT2LDP.js";import"./chunk-XZEGVBAI.js";import{a as Ne,b as Le}from"./chunk-J4VTKRH7.js";import{V as Xe,Y as We,la as ue,n as un,p as $e,q as Qe,r as Je}from"./chunk-WRUW2UIJ.js";import{c as Ie}from"./chunk-FJGJQGYF.js";import{a as c}from"./chunk-HJLGRW4A.js";import{h as $}from"./chunk-XIP32WI7.js";import"./chunk-3VUPVXAV.js";import"./chunk-FVGUBIVT.js";import{b as u}from"./chunk-ZY4XAKNQ.js";import"./chunk-DSPLGTQI.js";import{a as Ye}from"./chunk-6BTJNSQQ.js";import"./chunk-PWXN3W4Q.js";import"./chunk-WOT6VMZA.js";var Mt=4,_t=[...tt,"requirement_checks","native_offers","preparations","benefit_claims","authorizations","business_results"],In=u.enum(_t),X=(e,n)=>u.array(e).max(n).refine(t=>new Set(t).size===t.length,"Declarations must be unique"),ke=u.strictObject({...ie.shape,bridgeVersion:u.literal(Mt),capabilities:X(In,_t.length),checkKinds:X(u.enum(["access","metered","credit"]),3),preparationActions:X(u.enum(["purchase","subscription_change","refund"]),3),authorizationKinds:X(u.enum(["auto_topup"]),1),nextActionTypes:X(u.enum(["redirect","authenticate"]),2),resultEvents:X(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("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`)}),W={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":u.strictObject({}),"requirement.check":$e,"operation.prepare":ze,"benefit.claim":Ue,"operation.read":qe},wn={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":ke,"requirement.check":Qe,"operation.prepare":Ke,"benefit.claim":Ve,"operation.read":He},Hn=u.enum(["bridge.ping","bridge.describe","requirement.check","operation.prepare","benefit.claim","operation.read"]);function Z(e,n){return u.strictObject({bridgeVersion:u.literal(Mt),requestId:u.uuid(),scope:Ce,command:u.literal(e),data:n})}var kt=u.discriminatedUnion("command",[Z("bridge.ping",W["bridge.ping"]),Z("bridge.describe",W["bridge.describe"]),Z("requirement.check",W["requirement.check"]),Z("operation.prepare",W["operation.prepare"]),Z("benefit.claim",W["benefit.claim"]),Z("operation.read",W["operation.read"])]),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",z="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
|
${J}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a,c as b}from"./chunk-
|
|
1
|
+
import{b as a,c as b}from"./chunk-RFUXSC52.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-RFUXSC52.js";import{b as ue}from"./chunk-J6KIN4RH.js";import{a as Ve,b as re,c as ce,d as de}from"./chunk-SLUA7ABW.js";import{a as J,b as F,c as ge,e as me}from"./chunk-S5H3WJVQ.js";import{a as ae,b as se,c as oe,d as le}from"./chunk-ZYTT7ZAB.js";import"./chunk-3VUPVXAV.js";import"./chunk-FVGUBIVT.js";import{b as o}from"./chunk-ZY4XAKNQ.js";import"./chunk-DSPLGTQI.js";import{c as te,e as ie,g as M}from"./chunk-6BTJNSQQ.js";import"./chunk-PWXN3W4Q.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:ue(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=oe(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=ae(e.deviceIdCookie??"indiana_did"),T=se(),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(ce(`${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=le(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=de(()=>{i&&!t&&V()});return{async start(){if(!(i||t)){i=!0,e.appManifestRelease&&(B=re(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
package/dist/chunk-3GT4A3TA.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as e}from"./chunk-7GD2UTBU.js";var c=e.enum(["replace","stack_native"]);export{c as a};
|
package/dist/chunk-IDMOAV63.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as kn,b as rn,c as on,d as _e,e as Fn,f as We,h as Dn}from"./chunk-K72QA2PO.js";import{c as Cn,d as Pn,e as Rn,f as Ae,g as Be,h as En,i as je,k as qn}from"./chunk-GOYKJHDV.js";import{$ as Qe}from"./chunk-2JTMXZ5M.js";import{a as ze,e as gn,f as vn,g as hn,h as In,i as bn}from"./chunk-KAXKYBSI.js";import{b as wn}from"./chunk-AZ53RDWO.js";import{R as fn,qa as yn}from"./chunk-4WBIACS2.js";import{a as P}from"./chunk-7EPE2PUN.js";import{b as Sn,e as On}from"./chunk-SLUA7ABW.js";import{d as Tn}from"./chunk-QZG2YXM4.js";import{a as le}from"./chunk-DSPLGTQI.js";import{b as mn}from"./chunk-O4KXODTJ.js";var Te=new WeakMap;function Bn(t){let y=t.view,w=y?.paywall?.resolution;if(!y||!["running","waiting"].includes(y.status)||y.stopped||!w||"document"in w||!t.resolvePaywall||t.identitySignal?.aborted)return;let e=JSON.stringify(w);if(Te.get(t)?.key===e)return;let c=JSON.parse(e),D=t.identitySignal,a=Promise.resolve().then(async()=>{D?.throwIfAborted();let o=await t.resolvePaywall(c);return D?.throwIfAborted(),o}),S={key:e,content:a};return Te.set(t,S),a.catch(()=>{}),()=>{Te.get(t)===S&&Te.delete(t)}}function Nn(t,y){let w=Te.get(t);return Te.delete(t),w?.key===JSON.stringify(y)?w.content:t.resolvePaywall(y)}async function An(t){let{session:y,load:w}=Qn(t);try{return await w(),y}catch(e){throw y.destroy(),e}}function Qn(t){let y=t.view;if(!y?.paywall)throw new P("INVALID_REQUEST","The current node is not a Paywall");let w=y.paywall.receiptId,e=y.nodeId,c=y.visit,D=y.paywall.resolution,a=y.paywall,S="document"in D?{document:D.document,offering:D.offering,capabilities:D.capabilities}:null;function o(){let i=a.resolution;return"document"in i?i:S&&{...i,document:S.document,offering:S.offering,capabilities:gn(i.capabilities,S.capabilities)}}function g(i){if(!vn(i,D))throw new P("INVALID_RESPONSE","The pinned Paywall binding changed")}let u=!1,q=new Set,A=null;function L(){let i=o();if(i&&!u)for(let l of q)le(l,structuredClone(i))}async function k(){U();let i=o();if(i)return structuredClone(i);if(!A){let l=(async()=>{if("document"in a.resolution||!t.resolvePaywall)throw new P("INVALID_RESPONSE","Public Paywall reader is unavailable");let p=await Nn(t,a.resolution);return U(),g(p),S={document:p.document,offering:p.offering,capabilities:p.capabilities},L(),o()})();A=l;let s=()=>{A===l&&(A=null)};l.then(s,s)}return A.then(l=>structuredClone(l))}let d=new AbortController,F=(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).find(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===c&&i.input.type==="paywall_quote")?.requestId??y.paywall.purchaseRequestId,R=0,V=null,b=new Set,J=null,h=new Map;function _(i){if(i.purchase&&i.purchase.receiptId!==w)throw new P("INVALID_RESPONSE","Purchase receipt changed");let l=i.run.paywall;return i.purchase??(l?.receiptId===w?l:null)}function U(){if(u)throw new P("IDENTITY_CHANGED","Paywall presentation has closed")}function z(i,l,s){if(U(),l!==R||s!==void 0&&a.quote?.operationId!==s)return!1;let p=a.selectionGeneration??0,I=i.run.paywall;if(I?.receiptId===w){if((I.selectionGeneration??0)<(a.selectionGeneration??0))return!1;g(I.resolution)}let C=_(i),B=I?.receiptId===w&&(I.selectionGeneration??0)>p,Q=B?C?.quote??null:C?.quote??a.quote,v=C?.operation??(Q?.operationId===a.quote?.operationId?a.operation:null);return Q&&v&&hn(v,{operationId:Q.operationId},"Purchase operation changed"),(B||Q?.operationId!==a.quote?.operationId)&&(R++,I?.receiptId===w&&(F=I.purchaseRequestId)),a={...a,...I?.receiptId===w?I:{},quote:Q,operation:bn(a.operation,v,!0)},L(),!0}function $(i,l,s){return new Promise((p,I)=>{let C=!1,B=()=>{clearTimeout(Re),d.signal.removeEventListener("abort",x)},Q=Ee=>{C||(C=!0,B(),p(Ee))},v=Ee=>{C||(C=!0,B(),I(Ee))},x=()=>v(new P("IDENTITY_CHANGED","Paywall presentation has closed")),Re=setTimeout(()=>v(new P("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,s)),Math.max(0,l-Date.now()));d.signal.addEventListener("abort",x,{once:!0}),d.signal.aborted&&x(),i.then(Q,v)})}function de(i){return new Promise(l=>{let s=()=>{clearTimeout(p),d.signal.removeEventListener("abort",s),l()},p=setTimeout(s,i);d.signal.addEventListener("abort",s,{once:!0}),d.signal.aborted&&s()})}function Y(i,l){U();let s=h.get(i)??t.pendingCommands?.find(C=>C.requestId===i)??t.pendingCommand;if(s?.operation==="submit"&&s.requestId===i&&s.nodeId===e&&s.visit===c){l.type==="paywall_quote"&&s.input.type==="paywall_quote"&&s.input.predecessor&&!l.predecessor&&(l={...l,predecessor:s.input.predecessor});let C=Qe.parse(s),B=Qe.parse({...s,input:l});if(C.operation!=="submit"||B.operation!=="submit"||JSON.stringify(C.input)!==JSON.stringify(B.input))throw new P("CONFLICT","A purchase request cannot change its input");return h.set(i,C),C}let p=t.view;if(!p||p.nodeId!==e||p.visit!==c||p.paywall?.receiptId!==w)throw new P("PRECONDITION_FAILED","The Paywall visit has changed");let I=Qe.parse({operation:"submit",requestId:i,nodeId:e,visit:c,revision:p.revision,input:structuredClone(l)});if(I.operation!=="submit")throw new P("INVALID_REQUEST","A purchase submission is required");return h.set(i,I),I}async function ce(i,l){U();let{requestId:s,input:p}=i,I=Date.now()+3e4;b.add(s);try{let C=await $(t.submit(i),I,s);for(;C.run.pendingRequest?.requestId===s&&Date.now()<I&&!u&&(await de(Math.min(1e3,I-Date.now())),!(u||Date.now()>=I));)C=await $(t.resume(s),I,s);if(u)throw new P("IDENTITY_CHANGED","Paywall presentation has closed");if(C.run.pendingRequest?.requestId===s)throw new P("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,s);if(!z(C,l,p.type==="paywall_confirm"||p.type==="paywall_cancel"?p.operationId:void 0))throw new P("PRECONDITION_FAILED","The purchase selection has changed");J===s&&(J=null)}catch(C){throw J=s,C instanceof P&&C.code==="COMMAND_PENDING"&&C.status===void 0&&h.delete(s),C}finally{b.delete(s)}}async function re(i){if(!a.quote)throw new P("INVALID_REQUEST","A quoted purchase is required");let l=i==="confirm"?"paywall_confirm":"paywall_cancel",s=[...h.values(),...t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])].find(I=>I.operation==="submit"&&I.input.type===l&&"operationId"in I.input&&I.input.operationId===a.quote.operationId),p=s?.operation==="submit"&&s.input.type===l&&"operationId"in s.input&&s.input.operationId===a.quote.operationId?s.requestId:crypto.randomUUID();if(await ce(Y(p,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:a.quote.operationId}),R),!a.operation)throw new P("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(a.operation)}let T={get view(){return structuredClone(o())},get quote(){return a.quote?structuredClone(a.quote):null},get operation(){return a.operation?structuredClone(a.operation):null},get webViewUrl(){return t.webViewUrl},get canReselect(){return a.canReselect===!0},get recovery(){let i=t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[]),l=t.pendingPurchase;if(l&&(l.receiptId!==w||l.operationId!==a.quote?.operationId))return{type:"recover",operationId:l.operationId,requestId:i[0]?.requestId??null};let s=ze({quote:a.quote,operation:a.operation,requestId:i[0]?.requestId??J??F,pending:b.size>0||i.length>0||J!==null,destroyed:u,canReselect:a.canReselect});return s.type==="recover"&&s.requestId===null&&!u&&t.hasDurableJournal===!0&&!a.quote&&!a.operation&&(a.selectionGeneration??0)===0&&!l&&!i.length&&!b.size&&!F?{type:"native",operationId:null}:s},get pendingCancellation(){return!u&&(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).some(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===c&&i.input.type==="paywall_cancel"&&i.input.operationId===a.quote?.operationId)},subscribe(i){return u?()=>{}:(q.add(i),()=>q.delete(i))},async refresh(){U();let i=R,l=await t.get();if(z(l,i),l.run.paywall?.receiptId!==w)throw new P("PRECONDITION_FAILED","Paywall presentation has changed");return k()},preview(i){let l=o();if(!l)return Promise.reject(new P("PRECONDITION_FAILED","Load the Paywall presentation first"));if(F&&F!==i.requestId&&(V||a.canReselect!==!0))return Promise.reject(new P("COMMAND_PENDING","Retry the original purchase before starting another"));let s=l.document.buttons[i.actionId],p=s?.type==="checkout"?wn(s.product,i.selection,l.capabilities):null;if(!p)return Promise.reject(new P("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let I=yn(l.document.screen,p,i.selection,l.capabilities),C=F!==i.requestId&&(a.selectionGeneration??0)>0?{operationId:a.quote?.operationId??null,generation:a.selectionGeneration??0}:void 0;if(C&&a.canReselect!==!0)return Promise.reject(new P("COMMAND_PENDING","Original purchase requires authoritative termination"));let B;try{B=Y(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:p,...Object.keys(I).length?{featureQuantities:I}:{},...C?{predecessor:C}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{}})}catch(x){return Promise.reject(x)}if(F===i.requestId&&V)return V;F!==i.requestId&&R++;let Q=R;F=i.requestId;let v=(async()=>{if(await ce(B,Q),!a.quote)throw new P("INVALID_RESPONSE","The accepted quote is missing");return In(a.quote,{productVersionId:p,featureQuantities:I},"The selected purchase changed"),structuredClone(a.quote)})();return V=v,v.then(()=>{V===v&&(V=null)},x=>{V===v&&(V=null),F===i.requestId&&t.pendingCommand?.requestId!==i.requestId&&x instanceof P&&x.status!==void 0&&x.status<500&&![401,425].includes(x.status)&&(F=null)}),v},confirm:()=>re("confirm"),cancel:()=>re("cancel"),async read(){if(U(),!a.quote)throw new P("INVALID_REQUEST","A quoted purchase is required");let i=a.quote.operationId,l=R,s=t.pendingCommands?.find(Q=>Q.operation==="submit"&&(Q.input.type==="paywall_confirm"||Q.input.type==="paywall_cancel")&&Q.input.operationId===i)??t.pendingCommand;s?.operation==="submit"&&(s.input.type==="paywall_confirm"||s.input.type==="paywall_cancel")&&s.input.operationId===i&&await t.settle?.(s.requestId);let p=await t.get(void 0,{receiptId:w,operationId:i});U();let I=_(p);if(I?.quote&&I.quote.operationId!==i||I?.operation&&I.operation.operationId!==i)throw new P("INVALID_RESPONSE","Purchase operation changed");let C=z(p,l,i),B=C?a.operation:I?.operation;if(!B)throw new P("INVALID_RESPONSE","The current purchase result is missing");return C&&b.size===0&&!(t.pendingCommands?.length??(t.pendingCommand?1:0))&&(J=null),structuredClone(B)},destroy(){u=!0,E(),q.clear(),d.abort(),h.clear()}},E=t.subscribe(i=>{u||i.nodeId!==e||i.visit!==c||i.paywall?.receiptId!==w||(i.paywall.selectionGeneration??0)<(a.selectionGeneration??0)||(g(i.paywall.resolution),a={...a,resolution:i.paywall.resolution},L())});return{session:T,load:k}}function _n(t){let y=new Set,w=new Set,e=null;async function c(o,g){let u=!1;for(;!t.stopped&&t.key===o&&t.client.pendingCommand?.requestId===g;){if(!t.client.settle)throw new P("COMMAND_PENDING","The original display acknowledgement is still pending");await t.client.settle(g),u=!0,t.client.pendingCommand?.requestId===g&&await new Promise(q=>setTimeout(q,1500))}t.stopped||t.key!==o||(u&&await t.client.get(),!(t.stopped||t.key!==o)&&y.add(o))}function D(o,g){e=g;let u=()=>{e===g&&(e=null),w.delete(o)};return g.then(u,q=>{u(),t.busy||t.fail(q)}),g}function a(o){if(t.reviewing||y.has(o)||w.has(o)||t.stopped)return;w.add(o);let g=async()=>{if(t.reviewing||t.stopped||t.key!==o||y.has(o)){w.delete(o);return}if(t.busy||t.client.pendingCommand){setTimeout(()=>{g()},250);return}let u=(async()=>{if(t.staleRead){if(await t.staleRead,t.stopped||t.key!==o)return;if(t.client.pendingCommand){setTimeout(()=>{g()},250);return}}let q=t.client.view,A=t.expected(),L=A.requestId;try{await t.client.submit({operation:"shown",...A})}catch(k){if(!(k instanceof P)||k.code!=="CONFLICT"||k.status!==409||t.client.pendingCommand)throw k;await t.client.get();let d=t.client.view;if(t.stopped||t.reviewing||t.key!==o||!d||!q||d.id!==q.id||d.source.versionId!==q.source.versionId||d.nodeId!==A.nodeId||d.visit!==A.visit||d.revision<=A.revision||d.stopped||!d.screen&&(!d.paywall||d.paywall.receiptId!==q.paywall?.receiptId)||!["running","waiting"].includes(d.status)||t.client.pendingCommand)throw k;let O=t.expected();L=O.requestId,await t.client.submit({operation:"shown",...O})}await c(o,L)})();D(o,u)};g()}function S(){if(e)return e;let o=t.client.pendingCommand;if(o?.operation!=="shown")return null;let g=t.key;return w.add(g),D(g,(async()=>{await t.client.retry(),await c(g,o.requestId)})())}return{report:a,settled:S,get inFlight(){return e}}}function Ln(t){let y={},w=new Map;async function e(c){let D=t.client.view,a=D?.screen,S=a?.customerData.nodes[c.nodeId];if(t.stopped||t.busy||!D||!a||!S)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(c.action)){let k=t.document,d=k?fn(k,c.nodeId):null,O=d?.type==="customer_data"?d.data.outputs?.[c.action]:void 0;O&&a.outputs.includes(O)?await t.perform(()=>t.client.submit({operation:"submit",...t.expected(),input:{type:"screen",output:O,answers:t.answers,selection:c.value?{[c.nodeId]:c.value}:{}}})):await t.onIntent?.(c,D);return}let g=c.action.startsWith("sources_")?S.resources.find(k=>k.key===c.value):null;if(c.action.startsWith("sources_")&&!g)throw new P("INVALID_REQUEST","Choose a current resource");let u=`${D.visit}:${c.nodeId}:${g?.key??""}`,q=w.get(u)??[null],L=y[c.nodeId]??{page:1,after:null,filter:"all",...g?{resourceKey:g.key}:{}};if(c.action==="filter"){let k=c.value;if(!k||!(S.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(k))throw new P("INVALID_REQUEST","Unknown data filter");L={page:1,after:null,filter:k},q.splice(0,q.length,null)}else if(c.action==="next"||c.action==="sources_next"){let k=g?.sources.at(-1),d=g?k?{kind:"ledger",cursor:{at:k.detail[0],id:k.id,type:"source"}}:null:a.dataCursors[c.nodeId];if(!d||!g&&!S.hasNext)return;q[L.page]=d,L={...L,page:L.page+1,after:d}}else if(c.action==="previous"||c.action==="sources_previous"){if(L.page<=1)return;L={...L,page:L.page-1,after:q[L.page-2]??null}}w.set(u,q),y={...y,[c.nodeId]:L},await t.perform(()=>t.client.get({nodeId:D.nodeId,visit:D.visit,revision:D.revision,components:y}))}return{get queries(){return y},intent:e,reset(){y={},w.clear()}}}function Vn(t){let{doc:y,holder:w,reviewHolder:e,mountScreenPreview:c}=t,D=!1,a,S=0,o=null,g="",u,q=new Map,A=d=>d?`${d.id}:${d.nodeId}:${d.visit}:${d.revision}:${d.paywall?.quote?.operationId??""}`:"";async function L(d){if(t.stopped||!t.client.review||D&&d===a&&u?.active)return;let O=!D||d!==a;D||(g=A(t.client.view),q.set(g,structuredClone(t.answers))),D=!0,a=d,w.hidden=!0,t.suspend(!0),e.hidden=!1;let F=++S;O&&(u?.finish("dismissed"),o?.destroy(),o=null,e.replaceChildren(),u=Be(e,t.loadingOptions,"funnel",()=>{k()}));let R=O?u:void 0;try{if(R?.start(!1,t.client.view?.locale),F!==S||t.stopped)return;let V=t.client.review(d),b=await(R?.wait(V,Ae)??V);if(t.stopped||F!==S||!D)return;if(!b.review)throw new P("INVALID_RESPONSE","Historical projection is missing");o?.destroy(),o=null,R||e.replaceChildren();let J=y.createElement("div"),h=R?je(J,e):()=>{};e.append(J);let _=b.run.locale.startsWith("zh"),U=t.chrome;J.style.cssText=U.history;let z=y.createElement("p");z.textContent=_?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",z.style.cssText=U.historyTitle,J.append(z);let $=y.createElement("p");$.style.cssText=U.historyNote,$.textContent=b.review.pages.length?_?"\u9009\u62E9\u4E00\u9875\u67E5\u770B\u5F53\u65F6\u7684\u5185\u5BB9\uFF0C\u56DE\u770B\u4E0D\u4F1A\u6539\u52A8\u4EFB\u4F55\u4FE1\u606F\u3002":"Choose a page to see it as it was. Nothing here can be changed.":_?"\u8FD8\u6CA1\u6709\u53EF\u56DE\u770B\u7684\u9875\u9762\u3002":"There are no earlier pages yet.",J.append($);let de=b.review.page?.receiptId,Y=y.createElement("div");Y.style.cssText=U.historyPages;for(let[T,E]of b.review.pages.entries()){let i=y.createElement("button");i.type="button",i.textContent=_?`\u7B2C ${T+1} \u9875`:`Page ${T+1}`;let l=de!==void 0&&E.receiptId===de;i.style.cssText=l?U.primary:U.secondary,l&&i.setAttribute("aria-current","page"),_e(i,()=>t.chrome.focus),i.onclick=()=>{L(E.receiptId)},Y.append(i)}if(Y.childElementCount&&J.append(Y),b.review.page){let T=b.review.page,E=y.createElement("div");E.inert=!0,E.style.cssText=U.historyPage,J.append(E),o=c(E,{mode:"live",rendererUrl:t.client.webViewUrl,title:T.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{F===S&&!t.stopped&&R?.present(h)},onError:l=>{if(F!==S||t.stopped)return;let s=new Error(l);R?.finish("error",s),o?.destroy(),o=null,J.remove(),t.fail(s)},onEscape:()=>{k()}});let i=o;if(i.update(T.document,b.run.locale,{serverInput:{bindings:T.inputs,answers:T.answers,values:T.values}}),await i.ready,t.stopped||F!==S||!D)return}let ce=_?{issued:"\u5DF2\u9886\u53D6",reserved:"\u5DF2\u9884\u7559",redeemed:"\u5DF2\u4F7F\u7528",expired:"\u5DF2\u8FC7\u671F",revoked:"\u5DF2\u64A4\u9500",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"},re=y.createElement("div");re.style.cssText=U.historyRecords;for(let T of[...b.review.coupons.map((E,i)=>`${_?"\u4F18\u60E0\u5238":"Coupon"} ${i+1}: ${ce[E.status]}`),...b.review.purchases.map((E,i)=>`${_?"\u8D2D\u4E70":"Purchase"} ${i+1}: ${Dn(E.status,_)}`)]){let E=y.createElement("p");E.textContent=T,E.style.margin="0",re.append(E)}re.childElementCount&&J.append(re),b.review.page||R?.present(h),t.client.view&&await t.enqueue(t.client.view)}catch(V){if(F!==S||t.stopped)return;R?.finish("error",V),o?.destroy(),o=null,e.replaceChildren(),t.fail(V)}}async function k(){if(!D||t.stopped||!t.client.review)return;let d=++S;u?.finish("dismissed");try{if(await t.client.review(),t.stopped||d!==S)return;D=!1,S++,u?.finish("dismissed"),o?.destroy(),o=null,e.replaceChildren(),e.hidden=!0,w.hidden=!1;let O=t.client.view;A(O)!==g?(q.set(g,structuredClone(t.answers)),t.resetScreen()):(q.delete(g),t.suspend(!1)),O&&await t.enqueue(O)}catch(O){if(d!==S||t.stopped)return;o?.destroy(),o=null,e.replaceChildren(),t.fail(O)}}return{get active(){return D},get receipt(){return a},open:L,exit:k,get drafts(){return new Map([...q].map(([d,O])=>[d,structuredClone(O)]))},stop(){D=!1,S++,u?.finish("dismissed"),o?.destroy(),o=null,e.replaceChildren(),e.hidden=!0,w.hidden=!1}}}function Mn(t){if(!t.client.pageExperiments)throw new Error("The Run controller does not support page experiments");let y=t.client.pageExperiments.bind(t.client),w=!1,e=!1,c=0,D=!1,a=!1,S="",o=()=>{let h=t.client.view;return JSON.stringify([h?.id,h?.source.versionId,h?.visit,h?.revision,h?.status,h?.stopped])},g=new Map,u=new Set,q={},A=new Map,L=Sn(t.appManifestRelease),k=()=>{for(let h of g.values())h.effect.revert();g.clear()},d=()=>{k();for(let h of A.values())h();A.clear()};function O(h){if(w||u.has(h))return;u.add(h);let _=c;y(t.appManifestRelease,[h]).catch(U=>{u.delete(h),!w&&_===c&&le(t.onError,U)})}async function F(){if(w)return;S=o();let h=t.client.view;if(!h||h.stopped||!["running","waiting"].includes(h.status)){c++,d();return}if(document.visibilityState==="hidden")return;if(D){a=!0;return}D=!0;let _=++c,U=`${h.id}:${h.visit}:${h.revision}`,z=location.href;try{let[$,{applyVisualVariation:de}]=await Promise.all([y(t.appManifestRelease),import("./visual-dom-5LUN4AHO.js")]),Y=t.client.view;if(w||_!==c||!Y||Y.stopped||!["running","waiting"].includes(Y.status)||`${Y.id}:${Y.visit}:${Y.revision}`!==U||location.href!==z)return;let ce=new Set,re=new Set;for(let T of $.assignments){let E=`${$.payload.environmentId}:${T.experimentKey}`;if(re.add(E),A.has(E)||A.set(E,On(E,q)),!!T.inExperiment)for(let i of $.payload.experiments){if(i.key!==T.experimentKey||!mn(location.href,i.urlPatterns??[]))continue;let l=i.meta?.findIndex(Q=>Q.key===T.variationKey)??-1,s=i.variations[l];if(!s?.renderGuard)continue;let p=T.receiptId+":"+i.changeId,I=JSON.stringify([T.variationKey,s]);ce.add(p);let C=g.get(p);if(C?.signature===I){C.effect.applied&&O(T.receiptId);continue}g.get(p)?.effect.revert(),g.delete(p);let B=de(s,{requireUniqueTargets:!0,boundVariations:i.variations,allowJs:!1,onApplied:()=>O(T.receiptId),onError:Q=>le(t.onError,Q)});g.set(p,{signature:I,effect:B}),B.applied&&O(T.receiptId)}}for(let[T,E]of g)ce.has(T)||(E.effect.revert(),g.delete(T));for(let[T,E]of A)re.has(T)||(E(),A.delete(T))}catch($){_===c&&d(),!w&&_===c&&le(t.onError,$)}finally{D=!1,a&&!w&&(a=!1,F())}}let R=t.client.subscribe(()=>{if(o()===S)return;S=o(),c++;let h=t.client.view;(!h||h.stopped||!["running","waiting"].includes(h.status))&&d(),e&&F()}),V=Tn(()=>{c++,d(),e&&F()}),b=()=>{c++,k()};document.addEventListener("visibilitychange",b);let J=We({document,run:async()=>{e&&await F()},delay:()=>e&&!w?15e3:void 0});return{async start(){e||w||(e=!0,await J.refresh())},refresh:F,destroy(){w=!0,c++,J.destroy(),document.removeEventListener("visibilitychange",b),R(),V(),d(),L.destroy()}}}var sn=5e3;async function zn(t,y,w){let e=y,[{mountScreenPreview:c},{showPaywall:D}]=await Promise.all([import("./screen-renderer-ITUUNF4E.js"),import("./paywall-BEFHTZW7.js")]),a=e.client.identitySignal;e.signal?.throwIfAborted(),a?.throwIfAborted();let S=e.appManifestRelease?Mn({client:e.client,appManifestRelease:e.appManifestRelease,onError:e.onError}):void 0;S?.start();let o=t.ownerDocument,g=qn(o),u=o.createElement("section"),q=o.createElement("div"),A=o.createElement("div"),L=o.createElement("div"),k=o.createElement("button");L.hidden=!0,k.type="button";let d=o.createElement("p"),O=o.createElement("p"),F=o.createElement("button"),R=o.createElement("button"),V=o.createElement("button"),b=o.createElement("dialog"),J;u.dataset.indianaFunnel="",u.setAttribute("aria-busy","false"),d.setAttribute("role","status"),O.setAttribute("role","alert"),O.hidden=!0,F.type=R.type=V.type="button",A.append(F,k,d,O,V,R),u.append(q,L,A),t.append(u);let h=kn,_=rn(h),U="",z=(o.documentElement.lang||"").startsWith("zh"),$,de="",Y;for(let n of[F,k,V,R])_e(n,()=>_.focus);function ce(){let n=z?"\u5173\u95ED":"Close";R.parentElement===b?(R.textContent="\xD7",R.setAttribute("aria-label",n),Rn(R,h)):(R.textContent=n,R.removeAttribute("aria-label"),R.style.cssText=_.link+";margin-inline-start:auto")}function re(n){let r=n?.screen?.content.document.theme??h,f=JSON.stringify([r.primary,r.background,r.text,r.radius,r.font,R.parentElement===b]);f!==U&&(U=f,h=r,_=rn(h,R.parentElement===b),u.style.cssText=_.root+";min-width:0",A.style.cssText=_.bar,F.style.cssText=k.style.cssText=_.secondary,V.style.cssText=_.primary,d.style.cssText=_.status,O.style.cssText=_.alert,ce(),on(F))}function T(){A.hidden=F.hidden&&k.hidden&&V.hidden&&O.hidden&&!d.textContent&&(R.hidden||R.parentElement!==A),$?.responsive&&Y!==void 0&&$.setContentHeight(Y+A.getBoundingClientRect().height)}re();let E=null,i=null,l=null,s="",p="",I=!1,C="",B="",Q="",v=!1,x=0,Re=!1,Ee="",Ke=null,Ye=Promise.resolve(),an=!e.client.view,W=w,qe,Oe,Le="",Ve,pe=!1,Ie=null,ye=!1,Me=()=>e.client.pendingCommand?.operation==="close",se=null,K=null,ln=We({document:o,run:async()=>{(!i?.observing||e.client.pendingCommand)&&await Ze()},delay:()=>{if(!(v||!l||!["running","waiting"].includes(l.status)&&!e.client.pendingCommand)&&!(i?.observing&&!e.client.pendingCommand))return l.pendingRequest||e.client.pendingCommand?1500:sn},hiddenDelay:()=>!v&&e.client.pendingCommand?15e3:void 0}),X=null;function Xe(){return K&&e.client.hasDurableJournal===!0&&X?.acknowledged===!0&&X.operationId===K.operationId&&e.client.view?.id===X.runId&&e.client.view?.status==="closed"&&e.client.view.revision===X.revision+1&&!(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0))&&!e.client.pendingPurchase?K:null}function un(n){let r=n.run.paywall;if(X&&n.settlement?.requestId===X.requestId&&n.settlement.state==="settled"&&n.settlement.operationId===null&&n.run.id===X.runId&&n.run.status==="closed"&&!n.run.pendingRequest&&n.run.revision===X.revision+1&&n.run.nodeId===X.nodeId&&n.run.visit===X.visit&&r?.receiptId===X.receiptId&&r.selectionGeneration===X.selectionGeneration&&(r.quote?.operationId??null)===X.operationId&&(r.operation?.operationId??r.quote?.operationId??null)===X.operationId){let f=X.operationId===null&&r.selectionGeneration===0&&!r.quote&&!r.operation&&!r.purchaseRequestId,ne=ze({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect});(f||r.canReselect===!0&&ne.type==="native")&&(X.acknowledged=!0)}}let ke=null,He=new Set,fe={},Fe=!1,ue=(n,r=null)=>{v||(ke=r,Fe=!1,O.textContent=Fn(n,z),O.hidden=!1,V.hidden=e.client.pendingCommand===null,T(),le(e.onError,n))};function be(){let n=e.client.view;if(!n)throw new P("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:n.revision}}let M=Vn({client:e.client,doc:o,holder:q,reviewHolder:L,mountScreenPreview:c,loadingOptions:e,get chrome(){return _},get stopped(){return v},get answers(){return fe},suspend(n){i?.setSuspended(n)},resetScreen(){s="",p="",C=""},enqueue:me,fail:ue}),$e=_n({client:e.client,expected:be,fail:ue,get stopped(){return v},get reviewing(){return M.active},get key(){return s},get busy(){return x},get staleRead(){return Ke}}),Ue=Ln({client:e.client,expected:be,perform:Se,onIntent:e.onCustomerDataIntent,get stopped(){return v},get busy(){return x},get document(){return E?.document},get answers(){return fe}}),xe=n=>`${n.id}:${n.nodeId}:${n.visit}`,De=n=>n&&(n.screen||n.paywall)?xe(n):"";function Ce(){let n=e.client.view;F.disabled=!M.active&&(x>0||!!e.client.pendingCommand||!n?.canBack||n.stopped||!["running","waiting"].includes(n.status)||!De(n)||p!==De(n)),F.hidden=!M.active&&!n?.canBack,on(F);let r=!!i&&!M.active;R.hidden=r&&!W?.active,k.hidden=!e.client.review||r&&!n?.canBack,r&&(d.textContent=""),T()}async function dn(n){if(!n)return;let r=e.client.view;await n;let f=e.client.view;if(!r||!f||f.id!==r.id||f.nodeId!==r.nodeId||f.visit!==r.visit||f.stopped||!["running","waiting"].includes(f.status))throw new P("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function Se(n,r=!1){if(!((x||ye||se||K)&&!r||v||M.active&&!r)){x++,u.setAttribute("aria-busy","true"),O.hidden=!0,ke=null,Fe=!1,Ce();try{if(r||await dn($e.inFlight),v)return;let f=await n();v||await me(e.client.view??f.run)}catch(f){ue(f,e.client.pendingCommand?.requestId??null)}finally{x=Math.max(0,x-1),u.setAttribute("aria-busy",String(x>0)),v||(V.hidden=e.client.pendingCommand===null,Ce())}}}function Ne(){ln.schedule()}async function Ze(){if(!(v||Re||x)){if(M.active){await M.open(M.receipt);return}Re=!0;try{let n=e.client.pendingCommand;n&&e.client.settle&&await e.client.settle(n.requestId);let r=e.client.view,f=Ue.queries,ne=await e.client.get(r?.screen&&Object.keys(f).length?{nodeId:r.nodeId,visit:r.visit,revision:r.revision,components:f}:void 0);Fe&&!v&&(Fe=!1,O.hidden=!0,T()),!v&&f===Ue.queries&&await me(e.client.view??ne.run)}catch(n){ue(n),Fe=!v}finally{Re=!1}}}function Ge(n,r){if(W?.active){let ne=W;return ne.setDismissHandler(()=>cn(ne)),ne}let f=Be(t,e,"funnel",()=>cn(f));return W=f,f.start(n,r),f}function cn(n){v||pe||(pe=!0,n.finish("dismissed"),ve(),u.hidden=!0,e.client.view?Pe().finally(ae):ae())}function en(){clearTimeout(Ve?.timeout),Ve=void 0}function ve(){en(),qe?.abort(),qe=void 0,E?.destroy(),E=null,i?.destroy(),i=null,Oe?.(),Oe=void 0,b.open&&b.close(),q.replaceChildren(),q.style.cssText="",Y=void 0,s="",p="",I=!1,C="",Q=""}function pn(){let n=o.defaultView;$?.responsive&&n&&E?.resizeViewport?.(n.innerHeight,n.innerWidth)}function nn(){$?.destroy(),$=void 0,de=""}function tn(n){let r=n.screen?.presentation;if(!r||r.type==="inline"){b.open&&b.close(),nn(),R.parentElement!==A&&A.append(R),u.parentElement!==t&&t.append(u),re(n),T();return}u.parentElement!==b&&(b.append(R,u),t.append(b)),re(n);let f=n.screen.content.document,ne=JSON.stringify([r,U]);if(ne!==de){nn(),de=ne;let ge={sm:420,md:640,lg:900},we="size"in r&&!r.backdrop?",0 0 0 100vmax #16142566":"";b.style.cssText=`box-sizing:border-box;padding:0;border:0;overflow:auto;background:${h.background};color:${h.text};`+(r.type==="fullscreen"?"width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border-radius:0":`width:${ge[r.size]}px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 24px 80px #0003${we};`+(r.type==="sheet"?"margin:auto auto 0;border-radius:14px 14px 0 0":"border-radius:14px")),$=Cn(b,{presentation:r,theme:f.theme,pages:f.pages},pn),$.latch()}T(),b.setAttribute("aria-label",(J?.screen===n.screen?.content.document.name?J?.label:void 0)??E?.document?.name??n.screen?.content.document.name??"Funnel")}async function Hn(n){if(v||pe||ye&&(Me()||["running","waiting"].includes(n.status))||(l=n,ke&&e.client.pendingCommand?.requestId!==ke&&(O.hidden=!0,ke=null),z=n.locale.startsWith("zh"),k.textContent=z?"\u56DE\u770B":"History",F.textContent=M.active?z?"\u8FD4\u56DE\u5F53\u524D":"Return to current":z?"\u8FD4\u56DE":"Back",ce(),V.textContent=z?"\u91CD\u8BD5":"Retry",V.hidden=e.client.pendingCommand===null,d.textContent=n.pendingRequest?z?"\u6B63\u5728\u5904\u7406":"Processing":n.instruction?.type==="wait"?z?"\u7B49\u5F85\u4E2D":"Waiting":"",Ce(),Ee!==`${n.revision}:${n.visit}:${n.status}:${n.stopped}`&&(Ee=`${n.revision}:${n.visit}:${n.status}:${n.stopped}`,le(e.onState,structuredClone(n))),v||pe))return;if((!n.pendingRequest||ye&&n.status==="closed")&&["closed","ineligible","failed"].includes(n.status)){ae();return}if(n.stopped||e.client.configurationReady===!1){M.stop(),ve(),W?.finish("skipped"),u.hidden=!0,Ne();return}if(u.hidden=!1,M.active){Ne();return}let r=De(n),f=e.client.view;if(f&&f.revision>n.revision&&De(f)!==r)return;let ne=!n.instruction&&!n.pendingRequest&&n.nodeType==="screen"&&["running","waiting"].includes(n.status);r!==s&&(s&&W?.finish("dismissed"),ve(),s=r,fe={...n.answers},Ue.reset());let ge=xe(n);if(Le===ge){u.hidden=!0;return}if(ne&&!r){u.hidden=!0;let G=Ge(!0,n.locale);!v&&!pe&&Ve?.key!==ge&&(en(),Ve={key:ge,timeout:setTimeout(()=>{let m=e.client.view;if(!G.active||!m||xe(m)!==ge)return;Le=ge;let j=new Error("Funnel screen preparation timed out");G.finish("error",j),ve(),ue(j)},Ae)}),Ne();return}en();let Z=G=>{let m=e.client.view;return!v&&!pe&&!Ie&&!G.aborted&&e.client.configurationReady!==!1&&!!m&&!m.stopped&&!["closed","ineligible","failed"].includes(m.status)&&De(m)===r},we=(G,m)=>{Z(m)&&(Le=r,W?.finish("error",G),ve(),u.hidden=!0,ue(G))};if(r||(tn(n),n.instruction?.type!=="event"&&n.instruction?.type!=="open_url"&&W?.finish("skipped")),n.screen){let G=n.screen.content;if(!E){let te=n.screen.presentation.type!=="inline",oe=Ge(te,n.locale);if(v||pe)return;let ie=(qe=new AbortController).signal;tn(n),Oe=te?En(b):je(u,t),E=c(q,{mode:"live",rendererUrl:e.client.webViewUrl,title:G.document.name,...te?{hostPresentation:()=>$?.type??n.screen.presentation.type}:{},onResize:ee=>{Y=ee,$?.responsive&&$.setContentHeight(ee+A.getBoundingClientRect().height)},onAction(ee,he={},Gn={}){if(M.active||!Z(ie)||p!==r)return;fe={...fe,...Gn};let Jn=Object.fromEntries((n.screen?.inputs??[]).filter(({variable:Je})=>Object.hasOwn(fe,Je)).map(({variable:Je})=>[Je,fe[Je]]));Se(()=>e.client.submit({operation:"submit",...be(),input:{type:"screen",output:ee,answers:Jn,selection:he}}))},onAnswers:ee=>{M.active||!Z(ie)||p!==r||(fe={...fe,...ee})},onCustomerDataIntent:ee=>{M.active||!Z(ie)||p!==r||Ue.intent(ee).catch(ue)},onEscape:()=>{!Z(ie)||p!==r||M.active||se||K||Pe()},onError:ee=>{let he=new Error(ee);p===r?ue(he):we(he,ie)},onRendered:ee=>{if(!(!Z(ie)||p===r))try{oe.present(he=>{Oe?.(),Oe=void 0,ee&&(J={screen:G.document.name,label:ee},b.setAttribute("aria-label",ee)),te&&(b.showModal(),$?.responsive&&b.focus({preventScroll:!0}),!he&&e.loading!=="host"&&Pn(b,$?.type??n.screen.presentation.type,$?.responsive)),p=r,I=te,Ce()}),Z(ie)&&$e.report(r)}catch(he){we(he,ie)}}}),pn()}let m={capabilities:n.screen.capabilities,customerData:n.screen.customerData,parameters:n.parameters,serverInput:{bindings:n.screen.inputs,answers:fe,values:n.screen.values}},j=JSON.stringify([G,n.locale,m.parameters,n.screen.inputs,n.screen.values]);if(j!==C)E.update(G.document,n.locale,m),C=j,B=JSON.stringify(m.capabilities),Q=JSON.stringify(m.customerData);else{let te=JSON.stringify(m.capabilities);te!==B&&(E.updateCapabilities(m.capabilities),B=te),JSON.stringify(m.customerData)!==Q&&(E.updateCustomerData(m.customerData),Q=JSON.stringify(m.customerData))}let H=E;if(H)try{await(W?.wait(H.ready)??H.ready)}catch(te){qe&&we(te,qe.signal)}}else if(n.paywall&&!i){let G=Ge(!0,n.locale);if(v||pe)return;let m=(qe=new AbortController).signal;tn(n);let j=await D(q,{loading:"host",signal:m,canInteract:()=>Z(m)&&!M.active&&!se&&!K,beforeAction:async()=>{x++;try{await dn($e.settled()),O.hidden=!0,ke=null,Fe=!1,T()}finally{x=Math.max(0,x-1)}},start:()=>An(e.client),onObservationChange:Ne,onPurchase:e.onPurchase,onCheckoutUrl:e.onCheckoutUrl,checkoutNavigation:e.checkoutNavigation,confirmOnHostedCheckout:e.confirmOnHostedCheckout,resolveOfferId:e.resolveOfferId,onEvent:e.onEvent,onOpenUrl:H=>e.onOpenUrl?e.onOpenUrl({receiptId:n.paywall.receiptId,url:H,openIn:"same_window"}):o.defaultView?.location.assign(H),onAction:async H=>{if(M.active)return;let te=await e.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:e.client.view?.revision??n.revision,input:{type:"screen",output:H,answers:{}}});await me(e.client.view??te.run)},onError:H=>{p===r?ue(H):we(H,m)}},{quoteError:H=>le(e.onError,H),present(H){Z(m)&&(G.present(()=>{H(),p=r,I=!!q.querySelector("dialog[open]"),Ce()}),Z(m)&&$e.report(r))},async dismiss(){v||m.aborted||M.active||se||K||!ye&&!Z(m)||(ye=!0,await Pe())}}).catch(H=>(we(H,m),null));!Z(m)&&!(ye&&!v&&!m.aborted)?j?.host?.destroy():j&&(i=j.host,i?.setSuspended(M.active))}if(v||pe)return;Ce();let N=n.instruction;if(N&&(N.type==="open_url"||N.type==="event")&&!He.has(N.receiptId)){let G=o.createElement("button");G.type="button",G.style.cssText=_.primary,_e(G,()=>_.focus),q.style.cssText=_.stage,G.textContent=N.type==="open_url"?`${z?"\u524D\u5F80":"Continue to"} ${new URL(N.url).host}`:z?"\u7EE7\u7EED":"Continue",G.onclick=()=>{let m=be(),j=N.type==="open_url"&&!e.onOpenUrl&&N.openIn==="new_window"?$n(N.url):null;Se(async()=>{let H="success";if(N.type==="open_url")if(e.onOpenUrl)try{H=await e.onOpenUrl({receiptId:N.receiptId,url:N.url,openIn:N.openIn})===!1?"failed":"opened"}catch(oe){le(e.onError,oe),H="failed"}else H=N.openIn==="new_window"&&!j?"failed":"opened";if(N.type==="event"){if(!e.onEvent)throw new P("EVENT_HANDLER_REQUIRED","Provide the event handler");await e.onEvent(N.event)}if(v||e.client.view?.nodeId!==m.nodeId||e.client.view.visit!==m.visit)throw new P("PRECONDITION_FAILED","The client action visit changed");let te=await e.client.submit({operation:"submit",...m,input:{type:"client_action",receiptId:N.receiptId,outcome:H}});return He.add(N.receiptId),N.type==="open_url"&&!e.onOpenUrl&&N.openIn==="same_window"&&o.defaultView?.location.assign(N.url),te})},W?.active?W.present(()=>q.replaceChildren(G)):q.replaceChildren(G)}!n.pendingRequest&&n.status==="completed"&&!He.has(`complete:${n.id}`)&&(He.add(`complete:${n.id}`),le(e.onComplete,structuredClone(n))),Ne()}function $n(n){let r=o.defaultView?.open(n,"_blank")??null;return r&&(r.opener=null),r}function me(n){return Ce(),Ye=Ye.catch(()=>{}).then(async()=>{try{await Hn(n)}catch(r){throw W?.active&&(Le=xe(n),W.finish("error",r),ve(),u.hidden=!0),r}}),Ye}let Un=e.client.subscribe(n=>{if(!an){if(n.stopped&&I&&!ye){l=n,ae();return}!ye&&(n.stopped||e.client.configurationReady===!1||s&&p!==s&&(De(n)!==s||["closed","ineligible","failed"].includes(n.status)))&&(ve(),W?.finish("dismissed"),u.hidden=!0),me(n).catch(ue)}}),xn=e.client.subscribeError?.(ue);function Pe(n){if(Ie)return Ie;if(v||!n&&(se||K))return Promise.resolve();let r=!n&&Me();return!r&&e.client.view&&!["running","waiting"].includes(e.client.view.status)?(l=e.client.view,ae(),Promise.resolve()):(Ie=Se(async()=>{let f=r?await e.client.retry():await e.client.submit({operation:"close",...n??be()});return n&&un(f),f},!0).then(()=>{let f=e.client.view;f?.status==="closed"&&!Me()&&(l=f,ae())}).finally(()=>{Ie=null}),Ie)}function ae(){S?.destroy(),!v&&(v=!0,e.signal?.removeEventListener("abort",ae),a?.removeEventListener("abort",ae),W?.finish("dismissed"),ln.destroy(),Un(),xn?.(),ve(),nn(),M.stop(),b.remove(),u.remove(),g(),le(e.onDismiss,l?structuredClone(l):null))}F.onclick=()=>{if(!F.disabled){if(M.active){M.exit();return}Se(()=>e.client.submit({operation:"back",...be()}))}},k.onclick=()=>{M.open()},R.onclick=()=>{W?.active?W.dismiss():se||Pe()},V.onclick=()=>{Me()?Pe():Se(()=>e.client.retry())},b.addEventListener("cancel",n=>{n.preventDefault(),W?.active?W.dismiss():se||Pe()}),e.signal?.addEventListener("abort",ae,{once:!0}),a?.addEventListener("abort",ae,{once:!0});try{let n=e.client.view;if(n)((e.client.viewAgeMs??sn)>=sn||n.instruction?.type==="evaluate_segment")&&(Ke=Ze().finally(()=>{Ke=null})),await me(n);else{u.hidden=!0;let r=Ge(e.client.view?.screen?.presentation.type!=="inline",e.client.view?.locale);if(v||pe)throw new DOMException("Presentation cancelled","AbortError");let f=await r.wait(e.client.get(),Ae);an=!1,await me(e.client.view??f.run)}}catch(n){throw W?.finish("error",n),ae(),n}return{destroy:ae,refresh:Ze,get recovery(){let n=Xe();if(n)return n;if(!v&&!x&&!ye&&!se&&i){let r=i.recovery;if(r.type!=="native")return r}return{type:"recover",operationId:e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??K?.operationId??null,requestId:e.client.pendingCommand?.requestId??null}},prepareFallback(){if(se)return se;let n=Xe();if(n)return Promise.resolve(n);let r=e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??K?.operationId??null,f=()=>({type:"recover",operationId:r,requestId:e.client.pendingCommand?.requestId??null});if(e.client.hasDurableJournal!==!0){let N=i?.recovery;return Promise.resolve(N&&N.type!=="native"&&N.type!=="cancel"?N:f())}let ne=(e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[])).some(N=>N.operation==="close");if(v&&!(ne||K&&e.client.view?.status==="closed")||x||Re||Ie||M.active||!i&&!K&&!ne)return Promise.resolve(f());let ge=i,Z=(async()=>{try{if(!K&&ne){let m=await e.client.retry();return await me(e.client.view??m.run),f()}if(!K){let m=await ge.prepareFallback();if(m.type!=="native")return m;if(e.client.hasDurableJournal!==!0)return f();K=m}let N=e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[]);if(N.length){let m=N.find(H=>H.operation==="close");if(!m||!X||m.requestId!==X.requestId)return f();let j=await e.client.retry();un(j),await me(e.client.view??j.run)}else{let m=e.client.view,j=m?.paywall;if(!m||!j||j.selectionGeneration===void 0||(j.quote?.operationId??null)!==K.operationId||K.operationId!==null&&j.canReselect!==!0)return f();let H=j.selectionGeneration,te=await e.client.get();await me(e.client.view??te.run);let oe=e.client.view,ie=oe?.paywall;if(!oe||!ie||!["running","waiting"].includes(oe.status)||oe.stopped||oe.id!==m.id||oe.nodeId!==m.nodeId||oe.visit!==m.visit||ie.receiptId!==j.receiptId||ie.selectionGeneration!==H||(ie.quote?.operationId??null)!==K.operationId||K.operationId!==null&&ie.canReselect!==!0||e.client.pendingPurchase||(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0)))return f();let ee=be();X={runId:oe.id,operationId:K.operationId,revision:ee.revision,requestId:ee.requestId,nodeId:oe.nodeId,visit:oe.visit,receiptId:ie.receiptId,selectionGeneration:H,acknowledged:!1},await Pe(ee)}let G=Xe();return G?(ae(),G):f()}catch(N){return ue(N),f()}})();se=Z;let we=()=>{se===Z&&(se=null)};return Z.then(we,we),Z},review:M.open,exitReview:M.exit,get unappliedDrafts(){return M.drafts}}}function Vt(t,y,w){return zn(t,y,w)}export{Bn as a,Mn as b,zn as c,Vt as d};
|
package/dist/chunk-JAUJZWYJ.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as n,s as t}from"./chunk-JPHYIUIR.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
|
package/dist/chunk-MMZR4I5X.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as Ie}from"./chunk-PQJJ5BSY.js";import{a as Q}from"./chunk-6QJRT23Q.js";import{A as Se,E as z,G as Pe,d as pe,f as k,k as me,v as we,w as ge,y as ye}from"./chunk-JPHYIUIR.js";import{$ as N}from"./chunk-2JTMXZ5M.js";import{a as B,i as J}from"./chunk-KAXKYBSI.js";import{b as he}from"./chunk-YBX2LLRG.js";import{a as c}from"./chunk-7EPE2PUN.js";import{h as G}from"./chunk-VC2H3LFP.js";import{b as fe}from"./chunk-5X6WAPH3.js";import{b as r}from"./chunk-7GD2UTBU.js";import{a as oe}from"./chunk-DSPLGTQI.js";var g=N.options,Ae=r.discriminatedUnion("operation",[g[1].omit({customerToken:!0}),g[2].omit({customerToken:!0}),g[3].omit({customerToken:!0}),g[4].omit({customerToken:!0}),g[5].omit({customerToken:!0}),g[6].omit({customerToken:!0}),g[7].omit({customerToken:!0}),g[8].omit({customerToken:!0}),me.omit({customerToken:!0})]),je=r.strictObject({receiptId:r.uuid(),operationId:r.uuid()}),Me=r.discriminatedUnion("operation",[r.strictObject({operation:r.literal("recover_start"),intent:r.enum(["lookup","resume"]),start:r.strictObject({requestId:g[0].shape.requestId,funnelId:g[0].shape.funnelId,locale:g[0].shape.locale,parameters:g[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:je}),r.strictObject({operation:r.literal("settle_command"),runId:r.uuid(),funnelId:r.uuid(),requestId:r.uuid(),command:r.discriminatedUnion("operation",[g[3].omit({customerToken:!0}),g[4].omit({customerToken:!0}),g[5].omit({customerToken:!0}),g[6].omit({customerToken:!0}),g[7].omit({customerToken:!0})]).optional()}).refine(o=>!o.command||o.requestId===o.command.requestId),r.strictObject({operation:r.literal("run_command"),runId:r.uuid(),funnelId:r.uuid(),command:Ae})]),ae=r.strictObject({runId:r.uuid(),funnelId:r.uuid(),versionId:r.uuid(),startRequestId:r.uuid(),runExpiresAt:r.iso.datetime({offset:!0}),status:k.shape.run.shape.status}),K={scope:G,customerId:r.uuid()},Ce=r.discriminatedUnion("outcome",[r.strictObject({...K,outcome:r.literal("unknown"),target:r.null(),view:r.null(),access:r.null()}),r.strictObject({...K,outcome:r.literal("resolved"),target:ae,view:k.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((o,d)=>{o.outcome==="resolved"&&(o.access.type==="customer"!=(o.view!==null)||o.view&&(o.view.id!==o.target.runId||o.view.source.id!==o.target.funnelId||o.view.source.versionId!==o.target.versionId||o.view.status!==o.target.status||o.view.runExpiresAt!==o.target.runExpiresAt||o.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Recovery view and original Run binding differ"})}),Re=r.strictObject({...K,target:ae,view:k.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:k.shape.purchase.unwrap().nullable()}).superRefine((o,d)=>{let p=o.settlement;(p.acceptance==="accepted"!=(p.receiptPhase!==null)||p.acceptance==="accepted"&&p.basis!=="receipt"||p.acceptance==="unknown"&&(p.state!=="unknown"||p.basis!=="none")||p.acceptance!=="accepted"&&(p.operationId!==null||p.receiptId!==null)||p.acceptance==="not_accepted"&&(p.state!=="settled"||!["run_terminal","position_advanced"].includes(p.basis))||o.purchase&&(o.purchase.receiptId!==p.receiptId||o.purchase.operation&&o.purchase.operation.operationId!==p.operationId||o.purchase.quote&&o.purchase.quote.operationId!==p.operationId)||o.view&&(o.view.id!==o.target.runId||o.view.source.id!==o.target.funnelId||o.view.source.versionId!==o.target.versionId||o.view.status!==o.target.status||o.view.runExpiresAt!==o.target.runExpiresAt||o.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Original command settlement binding differs"})}),Ee=r.strictObject({...K,target:ae,purchase:k.shape.purchase.unwrap()}).superRefine((o,d)=>{(!o.purchase.operation||typeof o.purchase.canReselect!="boolean"||o.purchase.quote&&o.purchase.quote.operationId!==o.purchase.operation.operationId)&&d.addIssue({code:"custom",message:"Original purchase proof is incomplete"})});var Ne=N.options[0].refine(o=>!o.customer&&!o.customerData),ke=r.strictObject({receiptId:r.uuid(),operationId:r.uuid(),terminal:r.enum(["complete","native"]).nullable()}),ve=r.strictObject({schemaVersion:r.literal(1),baseUrl:r.url(),scope:G,customerId:r.uuid(),sessionId:r.uuid(),start:Ne,allowed:r.array(r.enum(["merchant","record_only","indiana","native"])),run:r.strictObject({id:r.uuid(),versionId:r.uuid(),status:pe.shape.status,revision:r.number().int().nonnegative(),runExpiresAt:r.iso.datetime({offset:!0}).optional()}).optional(),purchases:r.array(ke).max(100),operationCommand:r.strictObject({operationId:r.uuid(),intent:r.literal("confirm")}).optional(),journal:r.strictObject({revision:r.number().int().nonnegative(),entry:we.nullable()})});function be(o){return ye({...o,namespace:"purchases",identity:[o.scope.projectId,o.scope.environment,o.customerId]})}function Oe(o){let d=new URL(o.baseUrl??fe).href,p=()=>new c("PURCHASE_STORAGE_INVALID","Purchase recovery storage is unavailable or invalid; native fallback is not authorized");async function E(){o.assertCurrent();try{let y=await o.storage.read();if(o.assertCurrent(),!Number.isSafeInteger(y.revision)||y.revision<0)throw p();let a=y.entry===null?null:ve.parse(y.entry);if(a&&(a.baseUrl!==d||a.customerId!==o.customerId||a.scope.projectId!==o.scope.projectId||a.scope.environment!==o.scope.environment))throw new c("SCOPE_MISMATCH","Purchase recovery belongs to another Customer or environment");if(a?.journal.entry&&(a.journal.entry.scope.projectId!==a.scope.projectId||a.journal.entry.scope.environment!==a.scope.environment||a.journal.entry.funnelId!==a.start.funnelId||a.journal.entry.runId!==a.run?.id||a.journal.entry.versionId!==a.run?.versionId)||a?.operationCommand&&!a.purchases.some(R=>R.operationId===a.operationCommand?.operationId))throw p();return{revision:y.revision,entry:a}}catch(y){throw y instanceof c?y:p()}}async function Y(y){for(let a=0;a<8;a++){let R=await E(),b=y(structuredClone(R.entry));if(JSON.stringify(b)===JSON.stringify(R.entry))return b;b&&ve.parse(b),o.assertCurrent();let v;try{v=await o.storage.write(R.revision,b)}catch{throw p()}if(o.assertCurrent(),v!==null){if(!Number.isSafeInteger(v)||v<=R.revision)throw p();return b}}throw new c("PURCHASE_STORAGE_CONFLICT","Another consumer changed this purchase; recover the original attempt")}return{read:E,update:Y,baseUrl:d}}function Te(o){let d=o.purchases.find(p=>p.type==="checkout");if(!o.actions.includes("continue_checkout")||d?.type!=="checkout")throw new c("PURCHASE_PENDING","No single resumable Checkout is confirmed");return d.checkoutUrl}function pn(o){let d={...o,scope:{...o.scope},executionPolicy:structuredClone(o.executionPolicy)},p=d.session.snapshot();if(!p)throw new c("CUSTOMER_SESSION_REQUIRED","Purchase recovery requires a verified Customer session");let{customerId:E,sessionId:Y}=p,y=!1,a=null,R,b=null,v=!1,q,U,D,O={mode:"idle",status:"idle",actions:["start"],purchases:[]},I=new Map,j=new Map,ie=new AbortController,H=new Set,W=he(d),se=Ie(W.request);function L(e){return{code:e instanceof c?e.code:"PURCHASE_RECOVERY_BLOCKED",message:e instanceof Error?e.message:"The original purchase requires server confirmation",...e instanceof c&&e.status!==void 0?{status:e.status}:{}}}function P(){if(y||d.session.snapshot()?.customerId!==E)throw new c("IDENTITY_CHANGED","The original purchase Customer changed")}let w=Oe({...d,customerId:E,assertCurrent:P,storage:d.storage??be({baseUrl:d.baseUrl,scope:d.scope,customerId:E})}),Fe=d.session.subscribeIdentity(ue);function ue(){y||(y=!0,clearTimeout(D),ie.abort(new c("IDENTITY_CHANGED","Purchase consumer was destroyed")),Fe(),a?.reset(),a=null,b=null,W.dispose(),H.clear(),I.clear(),j.clear())}function C(e){P();let n=JSON.stringify(e)!==JSON.stringify(O);O=e,clearTimeout(D),(e.mode==="operation"||e.mode==="run"&&!e.actions.includes("close"))&&["waiting_result","fulfillment","recording"].includes(e.status)&&(D=setTimeout(()=>{T().catch(()=>{})},5e3)),n&&oe(d.onRecovery,structuredClone(e));for(let t of n?H:[]){if(y)break;oe(t,structuredClone(e))}return structuredClone(e)}function h(e){if(P(),!e||e.start.requestId!==R)throw new c("PURCHASE_STORAGE_CONFLICT","This purchase was superseded; the old consumer cannot dispatch")}function F(e){let n=[...e.purchases],t=e.journal.entry?.purchase;return t&&!n.some(u=>u.operationId===t.operationId)&&n.push({receiptId:t.receiptId,operationId:t.operationId,terminal:null}),n}function M(e){return e.run&&!["running","waiting"].includes(e.run.status)&&!e.journal.entry?.command&&!e.journal.entry?.closeCommand&&!e.operationCommand&&F(e).every(n=>n.terminal!==null)}function _(e,n){let t=e.journal.entry?.command??e.journal.entry?.closeCommand,u=F(e).map(S=>{let re=I.get(S.operationId);return S.terminal&&!re?{type:S.terminal,operationId:S.operationId}:B({quote:re?.quote??null,operation:re??null,requestId:t?.requestId??null,pending:!1,destroyed:!1,canReselect:j.get(S.operationId)===!0})}),l=u.filter(S=>!["complete","native"].includes(S.type)),i=l[0],s=l.length===1&&i?.operationId?I.get(i.operationId):void 0;if(s&&(i?.type==="checkout"||i?.type==="cancel"))try{z({allowed:e.allowed.filter(S=>d.executionPolicy.allowed.includes(S))},s.quote)}catch(S){return{mode:n,status:"blocked",actions:["refresh",...n==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[]],purchases:u,error:L(S)}}let m;if(n==="operation"&&!t&&i?.type==="cancel"&&s?.quote&&!s.problem&&!s.confirmedAt)try{z({allowed:e.allowed.filter(S=>d.executionPolicy.allowed.includes(S))},s.quote),Date.parse(s.quote.expiresAt)>Date.now()&&(m={operationId:s.operationId,quote:s.quote})}catch{}let f=u.length>0&&l.length===0,x=M(e)||n==="operation"&&f&&!t&&!e.operationCommand?"complete":i?.type==="checkout"?"checkout":i?.type==="fulfillment"?"fulfillment":i?.type==="recording"?"recording":t||e.operationCommand||i&&i.type!=="cancel"||n==="operation"&&!m?"waiting_result":"ready";return{mode:n,status:x,purchases:u,...m?{confirmation:structuredClone(m)}:{},actions:["refresh",...M(e)?["start"]:[],...n==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[],...e.operationCommand?["retry"]:m?["confirm"]:[],...l.length===1&&i?.type==="checkout"?["continue_checkout"]:[]]}}function $(e){let n=B({quote:e?.quote??null,operation:e??null,requestId:null,pending:!1,destroyed:!1,canReselect:e&&j.get(e.operationId)===!0});return n.type==="complete"||n.type==="native"?n.type:null}function X(e){if(!e.operation)return;let n={...e.operation,...e.operation.quote?{}:e.quote?{quote:e.quote}:{}};if(n.merchantExecution&&n.merchantExecution.customerId!==E)throw new c("SCOPE_MISMATCH","Purchase execution belongs to another Customer");let t=J(I.get(n.operationId)??null,n);I.set(n.operationId,t),t===n&&j.set(n.operationId,e.canReselect===!0)}async function qe(e){P();for(let t of[e.purchase,e.run.paywall])t&&X(t);let n=await w.update(t=>{if(h(t),t.run&&(t.run.id!==e.run.id||t.run.versionId!==e.run.source.versionId))throw new c("SCOPE_MISMATCH","The original purchase Run changed");let u=F(t);for(let l of[e.purchase,e.run.paywall]){let i=l?.operation?.operationId??l?.quote?.operationId;if(!l||!i)continue;let s=u.find(f=>f.operationId===i);if(s&&s.receiptId!==l.receiptId)throw new c("INVALID_RESPONSE","The original purchase Receipt changed");let m=$(I.get(i));s?s.terminal??=m:u.push({receiptId:l.receiptId,operationId:i,terminal:m})}return{...t,purchases:u,run:t.run&&(t.run.revision>e.run.revision||!["running","waiting"].includes(t.run.status)&&["running","waiting"].includes(e.run.status))?t.run:{id:e.run.id,versionId:e.run.source.versionId,status:e.run.status,revision:e.run.revision,runExpiresAt:e.run.runExpiresAt}}});h(n),n.run&&!["running","waiting"].includes(n.run.status)&&F(n).some(t=>!t.terminal)&&(n=await Z(n,!n.journal.entry?.command&&!n.journal.entry?.closeCommand,new Set([e.purchase?.operation?.operationId,e.run.paywall?.operation?.operationId].filter(t=>!!t)))),h(n),C(_(n,"run"))}function _e(){return{async read(){let{entry:e}=await w.read();return h(e),structuredClone(e.journal)},async write(e,n){let t=null;return await w.update(u=>{if(h(u),u.operationCommand&&n?.command&&n.command.operation!=="close")throw new c("PURCHASE_PENDING","Recover the original Operation command before dispatching a Run mutation");return t=null,u.journal.revision!==e?u:(t=e+1,{...u,journal:{revision:t,entry:n}})}),t}}}async function Z(e,n=!1,t=new Set){h(e);let u=F(e);for(let i of u){if(i.terminal)continue;let s=t.has(i.operationId)?I.get(i.operationId):void 0;if(s??=await ce(e,i),P(),s.operationId!==i.operationId)throw new c("INVALID_RESPONSE","Original Operation changed");if(s.merchantExecution&&s.merchantExecution.customerId!==E)throw new c("SCOPE_MISMATCH","Purchase execution belongs to another Customer");if(n&&!e.operationCommand&&B({quote:s.quote??null,operation:s,requestId:null,pending:!1,destroyed:!1}).type==="cancel"){if({operation:s}=await se.attach({operationId:i.operationId,intent:"cancel"}),P(),s.operationId!==i.operationId)throw new c("INVALID_RESPONSE","Original cancellation Operation changed");s=await ce(e,i)}I.set(i.operationId,J(I.get(i.operationId)??null,s))}let l=await w.update(i=>{h(i);let s=i.operationCommand&&I.get(i.operationCommand.operationId);return{...i,...s&&(s.confirmedAt||s.merchantExecution||s.status!=="pending")?{operationCommand:void 0}:{},purchases:F(i).map(m=>({...m,terminal:m.terminal??$(I.get(m.operationId))}))}});return h(l),l}async function ee(e){P();let n=await W.request("funnels",e);return P(),n}async function ce(e,n){let t=Q(Ee,await ee({operation:"recover_purchase",runId:e.run.id,funnelId:e.start.funnelId,purchase:{receiptId:n.receiptId,operationId:n.operationId}}));if(ne(e,t),t.purchase.receiptId!==n.receiptId||t.purchase.operation?.operationId!==n.operationId)throw new c("INVALID_RESPONSE","Original purchase reference changed");return X(t.purchase),I.get(n.operationId)}async function le(e){for(let n of[e.journal.entry?.command,e.journal.entry?.closeCommand]){if(!n)continue;let t=Q(Re,await ee({operation:"settle_command",runId:e.run.id,funnelId:e.start.funnelId,requestId:n.requestId,...n.operation==="resume"?{}:{command:n}}));if(ne(e,t),t.settlement.requestId!==n.requestId)throw new c("INVALID_RESPONSE","Original command settlement changed");t.purchase&&X(t.purchase);let u=await w.update(l=>{h(l);let i=F(l),{receiptId:s,operationId:m}=t.settlement;if(s&&m){let x=i.find(S=>S.operationId===m);if(x&&x.receiptId!==s)throw new c("INVALID_RESPONSE","Original Receipt changed");x||i.push({receiptId:s,operationId:m,terminal:$(I.get(m))})}let f=t.settlement.state==="settled"?ge(l.journal.entry,n.requestId):l.journal.entry;return{...l,purchases:i,journal:f===l.journal.entry?l.journal:{revision:l.journal.revision+1,entry:f}}});h(u),e=u}return e}function ne(e,n){if(n.customerId!==E||n.scope.projectId!==d.scope.projectId||n.scope.environment!==d.scope.environment||n.target.funnelId!==e.start.funnelId||n.target.startRequestId!==e.start.requestId||e.run&&(n.target.runId!==e.run.id||n.target.versionId!==e.run.versionId))throw new c("SCOPE_MISMATCH","The original recovery binding changed")}async function te(e,n){if(h(e),e.run&&(e=await le(e)),!F(e).length&&M(e))return C(_(e,"operation"));if(!F(e).length)return C({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:L(n)});v=!0;let t=await Z(e);return C(_(t,"operation"))}async function V(e,n=!1,t=!0){if(R=e.start.requestId,b=structuredClone({requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}),!a){let u=e.run?{operation:"recover_run",runId:e.run.id,funnelId:e.start.funnelId}:{operation:"recover_start",intent:n?"resume":"lookup",start:{requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}},l;try{l=await ee(u)}catch(f){if(!e.run&&f instanceof c&&(f.status===void 0||f.status>=500))return C({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:O.purchases,error:L(f)});throw f}let i=Q(Ce,l);if(i.customerId!==E||i.scope.projectId!==d.scope.projectId||i.scope.environment!==d.scope.environment)throw new c("SCOPE_MISMATCH","Recovery Customer or environment changed");if(i.outcome==="unknown")return C({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:O.purchases,error:{code:"RESULT_UNKNOWN",message:"The original Start outcome remains unknown; retry only its original input"}});ne(e,i);let s=await w.update(f=>(h(f),{...f,run:{id:i.target.runId,versionId:i.target.versionId,status:i.target.status,revision:i.view?.revision??f.run?.revision??0,runExpiresAt:i.target.runExpiresAt}}));if(h(s),e=s,i.access.type==="operation_only")return te(e,new c("RUN_RECONCILIATION_REQUIRED","Only the original command and Operation can be recovered"));e=await le(e);let m=i.view;if(m.locale!==e.start.locale||!Se(m.parameters,e.start.parameters))throw new c("INVALID_RESPONSE","The original Start input changed");a=Pe({...d,customerRun:{runId:i.target.runId,customerId:E,startRequestId:e.start.requestId},funnelId:e.start.funnelId,funnelExecutionPolicy:{allowed:e.allowed.filter(f=>d.executionPolicy.allowed.includes(f))},funnelCommandStorage:_e(),onAcceptedResponse:qe},{scope:i.scope,run:m})}try{await a.get(),a.view?.pendingRequest?.requestId===e.start.requestId&&!a.pendingCommands?.length&&await a.resume(a.view.pendingRequest.requestId);for(let l of a.pendingCommands??[])l.operation!=="close"&&await a.settle?.(l.requestId);a.pendingCommands?.length&&await a.retry(),P();let u=(await w.read()).entry;return h(u),C(_(u,"run"))}catch(u){if(P(),t&&u instanceof c&&(u.status===401||u.status===409&&u.reason==="STATE_CHANGED")){a.reset(),a=null;let l=(await w.read()).entry;return h(l),V(l,!1,!1)}throw u}}function A(e,n="read"){if(P(),q)return n==="read"||n===U?q:q.then(()=>A(e,n),()=>A(e,n));clearTimeout(D);let t=e().catch(u=>{throw y||C({mode:"blocked",status:"blocked",actions:["refresh"],purchases:O.purchases,error:L(u)}),u});return q=t,U=n,t.then(()=>{q===t&&(q=void 0,U=void 0)},()=>{q===t&&(q=void 0,U=void 0)}),t}function T(){return A(async()=>{let{entry:e}=await w.read();return e?(R&&e.start.requestId!==R&&(a?.reset(),a=null,I.clear(),j.clear()),v&&R===e.start.requestId?te(e,O.error):V(e)):C({mode:"idle",status:"idle",actions:["start"],purchases:[]})})}async function de(){let e=await T();return e.mode==="operation"&&!e.actions.includes("confirm")&&!e.actions.includes("retry")?e:A(async()=>{let n=(await w.read()).entry;if(h(n),!v){if(!a?.view?.paywall?.quote)throw new c("PURCHASE_PENDING","Read the original quote before confirming");let s=a.view.paywall.operation;if(s?.confirmedAt||s?.merchantExecution||s&&s.status!=="pending")return C(_(n,"run"));if(a.pendingCommands?.length)await a.retry();else{let f=a.view;await a.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:f.nodeId,visit:f.visit,revision:f.revision,input:{type:"paywall_confirm",operationId:f.paywall.quote.operationId}})}let m=(await w.read()).entry;return h(m),C(_(m,"run"))}let t=n.operationCommand?.operationId??O.confirmation?.operationId,u=t&&I.get(t);if(!t||!u||n.journal.entry?.command||n.journal.entry?.closeCommand)throw new c("PURCHASE_PENDING","The original Run command must be settled before Operation confirmation");z({allowed:n.allowed.filter(s=>d.executionPolicy.allowed.includes(s))},u.quote),await w.update(s=>{if(h(s),s.journal.entry?.command||s.journal.entry?.closeCommand||s.operationCommand&&s.operationCommand.operationId!==t)throw new c("PURCHASE_PENDING","Another original command is pending");return{...s,operationCommand:{operationId:t,intent:"confirm"}}});let l=await se.attach({operationId:t,intent:"confirm"});if(P(),l.operation.operationId!==t)throw new c("INVALID_RESPONSE","Original confirmation Operation changed");I.set(t,J(u,l.operation));let i=(await w.read()).entry;return h(i),C(_(await Z(i,!1,new Set([t])),"operation"))},"confirm")}return{get controller(){return a},get recovery(){return structuredClone(O)},get attempt(){return P(),structuredClone(b)},get identitySignal(){return ie.signal},start(e){let n=N.parse({...structuredClone(e),operation:"start",requestId:e.requestId??crypto.randomUUID()});if(n.operation!=="start"||n.customer||n.customerData)throw new c("INVALID_REQUEST","A Customer-owned Funnel start is required");return A(async()=>{let t=await w.update(u=>{if(u&&!M(u)){if(u.start.funnelId!==n.funnelId)throw new c("PURCHASE_PENDING","Recover the original Funnel before starting another purchase");return u}return{schemaVersion:1,baseUrl:w.baseUrl,scope:d.scope,customerId:E,sessionId:Y,start:n,allowed:[...d.executionPolicy.allowed],purchases:[],journal:{revision:0,entry:null}}});if(!t)throw new c("PURCHASE_STORAGE_INVALID","Original start was not retained");return R!==t.start.requestId&&(a?.reset(),a=null,I.clear(),j.clear(),v=!1),v?te(t,O.error):V(t,!0)},`start:${n.funnelId}`)},refresh:T,confirm:de,retry:()=>v?de():A(async()=>{let{entry:e}=await w.read();return e?V(e,!0):C({mode:"idle",status:"idle",actions:["start"],purchases:[]})},"retry"),async close(){return a?.view?A(async()=>{if(!a?.view)throw new c("PURCHASE_PENDING","Recover the original Run before closing");if(a.pendingCommands?.find(t=>t.operation==="close"))await a.retry();else if(["running","waiting"].includes(a.view.status)){let t=a.view;await a.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision})}let n=(await w.read()).entry;return h(n),C(_(n,"run"))},"close"):T()},async continueCheckout(e){let n=await T();P(),await e(Te(n))},subscribe(e){return H.add(e),()=>{H.delete(e)}},destroy:ue}}export{be as a,Te as b,pn as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as a,d as b}from"./chunk-IDMOAV63.js";import"./chunk-K72QA2PO.js";import"./chunk-GOYKJHDV.js";import"./chunk-2JTMXZ5M.js";import"./chunk-3GT4A3TA.js";import"./chunk-KAXKYBSI.js";import"./chunk-AZ53RDWO.js";import"./chunk-YBX2LLRG.js";import"./chunk-TLGKBSXC.js";import"./chunk-4WBIACS2.js";import"./chunk-HZYCK4XJ.js";import"./chunk-7EPE2PUN.js";import"./chunk-VC2H3LFP.js";import"./chunk-SLUA7ABW.js";import"./chunk-QZG2YXM4.js";import"./chunk-5X6WAPH3.js";import"./chunk-7GD2UTBU.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{N as r,O as m,h as e}from"./chunk-PNHGULO2.js";import"./chunk-3GT4A3TA.js";import"./chunk-TLGKBSXC.js";import"./chunk-HZYCK4XJ.js";import"./chunk-VC2H3LFP.js";import"./chunk-7GD2UTBU.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-Q2TQLDEH.js";import"./chunk-CGSZBPSX.js";import"./chunk-MBKZYWPF.js";import"./chunk-UWAZDSWO.js";import"./chunk-TNN4S6VO.js";import"./chunk-PNHGULO2.js";import"./chunk-2JTMXZ5M.js";import"./chunk-3GT4A3TA.js";import"./chunk-AZ53RDWO.js";import"./chunk-EUVKRGMO.js";import"./chunk-TLGKBSXC.js";import"./chunk-4WBIACS2.js";import"./chunk-HZYCK4XJ.js";import"./chunk-VC2H3LFP.js";import"./chunk-7GD2UTBU.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
|
package/dist/paywall-BEFHTZW7.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as at,c as Ne,e as ot,g as st,h as ct}from"./chunk-K72QA2PO.js";import{c as Xe,d as Ze,e as et,f as de,g as tt,h as nt,i as rt,k as it}from"./chunk-GOYKJHDV.js";import{a as We,c as Se,d as Ye,g as Je,j as Ke}from"./chunk-KAXKYBSI.js";import{b as te}from"./chunk-AZ53RDWO.js";import"./chunk-YBX2LLRG.js";import"./chunk-TLGKBSXC.js";import{c as ee,o as re,oa as ie,qa as Oe}from"./chunk-4WBIACS2.js";import{c as Te}from"./chunk-HZYCK4XJ.js";import{a as x}from"./chunk-7EPE2PUN.js";import"./chunk-VC2H3LFP.js";import"./chunk-5X6WAPH3.js";import"./chunk-7GD2UTBU.js";import{a as G}from"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";async function lt(T,r,D){if(r.status!=="complete")throw new x("INVALID_RESPONSE","A verified completed purchase is required");let O=T?re.parse(T):null;if(await D.onComplete?.(r),!O||!D.check)return;let S=re.parse(await D.check());if(S.internal_feature_id!==O.internal_feature_id||S.quantity!==O.quantity||O.observation!==void 0&&(S.observation===void 0||S.observation.requirementDigest!==O.observation.requirementDigest||S.observation.authority!==O.observation.authority||Te(S.observation.subject)!==Te(O.observation.subject)))throw new x("INVALID_RESPONSE","The access requirement changed");S.allowed&&await D.onAccessGranted?.(S)}function De(T){return Object.entries(T.document.buttons).filter(([,r])=>r.type==="checkout"&&r.product.type==="fixed"&&!te(r.product,{},T.capabilities)).map(([r])=>r)}async function zt(T,r,D){let O=it(T.ownerDocument),S=()=>{C.finish("dismissed"),O()},B=()=>S(),C=tt(T,r,"paywall",()=>{S(),G(r.onDismiss)});r.signal?.throwIfAborted(),r.signal?.addEventListener("abort",B,{once:!0});let W=null,_,h,Le;try{if(C.start(!0),C.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(W=r.check?re.parse(await C.wait(r.check(),de)):null,W?.allowed)return C.finish("skipped"),r.signal?.removeEventListener("abort",B),O(),await r.onAccessGranted?.(W),{check:W,host:null};let[e,t]=await Promise.allSettled([C.wait(import("./screen-renderer-ITUUNF4E.js")),C.wait(r.start().then(s=>(C.cancelled&&s.destroy(),s)),de)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;Le=e.value,_=t.value,r.signal?.throwIfAborted(),_.signal?.throwIfAborted(),_.signal?.addEventListener("abort",B,{once:!0});let n=_.view??await C.wait(_.refresh(),de);if(!n)throw new x("INVALID_RESPONSE","Paywall presentation is missing");_.signal?.throwIfAborted(),h=n}catch(e){throw C.finish("error",e),r.signal?.removeEventListener("abort",B),_?.signal?.removeEventListener("abort",B),_?.destroy(),O(),e}let o=_,{mountScreenPreview:ut}=Le,d=T.ownerDocument,pe=new AbortController,k=d.createElement("section"),Y=d.createElement("div"),U=d.createElement("div"),u=d.createElement("p"),y=d.createElement("button"),b=d.createElement("button"),w=d.createElement("dialog"),a=h.document.screen.strings.defaultLocale.startsWith("zh"),dt=a?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",pt=a?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",P=at(h.document.screen.theme);k.dataset.indianaPaywall="",k.setAttribute("aria-label",h.document.name),k.style.cssText=P.root,U.style.cssText=P.controls,u.style.cssText=P.message,u.setAttribute("role","status"),b.style.cssText=P.link,b.textContent=a?"\u5173\u95ED":"Close",y.style.cssText=P.secondary,y.textContent=a?"\u91CD\u8BD5":"Retry",y.hidden=!0,U.append(u,y,b),k.append(Y,U);let Me=()=>{let e=H??U,t=[...e.children].every(s=>s===u?!u.textContent:s.hidden),n=[...e.children].some(s=>s===b?!1:s===u?!!u.textContent:!s.hidden);e.style.cssText=t?P.controls.replace(/padding:[^;]+/,"padding:0"):n?`${P.controls};${P.pinned}`:P.controls,ye()},_e=typeof MutationObserver>"u"?void 0:new MutationObserver(Me);_e?.observe(k,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let J=h.document.presentation,F,Ue,fe=!1,$e=JSON.stringify(h.capabilities),qe=e=>K?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):De(e);function me(e){if(p)return;h=e;let t=JSON.stringify(e.capabilities);t!==$e&&(F?.updateCapabilities(e.capabilities,qe(e)),$e=t),mt(e)}let g,he=0;function ye(){let e=d.defaultView;if(!g?.responsive||!e)return;let t=H??U,n=e.innerHeight-(g.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",he=Math.max(1,n-t.getBoundingClientRect().height),F?.resizeViewport?.(he,e.innerWidth)}let p=!1,K=!1,A=null,ae=!1,Ve=!1,j=!1,we,be=!1,V,H;function ft(){return K||p||V||be?{type:"recover",operationId:o.operation?.operationId??o.quote?.operationId??null,requestId:null}:Se(o)}let R=()=>!p&&!ae&&!V&&r.canInteract?.()!==!1,ge=!1,l=null,$=null;function mt(e){K||A||o.quote||o.operation||(u.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":a?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let ve=new Map,Ce=!1;function ht(e,t,n,s){let i=e.lines.length===1?e.lines[0]:void 0,m=te(n,s,t.capabilities);if(!i||!m||i.productVersionId!==m)return!1;let E;try{E=Oe(t.document.screen,m,s,t.capabilities)}catch{return!1}let I=Object.fromEntries((i.prepaid??[]).map(z=>[z.internal_feature_id,z.quantity]));return[...new Set([...Object.keys(E),...Object.keys(I)])].every(z=>(E[z]??0)===(I[z]??0))}let oe=e=>We({quote:o.quote,operation:e,requestId:null,pending:!1,destroyed:p,canReselect:o.canReselect});async function Pe(e){let t=e.merchantExecution;if(!(!R()||!e.checkoutUrl||r.checkoutNavigation==="after_confirmation"&&oe(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||ve.get(e.operationId)===e.checkoutUrl)){ve.set(e.operationId,e.checkoutUrl);try{r.onCheckoutUrl?await r.onCheckoutUrl(e.checkoutUrl):d.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw ve.delete(e.operationId),n}}}let Q=(e,t=!1)=>{if(t){let n=e instanceof x?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(l=null,u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u4E3A\u6B64\u5957\u9910\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002":"Pricing for this plan is unavailable. Payment hasn\u2019t started."):n==="COMMAND_PENDING"?u.textContent=a?"\u4ECD\u5728\u51C6\u5907\u62A5\u4EF7\uFF0C\u8BF7\u91CD\u8BD5\u4EE5\u67E5\u770B\u7ED3\u679C\u3002":"Your price is still being prepared. Retry to check the result.":u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u8BD5\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Try again."}else u.textContent=e instanceof x&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?ot(e,a):e instanceof x?e.message:a?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";y.hidden=l===null,t&&!g?.responsive&&u.scrollIntoView?.({block:"nearest"}),G(t&&D?.quoteError?D.quoteError:r.onError,e)},se=new WeakMap;function ce(e){K=e,F?.updateCapabilities?.(h.capabilities,qe(h));for(let t of $?.querySelectorAll("button")??[])e?(se.set(t,t.disabled),t.disabled=!0):se.has(t)&&(t.disabled=se.get(t),se.delete(t)),Ne(t)}function Ee(){u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"This action is unavailable right now. Try again in a moment."}async function yt(e){if(r.beforeAction)try{await r.beforeAction()}catch(t){throw l=e,t}}async function q(e){if(K||p)return;if(!R()){Ee();return}let t=e===le,n=t?pt:dt;ce(!0),y.hidden=!0,u.textContent=n;try{if(await yt(e),p)return;if(!R()){l=e,y.hidden=!1,Ee();return}await e()}catch(s){p||Q(s,t)}finally{ce(!1),u.textContent===n&&(u.textContent="")}}async function wt(e){await lt(W,e,r)}function He(e){return Se(o).type==="recording"||oe(e).type==="recording"}function Be(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],s=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),i=t?n.length===1&&n[0]?.amountMinor===s&&n[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===s&&e.lines[0],m=s===null?ee(t.subtotalMinor-t.discountMinor,e.currency)+(a?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):ee(s,e.currency)+(i?ie(i.interval,a?"zh-CN":"en",i.intervalCount??1):""),E=e.lines.map(I=>I.productName).join(", ");return{label:E?`${E} \xB7 ${m}`:m,recurring:i}}async function N(e,t=r.checkoutNavigation!=="after_confirmation"){if(p)return;if(!R()){l=async()=>N(await o.read()),y.hidden=!1;return}if(u.textContent=ct(e.status,a),He(e)){let i=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";u.textContent=i?a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u4F46\u4EA4\u6613\u8BB0\u5F55\u5931\u8D25\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u4FEE\u590D\uFF0C\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u8BB0\u5F55\u3002\u8BF7\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",y.textContent=a?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",l=async()=>N(await o.read()),y.hidden=!1;return}if(e.problem){let i=e.problem;l=ne,y.textContent=a?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",Q(new x(i.code,i.reason==="RESULT_UNKNOWN"?a?"\u4ED8\u6B3E\u7ED3\u679C\u5C1A\u672A\u786E\u5B9A\uFF0C\u8BF7\u6062\u590D\u539F\u64CD\u4F5C\uFF0C\u6682\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"The payment result is unknown. Recover the original purchase before buying again.":i.phase==="fulfillment"?a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":i.code==="CAPABILITY_UNAVAILABLE"?a?"\u5546\u6237\u5C1A\u4E0D\u652F\u6301\u672C\u6B21\u8D2D\u4E70\u6240\u9700\u7684\u5B8C\u6574\u80FD\u529B\uFF0C\u8BF7\u5904\u7406\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":i.code==="NOT_CONFIGURED"?a?"\u4ED8\u6B3E\u670D\u52A1\u8FDE\u63A5\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":a?"\u539F\u8D2D\u4E70\u64CD\u4F5C\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u67E5\u8BE2\u6216\u6062\u590D\u6B64\u64CD\u4F5C\u3002":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,i));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(u.textContent=a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u6B63\u5728\u7B49\u5F85\u5546\u6237\u5B8C\u6210\u5904\u7406\u3002":"Payment was recorded. Waiting for merchant fulfillment."),e.status==="complete"){l=null,await wt(e);return}if(e.status!=="pending"){if(o.canReselect===!1){u.textContent=a?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",y.textContent=a?"\u67E5\u8BE2\u7ED3\u679C":"Check result",l=async()=>N(await o.read()),y.hidden=!1;return}e.status==="cancelled"?u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u5DF2\u53D6\u6D88\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u672A\u80FD\u5B8C\u6210\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase didn\u2019t go through. Choose a plan to try again."),y.textContent=a?"\u91CD\u8BD5":"Retry",l=null,A=null;return}if(!t&&oe(e).type==="checkout"){let i=o.quote,m=i?.operationId===e.operationId?Be(i).label:"";u.textContent=Ce?m?a?`${m} \u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002`:`${m} is still unpaid. Choose it again to continue paying.`:a?"\u4E4B\u524D\u7684\u8D2D\u4E70\u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",Ce=!1,l=null;return}await Pe(e);let n=Date.now()+6e5,s=2e3;fe=!0,G(r.onObservationChange,!0);try{for(;!p&&Date.now()<n;){if(await st(s,d,pe.signal),p)return;if(!R()){l=async()=>N(await o.read()),y.hidden=!1;return}let i=await o.read();if(!t&&oe(i).type==="checkout"){await N(i,!1);return}if(!i.problem&&i.status==="pending"&&await Pe(i),i.status!=="pending"||i.problem||He(i)){await N(i);return}s=Math.min(s*1.5,3e4)}}finally{fe=!1,G(r.onObservationChange,!1)}l=async()=>N(await o.read()),y.hidden=!1}async function xe(e=!1){let t=await o.read();if(p)return;if(!R()){l=()=>xe(e),y.hidden=!1;return}let n=o.quote;if(n&&Je(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&t.status==="pending"&&t.quoteFinalized===!1&&!t.confirmedAt&&!t.checkoutUrl&&!t.nativePurchase&&!t.merchantExecution&&!t.problem&&!o.pendingCancellation){Fe(n);return}await N(t,e||void 0)}async function ne(){$?.remove(),$=null,l=ne;let e=await o.confirm();if(!R()){l=ne,y.hidden=!1;return}if(e.problem){await N(e);return}if(e.status==="pending"){if(e.checkoutUrl)await Pe(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!r.onPurchase)throw new x("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await r.onPurchase({operation:e,signal:pe.signal})}}l=async()=>N(await o.read()),await N(e,!0)}function Fe(e){$?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());u.textContent=t?a?"\u6B64\u62A5\u4EF7\u5DF2\u8FC7\u671F\u3002\u8BF7\u5148\u53D6\u6D88\uFF0C\u518D\u91CD\u65B0\u9009\u62E9\u3002":"This quote has expired. Cancel it, then choose again.":"";let n=d.createElement("div"),s=d.createElement("button"),i=d.createElement("button"),m=d.createElement("div"),E=d.createElement("p"),I=e.merchantTerms,ue=a?"zh-CN":"en",z=I?.subscriptionTerms?.items??[],Re=I?I.subscriptionTerms?.trial?.days:e.lines.find(c=>c.trial)?.trial?.days,Z=Re===void 0?null:I?I.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(c=>c.trial)?0:null,je=(c,f)=>a?`${f} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${c}`:`Then ${c} after the ${f}-day trial`,{label:bt,recurring:Qe}=Be(e),gt=e.lines.map(c=>c.productName).join(", "),ze=Z===null?"":`${a?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${ee(Z,e.currency)}`;E.textContent=ze?[gt,ze].filter(Boolean).join(" \xB7 "):bt,s.textContent=a?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",s.disabled=t,i.textContent=a?"\u53D6\u6D88":"Cancel",n.style.cssText=P.panel,E.style.cssText=P.summary,m.style.cssText=P.actions,s.style.cssText=P.primary,i.style.cssText=P.secondary,Ne(s),s.onclick=()=>{q(ne)};let Ge=async()=>{let c=await o.cancel();p||(n.remove(),$=null,await N(c))};i.onclick=()=>{l=Ge,q(Ge)};let L=d.createElement("div");if(L.style.cssText=P.terms,I){for(let f of z){if(Z===null&&f===Qe)continue;let v=d.createElement("p"),M=ee(f.amountMinor,e.currency)+ie(f.interval,ue,f.intervalCount);v.textContent=Z!==null&&Re!==void 0?je(M,Re):M,L.append(v)}let c=I.subscriptionTerms?.trial;if(c){let f=d.createElement("p");f.textContent=a?`\u8BD5\u7528 ${c.days} \u5929\uFF1B${c.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${c.days}; ${c.cardRequired?"a payment method is required":"no payment method is required"}`,L.append(f)}for(let f of[...I.expectedEffects.map(v=>v.description),...I.requiredConsents.map(v=>v.summary)]){let v=d.createElement("p");v.textContent=f,L.append(v)}}else{for(let c of e.lines){if(Z!==null||c!==Qe){let f=d.createElement("p"),v=`${ee(c.catalogAmountMinor,e.currency)}${ie(c.interval,ue,c.intervalCount??1)}`;f.textContent=Z!==null&&c.trial?(e.lines.length>1?`${c.productName} \xB7 `:"")+je(v,c.trial.days):`${c.productName} \xB7 ${v}`,L.append(f)}for(let f of c.prepaid??[]){let v=d.createElement("p"),M=o.view?.capabilities.plans[c.productVersionId]?.prepaid?.find(vt=>vt.internalFeatureId===f.internal_feature_id);v.textContent=`${M?.name??f.internal_feature_id} \xB7 ${f.quantity} ${a?"\u4EFD":"packs"} \xD7 ${f.terms.units}`,M&&(v.textContent+=ie(M.reset==="week"||M.reset==="month"||M.reset==="year"?M.reset:"one_time",ue,M.resetCount)),L.append(v)}if(c.trial){let f=d.createElement("p");f.textContent=a?`\u8BD5\u7528 ${c.trial.days} \u5929\uFF1B${c.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${c.trial.days}; ${c.trial.cardRequired?"a payment method is required":"no payment method is required"}`,L.append(f)}}if(!e.charge){let c=d.createElement("p");c.textContent=a?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",L.append(c)}}for(let c of L.children)c.style.margin="0";m.append(s,i),n.append(E,...L.childElementCount?[L]:[],m),U.prepend(n),g?.responsive||n.scrollIntoView?.({block:"nearest"}),s.focus({preventScroll:!0}),$=n,l=null}async function le(){if(!A)return;if(l=le,!ge){let n=o.view,s=n?.document.buttons[A.actionId],i=n&&s?.type==="checkout"?te(s.product,A.selection,n.capabilities):null;if(!i)throw new x("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let m=await r.resolveOfferId?.({actionId:A.actionId,productVersionId:i});if(p)return;m!==void 0&&(A.offerId=m),ge=!0}if(!R()){y.hidden=!1;return}let e=await o.preview(A);if(p)return;let t=e.merchantTerms;if(r.confirmOnHostedCheckout&&R()&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){let n=a?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";u.textContent=n;try{await ne()}catch(s){p||Q(s)}finally{u.textContent===n&&(u.textContent="")}return}Fe(e)}function X(e="destroy"){p||(p=!0,r.signal?.removeEventListener("abort",B),o.signal?.removeEventListener("abort",B),C.finish("dismissed"),Ue?.(),pe.abort(),_e?.disconnect(),g?.destroy(),F?.destroy(),o.destroy(),w.open&&w.close(),w.remove(),k.remove(),O(),e==="dismiss"&&G(r.onDismiss))}S=X;async function ke(){if(!j||p||ae||V==="closing"||!V&&!R())return;if(!D){X("dismiss");return}let e=d.createElement("p");e.setAttribute("role","status"),e.textContent=a?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",H||(H=d.createElement("div"),H.style.cssText=U.style.cssText,U.replaceWith(H),Y.inert=!0),b.hidden=!1,H.replaceChildren(e,b),V="closing",b.setAttribute("aria-disabled","true"),b.focus({preventScroll:!0});try{await D.dismiss()}catch(t){p||G(r.onError,t)}p||(V="retry",e.textContent=a?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",b.textContent=a?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",b.removeAttribute("aria-label"),b.removeAttribute("aria-disabled"))}b.onclick=()=>{ke()},w.addEventListener("cancel",e=>{e.preventDefault(),ke()}),y.onclick=()=>{l&&q(l)};function Ie(e){C.finish("error",e),X()}function Ae(){if(!(!Ve||j||p||ae||g&&!R()))try{let e=t=>{we?.(),g&&(w.showModal(),g.responsive&&w.focus({preventScroll:!0}),!t&&r.loading!=="host"&&Ze(w,g.type,g.responsive)),j=!0};D?D.present(()=>C.present(()=>e(!0))):C.present(e)}catch(e){Ie(e),Q(e)}}try{if(J.type==="inline")b.hidden=Object.values(h.document.buttons).some(t=>t.type==="close"),Me(),we=rt(k,T),T.append(k);else{let t={sm:420,md:640,lg:900};w.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in J?t[J.size]+"px":"100vw"}`,w.setAttribute("aria-label",h.document.name),b.textContent="\xD7",b.setAttribute("aria-label",a?"\u5173\u95ED":"Close"),et(b,h.document.screen.theme),Ke(h.document)?(b.hidden=!0,w.append(k)):w.append(b,k),T.append(w),g=Xe(w,{...h.document.screen,presentation:J},ye),g.latch(),g.responsive&&(k.style.display="flex",k.style.flexDirection="column",k.style.maxHeight="100%",Y.style.overflow="clip",Y.style.minHeight="0"),we=nt(w)}F=ut(Y,{mode:"live",rendererUrl:o.webViewUrl,title:h.document.name,hostPresentation:()=>g?.type??J.type,reportContentHeight:g?.responsive,onResize:t=>{if(!g?.responsive)return;let n=Math.min(t,he);Y.style.height=`${n}px`,g.setContentHeight(n+(H??U).getBoundingClientRect().height)},onAction(t,n={}){if(!j||p||V)return;if(!R()){Ee();return}let s=o.view,i=s?.document.buttons[t];if(!i)return;if(i.type==="close"){q(async()=>{await r.onAction?.(t),X(r.onAction?"action":"dismiss")});return}if(i.type==="action"){l=async()=>{if(i.action.type==="event"){if(!r.onEvent)throw new x("EVENT_HANDLER_REQUIRED","Provide the event handler");await r.onEvent(i.action.event)}else r.onOpenUrl?await r.onOpenUrl(i.action.url):d.defaultView?.location.assign(i.action.url);await r.onAction?.(t),l=null},q(l);return}if($&&o.canReselect===!1){u.textContent=a?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",g?.responsive||$.scrollIntoView?.({block:"nearest"}),$.querySelector("button")?.focus({preventScroll:!0});return}if((o.quote||A)&&o.canReselect===!1){let E=!!s&&!!o.quote&&ht(o.quote,s,i.product,n);Ce=!!o.quote&&!E,l=o.quote?()=>xe(E):le,q(l);return}let m=s&&te(i.product,n,s.capabilities);if(!s||!m){Q(new x("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(r.onPurchaseIntent){l=null,q(async()=>{let E={actionId:t,productVersionId:m,selection:structuredClone(n),featureQuantities:Oe(s.document.screen,m,n,s.capabilities)};be=!0,await r.onPurchaseIntent(E)});return}if(A&&A.actionId!==t){Q(new x("COMMAND_PENDING","Finish the current purchase"));return}A||(A={requestId:crypto.randomUUID(),actionId:t,selection:n},ge=!1),q(le)},onEscape:()=>{ke()},onError:t=>{let n=new Error(t);!j&&!p&&Ie(n),Q(n)},onRendered:t=>{t&&w.setAttribute("aria-label",t),Ve=!0,Ae()}}),ye(),F.update(h.document.screen,h.document.screen.strings.defaultLocale,{capabilities:h.capabilities,unavailableActions:De(h),serverInput:{bindings:[],answers:{}}}),Ue=o.subscribe?.(me),me(o.view??h),await C.wait(F.ready);let e=o.operation;(o.quote||e&&(e.confirmedAt||e.checkoutUrl||e.status==="complete"))&&(l=()=>xe(),q(l))}catch(e){throw Ie(e),e}return{check:W,host:{get observing(){return fe},get recovery(){return ft()},async prepareFallback(){if(K||p||V||be)return{type:"recover",operationId:o.operation?.operationId??o.quote?.operationId??null,requestId:null};ce(!0);try{let e=await Ye(o);return e.type==="native"&&X(),e}finally{ce(!1)}},setSuspended(e){ae=e,k.hidden=e,e&&w.open?w.close():!e&&!j?Ae():!e&&!p&&j&&J.type!=="inline"&&!w.open&&w.showModal()},destroy:X,refresh:async()=>{if(!R()){if(o.view)return o.view;throw new x("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await o.refresh();return me(e),Ae(),e}}}}export{zt as showPaywall};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-77GCT2VP.js";import"./chunk-Q2TQLDEH.js";import"./chunk-CGSZBPSX.js";import"./chunk-VSWKFI3L.js";import"./chunk-MBKZYWPF.js";import"./chunk-PKY55SBA.js";import"./chunk-UWAZDSWO.js";import"./chunk-TNN4S6VO.js";import"./chunk-PNHGULO2.js";import"./chunk-2JTMXZ5M.js";import"./chunk-3GT4A3TA.js";import"./chunk-KAXKYBSI.js";import"./chunk-AZ53RDWO.js";import"./chunk-EUVKRGMO.js";import"./chunk-YBX2LLRG.js";import"./chunk-TLGKBSXC.js";import"./chunk-4WBIACS2.js";import"./chunk-HZYCK4XJ.js";import"./chunk-7EPE2PUN.js";import"./chunk-VC2H3LFP.js";import"./chunk-3VUPVXAV.js";import"./chunk-5X6WAPH3.js";import"./chunk-7GD2UTBU.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.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-4OBCF5H3.js";import"./chunk-GOYKJHDV.js";import"./chunk-4WBIACS2.js";import"./chunk-HZYCK4XJ.js";import"./chunk-7EPE2PUN.js";import"./chunk-VC2H3LFP.js";import"./chunk-7GD2UTBU.js";import"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.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
|