@tinkerlandai/longplay-sdk 0.10.82 → 0.10.84

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 (98) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +2 -0
  3. package/dist/check-response-AB52X53M.js +1 -0
  4. package/dist/{chunk-PUDTOCQF.js → chunk-25LM2JXB.js} +1 -1
  5. package/dist/{chunk-PFEJZEVM.js → chunk-3AUMX2ZW.js} +1 -1
  6. package/dist/{chunk-3532HSBP.js → chunk-3QRVHAWK.js} +1 -1
  7. package/dist/{chunk-7ZAM4YRK.js → chunk-45PGU2HW.js} +1 -1
  8. package/dist/{chunk-V5OI4YOT.js → chunk-45RTRADT.js} +1 -1
  9. package/dist/{chunk-US4W5LDV.js → chunk-4CWYR6NX.js} +1 -1
  10. package/dist/chunk-57NEGKC5.js +1 -0
  11. package/dist/{chunk-EQUVI5QU.js → chunk-AH36XJ2P.js} +1 -1
  12. package/dist/{chunk-A5WUQLAO.js → chunk-B3FNR6MN.js} +1 -1
  13. package/dist/{chunk-LFR2LWYC.js → chunk-BJSY53HD.js} +1 -1
  14. package/dist/{chunk-3IDJUC7A.js → chunk-BKN33GVY.js} +1 -1
  15. package/dist/{chunk-UGATOG2T.js → chunk-BNVQIMXY.js} +1 -1
  16. package/dist/{chunk-VXNN3RV3.js → chunk-CTDXIKX3.js} +1 -1
  17. package/dist/{chunk-ME6QTD5Y.js → chunk-DGGXLPHI.js} +1 -1
  18. package/dist/{chunk-KX67ZM7H.js → chunk-EPKQGOCT.js} +1 -1
  19. package/dist/{chunk-KCUE2VFJ.js → chunk-FRWORXER.js} +1 -1
  20. package/dist/{chunk-Y6KA56V2.js → chunk-HFLMTQ5S.js} +1 -1
  21. package/dist/{chunk-67WFVDTV.js → chunk-HJLZY2VK.js} +1 -1
  22. package/dist/{chunk-7QPCNDIY.js → chunk-HVDAQX2D.js} +1 -1
  23. package/dist/{chunk-XCURKI2P.js → chunk-HVWHUYSF.js} +2 -2
  24. package/dist/{chunk-LXAOFLCO.js → chunk-J6F2XFDL.js} +1 -1
  25. package/dist/chunk-K6Q64QHZ.js +1 -0
  26. package/dist/{chunk-YKPTPRS5.js → chunk-KHJZA73V.js} +1 -1
  27. package/dist/{chunk-F4AIEI5N.js → chunk-MCQGIPH7.js} +1 -1
  28. package/dist/{chunk-6VVQWTHV.js → chunk-NBIHNC2C.js} +1 -1
  29. package/dist/{chunk-SX7U2ONB.js → chunk-OT3ED6TT.js} +1 -1
  30. package/dist/{chunk-CKMSSBJM.js → chunk-P6O6ULXW.js} +1 -1
  31. package/dist/{chunk-S2S4ROGY.js → chunk-Q2ZKKRIB.js} +1 -1
  32. package/dist/{chunk-BOT6ZDLK.js → chunk-Q3K63EFB.js} +1 -1
  33. package/dist/{chunk-6XRQR43F.js → chunk-R6NVHYXW.js} +1 -1
  34. package/dist/{chunk-CO6HDNOC.js → chunk-RWGMLH42.js} +1 -1
  35. package/dist/{chunk-FPJ3FE26.js → chunk-S7UDY3NL.js} +1 -1
  36. package/dist/chunk-SBZFPW6N.js +1 -0
  37. package/dist/{chunk-LQV7EC5H.js → chunk-SY3GVNMT.js} +1 -1
  38. package/dist/chunk-TG7FSNRF.js +1 -0
  39. package/dist/{chunk-DMI26MYC.js → chunk-TGY77F4A.js} +1 -1
  40. package/dist/{chunk-2EBHH36T.js → chunk-TQIZN3GB.js} +1 -1
  41. package/dist/{chunk-2OBXRQMW.js → chunk-U3TW2YVO.js} +1 -1
  42. package/dist/{chunk-M5TCDVMJ.js → chunk-UDVFPFL6.js} +1 -1
  43. package/dist/{chunk-DVETYJRC.js → chunk-UO3DDQEW.js} +1 -1
  44. package/dist/{chunk-MOIVJERE.js → chunk-VJXGTINT.js} +1 -1
  45. package/dist/{chunk-FYMVNLQN.js → chunk-VPT5MFDG.js} +2 -2
  46. package/dist/{chunk-DUS5V65Z.js → chunk-VUGDBVIZ.js} +1 -1
  47. package/dist/{chunk-FYUMVOCV.js → chunk-W5MSVU2K.js} +1 -1
  48. package/dist/{chunk-7CZEXBQY.js → chunk-X6WXJJED.js} +1 -1
  49. package/dist/{chunk-Y3W5G4BF.js → chunk-YBDTPMGD.js} +1 -1
  50. package/dist/{chunk-XLGNBPGF.js → chunk-YJHL2DPP.js} +1 -1
  51. package/dist/{chunk-CHRNCOXJ.js → chunk-YMNCFP4X.js} +1 -1
  52. package/dist/{chunk-GZK5X6HY.js → chunk-Z42LII54.js} +1 -1
  53. package/dist/{chunk-BT7IC765.js → chunk-ZBVIIFB4.js} +1 -1
  54. package/dist/{content-4CLPWHZA.js → content-YCHZNM7Y.js} +1 -1
  55. package/dist/{funnel-host-purchase-VVJR6CTK.js → funnel-host-purchase-O2XMLQLO.js} +1 -1
  56. package/dist/funnel-host-recovery-paywall-3OLSW5TK.js +1 -0
  57. package/dist/{funnel-paywall-copies-LPOTYSTS.js → funnel-paywall-copies-GHMZFYUK.js} +1 -1
  58. package/dist/funnel-paywall-prerender-ZUE3E5CD.js +1 -0
  59. package/dist/funnel-route-prediction-EFAGTU7F.js +1 -0
  60. package/dist/funnel-route-source-D66HFVVK.js +1 -0
  61. package/dist/funnel-runtime-host-CHUEAXTG.js +1 -0
  62. package/dist/index.js +1 -1
  63. package/dist/merchant-bridge-contracts-RF4XQQTE.js +1 -0
  64. package/dist/native-shell.js +1 -1
  65. package/dist/openrouter.js +1 -1
  66. package/dist/operation-contracts-IAMHNJCL.js +1 -0
  67. package/dist/page.js +1 -1
  68. package/dist/paywall-SMS52HSX.js +1 -0
  69. package/dist/paywall-content-ZJWLT3BD.js +1 -0
  70. package/dist/paywall-session-YNYTE7BE.js +1 -0
  71. package/dist/popup.js +1 -1
  72. package/dist/react-native.js +1 -1
  73. package/dist/screen-renderer-MVJ5BKQS.js +1 -0
  74. package/dist/server.js +1 -1
  75. package/dist/{visual-dom-KUABNJV6.js → visual-dom-5LUN4AHO.js} +1 -1
  76. package/dist/visual.js +1 -1
  77. package/package.json +1 -1
  78. package/dist/check-response-XGOTG3KL.js +0 -1
  79. package/dist/chunk-EQBJNU6R.js +0 -1
  80. package/dist/chunk-SVRKXSZR.js +0 -1
  81. package/dist/chunk-TK5HLSLY.js +0 -1
  82. package/dist/chunk-UT4LWHP6.js +0 -1
  83. package/dist/funnel-host-recovery-paywall-ENWNYNHN.js +0 -1
  84. package/dist/funnel-paywall-prerender-M2H3XT4R.js +0 -1
  85. package/dist/funnel-route-prediction-Q4HMRAVQ.js +0 -1
  86. package/dist/funnel-route-source-HYWJWEM3.js +0 -1
  87. package/dist/funnel-runtime-host-YM5QWGDI.js +0 -1
  88. package/dist/merchant-bridge-contracts-OIYML3DE.js +0 -1
  89. package/dist/operation-contracts-YJM6772C.js +0 -1
  90. package/dist/paywall-VS6HDN7Z.js +0 -1
  91. package/dist/paywall-content-RV2TV6A2.js +0 -1
  92. package/dist/paywall-session-PG7XUJ6W.js +0 -1
  93. package/dist/screen-renderer-HJOKBOZH.js +0 -1
  94. /package/dist/{chunk-FRK6322O.js → chunk-CILM5XMH.js} +0 -0
  95. /package/dist/{chunk-XCURKI2P.js.LEGAL.txt → chunk-HVWHUYSF.js.LEGAL.txt} +0 -0
  96. /package/dist/{chunk-KV5MZ4NI.js → chunk-OJM6ORHE.js} +0 -0
  97. /package/dist/{chunk-W22ESUYY.js → chunk-VITB5MIL.js} +0 -0
  98. /package/dist/{chunk-FYMVNLQN.js.LEGAL.txt → chunk-VPT5MFDG.js.LEGAL.txt} +0 -0
@@ -1 +1 @@
1
- import{a as p}from"./chunk-UGATOG2T.js";import{a as d}from"./chunk-W22ESUYY.js";function I(n,r,i){if(!["subscriptions/operations/read","subscriptions/updates/read","subscriptions/refunds/read"].includes(n))return;let e=r,s=i,o=s.operation;if(o.operationId!==e.operationId||[o.authority,o.merchantExecution].some(t=>t&&(t.operationId!==e.operationId||e.customerId!==void 0&&t.customerId!==e.customerId))||o.authority&&(o.authority.scope.projectId!==s.scope.projectId||o.authority.scope.environment!==s.scope.environment))throw new p("INVALID_RESPONSE","Original commerce operation changed")}function g(n){try{return structuredClone(n)}catch{return n}}async function E(n,r){let i=n.captureIdentity?.(),{apiOperations:e}=await import("./operation-contracts-YJM6772C.js");return i?.(),e[r]}function m(n,r,i,e){try{return n.parse(r)}catch(s){throw e&&s instanceof d?new p(i,e):s}}async function P(n,r,i,e={},s){let o=typeof e=="function"?{}:e,t=m(r.request,i,"INVALID_REQUEST",o.request);try{let a=await n(r.path,t,r.method,s),u=typeof e=="function"?e:e.parseResponse,c=u?u(r.response,a):m(r.response,a,"INVALID_RESPONSE",o.response);return I(r.path,t,c),c}catch(a){throw a instanceof p&&t!==null&&typeof t=="object"&&"requestId"in t&&typeof t.requestId=="string"&&(a.commandRequestId??=t.requestId),a}}export{g as a,E as b,P as c};
1
+ import{a as p}from"./chunk-BNVQIMXY.js";import{a as d}from"./chunk-VITB5MIL.js";function I(n,r,i){if(!["subscriptions/operations/read","subscriptions/updates/read","subscriptions/refunds/read"].includes(n))return;let e=r,s=i,o=s.operation;if(o.operationId!==e.operationId||[o.authority,o.merchantExecution].some(t=>t&&(t.operationId!==e.operationId||e.customerId!==void 0&&t.customerId!==e.customerId))||o.authority&&(o.authority.scope.projectId!==s.scope.projectId||o.authority.scope.environment!==s.scope.environment))throw new p("INVALID_RESPONSE","Original commerce operation changed")}function g(n){try{return structuredClone(n)}catch{return n}}async function E(n,r){let i=n.captureIdentity?.(),{apiOperations:e}=await import("./operation-contracts-IAMHNJCL.js");return i?.(),e[r]}function m(n,r,i,e){try{return n.parse(r)}catch(s){throw e&&s instanceof d?new p(i,e):s}}async function P(n,r,i,e={},s){let o=typeof e=="function"?{}:e,t=m(r.request,i,"INVALID_REQUEST",o.request);try{let a=await n(r.path,t,r.method,s),u=typeof e=="function"?e:e.parseResponse,c=u?u(r.response,a):m(r.response,a,"INVALID_RESPONSE",o.response);return I(r.path,t,c),c}catch(a){throw a instanceof p&&t!==null&&typeof t=="object"&&"requestId"in t&&typeof t.requestId=="string"&&(a.commandRequestId??=t.requestId),a}}export{g as a,E as b,P as c};
@@ -1 +1 @@
1
- import{g as p}from"./chunk-LFR2LWYC.js";import{b as r}from"./chunk-W22ESUYY.js";import{a as i,b as s}from"./chunk-FRK6322O.js";var b=r.string().regex(/^[a-f0-9]{64}$/),j=r.strictObject({scope:r.strictObject({projectId:r.uuid(),environmentId:r.uuid(),environment:p}),customerId:r.uuid()});function l(u){let n=e=>{if(Array.isArray(e))return`[${e.map(n).join(",")}]`;if(e!==null&&typeof e=="object"){let c=Object.getPrototypeOf(e);if(c!==Object.prototype&&c!==null)throw new TypeError("Commerce protocol digests require JSON objects");return`{${Object.entries(e).filter(([,o])=>o!==void 0).sort(([o],[t])=>o<t?-1:o>t?1:0).map(([o,t])=>`${JSON.stringify(o)}:${n(t)}`).join(",")}}`}if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return JSON.stringify(e);throw new TypeError("Commerce protocol digests require JSON values")};return i(s(new TextEncoder().encode(n(u))))}export{b as a,j as b,l as c};
1
+ import{g as p}from"./chunk-BJSY53HD.js";import{b as r}from"./chunk-VITB5MIL.js";import{a as i,b as s}from"./chunk-CILM5XMH.js";var b=r.string().regex(/^[a-f0-9]{64}$/),j=r.strictObject({scope:r.strictObject({projectId:r.uuid(),environmentId:r.uuid(),environment:p}),customerId:r.uuid()});function l(u){let n=e=>{if(Array.isArray(e))return`[${e.map(n).join(",")}]`;if(e!==null&&typeof e=="object"){let c=Object.getPrototypeOf(e);if(c!==Object.prototype&&c!==null)throw new TypeError("Commerce protocol digests require JSON objects");return`{${Object.entries(e).filter(([,o])=>o!==void 0).sort(([o],[t])=>o<t?-1:o>t?1:0).map(([o,t])=>`${JSON.stringify(o)}:${n(t)}`).join(",")}}`}if(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number"&&Number.isFinite(e))return JSON.stringify(e);throw new TypeError("Commerce protocol digests require JSON values")};return i(s(new TextEncoder().encode(n(u))))}export{b as a,j as b,l as c};
@@ -1 +1 @@
1
- import{k as c}from"./chunk-FYUMVOCV.js";import{b as r}from"./chunk-W22ESUYY.js";var s=r.strictObject({items:r.array(r.strictObject({productVersionId:r.string().min(1).max(200),label:r.string().trim().max(40)})).max(20).refine(e=>new Set(e.map(t=>t.productVersionId)).size===e.length,"Duplicate Paywall Product"),defaultProductVersionId:r.string().min(1).max(200).nullable(),grouping:c.optional()});function p(e,t,n){let i=e.type==="fixed"?e.productVersionId:t[e.pickerId];return typeof i!="string"||!Object.values(n.plans).some(o=>o.versionId===i&&o.available)||e.type==="picker"&&(!e.allowedProductVersionIds.includes(i)||!n.pickers[e.pickerId]?.options.includes(i))?null:i}export{s as a,p as b};
1
+ import{k as c}from"./chunk-W5MSVU2K.js";import{b as r}from"./chunk-VITB5MIL.js";var s=r.strictObject({items:r.array(r.strictObject({productVersionId:r.string().min(1).max(200),label:r.string().trim().max(40)})).max(20).refine(e=>new Set(e.map(t=>t.productVersionId)).size===e.length,"Duplicate Paywall Product"),defaultProductVersionId:r.string().min(1).max(200).nullable(),grouping:c.optional()});function p(e,t,n){let i=e.type==="fixed"?e.productVersionId:t[e.pickerId];return typeof i!="string"||!Object.values(n.plans).some(o=>o.versionId===i&&o.available)||e.type==="picker"&&(!e.allowedProductVersionIds.includes(i)||!n.pickers[e.pickerId]?.options.includes(i))?null:i}export{s as a,p as b};
@@ -1 +1 @@
1
- import{c as I}from"./chunk-A5WUQLAO.js";import{a as z}from"./chunk-DSPLGTQI.js";var F={sm:420,md:640,lg:900},B=767;function q(e,t,r=()=>!0,a="Close"){let n=e.ownerDocument.defaultView,o=e.ownerDocument.createElement("button");o.type="button",o.setAttribute("aria-label",a),o.style.cssText="position:absolute;inset:0 48px auto;z-index:2;height:24px;border:0;padding:0;background:transparent;touch-action:none;cursor:grab";let s=e.ownerDocument.createElement("span");s.style.cssText="display:block;width:36px;height:4px;border-radius:4px;margin:8px auto 12px;background:currentColor;opacity:.22;pointer-events:none",o.append(s),e.prepend(o);let d,l=0,c=!1,p=()=>{o.hidden=e.dataset.presentation!=="sheet",o.setAttribute("aria-disabled",String(!r()))},b=i=>{p(),!(o.hidden||!r()||i.button!==0)&&(d={y:i.clientY,time:Date.now(),id:i.pointerId},l=0,c=!1,o.setPointerCapture?.(i.pointerId))},x=i=>{!d||i.pointerId!==d.id||(l=Math.max(0,i.clientY-d.y),e.style.transform=`translateY(${l}px)`)},v=i=>{if(!d||i.pointerId!==d.id)return;let g=Math.max(1,Date.now()-d.time),P=i.type!=="pointercancel"&&r()&&(l>120||l>40&&l/g>.5);c=l>6,d=void 0,o.releasePointerCapture?.(i.pointerId),e.style.transform="",P?t():l&&typeof e.animate=="function"&&!n?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&e.animate([{transform:`translateY(${l}px)`},{transform:"none"}],{duration:200,easing:"cubic-bezier(.2,.8,.2,1)"}),l=0},m=()=>{if(c){c=!1;return}!d&&l===0&&r()&&t()};o.addEventListener("pointerdown",b),o.addEventListener("pointermove",x),o.addEventListener("pointerup",v),o.addEventListener("pointercancel",v),o.addEventListener("click",m);let D=typeof MutationObserver=="function"?new MutationObserver(p):void 0;return D?.observe(e,{attributes:!0,attributeFilter:["data-presentation"]}),n?.addEventListener("resize",p),p(),()=>{D?.disconnect(),n?.removeEventListener("resize",p),o.remove(),e.style.transform=""}}function X(e,t,r){if(e==="paywall")return`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${t.type==="fullscreen"?"100vw":`${F[t.size]}px`}`;if(e==="content")return"box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;"+(t.type==="fullscreen"?"width:100vw":`width:${I[t.size]}px${t.type==="sheet"?";margin:auto auto 0":""}`);let a=t.type!=="fullscreen"&&!t.backdrop?",0 0 0 100vmax #16142566":"";return`box-sizing:border-box;padding:0;border:0;overflow:auto;background:${r.background};color:${r.text};`+(t.type==="fullscreen"?"width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border-radius:0":`width:${F[t.size]}px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 24px 80px #0003${a};`+(t.type==="sheet"?"margin:auto auto 0;border-radius:14px 14px 0 0":"border-radius:14px"))}function De(e,t,r,a){let n=q(e,t,r,a),o=s=>{if(s.target!==e)return;let d=e.getBoundingClientRect();(s.clientX<d.left||s.clientX>d.right||s.clientY<d.top||s.clientY>d.bottom)&&t()};return e.addEventListener("click",o),()=>{n(),e.removeEventListener("click",o)}}function j(e,t,r=!1){return(e.type==="modal"||e.type==="sheet")&&e.mobile&&r&&t<=B?e.mobile:e.type}function J(e,t,r){let a=e.ownerDocument.defaultView,n=t.presentation,o;if((n.type==="modal"||n.type==="sheet")&&n.backdrop){let i=`lp-backdrop-${crypto.randomUUID()}`,g={none:"transparent",scrim:"#f2f2f2cc",dim:"#0006","strong-dim":"#000000bf",blur:"#0006"};e.dataset.indianaBackdrop=i,o=e.ownerDocument.createElement("style"),o.textContent=`dialog[data-indiana-backdrop="${i}"]::backdrop{background:${g[n.backdrop]};backdrop-filter:${n.backdrop==="blur"?"blur(16px)":"none"}}`,e.append(o)}let s=t.pages?.[0]?.root.style?.shape,d=s?.type==="pill"?"9999px":s?.type==="rect"?typeof s.radius=="number"?`${s.radius}px`:[s.radius.topLeft,s.radius.topRight,s.radius.bottomRight,s.radius.bottomLeft].map(i=>`${i}px`).join(" "):void 0,l=(n.type==="modal"||n.type==="sheet")&&(n.desktopWidth!==void 0||n.mobile!==void 0||n.type==="modal"&&n.position!==void 0),c=n.type,p,b,x=!1,v=i=>{x||!Number.isFinite(i)||i<0||(b=i,c!=="fullscreen"&&c!=="inline"&&(e.style.height=`min(${Math.max(i,40)}px, calc(100dvh - ${c==="sheet"?0:32}px))`))},m=()=>{if(!x&&(c=p??j(n,a?.innerWidth??1024,a?.matchMedia?.("(pointer: coarse)").matches===!0),e.dataset.presentation=c,!(!l||n.type!=="modal"&&n.type!=="sheet"))){if(e.style.boxSizing="border-box",e.style.padding="0",e.style.border="0",e.style.overflow="hidden",e.style.outline="none",e.tabIndex=-1,e.style.background=t.theme.background,e.style.color=t.theme.text,c==="fullscreen")e.style.width="100vw",e.style.height="100dvh",e.style.maxWidth="100vw",e.style.maxHeight="100dvh",e.style.margin="0",e.style.borderRadius="0";else{let i=n.mobile==="sheet"&&c==="sheet",g=n.desktopWidth,P=a?.innerWidth??1024;e.style.width=i?`${P}px`:g?`${Math.min(g.max,Math.max(P*g.viewport/100,g.min))}px`:`${I[n.size]}px`,e.style.maxWidth=`${Math.max(0,P-(c==="sheet"?0:32))}px`,e.style.maxHeight=c==="sheet"?"100dvh":"calc(100dvh - 32px)",e.style.margin=c==="sheet"?"auto auto 0":n.type==="modal"&&n.position==="top"?"16px auto auto":n.type==="modal"&&n.position==="bottom"?"auto auto 16px":"auto",e.style.borderRadius=d??(c==="sheet"?"16px 16px 0 0":"24px"),e.style.height="",b!==void 0&&v(b)}r?.(c)}},D=l?[a?.matchMedia?.(`(max-width: ${B}px)`),a?.matchMedia?.("(pointer: coarse)")].filter(i=>i!==void 0):[];if(l){a?.addEventListener("resize",m);for(let i of D)i.addEventListener?i.addEventListener("change",m):i.addListener?.(m)}return m(),{responsive:l,get type(){return c},latch(){x||p!==void 0||(m(),p=c)},setContentHeight:v,destroy(){if(!x){x=!0,o?.remove(),delete e.dataset.indianaBackdrop,a?.removeEventListener("resize",m);for(let i of D)i.removeEventListener?i.removeEventListener("change",m):i.removeListener?.(m)}}}}function Le(e,t,r){let{presentation:a}=t;return e.style.cssText=X("paywall",a.type==="inline"?{type:"fullscreen"}:a,t.theme),J(e,t,r)}function Te(e,t,r=!1){let a=e.ownerDocument.defaultView;if(typeof e.animate!="function"||a?.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;let n=r?{duration:300,easing:"cubic-bezier(0.23, 1, 0.32, 1)"}:{duration:240,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)"};e.animate(t==="sheet"?[{transform:"translateY(100%)"},{transform:"none"}]:t==="modal"?[{opacity:0,transform:r?"translateY(12px) scale(0.96)":"translateY(8px) scale(0.98)"},{opacity:1,transform:"none"}]:[{opacity:0},{opacity:1}],n);try{e.animate([{opacity:0},{opacity:1}],{...n,pseudoElement:"::backdrop"})}catch{}}function V(e,t){e.style.cssText=["position:absolute","z-index:1","top:calc(4px + env(safe-area-inset-top, 0px))","inset-inline-end:calc(4px + env(safe-area-inset-right, 0px))","width:44px","height:44px","padding:0","border:0","border-radius:50%","font:400 20px/1 system-ui,sans-serif","cursor:pointer","touch-action:manipulation"].join(";"),e.style.background=`radial-gradient(circle, ${t.background} 0 15px, color-mix(in srgb, ${t.text} 22%, ${t.background}) 15px 16px, transparent 16.5px)`,e.style.color=t.text}function ke(e){let t=e.closest("dialog");if(!t?.open||!t.isConnected)return;let r=["style","tabindex","aria-label","data-presentation","data-indiana-backdrop"].map(a=>[a,t.getAttribute(a)]);return{dialog:t,content:e,release(){for(let[a,n]of r)n===null?t.removeAttribute(a):t.setAttribute(a,n)}}}var O=new WeakMap;function Ce(e,t){return O.set(e,t),()=>O.delete(e)}function Y(e){let t=e.defaultView?.HTMLElement,r=e.activeElement;for(let n=0;n<16&&r?.shadowRoot?.activeElement;n++)r=r.shadowRoot.activeElement;let a=r?O.get(r)?.():void 0;return()=>{!r?.isConnected||!t||!(r instanceof t)||(r.focus({preventScroll:!0}),a?.())}}var $e=15e3;function ze(e,t,r,a,n){let o=e.ownerDocument,s=new AbortController,d=!1,l=!1,c,p,b,x,v,m;function D(){clearTimeout(m),m=void 0,b?.(),b=void 0,c?.tagName==="DIALOG"&&c.close?.(),c?.remove(),c=void 0,p=void 0,v=void 0}function i(u,w){l||(l=!0,D(),(u==="dismissed"||u==="error")&&s.abort(w??new DOMException("Presentation cancelled","AbortError")),!(!d&&u!=="ready")&&z(t.onPresentationState,u==="error"?{surface:r,state:u,error:w}:{surface:r,state:u}))}let g=a,P=()=>{l||g()};return{setDismissHandler(u){g=u},get active(){return d&&!l},get cancelled(){return s.signal.aborted},retainPurchaseDialog(){return p?.()},setPurchaseRecovery(u,w){x={message:u,retry:w},v?.()},start(u,w,h){if(d||l)return;d=!0;let C=()=>{if(!l&&t.loading!=="host"){let k=(w??o.documentElement.lang)||"en",M=u&&h?.presentation?.type!=="inline",L=h!==void 0,y=o.createElement(M?"dialog":"div");c=y,y.dataset.longplayLoading=r;let R=k.startsWith("zh"),W=L?R?"正在加载套餐":"Loading plans":R?"正在加载":"Loading",N=h?.screen.theme??{background:"Canvas",text:"CanvasText"};y.setAttribute("aria-label",W);let S=o.createElement("div");S.setAttribute("role","status");let H=o.createElement("div");H.setAttribute("aria-hidden","true"),L?(S.style.cssText="padding:calc(24px + env(safe-area-inset-top, 0px)) 24px 16px;padding-inline-end:68px;font:650 20px/1.3 system-ui,sans-serif;letter-spacing:-.015em",h||(S.style.paddingBlockEnd="24px")):S.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)",S.textContent=W;let T=o.createElement("button");T.type="button",T.textContent=R?"重试":"Retry",T.style.cssText="margin:0 24px 20px;padding:8px 16px",T.onclick=()=>x?.retry?.(),v=()=>{x&&(S.textContent=x.message,x.retry?S.after(T):T.remove())};let E=o.createElement("button");E.type="button",E.textContent="×",E.setAttribute("aria-label",R?"取消加载":"Cancel loading"),V(E,N),L&&(E.style.borderRadius="50%",E.style.top="calc(15px + env(safe-area-inset-top, 0px))",E.style.insetInlineEnd="calc(15px + env(safe-area-inset-right, 0px))"),E.addEventListener("click",P);let _=f=>{f.preventDefault(),P()};y.addEventListener("cancel",_);let A=o.createElement("style");A.textContent="[data-longplay-loading] > button:focus-visible{outline:2px solid currentColor;outline-offset:-2px}",y.append(S,H,E,A),v(),e.append(y);let $=()=>{if(!l&&M){let f=y,G=Y(o);f.showModal?f.showModal():f.open=!0,E.focus({preventScroll:!0}),p=()=>{if(!f.open||!f.isConnected)return;let U=b;return b=void 0,c=void 0,p=void 0,delete f.dataset.longplayLoading,f.removeAttribute("aria-label"),f.style.padding="0",f.removeEventListener("cancel",_),S.remove(),H.remove(),E.remove(),A.remove(),T.remove(),v=void 0,{dialog:f,release(){U?.(),f.close?.(),f.remove(),G()}}}}};h&&n?(b=n(y,H,h),$()):L?(y.style.cssText=M?"padding:0;border:0;border-radius:24px;background:Canvas;color:CanvasText;width:min(420px,calc(100vw - 32px))":"position:relative;background:Canvas;color:CanvasText;width:100%",$()):(K(y,H,M,r),$())}};h!==void 0&&t.loading!=="host"?m=setTimeout(C,120):C(),z(t.onPresentationState,{surface:r,state:"loading",dismiss:P})},present(u){if(l)return;let w=!!c;D(),u(w),i("ready")},dismiss:P,finish:i,async wait(u,w){let h=s.signal,C,k,M=new Promise((L,y)=>{k=()=>y(h.reason),h.aborted?k():h.addEventListener("abort",k,{once:!0}),w!==void 0&&(C=setTimeout(()=>y(new Error("Presentation data timed out")),w))});try{let L=await Promise.race([M,u]);return h.throwIfAborted(),L}finally{h.removeEventListener("abort",k),clearTimeout(C)}}}}function K(e,t,r,a){e.style.cssText="position:relative;box-sizing:border-box;background:Canvas;color:CanvasText;padding:24px 48px 24px 24px;"+(r?"position:fixed;width:min(480px,calc(100% - 32px));border:0;border-radius:16px;max-height:calc(100dvh - 32px)":"width:100%"),t.style.cssText="display:grid;gap:12px";let n=a==="banner"?[["72%",12],["44%",10]]:[["46%",20],["84%",12],["65%",12],["100%",64]];for(let[o,s]of n){let d=e.ownerDocument.createElement("div");d.style.cssText=`width:${o};height:${s}px;background:currentColor;opacity:.11;border-radius:6px`,t.append(d)}}function Q(e){let t={display:"block",position:"fixed",top:"0",left:"0",opacity:"0",pointerEvents:"none",zIndex:"-1"},r=Object.keys(t).map(o=>{let s=o,d=e.style[s];return e.style[s]=t[s],[s,d]}),a=e.inert??!1,n=e.getAttribute("aria-hidden");return e.inert=!0,e.setAttribute("aria-hidden","true"),()=>{for(let[o,s]of r)e.style[o]=s;e.inert=a,n===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n)}}function We(e,t){let r=e.style.width;e.style.width=`${t.getBoundingClientRect().width||t.ownerDocument.defaultView?.innerWidth||800}px`;let a=Q(e);return()=>{a(),e.style.width=r}}export{X as a,De as b,j as c,J as d,Le as e,Te as f,V as g,ke as h,Ce as i,Y as j,$e as k,ze as l,Q as m,We as n};
1
+ import{c as I}from"./chunk-B3FNR6MN.js";import{a as z}from"./chunk-DSPLGTQI.js";var F={sm:420,md:640,lg:900},B=767;function q(e,t,r=()=>!0,a="Close"){let n=e.ownerDocument.defaultView,o=e.ownerDocument.createElement("button");o.type="button",o.setAttribute("aria-label",a),o.style.cssText="position:absolute;inset:0 48px auto;z-index:2;height:24px;border:0;padding:0;background:transparent;touch-action:none;cursor:grab";let s=e.ownerDocument.createElement("span");s.style.cssText="display:block;width:36px;height:4px;border-radius:4px;margin:8px auto 12px;background:currentColor;opacity:.22;pointer-events:none",o.append(s),e.prepend(o);let d,l=0,c=!1,p=()=>{o.hidden=e.dataset.presentation!=="sheet",o.setAttribute("aria-disabled",String(!r()))},b=i=>{p(),!(o.hidden||!r()||i.button!==0)&&(d={y:i.clientY,time:Date.now(),id:i.pointerId},l=0,c=!1,o.setPointerCapture?.(i.pointerId))},x=i=>{!d||i.pointerId!==d.id||(l=Math.max(0,i.clientY-d.y),e.style.transform=`translateY(${l}px)`)},v=i=>{if(!d||i.pointerId!==d.id)return;let g=Math.max(1,Date.now()-d.time),P=i.type!=="pointercancel"&&r()&&(l>120||l>40&&l/g>.5);c=l>6,d=void 0,o.releasePointerCapture?.(i.pointerId),e.style.transform="",P?t():l&&typeof e.animate=="function"&&!n?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&e.animate([{transform:`translateY(${l}px)`},{transform:"none"}],{duration:200,easing:"cubic-bezier(.2,.8,.2,1)"}),l=0},m=()=>{if(c){c=!1;return}!d&&l===0&&r()&&t()};o.addEventListener("pointerdown",b),o.addEventListener("pointermove",x),o.addEventListener("pointerup",v),o.addEventListener("pointercancel",v),o.addEventListener("click",m);let D=typeof MutationObserver=="function"?new MutationObserver(p):void 0;return D?.observe(e,{attributes:!0,attributeFilter:["data-presentation"]}),n?.addEventListener("resize",p),p(),()=>{D?.disconnect(),n?.removeEventListener("resize",p),o.remove(),e.style.transform=""}}function X(e,t,r){if(e==="paywall")return`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${t.type==="fullscreen"?"100vw":`${F[t.size]}px`}`;if(e==="content")return"box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;"+(t.type==="fullscreen"?"width:100vw":`width:${I[t.size]}px${t.type==="sheet"?";margin:auto auto 0":""}`);let a=t.type!=="fullscreen"&&!t.backdrop?",0 0 0 100vmax #16142566":"";return`box-sizing:border-box;padding:0;border:0;overflow:auto;background:${r.background};color:${r.text};`+(t.type==="fullscreen"?"width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border-radius:0":`width:${F[t.size]}px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 24px 80px #0003${a};`+(t.type==="sheet"?"margin:auto auto 0;border-radius:14px 14px 0 0":"border-radius:14px"))}function De(e,t,r,a){let n=q(e,t,r,a),o=s=>{if(s.target!==e)return;let d=e.getBoundingClientRect();(s.clientX<d.left||s.clientX>d.right||s.clientY<d.top||s.clientY>d.bottom)&&t()};return e.addEventListener("click",o),()=>{n(),e.removeEventListener("click",o)}}function j(e,t,r=!1){return(e.type==="modal"||e.type==="sheet")&&e.mobile&&r&&t<=B?e.mobile:e.type}function J(e,t,r){let a=e.ownerDocument.defaultView,n=t.presentation,o;if((n.type==="modal"||n.type==="sheet")&&n.backdrop){let i=`lp-backdrop-${crypto.randomUUID()}`,g={none:"transparent",scrim:"#f2f2f2cc",dim:"#0006","strong-dim":"#000000bf",blur:"#0006"};e.dataset.indianaBackdrop=i,o=e.ownerDocument.createElement("style"),o.textContent=`dialog[data-indiana-backdrop="${i}"]::backdrop{background:${g[n.backdrop]};backdrop-filter:${n.backdrop==="blur"?"blur(16px)":"none"}}`,e.append(o)}let s=t.pages?.[0]?.root.style?.shape,d=s?.type==="pill"?"9999px":s?.type==="rect"?typeof s.radius=="number"?`${s.radius}px`:[s.radius.topLeft,s.radius.topRight,s.radius.bottomRight,s.radius.bottomLeft].map(i=>`${i}px`).join(" "):void 0,l=(n.type==="modal"||n.type==="sheet")&&(n.desktopWidth!==void 0||n.mobile!==void 0||n.type==="modal"&&n.position!==void 0),c=n.type,p,b,x=!1,v=i=>{x||!Number.isFinite(i)||i<0||(b=i,c!=="fullscreen"&&c!=="inline"&&(e.style.height=`min(${Math.max(i,40)}px, calc(100dvh - ${c==="sheet"?0:32}px))`))},m=()=>{if(!x&&(c=p??j(n,a?.innerWidth??1024,a?.matchMedia?.("(pointer: coarse)").matches===!0),e.dataset.presentation=c,!(!l||n.type!=="modal"&&n.type!=="sheet"))){if(e.style.boxSizing="border-box",e.style.padding="0",e.style.border="0",e.style.overflow="hidden",e.style.outline="none",e.tabIndex=-1,e.style.background=t.theme.background,e.style.color=t.theme.text,c==="fullscreen")e.style.width="100vw",e.style.height="100dvh",e.style.maxWidth="100vw",e.style.maxHeight="100dvh",e.style.margin="0",e.style.borderRadius="0";else{let i=n.mobile==="sheet"&&c==="sheet",g=n.desktopWidth,P=a?.innerWidth??1024;e.style.width=i?`${P}px`:g?`${Math.min(g.max,Math.max(P*g.viewport/100,g.min))}px`:`${I[n.size]}px`,e.style.maxWidth=`${Math.max(0,P-(c==="sheet"?0:32))}px`,e.style.maxHeight=c==="sheet"?"100dvh":"calc(100dvh - 32px)",e.style.margin=c==="sheet"?"auto auto 0":n.type==="modal"&&n.position==="top"?"16px auto auto":n.type==="modal"&&n.position==="bottom"?"auto auto 16px":"auto",e.style.borderRadius=d??(c==="sheet"?"16px 16px 0 0":"24px"),e.style.height="",b!==void 0&&v(b)}r?.(c)}},D=l?[a?.matchMedia?.(`(max-width: ${B}px)`),a?.matchMedia?.("(pointer: coarse)")].filter(i=>i!==void 0):[];if(l){a?.addEventListener("resize",m);for(let i of D)i.addEventListener?i.addEventListener("change",m):i.addListener?.(m)}return m(),{responsive:l,get type(){return c},latch(){x||p!==void 0||(m(),p=c)},setContentHeight:v,destroy(){if(!x){x=!0,o?.remove(),delete e.dataset.indianaBackdrop,a?.removeEventListener("resize",m);for(let i of D)i.removeEventListener?i.removeEventListener("change",m):i.removeListener?.(m)}}}}function Le(e,t,r){let{presentation:a}=t;return e.style.cssText=X("paywall",a.type==="inline"?{type:"fullscreen"}:a,t.theme),J(e,t,r)}function Te(e,t,r=!1){let a=e.ownerDocument.defaultView;if(typeof e.animate!="function"||a?.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;let n=r?{duration:300,easing:"cubic-bezier(0.23, 1, 0.32, 1)"}:{duration:240,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)"};e.animate(t==="sheet"?[{transform:"translateY(100%)"},{transform:"none"}]:t==="modal"?[{opacity:0,transform:r?"translateY(12px) scale(0.96)":"translateY(8px) scale(0.98)"},{opacity:1,transform:"none"}]:[{opacity:0},{opacity:1}],n);try{e.animate([{opacity:0},{opacity:1}],{...n,pseudoElement:"::backdrop"})}catch{}}function V(e,t){e.style.cssText=["position:absolute","z-index:1","top:calc(4px + env(safe-area-inset-top, 0px))","inset-inline-end:calc(4px + env(safe-area-inset-right, 0px))","width:44px","height:44px","padding:0","border:0","border-radius:50%","font:400 20px/1 system-ui,sans-serif","cursor:pointer","touch-action:manipulation"].join(";"),e.style.background=`radial-gradient(circle, ${t.background} 0 15px, color-mix(in srgb, ${t.text} 22%, ${t.background}) 15px 16px, transparent 16.5px)`,e.style.color=t.text}function ke(e){let t=e.closest("dialog");if(!t?.open||!t.isConnected)return;let r=["style","tabindex","aria-label","data-presentation","data-indiana-backdrop"].map(a=>[a,t.getAttribute(a)]);return{dialog:t,content:e,release(){for(let[a,n]of r)n===null?t.removeAttribute(a):t.setAttribute(a,n)}}}var O=new WeakMap;function Ce(e,t){return O.set(e,t),()=>O.delete(e)}function Y(e){let t=e.defaultView?.HTMLElement,r=e.activeElement;for(let n=0;n<16&&r?.shadowRoot?.activeElement;n++)r=r.shadowRoot.activeElement;let a=r?O.get(r)?.():void 0;return()=>{!r?.isConnected||!t||!(r instanceof t)||(r.focus({preventScroll:!0}),a?.())}}var $e=15e3;function ze(e,t,r,a,n){let o=e.ownerDocument,s=new AbortController,d=!1,l=!1,c,p,b,x,v,m;function D(){clearTimeout(m),m=void 0,b?.(),b=void 0,c?.tagName==="DIALOG"&&c.close?.(),c?.remove(),c=void 0,p=void 0,v=void 0}function i(u,w){l||(l=!0,D(),(u==="dismissed"||u==="error")&&s.abort(w??new DOMException("Presentation cancelled","AbortError")),!(!d&&u!=="ready")&&z(t.onPresentationState,u==="error"?{surface:r,state:u,error:w}:{surface:r,state:u}))}let g=a,P=()=>{l||g()};return{setDismissHandler(u){g=u},get active(){return d&&!l},get cancelled(){return s.signal.aborted},retainPurchaseDialog(){return p?.()},setPurchaseRecovery(u,w){x={message:u,retry:w},v?.()},start(u,w,h){if(d||l)return;d=!0;let C=()=>{if(!l&&t.loading!=="host"){let k=(w??o.documentElement.lang)||"en",M=u&&h?.presentation?.type!=="inline",L=h!==void 0,y=o.createElement(M?"dialog":"div");c=y,y.dataset.longplayLoading=r;let R=k.startsWith("zh"),W=L?R?"正在加载套餐":"Loading plans":R?"正在加载":"Loading",N=h?.screen.theme??{background:"Canvas",text:"CanvasText"};y.setAttribute("aria-label",W);let S=o.createElement("div");S.setAttribute("role","status");let H=o.createElement("div");H.setAttribute("aria-hidden","true"),L?(S.style.cssText="padding:calc(24px + env(safe-area-inset-top, 0px)) 24px 16px;padding-inline-end:68px;font:650 20px/1.3 system-ui,sans-serif;letter-spacing:-.015em",h||(S.style.paddingBlockEnd="24px")):S.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)",S.textContent=W;let T=o.createElement("button");T.type="button",T.textContent=R?"重试":"Retry",T.style.cssText="margin:0 24px 20px;padding:8px 16px",T.onclick=()=>x?.retry?.(),v=()=>{x&&(S.textContent=x.message,x.retry?S.after(T):T.remove())};let E=o.createElement("button");E.type="button",E.textContent="×",E.setAttribute("aria-label",R?"取消加载":"Cancel loading"),V(E,N),L&&(E.style.borderRadius="50%",E.style.top="calc(15px + env(safe-area-inset-top, 0px))",E.style.insetInlineEnd="calc(15px + env(safe-area-inset-right, 0px))"),E.addEventListener("click",P);let _=f=>{f.preventDefault(),P()};y.addEventListener("cancel",_);let A=o.createElement("style");A.textContent="[data-longplay-loading] > button:focus-visible{outline:2px solid currentColor;outline-offset:-2px}",y.append(S,H,E,A),v(),e.append(y);let $=()=>{if(!l&&M){let f=y,G=Y(o);f.showModal?f.showModal():f.open=!0,E.focus({preventScroll:!0}),p=()=>{if(!f.open||!f.isConnected)return;let U=b;return b=void 0,c=void 0,p=void 0,delete f.dataset.longplayLoading,f.removeAttribute("aria-label"),f.style.padding="0",f.removeEventListener("cancel",_),S.remove(),H.remove(),E.remove(),A.remove(),T.remove(),v=void 0,{dialog:f,release(){U?.(),f.close?.(),f.remove(),G()}}}}};h&&n?(b=n(y,H,h),$()):L?(y.style.cssText=M?"padding:0;border:0;border-radius:24px;background:Canvas;color:CanvasText;width:min(420px,calc(100vw - 32px))":"position:relative;background:Canvas;color:CanvasText;width:100%",$()):(K(y,H,M,r),$())}};h!==void 0&&t.loading!=="host"?m=setTimeout(C,120):C(),z(t.onPresentationState,{surface:r,state:"loading",dismiss:P})},present(u){if(l)return;let w=!!c;D(),u(w),i("ready")},dismiss:P,finish:i,async wait(u,w){let h=s.signal,C,k,M=new Promise((L,y)=>{k=()=>y(h.reason),h.aborted?k():h.addEventListener("abort",k,{once:!0}),w!==void 0&&(C=setTimeout(()=>y(new Error("Presentation data timed out")),w))});try{let L=await Promise.race([M,u]);return h.throwIfAborted(),L}finally{h.removeEventListener("abort",k),clearTimeout(C)}}}}function K(e,t,r,a){e.style.cssText="position:relative;box-sizing:border-box;background:Canvas;color:CanvasText;padding:24px 48px 24px 24px;"+(r?"position:fixed;width:min(480px,calc(100% - 32px));border:0;border-radius:16px;max-height:calc(100dvh - 32px)":"width:100%"),t.style.cssText="display:grid;gap:12px";let n=a==="banner"?[["72%",12],["44%",10]]:[["46%",20],["84%",12],["65%",12],["100%",64]];for(let[o,s]of n){let d=e.ownerDocument.createElement("div");d.style.cssText=`width:${o};height:${s}px;background:currentColor;opacity:.11;border-radius:6px`,t.append(d)}}function Q(e){let t={display:"block",position:"fixed",top:"0",left:"0",opacity:"0",pointerEvents:"none",zIndex:"-1"},r=Object.keys(t).map(o=>{let s=o,d=e.style[s];return e.style[s]=t[s],[s,d]}),a=e.inert??!1,n=e.getAttribute("aria-hidden");return e.inert=!0,e.setAttribute("aria-hidden","true"),()=>{for(let[o,s]of r)e.style[o]=s;e.inert=a,n===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n)}}function We(e,t){let r=e.style.width;e.style.width=`${t.getBoundingClientRect().width||t.ownerDocument.defaultView?.innerWidth||800}px`;let a=Q(e);return()=>{a(),e.style.width=r}}export{X as a,De as b,j as c,J as d,Le as e,Te as f,V as g,ke as h,Ce as i,Y as j,$e as k,ze as l,Q as m,We as n};
@@ -1 +1 @@
1
- import{b as p,c as d}from"./chunk-ME6QTD5Y.js";import{t as a,w as u,z as m}from"./chunk-FYUMVOCV.js";import{b as e}from"./chunk-W22ESUYY.js";var s=e.enum(["page","popup","banner"]),y=3e5,f=e.strictObject({type:e.enum(["string","number","boolean","strings","json"]),nullable:e.boolean()}),h=e.strictObject({inputs:e.record(a,f.extend({required:e.boolean()})).refine(t=>Object.keys(t).length<=40,"Too many content inputs"),outputs:e.record(a,f).refine(t=>Object.keys(t).length<=40,"Too many content outputs")}),g=e.strictObject({kind:s,schemaVersion:e.literal(1),name:e.string().trim().min(1).max(80),screen:u,contract:h}),c=g.superRefine((t,r)=>{let n=(o,b)=>r.addIssue({code:"custom",message:o,path:b});t.screen.surface!==t.kind&&n("Content surface must match its domain",["screen","surface"]),t.screen.name!==t.name&&n("Content has one editable name",["screen","name"]),t.kind==="banner"&&t.screen.presentation.type!=="inline"&&n("Banner requires an inline container",["screen","presentation"]),t.kind!=="banner"&&t.screen.presentation.type==="inline"&&n("Inline presentation belongs to Banner",["screen","presentation"]),t.screen.actions.some(o=>o.type!=="event"&&o.type!=="navigate")&&n("Content actions must emit host intents or navigate locally",["screen","actions"]);let i=new Set(t.screen.actions.filter(o=>o.type==="event").map(o=>o.id));(Object.keys(t.contract.outputs).some(o=>!i.has(o))||[...i].some(o=>!Object.hasOwn(t.contract.outputs,o)))&&n("Every event needs exactly one output declaration",["contract","outputs"]),d(t)>y&&n("Content document exceeds its byte budget",[])});function S(t,r){if(t===null)return r.nullable;switch(r.type){case"json":return!0;case"string":return typeof t=="string";case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"strings":return Array.isArray(t)&&t.every(n=>typeof n=="string")}}var x=c.superRefine((t,r)=>{for(let n of p(t.screen))Object.keys(t.contract.inputs).some(i=>n===i||n.startsWith(i+"."))||r.addIssue({code:"custom",path:["contract","inputs"],message:"Declare every reusable input read"});for(let n of t.screen.actions){if(n.type!=="event")continue;let i=t.contract.outputs[n.id],o=Object.hasOwn(n.properties,"value")?n.properties.value:n.properties;i&&!S(o,i)&&r.addIssue({code:"custom",path:["contract","outputs",n.id],message:"Action value differs from its declared type"})}m(t.screen).some(n=>!n.complete)&&r.addIssue({code:"custom",path:["screen","strings"],message:"Content needs complete localized copy"})}),l=e.strictObject({id:e.uuid(),kind:s,projectId:e.uuid(),environmentId:e.uuid(),name:e.string(),revision:e.number().int().nonnegative(),status:e.enum(["draft","published","archived"]),publishedVersionId:e.uuid().nullable(),createdAt:e.iso.datetime({offset:!0}),updatedAt:e.iso.datetime({offset:!0})}),D=l.extend({draft:c}),I=e.strictObject({rows:e.array(l).max(200),nextCursor:e.uuid().nullable()}),v=e.strictObject({id:e.uuid(),kind:s,resourceId:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),version:e.number().int().positive(),sourceRevision:e.number().int().nonnegative(),document:x,createdAt:e.iso.datetime({offset:!0})}),z=v.omit({document:!0}),V=e.discriminatedUnion("action",[e.strictObject({action:e.literal("create"),kind:s,id:e.uuid(),document:c}),e.strictObject({action:e.literal("save"),kind:s,id:e.uuid(),revision:e.number().int().nonnegative(),document:c}),e.strictObject({action:e.enum(["publish","archive"]),kind:s,id:e.uuid(),revision:e.number().int().nonnegative()})]).superRefine((t,r)=>{"document"in t&&t.document.kind!==t.kind&&r.addIssue({code:"custom",path:["document","kind"],message:"Content cannot change domain"})});export{s as a,v as b};
1
+ import{b as p,c as d}from"./chunk-DGGXLPHI.js";import{t as a,w as u,z as m}from"./chunk-W5MSVU2K.js";import{b as e}from"./chunk-VITB5MIL.js";var s=e.enum(["page","popup","banner"]),y=3e5,f=e.strictObject({type:e.enum(["string","number","boolean","strings","json"]),nullable:e.boolean()}),h=e.strictObject({inputs:e.record(a,f.extend({required:e.boolean()})).refine(t=>Object.keys(t).length<=40,"Too many content inputs"),outputs:e.record(a,f).refine(t=>Object.keys(t).length<=40,"Too many content outputs")}),g=e.strictObject({kind:s,schemaVersion:e.literal(1),name:e.string().trim().min(1).max(80),screen:u,contract:h}),c=g.superRefine((t,r)=>{let n=(o,b)=>r.addIssue({code:"custom",message:o,path:b});t.screen.surface!==t.kind&&n("Content surface must match its domain",["screen","surface"]),t.screen.name!==t.name&&n("Content has one editable name",["screen","name"]),t.kind==="banner"&&t.screen.presentation.type!=="inline"&&n("Banner requires an inline container",["screen","presentation"]),t.kind!=="banner"&&t.screen.presentation.type==="inline"&&n("Inline presentation belongs to Banner",["screen","presentation"]),t.screen.actions.some(o=>o.type!=="event"&&o.type!=="navigate")&&n("Content actions must emit host intents or navigate locally",["screen","actions"]);let i=new Set(t.screen.actions.filter(o=>o.type==="event").map(o=>o.id));(Object.keys(t.contract.outputs).some(o=>!i.has(o))||[...i].some(o=>!Object.hasOwn(t.contract.outputs,o)))&&n("Every event needs exactly one output declaration",["contract","outputs"]),d(t)>y&&n("Content document exceeds its byte budget",[])});function S(t,r){if(t===null)return r.nullable;switch(r.type){case"json":return!0;case"string":return typeof t=="string";case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"strings":return Array.isArray(t)&&t.every(n=>typeof n=="string")}}var x=c.superRefine((t,r)=>{for(let n of p(t.screen))Object.keys(t.contract.inputs).some(i=>n===i||n.startsWith(i+"."))||r.addIssue({code:"custom",path:["contract","inputs"],message:"Declare every reusable input read"});for(let n of t.screen.actions){if(n.type!=="event")continue;let i=t.contract.outputs[n.id],o=Object.hasOwn(n.properties,"value")?n.properties.value:n.properties;i&&!S(o,i)&&r.addIssue({code:"custom",path:["contract","outputs",n.id],message:"Action value differs from its declared type"})}m(t.screen).some(n=>!n.complete)&&r.addIssue({code:"custom",path:["screen","strings"],message:"Content needs complete localized copy"})}),l=e.strictObject({id:e.uuid(),kind:s,projectId:e.uuid(),environmentId:e.uuid(),name:e.string(),revision:e.number().int().nonnegative(),status:e.enum(["draft","published","archived"]),publishedVersionId:e.uuid().nullable(),createdAt:e.iso.datetime({offset:!0}),updatedAt:e.iso.datetime({offset:!0})}),D=l.extend({draft:c}),I=e.strictObject({rows:e.array(l).max(200),nextCursor:e.uuid().nullable()}),v=e.strictObject({id:e.uuid(),kind:s,resourceId:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),version:e.number().int().positive(),sourceRevision:e.number().int().nonnegative(),document:x,createdAt:e.iso.datetime({offset:!0})}),z=v.omit({document:!0}),V=e.discriminatedUnion("action",[e.strictObject({action:e.literal("create"),kind:s,id:e.uuid(),document:c}),e.strictObject({action:e.literal("save"),kind:s,id:e.uuid(),revision:e.number().int().nonnegative(),document:c}),e.strictObject({action:e.enum(["publish","archive"]),kind:s,id:e.uuid(),revision:e.number().int().nonnegative()})]).superRefine((t,r)=>{"document"in t&&t.document.kind!==t.kind&&r.addIssue({code:"custom",path:["document","kind"],message:"Content cannot change domain"})});export{s as a,v as b};
@@ -0,0 +1 @@
1
+ import{a as xn,c as Sn,d as Lt,f as Mt,g as Tn,k as On}from"./chunk-YMNCFP4X.js";import{a as Cn,b as Ye}from"./chunk-W32FI2A2.js";import{e as Pn,f as vn,g as kn,h as In,j as Ut,k as ct,l as En,m as An,n as Rn}from"./chunk-RWGMLH42.js";import{a as Ot,b as yn,d as Nt,e as gn,f as wn}from"./chunk-TG7FSNRF.js";import{a as st,b as oe,d as Dt,f as _t,j as bn}from"./chunk-VJXGTINT.js";import{b as ke}from"./chunk-R6NVHYXW.js";import{B as L,C as ot,D as Ge,E as Se,y as mn}from"./chunk-3QRVHAWK.js";import{r as Le,t as Ie}from"./chunk-YBDTPMGD.js";import{i as hn}from"./chunk-W5MSVU2K.js";import{c as ve,j as We}from"./chunk-VUGDBVIZ.js";import{c as Tt}from"./chunk-Q3K63EFB.js";import{a as k}from"./chunk-BNVQIMXY.js";import{a as K}from"./chunk-DSPLGTQI.js";async function Nn(j,a,A){if(!Ge(a))throw new k("INVALID_RESPONSE","A verified completed purchase is required");let N=j?We.parse(j):null;if(await A.onComplete?.(a),!N||!A.check)return;let G=We.parse(await A.check());if(G.internal_feature_id!==N.internal_feature_id||G.quantity!==N.quantity||N.observation!==void 0&&(G.observation===void 0||G.observation.requirementDigest!==N.observation.requirementDigest||G.observation.authority!==N.observation.authority||Tt(G.observation.subject)!==Tt(N.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");G.allowed&&await A.onAccessGranted?.(G)}function Dn(j){return Object.entries(j.document.buttons).filter(([,a])=>a.type==="checkout"&&a.product.type==="fixed"&&!ke(a.product,{},j.capabilities)).map(([a])=>a)}function _n(j,a){let A=L(a)?void 0:a.lines[0];if(!L(a)&&(a.lines.length!==1||!A))return;let N=L(a)?a.productVersionId:A.productVersionId,{screen:G,buttons:se}=j.document,Q=new Map(L(a)?Object.entries(a.featureQuantities??{}):(A?.prepaid??[]).map(C=>[C.internal_feature_id,C.quantity]));function ce(C,d){if(C.hidden)return!1;if(C.type==="plan_picker"&&j.capabilities.pickers[C.id]?.options.includes(N))return d[C.id]=N,!0;if(C.type==="quantity_picker"){let ne=Q.get(C.internalFeatureId);return ne!==void 0&&(!C.bind?.plan||C.bind.plan===N)&&(d[C.id]=ne),!1}if(C.type==="button"&&C.action){let ne=se[C.action];return ne?.type==="checkout"&&ne.product.type==="fixed"&&ne.product.productVersionId===N}if(C.type!=="stack")return!1;let te=C.interaction,i=C.bind?.plan===N;for(let[ne,h]of C.children.entries()){let Z={},M=ce(h,Z);if(te?.type==="toggle"||te?.type==="tabs"){if(!M)continue;return d[C.id]=te.type==="toggle"?ne===0:h.id,Object.assign(d,Z),!0}Object.assign(d,Z),M&&(i=!0,te?.type==="select"&&te.purpose==="product"&&te.pickerId&&h.type==="stack"&&h.bind?.plan===N&&(d[C.id]=h.id,d[te.pickerId]=N))}return i}for(let C of G.pages){let d={__page:C.id};if(ce(C.root,d))return d}}var qn="position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0";async function kr(j,a,A){let N=a.focusAtReveal?()=>{}:Ut(j.ownerDocument),G=()=>{Q.finish("dismissed"),N()},se=()=>G(),Q=En(j,a,"paywall",()=>{G(),K(a.onDismiss)},xn);a.signal?.throwIfAborted(),a.signal?.addEventListener("abort",se,{once:!0});let ce=null,C,d,te;try{if(Q.start(!0,a.loadingDocument?.screen.strings.defaultLocale,a.loadingDocument??null),Q.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(ce=a.check?We.parse(await Q.wait(a.check(),ct)):null,ce?.allowed)return Q.finish("skipped"),a.signal?.removeEventListener("abort",se),N(),await a.onAccessGranted?.(ce),{check:ce,host:null};let[e,n]=await Promise.allSettled([Q.wait(import("./screen-renderer-MVJ5BKQS.js")),Q.wait(a.start().then(r=>(Q.cancelled&&r.destroy(),r)),ct)]);if(e.status==="rejected")throw n.status==="fulfilled"&&n.value.destroy(),e.reason;if(n.status==="rejected")throw n.reason;te=e.value,C=n.value,a.signal?.throwIfAborted(),C.signal?.throwIfAborted(),C.signal?.addEventListener("abort",se,{once:!0});let t=C.view??await Q.wait(C.refresh(),ct);if(!t)throw new k("INVALID_RESPONSE","Paywall presentation is missing");C.signal?.throwIfAborted(),d=t}catch(e){throw Q.finish("error",e),A?.retainedDialog?.release(),a.signal?.removeEventListener("abort",se),C?.signal?.removeEventListener("abort",se),C?.destroy(),N(),e}let i=C,{mountScreenPreview:ne}=te,h=j.ownerDocument,Z=new AbortController,M=h.createElement("section"),pe=h.createElement("div"),Y=h.createElement("div"),lt=a.mountControls,ee=lt?h.createElement("div"):void 0,f=h.createElement("p"),y=h.createElement("button"),le=h.createElement("button"),_=h.createElement("button");(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&A?.hostPaywallTarget&&!A.retainedDialog&&d.document.presentation.type==="modal"&&(A.retainedDialog=In(A.hostPaywallTarget));let ue=A?.retainedDialog,S=ue?.dialog??h.createElement("dialog"),Me=ue&&d.document.presentation.type==="inline"?{type:"modal",size:"md"}:d.document.presentation,re=Me.type==="inline"?Y:h.createElement("div"),ut=i.locale||d.document.screen.strings.defaultLocale,o=ut.toLowerCase().startsWith("zh"),Un=o?"正在处理…":"Processing…",Ln=o?"正在准备报价…":"Preparing your price…",U=Sn(d.document.screen.theme);M.dataset.indianaPaywall="",M.setAttribute("aria-label",d.document.name),M.style.cssText=U.root,Y.style.cssText=U.controls,f.style.cssText=U.message,f.setAttribute("role","status"),_.style.cssText=U.link,_.textContent=o?"关闭":"Close",y.style.cssText=U.secondary,y.textContent=o?"重试":"Retry",y.hidden=!0,le.type="button",le.style.cssText=U.primary,le.textContent=o?"继续付款":"Continue payment",le.hidden=!0,re.append(f,le,y),Y.append(_),ee&&(ee.style.cssText="flex:1 0 100%;min-width:0",ee.hidden=!0,Y.prepend(ee)),re!==Y&&(re.dataset.indianaPaywallStatus="",re.style.cssText="display:none;padding:0",M.append(re)),M.append(pe,Y);let dt=()=>{let e=$n();f.style.cssText=e?`${U.message};${qn}`:U.message,Kt();let n=c=>!c.hidden&&(c!==f||!!f.textContent&&!e);if(re!==Y&&(re.style.cssText=!ie&&[...re.children].some(n)?`${U.controls};padding:12px 64px 12px 20px;flex-shrink:0`:e?"padding:0":"display:none;padding:0"),ee){let c=!ee.childElementCount&&!ee.textContent?.trim();ee.hidden!==c&&(ee.hidden=c)}let t=me??Y,r=![...t.children].some(n),l=[...t.children].some(c=>c!==_&&n(c));t.style.cssText=r?U.controls.replace(/padding:[^;]+/,"padding:0"):l?`${U.controls};${U.pinned}`:U.controls,ft()},Vt=typeof MutationObserver>"u"?void 0:new MutationObserver(dt);Vt?.observe(M,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Mn=Object.entries(d.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),D,$t,Ve=!1,Ht=JSON.stringify(d.capabilities),q;function xe(e){let n=Dn(e);if(q||fe&&!ae||F&&(P||!be()||we))return Oe(e).map(({actionId:r})=>r);if(Ct()||!P&&be())return n;let t=P?bt(e):Pt(e);return[...new Set([...n,...Oe(e).map(({actionId:r})=>r).filter(r=>!t.includes(r))])]}function $e(e){if(w)return;let n=d.id!==e.id;d=e;let t=JSON.stringify(e.capabilities);if(n||t!==Ht){let r=!b&&!i.quote&&!i.operation?st(e,J,jt):J;n||JSON.stringify(r)!==JSON.stringify(J)?(J=r,D?.update(e.document.screen,ut,{capabilities:oe(e),unavailableActions:xe(e),serverInput:{bindings:[],answers:{}},selection:J})):D?.updateCapabilities(oe(e),xe(e)),Ht=t}Hn(e),Ee(),Ze()}let V,pt=0;function Qt(){return(me??Y).getBoundingClientRect().height+(re===Y?0:re.getBoundingClientRect().height)}function ft(){let e=h.defaultView;if(!V?.responsive||!e)return;let n=me??Y,t=e.innerHeight-(V.type==="modal"?32:0);n.style.maxHeight=`${Math.max(1,t)}px`,n.style.overflowY="auto",n.style.flexShrink="0",pt=Math.max(1,t-Qt()),D?.resizeViewport?.(pt,e.innerWidth)}let w=!1,fe=!1,b=null,ht,ze=!1,Bt=!1,he=!1,mt,Ke=!1,ie,me;function Vn(){return fe||w||ie||Ke?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:Nt(i)}let E=()=>!w&&!ze&&!ie&&a.canInteract?.()!==!1,$,ye=!1,Te=!1,yt,m=null,de=null,Je="",ge=()=>a.checkoutNavigation==="after_confirmation"&&!!(a.terminateCheckout||a.resumeCheckout),J={},jt=new Set,ae,P;function gt(e){return!!e&&L(e)&&e.timing==="immediate"&&e.execution.provider==="merchant"}let wt=o?"正在确认付款…":"Confirming payment…",F=null,we,Xe,qt=!1,be=()=>a.allowNewPurchase!==!1||qt;function Ft(){return JSON.stringify([d.id,d.capabilities])}function Wt(){let e=yt;return e&&e.read===a.prepareSubscriptionChange&&e.basis===Ft()?e:void 0}function Ze(){let e=a.prepareSubscriptionChange;if(!e||!he||!E()||!be()||a.onPurchaseIntent||h.visibilityState==="hidden"||b||i.quote||i.operation||!Oe(d).length||Wt())return;let n=Z.signal,t=new Promise(r=>{let l=()=>r(void 0);n.addEventListener("abort",l,{once:!0}),Promise.resolve().then(()=>(n.throwIfAborted(),e(n))).then(c=>r(n.aborted?void 0:c),l).finally(()=>n.removeEventListener("abort",l))});yt={read:e,basis:Ft(),result:t}}let Gt=()=>{h.visibilityState==="hidden"?yt=void 0:Ze()};h.addEventListener("visibilitychange",Gt);function Oe(e){return Object.entries(e.document.buttons).flatMap(([n,t])=>t.type==="checkout"?[{actionId:n,policy:t}]:[])}function Yt(e){let n=P?.quote;return n?Oe(e).filter(({actionId:t,policy:r})=>Ne(n,e,t,r.product,J)).map(({actionId:t})=>t):[]}function bt(e){return P?.phase==="payment"?Yt(e):[]}function Ct(){return(P?P.phase==="payment":!be())&&(be()||!!a.prepareUpgradeReplacement)&&ge()&&!!a.terminateCheckout&&!!i.quote&&i.canReselect===!1&&!!i.operation&&R(i.operation).type==="checkout"}function Pt(e){let n=i.quote;return!ge()||F||!n||!i.operation||R(i.operation).type!=="checkout"?[]:Oe(e).filter(({actionId:t,policy:r})=>Ne(n,e,t,r.product,J)).map(({actionId:t})=>t)}function Ee(){let e=q?[]:P?bt(d):Pt(d),n=a.allowNewPurchase===!1&&!!i.operation&&R(i.operation).type==="checkout";le.hidden=!!q||(P?P.phase!=="payment":!n)||e.length>0,Kt(e)}function zt(){if(!(ae===void 0||q))return f.textContent?f.textContent:P?.phase==="checking"?wt:void 0}function $n(){return!!D?.updateCheckoutControls&&!!f.textContent&&zt()!==void 0}let et;function Kt(e=q?[]:P?bt(d):Pt(d)){if(!D?.updateCheckoutControls)return;let n=zt(),t=ge()||!!P;if(!n&&!t&&et?.on!==D)return;let r={actions:Oe(d).map(({actionId:c})=>c),resume:n?[ae]:t?e:[],resumeLabel:n??(o?"继续付款":P?"Continue payment":"Continue checkout"),busy:ae},l=JSON.stringify(r);et?.on===D&&et.key===l||(et={on:D,key:l},D.updateCheckoutControls(r))}function Jt(){de?.remove(),de=null}async function tt(){if(F)return;if(a.resumeCheckout&&i.operation){let n=i.operation.operationId;try{await a.resumeCheckout(n)}catch(t){if(!(t instanceof k&&t.code==="PURCHASE_PENDING"))throw t;let r=await i.read();if(!E())return;if(r.operationId!==n||R(r).type==="checkout")throw t;await H(r,!1)}return}let e=await i.read();if(R(e).type!=="checkout")return H(e,!1);E()&&(He.delete(e.operationId),await Qe(e))}function vt(){we?.destroy(),we=void 0,Xe=void 0}function Xt(){let e=F;if(!e||we)return;let n=o?"仍在核对原订单,暂时无法更换套餐。":"We’re still checking the original purchase before changing plans.",t=Date.now()+6e5,r=Cn({document:h,delay:()=>Date.now()<t?5e3:void 0,async run(){if(!E())return;let l=await i.read();if(we!==r||!E())return;if(l.operationId!==e.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");let c=R(l);c.type==="native"?(vt(),f.textContent=o?"原订单已关闭。你可以继续更换套餐。":"The original checkout is closed. You can continue changing plans.",y.textContent=o?"继续更换套餐":"Continue changing plans",m=()=>nt(),y.hidden=!1):(c.type==="complete"||c.type==="fulfillment"||c.type==="recording")&&(vt(),F=null,y.hidden=!0,await H(l,!1))}});we=r,Xe=async()=>{try{await r.refresh()}finally{we===r&&(f.textContent=n,y.hidden=!1)}},m=Xe,y.textContent=o?"查询结果":"Check result",y.hidden=!1,f.textContent=n,r.schedule()}async function nt(e=!1,n=!1){let t=F;if(!t)return;m=()=>nt(),P&&(y.textContent=o?"查询状态":"Check status"),y.hidden=!0;let r=async()=>{if(!be()&&a.prepareUpgradeReplacement){let c=await a.prepareUpgradeReplacement(t.operationId,t.intent);if(!E())return;qt=!0,$e(c)}F=null,P&&De(P.quote),Jt(),b=t.selection,$=t.coupon,ye=!1,Te=!1,await qe()};if(n&&!be()&&a.prepareUpgradeReplacement)return r();let l=Date.now()+2e4;for(;E();){let c=await i.read();if(c.operationId!==t.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");if(!E())break;let s=R(c);if(s.type==="native"){await r();return}if(s.type==="complete"||s.type==="fulfillment"||s.type==="recording"){F=null,P?await Ae(P.quote,c):await H(c,!1);return}if(e&&s.type==="checkout"){e=!1;try{await a.terminateCheckout(t.operationId)}catch(u){K(a.onError,u)}}if(Date.now()>=l){P&&s.type==="checkout"&&(F=null,await Ae(P.quote,c));break}await Ye(1e3,h,Z.signal)}!F||w||(P?(f.textContent=o?"仍在核对原升级单,暂时无法更换套餐。":"We’re still checking the original upgrade before changing plans.",y.hidden=!1):Xt())}async function Zt(e,n,t,r){if(m=()=>Zt(e,n,t,r),await a.beforeCheckoutReplacement?.(structuredClone(r)),!E())return;let l=i.operation;if(l?.operationId!==e||R(l).type!=="checkout"){m=null,l&&await H(l,!1);return}F={operationId:e,selection:n,coupon:t,intent:r},P&&(f.textContent=o?"正在切换套餐…":"Changing plan…",y.hidden=!0);let c=!1,s=!1;try{let u=await a.terminateCheckout(e);s=(Array.isArray(u?.purchases)?u.purchases:[]).some(p=>p.operationId===e&&p.type==="native")}catch(u){if(u instanceof k&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(u.code)){F=null,P&&(m=It,y.textContent=o?"查询状态":"Check status",y.hidden=!1),f.textContent=o?"请继续原订单,或等待它过期后再更换方案。":"Continue your original checkout, or wait for it to expire before changing plans.",K(a.onError,u);return}c=u instanceof k&&(u.status??0)>=500,K(a.onError,u)}E()&&await nt(c,s)}function rt(e,n,t,r,l){let c=oe(e).checkoutCoupons?.[n],s=c?c.products[t]:a.claimCoupon&&l?hn(e.capabilities,l,r):void 0;return s?.couponId&&s.planVersionId===t?{id:s.couponId,offerId:s.offerId}:void 0}function Hn(e){fe||b||i.quote||i.operation||Je&&f.textContent===Je||(f.textContent=Object.values(e.capabilities.plans).some(n=>n.available)?"":o?"当前账号暂无可购买的方案。":"No plans are currently available for this account.")}let He=new Map,it=!1;function Ne(e,n,t,r,l,c){let s=L(e),u=!s&&e.lines.length===1?e.lines[0]:void 0,I=ke(r,l,n.capabilities);if(!I||I!==(s?e.productVersionId:u?.productVersionId))return!1;let p=rt(n,t,I,l,c),x;try{x=Ie(n.document.screen,I,l,n.capabilities)}catch{return!1}if(s){let X=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return Object.keys(x).length===Object.keys(e.featureQuantities??{}).length&&Object.entries(x).every(([Ue,St])=>e.featureQuantities?.[Ue]===St)&&(!p||X?.couponId===p.id&&(!p.offerId||X.grantId===p.offerId))}if((p||oe(n).checkoutCoupons?.[t])&&(p?.id??null)!==(e.discount?.couponId??null))return!1;let T=Object.fromEntries((u?.prepaid??[]).map(X=>[X.internal_feature_id,X.quantity]));return[...new Set([...Object.keys(x),...Object.keys(T)])].every(X=>(x[X]??0)===(T[X]??0))}let R=e=>yn({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:w,canReselect:i.canReselect});async function Qe(e){let n=e.merchantExecution,t=R(e),r=t.type==="checkout"?t.checkoutUrl:e.checkoutUrl;if(!(!E()||!r||ot(e)&&t.type!=="checkout"||a.checkoutNavigation==="after_confirmation"&&t.type!=="checkout"||n?.type==="purchase"&&!["not_started","pending"].includes(n.paymentStatus)||He.get(e.operationId)===r)){He.set(e.operationId,r);try{a.onCheckoutUrl?await a.onCheckoutUrl(r):h.defaultView?.location.assign(r)}catch(l){throw He.delete(e.operationId),l}}}let Ce=(e,n=!1)=>{if(e instanceof Dt)m=null,f.textContent=e.customerMessage(o);else if(Tn(e))m=null,f.textContent=n?o?"当前无法在此购买,付款尚未开始。请联系商户。":"Purchases aren’t available here right now. Payment hasn’t started. Contact the merchant for help.":Mt(e,o);else if(n){let t=e instanceof k?e.code:void 0;t==="CAPABILITY_UNAVAILABLE"||t==="NOT_CONFIGURED"?(m=null,f.textContent=o?"暂时无法为此套餐报价,付款尚未开始。":"Pricing for this plan is unavailable. Payment hasn’t started."):i.canReselect===!0&&!b?f.textContent=o?"未能取得报价,付款尚未开始。请重新选择套餐。":"We couldn’t prepare your price. Payment hasn’t started. Choose a plan again.":t==="COMMAND_PENDING"?f.textContent=o?"仍在准备报价,请重试以查看结果。":"Your price is still being prepared. Retry to check the result.":f.textContent=o?"未能取得报价,付款尚未开始。请重试。":"We couldn’t prepare your price. Payment hasn’t started. Try again."}else f.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?Mt(e,o):e instanceof k?e.message:o?"操作未完成,请重试。":"This action couldn’t be completed. Try again.";y.hidden=m===null,Je=f.textContent,n&&ae===void 0&&!V?.responsive&&f.scrollIntoView?.({block:"nearest"}),K(n&&A?.quoteError?A.quoteError:a.onError,e)},Be=new WeakMap;function je(e){fe=e,y.disabled=e,le.disabled=e,D?.updateCapabilities?.(oe(d),xe(d));for(let n of de?.querySelectorAll("button")??[])e?(Be.has(n)||Be.set(n,n.disabled),n.disabled=!0):Be.has(n)&&(n.disabled=Be.get(n),Be.delete(n)),Lt(n)}function en(){q&&(f.textContent=q.message,y.textContent=o?"重试":"Retry",y.disabled=!1,y.hidden=!q.retry,le.disabled=!0)}function kt(){f.textContent=o?"暂时无法操作,请稍后重试。":"This action is unavailable right now. Try again in a moment."}let tn=new WeakSet;async function Qn(e){if(a.beforeAction)try{await a.beforeAction({purchaseIntent:tn.has(e)})}catch(n){throw n instanceof Dt?(b=null,ye=!1,Te=!1,m=null):m=e,n}}async function W(e,n){if(fe||w||q)return;if(!E()){kt();return}let t=e===qe,r=t?Ln:Un;ae=n!==void 0&&D?.updateCheckoutControls?n:void 0,f.textContent=r,je(!0),Ee(),y.hidden=!0;try{if(e!==cn&&e!==It&&e!==xt&&e!==Xe&&(e!==tt||!a.resumeCheckout)&&await Qn(e),w||q)return;if(!E()){m=e,y.hidden=!1,kt();return}await e()}catch(l){w||Ce(l,t)}finally{ae=void 0,je(!1),Ee(),q?en():f.textContent===r&&(f.textContent="")}}async function nn(e){await Nn(ce,e,a)}function De(e,n){P=n?{quote:e,phase:n}:void 0,n==="checking"?(ae??=b?.actionId??Yt(d)[0],f.textContent=wt,m=It,y.textContent=o?"查询状态":"Check status",y.hidden=!0):ae=void 0,D?.updateCapabilities(oe(d),xe(d)),Ee()}function rn(e){return e instanceof k&&(e.code==="COMMAND_PENDING"||e.reason==="RESULT_UNKNOWN"||e.code==="NETWORK_ERROR"||e.code==="TIMEOUT"||e.status===429||(e.status??0)>=500)}function an(e,n){_t(e,{...n,featureQuantities:n.featureQuantities??{}},"Purchase operation changed")}async function It(){P&&await Ae(P.quote)}async function Ae(e,n){De(e,"checking"),Je="";let t=1e3;Ve=!0,K(a.onObservationChange,!0);try{for(let r=n;E();r=void 0){if(!r){try{r=await i.read()}catch(l){if(!rn(l))throw l}if(!E())return}if(r){an(r,e);let l=R(r);if(l.type==="checkout"){De(e,"payment"),f.textContent=o?"请先完成原订单的付款。":"Finish paying for this upgrade.",y.hidden=!1;return}if(l.type==="complete"){De(e,"complete"),m=null;let c=d.capabilities.plans[e.productVersionId]?.name,s=e.merchantTerms?.subscriptionTerms?.items,u=s?.length===1?s[0].interval:void 0,I=u==="year"?o?"年付":"annual billing":u==="month"?o?"月付":"monthly billing":null;f.textContent=c?o?`已升级到 ${c}${I?" "+I:""}。`:`Upgraded to ${c}${I?" ("+I+")":""}.`:o?"已成功升级。":"Plan upgraded.",await nn(r);return}if(l.type==="native"&&!Se(r)){De(e),b=null,m=null,f.textContent=o?"付款没有成功,套餐未变更。请检查付款方式后重新选择套餐。":"Your payment didn’t go through, so your plan is unchanged. Check your payment method, then choose a plan again.",y.textContent=o?"重试":"Retry";return}if(r.problem&&!["RESULT_UNKNOWN","STATE_CHANGED"].includes(r.problem.reason??""))throw new k(r.problem.code,o?"暂时无法完成升级。":"The upgrade needs attention.",void 0,void 0,r.problem)}await Ye(t,h,Z.signal),t=Math.min(t*1.5,15e3)}}finally{Ve=!1,K(a.onObservationChange,!1)}}async function xt(){let e=P?.quote;if(!e)return;let n=await i.read();if(an(n,e),R(n).type!=="checkout")return Ae(e,n);if(a.resumeCheckout){await a.resumeCheckout(n.operationId);return}He.delete(n.operationId),await Qe(n)}function on(e){return Nt(i).type==="recording"||R(e).type==="recording"}function sn(e){let n=e.merchantTerms,t=n?.subscriptionTerms?.items??[],r=n?n.totalMinor:L(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),l=n?t.length===1&&t[0]?.amountMinor===r&&t[0]:!L(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===r&&e.lines[0],c=r===null?ve(n.subtotalMinor-n.discountMinor,e.currency)+(o?" + 待确认税费":" + tax confirmed at checkout"):ve(r,e.currency)+(l?Le(l.interval,o?"zh-CN":"en",l.intervalCount??1):""),s=L(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(u=>u.productName).join(", ");return{label:s?`${s} · ${c}`:c,recurring:l}}async function H(e,n=a.checkoutNavigation!=="after_confirmation"){if(w)return;if(!E()){m=async()=>H(await i.read()),y.hidden=!1;return}let t=e.quote??i.quote;if(gt(t)&&(e.confirmedAt||e.merchantExecution))return Ae(t,e);if(f.textContent=On(e.status,o),on(e)){let p=e.merchantExecution?.recordingStatus==="failed";f.textContent=p?o?"付款和商户处理已完成,但交易记录失败。请联系商户修复,勿重复购买。":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":o?"付款和商户处理已完成,正在确认交易记录。请勿重复购买。":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",y.textContent=o?"查询记录":"Check recording",m=async()=>H(await i.read()),y.hidden=!1;return}if(e.problem&&R(e).type!=="native"){let p=e.problem;m=_e,y.textContent=o?"检查并恢复原操作":"Check and recover original purchase",Ce(new k(p.code,p.reason==="RESULT_UNKNOWN"?o?"付款结果尚未确定,请恢复原操作,暂勿重复购买。":"The payment result is unknown. Recover the original purchase before buying again.":p.phase==="fulfillment"?o?"付款已记录,商户权益处理需要核对。":"Payment was recorded. Access fulfillment needs attention.":p.code==="CAPABILITY_UNAVAILABLE"?o?"商户尚不支持本次购买所需的完整能力,请处理后恢复原操作。":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":p.code==="NOT_CONFIGURED"?o?"付款服务连接需要处理,请联系商户后恢复原操作。":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":o?"原购买操作需要处理,请查询或恢复此操作。":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,p));return}if((e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"||e.merchantExecution?.type==="subscription_change"&&e.merchantExecution.status==="applied")&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(f.textContent=o?"付款已记录,正在等待商户完成处理。":"Payment was recorded. Waiting for merchant fulfillment."),Ge(e)&&R(e).type==="complete"){m=null,await nn(e);return}let r=Ot(e);if((r||!Se(e))&&R(e).type!=="fulfillment"){if(i.canReselect===!1||r&&Se(e)&&i.canReselect!==!0){f.textContent=o?"正在核对原购买结果":"Checking the original purchase result",y.textContent=o?"查询结果":"Check result",m=async()=>H(await i.read()),y.hidden=!1;return}r?f.textContent=o?"结账未启动,可以重新选择方案。":"Checkout didn’t start. Choose a plan to try again.":e.status==="cancelled"?f.textContent=o?"这笔购买已取消,可以重新选择方案。":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(f.textContent=o?"这笔购买未能完成,可以重新选择方案。":"This purchase didn’t go through. Choose a plan to try again."),y.textContent=o?"重试":"Retry",m=null,b=null;return}if(!n&&R(e).type==="checkout"){if(F){Xt();return}if(ge()){f.textContent="",it=!1,m=null,y.hidden=!0,D?.updateCapabilities?.(oe(d),xe(d)),Ee();return}let p=i.quote,x=p?.operationId===e.operationId?sn(p).label:"";f.textContent=it?x?o?`${x} 尚未付款。再次选择该方案即可继续付款。`:`${x} is still unpaid. Choose it again to continue paying.`:o?"之前的购买尚未付款。再次选择该方案即可继续付款。":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",it=!1,m=null;return}await Qe(e);let l=Date.now(),c=l+6e5,s=2e3,u=R(e).type!=="checkout",I=()=>u&&Date.now()-l<15e3;Ve=!0,K(a.onObservationChange,!0);try{for(;!w&&Date.now()<c;){if(await Ye(I()?700:s,h,Z.signal),w)return;if(!E()){m=async()=>H(await i.read()),y.hidden=!1;return}let p=await i.read();if(R(p).type==="checkout"&&(u=!1),!n&&R(p).type==="checkout"){await H(p,!1);return}if(!p.problem&&Se(p)&&await Qe(p),!Se(p)||Ot(p)||p.problem||on(p)){await H(p);return}I()||(s=Math.min(s*1.5,3e4))}}finally{Ve=!1,K(a.onObservationChange,!1)}m=async()=>H(await i.read()),y.hidden=!1}async function Et(e=!1){let n=await i.read();if(w)return;if(!E()){m=()=>Et(e),y.hidden=!1;return}let t=i.quote;if(t&&_t(n,{operationId:t.operationId,currency:t.currency},"The original purchase operation changed"),t&&(ot(n)?["prepared","quoted"].includes(n.status):n.status==="pending")&&(ot(n)||n.quoteFinalized===!1)&&!n.confirmedAt&&!n.checkoutUrl&&!("nativePurchase"in n&&n.nativePurchase)&&!n.merchantExecution&&!n.problem&&!i.pendingCancellation){if(a.purchaseConfirmation!=="paywall"){e?await _e():m=null;return}setTimeout(ln,0,t);return}await H(n,e||void 0)}async function cn(){await Et()}async function Bn(e){f.textContent=wt;let n=Date.now()+12e3;for(;!w&&Date.now()<n&&(await Ye(1500,h,Z.signal),!(w||!E()));){let t;try{t=await i.read()}catch{break}if(t.problem?.reason!=="RESULT_UNKNOWN")return t}return e}async function _e(){if(i.quote&&!(Date.parse(i.quote.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");Jt();let e=i.quote;if(gt(e)){De(e,"checking");let t;try{t=await i.confirm()}catch(r){if(!rn(r))throw r;return Ae(e)}return Ae(e,t)}m=_e;let n=await i.confirm();if(!E()){m=_e,y.hidden=!1;return}if(n.problem?.reason==="RESULT_UNKNOWN"&&(n=await Bn(n)),n.problem){await H(n);return}if(Se(n)){if(R(n).type==="checkout")await Qe(n);else if(n.execution&&n.execution.provider!=="merchant"||"nativePurchase"in n&&n.nativePurchase){if(!a.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:n,signal:Z.signal})}}m=async()=>H(await i.read()),await H(n,!0)}function ln(e){if(w)return;de?.remove();let n=!(Date.parse(e.expiresAt)>Date.now());f.textContent=n?o?"此报价已过期。请先取消,再重新选择。":"This quote has expired. Cancel it, then choose again.":"";let t=h.createElement("div"),r=h.createElement("button"),l=h.createElement("button"),c=h.createElement("div"),s=h.createElement("p"),u=e.merchantTerms,I=o?"zh-CN":"en",p=u?.subscriptionTerms?.items??[],x=u?u.subscriptionTerms?.trial?.days:L(e)?void 0:e.lines.find(g=>g.trial)?.trial?.days,T=L(e)?u?u.totalMinor:e.totalMinor:x===void 0?null:u?u.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(g=>g.trial)?0:null,Pe=(g,v)=>o?`${v} 天试用结束后 ${g}`:`Then ${g} after the ${v}-day trial`,{label:X,recurring:Ue}=sn(e),St=L(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(g=>g.productName).join(", "),pn=T===null?"":`${o?"今天应付":"Due today"} ${ve(T,e.currency)}`;s.textContent=pn?[St,pn].filter(Boolean).join(" · "):X,r.textContent=L(e)?o?"确认变更":"Confirm change":o?"确认购买":"Confirm purchase",r.disabled=n,l.textContent=o?"取消":"Cancel",t.style.cssText=U.panel,s.style.cssText=U.summary,c.style.cssText=U.actions,r.style.cssText=U.primary,l.style.cssText=U.secondary,Lt(r),r.onclick=()=>{W(_e)};let fn=async()=>{let g=await i.cancel();w||(t.remove(),de=null,await H(g))};l.onclick=()=>{m=fn,W(fn)};let z=h.createElement("div");if(z.style.cssText=U.terms,L(e)){for(let[v,O]of Object.entries(e.featureQuantities??{})){let B=i.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(jn=>jn.internalFeatureId===v),at=h.createElement("p");at.textContent=`${B?.name??v} · ${O} ${o?"份":"packs"}${B?` × ${B.terms.units}`:""}`,z.append(at)}for(let[v,O]of[[o?"原订阅抵扣":"Unused subscription credit",e.creditMinor],[o?"新套餐费用":"New plan charge",e.debitMinor],[o?"优惠减免":"Offer savings",u?.discountMinor??e.discountMinor],[o?"税费":"Tax",u?u.taxMinor:e.taxMinor]]){let B=h.createElement("p");B.textContent=`${v}: ${O===null?o?"结账时确认":"Confirmed at checkout":ve(O,e.currency)}`,z.append(B)}let g=h.createElement("p");g.textContent=`${o?"生效时间":"Effective"}: ${e.effectiveAt}`,z.append(g)}if(u){for(let v of p){if(T===null&&v===Ue)continue;let O=h.createElement("p"),B=ve(v.amountMinor,e.currency)+Le(v.interval,I,v.intervalCount);O.textContent=T!==null&&x!==void 0?Pe(B,x):B,v.amountAfterOfferMinor!==void 0&&(O.textContent+=` · ${o?"优惠结束后":"After the offer"} ${ve(v.amountAfterOfferMinor,e.currency)}${Le(v.interval,I,v.intervalCount)}`),z.append(O)}let g=u.subscriptionTerms?.trial;if(g){let v=h.createElement("p");v.textContent=o?`试用 ${g.days} 天;${g.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${g.days}; ${g.cardRequired?"a payment method is required":"no payment method is required"}`,z.append(v)}for(let v of[...u.expectedEffects.map(O=>O.description),...u.requiredConsents.map(O=>O.summary)]){let O=h.createElement("p");O.textContent=v,z.append(O)}}else if(!L(e)){for(let g of e.lines){if(T!==null||g!==Ue){let v=h.createElement("p"),O=`${ve(g.catalogAmountMinor,e.currency)}${Le(g.interval,I,g.intervalCount??1)}`;v.textContent=T!==null&&g.trial?(e.lines.length>1?`${g.productName} · `:"")+Pe(O,g.trial.days):`${g.productName} · ${O}`,z.append(v)}for(let v of g.prepaid??[]){let O=h.createElement("p"),B=i.view?.capabilities.plans[g.productVersionId]?.prepaid?.find(at=>at.internalFeatureId===v.internal_feature_id);O.textContent=`${B?.name??v.internal_feature_id} · ${v.quantity} ${o?"份":"packs"} × ${v.terms.units}`,B&&(O.textContent+=Le(B.reset==="week"||B.reset==="month"||B.reset==="year"?B.reset:"one_time",I,B.resetCount)),z.append(O)}if(g.trial){let v=h.createElement("p");v.textContent=o?`试用 ${g.trial.days} 天;${g.trial.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${g.trial.days}; ${g.trial.cardRequired?"a payment method is required":"no payment method is required"}`,z.append(v)}}if(!e.charge){let g=h.createElement("p");g.textContent=o?"目录价格;最终金额以结账时税费和试用规则为准。":"Catalog price; the final charge depends on checkout taxes and trial terms.",z.append(g)}}for(let g of z.children)g.style.margin="0";c.append(r,l),t.append(s,...z.childElementCount?[z]:[],c),Y.prepend(t),V?.responsive||t.scrollIntoView?.({block:"nearest"}),r.focus({preventScroll:!0}),de=t,fe&&je(!0),m=null}async function qe(){if(!b)return;if(a.onPurchaseIntent&&!ye&&!i.quote&&!i.operation){let t=b,r=i.view,l=r?.document.buttons[t.actionId],c=r&&l?.type==="checkout"?ke(l.product,t.selection,r.capabilities):null;if(!r||!c)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let s={actionId:t.actionId,productVersionId:c,selection:structuredClone(t.selection),featureQuantities:Ie(r.document.screen,c,t.selection,r.capabilities),...$&&{coupon:{id:$.id,...$.offerId&&{offerId:$.offerId}}}};b=null,$=void 0,m=null,Ke=!0,await a.onPurchaseIntent(s);return}if(m=qe,!ye){let t=i.view,r=t?.document.buttons[b.actionId],l=t&&r?.type==="checkout"?ke(r.product,b.selection,t.capabilities):null;if(!t||!l)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!Te){let s=Wt(),u=s?await s.result:void 0;if(w)return;let I=a.resolveSubscriptionChange;if(I||u){let p={actionId:b.actionId,productVersionId:l,featureQuantities:Ie(t.document.screen,l,b.selection,t.capabilities)},x=u?[async()=>u(p)]:[],T=I?await I(p,...x):await x[0]?.();if(w)return;T!==void 0&&(b.subscriptionChange=mn.parse(T))}Te=!0}let c=$?.offerId;if($&&!c){if(!a.claimCoupon)throw new k("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:s}=await a.claimCoupon($.id,b.requestId);if(w)return;if(!s||s.couponId!==$.id||s.status!=="issued"||!(Date.parse(s.expiresAt)>Date.now()))throw b=null,$=void 0,m=async()=>{$e(await i.refresh()),m=null},new k("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");c=s.id}if(!$&&!t.document.screen.actions.some(s=>s.id===b?.actionId&&typeof s.properties.couponBinding=="string")&&(c=await a.resolveOfferId?.({actionId:b.actionId,productVersionId:l,featureQuantities:Ie(t.document.screen,l,b.selection,t.capabilities)})),w)return;c!==void 0&&(b.offerId=c),ye=!0}if(!E()){y.hidden=!1;return}let e;try{e=await i.preview(b)}catch(t){throw i.canReselect===!0&&(b=null,ye=!1,Te=!1,$=void 0,m=null),t}if(b.acceptHostedMonthly!==void 0){let t=i.operation;if(!t||t.operationId!==e.operationId||!t.confirmedAt)throw new k("INVALID_RESPONSE","The confirmed Checkout is missing");w||await H(t,!0);return}if($&&(L(e)?(()=>{let t=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return t?.couponId!==$.id||t.grantId!==b.offerId})():e.discount?.couponId!==$.id||e.discount.offerId!==b.offerId))throw new k("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(w)return;let n=e.merchantTerms;if(a.purchaseConfirmation!=="paywall"||a.confirmOnHostedCheckout&&E()&&!L(e)&&e.provider==="merchant"&&e.billingSubscriptionId===null&&n?.request.action==="purchase"&&n.request.mode==="subscription"&&n.subscriptionTerms?.trial===null&&n.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){if(!E()){y.hidden=!1;return}if(!(Date.parse(e.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");let t=ae?"":o?"正在打开收银台…":"Opening checkout…";f.textContent=t;try{await _e()}catch(r){w||Ce(r)}finally{f.textContent===t&&(f.textContent="")}return}ln(e)}function Re(e="destroy",n=!1){if(w)return;w=!0;let t=ht;ht=void 0,K(t),a.signal?.removeEventListener("abort",se),i.signal?.removeEventListener("abort",se),Q.finish("dismissed"),$t?.(),vt(),h.removeEventListener("visibilitychange",Gt),Z.abort(),Vt?.disconnect(),D?.destroy(),i.destroy(),S.removeEventListener("cancel",dn),_.remove(),M.remove(),n||un(),e==="dismiss"&&K(a.onDismiss)}function un(){if(V?.destroy(),ue){ue.release();return}S.open&&S.close(),S.remove(),N()}G=Re;async function Fe(){if(!he||w||ze||ie==="closing"||!ie&&!E())return;if(!A){Re("dismiss");return}let e=h.createElement("p");e.setAttribute("role","status"),e.textContent=o?"正在关闭…":"Closing…",me||(me=h.createElement("div"),me.style.cssText=Y.style.cssText,Y.replaceWith(me),pe.inert=!0),_.hidden=!1,me.replaceChildren(e,_),ie="closing",_.setAttribute("aria-disabled","true"),_.focus({preventScroll:!0});try{await A.dismiss()}catch(n){w||K(a.onError,n)}w||(ie="retry",e.textContent=o?"未能确认关闭,请重试。":"Could not confirm closure. Try again.",_.textContent=o?"重试关闭":"Retry closing",_.removeAttribute("aria-label"),_.removeAttribute("aria-disabled"))}_.onclick=()=>{Fe()};function dn(e){e.preventDefault(),Fe()}S.addEventListener("cancel",dn),le.onclick=()=>{W(P?xt:tt)},y.onclick=()=>{if(q){q.retry?.();return}m&&W(m)};function At(e){Q.finish("error",e),Re()}function Rt(){if(!(!Bt||he||w||ze||V&&!E()))try{let e=n=>{a.focusAtReveal&&(N=Ut(h)),a.settleMotionAtReveal?D?.setHidden?.(!1,!0):D?.setHidden?.(!1),mt?.(),V&&(S.open||S.showModal(),V.responsive&&S.focus({preventScroll:!0}),!n&&a.loading!=="host"&&vn(S,V.type,V.responsive)),n&&a.loading!=="host"&&typeof pe.animate=="function"&&!h.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&pe.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),he=!0,Ze()};A?A.present(n=>Q.present(t=>e(n??t))):Q.present(e)}catch(e){At(e),Ce(e)}}try{if(Me.type==="inline"?(dt(),mt=Rn(M,j),j.append(M)):(S.setAttribute("aria-label",d.document.name),_.textContent="×",_.setAttribute("aria-label",o?"关闭":"Close"),kn(_,d.document.screen.theme),_.hidden=bn(d.document),(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&ue?.content?ue.content.append(_,M):S.replaceChildren(_,M),ue||j.append(S),V=Pn(S,{...d.document.screen,presentation:Me},ft),V.latch(),V.responsive&&(M.style.display="flex",M.style.flexDirection="column",M.style.maxHeight="100%",pe.style.overflow="clip",pe.style.minHeight="0"),ue||(mt=An(S))),lt&&ee){let t=lt(ee);if(typeof t=="function"&&(w?K(t):ht=t),w)throw new DOMException("Presentation cancelled","AbortError");dt()}D=ne(pe,{mode:"live",rendererUrl:"bundled",title:d.document.name,closeActions:Mn,onAuthoredClose(t){ie||w||(_.hidden=t)},hostPresentation:()=>V?.type??Me.type,reportContentHeight:V?.responsive,onResize:t=>{if(!V?.responsive)return;let r=Math.min(t,pt);pe.style.height=`${r}px`,V.setContentHeight(r+Qt())},onSelection(t){for(let[r,l]of Object.entries(t))typeof l=="number"&&typeof J[r]=="number"&&J[r]!==l&&jt.add(r);J=t,Ee(),Ze()},onAction(t,r={},l,c){if(!he||w||ie)return;let s=i.view,u=s?.document.buttons[t];if(!u)return;if(q){u.type==="close"&&Fe();return}if(u.type==="close"&&A&&a.resumeCheckout&&i.operation&&gn(R(i.operation))){Fe();return}if(fe)return;if(!E()){kt();return}if(u.type==="close"){W(async()=>{A?.closeAction?await A.closeAction(t):await a.onAction?.(t),Re(a.onAction?"action":"dismiss")});return}if(u.type==="action"){m=async()=>{if(u.action.type==="event"){if(!a.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(u.action.event)}else a.onOpenUrl?await a.onOpenUrl(u.action.url):h.defaultView?.location.assign(u.action.url);await a.onAction?.(t),m=null},W(m);return}if(ge()&&F){!we&&F.selection.actionId===t&&W(()=>nt(!0),t);return}if(P){if(P.phase==="payment"&&s&&Ne(P.quote,s,t,u.product,r,c)){W(xt,t);return}if(!Ct())return}if(!be()&&!Ct()){ge()&&s&&i.quote&&i.operation&&R(i.operation).type==="checkout"&&Ne(i.quote,s,t,u.product,r,c)?W(tt,t):f.textContent=o?"当前只能继续原订单。":"Only your original checkout is available.";return}if(de&&i.canReselect===!1){f.textContent=o?"请先确认或取消当前购买。":"Confirm or cancel the current purchase first.",V?.responsive||de.scrollIntoView?.({block:"nearest"}),de.querySelector("button")?.focus({preventScroll:!0});return}if(ge()&&a.terminateCheckout&&s&&i.quote&&i.operation&&i.canReselect===!1&&R(i.operation).type==="checkout"){if(Ne(i.quote,s,t,u.product,r,c)){W(tt,t);return}let p=ke(u.product,r,s.capabilities),x;try{if(!p)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");x=Ie(s.document.screen,p,r,s.capabilities)}catch(Ue){Ce(Ue);return}let T=i.operation.operationId,Pe={actionId:t,requestId:crypto.randomUUID(),selection:structuredClone(r)},X=rt(s,t,p,r,c);W(()=>Zt(T,Pe,X,{actionId:t,productVersionId:p,selection:Pe.selection,featureQuantities:x}),t);return}if((i.quote||b)&&i.canReselect===!1){let p=!!s&&!!i.quote&&Ne(i.quote,s,t,u.product,r,c);it=!!i.quote&&!p,m=i.quote?()=>Et(p):qe,W(m,t);return}let I=s&&ke(u.product,r,s.capabilities);if(!s||!I){Ce(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){m=null;let p=async()=>{let x={actionId:t,productVersionId:I,selection:structuredClone(r),featureQuantities:Ie(s.document.screen,I,r,s.capabilities)},T=rt(s,t,I,r,c);T&&(x.coupon={id:T.id,...T.offerId&&{offerId:T.offerId}}),Ke=!0,await a.onPurchaseIntent(x)};tn.add(p),W(p,t);return}if(b&&b.actionId!==t){Ce(new k("COMMAND_PENDING","Finish the current purchase"));return}if(!b){$=rt(s,t,I,r,c),b={requestId:crypto.randomUUID(),actionId:t,selection:structuredClone(r)};let p=s.document.screen.actions.find(Pe=>Pe.id===t)?.properties,x=p?.hostedMonthlyPriceMinor,T=p?.hostedMonthlyAutomaticTax;a.purchaseConfirmation==="purchase_button"&&a.confirmOnHostedCheckout&&i.supportsHostedCheckout===!0&&!$&&u.product.type==="fixed"&&typeof T=="boolean"&&typeof x=="number"&&Number.isSafeInteger(x)&&x>0&&x<=1e8&&Object.keys(Ie(s.document.screen,I,r,s.capabilities)).length===0&&(b.acceptHostedMonthly={amountMinor:x,automaticTax:T}),ye=b.acceptHostedMonthly!==void 0,Te=ye}W(qe,t)},onEscape:()=>{Fe()},onError:t=>{let r=new Error(t);!he&&!w&&At(r),Ce(r)},onRendered:t=>{t&&S.setAttribute("aria-label",t),Bt=!0,Rt()}}),D.setHidden?.(!0),ft();let e=ge()&&!!i.quote&&!!i.operation&&R(i.operation).type==="checkout";J=i.quote?_n(d,i.quote)??st(d,{}):st(d,{}),D.update(d.document.screen,ut,{capabilities:oe(d),unavailableActions:xe(d),serverInput:{bindings:[],answers:{}},...Object.keys(J).length?{selection:J}:{}}),$t=i.subscribe?.($e),$e(i.view??d),await Q.wait(D.ready);let n=i.operation;(!e||gt(i.quote))&&(i.quote||n&&(n.confirmedAt||n.checkoutUrl||Ge(n)))&&(m=cn,W(m))}catch(e){throw At(e),e}return{check:ce,host:{get currentResolution(){return d},setPurchaseRecovery(e,n){q={message:e,retry:n},D?.updateCapabilities?.(oe(d),xe(d)),Ee(),en()},get subscriptionUpgradeActive(){return P!==void 0},get observing(){return Ve},get recovery(){return Vn()},async prepareFallback(){if(fe||w||ie||Ke)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};je(!0);try{let e=await wn(i);return e.type==="native"&&Re(),e}finally{je(!1)}},setSuspended(e){ze=e,M.hidden=e,e&&S.open?S.close():!e&&!he?Rt():!e&&!w&&he&&Me.type!=="inline"&&!S.open&&S.showModal()},destroy:Re,retainPurchaseDialog(){if(!(w||!S.open||!S.isConnected))return Re("destroy",!0),{dialog:S,content:ue?.content,release:un}},refresh:async()=>{if(!E()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return $e(e),Rt(),e}}}}export{kr as a};