@tinkerlandai/longplay-sdk 0.10.33 → 0.10.35

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.
Files changed (96) hide show
  1. package/CHANGELOG.md +12 -3
  2. package/README.md +58 -9
  3. package/README.zh-CN.md +22 -5
  4. package/dist/check-response-GZZRWBEA.js +1 -0
  5. package/dist/chunk-2FE4FTPH.js +1 -0
  6. package/dist/chunk-3NCMYTNG.js +1 -0
  7. package/dist/chunk-44U3FOBB.js +1 -0
  8. package/dist/chunk-56BYGPQ6.js +1 -0
  9. package/dist/chunk-73NP72FV.js +1 -0
  10. package/dist/{chunk-KR3KDTVD.js → chunk-BLVBUN2R.js} +1 -1
  11. package/dist/chunk-BOVN2BE3.js +1 -0
  12. package/dist/chunk-BQRS7Y4K.js +1 -0
  13. package/dist/chunk-CIP5SQ5Y.js +1 -0
  14. package/dist/chunk-CKKIB2HC.js +1 -0
  15. package/dist/chunk-EM3MGDPG.js +1 -0
  16. package/dist/chunk-ETK6GC5P.js +1 -0
  17. package/dist/chunk-EUTWY7A2.js +1 -0
  18. package/dist/{chunk-NVHIGAO3.js → chunk-FMDC6N4W.js} +1 -1
  19. package/dist/chunk-GZRRVHYK.js +1 -0
  20. package/dist/{chunk-MIBRUDIS.js → chunk-KE26KWIU.js} +1 -1
  21. package/dist/{chunk-GGRDM54V.js → chunk-KPDHY76A.js} +1 -1
  22. package/dist/{chunk-FYQXSGRT.js → chunk-LF2UIJYD.js} +1 -1
  23. package/dist/{chunk-UWLEGMWX.js → chunk-MSK3VZ3A.js} +1 -1
  24. package/dist/{chunk-X4W22IH6.js → chunk-OX7PA64E.js} +1 -1
  25. package/dist/chunk-PUR5CYWX.js +1 -0
  26. package/dist/{chunk-XLSDL4D3.js → chunk-RML52BOR.js} +1 -1
  27. package/dist/chunk-RNEF4MZW.js +1 -0
  28. package/dist/chunk-SFHIFCXG.js +1 -0
  29. package/dist/{chunk-HQITRRHF.js → chunk-SXBM3DWK.js} +1 -1
  30. package/dist/chunk-TAFALMQN.js +1 -0
  31. package/dist/chunk-TJGIT5CU.js +1 -0
  32. package/dist/{chunk-KIMX3OIV.js → chunk-TLZP7BW6.js} +1 -1
  33. package/dist/chunk-TOTRALYQ.js +10 -0
  34. package/dist/chunk-U4RSRFZY.js +1 -0
  35. package/dist/chunk-UVRT4MY6.js +1 -0
  36. package/dist/chunk-V7MMTILA.js +1 -0
  37. package/dist/chunk-V7PFLFHE.js +1 -0
  38. package/dist/{chunk-BXPXJARS.js → chunk-VEX2FOFZ.js} +1 -1
  39. package/dist/chunk-W32FI2A2.js +1 -0
  40. package/dist/chunk-W6OQTXLL.js +1 -0
  41. package/dist/{chunk-EQPEUPMG.js → chunk-WZR2XCSJ.js} +1 -1
  42. package/dist/chunk-XUGEOELU.js +1 -0
  43. package/dist/chunk-YVXLCQGM.js +1 -0
  44. package/dist/content-AJDTSI7A.js +1 -0
  45. package/dist/funnel-host-purchase-Z7FCJ5CX.js +1 -0
  46. package/dist/{funnel-local-client-BeGBvi3z.d.ts → funnel-local-client-Dz1dTgES.d.ts} +22 -22
  47. package/dist/funnel-paywall-prerender-QHCUZZY3.js +1 -0
  48. package/dist/{funnel-process-client-C6QKDZun.d.ts → funnel-process-client-D6qjStm2.d.ts} +1 -1
  49. package/dist/funnel-runtime-host-UKSOOA4H.js +1 -0
  50. package/dist/index.d.ts +196 -61
  51. package/dist/index.js +1 -1
  52. package/dist/merchant-bridge-contracts-EAE4HQE4.js +1 -0
  53. package/dist/native-shell.js +1 -1
  54. package/dist/openrouter.js +1 -1
  55. package/dist/operation-contracts-HS4M2UXN.js +1 -0
  56. package/dist/page.js +1 -1
  57. package/dist/paywall-VYUBYBUI.js +1 -0
  58. package/dist/paywall-content-YQAVSO2T.js +1 -0
  59. package/dist/paywall-session-E5V42XUT.js +1 -0
  60. package/dist/popup.d.ts +20 -2
  61. package/dist/popup.js +1 -1
  62. package/dist/{presentation-loading-CiEQbUDk.d.ts → presentation-loading-CFSiS0VX.d.ts} +3 -1
  63. package/dist/react-native.d.ts +4 -4
  64. package/dist/react-native.js +1 -1
  65. package/dist/screen-renderer-R5GH7XLV.js +1 -0
  66. package/dist/server.d.ts +32 -2
  67. package/dist/server.js +3 -3
  68. package/dist/visual.js +1 -1
  69. package/package.json +1 -1
  70. package/dist/chunk-BRAVNBCC.js +0 -1
  71. package/dist/chunk-EHDHWYVJ.js +0 -1
  72. package/dist/chunk-ENZBWR3Y.js +0 -1
  73. package/dist/chunk-HQPP76BS.js +0 -1
  74. package/dist/chunk-ILEDKSRQ.js +0 -1
  75. package/dist/chunk-JN6JEKWN.js +0 -1
  76. package/dist/chunk-MPYJRLKB.js +0 -10
  77. package/dist/chunk-N7YXDSQL.js +0 -1
  78. package/dist/chunk-NAZU3EEJ.js +0 -1
  79. package/dist/chunk-NVIHK5GE.js +0 -1
  80. package/dist/chunk-R23IGK5U.js +0 -1
  81. package/dist/chunk-R4FDIYMN.js +0 -1
  82. package/dist/chunk-SCC3O2RD.js +0 -1
  83. package/dist/chunk-THMGTRXP.js +0 -1
  84. package/dist/chunk-U2R7MG3J.js +0 -1
  85. package/dist/chunk-U6E6CM7Z.js +0 -1
  86. package/dist/chunk-U6GWWCUS.js +0 -1
  87. package/dist/chunk-UHQGO6OR.js +0 -1
  88. package/dist/chunk-YTZQ5BMP.js +0 -1
  89. package/dist/content-CFX2L2BP.js +0 -1
  90. package/dist/funnel-host-purchase-MSPLT3ZV.js +0 -1
  91. package/dist/funnel-runtime-host-ATOA7MGC.js +0 -1
  92. package/dist/merchant-bridge-contracts-ZUQ6SGXZ.js +0 -1
  93. package/dist/operation-contracts-443N2P3A.js +0 -1
  94. package/dist/paywall-XAXSMLDU.js +0 -1
  95. package/dist/paywall-session-MB7BD2XP.js +0 -1
  96. package/dist/screen-renderer-3CBREMIS.js +0 -1
@@ -1 +1 @@
1
- import"./chunk-HQITRRHF.js";import"./chunk-5HJYR6Z4.js";import"./chunk-U2R7MG3J.js";import"./chunk-VYFSRHXM.js";import{a as i}from"./chunk-X4W22IH6.js";import"./chunk-R4FDIYMN.js";import"./chunk-UHQGO6OR.js";import{b as A}from"./chunk-VF6QMMEA.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};
1
+ import"./chunk-SXBM3DWK.js";import"./chunk-5HJYR6Z4.js";import"./chunk-56BYGPQ6.js";import"./chunk-VYFSRHXM.js";import"./chunk-TJGIT5CU.js";import{a as i}from"./chunk-OX7PA64E.js";import"./chunk-V7MMTILA.js";import"./chunk-EM3MGDPG.js";import{b as A}from"./chunk-VF6QMMEA.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-44U3FOBB.js";import"./chunk-WZR2XCSJ.js";import"./chunk-7MNJH5GB.js";import"./chunk-CIP5SQ5Y.js";import"./chunk-CKKIB2HC.js";import"./chunk-BOVN2BE3.js";import"./chunk-PUR5CYWX.js";import"./chunk-TAFALMQN.js";import"./chunk-ZGCKQWQ5.js";import"./chunk-VEX2FOFZ.js";import"./chunk-5HJYR6Z4.js";import"./chunk-VYFSRHXM.js";import"./chunk-BQRS7Y4K.js";import"./chunk-U4RSRFZY.js";import"./chunk-KE26KWIU.js";import"./chunk-TJGIT5CU.js";import"./chunk-V7MMTILA.js";import"./chunk-VF6QMMEA.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.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-NVHIGAO3.js";import"./chunk-KIMX3OIV.js";import"./chunk-3VUPVXAV.js";import"./chunk-UHQGO6OR.js";import"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
1
+ import{d as o,e as r,f as e,g as f}from"./chunk-FMDC6N4W.js";import"./chunk-TLZP7BW6.js";import"./chunk-3VUPVXAV.js";import"./chunk-EM3MGDPG.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
@@ -0,0 +1 @@
1
+ import{a as gt,c as vt,d as Fe,f as Ct,i as Pt}from"./chunk-SFHIFCXG.js";import{b as Be}from"./chunk-W32FI2A2.js";import{d as pt,e as mt,f as ht,h as je,i as Ae,j as yt,k as wt,l as bt}from"./chunk-XUGEOELU.js";import{a as ct,c as Ve,d as lt,e as ut}from"./chunk-3NCMYTNG.js";import{b as ne}from"./chunk-VEX2FOFZ.js";import{b as He,d as dt,g as ft}from"./chunk-V7PFLFHE.js";import"./chunk-56BYGPQ6.js";import"./chunk-VYFSRHXM.js";import{ba as ye,da as we}from"./chunk-BQRS7Y4K.js";import{c as ce,j as he}from"./chunk-U4RSRFZY.js";import{c as $e}from"./chunk-KE26KWIU.js";import"./chunk-TJGIT5CU.js";import{a as v}from"./chunk-OX7PA64E.js";import"./chunk-V7MMTILA.js";import"./chunk-EM3MGDPG.js";import"./chunk-VF6QMMEA.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import{a as j}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";async function kt(T,a,A){if(a.status!=="complete")throw new v("INVALID_RESPONSE","A verified completed purchase is required");let g=T?he.parse(T):null;if(await A.onComplete?.(a),!g||!A.check)return;let D=he.parse(await A.check());if(D.internal_feature_id!==g.internal_feature_id||D.quantity!==g.quantity||g.observation!==void 0&&(D.observation===void 0||D.observation.requirementDigest!==g.observation.requirementDigest||D.observation.authority!==g.observation.authority||$e(D.observation.subject)!==$e(g.observation.subject)))throw new v("INVALID_RESPONSE","The access requirement changed");D.allowed&&await A.onAccessGranted?.(D)}function Qe(T){return Object.entries(T.document.buttons).filter(([,a])=>a.type==="checkout"&&a.product.type==="fixed"&&!ne(a.product,{},T.capabilities)).map(([a])=>a)}function Et(T,a){let A=a.lines[0];if(a.lines.length!==1||!A)return;let g=A.productVersionId,{screen:D,buttons:F}=T.document,E=new Map((A.prepaid??[]).map(d=>[d.internal_feature_id,d.quantity]));function Q(d,f){if(d.hidden)return!1;if(d.type==="plan_picker"&&T.capabilities.pickers[d.id]?.options.includes(g))return f[d.id]=g,!0;if(d.type==="quantity_picker"){let V=E.get(d.internalFeatureId);return V!==void 0&&(!d.bind?.plan||d.bind.plan===g)&&(f[d.id]=V),!1}if(d.type==="button"&&d.action){let V=F[d.action];return V?.type==="checkout"&&V.product.type==="fixed"&&V.product.productVersionId===g}if(d.type!=="stack")return!1;let $=d.interaction,r=d.bind?.plan===g;for(let[V,p]of d.children.entries()){let J={},R=Q(p,J);if($?.type==="toggle"||$?.type==="tabs"){if(!R)continue;return f[d.id]=$.type==="toggle"?V===0:p.id,Object.assign(f,J),!0}Object.assign(f,J),R&&(r=!0,$?.type==="select"&&$.purpose==="product"&&$.pickerId&&p.type==="stack"&&p.bind?.plan===g&&(f[d.id]=p.id,f[$.pickerId]=g))}return r}for(let d of D.pages){let f={__page:d.id};if(Q(d.root,f))return f}}async function dn(T,a,A){let g=a.focusAtReveal?()=>{}:je(T.ownerDocument),D=()=>{E.finish("dismissed"),g()},F=()=>D(),E=yt(T,a,"paywall",()=>{D(),j(a.onDismiss)},gt);a.signal?.throwIfAborted(),a.signal?.addEventListener("abort",F,{once:!0});let Q=null,d,f,$;try{if(E.start(!0,a.loadingDocument?.screen.strings.defaultLocale,a.loadingDocument??null),E.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(Q=a.check?he.parse(await E.wait(a.check(),Ae)):null,Q?.allowed)return E.finish("skipped"),a.signal?.removeEventListener("abort",F),g(),await a.onAccessGranted?.(Q),{check:Q,host:null};let[e,t]=await Promise.allSettled([E.wait(import("./screen-renderer-R5GH7XLV.js")),E.wait(a.start().then(i=>(E.cancelled&&i.destroy(),i)),Ae)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;$=e.value,d=t.value,a.signal?.throwIfAborted(),d.signal?.throwIfAborted(),d.signal?.addEventListener("abort",F,{once:!0});let n=d.view??await E.wait(d.refresh(),Ae);if(!n)throw new v("INVALID_RESPONSE","Paywall presentation is missing");d.signal?.throwIfAborted(),f=n}catch(e){throw E.finish("error",e),a.signal?.removeEventListener("abort",F),d?.signal?.removeEventListener("abort",F),d?.destroy(),g(),e}let r=d,{mountScreenPreview:V}=$,p=T.ownerDocument,J=new AbortController,R=p.createElement("section"),re=p.createElement("div"),G=p.createElement("div"),l=p.createElement("p"),y=p.createElement("button"),C=p.createElement("button"),x=p.createElement("dialog"),s=f.document.screen.strings.defaultLocale.startsWith("zh"),xt=s?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",It=s?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",O=vt(f.document.screen.theme);R.dataset.indianaPaywall="",R.setAttribute("aria-label",f.document.name),R.style.cssText=O.root,G.style.cssText=O.controls,l.style.cssText=O.message,l.setAttribute("role","status"),C.style.cssText=O.link,C.textContent=s?"\u5173\u95ED":"Close",y.style.cssText=O.secondary,y.textContent=s?"\u91CD\u8BD5":"Retry",y.hidden=!0,G.append(l,y,C),R.append(re,G);let Ge=()=>{let e=K??G,t=[...e.children].every(i=>i===l?!l.textContent:i.hidden),n=[...e.children].some(i=>i===C?!1:i===l?!!l.textContent:!i.hidden);e.style.cssText=t?O.controls.replace(/padding:[^;]+/,"padding:0"):n?`${O.controls};${O.pinned}`:O.controls,Oe()},We=typeof MutationObserver>"u"?void 0:new MutationObserver(Ge);We?.observe(R,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let be=f.document.presentation,At=Object.entries(f.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),U,ze,Re=!1,Ye=JSON.stringify(f.capabilities),Je=e=>Z&&!ue?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):Qe(e);function Se(e){if(h)return;f=e;let t=JSON.stringify(e.capabilities);t!==Ye&&(U?.updateCapabilities(e.capabilities,Je(e)),Ye=t),Tt(e),de()}let P,Te=0;function Oe(){let e=p.defaultView;if(!P?.responsive||!e)return;let t=K??G,n=e.innerHeight-(P.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",Te=Math.max(1,n-t.getBoundingClientRect().height),U?.resizeViewport?.(Te,e.innerWidth)}let h=!1,Z=!1,k=null,ge=!1,Ke=!1,ee=!1,De,Ne=!1,W,K;function Rt(){return Z||h||W||Ne?{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}:Ve(r)}let I=()=>!h&&!ge&&!W&&a.canInteract?.()!==!1,ie=!1,m=null,z=null,te=()=>a.checkoutNavigation==="after_confirmation"&&!!(a.terminateCheckout||a.resumeCheckout),le={},ue,H=null;function de(){if(!te()||!U?.updateCheckoutControls)return;let e=r.quote,t=!H&&!!e&&!!r.operation&&M(r.operation).type==="checkout",n=Object.entries(f.document.buttons).flatMap(([i,o])=>o.type==="checkout"?[{actionId:i,policy:o}]:[]);U.updateCheckoutControls({actions:n.map(({actionId:i})=>i),resume:t?n.filter(({policy:i})=>Pe(e,f,i.product,le)).map(({actionId:i})=>i):[],resumeLabel:s?"\u7EE7\u7EED\u4ED8\u6B3E":"Continue checkout",busy:ue})}function Xe(){z?.remove(),z=null}async function _e(){if(H)return;if(a.resumeCheckout&&r.operation){await a.resumeCheckout(r.operation.operationId);return}let e=await r.read();if(M(e).type!=="checkout")return N(e,!1);I()&&(ve.delete(e.operationId),await ke(e))}function Ze(){l.textContent=s?"\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\u4ED8\u6B3E\u9875\u9762\u3002\u8BF7\u91CD\u8BD5\u3002":"Couldn\u2019t open checkout. Try again.",y.hidden=!0}async function et(e=!1){let t=H;if(!t)return;y.hidden=!0;let n=Date.now()+2e4;for(;I();){let i=await r.read();if(i.operationId!==t.operationId)throw new v("PURCHASE_PENDING","The original Checkout changed");if(!I())break;let o=M(i);if(o.type==="native"){H=null,Xe(),k=t.selection,ie=!1,await pe();return}if(o.type==="complete"||o.type==="fulfillment"||o.type==="recording"){H=null,await N(i,!1);return}if(e&&o.type==="checkout"){e=!1;try{await a.terminateCheckout(t.operationId)}catch(u){j(a.onError,u)}}if(Date.now()>=n)break;await Be(1e3,p,J.signal)}h||Ze()}async function St(e,t){H={operationId:e,selection:t};let n=!1;try{await a.terminateCheckout(e)}catch(i){if(i instanceof v&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(i.code)){H=null,l.textContent=s?"\u8BF7\u7EE7\u7EED\u539F\u8BA2\u5355\uFF0C\u6216\u7B49\u5F85\u5B83\u8FC7\u671F\u540E\u518D\u66F4\u6362\u65B9\u6848\u3002":"Continue your original checkout, or wait for it to expire before changing plans.",j(a.onError,i);return}n=i instanceof v&&(i.status??0)>=500,j(a.onError,i)}I()&&await et(n)}function Tt(e){Z||k||r.quote||r.operation||(l.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":s?"\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 Pe(e,t,n,i){let o=e.lines.length===1?e.lines[0]:void 0,u=ne(n,i,t.capabilities);if(!o||!u||o.productVersionId!==u)return!1;let _;try{_=we(t.document.screen,u,i,t.capabilities)}catch{return!1}let b=Object.fromEntries((o.prepaid??[]).map(Y=>[Y.internal_feature_id,Y.quantity]));return[...new Set([...Object.keys(_),...Object.keys(b)])].every(Y=>(_[Y]??0)===(b[Y]??0))}let M=e=>ct({quote:r.quote,operation:e,requestId:null,pending:!1,destroyed:h,canReselect:r.canReselect});async function ke(e){let t=e.merchantExecution;if(!(!I()||!e.checkoutUrl||a.checkoutNavigation==="after_confirmation"&&M(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{a.onCheckoutUrl?await a.onCheckoutUrl(e.checkoutUrl):p.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw ve.delete(e.operationId),n}}}let X=(e,t=!1)=>{if(e instanceof He)m=null,l.textContent=e.customerMessage(s);else if(t){let n=e instanceof v?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(m=null,l.textContent=s?"\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."):r.canReselect===!0&&!k?l.textContent=s?"\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"?l.textContent=s?"\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.":l.textContent=s?"\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 l.textContent=e instanceof v&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?Ct(e,s):e instanceof v?e.message:s?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";y.hidden=m===null,t&&!P?.responsive&&l.scrollIntoView?.({block:"nearest"}),j(t&&A?.quoteError?A.quoteError:a.onError,e)},Ee=new WeakMap;function xe(e){Z=e,y.disabled=e,U?.updateCapabilities?.(f.capabilities,Je(f));for(let t of z?.querySelectorAll("button")??[])e?(Ee.set(t,t.disabled),t.disabled=!0):Ee.has(t)&&(t.disabled=Ee.get(t),Ee.delete(t)),Fe(t)}function Le(){l.textContent=s?"\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 Ot(e){if(a.beforeAction)try{await a.beforeAction()}catch(t){throw t instanceof He?(k=null,ie=!1,m=null):m=e,t}}async function L(e,t){if(Z||h)return;if(!I()){Le();return}let n=e===pe,i=n?It:xt,o=te()&&t!==void 0;ue=o?t:void 0,xe(!0),de(),y.hidden=!0,l.textContent=o?"":i;try{if((e!==_e||!a.resumeCheckout)&&await Ot(e),h)return;if(!I()){m=e,y.hidden=!1,Le();return}await e()}catch(u){h||X(u,n&&!o)}finally{ue=void 0,xe(!1),de(),l.textContent===i&&(l.textContent="")}}async function Dt(e){await kt(Q,e,a)}function tt(e){return Ve(r).type==="recording"||M(e).type==="recording"}function nt(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],i=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),o=t?n.length===1&&n[0]?.amountMinor===i&&n[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===i&&e.lines[0],u=i===null?ce(t.subtotalMinor-t.discountMinor,e.currency)+(s?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):ce(i,e.currency)+(o?ye(o.interval,s?"zh-CN":"en",o.intervalCount??1):""),_=e.lines.map(b=>b.productName).join(", ");return{label:_?`${_} \xB7 ${u}`:u,recurring:o}}async function N(e,t=a.checkoutNavigation!=="after_confirmation"){if(h)return;if(!I()){m=async()=>N(await r.read()),y.hidden=!1;return}if(l.textContent=Pt(e.status,s),tt(e)){let o=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";l.textContent=o?s?"\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.":s?"\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=s?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",m=async()=>N(await r.read()),y.hidden=!1;return}if(e.problem){let o=e.problem;m=fe,y.textContent=s?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",X(new v(o.code,o.reason==="RESULT_UNKNOWN"?s?"\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"?s?"\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"?s?"\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"?s?"\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.":s?"\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)&&(l.textContent=s?"\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"){m=null,await Dt(e);return}if(e.status!=="pending"){if(r.canReselect===!1){l.textContent=s?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",y.textContent=s?"\u67E5\u8BE2\u7ED3\u679C":"Check result",m=async()=>N(await r.read()),y.hidden=!1;return}e.status==="cancelled"?l.textContent=s?"\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"&&(l.textContent=s?"\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=s?"\u91CD\u8BD5":"Retry",m=null,k=null;return}if(!t&&M(e).type==="checkout"){if(H){Ze();return}if(te()){l.textContent="",Ce=!1,m=null,de();return}let o=r.quote,u=o?.operationId===e.operationId?nt(o).label:"";l.textContent=Ce?u?s?`${u} \u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002`:`${u} is still unpaid. Choose it again to continue paying.`:s?"\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,m=null;return}await ke(e);let n=Date.now()+6e5,i=2e3;Re=!0,j(a.onObservationChange,!0);try{for(;!h&&Date.now()<n;){if(await Be(i,p,J.signal),h)return;if(!I()){m=async()=>N(await r.read()),y.hidden=!1;return}let o=await r.read();if(!t&&M(o).type==="checkout"){await N(o,!1);return}if(!o.problem&&o.status==="pending"&&await ke(o),o.status!=="pending"||o.problem||tt(o)){await N(o);return}i=Math.min(i*1.5,3e4)}}finally{Re=!1,j(a.onObservationChange,!1)}m=async()=>N(await r.read()),y.hidden=!1}async function Ue(e=!1){let t=await r.read();if(h)return;if(!I()){m=()=>Ue(e),y.hidden=!1;return}let n=r.quote;if(n&&dt(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&&!r.pendingCancellation){rt(n);return}await N(t,e||void 0)}async function fe(){Xe(),m=fe;let e=await r.confirm();if(!I()){m=fe,y.hidden=!1;return}if(e.problem){await N(e);return}if(e.status==="pending"){if(e.checkoutUrl)await ke(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!a.onPurchase)throw new v("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:e,signal:J.signal})}}m=async()=>N(await r.read()),await N(e,!0)}function rt(e){z?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());l.textContent=t?s?"\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=p.createElement("div"),i=p.createElement("button"),o=p.createElement("button"),u=p.createElement("div"),_=p.createElement("p"),b=e.merchantTerms,oe=s?"zh-CN":"en",Y=b?.subscriptionTerms?.items??[],me=b?b.subscriptionTerms?.trial?.days:e.lines.find(c=>c.trial)?.trial?.days,se=me===void 0?null:b?b.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(c=>c.trial)?0:null,it=(c,w)=>s?`${w} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${c}`:`Then ${c} after the ${w}-day trial`,{label:Nt,recurring:at}=nt(e),_t=e.lines.map(c=>c.productName).join(", "),ot=se===null?"":`${s?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${ce(se,e.currency)}`;_.textContent=ot?[_t,ot].filter(Boolean).join(" \xB7 "):Nt,i.textContent=s?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",i.disabled=t,o.textContent=s?"\u53D6\u6D88":"Cancel",n.style.cssText=O.panel,_.style.cssText=O.summary,u.style.cssText=O.actions,i.style.cssText=O.primary,o.style.cssText=O.secondary,Fe(i),i.onclick=()=>{L(fe)};let st=async()=>{let c=await r.cancel();h||(n.remove(),z=null,await N(c))};o.onclick=()=>{m=st,L(st)};let q=p.createElement("div");if(q.style.cssText=O.terms,b){for(let w of Y){if(se===null&&w===at)continue;let S=p.createElement("p"),B=ce(w.amountMinor,e.currency)+ye(w.interval,oe,w.intervalCount);S.textContent=se!==null&&me!==void 0?it(B,me):B,q.append(S)}let c=b.subscriptionTerms?.trial;if(c){let w=p.createElement("p");w.textContent=s?`\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"}`,q.append(w)}for(let w of[...b.expectedEffects.map(S=>S.description),...b.requiredConsents.map(S=>S.summary)]){let S=p.createElement("p");S.textContent=w,q.append(S)}}else{for(let c of e.lines){if(se!==null||c!==at){let w=p.createElement("p"),S=`${ce(c.catalogAmountMinor,e.currency)}${ye(c.interval,oe,c.intervalCount??1)}`;w.textContent=se!==null&&c.trial?(e.lines.length>1?`${c.productName} \xB7 `:"")+it(S,c.trial.days):`${c.productName} \xB7 ${S}`,q.append(w)}for(let w of c.prepaid??[]){let S=p.createElement("p"),B=r.view?.capabilities.plans[c.productVersionId]?.prepaid?.find(Lt=>Lt.internalFeatureId===w.internal_feature_id);S.textContent=`${B?.name??w.internal_feature_id} \xB7 ${w.quantity} ${s?"\u4EFD":"packs"} \xD7 ${w.terms.units}`,B&&(S.textContent+=ye(B.reset==="week"||B.reset==="month"||B.reset==="year"?B.reset:"one_time",oe,B.resetCount)),q.append(S)}if(c.trial){let w=p.createElement("p");w.textContent=s?`\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"}`,q.append(w)}}if(!e.charge){let c=p.createElement("p");c.textContent=s?"\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.",q.append(c)}}for(let c of q.children)c.style.margin="0";u.append(i,o),n.append(_,...q.childElementCount?[q]:[],u),G.prepend(n),P?.responsive||n.scrollIntoView?.({block:"nearest"}),i.focus({preventScroll:!0}),z=n,m=null}async function pe(){if(!k)return;if(m=pe,!ie){let n=r.view,i=n?.document.buttons[k.actionId],o=n&&i?.type==="checkout"?ne(i.product,k.selection,n.capabilities):null;if(!n||!o)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let u=await a.resolveOfferId?.({actionId:k.actionId,productVersionId:o,featureQuantities:we(n.document.screen,o,k.selection,n.capabilities)});if(h)return;u!==void 0&&(k.offerId=u),ie=!0}if(!I()){y.hidden=!1;return}let e;try{e=await r.preview(k)}catch(n){throw r.canReselect===!0&&(k=null,ie=!1,m=null),n}if(h)return;let t=e.merchantTerms;if(a.confirmOnHostedCheckout&&I()&&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=ue?"":s?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";l.textContent=n;try{await fe()}catch(i){h||X(i)}finally{l.textContent===n&&(l.textContent="")}return}rt(e)}function ae(e="destroy"){h||(h=!0,a.signal?.removeEventListener("abort",F),r.signal?.removeEventListener("abort",F),E.finish("dismissed"),ze?.(),J.abort(),We?.disconnect(),P?.destroy(),U?.destroy(),r.destroy(),x.open&&x.close(),x.remove(),R.remove(),g(),e==="dismiss"&&j(a.onDismiss))}D=ae;async function Ie(){if(!ee||h||ge||W==="closing"||!W&&!I())return;if(!A){ae("dismiss");return}let e=p.createElement("p");e.setAttribute("role","status"),e.textContent=s?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",K||(K=p.createElement("div"),K.style.cssText=G.style.cssText,G.replaceWith(K),re.inert=!0),C.hidden=!1,K.replaceChildren(e,C),W="closing",C.setAttribute("aria-disabled","true"),C.focus({preventScroll:!0});try{await A.dismiss()}catch(t){h||j(a.onError,t)}h||(W="retry",e.textContent=s?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",C.textContent=s?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",C.removeAttribute("aria-label"),C.removeAttribute("aria-disabled"))}C.onclick=()=>{Ie()},x.addEventListener("cancel",e=>{e.preventDefault(),Ie()}),y.onclick=()=>{m&&L(m)};function Me(e){E.finish("error",e),ae()}function qe(){if(!(!Ke||ee||h||ge||P&&!I()))try{let e=t=>{a.focusAtReveal&&(g=je(p)),U?.setHidden?.(!1),De?.(),P&&(x.showModal(),P.responsive&&x.focus({preventScroll:!0}),!t&&a.loading!=="host"&&mt(x,P.type,P.responsive)),ee=!0};A?A.present(()=>E.present(()=>e(!0))):E.present(e)}catch(e){Me(e),X(e)}}try{be.type==="inline"?(Ge(),De=bt(R,T),T.append(R)):(x.setAttribute("aria-label",f.document.name),C.textContent="\xD7",C.setAttribute("aria-label",s?"\u5173\u95ED":"Close"),ht(C,f.document.screen.theme),C.hidden=ft(f.document),x.append(C,R),T.append(x),P=pt(x,{...f.document.screen,presentation:be},Oe),P.latch(),P.responsive&&(R.style.display="flex",R.style.flexDirection="column",R.style.maxHeight="100%",re.style.overflow="clip",re.style.minHeight="0"),De=wt(x)),U=V(re,{mode:"live",rendererUrl:r.webViewUrl,title:f.document.name,closeActions:At,onAuthoredClose(n){W||h||(C.hidden=n)},hostPresentation:()=>P?.type??be.type,reportContentHeight:P?.responsive,onResize:n=>{if(!P?.responsive)return;let i=Math.min(n,Te);re.style.height=`${i}px`,P.setContentHeight(i+(K??G).getBoundingClientRect().height)},onSelection(n){le=n,de()},onAction(n,i={}){if(!ee||h||W)return;let o=r.view,u=o?.document.buttons[n];if(!u)return;if(u.type==="close"&&A&&a.resumeCheckout&&r.operation&&lt(M(r.operation))){Ie();return}if(Z)return;if(!I()){Le();return}if(u.type==="close"){L(async()=>{await a.onAction?.(n),ae(a.onAction?"action":"dismiss")});return}if(u.type==="action"){m=async()=>{if(u.action.type==="event"){if(!a.onEvent)throw new v("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(u.action.event)}else a.onOpenUrl?await a.onOpenUrl(u.action.url):p.defaultView?.location.assign(u.action.url);await a.onAction?.(n),m=null},L(m);return}if(a.allowNewPurchase===!1){te()&&o&&r.quote&&r.operation&&M(r.operation).type==="checkout"&&Pe(r.quote,o,u.product,i)?L(_e,n):l.textContent=s?"\u5F53\u524D\u53EA\u80FD\u7EE7\u7EED\u539F\u8BA2\u5355\u3002":"Only your original checkout is available.";return}if(z&&r.canReselect===!1){l.textContent=s?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",P?.responsive||z.scrollIntoView?.({block:"nearest"}),z.querySelector("button")?.focus({preventScroll:!0});return}if(te()&&H){H.selection.actionId===n&&L(()=>et(!0),n);return}if(te()&&a.terminateCheckout&&o&&r.quote&&r.operation&&r.canReselect===!1&&M(r.operation).type==="checkout"){if(Pe(r.quote,o,u.product,i)){L(_e,n);return}let b=ne(u.product,i,o.capabilities);try{if(!b)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");we(o.document.screen,b,i,o.capabilities)}catch(me){X(me);return}let oe=r.operation.operationId,Y={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(i)};L(()=>St(oe,Y),n);return}if((r.quote||k)&&r.canReselect===!1){let b=!!o&&!!r.quote&&Pe(r.quote,o,u.product,i);Ce=!!r.quote&&!b,m=r.quote?()=>Ue(b):pe,L(m);return}let _=o&&ne(u.product,i,o.capabilities);if(!o||!_){X(new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){m=null,L(async()=>{let b={actionId:n,productVersionId:_,selection:structuredClone(i),featureQuantities:we(o.document.screen,_,i,o.capabilities)};Ne=!0,await a.onPurchaseIntent(b)});return}if(k&&k.actionId!==n){X(new v("COMMAND_PENDING","Finish the current purchase"));return}k||(k={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(i)},ie=!1),L(pe,n)},onEscape:()=>{Ie()},onError:n=>{let i=new Error(n);!ee&&!h&&Me(i),X(i)},onRendered:n=>{n&&x.setAttribute("aria-label",n),Ke=!0,qe()}}),U.setHidden?.(!0),Oe();let e=te()&&!!r.quote&&!!r.operation&&M(r.operation).type==="checkout";le=e?Et(f,r.quote)??{}:{},U.update(f.document.screen,f.document.screen.strings.defaultLocale,{capabilities:f.capabilities,unavailableActions:Qe(f),serverInput:{bindings:[],answers:{}},...Object.keys(le).length?{selection:le}:{}}),ze=r.subscribe?.(Se),Se(r.view??f),await E.wait(U.ready);let t=r.operation;!e&&(r.quote||t&&(t.confirmedAt||t.checkoutUrl||t.status==="complete"))&&(m=()=>Ue(),L(m))}catch(e){throw Me(e),e}return{check:Q,host:{get observing(){return Re},get recovery(){return Rt()},async prepareFallback(){if(Z||h||W||Ne)return{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null};xe(!0);try{let e=await ut(r);return e.type==="native"&&ae(),e}finally{xe(!1)}},setSuspended(e){ge=e,R.hidden=e,e&&x.open?x.close():!e&&!ee?qe():!e&&!h&&ee&&be.type!=="inline"&&!x.open&&x.showModal()},destroy:ae,refresh:async()=>{if(!I()){if(r.view)return r.view;throw new v("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await r.refresh();return Se(e),qe(),e}}}}export{dn as showPaywall};
@@ -0,0 +1 @@
1
+ import{b as a}from"./chunk-W6OQTXLL.js";import"./chunk-BOVN2BE3.js";import"./chunk-PUR5CYWX.js";import"./chunk-TAFALMQN.js";import"./chunk-ZGCKQWQ5.js";import"./chunk-VEX2FOFZ.js";import"./chunk-56BYGPQ6.js";import"./chunk-VYFSRHXM.js";import"./chunk-BQRS7Y4K.js";import"./chunk-U4RSRFZY.js";import"./chunk-KE26KWIU.js";import"./chunk-TJGIT5CU.js";import"./chunk-OX7PA64E.js";import"./chunk-V7MMTILA.js";import"./chunk-3VUPVXAV.js";import"./chunk-EM3MGDPG.js";import"./chunk-VF6QMMEA.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-GZRRVHYK.js";import"./chunk-44U3FOBB.js";import"./chunk-WZR2XCSJ.js";import"./chunk-EUTWY7A2.js";import"./chunk-7MNJH5GB.js";import"./chunk-CIP5SQ5Y.js";import"./chunk-LF2UIJYD.js";import"./chunk-CKKIB2HC.js";import"./chunk-W6OQTXLL.js";import"./chunk-BOVN2BE3.js";import"./chunk-PUR5CYWX.js";import"./chunk-TAFALMQN.js";import"./chunk-ZGCKQWQ5.js";import"./chunk-3NCMYTNG.js";import"./chunk-VEX2FOFZ.js";import"./chunk-V7PFLFHE.js";import"./chunk-5HJYR6Z4.js";import"./chunk-56BYGPQ6.js";import"./chunk-VYFSRHXM.js";import"./chunk-BQRS7Y4K.js";import"./chunk-U4RSRFZY.js";import"./chunk-KE26KWIU.js";import"./chunk-TJGIT5CU.js";import"./chunk-OX7PA64E.js";import"./chunk-V7MMTILA.js";import"./chunk-3VUPVXAV.js";import"./chunk-EM3MGDPG.js";import"./chunk-VF6QMMEA.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
package/dist/popup.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { b as ScreenAction, c as ScreenNode, d as ScreenInteractivity, e as ScreenDocument } from './screen-CGCJ46b1.js';
2
2
  import { O as Offer, a as OfferUnavailableReason } from './coupon-kfkIVf9n.js';
3
- import { e as CustomerPageData, a as SurfaceData, P as PresentationLoadingOptions, f as ScreenParameters, g as ScreenRendererInput, S as ScreenAnswers, C as CustomerDataIntent } from './presentation-loading-CiEQbUDk.js';
4
- export { d as PresentationState } from './presentation-loading-CiEQbUDk.js';
3
+ import { e as CustomerPageData, a as SurfaceData, P as PresentationLoadingOptions, f as ScreenParameters, g as ScreenRendererInput, S as ScreenAnswers, C as CustomerDataIntent } from './presentation-loading-CFSiS0VX.js';
4
+ export { d as PresentationState } from './presentation-loading-CFSiS0VX.js';
5
5
  import { WindowLike } from 'dompurify';
6
6
  import 'zod';
7
7
 
@@ -49,6 +49,17 @@ type ScreenNodeRect = {
49
49
  width: number;
50
50
  height: number;
51
51
  };
52
+ /**
53
+ * Live purchase buttons the host is driving: `resume` actions read `resumeLabel` (the original
54
+ * Checkout continues) and the `busy` action spins while every listed action is held.
55
+ */
56
+ type CheckoutControls = {
57
+ type: "checkout-controls";
58
+ actions: readonly string[];
59
+ resume: readonly string[];
60
+ resumeLabel: string;
61
+ busy?: string;
62
+ };
52
63
  /** Editor shortcuts typed while focus is inside the canvas; the host owns their meaning. */
53
64
  type RendererEditorKey = {
54
65
  key: string;
@@ -144,9 +155,16 @@ type ScreenPreviewHandle = {
144
155
  reset?: boolean;
145
156
  }): void;
146
157
  updateCustomerData(data: CustomerPageData): void;
158
+ /** Live purchase buttons: the original Checkout's label and the in-button progress. */
159
+ updateCheckoutControls(controls: Omit<CheckoutControls, "type">): void;
147
160
  updateCapabilities(data: SurfaceData, unavailableActions?: readonly string[]): void;
148
161
  /** Resize the visible viewport without replacing the document or interaction state. */
149
162
  resizeViewport(height: number, width?: number): void;
163
+ /**
164
+ * A staging host keeps the frame rendered but unseen: its motion waits until
165
+ * it is shown again. Frames that predate this message keep animating.
166
+ */
167
+ setHidden(hidden: boolean): void;
150
168
  /** 编辑模式下的悬停与选中描边。 */
151
169
  highlight(hoverId: string | null, selectedId: string | null): void;
152
170
  destroy(): void;
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-MPYJRLKB.js";import"./chunk-BRAVNBCC.js";import"./chunk-N7YXDSQL.js";import"./chunk-MIBRUDIS.js";import"./chunk-X4W22IH6.js";import"./chunk-R4FDIYMN.js";import"./chunk-VF6QMMEA.js";import"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.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};
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-TOTRALYQ.js";import"./chunk-XUGEOELU.js";import"./chunk-BQRS7Y4K.js";import"./chunk-U4RSRFZY.js";import"./chunk-KE26KWIU.js";import"./chunk-TJGIT5CU.js";import"./chunk-OX7PA64E.js";import"./chunk-V7MMTILA.js";import"./chunk-VF6QMMEA.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-DSPLGTQI.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};
@@ -992,6 +992,8 @@ type PaywallLoadingDocument = {
992
992
  screen: ScreenDocument;
993
993
  buttons?: PublicPaywall["buttons"];
994
994
  };
995
+ /** Render the authored layout in the same sandbox used by the live Paywall. */
996
+ declare function renderPaywallLoadingDocument(panel: HTMLElement, holder: HTMLElement, input: PaywallLoadingDocument, locale: string, onRendered: () => void): () => void;
995
997
 
996
998
  type Surface = "page" | "popup" | "banner" | "paywall" | "funnel";
997
999
  type PresentationState = {
@@ -1014,7 +1016,7 @@ type PresentationLoadingOptions = {
1014
1016
  signal?: AbortSignal;
1015
1017
  };
1016
1018
  /** One loading cycle. No authored content or controls are exposed during it. */
1017
- declare function createPresentationLoading(container: HTMLElement | ShadowRoot, options: PresentationLoadingOptions, surface: Surface, onDismiss: () => void): {
1019
+ declare function createPresentationLoading(container: HTMLElement | ShadowRoot, options: PresentationLoadingOptions, surface: Surface, onDismiss: () => void, renderPaywall?: typeof renderPaywallLoadingDocument): {
1018
1020
  setDismissHandler(handler: () => void): void;
1019
1021
  readonly active: boolean;
1020
1022
  readonly cancelled: boolean;
@@ -1,7 +1,7 @@
1
- import { f as createCustomerClient, d as createFunnelClient } from './funnel-process-client-C6QKDZun.js';
2
- export { F as FunnelProcessAdapter, a as FunnelProcessOptions, c as createFunnelProcess } from './funnel-process-client-C6QKDZun.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-BeGBvi3z.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-BeGBvi3z.js';
1
+ import { f as createCustomerClient, d as createFunnelClient } from './funnel-process-client-D6qjStm2.js';
2
+ export { F as FunnelProcessAdapter, a as FunnelProcessOptions, c as createFunnelProcess } from './funnel-process-client-D6qjStm2.js';
3
+ import { I as IndianaOptions, b as SessionCredentials, G as Scope, A as createFunnelRunController, w as PaywallStartInput, k as createPaywallSession } from './funnel-local-client-Dz1dTgES.js';
4
+ export { F as FunnelCommandStorage, f as FunnelRunController, t as LocalFunnelClientOptions, u as LongplayError, v as PaywallPurchaseInput, P as PaywallSession, x as PushHost, y as PushJournal, z as createFeatureClient, B as createLocalFunnelClient } from './funnel-local-client-Dz1dTgES.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';
@@ -1 +1 @@
1
- import{b as S,c as E,d as T}from"./chunk-XLSDL4D3.js";import"./chunk-GGRDM54V.js";import{a as A}from"./chunk-YTZQ5BMP.js";import{e as P}from"./chunk-ILEDKSRQ.js";import"./chunk-EQPEUPMG.js";import{h as b,i as x,k as L}from"./chunk-KR3KDTVD.js";import"./chunk-FYQXSGRT.js";import"./chunk-7MNJH5GB.js";import{F as C}from"./chunk-U6E6CM7Z.js";import"./chunk-JN6JEKWN.js";import"./chunk-THMGTRXP.js";import"./chunk-NAZU3EEJ.js";import"./chunk-SCC3O2RD.js";import"./chunk-R23IGK5U.js";import"./chunk-ZGCKQWQ5.js";import"./chunk-EHDHWYVJ.js";import"./chunk-BXPXJARS.js";import"./chunk-5HJYR6Z4.js";import"./chunk-U2R7MG3J.js";import"./chunk-VYFSRHXM.js";import"./chunk-N7YXDSQL.js";import"./chunk-MIBRUDIS.js";import{a as r}from"./chunk-X4W22IH6.js";import{h as R}from"./chunk-R4FDIYMN.js";import"./chunk-3VUPVXAV.js";import"./chunk-UHQGO6OR.js";import"./chunk-VF6QMMEA.js";import"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.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};
1
+ import{b as S,c as E,d as T}from"./chunk-RML52BOR.js";import"./chunk-KPDHY76A.js";import{a as A}from"./chunk-GZRRVHYK.js";import{e as P}from"./chunk-44U3FOBB.js";import"./chunk-WZR2XCSJ.js";import{h as b,i as x,k as L}from"./chunk-BLVBUN2R.js";import{F as C}from"./chunk-2FE4FTPH.js";import"./chunk-EUTWY7A2.js";import"./chunk-7MNJH5GB.js";import"./chunk-CIP5SQ5Y.js";import"./chunk-LF2UIJYD.js";import"./chunk-CKKIB2HC.js";import"./chunk-W6OQTXLL.js";import"./chunk-BOVN2BE3.js";import"./chunk-PUR5CYWX.js";import"./chunk-TAFALMQN.js";import"./chunk-ZGCKQWQ5.js";import"./chunk-3NCMYTNG.js";import"./chunk-VEX2FOFZ.js";import"./chunk-V7PFLFHE.js";import"./chunk-5HJYR6Z4.js";import"./chunk-56BYGPQ6.js";import"./chunk-VYFSRHXM.js";import"./chunk-BQRS7Y4K.js";import"./chunk-U4RSRFZY.js";import"./chunk-KE26KWIU.js";import{b as R}from"./chunk-TJGIT5CU.js";import{a as r}from"./chunk-OX7PA64E.js";import"./chunk-V7MMTILA.js";import"./chunk-3VUPVXAV.js";import"./chunk-EM3MGDPG.js";import"./chunk-VF6QMMEA.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-DSPLGTQI.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-TOTRALYQ.js";import"./chunk-XUGEOELU.js";import"./chunk-BQRS7Y4K.js";import"./chunk-U4RSRFZY.js";import"./chunk-KE26KWIU.js";import"./chunk-TJGIT5CU.js";import"./chunk-OX7PA64E.js";import"./chunk-V7MMTILA.js";import"./chunk-VF6QMMEA.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-DSPLGTQI.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-Do-6AyWa.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-BeGBvi3z.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-BeGBvi3z.js';
2
+ import { Q as IndianaServerOptions, u as IndianaError, T as FunnelProcessSuppression, U as FunnelProcessCommand, K as FunnelProcessResponse, C as CustomerSession, J as FunnelProcessOpenInput, N as FunnelProcessMutation, w as PaywallStartInput, P as PaywallSession, m as FeatureClientOptions, R as RemoteFeatureResult } from './funnel-local-client-Dz1dTgES.js';
3
+ export { l as FeatureClient, a as FunnelStartInput, L as LocalFunnelClient, t as LocalFunnelClientOptions, z as createFeatureClient, V as createFunnelStartClient, B as createLocalFunnelClient } from './funnel-local-client-Dz1dTgES.js';
4
4
  import * as zod from 'zod';
5
5
  import { z } from 'zod';
6
6
  import { S as StackNode } from './screen-CGCJ46b1.js';
@@ -537,6 +537,7 @@ declare const merchantBridgeV4ManifestSchema: z.ZodObject<{
537
537
  preparations: "preparations";
538
538
  benefit_claims: "benefit_claims";
539
539
  business_results: "business_results";
540
+ checkout_termination: "checkout_termination";
540
541
  }>>;
541
542
  checkKinds: z.ZodArray<z.ZodEnum<{
542
543
  access: "access";
@@ -757,6 +758,10 @@ declare const merchantBridgeV4CommandInputs: {
757
758
  operationId: z.ZodUUID;
758
759
  customerId: z.ZodUUID;
759
760
  }, z.core.$strict>;
761
+ readonly "purchase.terminate": z.ZodObject<{
762
+ operationId: z.ZodUUID;
763
+ customerId: z.ZodUUID;
764
+ }, z.core.$strict>;
760
765
  };
761
766
  declare const merchantBridgeV4CommandOutputs: {
762
767
  readonly "bridge.ping": z.ZodObject<{
@@ -781,6 +786,7 @@ declare const merchantBridgeV4CommandOutputs: {
781
786
  preparations: "preparations";
782
787
  benefit_claims: "benefit_claims";
783
788
  business_results: "business_results";
789
+ checkout_termination: "checkout_termination";
784
790
  }>>;
785
791
  checkKinds: z.ZodArray<z.ZodEnum<{
786
792
  access: "access";
@@ -1205,6 +1211,14 @@ declare const merchantBridgeV4CommandOutputs: {
1205
1211
  expiresAt: z.ZodISODateTime;
1206
1212
  }, z.core.$strict>;
1207
1213
  }, z.core.$strict>], "lookup">;
1214
+ readonly "purchase.terminate": z.ZodObject<{
1215
+ operationId: z.ZodUUID;
1216
+ customerId: z.ZodUUID;
1217
+ outcome: z.ZodEnum<{
1218
+ requested: "requested";
1219
+ already_paid: "already_paid";
1220
+ }>;
1221
+ }, z.core.$strict>;
1208
1222
  };
1209
1223
  type MerchantBridgeV4Command = keyof typeof merchantBridgeV4CommandInputs;
1210
1224
  declare const merchantBridgeV4RequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -1426,6 +1440,22 @@ declare const merchantBridgeV4RequestSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
1426
1440
  operationId: z.ZodUUID;
1427
1441
  customerId: z.ZodUUID;
1428
1442
  }, z.core.$strict>;
1443
+ }, z.core.$strict>, z.ZodObject<{
1444
+ bridgeVersion: z.ZodLiteral<4>;
1445
+ requestId: z.ZodUUID;
1446
+ scope: z.ZodObject<{
1447
+ projectId: z.ZodUUID;
1448
+ environmentId: z.ZodUUID;
1449
+ environment: z.ZodEnum<{
1450
+ sandbox: "sandbox";
1451
+ live: "live";
1452
+ }>;
1453
+ }, z.core.$strict>;
1454
+ command: z.ZodLiteral<"purchase.terminate">;
1455
+ data: z.ZodObject<{
1456
+ operationId: z.ZodUUID;
1457
+ customerId: z.ZodUUID;
1458
+ }, z.core.$strict>;
1429
1459
  }, z.core.$strict>], "command">;
1430
1460
  type MerchantBridgeV4Request<C extends MerchantBridgeV4Command = MerchantBridgeV4Command> = Extract<z.infer<typeof merchantBridgeV4RequestSchema>, {
1431
1461
  command: C;