jupystar
Version:
Converter from Jupyter notebook (ipynb) to Starboard notebook
1 lines • 101 kB
JavaScript
var e={Char:{ANCHOR:"&",COMMENT:"#",TAG:"!",DIRECTIVES_END:"-",DOCUMENT_END:"."},LogLevel:Object.assign(["silent","error","warn","debug"],{SILENT:0,ERROR:1,WARN:2,DEBUG:3}),Type:{ALIAS:"ALIAS",BLANK_LINE:"BLANK_LINE",BLOCK_FOLDED:"BLOCK_FOLDED",BLOCK_LITERAL:"BLOCK_LITERAL",COMMENT:"COMMENT",DIRECTIVE:"DIRECTIVE",DOCUMENT:"DOCUMENT",FLOW_MAP:"FLOW_MAP",FLOW_SEQ:"FLOW_SEQ",MAP:"MAP",MAP_KEY:"MAP_KEY",MAP_VALUE:"MAP_VALUE",PLAIN:"PLAIN",QUOTE_DOUBLE:"QUOTE_DOUBLE",QUOTE_SINGLE:"QUOTE_SINGLE",SEQ:"SEQ",SEQ_ITEM:"SEQ_ITEM"},defaultTagPrefix:"tag:yaml.org,2002:",defaultTags:{MAP:"tag:yaml.org,2002:map",SEQ:"tag:yaml.org,2002:seq",STR:"tag:yaml.org,2002:str"}};function t(e){const t=[0];let n=e.indexOf("\n");for(;-1!==n;)n+=1,t.push(n),n=e.indexOf("\n",n);return t}function n(e){let n,r;return"string"==typeof e?(n=t(e),r=e):(Array.isArray(e)&&(e=e[0]),e&&e.context&&(e.lineStarts||(e.lineStarts=t(e.context.src)),n=e.lineStarts,r=e.context.src)),{lineStarts:n,src:r}}function r(e,t){const{lineStarts:r,src:s}=n(t);if(!r||!(e>=1)||e>r.length)return null;const o=r[e-1];let i=r[e];for(;i&&i>o&&"\n"===s[i-1];)--i;return s.slice(o,i)}var s={getLine:r,getLinePos:function(e,t){if("number"!=typeof e||e<0)return null;const{lineStarts:r,src:s}=n(t);if(!r||!s||e>s.length)return null;for(let t=0;t<r.length;++t){const n=r[t];if(e<n)return{line:t,col:e-r[t-1]+1};if(e===n)return{line:t+1,col:1}}const o=r.length;return{line:o,col:e-r[o-1]+1}},getPrettyContext:function({start:e,end:t},n,s=80){let o=r(e.line,n);if(!o)return null;let{col:i}=e;if(o.length>s)if(i<=s-10)o=o.substr(0,s-1)+"…";else{const e=Math.round(s/2);o.length>i+e&&(o=o.substr(0,i+e-1)+"…"),i-=o.length-s,o="…"+o.substr(1-s)}let a=1,c="";return t&&(t.line===e.line&&i+(t.col-e.col)<=s+1?a=t.col-e.col:(a=Math.min(o.length+1,s)-i,c="…")),`${o}\n${i>1?" ".repeat(i-1):""}${"^".repeat(a)}${c}`}};class o{static copy(e){return new o(e.start,e.end)}constructor(e,t){this.start=e,this.end=t||e}isEmpty(){return"number"!=typeof this.start||!this.end||this.end<=this.start}setOrigRange(e,t){const{start:n,end:r}=this;if(0===e.length||r<=e[0])return this.origStart=n,this.origEnd=r,t;let s=t;for(;s<e.length&&!(e[s]>n);)++s;this.origStart=n+s;const o=s;for(;s<e.length&&!(e[s]>=r);)++s;return this.origEnd=r+s,o}}var i={Range:o};class a{static addStringTerminator(e,t,n){if("\n"===n[n.length-1])return n;const r=a.endOfWhiteSpace(e,t);return r>=e.length||"\n"===e[r]?n+"\n":n}static atDocumentBoundary(t,n,r){const s=t[n];if(!s)return!0;const o=t[n-1];if(o&&"\n"!==o)return!1;if(r){if(s!==r)return!1}else if(s!==e.Char.DIRECTIVES_END&&s!==e.Char.DOCUMENT_END)return!1;const i=t[n+1],a=t[n+2];if(i!==s||a!==s)return!1;const c=t[n+3];return!c||"\n"===c||"\t"===c||" "===c}static endOfIdentifier(e,t){let n=e[t];const r="<"===n,s=r?["\n","\t"," ",">"]:["\n","\t"," ","[","]","{","}",","];for(;n&&-1===s.indexOf(n);)n=e[t+=1];return r&&">"===n&&(t+=1),t}static endOfIndent(e,t){let n=e[t];for(;" "===n;)n=e[t+=1];return t}static endOfLine(e,t){let n=e[t];for(;n&&"\n"!==n;)n=e[t+=1];return t}static endOfWhiteSpace(e,t){let n=e[t];for(;"\t"===n||" "===n;)n=e[t+=1];return t}static startOfLine(e,t){let n=e[t-1];if("\n"===n)return t;for(;n&&"\n"!==n;)n=e[t-=1];return t+1}static endOfBlockIndent(e,t,n){const r=a.endOfIndent(e,n);if(r>n+t)return r;{const t=a.endOfWhiteSpace(e,r),n=e[t];if(!n||"\n"===n)return t}return null}static atBlank(e,t,n){const r=e[t];return"\n"===r||"\t"===r||" "===r||n&&!r}static nextNodeIsIndented(e,t,n){return!(!e||t<0)&&(t>0||n&&"-"===e)}static normalizeOffset(e,t){const n=e[t];return n?"\n"!==n&&"\n"===e[t-1]?t-1:a.endOfWhiteSpace(e,t):t}static foldNewline(e,t,n){let r=0,s=!1,o="",i=e[t+1];for(;" "===i||"\t"===i||"\n"===i;){switch(i){case"\n":r=0,t+=1,o+="\n";break;case"\t":r<=n&&(s=!0),t=a.endOfWhiteSpace(e,t+2)-1;break;case" ":r+=1,t+=1}i=e[t+1]}return o||(o=" "),i&&r<=n&&(s=!0),{fold:o,offset:t,error:s}}constructor(e,t,n){Object.defineProperty(this,"context",{value:n||null,writable:!0}),this.error=null,this.range=null,this.valueRange=null,this.props=t||[],this.type=e,this.value=null}getPropValue(e,t,n){if(!this.context)return null;const{src:r}=this.context,s=this.props[e];return s&&r[s.start]===t?r.slice(s.start+(n?1:0),s.end):null}get anchor(){for(let t=0;t<this.props.length;++t){const n=this.getPropValue(t,e.Char.ANCHOR,!0);if(null!=n)return n}return null}get comment(){const t=[];for(let n=0;n<this.props.length;++n){const r=this.getPropValue(n,e.Char.COMMENT,!0);null!=r&&t.push(r)}return t.length>0?t.join("\n"):null}commentHasRequiredWhitespace(e){const{src:t}=this.context;if(this.header&&e===this.header.end)return!1;if(!this.valueRange)return!1;const{end:n}=this.valueRange;return e!==n||a.atBlank(t,n-1)}get hasComment(){if(this.context){const{src:t}=this.context;for(let n=0;n<this.props.length;++n)if(t[this.props[n].start]===e.Char.COMMENT)return!0}return!1}get hasProps(){if(this.context){const{src:t}=this.context;for(let n=0;n<this.props.length;++n)if(t[this.props[n].start]!==e.Char.COMMENT)return!0}return!1}get includesTrailingLines(){return!1}get jsonLike(){return-1!==[e.Type.FLOW_MAP,e.Type.FLOW_SEQ,e.Type.QUOTE_DOUBLE,e.Type.QUOTE_SINGLE].indexOf(this.type)}get rangeAsLinePos(){if(!this.range||!this.context)return;const e=s.getLinePos(this.range.start,this.context.root);if(!e)return;return{start:e,end:s.getLinePos(this.range.end,this.context.root)}}get rawValue(){if(!this.valueRange||!this.context)return null;const{start:e,end:t}=this.valueRange;return this.context.src.slice(e,t)}get tag(){for(let t=0;t<this.props.length;++t){const n=this.getPropValue(t,e.Char.TAG,!1);if(null!=n){if("<"===n[1])return{verbatim:n.slice(2,-1)};{const[e,t,r]=n.match(/^(.*!)([^!]*)$/);return{handle:t,suffix:r}}}}return null}get valueRangeContainsNewline(){if(!this.valueRange||!this.context)return!1;const{start:e,end:t}=this.valueRange,{src:n}=this.context;for(let r=e;r<t;++r)if("\n"===n[r])return!0;return!1}parseComment(t){const{src:n}=this.context;if(n[t]===e.Char.COMMENT){const e=a.endOfLine(n,t+1),r=new i.Range(t,e);return this.props.push(r),e}return t}setOrigRanges(e,t){return this.range&&(t=this.range.setOrigRange(e,t)),this.valueRange&&this.valueRange.setOrigRange(e,t),this.props.forEach((n=>n.setOrigRange(e,t))),t}toString(){const{context:{src:e},range:t,value:n}=this;if(null!=n)return n;const r=e.slice(t.start,t.end);return a.addStringTerminator(e,t.end,r)}}var c={Node:a};class l extends Error{constructor(e,t,n){if(!(n&&t instanceof c.Node))throw new Error(`Invalid arguments for new ${e}`);super(),this.name=e,this.message=n,this.source=t}makePretty(){if(!this.source)return;this.nodeType=this.source.type;const e=this.source.context&&this.source.context.root;if("number"==typeof this.offset){this.range=new i.Range(this.offset,this.offset+1);const t=e&&s.getLinePos(this.offset,e);if(t){const e={line:t.line,col:t.col+1};this.linePos={start:t,end:e}}delete this.offset}else this.range=this.source.range,this.linePos=this.source.rangeAsLinePos;if(this.linePos){const{line:t,col:n}=this.linePos.start;this.message+=` at line ${t}, column ${n}`;const r=e&&s.getPrettyContext(this.linePos,e);r&&(this.message+=`:\n\n${r}\n`)}delete this.source}}var u={YAMLError:l,YAMLReferenceError:class extends l{constructor(e,t){super("YAMLReferenceError",e,t)}},YAMLSemanticError:class extends l{constructor(e,t){super("YAMLSemanticError",e,t)}},YAMLSyntaxError:class extends l{constructor(e,t){super("YAMLSyntaxError",e,t)}},YAMLWarning:class extends l{constructor(e,t){super("YAMLWarning",e,t)}}};class f extends c.Node{constructor(){super(e.Type.BLANK_LINE)}get includesTrailingLines(){return!0}parse(e,t){return this.context=e,this.range=new i.Range(t,t+1),t+1}}var p={BlankLine:f};class h extends c.Node{constructor(e,t){super(e,t),this.node=null}get includesTrailingLines(){return!!this.node&&this.node.includesTrailingLines}parse(t,n){this.context=t;const{parseNode:r,src:s}=t;let{atLineStart:o,lineStart:a}=t;o||this.type!==e.Type.SEQ_ITEM||(this.error=new u.YAMLSemanticError(this,"Sequence items must not have preceding content on the same line"));const l=o?n-a:t.indent;let f=c.Node.endOfWhiteSpace(s,n+1),h=s[f];const d="#"===h,m=[];let g=null;for(;"\n"===h||"#"===h;){if("#"===h){const e=c.Node.endOfLine(s,f+1);m.push(new i.Range(f,e)),f=e}else{o=!0,a=f+1;"\n"===s[c.Node.endOfWhiteSpace(s,a)]&&0===m.length&&(g=new p.BlankLine,a=g.parse({src:s},a)),f=c.Node.endOfIndent(s,a)}h=s[f]}if(c.Node.nextNodeIsIndented(h,f-(a+l),this.type!==e.Type.SEQ_ITEM)?this.node=r({atLineStart:o,inCollection:!1,indent:l,lineStart:a,parent:this},f):h&&a>n+1&&(f=a-1),this.node){if(g){const e=t.parent.items||t.parent.contents;e&&e.push(g)}m.length&&Array.prototype.push.apply(this.props,m),f=this.node.range.end}else if(d){const e=m[0];this.props.push(e),f=e.end}else f=c.Node.endOfLine(s,n+1);const y=this.node?this.node.valueRange.end:f;return this.valueRange=new i.Range(n,y),f}setOrigRanges(e,t){return t=super.setOrigRanges(e,t),this.node?this.node.setOrigRanges(e,t):t}toString(){const{context:{src:e},node:t,range:n,value:r}=this;if(null!=r)return r;const s=t?e.slice(n.start,t.range.start)+String(t):e.slice(n.start,n.end);return c.Node.addStringTerminator(e,n.end,s)}}var d={CollectionItem:h};class m extends c.Node{constructor(){super(e.Type.COMMENT)}parse(e,t){this.context=e;const n=this.parseComment(t);return this.range=new i.Range(t,n),n}}var g={Comment:m};function y(t){let n=t;for(;n instanceof d.CollectionItem;)n=n.node;if(!(n instanceof v))return null;const r=n.items.length;let s=-1;for(let t=r-1;t>=0;--t){const r=n.items[t];if(r.type===e.Type.COMMENT){const{indent:e,lineStart:n}=r.context;if(e>0&&r.range.start>=n+e)break;s=t}else{if(r.type!==e.Type.BLANK_LINE)break;s=t}}if(-1===s)return null;const o=n.items.splice(s,r-s),i=o[0].range.start;for(;n.range.end=i,n.valueRange&&n.valueRange.end>i&&(n.valueRange.end=i),n!==t;)n=n.context.parent;return o}class v extends c.Node{static nextContentHasIndent(e,t,n){const r=c.Node.endOfLine(e,t)+1,s=e[t=c.Node.endOfWhiteSpace(e,r)];return!!s&&(t>=r+n||("#"===s||"\n"===s)&&v.nextContentHasIndent(e,t,n))}constructor(t){super(t.type===e.Type.SEQ_ITEM?e.Type.SEQ:e.Type.MAP);for(let e=t.props.length-1;e>=0;--e)if(t.props[e].start<t.context.lineStart){this.props=t.props.slice(0,e+1),t.props=t.props.slice(e+1);const n=t.props[0]||t.valueRange;t.range.start=n.start;break}this.items=[t];const n=y(t);n&&Array.prototype.push.apply(this.items,n)}get includesTrailingLines(){return this.items.length>0}parse(t,n){this.context=t;const{parseNode:r,src:s}=t;let o=c.Node.startOfLine(s,n);const a=this.items[0];a.context.parent=this,this.valueRange=i.Range.copy(a.valueRange);const l=a.range.start-a.context.lineStart;let f=n;f=c.Node.normalizeOffset(s,f);let h=s[f],d=c.Node.endOfWhiteSpace(s,o)===f,m=!1;for(;h;){for(;"\n"===h||"#"===h;){if(d&&"\n"===h&&!m){const e=new p.BlankLine;if(f=e.parse({src:s},f),this.valueRange.end=f,f>=s.length){h=null;break}this.items.push(e),f-=1}else if("#"===h){if(f<o+l&&!v.nextContentHasIndent(s,f,l))return f;const e=new g.Comment;if(f=e.parse({indent:l,lineStart:o,src:s},f),this.items.push(e),this.valueRange.end=f,f>=s.length){h=null;break}}if(o=f+1,f=c.Node.endOfIndent(s,o),c.Node.atBlank(s,f)){const e=c.Node.endOfWhiteSpace(s,f),t=s[e];t&&"\n"!==t&&"#"!==t||(f=e)}h=s[f],d=!0}if(!h)break;if(f!==o+l&&(d||":"!==h)){if(f<o+l){o>n&&(f=o);break}if(!this.error){const e="All collection items must start at the same column";this.error=new u.YAMLSyntaxError(this,e)}}if(a.type===e.Type.SEQ_ITEM){if("-"!==h){o>n&&(f=o);break}}else if("-"===h&&!this.error){const e=s[f+1];if(!e||"\n"===e||"\t"===e||" "===e){const e="A collection cannot be both a mapping and a sequence";this.error=new u.YAMLSyntaxError(this,e)}}const t=r({atLineStart:d,inCollection:!0,indent:l,lineStart:o,parent:this},f);if(!t)return f;if(this.items.push(t),this.valueRange.end=t.valueRange.end,f=c.Node.normalizeOffset(s,t.range.end),h=s[f],d=!1,m=t.includesTrailingLines,h){let e=f-1,t=s[e];for(;" "===t||"\t"===t;)t=s[--e];"\n"===t&&(o=e+1,d=!0)}const i=y(t);i&&Array.prototype.push.apply(this.items,i)}return f}setOrigRanges(e,t){return t=super.setOrigRanges(e,t),this.items.forEach((n=>{t=n.setOrigRanges(e,t)})),t}toString(){const{context:{src:e},items:t,range:n,value:r}=this;if(null!=r)return r;let s=e.slice(n.start,t[0].range.start)+String(t[0]);for(let e=1;e<t.length;++e){const n=t[e],{atLineStart:r,indent:o}=n.context;if(r)for(let e=0;e<o;++e)s+=" ";s+=String(n)}return c.Node.addStringTerminator(e,n.end,s)}}var b={Collection:v,grabCollectionEndComments:y};class S extends c.Node{constructor(){super(e.Type.DIRECTIVE),this.name=null}get parameters(){const e=this.rawValue;return e?e.trim().split(/[ \t]+/):[]}parseName(e){const{src:t}=this.context;let n=e,r=t[n];for(;r&&"\n"!==r&&"\t"!==r&&" "!==r;)r=t[n+=1];return this.name=t.slice(e,n),n}parseParameters(e){const{src:t}=this.context;let n=e,r=t[n];for(;r&&"\n"!==r&&"#"!==r;)r=t[n+=1];return this.valueRange=new i.Range(e,n),n}parse(e,t){this.context=e;let n=this.parseName(t+1);return n=this.parseParameters(n),n=this.parseComment(n),this.range=new i.Range(t,n),n}}var w={Directive:S};class O extends c.Node{static startCommentOrEndBlankLine(e,t){const n=c.Node.endOfWhiteSpace(e,t),r=e[n];return"#"===r||"\n"===r?n:t}constructor(){super(e.Type.DOCUMENT),this.directives=null,this.contents=null,this.directivesEndMarker=null,this.documentEndMarker=null}parseDirectives(t){const{src:n}=this.context;this.directives=[];let r=!0,s=!1,o=t;for(;!c.Node.atDocumentBoundary(n,o,e.Char.DIRECTIVES_END);)switch(o=O.startCommentOrEndBlankLine(n,o),n[o]){case"\n":if(r){const e=new p.BlankLine;o=e.parse({src:n},o),o<n.length&&this.directives.push(e)}else o+=1,r=!0;break;case"#":{const e=new g.Comment;o=e.parse({src:n},o),this.directives.push(e),r=!1}break;case"%":{const e=new w.Directive;o=e.parse({parent:this,src:n},o),this.directives.push(e),s=!0,r=!1}break;default:return s?this.error=new u.YAMLSemanticError(this,"Missing directives-end indicator line"):this.directives.length>0&&(this.contents=this.directives,this.directives=[]),o}return n[o]?(this.directivesEndMarker=new i.Range(o,o+3),o+3):(s?this.error=new u.YAMLSemanticError(this,"Missing directives-end indicator line"):this.directives.length>0&&(this.contents=this.directives,this.directives=[]),o)}parseContents(t){const{parseNode:n,src:r}=this.context;this.contents||(this.contents=[]);let s=t;for(;"-"===r[s-1];)s-=1;let o=c.Node.endOfWhiteSpace(r,t),a=s===t;for(this.valueRange=new i.Range(o);!c.Node.atDocumentBoundary(r,o,e.Char.DOCUMENT_END);){switch(r[o]){case"\n":if(a){const e=new p.BlankLine;o=e.parse({src:r},o),o<r.length&&this.contents.push(e)}else o+=1,a=!0;s=o;break;case"#":{const e=new g.Comment;o=e.parse({src:r},o),this.contents.push(e),a=!1}break;default:{const e=c.Node.endOfIndent(r,o),t=n({atLineStart:a,indent:-1,inFlow:!1,inCollection:!1,lineStart:s,parent:this},e);if(!t)return this.valueRange.end=e;this.contents.push(t),o=t.range.end,a=!1;const i=b.grabCollectionEndComments(t);i&&Array.prototype.push.apply(this.contents,i)}}o=O.startCommentOrEndBlankLine(r,o)}if(this.valueRange.end=o,r[o]&&(this.documentEndMarker=new i.Range(o,o+3),o+=3,r[o])){if(o=c.Node.endOfWhiteSpace(r,o),"#"===r[o]){const e=new g.Comment;o=e.parse({src:r},o),this.contents.push(e)}switch(r[o]){case"\n":o+=1;break;case void 0:break;default:this.error=new u.YAMLSyntaxError(this,"Document end marker line cannot have a non-comment suffix")}}return o}parse(e,t){e.root=this,this.context=e;const{src:n}=e;let r=65279===n.charCodeAt(t)?t+1:t;return r=this.parseDirectives(r),r=this.parseContents(r),r}setOrigRanges(e,t){return t=super.setOrigRanges(e,t),this.directives.forEach((n=>{t=n.setOrigRanges(e,t)})),this.directivesEndMarker&&(t=this.directivesEndMarker.setOrigRange(e,t)),this.contents.forEach((n=>{t=n.setOrigRanges(e,t)})),this.documentEndMarker&&(t=this.documentEndMarker.setOrigRange(e,t)),t}toString(){const{contents:t,directives:n,value:r}=this;if(null!=r)return r;let s=n.join("");return t.length>0&&((n.length>0||t[0].type===e.Type.COMMENT)&&(s+="---\n"),s+=t.join("")),"\n"!==s[s.length-1]&&(s+="\n"),s}}var E={Document:O};var L={defineProperty:function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}};class N extends c.Node{parse(e,t){this.context=e;const{src:n}=e;let r=c.Node.endOfIdentifier(n,t+1);return this.valueRange=new i.Range(t+1,r),r=c.Node.endOfWhiteSpace(n,r),r=this.parseComment(r),r}}var A={Alias:N};const T={CLIP:"CLIP",KEEP:"KEEP",STRIP:"STRIP"};class M extends c.Node{constructor(e,t){super(e,t),this.blockIndent=null,this.chomping=T.CLIP,this.header=null}get includesTrailingLines(){return this.chomping===T.KEEP}get strValue(){if(!this.valueRange||!this.context)return null;let{start:t,end:n}=this.valueRange;const{indent:r,src:s}=this.context;if(this.valueRange.isEmpty())return"";let o=null,i=s[n-1];for(;"\n"===i||"\t"===i||" "===i;){if(n-=1,n<=t){if(this.chomping===T.KEEP)break;return""}"\n"===i&&(o=n),i=s[n-1]}let a=n+1;o&&(this.chomping===T.KEEP?(a=o,n=this.valueRange.end):n=o);const l=r+this.blockIndent,u=this.type===e.Type.BLOCK_FOLDED;let f=!0,p="",h="",d=!1;for(let e=t;e<n;++e){for(let t=0;t<l&&" "===s[e];++t)e+=1;const t=s[e];if("\n"===t)"\n"===h?p+="\n":h="\n";else{const r=c.Node.endOfLine(s,e),o=s.slice(e,r);e=r,u&&(" "===t||"\t"===t)&&e<a?(" "===h?h="\n":d||f||"\n"!==h||(h="\n\n"),p+=h+o,h=r<n&&s[r]||"",d=!0):(p+=h+o,h=u&&e<a?" ":"\n",d=!1),f&&""!==o&&(f=!1)}}return this.chomping===T.STRIP?p:p+"\n"}parseBlockHeader(e){const{src:t}=this.context;let n=e+1,r="";for(;;){const s=t[n];switch(s){case"-":this.chomping=T.STRIP;break;case"+":this.chomping=T.KEEP;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":r+=s;break;default:return this.blockIndent=Number(r)||null,this.header=new i.Range(e,n),n}n+=1}}parseBlockValue(e){const{indent:t,src:n}=this.context,r=!!this.blockIndent;let s=e,o=e,a=1;for(let e=n[s];"\n"===e&&(s+=1,!c.Node.atDocumentBoundary(n,s));e=n[s]){const e=c.Node.endOfBlockIndent(n,t,s);if(null===e)break;const i=n[e],l=e-(s+t);if(this.blockIndent){if(i&&"\n"!==i&&l<this.blockIndent){if("#"===n[e])break;if(!this.error){const e=`Block scalars must not be less indented than their ${r?"explicit indentation indicator":"first line"}`;this.error=new u.YAMLSemanticError(this,e)}}}else if("\n"!==n[e]){if(l<a){const e="Block scalars with more-indented leading empty lines must use an explicit indentation indicator";this.error=new u.YAMLSemanticError(this,e)}this.blockIndent=l}else l>a&&(a=l);s="\n"===n[e]?e:o=c.Node.endOfLine(n,e)}return this.chomping!==T.KEEP&&(s=n[o]?o+1:o),this.valueRange=new i.Range(e+1,s),s}parse(e,t){this.context=e;const{src:n}=e;let r=this.parseBlockHeader(t);return r=c.Node.endOfWhiteSpace(n,r),r=this.parseComment(r),r=this.parseBlockValue(r),r}setOrigRanges(e,t){return t=super.setOrigRanges(e,t),this.header?this.header.setOrigRange(e,t):t}}var x={BlockValue:M,Chomp:T};class k extends c.Node{constructor(e,t){super(e,t),this.items=null}prevNodeIsJsonLike(t=this.items.length){const n=this.items[t-1];return!!n&&(n.jsonLike||n.type===e.Type.COMMENT&&this.prevNodeIsJsonLike(t-1))}parse(e,t){this.context=e;const{parseNode:n,src:r}=e;let{indent:s,lineStart:o}=e,a=r[t];this.items=[{char:a,offset:t}];let l=c.Node.endOfWhiteSpace(r,t+1);for(a=r[l];a&&"]"!==a&&"}"!==a;){switch(a){case"\n":o=l+1;if("\n"===r[c.Node.endOfWhiteSpace(r,o)]){const e=new p.BlankLine;o=e.parse({src:r},o),this.items.push(e)}if(l=c.Node.endOfIndent(r,o),l<=o+s&&(a=r[l],l<o+s||"]"!==a&&"}"!==a)){const e="Insufficient indentation in flow collection";this.error=new u.YAMLSemanticError(this,e)}break;case",":this.items.push({char:a,offset:l}),l+=1;break;case"#":{const e=new g.Comment;l=e.parse({src:r},l),this.items.push(e)}break;case"?":case":":{const e=r[l+1];if("\n"===e||"\t"===e||" "===e||","===e||":"===a&&this.prevNodeIsJsonLike()){this.items.push({char:a,offset:l}),l+=1;break}}default:{const e=n({atLineStart:!1,inCollection:!1,inFlow:!0,indent:-1,lineStart:o,parent:this},l);if(!e)return this.valueRange=new i.Range(t,l),l;this.items.push(e),l=c.Node.normalizeOffset(r,e.range.end)}}l=c.Node.endOfWhiteSpace(r,l),a=r[l]}return this.valueRange=new i.Range(t,l+1),a&&(this.items.push({char:a,offset:l}),l=c.Node.endOfWhiteSpace(r,l+1),l=this.parseComment(l)),l}setOrigRanges(e,t){return t=super.setOrigRanges(e,t),this.items.forEach((n=>{if(n instanceof c.Node)t=n.setOrigRanges(e,t);else if(0===e.length)n.origOffset=n.offset;else{let r=t;for(;r<e.length&&!(e[r]>n.offset);)++r;n.origOffset=n.offset+r,t=r}})),t}toString(){const{context:{src:e},items:t,range:n,value:r}=this;if(null!=r)return r;const s=t.filter((e=>e instanceof c.Node));let o="",i=n.start;return s.forEach((t=>{const n=e.slice(i,t.range.start);i=t.range.end,o+=n+String(t),"\n"===o[o.length-1]&&"\n"!==e[i-1]&&"\n"===e[i]&&(i+=1)})),o+=e.slice(i,n.end),c.Node.addStringTerminator(e,n.end,o)}}var C={FlowCollection:k};class P extends c.Node{static endOfLine(e,t,n){let r=e[t],s=t;for(;r&&"\n"!==r&&(!n||"["!==r&&"]"!==r&&"{"!==r&&"}"!==r&&","!==r);){const t=e[s+1];if(":"===r&&(!t||"\n"===t||"\t"===t||" "===t||n&&","===t))break;if((" "===r||"\t"===r)&&"#"===t)break;s+=1,r=t}return s}get strValue(){if(!this.valueRange||!this.context)return null;let{start:e,end:t}=this.valueRange;const{src:n}=this.context;let r=n[t-1];for(;e<t&&("\n"===r||"\t"===r||" "===r);)r=n[--t-1];let s="";for(let r=e;r<t;++r){const e=n[r];if("\n"===e){const{fold:e,offset:t}=c.Node.foldNewline(n,r,-1);s+=e,r=t}else if(" "===e||"\t"===e){const o=r;let i=n[r+1];for(;r<t&&(" "===i||"\t"===i);)r+=1,i=n[r+1];"\n"!==i&&(s+=r>o?n.slice(o,r+1):e)}else s+=e}const o=n[e];switch(o){case"\t":{const e="Plain value cannot start with a tab character";return{errors:[new u.YAMLSemanticError(this,e)],str:s}}case"@":case"`":{const e=`Plain value cannot start with reserved character ${o}`;return{errors:[new u.YAMLSemanticError(this,e)],str:s}}default:return s}}parseBlockValue(e){const{indent:t,inFlow:n,src:r}=this.context;let s=e,o=e;for(let e=r[s];"\n"===e&&!c.Node.atDocumentBoundary(r,s+1);e=r[s]){const e=c.Node.endOfBlockIndent(r,t,s+1);if(null===e||"#"===r[e])break;"\n"===r[e]?s=e:(o=P.endOfLine(r,e,n),s=o)}return this.valueRange.isEmpty()&&(this.valueRange.start=e),this.valueRange.end=o,o}parse(e,t){this.context=e;const{inFlow:n,src:r}=e;let s=t;const o=r[s];return o&&"#"!==o&&"\n"!==o&&(s=P.endOfLine(r,t,n)),this.valueRange=new i.Range(t,s),s=c.Node.endOfWhiteSpace(r,s),s=this.parseComment(s),this.hasComment&&!this.valueRange.isEmpty()||(s=this.parseBlockValue(s)),s}}var $={PlainValue:P};class I extends c.Node{static endOfQuote(e,t){let n=e[t];for(;n&&'"'!==n;)n=e[t+="\\"===n?2:1];return t+1}get strValue(){if(!this.valueRange||!this.context)return null;const e=[],{start:t,end:n}=this.valueRange,{indent:r,src:s}=this.context;'"'!==s[n-1]&&e.push(new u.YAMLSyntaxError(this,'Missing closing "quote'));let o="";for(let i=t+1;i<n-1;++i){const t=s[i];if("\n"===t){c.Node.atDocumentBoundary(s,i+1)&&e.push(new u.YAMLSemanticError(this,"Document boundary indicators are not allowed within string values"));const{fold:t,offset:n,error:a}=c.Node.foldNewline(s,i,r);o+=t,i=n,a&&e.push(new u.YAMLSemanticError(this,"Multi-line double-quoted string needs to be sufficiently indented"))}else if("\\"===t)switch(i+=1,s[i]){case"0":o+="\0";break;case"a":o+="";break;case"b":o+="\b";break;case"e":o+="";break;case"f":o+="\f";break;case"n":o+="\n";break;case"r":o+="\r";break;case"t":o+="\t";break;case"v":o+="\v";break;case"N":o+="
";break;case"_":o+=" ";break;case"L":o+="\u2028";break;case"P":o+="\u2029";break;case" ":o+=" ";break;case'"':o+='"';break;case"/":o+="/";break;case"\\":o+="\\";break;case"\t":o+="\t";break;case"x":o+=this.parseCharCode(i+1,2,e),i+=2;break;case"u":o+=this.parseCharCode(i+1,4,e),i+=4;break;case"U":o+=this.parseCharCode(i+1,8,e),i+=8;break;case"\n":for(;" "===s[i+1]||"\t"===s[i+1];)i+=1;break;default:e.push(new u.YAMLSyntaxError(this,`Invalid escape sequence ${s.substr(i-1,2)}`)),o+="\\"+s[i]}else if(" "===t||"\t"===t){const e=i;let n=s[i+1];for(;" "===n||"\t"===n;)i+=1,n=s[i+1];"\n"!==n&&(o+=i>e?s.slice(e,i+1):t)}else o+=t}return e.length>0?{errors:e,str:o}:o}parseCharCode(e,t,n){const{src:r}=this.context,s=r.substr(e,t),o=s.length===t&&/^[0-9a-fA-F]+$/.test(s)?parseInt(s,16):NaN;return isNaN(o)?(n.push(new u.YAMLSyntaxError(this,`Invalid escape sequence ${r.substr(e-2,t+2)}`)),r.substr(e-2,t+2)):String.fromCodePoint(o)}parse(e,t){this.context=e;const{src:n}=e;let r=I.endOfQuote(n,t+1);return this.valueRange=new i.Range(t,r),r=c.Node.endOfWhiteSpace(n,r),r=this.parseComment(r),r}}var R={QuoteDouble:I};class _ extends c.Node{static endOfQuote(e,t){let n=e[t];for(;n;)if("'"===n){if("'"!==e[t+1])break;n=e[t+=2]}else n=e[t+=1];return t+1}get strValue(){if(!this.valueRange||!this.context)return null;const e=[],{start:t,end:n}=this.valueRange,{indent:r,src:s}=this.context;"'"!==s[n-1]&&e.push(new u.YAMLSyntaxError(this,"Missing closing 'quote"));let o="";for(let i=t+1;i<n-1;++i){const t=s[i];if("\n"===t){c.Node.atDocumentBoundary(s,i+1)&&e.push(new u.YAMLSemanticError(this,"Document boundary indicators are not allowed within string values"));const{fold:t,offset:n,error:a}=c.Node.foldNewline(s,i,r);o+=t,i=n,a&&e.push(new u.YAMLSemanticError(this,"Multi-line single-quoted string needs to be sufficiently indented"))}else if("'"===t)o+=t,i+=1,"'"!==s[i]&&e.push(new u.YAMLSyntaxError(this,"Unescaped single quote? This should not happen."));else if(" "===t||"\t"===t){const e=i;let n=s[i+1];for(;" "===n||"\t"===n;)i+=1,n=s[i+1];"\n"!==n&&(o+=i>e?s.slice(e,i+1):t)}else o+=t}return e.length>0?{errors:e,str:o}:o}parse(e,t){this.context=e;const{src:n}=e;let r=_.endOfQuote(n,t+1);return this.valueRange=new i.Range(t,r),r=c.Node.endOfWhiteSpace(n,r),r=this.parseComment(r),r}}var B={QuoteSingle:_};class j{static parseType(t,n,r){switch(t[n]){case"*":return e.Type.ALIAS;case">":return e.Type.BLOCK_FOLDED;case"|":return e.Type.BLOCK_LITERAL;case"{":return e.Type.FLOW_MAP;case"[":return e.Type.FLOW_SEQ;case"?":return!r&&c.Node.atBlank(t,n+1,!0)?e.Type.MAP_KEY:e.Type.PLAIN;case":":return!r&&c.Node.atBlank(t,n+1,!0)?e.Type.MAP_VALUE:e.Type.PLAIN;case"-":return!r&&c.Node.atBlank(t,n+1,!0)?e.Type.SEQ_ITEM:e.Type.PLAIN;case'"':return e.Type.QUOTE_DOUBLE;case"'":return e.Type.QUOTE_SINGLE;default:return e.Type.PLAIN}}constructor(t={},{atLineStart:n,inCollection:r,inFlow:s,indent:o,lineStart:a,parent:l}={}){L.defineProperty(this,"parseNode",((t,n)=>{if(c.Node.atDocumentBoundary(this.src,n))return null;const r=new j(this,t),{props:s,type:o,valueStart:a}=r.parseProps(n),l=function(t,n){switch(t){case e.Type.ALIAS:return new A.Alias(t,n);case e.Type.BLOCK_FOLDED:case e.Type.BLOCK_LITERAL:return new x.BlockValue(t,n);case e.Type.FLOW_MAP:case e.Type.FLOW_SEQ:return new C.FlowCollection(t,n);case e.Type.MAP_KEY:case e.Type.MAP_VALUE:case e.Type.SEQ_ITEM:return new d.CollectionItem(t,n);case e.Type.COMMENT:case e.Type.PLAIN:return new $.PlainValue(t,n);case e.Type.QUOTE_DOUBLE:return new R.QuoteDouble(t,n);case e.Type.QUOTE_SINGLE:return new B.QuoteSingle(t,n);default:return null}}(o,s);let f=l.parse(r,a);if(l.range=new i.Range(n,f),f<=n&&(l.error=new Error("Node#parse consumed no characters"),l.error.parseEnd=f,l.error.source=l,l.range.end=n+1),r.nodeStartsCollection(l)){l.error||r.atLineStart||r.parent.type!==e.Type.DOCUMENT||(l.error=new u.YAMLSyntaxError(l,"Block collection must not have preceding content here (e.g. directives-end indicator)"));const t=new b.Collection(l);return f=t.parse(new j(r),f),t.range=new i.Range(n,f),t}return l})),this.atLineStart=null!=n?n:t.atLineStart||!1,this.inCollection=null!=r?r:t.inCollection||!1,this.inFlow=null!=s?s:t.inFlow||!1,this.indent=null!=o?o:t.indent,this.lineStart=null!=a?a:t.lineStart,this.parent=null!=l?l:t.parent||{},this.root=t.root,this.src=t.src}nodeStartsCollection(e){const{inCollection:t,inFlow:n,src:r}=this;if(t||n)return!1;if(e instanceof d.CollectionItem)return!0;let s=e.range.end;return"\n"!==r[s]&&"\n"!==r[s-1]&&(s=c.Node.endOfWhiteSpace(r,s),":"===r[s])}parseProps(t){const{inFlow:n,parent:r,src:s}=this,o=[];let a=!1,l=s[t=this.atLineStart?c.Node.endOfIndent(s,t):c.Node.endOfWhiteSpace(s,t)];for(;l===e.Char.ANCHOR||l===e.Char.COMMENT||l===e.Char.TAG||"\n"===l;){if("\n"===l){const n=t+1,o=c.Node.endOfIndent(s,n),i=o-(n+this.indent),l=r.type===e.Type.SEQ_ITEM&&r.context.atLineStart;if(!c.Node.nextNodeIsIndented(s[o],i,!l))break;this.atLineStart=!0,this.lineStart=n,a=!1,t=o}else if(l===e.Char.COMMENT){const e=c.Node.endOfLine(s,t+1);o.push(new i.Range(t,e)),t=e}else{let n=c.Node.endOfIdentifier(s,t+1);l===e.Char.TAG&&","===s[n]&&/^[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+,\d\d\d\d(-\d\d){0,2}\/\S/.test(s.slice(t+1,n+13))&&(n=c.Node.endOfIdentifier(s,n+5)),o.push(new i.Range(t,n)),a=!0,t=c.Node.endOfWhiteSpace(s,n)}l=s[t]}a&&":"===l&&c.Node.atBlank(s,t+1,!0)&&(t-=1);return{props:o,type:j.parseType(s,t,n),valueStart:t}}}var Y={ParseContext:j};var D={parse:function(e){const t=[];-1!==e.indexOf("\r")&&(e=e.replace(/\r\n?/g,((e,n)=>(e.length>1&&t.push(n),"\n"))));const n=[];let r=0;do{const t=new E.Document,s=new Y.ParseContext({src:e});r=t.parse(s,r),n.push(t)}while(r<e.length);return n.setOrigRanges=()=>{if(0===t.length)return!1;for(let e=1;e<t.length;++e)t[e]-=e;let e=0;for(let r=0;r<n.length;++r)e=n[r].setOrigRanges(t,e);return t.splice(0,t.length),!0},n.toString=()=>n.join("...\n"),n}};var F={binaryOptions:{defaultType:e.Type.BLOCK_LITERAL,lineWidth:76},boolOptions:{trueStr:"true",falseStr:"false"},intOptions:{asBigInt:!1},nullOptions:{nullStr:"null"},strOptions:{defaultType:e.Type.PLAIN,defaultKeyType:e.Type.PLAIN,defaultQuoteSingle:!1,doubleQuoted:{jsonEncoding:!1,minMultiLineLength:40},fold:{lineWidth:80,minContentWidth:20}}};const W={get binary(){return F.binaryOptions},set binary(e){Object.assign(F.binaryOptions,e)},get bool(){return F.boolOptions},set bool(e){Object.assign(F.boolOptions,e)},get int(){return F.intOptions},set int(e){Object.assign(F.intOptions,e)},get null(){return F.nullOptions},set null(e){Object.assign(F.nullOptions,e)},get str(){return F.strOptions},set str(e){Object.assign(F.strOptions,e)}};var K={defaultOptions:{anchorPrefix:"a",customTags:null,indent:2,indentSeq:!0,keepCstNodes:!1,keepNodeTypes:!0,keepUndefined:!1,logLevel:"warn",mapAsMap:!1,maxAliasCount:100,prettyErrors:!0,simpleKeys:!1,version:"1.2"},documentOptions:{"1.0":{schema:"yaml-1.1",merge:!0,tagPrefixes:[{handle:"!",prefix:e.defaultTagPrefix},{handle:"!!",prefix:"tag:private.yaml.org,2002:"}]},1.1:{schema:"yaml-1.1",merge:!0,tagPrefixes:[{handle:"!",prefix:"!"},{handle:"!!",prefix:e.defaultTagPrefix}]},1.2:{schema:"core",merge:!1,resolveKnownTags:!0,tagPrefixes:[{handle:"!",prefix:"!"},{handle:"!!",prefix:e.defaultTagPrefix}]}},scalarOptions:W};var U={addComment:function(e,t,n){return n?-1===n.indexOf("\n")?`${e} #${n}`:`${e}\n`+n.replace(/^/gm,`${t||""}#`):e},addCommentBefore:function(e,t,n){return n?`#${n.replace(/[\s\S]^/gm,`$&${t}#`)}\n${t}${e}`:e}};var q=class{};var Q={toJS:function e(t,n,r){if(Array.isArray(t))return t.map(((t,n)=>e(t,String(n),r)));if(t&&"function"==typeof t.toJSON){const e=r&&r.anchors&&r.anchors.get(t);e&&(r.onCreate=t=>{e.res=t,delete r.onCreate});const s=t.toJSON(n,r);return e&&r.onCreate&&r.onCreate(s),s}return r&&r.keep||"bigint"!=typeof t?t:Number(t)}};var J={Scalar:class extends q{constructor(e){super(),this.value=e}toJSON(e,t){return t&&t.keep?this.value:Q.toJS(this.value,e,t)}toString(){return String(this.value)}},isScalarValue:e=>!e||"function"!=typeof e&&"object"!=typeof e};var V={createNode:function(t,n,r){if(t instanceof q)return t;const{onAlias:s,onTagObj:o,prevObjects:i,wrapScalars:a}=r,{map:c,seq:l,tags:u}=r.schema;n&&n.startsWith("!!")&&(n=e.defaultTagPrefix+n.slice(2));let f=function(e,t,n){if(t){const e=n.filter((e=>e.tag===t)),r=e.find((e=>!e.format))||e[0];if(!r)throw new Error(`Tag ${t} not found`);return r}return n.find((t=>t.identify&&t.identify(e)&&!t.format))}(t,n,u);if(!f){if("function"==typeof t.toJSON&&(t=t.toJSON()),!t||"object"!=typeof t)return a?new J.Scalar(t):t;f=t instanceof Map?c:t[Symbol.iterator]?l:c}o&&(o(f),delete r.onTagObj);const p={value:void 0,node:void 0};if(t&&"object"==typeof t){const e=i.get(t);if(e)return s(e);p.value=t,i.set(t,p)}return p.node=f.createNode?f.createNode(r.schema,t,r):a?new J.Scalar(t):t,n&&p.node instanceof q&&(p.node.tag=n),p.node}};function G(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){const n=t[e];if(Number.isInteger(n)&&n>=0){const e=[];e[n]=r,r=e}else{const e={};Object.defineProperty(e,n,{value:r,writable:!0,enumerable:!0,configurable:!0}),r=e}}return V.createNode(r,null,{onAlias(){throw new Error("Repeated objects are not supported here")},prevObjects:new Map,schema:e,wrapScalars:!1})}const z=e=>null==e||"object"==typeof e&&e[Symbol.iterator]().next().done;class H extends q{constructor(e){super(),L.defineProperty(this,"items",[]),this.schema=e}addIn(e,t){if(z(e))this.add(t);else{const[n,...r]=e,s=this.get(n,!0);if(s instanceof H)s.addIn(r,t);else{if(void 0!==s||!this.schema)throw new Error(`Expected YAML collection at ${n}. Remaining path: ${r}`);this.set(n,G(this.schema,r,t))}}}deleteIn([e,...t]){if(0===t.length)return this.delete(e);const n=this.get(e,!0);if(n instanceof H)return n.deleteIn(t);throw new Error(`Expected YAML collection at ${e}. Remaining path: ${t}`)}getIn([e,...t],n){const r=this.get(e,!0);return 0===t.length?!n&&r instanceof J.Scalar?r.value:r:r instanceof H?r.getIn(t,n):void 0}hasAllNullValues(){return this.items.every((e=>{if(!e||"PAIR"!==e.type)return!1;const t=e.value;return null==t||t instanceof J.Scalar&&null==t.value&&!t.commentBefore&&!t.comment&&!t.tag}))}hasIn([e,...t]){if(0===t.length)return this.has(e);const n=this.get(e,!0);return n instanceof H&&n.hasIn(t)}setIn([e,...t],n){if(0===t.length)this.set(e,n);else{const r=this.get(e,!0);if(r instanceof H)r.setIn(t,n);else{if(void 0!==r||!this.schema)throw new Error(`Expected YAML collection at ${e}. Remaining path: ${t}`);this.set(e,G(this.schema,t,n))}}}toJSON(){return null}toString(t,{blockItem:n,flowChars:r,isMap:s,itemIndent:o},i,a){const{indent:c,indentStep:l,stringify:u}=t,f=this.type===e.Type.FLOW_MAP||this.type===e.Type.FLOW_SEQ||t.inFlow;f&&(o+=l);const p=s&&this.hasAllNullValues();t=Object.assign({},t,{allNullValues:p,indent:o,inFlow:f,type:null});let h=!1,d=!1;const m=this.items.reduce(((e,n,r)=>{let s;n&&(!h&&n.spaceBefore&&e.push({type:"comment",str:""}),n.commentBefore&&n.commentBefore.match(/^.*$/gm).forEach((t=>{e.push({type:"comment",str:`#${t}`})})),n.comment&&(s=n.comment),f&&(!h&&n.spaceBefore||n.commentBefore||n.comment||n.key&&(n.key.commentBefore||n.key.comment)||n.value&&(n.value.commentBefore||n.value.comment))&&(d=!0)),h=!1;let i=u(n,t,(()=>s=null),(()=>h=!0));return f&&!d&&i.includes("\n")&&(d=!0),f&&r<this.items.length-1&&(i+=","),i=U.addComment(i,o,s),h&&(s||f)&&(h=!1),e.push({type:"item",str:i}),e}),[]);let g;if(0===m.length)g=r.start+r.end;else if(f){const{start:e,end:t}=r,n=m.map((e=>e.str));if(d||n.reduce(((e,t)=>e+t.length+2),2)>H.maxFlowStringSingleLineLength){g=e;for(const e of n)g+=e?`\n${l}${c}${e}`:"\n";g+=`\n${c}${t}`}else g=`${e} ${n.join(" ")} ${t}`}else{const e=m.map(n);g=e.shift();for(const t of e)g+=t?`\n${c}${t}`:"\n"}return this.comment?(g+="\n"+this.comment.replace(/^/gm,`${c}#`),i&&i()):h&&a&&a(),g}}L.defineProperty(H,"maxFlowStringSingleLineLength",60);var Z={Collection:H,collectionFromPath:G,isEmptyPath:z};var X={warn:function(t,n){e.LogLevel.indexOf(t)>=e.LogLevel.WARN&&("undefined"!=typeof process&&process.emitWarning?process.emitWarning(n):console.warn(n))}};function ee(e){let t=e instanceof J.Scalar?e.value:e;return t&&"string"==typeof t&&(t=Number(t)),Number.isInteger(t)&&t>=0?t:null}class te extends Z.Collection{add(e){this.items.push(e)}delete(e){const t=ee(e);if("number"!=typeof t)return!1;return this.items.splice(t,1).length>0}get(e,t){const n=ee(e);if("number"!=typeof n)return;const r=this.items[n];return!t&&r instanceof J.Scalar?r.value:r}has(e){const t=ee(e);return"number"==typeof t&&t<this.items.length}set(e,t){const n=ee(e);if("number"!=typeof n)throw new Error(`Expected a valid index, not ${e}.`);const r=this.items[n];r instanceof J.Scalar&&J.isScalarValue(t)?r.value=t:this.items[n]=t}toJSON(e,t){const n=[];t&&t.onCreate&&t.onCreate(n);let r=0;for(const e of this.items)n.push(Q.toJS(e,String(r++),t));return n}toString(e,t,n){return e?super.toString(e,{blockItem:e=>"comment"===e.type?e.str:`- ${e.str}`,flowChars:{start:"[",end:"]"},isMap:!1,itemIndent:(e.indent||"")+" "},t,n):JSON.stringify(this)}}var ne={YAMLSeq:te};class re extends q{constructor(e,t=null){super(),this.key=e,this.value=t,this.type=re.Type.PAIR}get commentBefore(){return this.key instanceof q?this.key.commentBefore:void 0}set commentBefore(e){if(null==this.key&&(this.key=new J.Scalar(null)),!(this.key instanceof q)){throw new Error("Pair.commentBefore is an alias for Pair.key.commentBefore. To set it, the key must be a Node.")}this.key.commentBefore=e}addToJSMap(e,t){const n=Q.toJS(this.key,"",e);if(t instanceof Map){const r=Q.toJS(this.value,n,e);t.set(n,r)}else if(t instanceof Set)t.add(n);else{const r=function(e,t,n){if(null===t)return"";if("object"!=typeof t)return String(t);if(e instanceof q&&n&&n.doc){const t=e.toString({anchors:Object.create(null),doc:n.doc,indent:"",indentStep:n.indentStep,inFlow:!0,inStringifyKey:!0,stringify:n.stringify});if(!n.mapKeyWarned){let e=JSON.stringify(t);e.length>40&&(e=e.split("").splice(36,'..."').join("")),X.warn(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return t}return JSON.stringify(t)}(this.key,n,e),s=Q.toJS(this.value,r,e);r in t?Object.defineProperty(t,r,{value:s,writable:!0,enumerable:!0,configurable:!0}):t[r]=s}return t}toJSON(e,t){const n=t&&t.mapAsMap?new Map:{};return this.addToJSMap(t,n)}toString(t,n,r){if(!t||!t.doc)return JSON.stringify(this);const{indent:s,indentSeq:o,simpleKeys:i}=t.doc.options;let{key:a,value:c}=this,l=a instanceof q&&a.comment;if(i){if(l)throw new Error("With simple keys, key nodes cannot have comments");if(a instanceof Z.Collection){throw new Error("With simple keys, collection cannot be used as a key value")}}let u=!i&&(!a||l||(a instanceof q?a instanceof Z.Collection||a.type===e.Type.BLOCK_FOLDED||a.type===e.Type.BLOCK_LITERAL:"object"==typeof a));const{allNullValues:f,doc:p,indent:h,indentStep:d,stringify:m}=t;t=Object.assign({},t,{implicitKey:!u&&(i||!f),indent:h+d});let g=!1,y=m(a,t,(()=>l=null),(()=>g=!0));if(y=U.addComment(y,t.indent,l),!u&&y.length>1024){if(i)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");u=!0}if(f&&!i)return this.comment?(y=U.addComment(y,t.indent,this.comment),n&&n()):g&&!l&&r&&r(),t.inFlow&&!u?y:`? ${y}`;y=u?`? ${y}\n${h}:`:`${y}:`,this.comment&&(y=U.addComment(y,t.indent,this.comment),n&&n());let v="",b=null;if(c instanceof q){if(c.spaceBefore&&(v="\n"),c.commentBefore){v+=`\n${c.commentBefore.replace(/^/gm,`${t.indent}#`)}`}b=c.comment}else c&&"object"==typeof c&&(c=p.createNode(c));t.implicitKey=!1,!u&&!this.comment&&c instanceof J.Scalar&&(t.indentAtStart=y.length+1),g=!1,!o&&s>=2&&!t.inFlow&&!u&&c instanceof ne.YAMLSeq&&c.type!==e.Type.FLOW_SEQ&&!c.tag&&!p.anchors.getName(c)&&(t.indent=t.indent.substr(2));const S=m(c,t,(()=>b=null),(()=>g=!0));let w=" ";if(v||this.comment)w=`${v}\n${t.indent}`;else if(!u&&c instanceof Z.Collection){("["===S[0]||"{"===S[0])&&!S.includes("\n")||(w=`\n${t.indent}`)}else"\n"===S[0]&&(w="");return g&&!b&&r&&r(),U.addComment(y+w+S,t.indent,b)}}L.defineProperty(re,"Type",{PAIR:"PAIR",MERGE_PAIR:"MERGE_PAIR"});var se={Pair:re,createPair:function(e,t,n){const r=V.createNode(e,null,n),s=V.createNode(t,null,n);return new re(r,s)}};const oe=(e,t)=>{if(e instanceof ie){const n=t.get(e.source);return n.count*n.aliasCount}if(e instanceof Z.Collection){let n=0;for(const r of e.items){const e=oe(r,t);e>n&&(n=e)}return n}if(e instanceof se.Pair){const n=oe(e.key,t),r=oe(e.value,t);return Math.max(n,r)}return 1};class ie extends q{static stringify({range:e,source:t},{anchors:n,doc:r,implicitKey:s,inStringifyKey:o}){let i=Object.keys(n).find((e=>n[e]===t));if(!i&&o&&(i=r.anchors.getName(t)||r.anchors.newName()),i)return`*${i}${s?" ":""}`;const a=r.anchors.getName(t)?"Alias node must be after source node":"Source node not found for alias node";throw new Error(`${a} [${e}]`)}constructor(t){super(),this.source=t,this.type=e.Type.ALIAS}set tag(e){throw new Error("Alias nodes cannot have tags")}toJSON(e,t){if(!t)return Q.toJS(this.source,e,t);const{anchors:n,maxAliasCount:r}=t,s=n.get(this.source);if(!s||void 0===s.res){const e="This should not happen: Alias anchor was not resolved?";throw this.cstNode?new u.YAMLReferenceError(this.cstNode,e):new ReferenceError(e)}if(r>=0&&(s.count+=1,0===s.aliasCount&&(s.aliasCount=oe(this.source,n)),s.count*s.aliasCount>r)){const e="Excessive alias count indicates a resource exhaustion attack";throw this.cstNode?new u.YAMLReferenceError(this.cstNode,e):new ReferenceError(e)}return s.res}toString(e){return ie.stringify(this,e)}}L.defineProperty(ie,"default",!0);var ae={Alias:ie};var ce={resolveScalar:function(e,t){for(const{format:n,test:r,resolve:s}of t)if(r&&r.test(e)){let t=s(e);return t instanceof J.Scalar||(t=new J.Scalar(t)),n&&(t.format=n),t}return new J.Scalar(e)}};const le=(e,t)=>{let n=e[t+1];for(;" "===n||"\t"===n;){do{n=e[t+=1]}while(n&&"\n"!==n);n=e[t+1]}return t};var ue={FOLD_BLOCK:"block",FOLD_FLOW:"flow",FOLD_QUOTED:"quoted",foldFlowLines:function(e,t,n,{indentAtStart:r,lineWidth:s=80,minContentWidth:o=20,onFold:i,onOverflow:a}){if(!s||s<0)return e;const c=Math.max(1+o,1+s-t.length);if(e.length<=c)return e;const l=[],u={};let f,p,h=s-t.length;"number"==typeof r&&(r>s-Math.max(2,o)?l.push(0):h=s-r);let d,m=!1,g=-1,y=-1,v=-1;for("block"===n&&(g=le(e,g),-1!==g&&(h=g+c));d=e[g+=1];){if("quoted"===n&&"\\"===d){switch(y=g,e[g+1]){case"x":g+=3;break;case"u":g+=5;break;case"U":g+=9;break;default:g+=1}v=g}if("\n"===d)"block"===n&&(g=le(e,g)),h=g+c,f=void 0;else{if(" "===d&&p&&" "!==p&&"\n"!==p&&"\t"!==p){const t=e[g+1];t&&" "!==t&&"\n"!==t&&"\t"!==t&&(f=g)}if(g>=h)if(f)l.push(f),h=f+c,f=void 0;else if("quoted"===n){for(;" "===p||"\t"===p;)p=d,d=e[g+=1],m=!0;const t=g>v+1?g-2:y-1;if(u[t])return e;l.push(t),u[t]=!0,h=t+c,f=void 0}else m=!0}p=d}if(m&&a&&a(),0===l.length)return e;i&&i();let b=e.slice(0,l[0]);for(let r=0;r<l.length;++r){const s=l[r],o=l[r+1]||e.length;0===s?b=`\n${t}${e.slice(0,o)}`:("quoted"===n&&u[s]&&(b+=`${e[s]}\\`),b+=`\n${t}${e.slice(s+1,o)}`)}return b}};const fe=({indentAtStart:e})=>e?Object.assign({indentAtStart:e},F.strOptions.fold):F.strOptions.fold,pe=e=>/^(%|---|\.\.\.)/m.test(e);function he(e,t){const{implicitKey:n}=t,{jsonEncoding:r,minMultiLineLength:s}=F.strOptions.doubleQuoted,o=JSON.stringify(e);if(r)return o;const i=t.indent||(pe(e)?" ":"");let a="",c=0;for(let e=0,t=o[e];t;t=o[++e])if(" "===t&&"\\"===o[e+1]&&"n"===o[e+2]&&(a+=o.slice(c,e)+"\\ ",e+=1,c=e,t="\\"),"\\"===t)switch(o[e+1]){case"u":{a+=o.slice(c,e);const t=o.substr(e+2,4);switch(t){case"0000":a+="\\0";break;case"0007":a+="\\a";break;case"000b":a+="\\v";break;case"001b":a+="\\e";break;case"0085":a+="\\N";break;case"00a0":a+="\\_";break;case"2028":a+="\\L";break;case"2029":a+="\\P";break;default:"00"===t.substr(0,2)?a+="\\x"+t.substr(2):a+=o.substr(e,6)}e+=5,c=e+1}break;case"n":if(n||'"'===o[e+2]||o.length<s)e+=1;else{for(a+=o.slice(c,e)+"\n\n";"\\"===o[e+2]&&"n"===o[e+3]&&'"'!==o[e+4];)a+="\n",e+=2;a+=i," "===o[e+2]&&(a+="\\"),e+=1,c=e+1}break;default:e+=1}return a=c?a+o.slice(c):o,n?a:ue.foldFlowLines(a,i,ue.FOLD_QUOTED,fe(t))}function de(e,t){if(t.implicitKey){if(/\n/.test(e))return he(e,t)}else if(/[ \t]\n|\n[ \t]/.test(e))return he(e,t);const n=t.indent||(pe(e)?" ":""),r="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&\n${n}`)+"'";return t.implicitKey?r:ue.foldFlowLines(r,n,ue.FOLD_FLOW,fe(t))}function me({comment:t,type:n,value:r},s,o,i){if(/\n[\t ]+$/.test(r)||/^\s*$/.test(r))return he(r,s);const a=s.indent||(s.forceBlockIndent||pe(r)?" ":""),c=a?"2":"1",l=n!==e.Type.BLOCK_FOLDED&&(n===e.Type.BLOCK_LITERAL||!function(e,t){const n=e.length;if(n<=t)return!1;for(let r=0,s=0;r<n;++r)if("\n"===e[r]){if(r-s>t)return!0;if(s=r+1,n-s<=t)return!1}return!0}(r,F.strOptions.fold.lineWidth-a.length));let u=l?"|":">";if(!r)return u+"\n";let f="",p="";if(r=r.replace(/[\n\t ]*$/,(e=>{const t=e.indexOf("\n");return-1===t?u+="-":r!==e&&t===e.length-1||(u+="+",i&&i()),p=e.replace(/\n$/,""),""})).replace(/^[\n ]*/,(e=>{-1!==e.indexOf(" ")&&(u+=c);const t=e.match(/ +$/);return t?(f=e.slice(0,-t[0].length),t[0]):(f=e,"")})),p&&(p=p.replace(/\n+(?!\n|$)/g,`$&${a}`)),f&&(f=f.replace(/\n+/g,`$&${a}`)),t&&(u+=" #"+t.replace(/ ?[\r\n]+/g," "),o&&o()),!r)return`${u}${c}\n${a}${p}`;if(l)return r=r.replace(/\n+/g,`$&${a}`),`${u}\n${a}${f}${r}${p}`;r=r.replace(/\n+/g,"\n$&").replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${a}`);const h=ue.foldFlowLines(`${f}${r}${p}`,a,ue.FOLD_BLOCK,F.strOptions.fold);return`${u}\n${a}${h}`}var ge={stringifyString:function(t,n,r,s){const{defaultKeyType:o,defaultType:i}=F.strOptions,{implicitKey:a,inFlow:c}=n;let{type:l,value:u}=t;"string"!=typeof u&&(u=String(u),t=Object.assign({},t,{value:u})),l!==e.Type.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(u)&&(l=e.Type.QUOTE_DOUBLE);const f=o=>{switch(o){case e.Type.BLOCK_FOLDED:case e.Type.BLOCK_LITERAL:return a||c?he(u,n):me(t,n,r,s);case e.Type.QUOTE_DOUBLE:return he(u,n);case e.Type.QUOTE_SINGLE:return de(u,n);case e.Type.PLAIN:return function(t,n,r,s){const{comment:o,type:i,value:a}=t,{actualString:c,implicitKey:l,indent:u,inFlow:f}=n;if(l&&/[\n[\]{},]/.test(a)||f&&/[[\]{},]/.test(a))return he(a,n);if(!a||/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a)){const e=-1!==a.indexOf('"'),o=-1!==a.indexOf("'");let i;return i=e&&!o?de:o&&!e?he:F.strOptions.defaultQuoteSingle?de:he,l||f||-1===a.indexOf("\n")?i(a,n):me(t,n,r,s)}if(!l&&!f&&i!==e.Type.PLAIN&&-1!==a.indexOf("\n"))return me(t,n,r,s);if(""===u&&pe(a))return n.forceBlockIndent=!0,me(t,n,r,s);const p=a.replace(/\n+/g,`$&\n${u}`);if(c){const{tags:e}=n.doc.schema;if("string"!=typeof ce.resolveScalar(p,e).value)return he(a,n)}const h=l?p:ue.foldFlowLines(p,u,ue.FOLD_FLOW,fe(n));return!o||f||-1===h.indexOf("\n")&&-1===o.indexOf("\n")?h:(r&&r(),U.addCommentBefore(h,u,o))}(t,n,r,s);default:return null}};let p=f(l);if(null===p){const e=a?o:i;if(p=f(e),null===p)throw new Error(`Unsupported default string type ${e}`)}return p}};var ye={stringifyTag:function(e,t){if("1.0"===(e.version||e.options.version)){const e=t.match(/^tag:private\.yaml\.org,2002:([^:/]+)$/);if(e)return"!"+e[1];const n=t.match(/^tag:([a-zA-Z0-9-]+)\.yaml\.org,2002:(.*)/);return n?`!${n[1]}/${n[2]}`:`!${t.replace(/^tag:/,"")}`}let n=e.tagPrefixes.find((e=>0===t.indexOf(e.prefix)));if(!n){const r=e.getDefaults().tagPrefixes;n=r&&r.find((e=>0===t.indexOf(e.prefix)))}if(!n)return"!"===t[0]?t:`!<${t}>`;const r=t.substr(n.prefix.length).replace(/[!,[\]{}]/g,(e=>({"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"}[e])));return n.handle+r}};var ve={stringify:function(e,t,n,r){const{schema:s}=t.doc;let o;if(e instanceof q||(e=t.doc.createNode(e,{onTagObj:e=>o=e,wrapScalars:!0})),e instanceof se.Pair)return e.toString(t,n,r);o||(o=function(e,t){if(t instanceof ae.Alias)return ae.Alias;if(t.tag){const n=e.filter((e=>e.tag===t.tag));if(n.length>0)return n.find((e=>e.format===t.format))||n[0]}let n,r;if(t instanceof J.Scalar){r=t.value;const s=e.filter((e=>e.identify&&e.identify(r)));n=s.find((e=>e.format===t.format))||s.find((e=>!e.format))}else r=t,n=e.find((e=>e.nodeClass&&r instanceof e.nodeClass));if(!n){const e=r&&r.constructor?r.constructor.name:typeof r;throw new Error(`Tag not resolved for ${e} value`)}return n}(s.tags,e));const i=function(e,t,{anchors:n,doc:r}){const s=[],o=r.anchors.getName(e);return o&&(n[o]=e,s.push(`&${o}`)),e.tag?s.push(ye.stringifyTag(r,e.tag)):t.default||s.push(ye.stringifyTag(r,t.tag)),s.join(" ")}(e,o,t);i.length>0&&(t.indentAtStart=(t.indentAtStart||0)+i.length+1);const a="function"==typeof o.stringify?o.stringify(e,t,n,r):e instanceof J.Scalar?ge.stringifyString(e,t,n,r):e.toString(t,n,r);return i?e instanceof J.Scalar||"{"===a[0]||"["===a[0]?`${i} ${a}`:`${i}\n${t.indent}${a}`:a}};function be(e,t){const n=t instanceof J.Scalar?t.value:t;for(const r of e)if(r instanceof se.Pair){if(r.key===t||r.key===n)return r;if(r.key&&r.key.value===n)return r}}class Se extends Z.Collection{add(e,t){e?e instanceof se.Pair||(e=new se.Pair(e.key||e,e.value)):e=new se.Pair(e);const n=be(this.items,e.key),r=this.schema&&this.schema.sortMapEntries;if(n){if(!t)throw new Error(`Key ${e.key} already set`);n.value instanceof J.Scalar&&J.isScalarValue(e.value)?n.value.value=e.value:n.value=e.value}else if(r){const t=this.items.findIndex((t=>r(e,t)<0));-1===t?this.items.push(e):this.items.splice(t,0,e)}else this.items.push(e)}delete(e){const t=be(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){const n=be(this.items,e),r=n&&n.value;return!t&&r instanceof J.Scalar?r.value:r}has(e){return!!be(this.items,e)}set(e,t){this.add(new se.Pair(e,t),!0)}toJSON(e,t,n){const r=n?new n:t&&t.mapAsMap?new Map:{};t&&t.onCreate&&t.onCreate(r);for(const e of this.items)e.addToJSMap(t,r);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(const e of this.items)if(!(e instanceof se.Pair))throw new Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return super.toString(e,{blockItem:e=>e.str,flowChars:{start:"{",end:"}"},isMap:!0,itemIndent:e.indent||""},t,n)}}var we={YAMLMap:Se,findPair:be};class Oe extends se.Pair{constructor(e){if(e instanceo