/
githubmirror
/
obsidian-headless
Обзор
Документация
Войти
/
githubmirror
/
obsidian-headless
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
cli.js
171 строка
213 KB
lishid
Fix .obsidian detection.
30 июл 2026, 18:23
30 июл 2026, 18:23
783aa55
Код
Авторство
О чём код?
#!/usr/bin/env node var $c=Object.create;var Cr=Object.defineProperty;var Uc=Object.getOwnPropertyDescriptor;var Kc=Object.getOwnPropertyNames;var Vc=Object.getPrototypeOf,Wc=Object.prototype.hasOwnProperty;var P=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var Hc=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Kc(e))!Wc.call(s,n)&&n!==t&&Cr(s,n,{get:()=>e[n],enumerable:!(i=Uc(e,n))||i.enumerable});return s};var de=(s,e,t)=>(t=s!=null?$c(Vc(s)):{},Hc(e||!s||!s.__esModule?Cr(t,"default",{value:s,enumerable:!0}):t,s));var L=P(q=>{"use strict";var Bs=Symbol.for("yaml.alias"),wo=Symbol.for("yaml.document"),Qt=Symbol.for("yaml.map"),So=Symbol.for("yaml.pair"),js=Symbol.for("yaml.scalar"),Xt=Symbol.for("yaml.seq"),Z=Symbol.for("yaml.node.type"),tu=s=>!!s&&typeof s=="object"&&s[Z]===Bs,iu=s=>!!s&&typeof s=="object"&&s[Z]===wo,su=s=>!!s&&typeof s=="object"&&s[Z]===Qt,nu=s=>!!s&&typeof s=="object"&&s[Z]===So,vo=s=>!!s&&typeof s=="object"&&s[Z]===js,ru=s=>!!s&&typeof s=="object"&&s[Z]===Xt;function Fo(s){if(s&&typeof s=="object")switch(s[Z]){case Qt:case Xt:return!0}return!1}function ou(s){if(s&&typeof s=="object")switch(s[Z]){case Bs:case Qt:case js:case Xt:return!0}return!1}var au=s=>(vo(s)||Fo(s))&&!!s.anchor;q.ALIAS=Bs;q.DOC=wo;q.MAP=Qt;q.NODE_TYPE=Z;q.PAIR=So;q.SCALAR=js;q.SEQ=Xt;q.hasAnchor=au;q.isAlias=tu;q.isCollection=Fo;q.isDocument=iu;q.isMap=su;q.isNode=ou;q.isPair=nu;q.isScalar=vo;q.isSeq=ru});var Xe=P($s=>{"use strict";var k=L(),B=Symbol("break visit"),Eo=Symbol("skip children"),Q=Symbol("remove node");function zt(s,e){let t=Po(e);k.isDocument(s)?Ce(null,s.contents,t,Object.freeze([s]))===Q&&(s.contents=null):Ce(null,s,t,Object.freeze([]))}zt.BREAK=B;zt.SKIP=Eo;zt.REMOVE=Q;function Ce(s,e,t,i){let n=Ao(s,e,t,i);if(k.isNode(n)||k.isPair(n))return Do(s,i,n),Ce(s,n,t,i);if(typeof n!="symbol"){if(k.isCollection(e)){i=Object.freeze(i.concat(e));for(let r=0;r<e.items.length;++r){let o=Ce(r,e.items[r],t,i);if(typeof o=="number")r=o-1;else{if(o===B)return B;o===Q&&(e.items.splice(r,1),r-=1)}}}else if(k.isPair(e)){i=Object.freeze(i.concat(e));let r=Ce("key",e.key,t,i);if(r===B)return B;r===Q&&(e.key=null);let o=Ce("value",e.value,t,i);if(o===B)return B;o===Q&&(e.value=null)}}return n}async function Zt(s,e){let t=Po(e);k.isDocument(s)?await Ie(null,s.contents,t,Object.freeze([s]))===Q&&(s.contents=null):await Ie(null,s,t,Object.freeze([]))}Zt.BREAK=B;Zt.SKIP=Eo;Zt.REMOVE=Q;async function Ie(s,e,t,i){let n=await Ao(s,e,t,i);if(k.isNode(n)||k.isPair(n))return Do(s,i,n),Ie(s,n,t,i);if(typeof n!="symbol"){if(k.isCollection(e)){i=Object.freeze(i.concat(e));for(let r=0;r<e.items.length;++r){let o=await Ie(r,e.items[r],t,i);if(typeof o=="number")r=o-1;else{if(o===B)return B;o===Q&&(e.items.splice(r,1),r-=1)}}}else if(k.isPair(e)){i=Object.freeze(i.concat(e));let r=await Ie("key",e.key,t,i);if(r===B)return B;r===Q&&(e.key=null);let o=await Ie("value",e.value,t,i);if(o===B)return B;o===Q&&(e.value=null)}}return n}function Po(s){return typeof s=="object"&&(s.Collection||s.Node||s.Value)?Object.assign({Alias:s.Node,Map:s.Node,Scalar:s.Node,Seq:s.Node},s.Value&&{Map:s.Value,Scalar:s.Value,Seq:s.Value},s.Collection&&{Map:s.Collection,Seq:s.Collection},s):s}function Ao(s,e,t,i){if(typeof t=="function")return t(s,e,i);if(k.isMap(e))return t.Map?.(s,e,i);if(k.isSeq(e))return t.Seq?.(s,e,i);if(k.isPair(e))return t.Pair?.(s,e,i);if(k.isScalar(e))return t.Scalar?.(s,e,i);if(k.isAlias(e))return t.Alias?.(s,e,i)}function Do(s,e,t){let i=e[e.length-1];if(k.isCollection(i))i.items[s]=t;else if(k.isPair(i))s==="key"?i.key=t:i.value=t;else if(k.isDocument(i))i.contents=t;else{let n=k.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}$s.visit=zt;$s.visitAsync=Zt});var Us=P(Lo=>{"use strict";var To=L(),lu=Xe(),cu={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},uu=s=>s.replace(/[!,[\]{}]/g,e=>cu[e]),ze=class s{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},s.defaultYaml,e),this.tags=Object.assign({},s.defaultTags,t)}clone(){let e=new s(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new s(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:s.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},s.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:s.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},s.defaultTags),this.atNextDocument=!1);let i=e.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[r,o]=i;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=i;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{let o=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,o),!1}}default:return t(0,`Unknown directive ${n}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let 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)}let[,i,n]=e.match(/^(.*!)([^!]*)$/s);n||t(`The ${e} tag has no suffix`);let r=this.tags[i];if(r)try{return r+decodeURIComponent(n)}catch(o){return t(String(o)),null}return i==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,i]of Object.entries(this.tags))if(e.startsWith(i))return t+uu(e.substring(i.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),n;if(e&&i.length>0&&To.isNode(e.contents)){let r={};lu.visit(e.contents,(o,a)=>{To.isNode(a)&&a.tag&&(r[a.tag]=!0)}),n=Object.keys(r)}else n=[];for(let[r,o]of i)r==="!!"&&o==="tag:yaml.org,2002:"||(!e||n.some(a=>a.startsWith(o)))&&t.push(`%TAG ${r} ${o}`);return t.join(` `)}};ze.defaultYaml={explicit:!1,version:"1.2"};ze.defaultTags={"!!":"tag:yaml.org,2002:"};Lo.Directives=ze});var ei=P(Ze=>{"use strict";var Oo=L(),fu=Xe();function hu(s){if(/[\x00-\x19\s,[\]{}]/.test(s)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;throw new Error(t)}return!0}function No(s){let e=new Set;return fu.visit(s,{Value(t,i){i.anchor&&e.add(i.anchor)}}),e}function _o(s,e){for(let t=1;;++t){let i=`${s}${t}`;if(!e.has(i))return i}}function pu(s,e){let t=[],i=new Map,n=null;return{onAnchor:r=>{t.push(r),n||(n=No(s));let o=_o(e,n);return n.add(o),o},setAnchors:()=>{for(let r of t){let o=i.get(r);if(typeof o=="object"&&o.anchor&&(Oo.isScalar(o.node)||Oo.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=r,a}}},sourceObjects:i}}Ze.anchorIsValid=hu;Ze.anchorNames=No;Ze.createNodeAnchors=pu;Ze.findNewAnchor=_o});var Ks=P(Co=>{"use strict";function et(s,e,t,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let o=i[n],a=et(s,i,String(n),o);a===void 0?delete i[n]:a!==o&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),o=et(s,i,n,r);o===void 0?i.delete(n):o!==r&&i.set(n,o)}else if(i instanceof Set)for(let n of Array.from(i)){let r=et(s,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let o=et(s,i,n,r);o===void 0?delete i[n]:o!==r&&(i[n]=o)}return s.call(e,t,i)}Co.applyReviver=et});var re=P(ko=>{"use strict";var du=L();function Io(s,e,t){if(Array.isArray(s))return s.map((i,n)=>Io(i,String(n),t));if(s&&typeof s.toJSON=="function"){if(!t||!du.hasAnchor(s))return s.toJSON(e,t);let i={aliasCount:0,count:1,res:void 0};t.anchors.set(s,i),t.onCreate=r=>{i.res=r,delete t.onCreate};let n=s.toJSON(e,t);return t.onCreate&&t.onCreate(n),n}return typeof s=="bigint"&&!t?.keep?Number(s):s}ko.toJS=Io});var ti=P(qo=>{"use strict";var gu=Ks(),xo=L(),mu=re(),Vs=class{constructor(e){Object.defineProperty(this,xo.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:i,onAnchor:n,reviver:r}={}){if(!xo.isDocument(e))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},a=mu.toJS(this,"",o);if(typeof n=="function")for(let{count:l,res:c}of o.anchors.values())n(c,l);return typeof r=="function"?gu.applyReviver(r,{"":a},"",a):a}};qo.NodeBase=Vs});var tt=P(Ro=>{"use strict";var yu=ei(),Mo=Xe(),ii=L(),bu=ti(),wu=re(),Ws=class extends bu.NodeBase{constructor(e){super(ii.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e){let t;return Mo.visit(e,{Node:(i,n)=>{if(n===this)return Mo.visit.BREAK;n.anchor===this.source&&(t=n)}}),t}toJSON(e,t){if(!t)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:r}=t,o=this.resolve(n);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=i.get(o);if(a||(wu.toJS(o,null,t),a=i.get(o)),!a||a.res===void 0){let 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=si(n,o,i)),a.count*a.aliasCount>r)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(e,t,i){let n=`*${this.source}`;if(e){if(yu.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(r)}if(e.implicitKey)return`${n} `}return n}};function si(s,e,t){if(ii.isAlias(e)){let i=e.resolve(s),n=t&&i&&t.get(i);return n?n.count*n.aliasCount:0}else if(ii.isCollection(e)){let i=0;for(let n of e.items){let r=si(s,n,t);r>i&&(i=r)}return i}else if(ii.isPair(e)){let i=si(s,e.key,t),n=si(s,e.value,t);return Math.max(i,n)}return 1}Ro.Alias=Ws});var I=P(Hs=>{"use strict";var Su=L(),vu=ti(),Fu=re(),Eu=s=>!s||typeof s!="function"&&typeof s!="object",oe=class extends vu.NodeBase{constructor(e){super(Su.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:Fu.toJS(this.value,e,t)}toString(){return String(this.value)}};oe.BLOCK_FOLDED="BLOCK_FOLDED";oe.BLOCK_LITERAL="BLOCK_LITERAL";oe.PLAIN="PLAIN";oe.QUOTE_DOUBLE="QUOTE_DOUBLE";oe.QUOTE_SINGLE="QUOTE_SINGLE";Hs.Scalar=oe;Hs.isScalarValue=Eu});var it=P(jo=>{"use strict";var Pu=tt(),Se=L(),Bo=I(),Au="tag:yaml.org,2002:";function Du(s,e,t){if(e){let i=t.filter(r=>r.tag===e),n=i.find(r=>!r.format)??i[0];if(!n)throw new Error(`Tag ${e} not found`);return n}return t.find(i=>i.identify?.(s)&&!i.format)}function Tu(s,e,t){if(Se.isDocument(s)&&(s=s.contents),Se.isNode(s))return s;if(Se.isPair(s)){let u=t.schema[Se.MAP].createNode?.(t.schema,null,t);return u.items.push(s),u}(s instanceof String||s instanceof Number||s instanceof Boolean||typeof BigInt<"u"&&s instanceof BigInt)&&(s=s.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:r,schema:o,sourceObjects:a}=t,l;if(i&&s&&typeof s=="object"){if(l=a.get(s),l)return l.anchor||(l.anchor=n(s)),new Pu.Alias(l.anchor);l={anchor:null,node:null},a.set(s,l)}e?.startsWith("!!")&&(e=Au+e.slice(2));let c=Du(s,e,o.tags);if(!c){if(s&&typeof s.toJSON=="function"&&(s=s.toJSON()),!s||typeof s!="object"){let u=new Bo.Scalar(s);return l&&(l.node=u),u}c=s instanceof Map?o[Se.MAP]:Symbol.iterator in Object(s)?o[Se.SEQ]:o[Se.MAP]}r&&(r(c),delete t.onTagObj);let f=c?.createNode?c.createNode(t.schema,s,t):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(t.schema,s,t):new Bo.Scalar(s);return e?f.tag=e:c.default||(f.tag=c.tag),l&&(l.node=f),f}jo.createNode=Tu});var ri=P(ni=>{"use strict";var Lu=it(),X=L(),Ou=ti();function Gs(s,e,t){let i=t;for(let n=e.length-1;n>=0;--n){let r=e[n];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){let o=[];o[r]=i,i=o}else i=new Map([[r,i]])}return Lu.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:s,sourceObjects:new Map})}var $o=s=>s==null||typeof s=="object"&&!!s[Symbol.iterator]().next().done,Ys=class extends Ou.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(i=>X.isNode(i)||X.isPair(i)?i.clone(e):i),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if($o(e))this.add(t);else{let[i,...n]=e,r=this.get(i,!0);if(X.isCollection(r))r.addIn(n,t);else if(r===void 0&&this.schema)this.set(i,Gs(this.schema,n,t));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(e){let[t,...i]=e;if(i.length===0)return this.delete(t);let n=this.get(t,!0);if(X.isCollection(n))return n.deleteIn(i);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${i}`)}getIn(e,t){let[i,...n]=e,r=this.get(i,!0);return n.length===0?!t&&X.isScalar(r)?r.value:r:X.isCollection(r)?r.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!X.isPair(t))return!1;let i=t.value;return i==null||e&&X.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(e){let[t,...i]=e;if(i.length===0)return this.has(t);let n=this.get(t,!0);return X.isCollection(n)?n.hasIn(i):!1}setIn(e,t){let[i,...n]=e;if(n.length===0)this.set(i,t);else{let r=this.get(i,!0);if(X.isCollection(r))r.setIn(n,t);else if(r===void 0&&this.schema)this.set(i,Gs(this.schema,n,t));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};ni.Collection=Ys;ni.collectionFromPath=Gs;ni.isEmptyPath=$o});var st=P(oi=>{"use strict";var Nu=s=>s.replace(/^(?!$)(?: $)?/gm,"#");function Js(s,e){return/^\n+$/.test(s)?s.substring(1):e?s.replace(/^(?! *$)/gm,e):s}var _u=(s,e,t)=>s.endsWith(` `)?Js(t,e):t.includes(` `)?` `+Js(t,e):(s.endsWith(" ")?"":" ")+t;oi.indentComment=Js;oi.lineComment=_u;oi.stringifyComment=Nu});var Ko=P(nt=>{"use strict";var Cu="flow",Qs="block",ai="quoted";function Iu(s,e,t="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:r=20,onFold:o,onOverflow:a}={}){if(!n||n<0)return s;n<r&&(r=0);let l=Math.max(1+r,1+n-e.length);if(s.length<=l)return s;let c=[],f={},u=n-e.length;typeof i=="number"&&(i>n-Math.max(2,r)?c.push(0):u=n-i);let h,y,S=!1,d=-1,p=-1,m=-1;t===Qs&&(d=Uo(s,d,e.length),d!==-1&&(u=d+l));for(let F;F=s[d+=1];){if(t===ai&&F==="\\"){switch(p=d,s[d+1]){case"x":d+=3;break;case"u":d+=5;break;case"U":d+=9;break;default:d+=1}m=d}if(F===` `)t===Qs&&(d=Uo(s,d,e.length)),u=d+e.length+l,h=void 0;else{if(F===" "&&y&&y!==" "&&y!==` `&&y!==" "){let b=s[d+1];b&&b!==" "&&b!==` `&&b!==" "&&(h=d)}if(d>=u)if(h)c.push(h),u=h+l,h=void 0;else if(t===ai){for(;y===" "||y===" ";)y=F,F=s[d+=1],S=!0;let b=d>m+1?d-2:p-1;if(f[b])return s;c.push(b),f[b]=!0,u=b+l,h=void 0}else S=!0}y=F}if(S&&a&&a(),c.length===0)return s;o&&o();let g=s.slice(0,c[0]);for(let F=0;F<c.length;++F){let b=c[F],w=c[F+1]||s.length;b===0?g=` ${e}${s.slice(0,w)}`:(t===ai&&f[b]&&(g+=`${s[b]}\\`),g+=` ${e}${s.slice(b+1,w)}`)}return g}function Uo(s,e,t){let i=e,n=e+1,r=s[n];for(;r===" "||r===" ";)if(e<n+t)r=s[++e];else{do r=s[++e];while(r&&r!==` `);i=e,n=e+1,r=s[n]}return i}nt.FOLD_BLOCK=Qs;nt.FOLD_FLOW=Cu;nt.FOLD_QUOTED=ai;nt.foldFlowLines=Iu});var ot=P(Vo=>{"use strict";var G=I(),ae=Ko(),ci=(s,e)=>({indentAtStart:e?s.indent.length:s.indentAtStart,lineWidth:s.options.lineWidth,minContentWidth:s.options.minContentWidth}),ui=s=>/^(%|---|\.\.\.)/m.test(s);function ku(s,e,t){if(!e||e<0)return!1;let i=e-t,n=s.length;if(n<=i)return!1;for(let r=0,o=0;r<n;++r)if(s[r]===` `){if(r-o>i)return!0;if(o=r+1,n-o<=i)return!1}return!0}function rt(s,e){let t=JSON.stringify(s);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:i}=e,n=e.options.doubleQuotedMinMultiLineLength,r=e.indent||(ui(s)?" ":""),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);let f=t.substr(l+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=t.substr(l,6)}l+=5,a=l+1}break;case"n":if(i||t[l+2]==='"'||t.length<n)l+=1;else{for(o+=t.slice(a,l)+` `;t[l+2]==="\\"&&t[l+3]==="n"&&t[l+4]!=='"';)o+=` `,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,i?o:ae.foldFlowLines(o,r,ae.FOLD_QUOTED,ci(e,!1))}function Xs(s,e){if(e.options.singleQuote===!1||e.implicitKey&&s.includes(` `)||/[ \t]\n|\n[ \t]/.test(s))return rt(s,e);let t=e.indent||(ui(s)?" ":""),i="'"+s.replace(/'/g,"''").replace(/\n+/g,`$& ${t}`)+"'";return e.implicitKey?i:ae.foldFlowLines(i,t,ae.FOLD_FLOW,ci(e,!1))}function ke(s,e){let{singleQuote:t}=e.options,i;if(t===!1)i=rt;else{let n=s.includes('"'),r=s.includes("'");n&&!r?i=Xs:r&&!n?i=rt:i=t?Xs:rt}return i(s,e)}var zs;try{zs=new RegExp(`(^|(?<! )) +(?! |$)`,"g")}catch{zs=/\n+(?!\n|$)/g}function li({comment:s,type:e,value:t},i,n,r){let{blockQuote:o,commentString:a,lineWidth:l}=i.options;if(!o||/\n[\t ]+$/.test(t)||/^\s*$/.test(t))return ke(t,i);let c=i.indent||(i.forceBlockIndent||ui(t)?" ":""),f=o==="literal"?!0:o==="folded"||e===G.Scalar.BLOCK_FOLDED?!1:e===G.Scalar.BLOCK_LITERAL?!0:!ku(t,l,c.length);if(!t)return f?`| `:`> `;let u,h;for(h=t.length;h>0;--h){let w=t[h-1];if(w!==` `&&w!==" "&&w!==" ")break}let y=t.substring(h),S=y.indexOf(` `);S===-1?u="-":t===y||S!==y.length-1?(u="+",r&&r()):u="",y&&(t=t.slice(0,-y.length),y[y.length-1]===` `&&(y=y.slice(0,-1)),y=y.replace(zs,`$&${c}`));let d=!1,p,m=-1;for(p=0;p<t.length;++p){let w=t[p];if(w===" ")d=!0;else if(w===` `)m=p;else break}let g=t.substring(0,m<p?m+1:p);g&&(t=t.substring(g.length),g=g.replace(/\n+/g,`$&${c}`));let b=(d?c?"2":"1":"")+u;if(s&&(b+=" "+a(s.replace(/ ?[\r\n]+/g," ")),n&&n()),!f){let w=t.replace(/\n+/g,` $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),v=!1,A=ci(i,!0);o!=="folded"&&e!==G.Scalar.BLOCK_FOLDED&&(A.onOverflow=()=>{v=!0});let E=ae.foldFlowLines(`${g}${w}${y}`,c,ae.FOLD_BLOCK,A);if(!v)return`>${b} ${c}${E}`}return t=t.replace(/\n+/g,`$&${c}`),`|${b} ${c}${g}${t}${y}`}function xu(s,e,t,i){let{type:n,value:r}=s,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:f}=e;if(a&&r.includes(` `)||f&&/[[\]{},]/.test(r))return ke(r,e);if(!r||/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return a||f||!r.includes(` `)?ke(r,e):li(s,e,t,i);if(!a&&!f&&n!==G.Scalar.PLAIN&&r.includes(` `))return li(s,e,t,i);if(ui(r)){if(l==="")return e.forceBlockIndent=!0,li(s,e,t,i);if(a&&l===c)return ke(r,e)}let u=r.replace(/\n+/g,`$& ${l}`);if(o){let h=d=>d.default&&d.tag!=="tag:yaml.org,2002:str"&&d.test?.test(u),{compat:y,tags:S}=e.doc.schema;if(S.some(h)||y?.some(h))return ke(r,e)}return a?u:ae.foldFlowLines(u,l,ae.FOLD_FLOW,ci(e,!1))}function qu(s,e,t,i){let{implicitKey:n,inFlow:r}=e,o=typeof s.value=="string"?s:Object.assign({},s,{value:String(s.value)}),{type:a}=s;a!==G.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=G.Scalar.QUOTE_DOUBLE);let l=f=>{switch(f){case G.Scalar.BLOCK_FOLDED:case G.Scalar.BLOCK_LITERAL:return n||r?ke(o.value,e):li(o,e,t,i);case G.Scalar.QUOTE_DOUBLE:return rt(o.value,e);case G.Scalar.QUOTE_SINGLE:return Xs(o.value,e);case G.Scalar.PLAIN:return xu(o,e,t,i);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:u}=e.options,h=n&&f||u;if(c=l(h),c===null)throw new Error(`Unsupported default string type ${h}`)}return c}Vo.stringifyString=qu});var at=P(Zs=>{"use strict";var Mu=ei(),le=L(),Ru=st(),Bu=ot();function ju(s,e){let t=Object.assign({blockQuote:!0,commentString:Ru.stringifyComment,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},s.schema.toStringOptions,e),i;switch(t.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:s,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:i,options:t}}function $u(s,e){if(e.tag){let n=s.filter(r=>r.tag===e.tag);if(n.length>0)return n.find(r=>r.format===e.format)??n[0]}let t,i;if(le.isScalar(e)){i=e.value;let n=s.filter(r=>r.identify?.(i));if(n.length>1){let r=n.filter(o=>o.test);r.length>0&&(n=r)}t=n.find(r=>r.format===e.format)??n.find(r=>!r.format)}else i=e,t=s.find(n=>n.nodeClass&&i instanceof n.nodeClass);if(!t){let n=i?.constructor?.name??typeof i;throw new Error(`Tag not resolved for ${n} value`)}return t}function Uu(s,e,{anchors:t,doc:i}){if(!i.directives)return"";let n=[],r=(le.isScalar(s)||le.isCollection(s))&&s.anchor;r&&Mu.anchorIsValid(r)&&(t.add(r),n.push(`&${r}`));let o=s.tag?s.tag:e.default?null:e.tag;return o&&n.push(i.directives.tagString(o)),n.join(" ")}function Ku(s,e,t,i){if(le.isPair(s))return s.toString(e,t,i);if(le.isAlias(s)){if(e.doc.directives)return s.toString(e);if(e.resolvedAliases?.has(s))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(s):e.resolvedAliases=new Set([s]),s=s.resolve(e.doc)}let n,r=le.isNode(s)?s:e.doc.createNode(s,{onTagObj:l=>n=l});n||(n=$u(e.doc.schema.tags,r));let o=Uu(r,n,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);let a=typeof n.stringify=="function"?n.stringify(r,e,t,i):le.isScalar(r)?Bu.stringifyString(r,e,t,i):r.toString(e,t,i);return o?le.isScalar(r)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o} ${e.indent}${a}`:a}Zs.createStringifyContext=ju;Zs.stringify=Ku});var Yo=P(Go=>{"use strict";var ee=L(),Wo=I(),Ho=at(),lt=st();function Vu({key:s,value:e},t,i,n){let{allNullValues:r,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:u}}=t,h=ee.isNode(s)&&s.comment||null;if(u){if(h)throw new Error("With simple keys, key nodes cannot have comments");if(ee.isCollection(s)||!ee.isNode(s)&&typeof s=="object"){let A="With simple keys, collection cannot be used as a key value";throw new Error(A)}}let y=!u&&(!s||h&&e==null&&!t.inFlow||ee.isCollection(s)||(ee.isScalar(s)?s.type===Wo.Scalar.BLOCK_FOLDED||s.type===Wo.Scalar.BLOCK_LITERAL:typeof s=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!y&&(u||!r),indent:a+l});let S=!1,d=!1,p=Ho.stringify(s,t,()=>S=!0,()=>d=!0);if(!y&&!t.inFlow&&p.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");y=!0}if(t.inFlow){if(r||e==null)return S&&i&&i(),p===""?"?":y?`? ${p}`:p}else if(r&&!u||e==null&&y)return p=`? ${p}`,h&&!S?p+=lt.lineComment(p,t.indent,c(h)):d&&n&&n(),p;S&&(h=null),y?(h&&(p+=lt.lineComment(p,t.indent,c(h))),p=`? ${p} ${a}:`):(p=`${p}:`,h&&(p+=lt.lineComment(p,t.indent,c(h))));let m,g,F;ee.isNode(e)?(m=!!e.spaceBefore,g=e.commentBefore,F=e.comment):(m=!1,g=null,F=null,e&&typeof e=="object"&&(e=o.createNode(e))),t.implicitKey=!1,!y&&!h&&ee.isScalar(e)&&(t.indentAtStart=p.length+1),d=!1,!f&&l.length>=2&&!t.inFlow&&!y&&ee.isSeq(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let b=!1,w=Ho.stringify(e,t,()=>b=!0,()=>d=!0),v=" ";if(h||m||g){if(v=m?` `:"",g){let A=c(g);v+=` ${lt.indentComment(A,t.indent)}`}w===""&&!t.inFlow?v===` `&&(v=` `):v+=` ${t.indent}`}else if(!y&&ee.isCollection(e)){let A=w[0],E=w.indexOf(` `),N=E!==-1,M=t.inFlow??e.flow??e.items.length===0;if(N||!M){let ie=!1;if(N&&(A==="&"||A==="!")){let C=w.indexOf(" ");A==="&"&&C!==-1&&C<E&&w[C+1]==="!"&&(C=w.indexOf(" ",C+1)),(C===-1||E<C)&&(ie=!0)}ie||(v=` ${t.indent}`)}}else(w===""||w[0]===` `)&&(v="");return p+=v+w,t.inFlow?b&&i&&i():F&&!b?p+=lt.lineComment(p,t.indent,c(F)):d&&n&&n(),p}Go.stringifyPair=Vu});var tn=P(en=>{"use strict";var Jo=require("node:process");function Wu(s,...e){s==="debug"&&console.log(...e)}function Hu(s,e){(s==="debug"||s==="warn")&&(typeof Jo.emitWarning=="function"?Jo.emitWarning(e):console.warn(e))}en.debug=Wu;en.warn=Hu});var di=P(pi=>{"use strict";var ct=L(),Qo=I(),fi="<<",hi={identify:s=>s===fi||typeof s=="symbol"&&s.description===fi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Qo.Scalar(Symbol(fi)),{addToJSMap:Xo}),stringify:()=>fi},Gu=(s,e)=>(hi.identify(e)||ct.isScalar(e)&&(!e.type||e.type===Qo.Scalar.PLAIN)&&hi.identify(e.value))&&s?.doc.schema.tags.some(t=>t.tag===hi.tag&&t.default);function Xo(s,e,t){if(t=s&&ct.isAlias(t)?t.resolve(s.doc):t,ct.isSeq(t))for(let i of t.items)sn(s,e,i);else if(Array.isArray(t))for(let i of t)sn(s,e,i);else sn(s,e,t)}function sn(s,e,t){let i=s&&ct.isAlias(t)?t.resolve(s.doc):t;if(!ct.isMap(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,s,Map);for(let[r,o]of n)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}pi.addMergeToJSMap=Xo;pi.isMergeKey=Gu;pi.merge=hi});var rn=P(ea=>{"use strict";var Yu=tn(),zo=di(),Ju=at(),Zo=L(),nn=re();function Qu(s,e,{key:t,value:i}){if(Zo.isNode(t)&&t.addToJSMap)t.addToJSMap(s,e,i);else if(zo.isMergeKey(s,t))zo.addMergeToJSMap(s,e,i);else{let n=nn.toJS(t,"",s);if(e instanceof Map)e.set(n,nn.toJS(i,n,s));else if(e instanceof Set)e.add(n);else{let r=Xu(t,n,s),o=nn.toJS(i,r,s);r in e?Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[r]=o}}return e}function Xu(s,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(Zo.isNode(s)&&t?.doc){let i=Ju.createStringifyContext(t.doc,{});i.anchors=new Set;for(let r of t.anchors.keys())i.anchors.add(r.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=s.toString(i);if(!t.mapKeyWarned){let r=JSON.stringify(n);r.length>40&&(r=r.substring(0,36)+'..."'),Yu.warn(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 n}return JSON.stringify(e)}ea.addPairToJSMap=Qu});var ce=P(on=>{"use strict";var ta=it(),zu=Yo(),Zu=rn(),gi=L();function ef(s,e,t){let i=ta.createNode(s,void 0,t),n=ta.createNode(e,void 0,t);return new mi(i,n)}var mi=class s{constructor(e,t=null){Object.defineProperty(this,gi.NODE_TYPE,{value:gi.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:i}=this;return gi.isNode(t)&&(t=t.clone(e)),gi.isNode(i)&&(i=i.clone(e)),new s(t,i)}toJSON(e,t){let i=t?.mapAsMap?new Map:{};return Zu.addPairToJSMap(t,i,this)}toString(e,t,i){return e?.doc?zu.stringifyPair(this,e,t,i):JSON.stringify(this)}};on.Pair=mi;on.createPair=ef});var an=P(sa=>{"use strict";var ve=L(),ia=at(),yi=st();function tf(s,e,t){return(e.inFlow??s.flow?nf:sf)(s,e,t)}function sf({comment:s,items:e},t,{blockItemPrefix:i,flowChars:n,itemIndent:r,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=t,f=Object.assign({},t,{indent:r,type:null}),u=!1,h=[];for(let S=0;S<e.length;++S){let d=e[S],p=null;if(ve.isNode(d))!u&&d.spaceBefore&&h.push(""),bi(t,h,d.commentBefore,u),d.comment&&(p=d.comment);else if(ve.isPair(d)){let g=ve.isNode(d.key)?d.key:null;g&&(!u&&g.spaceBefore&&h.push(""),bi(t,h,g.commentBefore,u))}u=!1;let m=ia.stringify(d,f,()=>p=null,()=>u=!0);p&&(m+=yi.lineComment(m,r,c(p))),u&&p&&(u=!1),h.push(i+m)}let y;if(h.length===0)y=n.start+n.end;else{y=h[0];for(let S=1;S<h.length;++S){let d=h[S];y+=d?` ${l}${d}`:` `}}return s?(y+=` `+yi.indentComment(c(s),l),a&&a()):u&&o&&o(),y}function nf({items:s},e,{flowChars:t,itemIndent:i}){let{indent:n,indentStep:r,flowCollectionPadding:o,options:{commentString:a}}=e;i+=r;let l=Object.assign({},e,{indent:i,inFlow:!0,type:null}),c=!1,f=0,u=[];for(let S=0;S<s.length;++S){let d=s[S],p=null;if(ve.isNode(d))d.spaceBefore&&u.push(""),bi(e,u,d.commentBefore,!1),d.comment&&(p=d.comment);else if(ve.isPair(d)){let g=ve.isNode(d.key)?d.key:null;g&&(g.spaceBefore&&u.push(""),bi(e,u,g.commentBefore,!1),g.comment&&(c=!0));let F=ve.isNode(d.value)?d.value:null;F?(F.comment&&(p=F.comment),F.commentBefore&&(c=!0)):d.value==null&&g?.comment&&(p=g.comment)}p&&(c=!0);let m=ia.stringify(d,l,()=>p=null);S<s.length-1&&(m+=","),p&&(m+=yi.lineComment(m,i,a(p))),!c&&(u.length>f||m.includes(` `))&&(c=!0),u.push(m),f=u.length}let{start:h,end:y}=t;if(u.length===0)return h+y;if(!c){let S=u.reduce((d,p)=>d+p.length+2,2);c=e.options.lineWidth>0&&S>e.options.lineWidth}if(c){let S=h;for(let d of u)S+=d?` ${r}${n}${d}`:` `;return`${S} ${n}${y}`}else return`${h}${o}${u.join(" ")}${o}${y}`}function bi({indent:s,options:{commentString:e}},t,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let r=yi.indentComment(e(i),s);t.push(r.trimStart())}}sa.stringifyCollection=tf});var fe=P(cn=>{"use strict";var rf=an(),of=rn(),af=ri(),ue=L(),wi=ce(),lf=I();function ut(s,e){let t=ue.isScalar(e)?e.value:e;for(let i of s)if(ue.isPair(i)&&(i.key===e||i.key===t||ue.isScalar(i.key)&&i.key.value===t))return i}var ln=class extends af.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(ue.MAP,e),this.items=[]}static from(e,t,i){let{keepUndefined:n,replacer:r}=i,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||n)&&o.items.push(wi.createPair(l,c,i))};if(t instanceof Map)for(let[l,c]of t)a(l,c);else if(t&&typeof t=="object")for(let l of Object.keys(t))a(l,t[l]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,t){let i;ue.isPair(e)?i=e:!e||typeof e!="object"||!("key"in e)?i=new wi.Pair(e,e?.value):i=new wi.Pair(e.key,e.value);let n=ut(this.items,i.key),r=this.schema?.sortMapEntries;if(n){if(!t)throw new Error(`Key ${i.key} already set`);ue.isScalar(n.value)&&lf.isScalarValue(i.value)?n.value.value=i.value:n.value=i.value}else if(r){let o=this.items.findIndex(a=>r(i,a)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(e){let t=ut(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=ut(this.items,e)?.value;return(!t&&ue.isScalar(n)?n.value:n)??void 0}has(e){return!!ut(this.items,e)}set(e,t){this.add(new wi.Pair(e,t),!0)}toJSON(e,t,i){let n=i?new i:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(n);for(let r of this.items)of.addPairToJSMap(t,n,r);return n}toString(e,t,i){if(!e)return JSON.stringify(this);for(let n of this.items)if(!ue.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),rf.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:i,onComment:t})}};cn.YAMLMap=ln;cn.findPair=ut});var xe=P(ra=>{"use strict";var cf=L(),na=fe(),uf={collection:"map",default:!0,nodeClass:na.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(s,e){return cf.isMap(s)||e("Expected a mapping for this tag"),s},createNode:(s,e,t)=>na.YAMLMap.from(s,e,t)};ra.map=uf});var he=P(oa=>{"use strict";var ff=it(),hf=an(),pf=ri(),vi=L(),df=I(),gf=re(),un=class extends pf.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(vi.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=Si(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){let i=Si(e);if(typeof i!="number")return;let n=this.items[i];return!t&&vi.isScalar(n)?n.value:n}has(e){let t=Si(e);return typeof t=="number"&&t<this.items.length}set(e,t){let i=Si(e);if(typeof i!="number")throw new Error(`Expected a valid index, not ${e}.`);let n=this.items[i];vi.isScalar(n)&&df.isScalarValue(t)?n.value=t:this.items[i]=t}toJSON(e,t){let i=[];t?.onCreate&&t.onCreate(i);let n=0;for(let r of this.items)i.push(gf.toJS(r,String(n++),t));return i}toString(e,t,i){return e?hf.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:i,onComment:t}):JSON.stringify(this)}static from(e,t,i){let{replacer:n}=i,r=new this(e);if(t&&Symbol.iterator in Object(t)){let o=0;for(let a of t){if(typeof n=="function"){let l=t instanceof Set?a:String(o++);a=n.call(t,l,a)}r.items.push(ff.createNode(a,void 0,i))}}return r}};function Si(s){let e=vi.isScalar(s)?s.value:s;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}oa.YAMLSeq=un});var qe=P(la=>{"use strict";var mf=L(),aa=he(),yf={collection:"seq",default:!0,nodeClass:aa.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(s,e){return mf.isSeq(s)||e("Expected a sequence for this tag"),s},createNode:(s,e,t)=>aa.YAMLSeq.from(s,e,t)};la.seq=yf});var ft=P(ca=>{"use strict";var bf=ot(),wf={identify:s=>typeof s=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:s=>s,stringify(s,e,t,i){return e=Object.assign({actualString:!0},e),bf.stringifyString(s,e,t,i)}};ca.string=wf});var Fi=P(ha=>{"use strict";var ua=I(),fa={identify:s=>s==null,createNode:()=>new ua.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new ua.Scalar(null),stringify:({source:s},e)=>typeof s=="string"&&fa.test.test(s)?s:e.options.nullStr};ha.nullTag=fa});var fn=P(da=>{"use strict";var Sf=I(),pa={identify:s=>typeof s=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:s=>new Sf.Scalar(s[0]==="t"||s[0]==="T"),stringify({source:s,value:e},t){if(s&&pa.test.test(s)){let i=s[0]==="t"||s[0]==="T";if(e===i)return s}return e?t.options.trueStr:t.options.falseStr}};da.boolTag=pa});var Me=P(ga=>{"use strict";function vf({format:s,minFractionDigits:e,tag:t,value:i}){if(typeof i=="bigint")return String(i);let n=typeof i=="number"?i:Number(i);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let r=JSON.stringify(i);if(!s&&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}ga.stringifyNumber=vf});var pn=P(Ei=>{"use strict";var Ff=I(),hn=Me(),Ef={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:s=>s.slice(-3).toLowerCase()==="nan"?NaN:s[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:hn.stringifyNumber},Pf={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:s=>parseFloat(s),stringify(s){let e=Number(s.value);return isFinite(e)?e.toExponential():hn.stringifyNumber(s)}},Af={identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(s){let e=new Ff.Scalar(parseFloat(s)),t=s.indexOf(".");return t!==-1&&s[s.length-1]==="0"&&(e.minFractionDigits=s.length-t-1),e},stringify:hn.stringifyNumber};Ei.float=Af;Ei.floatExp=Pf;Ei.floatNaN=Ef});var gn=P(Ai=>{"use strict";var ma=Me(),Pi=s=>typeof s=="bigint"||Number.isInteger(s),dn=(s,e,t,{intAsBigInt:i})=>i?BigInt(s):parseInt(s.substring(e),t);function ya(s,e,t){let{value:i}=s;return Pi(i)&&i>=0?t+i.toString(e):ma.stringifyNumber(s)}var Df={identify:s=>Pi(s)&&s>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(s,e,t)=>dn(s,2,8,t),stringify:s=>ya(s,8,"0o")},Tf={identify:Pi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(s,e,t)=>dn(s,0,10,t),stringify:ma.stringifyNumber},Lf={identify:s=>Pi(s)&&s>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(s,e,t)=>dn(s,2,16,t),stringify:s=>ya(s,16,"0x")};Ai.int=Tf;Ai.intHex=Lf;Ai.intOct=Df});var wa=P(ba=>{"use strict";var Of=xe(),Nf=Fi(),_f=qe(),Cf=ft(),If=fn(),mn=pn(),yn=gn(),kf=[Of.map,_f.seq,Cf.string,Nf.nullTag,If.boolTag,yn.intOct,yn.int,yn.intHex,mn.floatNaN,mn.floatExp,mn.float];ba.schema=kf});var Fa=P(va=>{"use strict";var xf=I(),qf=xe(),Mf=qe();function Sa(s){return typeof s=="bigint"||Number.isInteger(s)}var Di=({value:s})=>JSON.stringify(s),Rf=[{identify:s=>typeof s=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:s=>s,stringify:Di},{identify:s=>s==null,createNode:()=>new xf.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Di},{identify:s=>typeof s=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:s=>s==="true",stringify:Di},{identify:Sa,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(s,e,{intAsBigInt:t})=>t?BigInt(s):parseInt(s,10),stringify:({value:s})=>Sa(s)?s.toString():JSON.stringify(s)},{identify:s=>typeof s=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:s=>parseFloat(s),stringify:Di}],Bf={default:!0,tag:"",test:/^/,resolve(s,e){return e(`Unresolved plain scalar ${JSON.stringify(s)}`),s}},jf=[qf.map,Mf.seq].concat(Rf,Bf);va.schema=jf});var wn=P(Ea=>{"use strict";var ht=require("node:buffer"),bn=I(),$f=ot(),Uf={identify:s=>s instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(s,e){if(typeof ht.Buffer=="function")return ht.Buffer.from(s,"base64");if(typeof atob=="function"){let t=atob(s.replace(/[\n\r]/g,"")),i=new Uint8Array(t.length);for(let n=0;n<t.length;++n)i[n]=t.charCodeAt(n);return i}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),s},stringify({comment:s,type:e,value:t},i,n,r){let o=t,a;if(typeof ht.Buffer=="function")a=o instanceof ht.Buffer?o.toString("base64"):ht.Buffer.from(o.buffer).toString("base64");else 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=bn.Scalar.BLOCK_LITERAL),e!==bn.Scalar.QUOTE_DOUBLE){let l=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),c=Math.ceil(a.length/l),f=new Array(c);for(let u=0,h=0;u<c;++u,h+=l)f[u]=a.substr(h,l);a=f.join(e===bn.Scalar.BLOCK_LITERAL?` `:" ")}return $f.stringifyString({comment:s,type:e,value:a},i,n,r)}};Ea.binary=Uf});var Oi=P(Li=>{"use strict";var Ti=L(),Sn=ce(),Kf=I(),Vf=he();function Pa(s,e){if(Ti.isSeq(s))for(let t=0;t<s.items.length;++t){let i=s.items[t];if(!Ti.isPair(i)){if(Ti.isMap(i)){i.items.length>1&&e("Each pair must have its own sequence indicator");let n=i.items[0]||new Sn.Pair(new Kf.Scalar(null));if(i.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${i.commentBefore} ${n.key.commentBefore}`:i.commentBefore),i.comment){let r=n.value??n.key;r.comment=r.comment?`${i.comment} ${r.comment}`:i.comment}i=n}s.items[t]=Ti.isPair(i)?i:new Sn.Pair(i)}}else e("Expected a sequence for this tag");return s}function Aa(s,e,t){let{replacer:i}=t,n=new Vf.YAMLSeq(s);n.tag="tag:yaml.org,2 … [Строка слишком длинная. Вы можете скачать файл] `)?(t.push("..."),t.push(yt.indentComment(l,""))):t.push(`... ${l}`)}else t.push("...");else{let l=s.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||a)&&t[t.length-1]!==""&&t.push(""),t.push(yt.indentComment(r(l),"")))}return t.join(` `)+` `}za.stringifyDocument=Lh});var bt=P(el=>{"use strict";var Oh=tt(),Re=ri(),V=L(),Nh=ce(),_h=re(),Ch=Rn(),Ih=Za(),jn=ei(),kh=Ks(),xh=it(),$n=Us(),Un=class s{constructor(e,t,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,V.NODE_TYPE,{value:V.DOC});let n=null;typeof t=="function"||Array.isArray(t)?n=t:i===void 0&&t&&(i=t,t=void 0);let r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=r;let{version:o}=r;i?._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new $n.Directives({version:o}),this.setSchema(o,i),this.contents=e===void 0?null:this.createNode(e,n,i)}clone(){let e=Object.create(s.prototype,{[V.NODE_TYPE]:{value:V.DOC}});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=V.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Be(this.contents)&&this.contents.add(e)}addIn(e,t){Be(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let i=jn.anchorNames(this);e.anchor=!t||i.has(t)?jn.findNewAnchor(t||"a",i):t}return new Oh.Alias(e.anchor)}createNode(e,t,i){let n;if(typeof t=="function")e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){let p=g=>typeof g=="number"||g instanceof String||g instanceof Number,m=t.filter(p).map(String);m.length>0&&(t=t.concat(m)),n=t}else i===void 0&&t&&(i=t,t=void 0);let{aliasDuplicateObjects:r,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:f}=i??{},{onAnchor:u,setAnchors:h,sourceObjects:y}=jn.createNodeAnchors(this,o||"a"),S={aliasDuplicateObjects:r??!0,keepUndefined:l??!1,onAnchor:u,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:y},d=xh.createNode(e,f,S);return a&&V.isCollection(d)&&(d.flow=!0),h(),d}createPair(e,t,i={}){let n=this.createNode(e,null,i),r=this.createNode(t,null,i);return new Nh.Pair(n,r)}delete(e){return Be(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Re.isEmptyPath(e)?this.contents==null?!1:(this.contents=null,!0):Be(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return V.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return Re.isEmptyPath(e)?!t&&V.isScalar(this.contents)?this.contents.value:this.contents:V.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return V.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return Re.isEmptyPath(e)?this.contents!==void 0:V.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Re.collectionFromPath(this.schema,[e],t):Be(this.contents)&&this.contents.set(e,t)}setIn(e,t){Re.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=Re.collectionFromPath(this.schema,Array.from(e),t):Be(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let i;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new $n.Directives({version:"1.1"}),i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new $n.Directives({version:e}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{let n=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(i)this.schema=new Ch.Schema(Object.assign(i,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:i,maxAliasCount:n,onAnchor:r,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},l=_h.toJS(this.contents,t??"",a);if(typeof r=="function")for(let{count:c,res:f}of a.anchors.values())r(f,c);return typeof o=="function"?kh.applyReviver(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)){let t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return Ih.stringifyDocument(this,e)}};function Be(s){if(V.isCollection(s))return!0;throw new Error("Expected a YAML collection as document contents")}el.Document=Un});var vt=P(St=>{"use strict";var wt=class extends Error{constructor(e,t,i,n){super(),this.name=e,this.code=i,this.message=n,this.pos=t}},Kn=class extends wt{constructor(e,t,i){super("YAMLParseError",e,t,i)}},Vn=class extends wt{constructor(e,t,i){super("YAMLWarning",e,t,i)}},qh=(s,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(a=>e.linePos(a));let{line:i,col:n}=t.linePos[0];t.message+=` at line ${i}, column ${n}`;let r=n-1,o=s.substring(e.lineStarts[i-1],e.lineStarts[i]).replace(/[\n\r]+$/,"");if(r>=60&&o.length>80){let a=Math.min(r-39,o.length-79);o="\u2026"+o.substring(a),r-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),i>1&&/^ *$/.test(o.substring(0,r))){let a=s.substring(e.lineStarts[i-2],e.lineStarts[i-1]);a.length>80&&(a=a.substring(0,79)+`\u2026 `),o=a+o}if(/[^ ]/.test(o)){let a=1,l=t.linePos[1];l&&l.line===i&&l.col>n&&(a=Math.max(1,Math.min(l.col-n,80-r)));let c=" ".repeat(r)+"^".repeat(a);t.message+=`: ${o} ${c} `}};St.YAMLError=wt;St.YAMLParseError=Kn;St.YAMLWarning=Vn;St.prettifyError=qh});var Ft=P(tl=>{"use strict";function Mh(s,{flow:e,indicator:t,next:i,offset:n,onError:r,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,u="",h="",y=!1,S=!1,d=null,p=null,m=null,g=null,F=null,b=null,w=null;for(let E of s)switch(S&&(E.type!=="space"&&E.type!=="newline"&&E.type!=="comma"&&r(E.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),S=!1),d&&(c&&E.type!=="comment"&&E.type!=="newline"&&r(d,"TAB_AS_INDENT","Tabs are not allowed as indentation"),d=null),E.type){case"space":!e&&(t!=="doc-start"||i?.type!=="flow-collection")&&E.source.includes(" ")&&(d=E),f=!0;break;case"comment":{f||r(E,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let N=E.source.substring(1)||" ";u?u+=h+N:u=N,h="",c=!1;break}case"newline":c?u?u+=E.source:(!b||t!=="seq-item-ind")&&(l=!0):h+=E.source,c=!0,y=!0,(p||m)&&(g=E),f=!0;break;case"anchor":p&&r(E,"MULTIPLE_ANCHORS","A node can have at most one anchor"),E.source.endsWith(":")&&r(E.offset+E.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),p=E,w===null&&(w=E.offset),c=!1,f=!1,S=!0;break;case"tag":{m&&r(E,"MULTIPLE_TAGS","A node can have at most one tag"),m=E,w===null&&(w=E.offset),c=!1,f=!1,S=!0;break}case t:(p||m)&&r(E,"BAD_PROP_ORDER",`Anchors and tags must be after the ${E.source} indicator`),b&&r(E,"UNEXPECTED_TOKEN",`Unexpected ${E.source} in ${e??"collection"}`),b=E,c=t==="seq-item-ind"||t==="explicit-key-ind",f=!1;break;case"comma":if(e){F&&r(E,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),F=E,c=!1,f=!1;break}default:r(E,"UNEXPECTED_TOKEN",`Unexpected ${E.type} token`),c=!1,f=!1}let v=s[s.length-1],A=v?v.offset+v.source.length:n;return S&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&r(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),d&&(c&&d.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&r(d,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:F,found:b,spaceBefore:l,comment:u,hasNewline:y,anchor:p,tag:m,newlineAfterProp:g,end:A,start:w??A}}tl.resolveProps=Mh});var Bi=P(il=>{"use strict";function Wn(s){if(!s)return null;switch(s.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(s.source.includes(` `))return!0;if(s.end){for(let e of s.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of s.items){for(let t of e.start)if(t.type==="newline")return!0;if(e.sep){for(let t of e.sep)if(t.type==="newline")return!0}if(Wn(e.key)||Wn(e.value))return!0}return!1;default:return!0}}il.containsNewline=Wn});var Hn=P(sl=>{"use strict";var Rh=Bi();function Bh(s,e,t){if(e?.type==="flow-collection"){let i=e.end[0];i.indent===s&&(i.source==="]"||i.source==="}")&&Rh.containsNewline(e)&&t(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}sl.flowIndentCheck=Bh});var Gn=P(rl=>{"use strict";var nl=L();function jh(s,e,t){let{uniqueKeys:i}=s.options;if(i===!1)return!1;let n=typeof i=="function"?i:(r,o)=>r===o||nl.isScalar(r)&&nl.isScalar(o)&&r.value===o.value;return e.some(r=>n(r.key,t))}rl.mapIncludes=jh});var fl=P(ul=>{"use strict";var ol=ce(),$h=fe(),al=Ft(),Uh=Bi(),ll=Hn(),Kh=Gn(),cl="All mapping items must start at the same column";function Vh({composeNode:s,composeEmptyNode:e},t,i,n,r){let o=r?.nodeClass??$h.YAMLMap,a=new o(t.schema);t.atRoot&&(t.atRoot=!1);let l=i.offset,c=null;for(let f of i.items){let{start:u,key:h,sep:y,value:S}=f,d=al.resolveProps(u,{indicator:"explicit-key-ind",next:h??y?.[0],offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0}),p=!d.found;if(p){if(h&&(h.type==="block-seq"?n(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in h&&h.indent!==i.indent&&n(l,"BAD_INDENT",cl)),!d.anchor&&!d.tag&&!y){c=d.end,d.comment&&(a.comment?a.comment+=` `+d.comment:a.comment=d.comment);continue}(d.newlineAfterProp||Uh.containsNewline(h))&&n(h??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else d.found?.indent!==i.indent&&n(l,"BAD_INDENT",cl);t.atKey=!0;let m=d.end,g=h?s(t,h,d,n):e(t,m,u,null,d,n);t.schema.compat&&ll.flowIndentCheck(i.indent,h,n),t.atKey=!1,Kh.mapIncludes(t,a.items,g)&&n(m,"DUPLICATE_KEY","Map keys must be unique");let F=al.resolveProps(y??[],{indicator:"map-value-ind",next:S,offset:g.range[2],onError:n,parentIndent:i.indent,startOnNewline:!h||h.type==="block-scalar"});if(l=F.end,F.found){p&&(S?.type==="block-map"&&!F.hasNewline&&n(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&d.start<F.found.offset-1024&&n(g.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let b=S?s(t,S,F,n):e(t,l,y,null,F,n);t.schema.compat&&ll.flowIndentCheck(i.indent,S,n),l=b.range[2];let w=new ol.Pair(g,b);t.options.keepSourceTokens&&(w.srcToken=f),a.items.push(w)}else{p&&n(g.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),F.comment&&(g.comment?g.comment+=` `+F.comment:g.comment=F.comment);let b=new ol.Pair(g);t.options.keepSourceTokens&&(b.srcToken=f),a.items.push(b)}}return c&&c<l&&n(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[i.offset,l,c??l],a}ul.resolveBlockMap=Vh});var pl=P(hl=>{"use strict";var Wh=he(),Hh=Ft(),Gh=Hn();function Yh({composeNode:s,composeEmptyNode:e},t,i,n,r){let o=r?.nodeClass??Wh.YAMLSeq,a=new o(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let l=i.offset,c=null;for(let{start:f,value:u}of i.items){let h=Hh.resolveProps(f,{indicator:"seq-item-ind",next:u,offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!h.found)if(h.anchor||h.tag||u)u&&u.type==="block-seq"?n(h.end,"BAD_INDENT","All sequence items must start at the same column"):n(l,"MISSING_CHAR","Sequence item without - indicator");else{c=h.end,h.comment&&(a.comment=h.comment);continue}let y=u?s(t,u,h,n):e(t,h.end,f,null,h,n);t.schema.compat&&Gh.flowIndentCheck(i.indent,u,n),l=y.range[2],a.items.push(y)}return a.range=[i.offset,l,c??l],a}hl.resolveBlockSeq=Yh});var je=P(dl=>{"use strict";function Jh(s,e,t,i){let n="";if(s){let r=!1,o="";for(let a of s){let{source:l,type:c}=a;switch(c){case"space":r=!0;break;case"comment":{t&&!r&&i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=l.substring(1)||" ";n?n+=o+f:n=f,o="";break}case"newline":n&&(o+=l),r=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:n,offset:e}}dl.resolveEnd=Jh});var bl=P(yl=>{"use strict";var Qh=L(),Xh=ce(),gl=fe(),zh=he(),Zh=je(),ml=Ft(),ep=Bi(),tp=Gn(),Yn="Block collections are not allowed within flow collections",Jn=s=>s&&(s.type==="block-map"||s.type==="block-seq");function ip({composeNode:s,composeEmptyNode:e},t,i,n,r){let o=i.start.source==="{",a=o?"flow map":"flow sequence",l=r?.nodeClass??(o?gl.YAMLMap:zh.YAMLSeq),c=new l(t.schema);c.flow=!0;let f=t.atRoot;f&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let u=i.offset+i.start.source.length;for(let p=0;p<i.items.length;++p){let m=i.items[p],{start:g,key:F,sep:b,value:w}=m,v=ml.resolveProps(g,{flow:a,indicator:"explicit-key-ind",next:F??b?.[0],offset:u,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!v.found){if(!v.anchor&&!v.tag&&!b&&!w){p===0&&v.comma?n(v.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):p<i.items.length-1&&n(v.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),v.comment&&(c.comment?c.comment+=` `+v.comment:c.comment=v.comment),u=v.end;continue}!o&&t.options.strict&&ep.containsNewline(F)&&n(F,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(p===0)v.comma&&n(v.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(v.comma||n(v.start,"MISSING_CHAR",`Missing , between ${a} items`),v.comment){let A="";e:for(let E of g)switch(E.type){case"comma":case"space":break;case"comment":A=E.source.substring(1);break e;default:break e}if(A){let E=c.items[c.items.length-1];Qh.isPair(E)&&(E=E.value??E.key),E.comment?E.comment+=` `+A:E.comment=A,v.comment=v.comment.substring(A.length+1)}}if(!o&&!b&&!v.found){let A=w?s(t,w,v,n):e(t,v.end,b,null,v,n);c.items.push(A),u=A.range[2],Jn(w)&&n(A.range,"BLOCK_IN_FLOW",Yn)}else{t.atKey=!0;let A=v.end,E=F?s(t,F,v,n):e(t,A,g,null,v,n);Jn(F)&&n(E.range,"BLOCK_IN_FLOW",Yn),t.atKey=!1;let N=ml.resolveProps(b??[],{flow:a,indicator:"map-value-ind",next:w,offset:E.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(N.found){if(!o&&!v.found&&t.options.strict){if(b)for(let C of b){if(C===N.found)break;if(C.type==="newline"){n(C,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}v.start<N.found.offset-1024&&n(N.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else w&&("source"in w&&w.source&&w.source[0]===":"?n(w,"MISSING_CHAR",`Missing space after : in ${a}`):n(N.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let M=w?s(t,w,N,n):N.found?e(t,N.end,b,null,N,n):null;M?Jn(w)&&n(M.range,"BLOCK_IN_FLOW",Yn):N.comment&&(E.comment?E.comment+=` `+N.comment:E.comment=N.comment);let ie=new Xh.Pair(E,M);if(t.options.keepSourceTokens&&(ie.srcToken=m),o){let C=c;tp.mapIncludes(t,C.items,E)&&n(A,"DUPLICATE_KEY","Map keys must be unique"),C.items.push(ie)}else{let C=new gl.YAMLMap(t.schema);C.flow=!0,C.items.push(ie);let Rt=(M??E).range;C.range=[E.range[0],Rt[1],Rt[2]],c.items.push(C)}u=M?M.range[2]:N.end}}let h=o?"}":"]",[y,...S]=i.end,d=u;if(y&&y.source===h)d=y.offset+y.source.length;else{let p=a[0].toUpperCase()+a.substring(1),m=f?`${p} must end with a ${h}`:`${p} in block collection must be sufficiently indented and end with a ${h}`;n(u,f?"MISSING_CHAR":"BAD_INDENT",m),y&&y.source.length!==1&&S.unshift(y)}if(S.length>0){let p=Zh.resolveEnd(S,d,t.options.strict,n);p.comment&&(c.comment?c.comment+=` `+p.comment:c.comment=p.comment),c.range=[i.offset,d,p.offset]}else c.range=[i.offset,d,d];return c}yl.resolveFlowCollection=ip});var Sl=P(wl=>{"use strict";var sp=L(),np=I(),rp=fe(),op=he(),ap=fl(),lp=pl(),cp=bl();function Qn(s,e,t,i,n,r){let o=t.type==="block-map"?ap.resolveBlockMap(s,e,t,i,r):t.type==="block-seq"?lp.resolveBlockSeq(s,e,t,i,r):cp.resolveFlowCollection(s,e,t,i,r),a=o.constructor;return n==="!"||n===a.tagName?(o.tag=a.tagName,o):(n&&(o.tag=n),o)}function up(s,e,t,i,n){let r=i.tag,o=r?e.directives.tagName(r.source,h=>n(r,"TAG_RESOLVE_FAILED",h)):null;if(t.type==="block-seq"){let{anchor:h,newlineAfterProp:y}=i,S=h&&r?h.offset>r.offset?h:r:h??r;S&&(!y||y.offset<S.offset)&&n(S,"MISSING_CHAR","Missing newline after block sequence props")}let a=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!r||!o||o==="!"||o===rp.YAMLMap.tagName&&a==="map"||o===op.YAMLSeq.tagName&&a==="seq")return Qn(s,e,t,n,o);let l=e.schema.tags.find(h=>h.tag===o&&h.collection===a);if(!l){let h=e.schema.knownTags[o];if(h&&h.collection===a)e.schema.tags.push(Object.assign({},h,{default:!1})),l=h;else return h?.collection?n(r,"BAD_COLLECTION_TYPE",`${h.tag} used for ${a} collection, but expects ${h.collection}`,!0):n(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),Qn(s,e,t,n,o)}let c=Qn(s,e,t,n,o,l),f=l.resolve?.(c,h=>n(r,"TAG_RESOLVE_FAILED",h),e.options)??c,u=sp.isNode(f)?f:new np.Scalar(f);return u.range=c.range,u.tag=o,l?.format&&(u.format=l.format),u}wl.composeCollection=up});var zn=P(vl=>{"use strict";var Xn=I();function fp(s,e,t){let i=e.offset,n=hp(e,s.options.strict,t);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let r=n.mode===">"?Xn.Scalar.BLOCK_FOLDED:Xn.Scalar.BLOCK_LITERAL,o=e.source?pp(e.source):[],a=o.length;for(let d=o.length-1;d>=0;--d){let p=o[d][1];if(p===""||p==="\r")a=d;else break}if(a===0){let d=n.chomp==="+"&&o.length>0?` `.repeat(Math.max(1,o.length-1)):"",p=i+n.length;return e.source&&(p+=e.source.length),{value:d,type:r,comment:n.comment,range:[i,p,p]}}let l=e.indent+n.indent,c=e.offset+n.length,f=0;for(let d=0;d<a;++d){let[p,m]=o[d];if(m===""||m==="\r")n.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"),n.indent===0&&(l=p.length),f=d,l===0&&!s.atRoot&&t(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=p.length+m.length+1}for(let d=o.length-1;d>=a;--d)o[d][0].length>l&&(a=d+1);let u="",h="",y=!1;for(let d=0;d<f;++d)u+=o[d][0].slice(l)+` `;for(let d=f;d<a;++d){let[p,m]=o[d];c+=p.length+m.length+1;let g=m[m.length-1]==="\r";if(g&&(m=m.slice(0,-1)),m&&p.length<l){let b=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;t(c-m.length-(g?2:1),"BAD_INDENT",b),p=""}r===Xn.Scalar.BLOCK_LITERAL?(u+=h+p.slice(l)+m,h=` `):p.length>l||m[0]===" "?(h===" "?h=` `:!y&&h===` `&&(h=` `),u+=h+p.slice(l)+m,h=` `,y=!0):m===""?h===` `?u+=` `:h=` `:(u+=h+m,h=" ",y=!1)}switch(n.chomp){case"-":break;case"+":for(let d=a;d<o.length;++d)u+=` `+o[d][0].slice(l);u[u.length-1]!==` `&&(u+=` `);break;default:u+=` `}let S=i+n.length+e.source.length;return{value:u,type:r,comment:n.comment,range:[i,S,S]}}function hp({offset:s,props:e},t,i){if(e[0].type!=="block-scalar-header")return i(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=e[0],r=n[0],o=0,a="",l=-1;for(let h=1;h<n.length;++h){let y=n[h];if(!a&&(y==="-"||y==="+"))a=y;else{let S=Number(y);!o&&S?o=S:l===-1&&(l=s+h)}}l!==-1&&i(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let c=!1,f="",u=n.length;for(let h=1;h<e.length;++h){let y=e[h];switch(y.type){case"space":c=!0;case"newline":u+=y.source.length;break;case"comment":t&&!c&&i(y,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=y.source.length,f=y.source.substring(1);break;case"error":i(y,"UNEXPECTED_TOKEN",y.message),u+=y.source.length;break;default:{let S=`Unexpected token in block scalar header: ${y.type}`;i(y,"UNEXPECTED_TOKEN",S);let d=y.source;d&&typeof d=="string"&&(u+=d.length)}}}return{mode:r,indent:o,chomp:a,comment:f,length:u}}function pp(s){let e=s.split(/\n( *)/),t=e[0],i=t.match(/^( *)/),r=[i?.[1]?[i[1],t.slice(i[1].length)]:["",t]];for(let o=1;o<e.length;o+=2)r.push([e[o],e[o+1]]);return r}vl.resolveBlockScalar=fp});var er=P(El=>{"use strict";var Zn=I(),dp=je();function gp(s,e,t){let{offset:i,type:n,source:r,end:o}=s,a,l,c=(h,y,S)=>t(i+h,y,S);switch(n){case"scalar":a=Zn.Scalar.PLAIN,l=mp(r,c);break;case"single-quoted-scalar":a=Zn.Scalar.QUOTE_SINGLE,l=yp(r,c);break;case"double-quoted-scalar":a=Zn.Scalar.QUOTE_DOUBLE,l=bp(r,c);break;default:return t(s,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+r.length,i+r.length]}}let f=i+r.length,u=dp.resolveEnd(o,f,e,t);return{value:l,type:a,comment:u.comment,range:[i,f,u.offset]}}function mp(s,e){let t="";switch(s[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${s[0]}`;break}case"@":case"`":{t=`reserved character ${s[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),Fl(s)}function yp(s,e){return(s[s.length-1]!=="'"||s.length===1)&&e(s.length,"MISSING_CHAR","Missing closing 'quote"),Fl(s.slice(1,-1)).replace(/''/g,"'")}function Fl(s){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r? `,"sy"),t=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r? `,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,t=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=e.exec(s);if(!i)return s;let n=i[1],r=" ",o=e.lastIndex;for(t.lastIndex=o;i=t.exec(s);)i[1]===""?r===` `?n+=r:r=` `:(n+=r+i[1],r=" "),o=t.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,i=a.exec(s),n+r+(i?.[1]??"")}function bp(s,e){let t="";for(let i=1;i<s.length-1;++i){let n=s[i];if(!(n==="\r"&&s[i+1]===` `))if(n===` `){let{fold:r,offset:o}=wp(s,i);t+=r,i=o}else if(n==="\\"){let r=s[++i],o=Sp[r];if(o)t+=o;else if(r===` `)for(r=s[i+1];r===" "||r===" ";)r=s[++i+1];else if(r==="\r"&&s[i+1]===` `)for(r=s[++i+1];r===" "||r===" ";)r=s[++i+1];else if(r==="x"||r==="u"||r==="U"){let a={x:2,u:4,U:8}[r];t+=vp(s,i+1,a,e),i+=a}else{let a=s.substr(i-1,2);e(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),t+=a}}else if(n===" "||n===" "){let r=i,o=s[i+1];for(;o===" "||o===" ";)o=s[++i+1];o!==` `&&!(o==="\r"&&s[i+2]===` `)&&(t+=i>r?s.slice(r,i+1):n)}else t+=n}return(s[s.length-1]!=='"'||s.length===1)&&e(s.length,"MISSING_CHAR",'Missing closing "quote'),t}function wp(s,e){let t="",i=s[e+1];for(;(i===" "||i===" "||i===` `||i==="\r")&&!(i==="\r"&&s[e+2]!==` `);)i===` `&&(t+=` `),e+=1,i=s[e+1];return t||(t=" "),{fold:t,offset:e}}var Sp={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:` `,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function vp(s,e,t,i){let n=s.substr(e,t),o=n.length===t&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;if(isNaN(o)){let a=s.substr(e-2,t+2);return i(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}El.resolveFlowScalar=gp});var Dl=P(Al=>{"use strict";var Pe=L(),Pl=I(),Fp=zn(),Ep=er();function Pp(s,e,t,i){let{value:n,type:r,comment:o,range:a}=e.type==="block-scalar"?Fp.resolveBlockScalar(s,e,i):Ep.resolveFlowScalar(e,s.options.strict,i),l=t?s.directives.tagName(t.source,u=>i(t,"TAG_RESOLVE_FAILED",u)):null,c;s.options.stringKeys&&s.atKey?c=s.schema[Pe.SCALAR]:l?c=Ap(s.schema,n,l,t,i):e.type==="scalar"?c=Dp(s,n,e,i):c=s.schema[Pe.SCALAR];let f;try{let u=c.resolve(n,h=>i(t??e,"TAG_RESOLVE_FAILED",h),s.options);f=Pe.isScalar(u)?u:new Pl.Scalar(u)}catch(u){let h=u instanceof Error?u.message:String(u);i(t??e,"TAG_RESOLVE_FAILED",h),f=new Pl.Scalar(n)}return f.range=a,f.source=n,r&&(f.type=r),l&&(f.tag=l),c.format&&(f.format=c.format),o&&(f.comment=o),f}function Ap(s,e,t,i,n){if(t==="!")return s[Pe.SCALAR];let r=[];for(let a of s.tags)if(!a.collection&&a.tag===t)if(a.default&&a.test)r.push(a);else return a;for(let a of r)if(a.test?.test(e))return a;let o=s.knownTags[t];return o&&!o.collection?(s.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),s[Pe.SCALAR])}function Dp({atKey:s,directives:e,schema:t},i,n,r){let o=t.tags.find(a=>(a.default===!0||s&&a.default==="key")&&a.test?.test(i))||t[Pe.SCALAR];if(t.compat){let a=t.compat.find(l=>l.default&&l.test?.test(i))??t[Pe.SCALAR];if(o.tag!==a.tag){let l=e.tagString(o.tag),c=e.tagString(a.tag),f=`Value may be parsed as either ${l} or ${c}`;r(n,"TAG_RESOLVE_FAILED",f,!0)}}return o}Al.composeScalar=Pp});var Ll=P(Tl=>{"use strict";function Tp(s,e,t){if(e){t===null&&(t=e.length);for(let i=t-1;i>=0;--i){let n=e[i];switch(n.type){case"space":case"comment":case"newline":s-=n.source.length;continue}for(n=e[++i];n?.type==="space";)s+=n.source.length,n=e[++i];break}}return s}Tl.emptyScalarPosition=Tp});var _l=P(ir=>{"use strict";var Lp=tt(),Op=L(),Np=Sl(),Ol=Dl(),_p=je(),Cp=Ll(),Ip={composeNode:Nl,composeEmptyNode:tr};function Nl(s,e,t,i){let n=s.atKey,{spaceBefore:r,comment:o,anchor:a,tag:l}=t,c,f=!0;switch(e.type){case"alias":c=kp(s,e,i),(a||l)&&i(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=Ol.composeScalar(s,e,l,i),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=Np.composeCollection(Ip,s,e,t,i),a&&(c.anchor=a.source.substring(1));break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;i(e,"UNEXPECTED_TOKEN",u),c=tr(s,e.offset,void 0,null,t,i),f=!1}}return a&&c.anchor===""&&i(a,"BAD_ALIAS","Anchor cannot be an empty string"),n&&s.options.stringKeys&&(!Op.isScalar(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&i(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),s.options.keepSourceTokens&&f&&(c.srcToken=e),c}function tr(s,e,t,i,{spaceBefore:n,comment:r,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:Cp.emptyScalarPosition(e,t,i),indent:-1,source:""},u=Ol.composeScalar(s,f,a,c);return o&&(u.anchor=o.source.substring(1),u.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(u.spaceBefore=!0),r&&(u.comment=r,u.range[2]=l),u}function kp({options:s},{offset:e,source:t,end:i},n){let r=new Lp.Alias(t.substring(1));r.source===""&&n(e,"BAD_ALIAS","Alias cannot be an empty string"),r.source.endsWith(":")&&n(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=e+t.length,a=_p.resolveEnd(i,o,s.strict,n);return r.range=[e,o,a.offset],a.comment&&(r.comment=a.comment),r}ir.composeEmptyNode=tr;ir.composeNode=Nl});var kl=P(Il=>{"use strict";var xp=bt(),Cl=_l(),qp=je(),Mp=Ft();function Rp(s,e,{offset:t,start:i,value:n,end:r},o){let a=Object.assign({_directives:e},s),l=new xp.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=Mp.resolveProps(i,{indicator:"doc-start",next:n??r?.[0],offset:t,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(l.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=n?Cl.composeNode(c,n,f,o):Cl.composeEmptyNode(c,f.end,i,null,f,o);let u=l.contents.range[2],h=qp.resolveEnd(r,u,!1,o);return h.comment&&(l.comment=h.comment),l.range=[t,u,h.offset],l}Il.composeDoc=Rp});var nr=P(Ml=>{"use strict";var Bp=require("node:process"),jp=Us(),$p=bt(),Et=vt(),xl=L(),Up=kl(),Kp=je();function Pt(s){if(typeof s=="number")return[s,s+1];if(Array.isArray(s))return s.length===2?s:[s[0],s[1]];let{offset:e,source:t}=s;return[e,e+(typeof t=="string"?t.length:1)]}function ql(s){let e="",t=!1,i=!1;for(let n=0;n<s.length;++n){let r=s[n];switch(r[0]){case"#":e+=(e===""?"":i?` `:` `)+(r.substring(1)||" "),t=!0,i=!1;break;case"%":s[n+1]?.[0]!=="#"&&(n+=1),t=!1;break;default:t||(i=!0),t=!1}}return{comment:e,afterEmptyLine:i}}var sr=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,i,n,r)=>{let o=Pt(t);r?this.warnings.push(new Et.YAMLWarning(o,i,n)):this.errors.push(new Et.YAMLParseError(o,i,n))},this.directives=new jp.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:i,afterEmptyLine:n}=ql(this.prelude);if(i){let r=e.contents;if(t)e.comment=e.comment?`${e.comment} ${i}`:i;else if(n||e.directives.docStart||!r)e.commentBefore=i;else if(xl.isCollection(r)&&!r.flow&&r.items.length>0){let o=r.items[0];xl.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${i} ${a}`:i}else{let o=r.commentBefore;r.commentBefore=o?`${i} ${o}`:i}}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:ql(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,i=-1){for(let n of e)yield*this.next(n);yield*this.end(t,i)}*next(e){switch(Bp.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case"directive":this.directives.add(e.source,(t,i,n)=>{let r=Pt(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",i,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=Up.composeDoc(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":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,i=new Et.YAMLParseError(Pt(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new Et.YAMLParseError(Pt(e),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let t=Kp.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let i=this.doc.comment;this.doc.comment=i?`${i} ${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Et.YAMLParseError(Pt(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){let i=Object.assign({_directives:this.directives},this.options),n=new $p.Document(void 0,i);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,t,t],this.decorate(n,!1),yield n}}};Ml.Composer=sr});var jl=P(ji=>{"use strict";var Vp=zn(),Wp=er(),Hp=vt(),Rl=ot();function Gp(s,e=!0,t){if(s){let i=(n,r,o)=>{let a=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(t)t(a,r,o);else throw new Hp.YAMLParseError([a,a+1],r,o)};switch(s.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Wp.resolveFlowScalar(s,e,i);case"block-scalar":return Vp.resolveBlockScalar({options:{strict:e}},s,i)}}return null}function Yp(s,e){let{implicitKey:t=!1,indent:i,inFlow:n=!1,offset:r=-1,type:o="PLAIN"}=e,a=Rl.stringifyString({type:o,value:s},{implicitKey:t,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),l=e.end??[{type:"newline",offset:-1,indent:i,source:` `}];switch(a[0]){case"|":case">":{let c=a.indexOf(` `),f=a.substring(0,c),u=a.substring(c+1)+` `,h=[{type:"block-scalar-header",offset:r,indent:i,source:f}];return Bl(h,l)||h.push({type:"newline",offset:-1,indent:i,source:` `}),{type:"block-scalar",offset:r,indent:i,props:h,source:u}}case'"':return{type:"double-quoted-scalar",offset:r,indent:i,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:r,indent:i,source:a,end:l};default:return{type:"scalar",offset:r,indent:i,source:a,end:l}}}function Jp(s,e,t={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:r=!1,type:o}=t,a="indent"in s?s.indent:null;if(i&&typeof a=="number"&&(a+=2),!o)switch(s.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=s.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=Rl.stringifyString({type:o,value:e},{implicitKey:n||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":Qp(s,l);break;case'"':rr(s,l,"double-quoted-scalar");break;case"'":rr(s,l,"single-quoted-scalar");break;default:rr(s,l,"scalar")}}function Qp(s,e){let t=e.indexOf(` `),i=e.substring(0,t),n=e.substring(t+1)+` `;if(s.type==="block-scalar"){let r=s.props[0];if(r.type!=="block-scalar-header")throw new Error("Invalid block scalar header");r.source=i,s.source=n}else{let{offset:r}=s,o="indent"in s?s.indent:-1,a=[{type:"block-scalar-header",offset:r,indent:o,source:i}];Bl(a,"end"in s?s.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:` `});for(let l of Object.keys(s))l!=="type"&&l!=="offset"&&delete s[l];Object.assign(s,{type:"block-scalar",indent:o,props:a,source:n})}}function Bl(s,e){if(e)for(let t of e)switch(t.type){case"space":case"comment":s.push(t);break;case"newline":return s.push(t),!0}return!1}function rr(s,e,t){switch(s.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":s.type=t,s.source=e;break;case"block-scalar":{let i=s.props.slice(1),n=e.length;s.props[0].type==="block-scalar-header"&&(n-=s.props[0].source.length);for(let r of i)r.offset+=n;delete s.props,Object.assign(s,{type:t,source:e,end:i});break}case"block-map":case"block-seq":{let n={type:"newline",offset:s.offset+e.length,indent:s.indent,source:` `};delete s.items,Object.assign(s,{type:t,source:e,end:[n]});break}default:{let i="indent"in s?s.indent:-1,n="end"in s&&Array.isArray(s.end)?s.end.filter(r=>r.type==="space"||r.type==="comment"||r.type==="newline"):[];for(let r of Object.keys(s))r!=="type"&&r!=="offset"&&delete s[r];Object.assign(s,{type:t,indent:i,source:e,end:n})}}}ji.createScalarToken=Yp;ji.resolveAsScalar=Gp;ji.setScalarValue=Jp});var Ul=P($l=>{"use strict";var Xp=s=>"type"in s?Ui(s):$i(s);function Ui(s){switch(s.type){case"block-scalar":{let e="";for(let t of s.props)e+=Ui(t);return e+s.source}case"block-map":case"block-seq":{let e="";for(let t of s.items)e+=$i(t);return e}case"flow-collection":{let e=s.start.source;for(let t of s.items)e+=$i(t);for(let t of s.end)e+=t.source;return e}case"document":{let e=$i(s);if(s.end)for(let t of s.end)e+=t.source;return e}default:{let e=s.source;if("end"in s&&s.end)for(let t of s.end)e+=t.source;return e}}}function $i({start:s,key:e,sep:t,value:i}){let n="";for(let r of s)n+=r.source;if(e&&(n+=Ui(e)),t)for(let r of t)n+=r.source;return i&&(n+=Ui(i)),n}$l.stringify=Xp});var Hl=P(Wl=>{"use strict";var or=Symbol("break visit"),zp=Symbol("skip children"),Kl=Symbol("remove item");function Ae(s,e){"type"in s&&s.type==="document"&&(s={start:s.start,value:s.value}),Vl(Object.freeze([]),s,e)}Ae.BREAK=or;Ae.SKIP=zp;Ae.REMOVE=Kl;Ae.itemAtPath=(s,e)=>{let t=s;for(let[i,n]of e){let r=t?.[i];if(r&&"items"in r)t=r.items[n];else return}return t};Ae.parentCollection=(s,e)=>{let t=Ae.itemAtPath(s,e.slice(0,-1)),i=e[e.length-1][0],n=t?.[i];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function Vl(s,e,t){let i=t(e,s);if(typeof i=="symbol")return i;for(let n of["key","value"]){let r=e[n];if(r&&"items"in r){for(let o=0;o<r.items.length;++o){let a=Vl(Object.freeze(s.concat([[n,o]])),r.items[o],t);if(typeof a=="number")o=a-1;else{if(a===or)return or;a===Kl&&(r.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(e,s))}}return typeof i=="function"?i(e,s):i}Wl.visit=Ae});var Ki=P(j=>{"use strict";var ar=jl(),Zp=Ul(),ed=Hl(),lr="\uFEFF",cr="",ur="",fr="",td=s=>!!s&&"items"in s,id=s=>!!s&&(s.type==="scalar"||s.type==="single-quoted-scalar"||s.type==="double-quoted-scalar"||s.type==="block-scalar");function sd(s){switch(s){case lr:return"<BOM>";case cr:return"<DOC>";case ur:return"<FLOW_END>";case fr:return"<SCALAR>";default:return JSON.stringify(s)}}function nd(s){switch(s){case lr:return"byte-order-mark";case cr:return"doc-mode";case ur:return"flow-error-end";case fr:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case` `:case`\r `:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(s[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}j.createScalarToken=ar.createScalarToken;j.resolveAsScalar=ar.resolveAsScalar;j.setScalarValue=ar.setScalarValue;j.stringify=Zp.stringify;j.visit=ed.visit;j.BOM=lr;j.DOCUMENT=cr;j.FLOW_END=ur;j.SCALAR=fr;j.isCollection=td;j.isScalar=id;j.prettyToken=sd;j.tokenType=nd});var dr=P(Yl=>{"use strict";var At=Ki();function Y(s){switch(s){case void 0:case" ":case` `:case"\r":case" ":return!0;default:return!1}}var Gl=new Set("0123456789ABCDEFabcdef"),rd=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Vi=new Set(",[]{}"),od=new Set(` ,[]{} \r `),hr=s=>!s||od.has(s),pr=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,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 i=this.next??"stream";for(;i&&(t||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===" "||t===" ";)t=this.buffer[++e];return!t||t==="#"||t===` `?!0:t==="\r"?this.buffer[e+1]===` `:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let i=0;for(;t===" ";)t=this.buffer[++i+e];if(t==="\r"){let n=this.buffer[i+e+1];if(n===` `||!n&&!this.atEnd)return e+i+1}return t===` `||i>=this.indentNext||!t&&!this.atEnd?e+i:-1}if(t==="-"||t==="."){let i=this.buffer.substr(e,3);if((i==="---"||i==="...")&&Y(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(` `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===At.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,i=e.indexOf("#");for(;i!==-1;){let r=e[i-1];if(r===" "||r===" "){t=i-1;break}else i=e.indexOf("#",i+1)}for(;;){let r=e[t-1];if(r===" "||r===" ")t-=1;else break}let n=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield At.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let t=this.peek(3);if((t==="---"||t==="...")&&Y(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&&!Y(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&Y(t)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let 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(hr),"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,i=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=i=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((i!==-1&&i<this.indentNext&&n[0]!=="#"||i===0&&(n.startsWith("---")||n.startsWith("..."))&&Y(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield At.FLOW_END,yield*this.parseLineStart();let r=0;for(;n[r]===",";)r+=yield*this.pushCount(1),r+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(r+=yield*this.pushIndicators(),n[r]){case void 0:return"flow";case"#":return yield*this.pushCount(n.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(hr),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Y(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),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)}let i=this.buffer.substring(0,t),n=i.indexOf(` `,this.pos);if(n!==-1){for(;n!==-1;){let r=this.continueScalar(n+1);if(r===-1)break;n=i.indexOf(` `,r)}n!==-1&&(t=n-(i[n-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(;;){let 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=>Y(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,i;e:for(let r=this.pos;i=this.buffer[r];++r)switch(i){case" ":t+=1;break;case` `:e=r,t=0;break;case"\r":{let o=this.buffer[r+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===` `)break}default:break e}if(!i&&!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{let r=this.continueScalar(e+1);if(r===-1)break;e=this.buffer.indexOf(` `,r)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;for(i=this.buffer[n];i===" ";)i=this.buffer[++n];if(i===" "){for(;i===" "||i===" "||i==="\r"||i===` `;)i=this.buffer[++n];e=n-1}else if(!this.blockScalarKeep)do{let r=e-1,o=this.buffer[r];o==="\r"&&(o=this.buffer[--r]);let a=r;for(;o===" ";)o=this.buffer[--r];if(o===` `&&r>=this.pos&&r+1+t>a)e=r;else break}while(!0);return yield At.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let r=this.buffer[i+1];if(Y(r)||e&&Vi.has(r))break;t=i}else if(Y(n)){let r=this.buffer[i+1];if(n==="\r"&&(r===` `?(i+=1,n=` `,r=this.buffer[i+1]):t=i),r==="#"||e&&Vi.has(r))break;if(n===` `){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(e&&Vi.has(n))break;t=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield At.SCALAR,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){let i=this.buffer.slice(this.pos,e);return i?(yield i,this.pos+=i.length,i.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(hr))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let e=this.flowLevel>0,t=this.charAt(1);if(Y(t)||e&&Vi.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(;!Y(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(rd.has(t))t=this.buffer[++e];else if(t==="%"&&Gl.has(this.buffer[e+1])&&Gl.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===` `?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===` `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,i;do i=this.buffer[++t];while(i===" "||e&&i===" ");let n=t-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=t),n}*pushUntil(e){let t=this.pos,i=this.buffer[t];for(;!e(i);)i=this.buffer[++t];return yield*this.pushToIndex(t,!1)}};Yl.Lexer=pr});var mr=P(Jl=>{"use strict";var gr=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,i=this.lineStarts.length;for(;t<i;){let r=t+i>>1;this.lineStarts[r]<e?t=r+1:i=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let n=this.lineStarts[t-1];return{line:t,col:e-n+1}}}};Jl.LineCounter=gr});var br=P(ec=>{"use strict";var ad=require("node:process"),Ql=Ki(),ld=dr();function De(s,e){for(let t=0;t<s.length;++t)if(s[t].type===e)return!0;return!1}function Xl(s){for(let e=0;e<s.length;++e)switch(s[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Zl(s){switch(s?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Wi(s){switch(s.type){case"document":return s.start;case"block-map":{let e=s.items[s.items.length-1];return e.sep??e.start}case"block-seq":return s.items[s.items.length-1].start;default:return[]}}function $e(s){if(s.length===0)return[];let e=s.length;e:for(;--e>=0;)switch(s[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;s[++e]?.type==="space";);return s.splice(e,s.length)}function zl(s){if(s.start.type==="flow-seq-start")for(let e of s.items)e.sep&&!e.value&&!De(e.start,"explicit-key-ind")&&!De(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Zl(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)}var yr=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new ld.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let i of this.lexer.lex(e,t))yield*this.next(i);t||(yield*this.end())}*next(e){if(this.source=e,ad.env.LOG_TOKENS&&console.log("|",Ql.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Ql.tokenType(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{let i=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:i,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&(!e||e.type!=="doc-end")){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let 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{let i=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in i?i.indent:0:t.type==="flow-collection"&&i.type==="document"&&(t.indent=0),t.type==="flow-collection"&&zl(t),i.type){case"document":i.value=t;break;case"block-scalar":i.props.push(t);break;case"block-map":{let n=i.items[i.items.length-1];if(n.value){i.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=i.items[i.items.length-1];n.value?i.items.push({start:[],value:t}):n.value=t;break}case"flow-collection":{let n=i.items[i.items.length-1];!n||n.value?i.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&Xl(n.start)===-1&&(t.indent===0||n.start.every(r=>r.type!=="comment"||r.indent<t.indent))&&(i.type==="document"?i.end=n.start:i.items.push({start:n.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":{let 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":{Xl(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}let 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"){let t=Wi(this.peek(2)),i=$e(t),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:i,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(` `)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(` `,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let i="end"in t.value?t.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let i=!this.onKeyLine&&this.indent===e.indent,n=i&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",r=[];if(n&&t.sep&&!t.value){let o=[];for(let a=0;a<t.sep.length;++a){let 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":n||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):n||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(De(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(Zl(t.key)&&!De(t.sep,"newline")){let o=$e(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(De(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let o=$e(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||n?e.items.push({start:r,key:null,sep:[this.sourceToken]}):De(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":{let o=this.flowScalar(this.type);n||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:{let o=this.startBlockValue(e);if(o){i&&o.type!=="block-seq"&&e.items.push({start:r}),this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let i="end"in t.value?t.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,t.start),n.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||De(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let i=this.startBlockValue(e);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i&&i.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":{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let i=this.startBlockValue(e);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===e.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let n=Wi(i),r=$e(n);zl(e);let o=e.end.splice(1,e.end.length);o.push(this.sourceToken);let 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(` `)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(` `,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=Wi(e),i=$e(t);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=Wi(e),i=$e(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};ec.Parser=yr});var rc=P(Tt=>{"use strict";var tc=nr(),cd=bt(),Dt=vt(),ud=tn(),fd=L(),hd=mr(),ic=br();function sc(s){let e=s.prettyErrors!==!1;return{lineCounter:s.lineCounter||e&&new hd.LineCounter||null,prettyErrors:e}}function pd(s,e={}){let{lineCounter:t,prettyErrors:i}=sc(e),n=new ic.Parser(t?.addNewLine),r=new tc.Composer(e),o=Array.from(r.compose(n.parse(s)));if(i&&t)for(let a of o)a.errors.forEach(Dt.prettifyError(s,t)),a.warnings.forEach(Dt.prettifyError(s,t));return o.length>0?o:Object.assign([],{empty:!0},r.streamInfo())}function nc(s,e={}){let{lineCounter:t,prettyErrors:i}=sc(e),n=new ic.Parser(t?.addNewLine),r=new tc.Composer(e),o=null;for(let a of r.compose(n.parse(s),!0,s.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new Dt.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&t&&(o.errors.forEach(Dt.prettifyError(s,t)),o.warnings.forEach(Dt.prettifyError(s,t))),o}function dd(s,e,t){let i;typeof e=="function"?i=e:t===void 0&&e&&typeof e=="object"&&(t=e);let n=nc(s,t);if(!n)return null;if(n.warnings.forEach(r=>ud.warn(n.options.logLevel,r)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:i},t))}function gd(s,e,t){let i=null;if(typeof e=="function"||Array.isArray(e)?i=e:t===void 0&&e&&(t=e),typeof t=="string"&&(t=t.length),typeof t=="number"){let n=Math.round(t);t=n<1?void 0:n>8?{indent:8}:{indent:n}}if(s===void 0){let{keepUndefined:n}=t??e??{};if(!n)return}return fd.isDocument(s)&&!i?s.toString(t):new cd.Document(s,i,t).toString(t)}Tt.parse=dd;Tt.parseAllDocuments=pd;Tt.parseDocument=nc;Tt.stringify=gd});var ac=P(O=>{"use strict";var md=nr(),yd=bt(),bd=Rn(),wr=vt(),wd=tt(),pe=L(),Sd=ce(),vd=I(),Fd=fe(),Ed=he(),Pd=Ki(),Ad=dr(),Dd=mr(),Td=br(),Hi=rc(),oc=Xe();O.Composer=md.Composer;O.Document=yd.Document;O.Schema=bd.Schema;O.YAMLError=wr.YAMLError;O.YAMLParseError=wr.YAMLParseError;O.YAMLWarning=wr.YAMLWarning;O.Alias=wd.Alias;O.isAlias=pe.isAlias;O.isCollection=pe.isCollection;O.isDocument=pe.isDocument;O.isMap=pe.isMap;O.isNode=pe.isNode;O.isPair=pe.isPair;O.isScalar=pe.isScalar;O.isSeq=pe.isSeq;O.Pair=Sd.Pair;O.Scalar=vd.Scalar;O.YAMLMap=Fd.YAMLMap;O.YAMLSeq=Ed.YAMLSeq;O.CST=Pd;O.Lexer=Ad.Lexer;O.LineCounter=Dd.LineCounter;O.Parser=Td.Parser;O.parse=Hi.parse;O.parseAllDocuments=Hi.parseAllDocuments;O.parseDocument=Hi.parseDocument;O.stringify=Hi.stringify;O.visit=oc.visit;O.visitAsync=oc.visitAsync});var xc=require("commander");var Ir=de(require("node:crypto")),D=de(require("node:fs")),ge=de(require("node:os")),T=de(require("node:path")),cs=de(require("node:url"));global.nodeCrypto=Ir.default;var Bt=null;try{let s=T.default.join(__dirname,"btime",process.platform+"-"+process.arch);Bt=require(T.default.join(s,"btime.node")).btime}catch{}function kr(){return Bt!==null}function xr(s,e){if(!Bt)return;let t=Buffer.alloc(Buffer.byteLength(s,"utf-8")+1);t.write(s,0,t.length-1,"utf-8"),t[t.length-1]=0,Bt(t,e)}var us=["image","audio","video","pdf","unsupported"],me=["image","audio","pdf","video"],fs=["app","appearance","appearance-data","hotkey","core-plugin","core-plugin-data","community-plugin","community-plugin-data"],hs=["app","appearance","appearance-data","hotkey","core-plugin","core-plugin-data"];var qr="obsidian-headless",ye=ge.default.platform()==="linux"?T.default.join(process.env.XDG_CONFIG_HOME||T.default.join(ge.default.homedir(),".config"),qr):T.default.join(ge.default.homedir(),"."+qr),Mr="OBSIDIAN_AUTH_TOKEN",ps=T.default.join(ye,"auth_token");function Ve(){if(process.env[Mr])return process.env[Mr];try{return D.default.readFileSync(ps,"utf8")}catch{return null}}function Rr(s){D.default.existsSync(ye)||D.default.mkdirSync(ye,{recursive:!0,mode:448}),D.default.writeFileSync(ps,s,{mode:384})}function ds(){D.default.rmSync(ps,{force:!0})}function We(s){return T.default.join(ye,"sync",s)}function gs(s){return T.default.join(We(s),"state.db")}function Br(s){return T.default.join(We(s),"sync.log")}function jr(s){return T.default.join(We(s),"config.json")}function Gc(s){let e=We(s);return D.default.existsSync(e)||D.default.mkdirSync(e,{recursive:!0,mode:448}),e}function ms(s){let e=jr(s);if(!D.default.existsSync(e))return null;try{let t=D.default.readFileSync(e,"utf-8");return JSON.parse(t)}catch{return null}}function ys(s,e){Gc(s);let t=jr(s);D.default.writeFileSync(t,JSON.stringify(e,null,2),{mode:384})}function $r(s,e){return T.default.join(s,e,".sync.lock")}function Ur(s){let e=We(s);D.default.existsSync(e)&&D.default.rmSync(e,{recursive:!0,force:!0})}function bs(){let s=T.default.join(ye,"sync");if(!D.default.existsSync(s))return[];let e=D.default.readdirSync(s,{withFileTypes:!0}),t=[];for(let i of e)if(i.isDirectory()){let n=T.default.join(s,i.name,"config.json");D.default.existsSync(n)&&t.push(i.name)}return t}function He(s){let e=T.default.resolve(s),t=bs();for(let i of t){let n=ms(i);if(n&&T.default.resolve(n.vaultPath)===e)return n}return null}function Kr(s){let e=s.split(",").map(t=>t.trim().toLowerCase());for(let t of e)if(!us.includes(t))throw new Error(`Invalid file type: "${t}". Valid values: ${us.join(", ")}`);return e}function Vr(s){let e=s.split(",").map(t=>t.trim().toLowerCase());for(let t of e)if(!fs.includes(t))throw new Error(`Invalid config: "${t}". Valid values: ${fs.join(", ")}`);return e}function ws(s){if(s){if(!Ss(s))throw new Error(`Invalid config directory: "${s}". Must be a dotfolder name (e.g. .obsidian).`);return s}}function Ss(s){return s&&s.startsWith(".")&&!s.includes("/")&&!s.includes("\\")}function jt(s){return T.default.join(ye,"publish",s)}function Wr(s){return T.default.join(jt(s),"config.json")}function vs(s){return T.default.join(jt(s),"cache.json")}function Fs(s){let e=jt(s);return D.default.existsSync(e)||D.default.mkdirSync(e,{recursive:!0,mode:448}),e}function Yc(s){let e=Wr(s);if(!D.default.existsSync(e))return null;try{let t=D.default.readFileSync(e,"utf-8");return JSON.parse(t)}catch{return null}}function Es(s,e){Fs(s);let t=Wr(s);D.default.writeFileSync(t,JSON.stringify(e,null,2),{mode:384})}function Hr(s){let e=jt(s);D.default.existsSync(e)&&D.default.rmSync(e,{recursive:!0,force:!0})}function Jc(){let s=T.default.join(ye,"publish");if(!D.default.existsSync(s))return[];let e=D.default.readdirSync(s,{withFileTypes:!0}),t=[];for(let i of e)if(i.isDirectory()){let n=T.default.join(s,i.name,"config.json");D.default.existsSync(n)&&t.push(i.name)}return t}function Ge(s){let e=T.default.resolve(s),t=Jc();for(let i of t){let n=Yc(i);if(n&&T.default.resolve(n.vaultPath)===e)return n}return null}function $t(){let s=ge.default.hostname(),e=ge.default.platform();return`${s} (${e==="darwin"?"macOS":e==="win32"?"Windows":e==="linux"?"Linux":e})`}function Gr(s){let e=T.default.dirname(s);D.default.existsSync(e)||D.default.mkdirSync(e,{recursive:!0});let t=D.default.createWriteStream(s,{flags:"a"}),i=console.log,n=console.warn,r=console.error,o=console.debug;function a(...l){let c=new Date().toISOString(),f=l.map(u=>typeof u=="object"?JSON.stringify(u):String(u)).join(" ");t.write(`[${c}] ${f} `)}return console.log=(...l)=>{i(...l),a(...l)},console.warn=(...l)=>{n(...l),a(...l)},console.error=(...l)=>{r(...l),a(...l)},console.debug=(...l)=>{o(...l),a(...l)},()=>{console.log=i,console.warn=n,console.error=r,console.debug=o,t.end()}}var Ut=fetch,Yr="https://"+["api","obsidian","md"].join("."),Qc="https://publish.obsidian.md",Ye=class s extends Error{constructor(e){super(e.error),this.response=e,this.error=e.error,Object.setPrototypeOf(this,s.prototype)}},Ps="";function Jr(s){Ps=s}async function z(s,e,t){let{preflight:i,headers:n}=t||{};n||(n={}),Ps&&(n["User-Agent"]=Ps),i&&await Ut(Yr+s,{method:"OPTIONS",headers:n}),n["Content-Type"]="application/json";let r=await Ut(Yr+s,{method:"POST",body:JSON.stringify(e),headers:n});if(!r.ok)throw new Error("HTTP Error "+r.status);let o=await r.json();if("error"in o)throw new Ye(o);return o}async function As(s,e,t){return z("/user/signin",{email:s,password:e,mfa:t},{preflight:!0,headers:{Origin:"https://obsidian.md"}})}function Ds(s){return z("/user/signout",{token:s})}function Qr(s){return z("/user/info",{token:s})}function Xr(s,e){return z("/vault/regions",{token:s,host:e})}function Ts(s,e){return z("/vault/list",{token:s,supported_encryption_version:e})}function zr(s,e,t,i,n,r){return z("/vault/create",{token:s,name:e,keyhash:t,salt:i,region:n,encryption_version:r})}function Zr(s,e,t,i,n){return z("/vault/access",{token:s,vault_uid:e,keyhash:t,host:i,encryption_version:n})}function Ls(s){return z("/publish/list",{token:s})}function eo(s){return z("/publish/create",{token:s})}var Kt=class s extends Error{constructor(e,t){super(t),this.name="RequestError",this.code=e,Object.setPrototypeOf(this,s.prototype)}};async function to(s,e,t){let i=await(await Ut(s+e,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"}})).json();if(i.code&&i.message)throw new Kt(i.code,i.message);return i}function io(s){return s.startsWith("127.0.0.1")||s.startsWith("localhost")?"http://"+s:"https://"+s}function so(s,e){return to(Qc,s,e)}function no(s,e,t,i){return so("/api/slug",{token:s,id:e,host:t,slug:i})}function Os(s,e){return so("/api/slugs",{token:s,ids:e})}function Ns(s,e,t){return to(io(s),e,t)}function ro(s,e,t){return Ns(e,"/api/list",{token:s,id:t,version:2})}function _s(s,e,t,i){return Ns(e,"/api/options",{token:s,id:t,options:i})}function oo(s,e,t,i){return Ns(e,"/api/remove",{token:s,id:t,path:i})}async function ao(s,e,t,i,n,r){let o=io(e)+"/api/upload",a=await(await Ut(o,{method:"POST",headers:{"obs-token":s,"obs-id":t,"obs-path":encodeURIComponent(i),"obs-hash":n,"Content-Type":"application/octet-stream"},body:r})).json();if(a.code&&a.message)throw new Kt(a.code,a.message);return a}var lo=["obsidian.css","publish.css","favicon.ico","publish.js"];var Xc=/\u00A0|\u202F/g;function Cs(s){return s.replace(Xc," ")}function W(s){let e=s.lastIndexOf("/");return e===-1?s:s.slice(e+1)}function be(s){let e=s.lastIndexOf("/");return e===-1?"":s.slice(0,e)}function Is(s){for(;s;){if(W(s).startsWith("."))return!0;s=be(s)}return!1}function co(s){let e=W(s),t=e.lastIndexOf(".");return t===-1||t===e.length-1||t===0?e:e.substr(0,t)}function uo(s){let e=s.lastIndexOf(".");return e===-1||e===s.length-1||e===0?s:s.substr(0,e)}function $(s){let e=s.lastIndexOf(".");return e===-1||e===s.length-1||e===0?"":s.substr(e+1).toLowerCase()}function Ne(s){return Cs(_e(s)).normalize("NFC")}function _e(s){return s=s.replace(/([\\/])+/g,"/").replace(/(^\/+|\/+$)/g,""),s===""&&(s="/"),s}var Vt=["bmp","png","jpg","jpeg","gif","svg","webp","avif"],Wt=["mp3","wav","m4a","3gp","flac","ogg","oga","opus"],Ht=["mp4","webm","ogv","mov","mkv"],Gt=["pdf"],fo=["md"],ks=["canvas"],ho=["base"];var hg=fo.concat(ks,ho),zc=[].concat(Vt,Wt,Ht,Gt,fo,ks);function po(s){return zc.includes(s)}var pg=[...Vt,...Wt,...Ht,...Gt,...ho,...ks];function se(s){return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}function xs(s){return Buffer.from(s)}var go=crypto,U=go?.subtle,qs="AES-GCM";function mo(s){return U.importKey("raw",s,qs,!1,["encrypt","decrypt"])}async function Yt(s,e,t){t||(t=go.getRandomValues(new Uint8Array(12)));let i=await U.encrypt({name:qs,iv:t},e,s),n=new ArrayBuffer(t.byteLength+i.byteLength),r=new Uint8Array(n);return r.set(new Uint8Array(t),0),r.set(new Uint8Array(i),t.byteLength),n}async function Jt(s,e){if(s.byteLength<12)throw new Error("Encrypted data is bad");if(s.byteLength===12)return new ArrayBuffer(0);let t=new Uint8Array(s,0,12),i=new Uint8Array(s,12);return await U.decrypt({name:qs,iv:t},e,i)}function Je(s){return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}function K(s){return Je(new TextEncoder().encode(s))}function we(s){return new TextDecoder().decode(new Uint8Array(s))}function yo(s){let e=atob(s),t=e.length,i=new Uint8Array(t);for(let n=0;n<t;n++)i[n]=e.charCodeAt(n);return i.buffer}function bo(s){return Zc(new Uint8Array(s))}function Zc(s){let e=[],t=s.byteLength;for(let i=0;i<t;i++)e.push(String.fromCharCode(s[i]));return btoa(e.join(""))}function Ms(s){let e=s.length/2,t=new ArrayBuffer(e),i=new Uint8Array(t);for(let n=0;n<e;n++)i[n]=parseInt(s.substr(n*2,2),16);return t}function H(s){let e=new Uint8Array(s),t=[];for(let i=0;i<e.length;i++){let n=e[i];t.push((n>>>4).toString(16)),t.push((n&15).toString(16))}return t.join("")}function Rs(s){if(s<=0)return"0 B";let e=["B","KB","MB","GB","TB","PB"],t=e.length-1,i=1024;for(let r=0;r<e.length;r++)if(s<Math.pow(i,r+1)){t=r;break}let n=s/Math.pow(i,t);return`${eu(n,t===0?0:2)} ${e[t]}`}function eu(s,e=2,t=".",i=","){let n=s<0?"-":"";s=Math.abs(s);let r=parseInt(s.toFixed(e),10)+"",o=r.length>3?r.length%3:0;return n+(o?r.substr(0,o)+i:"")+r.substr(o).replace(/(\d{3})(?=\d)/g,"$1"+i)+(e?t+Math.abs(s-Math.floor(s)).toFixed(e).slice(2):"")}async function ne(s){return H(await Qe(s))}async function Qe(s){return U.digest("SHA-256",new Uint8Array(s))}var lc=de(ac()),Gi=class{constructor(e,t){this.cache={};this.token=e,this.config=t,this.loadCache()}async scanForChanges(e){let{config:t,token:i,cache:n}=this,r=[],o=await ro(i,t.host,t.siteId),a={};for(let c of o.files)a[c.path]=c;let l=this.walkLocalFiles();for(let c of l){let f=n[c.path],u,h;if(f&&f.mtime===c.mtime&&f.size===c.size)u=f.publish,h=f.hash;else{let S=T.default.join(t.vaultPath,c.path),d;try{d=D.default.readFileSync(S)}catch{continue}u=T.default.extname(c.path).toLowerCase()===".md"?this.parseFrontmatterPublishFlag(d.toString("utf-8")):null,h=await ne(se(d)),n[c.path]={mtime:c.mtime,size:c.size,hash:h,publish:u}}if(u===null&&(u=this.getFolderPublishFlag(c.path)),u===!1)continue;u===null&&e&&(u=!0);let y=a[c.path];y?(h!==y.hash&&r.push({path:c.path,type:"changed"}),delete a[c.path]):u===!0&&r.push({path:c.path,type:"new"})}for(let c in a)r.push({path:c,type:"deleted"});return this.saveCache(),r}async uploadFile(e){let{config:t,token:i}=this,n=T.default.join(t.vaultPath,e),r=D.default.readFileSync(n);if(r.byteLength>52428800)throw new Error(`File exceeds 50MB upload limit: ${e}`);let o=se(r),a=await ne(o);await ao(i,t.host,t.siteId,e,a,o)}async removeFile(e){let{config:t,token:i}=this;await oo(i,t.host,t.siteId,e)}async publish(e,t){let i=e.length,n=0;for(let r of e)r.type==="new"||r.type==="changed"?await this.uploadFile(r.path):r.type==="deleted"&&await this.removeFile(r.path),n++,t?.(n,i);this.saveCache()}walkLocalFiles(){let{config:e}=this,t=e.vaultPath,i=[],n=r=>{let o;try{o=D.default.readdirSync(T.default.join(t,r),{withFileTypes:!0})}catch{return}for(let a of o){let l=a.name;if(l.startsWith("."))continue;let c=r?r+"/"+l:l;if(a.isDirectory())n(c);else if(a.isFile()&&this.isFileSupported(l,c)){let f;try{f=D.default.statSync(T.default.join(t,c))}catch{continue}i.push({path:c,mtime:f.mtimeMs,size:f.size})}}};return n(""),i}isFileSupported(e,t){if(lo.includes(e))return!0;let i=T.default.extname(t);return i.startsWith(".")&&(i=i.slice(1)),po(i)}getFolderPublishFlag(e){let{config:t}=this;if(t.excludes){for(let i of t.excludes)if(e.startsWith(i+"/"))return!1}if(t.includes){for(let i of t.includes)if(e.startsWith(i+"/"))return!0}return null}parseFrontmatterPublishFlag(e){if(!e.startsWith("---"))return null;let t=e.indexOf(` ---`,3);if(t===-1)return null;let i=e.slice(4,t),n;try{n=(0,lc.parse)(i)}catch{return null}if(!n||typeof n!="object")return null;let r=n.publish;if(r==null)return null;if(typeof r=="string"){let o=r.t … [Строка слишком длинная. Вы можете скачать файл] `),n=0,r=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;for(;n<i.length;){let o=i[n].match(r);if(!o)throw new Error("Invalid patch string: "+i[n]);let a=new Oe;t.push(a),a.start1=parseInt(o[1],10),o[2]===""?(a.start1--,a.length1=1):o[2]==="0"?a.length1=0:(a.start1--,a.length1=parseInt(o[2],10)),a.start2=parseInt(o[3],10),o[4]===""?(a.start2--,a.length2=1):o[4]==="0"?a.length2=0:(a.start2--,a.length2=parseInt(o[4],10)),n++;let l,c,f;for(;n<i.length;){l=i[n].charAt(0),f=i[n].substring(1);try{c=decodeURI(f)}catch{throw new Error("Illegal escape in patch_fromText: "+f)}if(l==="-")a.diffs.push([-1,c]);else if(l==="+")a.diffs.push([1,c]);else if(l===" ")a.diffs.push([0,c]);else{if(l==="@")break;if(l!=="")throw new Error('Invalid patch mode "'+l+'" in: '+c)}n++}}return t}diff_compute_(e,t,i,n){let r;if(!e)return[[1,t]];if(!t)return[[-1,e]];let o=e.length>t.length?e:t,a=e.length>t.length?t:e,l=o.indexOf(a);if(l!==-1)return r=[[1,o.substring(0,l)],[0,a],[1,o.substring(l+a.length)]],e.length>t.length&&(r[0][0]=-1,r[2][0]=-1),r;if(a.length===1)return[[-1,e],[1,t]];let c=this.diff_halfMatch_(e,t);if(c){let f=c[0],u=c[1],h=c[2],y=c[3],S=c[4],d=this.diff_main(f,h,i,n),p=this.diff_main(u,y,i,n);return d.concat([[0,S]],p)}return i&&e.length>100&&t.length>100?this.diff_lineMode_(e,t,n):this.diff_bisect_(e,t,n)}diff_lineMode_(e,t,i){let n=this.diff_linesToChars_(e,t);e=n.chars1,t=n.chars2;let r=n.lineArray,o=this.diff_main(e,t,!1,i);this.diff_charsToLines_(o,r),this.diff_cleanupSemantic(o),o.push([0,""]);let a=0,l=0,c=0,f="",u="";for(;a<o.length;){switch(o[a][0]){case 1:c++,u+=o[a][1];break;case-1:l++,f+=o[a][1];break;case 0:if(l>=1&&c>=1){o.splice(a-l-c,l+c),a=a-l-c;let h=this.diff_main(f,u,!1,i);for(let y=h.length-1;y>=0;y--)o.splice(a,0,h[y]);a=a+h.length}c=0,l=0,f="",u="";break}a++}return o.pop(),o}diff_bisect_(e,t,i){let n=e.length,r=t.length,o=Math.ceil((n+r)/2),a=o,l=2*o,c=new Array(l),f=new Array(l);for(let m=0;m<l;m++)c[m]=-1,f[m]=-1;c[a+1]=0,f[a+1]=0;let u=n-r,h=u%2!==0,y=0,S=0,d=0,p=0;for(let m=0;m<o&&!(Date.now()>i);m++){for(let g=-m+y;g<=m-S;g+=2){let F=a+g,b;g===-m||g!==m&&c[F-1]<c[F+1]?b=c[F+1]:b=c[F-1]+1;let w=b-g;for(;b<n&&w<r&&e.charAt(b)===t.charAt(w);)b++,w++;if(c[F]=b,b>n)S+=2;else if(w>r)y+=2;else if(h){let v=a+u-g;if(v>=0&&v<l&&f[v]!==-1){let A=n-f[v];if(b>=A)return this.diff_bisectSplit_(e,t,b,w,i)}}}for(let g=-m+d;g<=m-p;g+=2){let F=a+g,b;g===-m||g!==m&&f[F-1]<f[F+1]?b=f[F+1]:b=f[F-1]+1;let w=b-g;for(;b<n&&w<r&&e.charAt(n-b-1)===t.charAt(r-w-1);)b++,w++;if(f[F]=b,b>n)p+=2;else if(w>r)d+=2;else if(!h){let v=a+u-g;if(v>=0&&v<l&&c[v]!==-1){let A=c[v],E=a+A-v;if(b=n-b,A>=b)return this.diff_bisectSplit_(e,t,A,E,i)}}}}return[[-1,e],[1,t]]}diff_bisectSplit_(e,t,i,n,r){let o=e.substring(0,i),a=t.substring(0,n),l=e.substring(i),c=t.substring(n),f=this.diff_main(o,a,!1,r),u=this.diff_main(l,c,!1,r);return f.concat(u)}diff_linesToChars_(e,t){let i=[],n={};i[0]="";let r=this.diff_linesToCharsMunge_(e,i,n,4e4),o=this.diff_linesToCharsMunge_(t,i,n,65535);return{chars1:r,chars2:o,lineArray:i}}diff_linesToCharsMunge_(e,t,i,n){let r="",o=0,a=-1,l=t.length;for(;a<e.length-1;){a=e.indexOf(` `,o),a===-1&&(a=e.length-1);let c=e.substring(o,a+1);(i.hasOwnProperty?i.hasOwnProperty(c):i[c]!==void 0)?r+=String.fromCharCode(i[c]):(l===n&&(c=e.substring(o),a=e.length),r+=String.fromCharCode(l),i[c]=l,t[l++]=c),o=a+1}return r}diff_charsToLines_(e,t){for(let i=0;i<e.length;i++){let n=e[i][1],r=[];for(let o=0;o<n.length;o++)r[o]=t[n.charCodeAt(o)];e[i][1]=r.join("")}}diff_commonOverlap_(e,t){let i=e.length,n=t.length;if(i===0||n===0)return 0;i>n?e=e.substring(i-n):i<n&&(t=t.substring(0,i));let r=Te(i,n);if(e===t)return r;let o=0,a=1;for(;;){let l=e.substring(r-a),c=t.indexOf(l);if(c===-1)return o;a+=c,(c===0||e.substring(r-a)===t.substring(0,a))&&(o=a,a++)}}diff_halfMatch_(e,t){if(this.diffTimeout<=0)return null;let i=e.length>t.length?e:t,n=e.length>t.length?t:e;if(i.length<4||n.length*2<i.length)return null;let r=this.diff_halfMatchI_(i,n,Math.ceil(i.length/4)),o=this.diff_halfMatchI_(i,n,Math.ceil(i.length/2)),a;if(!r&&!o)return null;o?r?a=r[4].length>o[4].length?r:o:a=o:a=r;let l,c,f,u,h=a[4];return e.length>t.length?(l=a[0],c=a[1],f=a[2],u=a[3]):(f=a[0],u=a[1],l=a[2],c=a[3]),[l,c,f,u,h]}diff_halfMatchI_(e,t,i){let n=e.substring(i,i+Math.floor(e.length/4)),r="",o,a,l,c,f=t.indexOf(n,0);for(;f!==-1;){let u=this.diff_commonPrefix(e.substring(i),t.substring(f)),h=this.diff_commonSuffix(e.substring(0,i),t.substring(0,f));r.length<h+u&&(r=t.substring(f-h,f)+t.substring(f,f+u),o=e.substring(0,i-h),a=e.substring(i+u),l=t.substring(0,f-h),c=t.substring(f+u)),f=t.indexOf(n,f+1)}return r.length*2>=e.length?[o,a,l,c,r]:null}diff_cleanupSemanticScore_(e,t){if(!e||!t)return 6;let i=e.charAt(e.length-1),n=t.charAt(0),r=i.match(gc),o=n.match(gc),a=r&&i.match(mc),l=o&&n.match(mc),c=a&&i.match(yc),f=l&&n.match(yc),u=c&&e.match(Cd),h=f&&t.match(Id);return u||h?5:c||f?4:r&&!a&&l?3:a||l?2:r||o?1:0}match_bitap_(e,t,i){if(t.length>this.matchMaxBits)throw new Error("Pattern too long for this browser");let n=this.match_alphabet_(t),r=this.matchThreshold,o=e.indexOf(t,i);o!==-1&&(r=Te(this.match_bitapScore_(0,o,t,i),r),o=e.lastIndexOf(t,i+t.length),o!==-1&&(r=Te(this.match_bitapScore_(0,o,t,i),r)));let a=1<<t.length-1;o=-1;let l,c,f=t.length+e.length,u;for(let h=0;h<t.length;h++){for(l=0,c=f;l<c;)this.match_bitapScore_(h,i+c,t,i)<=r?l=c:f=c,c=Math.floor((f-l)/2+l);f=c;let y=Le(1,i-c+1),S=Te(i+c,e.length)+t.length,d=Array(S+2);d[S+1]=(1<<h)-1;for(let p=S;p>=y;p--){let m=n[e.charAt(p-1)];if(h===0?d[p]=(d[p+1]<<1|1)&m:d[p]=(d[p+1]<<1|1)&m|((u[p+1]|u[p])<<1|1)|u[p+1],d[p]&a){let g=this.match_bitapScore_(h,p-1,t,i);if(g<=r)if(r=g,o=p-1,o>i)y=Le(1,2*i-o);else break}}if(this.match_bitapScore_(h+1,i,t,i)>r)break;u=d}return o}match_bitapScore_(e,t,i,n){let r=e/i.length,o=Math.abs(n-t);return this.matchDistance?r+o/this.matchDistance:o?1:r}match_alphabet_(e){let t={};for(let i=0;i<e.length;i++)t[e.charAt(i)]=0;for(let i=0;i<e.length;i++)t[e.charAt(i)]|=1<<e.length-i-1;return t}patch_addContext_(e,t){if(t.length===0)return;if(e.start2==null)throw Error("patch not initialized");let i=t.substring(e.start2,e.start2+e.length1),n=0;for(;t.indexOf(i)!==t.lastIndexOf(i)&&i.length<this.matchMaxBits-this.patchMargin-this.patchMargin;)n+=this.patchMargin,i=t.substring(e.start2-n,e.start2+e.length1+n);n+=this.patchMargin;let r=t.substring(e.start2-n,e.start2);r&&e.diffs.unshift([0,r]);let o=t.substring(e.start2+e.length1,e.start2+e.length1+n);o&&e.diffs.push([0,o]),e.start1-=r.length,e.start2-=r.length,e.length1+=r.length+o.length,e.length2+=r.length+o.length}},Oe=class{constructor(){this.diffs=[];this.start1=0;this.start2=0;this.length1=0;this.length2=0}toString(){let e,t;this.length1===0?e=this.start1+",0":this.length1===1?e=this.start1+1:e=this.start1+1+","+this.length1,this.length2===0?t=this.start2+",0":this.length2===1?t=this.start2+1:t=this.start2+1+","+this.length2;let i=["@@ -"+e+" +"+t+` @@ `],n;for(let r=0;r<this.diffs.length;r++){switch(this.diffs[r][0]){case 1:n="+";break;case-1:n="-";break;case 0:n=" ";break}i[r+1]=n+encodeURI(this.diffs[r][1])+` `}return i.join("").replace(/%20/g," ")}};function bc(s,e,t){let i=new Qi,n=i.diff_main(s,e,!0,0);n.length>2&&(i.diff_cleanupSemantic(n),i.diff_cleanupEfficiency(n));let r=i.patch_make(s,n);return i.p … [Строка слишком длинная. Вы можете скачать файл] Vaults:`);let i=n=>console.log(` ${n.id} "${n.name}" (${n.region})`);for(let n of t.vaults)i(n);if(t.shared.length>0){console.log(` Shared vaults:`);for(let n of t.shared)i(n)}}catch(e){console.error("Failed to list vaults:",e),process.exit(1)}});x.command("sync-list-local").description("List locally configured vaults").option("--json","Output in JSON format").action(s=>{try{let e=bs(),t=[];for(let i of e){let n=ms(i);n&&t.push({id:i,path:n.vaultPath,host:n.host})}if(s.json){R({vaults:t});return}if(e.length===0){console.log("No vaults configured.");return}console.log("Configured vaults:");for(let i of t)console.log(` ${i.id}`),console.log(` Path: ${i.path}`),console.log(` Host: ${i.host}`)}catch(e){console.error("Failed to list vaults:",e),process.exit(1)}});x.command("sync-create-remote").description("Create a new remote vault").requiredOption("--name <name>","Vault name").option("--encryption <standard|end-to-end>","Encryption").option("--password <encryption-password>","End-to-end encryption password (prompt if omitted)").option("--region <region>","Vault region (leave empty for automatic)").action(async s=>{try{let e=te(),t=s.name,i=s.password;!i&&s.encryption!=="standard"&&(i=await Ke("End-to-end encryption password (leave empty for standard encryption): "));let n=s.region||"";if(n){let c=(await Xr(e)).regions;if(!c.some(f=>f.value===n)){console.error(`Invalid region: "${n}". Available regions:`);for(let f of c)console.error(` ${f.value} (${f.name})`);process.exit(1)}}console.log("Creating vault...");let r,o=null;if(i){r=H(crypto.getRandomValues(new Uint8Array(16)));let l=await Or(i,r);o=await Nr(l,r,Tr)}let a=await zr(e,t,o,r,n,Tr);console.log(` Vault created successfully!`),console.log(` Vault ID: ${a.id}`),console.log(` Vault name: ${a.name}`),console.log(` Region: ${a.region}`),console.log(` Encryption: ${i?"end-to-end":"standard"}`),console.log(` Run '${J} sync-setup --vault "${a.id}"' to configure sync.`)}catch(e){console.error("Failed to create vault:",e),process.exit(1)}});x.command("sync-setup").description("Setup sync from a local path to a remote vault").requiredOption("--vault <vault>","Remote vault ID or name").option("--path <local-path>","Local vault path (use current directory if omitted)").option("--password <encryption-password>","End-to-end encryption password (prompted if omitted)").option("--device-name <name>","Device name to identify this client in the sync version history").option("--config-dir <name>","Config directory name (default: .obsidian)").option("--json","Output in JSON format").action(async s=>{try{let e=te(),t=s.vault,i=T.default.resolve(s.path||"."),n=s.password,r=s.deviceName||"",o=ws(s.configDir);s.json||console.log("Fetching vault info...");let a=await Ts(e,Lr),l=[...a.vaults,...a.shared],c=l.find(S=>S.id===t);if(!c){let S=l.filter(d=>d.name===t);if(S.length===1)c=S[0];else if(S.length>1){console.error(`Multiple vaults named "${t}". Use the vault ID instead:`);for(let d of S)console.error(` ${d.id} "${d.name}"`);process.exit(1)}}c||(console.error(`Vault "${t}" not found.`),process.exit(3));let f=c.id;c.password?n=c.password:!n&&!s.json&&(n=await Ke("End-to-end encryption password: ")),n||(console.error("Password not provided."),process.exit(2)),s.json||console.log("Setting up...");let u=await Or(n,c.salt),h=await Nr(u,c.salt,c.encryption_version);try{await Zr(e,f,h,c.host,c.encryption_version)}catch(S){console.error("Failed to validate password.",S),process.exit(2)}let y={vaultId:f,vaultName:c.name,vaultPath:i,host:c.host,encryptionVersion:c.encryption_version,encryptionKey:bo(u),encryptionSalt:c.salt,conflictStrategy:"merge",deviceName:r,configDir:o};if(D.default.existsSync(i)){let d=D.default.readdirSync(i).filter(p=>!p.startsWith("."));!s.json&&d.length>0&&(console.log(` Warning: Your local vault already contains some notes.`),console.log("If you start syncing, notes in your local vault will be merged with notes from your remote vault."),console.log(`In case of conflicts, the most recent version of the note will be preserved. `))}else D.default.mkdirSync(i,{recursive:!0});if(ys(f,y),s.json){R(_r(y));return}Bc(),console.log(` Vault configured successfully!`),ls(y),console.log(` Run '${J} sync' to start syncing.`)}catch(e){console.error("Setup failed:",e),process.exit(1)}});x.command("sync-config").description("Change sync configuration for a vault").option("--path <local-path>","Local vault path (use current directory if omitted)").option("--conflict-strategy <strategy>","Conflict resolution strategy (merge or conflict)").option("--excluded-folders <folders>","Folders to exclude, comma-separated (empty string to clear)").option("--file-types <types>","Attachment types to sync, comma-separated: image, audio, video, pdf, unsupported (empty to clear)").option("--configs <settings>","Config categories to sync, comma-separated: app, appearance, appearance-data, hotkey, core-plugin, core-plugin-data, community-plugin, community-plugin-data (empty to clear)").option("--device-name <name>","Device name to identify this client in the sync version history").option("--mode <mode>","Sync mode: bidirectional (default), pull-only (only download, ignore local changes), or mirror-remote (only download, revert local changes)").option("--config-dir <name>","Config directory name (default: .obsidian)").option("--json","Output in JSON format").action(s=>{try{let e=T.default.resolve(s.path||"."),t=He(e);t||(console.error(`No sync configuration found for ${e}`),console.error(`Run '${J} sync-setup' first.`),process.exit(3));let i=!1;if(s.mode!==void 0&&(s.mode!=="bidirectional"&&s.mode!=="pull-only"&&s.mode!=="mirror-remote"&&(console.error(`Invalid sync mode: "${s.mode}". Must be "bidirectional", "pull-only", or "mirror-remote".`),process.exit(1)),s.mode==="bidirectional"?delete t.syncMode:t.syncMode=s.mode,i=!0),s.conflictStrategy!==void 0&&(s.conflictStrategy!=="merge"&&s.conflictStrategy!=="conflict"&&(console.error(`Invalid conflict strategy: "${s.conflictStrategy}". Must be "merge" or "conflict".`),process.exit(1)),t.conflictStrategy=s.conflictStrategy,i=!0),s.excludedFolders!==void 0&&(ss(t,()=>{s.excludedFolders===""?delete t.ignoreFolders:t.ignoreFolders=s.excludedFolders.split(",").map(n=>n.trim())}),i=!0),s.fileTypes!==void 0&&(ss(t,()=>{s.fileTypes===""?delete t.allowTypes:t.allowTypes=Kr(s.fileTypes)}),i=!0),s.configs!==void 0&&(ss(t,()=>{s.configs===""?delete t.allowSpecialFiles:t.allowSpecialFiles=Vr(s.configs)}),i=!0),s.deviceName!==void 0&&(t.deviceName=s.deviceName,i=!0),s.configDir!==void 0&&(t.configDir=ws(s.configDir),i=!0),i&&ys(t.vaultId,t),s.json){R(_r(t));return}console.log(i?"Configuration updated:":"No options provided. Current configuration:"),ls(t)}catch(e){console.error("Config update failed:",e),process.exit(1)}});x.command("sync-status").description("Show sync status for a vault").option("--path <local-path>","Local vault path (use current directory if omitted)").option("--json","Output in JSON format").action(async s=>{try{let e=T.default.resolve(s.path||"."),t=He(e);if(t||(console.error(`No sync configuration found for ${e}`),process.exit(3)),(!t.encryptionKey||!t.encryptionSalt||t.encryptionVersion==null)&&(console.error("End-to-end encryption key missing. Run setup again."),process.exit(2)),s.json){R(_r(t));return}Ve()||console.log("Not logged in."),console.log("Sync Configuration:"),ls(t)}catch(e){console.error("Status check failed:",e),process.exit(1)}});x.command("sync-unlink").description("Disconnect a vault from sync and remove stored credentials").option("--path <local-path>","Local vault path (use current directory if omitted)").action(async s=>{try{let e=T.default.resolve(s.path||"."),t=He(e);t||(console.error(`No sync configuration found for ${e}`),process.exit(3)),Ur(t.vaultId),console.log(`Sync configuration removed for ${e}`)}catch(e){console.error("Unlink failed:",e),process.exit(1)}});x.command("sync").description("Sync a vault").option("--path <local-path>","Local vault path (use current directory if omitted)").option("--continuous","Run in continuous sync mode").action(async s=>{try{let e=T.default.resolve(s.path||"."),t=He(e);t||(console.error(`No sync configuration found for ${e}`),console.error(`Run '${J} sync-setup' first.`),process.exit(3));let i=te();(!t.encryptionKey||!t.encryptionSalt||t.encryptionVersion==null)&&(console.error("Encryption key not found. Run setup again."),process.exit(2));let n=await kc(t.encryptionVersion,yo(t.encryptionKey),t.encryptionSalt),r=Gr(Br(t.vaultId));t.deviceName||(t.deviceName=$t()),Bc();let o=new os(D.default,T.default,$r(t.vaultPath,Ct(t)));try{o.acquire()}catch{console.error("Another sync instance is already running for this vault."),r(),process.exit(1)}let a;try{a=new is({config:t,token:i,encryption:n,continuous:s.continuous});let l=()=>{console.log(` Received signal to shut down...`),a.stop()};process.on("SIGINT",l),process.on("SIGTERM",l),console.log("Starting sync:"),ls(t),await a.sync()}finally{o.release(),r(),a?.stop()}}catch(e){console.error("Sync failed:",e),process.exit(1)}});function ls(s){console.log(` Vault: ${s.vaultName} (${s.vaultId})`),console.log(` Location: ${s.vaultPath}`),console.log(` Sync mode: ${s.syncMode||"bidirectional"}`),console.log(` Conflict strategy: ${s.conflictStrategy}`),console.log(` Device name: ${s.deviceName||$t()}`),s.configDir&&console.log(` Config directory: ${s.configDir}`);let{allowTypes:e,allowSpecialFiles:t,ignoreFolders:i}=s;console.log(` File types: ${(e||me).join(", ")}`),console.log(` Configs: ${t?.length?(t||[]).join(", "):"none (config syncing disabled)"}`),i&&i.length>0&&console.log(` Excluded folders: ${i.join(", ")}`)}function _r(s){return{vaultId:s.vaultId,vaultName:s.vaultName,vaultPath:s.vaultPath,syncMode:s.syncMode||"bidirectional",conflictStrategy:s.conflictStrategy,deviceName:s.deviceName||$t(),configDir:Ct(s),fileTypes:s.allowTypes||me,configs:s.allowSpecialFiles||[],excludedFolders:s.ignoreFolders||[]}}x.command("publish-list-sites").description("List publish sites").option("--json","Output in JSON format").action(async s=>{try{let e=te();s.json||console.log("Fetching sites...");let t=await Ls(e);if(t.sites.length===0&&t.shared.length===0){s.json?R({sites:[],shared:[]}):console.log("No publish sites found.");return}let i=[...t.sites,...t.shared],n={};try{n=await Os(e,i.map(o=>o.id))}catch{}if(s.json){let o=a=>({id:a.id,host:a.host,slug:n[a.id]||""});R({sites:t.sites.map(o),shared:t.shared.map(o)});return}console.log(` Sites:`);let r=o=>{let a=n[o.id]||"";console.log(` ${o.id} ${a?'"'+a+'"':"(no slug)"}`)};for(let o of t.sites)r(o);if(t.shared.length>0){console.log("Shared sites:");for(let o of t.shared)r(o)}}catch(e){console.error("Failed to list sites:",e),process.exit(1)}});x.command("publish-create-site").description("Create a new Publish site").requiredOption("--slug <slug>","Site slug (URL identifier)").option("--json","Output in JSON format").action(async s=>{try{let e=te();s.json||console.log("Creating site...");let t=await eo(e);if(await no(e,t.id,t.host,s.slug),s.json){R({id:t.id,slug:s.slug,host:t.host});return}console.log(` Site created successfully!`),console.log(` Site ID: ${t.id}`),console.log(` Slug: ${s.slug}`),console.log(` Host: ${t.host}`),console.log(` Run '${J} publish-setup --site "${t.id}"' to connect a vault.`)}catch(e){console.error("Failed to create site:",e),process.exit(1)}});x.command("publish-setup").description("Connect a local vault to a Publish site").requiredOption("--site <id-or-slug>","Site ID or slug").option("--path <local-path>","Local vault path (use current directory if omitted)").option("--json","Output in JSON format").action(async s=>{try{let e=te(),t=T.default.resolve(s.path||"."),i=s.site;s.json||console.log("Fetching sites...");let n=await Ls(e),r=[...n.sites,...n.shared],o=r.find(l=>l.id===i);if(!o){let l={};try{l=await Os(e,r.map(f=>f.id))}catch{}let c=Object.entries(l).find(([,f])=>f===i)?.[0];c&&(o=r.find(f=>f.id===c))}o||(console.error(`Site "${i}" not found.`),process.exit(1));let a={siteId:o.id,host:o.host,vaultPath:t};if(D.default.existsSync(t)||D.default.mkdirSync(t,{recursive:!0}),Es(o.id,a),s.json){R(Rc(a));return}console.log(` Site connected successfully!`),Mc(a),console.log(` Run '${J} publish --dry-run' to preview changes.`)}catch(e){console.error("Setup failed:",e),process.exit(1)}});x.command("publish").description("Publish vault changes to site").option("--path <local-path>","Local vault path (use current directory if omitted)").option("--dry-run","Show changes without publishing").option("--yes","Publish without prompting for confirmation").option("--all","Include files without a publish flag").option("--json","Output in JSON format").action(async s=>{try{let e=T.default.resolve(s.path||"."),t=Ge(e);t||(console.error(`No publish configuration found for ${e}`),console.error(`Run '${J} publish-setup' first.`),process.exit(1));let i=te(),n=new Gi(i,t);s.json||console.log("Scanning for changes...");let r=await n.scanForChanges(s.all);if(r.length===0){s.json?R({changes:[],published:!1}):console.log("No changes to publish.");return}if(!s.json){let l=r.filter(u=>u.type==="new"),c=r.filter(u=>u.type==="changed"),f=r.filter(u=>u.type==="deleted");if(l.length>0){console.log(` New (${l.length}):`);for(let u of l)console.log(` + ${u.path}`)}if(c.length>0){console.log(` Changed (${c.length}):`);for(let u of c)console.log(` ~ ${u.path}`)}if(f.length>0){console.log(` Deleted (${f.length}):`);for(let u of f)console.log(` - ${u.path}`)}console.log(` Total: ${r.length} changes`)}if(s.dryRun){s.json&&R({changes:r,published:!1});return}if(!s.yes){if(s.json){R({changes:r,published:!1}),console.error("This is a dry-run. Use --yes to publish.");return}(await Ke("Publish these changes? (y/N) ",!0)).toLowerCase()!=="y"&&(console.error("Cancelled."),process.exit(1))}s.json||console.log(` Publishing...`);let o=r.length,a=1;for(let l of r)l.type==="new"||l.type==="changed"?(s.json||console.log(`Uploading (${a}/${o}) ${l.path}`),await n.uploadFile(l.path)):l.type==="deleted"&&(s.json||console.log(`Deleting (${a}/${o}) ${l.path}`),await n.removeFile(l.path)),a++;s.json?R({changes:r,published:!0}):console.log(` Done.`)}catch(e){console.error("Publish failed:",e),process.exit(1)}});x.command("publish-config").description("Configure publish settings for a vault").option("--path <local-path>","Local vault path (use current directory if omitted)").option("--includes <folders>","Folders to include, comma-separated (empty string to clear)").option("--excludes <folders>","Folders to exclude, comma-separated (empty string to clear)").option("--json","Output in JSON format").action(s=>{try{let e=T.default.resolve(s.path||"."),t=Ge(e);t||(console.error(`No publish configuration found for ${e}`),console.error(`Run '${J} publish-setup' first.`),process.exit(1));let i=!1;if(s.includes!==void 0&&(s.includes===""?delete t.includes:t.includes=s.includes.split(",").map(n=>n.trim()),i=!0),s.excludes!==void 0&&(s.excludes===""?delete t.excludes:t.excludes=s.excludes.split(",").map(n=>n.trim()),i=!0),i&&Es(t.siteId,t),s.json){R(Rc(t));return}console.log(i?"Configuration updated:":"No options provided. Current configuration:"),Mc(t)}catch(e){console.error("Config update failed:",e),process.exit(1)}});x.command("publish-site-options").description("View or update publish site options").option("--path <local-path>","Local vault path (use current directory if omitted)").option("--site-name <name>","Site name").option("--index-file <path>","Home page file path").option("--logo <path>","Logo file path (empty string to clear)").option("--show-navigation <bool>","Show navigation sidebar").option("--show-graph <bool>","Show graph view").option("--show-outline <bool>","Show table of contents").option("--show-search <bool>","Show search").option("--show-backlinks <bool>","Show backlinks").option("--show-hover-preview <bool>","Show hover preview").option("--show-theme-toggle <bool>","Show theme toggle").option("--default-theme <theme>","Default theme: light or dark").option("--readable-line-length <bool>","Readable line length").option("--strict-line-breaks <bool>","Strict line breaks").option("--hide-title <bool>","Hide inline title").option("--sliding-window <bool>","Sliding window mode").option("--nav-order <paths>","Navigation ordering, comma-separated paths in display order (empty string to clear)").option("--nav-hidden <paths>","Navigation hidden items, comma-separated paths (empty string to clear)").option("--json","Output in JSON format").action(async s=>{try{let e=T.default.resolve(s.path||"."),t=Ge(e);t||(console.error(`No publish configuration found for ${e}`),console.error(`Run '${J} publish-setup' first.`),process.exit(1));let i=te(),n=l=>{let c=l.toLowerCase();if(c==="true"||c==="1"||c==="yes")return!0;if(c==="false"||c==="0"||c==="no")return!1;throw new Error(`Invalid boolean value: "${l}". Use true/false.`)},r={showNavigation:"showNavigation",showGraph:"showGraph",showOutline:"showOutline",showSearch:"showSearch",showBacklinks:"showBacklinks",showHoverPreview:"showHoverPreview",showThemeToggle:"showThemeToggle",readableLineLength:"readableLineLength",strictLineBreaks:"strictLineBreaks",hideTitle:"hideTitle",slidingWindow:"slidingWindowMode"},o={};for(let[l,c]of Object.entries(r))s[l]!==void 0&&(o[c]=n(s[l]));s.siteName!==void 0&&(o.siteName=s.siteName),s.indexFile!==void 0&&(o.indexFile=s.indexFile),s.logo!==void 0&&(o.logo=s.logo),s.defaultTheme!==void 0&&(s.defaultTheme!=="light"&&s.defaultTheme!=="dark"&&(console.error('Invalid theme. Use "light" or "dark".'),process.exit(1)),o.defaultTheme=s.defaultTheme),s.navOrder!==void 0&&(o.navigationOrdering=s.navOrder===""?null:s.navOrder.split(",").map(l=>l.trim())),s.navHidden!==void 0&&(o.navigationHiddenItems=s.navHidden===""?null:s.navHidden.split(",").map(l=>l.trim()));let a;if(Object.keys(o).length>0?(a=await _s(i,t.host,t.siteId,o),s.json||console.log("Site options updated.")):a=await _s(i,t.host,t.siteId),s.json){R(a);return}console.log(` Current site options:`);for(let[l,c]of Object.entries(a))console.log(` ${l}: ${JSON.stringify(c)}`)}catch(e){console.error("Site options failed:",e),process.exit(1)}});x.command("publish-unlink").description("Disconnect a vault from a publish site").option("--path <local-path>","Local vault path (use current directory if omitted)").action(s=>{try{let e=T.default.resolve(s.path||"."),t=Ge(e);t||(console.error(`No publish configuration found for ${e}`),process.exit(1)),Hr(t.siteId),console.log(`Publish configuration removed for ${e}`)}catch(e){console.error("Unlink failed:",e),process.exit(1)}});function Mc(s){console.log(` Site: ${s.siteId}`),console.log(` Host: ${s.host}`),console.log(` Location: ${s.vaultPath}`),s.includes?.length&&console.log(` Includes: ${s.includes.join(", ")}`),s.excludes?.length&&console.log(` Excludes: ${s.excludes.join(", ")}`)}function Rc(s){return{siteId:s.siteId,host:s.host,vaultPath:s.vaultPath,includes:s.includes||[],excludes:s.excludes||[]}}function R(s){console.log(JSON.stringify(s,null,2))}function Ke(s,e){return new Promise(t=>{if(process.stdin.isTTY){process.stdout.write(s),process.stdin.setRawMode(!0),process.stdin.resume();let i="",n=()=>{process.stdout.clearLine(0),process.stdout.cursorTo(0),process.stdout.write(s+(e?i:"*".repeat(i.length)))},r=o=>{let a=o.toString();a===` `||a==="\r"?(process.stdin.setRawMode(!1),process.stdin.pause(),process.stdin.removeListener("data",r),process.stdout.write(` `),t(i)):a===""?(process.stdin.setRawMode(!1),process.exit(1)):a==="\x7F"||a==="\b"?(i=i.slice(0,-1),n()):(i+=a,process.stdout.write(e?a:"*".repeat(a.length)))};process.stdin.on("data",r)}else{let i="";process.stdin.setEncoding("utf-8"),process.stdin.on("data",n=>{i+=n}),process.stdin.on("end",()=>{t(i.trimEnd())}),process.stdin.resume()}})}function Bc(){(process.platform==="win32"||process.platform==="darwin")&&!kr()&&console.warn(` Warning: btime native module failed to load. File creation times will not be preserved. `)}function te(){let s=Ve();return s||(console.error(`No account logged in. Run "${J} login" first.`),process.exit(2)),s}x.parse();