reviewme 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/THIRD_PARTY_NOTICES.md +5 -0
- package/dist/frontend/chunks/{index-yyapw3fj.js → index-09zsbbq4.js} +152 -152
- package/dist/frontend/chunks/index-24nqzty0.css +1 -0
- package/dist/frontend/index.html +1 -1
- package/dist/server/main.js +108 -103
- package/dist/server/main.js.map +6 -6
- package/package.json +1 -1
- package/dist/frontend/chunks/index-v02z1wkv.css +0 -1
package/dist/server/main.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{createRequire as $o}from"node:module";var
|
|
2
|
-
`)}}F.defaultYaml={explicit:!1,version:"1.2"};F.defaultTags={"!!":"tag:yaml.org,2002:"};Ml.Directives=F});var
|
|
1
|
+
import{createRequire as $o}from"node:module";var v=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ot=$o(import.meta.url);var N=v(function(fl){var Cs=Symbol.for("yaml.alias"),Er=Symbol.for("yaml.document"),wt=Symbol.for("yaml.map"),vr=Symbol.for("yaml.pair"),Ns=Symbol.for("yaml.scalar"),bt=Symbol.for("yaml.seq"),Q=Symbol.for("yaml.node.type"),il=(e)=>!!e&&typeof e==="object"&&e[Q]===Cs,ol=(e)=>!!e&&typeof e==="object"&&e[Q]===Er,al=(e)=>!!e&&typeof e==="object"&&e[Q]===wt,ll=(e)=>!!e&&typeof e==="object"&&e[Q]===vr,Tr=(e)=>!!e&&typeof e==="object"&&e[Q]===Ns,cl=(e)=>!!e&&typeof e==="object"&&e[Q]===bt;function Ar(e){if(e&&typeof e==="object")switch(e[Q]){case wt:case bt:return!0}return!1}function dl(e){if(e&&typeof e==="object")switch(e[Q]){case Cs:case wt:case Ns:case bt:return!0}return!1}var ul=(e)=>(Tr(e)||Ar(e))&&!!e.anchor;fl.ALIAS=Cs;fl.DOC=Er;fl.MAP=wt;fl.NODE_TYPE=Q;fl.PAIR=vr;fl.SCALAR=Ns;fl.SEQ=bt;fl.hasAnchor=ul;fl.isAlias=il;fl.isCollection=Ar;fl.isDocument=ol;fl.isMap=al;fl.isNode=dl;fl.isPair=ll;fl.isScalar=Tr;fl.isSeq=cl});var qe=v(function(xl){var P=N(),q=Symbol("break visit"),Rr=Symbol("skip children"),J=Symbol("remove node");function _t(e,t){let s=Cr(t);if(P.isDocument(e)){if(Ae(null,e.contents,s,Object.freeze([e]))===J)e.contents=null}else Ae(null,e,s,Object.freeze([]))}_t.BREAK=q;_t.SKIP=Rr;_t.REMOVE=J;function Ae(e,t,s,n){let r=Nr(e,t,s,n);if(P.isNode(r)||P.isPair(r))return xr(e,n,r),Ae(e,r,s,n);if(typeof r!=="symbol"){if(P.isCollection(t)){n=Object.freeze(n.concat(t));for(let i=0;i<t.items.length;++i){let o=Ae(i,t.items[i],s,n);if(typeof o==="number")i=o-1;else if(o===q)return q;else if(o===J)t.items.splice(i,1),i-=1}}else if(P.isPair(t)){n=Object.freeze(n.concat(t));let i=Ae("key",t.key,s,n);if(i===q)return q;else if(i===J)t.key=null;let o=Ae("value",t.value,s,n);if(o===q)return q;else if(o===J)t.value=null}}return r}async function St(e,t){let s=Cr(t);if(P.isDocument(e)){if(await Re(null,e.contents,s,Object.freeze([e]))===J)e.contents=null}else await Re(null,e,s,Object.freeze([]))}St.BREAK=q;St.SKIP=Rr;St.REMOVE=J;async function Re(e,t,s,n){let r=await Nr(e,t,s,n);if(P.isNode(r)||P.isPair(r))return xr(e,n,r),Re(e,r,s,n);if(typeof r!=="symbol"){if(P.isCollection(t)){n=Object.freeze(n.concat(t));for(let i=0;i<t.items.length;++i){let o=await Re(i,t.items[i],s,n);if(typeof o==="number")i=o-1;else if(o===q)return q;else if(o===J)t.items.splice(i,1),i-=1}}else if(P.isPair(t)){n=Object.freeze(n.concat(t));let i=await Re("key",t.key,s,n);if(i===q)return q;else if(i===J)t.key=null;let o=await Re("value",t.value,s,n);if(o===q)return q;else if(o===J)t.value=null}}return r}function Cr(e){if(typeof e==="object"&&(e.Collection||e.Node||e.Value))return Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e);return e}function Nr(e,t,s,n){if(typeof s==="function")return s(e,t,n);if(P.isMap(t))return s.Map?.(e,t,n);if(P.isSeq(t))return s.Seq?.(e,t,n);if(P.isPair(t))return s.Pair?.(e,t,n);if(P.isScalar(t))return s.Scalar?.(e,t,n);if(P.isAlias(t))return s.Alias?.(e,t,n);return}function xr(e,t,s){let n=t[t.length-1];if(P.isCollection(n))n.items[e]=s;else if(P.isPair(n))if(e==="key")n.key=s;else n.value=s;else if(P.isDocument(n))n.contents=s;else{let r=P.isAlias(n)?"alias":"scalar";throw Error(`Cannot replace node with ${r} parent`)}}xl.visit=_t;xl.visitAsync=St});var xs=v(function(Ml){var Or=N(),kl=qe(),Il={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Pl=(e)=>e.replace(/[!,[\]{}]/g,(t)=>Il[t]);class F{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},F.defaultYaml,e),this.tags=Object.assign({},F.defaultTags,t)}clone(){let e=new F(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new F(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:F.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},F.defaultTags);break}return e}add(e,t){if(this.atNextDocument)this.yaml={explicit:F.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},F.defaultTags),this.atNextDocument=!1;let s=e.trim().split(/[ \t]+/),n=s.shift();switch(n){case"%TAG":{if(s.length!==2){if(t(0,"%TAG directive should contain exactly two parts"),s.length<2)return!1}let[r,i]=s;return this.tags[r]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,s.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[r]=s;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;else{let i=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,i),!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 i=e.slice(2,-1);if(i==="!"||i==="!!")return t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null;if(e[e.length-1]!==">")t("Verbatim tags must end with a >");return i}let[,s,n]=e.match(/^(.*!)([^!]*)$/s);if(!n)t(`The ${e} tag has no suffix`);let r=this.tags[s];if(r)try{return r+decodeURIComponent(n)}catch(i){return t(String(i)),null}if(s==="!")return e;return t(`Could not resolve tag: ${e}`),null}tagString(e){for(let[t,s]of Object.entries(this.tags))if(e.startsWith(s))return t+Pl(e.substring(s.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags),n;if(e&&s.length>0&&Or.isNode(e.contents)){let r={};kl.visit(e.contents,(i,o)=>{if(Or.isNode(o)&&o.tag)r[o.tag]=!0}),n=Object.keys(r)}else n=[];for(let[r,i]of s){if(r==="!!"&&i==="tag:yaml.org,2002:")continue;if(!e||n.some((o)=>o.startsWith(i)))t.push(`%TAG ${r} ${i}`)}return t.join(`
|
|
2
|
+
`)}}F.defaultYaml={explicit:!1,version:"1.2"};F.defaultTags={"!!":"tag:yaml.org,2002:"};Ml.Directives=F});var Et=v(function(Ul){var Lr=N(),ql=qe();function Fl(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let s=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(s)}return!0}function kr(e){let t=new Set;return ql.visit(e,{Value(s,n){if(n.anchor)t.add(n.anchor)}}),t}function Ir(e,t){for(let s=1;;++s){let n=`${e}${s}`;if(!t.has(n))return n}}function $l(e,t){let s=[],n=new Map,r=null;return{onAnchor:(i)=>{s.push(i),r??(r=kr(e));let o=Ir(t,r);return r.add(o),o},setAnchors:()=>{for(let i of s){let o=n.get(i);if(typeof o==="object"&&o.anchor&&(Lr.isScalar(o.node)||Lr.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=Error("Failed to resolve repeated object (this should not happen)");throw a.source=i,a}}},sourceObjects:n}}Ul.anchorIsValid=Fl;Ul.anchorNames=kr;Ul.createNodeAnchors=$l;Ul.findNewAnchor=Ir});var Os=v(function(Hl){function Fe(e,t,s,n){if(n&&typeof n==="object")if(Array.isArray(n))for(let r=0,i=n.length;r<i;++r){let o=n[r],a=Fe(e,n,String(r),o);if(a===void 0)delete n[r];else if(a!==o)n[r]=a}else if(n instanceof Map)for(let r of Array.from(n.keys())){let i=n.get(r),o=Fe(e,n,r,i);if(o===void 0)n.delete(r);else if(o!==i)n.set(r,o)}else if(n instanceof Set)for(let r of Array.from(n)){let i=Fe(e,n,r,r);if(i===void 0)n.delete(r);else if(i!==r)n.delete(r),n.add(i)}else for(let[r,i]of Object.entries(n)){let o=Fe(e,n,r,i);if(o===void 0)delete n[r];else if(o!==i)n[r]=o}return e.call(t,s,n)}Hl.applyReviver=Fe});var ee=v(function(Vl){var Jl=N();function Pr(e,t,s){if(Array.isArray(e))return e.map((n,r)=>Pr(n,String(r),s));if(e&&typeof e.toJSON==="function"){if(!s||!Jl.hasAnchor(e))return e.toJSON(t,s);let n={aliasCount:0,count:1,res:void 0};s.anchors.set(e,n),s.onCreate=(i)=>{n.res=i,delete s.onCreate};let r=e.toJSON(t,s);if(s.onCreate)s.onCreate(r);return r}if(typeof e==="bigint"&&!s?.keep)return Number(e);return e}Vl.toJS=Pr});var vt=v(function(Ql){var Xl=Os(),Mr=N(),zl=ee();class Dr{constructor(e){Object.defineProperty(this,Mr.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));if(this.range)e.range=this.range.slice();return e}toJS(e,{mapAsMap:t,maxAliasCount:s,onAnchor:n,reviver:r}={}){if(!Mr.isDocument(e))throw TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof s==="number"?s:100},o=zl.toJS(this,"",i);if(typeof n==="function")for(let{count:a,res:l}of i.anchors.values())n(l,a);return typeof r==="function"?Xl.applyReviver(r,{"":o},"",o):o}}Ql.NodeBase=Dr});var $e=v(function(rc){var ec=Et(),tc=qe(),Ce=N(),sc=vt(),nc=ee();class qr extends sc.NodeBase{constructor(e){super(Ce.ALIAS);this.source=e,Object.defineProperty(this,"tag",{set(){throw Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError("Alias resolution is disabled");let s;if(t?.aliasResolveCache)s=t.aliasResolveCache;else if(s=[],tc.visit(e,{Node:(r,i)=>{if(Ce.isAlias(i)||Ce.hasAnchor(i))s.push(i)}}),t)t.aliasResolveCache=s;let n=void 0;for(let r of s){if(r===this)break;if(r.anchor===this.source)n=r}return n}toJSON(e,t){if(!t)return{source:this.source};let{anchors:s,doc:n,maxAliasCount:r}=t,i=this.resolve(n,t);if(!i){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(a)}let o=s.get(i);if(!o)nc.toJS(i,null,t),o=s.get(i);if(o?.res===void 0)throw ReferenceError("This should not happen: Alias anchor was not resolved?");if(r>=0){if(o.count+=1,o.aliasCount===0)o.aliasCount=Tt(n,i,s);if(o.count*o.aliasCount>r)throw ReferenceError("Excessive alias count indicates a resource exhaustion attack")}return o.res}toString(e,t,s){let n=`*${this.source}`;if(e){if(ec.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 Error(r)}if(e.implicitKey)return`${n} `}return n}}function Tt(e,t,s){if(Ce.isAlias(t)){let n=t.resolve(e),r=s&&n&&s.get(n);return r?r.count*r.aliasCount:0}else if(Ce.isCollection(t)){let n=0;for(let r of t.items){let i=Tt(e,r,s);if(i>n)n=i}return n}else if(Ce.isPair(t)){let n=Tt(e,t.key,s),r=Tt(e,t.value,s);return Math.max(n,r)}return 1}rc.Alias=qr});var k=v(function(dc){var oc=N(),ac=vt(),lc=ee(),cc=(e)=>!e||typeof e!=="function"&&typeof e!=="object";class he extends ac.NodeBase{constructor(e){super(oc.SCALAR);this.value=e}toJSON(e,t){return t?.keep?this.value:lc.toJS(this.value,e,t)}toString(){return String(this.value)}}he.BLOCK_FOLDED="BLOCK_FOLDED";he.BLOCK_LITERAL="BLOCK_LITERAL";he.PLAIN="PLAIN";he.QUOTE_DOUBLE="QUOTE_DOUBLE";he.QUOTE_SINGLE="QUOTE_SINGLE";dc.Scalar=he;dc.isScalarValue=cc});var Ue=v(function(yc){var hc=$e(),pe=N(),Fr=k(),pc="tag:yaml.org,2002:";function mc(e,t,s){if(t){let n=s.filter((i)=>i.tag===t),r=n.find((i)=>!i.format)??n[0];if(!r)throw Error(`Tag ${t} not found`);return r}return s.find((n)=>n.identify?.(e)&&!n.format)}function gc(e,t,s){if(pe.isDocument(e))e=e.contents;if(pe.isNode(e))return e;if(pe.isPair(e)){let u=s.schema[pe.MAP].createNode?.(s.schema,null,s);return u.items.push(e),u}if(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)e=e.valueOf();let{aliasDuplicateObjects:n,onAnchor:r,onTagObj:i,schema:o,sourceObjects:a}=s,l=void 0;if(n&&e&&typeof e==="object")if(l=a.get(e),l)return l.anchor??(l.anchor=r(e)),new hc.Alias(l.anchor);else l={anchor:null,node:null},a.set(e,l);if(t?.startsWith("!!"))t=pc+t.slice(2);let c=mc(e,t,o.tags);if(!c){if(e&&typeof e.toJSON==="function")e=e.toJSON();if(!e||typeof e!=="object"){let u=new Fr.Scalar(e);if(l)l.node=u;return u}c=e instanceof Map?o[pe.MAP]:(Symbol.iterator in Object(e))?o[pe.SEQ]:o[pe.MAP]}if(i)i(c),delete s.onTagObj;let p=c?.createNode?c.createNode(s.schema,e,s):typeof c?.nodeClass?.from==="function"?c.nodeClass.from(s.schema,e,s):new Fr.Scalar(e);if(t)p.tag=t;else if(!c.default)p.tag=c.tag;if(l)l.node=p;return p}yc.createNode=gc});var At=v(function(Sc){var bc=Ue(),V=N(),_c=vt();function Ls(e,t,s){let n=s;for(let r=t.length-1;r>=0;--r){let i=t[r];if(typeof i==="number"&&Number.isInteger(i)&&i>=0){let o=[];o[i]=n,n=o}else n=new Map([[i,n]])}return bc.createNode(n,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var $r=(e)=>e==null||typeof e==="object"&&!!e[Symbol.iterator]().next().done;class Ur extends _c.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));if(e)t.schema=e;if(t.items=t.items.map((s)=>V.isNode(s)||V.isPair(s)?s.clone(e):s),this.range)t.range=this.range.slice();return t}addIn(e,t){if($r(e))this.add(t);else{let[s,...n]=e,r=this.get(s,!0);if(V.isCollection(r))r.addIn(n,t);else if(r===void 0&&this.schema)this.set(s,Ls(this.schema,n,t));else throw Error(`Expected YAML collection at ${s}. Remaining path: ${n}`)}}deleteIn(e){let[t,...s]=e;if(s.length===0)return this.delete(t);let n=this.get(t,!0);if(V.isCollection(n))return n.deleteIn(s);else throw Error(`Expected YAML collection at ${t}. Remaining path: ${s}`)}getIn(e,t){let[s,...n]=e,r=this.get(s,!0);if(n.length===0)return!t&&V.isScalar(r)?r.value:r;else return V.isCollection(r)?r.getIn(n,t):void 0}hasAllNullValues(e){return this.items.every((t)=>{if(!V.isPair(t))return!1;let s=t.value;return s==null||e&&V.isScalar(s)&&s.value==null&&!s.commentBefore&&!s.comment&&!s.tag})}hasIn(e){let[t,...s]=e;if(s.length===0)return this.has(t);let n=this.get(t,!0);return V.isCollection(n)?n.hasIn(s):!1}setIn(e,t){let[s,...n]=e;if(n.length===0)this.set(s,t);else{let r=this.get(s,!0);if(V.isCollection(r))r.setIn(n,t);else if(r===void 0&&this.schema)this.set(s,Ls(this.schema,n,t));else throw Error(`Expected YAML collection at ${s}. Remaining path: ${n}`)}}}Sc.Collection=Ur;Sc.collectionFromPath=Ls;Sc.isEmptyPath=$r});var Be=v(function(Cc){var Ac=(e)=>e.replace(/^(?!$)(?: $)?/gm,"#");function ks(e,t){if(/^\n+$/.test(e))return e.substring(1);return t?e.replace(/^(?! *$)/gm,t):e}var Rc=(e,t,s)=>e.endsWith(`
|
|
3
3
|
`)?ks(s,t):s.includes(`
|
|
4
4
|
`)?`
|
|
5
|
-
`+ks(s,t):(e.endsWith(" ")?"":" ")+s;Cc.indentComment=ks;Cc.lineComment=Rc;Cc.stringifyComment=Ac});var jr=
|
|
6
|
-
`){if(s==="block")
|
|
7
|
-
`&&
|
|
8
|
-
`&&
|
|
9
|
-
${t}${e.slice(0,
|
|
10
|
-
${t}${e.slice(
|
|
11
|
-
`);n=t,r=t+1,i=e[r]}return n}kc.FOLD_BLOCK="block";kc.FOLD_FLOW="flow";kc.FOLD_QUOTED="quoted";kc.foldFlowLines=Lc});var Ke=
|
|
5
|
+
`+ks(s,t):(e.endsWith(" ")?"":" ")+s;Cc.indentComment=ks;Cc.lineComment=Rc;Cc.stringifyComment=Ac});var jr=v(function(kc){function Lc(e,t,s="flow",{indentAtStart:n,lineWidth:r=80,minContentWidth:i=20,onFold:o,onOverflow:a}={}){if(!r||r<0)return e;if(r<i)i=0;let l=Math.max(1+i,1+r-t.length);if(e.length<=l)return e;let c=[],p={},u=r-t.length;if(typeof n==="number")if(n>r-Math.max(2,i))c.push(0);else u=r-n;let h=void 0,y=void 0,b=!1,d=-1,g=-1,_=-1;if(s==="block"){if(d=Br(e,d,t.length),d!==-1)u=d+l}for(let f;f=e[d+=1];){if(s==="quoted"&&f==="\\"){switch(g=d,e[d+1]){case"x":d+=3;break;case"u":d+=5;break;case"U":d+=9;break;default:d+=1}_=d}if(f===`
|
|
6
|
+
`){if(s==="block")d=Br(e,d,t.length);u=d+t.length+l,h=void 0}else{if(f===" "&&y&&y!==" "&&y!==`
|
|
7
|
+
`&&y!=="\t"){let m=e[d+1];if(m&&m!==" "&&m!==`
|
|
8
|
+
`&&m!=="\t")h=d}if(d>=u)if(h)c.push(h),u=h+l,h=void 0;else if(s==="quoted"){while(y===" "||y==="\t")y=f,f=e[d+=1],b=!0;let m=d>_+1?d-2:g-1;if(p[m])return e;c.push(m),p[m]=!0,u=m+l,h=void 0}else b=!0}y=f}if(b&&a)a();if(c.length===0)return e;if(o)o();let S=e.slice(0,c[0]);for(let f=0;f<c.length;++f){let m=c[f],w=c[f+1]||e.length;if(m===0)S=`
|
|
9
|
+
${t}${e.slice(0,w)}`;else{if(s==="quoted"&&p[m])S+=`${e[m]}\\`;S+=`
|
|
10
|
+
${t}${e.slice(m+1,w)}`}}return S}function Br(e,t,s){let n=t,r=t+1,i=e[r];while(i===" "||i==="\t")if(t<r+s)i=e[++t];else{do i=e[++t];while(i&&i!==`
|
|
11
|
+
`);n=t,r=t+1,i=e[r]}return n}kc.FOLD_BLOCK="block";kc.FOLD_FLOW="flow";kc.FOLD_QUOTED="quoted";kc.foldFlowLines=Lc});var Ke=v(function(Uc){var j=k(),te=jr(),Ct=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Nt=(e)=>/^(%|---|\.\.\.)/m.test(e);function qc(e,t,s){if(!t||t<0)return!1;let n=t-s,r=e.length;if(r<=n)return!1;for(let i=0,o=0;i<r;++i)if(e[i]===`
|
|
12
12
|
`){if(i-o>n)return!0;if(o=i+1,r-o<=n)return!1}return!0}function je(e,t){let s=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return s;let{implicitKey:n}=t,r=t.options.doubleQuotedMinMultiLineLength,i=t.indent||(Nt(e)?" ":""),o="",a=0;for(let l=0,c=s[l];c;c=s[++l]){if(c===" "&&s[l+1]==="\\"&&s[l+2]==="n")o+=s.slice(a,l)+"\\ ",l+=1,a=l,c="\\";if(c==="\\")switch(s[l+1]){case"u":{o+=s.slice(a,l);let p=s.substr(l+2,4);switch(p){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:if(p.substr(0,2)==="00")o+="\\x"+p.substr(2);else o+=s.substr(l,6)}l+=5,a=l+1}break;case"n":if(n||s[l+2]==='"'||s.length<r)l+=1;else{o+=s.slice(a,l)+`
|
|
13
13
|
|
|
14
14
|
`;while(s[l+2]==="\\"&&s[l+3]==="n"&&s[l+4]!=='"')o+=`
|
|
@@ -17,71 +17,71 @@ ${t}${e.slice(b+1,v)}`}}return m}function Br(e,t,s){let n=t,r=t+1,i=e[r];while(i
|
|
|
17
17
|
${s}`)+"'";return t.implicitKey?n:te.foldFlowLines(n,s,te.FOLD_FLOW,Ct(t,!1))}function Ne(e,t){let{singleQuote:s}=t.options,n;if(s===!1)n=je;else{let r=e.includes('"'),i=e.includes("'");if(r&&!i)n=Is;else if(i&&!r)n=je;else n=s?Is:je}return n(e,t)}var Ps;try{Ps=new RegExp(`(^|(?<!
|
|
18
18
|
))
|
|
19
19
|
+(?!
|
|
20
|
-
|$)`,"g")}catch{Ps=/\n+(?!\n|$)/g}function Rt({comment:e,type:t,value:s},n,r,i){let{blockQuote:o,commentString:a,lineWidth:l}=n.options;if(!o||/\n[\t ]+$/.test(s))return Ne(s,n);let c=n.indent||(n.forceBlockIndent||Nt(s)?" ":""),p=o==="literal"?!0:o==="folded"||t===
|
|
20
|
+
|$)`,"g")}catch{Ps=/\n+(?!\n|$)/g}function Rt({comment:e,type:t,value:s},n,r,i){let{blockQuote:o,commentString:a,lineWidth:l}=n.options;if(!o||/\n[\t ]+$/.test(s))return Ne(s,n);let c=n.indent||(n.forceBlockIndent||Nt(s)?" ":""),p=o==="literal"?!0:o==="folded"||t===j.Scalar.BLOCK_FOLDED?!1:t===j.Scalar.BLOCK_LITERAL?!0:!qc(s,l,c.length);if(!s)return p?`|
|
|
21
21
|
`:`>
|
|
22
|
-
`;let
|
|
23
|
-
`&&
|
|
24
|
-
`);if(
|
|
25
|
-
`)
|
|
26
|
-
`)_=
|
|
27
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),
|
|
28
|
-
${c}${
|
|
29
|
-
${c}${
|
|
22
|
+
`;let u,h;for(h=s.length;h>0;--h){let w=s[h-1];if(w!==`
|
|
23
|
+
`&&w!=="\t"&&w!==" ")break}let y=s.substring(h),b=y.indexOf(`
|
|
24
|
+
`);if(b===-1)u="-";else if(s===y||b!==y.length-1){if(u="+",i)i()}else u="";if(y){if(s=s.slice(0,-y.length),y[y.length-1]===`
|
|
25
|
+
`)y=y.slice(0,-1);y=y.replace(Ps,`$&${c}`)}let d=!1,g,_=-1;for(g=0;g<s.length;++g){let w=s[g];if(w===" ")d=!0;else if(w===`
|
|
26
|
+
`)_=g;else break}let S=s.substring(0,_<g?_+1:g);if(S)s=s.substring(S.length),S=S.replace(/\n+/g,`$&${c}`);let m=(d?c?"2":"1":"")+u;if(e){if(m+=" "+a(e.replace(/ ?[\r\n]+/g," ")),r)r()}if(!p){let w=s.replace(/\n+/g,`
|
|
27
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),E=!1,A=Ct(n,!0);if(o!=="folded"&&t!==j.Scalar.BLOCK_FOLDED)A.onOverflow=()=>{E=!0};let T=te.foldFlowLines(`${S}${w}${y}`,c,te.FOLD_BLOCK,A);if(!E)return`>${m}
|
|
28
|
+
${c}${T}`}return s=s.replace(/\n+/g,`$&${c}`),`|${m}
|
|
29
|
+
${c}${S}${s}${y}`}function Fc(e,t,s,n){let{type:r,value:i}=e,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:p}=t;if(a&&i.includes(`
|
|
30
30
|
`)||p&&/[[\]{},]/.test(i))return Ne(i,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(i))return a||p||!i.includes(`
|
|
31
|
-
`)?Ne(i,t):Rt(e,t,s,n);if(!a&&!p&&r!==
|
|
32
|
-
`))return Rt(e,t,s,n);if(Nt(i)){if(l==="")return t.forceBlockIndent=!0,Rt(e,t,s,n);else if(a&&l===c)return Ne(i,t)}let
|
|
33
|
-
${l}`);if(o){let
|
|
34
|
-
${t.indent}${a}`}Gc.createStringifyContext=Hc;Gc.stringify=Vc});var Hr=
|
|
35
|
-
${a}:`}else if(
|
|
36
|
-
`:"",
|
|
37
|
-
${He.indentComment(
|
|
38
|
-
`&&
|
|
31
|
+
`)?Ne(i,t):Rt(e,t,s,n);if(!a&&!p&&r!==j.Scalar.PLAIN&&i.includes(`
|
|
32
|
+
`))return Rt(e,t,s,n);if(Nt(i)){if(l==="")return t.forceBlockIndent=!0,Rt(e,t,s,n);else if(a&&l===c)return Ne(i,t)}let u=i.replace(/\n+/g,`$&
|
|
33
|
+
${l}`);if(o){let h=(d)=>d.default&&d.tag!=="tag:yaml.org,2002:str"&&d.test?.test(u),{compat:y,tags:b}=t.doc.schema;if(b.some(h)||y?.some(h))return Ne(i,t)}return a?u:te.foldFlowLines(u,l,te.FOLD_FLOW,Ct(t,!1))}function $c(e,t,s,n){let{implicitKey:r,inFlow:i}=t,o=typeof e.value==="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;if(a!==j.Scalar.QUOTE_DOUBLE){if(/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value))a=j.Scalar.QUOTE_DOUBLE}let l=(p)=>{switch(p){case j.Scalar.BLOCK_FOLDED:case j.Scalar.BLOCK_LITERAL:return r||i?Ne(o.value,t):Rt(o,t,s,n);case j.Scalar.QUOTE_DOUBLE:return je(o.value,t);case j.Scalar.QUOTE_SINGLE:return Is(o.value,t);case j.Scalar.PLAIN:return Fc(o,t,s,n);default:return null}},c=l(a);if(c===null){let{defaultKeyType:p,defaultStringType:u}=t.options,h=r&&p||u;if(c=l(h),c===null)throw Error(`Unsupported default string type ${h}`)}return c}Uc.stringifyString=$c});var We=v(function(Gc){var jc=Et(),se=N(),Kc=Be(),Wc=Ke();function Hc(e,t){let s=Object.assign({blockQuote:!0,commentString:Kc.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,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),n;switch(s.collectionStyle){case"block":n=!1;break;case"flow":n=!0;break;default:n=null}return{anchors:new Set,doc:e,flowCollectionPadding:s.flowCollectionPadding?" ":"",indent:"",indentStep:typeof s.indent==="number"?" ".repeat(s.indent):" ",inFlow:n,options:s}}function Yc(e,t){if(t.tag){let r=e.filter((i)=>i.tag===t.tag);if(r.length>0)return r.find((i)=>i.format===t.format)??r[0]}let s=void 0,n;if(se.isScalar(t)){n=t.value;let r=e.filter((i)=>i.identify?.(n));if(r.length>1){let i=r.filter((o)=>o.test);if(i.length>0)r=i}s=r.find((i)=>i.format===t.format)??r.find((i)=>!i.format)}else n=t,s=e.find((r)=>r.nodeClass&&n instanceof r.nodeClass);if(!s){let r=n?.constructor?.name??(n===null?"null":typeof n);throw Error(`Tag not resolved for ${r} value`)}return s}function Jc(e,t,{anchors:s,doc:n}){if(!n.directives)return"";let r=[],i=(se.isScalar(e)||se.isCollection(e))&&e.anchor;if(i&&jc.anchorIsValid(i))s.add(i),r.push(`&${i}`);let o=e.tag??(t.default?null:t.tag);if(o)r.push(n.directives.tagString(o));return r.join(" ")}function Vc(e,t,s,n){if(se.isPair(e))return e.toString(t,s,n);if(se.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError("Cannot stringify circular structure without alias nodes");else{if(t.resolvedAliases)t.resolvedAliases.add(e);else t.resolvedAliases=new Set([e]);e=e.resolve(t.doc)}}let r=void 0,i=se.isNode(e)?e:t.doc.createNode(e,{onTagObj:(l)=>r=l});r??(r=Yc(t.doc.schema.tags,i));let o=Jc(i,r,t);if(o.length>0)t.indentAtStart=(t.indentAtStart??0)+o.length+1;let a=typeof r.stringify==="function"?r.stringify(i,t,s,n):se.isScalar(i)?Wc.stringifyString(i,t,s,n):i.toString(t,s,n);if(!o)return a;return se.isScalar(i)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
34
|
+
${t.indent}${a}`}Gc.createStringifyContext=Hc;Gc.stringify=Vc});var Hr=v(function(Zc){var Z=N(),Kr=k(),Wr=We(),He=Be();function Qc({key:e,value:t},s,n,r){let{allNullValues:i,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:p,simpleKeys:u}}=s,h=Z.isNode(e)&&e.comment||null;if(u){if(h)throw Error("With simple keys, key nodes cannot have comments");if(Z.isCollection(e)||!Z.isNode(e)&&typeof e==="object")throw Error("With simple keys, collection cannot be used as a key value")}let y=!u&&(!e||h&&t==null&&!s.inFlow||Z.isCollection(e)||(Z.isScalar(e)?e.type===Kr.Scalar.BLOCK_FOLDED||e.type===Kr.Scalar.BLOCK_LITERAL:typeof e==="object"));s=Object.assign({},s,{allNullValues:!1,implicitKey:!y&&(u||!i),indent:a+l});let b=!1,d=!1,g=Wr.stringify(e,s,()=>b=!0,()=>d=!0);if(!y&&!s.inFlow&&g.length>1024){if(u)throw Error("With simple keys, single line scalar must not span more than 1024 characters");y=!0}if(s.inFlow){if(i||t==null){if(b&&n)n();return g===""?"?":y?`? ${g}`:g}}else if(i&&!u||t==null&&y){if(g=`? ${g}`,h&&!b)g+=He.lineComment(g,s.indent,c(h));else if(d&&r)r();return g}if(b)h=null;if(y){if(h)g+=He.lineComment(g,s.indent,c(h));g=`? ${g}
|
|
35
|
+
${a}:`}else if(g=`${g}:`,h)g+=He.lineComment(g,s.indent,c(h));let _,S,f;if(Z.isNode(t))_=!!t.spaceBefore,S=t.commentBefore,f=t.comment;else if(_=!1,S=null,f=null,t&&typeof t==="object")t=o.createNode(t);if(s.implicitKey=!1,!y&&!h&&Z.isScalar(t))s.indentAtStart=g.length+1;if(d=!1,!p&&l.length>=2&&!s.inFlow&&!y&&Z.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor)s.indent=s.indent.substring(2);let m=!1,w=Wr.stringify(t,s,()=>m=!0,()=>d=!0),E=" ";if(h||_||S){if(E=_?`
|
|
36
|
+
`:"",S){let A=c(S);E+=`
|
|
37
|
+
${He.indentComment(A,s.indent)}`}if(w===""&&!s.inFlow){if(E===`
|
|
38
|
+
`&&f)E=`
|
|
39
39
|
|
|
40
|
-
`}else
|
|
41
|
-
${s.indent}`}else if(!
|
|
42
|
-
`),x=
|
|
43
|
-
${s.indent}`}}else if(
|
|
44
|
-
`)
|
|
45
|
-
${l}${
|
|
46
|
-
`}}if(e){if(
|
|
47
|
-
`+Mt.indentComment(c(e),l),a)a()}else if(
|
|
48
|
-
`)),
|
|
49
|
-
${i}${r}${
|
|
50
|
-
`;return`${
|
|
51
|
-
${r}${
|
|
52
|
-
`:" ")}return $u.stringifyString({comment:e,type:t,value:a},n,r,i)}};Bu.binary=Uu});var Wt=
|
|
40
|
+
`}else E+=`
|
|
41
|
+
${s.indent}`}else if(!y&&Z.isCollection(t)){let A=w[0],T=w.indexOf(`
|
|
42
|
+
`),x=T!==-1,W=s.inFlow??t.flow??t.items.length===0;if(x||!W){let _e=!1;if(x&&(A==="&"||A==="!")){let I=w.indexOf(" ");if(A==="&"&&I!==-1&&I<T&&w[I+1]==="!")I=w.indexOf(" ",I+1);if(I===-1||T<I)_e=!0}if(!_e)E=`
|
|
43
|
+
${s.indent}`}}else if(w===""||w[0]===`
|
|
44
|
+
`)E="";if(g+=E+w,s.inFlow){if(m&&n)n()}else if(f&&!m)g+=He.lineComment(g,s.indent,c(f));else if(d&&r)r();return g}Zc.stringifyPair=Qc});var Ms=v(function(nd){var Yr=ot("process");function td(e,...t){if(e==="debug")console.log(...t)}function sd(e,t){if(e==="debug"||e==="warn")if(typeof Yr.emitWarning==="function")Yr.emitWarning(t);else console.warn(t)}nd.debug=td;nd.warn=sd});var kt=v(function(ad){var Lt=N(),Jr=k(),xt="<<",Ot={identify:(e)=>e===xt||typeof e==="symbol"&&e.description===xt,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Jr.Scalar(Symbol(xt)),{addToJSMap:Vr}),stringify:()=>xt},od=(e,t)=>(Ot.identify(t)||Lt.isScalar(t)&&(!t.type||t.type===Jr.Scalar.PLAIN)&&Ot.identify(t.value))&&e?.doc.schema.tags.some((s)=>s.tag===Ot.tag&&s.default);function Vr(e,t,s){let n=Gr(e,s);if(Lt.isSeq(n))for(let r of n.items)Ds(e,t,r);else if(Array.isArray(n))for(let r of n)Ds(e,t,r);else Ds(e,t,n)}function Ds(e,t,s){let n=Gr(e,s);if(!Lt.isMap(n))throw Error("Merge sources must be maps or map aliases");let r=n.toJSON(null,e,Map);for(let[i,o]of r)if(t instanceof Map){if(!t.has(i))t.set(i,o)}else if(t instanceof Set)t.add(i);else if(!Object.prototype.hasOwnProperty.call(t,i))Object.defineProperty(t,i,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function Gr(e,t){return e&&Lt.isAlias(t)?t.resolve(e.doc,e):t}ad.addMergeToJSMap=Vr;ad.isMergeKey=od;ad.merge=Ot});var Fs=v(function(md){var ud=Ms(),Xr=kt(),fd=We(),zr=N(),qs=ee();function hd(e,t,{key:s,value:n}){if(zr.isNode(s)&&s.addToJSMap)s.addToJSMap(e,t,n);else if(Xr.isMergeKey(e,s))Xr.addMergeToJSMap(e,t,n);else{let r=qs.toJS(s,"",e);if(t instanceof Map)t.set(r,qs.toJS(n,r,e));else if(t instanceof Set)t.add(r);else{let i=pd(s,r,e),o=qs.toJS(n,i,e);if(i in t)Object.defineProperty(t,i,{value:o,writable:!0,enumerable:!0,configurable:!0});else t[i]=o}}return t}function pd(e,t,s){if(t===null)return"";if(typeof t!=="object")return String(t);if(zr.isNode(e)&&s?.doc){let n=fd.createStringifyContext(s.doc,{});n.anchors=new Set;for(let i of s.anchors.keys())n.anchors.add(i.anchor);n.inFlow=!0,n.inStringifyKey=!0;let r=e.toString(n);if(!s.mapKeyWarned){let i=JSON.stringify(r);if(i.length>40)i=i.substring(0,36)+'..."';ud.warn(s.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${i}. Set mapAsMap: true to use object keys.`),s.mapKeyWarned=!0}return r}return JSON.stringify(t)}md.addPairToJSMap=hd});var ne=v(function(_d){var Qr=Ue(),yd=Hr(),wd=Fs(),It=N();function bd(e,t,s){let n=Qr.createNode(e,void 0,s),r=Qr.createNode(t,void 0,s);return new Pt(n,r)}class Pt{constructor(e,t=null){Object.defineProperty(this,It.NODE_TYPE,{value:It.PAIR}),this.key=e,this.value=t}clone(e){let{key:t,value:s}=this;if(It.isNode(t))t=t.clone(e);if(It.isNode(s))s=s.clone(e);return new Pt(t,s)}toJSON(e,t){let s=t?.mapAsMap?new Map:{};return wd.addPairToJSMap(t,s,this)}toString(e,t,s){return e?.doc?yd.stringifyPair(this,e,t,s):JSON.stringify(this)}}_d.Pair=Pt;_d.createPair=bd});var $s=v(function(Rd){var me=N(),Zr=We(),Mt=Be();function vd(e,t,s){return(t.inFlow??e.flow?Ad:Td)(e,t,s)}function Td({comment:e,items:t},s,{blockItemPrefix:n,flowChars:r,itemIndent:i,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=s,p=Object.assign({},s,{indent:i,type:null}),u=!1,h=[];for(let b=0;b<t.length;++b){let d=t[b],g=null;if(me.isNode(d)){if(!u&&d.spaceBefore)h.push("");if(Dt(s,h,d.commentBefore,u),d.comment)g=d.comment}else if(me.isPair(d)){let S=me.isNode(d.key)?d.key:null;if(S){if(!u&&S.spaceBefore)h.push("");Dt(s,h,S.commentBefore,u)}}u=!1;let _=Zr.stringify(d,p,()=>g=null,()=>u=!0);if(g)_+=Mt.lineComment(_,i,c(g));if(u&&g)u=!1;h.push(n+_)}let y;if(h.length===0)y=r.start+r.end;else{y=h[0];for(let b=1;b<h.length;++b){let d=h[b];y+=d?`
|
|
45
|
+
${l}${d}`:`
|
|
46
|
+
`}}if(e){if(y+=`
|
|
47
|
+
`+Mt.indentComment(c(e),l),a)a()}else if(u&&o)o();return y}function Ad({items:e},t,{flowChars:s,itemIndent:n}){let{indent:r,indentStep:i,flowCollectionPadding:o,options:{commentString:a}}=t;n+=i;let l=Object.assign({},t,{indent:n,inFlow:!0,type:null}),c=!1,p=0,u=[];for(let b=0;b<e.length;++b){let d=e[b],g=null;if(me.isNode(d)){if(d.spaceBefore)u.push("");if(Dt(t,u,d.commentBefore,!1),d.comment)g=d.comment}else if(me.isPair(d)){let S=me.isNode(d.key)?d.key:null;if(S){if(S.spaceBefore)u.push("");if(Dt(t,u,S.commentBefore,!1),S.comment)c=!0}let f=me.isNode(d.value)?d.value:null;if(f){if(f.comment)g=f.comment;if(f.commentBefore)c=!0}else if(d.value==null&&S?.comment)g=S.comment}if(g)c=!0;let _=Zr.stringify(d,l,()=>g=null);if(c||(c=u.length>p||_.includes(`
|
|
48
|
+
`)),b<e.length-1)_+=",";else if(t.options.trailingComma){if(t.options.lineWidth>0)c||(c=u.reduce((S,f)=>S+f.length+2,2)+(_.length+2)>t.options.lineWidth);if(c)_+=","}if(g)_+=Mt.lineComment(_,n,a(g));u.push(_),p=u.length}let{start:h,end:y}=s;if(u.length===0)return h+y;else{if(!c){let b=u.reduce((d,g)=>d+g.length+2,2);c=t.options.lineWidth>0&&b>t.options.lineWidth}if(c){let b=h;for(let d of u)b+=d?`
|
|
49
|
+
${i}${r}${d}`:`
|
|
50
|
+
`;return`${b}
|
|
51
|
+
${r}${y}`}else return`${h}${o}${u.join(" ")}${o}${y}`}}function Dt({indent:e,options:{commentString:t}},s,n,r){if(n&&r)n=n.replace(/^\n+/,"");if(n){let i=Mt.indentComment(t(n),e);s.push(i.trimStart())}}Rd.stringifyCollection=vd});var ie=v(function(kd){var Nd=$s(),xd=Fs(),Od=At(),re=N(),qt=ne(),Ld=k();function Ye(e,t){let s=re.isScalar(t)?t.value:t;for(let n of e)if(re.isPair(n)){if(n.key===t||n.key===s)return n;if(re.isScalar(n.key)&&n.key.value===s)return n}return}class ei extends Od.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(re.MAP,e);this.items=[]}static from(e,t,s){let{keepUndefined:n,replacer:r}=s,i=new this(e),o=(a,l)=>{if(typeof r==="function")l=r.call(t,a,l);else if(Array.isArray(r)&&!r.includes(a))return;if(l!==void 0||n)i.items.push(qt.createPair(a,l,s))};if(t instanceof Map)for(let[a,l]of t)o(a,l);else if(t&&typeof t==="object")for(let a of Object.keys(t))o(a,t[a]);if(typeof e.sortMapEntries==="function")i.items.sort(e.sortMapEntries);return i}add(e,t){let s;if(re.isPair(e))s=e;else if(!e||typeof e!=="object"||!("key"in e))s=new qt.Pair(e,e?.value);else s=new qt.Pair(e.key,e.value);let n=Ye(this.items,s.key),r=this.schema?.sortMapEntries;if(n){if(!t)throw Error(`Key ${s.key} already set`);if(re.isScalar(n.value)&&Ld.isScalarValue(s.value))n.value.value=s.value;else n.value=s.value}else if(r){let i=this.items.findIndex((o)=>r(s,o)<0);if(i===-1)this.items.push(s);else this.items.splice(i,0,s)}else this.items.push(s)}delete(e){let t=Ye(this.items,e);if(!t)return!1;return this.items.splice(this.items.indexOf(t),1).length>0}get(e,t){let n=Ye(this.items,e)?.value;return(!t&&re.isScalar(n)?n.value:n)??void 0}has(e){return!!Ye(this.items,e)}set(e,t){this.add(new qt.Pair(e,t),!0)}toJSON(e,t,s){let n=s?new s:t?.mapAsMap?new Map:{};if(t?.onCreate)t.onCreate(n);for(let r of this.items)xd.addPairToJSMap(t,n,r);return n}toString(e,t,s){if(!e)return JSON.stringify(this);for(let n of this.items)if(!re.isPair(n))throw Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);if(!e.allNullValues&&this.hasAllNullValues(!1))e=Object.assign({},e,{allNullValues:!0});return Nd.stringifyCollection(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:t})}}kd.YAMLMap=ei;kd.findPair=Ye});var xe=v(function(qd){var Md=N(),ti=ie(),Dd={collection:"map",default:!0,nodeClass:ti.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){if(!Md.isMap(e))t("Expected a mapping for this tag");return e},createNode:(e,t,s)=>ti.YAMLMap.from(e,t,s)};qd.map=Dd});var oe=v(function(Wd){var $d=Ue(),Ud=$s(),Bd=At(),$t=N(),jd=k(),Kd=ee();class si extends Bd.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super($t.SEQ,e);this.items=[]}add(e){this.items.push(e)}delete(e){let t=Ft(e);if(typeof t!=="number")return!1;return this.items.splice(t,1).length>0}get(e,t){let s=Ft(e);if(typeof s!=="number")return;let n=this.items[s];return!t&&$t.isScalar(n)?n.value:n}has(e){let t=Ft(e);return typeof t==="number"&&t<this.items.length}set(e,t){let s=Ft(e);if(typeof s!=="number")throw Error(`Expected a valid index, not ${e}.`);let n=this.items[s];if($t.isScalar(n)&&jd.isScalarValue(t))n.value=t;else this.items[s]=t}toJSON(e,t){let s=[];if(t?.onCreate)t.onCreate(s);let n=0;for(let r of this.items)s.push(Kd.toJS(r,String(n++),t));return s}toString(e,t,s){if(!e)return JSON.stringify(this);return Ud.stringifyCollection(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:s,onComment:t})}static from(e,t,s){let{replacer:n}=s,r=new this(e);if(t&&Symbol.iterator in Object(t)){let i=0;for(let o of t){if(typeof n==="function"){let a=t instanceof Set?o:String(i++);o=n.call(t,a,o)}r.items.push($d.createNode(o,void 0,s))}}return r}}function Ft(e){let t=$t.isScalar(e)?e.value:e;if(t&&typeof t==="string")t=Number(t);return typeof t==="number"&&Number.isInteger(t)&&t>=0?t:null}Wd.YAMLSeq=si});var Oe=v(function(Vd){var Yd=N(),ni=oe(),Jd={collection:"seq",default:!0,nodeClass:ni.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){if(!Yd.isSeq(e))t("Expected a sequence for this tag");return e},createNode:(e,t,s)=>ni.YAMLSeq.from(e,t,s)};Vd.seq=Jd});var Je=v(function(Qd){var Xd=Ke(),zd={identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify(e,t,s,n){return t=Object.assign({actualString:!0},t),Xd.stringifyString(e,t,s,n)}};Qd.string=zd});var Ut=v(function(eu){var ri=k(),ii={identify:(e)=>e==null,createNode:()=>new ri.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new ri.Scalar(null),stringify:({source:e},t)=>typeof e==="string"&&ii.test.test(e)?e:t.options.nullStr};eu.nullTag=ii});var Us=v(function(nu){var su=k(),oi={identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:(e)=>new su.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},s){if(e&&oi.test.test(e)){let n=e[0]==="t"||e[0]==="T";if(t===n)return e}return t?s.options.trueStr:s.options.falseStr}};nu.boolTag=oi});var Le=v(function(ou){function iu({format:e,minFractionDigits:t,tag:s,value:n}){if(typeof n==="bigint")return String(n);let r=typeof n==="number"?n:Number(n);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let i=Object.is(n,-0)?"-0":JSON.stringify(n);if(!e&&t&&(!s||s==="tag:yaml.org,2002:float")&&/^-?\d/.test(i)&&!i.includes("e")){let o=i.indexOf(".");if(o<0)o=i.length,i+=".";let a=t-(i.length-o-1);while(a-- >0)i+="0"}return i}ou.stringifyNumber=iu});var js=v(function(fu){var lu=k(),Bs=Le(),cu={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Bs.stringifyNumber},du={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Bs.stringifyNumber(e)}},uu={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new lu.Scalar(parseFloat(e)),s=e.indexOf(".");if(s!==-1&&e[e.length-1]==="0")t.minFractionDigits=e.length-s-1;return t},stringify:Bs.stringifyNumber};fu.float=uu;fu.floatExp=du;fu.floatNaN=cu});var Ws=v(function(bu){var ai=Le(),Bt=(e)=>typeof e==="bigint"||Number.isInteger(e),Ks=(e,t,s,{intAsBigInt:n})=>n?BigInt(e):parseInt(e.substring(t),s);function li(e,t,s){let{value:n}=e;if(Bt(n)&&n>=0)return s+n.toString(t);return ai.stringifyNumber(e)}var gu={identify:(e)=>Bt(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,s)=>Ks(e,2,8,s),stringify:(e)=>li(e,8,"0o")},yu={identify:Bt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,s)=>Ks(e,0,10,s),stringify:ai.stringifyNumber},wu={identify:(e)=>Bt(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,s)=>Ks(e,2,16,s),stringify:(e)=>li(e,16,"0x")};bu.int=yu;bu.intHex=wu;bu.intOct=gu});var ci=v(function(xu){var vu=xe(),Tu=Ut(),Au=Oe(),Ru=Je(),Cu=Us(),Hs=js(),Ys=Ws(),Nu=[vu.map,Au.seq,Ru.string,Tu.nullTag,Cu.boolTag,Ys.intOct,Ys.int,Ys.intHex,Hs.floatNaN,Hs.floatExp,Hs.float];xu.schema=Nu});var ui=v(function(qu){var Lu=k(),ku=xe(),Iu=Oe();function di(e){return typeof e==="bigint"||Number.isInteger(e)}var jt=({value:e})=>JSON.stringify(e),Pu=[{identify:(e)=>typeof e==="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:(e)=>e,stringify:jt},{identify:(e)=>e==null,createNode:()=>new Lu.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:jt},{identify:(e)=>typeof e==="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:(e)=>e==="true",stringify:jt},{identify:di,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:s})=>s?BigInt(e):parseInt(e,10),stringify:({value:e})=>di(e)?e.toString():JSON.stringify(e)},{identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:(e)=>parseFloat(e),stringify:jt}],Mu={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Du=[ku.map,Iu.seq].concat(Pu,Mu);qu.schema=Du});var Vs=v(function(Bu){var Ve=ot("buffer"),Js=k(),$u=Ke(),Uu={identify:(e)=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Ve.Buffer==="function")return Ve.Buffer.from(e,"base64");else if(typeof atob==="function"){let s=atob(e.replace(/[\n\r]/g,"")),n=new Uint8Array(s.length);for(let r=0;r<s.length;++r)n[r]=s.charCodeAt(r);return n}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:s},n,r,i){if(!s)return"";let o=s,a;if(typeof Ve.Buffer==="function")a=o instanceof Ve.Buffer?o.toString("base64"):Ve.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 Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Js.Scalar.BLOCK_LITERAL),t!==Js.Scalar.QUOTE_DOUBLE){let l=Math.max(n.options.lineWidth-n.indent.length,n.options.minContentWidth),c=Math.ceil(a.length/l),p=Array(c);for(let u=0,h=0;u<c;++u,h+=l)p[u]=a.substr(h,l);a=p.join(t===Js.Scalar.BLOCK_LITERAL?`
|
|
52
|
+
`:" ")}return $u.stringifyString({comment:e,type:t,value:a},n,r,i)}};Bu.binary=Uu});var Wt=v(function(Yu){var Kt=N(),Gs=ne(),Ku=k(),Wu=oe();function fi(e,t){if(Kt.isSeq(e))for(let s=0;s<e.items.length;++s){let n=e.items[s];if(Kt.isPair(n))continue;else if(Kt.isMap(n)){if(n.items.length>1)t("Each pair must have its own sequence indicator");let r=n.items[0]||new Gs.Pair(new Ku.Scalar(null));if(n.commentBefore)r.key.commentBefore=r.key.commentBefore?`${n.commentBefore}
|
|
53
53
|
${r.key.commentBefore}`:n.commentBefore;if(n.comment){let i=r.value??r.key;i.comment=i.comment?`${n.comment}
|
|
54
|
-
${i.comment}`:n.comment}n=r}e.items[s]=Kt.isPair(n)?n:new Gs.Pair(n)}else t("Expected a sequence for this tag");return e}function hi(e,t,s){let{replacer:n}=s,r=new Wu.YAMLSeq(e);r.tag="tag:yaml.org,2002:pairs";let i=0;if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof n==="function")o=n.call(t,String(i++),o);let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;r.items.push(Gs.createPair(a,l,s))}return r}var Hu={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:fi,createNode:hi};Yu.createPairs=hi;Yu.pairs=Hu;Yu.resolvePairs=fi});var zs=S(function(Qu){var pi=C(),Xs=ee(),Ge=ie(),Xu=oe(),mi=Wt();class ge extends Xu.YAMLSeq{constructor(){super();this.add=Ge.YAMLMap.prototype.add.bind(this),this.delete=Ge.YAMLMap.prototype.delete.bind(this),this.get=Ge.YAMLMap.prototype.get.bind(this),this.has=Ge.YAMLMap.prototype.has.bind(this),this.set=Ge.YAMLMap.prototype.set.bind(this),this.tag=ge.tag}toJSON(e,t){if(!t)return super.toJSON(e);let s=new Map;if(t?.onCreate)t.onCreate(s);for(let n of this.items){let r,i;if(pi.isPair(n))r=Xs.toJS(n.key,"",t),i=Xs.toJS(n.value,r,t);else r=Xs.toJS(n,"",t);if(s.has(r))throw Error("Ordered maps must not include duplicate keys");s.set(r,i)}return s}static from(e,t,s){let n=mi.createPairs(e,t,s),r=new this;return r.items=n.items,r}}ge.tag="tag:yaml.org,2002:omap";var zu={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:ge,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=mi.resolvePairs(e,t),n=[];for(let{key:r}of s.items)if(pi.isScalar(r))if(n.includes(r.value))t(`Ordered maps must not include duplicate keys: ${r.value}`);else n.push(r.value);return Object.assign(new ge,s)},createNode:(e,t,s)=>ge.from(e,t,s)};Qu.YAMLOMap=ge;Qu.omap=zu});var _i=S(function(tf){var gi=k();function yi({value:e,source:t},s){if(t&&(e?wi:bi).test.test(t))return t;return e?s.options.trueStr:s.options.falseStr}var wi={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new gi.Scalar(!0),stringify:yi},bi={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new gi.Scalar(!1),stringify:yi};tf.falseTag=bi;tf.trueTag=wi});var Si=S(function(cf){var rf=k(),Qs=Le(),of={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Qs.stringifyNumber},af={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Qs.stringifyNumber(e)}},lf={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new rf.Scalar(parseFloat(e.replace(/_/g,""))),s=e.indexOf(".");if(s!==-1){let n=e.substring(s+1).replace(/_/g,"");if(n[n.length-1]==="0")t.minFractionDigits=n.length}return t},stringify:Qs.stringifyNumber};cf.float=lf;cf.floatExp=af;cf.floatNaN=of});var Ei=S(function(yf){var vi=Le(),Xe=(e)=>typeof e==="bigint"||Number.isInteger(e);function Ht(e,t,s,{intAsBigInt:n}){let r=e[0];if(r==="-"||r==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),n){switch(s){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return r==="-"?BigInt(-1)*o:o}let i=parseInt(e,s);return r==="-"?-1*i:i}function Zs(e,t,s){let{value:n}=e;if(Xe(n)){let r=n.toString(t);return n<0?"-"+s+r.substr(1):s+r}return vi.stringifyNumber(e)}var hf={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Ht(e,2,2,s),stringify:(e)=>Zs(e,2,"0b")},pf={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Ht(e,1,8,s),stringify:(e)=>Zs(e,8,"0")},mf={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Ht(e,0,10,s),stringify:vi.stringifyNumber},gf={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Ht(e,2,16,s),stringify:(e)=>Zs(e,16,"0x")};yf.int=mf;yf.intBin=hf;yf.intHex=gf;yf.intOct=pf});var en=S(function(Ef){var Vt=C(),Yt=ne(),Jt=ie();class ye extends Jt.YAMLMap{constructor(e){super(e);this.tag=ye.tag}add(e){let t;if(Vt.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Yt.Pair(e.key,null);else t=new Yt.Pair(e,null);if(!Jt.findPair(this.items,t.key))this.items.push(t)}get(e,t){let s=Jt.findPair(this.items,e);return!t&&Vt.isPair(s)?Vt.isScalar(s.key)?s.key.value:s.key:s}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let s=Jt.findPair(this.items,e);if(s&&!t)this.items.splice(this.items.indexOf(s),1);else if(!s&&t)this.items.push(new Yt.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,s){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,s);else throw Error("Set items must all have null values")}static from(e,t,s){let{replacer:n}=s,r=new this(e);if(t&&Symbol.iterator in Object(t))for(let i of t){if(typeof n==="function")i=n.call(t,i,i);r.items.push(Yt.createPair(i,null,s))}return r}}ye.tag="tag:yaml.org,2002:set";var vf={collection:"map",identify:(e)=>e instanceof Set,nodeClass:ye,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,s)=>ye.from(e,t,s),resolve(e,t){if(Vt.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new ye,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};Ef.YAMLSet=ye;Ef.set=vf});var sn=S(function(xf){var Rf=Le();function tn(e,t){let s=e[0],n=s==="-"||s==="+"?e.substring(1):e,r=(o)=>t?BigInt(o):Number(o),i=n.replace(/_/g,"").split(":").reduce((o,a)=>o*r(60)+r(a),r(0));return s==="-"?r(-1)*i:i}function Ti(e){let{value:t}=e,s=(o)=>o;if(typeof t==="bigint")s=(o)=>BigInt(o);else if(isNaN(t)||!isFinite(t))return Rf.stringifyNumber(e);let n="";if(t<0)n="-",t*=s(-1);let r=s(60),i=[t%r];if(t<60)i.unshift(0);else if(t=(t-i[0])/r,i.unshift(t%r),t>=60)t=(t-i[0])/r,i.unshift(t);return n+i.map((o)=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Cf={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:s})=>tn(e,s),stringify:Ti},Nf={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>tn(e,!1),stringify:Ti},Ai={identify:(e)=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Ai.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,s,n,r,i,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(s,n-1,r,i||0,o||0,a||0,l),p=t[8];if(p&&p!=="Z"){let d=tn(p,!1);if(Math.abs(d)<30)d*=60;c-=60000*d}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};xf.floatTime=Nf;xf.intTime=Cf;xf.timestamp=Ai});var Ci=S(function(Kf){var If=xe(),Pf=Ut(),Mf=Oe(),Df=Je(),qf=Vs(),Ri=_i(),nn=Si(),Gt=Ei(),Ff=kt(),$f=zs(),Uf=Wt(),Bf=en(),rn=sn(),jf=[If.map,Mf.seq,Df.string,Pf.nullTag,Ri.trueTag,Ri.falseTag,Gt.intBin,Gt.intOct,Gt.int,Gt.intHex,nn.floatNaN,nn.floatExp,nn.float,qf.binary,Ff.merge,$f.omap,Uf.pairs,Bf.set,rn.intTime,rn.floatTime,rn.timestamp];Kf.schema=jf});var qi=S(function(Qf){var Li=xe(),Hf=Ut(),ki=Oe(),Yf=Je(),Jf=Us(),on=js(),an=Ws(),Vf=ci(),Gf=ui(),Ii=Vs(),ze=kt(),Pi=zs(),Mi=Wt(),Ni=Ci(),Di=en(),Xt=sn(),xi=new Map([["core",Vf.schema],["failsafe",[Li.map,ki.seq,Yf.string]],["json",Gf.schema],["yaml11",Ni.schema],["yaml-1.1",Ni.schema]]),Oi={binary:Ii.binary,bool:Jf.boolTag,float:on.float,floatExp:on.floatExp,floatNaN:on.floatNaN,floatTime:Xt.floatTime,int:an.int,intHex:an.intHex,intOct:an.intOct,intTime:Xt.intTime,map:Li.map,merge:ze.merge,null:Hf.nullTag,omap:Pi.omap,pairs:Mi.pairs,seq:ki.seq,set:Di.set,timestamp:Xt.timestamp},Xf={"tag:yaml.org,2002:binary":Ii.binary,"tag:yaml.org,2002:merge":ze.merge,"tag:yaml.org,2002:omap":Pi.omap,"tag:yaml.org,2002:pairs":Mi.pairs,"tag:yaml.org,2002:set":Di.set,"tag:yaml.org,2002:timestamp":Xt.timestamp};function zf(e,t,s){let n=xi.get(t);if(n&&!e)return s&&!n.includes(ze.merge)?n.concat(ze.merge):n.slice();let r=n;if(!r)if(Array.isArray(e))r=[];else{let i=Array.from(xi.keys()).filter((o)=>o!=="yaml11").map((o)=>JSON.stringify(o)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${i} or define customTags array`)}if(Array.isArray(e))for(let i of e)r=r.concat(i);else if(typeof e==="function")r=e(r.slice());if(s)r=r.concat(ze.merge);return r.reduce((i,o)=>{let a=typeof o==="string"?Oi[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Oi).map((p)=>JSON.stringify(p)).join(", ");throw Error(`Unknown custom tag ${l}; use one of ${c}`)}if(!i.includes(a))i.push(a);return i},[])}Qf.coreKnownTags=Xf;Qf.getTags=zf});var dn=S(function(ih){var ln=C(),th=xe(),sh=Oe(),nh=Je(),zt=qi(),rh=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class cn{constructor({compat:e,customTags:t,merge:s,resolveKnownTags:n,schema:r,sortMapEntries:i,toStringDefaults:o}){this.compat=Array.isArray(e)?zt.getTags(e,"compat"):e?zt.getTags(null,e):null,this.name=typeof r==="string"&&r||"core",this.knownTags=n?zt.coreKnownTags:{},this.tags=zt.getTags(t,this.name,s),this.toStringOptions=o??null,Object.defineProperty(this,ln.MAP,{value:th.map}),Object.defineProperty(this,ln.SCALAR,{value:nh.string}),Object.defineProperty(this,ln.SEQ,{value:sh.seq}),this.sortMapEntries=typeof i==="function"?i:i===!0?rh:null}clone(){let e=Object.create(cn.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}ih.Schema=cn});var Fi=S(function(ch){var ah=C(),un=We(),Qe=Be();function lh(e,t){let s=[],n=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);if(l)s.push(l),n=!0;else if(e.directives.docStart)n=!0}if(n)s.push("---");let r=un.createStringifyContext(e,t),{commentString:i}=r.options;if(e.commentBefore){if(s.length!==1)s.unshift("");let l=i(e.commentBefore);s.unshift(Qe.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(ah.isNode(e.contents)){if(e.contents.spaceBefore&&n)s.push("");if(e.contents.commentBefore){let p=i(e.contents.commentBefore);s.push(Qe.indentComment(p,""))}r.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=un.stringify(e.contents,r,()=>a=null,l);if(a)c+=Qe.lineComment(c,"",i(a));if((c[0]==="|"||c[0]===">")&&s[s.length-1]==="---")s[s.length-1]=`--- ${c}`;else s.push(c)}else s.push(un.stringify(e.contents,r));if(e.directives?.docEnd)if(e.comment){let l=i(e.comment);if(l.includes(`
|
|
54
|
+
${i.comment}`:n.comment}n=r}e.items[s]=Kt.isPair(n)?n:new Gs.Pair(n)}else t("Expected a sequence for this tag");return e}function hi(e,t,s){let{replacer:n}=s,r=new Wu.YAMLSeq(e);r.tag="tag:yaml.org,2002:pairs";let i=0;if(t&&Symbol.iterator in Object(t))for(let o of t){if(typeof n==="function")o=n.call(t,String(i++),o);let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;r.items.push(Gs.createPair(a,l,s))}return r}var Hu={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:fi,createNode:hi};Yu.createPairs=hi;Yu.pairs=Hu;Yu.resolvePairs=fi});var zs=v(function(Qu){var pi=N(),Xs=ee(),Ge=ie(),Xu=oe(),mi=Wt();class ge extends Xu.YAMLSeq{constructor(){super();this.add=Ge.YAMLMap.prototype.add.bind(this),this.delete=Ge.YAMLMap.prototype.delete.bind(this),this.get=Ge.YAMLMap.prototype.get.bind(this),this.has=Ge.YAMLMap.prototype.has.bind(this),this.set=Ge.YAMLMap.prototype.set.bind(this),this.tag=ge.tag}toJSON(e,t){if(!t)return super.toJSON(e);let s=new Map;if(t?.onCreate)t.onCreate(s);for(let n of this.items){let r,i;if(pi.isPair(n))r=Xs.toJS(n.key,"",t),i=Xs.toJS(n.value,r,t);else r=Xs.toJS(n,"",t);if(s.has(r))throw Error("Ordered maps must not include duplicate keys");s.set(r,i)}return s}static from(e,t,s){let n=mi.createPairs(e,t,s),r=new this;return r.items=n.items,r}}ge.tag="tag:yaml.org,2002:omap";var zu={collection:"seq",identify:(e)=>e instanceof Map,nodeClass:ge,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=mi.resolvePairs(e,t),n=[];for(let{key:r}of s.items)if(pi.isScalar(r))if(n.includes(r.value))t(`Ordered maps must not include duplicate keys: ${r.value}`);else n.push(r.value);return Object.assign(new ge,s)},createNode:(e,t,s)=>ge.from(e,t,s)};Qu.YAMLOMap=ge;Qu.omap=zu});var _i=v(function(tf){var gi=k();function yi({value:e,source:t},s){if(t&&(e?wi:bi).test.test(t))return t;return e?s.options.trueStr:s.options.falseStr}var wi={identify:(e)=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new gi.Scalar(!0),stringify:yi},bi={identify:(e)=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new gi.Scalar(!1),stringify:yi};tf.falseTag=bi;tf.trueTag=wi});var Si=v(function(cf){var rf=k(),Qs=Le(),of={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:(e)=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Qs.stringifyNumber},af={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:(e)=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Qs.stringifyNumber(e)}},lf={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new rf.Scalar(parseFloat(e.replace(/_/g,""))),s=e.indexOf(".");if(s!==-1){let n=e.substring(s+1).replace(/_/g,"");if(n[n.length-1]==="0")t.minFractionDigits=n.length}return t},stringify:Qs.stringifyNumber};cf.float=lf;cf.floatExp=af;cf.floatNaN=of});var vi=v(function(yf){var Ei=Le(),Xe=(e)=>typeof e==="bigint"||Number.isInteger(e);function Ht(e,t,s,{intAsBigInt:n}){let r=e[0];if(r==="-"||r==="+")t+=1;if(e=e.substring(t).replace(/_/g,""),n){switch(s){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return r==="-"?BigInt(-1)*o:o}let i=parseInt(e,s);return r==="-"?-1*i:i}function Zs(e,t,s){let{value:n}=e;if(Xe(n)){let r=n.toString(t);return n<0?"-"+s+r.substr(1):s+r}return Ei.stringifyNumber(e)}var hf={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Ht(e,2,2,s),stringify:(e)=>Zs(e,2,"0b")},pf={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Ht(e,1,8,s),stringify:(e)=>Zs(e,8,"0")},mf={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Ht(e,0,10,s),stringify:Ei.stringifyNumber},gf={identify:Xe,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Ht(e,2,16,s),stringify:(e)=>Zs(e,16,"0x")};yf.int=mf;yf.intBin=hf;yf.intHex=gf;yf.intOct=pf});var en=v(function(vf){var Vt=N(),Yt=ne(),Jt=ie();class ye extends Jt.YAMLMap{constructor(e){super(e);this.tag=ye.tag}add(e){let t;if(Vt.isPair(e))t=e;else if(e&&typeof e==="object"&&"key"in e&&"value"in e&&e.value===null)t=new Yt.Pair(e.key,null);else t=new Yt.Pair(e,null);if(!Jt.findPair(this.items,t.key))this.items.push(t)}get(e,t){let s=Jt.findPair(this.items,e);return!t&&Vt.isPair(s)?Vt.isScalar(s.key)?s.key.value:s.key:s}set(e,t){if(typeof t!=="boolean")throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let s=Jt.findPair(this.items,e);if(s&&!t)this.items.splice(this.items.indexOf(s),1);else if(!s&&t)this.items.push(new Yt.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,s){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,s);else throw Error("Set items must all have null values")}static from(e,t,s){let{replacer:n}=s,r=new this(e);if(t&&Symbol.iterator in Object(t))for(let i of t){if(typeof n==="function")i=n.call(t,i,i);r.items.push(Yt.createPair(i,null,s))}return r}}ye.tag="tag:yaml.org,2002:set";var Ef={collection:"map",identify:(e)=>e instanceof Set,nodeClass:ye,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,s)=>ye.from(e,t,s),resolve(e,t){if(Vt.isMap(e))if(e.hasAllNullValues(!0))return Object.assign(new ye,e);else t("Set items must all have null values");else t("Expected a mapping for this tag");return e}};vf.YAMLSet=ye;vf.set=Ef});var sn=v(function(xf){var Rf=Le();function tn(e,t){let s=e[0],n=s==="-"||s==="+"?e.substring(1):e,r=(o)=>t?BigInt(o):Number(o),i=n.replace(/_/g,"").split(":").reduce((o,a)=>o*r(60)+r(a),r(0));return s==="-"?r(-1)*i:i}function Ti(e){let{value:t}=e,s=(o)=>o;if(typeof t==="bigint")s=(o)=>BigInt(o);else if(isNaN(t)||!isFinite(t))return Rf.stringifyNumber(e);let n="";if(t<0)n="-",t*=s(-1);let r=s(60),i=[t%r];if(t<60)i.unshift(0);else if(t=(t-i[0])/r,i.unshift(t%r),t>=60)t=(t-i[0])/r,i.unshift(t);return n+i.map((o)=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Cf={identify:(e)=>typeof e==="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:s})=>tn(e,s),stringify:Ti},Nf={identify:(e)=>typeof e==="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:(e)=>tn(e,!1),stringify:Ti},Ai={identify:(e)=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Ai.test);if(!t)throw Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,s,n,r,i,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(s,n-1,r,i||0,o||0,a||0,l),p=t[8];if(p&&p!=="Z"){let u=tn(p,!1);if(Math.abs(u)<30)u*=60;c-=60000*u}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};xf.floatTime=Nf;xf.intTime=Cf;xf.timestamp=Ai});var Ci=v(function(Kf){var If=xe(),Pf=Ut(),Mf=Oe(),Df=Je(),qf=Vs(),Ri=_i(),nn=Si(),Gt=vi(),Ff=kt(),$f=zs(),Uf=Wt(),Bf=en(),rn=sn(),jf=[If.map,Mf.seq,Df.string,Pf.nullTag,Ri.trueTag,Ri.falseTag,Gt.intBin,Gt.intOct,Gt.int,Gt.intHex,nn.floatNaN,nn.floatExp,nn.float,qf.binary,Ff.merge,$f.omap,Uf.pairs,Bf.set,rn.intTime,rn.floatTime,rn.timestamp];Kf.schema=jf});var qi=v(function(Qf){var Li=xe(),Hf=Ut(),ki=Oe(),Yf=Je(),Jf=Us(),on=js(),an=Ws(),Vf=ci(),Gf=ui(),Ii=Vs(),ze=kt(),Pi=zs(),Mi=Wt(),Ni=Ci(),Di=en(),Xt=sn(),xi=new Map([["core",Vf.schema],["failsafe",[Li.map,ki.seq,Yf.string]],["json",Gf.schema],["yaml11",Ni.schema],["yaml-1.1",Ni.schema]]),Oi={binary:Ii.binary,bool:Jf.boolTag,float:on.float,floatExp:on.floatExp,floatNaN:on.floatNaN,floatTime:Xt.floatTime,int:an.int,intHex:an.intHex,intOct:an.intOct,intTime:Xt.intTime,map:Li.map,merge:ze.merge,null:Hf.nullTag,omap:Pi.omap,pairs:Mi.pairs,seq:ki.seq,set:Di.set,timestamp:Xt.timestamp},Xf={"tag:yaml.org,2002:binary":Ii.binary,"tag:yaml.org,2002:merge":ze.merge,"tag:yaml.org,2002:omap":Pi.omap,"tag:yaml.org,2002:pairs":Mi.pairs,"tag:yaml.org,2002:set":Di.set,"tag:yaml.org,2002:timestamp":Xt.timestamp};function zf(e,t,s){let n=xi.get(t);if(n&&!e)return s&&!n.includes(ze.merge)?n.concat(ze.merge):n.slice();let r=n;if(!r)if(Array.isArray(e))r=[];else{let i=Array.from(xi.keys()).filter((o)=>o!=="yaml11").map((o)=>JSON.stringify(o)).join(", ");throw Error(`Unknown schema "${t}"; use one of ${i} or define customTags array`)}if(Array.isArray(e))for(let i of e)r=r.concat(i);else if(typeof e==="function")r=e(r.slice());if(s)r=r.concat(ze.merge);return r.reduce((i,o)=>{let a=typeof o==="string"?Oi[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Oi).map((p)=>JSON.stringify(p)).join(", ");throw Error(`Unknown custom tag ${l}; use one of ${c}`)}if(!i.includes(a))i.push(a);return i},[])}Qf.coreKnownTags=Xf;Qf.getTags=zf});var dn=v(function(ih){var ln=N(),th=xe(),sh=Oe(),nh=Je(),zt=qi(),rh=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0;class cn{constructor({compat:e,customTags:t,merge:s,resolveKnownTags:n,schema:r,sortMapEntries:i,toStringDefaults:o}){this.compat=Array.isArray(e)?zt.getTags(e,"compat"):e?zt.getTags(null,e):null,this.name=typeof r==="string"&&r||"core",this.knownTags=n?zt.coreKnownTags:{},this.tags=zt.getTags(t,this.name,s),this.toStringOptions=o??null,Object.defineProperty(this,ln.MAP,{value:th.map}),Object.defineProperty(this,ln.SCALAR,{value:nh.string}),Object.defineProperty(this,ln.SEQ,{value:sh.seq}),this.sortMapEntries=typeof i==="function"?i:i===!0?rh:null}clone(){let e=Object.create(cn.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}ih.Schema=cn});var Fi=v(function(ch){var ah=N(),un=We(),Qe=Be();function lh(e,t){let s=[],n=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);if(l)s.push(l),n=!0;else if(e.directives.docStart)n=!0}if(n)s.push("---");let r=un.createStringifyContext(e,t),{commentString:i}=r.options;if(e.commentBefore){if(s.length!==1)s.unshift("");let l=i(e.commentBefore);s.unshift(Qe.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(ah.isNode(e.contents)){if(e.contents.spaceBefore&&n)s.push("");if(e.contents.commentBefore){let p=i(e.contents.commentBefore);s.push(Qe.indentComment(p,""))}r.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=un.stringify(e.contents,r,()=>a=null,l);if(a)c+=Qe.lineComment(c,"",i(a));if((c[0]==="|"||c[0]===">")&&s[s.length-1]==="---")s[s.length-1]=`--- ${c}`;else s.push(c)}else s.push(un.stringify(e.contents,r));if(e.directives?.docEnd)if(e.comment){let l=i(e.comment);if(l.includes(`
|
|
55
55
|
`))s.push("..."),s.push(Qe.indentComment(l,""));else s.push(`... ${l}`)}else s.push("...");else{let l=e.comment;if(l&&o)l=l.replace(/^\n+/,"");if(l){if((!o||a)&&s[s.length-1]!=="")s.push("");s.push(Qe.indentComment(i(l),""))}}return s.join(`
|
|
56
56
|
`)+`
|
|
57
|
-
`}ch.stringifyDocument=lh});var Ze=
|
|
57
|
+
`}ch.stringifyDocument=lh});var Ze=v(function(wh){var uh=$e(),ke=At(),U=N(),fh=ne(),hh=ee(),ph=dn(),mh=Fi(),fn=Et(),gh=Os(),yh=Ue(),hn=xs();class pn{constructor(e,t,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,U.NODE_TYPE,{value:U.DOC});let n=null;if(typeof t==="function"||Array.isArray(t))n=t;else if(s===void 0&&t)s=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"},s);this.options=r;let{version:i}=r;if(s?._directives){if(this.directives=s._directives.atDocument(),this.directives.yaml.explicit)i=this.directives.yaml.version}else this.directives=new hn.Directives({version:i});this.setSchema(i,s),this.contents=e===void 0?null:this.createNode(e,n,s)}clone(){let e=Object.create(pn.prototype,{[U.NODE_TYPE]:{value:U.DOC}});if(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();if(e.schema=this.schema.clone(),e.contents=U.isNode(this.contents)?this.contents.clone(e.schema):this.contents,this.range)e.range=this.range.slice();return e}add(e){if(Ie(this.contents))this.contents.add(e)}addIn(e,t){if(Ie(this.contents))this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let s=fn.anchorNames(this);e.anchor=!t||s.has(t)?fn.findNewAnchor(t||"a",s):t}return new uh.Alias(e.anchor)}createNode(e,t,s){let n=void 0;if(typeof t==="function")e=t.call({"":e},"",e),n=t;else if(Array.isArray(t)){let d=(_)=>typeof _==="number"||_ instanceof String||_ instanceof Number,g=t.filter(d).map(String);if(g.length>0)t=t.concat(g);n=t}else if(s===void 0&&t)s=t,t=void 0;let{aliasDuplicateObjects:r,anchorPrefix:i,flow:o,keepUndefined:a,onTagObj:l,tag:c}=s??{},{onAnchor:p,setAnchors:u,sourceObjects:h}=fn.createNodeAnchors(this,i||"a"),y={aliasDuplicateObjects:r??!0,keepUndefined:a??!1,onAnchor:p,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:h},b=yh.createNode(e,c,y);if(o&&U.isCollection(b))b.flow=!0;return u(),b}createPair(e,t,s={}){let n=this.createNode(e,null,s),r=this.createNode(t,null,s);return new fh.Pair(n,r)}delete(e){return Ie(this.contents)?this.contents.delete(e):!1}deleteIn(e){if(ke.isEmptyPath(e)){if(this.contents==null)return!1;return this.contents=null,!0}return Ie(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return U.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){if(ke.isEmptyPath(e))return!t&&U.isScalar(this.contents)?this.contents.value:this.contents;return U.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return U.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){if(ke.isEmptyPath(e))return this.contents!==void 0;return U.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){if(this.contents==null)this.contents=ke.collectionFromPath(this.schema,[e],t);else if(Ie(this.contents))this.contents.set(e,t)}setIn(e,t){if(ke.isEmptyPath(e))this.contents=t;else if(this.contents==null)this.contents=ke.collectionFromPath(this.schema,Array.from(e),t);else if(Ie(this.contents))this.contents.setIn(e,t)}setSchema(e,t={}){if(typeof e==="number")e=String(e);let s;switch(e){case"1.1":if(this.directives)this.directives.yaml.version="1.1";else this.directives=new hn.Directives({version:"1.1"});s={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":if(this.directives)this.directives.yaml.version=e;else this.directives=new hn.Directives({version:e});s={resolveKnownTags:!0,schema:"core"};break;case null:if(this.directives)delete this.directives;s=null;break;default:{let n=JSON.stringify(e);throw 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(s)this.schema=new ph.Schema(Object.assign(s,t));else throw Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:s,maxAliasCount:n,onAnchor:r,reviver:i}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof n==="number"?n:100},a=hh.toJS(this.contents,t??"",o);if(typeof r==="function")for(let{count:l,res:c}of o.anchors.values())r(c,l);return typeof i==="function"?gh.applyReviver(i,{"":a},"",a):a}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw 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 Error(`"indent" option must be a positive integer, not ${t}`)}return mh.stringifyDocument(this,e)}}function Ie(e){if(U.isCollection(e))return!0;throw Error("Expected a YAML collection as document contents")}wh.Document=pn});var et=v(function(Sh){class Qt extends Error{constructor(e,t,s,n){super();this.name=e,this.code=s,this.message=n,this.pos=t}}class $i extends Qt{constructor(e,t,s){super("YAMLParseError",e,t,s)}}class Ui extends Qt{constructor(e,t,s){super("YAMLWarning",e,t,s)}}var _h=(e,t)=>(s)=>{if(s.pos[0]===-1)return;s.linePos=s.pos.map((a)=>t.linePos(a));let{line:n,col:r}=s.linePos[0];s.message+=` at line ${n}, column ${r}`;let i=r-1,o=e.substring(t.lineStarts[n-1],t.lineStarts[n]).replace(/[\n\r]+$/,"");if(i>=60&&o.length>80){let a=Math.min(i-39,o.length-79);o="…"+o.substring(a),i-=a-1}if(o.length>80)o=o.substring(0,79)+"…";if(n>1&&/^ *$/.test(o.substring(0,i))){let a=e.substring(t.lineStarts[n-2],t.lineStarts[n-1]);if(a.length>80)a=a.substring(0,79)+`…
|
|
58
58
|
`;o=a+o}if(/[^ ]/.test(o)){let a=1,l=s.linePos[1];if(l?.line===n&&l.col>r)a=Math.max(1,Math.min(l.col-r,80-i));let c=" ".repeat(i)+"^".repeat(a);s.message+=`:
|
|
59
59
|
|
|
60
60
|
${o}
|
|
61
61
|
${c}
|
|
62
|
-
`}};Sh.YAMLError=Qt;Sh.YAMLParseError=$i;Sh.YAMLWarning=Ui;Sh.prettifyError=_h});var tt=
|
|
63
|
-
`))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let s of t.start)if(s.type==="newline")return!0;if(t.sep){for(let s of t.sep)if(s.type==="newline")return!0}if(mn(t.key)||mn(t.value))return!0}return!1;default:return!0}}xh.containsNewline=mn});var gn=
|
|
64
|
-
`+
|
|
65
|
-
`+
|
|
66
|
-
`+
|
|
67
|
-
`+
|
|
68
|
-
`+x.comment;else
|
|
69
|
-
`+
|
|
70
|
-
`.repeat(Math.max(1,o.length-1)):"",
|
|
71
|
-
`;for(let
|
|
72
|
-
`;else if(
|
|
73
|
-
`;else if(!
|
|
74
|
-
`)
|
|
62
|
+
`}};Sh.YAMLError=Qt;Sh.YAMLParseError=$i;Sh.YAMLWarning=Ui;Sh.prettifyError=_h});var tt=v(function(Ch){function Rh(e,{flow:t,indicator:s,next:n,offset:r,onError:i,parentIndent:o,startOnNewline:a}){let l=!1,c=a,p=a,u="",h="",y=!1,b=!1,d=null,g=null,_=null,S=null,f=null,m=null,w=null;for(let T of e){if(b){if(T.type!=="space"&&T.type!=="newline"&&T.type!=="comma")i(T.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");b=!1}if(d){if(c&&T.type!=="comment"&&T.type!=="newline")i(d,"TAB_AS_INDENT","Tabs are not allowed as indentation");d=null}switch(T.type){case"space":if(!t&&(s!=="doc-start"||n?.type!=="flow-collection")&&T.source.includes("\t"))d=T;p=!0;break;case"comment":{if(!p)i(T,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let x=T.source.substring(1)||" ";if(!u)u=x;else u+=h+x;h="",c=!1;break}case"newline":if(c){if(u)u+=T.source;else if(!m||s!=="seq-item-ind")l=!0}else h+=T.source;if(c=!0,y=!0,g||_)S=T;p=!0;break;case"anchor":if(g)i(T,"MULTIPLE_ANCHORS","A node can have at most one anchor");if(T.source.endsWith(":"))i(T.offset+T.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0);g=T,w??(w=T.offset),c=!1,p=!1,b=!0;break;case"tag":{if(_)i(T,"MULTIPLE_TAGS","A node can have at most one tag");_=T,w??(w=T.offset),c=!1,p=!1,b=!0;break}case s:if(g||_)i(T,"BAD_PROP_ORDER",`Anchors and tags must be after the ${T.source} indicator`);if(m)i(T,"UNEXPECTED_TOKEN",`Unexpected ${T.source} in ${t??"collection"}`);m=T,c=s==="seq-item-ind"||s==="explicit-key-ind",p=!1;break;case"comma":if(t){if(f)i(T,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`);f=T,c=!1,p=!1;break}default:i(T,"UNEXPECTED_TOKEN",`Unexpected ${T.type} token`),c=!1,p=!1}}let E=e[e.length-1],A=E?E.offset+E.source.length:r;if(b&&n&&n.type!=="space"&&n.type!=="newline"&&n.type!=="comma"&&(n.type!=="scalar"||n.source!==""))i(n.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space");if(d&&(c&&d.indent<=o||n?.type==="block-map"||n?.type==="block-seq"))i(d,"TAB_AS_INDENT","Tabs are not allowed as indentation");return{comma:f,found:m,spaceBefore:l,comment:u,hasNewline:y,anchor:g,tag:_,newlineAfterProp:S,end:A,start:w??A}}Ch.resolveProps=Rh});var Zt=v(function(xh){function mn(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
|
|
63
|
+
`))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let s of t.start)if(s.type==="newline")return!0;if(t.sep){for(let s of t.sep)if(s.type==="newline")return!0}if(mn(t.key)||mn(t.value))return!0}return!1;default:return!0}}xh.containsNewline=mn});var gn=v(function(Ih){var Lh=Zt();function kh(e,t,s){if(t?.type==="flow-collection"){let n=t.end[0];if(n.indent===e&&(n.source==="]"||n.source==="}")&&Lh.containsNewline(t))s(n,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Ih.flowIndentCheck=kh});var yn=v(function(Dh){var Bi=N();function Mh(e,t,s){let{uniqueKeys:n}=e.options;if(n===!1)return!1;let r=typeof n==="function"?n:(i,o)=>i===o||Bi.isScalar(i)&&Bi.isScalar(o)&&i.value===o.value;return t.some((i)=>r(i.key,s))}Dh.mapIncludes=Mh});var Yi=v(function(jh){var ji=ne(),Fh=ie(),Ki=tt(),$h=Zt(),Wi=gn(),Uh=yn(),Hi="All mapping items must start at the same column";function Bh({composeNode:e,composeEmptyNode:t},s,n,r,i){let a=new(i?.nodeClass??Fh.YAMLMap)(s.schema);if(s.atRoot)s.atRoot=!1;let l=n.offset,c=null;for(let p of n.items){let{start:u,key:h,sep:y,value:b}=p,d=Ki.resolveProps(u,{indicator:"explicit-key-ind",next:h??y?.[0],offset:l,onError:r,parentIndent:n.indent,startOnNewline:!0}),g=!d.found;if(g){if(h){if(h.type==="block-seq")r(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key");else if("indent"in h&&h.indent!==n.indent)r(l,"BAD_INDENT",Hi)}if(!d.anchor&&!d.tag&&!y){if(c=d.end,d.comment)if(a.comment)a.comment+=`
|
|
64
|
+
`+d.comment;else a.comment=d.comment;continue}if(d.newlineAfterProp||$h.containsNewline(h))r(h??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else if(d.found?.indent!==n.indent)r(l,"BAD_INDENT",Hi);s.atKey=!0;let _=d.end,S=h?e(s,h,d,r):t(s,_,u,null,d,r);if(s.schema.compat)Wi.flowIndentCheck(n.indent,h,r);if(s.atKey=!1,Uh.mapIncludes(s,a.items,S))r(_,"DUPLICATE_KEY","Map keys must be unique");let f=Ki.resolveProps(y??[],{indicator:"map-value-ind",next:b,offset:S.range[2],onError:r,parentIndent:n.indent,startOnNewline:!h||h.type==="block-scalar"});if(l=f.end,f.found){if(g){if(b?.type==="block-map"&&!f.hasNewline)r(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings");if(s.options.strict&&d.start<f.found.offset-1024)r(S.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key")}let m=b?e(s,b,f,r):t(s,l,y,null,f,r);if(s.schema.compat)Wi.flowIndentCheck(n.indent,b,r);l=m.range[2];let w=new ji.Pair(S,m);if(s.options.keepSourceTokens)w.srcToken=p;a.items.push(w)}else{if(g)r(S.range,"MISSING_CHAR","Implicit map keys need to be followed by map values");if(f.comment)if(S.comment)S.comment+=`
|
|
65
|
+
`+f.comment;else S.comment=f.comment;let m=new ji.Pair(S);if(s.options.keepSourceTokens)m.srcToken=p;a.items.push(m)}}if(c&&c<l)r(c,"IMPOSSIBLE","Map comment with trailing content");return a.range=[n.offset,l,c??l],a}jh.resolveBlockMap=Bh});var Ji=v(function(Vh){var Wh=oe(),Hh=tt(),Yh=gn();function Jh({composeNode:e,composeEmptyNode:t},s,n,r,i){let a=new(i?.nodeClass??Wh.YAMLSeq)(s.schema);if(s.atRoot)s.atRoot=!1;if(s.atKey)s.atKey=!1;let l=n.offset,c=null;for(let{start:p,value:u}of n.items){let h=Hh.resolveProps(p,{indicator:"seq-item-ind",next:u,offset:l,onError:r,parentIndent:n.indent,startOnNewline:!0});if(!h.found)if(h.anchor||h.tag||u)if(u?.type==="block-seq")r(h.end,"BAD_INDENT","All sequence items must start at the same column");else r(l,"MISSING_CHAR","Sequence item without - indicator");else{if(c=h.end,h.comment)a.comment=h.comment;continue}let y=u?e(s,u,h,r):t(s,h.end,p,null,h,r);if(s.schema.compat)Yh.flowIndentCheck(n.indent,u,r);l=y.range[2],a.items.push(y)}return a.range=[n.offset,l,c??l],a}Vh.resolveBlockSeq=Jh});var Pe=v(function(zh){function Xh(e,t,s,n){let r="";if(e){let i=!1,o="";for(let a of e){let{source:l,type:c}=a;switch(c){case"space":i=!0;break;case"comment":{if(s&&!i)n(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let p=l.substring(1)||" ";if(!r)r=p;else r+=o+p;o="";break}case"newline":if(r)o+=l;i=!0;break;default:n(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=l.length}}return{comment:r,offset:t}}zh.resolveEnd=Xh});var Xi=v(function(op){var Zh=N(),ep=ne(),Vi=ie(),tp=oe(),sp=Pe(),Gi=tt(),np=Zt(),rp=yn(),wn="Block collections are not allowed within flow collections",bn=(e)=>e&&(e.type==="block-map"||e.type==="block-seq");function ip({composeNode:e,composeEmptyNode:t},s,n,r,i){let o=n.start.source==="{",a=o?"flow map":"flow sequence",c=new(i?.nodeClass??(o?Vi.YAMLMap:tp.YAMLSeq))(s.schema);c.flow=!0;let p=s.atRoot;if(p)s.atRoot=!1;if(s.atKey)s.atKey=!1;let u=n.offset+n.start.source.length;for(let g=0;g<n.items.length;++g){let _=n.items[g],{start:S,key:f,sep:m,value:w}=_,E=Gi.resolveProps(S,{flow:a,indicator:"explicit-key-ind",next:f??m?.[0],offset:u,onError:r,parentIndent:n.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!m&&!w){if(g===0&&E.comma)r(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(g<n.items.length-1)r(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`);if(E.comment)if(c.comment)c.comment+=`
|
|
66
|
+
`+E.comment;else c.comment=E.comment;u=E.end;continue}if(!o&&s.options.strict&&np.containsNewline(f))r(f,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0){if(E.comma)r(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`)}else{if(!E.comma)r(E.start,"MISSING_CHAR",`Missing , between ${a} items`);if(E.comment){let A="";e:for(let T of S)switch(T.type){case"comma":case"space":break;case"comment":A=T.source.substring(1);break e;default:break e}if(A){let T=c.items[c.items.length-1];if(Zh.isPair(T))T=T.value??T.key;if(T.comment)T.comment+=`
|
|
67
|
+
`+A;else T.comment=A;E.comment=E.comment.substring(A.length+1)}}}if(!o&&!m&&!E.found){let A=w?e(s,w,E,r):t(s,E.end,m,null,E,r);if(c.items.push(A),u=A.range[2],bn(w))r(A.range,"BLOCK_IN_FLOW",wn)}else{s.atKey=!0;let A=E.end,T=f?e(s,f,E,r):t(s,A,S,null,E,r);if(bn(f))r(T.range,"BLOCK_IN_FLOW",wn);s.atKey=!1;let x=Gi.resolveProps(m??[],{flow:a,indicator:"map-value-ind",next:w,offset:T.range[2],onError:r,parentIndent:n.indent,startOnNewline:!1});if(x.found){if(!o&&!E.found&&s.options.strict){if(m)for(let I of m){if(I===x.found)break;if(I.type==="newline"){r(I,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}if(E.start<x.found.offset-1024)r(x.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else if(w)if("source"in w&&w.source?.[0]===":")r(w,"MISSING_CHAR",`Missing space after : in ${a}`);else r(x.start,"MISSING_CHAR",`Missing , or : between ${a} items`);let W=w?e(s,w,x,r):x.found?t(s,x.end,m,null,x,r):null;if(W){if(bn(w))r(W.range,"BLOCK_IN_FLOW",wn)}else if(x.comment)if(T.comment)T.comment+=`
|
|
68
|
+
`+x.comment;else T.comment=x.comment;let _e=new ep.Pair(T,W);if(s.options.keepSourceTokens)_e.srcToken=_;if(o){let I=c;if(rp.mapIncludes(s,I.items,T))r(A,"DUPLICATE_KEY","Map keys must be unique");I.items.push(_e)}else{let I=new Vi.YAMLMap(s.schema);I.flow=!0,I.items.push(_e);let Bn=(W??T).range;I.range=[T.range[0],Bn[1],Bn[2]],c.items.push(I)}u=W?W.range[2]:x.end}}let h=o?"}":"]",[y,...b]=n.end,d=u;if(y?.source===h)d=y.offset+y.source.length;else{let g=a[0].toUpperCase()+a.substring(1),_=p?`${g} must end with a ${h}`:`${g} in block collection must be sufficiently indented and end with a ${h}`;if(r(u,p?"MISSING_CHAR":"BAD_INDENT",_),y&&y.source.length!==1)b.unshift(y)}if(b.length>0){let g=sp.resolveEnd(b,d,s.options.strict,r);if(g.comment)if(c.comment)c.comment+=`
|
|
69
|
+
`+g.comment;else c.comment=g.comment;c.range=[n.offset,d,g.offset]}else c.range=[n.offset,d,d];return c}op.resolveFlowCollection=ip});var zi=v(function(gp){var lp=N(),cp=k(),dp=ie(),up=oe(),fp=Yi(),hp=Ji(),pp=Xi();function _n(e,t,s,n,r,i){let o=s.type==="block-map"?fp.resolveBlockMap(e,t,s,n,i):s.type==="block-seq"?hp.resolveBlockSeq(e,t,s,n,i):pp.resolveFlowCollection(e,t,s,n,i),a=o.constructor;if(r==="!"||r===a.tagName)return o.tag=a.tagName,o;if(r)o.tag=r;return o}function mp(e,t,s,n,r){let i=n.tag,o=!i?null:t.directives.tagName(i.source,(h)=>r(i,"TAG_RESOLVE_FAILED",h));if(s.type==="block-seq"){let{anchor:h,newlineAfterProp:y}=n,b=h&&i?h.offset>i.offset?h:i:h??i;if(b&&(!y||y.offset<b.offset))r(b,"MISSING_CHAR","Missing newline after block sequence props")}let a=s.type==="block-map"?"map":s.type==="block-seq"?"seq":s.start.source==="{"?"map":"seq";if(!i||!o||o==="!"||o===dp.YAMLMap.tagName&&a==="map"||o===up.YAMLSeq.tagName&&a==="seq")return _n(e,t,s,r,o);let l=t.schema.tags.find((h)=>h.tag===o&&h.collection===a);if(!l){let h=t.schema.knownTags[o];if(h?.collection===a)t.schema.tags.push(Object.assign({},h,{default:!1})),l=h;else{if(h)r(i,"BAD_COLLECTION_TYPE",`${h.tag} used for ${a} collection, but expects ${h.collection??"scalar"}`,!0);else r(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0);return _n(e,t,s,r,o)}}let c=_n(e,t,s,r,o,l),p=l.resolve?.(c,(h)=>r(i,"TAG_RESOLVE_FAILED",h),t.options)??c,u=lp.isNode(p)?p:new cp.Scalar(p);if(u.range=c.range,u.tag=o,l?.format)u.format=l.format;return u}gp.composeCollection=mp});var En=v(function(Sp){var Sn=k();function wp(e,t,s){let n=t.offset,r=bp(t,e.options.strict,s);if(!r)return{value:"",type:null,comment:"",range:[n,n,n]};let i=r.mode===">"?Sn.Scalar.BLOCK_FOLDED:Sn.Scalar.BLOCK_LITERAL,o=t.source?_p(t.source):[],a=o.length;for(let d=o.length-1;d>=0;--d){let g=o[d][1];if(g===""||g==="\r")a=d;else break}if(a===0){let d=r.chomp==="+"&&o.length>0?`
|
|
70
|
+
`.repeat(Math.max(1,o.length-1)):"",g=n+r.length;if(t.source)g+=t.source.length;return{value:d,type:i,comment:r.comment,range:[n,g,g]}}let l=t.indent+r.indent,c=t.offset+r.length,p=0;for(let d=0;d<a;++d){let[g,_]=o[d];if(_===""||_==="\r"){if(r.indent===0&&g.length>l)l=g.length}else{if(g.length<l)s(c+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator");if(r.indent===0)l=g.length;if(p=d,l===0&&!e.atRoot)s(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=g.length+_.length+1}for(let d=o.length-1;d>=a;--d)if(o[d][0].length>l)a=d+1;let u="",h="",y=!1;for(let d=0;d<p;++d)u+=o[d][0].slice(l)+`
|
|
71
|
+
`;for(let d=p;d<a;++d){let[g,_]=o[d];c+=g.length+_.length+1;let S=_[_.length-1]==="\r";if(S)_=_.slice(0,-1);if(_&&g.length<l){let m=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;s(c-_.length-(S?2:1),"BAD_INDENT",m),g=""}if(i===Sn.Scalar.BLOCK_LITERAL)u+=h+g.slice(l)+_,h=`
|
|
72
|
+
`;else if(g.length>l||_[0]==="\t"){if(h===" ")h=`
|
|
73
|
+
`;else if(!y&&h===`
|
|
74
|
+
`)h=`
|
|
75
75
|
|
|
76
|
-
`;
|
|
77
|
-
`,
|
|
78
|
-
`)
|
|
79
|
-
`;else
|
|
80
|
-
`;else
|
|
81
|
-
`+o[
|
|
82
|
-
`)
|
|
83
|
-
`;break;default:
|
|
84
|
-
`}let
|
|
76
|
+
`;u+=h+g.slice(l)+_,h=`
|
|
77
|
+
`,y=!0}else if(_==="")if(h===`
|
|
78
|
+
`)u+=`
|
|
79
|
+
`;else h=`
|
|
80
|
+
`;else u+=h+_,h=" ",y=!1}switch(r.chomp){case"-":break;case"+":for(let d=a;d<o.length;++d)u+=`
|
|
81
|
+
`+o[d][0].slice(l);if(u[u.length-1]!==`
|
|
82
|
+
`)u+=`
|
|
83
|
+
`;break;default:u+=`
|
|
84
|
+
`}let b=n+r.length+t.source.length;return{value:u,type:i,comment:r.comment,range:[n,b,b]}}function bp({offset:e,props:t},s,n){if(t[0].type!=="block-scalar-header")return n(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:r}=t[0],i=r[0],o=0,a="",l=-1;for(let h=1;h<r.length;++h){let y=r[h];if(!a&&(y==="-"||y==="+"))a=y;else{let b=Number(y);if(!o&&b)o=b;else if(l===-1)l=e+h}}if(l!==-1)n(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let c=!1,p="",u=r.length;for(let h=1;h<t.length;++h){let y=t[h];switch(y.type){case"space":c=!0;case"newline":u+=y.source.length;break;case"comment":if(s&&!c)n(y,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");u+=y.source.length,p=y.source.substring(1);break;case"error":n(y,"UNEXPECTED_TOKEN",y.message),u+=y.source.length;break;default:{let b=`Unexpected token in block scalar header: ${y.type}`;n(y,"UNEXPECTED_TOKEN",b);let d=y.source;if(d&&typeof d==="string")u+=d.length}}}return{mode:i,indent:o,chomp:a,comment:p,length:u}}function _p(e){let t=e.split(/\n( *)/),s=t[0],n=s.match(/^( *)/),i=[n?.[1]?[n[1],s.slice(n[1].length)]:["",s]];for(let o=1;o<t.length;o+=2)i.push([t[o],t[o+1]]);return i}Sp.resolveBlockScalar=wp});var Tn=v(function(Lp){var vn=k(),vp=Pe();function Tp(e,t,s){let{offset:n,type:r,source:i,end:o}=e,a,l,c=(h,y,b)=>s(n+h,y,b);switch(r){case"scalar":a=vn.Scalar.PLAIN,l=Ap(i,c);break;case"single-quoted-scalar":a=vn.Scalar.QUOTE_SINGLE,l=Rp(i,c);break;case"double-quoted-scalar":a=vn.Scalar.QUOTE_DOUBLE,l=Cp(i,c);break;default:return s(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[n,n+i.length,n+i.length]}}let p=n+i.length,u=vp.resolveEnd(o,p,t,s);return{value:l,type:a,comment:u.comment,range:[n,p,u.offset]}}function Ap(e,t){let s="";switch(e[0]){case"\t":s="a tab character";break;case",":s="flow indicator character ,";break;case"%":s="directive indicator character %";break;case"|":case">":{s=`block scalar indicator ${e[0]}`;break}case"@":case"`":{s=`reserved character ${e[0]}`;break}}if(s)t(0,"BAD_SCALAR_START",`Plain value cannot start with ${s}`);return Qi(e)}function Rp(e,t){if(e[e.length-1]!=="'"||e.length===1)t(e.length,"MISSING_CHAR","Missing closing 'quote");return Qi(e.slice(1,-1)).replace(/''/g,"'")}function Qi(e){let t,s;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
85
85
|
`,"sy"),s=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
86
86
|
`,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,s=/[ \t]*(.*?)[ \t]*\r?\n/sy}let n=t.exec(e);if(!n)return e;let r=n[1],i=" ",o=t.lastIndex;s.lastIndex=o;while(n=s.exec(e)){if(n[1]==="")if(i===`
|
|
87
87
|
`)r+=i;else i=`
|
|
@@ -96,48 +96,48 @@ ${c}
|
|
|
96
96
|
`)break;if(n===`
|
|
97
97
|
`)s+=`
|
|
98
98
|
`;t+=1,n=e[t+1]}if(!s)s=" ";return{fold:s,offset:t}}var xp={"0":"\x00",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
99
|
-
`,r:"\r",t:"\t",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function Op(e,t,s,n){let r=e.substr(t,s),o=r.length===s&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(o)}catch{let a=e.substr(t-2,s+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}Lp.resolveFlowScalar=Tp});var eo=
|
|
99
|
+
`,r:"\r",t:"\t",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\","\t":"\t"};function Op(e,t,s,n){let r=e.substr(t,s),o=r.length===s&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(o)}catch{let a=e.substr(t-2,s+2);return n(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}Lp.resolveFlowScalar=Tp});var eo=v(function(Fp){var we=N(),Zi=k(),Ip=En(),Pp=Tn();function Mp(e,t,s,n){let{value:r,type:i,comment:o,range:a}=t.type==="block-scalar"?Ip.resolveBlockScalar(e,t,n):Pp.resolveFlowScalar(t,e.options.strict,n),l=s?e.directives.tagName(s.source,(u)=>n(s,"TAG_RESOLVE_FAILED",u)):null,c;if(e.options.stringKeys&&e.atKey)c=e.schema[we.SCALAR];else if(l)c=Dp(e.schema,r,l,s,n);else if(t.type==="scalar")c=qp(e,r,t,n);else c=e.schema[we.SCALAR];let p;try{let u=c.resolve(r,(h)=>n(s??t,"TAG_RESOLVE_FAILED",h),e.options);p=we.isScalar(u)?u:new Zi.Scalar(u)}catch(u){let h=u instanceof Error?u.message:String(u);n(s??t,"TAG_RESOLVE_FAILED",h),p=new Zi.Scalar(r)}if(p.range=a,p.source=r,i)p.type=i;if(l)p.tag=l;if(c.format)p.format=c.format;if(o)p.comment=o;return p}function Dp(e,t,s,n,r){if(s==="!")return e[we.SCALAR];let i=[];for(let a of e.tags)if(!a.collection&&a.tag===s)if(a.default&&a.test)i.push(a);else return a;for(let a of i)if(a.test?.test(t))return a;let o=e.knownTags[s];if(o&&!o.collection)return e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o;return r(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,s!=="tag:yaml.org,2002:str"),e[we.SCALAR]}function qp({atKey:e,directives:t,schema:s},n,r,i){let o=s.tags.find((a)=>(a.default===!0||e&&a.default==="key")&&a.test?.test(n))||s[we.SCALAR];if(s.compat){let a=s.compat.find((l)=>l.default&&l.test?.test(n))??s[we.SCALAR];if(o.tag!==a.tag){let l=t.tagString(o.tag),c=t.tagString(a.tag),p=`Value may be parsed as either ${l} or ${c}`;i(r,"TAG_RESOLVE_FAILED",p,!0)}}return o}Fp.composeScalar=Mp});var to=v(function(Bp){function Up(e,t,s){if(t){s??(s=t.length);for(let n=s-1;n>=0;--n){let r=t[n];switch(r.type){case"space":case"comment":case"newline":e-=r.source.length;continue}r=t[++n];while(r?.type==="space")e+=r.source.length,r=t[++n];break}}return e}Bp.emptyScalarPosition=Up});var ro=v(function(Xp){var Kp=$e(),Wp=N(),Hp=zi(),so=eo(),Yp=Pe(),Jp=to(),Vp={composeNode:no,composeEmptyNode:An};function no(e,t,s,n){let r=e.atKey,{spaceBefore:i,comment:o,anchor:a,tag:l}=s,c,p=!0;switch(t.type){case"alias":if(c=Gp(e,t,n),a||l)n(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":if(c=so.composeScalar(e,t,l,n),a)c.anchor=a.source.substring(1);break;case"block-map":case"block-seq":case"flow-collection":try{if(c=Hp.composeCollection(Vp,e,t,s,n),a)c.anchor=a.source.substring(1)}catch(u){let h=u instanceof Error?u.message:String(u);n(t,"RESOURCE_EXHAUSTION",h)}break;default:{let u=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;n(t,"UNEXPECTED_TOKEN",u),p=!1}}if(c??(c=An(e,t.offset,void 0,null,s,n)),a&&c.anchor==="")n(a,"BAD_ALIAS","Anchor cannot be an empty string");if(r&&e.options.stringKeys&&(!Wp.isScalar(c)||typeof c.value!=="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str"))n(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings");if(i)c.spaceBefore=!0;if(o)if(t.type==="scalar"&&t.source==="")c.comment=o;else c.commentBefore=o;if(e.options.keepSourceTokens&&p)c.srcToken=t;return c}function An(e,t,s,n,{spaceBefore:r,comment:i,anchor:o,tag:a,end:l},c){let p={type:"scalar",offset:Jp.emptyScalarPosition(t,s,n),indent:-1,source:""},u=so.composeScalar(e,p,a,c);if(o){if(u.anchor=o.source.substring(1),u.anchor==="")c(o,"BAD_ALIAS","Anchor cannot be an empty string")}if(r)u.spaceBefore=!0;if(i)u.comment=i,u.range[2]=l;return u}function Gp({options:e},{offset:t,source:s,end:n},r){let i=new Kp.Alias(s.substring(1));if(i.source==="")r(t,"BAD_ALIAS","Alias cannot be an empty string");if(i.source.endsWith(":"))r(t+s.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+s.length,a=Yp.resolveEnd(n,o,e.strict,r);if(i.range=[t,o,a.offset],a.comment)i.comment=a.comment;return i}Xp.composeEmptyNode=An;Xp.composeNode=no});var oo=v(function(nm){var Zp=Ze(),io=ro(),em=Pe(),tm=tt();function sm(e,t,{offset:s,start:n,value:r,end:i},o){let a=Object.assign({_directives:t},e),l=new Zp.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},p=tm.resolveProps(n,{indicator:"doc-start",next:r??i?.[0],offset:s,onError:o,parentIndent:0,startOnNewline:!0});if(p.found){if(l.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!p.hasNewline)o(p.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")}l.contents=r?io.composeNode(c,r,p,o):io.composeEmptyNode(c,p.end,n,null,p,o);let u=l.contents.range[2],h=em.resolveEnd(i,u,!1,o);if(h.comment)l.comment=h.comment;return l.range=[s,u,h.offset],l}nm.composeDoc=sm});var Rn=v(function(dm){var im=ot("process"),om=xs(),am=Ze(),st=et(),ao=N(),lm=oo(),cm=Pe();function nt(e){if(typeof e==="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:s}=e;return[t,t+(typeof s==="string"?s.length:1)]}function lo(e){let t="",s=!1,n=!1;for(let r=0;r<e.length;++r){let i=e[r];switch(i[0]){case"#":t+=(t===""?"":n?`
|
|
100
100
|
|
|
101
101
|
`:`
|
|
102
102
|
`)+(i.substring(1)||" "),s=!0,n=!1;break;case"%":if(e[r+1]?.[0]!=="#")r+=1;s=!1;break;default:if(!s)n=!0;s=!1}}return{comment:t,afterEmptyLine:n}}class co{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,s,n,r)=>{let i=nt(t);if(r)this.warnings.push(new st.YAMLWarning(i,s,n));else this.errors.push(new st.YAMLParseError(i,s,n))},this.directives=new om.Directives({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:s,afterEmptyLine:n}=lo(this.prelude);if(s){let r=e.contents;if(t)e.comment=e.comment?`${e.comment}
|
|
103
103
|
${s}`:s;else if(n||e.directives.docStart||!r)e.commentBefore=s;else if(ao.isCollection(r)&&!r.flow&&r.items.length>0){let i=r.items[0];if(ao.isPair(i))i=i.key;let o=i.commentBefore;i.commentBefore=o?`${s}
|
|
104
104
|
${o}`:s}else{let i=r.commentBefore;r.commentBefore=i?`${s}
|
|
105
105
|
${i}`:s}}if(t){for(let r=0;r<this.errors.length;++r)e.errors.push(this.errors[r]);for(let r=0;r<this.warnings.length;++r)e.warnings.push(this.warnings[r])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:lo(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,s=-1){for(let n of e)yield*this.next(n);yield*this.end(t,s)}*next(e){if(im.env.LOG_STREAM)console.dir(e,{depth:null});switch(e.type){case"directive":this.directives.add(e.source,(t,s,n)=>{let r=nt(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",s,n)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=lm.composeDoc(this.options,this.directives,e,this.onError);if(this.atDirectives&&!t.directives.docStart)this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line");if(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,s=new st.YAMLParseError(nt(e),"UNEXPECTED_TOKEN",t);if(this.atDirectives||!this.doc)this.errors.push(s);else this.doc.errors.push(s);break}case"doc-end":{if(!this.doc){this.errors.push(new st.YAMLParseError(nt(e),"UNEXPECTED_TOKEN","Unexpected doc-end without preceding document"));break}this.doc.directives.docEnd=!0;let t=cm.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let s=this.doc.comment;this.doc.comment=s?`${s}
|
|
106
|
-
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new st.YAMLParseError(nt(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 s=Object.assign({_directives:this.directives},this.options),n=new am.Document(void 0,s);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");n.range=[0,t,t],this.decorate(n,!1),yield n}}}dm.Composer=co});var ho=
|
|
106
|
+
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new st.YAMLParseError(nt(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 s=Object.assign({_directives:this.directives},this.options),n=new am.Document(void 0,s);if(this.atDirectives)this.onError(t,"MISSING_CHAR","Missing directives-end indicator line");n.range=[0,t,t],this.decorate(n,!1),yield n}}}dm.Composer=co});var ho=v(function(bm){var fm=En(),hm=Tn(),pm=et(),uo=Ke();function mm(e,t=!0,s){if(e){let n=(r,i,o)=>{let a=typeof r==="number"?r:Array.isArray(r)?r[0]:r.offset;if(s)s(a,i,o);else throw new pm.YAMLParseError([a,a+1],i,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return hm.resolveFlowScalar(e,t,n);case"block-scalar":return fm.resolveBlockScalar({options:{strict:t}},e,n)}}return null}function gm(e,t){let{implicitKey:s=!1,indent:n,inFlow:r=!1,offset:i=-1,type:o="PLAIN"}=t,a=uo.stringifyString({type:o,value:e},{implicitKey:s,indent:n>0?" ".repeat(n):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:"newline",offset:-1,indent:n,source:`
|
|
107
107
|
`}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
|
|
108
|
-
`),p=a.substring(0,c),
|
|
109
|
-
`,
|
|
110
|
-
`});return{type:"block-scalar",offset:i,indent:n,props:
|
|
108
|
+
`),p=a.substring(0,c),u=a.substring(c+1)+`
|
|
109
|
+
`,h=[{type:"block-scalar-header",offset:i,indent:n,source:p}];if(!fo(h,l))h.push({type:"newline",offset:-1,indent:n,source:`
|
|
110
|
+
`});return{type:"block-scalar",offset:i,indent:n,props:h,source:u}}case'"':return{type:"double-quoted-scalar",offset:i,indent:n,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:i,indent:n,source:a,end:l};default:return{type:"scalar",offset:i,indent:n,source:a,end:l}}}function ym(e,t,s={}){let{afterKey:n=!1,implicitKey:r=!1,inFlow:i=!1,type:o}=s,a="indent"in e?e.indent:null;if(n&&typeof a==="number")a+=2;if(!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=e.props[0];if(c.type!=="block-scalar-header")throw Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=uo.stringifyString({type:o,value:t},{implicitKey:r||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:i,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":wm(e,l);break;case'"':Cn(e,l,"double-quoted-scalar");break;case"'":Cn(e,l,"single-quoted-scalar");break;default:Cn(e,l,"scalar")}}function wm(e,t){let s=t.indexOf(`
|
|
111
111
|
`),n=t.substring(0,s),r=t.substring(s+1)+`
|
|
112
112
|
`;if(e.type==="block-scalar"){let i=e.props[0];if(i.type!=="block-scalar-header")throw Error("Invalid block scalar header");i.source=n,e.source=r}else{let{offset:i}=e,o="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:i,indent:o,source:n}];if(!fo(a,"end"in e?e.end:void 0))a.push({type:"newline",offset:-1,indent:o,source:`
|
|
113
113
|
`});for(let l of Object.keys(e))if(l!=="type"&&l!=="offset")delete e[l];Object.assign(e,{type:"block-scalar",indent:o,props:a,source:r})}}function fo(e,t){if(t)for(let s of t)switch(s.type){case"space":case"comment":e.push(s);break;case"newline":return e.push(s),!0}return!1}function Cn(e,t,s){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=s,e.source=t;break;case"block-scalar":{let n=e.props.slice(1),r=t.length;if(e.props[0].type==="block-scalar-header")r-=e.props[0].source.length;for(let i of n)i.offset+=r;delete e.props,Object.assign(e,{type:s,source:t,end:n});break}case"block-map":case"block-seq":{let r={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
|
|
114
|
-
`};delete e.items,Object.assign(e,{type:s,source:t,end:[r]});break}default:{let n="indent"in e?e.indent:-1,r="end"in e&&Array.isArray(e.end)?e.end.filter((i)=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(e))if(i!=="type"&&i!=="offset")delete e[i];Object.assign(e,{type:s,indent:n,source:t,end:r})}}}bm.createScalarToken=gm;bm.resolveAsScalar=mm;bm.setScalarValue=ym});var po=
|
|
114
|
+
`};delete e.items,Object.assign(e,{type:s,source:t,end:[r]});break}default:{let n="indent"in e?e.indent:-1,r="end"in e&&Array.isArray(e.end)?e.end.filter((i)=>i.type==="space"||i.type==="comment"||i.type==="newline"):[];for(let i of Object.keys(e))if(i!=="type"&&i!=="offset")delete e[i];Object.assign(e,{type:s,indent:n,source:t,end:r})}}}bm.createScalarToken=gm;bm.resolveAsScalar=mm;bm.setScalarValue=ym});var po=v(function(Tm){var vm=(e)=>("type"in e)?ts(e):es(e);function ts(e){switch(e.type){case"block-scalar":{let t="";for(let s of e.props)t+=ts(s);return t+e.source}case"block-map":case"block-seq":{let t="";for(let s of e.items)t+=es(s);return t}case"flow-collection":{let t=e.start.source;for(let s of e.items)t+=es(s);for(let s of e.end)t+=s.source;return t}case"document":{let t=es(e);if(e.end)for(let s of e.end)t+=s.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let s of e.end)t+=s.source;return t}}}function es({start:e,key:t,sep:s,value:n}){let r="";for(let i of e)r+=i.source;if(t)r+=ts(t);if(s)for(let i of s)r+=i.source;if(n)r+=ts(n);return r}Tm.stringify=vm});var yo=v(function(Cm){var Nn=Symbol("break visit"),Rm=Symbol("skip children"),mo=Symbol("remove item");function be(e,t){if("type"in e&&e.type==="document")e={start:e.start,value:e.value};go(Object.freeze([]),e,t)}be.BREAK=Nn;be.SKIP=Rm;be.REMOVE=mo;be.itemAtPath=(e,t)=>{let s=e;for(let[n,r]of t){let i=s?.[n];if(i&&"items"in i)s=i.items[r];else return}return s};be.parentCollection=(e,t)=>{let s=be.itemAtPath(e,t.slice(0,-1)),n=t[t.length-1][0],r=s?.[n];if(r&&"items"in r)return r;throw Error("Parent collection not found")};function go(e,t,s){let n=s(t,e);if(typeof n==="symbol")return n;for(let r of["key","value"]){let i=t[r];if(i&&"items"in i){for(let o=0;o<i.items.length;++o){let a=go(Object.freeze(e.concat([[r,o]])),i.items[o],s);if(typeof a==="number")o=a-1;else if(a===Nn)return Nn;else if(a===mo)i.items.splice(o,1),o-=1}if(typeof n==="function"&&r==="key")n=n(t,e)}}return typeof n==="function"?n(t,e):n}Cm.visit=be});var ss=v(function(Mm){var xn=ho(),xm=po(),Om=yo(),On="\uFEFF",Ln="\x02",kn="\x18",In="\x1F",Lm=(e)=>!!e&&("items"in e),km=(e)=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function Im(e){switch(e){case On:return"<BOM>";case Ln:return"<DOC>";case kn:return"<FLOW_END>";case In:return"<SCALAR>";default:return JSON.stringify(e)}}function Pm(e){switch(e){case On:return"byte-order-mark";case Ln:return"doc-mode";case kn:return"flow-error-end";case In:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
115
115
|
`:case`\r
|
|
116
|
-
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}Mm.createScalarToken=xn.createScalarToken;Mm.resolveAsScalar=xn.resolveAsScalar;Mm.setScalarValue=xn.setScalarValue;Mm.stringify=xm.stringify;Mm.visit=Om.visit;Mm.BOM=On;Mm.DOCUMENT=Ln;Mm.FLOW_END=kn;Mm.SCALAR=In;Mm.isCollection=Lm;Mm.isScalar=km;Mm.prettyToken=Im;Mm.tokenType=Pm});var Mn=
|
|
116
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case"\t":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}Mm.createScalarToken=xn.createScalarToken;Mm.resolveAsScalar=xn.resolveAsScalar;Mm.setScalarValue=xn.setScalarValue;Mm.stringify=xm.stringify;Mm.visit=Om.visit;Mm.BOM=On;Mm.DOCUMENT=Ln;Mm.FLOW_END=kn;Mm.SCALAR=In;Mm.isCollection=Lm;Mm.isScalar=km;Mm.prettyToken=Im;Mm.tokenType=Pm});var Mn=v(function(zm){var rt=ss();function K(e){switch(e){case void 0:case" ":case`
|
|
117
117
|
`:case"\r":case"\t":return!0;default:return!1}}var wo=new Set("0123456789ABCDEFabcdef"),Gm=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ns=new Set(",[]{}"),Xm=new Set(` ,[]{}
|
|
118
118
|
\r `),Pn=(e)=>!e||Xm.has(e);class bo{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let s=this.next??"stream";while(s&&(t||this.hasChars(1)))s=yield*this.parseNext(s)}atLineEnd(){let e=this.pos,t=this.buffer[e];while(t===" "||t==="\t")t=this.buffer[++e];if(!t||t==="#"||t===`
|
|
119
119
|
`)return!0;if(t==="\r")return this.buffer[e+1]===`
|
|
120
120
|
`;return!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let s=0;while(t===" ")t=this.buffer[++s+e];if(t==="\r"){let n=this.buffer[s+e+1];if(n===`
|
|
121
121
|
`||!n&&!this.atEnd)return e+s+1}return t===`
|
|
122
|
-
`||s>=this.indentNext||!t&&!this.atEnd?e+s:-1}if(t==="-"||t==="."){let s=this.buffer.substr(e,3);if((s==="---"||s==="...")&&
|
|
123
|
-
`,this.pos),this.lineEndPos=e;if(e===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[e-1]==="\r")e-=1;return 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]===rt.BOM)yield*this.pushCount(1),e=e.substring(1);if(e[0]==="%"){let t=e.length,s=e.indexOf("#");while(s!==-1){let r=e[s-1];if(r===" "||r==="\t"){t=s-1;break}else s=e.indexOf("#",s+1)}while(!0){let r=e[t-1];if(r===" "||r==="\t")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 rt.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==="...")&&
|
|
122
|
+
`||s>=this.indentNext||!t&&!this.atEnd?e+s:-1}if(t==="-"||t==="."){let s=this.buffer.substr(e,3);if((s==="---"||s==="...")&&K(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;if(typeof e!=="number"||e!==-1&&e<this.pos)e=this.buffer.indexOf(`
|
|
123
|
+
`,this.pos),this.lineEndPos=e;if(e===-1)return this.atEnd?this.buffer.substring(this.pos):null;if(this.buffer[e-1]==="\r")e-=1;return 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]===rt.BOM)yield*this.pushCount(1),e=e.substring(1);if(e[0]==="%"){let t=e.length,s=e.indexOf("#");while(s!==-1){let r=e[s-1];if(r===" "||r==="\t"){t=s-1;break}else s=e.indexOf("#",s+1)}while(!0){let r=e[t-1];if(r===" "||r==="\t")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 rt.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==="...")&&K(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}if(this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!K(this.charAt(1)))this.indentNext=this.indentValue;return yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&K(t)){let s=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=s,"block-start"}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(Pn),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,s=-1;do{if(e=yield*this.pushNewline(),e>0)t=yield*this.pushSpaces(!1),this.indentValue=s=t;else t=0;t+=yield*this.pushSpaces(!0)}while(e+t>0);let n=this.getLine();if(n===null)return this.setNext("flow");if(s!==-1&&s<this.indentNext&&n[0]!=="#"||s===0&&(n.startsWith("---")||n.startsWith("..."))&&K(n[3])){if(!(s===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield rt.FLOW_END,yield*this.parseLineStart()}let r=0;while(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(Pn),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let i=this.charAt(1);if(this.flowKey||K(i)||i===",")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==="'")while(t!==-1&&this.buffer[t+1]==="'")t=this.buffer.indexOf("'",t+2);else while(t!==-1){let r=0;while(this.buffer[t-1-r]==="\\")r+=1;if(r%2===0)break;t=this.buffer.indexOf('"',t+1)}let s=this.buffer.substring(0,t),n=s.indexOf(`
|
|
124
124
|
`,this.pos);if(n!==-1){while(n!==-1){let r=this.continueScalar(n+1);if(r===-1)break;n=s.indexOf(`
|
|
125
|
-
`,r)}if(n!==-1)t=n-(s[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;while(!0){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)=>
|
|
125
|
+
`,r)}if(n!==-1)t=n-(s[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;while(!0){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)=>K(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,s;e:for(let r=this.pos;s=this.buffer[r];++r)switch(s){case" ":t+=1;break;case`
|
|
126
126
|
`:e=r,t=0;break;case"\r":{let i=this.buffer[r+1];if(!i&&!this.atEnd)return this.setNext("block-scalar");if(i===`
|
|
127
127
|
`)break}default:break e}if(!s&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){if(this.blockScalarIndent===-1)this.indentNext=t;else 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(`
|
|
128
128
|
`,r)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let n=e+1;s=this.buffer[n];while(s===" ")s=this.buffer[++n];if(s==="\t"){while(s==="\t"||s===" "||s==="\r"||s===`
|
|
129
129
|
`)s=this.buffer[++n];e=n-1}else if(!this.blockScalarKeep)do{let r=e-1,i=this.buffer[r];if(i==="\r")i=this.buffer[--r];let o=r;while(i===" ")i=this.buffer[--r];if(i===`
|
|
130
|
-
`&&r>=this.pos&&r+1+t>o)e=r;else break}while(!0);return yield rt.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,s=this.pos-1,n;while(n=this.buffer[++s])if(n===":"){let r=this.buffer[s+1];if(
|
|
130
|
+
`&&r>=this.pos&&r+1+t>o)e=r;else break}while(!0);return yield rt.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,s=this.pos-1,n;while(n=this.buffer[++s])if(n===":"){let r=this.buffer[s+1];if(K(r)||e&&ns.has(r))break;t=s}else if(K(n)){let r=this.buffer[s+1];if(n==="\r")if(r===`
|
|
131
131
|
`)s+=1,n=`
|
|
132
132
|
`,r=this.buffer[s+1];else t=s;if(r==="#"||e&&ns.has(r))break;if(n===`
|
|
133
|
-
`){let i=this.continueScalar(s+1);if(i===-1)break;s=Math.max(s,i-2)}}else{if(e&&ns.has(n))break;t=s}if(!n&&!this.atEnd)return this.setNext("plain-scalar");return yield rt.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let s=this.buffer.slice(this.pos,e);if(s)return yield s,this.pos+=s.length,s.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Pn),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,s=this.charAt(1);if(
|
|
133
|
+
`){let i=this.continueScalar(s+1);if(i===-1)break;s=Math.max(s,i-2)}}else{if(e&&ns.has(n))break;t=s}if(!n&&!this.atEnd)return this.setNext("plain-scalar");return yield rt.SCALAR,yield*this.pushToIndex(t+1,!0),e?"flow":"doc"}*pushCount(e){if(e>0)return yield this.buffer.substr(this.pos,e),this.pos+=e,e;return 0}*pushToIndex(e,t){let s=this.buffer.slice(this.pos,e);if(s)return yield s,this.pos+=s.length,s.length;else if(t)yield"";return 0}*pushIndicators(){let e=0;e:while(!0){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(Pn),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,s=this.charAt(1);if(K(s)||t&&ns.has(s)){if(!t)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];while(!K(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];while(t)if(Gm.has(t))t=this.buffer[++e];else if(t==="%"&&wo.has(this.buffer[e+1])&&wo.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];if(e===`
|
|
134
134
|
`)return yield*this.pushCount(1);else if(e==="\r"&&this.charAt(1)===`
|
|
135
|
-
`)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,s;do s=this.buffer[++t];while(s===" "||e&&s==="\t");let n=t-this.pos;if(n>0)yield this.buffer.substr(this.pos,n),this.pos=t;return n}*pushUntil(e){let t=this.pos,s=this.buffer[t];while(!e(s))s=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}zm.Lexer=bo});var Dn=
|
|
135
|
+
`)return yield*this.pushCount(2);else return 0}*pushSpaces(e){let t=this.pos-1,s;do s=this.buffer[++t];while(s===" "||e&&s==="\t");let n=t-this.pos;if(n>0)yield this.buffer.substr(this.pos,n),this.pos=t;return n}*pushUntil(e){let t=this.pos,s=this.buffer[t];while(!e(s))s=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}zm.Lexer=bo});var Dn=v(function(Zm){class _o{constructor(){this.lineStarts=[],this.addNewLine=(e)=>this.lineStarts.push(e),this.linePos=(e)=>{let t=0,s=this.lineStarts.length;while(t<s){let r=t+s>>1;if(this.lineStarts[r]<e)t=r+1;else s=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}}}}Zm.LineCounter=_o});var qn=v(function(ng){var tg=ot("process"),So=ss(),sg=Mn();function ae(e,t){for(let s=0;s<e.length;++s)if(e[s].type===t)return!0;return!1}function Eo(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function To(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function rs(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function Me(e){if(e.length===0)return[];let t=e.length;e:while(--t>=0)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}while(e[++t]?.type==="space");return e.splice(t,e.length)}function is(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let s=0;s<t.length;++s)e.push(t[s])}function vo(e){if(e.start.type==="flow-seq-start"){for(let t of e.items)if(t.sep&&!t.value&&!ae(t.start,"explicit-key-ind")&&!ae(t.sep,"map-value-ind")){if(t.key)t.value=t.key;if(delete t.key,To(t.value))if(t.value.end)is(t.value.end,t.sep);else t.value.end=t.sep;else is(t.start,t.sep);delete t.sep}}}class Ao{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 sg.Lexer,this.onNewLine=e}*parse(e,t=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let s of this.lexer.lex(e,t))yield*this.next(s);if(!t)yield*this.end()}*next(e){if(this.source=e,tg.env.LOG_TOKENS)console.log("|",So.prettyToken(e));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=So.tokenType(e);if(!t){let s=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:s,source:e}),this.offset+=e.length}else if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+e.length);break;case"space":if(this.atNewLine&&e[0]===" ")this.indent+=e.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=e.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){while(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?.type!=="doc-end"){while(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 s=this.peek(1);if(t.type==="block-scalar")t.indent="indent"in s?s.indent:0;else if(t.type==="flow-collection"&&s.type==="document")t.indent=0;if(t.type==="flow-collection")vo(t);switch(s.type){case"document":s.value=t;break;case"block-scalar":s.props.push(t);break;case"block-map":{let n=s.items[s.items.length-1];if(n.value){s.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=s.items[s.items.length-1];if(n.value)s.items.push({start:[],value:t});else n.value=t;break}case"flow-collection":{let n=s.items[s.items.length-1];if(!n||n.value)s.items.push({start:[],key:t,sep:[]});else if(n.sep)n.value=t;else Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((s.type==="document"||s.type==="block-map"||s.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let n=t.items[t.items.length-1];if(n&&!n.sep&&!n.value&&n.start.length>0&&Eo(n.start)===-1&&(t.indent===0||n.start.every((r)=>r.type!=="comment"||r.indent<t.indent))){if(s.type==="document")s.end=n.start;else s.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:[]};if(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":{if(Eo(e.start)!==-1)yield*this.pop(),yield*this.step();else 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);if(t)this.stack.push(t);else 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=rs(this.peek(2)),s=Me(t),n;if(e.end)n=e.end,n.push(this.sourceToken),delete e.end;else n=[this.sourceToken];let r={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=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(`
|
|
136
136
|
`)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
137
|
-
`,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 s="end"in t.value?t.value.end:void 0;if((Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment")s?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else if(t.sep)t.sep.push(this.sourceToken);else 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)){is(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let s=!this.onKeyLine&&this.indent===e.indent,n=s&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",r=[];if(n&&t.sep&&!t.value){let i=[];for(let o=0;o<t.sep.length;++o){let a=t.sep[o];switch(a.type){case"newline":i.push(o);break;case"space":break;case"comment":if(a.indent>e.indent)i.length=0;break;default:i.length=0}}if(i.length>=2)r=t.sep.splice(i[1])}switch(this.type){case"anchor":case"tag":if(n||t.value)r.push(this.sourceToken),e.items.push({start:r}),this.onKeyLine=!0;else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"explicit-key-ind":if(!t.sep&&!t.explicitKey)t.start.push(this.sourceToken),t.explicitKey=!0;else if(n||t.value)r.push(this.sourceToken),e.items.push({start:r,explicitKey:!0});else 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(ae(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let i=Me(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(ae(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(To(t.key)&&!ae(t.sep,"newline")){let i=Me(t.start),o=t.key,a=t.sep;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:o,sep:a}]})}else if(r.length>0)t.sep=t.sep.concat(r,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||n)e.items.push({start:r,key:null,sep:[this.sourceToken]});else if(ae(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else t.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);if(n||t.value)e.items.push({start:r,key:i,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(i);else Object.assign(t,{key:i,sep:[]}),this.onKeyLine=!0;return}default:{let i=this.startBlockValue(e);if(i){if(i.type==="block-seq"){if(!t.explicitKey&&t.sep&&!ae(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(s)e.items.push({start:r});this.stack.push(i);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 s="end"in t.value?t.value.end:void 0;if((Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment")s?.push(this.sourceToken);else 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)){is(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;if(t.value||ae(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let s=this.startBlockValue(e);if(s){this.stack.push(s);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let s;do yield*this.pop(),s=this.peek(1);while(s?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!t||t.sep)e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return;case"map-value-ind":if(!t||t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!t||t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:n,sep:[]});else if(t.sep)this.stack.push(n);else Object.assign(t,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let s=this.startBlockValue(e);if(s)this.stack.push(s);else yield*this.pop(),yield*this.step()}else{let s=this.peek(2);if(s.type==="block-map"&&(this.type==="map-value-ind"&&s.indent===e.indent||this.type==="newline"&&!s.items[s.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&s.type!=="flow-collection"){let n=rs(s),r=Me(n);
|
|
137
|
+
`,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 s="end"in t.value?t.value.end:void 0;if((Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment")s?.push(this.sourceToken);else e.items.push({start:[this.sourceToken]})}else if(t.sep)t.sep.push(this.sourceToken);else 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)){is(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let s=!this.onKeyLine&&this.indent===e.indent,n=s&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",r=[];if(n&&t.sep&&!t.value){let i=[];for(let o=0;o<t.sep.length;++o){let a=t.sep[o];switch(a.type){case"newline":i.push(o);break;case"space":break;case"comment":if(a.indent>e.indent)i.length=0;break;default:i.length=0}}if(i.length>=2)r=t.sep.splice(i[1])}switch(this.type){case"anchor":case"tag":if(n||t.value)r.push(this.sourceToken),e.items.push({start:r}),this.onKeyLine=!0;else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"explicit-key-ind":if(!t.sep&&!t.explicitKey)t.start.push(this.sourceToken),t.explicitKey=!0;else if(n||t.value)r.push(this.sourceToken),e.items.push({start:r,explicitKey:!0});else 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(ae(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let i=Me(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(ae(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(To(t.key)&&!ae(t.sep,"newline")){let i=Me(t.start),o=t.key,a=t.sep;a.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:o,sep:a}]})}else if(r.length>0)t.sep=t.sep.concat(r,this.sourceToken);else t.sep.push(this.sourceToken);else if(!t.sep)Object.assign(t,{key:null,sep:[this.sourceToken]});else if(t.value||n)e.items.push({start:r,key:null,sep:[this.sourceToken]});else if(ae(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else t.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);if(n||t.value)e.items.push({start:r,key:i,sep:[]}),this.onKeyLine=!0;else if(t.sep)this.stack.push(i);else Object.assign(t,{key:i,sep:[]}),this.onKeyLine=!0;return}default:{let i=this.startBlockValue(e);if(i){if(i.type==="block-seq"){if(!t.explicitKey&&t.sep&&!ae(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(s)e.items.push({start:r});this.stack.push(i);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 s="end"in t.value?t.value.end:void 0;if((Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment")s?.push(this.sourceToken);else 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)){is(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;if(t.value||ae(t.start,"seq-item-ind"))e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return}if(this.indent>e.indent){let s=this.startBlockValue(e);if(s){this.stack.push(s);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let s;do yield*this.pop(),s=this.peek(1);while(s?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!t||t.sep)e.items.push({start:[this.sourceToken]});else t.start.push(this.sourceToken);return;case"map-value-ind":if(!t||t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!t||t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);if(!t||t.value)e.items.push({start:[],key:n,sep:[]});else if(t.sep)this.stack.push(n);else Object.assign(t,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let s=this.startBlockValue(e);if(s)this.stack.push(s);else yield*this.pop(),yield*this.step()}else{let s=this.peek(2);if(s.type==="block-map"&&(this.type==="map-value-ind"&&s.indent===e.indent||this.type==="newline"&&!s.items[s.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&s.type!=="flow-collection"){let n=rs(s),r=Me(n);vo(e);let i=e.end.splice(1,e.end.length);i.push(this.sourceToken);let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
|
|
138
138
|
`)+1;while(t!==0)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
139
|
-
`,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=rs(e),s=Me(t);return s.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=rs(e),s=Me(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((s)=>s.type==="newline"||s.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(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:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}ng.Parser=Ao});var Oo=
|
|
140
|
-
`))throw new
|
|
139
|
+
`,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=rs(e),s=Me(t);return s.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=rs(e),s=Me(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){if(this.type!=="comment")return!1;if(this.indent<=t)return!1;return e.every((s)=>s.type==="newline"||s.type==="space")}*documentEnd(e){if(this.type!=="doc-mode"){if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(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:if(e.end)e.end.push(this.sourceToken);else e.end=[this.sourceToken];if(this.type==="newline")yield*this.pop()}}}ng.Parser=Ao});var Oo=v(function(fg){var Ro=Rn(),ig=Ze(),it=et(),og=Ms(),ag=N(),lg=Dn(),Co=qn();function No(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new lg.LineCounter||null,prettyErrors:t}}function cg(e,t={}){let{lineCounter:s,prettyErrors:n}=No(t),r=new Co.Parser(s?.addNewLine),i=new Ro.Composer(t),o=Array.from(i.compose(r.parse(e)));if(n&&s)for(let a of o)a.errors.forEach(it.prettifyError(e,s)),a.warnings.forEach(it.prettifyError(e,s));if(o.length>0)return o;return Object.assign([],{empty:!0},i.streamInfo())}function xo(e,t={}){let{lineCounter:s,prettyErrors:n}=No(t),r=new Co.Parser(s?.addNewLine),i=new Ro.Composer(t),o=null;for(let a of i.compose(r.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new it.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}if(n&&s)o.errors.forEach(it.prettifyError(e,s)),o.warnings.forEach(it.prettifyError(e,s));return o}function dg(e,t,s){let n=void 0;if(typeof t==="function")n=t;else if(s===void 0&&t&&typeof t==="object")s=t;let r=xo(e,s);if(!r)return null;if(r.warnings.forEach((i)=>og.warn(r.options.logLevel,i)),r.errors.length>0)if(r.options.logLevel!=="silent")throw r.errors[0];else r.errors=[];return r.toJS(Object.assign({reviver:n},s))}function ug(e,t,s){let n=null;if(typeof t==="function"||Array.isArray(t))n=t;else if(s===void 0&&t)s=t;if(typeof s==="string")s=s.length;if(typeof s==="number"){let r=Math.round(s);s=r<1?void 0:r>8?{indent:8}:{indent:r}}if(e===void 0){let{keepUndefined:r}=s??t??{};if(!r)return}if(ag.isDocument(e)&&!n)return e.toString(s);return new ig.Document(e,n,s).toString(s)}fg.parse=dg;fg.parseAllDocuments=cg;fg.parseDocument=xo;fg.stringify=ug});import{spawn as dy}from"node:child_process";var jn={name:"reviewme",version:"0.0.6",license:"Apache-2.0",description:"A local, browser-based Git branch review tool with inline comments and Codex threads.",type:"module",bin:{reviewme:"bin/reviewme.mjs"},files:["bin","dist/frontend","dist/server","examples/themes","LICENSE","README.md","THIRD_PARTY_NOTICES.md"],engines:{node:">=22.13"},publishConfig:{access:"public"},scripts:{clean:"node scripts/clean-dist.mjs",dev:"npm run build && node ./bin/reviewme.mjs","build:frontend":"bun build ./src/frontend/index.html ./node_modules/@pierre/diffs/dist/worker/worker.js --outdir ./dist/frontend --entry-naming '[name].[ext]' --chunk-naming 'chunks/[name]-[hash].[ext]' --asset-naming 'assets/[name]-[hash].[ext]' --minify","build:server":"bun build ./src/server/main.ts --target=node --outdir=./dist/server --entry-naming=main.js --minify --sourcemap=linked",build:"npm run clean && npm run build:frontend && npm run build:server",prepack:"npm run build",start:"./bin/reviewme.mjs",test:"bun test",typecheck:"tsc --noEmit"},devDependencies:{"@pierre/diffs":"^1.3.6","@pierre/trees":"^1.0.0-beta.6","@types/react":"^19.2.2","@types/react-dom":"^19.2.2","bun-types":"^1.3.14","lucide-react":"^1.35.0",react:"^19.2.8","react-dom":"^19.2.8",typescript:"^5.9.3",yaml:"^2.9.0"}};import{basename as ra,join as Xn}from"node:path";import{spawn as zn}from"node:child_process";import{mkdtemp as ia,readFile as oa,rm as Ee}from"node:fs/promises";import{tmpdir as aa}from"node:os";import{Readable as la}from"node:stream";import{spawn as Bo}from"node:child_process";import{realpath as jo}from"node:fs/promises";import{resolve as Ko}from"node:path";class G extends Error{args;exitCode;stderr;constructor(e,t){let s=["git",...e].join(" "),n=t.stderr.trim()||`exited with code ${t.exitCode}`;super(`${s}: ${n}`);this.name="GitCommandError",this.args=e,this.exitCode=t.exitCode,this.stderr=t.stderr}}async function Kn(e){if(!e)return"";let t=[];for await(let s of e)t.push(Buffer.isBuffer(s)?s:Buffer.from(s));return Buffer.concat(t).toString("utf8")}function Wo(e){return new Promise((t,s)=>{let n=(i)=>{e.off("close",r),s(i)},r=(i)=>{e.off("error",n),t(i??1)};e.once("error",n),e.once("close",r)})}async function at(e,t){let s;try{s=Bo("git",[...e],{cwd:t,stdio:["ignore","pipe","pipe"]})}catch(n){throw Error(`Unable to start git: ${n instanceof Error?n.message:String(n)}`)}try{let[n,r,i]=await Promise.all([Kn(s.stdout),Kn(s.stderr),Wo(s)]);return{stdout:n,stderr:r,exitCode:i}}catch(n){throw Error(`Unable to start git: ${n instanceof Error?n.message:String(n)}`)}}async function Wn(e=process.cwd(),t=at){let s=Ko(e),n=await t(["-C",s,"rev-parse","--show-toplevel"],s);if(n.exitCode!==0)throw new G(["-C",s,"rev-parse","--show-toplevel"],n);let r=n.stdout.trim();if(!r)throw Error(`${s} is not inside a Git repository`);return jo(r)}async function H(e,t,s=at){let n=await s(t,e);if(n.exitCode!==0)throw new G(t,n);return n.stdout}import{access as Ho,constants as Yo,realpath as Hn}from"node:fs/promises";import{dirname as Jo,isAbsolute as Vo,relative as Go,resolve as ls,sep as cs,win32 as Xo}from"node:path";var Yn=new TextEncoder;class Y extends Error{constructor(e="Path must point to a file inside the repository"){super(e);this.name="InvalidRepositoryPathError"}}function Jn(){let e=new Uint8Array(32);crypto.getRandomValues(e);let t="";for(let s of e)t+=String.fromCharCode(s);return btoa(t).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function zo(e,t){if(!t)return!1;let s=Yn.encode(e),n=Yn.encode(t),r=s.length^n.length,i=Math.max(s.length,n.length);for(let o=0;o<i;o+=1)r|=(s[o]??0)^(n[o]??0);return r===0}function Qo(e){let t=e.headers.get("authorization");if(t){let n=/^Bearer\s+(.+)$/i.exec(t.trim());if(n?.[1])return n[1]}let s=e.headers.get("x-review-token");if(s)return s;return new URL(e.url).searchParams.get("token")}function Vn(e,t){return zo(t,Qo(e))}function Gn(e,t){let s=e.endsWith(cs)?e:`${e}${cs}`;return t===e||t.startsWith(s)}function Se(e,t){if(typeof t!=="string"||t.length===0)throw new Y("A non-empty repository-relative path is required");if(t.includes("\x00")||t.includes("\r")||t.includes(`
|
|
140
|
+
`))throw new Y("Path contains a forbidden control character");let s=t.replaceAll("\\","/");if(s.startsWith("/")||Vo(t)||Xo.isAbsolute(t)||/^[A-Za-z]:\//.test(s))throw new Y("Path must be repository-relative");let n=ls(e),r=ls(n,s);if(!Gn(n,r))throw new Y("Path resolves outside the repository");let i=Go(n,r).split(cs).join("/");if(!i||i==="."||i.startsWith("../")||i==="..")throw new Y("Path must identify a file inside the repository");return{relativePath:i,absolutePath:r}}async function ds(e,t){let s=Se(e,t),n=ls(e),r=s.absolutePath;while(r!==n)try{await Ho(r,Yo.F_OK);let i=await Hn(r);if(!Gn(await Hn(n),i))throw new Y("Path resolves outside the repository");return s}catch(i){if(i instanceof Y)throw i;r=Jo(r)}return s}import{existsSync as Zo}from"node:fs";import{spawn as ea}from"node:child_process";class lt extends Error{exitCode;constructor(e,t){super(t);this.name="OpenCommandError",this.exitCode=e}}var ta=process.platform==="darwin"?'open "$VR_FILE"':'xdg-open "$VR_FILE"';async function sa(e){if(!e)return"";let t=[];for await(let s of e)t.push(Buffer.isBuffer(s)?s:Buffer.from(s));return Buffer.concat(t).toString("utf8")}function na(e){return new Promise((t,s)=>{let n=(i)=>{e.off("close",r),s(i)},r=(i)=>{e.off("error",n),t(i??1)};e.once("error",n),e.once("close",r)})}function us(e=process.env.REVIEWME_OPEN_COMMAND?.trim()||ta){if(e.trim()==="")throw Error("Open command cannot be empty");return async(t)=>{let s;try{s=ea("/bin/sh",["-lc",e],{cwd:t.repositoryRoot,env:{...process.env,VR_FILE:t.absolutePath,VR_REL_FILE:t.relativePath,VR_FILE_EXISTS:String(Zo(t.absolutePath)),VR_ROOT:t.repositoryRoot,VR_SIDE:t.side??"new",VR_COMMIT:t.commit??t.headSha??"",VR_BASE_SHA:t.baseSha??"",VR_HEAD_SHA:t.headSha??"",VR_LINE:t.line===void 0?"":String(t.line),VR_COLUMN:t.column===void 0?"":String(t.column)},stdio:["ignore","ignore","pipe"]})}catch(i){throw new lt(-1,`Unable to start the open command: ${i instanceof Error?i.message:String(i)}`)}let[n,r]=await Promise.all([sa(s.stderr),na(s)]).catch((i)=>{throw new lt(-1,`Unable to start the open command: ${i instanceof Error?i.message:String(i)}`)});if(r!==0)throw new lt(r,n.trim()||"The open command returned a non-zero exit code")}}var Ty=us();class ce extends Error{code;constructor(e,t){super(t);this.name="RepositoryServiceError",this.code=e}}class dt extends ce{constructor(e){super("file_not_found",`Changed file not found: ${e}`);this.name="FileNotFoundError"}}function ca(e){if(e==null||e.trim()==="")return null;let t=e.trim().replace(/^git@github\.com:/,"ssh://git@github.com/");try{let s=new URL(t);if(s.hostname.toLowerCase()!=="github.com")return null;let[n,r]=s.pathname.replace(/^\/+/,"").split("/"),i=r?.replace(/\.git$/,"");return n&&i?{owner:n,repository:i}:null}catch{return null}}function Qn(e,t,s=[],n=!1){return["diff",...n?["--cached"]:[],"--patch","--binary","--full-index","--no-color","--no-ext-diff","-O","/dev/null","--find-renames","--find-copies",e,...t==null?[]:[t],"--",...s]}async function fs(e){if(!e)return"";let t=[];for await(let s of e)t.push(Buffer.isBuffer(s)?s:Buffer.from(s));return Buffer.concat(t).toString("utf8")}function Zn(e){return new Promise((t,s)=>{let n=(i)=>{e.off("close",r),s(i)},r=(i)=>{e.off("error",n),t(i??1)};e.once("error",n),e.once("close",r)})}function De(e,t,s){if(e&&(t||s))throw Error("Use either a range or --from/--to, not both");if(t||s){if(!t||!s)throw Error("--from and --to must be provided together");return ct(t),ct(s),{range:`${t}..${s}`,from:t,to:s,mode:"direct"}}if(!e)return{range:"main...HEAD",from:"main",to:"HEAD",mode:"merge-base"};let n=e.indexOf("..."),r=n<0?e.indexOf(".."):-1,i=n>=0?"...":r>=0?"..":null,o=n>=0?n:r;if(!i||o<0||e.indexOf(i,o+i.length)>=0)throw Error("Range must use exactly one `A...B` or `A..B` separator");let a=e.slice(0,o),l=e.slice(o+i.length);return ct(a),ct(l),{range:e,from:a,to:l,mode:i==="..."?"merge-base":"direct"}}function ct(e){if(!e||/[\0\r\n\t ]/.test(e)||e.startsWith("-")||e.includes(".."))throw Error(`Invalid Git ref: ${e||"(empty)"}`)}function tr(e){let t,s,n,r,i,o,a=!0,l=!1,c,p,u,h=!1,y=(b,d,g)=>{let _=b.indexOf("=");if(_>=0)return[b.slice(_+1),d];let S=e[d+1];if(!S||S.startsWith("-"))throw Error(`${g} requires a value`);return[S,d+1]};for(let b=0;b<e.length;b+=1){let d=e[b];if(d==="--help"||d==="-h"){h=!0;continue}if(d==="--no-open"){a=!1;continue}if(d==="--open"){a=!0;continue}if(d==="--auth"){l=!0;continue}if(d==="--open-command"||d.startsWith("--open-command=")){[c,b]=y(d,b,"--open-command");continue}if(d==="--color-theme"||d.startsWith("--color-theme=")){[p,b]=y(d,b,"--color-theme");continue}if(d==="--exit-on-close-after"||d.startsWith("--exit-on-close-after=")){let g=d.indexOf("="),_=g>=0?d.slice(g+1):e[++b],S=Number(_);if(_===void 0||!Number.isInteger(S)||Math.abs(S)>2147483)throw Error("--exit-on-close-after must be an integer between -2147483 and 2147483 seconds");u=S;continue}if(d==="--from"||d.startsWith("--from=")){[s,b]=y(d,b,"--from");continue}if(d==="--to"||d.startsWith("--to=")){[n,b]=y(d,b,"--to");continue}if(d==="--repo"||d.startsWith("--repo=")){[r,b]=y(d,b,"--repo");continue}if(d==="--port"||d.startsWith("--port=")){let[g,_]=y(d,b,"--port"),S=Number(g);if(!Number.isInteger(S)||S<0||S>65535)throw Error("--port must be an integer between 0 and 65535");i=S,b=_;continue}if(d==="--watch-interval"||d.startsWith("--watch-interval=")){let[g,_]=y(d,b,"--watch-interval"),S=Number(g);if(!Number.isInteger(S)||S<100)throw Error("--watch-interval must be an integer of at least 100ms");o=S,b=_;continue}if(d.startsWith("-"))throw Error(`Unknown option: ${d}`);if(t){if(r)throw Error(`Unexpected argument: ${d}`);r=d}else t=d}return{range:t,from:s,to:n,repoPath:r,port:i,openBrowser:a,auth:l,openCommand:c,colorThemePath:p,watchIntervalMs:o,exitOnCloseAfterSeconds:u,help:h}}var sr=`Usage: reviewme [RANGE] [REPOSITORY]
|
|
141
141
|
|
|
142
142
|
Compare a branch with a local Git ref and open the review in your browser.
|
|
143
143
|
|
|
@@ -148,17 +148,22 @@ Compare a branch with a local Git ref and open the review in your browser.
|
|
|
148
148
|
--auth Require a per-launch token for local API requests
|
|
149
149
|
--open-command CMD Shell command used to open files/locations
|
|
150
150
|
--color-theme PATH Load a JSON or YAML color theme
|
|
151
|
+
--exit-on-close-after N Close after the last tab disconnects (negative disables)
|
|
151
152
|
--no-open Do not launch the browser
|
|
152
|
-
`;function da(e){switch(e[0]){case"A":return"added";case"D":return"deleted";case"R":return"renamed";case"C":return"copied";case"T":return"type-changed";case"U":return"unmerged";case"M":return"modified";default:return"unknown"}}function ua(e){let t=e.split("\x00"),s=[];for(let n=0;n<t.length;){let r=t[n++];if(!r)continue;let i=r.slice(1).trim().split(/\s+/);if(i.length<5)continue;let o=i.at(-1)??"?",a=i[0],l=i[1],c=t[n++]??"",p=o[0];if(p==="R"||p==="C"){let
|
|
153
|
-
`),i=r.shift();if(!i)return[];let[o,a="",l="",c="",p=""]=i.split("\x1F");if(!o)return[];return[{sha:o,parents:a===""?[]:a.split(" "),author:l,authoredAt:c,subject:p,changedFiles:r.filter((
|
|
154
|
-
ON CONFLICT(id) DO UPDATE SET browser_tab_title = excluded.browser_tab_title`,[e]),e}
|
|
153
|
+
`;function da(e){switch(e[0]){case"A":return"added";case"D":return"deleted";case"R":return"renamed";case"C":return"copied";case"T":return"type-changed";case"U":return"unmerged";case"M":return"modified";default:return"unknown"}}function ua(e){let t=e.split("\x00"),s=[];for(let n=0;n<t.length;){let r=t[n++];if(!r)continue;let i=r.slice(1).trim().split(/\s+/);if(i.length<5)continue;let o=i.at(-1)??"?",a=i[0],l=i[1],c=t[n++]??"",p=o[0];if(p==="R"||p==="C"){let u=t[n++]??"";s.push({statusCode:o,path:u,oldPath:c,oldMode:a,newMode:l})}else s.push({statusCode:o,path:c,oldMode:a,newMode:l})}return s}function fa(e){let t=e.split("\x00"),s=new Map;for(let n=0;n<t.length;){let r=t[n++];if(r===void 0||r==="")continue;let i=/^(\d+|-)[\t ](\d+|-)[\t ](.*)$/.exec(r);if(!i)continue;let o=i[1]==="-"?null:Number(i[1]),a=i[2]==="-"?null:Number(i[2]),l={additions:o,deletions:a,binary:o===null||a===null};if(i[3])s.set(i[3],l);else{let c=t[n++]??"",p=t[n++]??"";if(c)s.set(c,l);if(p)s.set(p,l)}}return s}class nr{ready;options;git;vscode;listeners=new Set;state;root="";parsedRange;refreshInFlight;watchTimer;constructor(e={}){this.options=e,this.git=e.git??at,this.vscode=e.vscode??us(e.openCommand),this.ready=this.initialize()}get repositoryRoot(){return this.root}async initialize(){if(this.root=await Wn(this.options.repoPath??process.cwd(),this.git),this.options.range==null&&this.options.from==null&&this.options.to==null){let e=await this.git(["symbolic-ref","--quiet","--short","refs/remotes/origin/HEAD"],this.root),t=e.exitCode===0?e.stdout.trim():"";if(!t){for(let s of["main","master"])if((await this.git(["rev-parse","--verify","--quiet","--end-of-options",`refs/heads/${s}^{commit}`],this.root)).exitCode===0){t=s;break}}this.parsedRange=De(`${t||"main"}...HEAD`)}else this.parsedRange=De(this.options.range,this.options.from,this.options.to);await this.updateState(!1)}async resolveRef(e){let t;try{t=await H(this.root,["rev-parse","--verify","--end-of-options",`${e}^{commit}`],this.git)}catch(n){if(n instanceof G)throw new ce("invalid_ref",`Git ref does not exist: ${e}`);throw n}let s=t.trim().split(/\s+/)[0];if(!s||!/^[0-9a-f]{40,64}$/i.test(s))throw new ce("invalid_ref",`Git did not resolve ${e} to a commit`);return s}async resolveComparison(e=this.parsedRange){let[t,s]=await Promise.all([this.resolveRef(e.from),this.resolveRef(e.to)]),n=null,r=await this.git(["merge-base",t,s],this.root);if(r.exitCode===0&&r.stdout.trim())n=r.stdout.trim().split(/\s+/)[0]??null;else if(e.mode==="merge-base")throw new ce("no_merge_base",`No merge base exists between ${e.from} and ${e.to}`);return{fromSha:t,toSha:s,baseSha:e.mode==="merge-base"?n:t,mergeBaseSha:n}}async getBranch(){let e=await this.git(["symbolic-ref","--quiet","--short","HEAD"],this.root);return e.exitCode===0?e.stdout.trim()||null:null}async getRemoteOrigin(){let e=await this.git(["config","--get","remote.origin.url"],this.root);return e.exitCode===0?e.stdout.trim()||null:null}async getStatus(){return H(this.root,["status","--porcelain=v1","-z","--untracked-files=all"],this.git)}async getChangedFiles(e,t){let s=["diff","--raw","-z","--abbrev=40","--find-renames","--find-copies","--no-ext-diff","-O","/dev/null",e,t,"--"],[n,r]=await Promise.all([H(this.root,s,this.git),H(this.root,["diff","--numstat","-z","--find-renames","--find-copies","--no-ext-diff","-O","/dev/null",e,t,"--"],this.git)]),i=fa(r);return ua(n).map((o)=>{let a=i.get(o.path)??(o.oldPath?i.get(o.oldPath):void 0),l=da(o.statusCode),c=o.path||o.oldPath||"";return{id:c,path:c,...o.oldPath?{oldPath:o.oldPath}:{},status:l,additions:a?.additions??0,deletions:a?.deletions??0,isBinary:a?.binary??!1,...o.oldMode&&o.oldMode!=="000000"?{oldMode:o.oldMode}:{},...o.newMode&&o.newMode!=="000000"?{newMode:o.newMode}:{}}})}async updateState(e){let t=await this.resolveComparison(),[s,n,r,i]=await Promise.all([this.resolveRef("HEAD"),this.getStatus(),this.getBranch(),this.getRemoteOrigin()]),o=ca(i),a=[t.fromSha,t.toSha,t.baseSha,t.mergeBaseSha??"",n].join("\x00"),l=this.state,c=!l||l.fingerprint!==a,p=c||!l?await this.getChangedFiles(t.baseSha,t.toSha):l.files,u=l?c?l.info.revision+1:l.info.revision:1,h=n.split("\x00"),y=[];for(let g=0;g<h.length;g+=1){let _=h[g];if(_==null||_.length<4)continue;let S=_.slice(0,2);if(y.push(_.slice(3)),S.includes("R")||S.includes("C"))g+=1}let b={root:this.root,name:ra(this.root),remoteOrigin:i,githubOwner:o?.owner??null,githubRepository:o?.repository??null,branch:r,headSha:s,range:this.parsedRange.range,fromRef:this.parsedRange.from,toRef:this.parsedRange.to,baseRef:this.parsedRange.from,headRef:this.parsedRange.to,fromSha:t.fromSha,toSha:t.toSha,baseSha:t.baseSha,targetSha:t.toSha,mergeBaseSha:t.mergeBaseSha,comparisonMode:this.parsedRange.mode,revision:u,dirty:Boolean(n.trim()),uncommittedPaths:y};this.state={info:b,files:p,fingerprint:a};let d={changed:c,revision:u,repository:b,files:[...p]};if(e&&c)for(let g of this.listeners)g(d);return d}async refresh(){if(await this.ready,!this.refreshInFlight)this.refreshInFlight=this.updateState(!0).finally(()=>{this.refreshInFlight=void 0});return this.refreshInFlight}async getRepositoryMetadata(){return await this.ready,{...this.state.info}}async listFiles(){return await this.ready,{revision:this.state.info.revision,files:[...this.state.files]}}async listRefs(){await this.ready;let t=(await H(this.root,["for-each-ref","--format=%(refname)%00%(refname:short)%00%(objectname)%00%(objecttype)%00","refs/heads","refs/remotes","refs/tags"],this.git)).split("\x00"),s=[];for(let n=0;n+3<t.length;n+=4){let r=t[n]?.replace(/^\n+/,""),i=t[n+1],o=t[n+2];if(!r||!i||!o)continue;let a=r.startsWith("refs/heads/")?"branch":r.startsWith("refs/remotes/")?"remote":r.startsWith("refs/tags/")?"tag":"other";s.push({name:i,fullName:r,sha:o,kind:a})}return s}async listCommits(e){await this.ready;let t=e===void 0?{baseSha:this.state.info.baseSha,toSha:this.state.info.targetSha}:await this.resolveComparison(De(e.mode==="merge-base"?`${e.from}...${e.to}`:`${e.from}..${e.to}`));return(await H(this.root,["log","--topo-order","--numstat","--format=%x1e%H%x1f%P%x1f%an%x1f%aI%x1f%s",`${t.baseSha}..${t.toSha}`],this.git)).split("\x1E").flatMap((n)=>{let r=n.trim().split(`
|
|
154
|
+
`),i=r.shift();if(!i)return[];let[o,a="",l="",c="",p=""]=i.split("\x1F");if(!o)return[];return[{sha:o,parents:a===""?[]:a.split(" "),author:l,authoredAt:c,subject:p,changedFiles:r.filter((u)=>u.trim()!=="").length}]})}async streamPatch(e,t,s=!1){await this.ready;let n=t===void 0?{baseSha:this.state.info.baseSha,toSha:this.state.info.targetSha}:await this.resolveComparison(De(t.mode==="merge-base"?`${t.from}...${t.to}`:`${t.from}..${t.to}`)),r,i;if(s){r=await ia(Xn(aa(),"reviewme-index-")),i={...process.env,GIT_INDEX_FILE:Xn(r,"index")};for(let f of[["read-tree",n.baseSha],["add","-A","--",".",":(exclude).reviewme/**"]]){let m;try{m=zn("git",f,{cwd:this.root,env:i,stdio:["ignore","pipe","pipe"]})}catch(x){throw await Ee(r,{recursive:!0,force:!0}),Error(`Unable to start git: ${x instanceof Error?x.message:String(x)}`)}let w=Zn(m),E,A,T;try{[E,A,T]=await Promise.all([fs(m.stdout),fs(m.stderr),w])}catch(x){throw await Ee(r,{recursive:!0,force:!0}),Error(`Unable to start git: ${x instanceof Error?x.message:String(x)}`)}if(T!==0)throw await Ee(r,{recursive:!0,force:!0}),new G(f,{stdout:E,stderr:A,exitCode:T})}}let o=Qn(n.baseSha,s?void 0:n.toSha,[],s),a;try{a=zn("git",[...o],{cwd:this.root,env:i,stdio:["ignore","pipe","pipe"]})}catch(f){if(r!=null)await Ee(r,{recursive:!0,force:!0});throw Error(`Unable to start git: ${f instanceof Error?f.message:String(f)}`)}let l=Zn(a);if(l.catch(()=>{}),r!=null){let f=r;l.then(()=>Ee(f,{recursive:!0,force:!0}),()=>Ee(f,{recursive:!0,force:!0}))}let c=a.stdout;if(!c)throw a.kill(),Error("Git did not provide a readable stdout stream");let p=a.stderr,u=fs(p).catch(()=>""),h=la.toWeb(c).getReader(),y=!1,b=!1,d=!1,g=()=>{if(d)return;if(d=!0,a.exitCode===null)a.kill("SIGTERM")},_=()=>{e?.removeEventListener("abort",S)},S=()=>{if(y||b)return;y=!0,g(),h.cancel().catch(()=>{}),_()};if(e?.aborted)S();else e?.addEventListener("abort",S,{once:!0});return new ReadableStream({start(f){if(y)f.close()},async pull(f){if(y||b)return;try{let m=await h.read();if(y||b)return;if(m.done){let w,E;try{[w,E]=await Promise.all([l,u])}catch(A){if(y||b)return;b=!0,_(),g(),f.error(A);return}if(y||b)return;if(b=!0,_(),w!==0)f.error(new G(o,{stdout:"",stderr:E,exitCode:w}));else f.close();return}f.enqueue(m.value)}catch(m){if(y||b)return;b=!0,_(),g(),f.error(m)}},async cancel(f){if(y)return;y=!0,_(),g();try{await h.cancel(f)}catch{}await Promise.allSettled([l,u]),h.releaseLock()}})}async getFileDiff(e){await this.ready;let t=this.state.files.find((r)=>r.id===e||r.path===e||r.oldPath===e);if(!t)throw new dt(e);let s=[t.path,t.oldPath].filter((r)=>Boolean(r)),n=await H(this.root,Qn(this.state.info.baseSha,this.state.info.targetSha,s),this.git);return{revision:this.state.info.revision,file:{...t},patch:n}}async getFileContents(e){await this.ready;let t=await this.resolveComparison(De(e.comparison.mode==="merge-base"?`${e.comparison.from}...${e.comparison.to}`:`${e.comparison.from}..${e.comparison.to}`)),s=e.oldPath==null?void 0:Se(this.root,e.oldPath).relativePath,n=e.newPath==null?void 0:Se(this.root,e.newPath).relativePath,r=s==null||e.pureRename?null:{name:s,contents:await H(this.root,["show",`${t.baseSha}:${s}`],this.git)},i=null;if(n!=null){let o=e.includeUnstaged?await oa((await ds(this.root,n)).absolutePath,"utf8"):await H(this.root,["show",`${t.toSha}:${n}`],this.git);i={name:n,contents:o}}return{oldFile:r??(e.pureRename?null:{name:s??n,contents:""}),newFile:i??{name:n??s,contents:""}}}async openWorkingFile(e){await this.ready;let t=await ds(this.root,e.path);return er(e.line,"line"),er(e.column,"column"),await this.vscode({repositoryRoot:this.root,absolutePath:t.absolutePath,relativePath:t.relativePath,line:e.line,column:e.column,side:e.side,commit:e.side==="old"?this.state.info.baseSha:this.state.info.targetSha,baseSha:this.state.info.baseSha,headSha:this.state.info.targetSha}),{path:t.relativePath,absolutePath:t.absolutePath,...e.line===void 0?{}:{line:e.line},...e.column===void 0?{}:{column:e.column}}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}startWatching(e=this.options.watchIntervalMs??1000){if(this.watchTimer)return;this.watchTimer=setInterval(()=>{this.refresh().catch(()=>{})},e)}stopWatching(){if(!this.watchTimer)return;clearInterval(this.watchTimer),this.watchTimer=void 0}}function er(e,t){if(e!==void 0&&(!Number.isSafeInteger(e)||e<1))throw Error(`${t} must be a positive integer`)}function ut(e={}){return new nr(e)}import{createReadStream as hr,existsSync as pr}from"node:fs";import{stat as mr}from"node:fs/promises";import{createServer as Wa}from"node:http";import{dirname as Ha,extname as gr,isAbsolute as Ya,join as As,resolve as Rs}from"node:path";import{Readable as yt}from"node:stream";import{fileURLToPath as Ja}from"node:url";import{randomUUID as ha}from"node:crypto";import{mkdirSync as pa,realpathSync as ma}from"node:fs";import{homedir as hs}from"node:os";import{dirname as ga,join as de,resolve as mt}from"node:path";import{DatabaseSync as ya}from"node:sqlite";var ps=4,wa="reviewme";class Te extends Error{constructor(e){super(e);this.name="ReviewStoreError"}}class O extends Te{constructor(e){super(e);this.name="ReviewStoreValidationError"}}class D extends Te{constructor(e,t){super(`${e} not found: ${t}`);this.name="ReviewStoreNotFoundError"}}function ba(){let e=process.env.REVIEWME_DB;if(e)return mt(e);return de(_a(wa),"reviews.sqlite")}function _a(e){let t=process.env.REVIEWME_DATA_HOME;if(t)return de(mt(t),e);if(process.platform==="darwin")return de(hs(),"Library","Application Support",e);else if(process.platform==="win32")return de(process.env.APPDATA||process.env.LOCALAPPDATA||de(hs(),"AppData","Roaming"),e);else return de(process.env.XDG_DATA_HOME||de(hs(),".local","share"),e)}class _s{databasePath;database;statements=new Map;ownsDatabase;clock;idFactory;constructor(e={}){let t=typeof e==="string"?{filename:e}:e;if(this.clock=t.clock??(()=>new Date().toISOString()),this.idFactory=t.idFactory??ha,t.database)this.database=t.database,this.databasePath=t.filename??":memory:",this.ownsDatabase=!1;else{let s=t.filename??ba();if(s!==":memory:"&&s!=="")pa(ga(mt(s)),{recursive:!0});this.database=new ya(s),this.databasePath=s,this.ownsDatabase=!0}this.configureAndMigrate()}close(){if(this.statements.clear(),this.ownsDatabase)this.database.close()}getBrowserTabTitleMode(){return this.get("SELECT browser_tab_title FROM app_preferences WHERE id = 1")?.browser_tab_title??"branch"}setBrowserTabTitleMode(e){return this.run(`INSERT INTO app_preferences (id, browser_tab_title) VALUES (1, ?)
|
|
155
|
+
ON CONFLICT(id) DO UPDATE SET browser_tab_title = excluded.browser_tab_title`,[e]),e}getExitOnCloseSetting(){let e=this.get("SELECT exit_on_close_enabled, exit_on_close_after_seconds FROM app_preferences WHERE id = 1");return{enabled:e?.exit_on_close_enabled===1,afterSeconds:e?.exit_on_close_after_seconds??5}}setExitOnCloseSetting(e,t){if(!Number.isInteger(t)||t<0||t>2147483)throw new O("Exit-on-close delay must be an integer between 0 and 2147483 seconds");return this.run(`INSERT INTO app_preferences (id, browser_tab_title, exit_on_close_enabled, exit_on_close_after_seconds)
|
|
156
|
+
VALUES (1, 'branch', ?, ?)
|
|
157
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
158
|
+
exit_on_close_enabled = excluded.exit_on_close_enabled,
|
|
159
|
+
exit_on_close_after_seconds = excluded.exit_on_close_after_seconds`,[e?1:0,t]),{enabled:e,afterSeconds:t}}ensureRepository(e){let t=rr(e.canonicalRoot),s=this.timestamp(),n=this.getRepositoryByRoot(t);if(n){if(e.remoteOrigin!==void 0)this.run(`UPDATE repositories
|
|
155
160
|
SET remote_origin = ?, updated_at = ?
|
|
156
161
|
WHERE id = ?`,[e.remoteOrigin,s,n.id]);else this.run("UPDATE repositories SET updated_at = ? WHERE id = ?",[s,n.id]);return this.getRepository(n.id)}let r=this.newId();return this.run(`INSERT INTO repositories
|
|
157
162
|
(id, canonical_root, remote_origin, created_at, updated_at)
|
|
158
163
|
VALUES (?, ?, ?, ?, ?)`,[r,t,e.remoteOrigin??null,s,s]),this.getRepository(r)}getRepository(e){let t=this.get(`SELECT id, canonical_root, remote_origin, created_at, updated_at
|
|
159
164
|
FROM repositories WHERE id = ?`,[e]);return t?gs(t):null}getRepositoryByRoot(e){let t=rr(e),s=this.get(`SELECT id, canonical_root, remote_origin, created_at, updated_at
|
|
160
165
|
FROM repositories WHERE canonical_root = ?`,[t]);return s?gs(s):null}listRepositories(){return this.all(`SELECT id, canonical_root, remote_origin, created_at, updated_at
|
|
161
|
-
FROM repositories ORDER BY updated_at DESC, canonical_root ASC`).map(gs)}ensureSnapshot(e){let t=this.ensureRepository({canonicalRoot:e.canonicalRoot,remoteOrigin:e.remoteOrigin});Ta(e.comparisonMode);let s=ir(e.baseSha,"base SHA"),n=ir(e.headSha,"head SHA"),r=
|
|
166
|
+
FROM repositories ORDER BY updated_at DESC, canonical_root ASC`).map(gs)}ensureSnapshot(e){let t=this.ensureRepository({canonicalRoot:e.canonicalRoot,remoteOrigin:e.remoteOrigin});Ta(e.comparisonMode);let s=ir(e.baseSha,"base SHA"),n=ir(e.headSha,"head SHA"),r=ve(e.baseRef),i=ve(e.headRef),o=this.timestamp();this.run(`INSERT INTO review_snapshots
|
|
162
167
|
(id, repository_id, comparison_mode, base_ref, head_ref, base_sha, head_sha, created_at, updated_at)
|
|
163
168
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
164
169
|
ON CONFLICT(repository_id, comparison_mode, base_sha, head_sha)
|
|
@@ -179,10 +184,10 @@ Compare a branch with a local Git ref and open the review in your browser.
|
|
|
179
184
|
FROM review_snapshots ORDER BY updated_at DESC, created_at DESC`):this.all(`SELECT id, repository_id, comparison_mode, base_ref, head_ref, base_sha, head_sha, created_at, updated_at
|
|
180
185
|
FROM review_snapshots WHERE repository_id = ? ORDER BY updated_at DESC, created_at DESC`,[e])).map(ht)}setFileReviewed(e,t,s=!0){let n=this.normalizeSnapshotPath(e,t);if(!s)return this.run("DELETE FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,n]),null;let r=this.timestamp();return this.run(`INSERT INTO reviewed_files (snapshot_id, path, reviewed_at)
|
|
181
186
|
VALUES (?, ?, ?)
|
|
182
|
-
ON CONFLICT(snapshot_id, path) DO UPDATE SET reviewed_at = excluded.reviewed_at`,[e,n,r]),this.lookupReviewedFile(e,n)}setFilesReviewed(e,t,s=!0){let n=[...new Set(t.map((r)=>this.normalizeSnapshotPath(e,r)))];this.transaction(()=>{for(let r of n)this.setFileReviewed(e,r,s)})}markFileReviewed(e,t){let s=this.setFileReviewed(e,t,!0);if(!s)throw new Te("Unable to mark file reviewed");return s}unmarkFileReviewed(e,t){let s=this.normalizeSnapshotPath(e,t);return this.run("DELETE FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,s]).changes>0}toggleFileReviewed(e,t){let s=this.normalizeSnapshotPath(e,t);return this.transaction(()=>{if(this.lookupReviewedFile(e,s))return this.run("DELETE FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,s]),null;let r=this.timestamp();return this.run("INSERT INTO reviewed_files (snapshot_id, path, reviewed_at) VALUES (?, ?, ?)",[e,s,r]),this.lookupReviewedFile(e,s)})}isFileReviewed(e,t){let s=this.normalizeSnapshotPath(e,t);return this.lookupReviewedFile(e,s)!==null}getReviewedFile(e,t){let s=this.normalizeSnapshotPath(e,t),n=this.get("SELECT snapshot_id, path, reviewed_at FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,s]);return n?ys(n):null}listReviewedFiles(e){return this.requireSnapshotWithRepository(e),this.all("SELECT snapshot_id, path, reviewed_at FROM reviewed_files WHERE snapshot_id = ? ORDER BY path ASC",[e]).map(ys)}createThread(e){let t=this.normalizeAnchor(e.snapshotId,e.anchor),s=e.body===void 0?void 0:ft(e.body),n=
|
|
187
|
+
ON CONFLICT(snapshot_id, path) DO UPDATE SET reviewed_at = excluded.reviewed_at`,[e,n,r]),this.lookupReviewedFile(e,n)}setFilesReviewed(e,t,s=!0){let n=[...new Set(t.map((r)=>this.normalizeSnapshotPath(e,r)))];this.transaction(()=>{for(let r of n)this.setFileReviewed(e,r,s)})}markFileReviewed(e,t){let s=this.setFileReviewed(e,t,!0);if(!s)throw new Te("Unable to mark file reviewed");return s}unmarkFileReviewed(e,t){let s=this.normalizeSnapshotPath(e,t);return this.run("DELETE FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,s]).changes>0}toggleFileReviewed(e,t){let s=this.normalizeSnapshotPath(e,t);return this.transaction(()=>{if(this.lookupReviewedFile(e,s))return this.run("DELETE FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,s]),null;let r=this.timestamp();return this.run("INSERT INTO reviewed_files (snapshot_id, path, reviewed_at) VALUES (?, ?, ?)",[e,s,r]),this.lookupReviewedFile(e,s)})}isFileReviewed(e,t){let s=this.normalizeSnapshotPath(e,t);return this.lookupReviewedFile(e,s)!==null}getReviewedFile(e,t){let s=this.normalizeSnapshotPath(e,t),n=this.get("SELECT snapshot_id, path, reviewed_at FROM reviewed_files WHERE snapshot_id = ? AND path = ?",[e,s]);return n?ys(n):null}listReviewedFiles(e){return this.requireSnapshotWithRepository(e),this.all("SELECT snapshot_id, path, reviewed_at FROM reviewed_files WHERE snapshot_id = ? ORDER BY path ASC",[e]).map(ys)}createThread(e){let t=this.normalizeAnchor(e.snapshotId,e.anchor),s=e.body===void 0?void 0:ft(e.body),n=ve(e.title),r=this.newId(),i=this.newId(),o=this.timestamp();return this.transaction(()=>{if(this.requireSnapshot(e.snapshotId),this.run("INSERT INTO threads (id, snapshot_id, title, created_at, updated_at) VALUES (?, ?, ?, ?, ?)",[r,e.snapshotId,n,o,o]),this.insertAnchor(r,i,0,t,o),s!==void 0)this.run(`INSERT INTO messages
|
|
183
188
|
(id, thread_id, role, source, body, external_id, created_at, updated_at)
|
|
184
189
|
VALUES (?, ?, 'user', 'local', ?, NULL, ?, ?)`,[this.newId(),r,s,o,o])}),this.requireThreadDetails(r)}getThread(e){let t=this.get("SELECT id, snapshot_id, title, created_at, updated_at FROM threads WHERE id = ?",[e]);return t?this.composeThreadDetails(t):null}getThreadDetails(e){return this.getThread(e)}listThreads(e){return this.requireSnapshot(e),this.all(`SELECT id, snapshot_id, title, created_at, updated_at
|
|
185
|
-
FROM threads WHERE snapshot_id = ? ORDER BY updated_at DESC, created_at DESC`,[e]).map((t)=>this.composeThreadDetails(t))}updateThread(e,t){this.requireThread(e);let s=t.title===void 0?void 0:
|
|
190
|
+
FROM threads WHERE snapshot_id = ? ORDER BY updated_at DESC, created_at DESC`,[e]).map((t)=>this.composeThreadDetails(t))}updateThread(e,t){this.requireThread(e);let s=t.title===void 0?void 0:ve(t.title);if(s!==void 0)this.run("UPDATE threads SET title = ?, updated_at = ? WHERE id = ?",[s,this.timestamp(),e]);return this.requireThreadDetails(e)}deleteThread(e){return this.requireThread(e),this.run("DELETE FROM threads WHERE id = ?",[e]).changes>0}addAnchor(e,t){let s=this.requireThread(e),n=this.normalizeAnchor(s.snapshot_id,t),i=this.get("SELECT MAX(anchor_order) + 1 AS next_order FROM anchors WHERE thread_id = ?",[e])?.next_order??0,o=this.newId(),a=this.timestamp();return this.insertAnchor(e,o,i,n,a),this.touchThread(e,a),this.requireAnchor(o)}updateAnchor(e,t){let s=this.getAnchorWithSnapshot(e);if(!s)throw new D("Anchor",e);let n=this.normalizeAnchor(s.snapshot_id,t),r=this.timestamp();return this.run(`UPDATE anchors SET
|
|
186
191
|
kind = ?, path = ?, side = ?, start_line = ?, end_line = ?,
|
|
187
192
|
context_text = ?, context_fingerprint = ?, updated_at = ?
|
|
188
193
|
WHERE id = ?`,[n.kind,n.path,n.side,n.startLine,n.endLine,n.contextText??null,n.contextFingerprint??null,r,e]),this.touchThread(s.thread_id,r),this.requireAnchor(e)}deleteAnchor(e){let t=this.get(`SELECT id, thread_id, anchor_order, kind, path, side, start_line, end_line,
|
|
@@ -218,8 +223,8 @@ Compare a branch with a local Git ref and open the review in your browser.
|
|
|
218
223
|
external_thread_id = ?, model = ?, reasoning_effort = ?, permission_mode = ?,
|
|
219
224
|
status = ?, status_message = ?, last_event_at = ?, updated_at = ?
|
|
220
225
|
WHERE id = ?`,[t.externalThreadId===void 0?s.externalThreadId:t.externalThreadId,t.model===void 0?s.model:t.model,t.reasoningEffort===void 0?s.reasoningEffort:t.reasoningEffort,t.permissionMode===void 0?s.permissionMode:t.permissionMode,t.status===void 0?s.status:t.status,t.statusMessage===void 0?s.statusMessage:t.statusMessage,t.lastEventAt===void 0?s.lastEventAt:t.lastEventAt,n,e]),this.requireAgentSession(e)}linkAgentSession(e,t,s){this.requireThread(e),this.requireAgentSession(t);let n=this.get(`SELECT thread_id, agent_session_id, session_order, created_at
|
|
221
|
-
FROM thread_agent_sessions WHERE thread_id = ? AND agent_session_id = ?`,[e,t]);if(n){if(s!==void 0&&(!Number.isInteger(s)||s<0))throw new
|
|
222
|
-
FROM thread_agent_sessions WHERE thread_id = ? AND agent_session_id = ?`,[e,t]))}let r=s??(this.get("SELECT MAX(session_order) + 1 AS next_order FROM thread_agent_sessions WHERE thread_id = ?",[e])?.next_order??0);if(!Number.isInteger(r)||r<0)throw new
|
|
226
|
+
FROM thread_agent_sessions WHERE thread_id = ? AND agent_session_id = ?`,[e,t]);if(n){if(s!==void 0&&(!Number.isInteger(s)||s<0))throw new O("Agent-session order must be a non-negative integer");if(s!==void 0&&s!==n.session_order)this.run("UPDATE thread_agent_sessions SET session_order = ? WHERE thread_id = ? AND agent_session_id = ?",[s,e,t]);return bs(this.get(`SELECT thread_id, agent_session_id, session_order, created_at
|
|
227
|
+
FROM thread_agent_sessions WHERE thread_id = ? AND agent_session_id = ?`,[e,t]))}let r=s??(this.get("SELECT MAX(session_order) + 1 AS next_order FROM thread_agent_sessions WHERE thread_id = ?",[e])?.next_order??0);if(!Number.isInteger(r)||r<0)throw new O("Agent-session order must be a non-negative integer");let i=this.timestamp();return this.run(`INSERT INTO thread_agent_sessions (thread_id, agent_session_id, session_order, created_at)
|
|
223
228
|
VALUES (?, ?, ?, ?)`,[e,t,r,i]),bs(this.get(`SELECT thread_id, agent_session_id, session_order, created_at
|
|
224
229
|
FROM thread_agent_sessions WHERE thread_id = ? AND agent_session_id = ?`,[e,t]))}unlinkAgentSession(e,t){return this.requireThread(e),this.run("DELETE FROM thread_agent_sessions WHERE thread_id = ? AND agent_session_id = ?",[e,t]).changes>0}listAgentSessionsForThread(e){return this.requireThread(e),this.all(`SELECT s.id, s.provider, s.external_thread_id, s.model, s.reasoning_effort,
|
|
225
230
|
s.permission_mode, s.status, s.status_message, s.last_event_at,
|
|
@@ -228,7 +233,7 @@ Compare a branch with a local Git ref and open the review in your browser.
|
|
|
228
233
|
JOIN thread_agent_sessions ts ON ts.agent_session_id = s.id
|
|
229
234
|
WHERE ts.thread_id = ?
|
|
230
235
|
ORDER BY ts.session_order ASC, s.created_at ASC`,[e]).map(pt)}listThreadAgentLinks(e){return this.requireThread(e),this.all(`SELECT thread_id, agent_session_id, session_order, created_at
|
|
231
|
-
FROM thread_agent_sessions WHERE thread_id = ? ORDER BY session_order ASC`,[e]).map(bs)}addAgentContext(e){this.requireAgentSession(e.agentSessionId);let t=this.normalizeAnchor(e.snapshotId,e.anchor);if(e.sourceThreadId!=null){if(this.requireThread(e.sourceThreadId).snapshot_id!==e.snapshotId)throw new
|
|
236
|
+
FROM thread_agent_sessions WHERE thread_id = ? ORDER BY session_order ASC`,[e]).map(bs)}addAgentContext(e){this.requireAgentSession(e.agentSessionId);let t=this.normalizeAnchor(e.snapshotId,e.anchor);if(e.sourceThreadId!=null){if(this.requireThread(e.sourceThreadId).snapshot_id!==e.snapshotId)throw new O("Agent context and source thread must belong to the same snapshot")}let s=this.newId(),n=this.timestamp();return this.run(`INSERT INTO agent_session_contexts
|
|
232
237
|
(id, agent_session_id, snapshot_id, source_thread_id, anchor_kind, path, side,
|
|
233
238
|
start_line, end_line, context_text, context_fingerprint, prompt, created_at)
|
|
234
239
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,[s,e.agentSessionId,e.snapshotId,e.sourceThreadId??null,t.kind,t.path,t.side,t.startLine,t.endLine,t.contextText??null,t.contextFingerprint??null,ft(e.prompt),n]),this.requireAgentContext(s)}listAgentConversations(e){return this.requireSnapshot(e),this.all(`SELECT DISTINCT s.id, s.provider, s.external_thread_id, s.model, s.reasoning_effort,
|
|
@@ -243,7 +248,7 @@ Compare a branch with a local Git ref and open the review in your browser.
|
|
|
243
248
|
WHERE agent_session_id = ? AND snapshot_id = ? LIMIT 1`,[e,t]))return!1;return this.run("DELETE FROM agent_sessions WHERE id = ?",[e]).changes>0}configureAndMigrate(){if(this.run("PRAGMA foreign_keys = ON"),this.run("PRAGMA busy_timeout = 5000"),this.databasePath!==":memory:")this.run("PRAGMA journal_mode = WAL");let t=this.get("PRAGMA user_version")?.user_version??0;if(t>ps)throw new Te(`Review database version ${t} is newer than supported version ${ps}.
|
|
244
249
|
|
|
245
250
|
This usually means an older ReviewMe is running. Update and try again:
|
|
246
|
-
npx reviewme@latest`);if(t===ps)return;this.transaction(()=>{if(t<1){for(let s of Sa)this.run(s);this.run("PRAGMA user_version = 1")}if(t<2){for(let s of
|
|
251
|
+
npx reviewme@latest`);if(t===ps)return;this.transaction(()=>{if(t<1){for(let s of Sa)this.run(s);this.run("PRAGMA user_version = 1")}if(t<2){for(let s of Ea)this.run(s);this.run(`INSERT OR IGNORE INTO agent_session_contexts
|
|
247
252
|
(id, agent_session_id, snapshot_id, source_thread_id, anchor_kind, path, side,
|
|
248
253
|
start_line, end_line, context_text, context_fingerprint, prompt, created_at)
|
|
249
254
|
SELECT lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' ||
|
|
@@ -254,9 +259,9 @@ This usually means an older ReviewMe is running. Update and try again:
|
|
|
254
259
|
FROM thread_agent_sessions ts
|
|
255
260
|
JOIN threads t ON t.id = ts.thread_id
|
|
256
261
|
JOIN anchors a ON a.thread_id = t.id AND a.anchor_order = 0
|
|
257
|
-
LEFT JOIN messages m ON m.thread_id = t.id AND m.source = 'local'`),this.run("PRAGMA user_version = 2")}if(t<3){for(let s of
|
|
262
|
+
LEFT JOIN messages m ON m.thread_id = t.id AND m.source = 'local'`),this.run("PRAGMA user_version = 2")}if(t<3){for(let s of va)this.run(s);this.run("PRAGMA user_version = 3")}if(t<4)this.run("ALTER TABLE app_preferences ADD COLUMN exit_on_close_enabled INTEGER NOT NULL DEFAULT 0 CHECK (exit_on_close_enabled IN (0, 1))"),this.run("ALTER TABLE app_preferences ADD COLUMN exit_on_close_after_seconds INTEGER NOT NULL DEFAULT 5 CHECK (exit_on_close_after_seconds >= 0 AND exit_on_close_after_seconds <= 2147483)"),this.run("PRAGMA user_version = 4")})}timestamp(){let e=this.clock();if(typeof e!=="string"||!e)throw new O("Clock must return a non-empty timestamp");return e}newId(){let e=this.idFactory();if(typeof e!=="string"||!e)throw new O("ID factory must return a non-empty string");return e}transaction(e){this.run("BEGIN IMMEDIATE");try{let t=e();return this.run("COMMIT"),t}catch(t){try{this.run("ROLLBACK")}catch{}throw t}}run(e,t=[]){return this.prepare(e).run(...ms(t))}get(e,t=[]){let s=this.prepare(e).get(...ms(t));return s===void 0?null:s}all(e,t=[]){return this.prepare(e).all(...ms(t))}prepare(e){let t=this.statements.get(e);if(t)return t;let s=this.database.prepare(e);return this.statements.set(e,s),s}requireSnapshot(e){let t=this.getSnapshot(e);if(!t)throw new D("Review snapshot",e);return t}requireSnapshotWithRepository(e){let t=this.getSnapshotWithRepository(e);if(!t)throw new D("Review snapshot",e);return t}findSnapshotByIdentity(e,t,s,n){let r=this.get(`SELECT id, repository_id, comparison_mode, base_ref, head_ref, base_sha, head_sha, created_at, updated_at
|
|
258
263
|
FROM review_snapshots
|
|
259
|
-
WHERE repository_id = ? AND comparison_mode = ? AND base_sha = ? AND head_sha = ?`,[e,t,s,n]);return r?ht(r):null}normalizeSnapshotPath(e,t){let s=this.requireSnapshotWithRepository(e);try{return Se(s.repository.canonicalRoot,t).relativePath}catch(n){throw new
|
|
264
|
+
WHERE repository_id = ? AND comparison_mode = ? AND base_sha = ? AND head_sha = ?`,[e,t,s,n]);return r?ht(r):null}normalizeSnapshotPath(e,t){let s=this.requireSnapshotWithRepository(e);try{return Se(s.repository.canonicalRoot,t).relativePath}catch(n){throw new O(n instanceof Error?n.message:String(n))}}normalizeAnchor(e,t){let s=this.normalizeSnapshotPath(e,t.path),n=t.kind;if(n!=="file"&&n!=="diff_range")throw new O("Anchor kind must be `file` or `diff_range`");let r=t.side??null,i=t.startLine??null,o=t.endLine??null;if(n==="file"){if(r!==null||i!==null||o!==null)throw new O("File anchors cannot include a diff side or line range")}else{if(r!=="old"&&r!=="new")throw new O("Diff anchors require an `old` or `new` side");if(!or(i)||!or(o)||o<i)throw new O("Diff anchors require a valid positive line range")}return{kind:n,path:s,side:r,startLine:i,endLine:o,contextText:ve(t.contextText),contextFingerprint:ve(t.contextFingerprint)}}insertAnchor(e,t,s,n,r){this.run(`INSERT INTO anchors
|
|
260
265
|
(id, thread_id, anchor_order, kind, path, side, start_line, end_line,
|
|
261
266
|
context_text, context_fingerprint, created_at, updated_at)
|
|
262
267
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,[t,e,s,n.kind,n.path,n.side,n.startLine,n.endLine,n.contextText??null,n.contextFingerprint??null,r,r])}requireThread(e){let t=this.get("SELECT id, snapshot_id, title, created_at, updated_at FROM threads WHERE id = ?",[e]);if(!t)throw new D("Review thread",e);return t}requireThreadDetails(e){let t=this.getThread(e);if(!t)throw new D("Review thread",e);return t}requireAgentContext(e){let t=this.get(`SELECT id, agent_session_id, snapshot_id, source_thread_id, anchor_kind, path, side,
|
|
@@ -373,7 +378,7 @@ This usually means an older ReviewMe is running. Update and try again:
|
|
|
373
378
|
created_at TEXT NOT NULL,
|
|
374
379
|
PRIMARY KEY(thread_id, agent_session_id),
|
|
375
380
|
UNIQUE(thread_id, session_order)
|
|
376
|
-
)`,"CREATE INDEX idx_review_snapshots_repository ON review_snapshots(repository_id, updated_at DESC)","CREATE INDEX idx_reviewed_files_snapshot ON reviewed_files(snapshot_id, path)","CREATE INDEX idx_threads_snapshot ON threads(snapshot_id, updated_at DESC)","CREATE INDEX idx_anchors_thread ON anchors(thread_id, anchor_order)","CREATE INDEX idx_messages_thread ON messages(thread_id, created_at)","CREATE INDEX idx_drafts_snapshot ON drafts(snapshot_id, updated_at DESC)","CREATE INDEX idx_thread_agent_sessions_thread ON thread_agent_sessions(thread_id, session_order)"],
|
|
381
|
+
)`,"CREATE INDEX idx_review_snapshots_repository ON review_snapshots(repository_id, updated_at DESC)","CREATE INDEX idx_reviewed_files_snapshot ON reviewed_files(snapshot_id, path)","CREATE INDEX idx_threads_snapshot ON threads(snapshot_id, updated_at DESC)","CREATE INDEX idx_anchors_thread ON anchors(thread_id, anchor_order)","CREATE INDEX idx_messages_thread ON messages(thread_id, created_at)","CREATE INDEX idx_drafts_snapshot ON drafts(snapshot_id, updated_at DESC)","CREATE INDEX idx_thread_agent_sessions_thread ON thread_agent_sessions(thread_id, session_order)"],Ea=[`CREATE TABLE IF NOT EXISTS agent_session_contexts (
|
|
377
382
|
id TEXT PRIMARY KEY,
|
|
378
383
|
agent_session_id TEXT NOT NULL REFERENCES agent_sessions(id) ON DELETE CASCADE,
|
|
379
384
|
snapshot_id TEXT NOT NULL REFERENCES review_snapshots(id) ON DELETE CASCADE,
|
|
@@ -389,25 +394,25 @@ This usually means an older ReviewMe is running. Update and try again:
|
|
|
389
394
|
created_at TEXT NOT NULL,
|
|
390
395
|
CHECK ((anchor_kind = 'file' AND side IS NULL AND start_line IS NULL AND end_line IS NULL)
|
|
391
396
|
OR (anchor_kind = 'diff_range' AND side IS NOT NULL AND start_line > 0 AND end_line >= start_line))
|
|
392
|
-
)`,"CREATE INDEX IF NOT EXISTS idx_agent_contexts_snapshot ON agent_session_contexts(snapshot_id, created_at DESC)","CREATE INDEX IF NOT EXISTS idx_agent_contexts_session ON agent_session_contexts(agent_session_id, created_at)"],
|
|
397
|
+
)`,"CREATE INDEX IF NOT EXISTS idx_agent_contexts_snapshot ON agent_session_contexts(snapshot_id, created_at DESC)","CREATE INDEX IF NOT EXISTS idx_agent_contexts_session ON agent_session_contexts(agent_session_id, created_at)"],va=[`CREATE TABLE IF NOT EXISTS app_preferences (
|
|
393
398
|
id INTEGER PRIMARY KEY CHECK (id = 1),
|
|
394
399
|
browser_tab_title TEXT NOT NULL DEFAULT 'branch'
|
|
395
400
|
CHECK (browser_tab_title IN ('repository', 'directory', 'branch', 'diff'))
|
|
396
|
-
)`];function rr(e){if(typeof e!=="string"||!e.trim())throw new
|
|
397
|
-
`)}function Ua(e){let t=Array.isArray(e.turns)?e.turns:[],s=[];for(let n of t){if(!n||typeof n!=="object")continue;let r=n,i=M(r.id)??null;if(!Array.isArray(r.items))continue;for(let o of r.items){if(!o||typeof o!=="object")continue;let a=o,l=M(a.id);if(!l)continue;if(a.type==="userMessage"){let c=$a(a.content);if(c)s.push({id:l,turnId:i,role:"user",text:c})}else if(a.type==="agentMessage"&&typeof a.text==="string")s.push({id:l,turnId:i,role:"assistant",text:a.text})}}return s}function Ba(e){return e??"read-only"}function ur(e){if(Ba(e)!=="read-only")throw new
|
|
398
|
-
`);if(Ss(s))await s;let n=e.process.stdin.flush?.();if(Ss(n))await n}async sendNotification(e,t,s){await this.writeMessage(e,{method:t,...s===void 0?{}:{params:s}})}async ensureConnection(){if(this.closed)throw new
|
|
401
|
+
)`];function rr(e){if(typeof e!=="string"||!e.trim())throw new O("Repository root is required");try{return ma(mt(e))}catch(t){throw new O(`Repository root does not exist: ${e}`)}}function ir(e,t){if(typeof e!=="string"||!e.trim()||/[\0\r\n]/.test(e))throw new O(`${t} is required`);return e}function ve(e){if(e===void 0||e===null)return null;if(typeof e!=="string")throw new O("Text fields must be strings");if(/\0/.test(e))throw new O("Text fields cannot contain NUL bytes");return e}function ms(e){return e.map((t)=>{if(t===void 0)return null;if(typeof t==="boolean")return t?1:0;return t})}function ft(e){if(typeof e!=="string"||!e.trim())throw new O("Comment body cannot be empty");if(/\0/.test(e))throw new O("Comment body cannot contain NUL bytes");return e}function or(e){return e!==null&&Number.isSafeInteger(e)&&e>0}function Ta(e){if(e!=="merge-base"&&e!=="direct")throw new O("Comparison mode must be `merge-base` or `direct`")}function Aa(e){if(e!=="user"&&e!=="assistant"&&e!=="system")throw new O("Message role is invalid")}function gs(e){return{id:e.id,canonicalRoot:e.canonical_root,remoteOrigin:e.remote_origin,createdAt:e.created_at,updatedAt:e.updated_at}}function ht(e){return{id:e.id,repositoryId:e.repository_id,comparisonMode:e.comparison_mode,baseRef:e.base_ref,headRef:e.head_ref,baseSha:e.base_sha,headSha:e.head_sha,createdAt:e.created_at,updatedAt:e.updated_at}}function ys(e){return{snapshotId:e.snapshot_id,path:e.path,reviewedAt:e.reviewed_at}}function Ra(e){return{id:e.id,snapshotId:e.snapshot_id,title:e.title,createdAt:e.created_at,updatedAt:e.updated_at}}function ar(e){return{id:e.id,threadId:e.thread_id,order:e.anchor_order,kind:e.kind,path:e.path,side:e.side,startLine:e.start_line,endLine:e.end_line,contextText:e.context_text,contextFingerprint:e.context_fingerprint,createdAt:e.created_at,updatedAt:e.updated_at}}function ws(e){return{id:e.id,threadId:e.thread_id,role:e.role,source:e.source,body:e.body,externalId:e.external_id,createdAt:e.created_at,updatedAt:e.updated_at}}function lr(e){return{id:e.id,snapshotId:e.snapshot_id,anchor:{kind:e.anchor_kind,path:e.path,side:e.side,startLine:e.start_line,endLine:e.end_line,contextText:e.context_text,contextFingerprint:e.context_fingerprint},body:e.body,createdAt:e.created_at,updatedAt:e.updated_at}}function pt(e){return{id:e.id,provider:e.provider,externalThreadId:e.external_thread_id,model:e.model,reasoningEffort:e.reasoning_effort,permissionMode:e.permission_mode,status:e.status,statusMessage:e.status_message,lastEventAt:e.last_event_at,createdAt:e.created_at,updatedAt:e.updated_at}}function bs(e){return{threadId:e.thread_id,agentSessionId:e.agent_session_id,order:e.session_order,createdAt:e.created_at}}function cr(e){return{id:e.id,agentSessionId:e.agent_session_id,snapshotId:e.snapshot_id,sourceThreadId:e.source_thread_id,anchor:{kind:e.anchor_kind,path:e.path,side:e.side,startLine:e.start_line,endLine:e.end_line,contextText:e.context_text,contextFingerprint:e.context_fingerprint},prompt:e.prompt,createdAt:e.created_at}}import{spawn as Ca}from"node:child_process";import{Readable as dr}from"node:stream";var Na="codex",xa="reviewme",Oa="0.1.0",La=8388608,ka=8192,Ia=1000;class L extends Error{code;retryable;constructor(e,t,s={}){super(t,s.cause===void 0?void 0:{cause:s.cause});this.name="CodexAgentProviderError",this.code=e,this.retryable=s.retryable??e==="disconnected"}}class fr{values=[];waiters=[];done=!1;failure;push(e){if(this.done)return;let t=this.waiters.shift();if(t)t.resolve({done:!1,value:e});else this.values.push(e)}close(){if(this.done)return;this.done=!0;while(this.waiters.length>0)this.waiters.shift()?.resolve({done:!0,value:void 0})}fail(e){if(this.done)return;this.done=!0,this.failure=e;while(this.waiters.length>0)this.waiters.shift()?.reject(e)}async next(){if(this.values.length>0)return{done:!1,value:this.values.shift()};if(this.done){if(this.failure!==void 0)throw this.failure;return{done:!0,value:void 0}}return new Promise((e,t)=>{this.waiters.push({resolve:e,reject:t})})}async return(){return this.close(),{done:!0,value:void 0}}[Symbol.asyncIterator](){return this}}function Pa(e,t){return new Promise((s,n)=>{let r=()=>{e.off("drain",i),e.off("error",o),e.off("close",a)},i=()=>{r(),s(t)},o=(l)=>{r(),n(l)},a=()=>{r(),n(Error("Codex stdin closed before the request was flushed"))};e.once("drain",i),e.once("error",o),e.once("close",a)})}function Ma(e){return{write(t){let s=typeof t==="string"?Buffer.from(t):Buffer.from(t);return e.write(s)?s.byteLength:Pa(e,s.byteLength)},end(){e.end()}}}function Da(e){let[t,...s]=e;if(!t)throw Error("Codex command cannot be empty");let n=Ca(t,s,{stdio:["pipe","pipe","pipe"]});if(!n.stdin||!n.stdout||!n.stderr)throw n.kill(),Error("Codex app-server did not provide piped stdio");let r=new Promise((o,a)=>{let l=()=>{n.off("error",c),o()},c=(p)=>{n.off("spawn",l),a(p)};n.once("spawn",l),n.once("error",c)}),i=new Promise((o)=>{let a=()=>{n.off("close",l),o(-1)},l=(c)=>{n.off("error",a),o(c??1)};n.once("error",a),n.once("close",l)});return{stdin:Ma(n.stdin),stdout:dr.toWeb(n.stdout),stderr:dr.toWeb(n.stderr),exited:i,ready:r,kill(o){n.kill(o)}}}function fe(e,t){if(!e||typeof e!=="object"||Array.isArray(e))throw new L("protocol",`Codex returned an invalid ${t}`);return e}function M(e){return typeof e==="string"&&e.length>0?e:void 0}function Es(e,t){let s=M(e);if(!s)throw new L("protocol",`Codex response is missing ${t}`);return s}function ue(e){if(e instanceof Error)return e.message;return String(e)}function qa(e){return/auth|login|log in|unauthori[sz]ed|credential|token/i.test(e)}function Fa(e,t){if(qa(e))return new L("not-authenticated",`Codex is not authenticated. Run codex login, then retry. (${e})`,{retryable:!1,cause:t});return new L("request-failed",e,{retryable:!0,cause:t})}function Ss(e){return!!e&&typeof e==="object"&&"then"in e&&typeof e.then==="function"}function $a(e){if(!Array.isArray(e))return"";return e.map((t)=>{let s=t&&typeof t==="object"?t:void 0;return typeof s?.text==="string"?s.text:""}).filter(Boolean).join(`
|
|
402
|
+
`)}function Ua(e){let t=Array.isArray(e.turns)?e.turns:[],s=[];for(let n of t){if(!n||typeof n!=="object")continue;let r=n,i=M(r.id)??null;if(!Array.isArray(r.items))continue;for(let o of r.items){if(!o||typeof o!=="object")continue;let a=o,l=M(a.id);if(!l)continue;if(a.type==="userMessage"){let c=$a(a.content);if(c)s.push({id:l,turnId:i,role:"user",text:c})}else if(a.type==="agentMessage"&&typeof a.text==="string")s.push({id:l,turnId:i,role:"assistant",text:a.text})}}return s}function Ba(e){return e??"read-only"}function ur(e){if(Ba(e)!=="read-only")throw new L("unsupported","Codex sessions are read-only in this version of ReviewMe",{retryable:!1})}function ja(e){if(e==="completed"||e==="interrupted"||e==="failed"||e==="inProgress")return e==="inProgress"?"in-progress":e;return typeof e==="string"?e:"completed"}function Ka(e){let t=fe(e,"model"),s=Es(t.id??t.model,"model id"),n=Array.isArray(t.supportedReasoningEfforts)?t.supportedReasoningEfforts.map((r)=>{if(!r||typeof r!=="object")return;let i=r,o=M(i.reasoningEffort??i.reasoning_effort);return o?{value:o,description:typeof i.description==="string"?i.description:""}:void 0}).filter((r)=>r!==void 0):[];return{id:s,displayName:M(t.displayName??t.display_name)??s,description:typeof t.description==="string"?t.description:"",hidden:t.hidden===!0,isDefault:t.isDefault===!0||t.is_default===!0,defaultReasoningEffort:M(t.defaultReasoningEffort??t.default_reasoning_effort)??null,supportedReasoningEfforts:n}}class vs{id="codex";command;clientName;clientVersion;processFactory;connection;starting;everStarted=!1;restartUsed=!1;closed=!1;sessions=new Map;activeTurns=new Map;constructor(e={}){this.command=e.command??Na,this.clientName=e.clientName??xa,this.clientVersion=e.clientVersion??Oa,this.processFactory=e.processFactory??Da}async listModels(){let e,t=[],s=new Set;do{let n={includeHidden:!1,limit:100};if(e)n.cursor=e;let r=fe(await this.request("model/list",n),"model list response");if(!Array.isArray(r.data))throw new L("protocol","Codex model list response is missing data");for(let o of r.data)t.push(Ka(o));let i=M(r.nextCursor??r.next_cursor);if(!i)break;if(s.has(i))throw new L("protocol","Codex model list returned a repeated cursor");s.add(i),e=i}while(!0);return t}async startThread(e){ur(e.permissionMode),this.ensureCwd(e.cwd);let t={cwd:e.cwd,approvalPolicy:"never",sandbox:"read-only"};if(e.model)t.model=e.model;if(e.serviceTier)t.serviceTier=e.serviceTier;let s=fe(await this.request("thread/start",t),"thread start response");return this.threadResult(s,e)}async resumeThread(e){if(ur(e.permissionMode),this.ensureCwd(e.cwd),!e.externalThreadId.trim())throw new L("invalid","A Codex thread id is required to resume a thread",{retryable:!1});let t={threadId:e.externalThreadId,cwd:e.cwd,approvalPolicy:"never",sandbox:"read-only",excludeTurns:!1};if(e.model)t.model=e.model;let s=fe(await this.request("thread/resume",t),"thread resume response");return this.threadResult(s,e)}async sendMessage(e,t){if(!e.trim())throw new L("invalid","A Codex thread id is required to send a message",{retryable:!1});if(!t.text.trim())throw new L("invalid","A Codex message cannot be empty",{retryable:!1});if(this.activeTurns.has(e))throw new L("invalid","This Codex thread already has an active turn",{retryable:!1});let s=await this.ensureConnection(),n=new fr,r={sessionId:e,connection:s,queue:n,turnId:void 0,startedEmitted:!1};this.activeTurns.set(e,r);let i={threadId:e,input:[{type:"text",text:t.text,text_elements:[]}]},o=this.sessions.get(e),a=t.reasoningEffort??o?.reasoningEffort;if(a)i.effort=a;try{let l=fe(await this.requestOnConnection(s,"turn/start",i),"turn start response"),c=fe(l.turn,"turn");if(r.turnId=Es(c.id,"turn id"),!r.startedEmitted)r.startedEmitted=!0,n.push({type:"started",sessionId:e,turnId:r.turnId});let p=this.sessions.get(e);if(p)this.sessions.set(e,{...p,status:"running"});return{turnId:r.turnId,events:n,stop:()=>this.stop(e,r.turnId)}}catch(l){if(this.activeTurns.get(e)===r)this.activeTurns.delete(e);throw n.fail(l),l}}async stop(e,t){let s=this.activeTurns.get(e),n=t??s?.turnId;if(!n)return;let r=s?.connection??await this.ensureConnection();if(await this.requestOnConnection(r,"turn/interrupt",{threadId:e,turnId:n}),s&&s.turnId===n){s.queue.push({type:"stopped",sessionId:e,turnId:n}),s.queue.close(),this.activeTurns.delete(e);let i=this.sessions.get(e);if(i)this.sessions.set(e,{...i,status:"ready"})}}async close(){if(this.closed)return;this.closed=!0;let e=this.connection;if(e){this.handleConnectionClosed(e,"Codex provider closed");try{let t=e.process.stdin.end?.();if(Ss(t))await t}catch{}try{e.process.kill()}catch{}await Promise.race([e.process.exited.catch(()=>-1),new Promise((t)=>setTimeout(()=>t(-1),Ia))])}if(this.starting)try{await this.starting}catch{}}ensureCwd(e){if(!e||typeof e!=="string")throw new L("invalid","A repository working directory is required",{retryable:!1})}threadResult(e,t){let s=fe(e.thread,"thread"),n=Es(s.id,"thread id"),r=M(e.cwd)??t.cwd,i=M(e.model)??t.model??null,o=t.reasoningEffort??M(e.reasoningEffort??e.reasoning_effort)??null,a={id:n,provider:this.id,externalThreadId:n,cwd:r,model:i,reasoningEffort:o,permissionMode:"read-only",status:"ready"};return this.sessions.set(n,a),{session:a,history:Ua(s)}}async request(e,t){let s=await this.ensureConnection();return this.requestOnConnection(s,e,t)}async requestOnConnection(e,t,s){if(e.closed)throw new L("disconnected","The Codex app-server connection is closed");let n=String(e.nextRequestId++),r=new Promise((i,o)=>{e.pending.set(n,{method:t,resolve:i,reject:o})});try{await this.writeMessage(e,{id:Number(n),method:t,params:s})}catch(i){e.pending.delete(n);let o=i instanceof L?i:new L("disconnected",`Unable to send ${t} to Codex: ${ue(i)}`,{cause:i});throw this.handleConnectionClosed(e,o.message),o}return r}async writeMessage(e,t){if(e.closed)throw new L("disconnected","The Codex app-server connection is closed");let s=e.process.stdin.write(`${JSON.stringify(t)}
|
|
403
|
+
`);if(Ss(s))await s;let n=e.process.stdin.flush?.();if(Ss(n))await n}async sendNotification(e,t,s){await this.writeMessage(e,{method:t,...s===void 0?{}:{params:s}})}async ensureConnection(){if(this.closed)throw new L("disconnected","The Codex provider has been closed",{retryable:!1});if(this.starting)return this.starting;if(this.connection&&!this.connection.closed)return this.connection;if(this.everStarted&&this.restartUsed)throw new L("disconnected","The Codex app-server disconnected and its one automatic restart was already used");if(this.everStarted)this.restartUsed=!0;let e=this.openConnection();this.starting=e;try{return await e}finally{if(this.starting===e)this.starting=void 0}}async openConnection(){let e;try{if(e=this.processFactory([this.command,"app-server","--stdio"]),e.ready)await e.ready}catch(s){let n=ue(s),r=/ENOENT|not found|cannot find/i.test(n)?"missing":"disconnected";throw new L(r,r==="missing"?`Codex CLI was not found at ${this.command}. Install Codex or configure its executable.`:`Unable to start Codex app-server: ${n}`,{cause:s,retryable:r==="disconnected"})}this.everStarted=!0;let t={process:e,pending:new Map,nextRequestId:1,closed:!1,stderrTail:""};if(this.connection=t,this.consumeStdout(t),e.stderr)this.consumeStderr(t);e.exited.then((s)=>{if(!t.closed)this.handleConnectionClosed(t,`Codex app-server exited with code ${s}${t.stderrTail?`: ${t.stderrTail}`:""}`)}).catch((s)=>{if(!t.closed)this.handleConnectionClosed(t,`Codex app-server exited unexpectedly: ${ue(s)}`)});try{return await this.requestOnConnection(t,"initialize",{clientInfo:{name:this.clientName,title:"ReviewMe",version:this.clientVersion},capabilities:{experimentalApi:!0,requestAttestation:!1}}),await this.sendNotification(t,"initialized"),t}catch(s){if(!t.closed){try{t.process.kill()}catch{}this.handleConnectionClosed(t,ue(s))}throw s instanceof L?s:new L("disconnected",`Codex initialization failed: ${ue(s)}`,{cause:s})}}async consumeStdout(e){let t=e.process.stdout.getReader(),s=new TextDecoder,n="";try{while(!e.closed){let{done:i,value:o}=await t.read();if(i)break;if(n+=s.decode(o,{stream:!0}),new TextEncoder().encode(n).byteLength>La){this.handleConnectionClosed(e,"Codex protocol line exceeded the maximum size");return}let a=n.indexOf(`
|
|
399
404
|
`);while(a>=0){let l=n.slice(0,a).replace(/\r$/,"");if(n=n.slice(a+1),l.trim())this.handleProtocolLine(e,l);a=n.indexOf(`
|
|
400
|
-
`)}}let r=n+s.decode();if(r.trim()&&!e.closed)this.handleProtocolLine(e,r.trim())}catch(r){if(!e.closed)this.handleConnectionClosed(e,`Codex output could not be read: ${ue(r)}`)}finally{t.releaseLock()}}async consumeStderr(e){if(!e.process.stderr)return;let t=e.process.stderr.getReader(),s=new TextDecoder;try{while(!e.closed){let{done:n,value:r}=await t.read();if(n)break;e.stderrTail=`${e.stderrTail}${s.decode(r,{stream:!0})}`.slice(-ka)}}catch{}finally{t.releaseLock()}}handleProtocolLine(e,t){let s;try{s=JSON.parse(t)}catch(o){this.handleConnectionClosed(e,`Codex returned invalid JSON: ${ue(o)}`);return}if(!s||typeof s!=="object"||Array.isArray(s)){this.handleConnectionClosed(e,"Codex returned a non-object JSON message");return}let n=s,r=n.id;if(typeof n.method==="string"){if(r!==void 0)this.writeMessage(e,{id:typeof r==="number"||typeof r==="string"?r:String(r),error:{code:-32001,message:"ReviewMe does not permit Codex approval or input requests"}}).catch(()=>{if(!e.closed)this.handleConnectionClosed(e,"Unable to reject a Codex server request")});else this.handleNotification(n.method,n.params);return}if(r===void 0)return;let i=e.pending.get(String(r));if(!i)return;if(e.pending.delete(String(r)),Object.prototype.hasOwnProperty.call(n,"error")){let o=n.error&&typeof n.error==="object"?n.error:{},a=M(o.message)??"Codex request failed";i.reject(Fa(`${i.method}: ${a}`,o));return}i.resolve(n.result)}handleNotification(e,t){let s=t&&typeof t==="object"?t:{},n=M(s.threadId),r=n?this.activeTurns.get(n):void 0;if(e==="thread/status/changed"&&n){let o=this.sessions.get(n);if(o){let a=s.status&&typeof s.status==="object"?s.status:{},l=M(a.type);this.sessions.set(n,{...o,status:l==="active"?"running":l==="systemError"?"disconnected":"ready"})}return}if(!r)return;let i=M(s.turnId)??r.turnId;if(i)r.turnId=i;if(e==="turn/started"){if(!r.startedEmitted&&r.turnId)r.startedEmitted=!0,r.queue.push({type:"started",sessionId:r.sessionId,turnId:r.turnId});return}if(e==="item/agentMessage/delta"){if(typeof s.delta!=="string"||!r.turnId)return;if(!r.startedEmitted)r.startedEmitted=!0,r.queue.push({type:"started",sessionId:r.sessionId,turnId:r.turnId});r.queue.push({type:"text-delta",sessionId:r.sessionId,turnId:r.turnId,delta:s.delta});return}if(e==="item/started"){let o=s.item&&typeof s.item==="object"?s.item:{},a=M(o.type),l=this.activityForItem(a,o);if(l&&r.turnId)r.queue.push({type:"activity",sessionId:r.sessionId,turnId:r.turnId,kind:l.kind,detail:l.detail});return}if(e==="error"){let o=s.error&&typeof s.error==="object"?s.error:{},a=M(o.message)??"Codex turn failed",l=s.willRetry===!0;if(r.queue.push({type:"error",sessionId:r.sessionId,turnId:r.turnId??null,message:a,code:"turn-failed",retryable:l}),!l)r.queue.close(),this.activeTurns.delete(r.sessionId);return}if(e==="turn/completed"){let o=s.turn&&typeof s.turn==="object"?s.turn:{},a=M(o.id)??r.turnId;if(!a)return;r.turnId=a,r.queue.push({type:"completed",sessionId:r.sessionId,turnId:a,status:ja(o.status)}),r.queue.close(),this.activeTurns.delete(r.sessionId);let l=this.sessions.get(r.sessionId);if(l)this.sessions.set(r.sessionId,{...l,status:"ready"})}}activityForItem(e,t){switch(e){case"commandExecution":return{kind:"command",detail:"Running a command"};case"fileChange":return{kind:"other",detail:"Preparing file changes"};case"mcpToolCall":case"dynamicToolCall":return{kind:"tool",detail:M(t.tool)?`Using ${t.tool}`:"Using a tool"};case"webSearch":return{kind:"searching",detail:"Searching the web"};case"imageView":return{kind:"reading",detail:"Reading an image"};default:return}}handleConnectionClosed(e,t){if(e.closed)return;if(e.closed=!0,this.connection===e)this.connection=void 0;let s=new
|
|
405
|
+
`)}}let r=n+s.decode();if(r.trim()&&!e.closed)this.handleProtocolLine(e,r.trim())}catch(r){if(!e.closed)this.handleConnectionClosed(e,`Codex output could not be read: ${ue(r)}`)}finally{t.releaseLock()}}async consumeStderr(e){if(!e.process.stderr)return;let t=e.process.stderr.getReader(),s=new TextDecoder;try{while(!e.closed){let{done:n,value:r}=await t.read();if(n)break;e.stderrTail=`${e.stderrTail}${s.decode(r,{stream:!0})}`.slice(-ka)}}catch{}finally{t.releaseLock()}}handleProtocolLine(e,t){let s;try{s=JSON.parse(t)}catch(o){this.handleConnectionClosed(e,`Codex returned invalid JSON: ${ue(o)}`);return}if(!s||typeof s!=="object"||Array.isArray(s)){this.handleConnectionClosed(e,"Codex returned a non-object JSON message");return}let n=s,r=n.id;if(typeof n.method==="string"){if(r!==void 0)this.writeMessage(e,{id:typeof r==="number"||typeof r==="string"?r:String(r),error:{code:-32001,message:"ReviewMe does not permit Codex approval or input requests"}}).catch(()=>{if(!e.closed)this.handleConnectionClosed(e,"Unable to reject a Codex server request")});else this.handleNotification(n.method,n.params);return}if(r===void 0)return;let i=e.pending.get(String(r));if(!i)return;if(e.pending.delete(String(r)),Object.prototype.hasOwnProperty.call(n,"error")){let o=n.error&&typeof n.error==="object"?n.error:{},a=M(o.message)??"Codex request failed";i.reject(Fa(`${i.method}: ${a}`,o));return}i.resolve(n.result)}handleNotification(e,t){let s=t&&typeof t==="object"?t:{},n=M(s.threadId),r=n?this.activeTurns.get(n):void 0;if(e==="thread/status/changed"&&n){let o=this.sessions.get(n);if(o){let a=s.status&&typeof s.status==="object"?s.status:{},l=M(a.type);this.sessions.set(n,{...o,status:l==="active"?"running":l==="systemError"?"disconnected":"ready"})}return}if(!r)return;let i=M(s.turnId)??r.turnId;if(i)r.turnId=i;if(e==="turn/started"){if(!r.startedEmitted&&r.turnId)r.startedEmitted=!0,r.queue.push({type:"started",sessionId:r.sessionId,turnId:r.turnId});return}if(e==="item/agentMessage/delta"){if(typeof s.delta!=="string"||!r.turnId)return;if(!r.startedEmitted)r.startedEmitted=!0,r.queue.push({type:"started",sessionId:r.sessionId,turnId:r.turnId});r.queue.push({type:"text-delta",sessionId:r.sessionId,turnId:r.turnId,delta:s.delta});return}if(e==="item/started"){let o=s.item&&typeof s.item==="object"?s.item:{},a=M(o.type),l=this.activityForItem(a,o);if(l&&r.turnId)r.queue.push({type:"activity",sessionId:r.sessionId,turnId:r.turnId,kind:l.kind,detail:l.detail});return}if(e==="error"){let o=s.error&&typeof s.error==="object"?s.error:{},a=M(o.message)??"Codex turn failed",l=s.willRetry===!0;if(r.queue.push({type:"error",sessionId:r.sessionId,turnId:r.turnId??null,message:a,code:"turn-failed",retryable:l}),!l)r.queue.close(),this.activeTurns.delete(r.sessionId);return}if(e==="turn/completed"){let o=s.turn&&typeof s.turn==="object"?s.turn:{},a=M(o.id)??r.turnId;if(!a)return;r.turnId=a,r.queue.push({type:"completed",sessionId:r.sessionId,turnId:a,status:ja(o.status)}),r.queue.close(),this.activeTurns.delete(r.sessionId);let l=this.sessions.get(r.sessionId);if(l)this.sessions.set(r.sessionId,{...l,status:"ready"})}}activityForItem(e,t){switch(e){case"commandExecution":return{kind:"command",detail:"Running a command"};case"fileChange":return{kind:"other",detail:"Preparing file changes"};case"mcpToolCall":case"dynamicToolCall":return{kind:"tool",detail:M(t.tool)?`Using ${t.tool}`:"Using a tool"};case"webSearch":return{kind:"searching",detail:"Searching the web"};case"imageView":return{kind:"reading",detail:"Reading an image"};default:return}}handleConnectionClosed(e,t){if(e.closed)return;if(e.closed=!0,this.connection===e)this.connection=void 0;let s=new L("disconnected",t,{retryable:!0});for(let n of e.pending.values())n.reject(s);e.pending.clear();for(let[n,r]of this.activeTurns){if(r.connection!==e)continue;r.queue.fail(s),this.activeTurns.delete(n);let i=this.sessions.get(n);if(i)this.sessions.set(n,{...i,status:"disconnected"})}}}var Va=`<!doctype html>
|
|
401
406
|
<html lang="en"><head><meta charset="utf-8"><title>ReviewMe</title></head>
|
|
402
|
-
<body><main><h1>ReviewMe</h1><p>Frontend assets have not been built yet.</p></main></body></html>`,Ga={".css":"text/css; charset=utf-8",".gif":"image/gif",".html":"text/html; charset=utf-8",".ico":"image/x-icon",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"text/javascript; charset=utf-8",".json":"application/json; charset=utf-8",".map":"application/json; charset=utf-8",".png":"image/png",".svg":"image/svg+xml",".webp":"image/webp",".woff":"font/woff",".woff2":"font/woff2"};async function br(e={}){let t=e.service??ut({repoPath:e.repoPath,range:e.range,from:e.from,to:e.to,watchIntervalMs:e.watchIntervalMs});await t.ready;let s=e.reviewStore??new _s,n=e.reviewStore===void 0,r=e.agentProvider??new Es,i=new Sr,o=e.auth===!0||e.token!==void 0?e.token??Jn():void 0;if(o!==void 0&&o.length<20)throw Error("Review server token must be at least 20 characters");let a=sl(e.staticDir),l=e.port??0;if(!Number.isInteger(l)||l<0||l>65535)throw Error("Port must be an integer between 0 and 65535");let c=Wa((g,w)=>{Xa(g,w,(f)=>za(f,t,s,r,i,o,a,e.colorTheme))});if(c.requestTimeout=0,c.headersTimeout=60000,c.keepAliveTimeout=5000,await new Promise((g,w)=>{let f=(y)=>w(y);c.once("error",f),c.listen(l,"127.0.0.1",()=>{c.off("error",f),g()})}),e.watch!==!1)t.startWatching(e.watchIntervalMs);let p=c.address(),d=typeof p==="object"&&p!==null?p.port:l,u=o===void 0?`http://127.0.0.1:${d}/`:`http://127.0.0.1:${d}/?token=${encodeURIComponent(o)}`;return{server:c,service:t,reviewStore:s,agentProvider:r,token:o,port:d,url:u,close:()=>{if(t.stopWatching(),n)s.close();r.close(),c.closeAllConnections(),c.close()}}}async function Xa(e,t,s){let n=new AbortController;e.once("aborted",()=>n.abort()),t.once("close",()=>{if(!t.writableFinished)n.abort()});try{let r=new Headers;for(let[p,d]of Object.entries(e.headers))if(Array.isArray(d))for(let u of d)r.append(p,u);else if(d!==void 0)r.set(p,d);let i=e.method??"GET",o=i==="GET"||i==="HEAD"?void 0:yt.toWeb(e),a=new Request(`http://127.0.0.1${e.url??"/"}`,{method:i,headers:r,body:o,signal:n.signal,...o===void 0?{}:{duplex:"half"}}),l=await s(a);if(t.statusCode=l.status,t.statusMessage=l.statusText,l.headers.forEach((p,d)=>t.setHeader(d,p)),l.headers.get("content-type")?.startsWith("text/event-stream"))t.setTimeout(0);if(i==="HEAD"||l.body===null||l.status===204||l.status===304){l.body?.cancel(),t.end();return}let c=yt.fromWeb(l.body);c.once("error",(p)=>t.destroy(p)),t.once("close",()=>c.destroy()),c.pipe(t)}catch(r){if(!t.headersSent)t.statusCode=500,t.setHeader("content-type","application/json; charset=utf-8"),t.end(JSON.stringify({error:{code:"internal_error",message:r instanceof Error?r.message:String(r)}}));else t.destroy(r instanceof Error?r:void 0)}}async function za(e,t,s,n,r,i,o,a){let l=new URL(e.url);if(l.pathname.startsWith("/api/")){if(i!==void 0&&!Vn(e,i))return A({error:{code:"unauthorized",message:"A valid review token is required"}},401,{"www-authenticate":"Bearer"});try{return await Qa(e,t,s,n,r,l,a)}catch(c){return rl(c)}}return nl(l,o)}async function Qa(e,t,s,n,r,i,o){let a=i.pathname;if(e.method==="GET"&&a==="/api/theme")return A({theme:o??null});if(e.method==="GET"&&a==="/api/settings")return A({browserTabTitle:s.getBrowserTabTitleMode()});if(e.method==="PUT"&&a==="/api/settings/browser-tab-title"){let h=(await H(e))?.mode;if(h!=="repository"&&h!=="directory"&&h!=="branch"&&h!=="diff")throw new N("invalid_settings","Browser tab title mode is invalid",400);return A({browserTabTitle:s.setBrowserTabTitleMode(h)})}if(e.method==="GET"&&(a==="/api/repository"||a==="/api/metadata/repository"))return A({repository:await t.getRepositoryMetadata()});if(e.method==="GET"&&a==="/api/metadata"){let[m,h]=await Promise.all([t.getRepositoryMetadata(),t.listFiles()]);return A({repository:m,files:h.files})}if(e.method==="GET"&&(a==="/api/files"||a==="/api/metadata/files"))return A(await t.listFiles());if(e.method==="GET"&&a==="/api/refs")return A({refs:await t.listRefs()});if(e.method==="GET"&&a==="/api/revision"){let m=await t.getRepositoryMetadata();return A({revision:m.revision,dirty:m.dirty})}if((e.method==="GET"||e.method==="POST")&&a==="/api/refresh")return A(await t.refresh());if(e.method==="GET"&&a==="/api/events")return tl(t);if(e.method==="GET"&&a==="/api/patch-stream"){let m=i.searchParams.get("from"),h=i.searchParams.get("to"),b=i.searchParams.get("mode");if(m===null!==(h===null))throw new N("invalid_comparison","from and to must be provided together");if(b!==null&&b!=="merge-base"&&b!=="direct")throw new N("invalid_comparison","mode must be merge-base or direct");return new Response(await t.streamPatch(e.signal,m===null||h===null?void 0:{from:m,to:h,mode:b==="direct"?"direct":"merge-base"},i.searchParams.get("includeUnstaged")==="true"),{headers:{"cache-control":"no-cache, no-store","content-type":"text/plain; charset=utf-8",vary:"Authorization","x-accel-buffering":"no","x-content-type-options":"nosniff"}})}if(e.method==="GET"&&a==="/api/health")return A({ok:!0,revision:(await t.getRepositoryMetadata()).revision});if(e.method==="GET"&&a==="/api/commits"){let m=i.searchParams.get("from"),h=i.searchParams.get("to"),b=i.searchParams.get("mode");if(m===null!==(h===null))throw new N("invalid_comparison","from and to must be provided together");if(b!==null&&b!=="merge-base"&&b!=="direct")throw new N("invalid_comparison","mode must be merge-base or direct");return A(await t.listCommits(m===null||h===null?void 0:{from:m,to:h,mode:b==="direct"?"direct":"merge-base"}))}if(e.method==="GET"&&a==="/api/review"){let m=await G(t,s);return A({snapshotId:m.id,reviewedPaths:s.listReviewedFiles(m.id).map((h)=>h.path),threads:s.listThreads(m.id).map(Ts),drafts:s.listDrafts(m.id).map(yr),agentConversations:s.listAgentConversations(m.id).map(wr)})}if(e.method==="GET"&&a==="/api/agents/codex/models"){let m=await n.listModels(),h=m.find((b)=>b.isDefault)??m[0];return A({models:m,defaultModel:h?.id,defaultEffort:h?.defaultReasoningEffort??void 0,efforts:h?.supportedReasoningEfforts??[]})}let l=X(a,"/api/review/threads/","/agent-sessions");if(e.method==="POST"&&l!==void 0){let m=await G(t,s),h=s.getThread(l);if(h==null||h.snapshotId!==m.id)throw new N("not_found","Review thread not found",404);let b=await H(e),v=await n.startThread({cwd:t.repositoryRoot,model:typeof b?.model==="string"?b.model:void 0,reasoningEffort:typeof b?.effort==="string"?b.effort:void 0,permissionMode:"read-only"}),T=s.createAgentSession({provider:"codex",externalThreadId:v.session.externalThreadId,model:v.session.model,reasoningEffort:v.session.reasoningEffort,permissionMode:"read-only",status:"ready"});s.linkAgentSession(l,T.id);let R=h.anchors[0],E=h.messages.find((x)=>x.source==="local");if(R!=null)s.addAgentContext({agentSessionId:T.id,snapshotId:m.id,sourceThreadId:h.id,anchor:R,prompt:E?.body??"Review this code"});return r.markProviderReady(v.session.externalThreadId),A(_r(T,v.history),201)}if(e.method==="POST"&&a==="/api/agent-conversations"){let m=await G(t,s),h=await H(e);if(!h||typeof h.prompt!=="string"||typeof h.anchor!=="object"||h.anchor==null)throw new N("invalid_request","Agent prompt and anchor are required");let b=gt(h.anchor),v=await n.startThread({cwd:t.repositoryRoot,model:typeof h.model==="string"?h.model:void 0,reasoningEffort:typeof h.effort==="string"?h.effort:void 0,serviceTier:h.fast===!0?"priority":void 0,permissionMode:"read-only"}),T=s.createAgentSession({provider:"codex",externalThreadId:v.session.externalThreadId,model:v.session.model,reasoningEffort:v.session.reasoningEffort,permissionMode:"read-only",status:"ready"}),R=s.addAgentContext({agentSessionId:T.id,snapshotId:m.id,anchor:b,prompt:h.prompt});return r.markProviderReady(v.session.externalThreadId),A(wr({...T,contexts:[R]}),201)}let c=X(a,"/api/agent-conversations/");if(e.method==="DELETE"&&c!==void 0){let m=await G(t,s),h=s.getAgentSession(c);if(!s.deleteAgentConversation(c,m.id))throw new N("not_found","Agent conversation not found",404);if(h?.status==="running"&&h.externalThreadId!=null)try{await n.stop(h.externalThreadId)}catch{}return A({deleted:!0})}let p=X(a,"/api/agent-sessions/","/messages");if(e.method==="POST"&&p!==void 0){let m=await H(e),h=typeof m?.body==="string"?m.body:typeof m?.message==="string"?m.message:"";if(h.trim()==="")throw new N("invalid_request","Agent message is required");let b=s.getAgentSession(p);if(b==null||b.externalThreadId==null)throw new N("not_found","Agent session not found",404);if(!r.isProviderReady(b.externalThreadId)){let T=await n.resumeThread({externalThreadId:b.externalThreadId,cwd:t.repositoryRoot,model:b.model??void 0,reasoningEffort:b.reasoningEffort??void 0,permissionMode:"read-only"});r.markProviderReady(T.session.externalThreadId)}let v=await n.sendMessage(b.externalThreadId,{text:h,reasoningEffort:b.reasoningEffort??void 0});return s.updateAgentSession(b.id,{status:"running",lastEventAt:new Date().toISOString()}),r.pump(b.id,v.events,(T)=>{if(T.type==="completed"||T.type==="stopped")s.updateAgentSession(b.id,{status:"ready",lastEventAt:new Date().toISOString()});else if(T.type==="error")s.updateAgentSession(b.id,{status:"error",statusMessage:T.message,lastEventAt:new Date().toISOString()})}),A({status:"running",turnId:v.turnId})}let d=X(a,"/api/agent-sessions/","/history");if(e.method==="GET"&&d!==void 0){let m=s.getAgentSession(d);if(m==null||m.externalThreadId==null)throw new N("not_found","Agent session not found",404);let h;try{h=await n.resumeThread({externalThreadId:m.externalThreadId,cwd:t.repositoryRoot,model:m.model??void 0,reasoningEffort:m.reasoningEffort??void 0,permissionMode:"read-only"})}catch(b){if(b instanceof Error&&b.message.includes("rollout")&&b.message.includes("is empty"))return A({history:[]});throw b}return r.markProviderReady(h.session.externalThreadId),A({history:h.history})}let u=X(a,"/api/agent-sessions/","/events");if(e.method==="GET"&&u!==void 0){if(s.getAgentSession(u)==null)throw new N("not_found","Agent session not found",404);return r.response(u)}let g=X(a,"/api/agent-sessions/","/stop");if(e.method==="POST"&&g!==void 0){let m=s.getAgentSession(g);if(m==null||m.externalThreadId==null)throw new N("not_found","Agent session not found",404);return await n.stop(m.externalThreadId),s.updateAgentSession(m.id,{status:"stopped",lastEventAt:new Date().toISOString()}),A({stopped:!0})}if(e.method==="PUT"&&a==="/api/review/files/reviewed"){let m=await G(t,s),h=await H(e);if(!Array.isArray(h?.paths)||h.paths.some((v)=>typeof v!=="string"))throw new N("invalid_request","Request body must include an array of file paths");let b=h.reviewed!==!1;return s.setFilesReviewed(m.id,h.paths,b),A({reviewed:b,paths:h.paths})}let w=X(a,"/api/review/files/","/reviewed");if(e.method==="PUT"&&w!==void 0){let m=await G(t,s),h=await H(e),b=typeof h?.path==="string"?h.path:w,v=h?.reviewed!==!1;return A({reviewed:s.setFileReviewed(m.id,b,v)})}if(e.method==="POST"&&a==="/api/review/threads"){let m=await G(t,s),h=await H(e);if(!h||typeof h.body!=="string")throw new N("invalid_request","Comment body is required");return A(Ts(s.createThread({snapshotId:m.id,anchor:gt(h.anchor),body:h.body})),201)}let f=X(a,"/api/review/threads/");if((e.method==="PATCH"||e.method==="DELETE")&&f!==void 0){let m=await G(t,s),h=s.getThread(f);if(h==null||h.snapshotId!==m.id)throw new N("not_found","Review thread not found",404);if(e.method==="DELETE")return s.deleteThread(f),A({deleted:!0});let b=await H(e);if(!b||typeof b.body!=="string")throw new N("invalid_request","Comment body is required");let v=h.messages.find((T)=>T.source==="local");if(v==null)s.createMessage({threadId:f,body:b.body});else s.updateMessage(v.id,b.body);if(b.anchor!==void 0&&h.anchors[0]!=null)s.updateAnchor(h.anchors[0].id,gt(b.anchor));return A(Ts(s.getThread(f)))}let y=X(a,"/api/review/drafts/");if((e.method==="PUT"||e.method==="DELETE")&&y!==void 0){let m=await G(t,s);if(e.method==="DELETE"){let b=s.getDraft(y);if(b!=null&&b.snapshotId!==m.id)throw new N("not_found","Review draft not found",404);return s.deleteDraft(y),A({deleted:!0})}let h=await H(e);if(!h||typeof h.body!=="string")throw new N("invalid_request","Draft body is required");return A(yr(s.upsertDraft({id:y,snapshotId:m.id,anchor:gt(h.anchor),body:h.body})))}let _=el(a);if(e.method==="GET"&&_!==void 0){if(i.searchParams.get("hydrate")==="true"){let m=i.searchParams.get("from"),h=i.searchParams.get("to"),b=i.searchParams.get("mode");if(m===null||h===null||b!=="merge-base"&&b!=="direct")throw new N("invalid_comparison","from, to, and a valid mode are required");return A(await t.getFileContents({comparison:{from:m,to:h,mode:b},includeUnstaged:i.searchParams.get("includeUnstaged")==="true",oldPath:i.searchParams.get("oldPath")??void 0,newPath:i.searchParams.get("newPath")??void 0,pureRename:i.searchParams.get("pureRename")==="true"}))}return A(await t.getFileDiff(_))}if(e.method==="GET"&&(a==="/api/diff"||a==="/api/patch")){let m=i.searchParams.get("fileId")??i.searchParams.get("path");if(!m)throw new N("missing_file","A fileId or path query parameter is required");return A(await t.getFileDiff(m))}if(e.method==="POST"&&(a==="/api/open"||a==="/api/open-working-file")){let m=await H(e);if(!m||typeof m.path!=="string")throw new N("invalid_request","Request body must include a repository-relative path");if(m.line!==void 0&&typeof m.line!=="number"||m.column!==void 0&&typeof m.column!=="number"||m.side!==void 0&&m.side!=="old"&&m.side!=="new")throw new N("invalid_request","line and column must be numbers");let h={path:m.path,...m.line===void 0?{}:{line:m.line},...m.column===void 0?{}:{column:m.column},...m.side===void 0?{}:{side:m.side}};return A(await t.openWorkingFile(h))}throw new N("not_found","API endpoint not found",404)}async function G(e,t){let s=await e.getRepositoryMetadata();return t.ensureSnapshot({canonicalRoot:s.root,remoteOrigin:s.remoteOrigin,comparisonMode:s.comparisonMode,baseRef:s.fromRef,headRef:s.toRef,baseSha:s.baseSha,headSha:s.targetSha})}function gt(e){if(e==null||typeof e!=="object"||Array.isArray(e))throw new N("invalid_anchor","A review anchor is required");let t=e;if(typeof t.path!=="string")throw new N("invalid_anchor","Anchor path is required");let s=t.kind==="diff_range"?"diff_range":t.kind==="file"?"file":null;if(s==null)throw new N("invalid_anchor","Anchor kind is invalid");return{kind:s,path:t.path,side:t.side==="old"||t.side==="new"?t.side:null,startLine:typeof t.startLine==="number"?t.startLine:null,endLine:typeof t.endLine==="number"?t.endLine:null,contextFingerprint:typeof t.contextHash==="string"?t.contextHash:null}}function Ts(e){let t=e.anchors[0],s=e.messages.find((n)=>n.source==="local");return{id:e.id,snapshotId:e.snapshotId,anchor:t==null?null:{id:t.id,kind:t.kind,path:t.path,side:t.side,startLine:t.startLine,endLine:t.endLine,contextHash:t.contextFingerprint},body:s?.body??"",createdAt:e.createdAt,updatedAt:e.updatedAt,agentSession:e.agentSessions[0]??null}}function yr(e){return{id:e.id,snapshotId:e.snapshotId,anchor:{kind:e.anchor.kind,path:e.anchor.path,side:e.anchor.side,startLine:e.anchor.startLine,endLine:e.anchor.endLine,contextHash:e.anchor.contextFingerprint},body:e.body,updatedAt:e.updatedAt}}function X(e,t,s=""){if(!e.startsWith(t)||s!==""&&!e.endsWith(s))return;let n=e.slice(t.length,s===""?void 0:-s.length);if(n===""||n.includes("/"))return;try{return decodeURIComponent(n)}catch{throw new N("invalid_path","Path segment is not valid URL encoding")}}function _r(e,t=[]){return{id:e.id,provider:e.provider,externalThreadId:e.externalThreadId,model:e.model,effort:e.reasoningEffort,permissionMode:e.permissionMode,status:e.status,history:t}}function wr(e){return{..._r(e),contexts:e.contexts.map((t)=>({id:t.id,sourceThreadId:t.sourceThreadId,anchor:{kind:t.anchor.kind,path:t.anchor.path,side:t.anchor.side,startLine:t.anchor.startLine,endLine:t.anchor.endLine},prompt:t.prompt,createdAt:t.createdAt}))}}class Sr{providerReady=new Set;subscribers=new Map;buffered=new Map;encoder=new TextEncoder;markProviderReady(e){this.providerReady.add(e)}isProviderReady(e){return this.providerReady.has(e)}pump(e,t,s){this.buffered.set(e,[]),(async()=>{try{for await(let n of t)s(n),this.publish(e,Za(n))}catch(n){this.publish(e,{type:"error",message:n instanceof Error?n.message:String(n)})}})()}response(e){let t,s=new ReadableStream({start:(n)=>{t=n;let r=this.subscribers.get(e)??new Set;r.add(n),this.subscribers.set(e,r);for(let i of this.buffered.get(e)??[])this.send(n,i)},cancel:()=>{if(t==null)return;let n=this.subscribers.get(e);if(n?.delete(t),n?.size===0)this.subscribers.delete(e)}});return new Response(s,{headers:{"cache-control":"no-cache, no-store","content-type":"text/event-stream; charset=utf-8","x-accel-buffering":"no"}})}publish(e,t){let s=this.buffered.get(e)??[];if(s.push(t),s.length>2000)s.shift();this.buffered.set(e,s);for(let n of this.subscribers.get(e)??[])this.send(n,t)}send(e,t){try{e.enqueue(this.encoder.encode(`event: message
|
|
407
|
+
<body><main><h1>ReviewMe</h1><p>Frontend assets have not been built yet.</p></main></body></html>`,Ga={".css":"text/css; charset=utf-8",".gif":"image/gif",".html":"text/html; charset=utf-8",".ico":"image/x-icon",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"text/javascript; charset=utf-8",".json":"application/json; charset=utf-8",".map":"application/json; charset=utf-8",".png":"image/png",".svg":"image/svg+xml",".webp":"image/webp",".woff":"font/woff",".woff2":"font/woff2"};async function br(e={}){let t=e.service??ut({repoPath:e.repoPath,range:e.range,from:e.from,to:e.to,watchIntervalMs:e.watchIntervalMs});await t.ready;let s=e.reviewStore??new _s,n=e.reviewStore===void 0,r=e.agentProvider??new vs,i=new Sr,o=e.auth===!0||e.token!==void 0?e.token??Jn():void 0;if(o!==void 0&&o.length<20)throw Error("Review server token must be at least 20 characters");let a=sl(e.staticDir),l=e.port??0;if(!Number.isInteger(l)||l<0||l>65535)throw Error("Port must be an integer between 0 and 65535");if(e.exitOnCloseAfterSeconds!==void 0&&(!Number.isInteger(e.exitOnCloseAfterSeconds)||Math.abs(e.exitOnCloseAfterSeconds)>2147483))throw Error("Exit-on-close delay must be an integer between -2147483 and 2147483 seconds");let c=0,p=!1,u,h=!1,y,b=(f)=>{if(h)return;if(h=!0,u!==void 0)clearTimeout(u);if(f!==void 0)console.log(f);if(t.stopWatching(),n)s.close();r.close(),y.closeAllConnections(),y.close()},d={open(){if(p=!0,c+=1,u!==void 0)clearTimeout(u),u=void 0},close(){if(c=Math.max(0,c-1),!p||c>0||h)return;let f=s.getExitOnCloseSetting(),m=e.exitOnCloseAfterSeconds??(f.enabled?f.afterSeconds:-1);if(m<0)return;let w=m===0?"immediately":`after ${m} seconds`,E=e.exitOnCloseAfterSeconds!==void 0?`--exit-on-close-after=${m}`:`configured in Settings: ${m} seconds`,A=`ReviewMe: no browser tabs remained; server stopped ${w}. (${E})`;if(m===0){b(A);return}u=setTimeout(()=>b(A),m*1000)}};if(y=Wa((f,m)=>{Xa(f,m,(w)=>za(w,t,s,r,i,o,a,e.colorTheme,d))}),y.requestTimeout=0,y.headersTimeout=60000,y.keepAliveTimeout=5000,await new Promise((f,m)=>{let w=(E)=>m(E);y.once("error",w),y.listen(l,"127.0.0.1",()=>{y.off("error",w),f()})}),e.watch!==!1)t.startWatching(e.watchIntervalMs);let g=y.address(),_=typeof g==="object"&&g!==null?g.port:l,S=o===void 0?`http://127.0.0.1:${_}/`:`http://127.0.0.1:${_}/?token=${encodeURIComponent(o)}`;return{server:y,service:t,reviewStore:s,agentProvider:r,token:o,port:_,url:S,close:b}}async function Xa(e,t,s){let n=new AbortController;e.once("aborted",()=>n.abort()),t.once("close",()=>{if(!t.writableFinished)n.abort()});try{let r=new Headers;for(let[p,u]of Object.entries(e.headers))if(Array.isArray(u))for(let h of u)r.append(p,h);else if(u!==void 0)r.set(p,u);let i=e.method??"GET",o=i==="GET"||i==="HEAD"?void 0:yt.toWeb(e),a=new Request(`http://127.0.0.1${e.url??"/"}`,{method:i,headers:r,body:o,signal:n.signal,...o===void 0?{}:{duplex:"half"}}),l=await s(a);if(t.statusCode=l.status,t.statusMessage=l.statusText,l.headers.forEach((p,u)=>t.setHeader(u,p)),l.headers.get("content-type")?.startsWith("text/event-stream"))t.setTimeout(0);if(i==="HEAD"||l.body===null||l.status===204||l.status===304){l.body?.cancel(),t.end();return}let c=yt.fromWeb(l.body);c.once("error",(p)=>t.destroy(p)),t.once("close",()=>c.destroy()),c.pipe(t)}catch(r){if(!t.headersSent)t.statusCode=500,t.setHeader("content-type","application/json; charset=utf-8"),t.end(JSON.stringify({error:{code:"internal_error",message:r instanceof Error?r.message:String(r)}}));else t.destroy(r instanceof Error?r:void 0)}}async function za(e,t,s,n,r,i,o,a,l){let c=new URL(e.url);if(c.pathname.startsWith("/api/")){if(i!==void 0&&!Vn(e,i))return R({error:{code:"unauthorized",message:"A valid review token is required"}},401,{"www-authenticate":"Bearer"});try{return await Qa(e,t,s,n,r,c,a,l)}catch(p){return rl(p)}}return nl(c,o)}async function Qa(e,t,s,n,r,i,o,a){let l=i.pathname;if(e.method==="GET"&&l==="/api/theme")return R({theme:o??null});if(e.method==="GET"&&l==="/api/settings")return R({browserTabTitle:s.getBrowserTabTitleMode(),exitOnClose:s.getExitOnCloseSetting()});if(e.method==="PUT"&&l==="/api/settings/browser-tab-title"){let m=(await B(e))?.mode;if(m!=="repository"&&m!=="directory"&&m!=="branch"&&m!=="diff")throw new C("invalid_settings","Browser tab title mode is invalid",400);return R({browserTabTitle:s.setBrowserTabTitleMode(m),exitOnClose:s.getExitOnCloseSetting()})}if(e.method==="PUT"&&l==="/api/settings/exit-on-close"){let f=await B(e);if(typeof f?.enabled!=="boolean"||!Number.isInteger(f.afterSeconds))throw new C("invalid_settings","Exit-on-close setting requires enabled and an integer afterSeconds",400);return R({browserTabTitle:s.getBrowserTabTitleMode(),exitOnClose:s.setExitOnCloseSetting(f.enabled,f.afterSeconds)})}if(e.method==="GET"&&(l==="/api/repository"||l==="/api/metadata/repository"))return R({repository:await t.getRepositoryMetadata()});if(e.method==="GET"&&l==="/api/metadata"){let[f,m]=await Promise.all([t.getRepositoryMetadata(),t.listFiles()]);return R({repository:f,files:m.files})}if(e.method==="GET"&&(l==="/api/files"||l==="/api/metadata/files"))return R(await t.listFiles());if(e.method==="GET"&&l==="/api/refs")return R({refs:await t.listRefs()});if(e.method==="GET"&&l==="/api/revision"){let f=await t.getRepositoryMetadata();return R({revision:f.revision,dirty:f.dirty})}if((e.method==="GET"||e.method==="POST")&&l==="/api/refresh")return R(await t.refresh());if(e.method==="GET"&&l==="/api/events")return tl(t,a);if(e.method==="GET"&&l==="/api/patch-stream"){let f=i.searchParams.get("from"),m=i.searchParams.get("to"),w=i.searchParams.get("mode");if(f===null!==(m===null))throw new C("invalid_comparison","from and to must be provided together");if(w!==null&&w!=="merge-base"&&w!=="direct")throw new C("invalid_comparison","mode must be merge-base or direct");return new Response(await t.streamPatch(e.signal,f===null||m===null?void 0:{from:f,to:m,mode:w==="direct"?"direct":"merge-base"},i.searchParams.get("includeUnstaged")==="true"),{headers:{"cache-control":"no-cache, no-store","content-type":"text/plain; charset=utf-8",vary:"Authorization","x-accel-buffering":"no","x-content-type-options":"nosniff"}})}if(e.method==="GET"&&l==="/api/health")return R({ok:!0,revision:(await t.getRepositoryMetadata()).revision});if(e.method==="GET"&&l==="/api/commits"){let f=i.searchParams.get("from"),m=i.searchParams.get("to"),w=i.searchParams.get("mode");if(f===null!==(m===null))throw new C("invalid_comparison","from and to must be provided together");if(w!==null&&w!=="merge-base"&&w!=="direct")throw new C("invalid_comparison","mode must be merge-base or direct");return R(await t.listCommits(f===null||m===null?void 0:{from:f,to:m,mode:w==="direct"?"direct":"merge-base"}))}if(e.method==="GET"&&l==="/api/review"){let f=await X(t,s);return R({snapshotId:f.id,reviewedPaths:s.listReviewedFiles(f.id).map((m)=>m.path),threads:s.listThreads(f.id).map(Ts),drafts:s.listDrafts(f.id).map(yr),agentConversations:s.listAgentConversations(f.id).map(wr)})}if(e.method==="GET"&&l==="/api/agents/codex/models"){let f=await n.listModels(),m=f.find((w)=>w.isDefault)??f[0];return R({models:f,defaultModel:m?.id,defaultEffort:m?.defaultReasoningEffort??void 0,efforts:m?.supportedReasoningEfforts??[]})}let c=z(l,"/api/review/threads/","/agent-sessions");if(e.method==="POST"&&c!==void 0){let f=await X(t,s),m=s.getThread(c);if(m==null||m.snapshotId!==f.id)throw new C("not_found","Review thread not found",404);let w=await B(e),E=await n.startThread({cwd:t.repositoryRoot,model:typeof w?.model==="string"?w.model:void 0,reasoningEffort:typeof w?.effort==="string"?w.effort:void 0,permissionMode:"read-only"}),A=s.createAgentSession({provider:"codex",externalThreadId:E.session.externalThreadId,model:E.session.model,reasoningEffort:E.session.reasoningEffort,permissionMode:"read-only",status:"ready"});s.linkAgentSession(c,A.id);let T=m.anchors[0],x=m.messages.find((W)=>W.source==="local");if(T!=null)s.addAgentContext({agentSessionId:A.id,snapshotId:f.id,sourceThreadId:m.id,anchor:T,prompt:x?.body??"Review this code"});return r.markProviderReady(E.session.externalThreadId),R(_r(A,E.history),201)}if(e.method==="POST"&&l==="/api/agent-conversations"){let f=await X(t,s),m=await B(e);if(!m||typeof m.prompt!=="string"||typeof m.anchor!=="object"||m.anchor==null)throw new C("invalid_request","Agent prompt and anchor are required");let w=gt(m.anchor),E=await n.startThread({cwd:t.repositoryRoot,model:typeof m.model==="string"?m.model:void 0,reasoningEffort:typeof m.effort==="string"?m.effort:void 0,serviceTier:m.fast===!0?"priority":void 0,permissionMode:"read-only"}),A=s.createAgentSession({provider:"codex",externalThreadId:E.session.externalThreadId,model:E.session.model,reasoningEffort:E.session.reasoningEffort,permissionMode:"read-only",status:"ready"}),T=s.addAgentContext({agentSessionId:A.id,snapshotId:f.id,anchor:w,prompt:m.prompt});return r.markProviderReady(E.session.externalThreadId),R(wr({...A,contexts:[T]}),201)}let p=z(l,"/api/agent-conversations/");if(e.method==="DELETE"&&p!==void 0){let f=await X(t,s),m=s.getAgentSession(p);if(!s.deleteAgentConversation(p,f.id))throw new C("not_found","Agent conversation not found",404);if(m?.status==="running"&&m.externalThreadId!=null)try{await n.stop(m.externalThreadId)}catch{}return R({deleted:!0})}let u=z(l,"/api/agent-sessions/","/messages");if(e.method==="POST"&&u!==void 0){let f=await B(e),m=typeof f?.body==="string"?f.body:typeof f?.message==="string"?f.message:"";if(m.trim()==="")throw new C("invalid_request","Agent message is required");let w=s.getAgentSession(u);if(w==null||w.externalThreadId==null)throw new C("not_found","Agent session not found",404);if(!r.isProviderReady(w.externalThreadId)){let A=await n.resumeThread({externalThreadId:w.externalThreadId,cwd:t.repositoryRoot,model:w.model??void 0,reasoningEffort:w.reasoningEffort??void 0,permissionMode:"read-only"});r.markProviderReady(A.session.externalThreadId)}let E=await n.sendMessage(w.externalThreadId,{text:m,reasoningEffort:w.reasoningEffort??void 0});return s.updateAgentSession(w.id,{status:"running",lastEventAt:new Date().toISOString()}),r.pump(w.id,E.events,(A)=>{if(A.type==="completed"||A.type==="stopped")s.updateAgentSession(w.id,{status:"ready",lastEventAt:new Date().toISOString()});else if(A.type==="error")s.updateAgentSession(w.id,{status:"error",statusMessage:A.message,lastEventAt:new Date().toISOString()})}),R({status:"running",turnId:E.turnId})}let h=z(l,"/api/agent-sessions/","/history");if(e.method==="GET"&&h!==void 0){let f=s.getAgentSession(h);if(f==null||f.externalThreadId==null)throw new C("not_found","Agent session not found",404);let m;try{m=await n.resumeThread({externalThreadId:f.externalThreadId,cwd:t.repositoryRoot,model:f.model??void 0,reasoningEffort:f.reasoningEffort??void 0,permissionMode:"read-only"})}catch(w){if(w instanceof Error&&w.message.includes("rollout")&&w.message.includes("is empty"))return R({history:[]});throw w}return r.markProviderReady(m.session.externalThreadId),R({history:m.history})}let y=z(l,"/api/agent-sessions/","/events");if(e.method==="GET"&&y!==void 0){if(s.getAgentSession(y)==null)throw new C("not_found","Agent session not found",404);return r.response(y)}let b=z(l,"/api/agent-sessions/","/stop");if(e.method==="POST"&&b!==void 0){let f=s.getAgentSession(b);if(f==null||f.externalThreadId==null)throw new C("not_found","Agent session not found",404);return await n.stop(f.externalThreadId),s.updateAgentSession(f.id,{status:"stopped",lastEventAt:new Date().toISOString()}),R({stopped:!0})}if(e.method==="PUT"&&l==="/api/review/files/reviewed"){let f=await X(t,s),m=await B(e);if(!Array.isArray(m?.paths)||m.paths.some((E)=>typeof E!=="string"))throw new C("invalid_request","Request body must include an array of file paths");let w=m.reviewed!==!1;return s.setFilesReviewed(f.id,m.paths,w),R({reviewed:w,paths:m.paths})}let d=z(l,"/api/review/files/","/reviewed");if(e.method==="PUT"&&d!==void 0){let f=await X(t,s),m=await B(e),w=typeof m?.path==="string"?m.path:d,E=m?.reviewed!==!1;return R({reviewed:s.setFileReviewed(f.id,w,E)})}if(e.method==="POST"&&l==="/api/review/threads"){let f=await X(t,s),m=await B(e);if(!m||typeof m.body!=="string")throw new C("invalid_request","Comment body is required");return R(Ts(s.createThread({snapshotId:f.id,anchor:gt(m.anchor),body:m.body})),201)}let g=z(l,"/api/review/threads/");if((e.method==="PATCH"||e.method==="DELETE")&&g!==void 0){let f=await X(t,s),m=s.getThread(g);if(m==null||m.snapshotId!==f.id)throw new C("not_found","Review thread not found",404);if(e.method==="DELETE")return s.deleteThread(g),R({deleted:!0});let w=await B(e);if(!w||typeof w.body!=="string")throw new C("invalid_request","Comment body is required");let E=m.messages.find((A)=>A.source==="local");if(E==null)s.createMessage({threadId:g,body:w.body});else s.updateMessage(E.id,w.body);if(w.anchor!==void 0&&m.anchors[0]!=null)s.updateAnchor(m.anchors[0].id,gt(w.anchor));return R(Ts(s.getThread(g)))}let _=z(l,"/api/review/drafts/");if((e.method==="PUT"||e.method==="DELETE")&&_!==void 0){let f=await X(t,s);if(e.method==="DELETE"){let w=s.getDraft(_);if(w!=null&&w.snapshotId!==f.id)throw new C("not_found","Review draft not found",404);return s.deleteDraft(_),R({deleted:!0})}let m=await B(e);if(!m||typeof m.body!=="string")throw new C("invalid_request","Draft body is required");return R(yr(s.upsertDraft({id:_,snapshotId:f.id,anchor:gt(m.anchor),body:m.body})))}let S=el(l);if(e.method==="GET"&&S!==void 0){if(i.searchParams.get("hydrate")==="true"){let f=i.searchParams.get("from"),m=i.searchParams.get("to"),w=i.searchParams.get("mode");if(f===null||m===null||w!=="merge-base"&&w!=="direct")throw new C("invalid_comparison","from, to, and a valid mode are required");return R(await t.getFileContents({comparison:{from:f,to:m,mode:w},includeUnstaged:i.searchParams.get("includeUnstaged")==="true",oldPath:i.searchParams.get("oldPath")??void 0,newPath:i.searchParams.get("newPath")??void 0,pureRename:i.searchParams.get("pureRename")==="true"}))}return R(await t.getFileDiff(S))}if(e.method==="GET"&&(l==="/api/diff"||l==="/api/patch")){let f=i.searchParams.get("fileId")??i.searchParams.get("path");if(!f)throw new C("missing_file","A fileId or path query parameter is required");return R(await t.getFileDiff(f))}if(e.method==="POST"&&(l==="/api/open"||l==="/api/open-working-file")){let f=await B(e);if(!f||typeof f.path!=="string")throw new C("invalid_request","Request body must include a repository-relative path");if(f.line!==void 0&&typeof f.line!=="number"||f.column!==void 0&&typeof f.column!=="number"||f.side!==void 0&&f.side!=="old"&&f.side!=="new")throw new C("invalid_request","line and column must be numbers");let m={path:f.path,...f.line===void 0?{}:{line:f.line},...f.column===void 0?{}:{column:f.column},...f.side===void 0?{}:{side:f.side}};return R(await t.openWorkingFile(m))}throw new C("not_found","API endpoint not found",404)}async function X(e,t){let s=await e.getRepositoryMetadata();return t.ensureSnapshot({canonicalRoot:s.root,remoteOrigin:s.remoteOrigin,comparisonMode:s.comparisonMode,baseRef:s.fromRef,headRef:s.toRef,baseSha:s.baseSha,headSha:s.targetSha})}function gt(e){if(e==null||typeof e!=="object"||Array.isArray(e))throw new C("invalid_anchor","A review anchor is required");let t=e;if(typeof t.path!=="string")throw new C("invalid_anchor","Anchor path is required");let s=t.kind==="diff_range"?"diff_range":t.kind==="file"?"file":null;if(s==null)throw new C("invalid_anchor","Anchor kind is invalid");return{kind:s,path:t.path,side:t.side==="old"||t.side==="new"?t.side:null,startLine:typeof t.startLine==="number"?t.startLine:null,endLine:typeof t.endLine==="number"?t.endLine:null,contextFingerprint:typeof t.contextHash==="string"?t.contextHash:null}}function Ts(e){let t=e.anchors[0],s=e.messages.find((n)=>n.source==="local");return{id:e.id,snapshotId:e.snapshotId,anchor:t==null?null:{id:t.id,kind:t.kind,path:t.path,side:t.side,startLine:t.startLine,endLine:t.endLine,contextHash:t.contextFingerprint},body:s?.body??"",createdAt:e.createdAt,updatedAt:e.updatedAt,agentSession:e.agentSessions[0]??null}}function yr(e){return{id:e.id,snapshotId:e.snapshotId,anchor:{kind:e.anchor.kind,path:e.anchor.path,side:e.anchor.side,startLine:e.anchor.startLine,endLine:e.anchor.endLine,contextHash:e.anchor.contextFingerprint},body:e.body,updatedAt:e.updatedAt}}function z(e,t,s=""){if(!e.startsWith(t)||s!==""&&!e.endsWith(s))return;let n=e.slice(t.length,s===""?void 0:-s.length);if(n===""||n.includes("/"))return;try{return decodeURIComponent(n)}catch{throw new C("invalid_path","Path segment is not valid URL encoding")}}function _r(e,t=[]){return{id:e.id,provider:e.provider,externalThreadId:e.externalThreadId,model:e.model,effort:e.reasoningEffort,permissionMode:e.permissionMode,status:e.status,history:t}}function wr(e){return{..._r(e),contexts:e.contexts.map((t)=>({id:t.id,sourceThreadId:t.sourceThreadId,anchor:{kind:t.anchor.kind,path:t.anchor.path,side:t.anchor.side,startLine:t.anchor.startLine,endLine:t.anchor.endLine},prompt:t.prompt,createdAt:t.createdAt}))}}class Sr{providerReady=new Set;subscribers=new Map;buffered=new Map;encoder=new TextEncoder;markProviderReady(e){this.providerReady.add(e)}isProviderReady(e){return this.providerReady.has(e)}pump(e,t,s){this.buffered.set(e,[]),(async()=>{try{for await(let n of t)s(n),this.publish(e,Za(n))}catch(n){this.publish(e,{type:"error",message:n instanceof Error?n.message:String(n)})}})()}response(e){let t,s=new ReadableStream({start:(n)=>{t=n;let r=this.subscribers.get(e)??new Set;r.add(n),this.subscribers.set(e,r);for(let i of this.buffered.get(e)??[])this.send(n,i)},cancel:()=>{if(t==null)return;let n=this.subscribers.get(e);if(n?.delete(t),n?.size===0)this.subscribers.delete(e)}});return new Response(s,{headers:{"cache-control":"no-cache, no-store","content-type":"text/event-stream; charset=utf-8","x-accel-buffering":"no"}})}publish(e,t){let s=this.buffered.get(e)??[];if(s.push(t),s.length>2000)s.shift();this.buffered.set(e,s);for(let n of this.subscribers.get(e)??[])this.send(n,t)}send(e,t){try{e.enqueue(this.encoder.encode(`event: message
|
|
403
408
|
data: ${JSON.stringify(t)}
|
|
404
409
|
|
|
405
|
-
`))}catch{}}}function Za(e){switch(e.type){case"text-delta":return{type:"text_delta",delta:e.delta};case"activity":return{type:"activity",label:e.detail,detail:e.kind};case"completed":return{type:"done",status:e.status};case"stopped":return{type:"done",status:"stopped"};case"error":return{type:"error",message:e.message};default:return e}}function el(e){let t;if(e.startsWith("/api/files/")&&e.endsWith("/diff"))t=e.slice(11,-5);else if(e.startsWith("/api/diff/"))t=e.slice(10);else if(e.startsWith("/api/patch/"))t=e.slice(11);if(t===void 0||!t)return;try{return decodeURIComponent(t)}catch{throw new
|
|
406
|
-
data: ${JSON.stringify(
|
|
410
|
+
`))}catch{}}}function Za(e){switch(e.type){case"text-delta":return{type:"text_delta",delta:e.delta};case"activity":return{type:"activity",label:e.detail,detail:e.kind};case"completed":return{type:"done",status:e.status};case"stopped":return{type:"done",status:"stopped"};case"error":return{type:"error",message:e.message};default:return e}}function el(e){let t;if(e.startsWith("/api/files/")&&e.endsWith("/diff"))t=e.slice(11,-5);else if(e.startsWith("/api/diff/"))t=e.slice(10);else if(e.startsWith("/api/patch/"))t=e.slice(11);if(t===void 0||!t)return;try{return decodeURIComponent(t)}catch{throw new C("invalid_file","File identifier is not valid URL encoding")}}async function B(e){let t=await e.text();if(t.length>65536)throw new C("request_too_large","Request body is too large",413);try{let s=JSON.parse(t);return s&&typeof s==="object"&&!Array.isArray(s)?s:null}catch{throw new C("invalid_json","Request body must be valid JSON")}}function tl(e,t){let s=new TextEncoder,n=!1,r=!1,i=()=>{},o=()=>{if(r)return;r=!0,t.close()},a=new ReadableStream({start(l){t.open();let c=(p,u)=>{if(n)return;try{l.enqueue(s.encode(`event: ${p}
|
|
411
|
+
data: ${JSON.stringify(u)}
|
|
407
412
|
|
|
408
|
-
`))}catch{
|
|
413
|
+
`))}catch{n=!0,i(),o()}};i=e.subscribe((p)=>c("repository",{changed:p.changed,revision:p.revision})),e.getRepositoryMetadata().then((p)=>{c("ready",{revision:p.revision})}).catch(()=>{})},cancel(){n=!0,i(),o()}});return new Response(a,{headers:{"cache-control":"no-cache, no-store",connection:"keep-alive","content-type":"text/event-stream; charset=utf-8","x-accel-buffering":"no"}})}function sl(e){let t=e??process.env.REVIEWME_STATIC_DIR;if(!t){let n=Rs(Ha(Ja(import.meta.url)),"../frontend");return pr(As(n,"index.html"))?n:void 0}let s=Ya(t)?t:Rs(process.cwd(),t);return pr(As(s,"index.html"))?s:void 0}async function nl(e,t){if(!t)return new Response(Va,{headers:{"content-type":"text/html; charset=utf-8"}});let s;try{s=decodeURIComponent(e.pathname)}catch{return new Response("Bad URL",{status:400})}let n=s==="/"?"index.html":s.replace(/^\/+/,""),r=Rs(t,n);if(r!==t&&!r.startsWith(`${t}/`))return new Response("Not found",{status:404});try{let o=await mr(r);if(o.isFile())return new Response(yt.toWeb(hr(r)),{headers:{"cache-control":"no-cache","content-length":String(o.size),"content-type":Ga[gr(r).toLowerCase()]??"application/octet-stream"}})}catch{}let i=As(t,"index.html");if(!gr(r))try{let o=await mr(i);if(o.isFile())return new Response(yt.toWeb(hr(i)),{headers:{"content-length":String(o.size),"content-type":"text/html; charset=utf-8"}})}catch{}return new Response("Not found",{status:404})}class C extends Error{code;status;constructor(e,t,s=400){super(t);this.name="RequestError",this.code=e,this.status=s}}function rl(e){if(e instanceof C)return R({error:{code:e.code,message:e.message}},e.status);if(e instanceof dt)return R({error:{code:e.code,message:e.message}},404);if(e instanceof Y)return R({error:{code:"invalid_path",message:e.message}},400);if(e instanceof O)return R({error:{code:"invalid_review",message:e.message}},400);if(e instanceof D)return R({error:{code:"not_found",message:e.message}},404);if(e instanceof ce){let s=e.code==="invalid_ref"||e.code==="no_merge_base"?422:400;return R({error:{code:e.code,message:e.message}},s)}if(e instanceof G)return R({error:{code:"git_error",message:e.message}},500);let t=e instanceof Error?e.message:"Unexpected server error";return R({error:{code:"internal_error",message:t}},500)}function R(e,t=200,s={}){return new Response(JSON.stringify(e),{status:t,headers:{"cache-control":"no-store","content-type":"application/json; charset=utf-8",...s}})}import{readFile as ry,stat as iy}from"node:fs/promises";import{extname as oy,resolve as ay}from"node:path";var yg=Rn(),wg=Ze(),bg=dn(),Fn=et(),_g=$e(),le=N(),Sg=ne(),Eg=k(),vg=ie(),Tg=oe(),Sb=ss(),Ag=Mn(),Rg=Dn(),Cg=qn(),os=Oo(),Lo=qe();var Ng=yg.Composer,xg=wg.Document,Og=bg.Schema,Lg=Fn.YAMLError,kg=Fn.YAMLParseError,Ig=Fn.YAMLWarning,Pg=_g.Alias,Mg=le.isAlias,Dg=le.isCollection,qg=le.isDocument,Fg=le.isMap,$g=le.isNode,Ug=le.isPair,Bg=le.isScalar,jg=le.isSeq,Kg=Sg.Pair,Wg=Eg.Scalar,Hg=vg.YAMLMap,Yg=Tg.YAMLSeq;var Jg=Ag.Lexer,Vg=Rg.LineCounter,Gg=Cg.Parser,$n=os.parse,Xg=os.parseAllDocuments,zg=os.parseDocument,Qg=os.stringify,Zg=Lo.visit,ey=Lo.visitAsync;var ko=["background","sidebar","panel","panelRaised","border","borderStrong","text","muted","subtle","accent","added","deleted","info"],ty=new Set(["name","version","light","dark","syntax"]),Io=new Set(["github-light","github-dark","github-dark-dimmed","nord","dracula","dracula-soft"]),sy=[/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i,/^rgba?\(\s*\d{1,3}(?:\.\d+)?%?\s*,\s*\d{1,3}(?:\.\d+)?%?\s*,\s*\d{1,3}(?:\.\d+)?%?(?:\s*,\s*(?:0|1|0?\.\d+|\d+(?:\.\d+)?%))?\s*\)$/i,/^hsla?\(\s*-?\d+(?:\.\d+)?(?:deg)?\s*,\s*\d+(?:\.\d+)?%\s*,\s*\d+(?:\.\d+)?%(?:\s*,\s*(?:0|1|0?\.\d+|\d+(?:\.\d+)?%))?\s*\)$/i];function ny(e){if(!Un(e))throw Error("theme must be an object");for(let n of Object.keys(e))if(!ty.has(n))throw Error(`unknown field: ${n}`);if(typeof e.name!=="string"||e.name.trim()==="")throw Error("name must be a non-empty string");if(e.version!==1)throw Error("version must be 1");let t=(n)=>{let r=e[n];if(!Un(r))throw Error(`${n} must be an object`);for(let i of Object.keys(r))if(!ko.includes(i))throw Error(`${n}.${i} is not supported`);return Object.fromEntries(ko.map((i)=>{let o=r[i];if(typeof o!=="string"||!sy.some((a)=>a.test(o.trim())))throw Error(`${n}.${i} must be a safe CSS color`);return[i,o.trim()]}))},s=e.syntax;if(s!==void 0&&!Un(s))throw Error("syntax must be an object");if(s!=null){for(let n of Object.keys(s))if(n!=="light"&&n!=="dark")throw Error(`syntax.${n} is not supported`);if(s.light!==void 0&&(typeof s.light!=="string"||!Io.has(s.light)))throw Error("syntax.light is not a supported syntax theme");if(s.dark!==void 0&&(typeof s.dark!=="string"||!Io.has(s.dark)))throw Error("syntax.dark is not a supported syntax theme")}return{name:e.name.trim(),version:1,light:t("light"),dark:t("dark"),syntax:{light:s?.light??"github-light",dark:s?.dark??"github-dark"}}}function Po(e,t){let s;try{s=t==="json"?JSON.parse(e):$n(e,{maxAliasCount:50})}catch(n){throw Error(`could not parse ${t.toUpperCase()}: ${n instanceof Error?n.message:String(n)}`)}return ny(s)}var as=(e,t,s,n={light:"github-light",dark:"github-dark"})=>({name:e,version:1,light:t,dark:s,syntax:n}),Tb={default:as("Default",{background:"#f5f6f4",sidebar:"#eef0ed",panel:"#ffffff",panelRaised:"#e7eae6",border:"rgba(22,31,28,0.11)",borderStrong:"rgba(22,31,28,0.20)",text:"#202724",muted:"#64706b",subtle:"#89938f",accent:"#303ca9",added:"#16844b",deleted:"#c13e45",info:"#316fc1"},{background:"#0d0f10",sidebar:"#111315",panel:"#151819",panelRaised:"#1b1f20",border:"rgba(255,255,255,0.09)",borderStrong:"rgba(255,255,255,0.15)",text:"#e2e6e5",muted:"#8c9694",subtle:"#5e6967",accent:"#4c67dc",added:"#5bc98a",deleted:"#f07979",info:"#7aa8ff"}),github:as("GitHub",{background:"#ffffff",sidebar:"#f6f8fa",panel:"#ffffff",panelRaised:"#f6f8fa",border:"rgba(31,35,40,0.15)",borderStrong:"rgba(31,35,40,0.25)",text:"#1f2328",muted:"#636c76",subtle:"#8c959f",accent:"#0969da",added:"#1a7f37",deleted:"#cf222e",info:"#0969da"},{background:"#0d1117",sidebar:"#161b22",panel:"#161b22",panelRaised:"#21262d",border:"rgba(240,246,252,0.10)",borderStrong:"rgba(240,246,252,0.20)",text:"#e6edf3",muted:"#8b949e",subtle:"#6e7681",accent:"#58a6ff",added:"#3fb950",deleted:"#f85149",info:"#58a6ff"}),nord:as("Nord",{background:"#eceff4",sidebar:"#e5e9f0",panel:"#ffffff",panelRaised:"#d8dee9",border:"rgba(46,52,64,0.12)",borderStrong:"rgba(46,52,64,0.22)",text:"#2e3440",muted:"#667080",subtle:"#8792a2",accent:"#5e81ac",added:"#3b8c6e",deleted:"#bf616a",info:"#5e81ac"},{background:"#2e3440",sidebar:"#272c36",panel:"#343b49",panelRaised:"#3b4352",border:"rgba(236,239,244,0.10)",borderStrong:"rgba(236,239,244,0.18)",text:"#eceff4",muted:"#aeb8c8",subtle:"#7f8a9a",accent:"#88c0d0",added:"#a3be8c",deleted:"#bf616a",info:"#81a1c1"},{light:"github-light",dark:"nord"}),dracula:as("Dracula",{background:"#f8f8f2",sidebar:"#eeeeea",panel:"#ffffff",panelRaised:"#e5e5df",border:"rgba(40,42,54,0.13)",borderStrong:"rgba(40,42,54,0.23)",text:"#282a36",muted:"#626579",subtle:"#898b99",accent:"#7c3aed",added:"#2d8a54",deleted:"#c43d58",info:"#526ddb"},{background:"#282a36",sidebar:"#21222c",panel:"#30323f",panelRaised:"#3a3c4b",border:"rgba(248,248,242,0.10)",borderStrong:"rgba(248,248,242,0.18)",text:"#f8f8f2",muted:"#b5b6c3",subtle:"#77798a",accent:"#bd93f9",added:"#50fa7b",deleted:"#ff5555",info:"#8be9fd"},{light:"github-light",dark:"dracula"})};function Un(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}var ly=262144;async function Mo(e){let t=ay(process.cwd(),e);try{let s=await iy(t);if(!s.isFile())throw Error("path is not a file");if(s.size>ly)throw Error("file exceeds the 256 KB limit");let n=oy(t).toLowerCase();if(n!==".json"&&n!==".yaml"&&n!==".yml")throw Error("file extension must be .json, .yaml, or .yml");return Po(await ry(t,"utf8"),n===".json"?"json":"yaml")}catch(s){throw Error(`Color theme ${e}: ${s instanceof Error?s.message:String(s)}`)}}async function Do(e,t={}){try{let s=await(t.fetchImpl??fetch)("https://registry.npmjs.org/reviewme/latest",{signal:AbortSignal.timeout(t.timeoutMs??2000)});if(!s.ok)return;let n=await s.json(),r=n!=null&&typeof n==="object"&&"version"in n?n.version:void 0;if(typeof r!=="string"||!cy(r,e))return;(t.write??console.log)(`
|
|
409
414
|
Update available: ${e} → ${r}
|
|
410
|
-
Run: npx reviewme@latest`)}catch{}}function cy(e,t){let s=/^(\d+)\.(\d+)\.(\d+)$/.exec(e),n=/^(\d+)\.(\d+)\.(\d+)$/.exec(t);if(s==null||n==null)return!1;for(let r=1;r<=3;r+=1){let i=Number(s[r])-Number(n[r]);if(i!==0)return i>0}return!1}async function qo(e=process.argv.slice(2),t={}){try{let s=tr(e);if(s.help)return console.log(sr),0;let n=ut({repoPath:s.repoPath,range:s.range,from:s.from,to:s.to,openCommand:s.openCommand,watchIntervalMs:s.watchIntervalMs}),r=s.colorThemePath==null?void 0:await Mo(s.colorThemePath),i=await br({...t,service:n,port:s.port,auth:s.auth,watchIntervalMs:s.watchIntervalMs,colorTheme:r});if(console.log(`ReviewMe: ${i.url}`),Do(jn.version),s.openBrowser)await uy(i.url);let o=()=>i.close();return process.once("SIGINT",o),process.once("SIGTERM",o),0}catch(s){return console.error(s instanceof Error?s.message:String(s)),1}}async function uy(e){let t=process.platform,s=t==="darwin"?["open",e]:t==="win32"?["cmd","/c","start","",e]:["xdg-open",e];try{let[n,...r]=s;if(!n)return;let i=dy(n,r,{stdio:"ignore",detached:!0});i.once("error",()=>{}),i.unref()}catch{}}var Fo=await qo();if(Fo!==0)process.exitCode=Fo;
|
|
415
|
+
Run: npx reviewme@latest`)}catch{}}function cy(e,t){let s=/^(\d+)\.(\d+)\.(\d+)$/.exec(e),n=/^(\d+)\.(\d+)\.(\d+)$/.exec(t);if(s==null||n==null)return!1;for(let r=1;r<=3;r+=1){let i=Number(s[r])-Number(n[r]);if(i!==0)return i>0}return!1}async function qo(e=process.argv.slice(2),t={}){try{let s=tr(e);if(s.help)return console.log(sr),0;let n=ut({repoPath:s.repoPath,range:s.range,from:s.from,to:s.to,openCommand:s.openCommand,watchIntervalMs:s.watchIntervalMs}),r=s.colorThemePath==null?void 0:await Mo(s.colorThemePath),i=await br({...t,service:n,port:s.port,auth:s.auth,watchIntervalMs:s.watchIntervalMs,colorTheme:r,exitOnCloseAfterSeconds:s.exitOnCloseAfterSeconds});if(console.log(`ReviewMe: ${i.url}`),Do(jn.version),s.openBrowser)await uy(i.url);let o=()=>i.close();return process.once("SIGINT",o),process.once("SIGTERM",o),0}catch(s){return console.error(s instanceof Error?s.message:String(s)),1}}async function uy(e){let t=process.platform,s=t==="darwin"?["open",e]:t==="win32"?["cmd","/c","start","",e]:["xdg-open",e];try{let[n,...r]=s;if(!n)return;let i=dy(n,r,{stdio:"ignore",detached:!0});i.once("error",()=>{}),i.unref()}catch{}}var Fo=await qo();if(Fo!==0)process.exitCode=Fo;
|
|
411
416
|
|
|
412
|
-
//# debugId=
|
|
417
|
+
//# debugId=A3A934011553D46264756E2164756E21
|
|
413
418
|
//# sourceMappingURL=main.js.map
|