@tinkerlandai/longplay-sdk 0.10.7 → 0.10.11
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 +25 -1
- package/README.md +40 -4
- package/README.zh-CN.md +4 -2
- package/dist/{ai-usage-Btwg1nD7.d.ts → ai-usage-C-OZBxgW.d.ts} +1 -1
- package/dist/{api-5gAz4-Sb.d.ts → api-Bf_aRlXs.d.ts} +82 -0
- package/dist/chunk-33FQUT3Z.js +179 -0
- package/dist/chunk-4B5G3ZVV.js +4 -0
- package/dist/chunk-4C5XH3T3.js +1 -0
- package/dist/chunk-7DUOIHRD.js +6 -0
- package/dist/chunk-7RDYCTR4.js +1 -0
- package/dist/chunk-CDG7GM4C.js +1 -0
- package/dist/chunk-GDFBOM3V.js +1 -0
- package/dist/chunk-JGFAFQKK.js +1 -0
- package/dist/chunk-OZZMZH7X.js +1 -0
- package/dist/chunk-PYIHBK7E.js +1 -0
- package/dist/chunk-QHJAF5T2.js +1 -0
- package/dist/chunk-VSJOHWDL.js +17 -0
- package/dist/chunk-VSMITXQD.js +1 -0
- package/dist/chunk-ZYQPKGJM.js +1 -0
- package/dist/{configuration-sync-CywDxRkX.d.ts → configuration-sync-D2n_gGj6.d.ts} +1 -0
- package/dist/content-YQ7IJ47M.js +1 -0
- package/dist/{funnel-local-client-B4Z3dvNf.d.ts → funnel-local-client-DJq2K7an.d.ts} +8869 -93
- package/dist/{funnel-node-evaluation-P5B4fPfJ.d.ts → funnel-node-evaluation-CJSkUkbv.d.ts} +36 -0
- package/dist/{funnel-resource-client-BhbXsB2q.d.ts → funnel-process-client-C_UhTH8g.d.ts} +5132 -41
- package/dist/funnel-runtime-host-K2SXD2R2.js +1 -0
- package/dist/index.d.ts +106 -77
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +2 -2
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +1 -1
- package/dist/page.js +1 -1
- package/dist/paywall-PJEMTVSZ.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +109 -106
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-NHJ6OQTF.js +1 -0
- package/dist/server.d.ts +10677 -25
- package/dist/server.js +1 -1
- package/dist/{visual-dom-OIXANRP3.js → visual-dom-7IF7ITAK.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +10 -9
- package/dist/chunk-22Z7JR4B.js +0 -1
- package/dist/chunk-3OFRQUUI.js +0 -1
- package/dist/chunk-5JJZSH23.js +0 -179
- package/dist/chunk-6LILLFH3.js +0 -1
- package/dist/chunk-7DXL3LHT.js +0 -1
- package/dist/chunk-ACF2FBUB.js +0 -1
- package/dist/chunk-G56XGVMS.js +0 -1
- package/dist/chunk-I4BZSRT4.js +0 -1
- package/dist/chunk-IAOOTBJV.js +0 -6
- package/dist/chunk-O52OWKP7.js +0 -4
- package/dist/chunk-SBPTOOYB.js +0 -1
- package/dist/chunk-SV6W2E2A.js +0 -1
- package/dist/chunk-XSVQHPQT.js +0 -17
- package/dist/chunk-Y3AGPHWF.js +0 -1
- package/dist/chunk-ZKSKBL4N.js +0 -1
- package/dist/content-F7IVCK3I.js +0 -1
- package/dist/funnel-runtime-host-W25OXLGE.js +0 -1
- package/dist/paywall-XGDRMPLP.js +0 -1
- package/dist/screen-renderer-NLB3FAQJ.js +0 -1
- /package/dist/{chunk-AK3IJ6FZ.js → chunk-OJM6ORHE.js} +0 -0
package/dist/chunk-6LILLFH3.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as t}from"./chunk-Y3AGPHWF.js";import{Ga as n}from"./chunk-IAOOTBJV.js";function r(e,o,a){return n(e,o,a,t)}export{r as a};
|
package/dist/chunk-7DXL3LHT.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{z as e}from"zod";var c=e.json().superRefine((t,i)=>{let r=0;function o(n,s){if(++r>1e4||s>20){i.addIssue({code:"custom",message:"JSON exceeds its depth or node budget"});return}if(typeof n=="string"&&(n.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(n))&&i.addIssue({code:"custom",message:"JSON text must contain valid Unicode without NUL"}),Array.isArray(n))n.forEach(a=>o(a,s+1));else if(n&&typeof n=="object")for(let[a,u]of Object.entries(n))(a.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(a)||["__proto__","prototype","constructor"].includes(a))&&i.addIssue({code:"custom",message:"Reserved JSON property"}),o(u,s+1)}o(t,0),new TextEncoder().encode(JSON.stringify(t)).byteLength>65536&&i.addIssue({code:"custom",message:"JSON exceeds 64 KiB"})}),l=e.record(e.string().min(1).max(128),c).superRefine((t,i)=>{(!c.safeParse(t).success||Object.keys(t).length>128||new TextEncoder().encode(JSON.stringify(t)).byteLength>65536||["__proto__","constructor","prototype"].some(r=>Object.hasOwn(t,r)))&&i.addIssue({code:"custom",message:"Attribute document exceeds its budget or uses a reserved key"})}),b=new Set(["$in","$ini","$inGroup","$nin","$nini","$notInGroup","$gt","$gte","$lt","$lte","$regex","$regexi","$ne","$eq","$size","$elemMatch","$all","$alli","$not","$type","$exists","$vgt","$vgte","$vlt","$vlte","$vne","$veq","$and","$or","$nor","$savedGroup"]),d=l.superRefine((t,i)=>{function r(o){if(Array.isArray(o))o.forEach(r);else if(o&&typeof o=="object")for(let[n,s]of Object.entries(o)){if(n==="$savedGroup"&&!e.strictObject({id:e.uuid(),attributeKey:e.string().min(1).max(128).optional()}).safeParse(s).success&&i.addIssue({code:"custom",message:"Saved groups use v2 object references"}),!n.startsWith("$")&&n.split(".").some(a=>["__proto__","prototype","constructor"].includes(a))&&i.addIssue({code:"custom",message:"Reserved attribute path"}),n.startsWith("$")&&!b.has(n)&&i.addIssue({code:"custom",message:`Unknown GrowthBook operator: ${n}`}),["$regex","$regexi"].includes(n)&&typeof s=="string"){(/\(\?[<!=]|\\[0-9]|\\k</.test(s)||[...s.matchAll(/\{(\d+)(?:,(\d*))?\}/g)].some(a=>Number(a[1])>255||Number(a[2]||0)>255)||n==="$regexi"&&/[^\x00-\x7f]/.test(s.replace(/\\u([0-9a-f]{4})/gi,(a,u)=>String.fromCharCode(Number.parseInt(u,16)))))&&i.addIssue({code:"custom",message:"Regex is outside the shared TS/SQL subset"});try{new RegExp(s)}catch{i.addIssue({code:"custom",message:"Invalid regular expression"})}}r(s)}}typeof t.source=="string"&&["all","any","group","parameter","answer","attribute","result"].includes(t.source)&&("operator"in t||"predicates"in t||"groupId"in t)&&i.addIssue({code:"custom",message:"Obsolete condition protocol"}),r(t)}),y=e.discriminatedUnion("type",[e.strictObject({type:e.literal("condition"),condition:d}),e.strictObject({type:e.literal("list"),attributeKey:e.string().min(1).max(128),values:e.array(e.union([e.string(),e.number().finite()])).max(1e5)})]).refine(t=>t.type!=="list"||new TextEncoder().encode(JSON.stringify(t.values)).byteLength<=1048576,"Saved group list exceeds 1 MiB");function x(t){let i=new Set;function r(o){if(Array.isArray(o))o.forEach(r);else if(o&&typeof o=="object")for(let[n,s]of Object.entries(o))n==="$savedGroup"&&s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.id=="string"?i.add(s.id):["$inGroup","$notInGroup"].includes(n)&&typeof s=="string"?i.add(s):["$eq","$ne","$in","$nin","$ini","$nini"].includes(n)||r(s)}return r(t),[...i]}var S=e.record(e.uuid(),y).superRefine((t,i)=>{let r=new Set,o=new Set;function n(s){if(r.has(s)){i.addIssue({code:"custom",message:"Cyclic saved group dependency"});return}if(o.has(s))return;let a=t[s];if(!a){i.addIssue({code:"custom",message:"Missing saved group dependency"});return}r.add(s),a.type==="condition"&&x(a.condition).forEach(n),r.delete(s),o.add(s)}Object.keys(t).forEach(n)}),g=e.tuple([e.number().min(0).max(1),e.number().min(0).max(1)]).refine(([t,i])=>t<=i),f=e.strictObject({attribute:e.string().optional(),seed:e.string().min(1),hashVersion:e.literal(2),ranges:e.array(g).min(1).max(100)}),$=e.strictObject({id:e.string().min(1).max(128),condition:d,gate:e.boolean().optional()}),m={id:e.string().max(128).optional(),condition:d.optional(),parentConditions:e.array($).max(50).optional(),filters:e.array(f).max(20).optional()},w=e.union([e.strictObject({...m}),e.strictObject({...m,force:c,coverage:e.number().min(0).max(1).optional(),range:g.optional(),seed:e.string().min(1).optional(),hashAttribute:e.string().optional(),hashVersion:e.literal(2).optional()}),e.strictObject({...m,type:e.literal("experiment-ref"),experimentId:e.uuid(),values:e.record(e.string().min(1),c),meta:e.record(e.string().min(1),e.strictObject({passthrough:e.boolean()})).optional()})]),v=e.strictObject({defaultValue:c,rules:e.array(w).max(100)}),V=e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),v).superRefine((t,i)=>{Object.keys(t).length>100&&i.addIssue({code:"custom",message:"Too many Features"});let r=new Set,o=new Set;function n(s){if(r.has(s)){i.addIssue({code:"custom",message:`Cyclic Feature dependency: ${s}`});return}if(o.has(s))return;let a=t[s];if(!a){i.addIssue({code:"custom",message:`Unknown prerequisite Feature: ${s}`});return}r.add(s);for(let u of a.rules)for(let p of u.parentConditions??[])n(p.id);r.delete(s),o.add(s)}Object.keys(t).forEach(n)}),O=e.strictObject({name:e.string().max(80),reason:e.string().max(500),dateStarted:e.iso.datetime({offset:!0}),dateEnded:e.iso.datetime({offset:!0}).nullable(),coverage:e.number().min(0).max(1),variationWeights:e.array(e.number().min(0).max(1)).min(2).max(20).refine(t=>Math.abs(t.reduce((i,r)=>i+r,0)-1)<=.01),condition:d,savedGroups:e.array(e.strictObject({match:e.enum(["any","all","none"]),ids:e.array(e.uuid()).min(1)})).max(50),namespace:e.strictObject({id:e.uuid(),ranges:e.array(g).min(1)}).nullable(),seed:e.string().min(1).max(128)}),j=e.strictObject({key:e.string().min(1).max(128),name:e.string().min(1).max(80),hypothesis:e.string().max(2e3),status:e.enum(["draft","running","stopped"]),hashAttribute:e.string().min(1).max(128),fallbackAttribute:e.string().max(128).nullable(),hashVersion:e.literal(2),disableStickyBucketing:e.boolean(),bucketVersion:e.number().int().min(0).max(1e3),minBucketVersion:e.number().int().min(0).max(1e3),variations:e.array(e.strictObject({id:e.string().min(1),key:e.string().min(1),name:e.string().max(80),description:e.string().max(500)})).min(2).max(20),phases:e.array(O).min(1).max(100),releasedVariationId:e.string().nullable(),excludeFromPayload:e.boolean(),statusSchedule:e.strictObject({startAt:e.iso.datetime({offset:!0}).nullable(),stopAt:e.iso.datetime({offset:!0}).nullable(),stopAfter:e.strictObject({value:e.number().int().positive().max(36500),unit:e.enum(["hours","days"])}).nullable().optional()}).nullable()}).superRefine((t,i)=>{(t.minBucketVersion>t.bucketVersion||t.statusSchedule?.stopAt&&t.statusSchedule?.stopAfter||t.phases.some((r,o)=>{if(o===0)return!1;let n=t.phases[o-1];return!n?.dateEnded||Date.parse(r.dateStarted)<Date.parse(n.dateStarted)||Date.parse(n.dateEnded)>Date.parse(r.dateStarted)})||new Set(t.variations.map(r=>r.key)).size!==t.variations.length||new Set(t.variations.map(r=>r.id)).size!==t.variations.length||t.releasedVariationId!==null&&!t.variations.some(r=>r.id===t.releasedVariationId)||t.statusSchedule?.startAt&&t.statusSchedule?.stopAt&&Date.parse(t.statusSchedule.startAt)>=Date.parse(t.statusSchedule.stopAt)||t.phases.some(r=>r.dateEnded&&Date.parse(r.dateStarted)>=Date.parse(r.dateEnded)||r.namespace?.ranges.some(([o,n],s,a)=>o>=n||a.some(([u,p],h)=>h!==s&&o<p&&u<n)))||t.phases.some(r=>r.variationWeights.length!==t.variations.length))&&i.addIssue({code:"custom",message:"Invalid experiment versions, variation keys or weights"})});var F=j.safeExtend({filters:e.array(f).optional()}),A=e.strictObject({experiments:e.record(e.uuid(),F),savedGroups:S}),k=e.strictObject({attributeName:e.string(),attributeValue:e.string(),assignments:e.record(e.string(),e.string())}),_=e.strictObject({snapshot:A,attributes:l,results:l,stickyBucketAssignmentDocs:e.record(e.string(),k)}),z=e.strictObject({variantKey:e.string().nullable(),bucketVersion:e.number().int().min(0),source:e.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),bucket:e.number().min(0).max(1).optional(),stickyBucketUsed:e.boolean().optional(),hashUsed:e.boolean().optional()});export{c as a,l as b,d as c,x as d,k as e};
|
package/dist/chunk-ACF2FBUB.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as pe}from"./chunk-7DXL3LHT.js";import{z as yt}from"zod";var bt=["USD","EUR","CNY","GBP","JPY","CAD","AUD","NZD","CHF","HKD","SGD","KRW","INR","BRL","MXN","TWD","THB","IDR","MYR","PHP","VND","ZAR","AED","SAR","SEK","NOK","DKK","PLN","CZK","HUF","ILS","TRY","RON"],C=yt.enum(bt);function ht(e){let t=C.parse(e.toUpperCase());return["JPY","KRW","VND"].includes(t)?0:2}function me(e,t,i="en",r={}){let o=C.parse(t.toUpperCase());return new Intl.NumberFormat(i,{style:"currency",currency:o,...r}).format(e/10**ht(o))}import{z as x}from"zod";import{z as _}from"zod";var oe=_.string().regex(/^(0|[1-9]\d{0,12})(\.\d{1,12})?$/),I=_.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e),xt=_.string().regex(/^-?(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>{let t=e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e;return t==="-0"?"0":t}),de=I.refine(e=>/[1-9]/.test(e),"\u6570\u91CF\u5FC5\u987B\u5927\u4E8E 0"),Ae=_.string().min(1).max(64),$=_.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),Ne=_.string().min(1).max(64).refine(e=>!e.includes("::"),"Dimension IDs cannot contain ::"),T=_.record(Ae,_.union([_.string().max(120),_.number().finite(),_.boolean()])).refine(e=>Object.keys(e).length<=16,"\u6700\u591A 16 \u4E2A\u8BA1\u4EF7\u5C5E\u6027").transform(e=>Object.fromEntries(Object.entries(e).map(([t,i])=>[t,String(i)]))),Re=_.record(Ae,_.union([_.string().max(120),_.number().finite(),_.boolean()]).transform(String)).refine(e=>Object.keys(e).length<=8,"\u5339\u914D\u6761\u4EF6\u6700\u591A 8 \u4E2A\u5C5E\u6027"),F=e=>{let t=e.startsWith("-");t&&(e=e.slice(1));let[i,r=""]=e.split(".");if(i===void 0||i==="")throw new Error("Invalid decimal value");let o=BigInt(i)*BigInt("1000000")+BigInt(r.padEnd(6,"0"));return t?-o:o},ke=_.array(_.object({upTo:de.nullable(),cost:I}).strict()).min(1).max(12).refine(e=>e.at(-1)?.upTo===null&&e.slice(0,-1).every((t,i)=>{let r=e[i-1]?.upTo;return t.upTo!==null&&(i===0||r!=null&&F(t.upTo)>F(r))}),"\u9636\u68AF\u4E0A\u9650\u5FC5\u987B\u9012\u589E\uFF0C\u6700\u540E\u4E00\u6863\u4E3A\u65E0\u9650"),St=_.object({key:Ne,match:Re,priority:_.number().int().default(0),cost:I.optional(),tiers:ke.optional()}).strict().refine(e=>e.cost!==void 0||e.tiers!==void 0,"\u7EF4\u5EA6\u9700\u8981\u6307\u5B9A\u5355\u4EF7\u6216\u9636\u68AF"),_t=_.object({key:Ne,match:Re,factor:de.optional(),add:xt.optional()}).strict().refine(e=>e.factor!==void 0||e.add!==void 0,"A multiplier needs a factor or an add").transform(e=>({...e,factor:e.factor??"1",add:e.add??"0"})),It=_.object({units:de.default("1"),cost:I,tiers:ke.optional(),dimensions:_.array(St).max(12).optional(),multipliers:_.array(_t).max(4).optional()}).strict().superRefine((e,t)=>{let i=e.dimensions??[],r=e.multipliers??[];(new Set(i.map(s=>s.key)).size!==i.length||new Set(r.map(s=>s.key)).size!==r.length)&&t.addIssue({code:"custom",message:"\u7EF4\u5EA6\u548C\u500D\u7387\u7684 ID \u4E0D\u80FD\u91CD\u590D"});for(let[s,u]of i.entries())for(let d of i.slice(s+1))Object.keys(u.match).length===Object.keys(d.match).length&&u.priority===d.priority&&!Object.keys(u.match).some(g=>d.match[g]!==void 0&&d.match[g]!==u.match[g])&&t.addIssue({code:"custom",message:"\u7EF4\u5EA6\u53EF\u80FD\u540C\u65F6\u5339\u914D\uFF0C\u8BF7\u8C03\u6574\u4F18\u5148\u7EA7"});let o=[e.cost,...(e.tiers??[]).map(s=>s.cost),...i.flatMap(s=>[...s.cost===void 0?[]:[s.cost],...(s.tiers??[]).map(u=>u.cost)])],c=F(e.units);for(let s of o)for(let u=0;u<1<<r.length;u++){let d=r.filter((O,A)=>u&1<<A);if(d.some((O,A)=>d.slice(A+1).some(M=>Object.keys(O.match).some(Q=>M.match[Q]!==void 0&&M.match[Q]!==O.match[Q]))))continue;let g=F(s),l=BigInt("1"),b=BigInt("0");for(let[O,A]of r.entries())u&1<<O&&(g*=F(A.factor??"1"),l*=BigInt("1000000"),b+=F(A.add??"0"));let S=(g+b*l)*BigInt("1000000"),k=l*c;(S<BigInt("0")||S%k!==BigInt("0")||S/k>BigInt("999999999999999999"))&&t.addIssue({code:"custom",message:"\u6BCF\u4E2A\u4E1A\u52A1\u5355\u4F4D\u7684\u6700\u7EC8\u5355\u4EF7\u5FC5\u987B\u975E\u8D1F\u3001\u5728\u8303\u56F4\u5185\u4E14\u80FD\u7CBE\u786E\u8868\u793A\u4E3A\u6700\u591A 6 \u4F4D\u5C0F\u6570"})}}),Tr=It.safeExtend({featureKey:$});import{z as Et}from"zod";import{z as Z}from"zod";var Oe=Z.enum(["stripe","apple","google","merchant"]),Dr=Z.enum(["membership","credit_pack","lifetime"]),zr=Z.enum(["active","grace","suspended","inactive","revoked"]),vr=Z.strictObject({currency:Z.string().regex(/^[A-Z]{3}$/),micros:Z.string().regex(/^(0|[1-9][0-9]{0,29})$/)});var Ce=Et.object({provider:Oe,currency:C}).strict();var Pe=x.strictObject({internal_feature_id:x.uuid(),quantity:I.refine(e=>/[1-9]/.test(e)),properties:T,entityId:x.uuid().optional()}),Gr=x.strictObject({requirement:Pe,commerce:Ce.optional(),paywallId:x.uuid().optional()}),At=x.enum(["not_entitled","insufficient_balance","capacity_exceeded","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded","unavailable","authentication_required"]),Nt=x.strictObject({productId:x.string().min(1),productVersionId:x.string().min(1),name:x.string().min(1).max(120),action:x.enum(["purchase","upgrade","addon","topup"]),membershipId:x.string().min(1).nullable(),currency:C,amountMinor:x.string().regex(/^(0|[1-9]\d{0,8})$/),interval:x.enum(["free","week","month","year","one_time"]),intervalCount:x.number().int().min(1).max(156)}),we=x.strictObject({internal_feature_id:x.string().min(1),name:x.string().min(1).max(120),kind:x.enum(["access","metered","credit"]),quantity:I,allowed:x.boolean(),reason:At.nullable(),preview:x.strictObject({scenario:x.enum(["feature_flag","usage_limit"]),candidates:x.array(Nt).max(20)}).nullable()}).superRefine((e,t)=>{(e.allowed!==(e.reason===null)||e.allowed&&e.preview!==null||new Set(e.preview?.candidates.map(i=>i.productVersionId)).size!==(e.preview?.candidates.length??0)||e.preview?.candidates.some(i=>i.action==="upgrade"!=(i.membershipId!==null)))&&t.addIssue({code:"custom",message:"Invalid access recommendation"})}),Hr=x.strictObject({paywallId:x.uuid(),requirement:Pe});import{z as m}from"zod";import{z as K}from"zod";import{z as H}from"zod";import{z as G}from"zod";var Te=G.number().int().min(0).max(1e8),fe=G.strictObject({kind:G.enum(["graduated","volume"]),tiers:G.array(G.strictObject({upTo:G.number().int().min(1).max(1e4).nullable(),unitAmountMinor:Te,flatAmountMinor:Te.optional()})).min(1).max(12)}).refine(e=>e.tiers.at(-1)?.upTo===null&&e.tiers.slice(0,-1).every((t,i)=>{let r=e.tiers[i-1]?.upTo;return t.upTo!==null&&(i===0||r!=null&&t.upTo>r)}),"Tier ceilings must increase and end unbounded").refine(e=>!e.tiers.some(t=>(t.flatAmountMinor??0)>0)||e.kind==="volume"&&e.tiers.length>1,"Tier flat fees require volume pricing with multiple tiers");function ge(e,t){if(!Number.isInteger(t)||t<0||t>1e4)throw new Error("Invalid purchased pack quantity");let i=e.pricing?fe.parse(e.pricing):void 0;if(t===0)return 0;let r=0n,o=0;if(!i)r=BigInt(e.amountMinor)*BigInt(t);else for(let c of i.tiers){let s=c.upTo??1e4;if(i.kind==="volume"){if(t<=s){r=BigInt(t)*BigInt(c.unitAmountMinor)+BigInt(c.flatAmountMinor??0);break}}else t>o&&(r+=BigInt(Math.min(t,s)-o)*BigInt(c.unitAmountMinor));o=s}if(r>200000000n)throw new Error("Purchased price exceeds the payment amount limit");return Number(r)}function je(e){return ge({amountMinor:e.unitAmountMinor,...e.pricing?{pricing:e.pricing}:{}},e.quantity)}var Rt=I.refine(e=>/[1-9]/.test(e)),De=H.strictObject({units:Rt,prices:H.array(H.strictObject({currency:C,amountMinor:H.number().int().min(0).max(1e8),pricing:fe.optional()})).min(1).max(20).refine(e=>new Set(e.map(t=>t.currency)).size===e.length,"Currencies must be unique").refine(e=>e.every(t=>!t.pricing||t.amountMinor===0),"Tiered prices specify their rates in tiers"),minimumQuantity:H.number().int().min(0).max(1e4),maximumQuantity:H.number().int().min(0).max(1e4)}).refine(e=>e.maximumQuantity>=e.minimumQuantity,"Purchased quantity must fit its published bounds").refine(e=>{try{for(let t of e.prices)for(let i of[e.maximumQuantity,...t.pricing?.tiers.flatMap(r=>r.upTo===null?[]:[r.upTo,r.upTo+1])??[]])i<=e.maximumQuantity&&ge({amountMinor:t.amountMinor,...t.pricing===void 0?{}:{pricing:t.pricing}},i);return!0}catch{return!1}},"Every purchasable quantity must fit the payment amount limit");function Le(e){if(!/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/.test(e))throw new Error("Invalid quantity");let[t,i=""]=e.split(".");if(t===void 0||t==="")throw new Error("Invalid decimal value");return BigInt(t)*1000000n+BigInt(i.padEnd(6,"0"))}function ze(e,t,i){if(!Number.isSafeInteger(i)||i<0||i>1e4)throw new Error("Invalid purchased quantity");let r=Le(e)+Le(t)*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 ye=K.strictObject({internalFeatureId:K.uuid(),name:K.string().min(1).max(120),includedAmount:K.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),reset:K.enum(["hour","day","week","month","year","lifetime"]),resetCount:K.number().int().min(1).max(100),terms:De});var kt=["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"],ae=m.object({plan:m.string().min(1).max(200).optional(),coupon:m.uuid().optional(),promotionCode:m.uuid().optional(),picker:m.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).optional()}).strict(),ve=m.object({text:m.string().optional(),label:m.string().optional(),alt:m.string().optional(),html:m.string().max(32768).optional(),price:m.object({current:m.string(),original:m.string().nullable(),period:m.string()}).optional(),code:m.string().optional(),countdownAt:m.iso.datetime().optional(),planId:m.string().min(1).max(200).optional(),planVersionId:m.string().min(1).max(200).optional(),currency:C.optional(),couponId:m.uuid().optional(),offerId:m.uuid().optional(),unavailable:m.boolean().optional(),unavailableReason:m.string().optional(),missing:m.array(m.string()).optional()}).strict(),pn=m.object({paywall:we.optional(),nodes:m.record(m.string(),m.object({base:ve,picker:m.string().optional(),byPlan:m.record(m.string(),ve).optional()}).strict()),plans:m.record(m.string(),m.object({id:m.string().min(1).max(200),versionId:m.string().min(1).max(200),available:m.boolean(),name:m.string(),price:m.string(),period:m.string(),currency:C.optional(),amountMinor:m.number().int().nonnegative().optional(),interval:m.enum(["free","week","month","year","one_time"]).optional(),intervalCount:m.number().int().positive().optional(),prepaid:m.array(ye).max(100).optional()}).strict()),pickers:m.record(m.string(),m.object({options:m.array(m.string().min(1).max(200)).max(20),selected:m.string().min(1).max(200).nullable()}).strict()),quantities:m.record(m.string(),m.strictObject({minimum:m.number().int().nonnegative(),maximum:m.number().int().nonnegative(),step:m.number().int().positive(),value:m.number().int().nonnegative(),label:m.string(),available:m.boolean()})).optional(),diagnostics:m.array(m.object({nodeId:m.string(),message:m.string()}).strict())}).strict();function Ue(e){return[...e.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].flatMap(t=>t[1]===void 0?[]:[t[1].trim()])}function be(e){let t=Ue(e).filter(r=>!kt.includes(r)&&!/^variables\.[A-Za-z0-9_][A-Za-z0-9_.:-]*$/.test(r)),i=e.replace(/\{\{\s*[^{}]+?\s*\}\}/g,"");return(i.includes("{{")||i.includes("}}"))&&t.push("\u65E0\u6548\u53D8\u91CF\u8BED\u6CD5"),[...new Set(t)]}function mn(e,t,i={}){let r=e?.nodes[t];if(!r)return;let o=r.picker?i[r.picker]??e?.pickers[r.picker]?.selected:void 0;return typeof o=="string"?r.byPlan?.[o]??r.base:r.base}import{z as f}from"zod";var Ot=["credit_balance","credit_transactions","membership","billing","billing_controls","customer_plans","credit_packs","credit_pack_orders","offer_history"],Ve=f.enum(Ot),Me=f.object({source:Ve,layout:f.enum(["full","compact"]),resourceKey:$.optional(),pageSize:f.number().int().min(1).max(50),showSources:f.boolean(),allowPurchase:f.boolean(),outputs:f.object({billing_adjustment:f.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_authorization:f.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),buy_pack:f.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_portal:f.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),cancel_membership:f.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),resume_membership:f.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional()}).strict().optional()}).strict().superRefine((e,t)=>{(e.outputs?.billing_authorization||e.outputs?.billing_adjustment)&&e.source!=="billing_controls"&&t.addIssue({code:"custom",message:"Payment authorization routes belong to the billing controls component."}),e.resourceKey&&!["credit_balance","credit_transactions"].includes(e.source)&&t.addIssue({code:"custom",message:"\u8FD9\u4E2A\u6570\u636E\u6E90\u4E0D\u80FD\u7ED1\u5B9A\u79EF\u5206\u8D44\u6E90\u3002"}),e.showSources&&e.source!=="credit_balance"&&t.addIssue({code:"custom",message:"\u53EA\u6709\u79EF\u5206\u4F59\u989D\u53EF\u4EE5\u5C55\u5F00\u6765\u6E90\u3002"}),e.allowPurchase&&!["credit_packs","customer_plans","membership"].includes(e.source)&&t.addIssue({code:"custom",message:"\u53EA\u6709\u79EF\u5206\u5305\u3001\u5957\u9910\u4E0E\u4F1A\u5458\u7EC4\u4EF6\u53EF\u4EE5\u542F\u7528\u4EA4\u6613\u3002"})}),N=f.string().max(2e3),$e=f.object({id:f.string().max(100),label:N,detail:f.array(N).max(12),value:N.optional(),status:N.optional(),facts:f.array(f.object({label:N,value:N}).strict()).max(1e3),purchaseId:f.uuid().optional(),invoiceUrl:f.url().max(2048).refine(e=>{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}).optional(),billingActions:f.array(f.strictObject({action:f.literal("invoice_open"),label:N})).max(1).optional(),membershipActions:f.array(f.object({value:f.string().max(100),label:N}).strict()).max(3).optional()}).strict(),Ct=f.object({key:$,name:N,spendable:N,reserved:N,available:N,expiry:N.nullable(),sources:f.array($e).max(50),sourceCount:f.number().int().nonnegative(),sourcePage:f.number().int().positive(),hasNextSources:f.boolean(),hasPreviousSources:f.boolean()}).strict(),Pt=f.object({source:Ve,status:f.enum(["idle","loading","ready","error"]),stale:f.boolean(),preview:f.boolean(),errorCode:f.string().max(80).optional(),errorMessage:N.optional(),resources:f.array(Ct).max(500),rows:f.array($e).max(50),hasNext:f.boolean(),hasPrevious:f.boolean(),page:f.number().int().positive(),filter:f.string().max(40),updatedAt:f.iso.datetime().optional(),buyingId:f.uuid().optional(),membershipBusy:f.boolean().optional(),billingBusy:f.boolean().optional(),membershipReview:f.object({title:N,note:N,facts:f.array(f.object({label:N,value:N}).strict()).max(100)}).strict().optional(),membershipResult:N.optional()}).strict(),yn=f.object({nodes:f.record(f.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Pt)}).strict(),bn=f.object({nodeId:f.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),action:f.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:f.string().max(100).optional()}).strict();import{z as n}from"zod";function Be(e){return e.type==="stack"&&e.interaction?.type==="select"&&e.interaction.purpose==="product"&&!!e.interaction.pickerId}function qe(e){let t={};function i(r){if(Be(r)){let o=t[r.interaction.pickerId]??={ids:[],defaultId:null};for(let s of r.children){let u=s.type==="stack"?s.bind?.plan:void 0;u&&!o.ids.includes(u)&&o.ids.push(u)}let c=r.children[r.interaction.defaultIndex];!o.defaultId&&c?.type==="stack"&&(o.defaultId=c.bind?.plan??null)}r.type==="stack"&&r.children.forEach(i)}return e.pages.forEach(r=>i(r.root)),t}function Qe(e,t,i){let r={};function o(d){if(d.hidden)return;if(d.type==="plan_picker"){let b=i.pickers[d.id];r[d.id]={ids:b?.options??[],defaults:b?.selected?[b.selected]:[],remembered:[]};return}if(d.type!=="stack")return;let g=d.children.filter(b=>!b.hidden),l=d.interaction;if(Be(d)){let b=r[d.interaction.pickerId]??={ids:[],defaults:[],remembered:[]},S=i.pickers[d.interaction.pickerId]?.options??[];for(let O of g){let A=O.type==="stack"?O.bind?.plan:void 0;A&&S.includes(A)&&!b.ids.includes(A)&&b.ids.push(A),A&&O.id===t[d.id]&&b.remembered.push(A)}let k=d.children[d.interaction.defaultIndex];k?.type==="stack"&&!k.hidden&&k.bind?.plan&&b.defaults.push(k.bind.plan)}if(l?.type==="tabs"){let b=g.find(S=>S.id===t[d.id])??d.children[l.defaultIndex];b&&o(b)}else if(l?.type==="toggle"){let b=typeof t[d.id]=="boolean"?t[d.id]:l.defaultEnabled,S=d.children[b?0:1];S&&o(S)}else g.forEach(o)}let c=typeof t.__page=="string"?t.__page:e.initialPageId??e.pages[0]?.id,s=e.pages.find(d=>d.id===c);s&&o(s.root);let u={};for(let[d,g]of Object.entries(r)){let l=t[d],b=g.remembered[0]??(g.ids.includes(i.pickers[d]?.selected??"")?i.pickers[d]?.selected:g.defaults[0]);u[d]=typeof l=="string"?g.ids.includes(l)?l:"":b&&g.ids.includes(b)?b:""}for(let d of Object.keys(qe(e)))u[d]??="";return u}import{z as V}from"zod";var Fe=V.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Ze=V.strictObject({tiers:V.array(V.strictObject({id:Fe,name:V.string().trim().min(1).max(80)})).min(1).max(8),assignments:V.array(V.strictObject({productVersionId:V.string().min(1).max(200),tierId:Fe,period:V.enum(["month","year"])})).max(20)}).superRefine((e,t)=>{let i=e.tiers.map(r=>r.id);(new Set(i).size!==i.length||new Set(e.assignments.map(r=>r.productVersionId)).size!==e.assignments.length||new Set(e.assignments.map(r=>`${r.tierId}:${r.period}`)).size!==e.assignments.length||e.assignments.some(r=>!i.includes(r.tierId)))&&t.addIssue({code:"custom",message:"Each product and tier/period cell must have one unambiguous assignment"})});function Ge(e,t){return e.assignments.length===t.length&&e.assignments.every(i=>t.includes(i.productVersionId))}function En(e){let t=be(e).map(i=>`\u672A\u77E5\u53D8\u91CF\uFF1A${i}`);for(let i=0;i<e.length;i++){if(e[i]!=="<"||!/[A-Za-z!/?{]/.test(e[i+1]??""))continue;let r=i;if(e.startsWith("<!--",i)){let o=e.indexOf("-->",i+4);i=o<0?e.length:o+2}else{let o="";for(i++;i<e.length;i++){let c=e[i];if(o)c===o&&(o="");else if(c==='"'||c==="'")o=c;else if(c===">")break}}/\{\{|\}\}/.test(e.slice(r,i+1))&&t.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(t)]}import{z as wt}from"zod";var Ke=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,W=wt.string().max(16).regex(Ke,"\u8BED\u8A00\u4EE3\u7801\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u4F8B\u5982 zh-CN\u3001en").refine(e=>{try{return Intl.getCanonicalLocales(e)[0]===e}catch{return!1}},"\u6301\u4E45\u5316\u8BED\u8A00\u4EE3\u7801\u5FC5\u987B\u4F7F\u7528\u89C4\u8303\u5199\u6CD5");function he(e){if(typeof e!="string")return null;try{let t=Intl.getCanonicalLocales(e.trim().replaceAll("_","-"))[0];if(!t)return null;let{language:i,script:r,region:o}=new Intl.Locale(t),c=[i,r,o].filter(Boolean).join("-");return Ke.test(c)?c:null}catch{return null}}var Tt=new Set(["TW","HK","MO"]);function He(e){let[t,i,r]=e.split("-");if(t!=="zh")return`${t}-${new Intl.Locale(e).maximize().script??""}`;let o=i?.length===4?i:void 0,c=i?.length===4?r:i;return o?`zh-${o}`:c&&Tt.has(c)?"zh-Hant":"zh-Hans"}function We(e,t,i){let r=t.map(o=>({code:W.parse(o),normalized:o}));for(let o of e){let c=he(o);if(!c)continue;let s=r.find(l=>l.normalized===c);if(s)return s.code;let u=He(c),d=r.filter(l=>He(l.normalized)===u),g=d.find(l=>!l.normalized.includes("-")||l.normalized===u)??d[0];if(g)return g.code}return i}var jt=4,L={nodes:150,depth:8,children:50,locales:20,actions:40,pages:10,stringLength:2e3,customHtml:32768,customCss:16384,documentBytes:2e5},X=n.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),h=n.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Lt=n.enum(["none","xs","sm","md","lg","xl"]),Dt=n.enum(["none","sm","md","lg","full"]),xe=n.string().regex(/^#[0-9a-fA-F]{6}$/),Xe=n.string().max(2048).refine(e=>{try{let t=new URL(e);return t.protocol==="https:"&&t.hostname.length>0}catch{return!1}},"\u53EA\u652F\u6301 https \u94FE\u63A5"),Se=n.union([Xe,n.string().max(32768).regex(/^data:image\/svg\+xml;base64,[A-Za-z0-9+/]+={0,2}$/),n.string().max(131072).regex(/^data:image\/jpeg;base64,\/9j\/[A-Za-z0-9+/]+={0,2}$/),n.string().max(131072).regex(/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]+={0,2}$/)]),Ye=n.object({primary:xe,background:xe,text:xe,radius:Dt,font:n.enum(["system","serif","rounded","mono"])}).strict(),ee=n.union([n.enum(["primary","text","muted","background","surface"]),n.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)]),y=(e,t)=>n.number().int().min(e).max(t),Je=n.union([n.enum(["fit","fill"]),y(1,1200)]),zt=n.object({top:y(0,200),right:y(0,200),bottom:y(0,200),left:y(0,200)}).strict(),vt=n.object({top:y(-100,200),right:y(-100,200),bottom:y(-100,200),left:y(-100,200)}).strict(),et=n.object({x:y(0,100),y:y(0,100)}).strict(),Ut=n.discriminatedUnion("type",[n.object({type:n.literal("color"),color:ee}).strict(),n.object({type:n.literal("linear"),angle:y(0,360),stops:n.array(n.object({color:ee,at:y(0,100)}).strict()).min(2).max(4)}).strict(),n.object({type:n.literal("image"),src:Se,fit:n.enum(["cover","contain"]),position:et.optional()}).strict()]),Vt=n.discriminatedUnion("type",[n.object({type:n.literal("rect"),radius:n.union([y(0,200),n.object({topLeft:y(0,200),topRight:y(0,200),bottomRight:y(0,200),bottomLeft:y(0,200)}).strict()])}).strict(),n.object({type:n.literal("pill")}).strict()]),Mt=n.object({width:y(0,12),color:ee,style:n.enum(["solid","dashed"])}).strict(),$t=n.object({x:y(-40,40),y:y(-40,40),blur:y(0,80),spread:y(-20,40),color:ee}).strict(),Bt=n.object({font:n.enum(["system","serif","rounded","mono"]),size:y(8,96),weight:n.number().int().min(100).max(900).multipleOf(100),lineHeight:n.number().min(.8).max(3),letterSpacing:n.number().min(-5).max(20),color:ee,align:n.enum(["start","center","end"]),italic:n.boolean(),decoration:n.enum(["none","underline","line-through"]),transform:n.enum(["none","uppercase"])}).strict().partial(),B=n.object({width:Je,height:Je,padding:zt,margin:vt,gap:y(0,120),grow:n.union([n.boolean(),n.number().min(0).max(12)]),background:Ut,opacity:n.number().min(0).max(1),clipContent:n.boolean(),shape:Vt,border:Mt,shadow:$t,text:Bt}).strict().partial(),P={id:X,name:n.string().trim().min(1).max(60).optional(),hidden:n.boolean().optional(),style:B.optional(),fallback:h.optional()},qt=n.object({...P,type:n.literal("text"),productField:n.enum(["name","price","trial","period"]).optional(),feature:n.object({id:n.uuid(),field:n.enum(["name","allowance"])}).strict().optional(),text:h,variant:n.enum(["title","heading","body","caption"])}).strict(),Qt=n.object({...P,type:n.literal("image"),src:Se,localizedSrc:n.record(W,Se).optional(),alt:h,aspect:n.enum(["auto","1:1","4:3","16:9","3:1"]),fit:n.enum(["cover","contain"]),position:et.optional()}).strict(),Ft=n.object({...P,type:n.literal("button"),label:h,variant:n.enum(["primary","secondary","link"]),action:h,purpose:n.enum(["purchase","navigation","close"]).optional(),bind:ae.optional()}).strict(),Zt=n.object({...P,type:n.literal("divider")}).strict(),Gt=n.object({...P,type:n.literal("customer_data"),title:h,data:Me}).strict(),Ht=n.object({...P,type:n.literal("spacer"),size:Lt}).strict(),Kt=n.object({...P,type:n.literal("custom_html"),html:n.record(W,n.string().max(L.customHtml)),css:n.string().max(L.customCss)}).strict(),Wt=n.object({...P,type:n.literal("price"),fallback:h,parts:n.object({current:B.optional(),original:B.optional(),period:B.optional()}).strict().optional()}).strict(),Yt=n.object({...P,type:n.literal("coupon_code"),label:h,fallback:h}).strict(),Jt=n.object({...P,type:n.literal("countdown"),source:n.enum(["offer.ends_at","offer.expires_at","fixed"]),at:n.iso.datetime().optional(),granularity:n.enum(["day","hour","minute","second"]),expired:h,fallback:h}).strict().refine(e=>e.source!=="fixed"||!!e.at,"\u56FA\u5B9A\u5012\u8BA1\u65F6\u9700\u8981\u7ED3\u675F\u65F6\u95F4"),Xt=n.object({...P,type:n.literal("plan_picker"),label:h,fallback:h,planIds:n.array(n.string().min(1).max(200)).min(1).max(20).refine(e=>new Set(e).size===e.length,"\u5957\u9910\u4E0D\u80FD\u91CD\u590D").optional(),defaultPlan:n.string().min(1).max(200).optional(),grouping:Ze.safeExtend({monthLabel:h,yearLabel:h,unavailableLabel:h}).optional(),states:n.object({selected:B.optional()}).strict().optional()}).strict().superRefine((e,t)=>{e.grouping&&(!e.planIds||!Ge(e.grouping,e.planIds))&&t.addIssue({code:"custom",message:"Grouped picker assignments must match its product allowlist"})}),er=n.object({...P,type:n.literal("quantity_picker"),bind:ae.optional(),label:h,fallback:h,internalFeatureId:n.uuid(),minimumQuantity:y(0,1e4),maximumQuantity:y(0,1e4),defaultQuantity:y(0,1e4),step:y(1,1e4)}).strict().refine(e=>e.minimumQuantity<=e.defaultQuantity&&e.defaultQuantity<=e.maximumQuantity&&(e.defaultQuantity-e.minimumQuantity)%e.step===0,"Quantity controls require a Product binding and valid bounds"),tr=n.discriminatedUnion("type",[n.object({type:n.literal("input"),label:h,keyboard:n.enum(["text","email","tel","url"]),maxLength:y(1,500)}).strict(),n.object({type:n.literal("multiselect"),label:h,min:y(0,50),max:y(1,50)}).strict(),n.object({type:n.literal("select"),label:h,defaultIndex:y(0,49),purpose:n.enum(["option","product","tier"]).optional(),pickerId:X.optional(),selectedStyle:B.optional()}).strict(),n.object({type:n.literal("tabs"),label:h,defaultIndex:y(0,49),purpose:n.literal("tier").optional()}).strict(),n.object({type:n.literal("toggle"),label:h,defaultEnabled:n.boolean()}).strict(),n.object({type:n.literal("carousel"),label:h}).strict()]),j={...P,type:n.literal("stack"),direction:n.enum(["vertical","horizontal","overlay"]),align:n.enum(["start","center","end","stretch"]),justify:n.enum(["start","center","end","between"]),productSlot:n.object({index:y(0,19),period:n.enum(["month","year"]).optional(),requireBinding:n.boolean().optional()}).strict().optional(),interaction:tr.optional(),states:n.object({selected:B.optional()}).strict().optional(),purpose:n.literal("benefits").optional(),purchaseAction:h.optional(),buttonVariant:n.enum(["primary","secondary","link"]).optional(),bind:ae.optional()},tt=n.lazy(()=>n.object({...P,type:j.type,direction:j.direction,align:j.align,justify:j.justify,children:n.array(rr).max(L.children),productSlot:j.productSlot,interaction:j.interaction,states:j.states,purpose:j.purpose,purchaseAction:j.purchaseAction,buttonVariant:j.buttonVariant,bind:j.bind}).strict()),rr=n.lazy(()=>n.union([tt,qt,Qt,Ft,Zt,Ht,Kt,Wt,Yt,Jt,Xt,er,Gt])),nr=n.union([n.string().max(500),n.number().finite(),n.boolean(),n.null()]),J={id:h,event:h,properties:n.record(h,nr).refine(e=>Object.keys(e).length<=20,"\u6700\u591A 20 \u4E2A\u53C2\u6570")},ir=n.discriminatedUnion("type",[n.object({...J,type:n.literal("navigate"),close:n.literal(!1),pageId:X}).strict(),n.object({...J,type:n.literal("event"),close:n.boolean()}).strict(),n.object({...J,type:n.literal("close"),close:n.literal(!0)}).strict(),n.object({...J,type:n.literal("open_url"),close:n.boolean(),url:Xe}).strict(),n.object({...J,type:n.literal("claim_offer"),close:n.boolean(),couponId:n.uuid()}).strict()]),or=n.object({defaultLocale:W,locales:n.record(W,n.record(h,n.string().max(L.stringLength)))}).strict(),ar=n.enum(["popup","paywall","onboarding","page","banner"]);var sr=n.discriminatedUnion("type",[n.object({type:n.literal("modal"),size:n.enum(["sm","md","lg"])}).strict(),n.object({type:n.literal("sheet"),size:n.enum(["sm","md","lg"])}).strict(),n.object({type:n.literal("fullscreen")}).strict(),n.object({type:n.literal("inline")}).strict()]),jn={sm:360,md:420,lg:560},cr=n.object({kind:n.literal("screen"),schemaVersion:n.literal(jt),name:n.string().trim().min(1).max(80),surface:ar,initialPageId:X.optional(),presentation:sr,theme:Ye,pages:n.array(n.object({id:X,name:n.string().trim().min(1).max(60),root:tt,theme:Ye.optional(),editorPosition:n.object({x:n.number().finite().min(-1e5).max(1e5),y:n.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict()).min(1).max(L.pages),strings:or,actions:n.array(ir).max(L.actions)}).strict();function v(e,t){for(let i of e.pages)_e(i.root,t)}var Ln=cr.superRefine((e,t)=>{let i=L;e.surface!=="paywall"&&e.pages.length!==1&&t.addIssue({code:"custom",message:"Only a Paywall can contain multiple screens"}),e.initialPageId&&!e.pages.some(l=>l.id===e.initialPageId)&&t.addIssue({code:"custom",message:"Initial screen does not exist"});for(let l of e.actions)l.type==="navigate"&&(e.surface!=="paywall"||!e.pages.some(b=>b.id===l.pageId))&&t.addIssue({code:"custom",message:"Navigation screen does not exist"});e.pages.length>i.pages&&t.addIssue({code:"custom",message:`\u9875\u9762\u6700\u591A ${i.pages} \u4E2A`}),e.actions.length>i.actions&&t.addIssue({code:"custom",message:`\u52A8\u4F5C\u6700\u591A ${i.actions} \u4E2A`});let r=l=>t.addIssue({code:"custom",message:l}),o=Object.keys(e.strings.locales);o.includes(e.strings.defaultLocale)||r("\u9ED8\u8BA4\u8BED\u8A00\u5FC5\u987B\u5728\u8BED\u8A00\u5217\u8868\u91CC"),o.length>L.locales&&r(`\u6700\u591A ${L.locales} \u79CD\u8BED\u8A00`);let c=new Set;for(let l of e.actions)c.has(l.id)&&r(`\u52A8\u4F5C\u6807\u8BC6\u91CD\u590D\uFF1A${l.id}`),c.add(l.id);let s=new Set;for(let l of e.pages)["next","back"].includes(l.id)&&r(`\u9875\u9762 id \u4E0D\u80FD\u4F7F\u7528\u4FDD\u7559\u540D\u79F0\uFF1A${l.id}`),s.has(l.id)&&r(`\u9875\u9762 id \u91CD\u590D\uFF1A${l.id}`),s.add(l.id);let u=new Set,d=0,g=!1;v(e,(l,b)=>{if(d++,b>L.depth&&(g=!0),u.has(l.id)&&r(`\u7EC4\u4EF6 id \u91CD\u590D\uFF1A${l.id}`),u.add(l.id),l.type==="button"&&!c.has(l.action)&&r(`\u6309\u94AE ${l.id} \u5F15\u7528\u7684\u52A8\u4F5C\u4E0D\u5B58\u5728\uFF1A${l.action}`),l.type==="custom_html")for(let S of Object.keys(l.html))o.includes(S)||r(`\u81EA\u5B9A\u4E49 HTML ${l.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${S}`);if(l.type==="image")for(let S of Object.keys(l.localizedSrc??{}))o.includes(S)||r(`\u56FE\u7247 ${l.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${S}`)}),d>i.nodes&&r(`\u7EC4\u4EF6\u6700\u591A ${i.nodes} \u4E2A`),g&&r(`\u5C42\u7EA7\u6700\u591A ${L.depth} \u5C42`)});function _e(e,t,i=1,r=null){if(t(e,i,r)!==!1&&e.type==="stack")for(let o of e.children)_e(o,t,i+1,e)}function rt(e){let t=[],i=new Set;return v(e,r=>{let o=(c,s,u)=>{i.has(c)||(i.add(c),t.push({key:c,nodeId:r.id,nodeType:r.type,field:s,required:u}))};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)}),t}function ur(e,t,i){if(t.field==="html"){let r;return v(e,o=>{o.id===t.nodeId&&o.type==="custom_html"&&(r=o.html[i])}),r}if(t.field==="src"){let r=Ie(e,t.nodeId);return r?.type==="image"?r.localizedSrc?.[i]??(i===e.strings.defaultLocale?r.src:void 0):void 0}return e.strings.locales[i]?.[t.key]}function lr(e){let t=rt(e).filter(r=>r.required);return Object.keys(e.strings.locales).sort((r,o)=>r===e.strings.defaultLocale?-1:o===e.strings.defaultLocale?1:0).map(r=>{let o=t.filter(c=>!ur(e,c,r)?.trim()).map(c=>c.key);return{locale:r,total:t.length,filled:t.length-o.length,missing:o,complete:o.length===0}})}function pr(e){return lr(e).filter(t=>t.complete||t.locale===e.strings.defaultLocale).map(t=>t.locale)}function Dn(e,t){return We(t,pr(e),e.strings.defaultLocale)}function zn(e,t){let i=e.strings.locales[t]??{},r=e.strings.locales[e.strings.defaultLocale]??{},o={};for(let s of rt(e)){if(s.field==="html"||s.field==="src")continue;let u=i[s.key]?.trim()?i[s.key]:r[s.key];u!==void 0&&(o[s.key]=u)}let c=s=>{if(s.type==="stack")return{...s,children:s.children.map(c)};if(s.type==="custom_html"){let u=s.html[t]?.trim()?s.html[t]:s.html[e.strings.defaultLocale];return{...s,html:u===void 0?{}:{[t]:u}}}if(s.type==="image"){let{localizedSrc:u,...d}=s;return{...d,src:u?.[t]??u?.[e.strings.defaultLocale]??s.src}}return s};return{...e,pages:e.pages.map(s=>({...s,root:c(s.root)})),strings:{defaultLocale:t,locales:{[t]:o}}}}function mr(e,t){let i=null;return _e(e,r=>{if(i)return!1;r.id===t&&(i=r)}),i}function Ie(e,t){for(let i of e.pages){let r=mr(i.root,t);if(r)return r}return null}function vn(e){let t=he(e)?.split("-")[0];return t!==void 0&&["ar","he","fa","ur"].includes(t)}function Un(e,t,i){let r={};if(!t||typeof t!="object"||Array.isArray(t))return r;let o=t;if(v(e,c=>{if(c.type==="quantity_picker"){let u=o[c.id];typeof u=="number"&&Number.isSafeInteger(u)&&u>=c.minimumQuantity&&u<=c.maximumQuantity&&(u-c.minimumQuantity)%c.step===0&&(r[c.id]=u);return}if(c.type==="plan_picker"){let u=o[c.id];typeof u=="string"&&(r[c.id]=i?.pickers[c.id]?.options.includes(u)?u:"");return}if(c.type!=="stack"||!c.interaction)return;let s=Object.hasOwn(o,c.id)?o[c.id]:void 0;["select","tabs"].includes(c.interaction.type)&&typeof s=="string"&&c.children.some(u=>u.id===s)&&(r[c.id]=s),c.interaction.type==="toggle"&&typeof s=="boolean"&&(r[c.id]=s)}),e.surface==="paywall"&&typeof o.__page=="string"&&e.pages.some(c=>c.id===o.__page)&&(r.__page=o.__page),i){let c={...r};for(let[s,u]of Object.entries(o))(typeof u=="string"||typeof u=="boolean")&&(c[s]=u);Object.assign(r,Qe(e,c,i))}return r}import{z as E}from"zod";import{z as a}from"zod";import{z as p}from"zod";var q=I.refine(e=>/[1-9]/.test(e),"Quantity must be positive"),te=p.string().min(1).max(120),se=p.enum(["cap","overflow"]),w=(e,t)=>{let[i,r=""]=e.split(".");if(i===void 0||i==="")throw new Error("Invalid decimal value");return BigInt(i)*10n**BigInt(t)+BigInt(r.padEnd(t,"0"))},re=e=>{try{return e()}catch{return!1}},Bn=p.discriminatedUnion("operation",[p.object({operation:p.literal("quote"),overageBehavior:se.optional(),internal_feature_id:p.uuid(),entityId:p.uuid().optional(),quantity:q,properties:T}).strict(),p.object({operation:p.literal("consume"),overageBehavior:se.optional(),occurredAt:p.iso.datetime({offset:!0}).optional(),internal_feature_id:p.uuid(),entityId:p.uuid().optional(),quantity:I,properties:T,idempotencyKey:te}).strict(),p.object({operation:p.literal("reserve"),occurredAt:p.iso.datetime({offset:!0}).optional(),internal_feature_id:p.uuid(),entityId:p.uuid().optional(),quantity:q,properties:T,idempotencyKey:te,expiresInSeconds:p.number().int().min(1).max(86400)}).strict(),p.object({operation:p.literal("confirm"),operationId:p.uuid(),quantity:q,properties:T.optional(),idempotencyKey:te}).strict(),p.object({operation:p.literal("refund"),operationId:p.uuid(),quantity:q,idempotencyKey:te}).strict(),p.object({operation:p.literal("release"),operationId:p.uuid(),idempotencyKey:te}).strict()]),dr=p.object({internal_credit_feature_id:p.uuid().nullable(),internal_metered_feature_id:p.uuid(),dimension:p.string().min(1).max(64),counterKey:p.string().min(1).max(240),cycleStart:p.iso.datetime({offset:!0}),unitCost:I,units:q,amount:oe,tier:p.number().int().min(1).max(12).nullable()}).strict(),ne=p.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/);function nt(e,t){let i=e.reduce((r,o)=>r+w(o.units,12),0n)-w(t,12);return e.some(r=>r.funding==="balance")?i>=-100n&&i<=100n:i===0n}var it=p.discriminatedUnion("funding",[p.strictObject({funding:p.literal("balance"),sourceId:p.uuid(),rolloverId:p.uuid().nullable(),units:ne.refine(e=>/[1-9]/.test(e)),amount:oe}),p.strictObject({funding:p.literal("unbilled"),units:ne.refine(e=>/[1-9]/.test(e))}),p.object({funding:p.literal("prepaid"),sourceId:p.uuid(),units:q,amount:oe,pricing:p.array(dr).min(1).max(12)}).strict().refine(e=>re(()=>e.pricing.reduce((t,i)=>t+w(i.units,6),0n)===w(e.units,6)&&e.pricing.reduce((t,i)=>t+w(i.amount,12),0n)===w(e.amount,12)&&e.pricing.every(t=>w(t.unitCost,6)*w(t.units,6)===w(t.amount,12))),"Frozen pricing must conserve allocated units and amounts"),p.object({funding:p.literal("postpaid"),invoiceLineId:p.uuid().nullable(),units:q,authorizationId:p.uuid()}).strict()]),ce=p.enum(["unavailable","insufficient_balance","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded"]),qn=p.object({allowed:p.boolean(),internal_feature_id:p.uuid(),quantity:I,requestedQuantity:I.optional(),overageBehavior:se.optional(),reason:ce.nullable(),allocations:p.array(it).max(500)}).strict().refine(e=>re(()=>e.allowed?e.reason===null&&nt(e.allocations,e.quantity):e.reason!==null&&e.allocations.length===0),"A quote must conserve its accepted units").refine(e=>re(()=>e.overageBehavior===void 0?e.requestedQuantity===void 0&&/[1-9]/.test(e.quantity):e.requestedQuantity!==void 0&&w(e.requestedQuantity,6)>=w(e.quantity,6)&&(e.overageBehavior==="cap"||e.requestedQuantity===e.quantity)),"Explicit overage behavior must retain the requested quantity"),Qn=p.object({id:p.uuid(),internal_feature_id:p.uuid(),kind:p.enum(["consume","reserve","confirm","refund","release","expire"]),originalId:p.uuid().nullable(),quantity:I,requestedQuantity:I.optional(),overageBehavior:se.optional(),accepted:p.boolean(),reason:p.enum([...ce.options,"expired"]).nullable(),createdAt:p.iso.datetime({offset:!0}),reservationStatus:p.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:p.iso.datetime({offset:!0}).nullable(),allocations:p.array(it).max(500)}).strict().refine(e=>re(()=>e.accepted?e.reason===null&&nt(e.allocations,e.quantity):e.reason!==null&&e.allocations.length===0),"An operation must conserve its requested units").refine(e=>re(()=>e.overageBehavior===void 0?e.requestedQuantity===void 0:e.kind==="consume"&&e.requestedQuantity!==void 0&&w(e.requestedQuantity,6)>=w(e.quantity,6)&&(e.overageBehavior==="cap"||e.requestedQuantity===e.quantity)),"Overage metadata belongs to consumption and preserves requested units").refine(e=>/[1-9]/.test(e.quantity)||e.kind==="consume","Only consumption can record a zero cost event").refine(e=>e.allocations.every(t=>t.funding!=="postpaid"||t.invoiceLineId!==null),"Accepted operations must reference persisted invoice lines").refine(e=>e.originalId!==null===["confirm","refund","release","expire"].includes(e.kind)&&e.expiresAt!==null==(e.reservationStatus!==null)&&(e.kind!=="reserve"||!e.accepted||e.reservationStatus!==null),"Operation provenance and reservation state must be explicit");import{z as D}from"zod";var fr=D.string().max(40).regex(/^(0|[1-9]\d*)(\.\d{1,12})?$/),gr=D.string().max(41).regex(/^-?(0|[1-9]\d*)(\.\d{1,12})?$/),ot=D.strictObject({internal_feature_id:D.uuid(),entityId:D.uuid().nullable()}),Hn=ot.extend({quantity:I,expectedRevision:D.number().int().min(0).max(Number.MAX_SAFE_INTEGER),idempotencyKey:D.string().min(1).max(120),properties:T.refine(e=>Object.keys(e).length<=13&&!Object.keys(e).some(t=>t.startsWith("usage_")),"Usage accounting reserves three properties")}).strict(),at=ot.extend({operationId:D.uuid().nullable(),usage:I,capacity:fr.nullable(),remaining:gr.nullable(),withinLimit:D.boolean(),revision:D.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:D.iso.datetime({offset:!0}).nullable()}).strict().superRefine((e,t)=>{let i=r=>{let o=r.startsWith("-"),[c,s=""]=(o?r.slice(1):r).split(".");if(c===void 0||c==="")throw new Error("Invalid decimal value");return(o?-1n:1n)*(BigInt(c)*10n**12n+BigInt(s.padEnd(12,"0")))};(e.capacity===null!=(e.remaining===null)||(e.capacity===null?!e.withinLimit:e.remaining===null||i(e.remaining)!==i(e.capacity)-i(e.usage)||e.withinLimit!==i(e.remaining)>=0n)||e.revision===0!=(e.operationId===null)||e.operationId===null!=(e.updatedAt===null))&&t.addIssue({code:"custom",message:"Absolute usage must conserve capacity and its immutable revision"})});var U=a.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/),z=a.iso.datetime({offset:!0}),yr=a.enum(["access","metered","credit"]),ie={internal_feature_id:a.uuid(),key:$,name:a.string().min(1).max(120),kind:yr},ti=a.object({customerId:a.uuid(),snapshotAt:z,memberships:a.array(a.object({id:a.uuid(),productId:a.string().min(1).max(255),productVersionId:a.uuid(),billingProductVersionId:a.uuid(),version:a.number().int().positive(),key:a.string().min(1).max(64),name:a.string().min(1).max(120),groupId:a.string().max(255).nullable(),membershipType:a.enum(["main","addon"]),status:a.enum(["trial","active","past_due","ended","expired","trialing","paused","pending","scheduled","unknown"]),cancelAtPeriodEnd:a.boolean(),accessEnabled:a.boolean(),renewalChange:a.object({productVersionId:a.uuid(),name:a.string().min(1).max(120),version:a.number().int().positive(),effectiveAt:z,benefitsAppliedAt:z.nullable(),timing:a.enum(["immediate","renewal"]),changeKind:a.enum(["plan","seats","quantity"]),feature:a.strictObject({internal_feature_id:a.uuid(),name:a.string().min(1).max(80),fromQuantity:a.number().int().min(0).max(1e4),toQuantity:a.number().int().min(0).max(1e4)}).optional(),seat:a.object({key:a.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),fromQuantity:a.number().int().min(0).max(1e4),toQuantity:a.number().int().min(0).max(1e4)}).strict().nullable(),status:a.enum(["prepared","quoted","confirmed","pending","scheduled"])}).strict().refine(e=>e.changeKind==="seats"==(e.seat!==null)&&e.changeKind==="quantity"==(e.feature!==void 0),"Quantity changes require their fixed component identities and quantities").nullable(),period:a.object({phase:a.enum(["paid","trial"]),startsAt:z,endsAt:z.nullable()}).strict().nullable()}).strict()).max(100),membershipsLimited:a.boolean(),balances:a.array(a.object({...ie,usageType:a.enum(["consumable","non_consumable"]).nullable(),accessible:a.boolean(),unlimited:a.boolean(),available:U,held:U,debt:U,nextExpiresAt:z.nullable(),usage:at.nullable()}).strict().refine(e=>e.kind==="metered"==(e.usageType!==null)&&(e.accessible||e.available==="0"&&e.held==="0")&&(e.usageType==="non_consumable"?e.usage!==null&&e.usage.internal_feature_id===e.internal_feature_id&&e.unlimited===(e.usage.capacity===null)&&e.available===(e.usage.remaining===null||e.usage.remaining.startsWith("-")?"0":e.usage.remaining)&&e.held==="0"&&e.debt==="0":e.usage===null),"Balances must expose their actual spendable or non-consumable state")).max(500),balancesLimited:a.boolean()}).strict(),st=a.enum(["source","usage","transaction","invoice","debt","settlement"]),ue=a.object({at:z,id:a.uuid(),type:st}).strict(),ri=a.object({type:st.nullable(),resourceKey:$.optional(),kind:a.enum(["purchase","refund"]).optional(),topup:a.boolean().optional(),from:a.iso.date().nullable(),to:a.iso.date().nullable(),after:ue.nullable(),limit:a.number().int().min(1).max(50)}).strict().refine(e=>!e.from||!e.to||e.from<=e.to,"Date range is reversed"),Y={id:a.uuid(),occurredAt:z},br=a.discriminatedUnion("type",[a.strictObject({...Y,type:a.literal("invoice"),status:a.string().min(1).max(80),paid:U,refunded:U,currency:C,externalId:a.string().nullable()}),a.object({...Y,...ie,type:a.literal("source"),reason:a.enum(["membership","trial","topup","manual","rollover","upgrade_carry","seat"]),quantity:U,unlimited:a.boolean(),status:a.enum(["scheduled","active","expired","revoked","unavailable"]),startsAt:z,expiresAt:z.nullable(),orderId:a.uuid().nullable(),parentSourceId:a.uuid().nullable()}).strict(),a.object({...Y,type:a.literal("usage"),internal_feature_id:a.uuid(),name:a.string().min(1).max(120),kind:a.enum(["consume","set_usage","reserve","confirm","refund","release","expire"]),originalId:a.uuid().nullable(),quantity:I,accepted:a.boolean(),reason:a.enum([...ce.options,"expired"]).nullable(),properties:T,reservationStatus:a.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:z.nullable(),charges:a.array(a.discriminatedUnion("funding",[a.strictObject({funding:a.literal("balance"),sourceId:a.uuid(),rolloverId:a.uuid().nullable(),units:ne,amount:U}),a.strictObject({funding:a.literal("unbilled"),units:ne}),a.object({...ie,funding:a.literal("prepaid"),amount:U}).strict(),a.object({funding:a.literal("postpaid"),invoiceId:a.uuid(),invoiceLineId:a.uuid(),authorizationId:a.uuid(),units:I,currency:C}).strict()])).max(500)}).strict().refine(e=>(e.kind==="set_usage"||e.kind==="consume"&&e.quantity==="0"?e.accepted&&e.reason===null&&e.charges.length===0&&e.reservationStatus===null:e.accepted?e.reason===null&&e.charges.length>0:e.reason!==null&&e.charges.length===0)&&e.originalId!==null===["confirm","refund","release","expire"].includes(e.kind)&&e.expiresAt!==null==(e.reservationStatus!==null),"Usage facts must retain their original outcome and receipt"),a.object({...Y,type:a.literal("transaction"),purpose:a.enum(["product","invoice"]),productVersionId:a.uuid().nullable(),productName:a.string().min(1).max(120).nullable(),productVersion:a.number().int().positive().nullable(),invoiceId:a.uuid().nullable(),orderId:a.uuid(),originalId:a.uuid().nullable(),kind:a.enum(["purchase","refund"]),amountMinor:a.number().int().nonnegative().max(2e8).nullable(),currency:C.nullable()}).strict().refine(e=>e.currency===null==(e.amountMinor===null)&&(e.purpose==="product"?e.productVersionId!==null&&e.productName!==null&&e.productVersion!==null&&e.invoiceId===null:e.productVersionId===null&&e.productName===null&&e.productVersion===null&&e.invoiceId!==null)&&e.kind==="refund"==(e.originalId!==null)&&(e.kind!=="refund"||e.amountMinor===null||e.amountMinor>0),"Payment fact provenance is incomplete"),a.object({...Y,...ie,type:a.literal("debt"),sourceId:a.uuid(),transactionId:a.uuid(),amount:U}).strict(),a.object({...Y,...ie,type:a.literal("settlement"),sourceId:a.uuid(),debtId:a.uuid(),kind:a.enum(["payment","usage_refund","payment_return"]),amount:U}).strict()]),ni=a.object({customerId:a.uuid(),rows:a.array(br).max(50),nextCursor:ue.nullable()}).strict().refine(e=>new Set(e.rows.map(t=>t.type+t.id)).size===e.rows.length,"A page cannot repeat a fact").refine(e=>{let t=e.rows.at(-1);return!e.nextCursor||!!(t&&t.id===e.nextCursor.id&&t.type===e.nextCursor.type&&t.occurredAt===e.nextCursor.at)},"Cursor must name the final displayed fact");var ci=E.discriminatedUnion("kind",[E.object({kind:E.literal("ledger"),cursor:ue}).strict(),E.object({kind:E.literal("billing"),cursor:E.uuid()}).strict()]),hr=E.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),xr=E.record(E.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),E.union([E.string().max(500),E.boolean(),E.array(E.string().max(500)).max(50)])).refine(e=>Object.keys(e).length<=40,"Too many answers"),Sr=/^(?:api_?key|authorization|password|(?:customer|run|visitor|access|purchase)_?token|client_?secret|signed_?transaction|raw_?proof)$/i;function Ee(e,t=0){return t>20?!0:!!e&&typeof e=="object"&&(Array.isArray(e)?e.some(i=>Ee(i,t+1)):Object.entries(e).some(([i,r])=>["__proto__","constructor","prototype"].includes(i)||Sr.test(i)||Ee(r,t+1)))}var _r=/gg_(?:sk|ct|fr|fv|gc)_[A-Za-z0-9_-]{20,}/,ui=E.record(hr,pe).refine(e=>Object.keys(e).length<=20,"Too many parameters").refine(e=>!Ee(e)&&!_r.test(JSON.stringify(e)),"Credentials cannot be screen parameters");var ct=E.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Ir=E.array(E.object({variable:ct,componentId:ct,required:E.boolean()}).strict()).max(40).refine(e=>new Set(e.map(t=>t.variable)).size===e.length&&new Set(e.map(t=>t.componentId)).size===e.length,"Input bindings must be unique"),li=E.object({bindings:Ir,answers:xr,values:E.record(E.string(),pe).optional()}).strict();function ut(e,t,i=1){if(e==="free")return"";if(e==="one_time")return t.startsWith("zh")?" \xB7 \u4E00\u6B21\u4ED8\u6B3E":" \xB7 one-time";let r=t.split("-")[0]??"en",o={zh:["/\u6708","/\u5E74"],en:["/month","/year"],ja:["/\u6708","/\u5E74"],ko:["/\uC6D4","/\uB144"],es:["/mes","/a\xF1o"],fr:["/mois","/an"],de:["/Monat","/Jahr"],pt:["/m\xEAs","/ano"],it:["/mese","/anno"],ar:["/\u0634\u0647\u0631","/\u0633\u0646\u0629"]},c={zh:"\u5468",en:"week",ja:"\u9031",ko:"\uC8FC",es:"semana",fr:"semaine",de:"Woche",pt:"semana",it:"settimana",ar:"\u0623\u0633\u0628\u0648\u0639"},s=e==="week"?`/${c[r]??c.en}`:(o[r]??o.en)[e==="month"?0:1];return i===1?s:`/${i} ${s.slice(1)}${r==="en"?"s":""}`}function hi(e,t){let i=[],r={};v(e,o=>{if(o.hidden)return!1;if(o.type!=="quantity_picker")return;let c=o.bind?.plan?[o.bind.plan]:[];o.bind?.picker&&v(e,s=>{if(s.type==="plan_picker"&&s.id===o.bind?.picker&&c.push(...s.planIds??[]),s.type==="stack"&&s.interaction?.type==="select"&&s.interaction.pickerId===o.bind?.picker)for(let u of s.children)u.type==="stack"&&u.bind?.plan&&c.push(u.bind.plan)}),c.length||i.push(`Quantity control ${o.id} needs a Product binding`);for(let s of new Set(c)){let u=t[s]?.prepaid?.find(g=>g.internalFeatureId===o.internalFeatureId)?.terms,d=r[s]??=new Set;(!u||d.has(o.internalFeatureId)||o.minimumQuantity<u.minimumQuantity||o.maximumQuantity>u.maximumQuantity)&&i.push(`Quantity control ${o.id} must match its Product's prepaid Feature and bounds`),d.add(o.internalFeatureId)}});for(let[o,c]of Object.entries(t))for(let s of c.prepaid??[])r[o]?.has(s.internalFeatureId)||i.push(`Product ${o} needs a quantity control for ${s.internalFeatureId}`);return i}function xi(e,t,i,r){let o=r.plans[t];if(!o?.available)throw new Error("Selected Product is unavailable");let c={};if(v(e,s=>{if(s.hidden)return!1;if(s.type!=="quantity_picker"||s.hidden||(s.bind?.plan??(s.bind?.picker?i[s.bind.picker]:void 0))!==t)return;let d=o.prepaid?.find(l=>l.internalFeatureId===s.internalFeatureId)?.terms,g=i[s.id];if(!d||typeof g!="number"||!Number.isSafeInteger(g)||g<Math.max(d.minimumQuantity,s.minimumQuantity)||g>Math.min(d.maximumQuantity,s.maximumQuantity)||(g-s.minimumQuantity)%s.step!==0||c[s.internalFeatureId]!==void 0)throw new Error("Choose a valid quantity for each prepaid Feature");c[s.internalFeatureId]=g}),(o.prepaid??[]).some(s=>c[s.internalFeatureId]===void 0))throw new Error("Choose a quantity for each prepaid Feature");return c}function Er(e,t,i){let r=e.terms.prices.find(o=>o.currency===t);if(!r||i<e.terms.minimumQuantity||i>e.terms.maximumQuantity)throw new Error("Quantity or currency is unavailable");return{amountMinor:je({quantity:i,unitAmountMinor:r.amountMinor,...r.pricing?{pricing:r.pricing}:{}}),allowance:ze(e.includedAmount,e.terms.units,i)}}function Si(e,t,i,r){let o=!1;if(v(e,u=>{u.type==="quantity_picker"&&(o=!0)}),!o)return t;let c=structuredClone(t);c.quantities={};let s=new Map;v(e,u=>{if(u.hidden)return!1;if(u.type!=="quantity_picker")return;let d=u.bind?.plan??(u.bind?.picker?i[u.bind.picker]??c.pickers[u.bind.picker]?.selected:void 0),g=typeof d=="string"?c.plans[d]:void 0,l=g?.prepaid?.find(gt=>gt.internalFeatureId===u.internalFeatureId),b=Math.max(u.minimumQuantity,l?.terms.minimumQuantity??0),S=Math.min(u.maximumQuantity,l?.terms.maximumQuantity??0),k=i[u.id]??u.defaultQuantity,O=typeof k=="number"&&Number.isSafeInteger(k)?k:u.defaultQuantity,A=!!l&&!!g?.available&&O>=b&&O<=S&&(O-u.minimumQuantity)%u.step===0,M=c.quantities[u.id]={minimum:b,maximum:Math.max(b,S),step:u.step,value:O,label:"",available:A};if(!A||!l||!g?.currency||g.amountMinor===void 0)return;let Q=Er(l,g.currency,O);M.label=`${new Intl.NumberFormat(r).format(Number(Q.allowance))} ${l.name}${["week","month","year"].includes(l.reset)?ut(l.reset,r,l.resetCount):l.reset==="lifetime"?"":` / ${l.resetCount} ${l.reset}`}`,s.set(String(d),(s.get(String(d))??g.amountMinor)+Q.amountMinor)});for(let[u,d]of s){let g=c.plans[u];if(!g?.currency)continue;let l=me(d,g.currency,r);g.price=l;for(let[b,S]of Object.entries(c.nodes)){let k=Ie(e,b),O=A=>{if(A.price&&(A.price={...A.price,current:l,original:null}),k?.type==="text"){let M=e.strings.locales[r]?.[k.text]??e.strings.locales[e.strings.defaultLocale]?.[k.text];M?.includes("{{plan.price")&&(A.text=M.replace(/\{\{\s*plan.price\s*\}\}/g,l).replace(/\{\{\s*plan.price_per_month\s*\}\}/g,me(Math.round(d/((g.interval==="year"?12:1)*(g.intervalCount??1))),g.currency,r)))}};S.byPlan?.[u]&&O(S.byPlan[u]),(S.base.planVersionId===u||k&&"bind"in k&&k.bind?.plan===u)&&O(S.base)}}return c}import{z as R}from"zod";var le=R.enum(["INVALID_PROTOCOL_VERSION","UNSUPPORTED_PROTOCOL_VERSION","PROTOCOL_RETIRED","UNAUTHENTICATED","FORBIDDEN","SCOPE_MISMATCH","INVALID_REQUEST","NOT_FOUND","CONFLICT","PAYLOAD_TOO_LARGE","RATE_LIMITED","SERVICE_UNAVAILABLE","NOT_CONFIGURED","CAPABILITY_UNAVAILABLE","INTERNAL_ERROR"]),Ai=R.enum([...le.options,"INVALID_SERVER_RESPONSE","RESPONSE_TOO_LARGE","AMBIGUOUS_AUTHENTICATION","BROWSER_REQUIRED","INVALID_REDIRECT_URI","AUTHORIZATION_UNAVAILABLE","UNREGISTERED_CLIENT","MANAGEMENT_OPERATION_FAILED"]),Ni=R.enum([...le.options,"stale_revision"]),Ar=R.enum(["fix_request","authenticate","check_permissions","check_scope","resolve_conflict","reload_state","retry_same_request","configure_integration","check_availability","upgrade_sdk","recover_operation","contact_support"]),Nr=R.enum(["CAPABILITY_NOT_ENABLED","INTEGRATION_MISSING","PROVIDER_CREDENTIAL_REJECTED","PRICE_BINDING_REQUIRED","IDEMPOTENCY_CONFLICT","RESULT_UNKNOWN","STATE_CHANGED","OPERATION_IN_PROGRESS","FUNNEL_VERSION_RETIRED"]),pt={INVALID_PROTOCOL_VERSION:{status:400,recovery:"fix_request"},UNSUPPORTED_PROTOCOL_VERSION:{status:400,recovery:"upgrade_sdk"},PROTOCOL_RETIRED:{status:410,recovery:"upgrade_sdk"},UNAUTHENTICATED:{status:401,recovery:"authenticate"},FORBIDDEN:{status:403,recovery:"check_permissions"},SCOPE_MISMATCH:{status:403,recovery:"check_scope"},INVALID_REQUEST:{status:400,recovery:"fix_request"},NOT_FOUND:{status:404,recovery:"fix_request"},CONFLICT:{status:409,recovery:"resolve_conflict"},PAYLOAD_TOO_LARGE:{status:413,recovery:"fix_request"},RATE_LIMITED:{status:429,recovery:"retry_same_request"},SERVICE_UNAVAILABLE:{status:503,recovery:"retry_same_request"},NOT_CONFIGURED:{status:501,recovery:"configure_integration"},CAPABILITY_UNAVAILABLE:{status:501,recovery:"check_availability"},INTERNAL_ERROR:{status:500,recovery:"recover_operation"}};var lt={TIMEOUT:"recover_operation",NETWORK_ERROR:"recover_operation",HTTP_ERROR:"recover_operation",INVALID_RESPONSE:"recover_operation",NOT_IDENTIFIED:"authenticate",INVALID_TOKEN:"authenticate",INVALID_URL:"fix_request",INVALID_TIMEOUT:"fix_request",SERVER_ONLY:"fix_request",PROTOCOL_MISMATCH:"upgrade_sdk",IDENTITY_CHANGED:"reload_state",INVALID_STATE:"reload_state",EVENT_QUEUE_FULL:"retry_same_request",COMMAND_PENDING:"recover_operation",DECISION_PENDING:"recover_operation",DECISION_ACCEPTANCE_UNKNOWN:"recover_operation",RUN_RECONCILIATION_REQUIRED:"recover_operation",DECISION_FAILED:"contact_support",COMMAND_STORAGE_CONFLICT:"resolve_conflict",COMMAND_STORAGE_INVALID:"fix_request",CONFIGURATION_UNAVAILABLE:"check_availability",CONFIGURATION_EXPIRED:"reload_state",CONFIGURATION_CHANGED:"reload_state",CONFIGURATION_DISPOSED:"reload_state",UNSUPPORTED_SCHEMA:"upgrade_sdk",FUNNEL_STOPPED:"check_availability",PAYWALL_UNAVAILABLE:"check_availability",EVALUATION_MODE:"reload_state",SERVER_REQUIRED:"fix_request",STICKY_SAVE_FAILED:"retry_same_request",TRANSITION_LIMIT:"resolve_conflict",PRECONDITION_FAILED:"reload_state",PRODUCT_UNAVAILABLE:"fix_request",PURCHASE_HANDLER_REQUIRED:"fix_request",EVENT_HANDLER_REQUIRED:"fix_request",CLOSED:"fix_request",BRIDGE_UNAVAILABLE:"check_availability",INVALID_CONFIGURATION:"fix_request",NATIVE_OPERATION_FAILED:"contact_support",AI_PRICE_UNAVAILABLE:"fix_request",AI_USAGE_UNAVAILABLE:"recover_operation",AI_PROVIDER_ERROR:"check_availability",AI_BALANCE_REJECTED:"resolve_conflict"};function Rr(e,t){if(e==="CONFLICT"&&t===425)return{retryable:!0,recovery:"retry_same_request"};if(e==="CONFLICT"&&t===412)return{retryable:!1,recovery:"reload_state"};if(e==="INVALID_SERVER_RESPONSE")return{retryable:!1,recovery:"recover_operation"};if(e==="AMBIGUOUS_AUTHENTICATION")return{retryable:!1,recovery:"fix_request"};if(Object.hasOwn(lt,e)){let r=lt[e];return{retryable:r==="retry_same_request",recovery:r}}let i=le.safeParse(e);return i.success?{retryable:e==="RATE_LIMITED"||e==="SERVICE_UNAVAILABLE",recovery:pt[i.data].recovery}:{retryable:!1,recovery:"contact_support"}}function Ri(e,t){let i=le.safeParse(e);if(i.success)return e==="CONFLICT"?[409,412,425].includes(t):e==="SERVICE_UNAVAILABLE"?[408,502,503,504].includes(t):e==="INVALID_REQUEST"?[400,405,415,422].includes(t):e==="NOT_CONFIGURED"?[501,503].includes(t):pt[i.data].status===t;let r={INVALID_SERVER_RESPONSE:[502],RESPONSE_TOO_LARGE:[502],AMBIGUOUS_AUTHENTICATION:[400],BROWSER_REQUIRED:[403],INVALID_REDIRECT_URI:[403],AUTHORIZATION_UNAVAILABLE:[400],UNREGISTERED_CLIENT:[403],MANAGEMENT_OPERATION_FAILED:[400,422,500]};return Object.hasOwn(r,e)&&(r[e]?.includes(t)??!1)}function kr(e,t=Date.now()){if(e===null)return;let i=e.trim();if(/^\d+$/.test(i)){let o=Number(i);return Number.isSafeInteger(o)?o:void 0}if(!/^[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/.test(i))return;let r=Date.parse(i);return Number.isFinite(r)?Math.max(0,Math.ceil((r-t)/1e3)):void 0}var mt=R.object({retryable:R.boolean(),recovery:Ar,reason:Nr.optional(),retryAfterSeconds:R.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()}),Or=R.object({requestId:R.uuid().optional(),error:R.object({code:R.string().regex(/^[A-Z][A-Z0-9_]{0,95}$/),message:R.string(),...mt.partial().shape})}),ki=R.object({error:Or.shape.error.extend({requestId:R.uuid().optional()})}),Oi=R.object({error:R.string(),code:R.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,95}$/),requestId:R.uuid(),...mt.shape});function dt(e,t,i={}){let r=Rr(e,t),o=i.reason==="RESULT_UNKNOWN"?"recover_operation":i.recovery??r.recovery,c=r.retryable&&i.retryable!==!1&&o!=="recover_operation",s=c?kr(i.retryAfter??null):void 0;return{...r,retryable:c,recovery:o,...s===void 0?{}:{retryAfterSeconds:s},...i.reason?{reason:i.reason}:{}}}var ft=class extends Error{constructor(i,r,o,c,s){super(r);this.code=i;this.status=o;this.requestId=c;this.name="IndianaError",this.reason=s?.reason;let u=dt(i,o??0,{...s,retryAfter:s?.retryAfterSeconds===void 0?void 0:String(s.retryAfterSeconds)});this.retryable=u.retryable,this.recovery=u.recovery,this.retryAfterSeconds=u.retryAfterSeconds}code;status;requestId;retryable;recovery;retryAfterSeconds;reason};export{le as a,Ar as b,Nr as c,Ri as d,Or as e,dt as f,C as g,ht as h,me as i,oe as j,I as k,xt as l,T as m,fe as n,je as o,De as p,ze as q,W as r,he as s,Bn as t,dr as u,ne as v,qn as w,Qn as x,ot as y,Hn as z,at as A,U as B,ti as C,ri as D,ni as E,ye as F,Dr as G,Ce as H,Pe as I,Gr as J,Nt as K,we as L,ve as M,pn as N,Ue as O,mn as P,qe as Q,Ze as R,Ge as S,yn as T,bn as U,En as V,L as W,h as X,jn as Y,v as Z,Ln as _,_e as $,rt as aa,lr as ba,Dn as ca,zn as da,Ie as ea,vn as fa,Un as ga,ci as ha,xr as ia,ui as ja,Ir as ka,li as la,ut as ma,hi as na,xi as oa,Si as pa,ft as qa};
|
package/dist/chunk-G56XGVMS.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as m,c as p}from"./chunk-7DXL3LHT.js";import{z as d}from"zod";var V=d.enum(["sandbox","live"]),j=d.object({projectId:d.string().min(1),environment:V}).strict();import{z as t}from"zod";var y=t.tuple([t.number().min(0).max(1),t.number().min(0).max(1)]).refine(([n,l])=>n<=l),A=t.strictObject({attribute:t.string().optional(),seed:t.string(),hashVersion:t.literal(2),ranges:t.array(y).max(100)}),E=t.strictObject({id:t.string().min(1).max(255),condition:p,gate:t.boolean().optional()}),$=t.strictObject({key:t.string().optional(),name:t.string().optional(),passthrough:t.boolean().optional()}),R={condition:p.optional(),parentConditions:t.array(E).max(100).optional(),weights:t.array(t.number().min(0).max(1)).max(20).optional(),coverage:t.number().min(0).max(1).optional(),hashAttribute:t.string().optional(),fallbackAttribute:t.string().optional(),hashVersion:t.literal(2).optional(),disableStickyBucketing:t.boolean().optional(),bucketVersion:t.number().int().nonnegative().optional(),minBucketVersion:t.number().int().nonnegative().optional(),filters:t.array(A).max(100).optional(),ranges:t.array(y).max(20).optional(),meta:t.array($).max(20).optional(),seed:t.string().optional(),name:t.string().optional(),phase:t.string().optional()},g=t.strictObject({...R,key:t.string().min(1).max(255),variations:t.tuple([m,m]).rest(m).refine(n=>n.length<=20),urlPatterns:t.array(t.strictObject({include:t.boolean(),type:t.enum(["regex","simple"]),pattern:t.string()})).max(100).optional(),force:t.number().int().nonnegative().optional(),active:t.boolean().optional(),persistQueryString:t.boolean().optional()}),C=t.strictObject({value:m,variationId:t.number().int(),key:t.string(),name:t.string().optional(),bucket:t.number().optional(),passthrough:t.boolean().optional(),inExperiment:t.boolean(),hashUsed:t.boolean().optional(),hashAttribute:t.string(),hashValue:t.string(),featureId:t.string().nullable(),stickyBucketUsed:t.boolean().optional()}),G=t.strictObject({...R,id:t.string().max(255).optional(),force:m.optional(),variations:t.array(m).min(2).max(20).optional(),key:t.string().optional(),range:y.optional(),tracks:t.array(t.strictObject({experiment:g,result:C})).max(100).optional()}),H=t.strictObject({defaultValue:m.optional(),rules:t.array(G).max(500).optional()}),b=t.record(t.string(),t.union([t.strictObject({type:t.literal("hashed"),attributeKey:t.string(),values:t.array(t.string().regex(/^[a-f0-9]{64}$/))}),t.strictObject({type:t.literal("list"),attributeKey:t.string(),values:t.array(t.union([t.string(),t.number()]))}),t.strictObject({type:t.literal("condition"),condition:p})])),Y=t.strictObject({scope:j,generation:t.string().regex(/^[a-f0-9]{64}$/),evaluatedAt:t.iso.datetime({offset:!0}),expiresAt:t.iso.datetime({offset:!0}).nullable(),features:t.record(t.string(),H),savedGroups:b,experiments:t.record(t.uuid(),g)});import{z as a}from"zod";import{z as e}from"zod";import{z as r}from"zod";var k=r.strictObject({schemaVersion:r.literal(1),renderKey:r.string().min(1).max(256),routeTemplate:r.string().startsWith("/").max(2048),selectors:r.array(r.string().regex(/^[a-z][a-z0-9-]*\[(?:id|data-testid|data-test|data-qa|data-indiana-id)="(?:[^"\\\x00-\x1f\x7f]|\\["\\])*"\]$/).max(512)),present:r.array(r.number().int().min(0)).min(1),absent:r.array(r.number().int().min(0))}).superRefine((n,l)=>{let o=[...n.present,...n.absent];(new Set(n.selectors).size!==n.selectors.length||new Set(o).size!==o.length||o.length!==n.selectors.length||o.some(s=>s>=n.selectors.length))&&l.addIssue({code:"custom",message:"Incomplete or ambiguous render signature"})}),O=r.strictObject({renderKey:r.string().min(1).max(256),routeKey:r.string().min(1).max(256),stateKey:r.string().min(1).max(256),documentKey:r.string().min(1).max(256),documentHash:r.string().regex(/^[a-f0-9]{64}$/),compositionKey:r.string().min(1).max(256),entryMode:r.enum(["hard","soft"]),match:r.strictObject({present:r.array(r.number().int().min(0)),absent:r.array(r.number().int().min(0))})});import{z as u}from"zod";var U=["enterprise-internal-indiana-test","tinkerland-indiana-prod"],h="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}",N=u.string().regex(new RegExp(`^${h}/${h}/${h}/manifest\\.json$`)),M=u.strictObject({kind:u.literal("gcs-resumable"),url:u.url(),bucket:u.enum(U),objectKey:N,byteLength:u.number().int().positive(),expiresAt:u.iso.datetime()}).superRefine((n,l)=>{let o=new URL(n.url),s=o.searchParams,z=["uploadType","upload_id","name","upload_protocol","ifGenerationMatch"];(o.origin!=="https://storage.googleapis.com"||o.username||o.password||o.hash||o.pathname!==`/upload/storage/v1/b/${n.bucket}/o`||[...s.keys()].some(S=>!z.includes(S)||s.getAll(S).length!==1)||s.get("uploadType")!=="resumable"||!/^[A-Za-z0-9_-]{1,4096}$/.test(s.get("upload_id")??"")||s.has("name")&&s.get("name")!==`app-manifests/${n.objectKey}`||s.has("upload_protocol")&&s.get("upload_protocol")!=="resumable"||s.has("ifGenerationMatch")&&s.get("ifGenerationMatch")!=="0")&&l.addIssue({code:"custom",message:"Invalid IAM upload capability"})});var i=e.string().min(1).max(256),c=e.string().regex(/^[a-f0-9]{64}$/),se=e.strictObject({versionId:e.uuid(),manifestDigest:c,sourceGraphDigest:c,pageKey:i,stateKey:i,documentKey:i,documentHash:c,elementKey:i.optional(),nodeId:i.optional(),contentHash:c.optional(),renderKey:i.optional()}),P=e.strictObject({pageKey:i,documentKey:i,expectedDocumentHash:c,renderKey:i.optional(),nodeId:i,elementKey:i,expectedContentHash:c,property:e.enum(["text","fontSize","color"]),value:e.union([e.string().max(4e3),e.number().finite()])}),w=e.strictObject({versionId:e.uuid(),manifestDigest:c,sourceGraphDigest:c,pageKey:i,stateKey:i,documentKey:i,documentHash:c,renderKey:i.optional(),patches:e.array(P.omit({pageKey:!0,documentKey:!0,expectedDocumentHash:!0,renderKey:!0})).min(1).max(200)}),B=/^[a-z][a-z0-9-]{0,39}$/,x=e.string().regex(B),K=e.enum(["web","ios","android"]),oe=e.discriminatedUnion("action",[e.strictObject({action:e.literal("register"),requestId:e.uuid(),client:x,platform:K,label:e.string().trim().min(1).max(100),sha256:c,bytes:e.number().int().min(1),transferBytes:e.number().int().min(1)}),e.strictObject({action:e.literal("complete"),versionId:e.uuid()}),e.strictObject({action:e.literal("current"),versionId:e.uuid(),expectedCurrent:e.uuid().nullable()}),e.strictObject({action:e.literal("delivery"),enabled:e.boolean()}),e.strictObject({action:e.literal("changes"),versionId:e.uuid(),experimentId:e.uuid(),variationId:i,changesetId:e.uuid().nullable(),expectedRevision:c.nullable(),editorUrl:e.string().url().max(2048),patches:e.array(P).max(200)})]),v=e.strictObject({id:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),clientKey:x,platform:K,label:e.string(),sha256:c,bytes:e.number().int().positive(),objectKey:e.string(),state:e.enum(["uploading","ready","rejected"]),isCurrent:e.boolean(),revision:e.number().int().nonnegative(),createdAt:e.string(),expiresAt:e.string(),readyAt:e.string().nullable(),summary:e.record(e.string(),e.json()),routeTree:e.json().nullable(),validation:e.record(e.string(),e.json())}),_=e.strictObject({key:x,platform:K,currentId:e.uuid().nullable()}),ce=e.strictObject({rows:e.array(v).max(100),nextCursor:e.uuid().nullable(),clients:e.array(_).max(20)}),f=e.strictObject({storedBytes:e.number().int().nonnegative(),reservedBytes:e.number().int().nonnegative(),chargedBytes:e.number().int().nonnegative(),versions:e.number().int().nonnegative(),objects:e.number().int().nonnegative(),orphanObjects:e.number().int().nonnegative(),missingReadyObjects:e.number().int().nonnegative(),unknownObjectSizes:e.number().int().nonnegative(),byteLimit:e.number().int().positive(),versionLimit:e.number().int().positive(),remainingBytes:e.number().int().nonnegative()}),me=e.strictObject({asOf:e.iso.datetime({offset:!0}),reclamation:e.literal("manual-review-required"),buckets:e.strictObject({source:f,runtime:f,previews:f})}),le=e.strictObject({version:v,actorId:e.uuid(),claims:e.record(e.string(),e.json())}),ue=e.strictObject({version:v,upload:M.nullable()}),pe=e.object({format:e.literal("indiana-route-state-index"),schemaVersion:e.literal(3),routes:e.array(e.object({routeKey:i,path:e.string(),documentKey:i,documentHash:c,initialStateKey:i,initialRenderKey:i})),renders:e.array(O)}).loose().superRefine((n,l)=>{(!n.renders||n.routes.some(o=>!n.renders?.some(s=>s.renderKey===o.initialRenderKey&&s.routeKey===o.routeKey&&s.documentKey===o.documentKey&&s.stateKey===o.initialStateKey&&s.documentHash===o.documentHash&&s.entryMode==="hard")))&&l.addIssue({code:"custom",message:"Incomplete render catalog"})}),ge=e.strictObject({rows:e.array(e.object({id:e.uuid(),name:e.string(),status:e.string(),variations:e.array(e.object({id:i,key:i,name:e.string().optional()}).loose())}).loose()),limited:e.boolean()}),de=e.strictObject({enabled:e.boolean(),allowedOrigins:e.array(e.string())});var D=a.strictObject({selector:a.string().min(1).max(2048),action:a.enum(["set","append","remove"]),attribute:a.string().min(1).max(128).refine(n=>["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(n)||/^(aria|data)-[a-z0-9_-]+$/.test(n)),value:a.string().max(5e4).optional(),parentSelector:a.string().max(2048).optional(),insertBeforeSelector:a.string().max(2048).optional()}),T=a.strictObject({variation:a.string().min(1).max(128),description:a.string().max(2e3).default(""),css:a.string().max(1e5).default(""),js:a.string().max(1e5).default(""),domMutations:a.array(D).max(200).default([]),iam:w.optional(),renderGuard:k.optional()}),I=T.omit({variation:!0,description:!0,iam:!0}),F=g.omit({variations:!0,active:!0}).extend({changeId:a.string().regex(/^[a-f0-9]{64}$/),variations:a.tuple([I,I]).rest(I).refine(n=>n.length<=20)}),Ke=a.strictObject({trackExposures:a.boolean(),environmentId:a.uuid(),generation:a.string().regex(/^[a-f0-9]{64}$/),experiments:a.array(F).max(100),savedGroups:b});export{j as a,g as b,C as c,b as d,Y as e,k as f,se as g,x as h,Ke as i};
|
package/dist/chunk-I4BZSRT4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ia as E,ja as M,ka as j,la as O,ma as T}from"./chunk-IAOOTBJV.js";import{k as w,qa as u}from"./chunk-ACF2FBUB.js";import{z as t}from"zod";var _=E,V=t.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),C=t.strictObject(Object.fromEntries(_.map(i=>[i,t.number().int().nonnegative().max(1e9)]))),L=M,D=j,q=t.strictObject({modelId:L,source:t.enum(["models.dev","custom"]),fetchedAt:t.iso.datetime(),rates:O,contextTier:t.number().int().nonnegative(),markupPercent:D}),U=t.strictObject({pricing:q,tokens:C,quantity:w,digest:t.string().regex(/^[a-f0-9]{64}$/)}),z=i=>{let[s,o=""]=i.split(".");return BigInt(s)*10n**12n+BigInt(o.padEnd(12,"0"))};function $(i){if(typeof i!="number"||!Number.isFinite(i)||i<0)throw new u("AI_PRICE_UNAVAILABLE","A published token price is missing");let s=String(i),o=s.includes("e")?i.toFixed(12).replace(/0+$/,"").replace(/\.$/,""):s;if(Number(o)!==i||!V.safeParse(o).success)throw new u("AI_PRICE_UNAVAILABLE","Published price exceeds the supported precision");return o}var R=t.strictObject({input:t.number().nonnegative(),output:t.number().nonnegative(),cache_read:t.number().nonnegative().optional(),cache_write:t.number().nonnegative().optional(),reasoning:t.number().nonnegative().optional(),input_audio:t.number().nonnegative().optional(),output_audio:t.number().nonnegative().optional()}),F=R.extend({context_over_200k:t.unknown().optional(),tiers:t.array(R.extend({tier:t.strictObject({type:t.literal("context"),size:t.number().int().nonnegative()})})).max(20).refine(i=>new Set(i.map(s=>s.tier.size)).size===i.length).optional()});async function N(i,s,o){let d=new TextEncoder().encode(JSON.stringify({pricing:i,tokens:s,quantity:o}));return[...new Uint8Array(await crypto.subtle.digest("SHA-256",d))].map(m=>m.toString(16).padStart(2,"0")).join("")}function B(i,s){let o=0n;for(let c of _){if(!s[c])continue;let f=i.rates[c];if(f===void 0)throw new u("AI_PRICE_UNAVAILABLE",`No published price for ${c}; report exclusive token pools`);o+=z(f)*BigInt(s[c])}let[d,m="0"]=String(i.markupPercent).split("e"),r=(d.split(".")[1]?.length??0)-Number(m),e=10n**BigInt(Math.max(r,0)),n=BigInt(d.replace(".",""))*10n**BigInt(Math.max(-r,0)),g=100n*e+n,l=100n*e*1000000n,a=(o*g+l-1n)/l;return w.parse(`${a/1000000n}.${(a%1000000n).toString().padStart(6,"0")}`)}function K(i={}){if(typeof window<"u")throw new u("SERVER_ONLY","AI token pricing belongs on your backend");let s=T.parse({defaultMarkup:i.defaultMarkup??0,providerMarkups:i.providerMarkups??{},modelMarkups:i.modelMarkups??{},customModels:i.customModels??{}}),o=null,d=0;async function m(){if(!o||Date.now()>=d){d=Date.now()+15*6e4;let r=(async()=>{let e=await(i.fetch??fetch)("https://models.dev/api.json",{signal:AbortSignal.timeout(3e4)});if(!e.ok)throw new u("AI_PRICE_UNAVAILABLE","Models.dev pricing is unavailable");return{data:t.record(t.string(),t.object({models:t.record(t.string(),t.unknown())})).parse(await e.json()),fetchedAt:new Date().toISOString()}})().catch(e=>{throw o===r&&(o=null),e});o=r}return o}return{refreshPrices(){o=null,d=0},async quoteTokens(r){let e=L.parse(r.modelId),n=C.parse(r.tokens),[g,...l]=e.split("/"),a=s.customModels[e],c,f,p,y=0;if(a?.input!==void 0&&a.output!==void 0&&_.every(A=>n[A]===0||a[A]!==void 0))c={...a,input:a.input,output:a.output},f="custom",p=new Date().toISOString();else{let A=await m(),x=A.data[g]?.models[l.join("/")];if(!x)throw new u("AI_PRICE_UNAVAILABLE","Unknown model; configure a complete custom price");let{cost:I}=t.object({cost:F}).parse(x),P=n.input+n.cache_read+n.cache_write+n.input_audio;if(I.tiers===void 0&&I.context_over_200k!==void 0&&P>2e5)throw new u("AI_PRICE_UNAVAILABLE","A current context tier is required for this model");let b=I.tiers?.filter(k=>P>k.tier.size).sort((k,Q)=>Q.tier.size-k.tier.size)[0],v=b??I;b&&(y=b.tier.size),c=Object.fromEntries(_.filter(k=>v[k]!==void 0).map(k=>[k,$(v[k])])),c={...c,...a},f=a?"custom":"models.dev",p=A.fetchedAt}let h=q.parse({modelId:e,source:f,fetchedAt:p,rates:c,contextTier:y,markupPercent:s.modelMarkups[e]??s.providerMarkups[g]??s.defaultMarkup}),S=B(h,n);return U.parse({pricing:h,tokens:n,quantity:S,digest:await N(h,n,S)})},async trackTokens(r,e){let n=U.parse(e.quote);if(n.quantity!==B(n.pricing,n.tokens)||n.digest!==await N(n.pricing,n.tokens,n.quantity))throw new u("INVALID_REQUEST","AI quote changed after pricing");let g=e.properties??{},l=e.providerCostUsd===void 0?void 0:t.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/).parse(e.providerCostUsd),a=e.generationId===void 0?void 0:t.string().min(1).max(120).parse(e.generationId),c=8+ +(l!==void 0)+ +(a!==void 0);if(Object.keys(g).some(p=>p.startsWith("ai_")))throw new u("INVALID_REQUEST","AI tracking reserves ai_ event properties");if(Object.keys(g).length>16-c)throw new u("INVALID_REQUEST","AI tracking properties exceed the available event budget");let f={operation:"consume",internal_feature_id:e.internal_feature_id,quantity:n.quantity,idempotencyKey:e.idempotencyKey,properties:{...g,...l!==void 0?{ai_provider_cost_usd:l}:{},...a!==void 0?{ai_generation_id:a}:{},ai_model:n.pricing.modelId,ai_source:n.pricing.source,ai_price_at:n.pricing.fetchedAt,ai_quote_hash:n.digest,ai_markup:String(n.pricing.markupPercent),ai_tier:String(n.pricing.contextTier),ai_tokens:_.map(p=>n.tokens[p]).join(","),ai_rates:"v1:"+_.map(p=>n.pricing.rates[p]===void 0?"-":z(n.pricing.rates[p]).toString(36)).join(",")},...e.entityId?{entityId:e.entityId}:{}};return r.mutateBalance({customerId:e.customerId,command:f})}}}async function Y(i,s,o={}){let{config:d,model_markups:m}=await i.readAiPricing(s);return K({defaultMarkup:d.default_markup??0,providerMarkups:Object.fromEntries(Object.entries(d.provider_markups??{}).map(([r,e])=>[r,e.markup])),modelMarkups:Object.fromEntries(Object.entries(m??{}).filter(([,r])=>r.markup!==void 0).map(([r,e])=>[r,e.markup])),customModels:Object.fromEntries(Object.entries(m??{}).filter(([,r])=>r.input_cost!==void 0||r.output_cost!==void 0).map(([r,e])=>[r,{...e.input_cost!==void 0?{input:String(e.input_cost)}:{},...e.output_cost!==void 0?{output:String(e.output_cost)}:{}}])),...o})}export{q as a,U as b,K as c,Y as d};
|