fix: hydrate published Markdown assets (#6422)

Migrated from #6421 to the short .staging branch name.
This commit is contained in:
Oleg Isonen authored and GitHub committed 2026-09-23 01:01:08 +02:00
1 parent 3d0a0657aa
commit 9845517029
27 files changed
+930 -385

No files matched your search

+1 -2
View File
@@ -30,8 +30,7 @@ POSTGREST_API_KEY=
# S3_ACCESS_KEY_ID=
# S3_SECRET_ACCESS_KEY=
# if using r2 this your worker url
# ASSET_CDN_URL=https://assets.webstudio.is
# Asset CDN origin used by published builds, without a trailing slash.
# Publisher config
# PUBLISHER_HOST=wstd.io
@@ -82,7 +82,10 @@ import {
import { AddDomain } from "./add-domain";
import { humanizeString } from "~/shared/string-utils";
import { trpcClient, nativeClient } from "~/shared/trpc/trpc-client";
import type { Templates } from "@webstudio-is/sdk";
import {
publishedDeploymentDestination,
type Templates,
} from "@webstudio-is/sdk";
import { DomainCheckbox, domainToPublishName } from "./domain-checkbox";
import { CopyToClipboard } from "~/shared/copy-to-clipboard";
import { $openProjectSettings } from "~/shared/nano-states/project-settings";
@@ -557,7 +560,7 @@ const Publish = ({
const publishResult = await nativeClient.domain.publish.mutate({
projectId: project.id,
domains,
destination: "saas",
destination: publishedDeploymentDestination,
});
if (publishResult.success === false) {
@@ -3,6 +3,7 @@ import type { ResourceRequest } from "@webstudio-is/sdk";
declare module "react-router" {
interface AppLoadContext {
EXCLUDE_FROM_SEARCH: boolean;
WEBSTUDIO_AUTOMATION_TOKEN?: string;
getDefaultActionResource?: (options: {
url: URL;
projectId: string;
@@ -3,6 +3,7 @@ import type { ResourceRequest } from "@webstudio-is/sdk";
declare module "react-router" {
interface AppLoadContext {
EXCLUDE_FROM_SEARCH: boolean;
WEBSTUDIO_AUTOMATION_TOKEN?: string;
getDefaultActionResource?: (options: {
url: URL;
projectId: string;
@@ -3,6 +3,7 @@ import type { ResourceRequest } from "@webstudio-is/sdk";
declare module "react-router" {
interface AppLoadContext {
EXCLUDE_FROM_SEARCH: boolean;
WEBSTUDIO_AUTOMATION_TOKEN?: string;
getDefaultActionResource?: (options: {
url: URL;
projectId: string;
@@ -3,6 +3,7 @@ import type { ResourceRequest } from "@webstudio-is/sdk";
declare module "react-router" {
interface AppLoadContext {
EXCLUDE_FROM_SEARCH: boolean;
WEBSTUDIO_AUTOMATION_TOKEN?: string;
getDefaultActionResource?: (options: {
url: URL;
projectId: string;
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/wrangler/config-schema.json",
// SaaS publishes Workers. This takes precedence over the Cloudflare Pages
// Hosted deployments publish Workers. This takes precedence over the Cloudflare Pages
// template's wrangler.toml; publish workflows provide the name and date.
"name": "webstudio-remix-app",
"compatibility_date": "2024-04-05"
@@ -9,9 +9,9 @@ const createRuntimeFetch = createGeneratedAssetResourceRuntime({
runtimeAssets,
});
export const createGeneratedAssetResourceFetch = ({ request, fallback }: {
export const createGeneratedAssetResourceFetch = ({ request, context, fallback }: {
request: Request;
context: unknown;
fallback: typeof fetch;
}) =>
createRuntimeFetch({ request, fallback });
createRuntimeFetch({ request, context, fallback });
@@ -1,45 +1,45 @@
var Ad=Object.defineProperty;var vd=(t,e)=>{for(var n in e)Ad(t,n,{get:e[n],enumerable:!0})};var ni;function b(t,e,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,c);let u=i.prototype,d=Object.keys(u);for(let l=0;l<d.length;l++){let f=d[l];f in a||(a[f]=u[f].bind(a))}}let o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:t});function i(a){var c;let u=n?.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let d of u._zod.deferred)d();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var Sy=Symbol("zod_brand"),Te=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Rt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(ni=globalThis).__zod_globalConfig??(ni.__zod_globalConfig={});var kt=globalThis.__zod_globalConfig;function xe(t){return t&&Object.assign(kt,t),kt}var F={};vd(F,{BIGINT_FORMAT_RANGES:()=>ai,Class:()=>bo,NUMBER_FORMAT_RANGES:()=>Ao,aborted:()=>et,allowsEval:()=>Eo,assert:()=>Od,assertEqual:()=>Dd,assertIs:()=>kd,assertNever:()=>Id,assertNotEqual:()=>Rd,assignProp:()=>Xe,base64ToUint8Array:()=>ui,base64urlToUint8Array:()=>Kd,cached:()=>Ot,captureStackTrace:()=>Wn,cleanEnum:()=>Jd,cleanRegex:()=>pn,clone:()=>Se,cloneDef:()=>Nd,createTransparentProxy:()=>Fd,defineLazy:()=>M,esc:()=>Kn,escapeRegex:()=>Ve,explicitlyAborted:()=>vo,extend:()=>jd,finalizeIssue:()=>he,floatSafeRemainder:()=>wo,getElementAtPath:()=>$d,getEnumValues:()=>fn,getLengthableOrigin:()=>mn,getParsedType:()=>Md,getSizableOrigin:()=>ci,hexToUint8Array:()=>Yd,isObject:()=>wt,isPlainObject:()=>He,issue:()=>Ct,joinValues:()=>Cd,jsonStringifyReplacer:()=>It,merge:()=>Qd,mergeDefs:()=>Qe,normalizeParams:()=>I,nullish:()=>dn,numKeys:()=>Ld,objectClone:()=>Td,omit:()=>Bd,optionalKeys:()=>So,parsedType:()=>qd,partial:()=>Vd,pick:()=>Zd,prefixIssues:()=>Ge,primitiveTypes:()=>si,promiseAllObject:()=>zd,propertyKeyTypes:()=>xo,randomString:()=>Pd,required:()=>Gd,safeExtend:()=>Ud,shallowClone:()=>oi,slugify:()=>_o,stringifyPrimitive:()=>ii,uint8ArrayToBase64:()=>li,uint8ArrayToBase64url:()=>Wd,uint8ArrayToHex:()=>Xd,unwrapMessage:()=>ln});function Dd(t){return t}function Rd(t){return t}function kd(t){}function Id(t){throw new Error("Unexpected value in exhaustive check")}function Od(t){}function fn(t){let e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,o])=>e.indexOf(+r)===-1).map(([r,o])=>o)}function Cd(t,e="|"){return t.map(n=>ii(n)).join(e)}function It(t,e){return typeof e=="bigint"?e.toString():e}function Ot(t){return{get value(){{let n=t();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function dn(t){return t==null}function pn(t){let e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function wo(t,e){let n=t/e,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}var ri=Symbol("evaluating");function M(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==ri)return r===void 0&&(r=ri,r=n()),r},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function Td(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function Xe(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Qe(...t){let e={};for(let n of t){let r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function Nd(t){return Qe(t._zod.def)}function $d(t,e){return e?e.reduce((n,r)=>n?.[r],t):t}function zd(t){let e=Object.keys(t),n=e.map(r=>t[r]);return Promise.all(n).then(r=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=r[s];return o})}function Pd(t=10){let e="abcdefghijklmnopqrstuvwxyz",n="";for(let r=0;r<t;r++)n+=e[Math.floor(Math.random()*e.length)];return n}function Kn(t){return JSON.stringify(t)}function _o(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Wn="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function wt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Eo=Ot(()=>{if(kt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function He(t){if(wt(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let n=e.prototype;return!(wt(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function oi(t){return He(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function Ld(t){let Line truncated
var Rd=Object.defineProperty;var kd=(t,e)=>{for(var n in e)Rd(t,n,{get:e[n],enumerable:!0})};var si;function w(t,e,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,c);let u=i.prototype,d=Object.keys(u);for(let l=0;l<d.length;l++){let f=d[l];f in a||(a[f]=u[f].bind(a))}}let o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:t});function i(a){var c;let u=n?.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let d of u._zod.deferred)d();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var Ry=Symbol("zod_brand"),Te=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Rt=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(si=globalThis).__zod_globalConfig??(si.__zod_globalConfig={});var kt=globalThis.__zod_globalConfig;function xe(t){return t&&Object.assign(kt,t),kt}var F={};kd(F,{BIGINT_FORMAT_RANGES:()=>li,Class:()=>Eo,NUMBER_FORMAT_RANGES:()=>Ro,aborted:()=>et,allowsEval:()=>Ao,assert:()=>Nd,assertEqual:()=>Id,assertIs:()=>Cd,assertNever:()=>Td,assertNotEqual:()=>Od,assignProp:()=>Xe,base64ToUint8Array:()=>di,base64urlToUint8Array:()=>Xd,cached:()=>Ot,captureStackTrace:()=>Wn,cleanEnum:()=>Yd,cleanRegex:()=>dn,clone:()=>Se,cloneDef:()=>Pd,createTransparentProxy:()=>jd,defineLazy:()=>M,esc:()=>Kn,escapeRegex:()=>Ve,explicitlyAborted:()=>ko,extend:()=>Vd,finalizeIssue:()=>he,floatSafeRemainder:()=>xo,getElementAtPath:()=>Ld,getEnumValues:()=>ln,getLengthableOrigin:()=>pn,getParsedType:()=>Bd,getSizableOrigin:()=>fi,hexToUint8Array:()=>ep,isObject:()=>wt,isPlainObject:()=>He,issue:()=>Ct,joinValues:()=>$d,jsonStringifyReplacer:()=>It,merge:()=>qd,mergeDefs:()=>Qe,normalizeParams:()=>I,nullish:()=>fn,numKeys:()=>Zd,objectClone:()=>zd,omit:()=>Qd,optionalKeys:()=>Do,parsedType:()=>Wd,partial:()=>Jd,pick:()=>Ud,prefixIssues:()=>Ge,primitiveTypes:()=>ci,promiseAllObject:()=>Md,propertyKeyTypes:()=>vo,randomString:()=>Fd,required:()=>Kd,safeExtend:()=>Gd,shallowClone:()=>ai,slugify:()=>So,stringifyPrimitive:()=>ui,uint8ArrayToBase64:()=>pi,uint8ArrayToBase64url:()=>Hd,uint8ArrayToHex:()=>tp,unwrapMessage:()=>un});function Id(t){return t}function Od(t){return t}function Cd(t){}function Td(t){throw new Error("Unexpected value in exhaustive check")}function Nd(t){}function ln(t){let e=Object.values(t).filter(r=>typeof r=="number");return Object.entries(t).filter(([r,o])=>e.indexOf(+r)===-1).map(([r,o])=>o)}function $d(t,e="|"){return t.map(n=>ui(n)).join(e)}function It(t,e){return typeof e=="bigint"?e.toString():e}function Ot(t){return{get value(){{let n=t();return Object.defineProperty(this,"value",{value:n}),n}throw new Error("cached value already set")}}}function fn(t){return t==null}function dn(t){let e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function xo(t,e){let n=t/e,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}var ii=Symbol("evaluating");function M(t,e,n){let r;Object.defineProperty(t,e,{get(){if(r!==ii)return r===void 0&&(r=ii,r=n()),r},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function zd(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function Xe(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Qe(...t){let e={};for(let n of t){let r=Object.getOwnPropertyDescriptors(n);Object.assign(e,r)}return Object.defineProperties({},e)}function Pd(t){return Qe(t._zod.def)}function Ld(t,e){return e?e.reduce((n,r)=>n?.[r],t):t}function Md(t){let e=Object.keys(t),n=e.map(r=>t[r]);return Promise.all(n).then(r=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=r[s];return o})}function Fd(t=10){let e="abcdefghijklmnopqrstuvwxyz",n="";for(let r=0;r<t;r++)n+=e[Math.floor(Math.random()*e.length)];return n}function Kn(t){return JSON.stringify(t)}function So(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Wn="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function wt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Ao=Ot(()=>{if(kt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function He(t){if(wt(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let n=e.prototype;return!(wt(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function ai(t){return He(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function Zd(t){let Line truncated
`).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 e=Function,n=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new e(...n,o.join(`
`))}};var da={major:4,minor:4,patch:3};var U=b("$ZodType",(t,e)=>{var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=da;let r=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&r.unshift(t);for(let o of r)for(let s of o._zod.onattach)s(t);if(r.length===0)(n=t._zod).deferred??(n.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let o=(i,a,c)=>{let u=et(i),d;for(let l of a){if(l._zod.def.when){if(vo(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&&c?.async===!1)throw new Te;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,i.issues.length!==f&&(u||(u=et(i,f)))});else{if(i.issues.length===f)continue;u||(u=et(i,f))}}return d?d.then(()=>i):i},s=(i,a,c)=>{if(et(i))return i.aborted=!0,i;let u=o(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new Te;return u.then(d=>t._zod.parse(d,c))}return t._zod.parse(u,c)};t._zod.run=(i,a)=>{if(a.skipChecks)return t._zod.parse(i,a);if(a.direction==="backward"){let u=t._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(d=>s(d,i,a)):s(u,i,a)}let c=t._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new Te;return c.then(u=>o(u,r,a))}return o(c,r,a)}}M(t,"~standard",()=>({validate:o=>{try{let s=mi(t,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return hi(t,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),or=b("$ZodString",(t,e)=>{U.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Gi(t._zod.bag),t._zod.parse=(n,r)=>{if(e.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:t}),n}}),Q=b("$ZodStringFormat",(t,e)=>{gn.init(t,e),or.init(t,e)}),Ea=b("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=Ci),Q.init(t,e)}),xa=b("$ZodUUID",(t,e)=>{if(e.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Ro(r))}else e.pattern??(e.pattern=Ro());Q.init(t,e)}),Sa=b("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=Ti),Q.init(t,e)}),Aa=b("$ZodURL",(t,e)=>{Q.init(t,e),t._zod.check=n=>{try{let r=n.value.trim();if(!e.normalize&&e.protocol?.source===Fi.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:t,continue:!e.abort});return}let o=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),va=b("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Ni()),Q.init(t,e)}),Da=b("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Ii),Q.init(t,e)}),Ra=b("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Ai),Q.init(t,e)}),ka=b("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=vi),Q.init(t,e)}),Ia=b("$ZodULID",(t,e)=>{e.pattern??(e.pattern=Di),Q.init(t,e)}),Oa=b("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Ri),Q.init(t,e)}),Ca=b("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=ki),Q.init(t,e)}),Ta=b("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Vi(e)),Q.init(t,e)}),Na=b("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=ji),Q.init(t,e)}),$a=b("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Qi(e)),Q.init(t,e)}),za=b("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Oi),Q.init(t,e)}),Pa=b("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=$i),Q.init(t,e),t._zod.bag.format="ipv4"}),La=b("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=zi),Q.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}});var Ma=b("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=Pi),Q.init(t,e)}),Fa=b("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Li),Q.init(t,e),t._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:t,continue:!e.abort})}}});function Za(t){if(t==="")return!0;if(/\s/.test(t)||t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var Ba=b("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Mi),Q.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{Za(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});func Line truncated
`))}};var ha={major:4,minor:4,patch:3};var U=w("$ZodType",(t,e)=>{var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=ha;let r=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&r.unshift(t);for(let o of r)for(let s of o._zod.onattach)s(t);if(r.length===0)(n=t._zod).deferred??(n.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let o=(i,a,c)=>{let u=et(i),d;for(let l of a){if(l._zod.def.when){if(ko(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&&c?.async===!1)throw new Te;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,i.issues.length!==f&&(u||(u=et(i,f)))});else{if(i.issues.length===f)continue;u||(u=et(i,f))}}return d?d.then(()=>i):i},s=(i,a,c)=>{if(et(i))return i.aborted=!0,i;let u=o(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new Te;return u.then(d=>t._zod.parse(d,c))}return t._zod.parse(u,c)};t._zod.run=(i,a)=>{if(a.skipChecks)return t._zod.parse(i,a);if(a.direction==="backward"){let u=t._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(d=>s(d,i,a)):s(u,i,a)}let c=t._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new Te;return c.then(u=>o(u,r,a))}return o(c,r,a)}}M(t,"~standard",()=>({validate:o=>{try{let s=gi(t,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return bi(t,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),or=w("$ZodString",(t,e)=>{U.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Ki(t._zod.bag),t._zod.parse=(n,r)=>{if(e.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:t}),n}}),Q=w("$ZodStringFormat",(t,e)=>{yn.init(t,e),or.init(t,e)}),Aa=w("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=$i),Q.init(t,e)}),va=w("$ZodUUID",(t,e)=>{if(e.version){let r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(r===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Oo(r))}else e.pattern??(e.pattern=Oo());Q.init(t,e)}),Da=w("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=zi),Q.init(t,e)}),Ra=w("$ZodURL",(t,e)=>{Q.init(t,e),t._zod.check=n=>{try{let r=n.value.trim();if(!e.normalize&&e.protocol?.source===ji.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:t,continue:!e.abort});return}let o=new URL(r);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),ka=w("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Pi()),Q.init(t,e)}),Ia=w("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Ti),Q.init(t,e)}),Oa=w("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Ri),Q.init(t,e)}),Ca=w("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=ki),Q.init(t,e)}),Ta=w("$ZodULID",(t,e)=>{e.pattern??(e.pattern=Ii),Q.init(t,e)}),Na=w("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Oi),Q.init(t,e)}),$a=w("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Ci),Q.init(t,e)}),za=w("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Ji(e)),Q.init(t,e)}),Pa=w("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Vi),Q.init(t,e)}),La=w("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=qi(e)),Q.init(t,e)}),Ma=w("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Ni),Q.init(t,e)}),Fa=w("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Li),Q.init(t,e),t._zod.bag.format="ipv4"}),Za=w("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Mi),Q.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}});var Ba=w("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=Fi),Q.init(t,e)}),ja=w("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Zi),Q.init(t,e),t._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:t,continue:!e.abort})}}});function Ua(t){if(t==="")return!0;if(/\s/.test(t)||t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var Qa=w("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Bi),Q.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{Ua(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});func Line truncated
if (${_}.issues.length) {
if (${w} in input) {
if (${b} in input) {
payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
...iss,
path: iss.path ? [${w}, ...iss.path] : [${w}]
path: iss.path ? [${b}, ...iss.path] : [${b}]
})));
}
}
if (${_}.value === undefined) {
if (${w} in input) {
newResult[${w}] = undefined;
if (${b} in input) {
newResult[${b}] = undefined;
}
} else {
newResult[${w}] = ${_}.value;
newResult[${b}] = ${_}.value;
}
`):D?p.write(`
if (${_}.issues.length) {
payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
...iss,
path: iss.path ? [${w}, ...iss.path] : [${w}]
path: iss.path ? [${b}, ...iss.path] : [${b}]
})));
}
if (${_}.value === undefined) {
if (${w} in input) {
newResult[${w}] = undefined;
if (${b} in input) {
newResult[${b}] = undefined;
}
} else {
newResult[${w}] = ${_}.value;
newResult[${b}] = ${_}.value;
}
`):p.write(`
const ${_}_present = ${w} in input;
const ${_}_present = ${b} in input;
if (${_}.issues.length) {
payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
...iss,
path: iss.path ? [${w}, ...iss.path] : [${w}]
path: iss.path ? [${b}, ...iss.path] : [${b}]
})));
}
if (!${_}_present && !${_}.issues.length) {
@@ -47,91 +47,91 @@ var Ad=Object.defineProperty;var vd=(t,e)=>{for(var n in e)Ad(t,n,{get:e[n],enum
code: "invalid_type",
expected: "nonoptional",
input: undefined,
path: [${w}]
path: [${b}]
});
}
if (${_}_present) {
if (${_}.value === undefined) {
newResult[${w}] = undefined;
newResult[${b}] = undefined;
} else {
newResult[${w}] = ${_}.value;
newResult[${b}] = ${_}.value;
}
}
`)}p.write("payload.value = newResult;"),p.write("return payload;");let E=p.compile();return(S,_)=>E(f,S,_)},s,i=wt,a=!kt.jitless,u=a&&Eo.value,d=e.catchall,l;t._zod.parse=(f,p)=>{l??(l=r.value);let g=f.value;return i(g)?a&&u&&p?.async===!1&&p.jitless!==!0?(s||(s=o(e.shape)),f=s(f,p),d?Xa([],g,f,p,l,t):f):n(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:g,inst:t}),f)}});function ma(t,e,n,r){for(let s of t)if(s.issues.length===0)return e.value=s.value,e;let o=t.filter(s=>!et(s));return o.length===1?(e.value=o[0].value,o[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(s=>s.issues.map(i=>he(i,r,xe())))}),e)}var $o=b("$ZodUnion",(t,e)=>{U.init(t,e),M(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),M(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),M(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),M(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){let r=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>pn(o.source)).join("|")})$`)}});let n=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(r,o)=>{if(n)return n(r,o);let s=!1,i=[];for(let a of e.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>ma(a,r,t,o)):ma(i,r,t,o)}});var ec=b("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,$o.init(t,e);let n=t._zod.parse;M(t._zod,"propValues",()=>{let o={};for(let s of e.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let r=Ot(()=>{let o=e.options,s=new Map;for(let i of o){let a=i._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});t._zod.parse=(o,s)=>{let i=o.value;if(!wt(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),o;let a=r.value.get(i?.[e.discriminator]);return a?a._zod.run(o,s):e.unionFallback||s.direction==="backward"?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(r.value.keys()),input:i,path:[e.discriminator],inst:t}),o)}}),tc=b("$ZodIntersection",(t,e)=>{U.init(t,e),t._zod.parse=(n,r)=>{let o=n.value,s=e.left._zod.run({value:o,issues:[]},r),i=e.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>ha(n,c,u)):ha(n,s,i)}});function To(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(He(t)&&He(e)){let n=Object.keys(e),r=Object.keys(t).filter(s=>n.indexOf(s)!==-1),o={...t,...e};for(let s of r){let i=To(t[s],e[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<t.length;r++){let o=t[r],s=e[r],i=To(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 ha(t,e,n){let r=new Map,o;for(let a of e.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(let c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else t.issues.push(a);for(let a of n.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else t.issues.push(a);let s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&o&&t.issues.push({...o,keys:s}),et(t))return t;let i=To(e.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return t.value=i.data,t}var nc=b("$ZodRecord",(t,e)=>{U.init(t,e),t._zod.parse=(n,r)=>{let o=n.value;if(!He(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),n;let s=[],i=e.keyType._zod.values;if(i){n.value={};let a=new Set;for(let u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let d=e.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=>he(p,r,xe())),input:u,path:[u],inst:t});continue}let l=d.value,f=e.valueType._zod.run({value:o[u],issues:[]},r);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&n.issues.push(...Ge(u,p.issues)),n.value[l]=p.value})):(f.issues.length&&n.issues.push(...Ge(u,f.issues)) Line truncated
`)}p.write("payload.value = newResult;"),p.write("return payload;");let x=p.compile();return(S,_)=>x(f,S,_)},s,i=wt,a=!kt.jitless,u=a&&Ao.value,d=e.catchall,l;t._zod.parse=(f,p)=>{l??(l=r.value);let g=f.value;return i(g)?a&&u&&p?.async===!1&&p.jitless!==!0?(s||(s=o(e.shape)),f=s(f,p),d?tc([],g,f,p,l,t):f):n(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:g,inst:t}),f)}});function ga(t,e,n,r){for(let s of t)if(s.issues.length===0)return e.value=s.value,e;let o=t.filter(s=>!et(s));return o.length===1?(e.value=o[0].value,o[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(s=>s.issues.map(i=>he(i,r,xe())))}),e)}var Lo=w("$ZodUnion",(t,e)=>{U.init(t,e),M(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),M(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),M(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),M(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){let r=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>dn(o.source)).join("|")})$`)}});let n=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(r,o)=>{if(n)return n(r,o);let s=!1,i=[];for(let a of e.options){let c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>ga(a,r,t,o)):ga(i,r,t,o)}});var rc=w("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,Lo.init(t,e);let n=t._zod.parse;M(t._zod,"propValues",()=>{let o={};for(let s of e.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let r=Ot(()=>{let o=e.options,s=new Map;for(let i of o){let a=i._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});t._zod.parse=(o,s)=>{let i=o.value;if(!wt(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),o;let a=r.value.get(i?.[e.discriminator]);return a?a._zod.run(o,s):e.unionFallback||s.direction==="backward"?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(r.value.keys()),input:i,path:[e.discriminator],inst:t}),o)}}),oc=w("$ZodIntersection",(t,e)=>{U.init(t,e),t._zod.parse=(n,r)=>{let o=n.value,s=e.left._zod.run({value:o,issues:[]},r),i=e.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>ba(n,c,u)):ba(n,s,i)}});function zo(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(He(t)&&He(e)){let n=Object.keys(e),r=Object.keys(t).filter(s=>n.indexOf(s)!==-1),o={...t,...e};for(let s of r){let i=zo(t[s],e[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<t.length;r++){let o=t[r],s=e[r],i=zo(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 ba(t,e,n){let r=new Map,o;for(let a of e.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(let c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else t.issues.push(a);for(let a of n.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else t.issues.push(a);let s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&o&&t.issues.push({...o,keys:s}),et(t))return t;let i=zo(e.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return t.value=i.data,t}var sc=w("$ZodRecord",(t,e)=>{U.init(t,e),t._zod.parse=(n,r)=>{let o=n.value;if(!He(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),n;let s=[],i=e.keyType._zod.values;if(i){n.value={};let a=new Set;for(let u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let d=e.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=>he(p,r,xe())),input:u,path:[u],inst:t});continue}let l=d.value,f=e.valueType._zod.run({value:o[u],issues:[]},r);f instanceof Promise?s.push(f.then(p=>{p.issues.length&&n.issues.push(...Ge(u,p.issues)),n.value[l]=p.value})):(f.issues.length&&n.issues.push(...Ge(u,f.issues)) Line truncated
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of t.seen.entries()){let a=i[1];if(e===i[0]){s(i);continue}if(t.external){let u=t.external.registry.get(i[0])?.id;if(e!==i[0]&&u){s(i);continue}}if(t.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&t.reused==="ref"){s(i);continue}}}function Yo(t,e){let n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=a=>{let c=t.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,d={...u},l=c.ref;if(c.ref=null,l){r(l);let p=t.seen.get(l),g=p.schema;if(g.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(g)):Object.assign(u,g),Object.assign(u,d),a._zod.parent===l)for(let h in u)h==="$ref"||h==="allOf"||h in d||delete u[h];if(g.$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=a._zod.parent;if(f&&f!==l){r(f);let p=t.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let g in u)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(u[g])===JSON.stringify(p.def[g])&&delete u[g]}t.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...t.seen.entries()].reverse())r(a[0]);let o={};if(t.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=t.external.uri(a)}Object.assign(o,n.def??n.schema);let s=t.metadataRegistry.get(e)?.id;s!==void 0&&o.id===s&&delete o.id;let i=t.external?.defs??{};for(let a of t.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,i[c.defId]=c.def)}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:_n(e,"input",t.processors),output:_n(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function oe(t,e){let n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);let r=t._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return oe(r.element,n);if(r.type==="set")return oe(r.valueType,n);if(r.type==="lazy")return oe(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 oe(r.innerType,n);if(r.type==="intersection")return oe(r.left,n)||oe(r.right,n);if(r.type==="record"||r.type==="map")return oe(r.keyType,n)||oe(r.valueType,n);if(r.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:oe(r.in,n)||oe(r.out,n);if(r.type==="object"){for(let o in r.shape)if(oe(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(let o of r.options)if(oe(o,n))return!0;return!1}if(r.type==="tuple"){for(let o of r.items)if(oe(o,n))return!0;return!!(r.rest&&oe(r.rest,n))}return!1}var Xc=(t,e={})=>n=>{let r=Ko({...n,processors:e});return J(t,r),Wo(r,t),Yo(r,t)},_n=(t,e,n={})=>r=>{let{libraryOptions:o,target:s}=r??{},i=Ko({...o??{},target:s,io:e,processors:n});return J(t,i),Wo(i,t),Yo(i,t)};var ip={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Hc=(t,e,n,r)=>{let o=n;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=t._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=ip[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let d=[...c];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(l=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:l.source}))])}},eu=(t,e,n,r)=>{let o=n,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=t._zod.bag;typeof a=="string"&&a.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=e.target==="draft-04"||e.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 c=="number"&&(o.multipleOf=c)},tu=(t,e,n,r)=>{n.type="boolean"};var nu=(t,e,n,r)=>{e.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"};var ru=(t,e,n,r)=>{n.not={}};var ou=(t,e,n,r)=>{};var su=(t,e,n,r)=>{let o=t._zod.def,s=fn(o.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},iu=(t,e,n,r)=>{let o=t._zod.def,Line truncated
`)}};Ze.defaultYaml={explicit:!1,version:"1.2"};Ze.defaultTags={"!!":"tag:yaml.org,2002:"};function Dr(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function ps(t){let e=new Set;return Fe(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function ms(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function Pl(t,e){let n=[],r=new Map,o=null;return{onAnchor:s=>{n.push(s),o??(o=ps(t));let i=ms(e,o);return o.add(i),i},setAnchors:()=>{for(let s of n){let i=r.get(s);if(typeof i=="object"&&i.anchor&&(T(i.node)||B(i.node)))i.node.anchor=i.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=s,a}}},sourceObjects:r}}function at(t,e,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],a=at(t,r,String(o),i);a===void 0?delete r[o]:a!==i&&(r[o]=a)}else if(r instanceof Map)for(let o of Array.from(r.keys())){let s=r.get(o),i=at(t,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=at(t,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=at(t,r,o,s);i===void 0?delete r[o]:i!==s&&(r[o]=i)}return t.call(e,n,r)}function H(t,e,n){if(Array.isArray(t))return t.map((r,o)=>H(r,String(o),n));if(t&&typeof t.toJSON=="function"){if(!n||!Ar(t))return t.toJSON(e,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(t,r),n.onCreate=s=>{r.res=s,delete n.onCreate};let o=t.toJSON(e,n);return n.onCreate&&n.onCreate(o),o}return typeof t=="bigint"&&!n?.keep?Number(t):t}var ct=class{constructor(e){Object.defineProperty(this,ie,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:n,maxAliasCount:r,onAnchor:o,reviver:s}={}){if(!Le(e))throw new TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=H(this,"",i);if(typeof o=="function")for(let{count:c,res:u}of i.anchors.values())o(u,c);return typeof s=="function"?at(s,{"":a},"",a):a}};var Ke=class extends ct{constructor(e){super(xr),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){if(n?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],Fe(e,{Node:(s,i)=>{(ye(i)||Ar(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(e,n){if(!n)return{source:this.source};let{anchors:r,doc:o,maxAliasCount:s}=n,i=this.resolve(o,n);if(!i){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let a=r.get(i);if(a||(H(i,null,n),a=r.get(i)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(s>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Rr(o,i,r)),a.count*a.aliasCount>s)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return a.res}toString(e,n,r){let o=`*${this.source}`;if(e){if(Dr(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(s)}if(e.implicitKey)return`${o} `}return o}};function Rr(t,e,n){if(ye(e)){let r=e.resolve(t),o=n&&r&&n.get(r);return o?o.count*o.aliasCount:0}else if(B(e)){let r=0;for(let o of e.items){let s=Rr(t,o,n);s>r&&(r=s)}return r}else if($(e)){let r=Rr(t,e.key,n),o=Rr(t,e.value,n);return Math.max(r,o)}return 1}var kr=t=>!t||typeof t!="function"&&typeof t!="object",R=class extends ct{constructor(e){super(pe),this.value=e}toJSON(e,n){return n?.keep?this.value:H(this.value,e,n)}toString(){return String(this.value)}};R.BLOCK_FOLDED="BLOCK_FOLDED";R.BLOCK_LITERAL="BLOCK_LITERAL";R.PLAIN="PLAIN";R.QUOTE_DOUBLE="QUOTE_DOUBLE";R.QUOTE_SINGLE="QUOTE_SINGLE";var Hm="tag:yaml.org,2002:";function eh(t,e,n){if(e){let r=n.filter(s=>s.tag===e),o=r.find(s=>!s.format)??r[0];if(!o)throw new Error(`Tag ${e} not found`);return o}return n.find(r=>r.identify?.(t)&&!r.format)}function We(t,e,n){if(Le(t)&&(t=t.contents),z(t))return t;if($(t)){let l=n.schema[ve].createNode?.(n.schema,null,n);return l.items.push(t),l}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:o,onTagObj:s,schema:i,sourceObjects:a}=n,c;if(r&&t&&typeof t=="object"){if(c=a.get(t),c)return c.anchor??(c.anchor=o(t)),new Ke(c.anchor);c={anchor:null,node:null},a.set(t,c)}e?.startsWith("!!")&&(e=Hm+e.slice(2));let u=eh(t,e,i.tags);if(!u){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let l=new Line truncated
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of t.seen.entries()){let a=i[1];if(e===i[0]){s(i);continue}if(t.external){let u=t.external.registry.get(i[0])?.id;if(e!==i[0]&&u){s(i);continue}}if(t.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&t.reused==="ref"){s(i);continue}}}function es(t,e){let n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let r=a=>{let c=t.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,d={...u},l=c.ref;if(c.ref=null,l){r(l);let p=t.seen.get(l),g=p.schema;if(g.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(g)):Object.assign(u,g),Object.assign(u,d),a._zod.parent===l)for(let h in u)h==="$ref"||h==="allOf"||h in d||delete u[h];if(g.$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=a._zod.parent;if(f&&f!==l){r(f);let p=t.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let g in u)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(u[g])===JSON.stringify(p.def[g])&&delete u[g]}t.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...t.seen.entries()].reverse())r(a[0]);let o={};if(t.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=t.external.uri(a)}Object.assign(o,n.def??n.schema);let s=t.metadataRegistry.get(e)?.id;s!==void 0&&o.id===s&&delete o.id;let i=t.external?.defs??{};for(let a of t.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,i[c.defId]=c.def)}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:wn(e,"input",t.processors),output:wn(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function oe(t,e){let n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);let r=t._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return oe(r.element,n);if(r.type==="set")return oe(r.valueType,n);if(r.type==="lazy")return oe(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 oe(r.innerType,n);if(r.type==="intersection")return oe(r.left,n)||oe(r.right,n);if(r.type==="record"||r.type==="map")return oe(r.keyType,n)||oe(r.valueType,n);if(r.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:oe(r.in,n)||oe(r.out,n);if(r.type==="object"){for(let o in r.shape)if(oe(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(let o of r.options)if(oe(o,n))return!0;return!1}if(r.type==="tuple"){for(let o of r.items)if(oe(o,n))return!0;return!!(r.rest&&oe(r.rest,n))}return!1}var tu=(t,e={})=>n=>{let r=Xo({...n,processors:e});return J(t,r),Ho(r,t),es(r,t)},wn=(t,e,n={})=>r=>{let{libraryOptions:o,target:s}=r??{},i=Xo({...o??{},target:s,io:e,processors:n});return J(t,i),Ho(i,t),es(i,t)};var up={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},nu=(t,e,n,r)=>{let o=n;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=t._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=up[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let d=[...c];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(l=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:l.source}))])}},ru=(t,e,n,r)=>{let o=n,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=t._zod.bag;typeof a=="string"&&a.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=e.target==="draft-04"||e.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 c=="number"&&(o.multipleOf=c)},ou=(t,e,n,r)=>{n.type="boolean"};var su=(t,e,n,r)=>{e.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"};var iu=(t,e,n,r)=>{n.not={}};var au=(t,e,n,r)=>{};var cu=(t,e,n,r)=>{let o=t._zod.def,s=ln(o.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},uu=(t,e,n,r)=>{let o=t._zod.def,Line truncated
`)}};Ze.defaultYaml={explicit:!1,version:"1.2"};Ze.defaultTags={"!!":"tag:yaml.org,2002:"};function kr(t){if(/[\x00-\x19\s,[\]{}]/.test(t)){let n=`Anchor must not contain whitespace or control characters: ${JSON.stringify(t)}`;throw new Error(n)}return!0}function ys(t){let e=new Set;return Fe(t,{Value(n,r){r.anchor&&e.add(r.anchor)}}),e}function gs(t,e){for(let n=1;;++n){let r=`${t}${n}`;if(!e.has(r))return r}}function Ml(t,e){let n=[],r=new Map,o=null;return{onAnchor:s=>{n.push(s),o??(o=ys(t));let i=gs(e,o);return o.add(i),i},setAnchors:()=>{for(let s of n){let i=r.get(s);if(typeof i=="object"&&i.anchor&&(T(i.node)||B(i.node)))i.node.anchor=i.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=s,a}}},sourceObjects:r}}function at(t,e,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],a=at(t,r,String(o),i);a===void 0?delete r[o]:a!==i&&(r[o]=a)}else if(r instanceof Map)for(let o of Array.from(r.keys())){let s=r.get(o),i=at(t,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=at(t,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=at(t,r,o,s);i===void 0?delete r[o]:i!==s&&(r[o]=i)}return t.call(e,n,r)}function H(t,e,n){if(Array.isArray(t))return t.map((r,o)=>H(r,String(o),n));if(t&&typeof t.toJSON=="function"){if(!n||!Dr(t))return t.toJSON(e,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(t,r),n.onCreate=s=>{r.res=s,delete n.onCreate};let o=t.toJSON(e,n);return n.onCreate&&n.onCreate(o),o}return typeof t=="bigint"&&!n?.keep?Number(t):t}var ct=class{constructor(e){Object.defineProperty(this,ie,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:n,maxAliasCount:r,onAnchor:o,reviver:s}={}){if(!Le(e))throw new TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=H(this,"",i);if(typeof o=="function")for(let{count:c,res:u}of i.anchors.values())o(u,c);return typeof s=="function"?at(s,{"":a},"",a):a}};var Ke=class extends ct{constructor(e){super(Ar),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,n){if(n?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;n?.aliasResolveCache?r=n.aliasResolveCache:(r=[],Fe(e,{Node:(s,i)=>{(ye(i)||Dr(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(e,n){if(!n)return{source:this.source};let{anchors:r,doc:o,maxAliasCount:s}=n,i=this.resolve(o,n);if(!i){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let a=r.get(i);if(a||(H(i,null,n),a=r.get(i)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(s>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Ir(o,i,r)),a.count*a.aliasCount>s)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return a.res}toString(e,n,r){let o=`*${this.source}`;if(e){if(kr(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let s=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(s)}if(e.implicitKey)return`${o} `}return o}};function Ir(t,e,n){if(ye(e)){let r=e.resolve(t),o=n&&r&&n.get(r);return o?o.count*o.aliasCount:0}else if(B(e)){let r=0;for(let o of e.items){let s=Ir(t,o,n);s>r&&(r=s)}return r}else if($(e)){let r=Ir(t,e.key,n),o=Ir(t,e.value,n);return Math.max(r,o)}return 1}var Or=t=>!t||typeof t!="function"&&typeof t!="object",R=class extends ct{constructor(e){super(pe),this.value=e}toJSON(e,n){return n?.keep?this.value:H(this.value,e,n)}toString(){return String(this.value)}};R.BLOCK_FOLDED="BLOCK_FOLDED";R.BLOCK_LITERAL="BLOCK_LITERAL";R.PLAIN="PLAIN";R.QUOTE_DOUBLE="QUOTE_DOUBLE";R.QUOTE_SINGLE="QUOTE_SINGLE";var nh="tag:yaml.org,2002:";function rh(t,e,n){if(e){let r=n.filter(s=>s.tag===e),o=r.find(s=>!s.format)??r[0];if(!o)throw new Error(`Tag ${e} not found`);return o}return n.find(r=>r.identify?.(t)&&!r.format)}function We(t,e,n){if(Le(t)&&(t=t.contents),z(t))return t;if($(t)){let l=n.schema[ve].createNode?.(n.schema,null,n);return l.items.push(t),l}(t instanceof String||t instanceof Number||t instanceof Boolean||typeof BigInt<"u"&&t instanceof BigInt)&&(t=t.valueOf());let{aliasDuplicateObjects:r,onAnchor:o,onTagObj:s,schema:i,sourceObjects:a}=n,c;if(r&&t&&typeof t=="object"){if(c=a.get(t),c)return c.anchor??(c.anchor=o(t)),new Ke(c.anchor);c={anchor:null,node:null},a.set(t,c)}e?.startsWith("!!")&&(e=nh+e.slice(2));let u=rh(t,e,i.tags);if(!u){if(t&&typeof t.toJSON=="function"&&(t=t.toJSON()),!t||typeof t!="object"){let l=new Line truncated
`)?we(n,e):n.includes(`
`)?`
`+we(n,e):(t.endsWith(" ")?"":" ")+n;var hs="flow",Ir="block",Rn="quoted";function kn(t,e,n="flow",{indentAtStart:r,lineWidth:o=80,minContentWidth:s=20,onFold:i,onOverflow:a}={}){if(!o||o<0)return t;o<s&&(s=0);let c=Math.max(1+s,1+o-e.length);if(t.length<=c)return t;let u=[],d={},l=o-e.length;typeof r=="number"&&(r>o-Math.max(2,s)?u.push(0):l=o-r);let f,p,g=!1,m=-1,h=-1,y=-1;n===Ir&&(m=Ml(t,m,e.length),m!==-1&&(l=m+c));for(let S;S=t[m+=1];){if(n===Rn&&S==="\\"){switch(h=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}y=m}if(S===`
`)n===Ir&&(m=Ml(t,m,e.length)),l=m+e.length+c,f=void 0;else{if(S===" "&&p&&p!==" "&&p!==`
`+we(n,e):(t.endsWith(" ")?"":" ")+n;var bs="flow",Cr="block",Rn="quoted";function kn(t,e,n="flow",{indentAtStart:r,lineWidth:o=80,minContentWidth:s=20,onFold:i,onOverflow:a}={}){if(!o||o<0)return t;o<s&&(s=0);let c=Math.max(1+s,1+o-e.length);if(t.length<=c)return t;let u=[],d={},l=o-e.length;typeof r=="number"&&(r>o-Math.max(2,s)?u.push(0):l=o-r);let f,p,g=!1,m=-1,h=-1,y=-1;n===Cr&&(m=Zl(t,m,e.length),m!==-1&&(l=m+c));for(let S;S=t[m+=1];){if(n===Rn&&S==="\\"){switch(h=m,t[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}y=m}if(S===`
`)n===Cr&&(m=Zl(t,m,e.length)),l=m+e.length+c,f=void 0;else{if(S===" "&&p&&p!==" "&&p!==`
`&&p!==" "){let _=t[m+1];_&&_!==" "&&_!==`
`&&_!==" "&&(f=m)}if(m>=l)if(f)u.push(f),l=f+c,f=void 0;else if(n===Rn){for(;p===" "||p===" ";)p=S,S=t[m+=1],g=!0;let _=m>y+1?m-2:h-1;if(d[_])return t;u.push(_),d[_]=!0,l=_+c,f=void 0}else g=!0}p=S}if(g&&a&&a(),u.length===0)return t;i&&i();let E=t.slice(0,u[0]);for(let S=0;S<u.length;++S){let _=u[S],w=u[S+1]||t.length;_===0?E=`
${e}${t.slice(0,w)}`:(n===Rn&&d[_]&&(E+=`${t[_]}\\`),E+=`
${e}${t.slice(_+1,w)}`)}return E}function Ml(t,e,n){let r=e,o=e+1,s=t[o];for(;s===" "||s===" ";)if(e<o+n)s=t[++e];else{do s=t[++e];while(s&&s!==`
`);r=e,o=e+1,s=t[o]}return r}var Cr=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),Tr=t=>/^(%|---|\.\.\.)/m.test(t);function th(t,e,n){if(!e||e<0)return!1;let r=e-n,o=t.length;if(o<=r)return!1;for(let s=0,i=0;s<o;++s)if(t[s]===`
`){if(s-i>r)return!0;if(i=s+1,o-i<=r)return!1}return!0}function In(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,o=e.options.doubleQuotedMinMultiLineLength,s=e.indent||(Tr(t)?" ":""),i="",a=0;for(let c=0,u=n[c];u;u=n[++c])if(u===" "&&n[c+1]==="\\"&&n[c+2]==="n"&&(i+=n.slice(a,c)+"\\ ",c+=1,a=c,u="\\"),u==="\\")switch(n[c+1]){case"u":{i+=n.slice(a,c);let d=n.substr(c+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(c,6)}c+=5,a=c+1}break;case"n":if(r||n[c+2]==='"'||n.length<o)c+=1;else{for(i+=n.slice(a,c)+`
`&&_!==" "&&(f=m)}if(m>=l)if(f)u.push(f),l=f+c,f=void 0;else if(n===Rn){for(;p===" "||p===" ";)p=S,S=t[m+=1],g=!0;let _=m>y+1?m-2:h-1;if(d[_])return t;u.push(_),d[_]=!0,l=_+c,f=void 0}else g=!0}p=S}if(g&&a&&a(),u.length===0)return t;i&&i();let x=t.slice(0,u[0]);for(let S=0;S<u.length;++S){let _=u[S],b=u[S+1]||t.length;_===0?x=`
${e}${t.slice(0,b)}`:(n===Rn&&d[_]&&(x+=`${t[_]}\\`),x+=`
${e}${t.slice(_+1,b)}`)}return x}function Zl(t,e,n){let r=e,o=e+1,s=t[o];for(;s===" "||s===" ";)if(e<o+n)s=t[++e];else{do s=t[++e];while(s&&s!==`
`);r=e,o=e+1,s=t[o]}return r}var Nr=(t,e)=>({indentAtStart:e?t.indent.length:t.indentAtStart,lineWidth:t.options.lineWidth,minContentWidth:t.options.minContentWidth}),$r=t=>/^(%|---|\.\.\.)/m.test(t);function oh(t,e,n){if(!e||e<0)return!1;let r=e-n,o=t.length;if(o<=r)return!1;for(let s=0,i=0;s<o;++s)if(t[s]===`
`){if(s-i>r)return!0;if(i=s+1,o-i<=r)return!1}return!0}function In(t,e){let n=JSON.stringify(t);if(e.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=e,o=e.options.doubleQuotedMinMultiLineLength,s=e.indent||($r(t)?" ":""),i="",a=0;for(let c=0,u=n[c];u;u=n[++c])if(u===" "&&n[c+1]==="\\"&&n[c+2]==="n"&&(i+=n.slice(a,c)+"\\ ",c+=1,a=c,u="\\"),u==="\\")switch(n[c+1]){case"u":{i+=n.slice(a,c);let d=n.substr(c+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(c,6)}c+=5,a=c+1}break;case"n":if(r||n[c+2]==='"'||n.length<o)c+=1;else{for(i+=n.slice(a,c)+`
`;n[c+2]==="\\"&&n[c+3]==="n"&&n[c+4]!=='"';)i+=`
`,c+=2;i+=s,n[c+2]===" "&&(i+="\\"),c+=1,a=c+1}break;default:c+=1}return i=a?i+n.slice(a):n,r?i:kn(i,s,Rn,Cr(e,!1))}function ys(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
`)||/[ \t]\n|\n[ \t]/.test(t))return In(t,e);let n=e.indent||(Tr(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
${n}`)+"'";return e.implicitKey?r:kn(r,n,hs,Cr(e,!1))}function Vt(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=In;else{let o=t.includes('"'),s=t.includes("'");o&&!s?r=ys:s&&!o?r=In:r=n?ys:In}return r(t,e)}var gs;try{gs=new RegExp(`(^|(?<!
`,c+=2;i+=s,n[c+2]===" "&&(i+="\\"),c+=1,a=c+1}break;default:c+=1}return i=a?i+n.slice(a):n,r?i:kn(i,s,Rn,Nr(e,!1))}function ws(t,e){if(e.options.singleQuote===!1||e.implicitKey&&t.includes(`
`)||/[ \t]\n|\n[ \t]/.test(t))return In(t,e);let n=e.indent||($r(t)?" ":""),r="'"+t.replace(/'/g,"''").replace(/\n+/g,`$&
${n}`)+"'";return e.implicitKey?r:kn(r,n,bs,Nr(e,!1))}function Qt(t,e){let{singleQuote:n}=e.options,r;if(n===!1)r=In;else{let o=t.includes('"'),s=t.includes("'");o&&!s?r=ws:s&&!o?r=In:r=n?ws:In}return r(t,e)}var _s;try{_s=new RegExp(`(^|(?<!
))
+(?!
|$)`,"g")}catch{gs=/\n+(?!\n|$)/g}function Or({comment:t,type:e,value:n},r,o,s){let{blockQuote:i,commentString:a,lineWidth:c}=r.options;if(!i||/\n[\t ]+$/.test(n))return Vt(n,r);let u=r.indent||(r.forceBlockIndent||Tr(n)?" ":""),d=i==="literal"?!0:i==="folded"||e===R.BLOCK_FOLDED?!1:e===R.BLOCK_LITERAL?!0:!th(n,c,u.length);if(!n)return d?`|
|$)`,"g")}catch{_s=/\n+(?!\n|$)/g}function Tr({comment:t,type:e,value:n},r,o,s){let{blockQuote:i,commentString:a,lineWidth:c}=r.options;if(!i||/\n[\t ]+$/.test(n))return Qt(n,r);let u=r.indent||(r.forceBlockIndent||$r(n)?" ":""),d=i==="literal"?!0:i==="folded"||e===R.BLOCK_FOLDED?!1:e===R.BLOCK_LITERAL?!0:!oh(n,c,u.length);if(!n)return d?`|
`:`>
`;let l,f;for(f=n.length;f>0;--f){let w=n[f-1];if(w!==`
`&&w!==" "&&w!==" ")break}let p=n.substring(f),g=p.indexOf(`
`;let l,f;for(f=n.length;f>0;--f){let b=n[f-1];if(b!==`
`&&b!==" "&&b!==" ")break}let p=n.substring(f),g=p.indexOf(`
`);g===-1?l="-":n===p||g!==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(gs,`$&${u}`));let m=!1,h,y=-1;for(h=0;h<n.length;++h){let w=n[h];if(w===" ")m=!0;else if(w===`
`)y=h;else break}let E=n.substring(0,y<h?y+1:h);E&&(n=n.substring(E.length),E=E.replace(/\n+/g,`$&${u}`));let _=(m?u?"2":"1":"")+l;if(t&&(_+=" "+a(t.replace(/ ?[\r\n]+/g," ")),o&&o()),!d){let w=n.replace(/\n+/g,`
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${u}`),A=!1,D=Cr(r,!0);i!=="folded"&&e!==R.BLOCK_FOLDED&&(D.onOverflow=()=>{A=!0});let x=kn(`${E}${w}${p}`,u,Ir,D);if(!A)return`>${_}
${u}${x}`}return n=n.replace(/\n+/g,`$&${u}`),`|${_}
${u}${E}${n}${p}`}function nh(t,e,n,r){let{type:o,value:s}=t,{actualString:i,implicitKey:a,indent:c,indentStep:u,inFlow:d}=e;if(a&&s.includes(`
`)||d&&/[[\]{},]/.test(s))return Vt(s,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(s))return a||d||!s.includes(`
`)?Vt(s,e):Or(t,e,n,r);if(!a&&!d&&o!==R.PLAIN&&s.includes(`
`))return Or(t,e,n,r);if(Tr(s)){if(c==="")return e.forceBlockIndent=!0,Or(t,e,n,r);if(a&&c===u)return Vt(s,e)}let l=s.replace(/\n+/g,`$&
${c}`);if(i){let f=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(l),{compat:p,tags:g}=e.doc.schema;if(g.some(f)||p?.some(f))return Vt(s,e)}return a?l:kn(l,c,hs,Cr(e,!1))}function xt(t,e,n,r){let{implicitKey:o,inFlow:s}=e,i=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==R.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value)&&(a=R.QUOTE_DOUBLE);let c=d=>{switch(d){case R.BLOCK_FOLDED:case R.BLOCK_LITERAL:return o||s?Vt(i.value,e):Or(i,e,n,r);case R.QUOTE_DOUBLE:return In(i.value,e);case R.QUOTE_SINGLE:return ys(i.value,e);case R.PLAIN:return nh(i,e,n,r);default:return null}},u=c(a);if(u===null){let{defaultKeyType:d,defaultStringType:l}=e.options,f=o&&d||l;if(u=c(f),u===null)throw new Error(`Unsupported default string type ${f}`)}return u}function Nr(t,e){let n=Object.assign({blockQuote:!0,commentString:Ll,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},t.schema.toStringOptions,e),r;switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:r,options:n}}function rh(t,e){if(e.tag){let o=t.filter(s=>s.tag===e.tag);if(o.length>0)return o.find(s=>s.format===e.format)??o[0]}let n,r;if(T(e)){r=e.value;let o=t.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===e.format)??o.find(s=>!s.format)}else r=e,n=t.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 oh(t,e,{anchors:n,doc:r}){if(!r.directives)return"";let o=[],s=(T(t)||B(t))&&t.anchor;s&&Dr(s)&&(n.add(s),o.push(`&${s}`));let i=t.tag??(e.default?null:e.tag);return i&&o.push(r.directives.tagString(i)),o.join(" ")}function Ye(t,e,n,r){if($(t))return t.toString(e,n,r);if(ye(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let o,s=z(t)?t:e.doc.createNode(t,{onTagObj:c=>o=c});o??(o=rh(e.doc.schema.tags,s));let i=oh(s,o,e);i.length>0&&(e.indentAtStart=(e.indentAtStart??0)+i.length+1);let a=typeof o.stringify=="function"?o.stringify(s,e,n,r):T(s)?xt(s,e,n,r):s.toString(e,n,r);return i?T(s)||a[0]==="{"||a[0]==="["?`${i} ${a}`:`${i}
${e.indent}${a}`:a}function Fl({key:t,value:e},n,r,o){let{allNullValues:s,doc:i,indent:a,indentStep:c,options:{commentString:u,indentSeq:d,simpleKeys:l}}=n,f=z(t)&&t.comment||null;if(l){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(B(t)||!z(t)&&typeof t=="object"){let D="With simple keys, collection cannot be used as a key value";throw new Error(D)}}let p=!l&&(!t||f&&e==null&&!n.inFlow||B(t)||(T(t)?t.type===R.BLOCK_FOLDED||t.type===R.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(l||!s),indent:a+c});let g=!1,m=!1,h=Ye(t,n,()=>g=!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||e==null)return g&&r&&r(),h===""?"?":p?`? ${h}`:h}else if(s&&!l||e==null&&p)return h=`? ${h}`,f&&!g?h+=Be(h,n.indent,u(f)):m&&o&&o(),h;g&&(f=null),p?(f&&(h+=Be(h,n.indent,u(f))),h=`? ${h}
${a}:`):(h=`${h}:`,f&&(h+=Be(h,n.indent,u(f))));let y,E,S;z(e)?(y=!!e.spaceBefore,E=e.commentBefore,S=e.comment):(y=!1,E=null,S=null,e&&typeof e=="object"&&(e=i.createNode(e))),n.implicitKey=!1,!p&&!f&&T(e)&&(n.indentAtStart=h.length+1),m=!1,!d&&c.length>=2&&!n.inFlow&&!p&&be(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let _=!1,w=Ye(e,n,()=>_=!0,()=>m=!0),A=" ";if(f||y||E){if(A=y?`
`:"",E){let D=u(E);A+=`
${we(D,n.indent)}`}w===""&&!n.inFlow?A===`
`&&(p=p.slice(0,-1)),p=p.replace(_s,`$&${u}`));let m=!1,h,y=-1;for(h=0;h<n.length;++h){let b=n[h];if(b===" ")m=!0;else if(b===`
`)y=h;else break}let x=n.substring(0,y<h?y+1:h);x&&(n=n.substring(x.length),x=x.replace(/\n+/g,`$&${u}`));let _=(m?u?"2":"1":"")+l;if(t&&(_+=" "+a(t.replace(/ ?[\r\n]+/g," ")),o&&o()),!d){let b=n.replace(/\n+/g,`
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${u}`),A=!1,D=Nr(r,!0);i!=="folded"&&e!==R.BLOCK_FOLDED&&(D.onOverflow=()=>{A=!0});let E=kn(`${x}${b}${p}`,u,Cr,D);if(!A)return`>${_}
${u}${E}`}return n=n.replace(/\n+/g,`$&${u}`),`|${_}
${u}${x}${n}${p}`}function sh(t,e,n,r){let{type:o,value:s}=t,{actualString:i,implicitKey:a,indent:c,indentStep:u,inFlow:d}=e;if(a&&s.includes(`
`)||d&&/[[\]{},]/.test(s))return Qt(s,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(s))return a||d||!s.includes(`
`)?Qt(s,e):Tr(t,e,n,r);if(!a&&!d&&o!==R.PLAIN&&s.includes(`
`))return Tr(t,e,n,r);if($r(s)){if(c==="")return e.forceBlockIndent=!0,Tr(t,e,n,r);if(a&&c===u)return Qt(s,e)}let l=s.replace(/\n+/g,`$&
${c}`);if(i){let f=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(l),{compat:p,tags:g}=e.doc.schema;if(g.some(f)||p?.some(f))return Qt(s,e)}return a?l:kn(l,c,bs,Nr(e,!1))}function xt(t,e,n,r){let{implicitKey:o,inFlow:s}=e,i=typeof t.value=="string"?t:Object.assign({},t,{value:String(t.value)}),{type:a}=t;a!==R.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value)&&(a=R.QUOTE_DOUBLE);let c=d=>{switch(d){case R.BLOCK_FOLDED:case R.BLOCK_LITERAL:return o||s?Qt(i.value,e):Tr(i,e,n,r);case R.QUOTE_DOUBLE:return In(i.value,e);case R.QUOTE_SINGLE:return ws(i.value,e);case R.PLAIN:return sh(i,e,n,r);default:return null}},u=c(a);if(u===null){let{defaultKeyType:d,defaultStringType:l}=e.options,f=o&&d||l;if(u=c(f),u===null)throw new Error(`Unsupported default string type ${f}`)}return u}function zr(t,e){let n=Object.assign({blockQuote:!0,commentString:Fl,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},t.schema.toStringOptions,e),r;switch(n.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:t,flowCollectionPadding:n.flowCollectionPadding?" ":"",indent:"",indentStep:typeof n.indent=="number"?" ".repeat(n.indent):" ",inFlow:r,options:n}}function ih(t,e){if(e.tag){let o=t.filter(s=>s.tag===e.tag);if(o.length>0)return o.find(s=>s.format===e.format)??o[0]}let n,r;if(T(e)){r=e.value;let o=t.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===e.format)??o.find(s=>!s.format)}else r=e,n=t.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 ah(t,e,{anchors:n,doc:r}){if(!r.directives)return"";let o=[],s=(T(t)||B(t))&&t.anchor;s&&kr(s)&&(n.add(s),o.push(`&${s}`));let i=t.tag??(e.default?null:e.tag);return i&&o.push(r.directives.tagString(i)),o.join(" ")}function Ye(t,e,n,r){if($(t))return t.toString(e,n,r);if(ye(t)){if(e.doc.directives)return t.toString(e);if(e.resolvedAliases?.has(t))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(t):e.resolvedAliases=new Set([t]),t=t.resolve(e.doc)}let o,s=z(t)?t:e.doc.createNode(t,{onTagObj:c=>o=c});o??(o=ih(e.doc.schema.tags,s));let i=ah(s,o,e);i.length>0&&(e.indentAtStart=(e.indentAtStart??0)+i.length+1);let a=typeof o.stringify=="function"?o.stringify(s,e,n,r):T(s)?xt(s,e,n,r):s.toString(e,n,r);return i?T(s)||a[0]==="{"||a[0]==="["?`${i} ${a}`:`${i}
${e.indent}${a}`:a}function Bl({key:t,value:e},n,r,o){let{allNullValues:s,doc:i,indent:a,indentStep:c,options:{commentString:u,indentSeq:d,simpleKeys:l}}=n,f=z(t)&&t.comment||null;if(l){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(B(t)||!z(t)&&typeof t=="object"){let D="With simple keys, collection cannot be used as a key value";throw new Error(D)}}let p=!l&&(!t||f&&e==null&&!n.inFlow||B(t)||(T(t)?t.type===R.BLOCK_FOLDED||t.type===R.BLOCK_LITERAL:typeof t=="object"));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(l||!s),indent:a+c});let g=!1,m=!1,h=Ye(t,n,()=>g=!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||e==null)return g&&r&&r(),h===""?"?":p?`? ${h}`:h}else if(s&&!l||e==null&&p)return h=`? ${h}`,f&&!g?h+=Be(h,n.indent,u(f)):m&&o&&o(),h;g&&(f=null),p?(f&&(h+=Be(h,n.indent,u(f))),h=`? ${h}
${a}:`):(h=`${h}:`,f&&(h+=Be(h,n.indent,u(f))));let y,x,S;z(e)?(y=!!e.spaceBefore,x=e.commentBefore,S=e.comment):(y=!1,x=null,S=null,e&&typeof e=="object"&&(e=i.createNode(e))),n.implicitKey=!1,!p&&!f&&T(e)&&(n.indentAtStart=h.length+1),m=!1,!d&&c.length>=2&&!n.inFlow&&!p&&be(e)&&!e.flow&&!e.tag&&!e.anchor&&(n.indent=n.indent.substring(2));let _=!1,b=Ye(e,n,()=>_=!0,()=>m=!0),A=" ";if(f||y||x){if(A=y?`
`:"",x){let D=u(x);A+=`
${we(D,n.indent)}`}b===""&&!n.inFlow?A===`
`&&S&&(A=`
`):A+=`
${n.indent}`}else if(!p&&B(e)){let D=w[0],x=w.indexOf(`
`),C=x!==-1,P=n.inFlow??e.flow??e.items.length===0;if(C||!P){let G=!1;if(C&&(D==="&"||D==="!")){let L=w.indexOf(" ");D==="&"&&L!==-1&&L<x&&w[L+1]==="!"&&(L=w.indexOf(" ",L+1)),(L===-1||x<L)&&(G=!0)}G||(A=`
${n.indent}`)}}else(w===""||w[0]===`
`)&&(A="");return h+=A+w,n.inFlow?_&&r&&r():S&&!_?h+=Be(h,n.indent,u(S)):m&&o&&o(),h}function bs(t,e){(t==="debug"||t==="warn")&&console.warn(e)}var $r="<<",De={identify:t=>t===$r||typeof t=="symbol"&&t.description===$r,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new R(Symbol($r)),{addToJSMap:_s}),stringify:()=>$r},Zl=(t,e)=>(De.identify(e)||T(e)&&(!e.type||e.type===R.PLAIN)&&De.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===De.tag&&n.default);function _s(t,e,n){let r=Bl(t,n);if(be(r))for(let o of r.items)ws(t,e,o);else if(Array.isArray(r))for(let o of r)ws(t,e,o);else ws(t,e,r)}function ws(t,e,n){let r=Bl(t,n);if(!ge(r))throw new Error("Merge sources must be maps or map aliases");let o=r.toJSON(null,t,Map);for(let[s,i]of o)e instanceof Map?e.has(s)||e.set(s,i):e instanceof Set?e.add(s):Object.prototype.hasOwnProperty.call(e,s)||Object.defineProperty(e,s,{value:i,writable:!0,enumerable:!0,configurable:!0});return e}function Bl(t,e){return t&&ye(e)?e.resolve(t.doc,t):e}function zr(t,e,{key:n,value:r}){if(z(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(Zl(t,n))_s(t,e,r);else{let o=H(n,"",t);if(e instanceof Map)e.set(o,H(r,o,t));else if(e instanceof Set)e.add(o);else{let s=sh(n,o,t),i=H(r,s,t);s in e?Object.defineProperty(e,s,{value:i,writable:!0,enumerable:!0,configurable:!0}):e[s]=i}}return e}function sh(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(z(t)&&n?.doc){let r=Nr(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=t.toString(r);if(!n.mapKeyWarned){let s=JSON.stringify(o);s.length>40&&(s=s.substring(0,36)+'..."'),bs(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(e)}function Gt(t,e,n){let r=We(t,void 0,n),o=We(e,void 0,n);return new K(r,o)}var K=class t{constructor(e,n=null){Object.defineProperty(this,ie,{value:ds}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return z(n)&&(n=n.clone(e)),z(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return zr(n,r,this)}toString(e,n,r){return e?.doc?Fl(this,e,n,r):JSON.stringify(this)}};function Lr(t,e,n){return(e.inFlow??t.flow?ah:ih)(t,e,n)}function ih({comment:t,items:e},n,{blockItemPrefix:r,flowChars:o,itemIndent:s,onChompKeep:i,onComment:a}){let{indent:c,options:{commentString:u}}=n,d=Object.assign({},n,{indent:s,type:null}),l=!1,f=[];for(let g=0;g<e.length;++g){let m=e[g],h=null;if(z(m))!l&&m.spaceBefore&&f.push(""),Pr(n,f,m.commentBefore,l),m.comment&&(h=m.comment);else if($(m)){let E=z(m.key)?m.key:null;E&&(!l&&E.spaceBefore&&f.push(""),Pr(n,f,E.commentBefore,l))}l=!1;let y=Ye(m,d,()=>h=null,()=>l=!0);h&&(y+=Be(y,s,u(h))),l&&h&&(l=!1),f.push(r+y)}let p;if(f.length===0)p=o.start+o.end;else{p=f[0];for(let g=1;g<f.length;++g){let m=f[g];p+=m?`
${n.indent}`}else if(!p&&B(e)){let D=b[0],E=b.indexOf(`
`),C=E!==-1,P=n.inFlow??e.flow??e.items.length===0;if(C||!P){let G=!1;if(C&&(D==="&"||D==="!")){let L=b.indexOf(" ");D==="&"&&L!==-1&&L<E&&b[L+1]==="!"&&(L=b.indexOf(" ",L+1)),(L===-1||E<L)&&(G=!0)}G||(A=`
${n.indent}`)}}else(b===""||b[0]===`
`)&&(A="");return h+=A+b,n.inFlow?_&&r&&r():S&&!_?h+=Be(h,n.indent,u(S)):m&&o&&o(),h}function Es(t,e){(t==="debug"||t==="warn")&&console.warn(e)}var Pr="<<",De={identify:t=>t===Pr||typeof t=="symbol"&&t.description===Pr,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new R(Symbol(Pr)),{addToJSMap:Ss}),stringify:()=>Pr},jl=(t,e)=>(De.identify(e)||T(e)&&(!e.type||e.type===R.PLAIN)&&De.identify(e.value))&&t?.doc.schema.tags.some(n=>n.tag===De.tag&&n.default);function Ss(t,e,n){let r=Ul(t,n);if(be(r))for(let o of r.items)xs(t,e,o);else if(Array.isArray(r))for(let o of r)xs(t,e,o);else xs(t,e,r)}function xs(t,e,n){let r=Ul(t,n);if(!ge(r))throw new Error("Merge sources must be maps or map aliases");let o=r.toJSON(null,t,Map);for(let[s,i]of o)e instanceof Map?e.has(s)||e.set(s,i):e instanceof Set?e.add(s):Object.prototype.hasOwnProperty.call(e,s)||Object.defineProperty(e,s,{value:i,writable:!0,enumerable:!0,configurable:!0});return e}function Ul(t,e){return t&&ye(e)?e.resolve(t.doc,t):e}function Lr(t,e,{key:n,value:r}){if(z(n)&&n.addToJSMap)n.addToJSMap(t,e,r);else if(jl(t,n))Ss(t,e,r);else{let o=H(n,"",t);if(e instanceof Map)e.set(o,H(r,o,t));else if(e instanceof Set)e.add(o);else{let s=ch(n,o,t),i=H(r,s,t);s in e?Object.defineProperty(e,s,{value:i,writable:!0,enumerable:!0,configurable:!0}):e[s]=i}}return e}function ch(t,e,n){if(e===null)return"";if(typeof e!="object")return String(e);if(z(t)&&n?.doc){let r=zr(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=t.toString(r);if(!n.mapKeyWarned){let s=JSON.stringify(o);s.length>40&&(s=s.substring(0,36)+'..."'),Es(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(e)}function Vt(t,e,n){let r=We(t,void 0,n),o=We(e,void 0,n);return new K(r,o)}var K=class t{constructor(e,n=null){Object.defineProperty(this,ie,{value:hs}),this.key=e,this.value=n}clone(e){let{key:n,value:r}=this;return z(n)&&(n=n.clone(e)),z(r)&&(r=r.clone(e)),new t(n,r)}toJSON(e,n){let r=n?.mapAsMap?new Map:{};return Lr(n,r,this)}toString(e,n,r){return e?.doc?Bl(this,e,n,r):JSON.stringify(this)}};function Fr(t,e,n){return(e.inFlow??t.flow?lh:uh)(t,e,n)}function uh({comment:t,items:e},n,{blockItemPrefix:r,flowChars:o,itemIndent:s,onChompKeep:i,onComment:a}){let{indent:c,options:{commentString:u}}=n,d=Object.assign({},n,{indent:s,type:null}),l=!1,f=[];for(let g=0;g<e.length;++g){let m=e[g],h=null;if(z(m))!l&&m.spaceBefore&&f.push(""),Mr(n,f,m.commentBefore,l),m.comment&&(h=m.comment);else if($(m)){let x=z(m.key)?m.key:null;x&&(!l&&x.spaceBefore&&f.push(""),Mr(n,f,x.commentBefore,l))}l=!1;let y=Ye(m,d,()=>h=null,()=>l=!0);h&&(y+=Be(y,s,u(h))),l&&h&&(l=!1),f.push(r+y)}let p;if(f.length===0)p=o.start+o.end;else{p=f[0];for(let g=1;g<f.length;++g){let m=f[g];p+=m?`
${c}${m}`:`
`}}return t?(p+=`
`+we(u(t),c),a&&a()):l&&i&&i(),p}function ah({items:t},e,{flowChars:n,itemIndent:r}){let{indent:o,indentStep:s,flowCollectionPadding:i,options:{commentString:a}}=e;r+=s;let c=Object.assign({},e,{indent:r,inFlow:!0,type:null}),u=!1,d=0,l=[];for(let g=0;g<t.length;++g){let m=t[g],h=null;if(z(m))m.spaceBefore&&l.push(""),Pr(e,l,m.commentBefore,!1),m.comment&&(h=m.comment);else if($(m)){let E=z(m.key)?m.key:null;E&&(E.spaceBefore&&l.push(""),Pr(e,l,E.commentBefore,!1),E.comment&&(u=!0));let S=z(m.value)?m.value:null;S?(S.comment&&(h=S.comment),S.commentBefore&&(u=!0)):m.value==null&&E?.comment&&(h=E.comment)}h&&(u=!0);let y=Ye(m,c,()=>h=null);u||(u=l.length>d||y.includes(`
`)),g<t.length-1?y+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(u||(u=l.reduce((E,S)=>E+S.length+2,2)+(y.length+2)>e.options.lineWidth)),u&&(y+=",")),h&&(y+=Be(y,r,a(h))),l.push(y),d=l.length}let{start:f,end:p}=n;if(l.length===0)return f+p;if(!u){let g=l.reduce((m,h)=>m+h.length+2,2);u=e.options.lineWidth>0&&g>e.options.lineWidth}if(u){let g=f;for(let m of l)g+=m?`
`+we(u(t),c),a&&a()):l&&i&&i(),p}function lh({items:t},e,{flowChars:n,itemIndent:r}){let{indent:o,indentStep:s,flowCollectionPadding:i,options:{commentString:a}}=e;r+=s;let c=Object.assign({},e,{indent:r,inFlow:!0,type:null}),u=!1,d=0,l=[];for(let g=0;g<t.length;++g){let m=t[g],h=null;if(z(m))m.spaceBefore&&l.push(""),Mr(e,l,m.commentBefore,!1),m.comment&&(h=m.comment);else if($(m)){let x=z(m.key)?m.key:null;x&&(x.spaceBefore&&l.push(""),Mr(e,l,x.commentBefore,!1),x.comment&&(u=!0));let S=z(m.value)?m.value:null;S?(S.comment&&(h=S.comment),S.commentBefore&&(u=!0)):m.value==null&&x?.comment&&(h=x.comment)}h&&(u=!0);let y=Ye(m,c,()=>h=null);u||(u=l.length>d||y.includes(`
`)),g<t.length-1?y+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(u||(u=l.reduce((x,S)=>x+S.length+2,2)+(y.length+2)>e.options.lineWidth)),u&&(y+=",")),h&&(y+=Be(y,r,a(h))),l.push(y),d=l.length}let{start:f,end:p}=n;if(l.length===0)return f+p;if(!u){let g=l.reduce((m,h)=>m+h.length+2,2);u=e.options.lineWidth>0&&g>e.options.lineWidth}if(u){let g=f;for(let m of l)g+=m?`
${s}${o}${m}`:`
`;return`${g}
${o}${p}`}else return`${f}${i}${l.join(" ")}${i}${p}`}function Pr({indent:t,options:{commentString:e}},n,r,o){if(r&&o&&(r=r.replace(/^\n+/,"")),r){let s=we(e(r),t);n.push(s.trimStart())}}function ut(t,e){let n=T(e)?e.value:e;for(let r of t)if($(r)&&(r.key===e||r.key===n||T(r.key)&&r.key.value===n))return r}var W=class extends Ut{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(ve,e),this.items=[]}static from(e,n,r){let{keepUndefined:o,replacer:s}=r,i=new this(e),a=(c,u)=>{if(typeof s=="function")u=s.call(n,c,u);else if(Array.isArray(s)&&!s.includes(c))return;(u!==void 0||o)&&i.items.push(Gt(c,u,r))};if(n instanceof Map)for(let[c,u]of n)a(c,u);else if(n&&typeof n=="object")for(let c of Object.keys(n))a(c,n[c]);return typeof e.sortMapEntries=="function"&&i.items.sort(e.sortMapEntries),i}add(e,n){let r;$(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new K(e,e?.value):r=new K(e.key,e.value);let o=ut(this.items,r.key),s=this.schema?.sortMapEntries;if(o){if(!n)throw new Error(`Key ${r.key} already set`);T(o.value)&&kr(r.value)?o.value.value=r.value:o.value=r.value}else if(s){let i=this.items.findIndex(a=>s(r,a)<0);i===-1?this.items.push(r):this.items.splice(i,0,r)}else this.items.push(r)}delete(e){let n=ut(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let o=ut(this.items,e)?.value;return(!n&&T(o)?o.value:o)??void 0}has(e){return!!ut(this.items,e)}set(e,n){this.add(new K(e,n),!0)}toJSON(e,n,r){let o=r?new r:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(o);for(let s of this.items)zr(n,o,s);return o}toString(e,n,r){if(!e)return JSON.stringify(this);for(let o of this.items)if(!$(o))throw new Error(`Map items must all be pairs; found ${JSON.stringify(o)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Lr(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};var Re={collection:"map",default:!0,nodeClass:W,tag:"tag:yaml.org,2002:map",resolve(t,e){return ge(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>W.from(t,e,n)};var ne=class extends Ut{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Je,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=Mr(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=Mr(e);if(typeof r!="number")return;let o=this.items[r];return!n&&T(o)?o.value:o}has(e){let n=Mr(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=Mr(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let o=this.items[r];T(o)&&kr(n)?o.value=n:this.items[r]=n}toJSON(e,n){let r=[];n?.onCreate&&n.onCreate(r);let o=0;for(let s of this.items)r.push(H(s,String(o++),n));return r}toString(e,n,r){return e?Lr(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:n}):JSON.stringify(this)}static from(e,n,r){let{replacer:o}=r,s=new this(e);if(n&&Symbol.iterator in Object(n)){let i=0;for(let a of n){if(typeof o=="function"){let c=n instanceof Set?a:String(i++);a=o.call(n,c,a)}s.items.push(We(a,void 0,r))}}return s}};function Mr(t){let e=T(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}var ke={collection:"seq",default:!0,nodeClass:ne,tag:"tag:yaml.org,2002:seq",resolve(t,e){return be(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>ne.from(t,e,n)};var lt={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,n,r){return e=Object.assign({actualString:!0},e),xt(t,e,n,r)}};var St={identify:t=>t==null,createNode:()=>new R(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new R(null),stringify:({source:t},e)=>typeof t=="string"&&St.test.test(t)?t:e.options.nullStr};var On={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new R(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&On.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};function re({format:t,minFractionDigits:e,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(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(s)&&!s.includes("e")){let i=s.indexOf(".");i<0&&(i=s.length,s+=".");let a=e-(s.length-i-1);for(;a-- >0;)s+="0"}return s}var Fr={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:re},Zr={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+| Line truncated
`:" ")}return xt({comment:t,type:e,value:a},r,o,s)}};function xs(t,e){if(be(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!$(r)){if(ge(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let o=r.items[0]||new K(new R(null));if(r.commentBefore&&(o.key.commentBefore=o.key.commentBefore?`${r.commentBefore}
${o}${p}`}else return`${f}${i}${l.join(" ")}${i}${p}`}function Mr({indent:t,options:{commentString:e}},n,r,o){if(r&&o&&(r=r.replace(/^\n+/,"")),r){let s=we(e(r),t);n.push(s.trimStart())}}function ut(t,e){let n=T(e)?e.value:e;for(let r of t)if($(r)&&(r.key===e||r.key===n||T(r.key)&&r.key.value===n))return r}var W=class extends jt{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(ve,e),this.items=[]}static from(e,n,r){let{keepUndefined:o,replacer:s}=r,i=new this(e),a=(c,u)=>{if(typeof s=="function")u=s.call(n,c,u);else if(Array.isArray(s)&&!s.includes(c))return;(u!==void 0||o)&&i.items.push(Vt(c,u,r))};if(n instanceof Map)for(let[c,u]of n)a(c,u);else if(n&&typeof n=="object")for(let c of Object.keys(n))a(c,n[c]);return typeof e.sortMapEntries=="function"&&i.items.sort(e.sortMapEntries),i}add(e,n){let r;$(e)?r=e:!e||typeof e!="object"||!("key"in e)?r=new K(e,e?.value):r=new K(e.key,e.value);let o=ut(this.items,r.key),s=this.schema?.sortMapEntries;if(o){if(!n)throw new Error(`Key ${r.key} already set`);T(o.value)&&Or(r.value)?o.value.value=r.value:o.value=r.value}else if(s){let i=this.items.findIndex(a=>s(r,a)<0);i===-1?this.items.push(r):this.items.splice(i,0,r)}else this.items.push(r)}delete(e){let n=ut(this.items,e);return n?this.items.splice(this.items.indexOf(n),1).length>0:!1}get(e,n){let o=ut(this.items,e)?.value;return(!n&&T(o)?o.value:o)??void 0}has(e){return!!ut(this.items,e)}set(e,n){this.add(new K(e,n),!0)}toJSON(e,n,r){let o=r?new r:n?.mapAsMap?new Map:{};n?.onCreate&&n.onCreate(o);for(let s of this.items)Lr(n,o,s);return o}toString(e,n,r){if(!e)return JSON.stringify(this);for(let o of this.items)if(!$(o))throw new Error(`Map items must all be pairs; found ${JSON.stringify(o)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Fr(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:r,onComment:n})}};var Re={collection:"map",default:!0,nodeClass:W,tag:"tag:yaml.org,2002:map",resolve(t,e){return ge(t)||e("Expected a mapping for this tag"),t},createNode:(t,e,n)=>W.from(t,e,n)};var ne=class extends jt{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Je,e),this.items=[]}add(e){this.items.push(e)}delete(e){let n=Zr(e);return typeof n!="number"?!1:this.items.splice(n,1).length>0}get(e,n){let r=Zr(e);if(typeof r!="number")return;let o=this.items[r];return!n&&T(o)?o.value:o}has(e){let n=Zr(e);return typeof n=="number"&&n<this.items.length}set(e,n){let r=Zr(e);if(typeof r!="number")throw new Error(`Expected a valid index, not ${e}.`);let o=this.items[r];T(o)&&Or(n)?o.value=n:this.items[r]=n}toJSON(e,n){let r=[];n?.onCreate&&n.onCreate(r);let o=0;for(let s of this.items)r.push(H(s,String(o++),n));return r}toString(e,n,r){return e?Fr(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:r,onComment:n}):JSON.stringify(this)}static from(e,n,r){let{replacer:o}=r,s=new this(e);if(n&&Symbol.iterator in Object(n)){let i=0;for(let a of n){if(typeof o=="function"){let c=n instanceof Set?a:String(i++);a=o.call(n,c,a)}s.items.push(We(a,void 0,r))}}return s}};function Zr(t){let e=T(t)?t.value:t;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}var ke={collection:"seq",default:!0,nodeClass:ne,tag:"tag:yaml.org,2002:seq",resolve(t,e){return be(t)||e("Expected a sequence for this tag"),t},createNode:(t,e,n)=>ne.from(t,e,n)};var lt={identify:t=>typeof t=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:t=>t,stringify(t,e,n,r){return e=Object.assign({actualString:!0},e),xt(t,e,n,r)}};var St={identify:t=>t==null,createNode:()=>new R(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new R(null),stringify:({source:t},e)=>typeof t=="string"&&St.test.test(t)?t:e.options.nullStr};var On={identify:t=>typeof t=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:t=>new R(t[0]==="t"||t[0]==="T"),stringify({source:t,value:e},n){if(t&&On.test.test(t)){let r=t[0]==="t"||t[0]==="T";if(e===r)return t}return e?n.options.trueStr:n.options.falseStr}};function re({format:t,minFractionDigits:e,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(!t&&e&&(!n||n==="tag:yaml.org,2002:float")&&/^-?\d/.test(s)&&!s.includes("e")){let i=s.indexOf(".");i<0&&(i=s.length,s+=".");let a=e-(s.length-i-1);for(;a-- >0;)s+="0"}return s}var Br={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:re},jr={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+| Line truncated
`:" ")}return xt({comment:t,type:e,value:a},r,o,s)}};function vs(t,e){if(be(t))for(let n=0;n<t.items.length;++n){let r=t.items[n];if(!$(r)){if(ge(r)){r.items.length>1&&e("Each pair must have its own sequence indicator");let o=r.items[0]||new K(new R(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}t.items[n]=$(r)?r:new K(r)}}else e("Expected a sequence for this tag");return t}function Ss(t,e,n){let{replacer:r}=n,o=new ne(t);o.tag="tag:yaml.org,2002:pairs";let s=0;if(e&&Symbol.iterator in Object(e))for(let i of e){typeof r=="function"&&(i=r.call(e,String(s++),i));let a,c;if(Array.isArray(i))if(i.length===2)a=i[0],c=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)a=u[0],c=i[a];else throw new TypeError(`Expected tuple with one key, not ${u.length} keys`)}else a=i;o.items.push(Gt(a,c,n))}return o}var Tn={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:xs,createNode:Ss};var qt=class t extends ne{constructor(){super(),this.add=W.prototype.add.bind(this),this.delete=W.prototype.delete.bind(this),this.get=W.prototype.get.bind(this),this.has=W.prototype.has.bind(this),this.set=W.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let r=new Map;n?.onCreate&&n.onCreate(r);for(let o of this.items){let s,i;if($(o)?(s=H(o.key,"",n),i=H(o.value,s,n)):s=H(o,"",n),r.has(s))throw new Error("Ordered maps must not include duplicate keys");r.set(s,i)}return r}static from(e,n,r){let o=Ss(e,n,r),s=new this;return s.items=o.items,s}};qt.tag="tag:yaml.org,2002:omap";var Nn={collection:"seq",identify:t=>t instanceof Map,nodeClass:qt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=xs(t,e),r=[];for(let{key:o}of n.items)T(o)&&(r.includes(o.value)?e(`Ordered maps must not include duplicate keys: ${o.value}`):r.push(o.value));return Object.assign(new qt,n)},createNode:(t,e,n)=>qt.from(t,e,n)};function Gl({value:t,source:e},n){return e&&(t?As:vs).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var As={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new R(!0),stringify:Gl},vs={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new R(!1),stringify:Gl};var ql={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:re},Jl={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():re(t)}},Kl={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new R(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let r=t.substring(n+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:re};var $n=t=>typeof t=="bigint"||Number.isInteger(t);function qr(t,e,n,{intAsBigInt:r}){let o=t[0];if((o==="-"||o==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let i=BigInt(t);return o==="-"?BigInt(-1)*i:i}let s=parseInt(t,n);return o==="-"?-1*s:s}function Ds(t,e,n){let{value:r}=t;if($n(r)){let o=r.toString(e);return r<0?"-"+n+o.substr(1):n+o}return re(t)}var Wl={identify:$n,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>qr(t,2,2,n),stringify:t=>Ds(t,2,"0b")},Yl={identify:$n,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>qr(t,1,8,n),stringify:t=>Ds(t,8,"0")},Xl={identify:$n,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>qr(t,0,10,n),stringify:re},Hl={identify:$n,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>qr(t,2,16,n),stringify:t=>Ds(t,16,"0x")};var Jt=class t extends W{constructor(e){super(e),this.tag=t.tag}add(e){let n;$(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new K(e.key,null):n=new K(e,null),ut(this.items,n.key)||this.items.push(n)}get(e,n){let r=ut(this.items,e);return!n&&$(r)?T(r.key)?r.key.value:r.key:r}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let r=ut(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new K(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,r);throw new Error("Set items must all have null values")}static from(e,n,r){let{replacer:o}=r,s=new this(e);if(n&&Symbol.iterator in Object(n))for(let i of n)typeof o=="function"&&(i=o.call(n,i,i)),s.items.push(Gt(i,null,r));return s}};Jt.tag="tag:yaml.org,2002:set";var zn={collection:"map",identify:t=>t instanceof Set,nodeClass:Jt, Line truncated
${s.comment}`:r.comment}r=o}t.items[n]=$(r)?r:new K(r)}}else e("Expected a sequence for this tag");return t}function Ds(t,e,n){let{replacer:r}=n,o=new ne(t);o.tag="tag:yaml.org,2002:pairs";let s=0;if(e&&Symbol.iterator in Object(e))for(let i of e){typeof r=="function"&&(i=r.call(e,String(s++),i));let a,c;if(Array.isArray(i))if(i.length===2)a=i[0],c=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)a=u[0],c=i[a];else throw new TypeError(`Expected tuple with one key, not ${u.length} keys`)}else a=i;o.items.push(Vt(a,c,n))}return o}var Tn={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:vs,createNode:Ds};var Gt=class t extends ne{constructor(){super(),this.add=W.prototype.add.bind(this),this.delete=W.prototype.delete.bind(this),this.get=W.prototype.get.bind(this),this.has=W.prototype.has.bind(this),this.set=W.prototype.set.bind(this),this.tag=t.tag}toJSON(e,n){if(!n)return super.toJSON(e);let r=new Map;n?.onCreate&&n.onCreate(r);for(let o of this.items){let s,i;if($(o)?(s=H(o.key,"",n),i=H(o.value,s,n)):s=H(o,"",n),r.has(s))throw new Error("Ordered maps must not include duplicate keys");r.set(s,i)}return r}static from(e,n,r){let o=Ds(e,n,r),s=new this;return s.items=o.items,s}};Gt.tag="tag:yaml.org,2002:omap";var Nn={collection:"seq",identify:t=>t instanceof Map,nodeClass:Gt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(t,e){let n=vs(t,e),r=[];for(let{key:o}of n.items)T(o)&&(r.includes(o.value)?e(`Ordered maps must not include duplicate keys: ${o.value}`):r.push(o.value));return Object.assign(new Gt,n)},createNode:(t,e,n)=>Gt.from(t,e,n)};function Jl({value:t,source:e},n){return e&&(t?Rs:ks).test.test(e)?e:t?n.options.trueStr:n.options.falseStr}var Rs={identify:t=>t===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new R(!0),stringify:Jl},ks={identify:t=>t===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new R(!1),stringify:Jl};var Kl={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:t=>t.slice(-3).toLowerCase()==="nan"?NaN:t[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:re},Wl={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:t=>parseFloat(t.replace(/_/g,"")),stringify(t){let e=Number(t.value);return isFinite(e)?e.toExponential():re(t)}},Yl={identify:t=>typeof t=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(t){let e=new R(parseFloat(t.replace(/_/g,""))),n=t.indexOf(".");if(n!==-1){let r=t.substring(n+1).replace(/_/g,"");r[r.length-1]==="0"&&(e.minFractionDigits=r.length)}return e},stringify:re};var $n=t=>typeof t=="bigint"||Number.isInteger(t);function Kr(t,e,n,{intAsBigInt:r}){let o=t[0];if((o==="-"||o==="+")&&(e+=1),t=t.substring(e).replace(/_/g,""),r){switch(n){case 2:t=`0b${t}`;break;case 8:t=`0o${t}`;break;case 16:t=`0x${t}`;break}let i=BigInt(t);return o==="-"?BigInt(-1)*i:i}let s=parseInt(t,n);return o==="-"?-1*s:s}function Is(t,e,n){let{value:r}=t;if($n(r)){let o=r.toString(e);return r<0?"-"+n+o.substr(1):n+o}return re(t)}var Xl={identify:$n,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(t,e,n)=>Kr(t,2,2,n),stringify:t=>Is(t,2,"0b")},Hl={identify:$n,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(t,e,n)=>Kr(t,1,8,n),stringify:t=>Is(t,8,"0")},ef={identify:$n,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(t,e,n)=>Kr(t,0,10,n),stringify:re},tf={identify:$n,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(t,e,n)=>Kr(t,2,16,n),stringify:t=>Is(t,16,"0x")};var qt=class t extends W{constructor(e){super(e),this.tag=t.tag}add(e){let n;$(e)?n=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?n=new K(e.key,null):n=new K(e,null),ut(this.items,n.key)||this.items.push(n)}get(e,n){let r=ut(this.items,e);return!n&&$(r)?T(r.key)?r.key.value:r.key:r}set(e,n){if(typeof n!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof n}`);let r=ut(this.items,e);r&&!n?this.items.splice(this.items.indexOf(r),1):!r&&n&&this.items.push(new K(e))}toJSON(e,n){return super.toJSON(e,n,Set)}toString(e,n,r){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),n,r);throw new Error("Set items must all have null values")}static from(e,n,r){let{replacer:o}=r,s=new this(e);if(n&&Symbol.iterator in Object(n))for(let i of n)typeof o=="function"&&(i=o.call(n,i,i)),s.items.push(Vt(i,null,r));return s}};qt.tag="tag:yaml.org,2002:set";var zn={collection:"map",identify:t=>t instanceof Set,nodeClass:qt, Line truncated
`)?(n.push("..."),n.push(we(c,""))):n.push(`... ${c}`)}else n.push("...");else{let c=t.comment;c&&i&&(c=c.replace(/^\n+/,"")),c&&((!i||a)&&n[n.length-1]!==""&&n.push(""),n.push(we(s(c),"")))}return n.join(`
`)+`
`}var ft=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ie,{value:Sr});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 Ze({version:i}),this.setSchema(i,r),this.contents=e===void 0?null:this.createNode(e,o,r)}clone(){let e=Object.create(t.prototype,{[ie]:{value:Sr}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=z(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Wt(this.contents)&&this.contents.add(e)}addIn(e,n){Wt(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=ps(this);e.anchor=!n||r.has(n)?ms(n||"a",r):n}return new Ke(e.anchor)}createNode(e,n,r){let o;if(typeof n=="function")e=n.call({"":e},"",e),o=n;else if(Array.isArray(n)){let h=E=>typeof E=="number"||E instanceof String||E instanceof Number,y=n.filter(h).map(String);y.length>0&&(n=n.concat(y)),o=n}else r===void 0&&n&&(r=n,n=void 0);let{aliasDuplicateObjects:s,anchorPrefix:i,flow:a,keepUndefined:c,onTagObj:u,tag:d}=r??{},{onAnchor:l,setAnchors:f,sourceObjects:p}=Pl(this,i||"a"),g={aliasDuplicateObjects:s??!0,keepUndefined:c??!1,onAnchor:l,onTagObj:u,replacer:o,schema:this.schema,sourceObjects:p},m=We(e,d,g);return a&&B(m)&&(m.flow=!0),f(),m}createPair(e,n,r={}){let o=this.createNode(e,null,r),s=this.createNode(n,null,r);return new K(o,s)}delete(e){return Wt(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Qt(e)?this.contents==null?!1:(this.contents=null,!0):Wt(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return B(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return Qt(e)?!n&&T(this.contents)?this.contents.value:this.contents:B(this.contents)?this.contents.getIn(e,n):void 0}has(e){return B(this.contents)?this.contents.has(e):!1}hasIn(e){return Qt(e)?this.contents!==void 0:B(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=Dn(this.schema,[e],n):Wt(this.contents)&&this.contents.set(e,n)}setIn(e,n){Qt(e)?this.contents=n:this.contents==null?this.contents=Dn(this.schema,Array.from(e),n):Wt(this.contents)&&this.contents.setIn(e,n)}setSchema(e,n={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Ze({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new Ze({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let o=JSON.stringify(e);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 Pn(Object.assign(r,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:n,mapAsMap:r,maxAliasCount:o,onAnchor:s,reviver:i}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof o=="number"?o:100},c=H(this.contents,n??"",a);if(typeof s=="function")for(let{count:u,res:d}of a.anchors.values())s(d,u);return typeof i=="function"?at(i,{"":c},"",c):c}toJSON(e,n){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:n})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let n=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return of(this,e)}};function Wt(t){if(B(t))return!0;throw new Error("Expected a YAML collection as document contents")}var Ln=class extends Error{constructor(e,n,r,o){super(),this.name=e,this.code=r,this.message=o,this.pos=n}},Ie=class extends Ln{constructor(e,n,r){super("YAMLParseError",e,n,r)}},Mn=class extends Ln{constructor(e,n,r){super("YAMLWarning",e,n,r)}},Is=(t,e)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(a=>e.linePos(a));let{line:r,col:o}=n.linePos[0];n.message+=` at line ${r}, column ${o}`;let s=o-1,i=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(s>=60&&i.length>80){let a=Math.min(s-39,i.length-79);i="\u2026"+i.substring(a),s-=a-1}if(i.length>80&&(i=i.substring(0,79)+"\u2026"),r>1&&/^ *$/.test(i.substring(0,s))){let a=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);a.length>80&&(a=a.substring(0,79)+ Line truncated
`}var ft=class t{constructor(e,n,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ie,{value:vr});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 Ze({version:i}),this.setSchema(i,r),this.contents=e===void 0?null:this.createNode(e,o,r)}clone(){let e=Object.create(t.prototype,{[ie]:{value:vr}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=z(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Kt(this.contents)&&this.contents.add(e)}addIn(e,n){Kt(this.contents)&&this.contents.addIn(e,n)}createAlias(e,n){if(!e.anchor){let r=ys(this);e.anchor=!n||r.has(n)?gs(n||"a",r):n}return new Ke(e.anchor)}createNode(e,n,r){let o;if(typeof n=="function")e=n.call({"":e},"",e),o=n;else if(Array.isArray(n)){let h=x=>typeof x=="number"||x instanceof String||x instanceof Number,y=n.filter(h).map(String);y.length>0&&(n=n.concat(y)),o=n}else r===void 0&&n&&(r=n,n=void 0);let{aliasDuplicateObjects:s,anchorPrefix:i,flow:a,keepUndefined:c,onTagObj:u,tag:d}=r??{},{onAnchor:l,setAnchors:f,sourceObjects:p}=Ml(this,i||"a"),g={aliasDuplicateObjects:s??!0,keepUndefined:c??!1,onAnchor:l,onTagObj:u,replacer:o,schema:this.schema,sourceObjects:p},m=We(e,d,g);return a&&B(m)&&(m.flow=!0),f(),m}createPair(e,n,r={}){let o=this.createNode(e,null,r),s=this.createNode(n,null,r);return new K(o,s)}delete(e){return Kt(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Ut(e)?this.contents==null?!1:(this.contents=null,!0):Kt(this.contents)?this.contents.deleteIn(e):!1}get(e,n){return B(this.contents)?this.contents.get(e,n):void 0}getIn(e,n){return Ut(e)?!n&&T(this.contents)?this.contents.value:this.contents:B(this.contents)?this.contents.getIn(e,n):void 0}has(e){return B(this.contents)?this.contents.has(e):!1}hasIn(e){return Ut(e)?this.contents!==void 0:B(this.contents)?this.contents.hasIn(e):!1}set(e,n){this.contents==null?this.contents=Dn(this.schema,[e],n):Kt(this.contents)&&this.contents.set(e,n)}setIn(e,n){Ut(e)?this.contents=n:this.contents==null?this.contents=Dn(this.schema,Array.from(e),n):Kt(this.contents)&&this.contents.setIn(e,n)}setSchema(e,n={}){typeof e=="number"&&(e=String(e));let r;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Ze({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new Ze({version:e}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let o=JSON.stringify(e);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 Pn(Object.assign(r,n));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:n,mapAsMap:r,maxAliasCount:o,onAnchor:s,reviver:i}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof o=="number"?o:100},c=H(this.contents,n??"",a);if(typeof s=="function")for(let{count:u,res:d}of a.anchors.values())s(d,u);return typeof i=="function"?at(i,{"":c},"",c):c}toJSON(e,n){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:n})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let n=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${n}`)}return af(this,e)}};function Kt(t){if(B(t))return!0;throw new Error("Expected a YAML collection as document contents")}var Ln=class extends Error{constructor(e,n,r,o){super(),this.name=e,this.code=r,this.message=o,this.pos=n}},Ie=class extends Ln{constructor(e,n,r){super("YAMLParseError",e,n,r)}},Mn=class extends Ln{constructor(e,n,r){super("YAMLWarning",e,n,r)}},Ts=(t,e)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(a=>e.linePos(a));let{line:r,col:o}=n.linePos[0];n.message+=` at line ${r}, column ${o}`;let s=o-1,i=t.substring(e.lineStarts[r-1],e.lineStarts[r]).replace(/[\n\r]+$/,"");if(s>=60&&i.length>80){let a=Math.min(s-39,i.length-79);i="\u2026"+i.substring(a),s-=a-1}if(i.length>80&&(i=i.substring(0,79)+"\u2026"),r>1&&/^ *$/.test(i.substring(0,s))){let a=t.substring(e.lineStarts[r-2],e.lineStarts[r-1]);a.length>80&&(a=a.substring(0,79)+ Line truncated
`),i=a+i}if(/[^ ]/.test(i)){let a=1,c=n.linePos[1];c?.line===r&&c.col>o&&(a=Math.max(1,Math.min(c.col-o,80-s)));let u=" ".repeat(s)+"^".repeat(a);n.message+=`:
${i}
${u}
`}};function je(t,{flow:e,indicator:n,next:r,offset:o,onError:s,parentIndent:i,startOnNewline:a}){let c=!1,u=a,d=a,l="",f="",p=!1,g=!1,m=null,h=null,y=null,E=null,S=null,_=null,w=null;for(let x of t)switch(g&&(x.type!=="space"&&x.type!=="newline"&&x.type!=="comma"&&s(x.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),m&&(u&&x.type!=="comment"&&x.type!=="newline"&&s(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),x.type){case"space":!e&&(n!=="doc-start"||r?.type!=="flow-collection")&&x.source.includes(" ")&&(m=x),d=!0;break;case"comment":{d||s(x,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let C=x.source.substring(1)||" ";l?l+=f+C:l=C,f="",u=!1;break}case"newline":u?l?l+=x.source:(!_||n!=="seq-item-ind")&&(c=!0):f+=x.source,u=!0,p=!0,(h||y)&&(E=x),d=!0;break;case"anchor":h&&s(x,"MULTIPLE_ANCHORS","A node can have at most one anchor"),x.source.endsWith(":")&&s(x.offset+x.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),h=x,w??(w=x.offset),u=!1,d=!1,g=!0;break;case"tag":{y&&s(x,"MULTIPLE_TAGS","A node can have at most one tag"),y=x,w??(w=x.offset),u=!1,d=!1,g=!0;break}case n:(h||y)&&s(x,"BAD_PROP_ORDER",`Anchors and tags must be after the ${x.source} indicator`),_&&s(x,"UNEXPECTED_TOKEN",`Unexpected ${x.source} in ${e??"collection"}`),_=x,u=n==="seq-item-ind"||n==="explicit-key-ind",d=!1;break;case"comma":if(e){S&&s(x,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),S=x,u=!1,d=!1;break}default:s(x,"UNEXPECTED_TOKEN",`Unexpected ${x.type} token`),u=!1,d=!1}let A=t[t.length-1],D=A?A.offset+A.source.length:o;return g&&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:S,found:_,spaceBefore:c,comment:l,hasNewline:p,anchor:h,tag:y,newlineAfterProp:E,end:D,start:w??D}}function dt(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(dt(e.key)||dt(e.value))return!0}return!1;default:return!0}}function Fn(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&dt(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function Yr(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let o=typeof r=="function"?r:(s,i)=>s===i||T(s)&&T(i)&&s.value===i.value;return e.some(s=>o(s.key,n))}var sf="All mapping items must start at the same column";function af({composeNode:t,composeEmptyNode:e},n,r,o,s){let i=s?.nodeClass??W,a=new i(n.schema);n.atRoot&&(n.atRoot=!1);let c=r.offset,u=null;for(let d of r.items){let{start:l,key:f,sep:p,value:g}=d,m=je(l,{indicator:"explicit-key-ind",next:f??p?.[0],offset:c,onError:o,parentIndent:r.indent,startOnNewline:!0}),h=!m.found;if(h){if(f&&(f.type==="block-seq"?o(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==r.indent&&o(c,"BAD_INDENT",sf)),!m.anchor&&!m.tag&&!p){u=m.end,m.comment&&(a.comment?a.comment+=`
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||dt(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(c,"BAD_INDENT",sf);n.atKey=!0;let y=m.end,E=f?t(n,f,m,o):e(n,y,l,null,m,o);n.schema.compat&&Fn(r.indent,f,o),n.atKey=!1,Yr(n,a.items,E)&&o(y,"DUPLICATE_KEY","Map keys must be unique");let S=je(p??[],{indicator:"map-value-ind",next:g,offset:E.range[2],onError:o,parentIndent:r.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=S.end,S.found){h&&(g?.type==="block-map"&&!S.hasNewline&&o(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<S.found.offset-1024&&o(E.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let _=g?t(n,g,S,o):e(n,c,p,null,S,o);n.schema.compat&&Fn(r.indent,g,o),c=_.range[2];let w=new K(E,_);n.options.keepSourceTokens&&(w.srcToken=d),a.items.push(w)}else{h&&o(E.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),S.comment&&(E.comment?E.comment+=`
`+S.comment:E.comment=S.comment);let _=new K(E);n.options.keepSourceTokens&&(_.srcToken=d),a.items.push(_)}}return u&&u<c&&o(u,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,c,u??c],a}function cf({composeNode:t,composeEmptyNode:e},n,r,o,s){let i=s?.nodeClass??ne,a=new i(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let c=r.offset,u=null;for(let{start:d,value:l}of r.items){let f=je(d,{indicator:"seq-item-ind",next:l,offset:c,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(c,"MISSING_CHAR","Sequence item without - indicator");else{u=f.end,f.comment&&(a.comment=f.comment);continue}let p=l?t(n,l,f,o):e(n,f.end,d,null,f,o);n.schema.compat&&Fn(r.indent,l,o),c=p.range[2],a.items.push(p)}return a.range=[r.offset,c,u??c],a}function Ue(t,e,n,r){let o="";if(t){let s=!1,i="";for(let a of t){let{source:c,type:u}=a;switch(u){case"space":s=!0;break;case"comment":{n&&!s&&r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let d=c.substring(1)||" ";o?o+=i+d:o=d,i="";break}case"newline":o&&(i+=c),s=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${u} at node end`)}e+=c.length}}return{comment:o,offset:e}}var Os="Block collections are not allowed within flow collections",Cs=t=>t&&(t.type==="block-map"||t.type==="block-seq");function uf({composeNode:t,composeEmptyNode:e},n,r,o,s){let i=r.start.source==="{",a=i?"flow map":"flow sequence",c=s?.nodeClass??(i?W:ne),u=new c(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 y=r.items[h],{start:E,key:S,sep:_,value:w}=y,A=je(E,{flow:a,indicator:"explicit-key-ind",next:S??_?.[0],offset:l,onError:o,parentIndent:r.indent,startOnNewline:!1});if(!A.found){if(!A.anchor&&!A.tag&&!_&&!w){h===0&&A.comma?o(A.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):h<r.items.length-1&&o(A.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),A.comment&&(u.comment?u.comment+=`
`+A.comment:u.comment=A.comment),l=A.end;continue}!i&&n.options.strict&&dt(S)&&o(S,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(h===0)A.comma&&o(A.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(A.comma||o(A.start,"MISSING_CHAR",`Missing , between ${a} items`),A.comment){let D="";e:for(let x of E)switch(x.type){case"comma":case"space":break;case"comment":D=x.source.substring(1);break e;default:break e}if(D){let x=u.items[u.items.length-1];$(x)&&(x=x.value??x.key),x.comment?x.comment+=`
`+D:x.comment=D,A.comment=A.comment.substring(D.length+1)}}if(!i&&!_&&!A.found){let D=w?t(n,w,A,o):e(n,A.end,_,null,A,o);u.items.push(D),l=D.range[2],Cs(w)&&o(D.range,"BLOCK_IN_FLOW",Os)}else{n.atKey=!0;let D=A.end,x=S?t(n,S,A,o):e(n,D,E,null,A,o);Cs(S)&&o(x.range,"BLOCK_IN_FLOW",Os),n.atKey=!1;let C=je(_??[],{flow:a,indicator:"map-value-ind",next:w,offset:x.range[2],onError:o,parentIndent:r.indent,startOnNewline:!1});if(C.found){if(!i&&!A.found&&n.options.strict){if(_)for(let L of _){if(L===C.found)break;if(L.type==="newline"){o(L,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}A.start<C.found.offset-1024&&o(C.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else w&&("source"in w&&w.source?.[0]===":"?o(w,"MISSING_CHAR",`Missing space after : in ${a}`):o(C.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let P=w?t(n,w,C,o):C.found?e(n,C.end,_,null,C,o):null;P?Cs(w)&&o(P.range,"BLOCK_IN_FLOW",Os):C.comment&&(x.comment?x.comment+=`
`+C.comment:x.comment=C.comment);let G=new K(x,P);if(n.options.keepSourceTokens&&(G.srcToken=y),i){let L=u;Yr(n,L.items,x)&&o(D,"DUPLICATE_KEY","Map keys must be unique"),L.items.push(G)}else{let L=new W(n.schema);L.flow=!0,L.items.push(G);let bt=(P??x).range;L.range=[x.range[0],bt[1],bt[2]],u.items.push(L)}l=P?P.range[2]:C.end}}let f=i?"}":"]",[p,...g]=r.end,m=l;if(p?.source===f)m=p.offset+p.source.length;else{let h=a[0].toUpperCase()+a.substring(1),y=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",y),p&&p.source.length!==1&&g.unshift(p)}if(g.length>0){let h=Ue(g,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 Ts(t,e,n,r,o,s){let i=n.type==="block-map"?af(t,e,n,r,s):n.type==="block-seq"?cf(t,e,n,r,s):uf(t,e,n,r,s),a=i.constructor;return o==="!"||o===a.tagName?(i.tag=a.tagName,i):(o&&(i.tag=o),i)}function lf(t,e,n,r,o){let s=r.tag,i=s?e.directives.tagName(s.source,f=>o(s,"TAG_RESOLVE_FAILED",f)):null;if(n.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=r,g=f&&s?f.offset>s.offset?f:s:f??s;g&&(!p||p.offset<g.offset)&&o(g,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!s||!i||i==="!"||i===W.tagName&&a==="map"||i===ne.tagName&&a==="seq")return Ts(t,e,n,o,i);let c=e.schema.tags.find(f=>f.tag===i&&f.collection===a);if(!c){let f=e.schema.knownTags[i];if(f?.collection===a)e.schema.tags.push(Object.assign({},f,{default:!1})),c=f;else return f?o(s,"BAD_COLLECTION_TYPE",`${f.tag} used for ${a} collection, but expects ${f.collection??"scalar"}`,!0):o(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0),Ts(t,e,n,o,i)}let u=Ts(t,e,n,o,i,c),d=c.resolve?.(u,f=>o(s,"TAG_RESOLVE_FAILED",f),e.options)??u,l=z(d)?d:new R(d);return l.range=u.range,l.tag=i,c?.format&&(l.format=c.format),l}function Ns(t,e,n){let r=e.offset,o=fh(e,t.options.strict,n);if(!o)return{value:"",type:null,comment:"",range:[r,r,r]};let s=o.mode===">"?R.BLOCK_FOLDED:R.BLOCK_LITERAL,i=e.source?dh(e.source):[],a=i.length;for(let m=i.length-1;m>=0;--m){let h=i[m][1];if(h===""||h==="\r")a=m;else break}if(a===0){let m=o.chomp==="+"&&i.length>0?`
`}};function je(t,{flow:e,indicator:n,next:r,offset:o,onError:s,parentIndent:i,startOnNewline:a}){let c=!1,u=a,d=a,l="",f="",p=!1,g=!1,m=null,h=null,y=null,x=null,S=null,_=null,b=null;for(let E of t)switch(g&&(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"),g=!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":!e&&(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 C=E.source.substring(1)||" ";l?l+=f+C:l=C,f="",u=!1;break}case"newline":u?l?l+=E.source:(!_||n!=="seq-item-ind")&&(c=!0):f+=E.source,u=!0,p=!0,(h||y)&&(x=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,b??(b=E.offset),u=!1,d=!1,g=!0;break;case"tag":{y&&s(E,"MULTIPLE_TAGS","A node can have at most one tag"),y=E,b??(b=E.offset),u=!1,d=!1,g=!0;break}case n:(h||y)&&s(E,"BAD_PROP_ORDER",`Anchors and tags must be after the ${E.source} indicator`),_&&s(E,"UNEXPECTED_TOKEN",`Unexpected ${E.source} in ${e??"collection"}`),_=E,u=n==="seq-item-ind"||n==="explicit-key-ind",d=!1;break;case"comma":if(e){S&&s(E,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),S=E,u=!1,d=!1;break}default:s(E,"UNEXPECTED_TOKEN",`Unexpected ${E.type} token`),u=!1,d=!1}let A=t[t.length-1],D=A?A.offset+A.source.length:o;return g&&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:S,found:_,spaceBefore:c,comment:l,hasNewline:p,anchor:h,tag:y,newlineAfterProp:x,end:D,start:b??D}}function dt(t){if(!t)return null;switch(t.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(t.source.includes(`
`))return!0;if(t.end){for(let e of t.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of t.items){for(let n of e.start)if(n.type==="newline")return!0;if(e.sep){for(let n of e.sep)if(n.type==="newline")return!0}if(dt(e.key)||dt(e.value))return!0}return!1;default:return!0}}function Fn(t,e,n){if(e?.type==="flow-collection"){let r=e.end[0];r.indent===t&&(r.source==="]"||r.source==="}")&&dt(e)&&n(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function Hr(t,e,n){let{uniqueKeys:r}=t.options;if(r===!1)return!1;let o=typeof r=="function"?r:(s,i)=>s===i||T(s)&&T(i)&&s.value===i.value;return e.some(s=>o(s.key,n))}var cf="All mapping items must start at the same column";function uf({composeNode:t,composeEmptyNode:e},n,r,o,s){let i=s?.nodeClass??W,a=new i(n.schema);n.atRoot&&(n.atRoot=!1);let c=r.offset,u=null;for(let d of r.items){let{start:l,key:f,sep:p,value:g}=d,m=je(l,{indicator:"explicit-key-ind",next:f??p?.[0],offset:c,onError:o,parentIndent:r.indent,startOnNewline:!0}),h=!m.found;if(h){if(f&&(f.type==="block-seq"?o(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==r.indent&&o(c,"BAD_INDENT",cf)),!m.anchor&&!m.tag&&!p){u=m.end,m.comment&&(a.comment?a.comment+=`
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||dt(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(c,"BAD_INDENT",cf);n.atKey=!0;let y=m.end,x=f?t(n,f,m,o):e(n,y,l,null,m,o);n.schema.compat&&Fn(r.indent,f,o),n.atKey=!1,Hr(n,a.items,x)&&o(y,"DUPLICATE_KEY","Map keys must be unique");let S=je(p??[],{indicator:"map-value-ind",next:g,offset:x.range[2],onError:o,parentIndent:r.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=S.end,S.found){h&&(g?.type==="block-map"&&!S.hasNewline&&o(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),n.options.strict&&m.start<S.found.offset-1024&&o(x.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let _=g?t(n,g,S,o):e(n,c,p,null,S,o);n.schema.compat&&Fn(r.indent,g,o),c=_.range[2];let b=new K(x,_);n.options.keepSourceTokens&&(b.srcToken=d),a.items.push(b)}else{h&&o(x.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),S.comment&&(x.comment?x.comment+=`
`+S.comment:x.comment=S.comment);let _=new K(x);n.options.keepSourceTokens&&(_.srcToken=d),a.items.push(_)}}return u&&u<c&&o(u,"IMPOSSIBLE","Map comment with trailing content"),a.range=[r.offset,c,u??c],a}function lf({composeNode:t,composeEmptyNode:e},n,r,o,s){let i=s?.nodeClass??ne,a=new i(n.schema);n.atRoot&&(n.atRoot=!1),n.atKey&&(n.atKey=!1);let c=r.offset,u=null;for(let{start:d,value:l}of r.items){let f=je(d,{indicator:"seq-item-ind",next:l,offset:c,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(c,"MISSING_CHAR","Sequence item without - indicator");else{u=f.end,f.comment&&(a.comment=f.comment);continue}let p=l?t(n,l,f,o):e(n,f.end,d,null,f,o);n.schema.compat&&Fn(r.indent,l,o),c=p.range[2],a.items.push(p)}return a.range=[r.offset,c,u??c],a}function Ue(t,e,n,r){let o="";if(t){let s=!1,i="";for(let a of t){let{source:c,type:u}=a;switch(u){case"space":s=!0;break;case"comment":{n&&!s&&r(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let d=c.substring(1)||" ";o?o+=i+d:o=d,i="";break}case"newline":o&&(i+=c),s=!0;break;default:r(a,"UNEXPECTED_TOKEN",`Unexpected ${u} at node end`)}e+=c.length}}return{comment:o,offset:e}}var Ns="Block collections are not allowed within flow collections",$s=t=>t&&(t.type==="block-map"||t.type==="block-seq");function ff({composeNode:t,composeEmptyNode:e},n,r,o,s){let i=r.start.source==="{",a=i?"flow map":"flow sequence",c=s?.nodeClass??(i?W:ne),u=new c(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 y=r.items[h],{start:x,key:S,sep:_,value:b}=y,A=je(x,{flow:a,indicator:"explicit-key-ind",next:S??_?.[0],offset:l,onError:o,parentIndent:r.indent,startOnNewline:!1});if(!A.found){if(!A.anchor&&!A.tag&&!_&&!b){h===0&&A.comma?o(A.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):h<r.items.length-1&&o(A.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),A.comment&&(u.comment?u.comment+=`
`+A.comment:u.comment=A.comment),l=A.end;continue}!i&&n.options.strict&&dt(S)&&o(S,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(h===0)A.comma&&o(A.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(A.comma||o(A.start,"MISSING_CHAR",`Missing , between ${a} items`),A.comment){let D="";e:for(let E of x)switch(E.type){case"comma":case"space":break;case"comment":D=E.source.substring(1);break e;default:break e}if(D){let E=u.items[u.items.length-1];$(E)&&(E=E.value??E.key),E.comment?E.comment+=`
`+D:E.comment=D,A.comment=A.comment.substring(D.length+1)}}if(!i&&!_&&!A.found){let D=b?t(n,b,A,o):e(n,A.end,_,null,A,o);u.items.push(D),l=D.range[2],$s(b)&&o(D.range,"BLOCK_IN_FLOW",Ns)}else{n.atKey=!0;let D=A.end,E=S?t(n,S,A,o):e(n,D,x,null,A,o);$s(S)&&o(E.range,"BLOCK_IN_FLOW",Ns),n.atKey=!1;let C=je(_??[],{flow:a,indicator:"map-value-ind",next:b,offset:E.range[2],onError:o,parentIndent:r.indent,startOnNewline:!1});if(C.found){if(!i&&!A.found&&n.options.strict){if(_)for(let L of _){if(L===C.found)break;if(L.type==="newline"){o(L,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}A.start<C.found.offset-1024&&o(C.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else b&&("source"in b&&b.source?.[0]===":"?o(b,"MISSING_CHAR",`Missing space after : in ${a}`):o(C.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let P=b?t(n,b,C,o):C.found?e(n,C.end,_,null,C,o):null;P?$s(b)&&o(P.range,"BLOCK_IN_FLOW",Ns):C.comment&&(E.comment?E.comment+=`
`+C.comment:E.comment=C.comment);let G=new K(E,P);if(n.options.keepSourceTokens&&(G.srcToken=y),i){let L=u;Hr(n,L.items,E)&&o(D,"DUPLICATE_KEY","Map keys must be unique"),L.items.push(G)}else{let L=new W(n.schema);L.flow=!0,L.items.push(G);let bt=(P??E).range;L.range=[E.range[0],bt[1],bt[2]],u.items.push(L)}l=P?P.range[2]:C.end}}let f=i?"}":"]",[p,...g]=r.end,m=l;if(p?.source===f)m=p.offset+p.source.length;else{let h=a[0].toUpperCase()+a.substring(1),y=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",y),p&&p.source.length!==1&&g.unshift(p)}if(g.length>0){let h=Ue(g,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 zs(t,e,n,r,o,s){let i=n.type==="block-map"?uf(t,e,n,r,s):n.type==="block-seq"?lf(t,e,n,r,s):ff(t,e,n,r,s),a=i.constructor;return o==="!"||o===a.tagName?(i.tag=a.tagName,i):(o&&(i.tag=o),i)}function df(t,e,n,r,o){let s=r.tag,i=s?e.directives.tagName(s.source,f=>o(s,"TAG_RESOLVE_FAILED",f)):null;if(n.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=r,g=f&&s?f.offset>s.offset?f:s:f??s;g&&(!p||p.offset<g.offset)&&o(g,"MISSING_CHAR","Missing newline after block sequence props")}let a=n.type==="block-map"?"map":n.type==="block-seq"?"seq":n.start.source==="{"?"map":"seq";if(!s||!i||i==="!"||i===W.tagName&&a==="map"||i===ne.tagName&&a==="seq")return zs(t,e,n,o,i);let c=e.schema.tags.find(f=>f.tag===i&&f.collection===a);if(!c){let f=e.schema.knownTags[i];if(f?.collection===a)e.schema.tags.push(Object.assign({},f,{default:!1})),c=f;else return f?o(s,"BAD_COLLECTION_TYPE",`${f.tag} used for ${a} collection, but expects ${f.collection??"scalar"}`,!0):o(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0),zs(t,e,n,o,i)}let u=zs(t,e,n,o,i,c),d=c.resolve?.(u,f=>o(s,"TAG_RESOLVE_FAILED",f),e.options)??u,l=z(d)?d:new R(d);return l.range=u.range,l.tag=i,c?.format&&(l.format=c.format),l}function Ps(t,e,n){let r=e.offset,o=mh(e,t.options.strict,n);if(!o)return{value:"",type:null,comment:"",range:[r,r,r]};let s=o.mode===">"?R.BLOCK_FOLDED:R.BLOCK_LITERAL,i=e.source?hh(e.source):[],a=i.length;for(let m=i.length-1;m>=0;--m){let h=i[m][1];if(h===""||h==="\r")a=m;else break}if(a===0){let m=o.chomp==="+"&&i.length>0?`
`.repeat(Math.max(1,i.length-1)):"",h=r+o.length;return e.source&&(h+=e.source.length),{value:m,type:s,comment:o.comment,range:[r,h,h]}}let c=e.indent+o.indent,u=e.offset+o.length,d=0;for(let m=0;m<a;++m){let[h,y]=i[m];if(y===""||y==="\r")o.indent===0&&h.length>c&&(c=h.length);else{h.length<c&&n(u+h.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),o.indent===0&&(c=h.length),d=m,c===0&&!t.atRoot&&n(u,"BAD_INDENT","Block scalar values in collections must be indented");break}u+=h.length+y.length+1}for(let m=i.length-1;m>=a;--m)i[m][0].length>c&&(a=m+1);let l="",f="",p=!1;for(let m=0;m<d;++m)l+=i[m][0].slice(c)+`
`;for(let m=d;m<a;++m){let[h,y]=i[m];u+=h.length+y.length+1;let E=y[y.length-1]==="\r";if(E&&(y=y.slice(0,-1)),y&&h.length<c){let _=`Block scalar lines must not be less indented than their ${o.indent?"explicit indentation indicator":"first line"}`;n(u-y.length-(E?2:1),"BAD_INDENT",_),h=""}s===R.BLOCK_LITERAL?(l+=f+h.slice(c)+y,f=`
`;for(let m=d;m<a;++m){let[h,y]=i[m];u+=h.length+y.length+1;let x=y[y.length-1]==="\r";if(x&&(y=y.slice(0,-1)),y&&h.length<c){let _=`Block scalar lines must not be less indented than their ${o.indent?"explicit indentation indicator":"first line"}`;n(u-y.length-(x?2:1),"BAD_INDENT",_),h=""}s===R.BLOCK_LITERAL?(l+=f+h.slice(c)+y,f=`
`):h.length>c||y[0]===" "?(f===" "?f=`
`:!p&&f===`
`&&(f=`
@@ -144,51 +144,51 @@ ${u}
`+i[m][0].slice(c);l[l.length-1]!==`
`&&(l+=`
`);break;default:l+=`
`}let g=r+o.length+e.source.length;return{value:l,type:s,comment:o.comment,range:[r,g,g]}}function fh({offset:t,props:e},n,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:o}=e[0],s=o[0],i=0,a="",c=-1;for(let f=1;f<o.length;++f){let p=o[f];if(!a&&(p==="-"||p==="+"))a=p;else{let g=Number(p);!i&&g?i=g:c===-1&&(c=t+f)}}c!==-1&&r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${o}`);let u=!1,d="",l=o.length;for(let f=1;f<e.length;++f){let p=e[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 g=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",g);let m=p.source;m&&typeof m=="string"&&(l+=m.length)}}}return{mode:s,indent:i,chomp:a,comment:d,length:l}}function dh(t){let e=t.split(/\n( *)/),n=e[0],r=n.match(/^( *)/),s=[r?.[1]?[r[1],n.slice(r[1].length)]:["",n]];for(let i=1;i<e.length;i+=2)s.push([e[i],e[i+1]]);return s}function $s(t,e,n){let{offset:r,type:o,source:s,end:i}=t,a,c,u=(f,p,g)=>n(r+f,p,g);switch(o){case"scalar":a=R.PLAIN,c=ph(s,u);break;case"single-quoted-scalar":a=R.QUOTE_SINGLE,c=mh(s,u);break;case"double-quoted-scalar":a=R.QUOTE_DOUBLE,c=hh(s,u);break;default:return n(t,"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=Ue(i,d,e,n);return{value:c,type:a,comment:l.comment,range:[r,d,l.offset]}}function ph(t,e){let n="";switch(t[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 ${t[0]}`;break}case"@":case"`":{n=`reserved character ${t[0]}`;break}}return n&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),ff(t)}function mh(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),ff(t.slice(1,-1)).replace(/''/g,"'")}function ff(t){let e,n;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
`}let g=r+o.length+e.source.length;return{value:l,type:s,comment:o.comment,range:[r,g,g]}}function mh({offset:t,props:e},n,r){if(e[0].type!=="block-scalar-header")return r(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:o}=e[0],s=o[0],i=0,a="",c=-1;for(let f=1;f<o.length;++f){let p=o[f];if(!a&&(p==="-"||p==="+"))a=p;else{let g=Number(p);!i&&g?i=g:c===-1&&(c=t+f)}}c!==-1&&r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${o}`);let u=!1,d="",l=o.length;for(let f=1;f<e.length;++f){let p=e[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 g=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",g);let m=p.source;m&&typeof m=="string"&&(l+=m.length)}}}return{mode:s,indent:i,chomp:a,comment:d,length:l}}function hh(t){let e=t.split(/\n( *)/),n=e[0],r=n.match(/^( *)/),s=[r?.[1]?[r[1],n.slice(r[1].length)]:["",n]];for(let i=1;i<e.length;i+=2)s.push([e[i],e[i+1]]);return s}function Ls(t,e,n){let{offset:r,type:o,source:s,end:i}=t,a,c,u=(f,p,g)=>n(r+f,p,g);switch(o){case"scalar":a=R.PLAIN,c=yh(s,u);break;case"single-quoted-scalar":a=R.QUOTE_SINGLE,c=gh(s,u);break;case"double-quoted-scalar":a=R.QUOTE_DOUBLE,c=bh(s,u);break;default:return n(t,"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=Ue(i,d,e,n);return{value:c,type:a,comment:l.comment,range:[r,d,l.offset]}}function yh(t,e){let n="";switch(t[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 ${t[0]}`;break}case"@":case"`":{n=`reserved character ${t[0]}`;break}}return n&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${n}`),pf(t)}function gh(t,e){return(t[t.length-1]!=="'"||t.length===1)&&e(t.length,"MISSING_CHAR","Missing closing 'quote"),pf(t.slice(1,-1)).replace(/''/g,"'")}function pf(t){let e,n;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
`,"sy"),n=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
`,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,n=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=e.exec(t);if(!r)return t;let o=r[1],s=" ",i=e.lastIndex;for(n.lastIndex=i;r=n.exec(t);)r[1]===""?s===`
`?o+=s:s=`
`:(o+=s+r[1],s=" "),i=n.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=i,r=a.exec(t),o+s+(r?.[1]??"")}function hh(t,e){let n="";for(let r=1;r<t.length-1;++r){let o=t[r];if(!(o==="\r"&&t[r+1]===`
`:(o+=s+r[1],s=" "),i=n.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=i,r=a.exec(t),o+s+(r?.[1]??"")}function bh(t,e){let n="";for(let r=1;r<t.length-1;++r){let o=t[r];if(!(o==="\r"&&t[r+1]===`
`))if(o===`
`){let{fold:s,offset:i}=yh(t,r);n+=s,r=i}else if(o==="\\"){let s=t[++r],i=gh[s];if(i)n+=i;else if(s===`
`){let{fold:s,offset:i}=wh(t,r);n+=s,r=i}else if(o==="\\"){let s=t[++r],i=_h[s];if(i)n+=i;else if(s===`
`)for(s=t[r+1];s===" "||s===" ";)s=t[++r+1];else if(s==="\r"&&t[r+1]===`
`)for(s=t[++r+1];s===" "||s===" ";)s=t[++r+1];else if(s==="x"||s==="u"||s==="U"){let a=s==="x"?2:s==="u"?4:8;n+=bh(t,r+1,a,e),r+=a}else{let a=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(o===" "||o===" "){let s=r,i=t[r+1];for(;i===" "||i===" ";)i=t[++r+1];i!==`
`)for(s=t[++r+1];s===" "||s===" ";)s=t[++r+1];else if(s==="x"||s==="u"||s==="U"){let a=s==="x"?2:s==="u"?4:8;n+=Eh(t,r+1,a,e),r+=a}else{let a=t.substr(r-1,2);e(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),n+=a}}else if(o===" "||o===" "){let s=r,i=t[r+1];for(;i===" "||i===" ";)i=t[++r+1];i!==`
`&&!(i==="\r"&&t[r+2]===`
`)&&(n+=r>s?t.slice(s,r+1):o)}else n+=o}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function yh(t,e){let n="",r=t[e+1];for(;(r===" "||r===" "||r===`
`)&&(n+=r>s?t.slice(s,r+1):o)}else n+=o}return(t[t.length-1]!=='"'||t.length===1)&&e(t.length,"MISSING_CHAR",'Missing closing "quote'),n}function wh(t,e){let n="",r=t[e+1];for(;(r===" "||r===" "||r===`
`||r==="\r")&&!(r==="\r"&&t[e+2]!==`
`);)r===`
`&&(n+=`
`),e+=1,r=t[e+1];return n||(n=" "),{fold:n,offset:e}}var gh={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function bh(t,e,n,r){let o=t.substr(e,n),i=o.length===n&&/^[0-9a-fA-F]+$/.test(o)?parseInt(o,16):NaN;try{return String.fromCodePoint(i)}catch{let a=t.substr(e-2,n+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}function zs(t,e,n,r){let{value:o,type:s,comment:i,range:a}=e.type==="block-scalar"?Ns(t,e,r):$s(e,t.options.strict,r),c=n?t.directives.tagName(n.source,l=>r(n,"TAG_RESOLVE_FAILED",l)):null,u;t.options.stringKeys&&t.atKey?u=t.schema[pe]:c?u=wh(t.schema,o,c,n,r):e.type==="scalar"?u=_h(t,o,e,r):u=t.schema[pe];let d;try{let l=u.resolve(o,f=>r(n??e,"TAG_RESOLVE_FAILED",f),t.options);d=T(l)?l:new R(l)}catch(l){let f=l instanceof Error?l.message:String(l);r(n??e,"TAG_RESOLVE_FAILED",f),d=new R(o)}return d.range=a,d.source=o,s&&(d.type=s),c&&(d.tag=c),u.format&&(d.format=u.format),i&&(d.comment=i),d}function wh(t,e,n,r,o){if(n==="!")return t[pe];let s=[];for(let a of t.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)s.push(a);else return a;for(let a of s)if(a.test?.test(e))return a;let i=t.knownTags[n];return i&&!i.collection?(t.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"),t[pe])}function _h({atKey:t,directives:e,schema:n},r,o,s){let i=n.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(r))||n[pe];if(n.compat){let a=n.compat.find(c=>c.default&&c.test?.test(r))??n[pe];if(i.tag!==a.tag){let c=e.tagString(i.tag),u=e.tagString(a.tag),d=`Value may be parsed as either ${c} or ${u}`;s(o,"TAG_RESOLVE_FAILED",d,!0)}}return i}function df(t,e,n){if(e){n??(n=e.length);for(let r=n-1;r>=0;--r){let o=e[r];switch(o.type){case"space":case"comment":case"newline":t-=o.source.length;continue}for(o=e[++r];o?.type==="space";)t+=o.source.length,o=e[++r];break}}return t}var Eh={composeNode:Ps,composeEmptyNode:Xr};function Ps(t,e,n,r){let o=t.atKey,{spaceBefore:s,comment:i,anchor:a,tag:c}=n,u,d=!0;switch(e.type){case"alias":u=xh(t,e,r),(a||c)&&r(e,"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=zs(t,e,c,r),a&&(u.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=lf(Eh,t,e,n,r),a&&(u.anchor=a.source.substring(1))}catch(l){let f=l instanceof Error?l.message:String(l);r(e,"RESOURCE_EXHAUSTION",f)}break;default:{let l=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",l),d=!1}}return u??(u=Xr(t,e.offset,void 0,null,n,r)),a&&u.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),o&&t.options.stringKeys&&(!T(u)||typeof u.value!="string"||u.tag&&u.tag!=="tag:yaml.org,2002:str")&&r(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),s&&(u.spaceBefore=!0),i&&(e.type==="scalar"&&e.source===""?u.comment=i:u.commentBefore=i),t.options.keepSourceTokens&&d&&(u.srcToken=e),u}function Xr(t,e,n,r,{spaceBefore:o,comment:s,anchor:i,tag:a,end:c},u){let d={type:"scalar",offset:df(e,n,r),indent:-1,source:""},l=zs(t,d,a,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]=c),l}function xh({options:t},{offset:e,source:n,end:r},o){let s=new Ke(n.substring(1));s.source===""&&o(e,"BAD_ALIAS","Alias cannot be an empty string"),s.source.endsWith(":")&&o(e+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let i=e+n.length,a=Ue(r,i,t.strict,o);return s.range=[e,i,a.offset],a.comment&&(s.comment=a.comment),s}function pf(t,e,{offset:n,start:r,value:o,end:s},i){let a=Object.assign({_directives:e},t),c=new ft(void 0,a),u={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=je(r,{indicator:"doc-start",next:o??s?.[0],offset:n,onError:i,parentIndent:0,startOnNewline:!0});d.found&&(c.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")),c.contents=o?Ps(u,o,d,i):Xr(u,d.end,r,null,d,i);let l=c.contents.range[2],f=Ue(s,l,!1,i);return f.comment&&(c.comment=f.comment),c.range=[n,l,f.offset],c}function Zn(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:n}=t;return[e,e+(typeof n=="string"?n.length:1)]}function mf(t){let e="",n=!1,r=!1;for(let o=0;o<t.length;++o){let s=t[o];switch(s[0]){case"#":e+=(e===""?"":r?`
`),e+=1,r=t[e+1];return n||(n=" "),{fold:n,offset:e}}var _h={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Eh(t,e,n,r){let o=t.substr(e,n),i=o.length===n&&/^[0-9a-fA-F]+$/.test(o)?parseInt(o,16):NaN;try{return String.fromCodePoint(i)}catch{let a=t.substr(e-2,n+2);return r(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}function Ms(t,e,n,r){let{value:o,type:s,comment:i,range:a}=e.type==="block-scalar"?Ps(t,e,r):Ls(e,t.options.strict,r),c=n?t.directives.tagName(n.source,l=>r(n,"TAG_RESOLVE_FAILED",l)):null,u;t.options.stringKeys&&t.atKey?u=t.schema[pe]:c?u=xh(t.schema,o,c,n,r):e.type==="scalar"?u=Sh(t,o,e,r):u=t.schema[pe];let d;try{let l=u.resolve(o,f=>r(n??e,"TAG_RESOLVE_FAILED",f),t.options);d=T(l)?l:new R(l)}catch(l){let f=l instanceof Error?l.message:String(l);r(n??e,"TAG_RESOLVE_FAILED",f),d=new R(o)}return d.range=a,d.source=o,s&&(d.type=s),c&&(d.tag=c),u.format&&(d.format=u.format),i&&(d.comment=i),d}function xh(t,e,n,r,o){if(n==="!")return t[pe];let s=[];for(let a of t.tags)if(!a.collection&&a.tag===n)if(a.default&&a.test)s.push(a);else return a;for(let a of s)if(a.test?.test(e))return a;let i=t.knownTags[n];return i&&!i.collection?(t.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"),t[pe])}function Sh({atKey:t,directives:e,schema:n},r,o,s){let i=n.tags.find(a=>(a.default===!0||t&&a.default==="key")&&a.test?.test(r))||n[pe];if(n.compat){let a=n.compat.find(c=>c.default&&c.test?.test(r))??n[pe];if(i.tag!==a.tag){let c=e.tagString(i.tag),u=e.tagString(a.tag),d=`Value may be parsed as either ${c} or ${u}`;s(o,"TAG_RESOLVE_FAILED",d,!0)}}return i}function mf(t,e,n){if(e){n??(n=e.length);for(let r=n-1;r>=0;--r){let o=e[r];switch(o.type){case"space":case"comment":case"newline":t-=o.source.length;continue}for(o=e[++r];o?.type==="space";)t+=o.source.length,o=e[++r];break}}return t}var Ah={composeNode:Fs,composeEmptyNode:eo};function Fs(t,e,n,r){let o=t.atKey,{spaceBefore:s,comment:i,anchor:a,tag:c}=n,u,d=!0;switch(e.type){case"alias":u=vh(t,e,r),(a||c)&&r(e,"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=Ms(t,e,c,r),a&&(u.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=df(Ah,t,e,n,r),a&&(u.anchor=a.source.substring(1))}catch(l){let f=l instanceof Error?l.message:String(l);r(e,"RESOURCE_EXHAUSTION",f)}break;default:{let l=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;r(e,"UNEXPECTED_TOKEN",l),d=!1}}return u??(u=eo(t,e.offset,void 0,null,n,r)),a&&u.anchor===""&&r(a,"BAD_ALIAS","Anchor cannot be an empty string"),o&&t.options.stringKeys&&(!T(u)||typeof u.value!="string"||u.tag&&u.tag!=="tag:yaml.org,2002:str")&&r(c??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),s&&(u.spaceBefore=!0),i&&(e.type==="scalar"&&e.source===""?u.comment=i:u.commentBefore=i),t.options.keepSourceTokens&&d&&(u.srcToken=e),u}function eo(t,e,n,r,{spaceBefore:o,comment:s,anchor:i,tag:a,end:c},u){let d={type:"scalar",offset:mf(e,n,r),indent:-1,source:""},l=Ms(t,d,a,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]=c),l}function vh({options:t},{offset:e,source:n,end:r},o){let s=new Ke(n.substring(1));s.source===""&&o(e,"BAD_ALIAS","Alias cannot be an empty string"),s.source.endsWith(":")&&o(e+n.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let i=e+n.length,a=Ue(r,i,t.strict,o);return s.range=[e,i,a.offset],a.comment&&(s.comment=a.comment),s}function hf(t,e,{offset:n,start:r,value:o,end:s},i){let a=Object.assign({_directives:e},t),c=new ft(void 0,a),u={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},d=je(r,{indicator:"doc-start",next:o??s?.[0],offset:n,onError:i,parentIndent:0,startOnNewline:!0});d.found&&(c.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")),c.contents=o?Fs(u,o,d,i):eo(u,d.end,r,null,d,i);let l=c.contents.range[2],f=Ue(s,l,!1,i);return f.comment&&(c.comment=f.comment),c.range=[n,l,f.offset],c}function Zn(t){if(typeof t=="number")return[t,t+1];if(Array.isArray(t))return t.length===2?t:[t[0],t[1]];let{offset:e,source:n}=t;return[e,e+(typeof n=="string"?n.length:1)]}function yf(t){let e="",n=!1,r=!1;for(let o=0;o<t.length;++o){let s=t[o];switch(s[0]){case"#":e+=(e===""?"":r?`
`:`
`)+(s.substring(1)||" "),n=!0,r=!1;break;case"%":t[o+1]?.[0]!=="#"&&(o+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:e,afterEmptyLine:r}}var Bn=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,o,s)=>{let i=Zn(n);s?this.warnings.push(new Mn(i,r,o)):this.errors.push(new Ie(i,r,o))},this.directives=new Ze({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:o}=mf(this.prelude);if(r){let s=e.contents;if(n)e.comment=e.comment?`${e.comment}
`)+(s.substring(1)||" "),n=!0,r=!1;break;case"%":t[o+1]?.[0]!=="#"&&(o+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:e,afterEmptyLine:r}}var Bn=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(n,r,o,s)=>{let i=Zn(n);s?this.warnings.push(new Mn(i,r,o)):this.errors.push(new Ie(i,r,o))},this.directives=new Ze({version:e.version||"1.2"}),this.options=e}decorate(e,n){let{comment:r,afterEmptyLine:o}=yf(this.prelude);if(r){let s=e.contents;if(n)e.comment=e.comment?`${e.comment}
${r}`:r;else if(o||e.directives.docStart||!s)e.commentBefore=r;else if(B(s)&&!s.flow&&s.items.length>0){let i=s.items[0];$(i)&&(i=i.key);let a=i.commentBefore;i.commentBefore=a?`${r}
${a}`:r}else{let i=s.commentBefore;s.commentBefore=i?`${r}
${i}`:r}}if(n){for(let s=0;s<this.errors.length;++s)e.errors.push(this.errors[s]);for(let s=0;s<this.warnings.length;++s)e.warnings.push(this.warnings[s])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:mf(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,n=!1,r=-1){for(let o of e)yield*this.next(o);yield*this.end(n,r)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(n,r,o)=>{let s=Zn(e);s[0]+=n,this.onError(s,"BAD_DIRECTIVE",r,o)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=pf(this.options,this.directives,e,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(e,"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(e.source);break;case"error":{let n=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new Ie(Zn(e),"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 Ie(Zn(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=Ue(e.end,e.offset+e.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 Ie(Zn(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),o=new ft(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 Ls=Symbol("break visit"),Sh=Symbol("skip children"),hf=Symbol("remove item");function At(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),yf(Object.freeze([]),t,e)}At.BREAK=Ls;At.SKIP=Sh;At.REMOVE=hf;At.itemAtPath=(t,e)=>{let n=t;for(let[r,o]of e){let s=n?.[r];if(s&&"items"in s)n=s.items[o];else return}return n};At.parentCollection=(t,e)=>{let n=At.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],o=n?.[r];if(o&&"items"in o)return o;throw new Error("Parent collection not found")};function yf(t,e,n){let r=n(e,t);if(typeof r=="symbol")return r;for(let o of["key","value"]){let s=e[o];if(s&&"items"in s){for(let i=0;i<s.items.length;++i){let a=yf(Object.freeze(t.concat([[o,i]])),s.items[i],n);if(typeof a=="number")i=a-1;else{if(a===Ls)return Ls;a===hf&&(s.items.splice(i,1),i-=1)}}typeof r=="function"&&o==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}var Ms="\uFEFF",Fs="",Zs="",Hr="";function gf(t){switch(t){case Ms:return"byte-order-mark";case Fs:return"doc-mode";case Zs:return"flow-error-end";case Hr: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)e.errors.push(this.errors[s]);for(let s=0;s<this.warnings.length;++s)e.warnings.push(this.warnings[s])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:yf(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,n=!1,r=-1){for(let o of e)yield*this.next(o);yield*this.end(n,r)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(n,r,o)=>{let s=Zn(e);s[0]+=n,this.onError(s,"BAD_DIRECTIVE",r,o)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let n=hf(this.options,this.directives,e,this.onError);this.atDirectives&&!n.directives.docStart&&this.onError(e,"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(e.source);break;case"error":{let n=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,r=new Ie(Zn(e),"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 Ie(Zn(e),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let n=Ue(e.end,e.offset+e.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 Ie(Zn(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,n=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let r=Object.assign({_directives:this.directives},this.options),o=new ft(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 Zs=Symbol("break visit"),Dh=Symbol("skip children"),gf=Symbol("remove item");function At(t,e){"type"in t&&t.type==="document"&&(t={start:t.start,value:t.value}),bf(Object.freeze([]),t,e)}At.BREAK=Zs;At.SKIP=Dh;At.REMOVE=gf;At.itemAtPath=(t,e)=>{let n=t;for(let[r,o]of e){let s=n?.[r];if(s&&"items"in s)n=s.items[o];else return}return n};At.parentCollection=(t,e)=>{let n=At.itemAtPath(t,e.slice(0,-1)),r=e[e.length-1][0],o=n?.[r];if(o&&"items"in o)return o;throw new Error("Parent collection not found")};function bf(t,e,n){let r=n(e,t);if(typeof r=="symbol")return r;for(let o of["key","value"]){let s=e[o];if(s&&"items"in s){for(let i=0;i<s.items.length;++i){let a=bf(Object.freeze(t.concat([[o,i]])),s.items[i],n);if(typeof a=="number")i=a-1;else{if(a===Zs)return Zs;a===gf&&(s.items.splice(i,1),i-=1)}}typeof r=="function"&&o==="key"&&(r=r(e,t))}}return typeof r=="function"?r(e,t):r}var Bs="\uFEFF",js="",Us="",to="";function wf(t){switch(t){case Bs:return"byte-order-mark";case js:return"doc-mode";case Us:return"flow-error-end";case to: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(t[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 Oe(t){switch(t){case void 0:case" ":case`
`:case"\r":case" ":return!0;default:return!1}}var bf=new Set("0123456789ABCDEFabcdef"),vh=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),eo=new Set(",[]{}"),Dh=new Set(` ,[]{}
\r `),Bs=t=>!t||Dh.has(t),jn=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(e,n=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!n;let r=this.next??"stream";for(;r&&(n||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
`:case"\r":case" ":return!0;default:return!1}}var _f=new Set("0123456789ABCDEFabcdef"),kh=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),no=new Set(",[]{}"),Ih=new Set(` ,[]{}
\r `),Qs=t=>!t||Ih.has(t),jn=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(e,n=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!n;let r=this.next??"stream";for(;r&&(n||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let e=this.pos,n=this.buffer[e];for(;n===" "||n===" ";)n=this.buffer[++e];return!n||n==="#"||n===`
`?!0:n==="\r"?this.buffer[e+1]===`
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let n=this.buffer[e];if(this.indentNext>0){let r=0;for(;n===" ";)n=this.buffer[++r+e];if(n==="\r"){let o=this.buffer[r+e+1];if(o===`
`||!o&&!this.atEnd)return e+r+1}return n===`
`||r>=this.indentNext||!n&&!this.atEnd?e+r:-1}if(n==="-"||n==="."){let r=this.buffer.substr(e,3);if((r==="---"||r==="...")&&Oe(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){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 e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Ms&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,r=e.indexOf("#");for(;r!==-1;){let s=e[r-1];if(s===" "||s===" "){n=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let s=e[n-1];if(s===" "||s===" ")n-=1;else break}let o=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-o),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-n),yield*this.pushNewline(),"stream"}return yield Fs,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&Oe(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&&!Oe(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Oe(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 e=this.getLine();if(e===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(e[n]){case"#":yield*this.pushCount(e.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(e.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,n,r=-1;do e=yield*this.pushNewline(),e>0?(n=yield*this.pushSpaces(!1),this.indentValue=r=n):n=0,n+=yield*this.pushSpaces(!0);while(e+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("..."))&&Oe(o[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(o[0]==="]"||o[0]==="}")))return this.flowLevel=0,yield Zs,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||Oe(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 e=this.charAt(0),n=this.buffer.indexOf(e,this.pos+1);if(e==="'")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),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){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 e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Bs&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let n=e.length,r=e.indexOf("#");for(;r!==-1;){let s=e[r-1];if(s===" "||s===" "){n=r-1;break}else r=e.indexOf("#",r+1)}for(;;){let s=e[n-1];if(s===" "||s===" ")n-=1;else break}let o=(yield*this.pushCount(n))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-o),this.pushNewline(),"stream"}if(this.atLineEnd()){let n=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-n),yield*this.pushNewline(),"stream"}return yield js,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let n=this.peek(3);if((n==="---"||n==="...")&&Oe(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&&!Oe(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,n]=this.peek(2);if(!n&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Oe(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 e=this.getLine();if(e===null)return this.setNext("doc");let n=yield*this.pushIndicators();switch(e[n]){case"#":yield*this.pushCount(e.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(Qs),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return n+=yield*this.parseBlockScalarHeader(),n+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-n),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,n,r=-1;do e=yield*this.pushNewline(),e>0?(n=yield*this.pushSpaces(!1),this.indentValue=r=n):n=0,n+=yield*this.pushSpaces(!0);while(e+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("..."))&&Oe(o[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(o[0]==="]"||o[0]==="}")))return this.flowLevel=0,yield Us,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(Qs),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let i=this.charAt(1);if(this.flowKey||Oe(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 e=this.charAt(0),n=this.buffer.indexOf(e,this.pos+1);if(e==="'")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 e=this.pos;for(;;){let n=this.buffer[++e];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=>Oe(n)||n==="#")}*parseBlockScalar(){let e=this.pos-1,n=0,r;e:for(let s=this.pos;r=this.buffer[s];++s)switch(r){case" ":n+=1;break;case`
`:e=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(e+1);if(s===-1)break;e=this.buffer.indexOf(`
`,s)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let o=e+1;for(r=this.buffer[o];r===" ";)r=this.buffer[++o];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
`;)r=this.buffer[++o];e=o-1}else if(!this.blockScalarKeep)do{let s=e-1,i=this.buffer[s];i==="\r"&&(i=this.buffer[--s]);let a=s;for(;i===" ";)i=this.buffer[--s];if(i===`
`&&s>=this.pos&&s+1+n>a)e=s;else break}while(!0);return yield Hr,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=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(Oe(s)||e&&eo.has(s))break;n=r}else if(Oe(o)){let s=this.buffer[r+1];if(o==="\r"&&(s===`
`&&s>=this.pos&&s+1+n>a)e=s;else break}while(!0);return yield to,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=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(Oe(s)||e&&no.has(s))break;n=r}else if(Oe(o)){let s=this.buffer[r+1];if(o==="\r"&&(s===`
`?(r+=1,o=`
`,s=this.buffer[r+1]):n=r),s==="#"||e&&eo.has(s))break;if(o===`
`){let i=this.continueScalar(r+1);if(i===-1)break;r=Math.max(r,i-2)}}else{if(e&&eo.has(o))break;n=r}return!o&&!this.atEnd?this.setNext("plain-scalar"):(yield Hr,yield*this.pushToIndex(n+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,n){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(n&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Bs),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let n=this.flowLevel>0,r=this.charAt(1);if(Oe(r)||n&&eo.has(r)){n?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,n=this.buffer[e];for(;!Oe(n)&&n!==">";)n=this.buffer[++e];return yield*this.pushToIndex(n===">"?e+1:e,!1)}else{let e=this.pos+1,n=this.buffer[e];for(;n;)if(vh.has(n))n=this.buffer[++e];else if(n==="%"&&bf.has(this.buffer[e+1])&&bf.has(this.buffer[e+2]))n=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
`,s=this.buffer[r+1]):n=r),s==="#"||e&&no.has(s))break;if(o===`
`){let i=this.continueScalar(r+1);if(i===-1)break;r=Math.max(r,i-2)}}else{if(e&&no.has(o))break;n=r}return!o&&!this.atEnd?this.setNext("plain-scalar"):(yield to,yield*this.pushToIndex(n+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,n){let r=this.buffer.slice(this.pos,e);return r?(yield r,this.pos+=r.length,r.length):(n&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Qs),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let n=this.flowLevel>0,r=this.charAt(1);if(Oe(r)||n&&no.has(r)){n?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,n=this.buffer[e];for(;!Oe(n)&&n!==">";)n=this.buffer[++e];return yield*this.pushToIndex(n===">"?e+1:e,!1)}else{let e=this.pos+1,n=this.buffer[e];for(;n;)if(kh.has(n))n=this.buffer[++e];else if(n==="%"&&_f.has(this.buffer[e+1])&&_f.has(this.buffer[e+2]))n=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
`?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,r;do r=this.buffer[++n];while(r===" "||e&&r===" ");let o=n-this.pos;return o>0&&(yield this.buffer.substr(this.pos,o),this.pos=n),o}*pushUntil(e){let n=this.pos,r=this.buffer[n];for(;!e(r);)r=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};var vt=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let n=0,r=this.lineStarts.length;for(;n<r;){let s=n+r>>1;this.lineStarts[s]<e?n=s+1:r=s}if(this.lineStarts[n]===e)return{line:n+1,col:1};if(n===0)return{line:0,col:e};let o=this.lineStarts[n-1];return{line:n,col:e-o+1}}}};function pt(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function wf(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Ef(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function to(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function Yt(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function no(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let n=0;n<e.length;++n)t.push(e[n])}function _f(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!pt(e.start,"explicit-key-ind")&&!pt(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Ef(e.value)?e.value.end?no(e.value.end,e.sep):e.value.end=e.sep:no(e.start,e.sep),delete e.sep)}var Un=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new jn,this.onNewLine=e}*parse(e,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,n))yield*this.next(r);n||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=gf(e);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+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.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 e=this.peek(1);if(this.type==="doc-end"&&e?.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(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let n=e??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"&&_f(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&&wf(o.start)===-1&&(n.indent===0||o.start.every(s=>s.type!=="comment"||s. Line truncated
`?yield*this.pushCount(2):0}*pushSpaces(e){let n=this.pos-1,r;do r=this.buffer[++n];while(r===" "||e&&r===" ");let o=n-this.pos;return o>0&&(yield this.buffer.substr(this.pos,o),this.pos=n),o}*pushUntil(e){let n=this.pos,r=this.buffer[n];for(;!e(r);)r=this.buffer[++n];return yield*this.pushToIndex(n,!1)}};var vt=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let n=0,r=this.lineStarts.length;for(;n<r;){let s=n+r>>1;this.lineStarts[s]<e?n=s+1:r=s}if(this.lineStarts[n]===e)return{line:n+1,col:1};if(n===0)return{line:0,col:e};let o=this.lineStarts[n-1];return{line:n,col:e-o+1}}}};function pt(t,e){for(let n=0;n<t.length;++n)if(t[n].type===e)return!0;return!1}function Ef(t){for(let e=0;e<t.length;++e)switch(t[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Sf(t){switch(t?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function ro(t){switch(t.type){case"document":return t.start;case"block-map":{let e=t.items[t.items.length-1];return e.sep??e.start}case"block-seq":return t.items[t.items.length-1].start;default:return[]}}function Wt(t){if(t.length===0)return[];let e=t.length;e:for(;--e>=0;)switch(t[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;t[++e]?.type==="space";);return t.splice(e,t.length)}function oo(t,e){if(e.length<1e5)Array.prototype.push.apply(t,e);else for(let n=0;n<e.length;++n)t.push(e[n])}function xf(t){if(t.start.type==="flow-seq-start")for(let e of t.items)e.sep&&!e.value&&!pt(e.start,"explicit-key-ind")&&!pt(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Sf(e.value)?e.value.end?oo(e.value.end,e.sep):e.value.end=e.sep:oo(e.start,e.sep),delete e.sep)}var Un=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new jn,this.onNewLine=e}*parse(e,n=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(e,n))yield*this.next(r);n||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let n=wf(e);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+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let r=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:e}),this.offset+=e.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 e=this.peek(1);if(this.type==="doc-end"&&e?.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(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let n=e??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"&&xf(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&&Ef(o.start)===-1&&(n.indent===0||o.start.every(s=>s.type!=="comment"||s. Line truncated
`)+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(e){let n=e.items[e.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):e.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)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let o=e.items[e.items.length-2]?.value?.end;if(Array.isArray(o)){no(o,n.start),o.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,o=r&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",s=[];if(o&&n.sep&&!n.value){let i=[];for(let a=0;a<n.sep.length;++a){let c=n.sep[a];switch(c.type){case"newline":i.push(a);break;case"space":break;case"comment":c.indent>e.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),e.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),e.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)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(pt(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(Ef(n.key)&&!pt(n.sep,"newline")){let i=Yt(n.start),a=n.key,c=n.sep;c.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:a,sep:c}]})}else s.length>0?n.sep=n.sep.concat(s,this.sourceToken):n.sep.push(this.sourceToken);else if(pt(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let i=Yt(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?e.items.push({start:s,key:null,sep:[this.sourceToken]}):pt(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?(e.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(e);if(i){if(i.type==="block-seq"){if(!n.explicitKey&&n.sep&&!pt(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&&e.items.push({start:s});this.stack.push(i);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let n=e.items[e.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):e.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,e.indent)){let o=e.items[e.items.length-2]?.value?.end;if(Array.isArray(o)){no(o,n.start),o.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=e.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;n.value||pt(n.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let n=e.items[e.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(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?e.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?e.items.p Line truncated
`,n)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let n=e.items[e.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):e.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)e.items.push({start:[this.sourceToken]});else if(n.sep)n.sep.push(this.sourceToken);else{if(this.atIndentedComment(n.start,e.indent)){let o=e.items[e.items.length-2]?.value?.end;if(Array.isArray(o)){oo(o,n.start),o.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let r=!this.onKeyLine&&this.indent===e.indent,o=r&&(n.sep||n.explicitKey)&&this.type!=="seq-item-ind",s=[];if(o&&n.sep&&!n.value){let i=[];for(let a=0;a<n.sep.length;++a){let c=n.sep[a];switch(c.type){case"newline":i.push(a);break;case"space":break;case"comment":c.indent>e.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),e.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),e.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)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(pt(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(Sf(n.key)&&!pt(n.sep,"newline")){let i=Wt(n.start),a=n.key,c=n.sep;c.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:a,sep:c}]})}else s.length>0?n.sep=n.sep.concat(s,this.sourceToken):n.sep.push(this.sourceToken);else if(pt(n.start,"newline"))Object.assign(n,{key:null,sep:[this.sourceToken]});else{let i=Wt(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?e.items.push({start:s,key:null,sep:[this.sourceToken]}):pt(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?(e.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(e);if(i){if(i.type==="block-seq"){if(!n.explicitKey&&n.sep&&!pt(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&&e.items.push({start:s});this.stack.push(i);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let n=e.items[e.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):e.items.push({start:[this.sourceToken]})}else n.start.push(this.sourceToken);return;case"space":case"comment":if(n.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(n.start,e.indent)){let o=e.items[e.items.length-2]?.value?.end;if(Array.isArray(o)){oo(o,n.start),o.push(this.sourceToken),e.items.pop();return}}n.start.push(this.sourceToken)}return;case"anchor":case"tag":if(n.value||this.indent<=e.indent)break;n.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;n.value||pt(n.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return}if(this.indent>e.indent){let r=this.startBlockValue(e);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let n=e.items[e.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(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!n||n.sep?e.items.push({start:[this.sourceToken]}):n.start.push(this.sourceToken);return;case"map-value-ind":!n||n.value?e.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?e.items.p Line truncated
`)+1;for(;n!==0;)this.onNewLine(this.offset+n),n=this.source.indexOf(`
`,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){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=to(e),r=Yt(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=to(e),r=Yt(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){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:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};function Rh(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new vt||null,prettyErrors:e}}function js(t,e={}){let{lineCounter:n,prettyErrors:r}=Rh(e),o=new Un(n?.addNewLine),s=new Bn(e),i=null;for(let a of s.compose(o.parse(t),!0,t.length))if(!i)i=a;else if(i.options.logLevel!=="silent"){i.errors.push(new Ie(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(i.errors.forEach(Is(t,n)),i.warnings.forEach(Is(t,n))),i}var Ce=class extends Error{code;constructor(e){super(`Structured data failed validation: ${e}`),this.name="StructuredDataError",this.code=e}},Sf=t=>Ne(JSON.stringify(t)),xf=t=>{if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null},Af=(t,e)=>{if(xf(t)===!1)throw new Ce("INVALID");let n=0,r=(s,i)=>{if(i>e.depth)throw new Ce("DEPTH_EXCEEDED");if(typeof s=="string"){if(Ne(s)>e.stringBytes)throw new Ce("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(a=>{if(n+=1,n>e.fields)throw new Ce("FIELDS_EXCEEDED");return r(a,i+1)});if(xf(s)){let a=Object.create(null);for(let[c,u]of Object.entries(s)){if(n+=1,n>e.fields)throw new Ce("FIELDS_EXCEEDED");a[c]=r(u,i+1)}return a}throw new Ce("INVALID")},o=r(t,1);if(Sf(o)>e.serializedBytes)throw new Ce("SERIALIZED_BYTES_EXCEEDED");return o};var Y=class extends Error{code;line;column;constructor(e,n,r,o){super(n,{cause:o}),this.name="MarkdownMetadataError",this.code=e,this.line=r?.line,this.column=r?.column}};var Xt=new Uint8Array([239,187,191]),vf=Xt.byteLength+10,Oh=(t,e,n=0)=>t.byteLength-n<e.byteLength?!1:e.every((r,o)=>t[n+o]===r),Qn=(t,e)=>{let n=0;if(Oh(t,Xt))n=Xt.byteLength;else if(t.byteLength<Xt.byteLength&&Xt.slice(0,t.byteLength).every((s,i)=>s===t[i]))return e?null:void 0;if(t.byteLength<n+4)return e?null:void 0;if(t[n]!==45||t[n+1]!==45||t[n+2]!==45)return null;let r=n+3;if(t[r]===10)r+=1;else if(t[r]===13){if(t.byteLength===r+1)return e?null:void 0;if(t[r+1]!==10)return null;r+=2}else return null;let o=r;for(let s=r;s<=t.byteLength;s+=1){let i=s===t.byteLength;if(i===!1&&t[s]!==10)continue;if(i&&e===!1)return;let a=s;if(a>o&&t[a-1]===13&&(a-=1),a-o===3&&(t[o]===45&&t[o+1]===45&&t[o+2]===45||t[o]===46&&t[o+1]===46&&t[o+2]===46))return{yamlStart:r,yamlEnd:o,blockEnd:i?s:s+1};o=s+1}};var Ch={bytes:k.frontmatterBytes,depth:k.frontmatterDepth,fields:k.frontmatterFields,stringBytes:k.frontmatterStringBytes,serializedBytes:k.indexedPropertiesBytes},Df=t=>{try{return le(t)}catch{throw new Y("FRONTMATTER_DECODING_FAILED","Markdown frontmatter is not valid UTF-8")}},Th=t=>t.code==="DEPTH_EXCEEDED"?new Y("FRONTMATTER_DEPTH_EXCEEDED","Markdown frontmatter exceeds the nesting limit"):t.code==="FIELDS_EXCEEDED"?new Y("FRONTMATTER_FIELDS_EXCEEDED","Markdown frontmatter exceeds the field limit"):t.code==="STRING_BYTES_EXCEEDED"?new Y("FRONTMATTER_STRING_BYTES_EXCEEDED","Markdown frontmatter contains a string that exceeds the byte limit"):t.code==="SERIALIZED_BYTES_EXCEEDED"?new Y("FRONTMATTER_BYTES_EXCEEDED","Markdown frontmatter properties exceed the indexed byte limit"):new Y("FRONTMATTER_INVALID","Markdown frontmatter must contain a JSON-compatible object"),Rf=(t,e)=>{let n=new vt, Line truncated
`,n)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){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=ro(e),r=Wt(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=ro(e),r=Wt(n);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,n){return this.type!=="comment"||this.indent<=n?!1:e.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){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:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};function Oh(t){let e=t.prettyErrors!==!1;return{lineCounter:t.lineCounter||e&&new vt||null,prettyErrors:e}}function Vs(t,e={}){let{lineCounter:n,prettyErrors:r}=Oh(e),o=new Un(n?.addNewLine),s=new Bn(e),i=null;for(let a of s.compose(o.parse(t),!0,t.length))if(!i)i=a;else if(i.options.logLevel!=="silent"){i.errors.push(new Ie(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&n&&(i.errors.forEach(Ts(t,n)),i.warnings.forEach(Ts(t,n))),i}var Ce=class extends Error{code;constructor(e){super(`Structured data failed validation: ${e}`),this.name="StructuredDataError",this.code=e}},vf=t=>Ne(JSON.stringify(t)),Af=t=>{if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null},Df=(t,e)=>{if(Af(t)===!1)throw new Ce("INVALID");let n=0,r=(s,i)=>{if(i>e.depth)throw new Ce("DEPTH_EXCEEDED");if(typeof s=="string"){if(Ne(s)>e.stringBytes)throw new Ce("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(a=>{if(n+=1,n>e.fields)throw new Ce("FIELDS_EXCEEDED");return r(a,i+1)});if(Af(s)){let a=Object.create(null);for(let[c,u]of Object.entries(s)){if(n+=1,n>e.fields)throw new Ce("FIELDS_EXCEEDED");a[c]=r(u,i+1)}return a}throw new Ce("INVALID")},o=r(t,1);if(vf(o)>e.serializedBytes)throw new Ce("SERIALIZED_BYTES_EXCEEDED");return o};var Y=class extends Error{code;line;column;constructor(e,n,r,o){super(n,{cause:o}),this.name="MarkdownMetadataError",this.code=e,this.line=r?.line,this.column=r?.column}};var Yt=new Uint8Array([239,187,191]),Rf=Yt.byteLength+10,Nh=(t,e,n=0)=>t.byteLength-n<e.byteLength?!1:e.every((r,o)=>t[n+o]===r),Qn=(t,e)=>{let n=0;if(Nh(t,Yt))n=Yt.byteLength;else if(t.byteLength<Yt.byteLength&&Yt.slice(0,t.byteLength).every((s,i)=>s===t[i]))return e?null:void 0;if(t.byteLength<n+4)return e?null:void 0;if(t[n]!==45||t[n+1]!==45||t[n+2]!==45)return null;let r=n+3;if(t[r]===10)r+=1;else if(t[r]===13){if(t.byteLength===r+1)return e?null:void 0;if(t[r+1]!==10)return null;r+=2}else return null;let o=r;for(let s=r;s<=t.byteLength;s+=1){let i=s===t.byteLength;if(i===!1&&t[s]!==10)continue;if(i&&e===!1)return;let a=s;if(a>o&&t[a-1]===13&&(a-=1),a-o===3&&(t[o]===45&&t[o+1]===45&&t[o+2]===45||t[o]===46&&t[o+1]===46&&t[o+2]===46))return{yamlStart:r,yamlEnd:o,blockEnd:i?s:s+1};o=s+1}};var $h={bytes:k.frontmatterBytes,depth:k.frontmatterDepth,fields:k.frontmatterFields,stringBytes:k.frontmatterStringBytes,serializedBytes:k.indexedPropertiesBytes},kf=t=>{try{return le(t)}catch{throw new Y("FRONTMATTER_DECODING_FAILED","Markdown frontmatter is not valid UTF-8")}},zh=t=>t.code==="DEPTH_EXCEEDED"?new Y("FRONTMATTER_DEPTH_EXCEEDED","Markdown frontmatter exceeds the nesting limit"):t.code==="FIELDS_EXCEEDED"?new Y("FRONTMATTER_FIELDS_EXCEEDED","Markdown frontmatter exceeds the field limit"):t.code==="STRING_BYTES_EXCEEDED"?new Y("FRONTMATTER_STRING_BYTES_EXCEEDED","Markdown frontmatter contains a string that exceeds the byte limit"):t.code==="SERIALIZED_BYTES_EXCEEDED"?new Y("FRONTMATTER_BYTES_EXCEEDED","Markdown frontmatter properties exceed the indexed byte limit"):new Y("FRONTMATTER_INVALID","Markdown frontmatter must contain a JSON-compatible object"),If=(t,e)=>{let n=new vt, Line truncated
@@ -3,6 +3,7 @@ import type { ResourceRequest } from "@webstudio-is/sdk";
declare module "react-router" {
interface AppLoadContext {
EXCLUDE_FROM_SEARCH: boolean;
WEBSTUDIO_AUTOMATION_TOKEN?: string;
getDefaultActionResource?: (options: {
url: URL;
projectId: string;
+319 -199
View File
@@ -15,6 +15,7 @@ import { pathToFileURL } from "node:url";
import { tmpdir } from "node:os";
import { execFile } from "node:child_process";
import { promisify } from "node:util";
import { createServer } from "node:http";
import {
defaultTreeAdapter,
parse as parseHtml,
@@ -2196,123 +2197,215 @@ sitemap.map((page) => page.path);`
);
});
test("hydrates a synced MDX asset into a dynamic SSR content database", async () => {
const source = "# Published post\n";
const index = await createTestAssetIndex({
...indexedDocument,
name: "post.mdx",
path: "blog/post.mdx",
extension: "mdx",
mimeType: "text/mdx",
contentRef: "post.mdx",
size: new TextEncoder().encode(source).byteLength,
properties: { slug: "post" },
});
const siteData = {
...createSiteData({
pages: [
test.each(["mdx", "md"])(
"fetches a synced %s asset over HTTP in a dynamic SSR build",
async (extension) => {
const source = "# Published post\n";
const name = `post.${extension}`;
const index = await createTestAssetIndex({
...indexedDocument,
name,
path: `blog/${name}`,
extension,
mimeType: extension === "mdx" ? "text/mdx" : "text/markdown",
contentRef: name,
size: new TextEncoder().encode(source).byteLength,
properties: { slug: "post" },
});
const siteData = {
...createSiteData({
pages: [
{
id: "home",
name: "Home",
title: "Home",
path: "",
rootInstanceId: "root",
meta: {},
},
{
id: "post",
name: "Post",
title: "Post",
path: "/blog/:slug",
rootInstanceId: "root",
meta: {},
},
],
}),
assets: [
{
id: "home",
name: "Home",
title: "Home",
path: "",
rootInstanceId: "root",
id: "post-1",
projectId: "project-id",
name,
type: "file" as const,
format: extension,
size: source.length,
meta: {},
description: "",
createdAt: "2024-01-01T00:00:00.000Z",
},
{
id: "post",
name: "Post",
title: "Post",
path: "/blog/:slug",
rootInstanceId: "root",
id: "draft",
projectId: "project-id",
name: `draft.${extension}`,
type: "file" as const,
format: extension,
size: source.length,
meta: {},
description: "",
createdAt: "2024-01-01T00:00:00.000Z",
},
],
}),
assets: [
{
id: "post-1",
projectId: "project-id",
name: "post.mdx",
type: "file" as const,
format: "mdx",
size: source.length,
meta: {},
description: "",
createdAt: "2024-01-01T00:00:00.000Z",
},
{
id: "draft",
projectId: "project-id",
name: "draft.mdx",
type: "file" as const,
format: "mdx",
size: source.length,
meta: {},
description: "",
createdAt: "2024-01-01T00:00:00.000Z",
},
],
assetIndex: index,
};
await writeSiteData(
siteData as unknown as ReturnType<typeof createSiteData>
);
await mkdir(".webstudio/assets", { recursive: true });
await writeFile(".webstudio/assets/post.mdx", source, "utf8");
await writeFile(".webstudio/assets/draft.mdx", "draft secret", "utf8");
assetIndex: index,
};
siteData.build.resources = [
["posts", createQueryResource("full")],
] as never;
siteData.build.dataSources = [
[
"posts-data",
{
id: "posts-data",
type: "resource",
name: "posts",
resourceId: "posts",
scopeInstanceId: "root",
},
],
] as never;
await writeSiteData(
siteData as unknown as ReturnType<typeof createSiteData>
);
await mkdir(".webstudio/assets", { recursive: true });
await writeFile(`.webstudio/assets/${name}`, source, "utf8");
await writeFile(
`.webstudio/assets/draft.${extension}`,
"draft secret",
"utf8"
);
await prebuild({ assets: true, template: ["react-router"] });
await prebuild({
assets: true,
template: ["react-router"],
});
await expect(
readFile("app/routes/[blog].$slug._index.tsx", "utf8")
).resolves.toContain("createGeneratedAssetResourceFetch");
await expect(readFile("public/assets/post.mdx", "utf8")).resolves.toBe(
source
);
await expect(readFile("public/assets/draft.mdx", "utf8")).resolves.toBe(
"draft secret"
);
const manifest = await readFile(
"app/__generated__/$resources.asset-query-manifest.ts",
"utf8"
);
expect(manifest).toContain("Published post");
expect(manifest).not.toContain("draft secret");
await expect(
readFile("app/asset-resource-fetch.ts", "utf8")
).rejects.toThrow("ENOENT");
expect(
(await getFilePaths("app/routes")).filter((path) =>
path.includes("$slug")
)
).toHaveLength(1);
await symlink(join(originalCwd, "node_modules"), "node_modules", "dir");
await runGeneratedCommand("react-router", ["build"]);
const serverBundle = (
await Promise.all(
(
await getFilePaths("build/server")
await expect(
readFile("app/routes/[blog].$slug._index.tsx", "utf8")
).resolves.toContain("createGeneratedAssetResourceFetch");
await expect(readFile(`public/assets/${name}`, "utf8")).resolves.toBe(
source
);
await expect(
readFile(`public/assets/draft.${extension}`, "utf8")
).resolves.toBe("draft secret");
const manifest = await readFile(
"app/__generated__/$resources.asset-query-manifest.ts",
"utf8"
);
expect(manifest).not.toContain("Published post");
expect(manifest).not.toContain('"contents"');
expect(manifest).not.toContain("draft secret");
await expect(
readFile("app/asset-resource-fetch.ts", "utf8")
).rejects.toThrow("ENOENT");
expect(
(await getFilePaths("app/routes")).filter((path) =>
path.includes("$slug")
)
.filter((path) => path.endsWith(".js"))
.map((path) => readFile(path, "utf8"))
)
).join("\n");
expect(serverBundle).toContain("Published post");
expect(serverBundle).not.toContain("draft secret");
expect(serverBundle).toContain("post-revision");
const clientBundle = (
await Promise.all(
(
await getFilePaths("build/client")
).toHaveLength(1);
await symlink(join(originalCwd, "node_modules"), "node_modules", "dir");
await runGeneratedCommand("react-router", ["build"]);
const serverBundle = (
await Promise.all(
(
await getFilePaths("build/server")
)
.filter((path) => path.endsWith(".js"))
.map((path) => readFile(path, "utf8"))
)
.filter((path) => path.endsWith(".js"))
.map((path) => readFile(path, "utf8"))
)
).join("\n");
expect(clientBundle).not.toContain("Published post");
expect(clientBundle).not.toContain("post-revision");
}, 30_000);
).join("\n");
expect(serverBundle).not.toContain("Published post");
expect(serverBundle).not.toContain("draft secret");
expect(serverBundle).toContain("post-revision");
const clientBundle = (
await Promise.all(
(
await getFilePaths("build/client")
)
.filter((path) => path.endsWith(".js"))
.map((path) => readFile(path, "utf8"))
)
).join("\n");
expect(clientBundle).not.toContain("Published post");
expect(clientBundle).not.toContain("post-revision");
// Exercise the generated runtime against real locally served assets.
// The preview/Vite server supplies the same public files in normal use.
const runtimeBundle = await build({
entryPoints: [
join(tempDir, "app/__generated__/$resources.asset-query-runtime.ts"),
],
bundle: true,
format: "esm",
platform: "node",
write: false,
});
const runtime = await import(
/* @vite-ignore */
`data:text/javascript;base64,${Buffer.from(runtimeBundle.outputFiles[0].text).toString("base64")}`
);
const requestedPaths: string[] = [];
const server = createServer((request, response) => {
requestedPaths.push(request.url ?? "");
if (request.url !== `/assets/${name}`) {
response.writeHead(404).end();
return;
}
void readFile(join(tempDir, "build/client/assets", name)).then(
(bytes) => response.end(bytes),
() => response.writeHead(404).end()
);
});
await new Promise<void>((resolve) =>
server.listen(0, "127.0.0.1", resolve)
);
try {
const address = server.address();
if (address === null || typeof address === "string") {
throw new Error("Expected a local TCP server");
}
const origin = `http://127.0.0.1:${address.port}`;
const generatedFetch = await runtime.createGeneratedAssetResourceFetch({
request: new Request(`${origin}/blog/post`),
context: {},
fallback: originalFetch,
});
const response = await generatedFetch("/$resources/assets", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
query: {
content: { mode: "full" },
output: { mode: "all", includeMetadata: true },
},
}),
});
const data = await response.json();
expect(response.status, JSON.stringify(data)).toBe(200);
expect(data).toMatchObject({
items: [{ id: "post-1", content: { text: source } }],
});
expect(requestedPaths).toEqual([`/assets/${name}`]);
} finally {
server.closeAllConnections();
await new Promise<void>((resolve, reject) =>
server.close((error) => (error ? reject(error) : resolve()))
);
}
},
30_000
);
test("embeds the deployment database when asset downloads are disabled", async () => {
const index = await createTestAssetIndex();
@@ -2348,6 +2441,8 @@ sitemap.map((page) => page.path);`
await writeSiteData(
siteData as unknown as ReturnType<typeof createSiteData>
);
await mkdir(".webstudio/assets", { recursive: true });
await writeFile(".webstudio/assets/post.md", "local post body\n", "utf8");
await prebuild({
assets: false,
@@ -2358,6 +2453,9 @@ sitemap.map((page) => page.path);`
await expect(
readFile("app/__generated__/$resources.asset-query-manifest.ts", "utf8")
).resolves.toContain(index.integrity.checksum);
await expect(
readFile("app/__generated__/$resources.asset-query-manifest.ts", "utf8")
).resolves.not.toContain("local post body");
const runtimeModule = await readFile(
"app/__generated__/$resources.asset-query-runtime.ts",
"utf8"
@@ -2388,109 +2486,131 @@ sitemap.map((page) => page.path);`
).rejects.toThrow("ENOENT");
});
test("keeps deferred SaaS asset proxy URLs deployment-relative", async () => {
const index = await createAssetIndex({
projectId: "project-1",
entries: [
createCanonicalAssetFileEntry({
projectId: "project-1",
document: indexedDocument,
}),
],
documentGraph: createDocumentGraph({
nodes: [
test.each(["production", "staging"] as const)(
"keeps deferred published asset proxy URLs deployment-relative (%s)",
async (target) => {
const index = await createAssetIndex({
projectId: "project-1",
entries: [
{
id: indexedDocument._id,
revision: indexedDocument.revision,
contentRef: indexedDocument.contentRef,
format: "markdown",
...createCanonicalAssetFileEntry({
projectId: "project-1",
document: indexedDocument,
}),
content: "# Indexed post body\n",
},
],
edges: [],
}),
});
const baseSiteData = createSiteData({
assets: [createAssetForIndexedDocument(indexedDocument)],
});
const siteData = {
...baseSiteData,
origin: "https://p-project-1.apps.webstudio.is",
assetIndex: index,
build: {
...baseSiteData.build,
deployment: {
destination: "saas" as const,
domains: ["example"],
assetsDomain: "example",
excludeWstdDomainFromSearch: false,
},
resources: [["posts", createQueryResource("markdown-body-ref")]],
dataSources: [
[
"posts-data",
documentGraph: createDocumentGraph({
nodes: [
{
id: "posts-data",
type: "resource" as const,
name: "posts",
resourceId: "posts",
scopeInstanceId: "root",
id: indexedDocument._id,
revision: indexedDocument.revision,
contentRef: indexedDocument.contentRef,
format: "markdown",
},
],
],
},
};
await writeSiteData(
siteData as unknown as ReturnType<typeof createSiteData>
);
edges: [],
}),
});
const baseSiteData = createSiteData({
assets: [createAssetForIndexedDocument(indexedDocument)],
});
const siteData = {
...baseSiteData,
origin: "https://p-project-1.apps.webstudio.is",
assetIndex: index,
build: {
...baseSiteData.build,
deployment: {
destination: "saas" as const,
target,
domains: ["example"],
assetsDomain: "example",
excludeWstdDomainFromSearch: false,
},
resources: [["posts", createQueryResource("markdown-body-ref")]],
dataSources: [
[
"posts-data",
{
id: "posts-data",
type: "resource" as const,
name: "posts",
resourceId: "posts",
scopeInstanceId: "root",
},
],
],
},
};
await writeSiteData(
siteData as unknown as ReturnType<typeof createSiteData>
);
await prebuild({
assets: false,
template: ["react-router"],
preserveRouteTemplates: true,
});
await prebuild({
assets: false,
template: ["react-router"],
preserveRouteTemplates: true,
});
const runtimeModule = await readFile(
"app/__generated__/$resources.asset-query-runtime.ts",
"utf8"
);
expect(runtimeModule).toContain('"url":"/cgi/asset/post.md?format=raw"');
expect(runtimeModule).not.toContain(
"https://p-project-1.apps.webstudio.is/cgi/asset/"
);
expect(runtimeModule).not.toContain('"url":"/assets/post.md"');
const assetsModule = await readFile(
"app/__generated__/$resources.assets.ts",
"utf8"
);
expect(assetsModule).toContain(
'"/post.md": "/cgi/asset/post.md?format=raw"'
);
expect(assetsModule).not.toContain(
"https://p-project-1.apps.webstudio.is/cgi/asset/"
);
const runtimeModule = await readFile(
"app/__generated__/$resources.asset-query-runtime.ts",
"utf8"
);
const manifest = await readFile(
"app/__generated__/$resources.asset-query-manifest.ts",
"utf8"
);
expect(manifest).not.toContain("# Indexed post body");
expect(runtimeModule).toContain('"url":"/cgi/asset/post.md?format=raw"');
expect(runtimeModule).not.toContain("sourceUrl");
expect(runtimeModule).not.toContain(
"https://p-project-1.apps.webstudio.is/cgi/asset/"
);
expect(runtimeModule).not.toContain('"url":"/assets/post.md"');
const assetsModule = await readFile(
"app/__generated__/$resources.assets.ts",
"utf8"
);
expect(assetsModule).toContain(
'"/post.md": "/cgi/asset/post.md?format=raw"'
);
expect(assetsModule).not.toContain(
"https://p-project-1.apps.webstudio.is/cgi/asset/"
);
await mkdir(".webstudio/assets", { recursive: true });
await writeFile(".webstudio/assets/post.md", "# Post\n", "utf8");
await prebuild({
assets: true,
template: ["react-router"],
preserveRouteTemplates: true,
});
await mkdir(".webstudio/assets", { recursive: true });
await writeFile(".webstudio/assets/post.md", "# Post\n", "utf8");
await prebuild({
assets: true,
template: ["react-router"],
preserveRouteTemplates: true,
});
const materializedRuntimeModule = await readFile(
"app/__generated__/$resources.asset-query-runtime.ts",
"utf8"
);
expect(materializedRuntimeModule).toContain('"url":"/assets/post.md"');
expect(materializedRuntimeModule).not.toContain(
'"url":"https://assets.example/cgi/asset/post.md?format=raw"'
);
const materializedAssetsModule = await readFile(
"app/__generated__/$resources.assets.ts",
"utf8"
);
expect(materializedAssetsModule).toContain('"/post.md": "/assets/post.md"');
});
const materializedRuntimeModule = await readFile(
"app/__generated__/$resources.asset-query-runtime.ts",
"utf8"
);
const materializedManifest = await readFile(
"app/__generated__/$resources.asset-query-manifest.ts",
"utf8"
);
expect(materializedManifest).not.toContain("# Indexed post body");
expect(materializedManifest).not.toContain('"contents"');
expect(materializedRuntimeModule).toContain('"url":"/assets/post.md"');
expect(materializedRuntimeModule).not.toContain("sourceUrl");
expect(materializedRuntimeModule).not.toContain(
'"url":"https://assets.example/cgi/asset/post.md?format=raw"'
);
const materializedAssetsModule = await readFile(
"app/__generated__/$resources.assets.ts",
"utf8"
);
expect(materializedAssetsModule).toContain(
'"/post.md": "/assets/post.md"'
);
}
);
test("uses pass-through images in the base react-router template", async () => {
await prebuild({ assets: false, template: ["react-router"] });
+31 -11
View File
@@ -60,6 +60,7 @@ import {
type WsComponentMeta,
type Pages,
type ComponentBuildContribution,
isPublishedDeployment,
} from "@webstudio-is/sdk";
import { migratePages } from "@webstudio-is/project-migrations/pages";
import {
@@ -161,21 +162,24 @@ type SiteDataByPage = {
};
};
const hydrateLocalMdxContents = async ({
const hydrateLocalMarkdownContents = async ({
artifact,
assets,
assetsDirectory,
includeMarkdown,
}: {
artifact: ContentArtifactV1;
assets: readonly Asset[];
assetsDirectory: string;
includeMarkdown: boolean;
}): Promise<ContentArtifactV1> => {
const assetsById = new Map(assets.map((asset) => [asset.id, asset]));
const missingContents = await Promise.all(
artifact.documents
.filter(
(document) =>
document.extension === "mdx" &&
(document.extension === "mdx" ||
(includeMarkdown && document.extension === "md")) &&
document.contentRef !== undefined &&
artifact.contents?.[document.contentRef] === undefined
)
@@ -620,8 +624,8 @@ const createRuntimeFetch = createGeneratedAssetResourceRuntime({
runtimeAssets,
});
export const createGeneratedAssetResourceFetch = ({ request, fallback }: ${inputType}) =>
createRuntimeFetch({ request, fallback });
export const createGeneratedAssetResourceFetch = ({ request, context, fallback }: ${inputType}) =>
createRuntimeFetch({ request, context, fallback });
`;
};
@@ -629,17 +633,21 @@ const materializeVerifiedAssetIndex = async ({
index,
runtimeAssets,
includeDocumentRuntimeAssets,
includeContents,
generatedDirectory,
deploymentId,
}: {
index: ContentArtifactV1 | undefined;
runtimeAssets: Readonly<Record<string, AssetRuntimeData>>;
includeDocumentRuntimeAssets: boolean;
includeContents?: boolean;
generatedDirectory: string;
deploymentId: string;
}) => {
const runtimeIndex =
index === undefined ? undefined : createContentRuntimeArtifact(index);
index === undefined
? undefined
: createContentRuntimeArtifact(index, { includeContents });
const serializedIndex =
runtimeIndex === undefined
? undefined
@@ -709,6 +717,7 @@ export const materializeAssetIndex = async ({
index: PublishedProjectBundle["assetIndex"];
runtimeAssets: Readonly<Record<string, AssetRuntimeData>>;
includeDocumentRuntimeAssets: boolean;
includeContents?: boolean;
generatedDirectory: string;
deploymentId: string;
}) =>
@@ -979,8 +988,9 @@ export const prebuild = async (options: {
preserveTemplates: preserveRouteTemplates,
templatesDirectory: join(buildRoot, routeTemplatesDirectory),
};
const isStaticBuild = options.template.includes("ssg");
let framework;
if (options.template.includes("ssg")) {
if (isStaticBuild) {
framework = await createVikeSsgFramework(frameworkOptions);
} else if (options.template.includes("react-router")) {
framework = await createReactRouterFramework(frameworkOptions);
@@ -1020,12 +1030,18 @@ export const prebuild = async (options: {
siteData.assetIndex === undefined
? undefined
: await verifyContentArtifact(siteData.assetIndex);
if (verifiedAssetIndex !== undefined) {
verifiedAssetIndex = await hydrateLocalMdxContents({
if (
verifiedAssetIndex !== undefined &&
(options.previewIdentity === true || options.assets === true)
) {
verifiedAssetIndex = await hydrateLocalMarkdownContents({
artifact: verifiedAssetIndex,
assets: siteData.assets,
assetsDirectory:
options.sourceAssetsDirectory ?? join(buildRoot, LOCAL_ASSETS_DIR),
// SSR only needs local MDX sources during component compilation. Its
// runtime reads article contents over HTTP, just like hosted sites.
includeMarkdown: isStaticBuild,
});
}
let dynamicMdxCandidates: ReadonlyMap<string, readonly string[]> | undefined;
@@ -1165,7 +1181,7 @@ export const prebuild = async (options: {
asset,
"https://placeholder.local"
);
return siteData.build.deployment?.destination === "saas" &&
return isPublishedDeployment(siteData.build.deployment) &&
options.assets === false
? runtimeAsset.url
: `${assetBaseUrl}${asset.name}`;
@@ -1181,8 +1197,9 @@ export const prebuild = async (options: {
{
...runtimeAsset,
contentRef: asset.name,
// SaaS serves project assets through its storage-backed proxy.
// Generated projects with downloaded assets serve them locally.
// Hosted deployments serve project assets through storage-backed
// proxies. Generated projects with downloaded assets serve them
// locally.
url: getPublishedAssetUrl(asset),
},
];
@@ -1895,6 +1912,9 @@ export const prebuild = async (options: {
includeDocumentRuntimeAssets:
assetCompilationPlan !== undefined &&
requiresRuntimeDocumentData(assetCompilationPlan),
// Only static prerendering consumes embedded source files. Both local
// and hosted SSR use the same HTTP content loader and serve assets.
includeContents: isStaticBuild,
generatedDirectory: generatedDir,
deploymentId: siteData.build.id,
});
@@ -3,6 +3,7 @@ import type { ResourceRequest } from "@webstudio-is/sdk";
declare module "react-router" {
interface AppLoadContext {
EXCLUDE_FROM_SEARCH: boolean;
WEBSTUDIO_AUTOMATION_TOKEN?: string;
getDefaultActionResource?: (options: {
url: URL;
projectId: string;
@@ -1,6 +1,6 @@
{
"$schema": "node_modules/wrangler/config-schema.json",
// SaaS publishes Workers. This takes precedence over the Cloudflare Pages
// Hosted deployments publish Workers. This takes precedence over the Cloudflare Pages
// template's wrangler.toml; publish workflows provide the name and date.
"name": "webstudio-remix-app",
"compatibility_date": "2024-04-05"
@@ -18,5 +18,9 @@ export const createSsgAssetResourceFetch = ({
baseUrl: "https://webstudio.local",
deploymentId,
artifact,
automationToken:
typeof process === "undefined"
? undefined
: process.env.WEBSTUDIO_AUTOMATION_TOKEN,
runtimeAssets,
});
@@ -42,6 +42,40 @@ export const toByteChunks = (source: ByteSource): AsyncIterable<Uint8Array> => {
return source;
};
export const selectByteRange = (
source: ByteSource,
range?: { offset: number; length: number }
): AsyncIterable<Uint8Array> => {
if (range === undefined) {
return toByteChunks(source);
}
return {
async *[Symbol.asyncIterator]() {
let skipped = 0;
let emitted = 0;
for await (const chunk of toByteChunks(source)) {
if (emitted === range.length) {
return;
}
if (skipped + chunk.byteLength <= range.offset) {
skipped += chunk.byteLength;
continue;
}
const start = Math.max(0, range.offset - skipped);
const length = Math.min(
chunk.byteLength - start,
range.length - emitted
);
if (length > 0) {
yield chunk.subarray(start, start + length);
emitted += length;
}
skipped += chunk.byteLength;
}
},
};
};
export const readableStreamToAsyncIterable = (
stream: ReadableStream<Uint8Array>
): AsyncIterable<Uint8Array> => ({
@@ -197,6 +197,17 @@ describe("content compilation plan", () => {
}
});
test.each([
{ mode: "full" },
{ mode: "range", offset: 1, length: 2 },
{ mode: "markdown-body-ref" },
])("retains asset URLs for HTTP content reads: $mode", (content) => {
const plan = createContentCompilationPlan([
compilationQuery("content", assetQuery.parse({ ...query, content })),
]);
expect(requiresRuntimeDocumentData(plan!)).toBe(true);
});
test("unions selected fields deterministically and returns no requirements for no queries", () => {
expect(createContentCompilationPlan([])).toBeUndefined();
expect(
@@ -446,11 +446,13 @@ const includesField = (
};
export const requiresRuntimeDocumentData = (plan: ContentCompilationPlan) =>
plan.queries.some((query) =>
includesField(
query,
(field) => field.length === 1 && isAssetQueryRuntimeField(field[0])
)
plan.queries.some(
(query) =>
query.content.mode !== "none" ||
includesField(
query,
(field) => field.length === 1 && isAssetQueryRuntimeField(field[0])
)
);
const getStructuredPropertyPaths = (query: ContentCompilationQuery) => {
@@ -20,7 +20,7 @@ import {
matchesAssetQueryFilter,
type AssetRuntimeData,
} from "./structured-query";
import { encodeUtf8, getUtf8ByteLength, toByteChunks } from "./byte-stream";
import { encodeUtf8, getUtf8ByteLength, selectByteRange } from "./byte-stream";
import type { AssetResourceContentReader } from "./hydration";
import { getMaterializedAssetQueryResult } from "./materialized-query";
import {
@@ -81,40 +81,6 @@ export type RuntimeContentDatabase = Pick<
"query" | "queryManyWithDocumentGraph" | "queryWithDocumentGraph"
>;
const selectByteRange = (
source: Parameters<typeof toByteChunks>[0],
range?: { offset: number; length: number }
): AsyncIterable<Uint8Array> => {
if (range === undefined) {
return toByteChunks(source);
}
return {
async *[Symbol.asyncIterator]() {
let skipped = 0;
let emitted = 0;
for await (const chunk of toByteChunks(source)) {
if (emitted === range.length) {
return;
}
if (skipped + chunk.byteLength <= range.offset) {
skipped += chunk.byteLength;
continue;
}
const start = Math.max(0, range.offset - skipped);
const length = Math.min(
chunk.byteLength - start,
range.length - emitted
);
if (length > 0) {
yield chunk.subarray(start, start + length);
emitted += length;
}
skipped += chunk.byteLength;
}
},
};
};
const createDocumentContentReader = ({
graph,
load,
@@ -77,6 +77,9 @@ test("projects build metadata and inline JSON graph sources out of the runtime a
});
const runtime = createContentRuntimeArtifact(artifact);
const runtimeWithoutContents = createContentRuntimeArtifact(artifact, {
includeContents: false,
});
const serialized = serializeContentRuntimeArtifact(runtime);
const parsed = JSON.parse(serialized);
@@ -86,6 +89,7 @@ test("projects build metadata and inline JSON graph sources out of the runtime a
expect(parsed).not.toHaveProperty("fieldCatalog");
expect(parsed).not.toHaveProperty("database");
expect(parsed).not.toHaveProperty("integrity");
expect(runtimeWithoutContents).not.toHaveProperty("contents");
expect(runtime.documentGraph?.nodes.map(({ id }) => id)).toEqual([
"markdown",
]);
@@ -55,7 +55,8 @@ const getInlineDocumentIds = (artifact: ContentArtifactV1) => {
/** Projects the verified build artifact to the data executed in a Worker. */
export const createContentRuntimeArtifact = (
artifact: ContentArtifactV1
artifact: ContentArtifactV1,
{ includeContents = true }: { includeContents?: boolean } = {}
): ContentRuntimeArtifact => {
const inlineDocumentIds = getInlineDocumentIds(artifact);
const documentGraph =
@@ -78,7 +79,9 @@ export const createContentRuntimeArtifact = (
revision: artifact.integrity.checksum,
documents: artifact.documents,
...(documentGraph === undefined ? {} : { documentGraph }),
...(artifact.contents === undefined ? {} : { contents: artifact.contents }),
...(includeContents && artifact.contents !== undefined
? { contents: artifact.contents }
: {}),
...(artifact.assetReferences === undefined
? {}
: { assetReferences: artifact.assetReferences }),
@@ -31,6 +31,9 @@ const document: AssetFileDocument = {
};
const runtimeAssets = { "post-1": { url: "/assets/post.md" } };
const getRequestUrl = (input: RequestInfo | URL) =>
input instanceof Request ? input.url : String(input);
const createPublishedAssetResourceFetch = (
options: Omit<Parameters<typeof createPublishedRuntime>[0], "artifact"> & {
artifact: Parameters<typeof createContentRuntimeArtifact>[0];
@@ -100,6 +103,163 @@ const queryRequest = (content = false) =>
describe("published asset resource runtime", () => {
afterEach(() => vi.unstubAllGlobals());
describe.each([false, true])(
"Basic auth forwarding (graph: %s)",
(withGraph) => {
test.each([
{
url: "/assets/post.md",
authorization: "Basic dXNlcjpwYXNz",
expected: "Basic dXNlcjpwYXNz",
},
{
url: "https://site.example/assets/post.md",
authorization: "Basic dXNlcjpwYXNz",
expected: "Basic dXNlcjpwYXNz",
},
{
url: "https://cdn.example/post.md",
authorization: "Basic dXNlcjpwYXNz",
expected: null,
},
{
url: "http://site.example/assets/post.md",
authorization: "Basic dXNlcjpwYXNz",
expected: null,
},
{
url: "https://site.example:8443/assets/post.md",
authorization: "Basic dXNlcjpwYXNz",
expected: null,
},
{
url: "/assets/post.md",
authorization: "Bearer private-token",
expected: null,
},
{ url: "/assets/post.md", authorization: undefined, expected: null },
])(
"restricts credentials for $url ($authorization)",
async ({ url, authorization, expected }) => {
const { index } = await createRuntime();
const artifact = createContentRuntimeArtifact(index, {
includeContents: false,
});
const fallback = vi.fn<typeof fetch>(
async () => new Response("Post")
);
const createFetch = createGeneratedRuntime({
deploymentId: "basic-auth-test",
artifact: {
...artifact,
...(withGraph
? {
documentGraph: {
nodes: [
{
id: document._id,
revision,
contentRef: document.contentRef,
format: "markdown" as const,
},
],
edges: [],
},
}
: {}),
},
runtimeAssets: {
"post-1": { url, contentRef: document.contentRef },
},
});
const headers = new Headers({ cookie: "private=value" });
if (authorization !== undefined) {
headers.set("authorization", authorization);
}
const generatedFetch = await createFetch({
request: new Request("https://site.example/blog/post", { headers }),
fallback,
});
const response = await generatedFetch(queryRequest(true));
expect(response.status).toBe(200);
expect(await response.json()).toMatchObject({
items: [{ content: { text: "Post" } }],
});
expect(fallback).toHaveBeenCalledOnce();
const request = fallback.mock.calls[0][0] as Request;
expect(request.headers.get("authorization")).toBe(expected);
expect(request.headers.has("cookie")).toBe(false);
if (expected !== null) {
expect(request.redirect).toBe("manual");
}
}
);
}
);
test.each([
{ content: { mode: "full" }, text: "Post" },
{ content: { mode: "range", offset: 1, length: 2 }, text: "os" },
])(
"fetches unembedded files without graph nodes: $content.mode",
async ({ content, text }) => {
const { index } = await createRuntime();
const fetchDocument = vi.fn<typeof fetch>(
async () => new Response("Post")
);
const runtimeFetch = createPublishedRuntime({
baseUrl: "https://site.example/blog/post",
deploymentId: "build-http",
artifact: createContentRuntimeArtifact(index, {
includeContents: false,
}),
runtimeAssets,
automationToken: "test-automation-token",
fetchDocument,
});
const controller = new AbortController();
const request = new Request(queryRequest(), {
signal: controller.signal,
body: JSON.stringify({
query: { content, output: { mode: "all", includeMetadata: true } },
}),
});
const response = await runtimeFetch(request);
expect(response?.status).toBe(200);
expect(await response?.json()).toMatchObject({
items: [{ id: "post-1", content: { text } }],
});
expect(fetchDocument).toHaveBeenCalledOnce();
const [assetRequest, init] = fetchDocument.mock.calls[0];
expect(assetRequest).toBeInstanceOf(Request);
expect(getRequestUrl(assetRequest)).toBe(
"https://site.example/assets/post.md"
);
expect(
(assetRequest as Request).headers.get("x-webstudio-automation")
).toBe("test-automation-token");
expect(init?.signal?.aborted).toBe(false);
controller.abort();
expect(init?.signal?.aborted).toBe(true);
}
);
test("does not return an HTTP error body as file content", async () => {
const { index } = await createRuntime();
const runtimeFetch = createPublishedRuntime({
baseUrl: "https://site.example",
deploymentId: "build-http-error",
artifact: createContentRuntimeArtifact(index, { includeContents: false }),
runtimeAssets,
fetchDocument: async () => new Response("Unauthorized", { status: 401 }),
});
const response = await runtimeFetch(queryRequest(true));
expect(response?.status).toBe(400);
expect(await response?.json()).toMatchObject({
error: { code: "INVALID_REQUEST" },
});
});
test("does not open the query-result cache for ordinary generated fetches", async () => {
const { index } = await createRuntime();
const open = vi.fn();
@@ -372,10 +532,12 @@ describe("published asset resource runtime", () => {
items: [{ id: "post" }],
});
expect(fetchDocument).toHaveBeenCalledTimes(1);
expect(fetchDocument).toHaveBeenCalledWith(
new URL("https://site.example/assets/author.md"),
expect.anything()
const [documentRequest] = fetchDocument.mock.calls[0] ?? [];
expect(documentRequest).toBeInstanceOf(Request);
expect(getRequestUrl(documentRequest as Request)).toBe(
"https://site.example/assets/author.md"
);
expect((documentRequest as Request).headers.get("referer")).toBeNull();
expect(events).toEqual(
expect.arrayContaining([
{ type: "roots-selected", rootCount: 1 },
@@ -439,6 +601,11 @@ describe("published asset resource runtime", () => {
});
const generatedFetch = await createGeneratedFetch({
request: new Request("https://site.example/blog/post"),
context: {
cloudflare: {
env: { WEBSTUDIO_AUTOMATION_TOKEN: "test-automation-token" },
},
},
fallback: fetchDocument,
});
const generatedResponse = await generatedFetch(
@@ -453,6 +620,13 @@ describe("published asset resource runtime", () => {
],
});
expect(fetchDocument).toHaveBeenCalledTimes(3);
const [generatedDocumentRequest] = fetchDocument.mock.calls[2] ?? [];
expect(generatedDocumentRequest).toBeInstanceOf(Request);
expect(
(generatedDocumentRequest as Request).headers.get(
"x-webstudio-automation"
)
).toBe("test-automation-token");
expect(() =>
createPublishedAssetResourceFetch({
baseUrl: "https://site.example",
@@ -547,7 +721,9 @@ describe("published asset resource runtime", () => {
});
const runtimeArtifact = createContentRuntimeArtifact(artifact);
const fetchDocument = vi.fn(async (input: RequestInfo | URL) => {
const id = String(input).includes("second.md") ? "second" : "first";
const id = getRequestUrl(input).includes("second.md")
? "second"
: "first";
return new Response(sources[id]);
});
const runtimeFetch = createPublishedRuntime({
@@ -556,7 +732,10 @@ describe("published asset resource runtime", () => {
artifact: runtimeArtifact,
runtimeAssets: {
first: { url: "/assets/first.md", contentRef: "storage:first" },
second: { url: "/assets/second.md", contentRef: "storage:second" },
second: {
url: "/cgi/asset/second.md?format=raw",
contentRef: "storage:second",
},
},
fetchDocument,
});
@@ -596,7 +775,12 @@ describe("published asset resource runtime", () => {
totalCount: 1,
});
expect(fetchDocument).toHaveBeenCalledOnce();
expect(String(fetchDocument.mock.calls[0][0])).toContain("second.md");
const [documentRequest] = fetchDocument.mock.calls[0] ?? [];
expect(documentRequest).toBeInstanceOf(Request);
expect(getRequestUrl(documentRequest as Request)).toContain(
"/cgi/asset/second.md"
);
expect((documentRequest as Request).headers.get("referer")).toBeNull();
});
test("hydrates parallel CDN roots with one cached shared dependency", async () => {
@@ -652,7 +836,7 @@ describe("published asset resource runtime", () => {
const fetchDocument = vi.fn(
(input: RequestInfo | URL) =>
new Promise<Response>((resolve) => {
pending.set(new URL(String(input)).pathname, resolve);
pending.set(new URL(getRequestUrl(input)).pathname, resolve);
})
);
const runtimeFetch = createPublishedAssetResourceFetch({
@@ -715,7 +899,7 @@ describe("published asset resource runtime", () => {
expect(fetchDocument).toHaveBeenCalledTimes(1);
expect(
fetchDocument.mock.calls.filter(([input]) =>
String(input).includes("/assets/author.json")
getRequestUrl(input).includes("/assets/author.json")
)
).toHaveLength(1);
});
@@ -804,7 +988,7 @@ describe("published asset resource runtime", () => {
runtimeAssets,
fetchDocument: async (input) =>
new Response(
String(input).endsWith("graph-post.json")
getRequestUrl(input).endsWith("graph-post.json")
? '{"author":{"$ref":"./author.json"}}'
: `{"value":"${"a".repeat(1024 * 1024)}"}`
),
@@ -3,7 +3,11 @@ import {
type AssetResourceQueryFailure,
} from "./schema";
import { sha256Hex } from "./canonical-json";
import { encodeUtf8 } from "./byte-stream";
import {
encodeUtf8,
readableStreamToAsyncIterable,
selectByteRange,
} from "./byte-stream";
import { createRuntimeContentDatabase } from "./content-database";
import { readAssetQueryRequest } from "./request";
import type { AssetRuntimeData } from "./structured-query";
@@ -21,6 +25,31 @@ import {
import type { ContentRuntimeArtifact } from "./content-runtime-artifact";
const assetsResourceUrl = "/$resources/assets";
const automationEnvironmentVariable = "WEBSTUDIO_AUTOMATION_TOKEN";
const asRecord = (value: unknown): Record<string, unknown> | undefined =>
typeof value === "object" && value !== null
? (value as Record<string, unknown>)
: undefined;
const getAutomationToken = (context: unknown) => {
// Cloudflare exposes bindings under context.cloudflare.env. The other
// supported server adapters expose the environment directly or as env.
const contextRecord = asRecord(context);
const cloudflare = asRecord(contextRecord?.cloudflare);
const environments = [
contextRecord,
asRecord(contextRecord?.env),
asRecord(cloudflare?.env),
];
for (const environment of environments) {
const value = environment?.[automationEnvironmentVariable];
if (typeof value === "string" && value.length > 0) {
return value;
}
}
return undefined;
};
const jsonResponse = (value: unknown, status = 200) =>
new Response(JSON.stringify(value), {
@@ -80,6 +109,7 @@ export const createPublishedAssetResourceFetch = ({
runtimeAssets,
cache,
baseUrl,
automationToken,
fetchDocument = globalThis.fetch,
onDocumentGraphEvent,
}: {
@@ -88,6 +118,7 @@ export const createPublishedAssetResourceFetch = ({
runtimeAssets: Readonly<Record<string, AssetRuntimeData>>;
cache?: Pick<Cache, "match" | "put">;
baseUrl: string | URL;
automationToken?: string;
fetchDocument?: typeof fetch;
onDocumentGraphEvent?: DocumentGraphRuntimeObserver;
}) => {
@@ -99,6 +130,7 @@ export const createPublishedAssetResourceFetch = ({
runtimeAssets,
cache,
baseUrl,
automationToken,
database: createRuntimeContentDatabase({ artifact }),
fetchDocument,
documentCache,
@@ -106,10 +138,51 @@ export const createPublishedAssetResourceFetch = ({
});
};
const createPublishedDocumentRequest = ({
assetId,
baseUrl,
runtimeAssets,
automationToken,
authorization,
}: {
assetId: string;
baseUrl: string | URL;
runtimeAssets: Readonly<Record<string, AssetRuntimeData>>;
automationToken?: string;
authorization?: string;
}) => {
const asset = runtimeAssets[assetId];
if (asset === undefined) {
throw new Error(`Published document URL is unavailable for ${assetId}`);
}
const request = new Request(new URL(asset.url, baseUrl));
request.headers.delete("referer");
if (automationToken !== undefined) {
request.headers.set("x-webstudio-automation", automationToken);
}
// The asset proxy may require the same Basic login as the page. Never
// forward the visitor's credentials to a different origin or copy cookies.
if (
authorization !== undefined &&
/^Basic\s/i.test(authorization) &&
new URL(request.url).origin === new URL(baseUrl).origin
) {
request.headers.set("authorization", authorization);
// Workers can forward headers when following redirects. Asset requests
// carrying a visitor's credentials must never follow one.
// Use manual because older Workers runtimes reject redirect: "error".
// The document loader rejects the resulting non-OK redirect response.
return new Request(request, { redirect: "manual" });
}
return request;
};
const createPublishedDocumentLoader = ({
baseUrl,
runtimeAssets,
embeddedContents,
automationToken,
authorization,
fetchDocument,
cache,
onEvent,
@@ -117,19 +190,22 @@ const createPublishedDocumentLoader = ({
baseUrl: string | URL;
runtimeAssets: Readonly<Record<string, AssetRuntimeData>>;
embeddedContents?: Readonly<Record<string, string>>;
automationToken?: string;
authorization?: string;
fetchDocument: typeof fetch;
cache: DocumentSourceCache;
onEvent?: DocumentGraphRuntimeObserver;
}) => {
const httpLoader = createHttpDocumentSourceLoader({
fetch: fetchDocument,
getRequest: (node) => {
const asset = runtimeAssets[node.id];
if (asset === undefined) {
throw new Error(`Published document URL is unavailable for ${node.id}`);
}
return new URL(asset.url, baseUrl);
},
getRequest: (node) =>
createPublishedDocumentRequest({
assetId: node.id,
baseUrl,
runtimeAssets,
automationToken,
authorization,
}),
getMetadata: ({ node }) => ({
format: node.format,
revision: node.revision,
@@ -199,6 +275,8 @@ const createPublishedAssetResourceHandler = ({
runtimeAssets,
cache,
baseUrl,
automationToken,
authorization,
database,
fetchDocument,
documentCache,
@@ -209,16 +287,23 @@ const createPublishedAssetResourceHandler = ({
runtimeAssets: Readonly<Record<string, AssetRuntimeData>>;
cache?: Pick<Cache, "match" | "put">;
baseUrl: string | URL;
automationToken?: string;
authorization?: string;
database: ReturnType<typeof createRuntimeContentDatabase>;
fetchDocument: typeof fetch;
documentCache: DocumentSourceCache;
onDocumentGraphEvent?: DocumentGraphRuntimeObserver;
}) => {
const baseOrigin = new URL(baseUrl).origin;
const documentsByContentRef = new Map(
artifact.documents.map((document) => [document.contentRef, document])
);
const loadDocument = createPublishedDocumentLoader({
baseUrl,
runtimeAssets,
embeddedContents: artifact.contents,
automationToken,
authorization,
fetchDocument,
cache: documentCache,
onEvent: onDocumentGraphEvent,
@@ -272,6 +357,37 @@ const createPublishedAssetResourceHandler = ({
await database.queryWithDocumentGraph({
request: parsedRequest,
load: loadDocument,
// Plain text and full-file queries do not necessarily have graph
// nodes. Resolve those files through the same asset HTTP transport.
readContent: async (contentRef, range) => {
const document = documentsByContentRef.get(contentRef);
if (document === undefined) {
throw new Error(
`Published content reference is unavailable: ${contentRef}`
);
}
const response = await fetchDocument(
createPublishedDocumentRequest({
assetId: document._id,
baseUrl,
runtimeAssets,
automationToken,
authorization,
}),
{ signal: request.signal }
);
if (!response.ok || response.body === null) {
throw new Error(
`Document ${document._id} request returned status ${response.status} or no body`
);
}
return {
data: selectByteRange(
readableStreamToAsyncIterable(response.body),
range
),
};
},
runtimeAssets,
signal: request.signal,
onEvent: onDocumentGraphEvent,
@@ -342,9 +458,11 @@ export const createGeneratedAssetResourceRuntime = ({
const documentCache = createMemoryDocumentSourceCache();
return async ({
request,
context,
fallback,
}: {
request: Request;
context?: unknown;
fallback: typeof fetch;
}): Promise<typeof fetch> => {
const origin = new URL(request.url).origin;
@@ -354,6 +472,8 @@ export const createGeneratedAssetResourceRuntime = ({
runtimeAssets,
cache,
baseUrl: origin,
automationToken: getAutomationToken(context),
authorization: request.headers.get("authorization") ?? undefined,
database,
fetchDocument: fallback,
documentCache,
@@ -7,8 +7,11 @@ import {
import { parseDeployment } from "@webstudio-is/project-build/persistence";
import {
createId,
getPublishTarget,
publishedDeploymentDestination,
templates as templateSchema,
type Deployment,
type PublishTarget,
} from "@webstudio-is/sdk";
import type { AppContext } from "@webstudio-is/trpc-interface/index.server";
import { db } from "./db";
@@ -16,8 +19,6 @@ import { validateDomain } from "./db/validate";
type LoadedProject = Awaited<ReturnType<typeof projectApi.loadById>>;
type ProjectDomain = LoadedProject["domainsVirtual"][number];
type PublishTarget = "staging" | "production";
type SaasDeployment = Exclude<Deployment, { destination: "static" }>;
const assertMutation = (result: { success: boolean; error?: string }) => {
if (result.success === false) {
@@ -72,19 +73,6 @@ export const getPublishTargetForDomains = (
? "production"
: "staging";
const getSaasDeploymentTarget = (deployment: SaasDeployment): PublishTarget => {
if (deployment.target !== undefined) {
return deployment.target;
}
const stagingDomain = deployment.assetsDomain ?? deployment.projectDomain;
if (stagingDomain !== undefined) {
return deployment.domains.some((domain) => domain !== stagingDomain)
? "production"
: "staging";
}
return deployment.domains.length > 1 ? "production" : "staging";
};
export const getVerifiedPublishDomains = (
project: LoadedProject,
domains: string[]
@@ -136,7 +124,7 @@ export const listProjectPublishes = async (
id: build.id,
jobId: build.id,
version: build.version,
target: getSaasDeploymentTarget(deployment),
target: getPublishTarget(deployment),
domains: deployment.domains,
createdAt: build.createdAt,
},
@@ -179,7 +167,7 @@ export const getProjectPublishJob = async (
status,
target:
deployment !== undefined && deployment.destination !== "static"
? getSaasDeploymentTarget(deployment)
? getPublishTarget(deployment)
: undefined,
domains:
deployment !== undefined && deployment.destination !== "static"
@@ -193,7 +181,7 @@ export const getProjectPublishJob = async (
};
};
const createSaasDeployment = ({
const createPublishedDeployment = ({
project,
domains,
target,
@@ -202,7 +190,7 @@ const createSaasDeployment = ({
domains: string[];
target: PublishTarget;
}): Deployment => ({
destination: "saas",
destination: publishedDeploymentDestination,
target,
domains,
assetsDomain: project.domain,
@@ -226,7 +214,11 @@ export const publishProject = async (
const build = await createProductionBuild(
{
projectId: project.id,
deployment: createSaasDeployment({ project, domains, target }),
deployment: createPublishedDeployment({
project,
domains,
target,
}),
},
context
);
@@ -241,7 +233,7 @@ export const publishProject = async (
githubSha: env.GITHUB_SHA,
buildId: build.id,
branchName: env.GITHUB_REF_NAME,
destination: "saas",
destination: publishedDeploymentDestination,
logProjectName: `${project.title} - ${project.id}`,
});
+3 -3
View File
@@ -8,7 +8,7 @@ import {
getProjectOwnerId,
AuthorizationError,
} from "@webstudio-is/trpc-interface/index.server";
import { templates } from "@webstudio-is/sdk";
import { publishedDeploymentDestination, templates } from "@webstudio-is/sdk";
import { db } from "../db";
import { isDomainUsingCloudflareNameservers } from "../rdap";
import {
@@ -69,7 +69,7 @@ export const domainRouter = router({
z.object({
projectId: z.string(),
domains: z.array(z.string()),
destination: z.literal("saas"),
destination: z.literal(publishedDeploymentDestination),
}),
z.object({
projectId: z.string(),
@@ -80,7 +80,7 @@ export const domainRouter = router({
)
.mutation(async ({ input, ctx }) => {
try {
if (input.destination === "saas") {
if (input.destination === publishedDeploymentDestination) {
const project = await projectApi.loadById(input.projectId, ctx);
const domains = getVerifiedPublishDomains(project, input.domains);
await publishProject(
@@ -0,0 +1,43 @@
import { expect, test } from "vitest";
import { getPublishTarget } from "./deployment";
test.each([
{
name: "explicit staging",
deployment: {
destination: "saas" as const,
target: "staging" as const,
domains: ["project.webstudio.io"],
},
target: "staging",
},
{
name: "explicit production",
deployment: {
destination: "saas" as const,
target: "production" as const,
domains: ["project.webstudio.io"],
},
target: "production",
},
{
name: "legacy staging",
deployment: {
destination: "saas" as const,
domains: ["project.webstudio.io"],
assetsDomain: "project.webstudio.io",
},
target: "staging",
},
{
name: "legacy production",
deployment: {
destination: "saas" as const,
domains: ["project.webstudio.io", "www.example.com"],
assetsDomain: "project.webstudio.io",
},
target: "production",
},
])("resolves $name published deployment target", ({ deployment, target }) => {
expect(getPublishTarget(deployment)).toBe(target);
});
+35 -1
View File
@@ -11,6 +11,10 @@ export const templates = z.enum([
export type Templates = z.infer<typeof templates>;
// This is the persisted/API value for the hosted deployment destination.
// Keep the wire value here so the rest of the builder can use domain language.
export const publishedDeploymentDestination = "saas" as const;
export const deployment = z.union([
z.object({
destination: z.literal("static"),
@@ -20,7 +24,7 @@ export const deployment = z.union([
templates: z.array(templates),
}),
z.object({
destination: z.literal("saas").optional(),
destination: z.literal(publishedDeploymentDestination).optional(),
target: z.enum(["staging", "production"]).optional(),
domains: z.array(z.string()),
assetsDomain: z.string().optional(),
@@ -33,3 +37,33 @@ export const deployment = z.union([
]);
export type Deployment = z.infer<typeof deployment>;
export type PublishTarget = "staging" | "production";
export type PublishedDeployment = Exclude<
Deployment,
{ destination: "static" }
>;
export const isPublishedDeployment = (
deployment: Deployment | undefined
): deployment is PublishedDeployment =>
deployment?.destination === publishedDeploymentDestination;
/**
* Resolves the publish target for hosted deployments, including deployments
* written before the explicit target field was introduced.
*/
export const getPublishTarget = (
deployment: PublishedDeployment
): PublishTarget => {
if (deployment.target !== undefined) {
return deployment.target;
}
const stagingDomain = deployment.assetsDomain ?? deployment.projectDomain;
if (stagingDomain !== undefined) {
return deployment.domains.some((domain) => domain !== stagingDomain)
? "production"
: "staging";
}
return deployment.domains.length > 1 ? "production" : "staging";
};