Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
fix: Resolve structured Asset paths in queries (#5995)
Oleg Isonen74d88a3fb2fe
diff --git a/docs/university/foundations/assets.md b/docs/university/foundations/assets.mdindex 156f9ecfa9..145c1c62c0 100644--- a/docs/university/foundations/assets.md+++ b/docs/university/foundations/assets.md@@ -52,6 +52,42 @@ Edits save when the editor loses focus or when you press `Command + S` onmacOS, `Ctrl + S` on Windows, or `Command/Ctrl + Enter`. The file extension isfixed, but you can rename its basename in Asset settings.+### Reference assets from structured content++Markdown frontmatter and JSON files can use relative paths to reference other+project assets. When an **Assets** resource queries the structured content,+Webstudio returns the referenced asset's published URL while keeping the+portable relative path in the source file.++For example, given these assets:++```text+blog/+ posts/+ article.md+ images/+ hero.png+```++The frontmatter in `article.md` can reference the image relative to the+document:++```yaml+---+featureImage: ./images/hero.png+---+```++Bind the queried `properties.featureImage` value directly to an image,+background image, social image, download link, or another URL property. The+same resolution works for nested properties and values in arrays. JSON files+can use relative paths in the same way.++Query strings and fragments are preserved, so values such as+`./images/hero.png?width=1200#cover` remain usable. Webstudio resolves a value+only when it uniquely matches a project asset. Absolute URLs, root-relative+URLs, missing paths, and ambiguous paths remain unchanged.+## Organizing assets with foldersCreate folders in the Assets panel to organize large asset libraries. Foldersdiff --git a/fixtures/react-router-cloudflare/.webstudio/data.json b/fixtures/react-router-cloudflare/.webstudio/data.jsonindex 018b75f45a..29ce4493cc 100644--- a/fixtures/react-router-cloudflare/.webstudio/data.json+++ b/fixtures/react-router-cloudflare/.webstudio/data.json@@ -1,5 +1,5 @@{- "bundleVersion": "bundle-7ljlhp",+ "bundleVersion": "bundle-i6o13q","build": {"id": "f565d527-32e7-4731-bc71-aca9e9574587","projectId": "d845c167-ea07-4875-b08d-83e97c09dcce",diff --git a/fixtures/react-router-docker/.webstudio/data.json b/fixtures/react-router-docker/.webstudio/data.jsonindex 018b75f45a..29ce4493cc 100644--- a/fixtures/react-router-docker/.webstudio/data.json+++ b/fixtures/react-router-docker/.webstudio/data.json@@ -1,5 +1,5 @@{- "bundleVersion": "bundle-7ljlhp",+ "bundleVersion": "bundle-i6o13q","build": {"id": "f565d527-32e7-4731-bc71-aca9e9574587","projectId": "d845c167-ea07-4875-b08d-83e97c09dcce",diff --git a/fixtures/react-router-netlify/.webstudio/data.json b/fixtures/react-router-netlify/.webstudio/data.jsonindex 018b75f45a..29ce4493cc 100644--- a/fixtures/react-router-netlify/.webstudio/data.json+++ b/fixtures/react-router-netlify/.webstudio/data.json@@ -1,5 +1,5 @@{- "bundleVersion": "bundle-7ljlhp",+ "bundleVersion": "bundle-i6o13q","build": {"id": "f565d527-32e7-4731-bc71-aca9e9574587","projectId": "d845c167-ea07-4875-b08d-83e97c09dcce",diff --git a/fixtures/react-router-vercel/.webstudio/data.json b/fixtures/react-router-vercel/.webstudio/data.jsonindex 018b75f45a..29ce4493cc 100644--- a/fixtures/react-router-vercel/.webstudio/data.json+++ b/fixtures/react-router-vercel/.webstudio/data.json@@ -1,5 +1,5 @@{- "bundleVersion": "bundle-7ljlhp",+ "bundleVersion": "bundle-i6o13q","build": {"id": "f565d527-32e7-4731-bc71-aca9e9574587","projectId": "d845c167-ea07-4875-b08d-83e97c09dcce",diff --git a/fixtures/ssg-cloudflare-pages/.webstudio/data.json b/fixtures/ssg-cloudflare-pages/.webstudio/data.jsonindex 91913915dc..90342a0b72 100644--- a/fixtures/ssg-cloudflare-pages/.webstudio/data.json+++ b/fixtures/ssg-cloudflare-pages/.webstudio/data.json@@ -1,5 +1,5 @@{- "bundleVersion": "bundle-7ljlhp",+ "bundleVersion": "bundle-i6o13q","build": {"id": "a2e8de30-03d5-4514-a3a6-406b3266a3af","projectId": "d845c167-ea07-4875-b08d-83e97c09dcce",diff --git a/fixtures/ssg-netlify-by-project-id/.webstudio/data.json b/fixtures/ssg-netlify-by-project-id/.webstudio/data.jsonindex fa26559da3..6d5ea9c7ed 100644--- a/fixtures/ssg-netlify-by-project-id/.webstudio/data.json+++ b/fixtures/ssg-netlify-by-project-id/.webstudio/data.json@@ -1,5 +1,5 @@{- "bundleVersion": "bundle-7ljlhp",+ "bundleVersion": "bundle-i6o13q","build": {"id": "8f0fdff2-e76b-4f86-9203-ea7df5f1143c","projectId": "8a7358b1-7de3-459d-b7b1-56dddfb6ce1e",diff --git a/fixtures/webstudio-cloudflare-template/.webstudio/data.json b/fixtures/webstudio-cloudflare-template/.webstudio/data.jsonindex 91913915dc..90342a0b72 100644--- a/fixtures/webstudio-cloudflare-template/.webstudio/data.json+++ b/fixtures/webstudio-cloudflare-template/.webstudio/data.json@@ -1,5 +1,5 @@{- "bundleVersion": "bundle-7ljlhp",+ "bundleVersion": "bundle-i6o13q","build": {"id": "a2e8de30-03d5-4514-a3a6-406b3266a3af","projectId": "d845c167-ea07-4875-b08d-83e97c09dcce",diff --git a/fixtures/webstudio-features/.webstudio/data.json b/fixtures/webstudio-features/.webstudio/data.jsonindex be5f6bb7af..5ef601b25e 100644--- a/fixtures/webstudio-features/.webstudio/data.json+++ b/fixtures/webstudio-features/.webstudio/data.json@@ -1,5 +1,5 @@{- "bundleVersion": "bundle-7ljlhp",+ "bundleVersion": "bundle-i6o13q","build": {"id": "1b66ee06-8ea5-4420-9a0e-e0d3a67aca32","projectId": "cddc1d44-af37-4cb6-a430-d300cf6f932d",diff --git a/fixtures/webstudio-features/app/__generated__/$resources.asset-query-vendor.js b/fixtures/webstudio-features/app/__generated__/$resources.asset-query-vendor.jsindex 393a4be808..f9ddd13be1 100644--- a/fixtures/webstudio-features/app/__generated__/$resources.asset-query-vendor.js+++ b/fixtures/webstudio-features/app/__generated__/$resources.asset-query-vendor.js@@ -1,6 +1,6 @@-var Af=Object.defineProperty;var Df=(e,t)=>{for(var n in t)Af(e,n,{get:t[n],enumerable:!0})};var vs;function g(e,t,n){function r(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,d=Object.keys(u);for(let l=0;l<d.length;l++){let f=d[l];f in c||(c[f]=u[f].bind(c))}}let o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var a;let u=n?.Parent?new s:this;r(u,c),(a=u._zod).deferred??(a.deferred=[]);for(let d of u._zod.deferred)d();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}var gh=Symbol("zod_brand"),De=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},_t=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(vs=globalThis).__zod_globalConfig??(vs.__zod_globalConfig={});var xt=globalThis.__zod_globalConfig;function he(e){return e&&Object.assign(xt,e),xt}var z={};Df(z,{BIGINT_FORMAT_RANGES:()=>Os,Class:()=>Yr,NUMBER_FORMAT_RANGES:()=>ro,aborted:()=>Xe,allowsEval:()=>eo,assert:()=>Nf,assertEqual:()=>If,assertIs:()=>Rf,assertNever:()=>$f,assertNotEqual:()=>Of,assignProp:()=>We,base64ToUint8Array:()=>$s,base64urlToUint8Array:()=>Yf,cached:()=>St,captureStackTrace:()=>Pn,cleanEnum:()=>Wf,cleanRegex:()=>Xt,clone:()=>ye,cloneDef:()=>zf,createTransparentProxy:()=>Bf,defineLazy:()=>C,esc:()=>zn,escapeRegex:()=>Be,explicitlyAborted:()=>oo,extend:()=>Qf,finalizeIssue:()=>fe,floatSafeRemainder:()=>Xr,getElementAtPath:()=>Pf,getEnumValues:()=>Wt,getLengthableOrigin:()=>Ht,getParsedType:()=>Ff,getSizableOrigin:()=>Rs,hexToUint8Array:()=>Hf,isObject:()=>dt,isPlainObject:()=>Ye,issue:()=>vt,joinValues:()=>Cf,jsonStringifyReplacer:()=>Et,merge:()=>Vf,mergeDefs:()=>Fe,normalizeParams:()=>I,nullish:()=>Yt,numKeys:()=>Zf,objectClone:()=>Tf,omit:()=>Uf,optionalKeys:()=>no,parsedType:()=>Kf,partial:()=>Gf,pick:()=>jf,prefixIssues:()=>je,primitiveTypes:()=>Ds,promiseAllObject:()=>Lf,propertyKeyTypes:()=>to,randomString:()=>Mf,required:()=>qf,safeExtend:()=>Jf,shallowClone:()=>As,slugify:()=>Hr,stringifyPrimitive:()=>Is,uint8ArrayToBase64:()=>Ns,uint8ArrayToBase64url:()=>Xf,uint8ArrayToHex:()=>ed,unwrapMessage:()=>Kt});function If(e){return e}function Of(e){return e}function Rf(e){}function $f(e){throw new Error("Unexpected value in exhaustive check")}function Nf(e){}function Wt(e){let t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function Cf(e,t="|"){return e.map(n=>Is(n)).join(t)}function Et(e,t){return typeof t=="bigint"?t.toString():t}function St(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function Yt(e){return e==null}function Xt(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Xr(e,t){let n=e/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}var ks=Symbol("evaluating");function C(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ks)return r===void 0&&(r=ks,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Tf(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function We(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Fe(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function zf(e){return Fe(e._zod.def)}function Pf(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function Lf(e){let t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=r[s];return o})}function Mf(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function zn(e){return JSON.stringify(e)}function Hr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Pn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function dt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var eo=St(()=>{if(xt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Ye(e){if(dt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(dt(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function As(e){return Ye(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Zf(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var Ff=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}`)}},to=new Set(["string","number","symbol"]),Ds=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Be(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ye(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function I(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 Bf(e){let t;return new Proxy({},{get(n,r,o){return t??(t=e()),Reflect.get(t,r,o)},set(n,r,o,s){return t??(t=e()),Reflect.set(t,r,o,s)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,o){return t??(t=e()),Reflect.defineProperty(t,r,o)}})}function Is(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function no(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var ro={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]},Os={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function jf(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=Fe(e._zod.def,{get shape(){let i={};for(let c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(i[c]=n.shape[c])}return We(this,"shape",i),i},checks:[]});return ye(e,s)}function Uf(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=Fe(e._zod.def,{get shape(){let i={...e._zod.def.shape};for(let c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete i[c]}return We(this,"shape",i),i},checks:[]});return ye(e,s)}function Qf(e,t){if(!Ye(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.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=Fe(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return We(this,"shape",s),s}});return ye(e,o)}function Jf(e,t){if(!Ye(t))throw new Error("Invalid input to safeExtend: expected a plain object");let n=Fe(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return We(this,"shape",r),r}});return ye(e,n)}function Vf(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n=Fe(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return We(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ye(e,n)}function Gf(e,t,n){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=Fe(t._zod.def,{get shape(){let c=t._zod.def.shape,a={...c};if(n)for(let u in n){if(!(u in c))throw new Error(`Unrecognized key: "${u}"`);n[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 We(this,"shape",a),a},checks:[]});return ye(t,i)}function qf(e,t,n){let r=Fe(t._zod.def,{get shape(){let o=t._zod.def.shape,s={...o};if(n)for(let i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[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 We(this,"shape",s),s}});return ye(t,r)}function Xe(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function oo(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function je(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Kt(e){return typeof e=="string"?e:e?.message}function fe(e,t,n){let r=e.message?e.message:Kt(e.inst?._zod.def?.error?.(e))??Kt(t?.error?.(e))??Kt(n.customError?.(e))??Kt(n.localeError?.(e))??"Invalid input",{inst:o,continue:s,input:i,...c}=e;return c.path??(c.path=[]),c.message=r,t?.reportInput&&(c.input=i),c}function Rs(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Ht(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Kf(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 n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function vt(...e){let[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function Wf(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function $s(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function Ns(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function Yf(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return $s(t+n)}function Xf(e){return Ns(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Hf(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function ed(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Yr=class{constructor(...t){}};var Cs=(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,Et,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ln=g("$ZodError",Cs),so=g("$ZodError",Cs,{Parent:Error});function Ts(e,t=n=>n.message){let n={},r=[];for(let o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function zs(e,t=n=>n.message){let n={_errors:[]},r=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(c=>r({issues:c},[...s,...i.path]));else if(i.code==="invalid_key")r({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")r({issues:i.issues},[...s,...i.path]);else{let c=[...s,...i.path];if(c.length===0)n._errors.push(t(i));else{let a=n,u=0;for(;u<c.length;){let d=c[u];u===c.length-1?(a[d]=a[d]||{_errors:[]},a[d]._errors.push(t(i))):a[d]=a[d]||{_errors:[]},a=a[d],u++}}}};return r(e),n}var Mn=e=>(t,n,r,o)=>{let s=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new De;if(i.issues.length){let c=new(o?.Err??e)(i.issues.map(a=>fe(a,s,he())));throw Pn(c,o?.callee),c}return i.value};var Zn=e=>async(t,n,r,o)=>{let s=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let c=new(o?.Err??e)(i.issues.map(a=>fe(a,s,he())));throw Pn(c,o?.callee),c}return i.value};var en=e=>(t,n,r)=>{let o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new De;return s.issues.length?{success:!1,error:new(e??Ln)(s.issues.map(i=>fe(i,o,he())))}:{success:!0,data:s.value}},Ps=en(so),tn=e=>async(t,n,r)=>{let o=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>fe(i,o,he())))}:{success:!0,data:s.value}},Ls=tn(so),Ms=e=>(t,n,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Mn(e)(t,n,o)};var Zs=e=>(t,n,r)=>Mn(e)(t,n,r);var Fs=e=>async(t,n,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Zn(e)(t,n,o)};var Bs=e=>async(t,n,r)=>Zn(e)(t,n,r);var js=e=>(t,n,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return en(e)(t,n,o)};var Us=e=>(t,n,r)=>en(e)(t,n,r);var Qs=e=>async(t,n,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return tn(e)(t,n,o)};var Js=e=>async(t,n,r)=>tn(e)(t,n,r);var Vs=/^[cC][0-9a-z]{6,}$/,Gs=/^[0-9a-z]+$/,qs=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ks=/^[0-9a-vA-V]{20}$/,Ws=/^[A-Za-z0-9]{27}$/,Ys=/^[a-zA-Z0-9_-]{21}$/,Xs=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Hs=/^([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})$/,io=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 ei=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var nd="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ti(){return new RegExp(nd,"u")}var ni=/^(?:(?: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])$/,ri=/^(([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 oi=/^((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])$/,si=/^(([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])$/,ii=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,co=/^[A-Za-z0-9_-]*$/;var ci=/^https?$/,ai=/^\+[1-9]\d{6,14}$/,ui="(?:(?:\\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])))",li=new RegExp(`^${ui}$`);function fi(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 di(e){return new RegExp(`^${fi(e)}$`)}function pi(e){let t=fi({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${t}(?:${n.join("|")})`;return new RegExp(`^${ui}T(?:${r})$`)}var mi=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var hi=/^-?\d+$/,ao=/^-?\d+(?:\.\d+)?$/,yi=/^(?:true|false)$/i,gi=/^null$/i;var bi=/^[^A-Z]*$/,wi=/^[^a-z]*$/;var Y=g("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),_i={number:"number",bigint:"bigint",object:"date"},uo=g("$ZodCheckLessThan",(e,t)=>{Y.init(e,t);let n=_i[typeof t.value];e._zod.onattach.push(r=>{let o=r._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=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),lo=g("$ZodCheckGreaterThan",(e,t)=>{Y.init(e,t);let n=_i[typeof t.value];e._zod.onattach.push(r=>{let o=r._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=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xi=g("$ZodCheckMultipleOf",(e,t)=>{Y.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Xr(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ei=g("$ZodCheckNumberFormat",(e,t)=>{Y.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[o,s]=ro[t.format];e._zod.onattach.push(i=>{let c=i._zod.bag;c.format=t.format,c.minimum=o,c.maximum=s,n&&(c.pattern=hi)}),e._zod.check=i=>{let c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:r,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:r,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:r,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 Si=g("$ZodCheckMaxLength",(e,t)=>{var n;Y.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!Yt(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let o=r.value;if(o.length<=t.maximum)return;let i=Ht(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),vi=g("$ZodCheckMinLength",(e,t)=>{var n;Y.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!Yt(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let o=r.value;if(o.length>=t.minimum)return;let i=Ht(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ki=g("$ZodCheckLengthEquals",(e,t)=>{var n;Y.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!Yt(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{let o=r.value,s=o.length;if(s===t.length)return;let i=Ht(o),c=s>t.length;r.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),nn=g("$ZodCheckStringFormat",(e,t)=>{var n,r;Y.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?(n=e._zod).check??(n.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})}):(r=e._zod).check??(r.check=()=>{})}),Ai=g("$ZodCheckRegex",(e,t)=>{nn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Di=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=bi),nn.init(e,t)}),Ii=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=wi),nn.init(e,t)}),Oi=g("$ZodCheckIncludes",(e,t)=>{Y.init(e,t);let n=Be(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),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})}}),Ri=g("$ZodCheckStartsWith",(e,t)=>{Y.init(e,t);let n=new RegExp(`^${Be(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),$i=g("$ZodCheckEndsWith",(e,t)=>{Y.init(e,t);let n=new RegExp(`.*${Be(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var Ni=g("$ZodCheckOverwrite",(e,t)=>{Y.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});var Bn=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 r=t.split(`+var Rf=Object.defineProperty;var Of=(e,t)=>{for(var n in t)Rf(e,n,{get:t[n],enumerable:!0})};var Is;function g(e,t,n){function r(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,d=Object.keys(u);for(let l=0;l<d.length;l++){let f=d[l];f in c||(c[f]=u[f].bind(c))}}let o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var a;let u=n?.Parent?new s:this;r(u,c),(a=u._zod).deferred??(a.deferred=[]);for(let d of u._zod.deferred)d();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}var _h=Symbol("zod_brand"),Re=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},_t=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Is=globalThis).__zod_globalConfig??(Is.__zod_globalConfig={});var xt=globalThis.__zod_globalConfig;function he(e){return e&&Object.assign(xt,e),xt}var z={};Of(z,{BIGINT_FORMAT_RANGES:()=>Cs,Class:()=>Xr,NUMBER_FORMAT_RANGES:()=>oo,aborted:()=>Xe,allowsEval:()=>to,assert:()=>zf,assertEqual:()=>$f,assertIs:()=>Cf,assertNever:()=>Tf,assertNotEqual:()=>Nf,assignProp:()=>We,base64ToUint8Array:()=>zs,base64urlToUint8Array:()=>ed,cached:()=>St,captureStackTrace:()=>Ln,cleanEnum:()=>Hf,cleanRegex:()=>Ht,clone:()=>ye,cloneDef:()=>Mf,createTransparentProxy:()=>Vf,defineLazy:()=>C,esc:()=>Pn,escapeRegex:()=>Ue,explicitlyAborted:()=>so,extend:()=>Gf,finalizeIssue:()=>fe,floatSafeRemainder:()=>Hr,getElementAtPath:()=>Zf,getEnumValues:()=>Yt,getLengthableOrigin:()=>en,getParsedType:()=>Uf,getSizableOrigin:()=>Ts,hexToUint8Array:()=>nd,isObject:()=>dt,isPlainObject:()=>Ye,issue:()=>vt,joinValues:()=>Pf,jsonStringifyReplacer:()=>Et,merge:()=>Kf,mergeDefs:()=>je,normalizeParams:()=>I,nullish:()=>Xt,numKeys:()=>jf,objectClone:()=>Lf,omit:()=>Jf,optionalKeys:()=>ro,parsedType:()=>Xf,partial:()=>Wf,pick:()=>Qf,prefixIssues:()=>Ve,primitiveTypes:()=>$s,promiseAllObject:()=>Ff,propertyKeyTypes:()=>no,randomString:()=>Bf,required:()=>Yf,safeExtend:()=>qf,shallowClone:()=>Os,slugify:()=>eo,stringifyPrimitive:()=>Ns,uint8ArrayToBase64:()=>Ps,uint8ArrayToBase64url:()=>td,uint8ArrayToHex:()=>rd,unwrapMessage:()=>Wt});function $f(e){return e}function Nf(e){return e}function Cf(e){}function Tf(e){throw new Error("Unexpected value in exhaustive check")}function zf(e){}function Yt(e){let t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function Pf(e,t="|"){return e.map(n=>Ns(n)).join(t)}function Et(e,t){return typeof t=="bigint"?t.toString():t}function St(e){return{get value(){{let n=e();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function Xt(e){return e==null}function Ht(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Hr(e,t){let n=e/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}var Rs=Symbol("evaluating");function C(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Rs)return r===void 0&&(r=Rs,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Lf(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function We(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function je(...e){let t={};for(let n of e){let r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Mf(e){return je(e._zod.def)}function Zf(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function Ff(e){let t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=r[s];return o})}function Bf(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function Pn(e){return JSON.stringify(e)}function eo(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Ln="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function dt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var to=St(()=>{if(xt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Ye(e){if(dt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(dt(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Os(e){return Ye(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function jf(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var Uf=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}`)}},no=new Set(["string","number","symbol"]),$s=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ye(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function I(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 Vf(e){let t;return new Proxy({},{get(n,r,o){return t??(t=e()),Reflect.get(t,r,o)},set(n,r,o,s){return t??(t=e()),Reflect.set(t,r,o,s)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,o){return t??(t=e()),Reflect.defineProperty(t,r,o)}})}function Ns(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function ro(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var oo={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]},Cs={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Qf(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=je(e._zod.def,{get shape(){let i={};for(let c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&(i[c]=n.shape[c])}return We(this,"shape",i),i},checks:[]});return ye(e,s)}function Jf(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=je(e._zod.def,{get shape(){let i={...e._zod.def.shape};for(let c in t){if(!(c in n.shape))throw new Error(`Unrecognized key: "${c}"`);t[c]&&delete i[c]}return We(this,"shape",i),i},checks:[]});return ye(e,s)}function Gf(e,t){if(!Ye(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.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=je(e._zod.def,{get shape(){let s={...e._zod.def.shape,...t};return We(this,"shape",s),s}});return ye(e,o)}function qf(e,t){if(!Ye(t))throw new Error("Invalid input to safeExtend: expected a plain object");let n=je(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return We(this,"shape",r),r}});return ye(e,n)}function Kf(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n=je(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return We(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return ye(e,n)}function Wf(e,t,n){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=je(t._zod.def,{get shape(){let c=t._zod.def.shape,a={...c};if(n)for(let u in n){if(!(u in c))throw new Error(`Unrecognized key: "${u}"`);n[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 We(this,"shape",a),a},checks:[]});return ye(t,i)}function Yf(e,t,n){let r=je(t._zod.def,{get shape(){let o=t._zod.def.shape,s={...o};if(n)for(let i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[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 We(this,"shape",s),s}});return ye(t,r)}function Xe(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function so(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Ve(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Wt(e){return typeof e=="string"?e:e?.message}function fe(e,t,n){let r=e.message?e.message:Wt(e.inst?._zod.def?.error?.(e))??Wt(t?.error?.(e))??Wt(n.customError?.(e))??Wt(n.localeError?.(e))??"Invalid input",{inst:o,continue:s,input:i,...c}=e;return c.path??(c.path=[]),c.message=r,t?.reportInput&&(c.input=i),c}function Ts(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function en(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Xf(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 n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function vt(...e){let[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function Hf(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function zs(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function Ps(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function ed(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return zs(t+n)}function td(e){return Ps(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function nd(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function rd(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Xr=class{constructor(...t){}};var Ls=(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,Et,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Mn=g("$ZodError",Ls),io=g("$ZodError",Ls,{Parent:Error});function Ms(e,t=n=>n.message){let n={},r=[];for(let o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Zs(e,t=n=>n.message){let n={_errors:[]},r=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(c=>r({issues:c},[...s,...i.path]));else if(i.code==="invalid_key")r({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")r({issues:i.issues},[...s,...i.path]);else{let c=[...s,...i.path];if(c.length===0)n._errors.push(t(i));else{let a=n,u=0;for(;u<c.length;){let d=c[u];u===c.length-1?(a[d]=a[d]||{_errors:[]},a[d]._errors.push(t(i))):a[d]=a[d]||{_errors:[]},a=a[d],u++}}}};return r(e),n}var Zn=e=>(t,n,r,o)=>{let s=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new Re;if(i.issues.length){let c=new(o?.Err??e)(i.issues.map(a=>fe(a,s,he())));throw Ln(c,o?.callee),c}return i.value};var Fn=e=>async(t,n,r,o)=>{let s=r?{...r,async:!0}:{async:!0},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let c=new(o?.Err??e)(i.issues.map(a=>fe(a,s,he())));throw Ln(c,o?.callee),c}return i.value};var tn=e=>(t,n,r)=>{let o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new Re;return s.issues.length?{success:!1,error:new(e??Mn)(s.issues.map(i=>fe(i,o,he())))}:{success:!0,data:s.value}},Fs=tn(io),nn=e=>async(t,n,r)=>{let o=r?{...r,async:!0}:{async:!0},s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>fe(i,o,he())))}:{success:!0,data:s.value}},Bs=nn(io),js=e=>(t,n,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Zn(e)(t,n,o)};var Us=e=>(t,n,r)=>Zn(e)(t,n,r);var Vs=e=>async(t,n,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return Fn(e)(t,n,o)};var Qs=e=>async(t,n,r)=>Fn(e)(t,n,r);var Js=e=>(t,n,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return tn(e)(t,n,o)};var Gs=e=>(t,n,r)=>tn(e)(t,n,r);var qs=e=>async(t,n,r)=>{let o=r?{...r,direction:"backward"}:{direction:"backward"};return nn(e)(t,n,o)};var Ks=e=>async(t,n,r)=>nn(e)(t,n,r);var Ws=/^[cC][0-9a-z]{6,}$/,Ys=/^[0-9a-z]+$/,Xs=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Hs=/^[0-9a-vA-V]{20}$/,ei=/^[A-Za-z0-9]{27}$/,ti=/^[a-zA-Z0-9_-]{21}$/,ni=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var ri=/^([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})$/,co=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 oi=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var sd="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function si(){return new RegExp(sd,"u")}var ii=/^(?:(?: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])$/,ci=/^(([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 ai=/^((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])$/,ui=/^(([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])$/,li=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ao=/^[A-Za-z0-9_-]*$/;var fi=/^https?$/,di=/^\+[1-9]\d{6,14}$/,pi="(?:(?:\\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])))",mi=new RegExp(`^${pi}$`);function hi(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 yi(e){return new RegExp(`^${hi(e)}$`)}function gi(e){let t=hi({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${t}(?:${n.join("|")})`;return new RegExp(`^${pi}T(?:${r})$`)}var bi=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)};var wi=/^-?\d+$/,uo=/^-?\d+(?:\.\d+)?$/,_i=/^(?:true|false)$/i,xi=/^null$/i;var Ei=/^[^A-Z]*$/,Si=/^[^a-z]*$/;var Y=g("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),vi={number:"number",bigint:"bigint",object:"date"},lo=g("$ZodCheckLessThan",(e,t)=>{Y.init(e,t);let n=vi[typeof t.value];e._zod.onattach.push(r=>{let o=r._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=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),fo=g("$ZodCheckGreaterThan",(e,t)=>{Y.init(e,t);let n=vi[typeof t.value];e._zod.onattach.push(r=>{let o=r._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=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ki=g("$ZodCheckMultipleOf",(e,t)=>{Y.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Hr(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Ai=g("$ZodCheckNumberFormat",(e,t)=>{Y.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[o,s]=oo[t.format];e._zod.onattach.push(i=>{let c=i._zod.bag;c.format=t.format,c.minimum=o,c.maximum=s,n&&(c.pattern=wi)}),e._zod.check=i=>{let c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:r,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:r,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:r,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 Di=g("$ZodCheckMaxLength",(e,t)=>{var n;Y.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!Xt(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let o=r.value;if(o.length<=t.maximum)return;let i=en(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ii=g("$ZodCheckMinLength",(e,t)=>{var n;Y.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!Xt(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let o=r.value;if(o.length>=t.minimum)return;let i=en(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ri=g("$ZodCheckLengthEquals",(e,t)=>{var n;Y.init(e,t),(n=e._zod.def).when??(n.when=r=>{let o=r.value;return!Xt(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{let o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{let o=r.value,s=o.length;if(s===t.length)return;let i=en(o),c=s>t.length;r.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),rn=g("$ZodCheckStringFormat",(e,t)=>{var n,r;Y.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?(n=e._zod).check??(n.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})}):(r=e._zod).check??(r.check=()=>{})}),Oi=g("$ZodCheckRegex",(e,t)=>{rn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),$i=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ei),rn.init(e,t)}),Ni=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Si),rn.init(e,t)}),Ci=g("$ZodCheckIncludes",(e,t)=>{Y.init(e,t);let n=Ue(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),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})}}),Ti=g("$ZodCheckStartsWith",(e,t)=>{Y.init(e,t);let n=new RegExp(`^${Ue(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),zi=g("$ZodCheckEndsWith",(e,t)=>{Y.init(e,t);let n=new RegExp(`.*${Ue(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{let o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});var Pi=g("$ZodCheckOverwrite",(e,t)=>{Y.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});var jn=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 r=t.split(``).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.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,n=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`-`))}};var Ti={major:4,minor:4,patch:3};var Z=g("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ti;let r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(let o of r)for(let s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(i,c,a)=>{let u=Xe(i),d;for(let l of c){if(l._zod.def.when){if(oo(i)||!l._zod.def.when(i))continue}else if(u)continue;let f=i.issues.length,p=l._zod.check(i);if(p instanceof Promise&&a?.async===!1)throw new De;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,i.issues.length!==f&&(u||(u=Xe(i,f)))});else{if(i.issues.length===f)continue;u||(u=Xe(i,f))}}return d?d.then(()=>i):i},s=(i,c,a)=>{if(Xe(i))return i.aborted=!0,i;let u=o(c,r,a);if(u instanceof Promise){if(a.async===!1)throw new De;return u.then(d=>e._zod.parse(d,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(d=>s(d,i,c)):s(u,i,c)}let a=e._zod.parse(i,c);if(a instanceof Promise){if(c.async===!1)throw new De;return a.then(u=>o(u,r,c))}return o(a,r,c)}}C(e,"~standard",()=>({validate:o=>{try{let s=Ps(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Ls(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Qn=g("$ZodString",(e,t)=>{Z.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??mi(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),F=g("$ZodStringFormat",(e,t)=>{nn.init(e,t),Qn.init(e,t)}),Ui=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Hs),F.init(e,t)}),Qi=g("$ZodUUID",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=io(r))}else t.pattern??(t.pattern=io());F.init(e,t)}),Ji=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ei),F.init(e,t)}),Vi=g("$ZodURL",(e,t)=>{F.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===ci.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}let o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.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)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Gi=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ti()),F.init(e,t)}),qi=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ys),F.init(e,t)}),Ki=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Vs),F.init(e,t)}),Wi=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Gs),F.init(e,t)}),Yi=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=qs),F.init(e,t)}),Xi=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ks),F.init(e,t)}),Hi=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ws),F.init(e,t)}),ec=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=pi(t)),F.init(e,t)}),tc=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=li),F.init(e,t)}),nc=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=di(t)),F.init(e,t)}),rc=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Xs),F.init(e,t)}),oc=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ni),F.init(e,t),e._zod.bag.format="ipv4"}),sc=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ri),F.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}});var ic=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=oi),F.init(e,t)}),cc=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=si),F.init(e,t),e._zod.check=n=>{let r=n.value.split("/");try{if(r.length!==2)throw new Error;let[o,s]=r;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{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function ac(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var uc=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ii),F.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{ac(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function rd(e){if(!co.test(e))return!1;let t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return ac(n)}var lc=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=co),F.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{rd(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),fc=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ai),F.init(e,t)});function od(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var dc=g("$ZodJWT",(e,t)=>{F.init(e,t),e._zod.check=n=>{od(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var po=g("$ZodNumber",(e,t)=>{Z.init(e,t),e._zod.pattern=e._zod.bag.pattern??ao,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),pc=g("$ZodNumberFormat",(e,t)=>{Ei.init(e,t),po.init(e,t)}),mc=g("$ZodBoolean",(e,t)=>{Z.init(e,t),e._zod.pattern=yi,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}});var hc=g("$ZodNull",(e,t)=>{Z.init(e,t),e._zod.pattern=gi,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{let o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}});var yc=g("$ZodUnknown",(e,t)=>{Z.init(e,t),e._zod.parse=n=>n}),gc=g("$ZodNever",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function zi(e,t,n){e.issues.length&&t.issues.push(...je(n,e.issues)),t.value[n]=e.value}var bc=g("$ZodArray",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.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:[]},r);a instanceof Promise?s.push(a.then(u=>zi(u,n,i))):zi(a,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function Un(e,t,n,r,o,s){let i=n in r;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...je(n,e.issues))}if(!i&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?i&&(t.value[n]=void 0):t.value[n]=e.value}function wc(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);let n=no(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function _c(e,t,n,r,o,s){let i=[],c=o.keySet,a=o.catchall._zod,u=a.def.type,d=a.optin==="optional",l=a.optout==="optional";for(let f in t){if(f==="__proto__"||c.has(f))continue;if(u==="never"){i.push(f);continue}let p=a.run({value:t[f],issues:[]},r);p instanceof Promise?e.push(p.then(y=>Un(y,n,f,t,d,l))):Un(p,n,f,t,d,l)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}var sd=g("$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 r=St(()=>wc(t));C(e._zod,"propValues",()=>{let c=t.shape,a={};for(let u in c){let d=c[u]._zod;if(d.values){a[u]??(a[u]=new Set);for(let l of d.values)a[u].add(l)}}return a});let o=dt,s=t.catchall,i;e._zod.parse=(c,a)=>{i??(i=r.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 d=[],l=i.shape;for(let f of i.keys){let p=l[f],y=p._zod.optin==="optional",m=p._zod.optout==="optional",h=p._zod.run({value:u[f],issues:[]},a);h instanceof Promise?d.push(h.then(b=>Un(b,c,f,u,y,m))):Un(h,c,f,u,y,m)}return s?_c(d,u,c,a,r.value,e):d.length?Promise.all(d).then(()=>c):c}}),xc=g("$ZodObjectJIT",(e,t)=>{sd.init(e,t);let n=e._zod.parse,r=St(()=>wc(t)),o=f=>{let p=new Bn(["shape","payload","ctx"]),y=r.value,m=x=>{let w=zn(x);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`};p.write("const input = payload.value;");let h=Object.create(null),b=0;for(let x of y.keys)h[x]=`key_${b++}`;p.write("const newResult = {};");for(let x of y.keys){let w=h[x],S=zn(x),v=f[x],$=v?._zod?.optin==="optional",E=v?._zod?.optout==="optional";p.write(`const ${w} = ${m(x)};`),$&&E?p.write(`+`))}};var Mi={major:4,minor:4,patch:3};var Z=g("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Mi;let r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(let o of r)for(let s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(i,c,a)=>{let u=Xe(i),d;for(let l of c){if(l._zod.def.when){if(so(i)||!l._zod.def.when(i))continue}else if(u)continue;let f=i.issues.length,p=l._zod.check(i);if(p instanceof Promise&&a?.async===!1)throw new Re;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,i.issues.length!==f&&(u||(u=Xe(i,f)))});else{if(i.issues.length===f)continue;u||(u=Xe(i,f))}}return d?d.then(()=>i):i},s=(i,c,a)=>{if(Xe(i))return i.aborted=!0,i;let u=o(c,r,a);if(u instanceof Promise){if(a.async===!1)throw new Re;return u.then(d=>e._zod.parse(d,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(d=>s(d,i,c)):s(u,i,c)}let a=e._zod.parse(i,c);if(a instanceof Promise){if(c.async===!1)throw new Re;return a.then(u=>o(u,r,c))}return o(a,r,c)}}C(e,"~standard",()=>({validate:o=>{try{let s=Fs(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Bs(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),Qn=g("$ZodString",(e,t)=>{Z.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??bi(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),F=g("$ZodStringFormat",(e,t)=>{rn.init(e,t),Qn.init(e,t)}),Gi=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ri),F.init(e,t)}),qi=g("$ZodUUID",(e,t)=>{if(t.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=co(r))}else t.pattern??(t.pattern=co());F.init(e,t)}),Ki=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=oi),F.init(e,t)}),Wi=g("$ZodURL",(e,t)=>{F.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===fi.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}let o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.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)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Yi=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=si()),F.init(e,t)}),Xi=g("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=ti),F.init(e,t)}),Hi=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Ws),F.init(e,t)}),ec=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Ys),F.init(e,t)}),tc=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Xs),F.init(e,t)}),nc=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Hs),F.init(e,t)}),rc=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ei),F.init(e,t)}),oc=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=gi(t)),F.init(e,t)}),sc=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=mi),F.init(e,t)}),ic=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=yi(t)),F.init(e,t)}),cc=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ni),F.init(e,t)}),ac=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ii),F.init(e,t),e._zod.bag.format="ipv4"}),uc=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ci),F.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}});var lc=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ai),F.init(e,t)}),fc=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ui),F.init(e,t),e._zod.check=n=>{let r=n.value.split("/");try{if(r.length!==2)throw new Error;let[o,s]=r;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{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function dc(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var pc=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=li),F.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{dc(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function id(e){if(!ao.test(e))return!1;let t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return dc(n)}var mc=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ao),F.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{id(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),hc=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=di),F.init(e,t)});function cd(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var yc=g("$ZodJWT",(e,t)=>{F.init(e,t),e._zod.check=n=>{cd(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}});var mo=g("$ZodNumber",(e,t)=>{Z.init(e,t),e._zod.pattern=e._zod.bag.pattern??uo,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),gc=g("$ZodNumberFormat",(e,t)=>{Ai.init(e,t),mo.init(e,t)}),bc=g("$ZodBoolean",(e,t)=>{Z.init(e,t),e._zod.pattern=_i,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}});var wc=g("$ZodNull",(e,t)=>{Z.init(e,t),e._zod.pattern=xi,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{let o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}});var _c=g("$ZodUnknown",(e,t)=>{Z.init(e,t),e._zod.parse=n=>n}),xc=g("$ZodNever",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Zi(e,t,n){e.issues.length&&t.issues.push(...Ve(n,e.issues)),t.value[n]=e.value}var Ec=g("$ZodArray",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.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:[]},r);a instanceof Promise?s.push(a.then(u=>Zi(u,n,i))):Zi(a,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function Vn(e,t,n,r,o,s){let i=n in r;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...Ve(n,e.issues))}if(!i&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?i&&(t.value[n]=void 0):t.value[n]=e.value}function Sc(e){let t=Object.keys(e.shape);for(let r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);let n=ro(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function vc(e,t,n,r,o,s){let i=[],c=o.keySet,a=o.catchall._zod,u=a.def.type,d=a.optin==="optional",l=a.optout==="optional";for(let f in t){if(f==="__proto__"||c.has(f))continue;if(u==="never"){i.push(f);continue}let p=a.run({value:t[f],issues:[]},r);p instanceof Promise?e.push(p.then(y=>Vn(y,n,f,t,d,l))):Vn(p,n,f,t,d,l)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}var ad=g("$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 r=St(()=>Sc(t));C(e._zod,"propValues",()=>{let c=t.shape,a={};for(let u in c){let d=c[u]._zod;if(d.values){a[u]??(a[u]=new Set);for(let l of d.values)a[u].add(l)}}return a});let o=dt,s=t.catchall,i;e._zod.parse=(c,a)=>{i??(i=r.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 d=[],l=i.shape;for(let f of i.keys){let p=l[f],y=p._zod.optin==="optional",m=p._zod.optout==="optional",h=p._zod.run({value:u[f],issues:[]},a);h instanceof Promise?d.push(h.then(b=>Vn(b,c,f,u,y,m))):Vn(h,c,f,u,y,m)}return s?vc(d,u,c,a,r.value,e):d.length?Promise.all(d).then(()=>c):c}}),kc=g("$ZodObjectJIT",(e,t)=>{ad.init(e,t);let n=e._zod.parse,r=St(()=>Sc(t)),o=f=>{let p=new jn(["shape","payload","ctx"]),y=r.value,m=x=>{let w=Pn(x);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`};p.write("const input = payload.value;");let h=Object.create(null),b=0;for(let x of y.keys)h[x]=`key_${b++}`;p.write("const newResult = {};");for(let x of y.keys){let w=h[x],S=Pn(x),k=f[x],$=k?._zod?.optin==="optional",E=k?._zod?.optout==="optional";p.write(`const ${w} = ${m(x)};`),$&&E?p.write(`if (${w}.issues.length) {if (${S} in input) {payload.issues = payload.issues.concat(${w}.issues.map(iss => ({@@ -59,77 +59,77 @@ var Af=Object.defineProperty;var Df=(e,t)=>{for(var n in t)Af(e,n,{get:t[n],enum}}- `)}p.write("payload.value = newResult;"),p.write("return payload;");let _=p.compile();return(x,w)=>_(f,x,w)},s,i=dt,c=!xt.jitless,u=c&&eo.value,d=t.catchall,l;e._zod.parse=(f,p)=>{l??(l=r.value);let y=f.value;return i(y)?c&&u&&p?.async===!1&&p.jitless!==!0?(s||(s=o(t.shape)),f=s(f,p),d?_c([],y,f,p,l,e):f):n(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),f)}});function Pi(e,t,n,r){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!Xe(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>fe(i,r,he())))}),t)}var mo=g("$ZodUnion",(e,t)=>{Z.init(e,t),C(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),C(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),C(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),C(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){let r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>Xt(o.source)).join("|")})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let s=!1,i=[];for(let c of t.options){let a=c._zod.run({value:r.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=>Pi(c,r,e,o)):Pi(i,r,e,o)}});var Ec=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,mo.init(e,t);let n=e._zod.parse;C(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 r=St(()=>{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(!dt(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let c=r.value.get(i?.[t.discriminator]);return c?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:i,path:[t.discriminator],inst:e}),o)}}),Sc=g("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>{let o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([a,u])=>Li(n,a,u)):Li(n,s,i)}});function fo(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(Ye(e)&&Ye(t)){let n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(let s of r){let i=fo(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 n=[];for(let r=0;r<e.length;r++){let o=e[r],s=t[r],i=fo(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Li(e,t,n){let r=new Map,o;for(let c of t.issues)if(c.code==="unrecognized_keys"){o??(o=c);for(let a of c.keys)r.has(a)||r.set(a,{}),r.get(a).l=!0}else e.issues.push(c);for(let c of n.issues)if(c.code==="unrecognized_keys")for(let a of c.keys)r.has(a)||r.set(a,{}),r.get(a).r=!0;else e.issues.push(c);let s=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(s.length&&o&&e.issues.push({...o,keys:s}),Xe(e))return e;let i=fo(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}var vc=g("$ZodRecord",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(!Ye(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;let s=[],i=t.keyType._zod.values;if(i){n.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 d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(p=>fe(p,r,he())),input:u,path:[u],inst:e});continue}let l=d.value,f=t.valueType._zod.run({value:o[u],issues:[]},r);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&n.issues.push(...je(u,p.issues)),n.value[l]=p.value})):(f.issues.length&&n.issues.push(...je(u,f.issues)),n.value[l]=f.value)}let a;for(let u in o)c.has(u)||(a=a??[],a.push(u));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{n.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:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&ao.test(c)&&a.issues.length){let l=t.keyType._zod.run({value:Number(c),issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");l.issues.length===0&&(a=l)}if(a.issues.length){t.mode==="loose"?n.value[c]=o[c]:n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(l=>fe(l,r,he())),input:c,path:[c],inst:e});continue}let d=t.valueType._zod.run({value:o[c],issues:[]},r);d instanceof Promise?s.push(d.then(l=>{l.issues.length&&n.issues.push(...je(c,l.issues)),n.value[a.value]=l.value})):(d.issues.length&&n.issues.push(...je(c,d.issues)),n.value[a.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}});var kc=g("$ZodEnum",(e,t)=>{Z.init(e,t);let n=Wt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>to.has(typeof o)).map(o=>typeof o=="string"?Be(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{let i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),Ac=g("$ZodLiteral",(e,t)=>{if(Z.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Be(r):r?Be(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{let s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}});var Dc=g("$ZodTransform",(e,t)=>{Z.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new _t(e.constructor.name);let o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n.fallback=!0,n));if(o instanceof Promise)throw new De;return n.value=o,n.fallback=!0,n}});function Mi(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var ho=g("$ZodOptional",(e,t)=>{Z.init(e,t),e._zod.optin="optional",e._zod.optout="optional",C(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),C(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Xt(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){let o=n.value,s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>Mi(i,o)):Mi(s,o)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Ic=g("$ZodExactOptional",(e,t)=>{ho.init(e,t),C(e._zod,"values",()=>t.innerType._zod.values),C(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Oc=g("$ZodNullable",(e,t)=>{Z.init(e,t),C(e._zod,"optin",()=>t.innerType._zod.optin),C(e._zod,"optout",()=>t.innerType._zod.optout),C(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Xt(n.source)}|null)$`):void 0}),C(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Rc=g("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",C(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;let o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Zi(s,t)):Zi(o,t)}});function Zi(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var $c=g("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",C(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Nc=g("$ZodNonOptional",(e,t)=>{Z.init(e,t),C(e._zod,"values",()=>{let n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{let o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Fi(s,e)):Fi(o,e)}});function Fi(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 Cc=g("$ZodCatch",(e,t)=>{Z.init(e,t),e._zod.optin="optional",C(e._zod,"optout",()=>t.innerType._zod.optout),C(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>fe(i,r,he()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>fe(s,r,he()))},input:n.value}),n.issues=[],n.fallback=!0),n)}});var Tc=g("$ZodPipe",(e,t)=>{Z.init(e,t),C(e._zod,"values",()=>t.in._zod.values),C(e._zod,"optin",()=>t.in._zod.optin),C(e._zod,"optout",()=>t.out._zod.optout),C(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){let s=t.out._zod.run(n,r);return s instanceof Promise?s.then(i=>jn(i,t.in,r)):jn(s,t.in,r)}let o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>jn(s,t.out,r)):jn(o,t.out,r)}});function jn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var zc=g("$ZodReadonly",(e,t)=>{Z.init(e,t),C(e._zod,"propValues",()=>t.innerType._zod.propValues),C(e._zod,"values",()=>t.innerType._zod.values),C(e._zod,"optin",()=>t.innerType?._zod?.optin),C(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Bi):Bi(o)}});function Bi(e){return e.value=Object.freeze(e.value),e}var Pc=g("$ZodLazy",(e,t)=>{Z.init(e,t),C(e._zod,"innerType",()=>{let n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),C(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),C(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),C(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),C(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Lc=g("$ZodCustom",(e,t)=>{Y.init(e,t),Z.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{let r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>ji(s,n,r,e));ji(o,n,r,e)}});function ji(e,t,n,r){if(!e){let o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(vt(o))}}var Mc,Th=Symbol("ZodOutput"),zh=Symbol("ZodInput"),yo=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){let r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){let n=t._zod.parent;if(n){let r={...this.get(n)??{}};delete r.id;let o={...r,...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 id(){return new yo}(Mc=globalThis).__zod_globalRegistry??(Mc.__zod_globalRegistry=id());var pt=globalThis.__zod_globalRegistry;function Zc(e,t){return new e({type:"string",...I(t)})}function Fc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...I(t)})}function go(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...I(t)})}function Bc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...I(t)})}function jc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...I(t)})}function Uc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...I(t)})}function Qc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...I(t)})}function Jc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...I(t)})}function Vc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...I(t)})}function Gc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...I(t)})}function qc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...I(t)})}function Kc(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...I(t)})}function Wc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...I(t)})}function Yc(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...I(t)})}function Xc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...I(t)})}function Hc(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...I(t)})}function ea(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...I(t)})}function ta(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...I(t)})}function na(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...I(t)})}function ra(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...I(t)})}function oa(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...I(t)})}function sa(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...I(t)})}function ia(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...I(t)})}function ca(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...I(t)})}function aa(e,t){return new e({type:"string",format:"date",check:"string_format",...I(t)})}function ua(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...I(t)})}function la(e,t){return new e({type:"string",format:"duration",check:"string_format",...I(t)})}function fa(e,t){return new e({type:"number",checks:[],...I(t)})}function da(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...I(t)})}function pa(e,t){return new e({type:"boolean",...I(t)})}function ma(e,t){return new e({type:"null",...I(t)})}function ha(e){return new e({type:"unknown"})}function ya(e,t){return new e({type:"never",...I(t)})}function Jn(e,t){return new uo({check:"less_than",...I(t),value:e,inclusive:!1})}function rn(e,t){return new uo({check:"less_than",...I(t),value:e,inclusive:!0})}function Vn(e,t){return new lo({check:"greater_than",...I(t),value:e,inclusive:!1})}function on(e,t){return new lo({check:"greater_than",...I(t),value:e,inclusive:!0})}function Gn(e,t){return new xi({check:"multiple_of",...I(t),value:e})}function qn(e,t){return new Si({check:"max_length",...I(t),maximum:e})}function kt(e,t){return new vi({check:"min_length",...I(t),minimum:e})}function Kn(e,t){return new ki({check:"length_equals",...I(t),length:e})}function bo(e,t){return new Ai({check:"string_format",format:"regex",...I(t),pattern:e})}function wo(e){return new Di({check:"string_format",format:"lowercase",...I(e)})}function _o(e){return new Ii({check:"string_format",format:"uppercase",...I(e)})}function xo(e,t){return new Oi({check:"string_format",format:"includes",...I(t),includes:e})}function Eo(e,t){return new Ri({check:"string_format",format:"starts_with",...I(t),prefix:e})}function So(e,t){return new $i({check:"string_format",format:"ends_with",...I(t),suffix:e})}function He(e){return new Ni({check:"overwrite",tx:e})}function vo(e){return He(t=>t.normalize(e))}function ko(){return He(e=>e.trim())}function Ao(){return He(e=>e.toLowerCase())}function Do(){return He(e=>e.toUpperCase())}function Io(){return He(e=>Hr(e))}function ga(e,t,n){return new e({type:"array",element:t,...I(n)})}function ba(e,t,n){return new e({type:"custom",check:"custom",fn:t,...I(n)})}function wa(e,t){let n=cd(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(vt(o,r.value,n._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),r.issues.push(vt(s))}},e(r.value,r)),t);return n}function cd(e,t){let n=new Y({check:"custom",...I(t)});return n._zod.check=e,n}function Oo(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??pt,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 Q(e,t,n={path:[],schemaPath:[]}){var r;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);let c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{let d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,d);else{let f=i.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,f,d)}let l=e._zod.parent;l&&(i.ref||(i.ref=l),Q(l,t,d),t.seen.get(l).isParent=!0)}let a=t.metadataRegistry.get(e);return a&&Object.assign(i.schema,a),t.io==="input"&&ee(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((r=i.schema).default??(r.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Ro(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=new Map;for(let i of e.seen.entries()){let c=e.metadataRegistry.get(i[0])?.id;if(c){let a=r.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.`);r.set(c,i[0])}}let o=i=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let l=e.external.registry.get(i[0])?.id,f=e.external.uri??(y=>y);if(l)return{ref:f(l)};let p=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=p,{defId:p,ref:`${f("__shared")}#/${c}/${p}`}}if(i[1]===n)return{ref:"#"};let u=`#/${c}/`,d=i[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},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 d=c.schema;for(let l in d)delete d[l];d.$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>+ `)}p.write("payload.value = newResult;"),p.write("return payload;");let _=p.compile();return(x,w)=>_(f,x,w)},s,i=dt,c=!xt.jitless,u=c&&to.value,d=t.catchall,l;e._zod.parse=(f,p)=>{l??(l=r.value);let y=f.value;return i(y)?c&&u&&p?.async===!1&&p.jitless!==!0?(s||(s=o(t.shape)),f=s(f,p),d?vc([],y,f,p,l,e):f):n(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:y,inst:e}),f)}});function Fi(e,t,n,r){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!Xe(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>fe(i,r,he())))}),t)}var ho=g("$ZodUnion",(e,t)=>{Z.init(e,t),C(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),C(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),C(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),C(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){let r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>Ht(o.source)).join("|")})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let s=!1,i=[];for(let c of t.options){let a=c._zod.run({value:r.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=>Fi(c,r,e,o)):Fi(i,r,e,o)}});var Ac=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ho.init(e,t);let n=e._zod.parse;C(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 r=St(()=>{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(!dt(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let c=r.value.get(i?.[t.discriminator]);return c?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()),input:i,path:[t.discriminator],inst:e}),o)}}),Dc=g("$ZodIntersection",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>{let o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([a,u])=>Bi(n,a,u)):Bi(n,s,i)}});function po(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(Ye(e)&&Ye(t)){let n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(let s of r){let i=po(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 n=[];for(let r=0;r<e.length;r++){let o=e[r],s=t[r],i=po(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Bi(e,t,n){let r=new Map,o;for(let c of t.issues)if(c.code==="unrecognized_keys"){o??(o=c);for(let a of c.keys)r.has(a)||r.set(a,{}),r.get(a).l=!0}else e.issues.push(c);for(let c of n.issues)if(c.code==="unrecognized_keys")for(let a of c.keys)r.has(a)||r.set(a,{}),r.get(a).r=!0;else e.issues.push(c);let s=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(s.length&&o&&e.issues.push({...o,keys:s}),Xe(e))return e;let i=po(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}var Ic=g("$ZodRecord",(e,t)=>{Z.init(e,t),e._zod.parse=(n,r)=>{let o=n.value;if(!Ye(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;let s=[],i=t.keyType._zod.values;if(i){n.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 d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(p=>fe(p,r,he())),input:u,path:[u],inst:e});continue}let l=d.value,f=t.valueType._zod.run({value:o[u],issues:[]},r);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&n.issues.push(...Ve(u,p.issues)),n.value[l]=p.value})):(f.issues.length&&n.issues.push(...Ve(u,f.issues)),n.value[l]=f.value)}let a;for(let u in o)c.has(u)||(a=a??[],a.push(u));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{n.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:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&uo.test(c)&&a.issues.length){let l=t.keyType._zod.run({value:Number(c),issues:[]},r);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");l.issues.length===0&&(a=l)}if(a.issues.length){t.mode==="loose"?n.value[c]=o[c]:n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(l=>fe(l,r,he())),input:c,path:[c],inst:e});continue}let d=t.valueType._zod.run({value:o[c],issues:[]},r);d instanceof Promise?s.push(d.then(l=>{l.issues.length&&n.issues.push(...Ve(c,l.issues)),n.value[a.value]=l.value})):(d.issues.length&&n.issues.push(...Ve(c,d.issues)),n.value[a.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}});var Rc=g("$ZodEnum",(e,t)=>{Z.init(e,t);let n=Yt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>no.has(typeof o)).map(o=>typeof o=="string"?Ue(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{let i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),Oc=g("$ZodLiteral",(e,t)=>{if(Z.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?Ue(r):r?Ue(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{let s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}});var $c=g("$ZodTransform",(e,t)=>{Z.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new _t(e.constructor.name);let o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n.fallback=!0,n));if(o instanceof Promise)throw new Re;return n.value=o,n.fallback=!0,n}});function ji(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var yo=g("$ZodOptional",(e,t)=>{Z.init(e,t),e._zod.optin="optional",e._zod.optout="optional",C(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),C(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ht(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){let o=n.value,s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>ji(i,o)):ji(s,o)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Nc=g("$ZodExactOptional",(e,t)=>{yo.init(e,t),C(e._zod,"values",()=>t.innerType._zod.values),C(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Cc=g("$ZodNullable",(e,t)=>{Z.init(e,t),C(e._zod,"optin",()=>t.innerType._zod.optin),C(e._zod,"optout",()=>t.innerType._zod.optout),C(e._zod,"pattern",()=>{let n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ht(n.source)}|null)$`):void 0}),C(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Tc=g("$ZodDefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",C(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;let o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Ui(s,t)):Ui(o,t)}});function Ui(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var zc=g("$ZodPrefault",(e,t)=>{Z.init(e,t),e._zod.optin="optional",C(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Pc=g("$ZodNonOptional",(e,t)=>{Z.init(e,t),C(e._zod,"values",()=>{let n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{let o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>Vi(s,e)):Vi(o,e)}});function Vi(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 Lc=g("$ZodCatch",(e,t)=>{Z.init(e,t),e._zod.optin="optional",C(e._zod,"optout",()=>t.innerType._zod.optout),C(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>fe(i,r,he()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>fe(s,r,he()))},input:n.value}),n.issues=[],n.fallback=!0),n)}});var Mc=g("$ZodPipe",(e,t)=>{Z.init(e,t),C(e._zod,"values",()=>t.in._zod.values),C(e._zod,"optin",()=>t.in._zod.optin),C(e._zod,"optout",()=>t.out._zod.optout),C(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){let s=t.out._zod.run(n,r);return s instanceof Promise?s.then(i=>Un(i,t.in,r)):Un(s,t.in,r)}let o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>Un(s,t.out,r)):Un(o,t.out,r)}});function Un(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Zc=g("$ZodReadonly",(e,t)=>{Z.init(e,t),C(e._zod,"propValues",()=>t.innerType._zod.propValues),C(e._zod,"values",()=>t.innerType._zod.values),C(e._zod,"optin",()=>t.innerType?._zod?.optin),C(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);let o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Qi):Qi(o)}});function Qi(e){return e.value=Object.freeze(e.value),e}var Fc=g("$ZodLazy",(e,t)=>{Z.init(e,t),C(e._zod,"innerType",()=>{let n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),C(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),C(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),C(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),C(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Bc=g("$ZodCustom",(e,t)=>{Y.init(e,t),Z.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{let r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>Ji(s,n,r,e));Ji(o,n,r,e)}});function Ji(e,t,n,r){if(!e){let o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(vt(o))}}var jc,Lh=Symbol("ZodOutput"),Mh=Symbol("ZodInput"),go=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){let r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){let n=t._zod.parent;if(n){let r={...this.get(n)??{}};delete r.id;let o={...r,...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 ud(){return new go}(jc=globalThis).__zod_globalRegistry??(jc.__zod_globalRegistry=ud());var pt=globalThis.__zod_globalRegistry;function Uc(e,t){return new e({type:"string",...I(t)})}function Vc(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...I(t)})}function bo(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...I(t)})}function Qc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...I(t)})}function Jc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...I(t)})}function Gc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...I(t)})}function qc(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...I(t)})}function Kc(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...I(t)})}function Wc(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...I(t)})}function Yc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...I(t)})}function Xc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...I(t)})}function Hc(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...I(t)})}function ea(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...I(t)})}function ta(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...I(t)})}function na(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...I(t)})}function ra(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...I(t)})}function oa(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...I(t)})}function sa(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...I(t)})}function ia(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...I(t)})}function ca(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...I(t)})}function aa(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...I(t)})}function ua(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...I(t)})}function la(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...I(t)})}function fa(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...I(t)})}function da(e,t){return new e({type:"string",format:"date",check:"string_format",...I(t)})}function pa(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...I(t)})}function ma(e,t){return new e({type:"string",format:"duration",check:"string_format",...I(t)})}function ha(e,t){return new e({type:"number",checks:[],...I(t)})}function ya(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...I(t)})}function ga(e,t){return new e({type:"boolean",...I(t)})}function ba(e,t){return new e({type:"null",...I(t)})}function wa(e){return new e({type:"unknown"})}function _a(e,t){return new e({type:"never",...I(t)})}function Jn(e,t){return new lo({check:"less_than",...I(t),value:e,inclusive:!1})}function on(e,t){return new lo({check:"less_than",...I(t),value:e,inclusive:!0})}function Gn(e,t){return new fo({check:"greater_than",...I(t),value:e,inclusive:!1})}function sn(e,t){return new fo({check:"greater_than",...I(t),value:e,inclusive:!0})}function qn(e,t){return new ki({check:"multiple_of",...I(t),value:e})}function Kn(e,t){return new Di({check:"max_length",...I(t),maximum:e})}function kt(e,t){return new Ii({check:"min_length",...I(t),minimum:e})}function Wn(e,t){return new Ri({check:"length_equals",...I(t),length:e})}function wo(e,t){return new Oi({check:"string_format",format:"regex",...I(t),pattern:e})}function _o(e){return new $i({check:"string_format",format:"lowercase",...I(e)})}function xo(e){return new Ni({check:"string_format",format:"uppercase",...I(e)})}function Eo(e,t){return new Ci({check:"string_format",format:"includes",...I(t),includes:e})}function So(e,t){return new Ti({check:"string_format",format:"starts_with",...I(t),prefix:e})}function vo(e,t){return new zi({check:"string_format",format:"ends_with",...I(t),suffix:e})}function He(e){return new Pi({check:"overwrite",tx:e})}function ko(e){return He(t=>t.normalize(e))}function Ao(){return He(e=>e.trim())}function Do(){return He(e=>e.toLowerCase())}function Io(){return He(e=>e.toUpperCase())}function Ro(){return He(e=>eo(e))}function xa(e,t,n){return new e({type:"array",element:t,...I(n)})}function Ea(e,t,n){return new e({type:"custom",check:"custom",fn:t,...I(n)})}function Sa(e,t){let n=ld(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(vt(o,r.value,n._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),r.issues.push(vt(s))}},e(r.value,r)),t);return n}function ld(e,t){let n=new Y({check:"custom",...I(t)});return n._zod.check=e,n}function Oo(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??pt,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 Q(e,t,n={path:[],schemaPath:[]}){var r;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);let c=e._zod.toJSONSchema?.();if(c)i.schema=c;else{let d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,d);else{let f=i.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,f,d)}let l=e._zod.parent;l&&(i.ref||(i.ref=l),Q(l,t,d),t.seen.get(l).isParent=!0)}let a=t.metadataRegistry.get(e);return a&&Object.assign(i.schema,a),t.io==="input"&&ee(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((r=i.schema).default??(r.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function $o(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=new Map;for(let i of e.seen.entries()){let c=e.metadataRegistry.get(i[0])?.id;if(c){let a=r.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.`);r.set(c,i[0])}}let o=i=>{let c=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let l=e.external.registry.get(i[0])?.id,f=e.external.uri??(y=>y);if(l)return{ref:f(l)};let p=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=p,{defId:p,ref:`${f("__shared")}#/${c}/${p}`}}if(i[1]===n)return{ref:"#"};let u=`#/${c}/`,d=i[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},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 d=c.schema;for(let l in d)delete d[l];d.$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>-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 $o(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=c=>{let a=e.seen.get(c);if(a.ref===null)return;let u=a.def??a.schema,d={...u},l=a.ref;if(a.ref=null,l){r(l);let p=e.seen.get(l),y=p.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,d),c._zod.parent===l)for(let h in u)h==="$ref"||h==="allOf"||h in d||delete u[h];if(y.$ref&&p.def)for(let h in u)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(u[h])===JSON.stringify(p.def[h])&&delete u[h]}let f=c._zod.parent;if(f&&f!==l){r(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let y in u)y==="$ref"||y==="allOf"||y in p.def&&JSON.stringify(u[y])===JSON.stringify(p.def[y])&&delete u[y]}e.override({zodSchema:c,jsonSchema:u,path:a.path??[]})};for(let c of[...e.seen.entries()].reverse())r(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,n.def??n.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:sn(t,"input",e.processors),output:sn(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function ee(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return ee(r.element,n);if(r.type==="set")return ee(r.valueType,n);if(r.type==="lazy")return ee(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return ee(r.innerType,n);if(r.type==="intersection")return ee(r.left,n)||ee(r.right,n);if(r.type==="record"||r.type==="map")return ee(r.keyType,n)||ee(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ee(r.in,n)||ee(r.out,n);if(r.type==="object"){for(let o in r.shape)if(ee(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(let o of r.options)if(ee(o,n))return!0;return!1}if(r.type==="tuple"){for(let o of r.items)if(ee(o,n))return!0;return!!(r.rest&&ee(r.rest,n))}return!1}var _a=(e,t={})=>n=>{let r=Oo({...n,processors:t});return Q(e,r),Ro(r,e),$o(r,e)},sn=(e,t,n={})=>r=>{let{libraryOptions:o,target:s}=r??{},i=Oo({...o??{},target:s,io:t,processors:n});return Q(e,i),Ro(i,e),$o(i,e)};var ad={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},xa=(e,t,n,r)=>{let o=n;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=ad[c]??c,o.format===""&&delete o.format,c==="time"&&delete o.format),u&&(o.contentEncoding=u),a&&a.size>0){let d=[...a];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(l=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:l.source}))])}},Ea=(e,t,n,r)=>{let o=n,{minimum:s,maximum:i,format:c,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number";let l=typeof d=="number"&&d>=(s??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";l?p?(o.minimum=d,o.exclusiveMinimum=!0):o.exclusiveMinimum=d:typeof s=="number"&&(o.minimum=s),f?p?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof i=="number"&&(o.maximum=i),typeof a=="number"&&(o.multipleOf=a)},Sa=(e,t,n,r)=>{n.type="boolean"};var va=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"};var ka=(e,t,n,r)=>{n.not={}};var Aa=(e,t,n,r)=>{};var Da=(e,t,n,r)=>{let o=e._zod.def,s=Wt(o.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},Ia=(e,t,n,r)=>{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];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),s.every(i=>typeof i=="boolean")&&(n.type="boolean"),s.every(i=>i===null)&&(n.type="null"),n.enum=s};var Oa=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")};var Ra=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")};var $a=(e,t,n,r)=>{let o=n,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=Q(s.element,t,{...r,path:[...r.path,"items"]})},Na=(e,t,n,r)=>{let o=n,s=e._zod.def;o.type="object",o.properties={};let i=s.shape;for(let u in i)o.properties[u]=Q(i[u],t,{...r,path:[...r.path,"properties",u]});let c=new Set(Object.keys(i)),a=new Set([...c].filter(u=>{let d=s.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.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=Q(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Ca=(e,t,n,r)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((c,a)=>Q(c,t,{...r,path:[...r.path,s?"oneOf":"anyOf",a]}));s?n.oneOf=i:n.anyOf=i},Ta=(e,t,n,r)=>{let o=e._zod.def,s=Q(o.left,t,{...r,path:[...r.path,"allOf",0]}),i=Q(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=u=>"allOf"in u&&Object.keys(u).length===1,a=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];n.allOf=a};var za=(e,t,n,r)=>{let o=n,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 d=Q(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(let l of a)o.patternProperties[l.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=Q(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=Q(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});let u=i._zod.values;if(u){let d=[...u].filter(l=>typeof l=="string"||typeof l=="number");d.length>0&&(o.required=d)}},Pa=(e,t,n,r)=>{let o=e._zod.def,s=Q(o.innerType,t,r),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},La=(e,t,n,r)=>{let o=e._zod.def;Q(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType},Ma=(e,t,n,r)=>{let o=e._zod.def;Q(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Za=(e,t,n,r)=>{let o=e._zod.def;Q(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Fa=(e,t,n,r)=>{let o=e._zod.def;Q(o.innerType,t,r);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")}n.default=i},Ba=(e,t,n,r)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;Q(i,t,r);let c=t.seen.get(e);c.ref=i},ja=(e,t,n,r)=>{let o=e._zod.def;Q(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0};var No=(e,t,n,r)=>{let o=e._zod.def;Q(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType},Ua=(e,t,n,r)=>{let o=e._zod.innerType;Q(o,t,r);let s=t.seen.get(e);s.ref=o};var hd=g("ZodISODateTime",(e,t)=>{ec.init(e,t),j.init(e,t)});function Qa(e){return ca(hd,e)}var yd=g("ZodISODate",(e,t)=>{tc.init(e,t),j.init(e,t)});function Ja(e){return aa(yd,e)}var gd=g("ZodISOTime",(e,t)=>{nc.init(e,t),j.init(e,t)});function Va(e){return ua(gd,e)}var bd=g("ZodISODuration",(e,t)=>{rc.init(e,t),j.init(e,t)});function Ga(e){return la(bd,e)}var xd=(e,t)=>{Ln.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>zs(e,n)},flatten:{value:n=>Ts(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Et,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Et,2)}},isEmpty:{get(){return e.issues.length===0}}})};var ie=g("ZodError",xd,{Parent:Error});var qa=Mn(ie),Ka=Zn(ie),Wa=en(ie),Ya=tn(ie),Xa=Ms(ie),Ha=Zs(ie),eu=Fs(ie),tu=Bs(ie),nu=js(ie),ru=Us(ie),ou=Qs(ie),su=Js(ie);var iu=new WeakMap;function cn(e,t,n){let r=Object.getPrototypeOf(e),o=iu.get(r);if(o||(o=new Set,iu.set(r,o)),!o.has(t)){o.add(t);for(let s in n){let i=n[s];Object.defineProperty(r,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 B=g("ZodType",(e,t)=>(Z.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:sn(e,"input"),output:sn(e,"output")}}),e.toJSONSchema=_a(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>qa(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Wa(e,n,r),e.parseAsync=async(n,r)=>Ka(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Ya(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>Xa(e,n,r),e.decode=(n,r)=>Ha(e,n,r),e.encodeAsync=async(n,r)=>eu(e,n,r),e.decodeAsync=async(n,r)=>tu(e,n,r),e.safeEncode=(n,r)=>nu(e,n,r),e.safeDecode=(n,r)=>ru(e,n,r),e.safeEncodeAsync=async(n,r)=>ou(e,n,r),e.safeDecodeAsync=async(n,r)=>su(e,n,r),cn(e,"ZodType",{check(...n){let r=this.def;return this.clone(z.mergeDefs(r,{checks:[...r.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return ye(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(hp(n,r))},superRefine(n,r){return this.check(yp(n,r))},overwrite(n){return this.check(He(n))},optional(){return fu(this)},exactOptional(){return tp(this)},nullable(){return du(this)},nullish(){return fu(du(this))},nonoptional(n){return cp(this,n)},array(){return U(this)},or(n){return Xn([this,n])},and(n){return Wd(this,n)},transform(n){return pu(this,Hd(n))},default(n){return op(this,n)},prefault(n){return ip(this,n)},catch(n){return up(this,n)},pipe(n){return pu(this,n)},readonly(){return dp(this)},describe(n){let r=this.clone();return pt.add(r,{description:n}),r},meta(...n){if(n.length===0)return pt.get(this);let r=this.clone();return pt.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return pt.get(e)?.description},configurable:!0}),e)),mu=g("_ZodString",(e,t)=>{Qn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,s)=>xa(e,r,o,s);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,cn(e,"_ZodString",{regex(...r){return this.check(bo(...r))},includes(...r){return this.check(xo(...r))},startsWith(...r){return this.check(Eo(...r))},endsWith(...r){return this.check(So(...r))},min(...r){return this.check(kt(...r))},max(...r){return this.check(qn(...r))},length(...r){return this.check(Kn(...r))},nonempty(...r){return this.check(kt(1,...r))},lowercase(r){return this.check(wo(r))},uppercase(r){return this.check(_o(r))},trim(){return this.check(ko())},normalize(...r){return this.check(vo(...r))},toLowerCase(){return this.check(Ao())},toUpperCase(){return this.check(Do())},slugify(){return this.check(Io())}})}),Sd=g("ZodString",(e,t)=>{Qn.init(e,t),mu.init(e,t),e.email=n=>e.check(Fc(vd,n)),e.url=n=>e.check(Jc(kd,n)),e.jwt=n=>e.check(ia(Fd,n)),e.emoji=n=>e.check(Vc(Ad,n)),e.guid=n=>e.check(go(cu,n)),e.uuid=n=>e.check(Bc(Yn,n)),e.uuidv4=n=>e.check(jc(Yn,n)),e.uuidv6=n=>e.check(Uc(Yn,n)),e.uuidv7=n=>e.check(Qc(Yn,n)),e.nanoid=n=>e.check(Gc(Dd,n)),e.guid=n=>e.check(go(cu,n)),e.cuid=n=>e.check(qc(Id,n)),e.cuid2=n=>e.check(Kc(Od,n)),e.ulid=n=>e.check(Wc(Rd,n)),e.base64=n=>e.check(ra(Ld,n)),e.base64url=n=>e.check(oa(Md,n)),e.xid=n=>e.check(Yc($d,n)),e.ksuid=n=>e.check(Xc(Nd,n)),e.ipv4=n=>e.check(Hc(Cd,n)),e.ipv6=n=>e.check(ea(Td,n)),e.cidrv4=n=>e.check(ta(zd,n)),e.cidrv6=n=>e.check(na(Pd,n)),e.e164=n=>e.check(sa(Zd,n)),e.datetime=n=>e.check(Qa(n)),e.date=n=>e.check(Ja(n)),e.time=n=>e.check(Va(n)),e.duration=n=>e.check(Ga(n))});function k(e){return Zc(Sd,e)}var j=g("ZodStringFormat",(e,t)=>{F.init(e,t),mu.init(e,t)}),vd=g("ZodEmail",(e,t)=>{Ji.init(e,t),j.init(e,t)});var cu=g("ZodGUID",(e,t)=>{Ui.init(e,t),j.init(e,t)});var Yn=g("ZodUUID",(e,t)=>{Qi.init(e,t),j.init(e,t)});var kd=g("ZodURL",(e,t)=>{Vi.init(e,t),j.init(e,t)});var Ad=g("ZodEmoji",(e,t)=>{Gi.init(e,t),j.init(e,t)});var Dd=g("ZodNanoID",(e,t)=>{qi.init(e,t),j.init(e,t)});var Id=g("ZodCUID",(e,t)=>{Ki.init(e,t),j.init(e,t)});var Od=g("ZodCUID2",(e,t)=>{Wi.init(e,t),j.init(e,t)});var Rd=g("ZodULID",(e,t)=>{Yi.init(e,t),j.init(e,t)});var $d=g("ZodXID",(e,t)=>{Xi.init(e,t),j.init(e,t)});var Nd=g("ZodKSUID",(e,t)=>{Hi.init(e,t),j.init(e,t)});var Cd=g("ZodIPv4",(e,t)=>{oc.init(e,t),j.init(e,t)});var Td=g("ZodIPv6",(e,t)=>{sc.init(e,t),j.init(e,t)});var zd=g("ZodCIDRv4",(e,t)=>{ic.init(e,t),j.init(e,t)});var Pd=g("ZodCIDRv6",(e,t)=>{cc.init(e,t),j.init(e,t)});var Ld=g("ZodBase64",(e,t)=>{uc.init(e,t),j.init(e,t)});var Md=g("ZodBase64URL",(e,t)=>{lc.init(e,t),j.init(e,t)});var Zd=g("ZodE164",(e,t)=>{fc.init(e,t),j.init(e,t)});var Fd=g("ZodJWT",(e,t)=>{dc.init(e,t),j.init(e,t)});var hu=g("ZodNumber",(e,t)=>{po.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Ea(e,r,o,s),cn(e,"ZodNumber",{gt(r,o){return this.check(Vn(r,o))},gte(r,o){return this.check(on(r,o))},min(r,o){return this.check(on(r,o))},lt(r,o){return this.check(Jn(r,o))},lte(r,o){return this.check(rn(r,o))},max(r,o){return this.check(rn(r,o))},int(r){return this.check(au(r))},safe(r){return this.check(au(r))},positive(r){return this.check(Vn(0,r))},nonnegative(r){return this.check(on(0,r))},negative(r){return this.check(Jn(0,r))},nonpositive(r){return this.check(rn(0,r))},multipleOf(r,o){return this.check(Gn(r,o))},step(r,o){return this.check(Gn(r,o))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function M(e){return fa(hu,e)}var Bd=g("ZodNumberFormat",(e,t)=>{pc.init(e,t),hu.init(e,t)});function au(e){return da(Bd,e)}var jd=g("ZodBoolean",(e,t)=>{mc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Sa(e,n,r,o)});function et(e){return pa(jd,e)}var Ud=g("ZodNull",(e,t)=>{hc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>va(e,n,r,o)});function Qd(e){return ma(Ud,e)}var Jd=g("ZodUnknown",(e,t)=>{yc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Aa(e,n,r,o)});function uu(){return ha(Jd)}var Vd=g("ZodNever",(e,t)=>{gc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ka(e,n,r,o)});function yu(e){return ya(Vd,e)}var Gd=g("ZodArray",(e,t)=>{bc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$a(e,n,r,o),e.element=t.element,cn(e,"ZodArray",{min(n,r){return this.check(kt(n,r))},nonempty(n){return this.check(kt(1,n))},max(n,r){return this.check(qn(n,r))},length(n,r){return this.check(Kn(n,r))},unwrap(){return this.element}})});function U(e,t){return ga(Gd,e,t)}var gu=g("ZodObject",(e,t)=>{xc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Na(e,n,r,o),z.defineLazy(e,"shape",()=>t.shape),cn(e,"ZodObject",{keyof(){return ce(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:uu()})},loose(){return this.clone({...this._zod.def,catchall:uu()})},strict(){return this.clone({...this._zod.def,catchall:yu()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return z.extend(this,n)},safeExtend(n){return z.safeExtend(this,n)},merge(n){return z.merge(this,n)},pick(n){return z.pick(this,n)},omit(n){return z.omit(this,n)},partial(...n){return z.partial(wu,this,n[0])},required(...n){return z.required(_u,this,n[0])}})});function de(e,t){let n={type:"object",shape:e??{},...z.normalizeParams(t)};return new gu(n)}function O(e,t){return new gu({type:"object",shape:e,catchall:yu(),...z.normalizeParams(t)})}var bu=g("ZodUnion",(e,t)=>{mo.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ca(e,n,r,o),e.options=t.options});function Xn(e,t){return new bu({type:"union",options:e,...z.normalizeParams(t)})}var qd=g("ZodDiscriminatedUnion",(e,t)=>{bu.init(e,t),Ec.init(e,t)});function At(e,t,n){return new qd({type:"union",options:t,discriminator:e,...z.normalizeParams(n)})}var Kd=g("ZodIntersection",(e,t)=>{Sc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ta(e,n,r,o)});function Wd(e,t){return new Kd({type:"intersection",left:e,right:t})}var lu=g("ZodRecord",(e,t)=>{vc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>za(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function Ie(e,t,n){return!t||!t._zod?new lu({type:"record",keyType:k(),valueType:e,...z.normalizeParams(t)}):new lu({type:"record",keyType:e,valueType:t,...z.normalizeParams(n)})}var Co=g("ZodEnum",(e,t)=>{kc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Da(e,r,o,s),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{let s={};for(let i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Co({...t,checks:[],...z.normalizeParams(o),entries:s})},e.exclude=(r,o)=>{let s={...t.entries};for(let i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Co({...t,checks:[],...z.normalizeParams(o),entries:s})}});function ce(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Co({type:"enum",entries:n,...z.normalizeParams(t)})}var Yd=g("ZodLiteral",(e,t)=>{Ac.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ia(e,n,r,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 P(e,t){return new Yd({type:"literal",values:Array.isArray(e)?e:[e],...z.normalizeParams(t)})}var Xd=g("ZodTransform",(e,t)=>{Dc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ra(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new _t(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(z.issue(s,n.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(z.issue(i))}};let o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});function Hd(e){return new Xd({type:"transform",transform:e})}var wu=g("ZodOptional",(e,t)=>{ho.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>No(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function fu(e){return new wu({type:"optional",innerType:e})}var ep=g("ZodExactOptional",(e,t)=>{Ic.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>No(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function tp(e){return new ep({type:"optional",innerType:e})}var np=g("ZodNullable",(e,t)=>{Oc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Pa(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function du(e){return new np({type:"nullable",innerType:e})}var rp=g("ZodDefault",(e,t)=>{Rc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ma(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function op(e,t){return new rp({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():z.shallowClone(t)}})}var sp=g("ZodPrefault",(e,t)=>{$c.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Za(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ip(e,t){return new sp({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():z.shallowClone(t)}})}var _u=g("ZodNonOptional",(e,t)=>{Nc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>La(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function cp(e,t){return new _u({type:"nonoptional",innerType:e,...z.normalizeParams(t)})}var ap=g("ZodCatch",(e,t)=>{Cc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fa(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function up(e,t){return new ap({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var lp=g("ZodPipe",(e,t)=>{Tc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ba(e,n,r,o),e.in=t.in,e.out=t.out});function pu(e,t){return new lp({type:"pipe",in:e,out:t})}var fp=g("ZodReadonly",(e,t)=>{zc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ja(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function dp(e){return new fp({type:"readonly",innerType:e})}var pp=g("ZodLazy",(e,t)=>{Pc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ua(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function To(e){return new pp({type:"lazy",getter:e})}var mp=g("ZodCustom",(e,t)=>{Lc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Oa(e,n,r,o)});function hp(e,t={}){return ba(mp,e,t)}function yp(e,t){return wa(e,t)}function tt(e){let t=To(()=>Xn([k(e),M(),et(),Qd(),U(t),Ie(k(),t)]));return t}var xu=e=>"field"in e?[e]:("all"in e?e.all:e.any).flatMap(xu),Hn=e=>xu(e);var Dt=(e,t)=>{if("field"in e)return t(e);let n="all"in e?e.all:e.any,r=!1;if("all"in e){for(let o of n){let s=Dt(o,t);if(s===!1)return!1;r||=s===void 0}return r?void 0:!0}for(let o of n){let s=Dt(o,t);if(s===!0)return!0;r||=s===void 0}return r?void 0:!1},Eu=e=>JSON.stringify(e),zo=e=>{if("field"in e)return{conditions:1,depth:0};let t="all"in e?e.all:e.any,n=0,r=1;for(let o of t){let s=zo(o);n+=s.conditions,r=Math.max(r,s.depth+1)}return{conditions:n,depth:r}},Su=(e,t={})=>{let n=o=>{let s=U(o),i=t.maximumChildren===void 0?s:s.max(t.maximumChildren);return Xn([e,O({all:i}),O({any:i})])},r=To(()=>n(r));return t.maximumConditions===void 0&&t.maximumDepth===void 0?r:r.superRefine((o,s)=>{let{conditions:i,depth:c}=zo(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 D={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};function mt(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 r=mt(e.toJSON(),t);return t.delete(e),r}if(t.has(e))throw new Error("Circular reference detected");t.add(e);let n;if(Array.isArray(e))n=`[${e.map(o=>mt(o===void 0||typeof o=="symbol"?null:o,t)).join(",")}]`;else{let r=[];for(let o of Object.keys(e).sort())e[o]===void 0||typeof e[o]=="symbol"||r.push(`${mt(o)}:${mt(e[o],t)}`);n=`{${r.join(",")}}`}return t.delete(e),n}var gp=new TextEncoder,It=e=>gp.encode(e),Oe=e=>It(e).byteLength,te=class extends Error{constructor(){super("Byte stream exceeds the configured limit"),this.name="ByteLimitExceededError"}},bp=(e,t)=>{let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.byteLength;return n},Ot=e=>typeof e=="string"?{async*[Symbol.asyncIterator](){yield It(e)}}:e instanceof Uint8Array?{async*[Symbol.asyncIterator](){yield e}}:e,wp=async(e,t)=>{let n=[],r=0;for await(let o of Ot(e)){let s=t-r;if(s<=0)break;let i=o.subarray(0,s);if(n.push(i),r+=i.byteLength,r===t)break}return bp(n,r)},pe=async(e,t)=>{let n=await wp(e,t+1);if(n.byteLength>t)throw new te;return n},ae=e=>new TextDecoder("utf-8",{fatal:!0}).decode(e),Rt=e=>e.charCodeAt(0)===65279?e.slice(1):e;var vu=e=>{for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n>=55296&&n<=56319){let r=e.charCodeAt(t+1);if(t+1>=e.length||r<56320||r>57343)throw new Error("JSON strings cannot contain lone Unicode surrogates");t+=1;continue}if(n>=56320&&n<=57343)throw new Error("JSON strings cannot contain lone Unicode surrogates")}},Po=(e,t)=>{if(e===null||typeof e=="boolean")return e;if(typeof e=="string")return vu(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 n=[];for(let r=0;r<e.length;r+=1){if(Object.hasOwn(e,r)===!1)throw new Error("JSON arrays cannot be sparse");let o=e[r];if(o===void 0)throw new Error("JSON arrays cannot contain undefined values");n.push(Po(o,t))}if(Object.keys(e).length!==e.length)throw new Error("JSON arrays cannot contain named properties");return n}finally{t.delete(e)}}if(typeof e=="object"){let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==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 r={};try{for(let[o,s]of Object.entries(e))vu(o),s!==void 0&&Object.defineProperty(r,o,{value:Po(s,t),enumerable:!0,configurable:!0,writable:!0})}finally{t.delete(e)}return r}throw new Error("Value cannot be represented as JSON")},nt=e=>Po(e,new Set),Re=e=>{let t=mt(nt(e));if(t===void 0)throw new Error("Value cannot be represented as canonical JSON");return t},an=(e,t)=>e===void 0||t===void 0?e===t:Re(e)===Re(t),$e=(e,t)=>e<t?-1:e>t?1:0,Lo=async e=>{let t=typeof e=="string"?It(e):e,n=await globalThis.crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n),r=>r.toString(16).padStart(2,"0")).join("")},ku=async e=>`sha256:${await Lo(e)}`;var Au=At("type",[O({type:P("document")}),O({type:P("json"),path:U(k()).min(1)}),O({type:P("markdown-body")}),O({type:P("markdown-frontmatter")})]),Mo=O({documentId:k().min(1),revision:k().min(1),representation:Au}),_p=e=>{let t=Au.parse(e);return t.type==="json"?Object.freeze({...t,path:Object.freeze([...t.path])}):Object.freeze(t)},Du=e=>{let t=Mo.parse(e);return Object.freeze({...t,representation:_p(t.representation)})};var er=O({id:k().min(1),revision:k().min(1),contentRef:k().min(1),format:ce(["json","markdown"]).optional()}),tr=O({sourceId:k().min(1),referenceId:k().min(1),reference:Mo});var $t=e=>{let t=new Map;for(let n of e){let r=t.get(n.sourceId)??[];r.push(n),t.set(n.sourceId,r)}return t};var Ne=class extends Error{code;documentIds;constructor({code:t,message:n,documentIds:r=[]}){super(n),this.name="DocumentGraphError",this.code=t,this.documentIds=Object.freeze([...r])}},xp=(e,t)=>$e(e.sourceId,t.sourceId)||$e(e.referenceId,t.referenceId),un=({nodes:e,edges:t})=>{let n=e.map(c=>Object.freeze(er.parse(c))).sort((c,a)=>$e(c.id,a.id)),r=new Map,o=new Map;for(let c of n){if(r.has(c.id))throw new Ne({code:"DUPLICATE_NODE",message:`Document graph contains duplicate node ${c.id}`,documentIds:[c.id]});r.set(c.id,c);let a=o.get(c.contentRef);if(a!==void 0&&(a.revision!==c.revision||a.format!==c.format))throw new Ne({code:"CONTENT_IDENTITY_CONFLICT",message:`Document graph content reference ${c.contentRef} has conflicting identities`,documentIds:[a.id,c.id]});o.set(c.contentRef,c)}let s=t.map(c=>{let a=tr.parse(c);return Object.freeze({...a,reference:Du(a.reference)})}).sort(xp),i=new Set;for(let c of s){if(r.get(c.sourceId)===void 0)throw new Ne({code:"SOURCE_NOT_FOUND",message:`Document graph source ${c.sourceId} does not exist`,documentIds:[c.sourceId]});let u=r.get(c.reference.documentId);if(u===void 0)throw new Ne({code:"TARGET_NOT_FOUND",message:`Document graph target ${c.reference.documentId} does not exist`,documentIds:[c.sourceId,c.reference.documentId]});if(u.revision!==c.reference.revision)throw new Ne({code:"TARGET_REVISION_MISMATCH",message:`Document graph target ${u.id} revision does not match its reference`,documentIds:[c.sourceId,u.id]});let d=`${c.sourceId}\0${c.referenceId}`;if(i.has(d))throw new Ne({code:"DUPLICATE_REFERENCE",message:`Document ${c.sourceId} contains duplicate reference ID ${c.referenceId}`,documentIds:[c.sourceId]});i.add(d)}return Object.freeze({nodes:Object.freeze(n),edges:Object.freeze(s)})},Ep=e=>new Map(e.nodes.map(t=>[t.id,t]));var nr=({graph:e,rootIds:t})=>{let n=Ep(e),r=$t(e.edges),o=new Map,s=[],i=[],c=a=>{let u=n.get(a);if(u===void 0)throw new Ne({code:"ROOT_NOT_FOUND",message:`Document graph root ${a} does not exist`,documentIds:[a]});let d=o.get(a);if(d!=="visited"){if(d==="visiting"){let l=s.indexOf(a),f=[...s.slice(l),a];throw new Ne({code:"CYCLE",message:`Document graph contains a cycle: ${f.join(" -> ")}`,documentIds:f})}o.set(a,"visiting"),s.push(a);for(let l of r.get(a)??[])c(l.reference.documentId);s.pop(),o.set(a,"visited"),i.push(u)}};for(let a of[...new Set(t)].sort($e))c(a);return Object.freeze(i)};var Sp=k().regex(/^sha256:[a-f0-9]{64}$/),Iu=O({format:P("webstudio-document-graph"),version:P(1),nodes:U(er),edges:U(tr),integrity:O({algorithm:P("sha256"),checksum:Sp})});var vp=k().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"}),$u=O({_id:k().min(1),_type:P("asset.file"),name:k().min(1),description:k().optional(),path:vp,key:k(),folderId:k().min(1).optional(),extension:k().regex(/^[a-z0-9]*$/),mimeType:k().min(1),size:M().int().nonnegative(),createdAt:k().datetime().optional(),revision:k().min(1),contentRef:k().min(1),properties:Ie(k(),tt()),excerpt:k().optional(),metadataError:O({code:k().min(1),message:k().min(1)}).optional()}),Fo=$u.partial().required({_id:!0}),kp=ce(["null","boolean","number","string","object","array"]),Ap=de({format:P("webstudio-builder-asset-field-catalog"),version:P(1),canonicalRevision:k().regex(/^sha256:[a-f0-9]{64}$/),documentCount:M().int().nonnegative(),fields:Ie(k().min(1),de({queryPath:U(k().min(1)).min(1).max(D.fieldPathDepth).optional(),types:U(kp).min(1),occurrences:M().int().positive(),optional:P(!0).optional(),mixed:P(!0).optional()}))}).superRefine((e,t)=>{for(let[n,r]of Object.entries(e.fields)){let o=[...new Set(r.types)].sort();JSON.stringify(r.types)!==JSON.stringify(o)&&t.addIssue({code:"custom",path:["fields",n,"types"],message:"Observed field types must be unique and sorted"}),r.occurrences>e.documentCount&&t.addIssue({code:"custom",path:["fields",n,"occurrences"],message:"Field occurrences cannot exceed the document count"});let s=r.occurrences<e.documentCount;r.optional===!0!==s&&t.addIssue({code:"custom",path:["fields",n,"optional"],message:"Field optionality must match its occurrence count"});let i=o.length>1;r.mixed===!0!==i&&t.addIssue({code:"custom",path:["fields",n,"mixed"],message:"Mixed status must match the observed types"})}}),rr=k().regex(/^sha256:[a-f0-9]{64}$/),Nu=O({fields:U(U(k().min(1)).min(1).max(D.fieldPathDepth)).min(1).max(D.outputFieldCount+1),rows:U(U(tt())).max(D.resultCount),totalCount:M().int().nonnegative().max(D.candidateDocuments),hasMore:et()}).superRefine(({fields:e,rows:t},n)=>{for(let[r,o]of t.entries())o.length!==e.length&&n.addIssue({code:"custom",path:["rows",r],message:"Materialized query rows must match the field count"})}),Ou=O({format:P("webstudio-content-database"),version:P(1),assetRevision:rr,documents:U(Fo),documentGraph:Iu.optional(),contents:Ie(k().min(1),k()).optional(),assetReferences:Ie(k().min(1),U(O({start:M().int().nonnegative(),end:M().int().positive(),assetId:k().min(1),suffix:k().min(1).optional()}).refine(({start:e,end:t})=>t>e,{message:"Markdown asset reference range must not be empty"}))).optional(),fieldCatalog:Ap,queries:Ie(rr,Nu).optional(),database:O({maxBytes:M().int().positive(),unboundedBytes:M().int().nonnegative(),sourceDocumentCount:M().int().nonnegative(),includedDocumentCount:M().int().nonnegative().optional()}).optional(),integrity:O({algorithm:P("sha256"),checksum:rr})}).superRefine((e,t)=>{e.documents.length>D.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 n;for(let[o,s]of e.documents.entries())n!==void 0&&s._id<=n&&t.addIssue({code:"custom",path:["documents",o,"_id"],message:"Asset index documents must have unique sorted IDs"}),n=s._id;let r=new Set(e.documents.flatMap(({contentRef:o})=>o===void 0?[]:[o]));for(let o of Object.keys(e.contents??{}))r.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??{}))r.has(o)===!1&&t.addIssue({code:"custom",path:["assetReferences",o],message:"Asset references must belong to an indexed document"})}),Dp=At("mode",[de({mode:P("none")}),de({mode:P("full"),maxBytes:M().int().positive().max(D.hydratedFileBytes).optional()}),de({mode:P("range"),offset:M().int().nonnegative(),length:M().int().positive().max(D.hydratedRangeBytes)}),de({mode:P("markdown-body-ref"),maxBytes:M().int().positive().max(D.hydratedFileBytes).optional()})]),Bo={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"]},Cu=Object.keys(Bo),Tu=["url","width","height"],or=e=>Tu.includes(e),zu=Cu.filter(e=>or(e)===!1&&e!=="excerpt"),Pu=zu.filter(e=>e!=="id"),Lu=e=>zu.includes(e),Ip=ce(Cu),ln=U(k().min(1)).min(1).max(D.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||Ip.safeParse(e[0]).success===!1)&&t.addIssue({code:"custom",message:"Asset query field path is unsupported"})}),Zo=et().default(!0),Op=At("mode",[O({mode:P("all"),includeMetadata:Zo}),O({mode:P("base"),includeMetadata:Zo}),O({mode:P("fields"),includeMetadata:Zo,fields:U(ln).max(D.outputFieldCount).refine(e=>new Set(e.map(Eu)).size===e.length,{error:"Selected output fields must be unique"})})]),Rp={mode:"fields",includeMetadata:!1,fields:Tu.map(e=>[e])},Mu=["eq","ne","contains","startsWith","endsWith","gt","gte","lt","lte"],Qg=[...Mu,"in","exists","isEmpty"],$p=O({field:ln,operator:ce(Mu),value:tt()}),Np=O({field:ln,operator:P("in"),value:U(tt()).max(D.resultCount)}),Cp=O({field:ln,operator:ce(["exists","isEmpty"]),value:et()}),Tp=At("operator",[$p,Np,Cp]),zp=Su(Tp,{maximumChildren:D.filterCount,maximumConditions:D.filterCount,maximumDepth:D.filterDepth,maximumConditionsMessage:"Asset query exceeds the filter limit",maximumDepthMessage:"Asset query exceeds the filter nesting limit"});var Pp=zp,Zu=e=>{let t=new Set(["eq","ne","in","exists"]);return e.some(n=>n==="string"||n==="array")&&t.add("contains"),e.includes("string")&&(t.add("startsWith"),t.add("endsWith")),e.some(n=>n==="string"||n==="number")&&(t.add("gt"),t.add("gte"),t.add("lt"),t.add("lte")),e.some(n=>n==="string"||n==="array"||n==="object")&&t.add("isEmpty"),[...t]},Lp=O({field:ln,direction:ce(["asc","desc"])}),Mp=({output:e,content:t})=>e.includeMetadata||e.mode==="all"||e.mode==="fields"&&e.fields.length>0||t.mode!=="none",rt=O({where:Pp.default({all:[]}),sort:U(Lp).max(D.sortCount).default([]),limit:M().int().nonnegative().max(D.resultCount).default(D.defaultResultCount),offset:M().int().nonnegative().max(D.candidateDocuments).default(0),output:Op.default(Rp),content:Dp.default({mode:"none"})}).refine(Mp,{error:"Select at least one asset query output"}),Fu=O({query:rt,indexRevision:k().min(1).max(255).optional()}),Zp=de({_id:k().min(1),revision:k().min(1),contentRef:k().min(1),encoding:P("utf-8"),text:k(),range:de({offset:M().int().nonnegative(),length:M().int().nonnegative(),total:M().int().nonnegative()}).optional()}),Fp=Zp.omit({_id:!0,revision:!0,contentRef:!0}),Bp=$u.omit({_id:!0,_type:!0,contentRef:!0}).partial().extend({id:k().min(1),url:k().min(1).optional(),width:M().positive().optional(),height:M().positive().optional(),content:Fp.optional()}).refine(e=>e.width===void 0==(e.height===void 0),{error:"Asset dimensions must include both width and height"}),jp=O({format:P("webstudio-content-database"),version:P(1),revision:rr,usedBytes:M().int().nonnegative(),maxBytes:M().int().positive(),unboundedBytes:M().int().nonnegative(),includedDocumentCount:M().int().nonnegative(),omittedDocumentCount:M().int().nonnegative(),omissionReason:ce(["size","unavailable"]).optional(),truncated:et()}),Ru=jp.pick({usedBytes:!0,maxBytes:!0,unboundedBytes:!0,includedDocumentCount:!0,omittedDocumentCount:!0,omissionReason:!0,truncated:!0}),sr=O({items:U(Bp),totalCount:M().int().nonnegative(),hasMore:et()}),Up=O({scope:P("query-preview"),query:Ru,database:Ru,artifacts:O({query:Ou,database:Ou}).optional(),unresolved:sr.optional()}),Jg=O({data:sr,__diagnostics__:Up}),Qp=ce(["INVALID_REQUEST","REQUEST_CANCELLED","UNAUTHORIZED","FORBIDDEN","STALE_INDEX","CONTENT_IDENTITY_REQUIRED","CONTENT_NOT_TEXT","CONTENT_DECODING_FAILED","CONTENT_LIMIT_EXCEEDED","INTERNAL_ERROR"]),Jp=de({ok:P(!1),error:de({code:Qp,message:k().min(1),retryable:et(),details:Ie(k(),tt()).optional()}),meta:de({queryHash:k().min(1).optional(),indexRevision:k().min(1).optional(),assetRevision:k().min(1).optional()}).optional()}),Bu=({code:e,message:t,retryable:n=!1,details:r})=>Jp.parse({ok:!1,error:{code:e,message:t,retryable:n,details:r}});var ju=function*(e){if(e.length>0&&!e.startsWith("/")||/~(?![01])/.test(e))throw Error("Invalid JSON Pointer");let t=1,n=0;for(;n<e.length;){let r=e.indexOf("/",t);n=r===-1?e.length:r;let o=e.slice(t,n);t=n+1,yield Gp(o)}};var jo=(e,t)=>t+"/"+Vp(e),Vp=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),Gp=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~");var ir=async(e,t,n)=>{if(Number.isSafeInteger(t)===!1||t<=0)throw new Error("Concurrency must be a positive safe integer");let r=0,o=new Array(e.length),s=async()=>{for(;r<e.length;){let u=r;r+=1,o[u]=await n(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 Nt=e=>typeof e=="object"&&e!==null&&Array.isArray(e)===!1,Uu=e=>{if(Nt(e)===!1)return;let t=Object.keys(e);if(!(t.length!==1||t[0]!=="$ref"))return e.$ref};var ue=class extends Error{code;referenceId;constructor({code:t,message:n,referenceId:r,cause:o}){super(n,{cause:o}),this.name="JsonDocumentError",this.code=t,this.referenceId=r}},qp=(e,t)=>{let n=Uu(e);if(n!==void 0){if(typeof n!="string")throw new ue({code:"INVALID_REFERENCE_MARKER",message:`JSON reference marker ${t} must contain a string $ref`,referenceId:t});return n}},Kp=e=>`#${e}`;var Qu=async({source:e,maximumBytes:t=D.hydratedFileBytes})=>{let n;try{n=await pe(e,t)}catch(o){throw o instanceof te?new ue({code:"CONTENT_LIMIT_EXCEEDED",message:"JSON document exceeds the byte limit",cause:o}):o}let r;try{r=Rt(ae(n))}catch(o){throw new ue({code:"CONTENT_DECODING_FAILED",message:"JSON document is not valid UTF-8",cause:o})}try{return nt(JSON.parse(r))}catch(o){throw new ue({code:"INVALID_DOCUMENT",message:"JSON document is invalid",cause:o})}};var Wp=(e,t)=>{let n=e;for(let r of t){if(Array.isArray(n)){let o=Number(r);if(Number.isSafeInteger(o)===!1||o<0||String(o)!==r||o>=n.length)return;n=n[o];continue}if(Nt(n)&&Object.hasOwn(n,r)){n=n[r];continue}return}return n},Ju=({document:e,representation:t})=>{let n=nt(e);if(t.type==="document")return n;if(t.type!=="json")throw new ue({code:"UNSUPPORTED_REPRESENTATION",message:`JSON documents do not support ${t.type}`});let r=Wp(n,t.path);if(r===void 0)throw new ue({code:"JSON_PATH_NOT_FOUND",message:"JSON document path does not exist"});return r},Yp=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})},cr=({document:e,references:t,allowUnresolvedReferences:n=!1})=>{let r=nt(e),o=new Set,s=(c,a)=>{let u=Kp(a);if(qp(c,u)!==void 0){if(t.has(u)===!1){if(n)return c;throw new ue({code:"REFERENCE_NOT_FOUND",message:`Resolved JSON reference ${u} is unavailable`,referenceId:u})}o.add(u);try{return nt(t.get(u))}catch(l){throw new ue({code:"INVALID_RESOLVED_VALUE",message:`Resolved JSON reference ${u} is not JSON-compatible`,referenceId:u,cause:l})}}if(Array.isArray(c))return c.map((l,f)=>s(l,jo(String(f),a)));if(Nt(c)){let l={};for(let[f,p]of Object.entries(c))Yp(l,f,s(p,jo(f,a)));return l}return c},i=s(r,"");for(let c of[...t.keys()].sort())if(o.has(c)===!1)throw new ue({code:"UNUSED_REFERENCE",message:`Resolved JSON reference ${c} has no marker`,referenceId:c});return i};var ar=Symbol.for("yaml.alias"),ur=Symbol.for("yaml.document"),ge=Symbol.for("yaml.map"),Uo=Symbol.for("yaml.pair"),le=Symbol.for("yaml.scalar"),Ue=Symbol.for("yaml.seq"),ne=Symbol.for("yaml.node.type"),be=e=>!!e&&typeof e=="object"&&e[ne]===ar,Ce=e=>!!e&&typeof e=="object"&&e[ne]===ur,we=e=>!!e&&typeof e=="object"&&e[ne]===ge,N=e=>!!e&&typeof e=="object"&&e[ne]===Uo,R=e=>!!e&&typeof e=="object"&&e[ne]===le,_e=e=>!!e&&typeof e=="object"&&e[ne]===Ue;function L(e){if(e&&typeof e=="object")switch(e[ne]){case ge:case Ue:return!0}return!1}function T(e){if(e&&typeof e=="object")switch(e[ne]){case ar:case ge:case le:case Ue:return!0}return!1}var lr=e=>(R(e)||L(e))&&!!e.anchor;var se=Symbol("break visit"),Vu=Symbol("skip children"),Te=Symbol("remove node");function ze(e,t){let n=Gu(t);Ce(e)?Ct(null,e.contents,n,Object.freeze([e]))===Te&&(e.contents=null):Ct(null,e,n,Object.freeze([]))}ze.BREAK=se;ze.SKIP=Vu;ze.REMOVE=Te;function Ct(e,t,n,r){let o=qu(e,t,n,r);if(T(o)||N(o))return Ku(e,r,o),Ct(e,o,n,r);if(typeof o!="symbol"){if(L(t)){r=Object.freeze(r.concat(t));for(let s=0;s<t.items.length;++s){let i=Ct(s,t.items[s],n,r);if(typeof i=="number")s=i-1;else{if(i===se)return se;i===Te&&(t.items.splice(s,1),s-=1)}}}else if(N(t)){r=Object.freeze(r.concat(t));let s=Ct("key",t.key,n,r);if(s===se)return se;s===Te&&(t.key=null);let i=Ct("value",t.value,n,r);if(i===se)return se;i===Te&&(t.value=null)}}return o}async function fr(e,t){let n=Gu(t);Ce(e)?await Tt(null,e.contents,n,Object.freeze([e]))===Te&&(e.contents=null):await Tt(null,e,n,Object.freeze([]))}fr.BREAK=se;fr.SKIP=Vu;fr.REMOVE=Te;async function Tt(e,t,n,r){let o=await qu(e,t,n,r);if(T(o)||N(o))return Ku(e,r,o),Tt(e,o,n,r);if(typeof o!="symbol"){if(L(t)){r=Object.freeze(r.concat(t));for(let s=0;s<t.items.length;++s){let i=await Tt(s,t.items[s],n,r);if(typeof i=="number")s=i-1;else{if(i===se)return se;i===Te&&(t.items.splice(s,1),s-=1)}}}else if(N(t)){r=Object.freeze(r.concat(t));let s=await Tt("key",t.key,n,r);if(s===se)return se;s===Te&&(t.key=null);let i=await Tt("value",t.value,n,r);if(i===se)return se;i===Te&&(t.value=null)}}return o}function Gu(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function qu(e,t,n,r){if(typeof n=="function")return n(e,t,r);if(we(t))return n.Map?.(e,t,r);if(_e(t))return n.Seq?.(e,t,r);if(N(t))return n.Pair?.(e,t,r);if(R(t))return n.Scalar?.(e,t,r);if(be(t))return n.Alias?.(e,t,r)}function Ku(e,t,n){let r=t[t.length-1];if(L(r))r.items[e]=n;else if(N(r))e==="key"?r.key=n:r.value=n;else if(Ce(r))r.contents=n;else{let o=be(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${o} parent`)}}var Xp={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Hp=e=>e.replace(/[!,[\]{}]/g,t=>Xp[t]),Pe=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let r=t.trim().split(/[ \t]+/),o=r.shift();switch(o){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[s,i]=r;return this.tags[s]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[s]=r;if(s==="1.1"||s==="1.2")return this.yaml.version=s,!0;{let i=/^\d+\.\d+$/.test(s);return n(6,`Unsupported YAML version ${s}`,i),!1}}default:return n(0,`Unknown directive ${o}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let i=t.slice(2,-1);return i==="!"||i==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),i)}let[,r,o]=t.match(/^(.*!)([^!]*)$/s);o||n(`The ${t} tag has no suffix`);let s=this.tags[r];if(s)try{return s+decodeURIComponent(o)}catch(i){return n(String(i)),null}return r==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[n,r]of Object.entries(this.tags))if(t.startsWith(r))return n+Hp(t.substring(r.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),o;if(t&&r.length>0&&T(t.contents)){let s={};ze(t.contents,(i,c)=>{T(c)&&c.tag&&(s[c.tag]=!0)}),o=Object.keys(s)}else o=[];for(let[s,i]of r)s==="!!"&&i==="tag:yaml.org,2002:"||(!t||o.some(c=>c.startsWith(i)))&&n.push(`%TAG ${s} ${i}`);return n.join(`-`)}};Pe.defaultYaml={explicit:!1,version:"1.2"};Pe.defaultTags={"!!":"tag:yaml.org,2002:"};function dr(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(n)}return!0}function Qo(e){let t=new Set;return ze(e,{Value(n,r){r.anchor&&t.add(r.anchor)}}),t}function Jo(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function Wu(e,t){let n=[],r=new Map,o=null;return{onAnchor:s=>{n.push(s),o??(o=Qo(e));let i=Jo(t,o);return o.add(i),i},setAnchors:()=>{for(let s of n){let i=r.get(s);if(typeof i=="object"&&i.anchor&&(R(i.node)||L(i.node)))i.node.anchor=i.anchor;else{let c=new Error("Failed to resolve repeated object (this should not happen)");throw c.source=s,c}}},sourceObjects:r}}function ot(e,t,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let o=0,s=r.length;o<s;++o){let i=r[o],c=ot(e,r,String(o),i);c===void 0?delete r[o]:c!==i&&(r[o]=c)}else if(r instanceof Map)for(let o of Array.from(r.keys())){let s=r.get(o),i=ot(e,r,o,s);i===void 0?r.delete(o):i!==s&&r.set(o,i)}else if(r instanceof Set)for(let o of Array.from(r)){let s=ot(e,r,o,o);s===void 0?r.delete(o):s!==o&&(r.delete(o),r.add(s))}else for(let[o,s]of Object.entries(r)){let i=ot(e,r,o,s);i===void 0?delete r[o]:i!==s&&(r[o]=i)}return e.call(t,n,r)}function K(e,t,n){if(Array.isArray(e))return e.map((r,o)=>K(r,String(o),n));if(e&&typeof e.toJSON=="function"){if(!n||!lr(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=s=>{r.res=s,delete n.onCreate};let o=e.toJSON(t,n);return n.onCreate&&n.onCreate(o),o}return typeof e=="bigint"&&!n?.keep?Number(e):e}var st=class{constructor(t){Object.defineProperty(this,ne,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:n,maxAliasCount:r,onAnchor:o,reviver:s}={}){if(!Ce(t))throw new TypeError("A document argument is required");let i={anchors:new Map,doc:t,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},c=K(this,"",i);if(typeof o=="function")for(let{count:a,res:u}of i.anchors.values())o(u,a);return typeof s=="function"?ot(s,{"":c},"",c):c}};var Qe=class extends st{constructor(t){super(ar),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,n){if(n?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],ze(t,{Node:(s,i)=>{(be(i)||lr(i))&&r.push(i)}}),n&&(n.aliasResolveCache=r));let o;for(let s of r){if(s===this)break;s.anchor===this.source&&(o=s)}return o}toJSON(t,n){if(!n)return{source:this.source};let{anchors:r,doc:o,maxAliasCount:s}=n,i=this.resolve(o,n);if(!i){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(a)}let c=r.get(i);if(c||(K(i,null,n),c=r.get(i)),c?.res===void 0){let a="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(a)}if(s>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=pr(o,i,r)),c.count*c.aliasCount>s)){let a="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(a)}return c.res}toString(t,n,r){let o=`*${this.source}`;if(t){if(dr(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(s)}if(t.implicitKey)return`${o} `}return o}};function pr(e,t,n){if(be(t)){let r=t.resolve(e),o=n&&r&&n.get(r);return o?o.count*o.aliasCount:0}else if(L(t)){let r=0;for(let o of t.items){let s=pr(e,o,n);s>r&&(r=s)}return r}else if(N(t)){let r=pr(e,t.key,n),o=pr(e,t.value,n);return Math.max(r,o)}return 1}var mr=e=>!e||typeof e!="function"&&typeof e!="object",A=class extends st{constructor(t){super(le),this.value=t}toJSON(t,n){return n?.keep?this.value:K(this.value,t,n)}toString(){return String(this.value)}};A.BLOCK_FOLDED="BLOCK_FOLDED";A.BLOCK_LITERAL="BLOCK_LITERAL";A.PLAIN="PLAIN";A.QUOTE_DOUBLE="QUOTE_DOUBLE";A.QUOTE_SINGLE="QUOTE_SINGLE";var em="tag:yaml.org,2002:";function tm(e,t,n){if(t){let r=n.filter(s=>s.tag===t),o=r.find(s=>!s.format)??r[0];if(!o)throw new Error(`Tag ${t} not found`);return o}return n.find(r=>r.identify?.(e)&&!r.format)}function Je(e,t,n){if(Ce(e)&&(e=e.contents),T(e))return e;if(N(e)){let l=n.schema[ge].createNode?.(n.schema,null,n);return l.items.push(e),l}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:o,onTagObj:s,schema:i,sourceObjects:c}=n,a;if(r&&e&&typeof e=="object"){if(a=c.get(e),a)return a.anchor??(a.anchor=o(e)),new Qe(a.anchor);a={anchor:null,node:null},c.set(e,a)}t?.startsWith("!!")&&(t=em+t.slice(2));let u=tm(e,t,i.tags);if(!u){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let l=new A(e);return a&&(a.node=l),l}u=e instanceof Map?i[ge]:Symbol.iterator in Object(e)?i[Ue]:i[ge]}s&&(s(u),delete n.onTagObj);let d=u?.createNode?u.createNode(n.schema,e,n):typeof u?.nodeClass?.from=="function"?u.nodeClass.from(n.schema,e,n):new A(e);return t?d.tag=t:u.default||(d.tag=u.tag),a&&(a.node=d),d}function fn(e,t,n){let r=n;for(let o=t.length-1;o>=0;--o){let s=t[o];if(typeof s=="number"&&Number.isInteger(s)&&s>=0){let i=[];i[s]=r,r=i}else r=new Map([[s,r]])}return Je(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var Pt=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,zt=class extends st{constructor(t,n){super(t),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(t){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(n.schema=t),n.items=n.items.map(r=>T(r)||N(r)?r.clone(t):r),this.range&&(n.range=this.range.slice()),n}addIn(t,n){if(Pt(t))this.add(n);else{let[r,...o]=t,s=this.get(r,!0);if(L(s))s.addIn(o,n);else if(s===void 0&&this.schema)this.set(r,fn(this.schema,o,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${o}`)}}deleteIn(t){let[n,...r]=t;if(r.length===0)return this.delete(n);let o=this.get(n,!0);if(L(o))return o.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(t,n){let[r,...o]=t,s=this.get(r,!0);return o.length===0?!n&&R(s)?s.value:s:L(s)?s.getIn(o,n):void 0}hasAllNullValues(t){return this.items.every(n=>{if(!N(n))return!1;let r=n.value;return r==null||t&&R(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(t){let[n,...r]=t;if(r.length===0)return this.has(n);let o=this.get(n,!0);return L(o)?o.hasIn(r):!1}setIn(t,n){let[r,...o]=t;if(o.length===0)this.set(r,n);else{let s=this.get(r,!0);if(L(s))s.setIn(o,n);else if(s===void 0&&this.schema)this.set(r,fn(this.schema,o,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${o}`)}}};var Yu=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function me(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Le=(e,t,n)=>e.endsWith(`+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 No(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=c=>{let a=e.seen.get(c);if(a.ref===null)return;let u=a.def??a.schema,d={...u},l=a.ref;if(a.ref=null,l){r(l);let p=e.seen.get(l),y=p.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,d),c._zod.parent===l)for(let h in u)h==="$ref"||h==="allOf"||h in d||delete u[h];if(y.$ref&&p.def)for(let h in u)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(u[h])===JSON.stringify(p.def[h])&&delete u[h]}let f=c._zod.parent;if(f&&f!==l){r(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let y in u)y==="$ref"||y==="allOf"||y in p.def&&JSON.stringify(u[y])===JSON.stringify(p.def[y])&&delete u[y]}e.override({zodSchema:c,jsonSchema:u,path:a.path??[]})};for(let c of[...e.seen.entries()].reverse())r(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,n.def??n.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:cn(t,"input",e.processors),output:cn(t,"output",e.processors)}},enumerable:!1,writable:!1}),c}catch{throw new Error("Error converting schema to JSON.")}}function ee(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return ee(r.element,n);if(r.type==="set")return ee(r.valueType,n);if(r.type==="lazy")return ee(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return ee(r.innerType,n);if(r.type==="intersection")return ee(r.left,n)||ee(r.right,n);if(r.type==="record"||r.type==="map")return ee(r.keyType,n)||ee(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ee(r.in,n)||ee(r.out,n);if(r.type==="object"){for(let o in r.shape)if(ee(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(let o of r.options)if(ee(o,n))return!0;return!1}if(r.type==="tuple"){for(let o of r.items)if(ee(o,n))return!0;return!!(r.rest&&ee(r.rest,n))}return!1}var va=(e,t={})=>n=>{let r=Oo({...n,processors:t});return Q(e,r),$o(r,e),No(r,e)},cn=(e,t,n={})=>r=>{let{libraryOptions:o,target:s}=r??{},i=Oo({...o??{},target:s,io:t,processors:n});return Q(e,i),$o(i,e),No(i,e)};var fd={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},ka=(e,t,n,r)=>{let o=n;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=fd[c]??c,o.format===""&&delete o.format,c==="time"&&delete o.format),u&&(o.contentEncoding=u),a&&a.size>0){let d=[...a];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(l=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:l.source}))])}},Aa=(e,t,n,r)=>{let o=n,{minimum:s,maximum:i,format:c,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof c=="string"&&c.includes("int")?o.type="integer":o.type="number";let l=typeof d=="number"&&d>=(s??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";l?p?(o.minimum=d,o.exclusiveMinimum=!0):o.exclusiveMinimum=d:typeof s=="number"&&(o.minimum=s),f?p?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof i=="number"&&(o.maximum=i),typeof a=="number"&&(o.multipleOf=a)},Da=(e,t,n,r)=>{n.type="boolean"};var Ia=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"};var Ra=(e,t,n,r)=>{n.not={}};var Oa=(e,t,n,r)=>{};var $a=(e,t,n,r)=>{let o=e._zod.def,s=Yt(o.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},Na=(e,t,n,r)=>{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];n.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[i]:n.const=i}else s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),s.every(i=>typeof i=="boolean")&&(n.type="boolean"),s.every(i=>i===null)&&(n.type="null"),n.enum=s};var Ca=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")};var Ta=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")};var za=(e,t,n,r)=>{let o=n,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=Q(s.element,t,{...r,path:[...r.path,"items"]})},Pa=(e,t,n,r)=>{let o=n,s=e._zod.def;o.type="object",o.properties={};let i=s.shape;for(let u in i)o.properties[u]=Q(i[u],t,{...r,path:[...r.path,"properties",u]});let c=new Set(Object.keys(i)),a=new Set([...c].filter(u=>{let d=s.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.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=Q(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},La=(e,t,n,r)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((c,a)=>Q(c,t,{...r,path:[...r.path,s?"oneOf":"anyOf",a]}));s?n.oneOf=i:n.anyOf=i},Ma=(e,t,n,r)=>{let o=e._zod.def,s=Q(o.left,t,{...r,path:[...r.path,"allOf",0]}),i=Q(o.right,t,{...r,path:[...r.path,"allOf",1]}),c=u=>"allOf"in u&&Object.keys(u).length===1,a=[...c(s)?s.allOf:[s],...c(i)?i.allOf:[i]];n.allOf=a};var Za=(e,t,n,r)=>{let o=n,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 d=Q(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(let l of a)o.patternProperties[l.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=Q(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=Q(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});let u=i._zod.values;if(u){let d=[...u].filter(l=>typeof l=="string"||typeof l=="number");d.length>0&&(o.required=d)}},Fa=(e,t,n,r)=>{let o=e._zod.def,s=Q(o.innerType,t,r),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},Ba=(e,t,n,r)=>{let o=e._zod.def;Q(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType},ja=(e,t,n,r)=>{let o=e._zod.def;Q(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Ua=(e,t,n,r)=>{let o=e._zod.def;Q(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Va=(e,t,n,r)=>{let o=e._zod.def;Q(o.innerType,t,r);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")}n.default=i},Qa=(e,t,n,r)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;Q(i,t,r);let c=t.seen.get(e);c.ref=i},Ja=(e,t,n,r)=>{let o=e._zod.def;Q(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0};var Co=(e,t,n,r)=>{let o=e._zod.def;Q(o.innerType,t,r);let s=t.seen.get(e);s.ref=o.innerType},Ga=(e,t,n,r)=>{let o=e._zod.innerType;Q(o,t,r);let s=t.seen.get(e);s.ref=o};var bd=g("ZodISODateTime",(e,t)=>{oc.init(e,t),V.init(e,t)});function qa(e){return fa(bd,e)}var wd=g("ZodISODate",(e,t)=>{sc.init(e,t),V.init(e,t)});function Ka(e){return da(wd,e)}var _d=g("ZodISOTime",(e,t)=>{ic.init(e,t),V.init(e,t)});function Wa(e){return pa(_d,e)}var xd=g("ZodISODuration",(e,t)=>{cc.init(e,t),V.init(e,t)});function Ya(e){return ma(xd,e)}var vd=(e,t)=>{Mn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Zs(e,n)},flatten:{value:n=>Ms(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Et,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Et,2)}},isEmpty:{get(){return e.issues.length===0}}})};var ie=g("ZodError",vd,{Parent:Error});var Xa=Zn(ie),Ha=Fn(ie),eu=tn(ie),tu=nn(ie),nu=js(ie),ru=Us(ie),ou=Vs(ie),su=Qs(ie),iu=Js(ie),cu=Gs(ie),au=qs(ie),uu=Ks(ie);var lu=new WeakMap;function an(e,t,n){let r=Object.getPrototypeOf(e),o=lu.get(r);if(o||(o=new Set,lu.set(r,o)),!o.has(t)){o.add(t);for(let s in n){let i=n[s];Object.defineProperty(r,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 B=g("ZodType",(e,t)=>(Z.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:cn(e,"input"),output:cn(e,"output")}}),e.toJSONSchema=va(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>Xa(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>eu(e,n,r),e.parseAsync=async(n,r)=>Ha(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>tu(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>nu(e,n,r),e.decode=(n,r)=>ru(e,n,r),e.encodeAsync=async(n,r)=>ou(e,n,r),e.decodeAsync=async(n,r)=>su(e,n,r),e.safeEncode=(n,r)=>iu(e,n,r),e.safeDecode=(n,r)=>cu(e,n,r),e.safeEncodeAsync=async(n,r)=>au(e,n,r),e.safeDecodeAsync=async(n,r)=>uu(e,n,r),an(e,"ZodType",{check(...n){let r=this.def;return this.clone(z.mergeDefs(r,{checks:[...r.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return ye(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(bp(n,r))},superRefine(n,r){return this.check(wp(n,r))},overwrite(n){return this.check(He(n))},optional(){return hu(this)},exactOptional(){return op(this)},nullable(){return yu(this)},nullish(){return hu(yu(this))},nonoptional(n){return lp(this,n)},array(){return j(this)},or(n){return Hn([this,n])},and(n){return Hd(this,n)},transform(n){return gu(this,np(n))},default(n){return cp(this,n)},prefault(n){return up(this,n)},catch(n){return dp(this,n)},pipe(n){return gu(this,n)},readonly(){return hp(this)},describe(n){let r=this.clone();return pt.add(r,{description:n}),r},meta(...n){if(n.length===0)return pt.get(this);let r=this.clone();return pt.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return pt.get(e)?.description},configurable:!0}),e)),bu=g("_ZodString",(e,t)=>{Qn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,s)=>ka(e,r,o,s);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,an(e,"_ZodString",{regex(...r){return this.check(wo(...r))},includes(...r){return this.check(Eo(...r))},startsWith(...r){return this.check(So(...r))},endsWith(...r){return this.check(vo(...r))},min(...r){return this.check(kt(...r))},max(...r){return this.check(Kn(...r))},length(...r){return this.check(Wn(...r))},nonempty(...r){return this.check(kt(1,...r))},lowercase(r){return this.check(_o(r))},uppercase(r){return this.check(xo(r))},trim(){return this.check(Ao())},normalize(...r){return this.check(ko(...r))},toLowerCase(){return this.check(Do())},toUpperCase(){return this.check(Io())},slugify(){return this.check(Ro())}})}),Ad=g("ZodString",(e,t)=>{Qn.init(e,t),bu.init(e,t),e.email=n=>e.check(Vc(Dd,n)),e.url=n=>e.check(Kc(Id,n)),e.jwt=n=>e.check(la(Ud,n)),e.emoji=n=>e.check(Wc(Rd,n)),e.guid=n=>e.check(bo(fu,n)),e.uuid=n=>e.check(Qc(Xn,n)),e.uuidv4=n=>e.check(Jc(Xn,n)),e.uuidv6=n=>e.check(Gc(Xn,n)),e.uuidv7=n=>e.check(qc(Xn,n)),e.nanoid=n=>e.check(Yc(Od,n)),e.guid=n=>e.check(bo(fu,n)),e.cuid=n=>e.check(Xc($d,n)),e.cuid2=n=>e.check(Hc(Nd,n)),e.ulid=n=>e.check(ea(Cd,n)),e.base64=n=>e.check(ca(Fd,n)),e.base64url=n=>e.check(aa(Bd,n)),e.xid=n=>e.check(ta(Td,n)),e.ksuid=n=>e.check(na(zd,n)),e.ipv4=n=>e.check(ra(Pd,n)),e.ipv6=n=>e.check(oa(Ld,n)),e.cidrv4=n=>e.check(sa(Md,n)),e.cidrv6=n=>e.check(ia(Zd,n)),e.e164=n=>e.check(ua(jd,n)),e.datetime=n=>e.check(qa(n)),e.date=n=>e.check(Ka(n)),e.time=n=>e.check(Wa(n)),e.duration=n=>e.check(Ya(n))});function v(e){return Uc(Ad,e)}var V=g("ZodStringFormat",(e,t)=>{F.init(e,t),bu.init(e,t)}),Dd=g("ZodEmail",(e,t)=>{Ki.init(e,t),V.init(e,t)});var fu=g("ZodGUID",(e,t)=>{Gi.init(e,t),V.init(e,t)});var Xn=g("ZodUUID",(e,t)=>{qi.init(e,t),V.init(e,t)});var Id=g("ZodURL",(e,t)=>{Wi.init(e,t),V.init(e,t)});var Rd=g("ZodEmoji",(e,t)=>{Yi.init(e,t),V.init(e,t)});var Od=g("ZodNanoID",(e,t)=>{Xi.init(e,t),V.init(e,t)});var $d=g("ZodCUID",(e,t)=>{Hi.init(e,t),V.init(e,t)});var Nd=g("ZodCUID2",(e,t)=>{ec.init(e,t),V.init(e,t)});var Cd=g("ZodULID",(e,t)=>{tc.init(e,t),V.init(e,t)});var Td=g("ZodXID",(e,t)=>{nc.init(e,t),V.init(e,t)});var zd=g("ZodKSUID",(e,t)=>{rc.init(e,t),V.init(e,t)});var Pd=g("ZodIPv4",(e,t)=>{ac.init(e,t),V.init(e,t)});var Ld=g("ZodIPv6",(e,t)=>{uc.init(e,t),V.init(e,t)});var Md=g("ZodCIDRv4",(e,t)=>{lc.init(e,t),V.init(e,t)});var Zd=g("ZodCIDRv6",(e,t)=>{fc.init(e,t),V.init(e,t)});var Fd=g("ZodBase64",(e,t)=>{pc.init(e,t),V.init(e,t)});var Bd=g("ZodBase64URL",(e,t)=>{mc.init(e,t),V.init(e,t)});var jd=g("ZodE164",(e,t)=>{hc.init(e,t),V.init(e,t)});var Ud=g("ZodJWT",(e,t)=>{yc.init(e,t),V.init(e,t)});var wu=g("ZodNumber",(e,t)=>{mo.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Aa(e,r,o,s),an(e,"ZodNumber",{gt(r,o){return this.check(Gn(r,o))},gte(r,o){return this.check(sn(r,o))},min(r,o){return this.check(sn(r,o))},lt(r,o){return this.check(Jn(r,o))},lte(r,o){return this.check(on(r,o))},max(r,o){return this.check(on(r,o))},int(r){return this.check(du(r))},safe(r){return this.check(du(r))},positive(r){return this.check(Gn(0,r))},nonnegative(r){return this.check(sn(0,r))},negative(r){return this.check(Jn(0,r))},nonpositive(r){return this.check(on(0,r))},multipleOf(r,o){return this.check(qn(r,o))},step(r,o){return this.check(qn(r,o))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function M(e){return ha(wu,e)}var Vd=g("ZodNumberFormat",(e,t)=>{gc.init(e,t),wu.init(e,t)});function du(e){return ya(Vd,e)}var Qd=g("ZodBoolean",(e,t)=>{bc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Da(e,n,r,o)});function et(e){return ga(Qd,e)}var Jd=g("ZodNull",(e,t)=>{wc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ia(e,n,r,o)});function Gd(e){return ba(Jd,e)}var qd=g("ZodUnknown",(e,t)=>{_c.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Oa(e,n,r,o)});function pu(){return wa(qd)}var Kd=g("ZodNever",(e,t)=>{xc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ra(e,n,r,o)});function _u(e){return _a(Kd,e)}var Wd=g("ZodArray",(e,t)=>{Ec.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>za(e,n,r,o),e.element=t.element,an(e,"ZodArray",{min(n,r){return this.check(kt(n,r))},nonempty(n){return this.check(kt(1,n))},max(n,r){return this.check(Kn(n,r))},length(n,r){return this.check(Wn(n,r))},unwrap(){return this.element}})});function j(e,t){return xa(Wd,e,t)}var xu=g("ZodObject",(e,t)=>{kc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Pa(e,n,r,o),z.defineLazy(e,"shape",()=>t.shape),an(e,"ZodObject",{keyof(){return ce(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:pu()})},loose(){return this.clone({...this._zod.def,catchall:pu()})},strict(){return this.clone({...this._zod.def,catchall:_u()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return z.extend(this,n)},safeExtend(n){return z.safeExtend(this,n)},merge(n){return z.merge(this,n)},pick(n){return z.pick(this,n)},omit(n){return z.omit(this,n)},partial(...n){return z.partial(Su,this,n[0])},required(...n){return z.required(vu,this,n[0])}})});function de(e,t){let n={type:"object",shape:e??{},...z.normalizeParams(t)};return new xu(n)}function R(e,t){return new xu({type:"object",shape:e,catchall:_u(),...z.normalizeParams(t)})}var Eu=g("ZodUnion",(e,t)=>{ho.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>La(e,n,r,o),e.options=t.options});function Hn(e,t){return new Eu({type:"union",options:e,...z.normalizeParams(t)})}var Yd=g("ZodDiscriminatedUnion",(e,t)=>{Eu.init(e,t),Ac.init(e,t)});function At(e,t,n){return new Yd({type:"union",options:t,discriminator:e,...z.normalizeParams(n)})}var Xd=g("ZodIntersection",(e,t)=>{Dc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ma(e,n,r,o)});function Hd(e,t){return new Xd({type:"intersection",left:e,right:t})}var mu=g("ZodRecord",(e,t)=>{Ic.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Za(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function ge(e,t,n){return!t||!t._zod?new mu({type:"record",keyType:v(),valueType:e,...z.normalizeParams(t)}):new mu({type:"record",keyType:e,valueType:t,...z.normalizeParams(n)})}var To=g("ZodEnum",(e,t)=>{Rc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(r,o,s)=>$a(e,r,o,s),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{let s={};for(let i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new To({...t,checks:[],...z.normalizeParams(o),entries:s})},e.exclude=(r,o)=>{let s={...t.entries};for(let i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new To({...t,checks:[],...z.normalizeParams(o),entries:s})}});function ce(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new To({type:"enum",entries:n,...z.normalizeParams(t)})}var ep=g("ZodLiteral",(e,t)=>{Oc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Na(e,n,r,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 P(e,t){return new ep({type:"literal",values:Array.isArray(e)?e:[e],...z.normalizeParams(t)})}var tp=g("ZodTransform",(e,t)=>{$c.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ta(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new _t(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(z.issue(s,n.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(z.issue(i))}};let o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});function np(e){return new tp({type:"transform",transform:e})}var Su=g("ZodOptional",(e,t)=>{yo.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Co(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function hu(e){return new Su({type:"optional",innerType:e})}var rp=g("ZodExactOptional",(e,t)=>{Nc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Co(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function op(e){return new rp({type:"optional",innerType:e})}var sp=g("ZodNullable",(e,t)=>{Cc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fa(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function yu(e){return new sp({type:"nullable",innerType:e})}var ip=g("ZodDefault",(e,t)=>{Tc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ja(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function cp(e,t){return new ip({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():z.shallowClone(t)}})}var ap=g("ZodPrefault",(e,t)=>{zc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ua(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function up(e,t){return new ap({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():z.shallowClone(t)}})}var vu=g("ZodNonOptional",(e,t)=>{Pc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ba(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function lp(e,t){return new vu({type:"nonoptional",innerType:e,...z.normalizeParams(t)})}var fp=g("ZodCatch",(e,t)=>{Lc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Va(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function dp(e,t){return new fp({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var pp=g("ZodPipe",(e,t)=>{Mc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qa(e,n,r,o),e.in=t.in,e.out=t.out});function gu(e,t){return new pp({type:"pipe",in:e,out:t})}var mp=g("ZodReadonly",(e,t)=>{Zc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ja(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function hp(e){return new mp({type:"readonly",innerType:e})}var yp=g("ZodLazy",(e,t)=>{Fc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ga(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function zo(e){return new yp({type:"lazy",getter:e})}var gp=g("ZodCustom",(e,t)=>{Bc.init(e,t),B.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ca(e,n,r,o)});function bp(e,t={}){return Ea(gp,e,t)}function wp(e,t){return Sa(e,t)}function tt(e){let t=zo(()=>Hn([v(e),M(),et(),Gd(),j(t),ge(v(),t)]));return t}var ku=e=>"field"in e?[e]:("all"in e?e.all:e.any).flatMap(ku),er=e=>ku(e);var Dt=(e,t)=>{if("field"in e)return t(e);let n="all"in e?e.all:e.any,r=!1;if("all"in e){for(let o of n){let s=Dt(o,t);if(s===!1)return!1;r||=s===void 0}return r?void 0:!0}for(let o of n){let s=Dt(o,t);if(s===!0)return!0;r||=s===void 0}return r?void 0:!1},Au=e=>JSON.stringify(e),Po=e=>{if("field"in e)return{conditions:1,depth:0};let t="all"in e?e.all:e.any,n=0,r=1;for(let o of t){let s=Po(o);n+=s.conditions,r=Math.max(r,s.depth+1)}return{conditions:n,depth:r}},Du=(e,t={})=>{let n=o=>{let s=j(o),i=t.maximumChildren===void 0?s:s.max(t.maximumChildren);return Hn([e,R({all:i}),R({any:i})])},r=zo(()=>n(r));return t.maximumConditions===void 0&&t.maximumDepth===void 0?r:r.superRefine((o,s)=>{let{conditions:i,depth:c}=Po(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 D={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};function mt(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 r=mt(e.toJSON(),t);return t.delete(e),r}if(t.has(e))throw new Error("Circular reference detected");t.add(e);let n;if(Array.isArray(e))n=`[${e.map(o=>mt(o===void 0||typeof o=="symbol"?null:o,t)).join(",")}]`;else{let r=[];for(let o of Object.keys(e).sort())e[o]===void 0||typeof e[o]=="symbol"||r.push(`${mt(o)}:${mt(e[o],t)}`);n=`{${r.join(",")}}`}return t.delete(e),n}var _p=new TextEncoder,It=e=>_p.encode(e),Oe=e=>It(e).byteLength,te=class extends Error{constructor(){super("Byte stream exceeds the configured limit"),this.name="ByteLimitExceededError"}},xp=(e,t)=>{let n=new Uint8Array(t),r=0;for(let o of e)n.set(o,r),r+=o.byteLength;return n},Rt=e=>typeof e=="string"?{async*[Symbol.asyncIterator](){yield It(e)}}:e instanceof Uint8Array?{async*[Symbol.asyncIterator](){yield e}}:e,Ep=async(e,t)=>{let n=[],r=0;for await(let o of Rt(e)){let s=t-r;if(s<=0)break;let i=o.subarray(0,s);if(n.push(i),r+=i.byteLength,r===t)break}return xp(n,r)},pe=async(e,t)=>{let n=await Ep(e,t+1);if(n.byteLength>t)throw new te;return n},ae=e=>new TextDecoder("utf-8",{fatal:!0}).decode(e),Ot=e=>e.charCodeAt(0)===65279?e.slice(1):e;var Iu=e=>{for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n>=55296&&n<=56319){let r=e.charCodeAt(t+1);if(t+1>=e.length||r<56320||r>57343)throw new Error("JSON strings cannot contain lone Unicode surrogates");t+=1;continue}if(n>=56320&&n<=57343)throw new Error("JSON strings cannot contain lone Unicode surrogates")}},Lo=(e,t)=>{if(e===null||typeof e=="boolean")return e;if(typeof e=="string")return Iu(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 n=[];for(let r=0;r<e.length;r+=1){if(Object.hasOwn(e,r)===!1)throw new Error("JSON arrays cannot be sparse");let o=e[r];if(o===void 0)throw new Error("JSON arrays cannot contain undefined values");n.push(Lo(o,t))}if(Object.keys(e).length!==e.length)throw new Error("JSON arrays cannot contain named properties");return n}finally{t.delete(e)}}if(typeof e=="object"){let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==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 r={};try{for(let[o,s]of Object.entries(e))Iu(o),s!==void 0&&Object.defineProperty(r,o,{value:Lo(s,t),enumerable:!0,configurable:!0,writable:!0})}finally{t.delete(e)}return r}throw new Error("Value cannot be represented as JSON")},nt=e=>Lo(e,new Set),$e=e=>{let t=mt(nt(e));if(t===void 0)throw new Error("Value cannot be represented as canonical JSON");return t},un=(e,t)=>e===void 0||t===void 0?e===t:$e(e)===$e(t),Ne=(e,t)=>e<t?-1:e>t?1:0,Mo=async e=>{let t=typeof e=="string"?It(e):e,n=await globalThis.crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n),r=>r.toString(16).padStart(2,"0")).join("")},Ru=async e=>`sha256:${await Mo(e)}`;var Ou=At("type",[R({type:P("document")}),R({type:P("json"),path:j(v()).min(1)}),R({type:P("markdown-body")}),R({type:P("markdown-frontmatter")})]),Zo=R({documentId:v().min(1),revision:v().min(1),representation:Ou}),Sp=e=>{let t=Ou.parse(e);return t.type==="json"?Object.freeze({...t,path:Object.freeze([...t.path])}):Object.freeze(t)},$u=e=>{let t=Zo.parse(e);return Object.freeze({...t,representation:Sp(t.representation)})};var tr=R({id:v().min(1),revision:v().min(1),contentRef:v().min(1),format:ce(["json","markdown"]).optional()}),nr=R({sourceId:v().min(1),referenceId:v().min(1),reference:Zo});var $t=e=>{let t=new Map;for(let n of e){let r=t.get(n.sourceId)??[];r.push(n),t.set(n.sourceId,r)}return t};var Ce=class extends Error{code;documentIds;constructor({code:t,message:n,documentIds:r=[]}){super(n),this.name="DocumentGraphError",this.code=t,this.documentIds=Object.freeze([...r])}},vp=(e,t)=>Ne(e.sourceId,t.sourceId)||Ne(e.referenceId,t.referenceId),ln=({nodes:e,edges:t})=>{let n=e.map(c=>Object.freeze(tr.parse(c))).sort((c,a)=>Ne(c.id,a.id)),r=new Map,o=new Map;for(let c of n){if(r.has(c.id))throw new Ce({code:"DUPLICATE_NODE",message:`Document graph contains duplicate node ${c.id}`,documentIds:[c.id]});r.set(c.id,c);let a=o.get(c.contentRef);if(a!==void 0&&(a.revision!==c.revision||a.format!==c.format))throw new Ce({code:"CONTENT_IDENTITY_CONFLICT",message:`Document graph content reference ${c.contentRef} has conflicting identities`,documentIds:[a.id,c.id]});o.set(c.contentRef,c)}let s=t.map(c=>{let a=nr.parse(c);return Object.freeze({...a,reference:$u(a.reference)})}).sort(vp),i=new Set;for(let c of s){if(r.get(c.sourceId)===void 0)throw new Ce({code:"SOURCE_NOT_FOUND",message:`Document graph source ${c.sourceId} does not exist`,documentIds:[c.sourceId]});let u=r.get(c.reference.documentId);if(u===void 0)throw new Ce({code:"TARGET_NOT_FOUND",message:`Document graph target ${c.reference.documentId} does not exist`,documentIds:[c.sourceId,c.reference.documentId]});if(u.revision!==c.reference.revision)throw new Ce({code:"TARGET_REVISION_MISMATCH",message:`Document graph target ${u.id} revision does not match its reference`,documentIds:[c.sourceId,u.id]});let d=`${c.sourceId}\0${c.referenceId}`;if(i.has(d))throw new Ce({code:"DUPLICATE_REFERENCE",message:`Document ${c.sourceId} contains duplicate reference ID ${c.referenceId}`,documentIds:[c.sourceId]});i.add(d)}return Object.freeze({nodes:Object.freeze(n),edges:Object.freeze(s)})},kp=e=>new Map(e.nodes.map(t=>[t.id,t]));var rr=({graph:e,rootIds:t})=>{let n=kp(e),r=$t(e.edges),o=new Map,s=[],i=[],c=a=>{let u=n.get(a);if(u===void 0)throw new Ce({code:"ROOT_NOT_FOUND",message:`Document graph root ${a} does not exist`,documentIds:[a]});let d=o.get(a);if(d!=="visited"){if(d==="visiting"){let l=s.indexOf(a),f=[...s.slice(l),a];throw new Ce({code:"CYCLE",message:`Document graph contains a cycle: ${f.join(" -> ")}`,documentIds:f})}o.set(a,"visiting"),s.push(a);for(let l of r.get(a)??[])c(l.reference.documentId);s.pop(),o.set(a,"visited"),i.push(u)}};for(let a of[...new Set(t)].sort(Ne))c(a);return Object.freeze(i)};var Ap=v().regex(/^sha256:[a-f0-9]{64}$/),Nu=R({format:P("webstudio-document-graph"),version:P(1),nodes:j(tr),edges:j(nr),integrity:R({algorithm:P("sha256"),checksum:Ap})});var Dp=v().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"}),zu=R({_id:v().min(1),_type:P("asset.file"),name:v().min(1),description:v().optional(),path:Dp,key:v(),folderId:v().min(1).optional(),extension:v().regex(/^[a-z0-9]*$/),mimeType:v().min(1),size:M().int().nonnegative(),createdAt:v().datetime().optional(),revision:v().min(1),contentRef:v().min(1),properties:ge(v(),tt()),excerpt:v().optional(),metadataError:R({code:v().min(1),message:v().min(1)}).optional()}),Bo=zu.partial().required({_id:!0}),Ip=ce(["null","boolean","number","string","object","array"]),Rp=de({format:P("webstudio-builder-asset-field-catalog"),version:P(1),canonicalRevision:v().regex(/^sha256:[a-f0-9]{64}$/),documentCount:M().int().nonnegative(),fields:ge(v().min(1),de({queryPath:j(v().min(1)).min(1).max(D.fieldPathDepth).optional(),types:j(Ip).min(1),occurrences:M().int().positive(),optional:P(!0).optional(),mixed:P(!0).optional()}))}).superRefine((e,t)=>{for(let[n,r]of Object.entries(e.fields)){let o=[...new Set(r.types)].sort();JSON.stringify(r.types)!==JSON.stringify(o)&&t.addIssue({code:"custom",path:["fields",n,"types"],message:"Observed field types must be unique and sorted"}),r.occurrences>e.documentCount&&t.addIssue({code:"custom",path:["fields",n,"occurrences"],message:"Field occurrences cannot exceed the document count"});let s=r.occurrences<e.documentCount;r.optional===!0!==s&&t.addIssue({code:"custom",path:["fields",n,"optional"],message:"Field optionality must match its occurrence count"});let i=o.length>1;r.mixed===!0!==i&&t.addIssue({code:"custom",path:["fields",n,"mixed"],message:"Mixed status must match the observed types"})}}),or=v().regex(/^sha256:[a-f0-9]{64}$/),Pu=R({fields:j(j(v().min(1)).min(1).max(D.fieldPathDepth)).min(1).max(D.outputFieldCount+1),rows:j(j(tt())).max(D.resultCount),totalCount:M().int().nonnegative().max(D.candidateDocuments),hasMore:et()}).superRefine(({fields:e,rows:t},n)=>{for(let[r,o]of t.entries())o.length!==e.length&&n.addIssue({code:"custom",path:["rows",r],message:"Materialized query rows must match the field count"})}),Cu=R({format:P("webstudio-content-database"),version:P(1),assetRevision:or,documents:j(Bo),documentGraph:Nu.optional(),contents:ge(v().min(1),v()).optional(),assetReferences:ge(v().min(1),j(R({start:M().int().nonnegative(),end:M().int().positive(),assetId:v().min(1),suffix:v().min(1).optional()}).refine(({start:e,end:t})=>t>e,{message:"Markdown asset reference range must not be empty"}))).optional(),assetValueReferences:ge(v().min(1),j(R({path:j(v().min(1).or(M().int().nonnegative())).min(1),assetId:v().min(1),suffix:v().min(1).optional()}))).optional(),fieldCatalog:Rp,queries:ge(or,Pu).optional(),database:R({maxBytes:M().int().positive(),unboundedBytes:M().int().nonnegative(),sourceDocumentCount:M().int().nonnegative(),includedDocumentCount:M().int().nonnegative().optional()}).optional(),integrity:R({algorithm:P("sha256"),checksum:or})}).superRefine((e,t)=>{e.documents.length>D.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 n;for(let[o,s]of e.documents.entries())n!==void 0&&s._id<=n&&t.addIssue({code:"custom",path:["documents",o,"_id"],message:"Asset index documents must have unique sorted IDs"}),n=s._id;let r=new Set(e.documents.flatMap(({contentRef:o})=>o===void 0?[]:[o]));for(let o of Object.keys(e.contents??{}))r.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??{}))r.has(o)===!1&&t.addIssue({code:"custom",path:["assetReferences",o],message:"Asset references must belong to an indexed document"})}),Op=At("mode",[de({mode:P("none")}),de({mode:P("full"),maxBytes:M().int().positive().max(D.hydratedFileBytes).optional()}),de({mode:P("range"),offset:M().int().nonnegative(),length:M().int().positive().max(D.hydratedRangeBytes)}),de({mode:P("markdown-body-ref"),maxBytes:M().int().positive().max(D.hydratedFileBytes).optional()})]),jo={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"]},Lu=Object.keys(jo),Mu=["url","width","height"],sr=e=>Mu.includes(e),Zu=Lu.filter(e=>sr(e)===!1&&e!=="excerpt"),Fu=Zu.filter(e=>e!=="id"),Bu=e=>Zu.includes(e),$p=ce(Lu),fn=j(v().min(1)).min(1).max(D.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||$p.safeParse(e[0]).success===!1)&&t.addIssue({code:"custom",message:"Asset query field path is unsupported"})}),Fo=et().default(!0),Np=At("mode",[R({mode:P("all"),includeMetadata:Fo}),R({mode:P("base"),includeMetadata:Fo}),R({mode:P("fields"),includeMetadata:Fo,fields:j(fn).max(D.outputFieldCount).refine(e=>new Set(e.map(Au)).size===e.length,{error:"Selected output fields must be unique"})})]),Cp={mode:"fields",includeMetadata:!1,fields:Mu.map(e=>[e])},ju=["eq","ne","contains","startsWith","endsWith","gt","gte","lt","lte"],Gg=[...ju,"in","exists","isEmpty"],Tp=R({field:fn,operator:ce(ju),value:tt()}),zp=R({field:fn,operator:P("in"),value:j(tt()).max(D.resultCount)}),Pp=R({field:fn,operator:ce(["exists","isEmpty"]),value:et()}),Lp=At("operator",[Tp,zp,Pp]),Mp=Du(Lp,{maximumChildren:D.filterCount,maximumConditions:D.filterCount,maximumDepth:D.filterDepth,maximumConditionsMessage:"Asset query exceeds the filter limit",maximumDepthMessage:"Asset query exceeds the filter nesting limit"});var Zp=Mp,Uu=e=>{let t=new Set(["eq","ne","in","exists"]);return e.some(n=>n==="string"||n==="array")&&t.add("contains"),e.includes("string")&&(t.add("startsWith"),t.add("endsWith")),e.some(n=>n==="string"||n==="number")&&(t.add("gt"),t.add("gte"),t.add("lt"),t.add("lte")),e.some(n=>n==="string"||n==="array"||n==="object")&&t.add("isEmpty"),[...t]},Fp=R({field:fn,direction:ce(["asc","desc"])}),Bp=({output:e,content:t})=>e.includeMetadata||e.mode==="all"||e.mode==="fields"&&e.fields.length>0||t.mode!=="none",rt=R({where:Zp.default({all:[]}),sort:j(Fp).max(D.sortCount).default([]),limit:M().int().nonnegative().max(D.resultCount).default(D.defaultResultCount),offset:M().int().nonnegative().max(D.candidateDocuments).default(0),output:Np.default(Cp),content:Op.default({mode:"none"})}).refine(Bp,{error:"Select at least one asset query output"}),Vu=R({query:rt,indexRevision:v().min(1).max(255).optional()}),jp=de({_id:v().min(1),revision:v().min(1),contentRef:v().min(1),encoding:P("utf-8"),text:v(),range:de({offset:M().int().nonnegative(),length:M().int().nonnegative(),total:M().int().nonnegative()}).optional()}),Up=jp.omit({_id:!0,revision:!0,contentRef:!0}),Vp=zu.omit({_id:!0,_type:!0,contentRef:!0}).partial().extend({id:v().min(1),url:v().min(1).optional(),width:M().positive().optional(),height:M().positive().optional(),content:Up.optional()}).refine(e=>e.width===void 0==(e.height===void 0),{error:"Asset dimensions must include both width and height"}),Qp=R({format:P("webstudio-content-database"),version:P(1),revision:or,usedBytes:M().int().nonnegative(),maxBytes:M().int().positive(),unboundedBytes:M().int().nonnegative(),includedDocumentCount:M().int().nonnegative(),omittedDocumentCount:M().int().nonnegative(),omissionReason:ce(["size","unavailable"]).optional(),truncated:et()}),Tu=Qp.pick({usedBytes:!0,maxBytes:!0,unboundedBytes:!0,includedDocumentCount:!0,omittedDocumentCount:!0,omissionReason:!0,truncated:!0}),ir=R({items:j(Vp),totalCount:M().int().nonnegative(),hasMore:et()}),Jp=R({scope:P("query-preview"),query:Tu,database:Tu,artifacts:R({query:Cu,database:Cu}).optional(),unresolved:ir.optional()}),qg=R({data:ir,__diagnostics__:Jp}),Gp=ce(["INVALID_REQUEST","REQUEST_CANCELLED","UNAUTHORIZED","FORBIDDEN","STALE_INDEX","CONTENT_IDENTITY_REQUIRED","CONTENT_NOT_TEXT","CONTENT_DECODING_FAILED","CONTENT_LIMIT_EXCEEDED","INTERNAL_ERROR"]),qp=de({ok:P(!1),error:de({code:Gp,message:v().min(1),retryable:et(),details:ge(v(),tt()).optional()}),meta:de({queryHash:v().min(1).optional(),indexRevision:v().min(1).optional(),assetRevision:v().min(1).optional()}).optional()}),Qu=({code:e,message:t,retryable:n=!1,details:r})=>qp.parse({ok:!1,error:{code:e,message:t,retryable:n,details:r}});var Ju=function*(e){if(e.length>0&&!e.startsWith("/")||/~(?![01])/.test(e))throw Error("Invalid JSON Pointer");let t=1,n=0;for(;n<e.length;){let r=e.indexOf("/",t);n=r===-1?e.length:r;let o=e.slice(t,n);t=n+1,yield Wp(o)}};var Uo=(e,t)=>t+"/"+Kp(e),Kp=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),Wp=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~");var cr=async(e,t,n)=>{if(Number.isSafeInteger(t)===!1||t<=0)throw new Error("Concurrency must be a positive safe integer");let r=0,o=new Array(e.length),s=async()=>{for(;r<e.length;){let u=r;r+=1,o[u]=await n(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 Nt=e=>typeof e=="object"&&e!==null&&Array.isArray(e)===!1,Gu=e=>{if(Nt(e)===!1)return;let t=Object.keys(e);if(!(t.length!==1||t[0]!=="$ref"))return e.$ref};var ue=class extends Error{code;referenceId;constructor({code:t,message:n,referenceId:r,cause:o}){super(n,{cause:o}),this.name="JsonDocumentError",this.code=t,this.referenceId=r}},Yp=(e,t)=>{let n=Gu(e);if(n!==void 0){if(typeof n!="string")throw new ue({code:"INVALID_REFERENCE_MARKER",message:`JSON reference marker ${t} must contain a string $ref`,referenceId:t});return n}},Xp=e=>`#${e}`;var qu=async({source:e,maximumBytes:t=D.hydratedFileBytes})=>{let n;try{n=await pe(e,t)}catch(o){throw o instanceof te?new ue({code:"CONTENT_LIMIT_EXCEEDED",message:"JSON document exceeds the byte limit",cause:o}):o}let r;try{r=Ot(ae(n))}catch(o){throw new ue({code:"CONTENT_DECODING_FAILED",message:"JSON document is not valid UTF-8",cause:o})}try{return nt(JSON.parse(r))}catch(o){throw new ue({code:"INVALID_DOCUMENT",message:"JSON document is invalid",cause:o})}};var Hp=(e,t)=>{let n=e;for(let r of t){if(Array.isArray(n)){let o=Number(r);if(Number.isSafeInteger(o)===!1||o<0||String(o)!==r||o>=n.length)return;n=n[o];continue}if(Nt(n)&&Object.hasOwn(n,r)){n=n[r];continue}return}return n},Ku=({document:e,representation:t})=>{let n=nt(e);if(t.type==="document")return n;if(t.type!=="json")throw new ue({code:"UNSUPPORTED_REPRESENTATION",message:`JSON documents do not support ${t.type}`});let r=Hp(n,t.path);if(r===void 0)throw new ue({code:"JSON_PATH_NOT_FOUND",message:"JSON document path does not exist"});return r},em=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})},ar=({document:e,references:t,allowUnresolvedReferences:n=!1})=>{let r=nt(e),o=new Set,s=(c,a)=>{let u=Xp(a);if(Yp(c,u)!==void 0){if(t.has(u)===!1){if(n)return c;throw new ue({code:"REFERENCE_NOT_FOUND",message:`Resolved JSON reference ${u} is unavailable`,referenceId:u})}o.add(u);try{return nt(t.get(u))}catch(l){throw new ue({code:"INVALID_RESOLVED_VALUE",message:`Resolved JSON reference ${u} is not JSON-compatible`,referenceId:u,cause:l})}}if(Array.isArray(c))return c.map((l,f)=>s(l,Uo(String(f),a)));if(Nt(c)){let l={};for(let[f,p]of Object.entries(c))em(l,f,s(p,Uo(f,a)));return l}return c},i=s(r,"");for(let c of[...t.keys()].sort())if(o.has(c)===!1)throw new ue({code:"UNUSED_REFERENCE",message:`Resolved JSON reference ${c} has no marker`,referenceId:c});return i};var ur=Symbol.for("yaml.alias"),lr=Symbol.for("yaml.document"),be=Symbol.for("yaml.map"),Vo=Symbol.for("yaml.pair"),le=Symbol.for("yaml.scalar"),Qe=Symbol.for("yaml.seq"),ne=Symbol.for("yaml.node.type"),we=e=>!!e&&typeof e=="object"&&e[ne]===ur,Te=e=>!!e&&typeof e=="object"&&e[ne]===lr,_e=e=>!!e&&typeof e=="object"&&e[ne]===be,N=e=>!!e&&typeof e=="object"&&e[ne]===Vo,O=e=>!!e&&typeof e=="object"&&e[ne]===le,xe=e=>!!e&&typeof e=="object"&&e[ne]===Qe;function L(e){if(e&&typeof e=="object")switch(e[ne]){case be:case Qe:return!0}return!1}function T(e){if(e&&typeof e=="object")switch(e[ne]){case ur:case be:case le:case Qe:return!0}return!1}var fr=e=>(O(e)||L(e))&&!!e.anchor;var se=Symbol("break visit"),Wu=Symbol("skip children"),ze=Symbol("remove node");function Pe(e,t){let n=Yu(t);Te(e)?Ct(null,e.contents,n,Object.freeze([e]))===ze&&(e.contents=null):Ct(null,e,n,Object.freeze([]))}Pe.BREAK=se;Pe.SKIP=Wu;Pe.REMOVE=ze;function Ct(e,t,n,r){let o=Xu(e,t,n,r);if(T(o)||N(o))return Hu(e,r,o),Ct(e,o,n,r);if(typeof o!="symbol"){if(L(t)){r=Object.freeze(r.concat(t));for(let s=0;s<t.items.length;++s){let i=Ct(s,t.items[s],n,r);if(typeof i=="number")s=i-1;else{if(i===se)return se;i===ze&&(t.items.splice(s,1),s-=1)}}}else if(N(t)){r=Object.freeze(r.concat(t));let s=Ct("key",t.key,n,r);if(s===se)return se;s===ze&&(t.key=null);let i=Ct("value",t.value,n,r);if(i===se)return se;i===ze&&(t.value=null)}}return o}async function dr(e,t){let n=Yu(t);Te(e)?await Tt(null,e.contents,n,Object.freeze([e]))===ze&&(e.contents=null):await Tt(null,e,n,Object.freeze([]))}dr.BREAK=se;dr.SKIP=Wu;dr.REMOVE=ze;async function Tt(e,t,n,r){let o=await Xu(e,t,n,r);if(T(o)||N(o))return Hu(e,r,o),Tt(e,o,n,r);if(typeof o!="symbol"){if(L(t)){r=Object.freeze(r.concat(t));for(let s=0;s<t.items.length;++s){let i=await Tt(s,t.items[s],n,r);if(typeof i=="number")s=i-1;else{if(i===se)return se;i===ze&&(t.items.splice(s,1),s-=1)}}}else if(N(t)){r=Object.freeze(r.concat(t));let s=await Tt("key",t.key,n,r);if(s===se)return se;s===ze&&(t.key=null);let i=await Tt("value",t.value,n,r);if(i===se)return se;i===ze&&(t.value=null)}}return o}function Yu(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Xu(e,t,n,r){if(typeof n=="function")return n(e,t,r);if(_e(t))return n.Map?.(e,t,r);if(xe(t))return n.Seq?.(e,t,r);if(N(t))return n.Pair?.(e,t,r);if(O(t))return n.Scalar?.(e,t,r);if(we(t))return n.Alias?.(e,t,r)}function Hu(e,t,n){let r=t[t.length-1];if(L(r))r.items[e]=n;else if(N(r))e==="key"?r.key=n:r.value=n;else if(Te(r))r.contents=n;else{let o=we(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${o} parent`)}}var tm={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},nm=e=>e.replace(/[!,[\]{}]/g,t=>tm[t]),Le=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,n){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let r=t.trim().split(/[ \t]+/),o=r.shift();switch(o){case"%TAG":{if(r.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[s,i]=r;return this.tags[s]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[s]=r;if(s==="1.1"||s==="1.2")return this.yaml.version=s,!0;{let i=/^\d+\.\d+$/.test(s);return n(6,`Unsupported YAML version ${s}`,i),!1}}default:return n(0,`Unknown directive ${o}`,!0),!1}}tagName(t,n){if(t==="!")return"!";if(t[0]!=="!")return n(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let i=t.slice(2,-1);return i==="!"||i==="!!"?(n(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&n("Verbatim tags must end with a >"),i)}let[,r,o]=t.match(/^(.*!)([^!]*)$/s);o||n(`The ${t} tag has no suffix`);let s=this.tags[r];if(s)try{return s+decodeURIComponent(o)}catch(i){return n(String(i)),null}return r==="!"?t:(n(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[n,r]of Object.entries(this.tags))if(t.startsWith(r))return n+nm(t.substring(r.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),o;if(t&&r.length>0&&T(t.contents)){let s={};Pe(t.contents,(i,c)=>{T(c)&&c.tag&&(s[c.tag]=!0)}),o=Object.keys(s)}else o=[];for(let[s,i]of r)s==="!!"&&i==="tag:yaml.org,2002:"||(!t||o.some(c=>c.startsWith(i)))&&n.push(`%TAG ${s} ${i}`);return n.join(`+`)}};Le.defaultYaml={explicit:!1,version:"1.2"};Le.defaultTags={"!!":"tag:yaml.org,2002:"};function pr(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(n)}return!0}function Qo(e){let t=new Set;return Pe(e,{Value(n,r){r.anchor&&t.add(r.anchor)}}),t}function Jo(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function el(e,t){let n=[],r=new Map,o=null;return{onAnchor:s=>{n.push(s),o??(o=Qo(e));let i=Jo(t,o);return o.add(i),i},setAnchors:()=>{for(let s of n){let i=r.get(s);if(typeof i=="object"&&i.anchor&&(O(i.node)||L(i.node)))i.node.anchor=i.anchor;else{let c=new Error("Failed to resolve repeated object (this should not happen)");throw c.source=s,c}}},sourceObjects:r}}function ot(e,t,n,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let o=0,s=r.length;o<s;++o){let i=r[o],c=ot(e,r,String(o),i);c===void 0?delete r[o]:c!==i&&(r[o]=c)}else if(r instanceof Map)for(let o of Array.from(r.keys())){let s=r.get(o),i=ot(e,r,o,s);i===void 0?r.delete(o):i!==s&&r.set(o,i)}else if(r instanceof Set)for(let o of Array.from(r)){let s=ot(e,r,o,o);s===void 0?r.delete(o):s!==o&&(r.delete(o),r.add(s))}else for(let[o,s]of Object.entries(r)){let i=ot(e,r,o,s);i===void 0?delete r[o]:i!==s&&(r[o]=i)}return e.call(t,n,r)}function K(e,t,n){if(Array.isArray(e))return e.map((r,o)=>K(r,String(o),n));if(e&&typeof e.toJSON=="function"){if(!n||!fr(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=s=>{r.res=s,delete n.onCreate};let o=e.toJSON(t,n);return n.onCreate&&n.onCreate(o),o}return typeof e=="bigint"&&!n?.keep?Number(e):e}var st=class{constructor(t){Object.defineProperty(this,ne,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:n,maxAliasCount:r,onAnchor:o,reviver:s}={}){if(!Te(t))throw new TypeError("A document argument is required");let i={anchors:new Map,doc:t,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},c=K(this,"",i);if(typeof o=="function")for(let{count:a,res:u}of i.anchors.values())o(u,a);return typeof s=="function"?ot(s,{"":c},"",c):c}};var Je=class extends st{constructor(t){super(ur),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,n){if(n?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],Pe(t,{Node:(s,i)=>{(we(i)||fr(i))&&r.push(i)}}),n&&(n.aliasResolveCache=r));let o;for(let s of r){if(s===this)break;s.anchor===this.source&&(o=s)}return o}toJSON(t,n){if(!n)return{source:this.source};let{anchors:r,doc:o,maxAliasCount:s}=n,i=this.resolve(o,n);if(!i){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(a)}let c=r.get(i);if(c||(K(i,null,n),c=r.get(i)),c?.res===void 0){let a="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(a)}if(s>=0&&(c.count+=1,c.aliasCount===0&&(c.aliasCount=mr(o,i,r)),c.count*c.aliasCount>s)){let a="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(a)}return c.res}toString(t,n,r){let o=`*${this.source}`;if(t){if(pr(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(s)}if(t.implicitKey)return`${o} `}return o}};function mr(e,t,n){if(we(t)){let r=t.resolve(e),o=n&&r&&n.get(r);return o?o.count*o.aliasCount:0}else if(L(t)){let r=0;for(let o of t.items){let s=mr(e,o,n);s>r&&(r=s)}return r}else if(N(t)){let r=mr(e,t.key,n),o=mr(e,t.value,n);return Math.max(r,o)}return 1}var hr=e=>!e||typeof e!="function"&&typeof e!="object",A=class extends st{constructor(t){super(le),this.value=t}toJSON(t,n){return n?.keep?this.value:K(this.value,t,n)}toString(){return String(this.value)}};A.BLOCK_FOLDED="BLOCK_FOLDED";A.BLOCK_LITERAL="BLOCK_LITERAL";A.PLAIN="PLAIN";A.QUOTE_DOUBLE="QUOTE_DOUBLE";A.QUOTE_SINGLE="QUOTE_SINGLE";var rm="tag:yaml.org,2002:";function om(e,t,n){if(t){let r=n.filter(s=>s.tag===t),o=r.find(s=>!s.format)??r[0];if(!o)throw new Error(`Tag ${t} not found`);return o}return n.find(r=>r.identify?.(e)&&!r.format)}function Ge(e,t,n){if(Te(e)&&(e=e.contents),T(e))return e;if(N(e)){let l=n.schema[be].createNode?.(n.schema,null,n);return l.items.push(e),l}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:o,onTagObj:s,schema:i,sourceObjects:c}=n,a;if(r&&e&&typeof e=="object"){if(a=c.get(e),a)return a.anchor??(a.anchor=o(e)),new Je(a.anchor);a={anchor:null,node:null},c.set(e,a)}t?.startsWith("!!")&&(t=rm+t.slice(2));let u=om(e,t,i.tags);if(!u){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let l=new A(e);return a&&(a.node=l),l}u=e instanceof Map?i[be]:Symbol.iterator in Object(e)?i[Qe]:i[be]}s&&(s(u),delete n.onTagObj);let d=u?.createNode?u.createNode(n.schema,e,n):typeof u?.nodeClass?.from=="function"?u.nodeClass.from(n.schema,e,n):new A(e);return t?d.tag=t:u.default||(d.tag=u.tag),a&&(a.node=d),d}function dn(e,t,n){let r=n;for(let o=t.length-1;o>=0;--o){let s=t[o];if(typeof s=="number"&&Number.isInteger(s)&&s>=0){let i=[];i[s]=r,r=i}else r=new Map([[s,r]])}return Ge(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var Pt=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,zt=class extends st{constructor(t,n){super(t),Object.defineProperty(this,"schema",{value:n,configurable:!0,enumerable:!1,writable:!0})}clone(t){let n=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(n.schema=t),n.items=n.items.map(r=>T(r)||N(r)?r.clone(t):r),this.range&&(n.range=this.range.slice()),n}addIn(t,n){if(Pt(t))this.add(n);else{let[r,...o]=t,s=this.get(r,!0);if(L(s))s.addIn(o,n);else if(s===void 0&&this.schema)this.set(r,dn(this.schema,o,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${o}`)}}deleteIn(t){let[n,...r]=t;if(r.length===0)return this.delete(n);let o=this.get(n,!0);if(L(o))return o.deleteIn(r);throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}getIn(t,n){let[r,...o]=t,s=this.get(r,!0);return o.length===0?!n&&O(s)?s.value:s:L(s)?s.getIn(o,n):void 0}hasAllNullValues(t){return this.items.every(n=>{if(!N(n))return!1;let r=n.value;return r==null||t&&O(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(t){let[n,...r]=t;if(r.length===0)return this.has(n);let o=this.get(n,!0);return L(o)?o.hasIn(r):!1}setIn(t,n){let[r,...o]=t;if(o.length===0)this.set(r,n);else{let s=this.get(r,!0);if(L(s))s.setIn(o,n);else if(s===void 0&&this.schema)this.set(r,dn(this.schema,o,n));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${o}`)}}};var tl=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function me(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Me=(e,t,n)=>e.endsWith(``)?me(n,t):n.includes(``)?`-`+me(n,t):(e.endsWith(" ")?"":" ")+n;var Vo="flow",hr="block",dn="quoted";function pn(e,t,n="flow",{indentAtStart:r,lineWidth:o=80,minContentWidth:s=20,onFold:i,onOverflow:c}={}){if(!o||o<0)return e;o<s&&(s=0);let a=Math.max(1+s,1+o-t.length);if(e.length<=a)return e;let u=[],d={},l=o-t.length;typeof r=="number"&&(r>o-Math.max(2,s)?u.push(0):l=o-r);let f,p,y=!1,m=-1,h=-1,b=-1;n===hr&&(m=Xu(e,m,t.length),m!==-1&&(l=m+a));for(let x;x=e[m+=1];){if(n===dn&&x==="\\"){switch(h=m,e[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}b=m}if(x===`-`)n===hr&&(m=Xu(e,m,t.length)),l=m+t.length+a,f=void 0;else{if(x===" "&&p&&p!==" "&&p!==`+`+me(n,t):(e.endsWith(" ")?"":" ")+n;var Go="flow",yr="block",pn="quoted";function mn(e,t,n="flow",{indentAtStart:r,lineWidth:o=80,minContentWidth:s=20,onFold:i,onOverflow:c}={}){if(!o||o<0)return e;o<s&&(s=0);let a=Math.max(1+s,1+o-t.length);if(e.length<=a)return e;let u=[],d={},l=o-t.length;typeof r=="number"&&(r>o-Math.max(2,s)?u.push(0):l=o-r);let f,p,y=!1,m=-1,h=-1,b=-1;n===yr&&(m=nl(e,m,t.length),m!==-1&&(l=m+a));for(let x;x=e[m+=1];){if(n===pn&&x==="\\"){switch(h=m,e[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}b=m}if(x===`+`)n===yr&&(m=nl(e,m,t.length)),l=m+t.length+a,f=void 0;else{if(x===" "&&p&&p!==" "&&p!==``&&p!==" "){let w=e[m+1];w&&w!==" "&&w!==`-`&&w!==" "&&(f=m)}if(m>=l)if(f)u.push(f),l=f+a,f=void 0;else if(n===dn){for(;p===" "||p===" ";)p=x,x=e[m+=1],y=!0;let w=m>b+1?m-2:h-1;if(d[w])return e;u.push(w),d[w]=!0,l=w+a,f=void 0}else y=!0}p=x}if(y&&c&&c(),u.length===0)return e;i&&i();let _=e.slice(0,u[0]);for(let x=0;x<u.length;++x){let w=u[x],S=u[x+1]||e.length;w===0?_=`-${t}${e.slice(0,S)}`:(n===dn&&d[w]&&(_+=`${e[w]}\\`),_+=`-${t}${e.slice(w+1,S)}`)}return _}function Xu(e,t,n){let r=t,o=t+1,s=e[o];for(;s===" "||s===" ";)if(t<o+n)s=e[++t];else{do s=e[++t];while(s&&s!==`-`);r=t,o=t+1,s=e[o]}return r}var gr=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),br=e=>/^(%|---|\.\.\.)/m.test(e);function nm(e,t,n){if(!t||t<0)return!1;let r=t-n,o=e.length;if(o<=r)return!1;for(let s=0,i=0;s<o;++s)if(e[s]===`-`){if(s-i>r)return!0;if(i=s+1,o-i<=r)return!1}return!0}function mn(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,o=t.options.doubleQuotedMinMultiLineLength,s=t.indent||(br(e)?" ":""),i="",c=0;for(let a=0,u=n[a];u;u=n[++a])if(u===" "&&n[a+1]==="\\"&&n[a+2]==="n"&&(i+=n.slice(c,a)+"\\ ",a+=1,c=a,u="\\"),u==="\\")switch(n[a+1]){case"u":{i+=n.slice(c,a);let d=n.substr(a+2,4);switch(d){case"0000":i+="\\0";break;case"0007":i+="\\a";break;case"000b":i+="\\v";break;case"001b":i+="\\e";break;case"0085":i+="\\N";break;case"00a0":i+="\\_";break;case"2028":i+="\\L";break;case"2029":i+="\\P";break;default:d.substr(0,2)==="00"?i+="\\x"+d.substr(2):i+=n.substr(a,6)}a+=5,c=a+1}break;case"n":if(r||n[a+2]==='"'||n.length<o)a+=1;else{for(i+=n.slice(c,a)+`+`&&w!==" "&&(f=m)}if(m>=l)if(f)u.push(f),l=f+a,f=void 0;else if(n===pn){for(;p===" "||p===" ";)p=x,x=e[m+=1],y=!0;let w=m>b+1?m-2:h-1;if(d[w])return e;u.push(w),d[w]=!0,l=w+a,f=void 0}else y=!0}p=x}if(y&&c&&c(),u.length===0)return e;i&&i();let _=e.slice(0,u[0]);for(let x=0;x<u.length;++x){let w=u[x],S=u[x+1]||e.length;w===0?_=`+${t}${e.slice(0,S)}`:(n===pn&&d[w]&&(_+=`${e[w]}\\`),_+=`+${t}${e.slice(w+1,S)}`)}return _}function nl(e,t,n){let r=t,o=t+1,s=e[o];for(;s===" "||s===" ";)if(t<o+n)s=e[++t];else{do s=e[++t];while(s&&s!==`+`);r=t,o=t+1,s=e[o]}return r}var br=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),wr=e=>/^(%|---|\.\.\.)/m.test(e);function sm(e,t,n){if(!t||t<0)return!1;let r=t-n,o=e.length;if(o<=r)return!1;for(let s=0,i=0;s<o;++s)if(e[s]===`+`){if(s-i>r)return!0;if(i=s+1,o-i<=r)return!1}return!0}function hn(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,o=t.options.doubleQuotedMinMultiLineLength,s=t.indent||(wr(e)?" ":""),i="",c=0;for(let a=0,u=n[a];u;u=n[++a])if(u===" "&&n[a+1]==="\\"&&n[a+2]==="n"&&(i+=n.slice(c,a)+"\\ ",a+=1,c=a,u="\\"),u==="\\")switch(n[a+1]){case"u":{i+=n.slice(c,a);let d=n.substr(a+2,4);switch(d){case"0000":i+="\\0";break;case"0007":i+="\\a";break;case"000b":i+="\\v";break;case"001b":i+="\\e";break;case"0085":i+="\\N";break;case"00a0":i+="\\_";break;case"2028":i+="\\L";break;case"2029":i+="\\P";break;default:d.substr(0,2)==="00"?i+="\\x"+d.substr(2):i+=n.substr(a,6)}a+=5,c=a+1}break;case"n":if(r||n[a+2]==='"'||n.length<o)a+=1;else{for(i+=n.slice(c,a)+``;n[a+2]==="\\"&&n[a+3]==="n"&&n[a+4]!=='"';)i+=`-`,a+=2;i+=s,n[a+2]===" "&&(i+="\\"),a+=1,c=a+1}break;default:a+=1}return i=c?i+n.slice(c):n,r?i:pn(i,s,dn,gr(t,!1))}function Go(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`-`)||/[ \t]\n|\n[ \t]/.test(e))return mn(e,t);let n=t.indent||(br(e)?" ":""),r="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&-${n}`)+"'";return t.implicitKey?r:pn(r,n,Vo,gr(t,!1))}function Lt(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=mn;else{let o=e.includes('"'),s=e.includes("'");o&&!s?r=Go:s&&!o?r=mn:r=n?Go:mn}return r(e,t)}var qo;try{qo=new RegExp(`(^|(?<!+`,a+=2;i+=s,n[a+2]===" "&&(i+="\\"),a+=1,c=a+1}break;default:a+=1}return i=c?i+n.slice(c):n,r?i:mn(i,s,pn,br(t,!1))}function qo(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`+`)||/[ \t]\n|\n[ \t]/.test(e))return hn(e,t);let n=t.indent||(wr(e)?" ":""),r="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&+${n}`)+"'";return t.implicitKey?r:mn(r,n,Go,br(t,!1))}function Lt(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=hn;else{let o=e.includes('"'),s=e.includes("'");o&&!s?r=qo:s&&!o?r=hn:r=n?qo:hn}return r(e,t)}var Ko;try{Ko=new RegExp(`(^|(?<!))+(?!-|$)`,"g")}catch{qo=/\n+(?!\n|$)/g}function yr({comment:e,type:t,value:n},r,o,s){let{blockQuote:i,commentString:c,lineWidth:a}=r.options;if(!i||/\n[\t ]+$/.test(n))return Lt(n,r);let u=r.indent||(r.forceBlockIndent||br(n)?" ":""),d=i==="literal"?!0:i==="folded"||t===A.BLOCK_FOLDED?!1:t===A.BLOCK_LITERAL?!0:!nm(n,a,u.length);if(!n)return d?`|+|$)`,"g")}catch{Ko=/\n+(?!\n|$)/g}function gr({comment:e,type:t,value:n},r,o,s){let{blockQuote:i,commentString:c,lineWidth:a}=r.options;if(!i||/\n[\t ]+$/.test(n))return Lt(n,r);let u=r.indent||(r.forceBlockIndent||wr(n)?" ":""),d=i==="literal"?!0:i==="folded"||t===A.BLOCK_FOLDED?!1:t===A.BLOCK_LITERAL?!0:!sm(n,a,u.length);if(!n)return d?`|`:`>`;let l,f;for(f=n.length;f>0;--f){let S=n[f-1];if(S!==``&&S!==" "&&S!==" ")break}let p=n.substring(f),y=p.indexOf(``);y===-1?l="-":n===p||y!==p.length-1?(l="+",s&&s()):l="",p&&(n=n.slice(0,-p.length),p[p.length-1]===`-`&&(p=p.slice(0,-1)),p=p.replace(qo,`$&${u}`));let m=!1,h,b=-1;for(h=0;h<n.length;++h){let S=n[h];if(S===" ")m=!0;else if(S===`+`&&(p=p.slice(0,-1)),p=p.replace(Ko,`$&${u}`));let m=!1,h,b=-1;for(h=0;h<n.length;++h){let S=n[h];if(S===" ")m=!0;else if(S===``)b=h;else break}let _=n.substring(0,b<h?b+1:h);_&&(n=n.substring(_.length),_=_.replace(/\n+/g,`$&${u}`));let w=(m?u?"2":"1":"")+l;if(e&&(w+=" "+c(e.replace(/ ?[\r\n]+/g," ")),o&&o()),!d){let S=n.replace(/\n+/g,`-$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${u}`),v=!1,$=gr(r,!0);i!=="folded"&&t!==A.BLOCK_FOLDED&&($.onOverflow=()=>{v=!0});let E=pn(`${_}${S}${p}`,u,hr,$);if(!v)return`>${w}+$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${u}`),k=!1,$=br(r,!0);i!=="folded"&&t!==A.BLOCK_FOLDED&&($.onOverflow=()=>{k=!0});let E=mn(`${_}${S}${p}`,u,yr,$);if(!k)return`>${w}${u}${E}`}return n=n.replace(/\n+/g,`$&${u}`),`|${w}-${u}${_}${n}${p}`}function rm(e,t,n,r){let{type:o,value:s}=e,{actualString:i,implicitKey:c,indent:a,indentStep:u,inFlow:d}=t;if(c&&s.includes(`+${u}${_}${n}${p}`}function im(e,t,n,r){let{type:o,value:s}=e,{actualString:i,implicitKey:c,indent:a,indentStep:u,inFlow:d}=t;if(c&&s.includes(``)||d&&/[[\]{},]/.test(s))return Lt(s,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(s))return c||d||!s.includes(`-`)?Lt(s,t):yr(e,t,n,r);if(!c&&!d&&o!==A.PLAIN&&s.includes(`-`))return yr(e,t,n,r);if(br(s)){if(a==="")return t.forceBlockIndent=!0,yr(e,t,n,r);if(c&&a===u)return Lt(s,t)}let l=s.replace(/\n+/g,`$&-${a}`);if(i){let f=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(l),{compat:p,tags:y}=t.doc.schema;if(y.some(f)||p?.some(f))return Lt(s,t)}return c?l:pn(l,a,Vo,gr(t,!1))}function ht(e,t,n,r){let{implicitKey:o,inFlow:s}=t,i=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:c}=e;c!==A.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value)&&(c=A.QUOTE_DOUBLE);let a=d=>{switch(d){case A.BLOCK_FOLDED:case A.BLOCK_LITERAL:return o||s?Lt(i.value,t):yr(i,t,n,r);case A.QUOTE_DOUBLE:return mn(i.value,t);case A.QUOTE_SINGLE:return Go(i.value,t);case A.PLAIN:return rm(i,t,n,r);default:return null}},u=a(c);if(u===null){let{defaultKeyType:d,defaultStringType:l}=t.options,f=o&&d||l;if(u=a(f),u===null)throw new Error(`Unsupported default string type ${f}`)}return u}function wr(e,t){let n=Object.assign({blockQuote:!0,commentString:Yu,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:r,options:n}}function om(e,t){if(t.tag){let o=e.filter(s=>s.tag===t.tag);if(o.length>0)return o.find(s=>s.format===t.format)??o[0]}let n,r;if(R(t)){r=t.value;let o=e.filter(s=>s.identify?.(r));if(o.length>1){let s=o.filter(i=>i.test);s.length>0&&(o=s)}n=o.find(s=>s.format===t.format)??o.find(s=>!s.format)}else r=t,n=e.find(o=>o.nodeClass&&r instanceof o.nodeClass);if(!n){let o=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${o} value`)}return n}function sm(e,t,{anchors:n,doc:r}){if(!r.directives)return"";let o=[],s=(R(e)||L(e))&&e.anchor;s&&dr(s)&&(n.add(s),o.push(`&${s}`));let i=e.tag??(t.default?null:t.tag);return i&&o.push(r.directives.tagString(i)),o.join(" ")}function Ve(e,t,n,r){if(N(e))return e.toString(t,n,r);if(be(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let o,s=T(e)?e:t.doc.createNode(e,{onTagObj:a=>o=a});o??(o=om(t.doc.schema.tags,s));let i=sm(s,o,t);i.length>0&&(t.indentAtStart=(t.indentAtStart??0)+i.length+1);let c=typeof o.stringify=="function"?o.stringify(s,t,n,r):R(s)?ht(s,t,n,r):s.toString(t,n,r);return i?R(s)||c[0]==="{"||c[0]==="["?`${i} ${c}`:`${i}-${t.indent}${c}`:c}function Hu({key:e,value:t},n,r,o){let{allNullValues:s,doc:i,indent:c,indentStep:a,options:{commentString:u,indentSeq:d,simpleKeys:l}}=n,f=T(e)&&e.comment||null;if(l){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(L(e)||!T(e)&&typeof e=="object"){let $="With simple keys, collection cannot be used as a key value";throw new Error($)}}let p=!l&&(!e||f&&t==null&&!n.inFlow||L(e)||(R(e)?e.type===A.BLOCK_FOLDED||e.type===A.BLOCK_LITERAL:typeof e=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(l||!s),indent:c+a});let y=!1,m=!1,h=Ve(e,n,()=>y=!0,()=>m=!0);if(!p&&!n.inFlow&&h.length>1024){if(l)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(n.inFlow){if(s||t==null)return y&&r&&r(),h===""?"?":p?`? ${h}`:h}else if(s&&!l||t==null&&p)return h=`? ${h}`,f&&!y?h+=Le(h,n.indent,u(f)):m&&o&&o(),h;y&&(f=null),p?(f&&(h+=Le(h,n.indent,u(f))),h=`? ${h}-${c}:`):(h=`${h}:`,f&&(h+=Le(h,n.indent,u(f))));let b,_,x;T(t)?(b=!!t.spaceBefore,_=t.commentBefore,x=t.comment):(b=!1,_=null,x=null,t&&typeof t=="object"&&(t=i.createNode(t))),n.implicitKey=!1,!p&&!f&&R(t)&&(n.indentAtStart=h.length+1),m=!1,!d&&a.length>=2&&!n.inFlow&&!p&&_e(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let w=!1,S=Ve(t,n,()=>w=!0,()=>m=!0),v=" ";if(f||b||_){if(v=b?`-`:"",_){let $=u(_);v+=`-${me($,n.indent)}`}S===""&&!n.inFlow?v===`-`&&x&&(v=`+`)?Lt(s,t):gr(e,t,n,r);if(!c&&!d&&o!==A.PLAIN&&s.includes(`+`))return gr(e,t,n,r);if(wr(s)){if(a==="")return t.forceBlockIndent=!0,gr(e,t,n,r);if(c&&a===u)return Lt(s,t)}let l=s.replace(/\n+/g,`$&+${a}`);if(i){let f=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(l),{compat:p,tags:y}=t.doc.schema;if(y.some(f)||p?.some(f))return Lt(s,t)}return c?l:mn(l,a,Go,br(t,!1))}function ht(e,t,n,r){let{implicitKey:o,inFlow:s}=t,i=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:c}=e;c!==A.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value)&&(c=A.QUOTE_DOUBLE);let a=d=>{switch(d){case A.BLOCK_FOLDED:case A.BLOCK_LITERAL:return o||s?Lt(i.value,t):gr(i,t,n,r);case A.QUOTE_DOUBLE:return hn(i.value,t);case A.QUOTE_SINGLE:return qo(i.value,t);case A.PLAIN:return im(i,t,n,r);default:return null}},u=a(c);if(u===null){let{defaultKeyType:d,defaultStringType:l}=t.options,f=o&&d||l;if(u=a(f),u===null)throw new Error(`Unsupported default string type ${f}`)}return u}function _r(e,t){let n=Object.assign({blockQuote:!0,commentString:tl,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:r,options:n}}function cm(e,t){if(t.tag){let o=e.filter(s=>s.tag===t.tag);if(o.length>0)return o.find(s=>s.format===t.format)??o[0]}let n,r;if(O(t)){r=t.value;let o=e.filter(s=>s.identify?.(r));if(o.length>1){let s=o.filter(i=>i.test);s.length>0&&(o=s)}n=o.find(s=>s.format===t.format)??o.find(s=>!s.format)}else r=t,n=e.find(o=>o.nodeClass&&r instanceof o.nodeClass);if(!n){let o=r?.constructor?.name??(r===null?"null":typeof r);throw new Error(`Tag not resolved for ${o} value`)}return n}function am(e,t,{anchors:n,doc:r}){if(!r.directives)return"";let o=[],s=(O(e)||L(e))&&e.anchor;s&&pr(s)&&(n.add(s),o.push(`&${s}`));let i=e.tag??(t.default?null:t.tag);return i&&o.push(r.directives.tagString(i)),o.join(" ")}function qe(e,t,n,r){if(N(e))return e.toString(t,n,r);if(we(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let o,s=T(e)?e:t.doc.createNode(e,{onTagObj:a=>o=a});o??(o=cm(t.doc.schema.tags,s));let i=am(s,o,t);i.length>0&&(t.indentAtStart=(t.indentAtStart??0)+i.length+1);let c=typeof o.stringify=="function"?o.stringify(s,t,n,r):O(s)?ht(s,t,n,r):s.toString(t,n,r);return i?O(s)||c[0]==="{"||c[0]==="["?`${i} ${c}`:`${i}+${t.indent}${c}`:c}function rl({key:e,value:t},n,r,o){let{allNullValues:s,doc:i,indent:c,indentStep:a,options:{commentString:u,indentSeq:d,simpleKeys:l}}=n,f=T(e)&&e.comment||null;if(l){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(L(e)||!T(e)&&typeof e=="object"){let $="With simple keys, collection cannot be used as a key value";throw new Error($)}}let p=!l&&(!e||f&&t==null&&!n.inFlow||L(e)||(O(e)?e.type===A.BLOCK_FOLDED||e.type===A.BLOCK_LITERAL:typeof e=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(l||!s),indent:c+a});let y=!1,m=!1,h=qe(e,n,()=>y=!0,()=>m=!0);if(!p&&!n.inFlow&&h.length>1024){if(l)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(n.inFlow){if(s||t==null)return y&&r&&r(),h===""?"?":p?`? ${h}`:h}else if(s&&!l||t==null&&p)return h=`? ${h}`,f&&!y?h+=Me(h,n.indent,u(f)):m&&o&&o(),h;y&&(f=null),p?(f&&(h+=Me(h,n.indent,u(f))),h=`? ${h}+${c}:`):(h=`${h}:`,f&&(h+=Me(h,n.indent,u(f))));let b,_,x;T(t)?(b=!!t.spaceBefore,_=t.commentBefore,x=t.comment):(b=!1,_=null,x=null,t&&typeof t=="object"&&(t=i.createNode(t))),n.implicitKey=!1,!p&&!f&&O(t)&&(n.indentAtStart=h.length+1),m=!1,!d&&a.length>=2&&!n.inFlow&&!p&&xe(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let w=!1,S=qe(t,n,()=>w=!0,()=>m=!0),k=" ";if(f||b||_){if(k=b?`+`:"",_){let $=u(_);k+=`+${me($,n.indent)}`}S===""&&!n.inFlow?k===`+`&&x&&(k=`-`):v+=`+`):k+=`${n.indent}`}else if(!p&&L(t)){let $=S[0],E=S.indexOf(`-`),G=E!==-1,Ke=n.inFlow??t.flow??t.items.length===0;if(G||!Ke){let wt=!1;if(G&&($==="&"||$==="!")){let q=S.indexOf(" ");$==="&"&&q!==-1&&q<E&&S[q+1]==="!"&&(q=S.indexOf(" ",q+1)),(q===-1||E<q)&&(wt=!0)}wt||(v=`+`),U=E!==-1,Ie=n.inFlow??t.flow??t.items.length===0;if(U||!Ie){let wt=!1;if(U&&($==="&"||$==="!")){let q=S.indexOf(" ");$==="&"&&q!==-1&&q<E&&S[q+1]==="!"&&(q=S.indexOf(" ",q+1)),(q===-1||E<q)&&(wt=!0)}wt||(k=`${n.indent}`)}}else(S===""||S[0]===`-`)&&(v="");return h+=v+S,n.inFlow?w&&r&&r():x&&!w?h+=Le(h,n.indent,u(x)):m&&o&&o(),h}function Ko(e,t){(e==="debug"||e==="warn")&&console.warn(t)}var _r="<<",xe={identify:e=>e===_r||typeof e=="symbol"&&e.description===_r,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new A(Symbol(_r)),{addToJSMap:Yo}),stringify:()=>_r},el=(e,t)=>(xe.identify(t)||R(t)&&(!t.type||t.type===A.PLAIN)&&xe.identify(t.value))&&e?.doc.schema.tags.some(n=>n.tag===xe.tag&&n.default);function Yo(e,t,n){let r=tl(e,n);if(_e(r))for(let o of r.items)Wo(e,t,o);else if(Array.isArray(r))for(let o of r)Wo(e,t,o);else Wo(e,t,r)}function Wo(e,t,n){let r=tl(e,n);if(!we(r))throw new Error("Merge sources must be maps or map aliases");let o=r.toJSON(null,e,Map);for(let[s,i]of o)t instanceof Map?t.has(s)||t.set(s,i):t instanceof Set?t.add(s):Object.prototype.hasOwnProperty.call(t,s)||Object.defineProperty(t,s,{value:i,writable:!0,enumerable:!0,configurable:!0});return t}function tl(e,t){return e&&be(t)?t.resolve(e.doc,e):t}function xr(e,t,{key:n,value:r}){if(T(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(el(e,n))Yo(e,t,r);else{let o=K(n,"",e);if(t instanceof Map)t.set(o,K(r,o,e));else if(t instanceof Set)t.add(o);else{let s=im(n,o,e),i=K(r,s,e);s in t?Object.defineProperty(t,s,{value:i,writable:!0,enumerable:!0,configurable:!0}):t[s]=i}}return t}function im(e,t,n){if(t===null)return"";if(typeof t!="object")return String(t);if(T(e)&&n?.doc){let r=wr(n.doc,{});r.anchors=new Set;for(let s of n.anchors.keys())r.anchors.add(s.anchor);r.inFlow=!0,r.inStringifyKey=!0;let o=e.toString(r);if(!n.mapKeyWarned){let s=JSON.stringify(o);s.length>40&&(s=s.substring(0,36)+'..."'),Ko(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${s}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return o}return JSON.stringify(t)}function Mt(e,t,n){let r=Je(e,void 0,n),o=Je(t,void 0,n);return new J(r,o)}var J=class e{constructor(t,n=null){Object.defineProperty(this,ne,{value:Uo}),this.key=t,this.value=n}clone(t){let{key:n,value:r}=this;return T(n)&&(n=n.clone(t)),T(r)&&(r=r.clone(t)),new e(n,r)}toJSON(t,n){let r=n?.mapAsMap?new Map:{};return xr(n,r,this)}toString(t,n,r){return t?.doc?Hu(this,t,n,r):JSON.stringify(this)}};function Sr(e,t,n){return(t.inFlow??e.flow?am:cm)(e,t,n)}function cm({comment:e,items:t},n,{blockItemPrefix:r,flowChars:o,itemIndent:s,onChompKeep:i,onComment:c}){let{indent:a,options:{commentString:u}}=n,d=Object.assign({},n,{indent:s,type:null}),l=!1,f=[];for(let y=0;y<t.length;++y){let m=t[y],h=null;if(T(m))!l&&m.spaceBefore&&f.push(""),Er(n,f,m.commentBefore,l),m.comment&&(h=m.comment);else if(N(m)){let _=T(m.key)?m.key:null;_&&(!l&&_.spaceBefore&&f.push(""),Er(n,f,_.commentBefore,l))}l=!1;let b=Ve(m,d,()=>h=null,()=>l=!0);h&&(b+=Le(b,s,u(h))),l&&h&&(l=!1),f.push(r+b)}let p;if(f.length===0)p=o.start+o.end;else{p=f[0];for(let y=1;y<f.length;++y){let m=f[y];p+=m?`+`)&&(k="");return h+=k+S,n.inFlow?w&&r&&r():x&&!w?h+=Me(h,n.indent,u(x)):m&&o&&o(),h}function Wo(e,t){(e==="debug"||e==="warn")&&console.warn(t)}var xr="<<",Ee={identify:e=>e===xr||typeof e=="symbol"&&e.description===xr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new A(Symbol(xr)),{addToJSMap:Xo}),stringify:()=>xr},ol=(e,t)=>(Ee.identify(t)||O(t)&&(!t.type||t.type===A.PLAIN)&&Ee.identify(t.value))&&e?.doc.schema.tags.some(n=>n.tag===Ee.tag&&n.default);function Xo(e,t,n){let r=sl(e,n);if(xe(r))for(let o of r.items)Yo(e,t,o);else if(Array.isArray(r))for(let o of r)Yo(e,t,o);else Yo(e,t,r)}function Yo(e,t,n){let r=sl(e,n);if(!_e(r))throw new Error("Merge sources must be maps or map aliases");let o=r.toJSON(null,e,Map);for(let[s,i]of o)t instanceof Map?t.has(s)||t.set(s,i):t instanceof Set?t.add(s):Object.prototype.hasOwnProperty.call(t,s)||Object.defineProperty(t,s,{value:i,writable:!0,enumerable:!0,configurable:!0});return t}function sl(e,t){return e&&we(t)?t.resolve(e.doc,e):t}function Er(e,t,{key:n,value:r}){if(T(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(ol(e,n))Xo(e,t,r);else{let o=K(n,"",e);if(t instanceof Map)t.set(o,K(r,o,e));else if(t instanceof Set)t.add(o);else{let s=um(n,o,e),i=K(r,s,e);s in t?Object.defineProperty(t,s,{value:i,writable:!0,enumerable:!0,configurable:!0}):t[s]=i}}return t}function um(e,t,n){if(t===null)return"";if(typeof t!="object")return String(t);if(T(e)&&n?.doc){let r=_r(n.doc,{});r.anchors=new Set;for(let s of n.anchors.keys())r.anchors.add(s.anchor);r.inFlow=!0,r.inStringifyKey=!0;let o=e.toString(r);if(!n.mapKeyWarned){let s=JSON.stringify(o);s.length>40&&(s=s.substring(0,36)+'..."'),Wo(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${s}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return o}return JSON.stringify(t)}function Mt(e,t,n){let r=Ge(e,void 0,n),o=Ge(t,void 0,n);return new J(r,o)}var J=class e{constructor(t,n=null){Object.defineProperty(this,ne,{value:Vo}),this.key=t,this.value=n}clone(t){let{key:n,value:r}=this;return T(n)&&(n=n.clone(t)),T(r)&&(r=r.clone(t)),new e(n,r)}toJSON(t,n){let r=n?.mapAsMap?new Map:{};return Er(n,r,this)}toString(t,n,r){return t?.doc?rl(this,t,n,r):JSON.stringify(this)}};function vr(e,t,n){return(t.inFlow??e.flow?fm:lm)(e,t,n)}function lm({comment:e,items:t},n,{blockItemPrefix:r,flowChars:o,itemIndent:s,onChompKeep:i,onComment:c}){let{indent:a,options:{commentString:u}}=n,d=Object.assign({},n,{indent:s,type:null}),l=!1,f=[];for(let y=0;y<t.length;++y){let m=t[y],h=null;if(T(m))!l&&m.spaceBefore&&f.push(""),Sr(n,f,m.commentBefore,l),m.comment&&(h=m.comment);else if(N(m)){let _=T(m.key)?m.key:null;_&&(!l&&_.spaceBefore&&f.push(""),Sr(n,f,_.commentBefore,l))}l=!1;let b=qe(m,d,()=>h=null,()=>l=!0);h&&(b+=Me(b,s,u(h))),l&&h&&(l=!1),f.push(r+b)}let p;if(f.length===0)p=o.start+o.end;else{p=f[0];for(let y=1;y<f.length;++y){let m=f[y];p+=m?`${a}${m}`:``}}return e?(p+=`-`+me(u(e),a),c&&c()):l&&i&&i(),p}function am({items:e},t,{flowChars:n,itemIndent:r}){let{indent:o,indentStep:s,flowCollectionPadding:i,options:{commentString:c}}=t;r+=s;let a=Object.assign({},t,{indent:r,inFlow:!0,type:null}),u=!1,d=0,l=[];for(let y=0;y<e.length;++y){let m=e[y],h=null;if(T(m))m.spaceBefore&&l.push(""),Er(t,l,m.commentBefore,!1),m.comment&&(h=m.comment);else if(N(m)){let _=T(m.key)?m.key:null;_&&(_.spaceBefore&&l.push(""),Er(t,l,_.commentBefore,!1),_.comment&&(u=!0));let x=T(m.value)?m.value:null;x?(x.comment&&(h=x.comment),x.commentBefore&&(u=!0)):m.value==null&&_?.comment&&(h=_.comment)}h&&(u=!0);let b=Ve(m,a,()=>h=null);u||(u=l.length>d||b.includes(`-`)),y<e.length-1?b+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(u||(u=l.reduce((_,x)=>_+x.length+2,2)+(b.length+2)>t.options.lineWidth)),u&&(b+=",")),h&&(b+=Le(b,r,c(h))),l.push(b),d=l.length}let{start:f,end:p}=n;if(l.length===0)return f+p;if(!u){let y=l.reduce((m,h)=>m+h.length+2,2);u=t.options.lineWidth>0&&y>t.options.lineWidth}if(u){let y=f;for(let m of l)y+=m?`+`+me(u(e),a),c&&c()):l&&i&&i(),p}function fm({items:e},t,{flowChars:n,itemIndent:r}){let{indent:o,indentStep:s,flowCollectionPadding:i,options:{commentString:c}}=t;r+=s;let a=Object.assign({},t,{indent:r,inFlow:!0,type:null}),u=!1,d=0,l=[];for(let y=0;y<e.length;++y){let m=e[y],h=null;if(T(m))m.spaceBefore&&l.push(""),Sr(t,l,m.commentBefore,!1),m.comment&&(h=m.comment);else if(N(m)){let _=T(m.key)?m.key:null;_&&(_.spaceBefore&&l.push(""),Sr(t,l,_.commentBefore,!1),_.comment&&(u=!0));let x=T(m.value)?m.value:null;x?(x.comment&&(h=x.comment),x.commentBefore&&(u=!0)):m.value==null&&_?.comment&&(h=_.comment)}h&&(u=!0);let b=qe(m,a,()=>h=null);u||(u=l.length>d||b.includes(`+`)),y<e.length-1?b+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(u||(u=l.reduce((_,x)=>_+x.length+2,2)+(b.length+2)>t.options.lineWidth)),u&&(b+=",")),h&&(b+=Me(b,r,c(h))),l.push(b),d=l.length}let{start:f,end:p}=n;if(l.length===0)return f+p;if(!u){let y=l.reduce((m,h)=>m+h.length+2,2);u=t.options.lineWidth>0&&y>t.options.lineWidth}if(u){let y=f;for(let m of l)y+=m?`${s}${o}${m}`:``;return`${y}-${o}${p}`}else return`${f}${i}${l.join(" ")}${i}${p}`}function Er({indent:e,options:{commentString:t}},n,r,o){if(r&&o&&(r=r.replace(/^\n+/,"")),r){let s=me(t(r),e);n.push(s.trimStart())}}function it(e,t){let n=R(t)?t.value:t;for(let r of e)if(N(r)&&(r.key===t||r.key===n||R(r.key)&&r.key.value===n))return r}var V=class extends zt{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(ge,t),this.items=[]}static from(t,n,r){let{keepUndefined:o,replacer:s}=r,i=new this(t),c=(a,u)=>{if(typeof s=="function")u=s.call(n,a,u);else if(Array.isArray(s)&&!s.includes(a))return;(u!==void 0||o)&&i.items.push(Mt(a,u,r))};if(n instanceof Map)for(let[a,u]of n)c(a,u);else if(n&&typeof n=="object")for(let a of Object.keys(n))c(a,n[a]);return typeof t.sortMapEntries=="function"&&i.items.sort(t.sortMapEntries),i}add(t,n){let r;N(t)?r=t:!t||typeof t!="object"||!("key"in t)?r=new J(t,t?.value):r=new J(t.key,t.value);let o=it(this.items,r.key),s=this.schema?.sortMapEntries;if(o){if(!n)throw new Error(`Key ${r.key} already set`);R(o.value)&&mr(r.value)?o.value.value=r.value:o.value=r.value}else if(s){let i=this.items.findIndex(c=>s(r,c)<0);i===-1?this.items.push(r):this.items.splice(i,0,r)}else this.items.push(r)}delete(t){let n=it(this.items,t);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(t,n){let o=it(this.items,t)?.value;return(!n&&R(o)?o.value:o)??void 0}has(t){return!!it(this.items,t)}set(t,n){this.add(new J(t,n),!0)}toJSON(t,n,r){let o=r?new r:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(o);for(let s of this.items)xr(n,o,s);return o}toString(t,n,r){if(!t)return JSON.stringify(this);for(let o of this.items)if(!N(o))throw new Error(`Map items must all be pairs; found ${JSON.stringify(o)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),Sr(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:r,onComment:n})}};var Ee={collection:"map",default:!0,nodeClass:V,tag:"tag:yaml.org,2002:map",resolve(e,t){return we(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,n)=>V.from(e,t,n)};var X=class extends zt{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(Ue,t),this.items=[]}add(t){this.items.push(t)}delete(t){let n=vr(t);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(t,n){let r=vr(t);if(typeof r!="number")return;let o=this.items[r];return!n&&R(o)?o.value:o}has(t){let n=vr(t);return typeof n=="number"&&n<this.items.length}set(t,n){let r=vr(t);if(typeof r!="number")throw new Error(`Expected a valid index, not ${t}.`);let o=this.items[r];R(o)&&mr(n)?o.value=n:this.items[r]=n}toJSON(t,n){let r=[];n?.onCreate&&n.onCreate(r);let o=0;for(let s of this.items)r.push(K(s,String(o++),n));return r}toString(t,n,r){return t?Sr(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+" ",onChompKeep:r,onComment:n}):JSON.stringify(this)}static from(t,n,r){let{replacer:o}=r,s=new this(t);if(n&&Symbol.iterator in Object(n)){let i=0;for(let c of n){if(typeof o=="function"){let a=n instanceof Set?c:String(i++);c=o.call(n,a,c)}s.items.push(Je(c,void 0,r))}}return s}};function vr(e){let t=R(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}var Se={collection:"seq",default:!0,nodeClass:X,tag:"tag:yaml.org,2002:seq",resolve(e,t){return _e(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,n)=>X.from(e,t,n)};var ct={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),ht(e,t,n,r)}};var yt={identify:e=>e==null,createNode:()=>new A(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new A(null),stringify:({source:e},t)=>typeof e=="string"&&yt.test.test(e)?e:t.options.nullStr};var hn={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new A(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},n){if(e&&hn.test.test(e)){let r=e[0]==="t"||e[0]==="T";if(t===r)return e}return t?n.options.trueStr:n.options.falseStr}};function H({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r=="bigint")return String(r);let o=typeof r=="number"?r:Number(r);if(!isFinite(o))return isNaN(o)?".nan":o<0?"-.inf":".inf";let s=Object.is(r,-0)?"-0":JSON.stringify(r);if(!e&&t&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(s)&&!s.includes("e")){let i=s.indexOf(".");i<0&&(i=s.length,s+=".");let c=t-(s.length-i-1);for(;c-- >0;)s+="0"}return s}var kr={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:H},Ar={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():H(e)}},Dr={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new A(parseFloat(e)),n=e.indexOf(".");return n!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-n-1),t},stringify:H};var Ir=e=>typeof e=="bigint"||Number.isInteger(e),Xo=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function nl(e,t,n){let{value:r}=e;return Ir(r)&&r>=0?n+r.toString(t):H(e)}var Or={identify:e=>Ir(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>Xo(e,2,8,n),stringify:e=>nl(e,8,"0o")},Rr={identify:Ir,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>Xo(e,0,10,n),stringify:H},$r={identify:e=>Ir(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>Xo(e,2,16,n),stringify:e=>nl(e,16,"0x")};var rl=[Ee,Se,ct,yt,hn,Or,Rr,$r,kr,Ar,Dr];function ol(e){return typeof e=="bigint"||Number.isInteger(e)}var Nr=({value:e})=>JSON.stringify(e),um=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Nr},{identify:e=>e==null,createNode:()=>new A(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Nr},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:Nr},{identify:ol,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>ol(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Nr}],lm={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},sl=[Ee,Se].concat(um,lm);var yn={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof atob=="function"){let n=atob(e.replace(/[\n\r]/g,"")),r=new Uint8Array(n.length);for(let o=0;o<n.length;++o)r[o]=n.charCodeAt(o);return r}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:n},r,o,s){if(!n)return"";let i=n,c;if(typeof btoa=="function"){let a="";for(let u=0;u<i.length;++u)a+=String.fromCharCode(i[u]);c=btoa(a)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=A.BLOCK_LITERAL),t!==A.QUOTE_DOUBLE){let a=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),u=Math.ceil(c.length/a),d=new Array(u);for(let l=0,f=0;l<u;++l,f+=a)d[l]=c.substr(f,a);c=d.join(t===A.BLOCK_LITERAL?`-`:" ")}return ht({comment:e,type:t,value:c},r,o,s)}};function Ho(e,t){if(_e(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!N(r)){if(we(r)){r.items.length>1&&t("Each pair must have its own sequence indicator");let o=r.items[0]||new J(new A(null));if(r.commentBefore&&(o.key.commentBefore=o.key.commentBefore?`${r.commentBefore}+${o}${p}`}else return`${f}${i}${l.join(" ")}${i}${p}`}function Sr({indent:e,options:{commentString:t}},n,r,o){if(r&&o&&(r=r.replace(/^\n+/,"")),r){let s=me(t(r),e);n.push(s.trimStart())}}function it(e,t){let n=O(t)?t.value:t;for(let r of e)if(N(r)&&(r.key===t||r.key===n||O(r.key)&&r.key.value===n))return r}var G=class extends zt{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(be,t),this.items=[]}static from(t,n,r){let{keepUndefined:o,replacer:s}=r,i=new this(t),c=(a,u)=>{if(typeof s=="function")u=s.call(n,a,u);else if(Array.isArray(s)&&!s.includes(a))return;(u!==void 0||o)&&i.items.push(Mt(a,u,r))};if(n instanceof Map)for(let[a,u]of n)c(a,u);else if(n&&typeof n=="object")for(let a of Object.keys(n))c(a,n[a]);return typeof t.sortMapEntries=="function"&&i.items.sort(t.sortMapEntries),i}add(t,n){let r;N(t)?r=t:!t||typeof t!="object"||!("key"in t)?r=new J(t,t?.value):r=new J(t.key,t.value);let o=it(this.items,r.key),s=this.schema?.sortMapEntries;if(o){if(!n)throw new Error(`Key ${r.key} already set`);O(o.value)&&hr(r.value)?o.value.value=r.value:o.value=r.value}else if(s){let i=this.items.findIndex(c=>s(r,c)<0);i===-1?this.items.push(r):this.items.splice(i,0,r)}else this.items.push(r)}delete(t){let n=it(this.items,t);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(t,n){let o=it(this.items,t)?.value;return(!n&&O(o)?o.value:o)??void 0}has(t){return!!it(this.items,t)}set(t,n){this.add(new J(t,n),!0)}toJSON(t,n,r){let o=r?new r:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(o);for(let s of this.items)Er(n,o,s);return o}toString(t,n,r){if(!t)return JSON.stringify(this);for(let o of this.items)if(!N(o))throw new Error(`Map items must all be pairs; found ${JSON.stringify(o)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),vr(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:r,onComment:n})}};var Se={collection:"map",default:!0,nodeClass:G,tag:"tag:yaml.org,2002:map",resolve(e,t){return _e(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,n)=>G.from(e,t,n)};var X=class extends zt{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(Qe,t),this.items=[]}add(t){this.items.push(t)}delete(t){let n=kr(t);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(t,n){let r=kr(t);if(typeof r!="number")return;let o=this.items[r];return!n&&O(o)?o.value:o}has(t){let n=kr(t);return typeof n=="number"&&n<this.items.length}set(t,n){let r=kr(t);if(typeof r!="number")throw new Error(`Expected a valid index, not ${t}.`);let o=this.items[r];O(o)&&hr(n)?o.value=n:this.items[r]=n}toJSON(t,n){let r=[];n?.onCreate&&n.onCreate(r);let o=0;for(let s of this.items)r.push(K(s,String(o++),n));return r}toString(t,n,r){return t?vr(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+" ",onChompKeep:r,onComment:n}):JSON.stringify(this)}static from(t,n,r){let{replacer:o}=r,s=new this(t);if(n&&Symbol.iterator in Object(n)){let i=0;for(let c of n){if(typeof o=="function"){let a=n instanceof Set?c:String(i++);c=o.call(n,a,c)}s.items.push(Ge(c,void 0,r))}}return s}};function kr(e){let t=O(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}var ve={collection:"seq",default:!0,nodeClass:X,tag:"tag:yaml.org,2002:seq",resolve(e,t){return xe(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,n)=>X.from(e,t,n)};var ct={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),ht(e,t,n,r)}};var yt={identify:e=>e==null,createNode:()=>new A(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new A(null),stringify:({source:e},t)=>typeof e=="string"&&yt.test.test(e)?e:t.options.nullStr};var yn={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new A(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},n){if(e&&yn.test.test(e)){let r=e[0]==="t"||e[0]==="T";if(t===r)return e}return t?n.options.trueStr:n.options.falseStr}};function H({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r=="bigint")return String(r);let o=typeof r=="number"?r:Number(r);if(!isFinite(o))return isNaN(o)?".nan":o<0?"-.inf":".inf";let s=Object.is(r,-0)?"-0":JSON.stringify(r);if(!e&&t&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(s)&&!s.includes("e")){let i=s.indexOf(".");i<0&&(i=s.length,s+=".");let c=t-(s.length-i-1);for(;c-- >0;)s+="0"}return s}var Ar={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:H},Dr={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():H(e)}},Ir={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new A(parseFloat(e)),n=e.indexOf(".");return n!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-n-1),t},stringify:H};var Rr=e=>typeof e=="bigint"||Number.isInteger(e),Ho=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function il(e,t,n){let{value:r}=e;return Rr(r)&&r>=0?n+r.toString(t):H(e)}var Or={identify:e=>Rr(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,n)=>Ho(e,2,8,n),stringify:e=>il(e,8,"0o")},$r={identify:Rr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>Ho(e,0,10,n),stringify:H},Nr={identify:e=>Rr(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>Ho(e,2,16,n),stringify:e=>il(e,16,"0x")};var cl=[Se,ve,ct,yt,yn,Or,$r,Nr,Ar,Dr,Ir];function al(e){return typeof e=="bigint"||Number.isInteger(e)}var Cr=({value:e})=>JSON.stringify(e),dm=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Cr},{identify:e=>e==null,createNode:()=>new A(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Cr},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:Cr},{identify:al,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>al(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Cr}],pm={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},ul=[Se,ve].concat(dm,pm);var gn={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof atob=="function"){let n=atob(e.replace(/[\n\r]/g,"")),r=new Uint8Array(n.length);for(let o=0;o<n.length;++o)r[o]=n.charCodeAt(o);return r}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:n},r,o,s){if(!n)return"";let i=n,c;if(typeof btoa=="function"){let a="";for(let u=0;u<i.length;++u)a+=String.fromCharCode(i[u]);c=btoa(a)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=A.BLOCK_LITERAL),t!==A.QUOTE_DOUBLE){let a=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),u=Math.ceil(c.length/a),d=new Array(u);for(let l=0,f=0;l<u;++l,f+=a)d[l]=c.substr(f,a);c=d.join(t===A.BLOCK_LITERAL?`+`:" ")}return ht({comment:e,type:t,value:c},r,o,s)}};function es(e,t){if(xe(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!N(r)){if(_e(r)){r.items.length>1&&t("Each pair must have its own sequence indicator");let o=r.items[0]||new J(new A(null));if(r.commentBefore&&(o.key.commentBefore=o.key.commentBefore?`${r.commentBefore}${o.key.commentBefore}`:r.commentBefore),r.comment){let s=o.value??o.key;s.comment=s.comment?`${r.comment}-${s.comment}`:r.comment}r=o}e.items[n]=N(r)?r:new J(r)}}else t("Expected a sequence for this tag");return e}function es(e,t,n){let{replacer:r}=n,o=new X(e);o.tag="tag:yaml.org,2002:pairs";let s=0;if(t&&Symbol.iterator in Object(t))for(let i of t){typeof r=="function"&&(i=r.call(t,String(s++),i));let c,a;if(Array.isArray(i))if(i.length===2)c=i[0],a=i[1];else throw new TypeError(`Expected [key, value] tuple: ${i}`);else if(i&&i instanceof Object){let u=Object.keys(i);if(u.length===1)c=u[0],a=i[c];else throw new TypeError(`Expected tuple with one key, not ${u.length} keys`)}else c=i;o.items.push(Mt(c,a,n))}return o}var gn={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ho,createNode:es};var Zt=class e extends X{constructor(){super(),this.add=V.prototype.add.bind(this),this.delete=V.prototype.delete.bind(this),this.get=V.prototype.get.bind(this),this.has=V.prototype.has.bind(this),this.set=V.prototype.set.bind(this),this.tag=e.tag}toJSON(t,n){if(!n)return super.toJSON(t);let r=new Map;n?.onCreate&&n.onCreate(r);for(let o of this.items){let s,i;if(N(o)?(s=K(o.key,"",n),i=K(o.value,s,n)):s=K(o,"",n),r.has(s))throw new Error("Ordered maps must not include duplicate keys");r.set(s,i)}return r}static from(t,n,r){let o=es(t,n,r),s=new this;return s.items=o.items,s}};Zt.tag="tag:yaml.org,2002:omap";var bn={collection:"seq",identify:e=>e instanceof Map,nodeClass:Zt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let n=Ho(e,t),r=[];for(let{key:o}of n.items)R(o)&&(r.includes(o.value)?t(`Ordered maps must not include duplicate keys: ${o.value}`):r.push(o.value));return Object.assign(new Zt,n)},createNode:(e,t,n)=>Zt.from(e,t,n)};function il({value:e,source:t},n){return t&&(e?ts:ns).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var ts={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new A(!0),stringify:il},ns={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new A(!1),stringify:il};var cl={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:H},al={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():H(e)}},ul={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new A(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(n!==-1){let r=e.substring(n+1).replace(/_/g,"");r[r.length-1]==="0"&&(t.minFractionDigits=r.length)}return t},stringify:H};var wn=e=>typeof e=="bigint"||Number.isInteger(e);function Cr(e,t,n,{intAsBigInt:r}){let o=e[0];if((o==="-"||o==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let i=BigInt(e);return o==="-"?BigInt(-1)*i:i}let s=parseInt(e,n);return o==="-"?-1*s:s}function rs(e,t,n){let{value:r}=e;if(wn(r)){let o=r.toString(t);return r<0?"-"+n+o.substr(1):n+o}return H(e)}var ll={identify:wn,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>Cr(e,2,2,n),stringify:e=>rs(e,2,"0b")},fl={identify:wn,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>Cr(e,1,8,n),stringify:e=>rs(e,8,"0")},dl={identify:wn,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>Cr(e,0,10,n),stringify:H},pl={identify:wn,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>Cr(e,2,16,n),stringify:e=>rs(e,16,"0x")};var Ft=class e extends V{constructor(t){super(t),this.tag=e.tag}add(t){let n;N(t)?n=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?n=new J(t.key,null):n=new J(t,null),it(this.items,n.key)||this.items.push(n)}get(t,n){let r=it(this.items,t);return!n&&N(r)?R(r.key)?r.key.value:r.key:r}set(t,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let r=it(this.items,t);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new J(t))}toJSON(t,n){return super.toJSON(t,n,Set)}toString(t,n,r){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),n,r);throw new Error("Set items must all have null values")}static from(t,n,r){let{replacer:o}=r,s=new this(t);if(n&&Symbol.iterator in Object(n))for(let i of n)typeof o=="function"&&(i=o.call(n,i,i)),s.items.push(Mt(i,null,r));return s}};Ft.tag="tag:yaml.org,2002:set";var _n={collection:"map",identify:e=>e instanceof Set,nodeClass:Ft,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Ft.from(e,t,n),resolve(e,t){if(we(e)){if(e.hasAllNullValues(!0))return Object.assign(new Ft,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};function os(e,t){let n=e[0],r=n==="-"||n==="+"?e.substring(1):e,o=i=>t?BigInt(i):Number(i),s=r.replace(/_/g,"").split(":").reduce((i,c)=>i*o(60)+o(c),o(0));return n==="-"?o(-1)*s:s}function ml(e){let{value:t}=e,n=i=>i;if(typeof t=="bigint")n=i=>BigInt(i);else if(isNaN(t)||!isFinite(t))return H(e);let r="";t<0&&(r="-",t*=n(-1));let o=n(60),s=[t%o];return t<60?s.unshift(0):(t=(t-s[0])/o,s.unshift(t%o),t>=60&&(t=(t-s[0])/o,s.unshift(t))),r+s.map(i=>String(i).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Tr={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>os(e,n),stringify:ml},zr={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>os(e,!1),stringify:ml},Bt={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Bt.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,o,s,i,c]=t.map(Number),a=t[7]?Number((t[7]+"00").substr(1,3)):0,u=Date.UTC(n,r-1,o,s||0,i||0,c||0,a),d=t[8];if(d&&d!=="Z"){let l=os(d,!1);Math.abs(l)<30&&(l*=60),u-=6e4*l}return new Date(u)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};var ss=[Ee,Se,ct,yt,ts,ns,ll,fl,dl,pl,cl,al,ul,yn,xe,bn,gn,_n,Tr,zr,Bt];var hl=new Map([["core",rl],["failsafe",[Ee,Se,ct]],["json",sl],["yaml11",ss],["yaml-1.1",ss]]),yl={binary:yn,bool:hn,float:Dr,floatExp:Ar,floatNaN:kr,floatTime:zr,int:Rr,intHex:$r,intOct:Or,intTime:Tr,map:Ee,merge:xe,null:yt,omap:bn,pairs:gn,seq:Se,set:_n,timestamp:Bt},gl={"tag:yaml.org,2002:binary":yn,"tag:yaml.org,2002:merge":xe,"tag:yaml.org,2002:omap":bn,"tag:yaml.org,2002:pairs":gn,"tag:yaml.org,2002:set":_n,"tag:yaml.org,2002:timestamp":Bt};function Pr(e,t,n){let r=hl.get(t);if(r&&!e)return n&&!r.includes(xe)?r.concat(xe):r.slice();let o=r;if(!o)if(Array.isArray(e))o=[];else{let s=Array.from(hl.keys()).filter(i=>i!=="yaml11").map(i=>JSON.stringify(i)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${s} or define customTags array`)}if(Array.isArray(e))for(let s of e)o=o.concat(s);else typeof e=="function"&&(o=e(o.slice()));return n&&(o=o.concat(xe)),o.reduce((s,i)=>{let c=typeof i=="string"?yl[i]:i;if(!c){let a=JSON.stringify(i),u=Object.keys(yl).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${a}; use one of ${u}`)}return s.includes(c)||s.push(c),s},[])}var fm=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,xn=class e{constructor({compat:t,customTags:n,merge:r,resolveKnownTags:o,schema:s,sortMapEntries:i,toStringDefaults:c}){this.compat=Array.isArray(t)?Pr(t,"compat"):t?Pr(null,t):null,this.name=typeof s=="string"&&s||"core",this.knownTags=o?gl:{},this.tags=Pr(n,this.name,r),this.toStringOptions=c??null,Object.defineProperty(this,ge,{value:Ee}),Object.defineProperty(this,le,{value:ct}),Object.defineProperty(this,Ue,{value:Se}),this.sortMapEntries=typeof i=="function"?i:i===!0?fm:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function bl(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let a=e.directives.toString(e);a?(n.push(a),r=!0):e.directives.docStart&&(r=!0)}r&&n.push("---");let o=wr(e,t),{commentString:s}=o.options;if(e.commentBefore){n.length!==1&&n.unshift("");let a=s(e.commentBefore);n.unshift(me(a,""))}let i=!1,c=null;if(e.contents){if(T(e.contents)){if(e.contents.spaceBefore&&r&&n.push(""),e.contents.commentBefore){let d=s(e.contents.commentBefore);n.push(me(d,""))}o.forceBlockIndent=!!e.comment,c=e.contents.comment}let a=c?void 0:()=>i=!0,u=Ve(e.contents,o,()=>c=null,a);c&&(u+=Le(u,"",s(c))),(u[0]==="|"||u[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${u}`:n.push(u)}else n.push(Ve(e.contents,o));if(e.directives?.docEnd)if(e.comment){let a=s(e.comment);a.includes(`+${s.comment}`:r.comment}r=o}e.items[n]=N(r)?r:new J(r)}}else t("Expected a sequence for this tag");return e}function ts(e,t,n){let{replacer:r}=n,o=new X(e);o.tag="tag:yaml.org,2002:pairs";let s=0;if(t&&Symbol.iterator in Object(t))for(let i of t){typeof r=="function"&&(i=r.call(t,String(s++),i));let c,a;if(Array.isArray(i))if(i.length===2)c=i[0],a=i[1];else throw new TypeError(`Expected [key, value] tuple: ${i}`);else if(i&&i instanceof Object){let u=Object.keys(i);if(u.length===1)c=u[0],a=i[c];else throw new TypeError(`Expected tuple with one key, not ${u.length} keys`)}else c=i;o.items.push(Mt(c,a,n))}return o}var bn={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:es,createNode:ts};var Zt=class e extends X{constructor(){super(),this.add=G.prototype.add.bind(this),this.delete=G.prototype.delete.bind(this),this.get=G.prototype.get.bind(this),this.has=G.prototype.has.bind(this),this.set=G.prototype.set.bind(this),this.tag=e.tag}toJSON(t,n){if(!n)return super.toJSON(t);let r=new Map;n?.onCreate&&n.onCreate(r);for(let o of this.items){let s,i;if(N(o)?(s=K(o.key,"",n),i=K(o.value,s,n)):s=K(o,"",n),r.has(s))throw new Error("Ordered maps must not include duplicate keys");r.set(s,i)}return r}static from(t,n,r){let o=ts(t,n,r),s=new this;return s.items=o.items,s}};Zt.tag="tag:yaml.org,2002:omap";var wn={collection:"seq",identify:e=>e instanceof Map,nodeClass:Zt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let n=es(e,t),r=[];for(let{key:o}of n.items)O(o)&&(r.includes(o.value)?t(`Ordered maps must not include duplicate keys: ${o.value}`):r.push(o.value));return Object.assign(new Zt,n)},createNode:(e,t,n)=>Zt.from(e,t,n)};function ll({value:e,source:t},n){return t&&(e?ns:rs).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var ns={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new A(!0),stringify:ll},rs={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new A(!1),stringify:ll};var fl={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:H},dl={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():H(e)}},pl={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new A(parseFloat(e.replace(/_/g,""))),n=e.indexOf(".");if(n!==-1){let r=e.substring(n+1).replace(/_/g,"");r[r.length-1]==="0"&&(t.minFractionDigits=r.length)}return t},stringify:H};var _n=e=>typeof e=="bigint"||Number.isInteger(e);function Tr(e,t,n,{intAsBigInt:r}){let o=e[0];if((o==="-"||o==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let i=BigInt(e);return o==="-"?BigInt(-1)*i:i}let s=parseInt(e,n);return o==="-"?-1*s:s}function os(e,t,n){let{value:r}=e;if(_n(r)){let o=r.toString(t);return r<0?"-"+n+o.substr(1):n+o}return H(e)}var ml={identify:_n,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>Tr(e,2,2,n),stringify:e=>os(e,2,"0b")},hl={identify:_n,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>Tr(e,1,8,n),stringify:e=>os(e,8,"0")},yl={identify:_n,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>Tr(e,0,10,n),stringify:H},gl={identify:_n,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>Tr(e,2,16,n),stringify:e=>os(e,16,"0x")};var Ft=class e extends G{constructor(t){super(t),this.tag=e.tag}add(t){let n;N(t)?n=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?n=new J(t.key,null):n=new J(t,null),it(this.items,n.key)||this.items.push(n)}get(t,n){let r=it(this.items,t);return!n&&N(r)?O(r.key)?r.key.value:r.key:r}set(t,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let r=it(this.items,t);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new J(t))}toJSON(t,n){return super.toJSON(t,n,Set)}toString(t,n,r){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),n,r);throw new Error("Set items must all have null values")}static from(t,n,r){let{replacer:o}=r,s=new this(t);if(n&&Symbol.iterator in Object(n))for(let i of n)typeof o=="function"&&(i=o.call(n,i,i)),s.items.push(Mt(i,null,r));return s}};Ft.tag="tag:yaml.org,2002:set";var xn={collection:"map",identify:e=>e instanceof Set,nodeClass:Ft,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,n)=>Ft.from(e,t,n),resolve(e,t){if(_e(e)){if(e.hasAllNullValues(!0))return Object.assign(new Ft,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};function ss(e,t){let n=e[0],r=n==="-"||n==="+"?e.substring(1):e,o=i=>t?BigInt(i):Number(i),s=r.replace(/_/g,"").split(":").reduce((i,c)=>i*o(60)+o(c),o(0));return n==="-"?o(-1)*s:s}function bl(e){let{value:t}=e,n=i=>i;if(typeof t=="bigint")n=i=>BigInt(i);else if(isNaN(t)||!isFinite(t))return H(e);let r="";t<0&&(r="-",t*=n(-1));let o=n(60),s=[t%o];return t<60?s.unshift(0):(t=(t-s[0])/o,s.unshift(t%o),t>=60&&(t=(t-s[0])/o,s.unshift(t))),r+s.map(i=>String(i).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var zr={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>ss(e,n),stringify:bl},Pr={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>ss(e,!1),stringify:bl},Bt={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Bt.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,n,r,o,s,i,c]=t.map(Number),a=t[7]?Number((t[7]+"00").substr(1,3)):0,u=Date.UTC(n,r-1,o,s||0,i||0,c||0,a),d=t[8];if(d&&d!=="Z"){let l=ss(d,!1);Math.abs(l)<30&&(l*=60),u-=6e4*l}return new Date(u)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};var is=[Se,ve,ct,yt,ns,rs,ml,hl,yl,gl,fl,dl,pl,gn,Ee,wn,bn,xn,zr,Pr,Bt];var wl=new Map([["core",cl],["failsafe",[Se,ve,ct]],["json",ul],["yaml11",is],["yaml-1.1",is]]),_l={binary:gn,bool:yn,float:Ir,floatExp:Dr,floatNaN:Ar,floatTime:Pr,int:$r,intHex:Nr,intOct:Or,intTime:zr,map:Se,merge:Ee,null:yt,omap:wn,pairs:bn,seq:ve,set:xn,timestamp:Bt},xl={"tag:yaml.org,2002:binary":gn,"tag:yaml.org,2002:merge":Ee,"tag:yaml.org,2002:omap":wn,"tag:yaml.org,2002:pairs":bn,"tag:yaml.org,2002:set":xn,"tag:yaml.org,2002:timestamp":Bt};function Lr(e,t,n){let r=wl.get(t);if(r&&!e)return n&&!r.includes(Ee)?r.concat(Ee):r.slice();let o=r;if(!o)if(Array.isArray(e))o=[];else{let s=Array.from(wl.keys()).filter(i=>i!=="yaml11").map(i=>JSON.stringify(i)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${s} or define customTags array`)}if(Array.isArray(e))for(let s of e)o=o.concat(s);else typeof e=="function"&&(o=e(o.slice()));return n&&(o=o.concat(Ee)),o.reduce((s,i)=>{let c=typeof i=="string"?_l[i]:i;if(!c){let a=JSON.stringify(i),u=Object.keys(_l).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${a}; use one of ${u}`)}return s.includes(c)||s.push(c),s},[])}var mm=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,En=class e{constructor({compat:t,customTags:n,merge:r,resolveKnownTags:o,schema:s,sortMapEntries:i,toStringDefaults:c}){this.compat=Array.isArray(t)?Lr(t,"compat"):t?Lr(null,t):null,this.name=typeof s=="string"&&s||"core",this.knownTags=o?xl:{},this.tags=Lr(n,this.name,r),this.toStringOptions=c??null,Object.defineProperty(this,be,{value:Se}),Object.defineProperty(this,le,{value:ct}),Object.defineProperty(this,Qe,{value:ve}),this.sortMapEntries=typeof i=="function"?i:i===!0?mm:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function El(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let a=e.directives.toString(e);a?(n.push(a),r=!0):e.directives.docStart&&(r=!0)}r&&n.push("---");let o=_r(e,t),{commentString:s}=o.options;if(e.commentBefore){n.length!==1&&n.unshift("");let a=s(e.commentBefore);n.unshift(me(a,""))}let i=!1,c=null;if(e.contents){if(T(e.contents)){if(e.contents.spaceBefore&&r&&n.push(""),e.contents.commentBefore){let d=s(e.contents.commentBefore);n.push(me(d,""))}o.forceBlockIndent=!!e.comment,c=e.contents.comment}let a=c?void 0:()=>i=!0,u=qe(e.contents,o,()=>c=null,a);c&&(u+=Me(u,"",s(c))),(u[0]==="|"||u[0]===">")&&n[n.length-1]==="---"?n[n.length-1]=`--- ${u}`:n.push(u)}else n.push(qe(e.contents,o));if(e.directives?.docEnd)if(e.comment){let a=s(e.comment);a.includes(``)?(n.push("..."),n.push(me(a,""))):n.push(`... ${a}`)}else n.push("...");else{let a=e.comment;a&&i&&(a=a.replace(/^\n+/,"")),a&&((!i||c)&&n[n.length-1]!==""&&n.push(""),n.push(me(s(a),"")))}return n.join(``)+`-`}var at=class e{constructor(t,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ne,{value:ur});let o=null;typeof n=="function"||Array.isArray(n)?o=n:r===void 0&&n&&(r=n,n=void 0);let s=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=s;let{version:i}=s;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(i=this.directives.yaml.version)):this.directives=new Pe({version:i}),this.setSchema(i,r),this.contents=t===void 0?null:this.createNode(t,o,r)}clone(){let t=Object.create(e.prototype,{[ne]:{value:ur}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=T(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){jt(this.contents)&&this.contents.add(t)}addIn(t,n){jt(this.contents)&&this.contents.addIn(t,n)}createAlias(t,n){if(!t.anchor){let r=Qo(this);t.anchor=!n||r.has(n)?Jo(n||"a",r):n}return new Qe(t.anchor)}createNode(t,n,r){let o;if(typeof n=="function")t=n.call({"":t},"",t),o=n;else if(Array.isArray(n)){let h=_=>typeof _=="number"||_ instanceof String||_ instanceof Number,b=n.filter(h).map(String);b.length>0&&(n=n.concat(b)),o=n}else r===void 0&&n&&(r=n,n=void 0);let{aliasDuplicateObjects:s,anchorPrefix:i,flow:c,keepUndefined:a,onTagObj:u,tag:d}=r??{},{onAnchor:l,setAnchors:f,sourceObjects:p}=Wu(this,i||"a"),y={aliasDuplicateObjects:s??!0,keepUndefined:a??!1,onAnchor:l,onTagObj:u,replacer:o,schema:this.schema,sourceObjects:p},m=Je(t,d,y);return c&&L(m)&&(m.flow=!0),f(),m}createPair(t,n,r={}){let o=this.createNode(t,null,r),s=this.createNode(n,null,r);return new J(o,s)}delete(t){return jt(this.contents)?this.contents.delete(t):!1}deleteIn(t){return Pt(t)?this.contents==null?!1:(this.contents=null,!0):jt(this.contents)?this.contents.deleteIn(t):!1}get(t,n){return L(this.contents)?this.contents.get(t,n):void 0}getIn(t,n){return Pt(t)?!n&&R(this.contents)?this.contents.value:this.contents:L(this.contents)?this.contents.getIn(t,n):void 0}has(t){return L(this.contents)?this.contents.has(t):!1}hasIn(t){return Pt(t)?this.contents!==void 0:L(this.contents)?this.contents.hasIn(t):!1}set(t,n){this.contents==null?this.contents=fn(this.schema,[t],n):jt(this.contents)&&this.contents.set(t,n)}setIn(t,n){Pt(t)?this.contents=n:this.contents==null?this.contents=fn(this.schema,Array.from(t),n):jt(this.contents)&&this.contents.setIn(t,n)}setSchema(t,n={}){typeof t=="number"&&(t=String(t));let r;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Pe({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new Pe({version:t}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let o=JSON.stringify(t);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${o}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(r)this.schema=new xn(Object.assign(r,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:n,mapAsMap:r,maxAliasCount:o,onAnchor:s,reviver:i}={}){let c={anchors:new Map,doc:this,keep:!t,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof o=="number"?o:100},a=K(this.contents,n??"",c);if(typeof s=="function")for(let{count:u,res:d}of c.anchors.values())s(d,u);return typeof i=="function"?ot(i,{"":a},"",a):a}toJSON(t,n){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:n})}toString(t={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){let n=JSON.stringify(t.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return bl(this,t)}};function jt(e){if(L(e))return!0;throw new Error("Expected a YAML collection as document contents")}var En=class extends Error{constructor(t,n,r,o){super(),this.name=t,this.code=r,this.message=o,this.pos=n}},ve=class extends En{constructor(t,n,r){super("YAMLParseError",t,n,r)}},Sn=class extends En{constructor(t,n,r){super("YAMLWarning",t,n,r)}},is=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(c=>t.linePos(c));let{line:r,col:o}=n.linePos[0];n.message+=` at line ${r}, column ${o}`;let s=o-1,i=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,"");if(s>=60&&i.length>80){let c=Math.min(s-39,i.length-79);i="\u2026"+i.substring(c),s-=c-1}if(i.length>80&&(i=i.substring(0,79)+"\u2026"),r>1&&/^ *$/.test(i.substring(0,s))){let c=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);c.length>80&&(c=c.substring(0,79)+`\u2026+`}var at=class e{constructor(t,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ne,{value:lr});let o=null;typeof n=="function"||Array.isArray(n)?o=n:r===void 0&&n&&(r=n,n=void 0);let s=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=s;let{version:i}=s;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(i=this.directives.yaml.version)):this.directives=new Le({version:i}),this.setSchema(i,r),this.contents=t===void 0?null:this.createNode(t,o,r)}clone(){let t=Object.create(e.prototype,{[ne]:{value:lr}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=T(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){jt(this.contents)&&this.contents.add(t)}addIn(t,n){jt(this.contents)&&this.contents.addIn(t,n)}createAlias(t,n){if(!t.anchor){let r=Qo(this);t.anchor=!n||r.has(n)?Jo(n||"a",r):n}return new Je(t.anchor)}createNode(t,n,r){let o;if(typeof n=="function")t=n.call({"":t},"",t),o=n;else if(Array.isArray(n)){let h=_=>typeof _=="number"||_ instanceof String||_ instanceof Number,b=n.filter(h).map(String);b.length>0&&(n=n.concat(b)),o=n}else r===void 0&&n&&(r=n,n=void 0);let{aliasDuplicateObjects:s,anchorPrefix:i,flow:c,keepUndefined:a,onTagObj:u,tag:d}=r??{},{onAnchor:l,setAnchors:f,sourceObjects:p}=el(this,i||"a"),y={aliasDuplicateObjects:s??!0,keepUndefined:a??!1,onAnchor:l,onTagObj:u,replacer:o,schema:this.schema,sourceObjects:p},m=Ge(t,d,y);return c&&L(m)&&(m.flow=!0),f(),m}createPair(t,n,r={}){let o=this.createNode(t,null,r),s=this.createNode(n,null,r);return new J(o,s)}delete(t){return jt(this.contents)?this.contents.delete(t):!1}deleteIn(t){return Pt(t)?this.contents==null?!1:(this.contents=null,!0):jt(this.contents)?this.contents.deleteIn(t):!1}get(t,n){return L(this.contents)?this.contents.get(t,n):void 0}getIn(t,n){return Pt(t)?!n&&O(this.contents)?this.contents.value:this.contents:L(this.contents)?this.contents.getIn(t,n):void 0}has(t){return L(this.contents)?this.contents.has(t):!1}hasIn(t){return Pt(t)?this.contents!==void 0:L(this.contents)?this.contents.hasIn(t):!1}set(t,n){this.contents==null?this.contents=dn(this.schema,[t],n):jt(this.contents)&&this.contents.set(t,n)}setIn(t,n){Pt(t)?this.contents=n:this.contents==null?this.contents=dn(this.schema,Array.from(t),n):jt(this.contents)&&this.contents.setIn(t,n)}setSchema(t,n={}){typeof t=="number"&&(t=String(t));let r;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Le({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new Le({version:t}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let o=JSON.stringify(t);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${o}`)}}if(n.schema instanceof Object)this.schema=n.schema;else if(r)this.schema=new En(Object.assign(r,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:n,mapAsMap:r,maxAliasCount:o,onAnchor:s,reviver:i}={}){let c={anchors:new Map,doc:this,keep:!t,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof o=="number"?o:100},a=K(this.contents,n??"",c);if(typeof s=="function")for(let{count:u,res:d}of c.anchors.values())s(d,u);return typeof i=="function"?ot(i,{"":a},"",a):a}toJSON(t,n){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:n})}toString(t={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){let n=JSON.stringify(t.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return El(this,t)}};function jt(e){if(L(e))return!0;throw new Error("Expected a YAML collection as document contents")}var Sn=class extends Error{constructor(t,n,r,o){super(),this.name=t,this.code=r,this.message=o,this.pos=n}},ke=class extends Sn{constructor(t,n,r){super("YAMLParseError",t,n,r)}},vn=class extends Sn{constructor(t,n,r){super("YAMLWarning",t,n,r)}},cs=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(c=>t.linePos(c));let{line:r,col:o}=n.linePos[0];n.message+=` at line ${r}, column ${o}`;let s=o-1,i=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,"");if(s>=60&&i.length>80){let c=Math.min(s-39,i.length-79);i="\u2026"+i.substring(c),s-=c-1}if(i.length>80&&(i=i.substring(0,79)+"\u2026"),r>1&&/^ *$/.test(i.substring(0,s))){let c=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);c.length>80&&(c=c.substring(0,79)+`\u2026`),i=c+i}if(/[^ ]/.test(i)){let c=1,a=n.linePos[1];a?.line===r&&a.col>o&&(c=Math.max(1,Math.min(a.col-o,80-s)));let u=" ".repeat(s)+"^".repeat(c);n.message+=`:${i}${u}-`}};function Me(e,{flow:t,indicator:n,next:r,offset:o,onError:s,parentIndent:i,startOnNewline:c}){let a=!1,u=c,d=c,l="",f="",p=!1,y=!1,m=null,h=null,b=null,_=null,x=null,w=null,S=null;for(let E of e)switch(y&&(E.type!=="space"&&E.type!=="newline"&&E.type!=="comma"&&s(E.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),y=!1),m&&(u&&E.type!=="comment"&&E.type!=="newline"&&s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),E.type){case"space":!t&&(n!=="doc-start"||r?.type!=="flow-collection")&&E.source.includes(" ")&&(m=E),d=!0;break;case"comment":{d||s(E,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let G=E.source.substring(1)||" ";l?l+=f+G:l=G,f="",u=!1;break}case"newline":u?l?l+=E.source:(!w||n!=="seq-item-ind")&&(a=!0):f+=E.source,u=!0,p=!0,(h||b)&&(_=E),d=!0;break;case"anchor":h&&s(E,"MULTIPLE_ANCHORS","A node can have at most one anchor"),E.source.endsWith(":")&&s(E.offset+E.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),h=E,S??(S=E.offset),u=!1,d=!1,y=!0;break;case"tag":{b&&s(E,"MULTIPLE_TAGS","A node can have at most one tag"),b=E,S??(S=E.offset),u=!1,d=!1,y=!0;break}case n:(h||b)&&s(E,"BAD_PROP_ORDER",`Anchors and tags must be after the ${E.source} indicator`),w&&s(E,"UNEXPECTED_TOKEN",`Unexpected ${E.source} in ${t??"collection"}`),w=E,u=n==="seq-item-ind"||n==="explicit-key-ind",d=!1;break;case"comma":if(t){x&&s(E,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),x=E,u=!1,d=!1;break}default:s(E,"UNEXPECTED_TOKEN",`Unexpected ${E.type} token`),u=!1,d=!1}let v=e[e.length-1],$=v?v.offset+v.source.length:o;return y&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&s(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(u&&m.indent<=i||r?.type==="block-map"||r?.type==="block-seq")&&s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:x,found:w,spaceBefore:a,comment:l,hasNewline:p,anchor:h,tag:b,newlineAfterProp:_,end:$,start:S??$}}function ut(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`-`))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let n of t.start)if(n.type==="newline")return!0;if(t.sep){for(let n of t.sep)if(n.type==="newline")return!0}if(ut(t.key)||ut(t.value))return!0}return!1;default:return!0}}function vn(e,t,n){if(t?.type==="flow-collection"){let r=t.end[0];r.indent===e&&(r.source==="]"||r.source==="}")&&ut(t)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function Lr(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let o=typeof r=="function"?r:(s,i)=>s===i||R(s)&&R(i)&&s.value===i.value;return t.some(s=>o(s.key,n))}var wl="All mapping items must start at the same column";function _l({composeNode:e,composeEmptyNode:t},n,r,o,s){let i=s?.nodeClass??V,c=new i(n.schema);n.atRoot&&(n.atRoot=!1);let a=r.offset,u=null;for(let d of r.items){let{start:l,key:f,sep:p,value:y}=d,m=Me(l,{indicator:"explicit-key-ind",next:f??p?.[0],offset:a,onError:o,parentIndent:r.indent,startOnNewline:!0}),h=!m.found;if(h){if(f&&(f.type==="block-seq"?o(a,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==r.indent&&o(a,"BAD_INDENT",wl)),!m.anchor&&!m.tag&&!p){u=m.end,m.comment&&(c.comment?c.comment+=`-`+m.comment:c.comment=m.comment);continue}(m.newlineAfterProp||ut(f))&&o(f??l[l.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else m.found?.indent!==r.indent&&o(a,"BAD_INDENT",wl);n.atKey=!0;let b=m.end,_=f?e(n,f,m,o):t(n,b,l,null,m,o);n.schema.compat&&vn(r.indent,f,o),n.atKey=!1,Lr(n,c.items,_)&&o(b,"DUPLICATE_KEY","Map keys must be unique");let x=Me(p??[],{indicator:"map-value-ind",next:y,offset:_.range[2],onError:o,parentIndent:r.indent,startOnNewline:!f||f.type==="block-scalar"});if(a=x.end,x.found){h&&(y?.type==="block-map"&&!x.hasNewline&&o(a,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<x.found.offset-1024&&o(_.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let w=y?e(n,y,x,o):t(n,a,p,null,x,o);n.schema.compat&&vn(r.indent,y,o),a=w.range[2];let S=new J(_,w);n.options.keepSourceTokens&&(S.srcToken=d),c.items.push(S)}else{h&&o(_.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),x.comment&&(_.comment?_.comment+=`-`+x.comment:_.comment=x.comment);let w=new J(_);n.options.keepSourceTokens&&(w.srcToken=d),c.items.push(w)}}return u&&u<a&&o(u,"IMPOSSIBLE","Map comment with trailing content"),c.range=[r.offset,a,u??a],c}function xl({composeNode:e,composeEmptyNode:t},n,r,o,s){let i=s?.nodeClass??X,c=new i(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let a=r.offset,u=null;for(let{start:d,value:l}of r.items){let f=Me(d,{indicator:"seq-item-ind",next:l,offset:a,onError:o,parentIndent:r.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||l)l?.type==="block-seq"?o(f.end,"BAD_INDENT","All sequence items must start at the same column"):o(a,"MISSING_CHAR","Sequence item without - indicator");else{u=f.end,f.comment&&(c.comment=f.comment);continue}let p=l?e(n,l,f,o):t(n,f.end,d,null,f,o);n.schema.compat&&vn(r.indent,l,o),a=p.range[2],c.items.push(p)}return c.range=[r.offset,a,u??a],c}function Ze(e,t,n,r){let o="";if(e){let s=!1,i="";for(let c of e){let{source:a,type:u}=c;switch(u){case"space":s=!0;break;case"comment":{n&&!s&&r(c,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let d=a.substring(1)||" ";o?o+=i+d:o=d,i="";break}case"newline":o&&(i+=a),s=!0;break;default:r(c,"UNEXPECTED_TOKEN",`Unexpected ${u} at node end`)}t+=a.length}}return{comment:o,offset:t}}var cs="Block collections are not allowed within flow collections",as=e=>e&&(e.type==="block-map"||e.type==="block-seq");function El({composeNode:e,composeEmptyNode:t},n,r,o,s){let i=r.start.source==="{",c=i?"flow map":"flow sequence",a=s?.nodeClass??(i?V:X),u=new a(n.schema);u.flow=!0;let d=n.atRoot;d&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let l=r.offset+r.start.source.length;for(let h=0;h<r.items.length;++h){let b=r.items[h],{start:_,key:x,sep:w,value:S}=b,v=Me(_,{flow:c,indicator:"explicit-key-ind",next:x??w?.[0],offset:l,onError:o,parentIndent:r.indent,startOnNewline:!1});if(!v.found){if(!v.anchor&&!v.tag&&!w&&!S){h===0&&v.comma?o(v.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${c}`):h<r.items.length-1&&o(v.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${c}`),v.comment&&(u.comment?u.comment+=`-`+v.comment:u.comment=v.comment),l=v.end;continue}!i&&n.options.strict&&ut(x)&&o(x,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(h===0)v.comma&&o(v.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${c}`);else if(v.comma||o(v.start,"MISSING_CHAR",`Missing , between ${c} items`),v.comment){let $="";e:for(let E of _)switch(E.type){case"comma":case"space":break;case"comment":$=E.source.substring(1);break e;default:break e}if($){let E=u.items[u.items.length-1];N(E)&&(E=E.value??E.key),E.comment?E.comment+=`-`+$:E.comment=$,v.comment=v.comment.substring($.length+1)}}if(!i&&!w&&!v.found){let $=S?e(n,S,v,o):t(n,v.end,w,null,v,o);u.items.push($),l=$.range[2],as(S)&&o($.range,"BLOCK_IN_FLOW",cs)}else{n.atKey=!0;let $=v.end,E=x?e(n,x,v,o):t(n,$,_,null,v,o);as(x)&&o(E.range,"BLOCK_IN_FLOW",cs),n.atKey=!1;let G=Me(w??[],{flow:c,indicator:"map-value-ind",next:S,offset:E.range[2],onError:o,parentIndent:r.indent,startOnNewline:!1});if(G.found){if(!i&&!v.found&&n.options.strict){if(w)for(let q of w){if(q===G.found)break;if(q.type==="newline"){o(q,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}v.start<G.found.offset-1024&&o(G.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else S&&("source"in S&&S.source?.[0]===":"?o(S,"MISSING_CHAR",`Missing space after : in ${c}`):o(G.start,"MISSING_CHAR",`Missing , or : between ${c} items`));let Ke=S?e(n,S,G,o):G.found?t(n,G.end,w,null,G,o):null;Ke?as(S)&&o(Ke.range,"BLOCK_IN_FLOW",cs):G.comment&&(E.comment?E.comment+=`-`+G.comment:E.comment=G.comment);let wt=new J(E,Ke);if(n.options.keepSourceTokens&&(wt.srcToken=b),i){let q=u;Lr(n,q.items,E)&&o($,"DUPLICATE_KEY","Map keys must be unique"),q.items.push(wt)}else{let q=new V(n.schema);q.flow=!0,q.items.push(wt);let Ss=(Ke??E).range;q.range=[E.range[0],Ss[1],Ss[2]],u.items.push(q)}l=Ke?Ke.range[2]:G.end}}let f=i?"}":"]",[p,...y]=r.end,m=l;if(p?.source===f)m=p.offset+p.source.length;else{let h=c[0].toUpperCase()+c.substring(1),b=d?`${h} must end with a ${f}`:`${h} in block collection must be sufficiently indented and end with a ${f}`;o(l,d?"MISSING_CHAR":"BAD_INDENT",b),p&&p.source.length!==1&&y.unshift(p)}if(y.length>0){let h=Ze(y,m,n.options.strict,o);h.comment&&(u.comment?u.comment+=`-`+h.comment:u.comment=h.comment),u.range=[r.offset,m,h.offset]}else u.range=[r.offset,m,m];return u}function us(e,t,n,r,o,s){let i=n.type==="block-map"?_l(e,t,n,r,s):n.type==="block-seq"?xl(e,t,n,r,s):El(e,t,n,r,s),c=i.constructor;return o==="!"||o===c.tagName?(i.tag=c.tagName,i):(o&&(i.tag=o),i)}function Sl(e,t,n,r,o){let s=r.tag,i=s?t.directives.tagName(s.source,f=>o(s,"TAG_RESOLVE_FAILED",f)):null;if(n.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=r,y=f&&s?f.offset>s.offset?f:s:f??s;y&&(!p||p.offset<y.offset)&&o(y,"MISSING_CHAR","Missing newline after block sequence props")}let c=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!s||!i||i==="!"||i===V.tagName&&c==="map"||i===X.tagName&&c==="seq")return us(e,t,n,o,i);let a=t.schema.tags.find(f=>f.tag===i&&f.collection===c);if(!a){let f=t.schema.knownTags[i];if(f?.collection===c)t.schema.tags.push(Object.assign({},f,{default:!1})),a=f;else return f?o(s,"BAD_COLLECTION_TYPE",`${f.tag} used for ${c} collection, but expects ${f.collection??"scalar"}`,!0):o(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0),us(e,t,n,o,i)}let u=us(e,t,n,o,i,a),d=a.resolve?.(u,f=>o(s,"TAG_RESOLVE_FAILED",f),t.options)??u,l=T(d)?d:new A(d);return l.range=u.range,l.tag=i,a?.format&&(l.format=a.format),l}function ls(e,t,n){let r=t.offset,o=dm(t,e.options.strict,n);if(!o)return{value:"",type:null,comment:"",range:[r,r,r]};let s=o.mode===">"?A.BLOCK_FOLDED:A.BLOCK_LITERAL,i=t.source?pm(t.source):[],c=i.length;for(let m=i.length-1;m>=0;--m){let h=i[m][1];if(h===""||h==="\r")c=m;else break}if(c===0){let m=o.chomp==="+"&&i.length>0?`+`}};function Ze(e,{flow:t,indicator:n,next:r,offset:o,onError:s,parentIndent:i,startOnNewline:c}){let a=!1,u=c,d=c,l="",f="",p=!1,y=!1,m=null,h=null,b=null,_=null,x=null,w=null,S=null;for(let E of e)switch(y&&(E.type!=="space"&&E.type!=="newline"&&E.type!=="comma"&&s(E.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),y=!1),m&&(u&&E.type!=="comment"&&E.type!=="newline"&&s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),E.type){case"space":!t&&(n!=="doc-start"||r?.type!=="flow-collection")&&E.source.includes(" ")&&(m=E),d=!0;break;case"comment":{d||s(E,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let U=E.source.substring(1)||" ";l?l+=f+U:l=U,f="",u=!1;break}case"newline":u?l?l+=E.source:(!w||n!=="seq-item-ind")&&(a=!0):f+=E.source,u=!0,p=!0,(h||b)&&(_=E),d=!0;break;case"anchor":h&&s(E,"MULTIPLE_ANCHORS","A node can have at most one anchor"),E.source.endsWith(":")&&s(E.offset+E.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),h=E,S??(S=E.offset),u=!1,d=!1,y=!0;break;case"tag":{b&&s(E,"MULTIPLE_TAGS","A node can have at most one tag"),b=E,S??(S=E.offset),u=!1,d=!1,y=!0;break}case n:(h||b)&&s(E,"BAD_PROP_ORDER",`Anchors and tags must be after the ${E.source} indicator`),w&&s(E,"UNEXPECTED_TOKEN",`Unexpected ${E.source} in ${t??"collection"}`),w=E,u=n==="seq-item-ind"||n==="explicit-key-ind",d=!1;break;case"comma":if(t){x&&s(E,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),x=E,u=!1,d=!1;break}default:s(E,"UNEXPECTED_TOKEN",`Unexpected ${E.type} token`),u=!1,d=!1}let k=e[e.length-1],$=k?k.offset+k.source.length:o;return y&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&s(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(u&&m.indent<=i||r?.type==="block-map"||r?.type==="block-seq")&&s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:x,found:w,spaceBefore:a,comment:l,hasNewline:p,anchor:h,tag:b,newlineAfterProp:_,end:$,start:S??$}}function ut(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`+`))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let n of t.start)if(n.type==="newline")return!0;if(t.sep){for(let n of t.sep)if(n.type==="newline")return!0}if(ut(t.key)||ut(t.value))return!0}return!1;default:return!0}}function kn(e,t,n){if(t?.type==="flow-collection"){let r=t.end[0];r.indent===e&&(r.source==="]"||r.source==="}")&&ut(t)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function Mr(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let o=typeof r=="function"?r:(s,i)=>s===i||O(s)&&O(i)&&s.value===i.value;return t.some(s=>o(s.key,n))}var Sl="All mapping items must start at the same column";function vl({composeNode:e,composeEmptyNode:t},n,r,o,s){let i=s?.nodeClass??G,c=new i(n.schema);n.atRoot&&(n.atRoot=!1);let a=r.offset,u=null;for(let d of r.items){let{start:l,key:f,sep:p,value:y}=d,m=Ze(l,{indicator:"explicit-key-ind",next:f??p?.[0],offset:a,onError:o,parentIndent:r.indent,startOnNewline:!0}),h=!m.found;if(h){if(f&&(f.type==="block-seq"?o(a,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==r.indent&&o(a,"BAD_INDENT",Sl)),!m.anchor&&!m.tag&&!p){u=m.end,m.comment&&(c.comment?c.comment+=`+`+m.comment:c.comment=m.comment);continue}(m.newlineAfterProp||ut(f))&&o(f??l[l.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else m.found?.indent!==r.indent&&o(a,"BAD_INDENT",Sl);n.atKey=!0;let b=m.end,_=f?e(n,f,m,o):t(n,b,l,null,m,o);n.schema.compat&&kn(r.indent,f,o),n.atKey=!1,Mr(n,c.items,_)&&o(b,"DUPLICATE_KEY","Map keys must be unique");let x=Ze(p??[],{indicator:"map-value-ind",next:y,offset:_.range[2],onError:o,parentIndent:r.indent,startOnNewline:!f||f.type==="block-scalar"});if(a=x.end,x.found){h&&(y?.type==="block-map"&&!x.hasNewline&&o(a,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<x.found.offset-1024&&o(_.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let w=y?e(n,y,x,o):t(n,a,p,null,x,o);n.schema.compat&&kn(r.indent,y,o),a=w.range[2];let S=new J(_,w);n.options.keepSourceTokens&&(S.srcToken=d),c.items.push(S)}else{h&&o(_.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),x.comment&&(_.comment?_.comment+=`+`+x.comment:_.comment=x.comment);let w=new J(_);n.options.keepSourceTokens&&(w.srcToken=d),c.items.push(w)}}return u&&u<a&&o(u,"IMPOSSIBLE","Map comment with trailing content"),c.range=[r.offset,a,u??a],c}function kl({composeNode:e,composeEmptyNode:t},n,r,o,s){let i=s?.nodeClass??X,c=new i(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let a=r.offset,u=null;for(let{start:d,value:l}of r.items){let f=Ze(d,{indicator:"seq-item-ind",next:l,offset:a,onError:o,parentIndent:r.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||l)l?.type==="block-seq"?o(f.end,"BAD_INDENT","All sequence items must start at the same column"):o(a,"MISSING_CHAR","Sequence item without - indicator");else{u=f.end,f.comment&&(c.comment=f.comment);continue}let p=l?e(n,l,f,o):t(n,f.end,d,null,f,o);n.schema.compat&&kn(r.indent,l,o),a=p.range[2],c.items.push(p)}return c.range=[r.offset,a,u??a],c}function Fe(e,t,n,r){let o="";if(e){let s=!1,i="";for(let c of e){let{source:a,type:u}=c;switch(u){case"space":s=!0;break;case"comment":{n&&!s&&r(c,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let d=a.substring(1)||" ";o?o+=i+d:o=d,i="";break}case"newline":o&&(i+=a),s=!0;break;default:r(c,"UNEXPECTED_TOKEN",`Unexpected ${u} at node end`)}t+=a.length}}return{comment:o,offset:t}}var as="Block collections are not allowed within flow collections",us=e=>e&&(e.type==="block-map"||e.type==="block-seq");function Al({composeNode:e,composeEmptyNode:t},n,r,o,s){let i=r.start.source==="{",c=i?"flow map":"flow sequence",a=s?.nodeClass??(i?G:X),u=new a(n.schema);u.flow=!0;let d=n.atRoot;d&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let l=r.offset+r.start.source.length;for(let h=0;h<r.items.length;++h){let b=r.items[h],{start:_,key:x,sep:w,value:S}=b,k=Ze(_,{flow:c,indicator:"explicit-key-ind",next:x??w?.[0],offset:l,onError:o,parentIndent:r.indent,startOnNewline:!1});if(!k.found){if(!k.anchor&&!k.tag&&!w&&!S){h===0&&k.comma?o(k.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${c}`):h<r.items.length-1&&o(k.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${c}`),k.comment&&(u.comment?u.comment+=`+`+k.comment:u.comment=k.comment),l=k.end;continue}!i&&n.options.strict&&ut(x)&&o(x,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(h===0)k.comma&&o(k.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${c}`);else if(k.comma||o(k.start,"MISSING_CHAR",`Missing , between ${c} items`),k.comment){let $="";e:for(let E of _)switch(E.type){case"comma":case"space":break;case"comment":$=E.source.substring(1);break e;default:break e}if($){let E=u.items[u.items.length-1];N(E)&&(E=E.value??E.key),E.comment?E.comment+=`+`+$:E.comment=$,k.comment=k.comment.substring($.length+1)}}if(!i&&!w&&!k.found){let $=S?e(n,S,k,o):t(n,k.end,w,null,k,o);u.items.push($),l=$.range[2],us(S)&&o($.range,"BLOCK_IN_FLOW",as)}else{n.atKey=!0;let $=k.end,E=x?e(n,x,k,o):t(n,$,_,null,k,o);us(x)&&o(E.range,"BLOCK_IN_FLOW",as),n.atKey=!1;let U=Ze(w??[],{flow:c,indicator:"map-value-ind",next:S,offset:E.range[2],onError:o,parentIndent:r.indent,startOnNewline:!1});if(U.found){if(!i&&!k.found&&n.options.strict){if(w)for(let q of w){if(q===U.found)break;if(q.type==="newline"){o(q,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}k.start<U.found.offset-1024&&o(U.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else S&&("source"in S&&S.source?.[0]===":"?o(S,"MISSING_CHAR",`Missing space after : in ${c}`):o(U.start,"MISSING_CHAR",`Missing , or : between ${c} items`));let Ie=S?e(n,S,U,o):U.found?t(n,U.end,w,null,U,o):null;Ie?us(S)&&o(Ie.range,"BLOCK_IN_FLOW",as):U.comment&&(E.comment?E.comment+=`+`+U.comment:E.comment=U.comment);let wt=new J(E,Ie);if(n.options.keepSourceTokens&&(wt.srcToken=b),i){let q=u;Mr(n,q.items,E)&&o($,"DUPLICATE_KEY","Map keys must be unique"),q.items.push(wt)}else{let q=new G(n.schema);q.flow=!0,q.items.push(wt);let Ds=(Ie??E).range;q.range=[E.range[0],Ds[1],Ds[2]],u.items.push(q)}l=Ie?Ie.range[2]:U.end}}let f=i?"}":"]",[p,...y]=r.end,m=l;if(p?.source===f)m=p.offset+p.source.length;else{let h=c[0].toUpperCase()+c.substring(1),b=d?`${h} must end with a ${f}`:`${h} in block collection must be sufficiently indented and end with a ${f}`;o(l,d?"MISSING_CHAR":"BAD_INDENT",b),p&&p.source.length!==1&&y.unshift(p)}if(y.length>0){let h=Fe(y,m,n.options.strict,o);h.comment&&(u.comment?u.comment+=`+`+h.comment:u.comment=h.comment),u.range=[r.offset,m,h.offset]}else u.range=[r.offset,m,m];return u}function ls(e,t,n,r,o,s){let i=n.type==="block-map"?vl(e,t,n,r,s):n.type==="block-seq"?kl(e,t,n,r,s):Al(e,t,n,r,s),c=i.constructor;return o==="!"||o===c.tagName?(i.tag=c.tagName,i):(o&&(i.tag=o),i)}function Dl(e,t,n,r,o){let s=r.tag,i=s?t.directives.tagName(s.source,f=>o(s,"TAG_RESOLVE_FAILED",f)):null;if(n.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=r,y=f&&s?f.offset>s.offset?f:s:f??s;y&&(!p||p.offset<y.offset)&&o(y,"MISSING_CHAR","Missing newline after block sequence props")}let c=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!s||!i||i==="!"||i===G.tagName&&c==="map"||i===X.tagName&&c==="seq")return ls(e,t,n,o,i);let a=t.schema.tags.find(f=>f.tag===i&&f.collection===c);if(!a){let f=t.schema.knownTags[i];if(f?.collection===c)t.schema.tags.push(Object.assign({},f,{default:!1})),a=f;else return f?o(s,"BAD_COLLECTION_TYPE",`${f.tag} used for ${c} collection, but expects ${f.collection??"scalar"}`,!0):o(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0),ls(e,t,n,o,i)}let u=ls(e,t,n,o,i,a),d=a.resolve?.(u,f=>o(s,"TAG_RESOLVE_FAILED",f),t.options)??u,l=T(d)?d:new A(d);return l.range=u.range,l.tag=i,a?.format&&(l.format=a.format),l}function fs(e,t,n){let r=t.offset,o=hm(t,e.options.strict,n);if(!o)return{value:"",type:null,comment:"",range:[r,r,r]};let s=o.mode===">"?A.BLOCK_FOLDED:A.BLOCK_LITERAL,i=t.source?ym(t.source):[],c=i.length;for(let m=i.length-1;m>=0;--m){let h=i[m][1];if(h===""||h==="\r")c=m;else break}if(c===0){let m=o.chomp==="+"&&i.length>0?``.repeat(Math.max(1,i.length-1)):"",h=r+o.length;return t.source&&(h+=t.source.length),{value:m,type:s,comment:o.comment,range:[r,h,h]}}let a=t.indent+o.indent,u=t.offset+o.length,d=0;for(let m=0;m<c;++m){let[h,b]=i[m];if(b===""||b==="\r")o.indent===0&&h.length>a&&(a=h.length);else{h.length<a&&n(u+h.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),o.indent===0&&(a=h.length),d=m,a===0&&!e.atRoot&&n(u,"BAD_INDENT","Block scalar values in collections must be indented");break}u+=h.length+b.length+1}for(let m=i.length-1;m>=c;--m)i[m][0].length>a&&(c=m+1);let l="",f="",p=!1;for(let m=0;m<d;++m)l+=i[m][0].slice(a)+``;for(let m=d;m<c;++m){let[h,b]=i[m];u+=h.length+b.length+1;let _=b[b.length-1]==="\r";if(_&&(b=b.slice(0,-1)),b&&h.length<a){let w=`Block scalar lines must not be less indented than their ${o.indent?"explicit indentation indicator":"first line"}`;n(u-b.length-(_?2:1),"BAD_INDENT",w),h=""}s===A.BLOCK_LITERAL?(l+=f+h.slice(a)+b,f=``):h.length>a||b[0]===" "?(f===" "?f=`@@ -144,51 +144,51 @@ ${u}`+i[m][0].slice(a);l[l.length-1]!==``&&(l+=``);break;default:l+=`-`}let y=r+o.length+t.source.length;return{value:l,type:s,comment:o.comment,range:[r,y,y]}}function dm({offset:e,props:t},n,r){if(t[0].type!=="block-scalar-header")return r(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:o}=t[0],s=o[0],i=0,c="",a=-1;for(let f=1;f<o.length;++f){let p=o[f];if(!c&&(p==="-"||p==="+"))c=p;else{let y=Number(p);!i&&y?i=y:a===-1&&(a=e+f)}}a!==-1&&r(a,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${o}`);let u=!1,d="",l=o.length;for(let f=1;f<t.length;++f){let p=t[f];switch(p.type){case"space":u=!0;case"newline":l+=p.source.length;break;case"comment":n&&!u&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),l+=p.source.length,d=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),l+=p.source.length;break;default:{let y=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",y);let m=p.source;m&&typeof m=="string"&&(l+=m.length)}}}return{mode:s,indent:i,chomp:c,comment:d,length:l}}function pm(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),s=[r?.[1]?[r[1],n.slice(r[1].length)]:["",n]];for(let i=1;i<t.length;i+=2)s.push([t[i],t[i+1]]);return s}function fs(e,t,n){let{offset:r,type:o,source:s,end:i}=e,c,a,u=(f,p,y)=>n(r+f,p,y);switch(o){case"scalar":c=A.PLAIN,a=mm(s,u);break;case"single-quoted-scalar":c=A.QUOTE_SINGLE,a=hm(s,u);break;case"double-quoted-scalar":c=A.QUOTE_DOUBLE,a=ym(s,u);break;default:return n(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${o}`),{value:"",type:null,comment:"",range:[r,r+s.length,r+s.length]}}let d=r+s.length,l=Ze(i,d,t,n);return{value:a,type:c,comment:l.comment,range:[r,d,l.offset]}}function mm(e,t){let n="";switch(e[0]){case" ":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${e[0]}`;break}case"@":case"`":{n=`reserved character ${e[0]}`;break}}return n&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),vl(e)}function hm(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),vl(e.slice(1,-1)).replace(/''/g,"'")}function vl(e){let t,n;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?+`}let y=r+o.length+t.source.length;return{value:l,type:s,comment:o.comment,range:[r,y,y]}}function hm({offset:e,props:t},n,r){if(t[0].type!=="block-scalar-header")return r(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:o}=t[0],s=o[0],i=0,c="",a=-1;for(let f=1;f<o.length;++f){let p=o[f];if(!c&&(p==="-"||p==="+"))c=p;else{let y=Number(p);!i&&y?i=y:a===-1&&(a=e+f)}}a!==-1&&r(a,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${o}`);let u=!1,d="",l=o.length;for(let f=1;f<t.length;++f){let p=t[f];switch(p.type){case"space":u=!0;case"newline":l+=p.source.length;break;case"comment":n&&!u&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),l+=p.source.length,d=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),l+=p.source.length;break;default:{let y=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",y);let m=p.source;m&&typeof m=="string"&&(l+=m.length)}}}return{mode:s,indent:i,chomp:c,comment:d,length:l}}function ym(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),s=[r?.[1]?[r[1],n.slice(r[1].length)]:["",n]];for(let i=1;i<t.length;i+=2)s.push([t[i],t[i+1]]);return s}function ds(e,t,n){let{offset:r,type:o,source:s,end:i}=e,c,a,u=(f,p,y)=>n(r+f,p,y);switch(o){case"scalar":c=A.PLAIN,a=gm(s,u);break;case"single-quoted-scalar":c=A.QUOTE_SINGLE,a=bm(s,u);break;case"double-quoted-scalar":c=A.QUOTE_DOUBLE,a=wm(s,u);break;default:return n(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${o}`),{value:"",type:null,comment:"",range:[r,r+s.length,r+s.length]}}let d=r+s.length,l=Fe(i,d,t,n);return{value:a,type:c,comment:l.comment,range:[r,d,l.offset]}}function gm(e,t){let n="";switch(e[0]){case" ":n="a tab character";break;case",":n="flow indicator character ,";break;case"%":n="directive indicator character %";break;case"|":case">":{n=`block scalar indicator ${e[0]}`;break}case"@":case"`":{n=`reserved character ${e[0]}`;break}}return n&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),Il(e)}function bm(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),Il(e.slice(1,-1)).replace(/''/g,"'")}function Il(e){let t,n;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?`,"sy"),n=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?`,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=t.exec(e);if(!r)return e;let o=r[1],s=" ",i=t.lastIndex;for(n.lastIndex=i;r=n.exec(e);)r[1]===""?s===``?o+=s:s=`-`:(o+=s+r[1],s=" "),i=n.lastIndex;let c=/[ \t]*(.*)/sy;return c.lastIndex=i,r=c.exec(e),o+s+(r?.[1]??"")}function ym(e,t){let n="";for(let r=1;r<e.length-1;++r){let o=e[r];if(!(o==="\r"&&e[r+1]===`+`:(o+=s+r[1],s=" "),i=n.lastIndex;let c=/[ \t]*(.*)/sy;return c.lastIndex=i,r=c.exec(e),o+s+(r?.[1]??"")}function wm(e,t){let n="";for(let r=1;r<e.length-1;++r){let o=e[r];if(!(o==="\r"&&e[r+1]===``))if(o===`-`){let{fold:s,offset:i}=gm(e,r);n+=s,r=i}else if(o==="\\"){let s=e[++r],i=bm[s];if(i)n+=i;else if(s===`+`){let{fold:s,offset:i}=_m(e,r);n+=s,r=i}else if(o==="\\"){let s=e[++r],i=xm[s];if(i)n+=i;else if(s===``)for(s=e[r+1];s===" "||s===" ";)s=e[++r+1];else if(s==="\r"&&e[r+1]===`-`)for(s=e[++r+1];s===" "||s===" ";)s=e[++r+1];else if(s==="x"||s==="u"||s==="U"){let c=s==="x"?2:s==="u"?4:8;n+=wm(e,r+1,c,t),r+=c}else{let c=e.substr(r-1,2);t(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${c}`),n+=c}}else if(o===" "||o===" "){let s=r,i=e[r+1];for(;i===" "||i===" ";)i=e[++r+1];i!==`+`)for(s=e[++r+1];s===" "||s===" ";)s=e[++r+1];else if(s==="x"||s==="u"||s==="U"){let c=s==="x"?2:s==="u"?4:8;n+=Em(e,r+1,c,t),r+=c}else{let c=e.substr(r-1,2);t(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${c}`),n+=c}}else if(o===" "||o===" "){let s=r,i=e[r+1];for(;i===" "||i===" ";)i=e[++r+1];i!==``&&!(i==="\r"&&e[r+2]===`-`)&&(n+=r>s?e.slice(s,r+1):o)}else n+=o}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),n}function gm(e,t){let n="",r=e[t+1];for(;(r===" "||r===" "||r===`+`)&&(n+=r>s?e.slice(s,r+1):o)}else n+=o}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),n}function _m(e,t){let n="",r=e[t+1];for(;(r===" "||r===" "||r===``||r==="\r")&&!(r==="\r"&&e[t+2]!==``);)r===``&&(n+=`-`),t+=1,r=e[t+1];return n||(n=" "),{fold:n,offset:t}}var bm={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`-`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function wm(e,t,n,r){let o=e.substr(t,n),i=o.length===n&&/^[0-9a-fA-F]+$/.test(o)?parseInt(o,16):NaN;try{return String.fromCodePoint(i)}catch{let c=e.substr(t-2,n+2);return r(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${c}`),c}}function ds(e,t,n,r){let{value:o,type:s,comment:i,range:c}=t.type==="block-scalar"?ls(e,t,r):fs(t,e.options.strict,r),a=n?e.directives.tagName(n.source,l=>r(n,"TAG_RESOLVE_FAILED",l)):null,u;e.options.stringKeys&&e.atKey?u=e.schema[le]:a?u=_m(e.schema,o,a,n,r):t.type==="scalar"?u=xm(e,o,t,r):u=e.schema[le];let d;try{let l=u.resolve(o,f=>r(n??t,"TAG_RESOLVE_FAILED",f),e.options);d=R(l)?l:new A(l)}catch(l){let f=l instanceof Error?l.message:String(l);r(n??t,"TAG_RESOLVE_FAILED",f),d=new A(o)}return d.range=c,d.source=o,s&&(d.type=s),a&&(d.tag=a),u.format&&(d.format=u.format),i&&(d.comment=i),d}function _m(e,t,n,r,o){if(n==="!")return e[le];let s=[];for(let c of e.tags)if(!c.collection&&c.tag===n)if(c.default&&c.test)s.push(c);else return c;for(let c of s)if(c.test?.test(t))return c;let i=e.knownTags[n];return i&&!i.collection?(e.tags.push(Object.assign({},i,{default:!1,test:void 0})),i):(o(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),e[le])}function xm({atKey:e,directives:t,schema:n},r,o,s){let i=n.tags.find(c=>(c.default===!0||e&&c.default==="key")&&c.test?.test(r))||n[le];if(n.compat){let c=n.compat.find(a=>a.default&&a.test?.test(r))??n[le];if(i.tag!==c.tag){let a=t.tagString(i.tag),u=t.tagString(c.tag),d=`Value may be parsed as either ${a} or ${u}`;s(o,"TAG_RESOLVE_FAILED",d,!0)}}return i}function kl(e,t,n){if(t){n??(n=t.length);for(let r=n-1;r>=0;--r){let o=t[r];switch(o.type){case"space":case"comment":case"newline":e-=o.source.length;continue}for(o=t[++r];o?.type==="space";)e+=o.source.length,o=t[++r];break}}return e}var Em={composeNode:ps,composeEmptyNode:Mr};function ps(e,t,n,r){let o=e.atKey,{spaceBefore:s,comment:i,anchor:c,tag:a}=n,u,d=!0;switch(t.type){case"alias":u=Sm(e,t,r),(c||a)&&r(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":u=ds(e,t,a,r),c&&(u.anchor=c.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=Sl(Em,e,t,n,r),c&&(u.anchor=c.source.substring(1))}catch(l){let f=l instanceof Error?l.message:String(l);r(t,"RESOURCE_EXHAUSTION",f)}break;default:{let l=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;r(t,"UNEXPECTED_TOKEN",l),d=!1}}return u??(u=Mr(e,t.offset,void 0,null,n,r)),c&&u.anchor===""&&r(c,"BAD_ALIAS","Anchor cannot be an empty string"),o&&e.options.stringKeys&&(!R(u)||typeof u.value!="string"||u.tag&&u.tag!=="tag:yaml.org,2002:str")&&r(a??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),s&&(u.spaceBefore=!0),i&&(t.type==="scalar"&&t.source===""?u.comment=i:u.commentBefore=i),e.options.keepSourceTokens&&d&&(u.srcToken=t),u}function Mr(e,t,n,r,{spaceBefore:o,comment:s,anchor:i,tag:c,end:a},u){let d={type:"scalar",offset:kl(t,n,r),indent:-1,source:""},l=ds(e,d,c,u);return i&&(l.anchor=i.source.substring(1),l.anchor===""&&u(i,"BAD_ALIAS","Anchor cannot be an empty string")),o&&(l.spaceBefore=!0),s&&(l.comment=s,l.range[2]=a),l}function Sm({options:e},{offset:t,source:n,end:r},o){let s=new Qe(n.substring(1));s.source===""&&o(t,"BAD_ALIAS","Alias cannot be an empty string"),s.source.endsWith(":")&&o(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let i=t+n.length,c=Ze(r,i,e.strict,o);return s.range=[t,i,c.offset],c.comment&&(s.comment=c.comment),s}function Al(e,t,{offset:n,start:r,value:o,end:s},i){let c=Object.assign({_directives:t},e),a=new at(void 0,c),u={atKey:!1,atRoot:!0,directives:a.directives,options:a.options,schema:a.schema},d=Me(r,{indicator:"doc-start",next:o??s?.[0],offset:n,onError:i,parentIndent:0,startOnNewline:!0});d.found&&(a.directives.docStart=!0,o&&(o.type==="block-map"||o.type==="block-seq")&&!d.hasNewline&&i(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),a.contents=o?ps(u,o,d,i):Mr(u,d.end,r,null,d,i);let l=a.contents.range[2],f=Ze(s,l,!1,i);return f.comment&&(a.comment=f.comment),a.range=[n,l,f.offset],a}function kn(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n=="string"?n.length:1)]}function Dl(e){let t="",n=!1,r=!1;for(let o=0;o<e.length;++o){let s=e[o];switch(s[0]){case"#":t+=(t===""?"":r?`+`),t+=1,r=e[t+1];return n||(n=" "),{fold:n,offset:t}}var xm={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`+`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Em(e,t,n,r){let o=e.substr(t,n),i=o.length===n&&/^[0-9a-fA-F]+$/.test(o)?parseInt(o,16):NaN;try{return String.fromCodePoint(i)}catch{let c=e.substr(t-2,n+2);return r(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${c}`),c}}function ps(e,t,n,r){let{value:o,type:s,comment:i,range:c}=t.type==="block-scalar"?fs(e,t,r):ds(t,e.options.strict,r),a=n?e.directives.tagName(n.source,l=>r(n,"TAG_RESOLVE_FAILED",l)):null,u;e.options.stringKeys&&e.atKey?u=e.schema[le]:a?u=Sm(e.schema,o,a,n,r):t.type==="scalar"?u=vm(e,o,t,r):u=e.schema[le];let d;try{let l=u.resolve(o,f=>r(n??t,"TAG_RESOLVE_FAILED",f),e.options);d=O(l)?l:new A(l)}catch(l){let f=l instanceof Error?l.message:String(l);r(n??t,"TAG_RESOLVE_FAILED",f),d=new A(o)}return d.range=c,d.source=o,s&&(d.type=s),a&&(d.tag=a),u.format&&(d.format=u.format),i&&(d.comment=i),d}function Sm(e,t,n,r,o){if(n==="!")return e[le];let s=[];for(let c of e.tags)if(!c.collection&&c.tag===n)if(c.default&&c.test)s.push(c);else return c;for(let c of s)if(c.test?.test(t))return c;let i=e.knownTags[n];return i&&!i.collection?(e.tags.push(Object.assign({},i,{default:!1,test:void 0})),i):(o(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${n}`,n!=="tag:yaml.org,2002:str"),e[le])}function vm({atKey:e,directives:t,schema:n},r,o,s){let i=n.tags.find(c=>(c.default===!0||e&&c.default==="key")&&c.test?.test(r))||n[le];if(n.compat){let c=n.compat.find(a=>a.default&&a.test?.test(r))??n[le];if(i.tag!==c.tag){let a=t.tagString(i.tag),u=t.tagString(c.tag),d=`Value may be parsed as either ${a} or ${u}`;s(o,"TAG_RESOLVE_FAILED",d,!0)}}return i}function Rl(e,t,n){if(t){n??(n=t.length);for(let r=n-1;r>=0;--r){let o=t[r];switch(o.type){case"space":case"comment":case"newline":e-=o.source.length;continue}for(o=t[++r];o?.type==="space";)e+=o.source.length,o=t[++r];break}}return e}var km={composeNode:ms,composeEmptyNode:Zr};function ms(e,t,n,r){let o=e.atKey,{spaceBefore:s,comment:i,anchor:c,tag:a}=n,u,d=!0;switch(t.type){case"alias":u=Am(e,t,r),(c||a)&&r(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":u=ps(e,t,a,r),c&&(u.anchor=c.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=Dl(km,e,t,n,r),c&&(u.anchor=c.source.substring(1))}catch(l){let f=l instanceof Error?l.message:String(l);r(t,"RESOURCE_EXHAUSTION",f)}break;default:{let l=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;r(t,"UNEXPECTED_TOKEN",l),d=!1}}return u??(u=Zr(e,t.offset,void 0,null,n,r)),c&&u.anchor===""&&r(c,"BAD_ALIAS","Anchor cannot be an empty string"),o&&e.options.stringKeys&&(!O(u)||typeof u.value!="string"||u.tag&&u.tag!=="tag:yaml.org,2002:str")&&r(a??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),s&&(u.spaceBefore=!0),i&&(t.type==="scalar"&&t.source===""?u.comment=i:u.commentBefore=i),e.options.keepSourceTokens&&d&&(u.srcToken=t),u}function Zr(e,t,n,r,{spaceBefore:o,comment:s,anchor:i,tag:c,end:a},u){let d={type:"scalar",offset:Rl(t,n,r),indent:-1,source:""},l=ps(e,d,c,u);return i&&(l.anchor=i.source.substring(1),l.anchor===""&&u(i,"BAD_ALIAS","Anchor cannot be an empty string")),o&&(l.spaceBefore=!0),s&&(l.comment=s,l.range[2]=a),l}function Am({options:e},{offset:t,source:n,end:r},o){let s=new Je(n.substring(1));s.source===""&&o(t,"BAD_ALIAS","Alias cannot be an empty string"),s.source.endsWith(":")&&o(t+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let i=t+n.length,c=Fe(r,i,e.strict,o);return s.range=[t,i,c.offset],c.comment&&(s.comment=c.comment),s}function Ol(e,t,{offset:n,start:r,value:o,end:s},i){let c=Object.assign({_directives:t},e),a=new at(void 0,c),u={atKey:!1,atRoot:!0,directives:a.directives,options:a.options,schema:a.schema},d=Ze(r,{indicator:"doc-start",next:o??s?.[0],offset:n,onError:i,parentIndent:0,startOnNewline:!0});d.found&&(a.directives.docStart=!0,o&&(o.type==="block-map"||o.type==="block-seq")&&!d.hasNewline&&i(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),a.contents=o?ms(u,o,d,i):Zr(u,d.end,r,null,d,i);let l=a.contents.range[2],f=Fe(s,l,!1,i);return f.comment&&(a.comment=f.comment),a.range=[n,l,f.offset],a}function An(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n=="string"?n.length:1)]}function $l(e){let t="",n=!1,r=!1;for(let o=0;o<e.length;++o){let s=e[o];switch(s[0]){case"#":t+=(t===""?"":r?``:`-`)+(s.substring(1)||" "),n=!0,r=!1;break;case"%":e[o+1]?.[0]!=="#"&&(o+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var An=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,o,s)=>{let i=kn(n);s?this.warnings.push(new Sn(i,r,o)):this.errors.push(new ve(i,r,o))},this.directives=new Pe({version:t.version||"1.2"}),this.options=t}decorate(t,n){let{comment:r,afterEmptyLine:o}=Dl(this.prelude);if(r){let s=t.contents;if(n)t.comment=t.comment?`${t.comment}+`)+(s.substring(1)||" "),n=!0,r=!1;break;case"%":e[o+1]?.[0]!=="#"&&(o+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var Dn=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,o,s)=>{let i=An(n);s?this.warnings.push(new vn(i,r,o)):this.errors.push(new ke(i,r,o))},this.directives=new Le({version:t.version||"1.2"}),this.options=t}decorate(t,n){let{comment:r,afterEmptyLine:o}=$l(this.prelude);if(r){let s=t.contents;if(n)t.comment=t.comment?`${t.comment}${r}`:r;else if(o||t.directives.docStart||!s)t.commentBefore=r;else if(L(s)&&!s.flow&&s.items.length>0){let i=s.items[0];N(i)&&(i=i.key);let c=i.commentBefore;i.commentBefore=c?`${r}${c}`:r}else{let i=s.commentBefore;s.commentBefore=i?`${r}-${i}`:r}}if(n){for(let s=0;s<this.errors.length;++s)t.errors.push(this.errors[s]);for(let s=0;s<this.warnings.length;++s)t.warnings.push(this.warnings[s])}else t.errors=this.errors,t.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Dl(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(t,n=!1,r=-1){for(let o of t)yield*this.next(o);yield*this.end(n,r)}*next(t){switch(t.type){case"directive":this.directives.add(t.source,(n,r,o)=>{let s=kn(t);s[0]+=n,this.onError(s,"BAD_DIRECTIVE",r,o)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let n=Al(this.options,this.directives,t,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(t,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(t.source);break;case"error":{let n=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,r=new ve(kn(t),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new ve(kn(t),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=Ze(t.end,t.offset+t.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){let r=this.doc.comment;this.doc.comment=r?`${r}-${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new ve(kn(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let r=Object.assign({_directives:this.directives},this.options),o=new at(void 0,r);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),o.range=[0,n,n],this.decorate(o,!1),yield o}}};var ms=Symbol("break visit"),vm=Symbol("skip children"),Il=Symbol("remove item");function gt(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),Ol(Object.freeze([]),e,t)}gt.BREAK=ms;gt.SKIP=vm;gt.REMOVE=Il;gt.itemAtPath=(e,t)=>{let n=e;for(let[r,o]of t){let s=n?.[r];if(s&&"items"in s)n=s.items[o];else return}return n};gt.parentCollection=(e,t)=>{let n=gt.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],o=n?.[r];if(o&&"items"in o)return o;throw new Error("Parent collection not found")};function Ol(e,t,n){let r=n(t,e);if(typeof r=="symbol")return r;for(let o of["key","value"]){let s=t[o];if(s&&"items"in s){for(let i=0;i<s.items.length;++i){let c=Ol(Object.freeze(e.concat([[o,i]])),s.items[i],n);if(typeof c=="number")i=c-1;else{if(c===ms)return ms;c===Il&&(s.items.splice(i,1),i-=1)}}typeof r=="function"&&o==="key"&&(r=r(t,e))}}return typeof r=="function"?r(t,e):r}var hs="\uFEFF",ys="",gs="",Zr="";function Rl(e){switch(e){case hs:return"byte-order-mark";case ys:return"doc-mode";case gs:return"flow-error-end";case Zr:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`+${i}`:r}}if(n){for(let s=0;s<this.errors.length;++s)t.errors.push(this.errors[s]);for(let s=0;s<this.warnings.length;++s)t.warnings.push(this.warnings[s])}else t.errors=this.errors,t.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:$l(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(t,n=!1,r=-1){for(let o of t)yield*this.next(o);yield*this.end(n,r)}*next(t){switch(t.type){case"directive":this.directives.add(t.source,(n,r,o)=>{let s=An(t);s[0]+=n,this.onError(s,"BAD_DIRECTIVE",r,o)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let n=Ol(this.options,this.directives,t,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(t,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(n,!1),this.doc&&(yield this.doc),this.doc=n,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(t.source);break;case"error":{let n=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,r=new ke(An(t),"UNEXPECTED_TOKEN",n);this.atDirectives||!this.doc?this.errors.push(r):this.doc.errors.push(r);break}case"doc-end":{if(!this.doc){let r="Unexpected doc-end without preceding document";this.errors.push(new ke(An(t),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=Fe(t.end,t.offset+t.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),n.comment){let r=this.doc.comment;this.doc.comment=r?`${r}+${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.push(new ke(An(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let r=Object.assign({_directives:this.directives},this.options),o=new at(void 0,r);this.atDirectives&&this.onError(n,"MISSING_CHAR","Missing directives-end indicator line"),o.range=[0,n,n],this.decorate(o,!1),yield o}}};var hs=Symbol("break visit"),Dm=Symbol("skip children"),Nl=Symbol("remove item");function gt(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),Cl(Object.freeze([]),e,t)}gt.BREAK=hs;gt.SKIP=Dm;gt.REMOVE=Nl;gt.itemAtPath=(e,t)=>{let n=e;for(let[r,o]of t){let s=n?.[r];if(s&&"items"in s)n=s.items[o];else return}return n};gt.parentCollection=(e,t)=>{let n=gt.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],o=n?.[r];if(o&&"items"in o)return o;throw new Error("Parent collection not found")};function Cl(e,t,n){let r=n(t,e);if(typeof r=="symbol")return r;for(let o of["key","value"]){let s=t[o];if(s&&"items"in s){for(let i=0;i<s.items.length;++i){let c=Cl(Object.freeze(e.concat([[o,i]])),s.items[i],n);if(typeof c=="number")i=c-1;else{if(c===hs)return hs;c===Nl&&(s.items.splice(i,1),i-=1)}}typeof r=="function"&&o==="key"&&(r=r(t,e))}}return typeof r=="function"?r(t,e):r}var ys="\uFEFF",gs="",bs="",Fr="";function Tl(e){switch(e){case ys:return"byte-order-mark";case gs:return"doc-mode";case bs:return"flow-error-end";case Fr:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case``:case`\r-`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function ke(e){switch(e){case void 0:case" ":case`-`:case"\r":case" ":return!0;default:return!1}}var $l=new Set("0123456789ABCDEFabcdef"),Am=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Fr=new Set(",[]{}"),Dm=new Set(` ,[]{}-\r `),bs=e=>!e||Dm.has(e),Dn=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(t,n=!1){if(t){if(typeof t!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+t:t,this.lineEndPos=null}this.atEnd=!n;let r=this.next??"stream";for(;r&&(n||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let t=this.pos,n=this.buffer[t];for(;n===" "||n===" ";)n=this.buffer[++t];return!n||n==="#"||n===`+`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function Ae(e){switch(e){case void 0:case" ":case`+`:case"\r":case" ":return!0;default:return!1}}var zl=new Set("0123456789ABCDEFabcdef"),Rm=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Br=new Set(",[]{}"),Om=new Set(` ,[]{}+\r `),ws=e=>!e||Om.has(e),In=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(t,n=!1){if(t){if(typeof t!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+t:t,this.lineEndPos=null}this.atEnd=!n;let r=this.next??"stream";for(;r&&(n||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let t=this.pos,n=this.buffer[t];for(;n===" "||n===" ";)n=this.buffer[++t];return!n||n==="#"||n===``?!0:n==="\r"?this.buffer[t+1]===``:!1}charAt(t){return this.buffer[this.pos+t]}continueScalar(t){let n=this.buffer[t];if(this.indentNext>0){let r=0;for(;n===" ";)n=this.buffer[++r+t];if(n==="\r"){let o=this.buffer[r+t+1];if(o===``||!o&&!this.atEnd)return t+r+1}return n===`-`||r>=this.indentNext||!n&&!this.atEnd?t+r:-1}if(n==="-"||n==="."){let r=this.buffer.substr(t,3);if((r==="---"||r==="...")&&ke(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&t<this.pos)&&(t=this.buffer.indexOf(`-`,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]===hs&&(yield*this.pushCount(1),t=t.substring(1)),t[0]==="%"){let n=t.length,r=t.indexOf("#");for(;r!==-1;){let s=t[r-1];if(s===" "||s===" "){n=r-1;break}else r=t.indexOf("#",r+1)}for(;;){let s=t[n-1];if(s===" "||s===" ")n-=1;else break}let o=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(t.length-o),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(t.length-n),yield*this.pushNewline(),"stream"}return yield ys,yield*this.parseLineStart()}*parseLineStart(){let t=this.charAt(0);if(!t&&!this.atEnd)return this.setNext("line-start");if(t==="-"||t==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&ke(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,n==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!ke(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[t,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&ke(n)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let t=this.getLine();if(t===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(t[n]){case"#":yield*this.pushCount(t.length-n);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(bs),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,n,r=-1;do t=yield*this.pushNewline(),t>0?(n=yield*this.pushSpaces(!1),this.indentValue=r=n):n=0,n+=yield*this.pushSpaces(!0);while(t+n>0);let o=this.getLine();if(o===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&o[0]!=="#"||r===0&&(o.startsWith("---")||o.startsWith("..."))&&ke(o[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(o[0]==="]"||o[0]==="}")))return this.flowLevel=0,yield gs,yield*this.parseLineStart();let s=0;for(;o[s]===",";)s+=yield*this.pushCount(1),s+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(s+=yield*this.pushIndicators(),o[s]){case void 0:return"flow";case"#":return yield*this.pushCount(o.length-s),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(bs),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let i=this.charAt(1);if(this.flowKey||ke(i)||i===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let t=this.charAt(0),n=this.buffer.indexOf(t,this.pos+1);if(t==="'")for(;n!==-1&&this.buffer[n+1]==="'";)n=this.buffer.indexOf("'",n+2);else for(;n!==-1;){let s=0;for(;this.buffer[n-1-s]==="\\";)s+=1;if(s%2===0)break;n=this.buffer.indexOf('"',n+1)}let r=this.buffer.substring(0,n),o=r.indexOf(`+`||r>=this.indentNext||!n&&!this.atEnd?t+r:-1}if(n==="-"||n==="."){let r=this.buffer.substr(t,3);if((r==="---"||r==="...")&&Ae(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&t<this.pos)&&(t=this.buffer.indexOf(`+`,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]===ys&&(yield*this.pushCount(1),t=t.substring(1)),t[0]==="%"){let n=t.length,r=t.indexOf("#");for(;r!==-1;){let s=t[r-1];if(s===" "||s===" "){n=r-1;break}else r=t.indexOf("#",r+1)}for(;;){let s=t[n-1];if(s===" "||s===" ")n-=1;else break}let o=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(t.length-o),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(t.length-n),yield*this.pushNewline(),"stream"}return yield gs,yield*this.parseLineStart()}*parseLineStart(){let t=this.charAt(0);if(!t&&!this.atEnd)return this.setNext("line-start");if(t==="-"||t==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&Ae(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,n==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Ae(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[t,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&Ae(n)){let r=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=r,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let t=this.getLine();if(t===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(t[n]){case"#":yield*this.pushCount(t.length-n);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(ws),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,n,r=-1;do t=yield*this.pushNewline(),t>0?(n=yield*this.pushSpaces(!1),this.indentValue=r=n):n=0,n+=yield*this.pushSpaces(!0);while(t+n>0);let o=this.getLine();if(o===null)return this.setNext("flow");if((r!==-1&&r<this.indentNext&&o[0]!=="#"||r===0&&(o.startsWith("---")||o.startsWith("..."))&&Ae(o[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(o[0]==="]"||o[0]==="}")))return this.flowLevel=0,yield bs,yield*this.parseLineStart();let s=0;for(;o[s]===",";)s+=yield*this.pushCount(1),s+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(s+=yield*this.pushIndicators(),o[s]){case void 0:return"flow";case"#":return yield*this.pushCount(o.length-s),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(ws),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let i=this.charAt(1);if(this.flowKey||Ae(i)||i===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let t=this.charAt(0),n=this.buffer.indexOf(t,this.pos+1);if(t==="'")for(;n!==-1&&this.buffer[n+1]==="'";)n=this.buffer.indexOf("'",n+2);else for(;n!==-1;){let s=0;for(;this.buffer[n-1-s]==="\\";)s+=1;if(s%2===0)break;n=this.buffer.indexOf('"',n+1)}let r=this.buffer.substring(0,n),o=r.indexOf(``,this.pos);if(o!==-1){for(;o!==-1;){let s=this.continueScalar(o+1);if(s===-1)break;o=r.indexOf(`-`,s)}o!==-1&&(n=o-(r[o-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let t=this.pos;for(;;){let n=this.buffer[++t];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>ke(n)||n==="#")}*parseBlockScalar(){let t=this.pos-1,n=0,r;e:for(let s=this.pos;r=this.buffer[s];++s)switch(r){case" ":n+=1;break;case`+`,s)}o!==-1&&(n=o-(r[o-1]==="\r"?2:1))}if(n===-1){if(!this.atEnd)return this.setNext("quoted-scalar");n=this.buffer.length}return yield*this.pushToIndex(n+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let t=this.pos;for(;;){let n=this.buffer[++t];if(n==="+")this.blockScalarKeep=!0;else if(n>"0"&&n<="9")this.blockScalarIndent=Number(n)-1;else if(n!=="-")break}return yield*this.pushUntil(n=>Ae(n)||n==="#")}*parseBlockScalar(){let t=this.pos-1,n=0,r;e:for(let s=this.pos;r=this.buffer[s];++s)switch(r){case" ":n+=1;break;case``:t=s,n=0;break;case"\r":{let i=this.buffer[s+1];if(!i&&!this.atEnd)return this.setNext("block-scalar");if(i===``)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(n>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=n:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let s=this.continueScalar(t+1);if(s===-1)break;t=this.buffer.indexOf(``,s)}while(t!==-1);if(t===-1){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let o=t+1;for(r=this.buffer[o];r===" ";)r=this.buffer[++o];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===``;)r=this.buffer[++o];t=o-1}else if(!this.blockScalarKeep)do{let s=t-1,i=this.buffer[s];i==="\r"&&(i=this.buffer[--s]);let c=s;for(;i===" ";)i=this.buffer[--s];if(i===`-`&&s>=this.pos&&s+1+n>c)t=s;else break}while(!0);return yield Zr,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=this.flowLevel>0,n=this.pos-1,r=this.pos-1,o;for(;o=this.buffer[++r];)if(o===":"){let s=this.buffer[r+1];if(ke(s)||t&&Fr.has(s))break;n=r}else if(ke(o)){let s=this.buffer[r+1];if(o==="\r"&&(s===`+`&&s>=this.pos&&s+1+n>c)t=s;else break}while(!0);return yield Fr,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=this.flowLevel>0,n=this.pos-1,r=this.pos-1,o;for(;o=this.buffer[++r];)if(o===":"){let s=this.buffer[r+1];if(Ae(s)||t&&Br.has(s))break;n=r}else if(Ae(o)){let s=this.buffer[r+1];if(o==="\r"&&(s===``?(r+=1,o=`-`,s=this.buffer[r+1]):n=r),s==="#"||t&&Fr.has(s))break;if(o===`-`){let i=this.continueScalar(r+1);if(i===-1)break;r=Math.max(r,i-2)}}else{if(t&&Fr.has(o))break;n=r}return!o&&!this.atEnd?this.setNext("plain-scalar"):(yield Zr,yield*this.pushToIndex(n+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,n){let r=this.buffer.slice(this.pos,t);return r?(yield r,this.pos+=r.length,r.length):(n&&(yield""),0)}*pushIndicators(){let t=0;e:for(;;){switch(this.charAt(0)){case"!":t+=yield*this.pushTag(),t+=yield*this.pushSpaces(!0);continue e;case"&":t+=yield*this.pushUntil(bs),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let n=this.flowLevel>0,r=this.charAt(1);if(ke(r)||n&&Fr.has(r)){n?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,t+=yield*this.pushCount(1),t+=yield*this.pushSpaces(!0);continue e}}}break e}return t}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,n=this.buffer[t];for(;!ke(n)&&n!==">";)n=this.buffer[++t];return yield*this.pushToIndex(n===">"?t+1:t,!1)}else{let t=this.pos+1,n=this.buffer[t];for(;n;)if(Am.has(n))n=this.buffer[++t];else if(n==="%"&&$l.has(this.buffer[t+1])&&$l.has(this.buffer[t+2]))n=this.buffer[t+=3];else break;return yield*this.pushToIndex(t,!1)}}*pushNewline(){let t=this.buffer[this.pos];return t===`+`,s=this.buffer[r+1]):n=r),s==="#"||t&&Br.has(s))break;if(o===`+`){let i=this.continueScalar(r+1);if(i===-1)break;r=Math.max(r,i-2)}}else{if(t&&Br.has(o))break;n=r}return!o&&!this.atEnd?this.setNext("plain-scalar"):(yield Fr,yield*this.pushToIndex(n+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,n){let r=this.buffer.slice(this.pos,t);return r?(yield r,this.pos+=r.length,r.length):(n&&(yield""),0)}*pushIndicators(){let t=0;e:for(;;){switch(this.charAt(0)){case"!":t+=yield*this.pushTag(),t+=yield*this.pushSpaces(!0);continue e;case"&":t+=yield*this.pushUntil(ws),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let n=this.flowLevel>0,r=this.charAt(1);if(Ae(r)||n&&Br.has(r)){n?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,t+=yield*this.pushCount(1),t+=yield*this.pushSpaces(!0);continue e}}}break e}return t}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,n=this.buffer[t];for(;!Ae(n)&&n!==">";)n=this.buffer[++t];return yield*this.pushToIndex(n===">"?t+1:t,!1)}else{let t=this.pos+1,n=this.buffer[t];for(;n;)if(Rm.has(n))n=this.buffer[++t];else if(n==="%"&&zl.has(this.buffer[t+1])&&zl.has(this.buffer[t+2]))n=this.buffer[t+=3];else break;return yield*this.pushToIndex(t,!1)}}*pushNewline(){let t=this.buffer[this.pos];return t===``?yield*this.pushCount(1):t==="\r"&&this.charAt(1)===`-`?yield*this.pushCount(2):0}*pushSpaces(t){let n=this.pos-1,r;do r=this.buffer[++n];while(r===" "||t&&r===" ");let o=n-this.pos;return o>0&&(yield this.buffer.substr(this.pos,o),this.pos=n),o}*pushUntil(t){let n=this.pos,r=this.buffer[n];for(;!t(r);)r=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};var In=class{constructor(){this.lineStarts=[],this.addNewLine=t=>this.lineStarts.push(t),this.linePos=t=>{let n=0,r=this.lineStarts.length;for(;n<r;){let s=n+r>>1;this.lineStarts[s]<t?n=s+1:r=s}if(this.lineStarts[n]===t)return{line:n+1,col:1};if(n===0)return{line:0,col:t};let o=this.lineStarts[n-1];return{line:n,col:t-o+1}}}};function lt(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function Nl(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function Tl(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Br(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function Ut(e){if(e.length===0)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function jr(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function Cl(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!lt(t.start,"explicit-key-ind")&&!lt(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,Tl(t.value)?t.value.end?jr(t.value.end,t.sep):t.value.end=t.sep:jr(t.start,t.sep),delete t.sep)}var On=class{constructor(t){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Dn,this.onNewLine=t}*parse(t,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(t,n))yield*this.next(r);n||(yield*this.end())}*next(t){if(this.source=t,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let n=Rl(t);if(n)if(n==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=n,yield*this.step(),n){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+t.length);break;case"space":this.atNewLine&&t[0]===" "&&(this.indent+=t.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=t.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=t.length}else{let r=`Not a YAML token: ${t}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:t}),this.offset+=t.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let t=this.peek(1);if(this.type==="doc-end"&&t?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!t)return yield*this.stream();switch(t.type){case"document":return yield*this.document(t);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(t);case"block-scalar":return yield*this.blockScalar(t);case"block-map":return yield*this.blockMap(t);case"block-seq":return yield*this.blockSequence(t);case"flow-collection":return yield*this.flowCollection(t);case"doc-end":return yield*this.documentEnd(t)}yield*this.pop()}peek(t){return this.stack[this.stack.length-t]}*pop(t){let n=t??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{let r=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in r?r.indent:0:n.type==="flow-collection"&&r.type==="document"&&(n.indent=0),n.type==="flow-collection"&&Cl(n),r.type){case"document":r.value=n;break;case"block-scalar":r.props.push(n);break;case"block-map":{let o=r.items[r.items.length-1];if(o.value){r.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(o.sep)o.value=n;else{Object.assign(o,{key:n,sep:[]}),this.onKeyLine=!o.explicitKey;return}break}case"block-seq":{let o=r.items[r.items.length-1];o.value?r.items.push({start:[],value:n}):o.value=n;break}case"flow-collection":{let o=r.items[r.items.length-1];!o||o.value?r.items.push({start:[],key:n,sep:[]}):o.sep?o.value=n:Object.assign(o,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){let o=n.items[n.items.length-1];o&&!o.sep&&!o.value&&o.start.length>0&&Nl(o.start)===-1&&(n.indent===0||o.start.every(s=>s.type!=="comment"||s.indent<n.indent))&&(r.type==="document"?r.end=o.start:r.items.push({start:o.start}),n.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let t={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&t.start.push(this.sourceToken),this.stack.push(t);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(t){if(t.value)return yield*this.lineEnd(t);switch(this.type){case"doc-start":{Nl(t.start)!==-1?(yield*this.pop(),yield*this.step()):t.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":t.start.push(this.sourceToken);return}let n=this.startBlockValue(t);n?this.stack.push(n):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(t){if(this.type==="map-value-ind"){let n=Br(this.peek(2)),r=Ut(n),o;t.end?(o=t.end,o.push(this.sourceToken),delete t.end):o=[this.sourceToken];let s={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:r,key:t,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(t)}*blockScalar(t){switch(this.type){case"space":case"comment":case"newline":t.props.push(this.sourceToken);return;case"scalar":if(t.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let n=this.source.indexOf(`+`?yield*this.pushCount(2):0}*pushSpaces(t){let n=this.pos-1,r;do r=this.buffer[++n];while(r===" "||t&&r===" ");let o=n-this.pos;return o>0&&(yield this.buffer.substr(this.pos,o),this.pos=n),o}*pushUntil(t){let n=this.pos,r=this.buffer[n];for(;!t(r);)r=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};var Rn=class{constructor(){this.lineStarts=[],this.addNewLine=t=>this.lineStarts.push(t),this.linePos=t=>{let n=0,r=this.lineStarts.length;for(;n<r;){let s=n+r>>1;this.lineStarts[s]<t?n=s+1:r=s}if(this.lineStarts[n]===t)return{line:n+1,col:1};if(n===0)return{line:0,col:t};let o=this.lineStarts[n-1];return{line:n,col:t-o+1}}}};function lt(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function Pl(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function Ml(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function jr(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function Ut(e){if(e.length===0)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function Ur(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function Ll(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!lt(t.start,"explicit-key-ind")&&!lt(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,Ml(t.value)?t.value.end?Ur(t.value.end,t.sep):t.value.end=t.sep:Ur(t.start,t.sep),delete t.sep)}var On=class{constructor(t){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new In,this.onNewLine=t}*parse(t,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(t,n))yield*this.next(r);n||(yield*this.end())}*next(t){if(this.source=t,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let n=Tl(t);if(n)if(n==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=n,yield*this.step(),n){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+t.length);break;case"space":this.atNewLine&&t[0]===" "&&(this.indent+=t.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=t.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=t.length}else{let r=`Not a YAML token: ${t}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:t}),this.offset+=t.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let t=this.peek(1);if(this.type==="doc-end"&&t?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!t)return yield*this.stream();switch(t.type){case"document":return yield*this.document(t);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(t);case"block-scalar":return yield*this.blockScalar(t);case"block-map":return yield*this.blockMap(t);case"block-seq":return yield*this.blockSequence(t);case"flow-collection":return yield*this.flowCollection(t);case"doc-end":return yield*this.documentEnd(t)}yield*this.pop()}peek(t){return this.stack[this.stack.length-t]}*pop(t){let n=t??this.stack.pop();if(!n)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield n;else{let r=this.peek(1);switch(n.type==="block-scalar"?n.indent="indent"in r?r.indent:0:n.type==="flow-collection"&&r.type==="document"&&(n.indent=0),n.type==="flow-collection"&&Ll(n),r.type){case"document":r.value=n;break;case"block-scalar":r.props.push(n);break;case"block-map":{let o=r.items[r.items.length-1];if(o.value){r.items.push({start:[],key:n,sep:[]}),this.onKeyLine=!0;return}else if(o.sep)o.value=n;else{Object.assign(o,{key:n,sep:[]}),this.onKeyLine=!o.explicitKey;return}break}case"block-seq":{let o=r.items[r.items.length-1];o.value?r.items.push({start:[],value:n}):o.value=n;break}case"flow-collection":{let o=r.items[r.items.length-1];!o||o.value?r.items.push({start:[],key:n,sep:[]}):o.sep?o.value=n:Object.assign(o,{key:n,sep:[]});return}default:yield*this.pop(),yield*this.pop(n)}if((r.type==="document"||r.type==="block-map"||r.type==="block-seq")&&(n.type==="block-map"||n.type==="block-seq")){let o=n.items[n.items.length-1];o&&!o.sep&&!o.value&&o.start.length>0&&Pl(o.start)===-1&&(n.indent===0||o.start.every(s=>s.type!=="comment"||s.indent<n.indent))&&(r.type==="document"?r.end=o.start:r.items.push({start:o.start}),n.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let t={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&t.start.push(this.sourceToken),this.stack.push(t);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(t){if(t.value)return yield*this.lineEnd(t);switch(this.type){case"doc-start":{Pl(t.start)!==-1?(yield*this.pop(),yield*this.step()):t.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":t.start.push(this.sourceToken);return}let n=this.startBlockValue(t);n?this.stack.push(n):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(t){if(this.type==="map-value-ind"){let n=jr(this.peek(2)),r=Ut(n),o;t.end?(o=t.end,o.push(this.sourceToken),delete t.end):o=[this.sourceToken];let s={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:r,key:t,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(t)}*blockScalar(t){switch(this.type){case"space":case"comment":case"newline":t.props.push(this.sourceToken);return;case"scalar":if(t.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let n=this.source.indexOf(``)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`-`,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(t){let n=t.items[t.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)t.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,t.indent)){let o=t.items[t.items.length-2]?.value?.end;if(Array.isArray(o)){jr(o,n.start),o.push(this.sourceToken),t.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=t.indent){let r=!this.onKeyLine&&this.indent===t.indent,o=r&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",s=[];if(o&&n.sep&&!n.value){let i=[];for(let c=0;c<n.sep.length;++c){let a=n.sep[c];switch(a.type){case"newline":i.push(c);break;case"space":break;case"comment":a.indent>t.indent&&(i.length=0);break;default:i.length=0}}i.length>=2&&(s=n.sep.splice(i[1]))}switch(this.type){case"anchor":case"tag":o||n.value?(s.push(this.sourceToken),t.items.push({start:s}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):o||n.value?(s.push(this.sourceToken),t.items.push({start:s,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(n.explicitKey)if(n.sep)if(n.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(lt(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]});else if(Tl(n.key)&&!lt(n.sep,"newline")){let i=Ut(n.start),c=n.key,a=n.sep;a.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:c,sep:a}]})}else s.length>0?n.sep=n.sep.concat(s,this.sourceToken):n.sep.push(this.sourceToken);else if(lt(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let i=Ut(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||o?t.items.push({start:s,key:null,sep:[this.sourceToken]}):lt(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);o||n.value?(t.items.push({start:s,key:i,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(i):(Object.assign(n,{key:i,sep:[]}),this.onKeyLine=!0);return}default:{let i=this.startBlockValue(t);if(i){if(i.type==="block-seq"){if(!n.explicitKey&&n.sep&&!lt(n.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&t.items.push({start:s});this.stack.push(i);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){let n=t.items[t.items.length-1];switch(this.type){case"newline":if(n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,t.indent)){let o=t.items[t.items.length-2]?.value?.end;if(Array.isArray(o)){jr(o,n.start),o.push(this.sourceToken),t.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=t.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;n.value||lt(n.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>t.indent){let r=this.startBlockValue(t);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){let n=t.items[t.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?t.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?t.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?t.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);!n||n.value?t.items.push({start:[],key:o,sep:[]}):n.sep?this.stack.push(o):Object.assign(n,{key:o,sep:[]});return}case"flow-map-end":case"flow-seq-end":t.end.push(this.sourceToken);return}let r=this.startBlockValue(t);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===t.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let o=Br(r),s=Ut(o);Cl(t);let i=t.end.splice(1,t.end.length);i.push(this.sourceToken);let c={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:s,key:t,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=c}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let n=this.source.indexOf(`+`,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(t){let n=t.items[t.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)t.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,t.indent)){let o=t.items[t.items.length-2]?.value?.end;if(Array.isArray(o)){Ur(o,n.start),o.push(this.sourceToken),t.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=t.indent){let r=!this.onKeyLine&&this.indent===t.indent,o=r&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",s=[];if(o&&n.sep&&!n.value){let i=[];for(let c=0;c<n.sep.length;++c){let a=n.sep[c];switch(a.type){case"newline":i.push(c);break;case"space":break;case"comment":a.indent>t.indent&&(i.length=0);break;default:i.length=0}}i.length>=2&&(s=n.sep.splice(i[1]))}switch(this.type){case"anchor":case"tag":o||n.value?(s.push(this.sourceToken),t.items.push({start:s}),this.onKeyLine=!0):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"explicit-key-ind":!n.sep&&!n.explicitKey?(n.start.push(this.sourceToken),n.explicitKey=!0):o||n.value?(s.push(this.sourceToken),t.items.push({start:s,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(n.explicitKey)if(n.sep)if(n.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(lt(n.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]});else if(Ml(n.key)&&!lt(n.sep,"newline")){let i=Ut(n.start),c=n.key,a=n.sep;a.push(this.sourceToken),delete n.key,delete n.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:c,sep:a}]})}else s.length>0?n.sep=n.sep.concat(s,this.sourceToken):n.sep.push(this.sourceToken);else if(lt(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let i=Ut(n.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else n.sep?n.value||o?t.items.push({start:s,key:null,sep:[this.sourceToken]}):lt(n.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);o||n.value?(t.items.push({start:s,key:i,sep:[]}),this.onKeyLine=!0):n.sep?this.stack.push(i):(Object.assign(n,{key:i,sep:[]}),this.onKeyLine=!0);return}default:{let i=this.startBlockValue(t);if(i){if(i.type==="block-seq"){if(!n.explicitKey&&n.sep&&!lt(n.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else r&&t.items.push({start:s});this.stack.push(i);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){let n=t.items[t.items.length-1];switch(this.type){case"newline":if(n.value){let r="end"in n.value?n.value.end:void 0;(Array.isArray(r)?r[r.length-1]:void 0)?.type==="comment"?r?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,t.indent)){let o=t.items[t.items.length-2]?.value?.end;if(Array.isArray(o)){Ur(o,n.start),o.push(this.sourceToken),t.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=t.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;n.value||lt(n.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>t.indent){let r=this.startBlockValue(t);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){let n=t.items[t.items.length-1];if(this.type==="flow-error-end"){let r;do yield*this.pop(),r=this.peek(1);while(r?.type==="flow-collection")}else if(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?t.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?t.items.push({start:[],key:null,sep:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):Object.assign(n,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!n||n.value?t.items.push({start:[this.sourceToken]}):n.sep?n.sep.push(this.sourceToken):n.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);!n||n.value?t.items.push({start:[],key:o,sep:[]}):n.sep?this.stack.push(o):Object.assign(n,{key:o,sep:[]});return}case"flow-map-end":case"flow-seq-end":t.end.push(this.sourceToken);return}let r=this.startBlockValue(t);r?this.stack.push(r):(yield*this.pop(),yield*this.step())}else{let r=this.peek(2);if(r.type==="block-map"&&(this.type==="map-value-ind"&&r.indent===t.indent||this.type==="newline"&&!r.items[r.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&r.type!=="flow-collection"){let o=jr(r),s=Ut(o);Ll(t);let i=t.end.splice(1,t.end.length);i.push(this.sourceToken);let c={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:s,key:t,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=c}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let n=this.source.indexOf(``)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`-`,n)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n=Br(t),r=Ut(n);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=Br(t),r=Ut(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,n){return this.type!=="comment"||this.indent<=n?!1:t.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};function Im(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new In||null,prettyErrors:t}}function ws(e,t={}){let{lineCounter:n,prettyErrors:r}=Im(t),o=new On(n?.addNewLine),s=new An(t),i=null;for(let c of s.compose(o.parse(e),!0,e.length))if(!i)i=c;else if(i.options.logLevel!=="silent"){i.errors.push(new ve(c.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(i.errors.forEach(is(e,n)),i.warnings.forEach(is(e,n))),i}var Ae=class extends Error{code;constructor(t){super(`Structured data failed validation: ${t}`),this.name="StructuredDataError",this.code=t}},Rm=e=>Oe(JSON.stringify(e)),zl=e=>{if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Pl=(e,t)=>{if(zl(e)===!1)throw new Ae("INVALID");let n=0,r=(s,i)=>{if(i>t.depth)throw new Ae("DEPTH_EXCEEDED");if(typeof s=="string"){if(Oe(s)>t.stringBytes)throw new Ae("STRING_BYTES_EXCEEDED");return s}if(s===null||typeof s=="boolean"||typeof s=="number"&&Number.isFinite(s)&&(Number.isInteger(s)===!1||Number.isSafeInteger(s)))return s;if(Array.isArray(s))return s.map(c=>{if(n+=1,n>t.fields)throw new Ae("FIELDS_EXCEEDED");return r(c,i+1)});if(zl(s)){let c=Object.create(null);for(let[a,u]of Object.entries(s)){if(n+=1,n>t.fields)throw new Ae("FIELDS_EXCEEDED");c[a]=r(u,i+1)}return c}throw new Ae("INVALID")},o=r(e,1);if(Rm(o)>t.serializedBytes)throw new Ae("SERIALIZED_BYTES_EXCEEDED");return o};var W=class extends Error{code;constructor(t,n){super(n),this.name="MarkdownMetadataError",this.code=t}};var Rn=new Uint8Array([239,187,191]),Ll=Rn.byteLength+10,$m=(e,t,n=0)=>e.byteLength-n<t.byteLength?!1:t.every((r,o)=>e[n+o]===r),$n=(e,t)=>{let n=0;if($m(e,Rn))n=Rn.byteLength;else if(e.byteLength<Rn.byteLength&&Rn.slice(0,e.byteLength).every((s,i)=>s===e[i]))return t?null:void 0;if(e.byteLength<n+4)return t?null:void 0;if(e[n]!==45||e[n+1]!==45||e[n+2]!==45)return null;let r=n+3;if(e[r]===10)r+=1;else if(e[r]===13){if(e.byteLength===r+1)return t?null:void 0;if(e[r+1]!==10)return null;r+=2}else return null;let o=r;for(let s=r;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:r,yamlEnd:o,blockEnd:i?s:s+1};o=s+1}};var Nm={bytes:D.frontmatterBytes,depth:D.frontmatterDepth,fields:D.frontmatterFields,stringBytes:D.frontmatterStringBytes,serializedBytes:D.indexedPropertiesBytes},Ml=e=>{try{return ae(e)}catch{throw new W("FRONTMATTER_DECODING_FAILED","Markdown frontmatter is not valid UTF-8")}},Zl=(e,t)=>{let n=ws(e,{schema:"core",uniqueKeys:!0});if(n.errors.length>0)throw new W("FRONTMATTER_INVALID","Markdown frontmatter contains invalid YAML");let r;try{r=n.toJS({maxAliasCount:0})}catch{throw new W("FRONTMATTER_INVALID","Markdown frontmatter contains unsupported YAML aliases")}if(r===null)return{};try{return Pl(r,t)}catch(o){throw o instanceof Ae?o.code==="DEPTH_EXCEEDED"?new W("FRONTMATTER_DEPTH_EXCEEDED","Markdown frontmatter exceeds the nesting limit"):o.code==="FIELDS_EXCEEDED"?new W("FRONTMATTER_FIELDS_EXCEEDED","Markdown frontmatter exceeds the field limit"):o.code==="STRING_BYTES_EXCEEDED"?new W("FRONTMATTER_STRING_BYTES_EXCEEDED","Markdown frontmatter contains a string that exceeds the byte limit"):o.code==="SERIALIZED_BYTES_EXCEEDED"?new W("FRONTMATTER_BYTES_EXCEEDED","Markdown frontmatter properties exceed the indexed byte limit"):new W("FRONTMATTER_INVALID","Markdown frontmatter must contain a JSON-compatible object"):o}},Fl=async(e,t={})=>{let n={...Nm,...t},r=n.bytes+Ll,o=new Uint8Array(r),s=0;for await(let a of Ot(e)){let u=0;for(;u<a.byteLength;){let d=r-s;if(d<=0)break;let l=Math.max(0,6-s),f=Math.min(a.byteLength-u,l);if(l===0){let m=a.subarray(u,Math.min(a.byteLength,u+d)),h=m.indexOf(10);f=h===-1?m.byteLength:h+1}o.set(a.subarray(u,u+f),s),s+=f,u+=f;let p=o.subarray(0,s),y=$n(p,!1);if(y===null)return{properties:{},frontmatterBytes:0,consumedBytes:p.length};if(y!==void 0){let m=y.yamlEnd-y.yamlStart;if(m>n.bytes)throw new W("FRONTMATTER_BYTES_EXCEEDED","Markdown frontmatter exceeds the byte limit");let h=Ml(p.subarray(y.yamlStart,y.yamlEnd));return{properties:Zl(h,n),frontmatterBytes:m,consumedBytes:y.blockEnd}}}if(s>=r)break}let i=o.subarray(0,s),c=$n(i,!0);if(c===null)return{properties:{},frontmatterBytes:0,consumedBytes:i.length};if(c!==void 0){let a=c.yamlEnd-c.yamlStart;if(a<=n.bytes){let u=Ml(i.subarray(c.yamlStart,c.yamlEnd));return{properties:Zl(u,n),frontmatterBytes:a,consumedBytes:c.blockEnd}}}throw new W("FRONTMATTER_BYTES_EXCEEDED","Markdown frontmatter is not closed within the byte limit")};var Ur=async(e,t=D.hydratedFileBytes)=>{if(Number.isInteger(t)===!1||t<=0||t>D.hydratedFileBytes)throw new W("MARKDOWN_BODY_BYTES_EXCEEDED","Markdown body byte limit is outside the supported range");let n;try{n=await pe(e,t)}catch(c){throw c instanceof te?new W("MARKDOWN_BODY_BYTES_EXCEEDED","Markdown content exceeds the byte limit"):c}let r;try{r=ae(n)}catch{throw new W("MARKDOWN_BODY_DECODING_FAILED","Markdown content is not valid UTF-8")}let s=$n(n,!0)?.blockEnd??0,i;try{i=s===0?Rt(r):ae(n.subarray(s))}catch{throw new W("MARKDOWN_BODY_DECODING_FAILED","Markdown content is not valid UTF-8")}return{body:i,bodyBytes:Oe(i),sourceBytes:n.byteLength}};var ft=class extends Error{code;referenceId;constructor({code:t,message:n,referenceId:r,cause:o}){super(n,{cause:o}),this.name="MarkdownDocumentError",this.code=t,this.referenceId=r}},Cm=O({source:k(),body:k(),frontmatter:Ie(k(),tt())}),Jr=e=>{let t;try{t=Cm.parse(e)}catch(n){throw new ft({code:"INVALID_DOCUMENT",message:"Markdown document is invalid",cause:n})}return Object.freeze({source:t.source,body:t.body,frontmatter:nt(t.frontmatter)})},Qr="#frontmatter",Tm=e=>`${Qr}${e.slice(1)}`,zm=e=>{if(e!==Qr&&e.startsWith(`${Qr}/`)===!1)throw new ft({code:"UNUSED_REFERENCE",message:`Resolved Markdown reference ${e} is outside frontmatter`,referenceId:e});return`#${e.slice(Qr.length)}`},Pm=e=>{let t=e.referenceId===void 0?void 0:Tm(e.referenceId),n="INVALID_DOCUMENT";throw(e.code==="INVALID_REFERENCE_MARKER"||e.code==="INVALID_REFERENCE"||e.code==="REFERENCE_NOT_FOUND"||e.code==="INVALID_RESOLVED_VALUE"||e.code==="UNUSED_REFERENCE")&&(n=e.code),new ft({code:n,message:e.message,referenceId:t,cause:e})},Bl=async({source:e,maximumBytes:t=D.hydratedFileBytes})=>{let n;try{n=await pe(e,t)}catch(i){throw i instanceof te?new ft({code:"CONTENT_LIMIT_EXCEEDED",message:"Markdown document exceeds the byte limit",cause:i}):i}let r;try{r=Rt(ae(n))}catch(i){throw new ft({code:"CONTENT_DECODING_FAILED",message:"Markdown document is not valid UTF-8",cause:i})}let[o,s]=await Promise.all([Ur(n,t),Fl(n)]);return Jr({source:r,body:o.body,frontmatter:s.properties})};var jl=({document:e,references:t,allowUnresolvedReferences:n=!1})=>{let r=Jr(e),o=new Map;for(let[i,c]of t)o.set(zm(i),c);let s;try{s=cr({document:r.frontmatter,references:o,allowUnresolvedReferences:n})}catch(i){throw i instanceof ue&&Pm(i),i}return Jr({...r,frontmatter:s})},Ul=({document:e,representation:t})=>{let n=Jr(e);if(t.type==="document")return n.source;if(t.type==="markdown-body")return n.body;if(t.type==="markdown-frontmatter")return n.frontmatter;throw new ft({code:"UNSUPPORTED_REPRESENTATION",message:`Markdown documents do not support ${t.type}`})};var Ql=e=>{let t=e.format==="markdown"?e.value.frontmatter:e.value;return Nt(t)?t:void 0},Vr=e=>Object.freeze(e),Jl=async({format:e,source:t,maximumBytes:n=D.hydratedFileBytes})=>Vr(e==="json"?{format:e,value:await Qu({source:t,maximumBytes:n})}:{format:e,value:await Bl({source:t,maximumBytes:n})});var Vl=({document:e,references:t,allowUnresolvedReferences:n})=>e.format==="json"?Vr({format:e.format,value:cr({document:e.value,references:t,allowUnresolvedReferences:n})}):Vr({format:e.format,value:jl({document:e.value,references:t,allowUnresolvedReferences:n})}),Gl=({document:e,representation:t})=>e.format==="json"?Ju({document:e.value,representation:t}):Ul({document:e.value,representation:t});var Gr=class extends Error{code;documentId;expectedRevision;actualRevision;expectedFormat;actualFormat;constructor({code:t,documentId:n,expectedRevision:r,actualRevision:o,expectedFormat:s,actualFormat:i}){super(`Document ${n} source ${t==="REVISION_MISMATCH"?"revision":"format"} does not match its graph`),this.name="DocumentSourceError",this.code=t,this.documentId=n,this.expectedRevision=r,this.actualRevision=o,this.expectedFormat=s,this.actualFormat=i}},Qt=({node:e,source:t})=>{if(t.revision!==e.revision)throw new Gr({code:"REVISION_MISMATCH",documentId:e.id,expectedRevision:e.revision,actualRevision:t.revision});if(e.format!==void 0&&t.format!==e.format)throw new Gr({code:"FORMAT_MISMATCH",documentId:e.id,expectedFormat:e.format,actualFormat:t.format});return t};var Jt=e=>{if(typeof e=="object"&&e!==null){let t=Reflect.get(e,"code");if(typeof t=="string"&&t.length>0)return t;let n=Reflect.get(e,"name");if(typeof n=="string"&&n.length>0)return n}return"UNKNOWN"},re=(e,t)=>{try{e?.(t)}catch{}},ql=({load:e,onEvent:t})=>async(n,r)=>{let o={documentId:n.id,revision:n.revision};re(t,{type:"document-fetch-started",...o});try{let s=await e(n,r);return re(t,{type:"document-fetch-completed",...o}),s}catch(s){throw re(t,{type:"document-fetch-failed",...o,errorCode:Jt(s)}),s}};var Lm=O({format:ce(["json","markdown"]),revision:k().min(1)}),Vt=class extends Error{code;documentId;status;constructor({code:t,message:n,documentId:r,status:o,cause:s}){super(n,{cause:s}),this.name="HttpDocumentLoaderError",this.code=t,this.documentId=r,this.status=o}},Mm=e=>({async*[Symbol.asyncIterator](){let t=e.getReader(),n=!1;try{for(;;){let r=await t.read();if(r.done){n=!0;return}yield r.value}}finally{if(n===!1)try{await t.cancel()}catch{}t.releaseLock()}}}),Kl=({fetch:e,getRequest:t,getMetadata:n,onEvent:r})=>ql({load:async(s,{signal:i})=>{let c;try{c=await e(t(s),{signal:i})}catch(d){throw new Vt({code:"REQUEST_FAILED",message:`Document ${s.id} request failed`,documentId:s.id,cause:d})}if(c.ok===!1)throw new Vt({code:"HTTP_STATUS",message:`Document ${s.id} request returned status ${c.status}`,documentId:s.id,status:c.status});let a;try{a=Lm.parse(n({node:s,response:c}))}catch(d){throw new Vt({code:"INVALID_METADATA",message:`Document ${s.id} response metadata is invalid`,documentId:s.id,cause:d})}let u=c.body;if(u===null)throw new Vt({code:"BODY_MISSING",message:`Document ${s.id} response body is unavailable`,documentId:s.id});return Object.freeze({...a,source:Mm(u)})},onEvent:r});var Nn=class extends Error{code="CONTENT_LIMIT_EXCEEDED";documentId;contentByteLimit;constructor({message:t,documentId:n,contentByteLimit:r,cause:o}){super(t,{cause:o}),this.name="CachedDocumentLoaderError",this.documentId=n,this.contentByteLimit=r}},Zm=({contentRef:e,revision:t,format:n})=>Re([e,t,n??null]),Fm=e=>{if(typeof e!="object"||e===null)return!1;let t=e;return(t.format==="json"||t.format==="markdown")&&typeof t.revision=="string"&&t.revision.length>0&&t.bytes instanceof Uint8Array},Wl=e=>Object.freeze({format:e.format,revision:e.revision,source:e.bytes}),Yl=({load:e,cache:t,maximumBytes:n=D.hydratedFileBytes,onEvent:r})=>{let o=new Map;return async(s,i)=>{let c=Zm(s),a=o.get(c)??new Map;o.set(c,a);let u=a.get(i.signal);if(u!==void 0)return await u;let d=(async()=>{let l;try{l=await t.get(c)}catch(m){re(r,{type:"document-cache-read-failed",documentId:s.id,revision:s.revision,errorCode:Jt(m)})}if(Fm(l)&&l.revision===s.revision&&l.bytes.byteLength<=n&&(s.format===void 0||l.format===s.format))return re(r,{type:"document-cache-hit",documentId:s.id,revision:s.revision}),Wl(l);re(r,{type:"document-cache-miss",documentId:s.id,revision:s.revision});let f=Qt({node:s,source:await e(s,i)}),p;try{p=await pe(f.source,n)}catch(m){throw m instanceof te?new Nn({message:`Document ${s.id} exceeds the cache byte limit`,documentId:s.id,contentByteLimit:n,cause:m}):m}let y=Object.freeze({format:f.format,revision:f.revision,bytes:p});try{await t.set(c,y),re(r,{type:"document-cache-stored",documentId:s.id,revision:s.revision})}catch(m){re(r,{type:"document-cache-write-failed",documentId:s.id,revision:s.revision,errorCode:Jt(m)})}return Wl(y)})();a.set(i.signal,d);try{return await d}finally{a.delete(i.signal),a.size===0&&o.delete(c)}}};var Ge=class extends Error{code;documentId;referenceId;constructor({code:t,message:n,documentId:r,referenceId:o,cause:s}){super(n,{cause:s}),this.name="DocumentGraphResolutionError",this.code=t,this.documentId=r,this.referenceId=o}},qr=e=>{if(e?.aborted)throw new Ge({code:"REQUEST_CANCELLED",message:"Document graph resolution was cancelled",cause:e.reason})},Xl=async({graph:e,rootIds:t,concurrency:n,signal:r,load:o,select:s,assemble:i})=>{qr(r);let c=nr({graph:e,rootIds:t}),a=new Map(c.map(p=>[p.id,p])),u=new Map,d=new Map;for(let p of c){let y=d.get(p.contentRef);y===void 0?d.set(p.contentRef,{representative:p,nodes:[p]}):y.nodes.push(p)}await ir([...d.values()],n,async p=>{qr(r);let y=p.representative;try{let m=await o(y,{signal:r});for(let h of p.nodes)u.set(h.id,m)}catch(m){throw r?.aborted&&qr(r),new Ge({code:"DOCUMENT_LOAD_FAILED",message:`Document ${y.id} could not be loaded`,documentId:y.id,cause:m})}});let l=$t(e.edges),f=new Map;for(let p of c){qr(r);let y=new Map;for(let h of l.get(p.id)??[]){let b=a.get(h.reference.documentId);if(b===void 0||f.has(h.reference.documentId)===!1)throw new Ge({code:"DOCUMENT_ASSEMBLY_FAILED",message:`Document ${p.id} dependency ${h.reference.documentId} is unavailable`,documentId:p.id,referenceId:h.referenceId});let _=f.get(h.reference.documentId),x;if(s===void 0){if(h.reference.representation.type!=="document")throw new Ge({code:"REPRESENTATION_SELECTOR_REQUIRED",message:`Document ${p.id} reference ${h.referenceId} requires a representation selector`,documentId:p.id,referenceId:h.referenceId});x=_}else try{x=await s({reference:h.reference,value:_,sourceNode:p,targetNode:b})}catch(w){throw new Ge({code:"DOCUMENT_SELECTION_FAILED",message:`Document ${p.id} reference ${h.referenceId} could not be selected`,documentId:p.id,referenceId:h.referenceId,cause:w})}y.set(h.referenceId,x)}if(u.has(p.id)===!1)throw new Ge({code:"DOCUMENT_ASSEMBLY_FAILED",message:`Document ${p.id} source is unavailable`,documentId:p.id});let m=u.get(p.id);try{f.set(p.id,await i({node:p,source:m,references:y}))}catch(h){throw new Ge({code:"DOCUMENT_ASSEMBLY_FAILED",message:`Document ${p.id} could not be assembled`,documentId:p.id,cause:h})}}return Object.freeze({roots:Object.freeze(t.map(p=>f.get(p))),values:f})};var bt=class extends Error{code;documentId;documentCount;documentLimit;contentByteLimit;totalBytes;totalByteLimit;constructor({code:t,message:n,documentId:r,documentCount:o,documentLimit:s,contentByteLimit:i,totalBytes:c,totalByteLimit:a,cause:u}){super(n,{cause:u}),this.name="DocumentResolutionLimitError",this.code=t,this.documentId=r,this.documentCount=o,this.documentLimit=s,this.contentByteLimit=i,this.totalBytes=c,this.totalByteLimit=a}},Hl=async({graph:e,rootIds:t,concurrency:n,maximumBytes:r=D.hydratedFileBytes,maximumTotalBytes:o=D.hydratedTotalBytes,maximumDocuments:s=D.hydratedFileCount,signal:i,load:c,onEvent:a,allowUnresolvedReferences:u=!1})=>{let d=nr({graph:e,rootIds:t}).length,l={rootCount:t.length,documentCount:d};re(a,{type:"resolution-started",...l});try{if(d>s)throw new bt({code:"DOCUMENT_COUNT_EXCEEDED",message:"Document graph resolution exceeds the document limit",documentCount:d,documentLimit:s});let f=0,p=await Xl({graph:e,rootIds:t,concurrency:n,signal:i,load:async(y,m)=>{let h=Qt({node:y,source:await c(y,m)}),b;try{b=await pe(h.source,r)}catch(x){throw x instanceof te?new bt({code:"CONTENT_LIMIT_EXCEEDED",message:`Document ${y.id} exceeds the byte limit`,documentId:y.id,contentByteLimit:r,cause:x}):x}let _=f+b.byteLength;if(_>o)throw new bt({code:"TOTAL_BYTES_EXCEEDED",message:"Document graph resolution exceeds the total byte limit",documentId:y.id,totalBytes:_,totalByteLimit:o});return f=_,await Jl({format:h.format,source:b,maximumBytes:r})},select:({reference:y,value:m})=>Gl({document:m,representation:y.representation}),assemble:({source:y,references:m})=>Vl({document:y,references:m,allowUnresolvedReferences:u})});return re(a,{type:"resolution-completed",...l}),p}catch(f){throw re(a,{type:"resolution-failed",...l,errorCode:Jt(f)}),f}};var ef=e=>{if(e.output.mode==="all")return"all";let t=[];for(let{field:n}of Hn(e.where))n[0]==="properties"&&t.push(n);for(let{field:n}of e.sort)n[0]==="properties"&&t.push(n);if(e.output.mode==="fields")for(let n of e.output.fields)n[0]==="properties"&&t.push(n);return t},tf=e=>{let t;if(e==="#frontmatter")t="";else if(e.startsWith("#frontmatter/"))t=e.slice(12);else if(e==="#")t="";else if(e.startsWith("#/"))t=e.slice(1);else return;try{return["properties",...ju(t)]}catch{return}},nf=(e,t)=>{let n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1)if(e[r]!==t[r])return!1;return!0},rf=({queryPaths:e,referenceId:t})=>{let n=tf(t);return n!==void 0&&(e==="all"||e.some(r=>nf(r,n)))},of=({graph:e,sourceId:t,field:n})=>n[0]!=="properties"?!1:e.edges.some(r=>{if(r.sourceId!==t)return!1;let o=tf(r.referenceId);return o!==void 0&&nf(n,o)}),sf=({graph:e,query:t})=>{let n=ef(t),r=new Set;for(let o of e.edges)rf({queryPaths:n,referenceId:o.referenceId})&&r.add(o.sourceId);return[...r]},cf=({graph:e,query:t,rootIds:n})=>{let r=ef(t),o=new Set(n),s=new Map(e.nodes.map(l=>[l.id,l])),i=$t(e.edges),c=new Set(n),a=new Set,u=new Set,d=l=>{if(c.add(l),!u.has(l)){u.add(l);for(let f of i.get(l)??[])a.add(f),d(f.reference.documentId)}};for(let l of e.edges)o.has(l.sourceId)&&rf({queryPaths:r,referenceId:l.referenceId})&&(a.add(l),d(l.reference.documentId));return un({nodes:[...c].map(l=>{let f=s.get(l);if(f===void 0)throw new Error(`Document graph query root ${l} does not exist`);return f}),edges:[...a]})};var af=({artifact:e})=>{if(e.documentGraph===void 0)return;let t=new Map(e.documents.map(s=>[s._id,s])),n=new Map(e.documentGraph.nodes.map(s=>[s.id,s])),r=new Map;for(let{sourceId:s}of e.documentGraph.edges){if(n.has(s))continue;let i=t.get(s);if(i?.properties===void 0)throw new Error(`Runtime document graph source ${s} is unavailable`);r.set(s,i),n.set(s,{id:s,revision:s,contentRef:s,format:"json"})}return{graph:un({nodes:[...n.values()],edges:e.documentGraph.edges.map(({sourceId:s,referenceId:i,documentId:c,representation:a})=>{let u=n.get(c);if(u===void 0)throw new Error(`Runtime document graph target ${c} is unavailable`);return{sourceId:s,referenceId:i,reference:{documentId:c,revision:u.revision,representation:a}}})}),inlineDocuments:r}};var Bm=(e,t)=>{if(t===void 0||t.length===0)return e;let n=new URL("https://content.webstudio.invalid/__assets__/"),r=new URL(e,n),o=new URL(t,n);for(let[c,a]of o.searchParams)r.searchParams.append(c,a);if(o.hash!==""&&(r.hash=o.hash),URL.canParse(e))return r.href;if(e.startsWith("//"))return`//${r.host}${r.pathname}${r.search}${r.hash}`;if(e.startsWith("/"))return`${r.pathname}${r.search}${r.hash}`;let s=n.pathname;return`${r.pathname.startsWith(s)?r.pathname.slice(s.length):r.pathname}${r.search}${r.hash}`},uf=({markdown:e,references:t,assetUrls:n})=>{let r=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>r)throw new Error("Markdown asset reference range is invalid");r=s.start;let i=n[s.assetId];if(i===void 0)continue;let c=Bm(i,s.suffix);o=`${o.slice(0,s.start)}${c}${o.slice(s.end)}`}return o};var oe=class extends Error{code;details;constructor({code:t,message:n,details:r}){super(n),this.name="AssetResourceHydrationError",this.code=t,this.details=r}},jm=e=>{if(e===null)return[];let t=Array.isArray(e)?e:[e],n=new Map;for(let r of t){if(typeof r!="object"||r===null||!("_id"in r)||typeof r._id!="string"||!("revision"in r)||typeof r.revision!="string"||!("contentRef"in r)||typeof r.contentRef!="string")throw new oe({code:"CONTENT_IDENTITY_REQUIRED",message:"Hydrated query results must retain _id, revision, and contentRef"});let o=n.get(r._id);if(o!==void 0&&(o.revision!==r.revision||o.contentRef!==r.contentRef))throw new oe({code:"CONTENT_IDENTITY_REQUIRED",message:"A selected asset ID has conflicting content identity",details:{assetId:r._id}});n.set(r._id,{_id:r._id,revision:r.revision,contentRef:r.contentRef})}return Array.from(n.values())},Um=e=>typeof e.mimeType=="string"&&(e.mimeType.startsWith("text/")||["application/json","application/javascript","application/xml","image/svg+xml"].includes(e.mimeType)),Qm=async({read:e,contentRef:t,range:n,maximumBytes:r})=>{if(r===0)return new Uint8Array;let o=await e(t,n);try{return await pe(o.data,r)}catch(s){throw s instanceof te?new oe({code:"CONTENT_LIMIT_EXCEEDED",message:"Asset storage returned more content than requested"}):s}},Jm=e=>{try{return ae(e)}catch{throw new oe({code:"CONTENT_DECODING_FAILED",message:"Selected asset content is not valid UTF-8"})}},Vm=(e,t)=>{if(t.mode==="range")return Math.max(0,Math.min(t.length,e.size-t.offset));let n=t.maxBytes??D.hydratedFileBytes;if(e.size>n)throw new oe({code:"CONTENT_LIMIT_EXCEEDED",message:"Selected asset exceeds the per-file content limit",details:{assetId:e._id,assetBytes:e.size,fileByteLimit:n}});return e.size},lf=async({result:e,documents:t,options:n,read:r,assetReferences:o,assetUrls:s})=>{if(n.mode==="none")return{content:{},hydratedFileCount:0,hydratedBytes:0};let i=jm(e);if(i.length>D.hydratedFileCount)throw new oe({code:"CONTENT_LIMIT_EXCEEDED",message:"Too many selected assets requested content hydration",details:{fileCount:i.length,fileCountLimit:D.hydratedFileCount}});let c=new Map(t.map(l=>[l._id,l])),a=i.map(l=>{let f=c.get(l._id);if(f===void 0||f.revision!==l.revision||f.contentRef!==l.contentRef||typeof f.size!="number"||typeof f.mimeType!="string")throw new oe({code:"CONTENT_IDENTITY_REQUIRED",message:"Selected asset content identity is stale or unavailable",details:{assetId:l._id}});let p={...f,size:f.size,mimeType:f.mimeType};if(Um(p)===!1)throw new oe({code:"CONTENT_NOT_TEXT",message:"Selected binary asset cannot be embedded as text",details:{assetId:l._id,mimeType:p.mimeType}});return{identity:l,document:p,readLength:Vm(p,n)}}),u=a.reduce((l,f)=>l+f.readLength,0);if(u>D.hydratedTotalBytes)throw new oe({code:"CONTENT_LIMIT_EXCEEDED",message:"Selected assets exceed the total hydrated-content limit",details:{totalReadBytes:u,totalByteLimit:D.hydratedTotalBytes}});let d=await ir(a,D.concurrentContentReads,async l=>{let f=n.mode==="range"?{offset:n.offset,length:l.readLength}:l.readLength===0?void 0:{offset:0,length:l.readLength},p=await Qm({read:r,contentRef:l.identity.contentRef,range:f,maximumBytes:l.readLength});if(p.byteLength!==l.readLength)throw new oe({code:"CONTENT_IDENTITY_REQUIRED",message:"Selected asset bytes do not match canonical metadata",details:{assetId:l.identity._id}});let y;if(n.mode==="markdown-body-ref")try{y=(await Ur(p,l.readLength||1)).body;let h=o?.[l.identity.contentRef];h!==void 0&&s!==void 0&&(y=uf({markdown:y,references:h,assetUrls:s}))}catch{throw new oe({code:"CONTENT_DECODING_FAILED",message:"Selected Markdown body could not be decoded",details:{assetId:l.identity._id}})}else y=Jm(p);let m=Oe(y);return{id:l.identity._id,returnedBytes:m,content:{...l.identity,encoding:"utf-8",text:y,...n.mode==="range"?{range:{offset:n.offset,length:p.byteLength,total:l.document.size}}:{}}}});return{content:Object.fromEntries(d.map(({id:l,content:f})=>[l,f])),hydratedFileCount:a.length,hydratedBytes:d.reduce((l,{returnedBytes:f})=>l+f,0)}};var ek=k().datetime({offset:!0}).transform(e=>new Date(e).toISOString());var Gm=/^[A-Za-z_][A-Za-z0-9_]*$/,ff=(e,t)=>Gm.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`;var df=({document:e,includes:t})=>{let n={};for(let r of Pu){let o=e[r];o!==void 0&&t(r)&&(n[r]=o)}return n},pf=({source:e,target:t,path:n})=>{let[r,...o]=n;if(r===void 0||Object.hasOwn(e,r)===!1)return;let s=e[r];if(o.length===0){Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0});return}if(typeof s!="object"||s===null||Array.isArray(s))return;let i={};if(pf({source:s,target:i,path:o}),Object.keys(i).length===0)return;let c=t[r];Object.defineProperty(t,r,{value:{...typeof c=="object"&&c!==null&&Array.isArray(c)===!1?c:{},...i},enumerable:!0,configurable:!0,writable:!0})},mf=({properties:e,fields:t})=>{let n={};for(let r of t)r[0]==="properties"&&pf({source:e,target:n,path:r.slice(1)});return n};var qe=class extends Error{constructor(t,n){super(t,n),this.name="AssetQueryExecutionError"}},qt=class extends Error{constructor(){super("The requested asset index revision is stale"),this.name="AssetIndexRevisionError"}},hf=e=>{if(e[0]!=="properties")return e[0];let t="properties";for(let n of e.slice(1))t=ff(t,n);return t},yf=({filter:e,fieldTypes:t})=>Zu(t).includes(e.operator),gf=(e,t)=>e!==void 0&&Object.hasOwn(e.fields,t)?e.fields[t]:void 0,qm=({query:e,catalog:t})=>{let n=rt.parse(e),r=new Map,o=[];for(let s of Hn(n.where)){let i=hf(s.field);if(r.set(i,s.field),s.field[0]==="properties"){let c=gf(t,i);t!==void 0&&c===void 0?o.push(`Asset field ${i} is not currently observed`):c!==void 0&&yf({filter:s,fieldTypes:c.types})===!1&&o.push(`Operator ${s.operator} is not compatible with the currently observed types of ${i}`)}else if(yf({filter:s,fieldTypes:Bo[s.field[0]]})===!1)throw new qe(`Operator ${s.operator} is incompatible with ${i}`)}for(let s of n.sort){let i=hf(s.field);if(r.set(i,s.field),s.field[0]==="properties"){let c=gf(t,i);t!==void 0&&c===void 0?o.push(`Asset field ${i} is not currently observed`):c!==void 0&&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:n,referencedFieldPaths:[...r.values()],warnings:[...new Set(o)]}},_s=(e,t,n)=>{let r=t[0]==="id"?e._id:or(t[0])?n?.[t[0]]:e[t[0]];for(let o of t.slice(1)){if(typeof r!="object"||r===null||Object.hasOwn(r,o)===!1)return;r=r[o]}return r},Km=e=>typeof e=="string"||Array.isArray(e)?e.length===0:typeof e=="object"&&e!==null&&Object.keys(e).length===0,Wm=(e,t)=>{if(typeof e=="number"&&typeof t=="number")return e-t;if(typeof e=="string"&&typeof t=="string")return $e(e,t)},xs=(e,t,n)=>{let r=_s(e,t.field,n);if(t.operator==="exists")return r!=null===t.value;if(t.operator==="isEmpty")return Km(r)===t.value;if(t.operator==="eq")return an(r,t.value);if(t.operator==="ne")return an(r,t.value)===!1;if(t.operator==="in")return t.value.some(s=>an(r,s));if(t.operator==="contains")return typeof r=="string"&&typeof t.value=="string"?r.includes(t.value):Array.isArray(r)&&r.some(s=>an(s,t.value));if(t.operator==="startsWith")return typeof r=="string"&&typeof t.value=="string"&&r.startsWith(t.value);if(t.operator==="endsWith")return typeof r=="string"&&typeof t.value=="string"&&r.endsWith(t.value);let o=Wm(r,t.value);return o===void 0?!1:t.operator==="gt"?o>0:t.operator==="gte"?o>=0:t.operator==="lt"?o<0:o<=0},Ym=(e,t,n)=>Dt(t,r=>xs(e,r,n))===!0,Xm=({document:e,content:t})=>t.mode!=="markdown-body-ref"||e.mimeType==="text/markdown"||e.extension==="md",Hm=(e,t)=>{let n=e==null,r=t==null;return n||r?n===r?0:n?1:-1:typeof e=="number"&&typeof t=="number"?e-t:(typeof e=="string"||typeof e=="boolean")&&(typeof t=="string"||typeof t=="boolean")?$e(String(e),String(t)):$e(Re(e),Re(t))},eh=({left:e,right:t,sort:n,runtimeAssets:r})=>{for(let o of n){let s=Hm(_s(e,o.field,r?.[e._id]),_s(t,o.field,r?.[t._id]));if(s!==0)return o.direction==="asc"?s:-s}return $e(e._id,t._id)};var th=(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(r=>r[0]==="properties")===!1)return;let n=mf({properties:e.properties,fields:t.fields});return Object.keys(n).length===0?void 0:n},Gt=(e,t)=>e.includeMetadata&&Lu(t)||e.mode==="fields"&&e.fields.some(n=>n.length===1&&n[0]===t),nh=e=>e.mode==="all"||e.mode==="fields"&&e.fields.some(t=>t.length===1&&t[0]==="excerpt"),rh=(e,t,n)=>{if(Gt(t,"url")&&n===void 0)throw new Error(`Asset URL is unavailable for ${e._id}`);let r=th(e,t),o=n?.width!==void 0&&n.height!==void 0;return{...n!==void 0&&Gt(t,"url")?{url:n.url}:{},...o&&Gt(t,"width")?{width:n.width}:{},...o&&Gt(t,"height")?{height:n.height}:{},...df({document:e,includes:s=>Gt(t,s)}),...r===void 0?{}:{properties:r},...e.excerpt===void 0||nh(t)===!1?{}:{excerpt:e.excerpt},...e.metadataError===void 0||t.includeMetadata===!1?{}:{metadataError:e.metadataError}}},oh=e=>{if(Oe(Re(e))>D.resultBytes)throw new qe("Asset query result exceeds the byte limit")},bf=async({query:e,catalog:t,documents:n,read:r,runtimeAssets:o,assetReferences:s})=>{let{query:i}=qm({query:e,catalog:t});if(n.length>D.candidateDocuments)throw new qe("Asset query document limit was exceeded");let c=n.flatMap(p=>{let y=o?.[p._id];if(Xm({document:p,content:i.content})===!1||Ym(p,i.where,y)===!1)return[];let m=rh(p,i.output,y);return i.content.mode==="none"&&Object.keys(m).length===0&&Gt(i.output,"id")===!1?[]:[{document:p,item:{id:p._id,...m}}]}),u=[...c].sort((p,y)=>eh({left:p.document,right:y.document,sort:i.sort,runtimeAssets:o})).slice(i.offset,i.offset+i.limit),d=u.map(({document:p})=>p),l=u.map(({item:p})=>p);if(i.content.mode!=="none"){let p=i.content;if(r===void 0)throw new qe("Asset content reader is unavailable");let y=await lf({result:d,documents:d,options:p,read:r,assetReferences:s,assetUrls:s===void 0?void 0:Object.fromEntries(Object.entries(o??{}).map(([m,h])=>[m,h.url]))});l=d.map((m,h)=>{let b=y.content[m._id];if(b===void 0)throw new qe("Selected asset content could not be read");return{...l[h],content:{encoding:b.encoding,text:b.text,...b.range===void 0?{}:{range:b.range}}}})}let f={items:l,totalCount:c.length,hasMore:i.offset+u.length<c.length};return oh(f),f};var sh=async e=>await ku(Re(rt.parse(e)));var ih=({item:e,field:t,value:n})=>{let r=e;for(let[o,s]of t.entries()){if(o===t.length-1){Object.defineProperty(r,s,{value:n,enumerable:!0,configurable:!0,writable:!0});return}let i=Object.hasOwn(r,s)?r[s]:void 0;if(typeof i=="object"&&i!==null){r=i;continue}let c={};Object.defineProperty(r,s,{value:c,enumerable:!0,configurable:!0,writable:!0}),r=c}},ch=e=>sr.parse({items:e.rows.map(t=>{let n={};for(let[r,o]of e.fields.entries())ih({item:n,field:o,value:t[r]});return n}),totalCount:e.totalCount,hasMore:e.hasMore}),wf=async({queries:e,query:t})=>{if(e===void 0)return;let n=e[await sh(rt.parse(t))];return n===void 0?void 0:ch(n)};var ah=(e,t)=>t===void 0?Ot(e):{async*[Symbol.asyncIterator](){let n=0,r=0;for await(let o of Ot(e)){if(r===t.length)return;if(n+o.byteLength<=t.offset){n+=o.byteLength;continue}let s=Math.max(0,t.offset-n),i=Math.min(o.byteLength-s,t.length-r);i>0&&(yield o.subarray(s,s+i),r+=i),n+=o.byteLength}}},uh=({graph:e,load:t,signal:n})=>{let r=new Map(e.nodes.map(o=>[o.contentRef,o]));return async(o,s)=>{let i=r.get(o);if(i===void 0)throw new Error(`Document content reference ${o} is unavailable`);let c=Qt({node:i,source:await t(i,{signal:n})});return{data:ah(c.source,s),...s===void 0?{}:{contentLength:s.length}}}},lh=({artifact:e,revision:t,catalog:n,documentGraph:r,inlineDocuments:o,readContent:s})=>{let i=async(a,u,d,l)=>{if(a.indexRevision!==void 0&&a.indexRevision!==t)throw new qt;let f=l?.skipMaterialized===!0?void 0:await wf({queries:e.queries,query:a.query});if(f!==void 0)return f;let p=async(m,h)=>{let b=e.contents?.[m];if(b===void 0){let w=u??s;if(w===void 0)throw new Error("Content is not embedded in this database");return await w(m,h)}let _=It(b),x=h===void 0?_:_.slice(h.offset,h.offset+h.length);return{data:async function*(){yield x}(),contentLength:x.byteLength}};return await bf({query:a.query,catalog:n,documents:l?.documents??e.documents,read:p,runtimeAssets:d,assetReferences:e.assetReferences})};return{query:async(...a)=>await i(...a),queryWithDocumentGraph:async({request:a,load:u,readContent:d,runtimeAssets:l,signal:f,onEvent:p})=>{if(r===void 0)return await i(a,d,l);let y=d??uh({graph:r,load:u,signal:f}),m=rt.parse(a.query),h=new Map(e.documents.map(v=>[v._id,v])),b=sf({graph:r,query:m}).filter(v=>{let $=h.get(v);return $===void 0?!1:Dt(m.where,E=>{if(!of({graph:r,sourceId:v,field:E.field}))return xs($,E,l?.[v])})!==!1});if(b.length===0)return await i(a,y,l);let _=cf({graph:r,query:m,rootIds:b});re(p,{type:"roots-selected",rootCount:b.length});let x=await Hl({graph:_,rootIds:b,load:async(v,$)=>{let E=o?.get(v.id);return E!==void 0?{format:"json",revision:v.revision,source:JSON.stringify(E.properties)}:await u(v,$)},concurrency:D.concurrentContentReads,signal:f,onEvent:p,allowUnresolvedReferences:!0}),w=new Map(b.flatMap((v,$)=>{let E=Ql(x.roots[$]);return E===void 0?[]:[[v,E]]})),S=e.documents.map(v=>{let $=w.get(v._id);return $===void 0?v:Fo.parse({...v,properties:$})});return await i(a,y,l,{documents:S,skipMaterialized:!0})}}};var Es=({artifact:e,readContent:t})=>{let n=af({artifact:e});return lh({artifact:e,revision:e.revision,documentGraph:n?.graph,inlineDocuments:n?.inlineDocuments,readContent:t})};var Kr=class extends Error{constructor(t,n){super(t,n),this.name="AssetQueryRequestError"}},Cn=class extends Error{},fh=async(e,t)=>{if(Number.isSafeInteger(t)===!1||t<0)throw new TypeError("Request byte limit must be a non-negative integer");let n=Number(e.headers.get("content-length"));if(Number.isFinite(n)&&n>t)throw new Cn("Request exceeds the byte limit");let r=e.body?.getReader(),o=[],s=0;if(r!==void 0)for(;;){let{done:a,value:u}=await r.read();if(a)break;if(s+=u.byteLength,s>t){try{await r.cancel()}catch{}throw new Cn("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},_f=async e=>{let t;try{t=await fh(e,D.requestBytes)}catch(n){throw n instanceof Cn?new Kr("Asset query request exceeds the byte limit",{cause:n}):n}try{return Fu.parse(JSON.parse(ae(t)))}catch(n){throw new Kr("Asset query request is invalid",{cause:n})}};var xf=e=>{if(e instanceof qt)return{code:"STALE_INDEX",message:e.message,retryable:!1,status:409};if(e instanceof qe)return{code:"INVALID_REQUEST",message:e.message,retryable:!1,status:400};if(e instanceof oe)return{code:e.code,message:e.message,retryable:!1,details:e.details,status:400};let t=new Set,n=e;for(;n!==void 0&&t.has(n)===!1;){if(n instanceof bt){let r={};for(let[o,s]of Object.entries({assetId:n.documentId,documentCount:n.documentCount,documentLimit:n.documentLimit,contentByteLimit:n.contentByteLimit,totalBytes:n.totalBytes,totalByteLimit:n.totalByteLimit}))s!==void 0&&(r[o]=s);return{code:"CONTENT_LIMIT_EXCEEDED",message:n.message,retryable:!1,details:r,status:400}}if(n instanceof Nn)return{code:"CONTENT_LIMIT_EXCEEDED",message:n.message,retryable:!1,details:{assetId:n.documentId,contentByteLimit:n.contentByteLimit},status:400};t.add(n),n=n instanceof Error?n.cause:void 0}};var dh="/$resources/assets",Ef=(e,t=200)=>new Response(JSON.stringify(e),{status:t,headers:{"content-type":"application/json; charset=utf-8"}}),Tn=({code:e,message:t,status:n,retryable:r=!1,details:o})=>Ef(Bu({code:e,message:t,retryable:r,details:o}),n),ph=(e,t,n)=>typeof e=="string"||e instanceof URL?new Request(new URL(e,t),n):new Request(e,n),mh=async({deploymentId:e,artifact:t,request:n})=>{let r=await n.clone().text(),o=n.headers.get("cache-control"),s=await Lo(JSON.stringify([e,t.revision,r,o])),i=new URL(n.url);return i.searchParams.set("ws-asset-resource",s),new Request(i,{method:"GET"})},Bk=({deploymentId:e,artifact:t,runtimeAssets:n,cache:r,baseUrl:o,fetchDocument:s=globalThis.fetch,onDocumentGraphEvent:i})=>{vf({artifact:t,runtimeAssets:n});let c=Sf();return kf({deploymentId:e,artifact:t,runtimeAssets:n,cache:r,baseUrl:o,database:Es({artifact:t}),fetchDocument:s,documentCache:c,onDocumentGraphEvent:i})},Sf=()=>{let e=new Map,t=D.hydratedTotalBytes*4,n=0;return{get:async r=>{let o=e.get(r);return o!==void 0&&(e.delete(r),e.set(r,o)),o},set:async(r,o)=>{if(o.bytes.byteLength>t)return;let s=e.get(r);for(s!==void 0&&(n-=s.bytes.byteLength,e.delete(r)),e.set(r,o),n+=o.bytes.byteLength;n>t;){let i=e.entries().next().value;if(i===void 0)break;e.delete(i[0]),n-=i[1].bytes.byteLength}}}},hh=({baseUrl:e,runtimeAssets:t,fetchDocument:n,cache:r,onEvent:o})=>Yl({cache:r,onEvent:o,load:Kl({fetch:n,getRequest:s=>{let i=t[s.id];if(i===void 0)throw new Error(`Published document URL is unavailable for ${s.id}`);return new URL(i.url,e)},getMetadata:({node:s})=>({format:s.format,revision:s.revision}),onEvent:o})}),vf=({artifact:e,runtimeAssets:t})=>{let n=Object.values(e.assetReferences??{}).flat().map(({assetId:s})=>s).find(s=>t[s]===void 0);if(n!==void 0)throw new Error(`Published referenced asset URL is unavailable for ${n}`);let r=e.documentGraph?.nodes.find(({id:s})=>t[s]===void 0)?.id;if(r!==void 0)throw new Error(`Published document URL is unavailable for ${r}`);let o=e.documentGraph?.nodes.find(({id:s,contentRef:i})=>t[s]?.contentRef!==i)?.id;if(o!==void 0)throw new Error(`Published document identity does not match graph node ${o}`)},kf=({deploymentId:e,artifact:t,runtimeAssets:n,cache:r,baseUrl:o,database:s,fetchDocument:i,documentCache:c,onDocumentGraphEvent:a})=>{let u=new URL(o).origin,d=hh({baseUrl:o,runtimeAssets:n,fetchDocument:i,cache:c,onEvent:a});return async(l,f)=>{let p=ph(l,o,f),y=new URL(p.url);if(y.origin!==u||y.pathname!==dh||p.method.toUpperCase()!=="POST")return;let m;try{m=await _f(p.clone())}catch{return Tn({code:"INVALID_REQUEST",message:"Asset resource request is invalid",status:400})}let h=r===void 0||p.headers.has("cache-control")===!1?void 0:await mh({deploymentId:e,artifact:t,request:p});if(h!==void 0&&r!==void 0){let b=await r.match(h).catch(()=>{});if(b!==void 0)return new Response(b.body,b)}try{if(p.signal.aborted)return Tn({code:"REQUEST_CANCELLED",message:"Published asset query was cancelled",status:499});let b=Ef(await s.queryWithDocumentGraph({request:m,load:d,runtimeAssets:n,signal:p.signal,onEvent:a}));return h!==void 0&&r!==void 0&&p.signal.aborted===!1&&(b.headers.set("cache-control",p.headers.get("cache-control")),await r.put(h,b.clone()).catch(()=>{})),b}catch(b){if(p.signal.aborted)return Tn({code:"REQUEST_CANCELLED",message:"Published asset query was cancelled",status:499});let _=xf(b);return Tn(_!==void 0?_:{code:"INTERNAL_ERROR",message:"Published asset query failed",status:500,retryable:!0})}}},jk=({deploymentId:e,artifact:t,runtimeAssets:n,onDocumentGraphEvent:r=void 0})=>{let o=globalThis.caches,s,i=()=>(s??=o.open(`webstudio-assets-${e}`),s),c=o===void 0?void 0:{match:async d=>(await i()).match(d),put:async(d,l)=>(await i()).put(d,l)};vf({artifact:t,runtimeAssets:n});let a=Es({artifact:t}),u=Sf();return async({request:d,fallback:l})=>{let f=new URL(d.url).origin,p=kf({deploymentId:e,artifact:t,runtimeAssets:n,cache:c,baseUrl:f,database:a,fetchDocument:l,documentCache:u,onDocumentGraphEvent:r});return async(y,m)=>await p(y,m)??l(y,m)}};export{jk as createGeneratedAssetResourceRuntime,Bk as createPublishedAssetResourceFetch};+`,n)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let n=jr(t),r=Ut(n);return r.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let n=jr(t),r=Ut(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,n){return this.type!=="comment"||this.indent<=n?!1:t.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};function $m(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Rn||null,prettyErrors:t}}function _s(e,t={}){let{lineCounter:n,prettyErrors:r}=$m(t),o=new On(n?.addNewLine),s=new Dn(t),i=null;for(let c of s.compose(o.parse(e),!0,e.length))if(!i)i=c;else if(i.options.logLevel!=="silent"){i.errors.push(new ke(c.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(i.errors.forEach(cs(e,n)),i.warnings.forEach(cs(e,n))),i}var De=class extends Error{code;constructor(t){super(`Structured data failed validation: ${t}`),this.name="StructuredDataError",this.code=t}},Cm=e=>Oe(JSON.stringify(e)),Zl=e=>{if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Fl=(e,t)=>{if(Zl(e)===!1)throw new De("INVALID");let n=0,r=(s,i)=>{if(i>t.depth)throw new De("DEPTH_EXCEEDED");if(typeof s=="string"){if(Oe(s)>t.stringBytes)throw new De("STRING_BYTES_EXCEEDED");return s}if(s===null||typeof s=="boolean"||typeof s=="number"&&Number.isFinite(s)&&(Number.isInteger(s)===!1||Number.isSafeInteger(s)))return s;if(Array.isArray(s))return s.map(c=>{if(n+=1,n>t.fields)throw new De("FIELDS_EXCEEDED");return r(c,i+1)});if(Zl(s)){let c=Object.create(null);for(let[a,u]of Object.entries(s)){if(n+=1,n>t.fields)throw new De("FIELDS_EXCEEDED");c[a]=r(u,i+1)}return c}throw new De("INVALID")},o=r(e,1);if(Cm(o)>t.serializedBytes)throw new De("SERIALIZED_BYTES_EXCEEDED");return o};var W=class extends Error{code;constructor(t,n){super(n),this.name="MarkdownMetadataError",this.code=t}};var $n=new Uint8Array([239,187,191]),Bl=$n.byteLength+10,Tm=(e,t,n=0)=>e.byteLength-n<t.byteLength?!1:t.every((r,o)=>e[n+o]===r),Nn=(e,t)=>{let n=0;if(Tm(e,$n))n=$n.byteLength;else if(e.byteLength<$n.byteLength&&$n.slice(0,e.byteLength).every((s,i)=>s===e[i]))return t?null:void 0;if(e.byteLength<n+4)return t?null:void 0;if(e[n]!==45||e[n+1]!==45||e[n+2]!==45)return null;let r=n+3;if(e[r]===10)r+=1;else if(e[r]===13){if(e.byteLength===r+1)return t?null:void 0;if(e[r+1]!==10)return null;r+=2}else return null;let o=r;for(let s=r;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:r,yamlEnd:o,blockEnd:i?s:s+1};o=s+1}};var zm={bytes:D.frontmatterBytes,depth:D.frontmatterDepth,fields:D.frontmatterFields,stringBytes:D.frontmatterStringBytes,serializedBytes:D.indexedPropertiesBytes},jl=e=>{try{return ae(e)}catch{throw new W("FRONTMATTER_DECODING_FAILED","Markdown frontmatter is not valid UTF-8")}},Ul=(e,t)=>{let n=_s(e,{schema:"core",uniqueKeys:!0});if(n.errors.length>0)throw new W("FRONTMATTER_INVALID","Markdown frontmatter contains invalid YAML");let r;try{r=n.toJS({maxAliasCount:0})}catch{throw new W("FRONTMATTER_INVALID","Markdown frontmatter contains unsupported YAML aliases")}if(r===null)return{};try{return Fl(r,t)}catch(o){throw o instanceof De?o.code==="DEPTH_EXCEEDED"?new W("FRONTMATTER_DEPTH_EXCEEDED","Markdown frontmatter exceeds the nesting limit"):o.code==="FIELDS_EXCEEDED"?new W("FRONTMATTER_FIELDS_EXCEEDED","Markdown frontmatter exceeds the field limit"):o.code==="STRING_BYTES_EXCEEDED"?new W("FRONTMATTER_STRING_BYTES_EXCEEDED","Markdown frontmatter contains a string that exceeds the byte limit"):o.code==="SERIALIZED_BYTES_EXCEEDED"?new W("FRONTMATTER_BYTES_EXCEEDED","Markdown frontmatter properties exceed the indexed byte limit"):new W("FRONTMATTER_INVALID","Markdown frontmatter must contain a JSON-compatible object"):o}},Vl=async(e,t={})=>{let n={...zm,...t},r=n.bytes+Bl,o=new Uint8Array(r),s=0;for await(let a of Rt(e)){let u=0;for(;u<a.byteLength;){let d=r-s;if(d<=0)break;let l=Math.max(0,6-s),f=Math.min(a.byteLength-u,l);if(l===0){let m=a.subarray(u,Math.min(a.byteLength,u+d)),h=m.indexOf(10);f=h===-1?m.byteLength:h+1}o.set(a.subarray(u,u+f),s),s+=f,u+=f;let p=o.subarray(0,s),y=Nn(p,!1);if(y===null)return{properties:{},frontmatterBytes:0,consumedBytes:p.length};if(y!==void 0){let m=y.yamlEnd-y.yamlStart;if(m>n.bytes)throw new W("FRONTMATTER_BYTES_EXCEEDED","Markdown frontmatter exceeds the byte limit");let h=jl(p.subarray(y.yamlStart,y.yamlEnd));return{properties:Ul(h,n),frontmatterBytes:m,consumedBytes:y.blockEnd}}}if(s>=r)break}let i=o.subarray(0,s),c=Nn(i,!0);if(c===null)return{properties:{},frontmatterBytes:0,consumedBytes:i.length};if(c!==void 0){let a=c.yamlEnd-c.yamlStart;if(a<=n.bytes){let u=jl(i.subarray(c.yamlStart,c.yamlEnd));return{properties:Ul(u,n),frontmatterBytes:a,consumedBytes:c.blockEnd}}}throw new W("FRONTMATTER_BYTES_EXCEEDED","Markdown frontmatter is not closed within the byte limit")};var Vr=async(e,t=D.hydratedFileBytes)=>{if(Number.isInteger(t)===!1||t<=0||t>D.hydratedFileBytes)throw new W("MARKDOWN_BODY_BYTES_EXCEEDED","Markdown body byte limit is outside the supported range");let n;try{n=await pe(e,t)}catch(c){throw c instanceof te?new W("MARKDOWN_BODY_BYTES_EXCEEDED","Markdown content exceeds the byte limit"):c}let r;try{r=ae(n)}catch{throw new W("MARKDOWN_BODY_DECODING_FAILED","Markdown content is not valid UTF-8")}let s=Nn(n,!0)?.blockEnd??0,i;try{i=s===0?Ot(r):ae(n.subarray(s))}catch{throw new W("MARKDOWN_BODY_DECODING_FAILED","Markdown content is not valid UTF-8")}return{body:i,bodyBytes:Oe(i),sourceBytes:n.byteLength}};var ft=class extends Error{code;referenceId;constructor({code:t,message:n,referenceId:r,cause:o}){super(n,{cause:o}),this.name="MarkdownDocumentError",this.code=t,this.referenceId=r}},Pm=R({source:v(),body:v(),frontmatter:ge(v(),tt())}),Jr=e=>{let t;try{t=Pm.parse(e)}catch(n){throw new ft({code:"INVALID_DOCUMENT",message:"Markdown document is invalid",cause:n})}return Object.freeze({source:t.source,body:t.body,frontmatter:nt(t.frontmatter)})},Qr="#frontmatter",Lm=e=>`${Qr}${e.slice(1)}`,Mm=e=>{if(e!==Qr&&e.startsWith(`${Qr}/`)===!1)throw new ft({code:"UNUSED_REFERENCE",message:`Resolved Markdown reference ${e} is outside frontmatter`,referenceId:e});return`#${e.slice(Qr.length)}`},Zm=e=>{let t=e.referenceId===void 0?void 0:Lm(e.referenceId),n="INVALID_DOCUMENT";throw(e.code==="INVALID_REFERENCE_MARKER"||e.code==="INVALID_REFERENCE"||e.code==="REFERENCE_NOT_FOUND"||e.code==="INVALID_RESOLVED_VALUE"||e.code==="UNUSED_REFERENCE")&&(n=e.code),new ft({code:n,message:e.message,referenceId:t,cause:e})},Ql=async({source:e,maximumBytes:t=D.hydratedFileBytes})=>{let n;try{n=await pe(e,t)}catch(i){throw i instanceof te?new ft({code:"CONTENT_LIMIT_EXCEEDED",message:"Markdown document exceeds the byte limit",cause:i}):i}let r;try{r=Ot(ae(n))}catch(i){throw new ft({code:"CONTENT_DECODING_FAILED",message:"Markdown document is not valid UTF-8",cause:i})}let[o,s]=await Promise.all([Vr(n,t),Vl(n)]);return Jr({source:r,body:o.body,frontmatter:s.properties})};var Jl=({document:e,references:t,allowUnresolvedReferences:n=!1})=>{let r=Jr(e),o=new Map;for(let[i,c]of t)o.set(Mm(i),c);let s;try{s=ar({document:r.frontmatter,references:o,allowUnresolvedReferences:n})}catch(i){throw i instanceof ue&&Zm(i),i}return Jr({...r,frontmatter:s})},Gl=({document:e,representation:t})=>{let n=Jr(e);if(t.type==="document")return n.source;if(t.type==="markdown-body")return n.body;if(t.type==="markdown-frontmatter")return n.frontmatter;throw new ft({code:"UNSUPPORTED_REPRESENTATION",message:`Markdown documents do not support ${t.type}`})};var ql=e=>{let t=e.format==="markdown"?e.value.frontmatter:e.value;return Nt(t)?t:void 0},Gr=e=>Object.freeze(e),Kl=async({format:e,source:t,maximumBytes:n=D.hydratedFileBytes})=>Gr(e==="json"?{format:e,value:await qu({source:t,maximumBytes:n})}:{format:e,value:await Ql({source:t,maximumBytes:n})});var Wl=({document:e,references:t,allowUnresolvedReferences:n})=>e.format==="json"?Gr({format:e.format,value:ar({document:e.value,references:t,allowUnresolvedReferences:n})}):Gr({format:e.format,value:Jl({document:e.value,references:t,allowUnresolvedReferences:n})}),Yl=({document:e,representation:t})=>e.format==="json"?Ku({document:e.value,representation:t}):Gl({document:e.value,representation:t});var qr=class extends Error{code;documentId;expectedRevision;actualRevision;expectedFormat;actualFormat;constructor({code:t,documentId:n,expectedRevision:r,actualRevision:o,expectedFormat:s,actualFormat:i}){super(`Document ${n} source ${t==="REVISION_MISMATCH"?"revision":"format"} does not match its graph`),this.name="DocumentSourceError",this.code=t,this.documentId=n,this.expectedRevision=r,this.actualRevision=o,this.expectedFormat=s,this.actualFormat=i}},Vt=({node:e,source:t})=>{if(t.revision!==e.revision)throw new qr({code:"REVISION_MISMATCH",documentId:e.id,expectedRevision:e.revision,actualRevision:t.revision});if(e.format!==void 0&&t.format!==e.format)throw new qr({code:"FORMAT_MISMATCH",documentId:e.id,expectedFormat:e.format,actualFormat:t.format});return t};var Qt=e=>{if(typeof e=="object"&&e!==null){let t=Reflect.get(e,"code");if(typeof t=="string"&&t.length>0)return t;let n=Reflect.get(e,"name");if(typeof n=="string"&&n.length>0)return n}return"UNKNOWN"},re=(e,t)=>{try{e?.(t)}catch{}},Xl=({load:e,onEvent:t})=>async(n,r)=>{let o={documentId:n.id,revision:n.revision};re(t,{type:"document-fetch-started",...o});try{let s=await e(n,r);return re(t,{type:"document-fetch-completed",...o}),s}catch(s){throw re(t,{type:"document-fetch-failed",...o,errorCode:Qt(s)}),s}};var Fm=R({format:ce(["json","markdown"]),revision:v().min(1)}),Jt=class extends Error{code;documentId;status;constructor({code:t,message:n,documentId:r,status:o,cause:s}){super(n,{cause:s}),this.name="HttpDocumentLoaderError",this.code=t,this.documentId=r,this.status=o}},Bm=e=>({async*[Symbol.asyncIterator](){let t=e.getReader(),n=!1;try{for(;;){let r=await t.read();if(r.done){n=!0;return}yield r.value}}finally{if(n===!1)try{await t.cancel()}catch{}t.releaseLock()}}}),Hl=({fetch:e,getRequest:t,getMetadata:n,onEvent:r})=>Xl({load:async(s,{signal:i})=>{let c;try{c=await e(t(s),{signal:i})}catch(d){throw new Jt({code:"REQUEST_FAILED",message:`Document ${s.id} request failed`,documentId:s.id,cause:d})}if(c.ok===!1)throw new Jt({code:"HTTP_STATUS",message:`Document ${s.id} request returned status ${c.status}`,documentId:s.id,status:c.status});let a;try{a=Fm.parse(n({node:s,response:c}))}catch(d){throw new Jt({code:"INVALID_METADATA",message:`Document ${s.id} response metadata is invalid`,documentId:s.id,cause:d})}let u=c.body;if(u===null)throw new Jt({code:"BODY_MISSING",message:`Document ${s.id} response body is unavailable`,documentId:s.id});return Object.freeze({...a,source:Bm(u)})},onEvent:r});var Cn=class extends Error{code="CONTENT_LIMIT_EXCEEDED";documentId;contentByteLimit;constructor({message:t,documentId:n,contentByteLimit:r,cause:o}){super(t,{cause:o}),this.name="CachedDocumentLoaderError",this.documentId=n,this.contentByteLimit=r}},jm=({contentRef:e,revision:t,format:n})=>$e([e,t,n??null]),Um=e=>{if(typeof e!="object"||e===null)return!1;let t=e;return(t.format==="json"||t.format==="markdown")&&typeof t.revision=="string"&&t.revision.length>0&&t.bytes instanceof Uint8Array},ef=e=>Object.freeze({format:e.format,revision:e.revision,source:e.bytes}),tf=({load:e,cache:t,maximumBytes:n=D.hydratedFileBytes,onEvent:r})=>{let o=new Map;return async(s,i)=>{let c=jm(s),a=o.get(c)??new Map;o.set(c,a);let u=a.get(i.signal);if(u!==void 0)return await u;let d=(async()=>{let l;try{l=await t.get(c)}catch(m){re(r,{type:"document-cache-read-failed",documentId:s.id,revision:s.revision,errorCode:Qt(m)})}if(Um(l)&&l.revision===s.revision&&l.bytes.byteLength<=n&&(s.format===void 0||l.format===s.format))return re(r,{type:"document-cache-hit",documentId:s.id,revision:s.revision}),ef(l);re(r,{type:"document-cache-miss",documentId:s.id,revision:s.revision});let f=Vt({node:s,source:await e(s,i)}),p;try{p=await pe(f.source,n)}catch(m){throw m instanceof te?new Cn({message:`Document ${s.id} exceeds the cache byte limit`,documentId:s.id,contentByteLimit:n,cause:m}):m}let y=Object.freeze({format:f.format,revision:f.revision,bytes:p});try{await t.set(c,y),re(r,{type:"document-cache-stored",documentId:s.id,revision:s.revision})}catch(m){re(r,{type:"document-cache-write-failed",documentId:s.id,revision:s.revision,errorCode:Qt(m)})}return ef(y)})();a.set(i.signal,d);try{return await d}finally{a.delete(i.signal),a.size===0&&o.delete(c)}}};var Ke=class extends Error{code;documentId;referenceId;constructor({code:t,message:n,documentId:r,referenceId:o,cause:s}){super(n,{cause:s}),this.name="DocumentGraphResolutionError",this.code=t,this.documentId=r,this.referenceId=o}},Kr=e=>{if(e?.aborted)throw new Ke({code:"REQUEST_CANCELLED",message:"Document graph resolution was cancelled",cause:e.reason})},nf=async({graph:e,rootIds:t,concurrency:n,signal:r,load:o,select:s,assemble:i})=>{Kr(r);let c=rr({graph:e,rootIds:t}),a=new Map(c.map(p=>[p.id,p])),u=new Map,d=new Map;for(let p of c){let y=d.get(p.contentRef);y===void 0?d.set(p.contentRef,{representative:p,nodes:[p]}):y.nodes.push(p)}await cr([...d.values()],n,async p=>{Kr(r);let y=p.representative;try{let m=await o(y,{signal:r});for(let h of p.nodes)u.set(h.id,m)}catch(m){throw r?.aborted&&Kr(r),new Ke({code:"DOCUMENT_LOAD_FAILED",message:`Document ${y.id} could not be loaded`,documentId:y.id,cause:m})}});let l=$t(e.edges),f=new Map;for(let p of c){Kr(r);let y=new Map;for(let h of l.get(p.id)??[]){let b=a.get(h.reference.documentId);if(b===void 0||f.has(h.reference.documentId)===!1)throw new Ke({code:"DOCUMENT_ASSEMBLY_FAILED",message:`Document ${p.id} dependency ${h.reference.documentId} is unavailable`,documentId:p.id,referenceId:h.referenceId});let _=f.get(h.reference.documentId),x;if(s===void 0){if(h.reference.representation.type!=="document")throw new Ke({code:"REPRESENTATION_SELECTOR_REQUIRED",message:`Document ${p.id} reference ${h.referenceId} requires a representation selector`,documentId:p.id,referenceId:h.referenceId});x=_}else try{x=await s({reference:h.reference,value:_,sourceNode:p,targetNode:b})}catch(w){throw new Ke({code:"DOCUMENT_SELECTION_FAILED",message:`Document ${p.id} reference ${h.referenceId} could not be selected`,documentId:p.id,referenceId:h.referenceId,cause:w})}y.set(h.referenceId,x)}if(u.has(p.id)===!1)throw new Ke({code:"DOCUMENT_ASSEMBLY_FAILED",message:`Document ${p.id} source is unavailable`,documentId:p.id});let m=u.get(p.id);try{f.set(p.id,await i({node:p,source:m,references:y}))}catch(h){throw new Ke({code:"DOCUMENT_ASSEMBLY_FAILED",message:`Document ${p.id} could not be assembled`,documentId:p.id,cause:h})}}return Object.freeze({roots:Object.freeze(t.map(p=>f.get(p))),values:f})};var bt=class extends Error{code;documentId;documentCount;documentLimit;contentByteLimit;totalBytes;totalByteLimit;constructor({code:t,message:n,documentId:r,documentCount:o,documentLimit:s,contentByteLimit:i,totalBytes:c,totalByteLimit:a,cause:u}){super(n,{cause:u}),this.name="DocumentResolutionLimitError",this.code=t,this.documentId=r,this.documentCount=o,this.documentLimit=s,this.contentByteLimit=i,this.totalBytes=c,this.totalByteLimit=a}},rf=async({graph:e,rootIds:t,concurrency:n,maximumBytes:r=D.hydratedFileBytes,maximumTotalBytes:o=D.hydratedTotalBytes,maximumDocuments:s=D.hydratedFileCount,signal:i,load:c,onEvent:a,allowUnresolvedReferences:u=!1})=>{let d=rr({graph:e,rootIds:t}).length,l={rootCount:t.length,documentCount:d};re(a,{type:"resolution-started",...l});try{if(d>s)throw new bt({code:"DOCUMENT_COUNT_EXCEEDED",message:"Document graph resolution exceeds the document limit",documentCount:d,documentLimit:s});let f=0,p=await nf({graph:e,rootIds:t,concurrency:n,signal:i,load:async(y,m)=>{let h=Vt({node:y,source:await c(y,m)}),b;try{b=await pe(h.source,r)}catch(x){throw x instanceof te?new bt({code:"CONTENT_LIMIT_EXCEEDED",message:`Document ${y.id} exceeds the byte limit`,documentId:y.id,contentByteLimit:r,cause:x}):x}let _=f+b.byteLength;if(_>o)throw new bt({code:"TOTAL_BYTES_EXCEEDED",message:"Document graph resolution exceeds the total byte limit",documentId:y.id,totalBytes:_,totalByteLimit:o});return f=_,await Kl({format:h.format,source:b,maximumBytes:r})},select:({reference:y,value:m})=>Yl({document:m,representation:y.representation}),assemble:({source:y,references:m})=>Wl({document:y,references:m,allowUnresolvedReferences:u})});return re(a,{type:"resolution-completed",...l}),p}catch(f){throw re(a,{type:"resolution-failed",...l,errorCode:Qt(f)}),f}};var of=e=>{if(e.output.mode==="all")return"all";let t=[];for(let{field:n}of er(e.where))n[0]==="properties"&&t.push(n);for(let{field:n}of e.sort)n[0]==="properties"&&t.push(n);if(e.output.mode==="fields")for(let n of e.output.fields)n[0]==="properties"&&t.push(n);return t},sf=e=>{let t;if(e==="#frontmatter")t="";else if(e.startsWith("#frontmatter/"))t=e.slice(12);else if(e==="#")t="";else if(e.startsWith("#/"))t=e.slice(1);else return;try{return["properties",...Ju(t)]}catch{return}},cf=(e,t)=>{let n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1)if(e[r]!==t[r])return!1;return!0},af=({queryPaths:e,referenceId:t})=>{let n=sf(t);return n!==void 0&&(e==="all"||e.some(r=>cf(r,n)))},uf=({graph:e,sourceId:t,field:n})=>n[0]!=="properties"?!1:e.edges.some(r=>{if(r.sourceId!==t)return!1;let o=sf(r.referenceId);return o!==void 0&&cf(n,o)}),lf=({graph:e,query:t})=>{let n=of(t),r=new Set;for(let o of e.edges)af({queryPaths:n,referenceId:o.referenceId})&&r.add(o.sourceId);return[...r]},ff=({graph:e,query:t,rootIds:n})=>{let r=of(t),o=new Set(n),s=new Map(e.nodes.map(l=>[l.id,l])),i=$t(e.edges),c=new Set(n),a=new Set,u=new Set,d=l=>{if(c.add(l),!u.has(l)){u.add(l);for(let f of i.get(l)??[])a.add(f),d(f.reference.documentId)}};for(let l of e.edges)o.has(l.sourceId)&&af({queryPaths:r,referenceId:l.referenceId})&&(a.add(l),d(l.reference.documentId));return ln({nodes:[...c].map(l=>{let f=s.get(l);if(f===void 0)throw new Error(`Document graph query root ${l} does not exist`);return f}),edges:[...a]})};var df=({artifact:e})=>{if(e.documentGraph===void 0)return;let t=new Map(e.documents.map(s=>[s._id,s])),n=new Map(e.documentGraph.nodes.map(s=>[s.id,s])),r=new Map;for(let{sourceId:s}of e.documentGraph.edges){if(n.has(s))continue;let i=t.get(s);if(i?.properties===void 0)throw new Error(`Runtime document graph source ${s} is unavailable`);r.set(s,i),n.set(s,{id:s,revision:s,contentRef:s,format:"json"})}return{graph:ln({nodes:[...n.values()],edges:e.documentGraph.edges.map(({sourceId:s,referenceId:i,documentId:c,representation:a})=>{let u=n.get(c);if(u===void 0)throw new Error(`Runtime document graph target ${c} is unavailable`);return{sourceId:s,referenceId:i,reference:{documentId:c,revision:u.revision,representation:a}}})}),inlineDocuments:r}};var Vm=(e,t)=>{if(t===void 0||t.length===0)return e;let n=new URL("https://content.webstudio.invalid/__assets__/"),r=new URL(e,n),o=new URL(t,n);for(let[c,a]of o.searchParams)r.searchParams.append(c,a);if(o.hash!==""&&(r.hash=o.hash),URL.canParse(e))return r.href;if(e.startsWith("//"))return`//${r.host}${r.pathname}${r.search}${r.hash}`;if(e.startsWith("/"))return`${r.pathname}${r.search}${r.hash}`;let s=n.pathname;return`${r.pathname.startsWith(s)?r.pathname.slice(s.length):r.pathname}${r.search}${r.hash}`},pf=({markdown:e,references:t,assetUrls:n})=>{let r=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>r)throw new Error("Markdown asset reference range is invalid");r=s.start;let i=n[s.assetId];if(i===void 0)continue;let c=Vm(i,s.suffix);o=`${o.slice(0,s.start)}${c}${o.slice(s.end)}`}return o};var oe=class extends Error{code;details;constructor({code:t,message:n,details:r}){super(n),this.name="AssetResourceHydrationError",this.code=t,this.details=r}},Qm=e=>{if(e===null)return[];let t=Array.isArray(e)?e:[e],n=new Map;for(let r of t){if(typeof r!="object"||r===null||!("_id"in r)||typeof r._id!="string"||!("revision"in r)||typeof r.revision!="string"||!("contentRef"in r)||typeof r.contentRef!="string")throw new oe({code:"CONTENT_IDENTITY_REQUIRED",message:"Hydrated query results must retain _id, revision, and contentRef"});let o=n.get(r._id);if(o!==void 0&&(o.revision!==r.revision||o.contentRef!==r.contentRef))throw new oe({code:"CONTENT_IDENTITY_REQUIRED",message:"A selected asset ID has conflicting content identity",details:{assetId:r._id}});n.set(r._id,{_id:r._id,revision:r.revision,contentRef:r.contentRef})}return Array.from(n.values())},Jm=e=>typeof e.mimeType=="string"&&(e.mimeType.startsWith("text/")||["application/json","application/javascript","application/xml","image/svg+xml"].includes(e.mimeType)),Gm=async({read:e,contentRef:t,range:n,maximumBytes:r})=>{if(r===0)return new Uint8Array;let o=await e(t,n);try{return await pe(o.data,r)}catch(s){throw s instanceof te?new oe({code:"CONTENT_LIMIT_EXCEEDED",message:"Asset storage returned more content than requested"}):s}},qm=e=>{try{return ae(e)}catch{throw new oe({code:"CONTENT_DECODING_FAILED",message:"Selected asset content is not valid UTF-8"})}},Km=(e,t)=>{if(t.mode==="range")return Math.max(0,Math.min(t.length,e.size-t.offset));let n=t.maxBytes??D.hydratedFileBytes;if(e.size>n)throw new oe({code:"CONTENT_LIMIT_EXCEEDED",message:"Selected asset exceeds the per-file content limit",details:{assetId:e._id,assetBytes:e.size,fileByteLimit:n}});return e.size},mf=async({result:e,documents:t,options:n,read:r,assetReferences:o,assetUrls:s})=>{if(n.mode==="none")return{content:{},hydratedFileCount:0,hydratedBytes:0};let i=Qm(e);if(i.length>D.hydratedFileCount)throw new oe({code:"CONTENT_LIMIT_EXCEEDED",message:"Too many selected assets requested content hydration",details:{fileCount:i.length,fileCountLimit:D.hydratedFileCount}});let c=new Map(t.map(l=>[l._id,l])),a=i.map(l=>{let f=c.get(l._id);if(f===void 0||f.revision!==l.revision||f.contentRef!==l.contentRef||typeof f.size!="number"||typeof f.mimeType!="string")throw new oe({code:"CONTENT_IDENTITY_REQUIRED",message:"Selected asset content identity is stale or unavailable",details:{assetId:l._id}});let p={...f,size:f.size,mimeType:f.mimeType};if(Jm(p)===!1)throw new oe({code:"CONTENT_NOT_TEXT",message:"Selected binary asset cannot be embedded as text",details:{assetId:l._id,mimeType:p.mimeType}});return{identity:l,document:p,readLength:Km(p,n)}}),u=a.reduce((l,f)=>l+f.readLength,0);if(u>D.hydratedTotalBytes)throw new oe({code:"CONTENT_LIMIT_EXCEEDED",message:"Selected assets exceed the total hydrated-content limit",details:{totalReadBytes:u,totalByteLimit:D.hydratedTotalBytes}});let d=await cr(a,D.concurrentContentReads,async l=>{let f=n.mode==="range"?{offset:n.offset,length:l.readLength}:l.readLength===0?void 0:{offset:0,length:l.readLength},p=await Gm({read:r,contentRef:l.identity.contentRef,range:f,maximumBytes:l.readLength});if(p.byteLength!==l.readLength)throw new oe({code:"CONTENT_IDENTITY_REQUIRED",message:"Selected asset bytes do not match canonical metadata",details:{assetId:l.identity._id}});let y;if(n.mode==="markdown-body-ref")try{y=(await Vr(p,l.readLength||1)).body;let h=o?.[l.identity.contentRef];h!==void 0&&s!==void 0&&(y=pf({markdown:y,references:h,assetUrls:s}))}catch{throw new oe({code:"CONTENT_DECODING_FAILED",message:"Selected Markdown body could not be decoded",details:{assetId:l.identity._id}})}else y=qm(p);let m=Oe(y);return{id:l.identity._id,returnedBytes:m,content:{...l.identity,encoding:"utf-8",text:y,...n.mode==="range"?{range:{offset:n.offset,length:p.byteLength,total:l.document.size}}:{}}}});return{content:Object.fromEntries(d.map(({id:l,content:f})=>[l,f])),hydratedFileCount:a.length,hydratedBytes:d.reduce((l,{returnedBytes:f})=>l+f,0)}};var rk=v().datetime({offset:!0}).transform(e=>new Date(e).toISOString());var Wm=/^[A-Za-z_][A-Za-z0-9_]*$/,hf=(e,t)=>Wm.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`;var yf=({document:e,includes:t})=>{let n={};for(let r of Fu){let o=e[r];o!==void 0&&t(r)&&(n[r]=o)}return n},gf=({source:e,target:t,path:n})=>{let[r,...o]=n;if(r===void 0||Object.hasOwn(e,r)===!1)return;let s=e[r];if(o.length===0){Object.defineProperty(t,r,{value:s,enumerable:!0,configurable:!0,writable:!0});return}if(typeof s!="object"||s===null||Array.isArray(s))return;let i={};if(gf({source:s,target:i,path:o}),Object.keys(i).length===0)return;let c=t[r];Object.defineProperty(t,r,{value:{...typeof c=="object"&&c!==null&&Array.isArray(c)===!1?c:{},...i},enumerable:!0,configurable:!0,writable:!0})},bf=({properties:e,fields:t})=>{let n={};for(let r of t)r[0]==="properties"&&gf({source:e,target:n,path:r.slice(1)});return n};var Ym=(e,t)=>{if(t===void 0)return e;let n="https://content.webstudio.invalid",r=new URL(e,`${n}/`),o=new URL(t,`${n}/`);for(let[s,i]of o.searchParams)r.searchParams.append(s,i);return o.hash!==""&&(r.hash=o.hash),e.startsWith("//")?`//${r.host}${r.pathname}${r.search}${r.hash}`:e.startsWith("/")?`${r.pathname}${r.search}${r.hash}`:r.href},xs=({value:e,path:t,replacement:n})=>{let[r,...o]=t;if(r===void 0)return n;if(typeof e!="object"||e===null||Object.hasOwn(e,r)===!1)return e;if(Array.isArray(e)){if(typeof r!="number")return e;let s=[...e];return s[r]=xs({value:e[r],path:o,replacement:n}),s}return typeof r!="string"?e:{...e,[r]:xs({value:e[r],path:o,replacement:n})}},Gt=({value:e,references:t,assetUrls:n})=>{let r=e;for(let o of t??[]){let s=n[o.assetId];s!==void 0&&(r=xs({value:r,path:o.path,replacement:Ym(s,o.suffix)}))}return r};var Be=class extends Error{constructor(t,n){super(t,n),this.name="AssetQueryExecutionError"}},Kt=class extends Error{constructor(){super("The requested asset index revision is stale"),this.name="AssetIndexRevisionError"}},wf=e=>{if(e[0]!=="properties")return e[0];let t="properties";for(let n of e.slice(1))t=hf(t,n);return t},_f=({filter:e,fieldTypes:t})=>Uu(t).includes(e.operator),xf=(e,t)=>e!==void 0&&Object.hasOwn(e.fields,t)?e.fields[t]:void 0,Xm=({query:e,catalog:t})=>{let n=rt.parse(e),r=new Map,o=[];for(let s of er(n.where)){let i=wf(s.field);if(r.set(i,s.field),s.field[0]==="properties"){let c=xf(t,i);t!==void 0&&c===void 0?o.push(`Asset field ${i} is not currently observed`):c!==void 0&&_f({filter:s,fieldTypes:c.types})===!1&&o.push(`Operator ${s.operator} is not compatible with the currently observed types of ${i}`)}else if(_f({filter:s,fieldTypes:jo[s.field[0]]})===!1)throw new Be(`Operator ${s.operator} is incompatible with ${i}`)}for(let s of n.sort){let i=wf(s.field);if(r.set(i,s.field),s.field[0]==="properties"){let c=xf(t,i);t!==void 0&&c===void 0?o.push(`Asset field ${i} is not currently observed`):c!==void 0&&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:n,referencedFieldPaths:[...r.values()],warnings:[...new Set(o)]}},Es=(e,t,n)=>{let r=t[0]==="id"?e._id:sr(t[0])?n?.[t[0]]:e[t[0]];for(let o of t.slice(1)){if(typeof r!="object"||r===null||Object.hasOwn(r,o)===!1)return;r=r[o]}return r},Hm=e=>typeof e=="string"||Array.isArray(e)?e.length===0:typeof e=="object"&&e!==null&&Object.keys(e).length===0,eh=(e,t)=>{if(typeof e=="number"&&typeof t=="number")return e-t;if(typeof e=="string"&&typeof t=="string")return Ne(e,t)},Ss=(e,t,n)=>{let r=Es(e,t.field,n);if(t.operator==="exists")return r!=null===t.value;if(t.operator==="isEmpty")return Hm(r)===t.value;if(t.operator==="eq")return un(r,t.value);if(t.operator==="ne")return un(r,t.value)===!1;if(t.operator==="in")return t.value.some(s=>un(r,s));if(t.operator==="contains")return typeof r=="string"&&typeof t.value=="string"?r.includes(t.value):Array.isArray(r)&&r.some(s=>un(s,t.value));if(t.operator==="startsWith")return typeof r=="string"&&typeof t.value=="string"&&r.startsWith(t.value);if(t.operator==="endsWith")return typeof r=="string"&&typeof t.value=="string"&&r.endsWith(t.value);let o=eh(r,t.value);return o===void 0?!1:t.operator==="gt"?o>0:t.operator==="gte"?o>=0:t.operator==="lt"?o<0:o<=0},th=(e,t,n)=>Dt(t,r=>Ss(e,r,n))===!0,nh=({document:e,content:t})=>t.mode!=="markdown-body-ref"||e.mimeType==="text/markdown"||e.extension==="md",rh=(e,t)=>{let n=e==null,r=t==null;return n||r?n===r?0:n?1:-1:typeof e=="number"&&typeof t=="number"?e-t:(typeof e=="string"||typeof e=="boolean")&&(typeof t=="string"||typeof t=="boolean")?Ne(String(e),String(t)):Ne($e(e),$e(t))},oh=({left:e,right:t,sort:n,runtimeAssets:r})=>{for(let o of n){let s=rh(Es(e,o.field,r?.[e._id]),Es(t,o.field,r?.[t._id]));if(s!==0)return o.direction==="asc"?s:-s}return Ne(e._id,t._id)};var sh=(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(r=>r[0]==="properties")===!1)return;let n=bf({properties:e.properties,fields:t.fields});return Object.keys(n).length===0?void 0:n},qt=(e,t)=>e.includeMetadata&&Bu(t)||e.mode==="fields"&&e.fields.some(n=>n.length===1&&n[0]===t),ih=e=>e.mode==="all"||e.mode==="fields"&&e.fields.some(t=>t.length===1&&t[0]==="excerpt"),ch=(e,t,n)=>{if(qt(t,"url")&&n===void 0)throw new Error(`Asset URL is unavailable for ${e._id}`);let r=sh(e,t),o=n?.width!==void 0&&n.height!==void 0;return{...n!==void 0&&qt(t,"url")?{url:n.url}:{},...o&&qt(t,"width")?{width:n.width}:{},...o&&qt(t,"height")?{height:n.height}:{},...yf({document:e,includes:s=>qt(t,s)}),...r===void 0?{}:{properties:r},...e.excerpt===void 0||ih(t)===!1?{}:{excerpt:e.excerpt},...e.metadataError===void 0||t.includeMetadata===!1?{}:{metadataError:e.metadataError}}},vs=e=>{if(Oe($e(e))>D.resultBytes)throw new Be("Asset query result exceeds the byte limit")},ks=async({query:e,catalog:t,documents:n,read:r,runtimeAssets:o,assetReferences:s,assetValueReferences:i})=>{let{query:c}=Xm({query:e,catalog:t});if(n.length>D.candidateDocuments)throw new Be("Asset query document limit was exceeded");let a=Object.fromEntries(Object.entries(o??{}).map(([h,b])=>[h,b.url])),d=n.map(h=>Gt({value:h,references:i?.[h._id],assetUrls:a})).flatMap(h=>{let b=o?.[h._id];if(nh({document:h,content:c.content})===!1||th(h,c.where,b)===!1)return[];let _=ch(h,c.output,b);return c.content.mode==="none"&&Object.keys(_).length===0&&qt(c.output,"id")===!1?[]:[{document:h,item:{id:h._id,..._}}]}),f=[...d].sort((h,b)=>oh({left:h.document,right:b.document,sort:c.sort,runtimeAssets:o})).slice(c.offset,c.offset+c.limit),p=f.map(({document:h})=>h),y=f.map(({item:h})=>h);if(c.content.mode!=="none"){let h=c.content;if(r===void 0)throw new Be("Asset content reader is unavailable");let b=await mf({result:p,documents:p,options:h,read:r,assetReferences:s,assetUrls:s===void 0?void 0:a});y=p.map((_,x)=>{let w=b.content[_._id];if(w===void 0)throw new Be("Selected asset content could not be read");return{...y[x],content:{encoding:w.encoding,text:w.text,...w.range===void 0?{}:{range:w.range}}}})}let m={items:y,totalCount:d.length,hasMore:c.offset+f.length<d.length};return vs(m),m};var ah=async e=>await Ru($e(rt.parse(e)));var uh=({item:e,field:t,value:n})=>{let r=e;for(let[o,s]of t.entries()){if(o===t.length-1){Object.defineProperty(r,s,{value:n,enumerable:!0,configurable:!0,writable:!0});return}let i=Object.hasOwn(r,s)?r[s]:void 0;if(typeof i=="object"&&i!==null){r=i;continue}let c={};Object.defineProperty(r,s,{value:c,enumerable:!0,configurable:!0,writable:!0}),r=c}},lh=e=>ir.parse({items:e.rows.map(t=>{let n={};for(let[r,o]of e.fields.entries())uh({item:n,field:o,value:t[r]});return n}),totalCount:e.totalCount,hasMore:e.hasMore}),Ef=async({queries:e,query:t,assetValueReferences:n,assetUrls:r={}})=>{if(e===void 0)return;let o=e[await ah(rt.parse(t))];if(o===void 0)return;let s=lh(o),i={...s,items:s.items.map(c=>Gt({value:c,references:n?.[c.id],assetUrls:r}))};return vs(i),i};var fh=(e,t)=>t===void 0?Rt(e):{async*[Symbol.asyncIterator](){let n=0,r=0;for await(let o of Rt(e)){if(r===t.length)return;if(n+o.byteLength<=t.offset){n+=o.byteLength;continue}let s=Math.max(0,t.offset-n),i=Math.min(o.byteLength-s,t.length-r);i>0&&(yield o.subarray(s,s+i),r+=i),n+=o.byteLength}}},dh=({graph:e,load:t,signal:n})=>{let r=new Map(e.nodes.map(o=>[o.contentRef,o]));return async(o,s)=>{let i=r.get(o);if(i===void 0)throw new Error(`Document content reference ${o} is unavailable`);let c=Vt({node:i,source:await t(i,{signal:n})});return{data:fh(c.source,s),...s===void 0?{}:{contentLength:s.length}}}},ph=({artifact:e,revision:t,catalog:n,documentGraph:r,inlineDocuments:o,readContent:s})=>{let i=async(a,u,d,l)=>{if(a.indexRevision!==void 0&&a.indexRevision!==t)throw new Kt;let f=Object.fromEntries(Object.entries(d??{}).map(([h,b])=>[h,b.url])),p=l?.skipMaterialized===!0?void 0:await Ef({queries:e.queries,query:a.query,assetValueReferences:e.assetValueReferences,assetUrls:f});if(p!==void 0)return p;let y=async(h,b)=>{let _=e.contents?.[h];if(_===void 0){let S=u??s;if(S===void 0)throw new Error("Content is not embedded in this database");return await S(h,b)}let x=It(_),w=b===void 0?x:x.slice(b.offset,b.offset+b.length);return{data:async function*(){yield w}(),contentLength:w.byteLength}};return await ks({query:a.query,catalog:n,documents:l?.documents??e.documents,read:y,runtimeAssets:d,assetReferences:e.assetReferences,assetValueReferences:e.assetValueReferences})};return{query:async(...a)=>await i(...a),queryWithDocumentGraph:async({request:a,load:u,readContent:d,runtimeAssets:l,signal:f,onEvent:p})=>{if(r===void 0)return await i(a,d,l);let y=d??dh({graph:r,load:u,signal:f}),m=rt.parse(a.query),h=new Map(e.documents.map(k=>[k._id,k])),b=lf({graph:r,query:m}).filter(k=>{let $=h.get(k),E=$===void 0?void 0:Gt({value:$,references:e.assetValueReferences?.[k],assetUrls:Object.fromEntries(Object.entries(l??{}).map(([U,Ie])=>[U,Ie.url]))});return E===void 0?!1:Dt(m.where,U=>{if(!uf({graph:r,sourceId:k,field:U.field}))return Ss(E,U,l?.[k])})!==!1});if(b.length===0)return await i(a,y,l);let _=ff({graph:r,query:m,rootIds:b});re(p,{type:"roots-selected",rootCount:b.length});let x=await rf({graph:_,rootIds:b,load:async(k,$)=>{let E=o?.get(k.id);return E!==void 0?{format:"json",revision:k.revision,source:JSON.stringify(E.properties)}:await u(k,$)},concurrency:D.concurrentContentReads,signal:f,onEvent:p,allowUnresolvedReferences:!0}),w=new Map(b.flatMap((k,$)=>{let E=ql(x.roots[$]);return E===void 0?[]:[[k,E]]})),S=e.documents.map(k=>{let $=w.get(k._id);return $===void 0?k:Bo.parse({...k,properties:$})});return await i(a,y,l,{documents:S,skipMaterialized:!0})}}};var As=({artifact:e,readContent:t})=>{let n=df({artifact:e});return ph({artifact:e,revision:e.revision,documentGraph:n?.graph,inlineDocuments:n?.inlineDocuments,readContent:t})};var Wr=class extends Error{constructor(t,n){super(t,n),this.name="AssetQueryRequestError"}},Tn=class extends Error{},mh=async(e,t)=>{if(Number.isSafeInteger(t)===!1||t<0)throw new TypeError("Request byte limit must be a non-negative integer");let n=Number(e.headers.get("content-length"));if(Number.isFinite(n)&&n>t)throw new Tn("Request exceeds the byte limit");let r=e.body?.getReader(),o=[],s=0;if(r!==void 0)for(;;){let{done:a,value:u}=await r.read();if(a)break;if(s+=u.byteLength,s>t){try{await r.cancel()}catch{}throw new Tn("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},Sf=async e=>{let t;try{t=await mh(e,D.requestBytes)}catch(n){throw n instanceof Tn?new Wr("Asset query request exceeds the byte limit",{cause:n}):n}try{return Vu.parse(JSON.parse(ae(t)))}catch(n){throw new Wr("Asset query request is invalid",{cause:n})}};var vf=e=>{if(e instanceof Kt)return{code:"STALE_INDEX",message:e.message,retryable:!1,status:409};if(e instanceof Be)return{code:"INVALID_REQUEST",message:e.message,retryable:!1,status:400};if(e instanceof oe)return{code:e.code,message:e.message,retryable:!1,details:e.details,status:400};let t=new Set,n=e;for(;n!==void 0&&t.has(n)===!1;){if(n instanceof bt){let r={};for(let[o,s]of Object.entries({assetId:n.documentId,documentCount:n.documentCount,documentLimit:n.documentLimit,contentByteLimit:n.contentByteLimit,totalBytes:n.totalBytes,totalByteLimit:n.totalByteLimit}))s!==void 0&&(r[o]=s);return{code:"CONTENT_LIMIT_EXCEEDED",message:n.message,retryable:!1,details:r,status:400}}if(n instanceof Cn)return{code:"CONTENT_LIMIT_EXCEEDED",message:n.message,retryable:!1,details:{assetId:n.documentId,contentByteLimit:n.contentByteLimit},status:400};t.add(n),n=n instanceof Error?n.cause:void 0}};var hh="/$resources/assets",kf=(e,t=200)=>new Response(JSON.stringify(e),{status:t,headers:{"content-type":"application/json; charset=utf-8"}}),zn=({code:e,message:t,status:n,retryable:r=!1,details:o})=>kf(Qu({code:e,message:t,retryable:r,details:o}),n),yh=(e,t,n)=>typeof e=="string"||e instanceof URL?new Request(new URL(e,t),n):new Request(e,n),gh=async({deploymentId:e,artifact:t,request:n})=>{let r=await n.clone().text(),o=n.headers.get("cache-control"),s=await Mo(JSON.stringify([e,t.revision,r,o])),i=new URL(n.url);return i.searchParams.set("ws-asset-resource",s),new Request(i,{method:"GET"})},Kk=({deploymentId:e,artifact:t,runtimeAssets:n,cache:r,baseUrl:o,fetchDocument:s=globalThis.fetch,onDocumentGraphEvent:i})=>{Df({artifact:t,runtimeAssets:n});let c=Af();return If({deploymentId:e,artifact:t,runtimeAssets:n,cache:r,baseUrl:o,database:As({artifact:t}),fetchDocument:s,documentCache:c,onDocumentGraphEvent:i})},Af=()=>{let e=new Map,t=D.hydratedTotalBytes*4,n=0;return{get:async r=>{let o=e.get(r);return o!==void 0&&(e.delete(r),e.set(r,o)),o},set:async(r,o)=>{if(o.bytes.byteLength>t)return;let s=e.get(r);for(s!==void 0&&(n-=s.bytes.byteLength,e.delete(r)),e.set(r,o),n+=o.bytes.byteLength;n>t;){let i=e.entries().next().value;if(i===void 0)break;e.delete(i[0]),n-=i[1].bytes.byteLength}}}},bh=({baseUrl:e,runtimeAssets:t,fetchDocument:n,cache:r,onEvent:o})=>tf({cache:r,onEvent:o,load:Hl({fetch:n,getRequest:s=>{let i=t[s.id];if(i===void 0)throw new Error(`Published document URL is unavailable for ${s.id}`);return new URL(i.url,e)},getMetadata:({node:s})=>({format:s.format,revision:s.revision}),onEvent:o})}),Df=({artifact:e,runtimeAssets:t})=>{let n=[e.assetReferences,e.assetValueReferences].flatMap(s=>Object.values(s??{}).flat()).map(({assetId:s})=>s).find(s=>t[s]===void 0);if(n!==void 0)throw new Error(`Published referenced asset URL is unavailable for ${n}`);let r=e.documentGraph?.nodes.find(({id:s})=>t[s]===void 0)?.id;if(r!==void 0)throw new Error(`Published document URL is unavailable for ${r}`);let o=e.documentGraph?.nodes.find(({id:s,contentRef:i})=>t[s]?.contentRef!==i)?.id;if(o!==void 0)throw new Error(`Published document identity does not match graph node ${o}`)},If=({deploymentId:e,artifact:t,runtimeAssets:n,cache:r,baseUrl:o,database:s,fetchDocument:i,documentCache:c,onDocumentGraphEvent:a})=>{let u=new URL(o).origin,d=bh({baseUrl:o,runtimeAssets:n,fetchDocument:i,cache:c,onEvent:a});return async(l,f)=>{let p=yh(l,o,f),y=new URL(p.url);if(y.origin!==u||y.pathname!==hh||p.method.toUpperCase()!=="POST")return;let m;try{m=await Sf(p.clone())}catch{return zn({code:"INVALID_REQUEST",message:"Asset resource request is invalid",status:400})}let h=r===void 0||p.headers.has("cache-control")===!1?void 0:await gh({deploymentId:e,artifact:t,request:p});if(h!==void 0&&r!==void 0){let b=await r.match(h).catch(()=>{});if(b!==void 0)return new Response(b.body,b)}try{if(p.signal.aborted)return zn({code:"REQUEST_CANCELLED",message:"Published asset query was cancelled",status:499});let b=kf(await s.queryWithDocumentGraph({request:m,load:d,runtimeAssets:n,signal:p.signal,onEvent:a}));return h!==void 0&&r!==void 0&&p.signal.aborted===!1&&(b.headers.set("cache-control",p.headers.get("cache-control")),await r.put(h,b.clone()).catch(()=>{})),b}catch(b){if(p.signal.aborted)return zn({code:"REQUEST_CANCELLED",message:"Published asset query was cancelled",status:499});let _=vf(b);return zn(_!==void 0?_:{code:"INTERNAL_ERROR",message:"Published asset query failed",status:500,retryable:!0})}}},Wk=({deploymentId:e,artifact:t,runtimeAssets:n,onDocumentGraphEvent:r=void 0})=>{let o=globalThis.caches,s,i=()=>(s??=o.open(`webstudio-assets-${e}`),s),c=o===void 0?void 0:{match:async d=>(await i()).match(d),put:async(d,l)=>(await i()).put(d,l)};Df({artifact:t,runtimeAssets:n});let a=As({artifact:t}),u=Af();return async({request:d,fallback:l})=>{let f=new URL(d.url).origin,p=If({deploymentId:e,artifact:t,runtimeAssets:n,cache:c,baseUrl:f,database:a,fetchDocument:l,documentCache:u,onDocumentGraphEvent:r});return async(y,m)=>await p(y,m)??l(y,m)}};export{Wk as createGeneratedAssetResourceRuntime,Kk as createPublishedAssetResourceFetch};diff --git a/packages/asset-uploader/src/asset-repository.ts b/packages/asset-uploader/src/asset-repository.tsindex 0ff17b625d..14addf6445 100644--- a/packages/asset-uploader/src/asset-repository.ts+++ b/packages/asset-uploader/src/asset-repository.ts@@ -578,24 +578,36 @@ export class PostgresAssetRepository implements AssetRepository {assetReferences: Parameters<typeof createAssetIndex>[0]["assetReferences"],+ assetValueReferences: Parameters<+ typeof createAssetIndex+ >[0]["assetValueReferences"],documentGraph: Parameters<typeof createAssetIndex>[0]["documentGraph"]) =>await this.dependencies.createAssetIndex({projectId: this.projectId,entries,assetReferences,+ ...(assetValueReferences === undefined ||+ Object.keys(assetValueReferences).length === 0+ ? {}+ : { assetValueReferences }),documentGraph,maxBytes: this.contentDatabaseMaxBytes,...(requirements === undefined ? {} : { plan: requirements }),});if (this.compilationCache === undefined) {- const { entries, assetReferences, documentGraph } =+ const { entries, assetReferences, assetValueReferences, documentGraph } =await materializeContentSource({source,plan: requirements,maximumContentBytes: this.contentDatabaseMaxBytes,});- return await compile(entries, assetReferences, documentGraph);+ return await compile(+ entries,+ assetReferences,+ assetValueReferences,+ documentGraph+ );}for (let attempt = 0; attempt < 2; attempt += 1) {const snapshot = await source.openSnapshot();@@ -608,13 +620,22 @@ export class PostgresAssetRepository implements AssetRepository {});try {return await this.compilationCache.getOrCreate(key, async () => {- const { entries, assetReferences, documentGraph } =- await materializeContentSnapshot({- snapshot,- plan: requirements,- maximumContentBytes: this.contentDatabaseMaxBytes,- });- return await compile(entries, assetReferences, documentGraph);+ const {+ entries,+ assetReferences,+ assetValueReferences,+ documentGraph,+ } = await materializeContentSnapshot({+ snapshot,+ plan: requirements,+ maximumContentBytes: this.contentDatabaseMaxBytes,+ });+ return await compile(+ entries,+ assetReferences,+ assetValueReferences,+ documentGraph+ );});} catch (error) {if (error instanceof ContentSourceChangedError === false) {diff --git a/packages/asset-uploader/src/content-compilation-cache.test.ts b/packages/asset-uploader/src/content-compilation-cache.test.tsindex 72211619d9..f706e3cc06 100644--- a/packages/asset-uploader/src/content-compilation-cache.test.ts+++ b/packages/asset-uploader/src/content-compilation-cache.test.ts@@ -2,6 +2,7 @@ import { describe, expect, test, vi } from "vitest";import type { ContentArtifactV1 } from "@webstudio-is/content-engine";import {canonicalAssetMetadataExtractorGeneration,+ contentCompilationGeneration,createAssetIndex,} from "@webstudio-is/content-engine/compiler";import {@@ -14,7 +15,7 @@ const artifact = (revision: string) =>({ integrity: { checksum: revision } }) as ContentArtifactV1;describe("content compilation cache", () => {- test("keys compiled artifacts by metadata extraction generation", () => {+ test("keys compiled artifacts by compiler generations", () => {const key = createContentCompilationCacheKey({projectId: "project",sourceRevision: "source",@@ -24,6 +25,7 @@ describe("content compilation cache", () => {expect(JSON.parse(key)).toMatchObject({metadataExtractorGeneration: canonicalAssetMetadataExtractorGeneration,+ contentCompilationGeneration,});});diff --git a/packages/asset-uploader/src/content-compilation-cache.ts b/packages/asset-uploader/src/content-compilation-cache.tsindex a1a22216cd..c6623ba4a3 100644--- a/packages/asset-uploader/src/content-compilation-cache.ts+++ b/packages/asset-uploader/src/content-compilation-cache.ts@@ -5,6 +5,7 @@ import {} from "@webstudio-is/content-engine";import {canonicalAssetMetadataExtractorGeneration,+ contentCompilationGeneration,serializeJsonDeterministically,} from "@webstudio-is/content-engine/compiler";@@ -29,6 +30,7 @@ export const createContentCompilationCacheKey = ({projectId,sourceRevision,metadataExtractorGeneration: canonicalAssetMetadataExtractorGeneration,+ contentCompilationGeneration,plan: plan ?? null,strict,maxBytes,diff --git a/packages/content-engine/src/asset-index.test.ts b/packages/content-engine/src/asset-index.test.tsindex 5ba72f7e2a..2775d7148f 100644--- a/packages/content-engine/src/asset-index.test.ts+++ b/packages/content-engine/src/asset-index.test.ts@@ -46,7 +46,7 @@ const entry = ({});describe("shared asset index", () => {- test("selects runtime assets from documents and Markdown references", () => {+ test("selects runtime assets from documents and content references", () => {const artifact = {documents: [{ _id: "document" }, { _id: "shared" }],assetReferences: {@@ -55,18 +55,24 @@ describe("shared asset index", () => {{ start: 2, end: 3, assetId: "shared" },],},+ assetValueReferences: {+ document: [+ { path: ["properties", "image"], assetId: "structured-reference" },+ ],+ },};expect(getContentArtifactReferencedAssetIds(artifact)).toEqual(["reference","shared",+ "structured-reference",]);expect(getContentArtifactRuntimeAssetIds({artifact,includeDocuments: true,})- ).toEqual(["document", "reference", "shared"]);+ ).toEqual(["document", "reference", "shared", "structured-reference"]);});test("stores only fields required by an ID-only query", async () => {@@ -330,6 +336,66 @@ describe("shared asset index", () => {);});+ test("keeps queries that evaluate structured Asset values in the runtime database", async () => {+ const post = createCanonicalAssetFileEntry({+ projectId: "project",+ document: {+ ...entry({ id: "post" }).document,+ properties: { featureImage: "./assets/hero.png" },+ },+ });+ const query = assetQuery.parse({+ where: {+ all: [+ {+ field: ["properties", "featureImage"],+ operator: "eq",+ value: "/cgi/image/hero.png?format=raw",+ },+ ],+ },+ sort: [{ field: ["properties", "featureImage"], direction: "asc" }],+ output: {+ mode: "fields",+ includeMetadata: false,+ fields: [["properties", "featureImage"]],+ },+ content: { mode: "none" },+ });+ const { artifact } = await compileContentArtifact({+ projectId: "project",+ entries: [post],+ assetValueReferences: {+ post: [+ {+ path: ["properties", "featureImage"],+ assetId: "hero",+ },+ ],+ },+ plan: createContentCompilationPlan([+ createLiteralContentCompilationQuery({ id: "post", query }),+ ]),+ });++ expect(artifact.queries).toBeUndefined();+ expect(artifact.documents).toHaveLength(1);+ await expect(+ createContentDatabase({ artifact }).query({ query }, undefined, {+ hero: { url: "/cgi/image/hero.png?format=raw" },+ })+ ).resolves.toMatchObject({+ items: [+ {+ id: "post",+ properties: {+ featureImage: "/cgi/image/hero.png?format=raw",+ },+ },+ ],+ });+ });+test("stores overview-only fields outside dynamic detail documents", async () => {const sourceEntries = ["alpha", "beta"].map((id) =>createCanonicalAssetFileEntry({diff --git a/packages/content-engine/src/asset-index.ts b/packages/content-engine/src/asset-index.tsindex b42544e2df..d8a3781fc3 100644--- a/packages/content-engine/src/asset-index.ts+++ b/packages/content-engine/src/asset-index.ts@@ -35,6 +35,10 @@ import {type DocumentGraph,type DocumentGraphArtifactV1,} from "./document-graph";+import { getQueryConditions } from "@webstudio-is/query-builder/runtime";+import type { AssetValueReferences } from "./asset-value-references";++export const contentCompilationGeneration = 1;export type ContentCompilerDiagnostics = {maxBytes: number;@@ -62,6 +66,52 @@ const getDocumentBytes = ());+const pathsOverlap = (+ left: readonly (string | number)[],+ right: readonly (string | number)[]+) => {+ const length = Math.min(left.length, right.length);+ return left+ .slice(0, length)+ .every((segment, index) => segment === right[index]);+};++const isQueryEvaluationAffectedByAssetValues = ({+ query,+ assetValueReferences,+}: {+ query: ContentCompilationPlan["queries"][number];+ assetValueReferences?: AssetValueReferences;+}) => {+ const evaluationPaths = [+ ...getQueryConditions(query.where).map(({ field }) => field),+ ...query.sort.map(({ field }) => field),+ ];+ return Object.values(assetValueReferences ?? {})+ .flat()+ .some(({ path }) =>+ evaluationPaths.some((field) => pathsOverlap(path, field))+ );+};++const isDocumentEvaluationAffectedByAssetValues = ({+ documentId,+ plan,+ assetValueReferences,+}: {+ documentId: string;+ plan: ContentCompilationPlan;+ assetValueReferences?: AssetValueReferences;+}) =>+ plan.queries.some((query) =>+ isQueryEvaluationAffectedByAssetValues({+ query,+ assetValueReferences: {+ [documentId]: assetValueReferences?.[documentId] ?? [],+ },+ })+ );+export type ContentCompilerInput = CanonicalAssetFileEntry & {content?: string;contentRequired?: true;@@ -216,6 +266,7 @@ const buildAssetIndex = async ({maxBytes,unboundedBytes,assetReferences,+ assetValueReferences,documentGraph,plan,finalize = true,@@ -225,6 +276,7 @@ const buildAssetIndex = async ({maxBytes: number;unboundedBytes: number;assetReferences?: MarkdownAssetReferences;+ assetValueReferences?: AssetValueReferences;documentGraph?: DocumentGraphArtifactV1;plan?: ContentCompilationPlan;finalize?: boolean;@@ -236,9 +288,13 @@ const buildAssetIndex = async ({const materializableQueries =plan?.queries.filter((query) =>- documentGraph === undefined ||- getDocumentGraphQueryRootIds({ graph: documentGraph, query }).length ===- 0+ isQueryEvaluationAffectedByAssetValues({+ query,+ assetValueReferences,+ }) === false &&+ (documentGraph === undefined ||+ getDocumentGraphQueryRootIds({ graph: documentGraph, query })+ .length === 0)) ?? [];const materialized =plan === undefined@@ -272,12 +328,18 @@ const buildAssetIndex = async ({? entries: runtimePlan.queries.length === 0? []- : entries.filter(({ document }) =>- isContentDocumentCandidate({- document,- plan: runtimePlan,- available: "all",- })+ : entries.filter(+ ({ document }) =>+ isDocumentEvaluationAffectedByAssetValues({+ documentId: document._id,+ plan: runtimePlan,+ assetValueReferences,+ }) ||+ isContentDocumentCandidate({+ document,+ plan: runtimePlan,+ available: "all",+ }));const documents = runtimeEntries.map(({ document }) =>@@ -303,6 +365,12 @@ const buildAssetIndex = async ({includedContentRefs.has(contentRef)));+ const includedDocumentIds = new Set(entries.map(({ assetId }) => assetId));+ const includedAssetValueReferences = Object.fromEntries(+ Object.entries(assetValueReferences ?? {}).filter(([documentId]) =>+ includedDocumentIds.has(documentId)+ )+ );const runtimeCatalog =runtimeEntries === entries? sourceCatalog@@ -336,6 +404,9 @@ const buildAssetIndex = async ({...(Object.keys(includedAssetReferences).length === 0? {}: { assetReferences: includedAssetReferences }),+ ...(Object.keys(includedAssetValueReferences).length === 0+ ? {}+ : { assetValueReferences: includedAssetValueReferences }),fieldCatalog,...(Object.keys(materialized.values).length === 0? {}@@ -370,6 +441,7 @@ export const compileContentArtifact = async ({entries,maxBytes = contentEngineLimits.databaseBytes,assetReferences,+ assetValueReferences,documentGraph,plan,}: {@@ -377,6 +449,7 @@ export const compileContentArtifact = async ({entries: readonly ContentCompilerInput[];maxBytes?: number;assetReferences?: MarkdownAssetReferences;+ assetValueReferences?: AssetValueReferences;documentGraph?: DocumentGraph;plan?: ContentCompilationPlan;}): Promise<{@@ -434,6 +507,7 @@ export const compileContentArtifact = async ({maxBytes,unboundedBytes,assetReferences,+ assetValueReferences,documentGraph: documentGraphArtifact,plan,finalize: false,@@ -461,6 +535,7 @@ export const compileContentArtifact = async ({maxBytes,unboundedBytes,assetReferences,+ assetValueReferences,documentGraph: documentGraphArtifact,plan,finalize: false,@@ -493,6 +568,7 @@ export const compileContentArtifact = async ({maxBytes,unboundedBytes,assetReferences,+ assetValueReferences,documentGraph: documentGraphArtifact,plan,finalize: false,@@ -526,6 +602,7 @@ export const compileContentArtifact = async ({maxBytes,unboundedBytes,assetReferences,+ assetValueReferences,documentGraph: documentGraphArtifact,plan,});@@ -577,6 +654,7 @@ export const createAssetIndex = async (input: {entries: readonly ContentCompilerInput[];maxBytes?: number;assetReferences?: MarkdownAssetReferences;+ assetValueReferences?: AssetValueReferences;documentGraph?: DocumentGraph;plan?: ContentCompilationPlan;}): Promise<ContentArtifactV1> =>diff --git a/packages/content-engine/src/asset-value-references.test.ts b/packages/content-engine/src/asset-value-references.test.tsnew file mode 100644index 0000000000..d9c9acd14e--- /dev/null+++ b/packages/content-engine/src/asset-value-references.test.ts@@ -0,0 +1,107 @@+import { describe, expect, test } from "vitest";+import {+ discoverAssetValueReferences,+ mergeAssetUrlSuffix,+ resolveAssetValueReferences,+} from "./asset-value-references";++describe("structured asset value references", () => {+ test("discovers nested object and array values relative to the source document", () => {+ const properties = {+ featureImage: "./assets/hero.png",+ openGraph: { image: "../shared/social.png#cover" },+ gallery: ["./assets/first.png?width=800", { src: "missing.png" }],+ external: "https://example.com/image.png",+ rootRelative: "/images/hero.png",+ fragment: "#hero",+ };++ expect(+ discoverAssetValueReferences({+ properties,+ sourcePath: "blog/posts/article.md",+ assetIdsByPath: new Map([+ ["blog/posts/assets/hero.png", "hero"],+ ["blog/shared/social.png", "social"],+ ["blog/posts/assets/first.png", "first"],+ ]),+ })+ ).toEqual([+ {+ path: ["properties", "featureImage"],+ assetId: "hero",+ },+ {+ path: ["properties", "openGraph", "image"],+ assetId: "social",+ suffix: "#cover",+ },+ {+ path: ["properties", "gallery", 0],+ assetId: "first",+ suffix: "?width=800",+ },+ ]);+ });++ test("leaves missing and non-unique paths undiscovered", () => {+ expect(+ discoverAssetValueReferences({+ properties: {+ ambiguous: "./hero.png",+ missing: "./missing.png",+ stableId: "asset-id",+ },+ sourcePath: "posts/article.json",+ assetIdsByPath: new Map([["images/hero.png", "asset-id"]]),+ })+ ).toEqual([+ {+ path: ["properties", "stableId"],+ assetId: "asset-id",+ },+ ]);+ });++ test("resolves without mutating source values and merges URL suffixes", () => {+ const value = {+ properties: {+ image: "./hero.png?width=1200#cover",+ gallery: ["./first.png"],+ },+ };++ const resolved = resolveAssetValueReferences({+ value,+ references: [+ {+ path: ["properties", "image"],+ assetId: "hero",+ suffix: "?width=1200#cover",+ },+ {+ path: ["properties", "gallery", 0],+ assetId: "first",+ },+ ],+ assetUrls: {+ hero: "/cgi/image/hero.png?format=raw",+ first: "/cgi/image/first.png?format=raw",+ },+ });++ expect(resolved).toEqual({+ properties: {+ image: "/cgi/image/hero.png?format=raw&width=1200#cover",+ gallery: ["/cgi/image/first.png?format=raw"],+ },+ });+ expect(value.properties.image).toBe("./hero.png?width=1200#cover");+ expect(+ mergeAssetUrlSuffix(+ "https://cdn.example.com/guide.pdf?format=raw",+ "?download=1#section"+ )+ ).toBe("https://cdn.example.com/guide.pdf?format=raw&download=1#section");+ });+});diff --git a/packages/content-engine/src/asset-value-references.ts b/packages/content-engine/src/asset-value-references.tsnew file mode 100644index 0000000000..819ecf8380--- /dev/null+++ b/packages/content-engine/src/asset-value-references.ts@@ -0,0 +1,152 @@+import { createAssetIdResolver } from "./markdown-assets";++export type AssetValueReference = {+ path: Array<string | number>;+ assetId: string;+ suffix?: string;+};++export type AssetValueReferences = Record<string, AssetValueReference[]>;++const getUrlSuffix = (value: string) => {+ let parsed: URL;+ try {+ parsed = new URL(value, "https://content.webstudio.invalid/");+ } catch {+ return;+ }+ const suffix = `${parsed.search}${parsed.hash}`;+ return suffix === "" ? undefined : suffix;+};++export const discoverAssetValueReferences = ({+ properties,+ sourcePath,+ assetIdsByPath,+}: {+ properties: Readonly<Record<string, unknown>>;+ sourcePath: string;+ assetIdsByPath: ReadonlyMap<string, string>;+}): AssetValueReference[] => {+ const resolveAssetId = createAssetIdResolver(assetIdsByPath, sourcePath);+ const references: AssetValueReference[] = [];+ const visit = (value: unknown, path: Array<string | number>) => {+ if (typeof value === "string") {+ const assetId = resolveAssetId(value);+ if (assetId !== undefined) {+ const suffix = getUrlSuffix(value);+ references.push({+ path,+ assetId,+ ...(suffix === undefined ? {} : { suffix }),+ });+ }+ return;+ }+ if (Array.isArray(value)) {+ for (const [index, item] of value.entries()) {+ visit(item, [...path, index]);+ }+ return;+ }+ if (typeof value !== "object" || value === null) {+ return;+ }+ for (const [key, item] of Object.entries(value)) {+ visit(item, [...path, key]);+ }+ };+ visit(properties, ["properties"]);+ return references;+};++export const mergeAssetUrlSuffix = (url: string, suffix?: string) => {+ if (suffix === undefined) {+ return url;+ }+ const base = "https://content.webstudio.invalid";+ const canonical = new URL(url, `${base}/`);+ const authored = new URL(suffix, `${base}/`);+ for (const [key, value] of authored.searchParams) {+ canonical.searchParams.append(key, value);+ }+ if (authored.hash !== "") {+ canonical.hash = authored.hash;+ }+ if (url.startsWith("//")) {+ return `//${canonical.host}${canonical.pathname}${canonical.search}${canonical.hash}`;+ }+ if (url.startsWith("/")) {+ return `${canonical.pathname}${canonical.search}${canonical.hash}`;+ }+ return canonical.href;+};++const replaceValueAtPath = ({+ value,+ path,+ replacement,+}: {+ value: unknown;+ path: readonly (string | number)[];+ replacement: string;+}): unknown => {+ const [segment, ...rest] = path;+ if (segment === undefined) {+ return replacement;+ }+ if (+ typeof value !== "object" ||+ value === null ||+ Object.hasOwn(value, segment) === false+ ) {+ return value;+ }+ if (Array.isArray(value)) {+ if (typeof segment !== "number") {+ return value;+ }+ const next = [...value];+ next[segment] = replaceValueAtPath({+ value: value[segment],+ path: rest,+ replacement,+ });+ return next;+ }+ if (typeof segment !== "string") {+ return value;+ }+ return {+ ...value,+ [segment]: replaceValueAtPath({+ value: (value as Readonly<Record<string, unknown>>)[segment],+ path: rest,+ replacement,+ }),+ };+};++export const resolveAssetValueReferences = <Value>({+ value,+ references,+ assetUrls,+}: {+ value: Value;+ references: readonly AssetValueReference[] | undefined;+ assetUrls: Readonly<Record<string, string>>;+}): Value => {+ let resolved: unknown = value;+ for (const reference of references ?? []) {+ const assetUrl = assetUrls[reference.assetId];+ if (assetUrl === undefined) {+ continue;+ }+ resolved = replaceValueAtPath({+ value: resolved,+ path: reference.path,+ replacement: mergeAssetUrlSuffix(assetUrl, reference.suffix),+ });+ }+ return resolved as Value;+};diff --git a/packages/content-engine/src/compiler.ts b/packages/content-engine/src/compiler.tsindex 08a17457ed..fbab8fd608 100644--- a/packages/content-engine/src/compiler.ts+++ b/packages/content-engine/src/compiler.ts@@ -6,6 +6,7 @@ export * from "./asset-index";export * from "./content-runtime-artifact";export * from "./content-source";export * from "./document-metadata";+export * from "./asset-value-references";export { serializeJsonDeterministically } from "./canonical-json";export { decodeUtf8, readBoundedBytes, readBytePrefix } from "./byte-stream";export { mapBounded } from "./async-utils";diff --git a/packages/content-engine/src/content-artifact.ts b/packages/content-engine/src/content-artifact.tsindex 4656dc40d7..8e4a909a4a 100644--- a/packages/content-engine/src/content-artifact.ts+++ b/packages/content-engine/src/content-artifact.ts@@ -13,13 +13,16 @@ export const serializeContentArtifact = (value: unknown) =>serializeJsonDeterministically(contentArtifactV1.parse(value));export const getContentArtifactReferencedAssetIds = (- artifact: Pick<ContentArtifactV1, "assetReferences">+ artifact: Pick<ContentArtifactV1, "assetReferences" | "assetValueReferences">) =>[...new Set(- Object.values(artifact.assetReferences ?? {})- .flat()- .map(({ assetId }) => assetId)+ [artifact.assetReferences, artifact.assetValueReferences].flatMap(+ (references) =>+ Object.values(references ?? {})+ .flat()+ .map(({ assetId }) => assetId)+ )),].sort();@@ -28,7 +31,10 @@ export const getContentArtifactRuntimeAssetIds = ({includeDocuments,includeDocumentGraph = true,}: {- artifact: Pick<ContentArtifactV1, "assetReferences"> & {+ artifact: Pick<+ ContentArtifactV1,+ "assetReferences" | "assetValueReferences"+ > & {documents: readonly { _id: string }[];documentGraph?: { readonly nodes: readonly { id: string }[] };};diff --git a/packages/content-engine/src/content-database.ts b/packages/content-engine/src/content-database.tsindex a90643c2bb..10cc5d95c9 100644--- a/packages/content-engine/src/content-database.ts+++ b/packages/content-engine/src/content-database.ts@@ -35,6 +35,7 @@ import {assertDocumentSourceIdentity,} from "./document-graph";import { contentEngineLimits } from "./limits";+import { resolveAssetValueReferences } from "./asset-value-references";type ContentDatabaseQueryArguments = [request: AssetQueryRequestInput,@@ -135,7 +136,11 @@ const createQueryableContentDatabase = ({}: {artifact: Pick<ContentRuntimeArtifact,- "documents" | "contents" | "assetReferences" | "queries"+ | "documents"+ | "contents"+ | "assetReferences"+ | "assetValueReferences"+ | "queries">;revision: string;catalog?: BuilderAssetFieldCatalog;@@ -158,12 +163,17 @@ const createQueryableContentDatabase = ({) {throw new AssetIndexRevisionError();}+ const assetUrls = Object.fromEntries(+ Object.entries(runtimeAssets ?? {}).map(([id, asset]) => [id, asset.url])+ );const materialized =options?.skipMaterialized === true? undefined: await getMaterializedAssetQueryResult({queries: artifact.queries,query: request.query,+ assetValueReferences: artifact.assetValueReferences,+ assetUrls,});if (materialized !== undefined) {return materialized;@@ -199,6 +209,7 @@ const createQueryableContentDatabase = ({read: readEmbeddedContent,runtimeAssets,assetReferences: artifact.assetReferences,+ assetValueReferences: artifact.assetValueReferences,});return result;};@@ -228,7 +239,20 @@ const createQueryableContentDatabase = ({graph: documentGraph,query,}).filter((rootId) => {- const document = documentsById.get(rootId);+ const storedDocument = documentsById.get(rootId);+ const document =+ storedDocument === undefined+ ? undefined+ : resolveAssetValueReferences({+ value: storedDocument,+ references: artifact.assetValueReferences?.[rootId],+ assetUrls: Object.fromEntries(+ Object.entries(runtimeAssets ?? {}).map(([id, asset]) => [+ id,+ asset.url,+ ])+ ),+ });if (document === undefined) {return false;}diff --git a/packages/content-engine/src/content-runtime-artifact.ts b/packages/content-engine/src/content-runtime-artifact.tsindex 4a014c53d2..c30d71dbe0 100644--- a/packages/content-engine/src/content-runtime-artifact.ts+++ b/packages/content-engine/src/content-runtime-artifact.ts@@ -11,6 +11,7 @@ import {type DocumentRepresentation,} from "./document-graph";import type { MarkdownAssetReferences } from "./markdown-references";+import type { AssetValueReferences } from "./asset-value-references";type RuntimeDocumentGraphEdge = Readonly<{sourceId: string;@@ -28,6 +29,7 @@ export type ContentRuntimeArtifact = Readonly<{}>;contents?: Readonly<Record<string, string>>;assetReferences?: MarkdownAssetReferences;+ assetValueReferences?: AssetValueReferences;queries?: Readonly<Record<string, MaterializedAssetQuery>>;}>;@@ -80,6 +82,9 @@ export const createContentRuntimeArtifact = (...(artifact.assetReferences === undefined? {}: { assetReferences: artifact.assetReferences }),+ ...(artifact.assetValueReferences === undefined+ ? {}+ : { assetValueReferences: artifact.assetValueReferences }),...(artifact.queries === undefined ? {} : { queries: artifact.queries }),};};@@ -96,9 +101,12 @@ export const getContentRuntimeArtifactRuntimeAssetIds = ({includeDocuments: boolean;}) => {const ids = new Set(- Object.values(artifact.assetReferences ?? {})- .flat()- .map(({ assetId }) => assetId)+ [artifact.assetReferences, artifact.assetValueReferences].flatMap(+ (references) =>+ Object.values(references ?? {})+ .flat()+ .map(({ assetId }) => assetId)+ ));if (includeDocuments) {for (const { _id } of artifact.documents) {diff --git a/packages/content-engine/src/content-source.test.ts b/packages/content-engine/src/content-source.test.tsindex 996bcd3262..b81c9970e4 100644--- a/packages/content-engine/src/content-source.test.ts+++ b/packages/content-engine/src/content-source.test.ts@@ -504,6 +504,87 @@ describe("content source snapshots", () => {});});+ test("discovers structured Asset values in Markdown and JSON documents", async () => {+ const markdown = createFile({+ id: "markdown",+ path: "blog/posts/content-mode.md",+ });+ const json = createFile({+ id: "json",+ path: "team/member.json",+ contentType: "application/json",+ contentRef: "revisions/member.json",+ });+ const hero = createFile({+ id: "hero",+ path: "blog/posts/assets/content-mode.png",+ contentType: "image/png",+ });+ const portrait = createFile({+ id: "portrait",+ path: "team/assets/portrait.png",+ contentType: "image/png",+ });+ const source: ContentSource = {+ async openSnapshot() {+ return {+ revision: "snapshot",+ files: [markdown, json, hero, portrait],+ async loadEntries() {+ const markdownEntry = createEntry(markdown);+ const jsonEntry = createEntry(json);+ return [+ {+ ...markdownEntry,+ document: {+ ...markdownEntry.document,+ properties: {+ featureImage: "./assets/content-mode.png",+ openGraph: {+ images: ["./assets/content-mode.png#social"],+ },+ },+ },+ } as typeof markdownEntry,+ {+ ...jsonEntry,+ document: {+ ...jsonEntry.document,+ properties: { portrait: "./assets/portrait.png" },+ },+ } as typeof jsonEntry,+ ];+ },+ async isCurrent() {+ return true;+ },+ };+ },+ };++ const result = await compileContentSource({ source, projectId });++ expect(result.artifact.assetValueReferences).toEqual({+ json: [+ {+ path: ["properties", "portrait"],+ assetId: "portrait",+ },+ ],+ markdown: [+ {+ path: ["properties", "featureImage"],+ assetId: "hero",+ },+ {+ path: ["properties", "openGraph", "images", 0],+ assetId: "hero",+ suffix: "#social",+ },+ ],+ });+ });+test("resolves the same relative URL independently for each Markdown folder", async () => {const firstPost = createFile({id: "first-post",diff --git a/packages/content-engine/src/content-source.ts b/packages/content-engine/src/content-source.tsindex f83e2ae4eb..d1ca4a4388 100644--- a/packages/content-engine/src/content-source.ts+++ b/packages/content-engine/src/content-source.ts@@ -15,6 +15,10 @@ import {discoverMarkdownAssetReferenceRanges,} from "./markdown-assets";import type { MarkdownAssetReferences } from "./markdown-references";+import {+ discoverAssetValueReferences,+ type AssetValueReferences,+} from "./asset-value-references";import { compareStrings } from "./canonical-json";import { encodeUtf8, type ByteSource } from "./byte-stream";import { extractMarkdownBody } from "./markdown-body";@@ -175,6 +179,30 @@ const discoverSnapshotAssetReferences = async ({return references;};+const discoverSnapshotAssetValueReferences = ({+ snapshot,+ entries,+}: {+ snapshot: ContentSourceSnapshot;+ entries: readonly ContentCompilerInput[];+}): AssetValueReferences => {+ const assetIdsByPath = createUniqueAssetIdsByPath(snapshot.files);+ const references: AssetValueReferences = {};+ for (const entry of [...entries].sort((left, right) =>+ compareStrings(left.assetId, right.assetId)+ )) {+ const discovered = discoverAssetValueReferences({+ properties: entry.document.properties ?? {},+ sourcePath: entry.document.path,+ assetIdsByPath,+ });+ if (discovered.length > 0) {+ references[entry.assetId] = discovered;+ }+ }+ return references;+};+const documentUrlBase = "https://content.webstudio.local/";const getDocumentUrl = (path: string) =>@@ -288,11 +316,16 @@ export const materializeContentSnapshot = async ({entries,plan,});+ const assetValueReferences = discoverSnapshotAssetValueReferences({+ snapshot,+ entries,+ });if (await snapshot.isCurrent()) {return {sourceRevision: snapshot.revision,entries,assetReferences,+ assetValueReferences,documentGraph,};}@@ -320,16 +353,22 @@ export const compileContentSource = async ({artifact: ContentArtifactV1;diagnostics: ContentCompilerDiagnostics;}> => {- const { sourceRevision, entries, assetReferences, documentGraph } =- await materializeContentSource({- source,- plan,- maximumContentBytes: maxBytes,- });+ const {+ sourceRevision,+ entries,+ assetReferences,+ assetValueReferences,+ documentGraph,+ } = await materializeContentSource({+ source,+ plan,+ maximumContentBytes: maxBytes,+ });const compiled = await compileContentArtifact({projectId,entries,assetReferences,+ assetValueReferences,documentGraph,...(plan === undefined ? {} : { plan }),...(maxBytes === undefined ? {} : { maxBytes }),@@ -349,6 +388,7 @@ export const materializeContentSource = async ({sourceRevision: string;entries: readonly ContentCompilerInput[];assetReferences: MarkdownAssetReferences;+ assetValueReferences: AssetValueReferences;documentGraph?: DocumentGraph;}> => {for (let attempt = 0; attempt < 2; attempt += 1) {diff --git a/packages/content-engine/src/document-graph/query-resolution.test.ts b/packages/content-engine/src/document-graph/query-resolution.test.tsindex ce688acdca..68d970d26f 100644--- a/packages/content-engine/src/document-graph/query-resolution.test.ts+++ b/packages/content-engine/src/document-graph/query-resolution.test.ts@@ -23,7 +23,10 @@ const createPostEntry = (id: string, authorPath: string) =>size: 1,revision: `${id}-r1`,contentRef: `content:${id}`,- properties: { author: { $ref: authorPath } },+ properties: {+ author: { $ref: authorPath },+ featureImage: "./assets/hero.png",+ },},});@@ -78,11 +81,24 @@ describe("document graph query resolution", () => {const { artifact } = await compileContentArtifact({projectId: "project",entries,+ assetValueReferences: Object.fromEntries(+ entries.map(({ assetId }) => [+ assetId,+ [+ {+ path: ["properties", "featureImage"],+ assetId: "hero",+ },+ ],+ ])+ ),documentGraph: graph,});const sources: Record<string, string> = {- "post-ada": '{"author":{"$ref":"../authors/ada.json"}}',- "post-grace": '{"author":{"$ref":"../authors/grace.json"}}',+ "post-ada":+ '{"author":{"$ref":"../authors/ada.json"},"featureImage":"./assets/hero.png"}',+ "post-grace":+ '{"author":{"$ref":"../authors/grace.json"},"featureImage":"./assets/hero.png"}',"author-ada": '{"name":"Ada"}',"author-grace": '{"name":"Grace"}',};@@ -103,6 +119,11 @@ describe("document graph query resolution", () => {operator: "eq",value: "Ada",},+ {+ field: ["properties", "featureImage"],+ operator: "startsWith",+ value: "/cgi/image/",+ },],},sort: [@@ -114,19 +135,28 @@ describe("document graph query resolution", () => {output: {mode: "fields",includeMetadata: false,- fields: [["properties", "author", "name"]],+ fields: [+ ["properties", "author", "name"],+ ["properties", "featureImage"],+ ],},content: { mode: "none" },},},load,+ runtimeAssets: {+ hero: { url: "/cgi/image/hero.png?format=raw" },+ },});expect(result).toEqual({items: [{id: "post-ada",- properties: { author: { name: "Ada" } },+ properties: {+ author: { name: "Ada" },+ featureImage: "/cgi/image/hero.png?format=raw",+ },},],totalCount: 1,diff --git a/packages/content-engine/src/index.ts b/packages/content-engine/src/index.tsindex 1d4c540632..cae443e72f 100644--- a/packages/content-engine/src/index.ts+++ b/packages/content-engine/src/index.ts@@ -11,3 +11,4 @@ export * from "./request";export * from "./query-source";export * from "./query-error";export * from "./document-graph";+export * from "./asset-value-references";diff --git a/packages/content-engine/src/markdown-assets.ts b/packages/content-engine/src/markdown-assets.tsindex afab664c4d..30924be195 100644--- a/packages/content-engine/src/markdown-assets.ts+++ b/packages/content-engine/src/markdown-assets.ts@@ -107,7 +107,7 @@ const getRelativeAssetPath = ({return segments.join("/");};-const createAssetIdResolver = (+export const createAssetIdResolver = (assetIdsByPath: ReadonlyMap<string, string>,sourcePath: string) => {diff --git a/packages/content-engine/src/materialized-query.ts b/packages/content-engine/src/materialized-query.tsindex 2cbf630397..1880c79d58 100644--- a/packages/content-engine/src/materialized-query.ts+++ b/packages/content-engine/src/materialized-query.ts@@ -19,9 +19,14 @@ import {type MaterializedAssetQuery,} from "./schema";import {+ assertAssetQueryResultSize,AssetQueryExecutionError,executeAssetQuery,} from "./structured-query";+import {+ resolveAssetValueReferences,+ type AssetValueReferences,+} from "./asset-value-references";const hasOverlappingFields = (fields: readonly AssetQueryFieldPath[]) =>fields.some((field, index) =>@@ -249,13 +254,32 @@ const hydrateMaterializedQuery = (export const getMaterializedAssetQueryResult = async ({queries,query,+ assetValueReferences,+ assetUrls = {},}: {queries: Readonly<Record<string, MaterializedAssetQuery>> | undefined;query: AssetQueryInput;+ assetValueReferences?: AssetValueReferences;+ assetUrls?: Readonly<Record<string, string>>;}): Promise<AssetQueryResult | undefined> => {if (queries === undefined) {return;}const value = queries[await getAssetQueryHash(assetQuery.parse(query))];- return value === undefined ? undefined : hydrateMaterializedQuery(value);+ if (value === undefined) {+ return;+ }+ const result = hydrateMaterializedQuery(value);+ const resolved = {+ ...result,+ items: result.items.map((item) =>+ resolveAssetValueReferences({+ value: item,+ references: assetValueReferences?.[item.id],+ assetUrls,+ })+ ),+ };+ assertAssetQueryResultSize(resolved);+ return resolved;};diff --git a/packages/content-engine/src/published-runtime.test.ts b/packages/content-engine/src/published-runtime.test.tsindex 9e75f1e9b5..4b9f5d6460 100644--- a/packages/content-engine/src/published-runtime.test.ts+++ b/packages/content-engine/src/published-runtime.test.ts@@ -820,6 +820,91 @@ describe("published asset resource runtime", () => {});});+ test("resolves structured Asset values from materialized query rows", async () => {+ const query = assetQuery.parse({+ where: {+ all: [+ {+ field: ["properties", "slug"],+ operator: "eq",+ value: "post",+ },+ ],+ },+ sort: [],+ limit: 1,+ offset: 0,+ output: {+ mode: "fields",+ includeMetadata: false,+ fields: [["properties", "featureImage"]],+ },+ content: { mode: "none" },+ });+ const index = await createAssetIndex({+ projectId: "project-1",+ entries: [+ createCanonicalAssetFileEntry({+ projectId: "project-1",+ document: {+ ...document,+ properties: {+ ...document.properties,+ featureImage: "./assets/hero.png?width=1200#cover",+ },+ },+ }),+ ],+ assetValueReferences: {+ "post-1": [+ {+ path: ["properties", "featureImage"],+ assetId: "hero",+ suffix: "?width=1200#cover",+ },+ ],+ },+ plan: createContentCompilationPlan([+ createLiteralContentCompilationQuery({ id: "posts", query }),+ ]),+ });++ expect(index.documents).toEqual([]);+ expect(() =>+ createPublishedAssetResourceFetch({+ baseUrl: "https://site.example",+ deploymentId: "missing-structured-asset",+ artifact: index,+ runtimeAssets: {},+ })+ ).toThrow("Published referenced asset URL is unavailable for hero");+ const runtimeFetch = createPublishedAssetResourceFetch({+ baseUrl: "https://site.example",+ deploymentId: "materialized-structured-asset",+ artifact: index,+ runtimeAssets: {+ hero: { url: "/cgi/image/hero.png?format=raw" },+ },+ });+ const response = await runtimeFetch("/$resources/assets", {+ method: "POST",+ body: JSON.stringify({ query }),+ });++ await expect(response?.json()).resolves.toEqual({+ items: [+ {+ id: "post-1",+ properties: {+ featureImage: "/cgi/image/hero.png?format=raw&width=1200#cover",+ },+ },+ ],+ totalCount: 1,+ hasMore: false,+ });+ });+test("reuses one initialized runtime across deployment origins", async () => {const { index } = await createRuntime();const createGeneratedFetch = createGeneratedAssetResourceRuntime({diff --git a/packages/content-engine/src/published-runtime.ts b/packages/content-engine/src/published-runtime.tsindex 0b20912ecd..68db6b7826 100644--- a/packages/content-engine/src/published-runtime.ts+++ b/packages/content-engine/src/published-runtime.ts@@ -181,8 +181,11 @@ const validateRuntimeAssets = ({artifact: ContentRuntimeArtifact;runtimeAssets: Readonly<Record<string, AssetRuntimeData>>;}) => {- const missingReferencedAssetId = Object.values(artifact.assetReferences ?? {})- .flat()+ const missingReferencedAssetId = [+ artifact.assetReferences,+ artifact.assetValueReferences,+ ]+ .flatMap((references) => Object.values(references ?? {}).flat()).map(({ assetId }) => assetId).find((assetId) => runtimeAssets[assetId] === undefined);if (missingReferencedAssetId !== undefined) {diff --git a/packages/content-engine/src/schema.ts b/packages/content-engine/src/schema.tsindex 605086eac4..7f97cb93f7 100644--- a/packages/content-engine/src/schema.ts+++ b/packages/content-engine/src/schema.ts@@ -192,6 +192,16 @@ export const contentArtifactV1 = strictObject({}))).optional(),+ assetValueReferences: record(+ string().min(1),+ array(+ strictObject({+ path: array(string().min(1).or(number().int().nonnegative())).min(1),+ assetId: string().min(1),+ suffix: string().min(1).optional(),+ })+ )+ ).optional(),fieldCatalog: builderAssetFieldCatalog,queries: record(sha256Revision, materializedAssetQuery).optional(),database: strictObject({diff --git a/packages/content-engine/src/structured-query.test.ts b/packages/content-engine/src/structured-query.test.tsindex 63c4346a9f..3bdb15b8f4 100644--- a/packages/content-engine/src/structured-query.test.ts+++ b/packages/content-engine/src/structured-query.test.ts@@ -93,6 +93,77 @@ const runtimeAssets = Object.fromEntries();describe("structured asset query", () => {+ test("filters, sorts, and projects resolved structured asset values", async () => {+ const result = await executeAssetQuery({+ documents: [+ document({+ id: "alpha",+ properties: { featureImage: "./alpha.png" },+ }),+ document({+ id: "beta",+ properties: { featureImage: "./beta.png" },+ }),+ ],+ assetValueReferences: {+ alpha: [+ {+ path: ["properties", "featureImage"],+ assetId: "alpha-image",+ },+ ],+ beta: [+ {+ path: ["properties", "featureImage"],+ assetId: "beta-image",+ },+ ],+ },+ runtimeAssets: {+ "alpha-image": { url: "/cgi/image/z-alpha.png?format=raw" },+ "beta-image": { url: "/cgi/image/a-beta.png?format=raw" },+ },+ query: {+ where: {+ all: [+ {+ field: ["properties", "featureImage"],+ operator: "startsWith",+ value: "/cgi/image/",+ },+ ],+ },+ sort: [+ {+ field: ["properties", "featureImage"],+ direction: "asc",+ },+ ],+ output: {+ mode: "fields",+ includeMetadata: false,+ fields: [["properties", "featureImage"]],+ },+ content: { mode: "none" },+ },+ });++ expect(result.items).toEqual([+ {+ id: "beta",+ properties: {+ featureImage: "/cgi/image/a-beta.png?format=raw",+ },+ },+ {+ id: "alpha",+ properties: {+ featureImage: "/cgi/image/z-alpha.png?format=raw",+ },+ },+ ]);+ });+test("accepts only referenced Markdown body queries", () => {expect(assetQuery.safeParse({ content: { mode: "markdown-body-ref" } }).successdiff --git a/packages/content-engine/src/structured-query.ts b/packages/content-engine/src/structured-query.tsindex abd0f9fa55..46f9723075 100644--- a/packages/content-engine/src/structured-query.ts+++ b/packages/content-engine/src/structured-query.ts@@ -34,6 +34,10 @@ import { appendAssetFieldPath } from "./canonical";import { selectAssetDocumentFields, selectAssetProperties } from "./projection";import { getUtf8ByteLength } from "./byte-stream";import type { MarkdownAssetReferences } from "./markdown-references";+import {+ resolveAssetValueReferences,+ type AssetValueReferences,+} from "./asset-value-references";export type AssetRuntimeData = {url: string;@@ -425,6 +429,7 @@ export const executeAssetQuery = async ({read,runtimeAssets,assetReferences,+ assetValueReferences,}: {query: AssetQueryInput;catalog?: BuilderAssetFieldCatalog;@@ -432,6 +437,7 @@ export const executeAssetQuery = async ({read?: AssetResourceContentReader;runtimeAssets?: Readonly<Record<string, AssetRuntimeData>>;assetReferences?: MarkdownAssetReferences;+ assetValueReferences?: AssetValueReferences;}): Promise<AssetQueryResult> => {const { query } = validateAssetQueryAgainstCatalog({ query: input, catalog });if (documents.length > contentEngineLimits.candidateDocuments) {@@ -439,7 +445,17 @@ export const executeAssetQuery = async ({"Asset query document limit was exceeded");}- const matched = documents.flatMap((document) => {+ const assetUrls = Object.fromEntries(+ Object.entries(runtimeAssets ?? {}).map(([id, asset]) => [id, asset.url])+ );+ const resolvedDocuments = documents.map((document) =>+ resolveAssetValueReferences({+ value: document,+ references: assetValueReferences?.[document._id],+ assetUrls,+ })+ );+ const matched = resolvedDocuments.flatMap((document) => {const runtimeAsset = runtimeAssets?.[document._id];if (supportsAssetQueryContent({ document, content: query.content }) ===@@ -480,15 +496,7 @@ export const executeAssetQuery = async ({options: contentOptions,read,assetReferences,- assetUrls:- assetReferences === undefined- ? undefined- : Object.fromEntries(- Object.entries(runtimeAssets ?? {}).map(([id, asset]) => [- id,- asset.url,- ])- ),+ assetUrls: assetReferences === undefined ? undefined : assetUrls,});items = selectedDocuments.map((document, index) => {const content = hydrated.content[document._id];