From 91bb9d6e38d11e218114a0aa736290841fc0d278 Mon Sep 17 00:00:00 2001 From: Oleg Kalachev Date: Sun, 9 Jun 2024 21:35:17 +0300 Subject: [PATCH] Change the library for YAML encode in topic viewer To support displaying newlines in long strings --- clover/www/js/json-to-pretty-yaml.js | 236 --------------------------- clover/www/js/topics.js | 2 +- clover/www/js/yaml.js | 19 +++ clover/www/topics.html | 2 +- 4 files changed, 21 insertions(+), 238 deletions(-) delete mode 100644 clover/www/js/json-to-pretty-yaml.js create mode 100644 clover/www/js/yaml.js diff --git a/clover/www/js/json-to-pretty-yaml.js b/clover/www/js/json-to-pretty-yaml.js deleted file mode 100644 index 661afd9b4..000000000 --- a/clover/www/js/json-to-pretty-yaml.js +++ /dev/null @@ -1,236 +0,0 @@ -// Browserified https://www.npmjs.com/package/json-to-pretty-yaml module - -(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i/g, ">"); - }; - } - - if (!String.prototype.quote) { - String.prototype.quote = function () { - var c, i, l = this.length, o = '"'; - for (i = 0; i < l; i += 1) { - c = this.charAt(i); - if (c >= ' ') { - if (c === '\\' || c === '"') { - o += '\\'; - } - o += c; - } else { - switch (c) { - case '\b': - o += '\\b'; - break; - case '\f': - o += '\\f'; - break; - case '\n': - o += '\\n'; - break; - case '\r': - o += '\\r'; - break; - case '\t': - o += '\\t'; - break; - default: - c = c.charCodeAt(); - o += '\\u00' + Math.floor(c / 16).toString(16) + - (c % 16).toString(16); - } - } - } - return o + '"'; - }; - } - - if (!String.prototype.supplant) { - String.prototype.supplant = function (o) { - return this.replace(/{([^{}]*)}/g, - function (a, b) { - var r = o[b]; - return typeof r === 'string' || typeof r === 'number' ? r : a; - } - ); - }; - } - - if (!String.prototype.trim) { - String.prototype.trim = function () { - return this.replace(/^\s*(\S*(?:\s+\S+)*)\s*$/, "$1"); - }; - } - - // CommonJS / npm / Ender.JS - module.exports = { - typeOf: typeOf, - isEmpty: isEmpty - }; - global.typeOf = global.typeOf || typeOf; - global.isEmpty = global.isEmpty || isEmpty; -}()); - -},{}],3:[function(require,module,exports){ -"use strict"; - -/** - * removeTrailingSpaces - * Remove the trailing spaces from a string. - * - * @name removeTrailingSpaces - * @function - * @param {String} input The input string. - * @returns {String} The output string. - */ - -module.exports = function removeTrailingSpaces(input) { - // TODO If possible, use a regex - return input.split("\n").map(function (x) { - return x.trimRight(); - }).join("\n"); -}; -},{}]},{},[1]); diff --git a/clover/www/js/topics.js b/clover/www/js/topics.js index 7d8f03df3..ea792ba59 100644 --- a/clover/www/js/topics.js +++ b/clover/www/js/topics.js @@ -64,7 +64,7 @@ function viewTopic(topic) { } } - let txt = `
${counter} received
${yamlStringify(msg)}`; // JSON.stringify(msg, null, 4); + let txt = `
${counter} received
${YAML.stringify(msg)}`; // JSON.stringify(msg, null, 4); topicMessage.innerHTML = txt; }); } diff --git a/clover/www/js/yaml.js b/clover/www/js/yaml.js new file mode 100644 index 000000000..3c8642ee7 --- /dev/null +++ b/clover/www/js/yaml.js @@ -0,0 +1,19 @@ +/* +Built using WebPack from https://github.com/eemeli/yaml + +Copyright Eemeli Aro + +Permission to use, copy, modify, and/or distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright notice +and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS +OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF +THIS SOFTWARE. +*/ + +var YAML;(()=>{"use strict";var e={d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{Alias:()=>K,CST:()=>s,Composer:()=>Xt,Document:()=>Et,Lexer:()=>Os,LineCounter:()=>As,Pair:()=>ye,Parser:()=>_s,Scalar:()=>U,Schema:()=>St,YAMLError:()=>Ot,YAMLMap:()=>Se,YAMLParseError:()=>At,YAMLSeq:()=>Ne,YAMLWarning:()=>Tt,default:()=>Ps,isAlias:()=>f,isCollection:()=>g,isDocument:()=>h,isMap:()=>d,isNode:()=>b,isPair:()=>p,isScalar:()=>m,isSeq:()=>y,parse:()=>Ds,parseAllDocuments:()=>js,parseDocument:()=>Ms,stringify:()=>Ks,visit:()=>E,visitAsync:()=>O});var s={};e.r(s),e.d(s,{BOM:()=>fs,DOCUMENT:()=>hs,FLOW_END:()=>ds,SCALAR:()=>ps,createScalarToken:()=>Zt,isCollection:()=>ms,isScalar:()=>ys,prettyToken:()=>gs,resolveAsScalar:()=>zt,setScalarValue:()=>es,stringify:()=>ns,tokenType:()=>bs,visit:()=>ls});var n={};e.r(n),e.d(n,{Alias:()=>K,CST:()=>s,Composer:()=>Xt,Document:()=>Et,Lexer:()=>Os,LineCounter:()=>As,Pair:()=>ye,Parser:()=>_s,Scalar:()=>U,Schema:()=>St,YAMLError:()=>Ot,YAMLMap:()=>Se,YAMLParseError:()=>At,YAMLSeq:()=>Ne,YAMLWarning:()=>Tt,isAlias:()=>f,isCollection:()=>g,isDocument:()=>h,isMap:()=>d,isNode:()=>b,isPair:()=>p,isScalar:()=>m,isSeq:()=>y,parse:()=>Ds,parseAllDocuments:()=>js,parseDocument:()=>Ms,stringify:()=>Ks,visit:()=>E,visitAsync:()=>O});const i=Symbol.for("yaml.alias"),o=Symbol.for("yaml.document"),r=Symbol.for("yaml.map"),a=Symbol.for("yaml.pair"),c=Symbol.for("yaml.scalar"),l=Symbol.for("yaml.seq"),u=Symbol.for("yaml.node.type"),f=e=>!!e&&"object"==typeof e&&e[u]===i,h=e=>!!e&&"object"==typeof e&&e[u]===o,d=e=>!!e&&"object"==typeof e&&e[u]===r,p=e=>!!e&&"object"==typeof e&&e[u]===a,m=e=>!!e&&"object"==typeof e&&e[u]===c,y=e=>!!e&&"object"==typeof e&&e[u]===l;function g(e){if(e&&"object"==typeof e)switch(e[u]){case r:case l:return!0}return!1}function b(e){if(e&&"object"==typeof e)switch(e[u]){case i:case r:case c:case l:return!0}return!1}const k=e=>(m(e)||g(e))&&!!e.anchor,w=Symbol("break visit"),v=Symbol("skip children"),S=Symbol("remove node");function E(e,t){const s=T(t);h(e)?N(null,e.contents,s,Object.freeze([e]))===S&&(e.contents=null):N(null,e,s,Object.freeze([]))}function N(e,t,s,n){const i=I(e,t,s,n);if(b(i)||p(i))return L(e,n,i),N(e,i,s,n);if("symbol"!=typeof i)if(g(t)){n=Object.freeze(n.concat(t));for(let e=0;e"!==e[e.length-1]&&t("Verbatim tags must end with a >"),s)}const[,s,n]=e.match(/^(.*!)([^!]*)$/s);n||t(`The ${e} tag has no suffix`);const i=this.tags[s];if(i)try{return i+decodeURIComponent(n)}catch(e){return t(String(e)),null}return"!"===s?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(const[t,s]of Object.entries(this.tags))if(e.startsWith(s))return t+e.substring(s.length).replace(/[!,[\]{}]/g,(e=>x[e]));return"!"===e[0]?e:`!<${e}>`}toString(e){const t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags);let n;if(e&&s.length>0&&b(e.contents)){const t={};E(e.contents,((e,s)=>{b(s)&&s.tag&&(t[s.tag]=!0)})),n=Object.keys(t)}else n=[];for(const[i,o]of s)"!!"===i&&"tag:yaml.org,2002:"===o||e&&!n.some((e=>e.startsWith(o)))||t.push(`%TAG ${i} ${o}`);return t.join("\n")}}function C(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){const t=JSON.stringify(e);throw new Error(`Anchor must not contain whitespace or control characters: ${t}`)}return!0}function _(e){const t=new Set;return E(e,{Value(e,s){s.anchor&&t.add(s.anchor)}}),t}function B(e,t){for(let s=1;;++s){const n=`${e}${s}`;if(!t.has(n))return n}}function j(e,t,s,n){if(n&&"object"==typeof n)if(Array.isArray(n))for(let t=0,s=n.length;tM(e,String(t),s)));if(e&&"function"==typeof e.toJSON){if(!s||!k(e))return e.toJSON(t,s);const n={aliasCount:0,count:1,res:void 0};s.anchors.set(e,n),s.onCreate=e=>{n.res=e,delete s.onCreate};const i=e.toJSON(t,s);return s.onCreate&&s.onCreate(i),i}return"bigint"!=typeof e||s?.keep?e:Number(e)}$.defaultYaml={explicit:!1,version:"1.2"},$.defaultTags={"!!":"tag:yaml.org,2002:"};class D{constructor(e){Object.defineProperty(this,u,{value:e})}clone(){const e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:s,onAnchor:n,reviver:i}={}){if(!h(e))throw new TypeError("A document argument is required");const o={anchors:new Map,doc:e,keep:!0,mapAsMap:!0===t,mapKeyWarned:!1,maxAliasCount:"number"==typeof s?s:100},r=M(this,"",o);if("function"==typeof n)for(const{count:e,res:t}of o.anchors.values())n(t,e);return"function"==typeof i?j(i,{"":r},"",r):r}}class K extends D{constructor(e){super(i),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e){let t;return E(e,{Node:(e,s)=>{if(s===this)return E.BREAK;s.anchor===this.source&&(t=s)}}),t}toJSON(e,t){if(!t)return{source:this.source};const{anchors:s,doc:n,maxAliasCount:i}=t,o=this.resolve(n);if(!o){const e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(e)}let r=s.get(o);if(r||(M(o,null,t),r=s.get(o)),!r||void 0===r.res)throw new ReferenceError("This should not happen: Alias anchor was not resolved?");if(i>=0&&(r.count+=1,0===r.aliasCount&&(r.aliasCount=P(n,o,s)),r.count*r.aliasCount>i))throw new ReferenceError("Excessive alias count indicates a resource exhaustion attack");return r.res}toString(e,t,s){const n=`*${this.source}`;if(e){if(C(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){const e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(e)}if(e.implicitKey)return`${n} `}return n}}function P(e,t,s){if(f(t)){const n=t.resolve(e),i=s&&n&&s.get(n);return i?i.count*i.aliasCount:0}if(g(t)){let n=0;for(const i of t.items){const t=P(e,i,s);t>n&&(n=t)}return n}if(p(t)){const n=P(e,t.key,s),i=P(e,t.value,s);return Math.max(n,i)}return 1}const q=e=>!e||"function"!=typeof e&&"object"!=typeof e;class U extends D{constructor(e){super(c),this.value=e}toJSON(e,t){return t?.keep?this.value:M(this.value,e,t)}toString(){return String(this.value)}}U.BLOCK_FOLDED="BLOCK_FOLDED",U.BLOCK_LITERAL="BLOCK_LITERAL",U.PLAIN="PLAIN",U.QUOTE_DOUBLE="QUOTE_DOUBLE",U.QUOTE_SINGLE="QUOTE_SINGLE";const R="tag:yaml.org,2002:";function F(e,t,s){if(h(e)&&(e=e.contents),b(e))return e;if(p(e)){const t=s.schema[r].createNode?.(s.schema,null,s);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||"undefined"!=typeof BigInt&&e instanceof BigInt)&&(e=e.valueOf());const{aliasDuplicateObjects:n,onAnchor:i,onTagObj:o,schema:a,sourceObjects:c}=s;let u;if(n&&e&&"object"==typeof e){if(u=c.get(e),u)return u.anchor||(u.anchor=i(e)),new K(u.anchor);u={anchor:null,node:null},c.set(e,u)}t?.startsWith("!!")&&(t=R+t.slice(2));let f=function(e,t,s){if(t){const e=s.filter((e=>e.tag===t)),n=e.find((e=>!e.format))??e[0];if(!n)throw new Error(`Tag ${t} not found`);return n}return s.find((t=>t.identify?.(e)&&!t.format))}(e,t,a.tags);if(!f){if(e&&"function"==typeof e.toJSON&&(e=e.toJSON()),!e||"object"!=typeof e){const t=new U(e);return u&&(u.node=t),t}f=e instanceof Map?a[r]:Symbol.iterator in Object(e)?a[l]:a[r]}o&&(o(f),delete s.onTagObj);const d=f?.createNode?f.createNode(s.schema,e,s):"function"==typeof f?.nodeClass?.from?f.nodeClass.from(s.schema,e,s):new U(e);return t?d.tag=t:f.default||(d.tag=f.tag),u&&(u.node=d),d}function V(e,t,s){let n=s;for(let e=t.length-1;e>=0;--e){const s=t[e];if("number"==typeof s&&Number.isInteger(s)&&s>=0){const e=[];e[s]=n,n=e}else n=new Map([[s,n]])}return F(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}const Y=e=>null==e||"object"==typeof e&&!!e[Symbol.iterator]().next().done;class J extends D{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((t=>b(t)||p(t)?t.clone(e):t)),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Y(e))this.add(t);else{const[s,...n]=e,i=this.get(s,!0);if(g(i))i.addIn(n,t);else{if(void 0!==i||!this.schema)throw new Error(`Expected YAML collection at ${s}. Remaining path: ${n}`);this.set(s,V(this.schema,n,t))}}}deleteIn(e){const[t,...s]=e;if(0===s.length)return this.delete(t);const n=this.get(t,!0);if(g(n))return n.deleteIn(s);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${s}`)}getIn(e,t){const[s,...n]=e,i=this.get(s,!0);return 0===n.length?!t&&m(i)?i.value:i:g(i)?i.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every((t=>{if(!p(t))return!1;const s=t.value;return null==s||e&&m(s)&&null==s.value&&!s.commentBefore&&!s.comment&&!s.tag}))}hasIn(e){const[t,...s]=e;if(0===s.length)return this.has(t);const n=this.get(t,!0);return!!g(n)&&n.hasIn(s)}setIn(e,t){const[s,...n]=e;if(0===n.length)this.set(s,t);else{const e=this.get(s,!0);if(g(e))e.setIn(n,t);else{if(void 0!==e||!this.schema)throw new Error(`Expected YAML collection at ${s}. Remaining path: ${n}`);this.set(s,V(this.schema,n,t))}}}}J.maxFlowStringSingleLineLength=60;const W=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function G(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}const Q=(e,t,s)=>e.endsWith("\n")?G(s,t):s.includes("\n")?"\n"+G(s,t):(e.endsWith(" ")?"":" ")+s,H="flow",X="block",z="quoted";function Z(e,t,s="flow",{indentAtStart:n,lineWidth:i=80,minContentWidth:o=20,onFold:r,onOverflow:a}={}){if(!i||i<0)return e;const c=Math.max(1+o,1+i-t.length);if(e.length<=c)return e;const l=[],u={};let f,h,d=i-t.length;"number"==typeof n&&(n>i-Math.max(2,o)?l.push(0):d=i-n);let p=!1,m=-1,y=-1,g=-1;s===X&&(m=ee(e,m,t.length),-1!==m&&(d=m+c));for(let n;n=e[m+=1];){if(s===z&&"\\"===n){switch(y=m,e[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}g=m}if("\n"===n)s===X&&(m=ee(e,m,t.length)),d=m+t.length+c,f=void 0;else{if(" "===n&&h&&" "!==h&&"\n"!==h&&"\t"!==h){const t=e[m+1];t&&" "!==t&&"\n"!==t&&"\t"!==t&&(f=m)}if(m>=d)if(f)l.push(f),d=f+c,f=void 0;else if(s===z){for(;" "===h||"\t"===h;)h=n,n=e[m+=1],p=!0;const t=m>g+1?m-2:y-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else p=!0}h=n}if(p&&a&&a(),0===l.length)return e;r&&r();let b=e.slice(0,l[0]);for(let n=0;n({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),se=e=>/^(%|---|\.\.\.)/m.test(e);function ne(e,t){const s=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return s;const{implicitKey:n}=t,i=t.options.doubleQuotedMinMultiLineLength,o=t.indent||(se(e)?" ":"");let r="",a=0;for(let e=0,t=s[e];t;t=s[++e])if(" "===t&&"\\"===s[e+1]&&"n"===s[e+2]&&(r+=s.slice(a,e)+"\\ ",e+=1,a=e,t="\\"),"\\"===t)switch(s[e+1]){case"u":{r+=s.slice(a,e);const t=s.substr(e+2,4);switch(t){case"0000":r+="\\0";break;case"0007":r+="\\a";break;case"000b":r+="\\v";break;case"001b":r+="\\e";break;case"0085":r+="\\N";break;case"00a0":r+="\\_";break;case"2028":r+="\\L";break;case"2029":r+="\\P";break;default:"00"===t.substr(0,2)?r+="\\x"+t.substr(2):r+=s.substr(e,6)}e+=5,a=e+1}break;case"n":if(n||'"'===s[e+2]||s.lengthn)return!0;if(s=t+1,i-s<=n)return!1}return!0}(s,c,l.length));if(!s)return u?"|\n":">\n";let f,h;for(h=s.length;h>0;--h){const e=s[h-1];if("\n"!==e&&"\t"!==e&&" "!==e)break}let d=s.substring(h);const p=d.indexOf("\n");-1===p?f="-":s===d||p!==d.length-1?(f="+",o&&o()):f="",d&&(s=s.slice(0,-d.length),"\n"===d[d.length-1]&&(d=d.slice(0,-1)),d=d.replace(re,`$&${l}`));let m,y=!1,g=-1;for(m=0;m")+(y?l?"2":"1":"")+f;return e&&(k+=" "+a(e.replace(/ ?[\r\n]+/g," ")),i&&i()),u?`${k}\n${l}${b}${s=s.replace(/\n+/g,`$&${l}`)}${d}`:`${k}\n${l}${Z(`${b}${s=s.replace(/\n+/g,"\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`)}${d}`,l,X,te(n,!0))}`}function ce(e,t,s,n){const{implicitKey:i,inFlow:o}=t,r="string"==typeof e.value?e:Object.assign({},e,{value:String(e.value)});let{type:a}=e;a!==U.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(r.value)&&(a=U.QUOTE_DOUBLE);const c=e=>{switch(e){case U.BLOCK_FOLDED:case U.BLOCK_LITERAL:return i||o?oe(r.value,t):ae(r,t,s,n);case U.QUOTE_DOUBLE:return ne(r.value,t);case U.QUOTE_SINGLE:return ie(r.value,t);case U.PLAIN:return function(e,t,s,n){const{type:i,value:o}=e,{actualString:r,implicitKey:a,indent:c,indentStep:l,inFlow:u}=t;if(a&&o.includes("\n")||u&&/[[\]{},]/.test(o))return oe(o,t);if(!o||/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||u||!o.includes("\n")?oe(o,t):ae(e,t,s,n);if(!a&&!u&&i!==U.PLAIN&&o.includes("\n"))return ae(e,t,s,n);if(se(o)){if(""===c)return t.forceBlockIndent=!0,ae(e,t,s,n);if(a&&c===l)return oe(o,t)}const f=o.replace(/\n+/g,`$&\n${c}`);if(r){const e=e=>e.default&&"tag:yaml.org,2002:str"!==e.tag&&e.test?.test(f),{compat:s,tags:n}=t.doc.schema;if(n.some(e)||s?.some(e))return oe(o,t)}return a?f:Z(f,c,H,te(t,!1))}(r,t,s,n);default:return null}};let l=c(a);if(null===l){const{defaultKeyType:e,defaultStringType:s}=t.options,n=i&&e||s;if(l=c(n),null===l)throw new Error(`Unsupported default string type ${n}`)}return l}function le(e,t){const s=Object.assign({blockQuote:!0,commentString:W,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t);let n;switch(s.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:e,flowCollectionPadding:s.flowCollectionPadding?" ":"",indent:"",indentStep:"number"==typeof s.indent?" ".repeat(s.indent):" ",inFlow:n,options:s}}function ue(e,t,s,n){if(p(e))return e.toString(t,s,n);if(f(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i;const o=b(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i||(i=function(e,t){if(t.tag){const s=e.filter((e=>e.tag===t.tag));if(s.length>0)return s.find((e=>e.format===t.format))??s[0]}let s,n;if(m(t)){n=t.value;const i=e.filter((e=>e.identify?.(n)));s=i.find((e=>e.format===t.format))??i.find((e=>!e.format))}else n=t,s=e.find((e=>e.nodeClass&&n instanceof e.nodeClass));if(!s)throw new Error(`Tag not resolved for ${n?.constructor?.name??typeof n} value`);return s}(t.doc.schema.tags,o));const r=function(e,t,{anchors:s,doc:n}){if(!n.directives)return"";const i=[],o=(m(e)||g(e))&&e.anchor;o&&C(o)&&(s.add(o),i.push(`&${o}`));const r=e.tag?e.tag:t.default?null:t.tag;return r&&i.push(n.directives.tagString(r)),i.join(" ")}(o,i,t);r.length>0&&(t.indentAtStart=(t.indentAtStart??0)+r.length+1);const a="function"==typeof i.stringify?i.stringify(o,t,s,n):m(o)?ce(o,t,s,n):o.toString(t,s,n);return r?m(o)||"{"===a[0]||"["===a[0]?`${r} ${a}`:`${r}\n${t.indent}${a}`:a}function fe(e,t){"debug"!==e&&"warn"!==e||("undefined"!=typeof process&&process.emitWarning?process.emitWarning(t):console.warn(t))}function he(e,t,{key:s,value:n}){if(e?.doc.schema.merge&&de(s))if(n=f(n)?n.resolve(e.doc):n,y(n))for(const s of n.items)pe(e,t,s);else if(Array.isArray(n))for(const s of n)pe(e,t,s);else pe(e,t,n);else{const i=M(s,"",e);if(t instanceof Map)t.set(i,M(n,i,e));else if(t instanceof Set)t.add(i);else{const o=function(e,t,s){if(null===t)return"";if("object"!=typeof t)return String(t);if(b(e)&&s?.doc){const t=le(s.doc,{});t.anchors=new Set;for(const e of s.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;const n=e.toString(t);if(!s.mapKeyWarned){let e=JSON.stringify(n);e.length>40&&(e=e.substring(0,36)+'..."'),fe(s.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),s.mapKeyWarned=!0}return n}return JSON.stringify(t)}(s,i,e),r=M(n,o,e);o in t?Object.defineProperty(t,o,{value:r,writable:!0,enumerable:!0,configurable:!0}):t[o]=r}}return t}const de=e=>"<<"===e||m(e)&&"<<"===e.value&&(!e.type||e.type===U.PLAIN);function pe(e,t,s){const n=e&&f(s)?s.resolve(e.doc):s;if(!d(n))throw new Error("Merge sources must be maps or map aliases");const i=n.toJSON(null,e,Map);for(const[e,s]of i)t instanceof Map?t.has(e)||t.set(e,s):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:s,writable:!0,enumerable:!0,configurable:!0});return t}function me(e,t,s){const n=F(e,void 0,s),i=F(t,void 0,s);return new ye(n,i)}class ye{constructor(e,t=null){Object.defineProperty(this,u,{value:a}),this.key=e,this.value=t}clone(e){let{key:t,value:s}=this;return b(t)&&(t=t.clone(e)),b(s)&&(s=s.clone(e)),new ye(t,s)}toJSON(e,t){return he(t,t?.mapAsMap?new Map:{},this)}toString(e,t,s){return e?.doc?function({key:e,value:t},s,n,i){const{allNullValues:o,doc:r,indent:a,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:f}}=s;let h=b(e)&&e.comment||null;if(f){if(h)throw new Error("With simple keys, key nodes cannot have comments");if(g(e)||!b(e)&&"object"==typeof e)throw new Error("With simple keys, collection cannot be used as a key value")}let d=!f&&(!e||h&&null==t&&!s.inFlow||g(e)||(m(e)?e.type===U.BLOCK_FOLDED||e.type===U.BLOCK_LITERAL:"object"==typeof e));s=Object.assign({},s,{allNullValues:!1,implicitKey:!d&&(f||!o),indent:a+c});let p,k,w,v=!1,S=!1,E=ue(e,s,(()=>v=!0),(()=>S=!0));if(!d&&!s.inFlow&&E.length>1024){if(f)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");d=!0}if(s.inFlow){if(o||null==t)return v&&n&&n(),""===E?"?":d?`? ${E}`:E}else if(o&&!f||null==t&&d)return E=`? ${E}`,h&&!v?E+=Q(E,s.indent,l(h)):S&&i&&i(),E;v&&(h=null),d?(h&&(E+=Q(E,s.indent,l(h))),E=`? ${E}\n${a}:`):(E=`${E}:`,h&&(E+=Q(E,s.indent,l(h)))),b(t)?(p=!!t.spaceBefore,k=t.commentBefore,w=t.comment):(p=!1,k=null,w=null,t&&"object"==typeof t&&(t=r.createNode(t))),s.implicitKey=!1,d||h||!m(t)||(s.indentAtStart=E.length+1),S=!1,u||!(c.length>=2)||s.inFlow||d||!y(t)||t.flow||t.tag||t.anchor||(s.indent=s.indent.substring(2));let N=!1;const O=ue(t,s,(()=>N=!0),(()=>S=!0));let A=" ";if(h||p||k)A=p?"\n":"",k&&(A+=`\n${G(l(k),s.indent)}`),""!==O||s.inFlow?A+=`\n${s.indent}`:"\n"===A&&(A="\n\n");else if(!d&&g(t)){const e=O[0],n=O.indexOf("\n"),i=-1!==n,o=s.inFlow??t.flow??0===t.items.length;if(i||!o){let t=!1;if(i&&("&"===e||"!"===e)){let s=O.indexOf(" ");"&"===e&&-1!==s&&sr=null),(()=>f=!0));r&&(a+=Q(a,o,l(r))),f&&r&&(f=!1),h.push(n+a)}let d;if(0===h.length)d=i.start+i.end;else{d=h[0];for(let e=1;eo=null));su||r.includes("\n"))&&(l=!0),f.push(r),u=f.length}const{start:h,end:d}=s;if(0===f.length)return h+d;if(!l){const e=f.reduce(((e,t)=>e+t.length+2),2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=h;for(const t of f)e+=t?`\n${o}${i}${t}`:"\n";return`${e}\n${i}${d}`}return`${h}${r}${f.join(" ")}${r}${d}`}function we({indent:e,options:{commentString:t}},s,n,i){if(n&&i&&(n=n.replace(/^\n+/,"")),n){const i=G(t(n),e);s.push(i.trimStart())}}function ve(e,t){const s=m(t)?t.value:t;for(const n of e)if(p(n)){if(n.key===t||n.key===s)return n;if(m(n.key)&&n.key.value===s)return n}}class Se extends J{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(r,e),this.items=[]}static from(e,t,s){const{keepUndefined:n,replacer:i}=s,o=new this(e),r=(e,r)=>{if("function"==typeof i)r=i.call(t,e,r);else if(Array.isArray(i)&&!i.includes(e))return;(void 0!==r||n)&&o.items.push(me(e,r,s))};if(t instanceof Map)for(const[e,s]of t)r(e,s);else if(t&&"object"==typeof t)for(const e of Object.keys(t))r(e,t[e]);return"function"==typeof e.sortMapEntries&&o.items.sort(e.sortMapEntries),o}add(e,t){let s;s=p(e)?e:e&&"object"==typeof e&&"key"in e?new ye(e.key,e.value):new ye(e,e?.value);const n=ve(this.items,s.key),i=this.schema?.sortMapEntries;if(n){if(!t)throw new Error(`Key ${s.key} already set`);m(n.value)&&q(s.value)?n.value.value=s.value:n.value=s.value}else if(i){const e=this.items.findIndex((e=>i(s,e)<0));-1===e?this.items.push(s):this.items.splice(e,0,s)}else this.items.push(s)}delete(e){const t=ve(this.items,e);return!!t&&this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){const s=ve(this.items,e),n=s?.value;return(!t&&m(n)?n.value:n)??void 0}has(e){return!!ve(this.items,e)}set(e,t){this.add(new ye(e,t),!0)}toJSON(e,t,s){const n=s?new s:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(n);for(const e of this.items)he(t,n,e);return n}toString(e,t,s){if(!e)return JSON.stringify(this);for(const e of this.items)if(!p(e))throw new Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),ge(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:t})}}const Ee={collection:"map",default:!0,nodeClass:Se,tag:"tag:yaml.org,2002:map",resolve:(e,t)=>(d(e)||t("Expected a mapping for this tag"),e),createNode:(e,t,s)=>Se.from(e,t,s)};class Ne extends J{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(l,e),this.items=[]}add(e){this.items.push(e)}delete(e){const t=Oe(e);return"number"==typeof t&&this.items.splice(t,1).length>0}get(e,t){const s=Oe(e);if("number"!=typeof s)return;const n=this.items[s];return!t&&m(n)?n.value:n}has(e){const t=Oe(e);return"number"==typeof t&&t=0?t:null}const Ae={collection:"seq",default:!0,nodeClass:Ne,tag:"tag:yaml.org,2002:seq",resolve:(e,t)=>(y(e)||t("Expected a sequence for this tag"),e),createNode:(e,t,s)=>Ne.from(e,t,s)},Te={identify:e=>"string"==typeof e,default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:(e,t,s,n)=>ce(e,t=Object.assign({actualString:!0},t),s,n)},Ie={identify:e=>null==e,createNode:()=>new U(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new U(null),stringify:({source:e},t)=>"string"==typeof e&&Ie.test.test(e)?e:t.options.nullStr},Le={identify:e=>"boolean"==typeof e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new U("t"===e[0]||"T"===e[0]),stringify:({source:e,value:t},s)=>e&&Le.test.test(e)&&t===("t"===e[0]||"T"===e[0])?e:t?s.options.trueStr:s.options.falseStr};function xe({format:e,minFractionDigits:t,tag:s,value:n}){if("bigint"==typeof n)return String(n);const i="number"==typeof n?n:Number(n);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let o=JSON.stringify(n);if(!e&&t&&(!s||"tag:yaml.org,2002:float"===s)&&/^\d/.test(o)){let e=o.indexOf(".");e<0&&(e=o.length,o+=".");let s=t-(o.length-e-1);for(;s-- >0;)o+="0"}return o}const $e={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>"nan"===e.slice(-3).toLowerCase()?NaN:"-"===e[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:xe},Ce={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){const t=Number(e.value);return isFinite(t)?t.toExponential():xe(e)}},_e={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){const t=new U(parseFloat(e)),s=e.indexOf(".");return-1!==s&&"0"===e[e.length-1]&&(t.minFractionDigits=e.length-s-1),t},stringify:xe},Be=e=>"bigint"==typeof e||Number.isInteger(e),je=(e,t,s,{intAsBigInt:n})=>n?BigInt(e):parseInt(e.substring(t),s);function Me(e,t,s){const{value:n}=e;return Be(n)&&n>=0?s+n.toString(t):xe(e)}const De={identify:e=>Be(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,s)=>je(e,2,8,s),stringify:e=>Me(e,8,"0o")},Ke={identify:Be,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,s)=>je(e,0,10,s),stringify:xe},Pe={identify:e=>Be(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,s)=>je(e,2,16,s),stringify:e=>Me(e,16,"0x")},qe=[Ee,Ae,Te,Ie,Le,De,Ke,Pe,$e,Ce,_e];function Ue(e){return"bigint"==typeof e||Number.isInteger(e)}const Re=({value:e})=>JSON.stringify(e),Fe=[Ee,Ae].concat([{identify:e=>"string"==typeof e,default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Re},{identify:e=>null==e,createNode:()=>new U(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Re},{identify:e=>"boolean"==typeof e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^true|false$/,resolve:e=>"true"===e,stringify:Re},{identify:Ue,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:s})=>s?BigInt(e):parseInt(e,10),stringify:({value:e})=>Ue(e)?e.toString():JSON.stringify(e)},{identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Re}],{default:!0,tag:"",test:/^/,resolve:(e,t)=>(t(`Unresolved plain scalar ${JSON.stringify(e)}`),e)}),Ve={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if("function"==typeof Buffer)return Buffer.from(e,"base64");if("function"==typeof atob){const t=atob(e.replace(/[\n\r]/g,"")),s=new Uint8Array(t.length);for(let e=0;e1&&t("Each pair must have its own sequence indicator");const e=n.items[0]||new ye(new U(null));if(n.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${n.commentBefore}\n${e.key.commentBefore}`:n.commentBefore),n.comment){const t=e.value??e.key;t.comment=t.comment?`${n.comment}\n${t.comment}`:n.comment}n=e}e.items[s]=p(n)?n:new ye(n)}}else t("Expected a sequence for this tag");return e}function Je(e,t,s){const{replacer:n}=s,i=new Ne(e);i.tag="tag:yaml.org,2002:pairs";let o=0;if(t&&Symbol.iterator in Object(t))for(let e of t){let r,a;if("function"==typeof n&&(e=n.call(t,String(o++),e)),Array.isArray(e)){if(2!==e.length)throw new TypeError(`Expected [key, value] tuple: ${e}`);r=e[0],a=e[1]}else if(e&&e instanceof Object){const t=Object.keys(e);if(1!==t.length)throw new TypeError(`Expected tuple with one key, not ${t.length} keys`);r=t[0],a=e[r]}else r=e;i.items.push(me(r,a,s))}return i}const We={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ye,createNode:Je};class Ge extends Ne{constructor(){super(),this.add=Se.prototype.add.bind(this),this.delete=Se.prototype.delete.bind(this),this.get=Se.prototype.get.bind(this),this.has=Se.prototype.has.bind(this),this.set=Se.prototype.set.bind(this),this.tag=Ge.tag}toJSON(e,t){if(!t)return super.toJSON(e);const s=new Map;t?.onCreate&&t.onCreate(s);for(const e of this.items){let n,i;if(p(e)?(n=M(e.key,"",t),i=M(e.value,n,t)):n=M(e,"",t),s.has(n))throw new Error("Ordered maps must not include duplicate keys");s.set(n,i)}return s}static from(e,t,s){const n=Je(e,t,s),i=new this;return i.items=n.items,i}}Ge.tag="tag:yaml.org,2002:omap";const Qe={collection:"seq",identify:e=>e instanceof Map,nodeClass:Ge,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){const s=Ye(e,t),n=[];for(const{key:e}of s.items)m(e)&&(n.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):n.push(e.value));return Object.assign(new Ge,s)},createNode:(e,t,s)=>Ge.from(e,t,s)};function He({value:e,source:t},s){return t&&(e?Xe:ze).test.test(t)?t:e?s.options.trueStr:s.options.falseStr}const Xe={identify:e=>!0===e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new U(!0),stringify:He},ze={identify:e=>!1===e,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new U(!1),stringify:He},Ze={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>"nan"===e.slice(-3).toLowerCase()?NaN:"-"===e[0]?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:xe},et={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){const t=Number(e.value);return isFinite(t)?t.toExponential():xe(e)}},tt={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){const t=new U(parseFloat(e.replace(/_/g,""))),s=e.indexOf(".");if(-1!==s){const n=e.substring(s+1).replace(/_/g,"");"0"===n[n.length-1]&&(t.minFractionDigits=n.length)}return t},stringify:xe},st=e=>"bigint"==typeof e||Number.isInteger(e);function nt(e,t,s,{intAsBigInt:n}){const i=e[0];if("-"!==i&&"+"!==i||(t+=1),e=e.substring(t).replace(/_/g,""),n){switch(s){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}const t=BigInt(e);return"-"===i?BigInt(-1)*t:t}const o=parseInt(e,s);return"-"===i?-1*o:o}function it(e,t,s){const{value:n}=e;if(st(n)){const e=n.toString(t);return n<0?"-"+s+e.substr(1):s+e}return xe(e)}const ot={identify:st,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>nt(e,2,2,s),stringify:e=>it(e,2,"0b")},rt={identify:st,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>nt(e,1,8,s),stringify:e=>it(e,8,"0")},at={identify:st,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>nt(e,0,10,s),stringify:xe},ct={identify:st,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>nt(e,2,16,s),stringify:e=>it(e,16,"0x")};class lt extends Se{constructor(e){super(e),this.tag=lt.tag}add(e){let t;t=p(e)?e:e&&"object"==typeof e&&"key"in e&&"value"in e&&null===e.value?new ye(e.key,null):new ye(e,null),ve(this.items,t.key)||this.items.push(t)}get(e,t){const s=ve(this.items,e);return!t&&p(s)?m(s.key)?s.key.value:s.key:s}set(e,t){if("boolean"!=typeof t)throw new Error("Expected boolean value for set(key, value) in a YAML set, not "+typeof t);const s=ve(this.items,e);s&&!t?this.items.splice(this.items.indexOf(s),1):!s&&t&&this.items.push(new ye(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,s){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,s);throw new Error("Set items must all have null values")}static from(e,t,s){const{replacer:n}=s,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)"function"==typeof n&&(e=n.call(t,e,e)),i.items.push(me(e,null,s));return i}}lt.tag="tag:yaml.org,2002:set";const ut={collection:"map",identify:e=>e instanceof Set,nodeClass:lt,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,s)=>lt.from(e,t,s),resolve(e,t){if(d(e)){if(e.hasAllNullValues(!0))return Object.assign(new lt,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};function ft(e,t){const s=e[0],n="-"===s||"+"===s?e.substring(1):e,i=e=>t?BigInt(e):Number(e),o=n.replace(/_/g,"").split(":").reduce(((e,t)=>e*i(60)+i(t)),i(0));return"-"===s?i(-1)*o:o}function ht(e){let{value:t}=e,s=e=>e;if("bigint"==typeof t)s=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return xe(e);let n="";t<0&&(n="-",t*=s(-1));const i=s(60),o=[t%i];return t<60?o.unshift(0):(t=(t-o[0])/i,o.unshift(t%i),t>=60&&(t=(t-o[0])/i,o.unshift(t))),n+o.map((e=>String(e).padStart(2,"0"))).join(":").replace(/000000\d*$/,"")}const dt={identify:e=>"bigint"==typeof e||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:s})=>ft(e,s),stringify:ht},pt={identify:e=>"number"==typeof e,default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>ft(e,!1),stringify:ht},mt={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){const t=e.match(mt.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,s,n,i,o,r,a]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0;let l=Date.UTC(s,n-1,i,o||0,r||0,a||0,c);const u=t[8];if(u&&"Z"!==u){let e=ft(u,!1);Math.abs(e)<30&&(e*=60),l-=6e4*e}return new Date(l)},stringify:({value:e})=>e.toISOString().replace(/((T00:00)?:00)?\.000Z$/,"")},yt=[Ee,Ae,Te,Ie,Xe,ze,ot,rt,at,ct,Ze,et,tt,Ve,Qe,We,ut,dt,pt,mt],gt=new Map([["core",qe],["failsafe",[Ee,Ae,Te]],["json",Fe],["yaml11",yt],["yaml-1.1",yt]]),bt={binary:Ve,bool:Le,float:_e,floatExp:Ce,floatNaN:$e,floatTime:pt,int:Ke,intHex:Pe,intOct:De,intTime:dt,map:Ee,null:Ie,omap:Qe,pairs:We,seq:Ae,set:ut,timestamp:mt},kt={"tag:yaml.org,2002:binary":Ve,"tag:yaml.org,2002:omap":Qe,"tag:yaml.org,2002:pairs":We,"tag:yaml.org,2002:set":ut,"tag:yaml.org,2002:timestamp":mt};function wt(e,t){let s=gt.get(t);if(!s){if(!Array.isArray(e)){const e=Array.from(gt.keys()).filter((e=>"yaml11"!==e)).map((e=>JSON.stringify(e))).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}s=[]}if(Array.isArray(e))for(const t of e)s=s.concat(t);else"function"==typeof e&&(s=e(s.slice()));return s.map((e=>{if("string"!=typeof e)return e;const t=bt[e];if(t)return t;const s=Object.keys(bt).map((e=>JSON.stringify(e))).join(", ");throw new Error(`Unknown custom tag "${e}"; use one of ${s}`)}))}const vt=(e,t)=>e.keyt.key?1:0;class St{constructor({compat:e,customTags:t,merge:s,resolveKnownTags:n,schema:i,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?wt(e,"compat"):e?wt(null,e):null,this.merge=!!s,this.name="string"==typeof i&&i||"core",this.knownTags=n?kt:{},this.tags=wt(t,this.name),this.toStringOptions=a??null,Object.defineProperty(this,r,{value:Ee}),Object.defineProperty(this,c,{value:Te}),Object.defineProperty(this,l,{value:Ae}),this.sortMapEntries="function"==typeof o?o:!0===o?vt:null}clone(){const e=Object.create(St.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}class Et{constructor(e,t,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,u,{value:o});let n=null;"function"==typeof t||Array.isArray(t)?n=t:void 0===s&&t&&(s=t,t=void 0);const i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,uniqueKeys:!0,version:"1.2"},s);this.options=i;let{version:r}=i;s?._directives?(this.directives=s._directives.atDocument(),this.directives.yaml.explicit&&(r=this.directives.yaml.version)):this.directives=new $({version:r}),this.setSchema(r,s),this.contents=void 0===e?null:this.createNode(e,n,s)}clone(){const e=Object.create(Et.prototype,{[u]:{value:o}});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=b(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Nt(this.contents)&&this.contents.add(e)}addIn(e,t){Nt(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){const s=_(this);e.anchor=!t||s.has(t)?B(t||"a",s):t}return new K(e.anchor)}createNode(e,t,s){let n;if("function"==typeof t)e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){const e=e=>"number"==typeof e||e instanceof String||e instanceof Number,s=t.filter(e).map(String);s.length>0&&(t=t.concat(s)),n=t}else void 0===s&&t&&(s=t,t=void 0);const{aliasDuplicateObjects:i,anchorPrefix:o,flow:r,keepUndefined:a,onTagObj:c,tag:l}=s??{},{onAnchor:u,setAnchors:f,sourceObjects:h}=function(e,t){const s=[],n=new Map;let i=null;return{onAnchor:n=>{s.push(n),i||(i=_(e));const o=B(t,i);return i.add(o),o},setAnchors:()=>{for(const e of s){const t=n.get(e);if("object"!=typeof t||!t.anchor||!m(t.node)&&!g(t.node)){const t=new Error("Failed to resolve repeated object (this should not happen)");throw t.source=e,t}t.node.anchor=t.anchor}},sourceObjects:n}}(this,o||"a"),d=F(e,l,{aliasDuplicateObjects:i??!0,keepUndefined:a??!1,onAnchor:u,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:h});return r&&g(d)&&(d.flow=!0),f(),d}createPair(e,t,s={}){const n=this.createNode(e,null,s),i=this.createNode(t,null,s);return new ye(n,i)}delete(e){return!!Nt(this.contents)&&this.contents.delete(e)}deleteIn(e){return Y(e)?null!=this.contents&&(this.contents=null,!0):!!Nt(this.contents)&&this.contents.deleteIn(e)}get(e,t){return g(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Y(e)?!t&&m(this.contents)?this.contents.value:this.contents:g(this.contents)?this.contents.getIn(e,t):void 0}has(e){return!!g(this.contents)&&this.contents.has(e)}hasIn(e){return Y(e)?void 0!==this.contents:!!g(this.contents)&&this.contents.hasIn(e)}set(e,t){null==this.contents?this.contents=V(this.schema,[e],t):Nt(this.contents)&&this.contents.set(e,t)}setIn(e,t){Y(e)?this.contents=t:null==this.contents?this.contents=V(this.schema,Array.from(e),t):Nt(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){let s;switch("number"==typeof e&&(e=String(e)),e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new $({version:"1.1"}),s={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}),s={merge:!1,resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,s=null;break;default:{const t=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else{if(!s)throw new Error("With a null YAML version, the { schema: Schema } option is required");this.schema=new St(Object.assign(s,t))}}toJS({json:e,jsonArg:t,mapAsMap:s,maxAliasCount:n,onAnchor:i,reviver:o}={}){const r={anchors:new Map,doc:this,keep:!e,mapAsMap:!0===s,mapKeyWarned:!1,maxAliasCount:"number"==typeof n?n:100},a=M(this.contents,t??"",r);if("function"==typeof i)for(const{count:e,res:t}of r.anchors.values())i(t,e);return"function"==typeof o?j(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 function(e,t){const s=[];let n=!0===t.directives;if(!1!==t.directives&&e.directives){const t=e.directives.toString(e);t?(s.push(t),n=!0):e.directives.docStart&&(n=!0)}n&&s.push("---");const i=le(e,t),{commentString:o}=i.options;if(e.commentBefore){1!==s.length&&s.unshift("");const t=o(e.commentBefore);s.unshift(G(t,""))}let r=!1,a=null;if(e.contents){if(b(e.contents)){if(e.contents.spaceBefore&&n&&s.push(""),e.contents.commentBefore){const t=o(e.contents.commentBefore);s.push(G(t,""))}i.forceBlockIndent=!!e.comment,a=e.contents.comment}const t=a?void 0:()=>r=!0;let c=ue(e.contents,i,(()=>a=null),t);a&&(c+=Q(c,"",o(a))),"|"!==c[0]&&">"!==c[0]||"---"!==s[s.length-1]?s.push(c):s[s.length-1]=`--- ${c}`}else s.push(ue(e.contents,i));if(e.directives?.docEnd)if(e.comment){const t=o(e.comment);t.includes("\n")?(s.push("..."),s.push(G(t,""))):s.push(`... ${t}`)}else s.push("...");else{let t=e.comment;t&&r&&(t=t.replace(/^\n+/,"")),t&&(r&&!a||""===s[s.length-1]||s.push(""),s.push(G(o(t),"")))}return s.join("\n")+"\n"}(this,e)}}function Nt(e){if(g(e))return!0;throw new Error("Expected a YAML collection as document contents")}class Ot extends Error{constructor(e,t,s,n){super(),this.name=e,this.code=s,this.message=n,this.pos=t}}class At extends Ot{constructor(e,t,s){super("YAMLParseError",e,t,s)}}class Tt extends Ot{constructor(e,t,s){super("YAMLWarning",e,t,s)}}const It=(e,t)=>s=>{if(-1===s.pos[0])return;s.linePos=s.pos.map((e=>t.linePos(e)));const{line:n,col:i}=s.linePos[0];s.message+=` at line ${n}, column ${i}`;let o=i-1,r=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(o>=60&&r.length>80){const e=Math.min(o-39,r.length-79);r="…"+r.substring(e),o-=e-1}if(r.length>80&&(r=r.substring(0,79)+"…"),n>1&&/^ *$/.test(r.substring(0,o))){let s=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);s.length>80&&(s=s.substring(0,79)+"…\n"),r=s+r}if(/[^ ]/.test(r)){let e=1;const t=s.linePos[1];t&&t.line===n&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-o)));const a=" ".repeat(o)+"^".repeat(e);s.message+=`:\n\n${r}\n${a}\n`}};function Lt(e,{flow:t,indicator:s,next:n,offset:i,onError:o,startOnNewline:r}){let a=!1,c=r,l=r,u="",f="",h=!1,d=!1,p=!1,m=null,y=null,g=null,b=null,k=null;for(const n of e)switch(p&&("space"!==n.type&&"newline"!==n.type&&"comma"!==n.type&&o(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),p=!1),n.type){case"space":!t&&c&&"doc-start"!==s&&"\t"===n.source[0]&&o(n,"TAB_AS_INDENT","Tabs are not allowed as indentation"),l=!0;break;case"comment":{l||o(n,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const e=n.source.substring(1)||" ";u?u+=f+e:u=e,f="",c=!1;break}case"newline":c?u?u+=n.source:a=!0:f+=n.source,c=!0,h=!0,(m||y)&&(d=!0),l=!0;break;case"anchor":m&&o(n,"MULTIPLE_ANCHORS","A node can have at most one anchor"),n.source.endsWith(":")&&o(n.offset+n.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),m=n,null===k&&(k=n.offset),c=!1,l=!1,p=!0;break;case"tag":y&&o(n,"MULTIPLE_TAGS","A node can have at most one tag"),y=n,null===k&&(k=n.offset),c=!1,l=!1,p=!0;break;case s:(m||y)&&o(n,"BAD_PROP_ORDER",`Anchors and tags must be after the ${n.source} indicator`),b&&o(n,"UNEXPECTED_TOKEN",`Unexpected ${n.source} in ${t??"collection"}`),b=n,c=!1,l=!1;break;case"comma":if(t){g&&o(n,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),g=n,c=!1,l=!1;break}default:o(n,"UNEXPECTED_TOKEN",`Unexpected ${n.type} token`),c=!1,l=!1}const w=e[e.length-1],v=w?w.offset+w.source.length:i;return p&&n&&"space"!==n.type&&"newline"!==n.type&&"comma"!==n.type&&("scalar"!==n.type||""!==n.source)&&o(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),{comma:g,found:b,spaceBefore:a,comment:u,hasNewline:h,hasNewlineAfterProp:d,anchor:m,tag:y,end:v,start:k??v}}function xt(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes("\n"))return!0;if(e.end)for(const t of e.end)if("newline"===t.type)return!0;return!1;case"flow-collection":for(const t of e.items){for(const e of t.start)if("newline"===e.type)return!0;if(t.sep)for(const e of t.sep)if("newline"===e.type)return!0;if(xt(t.key)||xt(t.value))return!0}return!1;default:return!0}}function $t(e,t,s){if("flow-collection"===t?.type){const n=t.end[0];n.indent!==e||"]"!==n.source&&"}"!==n.source||!xt(t)||s(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function Ct(e,t,s){const{uniqueKeys:n}=e.options;if(!1===n)return!1;const i="function"==typeof n?n:(t,s)=>t===s||m(t)&&m(s)&&t.value===s.value&&!("<<"===t.value&&e.schema.merge);return t.some((e=>i(e.key,s)))}const _t="All mapping items must start at the same column";function Bt(e,t,s,n){let i="";if(e){let o=!1,r="";for(const a of e){const{source:e,type:c}=a;switch(c){case"space":o=!0;break;case"comment":{s&&!o&&n(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const t=e.substring(1)||" ";i?i+=r+t:i=t,r="";break}case"newline":i&&(r+=e),o=!0;break;default:n(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}const jt="Block collections are not allowed within flow collections",Mt=e=>e&&("block-map"===e.type||"block-seq"===e.type);function Dt(e,t,s,n,i,o){const r="block-map"===s.type?function({composeNode:e,composeEmptyNode:t},s,n,i,o){const r=new(o?.nodeClass??Se)(s.schema);s.atRoot&&(s.atRoot=!1);let a=n.offset,c=null;for(const o of n.items){const{start:l,key:u,sep:f,value:h}=o,d=Lt(l,{indicator:"explicit-key-ind",next:u??f?.[0],offset:a,onError:i,startOnNewline:!0}),p=!d.found;if(p){if(u&&("block-seq"===u.type?i(a,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in u&&u.indent!==n.indent&&i(a,"BAD_INDENT",_t)),!d.anchor&&!d.tag&&!f){c=d.end,d.comment&&(r.comment?r.comment+="\n"+d.comment:r.comment=d.comment);continue}(d.hasNewlineAfterProp||xt(u))&&i(u??l[l.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else d.found?.indent!==n.indent&&i(a,"BAD_INDENT",_t);const m=d.end,y=u?e(s,u,d,i):t(s,m,l,null,d,i);s.schema.compat&&$t(n.indent,u,i),Ct(s,r.items,y)&&i(m,"DUPLICATE_KEY","Map keys must be unique");const g=Lt(f??[],{indicator:"map-value-ind",next:h,offset:y.range[2],onError:i,startOnNewline:!u||"block-scalar"===u.type});if(a=g.end,g.found){p&&("block-map"!==h?.type||g.hasNewline||i(a,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),s.options.strict&&d.start0){const e=Bt(d,m,s.options.strict,i);e.comment&&(c.comment?c.comment+="\n"+e.comment:c.comment=e.comment),c.range=[n.offset,m,e.offset]}else c.range=[n.offset,m,m];return c}(e,t,s,n,o),a=r.constructor;return"!"===i||i===a.tagName?(r.tag=a.tagName,r):(i&&(r.tag=i),r)}function Kt(e,t,s){const n=e.offset,i=function({offset:e,props:t},s,n){if("block-scalar-header"!==t[0].type)return n(t[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:i}=t[0],o=i[0];let r=0,a="",c=-1;for(let t=1;t=0;--e){const t=r[e][1];if(""!==t&&"\r"!==t)break;a=e}if(0===a){const t="+"===i.chomp&&r.length>0?"\n".repeat(Math.max(1,r.length-1)):"";let s=n+i.length;return e.source&&(s+=e.source.length),{value:t,type:o,comment:i.comment,range:[n,s,s]}}let c=e.indent+i.indent,l=e.offset+i.length,u=0;for(let e=0;ec&&(c=t.length),l+=t.length+n.length+1}for(let e=r.length-1;e>=a;--e)r[e][0].length>c&&(a=e+1);let f="",h="",d=!1;for(let e=0;ec||"\t"===n[0]?(" "===h?h="\n":d||"\n"!==h||(h="\n\n"),f+=h+t.slice(c)+n,h="\n",d=!0):""===n?"\n"===h?f+="\n":h="\n":(f+=h+n,h=" ",d=!1)}switch(i.chomp){case"-":break;case"+":for(let e=a;es(n+e,t,i);switch(i){case"scalar":a=U.PLAIN,c=function(e,t){let s="";switch(e[0]){case"\t":s="a tab character";break;case",":s="flow indicator character ,";break;case"%":s="directive indicator character %";break;case"|":case">":s=`block scalar indicator ${e[0]}`;break;case"@":case"`":s=`reserved character ${e[0]}`}return s&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${s}`),qt(e)}(o,l);break;case"single-quoted-scalar":a=U.QUOTE_SINGLE,c=function(e,t){return"'"===e[e.length-1]&&1!==e.length||t(e.length,"MISSING_CHAR","Missing closing 'quote"),qt(e.slice(1,-1)).replace(/''/g,"'")}(o,l);break;case"double-quoted-scalar":a=U.QUOTE_DOUBLE,c=function(e,t){let s="";for(let n=1;nt?e.slice(t,n+1):i)}else s+=i}return'"'===e[e.length-1]&&1!==e.length||t(e.length,"MISSING_CHAR",'Missing closing "quote'),s}(o,l);break;default:return s(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${i}`),{value:"",type:null,comment:"",range:[n,n+o.length,n+o.length]}}const u=n+o.length,f=Bt(r,u,t,s);return{value:c,type:a,comment:f.comment,range:[n,u,f.offset]}}function qt(e){let t,s;try{t=new RegExp("(.*?)(?n(s,"TAG_RESOLVE_FAILED",e))):null,u=s&&l?function(e,t,s,n,i){if("!"===s)return e[c];const o=[];for(const t of e.tags)if(!t.collection&&t.tag===s){if(!t.default||!t.test)return t;o.push(t)}for(const e of o)if(e.test?.test(t))return e;const r=e.knownTags[s];return r&&!r.collection?(e.tags.push(Object.assign({},r,{default:!1,test:void 0})),r):(i(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,"tag:yaml.org,2002:str"!==s),e[c])}(e.schema,i,l,s,n):"scalar"===t.type?function({directives:e,schema:t},s,n,i){const o=t.tags.find((e=>e.default&&e.test?.test(s)))||t[c];if(t.compat){const r=t.compat.find((e=>e.default&&e.test?.test(s)))??t[c];o.tag!==r.tag&&i(n,"TAG_RESOLVE_FAILED",`Value may be parsed as either ${e.tagString(o.tag)} or ${e.tagString(r.tag)}`,!0)}return o}(e,i,t,n):e.schema[c];let f;try{const o=u.resolve(i,(e=>n(s??t,"TAG_RESOLVE_FAILED",e)),e.options);f=m(o)?o:new U(o)}catch(e){const o=e instanceof Error?e.message:String(e);n(s??t,"TAG_RESOLVE_FAILED",o),f=new U(i)}return f.range=a,f.source=i,o&&(f.type=o),l&&(f.tag=l),u.format&&(f.format=u.format),r&&(f.comment=r),f}function Yt(e,t,s){if(t){null===s&&(s=t.length);for(let n=s-1;n>=0;--n){let s=t[n];switch(s.type){case"space":case"comment":case"newline":e-=s.source.length;continue}for(s=t[++n];"space"===s?.type;)e+=s.source.length,s=t[++n];break}}return e}const Jt={composeNode:Wt,composeEmptyNode:Gt};function Wt(e,t,s,n){const{spaceBefore:i,comment:o,anchor:r,tag:a}=s;let c,l=!0;switch(t.type){case"alias":c=function({options:e},{offset:t,source:s,end:n},i){const o=new K(s.substring(1));""===o.source&&i(t,"BAD_ALIAS","Alias cannot be an empty string"),o.source.endsWith(":")&&i(t+s.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const r=t+s.length,a=Bt(n,r,e.strict,i);return o.range=[t,r,a.offset],a.comment&&(o.comment=a.comment),o}(e,t,n),(r||a)&&n(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=Vt(e,t,a,n),r&&(c.anchor=r.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=function(e,t,s,n,i){const o=n?t.directives.tagName(n.source,(e=>i(n,"TAG_RESOLVE_FAILED",e))):null,r="block-map"===s.type?"map":"block-seq"===s.type?"seq":"{"===s.start.source?"map":"seq";if(!n||!o||"!"===o||o===Se.tagName&&"map"===r||o===Ne.tagName&&"seq"===r||!r)return Dt(e,t,s,i,o);let a=t.schema.tags.find((e=>e.tag===o&&e.collection===r));if(!a){const c=t.schema.knownTags[o];if(!c||c.collection!==r)return c?.collection?i(n,"BAD_COLLECTION_TYPE",`${c.tag} used for ${r} collection, but expects ${c.collection}`,!0):i(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Dt(e,t,s,i,o);t.schema.tags.push(Object.assign({},c,{default:!1})),a=c}const c=Dt(e,t,s,i,o,a),l=a.resolve?.(c,(e=>i(n,"TAG_RESOLVE_FAILED",e)),t.options)??c,u=b(l)?l:new U(l);return u.range=c.range,u.tag=o,a?.format&&(u.format=a.format),u}(Jt,e,t,a,n),r&&(c.anchor=r.source.substring(1));break;default:n(t,"UNEXPECTED_TOKEN","error"===t.type?t.message:`Unsupported token (type: ${t.type})`),c=Gt(e,t.offset,void 0,null,s,n),l=!1}return r&&""===c.anchor&&n(r,"BAD_ALIAS","Anchor cannot be an empty string"),i&&(c.spaceBefore=!0),o&&("scalar"===t.type&&""===t.source?c.comment=o:c.commentBefore=o),e.options.keepSourceTokens&&l&&(c.srcToken=t),c}function Gt(e,t,s,n,{spaceBefore:i,comment:o,anchor:r,tag:a,end:c},l){const u=Vt(e,{type:"scalar",offset:Yt(t,s,n),indent:-1,source:""},a,l);return r&&(u.anchor=r.source.substring(1),""===u.anchor&&l(r,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(u.spaceBefore=!0),o&&(u.comment=o,u.range[2]=c),u}function Qt(e){if("number"==typeof e)return[e,e+1];if(Array.isArray(e))return 2===e.length?e:[e[0],e[1]];const{offset:t,source:s}=e;return[t,t+("string"==typeof s?s.length:1)]}function Ht(e){let t="",s=!1,n=!1;for(let i=0;i{const i=Qt(e);n?this.warnings.push(new Tt(i,t,s)):this.errors.push(new At(i,t,s))},this.directives=new $({version:e.version||"1.2"}),this.options=e}decorate(e,t){const{comment:s,afterEmptyLine:n}=Ht(this.prelude);if(s){const i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${s}`:s;else if(n||e.directives.docStart||!i)e.commentBefore=s;else if(g(i)&&!i.flow&&i.items.length>0){let e=i.items[0];p(e)&&(e=e.key);const t=e.commentBefore;e.commentBefore=t?`${s}\n${t}`:s}else{const e=i.commentBefore;i.commentBefore=e?`${s}\n${e}`:s}}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:Ht(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,s=-1){for(const t of e)yield*this.next(t);yield*this.end(t,s)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,((t,s,n)=>{const i=Qt(e);i[0]+=t,this.onError(i,"BAD_DIRECTIVE",s,n)})),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{const t=function(e,t,{offset:s,start:n,value:i,end:o},r){const a=Object.assign({_directives:t},e),c=new Et(void 0,a),l={atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=Lt(n,{indicator:"doc-start",next:i??o?.[0],offset:s,onError:r,startOnNewline:!0});u.found&&(c.directives.docStart=!0,!i||"block-map"!==i.type&&"block-seq"!==i.type||u.hasNewline||r(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=i?Wt(l,i,u,r):Gt(l,u.end,n,null,u,r);const f=c.contents.range[2],h=Bt(o,f,!1,r);return h.comment&&(c.comment=h.comment),c.range=[s,f,h.offset],c}(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,s=new At(Qt(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(s):this.doc.errors.push(s);break}case"doc-end":{if(!this.doc){const t="Unexpected doc-end without preceding document";this.errors.push(new At(Qt(e),"UNEXPECTED_TOKEN",t));break}this.doc.directives.docEnd=!0;const t=Bt(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){const e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new At(Qt(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 e=Object.assign({_directives:this.directives},this.options),s=new Et(void 0,e);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),s.range=[0,t,t],this.decorate(s,!1),yield s}}}function zt(e,t=!0,s){if(e){const n=(e,t,n)=>{const i="number"==typeof e?e:Array.isArray(e)?e[0]:e.offset;if(!s)throw new At([i,i+1],t,n);s(i,t,n)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Pt(e,t,n);case"block-scalar":return Kt(e,t,n)}}return null}function Zt(e,t){const{implicitKey:s=!1,indent:n,inFlow:i=!1,offset:o=-1,type:r="PLAIN"}=t,a=ce({type:r,value:e},{implicitKey:s,indent:n>0?" ".repeat(n):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:n,source:"\n"}];switch(a[0]){case"|":case">":{const e=a.indexOf("\n"),t=a.substring(0,e),s=a.substring(e+1)+"\n",i=[{type:"block-scalar-header",offset:o,indent:n,source:t}];return ts(i,c)||i.push({type:"newline",offset:-1,indent:n,source:"\n"}),{type:"block-scalar",offset:o,indent:n,props:i,source:s}}case'"':return{type:"double-quoted-scalar",offset:o,indent:n,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:o,indent:n,source:a,end:c};default:return{type:"scalar",offset:o,indent:n,source:a,end:c}}}function es(e,t,s={}){let{afterKey:n=!1,implicitKey:i=!1,inFlow:o=!1,type:r}=s,a="indent"in e?e.indent:null;if(n&&"number"==typeof a&&(a+=2),!r)switch(e.type){case"single-quoted-scalar":r="QUOTE_SINGLE";break;case"double-quoted-scalar":r="QUOTE_DOUBLE";break;case"block-scalar":{const t=e.props[0];if("block-scalar-header"!==t.type)throw new Error("Invalid block scalar header");r=">"===t.source[0]?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:r="PLAIN"}const c=ce({type:r,value:t},{implicitKey:i||null===a,indent:null!==a&&a>0?" ".repeat(a):"",inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":!function(e,t){const s=t.indexOf("\n"),n=t.substring(0,s),i=t.substring(s+1)+"\n";if("block-scalar"===e.type){const t=e.props[0];if("block-scalar-header"!==t.type)throw new Error("Invalid block scalar header");t.source=n,e.source=i}else{const{offset:t}=e,s="indent"in e?e.indent:-1,o=[{type:"block-scalar-header",offset:t,indent:s,source:n}];ts(o,"end"in e?e.end:void 0)||o.push({type:"newline",offset:-1,indent:s,source:"\n"});for(const t of Object.keys(e))"type"!==t&&"offset"!==t&&delete e[t];Object.assign(e,{type:"block-scalar",indent:s,props:o,source:i})}}(e,c);break;case'"':ss(e,c,"double-quoted-scalar");break;case"'":ss(e,c,"single-quoted-scalar");break;default:ss(e,c,"scalar")}}function ts(e,t){if(t)for(const s of t)switch(s.type){case"space":case"comment":e.push(s);break;case"newline":return e.push(s),!0}return!1}function ss(e,t,s){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=s,e.source=t;break;case"block-scalar":{const n=e.props.slice(1);let i=t.length;"block-scalar-header"===e.props[0].type&&(i-=e.props[0].source.length);for(const e of n)e.offset+=i;delete e.props,Object.assign(e,{type:s,source:t,end:n});break}case"block-map":case"block-seq":{const n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:"\n"};delete e.items,Object.assign(e,{type:s,source:t,end:[n]});break}default:{const n="indent"in e?e.indent:-1,i="end"in e&&Array.isArray(e.end)?e.end.filter((e=>"space"===e.type||"comment"===e.type||"newline"===e.type)):[];for(const t of Object.keys(e))"type"!==t&&"offset"!==t&&delete e[t];Object.assign(e,{type:s,indent:n,source:t,end:i})}}}const ns=e=>"type"in e?is(e):os(e);function is(e){switch(e.type){case"block-scalar":{let t="";for(const s of e.props)t+=is(s);return t+e.source}case"block-map":case"block-seq":{let t="";for(const s of e.items)t+=os(s);return t}case"flow-collection":{let t=e.start.source;for(const s of e.items)t+=os(s);for(const s of e.end)t+=s.source;return t}case"document":{let t=os(e);if(e.end)for(const s of e.end)t+=s.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(const s of e.end)t+=s.source;return t}}}function os({start:e,key:t,sep:s,value:n}){let i="";for(const t of e)i+=t.source;if(t&&(i+=is(t)),s)for(const e of s)i+=e.source;return n&&(i+=is(n)),i}const rs=Symbol("break visit"),as=Symbol("skip children"),cs=Symbol("remove item");function ls(e,t){"type"in e&&"document"===e.type&&(e={start:e.start,value:e.value}),us(Object.freeze([]),e,t)}function us(e,t,s){let n=s(t,e);if("symbol"==typeof n)return n;for(const i of["key","value"]){const o=t[i];if(o&&"items"in o){for(let t=0;t{let s=e;for(const[e,n]of t){const t=s?.[e];if(!t||!("items"in t))return;s=t.items[n]}return s},ls.parentCollection=(e,t)=>{const s=ls.itemAtPath(e,t.slice(0,-1)),n=t[t.length-1][0],i=s?.[n];if(i&&"items"in i)return i;throw new Error("Parent collection not found")};const fs="\ufeff",hs="",ds="",ps="",ms=e=>!!e&&"items"in e,ys=e=>!!e&&("scalar"===e.type||"single-quoted-scalar"===e.type||"double-quoted-scalar"===e.type||"block-scalar"===e.type);function gs(e){switch(e){case fs:return"";case hs:return"";case ds:return"";case ps:return"";default:return JSON.stringify(e)}}function bs(e){switch(e){case fs:return"byte-order-mark";case hs:return"doc-mode";case ds:return"flow-error-end";case ps:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case"\n":case"\r\n":return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function ks(e){switch(e){case void 0:case" ":case"\n":case"\r":case"\t":return!0;default:return!1}}const ws="0123456789ABCDEFabcdef".split(""),vs="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()".split(""),Ss=",[]{}".split(""),Es=" ,[]{}\n\r\t".split(""),Ns=e=>!e||Es.includes(e);class Os{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){if(e){if("string"!=typeof e)throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let s=this.next??"stream";for(;s&&(t||this.hasChars(1));)s=yield*this.parseNext(s)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;" "===t||"\t"===t;)t=this.buffer[++e];return!t||"#"===t||"\n"===t||"\r"===t&&"\n"===this.buffer[e+1]}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let s=0;for(;" "===t;)t=this.buffer[++s+e];if("\r"===t){const t=this.buffer[s+e+1];if("\n"===t||!t&&!this.atEnd)return e+s+1}return"\n"===t||s>=this.indentNext||!t&&!this.atEnd?e+s:-1}if("-"===t||"."===t){const t=this.buffer.substr(e,3);if(("---"===t||"..."===t)&&ks(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return("number"!=typeof e||-1!==e&&ethis.indentValue&&!ks(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)&&ks(t)){const e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);const e=this.getLine();if(null===e)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(Ns),"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,s=-1;do{e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=s=t):t=0,t+=(yield*this.pushSpaces(!0))}while(e+t>0);const n=this.getLine();if(null===n)return this.setNext("flow");if((-1!==s&&s"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if("-"!==t)break}return yield*this.pushUntil((e=>ks(e)||"#"===e))}*parseBlockScalar(){let e,t=this.pos-1,s=0;e:for(let n=this.pos;e=this.buffer[n];++n)switch(e){case" ":s+=1;break;case"\n":t=n,s=0;break;case"\r":{const e=this.buffer[n+1];if(!e&&!this.atEnd)return this.setNext("block-scalar");if("\n"===e)break}default:break e}if(!e&&!this.atEnd)return this.setNext("block-scalar");if(s>=this.indentNext){-1===this.blockScalarIndent?this.indentNext=s:this.indentNext+=this.blockScalarIndent;do{const e=this.continueScalar(t+1);if(-1===e)break;t=this.buffer.indexOf("\n",e)}while(-1!==t);if(-1===t){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}if(!this.blockScalarKeep)for(;;){let e=t-1,n=this.buffer[e];"\r"===n&&(n=this.buffer[--e]);const i=e;for(;" "===n||"\t"===n;)n=this.buffer[--e];if(!("\n"===n&&e>=this.pos&&e+1+s>i))break;t=e}return yield ps,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){const e=this.flowLevel>0;let t,s=this.pos-1,n=this.pos-1;for(;t=this.buffer[++n];)if(":"===t){const t=this.buffer[n+1];if(ks(t)||e&&","===t)break;s=n}else if(ks(t)){let i=this.buffer[n+1];if("\r"===t&&("\n"===i?(n+=1,t="\n",i=this.buffer[n+1]):s=n),"#"===i||e&&Ss.includes(i))break;if("\n"===t){const e=this.continueScalar(n+1);if(-1===e)break;n=Math.max(n,e-2)}}else{if(e&&Ss.includes(t))break;s=n}return t||this.atEnd?(yield ps,yield*this.pushToIndex(s+1,!0),e?"flow":"doc"):this.setNext("plain-scalar")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){const s=this.buffer.slice(this.pos,e);return s?(yield s,this.pos+=s.length,s.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(Ns))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{const e=this.flowLevel>0,t=this.charAt(1);if(ks(t)||e&&Ss.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(;!ks(t)&&">"!==t;)t=this.buffer[++e];return yield*this.pushToIndex(">"===t?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(vs.includes(t))t=this.buffer[++e];else{if("%"!==t||!ws.includes(this.buffer[e+1])||!ws.includes(this.buffer[e+2]))break;t=this.buffer[e+=3]}return yield*this.pushToIndex(e,!1)}}*pushNewline(){const e=this.buffer[this.pos];return"\n"===e?yield*this.pushCount(1):"\r"===e&&"\n"===this.charAt(1)?yield*this.pushCount(2):0}*pushSpaces(e){let t,s=this.pos-1;do{t=this.buffer[++s]}while(" "===t||e&&"\t"===t);const n=s-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=s),n}*pushUntil(e){let t=this.pos,s=this.buffer[t];for(;!e(s);)s=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}class As{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,s=this.lineStarts.length;for(;t>1;this.lineStarts[n]=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;"space"===e[++t]?.type;);return e.splice(t,e.length)}function Cs(e){if("flow-seq-start"===e.start.type)for(const t of e.items)!t.sep||t.value||Ts(t.start,"explicit-key-ind")||Ts(t.sep,"map-value-ind")||(t.key&&(t.value=t.key),delete t.key,Ls(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}class _s{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 Os,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&0===this.offset&&this.onNewLine(0);for(const s of this.lexer.lex(e,t))yield*this.next(s);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar)return this.atScalar=!1,yield*this.step(),void(this.offset+=e.length);const t=bs(e);if(t)if("scalar"===t)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 t=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:t,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("doc-end"!==this.type||e&&"doc-end"===e.type){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()}else{for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source})}}peek(e){return this.stack[this.stack.length-e]}*pop(e){const t=e??this.stack.pop();if(t)if(0===this.stack.length)yield t;else{const e=this.peek(1);switch("block-scalar"===t.type?t.indent="indent"in e?e.indent:0:"flow-collection"===t.type&&"document"===e.type&&(t.indent=0),"flow-collection"===t.type&&Cs(t),e.type){case"document":e.value=t;break;case"block-scalar":e.props.push(t);break;case"block-map":{const s=e.items[e.items.length-1];if(s.value)return e.items.push({start:[],key:t,sep:[]}),void(this.onKeyLine=!0);if(!s.sep)return Object.assign(s,{key:t,sep:[]}),void(this.onKeyLine=!Ts(s.start,"explicit-key-ind"));s.value=t;break}case"block-seq":{const s=e.items[e.items.length-1];s.value?e.items.push({start:[],value:t}):s.value=t;break}case"flow-collection":{const s=e.items[e.items.length-1];return void(!s||s.value?e.items.push({start:[],key:t,sep:[]}):s.sep?s.value=t:Object.assign(s,{key:t,sep:[]}))}default:yield*this.pop(),yield*this.pop(t)}if(!("document"!==e.type&&"block-map"!==e.type&&"block-seq"!==e.type||"block-map"!==t.type&&"block-seq"!==t.type)){const s=t.items[t.items.length-1];s&&!s.sep&&!s.value&&s.start.length>0&&-1===Is(s.start)&&(0===t.indent||s.start.every((e=>"comment"!==e.type||e.indent=e.indent){const s=!this.onKeyLine&&this.indent===e.indent&&t.sep&&"seq-item-ind"!==this.type;let n=[];if(s&&t.sep&&!t.value){const s=[];for(let n=0;ne.indent&&(s.length=0);break;default:s.length=0}}s.length>=2&&(n=t.sep.splice(s[1]))}switch(this.type){case"anchor":case"tag":return void(s||t.value?(n.push(this.sourceToken),e.items.push({start:n}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken));case"explicit-key-ind":return t.sep||Ts(t.start,"explicit-key-ind")?s||t.value?(n.push(this.sourceToken),e.items.push({start:n})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]}):t.start.push(this.sourceToken),void(this.onKeyLine=!0);case"map-value-ind":if(Ts(t.start,"explicit-key-ind"))if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ts(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]});else if(Ls(t.key)&&!Ts(t.sep,"newline")){const e=$s(t.start),s=t.key,n=t.sep;n.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:e,key:s,sep:n}]})}else n.length>0?t.sep=t.sep.concat(n,this.sourceToken):t.sep.push(this.sourceToken);else if(Ts(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{const e=$s(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||s?e.items.push({start:n,key:null,sep:[this.sourceToken]}):Ts(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]});return void(this.onKeyLine=!0);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const i=this.flowScalar(this.type);return void(s||t.value?(e.items.push({start:n,key:i,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(i):(Object.assign(t,{key:i,sep:[]}),this.onKeyLine=!0))}default:{const i=this.startBlockValue(e);if(i)return s&&"block-seq"!==i.type&&Ts(t.start,"explicit-key-ind")&&e.items.push({start:n}),void this.stack.push(i)}}}yield*this.pop(),yield*this.step()}*blockSequence(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){const s="end"in t.value?t.value.end:void 0,n=Array.isArray(s)?s[s.length-1]:void 0;"comment"===n?.type?s?.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 s=e.items[e.items.length-2],n=s?.value?.end;if(Array.isArray(n))return Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),void e.items.pop()}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;return void t.start.push(this.sourceToken);case"seq-item-ind":if(this.indent!==e.indent)break;return void(t.value||Ts(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken))}if(this.indent>e.indent){const t=this.startBlockValue(e);if(t)return void this.stack.push(t)}yield*this.pop(),yield*this.step()}*flowCollection(e){const t=e.items[e.items.length-1];if("flow-error-end"===this.type){let e;do{yield*this.pop(),e=this.peek(1)}while(e&&"flow-collection"===e.type)}else if(0===e.end.length){switch(this.type){case"comma":case"explicit-key-ind":return void(!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken));case"map-value-ind":return void(!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]}));case"space":case"comment":case"newline":case"anchor":case"tag":return void(!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken));case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const s=this.flowScalar(this.type);return void(!t||t.value?e.items.push({start:[],key:s,sep:[]}):t.sep?this.stack.push(s):Object.assign(t,{key:s,sep:[]}))}case"flow-map-end":case"flow-seq-end":return void e.end.push(this.sourceToken)}const s=this.startBlockValue(e);s?this.stack.push(s):(yield*this.pop(),yield*this.step())}else{const t=this.peek(2);if("block-map"===t.type&&("map-value-ind"===this.type&&t.indent===e.indent||"newline"===this.type&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if("map-value-ind"===this.type&&"flow-collection"!==t.type){const s=$s(xs(t));Cs(e);const n=e.end.splice(1,e.end.length);n.push(this.sourceToken);const i={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf("\n")+1;for(;0!==e;)this.onNewLine(this.offset+e),e=this.source.indexOf("\n",e)+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=$s(xs(e));return t.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t}]}}case"map-value-ind":{this.onKeyLine=!0;const t=$s(xs(e));return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return"comment"===this.type&&!(this.indent<=t)&&e.every((e=>"newline"===e.type||"space"===e.type))}*documentEnd(e){"doc-mode"!==this.type&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],"newline"===this.type&&(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;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],"newline"===this.type&&(yield*this.pop())}}}function Bs(e){const t=!1!==e.prettyErrors;return{lineCounter:e.lineCounter||t&&new As||null,prettyErrors:t}}function js(e,t={}){const{lineCounter:s,prettyErrors:n}=Bs(t),i=new _s(s?.addNewLine),o=new Xt(t),r=Array.from(o.compose(i.parse(e)));if(n&&s)for(const t of r)t.errors.forEach(It(e,s)),t.warnings.forEach(It(e,s));return r.length>0?r:Object.assign([],{empty:!0},o.streamInfo())}function Ms(e,t={}){const{lineCounter:s,prettyErrors:n}=Bs(t),i=new _s(s?.addNewLine),o=new Xt(t);let r=null;for(const t of o.compose(i.parse(e),!0,e.length))if(r){if("silent"!==r.options.logLevel){r.errors.push(new At(t.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}}else r=t;return n&&s&&(r.errors.forEach(It(e,s)),r.warnings.forEach(It(e,s))),r}function Ds(e,t,s){let n;"function"==typeof t?n=t:void 0===s&&t&&"object"==typeof t&&(s=t);const i=Ms(e,s);if(!i)return null;if(i.warnings.forEach((e=>fe(i.options.logLevel,e))),i.errors.length>0){if("silent"!==i.options.logLevel)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:n},s))}function Ks(e,t,s){let n=null;if("function"==typeof t||Array.isArray(t)?n=t:void 0===s&&t&&(s=t),"string"==typeof s&&(s=s.length),"number"==typeof s){const e=Math.round(s);s=e<1?void 0:e>8?{indent:8}:{indent:e}}if(void 0===e){const{keepUndefined:e}=s??t??{};if(!e)return}return new Et(e,n,s).toString(s)}const Ps=n;YAML=t})(); \ No newline at end of file diff --git a/clover/www/topics.html b/clover/www/topics.html index a5f6bc92f..0c7ed7ca1 100644 --- a/clover/www/topics.html +++ b/clover/www/topics.html @@ -4,7 +4,7 @@ - +