@origints/markdown 0.1.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,72 +1,72 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const kt=require("unist-util-select"),st=require("unified"),Ct=require("remark-parse"),nt=require("remark-gfm"),ks=require("remark-frontmatter"),Mt=require("remark-rehype"),Bt=require("rehype-stringify");function v(n,e){return{ok:!0,value:n,path:e}}function E(n,e,t,s){return{ok:!1,failure:{kind:n,message:e,path:t,position:s}}}function Ss(n){return n.length===0?"$":"$"+n.map(e=>typeof e=="number"?`[${e}]`:`.${e}`).join("")}class R{constructor(e,t,s){this.node=e,this._path=t,this.root=s}static fromRoot(e){return new R(e,[],e)}static fromNode(e,t,s){return new R(e,t,s)}get path(){return this._path}get position(){if(this.node.position)return{start:{line:this.node.position.start.line,column:this.node.position.start.column,offset:this.node.position.start.offset},end:{line:this.node.position.end.line,column:this.node.position.end.column,offset:this.node.position.end.offset}}}get nodeType(){const e=this.node.type;return e==="root"?"root":e==="heading"?"heading":e==="paragraph"?"paragraph":e==="text"?"text":e==="emphasis"?"emphasis":e==="strong"?"strong":e==="inlineCode"?"inlineCode":e==="code"?"code":e==="link"?"link":e==="image"?"image":e==="list"?"list":e==="listItem"?"listItem":e==="table"?"table":e==="tableRow"?"tableRow":e==="tableCell"?"tableCell":e==="blockquote"?"blockquote":e==="thematicBreak"?"thematicBreak":e==="html"?"html":e==="definition"?"definition":e==="footnoteDefinition"?"footnoteDefinition":e==="footnoteReference"?"footnoteReference":e==="break"?"break":e==="yaml"?"yaml":e==="toml"?"toml":"unknown"}unwrap(){return this.node}select(e){const t=kt.select(e,this.node);if(!t)return E("selector",`No node matches selector: ${e}`,this._path,this.position);const s=[...this._path,e];return v(new R(t,s,this.root),s)}selectAll(e){const s=kt.selectAll(e,this.node).map((i,r)=>{const o=[...this._path,`${e}[${r}]`];return new R(i,o,this.root)});return v(s,this._path)}children(){if(!("children"in this.node))return v([],this._path);const t=this.node.children.map((s,i)=>{const r=[...this._path,i];return new R(s,r,this.root)});return v(t,this._path)}child(e){if(!("children"in this.node))return E("type","Node has no children",this._path,this.position);const t=this.node.children;if(e<0||e>=t.length)return E("missing",`Index ${e} out of bounds (length: ${t.length})`,this._path,this.position);const s=[...this._path,e];return v(new R(t[e],s,this.root),s)}first(){return this.child(0)}last(){if(!("children"in this.node))return E("type","Node has no children",this._path,this.position);const e=this.node.children;return this.child(e.length-1)}headings(){return this.selectAll("heading")}codeBlocks(){return this.selectAll("code")}links(){return this.selectAll("link")}images(){return this.selectAll("image")}lists(){return this.selectAll("list")}tables(){return this.selectAll("table")}paragraphs(){return this.selectAll("paragraph")}blockquotes(){return this.selectAll("blockquote")}section(e){const t=this.children();if(!t.ok)return t;const s=t.value;let i=!1,r=0;const o=[];for(const a of s){if(a.nodeType==="heading"){const l=this.extractText(a.node),c=a.node.depth;if(l===e){i=!0,r=c,o.push(a);continue}if(i&&c<=r)break}i&&o.push(a)}return o.length===0?E("missing",`Section "${e}" not found`,this._path,this.position):v(o,this._path)}asHeading(){if(this.node.type!=="heading")return E("type",`Expected heading, got ${this.nodeType}`,this._path,this.position);const e=this.node;return v({depth:e.depth,text:this.extractText(e),position:this.position},this._path)}asCodeBlock(){if(this.node.type!=="code")return E("type",`Expected code, got ${this.nodeType}`,this._path,this.position);const e=this.node;return v({lang:e.lang??void 0,meta:e.meta??void 0,value:e.value,position:this.position},this._path)}asInlineCode(){if(this.node.type!=="inlineCode")return E("type",`Expected inlineCode, got ${this.nodeType}`,this._path,this.position);const e=this.node;return v({value:e.value,position:this.position},this._path)}asLink(){if(this.node.type!=="link")return E("type",`Expected link, got ${this.nodeType}`,this._path,this.position);const e=this.node;return v({url:e.url,title:e.title??void 0,text:this.extractText(e),position:this.position},this._path)}asImage(){if(this.node.type!=="image")return E("type",`Expected image, got ${this.nodeType}`,this._path,this.position);const e=this.node;return v({url:e.url,alt:e.alt??void 0,title:e.title??void 0,position:this.position},this._path)}asList(){if(this.node.type!=="list")return E("type",`Expected list, got ${this.nodeType}`,this._path,this.position);const e=this.node,t=e.children.map(s=>this.extractListItem(s));return v({ordered:e.ordered??!1,start:e.start??void 0,items:t,position:this.position},this._path)}asTable(){if(this.node.type!=="table")return E("type",`Expected table, got ${this.nodeType}`,this._path,this.position);const e=this.node,t=e.align??[],s=e.children.map(o=>({cells:o.children.map((l,c)=>({text:this.extractText(l),align:t[c]??void 0}))})),[i,...r]=s;return v({headers:i?.cells??[],rows:r,position:this.position},this._path)}asBlockquote(){if(this.node.type!=="blockquote")return E("type",`Expected blockquote, got ${this.nodeType}`,this._path,this.position);const e=this.node;return v({text:this.extractText(e),position:this.position},this._path)}asParagraph(){if(this.node.type!=="paragraph")return E("type",`Expected paragraph, got ${this.nodeType}`,this._path,this.position);const e=this.node;return v({text:this.extractText(e),position:this.position},this._path)}asDefinition(){if(this.node.type!=="definition")return E("type",`Expected definition, got ${this.nodeType}`,this._path,this.position);const e=this.node;return v({identifier:e.identifier,url:e.url,title:e.title??void 0,position:this.position},this._path)}text(){return this.extractText(this.node)}isHeading(){return this.node.type==="heading"}isParagraph(){return this.node.type==="paragraph"}isCode(){return this.node.type==="code"}isInlineCode(){return this.node.type==="inlineCode"}isLink(){return this.node.type==="link"}isImage(){return this.node.type==="image"}isList(){return this.node.type==="list"}isTable(){return this.node.type==="table"}isBlockquote(){return this.node.type==="blockquote"}isText(){return this.node.type==="text"}extractText(e){return e.type==="text"||e.type==="inlineCode"||e.type==="code"?e.value:"children"in e?e.children.map(t=>this.extractText(t)).join(""):"value"in e?String(e.value):""}extractListItem(e){const t=this.extractText(e),s=[];for(const i of e.children)if(i.type==="list"){const r=i;for(const o of r.children)s.push(this.extractListItem(o))}return{checked:e.checked??void 0,text:t,children:s,position:e.position?{start:{line:e.position.start.line,column:e.position.start.column,offset:e.position.start.offset},end:{line:e.position.end.line,column:e.position.end.column,offset:e.position.end.offset}}:void 0}}}function Ns(n){return{kind:"transform",namespace:"@origints/markdown",name:"parseMarkdown",args:n}}function Pt(n={}){const{gfm:e=!0,frontmatter:t=!0,frontmatterFormats:s=["yaml","toml"]}=n;let i=st.unified().use(Ct);return e&&(i=i.use(nt)),t&&(i=i.use(ks,s)),i}async function Ts(n){const e=n.getReader(),t=new TextDecoder;let s="";for(;;){const{done:i,value:r}=await e.read();if(i)break;s+=t.decode(r,{stream:!0})}return s+=t.decode(),s}const Kt={namespace:"@origints/markdown",name:"parseMarkdown",execute(n,e){if(typeof n!="string")throw new TypeError(`parseMarkdown expects a string input, got ${typeof n}`);const s=Pt(e).parse(n);return R.fromRoot(s)}},Dt={namespace:"@origints/markdown",name:"parseMarkdown",async execute(n,e){let t;if(typeof n=="string")t=n;else if(n instanceof ReadableStream)t=await Ts(n);else throw new TypeError(`parseMarkdown expects a string or stream input, got ${typeof n}`);const i=Pt(e).parse(t);return R.fromRoot(i)}},it=Symbol.for("yaml.alias"),We=Symbol.for("yaml.document"),G=Symbol.for("yaml.map"),jt=Symbol.for("yaml.pair"),U=Symbol.for("yaml.scalar"),ce=Symbol.for("yaml.seq"),j=Symbol.for("yaml.node.type"),z=n=>!!n&&typeof n=="object"&&n[j]===it,Be=n=>!!n&&typeof n=="object"&&n[j]===We,ke=n=>!!n&&typeof n=="object"&&n[j]===G,_=n=>!!n&&typeof n=="object"&&n[j]===jt,I=n=>!!n&&typeof n=="object"&&n[j]===U,Se=n=>!!n&&typeof n=="object"&&n[j]===ce;function $(n){if(n&&typeof n=="object")switch(n[j]){case G:case ce:return!0}return!1}function L(n){if(n&&typeof n=="object")switch(n[j]){case it:case G:case U:case ce:return!0}return!1}const qt=n=>(I(n)||$(n))&&!!n.anchor,H=Symbol("break visit"),Os=Symbol("skip children"),ge=Symbol("remove node");function fe(n,e){const t=As(e);Be(n)?se(null,n.contents,t,Object.freeze([n]))===ge&&(n.contents=null):se(null,n,t,Object.freeze([]))}fe.BREAK=H;fe.SKIP=Os;fe.REMOVE=ge;function se(n,e,t,s){const i=Is(n,e,t,s);if(L(i)||_(i))return Es(n,s,i),se(n,i,t,s);if(typeof i!="symbol"){if($(e)){s=Object.freeze(s.concat(e));for(let r=0;r<e.items.length;++r){const o=se(r,e.items[r],t,s);if(typeof o=="number")r=o-1;else{if(o===H)return H;o===ge&&(e.items.splice(r,1),r-=1)}}}else if(_(e)){s=Object.freeze(s.concat(e));const r=se("key",e.key,t,s);if(r===H)return H;r===ge&&(e.key=null);const o=se("value",e.value,t,s);if(o===H)return H;o===ge&&(e.value=null)}}return i}function As(n){return typeof n=="object"&&(n.Collection||n.Node||n.Value)?Object.assign({Alias:n.Node,Map:n.Node,Scalar:n.Node,Seq:n.Node},n.Value&&{Map:n.Value,Scalar:n.Value,Seq:n.Value},n.Collection&&{Map:n.Collection,Seq:n.Collection},n):n}function Is(n,e,t,s){if(typeof t=="function")return t(n,e,s);if(ke(e))return t.Map?.(n,e,s);if(Se(e))return t.Seq?.(n,e,s);if(_(e))return t.Pair?.(n,e,s);if(I(e))return t.Scalar?.(n,e,s);if(z(e))return t.Alias?.(n,e,s)}function Es(n,e,t){const s=e[e.length-1];if($(s))s.items[n]=t;else if(_(s))n==="key"?s.key=t:s.value=t;else if(Be(s))s.contents=t;else{const i=z(s)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}const $s={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Ls=n=>n.replace(/[!,[\]{}]/g,e=>$s[e]);class B{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},B.defaultYaml,e),this.tags=Object.assign({},B.defaultTags,t)}clone(){const e=new B(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){const e=new B(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:B.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},B.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:B.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},B.defaultTags),this.atNextDocument=!1);const s=e.trim().split(/[ \t]+/),i=s.shift();switch(i){case"%TAG":{if(s.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),s.length<2))return!1;const[r,o]=s;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,s.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;const[r]=s;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{const o=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,o),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){const o=e.slice(2,-1);return o==="!"||o==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),o)}const[,s,i]=e.match(/^(.*!)([^!]*)$/s);i||t(`The ${e} tag has no suffix`);const r=this.tags[s];if(r)try{return r+decodeURIComponent(i)}catch(o){return t(String(o)),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+Ls(e.substring(s.length));return e[0]==="!"?e:`!<${e}>`}toString(e){const t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags);let i;if(e&&s.length>0&&L(e.contents)){const r={};fe(e.contents,(o,a)=>{L(a)&&a.tag&&(r[a.tag]=!0)}),i=Object.keys(r)}else i=[];for(const[r,o]of s)r==="!!"&&o==="tag:yaml.org,2002:"||(!e||i.some(a=>a.startsWith(o)))&&t.push(`%TAG ${r} ${o}`);return t.join(`
2
- `)}}B.defaultYaml={explicit:!1,version:"1.2"};B.defaultTags={"!!":"tag:yaml.org,2002:"};function Rt(n){if(/[\x00-\x19\s,[\]{}]/.test(n)){const t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(n)}`;throw new Error(t)}return!0}function Ft(n){const e=new Set;return fe(n,{Value(t,s){s.anchor&&e.add(s.anchor)}}),e}function Ut(n,e){for(let t=1;;++t){const s=`${n}${t}`;if(!e.has(s))return s}}function _s(n,e){const t=[],s=new Map;let i=null;return{onAnchor:r=>{t.push(r),i??(i=Ft(n));const o=Ut(e,i);return i.add(o),o},setAnchors:()=>{for(const r of t){const o=s.get(r);if(typeof o=="object"&&o.anchor&&(I(o.node)||$(o.node)))o.node.anchor=o.anchor;else{const a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=r,a}}},sourceObjects:s}}function ne(n,e,t,s){if(s&&typeof s=="object")if(Array.isArray(s))for(let i=0,r=s.length;i<r;++i){const o=s[i],a=ne(n,s,String(i),o);a===void 0?delete s[i]:a!==o&&(s[i]=a)}else if(s instanceof Map)for(const i of Array.from(s.keys())){const r=s.get(i),o=ne(n,s,i,r);o===void 0?s.delete(i):o!==r&&s.set(i,o)}else if(s instanceof Set)for(const i of Array.from(s)){const r=ne(n,s,i,i);r===void 0?s.delete(i):r!==i&&(s.delete(i),s.add(r))}else for(const[i,r]of Object.entries(s)){const o=ne(n,s,i,r);o===void 0?delete s[i]:o!==r&&(s[i]=o)}return n.call(e,t,s)}function D(n,e,t){if(Array.isArray(n))return n.map((s,i)=>D(s,String(i),t));if(n&&typeof n.toJSON=="function"){if(!t||!qt(n))return n.toJSON(e,t);const s={aliasCount:0,count:1,res:void 0};t.anchors.set(n,s),t.onCreate=r=>{s.res=r,delete t.onCreate};const i=n.toJSON(e,t);return t.onCreate&&t.onCreate(i),i}return typeof n=="bigint"&&!t?.keep?Number(n):n}class rt{constructor(e){Object.defineProperty(this,j,{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:i,reviver:r}={}){if(!Be(e))throw new TypeError("A document argument is required");const o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},a=D(this,"",o);if(typeof i=="function")for(const{count:l,res:c}of o.anchors.values())i(c,l);return typeof r=="function"?ne(r,{"":a},"",a):a}}class ot extends rt{constructor(e){super(it),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){let s;t?.aliasResolveCache?s=t.aliasResolveCache:(s=[],fe(e,{Node:(r,o)=>{(z(o)||qt(o))&&s.push(o)}}),t&&(t.aliasResolveCache=s));let i;for(const r of s){if(r===this)break;r.anchor===this.source&&(i=r)}return i}toJSON(e,t){if(!t)return{source:this.source};const{anchors:s,doc:i,maxAliasCount:r}=t,o=this.resolve(i,t);if(!o){const l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=s.get(o);if(a||(D(o,null,t),a=s.get(o)),a?.res===void 0){const l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(r>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Le(i,o,s)),a.count*a.aliasCount>r)){const l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(e,t,s){const i=`*${this.source}`;if(e){if(Rt(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){const r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(r)}if(e.implicitKey)return`${i} `}return i}}function Le(n,e,t){if(z(e)){const s=e.resolve(n),i=t&&s&&t.get(s);return i?i.count*i.aliasCount:0}else if($(e)){let s=0;for(const i of e.items){const r=Le(n,i,t);r>s&&(s=r)}return s}else if(_(e)){const s=Le(n,e.key,t),i=Le(n,e.value,t);return Math.max(s,i)}return 1}const Vt=n=>!n||typeof n!="function"&&typeof n!="object";class T extends rt{constructor(e){super(U),this.value=e}toJSON(e,t){return t?.keep?this.value:D(this.value,e,t)}toString(){return String(this.value)}}T.BLOCK_FOLDED="BLOCK_FOLDED";T.BLOCK_LITERAL="BLOCK_LITERAL";T.PLAIN="PLAIN";T.QUOTE_DOUBLE="QUOTE_DOUBLE";T.QUOTE_SINGLE="QUOTE_SINGLE";const vs="tag:yaml.org,2002:";function Cs(n,e,t){if(e){const s=t.filter(r=>r.tag===e),i=s.find(r=>!r.format)??s[0];if(!i)throw new Error(`Tag ${e} not found`);return i}return t.find(s=>s.identify?.(n)&&!s.format)}function be(n,e,t){if(Be(n)&&(n=n.contents),L(n))return n;if(_(n)){const f=t.schema[G].createNode?.(t.schema,null,t);return f.items.push(n),f}(n instanceof String||n instanceof Number||n instanceof Boolean||typeof BigInt<"u"&&n instanceof BigInt)&&(n=n.valueOf());const{aliasDuplicateObjects:s,onAnchor:i,onTagObj:r,schema:o,sourceObjects:a}=t;let l;if(s&&n&&typeof n=="object"){if(l=a.get(n),l)return l.anchor??(l.anchor=i(n)),new ot(l.anchor);l={anchor:null,node:null},a.set(n,l)}e?.startsWith("!!")&&(e=vs+e.slice(2));let c=Cs(n,e,o.tags);if(!c){if(n&&typeof n.toJSON=="function"&&(n=n.toJSON()),!n||typeof n!="object"){const f=new T(n);return l&&(l.node=f),f}c=n instanceof Map?o[G]:Symbol.iterator in Object(n)?o[ce]:o[G]}r&&(r(c),delete t.onTagObj);const d=c?.createNode?c.createNode(t.schema,n,t):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(t.schema,n,t):new T(n);return e?d.tag=e:c.default||(d.tag=c.tag),l&&(l.node=d),d}function Ce(n,e,t){let s=t;for(let i=e.length-1;i>=0;--i){const r=e[i];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){const o=[];o[r]=s,s=o}else s=new Map([[r,s]])}return be(s,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:n,sourceObjects:new Map})}const pe=n=>n==null||typeof n=="object"&&!!n[Symbol.iterator]().next().done;class xt extends rt{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(s=>L(s)||_(s)?s.clone(e):s),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(pe(e))this.add(t);else{const[s,...i]=e,r=this.get(s,!0);if($(r))r.addIn(i,t);else if(r===void 0&&this.schema)this.set(s,Ce(this.schema,i,t));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${i}`)}}deleteIn(e){const[t,...s]=e;if(s.length===0)return this.delete(t);const i=this.get(t,!0);if($(i))return i.deleteIn(s);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${s}`)}getIn(e,t){const[s,...i]=e,r=this.get(s,!0);return i.length===0?!t&&I(r)?r.value:r:$(r)?r.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!_(t))return!1;const s=t.value;return s==null||e&&I(s)&&s.value==null&&!s.commentBefore&&!s.comment&&!s.tag})}hasIn(e){const[t,...s]=e;if(s.length===0)return this.has(t);const i=this.get(t,!0);return $(i)?i.hasIn(s):!1}setIn(e,t){const[s,...i]=e;if(i.length===0)this.set(s,t);else{const r=this.get(s,!0);if($(r))r.setIn(i,t);else if(r===void 0&&this.schema)this.set(s,Ce(this.schema,i,t));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${i}`)}}}const Ms=n=>n.replace(/^(?!$)(?: $)?/gm,"#");function V(n,e){return/^\n+$/.test(n)?n.substring(1):e?n.replace(/^(?! *$)/gm,e):n}const Q=(n,e,t)=>n.endsWith(`
3
- `)?V(t,e):t.includes(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const at=require("@origints/core"),It=require("unist-util-select"),lt=require("unified"),jt=require("remark-parse"),ct=require("remark-gfm"),$s=require("remark-frontmatter"),qt=require("remark-rehype"),Rt=require("rehype-stringify");function C(n,e){return{ok:!0,value:n,path:e}}function $(n,e,t,s){return{ok:!1,failure:{kind:n,message:e,path:t,position:s}}}function Es(n){return n.length===0?"$":"$"+n.map(e=>typeof e=="number"?`[${e}]`:`.${e}`).join("")}class F{constructor(e,t,s){this.node=e,this._path=t,this.root=s}get[at.TYPE_LABEL](){return`MarkdownNode(${this.nodeType})`}static fromRoot(e){return new F(e,[],e)}static fromNode(e,t,s){return new F(e,t,s)}get path(){return this._path}get position(){if(this.node.position)return{start:{line:this.node.position.start.line,column:this.node.position.start.column,offset:this.node.position.start.offset},end:{line:this.node.position.end.line,column:this.node.position.end.column,offset:this.node.position.end.offset}}}get nodeType(){const e=this.node.type;return e==="root"?"root":e==="heading"?"heading":e==="paragraph"?"paragraph":e==="text"?"text":e==="emphasis"?"emphasis":e==="strong"?"strong":e==="inlineCode"?"inlineCode":e==="code"?"code":e==="link"?"link":e==="image"?"image":e==="list"?"list":e==="listItem"?"listItem":e==="table"?"table":e==="tableRow"?"tableRow":e==="tableCell"?"tableCell":e==="blockquote"?"blockquote":e==="thematicBreak"?"thematicBreak":e==="html"?"html":e==="definition"?"definition":e==="footnoteDefinition"?"footnoteDefinition":e==="footnoteReference"?"footnoteReference":e==="break"?"break":e==="yaml"?"yaml":e==="toml"?"toml":"unknown"}unwrap(){return this.node}select(e){const t=It.select(e,this.node);if(!t)return $("selector",`No node matches selector: ${e}`,this._path,this.position);const s=[...this._path,e];return C(new F(t,s,this.root),s)}selectAll(e){const s=It.selectAll(e,this.node).map((i,r)=>{const o=[...this._path,`${e}[${r}]`];return new F(i,o,this.root)});return C(s,this._path)}children(){if(!("children"in this.node))return C([],this._path);const t=this.node.children.map((s,i)=>{const r=[...this._path,i];return new F(s,r,this.root)});return C(t,this._path)}child(e){if(!("children"in this.node))return $("type","Node has no children",this._path,this.position);const t=this.node.children;if(e<0||e>=t.length)return $("missing",`Index ${e} out of bounds (length: ${t.length})`,this._path,this.position);const s=[...this._path,e];return C(new F(t[e],s,this.root),s)}first(){return this.child(0)}last(){if(!("children"in this.node))return $("type","Node has no children",this._path,this.position);const e=this.node.children;return this.child(e.length-1)}headings(){return this.selectAll("heading")}codeBlocks(){return this.selectAll("code")}links(){return this.selectAll("link")}images(){return this.selectAll("image")}lists(){return this.selectAll("list")}tables(){return this.selectAll("table")}paragraphs(){return this.selectAll("paragraph")}blockquotes(){return this.selectAll("blockquote")}section(e){const t=this.children();if(!t.ok)return t;const s=t.value;let i=!1,r=0;const o=[];for(const a of s){if(a.nodeType==="heading"){const l=this.extractText(a.node),c=a.node.depth;if(l===e){i=!0,r=c,o.push(a);continue}if(i&&c<=r)break}i&&o.push(a)}return o.length===0?$("missing",`Section "${e}" not found`,this._path,this.position):C(o,this._path)}asHeading(){if(this.node.type!=="heading")return $("type",`Expected heading, got ${this.nodeType}`,this._path,this.position);const e=this.node;return C({depth:e.depth,text:this.extractText(e),position:this.position},this._path)}asCodeBlock(){if(this.node.type!=="code")return $("type",`Expected code, got ${this.nodeType}`,this._path,this.position);const e=this.node;return C({lang:e.lang??void 0,meta:e.meta??void 0,value:e.value,position:this.position},this._path)}asInlineCode(){if(this.node.type!=="inlineCode")return $("type",`Expected inlineCode, got ${this.nodeType}`,this._path,this.position);const e=this.node;return C({value:e.value,position:this.position},this._path)}asLink(){if(this.node.type!=="link")return $("type",`Expected link, got ${this.nodeType}`,this._path,this.position);const e=this.node;return C({url:e.url,title:e.title??void 0,text:this.extractText(e),position:this.position},this._path)}asImage(){if(this.node.type!=="image")return $("type",`Expected image, got ${this.nodeType}`,this._path,this.position);const e=this.node;return C({url:e.url,alt:e.alt??void 0,title:e.title??void 0,position:this.position},this._path)}asList(){if(this.node.type!=="list")return $("type",`Expected list, got ${this.nodeType}`,this._path,this.position);const e=this.node,t=e.children.map(s=>this.extractListItem(s));return C({ordered:e.ordered??!1,start:e.start??void 0,items:t,position:this.position},this._path)}asTable(){if(this.node.type!=="table")return $("type",`Expected table, got ${this.nodeType}`,this._path,this.position);const e=this.node,t=e.align??[],s=e.children.map(o=>({cells:o.children.map((l,c)=>({text:this.extractText(l),align:t[c]??void 0}))})),[i,...r]=s;return C({headers:i?.cells??[],rows:r,position:this.position},this._path)}asBlockquote(){if(this.node.type!=="blockquote")return $("type",`Expected blockquote, got ${this.nodeType}`,this._path,this.position);const e=this.node;return C({text:this.extractText(e),position:this.position},this._path)}asParagraph(){if(this.node.type!=="paragraph")return $("type",`Expected paragraph, got ${this.nodeType}`,this._path,this.position);const e=this.node;return C({text:this.extractText(e),position:this.position},this._path)}asDefinition(){if(this.node.type!=="definition")return $("type",`Expected definition, got ${this.nodeType}`,this._path,this.position);const e=this.node;return C({identifier:e.identifier,url:e.url,title:e.title??void 0,position:this.position},this._path)}text(){return this.extractText(this.node)}isHeading(){return this.node.type==="heading"}isParagraph(){return this.node.type==="paragraph"}isCode(){return this.node.type==="code"}isInlineCode(){return this.node.type==="inlineCode"}isLink(){return this.node.type==="link"}isImage(){return this.node.type==="image"}isList(){return this.node.type==="list"}isTable(){return this.node.type==="table"}isBlockquote(){return this.node.type==="blockquote"}isText(){return this.node.type==="text"}extractText(e){return e.type==="text"||e.type==="inlineCode"||e.type==="code"?e.value:"children"in e?e.children.map(t=>this.extractText(t)).join(""):"value"in e?String(e.value):""}extractListItem(e){const t=this.extractText(e),s=[];for(const i of e.children)if(i.type==="list"){const r=i;for(const o of r.children)s.push(this.extractListItem(o))}return{checked:e.checked??void 0,text:t,children:s,position:e.position?{start:{line:e.position.start.line,column:e.position.start.column,offset:e.position.start.offset},end:{line:e.position.end.line,column:e.position.end.column,offset:e.position.end.offset}}:void 0}}}function Ge(n,e){return{kind:"extract",format:"markdown",steps:n,extract:e}}class x{constructor(e){this.steps=e}select(e){return new x([...this.steps,{kind:"select",selector:e}])}selectAt(e,t){return new x([...this.steps,{kind:"selectAll",selector:e,index:t}])}child(e){return new x([...this.steps,{kind:"child",index:e}])}first(){return new x([...this.steps,{kind:"first"}])}last(){return new x([...this.steps,{kind:"last"}])}text(){return Ge(this.steps,"text")}selectAll(e,t){const s=t(new x([]));return{kind:"array",source:Ge(this.steps,{kind:"selectAll",selector:e}),items:s}}children(e){const t=e(new x([]));return{kind:"array",source:Ge(this.steps,{kind:"children"}),items:t}}}class Ke extends x{constructor(e){super(e)}static root(){return new Ke([])}}function Ls(n){return{kind:"transform",namespace:"@origints/markdown",name:"parseMarkdown",args:n,specBuilderFactory:()=>Ke.root()}}function Ft(n={}){const{gfm:e=!0,frontmatter:t=!0,frontmatterFormats:s=["yaml","toml"]}=n;let i=lt.unified().use(jt);return e&&(i=i.use(ct)),t&&(i=i.use($s,s)),i}async function vs(n){const e=n.getReader(),t=new TextDecoder;let s="";for(;;){const{done:i,value:r}=await e.read();if(i)break;s+=t.decode(r,{stream:!0})}return s+=t.decode(),s}const Cs={namespace:"@origints/markdown",name:"parseMarkdown",execute(n,e){if(typeof n!="string")throw new TypeError(`parseMarkdown expects a string input, got ${typeof n}`);const s=Ft(e).parse(n);return F.fromRoot(s)}},Ut={namespace:"@origints/markdown",name:"parseMarkdown",async execute(n,e){let t;if(typeof n=="string")t=n;else if(n instanceof ReadableStream)t=await vs(n);else if(n instanceof Uint8Array)t=new TextDecoder().decode(n);else if(n instanceof ArrayBuffer)t=new TextDecoder().decode(n);else throw new TypeError(`parseMarkdown expects a string, stream, Uint8Array, or ArrayBuffer input, got ${typeof n}`);const i=Ft(e).parse(t);return F.fromRoot(i)}};function He(n){return{ok:!0,value:n,path:[]}}function q(n){return{ok:!1,kind:"format",message:n,path:[]}}function xt(n,e){if(n.kind!=="extract"||n.format!=="markdown")return q(`Expected extract spec with format "markdown", got kind="${n.kind}" format="${n.format}"`);let t=e;for(const i of n.steps)switch(i.kind){case"select":{const r=t.select(i.selector);if(!r.ok)return q(`Markdown navigation failed at select("${i.selector}"): ${r.failure.message}`);t=r.value;break}case"selectAll":{const r=t.selectAll(i.selector);if(!r.ok)return q(`Markdown navigation failed at selectAll("${i.selector}"): ${r.failure.message}`);if(i.index<0||i.index>=r.value.length)return q(`Markdown selectAll("${i.selector}") index ${i.index} out of bounds (found ${r.value.length})`);t=r.value[i.index];break}case"child":{const r=t.child(i.index);if(!r.ok)return q(`Markdown navigation failed at child(${i.index}): ${r.failure.message}`);t=r.value;break}case"first":{const r=t.first();if(!r.ok)return q(`Markdown navigation failed at first(): ${r.failure.message}`);t=r.value;break}case"last":{const r=t.last();if(!r.ok)return q(`Markdown navigation failed at last(): ${r.failure.message}`);t=r.value;break}}const s=n.extract;if(typeof s=="string")return s==="text"?He(t.text()):q(`Unknown Markdown extract type: ${s}`);switch(s.kind){case"selectAll":{const i=t.selectAll(s.selector);return i.ok?He(i.value):q(`Markdown selectAll("${s.selector}") failed: ${i.failure.message}`)}case"children":{const i=t.children();return i.ok?He(i.value):q(`Markdown children() failed: ${i.failure.message}`)}default:return q(`Unknown Markdown extract kind: ${s.kind}`)}}const ft=Symbol.for("yaml.alias"),tt=Symbol.for("yaml.document"),Q=Symbol.for("yaml.map"),Vt=Symbol.for("yaml.pair"),V=Symbol.for("yaml.scalar"),ue=Symbol.for("yaml.seq"),j=Symbol.for("yaml.node.type"),ee=n=>!!n&&typeof n=="object"&&n[j]===ft,De=n=>!!n&&typeof n=="object"&&n[j]===tt,Ne=n=>!!n&&typeof n=="object"&&n[j]===Q,v=n=>!!n&&typeof n=="object"&&n[j]===Vt,I=n=>!!n&&typeof n=="object"&&n[j]===V,Te=n=>!!n&&typeof n=="object"&&n[j]===ue;function E(n){if(n&&typeof n=="object")switch(n[j]){case Q:case ue:return!0}return!1}function L(n){if(n&&typeof n=="object")switch(n[j]){case ft:case Q:case V:case ue:return!0}return!1}const Jt=n=>(I(n)||E(n))&&!!n.anchor,W=Symbol("break visit"),_s=Symbol("skip children"),be=Symbol("remove node");function he(n,e){const t=Ms(e);De(n)?ie(null,n.contents,t,Object.freeze([n]))===be&&(n.contents=null):ie(null,n,t,Object.freeze([]))}he.BREAK=W;he.SKIP=_s;he.REMOVE=be;function ie(n,e,t,s){const i=Bs(n,e,t,s);if(L(i)||v(i))return Ps(n,s,i),ie(n,i,t,s);if(typeof i!="symbol"){if(E(e)){s=Object.freeze(s.concat(e));for(let r=0;r<e.items.length;++r){const o=ie(r,e.items[r],t,s);if(typeof o=="number")r=o-1;else{if(o===W)return W;o===be&&(e.items.splice(r,1),r-=1)}}}else if(v(e)){s=Object.freeze(s.concat(e));const r=ie("key",e.key,t,s);if(r===W)return W;r===be&&(e.key=null);const o=ie("value",e.value,t,s);if(o===W)return W;o===be&&(e.value=null)}}return i}function Ms(n){return typeof n=="object"&&(n.Collection||n.Node||n.Value)?Object.assign({Alias:n.Node,Map:n.Node,Scalar:n.Node,Seq:n.Node},n.Value&&{Map:n.Value,Scalar:n.Value,Seq:n.Value},n.Collection&&{Map:n.Collection,Seq:n.Collection},n):n}function Bs(n,e,t,s){if(typeof t=="function")return t(n,e,s);if(Ne(e))return t.Map?.(n,e,s);if(Te(e))return t.Seq?.(n,e,s);if(v(e))return t.Pair?.(n,e,s);if(I(e))return t.Scalar?.(n,e,s);if(ee(e))return t.Alias?.(n,e,s)}function Ps(n,e,t){const s=e[e.length-1];if(E(s))s.items[n]=t;else if(v(s))n==="key"?s.key=t:s.value=t;else if(De(s))s.contents=t;else{const i=ee(s)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}const Ks={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Ds=n=>n.replace(/[!,[\]{}]/g,e=>Ks[e]);class B{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},B.defaultYaml,e),this.tags=Object.assign({},B.defaultTags,t)}clone(){const e=new B(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){const e=new B(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:B.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},B.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:B.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},B.defaultTags),this.atNextDocument=!1);const s=e.trim().split(/[ \t]+/),i=s.shift();switch(i){case"%TAG":{if(s.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),s.length<2))return!1;const[r,o]=s;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,s.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;const[r]=s;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{const o=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,o),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){const o=e.slice(2,-1);return o==="!"||o==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),o)}const[,s,i]=e.match(/^(.*!)([^!]*)$/s);i||t(`The ${e} tag has no suffix`);const r=this.tags[s];if(r)try{return r+decodeURIComponent(i)}catch(o){return t(String(o)),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+Ds(e.substring(s.length));return e[0]==="!"?e:`!<${e}>`}toString(e){const t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags);let i;if(e&&s.length>0&&L(e.contents)){const r={};he(e.contents,(o,a)=>{L(a)&&a.tag&&(r[a.tag]=!0)}),i=Object.keys(r)}else i=[];for(const[r,o]of s)r==="!!"&&o==="tag:yaml.org,2002:"||(!e||i.some(a=>a.startsWith(o)))&&t.push(`%TAG ${r} ${o}`);return t.join(`
2
+ `)}}B.defaultYaml={explicit:!1,version:"1.2"};B.defaultTags={"!!":"tag:yaml.org,2002:"};function Yt(n){if(/[\x00-\x19\s,[\]{}]/.test(n)){const t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(n)}`;throw new Error(t)}return!0}function Gt(n){const e=new Set;return he(n,{Value(t,s){s.anchor&&e.add(s.anchor)}}),e}function Ht(n,e){for(let t=1;;++t){const s=`${n}${t}`;if(!e.has(s))return s}}function js(n,e){const t=[],s=new Map;let i=null;return{onAnchor:r=>{t.push(r),i??(i=Gt(n));const o=Ht(e,i);return i.add(o),o},setAnchors:()=>{for(const r of t){const o=s.get(r);if(typeof o=="object"&&o.anchor&&(I(o.node)||E(o.node)))o.node.anchor=o.anchor;else{const a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=r,a}}},sourceObjects:s}}function re(n,e,t,s){if(s&&typeof s=="object")if(Array.isArray(s))for(let i=0,r=s.length;i<r;++i){const o=s[i],a=re(n,s,String(i),o);a===void 0?delete s[i]:a!==o&&(s[i]=a)}else if(s instanceof Map)for(const i of Array.from(s.keys())){const r=s.get(i),o=re(n,s,i,r);o===void 0?s.delete(i):o!==r&&s.set(i,o)}else if(s instanceof Set)for(const i of Array.from(s)){const r=re(n,s,i,i);r===void 0?s.delete(i):r!==i&&(s.delete(i),s.add(r))}else for(const[i,r]of Object.entries(s)){const o=re(n,s,i,r);o===void 0?delete s[i]:o!==r&&(s[i]=o)}return n.call(e,t,s)}function D(n,e,t){if(Array.isArray(n))return n.map((s,i)=>D(s,String(i),t));if(n&&typeof n.toJSON=="function"){if(!t||!Jt(n))return n.toJSON(e,t);const s={aliasCount:0,count:1,res:void 0};t.anchors.set(n,s),t.onCreate=r=>{s.res=r,delete t.onCreate};const i=n.toJSON(e,t);return t.onCreate&&t.onCreate(i),i}return typeof n=="bigint"&&!t?.keep?Number(n):n}class ut{constructor(e){Object.defineProperty(this,j,{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:i,reviver:r}={}){if(!De(e))throw new TypeError("A document argument is required");const o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},a=D(this,"",o);if(typeof i=="function")for(const{count:l,res:c}of o.anchors.values())i(c,l);return typeof r=="function"?re(r,{"":a},"",a):a}}class ht extends ut{constructor(e){super(ft),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){let s;t?.aliasResolveCache?s=t.aliasResolveCache:(s=[],he(e,{Node:(r,o)=>{(ee(o)||Jt(o))&&s.push(o)}}),t&&(t.aliasResolveCache=s));let i;for(const r of s){if(r===this)break;r.anchor===this.source&&(i=r)}return i}toJSON(e,t){if(!t)return{source:this.source};const{anchors:s,doc:i,maxAliasCount:r}=t,o=this.resolve(i,t);if(!o){const l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=s.get(o);if(a||(D(o,null,t),a=s.get(o)),a?.res===void 0){const l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(r>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Ce(i,o,s)),a.count*a.aliasCount>r)){const l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(e,t,s){const i=`*${this.source}`;if(e){if(Yt(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){const r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(r)}if(e.implicitKey)return`${i} `}return i}}function Ce(n,e,t){if(ee(e)){const s=e.resolve(n),i=t&&s&&t.get(s);return i?i.count*i.aliasCount:0}else if(E(e)){let s=0;for(const i of e.items){const r=Ce(n,i,t);r>s&&(s=r)}return s}else if(v(e)){const s=Ce(n,e.key,t),i=Ce(n,e.value,t);return Math.max(s,i)}return 1}const Qt=n=>!n||typeof n!="function"&&typeof n!="object";class T extends ut{constructor(e){super(V),this.value=e}toJSON(e,t){return t?.keep?this.value:D(this.value,e,t)}toString(){return String(this.value)}}T.BLOCK_FOLDED="BLOCK_FOLDED";T.BLOCK_LITERAL="BLOCK_LITERAL";T.PLAIN="PLAIN";T.QUOTE_DOUBLE="QUOTE_DOUBLE";T.QUOTE_SINGLE="QUOTE_SINGLE";const qs="tag:yaml.org,2002:";function Rs(n,e,t){if(e){const s=t.filter(r=>r.tag===e),i=s.find(r=>!r.format)??s[0];if(!i)throw new Error(`Tag ${e} not found`);return i}return t.find(s=>s.identify?.(n)&&!s.format)}function ke(n,e,t){if(De(n)&&(n=n.contents),L(n))return n;if(v(n)){const f=t.schema[Q].createNode?.(t.schema,null,t);return f.items.push(n),f}(n instanceof String||n instanceof Number||n instanceof Boolean||typeof BigInt<"u"&&n instanceof BigInt)&&(n=n.valueOf());const{aliasDuplicateObjects:s,onAnchor:i,onTagObj:r,schema:o,sourceObjects:a}=t;let l;if(s&&n&&typeof n=="object"){if(l=a.get(n),l)return l.anchor??(l.anchor=i(n)),new ht(l.anchor);l={anchor:null,node:null},a.set(n,l)}e?.startsWith("!!")&&(e=qs+e.slice(2));let c=Rs(n,e,o.tags);if(!c){if(n&&typeof n.toJSON=="function"&&(n=n.toJSON()),!n||typeof n!="object"){const f=new T(n);return l&&(l.node=f),f}c=n instanceof Map?o[Q]:Symbol.iterator in Object(n)?o[ue]:o[Q]}r&&(r(c),delete t.onTagObj);const d=c?.createNode?c.createNode(t.schema,n,t):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(t.schema,n,t):new T(n);return e?d.tag=e:c.default||(d.tag=c.tag),l&&(l.node=d),d}function Be(n,e,t){let s=t;for(let i=e.length-1;i>=0;--i){const r=e[i];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){const o=[];o[r]=s,s=o}else s=new Map([[r,s]])}return ke(s,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:n,sourceObjects:new Map})}const ge=n=>n==null||typeof n=="object"&&!!n[Symbol.iterator]().next().done;class Wt extends ut{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(s=>L(s)||v(s)?s.clone(e):s),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(ge(e))this.add(t);else{const[s,...i]=e,r=this.get(s,!0);if(E(r))r.addIn(i,t);else if(r===void 0&&this.schema)this.set(s,Be(this.schema,i,t));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${i}`)}}deleteIn(e){const[t,...s]=e;if(s.length===0)return this.delete(t);const i=this.get(t,!0);if(E(i))return i.deleteIn(s);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${s}`)}getIn(e,t){const[s,...i]=e,r=this.get(s,!0);return i.length===0?!t&&I(r)?r.value:r:E(r)?r.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!v(t))return!1;const s=t.value;return s==null||e&&I(s)&&s.value==null&&!s.commentBefore&&!s.comment&&!s.tag})}hasIn(e){const[t,...s]=e;if(s.length===0)return this.has(t);const i=this.get(t,!0);return E(i)?i.hasIn(s):!1}setIn(e,t){const[s,...i]=e;if(i.length===0)this.set(s,t);else{const r=this.get(s,!0);if(E(r))r.setIn(i,t);else if(r===void 0&&this.schema)this.set(s,Be(this.schema,i,t));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${i}`)}}}const Fs=n=>n.replace(/^(?!$)(?: $)?/gm,"#");function J(n,e){return/^\n+$/.test(n)?n.substring(1):e?n.replace(/^(?! *$)/gm,e):n}const X=(n,e,t)=>n.endsWith(`
3
+ `)?J(t,e):t.includes(`
4
4
  `)?`
5
- `+V(t,e):(n.endsWith(" ")?"":" ")+t,Jt="flow",Xe="block",_e="quoted";function Pe(n,e,t="flow",{indentAtStart:s,lineWidth:i=80,minContentWidth:r=20,onFold:o,onOverflow:a}={}){if(!i||i<0)return n;i<r&&(r=0);const l=Math.max(1+r,1+i-e.length);if(n.length<=l)return n;const c=[],d={};let f=i-e.length;typeof s=="number"&&(s>i-Math.max(2,r)?c.push(0):f=i-s);let u,m,g=!1,h=-1,p=-1,b=-1;t===Xe&&(h=St(n,h,e.length),h!==-1&&(f=h+l));for(let k;k=n[h+=1];){if(t===_e&&k==="\\"){switch(p=h,n[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}b=h}if(k===`
6
- `)t===Xe&&(h=St(n,h,e.length)),f=h+e.length+l,u=void 0;else{if(k===" "&&m&&m!==" "&&m!==`
5
+ `+J(t,e):(n.endsWith(" ")?"":" ")+t,Xt="flow",st="block",_e="quoted";function je(n,e,t="flow",{indentAtStart:s,lineWidth:i=80,minContentWidth:r=20,onFold:o,onOverflow:a}={}){if(!i||i<0)return n;i<r&&(r=0);const l=Math.max(1+r,1+i-e.length);if(n.length<=l)return n;const c=[],d={};let f=i-e.length;typeof s=="number"&&(s>i-Math.max(2,r)?c.push(0):f=i-s);let u,m,g=!1,h=-1,p=-1,b=-1;t===st&&(h=$t(n,h,e.length),h!==-1&&(f=h+l));for(let k;k=n[h+=1];){if(t===_e&&k==="\\"){switch(p=h,n[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}b=h}if(k===`
6
+ `)t===st&&(h=$t(n,h,e.length)),f=h+e.length+l,u=void 0;else{if(k===" "&&m&&m!==" "&&m!==`
7
7
  `&&m!==" "){const S=n[h+1];S&&S!==" "&&S!==`
8
8
  `&&S!==" "&&(u=h)}if(h>=f)if(u)c.push(u),f=u+l,u=void 0;else if(t===_e){for(;m===" "||m===" ";)m=k,k=n[h+=1],g=!0;const S=h>b+1?h-2:p-1;if(d[S])return n;c.push(S),d[S]=!0,f=S+l,u=void 0}else g=!0}m=k}if(g&&a&&a(),c.length===0)return n;o&&o();let w=n.slice(0,c[0]);for(let k=0;k<c.length;++k){const S=c[k],N=c[k+1]||n.length;S===0?w=`
9
9
  ${e}${n.slice(0,N)}`:(t===_e&&d[S]&&(w+=`${n[S]}\\`),w+=`
10
- ${e}${n.slice(S+1,N)}`)}return w}function St(n,e,t){let s=e,i=e+1,r=n[i];for(;r===" "||r===" ";)if(e<i+t)r=n[++e];else{do r=n[++e];while(r&&r!==`
11
- `);s=e,i=e+1,r=n[i]}return s}const Ke=(n,e)=>({indentAtStart:e?n.indent.length:n.indentAtStart,lineWidth:n.options.lineWidth,minContentWidth:n.options.minContentWidth}),De=n=>/^(%|---|\.\.\.)/m.test(n);function Bs(n,e,t){if(!e||e<0)return!1;const s=e-t,i=n.length;if(i<=s)return!1;for(let r=0,o=0;r<i;++r)if(n[r]===`
12
- `){if(r-o>s)return!0;if(o=r+1,i-o<=s)return!1}return!0}function ye(n,e){const t=JSON.stringify(n);if(e.options.doubleQuotedAsJSON)return t;const{implicitKey:s}=e,i=e.options.doubleQuotedMinMultiLineLength,r=e.indent||(De(n)?" ":"");let o="",a=0;for(let l=0,c=t[l];c;c=t[++l])if(c===" "&&t[l+1]==="\\"&&t[l+2]==="n"&&(o+=t.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(t[l+1]){case"u":{o+=t.slice(a,l);const d=t.substr(l+2,4);switch(d){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:d.substr(0,2)==="00"?o+="\\x"+d.substr(2):o+=t.substr(l,6)}l+=5,a=l+1}break;case"n":if(s||t[l+2]==='"'||t.length<i)l+=1;else{for(o+=t.slice(a,l)+`
10
+ ${e}${n.slice(S+1,N)}`)}return w}function $t(n,e,t){let s=e,i=e+1,r=n[i];for(;r===" "||r===" ";)if(e<i+t)r=n[++e];else{do r=n[++e];while(r&&r!==`
11
+ `);s=e,i=e+1,r=n[i]}return s}const qe=(n,e)=>({indentAtStart:e?n.indent.length:n.indentAtStart,lineWidth:n.options.lineWidth,minContentWidth:n.options.minContentWidth}),Re=n=>/^(%|---|\.\.\.)/m.test(n);function Us(n,e,t){if(!e||e<0)return!1;const s=e-t,i=n.length;if(i<=s)return!1;for(let r=0,o=0;r<i;++r)if(n[r]===`
12
+ `){if(r-o>s)return!0;if(o=r+1,i-o<=s)return!1}return!0}function we(n,e){const t=JSON.stringify(n);if(e.options.doubleQuotedAsJSON)return t;const{implicitKey:s}=e,i=e.options.doubleQuotedMinMultiLineLength,r=e.indent||(Re(n)?" ":"");let o="",a=0;for(let l=0,c=t[l];c;c=t[++l])if(c===" "&&t[l+1]==="\\"&&t[l+2]==="n"&&(o+=t.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(t[l+1]){case"u":{o+=t.slice(a,l);const d=t.substr(l+2,4);switch(d){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:d.substr(0,2)==="00"?o+="\\x"+d.substr(2):o+=t.substr(l,6)}l+=5,a=l+1}break;case"n":if(s||t[l+2]==='"'||t.length<i)l+=1;else{for(o+=t.slice(a,l)+`
13
13
 
14
14
  `;t[l+2]==="\\"&&t[l+3]==="n"&&t[l+4]!=='"';)o+=`
15
- `,l+=2;o+=r,t[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+t.slice(a):t,s?o:Pe(o,r,_e,Ke(e,!1))}function ze(n,e){if(e.options.singleQuote===!1||e.implicitKey&&n.includes(`
16
- `)||/[ \t]\n|\n[ \t]/.test(n))return ye(n,e);const t=e.indent||(De(n)?" ":""),s="'"+n.replace(/'/g,"''").replace(/\n+/g,`$&
17
- ${t}`)+"'";return e.implicitKey?s:Pe(s,t,Jt,Ke(e,!1))}function ie(n,e){const{singleQuote:t}=e.options;let s;if(t===!1)s=ye;else{const i=n.includes('"'),r=n.includes("'");i&&!r?s=ze:r&&!i?s=ye:s=t?ze:ye}return s(n,e)}let Ze;try{Ze=new RegExp(`(^|(?<!
15
+ `,l+=2;o+=r,t[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+t.slice(a):t,s?o:je(o,r,_e,qe(e,!1))}function nt(n,e){if(e.options.singleQuote===!1||e.implicitKey&&n.includes(`
16
+ `)||/[ \t]\n|\n[ \t]/.test(n))return we(n,e);const t=e.indent||(Re(n)?" ":""),s="'"+n.replace(/'/g,"''").replace(/\n+/g,`$&
17
+ ${t}`)+"'";return e.implicitKey?s:je(s,t,Xt,qe(e,!1))}function oe(n,e){const{singleQuote:t}=e.options;let s;if(t===!1)s=we;else{const i=n.includes('"'),r=n.includes("'");i&&!r?s=nt:r&&!i?s=we:s=t?nt:we}return s(n,e)}let it;try{it=new RegExp(`(^|(?<!
18
18
  ))
19
19
  +(?!
20
- |$)`,"g")}catch{Ze=/\n+(?!\n|$)/g}function ve({comment:n,type:e,value:t},s,i,r){const{blockQuote:o,commentString:a,lineWidth:l}=s.options;if(!o||/\n[\t ]+$/.test(t))return ie(t,s);const c=s.indent||(s.forceBlockIndent||De(t)?" ":""),d=o==="literal"?!0:o==="folded"||e===T.BLOCK_FOLDED?!1:e===T.BLOCK_LITERAL?!0:!Bs(t,l,c.length);if(!t)return d?`|
20
+ |$)`,"g")}catch{it=/\n+(?!\n|$)/g}function Me({comment:n,type:e,value:t},s,i,r){const{blockQuote:o,commentString:a,lineWidth:l}=s.options;if(!o||/\n[\t ]+$/.test(t))return oe(t,s);const c=s.indent||(s.forceBlockIndent||Re(t)?" ":""),d=o==="literal"?!0:o==="folded"||e===T.BLOCK_FOLDED?!1:e===T.BLOCK_LITERAL?!0:!Us(t,l,c.length);if(!t)return d?`|
21
21
  `:`>
22
22
  `;let f,u;for(u=t.length;u>0;--u){const N=t[u-1];if(N!==`
23
23
  `&&N!==" "&&N!==" ")break}let m=t.substring(u);const g=m.indexOf(`
24
24
  `);g===-1?f="-":t===m||g!==m.length-1?(f="+",r&&r()):f="",m&&(t=t.slice(0,-m.length),m[m.length-1]===`
25
- `&&(m=m.slice(0,-1)),m=m.replace(Ze,`$&${c}`));let h=!1,p,b=-1;for(p=0;p<t.length;++p){const N=t[p];if(N===" ")h=!0;else if(N===`
25
+ `&&(m=m.slice(0,-1)),m=m.replace(it,`$&${c}`));let h=!1,p,b=-1;for(p=0;p<t.length;++p){const N=t[p];if(N===" ")h=!0;else if(N===`
26
26
  `)b=p;else break}let w=t.substring(0,b<p?b+1:p);w&&(t=t.substring(w.length),w=w.replace(/\n+/g,`$&${c}`));let S=(h?c?"2":"1":"")+f;if(n&&(S+=" "+a(n.replace(/ ?[\r\n]+/g," ")),i&&i()),!d){const N=t.replace(/\n+/g,`
27
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`);let O=!1;const A=Ke(s,!0);o!=="folded"&&e!==T.BLOCK_FOLDED&&(A.onOverflow=()=>{O=!0});const y=Pe(`${w}${N}${m}`,c,Xe,A);if(!O)return`>${S}
27
+ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`);let A=!1;const O=qe(s,!0);o!=="folded"&&e!==T.BLOCK_FOLDED&&(O.onOverflow=()=>{A=!0});const y=je(`${w}${N}${m}`,c,st,O);if(!A)return`>${S}
28
28
  ${c}${y}`}return t=t.replace(/\n+/g,`$&${c}`),`|${S}
29
- ${c}${w}${t}${m}`}function Ps(n,e,t,s){const{type:i,value:r}=n,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:d}=e;if(a&&r.includes(`
30
- `)||d&&/[[\]{},]/.test(r))return ie(r,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return a||d||!r.includes(`
31
- `)?ie(r,e):ve(n,e,t,s);if(!a&&!d&&i!==T.PLAIN&&r.includes(`
32
- `))return ve(n,e,t,s);if(De(r)){if(l==="")return e.forceBlockIndent=!0,ve(n,e,t,s);if(a&&l===c)return ie(r,e)}const f=r.replace(/\n+/g,`$&
33
- ${l}`);if(o){const u=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(f),{compat:m,tags:g}=e.doc.schema;if(g.some(u)||m?.some(u))return ie(r,e)}return a?f:Pe(f,l,Jt,Ke(e,!1))}function at(n,e,t,s){const{implicitKey:i,inFlow:r}=e,o=typeof n.value=="string"?n:Object.assign({},n,{value:String(n.value)});let{type:a}=n;a!==T.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=T.QUOTE_DOUBLE);const l=d=>{switch(d){case T.BLOCK_FOLDED:case T.BLOCK_LITERAL:return i||r?ie(o.value,e):ve(o,e,t,s);case T.QUOTE_DOUBLE:return ye(o.value,e);case T.QUOTE_SINGLE:return ze(o.value,e);case T.PLAIN:return Ps(o,e,t,s);default:return null}};let c=l(a);if(c===null){const{defaultKeyType:d,defaultStringType:f}=e.options,u=i&&d||f;if(c=l(u),c===null)throw new Error(`Unsupported default string type ${u}`)}return c}function Yt(n,e){const t=Object.assign({blockQuote:!0,commentString:Ms,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},n.schema.toStringOptions,e);let s;switch(t.collectionStyle){case"block":s=!1;break;case"flow":s=!0;break;default:s=null}return{anchors:new Set,doc:n,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:s,options:t}}function Ks(n,e){if(e.tag){const i=n.filter(r=>r.tag===e.tag);if(i.length>0)return i.find(r=>r.format===e.format)??i[0]}let t,s;if(I(e)){s=e.value;let i=n.filter(r=>r.identify?.(s));if(i.length>1){const r=i.filter(o=>o.test);r.length>0&&(i=r)}t=i.find(r=>r.format===e.format)??i.find(r=>!r.format)}else s=e,t=n.find(i=>i.nodeClass&&s instanceof i.nodeClass);if(!t){const i=s?.constructor?.name??(s===null?"null":typeof s);throw new Error(`Tag not resolved for ${i} value`)}return t}function Ds(n,e,{anchors:t,doc:s}){if(!s.directives)return"";const i=[],r=(I(n)||$(n))&&n.anchor;r&&Rt(r)&&(t.add(r),i.push(`&${r}`));const o=n.tag??(e.default?null:e.tag);return o&&i.push(s.directives.tagString(o)),i.join(" ")}function ae(n,e,t,s){if(_(n))return n.toString(e,t,s);if(z(n)){if(e.doc.directives)return n.toString(e);if(e.resolvedAliases?.has(n))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(n):e.resolvedAliases=new Set([n]),n=n.resolve(e.doc)}let i;const r=L(n)?n:e.doc.createNode(n,{onTagObj:l=>i=l});i??(i=Ks(e.doc.schema.tags,r));const o=Ds(r,i,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);const a=typeof i.stringify=="function"?i.stringify(r,e,t,s):I(r)?at(r,e,t,s):r.toString(e,t,s);return o?I(r)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
34
- ${e.indent}${a}`:a}function js({key:n,value:e},t,s,i){const{allNullValues:r,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:d,simpleKeys:f}}=t;let u=L(n)&&n.comment||null;if(f){if(u)throw new Error("With simple keys, key nodes cannot have comments");if($(n)||!L(n)&&typeof n=="object"){const A="With simple keys, collection cannot be used as a key value";throw new Error(A)}}let m=!f&&(!n||u&&e==null&&!t.inFlow||$(n)||(I(n)?n.type===T.BLOCK_FOLDED||n.type===T.BLOCK_LITERAL:typeof n=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!m&&(f||!r),indent:a+l});let g=!1,h=!1,p=ae(n,t,()=>g=!0,()=>h=!0);if(!m&&!t.inFlow&&p.length>1024){if(f)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(t.inFlow){if(r||e==null)return g&&s&&s(),p===""?"?":m?`? ${p}`:p}else if(r&&!f||e==null&&m)return p=`? ${p}`,u&&!g?p+=Q(p,t.indent,c(u)):h&&i&&i(),p;g&&(u=null),m?(u&&(p+=Q(p,t.indent,c(u))),p=`? ${p}
35
- ${a}:`):(p=`${p}:`,u&&(p+=Q(p,t.indent,c(u))));let b,w,k;L(e)?(b=!!e.spaceBefore,w=e.commentBefore,k=e.comment):(b=!1,w=null,k=null,e&&typeof e=="object"&&(e=o.createNode(e))),t.implicitKey=!1,!m&&!u&&I(e)&&(t.indentAtStart=p.length+1),h=!1,!d&&l.length>=2&&!t.inFlow&&!m&&Se(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let S=!1;const N=ae(e,t,()=>S=!0,()=>h=!0);let O=" ";if(u||b||w){if(O=b?`
36
- `:"",w){const A=c(w);O+=`
37
- ${V(A,t.indent)}`}N===""&&!t.inFlow?O===`
38
- `&&k&&(O=`
29
+ ${c}${w}${t}${m}`}function xs(n,e,t,s){const{type:i,value:r}=n,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:d}=e;if(a&&r.includes(`
30
+ `)||d&&/[[\]{},]/.test(r))return oe(r,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return a||d||!r.includes(`
31
+ `)?oe(r,e):Me(n,e,t,s);if(!a&&!d&&i!==T.PLAIN&&r.includes(`
32
+ `))return Me(n,e,t,s);if(Re(r)){if(l==="")return e.forceBlockIndent=!0,Me(n,e,t,s);if(a&&l===c)return oe(r,e)}const f=r.replace(/\n+/g,`$&
33
+ ${l}`);if(o){const u=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(f),{compat:m,tags:g}=e.doc.schema;if(g.some(u)||m?.some(u))return oe(r,e)}return a?f:je(f,l,Xt,qe(e,!1))}function dt(n,e,t,s){const{implicitKey:i,inFlow:r}=e,o=typeof n.value=="string"?n:Object.assign({},n,{value:String(n.value)});let{type:a}=n;a!==T.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=T.QUOTE_DOUBLE);const l=d=>{switch(d){case T.BLOCK_FOLDED:case T.BLOCK_LITERAL:return i||r?oe(o.value,e):Me(o,e,t,s);case T.QUOTE_DOUBLE:return we(o.value,e);case T.QUOTE_SINGLE:return nt(o.value,e);case T.PLAIN:return xs(o,e,t,s);default:return null}};let c=l(a);if(c===null){const{defaultKeyType:d,defaultStringType:f}=e.options,u=i&&d||f;if(c=l(u),c===null)throw new Error(`Unsupported default string type ${u}`)}return c}function zt(n,e){const t=Object.assign({blockQuote:!0,commentString:Fs,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},n.schema.toStringOptions,e);let s;switch(t.collectionStyle){case"block":s=!1;break;case"flow":s=!0;break;default:s=null}return{anchors:new Set,doc:n,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:s,options:t}}function Vs(n,e){if(e.tag){const i=n.filter(r=>r.tag===e.tag);if(i.length>0)return i.find(r=>r.format===e.format)??i[0]}let t,s;if(I(e)){s=e.value;let i=n.filter(r=>r.identify?.(s));if(i.length>1){const r=i.filter(o=>o.test);r.length>0&&(i=r)}t=i.find(r=>r.format===e.format)??i.find(r=>!r.format)}else s=e,t=n.find(i=>i.nodeClass&&s instanceof i.nodeClass);if(!t){const i=s?.constructor?.name??(s===null?"null":typeof s);throw new Error(`Tag not resolved for ${i} value`)}return t}function Js(n,e,{anchors:t,doc:s}){if(!s.directives)return"";const i=[],r=(I(n)||E(n))&&n.anchor;r&&Yt(r)&&(t.add(r),i.push(`&${r}`));const o=n.tag??(e.default?null:e.tag);return o&&i.push(s.directives.tagString(o)),i.join(" ")}function ce(n,e,t,s){if(v(n))return n.toString(e,t,s);if(ee(n)){if(e.doc.directives)return n.toString(e);if(e.resolvedAliases?.has(n))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(n):e.resolvedAliases=new Set([n]),n=n.resolve(e.doc)}let i;const r=L(n)?n:e.doc.createNode(n,{onTagObj:l=>i=l});i??(i=Vs(e.doc.schema.tags,r));const o=Js(r,i,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);const a=typeof i.stringify=="function"?i.stringify(r,e,t,s):I(r)?dt(r,e,t,s):r.toString(e,t,s);return o?I(r)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
34
+ ${e.indent}${a}`:a}function Ys({key:n,value:e},t,s,i){const{allNullValues:r,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:d,simpleKeys:f}}=t;let u=L(n)&&n.comment||null;if(f){if(u)throw new Error("With simple keys, key nodes cannot have comments");if(E(n)||!L(n)&&typeof n=="object"){const O="With simple keys, collection cannot be used as a key value";throw new Error(O)}}let m=!f&&(!n||u&&e==null&&!t.inFlow||E(n)||(I(n)?n.type===T.BLOCK_FOLDED||n.type===T.BLOCK_LITERAL:typeof n=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!m&&(f||!r),indent:a+l});let g=!1,h=!1,p=ce(n,t,()=>g=!0,()=>h=!0);if(!m&&!t.inFlow&&p.length>1024){if(f)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(t.inFlow){if(r||e==null)return g&&s&&s(),p===""?"?":m?`? ${p}`:p}else if(r&&!f||e==null&&m)return p=`? ${p}`,u&&!g?p+=X(p,t.indent,c(u)):h&&i&&i(),p;g&&(u=null),m?(u&&(p+=X(p,t.indent,c(u))),p=`? ${p}
35
+ ${a}:`):(p=`${p}:`,u&&(p+=X(p,t.indent,c(u))));let b,w,k;L(e)?(b=!!e.spaceBefore,w=e.commentBefore,k=e.comment):(b=!1,w=null,k=null,e&&typeof e=="object"&&(e=o.createNode(e))),t.implicitKey=!1,!m&&!u&&I(e)&&(t.indentAtStart=p.length+1),h=!1,!d&&l.length>=2&&!t.inFlow&&!m&&Te(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let S=!1;const N=ce(e,t,()=>S=!0,()=>h=!0);let A=" ";if(u||b||w){if(A=b?`
36
+ `:"",w){const O=c(w);A+=`
37
+ ${J(O,t.indent)}`}N===""&&!t.inFlow?A===`
38
+ `&&k&&(A=`
39
39
 
40
- `):O+=`
41
- ${t.indent}`}else if(!m&&$(e)){const A=N[0],y=N.indexOf(`
42
- `),C=y!==-1,J=t.inFlow??e.flow??e.items.length===0;if(C||!J){let Z=!1;if(C&&(A==="&"||A==="!")){let M=N.indexOf(" ");A==="&"&&M!==-1&&M<y&&N[M+1]==="!"&&(M=N.indexOf(" ",M+1)),(M===-1||y<M)&&(Z=!0)}Z||(O=`
40
+ `):A+=`
41
+ ${t.indent}`}else if(!m&&E(e)){const O=N[0],y=N.indexOf(`
42
+ `),_=y!==-1,G=t.inFlow??e.flow??e.items.length===0;if(_||!G){let te=!1;if(_&&(O==="&"||O==="!")){let M=N.indexOf(" ");O==="&"&&M!==-1&&M<y&&N[M+1]==="!"&&(M=N.indexOf(" ",M+1)),(M===-1||y<M)&&(te=!0)}te||(A=`
43
43
  ${t.indent}`)}}else(N===""||N[0]===`
44
- `)&&(O="");return p+=O+N,t.inFlow?S&&s&&s():k&&!S?p+=Q(p,t.indent,c(k)):h&&i&&i(),p}function qs(n,e){(n==="debug"||n==="warn")&&console.warn(e)}const Oe="<<",x={identify:n=>n===Oe||typeof n=="symbol"&&n.description===Oe,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new T(Symbol(Oe)),{addToJSMap:Gt}),stringify:()=>Oe},Rs=(n,e)=>(x.identify(e)||I(e)&&(!e.type||e.type===T.PLAIN)&&x.identify(e.value))&&n?.doc.schema.tags.some(t=>t.tag===x.tag&&t.default);function Gt(n,e,t){if(t=n&&z(t)?t.resolve(n.doc):t,Se(t))for(const s of t.items)xe(n,e,s);else if(Array.isArray(t))for(const s of t)xe(n,e,s);else xe(n,e,t)}function xe(n,e,t){const s=n&&z(t)?t.resolve(n.doc):t;if(!ke(s))throw new Error("Merge sources must be maps or map aliases");const i=s.toJSON(null,n,Map);for(const[r,o]of i)e instanceof Map?e.has(r)||e.set(r,o):e instanceof Set?e.add(r):Object.prototype.hasOwnProperty.call(e,r)||Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function Ht(n,e,{key:t,value:s}){if(L(t)&&t.addToJSMap)t.addToJSMap(n,e,s);else if(Rs(n,t))Gt(n,e,s);else{const i=D(t,"",n);if(e instanceof Map)e.set(i,D(s,i,n));else if(e instanceof Set)e.add(i);else{const r=Fs(t,i,n),o=D(s,r,n);r in e?Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[r]=o}}return e}function Fs(n,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(L(n)&&t?.doc){const s=Yt(t.doc,{});s.anchors=new Set;for(const r of t.anchors.keys())s.anchors.add(r.anchor);s.inFlow=!0,s.inStringifyKey=!0;const i=n.toString(s);if(!t.mapKeyWarned){let r=JSON.stringify(i);r.length>40&&(r=r.substring(0,36)+'..."'),qs(t.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`),t.mapKeyWarned=!0}return i}return JSON.stringify(e)}function lt(n,e,t){const s=be(n,void 0,t),i=be(e,void 0,t);return new P(s,i)}class P{constructor(e,t=null){Object.defineProperty(this,j,{value:jt}),this.key=e,this.value=t}clone(e){let{key:t,value:s}=this;return L(t)&&(t=t.clone(e)),L(s)&&(s=s.clone(e)),new P(t,s)}toJSON(e,t){const s=t?.mapAsMap?new Map:{};return Ht(t,s,this)}toString(e,t,s){return e?.doc?js(this,e,t,s):JSON.stringify(this)}}function Qt(n,e,t){return(e.inFlow??n.flow?Vs:Us)(n,e,t)}function Us({comment:n,items:e},t,{blockItemPrefix:s,flowChars:i,itemIndent:r,onChompKeep:o,onComment:a}){const{indent:l,options:{commentString:c}}=t,d=Object.assign({},t,{indent:r,type:null});let f=!1;const u=[];for(let g=0;g<e.length;++g){const h=e[g];let p=null;if(L(h))!f&&h.spaceBefore&&u.push(""),Me(t,u,h.commentBefore,f),h.comment&&(p=h.comment);else if(_(h)){const w=L(h.key)?h.key:null;w&&(!f&&w.spaceBefore&&u.push(""),Me(t,u,w.commentBefore,f))}f=!1;let b=ae(h,d,()=>p=null,()=>f=!0);p&&(b+=Q(b,r,c(p))),f&&p&&(f=!1),u.push(s+b)}let m;if(u.length===0)m=i.start+i.end;else{m=u[0];for(let g=1;g<u.length;++g){const h=u[g];m+=h?`
44
+ `)&&(A="");return p+=A+N,t.inFlow?S&&s&&s():k&&!S?p+=X(p,t.indent,c(k)):h&&i&&i(),p}function Gs(n,e){(n==="debug"||n==="warn")&&console.warn(e)}const Ie="<<",Y={identify:n=>n===Ie||typeof n=="symbol"&&n.description===Ie,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new T(Symbol(Ie)),{addToJSMap:Zt}),stringify:()=>Ie},Hs=(n,e)=>(Y.identify(e)||I(e)&&(!e.type||e.type===T.PLAIN)&&Y.identify(e.value))&&n?.doc.schema.tags.some(t=>t.tag===Y.tag&&t.default);function Zt(n,e,t){if(t=n&&ee(t)?t.resolve(n.doc):t,Te(t))for(const s of t.items)Qe(n,e,s);else if(Array.isArray(t))for(const s of t)Qe(n,e,s);else Qe(n,e,t)}function Qe(n,e,t){const s=n&&ee(t)?t.resolve(n.doc):t;if(!Ne(s))throw new Error("Merge sources must be maps or map aliases");const i=s.toJSON(null,n,Map);for(const[r,o]of i)e instanceof Map?e.has(r)||e.set(r,o):e instanceof Set?e.add(r):Object.prototype.hasOwnProperty.call(e,r)||Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function es(n,e,{key:t,value:s}){if(L(t)&&t.addToJSMap)t.addToJSMap(n,e,s);else if(Hs(n,t))Zt(n,e,s);else{const i=D(t,"",n);if(e instanceof Map)e.set(i,D(s,i,n));else if(e instanceof Set)e.add(i);else{const r=Qs(t,i,n),o=D(s,r,n);r in e?Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[r]=o}}return e}function Qs(n,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(L(n)&&t?.doc){const s=zt(t.doc,{});s.anchors=new Set;for(const r of t.anchors.keys())s.anchors.add(r.anchor);s.inFlow=!0,s.inStringifyKey=!0;const i=n.toString(s);if(!t.mapKeyWarned){let r=JSON.stringify(i);r.length>40&&(r=r.substring(0,36)+'..."'),Gs(t.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`),t.mapKeyWarned=!0}return i}return JSON.stringify(e)}function pt(n,e,t){const s=ke(n,void 0,t),i=ke(e,void 0,t);return new P(s,i)}class P{constructor(e,t=null){Object.defineProperty(this,j,{value:Vt}),this.key=e,this.value=t}clone(e){let{key:t,value:s}=this;return L(t)&&(t=t.clone(e)),L(s)&&(s=s.clone(e)),new P(t,s)}toJSON(e,t){const s=t?.mapAsMap?new Map:{};return es(t,s,this)}toString(e,t,s){return e?.doc?Ys(this,e,t,s):JSON.stringify(this)}}function ts(n,e,t){return(e.inFlow??n.flow?Xs:Ws)(n,e,t)}function Ws({comment:n,items:e},t,{blockItemPrefix:s,flowChars:i,itemIndent:r,onChompKeep:o,onComment:a}){const{indent:l,options:{commentString:c}}=t,d=Object.assign({},t,{indent:r,type:null});let f=!1;const u=[];for(let g=0;g<e.length;++g){const h=e[g];let p=null;if(L(h))!f&&h.spaceBefore&&u.push(""),Pe(t,u,h.commentBefore,f),h.comment&&(p=h.comment);else if(v(h)){const w=L(h.key)?h.key:null;w&&(!f&&w.spaceBefore&&u.push(""),Pe(t,u,w.commentBefore,f))}f=!1;let b=ce(h,d,()=>p=null,()=>f=!0);p&&(b+=X(b,r,c(p))),f&&p&&(f=!1),u.push(s+b)}let m;if(u.length===0)m=i.start+i.end;else{m=u[0];for(let g=1;g<u.length;++g){const h=u[g];m+=h?`
45
45
  ${l}${h}`:`
46
46
  `}}return n?(m+=`
47
- `+V(c(n),l),a&&a()):f&&o&&o(),m}function Vs({items:n},e,{flowChars:t,itemIndent:s}){const{indent:i,indentStep:r,flowCollectionPadding:o,options:{commentString:a}}=e;s+=r;const l=Object.assign({},e,{indent:s,inFlow:!0,type:null});let c=!1,d=0;const f=[];for(let g=0;g<n.length;++g){const h=n[g];let p=null;if(L(h))h.spaceBefore&&f.push(""),Me(e,f,h.commentBefore,!1),h.comment&&(p=h.comment);else if(_(h)){const w=L(h.key)?h.key:null;w&&(w.spaceBefore&&f.push(""),Me(e,f,w.commentBefore,!1),w.comment&&(c=!0));const k=L(h.value)?h.value:null;k?(k.comment&&(p=k.comment),k.commentBefore&&(c=!0)):h.value==null&&w?.comment&&(p=w.comment)}p&&(c=!0);let b=ae(h,l,()=>p=null);g<n.length-1&&(b+=","),p&&(b+=Q(b,s,a(p))),!c&&(f.length>d||b.includes(`
47
+ `+J(c(n),l),a&&a()):f&&o&&o(),m}function Xs({items:n},e,{flowChars:t,itemIndent:s}){const{indent:i,indentStep:r,flowCollectionPadding:o,options:{commentString:a}}=e;s+=r;const l=Object.assign({},e,{indent:s,inFlow:!0,type:null});let c=!1,d=0;const f=[];for(let g=0;g<n.length;++g){const h=n[g];let p=null;if(L(h))h.spaceBefore&&f.push(""),Pe(e,f,h.commentBefore,!1),h.comment&&(p=h.comment);else if(v(h)){const w=L(h.key)?h.key:null;w&&(w.spaceBefore&&f.push(""),Pe(e,f,w.commentBefore,!1),w.comment&&(c=!0));const k=L(h.value)?h.value:null;k?(k.comment&&(p=k.comment),k.commentBefore&&(c=!0)):h.value==null&&w?.comment&&(p=w.comment)}p&&(c=!0);let b=ce(h,l,()=>p=null);g<n.length-1&&(b+=","),p&&(b+=X(b,s,a(p))),!c&&(f.length>d||b.includes(`
48
48
  `))&&(c=!0),f.push(b),d=f.length}const{start:u,end:m}=t;if(f.length===0)return u+m;if(!c){const g=f.reduce((h,p)=>h+p.length+2,2);c=e.options.lineWidth>0&&g>e.options.lineWidth}if(c){let g=u;for(const h of f)g+=h?`
49
49
  ${r}${i}${h}`:`
50
50
  `;return`${g}
51
- ${i}${m}`}else return`${u}${o}${f.join(" ")}${o}${m}`}function Me({indent:n,options:{commentString:e}},t,s,i){if(s&&i&&(s=s.replace(/^\n+/,"")),s){const r=V(e(s),n);t.push(r.trimStart())}}function W(n,e){const t=I(e)?e.value:e;for(const s of n)if(_(s)&&(s.key===e||s.key===t||I(s.key)&&s.key.value===t))return s}class K extends xt{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(G,e),this.items=[]}static from(e,t,s){const{keepUndefined:i,replacer:r}=s,o=new this(e),a=(l,c)=>{if(typeof r=="function")c=r.call(t,l,c);else if(Array.isArray(r)&&!r.includes(l))return;(c!==void 0||i)&&o.items.push(lt(l,c,s))};if(t instanceof Map)for(const[l,c]of t)a(l,c);else if(t&&typeof t=="object")for(const l of Object.keys(t))a(l,t[l]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,t){let s;_(e)?s=e:!e||typeof e!="object"||!("key"in e)?s=new P(e,e?.value):s=new P(e.key,e.value);const i=W(this.items,s.key),r=this.schema?.sortMapEntries;if(i){if(!t)throw new Error(`Key ${s.key} already set`);I(i.value)&&Vt(s.value)?i.value.value=s.value:i.value=s.value}else if(r){const o=this.items.findIndex(a=>r(s,a)<0);o===-1?this.items.push(s):this.items.splice(o,0,s)}else this.items.push(s)}delete(e){const t=W(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){const i=W(this.items,e)?.value;return(!t&&I(i)?i.value:i)??void 0}has(e){return!!W(this.items,e)}set(e,t){this.add(new P(e,t),!0)}toJSON(e,t,s){const i=s?new s:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(i);for(const r of this.items)Ht(t,i,r);return i}toString(e,t,s){if(!e)return JSON.stringify(this);for(const i of this.items)if(!_(i))throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Qt(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:t})}}const ue={collection:"map",default:!0,nodeClass:K,tag:"tag:yaml.org,2002:map",resolve(n,e){return ke(n)||e("Expected a mapping for this tag"),n},createNode:(n,e,t)=>K.from(n,e,t)};class X extends xt{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ce,e),this.items=[]}add(e){this.items.push(e)}delete(e){const t=Ae(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){const s=Ae(e);if(typeof s!="number")return;const i=this.items[s];return!t&&I(i)?i.value:i}has(e){const t=Ae(e);return typeof t=="number"&&t<this.items.length}set(e,t){const s=Ae(e);if(typeof s!="number")throw new Error(`Expected a valid index, not ${e}.`);const i=this.items[s];I(i)&&Vt(t)?i.value=t:this.items[s]=t}toJSON(e,t){const s=[];t?.onCreate&&t.onCreate(s);let i=0;for(const r of this.items)s.push(D(r,String(i++),t));return s}toString(e,t,s){return e?Qt(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:s,onComment:t}):JSON.stringify(this)}static from(e,t,s){const{replacer:i}=s,r=new this(e);if(t&&Symbol.iterator in Object(t)){let o=0;for(let a of t){if(typeof i=="function"){const l=t instanceof Set?a:String(o++);a=i.call(t,l,a)}r.items.push(be(a,void 0,s))}}return r}}function Ae(n){let e=I(n)?n.value:n;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}const he={collection:"seq",default:!0,nodeClass:X,tag:"tag:yaml.org,2002:seq",resolve(n,e){return Se(n)||e("Expected a sequence for this tag"),n},createNode:(n,e,t)=>X.from(n,e,t)},je={identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify(n,e,t,s){return e=Object.assign({actualString:!0},e),at(n,e,t,s)}},qe={identify:n=>n==null,createNode:()=>new T(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new T(null),stringify:({source:n},e)=>typeof n=="string"&&qe.test.test(n)?n:e.options.nullStr},ct={identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:n=>new T(n[0]==="t"||n[0]==="T"),stringify({source:n,value:e},t){if(n&&ct.test.test(n)){const s=n[0]==="t"||n[0]==="T";if(e===s)return n}return e?t.options.trueStr:t.options.falseStr}};function F({format:n,minFractionDigits:e,tag:t,value:s}){if(typeof s=="bigint")return String(s);const i=typeof s=="number"?s:Number(s);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let r=Object.is(s,-0)?"-0":JSON.stringify(s);if(!n&&e&&(!t||t==="tag:yaml.org,2002:float")&&/^\d/.test(r)){let o=r.indexOf(".");o<0&&(o=r.length,r+=".");let a=e-(r.length-o-1);for(;a-- >0;)r+="0"}return r}const Wt={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:F},Xt={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n),stringify(n){const e=Number(n.value);return isFinite(e)?e.toExponential():F(n)}},zt={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(n){const e=new T(parseFloat(n)),t=n.indexOf(".");return t!==-1&&n[n.length-1]==="0"&&(e.minFractionDigits=n.length-t-1),e},stringify:F},Re=n=>typeof n=="bigint"||Number.isInteger(n),ft=(n,e,t,{intAsBigInt:s})=>s?BigInt(n):parseInt(n.substring(e),t);function Zt(n,e,t){const{value:s}=n;return Re(s)&&s>=0?t+s.toString(e):F(n)}const es={identify:n=>Re(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(n,e,t)=>ft(n,2,8,t),stringify:n=>Zt(n,8,"0o")},ts={identify:Re,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(n,e,t)=>ft(n,0,10,t),stringify:F},ss={identify:n=>Re(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(n,e,t)=>ft(n,2,16,t),stringify:n=>Zt(n,16,"0x")},xs=[ue,he,je,qe,ct,es,ts,ss,Wt,Xt,zt];function Nt(n){return typeof n=="bigint"||Number.isInteger(n)}const Ie=({value:n})=>JSON.stringify(n),Js=[{identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify:Ie},{identify:n=>n==null,createNode:()=>new T(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Ie},{identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:n=>n==="true",stringify:Ie},{identify:Nt,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(n,e,{intAsBigInt:t})=>t?BigInt(n):parseInt(n,10),stringify:({value:n})=>Nt(n)?n.toString():JSON.stringify(n)},{identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:n=>parseFloat(n),stringify:Ie}],Ys={default:!0,tag:"",test:/^/,resolve(n,e){return e(`Unresolved plain scalar ${JSON.stringify(n)}`),n}},Gs=[ue,he].concat(Js,Ys),ut={identify:n=>n instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(n,e){if(typeof atob=="function"){const t=atob(n.replace(/[\n\r]/g,"")),s=new Uint8Array(t.length);for(let i=0;i<t.length;++i)s[i]=t.charCodeAt(i);return s}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),n},stringify({comment:n,type:e,value:t},s,i,r){if(!t)return"";const o=t;let a;if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=T.BLOCK_LITERAL),e!==T.QUOTE_DOUBLE){const l=Math.max(s.options.lineWidth-s.indent.length,s.options.minContentWidth),c=Math.ceil(a.length/l),d=new Array(c);for(let f=0,u=0;f<c;++f,u+=l)d[f]=a.substr(u,l);a=d.join(e===T.BLOCK_LITERAL?`
52
- `:" ")}return at({comment:n,type:e,value:a},s,i,r)}};function ns(n,e){if(Se(n))for(let t=0;t<n.items.length;++t){let s=n.items[t];if(!_(s)){if(ke(s)){s.items.length>1&&e("Each pair must have its own sequence indicator");const i=s.items[0]||new P(new T(null));if(s.commentBefore&&(i.key.commentBefore=i.key.commentBefore?`${s.commentBefore}
51
+ ${i}${m}`}else return`${u}${o}${f.join(" ")}${o}${m}`}function Pe({indent:n,options:{commentString:e}},t,s,i){if(s&&i&&(s=s.replace(/^\n+/,"")),s){const r=J(e(s),n);t.push(r.trimStart())}}function z(n,e){const t=I(e)?e.value:e;for(const s of n)if(v(s)&&(s.key===e||s.key===t||I(s.key)&&s.key.value===t))return s}class K extends Wt{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(Q,e),this.items=[]}static from(e,t,s){const{keepUndefined:i,replacer:r}=s,o=new this(e),a=(l,c)=>{if(typeof r=="function")c=r.call(t,l,c);else if(Array.isArray(r)&&!r.includes(l))return;(c!==void 0||i)&&o.items.push(pt(l,c,s))};if(t instanceof Map)for(const[l,c]of t)a(l,c);else if(t&&typeof t=="object")for(const l of Object.keys(t))a(l,t[l]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,t){let s;v(e)?s=e:!e||typeof e!="object"||!("key"in e)?s=new P(e,e?.value):s=new P(e.key,e.value);const i=z(this.items,s.key),r=this.schema?.sortMapEntries;if(i){if(!t)throw new Error(`Key ${s.key} already set`);I(i.value)&&Qt(s.value)?i.value.value=s.value:i.value=s.value}else if(r){const o=this.items.findIndex(a=>r(s,a)<0);o===-1?this.items.push(s):this.items.splice(o,0,s)}else this.items.push(s)}delete(e){const t=z(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){const i=z(this.items,e)?.value;return(!t&&I(i)?i.value:i)??void 0}has(e){return!!z(this.items,e)}set(e,t){this.add(new P(e,t),!0)}toJSON(e,t,s){const i=s?new s:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(i);for(const r of this.items)es(t,i,r);return i}toString(e,t,s){if(!e)return JSON.stringify(this);for(const i of this.items)if(!v(i))throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),ts(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:t})}}const de={collection:"map",default:!0,nodeClass:K,tag:"tag:yaml.org,2002:map",resolve(n,e){return Ne(n)||e("Expected a mapping for this tag"),n},createNode:(n,e,t)=>K.from(n,e,t)};class Z extends Wt{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ue,e),this.items=[]}add(e){this.items.push(e)}delete(e){const t=$e(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){const s=$e(e);if(typeof s!="number")return;const i=this.items[s];return!t&&I(i)?i.value:i}has(e){const t=$e(e);return typeof t=="number"&&t<this.items.length}set(e,t){const s=$e(e);if(typeof s!="number")throw new Error(`Expected a valid index, not ${e}.`);const i=this.items[s];I(i)&&Qt(t)?i.value=t:this.items[s]=t}toJSON(e,t){const s=[];t?.onCreate&&t.onCreate(s);let i=0;for(const r of this.items)s.push(D(r,String(i++),t));return s}toString(e,t,s){return e?ts(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:s,onComment:t}):JSON.stringify(this)}static from(e,t,s){const{replacer:i}=s,r=new this(e);if(t&&Symbol.iterator in Object(t)){let o=0;for(let a of t){if(typeof i=="function"){const l=t instanceof Set?a:String(o++);a=i.call(t,l,a)}r.items.push(ke(a,void 0,s))}}return r}}function $e(n){let e=I(n)?n.value:n;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}const pe={collection:"seq",default:!0,nodeClass:Z,tag:"tag:yaml.org,2002:seq",resolve(n,e){return Te(n)||e("Expected a sequence for this tag"),n},createNode:(n,e,t)=>Z.from(n,e,t)},Fe={identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify(n,e,t,s){return e=Object.assign({actualString:!0},e),dt(n,e,t,s)}},Ue={identify:n=>n==null,createNode:()=>new T(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new T(null),stringify:({source:n},e)=>typeof n=="string"&&Ue.test.test(n)?n:e.options.nullStr},mt={identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:n=>new T(n[0]==="t"||n[0]==="T"),stringify({source:n,value:e},t){if(n&&mt.test.test(n)){const s=n[0]==="t"||n[0]==="T";if(e===s)return n}return e?t.options.trueStr:t.options.falseStr}};function U({format:n,minFractionDigits:e,tag:t,value:s}){if(typeof s=="bigint")return String(s);const i=typeof s=="number"?s:Number(s);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let r=Object.is(s,-0)?"-0":JSON.stringify(s);if(!n&&e&&(!t||t==="tag:yaml.org,2002:float")&&/^\d/.test(r)){let o=r.indexOf(".");o<0&&(o=r.length,r+=".");let a=e-(r.length-o-1);for(;a-- >0;)r+="0"}return r}const ss={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:U},ns={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n),stringify(n){const e=Number(n.value);return isFinite(e)?e.toExponential():U(n)}},is={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(n){const e=new T(parseFloat(n)),t=n.indexOf(".");return t!==-1&&n[n.length-1]==="0"&&(e.minFractionDigits=n.length-t-1),e},stringify:U},xe=n=>typeof n=="bigint"||Number.isInteger(n),gt=(n,e,t,{intAsBigInt:s})=>s?BigInt(n):parseInt(n.substring(e),t);function rs(n,e,t){const{value:s}=n;return xe(s)&&s>=0?t+s.toString(e):U(n)}const os={identify:n=>xe(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(n,e,t)=>gt(n,2,8,t),stringify:n=>rs(n,8,"0o")},as={identify:xe,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(n,e,t)=>gt(n,0,10,t),stringify:U},ls={identify:n=>xe(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(n,e,t)=>gt(n,2,16,t),stringify:n=>rs(n,16,"0x")},zs=[de,pe,Fe,Ue,mt,os,as,ls,ss,ns,is];function Et(n){return typeof n=="bigint"||Number.isInteger(n)}const Ee=({value:n})=>JSON.stringify(n),Zs=[{identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify:Ee},{identify:n=>n==null,createNode:()=>new T(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Ee},{identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:n=>n==="true",stringify:Ee},{identify:Et,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(n,e,{intAsBigInt:t})=>t?BigInt(n):parseInt(n,10),stringify:({value:n})=>Et(n)?n.toString():JSON.stringify(n)},{identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:n=>parseFloat(n),stringify:Ee}],en={default:!0,tag:"",test:/^/,resolve(n,e){return e(`Unresolved plain scalar ${JSON.stringify(n)}`),n}},tn=[de,pe].concat(Zs,en),yt={identify:n=>n instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(n,e){if(typeof atob=="function"){const t=atob(n.replace(/[\n\r]/g,"")),s=new Uint8Array(t.length);for(let i=0;i<t.length;++i)s[i]=t.charCodeAt(i);return s}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),n},stringify({comment:n,type:e,value:t},s,i,r){if(!t)return"";const o=t;let a;if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=T.BLOCK_LITERAL),e!==T.QUOTE_DOUBLE){const l=Math.max(s.options.lineWidth-s.indent.length,s.options.minContentWidth),c=Math.ceil(a.length/l),d=new Array(c);for(let f=0,u=0;f<c;++f,u+=l)d[f]=a.substr(u,l);a=d.join(e===T.BLOCK_LITERAL?`
52
+ `:" ")}return dt({comment:n,type:e,value:a},s,i,r)}};function cs(n,e){if(Te(n))for(let t=0;t<n.items.length;++t){let s=n.items[t];if(!v(s)){if(Ne(s)){s.items.length>1&&e("Each pair must have its own sequence indicator");const i=s.items[0]||new P(new T(null));if(s.commentBefore&&(i.key.commentBefore=i.key.commentBefore?`${s.commentBefore}
53
53
  ${i.key.commentBefore}`:s.commentBefore),s.comment){const r=i.value??i.key;r.comment=r.comment?`${s.comment}
54
- ${r.comment}`:s.comment}s=i}n.items[t]=_(s)?s:new P(s)}}else e("Expected a sequence for this tag");return n}function is(n,e,t){const{replacer:s}=t,i=new X(n);i.tag="tag:yaml.org,2002:pairs";let r=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof s=="function"&&(o=s.call(e,String(r++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){const c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;i.items.push(lt(a,l,t))}return i}const ht={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:ns,createNode:is};class re extends X{constructor(){super(),this.add=K.prototype.add.bind(this),this.delete=K.prototype.delete.bind(this),this.get=K.prototype.get.bind(this),this.has=K.prototype.has.bind(this),this.set=K.prototype.set.bind(this),this.tag=re.tag}toJSON(e,t){if(!t)return super.toJSON(e);const s=new Map;t?.onCreate&&t.onCreate(s);for(const i of this.items){let r,o;if(_(i)?(r=D(i.key,"",t),o=D(i.value,r,t)):r=D(i,"",t),s.has(r))throw new Error("Ordered maps must not include duplicate keys");s.set(r,o)}return s}static from(e,t,s){const i=is(e,t,s),r=new this;return r.items=i.items,r}}re.tag="tag:yaml.org,2002:omap";const dt={collection:"seq",identify:n=>n instanceof Map,nodeClass:re,default:!1,tag:"tag:yaml.org,2002:omap",resolve(n,e){const t=ns(n,e),s=[];for(const{key:i}of t.items)I(i)&&(s.includes(i.value)?e(`Ordered maps must not include duplicate keys: ${i.value}`):s.push(i.value));return Object.assign(new re,t)},createNode:(n,e,t)=>re.from(n,e,t)};function rs({value:n,source:e},t){return e&&(n?os:as).test.test(e)?e:n?t.options.trueStr:t.options.falseStr}const os={identify:n=>n===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new T(!0),stringify:rs},as={identify:n=>n===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new T(!1),stringify:rs},Hs={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:F},Qs={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n.replace(/_/g,"")),stringify(n){const e=Number(n.value);return isFinite(e)?e.toExponential():F(n)}},Ws={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(n){const e=new T(parseFloat(n.replace(/_/g,""))),t=n.indexOf(".");if(t!==-1){const s=n.substring(t+1).replace(/_/g,"");s[s.length-1]==="0"&&(e.minFractionDigits=s.length)}return e},stringify:F},Ne=n=>typeof n=="bigint"||Number.isInteger(n);function Fe(n,e,t,{intAsBigInt:s}){const i=n[0];if((i==="-"||i==="+")&&(e+=1),n=n.substring(e).replace(/_/g,""),s){switch(t){case 2:n=`0b${n}`;break;case 8:n=`0o${n}`;break;case 16:n=`0x${n}`;break}const o=BigInt(n);return i==="-"?BigInt(-1)*o:o}const r=parseInt(n,t);return i==="-"?-1*r:r}function pt(n,e,t){const{value:s}=n;if(Ne(s)){const i=s.toString(e);return s<0?"-"+t+i.substr(1):t+i}return F(n)}const Xs={identify:Ne,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(n,e,t)=>Fe(n,2,2,t),stringify:n=>pt(n,2,"0b")},zs={identify:Ne,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(n,e,t)=>Fe(n,1,8,t),stringify:n=>pt(n,8,"0")},Zs={identify:Ne,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(n,e,t)=>Fe(n,0,10,t),stringify:F},en={identify:Ne,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(n,e,t)=>Fe(n,2,16,t),stringify:n=>pt(n,16,"0x")};class oe extends K{constructor(e){super(e),this.tag=oe.tag}add(e){let t;_(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new P(e.key,null):t=new P(e,null),W(this.items,t.key)||this.items.push(t)}get(e,t){const s=W(this.items,e);return!t&&_(s)?I(s.key)?s.key.value:s.key:s}set(e,t){if(typeof t!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);const s=W(this.items,e);s&&!t?this.items.splice(this.items.indexOf(s),1):!s&&t&&this.items.push(new P(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:i}=s,r=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t)typeof i=="function"&&(o=i.call(t,o,o)),r.items.push(lt(o,null,s));return r}}oe.tag="tag:yaml.org,2002:set";const mt={collection:"map",identify:n=>n instanceof Set,nodeClass:oe,default:!1,tag:"tag:yaml.org,2002:set",createNode:(n,e,t)=>oe.from(n,e,t),resolve(n,e){if(ke(n)){if(n.hasAllNullValues(!0))return Object.assign(new oe,n);e("Set items must all have null values")}else e("Expected a mapping for this tag");return n}};function gt(n,e){const t=n[0],s=t==="-"||t==="+"?n.substring(1):n,i=o=>e?BigInt(o):Number(o),r=s.replace(/_/g,"").split(":").reduce((o,a)=>o*i(60)+i(a),i(0));return t==="-"?i(-1)*r:r}function ls(n){let{value:e}=n,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return F(n);let s="";e<0&&(s="-",e*=t(-1));const i=t(60),r=[e%i];return e<60?r.unshift(0):(e=(e-r[0])/i,r.unshift(e%i),e>=60&&(e=(e-r[0])/i,r.unshift(e))),s+r.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const cs={identify:n=>typeof n=="bigint"||Number.isInteger(n),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(n,e,{intAsBigInt:t})=>gt(n,t),stringify:ls},fs={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:n=>gt(n,!1),stringify:ls},Ue={identify:n=>n 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(n){const e=n.match(Ue.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,t,s,i,r,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0;let c=Date.UTC(t,s-1,i,r||0,o||0,a||0,l);const d=e[8];if(d&&d!=="Z"){let f=gt(d,!1);Math.abs(f)<30&&(f*=60),c-=6e4*f}return new Date(c)},stringify:({value:n})=>n?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""},Tt=[ue,he,je,qe,os,as,Xs,zs,Zs,en,Hs,Qs,Ws,ut,x,dt,ht,mt,cs,fs,Ue],Ot=new Map([["core",xs],["failsafe",[ue,he,je]],["json",Gs],["yaml11",Tt],["yaml-1.1",Tt]]),At={binary:ut,bool:ct,float:zt,floatExp:Xt,floatNaN:Wt,floatTime:fs,int:ts,intHex:ss,intOct:es,intTime:cs,map:ue,merge:x,null:qe,omap:dt,pairs:ht,seq:he,set:mt,timestamp:Ue},tn={"tag:yaml.org,2002:binary":ut,"tag:yaml.org,2002:merge":x,"tag:yaml.org,2002:omap":dt,"tag:yaml.org,2002:pairs":ht,"tag:yaml.org,2002:set":mt,"tag:yaml.org,2002:timestamp":Ue};function Je(n,e,t){const s=Ot.get(e);if(s&&!n)return t&&!s.includes(x)?s.concat(x):s.slice();let i=s;if(!i)if(Array.isArray(n))i=[];else{const r=Array.from(Ot.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${r} or define customTags array`)}if(Array.isArray(n))for(const r of n)i=i.concat(r);else typeof n=="function"&&(i=n(i.slice()));return t&&(i=i.concat(x)),i.reduce((r,o)=>{const a=typeof o=="string"?At[o]:o;if(!a){const l=JSON.stringify(o),c=Object.keys(At).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return r.includes(a)||r.push(a),r},[])}const sn=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0;class yt{constructor({compat:e,customTags:t,merge:s,resolveKnownTags:i,schema:r,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?Je(e,"compat"):e?Je(null,e):null,this.name=typeof r=="string"&&r||"core",this.knownTags=i?tn:{},this.tags=Je(t,this.name,s),this.toStringOptions=a??null,Object.defineProperty(this,G,{value:ue}),Object.defineProperty(this,U,{value:je}),Object.defineProperty(this,ce,{value:he}),this.sortMapEntries=typeof o=="function"?o:o===!0?sn:null}clone(){const e=Object.create(yt.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}function nn(n,e){const t=[];let s=e.directives===!0;if(e.directives!==!1&&n.directives){const l=n.directives.toString(n);l?(t.push(l),s=!0):n.directives.docStart&&(s=!0)}s&&t.push("---");const i=Yt(n,e),{commentString:r}=i.options;if(n.commentBefore){t.length!==1&&t.unshift("");const l=r(n.commentBefore);t.unshift(V(l,""))}let o=!1,a=null;if(n.contents){if(L(n.contents)){if(n.contents.spaceBefore&&s&&t.push(""),n.contents.commentBefore){const d=r(n.contents.commentBefore);t.push(V(d,""))}i.forceBlockIndent=!!n.comment,a=n.contents.comment}const l=a?void 0:()=>o=!0;let c=ae(n.contents,i,()=>a=null,l);a&&(c+=Q(c,"",r(a))),(c[0]==="|"||c[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${c}`:t.push(c)}else t.push(ae(n.contents,i));if(n.directives?.docEnd)if(n.comment){const l=r(n.comment);l.includes(`
55
- `)?(t.push("..."),t.push(V(l,""))):t.push(`... ${l}`)}else t.push("...");else{let l=n.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||a)&&t[t.length-1]!==""&&t.push(""),t.push(V(r(l),"")))}return t.join(`
54
+ ${r.comment}`:s.comment}s=i}n.items[t]=v(s)?s:new P(s)}}else e("Expected a sequence for this tag");return n}function fs(n,e,t){const{replacer:s}=t,i=new Z(n);i.tag="tag:yaml.org,2002:pairs";let r=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof s=="function"&&(o=s.call(e,String(r++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){const c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;i.items.push(pt(a,l,t))}return i}const bt={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:cs,createNode:fs};class ae extends Z{constructor(){super(),this.add=K.prototype.add.bind(this),this.delete=K.prototype.delete.bind(this),this.get=K.prototype.get.bind(this),this.has=K.prototype.has.bind(this),this.set=K.prototype.set.bind(this),this.tag=ae.tag}toJSON(e,t){if(!t)return super.toJSON(e);const s=new Map;t?.onCreate&&t.onCreate(s);for(const i of this.items){let r,o;if(v(i)?(r=D(i.key,"",t),o=D(i.value,r,t)):r=D(i,"",t),s.has(r))throw new Error("Ordered maps must not include duplicate keys");s.set(r,o)}return s}static from(e,t,s){const i=fs(e,t,s),r=new this;return r.items=i.items,r}}ae.tag="tag:yaml.org,2002:omap";const wt={collection:"seq",identify:n=>n instanceof Map,nodeClass:ae,default:!1,tag:"tag:yaml.org,2002:omap",resolve(n,e){const t=cs(n,e),s=[];for(const{key:i}of t.items)I(i)&&(s.includes(i.value)?e(`Ordered maps must not include duplicate keys: ${i.value}`):s.push(i.value));return Object.assign(new ae,t)},createNode:(n,e,t)=>ae.from(n,e,t)};function us({value:n,source:e},t){return e&&(n?hs:ds).test.test(e)?e:n?t.options.trueStr:t.options.falseStr}const hs={identify:n=>n===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new T(!0),stringify:us},ds={identify:n=>n===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new T(!1),stringify:us},sn={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:U},nn={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n.replace(/_/g,"")),stringify(n){const e=Number(n.value);return isFinite(e)?e.toExponential():U(n)}},rn={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(n){const e=new T(parseFloat(n.replace(/_/g,""))),t=n.indexOf(".");if(t!==-1){const s=n.substring(t+1).replace(/_/g,"");s[s.length-1]==="0"&&(e.minFractionDigits=s.length)}return e},stringify:U},Ae=n=>typeof n=="bigint"||Number.isInteger(n);function Ve(n,e,t,{intAsBigInt:s}){const i=n[0];if((i==="-"||i==="+")&&(e+=1),n=n.substring(e).replace(/_/g,""),s){switch(t){case 2:n=`0b${n}`;break;case 8:n=`0o${n}`;break;case 16:n=`0x${n}`;break}const o=BigInt(n);return i==="-"?BigInt(-1)*o:o}const r=parseInt(n,t);return i==="-"?-1*r:r}function kt(n,e,t){const{value:s}=n;if(Ae(s)){const i=s.toString(e);return s<0?"-"+t+i.substr(1):t+i}return U(n)}const on={identify:Ae,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(n,e,t)=>Ve(n,2,2,t),stringify:n=>kt(n,2,"0b")},an={identify:Ae,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(n,e,t)=>Ve(n,1,8,t),stringify:n=>kt(n,8,"0")},ln={identify:Ae,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(n,e,t)=>Ve(n,0,10,t),stringify:U},cn={identify:Ae,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(n,e,t)=>Ve(n,2,16,t),stringify:n=>kt(n,16,"0x")};class le extends K{constructor(e){super(e),this.tag=le.tag}add(e){let t;v(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new P(e.key,null):t=new P(e,null),z(this.items,t.key)||this.items.push(t)}get(e,t){const s=z(this.items,e);return!t&&v(s)?I(s.key)?s.key.value:s.key:s}set(e,t){if(typeof t!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);const s=z(this.items,e);s&&!t?this.items.splice(this.items.indexOf(s),1):!s&&t&&this.items.push(new P(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:i}=s,r=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t)typeof i=="function"&&(o=i.call(t,o,o)),r.items.push(pt(o,null,s));return r}}le.tag="tag:yaml.org,2002:set";const St={collection:"map",identify:n=>n instanceof Set,nodeClass:le,default:!1,tag:"tag:yaml.org,2002:set",createNode:(n,e,t)=>le.from(n,e,t),resolve(n,e){if(Ne(n)){if(n.hasAllNullValues(!0))return Object.assign(new le,n);e("Set items must all have null values")}else e("Expected a mapping for this tag");return n}};function Nt(n,e){const t=n[0],s=t==="-"||t==="+"?n.substring(1):n,i=o=>e?BigInt(o):Number(o),r=s.replace(/_/g,"").split(":").reduce((o,a)=>o*i(60)+i(a),i(0));return t==="-"?i(-1)*r:r}function ps(n){let{value:e}=n,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return U(n);let s="";e<0&&(s="-",e*=t(-1));const i=t(60),r=[e%i];return e<60?r.unshift(0):(e=(e-r[0])/i,r.unshift(e%i),e>=60&&(e=(e-r[0])/i,r.unshift(e))),s+r.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const ms={identify:n=>typeof n=="bigint"||Number.isInteger(n),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(n,e,{intAsBigInt:t})=>Nt(n,t),stringify:ps},gs={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:n=>Nt(n,!1),stringify:ps},Je={identify:n=>n 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(n){const e=n.match(Je.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,t,s,i,r,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0;let c=Date.UTC(t,s-1,i,r||0,o||0,a||0,l);const d=e[8];if(d&&d!=="Z"){let f=Nt(d,!1);Math.abs(f)<30&&(f*=60),c-=6e4*f}return new Date(c)},stringify:({value:n})=>n?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""},Lt=[de,pe,Fe,Ue,hs,ds,on,an,ln,cn,sn,nn,rn,yt,Y,wt,bt,St,ms,gs,Je],vt=new Map([["core",zs],["failsafe",[de,pe,Fe]],["json",tn],["yaml11",Lt],["yaml-1.1",Lt]]),Ct={binary:yt,bool:mt,float:is,floatExp:ns,floatNaN:ss,floatTime:gs,int:as,intHex:ls,intOct:os,intTime:ms,map:de,merge:Y,null:Ue,omap:wt,pairs:bt,seq:pe,set:St,timestamp:Je},fn={"tag:yaml.org,2002:binary":yt,"tag:yaml.org,2002:merge":Y,"tag:yaml.org,2002:omap":wt,"tag:yaml.org,2002:pairs":bt,"tag:yaml.org,2002:set":St,"tag:yaml.org,2002:timestamp":Je};function We(n,e,t){const s=vt.get(e);if(s&&!n)return t&&!s.includes(Y)?s.concat(Y):s.slice();let i=s;if(!i)if(Array.isArray(n))i=[];else{const r=Array.from(vt.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${r} or define customTags array`)}if(Array.isArray(n))for(const r of n)i=i.concat(r);else typeof n=="function"&&(i=n(i.slice()));return t&&(i=i.concat(Y)),i.reduce((r,o)=>{const a=typeof o=="string"?Ct[o]:o;if(!a){const l=JSON.stringify(o),c=Object.keys(Ct).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return r.includes(a)||r.push(a),r},[])}const un=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0;class Tt{constructor({compat:e,customTags:t,merge:s,resolveKnownTags:i,schema:r,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?We(e,"compat"):e?We(null,e):null,this.name=typeof r=="string"&&r||"core",this.knownTags=i?fn:{},this.tags=We(t,this.name,s),this.toStringOptions=a??null,Object.defineProperty(this,Q,{value:de}),Object.defineProperty(this,V,{value:Fe}),Object.defineProperty(this,ue,{value:pe}),this.sortMapEntries=typeof o=="function"?o:o===!0?un:null}clone(){const e=Object.create(Tt.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}function hn(n,e){const t=[];let s=e.directives===!0;if(e.directives!==!1&&n.directives){const l=n.directives.toString(n);l?(t.push(l),s=!0):n.directives.docStart&&(s=!0)}s&&t.push("---");const i=zt(n,e),{commentString:r}=i.options;if(n.commentBefore){t.length!==1&&t.unshift("");const l=r(n.commentBefore);t.unshift(J(l,""))}let o=!1,a=null;if(n.contents){if(L(n.contents)){if(n.contents.spaceBefore&&s&&t.push(""),n.contents.commentBefore){const d=r(n.contents.commentBefore);t.push(J(d,""))}i.forceBlockIndent=!!n.comment,a=n.contents.comment}const l=a?void 0:()=>o=!0;let c=ce(n.contents,i,()=>a=null,l);a&&(c+=X(c,"",r(a))),(c[0]==="|"||c[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${c}`:t.push(c)}else t.push(ce(n.contents,i));if(n.directives?.docEnd)if(n.comment){const l=r(n.comment);l.includes(`
55
+ `)?(t.push("..."),t.push(J(l,""))):t.push(`... ${l}`)}else t.push("...");else{let l=n.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||a)&&t[t.length-1]!==""&&t.push(""),t.push(J(r(l),"")))}return t.join(`
56
56
  `)+`
57
- `}class Ve{constructor(e,t,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,j,{value:We});let i=null;typeof t=="function"||Array.isArray(t)?i=t:s===void 0&&t&&(s=t,t=void 0);const r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},s);this.options=r;let{version:o}=r;s?._directives?(this.directives=s._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new B({version:o}),this.setSchema(o,s),this.contents=e===void 0?null:this.createNode(e,i,s)}clone(){const e=Object.create(Ve.prototype,{[j]:{value:We}});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=L(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){ee(this.contents)&&this.contents.add(e)}addIn(e,t){ee(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){const s=Ft(this);e.anchor=!t||s.has(t)?Ut(t||"a",s):t}return new ot(e.anchor)}createNode(e,t,s){let i;if(typeof t=="function")e=t.call({"":e},"",e),i=t;else if(Array.isArray(t)){const p=w=>typeof w=="number"||w instanceof String||w instanceof Number,b=t.filter(p).map(String);b.length>0&&(t=t.concat(b)),i=t}else s===void 0&&t&&(s=t,t=void 0);const{aliasDuplicateObjects:r,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:d}=s??{},{onAnchor:f,setAnchors:u,sourceObjects:m}=_s(this,o||"a"),g={aliasDuplicateObjects:r??!0,keepUndefined:l??!1,onAnchor:f,onTagObj:c,replacer:i,schema:this.schema,sourceObjects:m},h=be(e,d,g);return a&&$(h)&&(h.flow=!0),u(),h}createPair(e,t,s={}){const i=this.createNode(e,null,s),r=this.createNode(t,null,s);return new P(i,r)}delete(e){return ee(this.contents)?this.contents.delete(e):!1}deleteIn(e){return pe(e)?this.contents==null?!1:(this.contents=null,!0):ee(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return $(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return pe(e)?!t&&I(this.contents)?this.contents.value:this.contents:$(this.contents)?this.contents.getIn(e,t):void 0}has(e){return $(this.contents)?this.contents.has(e):!1}hasIn(e){return pe(e)?this.contents!==void 0:$(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Ce(this.schema,[e],t):ee(this.contents)&&this.contents.set(e,t)}setIn(e,t){pe(e)?this.contents=t:this.contents==null?this.contents=Ce(this.schema,Array.from(e),t):ee(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let s;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new B({version:"1.1"}),s={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new B({version:e}),s={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,s=null;break;default:{const i=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(s)this.schema=new yt(Object.assign(s,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:s,maxAliasCount:i,onAnchor:r,reviver:o}={}){const a={anchors:new Map,doc:this,keep:!e,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},l=D(this.contents,t??"",a);if(typeof r=="function")for(const{count:c,res:d}of a.anchors.values())r(d,c);return typeof o=="function"?ne(o,{"":l},"",l):l}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 nn(this,e)}}function ee(n){if($(n))return!0;throw new Error("Expected a YAML collection as document contents")}class us extends Error{constructor(e,t,s,i){super(),this.name=e,this.code=s,this.message=i,this.pos=t}}class me extends us{constructor(e,t,s){super("YAMLParseError",e,t,s)}}class rn extends us{constructor(e,t,s){super("YAMLWarning",e,t,s)}}const It=(n,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(a=>e.linePos(a));const{line:s,col:i}=t.linePos[0];t.message+=` at line ${s}, column ${i}`;let r=i-1,o=n.substring(e.lineStarts[s-1],e.lineStarts[s]).replace(/[\n\r]+$/,"");if(r>=60&&o.length>80){const a=Math.min(r-39,o.length-79);o="…"+o.substring(a),r-=a-1}if(o.length>80&&(o=o.substring(0,79)+"…"),s>1&&/^ *$/.test(o.substring(0,r))){let a=n.substring(e.lineStarts[s-2],e.lineStarts[s-1]);a.length>80&&(a=a.substring(0,79)+`…
57
+ `}class Ye{constructor(e,t,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,j,{value:tt});let i=null;typeof t=="function"||Array.isArray(t)?i=t:s===void 0&&t&&(s=t,t=void 0);const r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},s);this.options=r;let{version:o}=r;s?._directives?(this.directives=s._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new B({version:o}),this.setSchema(o,s),this.contents=e===void 0?null:this.createNode(e,i,s)}clone(){const e=Object.create(Ye.prototype,{[j]:{value:tt}});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=L(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){se(this.contents)&&this.contents.add(e)}addIn(e,t){se(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){const s=Gt(this);e.anchor=!t||s.has(t)?Ht(t||"a",s):t}return new ht(e.anchor)}createNode(e,t,s){let i;if(typeof t=="function")e=t.call({"":e},"",e),i=t;else if(Array.isArray(t)){const p=w=>typeof w=="number"||w instanceof String||w instanceof Number,b=t.filter(p).map(String);b.length>0&&(t=t.concat(b)),i=t}else s===void 0&&t&&(s=t,t=void 0);const{aliasDuplicateObjects:r,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:d}=s??{},{onAnchor:f,setAnchors:u,sourceObjects:m}=js(this,o||"a"),g={aliasDuplicateObjects:r??!0,keepUndefined:l??!1,onAnchor:f,onTagObj:c,replacer:i,schema:this.schema,sourceObjects:m},h=ke(e,d,g);return a&&E(h)&&(h.flow=!0),u(),h}createPair(e,t,s={}){const i=this.createNode(e,null,s),r=this.createNode(t,null,s);return new P(i,r)}delete(e){return se(this.contents)?this.contents.delete(e):!1}deleteIn(e){return ge(e)?this.contents==null?!1:(this.contents=null,!0):se(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return E(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return ge(e)?!t&&I(this.contents)?this.contents.value:this.contents:E(this.contents)?this.contents.getIn(e,t):void 0}has(e){return E(this.contents)?this.contents.has(e):!1}hasIn(e){return ge(e)?this.contents!==void 0:E(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Be(this.schema,[e],t):se(this.contents)&&this.contents.set(e,t)}setIn(e,t){ge(e)?this.contents=t:this.contents==null?this.contents=Be(this.schema,Array.from(e),t):se(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let s;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new B({version:"1.1"}),s={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new B({version:e}),s={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,s=null;break;default:{const i=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(s)this.schema=new Tt(Object.assign(s,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:s,maxAliasCount:i,onAnchor:r,reviver:o}={}){const a={anchors:new Map,doc:this,keep:!e,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},l=D(this.contents,t??"",a);if(typeof r=="function")for(const{count:c,res:d}of a.anchors.values())r(d,c);return typeof o=="function"?re(o,{"":l},"",l):l}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 hn(this,e)}}function se(n){if(E(n))return!0;throw new Error("Expected a YAML collection as document contents")}class ys extends Error{constructor(e,t,s,i){super(),this.name=e,this.code=s,this.message=i,this.pos=t}}class ye extends ys{constructor(e,t,s){super("YAMLParseError",e,t,s)}}class dn extends ys{constructor(e,t,s){super("YAMLWarning",e,t,s)}}const _t=(n,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(a=>e.linePos(a));const{line:s,col:i}=t.linePos[0];t.message+=` at line ${s}, column ${i}`;let r=i-1,o=n.substring(e.lineStarts[s-1],e.lineStarts[s]).replace(/[\n\r]+$/,"");if(r>=60&&o.length>80){const a=Math.min(r-39,o.length-79);o="…"+o.substring(a),r-=a-1}if(o.length>80&&(o=o.substring(0,79)+"…"),s>1&&/^ *$/.test(o.substring(0,r))){let a=n.substring(e.lineStarts[s-2],e.lineStarts[s-1]);a.length>80&&(a=a.substring(0,79)+`…
58
58
  `),o=a+o}if(/[^ ]/.test(o)){let a=1;const l=t.linePos[1];l?.line===s&&l.col>i&&(a=Math.max(1,Math.min(l.col-i,80-r)));const c=" ".repeat(r)+"^".repeat(a);t.message+=`:
59
59
 
60
60
  ${o}
61
61
  ${c}
62
- `}};function le(n,{flow:e,indicator:t,next:s,offset:i,onError:r,parentIndent:o,startOnNewline:a}){let l=!1,c=a,d=a,f="",u="",m=!1,g=!1,h=null,p=null,b=null,w=null,k=null,S=null,N=null;for(const y of n)switch(g&&(y.type!=="space"&&y.type!=="newline"&&y.type!=="comma"&&r(y.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),h&&(c&&y.type!=="comment"&&y.type!=="newline"&&r(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),y.type){case"space":!e&&(t!=="doc-start"||s?.type!=="flow-collection")&&y.source.includes(" ")&&(h=y),d=!0;break;case"comment":{d||r(y,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const C=y.source.substring(1)||" ";f?f+=u+C:f=C,u="",c=!1;break}case"newline":c?f?f+=y.source:(!S||t!=="seq-item-ind")&&(l=!0):u+=y.source,c=!0,m=!0,(p||b)&&(w=y),d=!0;break;case"anchor":p&&r(y,"MULTIPLE_ANCHORS","A node can have at most one anchor"),y.source.endsWith(":")&&r(y.offset+y.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),p=y,N??(N=y.offset),c=!1,d=!1,g=!0;break;case"tag":{b&&r(y,"MULTIPLE_TAGS","A node can have at most one tag"),b=y,N??(N=y.offset),c=!1,d=!1,g=!0;break}case t:(p||b)&&r(y,"BAD_PROP_ORDER",`Anchors and tags must be after the ${y.source} indicator`),S&&r(y,"UNEXPECTED_TOKEN",`Unexpected ${y.source} in ${e??"collection"}`),S=y,c=t==="seq-item-ind"||t==="explicit-key-ind",d=!1;break;case"comma":if(e){k&&r(y,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),k=y,c=!1,d=!1;break}default:r(y,"UNEXPECTED_TOKEN",`Unexpected ${y.type} token`),c=!1,d=!1}const O=n[n.length-1],A=O?O.offset+O.source.length:i;return g&&s&&s.type!=="space"&&s.type!=="newline"&&s.type!=="comma"&&(s.type!=="scalar"||s.source!=="")&&r(s.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(c&&h.indent<=o||s?.type==="block-map"||s?.type==="block-seq")&&r(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:k,found:S,spaceBefore:l,comment:f,hasNewline:m,anchor:p,tag:b,newlineAfterProp:w,end:A,start:N??A}}function we(n){if(!n)return null;switch(n.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(n.source.includes(`
63
- `))return!0;if(n.end){for(const e of n.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(const e of n.items){for(const t of e.start)if(t.type==="newline")return!0;if(e.sep){for(const t of e.sep)if(t.type==="newline")return!0}if(we(e.key)||we(e.value))return!0}return!1;default:return!0}}function et(n,e,t){if(e?.type==="flow-collection"){const s=e.end[0];s.indent===n&&(s.source==="]"||s.source==="}")&&we(e)&&t(s,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function hs(n,e,t){const{uniqueKeys:s}=n.options;if(s===!1)return!1;const i=typeof s=="function"?s:(r,o)=>r===o||I(r)&&I(o)&&r.value===o.value;return e.some(r=>i(r.key,t))}const Et="All mapping items must start at the same column";function on({composeNode:n,composeEmptyNode:e},t,s,i,r){const o=r?.nodeClass??K,a=new o(t.schema);t.atRoot&&(t.atRoot=!1);let l=s.offset,c=null;for(const d of s.items){const{start:f,key:u,sep:m,value:g}=d,h=le(f,{indicator:"explicit-key-ind",next:u??m?.[0],offset:l,onError:i,parentIndent:s.indent,startOnNewline:!0}),p=!h.found;if(p){if(u&&(u.type==="block-seq"?i(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in u&&u.indent!==s.indent&&i(l,"BAD_INDENT",Et)),!h.anchor&&!h.tag&&!m){c=h.end,h.comment&&(a.comment?a.comment+=`
64
- `+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||we(u))&&i(u??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==s.indent&&i(l,"BAD_INDENT",Et);t.atKey=!0;const b=h.end,w=u?n(t,u,h,i):e(t,b,f,null,h,i);t.schema.compat&&et(s.indent,u,i),t.atKey=!1,hs(t,a.items,w)&&i(b,"DUPLICATE_KEY","Map keys must be unique");const k=le(m??[],{indicator:"map-value-ind",next:g,offset:w.range[2],onError:i,parentIndent:s.indent,startOnNewline:!u||u.type==="block-scalar"});if(l=k.end,k.found){p&&(g?.type==="block-map"&&!k.hasNewline&&i(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&h.start<k.found.offset-1024&&i(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));const S=g?n(t,g,k,i):e(t,l,m,null,k,i);t.schema.compat&&et(s.indent,g,i),l=S.range[2];const N=new P(w,S);t.options.keepSourceTokens&&(N.srcToken=d),a.items.push(N)}else{p&&i(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(w.comment?w.comment+=`
65
- `+k.comment:w.comment=k.comment);const S=new P(w);t.options.keepSourceTokens&&(S.srcToken=d),a.items.push(S)}}return c&&c<l&&i(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[s.offset,l,c??l],a}function an({composeNode:n,composeEmptyNode:e},t,s,i,r){const o=r?.nodeClass??X,a=new o(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let l=s.offset,c=null;for(const{start:d,value:f}of s.items){const u=le(d,{indicator:"seq-item-ind",next:f,offset:l,onError:i,parentIndent:s.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||f)f?.type==="block-seq"?i(u.end,"BAD_INDENT","All sequence items must start at the same column"):i(l,"MISSING_CHAR","Sequence item without - indicator");else{c=u.end,u.comment&&(a.comment=u.comment);continue}const m=f?n(t,f,u,i):e(t,u.end,d,null,u,i);t.schema.compat&&et(s.indent,f,i),l=m.range[2],a.items.push(m)}return a.range=[s.offset,l,c??l],a}function Te(n,e,t,s){let i="";if(n){let r=!1,o="";for(const a of n){const{source:l,type:c}=a;switch(c){case"space":r=!0;break;case"comment":{t&&!r&&s(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const d=l.substring(1)||" ";i?i+=o+d:i=d,o="";break}case"newline":i&&(o+=l),r=!0;break;default:s(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:i,offset:e}}const Ye="Block collections are not allowed within flow collections",Ge=n=>n&&(n.type==="block-map"||n.type==="block-seq");function ln({composeNode:n,composeEmptyNode:e},t,s,i,r){const o=s.start.source==="{",a=o?"flow map":"flow sequence",l=r?.nodeClass??(o?K:X),c=new l(t.schema);c.flow=!0;const d=t.atRoot;d&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let f=s.offset+s.start.source.length;for(let p=0;p<s.items.length;++p){const b=s.items[p],{start:w,key:k,sep:S,value:N}=b,O=le(w,{flow:a,indicator:"explicit-key-ind",next:k??S?.[0],offset:f,onError:i,parentIndent:s.indent,startOnNewline:!1});if(!O.found){if(!O.anchor&&!O.tag&&!S&&!N){p===0&&O.comma?i(O.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):p<s.items.length-1&&i(O.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),O.comment&&(c.comment?c.comment+=`
66
- `+O.comment:c.comment=O.comment),f=O.end;continue}!o&&t.options.strict&&we(k)&&i(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(p===0)O.comma&&i(O.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(O.comma||i(O.start,"MISSING_CHAR",`Missing , between ${a} items`),O.comment){let A="";e:for(const y of w)switch(y.type){case"comma":case"space":break;case"comment":A=y.source.substring(1);break e;default:break e}if(A){let y=c.items[c.items.length-1];_(y)&&(y=y.value??y.key),y.comment?y.comment+=`
67
- `+A:y.comment=A,O.comment=O.comment.substring(A.length+1)}}if(!o&&!S&&!O.found){const A=N?n(t,N,O,i):e(t,O.end,S,null,O,i);c.items.push(A),f=A.range[2],Ge(N)&&i(A.range,"BLOCK_IN_FLOW",Ye)}else{t.atKey=!0;const A=O.end,y=k?n(t,k,O,i):e(t,A,w,null,O,i);Ge(k)&&i(y.range,"BLOCK_IN_FLOW",Ye),t.atKey=!1;const C=le(S??[],{flow:a,indicator:"map-value-ind",next:N,offset:y.range[2],onError:i,parentIndent:s.indent,startOnNewline:!1});if(C.found){if(!o&&!O.found&&t.options.strict){if(S)for(const M of S){if(M===C.found)break;if(M.type==="newline"){i(M,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}O.start<C.found.offset-1024&&i(C.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else N&&("source"in N&&N.source?.[0]===":"?i(N,"MISSING_CHAR",`Missing space after : in ${a}`):i(C.start,"MISSING_CHAR",`Missing , or : between ${a} items`));const J=N?n(t,N,C,i):C.found?e(t,C.end,S,null,C,i):null;J?Ge(N)&&i(J.range,"BLOCK_IN_FLOW",Ye):C.comment&&(y.comment?y.comment+=`
68
- `+C.comment:y.comment=C.comment);const Z=new P(y,J);if(t.options.keepSourceTokens&&(Z.srcToken=b),o){const M=c;hs(t,M.items,y)&&i(A,"DUPLICATE_KEY","Map keys must be unique"),M.items.push(Z)}else{const M=new K(t.schema);M.flow=!0,M.items.push(Z);const wt=(J??y).range;M.range=[y.range[0],wt[1],wt[2]],c.items.push(M)}f=J?J.range[2]:C.end}}const u=o?"}":"]",[m,...g]=s.end;let h=f;if(m?.source===u)h=m.offset+m.source.length;else{const p=a[0].toUpperCase()+a.substring(1),b=d?`${p} must end with a ${u}`:`${p} in block collection must be sufficiently indented and end with a ${u}`;i(f,d?"MISSING_CHAR":"BAD_INDENT",b),m&&m.source.length!==1&&g.unshift(m)}if(g.length>0){const p=Te(g,h,t.options.strict,i);p.comment&&(c.comment?c.comment+=`
69
- `+p.comment:c.comment=p.comment),c.range=[s.offset,h,p.offset]}else c.range=[s.offset,h,h];return c}function He(n,e,t,s,i,r){const o=t.type==="block-map"?on(n,e,t,s,r):t.type==="block-seq"?an(n,e,t,s,r):ln(n,e,t,s,r),a=o.constructor;return i==="!"||i===a.tagName?(o.tag=a.tagName,o):(i&&(o.tag=i),o)}function cn(n,e,t,s,i){const r=s.tag,o=r?e.directives.tagName(r.source,u=>i(r,"TAG_RESOLVE_FAILED",u)):null;if(t.type==="block-seq"){const{anchor:u,newlineAfterProp:m}=s,g=u&&r?u.offset>r.offset?u:r:u??r;g&&(!m||m.offset<g.offset)&&i(g,"MISSING_CHAR","Missing newline after block sequence props")}const a=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!r||!o||o==="!"||o===K.tagName&&a==="map"||o===X.tagName&&a==="seq")return He(n,e,t,i,o);let l=e.schema.tags.find(u=>u.tag===o&&u.collection===a);if(!l){const u=e.schema.knownTags[o];if(u?.collection===a)e.schema.tags.push(Object.assign({},u,{default:!1})),l=u;else return u?i(r,"BAD_COLLECTION_TYPE",`${u.tag} used for ${a} collection, but expects ${u.collection??"scalar"}`,!0):i(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),He(n,e,t,i,o)}const c=He(n,e,t,i,o,l),d=l.resolve?.(c,u=>i(r,"TAG_RESOLVE_FAILED",u),e.options)??c,f=L(d)?d:new T(d);return f.range=c.range,f.tag=o,l?.format&&(f.format=l.format),f}function fn(n,e,t){const s=e.offset,i=un(e,n.options.strict,t);if(!i)return{value:"",type:null,comment:"",range:[s,s,s]};const r=i.mode===">"?T.BLOCK_FOLDED:T.BLOCK_LITERAL,o=e.source?hn(e.source):[];let a=o.length;for(let h=o.length-1;h>=0;--h){const p=o[h][1];if(p===""||p==="\r")a=h;else break}if(a===0){const h=i.chomp==="+"&&o.length>0?`
62
+ `}};function fe(n,{flow:e,indicator:t,next:s,offset:i,onError:r,parentIndent:o,startOnNewline:a}){let l=!1,c=a,d=a,f="",u="",m=!1,g=!1,h=null,p=null,b=null,w=null,k=null,S=null,N=null;for(const y of n)switch(g&&(y.type!=="space"&&y.type!=="newline"&&y.type!=="comma"&&r(y.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),h&&(c&&y.type!=="comment"&&y.type!=="newline"&&r(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),y.type){case"space":!e&&(t!=="doc-start"||s?.type!=="flow-collection")&&y.source.includes(" ")&&(h=y),d=!0;break;case"comment":{d||r(y,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const _=y.source.substring(1)||" ";f?f+=u+_:f=_,u="",c=!1;break}case"newline":c?f?f+=y.source:(!S||t!=="seq-item-ind")&&(l=!0):u+=y.source,c=!0,m=!0,(p||b)&&(w=y),d=!0;break;case"anchor":p&&r(y,"MULTIPLE_ANCHORS","A node can have at most one anchor"),y.source.endsWith(":")&&r(y.offset+y.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),p=y,N??(N=y.offset),c=!1,d=!1,g=!0;break;case"tag":{b&&r(y,"MULTIPLE_TAGS","A node can have at most one tag"),b=y,N??(N=y.offset),c=!1,d=!1,g=!0;break}case t:(p||b)&&r(y,"BAD_PROP_ORDER",`Anchors and tags must be after the ${y.source} indicator`),S&&r(y,"UNEXPECTED_TOKEN",`Unexpected ${y.source} in ${e??"collection"}`),S=y,c=t==="seq-item-ind"||t==="explicit-key-ind",d=!1;break;case"comma":if(e){k&&r(y,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),k=y,c=!1,d=!1;break}default:r(y,"UNEXPECTED_TOKEN",`Unexpected ${y.type} token`),c=!1,d=!1}const A=n[n.length-1],O=A?A.offset+A.source.length:i;return g&&s&&s.type!=="space"&&s.type!=="newline"&&s.type!=="comma"&&(s.type!=="scalar"||s.source!=="")&&r(s.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(c&&h.indent<=o||s?.type==="block-map"||s?.type==="block-seq")&&r(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:k,found:S,spaceBefore:l,comment:f,hasNewline:m,anchor:p,tag:b,newlineAfterProp:w,end:O,start:N??O}}function Se(n){if(!n)return null;switch(n.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(n.source.includes(`
63
+ `))return!0;if(n.end){for(const e of n.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(const e of n.items){for(const t of e.start)if(t.type==="newline")return!0;if(e.sep){for(const t of e.sep)if(t.type==="newline")return!0}if(Se(e.key)||Se(e.value))return!0}return!1;default:return!0}}function rt(n,e,t){if(e?.type==="flow-collection"){const s=e.end[0];s.indent===n&&(s.source==="]"||s.source==="}")&&Se(e)&&t(s,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function bs(n,e,t){const{uniqueKeys:s}=n.options;if(s===!1)return!1;const i=typeof s=="function"?s:(r,o)=>r===o||I(r)&&I(o)&&r.value===o.value;return e.some(r=>i(r.key,t))}const Mt="All mapping items must start at the same column";function pn({composeNode:n,composeEmptyNode:e},t,s,i,r){const o=r?.nodeClass??K,a=new o(t.schema);t.atRoot&&(t.atRoot=!1);let l=s.offset,c=null;for(const d of s.items){const{start:f,key:u,sep:m,value:g}=d,h=fe(f,{indicator:"explicit-key-ind",next:u??m?.[0],offset:l,onError:i,parentIndent:s.indent,startOnNewline:!0}),p=!h.found;if(p){if(u&&(u.type==="block-seq"?i(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in u&&u.indent!==s.indent&&i(l,"BAD_INDENT",Mt)),!h.anchor&&!h.tag&&!m){c=h.end,h.comment&&(a.comment?a.comment+=`
64
+ `+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||Se(u))&&i(u??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==s.indent&&i(l,"BAD_INDENT",Mt);t.atKey=!0;const b=h.end,w=u?n(t,u,h,i):e(t,b,f,null,h,i);t.schema.compat&&rt(s.indent,u,i),t.atKey=!1,bs(t,a.items,w)&&i(b,"DUPLICATE_KEY","Map keys must be unique");const k=fe(m??[],{indicator:"map-value-ind",next:g,offset:w.range[2],onError:i,parentIndent:s.indent,startOnNewline:!u||u.type==="block-scalar"});if(l=k.end,k.found){p&&(g?.type==="block-map"&&!k.hasNewline&&i(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&h.start<k.found.offset-1024&&i(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));const S=g?n(t,g,k,i):e(t,l,m,null,k,i);t.schema.compat&&rt(s.indent,g,i),l=S.range[2];const N=new P(w,S);t.options.keepSourceTokens&&(N.srcToken=d),a.items.push(N)}else{p&&i(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(w.comment?w.comment+=`
65
+ `+k.comment:w.comment=k.comment);const S=new P(w);t.options.keepSourceTokens&&(S.srcToken=d),a.items.push(S)}}return c&&c<l&&i(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[s.offset,l,c??l],a}function mn({composeNode:n,composeEmptyNode:e},t,s,i,r){const o=r?.nodeClass??Z,a=new o(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let l=s.offset,c=null;for(const{start:d,value:f}of s.items){const u=fe(d,{indicator:"seq-item-ind",next:f,offset:l,onError:i,parentIndent:s.indent,startOnNewline:!0});if(!u.found)if(u.anchor||u.tag||f)f?.type==="block-seq"?i(u.end,"BAD_INDENT","All sequence items must start at the same column"):i(l,"MISSING_CHAR","Sequence item without - indicator");else{c=u.end,u.comment&&(a.comment=u.comment);continue}const m=f?n(t,f,u,i):e(t,u.end,d,null,u,i);t.schema.compat&&rt(s.indent,f,i),l=m.range[2],a.items.push(m)}return a.range=[s.offset,l,c??l],a}function Oe(n,e,t,s){let i="";if(n){let r=!1,o="";for(const a of n){const{source:l,type:c}=a;switch(c){case"space":r=!0;break;case"comment":{t&&!r&&s(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const d=l.substring(1)||" ";i?i+=o+d:i=d,o="";break}case"newline":i&&(o+=l),r=!0;break;default:s(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:i,offset:e}}const Xe="Block collections are not allowed within flow collections",ze=n=>n&&(n.type==="block-map"||n.type==="block-seq");function gn({composeNode:n,composeEmptyNode:e},t,s,i,r){const o=s.start.source==="{",a=o?"flow map":"flow sequence",l=r?.nodeClass??(o?K:Z),c=new l(t.schema);c.flow=!0;const d=t.atRoot;d&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let f=s.offset+s.start.source.length;for(let p=0;p<s.items.length;++p){const b=s.items[p],{start:w,key:k,sep:S,value:N}=b,A=fe(w,{flow:a,indicator:"explicit-key-ind",next:k??S?.[0],offset:f,onError:i,parentIndent:s.indent,startOnNewline:!1});if(!A.found){if(!A.anchor&&!A.tag&&!S&&!N){p===0&&A.comma?i(A.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):p<s.items.length-1&&i(A.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),A.comment&&(c.comment?c.comment+=`
66
+ `+A.comment:c.comment=A.comment),f=A.end;continue}!o&&t.options.strict&&Se(k)&&i(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(p===0)A.comma&&i(A.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(A.comma||i(A.start,"MISSING_CHAR",`Missing , between ${a} items`),A.comment){let O="";e:for(const y of w)switch(y.type){case"comma":case"space":break;case"comment":O=y.source.substring(1);break e;default:break e}if(O){let y=c.items[c.items.length-1];v(y)&&(y=y.value??y.key),y.comment?y.comment+=`
67
+ `+O:y.comment=O,A.comment=A.comment.substring(O.length+1)}}if(!o&&!S&&!A.found){const O=N?n(t,N,A,i):e(t,A.end,S,null,A,i);c.items.push(O),f=O.range[2],ze(N)&&i(O.range,"BLOCK_IN_FLOW",Xe)}else{t.atKey=!0;const O=A.end,y=k?n(t,k,A,i):e(t,O,w,null,A,i);ze(k)&&i(y.range,"BLOCK_IN_FLOW",Xe),t.atKey=!1;const _=fe(S??[],{flow:a,indicator:"map-value-ind",next:N,offset:y.range[2],onError:i,parentIndent:s.indent,startOnNewline:!1});if(_.found){if(!o&&!A.found&&t.options.strict){if(S)for(const M of S){if(M===_.found)break;if(M.type==="newline"){i(M,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}A.start<_.found.offset-1024&&i(_.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else N&&("source"in N&&N.source?.[0]===":"?i(N,"MISSING_CHAR",`Missing space after : in ${a}`):i(_.start,"MISSING_CHAR",`Missing , or : between ${a} items`));const G=N?n(t,N,_,i):_.found?e(t,_.end,S,null,_,i):null;G?ze(N)&&i(G.range,"BLOCK_IN_FLOW",Xe):_.comment&&(y.comment?y.comment+=`
68
+ `+_.comment:y.comment=_.comment);const te=new P(y,G);if(t.options.keepSourceTokens&&(te.srcToken=b),o){const M=c;bs(t,M.items,y)&&i(O,"DUPLICATE_KEY","Map keys must be unique"),M.items.push(te)}else{const M=new K(t.schema);M.flow=!0,M.items.push(te);const Ot=(G??y).range;M.range=[y.range[0],Ot[1],Ot[2]],c.items.push(M)}f=G?G.range[2]:_.end}}const u=o?"}":"]",[m,...g]=s.end;let h=f;if(m?.source===u)h=m.offset+m.source.length;else{const p=a[0].toUpperCase()+a.substring(1),b=d?`${p} must end with a ${u}`:`${p} in block collection must be sufficiently indented and end with a ${u}`;i(f,d?"MISSING_CHAR":"BAD_INDENT",b),m&&m.source.length!==1&&g.unshift(m)}if(g.length>0){const p=Oe(g,h,t.options.strict,i);p.comment&&(c.comment?c.comment+=`
69
+ `+p.comment:c.comment=p.comment),c.range=[s.offset,h,p.offset]}else c.range=[s.offset,h,h];return c}function Ze(n,e,t,s,i,r){const o=t.type==="block-map"?pn(n,e,t,s,r):t.type==="block-seq"?mn(n,e,t,s,r):gn(n,e,t,s,r),a=o.constructor;return i==="!"||i===a.tagName?(o.tag=a.tagName,o):(i&&(o.tag=i),o)}function yn(n,e,t,s,i){const r=s.tag,o=r?e.directives.tagName(r.source,u=>i(r,"TAG_RESOLVE_FAILED",u)):null;if(t.type==="block-seq"){const{anchor:u,newlineAfterProp:m}=s,g=u&&r?u.offset>r.offset?u:r:u??r;g&&(!m||m.offset<g.offset)&&i(g,"MISSING_CHAR","Missing newline after block sequence props")}const a=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!r||!o||o==="!"||o===K.tagName&&a==="map"||o===Z.tagName&&a==="seq")return Ze(n,e,t,i,o);let l=e.schema.tags.find(u=>u.tag===o&&u.collection===a);if(!l){const u=e.schema.knownTags[o];if(u?.collection===a)e.schema.tags.push(Object.assign({},u,{default:!1})),l=u;else return u?i(r,"BAD_COLLECTION_TYPE",`${u.tag} used for ${a} collection, but expects ${u.collection??"scalar"}`,!0):i(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Ze(n,e,t,i,o)}const c=Ze(n,e,t,i,o,l),d=l.resolve?.(c,u=>i(r,"TAG_RESOLVE_FAILED",u),e.options)??c,f=L(d)?d:new T(d);return f.range=c.range,f.tag=o,l?.format&&(f.format=l.format),f}function bn(n,e,t){const s=e.offset,i=wn(e,n.options.strict,t);if(!i)return{value:"",type:null,comment:"",range:[s,s,s]};const r=i.mode===">"?T.BLOCK_FOLDED:T.BLOCK_LITERAL,o=e.source?kn(e.source):[];let a=o.length;for(let h=o.length-1;h>=0;--h){const p=o[h][1];if(p===""||p==="\r")a=h;else break}if(a===0){const h=i.chomp==="+"&&o.length>0?`
70
70
  `.repeat(Math.max(1,o.length-1)):"";let p=s+i.length;return e.source&&(p+=e.source.length),{value:h,type:r,comment:i.comment,range:[s,p,p]}}let l=e.indent+i.indent,c=e.offset+i.length,d=0;for(let h=0;h<a;++h){const[p,b]=o[h];if(b===""||b==="\r")i.indent===0&&p.length>l&&(l=p.length);else{p.length<l&&t(c+p.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),i.indent===0&&(l=p.length),d=h,l===0&&!n.atRoot&&t(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=p.length+b.length+1}for(let h=o.length-1;h>=a;--h)o[h][0].length>l&&(a=h+1);let f="",u="",m=!1;for(let h=0;h<d;++h)f+=o[h][0].slice(l)+`
71
71
  `;for(let h=d;h<a;++h){let[p,b]=o[h];c+=p.length+b.length+1;const w=b[b.length-1]==="\r";if(w&&(b=b.slice(0,-1)),b&&p.length<l){const S=`Block scalar lines must not be less indented than their ${i.indent?"explicit indentation indicator":"first line"}`;t(c-b.length-(w?2:1),"BAD_INDENT",S),p=""}r===T.BLOCK_LITERAL?(f+=u+p.slice(l)+b,u=`
72
72
  `):p.length>l||b[0]===" "?(u===" "?u=`
@@ -81,52 +81,52 @@ ${c}
81
81
  `+o[h][0].slice(l);f[f.length-1]!==`
82
82
  `&&(f+=`
83
83
  `);break;default:f+=`
84
- `}const g=s+i.length+e.source.length;return{value:f,type:r,comment:i.comment,range:[s,g,g]}}function un({offset:n,props:e},t,s){if(e[0].type!=="block-scalar-header")return s(e[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:i}=e[0],r=i[0];let o=0,a="",l=-1;for(let u=1;u<i.length;++u){const m=i[u];if(!a&&(m==="-"||m==="+"))a=m;else{const g=Number(m);!o&&g?o=g:l===-1&&(l=n+u)}}l!==-1&&s(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let c=!1,d="",f=i.length;for(let u=1;u<e.length;++u){const m=e[u];switch(m.type){case"space":c=!0;case"newline":f+=m.source.length;break;case"comment":t&&!c&&s(m,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),f+=m.source.length,d=m.source.substring(1);break;case"error":s(m,"UNEXPECTED_TOKEN",m.message),f+=m.source.length;break;default:{const g=`Unexpected token in block scalar header: ${m.type}`;s(m,"UNEXPECTED_TOKEN",g);const h=m.source;h&&typeof h=="string"&&(f+=h.length)}}}return{mode:r,indent:o,chomp:a,comment:d,length:f}}function hn(n){const e=n.split(/\n( *)/),t=e[0],s=t.match(/^( *)/),r=[s?.[1]?[s[1],t.slice(s[1].length)]:["",t]];for(let o=1;o<e.length;o+=2)r.push([e[o],e[o+1]]);return r}function dn(n,e,t){const{offset:s,type:i,source:r,end:o}=n;let a,l;const c=(u,m,g)=>t(s+u,m,g);switch(i){case"scalar":a=T.PLAIN,l=pn(r,c);break;case"single-quoted-scalar":a=T.QUOTE_SINGLE,l=mn(r,c);break;case"double-quoted-scalar":a=T.QUOTE_DOUBLE,l=gn(r,c);break;default:return t(n,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${i}`),{value:"",type:null,comment:"",range:[s,s+r.length,s+r.length]}}const d=s+r.length,f=Te(o,d,e,t);return{value:l,type:a,comment:f.comment,range:[s,d,f.offset]}}function pn(n,e){let t="";switch(n[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${n[0]}`;break}case"@":case"`":{t=`reserved character ${n[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),ds(n)}function mn(n,e){return(n[n.length-1]!=="'"||n.length===1)&&e(n.length,"MISSING_CHAR","Missing closing 'quote"),ds(n.slice(1,-1)).replace(/''/g,"'")}function ds(n){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
84
+ `}const g=s+i.length+e.source.length;return{value:f,type:r,comment:i.comment,range:[s,g,g]}}function wn({offset:n,props:e},t,s){if(e[0].type!=="block-scalar-header")return s(e[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:i}=e[0],r=i[0];let o=0,a="",l=-1;for(let u=1;u<i.length;++u){const m=i[u];if(!a&&(m==="-"||m==="+"))a=m;else{const g=Number(m);!o&&g?o=g:l===-1&&(l=n+u)}}l!==-1&&s(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let c=!1,d="",f=i.length;for(let u=1;u<e.length;++u){const m=e[u];switch(m.type){case"space":c=!0;case"newline":f+=m.source.length;break;case"comment":t&&!c&&s(m,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),f+=m.source.length,d=m.source.substring(1);break;case"error":s(m,"UNEXPECTED_TOKEN",m.message),f+=m.source.length;break;default:{const g=`Unexpected token in block scalar header: ${m.type}`;s(m,"UNEXPECTED_TOKEN",g);const h=m.source;h&&typeof h=="string"&&(f+=h.length)}}}return{mode:r,indent:o,chomp:a,comment:d,length:f}}function kn(n){const e=n.split(/\n( *)/),t=e[0],s=t.match(/^( *)/),r=[s?.[1]?[s[1],t.slice(s[1].length)]:["",t]];for(let o=1;o<e.length;o+=2)r.push([e[o],e[o+1]]);return r}function Sn(n,e,t){const{offset:s,type:i,source:r,end:o}=n;let a,l;const c=(u,m,g)=>t(s+u,m,g);switch(i){case"scalar":a=T.PLAIN,l=Nn(r,c);break;case"single-quoted-scalar":a=T.QUOTE_SINGLE,l=Tn(r,c);break;case"double-quoted-scalar":a=T.QUOTE_DOUBLE,l=An(r,c);break;default:return t(n,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${i}`),{value:"",type:null,comment:"",range:[s,s+r.length,s+r.length]}}const d=s+r.length,f=Oe(o,d,e,t);return{value:l,type:a,comment:f.comment,range:[s,d,f.offset]}}function Nn(n,e){let t="";switch(n[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${n[0]}`;break}case"@":case"`":{t=`reserved character ${n[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),ws(n)}function Tn(n,e){return(n[n.length-1]!=="'"||n.length===1)&&e(n.length,"MISSING_CHAR","Missing closing 'quote"),ws(n.slice(1,-1)).replace(/''/g,"'")}function ws(n){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
85
85
  `,"sy"),t=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
86
86
  `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,t=/[ \t]*(.*?)[ \t]*\r?\n/sy}let s=e.exec(n);if(!s)return n;let i=s[1],r=" ",o=e.lastIndex;for(t.lastIndex=o;s=t.exec(n);)s[1]===""?r===`
87
87
  `?i+=r:r=`
88
- `:(i+=r+s[1],r=" "),o=t.lastIndex;const a=/[ \t]*(.*)/sy;return a.lastIndex=o,s=a.exec(n),i+r+(s?.[1]??"")}function gn(n,e){let t="";for(let s=1;s<n.length-1;++s){const i=n[s];if(!(i==="\r"&&n[s+1]===`
88
+ `:(i+=r+s[1],r=" "),o=t.lastIndex;const a=/[ \t]*(.*)/sy;return a.lastIndex=o,s=a.exec(n),i+r+(s?.[1]??"")}function An(n,e){let t="";for(let s=1;s<n.length-1;++s){const i=n[s];if(!(i==="\r"&&n[s+1]===`
89
89
  `))if(i===`
90
- `){const{fold:r,offset:o}=yn(n,s);t+=r,s=o}else if(i==="\\"){let r=n[++s];const o=bn[r];if(o)t+=o;else if(r===`
90
+ `){const{fold:r,offset:o}=On(n,s);t+=r,s=o}else if(i==="\\"){let r=n[++s];const o=In[r];if(o)t+=o;else if(r===`
91
91
  `)for(r=n[s+1];r===" "||r===" ";)r=n[++s+1];else if(r==="\r"&&n[s+1]===`
92
- `)for(r=n[++s+1];r===" "||r===" ";)r=n[++s+1];else if(r==="x"||r==="u"||r==="U"){const a={x:2,u:4,U:8}[r];t+=wn(n,s+1,a,e),s+=a}else{const a=n.substr(s-1,2);e(s-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),t+=a}}else if(i===" "||i===" "){const r=s;let o=n[s+1];for(;o===" "||o===" ";)o=n[++s+1];o!==`
92
+ `)for(r=n[++s+1];r===" "||r===" ";)r=n[++s+1];else if(r==="x"||r==="u"||r==="U"){const a={x:2,u:4,U:8}[r];t+=$n(n,s+1,a,e),s+=a}else{const a=n.substr(s-1,2);e(s-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),t+=a}}else if(i===" "||i===" "){const r=s;let o=n[s+1];for(;o===" "||o===" ";)o=n[++s+1];o!==`
93
93
  `&&!(o==="\r"&&n[s+2]===`
94
- `)&&(t+=s>r?n.slice(r,s+1):i)}else t+=i}return(n[n.length-1]!=='"'||n.length===1)&&e(n.length,"MISSING_CHAR",'Missing closing "quote'),t}function yn(n,e){let t="",s=n[e+1];for(;(s===" "||s===" "||s===`
94
+ `)&&(t+=s>r?n.slice(r,s+1):i)}else t+=i}return(n[n.length-1]!=='"'||n.length===1)&&e(n.length,"MISSING_CHAR",'Missing closing "quote'),t}function On(n,e){let t="",s=n[e+1];for(;(s===" "||s===" "||s===`
95
95
  `||s==="\r")&&!(s==="\r"&&n[e+2]!==`
96
96
  `);)s===`
97
97
  `&&(t+=`
98
- `),e+=1,s=n[e+1];return t||(t=" "),{fold:t,offset:e}}const bn={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
99
- `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function wn(n,e,t,s){const i=n.substr(e,t),o=i.length===t&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(o)){const a=n.substr(e-2,t+2);return s(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}function ps(n,e,t,s){const{value:i,type:r,comment:o,range:a}=e.type==="block-scalar"?fn(n,e,s):dn(e,n.options.strict,s),l=t?n.directives.tagName(t.source,f=>s(t,"TAG_RESOLVE_FAILED",f)):null;let c;n.options.stringKeys&&n.atKey?c=n.schema[U]:l?c=kn(n.schema,i,l,t,s):e.type==="scalar"?c=Sn(n,i,e,s):c=n.schema[U];let d;try{const f=c.resolve(i,u=>s(t??e,"TAG_RESOLVE_FAILED",u),n.options);d=I(f)?f:new T(f)}catch(f){const u=f instanceof Error?f.message:String(f);s(t??e,"TAG_RESOLVE_FAILED",u),d=new T(i)}return d.range=a,d.source=i,r&&(d.type=r),l&&(d.tag=l),c.format&&(d.format=c.format),o&&(d.comment=o),d}function kn(n,e,t,s,i){if(t==="!")return n[U];const r=[];for(const a of n.tags)if(!a.collection&&a.tag===t)if(a.default&&a.test)r.push(a);else return a;for(const a of r)if(a.test?.test(e))return a;const o=n.knownTags[t];return o&&!o.collection?(n.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),n[U])}function Sn({atKey:n,directives:e,schema:t},s,i,r){const o=t.tags.find(a=>(a.default===!0||n&&a.default==="key")&&a.test?.test(s))||t[U];if(t.compat){const a=t.compat.find(l=>l.default&&l.test?.test(s))??t[U];if(o.tag!==a.tag){const l=e.tagString(o.tag),c=e.tagString(a.tag),d=`Value may be parsed as either ${l} or ${c}`;r(i,"TAG_RESOLVE_FAILED",d,!0)}}return o}function Nn(n,e,t){if(e){t??(t=e.length);for(let s=t-1;s>=0;--s){let i=e[s];switch(i.type){case"space":case"comment":case"newline":n-=i.source.length;continue}for(i=e[++s];i?.type==="space";)n+=i.source.length,i=e[++s];break}}return n}const Tn={composeNode:ms,composeEmptyNode:bt};function ms(n,e,t,s){const i=n.atKey,{spaceBefore:r,comment:o,anchor:a,tag:l}=t;let c,d=!0;switch(e.type){case"alias":c=On(n,e,s),(a||l)&&s(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=ps(n,e,l,s),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=cn(Tn,n,e,t,s),a&&(c.anchor=a.source.substring(1));break;default:{const f=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;s(e,"UNEXPECTED_TOKEN",f),c=bt(n,e.offset,void 0,null,t,s),d=!1}}return a&&c.anchor===""&&s(a,"BAD_ALIAS","Anchor cannot be an empty string"),i&&n.options.stringKeys&&(!I(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&s(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),r&&(c.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?c.comment=o:c.commentBefore=o),n.options.keepSourceTokens&&d&&(c.srcToken=e),c}function bt(n,e,t,s,{spaceBefore:i,comment:r,anchor:o,tag:a,end:l},c){const d={type:"scalar",offset:Nn(e,t,s),indent:-1,source:""},f=ps(n,d,a,c);return o&&(f.anchor=o.source.substring(1),f.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(f.spaceBefore=!0),r&&(f.comment=r,f.range[2]=l),f}function On({options:n},{offset:e,source:t,end:s},i){const r=new ot(t.substring(1));r.source===""&&i(e,"BAD_ALIAS","Alias cannot be an empty string"),r.source.endsWith(":")&&i(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const o=e+t.length,a=Te(s,o,n.strict,i);return r.range=[e,o,a.offset],a.comment&&(r.comment=a.comment),r}function An(n,e,{offset:t,start:s,value:i,end:r},o){const a=Object.assign({_directives:e},n),l=new Ve(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},d=le(s,{indicator:"doc-start",next:i??r?.[0],offset:t,onError:o,parentIndent:0,startOnNewline:!0});d.found&&(l.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!d.hasNewline&&o(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=i?ms(c,i,d,o):bt(c,d.end,s,null,d,o);const f=l.contents.range[2],u=Te(r,f,!1,o);return u.comment&&(l.comment=u.comment),l.range=[t,f,u.offset],l}function de(n){if(typeof n=="number")return[n,n+1];if(Array.isArray(n))return n.length===2?n:[n[0],n[1]];const{offset:e,source:t}=n;return[e,e+(typeof t=="string"?t.length:1)]}function $t(n){let e="",t=!1,s=!1;for(let i=0;i<n.length;++i){const r=n[i];switch(r[0]){case"#":e+=(e===""?"":s?`
98
+ `),e+=1,s=n[e+1];return t||(t=" "),{fold:t,offset:e}}const In={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
99
+ `,r:"\r",t:" ",v:"\v",N:"…",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function $n(n,e,t,s){const i=n.substr(e,t),o=i.length===t&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(o)){const a=n.substr(e-2,t+2);return s(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}function ks(n,e,t,s){const{value:i,type:r,comment:o,range:a}=e.type==="block-scalar"?bn(n,e,s):Sn(e,n.options.strict,s),l=t?n.directives.tagName(t.source,f=>s(t,"TAG_RESOLVE_FAILED",f)):null;let c;n.options.stringKeys&&n.atKey?c=n.schema[V]:l?c=En(n.schema,i,l,t,s):e.type==="scalar"?c=Ln(n,i,e,s):c=n.schema[V];let d;try{const f=c.resolve(i,u=>s(t??e,"TAG_RESOLVE_FAILED",u),n.options);d=I(f)?f:new T(f)}catch(f){const u=f instanceof Error?f.message:String(f);s(t??e,"TAG_RESOLVE_FAILED",u),d=new T(i)}return d.range=a,d.source=i,r&&(d.type=r),l&&(d.tag=l),c.format&&(d.format=c.format),o&&(d.comment=o),d}function En(n,e,t,s,i){if(t==="!")return n[V];const r=[];for(const a of n.tags)if(!a.collection&&a.tag===t)if(a.default&&a.test)r.push(a);else return a;for(const a of r)if(a.test?.test(e))return a;const o=n.knownTags[t];return o&&!o.collection?(n.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),n[V])}function Ln({atKey:n,directives:e,schema:t},s,i,r){const o=t.tags.find(a=>(a.default===!0||n&&a.default==="key")&&a.test?.test(s))||t[V];if(t.compat){const a=t.compat.find(l=>l.default&&l.test?.test(s))??t[V];if(o.tag!==a.tag){const l=e.tagString(o.tag),c=e.tagString(a.tag),d=`Value may be parsed as either ${l} or ${c}`;r(i,"TAG_RESOLVE_FAILED",d,!0)}}return o}function vn(n,e,t){if(e){t??(t=e.length);for(let s=t-1;s>=0;--s){let i=e[s];switch(i.type){case"space":case"comment":case"newline":n-=i.source.length;continue}for(i=e[++s];i?.type==="space";)n+=i.source.length,i=e[++s];break}}return n}const Cn={composeNode:Ss,composeEmptyNode:At};function Ss(n,e,t,s){const i=n.atKey,{spaceBefore:r,comment:o,anchor:a,tag:l}=t;let c,d=!0;switch(e.type){case"alias":c=_n(n,e,s),(a||l)&&s(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=ks(n,e,l,s),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=yn(Cn,n,e,t,s),a&&(c.anchor=a.source.substring(1));break;default:{const f=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;s(e,"UNEXPECTED_TOKEN",f),c=At(n,e.offset,void 0,null,t,s),d=!1}}return a&&c.anchor===""&&s(a,"BAD_ALIAS","Anchor cannot be an empty string"),i&&n.options.stringKeys&&(!I(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&s(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),r&&(c.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?c.comment=o:c.commentBefore=o),n.options.keepSourceTokens&&d&&(c.srcToken=e),c}function At(n,e,t,s,{spaceBefore:i,comment:r,anchor:o,tag:a,end:l},c){const d={type:"scalar",offset:vn(e,t,s),indent:-1,source:""},f=ks(n,d,a,c);return o&&(f.anchor=o.source.substring(1),f.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(f.spaceBefore=!0),r&&(f.comment=r,f.range[2]=l),f}function _n({options:n},{offset:e,source:t,end:s},i){const r=new ht(t.substring(1));r.source===""&&i(e,"BAD_ALIAS","Alias cannot be an empty string"),r.source.endsWith(":")&&i(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const o=e+t.length,a=Oe(s,o,n.strict,i);return r.range=[e,o,a.offset],a.comment&&(r.comment=a.comment),r}function Mn(n,e,{offset:t,start:s,value:i,end:r},o){const a=Object.assign({_directives:e},n),l=new Ye(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},d=fe(s,{indicator:"doc-start",next:i??r?.[0],offset:t,onError:o,parentIndent:0,startOnNewline:!0});d.found&&(l.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!d.hasNewline&&o(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=i?Ss(c,i,d,o):At(c,d.end,s,null,d,o);const f=l.contents.range[2],u=Oe(r,f,!1,o);return u.comment&&(l.comment=u.comment),l.range=[t,f,u.offset],l}function me(n){if(typeof n=="number")return[n,n+1];if(Array.isArray(n))return n.length===2?n:[n[0],n[1]];const{offset:e,source:t}=n;return[e,e+(typeof t=="string"?t.length:1)]}function Bt(n){let e="",t=!1,s=!1;for(let i=0;i<n.length;++i){const r=n[i];switch(r[0]){case"#":e+=(e===""?"":s?`
100
100
 
101
101
  `:`
102
- `)+(r.substring(1)||" "),t=!0,s=!1;break;case"%":n[i+1]?.[0]!=="#"&&(i+=1),t=!1;break;default:t||(s=!0),t=!1}}return{comment:e,afterEmptyLine:s}}class In{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,s,i,r)=>{const o=de(t);r?this.warnings.push(new rn(o,s,i)):this.errors.push(new me(o,s,i))},this.directives=new B({version:e.version||"1.2"}),this.options=e}decorate(e,t){const{comment:s,afterEmptyLine:i}=$t(this.prelude);if(s){const r=e.contents;if(t)e.comment=e.comment?`${e.comment}
103
- ${s}`:s;else if(i||e.directives.docStart||!r)e.commentBefore=s;else if($(r)&&!r.flow&&r.items.length>0){let o=r.items[0];_(o)&&(o=o.key);const a=o.commentBefore;o.commentBefore=a?`${s}
102
+ `)+(r.substring(1)||" "),t=!0,s=!1;break;case"%":n[i+1]?.[0]!=="#"&&(i+=1),t=!1;break;default:t||(s=!0),t=!1}}return{comment:e,afterEmptyLine:s}}class Bn{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,s,i,r)=>{const o=me(t);r?this.warnings.push(new dn(o,s,i)):this.errors.push(new ye(o,s,i))},this.directives=new B({version:e.version||"1.2"}),this.options=e}decorate(e,t){const{comment:s,afterEmptyLine:i}=Bt(this.prelude);if(s){const r=e.contents;if(t)e.comment=e.comment?`${e.comment}
103
+ ${s}`:s;else if(i||e.directives.docStart||!r)e.commentBefore=s;else if(E(r)&&!r.flow&&r.items.length>0){let o=r.items[0];v(o)&&(o=o.key);const a=o.commentBefore;o.commentBefore=a?`${s}
104
104
  ${a}`:s}else{const o=r.commentBefore;r.commentBefore=o?`${s}
105
- ${o}`: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:$t(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,s=-1){for(const i of e)yield*this.next(i);yield*this.end(t,s)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(t,s,i)=>{const r=de(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",s,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{const t=An(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 me(de(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 s="Unexpected doc-end without preceding document";this.errors.push(new me(de(e),"UNEXPECTED_TOKEN",s));break}this.doc.directives.docEnd=!0;const t=Te(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){const s=this.doc.comment;this.doc.comment=s?`${s}
106
- ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new me(de(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 s=Object.assign({_directives:this.directives},this.options),i=new Ve(void 0,s);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),i.range=[0,t,t],this.decorate(i,!1),yield i}}}const gs="\uFEFF",ys="",bs="",tt="";function En(n){switch(n){case gs:return"byte-order-mark";case ys:return"doc-mode";case bs:return"flow-error-end";case tt:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
105
+ ${o}`: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:Bt(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,s=-1){for(const i of e)yield*this.next(i);yield*this.end(t,s)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(t,s,i)=>{const r=me(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",s,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{const t=Mn(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 ye(me(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 s="Unexpected doc-end without preceding document";this.errors.push(new ye(me(e),"UNEXPECTED_TOKEN",s));break}this.doc.directives.docEnd=!0;const t=Oe(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){const s=this.doc.comment;this.doc.comment=s?`${s}
106
+ ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new ye(me(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 s=Object.assign({_directives:this.directives},this.options),i=new Ye(void 0,s);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),i.range=[0,t,t],this.decorate(i,!1),yield i}}}const Ns="\uFEFF",Ts="",As="",ot="";function Pn(n){switch(n){case Ns:return"byte-order-mark";case Ts:return"doc-mode";case As:return"flow-error-end";case ot:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
107
107
  `:case`\r
108
- `: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(n[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function q(n){switch(n){case void 0:case" ":case`
109
- `:case"\r":case" ":return!0;default:return!1}}const Lt=new Set("0123456789ABCDEFabcdef"),$n=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Ee=new Set(",[]{}"),Ln=new Set(` ,[]{}
110
- \r `),Qe=n=>!n||Ln.has(n);class _n{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(typeof e!="string")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=this.buffer[++e];return!t||t==="#"||t===`
108
+ `: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(n[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function R(n){switch(n){case void 0:case" ":case`
109
+ `:case"\r":case" ":return!0;default:return!1}}const Pt=new Set("0123456789ABCDEFabcdef"),Kn=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Le=new Set(",[]{}"),Dn=new Set(` ,[]{}
110
+ \r `),et=n=>!n||Dn.has(n);class jn{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(typeof e!="string")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=this.buffer[++e];return!t||t==="#"||t===`
111
111
  `?!0:t==="\r"?this.buffer[e+1]===`
112
112
  `:!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(t==="\r"){const i=this.buffer[s+e+1];if(i===`
113
113
  `||!i&&!this.atEnd)return e+s+1}return t===`
114
- `||s>=this.indentNext||!t&&!this.atEnd?e+s:-1}if(t==="-"||t==="."){const s=this.buffer.substr(e,3);if((s==="---"||s==="...")&&q(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
115
- `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===gs&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,s=e.indexOf("#");for(;s!==-1;){const r=e[s-1];if(r===" "||r===" "){t=s-1;break}else s=e.indexOf("#",s+1)}for(;;){const r=e[t-1];if(r===" "||r===" ")t-=1;else break}const i=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-i),this.pushNewline(),"stream"}if(this.atLineEnd()){const t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield ys,yield*this.parseLineStart()}*parseLineStart(){const e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");const t=this.peek(3);if((t==="---"||t==="...")&&q(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!q(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===":")&&q(t)){const s=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=s,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);const e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Qe),"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 i=this.getLine();if(i===null)return this.setNext("flow");if((s!==-1&&s<this.indentNext&&i[0]!=="#"||s===0&&(i.startsWith("---")||i.startsWith("..."))&&q(i[3]))&&!(s===this.indentNext-1&&this.flowLevel===1&&(i[0]==="]"||i[0]==="}")))return this.flowLevel=0,yield bs,yield*this.parseLineStart();let r=0;for(;i[r]===",";)r+=yield*this.pushCount(1),r+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(r+=yield*this.pushIndicators(),i[r]){case void 0:return"flow";case"#":return yield*this.pushCount(i.length-r),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Qe),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{const o=this.charAt(1);if(this.flowKey||q(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){const e=this.charAt(0);let t=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;t!==-1&&this.buffer[t+1]==="'";)t=this.buffer.indexOf("'",t+2);else for(;t!==-1;){let r=0;for(;this.buffer[t-1-r]==="\\";)r+=1;if(r%2===0)break;t=this.buffer.indexOf('"',t+1)}const s=this.buffer.substring(0,t);let i=s.indexOf(`
114
+ `||s>=this.indentNext||!t&&!this.atEnd?e+s:-1}if(t==="-"||t==="."){const s=this.buffer.substr(e,3);if((s==="---"||s==="...")&&R(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
115
+ `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Ns&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,s=e.indexOf("#");for(;s!==-1;){const r=e[s-1];if(r===" "||r===" "){t=s-1;break}else s=e.indexOf("#",s+1)}for(;;){const r=e[t-1];if(r===" "||r===" ")t-=1;else break}const i=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-i),this.pushNewline(),"stream"}if(this.atLineEnd()){const t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield Ts,yield*this.parseLineStart()}*parseLineStart(){const e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");const t=this.peek(3);if((t==="---"||t==="...")&&R(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!R(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===":")&&R(t)){const s=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=s,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);const e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(et),"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 i=this.getLine();if(i===null)return this.setNext("flow");if((s!==-1&&s<this.indentNext&&i[0]!=="#"||s===0&&(i.startsWith("---")||i.startsWith("..."))&&R(i[3]))&&!(s===this.indentNext-1&&this.flowLevel===1&&(i[0]==="]"||i[0]==="}")))return this.flowLevel=0,yield As,yield*this.parseLineStart();let r=0;for(;i[r]===",";)r+=yield*this.pushCount(1),r+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(r+=yield*this.pushIndicators(),i[r]){case void 0:return"flow";case"#":return yield*this.pushCount(i.length-r),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(et),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{const o=this.charAt(1);if(this.flowKey||R(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){const e=this.charAt(0);let t=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;t!==-1&&this.buffer[t+1]==="'";)t=this.buffer.indexOf("'",t+2);else for(;t!==-1;){let r=0;for(;this.buffer[t-1-r]==="\\";)r+=1;if(r%2===0)break;t=this.buffer.indexOf('"',t+1)}const s=this.buffer.substring(0,t);let i=s.indexOf(`
116
116
  `,this.pos);if(i!==-1){for(;i!==-1;){const r=this.continueScalar(i+1);if(r===-1)break;i=s.indexOf(`
117
- `,r)}i!==-1&&(t=i-(s[i-1]==="\r"?2:1))}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){const t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil(t=>q(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,s;e:for(let r=this.pos;s=this.buffer[r];++r)switch(s){case" ":t+=1;break;case`
117
+ `,r)}i!==-1&&(t=i-(s[i-1]==="\r"?2:1))}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){const t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil(t=>R(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,s;e:for(let r=this.pos;s=this.buffer[r];++r)switch(s){case" ":t+=1;break;case`
118
118
  `:e=r,t=0;break;case"\r":{const o=this.buffer[r+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
119
119
  `)break}default:break e}if(!s&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=t:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{const r=this.continueScalar(e+1);if(r===-1)break;e=this.buffer.indexOf(`
120
120
  `,r)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let i=e+1;for(s=this.buffer[i];s===" ";)s=this.buffer[++i];if(s===" "){for(;s===" "||s===" "||s==="\r"||s===`
121
121
  `;)s=this.buffer[++i];e=i-1}else if(!this.blockScalarKeep)do{let r=e-1,o=this.buffer[r];o==="\r"&&(o=this.buffer[--r]);const a=r;for(;o===" ";)o=this.buffer[--r];if(o===`
122
- `&&r>=this.pos&&r+1+t>a)e=r;else break}while(!0);return yield tt,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){const e=this.flowLevel>0;let t=this.pos-1,s=this.pos-1,i;for(;i=this.buffer[++s];)if(i===":"){const r=this.buffer[s+1];if(q(r)||e&&Ee.has(r))break;t=s}else if(q(i)){let r=this.buffer[s+1];if(i==="\r"&&(r===`
122
+ `&&r>=this.pos&&r+1+t>a)e=r;else break}while(!0);return yield ot,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){const e=this.flowLevel>0;let t=this.pos-1,s=this.pos-1,i;for(;i=this.buffer[++s];)if(i===":"){const r=this.buffer[s+1];if(R(r)||e&&Le.has(r))break;t=s}else if(R(i)){let r=this.buffer[s+1];if(i==="\r"&&(r===`
123
123
  `?(s+=1,i=`
124
- `,r=this.buffer[s+1]):t=s),r==="#"||e&&Ee.has(r))break;if(i===`
125
- `){const o=this.continueScalar(s+1);if(o===-1)break;s=Math.max(s,o-2)}}else{if(e&&Ee.has(i))break;t=s}return!i&&!this.atEnd?this.setNext("plain-scalar"):(yield tt,yield*this.pushToIndex(t+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){const 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(Qe))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{const e=this.flowLevel>0,t=this.charAt(1);if(q(t)||e&&Ee.has(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(;!q(t)&&t!==">";)t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if($n.has(t))t=this.buffer[++e];else if(t==="%"&&Lt.has(this.buffer[e+1])&&Lt.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){const e=this.buffer[this.pos];return e===`
124
+ `,r=this.buffer[s+1]):t=s),r==="#"||e&&Le.has(r))break;if(i===`
125
+ `){const o=this.continueScalar(s+1);if(o===-1)break;s=Math.max(s,o-2)}}else{if(e&&Le.has(i))break;t=s}return!i&&!this.atEnd?this.setNext("plain-scalar"):(yield ot,yield*this.pushToIndex(t+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){const 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(et))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{const e=this.flowLevel>0,t=this.charAt(1);if(R(t)||e&&Le.has(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(;!R(t)&&t!==">";)t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(Kn.has(t))t=this.buffer[++e];else if(t==="%"&&Pt.has(this.buffer[e+1])&&Pt.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){const e=this.buffer[this.pos];return e===`
126
126
  `?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
127
- `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,s;do s=this.buffer[++t];while(s===" "||e&&s===" ");const i=t-this.pos;return i>0&&(yield this.buffer.substr(this.pos,i),this.pos=t),i}*pushUntil(e){let t=this.pos,s=this.buffer[t];for(;!e(s);)s=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}class vn{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,s=this.lineStarts.length;for(;t<s;){const r=t+s>>1;this.lineStarts[r]<e?t=r+1:s=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};const i=this.lineStarts[t-1];return{line:t,col:e-i+1}}}}function Y(n,e){for(let t=0;t<n.length;++t)if(n[t].type===e)return!0;return!1}function _t(n){for(let e=0;e<n.length;++e)switch(n[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function ws(n){switch(n?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function $e(n){switch(n.type){case"document":return n.start;case"block-map":{const e=n.items[n.items.length-1];return e.sep??e.start}case"block-seq":return n.items[n.items.length-1].start;default:return[]}}function te(n){if(n.length===0)return[];let e=n.length;e:for(;--e>=0;)switch(n[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;n[++e]?.type==="space";);return n.splice(e,n.length)}function vt(n){if(n.start.type==="flow-seq-start")for(const e of n.items)e.sep&&!e.value&&!Y(e.start,"explicit-key-ind")&&!Y(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,ws(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}class Cn{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 _n,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&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){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}const t=En(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{const s=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:s,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){const e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){const t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{const s=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in s?s.indent:0:t.type==="flow-collection"&&s.type==="document"&&(t.indent=0),t.type==="flow-collection"&&vt(t),s.type){case"document":s.value=t;break;case"block-scalar":s.props.push(t);break;case"block-map":{const i=s.items[s.items.length-1];if(i.value){s.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(i.sep)i.value=t;else{Object.assign(i,{key:t,sep:[]}),this.onKeyLine=!i.explicitKey;return}break}case"block-seq":{const i=s.items[s.items.length-1];i.value?s.items.push({start:[],value:t}):i.value=t;break}case"flow-collection":{const i=s.items[s.items.length-1];!i||i.value?s.items.push({start:[],key:t,sep:[]}):i.sep?i.value=t:Object.assign(i,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((s.type==="document"||s.type==="block-map"||s.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){const i=t.items[t.items.length-1];i&&!i.sep&&!i.value&&i.start.length>0&&_t(i.start)===-1&&(t.indent===0||i.start.every(r=>r.type!=="comment"||r.indent<t.indent))&&(s.type==="document"?s.end=i.start:s.items.push({start:i.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{const e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{_t(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}const t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){const t=$e(this.peek(2)),s=te(t);let i;e.end?(i=e.end,i.push(this.sourceToken),delete e.end):i=[this.sourceToken];const r={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
127
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,s;do s=this.buffer[++t];while(s===" "||e&&s===" ");const i=t-this.pos;return i>0&&(yield this.buffer.substr(this.pos,i),this.pos=t),i}*pushUntil(e){let t=this.pos,s=this.buffer[t];for(;!e(s);)s=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}class qn{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,s=this.lineStarts.length;for(;t<s;){const r=t+s>>1;this.lineStarts[r]<e?t=r+1:s=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};const i=this.lineStarts[t-1];return{line:t,col:e-i+1}}}}function H(n,e){for(let t=0;t<n.length;++t)if(n[t].type===e)return!0;return!1}function Kt(n){for(let e=0;e<n.length;++e)switch(n[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Os(n){switch(n?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function ve(n){switch(n.type){case"document":return n.start;case"block-map":{const e=n.items[n.items.length-1];return e.sep??e.start}case"block-seq":return n.items[n.items.length-1].start;default:return[]}}function ne(n){if(n.length===0)return[];let e=n.length;e:for(;--e>=0;)switch(n[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;n[++e]?.type==="space";);return n.splice(e,n.length)}function Dt(n){if(n.start.type==="flow-seq-start")for(const e of n.items)e.sep&&!e.value&&!H(e.start,"explicit-key-ind")&&!H(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Os(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}class Rn{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new jn,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&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){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}const t=Pn(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{const s=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:s,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){const e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){const t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{const s=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in s?s.indent:0:t.type==="flow-collection"&&s.type==="document"&&(t.indent=0),t.type==="flow-collection"&&Dt(t),s.type){case"document":s.value=t;break;case"block-scalar":s.props.push(t);break;case"block-map":{const i=s.items[s.items.length-1];if(i.value){s.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(i.sep)i.value=t;else{Object.assign(i,{key:t,sep:[]}),this.onKeyLine=!i.explicitKey;return}break}case"block-seq":{const i=s.items[s.items.length-1];i.value?s.items.push({start:[],value:t}):i.value=t;break}case"flow-collection":{const i=s.items[s.items.length-1];!i||i.value?s.items.push({start:[],key:t,sep:[]}):i.sep?i.value=t:Object.assign(i,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((s.type==="document"||s.type==="block-map"||s.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){const i=t.items[t.items.length-1];i&&!i.sep&&!i.value&&i.start.length>0&&Kt(i.start)===-1&&(t.indent===0||i.start.every(r=>r.type!=="comment"||r.indent<t.indent))&&(s.type==="document"?s.end=i.start:s.items.push({start:i.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{const e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{Kt(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}const t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){const t=ve(this.peek(2)),s=ne(t);let i;e.end?(i=e.end,i.push(this.sourceToken),delete e.end):i=[this.sourceToken];const r={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
128
128
  `)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
129
- `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){const s="end"in t.value?t.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){const i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Array.prototype.push.apply(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){const s=!this.onKeyLine&&this.indent===e.indent,i=s&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind";let r=[];if(i&&t.sep&&!t.value){const o=[];for(let a=0;a<t.sep.length;++a){const l=t.sep[a];switch(l.type){case"newline":o.push(a);break;case"space":break;case"comment":l.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(r=t.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":i||t.value?(r.push(this.sourceToken),e.items.push({start:r}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):i||t.value?(r.push(this.sourceToken),e.items.push({start:r,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Y(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]});else if(ws(t.key)&&!Y(t.sep,"newline")){const o=te(t.start),a=t.key,l=t.sep;l.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:l}]})}else r.length>0?t.sep=t.sep.concat(r,this.sourceToken):t.sep.push(this.sourceToken);else if(Y(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{const o=te(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||i?e.items.push({start:r,key:null,sep:[this.sourceToken]}):Y(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const o=this.flowScalar(this.type);i||t.value?(e.items.push({start:r,key:o,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(o):(Object.assign(t,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{const o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!t.explicitKey&&t.sep&&!Y(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else s&&e.items.push({start:r});this.stack.push(o);return}}}}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;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?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 i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Array.prototype.push.apply(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||Y(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){const s=this.startBlockValue(e);if(s){this.stack.push(s);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){const t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let s;do yield*this.pop(),s=this.peek(1);while(s?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const i=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:i,sep:[]}):t.sep?this.stack.push(i):Object.assign(t,{key:i,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}const s=this.startBlockValue(e);s?this.stack.push(s):(yield*this.pop(),yield*this.step())}else{const s=this.peek(2);if(s.type==="block-map"&&(this.type==="map-value-ind"&&s.indent===e.indent||this.type==="newline"&&!s.items[s.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&s.type!=="flow-collection"){const i=$e(s),r=te(i);vt(e);const o=e.end.splice(1,e.end.length);o.push(this.sourceToken);const a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
129
+ `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){const s="end"in t.value?t.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){const i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Array.prototype.push.apply(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){const s=!this.onKeyLine&&this.indent===e.indent,i=s&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind";let r=[];if(i&&t.sep&&!t.value){const o=[];for(let a=0;a<t.sep.length;++a){const l=t.sep[a];switch(l.type){case"newline":o.push(a);break;case"space":break;case"comment":l.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(r=t.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":i||t.value?(r.push(this.sourceToken),e.items.push({start:r}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):i||t.value?(r.push(this.sourceToken),e.items.push({start:r,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(H(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]});else if(Os(t.key)&&!H(t.sep,"newline")){const o=ne(t.start),a=t.key,l=t.sep;l.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:l}]})}else r.length>0?t.sep=t.sep.concat(r,this.sourceToken):t.sep.push(this.sourceToken);else if(H(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{const o=ne(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||i?e.items.push({start:r,key:null,sep:[this.sourceToken]}):H(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const o=this.flowScalar(this.type);i||t.value?(e.items.push({start:r,key:o,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(o):(Object.assign(t,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{const o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!t.explicitKey&&t.sep&&!H(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else s&&e.items.push({start:r});this.stack.push(o);return}}}}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;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?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 i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Array.prototype.push.apply(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||H(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){const s=this.startBlockValue(e);if(s){this.stack.push(s);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){const t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let s;do yield*this.pop(),s=this.peek(1);while(s?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const i=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:i,sep:[]}):t.sep?this.stack.push(i):Object.assign(t,{key:i,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}const s=this.startBlockValue(e);s?this.stack.push(s):(yield*this.pop(),yield*this.step())}else{const s=this.peek(2);if(s.type==="block-map"&&(this.type==="map-value-ind"&&s.indent===e.indent||this.type==="newline"&&!s.items[s.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&s.type!=="flow-collection"){const i=ve(s),r=ne(i);Dt(e);const o=e.end.splice(1,e.end.length);o.push(this.sourceToken);const a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
130
130
  `)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
131
- `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const t=$e(e),s=te(t);return s.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const t=$e(e),s=te(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(s=>s.type==="newline"||s.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function Mn(n){const e=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||e&&new vn||null,prettyErrors:e}}function Bn(n,e={}){const{lineCounter:t,prettyErrors:s}=Mn(e),i=new Cn(t?.addNewLine),r=new In(e);let o=null;for(const a of r.compose(i.parse(n),!0,n.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new me(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return s&&t&&(o.errors.forEach(It(n,t)),o.warnings.forEach(It(n,t))),o}function Pn(n){const t=n.unwrap().children[0];if(!t)return E("frontmatter","Document has no content",n.path,n.position);if(t.type==="yaml"){const s=t;try{const r=Bn(s.value).toJSON();return v({format:"yaml",data:r,raw:s.value},n.path)}catch(i){return E("frontmatter",`Failed to parse YAML frontmatter: ${i instanceof Error?i.message:String(i)}`,n.path,n.position)}}return t.type==="toml"?E("frontmatter","TOML frontmatter parsing requires @origints/toml",n.path,n.position):E("frontmatter","No frontmatter found in document",n.path,n.position)}function Kn(n){const s=n.unwrap().children[0]?.type;return s==="yaml"||s==="toml"}function Dn(n){const e=n.unwrap(),s=e.children[0]?.type;if(s==="yaml"||s==="toml"){const i={type:"root",children:e.children.slice(1)};return R.fromRoot(i)}return n}function jn(n,e={}){const{gfm:t=!0,allowDangerousHtml:s=!1}=e;try{const i=n.unwrap();let r=st.unified();t&&(r=r.use(nt)),r=r.use(Mt,{allowDangerousHtml:s}).use(Bt,{allowDangerousHtml:s});const o=r.runSync(i),a=r.stringify(o);return v(String(a),n.path)}catch(i){return E("parse",`Failed to convert to HTML: ${i instanceof Error?i.message:String(i)}`,n.path,n.position)}}function qn(n,e={}){const{gfm:t=!0,allowDangerousHtml:s=!1}=e;try{let i=st.unified().use(Ct);t&&(i=i.use(nt));const r=i.use(Mt,{allowDangerousHtml:s}).use(Bt,{allowDangerousHtml:s}).processSync(n);return v(String(r),[])}catch(i){return E("parse",`Failed to convert to HTML: ${i instanceof Error?i.message:String(i)}`,[],void 0)}}function Rn(n){n.register(Kt),n.register(Dt)}exports.MarkdownNode=R;exports.extractFrontmatter=Pn;exports.fail=E;exports.formatMarkdownPath=Ss;exports.hasFrontmatter=Kn;exports.markdownToHtml=qn;exports.ok=v;exports.parseMarkdown=Ns;exports.parseMarkdownAsyncImpl=Dt;exports.parseMarkdownImpl=Kt;exports.registerMarkdownTransforms=Rn;exports.toHtml=jn;exports.withoutFrontmatter=Dn;
131
+ `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const t=ve(e),s=ne(t);return s.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const t=ve(e),s=ne(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(s=>s.type==="newline"||s.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function Fn(n){const e=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||e&&new qn||null,prettyErrors:e}}function Un(n,e={}){const{lineCounter:t,prettyErrors:s}=Fn(e),i=new Rn(t?.addNewLine),r=new Bn(e);let o=null;for(const a of r.compose(i.parse(n),!0,n.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new ye(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return s&&t&&(o.errors.forEach(_t(n,t)),o.warnings.forEach(_t(n,t))),o}function xn(n){const t=n.unwrap().children[0];if(!t)return $("frontmatter","Document has no content",n.path,n.position);if(t.type==="yaml"){const s=t;try{const r=Un(s.value).toJSON();return C({format:"yaml",data:r,raw:s.value},n.path)}catch(i){return $("frontmatter",`Failed to parse YAML frontmatter: ${i instanceof Error?i.message:String(i)}`,n.path,n.position)}}return t.type==="toml"?$("frontmatter","TOML frontmatter parsing requires @origints/toml",n.path,n.position):$("frontmatter","No frontmatter found in document",n.path,n.position)}function Vn(n){const s=n.unwrap().children[0]?.type;return s==="yaml"||s==="toml"}function Jn(n){const e=n.unwrap(),s=e.children[0]?.type;if(s==="yaml"||s==="toml"){const i={type:"root",children:e.children.slice(1)};return F.fromRoot(i)}return n}function Yn(n,e={}){const{gfm:t=!0,allowDangerousHtml:s=!1}=e;try{const i=n.unwrap();let r=lt.unified();t&&(r=r.use(ct)),r=r.use(qt,{allowDangerousHtml:s}).use(Rt,{allowDangerousHtml:s});const o=r.runSync(i),a=r.stringify(o);return C(String(a),n.path)}catch(i){return $("parse",`Failed to convert to HTML: ${i instanceof Error?i.message:String(i)}`,n.path,n.position)}}function Gn(n,e={}){const{gfm:t=!0,allowDangerousHtml:s=!1}=e;try{let i=lt.unified().use(jt);t&&(i=i.use(ct));const r=i.use(qt,{allowDangerousHtml:s}).use(Rt,{allowDangerousHtml:s}).processSync(n);return C(String(r),[])}catch(i){return $("parse",`Failed to convert to HTML: ${i instanceof Error?i.message:String(i)}`,[],void 0)}}function Is(n){n.register(Ut)}Is(at.globalRegistry);at.registerSpecExecutor("markdown",(n,e)=>xt(n,e));exports.MarkdownNode=F;exports.MarkdownNodeSB=x;exports.MarkdownSpecBuilder=Ke;exports.executeMarkdownSpec=xt;exports.extractFrontmatter=xn;exports.fail=$;exports.formatMarkdownPath=Es;exports.hasFrontmatter=Vn;exports.markdownToHtml=Gn;exports.ok=C;exports.parseMarkdown=Ls;exports.parseMarkdownAsyncImpl=Ut;exports.parseMarkdownImpl=Cs;exports.registerMarkdownTransforms=Is;exports.toHtml=Yn;exports.withoutFrontmatter=Jn;
132
132
  //# sourceMappingURL=index.cjs.map