pickety 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/cli.js +13 -13
- package/out/extension.js +21 -21
- package/package.json +4 -4
package/out/cli.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`;break;case 114:g+="\r";break;case 116:g+=" ";break;case 117:let y=p(4,!0);y>=0?g+=String.fromCharCode(y):
|
|
4
|
-
`),c++,
|
|
5
|
-
`+" ".repeat(t)),"\r":new Array(
|
|
6
|
-
`+" ".repeat(t))}," ":{"\n":new Array(
|
|
7
|
-
`+" ".repeat(t)),"\r":new Array(
|
|
8
|
-
`+" ".repeat(t))}};var ie;(function(e){e.DEFAULT={allowTrailingComma:!1}})(ie||(ie={}));function Ae(e,t=[],s=ie.DEFAULT){let n=null,i=[],r=[];function o(l){Array.isArray(i)?i.push(l):n!==null&&(i[n]=l)}return Ne(e,{onObjectBegin:()=>{let l={};o(l),r.push(i),i=l,n=null},onObjectProperty:l=>{n=l},onObjectEnd:()=>{i=r.pop()},onArrayBegin:()=>{let l=[];o(l),r.push(i),i=l,n=null},onArrayEnd:()=>{i=r.pop()},onLiteralValue:o,onError:(l,a,u)=>{t.push({error:l,offset:a,length:u})}},s),i[0]}function Ne(e,t,s=ie.DEFAULT){let n=se(e,!1),i=[],r=0;function o(S){return S?()=>r===0&&S(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function c(S){return S?O=>r===0&&S(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function l(S){return S?O=>r===0&&S(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}function a(S){return S?()=>{r>0?r++:S(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice())===!1&&(r=1)}:()=>!0}function u(S){return S?()=>{r>0&&r--,r===0&&S(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}let f=a(t.onObjectBegin),p=l(t.onObjectProperty),h=u(t.onObjectEnd),d=a(t.onArrayBegin),m=u(t.onArrayEnd),b=l(t.onLiteralValue),T=c(t.onSeparator),E=o(t.onComment),g=c(t.onError),x=s&&s.disallowComments,w=s&&s.allowTrailingComma;function k(){for(;;){let S=n.scan();switch(n.getTokenError()){case 4:y(14);break;case 5:y(15);break;case 3:y(13);break;case 1:x||y(11);break;case 2:y(12);break;case 6:y(16);break}switch(S){case 12:case 13:x?y(10):E();break;case 16:y(1);break;case 15:case 14:break;default:return S}}}function y(S,O=[],Te=[]){if(g(S),O.length+Te.length>0){let ne=n.getToken();for(;ne!==17;){if(O.indexOf(ne)!==-1){k();break}else if(Te.indexOf(ne)!==-1)break;ne=k()}}}function W(S){let O=n.getTokenValue();return S?b(O):(p(O),i.push(O)),k(),!0}function I(){switch(n.getToken()){case 11:let S=n.getTokenValue(),O=Number(S);isNaN(O)&&(y(2),O=0),b(O);break;case 7:b(null);break;case 8:b(!0);break;case 9:b(!1);break;default:return!1}return k(),!0}function R(){return n.getToken()!==10?(y(3,[],[2,5]),!1):(W(!1),n.getToken()===6?(T(":"),k(),V()||y(4,[],[2,5])):y(5,[],[2,5]),i.pop(),!0)}function j(){f(),k();let S=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(S||y(4,[],[]),T(","),k(),n.getToken()===2&&w)break}else S&&y(6,[],[]);R()||y(4,[],[2,5]),S=!0}return h(),n.getToken()!==2?y(7,[2],[]):k(),!0}function L(){d(),k();let S=!0,O=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(O||y(4,[],[]),T(","),k(),n.getToken()===4&&w)break}else O&&y(6,[],[]);S?(i.push(0),S=!1):i[i.length-1]++,V()||y(4,[],[4,5]),O=!0}return m(),S||i.pop(),n.getToken()!==4?y(8,[4],[]):k(),!0}function V(){switch(n.getToken()){case 3:return L();case 1:return j();case 10:return W(!0);default:return I()}}return k(),n.getToken()===17?s.allowEmptyContent?!0:(y(4,[],[]),!1):V()?(n.getToken()!==17&&y(9,[],[]),!0):(y(4,[],[]),!1)}var $e;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})($e||($e={}));var Me;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(Me||(Me={}));var pe=Ae;var Re;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(Re||(Re={}));var be=B(require("path"));var he=(e,t,s)=>{let n=e instanceof RegExp?je(e,s):e,i=t instanceof RegExp?je(t,s):t,r=n!==null&&i!=null&&$t(n,i,s);return r&&{start:r[0],end:r[1],pre:s.slice(0,r[0]),body:s.slice(r[0]+n.length,r[1]),post:s.slice(r[1]+i.length)}},je=(e,t)=>{let s=t.match(e);return s?s[0]:null},$t=(e,t,s)=>{let n,i,r,o,c,l=s.indexOf(e),a=s.indexOf(t,l+1),u=l;if(l>=0&&a>0){if(e===t)return[l,a];for(n=[],r=s.length;u>=0&&!c;){if(u===l)n.push(u),l=s.indexOf(e,u+1);else if(n.length===1){let f=n.pop();f!==void 0&&(c=[f,a])}else i=n.pop(),i!==void 0&&i<r&&(r=i,o=a),a=s.indexOf(t,u+1);u=l<a&&l>=0?l:a}n.length&&o!==void 0&&(c=[r,o])}return c};var Le="\0SLASH"+Math.random()+"\0",Ie="\0OPEN"+Math.random()+"\0",de="\0CLOSE"+Math.random()+"\0",Ve="\0COMMA"+Math.random()+"\0",Pe="\0PERIOD"+Math.random()+"\0",Mt=new RegExp(Le,"g"),Rt=new RegExp(Ie,"g"),jt=new RegExp(de,"g"),Lt=new RegExp(Ve,"g"),It=new RegExp(Pe,"g"),Vt=/\\\\/g,Pt=/\\{/g,_t=/\\}/g,Bt=/\\,/g,Ft=/\\./g,Dt=1e5;function ge(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Wt(e){return e.replace(Vt,Le).replace(Pt,Ie).replace(_t,de).replace(Bt,Ve).replace(Ft,Pe)}function zt(e){return e.replace(Mt,"\\").replace(Rt,"{").replace(jt,"}").replace(Lt,",").replace(It,".")}function _e(e){if(!e)return[""];let t=[],s=he("{","}",e);if(!s)return e.split(",");let{pre:n,body:i,post:r}=s,o=n.split(",");o[o.length-1]+="{"+i+"}";let c=_e(r);return r.length&&(o[o.length-1]+=c.shift(),o.push.apply(o,c)),t.push.apply(t,o),t}function Be(e,t={}){if(!e)return[];let{max:s=Dt}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),Y(Wt(e),s,!0).map(zt)}function Ut(e){return"{"+e+"}"}function Ht(e){return/^-?0\d/.test(e)}function Gt(e,t){return e<=t}function qt(e,t){return e>=t}function Y(e,t,s){let n=[],i=he("{","}",e);if(!i)return[e];let r=i.pre,o=i.post.length?Y(i.post,t,!1):[""];if(/\$$/.test(i.pre))for(let c=0;c<o.length&&c<t;c++){let l=r+"{"+i.body+"}"+o[c];n.push(l)}else{let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),a=c||l,u=i.body.indexOf(",")>=0;if(!a&&!u)return i.post.match(/,(?!,).*\}/)?(e=i.pre+"{"+i.body+de+i.post,Y(e,t,!0)):[e];let f;if(a)f=i.body.split(/\.\./);else if(f=_e(i.body),f.length===1&&f[0]!==void 0&&(f=Y(f[0],t,!1).map(Ut),f.length===1))return o.map(h=>i.pre+f[0]+h);let p;if(a&&f[0]!==void 0&&f[1]!==void 0){let h=ge(f[0]),d=ge(f[1]),m=Math.max(f[0].length,f[1].length),b=f.length===3&&f[2]!==void 0?Math.abs(ge(f[2])):1,T=Gt;d<h&&(b*=-1,T=qt);let g=f.some(Ht);p=[];for(let x=h;T(x,d);x+=b){let w;if(l)w=String.fromCharCode(x),w==="\\"&&(w="");else if(w=String(x),g){let k=m-w.length;if(k>0){let y=new Array(k+1).join("0");x<0?w="-"+y+w.slice(1):w=y+w}}p.push(w)}}else{p=[];for(let h=0;h<f.length;h++)p.push.apply(p,Y(f[h],t,!1))}for(let h=0;h<p.length;h++)for(let d=0;d<o.length&&n.length<t;d++){let m=r+p[h]+o[d];(!s||a||m)&&n.push(m)}}return n}var K=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Xt={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},C=e=>e.replace(/[[\]\\-]/g,"\\$&"),Jt=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Fe=e=>e.join(""),De=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let n=[],i=[],r=s+1,o=!1,c=!1,l=!1,a=!1,u=s,f="";e:for(;r<e.length;){let m=e.charAt(r);if((m==="!"||m==="^")&&r===s+1){a=!0,r++;continue}if(m==="]"&&o&&!l){u=r+1;break}if(o=!0,m==="\\"&&!l){l=!0,r++;continue}if(m==="["&&!l){for(let[b,[T,E,g]]of Object.entries(Xt))if(e.startsWith(b,r)){if(f)return["$.",!1,e.length-s,!0];r+=b.length,g?i.push(T):n.push(T),c=c||E;continue e}}if(l=!1,f){m>f?n.push(C(f)+"-"+C(m)):m===f&&n.push(C(m)),f="",r++;continue}if(e.startsWith("-]",r+1)){n.push(C(m+"-")),r+=2;continue}if(e.startsWith("-",r+1)){f=m,r+=2;continue}n.push(C(m)),r++}if(u<r)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-s,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!a){let m=n[0].length===2?n[0].slice(-1):n[0];return[Jt(m),!1,u-s,!1]}let p="["+(a?"^":"")+Fe(n)+"]",h="["+(a?"":"^")+Fe(i)+"]";return[n.length&&i.length?"("+p+"|"+h+")":n.length?p:h,c,u-s,!0]};var P=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!0}={})=>s?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var Zt=new Set(["!","?","+","*","@"]),We=e=>Zt.has(e),Qt="(?!(?:^|/)\\.\\.?(?:$|/))",re="(?!\\.)",Yt=new Set(["[","."]),Kt=new Set(["..","."]),Ct=new Set("().*{}+?[]^$\\!"),en=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),me="[^/]",ze=me+"*?",Ue=me+"+?",H=class e{type;#n;#s;#r=!1;#e=[];#t;#o;#c;#l=!1;#i;#a;#u=!1;constructor(t,s,n={}){this.type=t,t&&(this.#s=!0),this.#t=s,this.#n=this.#t?this.#t.#n:this,this.#i=this.#n===this?n:this.#n.#i,this.#c=this.#n===this?[]:this.#n.#c,t==="!"&&!this.#n.#l&&this.#c.push(this),this.#o=this.#t?this.#t.#e.length:0}get hasMagic(){if(this.#s!==void 0)return this.#s;for(let t of this.#e)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#s=!0;return this.#s}toString(){return this.#a!==void 0?this.#a:this.type?this.#a=this.type+"("+this.#e.map(t=>String(t)).join("|")+")":this.#a=this.#e.map(t=>String(t)).join("")}#h(){if(this!==this.#n)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let t;for(;t=this.#c.pop();){if(t.type!=="!")continue;let s=t,n=s.#t;for(;n;){for(let i=s.#o+1;!n.type&&i<n.#e.length;i++)for(let r of t.#e){if(typeof r=="string")throw new Error("string part in extglob AST??");r.copyIn(n.#e[i])}s=n,n=s.#t}}return this}push(...t){for(let s of t)if(s!==""){if(typeof s!="string"&&!(s instanceof e&&s.#t===this))throw new Error("invalid part: "+s);this.#e.push(s)}}toJSON(){let t=this.type===null?this.#e.slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...this.#e.map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#n||this.#n.#l&&this.#t?.type==="!")&&t.push({}),t}isStart(){if(this.#n===this)return!0;if(!this.#t?.isStart())return!1;if(this.#o===0)return!0;let t=this.#t;for(let s=0;s<this.#o;s++){let n=t.#e[s];if(!(n instanceof e&&n.type==="!"))return!1}return!0}isEnd(){if(this.#n===this||this.#t?.type==="!")return!0;if(!this.#t?.isEnd())return!1;if(!this.type)return this.#t?.isEnd();let t=this.#t?this.#t.#e.length:0;return this.#o===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let s=new e(this.type,t);for(let n of this.#e)s.copyIn(n);return s}static#f(t,s,n,i){let r=!1,o=!1,c=-1,l=!1;if(s.type===null){let h=n,d="";for(;h<t.length;){let m=t.charAt(h++);if(r||m==="\\"){r=!r,d+=m;continue}if(o){h===c+1?(m==="^"||m==="!")&&(l=!0):m==="]"&&!(h===c+2&&l)&&(o=!1),d+=m;continue}else if(m==="["){o=!0,c=h,l=!1,d+=m;continue}if(!i.noext&&We(m)&&t.charAt(h)==="("){s.push(d),d="";let b=new e(m,s);h=e.#f(t,b,h,i),s.push(b);continue}d+=m}return s.push(d),h}let a=n+1,u=new e(null,s),f=[],p="";for(;a<t.length;){let h=t.charAt(a++);if(r||h==="\\"){r=!r,p+=h;continue}if(o){a===c+1?(h==="^"||h==="!")&&(l=!0):h==="]"&&!(a===c+2&&l)&&(o=!1),p+=h;continue}else if(h==="["){o=!0,c=a,l=!1,p+=h;continue}if(We(h)&&t.charAt(a)==="("){u.push(p),p="";let d=new e(h,u);u.push(d),a=e.#f(t,d,a,i);continue}if(h==="|"){u.push(p),p="",f.push(u),u=new e(null,s);continue}if(h===")")return p===""&&s.#e.length===0&&(s.#u=!0),u.push(p),p="",s.push(...f,u),a;p+=h}return s.type=null,s.#s=void 0,s.#e=[t.substring(n-1)],a}static fromGlob(t,s={}){let n=new e(null,void 0,s);return e.#f(t,n,0,s),n}toMMPattern(){if(this!==this.#n)return this.#n.toMMPattern();let t=this.toString(),[s,n,i,r]=this.toRegExpSource();if(!(i||this.#s||this.#i.nocase&&!this.#i.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let c=(this.#i.nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${s}$`,c),{_src:s,_glob:t})}get options(){return this.#i}toRegExpSource(t){let s=t??!!this.#i.dot;if(this.#n===this&&this.#h(),!this.type){let l=this.isStart()&&this.isEnd()&&!this.#e.some(h=>typeof h!="string"),a=this.#e.map(h=>{let[d,m,b,T]=typeof h=="string"?e.#g(h,this.#s,l):h.toRegExpSource(t);return this.#s=this.#s||b,this.#r=this.#r||T,d}).join(""),u="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&Kt.has(this.#e[0]))){let d=Yt,m=s&&d.has(a.charAt(0))||a.startsWith("\\.")&&d.has(a.charAt(2))||a.startsWith("\\.\\.")&&d.has(a.charAt(4)),b=!s&&!t&&d.has(a.charAt(0));u=m?Qt:b?re:""}let f="";return this.isEnd()&&this.#n.#l&&this.#t?.type==="!"&&(f="(?:$|\\/)"),[u+a+f,P(a),this.#s=!!this.#s,this.#r]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",r=this.#p(s);if(this.isStart()&&this.isEnd()&&!r&&this.type!=="!"){let l=this.toString();return this.#e=[l],this.type=null,this.#s=void 0,[l,P(this.toString()),!1,!1]}let o=!n||t||s||!re?"":this.#p(!0);o===r&&(o=""),o&&(r=`(?:${r})(?:${o})*?`);let c="";if(this.type==="!"&&this.#u)c=(this.isStart()&&!s?re:"")+Ue;else{let l=this.type==="!"?"))"+(this.isStart()&&!s&&!t?re:"")+ze+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;c=i+r+l}return[c,P(r),this.#s=!!this.#s,this.#r]}#p(t){return this.#e.map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[n,i,r,o]=s.toRegExpSource(t);return this.#r=this.#r||o,n}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")}static#g(t,s,n=!1){let i=!1,r="",o=!1,c=!1;for(let l=0;l<t.length;l++){let a=t.charAt(l);if(i){i=!1,r+=(Ct.has(a)?"\\":"")+a;continue}if(a==="*"){if(c)continue;c=!0,r+=n&&/^[*]+$/.test(t)?Ue:ze,s=!0;continue}else c=!1;if(a==="\\"){l===t.length-1?r+="\\\\":i=!0;continue}if(a==="["){let[u,f,p,h]=De(t,l);if(p){r+=u,o=o||f,l+=p-1,s=s||h;continue}}if(a==="?"){r+=me,s=!0;continue}r+=en(a)}return[r,P(t),!!s,o]}};var ye=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!1}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var v=(e,t,s={})=>(K(t),!s.nocomment&&t.charAt(0)==="#"?!1:new G(t,s).match(e)),tn=/^\*+([^+@!?\*\[\(]*)$/,nn=e=>t=>!t.startsWith(".")&&t.endsWith(e),sn=e=>t=>t.endsWith(e),rn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),on=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),ln=/^\*+\.\*+$/,cn=e=>!e.startsWith(".")&&e.includes("."),an=e=>e!=="."&&e!==".."&&e.includes("."),fn=/^\.\*+$/,un=e=>e!=="."&&e!==".."&&e.startsWith("."),pn=/^\*+$/,hn=e=>e.length!==0&&!e.startsWith("."),gn=e=>e.length!==0&&e!=="."&&e!=="..",dn=/^\?+([^+@!?\*\[\(]*)?$/,mn=([e,t=""])=>{let s=qe([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},yn=([e,t=""])=>{let s=Xe([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},bn=([e,t=""])=>{let s=Xe([e]);return t?n=>s(n)&&n.endsWith(t):s},kn=([e,t=""])=>{let s=qe([e]);return t?n=>s(n)&&n.endsWith(t):s},qe=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},Xe=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},Je=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",He={win32:{sep:"\\"},posix:{sep:"/"}},wn=Je==="win32"?He.win32.sep:He.posix.sep;v.sep=wn;var M=Symbol("globstar **");v.GLOBSTAR=M;var Sn="[^/]",xn=Sn+"*?",vn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Tn="(?:(?!(?:\\/|^)\\.).)*?",En=(e,t={})=>s=>v(s,e,t);v.filter=En;var $=(e,t={})=>Object.assign({},e,t),On=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return v;let t=v;return Object.assign((n,i,r={})=>t(n,i,$(e,r)),{Minimatch:class extends t.Minimatch{constructor(i,r={}){super(i,$(e,r))}static defaults(i){return t.defaults($(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,r,o={}){super(i,r,$(e,o))}static fromGlob(i,r={}){return t.AST.fromGlob(i,$(e,r))}},unescape:(n,i={})=>t.unescape(n,$(e,i)),escape:(n,i={})=>t.escape(n,$(e,i)),filter:(n,i={})=>t.filter(n,$(e,i)),defaults:n=>t.defaults($(e,n)),makeRe:(n,i={})=>t.makeRe(n,$(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,$(e,i)),match:(n,i,r={})=>t.match(n,i,$(e,r)),sep:t.sep,GLOBSTAR:M})};v.defaults=On;var Ze=(e,t={})=>(K(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Be(e,{max:t.braceExpandMax}));v.braceExpand=Ze;var An=(e,t={})=>new G(e,t).makeRe();v.makeRe=An;var Nn=(e,t,s={})=>{let n=new G(t,s);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};v.match=Nn;var Ge=/[?*]|[+@!]\(.*?\)|\[|\]/,$n=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),G=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,s={}){K(t),s=s||{},this.options=s,this.pattern=t,this.platform=s.platform||Je,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!s.windowsPathsNoEscape||s[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!s.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!s.nonegate,this.comment=!1,this.empty=!1,this.partial=!!s.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=s.windowsNoMagicRoot!==void 0?s.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let s of t)if(typeof s!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,s=this.options;if(!s.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],s.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((r,o,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=r[0]===""&&r[1]===""&&(r[2]==="?"||!Ge.test(r[2]))&&!Ge.test(r[3]),a=/^[a-z]:/i.test(r[0]);if(l)return[...r.slice(0,4),...r.slice(4).map(u=>this.parse(u))];if(a)return[r[0],...r.slice(1).map(u=>this.parse(u))]}return r.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let o=this.set[r];o[0]===""&&o[1]===""&&this.globParts[r][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n=0;n<t.length;n++)for(let i=0;i<t[n].length;i++)t[n][i]==="**"&&(t[n][i]="*");let{optimizationLevel:s=1}=this.options;return s>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):s>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(s=>{let n=-1;for(;(n=s.indexOf("**",n+1))!==-1;){let i=n;for(;s[i+1]==="**";)i++;i!==n&&s.splice(n,i-n)}return s})}levelOneOptimize(t){return t.map(s=>(s=s.reduce((n,i)=>{let r=n[n.length-1];return i==="**"&&r==="**"?n:i===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(n.pop(),n):(n.push(i),n)},[]),s.length===0?[""]:s))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let s=!1;do{if(s=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let r=t[i];i===1&&r===""&&t[0]===""||(r==="."||r==="")&&(s=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(s=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&(s=!0,t.splice(n-1,2),n-=2)}}while(s);return t.length===0?[""]:t}firstPhasePreProcess(t){let s=!1;do{s=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let c=n[i+1],l=n[i+2],a=n[i+3];if(c!==".."||!l||l==="."||l===".."||!a||a==="."||a==="..")continue;s=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let c=n[o];o===1&&c===""&&n[0]===""||(c==="."||c==="")&&(s=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(s=!0,n.pop())}let r=0;for(;(r=n.indexOf("..",r+1))!==-1;){let o=n[r-1];if(o&&o!=="."&&o!==".."&&o!=="**"){s=!0;let l=r===1&&n[r+1]==="**"?["."]:[];n.splice(r-1,2,...l),n.length===0&&n.push(""),r-=2}}}}while(s);return t}secondPhasePreProcess(t){for(let s=0;s<t.length-1;s++)for(let n=s+1;n<t.length;n++){let i=this.partsMatch(t[s],t[n],!this.preserveMultipleSlashes);if(i){t[s]=[],t[n]=i;break}}return t.filter(s=>s.length)}partsMatch(t,s,n=!1){let i=0,r=0,o=[],c="";for(;i<t.length&&r<s.length;)if(t[i]===s[r])o.push(c==="b"?s[r]:t[i]),i++,r++;else if(n&&t[i]==="**"&&s[r]===t[i+1])o.push(t[i]),i++;else if(n&&s[r]==="**"&&t[i]===s[r+1])o.push(s[r]),r++;else if(t[i]==="*"&&s[r]&&(this.options.dot||!s[r].startsWith("."))&&s[r]!=="**"){if(c==="b")return!1;c="a",o.push(t[i]),i++,r++}else if(s[r]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(c==="a")return!1;c="b",o.push(s[r]),i++,r++}else return!1;return t.length===s.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,s=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)s=!s,n++;n&&(this.pattern=t.slice(n)),this.negate=s}matchOne(t,s,n=!1){let i=this.options;if(this.isWindows){let m=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),b=!m&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),T=typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0]),E=!T&&s[0]===""&&s[1]===""&&s[2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3]),g=b?3:m?0:void 0,x=E?3:T?0:void 0;if(typeof g=="number"&&typeof x=="number"){let[w,k]=[t[g],s[x]];w.toLowerCase()===k.toLowerCase()&&(s[x]=w,x>g?s=s.slice(x):g>x&&(t=t.slice(g)))}}let{optimizationLevel:r=1}=this.options;r>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:s}),this.debug("matchOne",t.length,s.length);for(var o=0,c=0,l=t.length,a=s.length;o<l&&c<a;o++,c++){this.debug("matchOne loop");var u=s[c],f=t[o];if(this.debug(s,u,f),u===!1)return!1;if(u===M){this.debug("GLOBSTAR",[s,u,f]);var p=o,h=c+1;if(h===a){for(this.debug("** at the end");o<l;o++)if(t[o]==="."||t[o]===".."||!i.dot&&t[o].charAt(0)===".")return!1;return!0}for(;p<l;){var d=t[p];if(this.debug(`
|
|
2
|
+
"use strict";var dt=Object.create;var Oe=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var bt=Object.getPrototypeOf,kt=Object.prototype.hasOwnProperty;var wt=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of yt(t))!kt.call(e,i)&&i!==s&&Oe(e,i,{get:()=>t[i],enumerable:!(n=mt(t,i))||n.enumerable});return e};var F=(e,t,s)=>(s=e!=null?dt(bt(e)):{},wt(t||!e||!e.__esModule?Oe(s,"default",{value:e,enumerable:!0}):s,e));var z=F(require("fs")),W=F(require("path"));var P=F(require("path")),B=F(require("fs"));function ie(e,t=!1){let s=e.length,n=0,i="",r=0,o=16,c=0,l=0,f=0,u=0,a=0;function p(g,x){let w=0,k=0;for(;w<g||!x;){let y=e.charCodeAt(n);if(y>=48&&y<=57)k=k*16+y-48;else if(y>=65&&y<=70)k=k*16+y-65+10;else if(y>=97&&y<=102)k=k*16+y-97+10;else break;n++,w++}return w<g&&(k=-1),k}function h(g){n=g,i="",r=0,o=16,a=0}function d(){let g=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&H(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&H(e.charCodeAt(n)))for(n++;n<e.length&&H(e.charCodeAt(n));)n++;else return a=3,e.substring(g,n);let x=n;if(n<e.length&&(e.charCodeAt(n)===69||e.charCodeAt(n)===101))if(n++,(n<e.length&&e.charCodeAt(n)===43||e.charCodeAt(n)===45)&&n++,n<e.length&&H(e.charCodeAt(n))){for(n++;n<e.length&&H(e.charCodeAt(n));)n++;x=n}else a=3;return e.substring(g,x)}function m(){let g="",x=n;for(;;){if(n>=s){g+=e.substring(x,n),a=2;break}let w=e.charCodeAt(n);if(w===34){g+=e.substring(x,n),n++;break}if(w===92){if(g+=e.substring(x,n),n++,n>=s){a=2;break}switch(e.charCodeAt(n++)){case 34:g+='"';break;case 92:g+="\\";break;case 47:g+="/";break;case 98:g+="\b";break;case 102:g+="\f";break;case 110:g+=`
|
|
3
|
+
`;break;case 114:g+="\r";break;case 116:g+=" ";break;case 117:let y=p(4,!0);y>=0?g+=String.fromCharCode(y):a=4;break;default:a=5}x=n;continue}if(w>=0&&w<=31)if(Y(w)){g+=e.substring(x,n),a=2;break}else a=6;n++}return g}function b(){if(i="",a=0,r=n,l=c,u=f,n>=s)return r=s,o=17;let g=e.charCodeAt(n);if(pe(g)){do n++,i+=String.fromCharCode(g),g=e.charCodeAt(n);while(pe(g));return o=15}if(Y(g))return n++,i+=String.fromCharCode(g),g===13&&e.charCodeAt(n)===10&&(n++,i+=`
|
|
4
|
+
`),c++,f=n,o=14;switch(g){case 123:return n++,o=1;case 125:return n++,o=2;case 91:return n++,o=3;case 93:return n++,o=4;case 58:return n++,o=6;case 44:return n++,o=5;case 34:return n++,i=m(),o=10;case 47:let x=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<s&&!Y(e.charCodeAt(n));)n++;return i=e.substring(x,n),o=12}if(e.charCodeAt(n+1)===42){n+=2;let w=s-1,k=!1;for(;n<w;){let y=e.charCodeAt(n);if(y===42&&e.charCodeAt(n+1)===47){n+=2,k=!0;break}n++,Y(y)&&(y===13&&e.charCodeAt(n)===10&&n++,c++,f=n)}return k||(n++,a=1),i=e.substring(x,n),o=13}return i+=String.fromCharCode(g),n++,o=16;case 45:if(i+=String.fromCharCode(g),n++,n===s||!H(e.charCodeAt(n)))return o=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=d(),o=11;default:for(;n<s&&T(g);)n++,g=e.charCodeAt(n);if(r!==n){switch(i=e.substring(r,n),i){case"true":return o=8;case"false":return o=9;case"null":return o=7}return o=16}return i+=String.fromCharCode(g),n++,o=16}}function T(g){if(pe(g)||Y(g))return!1;switch(g){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function E(){let g;do g=b();while(g>=12&&g<=15);return g}return{setPosition:h,getPosition:()=>n,scan:t?E:b,getToken:()=>o,getTokenValue:()=>i,getTokenOffset:()=>r,getTokenLength:()=>n-r,getTokenStartLine:()=>l,getTokenStartCharacter:()=>r-u,getTokenError:()=>a}}function pe(e){return e===32||e===9}function Y(e){return e===10||e===13}function H(e){return e>=48&&e<=57}var Ae;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(Ae||(Ae={}));var xt=new Array(20).fill(0).map((e,t)=>" ".repeat(t)),G=200,vt={" ":{"\n":new Array(G).fill(0).map((e,t)=>`
|
|
5
|
+
`+" ".repeat(t)),"\r":new Array(G).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(G).fill(0).map((e,t)=>`\r
|
|
6
|
+
`+" ".repeat(t))}," ":{"\n":new Array(G).fill(0).map((e,t)=>`
|
|
7
|
+
`+" ".repeat(t)),"\r":new Array(G).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(G).fill(0).map((e,t)=>`\r
|
|
8
|
+
`+" ".repeat(t))}};var re;(function(e){e.DEFAULT={allowTrailingComma:!1}})(re||(re={}));function Ne(e,t=[],s=re.DEFAULT){let n=null,i=[],r=[];function o(l){Array.isArray(i)?i.push(l):n!==null&&(i[n]=l)}return $e(e,{onObjectBegin:()=>{let l={};o(l),r.push(i),i=l,n=null},onObjectProperty:l=>{n=l},onObjectEnd:()=>{i=r.pop()},onArrayBegin:()=>{let l=[];o(l),r.push(i),i=l,n=null},onArrayEnd:()=>{i=r.pop()},onLiteralValue:o,onError:(l,f,u)=>{t.push({error:l,offset:f,length:u})}},s),i[0]}function $e(e,t,s=re.DEFAULT){let n=ie(e,!1),i=[],r=0;function o(S){return S?()=>r===0&&S(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function c(S){return S?O=>r===0&&S(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function l(S){return S?O=>r===0&&S(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}function f(S){return S?()=>{r>0?r++:S(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice())===!1&&(r=1)}:()=>!0}function u(S){return S?()=>{r>0&&r--,r===0&&S(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}let a=f(t.onObjectBegin),p=l(t.onObjectProperty),h=u(t.onObjectEnd),d=f(t.onArrayBegin),m=u(t.onArrayEnd),b=l(t.onLiteralValue),T=c(t.onSeparator),E=o(t.onComment),g=c(t.onError),x=s&&s.disallowComments,w=s&&s.allowTrailingComma;function k(){for(;;){let S=n.scan();switch(n.getTokenError()){case 4:y(14);break;case 5:y(15);break;case 3:y(13);break;case 1:x||y(11);break;case 2:y(12);break;case 6:y(16);break}switch(S){case 12:case 13:x?y(10):E();break;case 16:y(1);break;case 15:case 14:break;default:return S}}}function y(S,O=[],Ee=[]){if(g(S),O.length+Ee.length>0){let se=n.getToken();for(;se!==17;){if(O.indexOf(se)!==-1){k();break}else if(Ee.indexOf(se)!==-1)break;se=k()}}}function U(S){let O=n.getTokenValue();return S?b(O):(p(O),i.push(O)),k(),!0}function j(){switch(n.getToken()){case 11:let S=n.getTokenValue(),O=Number(S);isNaN(O)&&(y(2),O=0),b(O);break;case 7:b(null);break;case 8:b(!0);break;case 9:b(!1);break;default:return!1}return k(),!0}function R(){return n.getToken()!==10?(y(3,[],[2,5]),!1):(U(!1),n.getToken()===6?(T(":"),k(),V()||y(4,[],[2,5])):y(5,[],[2,5]),i.pop(),!0)}function I(){a(),k();let S=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(S||y(4,[],[]),T(","),k(),n.getToken()===2&&w)break}else S&&y(6,[],[]);R()||y(4,[],[2,5]),S=!0}return h(),n.getToken()!==2?y(7,[2],[]):k(),!0}function L(){d(),k();let S=!0,O=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(O||y(4,[],[]),T(","),k(),n.getToken()===4&&w)break}else O&&y(6,[],[]);S?(i.push(0),S=!1):i[i.length-1]++,V()||y(4,[],[4,5]),O=!0}return m(),S||i.pop(),n.getToken()!==4?y(8,[4],[]):k(),!0}function V(){switch(n.getToken()){case 3:return L();case 1:return I();case 10:return U(!0);default:return j()}}return k(),n.getToken()===17?s.allowEmptyContent?!0:(y(4,[],[]),!1):V()?(n.getToken()!==17&&y(9,[],[]),!0):(y(4,[],[]),!1)}var Me;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(Me||(Me={}));var Re;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(Re||(Re={}));var he=Ne;var Ie;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(Ie||(Ie={}));var ke=F(require("path"));var ge=(e,t,s)=>{let n=e instanceof RegExp?Le(e,s):e,i=t instanceof RegExp?Le(t,s):t,r=n!==null&&i!=null&&Rt(n,i,s);return r&&{start:r[0],end:r[1],pre:s.slice(0,r[0]),body:s.slice(r[0]+n.length,r[1]),post:s.slice(r[1]+i.length)}},Le=(e,t)=>{let s=t.match(e);return s?s[0]:null},Rt=(e,t,s)=>{let n,i,r,o,c,l=s.indexOf(e),f=s.indexOf(t,l+1),u=l;if(l>=0&&f>0){if(e===t)return[l,f];for(n=[],r=s.length;u>=0&&!c;){if(u===l)n.push(u),l=s.indexOf(e,u+1);else if(n.length===1){let a=n.pop();a!==void 0&&(c=[a,f])}else i=n.pop(),i!==void 0&&i<r&&(r=i,o=f),f=s.indexOf(t,u+1);u=l<f&&l>=0?l:f}n.length&&o!==void 0&&(c=[r,o])}return c};var je="\0SLASH"+Math.random()+"\0",Ve="\0OPEN"+Math.random()+"\0",me="\0CLOSE"+Math.random()+"\0",Pe="\0COMMA"+Math.random()+"\0",_e="\0PERIOD"+Math.random()+"\0",It=new RegExp(je,"g"),Lt=new RegExp(Ve,"g"),jt=new RegExp(me,"g"),Vt=new RegExp(Pe,"g"),Pt=new RegExp(_e,"g"),_t=/\\\\/g,Dt=/\\{/g,Ft=/\\}/g,Bt=/\\,/g,Wt=/\\./g,zt=1e5;function de(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Ut(e){return e.replace(_t,je).replace(Dt,Ve).replace(Ft,me).replace(Bt,Pe).replace(Wt,_e)}function Ht(e){return e.replace(It,"\\").replace(Lt,"{").replace(jt,"}").replace(Vt,",").replace(Pt,".")}function De(e){if(!e)return[""];let t=[],s=ge("{","}",e);if(!s)return e.split(",");let{pre:n,body:i,post:r}=s,o=n.split(",");o[o.length-1]+="{"+i+"}";let c=De(r);return r.length&&(o[o.length-1]+=c.shift(),o.push.apply(o,c)),t.push.apply(t,o),t}function Fe(e,t={}){if(!e)return[];let{max:s=zt}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),K(Ut(e),s,!0).map(Ht)}function Gt(e){return"{"+e+"}"}function qt(e){return/^-?0\d/.test(e)}function Xt(e,t){return e<=t}function Jt(e,t){return e>=t}function K(e,t,s){let n=[],i=ge("{","}",e);if(!i)return[e];let r=i.pre,o=i.post.length?K(i.post,t,!1):[""];if(/\$$/.test(i.pre))for(let c=0;c<o.length&&c<t;c++){let l=r+"{"+i.body+"}"+o[c];n.push(l)}else{let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),f=c||l,u=i.body.indexOf(",")>=0;if(!f&&!u)return i.post.match(/,(?!,).*\}/)?(e=i.pre+"{"+i.body+me+i.post,K(e,t,!0)):[e];let a;if(f)a=i.body.split(/\.\./);else if(a=De(i.body),a.length===1&&a[0]!==void 0&&(a=K(a[0],t,!1).map(Gt),a.length===1))return o.map(h=>i.pre+a[0]+h);let p;if(f&&a[0]!==void 0&&a[1]!==void 0){let h=de(a[0]),d=de(a[1]),m=Math.max(a[0].length,a[1].length),b=a.length===3&&a[2]!==void 0?Math.abs(de(a[2])):1,T=Xt;d<h&&(b*=-1,T=Jt);let g=a.some(qt);p=[];for(let x=h;T(x,d);x+=b){let w;if(l)w=String.fromCharCode(x),w==="\\"&&(w="");else if(w=String(x),g){let k=m-w.length;if(k>0){let y=new Array(k+1).join("0");x<0?w="-"+y+w.slice(1):w=y+w}}p.push(w)}}else{p=[];for(let h=0;h<a.length;h++)p.push.apply(p,K(a[h],t,!1))}for(let h=0;h<p.length;h++)for(let d=0;d<o.length&&n.length<t;d++){let m=r+p[h]+o[d];(!s||f||m)&&n.push(m)}}return n}var C=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Zt={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},ee=e=>e.replace(/[[\]\\-]/g,"\\$&"),Qt=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Be=e=>e.join(""),We=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let n=[],i=[],r=s+1,o=!1,c=!1,l=!1,f=!1,u=s,a="";e:for(;r<e.length;){let m=e.charAt(r);if((m==="!"||m==="^")&&r===s+1){f=!0,r++;continue}if(m==="]"&&o&&!l){u=r+1;break}if(o=!0,m==="\\"&&!l){l=!0,r++;continue}if(m==="["&&!l){for(let[b,[T,E,g]]of Object.entries(Zt))if(e.startsWith(b,r)){if(a)return["$.",!1,e.length-s,!0];r+=b.length,g?i.push(T):n.push(T),c=c||E;continue e}}if(l=!1,a){m>a?n.push(ee(a)+"-"+ee(m)):m===a&&n.push(ee(m)),a="",r++;continue}if(e.startsWith("-]",r+1)){n.push(ee(m+"-")),r+=2;continue}if(e.startsWith("-",r+1)){a=m,r+=2;continue}n.push(ee(m)),r++}if(u<r)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-s,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!f){let m=n[0].length===2?n[0].slice(-1):n[0];return[Qt(m),!1,u-s,!1]}let p="["+(f?"^":"")+Be(n)+"]",h="["+(f?"":"^")+Be(i)+"]";return[n.length&&i.length?"("+p+"|"+h+")":n.length?p:h,c,u-s,!0]};var _=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!0}={})=>s?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var Yt=new Set(["!","?","+","*","@"]),ze=e=>Yt.has(e),Kt="(?!(?:^|/)\\.\\.?(?:$|/))",oe="(?!\\.)",Ct=new Set(["[","."]),en=new Set(["..","."]),tn=new Set("().*{}+?[]^$\\!"),nn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ye="[^/]",Ue=ye+"*?",He=ye+"+?",q=class e{type;#n;#s;#r=!1;#e=[];#t;#o;#c;#l=!1;#i;#a;#u=!1;constructor(t,s,n={}){this.type=t,t&&(this.#s=!0),this.#t=s,this.#n=this.#t?this.#t.#n:this,this.#i=this.#n===this?n:this.#n.#i,this.#c=this.#n===this?[]:this.#n.#c,t==="!"&&!this.#n.#l&&this.#c.push(this),this.#o=this.#t?this.#t.#e.length:0}get hasMagic(){if(this.#s!==void 0)return this.#s;for(let t of this.#e)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#s=!0;return this.#s}toString(){return this.#a!==void 0?this.#a:this.type?this.#a=this.type+"("+this.#e.map(t=>String(t)).join("|")+")":this.#a=this.#e.map(t=>String(t)).join("")}#h(){if(this!==this.#n)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let t;for(;t=this.#c.pop();){if(t.type!=="!")continue;let s=t,n=s.#t;for(;n;){for(let i=s.#o+1;!n.type&&i<n.#e.length;i++)for(let r of t.#e){if(typeof r=="string")throw new Error("string part in extglob AST??");r.copyIn(n.#e[i])}s=n,n=s.#t}}return this}push(...t){for(let s of t)if(s!==""){if(typeof s!="string"&&!(s instanceof e&&s.#t===this))throw new Error("invalid part: "+s);this.#e.push(s)}}toJSON(){let t=this.type===null?this.#e.slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...this.#e.map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#n||this.#n.#l&&this.#t?.type==="!")&&t.push({}),t}isStart(){if(this.#n===this)return!0;if(!this.#t?.isStart())return!1;if(this.#o===0)return!0;let t=this.#t;for(let s=0;s<this.#o;s++){let n=t.#e[s];if(!(n instanceof e&&n.type==="!"))return!1}return!0}isEnd(){if(this.#n===this||this.#t?.type==="!")return!0;if(!this.#t?.isEnd())return!1;if(!this.type)return this.#t?.isEnd();let t=this.#t?this.#t.#e.length:0;return this.#o===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let s=new e(this.type,t);for(let n of this.#e)s.copyIn(n);return s}static#f(t,s,n,i){let r=!1,o=!1,c=-1,l=!1;if(s.type===null){let h=n,d="";for(;h<t.length;){let m=t.charAt(h++);if(r||m==="\\"){r=!r,d+=m;continue}if(o){h===c+1?(m==="^"||m==="!")&&(l=!0):m==="]"&&!(h===c+2&&l)&&(o=!1),d+=m;continue}else if(m==="["){o=!0,c=h,l=!1,d+=m;continue}if(!i.noext&&ze(m)&&t.charAt(h)==="("){s.push(d),d="";let b=new e(m,s);h=e.#f(t,b,h,i),s.push(b);continue}d+=m}return s.push(d),h}let f=n+1,u=new e(null,s),a=[],p="";for(;f<t.length;){let h=t.charAt(f++);if(r||h==="\\"){r=!r,p+=h;continue}if(o){f===c+1?(h==="^"||h==="!")&&(l=!0):h==="]"&&!(f===c+2&&l)&&(o=!1),p+=h;continue}else if(h==="["){o=!0,c=f,l=!1,p+=h;continue}if(ze(h)&&t.charAt(f)==="("){u.push(p),p="";let d=new e(h,u);u.push(d),f=e.#f(t,d,f,i);continue}if(h==="|"){u.push(p),p="",a.push(u),u=new e(null,s);continue}if(h===")")return p===""&&s.#e.length===0&&(s.#u=!0),u.push(p),p="",s.push(...a,u),f;p+=h}return s.type=null,s.#s=void 0,s.#e=[t.substring(n-1)],f}static fromGlob(t,s={}){let n=new e(null,void 0,s);return e.#f(t,n,0,s),n}toMMPattern(){if(this!==this.#n)return this.#n.toMMPattern();let t=this.toString(),[s,n,i,r]=this.toRegExpSource();if(!(i||this.#s||this.#i.nocase&&!this.#i.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let c=(this.#i.nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${s}$`,c),{_src:s,_glob:t})}get options(){return this.#i}toRegExpSource(t){let s=t??!!this.#i.dot;if(this.#n===this&&this.#h(),!this.type){let l=this.isStart()&&this.isEnd()&&!this.#e.some(h=>typeof h!="string"),f=this.#e.map(h=>{let[d,m,b,T]=typeof h=="string"?e.#g(h,this.#s,l):h.toRegExpSource(t);return this.#s=this.#s||b,this.#r=this.#r||T,d}).join(""),u="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&en.has(this.#e[0]))){let d=Ct,m=s&&d.has(f.charAt(0))||f.startsWith("\\.")&&d.has(f.charAt(2))||f.startsWith("\\.\\.")&&d.has(f.charAt(4)),b=!s&&!t&&d.has(f.charAt(0));u=m?Kt:b?oe:""}let a="";return this.isEnd()&&this.#n.#l&&this.#t?.type==="!"&&(a="(?:$|\\/)"),[u+f+a,_(f),this.#s=!!this.#s,this.#r]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",r=this.#p(s);if(this.isStart()&&this.isEnd()&&!r&&this.type!=="!"){let l=this.toString();return this.#e=[l],this.type=null,this.#s=void 0,[l,_(this.toString()),!1,!1]}let o=!n||t||s||!oe?"":this.#p(!0);o===r&&(o=""),o&&(r=`(?:${r})(?:${o})*?`);let c="";if(this.type==="!"&&this.#u)c=(this.isStart()&&!s?oe:"")+He;else{let l=this.type==="!"?"))"+(this.isStart()&&!s&&!t?oe:"")+Ue+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;c=i+r+l}return[c,_(r),this.#s=!!this.#s,this.#r]}#p(t){return this.#e.map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[n,i,r,o]=s.toRegExpSource(t);return this.#r=this.#r||o,n}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")}static#g(t,s,n=!1){let i=!1,r="",o=!1,c=!1;for(let l=0;l<t.length;l++){let f=t.charAt(l);if(i){i=!1,r+=(tn.has(f)?"\\":"")+f;continue}if(f==="*"){if(c)continue;c=!0,r+=n&&/^[*]+$/.test(t)?He:Ue,s=!0;continue}else c=!1;if(f==="\\"){l===t.length-1?r+="\\\\":i=!0;continue}if(f==="["){let[u,a,p,h]=We(t,l);if(p){r+=u,o=o||a,l+=p-1,s=s||h;continue}}if(f==="?"){r+=ye,s=!0;continue}r+=nn(f)}return[r,_(t),!!s,o]}};var be=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!1}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var v=(e,t,s={})=>(C(t),!s.nocomment&&t.charAt(0)==="#"?!1:new X(t,s).match(e)),sn=/^\*+([^+@!?\*\[\(]*)$/,rn=e=>t=>!t.startsWith(".")&&t.endsWith(e),on=e=>t=>t.endsWith(e),ln=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),cn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),an=/^\*+\.\*+$/,fn=e=>!e.startsWith(".")&&e.includes("."),un=e=>e!=="."&&e!==".."&&e.includes("."),pn=/^\.\*+$/,hn=e=>e!=="."&&e!==".."&&e.startsWith("."),gn=/^\*+$/,dn=e=>e.length!==0&&!e.startsWith("."),mn=e=>e.length!==0&&e!=="."&&e!=="..",yn=/^\?+([^+@!?\*\[\(]*)?$/,bn=([e,t=""])=>{let s=Xe([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},kn=([e,t=""])=>{let s=Je([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},wn=([e,t=""])=>{let s=Je([e]);return t?n=>s(n)&&n.endsWith(t):s},Sn=([e,t=""])=>{let s=Xe([e]);return t?n=>s(n)&&n.endsWith(t):s},Xe=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},Je=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},Ze=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Ge={win32:{sep:"\\"},posix:{sep:"/"}},xn=Ze==="win32"?Ge.win32.sep:Ge.posix.sep;v.sep=xn;var M=Symbol("globstar **");v.GLOBSTAR=M;var vn="[^/]",Tn=vn+"*?",En="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",On="(?:(?!(?:\\/|^)\\.).)*?",An=(e,t={})=>s=>v(s,e,t);v.filter=An;var $=(e,t={})=>Object.assign({},e,t),Nn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return v;let t=v;return Object.assign((n,i,r={})=>t(n,i,$(e,r)),{Minimatch:class extends t.Minimatch{constructor(i,r={}){super(i,$(e,r))}static defaults(i){return t.defaults($(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,r,o={}){super(i,r,$(e,o))}static fromGlob(i,r={}){return t.AST.fromGlob(i,$(e,r))}},unescape:(n,i={})=>t.unescape(n,$(e,i)),escape:(n,i={})=>t.escape(n,$(e,i)),filter:(n,i={})=>t.filter(n,$(e,i)),defaults:n=>t.defaults($(e,n)),makeRe:(n,i={})=>t.makeRe(n,$(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,$(e,i)),match:(n,i,r={})=>t.match(n,i,$(e,r)),sep:t.sep,GLOBSTAR:M})};v.defaults=Nn;var Qe=(e,t={})=>(C(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Fe(e,{max:t.braceExpandMax}));v.braceExpand=Qe;var $n=(e,t={})=>new X(e,t).makeRe();v.makeRe=$n;var Mn=(e,t,s={})=>{let n=new X(t,s);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};v.match=Mn;var qe=/[?*]|[+@!]\(.*?\)|\[|\]/,Rn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),X=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,s={}){C(t),s=s||{},this.options=s,this.pattern=t,this.platform=s.platform||Ze,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!s.windowsPathsNoEscape||s[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!s.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!s.nonegate,this.comment=!1,this.empty=!1,this.partial=!!s.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=s.windowsNoMagicRoot!==void 0?s.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let s of t)if(typeof s!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,s=this.options;if(!s.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],s.debug&&(this.debug=(...r)=>console.error(...r)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(r=>this.slashSplit(r));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((r,o,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=r[0]===""&&r[1]===""&&(r[2]==="?"||!qe.test(r[2]))&&!qe.test(r[3]),f=/^[a-z]:/i.test(r[0]);if(l)return[...r.slice(0,4),...r.slice(4).map(u=>this.parse(u))];if(f)return[r[0],...r.slice(1).map(u=>this.parse(u))]}return r.map(l=>this.parse(l))});if(this.debug(this.pattern,i),this.set=i.filter(r=>r.indexOf(!1)===-1),this.isWindows)for(let r=0;r<this.set.length;r++){let o=this.set[r];o[0]===""&&o[1]===""&&this.globParts[r][2]==="?"&&typeof o[3]=="string"&&/^[a-z]:$/i.test(o[3])&&(o[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n=0;n<t.length;n++)for(let i=0;i<t[n].length;i++)t[n][i]==="**"&&(t[n][i]="*");let{optimizationLevel:s=1}=this.options;return s>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):s>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(s=>{let n=-1;for(;(n=s.indexOf("**",n+1))!==-1;){let i=n;for(;s[i+1]==="**";)i++;i!==n&&s.splice(n,i-n)}return s})}levelOneOptimize(t){return t.map(s=>(s=s.reduce((n,i)=>{let r=n[n.length-1];return i==="**"&&r==="**"?n:i===".."&&r&&r!==".."&&r!=="."&&r!=="**"?(n.pop(),n):(n.push(i),n)},[]),s.length===0?[""]:s))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let s=!1;do{if(s=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let r=t[i];i===1&&r===""&&t[0]===""||(r==="."||r==="")&&(s=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(s=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&(s=!0,t.splice(n-1,2),n-=2)}}while(s);return t.length===0?[""]:t}firstPhasePreProcess(t){let s=!1;do{s=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let o=i;for(;n[o+1]==="**";)o++;o>i&&n.splice(i+1,o-i);let c=n[i+1],l=n[i+2],f=n[i+3];if(c!==".."||!l||l==="."||l===".."||!f||f==="."||f==="..")continue;s=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let o=1;o<n.length-1;o++){let c=n[o];o===1&&c===""&&n[0]===""||(c==="."||c==="")&&(s=!0,n.splice(o,1),o--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(s=!0,n.pop())}let r=0;for(;(r=n.indexOf("..",r+1))!==-1;){let o=n[r-1];if(o&&o!=="."&&o!==".."&&o!=="**"){s=!0;let l=r===1&&n[r+1]==="**"?["."]:[];n.splice(r-1,2,...l),n.length===0&&n.push(""),r-=2}}}}while(s);return t}secondPhasePreProcess(t){for(let s=0;s<t.length-1;s++)for(let n=s+1;n<t.length;n++){let i=this.partsMatch(t[s],t[n],!this.preserveMultipleSlashes);if(i){t[s]=[],t[n]=i;break}}return t.filter(s=>s.length)}partsMatch(t,s,n=!1){let i=0,r=0,o=[],c="";for(;i<t.length&&r<s.length;)if(t[i]===s[r])o.push(c==="b"?s[r]:t[i]),i++,r++;else if(n&&t[i]==="**"&&s[r]===t[i+1])o.push(t[i]),i++;else if(n&&s[r]==="**"&&t[i]===s[r+1])o.push(s[r]),r++;else if(t[i]==="*"&&s[r]&&(this.options.dot||!s[r].startsWith("."))&&s[r]!=="**"){if(c==="b")return!1;c="a",o.push(t[i]),i++,r++}else if(s[r]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(c==="a")return!1;c="b",o.push(s[r]),i++,r++}else return!1;return t.length===s.length&&o}parseNegate(){if(this.nonegate)return;let t=this.pattern,s=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)s=!s,n++;n&&(this.pattern=t.slice(n)),this.negate=s}matchOne(t,s,n=!1){let i=this.options;if(this.isWindows){let m=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),b=!m&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),T=typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0]),E=!T&&s[0]===""&&s[1]===""&&s[2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3]),g=b?3:m?0:void 0,x=E?3:T?0:void 0;if(typeof g=="number"&&typeof x=="number"){let[w,k]=[t[g],s[x]];w.toLowerCase()===k.toLowerCase()&&(s[x]=w,x>g?s=s.slice(x):g>x&&(t=t.slice(g)))}}let{optimizationLevel:r=1}=this.options;r>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:s}),this.debug("matchOne",t.length,s.length);for(var o=0,c=0,l=t.length,f=s.length;o<l&&c<f;o++,c++){this.debug("matchOne loop");var u=s[c],a=t[o];if(this.debug(s,u,a),u===!1)return!1;if(u===M){this.debug("GLOBSTAR",[s,u,a]);var p=o,h=c+1;if(h===f){for(this.debug("** at the end");o<l;o++)if(t[o]==="."||t[o]===".."||!i.dot&&t[o].charAt(0)===".")return!1;return!0}for(;p<l;){var d=t[p];if(this.debug(`
|
|
9
9
|
globstar while`,t,p,s,h,d),this.matchOne(t.slice(p),s.slice(h),n))return this.debug("globstar found match!",p,l,d),!0;if(d==="."||d===".."||!i.dot&&d.charAt(0)==="."){this.debug("dot detected!",t,p,s,h);break}this.debug("globstar swallow a segment, and continue"),p++}return!!(n&&(this.debug(`
|
|
10
|
-
>>> no match, partial?`,t,p,s,h),p===l))}let m;if(typeof u=="string"?(m=
|
|
11
|
-
`),n=[],i=0;for(let c of s)n.push(i),i+=c.length+1;let r=c=>{let l=0;for(let
|
|
10
|
+
>>> no match, partial?`,t,p,s,h),p===l))}let m;if(typeof u=="string"?(m=a===u,this.debug("string match",u,a,m)):(m=u.test(a),this.debug("pattern match",u,a,m)),!m)return!1}if(o===l&&c===f)return!0;if(o===l)return n;if(c===f)return o===l-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return Qe(this.pattern,this.options)}parse(t){C(t);let s=this.options;if(t==="**")return M;if(t==="")return"";let n,i=null;(n=t.match(gn))?i=s.dot?mn:dn:(n=t.match(sn))?i=(s.nocase?s.dot?cn:ln:s.dot?on:rn)(n[1]):(n=t.match(yn))?i=(s.nocase?s.dot?kn:bn:s.dot?wn:Sn)(n):(n=t.match(an))?i=s.dot?un:fn:(n=t.match(pn))&&(i=hn);let r=q.fromGlob(t,this.options).toMMPattern();return i&&typeof r=="object"&&Reflect.defineProperty(r,"test",{value:i}),r}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let s=this.options,n=s.noglobstar?Tn:s.dot?En:On,i=new Set(s.nocase?["i"]:[]),r=t.map(l=>{let f=l.map(a=>{if(a instanceof RegExp)for(let p of a.flags.split(""))i.add(p);return typeof a=="string"?Rn(a):a===M?M:a._src});f.forEach((a,p)=>{let h=f[p+1],d=f[p-1];a!==M||d===M||(d===void 0?h!==void 0&&h!==M?f[p+1]="(?:\\/|"+n+"\\/)?"+h:f[p]=n:h===void 0?f[p-1]=d+"(?:\\/|\\/"+n+")?":h!==M&&(f[p-1]=d+"(?:\\/|\\/"+n+"\\/)"+h,f[p+1]=M))});let u=f.filter(a=>a!==M);if(this.partial&&u.length>=1){let a=[];for(let p=1;p<=u.length;p++)a.push(u.slice(0,p).join("/"));return"(?:"+a.join("|")+")"}return u.join("/")}).join("|"),[o,c]=t.length>1?["(?:",")"]:["",""];r="^"+o+r+c+"$",this.partial&&(r="^(?:\\/|"+o+r.slice(1,-1)+c+")$"),this.negate&&(r="^(?!"+r+").+$");try{this.regexp=new RegExp(r,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,s=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&s)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let r=this.set;this.debug(this.pattern,"set",r);let o=i[i.length-1];if(!o)for(let c=i.length-2;!o&&c>=0;c--)o=i[c];for(let c=0;c<r.length;c++){let l=r[c],f=i;if(n.matchBase&&l.length===1&&(f=[o]),this.matchOne(f,l,s))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return v.defaults(t).Minimatch}};v.AST=q;v.Minimatch=X;v.escape=be;v.unescape=_;var le="pickety.json",J=["ts","tsx","js","jsx","mjs","cjs"],In=`**/*.{${J.join(",")}}`,ce=new Set(["node_modules",".git",".next","dist","out","build",".turbo",".cache",".nx","coverage"]);function A(e){let t=e.replace(/\\/g,"/");return/^[a-zA-Z]:/.test(t)&&(t=t[0].toLowerCase()+t.slice(1)),t}function te(e,t){return ke.relative(e,t).replace(/\\/g,"/")}function we(e,t){return v(e,t)||e===t}function ae(e,t){return e==="instability"?t.toFixed(2):String(t)}function Ye(e,t,s){return{allow:e.allow??!1,severity:e.severity??s,name:e.name??`rule[${t}]`,effectiveImporter:e.containedTo||e.importer||"*",isOnly:e.only||!!e.containedTo,isAllowStyle:(e.allow??!1)||!!e.containedTo||e.only}}function Z(e,t,s,n,i,r,o){return{file:e,line:t.line,character:t.character,length:t.length,message:`[${s}] ${n} (importing "${t.specifier}")`,severity:i,ruleName:s,sourceModule:r,targetModule:o}}function Ke(e){let t=[],s=new Set,n=new Set,i=[];function r(o){s.add(o),n.add(o),i.push(o);let c=e.get(o);if(c){for(let l of c)if(!s.has(l))r(l);else if(n.has(l)){let f=i.indexOf(l);f!==-1&&t.push([...i.slice(f),l])}}n.delete(o),i.pop()}for(let o of e.keys())s.has(o)||r(o);return t}function Ce(e){let t=P.join(e,le);if(!B.existsSync(t))return{ok:!1,errors:[{message:`File not found: ${le}`}]};try{let s=B.readFileSync(t,"utf-8"),n;try{n=he(s)}catch(i){return{ok:!1,errors:[{message:`pickety.json is not valid JSONC: ${i instanceof Error?i.message:String(i)}`}]}}return Ln(n)}catch(s){return{ok:!1,errors:[{message:`Failed to read pickety.json: ${s instanceof Error?s.message:String(s)}`}]}}}function Ln(e){let t=[];if(typeof e!="object"||e===null)return{ok:!1,errors:[{message:"Configuration must be a JSON object"}]};let s=e,n=jn(s.modules,t),i=Vn(s.rules,t),r=Pn(s["boundary-diagrams"],t),o=_n(s.health,t);return t.length>0||!n||!i?{ok:!1,errors:t}:{ok:!0,config:{modules:n,rules:{"module-boundaries":i},"boundary-diagrams":r,health:o}}}function jn(e,t){if(e===void 0){t.push({message:'"modules" is required and must be an object',path:"modules"});return}if(typeof e!="object"||e===null){t.push({message:'"modules" must be an object mapping module names to patterns',path:"modules"});return}let s={};for(let[n,i]of Object.entries(e))typeof i!="string"?t.push({message:`Module "${n}" pattern must be a string, got ${typeof i}`,path:`modules.${n}`}):s[n]=i;return s}function Vn(e,t){if(e===void 0){t.push({message:'"rules" is required and must be an object',path:"rules"});return}if(typeof e!="object"||e===null){t.push({message:'"rules" must be an object',path:"rules"});return}let n=e["module-boundaries"];if(n===void 0){t.push({message:'"rules.module-boundaries" is required and must be an object',path:"rules.module-boundaries"});return}if(typeof n!="object"||n===null){t.push({message:'"rules.module-boundaries" must be an object',path:"rules.module-boundaries"});return}let i=n,r="error";if(i.severity!==void 0&&(i.severity!=="error"&&i.severity!=="warn"?t.push({message:`"rules.module-boundaries.severity" must be "error" or "warn", got "${i.severity}"`,path:"rules.module-boundaries.severity"}):r=i.severity),i.rules===void 0){t.push({message:'"rules.module-boundaries.rules" is required and must be an array',path:"rules.module-boundaries.rules"});return}if(!Array.isArray(i.rules)){t.push({message:'"rules.module-boundaries.rules" must be an array',path:"rules.module-boundaries.rules"});return}let o=[];return i.rules.forEach((c,l)=>{let f=`rules.module-boundaries.rules[${l}]`;if(typeof c!="object"||c===null){t.push({message:`Rule #${l} must be an object`,path:f});return}let u=c;typeof u.importer!="string"&&typeof u.containedTo!="string"&&t.push({message:`Rule #${l}: "importer" or "containedTo" is required`,path:f}),u.importer!==void 0&&typeof u.importer!="string"&&t.push({message:`Rule #${l}: "importer" must be a string`,path:`${f}.importer`}),typeof u.imports!="string"&&t.push({message:`Rule #${l}: "imports" is required and must be a string`,path:`${f}.imports`}),u.allow!==void 0&&typeof u.allow!="boolean"&&t.push({message:`Rule #${l}: "allow" must be a boolean`,path:`${f}.allow`}),u.only!==void 0&&typeof u.only!="boolean"&&t.push({message:`Rule #${l}: "only" must be a boolean`,path:`${f}.only`}),u.containedTo!==void 0&&typeof u.containedTo!="string"&&t.push({message:`Rule #${l}: "containedTo" must be a string`,path:`${f}.containedTo`}),u.message!==void 0&&typeof u.message!="string"&&t.push({message:`Rule #${l}: "message" must be a string`,path:`${f}.message`}),u.severity!==void 0&&u.severity!=="error"&&u.severity!=="warn"&&t.push({message:`Rule #${l}: "severity" must be "error" or "warn", got "${u.severity}"`,path:`${f}.severity`}),u.name!==void 0&&typeof u.name!="string"&&t.push({message:`Rule #${l}: "name" must be a string`,path:`${f}.name`}),u.maxViolations!==void 0&&(typeof u.maxViolations!="number"||!Number.isInteger(u.maxViolations)||u.maxViolations<0)&&t.push({message:`Rule #${l}: "maxViolations" must be a non-negative integer`,path:`${f}.maxViolations`}),o.push(u)}),{severity:r,rules:o}}function Pn(e,t){if(e!==void 0){if(typeof e!="boolean"&&typeof e!="string"){t.push({message:'"boundary-diagrams" must be a boolean or a string',path:"boundary-diagrams"});return}return e}}function _n(e,t){if(e===void 0)return;if(typeof e!="object"||e===null){t.push({message:'"health" must be an object',path:"health"});return}let s=e,n={},i=[{key:"maxAfferentCoupling",label:"maxAfferentCoupling"},{key:"maxEfferentCoupling",label:"maxEfferentCoupling"},{key:"maxDepth",label:"maxDepth"}];for(let{key:r,label:o}of i){let c=s[r];c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<1?t.push({message:`"health.${o}" must be a positive integer`,path:`health.${o}`}):n[r]=c)}if(s.maxInstability!==void 0){let r=s.maxInstability;typeof r!="number"||r<0||r>1?t.push({message:'"health.maxInstability" must be a number between 0 and 1',path:"health.maxInstability"}):n.maxInstability=r}return Object.keys(n).length>0?n:void 0}function et(e,t){if(t<0)return[];let s=[],n;try{n=B.readdirSync(e,{withFileTypes:!0})}catch{return s}for(let i of n)!ce.has(i.name)&&i.isFile()&&/^tsconfig(\..+)?\.json$/.test(i.name)&&s.push(P.join(e,i.name));for(let i of n)!ce.has(i.name)&&i.isDirectory()&&s.push(...et(P.join(e,i.name),t-1));return s}function tt(e){let t={},s=et(e,4);for(let n of s)try{let i=B.readFileSync(n,"utf-8"),o=he(i).compilerOptions;if(!o?.paths)continue;let c=P.dirname(n),l=P.relative(e,c),f=o.baseUrl||".";for(let[u,a]of Object.entries(o.paths))if(Array.isArray(a)&&a.length>0){let p=a[0];t[u]||(t[u]=A(P.join(l,f,p)))}}catch{}return t}var xe=F(require("path"));var D=F(require("path"));var st=J.map(e=>`.${e}`),Dn=st.map(e=>`index${e}`),nt=/(\/\*[\s\S]*?\*\/|\/\/.*)|(['"`](?:\\.|[^'"`])*['"`])|((?:import|export)\s+(?:[\s\S]*?from\s+)?['"`]([^'"`]+)['"`])|(import\s*\(\s*['"`]([^'"`]+)['"`]\s*\))/gm;function Fn(e){let t=[],s=e.split(`
|
|
11
|
+
`),n=[],i=0;for(let c of s)n.push(i),i+=c.length+1;let r=c=>{let l=0;for(let f=1;f<n.length&&!(n[f]>c);f++)l=f;return{line:l,character:c-n[l]}},o;for(nt.lastIndex=0;(o=nt.exec(e))!==null;){let[c,l,f,u,a,p,h]=o;if(!(l||f)){if(u&&a){let d=r(o.index);t.push({specifier:a,line:d.line,character:d.character,length:u.length})}else if(p&&h){let d=r(o.index);t.push({specifier:h,line:d.line,character:d.character,length:p.length})}}}return t}function Bn(e,t,s){let{knownFiles:n,root:i,aliases:r}=s;for(let[o,c]of Object.entries(r))if(o.endsWith("/*")&&c.endsWith("/*")){let l=o.slice(0,-2),f=c.slice(0,-2);if(e.startsWith(l)){let u=e.replace(l,f);return Se(D.resolve(i,u),n)}}else if(e===o)return Se(D.resolve(i,c),n);if(e.startsWith(".")){let o=D.dirname(t),c=D.resolve(o,e);return Se(c,n)}}function Se(e,t){let s=A(e);if(t.has(s))return s;for(let n of st){let i=s+n;if(t.has(i))return i}for(let n of Dn){let i=s+"/"+n;if(t.has(i))return i}}function N(e,t,s){let n=A(D.relative(s,e));for(let[i,r]of Object.entries(t)){let o=r.endsWith("/*")?r.slice(0,-2)+"/**/*":r;if(v(n,o)||v(n,r))return i}}function fe(e,t,s){let n=Fn(t),i=[];for(let r of n){let o=Bn(r.specifier,e,s);o&&i.push({statement:r,resolvedPath:o})}return i}function rt(e,t,s,n){let i=[],{modules:r}=s,{severity:o,rules:c}=s.rules["module-boundaries"],{knownFiles:l,root:f,aliases:u}=n,a=N(e,r,f);if(!a)return[];let p=A(xe.relative(f,e)),h=fe(e,t,n);for(let{statement:d,resolvedPath:m}of h){let b=N(m,r,f);if(!b)continue;let T=A(xe.relative(f,m));c.forEach((E,g)=>{let{allow:x,severity:w,name:k,effectiveImporter:y,isOnly:U}=Ye(E,g,o),j=Wn(U?E.imports:y);if(j.length>0)if(U){let R=it(E.imports,T,j);if(R){let I=ue(y,j,R);if(!Q(a,p,I)){let V=E.message||`Module "${a}" is not allowed to import from "${b}" (contained to "${I}")`;i.push(Z(e,d,k,V,w,a,b))}}}else{let R=it(y,p,j);if(!R)return;if(x){let I=ue(E.imports,j,"*"),L=ue(E.imports,j,R),V=Q(b,T,I),S=Q(b,T,L);if(V&&!S){let O=E.message||`Import must match scoped pattern "${L}"`;i.push(Z(e,d,k,O,w,a,b))}}else{let I=ue(E.imports,j,R);if(Q(b,T,I)){let V=E.message||`Module "${a}" cannot import from "${b}"`;i.push(Z(e,d,k,V,w))}}}else{let R=Q(a,p,y),I=Q(b,T,E.imports);if(U){if(I&&!R){let L=E.message||(E.containedTo?`Import is restricted: "${b}" is contained to "${y}"`:`Module "${b}" can only be imported by "${y}"`);i.push(Z(e,d,k,L,w,a,b))}}else if(R&&I&&!x){let L=E.message||`Module "${a}" cannot import from "${b}"`;i.push(Z(e,d,k,L,w,a,b))}}})}return i}function Q(e,t,s){return!!(we(e,s)||s.includes("/")&&(v(t,s)||v(t,`**/${s}`)||v(t,`**/${s}/**`)))}function Wn(e){return e.match(/\$[\w-]+/g)||[]}function it(e,t,s){let n=e.split("/"),i=t.split("/"),r=0,o=i.length-n.length;for(let c=r;c<=o;c++){let l=ot(n,i,c,s);if(l)return l}}function ot(e,t,s,n){let i={},r=s;for(let o=0;o<e.length;o++){let c=e[o];if(c==="**"){let a=e.slice(o+1);if(a.length===0)return i;for(let p=r;p<=t.length-a.length;p++){let h=ot(a,t,p,n);if(h)return{...i,...h}}return}if(r>=t.length)return;let l=c,f=[];for(let a of n)l.includes(a)&&(l=l.replace(a,`__VAR_${f.length}__`),f.push(a));l=l.replace(/[.+?^{}()|[\]\\]/g,"\\$&"),l=l.replace(/\*/g,"[^/]*");for(let a=0;a<f.length;a++)l=l.replace(`__VAR_${a}__`,"([^/]+)");let u=t[r].match(new RegExp(`^${l}$`));if(!u)return;for(let a=0;a<f.length;a++)i[f[a]]=u[a+1];r++}return i}function lt(e,t){let s=t.rules["module-boundaries"].rules,n=new Map;if(s.forEach((r,o)=>{if(r.maxViolations!==void 0){let c=r.name??`rule[${o}]`;n.set(c,r.maxViolations)}}),n.size===0)return e;let i=new Map;for(let r of e)r.ruleName&&n.has(r.ruleName)&&i.set(r.ruleName,(i.get(r.ruleName)??0)+1);return e.map(r=>{if(!r.ruleName||!n.has(r.ruleName))return r;let o=i.get(r.ruleName)??0,c=n.get(r.ruleName),l=o<=c?"warn":"error";return l===r.severity?r:{...r,severity:l}})}function ue(e,t,s){let n=e;for(let i of t){let r=typeof s=="string"?s:s[i],o=i.replace(/\$/g,"\\$");n=n.replace(new RegExp(o,"g"),r)}return n}function ve(e,t,s){let n=new Set,i=fe(e,t,s),r=A(e);for(let{resolvedPath:o}of i)o&&o!==r&&n.add(o);return n}var ne=class{dependents=new Map;dependencies=new Map;updateFile(t,s){let n=this.dependencies.get(t);if(n)for(let i of n)this.dependents.get(i)?.delete(t);this.dependencies.set(t,new Set(s));for(let i of s)this.dependents.has(i)||this.dependents.set(i,new Set),this.dependents.get(i).add(t)}removeFile(t){let s=this.dependencies.get(t);if(s)for(let i of s)this.dependents.get(i)?.delete(t);this.dependencies.delete(t);let n=this.dependents.get(t);if(n)for(let i of n)this.dependencies.get(i)?.delete(t);this.dependents.delete(t)}getDependents(t){return this.dependents.get(t)??new Set}getDependencies(t){return this.dependencies.get(t)??new Set}getTransitiveDependents(t){let s=new Set,n=[t];for(;n.length>0;){let i=n.shift(),r=this.dependents.get(i);if(r)for(let o of r)!s.has(o)&&o!==t&&(s.add(o),n.push(o))}return s}getModuleSummary(t,s,n){let i=this.getDependents(t),r=this.getDependencies(t),o=new Set;for(let l of i){let f=N(l,s,n);f&&o.add(f)}let c=new Set;for(let l of r){let f=N(l,s,n);f&&c.add(f)}return{dependentCount:i.size,dependentModules:[...o],dependencyCount:r.size,dependencyModules:[...c]}}getModuleLevelGraph(t,s){let n=new Map;for(let[i,r]of this.dependencies){let o=N(i,t,s);if(o){n.has(o)||n.set(o,new Set);for(let c of r){let l=N(c,t,s);l&&l!==o&&n.get(o).add(l)}}}return n}clear(){this.dependents.clear(),this.dependencies.clear()}};function ct(e,t,s){let{root:n,knownFiles:i}=s,r=e.getModuleLevelGraph(t,n),o=Object.keys(t),c=new Map;for(let a of o)c.set(a,0);for(let a of i){let p=N(a,t,n);p&&c.set(p,(c.get(p)??0)+1)}let l=new Map;for(let a of o)l.set(a,0);for(let[,a]of r)for(let p of a)l.set(p,(l.get(p)??0)+1);let f=zn(r,o),u=o.map(a=>{let p=l.get(a)??0,h=r.get(a)?.size??0,d=p+h;return{moduleName:a,fileCount:c.get(a)??0,afferentCoupling:p,efferentCoupling:h,instability:d===0?0:h/d,dependencyDepth:f.get(a)??0}});return u.sort((a,p)=>a.instability-p.instability),u}function zn(e,t){let s=new Map,n=new Set;function i(r){if(s.has(r))return s.get(r);if(n.has(r))return 0;n.add(r);let o=e.get(r),c=0;if(o&&o.size>0)for(let l of o)c=Math.max(c,1+i(l));return n.delete(r),s.set(r,c),c}for(let r of t)i(r);return s}function at(e,t){let s=[],n=[{key:"maxAfferentCoupling",label:"afferent coupling",getValue:i=>i.afferentCoupling},{key:"maxEfferentCoupling",label:"efferent coupling",getValue:i=>i.efferentCoupling},{key:"maxInstability",label:"instability",getValue:i=>i.instability},{key:"maxDepth",label:"dependency depth",getValue:i=>i.dependencyDepth}];for(let i of e)for(let r of n){let o=t[r.key],c=r.getValue(i);o!==void 0&&c>o&&s.push({moduleName:i.moduleName,metric:r.label,value:c,threshold:o})}return s}function ft(e,t){let s=te(t,e.file),n=e.line+1,i=e.character+1,r=e.severity==="error"?"error":"warning";return`${s}:${n}:${i}: ${r} ${e.message}`}function ut(e,t,s,n){let i=te(n,e),r=t.getDependents(e),o=t.getTransitiveDependents(e);if(console.log(`Impact analysis for ${i}:
|
|
12
12
|
`),r.size===0){console.log(` No dependents found.
|
|
13
|
-
`);return}console.log(` Direct dependents (${r.size} file${r.size===1?"":"s"}):`);for(let l of r){let
|
|
13
|
+
`);return}console.log(` Direct dependents (${r.size} file${r.size===1?"":"s"}):`);for(let l of r){let f=N(l,s.modules,n)??"(unmatched)",u=te(n,l);console.log(` ${u} (${f})`)}let c=new Set;for(let l of o){let f=N(l,s.modules,n);f&&c.add(f)}o.size>r.size&&(console.log(`
|
|
14
14
|
Transitive dependents (${o.size} file${o.size===1?"":"s"} across ${c.size} module${c.size===1?"":"s"}):`),console.log(` ${[...c].join(", ")}`)),console.log(`
|
|
15
|
-
Affected modules: ${[...c].join(", ")||"none"}`),console.log("")}function
|
|
16
|
-
`);let s=["Module","Files","Ca","Ce","Instability","Depth"],n=[Math.max(s[0].length,...e.map(o=>o.moduleName.length)),Math.max(s[1].length,...e.map(o=>String(o.fileCount).length)),Math.max(s[2].length,...e.map(o=>String(o.afferentCoupling).length)),Math.max(s[3].length,...e.map(o=>String(o.efferentCoupling).length)),Math.max(s[4].length,11),Math.max(s[5].length,...e.map(o=>String(o.dependencyDepth).length))],i=(o,c)=>o.padEnd(c),r=(o,c)=>o.padStart(c);console.log(" "+s.map((o,c)=>i(o,n[c])).join(" ")),console.log(" "+n.map(o=>"\u2500".repeat(o)).join(" "));for(let o of e){let l=" "+[i(o.moduleName,n[0]),r(String(o.fileCount),n[1]),r(String(o.afferentCoupling),n[2]),r(String(o.efferentCoupling),n[3]),r(
|
|
15
|
+
Affected modules: ${[...c].join(", ")||"none"}`),console.log("")}function pt(e,t){console.log(`Module Health Report:
|
|
16
|
+
`);let s=["Module","Files","Ca","Ce","Instability","Depth"],n=[Math.max(s[0].length,...e.map(o=>o.moduleName.length)),Math.max(s[1].length,...e.map(o=>String(o.fileCount).length)),Math.max(s[2].length,...e.map(o=>String(o.afferentCoupling).length)),Math.max(s[3].length,...e.map(o=>String(o.efferentCoupling).length)),Math.max(s[4].length,11),Math.max(s[5].length,...e.map(o=>String(o.dependencyDepth).length))],i=(o,c)=>o.padEnd(c),r=(o,c)=>o.padStart(c);console.log(" "+s.map((o,c)=>i(o,n[c])).join(" ")),console.log(" "+n.map(o=>"\u2500".repeat(o)).join(" "));for(let o of e){let l=" "+[i(o.moduleName,n[0]),r(String(o.fileCount),n[1]),r(String(o.afferentCoupling),n[2]),r(String(o.efferentCoupling),n[3]),r(ae("instability",o.instability),n[4]),r(String(o.dependencyDepth),n[5])].join(" "),f=t.filter(u=>u.moduleName===o.moduleName);if(f.length>0){let u=f.map(a=>{let p=ae(a.metric,a.threshold);return`exceeds max${a.metric.charAt(0).toUpperCase()+a.metric.slice(1)} (${p})`});l+=" \u2190 "+u.join(", ")}console.log(l)}}function Un(e){let t=e.slice(2),s=t[0],n=process.cwd(),i=t.indexOf("--root");i!==-1&&t[i+1]&&(n=W.resolve(t[i+1]));let r=s==="impact"&&t[1]&&!t[1].startsWith("--")?W.resolve(n,t[1]):void 0;return{command:s,root:n,target:r}}var Hn=new Set(J.map(e=>`.${e}`));function Gn(e){let t=z.readdirSync(e,{recursive:!0,withFileTypes:!0}),s=new Set;for(let n of t){if(!n.isFile())continue;let i=W.join(n.parentPath,n.name);i.includes("node_modules")||Hn.has(W.extname(n.name))&&s.add(A(i))}return s}function ht(){console.log("Usage: pickety <command> [options]"),console.log(""),console.log("Commands:"),console.log(" check Check all files for boundary violations"),console.log(" impact <file> Show which files and modules depend on a file"),console.log(" health Show module health metrics and check thresholds"),console.log(""),console.log("Options:"),console.log(" --root <path> Workspace root (defaults to current directory)")}function Te(e){let t=Ce(e);if(!t.ok){console.error("Configuration errors:");for(let i of t.errors)console.error(` ${i.message}${i.path?` (at ${i.path})`:""}`);process.exit(1)}let s=Gn(e),n=tt(e);return{config:t.config,ctx:{root:e,knownFiles:s,aliases:n}}}function gt(e){let t=new ne;for(let s of e.knownFiles)try{let n=z.readFileSync(s,"utf-8"),i=ve(s,n,e);t.updateFile(s,i)}catch{continue}return t}function qn(e){let{config:t,ctx:s}=Te(e),n=new ne,i=[];for(let u of s.knownFiles)try{let a=z.readFileSync(u,"utf-8"),p=rt(u,a,t,s);i.push(...p);let h=ve(u,a,s);n.updateFile(u,h)}catch{continue}let r=lt(i,t),o=n.getModuleLevelGraph(t.modules,e),c=Ke(o);r.length===0&&c.length===0&&(console.log("No boundary violations found."),process.exit(0));for(let u of r)console.log(ft(u,e));for(let u of c)console.log(`error: Circular dependency detected: ${u.join(" -> ")}`);let l=r.filter(u=>u.severity==="error").length+c.length,f=r.filter(u=>u.severity==="warn").length;console.log(""),console.log(`Found ${r.length} violation(s): ${l} error(s), ${f} warning(s)`),process.exit(l>0?1:0)}function Xn(e,t){t||(console.error("Usage: pickety impact <file> [--root <path>]"),process.exit(1)),z.existsSync(t)||(console.error(`File not found: ${t}`),process.exit(1));let{config:s,ctx:n}=Te(e),i=gt(n);ut(t,i,s,e)}function Jn(e){let{config:t,ctx:s}=Te(e),n=gt(s),i=ct(n,t.modules,s),r=t.health?at(i,t.health):[];pt(i,r),r.length>0?(console.log(`
|
|
17
17
|
${r.length} threshold violation(s) found.`),process.exit(1)):(console.log(`
|
|
18
|
-
All modules within configured thresholds.`),process.exit(0))}function
|
|
18
|
+
All modules within configured thresholds.`),process.exit(0))}function Zn(){let{command:e,root:t,target:s}=Un(process.argv);switch((!e||e==="--help"||e==="-h")&&(ht(),process.exit(0)),e){case"check":qn(t);break;case"impact":Xn(t,s);break;case"health":Jn(t);break;default:console.error(`Unknown command: "${e}"`),ht(),process.exit(1)}}Zn();
|
package/out/extension.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";var vn=Object.create;var $e=Object.defineProperty;var kn=Object.getOwnPropertyDescriptor;var wn=Object.getOwnPropertyNames;var xn=Object.getPrototypeOf,Sn=Object.prototype.hasOwnProperty;var En=(e,t)=>{for(var s in t)$e(e,s,{get:t[s],enumerable:!0})},vt=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of wn(t))!Sn.call(e,i)&&i!==s&&$e(e,i,{get:()=>t[i],enumerable:!(n=kn(t,i))||n.enumerable});return e};var S=(e,t,s)=>(s=e!=null?vn(xn(e)):{},vt(t||!e||!e.__esModule?$e(s,"default",{value:e,enumerable:!0}):s,e)),Tn=e=>vt($e({},"__esModule",{value:!0}),e);var Js={};En(Js,{activate:()=>Us,deactivate:()=>qs});module.exports=Tn(Js);var G=S(require("vscode"));var B=S(require("vscode"));var re=S(require("vscode")),Ne=S(require("fs"));var Re=S(require("path"));var Ke=(e,t,s)=>{let n=e instanceof RegExp?kt(e,s):e,i=t instanceof RegExp?kt(t,s):t,o=n!==null&&i!=null&&An(n,i,s);return o&&{start:o[0],end:o[1],pre:s.slice(0,o[0]),body:s.slice(o[0]+n.length,o[1]),post:s.slice(o[1]+i.length)}},kt=(e,t)=>{let s=t.match(e);return s?s[0]:null},An=(e,t,s)=>{let n,i,o,r,c,a=s.indexOf(e),l=s.indexOf(t,a+1),p=a;if(a>=0&&l>0){if(e===t)return[a,l];for(n=[],o=s.length;p>=0&&!c;){if(p===a)n.push(p),a=s.indexOf(e,p+1);else if(n.length===1){let u=n.pop();u!==void 0&&(c=[u,l])}else i=n.pop(),i!==void 0&&i<o&&(o=i,r=l),l=s.indexOf(t,p+1);p=a<l&&a>=0?a:l}n.length&&r!==void 0&&(c=[o,r])}return c};var wt="\0SLASH"+Math.random()+"\0",xt="\0OPEN"+Math.random()+"\0",tt="\0CLOSE"+Math.random()+"\0",St="\0COMMA"+Math.random()+"\0",Et="\0PERIOD"+Math.random()+"\0",Mn=new RegExp(wt,"g"),$n=new RegExp(xt,"g"),On=new RegExp(tt,"g"),Rn=new RegExp(St,"g"),Ln=new RegExp(Et,"g"),Pn=/\\\\/g,Nn=/\\{/g,In=/\\}/g,Dn=/\\,/g,Cn=/\\./g,jn=1e5;function et(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Fn(e){return e.replace(Pn,wt).replace(Nn,xt).replace(In,tt).replace(Dn,St).replace(Cn,Et)}function _n(e){return e.replace(Mn,"\\").replace($n,"{").replace(On,"}").replace(Rn,",").replace(Ln,".")}function Tt(e){if(!e)return[""];let t=[],s=Ke("{","}",e);if(!s)return e.split(",");let{pre:n,body:i,post:o}=s,r=n.split(",");r[r.length-1]+="{"+i+"}";let c=Tt(o);return o.length&&(r[r.length-1]+=c.shift(),r.push.apply(r,c)),t.push.apply(t,r),t}function At(e,t={}){if(!e)return[];let{max:s=jn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),ve(Fn(e),s,!0).map(_n)}function Wn(e){return"{"+e+"}"}function Vn(e){return/^-?0\d/.test(e)}function Bn(e,t){return e<=t}function Hn(e,t){return e>=t}function ve(e,t,s){let n=[],i=Ke("{","}",e);if(!i)return[e];let o=i.pre,r=i.post.length?ve(i.post,t,!1):[""];if(/\$$/.test(i.pre))for(let c=0;c<r.length&&c<t;c++){let a=o+"{"+i.body+"}"+r[c];n.push(a)}else{let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),l=c||a,p=i.body.indexOf(",")>=0;if(!l&&!p)return i.post.match(/,(?!,).*\}/)?(e=i.pre+"{"+i.body+tt+i.post,ve(e,t,!0)):[e];let u;if(l)u=i.body.split(/\.\./);else if(u=Tt(i.body),u.length===1&&u[0]!==void 0&&(u=ve(u[0],t,!1).map(Wn),u.length===1))return r.map(d=>i.pre+u[0]+d);let f;if(l&&u[0]!==void 0&&u[1]!==void 0){let d=et(u[0]),g=et(u[1]),b=Math.max(u[0].length,u[1].length),k=u.length===3&&u[2]!==void 0?Math.abs(et(u[2])):1,E=Bn;g<d&&(k*=-1,E=Hn);let m=u.some(Vn);f=[];for(let w=d;E(w,g);w+=k){let y;if(a)y=String.fromCharCode(w),y==="\\"&&(y="");else if(y=String(w),m){let v=b-y.length;if(v>0){let h=new Array(v+1).join("0");w<0?y="-"+h+y.slice(1):y=h+y}}f.push(y)}}else{f=[];for(let d=0;d<u.length;d++)f.push.apply(f,ve(u[d],t,!1))}for(let d=0;d<f.length;d++)for(let g=0;g<r.length&&n.length<t;g++){let b=o+f[d]+r[g];(!s||l||b)&&n.push(b)}}return n}var ke=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Gn={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},we=e=>e.replace(/[[\]\\-]/g,"\\$&"),zn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Mt=e=>e.join(""),$t=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=s+1,r=!1,c=!1,a=!1,l=!1,p=s,u="";e:for(;o<e.length;){let b=e.charAt(o);if((b==="!"||b==="^")&&o===s+1){l=!0,o++;continue}if(b==="]"&&r&&!a){p=o+1;break}if(r=!0,b==="\\"&&!a){a=!0,o++;continue}if(b==="["&&!a){for(let[k,[E,T,m]]of Object.entries(Gn))if(e.startsWith(k,o)){if(u)return["$.",!1,e.length-s,!0];o+=k.length,m?i.push(E):n.push(E),c=c||T;continue e}}if(a=!1,u){b>u?n.push(we(u)+"-"+we(b)):b===u&&n.push(we(b)),u="",o++;continue}if(e.startsWith("-]",o+1)){n.push(we(b+"-")),o+=2;continue}if(e.startsWith("-",o+1)){u=b,o+=2;continue}n.push(we(b)),o++}if(p<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-s,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!l){let b=n[0].length===2?n[0].slice(-1):n[0];return[zn(b),!1,p-s,!1]}let f="["+(l?"^":"")+Mt(n)+"]",d="["+(l?"":"^")+Mt(i)+"]";return[n.length&&i.length?"("+f+"|"+d+")":n.length?f:d,c,p-s,!0]};var Q=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!0}={})=>s?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var Un=new Set(["!","?","+","*","@"]),Ot=e=>Un.has(e),qn="(?!(?:^|/)\\.\\.?(?:$|/))",Oe="(?!\\.)",Jn=new Set(["[","."]),Xn=new Set(["..","."]),Qn=new Set("().*{}+?[]^$\\!"),Zn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),nt="[^/]",Rt=nt+"*?",Lt=nt+"+?",se=class e{type;#n;#s;#o=!1;#e=[];#t;#r;#c;#a=!1;#i;#l;#u=!1;constructor(t,s,n={}){this.type=t,t&&(this.#s=!0),this.#t=s,this.#n=this.#t?this.#t.#n:this,this.#i=this.#n===this?n:this.#n.#i,this.#c=this.#n===this?[]:this.#n.#c,t==="!"&&!this.#n.#a&&this.#c.push(this),this.#r=this.#t?this.#t.#e.length:0}get hasMagic(){if(this.#s!==void 0)return this.#s;for(let t of this.#e)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#s=!0;return this.#s}toString(){return this.#l!==void 0?this.#l:this.type?this.#l=this.type+"("+this.#e.map(t=>String(t)).join("|")+")":this.#l=this.#e.map(t=>String(t)).join("")}#d(){if(this!==this.#n)throw new Error("should only call on root");if(this.#a)return this;this.toString(),this.#a=!0;let t;for(;t=this.#c.pop();){if(t.type!=="!")continue;let s=t,n=s.#t;for(;n;){for(let i=s.#r+1;!n.type&&i<n.#e.length;i++)for(let o of t.#e){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#e[i])}s=n,n=s.#t}}return this}push(...t){for(let s of t)if(s!==""){if(typeof s!="string"&&!(s instanceof e&&s.#t===this))throw new Error("invalid part: "+s);this.#e.push(s)}}toJSON(){let t=this.type===null?this.#e.slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...this.#e.map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#n||this.#n.#a&&this.#t?.type==="!")&&t.push({}),t}isStart(){if(this.#n===this)return!0;if(!this.#t?.isStart())return!1;if(this.#r===0)return!0;let t=this.#t;for(let s=0;s<this.#r;s++){let n=t.#e[s];if(!(n instanceof e&&n.type==="!"))return!1}return!0}isEnd(){if(this.#n===this||this.#t?.type==="!")return!0;if(!this.#t?.isEnd())return!1;if(!this.type)return this.#t?.isEnd();let t=this.#t?this.#t.#e.length:0;return this.#r===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let s=new e(this.type,t);for(let n of this.#e)s.copyIn(n);return s}static#p(t,s,n,i){let o=!1,r=!1,c=-1,a=!1;if(s.type===null){let d=n,g="";for(;d<t.length;){let b=t.charAt(d++);if(o||b==="\\"){o=!o,g+=b;continue}if(r){d===c+1?(b==="^"||b==="!")&&(a=!0):b==="]"&&!(d===c+2&&a)&&(r=!1),g+=b;continue}else if(b==="["){r=!0,c=d,a=!1,g+=b;continue}if(!i.noext&&Ot(b)&&t.charAt(d)==="("){s.push(g),g="";let k=new e(b,s);d=e.#p(t,k,d,i),s.push(k);continue}g+=b}return s.push(g),d}let l=n+1,p=new e(null,s),u=[],f="";for(;l<t.length;){let d=t.charAt(l++);if(o||d==="\\"){o=!o,f+=d;continue}if(r){l===c+1?(d==="^"||d==="!")&&(a=!0):d==="]"&&!(l===c+2&&a)&&(r=!1),f+=d;continue}else if(d==="["){r=!0,c=l,a=!1,f+=d;continue}if(Ot(d)&&t.charAt(l)==="("){p.push(f),f="";let g=new e(d,p);p.push(g),l=e.#p(t,g,l,i);continue}if(d==="|"){p.push(f),f="",u.push(p),p=new e(null,s);continue}if(d===")")return f===""&&s.#e.length===0&&(s.#u=!0),p.push(f),f="",s.push(...u,p),l;f+=d}return s.type=null,s.#s=void 0,s.#e=[t.substring(n-1)],l}static fromGlob(t,s={}){let n=new e(null,void 0,s);return e.#p(t,n,0,s),n}toMMPattern(){if(this!==this.#n)return this.#n.toMMPattern();let t=this.toString(),[s,n,i,o]=this.toRegExpSource();if(!(i||this.#s||this.#i.nocase&&!this.#i.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let c=(this.#i.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${s}$`,c),{_src:s,_glob:t})}get options(){return this.#i}toRegExpSource(t){let s=t??!!this.#i.dot;if(this.#n===this&&this.#d(),!this.type){let a=this.isStart()&&this.isEnd()&&!this.#e.some(d=>typeof d!="string"),l=this.#e.map(d=>{let[g,b,k,E]=typeof d=="string"?e.#h(d,this.#s,a):d.toRegExpSource(t);return this.#s=this.#s||k,this.#o=this.#o||E,g}).join(""),p="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&Xn.has(this.#e[0]))){let g=Jn,b=s&&g.has(l.charAt(0))||l.startsWith("\\.")&&g.has(l.charAt(2))||l.startsWith("\\.\\.")&&g.has(l.charAt(4)),k=!s&&!t&&g.has(l.charAt(0));p=b?qn:k?Oe:""}let u="";return this.isEnd()&&this.#n.#a&&this.#t?.type==="!"&&(u="(?:$|\\/)"),[p+l+u,Q(l),this.#s=!!this.#s,this.#o]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#f(s);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let a=this.toString();return this.#e=[a],this.type=null,this.#s=void 0,[a,Q(this.toString()),!1,!1]}let r=!n||t||s||!Oe?"":this.#f(!0);r===o&&(r=""),r&&(o=`(?:${o})(?:${r})*?`);let c="";if(this.type==="!"&&this.#u)c=(this.isStart()&&!s?Oe:"")+Lt;else{let a=this.type==="!"?"))"+(this.isStart()&&!s&&!t?Oe:"")+Rt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&r?")":this.type==="*"&&r?")?":`)${this.type}`;c=i+o+a}return[c,Q(o),this.#s=!!this.#s,this.#o]}#f(t){return this.#e.map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[n,i,o,r]=s.toRegExpSource(t);return this.#o=this.#o||r,n}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")}static#h(t,s,n=!1){let i=!1,o="",r=!1,c=!1;for(let a=0;a<t.length;a++){let l=t.charAt(a);if(i){i=!1,o+=(Qn.has(l)?"\\":"")+l;continue}if(l==="*"){if(c)continue;c=!0,o+=n&&/^[*]+$/.test(t)?Lt:Rt,s=!0;continue}else c=!1;if(l==="\\"){a===t.length-1?o+="\\\\":i=!0;continue}if(l==="["){let[p,u,f,d]=$t(t,a);if(f){o+=p,r=r||u,a+=f-1,s=s||d;continue}}if(l==="?"){o+=nt,s=!0;continue}o+=Zn(l)}return[o,Q(t),!!s,r]}};var st=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!1}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var A=(e,t,s={})=>(ke(t),!s.nocomment&&t.charAt(0)==="#"?!1:new ie(t,s).match(e)),Yn=/^\*+([^+@!?\*\[\(]*)$/,Kn=e=>t=>!t.startsWith(".")&&t.endsWith(e),es=e=>t=>t.endsWith(e),ts=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),ns=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),ss=/^\*+\.\*+$/,is=e=>!e.startsWith(".")&&e.includes("."),os=e=>e!=="."&&e!==".."&&e.includes("."),rs=/^\.\*+$/,as=e=>e!=="."&&e!==".."&&e.startsWith("."),cs=/^\*+$/,ls=e=>e.length!==0&&!e.startsWith("."),ps=e=>e.length!==0&&e!=="."&&e!=="..",us=/^\?+([^+@!?\*\[\(]*)?$/,fs=([e,t=""])=>{let s=It([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},ds=([e,t=""])=>{let s=Dt([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},hs=([e,t=""])=>{let s=Dt([e]);return t?n=>s(n)&&n.endsWith(t):s},gs=([e,t=""])=>{let s=It([e]);return t?n=>s(n)&&n.endsWith(t):s},It=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},Dt=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},Ct=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Pt={win32:{sep:"\\"},posix:{sep:"/"}},ms=Ct==="win32"?Pt.win32.sep:Pt.posix.sep;A.sep=ms;var C=Symbol("globstar **");A.GLOBSTAR=C;var ys="[^/]",bs=ys+"*?",vs="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",ks="(?:(?!(?:\\/|^)\\.).)*?",ws=(e,t={})=>s=>A(s,e,t);A.filter=ws;var D=(e,t={})=>Object.assign({},e,t),xs=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return A;let t=A;return Object.assign((n,i,o={})=>t(n,i,D(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,D(e,o))}static defaults(i){return t.defaults(D(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,r={}){super(i,o,D(e,r))}static fromGlob(i,o={}){return t.AST.fromGlob(i,D(e,o))}},unescape:(n,i={})=>t.unescape(n,D(e,i)),escape:(n,i={})=>t.escape(n,D(e,i)),filter:(n,i={})=>t.filter(n,D(e,i)),defaults:n=>t.defaults(D(e,n)),makeRe:(n,i={})=>t.makeRe(n,D(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,D(e,i)),match:(n,i,o={})=>t.match(n,i,D(e,o)),sep:t.sep,GLOBSTAR:C})};A.defaults=xs;var jt=(e,t={})=>(ke(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:At(e,{max:t.braceExpandMax}));A.braceExpand=jt;var Ss=(e,t={})=>new ie(e,t).makeRe();A.makeRe=Ss;var Es=(e,t,s={})=>{let n=new ie(t,s);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};A.match=Es;var Nt=/[?*]|[+@!]\(.*?\)|\[|\]/,Ts=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ie=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,s={}){ke(t),s=s||{},this.options=s,this.pattern=t,this.platform=s.platform||Ct,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!s.windowsPathsNoEscape||s[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!s.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!s.nonegate,this.comment=!1,this.empty=!1,this.partial=!!s.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=s.windowsNoMagicRoot!==void 0?s.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let s of t)if(typeof s!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,s=this.options;if(!s.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],s.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,r,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let a=o[0]===""&&o[1]===""&&(o[2]==="?"||!Nt.test(o[2]))&&!Nt.test(o[3]),l=/^[a-z]:/i.test(o[0]);if(a)return[...o.slice(0,4),...o.slice(4).map(p=>this.parse(p))];if(l)return[o[0],...o.slice(1).map(p=>this.parse(p))]}return o.map(a=>this.parse(a))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let r=this.set[o];r[0]===""&&r[1]===""&&this.globParts[o][2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3])&&(r[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n=0;n<t.length;n++)for(let i=0;i<t[n].length;i++)t[n][i]==="**"&&(t[n][i]="*");let{optimizationLevel:s=1}=this.options;return s>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):s>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(s=>{let n=-1;for(;(n=s.indexOf("**",n+1))!==-1;){let i=n;for(;s[i+1]==="**";)i++;i!==n&&s.splice(n,i-n)}return s})}levelOneOptimize(t){return t.map(s=>(s=s.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),s.length===0?[""]:s))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let s=!1;do{if(s=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(s=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(s=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&(s=!0,t.splice(n-1,2),n-=2)}}while(s);return t.length===0?[""]:t}firstPhasePreProcess(t){let s=!1;do{s=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let r=i;for(;n[r+1]==="**";)r++;r>i&&n.splice(i+1,r-i);let c=n[i+1],a=n[i+2],l=n[i+3];if(c!==".."||!a||a==="."||a===".."||!l||l==="."||l==="..")continue;s=!0,n.splice(i,1);let p=n.slice(0);p[i]="**",t.push(p),i--}if(!this.preserveMultipleSlashes){for(let r=1;r<n.length-1;r++){let c=n[r];r===1&&c===""&&n[0]===""||(c==="."||c==="")&&(s=!0,n.splice(r,1),r--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(s=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let r=n[o-1];if(r&&r!=="."&&r!==".."&&r!=="**"){s=!0;let a=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...a),n.length===0&&n.push(""),o-=2}}}}while(s);return t}secondPhasePreProcess(t){for(let s=0;s<t.length-1;s++)for(let n=s+1;n<t.length;n++){let i=this.partsMatch(t[s],t[n],!this.preserveMultipleSlashes);if(i){t[s]=[],t[n]=i;break}}return t.filter(s=>s.length)}partsMatch(t,s,n=!1){let i=0,o=0,r=[],c="";for(;i<t.length&&o<s.length;)if(t[i]===s[o])r.push(c==="b"?s[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&s[o]===t[i+1])r.push(t[i]),i++;else if(n&&s[o]==="**"&&t[i]===s[o+1])r.push(s[o]),o++;else if(t[i]==="*"&&s[o]&&(this.options.dot||!s[o].startsWith("."))&&s[o]!=="**"){if(c==="b")return!1;c="a",r.push(t[i]),i++,o++}else if(s[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(c==="a")return!1;c="b",r.push(s[o]),i++,o++}else return!1;return t.length===s.length&&r}parseNegate(){if(this.nonegate)return;let t=this.pattern,s=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)s=!s,n++;n&&(this.pattern=t.slice(n)),this.negate=s}matchOne(t,s,n=!1){let i=this.options;if(this.isWindows){let b=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),k=!b&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),E=typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0]),T=!E&&s[0]===""&&s[1]===""&&s[2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3]),m=k?3:b?0:void 0,w=T?3:E?0:void 0;if(typeof m=="number"&&typeof w=="number"){let[y,v]=[t[m],s[w]];y.toLowerCase()===v.toLowerCase()&&(s[w]=y,w>m?s=s.slice(w):m>w&&(t=t.slice(m)))}}let{optimizationLevel:o=1}=this.options;o>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:s}),this.debug("matchOne",t.length,s.length);for(var r=0,c=0,a=t.length,l=s.length;r<a&&c<l;r++,c++){this.debug("matchOne loop");var p=s[c],u=t[r];if(this.debug(s,p,u),p===!1)return!1;if(p===C){this.debug("GLOBSTAR",[s,p,u]);var f=r,d=c+1;if(d===l){for(this.debug("** at the end");r<a;r++)if(t[r]==="."||t[r]===".."||!i.dot&&t[r].charAt(0)===".")return!1;return!0}for(;f<a;){var g=t[f];if(this.debug(`
|
|
1
|
+
"use strict";var wn=Object.create;var Re=Object.defineProperty;var xn=Object.getOwnPropertyDescriptor;var Sn=Object.getOwnPropertyNames;var En=Object.getPrototypeOf,Tn=Object.prototype.hasOwnProperty;var An=(e,t)=>{for(var s in t)Re(e,s,{get:t[s],enumerable:!0})},kt=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Sn(t))!Tn.call(e,i)&&i!==s&&Re(e,i,{get:()=>t[i],enumerable:!(n=xn(t,i))||n.enumerable});return e};var S=(e,t,s)=>(s=e!=null?wn(En(e)):{},kt(t||!e||!e.__esModule?Re(s,"default",{value:e,enumerable:!0}):s,e)),Mn=e=>kt(Re({},"__esModule",{value:!0}),e);var Qs={};An(Qs,{activate:()=>Js,deactivate:()=>Xs});module.exports=Mn(Qs);var G=S(require("vscode"));var B=S(require("vscode"));var le=S(require("vscode")),De=S(require("fs"));var Ie=S(require("path"));var et=(e,t,s)=>{let n=e instanceof RegExp?wt(e,s):e,i=t instanceof RegExp?wt(t,s):t,o=n!==null&&i!=null&&$n(n,i,s);return o&&{start:o[0],end:o[1],pre:s.slice(0,o[0]),body:s.slice(o[0]+n.length,o[1]),post:s.slice(o[1]+i.length)}},wt=(e,t)=>{let s=t.match(e);return s?s[0]:null},$n=(e,t,s)=>{let n,i,o,r,c,a=s.indexOf(e),l=s.indexOf(t,a+1),u=a;if(a>=0&&l>0){if(e===t)return[a,l];for(n=[],o=s.length;u>=0&&!c;){if(u===a)n.push(u),a=s.indexOf(e,u+1);else if(n.length===1){let p=n.pop();p!==void 0&&(c=[p,l])}else i=n.pop(),i!==void 0&&i<o&&(o=i,r=l),l=s.indexOf(t,u+1);u=a<l&&a>=0?a:l}n.length&&r!==void 0&&(c=[o,r])}return c};var xt="\0SLASH"+Math.random()+"\0",St="\0OPEN"+Math.random()+"\0",nt="\0CLOSE"+Math.random()+"\0",Et="\0COMMA"+Math.random()+"\0",Tt="\0PERIOD"+Math.random()+"\0",On=new RegExp(xt,"g"),Rn=new RegExp(St,"g"),Pn=new RegExp(nt,"g"),In=new RegExp(Et,"g"),Ln=new RegExp(Tt,"g"),Nn=/\\\\/g,Dn=/\\{/g,Cn=/\\}/g,jn=/\\,/g,Fn=/\\./g,_n=1e5;function tt(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Wn(e){return e.replace(Nn,xt).replace(Dn,St).replace(Cn,nt).replace(jn,Et).replace(Fn,Tt)}function Vn(e){return e.replace(On,"\\").replace(Rn,"{").replace(Pn,"}").replace(In,",").replace(Ln,".")}function At(e){if(!e)return[""];let t=[],s=et("{","}",e);if(!s)return e.split(",");let{pre:n,body:i,post:o}=s,r=n.split(",");r[r.length-1]+="{"+i+"}";let c=At(o);return o.length&&(r[r.length-1]+=c.shift(),r.push.apply(r,c)),t.push.apply(t,r),t}function Mt(e,t={}){if(!e)return[];let{max:s=_n}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),we(Wn(e),s,!0).map(Vn)}function Bn(e){return"{"+e+"}"}function Hn(e){return/^-?0\d/.test(e)}function Gn(e,t){return e<=t}function zn(e,t){return e>=t}function we(e,t,s){let n=[],i=et("{","}",e);if(!i)return[e];let o=i.pre,r=i.post.length?we(i.post,t,!1):[""];if(/\$$/.test(i.pre))for(let c=0;c<r.length&&c<t;c++){let a=o+"{"+i.body+"}"+r[c];n.push(a)}else{let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),l=c||a,u=i.body.indexOf(",")>=0;if(!l&&!u)return i.post.match(/,(?!,).*\}/)?(e=i.pre+"{"+i.body+nt+i.post,we(e,t,!0)):[e];let p;if(l)p=i.body.split(/\.\./);else if(p=At(i.body),p.length===1&&p[0]!==void 0&&(p=we(p[0],t,!1).map(Bn),p.length===1))return r.map(d=>i.pre+p[0]+d);let f;if(l&&p[0]!==void 0&&p[1]!==void 0){let d=tt(p[0]),g=tt(p[1]),b=Math.max(p[0].length,p[1].length),k=p.length===3&&p[2]!==void 0?Math.abs(tt(p[2])):1,E=Gn;g<d&&(k*=-1,E=zn);let m=p.some(Hn);f=[];for(let w=d;E(w,g);w+=k){let y;if(a)y=String.fromCharCode(w),y==="\\"&&(y="");else if(y=String(w),m){let v=b-y.length;if(v>0){let h=new Array(v+1).join("0");w<0?y="-"+h+y.slice(1):y=h+y}}f.push(y)}}else{f=[];for(let d=0;d<p.length;d++)f.push.apply(f,we(p[d],t,!1))}for(let d=0;d<f.length;d++)for(let g=0;g<r.length&&n.length<t;g++){let b=o+f[d]+r[g];(!s||l||b)&&n.push(b)}}return n}var xe=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Un={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Se=e=>e.replace(/[[\]\\-]/g,"\\$&"),qn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),$t=e=>e.join(""),Ot=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let n=[],i=[],o=s+1,r=!1,c=!1,a=!1,l=!1,u=s,p="";e:for(;o<e.length;){let b=e.charAt(o);if((b==="!"||b==="^")&&o===s+1){l=!0,o++;continue}if(b==="]"&&r&&!a){u=o+1;break}if(r=!0,b==="\\"&&!a){a=!0,o++;continue}if(b==="["&&!a){for(let[k,[E,T,m]]of Object.entries(Un))if(e.startsWith(k,o)){if(p)return["$.",!1,e.length-s,!0];o+=k.length,m?i.push(E):n.push(E),c=c||T;continue e}}if(a=!1,p){b>p?n.push(Se(p)+"-"+Se(b)):b===p&&n.push(Se(b)),p="",o++;continue}if(e.startsWith("-]",o+1)){n.push(Se(b+"-")),o+=2;continue}if(e.startsWith("-",o+1)){p=b,o+=2;continue}n.push(Se(b)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!i.length)return["$.",!1,e.length-s,!0];if(i.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!l){let b=n[0].length===2?n[0].slice(-1):n[0];return[qn(b),!1,u-s,!1]}let f="["+(l?"^":"")+$t(n)+"]",d="["+(l?"":"^")+$t(i)+"]";return[n.length&&i.length?"("+f+"|"+d+")":n.length?f:d,c,u-s,!0]};var Z=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!0}={})=>s?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var Jn=new Set(["!","?","+","*","@"]),Rt=e=>Jn.has(e),Xn="(?!(?:^|/)\\.\\.?(?:$|/))",Pe="(?!\\.)",Qn=new Set(["[","."]),Zn=new Set(["..","."]),Yn=new Set("().*{}+?[]^$\\!"),Kn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),st="[^/]",Pt=st+"*?",It=st+"+?",oe=class e{type;#n;#s;#o=!1;#e=[];#t;#r;#c;#a=!1;#i;#l;#p=!1;constructor(t,s,n={}){this.type=t,t&&(this.#s=!0),this.#t=s,this.#n=this.#t?this.#t.#n:this,this.#i=this.#n===this?n:this.#n.#i,this.#c=this.#n===this?[]:this.#n.#c,t==="!"&&!this.#n.#a&&this.#c.push(this),this.#r=this.#t?this.#t.#e.length:0}get hasMagic(){if(this.#s!==void 0)return this.#s;for(let t of this.#e)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#s=!0;return this.#s}toString(){return this.#l!==void 0?this.#l:this.type?this.#l=this.type+"("+this.#e.map(t=>String(t)).join("|")+")":this.#l=this.#e.map(t=>String(t)).join("")}#d(){if(this!==this.#n)throw new Error("should only call on root");if(this.#a)return this;this.toString(),this.#a=!0;let t;for(;t=this.#c.pop();){if(t.type!=="!")continue;let s=t,n=s.#t;for(;n;){for(let i=s.#r+1;!n.type&&i<n.#e.length;i++)for(let o of t.#e){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#e[i])}s=n,n=s.#t}}return this}push(...t){for(let s of t)if(s!==""){if(typeof s!="string"&&!(s instanceof e&&s.#t===this))throw new Error("invalid part: "+s);this.#e.push(s)}}toJSON(){let t=this.type===null?this.#e.slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...this.#e.map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#n||this.#n.#a&&this.#t?.type==="!")&&t.push({}),t}isStart(){if(this.#n===this)return!0;if(!this.#t?.isStart())return!1;if(this.#r===0)return!0;let t=this.#t;for(let s=0;s<this.#r;s++){let n=t.#e[s];if(!(n instanceof e&&n.type==="!"))return!1}return!0}isEnd(){if(this.#n===this||this.#t?.type==="!")return!0;if(!this.#t?.isEnd())return!1;if(!this.type)return this.#t?.isEnd();let t=this.#t?this.#t.#e.length:0;return this.#r===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let s=new e(this.type,t);for(let n of this.#e)s.copyIn(n);return s}static#u(t,s,n,i){let o=!1,r=!1,c=-1,a=!1;if(s.type===null){let d=n,g="";for(;d<t.length;){let b=t.charAt(d++);if(o||b==="\\"){o=!o,g+=b;continue}if(r){d===c+1?(b==="^"||b==="!")&&(a=!0):b==="]"&&!(d===c+2&&a)&&(r=!1),g+=b;continue}else if(b==="["){r=!0,c=d,a=!1,g+=b;continue}if(!i.noext&&Rt(b)&&t.charAt(d)==="("){s.push(g),g="";let k=new e(b,s);d=e.#u(t,k,d,i),s.push(k);continue}g+=b}return s.push(g),d}let l=n+1,u=new e(null,s),p=[],f="";for(;l<t.length;){let d=t.charAt(l++);if(o||d==="\\"){o=!o,f+=d;continue}if(r){l===c+1?(d==="^"||d==="!")&&(a=!0):d==="]"&&!(l===c+2&&a)&&(r=!1),f+=d;continue}else if(d==="["){r=!0,c=l,a=!1,f+=d;continue}if(Rt(d)&&t.charAt(l)==="("){u.push(f),f="";let g=new e(d,u);u.push(g),l=e.#u(t,g,l,i);continue}if(d==="|"){u.push(f),f="",p.push(u),u=new e(null,s);continue}if(d===")")return f===""&&s.#e.length===0&&(s.#p=!0),u.push(f),f="",s.push(...p,u),l;f+=d}return s.type=null,s.#s=void 0,s.#e=[t.substring(n-1)],l}static fromGlob(t,s={}){let n=new e(null,void 0,s);return e.#u(t,n,0,s),n}toMMPattern(){if(this!==this.#n)return this.#n.toMMPattern();let t=this.toString(),[s,n,i,o]=this.toRegExpSource();if(!(i||this.#s||this.#i.nocase&&!this.#i.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let c=(this.#i.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${s}$`,c),{_src:s,_glob:t})}get options(){return this.#i}toRegExpSource(t){let s=t??!!this.#i.dot;if(this.#n===this&&this.#d(),!this.type){let a=this.isStart()&&this.isEnd()&&!this.#e.some(d=>typeof d!="string"),l=this.#e.map(d=>{let[g,b,k,E]=typeof d=="string"?e.#h(d,this.#s,a):d.toRegExpSource(t);return this.#s=this.#s||k,this.#o=this.#o||E,g}).join(""),u="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&Zn.has(this.#e[0]))){let g=Qn,b=s&&g.has(l.charAt(0))||l.startsWith("\\.")&&g.has(l.charAt(2))||l.startsWith("\\.\\.")&&g.has(l.charAt(4)),k=!s&&!t&&g.has(l.charAt(0));u=b?Xn:k?Pe:""}let p="";return this.isEnd()&&this.#n.#a&&this.#t?.type==="!"&&(p="(?:$|\\/)"),[u+l+p,Z(l),this.#s=!!this.#s,this.#o]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#f(s);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let a=this.toString();return this.#e=[a],this.type=null,this.#s=void 0,[a,Z(this.toString()),!1,!1]}let r=!n||t||s||!Pe?"":this.#f(!0);r===o&&(r=""),r&&(o=`(?:${o})(?:${r})*?`);let c="";if(this.type==="!"&&this.#p)c=(this.isStart()&&!s?Pe:"")+It;else{let a=this.type==="!"?"))"+(this.isStart()&&!s&&!t?Pe:"")+Pt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&r?")":this.type==="*"&&r?")?":`)${this.type}`;c=i+o+a}return[c,Z(o),this.#s=!!this.#s,this.#o]}#f(t){return this.#e.map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[n,i,o,r]=s.toRegExpSource(t);return this.#o=this.#o||r,n}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")}static#h(t,s,n=!1){let i=!1,o="",r=!1,c=!1;for(let a=0;a<t.length;a++){let l=t.charAt(a);if(i){i=!1,o+=(Yn.has(l)?"\\":"")+l;continue}if(l==="*"){if(c)continue;c=!0,o+=n&&/^[*]+$/.test(t)?It:Pt,s=!0;continue}else c=!1;if(l==="\\"){a===t.length-1?o+="\\\\":i=!0;continue}if(l==="["){let[u,p,f,d]=Ot(t,a);if(f){o+=u,r=r||p,a+=f-1,s=s||d;continue}}if(l==="?"){o+=st,s=!0;continue}o+=Kn(l)}return[o,Z(t),!!s,r]}};var it=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!1}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var A=(e,t,s={})=>(xe(t),!s.nocomment&&t.charAt(0)==="#"?!1:new re(t,s).match(e)),es=/^\*+([^+@!?\*\[\(]*)$/,ts=e=>t=>!t.startsWith(".")&&t.endsWith(e),ns=e=>t=>t.endsWith(e),ss=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),is=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),os=/^\*+\.\*+$/,rs=e=>!e.startsWith(".")&&e.includes("."),as=e=>e!=="."&&e!==".."&&e.includes("."),cs=/^\.\*+$/,ls=e=>e!=="."&&e!==".."&&e.startsWith("."),us=/^\*+$/,ps=e=>e.length!==0&&!e.startsWith("."),fs=e=>e.length!==0&&e!=="."&&e!=="..",ds=/^\?+([^+@!?\*\[\(]*)?$/,hs=([e,t=""])=>{let s=Dt([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},gs=([e,t=""])=>{let s=Ct([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},ms=([e,t=""])=>{let s=Ct([e]);return t?n=>s(n)&&n.endsWith(t):s},ys=([e,t=""])=>{let s=Dt([e]);return t?n=>s(n)&&n.endsWith(t):s},Dt=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},Ct=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},jt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Lt={win32:{sep:"\\"},posix:{sep:"/"}},bs=jt==="win32"?Lt.win32.sep:Lt.posix.sep;A.sep=bs;var C=Symbol("globstar **");A.GLOBSTAR=C;var vs="[^/]",ks=vs+"*?",ws="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",xs="(?:(?!(?:\\/|^)\\.).)*?",Ss=(e,t={})=>s=>A(s,e,t);A.filter=Ss;var D=(e,t={})=>Object.assign({},e,t),Es=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return A;let t=A;return Object.assign((n,i,o={})=>t(n,i,D(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,D(e,o))}static defaults(i){return t.defaults(D(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,r={}){super(i,o,D(e,r))}static fromGlob(i,o={}){return t.AST.fromGlob(i,D(e,o))}},unescape:(n,i={})=>t.unescape(n,D(e,i)),escape:(n,i={})=>t.escape(n,D(e,i)),filter:(n,i={})=>t.filter(n,D(e,i)),defaults:n=>t.defaults(D(e,n)),makeRe:(n,i={})=>t.makeRe(n,D(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,D(e,i)),match:(n,i,o={})=>t.match(n,i,D(e,o)),sep:t.sep,GLOBSTAR:C})};A.defaults=Es;var Ft=(e,t={})=>(xe(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Mt(e,{max:t.braceExpandMax}));A.braceExpand=Ft;var Ts=(e,t={})=>new re(e,t).makeRe();A.makeRe=Ts;var As=(e,t,s={})=>{let n=new re(t,s);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};A.match=As;var Nt=/[?*]|[+@!]\(.*?\)|\[|\]/,Ms=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),re=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,s={}){xe(t),s=s||{},this.options=s,this.pattern=t,this.platform=s.platform||jt,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!s.windowsPathsNoEscape||s[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!s.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!s.nonegate,this.comment=!1,this.empty=!1,this.partial=!!s.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=s.windowsNoMagicRoot!==void 0?s.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let s of t)if(typeof s!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,s=this.options;if(!s.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],s.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let i=this.globParts.map((o,r,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let a=o[0]===""&&o[1]===""&&(o[2]==="?"||!Nt.test(o[2]))&&!Nt.test(o[3]),l=/^[a-z]:/i.test(o[0]);if(a)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(l)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(a=>this.parse(a))});if(this.debug(this.pattern,i),this.set=i.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let r=this.set[o];r[0]===""&&r[1]===""&&this.globParts[o][2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3])&&(r[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n=0;n<t.length;n++)for(let i=0;i<t[n].length;i++)t[n][i]==="**"&&(t[n][i]="*");let{optimizationLevel:s=1}=this.options;return s>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):s>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(s=>{let n=-1;for(;(n=s.indexOf("**",n+1))!==-1;){let i=n;for(;s[i+1]==="**";)i++;i!==n&&s.splice(n,i-n)}return s})}levelOneOptimize(t){return t.map(s=>(s=s.reduce((n,i)=>{let o=n[n.length-1];return i==="**"&&o==="**"?n:i===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(i),n)},[]),s.length===0?[""]:s))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let s=!1;do{if(s=!1,!this.preserveMultipleSlashes){for(let i=1;i<t.length-1;i++){let o=t[i];i===1&&o===""&&t[0]===""||(o==="."||o==="")&&(s=!0,t.splice(i,1),i--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(s=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let i=t[n-1];i&&i!=="."&&i!==".."&&i!=="**"&&(s=!0,t.splice(n-1,2),n-=2)}}while(s);return t.length===0?[""]:t}firstPhasePreProcess(t){let s=!1;do{s=!1;for(let n of t){let i=-1;for(;(i=n.indexOf("**",i+1))!==-1;){let r=i;for(;n[r+1]==="**";)r++;r>i&&n.splice(i+1,r-i);let c=n[i+1],a=n[i+2],l=n[i+3];if(c!==".."||!a||a==="."||a===".."||!l||l==="."||l==="..")continue;s=!0,n.splice(i,1);let u=n.slice(0);u[i]="**",t.push(u),i--}if(!this.preserveMultipleSlashes){for(let r=1;r<n.length-1;r++){let c=n[r];r===1&&c===""&&n[0]===""||(c==="."||c==="")&&(s=!0,n.splice(r,1),r--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(s=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let r=n[o-1];if(r&&r!=="."&&r!==".."&&r!=="**"){s=!0;let a=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...a),n.length===0&&n.push(""),o-=2}}}}while(s);return t}secondPhasePreProcess(t){for(let s=0;s<t.length-1;s++)for(let n=s+1;n<t.length;n++){let i=this.partsMatch(t[s],t[n],!this.preserveMultipleSlashes);if(i){t[s]=[],t[n]=i;break}}return t.filter(s=>s.length)}partsMatch(t,s,n=!1){let i=0,o=0,r=[],c="";for(;i<t.length&&o<s.length;)if(t[i]===s[o])r.push(c==="b"?s[o]:t[i]),i++,o++;else if(n&&t[i]==="**"&&s[o]===t[i+1])r.push(t[i]),i++;else if(n&&s[o]==="**"&&t[i]===s[o+1])r.push(s[o]),o++;else if(t[i]==="*"&&s[o]&&(this.options.dot||!s[o].startsWith("."))&&s[o]!=="**"){if(c==="b")return!1;c="a",r.push(t[i]),i++,o++}else if(s[o]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(c==="a")return!1;c="b",r.push(s[o]),i++,o++}else return!1;return t.length===s.length&&r}parseNegate(){if(this.nonegate)return;let t=this.pattern,s=!1,n=0;for(let i=0;i<t.length&&t.charAt(i)==="!";i++)s=!s,n++;n&&(this.pattern=t.slice(n)),this.negate=s}matchOne(t,s,n=!1){let i=this.options;if(this.isWindows){let b=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),k=!b&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),E=typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0]),T=!E&&s[0]===""&&s[1]===""&&s[2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3]),m=k?3:b?0:void 0,w=T?3:E?0:void 0;if(typeof m=="number"&&typeof w=="number"){let[y,v]=[t[m],s[w]];y.toLowerCase()===v.toLowerCase()&&(s[w]=y,w>m?s=s.slice(w):m>w&&(t=t.slice(m)))}}let{optimizationLevel:o=1}=this.options;o>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:s}),this.debug("matchOne",t.length,s.length);for(var r=0,c=0,a=t.length,l=s.length;r<a&&c<l;r++,c++){this.debug("matchOne loop");var u=s[c],p=t[r];if(this.debug(s,u,p),u===!1)return!1;if(u===C){this.debug("GLOBSTAR",[s,u,p]);var f=r,d=c+1;if(d===l){for(this.debug("** at the end");r<a;r++)if(t[r]==="."||t[r]===".."||!i.dot&&t[r].charAt(0)===".")return!1;return!0}for(;f<a;){var g=t[f];if(this.debug(`
|
|
2
2
|
globstar while`,t,f,s,d,g),this.matchOne(t.slice(f),s.slice(d),n))return this.debug("globstar found match!",f,a,g),!0;if(g==="."||g===".."||!i.dot&&g.charAt(0)==="."){this.debug("dot detected!",t,f,s,d);break}this.debug("globstar swallow a segment, and continue"),f++}return!!(n&&(this.debug(`
|
|
3
|
-
>>> no match, partial?`,t,f,s,d),f===a))}let b;if(typeof
|
|
4
|
-
`),n=[],i=0;for(let c of s)n.push(i),i+=c.length+1;let o=c=>{let a=0;for(let l=1;l<n.length&&!(n[l]>c);l++)a=l;return{line:a,character:c-n[a]}},r;for(
|
|
5
|
-
`)}var
|
|
3
|
+
>>> no match, partial?`,t,f,s,d),f===a))}let b;if(typeof u=="string"?(b=p===u,this.debug("string match",u,p,b)):(b=u.test(p),this.debug("pattern match",u,p,b)),!b)return!1}if(r===a&&c===l)return!0;if(r===a)return n;if(c===l)return r===a-1&&t[r]==="";throw new Error("wtf?")}braceExpand(){return Ft(this.pattern,this.options)}parse(t){xe(t);let s=this.options;if(t==="**")return C;if(t==="")return"";let n,i=null;(n=t.match(us))?i=s.dot?fs:ps:(n=t.match(es))?i=(s.nocase?s.dot?is:ss:s.dot?ns:ts)(n[1]):(n=t.match(ds))?i=(s.nocase?s.dot?gs:hs:s.dot?ms:ys)(n):(n=t.match(os))?i=s.dot?as:rs:(n=t.match(cs))&&(i=ls);let o=oe.fromGlob(t,this.options).toMMPattern();return i&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:i}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let s=this.options,n=s.noglobstar?ks:s.dot?ws:xs,i=new Set(s.nocase?["i"]:[]),o=t.map(a=>{let l=a.map(p=>{if(p instanceof RegExp)for(let f of p.flags.split(""))i.add(f);return typeof p=="string"?Ms(p):p===C?C:p._src});l.forEach((p,f)=>{let d=l[f+1],g=l[f-1];p!==C||g===C||(g===void 0?d!==void 0&&d!==C?l[f+1]="(?:\\/|"+n+"\\/)?"+d:l[f]=n:d===void 0?l[f-1]=g+"(?:\\/|\\/"+n+")?":d!==C&&(l[f-1]=g+"(?:\\/|\\/"+n+"\\/)"+d,l[f+1]=C))});let u=l.filter(p=>p!==C);if(this.partial&&u.length>=1){let p=[];for(let f=1;f<=u.length;f++)p.push(u.slice(0,f).join("/"));return"(?:"+p.join("|")+")"}return u.join("/")}).join("|"),[r,c]=t.length>1?["(?:",")"]:["",""];o="^"+r+o+c+"$",this.partial&&(o="^(?:\\/|"+r+o.slice(1,-1)+c+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...i].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,s=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&s)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let i=this.slashSplit(t);this.debug(this.pattern,"split",i);let o=this.set;this.debug(this.pattern,"set",o);let r=i[i.length-1];if(!r)for(let c=i.length-2;!r&&c>=0;c--)r=i[c];for(let c=0;c<o.length;c++){let a=o[c],l=i;if(n.matchBase&&a.length===1&&(l=[r]),this.matchOne(l,a,s))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return A.defaults(t).Minimatch}};A.AST=oe;A.Minimatch=re;A.escape=it;A.unescape=Z;var j="pickety.json",Le=["ts","tsx","js","jsx","mjs","cjs"],ee=`**/*.{${Le.join(",")}}`,ae=new Set(["node_modules",".git",".next","dist","out","build",".turbo",".cache",".nx","coverage"]);function M(e){let t=e.replace(/\\/g,"/");return/^[a-zA-Z]:/.test(t)&&(t=t[0].toLowerCase()+t.slice(1)),t}function Ne(e,t){return Ie.relative(e,t).replace(/\\/g,"/")}function ot(e,t){return A(e,t)||e===t}function ce(e){return Ie.join(e,j)}function U(e,t){return e==="instability"?t.toFixed(2):String(t)}async function _t(e,t){let s=ce(e);if(De.existsSync(s)&&await le.window.showWarningMessage("pickety.json already exists. Overwrite?","Yes","No")!=="Yes")return;De.writeFileSync(s,JSON.stringify({$schema:"https://raw.githubusercontent.com/DanielSerio/pickety/main/resources/pickety.schema.json",modules:{features:"src/features/*",components:"src/components/**/*",utils:"src/utils/**/*"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"features",imports:"features",allow:!0,message:"Features can import from their own module."},{importer:"features",imports:"components",allow:!0},{importer:"features",imports:"utils",allow:!0}]}},"boundary-diagrams":!0},null,2)),le.window.showInformationMessage("Pickety: pickety.json created.");let i=await le.workspace.openTextDocument(s);await le.window.showTextDocument(i),t()}var at=S(require("vscode"));var Y=S(require("path"));function Ce(e,t,s){return{allow:e.allow??!1,severity:e.severity??s,name:e.name??`rule[${t}]`,effectiveImporter:e.containedTo||e.importer||"*",isOnly:e.only||!!e.containedTo,isAllowStyle:(e.allow??!1)||!!e.containedTo||e.only}}function ue(e,t,s,n,i,o,r){return{file:e,line:t.line,character:t.character,length:t.length,message:`[${s}] ${n} (importing "${t.specifier}")`,severity:i,ruleName:s,sourceModule:o,targetModule:r}}function Wt(e){let t=[],s=new Set,n=new Set,i=[];function o(r){s.add(r),n.add(r),i.push(r);let c=e.get(r);if(c){for(let a of c)if(!s.has(a))o(a);else if(n.has(a)){let l=i.indexOf(a);l!==-1&&t.push([...i.slice(l),a])}}n.delete(r),i.pop()}for(let r of e.keys())s.has(r)||o(r);return t}var Bt=Le.map(e=>`.${e}`),$s=Bt.map(e=>`index${e}`),Vt=/(\/\*[\s\S]*?\*\/|\/\/.*)|(['"`](?:\\.|[^'"`])*['"`])|((?:import|export)\s+(?:[\s\S]*?from\s+)?['"`]([^'"`]+)['"`])|(import\s*\(\s*['"`]([^'"`]+)['"`]\s*\))/gm;function Os(e){let t=[],s=e.split(`
|
|
4
|
+
`),n=[],i=0;for(let c of s)n.push(i),i+=c.length+1;let o=c=>{let a=0;for(let l=1;l<n.length&&!(n[l]>c);l++)a=l;return{line:a,character:c-n[a]}},r;for(Vt.lastIndex=0;(r=Vt.exec(e))!==null;){let[c,a,l,u,p,f,d]=r;if(!(a||l)){if(u&&p){let g=o(r.index);t.push({specifier:p,line:g.line,character:g.character,length:u.length})}else if(f&&d){let g=o(r.index);t.push({specifier:d,line:g.line,character:g.character,length:f.length})}}}return t}function Rs(e,t,s){let{knownFiles:n,root:i,aliases:o}=s;for(let[r,c]of Object.entries(o))if(r.endsWith("/*")&&c.endsWith("/*")){let a=r.slice(0,-2),l=c.slice(0,-2);if(e.startsWith(a)){let u=e.replace(a,l);return rt(Y.resolve(i,u),n)}}else if(e===r)return rt(Y.resolve(i,c),n);if(e.startsWith(".")){let r=Y.dirname(t),c=Y.resolve(r,e);return rt(c,n)}}function rt(e,t){let s=M(e);if(t.has(s))return s;for(let n of Bt){let i=s+n;if(t.has(i))return i}for(let n of $s){let i=s+"/"+n;if(t.has(i))return i}}function F(e,t,s){let n=M(Y.relative(s,e));for(let[i,o]of Object.entries(t)){let r=o.endsWith("/*")?o.slice(0,-2)+"/**/*":o;if(A(n,r)||A(n,o))return i}}function je(e,t,s){let n=Os(t),i=[];for(let o of n){let r=Rs(o.specifier,e,s);r&&i.push({statement:o,resolvedPath:r})}return i}function pe(e,t,s){let{root:n,knownFiles:i}=s,o=e.getModuleLevelGraph(t,n),r=Object.keys(t),c=new Map;for(let p of r)c.set(p,0);for(let p of i){let f=F(p,t,n);f&&c.set(f,(c.get(f)??0)+1)}let a=new Map;for(let p of r)a.set(p,0);for(let[,p]of o)for(let f of p)a.set(f,(a.get(f)??0)+1);let l=Ps(o,r),u=r.map(p=>{let f=a.get(p)??0,d=o.get(p)?.size??0,g=f+d;return{moduleName:p,fileCount:c.get(p)??0,afferentCoupling:f,efferentCoupling:d,instability:g===0?0:d/g,dependencyDepth:l.get(p)??0}});return u.sort((p,f)=>p.instability-f.instability),u}function Ps(e,t){let s=new Map,n=new Set;function i(o){if(s.has(o))return s.get(o);if(n.has(o))return 0;n.add(o);let r=e.get(o),c=0;if(r&&r.size>0)for(let a of r)c=Math.max(c,1+i(a));return n.delete(o),s.set(o,c),c}for(let o of t)i(o);return s}function Ht(e,t){let s=[],n=[{key:"maxAfferentCoupling",label:"afferent coupling",getValue:i=>i.afferentCoupling},{key:"maxEfferentCoupling",label:"efferent coupling",getValue:i=>i.efferentCoupling},{key:"maxInstability",label:"instability",getValue:i=>i.instability},{key:"maxDepth",label:"dependency depth",getValue:i=>i.dependencyDepth}];for(let i of e)for(let o of n){let r=t[o.key],c=o.getValue(i);r!==void 0&&c>r&&s.push({moduleName:i.moduleName,metric:o.label,value:c,threshold:r})}return s}var J=S(require("fs")),q=S(require("path"));function Fe(e,t,s){let n=e["boundary-diagrams"];if(!n)return;let i="picket-boundaries.mermaid",o;if(typeof n=="string"){let l=q.resolve(t,n);try{J.existsSync(l)&&J.statSync(l).isDirectory()?o=q.join(l,i):o=l}catch{o=l}}else o=q.join(t,i);let r=M(q.resolve(t));if(!M(q.resolve(o)).startsWith(r+"/")){console.error(`Pickety: Diagram output path "${n}" escapes the workspace root. Ignoring.`);return}let a=Is(e,s);try{let l=q.dirname(o);return J.existsSync(l)||J.mkdirSync(l,{recursive:!0}),J.writeFileSync(o,a,"utf-8"),o}catch(l){console.error(`Pickety: Failed to write Mermaid diagram to ${o}`,l);return}}function fe(e){return e.replace(/"/g,"#quot;").replace(/\[/g,"#lsqb;").replace(/\]/g,"#rsqb;").replace(/\|/g,"#vert;").replace(/</g,"#lt;").replace(/>/g,"#gt;")}function Is(e,t){let s=["graph LR"],n=e.modules,i=e.rules["module-boundaries"].rules,o=e.rules["module-boundaries"].severity,r=new Map;if(t)for(let a of t)r.set(a.moduleName,a);s.push(""),s.push(" %% Module definitions");for(let[a,l]of Object.entries(n)){let u=r.get(a);u?s.push(` %% ${a}: ${l} (Ca=${u.afferentCoupling} Ce=${u.efferentCoupling} I=${u.instability.toFixed(2)} depth=${u.dependencyDepth})`):s.push(` %% ${a}: ${l}`)}let c=i.map((a,l)=>({rule:a,index:l,...Ce(a,l,o)}));if(c.forEach(({rule:a,index:l,allow:u,severity:p,name:f,effectiveImporter:d,isOnly:g,isAllowStyle:b})=>{let k=fe(f),E=u?"ALLOW":"DENY";g&&(E=a.containedTo?"CONTAINED TO":"ONLY"),s.push(""),s.push(` subgraph rule_${l} ["${E}: ${k} (${p})"]`);let T=`r${l}_from`,m=`r${l}_to`,w=fe(d),y=fe(a.imports),v=d.includes("$")?`(["${w}"])`:`["${w}"]`,h=a.imports.includes("$")?`(["${y}"])`:`["${y}"]`;s.push(` ${T}${v}`),s.push(` ${m}${h}`);let R=b?"-->":"-.->",I=a.message?` |"${fe(a.message)}"|`:"";s.push(` ${T} ${R}${I} ${m}`),s.push(" end")}),s.push(""),c.forEach(({isAllowStyle:a,index:l})=>{a?s.push(` linkStyle ${l} stroke:#22c55e,stroke-width:2px`):s.push(` linkStyle ${l} stroke:#ef4444,stroke-width:2px,stroke-dasharray:5`)}),r.size>0){s.push(""),s.push(' subgraph health_summary ["Module Health"]');for(let[a]of Object.entries(n)){let l=r.get(a);if(l){let u=`health_${fe(a)}`,p=`${fe(a)}\\nCa=${l.afferentCoupling} Ce=${l.efferentCoupling} I=${l.instability.toFixed(2)} depth=${l.dependencyDepth}`;s.push(` ${u}["${p}"]`)}}s.push(" end")}return s.join(`
|
|
5
|
+
`)}var Gt=S(require("vscode"));function de(e){return e?!0:(Gt.window.showErrorMessage("Pickety: No active configuration. Check pickety.json for errors."),!1)}function zt(e,t,s){if(!de(e))return;let n=pe(t,e.modules,s),i=Fe(e,s.root,n);i?at.window.showInformationMessage(`Pickety: Generated boundary diagram at ${i}`):at.window.showErrorMessage("Pickety: Failed to generate diagram. Is 'boundary-diagrams' enabled in pickety.json?")}var Ve=S(require("vscode"));var te;function qt(e,t){if(te){te.reveal(),te.webview.html=Ut(e,t);return}te=Ve.window.createWebviewPanel("picketyHealth","Pickety: Module Health",Ve.ViewColumn.One,{enableScripts:!1}),te.webview.html=Ut(e,t),te.onDidDispose(()=>{te=void 0})}function _e(e){let t=Math.max(0,Math.min(1,e));return`background-color: hsla(${Math.round((1-t)*140)}, 75%, 40%, 0.9); color: white; text-shadow: 0 1px 1px rgba(0,0,0,0.3);`}function We(e,t){return t===void 0?"":e>t?"exceeds":e>=t*.8?"approaching":""}function Ut(e,t){let s=Math.max(1,...e.map(r=>r.afferentCoupling)),n=Math.max(1,...e.map(r=>r.efferentCoupling)),i=Math.max(1,...e.map(r=>r.dependencyDepth));return`<!DOCTYPE html>
|
|
6
6
|
<html lang="en">
|
|
7
7
|
<head>
|
|
8
8
|
<meta charset="UTF-8">
|
|
@@ -54,14 +54,14 @@ globstar while`,t,f,s,d,g),this.matchOne(t.slice(f),s.slice(d),n))return this.de
|
|
|
54
54
|
}
|
|
55
55
|
tr.alt { background: var(--row-alt); }
|
|
56
56
|
tr:hover { background: rgba(128, 128, 128, 0.1); }
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
td.module-name { font-weight: 600; color: var(--fg); }
|
|
59
59
|
td.num {
|
|
60
60
|
text-align: right;
|
|
61
61
|
font-family: var(--vscode-editor-font-family, monospace);
|
|
62
62
|
font-variant-numeric: tabular-nums;
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
/* Metrics with Heatmap */
|
|
66
66
|
td.num[style*="background-color"] {
|
|
67
67
|
border-radius: 4px;
|
|
@@ -115,13 +115,13 @@ globstar while`,t,f,s,d,g),this.matchOne(t.slice(f),s.slice(d),n))return this.de
|
|
|
115
115
|
</tr>
|
|
116
116
|
</thead>
|
|
117
117
|
<tbody>
|
|
118
|
-
${e.map((r,c)=>{let a=r.afferentCoupling/s,l=r.efferentCoupling/n,
|
|
118
|
+
${e.map((r,c)=>{let a=r.afferentCoupling/s,l=r.efferentCoupling/n,u=r.instability,p=r.dependencyDepth/i,f=We(r.afferentCoupling,t?.maxAfferentCoupling),d=We(r.efferentCoupling,t?.maxEfferentCoupling),g=We(r.instability,t?.maxInstability),b=We(r.dependencyDepth,t?.maxDepth);return`<tr${c%2===1?' class="alt"':""}>
|
|
119
119
|
<td class="module-name">${Ls(r.moduleName)}</td>
|
|
120
120
|
<td class="num">${r.fileCount}</td>
|
|
121
|
-
<td class="num ${f}" style="${
|
|
122
|
-
<td class="num ${d}" style="${
|
|
123
|
-
<td class="num ${g}" style="${
|
|
124
|
-
<td class="num ${b}" style="${
|
|
121
|
+
<td class="num ${f}" style="${_e(a)}">${U("ca",r.afferentCoupling)}</td>
|
|
122
|
+
<td class="num ${d}" style="${_e(l)}">${U("ce",r.efferentCoupling)}</td>
|
|
123
|
+
<td class="num ${g}" style="${_e(u)}">${U("instability",r.instability)}</td>
|
|
124
|
+
<td class="num ${b}" style="${_e(p)}">${U("depth",r.dependencyDepth)}</td>
|
|
125
125
|
</tr>`}).join(`
|
|
126
126
|
`)}
|
|
127
127
|
</tbody>
|
|
@@ -136,18 +136,18 @@ globstar while`,t,f,s,d,g),this.matchOne(t.slice(f),s.slice(d),n))return this.de
|
|
|
136
136
|
`:""}
|
|
137
137
|
</div>
|
|
138
138
|
</body>
|
|
139
|
-
</html>`}function Ls(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function
|
|
140
|
-
`;break;case 114:m+="\r";break;case 116:m+=" ";break;case 117:let h=f(4,!0);h>=0?m+=String.fromCharCode(h):
|
|
141
|
-
`),c++,l=n,r=14;switch(m){case 123:return n++,r=1;case 125:return n++,r=2;case 91:return n++,r=3;case 93:return n++,r=4;case 58:return n++,r=6;case 44:return n++,r=5;case 34:return n++,i=b(),r=10;case 47:let w=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<s&&!
|
|
142
|
-
`+" ".repeat(t)),"\r":new Array(
|
|
143
|
-
`+" ".repeat(t))}," ":{"\n":new Array(
|
|
144
|
-
`+" ".repeat(t)),"\r":new Array(
|
|
145
|
-
`+" ".repeat(t))}},
|
|
139
|
+
</html>`}function Ls(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Jt(e,t,s){if(!de(e))return;let n=pe(t,e.modules,s);qt(n,e.health)}var W=S(require("vscode")),Xt=S(require("path"));async function Qt(e,t,s){let n=s.root,i=W.window.activeTextEditor;if(!i){W.window.showErrorMessage("Pickety: No active file.");return}if(!de(e))return;let o=M(i.document.uri.fsPath),r=t.getTransitiveDependents(o);if(r.size===0){W.window.showInformationMessage("Pickety: No dependents found for this file.");return}let c=new Map;for(let f of r){let d=F(f,e.modules,n)??"(unmatched)";c.has(d)||c.set(d,[]),c.get(d).push(Ne(n,f))}let a=[];for(let[f,d]of c){a.push({label:f,kind:W.QuickPickItemKind.Separator});for(let g of d)a.push({label:g,description:f})}let l=Ne(n,o),u=c.size,p=await W.window.showQuickPick(a,{title:`Impact: ${l} (${r.size} files across ${u} modules)`,placeHolder:"Select a file to open"});if(p&&p.kind!==W.QuickPickItemKind.Separator){let f=Xt.join(n,p.label),d=await W.workspace.openTextDocument(f);await W.window.showTextDocument(d)}}var O=S(require("vscode")),ht=S(require("path")),gt=S(require("fs"));function Te(e,t=!1){let s=e.length,n=0,i="",o=0,r=16,c=0,a=0,l=0,u=0,p=0;function f(m,w){let y=0,v=0;for(;y<m||!w;){let h=e.charCodeAt(n);if(h>=48&&h<=57)v=v*16+h-48;else if(h>=65&&h<=70)v=v*16+h-65+10;else if(h>=97&&h<=102)v=v*16+h-97+10;else break;n++,y++}return y<m&&(v=-1),v}function d(m){n=m,i="",o=0,r=16,p=0}function g(){let m=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&he(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&he(e.charCodeAt(n)))for(n++;n<e.length&&he(e.charCodeAt(n));)n++;else return p=3,e.substring(m,n);let w=n;if(n<e.length&&(e.charCodeAt(n)===69||e.charCodeAt(n)===101))if(n++,(n<e.length&&e.charCodeAt(n)===43||e.charCodeAt(n)===45)&&n++,n<e.length&&he(e.charCodeAt(n))){for(n++;n<e.length&&he(e.charCodeAt(n));)n++;w=n}else p=3;return e.substring(m,w)}function b(){let m="",w=n;for(;;){if(n>=s){m+=e.substring(w,n),p=2;break}let y=e.charCodeAt(n);if(y===34){m+=e.substring(w,n),n++;break}if(y===92){if(m+=e.substring(w,n),n++,n>=s){p=2;break}switch(e.charCodeAt(n++)){case 34:m+='"';break;case 92:m+="\\";break;case 47:m+="/";break;case 98:m+="\b";break;case 102:m+="\f";break;case 110:m+=`
|
|
140
|
+
`;break;case 114:m+="\r";break;case 116:m+=" ";break;case 117:let h=f(4,!0);h>=0?m+=String.fromCharCode(h):p=4;break;default:p=5}w=n;continue}if(y>=0&&y<=31)if(Ee(y)){m+=e.substring(w,n),p=2;break}else p=6;n++}return m}function k(){if(i="",p=0,o=n,a=c,u=l,n>=s)return o=s,r=17;let m=e.charCodeAt(n);if(ct(m)){do n++,i+=String.fromCharCode(m),m=e.charCodeAt(n);while(ct(m));return r=15}if(Ee(m))return n++,i+=String.fromCharCode(m),m===13&&e.charCodeAt(n)===10&&(n++,i+=`
|
|
141
|
+
`),c++,l=n,r=14;switch(m){case 123:return n++,r=1;case 125:return n++,r=2;case 91:return n++,r=3;case 93:return n++,r=4;case 58:return n++,r=6;case 44:return n++,r=5;case 34:return n++,i=b(),r=10;case 47:let w=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<s&&!Ee(e.charCodeAt(n));)n++;return i=e.substring(w,n),r=12}if(e.charCodeAt(n+1)===42){n+=2;let y=s-1,v=!1;for(;n<y;){let h=e.charCodeAt(n);if(h===42&&e.charCodeAt(n+1)===47){n+=2,v=!0;break}n++,Ee(h)&&(h===13&&e.charCodeAt(n)===10&&n++,c++,l=n)}return v||(n++,p=1),i=e.substring(w,n),r=13}return i+=String.fromCharCode(m),n++,r=16;case 45:if(i+=String.fromCharCode(m),n++,n===s||!he(e.charCodeAt(n)))return r=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return i+=g(),r=11;default:for(;n<s&&E(m);)n++,m=e.charCodeAt(n);if(o!==n){switch(i=e.substring(o,n),i){case"true":return r=8;case"false":return r=9;case"null":return r=7}return r=16}return i+=String.fromCharCode(m),n++,r=16}}function E(m){if(ct(m)||Ee(m))return!1;switch(m){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function T(){let m;do m=k();while(m>=12&&m<=15);return m}return{setPosition:d,getPosition:()=>n,scan:t?T:k,getToken:()=>r,getTokenValue:()=>i,getTokenOffset:()=>o,getTokenLength:()=>n-o,getTokenStartLine:()=>a,getTokenStartCharacter:()=>o-u,getTokenError:()=>p}}function ct(e){return e===32||e===9}function Ee(e){return e===10||e===13}function he(e){return e>=48&&e<=57}var Zt;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab"})(Zt||(Zt={}));var N=new Array(20).fill(0).map((e,t)=>" ".repeat(t)),ge=200,lt={" ":{"\n":new Array(ge).fill(0).map((e,t)=>`
|
|
142
|
+
`+" ".repeat(t)),"\r":new Array(ge).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(ge).fill(0).map((e,t)=>`\r
|
|
143
|
+
`+" ".repeat(t))}," ":{"\n":new Array(ge).fill(0).map((e,t)=>`
|
|
144
|
+
`+" ".repeat(t)),"\r":new Array(ge).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(ge).fill(0).map((e,t)=>`\r
|
|
145
|
+
`+" ".repeat(t))}},Yt=[`
|
|
146
146
|
`,"\r",`\r
|
|
147
|
-
`];function
|
|
147
|
+
`];function ut(e,t,s){let n,i,o,r,c;if(t){for(r=t.offset,c=r+t.length,o=r;o>0&&!Ae(e,o-1);)o--;let y=c;for(;y<e.length&&!Ae(e,y);)y++;i=e.substring(o,y),n=Ds(i,s)}else i=e,n=0,o=0,r=0,c=e.length;let a=Cs(s,e),l=Yt.includes(a),u=0,p=0,f;s.insertSpaces?f=N[s.tabSize||4]??me(N[1],s.tabSize||4):f=" ";let d=f===" "?" ":" ",g=Te(i,!1),b=!1;function k(){if(u>1)return me(a,u)+me(f,n+p);let y=f.length*(n+p);return!l||y>lt[d][a].length?a+me(f,n+p):y<=0?a:lt[d][a][y]}function E(){let y=g.scan();for(u=0;y===15||y===14;)y===14&&s.keepLines?u+=1:y===14&&(u=1),y=g.scan();return b=y===16||g.getTokenError()!==0,y}let T=[];function m(y,v,h){!b&&(!t||v<c&&h>r)&&e.substring(v,h)!==y&&T.push({offset:v,length:h-v,content:y})}let w=E();if(s.keepLines&&u>0&&m(me(a,u),0,0),w!==17){let y=g.getTokenOffset()+o,v=f.length*n<20&&s.insertSpaces?N[f.length*n]:me(f,n);m(v,o,y)}for(;w!==17;){let y=g.getTokenOffset()+g.getTokenLength()+o,v=E(),h="",R=!1;for(;u===0&&(v===12||v===13);){let L=g.getTokenOffset()+o;m(N[1],y,L),y=g.getTokenOffset()+g.getTokenLength()+o,R=v===12,h=R?k():"",v=E()}if(v===2)w!==1&&p--,s.keepLines&&u>0||!s.keepLines&&w!==1?h=k():s.keepLines&&(h=N[1]);else if(v===4)w!==3&&p--,s.keepLines&&u>0||!s.keepLines&&w!==3?h=k():s.keepLines&&(h=N[1]);else{switch(w){case 3:case 1:p++,s.keepLines&&u>0||!s.keepLines?h=k():h=N[1];break;case 5:s.keepLines&&u>0||!s.keepLines?h=k():h=N[1];break;case 12:h=k();break;case 13:u>0?h=k():R||(h=N[1]);break;case 6:s.keepLines&&u>0?h=k():R||(h=N[1]);break;case 10:s.keepLines&&u>0?h=k():v===6&&!R&&(h="");break;case 7:case 8:case 9:case 11:case 2:case 4:s.keepLines&&u>0?h=k():(v===12||v===13)&&!R?h=N[1]:v!==5&&v!==17&&(b=!0);break;case 16:b=!0;break}u>0&&(v===12||v===13)&&(h=k())}v===17&&(s.keepLines&&u>0?h=k():h=s.insertFinalNewline?a:"");let I=g.getTokenOffset()+o;m(h,y,I),w=v}return T}function me(e,t){let s="";for(let n=0;n<t;n++)s+=e;return s}function Ds(e,t){let s=0,n=0,i=t.tabSize||4;for(;s<e.length;){let o=e.charAt(s);if(o===N[1])n++;else if(o===" ")n+=i;else break;s++}return Math.floor(n/i)}function Cs(e,t){for(let s=0;s<t.length;s++){let n=t.charAt(s);if(n==="\r")return s+1<t.length&&t.charAt(s+1)===`
|
|
148
148
|
`?`\r
|
|
149
149
|
`:"\r";if(n===`
|
|
150
150
|
`)return`
|
|
151
151
|
`}return e&&e.eol||`
|
|
152
|
-
`}function
|
|
153
|
-
`.indexOf(e.charAt(t))!==-1}var Te;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Te||(Te={}));function Yt(e,t=[],s=Te.DEFAULT){let n=null,i=[],o=[];function r(a){Array.isArray(i)?i.push(a):n!==null&&(i[n]=a)}return pt(e,{onObjectBegin:()=>{let a={};r(a),o.push(i),i=a,n=null},onObjectProperty:a=>{n=a},onObjectEnd:()=>{i=o.pop()},onArrayBegin:()=>{let a=[];r(a),o.push(i),i=a,n=null},onArrayEnd:()=>{i=o.pop()},onLiteralValue:r,onError:(a,l,p)=>{t.push({error:a,offset:l,length:p})}},s),i[0]}function We(e,t=[],s=Te.DEFAULT){let n={type:"array",offset:-1,length:-1,children:[],parent:void 0};function i(a){n.type==="property"&&(n.length=a-n.offset,n=n.parent)}function o(a){return n.children.push(a),a}pt(e,{onObjectBegin:a=>{n=o({type:"object",offset:a,length:-1,parent:n,children:[]})},onObjectProperty:(a,l,p)=>{n=o({type:"property",offset:l,length:-1,parent:n,children:[]}),n.children.push({type:"string",value:a,offset:l,length:p,parent:n})},onObjectEnd:(a,l)=>{i(a+l),n.length=a+l-n.offset,n=n.parent,i(a+l)},onArrayBegin:(a,l)=>{n=o({type:"array",offset:a,length:-1,parent:n,children:[]})},onArrayEnd:(a,l)=>{n.length=a+l-n.offset,n=n.parent,i(a+l)},onLiteralValue:(a,l,p)=>{o({type:Cs(a),offset:l,length:p,parent:n,value:a}),i(l+p)},onSeparator:(a,l,p)=>{n.type==="property"&&(a===":"?n.colonOffset=l:a===","&&i(l))},onError:(a,l,p)=>{t.push({error:a,offset:l,length:p})}},s);let c=n.children[0];return c&&delete c.parent,c}function Ae(e,t){if(!e)return;let s=e;for(let n of t)if(typeof n=="string"){if(s.type!=="object"||!Array.isArray(s.children))return;let i=!1;for(let o of s.children)if(Array.isArray(o.children)&&o.children[0].value===n&&o.children.length===2){s=o.children[1],i=!0;break}if(!i)return}else{let i=n;if(s.type!=="array"||i<0||!Array.isArray(s.children)||i>=s.children.length)return;s=s.children[i]}return s}function pt(e,t,s=Te.DEFAULT){let n=Se(e,!1),i=[],o=0;function r(x){return x?()=>o===0&&x(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function c(x){return x?$=>o===0&&x($,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function a(x){return x?$=>o===0&&x($,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}function l(x){return x?()=>{o>0?o++:x(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice())===!1&&(o=1)}:()=>!0}function p(x){return x?()=>{o>0&&o--,o===0&&x(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}let u=l(t.onObjectBegin),f=a(t.onObjectProperty),d=p(t.onObjectEnd),g=l(t.onArrayBegin),b=p(t.onArrayEnd),k=a(t.onLiteralValue),E=c(t.onSeparator),T=r(t.onComment),m=c(t.onError),w=s&&s.disallowComments,y=s&&s.allowTrailingComma;function v(){for(;;){let x=n.scan();switch(n.getTokenError()){case 4:h(14);break;case 5:h(15);break;case 3:h(13);break;case 1:w||h(11);break;case 2:h(12);break;case 6:h(16);break}switch(x){case 12:case 13:w?h(10):T();break;case 16:h(1);break;case 15:case 14:break;default:return x}}}function h(x,$=[],bt=[]){if(m(x),$.length+bt.length>0){let Me=n.getToken();for(;Me!==17;){if($.indexOf(Me)!==-1){v();break}else if(bt.indexOf(Me)!==-1)break;Me=v()}}}function R(x){let $=n.getTokenValue();return x?k($):(f($),i.push($)),v(),!0}function P(){switch(n.getToken()){case 11:let x=n.getTokenValue(),$=Number(x);isNaN($)&&(h(2),$=0),k($);break;case 7:k(null);break;case 8:k(!0);break;case 9:k(!1);break;default:return!1}return v(),!0}function N(){return n.getToken()!==10?(h(3,[],[2,5]),!1):(R(!1),n.getToken()===6?(E(":"),v(),z()||h(4,[],[2,5])):h(5,[],[2,5]),i.pop(),!0)}function _(){u(),v();let x=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(x||h(4,[],[]),E(","),v(),n.getToken()===2&&y)break}else x&&h(6,[],[]);N()||h(4,[],[2,5]),x=!0}return d(),n.getToken()!==2?h(7,[2],[]):v(),!0}function V(){g(),v();let x=!0,$=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if($||h(4,[],[]),E(","),v(),n.getToken()===4&&y)break}else $&&h(6,[],[]);x?(i.push(0),x=!1):i[i.length-1]++,z()||h(4,[],[4,5]),$=!0}return b(),x||i.pop(),n.getToken()!==4?h(8,[4],[]):v(),!0}function z(){switch(n.getToken()){case 3:return V();case 1:return _();case 10:return R(!0);default:return P()}}return v(),n.getToken()===17?s.allowEmptyContent?!0:(h(4,[],[]),!1):z()?(n.getToken()!==17&&h(9,[],[]),!0):(h(4,[],[]),!1)}function Cs(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(e){if(Array.isArray(e))return"array"}else return"null";return"object"}default:return"null"}}function Kt(e,t,s,n){let i=t.slice(),r=We(e,[]),c,a;for(;i.length>0&&(a=i.pop(),c=Ae(r,i),c===void 0&&s!==void 0);)typeof a=="string"?s={[a]:s}:s=[s];if(c)if(c.type==="object"&&typeof a=="string"&&Array.isArray(c.children)){let l=Ae(c,[a]);if(l!==void 0)if(s===void 0){if(!l.parent)throw new Error("Malformed AST");let p=c.children.indexOf(l.parent),u,f=l.parent.offset+l.parent.length;if(p>0){let d=c.children[p-1];u=d.offset+d.length}else u=c.offset+1,c.children.length>1&&(f=c.children[1].offset);return te(e,{offset:u,length:f-u,content:""},n)}else return te(e,{offset:l.offset,length:l.length,content:JSON.stringify(s)},n);else{if(s===void 0)return[];let p=`${JSON.stringify(a)}: ${JSON.stringify(s)}`,u=n.getInsertionIndex?n.getInsertionIndex(c.children.map(d=>d.children[0].value)):c.children.length,f;if(u>0){let d=c.children[u-1];f={offset:d.offset+d.length,length:0,content:","+p}}else c.children.length===0?f={offset:c.offset+1,length:0,content:p}:f={offset:c.offset+1,length:0,content:p+","};return te(e,f,n)}}else if(c.type==="array"&&typeof a=="number"&&Array.isArray(c.children)){let l=a;if(l===-1){let p=`${JSON.stringify(s)}`,u;if(c.children.length===0)u={offset:c.offset+1,length:0,content:p};else{let f=c.children[c.children.length-1];u={offset:f.offset+f.length,length:0,content:","+p}}return te(e,u,n)}else if(s===void 0&&c.children.length>=0){let p=a,u=c.children[p],f;if(c.children.length===1)f={offset:c.offset+1,length:c.length-2,content:""};else if(c.children.length-1===p){let d=c.children[p-1],g=d.offset+d.length,b=c.offset+c.length;f={offset:g,length:b-2-g,content:""}}else f={offset:u.offset,length:c.children[p+1].offset-u.offset,content:""};return te(e,f,n)}else if(s!==void 0){let p,u=`${JSON.stringify(s)}`;if(!n.isArrayInsertion&&c.children.length>a){let f=c.children[a];p={offset:f.offset,length:f.length,content:u}}else if(c.children.length===0||a===0)p={offset:c.offset+1,length:0,content:c.children.length===0?u:u+","};else{let f=a>c.children.length?c.children.length:a,d=c.children[f-1];p={offset:d.offset+d.length,length:0,content:","+u}}return te(e,p,n)}else throw new Error(`Can not ${s===void 0?"remove":n.isArrayInsertion?"insert":"modify"} Array index ${l} as length is not sufficient`)}else throw new Error(`Can not add ${typeof a!="number"?"index":"property"} to parent of type ${c.type}`);else{if(s===void 0)throw new Error("Can not delete in empty document");return te(e,{offset:r?r.offset:0,length:r?r.length:0,content:JSON.stringify(s)},n)}}function te(e,t,s){if(!s.formattingOptions)return[t];let n=ut(e,t),i=t.offset,o=t.offset+t.content.length;if(t.length===0||t.content.length===0){for(;i>0&&!Ee(n,i-1);)i--;for(;o<n.length&&!Ee(n,o);)o++}let r=lt(n,{offset:i,length:o-i},{...s.formattingOptions,keepLines:!1});for(let a=r.length-1;a>=0;a--){let l=r[a];n=ut(n,l),i=Math.min(i,l.offset),o=Math.max(o,l.offset+l.length),o+=l.content.length-l.length}let c=e.length-(n.length-o)-i;return[{offset:i,length:c,content:n.substring(i,o)}]}function ut(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}var en;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(en||(en={}));var tn;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(tn||(tn={}));var ft=Yt,sn=We,Ve=Ae;var nn;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(nn||(nn={}));function on(e,t,s,n){return Kt(e,t,s,n)}async function an(e,t){let s=dt.join(e,j);if(!ht.existsSync(s))return;let n=await O.workspace.openTextDocument(O.Uri.file(s)),i=await O.window.showTextDocument(n),o=n.getText(),r=sn(o);if(!r)return;let c=-1,a=Ve(r,["rules","module-boundaries","rules"]);if(a&&a.children)if(typeof t=="string"&&!t.startsWith("rule[")){for(let l of a.children){let p=Ve(l,["name"]);if(p&&p.value===t){c=l.offset;break}}if(c===-1)for(let l of a.children){let p=Ve(l,["importer"]);if(p&&p.value===t){c=p.offset;break}}}else{let l=String(t).match(/rule\[(\d+)\]/),p=l?parseInt(l[1]):-1;p!==-1&&a.children[p]&&(c=a.children[p].offset)}if(c!==-1){let l=n.positionAt(c);i.selection=new O.Selection(l,l),i.revealRange(new O.Range(l,l),O.TextEditorRevealType.InCenter)}}async function cn(e,t,s){let n=dt.join(e,j);if(!ht.existsSync(n))return;let i=await O.workspace.openTextDocument(O.Uri.file(n)),o=i.getText(),r=on(o,["rules","module-boundaries","rules",-1],{importer:t,imports:s,allow:!0,name:`allow-${t}-to-${s}`},{formattingOptions:{insertSpaces:!0,tabSize:2}}),c=new O.WorkspaceEdit;for(let a of r)c.replace(i.uri,new O.Range(i.positionAt(a.offset),i.positionAt(a.offset+a.length)),a.content);await O.workspace.applyEdit(c),await i.save(),O.window.showInformationMessage(`Added exception: Allow '${s}' in '${t}'`)}function ln(e,t,s,n){e.subscriptions.push(B.commands.registerCommand("pickety.refresh",()=>{t.reload(),t.reloadAliases(),B.window.showInformationMessage("Pickety: Configuration refreshed")})),e.subscriptions.push(B.commands.registerCommand("pickety.generateDiagram",()=>Gt(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(B.commands.registerCommand("pickety.showImpact",()=>Xt(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(B.commands.registerCommand("pickety.showHealth",()=>qt(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(B.commands.registerCommand("pickety.goToRule",(i,o)=>an(i,o))),e.subscriptions.push(B.commands.registerCommand("pickety.allowImport",(i,o,r)=>cn(i,o,r))),e.subscriptions.push(B.commands.registerCommand("pickety.init",()=>Ft(n,()=>t.reload())))}var X=S(require("vscode"));var Be=S(require("path")),he=S(require("fs"));function pn(e){let t=Be.join(e,j);if(!he.existsSync(t))return{ok:!1,errors:[{message:`File not found: ${j}`}]};try{let s=he.readFileSync(t,"utf-8"),n;try{n=ft(s)}catch(i){return{ok:!1,errors:[{message:`pickety.json is not valid JSONC: ${i instanceof Error?i.message:String(i)}`}]}}return _s(n)}catch(s){return{ok:!1,errors:[{message:`Failed to read pickety.json: ${s instanceof Error?s.message:String(s)}`}]}}}function _s(e){let t=[];if(typeof e!="object"||e===null)return{ok:!1,errors:[{message:"Configuration must be a JSON object"}]};let s=e,n=Ws(s.modules,t),i=Vs(s.rules,t),o=Bs(s["boundary-diagrams"],t),r=Hs(s.health,t);return t.length>0||!n||!i?{ok:!1,errors:t}:{ok:!0,config:{modules:n,rules:{"module-boundaries":i},"boundary-diagrams":o,health:r}}}function Ws(e,t){if(e===void 0){t.push({message:'"modules" is required and must be an object',path:"modules"});return}if(typeof e!="object"||e===null){t.push({message:'"modules" must be an object mapping module names to patterns',path:"modules"});return}let s={};for(let[n,i]of Object.entries(e))typeof i!="string"?t.push({message:`Module "${n}" pattern must be a string, got ${typeof i}`,path:`modules.${n}`}):s[n]=i;return s}function Vs(e,t){if(e===void 0){t.push({message:'"rules" is required and must be an object',path:"rules"});return}if(typeof e!="object"||e===null){t.push({message:'"rules" must be an object',path:"rules"});return}let n=e["module-boundaries"];if(n===void 0){t.push({message:'"rules.module-boundaries" is required and must be an object',path:"rules.module-boundaries"});return}if(typeof n!="object"||n===null){t.push({message:'"rules.module-boundaries" must be an object',path:"rules.module-boundaries"});return}let i=n,o="error";if(i.severity!==void 0&&(i.severity!=="error"&&i.severity!=="warn"?t.push({message:`"rules.module-boundaries.severity" must be "error" or "warn", got "${i.severity}"`,path:"rules.module-boundaries.severity"}):o=i.severity),i.rules===void 0){t.push({message:'"rules.module-boundaries.rules" is required and must be an array',path:"rules.module-boundaries.rules"});return}if(!Array.isArray(i.rules)){t.push({message:'"rules.module-boundaries.rules" must be an array',path:"rules.module-boundaries.rules"});return}let r=[];return i.rules.forEach((c,a)=>{let l=`rules.module-boundaries.rules[${a}]`;if(typeof c!="object"||c===null){t.push({message:`Rule #${a} must be an object`,path:l});return}let p=c;typeof p.importer!="string"&&typeof p.containedTo!="string"&&t.push({message:`Rule #${a}: "importer" or "containedTo" is required`,path:l}),p.importer!==void 0&&typeof p.importer!="string"&&t.push({message:`Rule #${a}: "importer" must be a string`,path:`${l}.importer`}),typeof p.imports!="string"&&t.push({message:`Rule #${a}: "imports" is required and must be a string`,path:`${l}.imports`}),p.allow!==void 0&&typeof p.allow!="boolean"&&t.push({message:`Rule #${a}: "allow" must be a boolean`,path:`${l}.allow`}),p.only!==void 0&&typeof p.only!="boolean"&&t.push({message:`Rule #${a}: "only" must be a boolean`,path:`${l}.only`}),p.containedTo!==void 0&&typeof p.containedTo!="string"&&t.push({message:`Rule #${a}: "containedTo" must be a string`,path:`${l}.containedTo`}),p.message!==void 0&&typeof p.message!="string"&&t.push({message:`Rule #${a}: "message" must be a string`,path:`${l}.message`}),p.severity!==void 0&&p.severity!=="error"&&p.severity!=="warn"&&t.push({message:`Rule #${a}: "severity" must be "error" or "warn", got "${p.severity}"`,path:`${l}.severity`}),p.name!==void 0&&typeof p.name!="string"&&t.push({message:`Rule #${a}: "name" must be a string`,path:`${l}.name`}),p.maxViolations!==void 0&&(typeof p.maxViolations!="number"||!Number.isInteger(p.maxViolations)||p.maxViolations<0)&&t.push({message:`Rule #${a}: "maxViolations" must be a non-negative integer`,path:`${l}.maxViolations`}),r.push(p)}),{severity:o,rules:r}}function Bs(e,t){if(e!==void 0){if(typeof e!="boolean"&&typeof e!="string"){t.push({message:'"boundary-diagrams" must be a boolean or a string',path:"boundary-diagrams"});return}return e}}function Hs(e,t){if(e===void 0)return;if(typeof e!="object"||e===null){t.push({message:'"health" must be an object',path:"health"});return}let s=e,n={},i=[{key:"maxAfferentCoupling",label:"maxAfferentCoupling"},{key:"maxEfferentCoupling",label:"maxEfferentCoupling"},{key:"maxDepth",label:"maxDepth"}];for(let{key:o,label:r}of i){let c=s[o];c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<1?t.push({message:`"health.${r}" must be a positive integer`,path:`health.${r}`}):n[o]=c)}if(s.maxInstability!==void 0){let o=s.maxInstability;typeof o!="number"||o<0||o>1?t.push({message:'"health.maxInstability" must be a number between 0 and 1',path:"health.maxInstability"}):n.maxInstability=o}return Object.keys(n).length>0?n:void 0}function un(e){let t={},s=["tsconfig.json","tsconfig.app.json","tsconfig.web.json"],n;for(let i of s){let o=Be.join(e,i);if(he.existsSync(o)){n=o;break}}if(!n)return t;try{let i=he.readFileSync(n,"utf-8"),r=ft(i).compilerOptions;if(!r)return t;let c=r.baseUrl||".",a=r.paths;if(a){for(let[l,p]of Object.entries(a))if(Array.isArray(p)&&p.length>0){let u=p[0],f=M(Be.join(c,u));t[l]=f}}}catch{}return t}var He=class{constructor(t){this.workspaceRoot=t;this.registerWatchers()}config;aliases={};_onConfigChanged=new X.EventEmitter;onConfigChanged=this._onConfigChanged.event;_onAliasesChanged=new X.EventEmitter;onAliasesChanged=this._onAliasesChanged.event;disposables=[];getConfig(){return this.config}getAliases(){return this.aliases}reload(){let t=pn(this.workspaceRoot);this.config=t.ok?t.config:void 0,this._onConfigChanged.fire(t)}reloadAliases(){this.aliases=un(this.workspaceRoot),this._onAliasesChanged.fire(this.aliases)}registerWatchers(){let t=X.workspace.createFileSystemWatcher(new X.RelativePattern(this.workspaceRoot,j));this.disposables.push(t),t.onDidChange(()=>this.reload()),t.onDidCreate(()=>this.reload()),t.onDidDelete(()=>{this.config=void 0,this._onConfigChanged.fire({ok:!1,errors:[{message:"Configuration file deleted"}]})});let s=X.workspace.createFileSystemWatcher(new X.RelativePattern(this.workspaceRoot,"tsconfig*.json"));this.disposables.push(s),s.onDidChange(()=>this.reloadAliases()),s.onDidCreate(()=>this.reloadAliases()),s.onDidDelete(()=>this.reloadAliases())}dispose(){this.disposables.forEach(t=>t.dispose()),this._onConfigChanged.dispose(),this._onAliasesChanged.dispose()}};var Ue=S(require("vscode")),fn=S(require("fs"));function gt(e,t,s){let n=new Set,i=De(e,t,s),o=M(e);for(let{resolvedPath:r}of i)r&&r!==o&&n.add(r);return n}var Ge=class{dependents=new Map;dependencies=new Map;updateFile(t,s){let n=this.dependencies.get(t);if(n)for(let i of n)this.dependents.get(i)?.delete(t);this.dependencies.set(t,new Set(s));for(let i of s)this.dependents.has(i)||this.dependents.set(i,new Set),this.dependents.get(i).add(t)}removeFile(t){let s=this.dependencies.get(t);if(s)for(let i of s)this.dependents.get(i)?.delete(t);this.dependencies.delete(t);let n=this.dependents.get(t);if(n)for(let i of n)this.dependencies.get(i)?.delete(t);this.dependents.delete(t)}getDependents(t){return this.dependents.get(t)??new Set}getDependencies(t){return this.dependencies.get(t)??new Set}getTransitiveDependents(t){let s=new Set,n=[t];for(;n.length>0;){let i=n.shift(),o=this.dependents.get(i);if(o)for(let r of o)!s.has(r)&&r!==t&&(s.add(r),n.push(r))}return s}getModuleSummary(t,s,n){let i=this.getDependents(t),o=this.getDependencies(t),r=new Set;for(let a of i){let l=F(a,s,n);l&&r.add(l)}let c=new Set;for(let a of o){let l=F(a,s,n);l&&c.add(l)}return{dependentCount:i.size,dependentModules:[...r],dependencyCount:o.size,dependencyModules:[...c]}}getModuleLevelGraph(t,s){let n=new Map;for(let[i,o]of this.dependencies){let r=F(i,t,s);if(r){n.has(r)||n.set(r,new Set);for(let c of o){let a=F(c,t,s);a&&a!==r&&n.get(r).add(a)}}}return n}clear(){this.dependents.clear(),this.dependencies.clear()}};var ze=class e{constructor(t,s){this.workspaceRoot=t;this.configService=s;this.disposables.push(this.configService.onAliasesChanged(()=>{this.scanAndNotify()}))}knownFiles=new Set;importGraph=new Ge;isLargeWorkspace=!1;static MAX_FILES_THRESHOLD=5e3;_onAnalysisReady=new Ue.EventEmitter;onAnalysisReady=this._onAnalysisReady.event;disposables=[];dispose(){this.disposables.forEach(t=>t.dispose()),this._onAnalysisReady.dispose()}getImportGraph(){return this.importGraph}getKnownFiles(){return this.knownFiles}checkIsLargeWorkspace(){return this.isLargeWorkspace}getWorkspaceContext(){return{root:this.workspaceRoot,knownFiles:this.knownFiles,aliases:this.configService.getAliases()}}async scan(){let t=await Ue.workspace.findFiles(K,"**/node_modules/**");return this.knownFiles=new Set(t.map(s=>M(s.fsPath))),this.isLargeWorkspace=this.knownFiles.size>e.MAX_FILES_THRESHOLD,this.importGraph.clear(),this.isLargeWorkspace}async scanAndNotify(){await this.scan(),this._onAnalysisReady.fire()}updateFile(t,s,n){let i=M(t);this.knownFiles.add(i);try{let o=gt(i,s,n);this.importGraph.updateFile(i,o)}catch{}}removeFile(t){let s=M(t);this.knownFiles.delete(s),this.importGraph.removeFile(s)}ensureGraphReady(t){if(!this.isLargeWorkspace){for(let s of this.knownFiles)if(!this.importGraph.getDependencies(s).size)try{let n=fn.readFileSync(s,"utf-8"),i=gt(s,n,t);this.importGraph.updateFile(s,i)}catch{continue}}}computeCycles(t,s){if(this.isLargeWorkspace)return[];this.ensureGraphReady(s);let n=this.importGraph.getModuleLevelGraph(t.modules,this.workspaceRoot);return _t(n)}computeHealthViolations(t,s){if(!t.health||this.isLargeWorkspace)return[];this.ensureGraphReady(s);let n=ce(this.importGraph,t.modules,s);return Bt(n,t.health)}};var ne=S(require("vscode")),qe=class{item;constructor(t){this.item=ne.window.createStatusBarItem(ne.StatusBarAlignment.Right,100),this.item.command="pickety.refresh",t.subscriptions.push(this.item),this.item.show()}update(t,s){if(!t){this.item.text="$(warning) Pickety: No Config",this.item.tooltip="Pickety is inactive. Check pickety.json for errors.",this.item.backgroundColor=new ne.ThemeColor("statusBarItem.warningBackground");return}let n=0;s.forEach((i,o)=>{n+=o.filter(r=>r.source==="pickety").length}),n>0?(this.item.text=`$(shield) Pickety: ${n} issue(s)`,this.item.tooltip=`Found ${n} architectural violations. Click to refresh.`,this.item.backgroundColor=new ne.ThemeColor("statusBarItem.errorBackground")):(this.item.text="$(check) Pickety",this.item.tooltip="Architectural boundaries are secure. Click to refresh.",this.item.backgroundColor=void 0)}dispose(){this.item.dispose()}};var mt=S(require("vscode")),ge=class e{static instance;outputChannel;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}setOutputChannel(t){this.outputChannel=t}logEvent(t,s){if(!mt.env.isTelemetryEnabled)return;let n=new Date().toISOString(),i=JSON.stringify({event:t,timestamp:n,...s});this.outputChannel&&this.outputChannel.appendLine(`[Telemetry] ${i}`)}logError(t,s){if(!mt.env.isTelemetryEnabled)return;let n=t instanceof Error?t.message:t,i=t instanceof Error?t.stack:void 0;this.logEvent("error",{message:n,context:s||"unknown",stack:i||"no stack trace"})}};var L=S(require("vscode"));var Je=class e{constructor(t){this.collection=t}static CIRCULAR_TAG="pickety/circular";static HEALTH_TAG="pickety/health";getCollection(){return this.collection}setViolations(t,s){let n=s.map(i=>{let o=new L.Range(i.line,i.character,i.line,i.character+i.length),r=i.severity==="error"?L.DiagnosticSeverity.Error:L.DiagnosticSeverity.Warning,c=new L.Diagnostic(o,i.message,r);return c.source="pickety",i.ruleName&&(c.code={value:i.ruleName,target:L.Uri.parse(`https://github.com/DanielSerio/pickety/blob/main/docs/rules.md#${i.ruleName}`)}),c._picketyMetadata={sourceModule:i.sourceModule,targetModule:i.targetModule},c});this.collection.set(t,n)}setCircularDiagnostics(t,s){let n=s.map(i=>{let o=i.join(" -> "),r=new L.Diagnostic(new L.Range(0,0,0,100),`Circular dependency detected: ${o}`,L.DiagnosticSeverity.Error);return r.source="pickety",r.code=e.CIRCULAR_TAG,r});this.updateConfigDiagnostics(t,e.CIRCULAR_TAG,n)}setHealthDiagnostics(t,s){let n=s.map(i=>{let o=U(i.metric,i.value),r=U(i.metric,i.threshold),c=new L.Diagnostic(new L.Range(0,0,0,100),`Module "${i.moduleName}" has ${i.metric} of ${o} (max: ${r})`,L.DiagnosticSeverity.Warning);return c.source="pickety",c.code=e.HEALTH_TAG,c});this.updateConfigDiagnostics(t,e.HEALTH_TAG,n)}updateConfigDiagnostics(t,s,n){let i=(this.collection.get(t)||[]).filter(o=>(typeof o.code=="object"?o.code?.value:o.code)!==s);this.collection.set(t,[...i,...n])}clear(){this.collection.clear()}delete(t){this.collection.delete(t)}dispose(){this.collection.dispose()}};var Y=S(require("vscode"));var yt=S(require("path"));function hn(e,t,s,n){let i=[],{modules:o}=s,{severity:r,rules:c}=s.rules["module-boundaries"],{knownFiles:a,root:l,aliases:p}=n,u=F(e,o,l);if(!u)return[];let f=M(yt.relative(l,e)),d=De(e,t,n);for(let{statement:g,resolvedPath:b}of d){let k=F(b,o,l);if(!k)continue;let E=M(yt.relative(l,b));c.forEach((T,m)=>{let{allow:w,severity:y,name:v,effectiveImporter:h,isOnly:R}=Ie(T,m,r),P=Gs(R?T.imports:h);if(P.length>0)if(R){let N=dn(T.imports,E,P);if(N){let _=Xe(h,P,N);if(!me(u,f,_)){let z=T.message||`Module "${u}" is not allowed to import from "${k}" (contained to "${_}")`;i.push(ae(e,g,v,z,y,u,k))}}}else{let N=dn(h,f,P);if(!N)return;if(w){let _=Xe(T.imports,P,"*"),V=Xe(T.imports,P,N),z=me(k,E,_),x=me(k,E,V);if(z&&!x){let $=T.message||`Import must match scoped pattern "${V}"`;i.push(ae(e,g,v,$,y,u,k))}}else{let _=Xe(T.imports,P,N);if(me(k,E,_)){let z=T.message||`Module "${u}" cannot import from "${k}"`;i.push(ae(e,g,v,z,y))}}}else{let N=me(u,f,h),_=me(k,E,T.imports);if(R){if(_&&!N){let V=T.message||(T.containedTo?`Import is restricted: "${k}" is contained to "${h}"`:`Module "${k}" can only be imported by "${h}"`);i.push(ae(e,g,v,V,y,u,k))}}else if(N&&_&&!w){let V=T.message||`Module "${u}" cannot import from "${k}"`;i.push(ae(e,g,v,V,y,u,k))}}})}return i}function me(e,t,s){return!!(it(e,s)||s.includes("/")&&(A(t,s)||A(t,`**/${s}`)||A(t,`**/${s}/**`)))}function Gs(e){return e.match(/\$[\w-]+/g)||[]}function dn(e,t,s){let n=e.split("/"),i=t.split("/"),o=0,r=i.length-n.length;for(let c=o;c<=r;c++){let a=gn(n,i,c,s);if(a)return a}}function gn(e,t,s,n){let i={},o=s;for(let r=0;r<e.length;r++){let c=e[r];if(c==="**"){let u=e.slice(r+1);if(u.length===0)return i;for(let f=o;f<=t.length-u.length;f++){let d=gn(u,t,f,n);if(d)return{...i,...d}}return}if(o>=t.length)return;let a=c,l=[];for(let u of n)a.includes(u)&&(a=a.replace(u,`__VAR_${l.length}__`),l.push(u));a=a.replace(/[.+?^{}()|[\]\\]/g,"\\$&"),a=a.replace(/\*/g,"[^/]*");for(let u=0;u<l.length;u++)a=a.replace(`__VAR_${u}__`,"([^/]+)");let p=t[o].match(new RegExp(`^${a}$`));if(!p)return;for(let u=0;u<l.length;u++)i[l[u]]=p[u+1];o++}return i}function mn(e,t){let s=t.rules["module-boundaries"].rules,n=new Map;if(s.forEach((o,r)=>{if(o.maxViolations!==void 0){let c=o.name??`rule[${r}]`;n.set(c,o.maxViolations)}}),n.size===0)return e;let i=new Map;for(let o of e)o.ruleName&&n.has(o.ruleName)&&i.set(o.ruleName,(i.get(o.ruleName)??0)+1);return e.map(o=>{if(!o.ruleName||!n.has(o.ruleName))return o;let r=i.get(o.ruleName)??0,c=n.get(o.ruleName),a=r<=c?"warn":"error";return a===o.severity?o:{...o,severity:a}})}function Xe(e,t,s){let n=e;for(let i of t){let o=typeof s=="string"?s:s[i],r=i.replace(/\$/g,"\\$");n=n.replace(new RegExp(r,"g"),o)}return n}var H=S(require("vscode")),yn=S(require("path"));function bn(e,t,s,n){s.appendLine("Pickety: Configuration error(s) found:");let i=H.Uri.file(yn.join(t,j)),o=e.map(r=>{s.appendLine(` - ${r.message}${r.path?` (at ${r.path})`:""}`);let c=new H.Range(0,0,0,100),a=new H.Diagnostic(c,r.message,H.DiagnosticSeverity.Error);return a.source="pickety",r.path&&(a.code=r.path),a});n.set(i,o),H.window.showErrorMessage("Pickety: Configuration error. Check the Problems panel or Output channel for details.")}var Qe=class{constructor(t,s,n,i,o,r,c){this.context=t;this.configService=s;this.analysisService=n;this.diagnosticManager=i;this.statusBar=o;this.outputChannel=r;this.workspaceRoot=c;this.registerEventListeners()}analysisTimeout;telemetry=ge.getInstance();disposables=[];codeLensProvider;configRef={config:void 0};setCodeLensProvider(t){this.codeLensProvider=t}handleConfigResult(t){this.diagnosticManager.clear();let s=t.ok?t.config:void 0;if(this.configRef.config=s,t.ok&&t.config){this.outputChannel.appendLine("Pickety: Import boundaries active");try{let n=Ce(t.config,this.workspaceRoot);n&&this.outputChannel.appendLine(`Pickety: Generated boundary diagram at ${n}`)}catch(n){this.outputChannel.appendLine(`Pickety: Failed to generate boundary diagram: ${n instanceof Error?n.message:String(n)}`)}this.analyzeOpenEditors()}else t.ok||bn(t.errors,this.workspaceRoot,this.outputChannel,this.diagnosticManager.getCollection());this.statusBar.update(s,this.diagnosticManager.getCollection())}analyzeOpenEditors(){try{let t=this.configService.getConfig();if(!t)return;let s=[];for(let r of Y.workspace.textDocuments)this.isSourceFile(r)&&s.push({uri:r.uri,violations:this.checkDocument(r,t)});let n=s.flatMap(r=>r.violations),i=mn(n,t),o=0;for(let r of s){let c=r.violations.length;this.diagnosticManager.setViolations(r.uri,i.slice(o,o+c)),o+=c}this.statusBar.update(t,this.diagnosticManager.getCollection()),setTimeout(()=>{this.checkCircularDependencies(t),this.checkHealthThresholds(t)},0)}catch(t){this.telemetry.logError(t instanceof Error?t:String(t),"analyzeOpenEditors")}}analyzeDocument(t){let s=this.configService.getConfig();if(!s||!this.isSourceFile(t))return;if(this.hasMaxViolationsRules(s)){this.analyzeOpenEditors();return}let n=this.checkDocument(t,s);this.diagnosticManager.setViolations(t.uri,n),this.statusBar.update(s,this.diagnosticManager.getCollection())}checkDocument(t,s){return hn(t.uri.fsPath,t.getText(),s,this.analysisService.getWorkspaceContext())}hasMaxViolationsRules(t){return t.rules["module-boundaries"].rules.some(s=>s.maxViolations!==void 0)}checkCircularDependencies(t){let s=this.analysisService.computeCycles(t,this.analysisService.getWorkspaceContext()),n=Y.Uri.file(oe(this.workspaceRoot));this.diagnosticManager.setCircularDiagnostics(n,s)}checkHealthThresholds(t){let s=this.analysisService.computeHealthViolations(t,this.analysisService.getWorkspaceContext()),n=Y.Uri.file(oe(this.workspaceRoot));this.diagnosticManager.setHealthDiagnostics(n,s)}registerEventListeners(){this.disposables.push(Y.workspace.onDidChangeTextDocument(s=>{this.isSourceFile(s.document)&&(this.diagnosticManager.delete(s.document.uri),this.analysisTimeout&&clearTimeout(this.analysisTimeout),this.analysisTimeout=setTimeout(()=>{this.analysisService.updateFile(s.document.uri.fsPath,s.document.getText(),this.analysisService.getWorkspaceContext()),this.analyzeDocument(s.document),this.codeLensProvider?.refresh()},300))})),this.disposables.push(Y.workspace.onDidOpenTextDocument(s=>this.analyzeDocument(s)));let t=Y.workspace.createFileSystemWatcher(K);this.disposables.push(t),t.onDidCreate(s=>{this.analysisService.getKnownFiles().add(M(s.fsPath))}),t.onDidDelete(s=>{this.analysisService.removeFile(s.fsPath),this.codeLensProvider?.refresh()})}isSourceFile(t){return["typescript","typescriptreact","javascript","javascriptreact"].includes(t.languageId)}dispose(){this.analysisTimeout&&clearTimeout(this.analysisTimeout),this.disposables.forEach(t=>t.dispose())}};var ye=S(require("vscode")),Ze=class{constructor(t){this.workspaceRoot=t}provideCodeActions(t,s,n){let i=[];for(let o of n.diagnostics)if(o.source==="pickety"&&o.code){let r=typeof o.code=="object"?o.code.value:o.code,c=new ye.CodeAction(`Go to Pickety rule: ${r}`,ye.CodeActionKind.QuickFix);c.command={command:"pickety.goToRule",title:"Go to Rule",arguments:[this.workspaceRoot,r]},i.push(c);let a=o._picketyMetadata;if(a&&a.sourceModule&&a.targetModule){let l=new ye.CodeAction(`Allow imports from '${a.targetModule}' in '${a.sourceModule}'`,ye.CodeActionKind.QuickFix);l.command={command:"pickety.allowImport",title:"Allow Import",arguments:[this.workspaceRoot,a.sourceModule,a.targetModule]},i.push(l)}}return i}};var be=S(require("vscode"));var Ye=class{constructor(t,s,n){this.importGraph=t;this.workspaceRoot=s;this.configRef=n}_onDidChangeCodeLenses=new be.EventEmitter;onDidChangeCodeLenses=this._onDidChangeCodeLenses.event;refresh(){this._onDidChangeCodeLenses.fire()}provideCodeLenses(t){let s=this.configRef.config;if(!s)return[];let n=M(t.uri.fsPath),i=this.importGraph.getModuleSummary(n,s.modules,this.workspaceRoot);if(i.dependentCount===0&&i.dependencyCount===0)return[];let o=[];if(i.dependentCount>0){let a=i.dependentModules.length===1?"1 module":`${i.dependentModules.length} modules`;o.push(`${i.dependentCount} dependent${i.dependentCount===1?"":"s"} (${a})`)}if(i.dependencyCount>0){let a=i.dependencyModules.length===1?"1 module":`${i.dependencyModules.length} modules`;o.push(`${i.dependencyCount} dependenc${i.dependencyCount===1?"y":"ies"} (${a})`)}let r=new be.Range(0,0,0,0);return[new be.CodeLens(r,{title:o.join(" | "),command:"pickety.showImpact",tooltip:"Show full impact analysis for this file"})]}dispose(){this._onDidChangeCodeLenses.dispose()}};var zs=[];async function Us(e){let t=ge.getInstance();t.logEvent("extension_activate");let s=G.window.createOutputChannel("Pickety");e.subscriptions.push(s),t.setOutputChannel(s);let n=G.workspace.workspaceFolders?.[0]?.uri.fsPath;if(!n){s.appendLine("Pickety: No workspace root found.");return}s.appendLine(`Pickety: Extension activated for workspace: ${n}`);let i=new He(n);e.subscriptions.push(i);let o=new ze(n,i);e.subscriptions.push(o);let r=new qe(e);e.subscriptions.push(r);let c=G.languages.createDiagnosticCollection("pickety");e.subscriptions.push(c);let a=new Je(c);e.subscriptions.push(a);let l=new Ze(n);e.subscriptions.push(G.languages.registerCodeActionsProvider({scheme:"file",language:"*"},l,{providedCodeActionKinds:[G.CodeActionKind.QuickFix]}));let p=new Ye(o.getImportGraph(),n,{config:void 0});e.subscriptions.push(p);let u=new Qe(e,i,o,a,r,s,n);u.setCodeLensProvider(p),e.subscriptions.push(u),p.configRef=u.configRef,e.subscriptions.push(G.languages.registerCodeLensProvider({scheme:"file",pattern:K},p)),ln(e,i,o,n),i.onConfigChanged(f=>u.handleConfigResult(f)),o.onAnalysisReady(()=>{s.appendLine(`Pickety: Analysis complete. Found ${o.getKnownFiles().size} files.`),u.analyzeOpenEditors()}),i.reload(),i.reloadAliases()}function qs(){zs.forEach(e=>e.dispose())}0&&(module.exports={activate,deactivate});
|
|
152
|
+
`}function Ae(e,t){return`\r
|
|
153
|
+
`.indexOf(e.charAt(t))!==-1}var Me;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Me||(Me={}));function Kt(e,t=[],s=Me.DEFAULT){let n=null,i=[],o=[];function r(a){Array.isArray(i)?i.push(a):n!==null&&(i[n]=a)}return pt(e,{onObjectBegin:()=>{let a={};r(a),o.push(i),i=a,n=null},onObjectProperty:a=>{n=a},onObjectEnd:()=>{i=o.pop()},onArrayBegin:()=>{let a=[];r(a),o.push(i),i=a,n=null},onArrayEnd:()=>{i=o.pop()},onLiteralValue:r,onError:(a,l,u)=>{t.push({error:a,offset:l,length:u})}},s),i[0]}function Be(e,t=[],s=Me.DEFAULT){let n={type:"array",offset:-1,length:-1,children:[],parent:void 0};function i(a){n.type==="property"&&(n.length=a-n.offset,n=n.parent)}function o(a){return n.children.push(a),a}pt(e,{onObjectBegin:a=>{n=o({type:"object",offset:a,length:-1,parent:n,children:[]})},onObjectProperty:(a,l,u)=>{n=o({type:"property",offset:l,length:-1,parent:n,children:[]}),n.children.push({type:"string",value:a,offset:l,length:u,parent:n})},onObjectEnd:(a,l)=>{i(a+l),n.length=a+l-n.offset,n=n.parent,i(a+l)},onArrayBegin:(a,l)=>{n=o({type:"array",offset:a,length:-1,parent:n,children:[]})},onArrayEnd:(a,l)=>{n.length=a+l-n.offset,n=n.parent,i(a+l)},onLiteralValue:(a,l,u)=>{o({type:Fs(a),offset:l,length:u,parent:n,value:a}),i(l+u)},onSeparator:(a,l,u)=>{n.type==="property"&&(a===":"?n.colonOffset=l:a===","&&i(l))},onError:(a,l,u)=>{t.push({error:a,offset:l,length:u})}},s);let c=n.children[0];return c&&delete c.parent,c}function $e(e,t){if(!e)return;let s=e;for(let n of t)if(typeof n=="string"){if(s.type!=="object"||!Array.isArray(s.children))return;let i=!1;for(let o of s.children)if(Array.isArray(o.children)&&o.children[0].value===n&&o.children.length===2){s=o.children[1],i=!0;break}if(!i)return}else{let i=n;if(s.type!=="array"||i<0||!Array.isArray(s.children)||i>=s.children.length)return;s=s.children[i]}return s}function pt(e,t,s=Me.DEFAULT){let n=Te(e,!1),i=[],o=0;function r(x){return x?()=>o===0&&x(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function c(x){return x?$=>o===0&&x($,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function a(x){return x?$=>o===0&&x($,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}function l(x){return x?()=>{o>0?o++:x(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice())===!1&&(o=1)}:()=>!0}function u(x){return x?()=>{o>0&&o--,o===0&&x(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}let p=l(t.onObjectBegin),f=a(t.onObjectProperty),d=u(t.onObjectEnd),g=l(t.onArrayBegin),b=u(t.onArrayEnd),k=a(t.onLiteralValue),E=c(t.onSeparator),T=r(t.onComment),m=c(t.onError),w=s&&s.disallowComments,y=s&&s.allowTrailingComma;function v(){for(;;){let x=n.scan();switch(n.getTokenError()){case 4:h(14);break;case 5:h(15);break;case 3:h(13);break;case 1:w||h(11);break;case 2:h(12);break;case 6:h(16);break}switch(x){case 12:case 13:w?h(10):T();break;case 16:h(1);break;case 15:case 14:break;default:return x}}}function h(x,$=[],vt=[]){if(m(x),$.length+vt.length>0){let Oe=n.getToken();for(;Oe!==17;){if($.indexOf(Oe)!==-1){v();break}else if(vt.indexOf(Oe)!==-1)break;Oe=v()}}}function R(x){let $=n.getTokenValue();return x?k($):(f($),i.push($)),v(),!0}function I(){switch(n.getToken()){case 11:let x=n.getTokenValue(),$=Number(x);isNaN($)&&(h(2),$=0),k($);break;case 7:k(null);break;case 8:k(!0);break;case 9:k(!1);break;default:return!1}return v(),!0}function L(){return n.getToken()!==10?(h(3,[],[2,5]),!1):(R(!1),n.getToken()===6?(E(":"),v(),z()||h(4,[],[2,5])):h(5,[],[2,5]),i.pop(),!0)}function _(){p(),v();let x=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(x||h(4,[],[]),E(","),v(),n.getToken()===2&&y)break}else x&&h(6,[],[]);L()||h(4,[],[2,5]),x=!0}return d(),n.getToken()!==2?h(7,[2],[]):v(),!0}function V(){g(),v();let x=!0,$=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if($||h(4,[],[]),E(","),v(),n.getToken()===4&&y)break}else $&&h(6,[],[]);x?(i.push(0),x=!1):i[i.length-1]++,z()||h(4,[],[4,5]),$=!0}return b(),x||i.pop(),n.getToken()!==4?h(8,[4],[]):v(),!0}function z(){switch(n.getToken()){case 3:return V();case 1:return _();case 10:return R(!0);default:return I()}}return v(),n.getToken()===17?s.allowEmptyContent?!0:(h(4,[],[]),!1):z()?(n.getToken()!==17&&h(9,[],[]),!0):(h(4,[],[]),!1)}function Fs(e){switch(typeof e){case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"object":{if(e){if(Array.isArray(e))return"array"}else return"null";return"object"}default:return"null"}}function en(e,t,s,n){let i=t.slice(),r=Be(e,[]),c,a;for(;i.length>0&&(a=i.pop(),c=$e(r,i),c===void 0&&s!==void 0);)typeof a=="string"?s={[a]:s}:s=[s];if(c)if(c.type==="object"&&typeof a=="string"&&Array.isArray(c.children)){let l=$e(c,[a]);if(l!==void 0)if(s===void 0){if(!l.parent)throw new Error("Malformed AST");let u=c.children.indexOf(l.parent),p,f=l.parent.offset+l.parent.length;if(u>0){let d=c.children[u-1];p=d.offset+d.length}else p=c.offset+1,c.children.length>1&&(f=c.children[1].offset);return ne(e,{offset:p,length:f-p,content:""},n)}else return ne(e,{offset:l.offset,length:l.length,content:JSON.stringify(s)},n);else{if(s===void 0)return[];let u=`${JSON.stringify(a)}: ${JSON.stringify(s)}`,p=n.getInsertionIndex?n.getInsertionIndex(c.children.map(d=>d.children[0].value)):c.children.length,f;if(p>0){let d=c.children[p-1];f={offset:d.offset+d.length,length:0,content:","+u}}else c.children.length===0?f={offset:c.offset+1,length:0,content:u}:f={offset:c.offset+1,length:0,content:u+","};return ne(e,f,n)}}else if(c.type==="array"&&typeof a=="number"&&Array.isArray(c.children)){let l=a;if(l===-1){let u=`${JSON.stringify(s)}`,p;if(c.children.length===0)p={offset:c.offset+1,length:0,content:u};else{let f=c.children[c.children.length-1];p={offset:f.offset+f.length,length:0,content:","+u}}return ne(e,p,n)}else if(s===void 0&&c.children.length>=0){let u=a,p=c.children[u],f;if(c.children.length===1)f={offset:c.offset+1,length:c.length-2,content:""};else if(c.children.length-1===u){let d=c.children[u-1],g=d.offset+d.length,b=c.offset+c.length;f={offset:g,length:b-2-g,content:""}}else f={offset:p.offset,length:c.children[u+1].offset-p.offset,content:""};return ne(e,f,n)}else if(s!==void 0){let u,p=`${JSON.stringify(s)}`;if(!n.isArrayInsertion&&c.children.length>a){let f=c.children[a];u={offset:f.offset,length:f.length,content:p}}else if(c.children.length===0||a===0)u={offset:c.offset+1,length:0,content:c.children.length===0?p:p+","};else{let f=a>c.children.length?c.children.length:a,d=c.children[f-1];u={offset:d.offset+d.length,length:0,content:","+p}}return ne(e,u,n)}else throw new Error(`Can not ${s===void 0?"remove":n.isArrayInsertion?"insert":"modify"} Array index ${l} as length is not sufficient`)}else throw new Error(`Can not add ${typeof a!="number"?"index":"property"} to parent of type ${c.type}`);else{if(s===void 0)throw new Error("Can not delete in empty document");return ne(e,{offset:r?r.offset:0,length:r?r.length:0,content:JSON.stringify(s)},n)}}function ne(e,t,s){if(!s.formattingOptions)return[t];let n=ft(e,t),i=t.offset,o=t.offset+t.content.length;if(t.length===0||t.content.length===0){for(;i>0&&!Ae(n,i-1);)i--;for(;o<n.length&&!Ae(n,o);)o++}let r=ut(n,{offset:i,length:o-i},{...s.formattingOptions,keepLines:!1});for(let a=r.length-1;a>=0;a--){let l=r[a];n=ft(n,l),i=Math.min(i,l.offset),o=Math.max(o,l.offset+l.length),o+=l.content.length-l.length}let c=e.length-(n.length-o)-i;return[{offset:i,length:c,content:n.substring(i,o)}]}function ft(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}var tn;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter"})(tn||(tn={}));var nn;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF"})(nn||(nn={}));var dt=Kt,on=Be,He=$e;var sn;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter"})(sn||(sn={}));function rn(e,t,s,n){return en(e,t,s,n)}async function cn(e,t){let s=ht.join(e,j);if(!gt.existsSync(s))return;let n=await O.workspace.openTextDocument(O.Uri.file(s)),i=await O.window.showTextDocument(n),o=n.getText(),r=on(o);if(!r)return;let c=-1,a=He(r,["rules","module-boundaries","rules"]);if(a&&a.children)if(typeof t=="string"&&!t.startsWith("rule[")){for(let l of a.children){let u=He(l,["name"]);if(u&&u.value===t){c=l.offset;break}}if(c===-1)for(let l of a.children){let u=He(l,["importer"]);if(u&&u.value===t){c=u.offset;break}}}else{let l=String(t).match(/rule\[(\d+)\]/),u=l?parseInt(l[1]):-1;u!==-1&&a.children[u]&&(c=a.children[u].offset)}if(c!==-1){let l=n.positionAt(c);i.selection=new O.Selection(l,l),i.revealRange(new O.Range(l,l),O.TextEditorRevealType.InCenter)}}async function ln(e,t,s){let n=ht.join(e,j);if(!gt.existsSync(n))return;let i=await O.workspace.openTextDocument(O.Uri.file(n)),o=i.getText(),r=rn(o,["rules","module-boundaries","rules",-1],{importer:t,imports:s,allow:!0,name:`allow-${t}-to-${s}`},{formattingOptions:{insertSpaces:!0,tabSize:2}}),c=new O.WorkspaceEdit;for(let a of r)c.replace(i.uri,new O.Range(i.positionAt(a.offset),i.positionAt(a.offset+a.length)),a.content);await O.workspace.applyEdit(c),await i.save(),O.window.showInformationMessage(`Added exception: Allow '${s}' in '${t}'`)}function un(e,t,s,n){e.subscriptions.push(B.commands.registerCommand("pickety.refresh",()=>{t.reload(),t.reloadAliases(),B.window.showInformationMessage("Pickety: Configuration refreshed")})),e.subscriptions.push(B.commands.registerCommand("pickety.generateDiagram",()=>zt(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(B.commands.registerCommand("pickety.showImpact",()=>Qt(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(B.commands.registerCommand("pickety.showHealth",()=>Jt(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(B.commands.registerCommand("pickety.goToRule",(i,o)=>cn(i,o))),e.subscriptions.push(B.commands.registerCommand("pickety.allowImport",(i,o,r)=>ln(i,o,r))),e.subscriptions.push(B.commands.registerCommand("pickety.init",()=>_t(n,()=>t.reload())))}var Q=S(require("vscode"));var X=S(require("path")),se=S(require("fs"));function pn(e){let t=X.join(e,j);if(!se.existsSync(t))return{ok:!1,errors:[{message:`File not found: ${j}`}]};try{let s=se.readFileSync(t,"utf-8"),n;try{n=dt(s)}catch(i){return{ok:!1,errors:[{message:`pickety.json is not valid JSONC: ${i instanceof Error?i.message:String(i)}`}]}}return Vs(n)}catch(s){return{ok:!1,errors:[{message:`Failed to read pickety.json: ${s instanceof Error?s.message:String(s)}`}]}}}function Vs(e){let t=[];if(typeof e!="object"||e===null)return{ok:!1,errors:[{message:"Configuration must be a JSON object"}]};let s=e,n=Bs(s.modules,t),i=Hs(s.rules,t),o=Gs(s["boundary-diagrams"],t),r=zs(s.health,t);return t.length>0||!n||!i?{ok:!1,errors:t}:{ok:!0,config:{modules:n,rules:{"module-boundaries":i},"boundary-diagrams":o,health:r}}}function Bs(e,t){if(e===void 0){t.push({message:'"modules" is required and must be an object',path:"modules"});return}if(typeof e!="object"||e===null){t.push({message:'"modules" must be an object mapping module names to patterns',path:"modules"});return}let s={};for(let[n,i]of Object.entries(e))typeof i!="string"?t.push({message:`Module "${n}" pattern must be a string, got ${typeof i}`,path:`modules.${n}`}):s[n]=i;return s}function Hs(e,t){if(e===void 0){t.push({message:'"rules" is required and must be an object',path:"rules"});return}if(typeof e!="object"||e===null){t.push({message:'"rules" must be an object',path:"rules"});return}let n=e["module-boundaries"];if(n===void 0){t.push({message:'"rules.module-boundaries" is required and must be an object',path:"rules.module-boundaries"});return}if(typeof n!="object"||n===null){t.push({message:'"rules.module-boundaries" must be an object',path:"rules.module-boundaries"});return}let i=n,o="error";if(i.severity!==void 0&&(i.severity!=="error"&&i.severity!=="warn"?t.push({message:`"rules.module-boundaries.severity" must be "error" or "warn", got "${i.severity}"`,path:"rules.module-boundaries.severity"}):o=i.severity),i.rules===void 0){t.push({message:'"rules.module-boundaries.rules" is required and must be an array',path:"rules.module-boundaries.rules"});return}if(!Array.isArray(i.rules)){t.push({message:'"rules.module-boundaries.rules" must be an array',path:"rules.module-boundaries.rules"});return}let r=[];return i.rules.forEach((c,a)=>{let l=`rules.module-boundaries.rules[${a}]`;if(typeof c!="object"||c===null){t.push({message:`Rule #${a} must be an object`,path:l});return}let u=c;typeof u.importer!="string"&&typeof u.containedTo!="string"&&t.push({message:`Rule #${a}: "importer" or "containedTo" is required`,path:l}),u.importer!==void 0&&typeof u.importer!="string"&&t.push({message:`Rule #${a}: "importer" must be a string`,path:`${l}.importer`}),typeof u.imports!="string"&&t.push({message:`Rule #${a}: "imports" is required and must be a string`,path:`${l}.imports`}),u.allow!==void 0&&typeof u.allow!="boolean"&&t.push({message:`Rule #${a}: "allow" must be a boolean`,path:`${l}.allow`}),u.only!==void 0&&typeof u.only!="boolean"&&t.push({message:`Rule #${a}: "only" must be a boolean`,path:`${l}.only`}),u.containedTo!==void 0&&typeof u.containedTo!="string"&&t.push({message:`Rule #${a}: "containedTo" must be a string`,path:`${l}.containedTo`}),u.message!==void 0&&typeof u.message!="string"&&t.push({message:`Rule #${a}: "message" must be a string`,path:`${l}.message`}),u.severity!==void 0&&u.severity!=="error"&&u.severity!=="warn"&&t.push({message:`Rule #${a}: "severity" must be "error" or "warn", got "${u.severity}"`,path:`${l}.severity`}),u.name!==void 0&&typeof u.name!="string"&&t.push({message:`Rule #${a}: "name" must be a string`,path:`${l}.name`}),u.maxViolations!==void 0&&(typeof u.maxViolations!="number"||!Number.isInteger(u.maxViolations)||u.maxViolations<0)&&t.push({message:`Rule #${a}: "maxViolations" must be a non-negative integer`,path:`${l}.maxViolations`}),r.push(u)}),{severity:o,rules:r}}function Gs(e,t){if(e!==void 0){if(typeof e!="boolean"&&typeof e!="string"){t.push({message:'"boundary-diagrams" must be a boolean or a string',path:"boundary-diagrams"});return}return e}}function zs(e,t){if(e===void 0)return;if(typeof e!="object"||e===null){t.push({message:'"health" must be an object',path:"health"});return}let s=e,n={},i=[{key:"maxAfferentCoupling",label:"maxAfferentCoupling"},{key:"maxEfferentCoupling",label:"maxEfferentCoupling"},{key:"maxDepth",label:"maxDepth"}];for(let{key:o,label:r}of i){let c=s[o];c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<1?t.push({message:`"health.${r}" must be a positive integer`,path:`health.${r}`}):n[o]=c)}if(s.maxInstability!==void 0){let o=s.maxInstability;typeof o!="number"||o<0||o>1?t.push({message:'"health.maxInstability" must be a number between 0 and 1',path:"health.maxInstability"}):n.maxInstability=o}return Object.keys(n).length>0?n:void 0}function fn(e,t){if(t<0)return[];let s=[],n;try{n=se.readdirSync(e,{withFileTypes:!0})}catch{return s}for(let i of n)!ae.has(i.name)&&i.isFile()&&/^tsconfig(\..+)?\.json$/.test(i.name)&&s.push(X.join(e,i.name));for(let i of n)!ae.has(i.name)&&i.isDirectory()&&s.push(...fn(X.join(e,i.name),t-1));return s}function dn(e){let t={},s=fn(e,4);for(let n of s)try{let i=se.readFileSync(n,"utf-8"),r=dt(i).compilerOptions;if(!r?.paths)continue;let c=X.dirname(n),a=X.relative(e,c),l=r.baseUrl||".";for(let[u,p]of Object.entries(r.paths))if(Array.isArray(p)&&p.length>0){let f=p[0];t[u]||(t[u]=M(X.join(a,l,f)))}}catch{}return t}var Ge=class{constructor(t){this.workspaceRoot=t;this.registerWatchers()}config;aliases={};_onConfigChanged=new Q.EventEmitter;onConfigChanged=this._onConfigChanged.event;_onAliasesChanged=new Q.EventEmitter;onAliasesChanged=this._onAliasesChanged.event;disposables=[];getConfig(){return this.config}getAliases(){return this.aliases}reload(){let t=pn(this.workspaceRoot);this.config=t.ok?t.config:void 0,this._onConfigChanged.fire(t)}reloadAliases(){this.aliases=dn(this.workspaceRoot),this._onAliasesChanged.fire(this.aliases)}registerWatchers(){let t=Q.workspace.createFileSystemWatcher(new Q.RelativePattern(this.workspaceRoot,j));this.disposables.push(t),t.onDidChange(()=>this.reload()),t.onDidCreate(()=>this.reload()),t.onDidDelete(()=>{this.config=void 0,this._onConfigChanged.fire({ok:!1,errors:[{message:"Configuration file deleted"}]})});let s=Q.workspace.createFileSystemWatcher(new Q.RelativePattern(this.workspaceRoot,"**/tsconfig*.json"));this.disposables.push(s);let n=i=>i.fsPath.split(/[\\/]/).some(r=>ae.has(r));s.onDidChange(i=>{n(i)||this.reloadAliases()}),s.onDidCreate(i=>{n(i)||this.reloadAliases()}),s.onDidDelete(i=>{n(i)||this.reloadAliases()})}dispose(){this.disposables.forEach(t=>t.dispose()),this._onConfigChanged.dispose(),this._onAliasesChanged.dispose()}};var qe=S(require("vscode")),hn=S(require("fs"));function mt(e,t,s){let n=new Set,i=je(e,t,s),o=M(e);for(let{resolvedPath:r}of i)r&&r!==o&&n.add(r);return n}var ze=class{dependents=new Map;dependencies=new Map;updateFile(t,s){let n=this.dependencies.get(t);if(n)for(let i of n)this.dependents.get(i)?.delete(t);this.dependencies.set(t,new Set(s));for(let i of s)this.dependents.has(i)||this.dependents.set(i,new Set),this.dependents.get(i).add(t)}removeFile(t){let s=this.dependencies.get(t);if(s)for(let i of s)this.dependents.get(i)?.delete(t);this.dependencies.delete(t);let n=this.dependents.get(t);if(n)for(let i of n)this.dependencies.get(i)?.delete(t);this.dependents.delete(t)}getDependents(t){return this.dependents.get(t)??new Set}getDependencies(t){return this.dependencies.get(t)??new Set}getTransitiveDependents(t){let s=new Set,n=[t];for(;n.length>0;){let i=n.shift(),o=this.dependents.get(i);if(o)for(let r of o)!s.has(r)&&r!==t&&(s.add(r),n.push(r))}return s}getModuleSummary(t,s,n){let i=this.getDependents(t),o=this.getDependencies(t),r=new Set;for(let a of i){let l=F(a,s,n);l&&r.add(l)}let c=new Set;for(let a of o){let l=F(a,s,n);l&&c.add(l)}return{dependentCount:i.size,dependentModules:[...r],dependencyCount:o.size,dependencyModules:[...c]}}getModuleLevelGraph(t,s){let n=new Map;for(let[i,o]of this.dependencies){let r=F(i,t,s);if(r){n.has(r)||n.set(r,new Set);for(let c of o){let a=F(c,t,s);a&&a!==r&&n.get(r).add(a)}}}return n}clear(){this.dependents.clear(),this.dependencies.clear()}};var Ue=class e{constructor(t,s){this.workspaceRoot=t;this.configService=s;this.disposables.push(this.configService.onAliasesChanged(()=>{this.scanAndNotify()}))}knownFiles=new Set;importGraph=new ze;isLargeWorkspace=!1;static MAX_FILES_THRESHOLD=5e3;_onAnalysisReady=new qe.EventEmitter;onAnalysisReady=this._onAnalysisReady.event;disposables=[];dispose(){this.disposables.forEach(t=>t.dispose()),this._onAnalysisReady.dispose()}getImportGraph(){return this.importGraph}getKnownFiles(){return this.knownFiles}checkIsLargeWorkspace(){return this.isLargeWorkspace}getWorkspaceContext(){return{root:this.workspaceRoot,knownFiles:this.knownFiles,aliases:this.configService.getAliases()}}async scan(){let t=await qe.workspace.findFiles(ee,"**/node_modules/**");return this.knownFiles=new Set(t.map(s=>M(s.fsPath))),this.isLargeWorkspace=this.knownFiles.size>e.MAX_FILES_THRESHOLD,this.importGraph.clear(),this.isLargeWorkspace}async scanAndNotify(){await this.scan(),this._onAnalysisReady.fire()}updateFile(t,s,n){let i=M(t);this.knownFiles.add(i);try{let o=mt(i,s,n);this.importGraph.updateFile(i,o)}catch{}}removeFile(t){let s=M(t);this.knownFiles.delete(s),this.importGraph.removeFile(s)}ensureGraphReady(t){if(!this.isLargeWorkspace){for(let s of this.knownFiles)if(!this.importGraph.getDependencies(s).size)try{let n=hn.readFileSync(s,"utf-8"),i=mt(s,n,t);this.importGraph.updateFile(s,i)}catch{continue}}}computeCycles(t,s){if(this.isLargeWorkspace)return[];this.ensureGraphReady(s);let n=this.importGraph.getModuleLevelGraph(t.modules,this.workspaceRoot);return Wt(n)}computeHealthViolations(t,s){if(!t.health||this.isLargeWorkspace)return[];this.ensureGraphReady(s);let n=pe(this.importGraph,t.modules,s);return Ht(n,t.health)}};var ie=S(require("vscode")),Je=class{item;constructor(t){this.item=ie.window.createStatusBarItem(ie.StatusBarAlignment.Right,100),this.item.command="pickety.refresh",t.subscriptions.push(this.item),this.item.show()}update(t,s){if(!t){this.item.text="$(warning) Pickety: No Config",this.item.tooltip="Pickety is inactive. Check pickety.json for errors.",this.item.backgroundColor=new ie.ThemeColor("statusBarItem.warningBackground");return}let n=0;s.forEach((i,o)=>{n+=o.filter(r=>r.source==="pickety").length}),n>0?(this.item.text=`$(shield) Pickety: ${n} issue(s)`,this.item.tooltip=`Found ${n} architectural violations. Click to refresh.`,this.item.backgroundColor=new ie.ThemeColor("statusBarItem.errorBackground")):(this.item.text="$(check) Pickety",this.item.tooltip="Architectural boundaries are secure. Click to refresh.",this.item.backgroundColor=void 0)}dispose(){this.item.dispose()}};var yt=S(require("vscode")),ye=class e{static instance;outputChannel;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}setOutputChannel(t){this.outputChannel=t}logEvent(t,s){if(!yt.env.isTelemetryEnabled)return;let n=new Date().toISOString(),i=JSON.stringify({event:t,timestamp:n,...s});this.outputChannel&&this.outputChannel.appendLine(`[Telemetry] ${i}`)}logError(t,s){if(!yt.env.isTelemetryEnabled)return;let n=t instanceof Error?t.message:t,i=t instanceof Error?t.stack:void 0;this.logEvent("error",{message:n,context:s||"unknown",stack:i||"no stack trace"})}};var P=S(require("vscode"));var Xe=class e{constructor(t){this.collection=t}static CIRCULAR_TAG="pickety/circular";static HEALTH_TAG="pickety/health";getCollection(){return this.collection}setViolations(t,s){let n=s.map(i=>{let o=new P.Range(i.line,i.character,i.line,i.character+i.length),r=i.severity==="error"?P.DiagnosticSeverity.Error:P.DiagnosticSeverity.Warning,c=new P.Diagnostic(o,i.message,r);return c.source="pickety",i.ruleName&&(c.code={value:i.ruleName,target:P.Uri.parse(`https://github.com/DanielSerio/pickety/blob/main/docs/rules.md#${i.ruleName}`)}),c._picketyMetadata={sourceModule:i.sourceModule,targetModule:i.targetModule},c});this.collection.set(t,n)}setCircularDiagnostics(t,s){let n=s.map(i=>{let o=i.join(" -> "),r=new P.Diagnostic(new P.Range(0,0,0,100),`Circular dependency detected: ${o}`,P.DiagnosticSeverity.Error);return r.source="pickety",r.code=e.CIRCULAR_TAG,r});this.updateConfigDiagnostics(t,e.CIRCULAR_TAG,n)}setHealthDiagnostics(t,s){let n=s.map(i=>{let o=U(i.metric,i.value),r=U(i.metric,i.threshold),c=new P.Diagnostic(new P.Range(0,0,0,100),`Module "${i.moduleName}" has ${i.metric} of ${o} (max: ${r})`,P.DiagnosticSeverity.Warning);return c.source="pickety",c.code=e.HEALTH_TAG,c});this.updateConfigDiagnostics(t,e.HEALTH_TAG,n)}updateConfigDiagnostics(t,s,n){let i=(this.collection.get(t)||[]).filter(o=>(typeof o.code=="object"?o.code?.value:o.code)!==s);this.collection.set(t,[...i,...n])}clear(){this.collection.clear()}delete(t){this.collection.delete(t)}dispose(){this.collection.dispose()}};var K=S(require("vscode"));var bt=S(require("path"));function mn(e,t,s,n){let i=[],{modules:o}=s,{severity:r,rules:c}=s.rules["module-boundaries"],{knownFiles:a,root:l,aliases:u}=n,p=F(e,o,l);if(!p)return[];let f=M(bt.relative(l,e)),d=je(e,t,n);for(let{statement:g,resolvedPath:b}of d){let k=F(b,o,l);if(!k)continue;let E=M(bt.relative(l,b));c.forEach((T,m)=>{let{allow:w,severity:y,name:v,effectiveImporter:h,isOnly:R}=Ce(T,m,r),I=Us(R?T.imports:h);if(I.length>0)if(R){let L=gn(T.imports,E,I);if(L){let _=Qe(h,I,L);if(!be(p,f,_)){let z=T.message||`Module "${p}" is not allowed to import from "${k}" (contained to "${_}")`;i.push(ue(e,g,v,z,y,p,k))}}}else{let L=gn(h,f,I);if(!L)return;if(w){let _=Qe(T.imports,I,"*"),V=Qe(T.imports,I,L),z=be(k,E,_),x=be(k,E,V);if(z&&!x){let $=T.message||`Import must match scoped pattern "${V}"`;i.push(ue(e,g,v,$,y,p,k))}}else{let _=Qe(T.imports,I,L);if(be(k,E,_)){let z=T.message||`Module "${p}" cannot import from "${k}"`;i.push(ue(e,g,v,z,y))}}}else{let L=be(p,f,h),_=be(k,E,T.imports);if(R){if(_&&!L){let V=T.message||(T.containedTo?`Import is restricted: "${k}" is contained to "${h}"`:`Module "${k}" can only be imported by "${h}"`);i.push(ue(e,g,v,V,y,p,k))}}else if(L&&_&&!w){let V=T.message||`Module "${p}" cannot import from "${k}"`;i.push(ue(e,g,v,V,y,p,k))}}})}return i}function be(e,t,s){return!!(ot(e,s)||s.includes("/")&&(A(t,s)||A(t,`**/${s}`)||A(t,`**/${s}/**`)))}function Us(e){return e.match(/\$[\w-]+/g)||[]}function gn(e,t,s){let n=e.split("/"),i=t.split("/"),o=0,r=i.length-n.length;for(let c=o;c<=r;c++){let a=yn(n,i,c,s);if(a)return a}}function yn(e,t,s,n){let i={},o=s;for(let r=0;r<e.length;r++){let c=e[r];if(c==="**"){let p=e.slice(r+1);if(p.length===0)return i;for(let f=o;f<=t.length-p.length;f++){let d=yn(p,t,f,n);if(d)return{...i,...d}}return}if(o>=t.length)return;let a=c,l=[];for(let p of n)a.includes(p)&&(a=a.replace(p,`__VAR_${l.length}__`),l.push(p));a=a.replace(/[.+?^{}()|[\]\\]/g,"\\$&"),a=a.replace(/\*/g,"[^/]*");for(let p=0;p<l.length;p++)a=a.replace(`__VAR_${p}__`,"([^/]+)");let u=t[o].match(new RegExp(`^${a}$`));if(!u)return;for(let p=0;p<l.length;p++)i[l[p]]=u[p+1];o++}return i}function bn(e,t){let s=t.rules["module-boundaries"].rules,n=new Map;if(s.forEach((o,r)=>{if(o.maxViolations!==void 0){let c=o.name??`rule[${r}]`;n.set(c,o.maxViolations)}}),n.size===0)return e;let i=new Map;for(let o of e)o.ruleName&&n.has(o.ruleName)&&i.set(o.ruleName,(i.get(o.ruleName)??0)+1);return e.map(o=>{if(!o.ruleName||!n.has(o.ruleName))return o;let r=i.get(o.ruleName)??0,c=n.get(o.ruleName),a=r<=c?"warn":"error";return a===o.severity?o:{...o,severity:a}})}function Qe(e,t,s){let n=e;for(let i of t){let o=typeof s=="string"?s:s[i],r=i.replace(/\$/g,"\\$");n=n.replace(new RegExp(r,"g"),o)}return n}var H=S(require("vscode")),vn=S(require("path"));function kn(e,t,s,n){s.appendLine("Pickety: Configuration error(s) found:");let i=H.Uri.file(vn.join(t,j)),o=e.map(r=>{s.appendLine(` - ${r.message}${r.path?` (at ${r.path})`:""}`);let c=new H.Range(0,0,0,100),a=new H.Diagnostic(c,r.message,H.DiagnosticSeverity.Error);return a.source="pickety",r.path&&(a.code=r.path),a});n.set(i,o),H.window.showErrorMessage("Pickety: Configuration error. Check the Problems panel or Output channel for details.")}var Ze=class{constructor(t,s,n,i,o,r,c){this.context=t;this.configService=s;this.analysisService=n;this.diagnosticManager=i;this.statusBar=o;this.outputChannel=r;this.workspaceRoot=c;this.registerEventListeners()}analysisTimeout;telemetry=ye.getInstance();disposables=[];codeLensProvider;configRef={config:void 0};setCodeLensProvider(t){this.codeLensProvider=t}handleConfigResult(t){this.diagnosticManager.clear();let s=t.ok?t.config:void 0;if(this.configRef.config=s,t.ok&&t.config){this.outputChannel.appendLine("Pickety: Import boundaries active");try{let n=Fe(t.config,this.workspaceRoot);n&&this.outputChannel.appendLine(`Pickety: Generated boundary diagram at ${n}`)}catch(n){this.outputChannel.appendLine(`Pickety: Failed to generate boundary diagram: ${n instanceof Error?n.message:String(n)}`)}this.analyzeOpenEditors()}else t.ok||kn(t.errors,this.workspaceRoot,this.outputChannel,this.diagnosticManager.getCollection());this.statusBar.update(s,this.diagnosticManager.getCollection())}analyzeOpenEditors(){try{let t=this.configService.getConfig();if(!t)return;let s=[];for(let r of K.workspace.textDocuments)this.isSourceFile(r)&&s.push({uri:r.uri,violations:this.checkDocument(r,t)});let n=s.flatMap(r=>r.violations),i=bn(n,t),o=0;for(let r of s){let c=r.violations.length;this.diagnosticManager.setViolations(r.uri,i.slice(o,o+c)),o+=c}this.statusBar.update(t,this.diagnosticManager.getCollection()),setTimeout(()=>{this.checkCircularDependencies(t),this.checkHealthThresholds(t)},0)}catch(t){this.telemetry.logError(t instanceof Error?t:String(t),"analyzeOpenEditors")}}analyzeDocument(t){let s=this.configService.getConfig();if(!s||!this.isSourceFile(t))return;if(this.hasMaxViolationsRules(s)){this.analyzeOpenEditors();return}let n=this.checkDocument(t,s);this.diagnosticManager.setViolations(t.uri,n),this.statusBar.update(s,this.diagnosticManager.getCollection())}checkDocument(t,s){return mn(t.uri.fsPath,t.getText(),s,this.analysisService.getWorkspaceContext())}hasMaxViolationsRules(t){return t.rules["module-boundaries"].rules.some(s=>s.maxViolations!==void 0)}checkCircularDependencies(t){let s=this.analysisService.computeCycles(t,this.analysisService.getWorkspaceContext()),n=K.Uri.file(ce(this.workspaceRoot));this.diagnosticManager.setCircularDiagnostics(n,s)}checkHealthThresholds(t){let s=this.analysisService.computeHealthViolations(t,this.analysisService.getWorkspaceContext()),n=K.Uri.file(ce(this.workspaceRoot));this.diagnosticManager.setHealthDiagnostics(n,s)}registerEventListeners(){this.disposables.push(K.workspace.onDidChangeTextDocument(s=>{this.isSourceFile(s.document)&&(this.diagnosticManager.delete(s.document.uri),this.analysisTimeout&&clearTimeout(this.analysisTimeout),this.analysisTimeout=setTimeout(()=>{this.analysisService.updateFile(s.document.uri.fsPath,s.document.getText(),this.analysisService.getWorkspaceContext()),this.analyzeDocument(s.document),this.codeLensProvider?.refresh()},300))})),this.disposables.push(K.workspace.onDidOpenTextDocument(s=>this.analyzeDocument(s)));let t=K.workspace.createFileSystemWatcher(ee);this.disposables.push(t),t.onDidCreate(s=>{this.analysisService.getKnownFiles().add(M(s.fsPath))}),t.onDidDelete(s=>{this.analysisService.removeFile(s.fsPath),this.codeLensProvider?.refresh()})}isSourceFile(t){return["typescript","typescriptreact","javascript","javascriptreact"].includes(t.languageId)}dispose(){this.analysisTimeout&&clearTimeout(this.analysisTimeout),this.disposables.forEach(t=>t.dispose())}};var ve=S(require("vscode")),Ye=class{constructor(t){this.workspaceRoot=t}provideCodeActions(t,s,n){let i=[];for(let o of n.diagnostics)if(o.source==="pickety"&&o.code){let r=typeof o.code=="object"?o.code.value:o.code,c=new ve.CodeAction(`Go to Pickety rule: ${r}`,ve.CodeActionKind.QuickFix);c.command={command:"pickety.goToRule",title:"Go to Rule",arguments:[this.workspaceRoot,r]},i.push(c);let a=o._picketyMetadata;if(a&&a.sourceModule&&a.targetModule){let l=new ve.CodeAction(`Allow imports from '${a.targetModule}' in '${a.sourceModule}'`,ve.CodeActionKind.QuickFix);l.command={command:"pickety.allowImport",title:"Allow Import",arguments:[this.workspaceRoot,a.sourceModule,a.targetModule]},i.push(l)}}return i}};var ke=S(require("vscode"));var Ke=class{constructor(t,s,n){this.importGraph=t;this.workspaceRoot=s;this.configRef=n}_onDidChangeCodeLenses=new ke.EventEmitter;onDidChangeCodeLenses=this._onDidChangeCodeLenses.event;refresh(){this._onDidChangeCodeLenses.fire()}provideCodeLenses(t){let s=this.configRef.config;if(!s)return[];let n=M(t.uri.fsPath),i=this.importGraph.getModuleSummary(n,s.modules,this.workspaceRoot);if(i.dependentCount===0&&i.dependencyCount===0)return[];let o=[];if(i.dependentCount>0){let a=i.dependentModules.length===1?"1 module":`${i.dependentModules.length} modules`;o.push(`${i.dependentCount} dependent${i.dependentCount===1?"":"s"} (${a})`)}if(i.dependencyCount>0){let a=i.dependencyModules.length===1?"1 module":`${i.dependencyModules.length} modules`;o.push(`${i.dependencyCount} dependenc${i.dependencyCount===1?"y":"ies"} (${a})`)}let r=new ke.Range(0,0,0,0);return[new ke.CodeLens(r,{title:o.join(" | "),command:"pickety.showImpact",tooltip:"Show full impact analysis for this file"})]}dispose(){this._onDidChangeCodeLenses.dispose()}};var qs=[];async function Js(e){let t=ye.getInstance();t.logEvent("extension_activate");let s=G.window.createOutputChannel("Pickety");e.subscriptions.push(s),t.setOutputChannel(s);let n=G.workspace.workspaceFolders?.[0]?.uri.fsPath;if(!n){s.appendLine("Pickety: No workspace root found.");return}s.appendLine(`Pickety: Extension activated for workspace: ${n}`);let i=new Ge(n);e.subscriptions.push(i);let o=new Ue(n,i);e.subscriptions.push(o);let r=new Je(e);e.subscriptions.push(r);let c=G.languages.createDiagnosticCollection("pickety");e.subscriptions.push(c);let a=new Xe(c);e.subscriptions.push(a);let l=new Ye(n);e.subscriptions.push(G.languages.registerCodeActionsProvider({scheme:"file",language:"*"},l,{providedCodeActionKinds:[G.CodeActionKind.QuickFix]}));let u=new Ke(o.getImportGraph(),n,{config:void 0});e.subscriptions.push(u);let p=new Ze(e,i,o,a,r,s,n);p.setCodeLensProvider(u),e.subscriptions.push(p),u.configRef=p.configRef,e.subscriptions.push(G.languages.registerCodeLensProvider({scheme:"file",pattern:ee},u)),un(e,i,o,n),i.onConfigChanged(f=>p.handleConfigResult(f)),o.onAnalysisReady(()=>{s.appendLine(`Pickety: Analysis complete. Found ${o.getKnownFiles().size} files.`),p.analyzeOpenEditors()}),i.reload(),i.reloadAliases()}function Xs(){qs.forEach(e=>e.dispose())}0&&(module.exports={activate,deactivate});
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Dan Serio"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.1.
|
|
8
|
+
"version": "0.1.2",
|
|
9
9
|
"publisher": "DanSerio",
|
|
10
10
|
"icon": "resources/icon.png",
|
|
11
11
|
"license": "MIT",
|
|
@@ -112,9 +112,9 @@
|
|
|
112
112
|
"vscode:prepublish": "npm run build && npm run build:cli",
|
|
113
113
|
"compile": "npm run build",
|
|
114
114
|
"compile-tests": "tsc -p ./",
|
|
115
|
-
"build": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node --main-fields=module,main --minify",
|
|
116
|
-
"build:cli": "esbuild ./src/cli.ts --bundle --outfile=out/cli.js --format=cjs --platform=node --main-fields=module,main --minify --banner:js=\"#!/usr/bin/env node\"",
|
|
117
|
-
"watch": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node --main-fields=module,main --watch",
|
|
115
|
+
"build": "esbuild ./src/extension/index.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node --main-fields=module,main --minify",
|
|
116
|
+
"build:cli": "esbuild ./src/cli/index.ts --bundle --outfile=out/cli.js --format=cjs --platform=node --main-fields=module,main --minify --banner:js=\"#!/usr/bin/env node\"",
|
|
117
|
+
"watch": "esbuild ./src/extension/index.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node --main-fields=module,main --watch",
|
|
118
118
|
"type-check": "tsc -p ./ --noEmit",
|
|
119
119
|
"pretest": "npm run compile-tests && npm run compile && npm run lint",
|
|
120
120
|
"lint": "eslint src",
|