@tinkerlandai/longplay-sdk 0.10.40 → 0.10.41

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 (120) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +56 -1
  3. package/README.zh-CN.md +5 -1
  4. package/dist/{ai-usage-DXwAGTxT.d.ts → ai-usage-B-qsCn-k.d.ts} +1 -1
  5. package/dist/{api-r6FfVQpg.d.ts → api-DpRb_Pd3.d.ts} +52 -0
  6. package/dist/check-response-SR3PDVGE.js +1 -0
  7. package/dist/chunk-24Z3THUR.js +1 -0
  8. package/dist/{chunk-FCDWCQYC.js → chunk-26UXCYBP.js} +1 -1
  9. package/dist/{chunk-7QDT6DO7.js → chunk-2LERKK7O.js} +1 -1
  10. package/dist/{chunk-RV6UAUK2.js → chunk-2LUVO7GM.js} +1 -1
  11. package/dist/{chunk-C2KT5ZFU.js → chunk-2P2YSNYU.js} +1 -1
  12. package/dist/{chunk-X6ONZGRY.js → chunk-2RUJXZCO.js} +1 -1
  13. package/dist/chunk-2XF34Q6D.js +1 -0
  14. package/dist/chunk-4B4RB36N.js +1 -0
  15. package/dist/chunk-5PNH2FPI.js +1 -0
  16. package/dist/{chunk-EREQZWGI.js → chunk-6EBS6MLW.js} +1 -1
  17. package/dist/chunk-6OVMC5BT.js +1 -0
  18. package/dist/{chunk-ASDJTOGM.js → chunk-6STWY5GX.js} +1 -1
  19. package/dist/chunk-756SIMZF.js +1 -0
  20. package/dist/chunk-7IVLNV5H.js +1 -0
  21. package/dist/chunk-ANXK3B5B.js +1 -0
  22. package/dist/{chunk-P6C3PNMQ.js → chunk-AQQJPP3P.js} +1 -1
  23. package/dist/chunk-BWRRZ2NW.js +1 -0
  24. package/dist/{chunk-O4KXODTJ.js → chunk-CQRSMCCG.js} +1 -1
  25. package/dist/{chunk-YLPQLD2A.js → chunk-DPEMW2FO.js} +1 -1
  26. package/dist/chunk-EECTJHI6.js +1 -0
  27. package/dist/{chunk-CZ4TQCUV.js → chunk-EJSDOSP5.js} +1 -1
  28. package/dist/{chunk-POCDWUD3.js → chunk-EON4IKWR.js} +1 -1
  29. package/dist/chunk-EOPKOAR5.js +1 -0
  30. package/dist/{chunk-QZTTKH2H.js → chunk-FTVNGN6Z.js} +1 -1
  31. package/dist/{chunk-WLGLQJ6M.js → chunk-G6CWZBT5.js} +1 -1
  32. package/dist/chunk-GXADA7OV.js +1 -0
  33. package/dist/{chunk-ORMQJAQE.js → chunk-H26F3IOI.js} +1 -1
  34. package/dist/{chunk-BYP4KVB3.js → chunk-H7AHDGVU.js} +2 -2
  35. package/dist/chunk-HGH2X6QM.js +1 -0
  36. package/dist/chunk-KINNES62.js +1 -0
  37. package/dist/{chunk-LSPHUA7V.js → chunk-MYDMOAKX.js} +1 -1
  38. package/dist/chunk-NFY7DKVJ.js +1 -0
  39. package/dist/{chunk-YY445FBU.js → chunk-O3HLNU6T.js} +1 -1
  40. package/dist/chunk-OAAS5LJY.js +1 -0
  41. package/dist/{chunk-2DPNSTCN.js → chunk-OEONV3JY.js} +1 -1
  42. package/dist/chunk-P6XQC7GG.js +1 -0
  43. package/dist/chunk-PYLX3WF6.js +1 -0
  44. package/dist/{chunk-5DZJCFNQ.js → chunk-QJMM37CB.js} +1 -1
  45. package/dist/{chunk-33ZVZOSC.js → chunk-RQTYIUWP.js} +1 -1
  46. package/dist/chunk-S4P4UUUF.js +1 -0
  47. package/dist/{chunk-57GPGWSK.js → chunk-SYHMHKFQ.js} +1 -1
  48. package/dist/{chunk-67AY54E2.js → chunk-TGPZJ5A7.js} +1 -1
  49. package/dist/chunk-VILB5M4X.js +1 -0
  50. package/dist/chunk-VJHURKRY.js +1 -0
  51. package/dist/{chunk-VC2HPREX.js → chunk-VWRQBQZD.js} +1 -1
  52. package/dist/chunk-W35FZWGG.js +1 -0
  53. package/dist/chunk-W3J2SIPY.js +1 -0
  54. package/dist/chunk-Y2HXKANG.js +1 -0
  55. package/dist/{configuration-sync-BHrAf-ql.d.ts → configuration-sync-7ruSsSrL.d.ts} +150 -1
  56. package/dist/content-XYUJFGY2.js +1 -0
  57. package/dist/funnel-host-purchase-BNS3242X.js +1 -0
  58. package/dist/{funnel-local-client-DR8OpKGU.d.ts → funnel-local-client-BMxDQWE6.d.ts} +51987 -22983
  59. package/dist/{funnel-node-evaluation-COxXtZEQ.d.ts → funnel-node-evaluation-COIh1hKs.d.ts} +3 -0
  60. package/dist/funnel-paywall-prerender-DDQI3GAZ.js +1 -0
  61. package/dist/{funnel-process-client-C87U4r_G.d.ts → funnel-process-client-DNR9nHs8.d.ts} +7338 -3163
  62. package/dist/funnel-route-prediction-BT5ZWU54.js +1 -0
  63. package/dist/funnel-route-source-7ZJMZRID.js +1 -0
  64. package/dist/funnel-runtime-host-3SSDNG24.js +1 -0
  65. package/dist/index.d.ts +273 -22
  66. package/dist/index.js +1 -1
  67. package/dist/merchant-bridge-contracts-YU53UKUN.js +1 -0
  68. package/dist/native-shell.js +1 -1
  69. package/dist/openrouter.d.ts +2 -2
  70. package/dist/openrouter.js +1 -1
  71. package/dist/operation-contracts-GEIGP23I.js +1 -0
  72. package/dist/page.d.ts +1 -1
  73. package/dist/page.js +1 -1
  74. package/dist/paywall-YZAEI7TF.js +1 -0
  75. package/dist/paywall-content-QBSB5NA7.js +1 -0
  76. package/dist/paywall-session-MHBAZLS7.js +1 -0
  77. package/dist/popup.d.ts +2 -2
  78. package/dist/popup.js +1 -1
  79. package/dist/{presentation-loading-B_v5XZtM.d.ts → presentation-loading-B2OeFzRN.d.ts} +1 -0
  80. package/dist/react-native.d.ts +6 -6
  81. package/dist/react-native.js +1 -1
  82. package/dist/screen-renderer-SEJG7A2C.js +1 -0
  83. package/dist/server.d.ts +34204 -17797
  84. package/dist/server.js +1 -1
  85. package/dist/{visual-dom-5LUN4AHO.js → visual-dom-7YYJQ2ZI.js} +1 -1
  86. package/dist/visual.js +1 -1
  87. package/package.json +1 -1
  88. package/dist/check-response-DRQCUWDW.js +0 -1
  89. package/dist/chunk-3NCMYTNG.js +0 -1
  90. package/dist/chunk-4TEZZZYK.js +0 -1
  91. package/dist/chunk-6PG3AS3G.js +0 -1
  92. package/dist/chunk-AZFWG352.js +0 -1
  93. package/dist/chunk-C3GYAKIU.js +0 -1
  94. package/dist/chunk-ESAHTG3Y.js +0 -1
  95. package/dist/chunk-GC6JBIRQ.js +0 -1
  96. package/dist/chunk-IJKAQNK6.js +0 -1
  97. package/dist/chunk-IOJVF52Q.js +0 -1
  98. package/dist/chunk-OOD2VDDP.js +0 -1
  99. package/dist/chunk-P23JOPR5.js +0 -1
  100. package/dist/chunk-PJS7M6X3.js +0 -1
  101. package/dist/chunk-PZOQV6MU.js +0 -1
  102. package/dist/chunk-RFNIGJOL.js +0 -1
  103. package/dist/chunk-RULQQ7WI.js +0 -1
  104. package/dist/chunk-U7GH4VME.js +0 -1
  105. package/dist/chunk-VOKEZHAH.js +0 -1
  106. package/dist/chunk-XDOKFAE6.js +0 -1
  107. package/dist/chunk-Y6HL2IY2.js +0 -1
  108. package/dist/content-QUEVNSXD.js +0 -1
  109. package/dist/funnel-host-purchase-LMVMJNUO.js +0 -1
  110. package/dist/funnel-paywall-prerender-LGUSHEP3.js +0 -1
  111. package/dist/funnel-runtime-host-H5FM67UC.js +0 -1
  112. package/dist/merchant-bridge-contracts-LZSQYE3O.js +0 -1
  113. package/dist/operation-contracts-O7TCDGV4.js +0 -1
  114. package/dist/paywall-UANWOKKC.js +0 -1
  115. package/dist/paywall-content-CHPX2P77.js +0 -1
  116. package/dist/paywall-session-3BNUC5ZE.js +0 -1
  117. package/dist/screen-renderer-FFVZ64MR.js +0 -1
  118. /package/dist/{chunk-RGEBK6UF.js → chunk-2ULWP26K.js} +0 -0
  119. /package/dist/{chunk-OJM6ORHE.js → chunk-4PGYQ2TI.js} +0 -0
  120. /package/dist/{chunk-CILM5XMH.js → chunk-PBBREFS5.js} +0 -0
@@ -1 +0,0 @@
1
- import{a as c}from"./chunk-WLGLQJ6M.js";function b(t){let n=Object.create(null);for(let e of t.document.screen.actions){let a=e.properties.couponBinding,i=t.document.buttons[e.id];if(typeof a!="string"||i?.type!=="checkout")continue;let r=Object.hasOwn(t.capabilities.nodes,a)?t.capabilities.nodes[a]:void 0,{product:s}=i,l=s.type==="fixed"?[s.productVersionId]:s.allowedProductVersionIds,p=r?[r.base,...Object.values(r.byPlan??{})]:[],d=Object.fromEntries(p.flatMap(o=>o.planVersionId&&o.couponId&&o.text&&l.includes(o.planVersionId)?[[o.planVersionId,o]]:[]));n[e.id]={products:d,...s.type==="picker"?{picker:s.pickerId}:{}}}return Object.keys(n).length?{...t.capabilities,checkoutCoupons:n}:t.capabilities}function y(t,n){let e=structuredClone(t);for(let[a,i]of Object.entries(e.plans)){let r=n.plans[a];!r||r.versionId!==i.versionId||(r.amountMinor!==void 0&&(i.amountMinor=r.amountMinor),r.interval!==void 0&&(i.interval=r.interval),r.intervalCount!==void 0&&(i.intervalCount=r.intervalCount),r.prepaid!==void 0&&(i.prepaid=structuredClone(r.prepaid)))}return e}var u=class extends c{constructor(e="Plans were updated. Choose again.",a="\u5957\u9910\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002"){super("CONFLICT",e);this.zhMessage=a}zhMessage;customerMessage(e){return e?this.zhMessage:this.message}};function h(t,n){let e=a=>"document"in a?a.offering.id:a.content.offeringVersionId;return t.id===n.id&&e(t)===e(n)&&t.content?.artifact.sha256===n.content?.artifact.sha256}function O(t,n,e){if(t.operationId!==n.operationId||n.currency!==void 0&&t.currency!==n.currency)throw new c("INVALID_RESPONSE",e)}function S(t,n,e){let a=Object.fromEntries((t.lines[0]?.prepaid??[]).map(i=>[i.internal_feature_id,i.quantity]));if(n.featureQuantities&&(Object.keys(a).length!==Object.keys(n.featureQuantities).length||Object.entries(n.featureQuantities).some(([i,r])=>a[i]!==r)))throw new c("INVALID_RESPONSE","The purchase quote changed its selected quantities");if(t.lines.length!==1||t.lines[0].productVersionId!==n.productVersionId||n.currency!==void 0&&t.currency!==n.currency||n.provider!==void 0&&t.provider!==n.provider&&!(n.provider==="stripe"&&t.provider==="merchant"&&t.execution?.provider==="merchant"))throw new c("INVALID_RESPONSE",e)}function I(t,n,e=!1){if(!t||t.operationId!==n?.operationId)return n;let a=t.merchantExecution,i=n.merchantExecution;if(a&&(!i||Date.parse(i.updatedAt)<Date.parse(a.updatedAt))||t.status==="complete"&&n.status!=="complete")return t;let r=n.status===t.status&&a?.recordingStatus!=="accepted"&&i?.recordingStatus==="accepted";return t.status!=="pending"&&(n.status==="pending"||e&&n.status!=="complete"&&!r)?t:n}function P(t){return t.screen.actions.some(n=>n.properties.closeControl==="content"&&t.buttons[n.id]?.type==="close")}export{b as a,y as b,u as c,h as d,O as e,S as f,I as g,P as h};
@@ -1 +0,0 @@
1
- import{a as C,c as ie,j as Ie}from"./chunk-Y6HL2IY2.js";import{c as J,d as k,f as T,g as $}from"./chunk-OOD2VDDP.js";import{b as e}from"./chunk-RGEBK6UF.js";var ke=e.number().int().min(0).max(1e8),ae=e.strictObject({kind:e.enum(["graduated","volume"]),tiers:e.array(e.strictObject({upTo:e.number().int().min(1).max(1e4).nullable(),unitAmountMinor:ke,flatAmountMinor:ke.optional()})).min(1).max(12)}).refine(t=>t.tiers.at(-1)?.upTo===null&&t.tiers.slice(0,-1).every((n,i)=>{let r=t.tiers[i-1]?.upTo;return n.upTo!==null&&(i===0||r!=null&&n.upTo>r)}),"Tier ceilings must increase and end unbounded").refine(t=>!t.tiers.some(n=>(n.flatAmountMinor??0)>0)||t.kind==="volume"&&t.tiers.length>1,"Tier flat fees require volume pricing with multiple tiers");function oe(t,n){if(!Number.isInteger(n)||n<0||n>1e4)throw new Error("Invalid purchased pack quantity");let i=t.pricing?ae.parse(t.pricing):void 0;if(n===0)return 0;let r=0n,a=0;if(!i)r=BigInt(t.amountMinor)*BigInt(n);else for(let o of i.tiers){let s=o.upTo??1e4;if(i.kind==="volume"){if(n<=s){r=BigInt(n)*BigInt(o.unitAmountMinor)+BigInt(o.flatAmountMinor??0);break}}else n>a&&(r+=BigInt(Math.min(n,s)-a)*BigInt(o.unitAmountMinor));a=s}if(r>200000000n)throw new Error("Purchased price exceeds the payment amount limit");return Number(r)}function we(t){return oe({amountMinor:t.unitAmountMinor,...t.pricing?{pricing:t.pricing}:{}},t.quantity)}var ot=k.refine(t=>/[1-9]/.test(t)),_e=e.strictObject({units:ot,prices:e.array(e.strictObject({currency:C,amountMinor:e.number().int().min(0).max(1e8),pricing:ae.optional()})).min(1).max(20).refine(t=>new Set(t.map(n=>n.currency)).size===t.length,"Currencies must be unique").refine(t=>t.every(n=>!n.pricing||n.amountMinor===0),"Tiered prices specify their rates in tiers"),minimumQuantity:e.number().int().min(0).max(1e4),maximumQuantity:e.number().int().min(0).max(1e4)}).refine(t=>t.maximumQuantity>=t.minimumQuantity,"Purchased quantity must fit its published bounds").refine(t=>{try{for(let n of t.prices)for(let i of[t.maximumQuantity,...n.pricing?.tiers.flatMap(r=>r.upTo===null?[]:[r.upTo,r.upTo+1])??[]])i<=t.maximumQuantity&&oe({amountMinor:n.amountMinor,...n.pricing===void 0?{}:{pricing:n.pricing}},i);return!0}catch{return!1}},"Every purchasable quantity must fit the payment amount limit");function je(t){if(!/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/.test(t))throw new Error("Invalid quantity");let[n,i=""]=t.split(".");if(n===void 0||n==="")throw new Error("Invalid decimal value");return BigInt(n)*1000000n+BigInt(i.padEnd(6,"0"))}function ze(t,n,i){if(!Number.isSafeInteger(i)||i<0||i>1e4)throw new Error("Invalid purchased quantity");let r=je(t)+je(n)*BigInt(i);if(r>999999999999999999n)throw new Error("Purchased allowance exceeds the ledger quantity limit");let a=(r%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return(r/1000000n).toString()+(a?"."+a:"")}var se=e.strictObject({internalFeatureId:e.uuid(),name:e.string().min(1).max(120),includedAmount:e.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),reset:e.enum(["hour","day","week","month","year","lifetime"]),resetCount:e.number().int().min(1).max(100),terms:_e});var st=["plan.name","plan.price","plan.period","plan.price_per_month","trial.headline","trial.terms","offer.headline","offer.name","offer.description","offer.eligibility","offer.validity","offer.terms","offer.discount","offer.price","offer.original_price","offer.months","offer.code","offer.ends_at","offer.expires_at","paywall.feature","paywall.message","paywall.action"],X=e.object({plan:e.string().min(1).max(200).optional(),coupon:e.uuid().optional(),promotionCode:e.uuid().optional(),picker:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).optional()}).strict(),Ae=e.object({text:e.string().optional(),label:e.string().optional(),alt:e.string().optional(),html:e.string().max(32768).optional(),price:e.object({current:e.string(),original:e.string().nullable(),period:e.string()}).optional(),code:e.string().optional(),countdownAt:e.iso.datetime().optional(),planId:e.string().min(1).max(200).optional(),planVersionId:e.string().min(1).max(200).optional(),currency:C.optional(),couponId:e.uuid().optional(),offerId:e.uuid().optional(),unavailable:e.boolean().optional(),unavailableReason:e.string().optional(),missing:e.array(e.string()).optional()}).strict(),Mn=e.object({paywall:Ie.optional(),nodes:e.record(e.string(),e.object({base:Ae,picker:e.string().optional(),byPlan:e.record(e.string(),Ae).optional()}).strict()),plans:e.record(e.string(),e.object({id:e.string().min(1).max(200),versionId:e.string().min(1).max(200),available:e.boolean(),name:e.string(),price:e.string(),period:e.string(),currency:C.optional(),amountMinor:e.number().int().nonnegative().optional(),interval:e.enum(["free","week","month","year","one_time"]).optional(),intervalCount:e.number().int().positive().optional(),prepaid:e.array(se).max(100).optional()}).strict()),pickers:e.record(e.string(),e.object({options:e.array(e.string().min(1).max(200)).max(20),selected:e.string().min(1).max(200).nullable()}).strict()),quantities:e.record(e.string(),e.strictObject({minimum:e.number().int().nonnegative(),maximum:e.number().int().nonnegative(),step:e.number().int().positive(),value:e.number().int().nonnegative(),label:e.string(),available:e.boolean()})).optional(),diagnostics:e.array(e.object({nodeId:e.string(),message:e.string()}).strict())}).strict();function ve(t){return[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].flatMap(n=>n[1]===void 0?[]:[n[1].trim()])}function ce(t){let n=ve(t).filter(r=>!st.includes(r)&&!/^variables\.[A-Za-z0-9_][A-Za-z0-9_.:-]*$/.test(r)),i=t.replace(/\{\{\s*[^{}]+?\s*\}\}/g,"");return(i.includes("{{")||i.includes("}}"))&&n.push("\u65E0\u6548\u53D8\u91CF\u8BED\u6CD5"),[...new Set(n)]}function Qn(t,n,i={}){let r=t?.nodes[n];if(!r)return;let a=r.picker?i[r.picker]??t?.pickers[r.picker]?.selected:void 0;return typeof a=="string"?r.byPlan?.[a]??r.base:r.base}var ct=["credit_balance","credit_transactions","membership","billing","billing_controls","customer_plans","credit_packs","credit_pack_orders","offer_history"],Oe=e.enum(ct),Pe=e.object({source:Oe,layout:e.enum(["full","compact"]),resourceKey:T.optional(),pageSize:e.number().int().min(1).max(50),showSources:e.boolean(),allowPurchase:e.boolean(),outputs:e.object({billing_adjustment:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_authorization:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),buy_pack:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_portal:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),cancel_membership:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),resume_membership:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional()}).strict().optional()}).strict().superRefine((t,n)=>{(t.outputs?.billing_authorization||t.outputs?.billing_adjustment)&&t.source!=="billing_controls"&&n.addIssue({code:"custom",message:"Payment authorization routes belong to the billing controls component."}),t.resourceKey&&!["credit_balance","credit_transactions"].includes(t.source)&&n.addIssue({code:"custom",message:"\u8FD9\u4E2A\u6570\u636E\u6E90\u4E0D\u80FD\u7ED1\u5B9A\u79EF\u5206\u8D44\u6E90\u3002"}),t.showSources&&t.source!=="credit_balance"&&n.addIssue({code:"custom",message:"\u53EA\u6709\u79EF\u5206\u4F59\u989D\u53EF\u4EE5\u5C55\u5F00\u6765\u6E90\u3002"}),t.allowPurchase&&!["credit_packs","customer_plans","membership"].includes(t.source)&&n.addIssue({code:"custom",message:"\u53EA\u6709\u79EF\u5206\u5305\u3001\u5957\u9910\u4E0E\u4F1A\u5458\u7EC4\u4EF6\u53EF\u4EE5\u542F\u7528\u4EA4\u6613\u3002"})}),S=e.string().max(2e3),Ne=e.object({id:e.string().max(100),label:S,detail:e.array(S).max(12),value:S.optional(),status:S.optional(),facts:e.array(e.object({label:S,value:S}).strict()).max(1e3),purchaseId:e.uuid().optional(),invoiceUrl:e.url().max(2048).refine(t=>{let n=new URL(t);return n.protocol==="https:"&&!n.username&&!n.password}).optional(),billingActions:e.array(e.strictObject({action:e.literal("invoice_open"),label:S})).max(1).optional(),membershipActions:e.array(e.object({value:e.string().max(100),label:S}).strict()).max(3).optional()}).strict(),ut=e.object({key:T,name:S,spendable:S,reserved:S,available:S,expiry:S.nullable(),sources:e.array(Ne).max(50),sourceCount:e.number().int().nonnegative(),sourcePage:e.number().int().positive(),hasNextSources:e.boolean(),hasPreviousSources:e.boolean()}).strict(),lt=e.object({source:Oe,status:e.enum(["idle","loading","ready","error"]),stale:e.boolean(),preview:e.boolean(),errorCode:e.string().max(80).optional(),errorMessage:S.optional(),resources:e.array(ut).max(500),rows:e.array(Ne).max(50),hasNext:e.boolean(),hasPrevious:e.boolean(),page:e.number().int().positive(),filter:e.string().max(40),updatedAt:e.iso.datetime().optional(),buyingId:e.uuid().optional(),membershipBusy:e.boolean().optional(),billingBusy:e.boolean().optional(),membershipReview:e.object({title:S,note:S,facts:e.array(e.object({label:S,value:S}).strict()).max(100)}).strict().optional(),membershipResult:S.optional()}).strict(),Kn=e.object({nodes:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),lt)}).strict(),Hn=e.object({nodeId:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),action:e.enum(["refresh","next","previous","filter","buy_pack","billing_portal","billing_authorization","billing_adjustment","invoice_open","membership_preview","membership_confirm","membership_dismiss","sources_next","sources_previous"]),value:e.string().max(100).optional()}).strict();var pt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Xn=e.discriminatedUnion("type",[e.object({type:e.literal("fixed"),productVersionId:e.string().min(1).max(200)}).strict(),e.object({type:e.literal("picker"),pickerId:pt,allowedProductVersionIds:e.array(e.string().min(1).max(200)).min(1).max(20)}).strict().refine(t=>new Set(t.allowedProductVersionIds).size===t.allowedProductVersionIds.length,"Product choices must be unique")]),mt=e.strictObject({min:e.number().finite().min(1).max(1800),max:e.number().finite().min(1).max(1800),viewport:e.number().finite().min(1).max(100)}).refine(t=>t.min<=t.max,"Desktop width range is reversed"),$e={desktopWidth:mt.optional(),mobile:e.enum(["sheet","fullscreen"]).optional(),backdrop:e.enum(["none","scrim","dim","strong-dim","blur"]).optional()},Ce=e.discriminatedUnion("type",[e.strictObject({type:e.literal("modal"),position:e.enum(["center","top","bottom"]).optional(),size:e.enum(["sm","md","lg"]),...$e}),e.strictObject({type:e.literal("sheet"),size:e.enum(["sm","md","lg"]),...$e}),e.strictObject({type:e.literal("fullscreen")}),e.strictObject({type:e.literal("inline")})]),dt={sm:360,md:420,lg:560};function De(t){return t.type==="stack"&&t.interaction?.type==="select"&&t.interaction.purpose==="product"&&!!t.interaction.pickerId}function Ee(t){let n={};function i(r){if(De(r)){let a=n[r.interaction.pickerId]??={ids:[],defaultId:null};for(let s of r.children){let c=s.type==="stack"?s.bind?.plan:void 0;c&&!a.ids.includes(c)&&a.ids.push(c)}let o=r.children[r.interaction.defaultIndex];!a.defaultId&&o?.type==="stack"&&(a.defaultId=o.bind?.plan??null)}r.type==="stack"&&r.children.forEach(i)}return t.pages.forEach(r=>i(r.root)),n}function Re(t,n,i){let r={};function a(l){if(l.hidden)return;if(l.type==="plan_picker"){let b=i.pickers[l.id];r[l.id]={ids:b?.options??[],defaults:b?.selected?[b.selected]:[],remembered:[]};return}if(l.type!=="stack")return;let d=l.children.filter(b=>!b.hidden),u=l.interaction;if(De(l)){let b=r[l.interaction.pickerId]??={ids:[],defaults:[],remembered:[]},h=i.pickers[l.interaction.pickerId]?.options??[];for(let p of d){let f=p.type==="stack"?p.bind?.plan:void 0;f&&h.includes(f)&&!b.ids.includes(f)&&b.ids.push(f),f&&p.id===n[l.id]&&b.remembered.push(f)}let m=l.children[l.interaction.defaultIndex];m?.type==="stack"&&!m.hidden&&m.bind?.plan&&b.defaults.push(m.bind.plan)}if(u?.type==="tabs"){let b=d.find(h=>h.id===n[l.id])??l.children[u.defaultIndex];b&&a(b)}else if(u?.type==="toggle"){let b=typeof n[l.id]=="boolean"?n[l.id]:u.defaultEnabled,h=l.children[b?0:1];h&&a(h)}else d.forEach(a)}let o=typeof n.__page=="string"?n.__page:t.initialPageId??t.pages[0]?.id,s=t.pages.find(l=>l.id===o);s&&a(s.root);let c={};for(let[l,d]of Object.entries(r)){let u=n[l],b=d.remembered[0]??(d.ids.includes(i.pickers[l]?.selected??"")?i.pickers[l]?.selected:d.defaults[0]);c[l]=typeof u=="string"?d.ids.includes(u)?u:"":b&&d.ids.includes(b)?b:""}for(let l of Object.keys(Ee(t)))c[l]??="";return c}var Ue=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Le=e.strictObject({tiers:e.array(e.strictObject({id:Ue,name:e.string().trim().min(1).max(80)})).min(1).max(8),assignments:e.array(e.strictObject({productVersionId:e.string().min(1).max(200),tierId:Ue,period:e.enum(["month","year"])})).max(20)}).superRefine((t,n)=>{let i=t.tiers.map(r=>r.id);(new Set(i).size!==i.length||new Set(t.assignments.map(r=>r.productVersionId)).size!==t.assignments.length||new Set(t.assignments.map(r=>`${r.tierId}:${r.period}`)).size!==t.assignments.length||t.assignments.some(r=>!i.includes(r.tierId)))&&n.addIssue({code:"custom",message:"Each product and tier/period cell must have one unambiguous assignment"})});function Te(t,n){return t.assignments.length===n.length&&t.assignments.every(i=>n.includes(i.productVersionId))}function ir(t){let n=ce(t).map(i=>`\u672A\u77E5\u53D8\u91CF\uFF1A${i}`);for(let i=0;i<t.length;i++){if(t[i]!=="<"||!/[A-Za-z!/?{]/.test(t[i+1]??""))continue;let r=i;if(t.startsWith("<!--",i)){let a=t.indexOf("-->",i+4);i=a<0?t.length:a+2}else{let a="";for(i++;i<t.length;i++){let o=t[i];if(a)o===a&&(a="");else if(o==='"'||o==="'")a=o;else if(o===">")break}}/\{\{|\}\}/.test(t.slice(r,i+1))&&n.push("\u53D8\u91CF\u53EA\u80FD\u653E\u5728 HTML \u6587\u5B57\u4E2D\uFF0C\u4E0D\u80FD\u653E\u5165\u6807\u7B7E\u3001\u5C5E\u6027\u6216\u6CE8\u91CA")}return[...new Set(n)]}var x={state:32,enumValues:64,derived:96,bindings:256,controls:64,timers:4,effects:8,depth:12,expressionNodes:2e3},Ve=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),I=e.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/).refine(t=>!Ve.has(t),"Reserved UI identifier"),ue=e.union([e.string().max(2e3),e.number().finite(),e.boolean(),e.null()]),ft=e.discriminatedUnion("type",[e.strictObject({type:e.literal("enum"),values:e.array(ue).min(1).max(x.enumValues),default:ue}),e.strictObject({type:e.literal("number"),min:e.number().finite(),max:e.number().finite(),step:e.number().finite().positive(),default:e.number().finite()}),e.strictObject({type:e.literal("text"),maxLength:e.number().int().min(0).max(2e3),default:e.string().max(2e3).nullable()}),e.strictObject({type:e.literal("boolean"),default:e.boolean()})]);function Y(t,n){if(t.type==="enum")return t.values.some(r=>r===n);if(t.type==="boolean")return typeof n=="boolean";if(t.type==="text")return n===null||typeof n=="string"&&n.length<=t.maxLength;if(typeof n!="number"||!Number.isFinite(n)||n<t.min||n>t.max)return!1;let i=(n-t.min)/t.step;return Number.isFinite(i)&&Math.abs(i-Math.round(i))<=Math.min(1e-7,Math.max(1,Math.abs(i))*Number.EPSILON*8)}var gt=ft.superRefine((t,n)=>{t.type==="enum"&&new Set(t.values).size!==t.values.length&&n.addIssue({code:"custom",path:["values"],message:"UI enum values must be unique"}),t.type==="number"&&t.min>t.max&&n.addIssue({code:"custom",path:["max"],message:"UI number range is reversed"}),Y(t,t.default)||n.addIssue({code:"custom",path:["default"],message:"UI default must match its state definition"})}),bt=["add","sub","mul","div","min","max","round","floor","eq","ne","gt","gte","lt","lte","and","or","not","if","concat","number","parse_number","money","lookup","now","duration"];function yt(t,n){return t==="now"?n===0:t==="concat"?!0:t==="lookup"?n>=4&&n%2===0:t==="if"?n===3:["sub","div","eq","ne","gt","gte","lt","lte"].includes(t)?n===2:["round","floor","not","number","parse_number","money","duration"].includes(t)?n===1:n>=1}var R=e.lazy(()=>e.union([ue,e.strictObject({ref:I}),e.strictObject({op:e.enum(bt),args:e.array(R).max(x.expressionNodes)}).superRefine((t,n)=>{yt(t.op,t.args.length)||n.addIssue({code:"custom",path:["args"],message:"Invalid UI expression arity"})})]));function z(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let n=Object.getPrototypeOf(t);return n===null||n===Object.prototype}function E(t,n,i){if(!t||typeof t!="object")return!0;if(!z(t))return n.addIssue({code:"custom",path:i,message:"UI objects must be plain data"}),!1;for(let r of Object.keys(t)){if(Ve.has(r))return n.addIssue({code:"custom",path:[...i,r],message:"Reserved UI object key"}),!1;let a=Object.getOwnPropertyDescriptor(t,r);if(a&&!Object.hasOwn(a,"value"))return n.addIssue({code:"custom",path:[...i,r],message:"UI objects cannot contain accessors"}),!1}return!0}function F(t,n,i,r){let a=[{value:t,depth:1,path:i}];for(;a.length;){let o=a.pop();if(++r.nodes>x.expressionNodes||o.depth>x.depth){n.addIssue({code:"custom",path:o.path,message:"UI expression budget exceeded"});return}if(!E(o.value,n,o.path))return;if(z(o.value)&&Array.isArray(o.value.args)){if(o.value.args.length>x.expressionNodes){n.addIssue({code:"custom",path:[...o.path,"args"],message:"UI expression budget exceeded"});return}for(let s=o.value.args.length-1;s>=0;s--)a.push({value:o.value.args[s],depth:o.depth+1,path:[...o.path,"args",s]})}}}var sr=e.unknown().superRefine((t,n)=>{F(t,n,[],{nodes:0})}).pipe(R),le=e.record(I,R).refine(t=>Object.keys(t).length>0&&Object.keys(t).length<=x.state,"UI assignments need 1\u201332 state keys"),ht=e.strictObject({target:I,property:e.enum(["text","visible","disabled","checked","value","class","aria-label","aria-selected","aria-checked","aria-valuetext","tabindex"]),expression:R,className:I.optional()}).superRefine((t,n)=>{t.property==="class"!=(t.className!==void 0)&&n.addIssue({code:"custom",path:["className"],message:"Only class bindings require a safe className"})}),xt=e.discriminatedUnion("type",[e.strictObject({type:e.literal("scroll_latch"),target:I,state:I}),e.strictObject({type:e.literal("input"),target:I,state:I,set:le.optional()}),e.strictObject({type:e.literal("action"),target:I,set:le}),e.strictObject({type:e.literal("carousel"),target:I,state:I,initialIndex:e.number().int().nonnegative().optional(),maxWidth:e.number().int().min(1).max(1e4).optional(),previousTarget:I.optional(),nextTarget:I.optional(),inactiveTargets:e.array(I).max(20).optional(),inactiveMaxWidth:e.number().int().min(1).max(1e4).optional()})]),St=e.strictObject({afterMs:e.number().int().min(0).max(6e4),set:le}),It=e.strictObject({type:e.literal("mosaic_waves"),target:I,color:e.string().regex(/^#[0-9a-fA-F]{6}$/),hotColor:e.string().regex(/^#[0-9a-fA-F]{6}$/),enabled:R.optional(),speed:e.number().min(0).max(4).optional(),pitch:e.number().min(.05).max(4).optional(),fill:e.number().min(.05).max(1).optional(),feather:e.number().min(0).max(1).optional(),warp:e.number().min(0).max(4).optional(),warpScale:e.number().min(0).max(32).optional(),detailScale:e.number().min(0).max(32).optional(),waveScale:e.number().min(0).max(32).optional(),falloff:e.number().min(.1).max(32).optional(),brightness:e.number().min(0).max(32).optional(),ambient:e.number().min(0).max(1).optional(),gamma:e.number().min(.05).max(8).optional(),vignette:e.number().min(0).max(1).optional(),opacity:e.number().min(0).max(1).optional()}),kt=e.strictObject({type:e.literal("number_counter"),target:I,value:R,prefix:e.string().max(20).optional(),format:e.enum(["number","short"]).optional()}),wt=e.strictObject({state:e.record(I,gt).refine(t=>Object.keys(t).length<=x.state,"Too many UI state keys").optional(),derived:e.record(I,R).refine(t=>Object.keys(t).length<=x.derived,"Too many UI derived keys").optional(),bindings:e.array(ht).max(x.bindings).optional(),controls:e.array(xt).max(x.controls).optional(),timers:e.array(St).max(x.timers).optional(),effects:e.array(e.discriminatedUnion("type",[It,kt])).max(x.effects).optional(),clock:e.boolean().optional()});function jt(t,n){if(!E(t,n,[])||!z(t))return;for(let[r,a]of[["state",x.state],["derived",x.derived]]){let o=t[r];if(!E(o,n,[r]))return;if(z(o)&&Object.keys(o).length>a){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}}for(let[r,a]of[["bindings",x.bindings],["controls",x.controls],["timers",x.timers],["effects",x.effects]])if(Array.isArray(t[r])&&t[r].length>a){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}if(Array.isArray(t.effects)){for(let[r,a]of t.effects.entries())if(!E(a,n,["effects",r]))return}if(z(t.state))for(let[r,a]of Object.entries(t.state)){if(!E(a,n,["state",r]))return;if(z(a)&&Array.isArray(a.values)&&a.values.length>x.enumValues){n.addIssue({code:"custom",path:["state",r,"values"],message:"Too many UI enum values"});return}}let i={nodes:0};if(z(t.derived))for(let[r,a]of Object.entries(t.derived))F(a,n,["derived",r],i);for(let r of["bindings","controls","timers"]){let a=t[r];if(Array.isArray(a)){for(let[o,s]of a.entries())if(!(!E(s,n,[r,o])||!z(s))){if(r==="bindings")F(s.expression,n,[r,o,"expression"],i);else if(E(s.set,n,[r,o,"set"])&&z(s.set)){if(Object.keys(s.set).length>x.state){n.addIssue({code:"custom",path:[r,o,"set"],message:"Too many UI assignments"});return}for(let[c,l]of Object.entries(s.set))F(l,n,[r,o,"set",c],i)}if(i.nodes>x.expressionNodes)return}}}if(Array.isArray(t.effects))for(let[r,a]of t.effects.entries())z(a)&&a.type==="number_counter"?F(a.value,n,["effects",r,"value"],i):z(a)&&a.enabled!==void 0&&F(a.enabled,n,["effects",r,"enabled"],i)}function Fe(t){let n=[],i=[t];for(;i.length;){let r=i.pop();!r||typeof r!="object"||("ref"in r?n.push(r.ref):i.push(...r.args))}return n}var qe=e.unknown().superRefine(jt).pipe(wt).superRefine((t,n)=>{let i=t.state??{},r=t.derived??{},a=new Set([...Object.keys(i),...Object.keys(r)]),o=(m,p)=>{for(let f of Fe(m))a.has(f)||n.addIssue({code:"custom",path:p,message:`Unknown UI reference: ${f}`})};for(let[m,p]of Object.entries(t.derived??{}))Object.hasOwn(i,m)&&n.addIssue({code:"custom",path:["derived",m],message:"UI state and derived identifiers must be distinct"}),o(p,["derived",m]);let s=new Set,c=new Set,l=m=>{if(s.has(m))return!1;if(c.has(m))return!0;s.add(m);for(let p of Fe(r[m]))if(Object.hasOwn(r,p)&&!l(p))return!1;return s.delete(m),c.add(m),!0};for(let m of Object.keys(r))if(!l(m)){n.addIssue({code:"custom",path:["derived",m],message:"Cyclic UI derived references"});break}for(let[m,p]of(t.bindings??[]).entries())o(p.expression,["bindings",m,"expression"]);let d=new Set;for(let[m,p]of(t.effects??[]).entries())d.has(p.target)&&n.addIssue({code:"custom",path:["effects",m,"target"],message:"Effect targets must be unique"}),d.add(p.target),p.type==="number_counter"?(o(p.value,["effects",m,"value"]),typeof p.value=="number"&&Math.abs(p.value)>1e12&&n.addIssue({code:"custom",path:["effects",m,"value"],message:"Counter values must be within the display bound"})):p.enabled!==void 0&&o(p.enabled,["effects",m,"enabled"]);let u=(m,p)=>{for(let[f,w]of Object.entries(m))Object.hasOwn(i,f)||n.addIssue({code:"custom",path:[...p,f],message:"UI assignments can only update declared state"}),o(w,[...p,f])},b=new Set,h=new Set;for(let[m,p]of(t.controls??[]).entries()){if(p.type==="carousel"&&p.inactiveMaxWidth!==void 0&&p.inactiveTargets===void 0&&n.addIssue({code:"custom",path:["controls",m,"inactiveMaxWidth"],message:"Inactive width requires inactive article targets"}),p.type==="carousel")for(let f of p.inactiveTargets??[])(f===p.target||h.has(f))&&n.addIssue({code:"custom",path:["controls",m,"inactiveTargets"],message:"Inactive article targets must have one carousel owner"}),h.add(f);if(p.type==="carousel")for(let f of["previousTarget","nextTarget"]){let w=p[f];w!==void 0&&((w===p.target||b.has(w)||(t.controls??[]).some(M=>M.target===w))&&n.addIssue({code:"custom",path:["controls",m,f],message:"Carousel navigation needs a distinct, exclusive button target"}),b.add(w))}if(p.type!=="action"){let f=Object.hasOwn(i,p.state)?i[p.state]:void 0;(!f||p.type==="input"&&f.type==="enum"&&f.values.some(w=>typeof w!="string"))&&n.addIssue({code:"custom",path:["controls",m,"state"],message:"Control needs a supported declared UI state"}),p.type==="carousel"&&(f?.type!=="number"||!Number.isInteger(f.min)||f.min<0||!Number.isInteger(f.max)||f.step!==1||p.initialIndex!==void 0&&!Y(f,p.initialIndex))&&n.addIssue({code:"custom",path:["controls",m],message:"Carousel needs bounded nonnegative integer index state"}),p.type==="scroll_latch"&&f?.type!=="boolean"&&n.addIssue({code:"custom",path:["controls",m,"state"],message:"Scroll latches require boolean UI state"})}(p.type==="input"||p.type==="action")&&p.set&&u(p.set,["controls",m,"set"])}for(let[m,p]of(t.timers??[]).entries())u(p.set,["timers",m,"set"])});var Qe=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,V=e.string().max(16).regex(Qe,"\u8BED\u8A00\u4EE3\u7801\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u4F8B\u5982 zh-CN\u3001en").refine(t=>{try{return Intl.getCanonicalLocales(t)[0]===t}catch{return!1}},"\u6301\u4E45\u5316\u8BED\u8A00\u4EE3\u7801\u5FC5\u987B\u4F7F\u7528\u89C4\u8303\u5199\u6CD5");function pe(t){if(typeof t!="string")return null;try{let n=Intl.getCanonicalLocales(t.trim().replaceAll("_","-"))[0];if(!n)return null;let{language:i,script:r,region:a}=new Intl.Locale(n),o=[i,r,a].filter(Boolean).join("-");return Qe.test(o)?o:null}catch{return null}}var _t=new Set(["TW","HK","MO"]);function Me(t){let[n,i,r]=t.split("-");if(n!=="zh")return`${n}-${new Intl.Locale(t).maximize().script??""}`;let a=i?.length===4?i:void 0,o=i?.length===4?r:i;return a?`zh-${a}`:o&&_t.has(o)?"zh-Hant":"zh-Hans"}function Be(t,n,i){let r=n.map(a=>({code:V.parse(a),normalized:a}));for(let a of t){let o=pe(a);if(!o)continue;let s=r.find(u=>u.normalized===o);if(s)return s.code;let c=Me(o),l=r.filter(u=>Me(u.normalized)===c),d=l.find(u=>!u.normalized.includes("-")||u.normalized===c)??l[0];if(d)return d.code}return i}var zt=4,v={nodes:150,depth:8,children:50,locales:20,actions:40,pages:10,stringLength:2e3,customHtml:32768,customCss:32768,documentBytes:2e5},B=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),y=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),At=e.enum(["none","xs","sm","md","lg","xl"]),vt=e.enum(["none","sm","md","lg","full"]),me=e.string().regex(/^#[0-9a-fA-F]{6}$/),fe=e.string().max(2048).refine(t=>{try{let n=new URL(t);return n.protocol==="https:"&&n.hostname.length>0}catch{return!1}},"\u53EA\u652F\u6301 https \u94FE\u63A5"),de=e.union([fe,e.string().max(32768).regex(/^data:image\/svg\+xml;base64,[A-Za-z0-9+/]+={0,2}$/),e.string().max(131072).regex(/^data:image\/jpeg;base64,\/9j\/[A-Za-z0-9+/]+={0,2}$/),e.string().max(131072).regex(/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]+={0,2}$/)]),Ze=e.object({primary:me,background:me,text:me,radius:vt,font:e.enum(["system","serif","rounded","mono"]),fontAssets:e.object({family:e.string().regex(/^[A-Za-z][A-Za-z0-9 -]{0,39}$/),faces:e.array(e.object({url:fe,weight:e.number().int().min(100).max(900).multipleOf(100),family:e.string().regex(/^[A-Za-z][A-Za-z0-9 -]{0,39}$/).optional()}).strict()).min(1).max(4)}).strict().optional()}).strict(),Z=e.union([e.enum(["primary","text","muted","background","surface"]),e.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)]),g=(t,n)=>e.number().int().min(t).max(n),Ge=e.union([e.enum(["fit","fill"]),g(1,1200)]),Ot=e.object({top:g(0,200),right:g(0,200),bottom:g(0,200),left:g(0,200)}).strict(),Pt=e.object({top:g(-100,200),right:g(-100,200),bottom:g(-100,200),left:g(-100,200)}).strict(),Ke=e.object({x:g(0,100),y:g(0,100)}).strict(),Nt=e.discriminatedUnion("type",[e.object({type:e.literal("color"),color:Z}).strict(),e.object({type:e.literal("linear"),angle:g(0,360),stops:e.array(e.object({color:Z,at:g(0,100)}).strict()).min(2).max(4)}).strict(),e.object({type:e.literal("image"),src:de,fit:e.enum(["cover","contain"]),position:Ke.optional()}).strict()]),$t=e.discriminatedUnion("type",[e.object({type:e.literal("rect"),radius:e.union([g(0,200),e.object({topLeft:g(0,200),topRight:g(0,200),bottomRight:g(0,200),bottomLeft:g(0,200)}).strict()])}).strict(),e.object({type:e.literal("pill")}).strict()]),Ct=e.object({width:g(0,12),color:Z,style:e.enum(["solid","dashed"])}).strict(),Dt=e.object({x:g(-40,40),y:g(-40,40),blur:g(0,80),spread:g(-20,40),color:Z}).strict(),Et=e.object({font:e.enum(["system","serif","rounded","mono"]),size:g(8,96),weight:e.number().int().min(100).max(900).multipleOf(100),lineHeight:e.number().min(.8).max(3),letterSpacing:e.number().min(-5).max(20),color:Z,align:e.enum(["start","center","end"]),italic:e.boolean(),decoration:e.enum(["none","underline","line-through"]),transform:e.enum(["none","uppercase"])}).strict().partial(),U=e.object({width:Ge,height:Ge,padding:Ot,margin:Pt,gap:g(0,120),grow:e.union([e.boolean(),e.number().min(0).max(12)]),background:Nt,opacity:e.number().min(0).max(1),clipContent:e.boolean(),shape:$t,border:Ct,shadow:Dt,text:Et}).strict().partial(),j={id:B,name:e.string().trim().min(1).max(60).optional(),hidden:e.boolean().optional(),style:U.optional(),fallback:y.optional()},Rt=e.object({...j,type:e.literal("text"),productField:e.enum(["name","price","trial","period"]).optional(),feature:e.object({id:e.uuid(),field:e.enum(["name","allowance"])}).strict().optional(),text:y,variant:e.enum(["title","heading","body","caption"])}).strict(),Ut=e.object({...j,type:e.literal("image"),src:de,localizedSrc:e.record(V,de).optional(),alt:y,aspect:e.enum(["auto","1:1","4:3","16:9","3:1"]),fit:e.enum(["cover","contain"]),position:Ke.optional()}).strict(),Lt=e.object({...j,type:e.literal("button"),label:y,variant:e.enum(["primary","secondary","link"]),action:y,purpose:e.enum(["purchase","navigation","close"]).optional(),bind:X.optional()}).strict(),Tt=e.object({...j,type:e.literal("divider")}).strict(),Ft=e.object({...j,type:e.literal("customer_data"),title:y,data:Pe}).strict(),Vt=e.object({...j,type:e.literal("spacer"),size:At}).strict(),qt=e.object({...j,type:e.literal("custom_html"),html:e.record(V,e.string().max(v.customHtml)),css:e.string().max(v.customCss),ui:qe.optional()}).strict(),Mt=e.object({...j,type:e.literal("price"),fallback:y,parts:e.object({current:U.optional(),original:U.optional(),period:U.optional()}).strict().optional()}).strict(),Qt=e.object({...j,type:e.literal("coupon_code"),label:y,fallback:y}).strict(),Bt=e.object({...j,type:e.literal("countdown"),source:e.enum(["offer.ends_at","offer.expires_at","fixed"]),at:e.iso.datetime().optional(),granularity:e.enum(["day","hour","minute","second"]),expired:y,fallback:y}).strict().refine(t=>t.source!=="fixed"||!!t.at,"\u56FA\u5B9A\u5012\u8BA1\u65F6\u9700\u8981\u7ED3\u675F\u65F6\u95F4"),Zt=e.object({...j,type:e.literal("plan_picker"),label:y,fallback:y,planIds:e.array(e.string().min(1).max(200)).min(1).max(20).refine(t=>new Set(t).size===t.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D").optional(),defaultPlan:e.string().min(1).max(200).optional(),grouping:Le.safeExtend({monthLabel:y,yearLabel:y,unavailableLabel:y}).optional(),states:e.object({selected:U.optional()}).strict().optional()}).strict().superRefine((t,n)=>{t.grouping&&(!t.planIds||!Te(t.grouping,t.planIds))&&n.addIssue({code:"custom",message:"Grouped picker assignments must match its product allowlist"})}),Gt=e.object({...j,type:e.literal("quantity_picker"),bind:X.optional(),label:y,fallback:y,internalFeatureId:e.uuid(),minimumQuantity:g(0,1e4),maximumQuantity:g(0,1e4),defaultQuantity:g(0,1e4),step:g(1,1e4)}).strict().refine(t=>t.minimumQuantity<=t.defaultQuantity&&t.defaultQuantity<=t.maximumQuantity&&(t.defaultQuantity-t.minimumQuantity)%t.step===0,"Quantity controls require a Product binding and valid bounds"),Kt=e.discriminatedUnion("type",[e.object({type:e.literal("input"),label:y,keyboard:e.enum(["text","email","tel","url"]),maxLength:g(1,500)}).strict(),e.object({type:e.literal("multiselect"),label:y,min:g(0,50),max:g(1,50)}).strict(),e.object({type:e.literal("select"),label:y,defaultIndex:g(0,49),purpose:e.enum(["option","product","tier"]).optional(),pickerId:B.optional(),selectedStyle:U.optional()}).strict(),e.object({type:e.literal("tabs"),label:y,defaultIndex:g(0,49),purpose:e.literal("tier").optional()}).strict(),e.object({type:e.literal("toggle"),label:y,defaultEnabled:e.boolean()}).strict(),e.object({type:e.literal("carousel"),label:y}).strict()]),A={...j,type:e.literal("stack"),direction:e.enum(["vertical","horizontal","overlay"]),align:e.enum(["start","center","end","stretch"]),justify:e.enum(["start","center","end","between"]),productSlot:e.object({index:g(0,19),period:e.enum(["month","year"]).optional(),requireBinding:e.boolean().optional()}).strict().optional(),interaction:Kt.optional(),states:e.object({selected:U.optional()}).strict().optional(),purpose:e.literal("benefits").optional(),purchaseAction:y.optional(),buttonVariant:e.enum(["primary","secondary","link"]).optional(),bind:X.optional()},He=e.lazy(()=>e.object({...j,type:A.type,direction:A.direction,align:A.align,justify:A.justify,children:e.array(Ht).max(v.children),productSlot:A.productSlot,interaction:A.interaction,states:A.states,purpose:A.purpose,purchaseAction:A.purchaseAction,buttonVariant:A.buttonVariant,bind:A.bind}).strict()),Ht=e.lazy(()=>e.union([He,Rt,Ut,Lt,Tt,Vt,qt,Mt,Qt,Bt,Zt,Gt,Ft])),Wt=e.union([e.string().max(500),e.number().finite(),e.boolean(),e.null()]),Q={id:y,event:y,properties:e.record(y,Wt).refine(t=>Object.keys(t).length<=20,"\u6700\u591A 20 \u4E2A\u53C2\u6570")},Jt=e.discriminatedUnion("type",[e.object({...Q,type:e.literal("navigate"),close:e.literal(!1),pageId:B}).strict(),e.object({...Q,type:e.literal("event"),close:e.boolean()}).strict(),e.object({...Q,type:e.literal("close"),close:e.literal(!0)}).strict(),e.object({...Q,type:e.literal("open_url"),close:e.boolean(),url:fe}).strict(),e.object({...Q,type:e.literal("claim_offer"),close:e.boolean(),couponId:e.uuid()}).strict()]),Xt=e.object({defaultLocale:V,locales:e.record(V,e.record(y,e.string().max(v.stringLength)))}).strict(),Yt=e.enum(["popup","paywall","onboarding","page","banner"]);var en=e.object({kind:e.literal("screen"),schemaVersion:e.literal(zt),name:e.string().trim().min(1).max(80),surface:Yt,initialPageId:B.optional(),presentation:Ce,theme:Ze,pages:e.array(e.object({id:B,name:e.string().trim().min(1).max(60),root:He,theme:Ze.optional(),editorPosition:e.object({x:e.number().finite().min(-1e5).max(1e5),y:e.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict()).min(1).max(v.pages),strings:Xt,actions:e.array(Jt).max(v.actions)}).strict();function P(t,n){for(let i of t.pages)ge(i.root,n)}var xr=en.superRefine((t,n)=>{let i=v;t.surface!=="paywall"&&t.pages.length!==1&&n.addIssue({code:"custom",message:"Only a Paywall can contain multiple screens"}),t.initialPageId&&!t.pages.some(u=>u.id===t.initialPageId)&&n.addIssue({code:"custom",message:"Initial screen does not exist"});for(let u of t.actions)u.type==="navigate"&&(t.surface!=="paywall"||!t.pages.some(b=>b.id===u.pageId))&&n.addIssue({code:"custom",message:"Navigation screen does not exist"});t.pages.length>i.pages&&n.addIssue({code:"custom",message:`\u9875\u9762\u6700\u591A ${i.pages} \u4E2A`}),t.actions.length>i.actions&&n.addIssue({code:"custom",message:`\u52A8\u4F5C\u6700\u591A ${i.actions} \u4E2A`});let r=u=>n.addIssue({code:"custom",message:u}),a=Object.keys(t.strings.locales);a.includes(t.strings.defaultLocale)||r("\u9ED8\u8BA4\u8BED\u8A00\u5FC5\u987B\u5728\u8BED\u8A00\u5217\u8868\u91CC"),a.length>v.locales&&r(`\u6700\u591A ${v.locales} \u79CD\u8BED\u8A00`);let o=new Set;for(let u of t.actions)o.has(u.id)&&r(`\u52A8\u4F5C\u6807\u8BC6\u91CD\u590D\uFF1A${u.id}`),o.add(u.id);let s=new Set;for(let u of t.pages)["next","back"].includes(u.id)&&r(`\u9875\u9762 id \u4E0D\u80FD\u4F7F\u7528\u4FDD\u7559\u540D\u79F0\uFF1A${u.id}`),s.has(u.id)&&r(`\u9875\u9762 id \u91CD\u590D\uFF1A${u.id}`),s.add(u.id);let c=new Set,l=0,d=!1;P(t,(u,b)=>{if(l++,b>v.depth&&(d=!0),c.has(u.id)&&r(`\u7EC4\u4EF6 id \u91CD\u590D\uFF1A${u.id}`),c.add(u.id),u.type==="button"&&!o.has(u.action)&&r(`\u6309\u94AE ${u.id} \u5F15\u7528\u7684\u52A8\u4F5C\u4E0D\u5B58\u5728\uFF1A${u.action}`),u.type==="custom_html")for(let h of Object.keys(u.html))a.includes(h)||r(`\u81EA\u5B9A\u4E49 HTML ${u.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${h}`);if(u.type==="image")for(let h of Object.keys(u.localizedSrc??{}))a.includes(h)||r(`\u56FE\u7247 ${u.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${h}`)}),l>i.nodes&&r(`\u7EC4\u4EF6\u6700\u591A ${i.nodes} \u4E2A`),d&&r(`\u5C42\u7EA7\u6700\u591A ${v.depth} \u5C42`)});function ge(t,n,i=1,r=null){if(n(t,i,r)!==!1&&t.type==="stack")for(let a of t.children)ge(a,n,i+1,t)}function We(t){let n=[],i=new Set;return P(t,r=>{let a=(o,s,c)=>{i.has(o)||(i.add(o),n.push({key:o,nodeId:r.id,nodeType:r.type,field:s,required:c}))};r.type==="stack"&&r.interaction&&a(r.interaction.label,"label",!0),r.fallback&&a(r.fallback,"text",!0),r.type==="text"&&a(r.text,"text",!0),r.type==="customer_data"&&a(r.title,"title",!0),(r.type==="plan_picker"||r.type==="quantity_picker"||r.type==="coupon_code")&&a(r.label,"label",!0),r.type==="plan_picker"&&r.grouping&&(a(r.grouping.monthLabel,"label",!0),a(r.grouping.yearLabel,"label",!0),a(r.grouping.unavailableLabel,"text",!0)),r.type==="countdown"&&a(r.expired,"text",!0),r.type==="button"&&a(r.label,"label",!0),r.type==="image"&&(a(`image:${r.id}`,"src",!1),a(r.alt,"alt",!1)),r.type==="custom_html"&&a(`html:${r.id}`,"html",!0)}),n}function tn(t,n,i){if(n.field==="html"){let r;return P(t,a=>{a.id===n.nodeId&&a.type==="custom_html"&&(r=a.html[i])}),r}if(n.field==="src"){let r=be(t,n.nodeId);return r?.type==="image"?r.localizedSrc?.[i]??(i===t.strings.defaultLocale?r.src:void 0):void 0}return t.strings.locales[i]?.[n.key]}function nn(t){let n=We(t).filter(r=>r.required);return Object.keys(t.strings.locales).sort((r,a)=>r===t.strings.defaultLocale?-1:a===t.strings.defaultLocale?1:0).map(r=>{let a=n.filter(o=>!tn(t,o,r)?.trim()).map(o=>o.key);return{locale:r,total:n.length,filled:n.length-a.length,missing:a,complete:a.length===0}})}function rn(t){return nn(t).filter(n=>n.complete||n.locale===t.strings.defaultLocale).map(n=>n.locale)}function Sr(t,n){return Be(n,rn(t),t.strings.defaultLocale)}function Ir(t,n){let i=t.strings.locales[n]??{},r=t.strings.locales[t.strings.defaultLocale]??{},a={};for(let s of We(t)){if(s.field==="html"||s.field==="src")continue;let c=i[s.key]?.trim()?i[s.key]:r[s.key];c!==void 0&&(a[s.key]=c)}let o=s=>{if(s.type==="stack")return{...s,children:s.children.map(o)};if(s.type==="custom_html"){let c=s.html[n]?.trim()?s.html[n]:s.html[t.strings.defaultLocale];return{...s,html:c===void 0?{}:{[n]:c}}}if(s.type==="image"){let{localizedSrc:c,...l}=s;return{...l,src:c?.[n]??c?.[t.strings.defaultLocale]??s.src}}return s};return{...t,pages:t.pages.map(s=>({...s,root:o(s.root)})),strings:{defaultLocale:n,locales:{[n]:a}}}}function an(t,n){let i=null;return ge(t,r=>{if(i)return!1;r.id===n&&(i=r)}),i}function be(t,n){for(let i of t.pages){let r=an(i.root,n);if(r)return r}return null}function kr(t){let n=pe(t)?.split("-")[0];return n!==void 0&&["ar","he","fa","ur"].includes(n)}function wr(t,n,i){let r={};if(!n||typeof n!="object"||Array.isArray(n))return r;let a=n;if(P(t,o=>{if(o.type==="quantity_picker"){let c=a[o.id];typeof c=="number"&&Number.isSafeInteger(c)&&c>=o.minimumQuantity&&c<=o.maximumQuantity&&(c-o.minimumQuantity)%o.step===0&&(r[o.id]=c);return}if(o.type==="plan_picker"){let c=a[o.id];typeof c=="string"&&(r[o.id]=i?.pickers[o.id]?.options.includes(c)?c:"");return}if(o.type==="custom_html"&&o.ui)for(let[c,l]of Object.entries(o.ui.state??{})){let d=`${o.id}.${c}`,u=a[d];u!==null&&Y(l,u)&&(r[d]=u)}if(o.type!=="stack"||!o.interaction)return;let s=Object.hasOwn(a,o.id)?a[o.id]:void 0;["select","tabs"].includes(o.interaction.type)&&typeof s=="string"&&o.children.some(c=>c.id===s)&&(r[o.id]=s),o.interaction.type==="toggle"&&typeof s=="boolean"&&(r[o.id]=s)}),t.surface==="paywall"&&typeof a.__page=="string"&&t.pages.some(o=>o.id===a.__page)&&(r.__page=a.__page),i){let o={...r};for(let[s,c]of Object.entries(a))(typeof c=="string"||typeof c=="boolean")&&(o[s]=c);Object.assign(r,Re(t,o,i))}return r}var D=e.json().superRefine((t,n)=>{let i=0;function r(a,o){if(++i>1e4||o>20){n.addIssue({code:"custom",message:"JSON exceeds its depth or node budget"});return}if(typeof a=="string"&&(a.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(a))&&n.addIssue({code:"custom",message:"JSON text must contain valid Unicode without NUL"}),Array.isArray(a))a.forEach(s=>r(s,o+1));else if(a&&typeof a=="object")for(let[s,c]of Object.entries(a))(s.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(s)||["__proto__","prototype","constructor"].includes(s))&&n.addIssue({code:"custom",message:"Reserved JSON property"}),r(c,o+1)}r(t,0),new TextEncoder().encode(JSON.stringify(t)).byteLength>65536&&n.addIssue({code:"custom",message:"JSON exceeds 64 KiB"})}),he=e.record(e.string().min(1).max(128),D).superRefine((t,n)=>{(!D.safeParse(t).success||Object.keys(t).length>128||new TextEncoder().encode(JSON.stringify(t)).byteLength>65536||["__proto__","constructor","prototype"].some(i=>Object.hasOwn(t,i)))&&n.addIssue({code:"custom",message:"Attribute document exceeds its budget or uses a reserved key"})}),on=new Set(["$in","$ini","$inGroup","$nin","$nini","$notInGroup","$gt","$gte","$lt","$lte","$regex","$regexi","$ne","$eq","$size","$elemMatch","$all","$alli","$not","$type","$exists","$vgt","$vgte","$vlt","$vlte","$vne","$veq","$and","$or","$nor","$savedGroup"]),ee=he.superRefine((t,n)=>{function i(r){if(Array.isArray(r))r.forEach(i);else if(r&&typeof r=="object")for(let[a,o]of Object.entries(r)){if(a==="$savedGroup"&&!e.strictObject({id:e.uuid(),attributeKey:e.string().min(1).max(128).optional()}).safeParse(o).success&&n.addIssue({code:"custom",message:"Saved groups use v2 object references"}),!a.startsWith("$")&&a.split(".").some(s=>["__proto__","prototype","constructor"].includes(s))&&n.addIssue({code:"custom",message:"Reserved attribute path"}),a.startsWith("$")&&!on.has(a)&&n.addIssue({code:"custom",message:`Unknown GrowthBook operator: ${a}`}),["$regex","$regexi"].includes(a)&&typeof o=="string"){(/\(\?[<!=]|\\[0-9]|\\k</.test(o)||[...o.matchAll(/\{(\d+)(?:,(\d*))?\}/g)].some(s=>Number(s[1])>255||Number(s[2]||0)>255)||a==="$regexi"&&/[^\x00-\x7f]/.test(o.replace(/\\u([0-9a-f]{4})/gi,(s,c)=>String.fromCharCode(Number.parseInt(c,16)))))&&n.addIssue({code:"custom",message:"Regex is outside the shared TS/SQL subset"});try{new RegExp(o)}catch{n.addIssue({code:"custom",message:"Invalid regular expression"})}}i(o)}}typeof t.source=="string"&&["all","any","group","parameter","answer","attribute","result"].includes(t.source)&&("operator"in t||"predicates"in t||"groupId"in t)&&n.addIssue({code:"custom",message:"Obsolete condition protocol"}),i(t)}),sn=e.discriminatedUnion("type",[e.strictObject({type:e.literal("condition"),condition:ee}),e.strictObject({type:e.literal("list"),attributeKey:e.string().min(1).max(128),values:e.array(e.union([e.string(),e.number().finite()])).max(1e5)})]).refine(t=>t.type!=="list"||new TextEncoder().encode(JSON.stringify(t.values)).byteLength<=1048576,"Saved group list exceeds 1 MiB");function cn(t){let n=new Set;function i(r){if(Array.isArray(r))r.forEach(i);else if(r&&typeof r=="object")for(let[a,o]of Object.entries(r))a==="$savedGroup"&&o&&typeof o=="object"&&!Array.isArray(o)&&typeof o.id=="string"?n.add(o.id):["$inGroup","$notInGroup"].includes(a)&&typeof o=="string"?n.add(o):["$eq","$ne","$in","$nin","$ini","$nini"].includes(a)||i(o)}return i(t),[...n]}var un=e.record(e.uuid(),sn).superRefine((t,n)=>{let i=new Set,r=new Set;function a(o){if(i.has(o)){n.addIssue({code:"custom",message:"Cyclic saved group dependency"});return}if(r.has(o))return;let s=t[o];if(!s){n.addIssue({code:"custom",message:"Missing saved group dependency"});return}i.add(o),s.type==="condition"&&cn(s.condition).forEach(a),i.delete(o),r.add(o)}Object.keys(t).forEach(a)}),xe=e.tuple([e.number().min(0).max(1),e.number().min(0).max(1)]).refine(([t,n])=>t<=n),Je=e.strictObject({attribute:e.string().optional(),seed:e.string().min(1),hashVersion:e.literal(2),ranges:e.array(xe).min(1).max(100)}),ln=e.strictObject({id:e.string().min(1).max(128),condition:ee,gate:e.boolean().optional()}),ye={id:e.string().max(128).optional(),condition:ee.optional(),parentConditions:e.array(ln).max(50).optional(),filters:e.array(Je).max(20).optional()},pn=e.union([e.strictObject({...ye}),e.strictObject({...ye,force:D,coverage:e.number().min(0).max(1).optional(),range:xe.optional(),seed:e.string().min(1).optional(),hashAttribute:e.string().optional(),hashVersion:e.literal(2).optional()}),e.strictObject({...ye,type:e.literal("experiment-ref"),experimentId:e.uuid(),values:e.record(e.string().min(1),D),meta:e.record(e.string().min(1),e.strictObject({passthrough:e.boolean()})).optional()})]),mn=e.strictObject({defaultValue:D,rules:e.array(pn).max(100)}),$r=e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),mn).superRefine((t,n)=>{Object.keys(t).length>100&&n.addIssue({code:"custom",message:"Too many Features"});let i=new Set,r=new Set;function a(o){if(i.has(o)){n.addIssue({code:"custom",message:`Cyclic Feature dependency: ${o}`});return}if(r.has(o))return;let s=t[o];if(!s){n.addIssue({code:"custom",message:`Unknown prerequisite Feature: ${o}`});return}i.add(o);for(let c of s.rules)for(let l of c.parentConditions??[])a(l.id);i.delete(o),r.add(o)}Object.keys(t).forEach(a)}),dn=e.strictObject({name:e.string().max(80),reason:e.string().max(500),dateStarted:e.iso.datetime({offset:!0}),dateEnded:e.iso.datetime({offset:!0}).nullable(),coverage:e.number().min(0).max(1),variationWeights:e.array(e.number().min(0).max(1)).min(2).max(20).refine(t=>Math.abs(t.reduce((n,i)=>n+i,0)-1)<=.01),condition:ee,savedGroups:e.array(e.strictObject({match:e.enum(["any","all","none"]),ids:e.array(e.uuid()).min(1)})).max(50),namespace:e.strictObject({id:e.uuid(),ranges:e.array(xe).min(1)}).nullable(),seed:e.string().min(1).max(128)}),fn=e.strictObject({key:e.string().min(1).max(128),name:e.string().min(1).max(80),hypothesis:e.string().max(2e3),status:e.enum(["draft","running","stopped"]),hashAttribute:e.string().min(1).max(128),fallbackAttribute:e.string().max(128).nullable(),hashVersion:e.literal(2),disableStickyBucketing:e.boolean(),bucketVersion:e.number().int().min(0).max(1e3),minBucketVersion:e.number().int().min(0).max(1e3),variations:e.array(e.strictObject({id:e.string().min(1),key:e.string().min(1),name:e.string().max(80),description:e.string().max(500)})).min(2).max(20),phases:e.array(dn).min(1).max(100),releasedVariationId:e.string().nullable(),excludeFromPayload:e.boolean(),statusSchedule:e.strictObject({startAt:e.iso.datetime({offset:!0}).nullable(),stopAt:e.iso.datetime({offset:!0}).nullable(),stopAfter:e.strictObject({value:e.number().int().positive().max(36500),unit:e.enum(["hours","days"])}).nullable().optional()}).nullable()}).superRefine((t,n)=>{(t.minBucketVersion>t.bucketVersion||t.statusSchedule?.stopAt&&t.statusSchedule?.stopAfter||t.phases.some((i,r)=>{if(r===0)return!1;let a=t.phases[r-1];return!a?.dateEnded||Date.parse(i.dateStarted)<Date.parse(a.dateStarted)||Date.parse(a.dateEnded)>Date.parse(i.dateStarted)})||new Set(t.variations.map(i=>i.key)).size!==t.variations.length||new Set(t.variations.map(i=>i.id)).size!==t.variations.length||t.releasedVariationId!==null&&!t.variations.some(i=>i.id===t.releasedVariationId)||t.statusSchedule?.startAt&&t.statusSchedule?.stopAt&&Date.parse(t.statusSchedule.startAt)>=Date.parse(t.statusSchedule.stopAt)||t.phases.some(i=>i.dateEnded&&Date.parse(i.dateStarted)>=Date.parse(i.dateEnded)||i.namespace?.ranges.some(([r,a],o,s)=>r>=a||s.some(([c,l],d)=>d!==o&&r<l&&c<a)))||t.phases.some(i=>i.variationWeights.length!==t.variations.length))&&n.addIssue({code:"custom",message:"Invalid experiment versions, variation keys or weights"})});var gn=fn.safeExtend({filters:e.array(Je).optional()}),bn=e.strictObject({experiments:e.record(e.uuid(),gn),savedGroups:un}),yn=e.strictObject({attributeName:e.string(),attributeValue:e.string(),assignments:e.record(e.string(),e.string())}),Cr=e.strictObject({snapshot:bn,attributes:he,results:he,stickyBucketAssignmentDocs:e.record(e.string(),yn)}),Dr=e.strictObject({variantKey:e.string().nullable(),bucketVersion:e.number().int().min(0),source:e.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),bucket:e.number().min(0).max(1).optional(),stickyBucketUsed:e.boolean().optional(),hashUsed:e.boolean().optional()});var L=k.refine(t=>/[1-9]/.test(t),"Quantity must be positive"),G=e.string().min(1).max(120),te=e.enum(["cap","overflow"]),_=(t,n)=>{let[i,r=""]=t.split(".");if(i===void 0||i==="")throw new Error("Invalid decimal value");return BigInt(i)*10n**BigInt(n)+BigInt(r.padEnd(n,"0"))},K=t=>{try{return t()}catch{return!1}},Lr=e.discriminatedUnion("operation",[e.object({operation:e.literal("quote"),overageBehavior:te.optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:L,properties:$}).strict(),e.object({operation:e.literal("consume"),overageBehavior:te.optional(),occurredAt:e.iso.datetime({offset:!0}).optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:k,properties:$,idempotencyKey:G}).strict(),e.object({operation:e.literal("reserve"),occurredAt:e.iso.datetime({offset:!0}).optional(),internal_feature_id:e.uuid(),entityId:e.uuid().optional(),quantity:L,properties:$,idempotencyKey:G,expiresInSeconds:e.number().int().min(1).max(86400)}).strict(),e.object({operation:e.literal("confirm"),operationId:e.uuid(),quantity:L,properties:$.optional(),idempotencyKey:G}).strict(),e.object({operation:e.literal("refund"),operationId:e.uuid(),quantity:L,idempotencyKey:G}).strict(),e.object({operation:e.literal("release"),operationId:e.uuid(),idempotencyKey:G}).strict()]),hn=e.object({internal_credit_feature_id:e.uuid().nullable(),internal_metered_feature_id:e.uuid(),dimension:e.string().min(1).max(64),counterKey:e.string().min(1).max(240),cycleStart:e.iso.datetime({offset:!0}),unitCost:k,units:L,amount:J,tier:e.number().int().min(1).max(12).nullable()}).strict(),H=e.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/);function Xe(t,n){let i=t.reduce((r,a)=>r+_(a.units,12),0n)-_(n,12);return t.some(r=>r.funding==="balance")?i>=-100n&&i<=100n:i===0n}var Ye=e.discriminatedUnion("funding",[e.strictObject({funding:e.literal("balance"),sourceId:e.uuid(),rolloverId:e.uuid().nullable(),units:H.refine(t=>/[1-9]/.test(t)),amount:J}),e.strictObject({funding:e.literal("unbilled"),units:H.refine(t=>/[1-9]/.test(t))}),e.object({funding:e.literal("prepaid"),sourceId:e.uuid(),units:L,amount:J,pricing:e.array(hn).min(1).max(12)}).strict().refine(t=>K(()=>t.pricing.reduce((n,i)=>n+_(i.units,6),0n)===_(t.units,6)&&t.pricing.reduce((n,i)=>n+_(i.amount,12),0n)===_(t.amount,12)&&t.pricing.every(n=>_(n.unitCost,6)*_(n.units,6)===_(n.amount,12))),"Frozen pricing must conserve allocated units and amounts"),e.object({funding:e.literal("postpaid"),invoiceLineId:e.uuid().nullable(),units:L,authorizationId:e.uuid()}).strict()]),ne=e.enum(["unavailable","insufficient_balance","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded"]),Tr=e.object({allowed:e.boolean(),internal_feature_id:e.uuid(),quantity:k,requestedQuantity:k.optional(),overageBehavior:te.optional(),reason:ne.nullable(),allocations:e.array(Ye).max(500)}).strict().refine(t=>K(()=>t.allowed?t.reason===null&&Xe(t.allocations,t.quantity):t.reason!==null&&t.allocations.length===0),"A quote must conserve its accepted units").refine(t=>K(()=>t.overageBehavior===void 0?t.requestedQuantity===void 0&&/[1-9]/.test(t.quantity):t.requestedQuantity!==void 0&&_(t.requestedQuantity,6)>=_(t.quantity,6)&&(t.overageBehavior==="cap"||t.requestedQuantity===t.quantity)),"Explicit overage behavior must retain the requested quantity"),Fr=e.object({id:e.uuid(),internal_feature_id:e.uuid(),kind:e.enum(["consume","reserve","confirm","refund","release","expire"]),originalId:e.uuid().nullable(),quantity:k,requestedQuantity:k.optional(),overageBehavior:te.optional(),accepted:e.boolean(),reason:e.enum([...ne.options,"expired"]).nullable(),createdAt:e.iso.datetime({offset:!0}),reservationStatus:e.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:e.iso.datetime({offset:!0}).nullable(),allocations:e.array(Ye).max(500)}).strict().refine(t=>K(()=>t.accepted?t.reason===null&&Xe(t.allocations,t.quantity):t.reason!==null&&t.allocations.length===0),"An operation must conserve its requested units").refine(t=>K(()=>t.overageBehavior===void 0?t.requestedQuantity===void 0:t.kind==="consume"&&t.requestedQuantity!==void 0&&_(t.requestedQuantity,6)>=_(t.quantity,6)&&(t.overageBehavior==="cap"||t.requestedQuantity===t.quantity)),"Overage metadata belongs to consumption and preserves requested units").refine(t=>/[1-9]/.test(t.quantity)||t.kind==="consume","Only consumption can record a zero cost event").refine(t=>t.allocations.every(n=>n.funding!=="postpaid"||n.invoiceLineId!==null),"Accepted operations must reference persisted invoice lines").refine(t=>t.originalId!==null===["confirm","refund","release","expire"].includes(t.kind)&&t.expiresAt!==null==(t.reservationStatus!==null)&&(t.kind!=="reserve"||!t.accepted||t.reservationStatus!==null),"Operation provenance and reservation state must be explicit");var xn=e.string().max(40).regex(/^(0|[1-9]\d*)(\.\d{1,12})?$/),Sn=e.string().max(41).regex(/^-?(0|[1-9]\d*)(\.\d{1,12})?$/),et=e.strictObject({internal_feature_id:e.uuid(),entityId:e.uuid().nullable()}),Qr=et.extend({quantity:k,expectedRevision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),idempotencyKey:e.string().min(1).max(120),properties:$.refine(t=>Object.keys(t).length<=13&&!Object.keys(t).some(n=>n.startsWith("usage_")),"Usage accounting reserves three properties")}).strict(),tt=et.extend({operationId:e.uuid().nullable(),usage:k,capacity:xn.nullable(),remaining:Sn.nullable(),withinLimit:e.boolean(),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:e.iso.datetime({offset:!0}).nullable()}).strict().superRefine((t,n)=>{let i=r=>{let a=r.startsWith("-"),[o,s=""]=(a?r.slice(1):r).split(".");if(o===void 0||o==="")throw new Error("Invalid decimal value");return(a?-1n:1n)*(BigInt(o)*10n**12n+BigInt(s.padEnd(12,"0")))};(t.capacity===null!=(t.remaining===null)||(t.capacity===null?!t.withinLimit:t.remaining===null||i(t.remaining)!==i(t.capacity)-i(t.usage)||t.withinLimit!==i(t.remaining)>=0n)||t.revision===0!=(t.operationId===null)||t.operationId===null!=(t.updatedAt===null))&&n.addIssue({code:"custom",message:"Absolute usage must conserve capacity and its immutable revision"})});var N=e.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/),O=e.iso.datetime({offset:!0}),In=e.enum(["access","metered","credit"]),W={internal_feature_id:e.uuid(),key:T,name:e.string().min(1).max(120),kind:In},Jr=e.object({customerId:e.uuid(),snapshotAt:O,memberships:e.array(e.object({id:e.uuid(),productId:e.string().min(1).max(255),productVersionId:e.uuid(),billingProductVersionId:e.uuid(),version:e.number().int().positive(),key:e.string().min(1).max(64),name:e.string().min(1).max(120),groupId:e.string().max(255).nullable(),membershipType:e.enum(["main","addon"]),status:e.enum(["trial","active","past_due","ended","expired","trialing","paused","pending","scheduled","unknown"]),cancelAtPeriodEnd:e.boolean(),accessEnabled:e.boolean(),renewalChange:e.object({productVersionId:e.uuid(),name:e.string().min(1).max(120),version:e.number().int().positive(),effectiveAt:O,benefitsAppliedAt:O.nullable(),timing:e.enum(["immediate","renewal"]),changeKind:e.enum(["plan","seats","quantity"]),feature:e.strictObject({internal_feature_id:e.uuid(),name:e.string().min(1).max(80),fromQuantity:e.number().int().min(0).max(1e4),toQuantity:e.number().int().min(0).max(1e4)}).optional(),seat:e.object({key:e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),fromQuantity:e.number().int().min(0).max(1e4),toQuantity:e.number().int().min(0).max(1e4)}).strict().nullable(),status:e.enum(["prepared","quoted","confirmed","pending","scheduled"])}).strict().refine(t=>t.changeKind==="seats"==(t.seat!==null)&&t.changeKind==="quantity"==(t.feature!==void 0),"Quantity changes require their fixed component identities and quantities").nullable(),period:e.object({phase:e.enum(["paid","trial"]),startsAt:O,endsAt:O.nullable()}).strict().nullable()}).strict()).max(100),membershipsLimited:e.boolean(),balances:e.array(e.object({...W,usageType:e.enum(["consumable","non_consumable"]).nullable(),accessible:e.boolean(),unlimited:e.boolean(),available:N,held:N,debt:N,nextExpiresAt:O.nullable(),usage:tt.nullable()}).strict().refine(t=>t.kind==="metered"==(t.usageType!==null)&&(t.accessible||t.available==="0"&&t.held==="0")&&(t.usageType==="non_consumable"?t.usage!==null&&t.usage.internal_feature_id===t.internal_feature_id&&t.unlimited===(t.usage.capacity===null)&&t.available===(t.usage.remaining===null||t.usage.remaining.startsWith("-")?"0":t.usage.remaining)&&t.held==="0"&&t.debt==="0":t.usage===null),"Balances must expose their actual spendable or non-consumable state")).max(500),balancesLimited:e.boolean()}).strict(),nt=e.enum(["source","usage","transaction","invoice","debt","settlement"]),re=e.object({at:O,id:e.uuid(),type:nt}).strict(),Xr=e.object({type:nt.nullable(),resourceKey:T.optional(),kind:e.enum(["purchase","refund"]).optional(),topup:e.boolean().optional(),from:e.iso.date().nullable(),to:e.iso.date().nullable(),after:re.nullable(),limit:e.number().int().min(1).max(50)}).strict().refine(t=>!t.from||!t.to||t.from<=t.to,"Date range is reversed"),q={id:e.uuid(),occurredAt:O},kn=e.discriminatedUnion("type",[e.strictObject({...q,type:e.literal("invoice"),status:e.string().min(1).max(80),paid:N,refunded:N,currency:C,externalId:e.string().nullable()}),e.object({...q,...W,type:e.literal("source"),reason:e.enum(["membership","trial","topup","manual","rollover","upgrade_carry","seat"]),quantity:N,unlimited:e.boolean(),status:e.enum(["scheduled","active","expired","revoked","unavailable"]),startsAt:O,expiresAt:O.nullable(),orderId:e.uuid().nullable(),parentSourceId:e.uuid().nullable()}).strict(),e.object({...q,type:e.literal("usage"),internal_feature_id:e.uuid(),name:e.string().min(1).max(120),kind:e.enum(["consume","set_usage","reserve","confirm","refund","release","expire"]),originalId:e.uuid().nullable(),quantity:k,accepted:e.boolean(),reason:e.enum([...ne.options,"expired"]).nullable(),properties:$,reservationStatus:e.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:O.nullable(),charges:e.array(e.discriminatedUnion("funding",[e.strictObject({funding:e.literal("balance"),sourceId:e.uuid(),rolloverId:e.uuid().nullable(),units:H,amount:N}),e.strictObject({funding:e.literal("unbilled"),units:H}),e.object({...W,funding:e.literal("prepaid"),amount:N}).strict(),e.object({funding:e.literal("postpaid"),invoiceId:e.uuid(),invoiceLineId:e.uuid(),authorizationId:e.uuid(),units:k,currency:C}).strict()])).max(500)}).strict().refine(t=>(t.kind==="set_usage"||t.kind==="consume"&&t.quantity==="0"?t.accepted&&t.reason===null&&t.charges.length===0&&t.reservationStatus===null:t.accepted?t.reason===null&&t.charges.length>0:t.reason!==null&&t.charges.length===0)&&t.originalId!==null===["confirm","refund","release","expire"].includes(t.kind)&&t.expiresAt!==null==(t.reservationStatus!==null),"Usage facts must retain their original outcome and receipt"),e.object({...q,type:e.literal("transaction"),purpose:e.enum(["product","invoice"]),productVersionId:e.uuid().nullable(),productName:e.string().min(1).max(120).nullable(),productVersion:e.number().int().positive().nullable(),invoiceId:e.uuid().nullable(),orderId:e.uuid(),originalId:e.uuid().nullable(),kind:e.enum(["purchase","refund"]),amountMinor:e.number().int().nonnegative().max(2e8).nullable(),currency:C.nullable()}).strict().refine(t=>t.currency===null==(t.amountMinor===null)&&(t.purpose==="product"?t.productVersionId!==null&&t.productName!==null&&t.productVersion!==null&&t.invoiceId===null:t.productVersionId===null&&t.productName===null&&t.productVersion===null&&t.invoiceId!==null)&&t.kind==="refund"==(t.originalId!==null)&&(t.kind!=="refund"||t.amountMinor===null||t.amountMinor>0),"Payment fact provenance is incomplete"),e.object({...q,...W,type:e.literal("debt"),sourceId:e.uuid(),transactionId:e.uuid(),amount:N}).strict(),e.object({...q,...W,type:e.literal("settlement"),sourceId:e.uuid(),debtId:e.uuid(),kind:e.enum(["payment","usage_refund","payment_return"]),amount:N}).strict()]),Yr=e.object({customerId:e.uuid(),rows:e.array(kn).max(50),nextCursor:re.nullable()}).strict().refine(t=>new Set(t.rows.map(n=>n.type+n.id)).size===t.rows.length,"A page cannot repeat a fact").refine(t=>{let n=t.rows.at(-1);return!t.nextCursor||!!(n&&n.id===t.nextCursor.id&&n.type===t.nextCursor.type&&n.occurredAt===t.nextCursor.at)},"Cursor must name the final displayed fact");var ii=e.discriminatedUnion("kind",[e.object({kind:e.literal("ledger"),cursor:re}).strict(),e.object({kind:e.literal("billing"),cursor:e.uuid()}).strict()]),wn=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),jn=e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),e.union([e.string().max(500),e.boolean(),e.array(e.string().max(500)).max(50)])).refine(t=>Object.keys(t).length<=40,"Too many answers"),_n=/^(?:api_?key|authorization|password|(?:customer|run|visitor|access|purchase)_?token|client_?secret|signed_?transaction|raw_?proof)$/i;function Se(t,n=0){return n>20?!0:!!t&&typeof t=="object"&&(Array.isArray(t)?t.some(i=>Se(i,n+1)):Object.entries(t).some(([i,r])=>["__proto__","constructor","prototype"].includes(i)||_n.test(i)||Se(r,n+1)))}var zn=/gg_(?:sk|ct|fr|fv|gc)_[A-Za-z0-9_-]{20,}/,ai=e.record(wn,D).refine(t=>Object.keys(t).length<=20,"Too many parameters").refine(t=>!Se(t)&&!zn.test(JSON.stringify(t)),"Credentials cannot be screen parameters");var rt=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),An=e.array(e.object({variable:rt,componentId:rt,required:e.boolean()}).strict()).max(40).refine(t=>new Set(t.map(n=>n.variable)).size===t.length&&new Set(t.map(n=>n.componentId)).size===t.length,"Input bindings must be unique"),oi=e.object({bindings:An,answers:jn,values:e.record(e.string(),D).optional()}).strict();function it(t,n,i=1){if(t==="free")return"";if(t==="one_time")return n.startsWith("zh")?" \xB7 \u4E00\u6B21\u4ED8\u6B3E":" \xB7 one-time";let r=n.split("-")[0]??"en",a={zh:["/\u6708","/\u5E74"],en:["/month","/year"],ja:["/\u6708","/\u5E74"],ko:["/\uC6D4","/\uB144"],es:["/mes","/a\xF1o"],fr:["/mois","/an"],de:["/Monat","/Jahr"],pt:["/m\xEAs","/ano"],it:["/mese","/anno"],ar:["/\u0634\u0647\u0631","/\u0633\u0646\u0629"]},o={zh:"\u5468",en:"week",ja:"\u9031",ko:"\uC8FC",es:"semana",fr:"semaine",de:"Woche",pt:"semana",it:"settimana",ar:"\u0623\u0633\u0628\u0648\u0639"},s=t==="week"?`/${o[r]??o.en}`:(a[r]??a.en)[t==="month"?0:1];return i===1?s:`/${i} ${s.slice(1)}${r==="en"?"s":""}`}function fi(t,n){let i=[],r={};P(t,a=>{if(a.hidden)return!1;if(a.type!=="quantity_picker")return;let o=a.bind?.plan?[a.bind.plan]:[];a.bind?.picker&&P(t,s=>{if(s.type==="plan_picker"&&s.id===a.bind?.picker&&o.push(...s.planIds??[]),s.type==="stack"&&s.interaction?.type==="select"&&s.interaction.pickerId===a.bind?.picker)for(let c of s.children)c.type==="stack"&&c.bind?.plan&&o.push(c.bind.plan)}),o.length||i.push(`Quantity control ${a.id} needs a Product binding`);for(let s of new Set(o)){let c=n[s]?.prepaid?.find(d=>d.internalFeatureId===a.internalFeatureId)?.terms,l=r[s]??=new Set;(!c||l.has(a.internalFeatureId)||a.minimumQuantity<c.minimumQuantity||a.maximumQuantity>c.maximumQuantity)&&i.push(`Quantity control ${a.id} must match its Product's prepaid Feature and bounds`),l.add(a.internalFeatureId)}});for(let[a,o]of Object.entries(n))for(let s of o.prepaid??[])r[a]?.has(s.internalFeatureId)||i.push(`Product ${a} needs a quantity control for ${s.internalFeatureId}`);return i}function gi(t,n,i,r){let a=r.plans[n];if(!a?.available)throw new Error("Selected Product is unavailable");let o={};if(P(t,s=>{if(s.hidden)return!1;if(s.type!=="quantity_picker"||s.hidden||(s.bind?.plan??(s.bind?.picker?i[s.bind.picker]:void 0))!==n)return;let l=a.prepaid?.find(u=>u.internalFeatureId===s.internalFeatureId)?.terms,d=i[s.id];if(!l||typeof d!="number"||!Number.isSafeInteger(d)||d<Math.max(l.minimumQuantity,s.minimumQuantity)||d>Math.min(l.maximumQuantity,s.maximumQuantity)||(d-s.minimumQuantity)%s.step!==0||o[s.internalFeatureId]!==void 0)throw new Error("Choose a valid quantity for each prepaid Feature");o[s.internalFeatureId]=d}),(a.prepaid??[]).some(s=>o[s.internalFeatureId]===void 0))throw new Error("Choose a quantity for each prepaid Feature");return o}function vn(t,n,i){let r=t.terms.prices.find(a=>a.currency===n);if(!r||i<t.terms.minimumQuantity||i>t.terms.maximumQuantity)throw new Error("Quantity or currency is unavailable");return{amountMinor:we({quantity:i,unitAmountMinor:r.amountMinor,...r.pricing?{pricing:r.pricing}:{}}),allowance:ze(t.includedAmount,t.terms.units,i)}}function bi(t,n,i,r){let a=!1;if(P(t,c=>{c.type==="quantity_picker"&&(a=!0)}),!a)return n;let o=structuredClone(n);o.quantities={};let s=new Map;P(t,c=>{if(c.hidden)return!1;if(c.type!=="quantity_picker")return;let l=c.bind?.plan??(c.bind?.picker?i[c.bind.picker]??o.pickers[c.bind.picker]?.selected:void 0),d=typeof l=="string"?o.plans[l]:void 0,u=d?.prepaid?.find(at=>at.internalFeatureId===c.internalFeatureId),b=Math.max(c.minimumQuantity,u?.terms.minimumQuantity??0),h=Math.min(c.maximumQuantity,u?.terms.maximumQuantity??0),m=i[c.id]??c.defaultQuantity,p=typeof m=="number"&&Number.isSafeInteger(m)?m:c.defaultQuantity,f=!!u&&!!d?.available&&p>=b&&p<=h&&(p-c.minimumQuantity)%c.step===0,w=o.quantities[c.id]={minimum:b,maximum:Math.max(b,h),step:c.step,value:p,label:"",available:f};if(!f||!u||!d?.currency||d.amountMinor===void 0)return;let M=vn(u,d.currency,p);w.label=`${new Intl.NumberFormat(r).format(Number(M.allowance))} ${u.name}${["week","month","year"].includes(u.reset)?it(u.reset,r,u.resetCount):u.reset==="lifetime"?"":` / ${u.resetCount} ${u.reset}`}`,M.amountMinor!==0&&s.set(String(l),(s.get(String(l))??d.amountMinor)+M.amountMinor)});for(let[c,l]of s){let d=o.plans[c];if(!d?.currency)continue;let u=ie(l,d.currency,r);d.price=u;for(let[b,h]of Object.entries(o.nodes)){let m=be(t,b),p=f=>{if(f.price&&(f.price={...f.price,current:u,original:null}),m?.type==="text"){let w=t.strings.locales[r]?.[m.text]??t.strings.locales[t.strings.defaultLocale]?.[m.text];w?.includes("{{plan.price")&&(f.text=w.replace(/\{\{\s*plan.price\s*\}\}/g,u).replace(/\{\{\s*plan.price_per_month\s*\}\}/g,ie(Math.round(l/((d.interval==="year"?12:1)*(d.intervalCount??1))),d.currency,r)))}};h.byPlan?.[c]&&p(h.byPlan[c]),(h.base.planVersionId===c||m&&"bind"in m&&m.bind?.plan===c)&&p(h.base)}}return o}export{ae as a,we as b,_e as c,ze as d,se as e,Ae as f,Mn as g,ve as h,Qn as i,Ee as j,Le as k,Te as l,Kn as m,Hn as n,ir as o,Xn as p,Ce as q,dt as r,V as s,pe as t,v as u,B as v,y as w,de as x,P as y,xr as z,ge as A,We as B,nn as C,Sr as D,Ir as E,be as F,kr as G,wr as H,D as I,he as J,ee as K,cn as L,yn as M,Lr as N,hn as O,H as P,Tr as Q,Fr as R,et as S,Qr as T,tt as U,N as V,Jr as W,Xr as X,Yr as Y,ii as Z,jn as _,ai as $,An as aa,oi as ba,it as ca,fi as da,gi as ea,bi as fa};
@@ -1 +0,0 @@
1
- import{a as s,b as o,c as u}from"./chunk-LSPHUA7V.js";import{d as m,g as p}from"./chunk-OOD2VDDP.js";import{b as e}from"./chunk-RGEBK6UF.js";var f=["USD","EUR","CNY","GBP","JPY","CAD","AUD","NZD","CHF","HKD","SGD","KRW","INR","BRL","MXN","TWD","THB","IDR","MYR","PHP","VND","ZAR","AED","SAR","SEK","NOK","DKK","PLN","CZK","HUF","ILS","TRY","RON"],i=e.enum(f);function x(t){let r=i.parse(t.toUpperCase());return["JPY","KRW","VND"].includes(r)?0:2}function I(t,r,n="en",y={}){let a=i.parse(r.toUpperCase());return new Intl.NumberFormat(n,{style:"currency",currency:a,...y}).format(t/10**x(a))}var d=e.enum(["stripe","apple","google","merchant"]),_=e.enum(["membership","credit_pack","lifetime"]),v=e.enum(["active","grace","suspended","inactive","revoked"]),z=e.strictObject({currency:e.string().regex(/^[A-Z]{3}$/),micros:e.string().regex(/^(0|[1-9][0-9]{0,29})$/)});var l=e.object({provider:d,currency:i}).strict();var c=e.strictObject({internal_feature_id:e.uuid(),quantity:m.refine(t=>/[1-9]/.test(t)),properties:p,entityId:e.uuid().optional()}),B=e.strictObject({requirement:c,commerce:l.optional(),paywallId:e.uuid().optional()}),g=e.enum(["not_entitled","insufficient_balance","capacity_exceeded","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded","unavailable","authentication_required"]),S=e.strictObject({productId:e.string().min(1),productVersionId:e.string().min(1),name:e.string().min(1).max(120),action:e.enum(["purchase","upgrade","addon","topup"]),membershipId:e.string().min(1).nullable(),currency:i,amountMinor:e.string().regex(/^(0|[1-9]\d{0,8})$/),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(156)}),h=e.strictObject({subject:o,authority:e.enum(["longplay","merchant"]),observedAt:e.iso.datetime({offset:!0}),sourceRevision:e.string().min(1).max(128),requirementDigest:s});function b(t,r){return u({subject:o.parse(t),requirement:c.parse(r)})}var C=e.strictObject({internal_feature_id:e.string().min(1),name:e.string().min(1).max(120),kind:e.enum(["access","metered","credit"]),quantity:m,allowed:e.boolean(),observation:h.optional(),reason:g.nullable(),preview:e.strictObject({scenario:e.enum(["feature_flag","usage_limit"]),candidates:e.array(S).max(20)}).nullable()}).superRefine((t,r)=>{(t.allowed!==(t.reason===null)||t.allowed&&t.preview!==null||new Set(t.preview?.candidates.map(n=>n.productVersionId)).size!==(t.preview?.candidates.length??0)||t.preview?.candidates.some(n=>n.action==="upgrade"!=(n.membershipId!==null)))&&r.addIssue({code:"custom",message:"Invalid access recommendation"})}),T=e.strictObject({paywallId:e.uuid(),requirement:c}),U=e.strictObject({subject:o,requirement:c}),$=C.safeExtend({observation:h.extend({authority:e.literal("merchant")})});function F(t,r){let n=c.parse(t);return r.internal_feature_id===n.internal_feature_id&&r.quantity===n.quantity&&(!r.observation||r.observation.requirementDigest===b(r.observation.subject,n))}export{i as a,x as b,I as c,_ as d,l as e,c as f,B as g,S as h,b as i,C as j,U as k,$ as l,F as m};
@@ -1 +0,0 @@
1
- import{i as ie}from"./chunk-BYP4KVB3.js";import{a as Z,c as ee,e as te,f as ne,h as N,j as re,k as oe,l as se}from"./chunk-P6C3PNMQ.js";import{b as X}from"./chunk-YLPQLD2A.js";import{r as V}from"./chunk-P23JOPR5.js";import"./chunk-IOJVF52Q.js";import"./chunk-U7GH4VME.js";import"./chunk-33ZVZOSC.js";import"./chunk-PZOQV6MU.js";import"./chunk-FCDWCQYC.js";import{$ as Y,D as G,I as R,aa as K,r as $}from"./chunk-XDOKFAE6.js";import"./chunk-Y6HL2IY2.js";import"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import{a as p}from"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-RV6UAUK2.js";import{b as u}from"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var z=new WeakMap;function ce(s){let t={string:u.string(),number:u.number().finite(),boolean:u.boolean(),strings:u.array(u.string()),json:R}[s.type];return s.nullable?t.nullable():t}function ae(s,t){let f=u.record(u.string(),R).parse(s);if(Object.keys(f).length>40)throw new p("INVALID_REQUEST","Too many content inputs");for(let[m,r]of Object.entries(f))Y.parse({[m]:r});if(Object.keys(f).some(m=>!Object.hasOwn(t.inputs,m)))throw new p("INVALID_REQUEST","Undeclared content input");for(let[m,r]of Object.entries(t.inputs))if(Object.hasOwn(f,m))ce(r).parse(f[m]);else if(r.required)throw new p("INVALID_REQUEST",`Missing content input ${m}`);return f}async function Ae(s,t){return le(s,t,!1)}async function Se(s,t){return le(s,t,!0)}async function le(s,t,f){t.signal?.throwIfAborted();let m=X.parse(t.content),r=m.document;if(t.closeControl==="content"&&!r.screen.actions.some(e=>e.type==="event"&&e.close))throw new p("INVALID_REQUEST","An authored Close control requires a declared Close action");if(z.has(s))throw new p("CONFLICT","Content is already mounted in this container");let y=ae(t.inputs??{},r.contract),T=new Set(u.array(u.string()).max(40).parse(t.mutableInputs??[]));if(T.size!==(t.mutableInputs?.length??0)||[...T].some(e=>!Object.hasOwn(r.contract.inputs,e)))throw new p("INVALID_REQUEST","Mutable content inputs must name unique declared inputs");for(let e of Object.keys(r.contract.outputs))if(typeof t.actions[e]!="function")throw new p("INVALID_REQUEST",`Missing host handler for ${e}`);let M=K.parse(t.bindings??[]),d=s.ownerDocument,ue=s.clientHeight||d.defaultView?.innerHeight||800,P,w,a,_,x=r.kind==="popup",n=x?d.createElement("dialog"):null,c=d.createElement("div");if(c.dataset.indianaContent=r.kind,c.setAttribute("aria-label",r.name),c.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",r.name);let e=r.screen.presentation;n.style.cssText="box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto",e.type==="modal"||e.type==="sheet"?(n.style.width=`${$[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",a=ee(n,r.screen,()=>{w?.resizeViewport(d.defaultView?.innerHeight||800,d.defaultView?.innerWidth||1024)}),n.append(c),s.append(n)}else s.append(c);let i=!1,A=!1,E=!1,S=!1,de=n?oe(n):se(c,s),D=re(s,t,r.kind,()=>{k()&&(b(),h(t.onDismiss))}),q,H,L=new Promise((e,o)=>{q=e,H=o});L.catch(()=>{});let g=null,I=structuredClone(r.screen),W=G(I,[t.locale,...d.defaultView?.navigator.languages??[]]),j=t.capabilities;I.actions=I.actions.map(e=>e.type==="event"?{...e,close:!1}:e);function b(){i||(i=!0,t.signal?.removeEventListener("abort",b),D.finish("dismissed"),H(new Error("Content preparation cancelled")),a?.destroy(),_?.(),w?.destroy(),n?.close(),n?.remove(),c.remove(),z.delete(s),n&&P?.())}let v=()=>{!E||!k()||(b(),h(t.onDismiss))};function k(){try{return t.canDismiss?.()!==!1}catch(e){return h(t.onError,e),!1}}if(n&&t.closeControl!=="content"){let e=d.createElement("button");e.type="button",e.textContent="\xD7",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),ne(e,r.screen.theme),e.addEventListener("click",v),n.prepend(e)}n&&a?.responsive&&(_=Z(n,v,k,t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),n.addEventListener("click",e=>{if(e.target!==n)return;let o=n.getBoundingClientRect();(e.clientX<o.left||e.clientX>o.right||e.clientY<o.top||e.clientY>o.bottom)&&v()})),n?.addEventListener("cancel",e=>{e.preventDefault(),v()}),n?.addEventListener("keydown",e=>{e.key==="Escape"&&(e.preventDefault(),v())});async function F(){if(i||!E||A||!g)return;let e=g;A=!0,c.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),g=null}catch(o){i||h(t.onError,o)}finally{A=!1,i||c.removeAttribute("aria-busy")}}function J(){if(i)throw new p("CONFLICT","Content host has been destroyed");E||!S||(P??=N(d),D.present(e=>{de(),n&&(a?.latch(),n.showModal(),a?.responsive&&n.focus({preventScroll:!0}),!e&&t.loading!=="host"&&te(n,a?.type??r.screen.presentation.type,a?.responsive)),E=!0}))}function U(e){D.finish("error",e),H(e instanceof Error?e:new Error(String(e))),b()}let Q={destroy:b,show:J,get pendingAction(){return g?structuredClone(g):null},retryAction:F,updateInputs(e){if(i)throw new p("CONFLICT","Content host has been destroyed");let o=u.record(u.string(),R).parse(e),C=ae({...y,...o},r.contract);for(let l of Object.keys(o))if(!T.has(l)&&(!Object.hasOwn(y,l)||V(y[l])!==V(C[l])))throw new p("PRECONDITION_FAILED","This content input is frozen; prepare a new presentation");V(y)!==V(C)&&(w?.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:C}}),y=C)},updateCapabilities(e){if(i)return;let o=structuredClone(e);w?.updateCapabilities(o),j=o}};z.set(s,Q),t.signal?.addEventListener("abort",b,{once:!0});try{if(t.signal?.throwIfAborted(),f||(P=N(d),D.start(x,t.locale??r.screen.strings.defaultLocale),i&&await L),w=ie(c,{mode:"live",rendererUrl:t.rendererUrl,title:r.name,viewportHeight:r.kind==="page"?ue:a?.responsive?d.defaultView?.innerHeight||800:void 0,...a?.responsive?{viewportWidth:d.defaultView?.innerWidth||1024,hostPresentation:()=>a.type}:{},onResize:e=>{i||a?.responsive&&(c.style.height=`${e}px`,c.style.overflow="clip",a.setContentHeight(e))},onRendered:e=>{if(!i&&(e&&n?.setAttribute("aria-label",e),!S))try{S=!0,f||J(),q()}catch(o){U(o),h(t.onError,o)}},onError:e=>{if(i)return;let o=new Error(e);S||U(o),h(t.onError,o)},onEscape:x?v:void 0,onAction:(e,o,C)=>{if(i||!E||A||g)return;let l=r.screen.actions.find(O=>O.id===e),B=r.contract.outputs[e];if(!(l?.type!=="event"||!B)&&!(l.close&&!k()))try{let O=ce(B).parse(Object.hasOwn(l.properties,"value")?l.properties.value:l.properties);g=structuredClone({requestId:crypto.randomUUID(),contentVersionId:m.id,actionId:e,event:l.event,value:O,selection:o??{},answers:C??{},requestedClose:l.close}),F()}catch(O){h(t.onError,O)}}}),w.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:y}}),await Promise.race([w.ready,L]),f&&await L,i)throw new Error("Content preparation cancelled");return Q}catch(e){throw U(e),e}}export{Ae as mountContent,Se as prepareContent};
@@ -1 +0,0 @@
1
- import{b as B}from"./chunk-GC6JBIRQ.js";import{a as z}from"./chunk-CZ4TQCUV.js";import{b as S}from"./chunk-ESAHTG3Y.js";import{b as V}from"./chunk-PJS7M6X3.js";import"./chunk-VC2HPREX.js";import"./chunk-W32FI2A2.js";import{i as W,j}from"./chunk-P6C3PNMQ.js";import"./chunk-ASDJTOGM.js";import"./chunk-67AY54E2.js";import"./chunk-4TEZZZYK.js";import"./chunk-POCDWUD3.js";import"./chunk-RFNIGJOL.js";import"./chunk-6PG3AS3G.js";import"./chunk-X6ONZGRY.js";import"./chunk-EREQZWGI.js";import"./chunk-P23JOPR5.js";import"./chunk-IOJVF52Q.js";import"./chunk-U7GH4VME.js";import"./chunk-3NCMYTNG.js";import"./chunk-33ZVZOSC.js";import"./chunk-VOKEZHAH.js";import"./chunk-PZOQV6MU.js";import"./chunk-FCDWCQYC.js";import"./chunk-XDOKFAE6.js";import"./chunk-Y6HL2IY2.js";import"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import{a as v}from"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-SLUA7ABW.js";import"./chunk-C2KT5ZFU.js";import"./chunk-3VUPVXAV.js";import"./chunk-RV6UAUK2.js";import"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as u}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";var m=new WeakMap,I=new WeakMap,H=new WeakSet;function re(C,e){let s=e.prepared,N=()=>{s&&!H.has(s)&&S(s)?.release()},R=m.get(e.client);if(R)return N(),R;let c=e.allowNewPurchase===!1||!e.start?void 0:{...e.start,requestId:e.start.requestId??crypto.randomUUID()};c&&s?.state==="ready"&&s.matches(c)&&s.open();let i=c&&s&&(s.state==="preparing"||["shown","closed"].includes(s.state)&&s.matches(c))?s:void 0;i?H.add(i):N();let d=i&&S(i);d?.claim();let b=Promise.resolve().then(async()=>{let r=!1,w,E,U=!1,T=()=>{},L=()=>{},y,M=!1,O=!1,f,_=!1,n=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,P=()=>{m.get(e.client)===b&&m.delete(e.client),n.removeEventListener("abort",A),T(),L(),i&&H.delete(i),d?.release()};function x(){if(f)return f;let l=new Promise(h=>f=h);return I.set(e.client,l),l.then(()=>{I.get(e.client)===l&&I.delete(e.client)}),m.get(e.client)===b&&m.delete(e.client),f}let a=j(C,e,"funnel",()=>F(),z);function A(){F()}function F(l=!1){if(!r){if(r=!0,a.finish("dismissed"),w){w.destroy();return}if(l&&y){let h=x();_=!0,y.then(async g=>{g.mode==="run"&&g.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===c?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{h(),u(e.onDismiss,null)}),P();return}P(),u(e.onDismiss,null)}}n.addEventListener("abort",A,{once:!0}),d&&(L=d.onClose(()=>{M?r||x():F(!0)}));try{let k=function(){!r&&!n.aborted&&!U&&E&&e.client.recovery.status==="complete"&&(U=!0,u(e.onComplete,structuredClone(E)))},D=function(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(t):C.ownerDocument.defaultView?.location.assign(t)};var J=k,K=D;n.throwIfAborted();let l=e.client.controller?.view?.paywall?.resolution,h=l&&"document"in l?l.document:e.loadingDocument;a.start(!0,c?.locale??e.client.attempt?.locale??h?.screen.strings.defaultLocale,h??null),i?.state==="shown"?(O=!0,a.present(()=>{})):i?.state==="preparing"&&i.ready.then(t=>{if(t){if(r||!a.active||!i.matches(c)||!d?.revealable)return d?.release();a.present(()=>{i.open()==="shown"?O=!0:d.release()})}});let g=I.get(e.client);if(g&&await a.wait(g),r)return null;n.throwIfAborted(),y=c?e.client.start(c):e.client.refresh();let q=await a.wait(y,W);if(r)return null;n.throwIfAborted();let G=e.client.controller;return q.mode!=="run"||q.status==="blocked"||!G?(a.finish("skipped"),P(),O&&u(e.onDismiss,null),null):(n.removeEventListener("abort",A),M=!0,T=e.client.subscribe(k),w=await B(C,{...e,prepared:i,client:G,signal:n,checkoutNavigation:"after_confirmation",resumeCheckout:t=>e.client.continueCheckout(D,t),terminateCheckout:e.allowNewPurchase===!1?void 0:t=>e.client.terminateCheckout(t),async onCheckoutUrl(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let o=e.client.recovery;if((!o.actions.includes("continue_checkout")||!o.purchases.some(p=>p.type==="checkout"&&p.checkoutUrl===t))&&(o=await e.client.refresh(),n.throwIfAborted(),r))throw new DOMException("Presentation dismissed","AbortError");if(V(o)!==t)throw new v("PURCHASE_PENDING","Checkout differs from the original recovery proof");return D(t)},async resolveOfferId(t){if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");let o=e.client.attempt;if(!o)throw new v("PURCHASE_PENDING","Read the original Start before selecting an offer");let p=await e.resolveOfferId?.(t,o);if(n.throwIfAborted(),r)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==o.requestId)throw new v("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return p},onComplete(t){E=t,k()},onError(t){u(e.onError,t),t instanceof v&&t.status===401&&!n.aborted&&e.client.refresh().catch(o=>u(e.onError,o))},onDismiss(t){r=!0,P(),f?.(),u(e.onDismiss,t)}},a),r||n.aborted?(w.destroy(),null):w)}catch(l){if(_||f?.(),r)return null;throw a.finish("error",l),P(),u(e.onError,l),l}});return m.set(e.client,b),b}export{re as showFunnelPurchase};
@@ -1 +0,0 @@
1
- import{a,b,c}from"./chunk-ESAHTG3Y.js";import"./chunk-VOKEZHAH.js";import"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-RGEBK6UF.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as PRERENDER_MAX_AGE_MS,b as preparedInternals,c as prerenderFunnelPurchase};
@@ -1 +0,0 @@
1
- import{a,b}from"./chunk-GC6JBIRQ.js";import"./chunk-CZ4TQCUV.js";import"./chunk-ESAHTG3Y.js";import"./chunk-VC2HPREX.js";import"./chunk-W32FI2A2.js";import"./chunk-P6C3PNMQ.js";import"./chunk-IOJVF52Q.js";import"./chunk-U7GH4VME.js";import"./chunk-3NCMYTNG.js";import"./chunk-33ZVZOSC.js";import"./chunk-VOKEZHAH.js";import"./chunk-PZOQV6MU.js";import"./chunk-FCDWCQYC.js";import"./chunk-XDOKFAE6.js";import"./chunk-Y6HL2IY2.js";import"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-SLUA7ABW.js";import"./chunk-C2KT5ZFU.js";import"./chunk-RV6UAUK2.js";import"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
@@ -1 +0,0 @@
1
- import{N as r,O as m,h as e}from"./chunk-6PG3AS3G.js";import"./chunk-U7GH4VME.js";import"./chunk-FCDWCQYC.js";import"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import"./chunk-RULQQ7WI.js";import"./chunk-RGEBK6UF.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{m as merchantBridgeCommerceSchema,r as merchantBridgeOperationSchema,e as merchantOperationLookupSchema};
@@ -1 +0,0 @@
1
- import{e as o}from"./chunk-5DZJCFNQ.js";import"./chunk-YLPQLD2A.js";import"./chunk-ORMQJAQE.js";import"./chunk-RFNIGJOL.js";import"./chunk-6PG3AS3G.js";import"./chunk-EREQZWGI.js";import"./chunk-P23JOPR5.js";import"./chunk-IOJVF52Q.js";import"./chunk-U7GH4VME.js";import"./chunk-33ZVZOSC.js";import"./chunk-57GPGWSK.js";import"./chunk-FCDWCQYC.js";import"./chunk-XDOKFAE6.js";import"./chunk-Y6HL2IY2.js";import"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import"./chunk-RULQQ7WI.js";import"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
@@ -1 +0,0 @@
1
- import{a as Tt,c as Ot,d as et,f as tt,g as Dt,k as Lt}from"./chunk-CZ4TQCUV.js";import{b as Xe}from"./chunk-W32FI2A2.js";import{d as Et,e as xt,f as It,h as Ze,i as De,j as At,k as Rt,l as St}from"./chunk-P6C3PNMQ.js";import{a as bt,c as Je,d as Ct,e as vt}from"./chunk-3NCMYTNG.js";import{b as ce}from"./chunk-33ZVZOSC.js";import{a as pe,c as Ke,e as Pt,h as kt}from"./chunk-VOKEZHAH.js";import"./chunk-PZOQV6MU.js";import"./chunk-FCDWCQYC.js";import{ca as Ce,ea as ve,i as gt}from"./chunk-XDOKFAE6.js";import{c as fe,j as be}from"./chunk-Y6HL2IY2.js";import{c as Ye}from"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import{a as v}from"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-RV6UAUK2.js";import"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as q}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";async function Nt(O,i,R){if(i.status!=="complete")throw new v("INVALID_RESPONSE","A verified completed purchase is required");let P=O?be.parse(O):null;if(await R.onComplete?.(i),!P||!R.check)return;let N=be.parse(await R.check());if(N.internal_feature_id!==P.internal_feature_id||N.quantity!==P.quantity||P.observation!==void 0&&(N.observation===void 0||N.observation.requirementDigest!==P.observation.requirementDigest||N.observation.authority!==P.observation.authority||Ye(N.observation.subject)!==Ye(P.observation.subject)))throw new v("INVALID_RESPONSE","The access requirement changed");N.allowed&&await R.onAccessGranted?.(N)}function nt(O){return Object.entries(O.document.buttons).filter(([,i])=>i.type==="checkout"&&i.product.type==="fixed"&&!ce(i.product,{},O.capabilities)).map(([i])=>i)}function _t(O,i){let R=i.lines[0];if(i.lines.length!==1||!R)return;let P=R.productVersionId,{screen:N,buttons:J}=O.document,x=new Map((R.prepaid??[]).map(m=>[m.internal_feature_id,m.quantity]));function K(m,h){if(m.hidden)return!1;if(m.type==="plan_picker"&&O.capabilities.pickers[m.id]?.options.includes(P))return h[m.id]=P,!0;if(m.type==="quantity_picker"){let Q=x.get(m.internalFeatureId);return Q!==void 0&&(!m.bind?.plan||m.bind.plan===P)&&(h[m.id]=Q),!1}if(m.type==="button"&&m.action){let Q=J[m.action];return Q?.type==="checkout"&&Q.product.type==="fixed"&&Q.product.productVersionId===P}if(m.type!=="stack")return!1;let j=m.interaction,r=m.bind?.plan===P;for(let[Q,p]of m.children.entries()){let te={},S=K(p,te);if(j?.type==="toggle"||j?.type==="tabs"){if(!S)continue;return h[m.id]=j.type==="toggle"?Q===0:p.id,Object.assign(h,te),!0}Object.assign(h,te),S&&(r=!0,j?.type==="select"&&j.purpose==="product"&&j.pickerId&&p.type==="stack"&&p.bind?.plan===P&&(h[m.id]=p.id,h[j.pickerId]=P))}return r}for(let m of N.pages){let h={__page:m.id};if(K(m.root,h))return h}}async function Pn(O,i,R){let P=i.focusAtReveal?()=>{}:Ze(O.ownerDocument),N=()=>{x.finish("dismissed"),P()},J=()=>N(),x=At(O,i,"paywall",()=>{N(),q(i.onDismiss)},Tt);i.signal?.throwIfAborted(),i.signal?.addEventListener("abort",J,{once:!0});let K=null,m,h,j;try{if(x.start(!0,i.loadingDocument?.screen.strings.defaultLocale,i.loadingDocument??null),x.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(K=i.check?be.parse(await x.wait(i.check(),De)):null,K?.allowed)return x.finish("skipped"),i.signal?.removeEventListener("abort",J),P(),await i.onAccessGranted?.(K),{check:K,host:null};let[e,t]=await Promise.allSettled([x.wait(import("./screen-renderer-FFVZ64MR.js")),x.wait(i.start().then(o=>(x.cancelled&&o.destroy(),o)),De)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;j=e.value,m=t.value,i.signal?.throwIfAborted(),m.signal?.throwIfAborted(),m.signal?.addEventListener("abort",J,{once:!0});let n=m.view??await x.wait(m.refresh(),De);if(!n)throw new v("INVALID_RESPONSE","Paywall presentation is missing");m.signal?.throwIfAborted(),h=n}catch(e){throw x.finish("error",e),i.signal?.removeEventListener("abort",J),m?.signal?.removeEventListener("abort",J),m?.destroy(),P(),e}let r=m,{mountScreenPreview:Q}=j,p=O.ownerDocument,te=new AbortController,S=p.createElement("section"),le=p.createElement("div"),G=p.createElement("div"),Le=i.mountControls,V=Le?p.createElement("div"):void 0,u=p.createElement("p"),g=p.createElement("button"),k=p.createElement("button"),I=p.createElement("dialog"),rt=r.locale||h.document.screen.strings.defaultLocale,a=rt.toLowerCase().startsWith("zh"),Ut=a?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",Mt=a?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",D=Ot(h.document.screen.theme);S.dataset.indianaPaywall="",S.setAttribute("aria-label",h.document.name),S.style.cssText=D.root,G.style.cssText=D.controls,u.style.cssText=D.message,u.setAttribute("role","status"),k.style.cssText=D.link,k.textContent=a?"\u5173\u95ED":"Close",g.style.cssText=D.secondary,g.textContent=a?"\u91CD\u8BD5":"Retry",g.hidden=!0,G.append(u,g,k),V&&(V.style.cssText="flex:1 0 100%;min-width:0",V.hidden=!0,G.prepend(V)),S.append(le,G);let Ne=()=>{if(V){let o=!V.childElementCount&&!V.textContent?.trim();V.hidden!==o&&(V.hidden=o)}let e=ne??G,t=[...e.children].every(o=>o===u?!u.textContent:o.hidden),n=[...e.children].some(o=>o===k?!1:o===u?!!u.textContent:!o.hidden);e.style.cssText=t?D.controls.replace(/padding:[^;]+/,"padding:0"):n?`${D.controls};${D.pinned}`:D.controls,Me()},it=typeof MutationObserver>"u"?void 0:new MutationObserver(Ne);it?.observe(S,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Pe=h.document.presentation,qt=Object.entries(h.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),$,ot,_e=!1,at=JSON.stringify(h.capabilities),st=e=>oe&&!he?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):nt(e);function ke(e){if(y)return;h=e;let t=JSON.stringify(e.capabilities);t!==at&&($?.updateCapabilities(pe(e),st(e)),at=t),Ht(e),ye()}let E,Ue=0;function Me(){let e=p.defaultView;if(!E?.responsive||!e)return;let t=ne??G,n=e.innerHeight-(E.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",Ue=Math.max(1,n-t.getBoundingClientRect().height),$?.resizeViewport?.(Ue,e.innerWidth)}let y=!1,oe=!1,C=null,qe,Ee=!1,ct=!1,ae=!1,Ve,$e=!1,X,ne;function Vt(){return oe||y||X||$e?{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}:Je(r)}let A=()=>!y&&!Ee&&!X&&i.canInteract?.()!==!1,H,ue=!1,d=null,Z=null,He="",se=()=>i.checkoutNavigation==="after_confirmation"&&!!(i.terminateCheckout||i.resumeCheckout),me={},he,W=null;function ye(){if(!se()||!$?.updateCheckoutControls)return;let e=r.quote,t=!W&&!!e&&!!r.operation&&B(r.operation).type==="checkout",n=Object.entries(h.document.buttons).flatMap(([o,c])=>c.type==="checkout"?[{actionId:o,policy:c}]:[]);$.updateCheckoutControls({actions:n.map(({actionId:o})=>o),resume:t?n.filter(({actionId:o,policy:c})=>Ae(e,h,o,c.product,me)).map(({actionId:o})=>o):[],resumeLabel:a?"\u7EE7\u7EED\u4ED8\u6B3E":"Continue checkout",busy:he})}function lt(){Z?.remove(),Z=null}async function Be(){if(W)return;if(i.resumeCheckout&&r.operation){await i.resumeCheckout(r.operation.operationId);return}let e=await r.read();if(B(e).type!=="checkout")return _(e,!1);A()&&(xe.delete(e.operationId),await Re(e))}function ut(){u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\u4ED8\u6B3E\u9875\u9762\u3002\u8BF7\u91CD\u8BD5\u3002":"Couldn\u2019t open checkout. Try again.",g.hidden=!0}async function dt(e=!1){let t=W;if(!t)return;g.hidden=!0;let n=Date.now()+2e4;for(;A();){let o=await r.read();if(o.operationId!==t.operationId)throw new v("PURCHASE_PENDING","The original Checkout changed");if(!A())break;let c=B(o);if(c.type==="native"){W=null,lt(),C=t.selection,H=t.coupon,ue=!1,await ge();return}if(c.type==="complete"||c.type==="fulfillment"||c.type==="recording"){W=null,await _(o,!1);return}if(e&&c.type==="checkout"){e=!1;try{await i.terminateCheckout(t.operationId)}catch(w){q(i.onError,w)}}if(Date.now()>=n)break;await Xe(1e3,p,te.signal)}y||ut()}async function $t(e,t,n){W={operationId:e,selection:t,coupon:n};let o=!1;try{await i.terminateCheckout(e)}catch(c){if(c instanceof v&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(c.code)){W=null,u.textContent=a?"\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.",q(i.onError,c);return}o=c instanceof v&&(c.status??0)>=500,q(i.onError,c)}A()&&await dt(o)}function Fe(e,t,n,o,c){let w=pe(e).checkoutCoupons?.[t],l=w?w.products[n]:i.claimCoupon&&c?gt(e.capabilities,c,o):void 0;return l?.couponId&&l.planVersionId===n?{id:l.couponId,offerId:l.offerId}:void 0}function Ht(e){oe||C||r.quote||r.operation||He&&u.textContent===He||(u.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":a?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let xe=new Map,Ie=!1;function Ae(e,t,n,o,c,w){let l=e.lines.length===1?e.lines[0]:void 0,s=ce(o,c,t.capabilities);if(!l||!s||l.productVersionId!==s)return!1;let L=Fe(t,n,s,c,w);if((L||pe(t).checkoutCoupons?.[n])&&(L?.id??null)!==(e.discount?.couponId??null))return!1;let U;try{U=ve(t.document.screen,s,c,t.capabilities)}catch{return!1}let ie=Object.fromEntries((l.prepaid??[]).map(z=>[z.internal_feature_id,z.quantity]));return[...new Set([...Object.keys(U),...Object.keys(ie)])].every(z=>(U[z]??0)===(ie[z]??0))}let B=e=>bt({quote:r.quote,operation:e,requestId:null,pending:!1,destroyed:y,canReselect:r.canReselect});async function Re(e){let t=e.merchantExecution;if(!(!A()||!e.checkoutUrl||i.checkoutNavigation==="after_confirmation"&&B(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||xe.get(e.operationId)===e.checkoutUrl)){xe.set(e.operationId,e.checkoutUrl);try{i.onCheckoutUrl?await i.onCheckoutUrl(e.checkoutUrl):p.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw xe.delete(e.operationId),n}}}let re=(e,t=!1)=>{if(e instanceof Ke)d=null,u.textContent=e.customerMessage(a);else if(Dt(e))d=null,u.textContent=t?a?"\u5F53\u524D\u65E0\u6CD5\u5728\u6B64\u8D2D\u4E70\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u3002":"Purchases aren\u2019t available here right now. Payment hasn\u2019t started. Contact the merchant for help.":tt(e,a);else if(t){let n=e instanceof v?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(d=null,u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u4E3A\u6B64\u5957\u9910\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002":"Pricing for this plan is unavailable. Payment hasn\u2019t started."):r.canReselect===!0&&!C?u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u65B0\u9009\u62E9\u5957\u9910\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Choose a plan again.":n==="COMMAND_PENDING"?u.textContent=a?"\u4ECD\u5728\u51C6\u5907\u62A5\u4EF7\uFF0C\u8BF7\u91CD\u8BD5\u4EE5\u67E5\u770B\u7ED3\u679C\u3002":"Your price is still being prepared. Retry to check the result.":u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u8BD5\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Try again."}else u.textContent=e instanceof v&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?tt(e,a):e instanceof v?e.message:a?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";g.hidden=d===null,He=u.textContent,t&&!E?.responsive&&u.scrollIntoView?.({block:"nearest"}),q(t&&R?.quoteError?R.quoteError:i.onError,e)},Se=new WeakMap;function Te(e){oe=e,g.disabled=e,$?.updateCapabilities?.(pe(h),st(h));for(let t of Z?.querySelectorAll("button")??[])e?(Se.set(t,t.disabled),t.disabled=!0):Se.has(t)&&(t.disabled=Se.get(t),Se.delete(t)),et(t)}function je(){u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"This action is unavailable right now. Try again in a moment."}async function Bt(e){if(i.beforeAction)try{await i.beforeAction()}catch(t){throw t instanceof Ke?(C=null,ue=!1,d=null):d=e,t}}async function M(e,t){if(oe||y)return;if(!A()){je();return}let n=e===ge,o=n?Mt:Ut,c=se()&&t!==void 0;he=c?t:void 0,Te(!0),ye(),g.hidden=!0,u.textContent=c?"":o;try{if((e!==Be||!i.resumeCheckout)&&await Bt(e),y)return;if(!A()){d=e,g.hidden=!1,je();return}await e()}catch(w){y||re(w,n&&!c)}finally{he=void 0,Te(!1),ye(),u.textContent===o&&(u.textContent="")}}async function Ft(e){await Nt(K,e,i)}function ft(e){return Je(r).type==="recording"||B(e).type==="recording"}function pt(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],o=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),c=t?n.length===1&&n[0]?.amountMinor===o&&n[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===o&&e.lines[0],w=o===null?fe(t.subtotalMinor-t.discountMinor,e.currency)+(a?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):fe(o,e.currency)+(c?Ce(c.interval,a?"zh-CN":"en",c.intervalCount??1):""),l=e.lines.map(s=>s.productName).join(", ");return{label:l?`${l} \xB7 ${w}`:w,recurring:c}}async function _(e,t=i.checkoutNavigation!=="after_confirmation"){if(y)return;if(!A()){d=async()=>_(await r.read()),g.hidden=!1;return}if(u.textContent=Lt(e.status,a),ft(e)){let s=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";u.textContent=s?a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u4F46\u4EA4\u6613\u8BB0\u5F55\u5931\u8D25\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u4FEE\u590D\uFF0C\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u8BB0\u5F55\u3002\u8BF7\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",g.textContent=a?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",d=async()=>_(await r.read()),g.hidden=!1;return}if(e.problem){let s=e.problem;d=we,g.textContent=a?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",re(new v(s.code,s.reason==="RESULT_UNKNOWN"?a?"\u4ED8\u6B3E\u7ED3\u679C\u5C1A\u672A\u786E\u5B9A\uFF0C\u8BF7\u6062\u590D\u539F\u64CD\u4F5C\uFF0C\u6682\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"The payment result is unknown. Recover the original purchase before buying again.":s.phase==="fulfillment"?a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":s.code==="CAPABILITY_UNAVAILABLE"?a?"\u5546\u6237\u5C1A\u4E0D\u652F\u6301\u672C\u6B21\u8D2D\u4E70\u6240\u9700\u7684\u5B8C\u6574\u80FD\u529B\uFF0C\u8BF7\u5904\u7406\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":s.code==="NOT_CONFIGURED"?a?"\u4ED8\u6B3E\u670D\u52A1\u8FDE\u63A5\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":a?"\u539F\u8D2D\u4E70\u64CD\u4F5C\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u67E5\u8BE2\u6216\u6062\u590D\u6B64\u64CD\u4F5C\u3002":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,s));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(u.textContent=a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u6B63\u5728\u7B49\u5F85\u5546\u6237\u5B8C\u6210\u5904\u7406\u3002":"Payment was recorded. Waiting for merchant fulfillment."),e.status==="complete"){d=null,await Ft(e);return}if(e.status!=="pending"){if(r.canReselect===!1){u.textContent=a?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",g.textContent=a?"\u67E5\u8BE2\u7ED3\u679C":"Check result",d=async()=>_(await r.read()),g.hidden=!1;return}e.status==="cancelled"?u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u5DF2\u53D6\u6D88\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u672A\u80FD\u5B8C\u6210\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase didn\u2019t go through. Choose a plan to try again."),g.textContent=a?"\u91CD\u8BD5":"Retry",d=null,C=null;return}if(!t&&B(e).type==="checkout"){if(W){ut();return}if(se()){u.textContent="",Ie=!1,d=null,ye();return}let s=r.quote,L=s?.operationId===e.operationId?pt(s).label:"";u.textContent=Ie?L?a?`${L} \u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002`:`${L} is still unpaid. Choose it again to continue paying.`:a?"\u4E4B\u524D\u7684\u8D2D\u4E70\u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",Ie=!1,d=null;return}await Re(e);let n=Date.now(),o=n+6e5,c=2e3,w=!e.checkoutUrl,l=()=>w&&Date.now()-n<15e3;_e=!0,q(i.onObservationChange,!0);try{for(;!y&&Date.now()<o;){if(await Xe(l()?700:c,p,te.signal),y)return;if(!A()){d=async()=>_(await r.read()),g.hidden=!1;return}let s=await r.read();if(s.checkoutUrl&&(w=!1),!t&&B(s).type==="checkout"){await _(s,!1);return}if(!s.problem&&s.status==="pending"&&await Re(s),s.status!=="pending"||s.problem||ft(s)){await _(s);return}l()||(c=Math.min(c*1.5,3e4))}}finally{_e=!1,q(i.onObservationChange,!1)}d=async()=>_(await r.read()),g.hidden=!1}async function Qe(e=!1){let t=await r.read();if(y)return;if(!A()){d=()=>Qe(e),g.hidden=!1;return}let n=r.quote;if(n&&Pt(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){mt(n);return}await _(t,e||void 0)}async function we(){lt(),d=we;let e=await r.confirm();if(!A()){d=we,g.hidden=!1;return}if(e.problem){await _(e);return}if(e.status==="pending"){if(e.checkoutUrl)await Re(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!i.onPurchase)throw new v("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await i.onPurchase({operation:e,signal:te.signal})}}d=async()=>_(await r.read()),await _(e,!0)}function mt(e){Z?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());u.textContent=t?a?"\u6B64\u62A5\u4EF7\u5DF2\u8FC7\u671F\u3002\u8BF7\u5148\u53D6\u6D88\uFF0C\u518D\u91CD\u65B0\u9009\u62E9\u3002":"This quote has expired. Cancel it, then choose again.":"";let n=p.createElement("div"),o=p.createElement("button"),c=p.createElement("button"),w=p.createElement("div"),l=p.createElement("p"),s=e.merchantTerms,L=a?"zh-CN":"en",U=s?.subscriptionTerms?.items??[],ie=s?s.subscriptionTerms?.trial?.days:e.lines.find(f=>f.trial)?.trial?.days,ee=ie===void 0?null:s?s.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(f=>f.trial)?0:null,z=(f,b)=>a?`${b} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${f}`:`Then ${f} after the ${b}-day trial`,{label:ze,recurring:ht}=pt(e),jt=e.lines.map(f=>f.productName).join(", "),yt=ee===null?"":`${a?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${fe(ee,e.currency)}`;l.textContent=yt?[jt,yt].filter(Boolean).join(" \xB7 "):ze,o.textContent=a?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",o.disabled=t,c.textContent=a?"\u53D6\u6D88":"Cancel",n.style.cssText=D.panel,l.style.cssText=D.summary,w.style.cssText=D.actions,o.style.cssText=D.primary,c.style.cssText=D.secondary,et(o),o.onclick=()=>{M(we)};let wt=async()=>{let f=await r.cancel();y||(n.remove(),Z=null,await _(f))};c.onclick=()=>{d=wt,M(wt)};let F=p.createElement("div");if(F.style.cssText=D.terms,s){for(let b of U){if(ee===null&&b===ht)continue;let T=p.createElement("p"),Y=fe(b.amountMinor,e.currency)+Ce(b.interval,L,b.intervalCount);T.textContent=ee!==null&&ie!==void 0?z(Y,ie):Y,F.append(T)}let f=s.subscriptionTerms?.trial;if(f){let b=p.createElement("p");b.textContent=a?`\u8BD5\u7528 ${f.days} \u5929\uFF1B${f.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${f.days}; ${f.cardRequired?"a payment method is required":"no payment method is required"}`,F.append(b)}for(let b of[...s.expectedEffects.map(T=>T.description),...s.requiredConsents.map(T=>T.summary)]){let T=p.createElement("p");T.textContent=b,F.append(T)}}else{for(let f of e.lines){if(ee!==null||f!==ht){let b=p.createElement("p"),T=`${fe(f.catalogAmountMinor,e.currency)}${Ce(f.interval,L,f.intervalCount??1)}`;b.textContent=ee!==null&&f.trial?(e.lines.length>1?`${f.productName} \xB7 `:"")+z(T,f.trial.days):`${f.productName} \xB7 ${T}`,F.append(b)}for(let b of f.prepaid??[]){let T=p.createElement("p"),Y=r.view?.capabilities.plans[f.productVersionId]?.prepaid?.find(Qt=>Qt.internalFeatureId===b.internal_feature_id);T.textContent=`${Y?.name??b.internal_feature_id} \xB7 ${b.quantity} ${a?"\u4EFD":"packs"} \xD7 ${b.terms.units}`,Y&&(T.textContent+=Ce(Y.reset==="week"||Y.reset==="month"||Y.reset==="year"?Y.reset:"one_time",L,Y.resetCount)),F.append(T)}if(f.trial){let b=p.createElement("p");b.textContent=a?`\u8BD5\u7528 ${f.trial.days} \u5929\uFF1B${f.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${f.trial.days}; ${f.trial.cardRequired?"a payment method is required":"no payment method is required"}`,F.append(b)}}if(!e.charge){let f=p.createElement("p");f.textContent=a?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",F.append(f)}}for(let f of F.children)f.style.margin="0";w.append(o,c),n.append(l,...F.childElementCount?[F]:[],w),G.prepend(n),E?.responsive||n.scrollIntoView?.({block:"nearest"}),o.focus({preventScroll:!0}),Z=n,d=null}async function ge(){if(!C)return;if(d=ge,!ue){let n=r.view,o=n?.document.buttons[C.actionId],c=n&&o?.type==="checkout"?ce(o.product,C.selection,n.capabilities):null;if(!n||!c)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let w=H?.offerId;if(H&&!w){if(!i.claimCoupon)throw new v("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:l}=await i.claimCoupon(H.id,C.requestId);if(y)return;if(!l||l.couponId!==H.id||l.status!=="issued"||!(Date.parse(l.expiresAt)>Date.now()))throw C=null,H=void 0,d=async()=>{ke(await r.refresh()),d=null},new v("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");w=l.id}if(!H&&!n.document.screen.actions.some(l=>l.id===C?.actionId&&typeof l.properties.couponBinding=="string")&&(w=await i.resolveOfferId?.({actionId:C.actionId,productVersionId:c,featureQuantities:ve(n.document.screen,c,C.selection,n.capabilities)})),y)return;w!==void 0&&(C.offerId=w),ue=!0}if(!A()){g.hidden=!1;return}let e;try{e=await r.preview(C)}catch(n){throw r.canReselect===!0&&(C=null,ue=!1,H=void 0,d=null),n}if(H&&(e.discount?.couponId!==H.id||e.discount.offerId!==C.offerId))throw new v("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(y)return;let t=e.merchantTerms;if(i.confirmOnHostedCheckout&&A()&&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=he?"":a?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";u.textContent=n;try{await we()}catch(o){y||re(o)}finally{u.textContent===n&&(u.textContent="")}return}mt(e)}function de(e="destroy"){if(y)return;y=!0;let t=qe;qe=void 0,q(t),i.signal?.removeEventListener("abort",J),r.signal?.removeEventListener("abort",J),x.finish("dismissed"),ot?.(),te.abort(),it?.disconnect(),E?.destroy(),$?.destroy(),r.destroy(),I.open&&I.close(),I.remove(),S.remove(),P(),e==="dismiss"&&q(i.onDismiss)}N=de;async function Oe(){if(!ae||y||Ee||X==="closing"||!X&&!A())return;if(!R){de("dismiss");return}let e=p.createElement("p");e.setAttribute("role","status"),e.textContent=a?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",ne||(ne=p.createElement("div"),ne.style.cssText=G.style.cssText,G.replaceWith(ne),le.inert=!0),k.hidden=!1,ne.replaceChildren(e,k),X="closing",k.setAttribute("aria-disabled","true"),k.focus({preventScroll:!0});try{await R.dismiss()}catch(t){y||q(i.onError,t)}y||(X="retry",e.textContent=a?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",k.textContent=a?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",k.removeAttribute("aria-label"),k.removeAttribute("aria-disabled"))}k.onclick=()=>{Oe()},I.addEventListener("cancel",e=>{e.preventDefault(),Oe()}),g.onclick=()=>{d&&M(d)};function Ge(e){x.finish("error",e),de()}function We(){if(!(!ct||ae||y||Ee||E&&!A()))try{let e=t=>{i.focusAtReveal&&(P=Ze(p)),$?.setHidden?.(!1),Ve?.(),E&&(I.showModal(),E.responsive&&I.focus({preventScroll:!0}),!t&&i.loading!=="host"&&xt(I,E.type,E.responsive)),ae=!0};R?R.present(()=>x.present(()=>e(!0))):x.present(e)}catch(e){Ge(e),re(e)}}try{if(Pe.type==="inline"?(Ne(),Ve=St(S,O),O.append(S)):(I.setAttribute("aria-label",h.document.name),k.textContent="\xD7",k.setAttribute("aria-label",a?"\u5173\u95ED":"Close"),It(k,h.document.screen.theme),k.hidden=kt(h.document),I.append(k,S),O.append(I),E=Et(I,{...h.document.screen,presentation:Pe},Me),E.latch(),E.responsive&&(S.style.display="flex",S.style.flexDirection="column",S.style.maxHeight="100%",le.style.overflow="clip",le.style.minHeight="0"),Ve=Rt(I)),Le&&V){let n=Le(V);if(typeof n=="function"&&(y?q(n):qe=n),y)throw new DOMException("Presentation cancelled","AbortError");Ne()}$=Q(le,{mode:"live",rendererUrl:r.webViewUrl,title:h.document.name,closeActions:qt,onAuthoredClose(n){X||y||(k.hidden=n)},hostPresentation:()=>E?.type??Pe.type,reportContentHeight:E?.responsive,onResize:n=>{if(!E?.responsive)return;let o=Math.min(n,Ue);le.style.height=`${o}px`,E.setContentHeight(o+(ne??G).getBoundingClientRect().height)},onSelection(n){me=n,ye()},onAction(n,o={},c,w){if(!ae||y||X)return;let l=r.view,s=l?.document.buttons[n];if(!s)return;if(s.type==="close"&&R&&i.resumeCheckout&&r.operation&&Ct(B(r.operation))){Oe();return}if(oe)return;if(!A()){je();return}if(s.type==="close"){M(async()=>{await i.onAction?.(n),de(i.onAction?"action":"dismiss")});return}if(s.type==="action"){d=async()=>{if(s.action.type==="event"){if(!i.onEvent)throw new v("EVENT_HANDLER_REQUIRED","Provide the event handler");await i.onEvent(s.action.event)}else i.onOpenUrl?await i.onOpenUrl(s.action.url):p.defaultView?.location.assign(s.action.url);await i.onAction?.(n),d=null},M(d);return}if(i.allowNewPurchase===!1){se()&&l&&r.quote&&r.operation&&B(r.operation).type==="checkout"&&Ae(r.quote,l,n,s.product,o,w)?M(Be,n):u.textContent=a?"\u5F53\u524D\u53EA\u80FD\u7EE7\u7EED\u539F\u8BA2\u5355\u3002":"Only your original checkout is available.";return}if(Z&&r.canReselect===!1){u.textContent=a?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",E?.responsive||Z.scrollIntoView?.({block:"nearest"}),Z.querySelector("button")?.focus({preventScroll:!0});return}if(se()&&W){W.selection.actionId===n&&M(()=>dt(!0),n);return}if(se()&&i.terminateCheckout&&l&&r.quote&&r.operation&&r.canReselect===!1&&B(r.operation).type==="checkout"){if(Ae(r.quote,l,n,s.product,o,w)){M(Be,n);return}let U=ce(s.product,o,l.capabilities);try{if(!U)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");ve(l.document.screen,U,o,l.capabilities)}catch(ze){re(ze);return}let ie=r.operation.operationId,ee={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(o)},z=Fe(l,n,U,o,w);M(()=>$t(ie,ee,z),n);return}if((r.quote||C)&&r.canReselect===!1){let U=!!l&&!!r.quote&&Ae(r.quote,l,n,s.product,o,w);Ie=!!r.quote&&!U,d=r.quote?()=>Qe(U):ge,M(d);return}let L=l&&ce(s.product,o,l.capabilities);if(!l||!L){re(new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(i.onPurchaseIntent){d=null,M(async()=>{let U={actionId:n,productVersionId:L,selection:structuredClone(o),featureQuantities:ve(l.document.screen,L,o,l.capabilities)};$e=!0,await i.onPurchaseIntent(U)});return}if(C&&C.actionId!==n){re(new v("COMMAND_PENDING","Finish the current purchase"));return}C||(H=Fe(l,n,L,o,w),C={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(o)},ue=!1),M(ge,n)},onEscape:()=>{Oe()},onError:n=>{let o=new Error(n);!ae&&!y&&Ge(o),re(o)},onRendered:n=>{n&&I.setAttribute("aria-label",n),ct=!0,We()}}),$.setHidden?.(!0),Me();let e=se()&&!!r.quote&&!!r.operation&&B(r.operation).type==="checkout";me=e?_t(h,r.quote)??{}:{},$.update(h.document.screen,rt,{capabilities:pe(h),unavailableActions:nt(h),serverInput:{bindings:[],answers:{}},...Object.keys(me).length?{selection:me}:{}}),ot=r.subscribe?.(ke),ke(r.view??h),await x.wait($.ready);let t=r.operation;!e&&(r.quote||t&&(t.confirmedAt||t.checkoutUrl||t.status==="complete"))&&(d=()=>Qe(),M(d))}catch(e){throw Ge(e),e}return{check:K,host:{get observing(){return _e},get recovery(){return Vt()},async prepareFallback(){if(oe||y||X||$e)return{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null};Te(!0);try{let e=await vt(r);return e.type==="native"&&de(),e}finally{Te(!1)}},setSuspended(e){Ee=e,S.hidden=e,e&&I.open?I.close():!e&&!ae?We():!e&&!y&&ae&&Pe.type!=="inline"&&!I.open&&I.showModal()},destroy:de,refresh:async()=>{if(!A()){if(r.view)return r.view;throw new v("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await r.refresh();return ke(e),We(),e}}}}export{Pn as showPaywall};
@@ -1 +0,0 @@
1
- import{b as a}from"./chunk-X6ONZGRY.js";import"./chunk-EREQZWGI.js";import"./chunk-P23JOPR5.js";import"./chunk-IOJVF52Q.js";import"./chunk-U7GH4VME.js";import"./chunk-33ZVZOSC.js";import"./chunk-PZOQV6MU.js";import"./chunk-FCDWCQYC.js";import"./chunk-XDOKFAE6.js";import"./chunk-Y6HL2IY2.js";import"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-3VUPVXAV.js";import"./chunk-RV6UAUK2.js";import"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
@@ -1 +0,0 @@
1
- import{a}from"./chunk-C3GYAKIU.js";import"./chunk-5DZJCFNQ.js";import"./chunk-YLPQLD2A.js";import"./chunk-POCDWUD3.js";import"./chunk-ORMQJAQE.js";import"./chunk-RFNIGJOL.js";import"./chunk-7QDT6DO7.js";import"./chunk-6PG3AS3G.js";import"./chunk-X6ONZGRY.js";import"./chunk-EREQZWGI.js";import"./chunk-P23JOPR5.js";import"./chunk-IOJVF52Q.js";import"./chunk-U7GH4VME.js";import"./chunk-3NCMYTNG.js";import"./chunk-33ZVZOSC.js";import"./chunk-VOKEZHAH.js";import"./chunk-57GPGWSK.js";import"./chunk-PZOQV6MU.js";import"./chunk-FCDWCQYC.js";import"./chunk-XDOKFAE6.js";import"./chunk-Y6HL2IY2.js";import"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-3VUPVXAV.js";import"./chunk-RV6UAUK2.js";import"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
@@ -1 +0,0 @@
1
- import{a,b,c,d,e,f,g,h,i}from"./chunk-BYP4KVB3.js";import"./chunk-P6C3PNMQ.js";import"./chunk-XDOKFAE6.js";import"./chunk-Y6HL2IY2.js";import"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.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};
File without changes
File without changes
File without changes