webstudio 0.282.1 → 0.283.0
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/README.md +5 -1
- package/lib/cli.js +193208 -158935
- package/lib/content-runtime.js +64 -0
- package/package.json +24 -19
- package/templates/cloudflare/package.json +1 -1
- package/templates/defaults/app/route-templates/html.tsx +10 -9
- package/templates/defaults/app/route-templates/text.tsx +10 -9
- package/templates/defaults/app/route-templates/xml.tsx +10 -9
- package/templates/defaults/package.json +8 -8
- package/templates/react-router/app/route-templates/html.tsx +10 -9
- package/templates/react-router/app/route-templates/text.tsx +10 -9
- package/templates/react-router/app/route-templates/xml.tsx +10 -9
- package/templates/react-router/package.json +8 -8
- package/templates/react-router-cloudflare/package.json +1 -1
- package/templates/ssg/app/asset-resource-fetch.ts +19 -0
- package/templates/ssg/app/route-templates/html/+data.ts +22 -9
- package/templates/ssg/package.json +6 -6
- package/templates/ssg/vite.config.ts +5 -2
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var Ji=Object.defineProperty;var Vi=(e,t)=>{for(var r in t)Ji(e,r,{get:t[r],enumerable:!0})};var sr;function l(e,t,r){function n(c,a){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:a,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,a);let u=i.prototype,f=Object.keys(u);for(let p=0;p<f.length;p++){let m=f[p];m in c||(c[m]=u[m].bind(c))}}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var a;let u=r?.Parent?new s:this;n(u,c),(a=u._zod).deferred??(a.deferred=[]);for(let f of u._zod.deferred)f();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>r?.Parent&&c instanceof r.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}var Nu=Symbol("zod_brand"),B=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},le=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(sr=globalThis).__zod_globalConfig??(sr.__zod_globalConfig={});var pe=globalThis.__zod_globalConfig;function Q(e){return e&&Object.assign(pe,e),pe}var b={};Vi(b,{BIGINT_FORMAT_RANGES:()=>lr,Class:()=>pt,NUMBER_FORMAT_RANGES:()=>gt,aborted:()=>H,allowsEval:()=>mt,assert:()=>Xi,assertEqual:()=>qi,assertIs:()=>Gi,assertNever:()=>Ki,assertNotEqual:()=>Wi,assignProp:()=>X,base64ToUint8Array:()=>dr,base64urlToUint8Array:()=>yc,cached:()=>fe,captureStackTrace:()=>Le,cleanEnum:()=>hc,cleanRegex:()=>$e,clone:()=>U,cloneDef:()=>ec,createTransparentProxy:()=>ic,defineLazy:()=>_,esc:()=>je,escapeRegex:()=>q,explicitlyAborted:()=>_t,extend:()=>uc,finalizeIssue:()=>L,floatSafeRemainder:()=>dt,getElementAtPath:()=>tc,getEnumValues:()=>ve,getLengthableOrigin:()=>ke,getParsedType:()=>sc,getSizableOrigin:()=>pr,hexToUint8Array:()=>_c,isObject:()=>oe,isPlainObject:()=>Y,issue:()=>me,joinValues:()=>Yi,jsonStringifyReplacer:()=>de,merge:()=>pc,mergeDefs:()=>V,normalizeParams:()=>h,nullish:()=>ze,numKeys:()=>oc,objectClone:()=>Hi,omit:()=>ac,optionalKeys:()=>yt,parsedType:()=>mc,partial:()=>dc,pick:()=>cc,prefixIssues:()=>W,primitiveTypes:()=>ar,promiseAllObject:()=>rc,propertyKeyTypes:()=>ht,randomString:()=>nc,required:()=>fc,safeExtend:()=>lc,shallowClone:()=>cr,slugify:()=>ft,stringifyPrimitive:()=>ur,uint8ArrayToBase64:()=>fr,uint8ArrayToBase64url:()=>gc,uint8ArrayToHex:()=>xc,unwrapMessage:()=>we});function qi(e){return e}function Wi(e){return e}function Gi(e){}function Ki(e){throw new Error("Unexpected value in exhaustive check")}function Xi(e){}function ve(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Yi(e,t="|"){return e.map(r=>ur(r)).join(t)}function de(e,t){return typeof t=="bigint"?t.toString():t}function fe(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function ze(e){return e==null}function $e(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function dt(e,t){let r=e/t,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var ir=Symbol("evaluating");function _(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==ir)return n===void 0&&(n=ir,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Hi(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function X(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function V(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function ec(e){return V(e._zod.def)}function tc(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function rc(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function nc(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function je(e){return JSON.stringify(e)}function ft(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Le="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function oe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var mt=fe(()=>{if(pe.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Y(e){if(oe(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(oe(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function cr(e){return Y(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function oc(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var sc=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},ht=new Set(["string","number","symbol"]),ar=new Set(["string","number","bigint","boolean","symbol","undefined"]);function q(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function U(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function h(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function ic(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function ur(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function yt(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var gt={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},lr={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function cc(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=V(e._zod.def,{get shape(){let i={};for(let c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(i[c]=r.shape[c])}return X(this,"shape",i),i},checks:[]});return U(e,s)}function ac(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=V(e._zod.def,{get shape(){let i={...e._zod.def.shape};for(let c in t){if(!(c in r.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete i[c]}return X(this,"shape",i),i},checks:[]});return U(e,s)}function uc(e,t){if(!Y(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let s=e._zod.def.shape;for(let i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=V(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return X(this,"shape",s),s}});return U(e,o)}function lc(e,t){if(!Y(t))throw new Error("Invalid input to safeExtend: expected a plain object");let r=V(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return X(this,"shape",n),n}});return U(e,r)}function pc(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=V(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return X(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return U(e,r)}function dc(e,t,r){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let i=V(t._zod.def,{get shape(){let c=t._zod.def.shape,a={...c};if(r)for(let u in r){if(!(u in c))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(a[u]=e?new e({type:"optional",innerType:c[u]}):c[u])}else for(let u in c)a[u]=e?new e({type:"optional",innerType:c[u]}):c[u];return X(this,"shape",a),a},checks:[]});return U(t,i)}function fc(e,t,r){let n=V(t._zod.def,{get shape(){let o=t._zod.def.shape,s={...o};if(r)for(let i in r){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(let i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return X(this,"shape",s),s}});return U(t,n)}function H(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function _t(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function W(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function we(e){return typeof e=="string"?e:e?.message}function L(e,t,r){let n=e.message?e.message:we(e.inst?._zod.def?.error?.(e))??we(t?.error?.(e))??we(r.customError?.(e))??we(r.localeError?.(e))??"Invalid input",{inst:o,continue:s,input:i,...c}=e;return c.path??(c.path=[]),c.message=n,t?.reportInput&&(c.input=i),c}function pr(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function ke(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function mc(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function me(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function hc(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function dr(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function fr(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function yc(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return dr(t+r)}function gc(e){return fr(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function _c(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function xc(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var pt=class{constructor(...t){}};var mr=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,de,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Me=l("$ZodError",mr),xt=l("$ZodError",mr,{Parent:Error});function hr(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function yr(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(c=>n({issues:c},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let c=[...s,...i.path];if(c.length===0)r._errors.push(t(i));else{let a=r,u=0;for(;u<c.length;){let f=c[u];u===c.length-1?(a[f]=a[f]||{_errors:[]},a[f]._errors.push(t(i))):a[f]=a[f]||{_errors:[]},a=a[f],u++}}}};return n(e),r}var Qe=e=>(t,r,n,o)=>{let s=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new B;if(i.issues.length){let c=new(o?.Err??e)(i.issues.map(a=>L(a,s,Q())));throw Le(c,o?.callee),c}return i.value};var Ue=e=>async(t,r,n,o)=>{let s=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let c=new(o?.Err??e)(i.issues.map(a=>L(a,s,Q())));throw Le(c,o?.callee),c}return i.value};var Ae=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new B;return s.issues.length?{success:!1,error:new(e??Me)(s.issues.map(i=>L(i,o,Q())))}:{success:!0,data:s.value}},gr=Ae(xt),Ze=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>L(i,o,Q())))}:{success:!0,data:s.value}},_r=Ze(xt),xr=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Qe(e)(t,r,o)};var br=e=>(t,r,n)=>Qe(e)(t,r,n);var wr=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Ue(e)(t,r,o)};var vr=e=>async(t,r,n)=>Ue(e)(t,r,n);var zr=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Ae(e)(t,r,o)};var $r=e=>(t,r,n)=>Ae(e)(t,r,n);var kr=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Ze(e)(t,r,o)};var Ar=e=>async(t,r,n)=>Ze(e)(t,r,n);var Zr=/^[cC][0-9a-z]{6,}$/,Sr=/^[0-9a-z]+$/,Er=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Rr=/^[0-9a-vA-V]{20}$/,Pr=/^[A-Za-z0-9]{27}$/,Or=/^[a-zA-Z0-9_-]{21}$/,Cr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Ir=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,bt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var Tr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var wc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Dr(){return new RegExp(wc,"u")}var Nr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Fr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var jr=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Lr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Mr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,wt=/^[A-Za-z0-9_-]*$/;var Qr=/^https?$/,Ur=/^\+[1-9]\d{6,14}$/,Br="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Jr=new RegExp(`^${Br}$`);function Vr(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function qr(e){return new RegExp(`^${Vr(e)}$`)}function Wr(e){let t=Vr({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Br}T(?:${n})$`)}var Gr=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var Kr=/^-?\d+$/,vt=/^-?\d+(?:\.\d+)?$/,Xr=/^(?:true|false)$/i,Yr=/^null$/i;var Hr=/^[^A-Z]*$/,en=/^[^a-z]*$/;var I=l("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),tn={number:"number",bigint:"bigint",object:"date"},zt=l("$ZodCheckLessThan",(e,t)=>{I.init(e,t);let r=tn[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$t=l("$ZodCheckGreaterThan",(e,t)=>{I.init(e,t);let r=tn[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),rn=l("$ZodCheckMultipleOf",(e,t)=>{I.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):dt(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),nn=l("$ZodCheckNumberFormat",(e,t)=>{I.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=gt[t.format];e._zod.onattach.push(i=>{let c=i._zod.bag;c.format=t.format,c.minimum=o,c.maximum=s,r&&(c.pattern=Kr)}),e._zod.check=i=>{let c=i.value;if(r){if(!Number.isInteger(c)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}c<o&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>s&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var on=l("$ZodCheckMaxLength",(e,t)=>{var r;I.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ze(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;if(o.length<=t.maximum)return;let i=ke(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),sn=l("$ZodCheckMinLength",(e,t)=>{var r;I.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ze(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;if(o.length>=t.minimum)return;let i=ke(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),cn=l("$ZodCheckLengthEquals",(e,t)=>{var r;I.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!ze(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{let o=n.value,s=o.length;if(s===t.length)return;let i=ke(o),c=s>t.length;n.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Se=l("$ZodCheckStringFormat",(e,t)=>{var r,n;I.init(e,t),e._zod.onattach.push(o=>{let s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),an=l("$ZodCheckRegex",(e,t)=>{Se.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),un=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Hr),Se.init(e,t)}),ln=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=en),Se.init(e,t)}),pn=l("$ZodCheckIncludes",(e,t)=>{I.init(e,t);let r=q(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),dn=l("$ZodCheckStartsWith",(e,t)=>{I.init(e,t);let r=new RegExp(`^${q(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),fn=l("$ZodCheckEndsWith",(e,t)=>{I.init(e,t);let r=new RegExp(`.*${q(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var mn=l("$ZodCheckOverwrite",(e,t)=>{I.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Je=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
2
|
+
`).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let t=Function,r=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...r,o.join(`
|
|
3
|
+
`))}};var yn={major:4,minor:4,patch:3};var z=l("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yn;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let s of o._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(i,c,a)=>{let u=H(i),f;for(let p of c){if(p._zod.def.when){if(_t(i)||!p._zod.def.when(i))continue}else if(u)continue;let m=i.issues.length,d=p._zod.check(i);if(d instanceof Promise&&a?.async===!1)throw new B;if(f||d instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await d,i.issues.length!==m&&(u||(u=H(i,m)))});else{if(i.issues.length===m)continue;u||(u=H(i,m))}}return f?f.then(()=>i):i},s=(i,c,a)=>{if(H(i))return i.aborted=!0,i;let u=o(c,n,a);if(u instanceof Promise){if(a.async===!1)throw new B;return u.then(f=>e._zod.parse(f,a))}return e._zod.parse(u,a)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){let u=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(f=>s(f,i,c)):s(u,i,c)}let a=e._zod.parse(i,c);if(a instanceof Promise){if(c.async===!1)throw new B;return a.then(u=>o(u,n,c))}return o(a,n,c)}}_(e,"~standard",()=>({validate:o=>{try{let s=gr(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return _r(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),We=l("$ZodString",(e,t)=>{z.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Gr(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),k=l("$ZodStringFormat",(e,t)=>{Se.init(e,t),We.init(e,t)}),kn=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Ir),k.init(e,t)}),An=l("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=bt(n))}else t.pattern??(t.pattern=bt());k.init(e,t)}),Zn=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Tr),k.init(e,t)}),Sn=l("$ZodURL",(e,t)=>{k.init(e,t),e._zod.check=r=>{try{let n=r.value.trim();if(!t.normalize&&t.protocol?.source===Qr.source&&!/^https?:\/\//i.test(n)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}let o=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),En=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Dr()),k.init(e,t)}),Rn=l("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Or),k.init(e,t)}),Pn=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Zr),k.init(e,t)}),On=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Sr),k.init(e,t)}),Cn=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Er),k.init(e,t)}),In=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Rr),k.init(e,t)}),Tn=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Pr),k.init(e,t)}),Dn=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Wr(t)),k.init(e,t)}),Nn=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Jr),k.init(e,t)}),Fn=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=qr(t)),k.init(e,t)}),jn=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Cr),k.init(e,t)}),Ln=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Nr),k.init(e,t),e._zod.bag.format="ipv4"}),Mn=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Fr),k.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}});var Qn=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=jr),k.init(e,t)}),Un=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Lr),k.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[o,s]=n;if(!s)throw new Error;let i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Bn(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Jn=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Mr),k.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Bn(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function vc(e){if(!wt.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Bn(r)}var Vn=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=wt),k.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{vc(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),qn=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Ur),k.init(e,t)});function zc(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var Wn=l("$ZodJWT",(e,t)=>{k.init(e,t),e._zod.check=r=>{zc(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var At=l("$ZodNumber",(e,t)=>{z.init(e,t),e._zod.pattern=e._zod.bag.pattern??vt,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),Gn=l("$ZodNumberFormat",(e,t)=>{nn.init(e,t),At.init(e,t)}),Kn=l("$ZodBoolean",(e,t)=>{z.init(e,t),e._zod.pattern=Xr,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var Xn=l("$ZodNull",(e,t)=>{z.init(e,t),e._zod.pattern=Yr,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}});var Yn=l("$ZodUnknown",(e,t)=>{z.init(e,t),e._zod.parse=r=>r}),Hn=l("$ZodNever",(e,t)=>{z.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function gn(e,t,r){e.issues.length&&t.issues.push(...W(r,e.issues)),t.value[r]=e.value}var eo=l("$ZodArray",(e,t)=>{z.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let c=o[i],a=t.element._zod.run({value:c,issues:[]},n);a instanceof Promise?s.push(a.then(u=>gn(u,r,i))):gn(a,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function qe(e,t,r,n,o,s){let i=r in n;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...W(r,e.issues))}if(!i&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?i&&(t.value[r]=void 0):t.value[r]=e.value}function to(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=yt(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function ro(e,t,r,n,o,s){let i=[],c=o.keySet,a=o.catchall._zod,u=a.def.type,f=a.optin==="optional",p=a.optout==="optional";for(let m in t){if(m==="__proto__"||c.has(m))continue;if(u==="never"){i.push(m);continue}let d=a.run({value:t[m],issues:[]},n);d instanceof Promise?e.push(d.then(y=>qe(y,r,m,t,f,p))):qe(d,r,m,t,f,p)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>r):r}var $c=l("$ZodObject",(e,t)=>{if(z.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let c=t.shape;Object.defineProperty(t,"shape",{get:()=>{let a={...c};return Object.defineProperty(t,"shape",{value:a}),a}})}let n=fe(()=>to(t));_(e._zod,"propValues",()=>{let c=t.shape,a={};for(let u in c){let f=c[u]._zod;if(f.values){a[u]??(a[u]=new Set);for(let p of f.values)a[u].add(p)}}return a});let o=oe,s=t.catchall,i;e._zod.parse=(c,a)=>{i??(i=n.value);let u=c.value;if(!o(u))return c.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),c;c.value={};let f=[],p=i.shape;for(let m of i.keys){let d=p[m],y=d._zod.optin==="optional",O=d._zod.optout==="optional",w=d._zod.run({value:u[m],issues:[]},a);w instanceof Promise?f.push(w.then(j=>qe(j,c,m,u,y,O))):qe(w,c,m,u,y,O)}return s?ro(f,u,c,a,n.value,e):f.length?Promise.all(f).then(()=>c):c}}),no=l("$ZodObjectJIT",(e,t)=>{$c.init(e,t);let r=e._zod.parse,n=fe(()=>to(t)),o=m=>{let d=new Je(["shape","payload","ctx"]),y=n.value,O=N=>{let $=je(N);return`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`};d.write("const input = payload.value;");let w=Object.create(null),j=0;for(let N of y.keys)w[N]=`key_${j++}`;d.write("const newResult = {};");for(let N of y.keys){let $=w[N],C=je(N),nr=m[N],or=nr?._zod?.optin==="optional",Bi=nr?._zod?.optout==="optional";d.write(`const ${$} = ${O(N)};`),or&&Bi?d.write(`
|
|
4
|
+
if (${$}.issues.length) {
|
|
5
|
+
if (${C} in input) {
|
|
6
|
+
payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
|
|
7
|
+
...iss,
|
|
8
|
+
path: iss.path ? [${C}, ...iss.path] : [${C}]
|
|
9
|
+
})));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (${$}.value === undefined) {
|
|
14
|
+
if (${C} in input) {
|
|
15
|
+
newResult[${C}] = undefined;
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
newResult[${C}] = ${$}.value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
`):or?d.write(`
|
|
22
|
+
if (${$}.issues.length) {
|
|
23
|
+
payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
|
|
24
|
+
...iss,
|
|
25
|
+
path: iss.path ? [${C}, ...iss.path] : [${C}]
|
|
26
|
+
})));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (${$}.value === undefined) {
|
|
30
|
+
if (${C} in input) {
|
|
31
|
+
newResult[${C}] = undefined;
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
newResult[${C}] = ${$}.value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
`):d.write(`
|
|
38
|
+
const ${$}_present = ${C} in input;
|
|
39
|
+
if (${$}.issues.length) {
|
|
40
|
+
payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
|
|
41
|
+
...iss,
|
|
42
|
+
path: iss.path ? [${C}, ...iss.path] : [${C}]
|
|
43
|
+
})));
|
|
44
|
+
}
|
|
45
|
+
if (!${$}_present && !${$}.issues.length) {
|
|
46
|
+
payload.issues.push({
|
|
47
|
+
code: "invalid_type",
|
|
48
|
+
expected: "nonoptional",
|
|
49
|
+
input: undefined,
|
|
50
|
+
path: [${C}]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (${$}_present) {
|
|
55
|
+
if (${$}.value === undefined) {
|
|
56
|
+
newResult[${C}] = undefined;
|
|
57
|
+
} else {
|
|
58
|
+
newResult[${C}] = ${$}.value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
`)}d.write("payload.value = newResult;"),d.write("return payload;");let Fe=d.compile();return(N,$)=>Fe(m,N,$)},s,i=oe,c=!pe.jitless,u=c&&mt.value,f=t.catchall,p;e._zod.parse=(m,d)=>{p??(p=n.value);let y=m.value;return i(y)?c&&u&&d?.async===!1&&d.jitless!==!0?(s||(s=o(t.shape)),m=s(m,d),f?ro([],y,m,d,p,e):m):r(m,d):(m.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),m)}});function _n(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!H(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>L(i,n,Q())))}),t)}var Zt=l("$ZodUnion",(e,t)=>{z.init(e,t),_(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),_(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),_(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),_(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){let n=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${n.map(o=>$e(o.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let c of t.options){let a=c._zod.run({value:n.value,issues:[]},o);if(a instanceof Promise)i.push(a),s=!0;else{if(a.issues.length===0)return a;i.push(a)}}return s?Promise.all(i).then(c=>_n(c,n,e,o)):_n(i,n,e,o)}});var oo=l("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Zt.init(e,t);let r=e._zod.parse;_(e._zod,"propValues",()=>{let o={};for(let s of t.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[c,a]of Object.entries(i)){o[c]||(o[c]=new Set);for(let u of a)o[c].add(u)}}return o});let n=fe(()=>{let o=t.options,s=new Map;for(let i of o){let c=i._zod.propValues?.[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let a of c){if(s.has(a))throw new Error(`Duplicate discriminator value "${String(a)}"`);s.set(a,i)}}return s});e._zod.parse=(o,s)=>{let i=o.value;if(!oe(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let c=n.value.get(i?.[t.discriminator]);return c?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()),input:i,path:[t.discriminator],inst:e}),o)}}),so=l("$ZodIntersection",(e,t)=>{z.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([a,u])=>xn(r,a,u)):xn(r,s,i)}});function kt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Y(e)&&Y(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};for(let s of n){let i=kt(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=kt(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function xn(e,t,r){let n=new Map,o;for(let c of t.issues)if(c.code==="unrecognized_keys"){o??(o=c);for(let a of c.keys)n.has(a)||n.set(a,{}),n.get(a).l=!0}else e.issues.push(c);for(let c of r.issues)if(c.code==="unrecognized_keys")for(let a of c.keys)n.has(a)||n.set(a,{}),n.get(a).r=!0;else e.issues.push(c);let s=[...n].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(s.length&&o&&e.issues.push({...o,keys:s}),H(e))return e;let i=kt(t.value,r.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}var io=l("$ZodRecord",(e,t)=>{z.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Y(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;let s=[],i=t.keyType._zod.values;if(i){r.value={};let c=new Set;for(let u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){c.add(typeof u=="number"?u.toString():u);let f=t.keyType._zod.run({value:u,issues:[]},n);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(d=>L(d,n,Q())),input:u,path:[u],inst:e});continue}let p=f.value,m=t.valueType._zod.run({value:o[u],issues:[]},n);m instanceof Promise?s.push(m.then(d=>{d.issues.length&&r.issues.push(...W(u,d.issues)),r.value[p]=d.value})):(m.issues.length&&r.issues.push(...W(u,m.issues)),r.value[p]=m.value)}let a;for(let u in o)c.has(u)||(a=a??[],a.push(u));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{r.value={};for(let c of Reflect.ownKeys(o)){if(c==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,c))continue;let a=t.keyType._zod.run({value:c,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&vt.test(c)&&a.issues.length){let p=t.keyType._zod.run({value:Number(c),issues:[]},n);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(a=p)}if(a.issues.length){t.mode==="loose"?r.value[c]=o[c]:r.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(p=>L(p,n,Q())),input:c,path:[c],inst:e});continue}let f=t.valueType._zod.run({value:o[c],issues:[]},n);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&r.issues.push(...W(c,p.issues)),r.value[a.value]=p.value})):(f.issues.length&&r.issues.push(...W(c,f.issues)),r.value[a.value]=f.value)}}return s.length?Promise.all(s).then(()=>r):r}});var co=l("$ZodEnum",(e,t)=>{z.init(e,t);let r=ve(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(o=>ht.has(typeof o)).map(o=>typeof o=="string"?q(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),ao=l("$ZodLiteral",(e,t)=>{if(z.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?q(n):n?q(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var uo=l("$ZodTransform",(e,t)=>{z.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new le(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r.fallback=!0,r));if(o instanceof Promise)throw new B;return r.value=o,r.fallback=!0,r}});function bn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var St=l("$ZodOptional",(e,t)=>{z.init(e,t),e._zod.optin="optional",e._zod.optout="optional",_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${$e(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let o=r.value,s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>bn(i,o)):bn(s,o)}return r.value===void 0?r:t.innerType._zod.run(r,n)}}),lo=l("$ZodExactOptional",(e,t)=>{St.init(e,t),_(e._zod,"values",()=>t.innerType._zod.values),_(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),po=l("$ZodNullable",(e,t)=>{z.init(e,t),_(e._zod,"optin",()=>t.innerType._zod.optin),_(e._zod,"optout",()=>t.innerType._zod.optout),_(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${$e(r.source)}|null)$`):void 0}),_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),fo=l("$ZodDefault",(e,t)=>{z.init(e,t),e._zod.optin="optional",_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>wn(s,t)):wn(o,t)}});function wn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var mo=l("$ZodPrefault",(e,t)=>{z.init(e,t),e._zod.optin="optional",_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),ho=l("$ZodNonOptional",(e,t)=>{z.init(e,t),_(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>vn(s,e)):vn(o,e)}});function vn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var yo=l("$ZodCatch",(e,t)=>{z.init(e,t),e._zod.optin="optional",_(e._zod,"optout",()=>t.innerType._zod.optout),_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(i=>L(i,n,Q()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>L(s,n,Q()))},input:r.value}),r.issues=[],r.fallback=!0),r)}});var go=l("$ZodPipe",(e,t)=>{z.init(e,t),_(e._zod,"values",()=>t.in._zod.values),_(e._zod,"optin",()=>t.in._zod.optin),_(e._zod,"optout",()=>t.out._zod.optout),_(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Ve(i,t.in,n)):Ve(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Ve(s,t.out,n)):Ve(o,t.out,n)}});function Ve(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}var _o=l("$ZodReadonly",(e,t)=>{z.init(e,t),_(e._zod,"propValues",()=>t.innerType._zod.propValues),_(e._zod,"values",()=>t.innerType._zod.values),_(e._zod,"optin",()=>t.innerType?._zod?.optin),_(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(zn):zn(o)}});function zn(e){return e.value=Object.freeze(e.value),e}var xo=l("$ZodLazy",(e,t)=>{z.init(e,t),_(e._zod,"innerType",()=>{let r=t;return r._cachedInner||(r._cachedInner=t.getter()),r._cachedInner}),_(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),_(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),_(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),_(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,n)=>e._zod.innerType._zod.run(r,n)}),bo=l("$ZodCustom",(e,t)=>{I.init(e,t),z.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>$n(s,r,n,e));$n(o,r,n,e)}});function $n(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(me(o))}}var wo,el=Symbol("ZodOutput"),tl=Symbol("ZodInput"),Et=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function kc(){return new Et}(wo=globalThis).__zod_globalRegistry??(wo.__zod_globalRegistry=kc());var se=globalThis.__zod_globalRegistry;function vo(e,t){return new e({type:"string",...h(t)})}function zo(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...h(t)})}function Rt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...h(t)})}function $o(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...h(t)})}function ko(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...h(t)})}function Ao(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...h(t)})}function Zo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...h(t)})}function So(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...h(t)})}function Eo(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...h(t)})}function Ro(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...h(t)})}function Po(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...h(t)})}function Oo(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...h(t)})}function Co(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...h(t)})}function Io(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...h(t)})}function To(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...h(t)})}function Do(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...h(t)})}function No(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...h(t)})}function Fo(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...h(t)})}function jo(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...h(t)})}function Lo(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...h(t)})}function Mo(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...h(t)})}function Qo(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...h(t)})}function Uo(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...h(t)})}function Bo(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...h(t)})}function Jo(e,t){return new e({type:"string",format:"date",check:"string_format",...h(t)})}function Vo(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...h(t)})}function qo(e,t){return new e({type:"string",format:"duration",check:"string_format",...h(t)})}function Wo(e,t){return new e({type:"number",checks:[],...h(t)})}function Go(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...h(t)})}function Ko(e,t){return new e({type:"boolean",...h(t)})}function Xo(e,t){return new e({type:"null",...h(t)})}function Yo(e){return new e({type:"unknown"})}function Ho(e,t){return new e({type:"never",...h(t)})}function Ge(e,t){return new zt({check:"less_than",...h(t),value:e,inclusive:!1})}function Ee(e,t){return new zt({check:"less_than",...h(t),value:e,inclusive:!0})}function Ke(e,t){return new $t({check:"greater_than",...h(t),value:e,inclusive:!1})}function Re(e,t){return new $t({check:"greater_than",...h(t),value:e,inclusive:!0})}function Xe(e,t){return new rn({check:"multiple_of",...h(t),value:e})}function Ye(e,t){return new on({check:"max_length",...h(t),maximum:e})}function he(e,t){return new sn({check:"min_length",...h(t),minimum:e})}function He(e,t){return new cn({check:"length_equals",...h(t),length:e})}function Pt(e,t){return new an({check:"string_format",format:"regex",...h(t),pattern:e})}function Ot(e){return new un({check:"string_format",format:"lowercase",...h(e)})}function Ct(e){return new ln({check:"string_format",format:"uppercase",...h(e)})}function It(e,t){return new pn({check:"string_format",format:"includes",...h(t),includes:e})}function Tt(e,t){return new dn({check:"string_format",format:"starts_with",...h(t),prefix:e})}function Dt(e,t){return new fn({check:"string_format",format:"ends_with",...h(t),suffix:e})}function ee(e){return new mn({check:"overwrite",tx:e})}function Nt(e){return ee(t=>t.normalize(e))}function Ft(){return ee(e=>e.trim())}function jt(){return ee(e=>e.toLowerCase())}function Lt(){return ee(e=>e.toUpperCase())}function Mt(){return ee(e=>ft(e))}function es(e,t,r){return new e({type:"array",element:t,...h(r)})}function ts(e,t,r){return new e({type:"custom",check:"custom",fn:t,...h(r)})}function rs(e,t){let r=Ac(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(me(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(me(s))}},e(n.value,n)),t);return r}function Ac(e,t){let r=new I({check:"custom",...h(t)});return r._zod.check=e,r}function Qt(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??se,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function E(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i);let c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{let f={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,f);else{let m=i.schema,d=t.processors[o.type];if(!d)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);d(e,t,m,f)}let p=e._zod.parent;p&&(i.ref||(i.ref=p),E(p,t,f),t.seen.get(p).isParent=!0)}let a=t.metadataRegistry.get(e);return a&&Object.assign(i.schema,a),t.io==="input"&&T(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Ut(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let i of e.seen.entries()){let c=e.metadataRegistry.get(i[0])?.id;if(c){let a=n.get(c);if(a&&a!==i[0])throw new Error(`Duplicate schema id "${c}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(c,i[0])}}let o=i=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(i[0])?.id,m=e.external.uri??(y=>y);if(p)return{ref:m(p)};let d=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=d,{defId:d,ref:`${m("__shared")}#/${c}/${d}`}}if(i[1]===r)return{ref:"#"};let u=`#/${c}/`,f=i[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:u+f}},s=i=>{if(i[1].schema.$ref)return;let c=i[1],{ref:a,defId:u}=o(i);c.def={...c.schema},u&&(c.defId=u);let f=c.schema;for(let p in f)delete f[p];f.$ref=a};if(e.cycles==="throw")for(let i of e.seen.entries()){let c=i[1];if(c.cycle)throw new Error(`Cycle detected: #/${c.cycle?.join("/")}/<root>
|
|
63
|
+
|
|
64
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let c=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(c.cycle){s(i);continue}if(c.count>1&&e.reused==="ref"){s(i);continue}}}function Bt(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=c=>{let a=e.seen.get(c);if(a.ref===null)return;let u=a.def??a.schema,f={...u},p=a.ref;if(a.ref=null,p){n(p);let d=e.seen.get(p),y=d.schema;if(y.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(y)):Object.assign(u,y),Object.assign(u,f),c._zod.parent===p)for(let w in u)w==="$ref"||w==="allOf"||w in f||delete u[w];if(y.$ref&&d.def)for(let w in u)w==="$ref"||w==="allOf"||w in d.def&&JSON.stringify(u[w])===JSON.stringify(d.def[w])&&delete u[w]}let m=c._zod.parent;if(m&&m!==p){n(m);let d=e.seen.get(m);if(d?.schema.$ref&&(u.$ref=d.schema.$ref,d.def))for(let y in u)y==="$ref"||y==="allOf"||y in d.def&&JSON.stringify(u[y])===JSON.stringify(d.def[y])&&delete u[y]}e.override({zodSchema:c,jsonSchema:u,path:a.path??[]})};for(let c of[...e.seen.entries()].reverse())n(c[0]);let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let c=e.external.registry.get(t)?.id;if(!c)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(c)}Object.assign(o,r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};for(let c of e.seen.entries()){let a=c[1];a.def&&a.defId&&(a.def.id===a.defId&&delete a.def.id,i[a.defId]=a.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let c=JSON.parse(JSON.stringify(o));return Object.defineProperty(c,"~standard",{value:{...t["~standard"],jsonSchema:{input:Pe(t,"input",e.processors),output:Pe(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function T(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return T(n.element,r);if(n.type==="set")return T(n.valueType,r);if(n.type==="lazy")return T(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault")return T(n.innerType,r);if(n.type==="intersection")return T(n.left,r)||T(n.right,r);if(n.type==="record"||n.type==="map")return T(n.keyType,r)||T(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:T(n.in,r)||T(n.out,r);if(n.type==="object"){for(let o in n.shape)if(T(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(T(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(T(o,r))return!0;return!!(n.rest&&T(n.rest,r))}return!1}var ns=(e,t={})=>r=>{let n=Qt({...r,processors:t});return E(e,n),Ut(n,e),Bt(n,e)},Pe=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=Qt({...o??{},target:s,io:t,processors:r});return E(e,i),Ut(i,e),Bt(i,e)};var Zc={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},os=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:c,patterns:a,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),c&&(o.format=Zc[c]??c,o.format===""&&delete o.format,c==="time"&&delete o.format),u&&(o.contentEncoding=u),a&&a.size>0){let f=[...a];f.length===1?o.pattern=f[0].source:f.length>1&&(o.allOf=[...f.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},ss=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,format:c,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:f}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number";let p=typeof f=="number"&&f>=(s??Number.NEGATIVE_INFINITY),m=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),d=t.target==="draft-04"||t.target==="openapi-3.0";p?d?(o.minimum=f,o.exclusiveMinimum=!0):o.exclusiveMinimum=f:typeof s=="number"&&(o.minimum=s),m?d?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof i=="number"&&(o.maximum=i),typeof a=="number"&&(o.multipleOf=a)},is=(e,t,r,n)=>{r.type="boolean"};var cs=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var as=(e,t,r,n)=>{r.not={}};var us=(e,t,r,n)=>{};var ls=(e,t,r,n)=>{let o=e._zod.def,s=ve(o.entries);s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},ps=(e,t,r,n)=>{let o=e._zod.def,s=[];for(let i of o.values)if(i===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var ds=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")};var fs=(e,t,r,n)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")};var ms=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:c}=e._zod.bag;typeof i=="number"&&(o.minItems=i),typeof c=="number"&&(o.maxItems=c),o.type="array",o.items=E(s.element,t,{...n,path:[...n.path,"items"]})},hs=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object",o.properties={};let i=s.shape;for(let u in i)o.properties[u]=E(i[u],t,{...n,path:[...n.path,"properties",u]});let c=new Set(Object.keys(i)),a=new Set([...c].filter(u=>{let f=s.shape[u]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));a.size>0&&(o.required=Array.from(a)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=E(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},ys=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((c,a)=>E(c,t,{...n,path:[...n.path,s?"oneOf":"anyOf",a]}));s?r.oneOf=i:r.anyOf=i},gs=(e,t,r,n)=>{let o=e._zod.def,s=E(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=E(o.right,t,{...n,path:[...n.path,"allOf",1]}),c=u=>"allOf"in u&&Object.keys(u).length===1,a=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];r.allOf=a};var _s=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=i._zod.bag?.patterns;if(s.mode==="loose"&&a&&a.size>0){let f=E(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let p of a)o.patternProperties[p.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=E(s.keyType,t,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=E(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]});let u=i._zod.values;if(u){let f=[...u].filter(p=>typeof p=="string"||typeof p=="number");f.length>0&&(o.required=f)}},xs=(e,t,r,n)=>{let o=e._zod.def,s=E(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},bs=(e,t,r,n)=>{let o=e._zod.def;E(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},ws=(e,t,r,n)=>{let o=e._zod.def;E(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},vs=(e,t,r,n)=>{let o=e._zod.def;E(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},zs=(e,t,r,n)=>{let o=e._zod.def;E(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},$s=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;E(i,t,n);let c=t.seen.get(e);c.ref=i},ks=(e,t,r,n)=>{let o=e._zod.def;E(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var Jt=(e,t,r,n)=>{let o=e._zod.def;E(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},As=(e,t,r,n)=>{let o=e._zod.innerType;E(o,t,n);let s=t.seen.get(e);s.ref=o};var Ic=l("ZodISODateTime",(e,t)=>{Dn.init(e,t),Z.init(e,t)});function Zs(e){return Bo(Ic,e)}var Tc=l("ZodISODate",(e,t)=>{Nn.init(e,t),Z.init(e,t)});function Ss(e){return Jo(Tc,e)}var Dc=l("ZodISOTime",(e,t)=>{Fn.init(e,t),Z.init(e,t)});function Es(e){return Vo(Dc,e)}var Nc=l("ZodISODuration",(e,t)=>{jn.init(e,t),Z.init(e,t)});function Rs(e){return qo(Nc,e)}var Lc=(e,t)=>{Me.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>yr(e,r)},flatten:{value:r=>hr(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,de,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,de,2)}},isEmpty:{get(){return e.issues.length===0}}})};var F=l("ZodError",Lc,{Parent:Error});var Ps=Qe(F),Os=Ue(F),Cs=Ae(F),Is=Ze(F),Ts=xr(F),Ds=br(F),Ns=wr(F),Fs=vr(F),js=zr(F),Ls=$r(F),Ms=kr(F),Qs=Ar(F);var Us=new WeakMap;function Oe(e,t,r){let n=Object.getPrototypeOf(e),o=Us.get(n);if(o||(o=new Set,Us.set(n,o)),!o.has(t)){o.add(t);for(let s in r){let i=r[s];Object.defineProperty(n,s,{configurable:!0,enumerable:!1,get(){let c=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:c}),c},set(c){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:c})}})}}}var A=l("ZodType",(e,t)=>(z.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Pe(e,"input"),output:Pe(e,"output")}}),e.toJSONSchema=ns(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(r,n)=>Ps(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Cs(e,r,n),e.parseAsync=async(r,n)=>Os(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Is(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>Ts(e,r,n),e.decode=(r,n)=>Ds(e,r,n),e.encodeAsync=async(r,n)=>Ns(e,r,n),e.decodeAsync=async(r,n)=>Fs(e,r,n),e.safeEncode=(r,n)=>js(e,r,n),e.safeDecode=(r,n)=>Ls(e,r,n),e.safeEncodeAsync=async(r,n)=>Ms(e,r,n),e.safeDecodeAsync=async(r,n)=>Qs(e,r,n),Oe(e,"ZodType",{check(...r){let n=this.def;return this.clone(b.mergeDefs(n,{checks:[...n.checks??[],...r.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return U(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(Ia(r,n))},superRefine(r,n){return this.check(Ta(r,n))},overwrite(r){return this.check(ee(r))},optional(){return Ws(this)},exactOptional(){return ba(this)},nullable(){return Gs(this)},nullish(){return Ws(Gs(this))},nonoptional(r){return Aa(this,r)},array(){return P(this)},or(r){return rt([this,r])},and(r){return ha(this,r)},transform(r){return Ks(this,_a(r))},default(r){return za(this,r)},prefault(r){return ka(this,r)},catch(r){return Sa(this,r)},pipe(r){return Ks(this,r)},readonly(){return Pa(this)},describe(r){let n=this.clone();return se.add(n,{description:r}),n},meta(...r){if(r.length===0)return se.get(this);let n=this.clone();return se.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(e,"description",{get(){return se.get(e)?.description},configurable:!0}),e)),Xs=l("_ZodString",(e,t)=>{We.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,o,s)=>os(e,n,o,s);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,Oe(e,"_ZodString",{regex(...n){return this.check(Pt(...n))},includes(...n){return this.check(It(...n))},startsWith(...n){return this.check(Tt(...n))},endsWith(...n){return this.check(Dt(...n))},min(...n){return this.check(he(...n))},max(...n){return this.check(Ye(...n))},length(...n){return this.check(He(...n))},nonempty(...n){return this.check(he(1,...n))},lowercase(n){return this.check(Ot(n))},uppercase(n){return this.check(Ct(n))},trim(){return this.check(Ft())},normalize(...n){return this.check(Nt(...n))},toLowerCase(){return this.check(jt())},toUpperCase(){return this.check(Lt())},slugify(){return this.check(Mt())}})}),Qc=l("ZodString",(e,t)=>{We.init(e,t),Xs.init(e,t),e.email=r=>e.check(zo(Uc,r)),e.url=r=>e.check(So(Bc,r)),e.jwt=r=>e.check(Uo(sa,r)),e.emoji=r=>e.check(Eo(Jc,r)),e.guid=r=>e.check(Rt(Bs,r)),e.uuid=r=>e.check($o(tt,r)),e.uuidv4=r=>e.check(ko(tt,r)),e.uuidv6=r=>e.check(Ao(tt,r)),e.uuidv7=r=>e.check(Zo(tt,r)),e.nanoid=r=>e.check(Ro(Vc,r)),e.guid=r=>e.check(Rt(Bs,r)),e.cuid=r=>e.check(Po(qc,r)),e.cuid2=r=>e.check(Oo(Wc,r)),e.ulid=r=>e.check(Co(Gc,r)),e.base64=r=>e.check(Lo(ra,r)),e.base64url=r=>e.check(Mo(na,r)),e.xid=r=>e.check(Io(Kc,r)),e.ksuid=r=>e.check(To(Xc,r)),e.ipv4=r=>e.check(Do(Yc,r)),e.ipv6=r=>e.check(No(Hc,r)),e.cidrv4=r=>e.check(Fo(ea,r)),e.cidrv6=r=>e.check(jo(ta,r)),e.e164=r=>e.check(Qo(oa,r)),e.datetime=r=>e.check(Zs(r)),e.date=r=>e.check(Ss(r)),e.time=r=>e.check(Es(r)),e.duration=r=>e.check(Rs(r))});function g(e){return vo(Qc,e)}var Z=l("ZodStringFormat",(e,t)=>{k.init(e,t),Xs.init(e,t)}),Uc=l("ZodEmail",(e,t)=>{Zn.init(e,t),Z.init(e,t)});var Bs=l("ZodGUID",(e,t)=>{kn.init(e,t),Z.init(e,t)});var tt=l("ZodUUID",(e,t)=>{An.init(e,t),Z.init(e,t)});var Bc=l("ZodURL",(e,t)=>{Sn.init(e,t),Z.init(e,t)});var Jc=l("ZodEmoji",(e,t)=>{En.init(e,t),Z.init(e,t)});var Vc=l("ZodNanoID",(e,t)=>{Rn.init(e,t),Z.init(e,t)});var qc=l("ZodCUID",(e,t)=>{Pn.init(e,t),Z.init(e,t)});var Wc=l("ZodCUID2",(e,t)=>{On.init(e,t),Z.init(e,t)});var Gc=l("ZodULID",(e,t)=>{Cn.init(e,t),Z.init(e,t)});var Kc=l("ZodXID",(e,t)=>{In.init(e,t),Z.init(e,t)});var Xc=l("ZodKSUID",(e,t)=>{Tn.init(e,t),Z.init(e,t)});var Yc=l("ZodIPv4",(e,t)=>{Ln.init(e,t),Z.init(e,t)});var Hc=l("ZodIPv6",(e,t)=>{Mn.init(e,t),Z.init(e,t)});var ea=l("ZodCIDRv4",(e,t)=>{Qn.init(e,t),Z.init(e,t)});var ta=l("ZodCIDRv6",(e,t)=>{Un.init(e,t),Z.init(e,t)});var ra=l("ZodBase64",(e,t)=>{Jn.init(e,t),Z.init(e,t)});var na=l("ZodBase64URL",(e,t)=>{Vn.init(e,t),Z.init(e,t)});var oa=l("ZodE164",(e,t)=>{qn.init(e,t),Z.init(e,t)});var sa=l("ZodJWT",(e,t)=>{Wn.init(e,t),Z.init(e,t)});var Ys=l("ZodNumber",(e,t)=>{At.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,o,s)=>ss(e,n,o,s),Oe(e,"ZodNumber",{gt(n,o){return this.check(Ke(n,o))},gte(n,o){return this.check(Re(n,o))},min(n,o){return this.check(Re(n,o))},lt(n,o){return this.check(Ge(n,o))},lte(n,o){return this.check(Ee(n,o))},max(n,o){return this.check(Ee(n,o))},int(n){return this.check(Js(n))},safe(n){return this.check(Js(n))},positive(n){return this.check(Ke(0,n))},nonnegative(n){return this.check(Re(0,n))},negative(n){return this.check(Ge(0,n))},nonpositive(n){return this.check(Ee(0,n))},multipleOf(n,o){return this.check(Xe(n,o))},step(n,o){return this.check(Xe(n,o))},finite(){return this}});let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function v(e){return Wo(Ys,e)}var ia=l("ZodNumberFormat",(e,t)=>{Gn.init(e,t),Ys.init(e,t)});function Js(e){return Go(ia,e)}var ca=l("ZodBoolean",(e,t)=>{Kn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>is(e,r,n,o)});function te(e){return Ko(ca,e)}var aa=l("ZodNull",(e,t)=>{Xn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cs(e,r,n,o)});function ua(e){return Xo(aa,e)}var la=l("ZodUnknown",(e,t)=>{Yn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>us(e,r,n,o)});function Vs(){return Yo(la)}var pa=l("ZodNever",(e,t)=>{Hn.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>as(e,r,n,o)});function Hs(e){return Ho(pa,e)}var da=l("ZodArray",(e,t)=>{eo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ms(e,r,n,o),e.element=t.element,Oe(e,"ZodArray",{min(r,n){return this.check(he(r,n))},nonempty(r){return this.check(he(1,r))},max(r,n){return this.check(Ye(r,n))},length(r,n){return this.check(He(r,n))},unwrap(){return this.element}})});function P(e,t){return es(da,e,t)}var ei=l("ZodObject",(e,t)=>{no.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hs(e,r,n,o),b.defineLazy(e,"shape",()=>t.shape),Oe(e,"ZodObject",{keyof(){return G(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:Vs()})},loose(){return this.clone({...this._zod.def,catchall:Vs()})},strict(){return this.clone({...this._zod.def,catchall:Hs()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return b.extend(this,r)},safeExtend(r){return b.safeExtend(this,r)},merge(r){return b.merge(this,r)},pick(r){return b.pick(this,r)},omit(r){return b.omit(this,r)},partial(...r){return b.partial(ri,this,r[0])},required(...r){return b.required(ni,this,r[0])}})});function M(e,t){let r={type:"object",shape:e??{},...b.normalizeParams(t)};return new ei(r)}function S(e,t){return new ei({type:"object",shape:e,catchall:Hs(),...b.normalizeParams(t)})}var ti=l("ZodUnion",(e,t)=>{Zt.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ys(e,r,n,o),e.options=t.options});function rt(e,t){return new ti({type:"union",options:e,...b.normalizeParams(t)})}var fa=l("ZodDiscriminatedUnion",(e,t)=>{ti.init(e,t),oo.init(e,t)});function nt(e,t,r){return new fa({type:"union",options:t,discriminator:e,...b.normalizeParams(r)})}var ma=l("ZodIntersection",(e,t)=>{so.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gs(e,r,n,o)});function ha(e,t){return new ma({type:"intersection",left:e,right:t})}var qs=l("ZodRecord",(e,t)=>{io.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_s(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function re(e,t,r){return!t||!t._zod?new qs({type:"record",keyType:g(),valueType:e,...b.normalizeParams(t)}):new qs({type:"record",keyType:e,valueType:t,...b.normalizeParams(r)})}var Vt=l("ZodEnum",(e,t)=>{co.init(e,t),A.init(e,t),e._zod.processJSONSchema=(n,o,s)=>ls(e,n,o,s),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Vt({...t,checks:[],...b.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Vt({...t,checks:[],...b.normalizeParams(o),entries:s})}});function G(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Vt({type:"enum",entries:r,...b.normalizeParams(t)})}var ya=l("ZodLiteral",(e,t)=>{ao.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ps(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function R(e,t){return new ya({type:"literal",values:Array.isArray(e)?e:[e],...b.normalizeParams(t)})}var ga=l("ZodTransform",(e,t)=>{uo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fs(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new le(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(b.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),r.issues.push(b.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r.fallback=!0,r)):(r.value=o,r.fallback=!0,r)}});function _a(e){return new ga({type:"transform",transform:e})}var ri=l("ZodOptional",(e,t)=>{St.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jt(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ws(e){return new ri({type:"optional",innerType:e})}var xa=l("ZodExactOptional",(e,t)=>{lo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jt(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ba(e){return new xa({type:"optional",innerType:e})}var wa=l("ZodNullable",(e,t)=>{po.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Gs(e){return new wa({type:"nullable",innerType:e})}var va=l("ZodDefault",(e,t)=>{fo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ws(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function za(e,t){return new va({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():b.shallowClone(t)}})}var $a=l("ZodPrefault",(e,t)=>{mo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>vs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ka(e,t){return new $a({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():b.shallowClone(t)}})}var ni=l("ZodNonOptional",(e,t)=>{ho.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Aa(e,t){return new ni({type:"nonoptional",innerType:e,...b.normalizeParams(t)})}var Za=l("ZodCatch",(e,t)=>{yo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>zs(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Sa(e,t){return new Za({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Ea=l("ZodPipe",(e,t)=>{go.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$s(e,r,n,o),e.in=t.in,e.out=t.out});function Ks(e,t){return new Ea({type:"pipe",in:e,out:t})}var Ra=l("ZodReadonly",(e,t)=>{_o.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ks(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Pa(e){return new Ra({type:"readonly",innerType:e})}var Oa=l("ZodLazy",(e,t)=>{xo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>As(e,r,n,o),e.unwrap=()=>e._zod.def.getter()});function qt(e){return new Oa({type:"lazy",getter:e})}var Ca=l("ZodCustom",(e,t)=>{bo.init(e,t),A.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ds(e,r,n,o)});function Ia(e,t={}){return ts(Ca,e,t)}function Ta(e,t){return rs(e,t)}function ye(e){let t=qt(()=>rt([g(e),v(),te(),ua(),P(t),re(g(),t)]));return t}var oi=e=>"field"in e?[e]:("all"in e?e.all:e.any).flatMap(oi),si=e=>oi(e);var ot=(e,t)=>{if("field"in e)return t(e);let r="all"in e?e.all:e.any,n=!1;if("all"in e){for(let o of r){let s=ot(o,t);if(s===!1)return!1;n||=s===void 0}return n?void 0:!0}for(let o of r){let s=ot(o,t);if(s===!0)return!0;n||=s===void 0}return n?void 0:!1},ii=e=>JSON.stringify(e),Wt=e=>{if("field"in e)return{conditions:1,depth:0};let t="all"in e?e.all:e.any,r=0,n=1;for(let o of t){let s=Wt(o);r+=s.conditions,n=Math.max(n,s.depth+1)}return{conditions:r,depth:n}},ci=(e,t={})=>{let r=o=>{let s=P(o),i=t.maximumChildren===void 0?s:s.max(t.maximumChildren);return rt([e,S({all:i}),S({any:i})])},n=qt(()=>r(n));return t.maximumConditions===void 0&&t.maximumDepth===void 0?n:n.superRefine((o,s)=>{let{conditions:i,depth:c}=Wt(o);t.maximumConditions!==void 0&&i>t.maximumConditions&&s.addIssue({code:"custom",message:t.maximumConditionsMessage??"Query exceeds the condition limit"}),t.maximumDepth!==void 0&&c>t.maximumDepth&&s.addIssue({code:"custom",message:t.maximumDepthMessage??"Query exceeds the nesting limit"})})};var x={requestBytes:524288,filterCount:32,filterDepth:8,sortCount:8,outputFieldCount:256,fieldPathDepth:9,defaultResultCount:20,resultCount:1e3,resultBytes:16777216,candidateDocuments:1e3,databaseBytes:512e3,frontmatterBytes:65536,frontmatterDepth:8,frontmatterFields:256,frontmatterStringBytes:16384,jsonBytes:1048576,jsonDepth:8,jsonFields:256,jsonStringBytes:16384,indexedPropertiesBytes:65536,excerptBytes:2048,hydratedFileBytes:1048576,hydratedTotalBytes:2097152,hydratedFileCount:20,hydratedRangeBytes:262144,concurrentContentReads:8};var Da=g().min(1).refine(e=>e.startsWith("/")===!1,{error:"Asset path must be relative"}).refine(e=>e.includes("\\")===!1&&e.split("/").every(t=>t.length>0&&t!==".."&&t!=="."),{error:"Asset path must be normalized and must not contain dot segments"}),ui=S({_id:g().min(1),_type:R("asset.file"),name:g().min(1),description:g().optional(),path:Da,key:g(),folderId:g().min(1).optional(),extension:g().regex(/^[a-z0-9]*$/),mimeType:g().min(1),size:v().int().nonnegative(),createdAt:g().datetime().optional(),revision:g().min(1),contentRef:g().min(1),properties:re(g(),ye()),excerpt:g().optional(),metadataError:S({code:g().min(1),message:g().min(1)}).optional()}),Na=ui.partial().required({_id:!0}),Fa=G(["null","boolean","number","string","object","array"]),ja=M({format:R("webstudio-builder-asset-field-catalog"),version:R(1),canonicalRevision:g().regex(/^sha256:[a-f0-9]{64}$/),documentCount:v().int().nonnegative(),fields:re(g().min(1),M({queryPath:P(g().min(1)).min(1).max(x.fieldPathDepth).optional(),types:P(Fa).min(1),occurrences:v().int().positive(),optional:R(!0).optional(),mixed:R(!0).optional()}))}).superRefine((e,t)=>{for(let[r,n]of Object.entries(e.fields)){let o=[...new Set(n.types)].sort();JSON.stringify(n.types)!==JSON.stringify(o)&&t.addIssue({code:"custom",path:["fields",r,"types"],message:"Observed field types must be unique and sorted"}),n.occurrences>e.documentCount&&t.addIssue({code:"custom",path:["fields",r,"occurrences"],message:"Field occurrences cannot exceed the document count"});let s=n.occurrences<e.documentCount;n.optional===!0!==s&&t.addIssue({code:"custom",path:["fields",r,"optional"],message:"Field optionality must match its occurrence count"});let i=o.length>1;n.mixed===!0!==i&&t.addIssue({code:"custom",path:["fields",r,"mixed"],message:"Mixed status must match the observed types"})}}),st=g().regex(/^sha256:[a-f0-9]{64}$/),li=S({fields:P(P(g().min(1)).min(1).max(x.fieldPathDepth)).min(1).max(x.outputFieldCount+1),rows:P(P(ye())).max(x.resultCount),totalCount:v().int().nonnegative().max(x.candidateDocuments),hasMore:te()}).superRefine(({fields:e,rows:t},r)=>{for(let[n,o]of t.entries())o.length!==e.length&&r.addIssue({code:"custom",path:["rows",n],message:"Materialized query rows must match the field count"})}),pi=S({format:R("webstudio-content-database"),version:R(1),assetRevision:st,documents:P(Na),contents:re(g().min(1),g()).optional(),assetReferences:re(g().min(1),P(S({start:v().int().nonnegative(),end:v().int().positive(),assetId:g().min(1),suffix:g().min(1).optional()}).refine(({start:e,end:t})=>t>e,{message:"Markdown asset reference range must not be empty"}))).optional(),fieldCatalog:ja,queries:re(st,li).optional(),database:S({maxBytes:v().int().positive(),unboundedBytes:v().int().nonnegative(),sourceDocumentCount:v().int().nonnegative(),includedDocumentCount:v().int().nonnegative().optional()}).optional(),integrity:S({algorithm:R("sha256"),checksum:st})}).superRefine((e,t)=>{e.documents.length>x.candidateDocuments&&t.addIssue({code:"custom",path:["documents"],message:"Asset index exceeds the document limit"}),(e.fieldCatalog.canonicalRevision!==e.assetRevision||e.fieldCatalog.documentCount!==e.documents.length)&&t.addIssue({code:"custom",path:["fieldCatalog"],message:"Asset index field catalog does not match its documents"}),e.database!==void 0&&e.database.sourceDocumentCount<e.documents.length&&t.addIssue({code:"custom",path:["database","sourceDocumentCount"],message:"Source document count cannot be smaller than the database"}),e.database?.includedDocumentCount!==void 0&&(e.database.includedDocumentCount<e.documents.length||e.database.includedDocumentCount>e.database.sourceDocumentCount)&&t.addIssue({code:"custom",path:["database","includedDocumentCount"],message:"Included document count must match the database bounds"});let r;for(let[o,s]of e.documents.entries())r!==void 0&&s._id<=r&&t.addIssue({code:"custom",path:["documents",o,"_id"],message:"Asset index documents must have unique sorted IDs"}),r=s._id;let n=new Set(e.documents.flatMap(({contentRef:o})=>o===void 0?[]:[o]));for(let o of Object.keys(e.contents??{}))n.has(o)===!1&&t.addIssue({code:"custom",path:["contents",o],message:"Embedded content must belong to an indexed document"});for(let o of Object.keys(e.assetReferences??{}))n.has(o)===!1&&t.addIssue({code:"custom",path:["assetReferences",o],message:"Asset references must belong to an indexed document"})}),La=nt("mode",[M({mode:R("none")}),M({mode:R("full"),maxBytes:v().int().positive().max(x.hydratedFileBytes).optional()}),M({mode:R("range"),offset:v().int().nonnegative(),length:v().int().positive().max(x.hydratedRangeBytes)}),M({mode:R("markdown-body"),maxBytes:v().int().positive().max(x.hydratedFileBytes).optional()})]),Kt={id:["string"],url:["string"],width:["number"],height:["number"],name:["string"],description:["string"],path:["string"],key:["string"],folderId:["string"],extension:["string"],mimeType:["string"],size:["number"],createdAt:["string"],revision:["string"],excerpt:["string"]},di=Object.keys(Kt),fi=["url","width","height"],it=e=>fi.includes(e),mi=di.filter(e=>it(e)===!1&&e!=="excerpt"),hi=mi.filter(e=>e!=="id"),yi=e=>mi.includes(e),Ma=G(di),Ce=P(g().min(1)).min(1).max(x.fieldPathDepth).superRefine((e,t)=>{if(e[0]==="properties"){e.length<2&&t.addIssue({code:"custom",message:"A properties field path must select a property"});return}(e.length!==1||Ma.safeParse(e[0]).success===!1)&&t.addIssue({code:"custom",message:"Asset query field path is unsupported"})}),Gt=te().default(!0),Qa=nt("mode",[S({mode:R("all"),includeMetadata:Gt}),S({mode:R("base"),includeMetadata:Gt}),S({mode:R("fields"),includeMetadata:Gt,fields:P(Ce).max(x.outputFieldCount).refine(e=>new Set(e.map(ii)).size===e.length,{error:"Selected output fields must be unique"})})]),Ua={mode:"fields",includeMetadata:!1,fields:fi.map(e=>[e])},gi=["eq","ne","contains","startsWith","endsWith","gt","gte","lt","lte"],Bp=[...gi,"in","exists","isEmpty"],Ba=S({field:Ce,operator:G(gi),value:ye()}),Ja=S({field:Ce,operator:R("in"),value:P(ye()).max(x.resultCount)}),Va=S({field:Ce,operator:G(["exists","isEmpty"]),value:te()}),qa=nt("operator",[Ba,Ja,Va]),Wa=ci(qa,{maximumChildren:x.filterCount,maximumConditions:x.filterCount,maximumDepth:x.filterDepth,maximumConditionsMessage:"Asset query exceeds the filter limit",maximumDepthMessage:"Asset query exceeds the filter nesting limit"});var Ga=Wa,_i=e=>{let t=new Set(["eq","ne","in","exists"]);return e.some(r=>r==="string"||r==="array")&&t.add("contains"),e.includes("string")&&(t.add("startsWith"),t.add("endsWith")),e.some(r=>r==="string"||r==="number")&&(t.add("gt"),t.add("gte"),t.add("lt"),t.add("lte")),e.some(r=>r==="string"||r==="array"||r==="object")&&t.add("isEmpty"),[...t]},Ka=S({field:Ce,direction:G(["asc","desc"])}),Xa=({output:e,content:t})=>e.includeMetadata||e.mode==="all"||e.mode==="fields"&&e.fields.length>0||t.mode!=="none",ge=S({where:Ga.default({all:[]}),sort:P(Ka).max(x.sortCount).default([]),limit:v().int().nonnegative().max(x.resultCount).default(x.defaultResultCount),offset:v().int().nonnegative().max(x.candidateDocuments).default(0),output:Qa.default(Ua),content:La.default({mode:"none"})}).refine(Xa,{error:"Select at least one asset query output"}),xi=S({query:ge,indexRevision:g().min(1).max(255).optional()}),Ya=M({_id:g().min(1),revision:g().min(1),contentRef:g().min(1),encoding:R("utf-8"),text:g(),range:M({offset:v().int().nonnegative(),length:v().int().nonnegative(),total:v().int().nonnegative()}).optional()}),Ha=Ya.omit({_id:!0,revision:!0,contentRef:!0}),eu=ui.omit({_id:!0,_type:!0,contentRef:!0}).partial().extend({id:g().min(1),url:g().min(1).optional(),width:v().positive().optional(),height:v().positive().optional(),content:Ha.optional()}).refine(e=>e.width===void 0==(e.height===void 0),{error:"Asset dimensions must include both width and height"}),tu=S({format:R("webstudio-content-database"),version:R(1),revision:st,usedBytes:v().int().nonnegative(),maxBytes:v().int().positive(),unboundedBytes:v().int().nonnegative(),includedDocumentCount:v().int().nonnegative(),omittedDocumentCount:v().int().nonnegative(),omissionReason:G(["size","unavailable"]).optional(),truncated:te()}),ai=tu.pick({usedBytes:!0,maxBytes:!0,unboundedBytes:!0,includedDocumentCount:!0,omittedDocumentCount:!0,omissionReason:!0,truncated:!0}),ru=S({scope:R("query-preview"),query:ai,database:ai}),Xt=S({items:P(eu),totalCount:v().int().nonnegative(),hasMore:te()}),Jp=S({data:Xt,__diagnostics__:ru}),nu=G(["INVALID_REQUEST","REQUEST_CANCELLED","UNAUTHORIZED","FORBIDDEN","STALE_INDEX","CONTENT_IDENTITY_REQUIRED","CONTENT_NOT_TEXT","CONTENT_DECODING_FAILED","CONTENT_LIMIT_EXCEEDED","INTERNAL_ERROR"]),ou=M({ok:R(!1),error:M({code:nu,message:g().min(1),retryable:te(),details:re(g(),ye()).optional()}),meta:M({queryHash:g().min(1).optional(),indexRevision:g().min(1).optional(),assetRevision:g().min(1).optional()}).optional()}),bi=({code:e,message:t,retryable:r=!1,details:n})=>ou.parse({ok:!1,error:{code:e,message:t,retryable:r,details:n}});function ie(e,t=new Set){if(typeof e=="number"&&isNaN(e))throw new Error("NaN is not allowed");if(typeof e=="number"&&!isFinite(e))throw new Error("Infinity is not allowed");if(e===null||typeof e!="object")return JSON.stringify(e);if(typeof e.toJSON=="function"){if(t.has(e))throw new Error("Circular reference detected");t.add(e);let n=ie(e.toJSON(),t);return t.delete(e),n}if(t.has(e))throw new Error("Circular reference detected");t.add(e);let r;if(Array.isArray(e))r=`[${e.map(o=>ie(o===void 0||typeof o=="symbol"?null:o,t)).join(",")}]`;else{let n=[];for(let o of Object.keys(e).sort())e[o]===void 0||typeof e[o]=="symbol"||n.push(`${ie(o)}:${ie(e[o],t)}`);r=`{${n.join(",")}}`}return t.delete(e),r}var su=new TextEncoder,_e=e=>su.encode(e),ne=e=>_e(e).byteLength,ce=class extends Error{constructor(){super("Byte stream exceeds the configured limit"),this.name="ByteLimitExceededError"}},iu=(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)r.set(o,n),n+=o.byteLength;return r},cu=e=>typeof e=="string"?{async*[Symbol.asyncIterator](){yield _e(e)}}:e instanceof Uint8Array?{async*[Symbol.asyncIterator](){yield e}}:e,au=async(e,t)=>{let r=[],n=0;for await(let o of cu(e)){let s=t-n;if(s<=0)break;let i=o.subarray(0,s);if(r.push(i),n+=i.byteLength,n===t)break}return iu(r,n)},ct=async(e,t)=>{let r=await au(e,t+1);if(r.byteLength>t)throw new ce;return r},ae=e=>new TextDecoder("utf-8",{fatal:!0}).decode(e),wi=e=>e.charCodeAt(0)===65279?e.slice(1):e;var vi=e=>{for(let t=0;t<e.length;t+=1){let r=e.charCodeAt(t);if(r>=55296&&r<=56319){let n=e.charCodeAt(t+1);if(t+1>=e.length||n<56320||n>57343)throw new Error("JSON strings cannot contain lone Unicode surrogates");t+=1;continue}if(r>=56320&&r<=57343)throw new Error("JSON strings cannot contain lone Unicode surrogates")}},Yt=(e,t)=>{if(e===null||typeof e=="boolean")return e;if(typeof e=="string")return vi(e),e;if(typeof e=="number"){if(Number.isFinite(e)===!1)throw new Error("JSON cannot contain non-finite numbers");return e}if(Array.isArray(e)){if(Object.getOwnPropertySymbols(e).length>0)throw new Error("JSON arrays cannot contain symbol properties");if(t.has(e))throw new Error("JSON cannot contain circular references");t.add(e);try{let r=[];for(let n=0;n<e.length;n+=1){if(Object.hasOwn(e,n)===!1)throw new Error("JSON arrays cannot be sparse");let o=e[n];if(o===void 0)throw new Error("JSON arrays cannot contain undefined values");r.push(Yt(o,t))}if(Object.keys(e).length!==e.length)throw new Error("JSON arrays cannot contain named properties");return r}finally{t.delete(e)}}if(typeof e=="object"){let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)throw new Error("JSON can contain only plain objects");if(Object.getOwnPropertySymbols(e).length>0)throw new Error("JSON objects cannot contain symbol properties");if(t.has(e))throw new Error("JSON cannot contain circular references");t.add(e);let n={};try{for(let[o,s]of Object.entries(e))vi(o),s!==void 0&&Object.defineProperty(n,o,{value:Yt(s,t),enumerable:!0,configurable:!0,writable:!0})}finally{t.delete(e)}return n}throw new Error("Value cannot be represented as JSON")},uu=e=>Yt(e,new Set),J=e=>{let t=ie(uu(e));if(t===void 0)throw new Error("Value cannot be represented as canonical JSON");return t},Ie=(e,t)=>e<t?-1:e>t?1:0,Ht=async e=>{let t=typeof e=="string"?_e(e):e,r=await globalThis.crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(r),n=>n.toString(16).padStart(2,"0")).join("")},er=async e=>`sha256:${await Ht(e)}`;var zi=e=>J(pi.parse(e)),$i=e=>[...new Set(Object.values(e.assetReferences??{}).flat().map(({assetId:t})=>t))].sort();var ue=class extends Error{code;constructor(t,r){super(r),this.name="MarkdownMetadataError",this.code=t}};var Te=new Uint8Array([239,187,191]),rd=Te.byteLength+10,lu=(e,t,r=0)=>e.byteLength-r<t.byteLength?!1:t.every((n,o)=>e[r+o]===n),ki=(e,t)=>{let r=0;if(lu(e,Te))r=Te.byteLength;else if(e.byteLength<Te.byteLength&&Te.slice(0,e.byteLength).every((s,i)=>s===e[i]))return t?null:void 0;if(e.byteLength<r+4)return t?null:void 0;if(e[r]!==45||e[r+1]!==45||e[r+2]!==45)return null;let n=r+3;if(e[n]===10)n+=1;else if(e[n]===13){if(e.byteLength===n+1)return t?null:void 0;if(e[n+1]!==10)return null;n+=2}else return null;let o=n;for(let s=n;s<=e.byteLength;s+=1){let i=s===e.byteLength;if(i===!1&&e[s]!==10)continue;if(i&&t===!1)return;let c=s;if(c>o&&e[c-1]===13&&(c-=1),c-o===3&&(e[o]===45&&e[o+1]===45&&e[o+2]===45||e[o]===46&&e[o+1]===46&&e[o+2]===46))return{yamlStart:n,yamlEnd:o,blockEnd:i?s:s+1};o=s+1}};var Ai=async(e,t=x.hydratedFileBytes)=>{if(Number.isInteger(t)===!1||t<=0||t>x.hydratedFileBytes)throw new ue("MARKDOWN_BODY_BYTES_EXCEEDED","Markdown body byte limit is outside the supported range");let r;try{r=await ct(e,t)}catch(c){throw c instanceof ce?new ue("MARKDOWN_BODY_BYTES_EXCEEDED","Markdown content exceeds the byte limit"):c}let n;try{n=ae(r)}catch{throw new ue("MARKDOWN_BODY_DECODING_FAILED","Markdown content is not valid UTF-8")}let s=ki(r,!0)?.blockEnd??0,i;try{i=s===0?wi(n):ae(r.subarray(s))}catch{throw new ue("MARKDOWN_BODY_DECODING_FAILED","Markdown content is not valid UTF-8")}return{body:i,bodyBytes:ne(i),sourceBytes:r.byteLength}};var Zi=async(e,t,r)=>{if(Number.isSafeInteger(t)===!1||t<=0)throw new Error("Concurrency must be a positive safe integer");let n=0,o=new Array(e.length),s=async()=>{for(;n<e.length;){let u=n;n+=1,o[u]=await r(e[u])}},i=Array.from({length:Math.min(t,e.length)},s),a=(await Promise.allSettled(i)).find(u=>u.status==="rejected");if(a!==void 0)throw a.reason;return o};var pu=(e,t)=>{if(t===void 0||t.length===0)return e;let r=new URL("https://content.webstudio.invalid/__assets__/"),n=new URL(e,r),o=new URL(t,r);for(let[c,a]of o.searchParams)n.searchParams.append(c,a);if(o.hash!==""&&(n.hash=o.hash),URL.canParse(e))return n.href;if(e.startsWith("//"))return`//${n.host}${n.pathname}${n.search}${n.hash}`;if(e.startsWith("/"))return`${n.pathname}${n.search}${n.hash}`;let s=r.pathname;return`${n.pathname.startsWith(s)?n.pathname.slice(s.length):n.pathname}${n.search}${n.hash}`},Si=({markdown:e,references:t,assetUrls:r})=>{let n=e.length,o=e;for(let s of[...t].sort((i,c)=>c.start-i.start)){if(s.start<0||s.end<=s.start||s.end>e.length||s.end>n)throw new Error("Markdown asset reference range is invalid");n=s.start;let i=r[s.assetId];if(i===void 0)continue;let c=pu(i,s.suffix);o=`${o.slice(0,s.start)}${c}${o.slice(s.end)}`}return o};var D=class extends Error{code;details;constructor({code:t,message:r,details:n}){super(r),this.name="AssetResourceHydrationError",this.code=t,this.details=n}},du=e=>{if(e===null)return[];let t=Array.isArray(e)?e:[e],r=new Map;for(let n of t){if(typeof n!="object"||n===null||!("_id"in n)||typeof n._id!="string"||!("revision"in n)||typeof n.revision!="string"||!("contentRef"in n)||typeof n.contentRef!="string")throw new D({code:"CONTENT_IDENTITY_REQUIRED",message:"Hydrated query results must retain _id, revision, and contentRef"});let o=r.get(n._id);if(o!==void 0&&(o.revision!==n.revision||o.contentRef!==n.contentRef))throw new D({code:"CONTENT_IDENTITY_REQUIRED",message:"A selected asset ID has conflicting content identity",details:{assetId:n._id}});r.set(n._id,{_id:n._id,revision:n.revision,contentRef:n.contentRef})}return Array.from(r.values())},fu=e=>typeof e.mimeType=="string"&&(e.mimeType.startsWith("text/")||["application/json","application/javascript","application/xml","image/svg+xml"].includes(e.mimeType)),mu=async({read:e,contentRef:t,range:r,maximumBytes:n})=>{if(n===0)return new Uint8Array;let o=await e(t,r);try{return await ct(o.data,n)}catch(s){throw s instanceof ce?new D({code:"CONTENT_LIMIT_EXCEEDED",message:"Asset storage returned more content than requested"}):s}},hu=e=>{try{return ae(e)}catch{throw new D({code:"CONTENT_DECODING_FAILED",message:"Selected asset content is not valid UTF-8"})}},yu=(e,t)=>{if(t.mode==="range")return Math.max(0,Math.min(t.length,e.size-t.offset));let r=t.maxBytes??x.hydratedFileBytes;if(e.size>r)throw new D({code:"CONTENT_LIMIT_EXCEEDED",message:"Selected asset exceeds the per-file content limit",details:{assetId:e._id,assetBytes:e.size,fileByteLimit:r}});return e.size},Ei=async({result:e,documents:t,options:r,read:n,assetReferences:o,assetUrls:s})=>{if(r.mode==="none")return{content:{},hydratedFileCount:0,hydratedBytes:0};let i=du(e);if(i.length>x.hydratedFileCount)throw new D({code:"CONTENT_LIMIT_EXCEEDED",message:"Too many selected assets requested content hydration",details:{fileCount:i.length,fileCountLimit:x.hydratedFileCount}});let c=new Map(t.map(p=>[p._id,p])),a=i.map(p=>{let m=c.get(p._id);if(m===void 0||m.revision!==p.revision||m.contentRef!==p.contentRef||typeof m.size!="number"||typeof m.mimeType!="string")throw new D({code:"CONTENT_IDENTITY_REQUIRED",message:"Selected asset content identity is stale or unavailable",details:{assetId:p._id}});let d={...m,size:m.size,mimeType:m.mimeType};if(fu(d)===!1)throw new D({code:"CONTENT_NOT_TEXT",message:"Selected binary asset cannot be embedded as text",details:{assetId:p._id,mimeType:d.mimeType}});return{identity:p,document:d,readLength:yu(d,r)}}),u=a.reduce((p,m)=>p+m.readLength,0);if(u>x.hydratedTotalBytes)throw new D({code:"CONTENT_LIMIT_EXCEEDED",message:"Selected assets exceed the total hydrated-content limit",details:{totalReadBytes:u,totalByteLimit:x.hydratedTotalBytes}});let f=await Zi(a,x.concurrentContentReads,async p=>{let m=r.mode==="range"?{offset:r.offset,length:p.readLength}:p.readLength===0?void 0:{offset:0,length:p.readLength},d=await mu({read:n,contentRef:p.identity.contentRef,range:m,maximumBytes:p.readLength});if(d.byteLength!==p.readLength)throw new D({code:"CONTENT_IDENTITY_REQUIRED",message:"Selected asset bytes do not match canonical metadata",details:{assetId:p.identity._id}});let y;if(r.mode==="markdown-body")try{y=(await Ai(d,p.readLength||1)).body;let w=o?.[p.identity.contentRef];w!==void 0&&s!==void 0&&(y=Si({markdown:y,references:w,assetUrls:s}))}catch{throw new D({code:"CONTENT_DECODING_FAILED",message:"Selected Markdown body could not be decoded",details:{assetId:p.identity._id}})}else y=hu(d);let O=ne(y);return{id:p.identity._id,returnedBytes:O,content:{...p.identity,encoding:"utf-8",text:y,...r.mode==="range"?{range:{offset:r.offset,length:d.byteLength,total:p.document.size}}:{}}}});return{content:Object.fromEntries(f.map(({id:p,content:m})=>[p,m])),hydratedFileCount:a.length,hydratedBytes:f.reduce((p,{returnedBytes:m})=>p+m,0)}};var _d=g().datetime({offset:!0}).transform(e=>new Date(e).toISOString());var gu=/^[A-Za-z_][A-Za-z0-9_]*$/,Ri=(e,t)=>gu.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`;var Pi=({document:e,includes:t})=>{let r={};for(let n of hi){let o=e[n];o!==void 0&&t(n)&&(r[n]=o)}return r},Oi=({source:e,target:t,path:r})=>{let[n,...o]=r;if(n===void 0||Object.hasOwn(e,n)===!1)return;let s=e[n];if(o.length===0){Object.defineProperty(t,n,{value:s,enumerable:!0,configurable:!0,writable:!0});return}if(typeof s!="object"||s===null||Array.isArray(s))return;let i={};if(Oi({source:s,target:i,path:o}),Object.keys(i).length===0)return;let c=t[n];Object.defineProperty(t,n,{value:{...typeof c=="object"&&c!==null&&Array.isArray(c)===!1?c:{},...i},enumerable:!0,configurable:!0,writable:!0})},Ci=({properties:e,fields:t})=>{let r={};for(let n of t)n[0]==="properties"&&Oi({source:e,target:r,path:n.slice(1)});return r};var K=class extends Error{constructor(t,r){super(t,r),this.name="AssetQueryExecutionError"}},be=class extends Error{constructor(){super("The requested asset index revision is stale"),this.name="AssetIndexRevisionError"}},Ii=e=>{if(e[0]!=="properties")return e[0];let t="properties";for(let r of e.slice(1))t=Ri(t,r);return t},Ti=({filter:e,fieldTypes:t})=>_i(t).includes(e.operator),Di=(e,t)=>Object.hasOwn(e.fields,t)?e.fields[t]:void 0,_u=({query:e,catalog:t})=>{let r=ge.parse(e),n=new Map,o=[];for(let s of si(r.where)){let i=Ii(s.field);if(n.set(i,s.field),s.field[0]==="properties"){let c=Di(t,i);c===void 0?o.push(`Asset field ${i} is not currently observed`):Ti({filter:s,fieldTypes:c.types})===!1&&o.push(`Operator ${s.operator} is not compatible with the currently observed types of ${i}`)}else if(Ti({filter:s,fieldTypes:Kt[s.field[0]]})===!1)throw new K(`Operator ${s.operator} is incompatible with ${i}`)}for(let s of r.sort){let i=Ii(s.field);if(n.set(i,s.field),s.field[0]==="properties"){let c=Di(t,i);c===void 0?o.push(`Asset field ${i} is not currently observed`):c.types.some(a=>a==="object"||a==="array")&&o.push(`Asset field ${i} currently includes structured values that use deterministic JSON sort order`)}}return{query:r,referencedFieldPaths:[...n.values()],warnings:[...new Set(o)]}},tr=(e,t,r)=>{let n=t[0]==="id"?e._id:it(t[0])?r?.[t[0]]:e[t[0]];for(let o of t.slice(1)){if(typeof n!="object"||n===null||Object.hasOwn(n,o)===!1)return;n=n[o]}return n},at=(e,t)=>e===void 0||t===void 0?e===t:J(e)===J(t),xu=e=>typeof e=="string"||Array.isArray(e)?e.length===0:typeof e=="object"&&e!==null&&Object.keys(e).length===0,bu=(e,t)=>{if(typeof e=="number"&&typeof t=="number")return e-t;if(typeof e=="string"&&typeof t=="string")return Ie(e,t)},wu=(e,t,r)=>{let n=tr(e,t.field,r);if(t.operator==="exists")return n!=null===t.value;if(t.operator==="isEmpty")return xu(n)===t.value;if(t.operator==="eq")return at(n,t.value);if(t.operator==="ne")return at(n,t.value)===!1;if(t.operator==="in")return t.value.some(s=>at(n,s));if(t.operator==="contains")return typeof n=="string"&&typeof t.value=="string"?n.includes(t.value):Array.isArray(n)&&n.some(s=>at(s,t.value));if(t.operator==="startsWith")return typeof n=="string"&&typeof t.value=="string"&&n.startsWith(t.value);if(t.operator==="endsWith")return typeof n=="string"&&typeof t.value=="string"&&n.endsWith(t.value);let o=bu(n,t.value);return o===void 0?!1:t.operator==="gt"?o>0:t.operator==="gte"?o>=0:t.operator==="lt"?o<0:o<=0},vu=(e,t,r)=>ot(t,n=>wu(e,n,r))===!0,zu=(e,t)=>{let r=e==null,n=t==null;return r||n?r===n?0:r?1:-1:typeof e=="number"&&typeof t=="number"?e-t:(typeof e=="string"||typeof e=="boolean")&&(typeof t=="string"||typeof t=="boolean")?Ie(String(e),String(t)):Ie(J(e),J(t))},$u=({left:e,right:t,sort:r,runtimeAssets:n})=>{for(let o of r){let s=zu(tr(e,o.field,n?.[e._id]),tr(t,o.field,n?.[t._id]));if(s!==0)return o.direction==="asc"?s:-s}return Ie(e._id,t._id)};var ku=(e,t)=>{if(e.properties===void 0)return;if(t.mode==="all")return Object.keys(e.properties).length===0?void 0:e.properties;if(t.mode!=="fields"||t.fields.some(n=>n[0]==="properties")===!1)return;let r=Ci({properties:e.properties,fields:t.fields});return Object.keys(r).length===0?void 0:r},xe=(e,t)=>e.includeMetadata&&yi(t)||e.mode==="fields"&&e.fields.some(r=>r.length===1&&r[0]===t),Au=e=>e.mode==="all"||e.mode==="fields"&&e.fields.some(t=>t.length===1&&t[0]==="excerpt"),Zu=(e,t,r)=>{if(xe(t,"url")&&r===void 0)throw new Error(`Asset URL is unavailable for ${e._id}`);let n=ku(e,t),o=r?.width!==void 0&&r.height!==void 0;return{...r!==void 0&&xe(t,"url")?{url:r.url}:{},...o&&xe(t,"width")?{width:r.width}:{},...o&&xe(t,"height")?{height:r.height}:{},...Pi({document:e,includes:s=>xe(t,s)}),...n===void 0?{}:{properties:n},...e.excerpt===void 0||Au(t)===!1?{}:{excerpt:e.excerpt},...e.metadataError===void 0||t.includeMetadata===!1?{}:{metadataError:e.metadataError}}},Su=e=>{if(ne(J(e))>x.resultBytes)throw new K("Asset query result exceeds the byte limit")},Ni=async({query:e,catalog:t,documents:r,read:n,runtimeAssets:o,assetReferences:s})=>{let{query:i}=_u({query:e,catalog:t});if(r.length>x.candidateDocuments)throw new K("Asset query document limit was exceeded");let c=r.flatMap(d=>{let y=o?.[d._id];if(vu(d,i.where,y)===!1)return[];let O=Zu(d,i.output,y);return i.content.mode==="none"&&Object.keys(O).length===0&&xe(i.output,"id")===!1?[]:[{document:d,item:{id:d._id,...O}}]}),u=[...c].sort((d,y)=>$u({left:d.document,right:y.document,sort:i.sort,runtimeAssets:o})).slice(i.offset,i.offset+i.limit),f=u.map(({document:d})=>d),p=u.map(({item:d})=>d);if(i.content.mode!=="none"){let d=i.content;if(n===void 0)throw new K("Asset content reader is unavailable");let y=await Ei({result:f,documents:f,options:d,read:n,assetReferences:s,assetUrls:s===void 0?void 0:Object.fromEntries(Object.entries(o??{}).map(([O,w])=>[O,w.url]))});p=f.map((O,w)=>{let j=y.content[O._id];if(j===void 0)throw new K("Selected asset content could not be read");return{...p[w],content:{encoding:j.encoding,text:j.text,...j.range===void 0?{}:{range:j.range}}}})}let m={items:p,totalCount:c.length,hasMore:i.offset+u.length<c.length};return Su(m),m};var Eu=async e=>await er(J(ge.parse(e)));var Ru=({item:e,field:t,value:r})=>{let n=e;for(let[o,s]of t.entries()){if(o===t.length-1){Object.defineProperty(n,s,{value:r,enumerable:!0,configurable:!0,writable:!0});return}let i=Object.hasOwn(n,s)?n[s]:void 0;if(typeof i=="object"&&i!==null){n=i;continue}let c={};Object.defineProperty(n,s,{value:c,enumerable:!0,configurable:!0,writable:!0}),n=c}},Pu=e=>Xt.parse({items:e.rows.map(t=>{let r={};for(let[n,o]of e.fields.entries())Ru({item:r,field:o,value:t[n]});return r}),totalCount:e.totalCount,hasMore:e.hasMore}),Fi=async({queries:e,query:t})=>{if(e===void 0)return;let r=e[await Eu(ge.parse(t))];return r===void 0?void 0:Pu(r)};var rr=({artifact:e,readContent:t})=>{let r=e.database?.includedDocumentCount??e.documents.length,o=(e.database?.sourceDocumentCount??r)-r,s=ne(zi(e)),i=e.database?.maxBytes??Number.MAX_SAFE_INTEGER,c=e.database?.unboundedBytes??s,a={format:e.format,version:e.version,revision:e.integrity.checksum,usedBytes:s,maxBytes:i,unboundedBytes:c,includedDocumentCount:r,omittedDocumentCount:o,omissionReason:o===0?void 0:c>i?"size":"unavailable",truncated:o>0};return{query:async(u,f,p)=>{if(u.indexRevision!==void 0&&u.indexRevision!==e.integrity.checksum)throw new be;let m=await Fi({queries:e.queries,query:u.query});if(m!==void 0)return m;let d=async(O,w)=>{let j=e.contents?.[O];if(j===void 0){let $=f??t;if($===void 0)throw new Error("Content is not embedded in this database");return await $(O,w)}let Fe=_e(j),N=w===void 0?Fe:Fe.slice(w.offset,w.offset+w.length);return{data:async function*(){yield N}(),contentLength:N.byteLength}};return await Ni({query:u.query,catalog:e.fieldCatalog,documents:e.documents,read:d,runtimeAssets:p,assetReferences:e.assetReferences})},getFieldCatalog:()=>e.fieldCatalog,getStats:()=>a}};var ut=class extends Error{constructor(t,r){super(t,r),this.name="AssetQueryRequestError"}},De=class extends Error{},Ou=async(e,t)=>{if(Number.isSafeInteger(t)===!1||t<0)throw new TypeError("Request byte limit must be a non-negative integer");let r=Number(e.headers.get("content-length"));if(Number.isFinite(r)&&r>t)throw new De("Request exceeds the byte limit");let n=e.body?.getReader(),o=[],s=0;if(n!==void 0)for(;;){let{done:a,value:u}=await n.read();if(a)break;if(s+=u.byteLength,s>t){try{await n.cancel()}catch{}throw new De("Request exceeds the byte limit")}o.push(u)}let i=new Uint8Array(s),c=0;for(let a of o)i.set(a,c),c+=a.byteLength;return i},ji=async e=>{let t;try{t=await Ou(e,x.requestBytes)}catch(r){throw r instanceof De?new ut("Asset query request exceeds the byte limit",{cause:r}):r}try{return xi.parse(JSON.parse(ae(t)))}catch(r){throw new ut("Asset query request is invalid",{cause:r})}};var Li=e=>{if(e instanceof be)return{code:"STALE_INDEX",message:e.message,retryable:!1,status:409};if(e instanceof K)return{code:"INVALID_REQUEST",message:e.message,retryable:!1,status:400};if(e instanceof D)return{code:e.code,message:e.message,retryable:!1,details:e.details,status:400}};var Cu="/$resources/assets",Mi=(e,t=200)=>new Response(JSON.stringify(e),{status:t,headers:{"content-type":"application/json; charset=utf-8"}}),Ne=({code:e,message:t,status:r,retryable:n=!1,details:o})=>Mi(bi({code:e,message:t,retryable:n,details:o}),r),Iu=(e,t,r)=>typeof e=="string"||e instanceof URL?new Request(new URL(e,t),r):new Request(e,r),Tu=async({deploymentId:e,artifact:t,request:r})=>{let n=await r.clone().text(),o=r.headers.get("cache-control"),s=await Ht(JSON.stringify([e,t.integrity.checksum,n,o])),i=new URL(r.url);return i.searchParams.set("ws-asset-resource",s),new Request(i,{method:"GET"})},Yd=({deploymentId:e,artifact:t,runtimeAssets:r,cache:n,baseUrl:o})=>(Qi({artifact:t,runtimeAssets:r}),Ui({deploymentId:e,artifact:t,runtimeAssets:r,cache:n,baseUrl:o,database:rr({artifact:t})})),Qi=({artifact:e,runtimeAssets:t})=>{let r=$i(e).find(n=>t[n]===void 0);if(r!==void 0)throw new Error(`Published referenced asset URL is unavailable for ${r}`)},Ui=({deploymentId:e,artifact:t,runtimeAssets:r,cache:n,baseUrl:o,database:s})=>{let i=new URL(o).origin;return async(c,a)=>{let u=Iu(c,o,a),f=new URL(u.url);if(f.origin!==i||f.pathname!==Cu||u.method.toUpperCase()!=="POST")return;let p;try{p=await ji(u.clone())}catch{return Ne({code:"INVALID_REQUEST",message:"Asset resource request is invalid",status:400})}let m=n===void 0||u.headers.has("cache-control")===!1?void 0:await Tu({deploymentId:e,artifact:t,request:u});if(m!==void 0&&n!==void 0){let d=await n.match(m).catch(()=>{});if(d!==void 0)return new Response(d.body,d)}try{if(u.signal.aborted)return Ne({code:"REQUEST_CANCELLED",message:"Published asset query was cancelled",status:499});let d=Mi(await s.query(p,void 0,r));return m!==void 0&&n!==void 0&&u.signal.aborted===!1&&(d.headers.set("cache-control",u.headers.get("cache-control")),await n.put(m,d.clone()).catch(()=>{})),d}catch(d){if(u.signal.aborted)return Ne({code:"REQUEST_CANCELLED",message:"Published asset query was cancelled",status:499});let y=Li(d);return Ne(y!==void 0?y:{code:"INTERNAL_ERROR",message:"Published asset query failed",status:500,retryable:!0})}}},Hd=({deploymentId:e,artifact:t,runtimeAssets:r})=>{let n=globalThis.caches,o,s=()=>(o??=n.open(`webstudio-assets-${e}`),o),i=n===void 0?void 0:{match:async a=>(await s()).match(a),put:async(a,u)=>(await s()).put(a,u)};Qi({artifact:t,runtimeAssets:r});let c=rr({artifact:t});return async({request:a,fallback:u})=>{let f=new URL(a.url).origin,p=Ui({deploymentId:e,artifact:t,runtimeAssets:r,cache:i,baseUrl:f,database:c});return async(m,d)=>await p(m,d)??u(m,d)}};export{Hd as createGeneratedAssetResourceRuntime,Yd as createPublishedAssetResourceFetch};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webstudio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.283.0",
|
|
4
4
|
"description": "Webstudio CLI",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"warn-once": "^0.1.1",
|
|
45
45
|
"yargs": "^17.7.2",
|
|
46
46
|
"zod": "^4.4.3",
|
|
47
|
-
"@webstudio-is/
|
|
48
|
-
"@webstudio-is/
|
|
49
|
-
"@webstudio-is/
|
|
50
|
-
"@webstudio-is/
|
|
47
|
+
"@webstudio-is/http-client": "0.283.0",
|
|
48
|
+
"@webstudio-is/project-migrations": "0.283.0",
|
|
49
|
+
"@webstudio-is/sync-client": "0.0.0",
|
|
50
|
+
"@webstudio-is/protocol": "0.283.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@cloudflare/vite-plugin": "^1.1.0",
|
|
@@ -85,25 +85,30 @@
|
|
|
85
85
|
"vite": "^6.3.4",
|
|
86
86
|
"vitest": "^3.1.2",
|
|
87
87
|
"wrangler": "^3.63.2",
|
|
88
|
-
"@webstudio-is/
|
|
89
|
-
"@webstudio-is/
|
|
90
|
-
"@webstudio-is/
|
|
88
|
+
"@webstudio-is/css-engine": "0.283.0",
|
|
89
|
+
"@webstudio-is/content-engine": "0.283.0",
|
|
90
|
+
"@webstudio-is/expression": "0.283.0",
|
|
91
|
+
"@webstudio-is/fonts": "0.283.0",
|
|
92
|
+
"@webstudio-is/image": "0.283.0",
|
|
91
93
|
"@webstudio-is/project-build": "0.0.0",
|
|
92
|
-
"@webstudio-is/
|
|
93
|
-
"@webstudio-is/sdk
|
|
94
|
-
"@webstudio-is/sdk
|
|
95
|
-
"@webstudio-is/react
|
|
96
|
-
"@webstudio-is/sdk-components-react-
|
|
97
|
-
"@webstudio-is/sdk-components-
|
|
98
|
-
"@webstudio-is/
|
|
99
|
-
"@webstudio-is/sdk-components-
|
|
100
|
-
"@webstudio-is/
|
|
101
|
-
"@webstudio-is/
|
|
94
|
+
"@webstudio-is/query-builder": "0.283.0",
|
|
95
|
+
"@webstudio-is/react-sdk": "0.283.0",
|
|
96
|
+
"@webstudio-is/sdk": "0.283.0",
|
|
97
|
+
"@webstudio-is/sdk-components-react": "0.283.0",
|
|
98
|
+
"@webstudio-is/sdk-components-react-radix": "0.283.0",
|
|
99
|
+
"@webstudio-is/sdk-components-animation": "0.283.0",
|
|
100
|
+
"@webstudio-is/sdk-components-react-router": "0.283.0",
|
|
101
|
+
"@webstudio-is/sdk-components-react-remix": "0.283.0",
|
|
102
|
+
"@webstudio-is/sdk-components-registry": "0.283.0",
|
|
103
|
+
"@webstudio-is/wsauth": "0.283.0",
|
|
104
|
+
"@webstudio-is/tsconfig": "1.0.7"
|
|
102
105
|
},
|
|
103
106
|
"scripts": {
|
|
104
107
|
"typecheck": "tsc --noEmit",
|
|
105
108
|
"generate-docs": "tsx scripts/generate-docs.ts && oxfmt src/docs.generated.ts",
|
|
106
|
-
"build": "
|
|
109
|
+
"build:content-runtime": "esbuild @webstudio-is/content-engine/runtime --bundle --format=esm --platform=browser --target=es2022 --conditions=webstudio --minify --outfile=lib/content-runtime.js",
|
|
110
|
+
"build": "pnpm generate-docs && rm -rf lib && vite build && pnpm build:content-runtime",
|
|
111
|
+
"pretest": "mkdir -p lib && pnpm build:content-runtime",
|
|
107
112
|
"evaluations": "tsx --conditions=webstudio evaluations/high-impact/run-local-agent.ts",
|
|
108
113
|
"test": "vitest run",
|
|
109
114
|
"test:release-smoke": "pnpm build && tsx --conditions=webstudio scripts/release-smoke.ts",
|
|
@@ -44,8 +44,8 @@ import {
|
|
|
44
44
|
import * as constants from "__CONSTANTS__";
|
|
45
45
|
import css from "__CSS__?url";
|
|
46
46
|
import { sitemap } from "__SITEMAP__";
|
|
47
|
-
import { assets } from "__ASSETS__";
|
|
48
47
|
import { authRoutes } from "__AUTH__";
|
|
48
|
+
import { createGeneratedAssetResourceFetch } from "__ASSET_QUERY_RUNTIME__";
|
|
49
49
|
|
|
50
50
|
const authenticateProductionRequest = (request: Request) => {
|
|
51
51
|
const host =
|
|
@@ -95,12 +95,6 @@ const customFetch: typeof fetch = (input, init) => {
|
|
|
95
95
|
return Promise.resolve(response);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
if (isLocalResource(input, "assets")) {
|
|
99
|
-
const response = new Response(JSON.stringify(assets));
|
|
100
|
-
response.headers.set("content-type", "application/json; charset=utf-8");
|
|
101
|
-
return Promise.resolve(response);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
98
|
return cachedFetch(projectId, input, init);
|
|
105
99
|
};
|
|
106
100
|
|
|
@@ -123,9 +117,16 @@ export const loader = async (arg: LoaderFunctionArgs) => {
|
|
|
123
117
|
pathname: url.pathname,
|
|
124
118
|
};
|
|
125
119
|
|
|
120
|
+
const generatedFetch = await createGeneratedAssetResourceFetch({
|
|
121
|
+
request: arg.request,
|
|
122
|
+
context: arg.context,
|
|
123
|
+
fallback: customFetch,
|
|
124
|
+
});
|
|
126
125
|
const resources = await loadResources(
|
|
127
|
-
|
|
128
|
-
getResources({ system }).data
|
|
126
|
+
generatedFetch,
|
|
127
|
+
getResources({ system }).data,
|
|
128
|
+
url,
|
|
129
|
+
{ signal: arg.request.signal }
|
|
129
130
|
);
|
|
130
131
|
const pageMeta = getPageMeta({ system, resources });
|
|
131
132
|
|
|
@@ -4,8 +4,8 @@ import { authenticateRequest } from "@webstudio-is/wsauth";
|
|
|
4
4
|
import { projectDomain } from "__CLIENT__";
|
|
5
5
|
import { getPageMeta, getRemixParams, getResources } from "__SERVER__";
|
|
6
6
|
import { sitemap } from "__SITEMAP__";
|
|
7
|
-
import { assets } from "__ASSETS__";
|
|
8
7
|
import { authRoutes } from "__AUTH__";
|
|
8
|
+
import { createGeneratedAssetResourceFetch } from "__ASSET_QUERY_RUNTIME__";
|
|
9
9
|
|
|
10
10
|
const authenticateProductionRequest = (request: Request) => {
|
|
11
11
|
const host =
|
|
@@ -53,12 +53,6 @@ const customFetch: typeof fetch = (input, init) => {
|
|
|
53
53
|
return Promise.resolve(response);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
if (isLocalResource(input, "assets")) {
|
|
57
|
-
const response = new Response(JSON.stringify(assets));
|
|
58
|
-
response.headers.set("content-type", "application/json; charset=utf-8");
|
|
59
|
-
return Promise.resolve(response);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
56
|
return fetch(input, init);
|
|
63
57
|
};
|
|
64
58
|
|
|
@@ -82,9 +76,16 @@ export const loader = async (arg: LoaderFunctionArgs) => {
|
|
|
82
76
|
pathname: url.pathname,
|
|
83
77
|
};
|
|
84
78
|
|
|
79
|
+
const generatedFetch = await createGeneratedAssetResourceFetch({
|
|
80
|
+
request: arg.request,
|
|
81
|
+
context: arg.context,
|
|
82
|
+
fallback: customFetch,
|
|
83
|
+
});
|
|
85
84
|
const resources = await loadResources(
|
|
86
|
-
|
|
87
|
-
getResources({ system }).data
|
|
85
|
+
generatedFetch,
|
|
86
|
+
getResources({ system }).data,
|
|
87
|
+
url,
|
|
88
|
+
{ signal: arg.request.signal }
|
|
88
89
|
);
|
|
89
90
|
const pageMeta = getPageMeta({ system, resources });
|
|
90
91
|
|
|
@@ -10,8 +10,8 @@ import { Page, breakpoints, projectDomain } from "__CLIENT__";
|
|
|
10
10
|
import { getPageMeta, getRemixParams, getResources } from "__SERVER__";
|
|
11
11
|
import { assetBaseUrl, imageLoader } from "__CONSTANTS__";
|
|
12
12
|
import { sitemap } from "__SITEMAP__";
|
|
13
|
-
import { assets } from "__ASSETS__";
|
|
14
13
|
import { authRoutes } from "__AUTH__";
|
|
14
|
+
import { createGeneratedAssetResourceFetch } from "__ASSET_QUERY_RUNTIME__";
|
|
15
15
|
|
|
16
16
|
const authenticateProductionRequest = (request: Request) => {
|
|
17
17
|
const host =
|
|
@@ -61,12 +61,6 @@ const customFetch: typeof fetch = (input, init) => {
|
|
|
61
61
|
return Promise.resolve(response);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
if (isLocalResource(input, "assets")) {
|
|
65
|
-
const response = new Response(JSON.stringify(assets));
|
|
66
|
-
response.headers.set("content-type", "application/json; charset=utf-8");
|
|
67
|
-
return Promise.resolve(response);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
64
|
return fetch(input, init);
|
|
71
65
|
};
|
|
72
66
|
|
|
@@ -90,9 +84,16 @@ export const loader = async (arg: LoaderFunctionArgs) => {
|
|
|
90
84
|
pathname: url.pathname,
|
|
91
85
|
};
|
|
92
86
|
|
|
87
|
+
const generatedFetch = await createGeneratedAssetResourceFetch({
|
|
88
|
+
request: arg.request,
|
|
89
|
+
context: arg.context,
|
|
90
|
+
fallback: customFetch,
|
|
91
|
+
});
|
|
93
92
|
const resources = await loadResources(
|
|
94
|
-
|
|
95
|
-
getResources({ system }).data
|
|
93
|
+
generatedFetch,
|
|
94
|
+
getResources({ system }).data,
|
|
95
|
+
url,
|
|
96
|
+
{ signal: arg.request.signal }
|
|
96
97
|
);
|
|
97
98
|
const pageMeta = getPageMeta({ system, resources });
|
|
98
99
|
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
"@remix-run/node": "2.16.5",
|
|
12
12
|
"@remix-run/react": "2.16.5",
|
|
13
13
|
"@remix-run/server-runtime": "2.16.5",
|
|
14
|
-
"@webstudio-is/image": "0.
|
|
15
|
-
"@webstudio-is/react-sdk": "0.
|
|
16
|
-
"@webstudio-is/sdk": "0.
|
|
17
|
-
"@webstudio-is/sdk-components-react": "0.
|
|
18
|
-
"@webstudio-is/sdk-components-animation": "0.
|
|
19
|
-
"@webstudio-is/sdk-components-react-radix": "0.
|
|
20
|
-
"@webstudio-is/sdk-components-react-remix": "0.
|
|
21
|
-
"@webstudio-is/wsauth": "0.
|
|
14
|
+
"@webstudio-is/image": "0.283.0",
|
|
15
|
+
"@webstudio-is/react-sdk": "0.283.0",
|
|
16
|
+
"@webstudio-is/sdk": "0.283.0",
|
|
17
|
+
"@webstudio-is/sdk-components-react": "0.283.0",
|
|
18
|
+
"@webstudio-is/sdk-components-animation": "0.283.0",
|
|
19
|
+
"@webstudio-is/sdk-components-react-radix": "0.283.0",
|
|
20
|
+
"@webstudio-is/sdk-components-react-remix": "0.283.0",
|
|
21
|
+
"@webstudio-is/wsauth": "0.283.0",
|
|
22
22
|
"isbot": "^5.1.25",
|
|
23
23
|
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
24
24
|
"react-dom": "18.3.0-canary-14898b6a9-20240318"
|
|
@@ -43,8 +43,8 @@ import {
|
|
|
43
43
|
import * as constants from "__CONSTANTS__";
|
|
44
44
|
import css from "__CSS__?url";
|
|
45
45
|
import { sitemap } from "__SITEMAP__";
|
|
46
|
-
import { assets } from "__ASSETS__";
|
|
47
46
|
import { authRoutes } from "__AUTH__";
|
|
47
|
+
import { createGeneratedAssetResourceFetch } from "__ASSET_QUERY_RUNTIME__";
|
|
48
48
|
|
|
49
49
|
const authenticateProductionRequest = (request: Request) => {
|
|
50
50
|
const host =
|
|
@@ -94,12 +94,6 @@ const customFetch: typeof fetch = (input, init) => {
|
|
|
94
94
|
return Promise.resolve(response);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
if (isLocalResource(input, "assets")) {
|
|
98
|
-
const response = new Response(JSON.stringify(assets));
|
|
99
|
-
response.headers.set("content-type", "application/json; charset=utf-8");
|
|
100
|
-
return Promise.resolve(response);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
97
|
return cachedFetch(projectId, input, init);
|
|
104
98
|
};
|
|
105
99
|
|
|
@@ -122,9 +116,16 @@ export const loader = async (arg: LoaderFunctionArgs) => {
|
|
|
122
116
|
pathname: url.pathname,
|
|
123
117
|
};
|
|
124
118
|
|
|
119
|
+
const generatedFetch = await createGeneratedAssetResourceFetch({
|
|
120
|
+
request: arg.request,
|
|
121
|
+
context: arg.context,
|
|
122
|
+
fallback: customFetch,
|
|
123
|
+
});
|
|
125
124
|
const resources = await loadResources(
|
|
126
|
-
|
|
127
|
-
getResources({ system }).data
|
|
125
|
+
generatedFetch,
|
|
126
|
+
getResources({ system }).data,
|
|
127
|
+
url,
|
|
128
|
+
{ signal: arg.request.signal }
|
|
128
129
|
);
|
|
129
130
|
const pageMeta = getPageMeta({ system, resources });
|
|
130
131
|
|