mirror of
https://github.com/langhuihui/monibuca.git
synced 2025-12-24 13:48:04 +08:00
135 lines
99 KiB
JavaScript
135 lines
99 KiB
JavaScript
const at=Symbol.for("yaml.alias"),nt=Symbol.for("yaml.document"),V=Symbol.for("yaml.map"),Mt=Symbol.for("yaml.pair"),U=Symbol.for("yaml.scalar"),re=Symbol.for("yaml.seq"),M=Symbol.for("yaml.node.type"),H=s=>!!s&&typeof s=="object"&&s[M]===at,we=s=>!!s&&typeof s=="object"&&s[M]===nt,X=s=>!!s&&typeof s=="object"&&s[M]===V,E=s=>!!s&&typeof s=="object"&&s[M]===Mt,A=s=>!!s&&typeof s=="object"&&s[M]===U,oe=s=>!!s&&typeof s=="object"&&s[M]===re;function I(s){if(s&&typeof s=="object")switch(s[M]){case V:case re:return!0}return!1}function T(s){if(s&&typeof s=="object")switch(s[M]){case at:case V:case U:case re:return!0}return!1}const Es=s=>(A(s)||I(s))&&!!s.anchor;class ct{constructor(e){Object.defineProperty(this,M,{value:e})}clone(){const e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}}const C=Symbol("break visit"),jt=Symbol("skip children"),K=Symbol("remove node");function J(s,e){const t=Pt(e);we(s)?ee(null,s.contents,t,Object.freeze([s]))===K&&(s.contents=null):ee(null,s,t,Object.freeze([]))}J.BREAK=C;J.SKIP=jt;J.REMOVE=K;function ee(s,e,t,n){const i=Dt(s,e,t,n);if(T(i)||E(i))return Kt(s,n,i),ee(s,i,t,n);if(typeof i!="symbol"){if(I(e)){n=Object.freeze(n.concat(e));for(let r=0;r<e.items.length;++r){const o=ee(r,e.items[r],t,n);if(typeof o=="number")r=o-1;else{if(o===C)return C;o===K&&(e.items.splice(r,1),r-=1)}}}else if(E(e)){n=Object.freeze(n.concat(e));const r=ee("key",e.key,t,n);if(r===C)return C;r===K&&(e.key=null);const o=ee("value",e.value,t,n);if(o===C)return C;o===K&&(e.value=null)}}return i}async function Me(s,e){const t=Pt(e);we(s)?await te(null,s.contents,t,Object.freeze([s]))===K&&(s.contents=null):await te(null,s,t,Object.freeze([]))}Me.BREAK=C;Me.SKIP=jt;Me.REMOVE=K;async function te(s,e,t,n){const i=await Dt(s,e,t,n);if(T(i)||E(i))return Kt(s,n,i),te(s,i,t,n);if(typeof i!="symbol"){if(I(e)){n=Object.freeze(n.concat(e));for(let r=0;r<e.items.length;++r){const o=await te(r,e.items[r],t,n);if(typeof o=="number")r=o-1;else{if(o===C)return C;o===K&&(e.items.splice(r,1),r-=1)}}}else if(E(e)){n=Object.freeze(n.concat(e));const r=await te("key",e.key,t,n);if(r===C)return C;r===K&&(e.key=null);const o=await te("value",e.value,t,n);if(o===C)return C;o===K&&(e.value=null)}}return i}function Pt(s){return typeof s=="object"&&(s.Collection||s.Node||s.Value)?Object.assign({Alias:s.Node,Map:s.Node,Scalar:s.Node,Seq:s.Node},s.Value&&{Map:s.Value,Scalar:s.Value,Seq:s.Value},s.Collection&&{Map:s.Collection,Seq:s.Collection},s):s}function Dt(s,e,t,n){var i,r,o,l,a;if(typeof t=="function")return t(s,e,n);if(X(e))return(i=t.Map)==null?void 0:i.call(t,s,e,n);if(oe(e))return(r=t.Seq)==null?void 0:r.call(t,s,e,n);if(E(e))return(o=t.Pair)==null?void 0:o.call(t,s,e,n);if(A(e))return(l=t.Scalar)==null?void 0:l.call(t,s,e,n);if(H(e))return(a=t.Alias)==null?void 0:a.call(t,s,e,n)}function Kt(s,e,t){const n=e[e.length-1];if(I(n))n.items[s]=t;else if(E(n))s==="key"?n.key=t:n.value=t;else if(we(n))n.contents=t;else{const i=H(n)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}const Is={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Ts=s=>s.replace(/[!,[\]{}]/g,e=>Is[e]);class _{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},_.defaultYaml,e),this.tags=Object.assign({},_.defaultTags,t)}clone(){const e=new _(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){const e=new _(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:_.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},_.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:_.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},_.defaultTags),this.atNextDocument=!1);const n=e.trim().split(/[ \t]+/),i=n.shift();switch(i){case"%TAG":{if(n.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),n.length<2))return!1;const[r,o]=n;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,n.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;const[r]=n;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{const o=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,o),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){const o=e.slice(2,-1);return o==="!"||o==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),o)}const[,n,i]=e.match(/^(.*!)([^!]*)$/);i||t(`The ${e} tag has no suffix`);const r=this.tags[n];return r?r+decodeURIComponent(i):n==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(const[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+Ts(e.substring(n.length));return e[0]==="!"?e:`!<${e}>`}toString(e){const t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],n=Object.entries(this.tags);let i;if(e&&n.length>0&&T(e.contents)){const r={};J(e.contents,(o,l)=>{T(l)&&l.tag&&(r[l.tag]=!0)}),i=Object.keys(r)}else i=[];for(const[r,o]of n)r==="!!"&&o==="tag:yaml.org,2002:"||(!e||i.some(l=>l.startsWith(o)))&&t.push(`%TAG ${r} ${o}`);return t.join(`
|
||
`)}}_.defaultYaml={explicit:!1,version:"1.2"};_.defaultTags={"!!":"tag:yaml.org,2002:"};function qt(s){if(/[\x00-\x19\s,[\]{}]/.test(s)){const t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;throw new Error(t)}return!0}function Ft(s){const e=new Set;return J(s,{Value(t,n){n.anchor&&e.add(n.anchor)}}),e}function Ut(s,e){for(let t=1;;++t){const n=`${s}${t}`;if(!e.has(n))return n}}function Ls(s,e){const t=[],n=new Map;let i=null;return{onAnchor:r=>{t.push(r),i||(i=Ft(s));const o=Ut(e,i);return i.add(o),o},setAnchors:()=>{for(const r of t){const o=n.get(r);if(typeof o=="object"&&o.anchor&&(A(o.node)||I(o.node)))o.node.anchor=o.anchor;else{const l=new Error("Failed to resolve repeated object (this should not happen)");throw l.source=r,l}}},sourceObjects:n}}class je extends ct{constructor(e){super(at),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e){let t;return J(e,{Node:(n,i)=>{if(i===this)return J.BREAK;i.anchor===this.source&&(t=i)}}),t}toJSON(e,t){if(!t)return{source:this.source};const{anchors:n,doc:i,maxAliasCount:r}=t,o=this.resolve(i);if(!o){const a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(a)}const l=n.get(o);if(!l||l.res===void 0){const a="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(a)}if(r>=0&&(l.count+=1,l.aliasCount===0&&(l.aliasCount=Ie(i,o,n)),l.count*l.aliasCount>r)){const a="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(a)}return l.res}toString(e,t,n){const i=`*${this.source}`;if(e){if(qt(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){const r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(r)}if(e.implicitKey)return`${i} `}return i}}function Ie(s,e,t){if(H(e)){const n=e.resolve(s),i=t&&n&&t.get(n);return i?i.count*i.aliasCount:0}else if(I(e)){let n=0;for(const i of e.items){const r=Ie(s,i,t);r>n&&(n=r)}return n}else if(E(e)){const n=Ie(s,e.key,t),i=Ie(s,e.value,t);return Math.max(n,i)}return 1}function q(s,e,t){if(Array.isArray(s))return s.map((n,i)=>q(n,String(i),t));if(s&&typeof s.toJSON=="function"){if(!t||!Es(s))return s.toJSON(e,t);const n={aliasCount:0,count:1,res:void 0};t.anchors.set(s,n),t.onCreate=r=>{n.res=r,delete t.onCreate};const i=s.toJSON(e,t);return t.onCreate&&t.onCreate(i),i}return typeof s=="bigint"&&!(t!=null&&t.keep)?Number(s):s}const Rt=s=>!s||typeof s!="function"&&typeof s!="object";class N extends ct{constructor(e){super(U),this.value=e}toJSON(e,t){return t!=null&&t.keep?this.value:q(this.value,e,t)}toString(){return String(this.value)}}N.BLOCK_FOLDED="BLOCK_FOLDED";N.BLOCK_LITERAL="BLOCK_LITERAL";N.PLAIN="PLAIN";N.QUOTE_DOUBLE="QUOTE_DOUBLE";N.QUOTE_SINGLE="QUOTE_SINGLE";const $s="tag:yaml.org,2002:";function _s(s,e,t){if(e){const n=t.filter(r=>r.tag===e),i=n.find(r=>!r.format)??n[0];if(!i)throw new Error(`Tag ${e} not found`);return i}return t.find(n=>{var i;return((i=n.identify)==null?void 0:i.call(n,s))&&!n.format})}function ye(s,e,t){var h,u;if(we(s)&&(s=s.contents),T(s))return s;if(E(s)){const d=(u=(h=t.schema[V]).createNode)==null?void 0:u.call(h,t.schema,null,t);return d.items.push(s),d}(s instanceof String||s instanceof Number||s instanceof Boolean||typeof BigInt=="function"&&s instanceof BigInt)&&(s=s.valueOf());const{aliasDuplicateObjects:n,onAnchor:i,onTagObj:r,schema:o,sourceObjects:l}=t;let a;if(n&&s&&typeof s=="object"){if(a=l.get(s),a)return a.anchor||(a.anchor=i(s)),new je(a.anchor);a={anchor:null,node:null},l.set(s,a)}e!=null&&e.startsWith("!!")&&(e=$s+e.slice(2));let c=_s(s,e,o.tags);if(!c){if(s&&typeof s.toJSON=="function"&&(s=s.toJSON()),!s||typeof s!="object"){const d=new N(s);return a&&(a.node=d),d}c=s instanceof Map?o[V]:Symbol.iterator in Object(s)?o[re]:o[V]}r&&(r(c),delete t.onTagObj);const f=c!=null&&c.createNode?c.createNode(t.schema,s,t):new N(s);return e&&(f.tag=e),a&&(a.node=f),f}function _e(s,e,t){let n=t;for(let i=e.length-1;i>=0;--i){const r=e[i];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){const o=[];o[r]=n,n=o}else n=new Map([[r,n]])}return ye(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:s,sourceObjects:new Map})}const he=s=>s==null||typeof s=="object"&&!!s[Symbol.iterator]().next().done;class Pe extends ct{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(n=>T(n)||E(n)?n.clone(e):n),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(he(e))this.add(t);else{const[n,...i]=e,r=this.get(n,!0);if(I(r))r.addIn(i,t);else if(r===void 0&&this.schema)this.set(n,_e(this.schema,i,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}deleteIn(e){const[t,...n]=e;if(n.length===0)return this.delete(t);const i=this.get(t,!0);if(I(i))return i.deleteIn(n);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){const[n,...i]=e,r=this.get(n,!0);return i.length===0?!t&&A(r)?r.value:r:I(r)?r.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!E(t))return!1;const n=t.value;return n==null||e&&A(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){const[t,...n]=e;if(n.length===0)return this.has(t);const i=this.get(t,!0);return I(i)?i.hasIn(n):!1}setIn(e,t){const[n,...i]=e;if(i.length===0)this.set(n,t);else{const r=this.get(n,!0);if(I(r))r.setIn(i,t);else if(r===void 0&&this.schema)this.set(n,_e(this.schema,i,t));else throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`)}}}Pe.maxFlowStringSingleLineLength=60;const Cs=s=>s.replace(/^(?!$)(?: $)?/gm,"#");function F(s,e){return/^\n+$/.test(s)?s.substring(1):e?s.replace(/^(?! *$)/gm,e):s}const R=(s,e,t)=>s.endsWith(`
|
||
`)?F(t,e):t.includes(`
|
||
`)?`
|
||
`+F(t,e):(s.endsWith(" ")?"":" ")+t,Vt="flow",it="block",Te="quoted";function De(s,e,t="flow",{indentAtStart:n,lineWidth:i=80,minContentWidth:r=20,onFold:o,onOverflow:l}={}){if(!i||i<0)return s;const a=Math.max(1+r,1+i-e.length);if(s.length<=a)return s;const c=[],f={};let h=i-e.length;typeof n=="number"&&(n>i-Math.max(2,r)?c.push(0):h=i-n);let u,d,b=!1,p=-1,m=-1,y=-1;t===it&&(p=Ot(s,p),p!==-1&&(h=p+a));for(let k;k=s[p+=1];){if(t===Te&&k==="\\"){switch(m=p,s[p+1]){case"x":p+=3;break;case"u":p+=5;break;case"U":p+=9;break;default:p+=1}y=p}if(k===`
|
||
`)t===it&&(p=Ot(s,p)),h=p+a,u=void 0;else{if(k===" "&&d&&d!==" "&&d!==`
|
||
`&&d!==" "){const g=s[p+1];g&&g!==" "&&g!==`
|
||
`&&g!==" "&&(u=p)}if(p>=h)if(u)c.push(u),h=u+a,u=void 0;else if(t===Te){for(;d===" "||d===" ";)d=k,k=s[p+=1],b=!0;const g=p>y+1?p-2:m-1;if(f[g])return s;c.push(g),f[g]=!0,h=g+a,u=void 0}else b=!0}d=k}if(b&&l&&l(),c.length===0)return s;o&&o();let S=s.slice(0,c[0]);for(let k=0;k<c.length;++k){const g=c[k],O=c[k+1]||s.length;g===0?S=`
|
||
${e}${s.slice(0,O)}`:(t===Te&&f[g]&&(S+=`${s[g]}\\`),S+=`
|
||
${e}${s.slice(g+1,O)}`)}return S}function Ot(s,e){let t=s[e+1];for(;t===" "||t===" ";){do t=s[e+=1];while(t&&t!==`
|
||
`);t=s[e+1]}return e}const Ke=s=>({indentAtStart:s.indentAtStart,lineWidth:s.options.lineWidth,minContentWidth:s.options.minContentWidth}),qe=s=>/^(%|---|\.\.\.)/m.test(s);function vs(s,e,t){if(!e||e<0)return!1;const n=e-t,i=s.length;if(i<=n)return!1;for(let r=0,o=0;r<i;++r)if(s[r]===`
|
||
`){if(r-o>n)return!0;if(o=r+1,i-o<=n)return!1}return!0}function pe(s,e){const t=JSON.stringify(s);if(e.options.doubleQuotedAsJSON)return t;const{implicitKey:n}=e,i=e.options.doubleQuotedMinMultiLineLength,r=e.indent||(qe(s)?" ":"");let o="",l=0;for(let a=0,c=t[a];c;c=t[++a])if(c===" "&&t[a+1]==="\\"&&t[a+2]==="n"&&(o+=t.slice(l,a)+"\\ ",a+=1,l=a,c="\\"),c==="\\")switch(t[a+1]){case"u":{o+=t.slice(l,a);const f=t.substr(a+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=t.substr(a,6)}a+=5,l=a+1}break;case"n":if(n||t[a+2]==='"'||t.length<i)a+=1;else{for(o+=t.slice(l,a)+`
|
||
|
||
`;t[a+2]==="\\"&&t[a+3]==="n"&&t[a+4]!=='"';)o+=`
|
||
`,a+=2;o+=r,t[a+2]===" "&&(o+="\\"),a+=1,l=a+1}break;default:a+=1}return o=l?o+t.slice(l):t,n?o:De(o,r,Te,Ke(e))}function rt(s,e){if(e.options.singleQuote===!1||e.implicitKey&&s.includes(`
|
||
`)||/[ \t]\n|\n[ \t]/.test(s))return pe(s,e);const t=e.indent||(qe(s)?" ":""),n="'"+s.replace(/'/g,"''").replace(/\n+/g,`$&
|
||
${t}`)+"'";return e.implicitKey?n:De(n,t,Vt,Ke(e))}function me(s,e){const{singleQuote:t}=e.options;let n;if(t===!1)n=pe;else{const i=s.includes('"'),r=s.includes("'");i&&!r?n=rt:r&&!i?n=pe:n=t?rt:pe}return n(s,e)}function Le({comment:s,type:e,value:t},n,i,r){const{blockQuote:o,commentString:l,lineWidth:a}=n.options;if(!o||/\n[\t ]+$/.test(t)||/^\s*$/.test(t))return me(t,n);const c=n.indent||(n.forceBlockIndent||qe(t)?" ":""),f=o==="literal"?!0:o==="folded"||e===N.BLOCK_FOLDED?!1:e===N.BLOCK_LITERAL?!0:!vs(t,a,c.length);if(!t)return f?`|
|
||
`:`>
|
||
`;let h,u;for(u=t.length;u>0;--u){const w=t[u-1];if(w!==`
|
||
`&&w!==" "&&w!==" ")break}let d=t.substring(u);const b=d.indexOf(`
|
||
`);b===-1?h="-":t===d||b!==d.length-1?(h="+",r&&r()):h="",d&&(t=t.slice(0,-d.length),d[d.length-1]===`
|
||
`&&(d=d.slice(0,-1)),d=d.replace(/\n+(?!\n|$)/g,`$&${c}`));let p=!1,m,y=-1;for(m=0;m<t.length;++m){const w=t[m];if(w===" ")p=!0;else if(w===`
|
||
`)y=m;else break}let S=t.substring(0,y<m?y+1:m);S&&(t=t.substring(S.length),S=S.replace(/\n+/g,`$&${c}`));let g=(f?"|":">")+(p?c?"2":"1":"")+h;if(s&&(g+=" "+l(s.replace(/ ?[\r\n]+/g," ")),i&&i()),f)return t=t.replace(/\n+/g,`$&${c}`),`${g}
|
||
${c}${S}${t}${d}`;t=t.replace(/\n+/g,`
|
||
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`);const O=De(`${S}${t}${d}`,c,it,Ke(n));return`${g}
|
||
${c}${O}`}function Bs(s,e,t,n){const{type:i,value:r}=s,{actualString:o,implicitKey:l,indent:a,inFlow:c}=e;if(l&&/[\n[\]{},]/.test(r)||c&&/[[\]{},]/.test(r))return me(r,e);if(!r||/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return l||c||!r.includes(`
|
||
`)?me(r,e):Le(s,e,t,n);if(!l&&!c&&i!==N.PLAIN&&r.includes(`
|
||
`))return Le(s,e,t,n);if(a===""&&qe(r))return e.forceBlockIndent=!0,Le(s,e,t,n);const f=r.replace(/\n+/g,`$&
|
||
${a}`);if(o){const h=b=>{var p;return b.default&&b.tag!=="tag:yaml.org,2002:str"&&((p=b.test)==null?void 0:p.test(f))},{compat:u,tags:d}=e.doc.schema;if(d.some(h)||u!=null&&u.some(h))return me(r,e)}return l?f:De(f,a,Vt,Ke(e))}function Se(s,e,t,n){const{implicitKey:i,inFlow:r}=e,o=typeof s.value=="string"?s:Object.assign({},s,{value:String(s.value)});let{type:l}=s;l!==N.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(l=N.QUOTE_DOUBLE);const a=f=>{switch(f){case N.BLOCK_FOLDED:case N.BLOCK_LITERAL:return i||r?me(o.value,e):Le(o,e,t,n);case N.QUOTE_DOUBLE:return pe(o.value,e);case N.QUOTE_SINGLE:return rt(o.value,e);case N.PLAIN:return Bs(o,e,t,n);default:return null}};let c=a(l);if(c===null){const{defaultKeyType:f,defaultStringType:h}=e.options,u=i&&f||h;if(c=a(u),c===null)throw new Error(`Unsupported default string type ${u}`)}return c}function Jt(s,e){const t=Object.assign({blockQuote:!0,commentString:Cs,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},s.schema.toStringOptions,e);let n;switch(t.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:s,indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:n,options:t}}function Ms(s,e){var i;if(e.tag){const r=s.filter(o=>o.tag===e.tag);if(r.length>0)return r.find(o=>o.format===e.format)??r[0]}let t,n;if(A(e)){n=e.value;const r=s.filter(o=>{var l;return(l=o.identify)==null?void 0:l.call(o,n)});t=r.find(o=>o.format===e.format)??r.find(o=>!o.format)}else n=e,t=s.find(r=>r.nodeClass&&n instanceof r.nodeClass);if(!t){const r=((i=n==null?void 0:n.constructor)==null?void 0:i.name)??typeof n;throw new Error(`Tag not resolved for ${r} value`)}return t}function js(s,e,{anchors:t,doc:n}){if(!n.directives)return"";const i=[],r=(A(s)||I(s))&&s.anchor;r&&qt(r)&&(t.add(r),i.push(`&${r}`));const o=s.tag?s.tag:e.default?null:e.tag;return o&&i.push(n.directives.tagString(o)),i.join(" ")}function Q(s,e,t,n){var a;if(E(s))return s.toString(e,t,n);if(H(s)){if(e.doc.directives)return s.toString(e);if((a=e.resolvedAliases)!=null&&a.has(s))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(s):e.resolvedAliases=new Set([s]),s=s.resolve(e.doc)}let i;const r=T(s)?s:e.doc.createNode(s,{onTagObj:c=>i=c});i||(i=Ms(e.doc.schema.tags,r));const o=js(r,i,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);const l=typeof i.stringify=="function"?i.stringify(r,e,t,n):A(r)?Se(r,e,t,n):r.toString(e,t,n);return o?A(r)||l[0]==="{"||l[0]==="["?`${o} ${l}`:`${o}
|
||
${e.indent}${l}`:l}function Ps({key:s,value:e},t,n,i){const{allNullValues:r,doc:o,indent:l,indentStep:a,options:{commentString:c,indentSeq:f,simpleKeys:h}}=t;let u=T(s)&&s.comment||null;if(h){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(I(s)){const w="With simple keys, collection cannot be used as a key value";throw new Error(w)}}let d=!h&&(!s||u&&e==null&&!t.inFlow||I(s)||(A(s)?s.type===N.BLOCK_FOLDED||s.type===N.BLOCK_LITERAL:typeof s=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!d&&(h||!r),indent:l+a});let b=!1,p=!1,m=Q(s,t,()=>b=!0,()=>p=!0);if(!d&&!t.inFlow&&m.length>1024){if(h)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");d=!0}if(t.inFlow){if(r||e==null)return b&&n&&n(),m===""?"?":d?`? ${m}`:m}else if(r&&!h||e==null&&d)return m=`? ${m}`,u&&!b?m+=R(m,t.indent,c(u)):p&&i&&i(),m;b&&(u=null),d?(u&&(m+=R(m,t.indent,c(u))),m=`? ${m}
|
||
${l}:`):(m=`${m}:`,u&&(m+=R(m,t.indent,c(u))));let y="",S=null;if(T(e)){if(e.spaceBefore&&(y=`
|
||
`),e.commentBefore){const w=c(e.commentBefore);y+=`
|
||
${F(w,t.indent)}`}S=e.comment}else e&&typeof e=="object"&&(e=o.createNode(e));t.implicitKey=!1,!d&&!u&&A(e)&&(t.indentAtStart=m.length+1),p=!1,!f&&a.length>=2&&!t.inFlow&&!d&&oe(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substr(2));let k=!1;const g=Q(e,t,()=>k=!0,()=>p=!0);let O=" ";return y||u?g===""&&!t.inFlow?O=y===`
|
||
`?`
|
||
|
||
`:y:O=`${y}
|
||
${t.indent}`:!d&&I(e)?(!(g[0]==="["||g[0]==="{")||g.includes(`
|
||
`))&&(O=`
|
||
${t.indent}`):(g===""||g[0]===`
|
||
`)&&(O=""),m+=O+g,t.inFlow?k&&n&&n():S&&!k?m+=R(m,t.indent,c(S)):p&&i&&i(),m}function Yt(s,e){(s==="debug"||s==="warn")&&(typeof process<"u"&&process.emitWarning?process.emitWarning(e):console.warn(e))}const At="<<";function Gt(s,e,{key:t,value:n}){if(s!=null&&s.doc.schema.merge&&Ds(t))if(n=H(n)?n.resolve(s.doc):n,oe(n))for(const i of n.items)Xe(s,e,i);else if(Array.isArray(n))for(const i of n)Xe(s,e,i);else Xe(s,e,n);else{const i=q(t,"",s);if(e instanceof Map)e.set(i,q(n,i,s));else if(e instanceof Set)e.add(i);else{const r=Ks(t,i,s),o=q(n,r,s);r in e?Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[r]=o}}return e}const Ds=s=>s===At||A(s)&&s.value===At&&(!s.type||s.type===N.PLAIN);function Xe(s,e,t){const n=s&&H(t)?t.resolve(s.doc):t;if(!X(n))throw new Error("Merge sources must be maps or map aliases");const i=n.toJSON(null,s,Map);for(const[r,o]of i)e instanceof Map?e.has(r)||e.set(r,o):e instanceof Set?e.add(r):Object.prototype.hasOwnProperty.call(e,r)||Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function Ks(s,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(T(s)&&t&&t.doc){const n=Jt(t.doc,{});n.anchors=new Set;for(const r of t.anchors.keys())n.anchors.add(r.anchor);n.inFlow=!0,n.inStringifyKey=!0;const i=s.toString(n);if(!t.mapKeyWarned){let r=JSON.stringify(i);r.length>40&&(r=r.substring(0,36)+'..."'),Yt(t.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`),t.mapKeyWarned=!0}return i}return JSON.stringify(e)}function ft(s,e,t){const n=ye(s,void 0,t),i=ye(e,void 0,t);return new $(n,i)}class ${constructor(e,t=null){Object.defineProperty(this,M,{value:Mt}),this.key=e,this.value=t}clone(e){let{key:t,value:n}=this;return T(t)&&(t=t.clone(e)),T(n)&&(n=n.clone(e)),new $(t,n)}toJSON(e,t){const n=t!=null&&t.mapAsMap?new Map:{};return Gt(t,n,this)}toString(e,t,n){return e!=null&&e.doc?Ps(this,e,t,n):JSON.stringify(this)}}function Qt(s,e,t){return(e.inFlow??s.flow?Fs:qs)(s,e,t)}function qs({comment:s,items:e},t,{blockItemPrefix:n,flowChars:i,itemIndent:r,onChompKeep:o,onComment:l}){const{indent:a,options:{commentString:c}}=t,f=Object.assign({},t,{indent:r,type:null});let h=!1;const u=[];for(let b=0;b<e.length;++b){const p=e[b];let m=null;if(T(p))!h&&p.spaceBefore&&u.push(""),Ce(t,u,p.commentBefore,h),p.comment&&(m=p.comment);else if(E(p)){const S=T(p.key)?p.key:null;S&&(!h&&S.spaceBefore&&u.push(""),Ce(t,u,S.commentBefore,h))}h=!1;let y=Q(p,f,()=>m=null,()=>h=!0);m&&(y+=R(y,r,c(m))),h&&m&&(h=!1),u.push(n+y)}let d;if(u.length===0)d=i.start+i.end;else{d=u[0];for(let b=1;b<u.length;++b){const p=u[b];d+=p?`
|
||
${a}${p}`:`
|
||
`}}return s?(d+=`
|
||
`+F(c(s),a),l&&l()):h&&o&&o(),d}function Fs({comment:s,items:e},t,{flowChars:n,itemIndent:i,onComment:r}){const{indent:o,indentStep:l,options:{commentString:a}}=t;i+=l;const c=Object.assign({},t,{indent:i,inFlow:!0,type:null});let f=!1,h=0;const u=[];for(let m=0;m<e.length;++m){const y=e[m];let S=null;if(T(y))y.spaceBefore&&u.push(""),Ce(t,u,y.commentBefore,!1),y.comment&&(S=y.comment);else if(E(y)){const g=T(y.key)?y.key:null;g&&(g.spaceBefore&&u.push(""),Ce(t,u,g.commentBefore,!1),g.comment&&(f=!0));const O=T(y.value)?y.value:null;O?(O.comment&&(S=O.comment),O.commentBefore&&(f=!0)):y.value==null&&g&&g.comment&&(S=g.comment)}S&&(f=!0);let k=Q(y,c,()=>S=null);m<e.length-1&&(k+=","),S&&(k+=R(k,i,a(S))),!f&&(u.length>h||k.includes(`
|
||
`))&&(f=!0),u.push(k),h=u.length}let d;const{start:b,end:p}=n;if(u.length===0)d=b+p;else if(f||(f=u.reduce((y,S)=>y+S.length+2,2)>Pe.maxFlowStringSingleLineLength),f){d=b;for(const m of u)d+=m?`
|
||
${l}${o}${m}`:`
|
||
`;d+=`
|
||
${o}${p}`}else d=`${b} ${u.join(" ")} ${p}`;return s&&(d+=R(d,a(s),o),r&&r()),d}function Ce({indent:s,options:{commentString:e}},t,n,i){if(n&&i&&(n=n.replace(/^\n+/,"")),n){const r=F(e(n),s);t.push(r.trimStart())}}function Y(s,e){const t=A(e)?e.value:e;for(const n of s)if(E(n)&&(n.key===e||n.key===t||A(n.key)&&n.key.value===t))return n}class B extends Pe{constructor(e){super(V,e),this.items=[]}static get tagName(){return"tag:yaml.org,2002:map"}add(e,t){var o;let n;E(e)?n=e:!e||typeof e!="object"||!("key"in e)?n=new $(e,e==null?void 0:e.value):n=new $(e.key,e.value);const i=Y(this.items,n.key),r=(o=this.schema)==null?void 0:o.sortMapEntries;if(i){if(!t)throw new Error(`Key ${n.key} already set`);A(i.value)&&Rt(n.value)?i.value.value=n.value:i.value=n.value}else if(r){const l=this.items.findIndex(a=>r(n,a)<0);l===-1?this.items.push(n):this.items.splice(l,0,n)}else this.items.push(n)}delete(e){const t=Y(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){const n=Y(this.items,e),i=n==null?void 0:n.value;return(!t&&A(i)?i.value:i)??void 0}has(e){return!!Y(this.items,e)}set(e,t){this.add(new $(e,t),!0)}toJSON(e,t,n){const i=n?new n:t!=null&&t.mapAsMap?new Map:{};t!=null&&t.onCreate&&t.onCreate(i);for(const r of this.items)Gt(t,i,r);return i}toString(e,t,n){if(!e)return JSON.stringify(this);for(const i of this.items)if(!E(i))throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Qt(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:n,onComment:t})}}function Us(s,e,t){const{keepUndefined:n,replacer:i}=t,r=new B(s),o=(l,a)=>{if(typeof i=="function")a=i.call(e,l,a);else if(Array.isArray(i)&&!i.includes(l))return;(a!==void 0||n)&&r.items.push(ft(l,a,t))};if(e instanceof Map)for(const[l,a]of e)o(l,a);else if(e&&typeof e=="object")for(const l of Object.keys(e))o(l,e[l]);return typeof s.sortMapEntries=="function"&&r.items.sort(s.sortMapEntries),r}const le={collection:"map",createNode:Us,default:!0,nodeClass:B,tag:"tag:yaml.org,2002:map",resolve(s,e){return X(s)||e("Expected a mapping for this tag"),s}};class z extends Pe{constructor(e){super(re,e),this.items=[]}static get tagName(){return"tag:yaml.org,2002:seq"}add(e){this.items.push(e)}delete(e){const t=Oe(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){const n=Oe(e);if(typeof n!="number")return;const i=this.items[n];return!t&&A(i)?i.value:i}has(e){const t=Oe(e);return typeof t=="number"&&t<this.items.length}set(e,t){const n=Oe(e);if(typeof n!="number")throw new Error(`Expected a valid index, not ${e}.`);const i=this.items[n];A(i)&&Rt(t)?i.value=t:this.items[n]=t}toJSON(e,t){const n=[];t!=null&&t.onCreate&&t.onCreate(n);let i=0;for(const r of this.items)n.push(q(r,String(i++),t));return n}toString(e,t,n){return e?Qt(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:n,onComment:t}):JSON.stringify(this)}}function Oe(s){let e=A(s)?s.value:s;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function Rs(s,e,t){const{replacer:n}=t,i=new z(s);if(e&&Symbol.iterator in Object(e)){let r=0;for(let o of e){if(typeof n=="function"){const l=e instanceof Set?o:String(r++);o=n.call(e,l,o)}i.items.push(ye(o,void 0,t))}}return i}const ae={collection:"seq",createNode:Rs,default:!0,nodeClass:z,tag:"tag:yaml.org,2002:seq",resolve(s,e){return oe(s)||e("Expected a sequence for this tag"),s}},Fe={identify:s=>typeof s=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:s=>s,stringify(s,e,t,n){return e=Object.assign({actualString:!0},e),Se(s,e,t,n)}},Ue={identify:s=>s==null,createNode:()=>new N(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new N(null),stringify:({source:s},e)=>typeof s=="string"&&Ue.test.test(s)?s:e.options.nullStr},ut={identify:s=>typeof s=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:s=>new N(s[0]==="t"||s[0]==="T"),stringify({source:s,value:e},t){if(s&&ut.test.test(s)){const n=s[0]==="t"||s[0]==="T";if(e===n)return s}return e?t.options.trueStr:t.options.falseStr}};function P({format:s,minFractionDigits:e,tag:t,value:n}){if(typeof n=="bigint")return String(n);const i=typeof n=="number"?n:Number(n);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let r=JSON.stringify(n);if(!s&&e&&(!t||t==="tag:yaml.org,2002:float")&&/^\d/.test(r)){let o=r.indexOf(".");o<0&&(o=r.length,r+=".");let l=e-(r.length-o-1);for(;l-- >0;)r+="0"}return r}const Wt={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF|nan|NaN|NAN))$/,resolve:s=>s.slice(-3).toLowerCase()==="nan"?NaN:s[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:P},Ht={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:s=>parseFloat(s),stringify(s){const e=Number(s.value);return isFinite(e)?e.toExponential():P(s)}},Xt={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(s){const e=new N(parseFloat(s)),t=s.indexOf(".");return t!==-1&&s[s.length-1]==="0"&&(e.minFractionDigits=s.length-t-1),e},stringify:P},Re=s=>typeof s=="bigint"||Number.isInteger(s),ht=(s,e,t,{intAsBigInt:n})=>n?BigInt(s):parseInt(s.substring(e),t);function zt(s,e,t){const{value:n}=s;return Re(n)&&n>=0?t+n.toString(e):P(s)}const Zt={identify:s=>Re(s)&&s>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(s,e,t)=>ht(s,2,8,t),stringify:s=>zt(s,8,"0o")},xt={identify:Re,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(s,e,t)=>ht(s,0,10,t),stringify:P},es={identify:s=>Re(s)&&s>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(s,e,t)=>ht(s,2,16,t),stringify:s=>zt(s,16,"0x")},Vs=[le,ae,Fe,Ue,ut,Zt,xt,es,Wt,Ht,Xt];function Et(s){return typeof s=="bigint"||Number.isInteger(s)}const Ae=({value:s})=>JSON.stringify(s),Js=[{identify:s=>typeof s=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:s=>s,stringify:Ae},{identify:s=>s==null,createNode:()=>new N(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Ae},{identify:s=>typeof s=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true|false$/,resolve:s=>s==="true",stringify:Ae},{identify:Et,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(s,e,{intAsBigInt:t})=>t?BigInt(s):parseInt(s,10),stringify:({value:s})=>Et(s)?s.toString():JSON.stringify(s)},{identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:s=>parseFloat(s),stringify:Ae}],Ys={default:!0,tag:"",test:/^/,resolve(s,e){return e(`Unresolved plain scalar ${JSON.stringify(s)}`),s}},Gs=[le,ae].concat(Js,Ys),dt={identify:s=>s instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(s,e){if(typeof Buffer=="function")return Buffer.from(s,"base64");if(typeof atob=="function"){const t=atob(s.replace(/[\n\r]/g,"")),n=new Uint8Array(t.length);for(let i=0;i<t.length;++i)n[i]=t.charCodeAt(i);return n}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),s},stringify({comment:s,type:e,value:t},n,i,r){const o=t;let l;if(typeof Buffer=="function")l=o instanceof Buffer?o.toString("base64"):Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let a="";for(let c=0;c<o.length;++c)a+=String.fromCharCode(o[c]);l=btoa(a)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e||(e=N.BLOCK_LITERAL),e!==N.QUOTE_DOUBLE){const a=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),c=Math.ceil(l.length/a),f=new Array(c);for(let h=0,u=0;h<c;++h,u+=a)f[h]=l.substr(u,a);l=f.join(e===N.BLOCK_LITERAL?`
|
||
`:" ")}return Se({comment:s,type:e,value:l},n,i,r)}};function ts(s,e){if(oe(s))for(let t=0;t<s.items.length;++t){let n=s.items[t];if(!E(n)){if(X(n)){n.items.length>1&&e("Each pair must have its own sequence indicator");const i=n.items[0]||new $(new N(null));if(n.commentBefore&&(i.key.commentBefore=i.key.commentBefore?`${n.commentBefore}
|
||
${i.key.commentBefore}`:n.commentBefore),n.comment){const r=i.value??i.key;r.comment=r.comment?`${n.comment}
|
||
${r.comment}`:n.comment}n=i}s.items[t]=E(n)?n:new $(n)}}else e("Expected a sequence for this tag");return s}function ss(s,e,t){const{replacer:n}=t,i=new z(s);i.tag="tag:yaml.org,2002:pairs";let r=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof n=="function"&&(o=n.call(e,String(r++),o));let l,a;if(Array.isArray(o))if(o.length===2)l=o[0],a=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){const c=Object.keys(o);if(c.length===1)l=c[0],a=o[l];else throw new TypeError(`Expected { key: value } tuple: ${o}`)}else l=o;i.items.push(ft(l,a,t))}return i}const pt={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:ts,createNode:ss};class se extends z{constructor(){super(),this.add=B.prototype.add.bind(this),this.delete=B.prototype.delete.bind(this),this.get=B.prototype.get.bind(this),this.has=B.prototype.has.bind(this),this.set=B.prototype.set.bind(this),this.tag=se.tag}toJSON(e,t){if(!t)return super.toJSON(e);const n=new Map;t!=null&&t.onCreate&&t.onCreate(n);for(const i of this.items){let r,o;if(E(i)?(r=q(i.key,"",t),o=q(i.value,r,t)):r=q(i,"",t),n.has(r))throw new Error("Ordered maps must not include duplicate keys");n.set(r,o)}return n}}se.tag="tag:yaml.org,2002:omap";const mt={collection:"seq",identify:s=>s instanceof Map,nodeClass:se,default:!1,tag:"tag:yaml.org,2002:omap",resolve(s,e){const t=ts(s,e),n=[];for(const{key:i}of t.items)A(i)&&(n.includes(i.value)?e(`Ordered maps must not include duplicate keys: ${i.value}`):n.push(i.value));return Object.assign(new se,t)},createNode(s,e,t){const n=ss(s,e,t),i=new se;return i.items=n.items,i}};function ns({value:s,source:e},t){return e&&(s?is:rs).test.test(e)?e:s?t.options.trueStr:t.options.falseStr}const is={identify:s=>s===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new N(!0),stringify:ns},rs={identify:s=>s===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i,resolve:()=>new N(!1),stringify:ns},Qs={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?\.(?:inf|Inf|INF|nan|NaN|NAN)$/,resolve:s=>s.slice(-3).toLowerCase()==="nan"?NaN:s[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:P},Ws={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:s=>parseFloat(s.replace(/_/g,"")),stringify(s){const e=Number(s.value);return isFinite(e)?e.toExponential():P(s)}},Hs={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(s){const e=new N(parseFloat(s.replace(/_/g,""))),t=s.indexOf(".");if(t!==-1){const n=s.substring(t+1).replace(/_/g,"");n[n.length-1]==="0"&&(e.minFractionDigits=n.length)}return e},stringify:P},ke=s=>typeof s=="bigint"||Number.isInteger(s);function Ve(s,e,t,{intAsBigInt:n}){const i=s[0];if((i==="-"||i==="+")&&(e+=1),s=s.substring(e).replace(/_/g,""),n){switch(t){case 2:s=`0b${s}`;break;case 8:s=`0o${s}`;break;case 16:s=`0x${s}`;break}const o=BigInt(s);return i==="-"?BigInt(-1)*o:o}const r=parseInt(s,t);return i==="-"?-1*r:r}function yt(s,e,t){const{value:n}=s;if(ke(n)){const i=n.toString(e);return n<0?"-"+t+i.substr(1):t+i}return P(s)}const Xs={identify:ke,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(s,e,t)=>Ve(s,2,2,t),stringify:s=>yt(s,2,"0b")},zs={identify:ke,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(s,e,t)=>Ve(s,1,8,t),stringify:s=>yt(s,8,"0")},Zs={identify:ke,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(s,e,t)=>Ve(s,0,10,t),stringify:P},xs={identify:ke,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(s,e,t)=>Ve(s,2,16,t),stringify:s=>yt(s,16,"0x")};class ne extends B{constructor(e){super(e),this.tag=ne.tag}add(e){let t;E(e)?t=e:typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new $(e.key,null):t=new $(e,null),Y(this.items,t.key)||this.items.push(t)}get(e,t){const n=Y(this.items,e);return!t&&E(n)?A(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);const n=Y(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new $(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw new Error("Set items must all have null values")}}ne.tag="tag:yaml.org,2002:set";const gt={collection:"map",identify:s=>s instanceof Set,nodeClass:ne,default:!1,tag:"tag:yaml.org,2002:set",resolve(s,e){if(X(s)){if(s.hasAllNullValues(!0))return Object.assign(new ne,s);e("Set items must all have null values")}else e("Expected a mapping for this tag");return s},createNode(s,e,t){const{replacer:n}=t,i=new ne(s);if(e&&Symbol.iterator in Object(e))for(let r of e)typeof n=="function"&&(r=n.call(e,r,r)),i.items.push(ft(r,null,t));return i}};function bt(s,e){const t=s[0],n=t==="-"||t==="+"?s.substring(1):s,i=o=>e?BigInt(o):Number(o),r=n.replace(/_/g,"").split(":").reduce((o,l)=>o*i(60)+i(l),i(0));return t==="-"?i(-1)*r:r}function os(s){let{value:e}=s,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return P(s);let n="";e<0&&(n="-",e*=t(-1));const i=t(60),r=[e%i];return e<60?r.unshift(0):(e=(e-r[0])/i,r.unshift(e%i),e>=60&&(e=(e-r[0])/i,r.unshift(e))),n+r.map(o=>o<10?"0"+String(o):String(o)).join(":").replace(/000000\d*$/,"")}const ls={identify:s=>typeof s=="bigint"||Number.isInteger(s),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(s,e,{intAsBigInt:t})=>bt(s,t),stringify:os},as={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:s=>bt(s,!1),stringify:os},Je={identify:s=>s instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(s){const e=s.match(Je.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,t,n,i,r,o,l]=e.map(Number),a=e[7]?Number((e[7]+"00").substr(1,3)):0;let c=Date.UTC(t,n-1,i,r||0,o||0,l||0,a);const f=e[8];if(f&&f!=="Z"){let h=bt(f,!1);Math.abs(h)<30&&(h*=60),c-=6e4*h}return new Date(c)},stringify:({value:s})=>s.toISOString().replace(/((T00:00)?:00)?\.000Z$/,"")},It=[le,ae,Fe,Ue,is,rs,Xs,zs,Zs,xs,Qs,Ws,Hs,dt,mt,pt,gt,ls,as,Je],Tt=new Map([["core",Vs],["failsafe",[le,ae,Fe]],["json",Gs],["yaml11",It],["yaml-1.1",It]]),Lt={binary:dt,bool:ut,float:Xt,floatExp:Ht,floatNaN:Wt,floatTime:as,int:xt,intHex:es,intOct:Zt,intTime:ls,map:le,null:Ue,omap:mt,pairs:pt,seq:ae,set:gt,timestamp:Je},en={"tag:yaml.org,2002:binary":dt,"tag:yaml.org,2002:omap":mt,"tag:yaml.org,2002:pairs":pt,"tag:yaml.org,2002:set":gt,"tag:yaml.org,2002:timestamp":Je};function ze(s,e){let t=Tt.get(e);if(!t)if(Array.isArray(s))t=[];else{const n=Array.from(Tt.keys()).filter(i=>i!=="yaml11").map(i=>JSON.stringify(i)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${n} or define customTags array`)}if(Array.isArray(s))for(const n of s)t=t.concat(n);else typeof s=="function"&&(t=s(t.slice()));return t.map(n=>{if(typeof n!="string")return n;const i=Lt[n];if(i)return i;const r=Object.keys(Lt).map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown custom tag "${n}"; use one of ${r}`)})}const tn=(s,e)=>s.key<e.key?-1:s.key>e.key?1:0;class Ye{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:i,schema:r,sortMapEntries:o,toStringDefaults:l}){this.compat=Array.isArray(e)?ze(e,"compat"):e?ze(null,e):null,this.merge=!!n,this.name=typeof r=="string"&&r||"core",this.knownTags=i?en:{},this.tags=ze(t,this.name),this.toStringOptions=l??null,Object.defineProperty(this,V,{value:le}),Object.defineProperty(this,U,{value:Fe}),Object.defineProperty(this,re,{value:ae}),this.sortMapEntries=typeof o=="function"?o:o===!0?tn:null}clone(){const e=Object.create(Ye.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}function sn(s,e){var a;const t=[];let n=e.directives===!0;if(e.directives!==!1&&s.directives){const c=s.directives.toString(s);c?(t.push(c),n=!0):s.directives.docStart&&(n=!0)}n&&t.push("---");const i=Jt(s,e),{commentString:r}=i.options;if(s.commentBefore){t.length!==1&&t.unshift("");const c=r(s.commentBefore);t.unshift(F(c,""))}let o=!1,l=null;if(s.contents){if(T(s.contents)){if(s.contents.spaceBefore&&n&&t.push(""),s.contents.commentBefore){const h=r(s.contents.commentBefore);t.push(F(h,""))}i.forceBlockIndent=!!s.comment,l=s.contents.comment}const c=l?void 0:()=>o=!0;let f=Q(s.contents,i,()=>l=null,c);l&&(f+=R(f,"",r(l))),(f[0]==="|"||f[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${f}`:t.push(f)}else t.push(Q(s.contents,i));if((a=s.directives)!=null&&a.docEnd)if(s.comment){const c=r(s.comment);c.includes(`
|
||
`)?(t.push("..."),t.push(F(c,""))):t.push(`... ${c}`)}else t.push("...");else{let c=s.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||l)&&t[t.length-1]!==""&&t.push(""),t.push(F(r(c),"")))}return t.join(`
|
||
`)+`
|
||
`}function de(s,e,t,n){if(n&&typeof n=="object")if(Array.isArray(n))for(let i=0,r=n.length;i<r;++i){const o=n[i],l=de(s,n,String(i),o);l===void 0?delete n[i]:l!==o&&(n[i]=l)}else if(n instanceof Map)for(const i of Array.from(n.keys())){const r=n.get(i),o=de(s,n,i,r);o===void 0?n.delete(i):o!==r&&n.set(i,o)}else if(n instanceof Set)for(const i of Array.from(n)){const r=de(s,n,i,i);r===void 0?n.delete(i):r!==i&&(n.delete(i),n.add(r))}else for(const[i,r]of Object.entries(n)){const o=de(s,n,i,r);o===void 0?delete n[i]:o!==r&&(n[i]=o)}return s.call(e,t,n)}class ce{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,M,{value:nt});let i=null;typeof t=="function"||Array.isArray(t)?i=t:n===void 0&&t&&(n=t,t=void 0);const r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,uniqueKeys:!0,version:"1.2"},n);this.options=r;let{version:o}=r;n!=null&&n._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new _({version:o}),this.setSchema(o,n),e===void 0?this.contents=null:this.contents=this.createNode(e,i,n)}clone(){const e=Object.create(ce.prototype,{[M]:{value:nt}});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=T(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Z(this.contents)&&this.contents.add(e)}addIn(e,t){Z(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){const n=Ft(this);e.anchor=!t||n.has(t)?Ut(t||"a",n):t}return new je(e.anchor)}createNode(e,t,n){let i;if(typeof t=="function")e=t.call({"":e},"",e),i=t;else if(Array.isArray(t)){const m=S=>typeof S=="number"||S instanceof String||S instanceof Number,y=t.filter(m).map(String);y.length>0&&(t=t.concat(y)),i=t}else n===void 0&&t&&(n=t,t=void 0);const{aliasDuplicateObjects:r,anchorPrefix:o,flow:l,keepUndefined:a,onTagObj:c,tag:f}=n??{},{onAnchor:h,setAnchors:u,sourceObjects:d}=Ls(this,o||"a"),b={aliasDuplicateObjects:r??!0,keepUndefined:a??!1,onAnchor:h,onTagObj:c,replacer:i,schema:this.schema,sourceObjects:d},p=ye(e,f,b);return l&&I(p)&&(p.flow=!0),u(),p}createPair(e,t,n={}){const i=this.createNode(e,null,n),r=this.createNode(t,null,n);return new $(i,r)}delete(e){return Z(this.contents)?this.contents.delete(e):!1}deleteIn(e){return he(e)?this.contents==null?!1:(this.contents=null,!0):Z(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return I(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return he(e)?!t&&A(this.contents)?this.contents.value:this.contents:I(this.contents)?this.contents.getIn(e,t):void 0}has(e){return I(this.contents)?this.contents.has(e):!1}hasIn(e){return he(e)?this.contents!==void 0:I(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=_e(this.schema,[e],t):Z(this.contents)&&this.contents.set(e,t)}setIn(e,t){he(e)?this.contents=t:this.contents==null?this.contents=_e(this.schema,Array.from(e),t):Z(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let n;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new _({version:"1.1"}),n={merge:!0,resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new _({version:e}),n={merge:!1,resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,n=null;break;default:{const i=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new Ye(Object.assign(n,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:i,onAnchor:r,reviver:o}={}){const l={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100,stringify:Q},a=q(this.contents,t??"",l);if(typeof r=="function")for(const{count:c,res:f}of l.anchors.values())r(f,c);return typeof o=="function"?de(o,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}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)){const t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return sn(this,e)}}function Z(s){if(I(s))return!0;throw new Error("Expected a YAML collection as document contents")}class wt extends Error{constructor(e,t,n,i){super(),this.name=e,this.code=n,this.message=i,this.pos=t}}class G extends wt{constructor(e,t,n){super("YAMLParseError",e,t,n)}}class cs extends wt{constructor(e,t,n){super("YAMLWarning",e,t,n)}}const ve=(s,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(l=>e.linePos(l));const{line:n,col:i}=t.linePos[0];t.message+=` at line ${n}, column ${i}`;let r=i-1,o=s.substring(e.lineStarts[n-1],e.lineStarts[n]).replace(/[\n\r]+$/,"");if(r>=60&&o.length>80){const l=Math.min(r-39,o.length-79);o="…"+o.substring(l),r-=l-1}if(o.length>80&&(o=o.substring(0,79)+"…"),n>1&&/^ *$/.test(o.substring(0,r))){let l=s.substring(e.lineStarts[n-2],e.lineStarts[n-1]);l.length>80&&(l=l.substring(0,79)+`…
|
||
`),o=l+o}if(/[^ ]/.test(o)){let l=1;const a=t.linePos[1];a&&a.line===n&&a.col>i&&(l=Math.min(a.col-i,80-r));const c=" ".repeat(r)+"^".repeat(l);t.message+=`:
|
||
|
||
${o}
|
||
${c}
|
||
`}};function ie(s,{flow:e,indicator:t,next:n,offset:i,onError:r,startOnNewline:o}){let l=!1,a=o,c=o,f="",h="",u=!1,d=!1,b=!1,p=null,m=null,y=null,S=null,k=null;for(const w of s)switch(b&&(w.type!=="space"&&w.type!=="newline"&&w.type!=="comma"&&r(w.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),b=!1),w.type){case"space":!e&&a&&t!=="doc-start"&&w.source[0]===" "&&r(w,"TAB_AS_INDENT","Tabs are not allowed as indentation"),c=!0;break;case"comment":{c||r(w,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const L=w.source.substring(1)||" ";f?f+=h+L:f=L,h="",a=!1;break}case"newline":a?f?f+=w.source:l=!0:h+=w.source,a=!0,u=!0,(p||m)&&(d=!0),c=!0;break;case"anchor":p&&r(w,"MULTIPLE_ANCHORS","A node can have at most one anchor"),w.source.endsWith(":")&&r(w.offset+w.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),p=w,k===null&&(k=w.offset),a=!1,c=!1,b=!0;break;case"tag":{m&&r(w,"MULTIPLE_TAGS","A node can have at most one tag"),m=w,k===null&&(k=w.offset),a=!1,c=!1,b=!0;break}case t:(p||m)&&r(w,"BAD_PROP_ORDER",`Anchors and tags must be after the ${w.source} indicator`),S&&r(w,"UNEXPECTED_TOKEN",`Unexpected ${w.source} in ${e??"collection"}`),S=w,a=!1,c=!1;break;case"comma":if(e){y&&r(w,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),y=w,a=!1,c=!1;break}default:r(w,"UNEXPECTED_TOKEN",`Unexpected ${w.type} token`),a=!1,c=!1}const g=s[s.length-1],O=g?g.offset+g.source.length:i;return b&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!=="")&&r(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),{comma:y,found:S,spaceBefore:l,comment:f,hasNewline:u,hasNewlineAfterProp:d,anchor:p,tag:m,end:O,start:k??O}}function ge(s){if(!s)return null;switch(s.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(s.source.includes(`
|
||
`))return!0;if(s.end){for(const e of s.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(const e of s.items){for(const t of e.start)if(t.type==="newline")return!0;if(e.sep){for(const t of e.sep)if(t.type==="newline")return!0}if(ge(e.key)||ge(e.value))return!0}return!1;default:return!0}}function ot(s,e,t){if((e==null?void 0:e.type)==="flow-collection"){const n=e.end[0];n.indent===s&&(n.source==="]"||n.source==="}")&&ge(e)&&t(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function fs(s,e,t){const{uniqueKeys:n}=s.options;if(n===!1)return!1;const i=typeof n=="function"?n:(r,o)=>r===o||A(r)&&A(o)&&r.value===o.value&&!(r.value==="<<"&&s.schema.merge);return e.some(r=>i(r.key,t))}const $t="All mapping items must start at the same column";function nn({composeNode:s,composeEmptyNode:e},t,n,i){var l;const r=new B(t.schema);t.atRoot&&(t.atRoot=!1);let o=n.offset;for(const a of n.items){const{start:c,key:f,sep:h,value:u}=a,d=ie(c,{indicator:"explicit-key-ind",next:f??(h==null?void 0:h[0]),offset:o,onError:i,startOnNewline:!0}),b=!d.found;if(b){if(f&&(f.type==="block-seq"?i(o,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==n.indent&&i(o,"BAD_INDENT",$t)),!d.anchor&&!d.tag&&!h){d.comment&&(r.comment?r.comment+=`
|
||
`+d.comment:r.comment=d.comment);continue}(d.hasNewlineAfterProp||ge(f))&&i(f??c[c.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else((l=d.found)==null?void 0:l.indent)!==n.indent&&i(o,"BAD_INDENT",$t);const p=d.end,m=f?s(t,f,d,i):e(t,p,c,null,d,i);t.schema.compat&&ot(n.indent,f,i),fs(t,r.items,m)&&i(p,"DUPLICATE_KEY","Map keys must be unique");const y=ie(h??[],{indicator:"map-value-ind",next:u,offset:m.range[2],onError:i,startOnNewline:!f||f.type==="block-scalar"});if(o=y.end,y.found){b&&((u==null?void 0:u.type)==="block-map"&&!y.hasNewline&&i(o,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&d.start<y.found.offset-1024&&i(m.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));const S=u?s(t,u,y,i):e(t,o,h,null,y,i);t.schema.compat&&ot(n.indent,u,i),o=S.range[2];const k=new $(m,S);t.options.keepSourceTokens&&(k.srcToken=a),r.items.push(k)}else{b&&i(m.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),y.comment&&(m.comment?m.comment+=`
|
||
`+y.comment:m.comment=y.comment);const S=new $(m);t.options.keepSourceTokens&&(S.srcToken=a),r.items.push(S)}}return r.range=[n.offset,o,o],r}function rn({composeNode:s,composeEmptyNode:e},t,n,i){const r=new z(t.schema);t.atRoot&&(t.atRoot=!1);let o=n.offset;for(const{start:l,value:a}of n.items){const c=ie(l,{indicator:"seq-item-ind",next:a,offset:o,onError:i,startOnNewline:!0});if(o=c.end,!c.found)if(c.anchor||c.tag||a)a&&a.type==="block-seq"?i(o,"BAD_INDENT","All sequence items must start at the same column"):i(o,"MISSING_CHAR","Sequence item without - indicator");else{c.comment&&(r.comment=c.comment);continue}const f=a?s(t,a,c,i):e(t,o,l,null,c,i);t.schema.compat&&ot(n.indent,a,i),o=f.range[2],r.items.push(f)}return r.range=[n.offset,o,o],r}function Ne(s,e,t,n){let i="";if(s){let r=!1,o="";for(const l of s){const{source:a,type:c}=l;switch(c){case"space":r=!0;break;case"comment":{t&&!r&&n(l,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const f=a.substring(1)||" ";i?i+=o+f:i=f,o="";break}case"newline":i&&(o+=a),r=!0;break;default:n(l,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=a.length}}return{comment:i,offset:e}}const Ze="Block collections are not allowed within flow collections",xe=s=>s&&(s.type==="block-map"||s.type==="block-seq");function on({composeNode:s,composeEmptyNode:e},t,n,i){const r=n.start.source==="{",o=r?"flow map":"flow sequence",l=r?new B(t.schema):new z(t.schema);l.flow=!0;const a=t.atRoot;a&&(t.atRoot=!1);let c=n.offset+n.start.source.length;for(let b=0;b<n.items.length;++b){const p=n.items[b],{start:m,key:y,sep:S,value:k}=p,g=ie(m,{flow:o,indicator:"explicit-key-ind",next:y??(S==null?void 0:S[0]),offset:c,onError:i,startOnNewline:!1});if(!g.found){if(!g.anchor&&!g.tag&&!S&&!k){b===0&&g.comma?i(g.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${o}`):b<n.items.length-1&&i(g.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${o}`),g.comment&&(l.comment?l.comment+=`
|
||
`+g.comment:l.comment=g.comment),c=g.end;continue}!r&&t.options.strict&&ge(y)&&i(y,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(b===0)g.comma&&i(g.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${o}`);else if(g.comma||i(g.start,"MISSING_CHAR",`Missing , between ${o} items`),g.comment){let O="";e:for(const w of m)switch(w.type){case"comma":case"space":break;case"comment":O=w.source.substring(1);break e;default:break e}if(O){let w=l.items[l.items.length-1];E(w)&&(w=w.value??w.key),w.comment?w.comment+=`
|
||
`+O:w.comment=O,g.comment=g.comment.substring(O.length+1)}}if(!r&&!S&&!g.found){const O=k?s(t,k,g,i):e(t,g.end,S,null,g,i);l.items.push(O),c=O.range[2],xe(k)&&i(O.range,"BLOCK_IN_FLOW",Ze)}else{const O=g.end,w=y?s(t,y,g,i):e(t,O,m,null,g,i);xe(y)&&i(w.range,"BLOCK_IN_FLOW",Ze);const L=ie(S??[],{flow:o,indicator:"map-value-ind",next:k,offset:w.range[2],onError:i,startOnNewline:!1});if(L.found){if(!r&&!g.found&&t.options.strict){if(S)for(const D of S){if(D===L.found)break;if(D.type==="newline"){i(D,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}g.start<L.found.offset-1024&&i(L.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else k&&("source"in k&&k.source&&k.source[0]===":"?i(k,"MISSING_CHAR",`Missing space after : in ${o}`):i(L.start,"MISSING_CHAR",`Missing , or : between ${o} items`));const fe=k?s(t,k,L,i):L.found?e(t,L.end,S,null,L,i):null;fe?xe(k)&&i(fe.range,"BLOCK_IN_FLOW",Ze):L.comment&&(w.comment?w.comment+=`
|
||
`+L.comment:w.comment=L.comment);const He=new $(w,fe);if(t.options.keepSourceTokens&&(He.srcToken=p),r){const D=l;fs(t,D.items,w)&&i(O,"DUPLICATE_KEY","Map keys must be unique"),D.items.push(He)}else{const D=new B(t.schema);D.flow=!0,D.items.push(He),l.items.push(D)}c=fe?fe.range[2]:L.end}}const f=r?"}":"]",[h,...u]=n.end;let d=c;if(h&&h.source===f)d=h.offset+h.source.length;else{const b=o[0].toUpperCase()+o.substring(1),p=a?`${b} must end with a ${f}`:`${b} in block collection must be sufficiently indented and end with a ${f}`;i(c,a?"MISSING_CHAR":"BAD_INDENT",p),h&&h.source.length!==1&&u.unshift(h)}if(u.length>0){const b=Ne(u,d,t.options.strict,i);b.comment&&(l.comment?l.comment+=`
|
||
`+b.comment:l.comment=b.comment),l.range=[n.offset,d,b.offset]}else l.range=[n.offset,d,d];return l}function ln(s,e,t,n,i){let r;switch(t.type){case"block-map":{r=nn(s,e,t,i);break}case"block-seq":{r=rn(s,e,t,i);break}case"flow-collection":{r=on(s,e,t,i);break}}if(!n)return r;const o=e.directives.tagName(n.source,u=>i(n,"TAG_RESOLVE_FAILED",u));if(!o)return r;const l=r.constructor;if(o==="!"||o===l.tagName)return r.tag=l.tagName,r;const a=X(r)?"map":"seq";let c=e.schema.tags.find(u=>u.collection===a&&u.tag===o);if(!c){const u=e.schema.knownTags[o];if(u&&u.collection===a)e.schema.tags.push(Object.assign({},u,{default:!1})),c=u;else return i(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),r.tag=o,r}const f=c.resolve(r,u=>i(n,"TAG_RESOLVE_FAILED",u),e.options),h=T(f)?f:new N(f);return h.range=r.range,h.tag=o,c!=null&&c.format&&(h.format=c.format),h}function us(s,e,t){const n=s.offset,i=an(s,e,t);if(!i)return{value:"",type:null,comment:"",range:[n,n,n]};const r=i.mode===">"?N.BLOCK_FOLDED:N.BLOCK_LITERAL,o=s.source?cn(s.source):[];let l=o.length;for(let p=o.length-1;p>=0;--p){const m=o[p][1];if(m===""||m==="\r")l=p;else break}if(l===0){const p=i.chomp==="+"&&o.length>0?`
|
||
`.repeat(Math.max(1,o.length-1)):"";let m=n+i.length;return s.source&&(m+=s.source.length),{value:p,type:r,comment:i.comment,range:[n,m,m]}}let a=s.indent+i.indent,c=s.offset+i.length,f=0;for(let p=0;p<l;++p){const[m,y]=o[p];if(y===""||y==="\r")i.indent===0&&m.length>a&&(a=m.length);else{if(m.length<a){const S="Block scalars with more-indented leading empty lines must use an explicit indentation indicator";t(c+m.length,"MISSING_CHAR",S)}i.indent===0&&(a=m.length),f=p;break}c+=m.length+y.length+1}for(let p=o.length-1;p>=l;--p)o[p][0].length>a&&(l=p+1);let h="",u="",d=!1;for(let p=0;p<f;++p)h+=o[p][0].slice(a)+`
|
||
`;for(let p=f;p<l;++p){let[m,y]=o[p];c+=m.length+y.length+1;const S=y[y.length-1]==="\r";if(S&&(y=y.slice(0,-1)),y&&m.length<a){const g=`Block scalar lines must not be less indented than their ${i.indent?"explicit indentation indicator":"first line"}`;t(c-y.length-(S?2:1),"BAD_INDENT",g),m=""}r===N.BLOCK_LITERAL?(h+=u+m.slice(a)+y,u=`
|
||
`):m.length>a||y[0]===" "?(u===" "?u=`
|
||
`:!d&&u===`
|
||
`&&(u=`
|
||
|
||
`),h+=u+m.slice(a)+y,u=`
|
||
`,d=!0):y===""?u===`
|
||
`?h+=`
|
||
`:u=`
|
||
`:(h+=u+y,u=" ",d=!1)}switch(i.chomp){case"-":break;case"+":for(let p=l;p<o.length;++p)h+=`
|
||
`+o[p][0].slice(a);h[h.length-1]!==`
|
||
`&&(h+=`
|
||
`);break;default:h+=`
|
||
`}const b=n+i.length+s.source.length;return{value:h,type:r,comment:i.comment,range:[n,b,b]}}function an({offset:s,props:e},t,n){if(e[0].type!=="block-scalar-header")return n(e[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:i}=e[0],r=i[0];let o=0,l="",a=-1;for(let u=1;u<i.length;++u){const d=i[u];if(!l&&(d==="-"||d==="+"))l=d;else{const b=Number(d);!o&&b?o=b:a===-1&&(a=s+u)}}a!==-1&&n(a,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let c=!1,f="",h=i.length;for(let u=1;u<e.length;++u){const d=e[u];switch(d.type){case"space":c=!0;case"newline":h+=d.source.length;break;case"comment":t&&!c&&n(d,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),h+=d.source.length,f=d.source.substring(1);break;case"error":n(d,"UNEXPECTED_TOKEN",d.message),h+=d.source.length;break;default:{const b=`Unexpected token in block scalar header: ${d.type}`;n(d,"UNEXPECTED_TOKEN",b);const p=d.source;p&&typeof p=="string"&&(h+=p.length)}}}return{mode:r,indent:o,chomp:l,comment:f,length:h}}function cn(s){const e=s.split(/\n( *)/),t=e[0],n=t.match(/^( *)/),r=[n!=null&&n[1]?[n[1],t.slice(n[1].length)]:["",t]];for(let o=1;o<e.length;o+=2)r.push([e[o],e[o+1]]);return r}function hs(s,e,t){const{offset:n,type:i,source:r,end:o}=s;let l,a;const c=(u,d,b)=>t(n+u,d,b);switch(i){case"scalar":l=N.PLAIN,a=fn(r,c);break;case"single-quoted-scalar":l=N.QUOTE_SINGLE,a=un(r,c);break;case"double-quoted-scalar":l=N.QUOTE_DOUBLE,a=hn(r,c);break;default:return t(s,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${i}`),{value:"",type:null,comment:"",range:[n,n+r.length,n+r.length]}}const f=n+r.length,h=Ne(o,f,e,t);return{value:a,type:l,comment:h.comment,range:[n,f,h.offset]}}function fn(s,e){let t="";switch(s[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${s[0]}`;break}case"@":case"`":{t=`reserved character ${s[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),ds(s)}function un(s,e){return(s[s.length-1]!=="'"||s.length===1)&&e(s.length,"MISSING_CHAR","Missing closing 'quote"),ds(s.slice(1,-1)).replace(/''/g,"'")}function ds(s){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
||
`,"sy"),t=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
||
`,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,t=/[ \t]*(.*?)[ \t]*\r?\n/sy}let n=e.exec(s);if(!n)return s;let i=n[1],r=" ",o=e.lastIndex;for(t.lastIndex=o;n=t.exec(s);)n[1]===""?r===`
|
||
`?i+=r:r=`
|
||
`:(i+=r+n[1],r=" "),o=t.lastIndex;const l=/[ \t]*(.*)/sy;return l.lastIndex=o,n=l.exec(s),i+r+((n==null?void 0:n[1])??"")}function hn(s,e){let t="";for(let n=1;n<s.length-1;++n){const i=s[n];if(!(i==="\r"&&s[n+1]===`
|
||
`))if(i===`
|
||
`){const{fold:r,offset:o}=dn(s,n);t+=r,n=o}else if(i==="\\"){let r=s[++n];const o=pn[r];if(o)t+=o;else if(r===`
|
||
`)for(r=s[n+1];r===" "||r===" ";)r=s[++n+1];else if(r==="\r"&&s[n+1]===`
|
||
`)for(r=s[++n+1];r===" "||r===" ";)r=s[++n+1];else if(r==="x"||r==="u"||r==="U"){const l={x:2,u:4,U:8}[r];t+=mn(s,n+1,l,e),n+=l}else{const l=s.substr(n-1,2);e(n-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${l}`),t+=l}}else if(i===" "||i===" "){const r=n;let o=s[n+1];for(;o===" "||o===" ";)o=s[++n+1];o!==`
|
||
`&&!(o==="\r"&&s[n+2]===`
|
||
`)&&(t+=n>r?s.slice(r,n+1):i)}else t+=i}return(s[s.length-1]!=='"'||s.length===1)&&e(s.length,"MISSING_CHAR",'Missing closing "quote'),t}function dn(s,e){let t="",n=s[e+1];for(;(n===" "||n===" "||n===`
|
||
`||n==="\r")&&!(n==="\r"&&s[e+2]!==`
|
||
`);)n===`
|
||
`&&(t+=`
|
||
`),e+=1,n=s[e+1];return t||(t=" "),{fold:t,offset:e}}const pn={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
||
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function mn(s,e,t,n){const i=s.substr(e,t),o=i.length===t&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(o)){const l=s.substr(e-2,t+2);return n(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${l}`),l}return String.fromCodePoint(o)}function ps(s,e,t,n){const{value:i,type:r,comment:o,range:l}=e.type==="block-scalar"?us(e,s.options.strict,n):hs(e,s.options.strict,n),a=t?s.directives.tagName(t.source,h=>n(t,"TAG_RESOLVE_FAILED",h)):null,c=t&&a?yn(s.schema,i,a,t,n):e.type==="scalar"?gn(s,i,e,n):s.schema[U];let f;try{const h=c.resolve(i,u=>n(t??e,"TAG_RESOLVE_FAILED",u),s.options);f=A(h)?h:new N(h)}catch(h){const u=h instanceof Error?h.message:String(h);n(t??e,"TAG_RESOLVE_FAILED",u),f=new N(i)}return f.range=l,f.source=i,r&&(f.type=r),a&&(f.tag=a),c.format&&(f.format=c.format),o&&(f.comment=o),f}function yn(s,e,t,n,i){var l;if(t==="!")return s[U];const r=[];for(const a of s.tags)if(!a.collection&&a.tag===t)if(a.default&&a.test)r.push(a);else return a;for(const a of r)if((l=a.test)!=null&&l.test(e))return a;const o=s.knownTags[t];return o&&!o.collection?(s.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),s[U])}function gn({directives:s,schema:e},t,n,i){const r=e.tags.find(o=>{var l;return o.default&&((l=o.test)==null?void 0:l.test(t))})||e[U];if(e.compat){const o=e.compat.find(l=>{var a;return l.default&&((a=l.test)==null?void 0:a.test(t))})??e[U];if(r.tag!==o.tag){const l=s.tagString(r.tag),a=s.tagString(o.tag),c=`Value may be parsed as either ${l} or ${a}`;i(n,"TAG_RESOLVE_FAILED",c,!0)}}return r}function bn(s,e,t){if(e){t===null&&(t=e.length);for(let n=t-1;n>=0;--n){let i=e[n];switch(i.type){case"space":case"comment":case"newline":s-=i.source.length;continue}for(i=e[++n];(i==null?void 0:i.type)==="space";)s+=i.source.length,i=e[++n];break}}return s}const wn={composeNode:ms,composeEmptyNode:St};function ms(s,e,t,n){const{spaceBefore:i,comment:r,anchor:o,tag:l}=t;let a,c=!0;switch(e.type){case"alias":a=Sn(s,e,n),(o||l)&&n(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":a=ps(s,e,l,n),o&&(a.anchor=o.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":a=ln(wn,s,e,l,n),o&&(a.anchor=o.source.substring(1));break;default:{const f=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;n(e,"UNEXPECTED_TOKEN",f),a=St(s,e.offset,void 0,null,t,n),c=!1}}return o&&a.anchor===""&&n(o,"BAD_ALIAS","Anchor cannot be an empty string"),i&&(a.spaceBefore=!0),r&&(e.type==="scalar"&&e.source===""?a.comment=r:a.commentBefore=r),s.options.keepSourceTokens&&c&&(a.srcToken=e),a}function St(s,e,t,n,{spaceBefore:i,comment:r,anchor:o,tag:l},a){const c={type:"scalar",offset:bn(e,t,n),indent:-1,source:""},f=ps(s,c,l,a);return o&&(f.anchor=o.source.substring(1),f.anchor===""&&a(o,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(f.spaceBefore=!0),r&&(f.comment=r),f}function Sn({options:s},{offset:e,source:t,end:n},i){const r=new je(t.substring(1));r.source===""&&i(e,"BAD_ALIAS","Alias cannot be an empty string"),r.source.endsWith(":")&&i(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const o=e+t.length,l=Ne(n,o,s.strict,i);return r.range=[e,o,l.offset],l.comment&&(r.comment=l.comment),r}function kn(s,e,{offset:t,start:n,value:i,end:r},o){const l=Object.assign({_directives:e},s),a=new ce(void 0,l),c={atRoot:!0,directives:a.directives,options:a.options,schema:a.schema},f=ie(n,{indicator:"doc-start",next:i??(r==null?void 0:r[0]),offset:t,onError:o,startOnNewline:!0});f.found&&(a.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),a.contents=i?ms(c,i,f,o):St(c,f.end,n,null,f,o);const h=a.contents.range[2],u=Ne(r,h,!1,o);return u.comment&&(a.comment=u.comment),a.range=[t,h,u.offset],a}function ue(s){if(typeof s=="number")return[s,s+1];if(Array.isArray(s))return s.length===2?s:[s[0],s[1]];const{offset:e,source:t}=s;return[e,e+(typeof t=="string"?t.length:1)]}function _t(s){var i;let e="",t=!1,n=!1;for(let r=0;r<s.length;++r){const o=s[r];switch(o[0]){case"#":e+=(e===""?"":n?`
|
||
|
||
`:`
|
||
`)+(o.substring(1)||" "),t=!0,n=!1;break;case"%":((i=s[r+1])==null?void 0:i[0])!=="#"&&(r+=1),t=!1;break;default:t||(n=!0),t=!1}}return{comment:e,afterEmptyLine:n}}class kt{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,n,i,r)=>{const o=ue(t);r?this.warnings.push(new cs(o,n,i)):this.errors.push(new G(o,n,i))},this.directives=new _({version:e.version||"1.2"}),this.options=e}decorate(e,t){const{comment:n,afterEmptyLine:i}=_t(this.prelude);if(n){const r=e.contents;if(t)e.comment=e.comment?`${e.comment}
|
||
${n}`:n;else if(i||e.directives.docStart||!r)e.commentBefore=n;else if(I(r)&&!r.flow&&r.items.length>0){let o=r.items[0];E(o)&&(o=o.key);const l=o.commentBefore;o.commentBefore=l?`${n}
|
||
${l}`:n}else{const o=r.commentBefore;r.commentBefore=o?`${n}
|
||
${o}`:n}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:_t(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(const i of e)yield*this.next(i);yield*this.end(t,n)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(t,n,i)=>{const r=ue(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",n,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{const t=kn(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{const t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new G(ue(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case"doc-end":{if(!this.doc){const n="Unexpected doc-end without preceding document";this.errors.push(new G(ue(e),"UNEXPECTED_TOKEN",n));break}this.doc.directives.docEnd=!0;const t=Ne(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){const n=this.doc.comment;this.doc.comment=n?`${n}
|
||
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new G(ue(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){const n=Object.assign({_directives:this.directives},this.options),i=new ce(void 0,n);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),i.range=[0,t,t],this.decorate(i,!1),yield i}}}function Nn(s,e=!0,t){if(s){const n=(i,r,o)=>{const l=typeof i=="number"?i:Array.isArray(i)?i[0]:i.offset;if(t)t(l,r,o);else throw new G([l,l+1],r,o)};switch(s.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return hs(s,e,n);case"block-scalar":return us(s,e,n)}}return null}function On(s,e){const{implicitKey:t=!1,indent:n,inFlow:i=!1,offset:r=-1,type:o="PLAIN"}=e,l=Se({type:o,value:s},{implicitKey:t,indent:n>0?" ".repeat(n):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}}),a=e.end??[{type:"newline",offset:-1,indent:n,source:`
|
||
`}];switch(l[0]){case"|":case">":{const c=l.indexOf(`
|
||
`),f=l.substring(0,c),h=l.substring(c+1)+`
|
||
`,u=[{type:"block-scalar-header",offset:r,indent:n,source:f}];return ys(u,a)||u.push({type:"newline",offset:-1,indent:n,source:`
|
||
`}),{type:"block-scalar",offset:r,indent:n,props:u,source:h}}case'"':return{type:"double-quoted-scalar",offset:r,indent:n,source:l,end:a};case"'":return{type:"single-quoted-scalar",offset:r,indent:n,source:l,end:a};default:return{type:"scalar",offset:r,indent:n,source:l,end:a}}}function An(s,e,t={}){let{afterKey:n=!1,implicitKey:i=!1,inFlow:r=!1,type:o}=t,l="indent"in s?s.indent:null;if(n&&typeof l=="number"&&(l+=2),!o)switch(s.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{const c=s.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}const a=Se({type:o,value:e},{implicitKey:i||l===null,indent:l!==null&&l>0?" ".repeat(l):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}});switch(a[0]){case"|":case">":En(s,a);break;case'"':et(s,a,"double-quoted-scalar");break;case"'":et(s,a,"single-quoted-scalar");break;default:et(s,a,"scalar")}}function En(s,e){const t=e.indexOf(`
|
||
`),n=e.substring(0,t),i=e.substring(t+1)+`
|
||
`;if(s.type==="block-scalar"){const r=s.props[0];if(r.type!=="block-scalar-header")throw new Error("Invalid block scalar header");r.source=n,s.source=i}else{const{offset:r}=s,o="indent"in s?s.indent:-1,l=[{type:"block-scalar-header",offset:r,indent:o,source:n}];ys(l,"end"in s?s.end:void 0)||l.push({type:"newline",offset:-1,indent:o,source:`
|
||
`});for(const a of Object.keys(s))a!=="type"&&a!=="offset"&&delete s[a];Object.assign(s,{type:"block-scalar",indent:o,props:l,source:i})}}function ys(s,e){if(e)for(const t of e)switch(t.type){case"space":case"comment":s.push(t);break;case"newline":return s.push(t),!0}return!1}function et(s,e,t){switch(s.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":s.type=t,s.source=e;break;case"block-scalar":{const n=s.props.slice(1);let i=e.length;s.props[0].type==="block-scalar-header"&&(i-=s.props[0].source.length);for(const r of n)r.offset+=i;delete s.props,Object.assign(s,{type:t,source:e,end:n});break}case"block-map":case"block-seq":{const i={type:"newline",offset:s.offset+e.length,indent:s.indent,source:`
|
||
`};delete s.items,Object.assign(s,{type:t,source:e,end:[i]});break}default:{const n="indent"in s?s.indent:-1,i="end"in s&&Array.isArray(s.end)?s.end.filter(r=>r.type==="space"||r.type==="comment"||r.type==="newline"):[];for(const r of Object.keys(s))r!=="type"&&r!=="offset"&&delete s[r];Object.assign(s,{type:t,indent:n,source:e,end:i})}}}const In=s=>"type"in s?Be(s):$e(s);function Be(s){switch(s.type){case"block-scalar":{let e="";for(const t of s.props)e+=Be(t);return e+s.source}case"block-map":case"block-seq":{let e="";for(const t of s.items)e+=$e(t);return e}case"flow-collection":{let e=s.start.source;for(const t of s.items)e+=$e(t);for(const t of s.end)e+=t.source;return e}case"document":{let e=$e(s);if(s.end)for(const t of s.end)e+=t.source;return e}default:{let e=s.source;if("end"in s&&s.end)for(const t of s.end)e+=t.source;return e}}}function $e({start:s,key:e,sep:t,value:n}){let i="";for(const r of s)i+=r.source;if(e&&(i+=Be(e)),t)for(const r of t)i+=r.source;return n&&(i+=Be(n)),i}const lt=Symbol("break visit"),Tn=Symbol("skip children"),gs=Symbol("remove item");function W(s,e){"type"in s&&s.type==="document"&&(s={start:s.start,value:s.value}),bs(Object.freeze([]),s,e)}W.BREAK=lt;W.SKIP=Tn;W.REMOVE=gs;W.itemAtPath=(s,e)=>{let t=s;for(const[n,i]of e){const r=t==null?void 0:t[n];if(r&&"items"in r)t=r.items[i];else return}return t};W.parentCollection=(s,e)=>{const t=W.itemAtPath(s,e.slice(0,-1)),n=e[e.length-1][0],i=t==null?void 0:t[n];if(i&&"items"in i)return i;throw new Error("Parent collection not found")};function bs(s,e,t){let n=t(e,s);if(typeof n=="symbol")return n;for(const i of["key","value"]){const r=e[i];if(r&&"items"in r){for(let o=0;o<r.items.length;++o){const l=bs(Object.freeze(s.concat([[i,o]])),r.items[o],t);if(typeof l=="number")o=l-1;else{if(l===lt)return lt;l===gs&&(r.items.splice(o,1),o-=1)}}typeof n=="function"&&i==="key"&&(n=n(e,s))}}return typeof n=="function"?n(e,s):n}const Ge="\uFEFF",Qe="",We="",be="",Ln=s=>!!s&&"items"in s,$n=s=>!!s&&(s.type==="scalar"||s.type==="single-quoted-scalar"||s.type==="double-quoted-scalar"||s.type==="block-scalar");function _n(s){switch(s){case Ge:return"<BOM>";case Qe:return"<DOC>";case We:return"<FLOW_END>";case be:return"<SCALAR>";default:return JSON.stringify(s)}}function ws(s){switch(s){case Ge:return"byte-order-mark";case Qe:return"doc-mode";case We:return"flow-error-end";case be: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(s[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}const Cn=Object.freeze(Object.defineProperty({__proto__:null,BOM:Ge,DOCUMENT:Qe,FLOW_END:We,SCALAR:be,createScalarToken:On,isCollection:Ln,isScalar:$n,prettyToken:_n,resolveAsScalar:Nn,setScalarValue:An,stringify:In,tokenType:ws,visit:W},Symbol.toStringTag,{value:"Module"}));function v(s){switch(s){case void 0:case" ":case`
|
||
`:case"\r":case" ":return!0;default:return!1}}const Ct="0123456789ABCDEFabcdef".split(""),vn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()".split(""),tt=",[]{}".split(""),Bn=` ,[]{}
|
||
\r `.split(""),st=s=>!s||Bn.includes(s);class Ss{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,t=!1){e&&(this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null),this.atEnd=!t;let n=this.next??"stream";for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===" "||t===" ";)t=this.buffer[++e];return!t||t==="#"||t===`
|
||
`?!0:t==="\r"?this.buffer[e+1]===`
|
||
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===" ";)t=this.buffer[++n+e];if(t==="\r"){const i=this.buffer[n+e+1];if(i===`
|
||
`||!i&&!this.atEnd)return e+n+1}return t===`
|
||
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t==="-"||t==="."){const n=this.buffer.substr(e,3);if((n==="---"||n==="...")&&v(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]===Ge&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length;const n=e.indexOf("#");if(n!==-1){const r=e[n-1];(r===" "||r===" ")&&(t=n-1)}for(;;){const r=e[t-1];if(r===" "||r===" ")t-=1;else break}const i=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-i),this.pushNewline(),"stream"}if(this.atLineEnd()){const t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield Qe,yield*this.parseLineStart()}*parseLineStart(){const 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");const t=this.peek(3);if(t==="---"&&v(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,"doc";if(t==="..."&&v(this.charAt(3)))return yield*this.pushCount(3),"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!v(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){const[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&v(t)){const n=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=n,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);const e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);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(st),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);const i=this.getLine();if(i===null)return this.setNext("flow");if((n!==-1&&n<this.indentNext&&i[0]!=="#"||n===0&&(i.startsWith("---")||i.startsWith("..."))&&v(i[3]))&&!(n===this.indentNext-1&&this.flowLevel===1&&(i[0]==="]"||i[0]==="}")))return this.flowLevel=0,yield We,yield*this.parseLineStart();let r=0;for(;i[r]===",";)r+=yield*this.pushCount(1),r+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(r+=yield*this.pushIndicators(),i[r]){case void 0:return"flow";case"#":return yield*this.pushCount(i.length-r),"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(st),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{const o=this.charAt(1);if(this.flowKey||v(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){const e=this.charAt(0);let t=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;t!==-1&&this.buffer[t+1]==="'";)t=this.buffer.indexOf("'",t+2);else for(;t!==-1;){let r=0;for(;this.buffer[t-1-r]==="\\";)r+=1;if(r%2===0)break;t=this.buffer.indexOf('"',t+1)}const n=this.buffer.substring(0,t);let i=n.indexOf(`
|
||
`,this.pos);if(i!==-1){for(;i!==-1;){const r=this.continueScalar(i+1);if(r===-1)break;i=n.indexOf(`
|
||
`,r)}i!==-1&&(t=i-(n[i-1]==="\r"?2:1))}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){const t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil(t=>v(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,n;e:for(let i=this.pos;n=this.buffer[i];++i)switch(n){case" ":t+=1;break;case`
|
||
`:e=i,t=0;break;case"\r":{const r=this.buffer[i+1];if(!r&&!this.atEnd)return this.setNext("block-scalar");if(r===`
|
||
`)break}default:break e}if(!n&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=t:this.indentNext+=this.blockScalarIndent;do{const i=this.continueScalar(e+1);if(i===-1)break;e=this.buffer.indexOf(`
|
||
`,i)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}if(!this.blockScalarKeep)do{let i=e-1,r=this.buffer[i];r==="\r"&&(r=this.buffer[--i]);const o=i;for(;r===" "||r===" ";)r=this.buffer[--i];if(r===`
|
||
`&&i>=this.pos&&i+1+t>o)e=i;else break}while(!0);return yield be,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){const e=this.flowLevel>0;let t=this.pos-1,n=this.pos-1,i;for(;i=this.buffer[++n];)if(i===":"){const r=this.buffer[n+1];if(v(r)||e&&r===",")break;t=n}else if(v(i)){let r=this.buffer[n+1];if(i==="\r"&&(r===`
|
||
`?(n+=1,i=`
|
||
`,r=this.buffer[n+1]):t=n),r==="#"||e&&tt.includes(r))break;if(i===`
|
||
`){const o=this.continueScalar(n+1);if(o===-1)break;n=Math.max(n,o-2)}}else{if(e&&tt.includes(i))break;t=n}return!i&&!this.atEnd?this.setNext("plain-scalar"):(yield be,yield*this.pushToIndex(t+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){const n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(st))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{const e=this.flowLevel>0,t=this.charAt(1);if(v(t)||e&&tt.includes(t))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];for(;!v(t)&&t!==">";)t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(vn.includes(t))t=this.buffer[++e];else if(t==="%"&&Ct.includes(this.buffer[e+1])&&Ct.includes(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){const e=this.buffer[this.pos];return e===`
|
||
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
|
||
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===" "||e&&n===" ");const i=t-this.pos;return i>0&&(yield this.buffer.substr(this.pos,i),this.pos=t),i}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}class ks{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){const r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};const i=this.lineStarts[t-1];return{line:t,col:e-i+1}}}}function j(s,e){for(let t=0;t<s.length;++t)if(s[t].type===e)return!0;return!1}function vt(s){for(let e=0;e<s.length;++e)switch(s[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Ns(s){switch(s==null?void 0:s.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Ee(s){switch(s.type){case"document":return s.start;case"block-map":{const e=s.items[s.items.length-1];return e.sep??e.start}case"block-seq":return s.items[s.items.length-1].start;default:return[]}}function x(s){var t;if(s.length===0)return[];let e=s.length;e:for(;--e>=0;)switch(s[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;((t=s[++e])==null?void 0:t.type)==="space";);return s.splice(e,s.length)}function Bt(s){if(s.start.type==="flow-seq-start")for(const e of s.items)e.sep&&!e.value&&!j(e.start,"explicit-key-ind")&&!j(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Ns(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}class Nt{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 Ss,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(const n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}const t=ws(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){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{const n=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:n,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(){const e=this.peek(1);if(this.type==="doc-end"&&(!e||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){const t=e??this.stack.pop();if(t)if(this.stack.length===0)yield t;else{const n=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in n?n.indent:0:t.type==="flow-collection"&&n.type==="document"&&(t.indent=0),t.type==="flow-collection"&&Bt(t),n.type){case"document":n.value=t;break;case"block-scalar":n.props.push(t);break;case"block-map":{const i=n.items[n.items.length-1];if(i.value){n.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(i.sep)i.value=t;else{Object.assign(i,{key:t,sep:[]}),this.onKeyLine=!j(i.start,"explicit-key-ind");return}break}case"block-seq":{const i=n.items[n.items.length-1];i.value?n.items.push({start:[],value:t}):i.value=t;break}case"flow-collection":{const i=n.items[n.items.length-1];!i||i.value?n.items.push({start:[],key:t,sep:[]}):i.sep?i.value=t:Object.assign(i,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((n.type==="document"||n.type==="block-map"||n.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){const i=t.items[t.items.length-1];i&&!i.sep&&!i.value&&i.start.length>0&&vt(i.start)===-1&&(t.indent===0||i.start.every(r=>r.type!=="comment"||r.indent<t.indent))&&(n.type==="document"?n.end=i.start:n.items.push({start:i.start}),t.items.splice(-1,1))}}else{const n="Tried to pop an empty stack";yield{type:"error",offset:this.offset,source:"",message:n}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{const e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{vt(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}const t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){const t=Ee(this.peek(2)),n=x(t);let i;e.end?(i=e.end,i.push(this.sourceToken),delete e.end):i=[this.sourceToken];const r={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
|
||
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
||
`,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){var n;const t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){const i="end"in t.value?t.value.end:void 0,r=Array.isArray(i)?i[i.length-1]:void 0;(r==null?void 0:r.type)==="comment"?i==null||i.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){const i=e.items[e.items.length-2],r=(n=i==null?void 0:i.value)==null?void 0:n.end;if(Array.isArray(r)){Array.prototype.push.apply(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){const i=!this.onKeyLine&&this.indent===e.indent&&t.sep;let r=[];if(i&&t.sep&&!t.value){const o=[];for(let l=0;l<t.sep.length;++l){const a=t.sep[l];switch(a.type){case"newline":o.push(l);break;case"space":break;case"comment":a.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(r=t.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":i||t.value?(r.push(this.sourceToken),e.items.push({start:r}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!j(t.start,"explicit-key-ind")?t.start.push(this.sourceToken):i||t.value?(r.push(this.sourceToken),e.items.push({start:r})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]}),this.onKeyLine=!0;return;case"map-value-ind":if(j(t.start,"explicit-key-ind"))if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(j(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]});else if(Ns(t.key)&&!j(t.sep,"newline")){const o=x(t.start),l=t.key,a=t.sep;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:l,sep:a}]})}else r.length>0?t.sep=t.sep.concat(r,this.sourceToken):t.sep.push(this.sourceToken);else if(j(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{const o=x(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||i?e.items.push({start:r,key:null,sep:[this.sourceToken]}):j(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const o=this.flowScalar(this.type);i||t.value?(e.items.push({start:r,key:o,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(o):(Object.assign(t,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{const o=this.startBlockValue(e);if(o){i&&o.type!=="block-seq"&&j(t.start,"explicit-key-ind")&&e.items.push({start:r}),this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){var n;const t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){const i="end"in t.value?t.value.end:void 0,r=Array.isArray(i)?i[i.length-1]:void 0;(r==null?void 0:r.type)==="comment"?i==null||i.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){const i=e.items[e.items.length-2],r=(n=i==null?void 0:i.value)==null?void 0:n.end;if(Array.isArray(r)){Array.prototype.push.apply(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||j(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){const i=this.startBlockValue(e);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){const t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let n;do yield*this.pop(),n=this.peek(1);while(n&&n.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const i=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:i,sep:[]}):t.sep?this.stack.push(i):Object.assign(t,{key:i,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}const n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{const n=this.peek(2);if(n.type==="block-map"&&(this.type==="map-value-ind"&&n.indent===e.indent||this.type==="newline"&&!n.items[n.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&n.type!=="flow-collection"){const i=Ee(n),r=x(i);Bt(e);const o=e.end.splice(1,e.end.length);o.push(this.sourceToken);const l={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=l}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
|
||
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
||
`,t)+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;const t=Ee(e),n=x(t);return n.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n}]}}case"map-value-ind":{this.onKeyLine=!0;const t=Ee(e),n=x(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(n=>n.type==="newline"||n.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 Os(s){const e=s.prettyErrors!==!1;return{lineCounter:s.lineCounter||e&&new ks||null,prettyErrors:e}}function Mn(s,e={}){const{lineCounter:t,prettyErrors:n}=Os(e),i=new Nt(t==null?void 0:t.addNewLine),r=new kt(e),o=Array.from(r.compose(i.parse(s)));if(n&&t)for(const l of o)l.errors.forEach(ve(s,t)),l.warnings.forEach(ve(s,t));return o.length>0?o:Object.assign([],{empty:!0},r.streamInfo())}function As(s,e={}){const{lineCounter:t,prettyErrors:n}=Os(e),i=new Nt(t==null?void 0:t.addNewLine),r=new kt(e);let o=null;for(const l of r.compose(i.parse(s),!0,s.length))if(!o)o=l;else if(o.options.logLevel!=="silent"){o.errors.push(new G(l.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return n&&t&&(o.errors.forEach(ve(s,t)),o.warnings.forEach(ve(s,t))),o}function jn(s,e,t){let n;typeof e=="function"?n=e:t===void 0&&e&&typeof e=="object"&&(t=e);const i=As(s,t);if(!i)return null;if(i.warnings.forEach(r=>Yt(i.options.logLevel,r)),i.errors.length>0){if(i.options.logLevel!=="silent")throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:n},t))}function Pn(s,e,t){let n=null;if(typeof e=="function"||Array.isArray(e)?n=e:t===void 0&&e&&(t=e),typeof t=="string"&&(t=t.length),typeof t=="number"){const i=Math.round(t);t=i<1?void 0:i>8?{indent:8}:{indent:i}}if(s===void 0){const{keepUndefined:i}=t??e??{};if(!i)return}return new ce(s,n,t).toString(t)}const Dn=Object.freeze(Object.defineProperty({__proto__:null,Alias:je,CST:Cn,Composer:kt,Document:ce,Lexer:Ss,LineCounter:ks,Pair:$,Parser:Nt,Scalar:N,Schema:Ye,YAMLError:wt,YAMLMap:B,YAMLParseError:G,YAMLSeq:z,YAMLWarning:cs,isAlias:H,isCollection:I,isDocument:we,isMap:X,isNode:T,isPair:E,isScalar:A,isSeq:oe,parse:jn,parseAllDocuments:Mn,parseDocument:As,stringify:Pn,visit:J,visitAsync:Me},Symbol.toStringTag,{value:"Module"}));export{Dn as Y};
|