@tinkerlandai/longplay-sdk 0.10.41 → 0.10.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -3
- package/README.md +1 -0
- package/dist/check-response-OIBVUP72.js +1 -0
- package/dist/{chunk-P6XQC7GG.js → chunk-2EVGXJ4R.js} +1 -1
- package/dist/{chunk-EECTJHI6.js → chunk-3SXPCVIP.js} +1 -1
- package/dist/{chunk-6OVMC5BT.js → chunk-3WTVQ6OV.js} +1 -1
- package/dist/{chunk-MYDMOAKX.js → chunk-5JRBCW6V.js} +1 -1
- package/dist/{chunk-VJHURKRY.js → chunk-5TJISOWN.js} +1 -1
- package/dist/{chunk-2RUJXZCO.js → chunk-67SIVUOS.js} +1 -1
- package/dist/{chunk-S4P4UUUF.js → chunk-6XRXHFM6.js} +1 -1
- package/dist/{chunk-KINNES62.js → chunk-7MYS52FL.js} +1 -1
- package/dist/{chunk-W3J2SIPY.js → chunk-ABXCDVC7.js} +1 -1
- package/dist/{chunk-OEONV3JY.js → chunk-AC53CUJE.js} +1 -1
- package/dist/{chunk-4B4RB36N.js → chunk-ANXDWUPK.js} +1 -1
- package/dist/{chunk-W35FZWGG.js → chunk-AQONMY2H.js} +1 -1
- package/dist/{chunk-5PNH2FPI.js → chunk-ASL7TJFU.js} +1 -1
- package/dist/{chunk-H26F3IOI.js → chunk-AV2WZSII.js} +1 -1
- package/dist/chunk-B4AELNLE.js +1 -0
- package/dist/{chunk-CQRSMCCG.js → chunk-C4NG6RVA.js} +1 -1
- package/dist/{chunk-NFY7DKVJ.js → chunk-CALDEF4M.js} +1 -1
- package/dist/{chunk-24Z3THUR.js → chunk-CSLTAXC7.js} +1 -1
- package/dist/{chunk-HGH2X6QM.js → chunk-CWD36SJO.js} +1 -1
- package/dist/{chunk-OAAS5LJY.js → chunk-DCZWNTG2.js} +1 -1
- package/dist/{chunk-GXADA7OV.js → chunk-DGZCD3AY.js} +1 -1
- package/dist/{chunk-SYHMHKFQ.js → chunk-FTGRTYBL.js} +1 -1
- package/dist/{chunk-EOPKOAR5.js → chunk-HLCDAU5A.js} +1 -1
- package/dist/{chunk-EJSDOSP5.js → chunk-HTXB2WVI.js} +1 -1
- package/dist/chunk-JWTA2OCB.js +1 -0
- package/dist/{chunk-VWRQBQZD.js → chunk-KEF6HIFK.js} +1 -1
- package/dist/{chunk-7IVLNV5H.js → chunk-KP4QI4RX.js} +1 -1
- package/dist/{chunk-26UXCYBP.js → chunk-LSVTH3TS.js} +1 -1
- package/dist/{chunk-2XF34Q6D.js → chunk-LUGZNBIW.js} +1 -1
- package/dist/{chunk-DPEMW2FO.js → chunk-LZ3OJYBY.js} +1 -1
- package/dist/{chunk-QJMM37CB.js → chunk-MEDW4N3F.js} +1 -1
- package/dist/{chunk-2LERKK7O.js → chunk-MPD3UIY4.js} +1 -1
- package/dist/{chunk-Y2HXKANG.js → chunk-MWICFZUF.js} +1 -1
- package/dist/{chunk-EON4IKWR.js → chunk-NVF54BDR.js} +1 -1
- package/dist/{chunk-2P2YSNYU.js → chunk-O6CUNETH.js} +1 -1
- package/dist/chunk-OXXPMJRJ.js +1 -0
- package/dist/{chunk-AQQJPP3P.js → chunk-P6TNBX2S.js} +1 -1
- package/dist/{chunk-6EBS6MLW.js → chunk-PBZSOTKZ.js} +1 -1
- package/dist/{chunk-756SIMZF.js → chunk-QHWR5UHD.js} +1 -1
- package/dist/{chunk-RQTYIUWP.js → chunk-RDUKCMST.js} +1 -1
- package/dist/{chunk-6STWY5GX.js → chunk-RJY5CUTB.js} +1 -1
- package/dist/chunk-S7A3IBAF.js +10 -0
- package/dist/{chunk-FTVNGN6Z.js → chunk-SVLEVNHP.js} +1 -1
- package/dist/{chunk-G6CWZBT5.js → chunk-TL67SYPH.js} +1 -1
- package/dist/{chunk-O3HLNU6T.js → chunk-UJMP7AMY.js} +1 -1
- package/dist/{chunk-TGPZJ5A7.js → chunk-V65FSNYO.js} +1 -1
- package/dist/{chunk-2LUVO7GM.js → chunk-ZICZN6WO.js} +1 -1
- package/dist/{content-XYUJFGY2.js → content-KSIF5AXD.js} +1 -1
- package/dist/{funnel-host-purchase-BNS3242X.js → funnel-host-purchase-YNC4LQJS.js} +1 -1
- package/dist/funnel-paywall-prerender-DAAQUEEZ.js +1 -0
- package/dist/funnel-route-prediction-XGCMCIKA.js +1 -0
- package/dist/funnel-route-source-O76QSUYU.js +1 -0
- package/dist/funnel-runtime-host-WPU42YVT.js +1 -0
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-FB63H7NE.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-YSFIINLK.js +1 -0
- package/dist/page.js +1 -1
- package/dist/paywall-PZ4BBEFG.js +1 -0
- package/dist/paywall-content-5IWLT7YD.js +1 -0
- package/dist/paywall-session-K7GPR3UF.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-RDXKWHYE.js +1 -0
- package/dist/server.js +1 -1
- package/dist/{visual-dom-7YYJQ2ZI.js → visual-dom-IN6DRNX3.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/check-response-SR3PDVGE.js +0 -1
- package/dist/chunk-ANXK3B5B.js +0 -1
- package/dist/chunk-BWRRZ2NW.js +0 -1
- package/dist/chunk-H7AHDGVU.js +0 -10
- package/dist/chunk-PYLX3WF6.js +0 -1
- package/dist/funnel-paywall-prerender-DDQI3GAZ.js +0 -1
- package/dist/funnel-route-prediction-BT5ZWU54.js +0 -1
- package/dist/funnel-route-source-7ZJMZRID.js +0 -1
- package/dist/funnel-runtime-host-3SSDNG24.js +0 -1
- package/dist/merchant-bridge-contracts-YU53UKUN.js +0 -1
- package/dist/operation-contracts-GEIGP23I.js +0 -1
- package/dist/paywall-YZAEI7TF.js +0 -1
- package/dist/paywall-content-QBSB5NA7.js +0 -1
- package/dist/paywall-session-MHBAZLS7.js +0 -1
- package/dist/screen-renderer-SEJG7A2C.js +0 -1
- /package/dist/{chunk-2ULWP26K.js → chunk-GPJF3T43.js} +0 -0
- /package/dist/{chunk-4PGYQ2TI.js → chunk-RA7GZ67U.js} +0 -0
- /package/dist/{chunk-PBBREFS5.js → chunk-WPFTSHP2.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as C,j as J}from"./chunk-HGH2X6QM.js";import{b as X}from"./chunk-EECTJHI6.js";import{j as K,l as E}from"./chunk-S4P4UUUF.js";import{b as e}from"./chunk-2ULWP26K.js";var Y=e.number().int().min(0).max(1e8),V=e.strictObject({kind:e.enum(["graduated","volume"]),tiers:e.array(e.strictObject({upTo:e.number().int().min(1).max(1e4).nullable(),unitAmountMinor:Y,flatAmountMinor:Y.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 M(t,n){if(!Number.isInteger(n)||n<0||n>1e4)throw new Error("Invalid purchased pack quantity");let i=t.pricing?V.parse(t.pricing):void 0;if(n===0)return 0;let r=0n,o=0;if(!i)r=BigInt(t.amountMinor)*BigInt(n);else for(let a of i.tiers){let s=a.upTo??1e4;if(i.kind==="volume"){if(n<=s){r=BigInt(n)*BigInt(a.unitAmountMinor)+BigInt(a.flatAmountMinor??0);break}}else n>o&&(r+=BigInt(Math.min(n,s)-o)*BigInt(a.unitAmountMinor));o=s}if(r>200000000n)throw new Error("Purchased price exceeds the payment amount limit");return Number(r)}function wt(t){return M({amountMinor:t.unitAmountMinor,...t.pricing?{pricing:t.pricing}:{}},t.quantity)}var ve=K.refine(t=>/[1-9]/.test(t)),te=e.strictObject({units:ve,prices:e.array(e.strictObject({currency:C,amountMinor:e.number().int().min(0).max(1e8),pricing:V.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&&M({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 ee(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 Ot(t,n,i){if(!Number.isSafeInteger(i)||i<0||i>1e4)throw new Error("Invalid purchased quantity");let r=ee(t)+ee(n)*BigInt(i);if(r>999999999999999999n)throw new Error("Purchased allowance exceeds the ledger quantity limit");let o=(r%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return(r/1000000n).toString()+(o?"."+o:"")}var ne=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:te});var _e=["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"],T=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(),re=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(),Et=e.object({paywall:J.optional(),nodes:e.record(e.string(),e.object({base:re,picker:e.string().optional(),byPlan:e.record(e.string(),re).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(ne).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 ie(t){return[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].flatMap(n=>n[1]===void 0?[]:[n[1].trim()])}function Z(t){let n=ie(t).filter(r=>!_e.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 Vt(t,n,i={}){let r=t?.nodes[n];if(!r)return;let o=r.picker?i[r.picker]??t?.pickers[r.picker]?.selected:void 0;return typeof o=="string"?r.byPlan?.[o]??r.base:r.base}var Ne=["credit_balance","credit_transactions","membership","billing","billing_controls","customer_plans","credit_packs","credit_pack_orders","offer_history"],oe=e.enum(Ne),ae=e.object({source:oe,layout:e.enum(["full","compact"]),resourceKey:E.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"})}),x=e.string().max(2e3),se=e.object({id:e.string().max(100),label:x,detail:e.array(x).max(12),value:x.optional(),status:x.optional(),facts:e.array(e.object({label:x,value:x}).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:x})).max(1).optional(),membershipActions:e.array(e.object({value:e.string().max(100),label:x}).strict()).max(3).optional()}).strict(),Pe=e.object({key:E,name:x,spendable:x,reserved:x,available:x,expiry:x.nullable(),sources:e.array(se).max(50),sourceCount:e.number().int().nonnegative(),sourcePage:e.number().int().positive(),hasNextSources:e.boolean(),hasPreviousSources:e.boolean()}).strict(),Oe=e.object({source:oe,status:e.enum(["idle","loading","ready","error"]),stale:e.boolean(),preview:e.boolean(),errorCode:e.string().max(80).optional(),errorMessage:x.optional(),resources:e.array(Pe).max(500),rows:e.array(se).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:x,note:x,facts:e.array(e.object({label:x,value:x}).strict()).max(100)}).strict().optional(),membershipResult:x.optional()}).strict(),Qt=e.object({nodes:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Oe)}).strict(),Ft=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();function ce(t){return t.type==="stack"&&t.interaction?.type==="select"&&t.interaction.purpose==="product"&&!!t.interaction.pickerId}function le(t){let n={};function i(r){if(ce(r)){let o=n[r.interaction.pickerId]??={ids:[],defaultId:null};for(let s of r.children){let l=s.type==="stack"?s.bind?.plan:void 0;l&&!o.ids.includes(l)&&o.ids.push(l)}let a=r.children[r.interaction.defaultIndex];!o.defaultId&&a?.type==="stack"&&(o.defaultId=a.bind?.plan??null)}r.type==="stack"&&r.children.forEach(i)}return t.pages.forEach(r=>i(r.root)),n}function pe(t,n,i){let r={};function o(u){if(u.hidden)return;if(u.type==="plan_picker"){let b=i.pickers[u.id];r[u.id]={ids:b?.options??[],defaults:b?.selected?[b.selected]:[],remembered:[]};return}if(u.type!=="stack")return;let y=u.children.filter(b=>!b.hidden),c=u.interaction;if(ce(u)){let b=r[u.interaction.pickerId]??={ids:[],defaults:[],remembered:[]},k=i.pickers[u.interaction.pickerId]?.options??[];for(let p of y){let d=p.type==="stack"?p.bind?.plan:void 0;d&&k.includes(d)&&!b.ids.includes(d)&&b.ids.push(d),d&&p.id===n[u.id]&&b.remembered.push(d)}let m=u.children[u.interaction.defaultIndex];m?.type==="stack"&&!m.hidden&&m.bind?.plan&&b.defaults.push(m.bind.plan)}if(c?.type==="tabs"){let b=y.find(k=>k.id===n[u.id])??u.children[c.defaultIndex];b&&o(b)}else if(c?.type==="toggle"){let b=typeof n[u.id]=="boolean"?n[u.id]:c.defaultEnabled,k=u.children[b?0:1];k&&o(k)}else y.forEach(o)}let a=typeof n.__page=="string"?n.__page:t.initialPageId??t.pages[0]?.id,s=t.pages.find(u=>u.id===a);s&&o(s.root);let l={};for(let[u,y]of Object.entries(r)){let c=n[u],b=y.remembered[0]??(y.ids.includes(i.pickers[u]?.selected??"")?i.pickers[u]?.selected:y.defaults[0]);l[u]=typeof c=="string"?y.ids.includes(c)?c:"":b&&y.ids.includes(b)?b:""}for(let u of Object.keys(le(t)))l[u]??="";return l}var ue=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),me=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 fe(t,n){return t.assignments.length===n.length&&t.assignments.every(i=>n.includes(i.productVersionId))}function Jt(t){let n=Z(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 o=t.indexOf("-->",i+4);i=o<0?t.length:o+2}else{let o="";for(i++;i<t.length;i++){let a=t[i];if(o)a===o&&(o="");else if(a==='"'||a==="'")o=a;else if(a===">")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 h={state:32,enumValues:64,derived:96,bindings:256,controls:64,timers:4,effects:8,depth:12,expressionNodes:2e3},ge=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),S=e.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/).refine(t=>!ge.has(t),"Reserved UI identifier"),B=e.union([e.string().max(2e3),e.number().finite(),e.boolean(),e.null()]),Ae=e.discriminatedUnion("type",[e.strictObject({type:e.literal("enum"),values:e.array(B).min(1).max(h.enumValues),default:B}),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 D(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 Ce=Ae.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"}),D(t,t.default)||n.addIssue({code:"custom",path:["default"],message:"UI default must match its state definition"})}),$e=["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 Ue(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 N=e.lazy(()=>e.union([B,e.strictObject({ref:S}),e.strictObject({op:e.enum($e),args:e.array(N).max(h.expressionNodes)}).superRefine((t,n)=>{Ue(t.op,t.args.length)||n.addIssue({code:"custom",path:["args"],message:"Invalid UI expression arity"})})]));function j(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let n=Object.getPrototypeOf(t);return n===null||n===Object.prototype}function _(t,n,i){if(!t||typeof t!="object")return!0;if(!j(t))return n.addIssue({code:"custom",path:i,message:"UI objects must be plain data"}),!1;for(let r of Object.keys(t)){if(ge.has(r))return n.addIssue({code:"custom",path:[...i,r],message:"Reserved UI object key"}),!1;let o=Object.getOwnPropertyDescriptor(t,r);if(o&&!Object.hasOwn(o,"value"))return n.addIssue({code:"custom",path:[...i,r],message:"UI objects cannot contain accessors"}),!1}return!0}function O(t,n,i,r){let o=[{value:t,depth:1,path:i}];for(;o.length;){let a=o.pop();if(++r.nodes>h.expressionNodes||a.depth>h.depth){n.addIssue({code:"custom",path:a.path,message:"UI expression budget exceeded"});return}if(!_(a.value,n,a.path))return;if(j(a.value)&&Array.isArray(a.value.args)){if(a.value.args.length>h.expressionNodes){n.addIssue({code:"custom",path:[...a.path,"args"],message:"UI expression budget exceeded"});return}for(let s=a.value.args.length-1;s>=0;s--)o.push({value:a.value.args[s],depth:a.depth+1,path:[...a.path,"args",s]})}}}var en=e.unknown().superRefine((t,n)=>{O(t,n,[],{nodes:0})}).pipe(N),Q=e.record(S,N).refine(t=>Object.keys(t).length>0&&Object.keys(t).length<=h.state,"UI assignments need 1\u201332 state keys"),Le=e.strictObject({target:S,property:e.enum(["text","visible","disabled","checked","value","class","aria-label","aria-selected","aria-checked","aria-valuetext","tabindex"]),expression:N,className:S.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"})}),Te=e.discriminatedUnion("type",[e.strictObject({type:e.literal("scroll_latch"),target:S,state:S}),e.strictObject({type:e.literal("input"),target:S,state:S,set:Q.optional()}),e.strictObject({type:e.literal("action"),target:S,set:Q}),e.strictObject({type:e.literal("carousel"),target:S,state:S,initialIndex:e.number().int().nonnegative().optional(),maxWidth:e.number().int().min(1).max(1e4).optional(),previousTarget:S.optional(),nextTarget:S.optional(),inactiveTargets:e.array(S).max(20).optional(),inactiveMaxWidth:e.number().int().min(1).max(1e4).optional()})]),De=e.strictObject({afterMs:e.number().int().min(0).max(6e4),set:Q}),Re=e.strictObject({type:e.literal("mosaic_waves"),target:S,color:e.string().regex(/^#[0-9a-fA-F]{6}$/),hotColor:e.string().regex(/^#[0-9a-fA-F]{6}$/),enabled:N.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()}),Ee=e.strictObject({type:e.literal("number_counter"),target:S,value:N,prefix:e.string().max(20).optional(),format:e.enum(["number","short"]).optional()}),Ve=e.strictObject({state:e.record(S,Ce).refine(t=>Object.keys(t).length<=h.state,"Too many UI state keys").optional(),derived:e.record(S,N).refine(t=>Object.keys(t).length<=h.derived,"Too many UI derived keys").optional(),bindings:e.array(Le).max(h.bindings).optional(),controls:e.array(Te).max(h.controls).optional(),timers:e.array(De).max(h.timers).optional(),effects:e.array(e.discriminatedUnion("type",[Re,Ee])).max(h.effects).optional(),clock:e.boolean().optional()});function Me(t,n){if(!_(t,n,[])||!j(t))return;for(let[r,o]of[["state",h.state],["derived",h.derived]]){let a=t[r];if(!_(a,n,[r]))return;if(j(a)&&Object.keys(a).length>o){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}}for(let[r,o]of[["bindings",h.bindings],["controls",h.controls],["timers",h.timers],["effects",h.effects]])if(Array.isArray(t[r])&&t[r].length>o){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}if(Array.isArray(t.effects)){for(let[r,o]of t.effects.entries())if(!_(o,n,["effects",r]))return}if(j(t.state))for(let[r,o]of Object.entries(t.state)){if(!_(o,n,["state",r]))return;if(j(o)&&Array.isArray(o.values)&&o.values.length>h.enumValues){n.addIssue({code:"custom",path:["state",r,"values"],message:"Too many UI enum values"});return}}let i={nodes:0};if(j(t.derived))for(let[r,o]of Object.entries(t.derived))O(o,n,["derived",r],i);for(let r of["bindings","controls","timers"]){let o=t[r];if(Array.isArray(o)){for(let[a,s]of o.entries())if(!(!_(s,n,[r,a])||!j(s))){if(r==="bindings")O(s.expression,n,[r,a,"expression"],i);else if(_(s.set,n,[r,a,"set"])&&j(s.set)){if(Object.keys(s.set).length>h.state){n.addIssue({code:"custom",path:[r,a,"set"],message:"Too many UI assignments"});return}for(let[l,u]of Object.entries(s.set))O(u,n,[r,a,"set",l],i)}if(i.nodes>h.expressionNodes)return}}}if(Array.isArray(t.effects))for(let[r,o]of t.effects.entries())j(o)&&o.type==="number_counter"?O(o.value,n,["effects",r,"value"],i):j(o)&&o.enabled!==void 0&&O(o.enabled,n,["effects",r,"enabled"],i)}function de(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 be=e.unknown().superRefine(Me).pipe(Ve).superRefine((t,n)=>{let i=t.state??{},r=t.derived??{},o=new Set([...Object.keys(i),...Object.keys(r)]),a=(m,p)=>{for(let d of de(m))o.has(d)||n.addIssue({code:"custom",path:p,message:`Unknown UI reference: ${d}`})};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"}),a(p,["derived",m]);let s=new Set,l=new Set,u=m=>{if(s.has(m))return!1;if(l.has(m))return!0;s.add(m);for(let p of de(r[m]))if(Object.hasOwn(r,p)&&!u(p))return!1;return s.delete(m),l.add(m),!0};for(let m of Object.keys(r))if(!u(m)){n.addIssue({code:"custom",path:["derived",m],message:"Cyclic UI derived references"});break}for(let[m,p]of(t.bindings??[]).entries())a(p.expression,["bindings",m,"expression"]);let y=new Set;for(let[m,p]of(t.effects??[]).entries())y.has(p.target)&&n.addIssue({code:"custom",path:["effects",m,"target"],message:"Effect targets must be unique"}),y.add(p.target),p.type==="number_counter"?(a(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&&a(p.enabled,["effects",m,"enabled"]);let c=(m,p)=>{for(let[d,v]of Object.entries(m))Object.hasOwn(i,d)||n.addIssue({code:"custom",path:[...p,d],message:"UI assignments can only update declared state"}),a(v,[...p,d])},b=new Set,k=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 d of p.inactiveTargets??[])(d===p.target||k.has(d))&&n.addIssue({code:"custom",path:["controls",m,"inactiveTargets"],message:"Inactive article targets must have one carousel owner"}),k.add(d);if(p.type==="carousel")for(let d of["previousTarget","nextTarget"]){let v=p[d];v!==void 0&&((v===p.target||b.has(v)||(t.controls??[]).some(ze=>ze.target===v))&&n.addIssue({code:"custom",path:["controls",m,d],message:"Carousel navigation needs a distinct, exclusive button target"}),b.add(v))}if(p.type!=="action"){let d=Object.hasOwn(i,p.state)?i[p.state]:void 0;(!d||p.type==="input"&&d.type==="enum"&&d.values.some(v=>typeof v!="string"))&&n.addIssue({code:"custom",path:["controls",m,"state"],message:"Control needs a supported declared UI state"}),p.type==="carousel"&&(d?.type!=="number"||!Number.isInteger(d.min)||d.min<0||!Number.isInteger(d.max)||d.step!==1||p.initialIndex!==void 0&&!D(d,p.initialIndex))&&n.addIssue({code:"custom",path:["controls",m],message:"Carousel needs bounded nonnegative integer index state"}),p.type==="scroll_latch"&&d?.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&&c(p.set,["controls",m,"set"])}for(let[m,p]of(t.timers??[]).entries())c(p.set,["timers",m,"set"])});var he=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,A=e.string().max(16).regex(he,"\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 F(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:o}=new Intl.Locale(n),a=[i,r,o].filter(Boolean).join("-");return he.test(a)?a:null}catch{return null}}var Ze=new Set(["TW","HK","MO"]);function ye(t){let[n,i,r]=t.split("-");if(n!=="zh")return`${n}-${new Intl.Locale(t).maximize().script??""}`;let o=i?.length===4?i:void 0,a=i?.length===4?r:i;return o?`zh-${o}`:a&&Ze.has(a)?"zh-Hant":"zh-Hans"}function xe(t,n,i){let r=n.map(o=>({code:A.parse(o),normalized:o}));for(let o of t){let a=F(o);if(!a)continue;let s=r.find(c=>c.normalized===a);if(s)return s.code;let l=ye(a),u=r.filter(c=>ye(c.normalized)===l),y=u.find(c=>!c.normalized.includes("-")||c.normalized===l)??u[0];if(y)return y.code}return i}var Be=4,z={nodes:150,depth:8,children:50,locales:20,actions:40,pages:10,stringLength:2e3,customHtml:32768,customCss:32768,documentBytes:2e5},U=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),g=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Qe=e.enum(["none","xs","sm","md","lg","xl"]),Fe=e.enum(["none","sm","md","lg","full"]),H=e.string().regex(/^#[0-9a-fA-F]{6}$/),G=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"),q=e.union([G,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}$/)]),Se=e.object({primary:H,background:H,text:H,radius:Fe,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:G,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(),L=e.union([e.enum(["primary","text","muted","background","surface"]),e.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)]),f=(t,n)=>e.number().int().min(t).max(n),ke=e.union([e.enum(["fit","fill"]),f(1,1200)]),He=e.object({top:f(0,200),right:f(0,200),bottom:f(0,200),left:f(0,200)}).strict(),qe=e.object({top:f(-100,200),right:f(-100,200),bottom:f(-100,200),left:f(-100,200)}).strict(),Ie=e.object({x:f(0,100),y:f(0,100)}).strict(),Ge=e.discriminatedUnion("type",[e.object({type:e.literal("color"),color:L}).strict(),e.object({type:e.literal("linear"),angle:f(0,360),stops:e.array(e.object({color:L,at:f(0,100)}).strict()).min(2).max(4)}).strict(),e.object({type:e.literal("image"),src:q,fit:e.enum(["cover","contain"]),position:Ie.optional()}).strict()]),We=e.discriminatedUnion("type",[e.object({type:e.literal("rect"),radius:e.union([f(0,200),e.object({topLeft:f(0,200),topRight:f(0,200),bottomRight:f(0,200),bottomLeft:f(0,200)}).strict()])}).strict(),e.object({type:e.literal("pill")}).strict()]),Ke=e.object({width:f(0,12),color:L,style:e.enum(["solid","dashed"])}).strict(),Je=e.object({x:f(-40,40),y:f(-40,40),blur:f(0,80),spread:f(-20,40),color:L}).strict(),Xe=e.object({font:e.enum(["system","serif","rounded","mono"]),size:f(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:L,align:e.enum(["start","center","end"]),italic:e.boolean(),decoration:e.enum(["none","underline","line-through"]),transform:e.enum(["none","uppercase"])}).strict().partial(),P=e.object({width:ke,height:ke,padding:He,margin:qe,gap:f(0,120),grow:e.union([e.boolean(),e.number().min(0).max(12)]),background:Ge,opacity:e.number().min(0).max(1),clipContent:e.boolean(),shape:We,border:Ke,shadow:Je,text:Xe}).strict().partial(),I={id:U,name:e.string().trim().min(1).max(60).optional(),hidden:e.boolean().optional(),style:P.optional(),fallback:g.optional()},Ye=e.object({...I,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:g,variant:e.enum(["title","heading","body","caption"])}).strict(),et=e.object({...I,type:e.literal("image"),src:q,localizedSrc:e.record(A,q).optional(),alt:g,aspect:e.enum(["auto","1:1","4:3","16:9","3:1"]),fit:e.enum(["cover","contain"]),position:Ie.optional()}).strict(),tt=e.object({...I,type:e.literal("button"),label:g,variant:e.enum(["primary","secondary","link"]),action:g,purpose:e.enum(["purchase","navigation","close"]).optional(),bind:T.optional()}).strict(),nt=e.object({...I,type:e.literal("divider")}).strict(),rt=e.object({...I,type:e.literal("customer_data"),title:g,data:ae}).strict(),it=e.object({...I,type:e.literal("spacer"),size:Qe}).strict(),ot=e.object({...I,type:e.literal("custom_html"),html:e.record(A,e.string().max(z.customHtml)),css:e.string().max(z.customCss),ui:be.optional()}).strict(),at=e.object({...I,type:e.literal("price"),fallback:g,parts:e.object({current:P.optional(),original:P.optional(),period:P.optional()}).strict().optional()}).strict(),st=e.object({...I,type:e.literal("coupon_code"),label:g,fallback:g}).strict(),ct=e.object({...I,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:g,fallback:g}).strict().refine(t=>t.source!=="fixed"||!!t.at,"\u56FA\u5B9A\u5012\u8BA1\u65F6\u9700\u8981\u7ED3\u675F\u65F6\u95F4"),lt=e.object({...I,type:e.literal("plan_picker"),label:g,fallback:g,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:me.safeExtend({monthLabel:g,yearLabel:g,unavailableLabel:g}).optional(),states:e.object({selected:P.optional()}).strict().optional()}).strict().superRefine((t,n)=>{t.grouping&&(!t.planIds||!fe(t.grouping,t.planIds))&&n.addIssue({code:"custom",message:"Grouped picker assignments must match its product allowlist"})}),pt=e.object({...I,type:e.literal("quantity_picker"),bind:T.optional(),label:g,fallback:g,internalFeatureId:e.uuid(),minimumQuantity:f(0,1e4),maximumQuantity:f(0,1e4),defaultQuantity:f(0,1e4),step:f(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"),ut=e.discriminatedUnion("type",[e.object({type:e.literal("input"),label:g,keyboard:e.enum(["text","email","tel","url"]),maxLength:f(1,500)}).strict(),e.object({type:e.literal("multiselect"),label:g,min:f(0,50),max:f(1,50)}).strict(),e.object({type:e.literal("select"),label:g,defaultIndex:f(0,49),purpose:e.enum(["option","product","tier"]).optional(),pickerId:U.optional(),selectedStyle:P.optional()}).strict(),e.object({type:e.literal("tabs"),label:g,defaultIndex:f(0,49),purpose:e.literal("tier").optional()}).strict(),e.object({type:e.literal("toggle"),label:g,defaultEnabled:e.boolean()}).strict(),e.object({type:e.literal("carousel"),label:g}).strict()]),w={...I,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:f(0,19),period:e.enum(["month","year"]).optional(),requireBinding:e.boolean().optional()}).strict().optional(),interaction:ut.optional(),states:e.object({selected:P.optional()}).strict().optional(),purpose:e.literal("benefits").optional(),purchaseAction:g.optional(),buttonVariant:e.enum(["primary","secondary","link"]).optional(),bind:T.optional()},je=e.lazy(()=>e.object({...I,type:w.type,direction:w.direction,align:w.align,justify:w.justify,children:e.array(mt).max(z.children),productSlot:w.productSlot,interaction:w.interaction,states:w.states,purpose:w.purpose,purchaseAction:w.purchaseAction,buttonVariant:w.buttonVariant,bind:w.bind}).strict()),mt=e.lazy(()=>e.union([je,Ye,et,tt,nt,it,ot,at,st,ct,lt,pt,rt])),ft=e.union([e.string().max(500),e.number().finite(),e.boolean(),e.null()]),$={id:g,event:g,properties:e.record(g,ft).refine(t=>Object.keys(t).length<=20,"\u6700\u591A 20 \u4E2A\u53C2\u6570")},dt=e.discriminatedUnion("type",[e.object({...$,type:e.literal("navigate"),close:e.literal(!1),pageId:U}).strict(),e.object({...$,type:e.literal("event"),close:e.boolean()}).strict(),e.object({...$,type:e.literal("close"),close:e.literal(!0)}).strict(),e.object({...$,type:e.literal("open_url"),close:e.boolean(),url:G}).strict(),e.object({...$,type:e.literal("claim_offer"),close:e.boolean(),couponId:e.uuid()}).strict()]),gt=e.object({defaultLocale:A,locales:e.record(A,e.record(g,e.string().max(z.stringLength)))}).strict(),bt=e.enum(["popup","paywall","onboarding","page","banner"]);var yt=e.object({kind:e.literal("screen"),schemaVersion:e.literal(Be),name:e.string().trim().min(1).max(80),surface:bt,initialPageId:U.optional(),presentation:X,theme:Se,pages:e.array(e.object({id:U,name:e.string().trim().min(1).max(60),root:je,theme:Se.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(z.pages),strings:gt,actions:e.array(dt).max(z.actions)}).strict();function R(t,n){for(let i of t.pages)W(i.root,n)}var dn=yt.superRefine((t,n)=>{let i=z;t.surface!=="paywall"&&t.pages.length!==1&&n.addIssue({code:"custom",message:"Only a Paywall can contain multiple screens"}),t.initialPageId&&!t.pages.some(c=>c.id===t.initialPageId)&&n.addIssue({code:"custom",message:"Initial screen does not exist"});for(let c of t.actions)c.type==="navigate"&&(t.surface!=="paywall"||!t.pages.some(b=>b.id===c.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=c=>n.addIssue({code:"custom",message:c}),o=Object.keys(t.strings.locales);o.includes(t.strings.defaultLocale)||r("\u9ED8\u8BA4\u8BED\u8A00\u5FC5\u987B\u5728\u8BED\u8A00\u5217\u8868\u91CC"),o.length>z.locales&&r(`\u6700\u591A ${z.locales} \u79CD\u8BED\u8A00`);let a=new Set;for(let c of t.actions)a.has(c.id)&&r(`\u52A8\u4F5C\u6807\u8BC6\u91CD\u590D\uFF1A${c.id}`),a.add(c.id);let s=new Set;for(let c of t.pages)["next","back"].includes(c.id)&&r(`\u9875\u9762 id \u4E0D\u80FD\u4F7F\u7528\u4FDD\u7559\u540D\u79F0\uFF1A${c.id}`),s.has(c.id)&&r(`\u9875\u9762 id \u91CD\u590D\uFF1A${c.id}`),s.add(c.id);let l=new Set,u=0,y=!1;R(t,(c,b)=>{if(u++,b>z.depth&&(y=!0),l.has(c.id)&&r(`\u7EC4\u4EF6 id \u91CD\u590D\uFF1A${c.id}`),l.add(c.id),c.type==="button"&&!a.has(c.action)&&r(`\u6309\u94AE ${c.id} \u5F15\u7528\u7684\u52A8\u4F5C\u4E0D\u5B58\u5728\uFF1A${c.action}`),c.type==="custom_html")for(let k of Object.keys(c.html))o.includes(k)||r(`\u81EA\u5B9A\u4E49 HTML ${c.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${k}`);if(c.type==="image")for(let k of Object.keys(c.localizedSrc??{}))o.includes(k)||r(`\u56FE\u7247 ${c.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${k}`)}),u>i.nodes&&r(`\u7EC4\u4EF6\u6700\u591A ${i.nodes} \u4E2A`),y&&r(`\u5C42\u7EA7\u6700\u591A ${z.depth} \u5C42`)});function W(t,n,i=1,r=null){if(n(t,i,r)!==!1&&t.type==="stack")for(let o of t.children)W(o,n,i+1,t)}function we(t){let n=[],i=new Set;return R(t,r=>{let o=(a,s,l)=>{i.has(a)||(i.add(a),n.push({key:a,nodeId:r.id,nodeType:r.type,field:s,required:l}))};r.type==="stack"&&r.interaction&&o(r.interaction.label,"label",!0),r.fallback&&o(r.fallback,"text",!0),r.type==="text"&&o(r.text,"text",!0),r.type==="customer_data"&&o(r.title,"title",!0),(r.type==="plan_picker"||r.type==="quantity_picker"||r.type==="coupon_code")&&o(r.label,"label",!0),r.type==="plan_picker"&&r.grouping&&(o(r.grouping.monthLabel,"label",!0),o(r.grouping.yearLabel,"label",!0),o(r.grouping.unavailableLabel,"text",!0)),r.type==="countdown"&&o(r.expired,"text",!0),r.type==="button"&&o(r.label,"label",!0),r.type==="image"&&(o(`image:${r.id}`,"src",!1),o(r.alt,"alt",!1)),r.type==="custom_html"&&o(`html:${r.id}`,"html",!0)}),n}function ht(t,n,i){if(n.field==="html"){let r;return R(t,o=>{o.id===n.nodeId&&o.type==="custom_html"&&(r=o.html[i])}),r}if(n.field==="src"){let r=It(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 xt(t){let n=we(t).filter(r=>r.required);return Object.keys(t.strings.locales).sort((r,o)=>r===t.strings.defaultLocale?-1:o===t.strings.defaultLocale?1:0).map(r=>{let o=n.filter(a=>!ht(t,a,r)?.trim()).map(a=>a.key);return{locale:r,total:n.length,filled:n.length-o.length,missing:o,complete:o.length===0}})}function St(t){return xt(t).filter(n=>n.complete||n.locale===t.strings.defaultLocale).map(n=>n.locale)}function gn(t,n){return xe(n,St(t),t.strings.defaultLocale)}function bn(t,n){let i=t.strings.locales[n]??{},r=t.strings.locales[t.strings.defaultLocale]??{},o={};for(let s of we(t)){if(s.field==="html"||s.field==="src")continue;let l=i[s.key]?.trim()?i[s.key]:r[s.key];l!==void 0&&(o[s.key]=l)}let a=s=>{if(s.type==="stack")return{...s,children:s.children.map(a)};if(s.type==="custom_html"){let l=s.html[n]?.trim()?s.html[n]:s.html[t.strings.defaultLocale];return{...s,html:l===void 0?{}:{[n]:l}}}if(s.type==="image"){let{localizedSrc:l,...u}=s;return{...u,src:l?.[n]??l?.[t.strings.defaultLocale]??s.src}}return s};return{...t,pages:t.pages.map(s=>({...s,root:a(s.root)})),strings:{defaultLocale:n,locales:{[n]:o}}}}function kt(t,n){let i=null;return W(t,r=>{if(i)return!1;r.id===n&&(i=r)}),i}function It(t,n){for(let i of t.pages){let r=kt(i.root,n);if(r)return r}return null}function yn(t){let n=F(t)?.split("-")[0];return n!==void 0&&["ar","he","fa","ur"].includes(n)}function hn(t,n,i){let r={};if(!n||typeof n!="object"||Array.isArray(n))return r;let o=n;if(R(t,a=>{if(a.type==="quantity_picker"){let l=o[a.id];typeof l=="number"&&Number.isSafeInteger(l)&&l>=a.minimumQuantity&&l<=a.maximumQuantity&&(l-a.minimumQuantity)%a.step===0&&(r[a.id]=l);return}if(a.type==="plan_picker"){let l=o[a.id];typeof l=="string"&&(r[a.id]=i?.pickers[a.id]?.options.includes(l)?l:"");return}if(a.type==="custom_html"&&a.ui)for(let[l,u]of Object.entries(a.ui.state??{})){let y=`${a.id}.${l}`,c=o[y];c!==null&&D(u,c)&&(r[y]=c)}if(a.type!=="stack"||!a.interaction)return;let s=Object.hasOwn(o,a.id)?o[a.id]:void 0;["select","tabs"].includes(a.interaction.type)&&typeof s=="string"&&a.children.some(l=>l.id===s)&&(r[a.id]=s),a.interaction.type==="toggle"&&typeof s=="boolean"&&(r[a.id]=s)}),t.surface==="paywall"&&typeof o.__page=="string"&&t.pages.some(a=>a.id===o.__page)&&(r.__page=o.__page),i){let a={...r};for(let[s,l]of Object.entries(o))(typeof l=="string"||typeof l=="boolean")&&(a[s]=l);Object.assign(r,pe(t,a,i))}return r}export{V as a,wt as b,te as c,Ot as d,ne as e,re as f,Et as g,ie as h,Vt as i,le as j,me as k,fe as l,Qt as m,Ft as n,Jt as o,A as p,F as q,z as r,U as s,g as t,q as u,R as v,dn as w,W as x,we as y,xt as z,gn as A,bn as B,It as C,yn as D,hn as E};
|
|
1
|
+
import{a as C,j as J}from"./chunk-CWD36SJO.js";import{b as X}from"./chunk-3SXPCVIP.js";import{j as K,l as E}from"./chunk-6XRXHFM6.js";import{b as e}from"./chunk-GPJF3T43.js";var Y=e.number().int().min(0).max(1e8),V=e.strictObject({kind:e.enum(["graduated","volume"]),tiers:e.array(e.strictObject({upTo:e.number().int().min(1).max(1e4).nullable(),unitAmountMinor:Y,flatAmountMinor:Y.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 M(t,n){if(!Number.isInteger(n)||n<0||n>1e4)throw new Error("Invalid purchased pack quantity");let i=t.pricing?V.parse(t.pricing):void 0;if(n===0)return 0;let r=0n,o=0;if(!i)r=BigInt(t.amountMinor)*BigInt(n);else for(let a of i.tiers){let s=a.upTo??1e4;if(i.kind==="volume"){if(n<=s){r=BigInt(n)*BigInt(a.unitAmountMinor)+BigInt(a.flatAmountMinor??0);break}}else n>o&&(r+=BigInt(Math.min(n,s)-o)*BigInt(a.unitAmountMinor));o=s}if(r>200000000n)throw new Error("Purchased price exceeds the payment amount limit");return Number(r)}function wt(t){return M({amountMinor:t.unitAmountMinor,...t.pricing?{pricing:t.pricing}:{}},t.quantity)}var ve=K.refine(t=>/[1-9]/.test(t)),te=e.strictObject({units:ve,prices:e.array(e.strictObject({currency:C,amountMinor:e.number().int().min(0).max(1e8),pricing:V.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&&M({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 ee(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 Ot(t,n,i){if(!Number.isSafeInteger(i)||i<0||i>1e4)throw new Error("Invalid purchased quantity");let r=ee(t)+ee(n)*BigInt(i);if(r>999999999999999999n)throw new Error("Purchased allowance exceeds the ledger quantity limit");let o=(r%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return(r/1000000n).toString()+(o?"."+o:"")}var ne=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:te});var _e=["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"],T=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(),re=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(),Et=e.object({paywall:J.optional(),nodes:e.record(e.string(),e.object({base:re,picker:e.string().optional(),byPlan:e.record(e.string(),re).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(ne).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 ie(t){return[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].flatMap(n=>n[1]===void 0?[]:[n[1].trim()])}function Z(t){let n=ie(t).filter(r=>!_e.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 Vt(t,n,i={}){let r=t?.nodes[n];if(!r)return;let o=r.picker?i[r.picker]??t?.pickers[r.picker]?.selected:void 0;return typeof o=="string"?r.byPlan?.[o]??r.base:r.base}var Ne=["credit_balance","credit_transactions","membership","billing","billing_controls","customer_plans","credit_packs","credit_pack_orders","offer_history"],oe=e.enum(Ne),ae=e.object({source:oe,layout:e.enum(["full","compact"]),resourceKey:E.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"})}),x=e.string().max(2e3),se=e.object({id:e.string().max(100),label:x,detail:e.array(x).max(12),value:x.optional(),status:x.optional(),facts:e.array(e.object({label:x,value:x}).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:x})).max(1).optional(),membershipActions:e.array(e.object({value:e.string().max(100),label:x}).strict()).max(3).optional()}).strict(),Pe=e.object({key:E,name:x,spendable:x,reserved:x,available:x,expiry:x.nullable(),sources:e.array(se).max(50),sourceCount:e.number().int().nonnegative(),sourcePage:e.number().int().positive(),hasNextSources:e.boolean(),hasPreviousSources:e.boolean()}).strict(),Oe=e.object({source:oe,status:e.enum(["idle","loading","ready","error"]),stale:e.boolean(),preview:e.boolean(),errorCode:e.string().max(80).optional(),errorMessage:x.optional(),resources:e.array(Pe).max(500),rows:e.array(se).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:x,note:x,facts:e.array(e.object({label:x,value:x}).strict()).max(100)}).strict().optional(),membershipResult:x.optional()}).strict(),Qt=e.object({nodes:e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Oe)}).strict(),Ft=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();function ce(t){return t.type==="stack"&&t.interaction?.type==="select"&&t.interaction.purpose==="product"&&!!t.interaction.pickerId}function le(t){let n={};function i(r){if(ce(r)){let o=n[r.interaction.pickerId]??={ids:[],defaultId:null};for(let s of r.children){let l=s.type==="stack"?s.bind?.plan:void 0;l&&!o.ids.includes(l)&&o.ids.push(l)}let a=r.children[r.interaction.defaultIndex];!o.defaultId&&a?.type==="stack"&&(o.defaultId=a.bind?.plan??null)}r.type==="stack"&&r.children.forEach(i)}return t.pages.forEach(r=>i(r.root)),n}function pe(t,n,i){let r={};function o(u){if(u.hidden)return;if(u.type==="plan_picker"){let b=i.pickers[u.id];r[u.id]={ids:b?.options??[],defaults:b?.selected?[b.selected]:[],remembered:[]};return}if(u.type!=="stack")return;let y=u.children.filter(b=>!b.hidden),c=u.interaction;if(ce(u)){let b=r[u.interaction.pickerId]??={ids:[],defaults:[],remembered:[]},k=i.pickers[u.interaction.pickerId]?.options??[];for(let p of y){let d=p.type==="stack"?p.bind?.plan:void 0;d&&k.includes(d)&&!b.ids.includes(d)&&b.ids.push(d),d&&p.id===n[u.id]&&b.remembered.push(d)}let m=u.children[u.interaction.defaultIndex];m?.type==="stack"&&!m.hidden&&m.bind?.plan&&b.defaults.push(m.bind.plan)}if(c?.type==="tabs"){let b=y.find(k=>k.id===n[u.id])??u.children[c.defaultIndex];b&&o(b)}else if(c?.type==="toggle"){let b=typeof n[u.id]=="boolean"?n[u.id]:c.defaultEnabled,k=u.children[b?0:1];k&&o(k)}else y.forEach(o)}let a=typeof n.__page=="string"?n.__page:t.initialPageId??t.pages[0]?.id,s=t.pages.find(u=>u.id===a);s&&o(s.root);let l={};for(let[u,y]of Object.entries(r)){let c=n[u],b=y.remembered[0]??(y.ids.includes(i.pickers[u]?.selected??"")?i.pickers[u]?.selected:y.defaults[0]);l[u]=typeof c=="string"?y.ids.includes(c)?c:"":b&&y.ids.includes(b)?b:""}for(let u of Object.keys(le(t)))l[u]??="";return l}var ue=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),me=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 fe(t,n){return t.assignments.length===n.length&&t.assignments.every(i=>n.includes(i.productVersionId))}function Jt(t){let n=Z(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 o=t.indexOf("-->",i+4);i=o<0?t.length:o+2}else{let o="";for(i++;i<t.length;i++){let a=t[i];if(o)a===o&&(o="");else if(a==='"'||a==="'")o=a;else if(a===">")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 h={state:32,enumValues:64,derived:96,bindings:256,controls:64,timers:4,effects:8,depth:12,expressionNodes:2e3},ge=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),S=e.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/).refine(t=>!ge.has(t),"Reserved UI identifier"),B=e.union([e.string().max(2e3),e.number().finite(),e.boolean(),e.null()]),Ae=e.discriminatedUnion("type",[e.strictObject({type:e.literal("enum"),values:e.array(B).min(1).max(h.enumValues),default:B}),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 D(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 Ce=Ae.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"}),D(t,t.default)||n.addIssue({code:"custom",path:["default"],message:"UI default must match its state definition"})}),$e=["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 Ue(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 N=e.lazy(()=>e.union([B,e.strictObject({ref:S}),e.strictObject({op:e.enum($e),args:e.array(N).max(h.expressionNodes)}).superRefine((t,n)=>{Ue(t.op,t.args.length)||n.addIssue({code:"custom",path:["args"],message:"Invalid UI expression arity"})})]));function j(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;let n=Object.getPrototypeOf(t);return n===null||n===Object.prototype}function _(t,n,i){if(!t||typeof t!="object")return!0;if(!j(t))return n.addIssue({code:"custom",path:i,message:"UI objects must be plain data"}),!1;for(let r of Object.keys(t)){if(ge.has(r))return n.addIssue({code:"custom",path:[...i,r],message:"Reserved UI object key"}),!1;let o=Object.getOwnPropertyDescriptor(t,r);if(o&&!Object.hasOwn(o,"value"))return n.addIssue({code:"custom",path:[...i,r],message:"UI objects cannot contain accessors"}),!1}return!0}function O(t,n,i,r){let o=[{value:t,depth:1,path:i}];for(;o.length;){let a=o.pop();if(++r.nodes>h.expressionNodes||a.depth>h.depth){n.addIssue({code:"custom",path:a.path,message:"UI expression budget exceeded"});return}if(!_(a.value,n,a.path))return;if(j(a.value)&&Array.isArray(a.value.args)){if(a.value.args.length>h.expressionNodes){n.addIssue({code:"custom",path:[...a.path,"args"],message:"UI expression budget exceeded"});return}for(let s=a.value.args.length-1;s>=0;s--)o.push({value:a.value.args[s],depth:a.depth+1,path:[...a.path,"args",s]})}}}var en=e.unknown().superRefine((t,n)=>{O(t,n,[],{nodes:0})}).pipe(N),Q=e.record(S,N).refine(t=>Object.keys(t).length>0&&Object.keys(t).length<=h.state,"UI assignments need 1\u201332 state keys"),Le=e.strictObject({target:S,property:e.enum(["text","visible","disabled","checked","value","class","aria-label","aria-selected","aria-checked","aria-valuetext","tabindex"]),expression:N,className:S.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"})}),Te=e.discriminatedUnion("type",[e.strictObject({type:e.literal("scroll_latch"),target:S,state:S}),e.strictObject({type:e.literal("input"),target:S,state:S,set:Q.optional()}),e.strictObject({type:e.literal("action"),target:S,set:Q}),e.strictObject({type:e.literal("carousel"),target:S,state:S,initialIndex:e.number().int().nonnegative().optional(),maxWidth:e.number().int().min(1).max(1e4).optional(),previousTarget:S.optional(),nextTarget:S.optional(),inactiveTargets:e.array(S).max(20).optional(),inactiveMaxWidth:e.number().int().min(1).max(1e4).optional()})]),De=e.strictObject({afterMs:e.number().int().min(0).max(6e4),set:Q}),Re=e.strictObject({type:e.literal("mosaic_waves"),target:S,color:e.string().regex(/^#[0-9a-fA-F]{6}$/),hotColor:e.string().regex(/^#[0-9a-fA-F]{6}$/),enabled:N.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()}),Ee=e.strictObject({type:e.literal("number_counter"),target:S,value:N,prefix:e.string().max(20).optional(),format:e.enum(["number","short"]).optional()}),Ve=e.strictObject({state:e.record(S,Ce).refine(t=>Object.keys(t).length<=h.state,"Too many UI state keys").optional(),derived:e.record(S,N).refine(t=>Object.keys(t).length<=h.derived,"Too many UI derived keys").optional(),bindings:e.array(Le).max(h.bindings).optional(),controls:e.array(Te).max(h.controls).optional(),timers:e.array(De).max(h.timers).optional(),effects:e.array(e.discriminatedUnion("type",[Re,Ee])).max(h.effects).optional(),clock:e.boolean().optional()});function Me(t,n){if(!_(t,n,[])||!j(t))return;for(let[r,o]of[["state",h.state],["derived",h.derived]]){let a=t[r];if(!_(a,n,[r]))return;if(j(a)&&Object.keys(a).length>o){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}}for(let[r,o]of[["bindings",h.bindings],["controls",h.controls],["timers",h.timers],["effects",h.effects]])if(Array.isArray(t[r])&&t[r].length>o){n.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}if(Array.isArray(t.effects)){for(let[r,o]of t.effects.entries())if(!_(o,n,["effects",r]))return}if(j(t.state))for(let[r,o]of Object.entries(t.state)){if(!_(o,n,["state",r]))return;if(j(o)&&Array.isArray(o.values)&&o.values.length>h.enumValues){n.addIssue({code:"custom",path:["state",r,"values"],message:"Too many UI enum values"});return}}let i={nodes:0};if(j(t.derived))for(let[r,o]of Object.entries(t.derived))O(o,n,["derived",r],i);for(let r of["bindings","controls","timers"]){let o=t[r];if(Array.isArray(o)){for(let[a,s]of o.entries())if(!(!_(s,n,[r,a])||!j(s))){if(r==="bindings")O(s.expression,n,[r,a,"expression"],i);else if(_(s.set,n,[r,a,"set"])&&j(s.set)){if(Object.keys(s.set).length>h.state){n.addIssue({code:"custom",path:[r,a,"set"],message:"Too many UI assignments"});return}for(let[l,u]of Object.entries(s.set))O(u,n,[r,a,"set",l],i)}if(i.nodes>h.expressionNodes)return}}}if(Array.isArray(t.effects))for(let[r,o]of t.effects.entries())j(o)&&o.type==="number_counter"?O(o.value,n,["effects",r,"value"],i):j(o)&&o.enabled!==void 0&&O(o.enabled,n,["effects",r,"enabled"],i)}function de(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 be=e.unknown().superRefine(Me).pipe(Ve).superRefine((t,n)=>{let i=t.state??{},r=t.derived??{},o=new Set([...Object.keys(i),...Object.keys(r)]),a=(m,p)=>{for(let d of de(m))o.has(d)||n.addIssue({code:"custom",path:p,message:`Unknown UI reference: ${d}`})};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"}),a(p,["derived",m]);let s=new Set,l=new Set,u=m=>{if(s.has(m))return!1;if(l.has(m))return!0;s.add(m);for(let p of de(r[m]))if(Object.hasOwn(r,p)&&!u(p))return!1;return s.delete(m),l.add(m),!0};for(let m of Object.keys(r))if(!u(m)){n.addIssue({code:"custom",path:["derived",m],message:"Cyclic UI derived references"});break}for(let[m,p]of(t.bindings??[]).entries())a(p.expression,["bindings",m,"expression"]);let y=new Set;for(let[m,p]of(t.effects??[]).entries())y.has(p.target)&&n.addIssue({code:"custom",path:["effects",m,"target"],message:"Effect targets must be unique"}),y.add(p.target),p.type==="number_counter"?(a(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&&a(p.enabled,["effects",m,"enabled"]);let c=(m,p)=>{for(let[d,v]of Object.entries(m))Object.hasOwn(i,d)||n.addIssue({code:"custom",path:[...p,d],message:"UI assignments can only update declared state"}),a(v,[...p,d])},b=new Set,k=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 d of p.inactiveTargets??[])(d===p.target||k.has(d))&&n.addIssue({code:"custom",path:["controls",m,"inactiveTargets"],message:"Inactive article targets must have one carousel owner"}),k.add(d);if(p.type==="carousel")for(let d of["previousTarget","nextTarget"]){let v=p[d];v!==void 0&&((v===p.target||b.has(v)||(t.controls??[]).some(ze=>ze.target===v))&&n.addIssue({code:"custom",path:["controls",m,d],message:"Carousel navigation needs a distinct, exclusive button target"}),b.add(v))}if(p.type!=="action"){let d=Object.hasOwn(i,p.state)?i[p.state]:void 0;(!d||p.type==="input"&&d.type==="enum"&&d.values.some(v=>typeof v!="string"))&&n.addIssue({code:"custom",path:["controls",m,"state"],message:"Control needs a supported declared UI state"}),p.type==="carousel"&&(d?.type!=="number"||!Number.isInteger(d.min)||d.min<0||!Number.isInteger(d.max)||d.step!==1||p.initialIndex!==void 0&&!D(d,p.initialIndex))&&n.addIssue({code:"custom",path:["controls",m],message:"Carousel needs bounded nonnegative integer index state"}),p.type==="scroll_latch"&&d?.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&&c(p.set,["controls",m,"set"])}for(let[m,p]of(t.timers??[]).entries())c(p.set,["timers",m,"set"])});var he=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,A=e.string().max(16).regex(he,"\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 F(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:o}=new Intl.Locale(n),a=[i,r,o].filter(Boolean).join("-");return he.test(a)?a:null}catch{return null}}var Ze=new Set(["TW","HK","MO"]);function ye(t){let[n,i,r]=t.split("-");if(n!=="zh")return`${n}-${new Intl.Locale(t).maximize().script??""}`;let o=i?.length===4?i:void 0,a=i?.length===4?r:i;return o?`zh-${o}`:a&&Ze.has(a)?"zh-Hant":"zh-Hans"}function xe(t,n,i){let r=n.map(o=>({code:A.parse(o),normalized:o}));for(let o of t){let a=F(o);if(!a)continue;let s=r.find(c=>c.normalized===a);if(s)return s.code;let l=ye(a),u=r.filter(c=>ye(c.normalized)===l),y=u.find(c=>!c.normalized.includes("-")||c.normalized===l)??u[0];if(y)return y.code}return i}var Be=4,z={nodes:150,depth:8,children:50,locales:20,actions:40,pages:10,stringLength:2e3,customHtml:32768,customCss:32768,documentBytes:2e5},U=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),g=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Qe=e.enum(["none","xs","sm","md","lg","xl"]),Fe=e.enum(["none","sm","md","lg","full"]),H=e.string().regex(/^#[0-9a-fA-F]{6}$/),G=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"),q=e.union([G,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}$/)]),Se=e.object({primary:H,background:H,text:H,radius:Fe,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:G,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(),L=e.union([e.enum(["primary","text","muted","background","surface"]),e.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)]),f=(t,n)=>e.number().int().min(t).max(n),ke=e.union([e.enum(["fit","fill"]),f(1,1200)]),He=e.object({top:f(0,200),right:f(0,200),bottom:f(0,200),left:f(0,200)}).strict(),qe=e.object({top:f(-100,200),right:f(-100,200),bottom:f(-100,200),left:f(-100,200)}).strict(),Ie=e.object({x:f(0,100),y:f(0,100)}).strict(),Ge=e.discriminatedUnion("type",[e.object({type:e.literal("color"),color:L}).strict(),e.object({type:e.literal("linear"),angle:f(0,360),stops:e.array(e.object({color:L,at:f(0,100)}).strict()).min(2).max(4)}).strict(),e.object({type:e.literal("image"),src:q,fit:e.enum(["cover","contain"]),position:Ie.optional()}).strict()]),We=e.discriminatedUnion("type",[e.object({type:e.literal("rect"),radius:e.union([f(0,200),e.object({topLeft:f(0,200),topRight:f(0,200),bottomRight:f(0,200),bottomLeft:f(0,200)}).strict()])}).strict(),e.object({type:e.literal("pill")}).strict()]),Ke=e.object({width:f(0,12),color:L,style:e.enum(["solid","dashed"])}).strict(),Je=e.object({x:f(-40,40),y:f(-40,40),blur:f(0,80),spread:f(-20,40),color:L}).strict(),Xe=e.object({font:e.enum(["system","serif","rounded","mono"]),size:f(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:L,align:e.enum(["start","center","end"]),italic:e.boolean(),decoration:e.enum(["none","underline","line-through"]),transform:e.enum(["none","uppercase"])}).strict().partial(),P=e.object({width:ke,height:ke,padding:He,margin:qe,gap:f(0,120),grow:e.union([e.boolean(),e.number().min(0).max(12)]),background:Ge,opacity:e.number().min(0).max(1),clipContent:e.boolean(),shape:We,border:Ke,shadow:Je,text:Xe}).strict().partial(),I={id:U,name:e.string().trim().min(1).max(60).optional(),hidden:e.boolean().optional(),style:P.optional(),fallback:g.optional()},Ye=e.object({...I,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:g,variant:e.enum(["title","heading","body","caption"])}).strict(),et=e.object({...I,type:e.literal("image"),src:q,localizedSrc:e.record(A,q).optional(),alt:g,aspect:e.enum(["auto","1:1","4:3","16:9","3:1"]),fit:e.enum(["cover","contain"]),position:Ie.optional()}).strict(),tt=e.object({...I,type:e.literal("button"),label:g,variant:e.enum(["primary","secondary","link"]),action:g,purpose:e.enum(["purchase","navigation","close"]).optional(),bind:T.optional()}).strict(),nt=e.object({...I,type:e.literal("divider")}).strict(),rt=e.object({...I,type:e.literal("customer_data"),title:g,data:ae}).strict(),it=e.object({...I,type:e.literal("spacer"),size:Qe}).strict(),ot=e.object({...I,type:e.literal("custom_html"),html:e.record(A,e.string().max(z.customHtml)),css:e.string().max(z.customCss),ui:be.optional()}).strict(),at=e.object({...I,type:e.literal("price"),fallback:g,parts:e.object({current:P.optional(),original:P.optional(),period:P.optional()}).strict().optional()}).strict(),st=e.object({...I,type:e.literal("coupon_code"),label:g,fallback:g}).strict(),ct=e.object({...I,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:g,fallback:g}).strict().refine(t=>t.source!=="fixed"||!!t.at,"\u56FA\u5B9A\u5012\u8BA1\u65F6\u9700\u8981\u7ED3\u675F\u65F6\u95F4"),lt=e.object({...I,type:e.literal("plan_picker"),label:g,fallback:g,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:me.safeExtend({monthLabel:g,yearLabel:g,unavailableLabel:g}).optional(),states:e.object({selected:P.optional()}).strict().optional()}).strict().superRefine((t,n)=>{t.grouping&&(!t.planIds||!fe(t.grouping,t.planIds))&&n.addIssue({code:"custom",message:"Grouped picker assignments must match its product allowlist"})}),pt=e.object({...I,type:e.literal("quantity_picker"),bind:T.optional(),label:g,fallback:g,internalFeatureId:e.uuid(),minimumQuantity:f(0,1e4),maximumQuantity:f(0,1e4),defaultQuantity:f(0,1e4),step:f(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"),ut=e.discriminatedUnion("type",[e.object({type:e.literal("input"),label:g,keyboard:e.enum(["text","email","tel","url"]),maxLength:f(1,500)}).strict(),e.object({type:e.literal("multiselect"),label:g,min:f(0,50),max:f(1,50)}).strict(),e.object({type:e.literal("select"),label:g,defaultIndex:f(0,49),purpose:e.enum(["option","product","tier"]).optional(),pickerId:U.optional(),selectedStyle:P.optional()}).strict(),e.object({type:e.literal("tabs"),label:g,defaultIndex:f(0,49),purpose:e.literal("tier").optional()}).strict(),e.object({type:e.literal("toggle"),label:g,defaultEnabled:e.boolean()}).strict(),e.object({type:e.literal("carousel"),label:g}).strict()]),w={...I,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:f(0,19),period:e.enum(["month","year"]).optional(),requireBinding:e.boolean().optional()}).strict().optional(),interaction:ut.optional(),states:e.object({selected:P.optional()}).strict().optional(),purpose:e.literal("benefits").optional(),purchaseAction:g.optional(),buttonVariant:e.enum(["primary","secondary","link"]).optional(),bind:T.optional()},je=e.lazy(()=>e.object({...I,type:w.type,direction:w.direction,align:w.align,justify:w.justify,children:e.array(mt).max(z.children),productSlot:w.productSlot,interaction:w.interaction,states:w.states,purpose:w.purpose,purchaseAction:w.purchaseAction,buttonVariant:w.buttonVariant,bind:w.bind}).strict()),mt=e.lazy(()=>e.union([je,Ye,et,tt,nt,it,ot,at,st,ct,lt,pt,rt])),ft=e.union([e.string().max(500),e.number().finite(),e.boolean(),e.null()]),$={id:g,event:g,properties:e.record(g,ft).refine(t=>Object.keys(t).length<=20,"\u6700\u591A 20 \u4E2A\u53C2\u6570")},dt=e.discriminatedUnion("type",[e.object({...$,type:e.literal("navigate"),close:e.literal(!1),pageId:U}).strict(),e.object({...$,type:e.literal("event"),close:e.boolean()}).strict(),e.object({...$,type:e.literal("close"),close:e.literal(!0)}).strict(),e.object({...$,type:e.literal("open_url"),close:e.boolean(),url:G}).strict(),e.object({...$,type:e.literal("claim_offer"),close:e.boolean(),couponId:e.uuid()}).strict()]),gt=e.object({defaultLocale:A,locales:e.record(A,e.record(g,e.string().max(z.stringLength)))}).strict(),bt=e.enum(["popup","paywall","onboarding","page","banner"]);var yt=e.object({kind:e.literal("screen"),schemaVersion:e.literal(Be),name:e.string().trim().min(1).max(80),surface:bt,initialPageId:U.optional(),presentation:X,theme:Se,pages:e.array(e.object({id:U,name:e.string().trim().min(1).max(60),root:je,theme:Se.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(z.pages),strings:gt,actions:e.array(dt).max(z.actions)}).strict();function R(t,n){for(let i of t.pages)W(i.root,n)}var dn=yt.superRefine((t,n)=>{let i=z;t.surface!=="paywall"&&t.pages.length!==1&&n.addIssue({code:"custom",message:"Only a Paywall can contain multiple screens"}),t.initialPageId&&!t.pages.some(c=>c.id===t.initialPageId)&&n.addIssue({code:"custom",message:"Initial screen does not exist"});for(let c of t.actions)c.type==="navigate"&&(t.surface!=="paywall"||!t.pages.some(b=>b.id===c.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=c=>n.addIssue({code:"custom",message:c}),o=Object.keys(t.strings.locales);o.includes(t.strings.defaultLocale)||r("\u9ED8\u8BA4\u8BED\u8A00\u5FC5\u987B\u5728\u8BED\u8A00\u5217\u8868\u91CC"),o.length>z.locales&&r(`\u6700\u591A ${z.locales} \u79CD\u8BED\u8A00`);let a=new Set;for(let c of t.actions)a.has(c.id)&&r(`\u52A8\u4F5C\u6807\u8BC6\u91CD\u590D\uFF1A${c.id}`),a.add(c.id);let s=new Set;for(let c of t.pages)["next","back"].includes(c.id)&&r(`\u9875\u9762 id \u4E0D\u80FD\u4F7F\u7528\u4FDD\u7559\u540D\u79F0\uFF1A${c.id}`),s.has(c.id)&&r(`\u9875\u9762 id \u91CD\u590D\uFF1A${c.id}`),s.add(c.id);let l=new Set,u=0,y=!1;R(t,(c,b)=>{if(u++,b>z.depth&&(y=!0),l.has(c.id)&&r(`\u7EC4\u4EF6 id \u91CD\u590D\uFF1A${c.id}`),l.add(c.id),c.type==="button"&&!a.has(c.action)&&r(`\u6309\u94AE ${c.id} \u5F15\u7528\u7684\u52A8\u4F5C\u4E0D\u5B58\u5728\uFF1A${c.action}`),c.type==="custom_html")for(let k of Object.keys(c.html))o.includes(k)||r(`\u81EA\u5B9A\u4E49 HTML ${c.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${k}`);if(c.type==="image")for(let k of Object.keys(c.localizedSrc??{}))o.includes(k)||r(`\u56FE\u7247 ${c.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${k}`)}),u>i.nodes&&r(`\u7EC4\u4EF6\u6700\u591A ${i.nodes} \u4E2A`),y&&r(`\u5C42\u7EA7\u6700\u591A ${z.depth} \u5C42`)});function W(t,n,i=1,r=null){if(n(t,i,r)!==!1&&t.type==="stack")for(let o of t.children)W(o,n,i+1,t)}function we(t){let n=[],i=new Set;return R(t,r=>{let o=(a,s,l)=>{i.has(a)||(i.add(a),n.push({key:a,nodeId:r.id,nodeType:r.type,field:s,required:l}))};r.type==="stack"&&r.interaction&&o(r.interaction.label,"label",!0),r.fallback&&o(r.fallback,"text",!0),r.type==="text"&&o(r.text,"text",!0),r.type==="customer_data"&&o(r.title,"title",!0),(r.type==="plan_picker"||r.type==="quantity_picker"||r.type==="coupon_code")&&o(r.label,"label",!0),r.type==="plan_picker"&&r.grouping&&(o(r.grouping.monthLabel,"label",!0),o(r.grouping.yearLabel,"label",!0),o(r.grouping.unavailableLabel,"text",!0)),r.type==="countdown"&&o(r.expired,"text",!0),r.type==="button"&&o(r.label,"label",!0),r.type==="image"&&(o(`image:${r.id}`,"src",!1),o(r.alt,"alt",!1)),r.type==="custom_html"&&o(`html:${r.id}`,"html",!0)}),n}function ht(t,n,i){if(n.field==="html"){let r;return R(t,o=>{o.id===n.nodeId&&o.type==="custom_html"&&(r=o.html[i])}),r}if(n.field==="src"){let r=It(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 xt(t){let n=we(t).filter(r=>r.required);return Object.keys(t.strings.locales).sort((r,o)=>r===t.strings.defaultLocale?-1:o===t.strings.defaultLocale?1:0).map(r=>{let o=n.filter(a=>!ht(t,a,r)?.trim()).map(a=>a.key);return{locale:r,total:n.length,filled:n.length-o.length,missing:o,complete:o.length===0}})}function St(t){return xt(t).filter(n=>n.complete||n.locale===t.strings.defaultLocale).map(n=>n.locale)}function gn(t,n){return xe(n,St(t),t.strings.defaultLocale)}function bn(t,n){let i=t.strings.locales[n]??{},r=t.strings.locales[t.strings.defaultLocale]??{},o={};for(let s of we(t)){if(s.field==="html"||s.field==="src")continue;let l=i[s.key]?.trim()?i[s.key]:r[s.key];l!==void 0&&(o[s.key]=l)}let a=s=>{if(s.type==="stack")return{...s,children:s.children.map(a)};if(s.type==="custom_html"){let l=s.html[n]?.trim()?s.html[n]:s.html[t.strings.defaultLocale];return{...s,html:l===void 0?{}:{[n]:l}}}if(s.type==="image"){let{localizedSrc:l,...u}=s;return{...u,src:l?.[n]??l?.[t.strings.defaultLocale]??s.src}}return s};return{...t,pages:t.pages.map(s=>({...s,root:a(s.root)})),strings:{defaultLocale:n,locales:{[n]:o}}}}function kt(t,n){let i=null;return W(t,r=>{if(i)return!1;r.id===n&&(i=r)}),i}function It(t,n){for(let i of t.pages){let r=kt(i.root,n);if(r)return r}return null}function yn(t){let n=F(t)?.split("-")[0];return n!==void 0&&["ar","he","fa","ur"].includes(n)}function hn(t,n,i){let r={};if(!n||typeof n!="object"||Array.isArray(n))return r;let o=n;if(R(t,a=>{if(a.type==="quantity_picker"){let l=o[a.id];typeof l=="number"&&Number.isSafeInteger(l)&&l>=a.minimumQuantity&&l<=a.maximumQuantity&&(l-a.minimumQuantity)%a.step===0&&(r[a.id]=l);return}if(a.type==="plan_picker"){let l=o[a.id];typeof l=="string"&&(r[a.id]=i?.pickers[a.id]?.options.includes(l)?l:"");return}if(a.type==="custom_html"&&a.ui)for(let[l,u]of Object.entries(a.ui.state??{})){let y=`${a.id}.${l}`,c=o[y];c!==null&&D(u,c)&&(r[y]=c)}if(a.type!=="stack"||!a.interaction)return;let s=Object.hasOwn(o,a.id)?o[a.id]:void 0;["select","tabs"].includes(a.interaction.type)&&typeof s=="string"&&a.children.some(l=>l.id===s)&&(r[a.id]=s),a.interaction.type==="toggle"&&typeof s=="boolean"&&(r[a.id]=s)}),t.surface==="paywall"&&typeof o.__page=="string"&&t.pages.some(a=>a.id===o.__page)&&(r.__page=o.__page),i){let a={...r};for(let[s,l]of Object.entries(o))(typeof l=="string"||typeof l=="boolean")&&(a[s]=l);Object.assign(r,pe(t,a,i))}return r}export{V as a,wt as b,te as c,Ot as d,ne as e,re as f,Et as g,ie as h,Vt as i,le as j,me as k,fe as l,Qt as m,Ft as n,Jt as o,A as p,F as q,z as r,U as s,g as t,q as u,R as v,dn as w,W as x,we as y,xt as z,gn as A,bn as B,It as C,yn as D,hn as E};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as p}from"./chunk-
|
|
1
|
+
import{a as p}from"./chunk-TL67SYPH.js";import{a as d}from"./chunk-GPJF3T43.js";function I(n,r,i){if(!["subscriptions/operations/read","subscriptions/updates/read","subscriptions/refunds/read"].includes(n))return;let e=r,s=i,o=s.operation;if(o.operationId!==e.operationId||[o.authority,o.merchantExecution].some(t=>t&&(t.operationId!==e.operationId||e.customerId!==void 0&&t.customerId!==e.customerId))||o.authority&&(o.authority.scope.projectId!==s.scope.projectId||o.authority.scope.environment!==s.scope.environment))throw new p("INVALID_RESPONSE","Original commerce operation changed")}function g(n){try{return structuredClone(n)}catch{return n}}async function E(n,r){let i=n.captureIdentity?.(),{apiOperations:e}=await import("./operation-contracts-YSFIINLK.js");return i?.(),e[r]}function m(n,r,i,e){try{return n.parse(r)}catch(s){throw e&&s instanceof d?new p(i,e):s}}async function P(n,r,i,e={},s){let o=typeof e=="function"?{}:e,t=m(r.request,i,"INVALID_REQUEST",o.request);try{let a=await n(r.path,t,r.method,s),u=typeof e=="function"?e:e.parseResponse,c=u?u(r.response,a):m(r.response,a,"INVALID_RESPONSE",o.response);return I(r.path,t,c),c}catch(a){throw a instanceof p&&t!==null&&typeof t=="object"&&"requestId"in t&&typeof t.requestId=="string"&&(a.commandRequestId??=t.requestId),a}}export{g as a,E as b,P as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as d}from"./chunk-
|
|
1
|
+
import{b as d}from"./chunk-ZICZN6WO.js";import{a as u}from"./chunk-DSPLGTQI.js";function m(e){if(!/^[A-Za-z0-9_-]{1,64}$/.test(e))throw new Error("Invalid device cookie name");let t="";for(let i of document.cookie.split(";"))if(i.trim().startsWith(`${e}=`))try{t=decodeURIComponent(i.trim().slice(e.length+1))}catch{}return/^[A-Za-z0-9_-]{8,128}$/.test(t)||(t=crypto.randomUUID(),document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${400*24*3600}; SameSite=Lax`),t}function y(){try{let e=sessionStorage.getItem("indiana_sid");return e||(e=crypto.randomUUID(),sessionStorage.setItem("indiana_sid",e)),e}catch{return}}function g(e=d){let t=new URL(e);if(t.protocol!=="https:"&&!(t.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(t.hostname))||t.username||t.password||t.search||t.hash)throw new Error("baseUrl must be an https origin without credentials");return t.origin}var o=new Set,s;function S(e){let t=()=>e();if(o.add(t),!s){let i=!0,a=history.pushState,p=history.replaceState,r=()=>{if(i)for(let n of[...o])o.has(n)&&u(n)},c=function(...n){a.apply(this,n),r()},h=function(...n){p.apply(this,n),r()};history.pushState=c,history.replaceState=h,addEventListener("popstate",r),addEventListener("hashchange",r),s=()=>{i=!1,history.pushState===c&&(history.pushState=a),history.replaceState===h&&(history.replaceState=p),removeEventListener("popstate",r),removeEventListener("hashchange",r)}}return()=>{o.delete(t)&&(o.size||(s?.(),s=void 0))}}export{m as a,y as b,g as c,S as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as n,r as t}from"./chunk-ANXDWUPK.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as k}from"./chunk-
|
|
1
|
+
import{c as k}from"./chunk-3SXPCVIP.js";import{a as M}from"./chunk-DSPLGTQI.js";var z={sm:420,md:640,lg:900},A=767;function le(e,r,o=()=>!0,c="Close"){let n=e.ownerDocument.defaultView,i=e.ownerDocument.createElement("button");i.type="button",i.setAttribute("aria-label",c),i.style.cssText="position:absolute;inset:0 48px auto;z-index:2;height:24px;border:0;padding:0;background:transparent;touch-action:none;cursor:grab";let d=e.ownerDocument.createElement("span");d.style.cssText="display:block;width:36px;height:4px;border-radius:4px;margin:8px auto 12px;background:currentColor;opacity:.22;pointer-events:none",i.append(d),e.prepend(i);let p,s=0,a=!1,f=()=>{i.hidden=e.dataset.presentation!=="sheet",i.setAttribute("aria-disabled",String(!o()))},v=t=>{f(),!(i.hidden||!o()||t.button!==0)&&(p={y:t.clientY,time:Date.now(),id:t.pointerId},s=0,a=!1,i.setPointerCapture?.(t.pointerId))},y=t=>{!p||t.pointerId!==p.id||(s=Math.max(0,t.clientY-p.y),e.style.transform=`translateY(${s}px)`)},g=t=>{if(!p||t.pointerId!==p.id)return;let u=Math.max(1,Date.now()-p.time),x=t.type!=="pointercancel"&&o()&&(s>120||s>40&&s/u>.5);a=s>6,p=void 0,i.releasePointerCapture?.(t.pointerId),e.style.transform="",x?r():s&&typeof e.animate=="function"&&!n?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&e.animate([{transform:`translateY(${s}px)`},{transform:"none"}],{duration:200,easing:"cubic-bezier(.2,.8,.2,1)"}),s=0},m=()=>{if(a){a=!1;return}!p&&s===0&&o()&&r()};i.addEventListener("pointerdown",v),i.addEventListener("pointermove",y),i.addEventListener("pointerup",g),i.addEventListener("pointercancel",g),i.addEventListener("click",m);let l=typeof MutationObserver=="function"?new MutationObserver(f):void 0;return l?.observe(e,{attributes:!0,attributeFilter:["data-presentation"]}),n?.addEventListener("resize",f),f(),()=>{l?.disconnect(),n?.removeEventListener("resize",f),i.remove(),e.style.transform=""}}function O(e,r,o=!1){return(e.type==="modal"||e.type==="sheet")&&e.mobile&&o&&r<=A?e.mobile:e.type}function W(e,r,o){let c=e.ownerDocument.defaultView,n=r.presentation,i;if((n.type==="modal"||n.type==="sheet")&&n.backdrop){let t=`lp-backdrop-${crypto.randomUUID()}`,u={none:"transparent",scrim:"#f2f2f2cc",dim:"#0006","strong-dim":"#000000bf",blur:"#0006"};e.dataset.indianaBackdrop=t,i=e.ownerDocument.createElement("style"),i.textContent=`dialog[data-indiana-backdrop="${t}"]::backdrop{background:${u[n.backdrop]};backdrop-filter:${n.backdrop==="blur"?"blur(16px)":"none"}}`,e.append(i)}let d=r.pages?.[0]?.root.style?.shape,p=d?.type==="pill"?"9999px":d?.type==="rect"?typeof d.radius=="number"?`${d.radius}px`:[d.radius.topLeft,d.radius.topRight,d.radius.bottomRight,d.radius.bottomLeft].map(t=>`${t}px`).join(" "):void 0,s=(n.type==="modal"||n.type==="sheet")&&(n.desktopWidth!==void 0||n.mobile!==void 0||n.type==="modal"&&n.position!==void 0),a=n.type,f,v,y=!1,g=t=>{y||!Number.isFinite(t)||t<0||(v=t,a!=="fullscreen"&&a!=="inline"&&(e.style.height=`min(${Math.max(t,40)}px, calc(100dvh - ${a==="sheet"?0:32}px))`))},m=()=>{if(!y&&(a=f??O(n,c?.innerWidth??1024,c?.matchMedia?.("(pointer: coarse)").matches===!0),e.dataset.presentation=a,!(!s||n.type!=="modal"&&n.type!=="sheet"))){if(e.style.boxSizing="border-box",e.style.padding="0",e.style.border="0",e.style.overflow="hidden",e.style.outline="none",e.tabIndex=-1,e.style.background=r.theme.background,e.style.color=r.theme.text,a==="fullscreen")e.style.width="100vw",e.style.height="100dvh",e.style.maxWidth="100vw",e.style.maxHeight="100dvh",e.style.margin="0",e.style.borderRadius="0";else{let t=n.mobile==="sheet"&&a==="sheet",u=n.desktopWidth,x=c?.innerWidth??1024;e.style.width=t?`${x}px`:u?`${Math.min(u.max,Math.max(x*u.viewport/100,u.min))}px`:`${k[n.size]}px`,e.style.maxWidth=`${Math.max(0,x-(a==="sheet"?0:32))}px`,e.style.maxHeight=a==="sheet"?"100dvh":"calc(100dvh - 32px)",e.style.margin=a==="sheet"?"auto auto 0":n.type==="modal"&&n.position==="top"?"16px auto auto":n.type==="modal"&&n.position==="bottom"?"auto auto 16px":"auto",e.style.borderRadius=p??(a==="sheet"?"16px 16px 0 0":"24px"),e.style.height="",v!==void 0&&g(v)}o?.(a)}},l=s?[c?.matchMedia?.(`(max-width: ${A}px)`),c?.matchMedia?.("(pointer: coarse)")].filter(t=>t!==void 0):[];if(s){c?.addEventListener("resize",m);for(let t of l)t.addEventListener?t.addEventListener("change",m):t.addListener?.(m)}return m(),{responsive:s,get type(){return a},latch(){y||f!==void 0||(m(),f=a)},setContentHeight:g,destroy(){if(!y){y=!0,i?.remove(),delete e.dataset.indianaBackdrop,c?.removeEventListener("resize",m);for(let t of l)t.removeEventListener?t.removeEventListener("change",m):t.removeListener?.(m)}}}}function ue(e,r,o){let{presentation:c}=r,n="size"in c?`${z[c.size]}px`:"100vw";return e.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${n}`,W(e,r,o)}function me(e,r,o=!1){let c=e.ownerDocument.defaultView;if(typeof e.animate!="function"||c?.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;let n=o?{duration:300,easing:"cubic-bezier(0.23, 1, 0.32, 1)"}:{duration:240,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)"};e.animate(r==="sheet"?[{transform:"translateY(100%)"},{transform:"none"}]:r==="modal"?[{opacity:0,transform:o?"translateY(12px) scale(0.96)":"translateY(8px) scale(0.98)"},{opacity:1,transform:"none"}]:[{opacity:0},{opacity:1}],n);try{e.animate([{opacity:0},{opacity:1}],{...n,pseudoElement:"::backdrop"})}catch{}}function $(e,r){e.style.cssText=["position:absolute","z-index:1","top:calc(4px + env(safe-area-inset-top, 0px))","inset-inline-end:calc(4px + env(safe-area-inset-right, 0px))","width:44px","height:44px","padding:0","border:0","border-radius:50%","font:400 20px/1 system-ui,sans-serif","cursor:pointer","touch-action:manipulation"].join(";"),e.style.background=`radial-gradient(circle, ${r.background} 0 15px, color-mix(in srgb, ${r.text} 22%, ${r.background}) 15px 16px, transparent 16.5px)`,e.style.color=r.text}var C=new WeakMap;function he(e,r){return C.set(e,r),()=>C.delete(e)}function xe(e){let r=e.defaultView?.HTMLElement,o=e.activeElement;for(let n=0;n<16&&o?.shadowRoot?.activeElement;n++)o=o.shadowRoot.activeElement;let c=o?C.get(o)?.():void 0;return()=>{!o?.isConnected||!r||!(o instanceof r)||(o.focus({preventScroll:!0}),c?.())}}var ge=15e3;function we(e,r,o,c,n){let i=e.ownerDocument,d=new AbortController,p=!1,s=!1,a,f;function v(){f?.(),f=void 0,a?.tagName==="DIALOG"&&a.close?.(),a?.remove(),a=void 0}function y(l,t){s||(s=!0,v(),(l==="dismissed"||l==="error")&&d.abort(t??new DOMException("Presentation cancelled","AbortError")),!(!p&&l!=="ready")&&M(r.onPresentationState,l==="error"?{surface:o,state:l,error:t}:{surface:o,state:l}))}let g=c,m=()=>{s||g()};return{setDismissHandler(l){g=l},get active(){return p&&!s},get cancelled(){return d.signal.aborted},start(l,t,u){if(!(p||s)){if(p=!0,r.loading!=="host"){let x=(t??i.documentElement.lang)||"en",b=l&&u?.presentation?.type!=="inline",E=u!==void 0,h=i.createElement(b?"dialog":"div");a=h,h.dataset.longplayLoading=o;let S=x.startsWith("zh"),I=E?S?"\u6B63\u5728\u52A0\u8F7D\u5957\u9910":"Loading plans":S?"\u6B63\u5728\u52A0\u8F7D":"Loading",R=u?.screen.theme??{background:"Canvas",text:"CanvasText"};h.setAttribute("aria-label",I);let P=i.createElement("div");P.setAttribute("role","status");let L=i.createElement("div");L.setAttribute("aria-hidden","true");let H=()=>{P.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)"};E?P.style.cssText="padding:24px 60px 24px 24px;font:500 16px/1.5 system-ui,sans-serif":H(),P.textContent=I;let w=i.createElement("button");w.type="button",w.textContent="\xD7",w.setAttribute("aria-label",S?"\u53D6\u6D88\u52A0\u8F7D":"Cancel loading"),$(w,R),w.addEventListener("click",m),h.addEventListener("cancel",D=>{D.preventDefault(),m()}),h.append(P,L,w),e.append(h);let T=()=>{if(!s&&b){let D=h;D.showModal?D.showModal():D.open=!0,w.focus({preventScroll:!0})}};u&&n?(f=n(h,L,u,x,()=>{s||(L.style.visibility="",H())}),T()):E?(h.style.cssText=b?"padding:0;border:0;border-radius:24px;background:Canvas;color:CanvasText;width:min(420px,calc(100vw - 32px))":"position:relative;background:Canvas;color:CanvasText;width:100%",T()):(_(h,L,b,o),T())}M(r.onPresentationState,{surface:o,state:"loading",dismiss:m})}},present(l){if(s)return;let t=!!a;v(),l(t),y("ready")},dismiss:m,finish:y,async wait(l,t){let u=d.signal,x,b,E=new Promise((h,S)=>{b=()=>S(u.reason),u.aborted?b():u.addEventListener("abort",b,{once:!0}),t!==void 0&&(x=setTimeout(()=>S(new Error("Presentation data timed out")),t))});try{let h=await Promise.race([E,l]);return u.throwIfAborted(),h}finally{u.removeEventListener("abort",b),clearTimeout(x)}}}}function _(e,r,o,c){e.style.cssText="position:relative;box-sizing:border-box;background:Canvas;color:CanvasText;padding:24px 48px 24px 24px;"+(o?"position:fixed;width:min(480px,calc(100% - 32px));border:0;border-radius:16px;max-height:calc(100dvh - 32px)":"width:100%"),r.style.cssText="display:grid;gap:12px";let n=c==="banner"?[["72%",12],["44%",10]]:[["46%",20],["84%",12],["65%",12],["100%",64]];for(let[i,d]of n){let p=e.ownerDocument.createElement("div");p.style.cssText=`width:${i};height:${d}px;background:currentColor;opacity:.11;border-radius:6px`,r.append(p)}}function F(e){let r={display:"block",position:"fixed",top:"0",left:"0",opacity:"0",pointerEvents:"none",zIndex:"-1"},o=Object.keys(r).map(i=>{let d=i,p=e.style[d];return e.style[d]=r[d],[d,p]}),c=e.inert??!1,n=e.getAttribute("aria-hidden");return e.inert=!0,e.setAttribute("aria-hidden","true"),()=>{for(let[i,d]of o)e.style[i]=d;e.inert=c,n===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n)}}function Ee(e,r){let o=e.style.width;e.style.width=`${r.getBoundingClientRect().width||r.ownerDocument.defaultView?.innerWidth||800}px`;let c=F(e);return()=>{c(),e.style.width=o}}export{le as a,O as b,W as c,ue as d,me as e,$ as f,he as g,xe as h,ge as i,we as j,F as k,Ee as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as m,m as f,p as y}from"./chunk-
|
|
1
|
+
import{a as m,m as f,p as y}from"./chunk-HLCDAU5A.js";import{g as d}from"./chunk-MWICFZUF.js";import{e as l,f as u,j as p}from"./chunk-CWD36SJO.js";import{b as e}from"./chunk-GPJF3T43.js";var h={funnelId:e.uuid().optional(),funnelVersionId:e.uuid().optional()};var w=e.strictObject({runId:e.uuid(),bindingId:e.uuid(),receiptId:e.uuid()});var q=e.strictObject({processContext:w.optional(),...h,selector:e.discriminatedUnion("type",[e.strictObject({type:e.literal("paywall"),paywallId:e.uuid()}),e.strictObject({type:e.literal("version"),versionId:e.uuid()})]),customerId:e.uuid().optional(),commerce:l,locale:e.string().min(1).max(35),requirement:u.optional()}),c=e.strictObject({id:e.uuid(),paywallId:e.uuid(),version:e.number().int().positive(),document:m.omit({requirement:!0,offeringId:!0}),offering:e.strictObject({id:e.uuid()}),content:e.strictObject({environmentId:e.uuid(),offeringVersionId:e.uuid(),artifact:y.refine(n=>n.kind==="paywall"&&n.formatVersion===1)}).optional(),capabilities:d,check:p.nullable()}).superRefine((n,r)=>{let t=new Set(n.document.products.items.map(o=>o.productVersionId));(n.document.offeringVersionId!==n.offering.id||Object.values(n.capabilities.plans).some(o=>!t.has(o.versionId)))&&r.addIssue({code:"custom",message:"Paywall resolution must preserve the exact Offering Version and displayed Product subset"})}),M=e.strictObject(c.shape).omit({document:!0,offering:!0}).extend({content:c.shape.content.unwrap()});function _(n,r){let t=f.parse(r);if(t.offeringVersionId!==n.content.offeringVersionId)throw new Error("Public Paywall Offering pin changed");let o=structuredClone(n.capabilities);for(let[g,i]of Object.entries(t.catalog)){let a=o.plans[g],s=i.channels.stripe?.prices.find(I=>I.currency===a?.currency);a&&s&&Object.assign(a,{amountMinor:s.amountMinor,interval:i.interval,intervalCount:i.intervalCount,...i.prepaid?.length?{prepaid:i.prepaid}:{}})}return c.parse({...n,capabilities:o,document:{schemaVersion:3,kind:t.kind,name:t.name,presentation:t.presentation,products:t.products,offeringVersionId:t.offeringVersionId,screen:t.screen,buttons:t.buttons},offering:{id:t.offeringVersionId}})}export{h as a,w as b,q as c,c as d,M as e,_ as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as p}from"./chunk-
|
|
1
|
+
import{e as p}from"./chunk-MEDW4N3F.js";import{c as g}from"./chunk-NVF54BDR.js";import{b as B}from"./chunk-MPD3UIY4.js";import{b as F}from"./chunk-67SIVUOS.js";import{a as $}from"./chunk-B4AELNLE.js";import{e as z,f as Y,g as X,h as Z,i as ee}from"./chunk-AQONMY2H.js";import{b as j}from"./chunk-RDUKCMST.js";import{A as x,B as R,E as K,z as J}from"./chunk-KP4QI4RX.js";import{w as G}from"./chunk-5TJISOWN.js";import{b as W}from"./chunk-LUGZNBIW.js";import{a as M}from"./chunk-LSVTH3TS.js";import{t as H}from"./chunk-7MYS52FL.js";import{a}from"./chunk-TL67SYPH.js";import{a as re}from"./chunk-DSPLGTQI.js";function ae(I){let t=[...new Set(I.map(({path:s})=>{let c=s.map(String).join(".");return c.startsWith("selector")?"paywallId or paywallVersionId":c||"input"}))],O=t.includes("locale")?` Pass locale, the Customer's language such as "en" or "zh-CN".`:"";return new a("INVALID_REQUEST",`createPaywallSession input is invalid: ${t.join(", ")}.${O}`)}async function Ie(I,t){if(!M.test(t.customerToken))throw new a("INVALID_TOKEN","A verified Customer credential is required");if(I.session&&I.session.peek()!==t.customerToken)throw new a("SCOPE_MISMATCH","Paywall credential does not match the shared session");let O=p.resolvePaywall.request.safeParse({funnelId:t.funnelId,funnelVersionId:t.funnelVersionId,selector:t.paywallVersionId?{type:"version",versionId:t.paywallVersionId}:{type:"paywall",paywallId:t.paywallId},commerce:t.commerce,locale:t.locale,...t.requirement?{requirement:t.requirement}:{}});if(!O.success)throw ae(O.error.issues);let s=O.data,c=W(I);I.session||c.identify(t.customerToken);let n=null,v=!1,U=new AbortController,u=null,d=null,b=null,P=null,T=null,y=null,m=null,A=0,q=null,k="",D=0,C=new Map,E=new Set;function S(){if(v)throw new a("IDENTITY_CHANGED","Paywall is closed")}function L(){let e=JSON.stringify([A,m!==null]);if(!q||e!==k){k=e;let r=te(++D);q=r;let i=()=>{q===r&&(q=null)};r.then(i,i)}return q.then(r=>structuredClone(r))}async function te(e){S();let r=p.resolvePaywall,i=await g(c.request,r,{...s,selector:n?{type:"version",versionId:n.id}:s.selector});B(s,i.paywall.check,i.scope);let l=await F(I,i.paywall);if(S(),t.paywallVersionId?l.id!==t.paywallVersionId:l.paywallId!==t.paywallId)throw new a("INVALID_RESPONSE","The requested Paywall changed");if(n&&(!z(l,n)||l.paywallId!==n.paywallId))throw new a("INVALID_RESPONSE","The pinned Paywall or Offering Version changed");if(e!==D)return structuredClone(n??l);n=l;for(let h of E)re(h,structuredClone(n));return structuredClone(n)}async function Q(e){if(S(),P&&e!=="read")throw new a("COMMAND_PENDING","Wait for the original quote");if(!u)throw new a("INVALID_REQUEST","A quoted purchase is required");let r=u;if(e!=="read"){if(m){if(y===e)return m;throw new a("COMMAND_PENDING","Wait for the original purchase command")}if(y&&y!==e)throw new a("COMMAND_PENDING","Read the original purchase before changing an uncertain command");y=e,A++,D++}let i=y,l=A,h=e==="read"&&m===null,f=JSON.stringify([r.operationId,l,m!==null]);if(e==="read"&&C.has(f))return C.get(f).then(o=>structuredClone(o));let w=(async()=>{let o={operationId:r.operationId,...e==="read"?{}:{intent:e},...e==="confirm"&&r.merchantTerms?{merchantConfirmation:G(r.merchantTerms)}:{}},V=R(r)?e==="read"?await g(c.request,p.readSubscriptionUpdate,o):await g(c.request,p.update,o):e==="read"?await g(c.request,p.readSubscriptionOperation,o):await g(c.request,p.attach,o),N=x.parse(V.operation);return N.quote&&Z(r,N.quote),Y(N,{operationId:r.operationId,currency:s.commerce.currency,membershipId:R(r)?r.membershipId:null,...R(r)?{featureQuantities:r.featureQuantities??{}}:{}},"The purchase operation changed"),S(),u?.operationId!==r.operationId?structuredClone(N):(d=ee(d,N),(e!=="read"||h&&m===null)&&A===l&&y===i&&(y=null),structuredClone(d))})();if(e!=="read"){m=w;let o=()=>{m===w&&(m=null)};w.then(o,o)}else{C.set(f,w);let o=()=>{C.get(f)===w&&C.delete(f)};w.then(o,o)}return w.then(o=>structuredClone(o))}let _={signal:U.signal,get view(){return n?structuredClone(n):null},get quote(){return u?structuredClone(u):null},get operation(){return d?structuredClone(d):null},get webViewUrl(){return"bundled"},get locale(){return s.locale},get recovery(){return $({quote:u,operation:d,requestId:T,pending:P!==null||y!==null,destroyed:v})},get pendingCancellation(){return!v&&y==="cancel"},refresh:L,subscribe(e){return v?()=>{}:(E.add(e),()=>E.delete(e))},async preview(e){if(S(),!n)throw new a("INVALID_REQUEST","Load the Paywall first");let r=n.document.buttons[e.actionId];if(r?.type!=="checkout")throw new a("INVALID_REQUEST","Choose an authored purchase action");let i=j(r.product,e.selection,n.capabilities);if(!i)throw new a("PRODUCT_UNAVAILABLE","Choose an available Product");let l=H(n.document.screen,i,e.selection,n.capabilities);if(s.commerce.intent==="subscription_change"&&!e.subscriptionChange)throw new a("INVALID_REQUEST","Choose the existing membership for this subscription change");if(e.subscriptionChange&&e.nativeOffer)throw new a("INVALID_REQUEST","A web membership change cannot include a store offer");let h=e.subscriptionChange?p.previewUpdate.request.parse({requestId:e.requestId,...e.subscriptionChange,change:{type:"plan",productVersionId:i,...Object.keys(l).length?{featureQuantities:l}:{}},...e.offerId?{offerId:e.offerId}:{}}):p.previewAttach.request.parse({funnelId:s.funnelId,funnelVersionId:s.funnelVersionId,requestId:e.requestId,plans:[{productVersionId:i,...Object.keys(l).length?{featureQuantities:l}:{}}],provider:s.commerce.provider,currency:s.commerce.currency,...e.offerId?{offerId:e.offerId}:{},...e.nativeOffer?{nativeOffer:e.nativeOffer}:{}}),f=JSON.stringify(h);if(b&&b!==f&&(P||y||!d||K(d)))throw new a("COMMAND_PENDING","Finish or cancel the original purchase before changing it");if(b===f){if(P)return P;if(u)return structuredClone(u)}b!==f&&(u=null,d=null),b=f,T=h.requestId;let w=(async()=>{let o="membershipId"in h?await g(c.request,p.previewUpdate,h):await g(c.request,p.previewAttach,h),V=J.parse(o.quote);return S(),X(V,{productVersionId:i,featureQuantities:l,currency:s.commerce.currency,provider:s.commerce.provider,subscriptionChange:e.subscriptionChange},"The purchase quote changed its selected Product or presentment"),u=V,d=null,structuredClone(u)})();P=w;try{return await w}finally{P===w&&(P=null)}},confirm:()=>Q("confirm"),cancel:()=>Q("cancel"),read:()=>Q("read"),destroy(){v||(v=!0,U.abort(),E.clear(),C.clear(),ne?.(),c.dispose(),n=null,u=null,d=null,b=null,T=null)}},ne=I.session?.subscribeIdentity(_.destroy);try{return await L(),_}catch(e){throw _.destroy(),e}}export{Ie as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{k as c}from"./chunk-
|
|
1
|
+
import{k as c}from"./chunk-MWICFZUF.js";import{b as r}from"./chunk-GPJF3T43.js";var s=r.strictObject({items:r.array(r.strictObject({productVersionId:r.string().min(1).max(200),label:r.string().trim().max(40)})).max(20).refine(e=>new Set(e.map(t=>t.productVersionId)).size===e.length,"Duplicate Paywall Product"),defaultProductVersionId:r.string().min(1).max(200).nullable(),grouping:c.optional()});function p(e,t,n){let i=e.type==="fixed"?e.productVersionId:t[e.pickerId];return typeof i!="string"||!Object.values(n.plans).some(o=>o.versionId===i&&o.available)||e.type==="picker"&&(!e.allowedProductVersionIds.includes(i)||!n.pickers[e.pickerId]?.options.includes(i))?null:i}export{s as a,p as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b as o,c as i}from"./chunk-
|
|
1
|
+
import{a,b as o,c as i}from"./chunk-NVF54BDR.js";import{a as p}from"./chunk-TL67SYPH.js";function c(e){if(e!==null&&typeof e=="object"&&"customerId"in e)throw new p("INVALID_REQUEST","Customer requests use the verified session identity")}function I(e){return{async previewUpdate(t){t=a(t),c(t);let r=await o(e,"previewUpdate");return i(e,r,t)},async update(t){t=a(t),c(t);let r=await o(e,"update");return i(e,r,t)},async readSubscriptionUpdate(t){t=a(t),c(t);let r=await o(e,"readSubscriptionUpdate");return i(e,r,t)},async restoreNativePurchase(t){t=a(t),c(t);let r=await o(e,"restoreNativePurchase");return i(e,r,t)},async previewAttach(t){t=a(t),c(t);let r=await o(e,"previewAttach");return i(e,r,t)},async attach(t){t=a(t),c(t);let r=await o(e,"attach");return i(e,r,t)},async readSubscriptionOperation(t){t=a(t),c(t);let r=await o(e,"readSubscriptionOperation");return i(e,r,t)}}}export{c as a,I as b};
|