@tinkerlandai/longplay-sdk 0.10.15 → 0.10.16
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 +6 -0
- package/README.md +13 -15
- package/README.zh-CN.md +14 -16
- package/dist/{ai-usage-C3dCagmQ.d.ts → ai-usage-DejUdb17.d.ts} +1 -1
- package/dist/{api-Cefn6AaL.d.ts → api-RQUBSSEJ.d.ts} +60 -26
- package/dist/{chunk-OZZMZH7X.js → chunk-26HU2HXU.js} +1 -1
- package/dist/chunk-4IGRIYOQ.js +1 -0
- package/dist/{chunk-V73OHOTK.js → chunk-55MXKW5J.js} +1 -1
- package/dist/{chunk-6RZKX552.js → chunk-67XTOBGE.js} +1 -1
- package/dist/{chunk-RT35MPPD.js → chunk-6MBVIE3H.js} +1 -1
- package/dist/chunk-AC32XJZW.js +1 -0
- package/dist/{chunk-VXY2C4AL.js → chunk-APO7QUBB.js} +1 -1
- package/dist/chunk-EEZLS2YP.js +1 -0
- package/dist/chunk-EFFXE6CX.js +6 -0
- package/dist/chunk-FKBSUKXE.js +1 -0
- package/dist/{chunk-TPAQWTO4.js → chunk-JKLILKI5.js} +1 -1
- package/dist/{chunk-VSMITXQD.js → chunk-LC2VUKYM.js} +1 -1
- package/dist/{chunk-LUIKKMG5.js → chunk-M5HQW67G.js} +1 -1
- package/dist/chunk-ML6EHT43.js +10 -0
- package/dist/chunk-PFHS7HK3.js +17 -0
- package/dist/chunk-T5COWMDA.js +1 -0
- package/dist/{configuration-sync-D2n_gGj6.d.ts → configuration-sync-C2jtm37f.d.ts} +97 -9
- package/dist/{content-WXHCWIUL.js → content-XCLXWNGN.js} +1 -1
- package/dist/{funnel-local-client-9U-_hkEE.d.ts → funnel-local-client-P_R6FHVV.d.ts} +7995 -5523
- package/dist/{funnel-node-evaluation-DSSSmXHX.d.ts → funnel-node-evaluation-BLnJp8vj.d.ts} +11 -13
- package/dist/{funnel-process-client-BaHMeArI.d.ts → funnel-process-client-CY-GQ_SF.d.ts} +5498 -4539
- package/dist/funnel-runtime-host-GFTN7KQK.js +1 -0
- package/dist/index.d.ts +1258 -273
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +3 -3
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +2 -2
- package/dist/page.js +1 -1
- package/dist/paywall-H3KQZEJG.js +1 -0
- package/dist/popup.d.ts +11 -5
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +1541 -7
- package/dist/react-native.js +1 -1
- package/dist/{screen-D81zCpfi.d.ts → screen-DRP7nsrQ.d.ts} +613 -357
- package/dist/screen-renderer-IZ3VJGU6.js +1 -0
- package/dist/server.d.ts +717 -9
- package/dist/server.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-33FQUT3Z.js +0 -179
- package/dist/chunk-E5ECPR6Z.js +0 -1
- package/dist/chunk-LHA6VWP7.js +0 -1
- package/dist/chunk-MOWYD2TV.js +0 -1
- package/dist/chunk-RQZ42NQJ.js +0 -6
- package/dist/chunk-VSJOHWDL.js +0 -17
- package/dist/chunk-XAHWOLRT.js +0 -1
- package/dist/funnel-runtime-host-WQ64FAME.js +0 -1
- package/dist/paywall-H4YN4FTL.js +0 -1
- package/dist/screen-renderer-NHJ6OQTF.js +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import{z as rr}from"zod";var ir=["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"],$=rr.enum(ir);function or(e){let t=$.parse(e.toUpperCase());return["JPY","KRW","VND"].includes(t)?0:2}function He(e,t,n="en",r={}){let i=$.parse(t.toUpperCase());return new Intl.NumberFormat(n,{style:"currency",currency:i,...r}).format(e/10**or(i))}import{z as l}from"zod";function Ge(e){let t=2166136261,n=e.length;for(let r=0;r<n;r++)t^=e.charCodeAt(r),t+=(t<<1)+(t<<4)+(t<<7)+(t<<8)+(t<<24);return t>>>0}function xe(e,t,n){return n===2?Ge(Ge(e+t)+"")%1e4/1e4:null}function Ot(e){return e<=0?[]:new Array(e).fill(1/e)}function Se(e,t){return e>=t[0]&&e<t[1]}function Qe(e,t){for(let[n,r]of t.entries())if(Se(e,r))return n;return-1}function Ke(e,t,n){t=t===void 0?1:t,t<0?t=0:t>1&&(t=1);let r=Ot(e);n=n||r,n.length!==e&&(n=r);let i=n.reduce((s,u)=>u+s,0);(i<.99||i>1.01)&&(n=r);let o=0,a=t;return n.map(s=>{let u=o;return o+=s,[u,u+a*s]})}function Ze(e,t,n){if(!t)return null;let r=t.split("?")[1];if(!r)return null;let o=r.replace(/#.*/,"").split("&").map(a=>a.split("=",2)).filter(([a])=>a===e).map(([,a])=>a===void 0?NaN:parseInt(a))[0];return o!==void 0&&o>=0&&o<n?o:null}function We(e){try{return e()}catch{return!1}}function le(e){return typeof e=="string"?e:JSON.stringify(e)}function z(e){typeof e=="number"&&(e=e+""),(!e||typeof e!="string")&&(e="0");let t=e.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return t.length===3&&t.push("~"),t.map(n=>n.match(/^[0-9]+$/)?n.padStart(5," "):n).join("-")}function vt(e){try{let t=e.replace(/([^\\])\//g,"$1\\/");return new RegExp(t)}catch{return}}function Je(e,t){if(!t.length)return!1;let n=!1,r=!1;for(let i of t){let o=cr(e,i.type,i.pattern);if(i.include===!1){if(o)return!1}else n=!0,o&&(r=!0)}return r||!n}function ar(e,t,n){try{let r=t.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return n&&(r="\\/?"+r.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+r+"$","i").test(e)}catch{return!1}}function sr(e,t){try{let n=new URL(t.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),r=[[e.host,n.host,!1],[e.pathname,n.pathname,!0]];return n.hash&&r.push([e.hash,n.hash,!1]),n.searchParams.forEach((i,o)=>{r.push([e.searchParams.get(o)||"",i,!1])}),!r.some(i=>!ar(i[0],i[1],i[2]))}catch{return!1}}function cr(e,t,n){try{let r=new URL(e,"https://_");if(t==="regex"){let i=vt(n);return i?i.test(r.href)||i.test(r.href.substring(r.origin.length)):!1}else if(t==="simple")return sr(r,n);return!1}catch{return!1}}function Ye(e){for(let n of["namespace","status","url","groups"])if(Object.hasOwn(e,n))throw new TypeError(`Retired experiment field: ${n}`);let t=e;if(t.hashVersion!==void 0&&t.hashVersion!==2)throw new TypeError("Only hash version 2 is supported");if(t.filters?.some(n=>n.hashVersion!==2))throw new TypeError("Only hash version 2 is supported")}function Re(e){for(let t of Object.values(e)){if(Array.isArray(t))throw new TypeError("Saved groups require typed list or condition entries");if(t&&Object.hasOwn(t,"useEmptyListGroup"))throw new TypeError("Retired saved group field: useEmptyListGroup")}}function Rt(e){for(let t of["overrides","groups"])if(Object.hasOwn(e,t))throw new TypeError(`Retired evaluation context field: ${t}`);Re(e.savedGroups??{})}var ur=e=>e/2**32|0,lr=e=>e>>>0;function Nt(e,t,n,r){let i=ur(n),o=lr(n);e.setUint32(t,r?o:i,r),e.setUint32(t+4,r?i:o,r)}function Ct(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in e&&e.BYTES_PER_ELEMENT===1}var Xe=e=>e?`"${e}" `:"";function pr(e,t=""){if(typeof e!="number")throw new TypeError(Xe(t)+"expected number, got "+typeof e);if(!Number.isSafeInteger(e)||e<0)throw new RangeError(Xe(t)+"expected integer >= 0, got "+e);return e}function Ne(e,t,n=""){if(Ct(e)&&(t===void 0||e.length===t))return e;t!==void 0&&pr(t,"length");let r=Ct(e),i=t!==void 0?` of length ${t}`:"",o=r?`length=${e.length}`:`type=${typeof e}`,a=Xe(n)+"expected Uint8Array"+i+", got "+o;throw r?new RangeError(a):new TypeError(a)}var dr=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError((t==="object"?"":`"${t}" `)+"expected object, got type="+typeof e)},Tt=(e,t)=>{dr(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw new TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,"__proto__"))throw new TypeError(`"${t}.__proto__" is not allowed`)};function et(e,t=!0){if(e.destroyed)throw new Error("hash was destroyed");if(t&&e.finished)throw new Error("digest() was already called")}function jt(e,t){Ne(e,void 0,"output");let n=t.outputLen;if(!(e.length>=n))throw new RangeError('"output" expected length >= '+n)}function tt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Ce(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function B(e,t){return e<<32-t|e>>>t}var fr=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",mr=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Pt(e){if(Ne(e),fr)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=mr[e[n]];return t}function gr(e,t,n="opts"){return Tt(e,"defaults"),t!==void 0&&Tt(t,n),Object.assign(Object.create(null),e,t)}function Dt(e,t={}){if(typeof e!="function")throw new TypeError('"hashCons" expected function, got type='+typeof e);t=gr({},t,"info");let n=(i,o)=>e(o).update(i).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=i=>e(i),Object.assign(n,t),Object.freeze(n)}var Lt=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Ut(e,t,n){return e&t^~e&n}function $t(e,t,n){return e&t^e&n^t&n}var Te=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,n,r,i){this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(t),this.view=Ce(this.buffer)}update(t){et(this),Ne(t);let{view:n,buffer:r,blockLen:i}=this,o=t.length,a=!1;for(let s=0;s<o;){let u=Math.min(i-this.pos,o-s);if(u===i){let f=Ce(t);for(;i<=o-s;s+=i)this.process(f,s);a=!0;continue}r.set(s===0&&u===o?t:t.subarray(s,s+u),this.pos),this.pos+=u,s+=u,this.pos===i&&(this.process(n,0),this.pos=0,a=!0)}return this.length+=t.length,a&&this.roundClean(),this}digestInto(t){et(this),jt(t,this),this.finished=!0;let{buffer:n,view:r,blockLen:i,isLE:o}=this,{pos:a}=this;n[a++]=128,n.fill(0,a),this.padOffset>i-a&&(this.process(r,0),n.fill(0)),Nt(r,i-8,this.length*8,o),this.process(r,0),this.roundClean();let s=t===n?r:Ce(t),u=this.outputLen,f=u/4,d=this.get();if(u%4||f>d.length)throw new Error("invalid outputLen");for(let g=0;g<f;g++)s.setUint32(4*g,d[g],o)}digest(){let{buffer:t,outputLen:n}=this;this.digestInto(t);let r=t.slice(0,n);return this.destroy(),r}_cloneIntoMeta(t){let{buffer:n,length:r,finished:i,destroyed:o,pos:a}=this;return t.destroyed=o,t.finished=i,t.length=r,t.pos=a,a&&t.buffer.set(n),t}clone(){return this._cloneInto()}},zt=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var br=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),X=new Uint32Array(64),nt=class extends Te{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(t,n){super(64,t,8,!1),this.A=n[0]|0,this.B=n[1]|0,this.C=n[2]|0,this.D=n[3]|0,this.E=n[4]|0,this.F=n[5]|0,this.G=n[6]|0,this.H=n[7]|0}get(){let{A:t,B:n,C:r,D:i,E:o,F:a,G:s,H:u}=this;return[t,n,r,i,o,a,s,u]}set(t,n,r,i,o,a,s,u){this.A=t|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=o|0,this.F=a|0,this.G=s|0,this.H=u|0}_cloneInto(t){return(t||=new this.constructor).set(...this.get()),this._cloneIntoMeta(t)}process(t,n){for(let g=0;g<16;g++,n+=4)X[g]=t.getUint32(n,!1);for(let g=16;g<64;g++){let A=X[g-15],y=X[g-2],b=B(A,7)^B(A,18)^A>>>3,k=B(y,17)^B(y,19)^y>>>10;X[g]=k+X[g-7]+b+X[g-16]|0}let{A:r,B:i,C:o,D:a,E:s,F:u,G:f,H:d}=this;for(let g=0;g<64;g++){let A=B(s,6)^B(s,11)^B(s,25),y=d+A+Ut(s,u,f)+br[g]+X[g]|0,k=(B(r,2)^B(r,13)^B(r,22))+$t(r,i,o)|0;d=f,f=u,u=s,s=a+y|0,a=o,o=i,i=r,r=y+k|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,a=a+this.D|0,s=s+this.E|0,u=u+this.F|0,f=f+this.G|0,d=d+this.H|0,this.set(r,i,o,a,s,u,f,d)}roundClean(){tt(X)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),tt(this.buffer)}},rt=class extends nt{constructor(){super(32,zt)}};var Ft=Dt(()=>new rt,Lt(1));var Vt=new Map,it=32,Bt=new WeakMap,Mt=new WeakMap;function hr(e){return Pt(Ft(new TextEncoder().encode(String(e))))}var Pe=e=>Array.isArray(e)?e.map(Pe):typeof e=="string"||typeof e=="number"?hr(e):null,je=e=>typeof e=="string"?e.toLowerCase():e;function Kt(e){let t=Bt.get(e);return t||(t=new Set(e),Bt.set(e,t)),t}function yr(e){let t=Mt.get(e);return t||(t=new Set(e.map(je)),Mt.set(e,t)),t}function Zt(e){Re(e);for(let t of Object.values(e)){let n=t?.type==="list"||t?.type==="hashed"?t.values:null;n&&n.length>=it&&Kt(n)}return e}function M(e,t,n,r){n=n||{},r||Re(n),r=r||new Set;for(let[i,o]of Object.entries(t))switch(i){case"$or":if(!Qt(e,o,n,r))return!1;break;case"$nor":if(Qt(e,o,n,r))return!1;break;case"$and":if(!Ir(e,o,n,r))return!1;break;case"$not":if(M(e,o,n,r))return!1;break;case"$savedGroup":if(!xr(e,o,n,r))return!1;break;default:if(!ke(o,Wt(e,i),n,!1,r))return!1}return!0}function xr(e,t,n,r){if(!t||typeof t!="object"||Array.isArray(t))return!1;let{id:i,attributeKey:o}=t;if(typeof i!="string"||r.has(i)||o!==void 0&&typeof o!="string")return!1;let a=n[i];if(!a||Array.isArray(a)||typeof a!="object")return!1;let s=new Set(r).add(i);if(a.type==="list"||a.type==="hashed"){let u=o??a.attributeKey;if(typeof u!="string"||!Array.isArray(a.values))return!1;let f=Wt(e,u);return ie(a.type==="hashed"?Pe(f):f,a.values)}return a.type==="condition"?!a.condition||typeof a.condition!="object"?!1:M(e,a.condition,n,s):!1}function Wt(e,t){let n=t.split("."),r=e;for(let i of n)if(r&&typeof r=="object"&&i in r)r=r[i];else return null;return r}function qt(e,t=!1){let n=`${e}${t?"/i":""}`,r=Vt.get(n);return r||(r=new RegExp(e.replace(/([^\\])\//g,"$1\\/"),t?"i":void 0),Vt.set(n,r)),r}function ke(e,t,n,r=!1,i=new Set){if(typeof e=="string")return r?String(t).toLowerCase()===e.toLowerCase():t+""===e;if(typeof e=="number")return t*1===e;if(typeof e=="boolean")return t!==null&&!!t===e;if(e===null)return t===null;if(Array.isArray(e)||!Jt(e))return JSON.stringify(t)===JSON.stringify(e);let o=e;for(let a in o)if(!Ar(a,t,o[a],n,i))return!1;return!0}function Jt(e){let t=Object.keys(e);return t.length>0&&t.filter(n=>n[0]==="$").length===t.length}function Sr(e){if(e===null)return"null";if(Array.isArray(e))return"array";let t=typeof e;return["string","number","boolean","object","undefined"].includes(t)?t:"unknown"}function kr(e,t,n,r){if(!Array.isArray(e))return!1;let i=Jt(t)?o=>ke(t,o,n,!1,r):o=>M(o,t,n,r);for(let o=0;o<e.length;o++)if((e[o]??null)!==null&&i(e[o]))return!0;return!1}function ie(e,t,n=!1){if(n){let i;if(t.length>=it){let o=yr(t);i=a=>{let s=je(a);return!(typeof s=="number"&&Number.isNaN(s))&&o.has(s)}}else i=o=>t.some(a=>je(o)===je(a));return Array.isArray(e)?e.some(o=>i(o)):i(e)}let r=t.length>=it?(i=>o=>i.has(o))(Kt(t)):i=>t.includes(i);return Array.isArray(e)?e.some(i=>r(i)):r(e)}function Ht(e){return e===void 0?[]:e&&typeof e=="object"&&(e.type==="list"||e.type==="hashed")&&Array.isArray(e.values)?e.values:null}function Gt(e,t,n,r=!1,i=new Set){if(!Array.isArray(e))return!1;for(let o=0;o<t.length;o++){let a=!1;for(let s=0;s<e.length;s++)if(ke(t[o],e[s],n,r,i)){a=!0;break}if(!a)return!1}return!0}function Ar(e,t,n,r,i=new Set){let o=t,a=n;switch(e){case"$veq":return z(t)===z(n);case"$vne":return z(t)!==z(n);case"$vgt":return z(t)>z(n);case"$vgte":return z(t)>=z(n);case"$vlt":return z(t)<z(n);case"$vlte":return z(t)<=z(n);case"$eq":return t===n;case"$ne":return t!==n;case"$lt":return o<a;case"$lte":return o<=a;case"$gt":return o>a;case"$gte":return o>=a;case"$exists":return n?t!=null:t==null;case"$in":return Array.isArray(n)?ie(t,n):!1;case"$ini":return Array.isArray(n)?ie(t,n,!0):!1;case"$inGroup":{let s=r[n],u=Ht(s);return u===null?!1:ie(s?.type==="hashed"?Pe(t):t,u)}case"$notInGroup":{let s=r[n],u=Ht(s);return u===null?!1:!ie(s?.type==="hashed"?Pe(t):t,u)}case"$nin":return Array.isArray(n)?!ie(t,n):!1;case"$nini":return Array.isArray(n)?!ie(t,n,!0):!1;case"$not":return!ke(n,t,r,!1,i);case"$size":return Array.isArray(t)?ke(n,t.length,r,!1,i):!1;case"$elemMatch":return kr(t,n,r,i);case"$all":return Array.isArray(n)?Gt(t,n,r,!1,i):!1;case"$alli":return Array.isArray(n)?Gt(t,n,r,!0,i):!1;case"$regex":try{return qt(n).test(t)}catch{return!1}case"$regexi":try{return qt(n,!0).test(t)}catch{return!1}case"$type":return Sr(t)===n;default:return!1}}function Qt(e,t,n,r){if(!t.length)return!0;for(let i of t)if(M(e,i,n,r))return!0;return!1}function Ir(e,t,n,r){for(let i of t)if(!M(e,i,n,r))return!1;return!0}function ot(e){return Rt(e),{context:e,stack:{evaluatedFeatures:new Set}}}function at(e){return{...e.attributes,...e.attributeOverrides}}function ee(e,t,n){let r=t||"id",i="",o=at(e);return o[r]&&(i=o[r]),!i&&n&&(o[n]&&(i=o[n]),i&&(r=n)),{hashAttribute:r,hashValue:i}}function E(e,t,n){e.context.log?.(t,n)}function De(e,t){return t=t||0,`${e}__${t}`}function st(e,t){return`${e}||${t}`}function Er(e,t,n){let r=e.stickyBucketAssignmentDocs;if(!r)return{};let{hashAttribute:i,hashValue:o}=ee(e,t),a=st(i,le(o)),{hashAttribute:s,hashValue:u}=ee(e,n),f=u?st(s,le(u)):null,d={};return f&&r[f]&&Object.assign(d,r[f].assignments||{}),r[a]&&Object.assign(d,r[a].assignments||{}),d}function Yt({context:e,expKey:t,expBucketVersion:n,expHashAttribute:r,expFallbackAttribute:i,expMinBucketVersion:o,expMeta:a}){n=n||0,o=o||0,r=r||"id",a=a||[];let s=De(t,n),u=Er(e,r,i);if(o>0)for(let g=0;g<o;g++){let A=De(t,g);if(u[A]!==void 0)return{variation:-1,versionIsBlocked:!0}}let f=u[s];if(f===void 0)return{variation:-1};let d=a.findIndex(g=>g.key===f);return d<0?{variation:-1}:{variation:d}}function Xt(e,t,n,r){let i=st(t,n),o=e.stickyBucketAssignmentDocs,a=o&&o[i]?o[i].assignments||{}:{},s={...a,...r},u=JSON.stringify(a)!==JSON.stringify(s);return{key:i,doc:{attributeName:t,attributeValue:n,assignments:s},changed:u}}function en(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function tn(e,t){let n=ot(t),r=on(e,null,n);return t.onExperimentEval?.(e,r),r}function nn(e,t){return ut(e,ot(t))}function _r(e){return e.forcedVariations||{}}function rn(e,t,n){let{context:r}=e;if(r.trackedExperiments){let i=cn(t,n);if(r.trackedExperiments.has(i))return;r.trackedExperiments.add(i)}ct(()=>r.onExperimentViewed?.(t,n))}function wr(e,t,n){let{context:r}=e;if(r.trackedFeatureUsage){let i=JSON.stringify(n.value);if(r.trackedFeatureUsage[t]===i)return;r.trackedFeatureUsage[t]=i}ct(()=>r.onFeatureUsage?.(t,n))}function ct(e){try{let t=e();t&&typeof t.catch=="function"&&t.catch(()=>{})}catch{}}function ut(e,t){let{context:n}=t;if(t.stack.evaluatedFeatures.has(e))return E(t,`evalFeature: circular dependency detected: ${t.stack.id} -> ${e}`,{from:t.stack.id,to:e}),te(t,e,null,"cyclicPrerequisite");t.stack.evaluatedFeatures.add(e),t.stack.id=e;let r=n.features?.[e];for(let o of r?.rules??[])Ye(o);let i=n.forcedFeatureValues;if(i&&i.has(e))return E(t,"Global override",{id:e,value:i.get(e)}),te(t,e,i.get(e),"override");if(!r)return E(t,"Unknown feature",{id:e}),te(t,e,null,"unknownFeature");if(r.rules){let o=new Set(t.stack.evaluatedFeatures);e:for(let a of r.rules){if(a.parentConditions)for(let f of a.parentConditions){t.stack.evaluatedFeatures=new Set(o);let d=ut(f.id,t);if(d.source==="cyclicPrerequisite")return te(t,e,null,"cyclicPrerequisite");let g={value:d.value};if(!M(g,f.condition||{},n.savedGroups||{})){if(f.gate)return E(t,"Feature blocked by prerequisite",{id:e,rule:a}),te(t,e,null,"prerequisite");E(t,"Skip rule because prerequisite evaluation fails",{id:e,rule:a});continue e}}if(a.filters&&sn(a.filters,t)){E(t,"Skip rule because of filters",{id:e,rule:a});continue}if("force"in a){if(a.condition&&!an(a.condition,t)){E(t,"Skip rule because of condition ff",{id:e,rule:a});continue}if(!Or(t,a.seed||e,a.hashAttribute,n.saveStickyBucketAssignmentDoc&&!a.disableStickyBucketing?a.fallbackAttribute:void 0,a.range,a.coverage,a.hashVersion)){E(t,"Skip rule because user not included in rollout",{id:e,rule:a});continue}return E(t,"Force value from rule",{id:e,rule:a}),a.tracks&&a.tracks.forEach(f=>{rn(t,f.experiment,f.result)}),te(t,e,a.force,"force",a.id)}if(!a.variations){E(t,"Skip invalid rule",{id:e,rule:a});continue}let s={variations:a.variations,key:a.key||e};"coverage"in a&&(s.coverage=a.coverage),a.weights&&(s.weights=a.weights),a.hashAttribute&&(s.hashAttribute=a.hashAttribute),a.fallbackAttribute&&(s.fallbackAttribute=a.fallbackAttribute),a.disableStickyBucketing&&(s.disableStickyBucketing=a.disableStickyBucketing),a.bucketVersion!==void 0&&(s.bucketVersion=a.bucketVersion),a.minBucketVersion!==void 0&&(s.minBucketVersion=a.minBucketVersion),a.meta&&(s.meta=a.meta),a.ranges&&(s.ranges=a.ranges),a.name&&(s.name=a.name),a.phase&&(s.phase=a.phase),a.seed&&(s.seed=a.seed),a.hashVersion&&(s.hashVersion=a.hashVersion),a.filters&&(s.filters=a.filters),a.condition&&(s.condition=a.condition);let u=on(s,e,t);if(n.onExperimentEval?.(s,u),u.inExperiment&&!u.passthrough)return te(t,e,u.value,"experiment",a.id,s,u)}}return E(t,"Use default value",{id:e,value:r.defaultValue}),te(t,e,r.defaultValue===void 0?null:r.defaultValue,"defaultValue")}function on(e,t,n){let{context:r}=n;Ye(e);let i=e.key,o=e.variations.length;if(o<2)return E(n,"Invalid experiment",{id:i}),D(n,e,-1,!1,t);if(r.enabled===!1)return E(n,"Context disabled",{id:i}),D(n,e,-1,!1,t);if(e.urlPatterns&&!Je(r.url||"",e.urlPatterns))return E(n,"Skip because of url targeting",{id:i}),D(n,e,-1,!1,t);let a=Ze(i,r.url||"",o);if(a!==null)return E(n,"Force via querystring",{id:i,variation:a}),D(n,e,a,!1,t);let u=_r(r)[i];if(u!==void 0)return E(n,"Force via dev tools",{id:i,variation:u}),D(n,e,u,!1,t);if(e.active===!1)return E(n,"Skip because inactive",{id:i}),D(n,e,-1,!1,t);let{hashAttribute:f,hashValue:d}=ee(r,e.hashAttribute,r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0);if(!d)return E(n,"Skip because missing hashAttribute",{id:i}),D(n,e,-1,!1,t);let g=-1,A=!1,y=!1;if(r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{variation:w,versionIsBlocked:U}=Yt(en({context:r,expKey:e.key,expBucketVersion:e.bucketVersion,expHashAttribute:e.hashAttribute,expFallbackAttribute:e.fallbackAttribute,expMinBucketVersion:e.minBucketVersion,expMeta:e.meta}));A=w>=0,g=w,y=!!U}if(!A){if(e.filters&&sn(e.filters,n))return E(n,"Skip because of filters",{id:i}),D(n,e,-1,!1,t);if(e.include&&!We(e.include))return E(n,"Skip because of include function",{id:i}),D(n,e,-1,!1,t);if(e.condition&&!an(e.condition,n))return E(n,"Skip because of condition exp",{id:i}),D(n,e,-1,!1,t);if(e.parentConditions){let w=new Set(n.stack.evaluatedFeatures);for(let U of e.parentConditions){n.stack.evaluatedFeatures=new Set(w);let re=ut(U.id,n);if(re.source==="cyclicPrerequisite")return D(n,e,-1,!1,t);let qe={value:re.value};if(!M(qe,U.condition||{},r.savedGroups||{}))return E(n,"Skip because prerequisite evaluation fails",{id:i}),D(n,e,-1,!1,t)}}}let b=xe(e.seed||i,d,e.hashVersion??2);if(b===null)return E(n,"Skip because of invalid hash version",{id:i}),D(n,e,-1,!1,t);if(!A){let w=e.ranges||Ke(o,e.coverage===void 0?1:e.coverage,e.weights);g=Qe(b,w)}if(y)return E(n,"Skip because sticky bucket version is blocked",{id:i}),D(n,e,-1,!1,t,void 0,!0);if(g<0)return E(n,"Skip because of coverage",{id:i}),D(n,e,-1,!1,t);if("force"in e)return E(n,"Force variation",{id:i,variation:e.force}),D(n,e,e.force===void 0?-1:e.force,!1,t);if(r.qaMode)return E(n,"Skip because QA mode",{id:i}),D(n,e,-1,!1,t);let k=D(n,e,g,!0,t,b,A);if(r.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing){let{changed:w,key:U,doc:re}=Xt(r,f,le(d),{[De(e.key,e.bucketVersion)]:k.key});if(w){r.stickyBucketAssignmentDocs=r.stickyBucketAssignmentDocs||{},r.stickyBucketAssignmentDocs[U]=re;let qe=r.saveStickyBucketAssignmentDoc;ct(()=>qe(re))}}return rn(n,e,k),E(n,"In experiment",{id:i,variation:k.variationId}),k}function te(e,t,n,r,i,o,a){let s={value:n,on:!!n,off:!n,source:r,ruleId:i||""};return o&&(s.experiment=o),a&&(s.experimentResult=a),r!=="override"&&wr(e,t,s),s}function an(e,t){return M(at(t.context),e,t.context.savedGroups||{})}function sn(e,t){return e.some(n=>{let{hashValue:r}=ee(t.context,n.attribute);if(!r)return!0;let i=xe(n.seed,r,n.hashVersion||2);return i===null?!0:!n.ranges.some(o=>Se(i,o))})}function Or(e,t,n,r,i,o,a){if(!i&&o===void 0)return!0;if(!i&&o===0)return!1;let{hashValue:s}=ee(e.context,n,r);if(!s)return!1;let u=xe(t,s,a??2);return u===null?!1:i?Se(u,i):o!==void 0?u<=o:!0}function D(e,t,n,r,i,o,a){let s=!0;(n<0||n>=t.variations.length)&&(n=0,s=!1);let{hashAttribute:u,hashValue:f}=ee(e.context,t.hashAttribute,e.context.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0),d=t.meta?.[n]??{},g=t.variations[0];for(let[y,b]of t.variations.entries())if(y===n){g=b;break}let A={key:d.key||""+n,featureId:i,inExperiment:s,hashUsed:r,variationId:n,value:g,hashAttribute:u,hashValue:f,stickyBucketUsed:!!a};return d.name&&(A.name=d.name),o!==void 0&&(A.bucket=o),d.passthrough&&(A.passthrough=d.passthrough),A}function cn(e,t){return t.hashAttribute+t.hashValue+e.key+t.variationId}/*!
|
|
2
|
+
Copyright (c) 2025 GrowthBook, Inc.
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
5
|
+
furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all
|
|
8
|
+
copies or substantial portions of the Software.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
11
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
12
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
13
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
14
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
15
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
|
+
SOFTWARE.
|
|
17
|
+
*/var ne=l.json().superRefine((e,t)=>{let n=0;function r(i,o){if(++n>1e4||o>20){t.addIssue({code:"custom",message:"JSON exceeds its depth or node budget"});return}if(typeof i=="string"&&(i.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(i))&&t.addIssue({code:"custom",message:"JSON text must contain valid Unicode without NUL"}),Array.isArray(i))i.forEach(a=>r(a,o+1));else if(i&&typeof i=="object")for(let[a,s]of Object.entries(i))(a.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(a)||["__proto__","prototype","constructor"].includes(a))&&t.addIssue({code:"custom",message:"Reserved JSON property"}),r(s,o+1)}r(e,0),new TextEncoder().encode(JSON.stringify(e)).byteLength>65536&&t.addIssue({code:"custom",message:"JSON exceeds 64 KiB"})}),pt=l.record(l.string().min(1).max(128),ne).superRefine((e,t)=>{(!ne.safeParse(e).success||Object.keys(e).length>128||new TextEncoder().encode(JSON.stringify(e)).byteLength>65536||["__proto__","constructor","prototype"].some(n=>Object.hasOwn(e,n)))&&t.addIssue({code:"custom",message:"Attribute document exceeds its budget or uses a reserved key"})}),vr=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"]),Le=pt.superRefine((e,t)=>{function n(r){if(Array.isArray(r))r.forEach(n);else if(r&&typeof r=="object")for(let[i,o]of Object.entries(r)){if(i==="$savedGroup"&&!l.strictObject({id:l.uuid(),attributeKey:l.string().min(1).max(128).optional()}).safeParse(o).success&&t.addIssue({code:"custom",message:"Saved groups use v2 object references"}),!i.startsWith("$")&&i.split(".").some(a=>["__proto__","prototype","constructor"].includes(a))&&t.addIssue({code:"custom",message:"Reserved attribute path"}),i.startsWith("$")&&!vr.has(i)&&t.addIssue({code:"custom",message:`Unknown GrowthBook operator: ${i}`}),["$regex","$regexi"].includes(i)&&typeof o=="string"){(/\(\?[<!=]|\\[0-9]|\\k</.test(o)||[...o.matchAll(/\{(\d+)(?:,(\d*))?\}/g)].some(a=>Number(a[1])>255||Number(a[2]||0)>255)||i==="$regexi"&&/[^\x00-\x7f]/.test(o.replace(/\\u([0-9a-f]{4})/gi,(a,s)=>String.fromCharCode(Number.parseInt(s,16)))))&&t.addIssue({code:"custom",message:"Regex is outside the shared TS/SQL subset"});try{new RegExp(o)}catch{t.addIssue({code:"custom",message:"Invalid regular expression"})}}n(o)}}typeof e.source=="string"&&["all","any","group","parameter","answer","attribute","result"].includes(e.source)&&("operator"in e||"predicates"in e||"groupId"in e)&&t.addIssue({code:"custom",message:"Obsolete condition protocol"}),n(e)}),Rr=l.discriminatedUnion("type",[l.strictObject({type:l.literal("condition"),condition:Le}),l.strictObject({type:l.literal("list"),attributeKey:l.string().min(1).max(128),values:l.array(l.union([l.string(),l.number().finite()])).max(1e5)})]).refine(e=>e.type!=="list"||new TextEncoder().encode(JSON.stringify(e.values)).byteLength<=1048576,"Saved group list exceeds 1 MiB");function Nr(e){let t=new Set;function n(r){if(Array.isArray(r))r.forEach(n);else if(r&&typeof r=="object")for(let[i,o]of Object.entries(r))i==="$savedGroup"&&o&&typeof o=="object"&&!Array.isArray(o)&&typeof o.id=="string"?t.add(o.id):["$inGroup","$notInGroup"].includes(i)&&typeof o=="string"?t.add(o):["$eq","$ne","$in","$nin","$ini","$nini"].includes(i)||n(o)}return n(e),[...t]}var Cr=l.record(l.uuid(),Rr).superRefine((e,t)=>{let n=new Set,r=new Set;function i(o){if(n.has(o)){t.addIssue({code:"custom",message:"Cyclic saved group dependency"});return}if(r.has(o))return;let a=e[o];if(!a){t.addIssue({code:"custom",message:"Missing saved group dependency"});return}n.add(o),a.type==="condition"&&Nr(a.condition).forEach(i),n.delete(o),r.add(o)}Object.keys(e).forEach(i)}),dt=l.tuple([l.number().min(0).max(1),l.number().min(0).max(1)]).refine(([e,t])=>e<=t),un=l.strictObject({attribute:l.string().optional(),seed:l.string().min(1),hashVersion:l.literal(2),ranges:l.array(dt).min(1).max(100)}),Tr=l.strictObject({id:l.string().min(1).max(128),condition:Le,gate:l.boolean().optional()}),lt={id:l.string().max(128).optional(),condition:Le.optional(),parentConditions:l.array(Tr).max(50).optional(),filters:l.array(un).max(20).optional()},jr=l.union([l.strictObject({...lt}),l.strictObject({...lt,force:ne,coverage:l.number().min(0).max(1).optional(),range:dt.optional(),seed:l.string().min(1).optional(),hashAttribute:l.string().optional(),hashVersion:l.literal(2).optional()}),l.strictObject({...lt,type:l.literal("experiment-ref"),experimentId:l.uuid(),values:l.record(l.string().min(1),ne),meta:l.record(l.string().min(1),l.strictObject({passthrough:l.boolean()})).optional()})]),Pr=l.strictObject({defaultValue:ne,rules:l.array(jr).max(100)}),Xo=l.record(l.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),Pr).superRefine((e,t)=>{Object.keys(e).length>100&&t.addIssue({code:"custom",message:"Too many Features"});let n=new Set,r=new Set;function i(o){if(n.has(o)){t.addIssue({code:"custom",message:`Cyclic Feature dependency: ${o}`});return}if(r.has(o))return;let a=e[o];if(!a){t.addIssue({code:"custom",message:`Unknown prerequisite Feature: ${o}`});return}n.add(o);for(let s of a.rules)for(let u of s.parentConditions??[])i(u.id);n.delete(o),r.add(o)}Object.keys(e).forEach(i)}),Dr=l.strictObject({name:l.string().max(80),reason:l.string().max(500),dateStarted:l.iso.datetime({offset:!0}),dateEnded:l.iso.datetime({offset:!0}).nullable(),coverage:l.number().min(0).max(1),variationWeights:l.array(l.number().min(0).max(1)).min(2).max(20).refine(e=>Math.abs(e.reduce((t,n)=>t+n,0)-1)<=.01),condition:Le,savedGroups:l.array(l.strictObject({match:l.enum(["any","all","none"]),ids:l.array(l.uuid()).min(1)})).max(50),namespace:l.strictObject({id:l.uuid(),ranges:l.array(dt).min(1)}).nullable(),seed:l.string().min(1).max(128)}),Lr=l.strictObject({key:l.string().min(1).max(128),name:l.string().min(1).max(80),hypothesis:l.string().max(2e3),status:l.enum(["draft","running","stopped"]),hashAttribute:l.string().min(1).max(128),fallbackAttribute:l.string().max(128).nullable(),hashVersion:l.literal(2),disableStickyBucketing:l.boolean(),bucketVersion:l.number().int().min(0).max(1e3),minBucketVersion:l.number().int().min(0).max(1e3),variations:l.array(l.strictObject({id:l.string().min(1),key:l.string().min(1),name:l.string().max(80),description:l.string().max(500)})).min(2).max(20),phases:l.array(Dr).min(1).max(100),releasedVariationId:l.string().nullable(),excludeFromPayload:l.boolean(),statusSchedule:l.strictObject({startAt:l.iso.datetime({offset:!0}).nullable(),stopAt:l.iso.datetime({offset:!0}).nullable(),stopAfter:l.strictObject({value:l.number().int().positive().max(36500),unit:l.enum(["hours","days"])}).nullable().optional()}).nullable()}).superRefine((e,t)=>{(e.minBucketVersion>e.bucketVersion||e.statusSchedule?.stopAt&&e.statusSchedule?.stopAfter||e.phases.some((n,r)=>{if(r===0)return!1;let i=e.phases[r-1];return!i?.dateEnded||Date.parse(n.dateStarted)<Date.parse(i.dateStarted)||Date.parse(i.dateEnded)>Date.parse(n.dateStarted)})||new Set(e.variations.map(n=>n.key)).size!==e.variations.length||new Set(e.variations.map(n=>n.id)).size!==e.variations.length||e.releasedVariationId!==null&&!e.variations.some(n=>n.id===e.releasedVariationId)||e.statusSchedule?.startAt&&e.statusSchedule?.stopAt&&Date.parse(e.statusSchedule.startAt)>=Date.parse(e.statusSchedule.stopAt)||e.phases.some(n=>n.dateEnded&&Date.parse(n.dateStarted)>=Date.parse(n.dateEnded)||n.namespace?.ranges.some(([r,i],o,a)=>r>=i||a.some(([s,u],f)=>f!==o&&r<u&&s<i)))||e.phases.some(n=>n.variationWeights.length!==e.variations.length))&&t.addIssue({code:"custom",message:"Invalid experiment versions, variation keys or weights"})});var Ur=Lr.safeExtend({filters:l.array(un).optional()}),$r=l.strictObject({experiments:l.record(l.uuid(),Ur),savedGroups:Cr}),zr=l.strictObject({attributeName:l.string(),attributeValue:l.string(),assignments:l.record(l.string(),l.string())}),ea=l.strictObject({snapshot:$r,attributes:pt,results:pt,stickyBucketAssignmentDocs:l.record(l.string(),zr)}),ta=l.strictObject({variantKey:l.string().nullable(),bucketVersion:l.number().int().min(0),source:l.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),bucket:l.number().min(0).max(1).optional(),stickyBucketUsed:l.boolean().optional(),hashUsed:l.boolean().optional()});import{z as v}from"zod";import{z as R}from"zod";var Ue=R.string().regex(/^(0|[1-9]\d{0,12})(\.\d{1,12})?$/),N=R.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e),Fr=R.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}),ft=N.refine(e=>/[1-9]/.test(e),"\u6570\u91CF\u5FC5\u987B\u5927\u4E8E 0"),ln=R.string().min(1).max(64),oe=R.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),pn=R.string().min(1).max(64).refine(e=>!e.includes("::"),"Dimension IDs cannot contain ::"),q=R.record(ln,R.union([R.string().max(120),R.number().finite(),R.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,n])=>[t,String(n)]))),dn=R.record(ln,R.union([R.string().max(120),R.number().finite(),R.boolean()]).transform(String)).refine(e=>Object.keys(e).length<=8,"\u5339\u914D\u6761\u4EF6\u6700\u591A 8 \u4E2A\u5C5E\u6027"),pe=e=>{let t=e.startsWith("-");t&&(e=e.slice(1));let[n,r=""]=e.split(".");if(n===void 0||n==="")throw new Error("Invalid decimal value");let i=BigInt(n)*BigInt("1000000")+BigInt(r.padEnd(6,"0"));return t?-i:i},fn=R.array(R.object({upTo:ft.nullable(),cost:N}).strict()).min(1).max(12).refine(e=>e.at(-1)?.upTo===null&&e.slice(0,-1).every((t,n)=>{let r=e[n-1]?.upTo;return t.upTo!==null&&(n===0||r!=null&&pe(t.upTo)>pe(r))}),"\u9636\u68AF\u4E0A\u9650\u5FC5\u987B\u9012\u589E\uFF0C\u6700\u540E\u4E00\u6863\u4E3A\u65E0\u9650"),Vr=R.object({key:pn,match:dn,priority:R.number().int().default(0),cost:N.optional(),tiers:fn.optional()}).strict().refine(e=>e.cost!==void 0||e.tiers!==void 0,"\u7EF4\u5EA6\u9700\u8981\u6307\u5B9A\u5355\u4EF7\u6216\u9636\u68AF"),Br=R.object({key:pn,match:dn,factor:ft.optional(),add:Fr.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"})),Mr=R.object({units:ft.default("1"),cost:N,tiers:fn.optional(),dimensions:R.array(Vr).max(12).optional(),multipliers:R.array(Br).max(4).optional()}).strict().superRefine((e,t)=>{let n=e.dimensions??[],r=e.multipliers??[];(new Set(n.map(a=>a.key)).size!==n.length||new Set(r.map(a=>a.key)).size!==r.length)&&t.addIssue({code:"custom",message:"\u7EF4\u5EA6\u548C\u500D\u7387\u7684 ID \u4E0D\u80FD\u91CD\u590D"});for(let[a,s]of n.entries())for(let u of n.slice(a+1))Object.keys(s.match).length===Object.keys(u.match).length&&s.priority===u.priority&&!Object.keys(s.match).some(f=>u.match[f]!==void 0&&u.match[f]!==s.match[f])&&t.addIssue({code:"custom",message:"\u7EF4\u5EA6\u53EF\u80FD\u540C\u65F6\u5339\u914D\uFF0C\u8BF7\u8C03\u6574\u4F18\u5148\u7EA7"});let i=[e.cost,...(e.tiers??[]).map(a=>a.cost),...n.flatMap(a=>[...a.cost===void 0?[]:[a.cost],...(a.tiers??[]).map(s=>s.cost)])],o=pe(e.units);for(let a of i)for(let s=0;s<1<<r.length;s++){let u=r.filter((b,k)=>s&1<<k);if(u.some((b,k)=>u.slice(k+1).some(w=>Object.keys(b.match).some(U=>w.match[U]!==void 0&&w.match[U]!==b.match[U]))))continue;let f=pe(a),d=BigInt("1"),g=BigInt("0");for(let[b,k]of r.entries())s&1<<b&&(f*=pe(k.factor??"1"),d*=BigInt("1000000"),g+=pe(k.add??"0"));let A=(f+g*d)*BigInt("1000000"),y=d*o;(A<BigInt("0")||A%y!==BigInt("0")||A/y>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"})}}),ia=Mr.safeExtend({featureKey:oe});import{z as qr}from"zod";import{z as de}from"zod";var mn=de.enum(["stripe","apple","google","merchant"]),sa=de.enum(["membership","credit_pack","lifetime"]),ca=de.enum(["active","grace","suspended","inactive","revoked"]),ua=de.strictObject({currency:de.string().regex(/^[A-Z]{3}$/),micros:de.string().regex(/^(0|[1-9][0-9]{0,29})$/)});var gn=qr.object({provider:mn,currency:$}).strict();var bn=v.strictObject({internal_feature_id:v.uuid(),quantity:N.refine(e=>/[1-9]/.test(e)),properties:q,entityId:v.uuid().optional()}),xa=v.strictObject({requirement:bn,commerce:gn.optional(),paywallId:v.uuid().optional()}),Hr=v.enum(["not_entitled","insufficient_balance","capacity_exceeded","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded","unavailable","authentication_required"]),Gr=v.strictObject({productId:v.string().min(1),productVersionId:v.string().min(1),name:v.string().min(1).max(120),action:v.enum(["purchase","upgrade","addon","topup"]),membershipId:v.string().min(1).nullable(),currency:$,amountMinor:v.string().regex(/^(0|[1-9]\d{0,8})$/),interval:v.enum(["free","week","month","year","one_time"]),intervalCount:v.number().int().min(1).max(156)}),hn=v.strictObject({internal_feature_id:v.string().min(1),name:v.string().min(1).max(120),kind:v.enum(["access","metered","credit"]),quantity:N,allowed:v.boolean(),reason:Hr.nullable(),preview:v.strictObject({scenario:v.enum(["feature_flag","usage_limit"]),candidates:v.array(Gr).max(20)}).nullable()}).superRefine((e,t)=>{(e.allowed!==(e.reason===null)||e.allowed&&e.preview!==null||new Set(e.preview?.candidates.map(n=>n.productVersionId)).size!==(e.preview?.candidates.length??0)||e.preview?.candidates.some(n=>n.action==="upgrade"!=(n.membershipId!==null)))&&t.addIssue({code:"custom",message:"Invalid access recommendation"})}),Sa=v.strictObject({paywallId:v.uuid(),requirement:bn});import{z as x}from"zod";import{z as ge}from"zod";import{z as me}from"zod";import{z as fe}from"zod";var yn=fe.number().int().min(0).max(1e8),mt=fe.strictObject({kind:fe.enum(["graduated","volume"]),tiers:fe.array(fe.strictObject({upTo:fe.number().int().min(1).max(1e4).nullable(),unitAmountMinor:yn,flatAmountMinor:yn.optional()})).min(1).max(12)}).refine(e=>e.tiers.at(-1)?.upTo===null&&e.tiers.slice(0,-1).every((t,n)=>{let r=e.tiers[n-1]?.upTo;return t.upTo!==null&&(n===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 gt(e,t){if(!Number.isInteger(t)||t<0||t>1e4)throw new Error("Invalid purchased pack quantity");let n=e.pricing?mt.parse(e.pricing):void 0;if(t===0)return 0;let r=0n,i=0;if(!n)r=BigInt(e.amountMinor)*BigInt(t);else for(let o of n.tiers){let a=o.upTo??1e4;if(n.kind==="volume"){if(t<=a){r=BigInt(t)*BigInt(o.unitAmountMinor)+BigInt(o.flatAmountMinor??0);break}}else t>i&&(r+=BigInt(Math.min(t,a)-i)*BigInt(o.unitAmountMinor));i=a}if(r>200000000n)throw new Error("Purchased price exceeds the payment amount limit");return Number(r)}function xn(e){return gt({amountMinor:e.unitAmountMinor,...e.pricing?{pricing:e.pricing}:{}},e.quantity)}var Qr=N.refine(e=>/[1-9]/.test(e)),kn=me.strictObject({units:Qr,prices:me.array(me.strictObject({currency:$,amountMinor:me.number().int().min(0).max(1e8),pricing:mt.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:me.number().int().min(0).max(1e4),maximumQuantity:me.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 n of[e.maximumQuantity,...t.pricing?.tiers.flatMap(r=>r.upTo===null?[]:[r.upTo,r.upTo+1])??[]])n<=e.maximumQuantity&>({amountMinor:t.amountMinor,...t.pricing===void 0?{}:{pricing:t.pricing}},n);return!0}catch{return!1}},"Every purchasable quantity must fit the payment amount limit");function Sn(e){if(!/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/.test(e))throw new Error("Invalid quantity");let[t,n=""]=e.split(".");if(t===void 0||t==="")throw new Error("Invalid decimal value");return BigInt(t)*1000000n+BigInt(n.padEnd(6,"0"))}function An(e,t,n){if(!Number.isSafeInteger(n)||n<0||n>1e4)throw new Error("Invalid purchased quantity");let r=Sn(e)+Sn(t)*BigInt(n);if(r>999999999999999999n)throw new Error("Purchased allowance exceeds the ledger quantity limit");let i=(r%1000000n).toString().padStart(6,"0").replace(/0+$/,"");return(r/1000000n).toString()+(i?"."+i:"")}var bt=ge.strictObject({internalFeatureId:ge.uuid(),name:ge.string().min(1).max(120),includedAmount:ge.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/),reset:ge.enum(["hour","day","week","month","year","lifetime"]),resetCount:ge.number().int().min(1).max(100),terms:kn});var Kr=["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"],$e=x.object({plan:x.string().min(1).max(200).optional(),coupon:x.uuid().optional(),promotionCode:x.uuid().optional(),picker:x.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).optional()}).strict(),In=x.object({text:x.string().optional(),label:x.string().optional(),alt:x.string().optional(),html:x.string().max(32768).optional(),price:x.object({current:x.string(),original:x.string().nullable(),period:x.string()}).optional(),code:x.string().optional(),countdownAt:x.iso.datetime().optional(),planId:x.string().min(1).max(200).optional(),planVersionId:x.string().min(1).max(200).optional(),currency:$.optional(),couponId:x.uuid().optional(),offerId:x.uuid().optional(),unavailable:x.boolean().optional(),unavailableReason:x.string().optional(),missing:x.array(x.string()).optional()}).strict(),La=x.object({paywall:hn.optional(),nodes:x.record(x.string(),x.object({base:In,picker:x.string().optional(),byPlan:x.record(x.string(),In).optional()}).strict()),plans:x.record(x.string(),x.object({id:x.string().min(1).max(200),versionId:x.string().min(1).max(200),available:x.boolean(),name:x.string(),price:x.string(),period:x.string(),currency:$.optional(),amountMinor:x.number().int().nonnegative().optional(),interval:x.enum(["free","week","month","year","one_time"]).optional(),intervalCount:x.number().int().positive().optional(),prepaid:x.array(bt).max(100).optional()}).strict()),pickers:x.record(x.string(),x.object({options:x.array(x.string().min(1).max(200)).max(20),selected:x.string().min(1).max(200).nullable()}).strict()),quantities:x.record(x.string(),x.strictObject({minimum:x.number().int().nonnegative(),maximum:x.number().int().nonnegative(),step:x.number().int().positive(),value:x.number().int().nonnegative(),label:x.string(),available:x.boolean()})).optional(),diagnostics:x.array(x.object({nodeId:x.string(),message:x.string()}).strict())}).strict();function En(e){return[...e.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].flatMap(t=>t[1]===void 0?[]:[t[1].trim()])}function ht(e){let t=En(e).filter(r=>!Kr.includes(r)&&!/^variables\.[A-Za-z0-9_][A-Za-z0-9_.:-]*$/.test(r)),n=e.replace(/\{\{\s*[^{}]+?\s*\}\}/g,"");return(n.includes("{{")||n.includes("}}"))&&t.push("\u65E0\u6548\u53D8\u91CF\u8BED\u6CD5"),[...new Set(t)]}function Ua(e,t,n={}){let r=e?.nodes[t];if(!r)return;let i=r.picker?n[r.picker]??e?.pickers[r.picker]?.selected:void 0;return typeof i=="string"?r.byPlan?.[i]??r.base:r.base}import{z as S}from"zod";var Zr=["credit_balance","credit_transactions","membership","billing","billing_controls","customer_plans","credit_packs","credit_pack_orders","offer_history"],_n=S.enum(Zr),wn=S.object({source:_n,layout:S.enum(["full","compact"]),resourceKey:oe.optional(),pageSize:S.number().int().min(1).max(50),showSources:S.boolean(),allowPurchase:S.boolean(),outputs:S.object({billing_adjustment:S.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_authorization:S.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),buy_pack:S.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),billing_portal:S.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),cancel_membership:S.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/).optional(),resume_membership:S.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"})}),j=S.string().max(2e3),On=S.object({id:S.string().max(100),label:j,detail:S.array(j).max(12),value:j.optional(),status:j.optional(),facts:S.array(S.object({label:j,value:j}).strict()).max(1e3),purchaseId:S.uuid().optional(),invoiceUrl:S.url().max(2048).refine(e=>{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}).optional(),billingActions:S.array(S.strictObject({action:S.literal("invoice_open"),label:j})).max(1).optional(),membershipActions:S.array(S.object({value:S.string().max(100),label:j}).strict()).max(3).optional()}).strict(),Wr=S.object({key:oe,name:j,spendable:j,reserved:j,available:j,expiry:j.nullable(),sources:S.array(On).max(50),sourceCount:S.number().int().nonnegative(),sourcePage:S.number().int().positive(),hasNextSources:S.boolean(),hasPreviousSources:S.boolean()}).strict(),Jr=S.object({source:_n,status:S.enum(["idle","loading","ready","error"]),stale:S.boolean(),preview:S.boolean(),errorCode:S.string().max(80).optional(),errorMessage:j.optional(),resources:S.array(Wr).max(500),rows:S.array(On).max(50),hasNext:S.boolean(),hasPrevious:S.boolean(),page:S.number().int().positive(),filter:S.string().max(40),updatedAt:S.iso.datetime().optional(),buyingId:S.uuid().optional(),membershipBusy:S.boolean().optional(),billingBusy:S.boolean().optional(),membershipReview:S.object({title:j,note:j,facts:S.array(S.object({label:j,value:j}).strict()).max(100)}).strict().optional(),membershipResult:j.optional()}).strict(),Va=S.object({nodes:S.record(S.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Jr)}).strict(),Ba=S.object({nodeId:S.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),action:S.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:S.string().max(100).optional()}).strict();import{z as O}from"zod";var Yr=O.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),Ha=O.discriminatedUnion("type",[O.object({type:O.literal("fixed"),productVersionId:O.string().min(1).max(200)}).strict(),O.object({type:O.literal("picker"),pickerId:Yr,allowedProductVersionIds:O.array(O.string().min(1).max(200)).min(1).max(20)}).strict().refine(e=>new Set(e.allowedProductVersionIds).size===e.allowedProductVersionIds.length,"Product choices must be unique")]),Xr=O.strictObject({min:O.number().finite().min(1).max(1800),max:O.number().finite().min(1).max(1800),viewport:O.number().finite().min(1).max(100)}).refine(e=>e.min<=e.max,"Desktop width range is reversed"),vn={desktopWidth:Xr.optional(),mobile:O.enum(["sheet","fullscreen"]).optional(),backdrop:O.enum(["none","scrim","dim","strong-dim","blur"]).optional()},Rn=O.discriminatedUnion("type",[O.strictObject({type:O.literal("modal"),size:O.enum(["sm","md","lg"]),...vn}),O.strictObject({type:O.literal("sheet"),size:O.enum(["sm","md","lg"]),...vn}),O.strictObject({type:O.literal("fullscreen")}),O.strictObject({type:O.literal("inline")})]),ei={sm:360,md:420,lg:560};import{z as c}from"zod";function Nn(e){return e.type==="stack"&&e.interaction?.type==="select"&&e.interaction.purpose==="product"&&!!e.interaction.pickerId}function Cn(e){let t={};function n(r){if(Nn(r)){let i=t[r.interaction.pickerId]??={ids:[],defaultId:null};for(let a of r.children){let s=a.type==="stack"?a.bind?.plan:void 0;s&&!i.ids.includes(s)&&i.ids.push(s)}let o=r.children[r.interaction.defaultIndex];!i.defaultId&&o?.type==="stack"&&(i.defaultId=o.bind?.plan??null)}r.type==="stack"&&r.children.forEach(n)}return e.pages.forEach(r=>n(r.root)),t}function Tn(e,t,n){let r={};function i(u){if(u.hidden)return;if(u.type==="plan_picker"){let g=n.pickers[u.id];r[u.id]={ids:g?.options??[],defaults:g?.selected?[g.selected]:[],remembered:[]};return}if(u.type!=="stack")return;let f=u.children.filter(g=>!g.hidden),d=u.interaction;if(Nn(u)){let g=r[u.interaction.pickerId]??={ids:[],defaults:[],remembered:[]},A=n.pickers[u.interaction.pickerId]?.options??[];for(let b of f){let k=b.type==="stack"?b.bind?.plan:void 0;k&&A.includes(k)&&!g.ids.includes(k)&&g.ids.push(k),k&&b.id===t[u.id]&&g.remembered.push(k)}let y=u.children[u.interaction.defaultIndex];y?.type==="stack"&&!y.hidden&&y.bind?.plan&&g.defaults.push(y.bind.plan)}if(d?.type==="tabs"){let g=f.find(A=>A.id===t[u.id])??u.children[d.defaultIndex];g&&i(g)}else if(d?.type==="toggle"){let g=typeof t[u.id]=="boolean"?t[u.id]:d.defaultEnabled,A=u.children[g?0:1];A&&i(A)}else f.forEach(i)}let o=typeof t.__page=="string"?t.__page:e.initialPageId??e.pages[0]?.id,a=e.pages.find(u=>u.id===o);a&&i(a.root);let s={};for(let[u,f]of Object.entries(r)){let d=t[u],g=f.remembered[0]??(f.ids.includes(n.pickers[u]?.selected??"")?n.pickers[u]?.selected:f.defaults[0]);s[u]=typeof d=="string"?f.ids.includes(d)?d:"":g&&f.ids.includes(g)?g:""}for(let u of Object.keys(Cn(e)))s[u]??="";return s}import{z as Y}from"zod";var jn=Y.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Pn=Y.strictObject({tiers:Y.array(Y.strictObject({id:jn,name:Y.string().trim().min(1).max(80)})).min(1).max(8),assignments:Y.array(Y.strictObject({productVersionId:Y.string().min(1).max(200),tierId:jn,period:Y.enum(["month","year"])})).max(20)}).superRefine((e,t)=>{let n=e.tiers.map(r=>r.id);(new Set(n).size!==n.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=>!n.includes(r.tierId)))&&t.addIssue({code:"custom",message:"Each product and tier/period cell must have one unambiguous assignment"})});function Dn(e,t){return e.assignments.length===t.length&&e.assignments.every(n=>t.includes(n.productVersionId))}function Ja(e){let t=ht(e).map(n=>`\u672A\u77E5\u53D8\u91CF\uFF1A${n}`);for(let n=0;n<e.length;n++){if(e[n]!=="<"||!/[A-Za-z!/?{]/.test(e[n+1]??""))continue;let r=n;if(e.startsWith("<!--",n)){let i=e.indexOf("-->",n+4);n=i<0?e.length:i+2}else{let i="";for(n++;n<e.length;n++){let o=e[n];if(i)o===i&&(i="");else if(o==='"'||o==="'")i=o;else if(o===">")break}}/\{\{|\}\}/.test(e.slice(r,n+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 m}from"zod";var T={state:32,enumValues:64,derived:96,bindings:256,controls:64,timers:4,effects:8,depth:12,expressionNodes:2e3},Un=new Set([...Object.getOwnPropertyNames(Object.prototype),"prototype"]),L=m.string().regex(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/).refine(e=>!Un.has(e),"Reserved UI identifier"),yt=m.union([m.string().max(2e3),m.number().finite(),m.boolean(),m.null()]),ti=m.discriminatedUnion("type",[m.strictObject({type:m.literal("enum"),values:m.array(yt).min(1).max(T.enumValues),default:yt}),m.strictObject({type:m.literal("number"),min:m.number().finite(),max:m.number().finite(),step:m.number().finite().positive(),default:m.number().finite()}),m.strictObject({type:m.literal("text"),maxLength:m.number().int().min(0).max(2e3),default:m.string().max(2e3).nullable()}),m.strictObject({type:m.literal("boolean"),default:m.boolean()})]);function ze(e,t){if(e.type==="enum")return e.values.some(r=>r===t);if(e.type==="boolean")return typeof t=="boolean";if(e.type==="text")return t===null||typeof t=="string"&&t.length<=e.maxLength;if(typeof t!="number"||!Number.isFinite(t)||t<e.min||t>e.max)return!1;let n=(t-e.min)/e.step;return Number.isFinite(n)&&Math.abs(n-Math.round(n))<=Math.min(1e-7,Math.max(1,Math.abs(n))*Number.EPSILON*8)}var ni=ti.superRefine((e,t)=>{e.type==="enum"&&new Set(e.values).size!==e.values.length&&t.addIssue({code:"custom",path:["values"],message:"UI enum values must be unique"}),e.type==="number"&&e.min>e.max&&t.addIssue({code:"custom",path:["max"],message:"UI number range is reversed"}),ze(e,e.default)||t.addIssue({code:"custom",path:["default"],message:"UI default must match its state definition"})}),ri=["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 ii(e,t){return e==="now"?t===0:e==="concat"?!0:e==="lookup"?t>=4&&t%2===0:e==="if"?t===3:["sub","div","eq","ne","gt","gte","lt","lte"].includes(e)?t===2:["round","floor","not","number","parse_number","money","duration"].includes(e)?t===1:t>=1}var se=m.lazy(()=>m.union([yt,m.strictObject({ref:L}),m.strictObject({op:m.enum(ri),args:m.array(se).max(T.expressionNodes)}).superRefine((e,t)=>{ii(e.op,e.args.length)||t.addIssue({code:"custom",path:["args"],message:"Invalid UI expression arity"})})]));function H(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function ae(e,t,n){if(!e||typeof e!="object")return!0;if(!H(e))return t.addIssue({code:"custom",path:n,message:"UI objects must be plain data"}),!1;for(let r of Object.keys(e)){if(Un.has(r))return t.addIssue({code:"custom",path:[...n,r],message:"Reserved UI object key"}),!1;let i=Object.getOwnPropertyDescriptor(e,r);if(i&&!Object.hasOwn(i,"value"))return t.addIssue({code:"custom",path:[...n,r],message:"UI objects cannot contain accessors"}),!1}return!0}function be(e,t,n,r){let i=[{value:e,depth:1,path:n}];for(;i.length;){let o=i.pop();if(++r.nodes>T.expressionNodes||o.depth>T.depth){t.addIssue({code:"custom",path:o.path,message:"UI expression budget exceeded"});return}if(!ae(o.value,t,o.path))return;if(H(o.value)&&Array.isArray(o.value.args)){if(o.value.args.length>T.expressionNodes){t.addIssue({code:"custom",path:[...o.path,"args"],message:"UI expression budget exceeded"});return}for(let a=o.value.args.length-1;a>=0;a--)i.push({value:o.value.args[a],depth:o.depth+1,path:[...o.path,"args",a]})}}}var es=m.unknown().superRefine((e,t)=>{be(e,t,[],{nodes:0})}).pipe(se),xt=m.record(L,se).refine(e=>Object.keys(e).length>0&&Object.keys(e).length<=T.state,"UI assignments need 1\u201332 state keys"),oi=m.strictObject({target:L,property:m.enum(["text","visible","disabled","checked","value","class","aria-label","aria-selected","aria-checked","aria-valuetext","tabindex"]),expression:se,className:L.optional()}).superRefine((e,t)=>{e.property==="class"!=(e.className!==void 0)&&t.addIssue({code:"custom",path:["className"],message:"Only class bindings require a safe className"})}),ai=m.discriminatedUnion("type",[m.strictObject({type:m.literal("scroll_latch"),target:L,state:L}),m.strictObject({type:m.literal("input"),target:L,state:L,set:xt.optional()}),m.strictObject({type:m.literal("action"),target:L,set:xt}),m.strictObject({type:m.literal("carousel"),target:L,state:L,initialIndex:m.number().int().nonnegative().optional(),maxWidth:m.number().int().min(1).max(1e4).optional(),previousTarget:L.optional(),nextTarget:L.optional(),inactiveTargets:m.array(L).max(20).optional(),inactiveMaxWidth:m.number().int().min(1).max(1e4).optional()})]),si=m.strictObject({afterMs:m.number().int().min(0).max(6e4),set:xt}),ci=m.strictObject({type:m.literal("mosaic_waves"),target:L,color:m.string().regex(/^#[0-9a-fA-F]{6}$/),hotColor:m.string().regex(/^#[0-9a-fA-F]{6}$/),enabled:se.optional(),speed:m.number().min(0).max(4).optional(),pitch:m.number().min(.05).max(4).optional(),fill:m.number().min(.05).max(1).optional(),feather:m.number().min(0).max(1).optional(),warp:m.number().min(0).max(4).optional(),warpScale:m.number().min(0).max(32).optional(),detailScale:m.number().min(0).max(32).optional(),waveScale:m.number().min(0).max(32).optional(),falloff:m.number().min(.1).max(32).optional(),brightness:m.number().min(0).max(32).optional(),ambient:m.number().min(0).max(1).optional(),gamma:m.number().min(.05).max(8).optional(),vignette:m.number().min(0).max(1).optional(),opacity:m.number().min(0).max(1).optional()}),ui=m.strictObject({type:m.literal("number_counter"),target:L,value:se,prefix:m.string().max(20).optional(),format:m.enum(["number","short"]).optional()}),li=m.strictObject({state:m.record(L,ni).refine(e=>Object.keys(e).length<=T.state,"Too many UI state keys").optional(),derived:m.record(L,se).refine(e=>Object.keys(e).length<=T.derived,"Too many UI derived keys").optional(),bindings:m.array(oi).max(T.bindings).optional(),controls:m.array(ai).max(T.controls).optional(),timers:m.array(si).max(T.timers).optional(),effects:m.array(m.discriminatedUnion("type",[ci,ui])).max(T.effects).optional(),clock:m.boolean().optional()});function pi(e,t){if(!ae(e,t,[])||!H(e))return;for(let[r,i]of[["state",T.state],["derived",T.derived]]){let o=e[r];if(!ae(o,t,[r]))return;if(H(o)&&Object.keys(o).length>i){t.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}}for(let[r,i]of[["bindings",T.bindings],["controls",T.controls],["timers",T.timers],["effects",T.effects]])if(Array.isArray(e[r])&&e[r].length>i){t.addIssue({code:"custom",path:[r],message:"UI declaration budget exceeded"});return}if(Array.isArray(e.effects)){for(let[r,i]of e.effects.entries())if(!ae(i,t,["effects",r]))return}if(H(e.state))for(let[r,i]of Object.entries(e.state)){if(!ae(i,t,["state",r]))return;if(H(i)&&Array.isArray(i.values)&&i.values.length>T.enumValues){t.addIssue({code:"custom",path:["state",r,"values"],message:"Too many UI enum values"});return}}let n={nodes:0};if(H(e.derived))for(let[r,i]of Object.entries(e.derived))be(i,t,["derived",r],n);for(let r of["bindings","controls","timers"]){let i=e[r];if(Array.isArray(i)){for(let[o,a]of i.entries())if(!(!ae(a,t,[r,o])||!H(a))){if(r==="bindings")be(a.expression,t,[r,o,"expression"],n);else if(ae(a.set,t,[r,o,"set"])&&H(a.set)){if(Object.keys(a.set).length>T.state){t.addIssue({code:"custom",path:[r,o,"set"],message:"Too many UI assignments"});return}for(let[s,u]of Object.entries(a.set))be(u,t,[r,o,"set",s],n)}if(n.nodes>T.expressionNodes)return}}}if(Array.isArray(e.effects))for(let[r,i]of e.effects.entries())H(i)&&i.type==="number_counter"?be(i.value,t,["effects",r,"value"],n):H(i)&&i.enabled!==void 0&&be(i.enabled,t,["effects",r,"enabled"],n)}function Ln(e){let t=[],n=[e];for(;n.length;){let r=n.pop();!r||typeof r!="object"||("ref"in r?t.push(r.ref):n.push(...r.args))}return t}var $n=m.unknown().superRefine(pi).pipe(li).superRefine((e,t)=>{let n=e.state??{},r=e.derived??{},i=new Set([...Object.keys(n),...Object.keys(r)]),o=(y,b)=>{for(let k of Ln(y))i.has(k)||t.addIssue({code:"custom",path:b,message:`Unknown UI reference: ${k}`})};for(let[y,b]of Object.entries(e.derived??{}))Object.hasOwn(n,y)&&t.addIssue({code:"custom",path:["derived",y],message:"UI state and derived identifiers must be distinct"}),o(b,["derived",y]);let a=new Set,s=new Set,u=y=>{if(a.has(y))return!1;if(s.has(y))return!0;a.add(y);for(let b of Ln(r[y]))if(Object.hasOwn(r,b)&&!u(b))return!1;return a.delete(y),s.add(y),!0};for(let y of Object.keys(r))if(!u(y)){t.addIssue({code:"custom",path:["derived",y],message:"Cyclic UI derived references"});break}for(let[y,b]of(e.bindings??[]).entries())o(b.expression,["bindings",y,"expression"]);let f=new Set;for(let[y,b]of(e.effects??[]).entries())f.has(b.target)&&t.addIssue({code:"custom",path:["effects",y,"target"],message:"Effect targets must be unique"}),f.add(b.target),b.type==="number_counter"?(o(b.value,["effects",y,"value"]),typeof b.value=="number"&&Math.abs(b.value)>1e12&&t.addIssue({code:"custom",path:["effects",y,"value"],message:"Counter values must be within the display bound"})):b.enabled!==void 0&&o(b.enabled,["effects",y,"enabled"]);let d=(y,b)=>{for(let[k,w]of Object.entries(y))Object.hasOwn(n,k)||t.addIssue({code:"custom",path:[...b,k],message:"UI assignments can only update declared state"}),o(w,[...b,k])},g=new Set,A=new Set;for(let[y,b]of(e.controls??[]).entries()){if(b.type==="carousel"&&b.inactiveMaxWidth!==void 0&&b.inactiveTargets===void 0&&t.addIssue({code:"custom",path:["controls",y,"inactiveMaxWidth"],message:"Inactive width requires inactive article targets"}),b.type==="carousel")for(let k of b.inactiveTargets??[])(k===b.target||A.has(k))&&t.addIssue({code:"custom",path:["controls",y,"inactiveTargets"],message:"Inactive article targets must have one carousel owner"}),A.add(k);if(b.type==="carousel")for(let k of["previousTarget","nextTarget"]){let w=b[k];w!==void 0&&((w===b.target||g.has(w)||(e.controls??[]).some(U=>U.target===w))&&t.addIssue({code:"custom",path:["controls",y,k],message:"Carousel navigation needs a distinct, exclusive button target"}),g.add(w))}if(b.type!=="action"){let k=Object.hasOwn(n,b.state)?n[b.state]:void 0;(!k||b.type==="input"&&k.type==="enum"&&k.values.some(w=>typeof w!="string"))&&t.addIssue({code:"custom",path:["controls",y,"state"],message:"Control needs a supported declared UI state"}),b.type==="carousel"&&(k?.type!=="number"||!Number.isInteger(k.min)||k.min<0||!Number.isInteger(k.max)||k.step!==1||b.initialIndex!==void 0&&!ze(k,b.initialIndex))&&t.addIssue({code:"custom",path:["controls",y],message:"Carousel needs bounded nonnegative integer index state"}),b.type==="scroll_latch"&&k?.type!=="boolean"&&t.addIssue({code:"custom",path:["controls",y,"state"],message:"Scroll latches require boolean UI state"})}(b.type==="input"||b.type==="action")&&b.set&&d(b.set,["controls",y,"set"])}for(let[y,b]of(e.timers??[]).entries())d(b.set,["timers",y,"set"])});import{z as di}from"zod";var Fn=/^[a-z]{2,3}(-[A-Z][a-z]{3})?(-([A-Z]{2}|[0-9]{3}))?$/,he=di.string().max(16).regex(Fn,"\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 St(e){if(typeof e!="string")return null;try{let t=Intl.getCanonicalLocales(e.trim().replaceAll("_","-"))[0];if(!t)return null;let{language:n,script:r,region:i}=new Intl.Locale(t),o=[n,r,i].filter(Boolean).join("-");return Fn.test(o)?o:null}catch{return null}}var fi=new Set(["TW","HK","MO"]);function zn(e){let[t,n,r]=e.split("-");if(t!=="zh")return`${t}-${new Intl.Locale(e).maximize().script??""}`;let i=n?.length===4?n:void 0,o=n?.length===4?r:n;return i?`zh-${i}`:o&&fi.has(o)?"zh-Hant":"zh-Hans"}function Vn(e,t,n){let r=t.map(i=>({code:he.parse(i),normalized:i}));for(let i of e){let o=St(i);if(!o)continue;let a=r.find(d=>d.normalized===o);if(a)return a.code;let s=zn(o),u=r.filter(d=>zn(d.normalized)===s),f=u.find(d=>!d.normalized.includes("-")||d.normalized===s)??u[0];if(f)return f.code}return n}var mi=4,Q={nodes:150,depth:8,children:50,locales:20,actions:40,pages:10,stringLength:2e3,customHtml:32768,customCss:32768,documentBytes:2e5},Ie=c.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),_=c.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),gi=c.enum(["none","xs","sm","md","lg","xl"]),bi=c.enum(["none","sm","md","lg","full"]),kt=c.string().regex(/^#[0-9a-fA-F]{6}$/),It=c.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"),At=c.union([It,c.string().max(32768).regex(/^data:image\/svg\+xml;base64,[A-Za-z0-9+/]+={0,2}$/),c.string().max(131072).regex(/^data:image\/jpeg;base64,\/9j\/[A-Za-z0-9+/]+={0,2}$/),c.string().max(131072).regex(/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]+={0,2}$/)]),Bn=c.object({primary:kt,background:kt,text:kt,radius:bi,font:c.enum(["system","serif","rounded","mono"]),fontAssets:c.object({family:c.string().regex(/^[A-Za-z][A-Za-z0-9 -]{0,39}$/),faces:c.array(c.object({url:It,weight:c.number().int().min(100).max(900).multipleOf(100),family:c.string().regex(/^[A-Za-z][A-Za-z0-9 -]{0,39}$/).optional()}).strict()).min(1).max(4)}).strict().optional()}).strict(),Ee=c.union([c.enum(["primary","text","muted","background","surface"]),c.string().regex(/^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/)]),I=(e,t)=>c.number().int().min(e).max(t),Mn=c.union([c.enum(["fit","fill"]),I(1,1200)]),hi=c.object({top:I(0,200),right:I(0,200),bottom:I(0,200),left:I(0,200)}).strict(),yi=c.object({top:I(-100,200),right:I(-100,200),bottom:I(-100,200),left:I(-100,200)}).strict(),qn=c.object({x:I(0,100),y:I(0,100)}).strict(),xi=c.discriminatedUnion("type",[c.object({type:c.literal("color"),color:Ee}).strict(),c.object({type:c.literal("linear"),angle:I(0,360),stops:c.array(c.object({color:Ee,at:I(0,100)}).strict()).min(2).max(4)}).strict(),c.object({type:c.literal("image"),src:At,fit:c.enum(["cover","contain"]),position:qn.optional()}).strict()]),Si=c.discriminatedUnion("type",[c.object({type:c.literal("rect"),radius:c.union([I(0,200),c.object({topLeft:I(0,200),topRight:I(0,200),bottomRight:I(0,200),bottomLeft:I(0,200)}).strict()])}).strict(),c.object({type:c.literal("pill")}).strict()]),ki=c.object({width:I(0,12),color:Ee,style:c.enum(["solid","dashed"])}).strict(),Ai=c.object({x:I(-40,40),y:I(-40,40),blur:I(0,80),spread:I(-20,40),color:Ee}).strict(),Ii=c.object({font:c.enum(["system","serif","rounded","mono"]),size:I(8,96),weight:c.number().int().min(100).max(900).multipleOf(100),lineHeight:c.number().min(.8).max(3),letterSpacing:c.number().min(-5).max(20),color:Ee,align:c.enum(["start","center","end"]),italic:c.boolean(),decoration:c.enum(["none","underline","line-through"]),transform:c.enum(["none","uppercase"])}).strict().partial(),ce=c.object({width:Mn,height:Mn,padding:hi,margin:yi,gap:I(0,120),grow:c.union([c.boolean(),c.number().min(0).max(12)]),background:xi,opacity:c.number().min(0).max(1),clipContent:c.boolean(),shape:Si,border:ki,shadow:Ai,text:Ii}).strict().partial(),F={id:Ie,name:c.string().trim().min(1).max(60).optional(),hidden:c.boolean().optional(),style:ce.optional(),fallback:_.optional()},Ei=c.object({...F,type:c.literal("text"),productField:c.enum(["name","price","trial","period"]).optional(),feature:c.object({id:c.uuid(),field:c.enum(["name","allowance"])}).strict().optional(),text:_,variant:c.enum(["title","heading","body","caption"])}).strict(),_i=c.object({...F,type:c.literal("image"),src:At,localizedSrc:c.record(he,At).optional(),alt:_,aspect:c.enum(["auto","1:1","4:3","16:9","3:1"]),fit:c.enum(["cover","contain"]),position:qn.optional()}).strict(),wi=c.object({...F,type:c.literal("button"),label:_,variant:c.enum(["primary","secondary","link"]),action:_,purpose:c.enum(["purchase","navigation","close"]).optional(),bind:$e.optional()}).strict(),Oi=c.object({...F,type:c.literal("divider")}).strict(),vi=c.object({...F,type:c.literal("customer_data"),title:_,data:wn}).strict(),Ri=c.object({...F,type:c.literal("spacer"),size:gi}).strict(),Ni=c.object({...F,type:c.literal("custom_html"),html:c.record(he,c.string().max(Q.customHtml)),css:c.string().max(Q.customCss),ui:$n.optional()}).strict(),Ci=c.object({...F,type:c.literal("price"),fallback:_,parts:c.object({current:ce.optional(),original:ce.optional(),period:ce.optional()}).strict().optional()}).strict(),Ti=c.object({...F,type:c.literal("coupon_code"),label:_,fallback:_}).strict(),ji=c.object({...F,type:c.literal("countdown"),source:c.enum(["offer.ends_at","offer.expires_at","fixed"]),at:c.iso.datetime().optional(),granularity:c.enum(["day","hour","minute","second"]),expired:_,fallback:_}).strict().refine(e=>e.source!=="fixed"||!!e.at,"\u56FA\u5B9A\u5012\u8BA1\u65F6\u9700\u8981\u7ED3\u675F\u65F6\u95F4"),Pi=c.object({...F,type:c.literal("plan_picker"),label:_,fallback:_,planIds:c.array(c.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:c.string().min(1).max(200).optional(),grouping:Pn.safeExtend({monthLabel:_,yearLabel:_,unavailableLabel:_}).optional(),states:c.object({selected:ce.optional()}).strict().optional()}).strict().superRefine((e,t)=>{e.grouping&&(!e.planIds||!Dn(e.grouping,e.planIds))&&t.addIssue({code:"custom",message:"Grouped picker assignments must match its product allowlist"})}),Di=c.object({...F,type:c.literal("quantity_picker"),bind:$e.optional(),label:_,fallback:_,internalFeatureId:c.uuid(),minimumQuantity:I(0,1e4),maximumQuantity:I(0,1e4),defaultQuantity:I(0,1e4),step:I(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"),Li=c.discriminatedUnion("type",[c.object({type:c.literal("input"),label:_,keyboard:c.enum(["text","email","tel","url"]),maxLength:I(1,500)}).strict(),c.object({type:c.literal("multiselect"),label:_,min:I(0,50),max:I(1,50)}).strict(),c.object({type:c.literal("select"),label:_,defaultIndex:I(0,49),purpose:c.enum(["option","product","tier"]).optional(),pickerId:Ie.optional(),selectedStyle:ce.optional()}).strict(),c.object({type:c.literal("tabs"),label:_,defaultIndex:I(0,49),purpose:c.literal("tier").optional()}).strict(),c.object({type:c.literal("toggle"),label:_,defaultEnabled:c.boolean()}).strict(),c.object({type:c.literal("carousel"),label:_}).strict()]),G={...F,type:c.literal("stack"),direction:c.enum(["vertical","horizontal","overlay"]),align:c.enum(["start","center","end","stretch"]),justify:c.enum(["start","center","end","between"]),productSlot:c.object({index:I(0,19),period:c.enum(["month","year"]).optional(),requireBinding:c.boolean().optional()}).strict().optional(),interaction:Li.optional(),states:c.object({selected:ce.optional()}).strict().optional(),purpose:c.literal("benefits").optional(),purchaseAction:_.optional(),buttonVariant:c.enum(["primary","secondary","link"]).optional(),bind:$e.optional()},Hn=c.lazy(()=>c.object({...F,type:G.type,direction:G.direction,align:G.align,justify:G.justify,children:c.array(Ui).max(Q.children),productSlot:G.productSlot,interaction:G.interaction,states:G.states,purpose:G.purpose,purchaseAction:G.purchaseAction,buttonVariant:G.buttonVariant,bind:G.bind}).strict()),Ui=c.lazy(()=>c.union([Hn,Ei,_i,wi,Oi,Ri,Ni,Ci,Ti,ji,Pi,Di,vi])),$i=c.union([c.string().max(500),c.number().finite(),c.boolean(),c.null()]),Ae={id:_,event:_,properties:c.record(_,$i).refine(e=>Object.keys(e).length<=20,"\u6700\u591A 20 \u4E2A\u53C2\u6570")},zi=c.discriminatedUnion("type",[c.object({...Ae,type:c.literal("navigate"),close:c.literal(!1),pageId:Ie}).strict(),c.object({...Ae,type:c.literal("event"),close:c.boolean()}).strict(),c.object({...Ae,type:c.literal("close"),close:c.literal(!0)}).strict(),c.object({...Ae,type:c.literal("open_url"),close:c.boolean(),url:It}).strict(),c.object({...Ae,type:c.literal("claim_offer"),close:c.boolean(),couponId:c.uuid()}).strict()]),Fi=c.object({defaultLocale:he,locales:c.record(he,c.record(_,c.string().max(Q.stringLength)))}).strict(),Vi=c.enum(["popup","paywall","onboarding","page","banner"]);var Bi=c.object({kind:c.literal("screen"),schemaVersion:c.literal(mi),name:c.string().trim().min(1).max(80),surface:Vi,initialPageId:Ie.optional(),presentation:Rn,theme:Bn,pages:c.array(c.object({id:Ie,name:c.string().trim().min(1).max(60),root:Hn,theme:Bn.optional(),editorPosition:c.object({x:c.number().finite().min(-1e5).max(1e5),y:c.number().finite().min(-1e5).max(1e5)}).strict().optional()}).strict()).min(1).max(Q.pages),strings:Fi,actions:c.array(zi).max(Q.actions)}).strict();function W(e,t){for(let n of e.pages)Et(n.root,t)}var ds=Bi.superRefine((e,t)=>{let n=Q;e.surface!=="paywall"&&e.pages.length!==1&&t.addIssue({code:"custom",message:"Only a Paywall can contain multiple screens"}),e.initialPageId&&!e.pages.some(d=>d.id===e.initialPageId)&&t.addIssue({code:"custom",message:"Initial screen does not exist"});for(let d of e.actions)d.type==="navigate"&&(e.surface!=="paywall"||!e.pages.some(g=>g.id===d.pageId))&&t.addIssue({code:"custom",message:"Navigation screen does not exist"});e.pages.length>n.pages&&t.addIssue({code:"custom",message:`\u9875\u9762\u6700\u591A ${n.pages} \u4E2A`}),e.actions.length>n.actions&&t.addIssue({code:"custom",message:`\u52A8\u4F5C\u6700\u591A ${n.actions} \u4E2A`});let r=d=>t.addIssue({code:"custom",message:d}),i=Object.keys(e.strings.locales);i.includes(e.strings.defaultLocale)||r("\u9ED8\u8BA4\u8BED\u8A00\u5FC5\u987B\u5728\u8BED\u8A00\u5217\u8868\u91CC"),i.length>Q.locales&&r(`\u6700\u591A ${Q.locales} \u79CD\u8BED\u8A00`);let o=new Set;for(let d of e.actions)o.has(d.id)&&r(`\u52A8\u4F5C\u6807\u8BC6\u91CD\u590D\uFF1A${d.id}`),o.add(d.id);let a=new Set;for(let d of e.pages)["next","back"].includes(d.id)&&r(`\u9875\u9762 id \u4E0D\u80FD\u4F7F\u7528\u4FDD\u7559\u540D\u79F0\uFF1A${d.id}`),a.has(d.id)&&r(`\u9875\u9762 id \u91CD\u590D\uFF1A${d.id}`),a.add(d.id);let s=new Set,u=0,f=!1;W(e,(d,g)=>{if(u++,g>Q.depth&&(f=!0),s.has(d.id)&&r(`\u7EC4\u4EF6 id \u91CD\u590D\uFF1A${d.id}`),s.add(d.id),d.type==="button"&&!o.has(d.action)&&r(`\u6309\u94AE ${d.id} \u5F15\u7528\u7684\u52A8\u4F5C\u4E0D\u5B58\u5728\uFF1A${d.action}`),d.type==="custom_html")for(let A of Object.keys(d.html))i.includes(A)||r(`\u81EA\u5B9A\u4E49 HTML ${d.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${A}`);if(d.type==="image")for(let A of Object.keys(d.localizedSrc??{}))i.includes(A)||r(`\u56FE\u7247 ${d.id} \u542B\u6709\u672A\u542F\u7528\u7684\u8BED\u8A00\uFF1A${A}`)}),u>n.nodes&&r(`\u7EC4\u4EF6\u6700\u591A ${n.nodes} \u4E2A`),f&&r(`\u5C42\u7EA7\u6700\u591A ${Q.depth} \u5C42`)});function Et(e,t,n=1,r=null){if(t(e,n,r)!==!1&&e.type==="stack")for(let i of e.children)Et(i,t,n+1,e)}function Gn(e){let t=[],n=new Set;return W(e,r=>{let i=(o,a,s)=>{n.has(o)||(n.add(o),t.push({key:o,nodeId:r.id,nodeType:r.type,field:a,required:s}))};r.type==="stack"&&r.interaction&&i(r.interaction.label,"label",!0),r.fallback&&i(r.fallback,"text",!0),r.type==="text"&&i(r.text,"text",!0),r.type==="customer_data"&&i(r.title,"title",!0),(r.type==="plan_picker"||r.type==="quantity_picker"||r.type==="coupon_code")&&i(r.label,"label",!0),r.type==="plan_picker"&&r.grouping&&(i(r.grouping.monthLabel,"label",!0),i(r.grouping.yearLabel,"label",!0),i(r.grouping.unavailableLabel,"text",!0)),r.type==="countdown"&&i(r.expired,"text",!0),r.type==="button"&&i(r.label,"label",!0),r.type==="image"&&(i(`image:${r.id}`,"src",!1),i(r.alt,"alt",!1)),r.type==="custom_html"&&i(`html:${r.id}`,"html",!0)}),t}function Mi(e,t,n){if(t.field==="html"){let r;return W(e,i=>{i.id===t.nodeId&&i.type==="custom_html"&&(r=i.html[n])}),r}if(t.field==="src"){let r=_t(e,t.nodeId);return r?.type==="image"?r.localizedSrc?.[n]??(n===e.strings.defaultLocale?r.src:void 0):void 0}return e.strings.locales[n]?.[t.key]}function qi(e){let t=Gn(e).filter(r=>r.required);return Object.keys(e.strings.locales).sort((r,i)=>r===e.strings.defaultLocale?-1:i===e.strings.defaultLocale?1:0).map(r=>{let i=t.filter(o=>!Mi(e,o,r)?.trim()).map(o=>o.key);return{locale:r,total:t.length,filled:t.length-i.length,missing:i,complete:i.length===0}})}function Hi(e){return qi(e).filter(t=>t.complete||t.locale===e.strings.defaultLocale).map(t=>t.locale)}function fs(e,t){return Vn(t,Hi(e),e.strings.defaultLocale)}function ms(e,t){let n=e.strings.locales[t]??{},r=e.strings.locales[e.strings.defaultLocale]??{},i={};for(let a of Gn(e)){if(a.field==="html"||a.field==="src")continue;let s=n[a.key]?.trim()?n[a.key]:r[a.key];s!==void 0&&(i[a.key]=s)}let o=a=>{if(a.type==="stack")return{...a,children:a.children.map(o)};if(a.type==="custom_html"){let s=a.html[t]?.trim()?a.html[t]:a.html[e.strings.defaultLocale];return{...a,html:s===void 0?{}:{[t]:s}}}if(a.type==="image"){let{localizedSrc:s,...u}=a;return{...u,src:s?.[t]??s?.[e.strings.defaultLocale]??a.src}}return a};return{...e,pages:e.pages.map(a=>({...a,root:o(a.root)})),strings:{defaultLocale:t,locales:{[t]:i}}}}function Gi(e,t){let n=null;return Et(e,r=>{if(n)return!1;r.id===t&&(n=r)}),n}function _t(e,t){for(let n of e.pages){let r=Gi(n.root,t);if(r)return r}return null}function gs(e){let t=St(e)?.split("-")[0];return t!==void 0&&["ar","he","fa","ur"].includes(t)}function bs(e,t,n){let r={};if(!t||typeof t!="object"||Array.isArray(t))return r;let i=t;if(W(e,o=>{if(o.type==="quantity_picker"){let s=i[o.id];typeof s=="number"&&Number.isSafeInteger(s)&&s>=o.minimumQuantity&&s<=o.maximumQuantity&&(s-o.minimumQuantity)%o.step===0&&(r[o.id]=s);return}if(o.type==="plan_picker"){let s=i[o.id];typeof s=="string"&&(r[o.id]=n?.pickers[o.id]?.options.includes(s)?s:"");return}if(o.type==="custom_html"&&o.ui)for(let[s,u]of Object.entries(o.ui.state??{})){let f=`${o.id}.${s}`,d=i[f];d!==null&&ze(u,d)&&(r[f]=d)}if(o.type!=="stack"||!o.interaction)return;let a=Object.hasOwn(i,o.id)?i[o.id]:void 0;["select","tabs"].includes(o.interaction.type)&&typeof a=="string"&&o.children.some(s=>s.id===a)&&(r[o.id]=a),o.interaction.type==="toggle"&&typeof a=="boolean"&&(r[o.id]=a)}),e.surface==="paywall"&&typeof i.__page=="string"&&e.pages.some(o=>o.id===i.__page)&&(r.__page=i.__page),n){let o={...r};for(let[a,s]of Object.entries(i))(typeof s=="string"||typeof s=="boolean")&&(o[a]=s);Object.assign(r,Tn(e,o,n))}return r}import{z as C}from"zod";import{z as p}from"zod";import{z as h}from"zod";var ue=N.refine(e=>/[1-9]/.test(e),"Quantity must be positive"),_e=h.string().min(1).max(120),Fe=h.enum(["cap","overflow"]),V=(e,t)=>{let[n,r=""]=e.split(".");if(n===void 0||n==="")throw new Error("Invalid decimal value");return BigInt(n)*10n**BigInt(t)+BigInt(r.padEnd(t,"0"))},we=e=>{try{return e()}catch{return!1}},ks=h.discriminatedUnion("operation",[h.object({operation:h.literal("quote"),overageBehavior:Fe.optional(),internal_feature_id:h.uuid(),entityId:h.uuid().optional(),quantity:ue,properties:q}).strict(),h.object({operation:h.literal("consume"),overageBehavior:Fe.optional(),occurredAt:h.iso.datetime({offset:!0}).optional(),internal_feature_id:h.uuid(),entityId:h.uuid().optional(),quantity:N,properties:q,idempotencyKey:_e}).strict(),h.object({operation:h.literal("reserve"),occurredAt:h.iso.datetime({offset:!0}).optional(),internal_feature_id:h.uuid(),entityId:h.uuid().optional(),quantity:ue,properties:q,idempotencyKey:_e,expiresInSeconds:h.number().int().min(1).max(86400)}).strict(),h.object({operation:h.literal("confirm"),operationId:h.uuid(),quantity:ue,properties:q.optional(),idempotencyKey:_e}).strict(),h.object({operation:h.literal("refund"),operationId:h.uuid(),quantity:ue,idempotencyKey:_e}).strict(),h.object({operation:h.literal("release"),operationId:h.uuid(),idempotencyKey:_e}).strict()]),Qi=h.object({internal_credit_feature_id:h.uuid().nullable(),internal_metered_feature_id:h.uuid(),dimension:h.string().min(1).max(64),counterKey:h.string().min(1).max(240),cycleStart:h.iso.datetime({offset:!0}),unitCost:N,units:ue,amount:Ue,tier:h.number().int().min(1).max(12).nullable()}).strict(),Oe=h.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/);function Qn(e,t){let n=e.reduce((r,i)=>r+V(i.units,12),0n)-V(t,12);return e.some(r=>r.funding==="balance")?n>=-100n&&n<=100n:n===0n}var Kn=h.discriminatedUnion("funding",[h.strictObject({funding:h.literal("balance"),sourceId:h.uuid(),rolloverId:h.uuid().nullable(),units:Oe.refine(e=>/[1-9]/.test(e)),amount:Ue}),h.strictObject({funding:h.literal("unbilled"),units:Oe.refine(e=>/[1-9]/.test(e))}),h.object({funding:h.literal("prepaid"),sourceId:h.uuid(),units:ue,amount:Ue,pricing:h.array(Qi).min(1).max(12)}).strict().refine(e=>we(()=>e.pricing.reduce((t,n)=>t+V(n.units,6),0n)===V(e.units,6)&&e.pricing.reduce((t,n)=>t+V(n.amount,12),0n)===V(e.amount,12)&&e.pricing.every(t=>V(t.unitCost,6)*V(t.units,6)===V(t.amount,12))),"Frozen pricing must conserve allocated units and amounts"),h.object({funding:h.literal("postpaid"),invoiceLineId:h.uuid().nullable(),units:ue,authorizationId:h.uuid()}).strict()]),Ve=h.enum(["unavailable","insufficient_balance","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded"]),As=h.object({allowed:h.boolean(),internal_feature_id:h.uuid(),quantity:N,requestedQuantity:N.optional(),overageBehavior:Fe.optional(),reason:Ve.nullable(),allocations:h.array(Kn).max(500)}).strict().refine(e=>we(()=>e.allowed?e.reason===null&&Qn(e.allocations,e.quantity):e.reason!==null&&e.allocations.length===0),"A quote must conserve its accepted units").refine(e=>we(()=>e.overageBehavior===void 0?e.requestedQuantity===void 0&&/[1-9]/.test(e.quantity):e.requestedQuantity!==void 0&&V(e.requestedQuantity,6)>=V(e.quantity,6)&&(e.overageBehavior==="cap"||e.requestedQuantity===e.quantity)),"Explicit overage behavior must retain the requested quantity"),Is=h.object({id:h.uuid(),internal_feature_id:h.uuid(),kind:h.enum(["consume","reserve","confirm","refund","release","expire"]),originalId:h.uuid().nullable(),quantity:N,requestedQuantity:N.optional(),overageBehavior:Fe.optional(),accepted:h.boolean(),reason:h.enum([...Ve.options,"expired"]).nullable(),createdAt:h.iso.datetime({offset:!0}),reservationStatus:h.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:h.iso.datetime({offset:!0}).nullable(),allocations:h.array(Kn).max(500)}).strict().refine(e=>we(()=>e.accepted?e.reason===null&&Qn(e.allocations,e.quantity):e.reason!==null&&e.allocations.length===0),"An operation must conserve its requested units").refine(e=>we(()=>e.overageBehavior===void 0?e.requestedQuantity===void 0:e.kind==="consume"&&e.requestedQuantity!==void 0&&V(e.requestedQuantity,6)>=V(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 K}from"zod";var Ki=K.string().max(40).regex(/^(0|[1-9]\d*)(\.\d{1,12})?$/),Zi=K.string().max(41).regex(/^-?(0|[1-9]\d*)(\.\d{1,12})?$/),Zn=K.strictObject({internal_feature_id:K.uuid(),entityId:K.uuid().nullable()}),Os=Zn.extend({quantity:N,expectedRevision:K.number().int().min(0).max(Number.MAX_SAFE_INTEGER),idempotencyKey:K.string().min(1).max(120),properties:q.refine(e=>Object.keys(e).length<=13&&!Object.keys(e).some(t=>t.startsWith("usage_")),"Usage accounting reserves three properties")}).strict(),Wn=Zn.extend({operationId:K.uuid().nullable(),usage:N,capacity:Ki.nullable(),remaining:Zi.nullable(),withinLimit:K.boolean(),revision:K.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:K.iso.datetime({offset:!0}).nullable()}).strict().superRefine((e,t)=>{let n=r=>{let i=r.startsWith("-"),[o,a=""]=(i?r.slice(1):r).split(".");if(o===void 0||o==="")throw new Error("Invalid decimal value");return(i?-1n:1n)*(BigInt(o)*10n**12n+BigInt(a.padEnd(12,"0")))};(e.capacity===null!=(e.remaining===null)||(e.capacity===null?!e.withinLimit:e.remaining===null||n(e.remaining)!==n(e.capacity)-n(e.usage)||e.withinLimit!==n(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 J=p.string().regex(/^(0|[1-9]\d{0,17})(\.\d{1,12})?$/),Z=p.iso.datetime({offset:!0}),Wi=p.enum(["access","metered","credit"]),ve={internal_feature_id:p.uuid(),key:oe,name:p.string().min(1).max(120),kind:Wi},Ps=p.object({customerId:p.uuid(),snapshotAt:Z,memberships:p.array(p.object({id:p.uuid(),productId:p.string().min(1).max(255),productVersionId:p.uuid(),billingProductVersionId:p.uuid(),version:p.number().int().positive(),key:p.string().min(1).max(64),name:p.string().min(1).max(120),groupId:p.string().max(255).nullable(),membershipType:p.enum(["main","addon"]),status:p.enum(["trial","active","past_due","ended","expired","trialing","paused","pending","scheduled","unknown"]),cancelAtPeriodEnd:p.boolean(),accessEnabled:p.boolean(),renewalChange:p.object({productVersionId:p.uuid(),name:p.string().min(1).max(120),version:p.number().int().positive(),effectiveAt:Z,benefitsAppliedAt:Z.nullable(),timing:p.enum(["immediate","renewal"]),changeKind:p.enum(["plan","seats","quantity"]),feature:p.strictObject({internal_feature_id:p.uuid(),name:p.string().min(1).max(80),fromQuantity:p.number().int().min(0).max(1e4),toQuantity:p.number().int().min(0).max(1e4)}).optional(),seat:p.object({key:p.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),fromQuantity:p.number().int().min(0).max(1e4),toQuantity:p.number().int().min(0).max(1e4)}).strict().nullable(),status:p.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:p.object({phase:p.enum(["paid","trial"]),startsAt:Z,endsAt:Z.nullable()}).strict().nullable()}).strict()).max(100),membershipsLimited:p.boolean(),balances:p.array(p.object({...ve,usageType:p.enum(["consumable","non_consumable"]).nullable(),accessible:p.boolean(),unlimited:p.boolean(),available:J,held:J,debt:J,nextExpiresAt:Z.nullable(),usage:Wn.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:p.boolean()}).strict(),Jn=p.enum(["source","usage","transaction","invoice","debt","settlement"]),Be=p.object({at:Z,id:p.uuid(),type:Jn}).strict(),Ds=p.object({type:Jn.nullable(),resourceKey:oe.optional(),kind:p.enum(["purchase","refund"]).optional(),topup:p.boolean().optional(),from:p.iso.date().nullable(),to:p.iso.date().nullable(),after:Be.nullable(),limit:p.number().int().min(1).max(50)}).strict().refine(e=>!e.from||!e.to||e.from<=e.to,"Date range is reversed"),ye={id:p.uuid(),occurredAt:Z},Ji=p.discriminatedUnion("type",[p.strictObject({...ye,type:p.literal("invoice"),status:p.string().min(1).max(80),paid:J,refunded:J,currency:$,externalId:p.string().nullable()}),p.object({...ye,...ve,type:p.literal("source"),reason:p.enum(["membership","trial","topup","manual","rollover","upgrade_carry","seat"]),quantity:J,unlimited:p.boolean(),status:p.enum(["scheduled","active","expired","revoked","unavailable"]),startsAt:Z,expiresAt:Z.nullable(),orderId:p.uuid().nullable(),parentSourceId:p.uuid().nullable()}).strict(),p.object({...ye,type:p.literal("usage"),internal_feature_id:p.uuid(),name:p.string().min(1).max(120),kind:p.enum(["consume","set_usage","reserve","confirm","refund","release","expire"]),originalId:p.uuid().nullable(),quantity:N,accepted:p.boolean(),reason:p.enum([...Ve.options,"expired"]).nullable(),properties:q,reservationStatus:p.enum(["pending","confirmed","released","expired"]).nullable(),expiresAt:Z.nullable(),charges:p.array(p.discriminatedUnion("funding",[p.strictObject({funding:p.literal("balance"),sourceId:p.uuid(),rolloverId:p.uuid().nullable(),units:Oe,amount:J}),p.strictObject({funding:p.literal("unbilled"),units:Oe}),p.object({...ve,funding:p.literal("prepaid"),amount:J}).strict(),p.object({funding:p.literal("postpaid"),invoiceId:p.uuid(),invoiceLineId:p.uuid(),authorizationId:p.uuid(),units:N,currency:$}).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"),p.object({...ye,type:p.literal("transaction"),purpose:p.enum(["product","invoice"]),productVersionId:p.uuid().nullable(),productName:p.string().min(1).max(120).nullable(),productVersion:p.number().int().positive().nullable(),invoiceId:p.uuid().nullable(),orderId:p.uuid(),originalId:p.uuid().nullable(),kind:p.enum(["purchase","refund"]),amountMinor:p.number().int().nonnegative().max(2e8).nullable(),currency:$.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"),p.object({...ye,...ve,type:p.literal("debt"),sourceId:p.uuid(),transactionId:p.uuid(),amount:J}).strict(),p.object({...ye,...ve,type:p.literal("settlement"),sourceId:p.uuid(),debtId:p.uuid(),kind:p.enum(["payment","usage_refund","payment_return"]),amount:J}).strict()]),Ls=p.object({customerId:p.uuid(),rows:p.array(Ji).max(50),nextCursor:Be.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 Vs=C.discriminatedUnion("kind",[C.object({kind:C.literal("ledger"),cursor:Be}).strict(),C.object({kind:C.literal("billing"),cursor:C.uuid()}).strict()]),Yi=C.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/),Xi=C.record(C.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),C.union([C.string().max(500),C.boolean(),C.array(C.string().max(500)).max(50)])).refine(e=>Object.keys(e).length<=40,"Too many answers"),eo=/^(?:api_?key|authorization|password|(?:customer|run|visitor|access|purchase)_?token|client_?secret|signed_?transaction|raw_?proof)$/i;function wt(e,t=0){return t>20?!0:!!e&&typeof e=="object"&&(Array.isArray(e)?e.some(n=>wt(n,t+1)):Object.entries(e).some(([n,r])=>["__proto__","constructor","prototype"].includes(n)||eo.test(n)||wt(r,t+1)))}var to=/gg_(?:sk|ct|fr|fv|gc)_[A-Za-z0-9_-]{20,}/,Bs=C.record(Yi,ne).refine(e=>Object.keys(e).length<=20,"Too many parameters").refine(e=>!wt(e)&&!to.test(JSON.stringify(e)),"Credentials cannot be screen parameters");var Yn=C.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),no=C.array(C.object({variable:Yn,componentId:Yn,required:C.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"),Ms=C.object({bindings:no,answers:Xi,values:C.record(C.string(),ne).optional()}).strict();function Xn(e,t,n=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",i={zh:["/\u6708","/\u5E74"],en:["/month","/year"],ja:["/\u6708","/\u5E74"],ko:["/\uC6D4","/\uB144"],es:["/mes","/a\xF1o"],fr:["/mois","/an"],de:["/Monat","/Jahr"],pt:["/m\xEAs","/ano"],it:["/mese","/anno"],ar:["/\u0634\u0647\u0631","/\u0633\u0646\u0629"]},o={zh:"\u5468",en:"week",ja:"\u9031",ko:"\uC8FC",es:"semana",fr:"semaine",de:"Woche",pt:"semana",it:"settimana",ar:"\u0623\u0633\u0628\u0648\u0639"},a=e==="week"?`/${o[r]??o.en}`:(i[r]??i.en)[e==="month"?0:1];return n===1?a:`/${n} ${a.slice(1)}${r==="en"?"s":""}`}function Js(e,t){let n=[],r={};W(e,i=>{if(i.hidden)return!1;if(i.type!=="quantity_picker")return;let o=i.bind?.plan?[i.bind.plan]:[];i.bind?.picker&&W(e,a=>{if(a.type==="plan_picker"&&a.id===i.bind?.picker&&o.push(...a.planIds??[]),a.type==="stack"&&a.interaction?.type==="select"&&a.interaction.pickerId===i.bind?.picker)for(let s of a.children)s.type==="stack"&&s.bind?.plan&&o.push(s.bind.plan)}),o.length||n.push(`Quantity control ${i.id} needs a Product binding`);for(let a of new Set(o)){let s=t[a]?.prepaid?.find(f=>f.internalFeatureId===i.internalFeatureId)?.terms,u=r[a]??=new Set;(!s||u.has(i.internalFeatureId)||i.minimumQuantity<s.minimumQuantity||i.maximumQuantity>s.maximumQuantity)&&n.push(`Quantity control ${i.id} must match its Product's prepaid Feature and bounds`),u.add(i.internalFeatureId)}});for(let[i,o]of Object.entries(t))for(let a of o.prepaid??[])r[i]?.has(a.internalFeatureId)||n.push(`Product ${i} needs a quantity control for ${a.internalFeatureId}`);return n}function Ys(e,t,n,r){let i=r.plans[t];if(!i?.available)throw new Error("Selected Product is unavailable");let o={};if(W(e,a=>{if(a.hidden)return!1;if(a.type!=="quantity_picker"||a.hidden||(a.bind?.plan??(a.bind?.picker?n[a.bind.picker]:void 0))!==t)return;let u=i.prepaid?.find(d=>d.internalFeatureId===a.internalFeatureId)?.terms,f=n[a.id];if(!u||typeof f!="number"||!Number.isSafeInteger(f)||f<Math.max(u.minimumQuantity,a.minimumQuantity)||f>Math.min(u.maximumQuantity,a.maximumQuantity)||(f-a.minimumQuantity)%a.step!==0||o[a.internalFeatureId]!==void 0)throw new Error("Choose a valid quantity for each prepaid Feature");o[a.internalFeatureId]=f}),(i.prepaid??[]).some(a=>o[a.internalFeatureId]===void 0))throw new Error("Choose a quantity for each prepaid Feature");return o}function ro(e,t,n){let r=e.terms.prices.find(i=>i.currency===t);if(!r||n<e.terms.minimumQuantity||n>e.terms.maximumQuantity)throw new Error("Quantity or currency is unavailable");return{amountMinor:xn({quantity:n,unitAmountMinor:r.amountMinor,...r.pricing?{pricing:r.pricing}:{}}),allowance:An(e.includedAmount,e.terms.units,n)}}function Xs(e,t,n,r){let i=!1;if(W(e,s=>{s.type==="quantity_picker"&&(i=!0)}),!i)return t;let o=structuredClone(t);o.quantities={};let a=new Map;W(e,s=>{if(s.hidden)return!1;if(s.type!=="quantity_picker")return;let u=s.bind?.plan??(s.bind?.picker?n[s.bind.picker]??o.pickers[s.bind.picker]?.selected:void 0),f=typeof u=="string"?o.plans[u]:void 0,d=f?.prepaid?.find(re=>re.internalFeatureId===s.internalFeatureId),g=Math.max(s.minimumQuantity,d?.terms.minimumQuantity??0),A=Math.min(s.maximumQuantity,d?.terms.maximumQuantity??0),y=n[s.id]??s.defaultQuantity,b=typeof y=="number"&&Number.isSafeInteger(y)?y:s.defaultQuantity,k=!!d&&!!f?.available&&b>=g&&b<=A&&(b-s.minimumQuantity)%s.step===0,w=o.quantities[s.id]={minimum:g,maximum:Math.max(g,A),step:s.step,value:b,label:"",available:k};if(!k||!d||!f?.currency||f.amountMinor===void 0)return;let U=ro(d,f.currency,b);w.label=`${new Intl.NumberFormat(r).format(Number(U.allowance))} ${d.name}${["week","month","year"].includes(d.reset)?Xn(d.reset,r,d.resetCount):d.reset==="lifetime"?"":` / ${d.resetCount} ${d.reset}`}`,a.set(String(u),(a.get(String(u))??f.amountMinor)+U.amountMinor)});for(let[s,u]of a){let f=o.plans[s];if(!f?.currency)continue;let d=He(u,f.currency,r);f.price=d;for(let[g,A]of Object.entries(o.nodes)){let y=_t(e,g),b=k=>{if(k.price&&(k.price={...k.price,current:d,original:null}),y?.type==="text"){let w=e.strings.locales[r]?.[y.text]??e.strings.locales[e.strings.defaultLocale]?.[y.text];w?.includes("{{plan.price")&&(k.text=w.replace(/\{\{\s*plan.price\s*\}\}/g,d).replace(/\{\{\s*plan.price_per_month\s*\}\}/g,He(Math.round(u/((f.interval==="year"?12:1)*(f.intervalCount??1))),f.currency,r)))}};A.byPlan?.[s]&&b(A.byPlan[s]),(A.base.planVersionId===s||y&&"bind"in y&&y.bind?.plan===s)&&b(A.base)}}return o}import{z as P}from"zod";var Me=P.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"]),rc=P.enum([...Me.options,"INVALID_SERVER_RESPONSE","RESPONSE_TOO_LARGE","AMBIGUOUS_AUTHENTICATION","BROWSER_REQUIRED","INVALID_REDIRECT_URI","AUTHORIZATION_UNAVAILABLE","UNREGISTERED_CLIENT","MANAGEMENT_OPERATION_FAILED"]),ic=P.enum([...Me.options,"stale_revision"]),io=P.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"]),oo=P.enum(["CAPABILITY_NOT_ENABLED","INTEGRATION_MISSING","PROVIDER_CREDENTIAL_REJECTED","PRICE_BINDING_REQUIRED","IDEMPOTENCY_CONFLICT","RESULT_UNKNOWN","STATE_CHANGED","IDENTITY_CONTEXT_CHANGED","CUSTOMER_BINDING_CONFLICT","RUN_CONTRACT_MISMATCH","OPERATION_IN_PROGRESS","FUNNEL_VERSION_RETIRED"]),tr={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 er={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 ao(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(er,e)){let r=er[e];return{retryable:r==="retry_same_request",recovery:r}}let n=Me.safeParse(e);return n.success?{retryable:e==="RATE_LIMITED"||e==="SERVICE_UNAVAILABLE",recovery:tr[n.data].recovery}:{retryable:!1,recovery:"contact_support"}}function oc(e,t){let n=Me.safeParse(e);if(n.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):tr[n.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 so(e,t=Date.now()){if(e===null)return;let n=e.trim();if(/^\d+$/.test(n)){let i=Number(n);return Number.isSafeInteger(i)?i:void 0}if(!/^[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/.test(n))return;let r=Date.parse(n);return Number.isFinite(r)?Math.max(0,Math.ceil((r-t)/1e3)):void 0}var nr=P.object({retryable:P.boolean(),recovery:io,reason:oo.optional(),retryAfterSeconds:P.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()}),co=P.object({requestId:P.uuid().optional(),error:P.object({code:P.string().regex(/^[A-Z][A-Z0-9_]{0,95}$/),message:P.string(),...nr.partial().shape})}),ac=P.object({error:co.shape.error.extend({requestId:P.uuid().optional()})}),sc=P.object({error:P.string(),code:P.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,95}$/),requestId:P.uuid(),...nr.shape});function cc(e,t,n={}){let r=ao(e,t),i=n.reason==="RESULT_UNKNOWN"?"recover_operation":n.recovery??r.recovery,o=r.retryable&&n.retryable!==!1&&i!=="recover_operation",a=o?so(n.retryAfter??null):void 0;return{...r,retryable:o,recovery:i,...a===void 0?{}:{retryAfterSeconds:a},...n.reason?{reason:n.reason}:{}}}export{Me as a,io as b,oo as c,oc as d,co as e,cc as f,$ as g,or as h,He as i,Ue as j,N as k,Fr as l,q as m,mt as n,xn as o,kn as p,An as q,le as r,Je as s,Pt as t,Ft as u,Zt as v,M as w,tn as x,nn as y,cn as z,ne as A,pt as B,Le as C,Nr as D,zr as E,he as F,St as G,ks as H,Qi as I,Oe as J,As as K,Is as L,Zn as M,Os as N,Wn as O,J as P,Ps as Q,Ds as R,Ls as S,bt as T,sa as U,gn as V,bn as W,xa as X,Gr as Y,hn as Z,In as _,La as $,En as aa,Ua as ba,Cn as ca,Pn as da,Dn as ea,Va as fa,Ba as ga,Ja as ha,Ha as ia,Rn as ja,ei as ka,Q as la,_ as ma,At as na,W as oa,ds as pa,Et as qa,Gn as ra,qi as sa,fs as ta,ms as ua,_t as va,gs as wa,bs as xa,Vs as ya,Xi as za,Bs as Aa,no as Ba,Ms as Ca,Xn as Da,Js as Ea,Ys as Fa,Xs as Ga};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ka as y}from"./chunk-PFHS7HK3.js";var v=767;function D(e,r,c=!1){return(e.type==="modal"||e.type==="sheet")&&e.mobile&&c&&r<=v?e.mobile:e.type}function G(e,r,c){let a=e.ownerDocument.defaultView,n=r.presentation,u;if((n.type==="modal"||n.type==="sheet")&&n.backdrop){let t=`lp-backdrop-${crypto.randomUUID()}`,p={none:"transparent",scrim:"#f2f2f2cc",dim:"#0006","strong-dim":"#000000bf",blur:"#0006"};e.dataset.indianaBackdrop=t,u=e.ownerDocument.createElement("style"),u.textContent=`dialog[data-indiana-backdrop="${t}"]::backdrop{background:${p[n.backdrop]};backdrop-filter:${n.backdrop==="blur"?"blur(16px)":"none"}}`,e.append(u)}let i=r.pages?.[0]?.root.style?.shape,S=i?.type==="pill"?"9999px":i?.type==="rect"?typeof i.radius=="number"?`${i.radius}px`:[i.radius.topLeft,i.radius.topRight,i.radius.bottomRight,i.radius.bottomLeft].map(t=>`${t}px`).join(" "):void 0,m=(n.type==="modal"||n.type==="sheet")&&(n.desktopWidth!==void 0||n.mobile!==void 0),o=n.type,l,f,d=!1,x=t=>{d||!Number.isFinite(t)||t<0||(f=t,o!=="fullscreen"&&o!=="inline"&&(e.style.height=`min(${Math.max(t,40)}px, calc(100dvh - ${o==="sheet"?0:32}px))`))},s=()=>{if(!d&&(o=l??D(n,a?.innerWidth??1024,a?.matchMedia?.("(pointer: coarse)").matches===!0),e.dataset.presentation=o,!(!m||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,o==="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"&&o==="sheet",p=n.desktopWidth,h=a?.innerWidth??1024;e.style.width=t?`${h}px`:p?`${Math.min(p.max,Math.max(h*p.viewport/100,p.min))}px`:`${y[n.size]}px`,e.style.maxWidth=`${Math.max(0,h-(o==="sheet"?0:32))}px`,e.style.maxHeight=o==="sheet"?"100dvh":"calc(100dvh - 32px)",e.style.margin=o==="sheet"?"auto auto 0":"auto",e.style.borderRadius=S??(o==="sheet"?"16px 16px 0 0":"24px"),e.style.height="",f!==void 0&&x(f)}c?.(o)}},b=m?[a?.matchMedia?.(`(max-width: ${v}px)`),a?.matchMedia?.("(pointer: coarse)")].filter(t=>t!==void 0):[];if(m){a?.addEventListener("resize",s);for(let t of b)t.addEventListener?t.addEventListener("change",s):t.addListener?.(s)}return s(),{responsive:m,get type(){return o},latch(){d||l!==void 0||(s(),l=o)},setContentHeight:x,destroy(){if(!d){d=!0,u?.remove(),delete e.dataset.indianaBackdrop,a?.removeEventListener("resize",s);for(let t of b)t.removeEventListener?t.removeEventListener("change",s):t.removeListener?.(s)}}}}function j(e,r,c=!1){let a=e.ownerDocument.defaultView;if(typeof e.animate!="function"||a?.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;let n=c?{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:c?"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 F(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",`background:radial-gradient(circle, ${r.background} 0 15px, color-mix(in srgb, ${r.text} 22%, ${r.background}) 15px 16px, transparent 16.5px)`,`color:${r.text}`,"font:400 20px/1 system-ui,sans-serif","cursor:pointer","touch-action:manipulation"].join(";")}export{D as a,G as b,j as c,F as d};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { S as StackNode } from './screen-
|
|
2
|
+
import { S as StackNode } from './screen-DRP7nsrQ.js';
|
|
3
3
|
|
|
4
4
|
declare const configurationScopeSchema: z.ZodObject<{
|
|
5
5
|
projectId: z.ZodString;
|
|
@@ -432,9 +432,23 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
432
432
|
presentation: {
|
|
433
433
|
type: "modal";
|
|
434
434
|
size: "sm" | "md" | "lg";
|
|
435
|
+
desktopWidth?: {
|
|
436
|
+
min: number;
|
|
437
|
+
max: number;
|
|
438
|
+
viewport: number;
|
|
439
|
+
} | undefined;
|
|
440
|
+
mobile?: "sheet" | "fullscreen" | undefined;
|
|
441
|
+
backdrop?: "none" | "scrim" | "dim" | "strong-dim" | "blur" | undefined;
|
|
435
442
|
} | {
|
|
436
443
|
type: "sheet";
|
|
437
444
|
size: "sm" | "md" | "lg";
|
|
445
|
+
desktopWidth?: {
|
|
446
|
+
min: number;
|
|
447
|
+
max: number;
|
|
448
|
+
viewport: number;
|
|
449
|
+
} | undefined;
|
|
450
|
+
mobile?: "sheet" | "fullscreen" | undefined;
|
|
451
|
+
backdrop?: "none" | "scrim" | "dim" | "strong-dim" | "blur" | undefined;
|
|
438
452
|
} | {
|
|
439
453
|
type: "fullscreen";
|
|
440
454
|
} | {
|
|
@@ -737,13 +751,27 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
737
751
|
kind: "screen";
|
|
738
752
|
schemaVersion: 4;
|
|
739
753
|
name: string;
|
|
740
|
-
surface: "
|
|
754
|
+
surface: "popup" | "paywall" | "onboarding" | "page" | "banner";
|
|
741
755
|
presentation: {
|
|
742
756
|
type: "modal";
|
|
743
757
|
size: "sm" | "md" | "lg";
|
|
758
|
+
desktopWidth?: {
|
|
759
|
+
min: number;
|
|
760
|
+
max: number;
|
|
761
|
+
viewport: number;
|
|
762
|
+
} | undefined;
|
|
763
|
+
mobile?: "sheet" | "fullscreen" | undefined;
|
|
764
|
+
backdrop?: "none" | "scrim" | "dim" | "strong-dim" | "blur" | undefined;
|
|
744
765
|
} | {
|
|
745
766
|
type: "sheet";
|
|
746
767
|
size: "sm" | "md" | "lg";
|
|
768
|
+
desktopWidth?: {
|
|
769
|
+
min: number;
|
|
770
|
+
max: number;
|
|
771
|
+
viewport: number;
|
|
772
|
+
} | undefined;
|
|
773
|
+
mobile?: "sheet" | "fullscreen" | undefined;
|
|
774
|
+
backdrop?: "none" | "scrim" | "dim" | "strong-dim" | "blur" | undefined;
|
|
747
775
|
} | {
|
|
748
776
|
type: "fullscreen";
|
|
749
777
|
} | {
|
|
@@ -753,8 +781,16 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
753
781
|
primary: string;
|
|
754
782
|
background: string;
|
|
755
783
|
text: string;
|
|
756
|
-
radius: "
|
|
784
|
+
radius: "sm" | "md" | "lg" | "none" | "full";
|
|
757
785
|
font: "system" | "serif" | "rounded" | "mono";
|
|
786
|
+
fontAssets?: {
|
|
787
|
+
family: string;
|
|
788
|
+
faces: {
|
|
789
|
+
url: string;
|
|
790
|
+
weight: number;
|
|
791
|
+
family?: string | undefined;
|
|
792
|
+
}[];
|
|
793
|
+
} | undefined;
|
|
758
794
|
};
|
|
759
795
|
pages: {
|
|
760
796
|
id: string;
|
|
@@ -764,8 +800,16 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
764
800
|
primary: string;
|
|
765
801
|
background: string;
|
|
766
802
|
text: string;
|
|
767
|
-
radius: "
|
|
803
|
+
radius: "sm" | "md" | "lg" | "none" | "full";
|
|
768
804
|
font: "system" | "serif" | "rounded" | "mono";
|
|
805
|
+
fontAssets?: {
|
|
806
|
+
family: string;
|
|
807
|
+
faces: {
|
|
808
|
+
url: string;
|
|
809
|
+
weight: number;
|
|
810
|
+
family?: string | undefined;
|
|
811
|
+
}[];
|
|
812
|
+
} | undefined;
|
|
769
813
|
} | undefined;
|
|
770
814
|
editorPosition?: {
|
|
771
815
|
x: number;
|
|
@@ -820,10 +864,10 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
820
864
|
base: {
|
|
821
865
|
text?: string | undefined;
|
|
822
866
|
label?: string | undefined;
|
|
867
|
+
couponId?: string | undefined;
|
|
823
868
|
alt?: string | undefined;
|
|
824
869
|
html?: string | undefined;
|
|
825
870
|
countdownAt?: string | undefined;
|
|
826
|
-
couponId?: string | undefined;
|
|
827
871
|
missing?: string[] | undefined;
|
|
828
872
|
};
|
|
829
873
|
}>;
|
|
@@ -1159,9 +1203,23 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
1159
1203
|
presentation: {
|
|
1160
1204
|
type: "modal";
|
|
1161
1205
|
size: "sm" | "md" | "lg";
|
|
1206
|
+
desktopWidth?: {
|
|
1207
|
+
min: number;
|
|
1208
|
+
max: number;
|
|
1209
|
+
viewport: number;
|
|
1210
|
+
} | undefined;
|
|
1211
|
+
mobile?: "sheet" | "fullscreen" | undefined;
|
|
1212
|
+
backdrop?: "none" | "scrim" | "dim" | "strong-dim" | "blur" | undefined;
|
|
1162
1213
|
} | {
|
|
1163
1214
|
type: "sheet";
|
|
1164
1215
|
size: "sm" | "md" | "lg";
|
|
1216
|
+
desktopWidth?: {
|
|
1217
|
+
min: number;
|
|
1218
|
+
max: number;
|
|
1219
|
+
viewport: number;
|
|
1220
|
+
} | undefined;
|
|
1221
|
+
mobile?: "sheet" | "fullscreen" | undefined;
|
|
1222
|
+
backdrop?: "none" | "scrim" | "dim" | "strong-dim" | "blur" | undefined;
|
|
1165
1223
|
} | {
|
|
1166
1224
|
type: "fullscreen";
|
|
1167
1225
|
} | {
|
|
@@ -1171,13 +1229,27 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
1171
1229
|
kind: "screen";
|
|
1172
1230
|
schemaVersion: 4;
|
|
1173
1231
|
name: string;
|
|
1174
|
-
surface: "
|
|
1232
|
+
surface: "popup" | "paywall" | "onboarding" | "page" | "banner";
|
|
1175
1233
|
presentation: {
|
|
1176
1234
|
type: "modal";
|
|
1177
1235
|
size: "sm" | "md" | "lg";
|
|
1236
|
+
desktopWidth?: {
|
|
1237
|
+
min: number;
|
|
1238
|
+
max: number;
|
|
1239
|
+
viewport: number;
|
|
1240
|
+
} | undefined;
|
|
1241
|
+
mobile?: "sheet" | "fullscreen" | undefined;
|
|
1242
|
+
backdrop?: "none" | "scrim" | "dim" | "strong-dim" | "blur" | undefined;
|
|
1178
1243
|
} | {
|
|
1179
1244
|
type: "sheet";
|
|
1180
1245
|
size: "sm" | "md" | "lg";
|
|
1246
|
+
desktopWidth?: {
|
|
1247
|
+
min: number;
|
|
1248
|
+
max: number;
|
|
1249
|
+
viewport: number;
|
|
1250
|
+
} | undefined;
|
|
1251
|
+
mobile?: "sheet" | "fullscreen" | undefined;
|
|
1252
|
+
backdrop?: "none" | "scrim" | "dim" | "strong-dim" | "blur" | undefined;
|
|
1181
1253
|
} | {
|
|
1182
1254
|
type: "fullscreen";
|
|
1183
1255
|
} | {
|
|
@@ -1187,8 +1259,16 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
1187
1259
|
primary: string;
|
|
1188
1260
|
background: string;
|
|
1189
1261
|
text: string;
|
|
1190
|
-
radius: "
|
|
1262
|
+
radius: "sm" | "md" | "lg" | "none" | "full";
|
|
1191
1263
|
font: "system" | "serif" | "rounded" | "mono";
|
|
1264
|
+
fontAssets?: {
|
|
1265
|
+
family: string;
|
|
1266
|
+
faces: {
|
|
1267
|
+
url: string;
|
|
1268
|
+
weight: number;
|
|
1269
|
+
family?: string | undefined;
|
|
1270
|
+
}[];
|
|
1271
|
+
} | undefined;
|
|
1192
1272
|
};
|
|
1193
1273
|
pages: {
|
|
1194
1274
|
id: string;
|
|
@@ -1198,8 +1278,16 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
1198
1278
|
primary: string;
|
|
1199
1279
|
background: string;
|
|
1200
1280
|
text: string;
|
|
1201
|
-
radius: "
|
|
1281
|
+
radius: "sm" | "md" | "lg" | "none" | "full";
|
|
1202
1282
|
font: "system" | "serif" | "rounded" | "mono";
|
|
1283
|
+
fontAssets?: {
|
|
1284
|
+
family: string;
|
|
1285
|
+
faces: {
|
|
1286
|
+
url: string;
|
|
1287
|
+
weight: number;
|
|
1288
|
+
family?: string | undefined;
|
|
1289
|
+
}[];
|
|
1290
|
+
} | undefined;
|
|
1203
1291
|
} | undefined;
|
|
1204
1292
|
editorPosition?: {
|
|
1205
1293
|
x: number;
|
|
@@ -1631,7 +1719,7 @@ declare function createConfigurationSync(options: ConfigurationSyncOptions): {
|
|
|
1631
1719
|
entry: string;
|
|
1632
1720
|
nodes: {
|
|
1633
1721
|
id: string;
|
|
1634
|
-
type: "output" | "action" | "
|
|
1722
|
+
type: "output" | "action" | "screen" | "end" | "coupon" | "split" | "feature" | "condition" | "entry" | "offering" | "coupons" | "external_page" | "wait";
|
|
1635
1723
|
outputs: Record<string, string>;
|
|
1636
1724
|
writes: Record<string, string>;
|
|
1637
1725
|
resources: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as F,j as Q}from"./chunk-
|
|
1
|
+
import{f as F,j as Q}from"./chunk-ML6EHT43.js";import{b as B}from"./chunk-SSLZKIIU.js";import{c as z,d as _}from"./chunk-T5COWMDA.js";import"./chunk-APO7QUBB.js";import{a as d}from"./chunk-26HU2HXU.js";import{a as v}from"./chunk-DSPLGTQI.js";import{Q as M}from"./chunk-EFFXE6CX.js";import{A as V,Aa as N,Ba as q,ka as P,ta as U}from"./chunk-PFHS7HK3.js";import{z as p}from"zod";var x=new WeakMap;function W(r){let t={string:p.string(),number:p.number().finite(),boolean:p.boolean(),strings:p.array(p.string()),json:V}[r.type];return r.nullable?t.nullable():t}async function ie(r,t){return $(r,t,!1)}async function se(r,t){return $(r,t,!0)}async function $(r,t,w){t.signal?.throwIfAborted();let L=M.parse(t.content),o=L.document;if(x.has(r))throw new d("CONFLICT","Content is already mounted in this container");let f=p.record(p.string(),V).parse(t.inputs??{});if(Object.keys(f).length>40)throw new d("INVALID_REQUEST","Too many content inputs");for(let[e,s]of Object.entries(f))N.parse({[e]:s});if(Object.keys(f).some(e=>!Object.hasOwn(o.contract.inputs,e)))throw new d("INVALID_REQUEST","Undeclared content input");for(let[e,s]of Object.entries(o.contract.inputs))if(Object.hasOwn(f,e))W(s).parse(f[e]);else if(s.required)throw new d("INVALID_REQUEST",`Missing content input ${e}`);for(let e of Object.keys(o.contract.outputs))if(typeof t.actions[e]!="function")throw new d("INVALID_REQUEST",`Missing host handler for ${e}`);let J=q.parse(t.bindings??[]),c=r.ownerDocument,T,k=o.kind==="popup",n=k?c.createElement("dialog"):null,i=c.createElement("div");if(i.dataset.indianaContent=o.kind,i.setAttribute("aria-label",o.name),i.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",o.name);let e=o.screen.presentation;n.style.cssText="box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto",e.type==="modal"||e.type==="sheet"?(n.style.width=`${P[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",n.append(i),r.append(n)}else r.append(i);let l=!1,C=!1,g=!1;w&&!n&&(i.style.width=`${r.getBoundingClientRect().width||c.defaultView?.innerWidth||800}px`);let G=w?F(n??i):()=>{},D,A,S=new Promise((e,s)=>{D=e,A=s});S.catch(()=>{});let u=null,E=structuredClone(o.screen);E.actions=E.actions.map(e=>e.type==="event"?{...e,close:!1}:e);let y;function m(){l||(l=!0,t.signal?.removeEventListener("abort",m),A(new Error("Content preparation cancelled")),y?.destroy(),n?.close(),n?.remove(),i.remove(),x.delete(r),n&&T?.())}let O=()=>{g&&(m(),v(t.onDismiss))};if(n){let e=c.createElement("button");e.type="button",e.textContent="\xD7",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),_(e,o.screen.theme),e.addEventListener("click",O),n.prepend(e)}n?.addEventListener("cancel",e=>{e.preventDefault(),O()});async function H(){if(l||!g||C||!u)return;let e=u;C=!0,i.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),u=null}catch(s){v(t.onError,s)}finally{C=!1,l||i.removeAttribute("aria-busy")}}function R(){if(l)throw new d("CONFLICT","Content host has been destroyed");g||(T=B(c),G(),w&&!n&&(i.style.width="100%"),n&&(n.showModal(),z(n,o.screen.presentation.type)),g=!0)}try{w||R(),y=Q(i,{mode:"live",rendererUrl:t.rendererUrl,title:o.name,viewportHeight:o.kind==="page"?r.clientHeight||c.defaultView?.innerHeight||800:void 0,onRendered:a=>{a&&n?.setAttribute("aria-label",a),D()},onError:a=>{let I=new Error(a);A(I),v(t.onError,I)},onEscape:k?O:void 0,onAction:(a,I,K)=>{if(l||!g||C||u)return;let h=o.screen.actions.find(b=>b.id===a),j=o.contract.outputs[a];if(!(h?.type!=="event"||!j))try{let b=W(j).parse(Object.hasOwn(h.properties,"value")?h.properties.value:h.properties);u={requestId:crypto.randomUUID(),contentVersionId:L.id,actionId:a,event:h.event,value:b,selection:I??{},answers:K??{},requestedClose:h.close},H()}catch(b){v(t.onError,b)}}});let e={destroy:m,show:R,get pendingAction(){return u?structuredClone(u):null},retryAction:H,updateCapabilities:a=>y?.updateCapabilities(a)};x.set(r,e),t.signal?.addEventListener("abort",m,{once:!0}),t.signal?.aborted&&(m(),t.signal.throwIfAborted());let s=U(E,[t.locale,...c.defaultView?.navigator.languages??[]]);if(y.update(E,s,{capabilities:t.capabilities,serverInput:{bindings:J,answers:{},values:f}}),await Promise.race([y.ready,S]),w&&await S,l)throw new Error("Content preparation cancelled");return e}catch(e){throw m(),e}}export{ie as mountContent,se as prepareContent};
|