pickety 0.1.4 → 0.2.1
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/.vscodeignore +2 -1
- package/README.md +2 -2
- package/out/cli.js +10 -10
- package/out/extension.js +20 -20
- package/package.json +2 -1
package/.vscodeignore
CHANGED
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ ESLint's `no-restricted-imports` can block a handful of hard-coded paths. But th
|
|
|
67
67
|
|
|
68
68
|
## Features
|
|
69
69
|
|
|
70
|
-
- **
|
|
70
|
+
- **On-save enforcement** -- violations appear instantly when you save, keeping feedback fast without noisy mid-keystroke diagnostics
|
|
71
71
|
- **Glob patterns** -- flexible module definitions using [minimatch](https://github.com/isaacs/minimatch) syntax
|
|
72
72
|
- **Interpolation variables** -- enforce scoped relationships like "route X can only import from feature X"
|
|
73
73
|
- **Strict enforcement** -- use `only` and `containedTo` to restrict modules to specific consumers
|
|
@@ -249,7 +249,7 @@ With this rule, `routes/auth/index.ts` can import from `features/auth/pages/` bu
|
|
|
249
249
|
|
|
250
250
|
## Boundary Diagrams
|
|
251
251
|
|
|
252
|
-
Pickety can auto-generate a [Mermaid](https://mermaid.js.org/) diagram of your module boundaries.
|
|
252
|
+
Pickety can auto-generate a [Mermaid](https://mermaid.js.org/) diagram of your module boundaries. Modules are clustered by their top-level path segment, with edges labeled by rule action and name.
|
|
253
253
|
|
|
254
254
|
Add this to your `pickety.json`:
|
|
255
255
|
|
package/out/cli.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var Ot=Object.create;var ve=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var Nt=Object.getPrototypeOf,Rt=Object.prototype.hasOwnProperty;var jt=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of At(t))!Rt.call(e,i)&&i!==s&&ve(e,i,{get:()=>t[i],enumerable:!(n=$t(t,i))||n.enumerable});return e};var j=(e,t,s)=>(s=e!=null?Ot(Nt(e)):{},jt(t||!e||!e.__esModule?ve(s,"default",{value:e,enumerable:!0}):s,e));var D=j(require("fs")),_=j(require("path"));var st=j(require("path")),
|
|
3
|
-
`;break;case 114:m+="\r";break;case 116:m+=" ";break;case 117:let y=h(4,!0);y>=0?m+=String.fromCharCode(y):f=4;break;default:f=5}S=n;continue}if(x>=0&&x<=31)if(H(x)){m+=e.substring(S,n),f=2;break}else f=6;n++}return m}function b(){if(i="",f=0,r=n,l=
|
|
4
|
-
`),a
|
|
2
|
+
"use strict";var Ot=Object.create;var ve=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var At=Object.getOwnPropertyNames;var Nt=Object.getPrototypeOf,Rt=Object.prototype.hasOwnProperty;var jt=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of At(t))!Rt.call(e,i)&&i!==s&&ve(e,i,{get:()=>t[i],enumerable:!(n=$t(t,i))||n.enumerable});return e};var j=(e,t,s)=>(s=e!=null?Ot(Nt(e)):{},jt(t||!e||!e.__esModule?ve(s,"default",{value:e,enumerable:!0}):s,e));var D=j(require("fs")),_=j(require("path"));var st=j(require("path")),ie=j(require("fs"));function K(e,t=!1){let s=e.length,n=0,i="",r=0,o=16,c=0,l=0,a=0,u=0,f=0;function h(m,S){let x=0,w=0;for(;x<m||!S;){let y=e.charCodeAt(n);if(y>=48&&y<=57)w=w*16+y-48;else if(y>=65&&y<=70)w=w*16+y-65+10;else if(y>=97&&y<=102)w=w*16+y-97+10;else break;n++,x++}return x<m&&(w=-1),w}function p(m){n=m,i="",r=0,o=16,f=0}function g(){let m=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&F(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&F(e.charCodeAt(n)))for(n++;n<e.length&&F(e.charCodeAt(n));)n++;else return f=3,e.substring(m,n);let S=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&&F(e.charCodeAt(n))){for(n++;n<e.length&&F(e.charCodeAt(n));)n++;S=n}else f=3;return e.substring(m,S)}function d(){let m="",S=n;for(;;){if(n>=s){m+=e.substring(S,n),f=2;break}let x=e.charCodeAt(n);if(x===34){m+=e.substring(S,n),n++;break}if(x===92){if(m+=e.substring(S,n),n++,n>=s){f=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+=`
|
|
3
|
+
`;break;case 114:m+="\r";break;case 116:m+=" ";break;case 117:let y=h(4,!0);y>=0?m+=String.fromCharCode(y):f=4;break;default:f=5}S=n;continue}if(x>=0&&x<=31)if(H(x)){m+=e.substring(S,n),f=2;break}else f=6;n++}return m}function b(){if(i="",f=0,r=n,l=c,u=a,n>=s)return r=s,o=17;let m=e.charCodeAt(n);if(ce(m)){do n++,i+=String.fromCharCode(m),m=e.charCodeAt(n);while(ce(m));return o=15}if(H(m))return n++,i+=String.fromCharCode(m),m===13&&e.charCodeAt(n)===10&&(n++,i+=`
|
|
4
|
+
`),c++,a=n,o=14;switch(m){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=d(),o=10;case 47:let S=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<s&&!H(e.charCodeAt(n));)n++;return i=e.substring(S,n),o=12}if(e.charCodeAt(n+1)===42){n+=2;let x=s-1,w=!1;for(;n<x;){let y=e.charCodeAt(n);if(y===42&&e.charCodeAt(n+1)===47){n+=2,w=!0;break}n++,H(y)&&(y===13&&e.charCodeAt(n)===10&&n++,c++,a=n)}return w||(n++,f=1),i=e.substring(S,n),o=13}return i+=String.fromCharCode(m),n++,o=16;case 45:if(i+=String.fromCharCode(m),n++,n===s||!F(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+=g(),o=11;default:for(;n<s&&T(m);)n++,m=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(m),n++,o=16}}function T(m){if(ce(m)||H(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 O(){let m;do m=b();while(m>=12&&m<=15);return m}return{setPosition:p,getPosition:()=>n,scan:t?O:b,getToken:()=>o,getTokenValue:()=>i,getTokenOffset:()=>r,getTokenLength:()=>n-r,getTokenStartLine:()=>l,getTokenStartCharacter:()=>r-u,getTokenError:()=>f}}function ce(e){return e===32||e===9}function H(e){return e===10||e===13}function F(e){return e>=48&&e<=57}var Ee;(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"})(Ee||(Ee={}));var Lt=new Array(20).fill(0).map((e,t)=>" ".repeat(t)),P=200,Mt={" ":{"\n":new Array(P).fill(0).map((e,t)=>`
|
|
5
5
|
`+" ".repeat(t)),"\r":new Array(P).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(P).fill(0).map((e,t)=>`\r
|
|
6
6
|
`+" ".repeat(t))}," ":{"\n":new Array(P).fill(0).map((e,t)=>`
|
|
7
7
|
`+" ".repeat(t)),"\r":new Array(P).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(P).fill(0).map((e,t)=>`\r
|
|
8
|
-
`+" ".repeat(t))}};var C;(function(e){e.DEFAULT={allowTrailingComma:!1}})(C||(C={}));function Oe(e,t=[],s=C.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,c,u)=>{t.push({error:l,offset:c,length:u})}},s),i[0]}function $e(e,t,s=C.DEFAULT){let n=K(e,!1),i=[],r=0;function o(k){return k?()=>r===0&&k(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function a(k){return k?E=>r===0&&k(E,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function l(k){return k?E=>r===0&&k(E,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}function c(k){return k?()=>{r>0?r++:k(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice())===!1&&(r=1)}:()=>!0}function u(k){return k?()=>{r>0&&r--,r===0&&k(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}let f=c(t.onObjectBegin),h=l(t.onObjectProperty),p=u(t.onObjectEnd),g=c(t.onArrayBegin),d=u(t.onArrayEnd),b=l(t.onLiteralValue),T=a(t.onSeparator),O=o(t.onComment),m=a(t.onError),S=s&&s.disallowComments,x=s&&s.allowTrailingComma;function w(){for(;;){let k=n.scan();switch(n.getTokenError()){case 4:y(14);break;case 5:y(15);break;case 3:y(13);break;case 1:S||y(11);break;case 2:y(12);break;case 6:y(16);break}switch(k){case 12:case 13:S?y(10):O();break;case 16:y(1);break;case 15:case 14:break;default:return k}}}function y(k,E=[],Te=[]){if(m(k),E.length+Te.length>0){let Y=n.getToken();for(;Y!==17;){if(E.indexOf(Y)!==-1){w();break}else if(Te.indexOf(Y)!==-1)break;Y=w()}}}function xe(k){let E=n.getTokenValue();return k?b(E):(h(E),i.push(E)),w(),!0}function xt(){switch(n.getToken()){case 11:let k=n.getTokenValue(),E=Number(k);isNaN(E)&&(y(2),E=0),b(E);break;case 7:b(null);break;case 8:b(!0);break;case 9:b(!1);break;default:return!1}return w(),!0}function Tt(){return n.getToken()!==10?(y(3,[],[2,5]),!1):(xe(!1),n.getToken()===6?(T(":"),w(),ae()||y(4,[],[2,5])):y(5,[],[2,5]),i.pop(),!0)}function vt(){f(),w();let k=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(k||y(4,[],[]),T(","),w(),n.getToken()===2&&x)break}else k&&y(6,[],[]);Tt()||y(4,[],[2,5]),k=!0}return p(),n.getToken()!==2?y(7,[2],[]):w(),!0}function Et(){g(),w();let k=!0,E=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(E||y(4,[],[]),T(","),w(),n.getToken()===4&&x)break}else E&&y(6,[],[]);k?(i.push(0),k=!1):i[i.length-1]++,ae()||y(4,[],[4,5]),E=!0}return d(),k||i.pop(),n.getToken()!==4?y(8,[4],[]):w(),!0}function ae(){switch(n.getToken()){case 3:return Et();case 1:return vt();case 10:return xe(!0);default:return xt()}}return w(),n.getToken()===17?s.allowEmptyContent?!0:(y(4,[],[]),!1):ae()?(n.getToken()!==17&&y(9,[],[]),!0):(y(4,[],[]),!1)}var Ae;(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"})(Ae||(Ae={}));var Ne;(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"})(Ne||(Ne={}));var ee=Oe;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 de=j(require("path"));var fe=(e,t,s)=>{let n=e instanceof RegExp?Ie(e,s):e,i=t instanceof RegExp?Ie(t,s):t,r=n!==null&&i!=null&&Wt(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)}},Ie=(e,t)=>{let s=t.match(e);return s?s[0]:null},Wt=(e,t,s)=>{let n,i,r,o,a,l=s.indexOf(e),c=s.indexOf(t,l+1),u=l;if(l>=0&&c>0){if(e===t)return[l,c];for(n=[],r=s.length;u>=0&&!a;){if(u===l)n.push(u),l=s.indexOf(e,u+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,c])}else i=n.pop(),i!==void 0&&i<r&&(r=i,o=c),c=s.indexOf(t,u+1);u=l<c&&l>=0?l:c}n.length&&o!==void 0&&(a=[r,o])}return a};var Le="\0SLASH"+Math.random()+"\0",Me="\0OPEN"+Math.random()+"\0",pe="\0CLOSE"+Math.random()+"\0",Ve="\0COMMA"+Math.random()+"\0",Be="\0PERIOD"+Math.random()+"\0",zt=new RegExp(Le,"g"),Ut=new RegExp(Me,"g"),Ht=new RegExp(pe,"g"),Gt=new RegExp(Ve,"g"),qt=new RegExp(Be,"g"),Xt=/\\\\/g,Jt=/\\{/g,Zt=/\\}/g,Qt=/\\,/g,Yt=/\\./g,Kt=1e5;function ue(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Ct(e){return e.replace(Xt,Le).replace(Jt,Me).replace(Zt,pe).replace(Qt,Ve).replace(Yt,Be)}function en(e){return e.replace(zt,"\\").replace(Ut,"{").replace(Ht,"}").replace(Gt,",").replace(qt,".")}function _e(e){if(!e)return[""];let t=[],s=fe("{","}",e);if(!s)return e.split(",");let{pre:n,body:i,post:r}=s,o=n.split(",");o[o.length-1]+="{"+i+"}";let a=_e(r);return r.length&&(o[o.length-1]+=a.shift(),o.push.apply(o,a)),t.push.apply(t,o),t}function De(e,t={}){if(!e)return[];let{max:s=Kt}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),G(Ct(e),s,!0).map(en)}function tn(e){return"{"+e+"}"}function nn(e){return/^-?0\d/.test(e)}function sn(e,t){return e<=t}function rn(e,t){return e>=t}function G(e,t,s){let n=[],i=fe("{","}",e);if(!i)return[e];let r=i.pre,o=i.post.length?G(i.post,t,!1):[""];if(/\$$/.test(i.pre))for(let a=0;a<o.length&&a<t;a++){let l=r+"{"+i.body+"}"+o[a];n.push(l)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body),c=a||l,u=i.body.indexOf(",")>=0;if(!c&&!u)return i.post.match(/,(?!,).*\}/)?(e=i.pre+"{"+i.body+pe+i.post,G(e,t,!0)):[e];let f;if(c)f=i.body.split(/\.\./);else if(f=_e(i.body),f.length===1&&f[0]!==void 0&&(f=G(f[0],t,!1).map(tn),f.length===1))return o.map(p=>i.pre+f[0]+p);let h;if(c&&f[0]!==void 0&&f[1]!==void 0){let p=ue(f[0]),g=ue(f[1]),d=Math.max(f[0].length,f[1].length),b=f.length===3&&f[2]!==void 0?Math.abs(ue(f[2])):1,T=sn;g<p&&(b*=-1,T=rn);let m=f.some(nn);h=[];for(let S=p;T(S,g);S+=b){let x;if(l)x=String.fromCharCode(S),x==="\\"&&(x="");else if(x=String(S),m){let w=d-x.length;if(w>0){let y=new Array(w+1).join("0");S<0?x="-"+y+x.slice(1):x=y+x}}h.push(x)}}else{h=[];for(let p=0;p<f.length;p++)h.push.apply(h,G(f[p],t,!1))}for(let p=0;p<h.length;p++)for(let g=0;g<o.length&&n.length<t;g++){let d=r+h[p]+o[g];(!s||c||d)&&n.push(d)}}return n}var q=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var on={"[: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]},X=e=>e.replace(/[[\]\\-]/g,"\\$&"),ln=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Fe=e=>e.join(""),Pe=(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,a=!1,l=!1,c=!1,u=s,f="";e:for(;r<e.length;){let d=e.charAt(r);if((d==="!"||d==="^")&&r===s+1){c=!0,r++;continue}if(d==="]"&&o&&!l){u=r+1;break}if(o=!0,d==="\\"&&!l){l=!0,r++;continue}if(d==="["&&!l){for(let[b,[T,O,m]]of Object.entries(on))if(e.startsWith(b,r)){if(f)return["$.",!1,e.length-s,!0];r+=b.length,m?i.push(T):n.push(T),a=a||O;continue e}}if(l=!1,f){d>f?n.push(X(f)+"-"+X(d)):d===f&&n.push(X(d)),f="",r++;continue}if(e.startsWith("-]",r+1)){n.push(X(d+"-")),r+=2;continue}if(e.startsWith("-",r+1)){f=d,r+=2;continue}n.push(X(d)),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])&&!c){let d=n[0].length===2?n[0].slice(-1):n[0];return[ln(d),!1,u-s,!1]}let h="["+(c?"^":"")+Fe(n)+"]",p="["+(c?"":"^")+Fe(i)+"]";return[n.length&&i.length?"("+h+"|"+p+")":n.length?h:p,a,u-s,!0]};var I=(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 an=new Set(["!","?","+","*","@"]),We=e=>an.has(e),cn="(?!(?:^|/)\\.\\.?(?:$|/))",te="(?!\\.)",fn=new Set(["[","."]),un=new Set(["..","."]),pn=new Set("().*{}+?[]^$\\!"),hn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),he="[^/]",ze=he+"*?",Ue=he+"+?",W=class e{type;#n;#s;#r=!1;#e=[];#t;#o;#a;#l=!1;#i;#c;#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.#a=this.#n===this?[]:this.#n.#a,t==="!"&&!this.#n.#l&&this.#a.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.#c!==void 0?this.#c:this.type?this.#c=this.type+"("+this.#e.map(t=>String(t)).join("|")+")":this.#c=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.#a.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,a=-1,l=!1;if(s.type===null){let p=n,g="";for(;p<t.length;){let d=t.charAt(p++);if(r||d==="\\"){r=!r,g+=d;continue}if(o){p===a+1?(d==="^"||d==="!")&&(l=!0):d==="]"&&!(p===a+2&&l)&&(o=!1),g+=d;continue}else if(d==="["){o=!0,a=p,l=!1,g+=d;continue}if(!i.noext&&We(d)&&t.charAt(p)==="("){s.push(g),g="";let b=new e(d,s);p=e.#f(t,b,p,i),s.push(b);continue}g+=d}return s.push(g),p}let c=n+1,u=new e(null,s),f=[],h="";for(;c<t.length;){let p=t.charAt(c++);if(r||p==="\\"){r=!r,h+=p;continue}if(o){c===a+1?(p==="^"||p==="!")&&(l=!0):p==="]"&&!(c===a+2&&l)&&(o=!1),h+=p;continue}else if(p==="["){o=!0,a=c,l=!1,h+=p;continue}if(We(p)&&t.charAt(c)==="("){u.push(h),h="";let g=new e(p,u);u.push(g),c=e.#f(t,g,c,i);continue}if(p==="|"){u.push(h),h="",f.push(u),u=new e(null,s);continue}if(p===")")return h===""&&s.#e.length===0&&(s.#u=!0),u.push(h),h="",s.push(...f,u),c;h+=p}return s.type=null,s.#s=void 0,s.#e=[t.substring(n-1)],c}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 a=(this.#i.nocase?"i":"")+(r?"u":"");return Object.assign(new RegExp(`^${s}$`,a),{_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(p=>typeof p!="string"),c=this.#e.map(p=>{let[g,d,b,T]=typeof p=="string"?e.#g(p,this.#s,l):p.toRegExpSource(t);return this.#s=this.#s||b,this.#r=this.#r||T,g}).join(""),u="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&un.has(this.#e[0]))){let g=fn,d=s&&g.has(c.charAt(0))||c.startsWith("\\.")&&g.has(c.charAt(2))||c.startsWith("\\.\\.")&&g.has(c.charAt(4)),b=!s&&!t&&g.has(c.charAt(0));u=d?cn:b?te:""}let f="";return this.isEnd()&&this.#n.#l&&this.#t?.type==="!"&&(f="(?:$|\\/)"),[u+c+f,I(c),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,I(this.toString()),!1,!1]}let o=!n||t||s||!te?"":this.#p(!0);o===r&&(o=""),o&&(r=`(?:${r})(?:${o})*?`);let a="";if(this.type==="!"&&this.#u)a=(this.isStart()&&!s?te:"")+Ue;else{let l=this.type==="!"?"))"+(this.isStart()&&!s&&!t?te:"")+ze+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;a=i+r+l}return[a,I(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,a=!1;for(let l=0;l<t.length;l++){let c=t.charAt(l);if(i){i=!1,r+=(pn.has(c)?"\\":"")+c;continue}if(c==="*"){if(a)continue;a=!0,r+=n&&/^[*]+$/.test(t)?Ue:ze,s=!0;continue}else a=!1;if(c==="\\"){l===t.length-1?r+="\\\\":i=!0;continue}if(c==="["){let[u,f,h,p]=Pe(t,l);if(h){r+=u,o=o||f,l+=h-1,s=s||p;continue}}if(c==="?"){r+=he,s=!0;continue}r+=hn(c)}return[r,I(t),!!s,o]}};var ge=(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={})=>(q(t),!s.nocomment&&t.charAt(0)==="#"?!1:new z(t,s).match(e)),gn=/^\*+([^+@!?\*\[\(]*)$/,dn=e=>t=>!t.startsWith(".")&&t.endsWith(e),mn=e=>t=>t.endsWith(e),yn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),bn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),kn=/^\*+\.\*+$/,wn=e=>!e.startsWith(".")&&e.includes("."),Sn=e=>e!=="."&&e!==".."&&e.includes("."),xn=/^\.\*+$/,Tn=e=>e!=="."&&e!==".."&&e.startsWith("."),vn=/^\*+$/,En=e=>e.length!==0&&!e.startsWith("."),On=e=>e.length!==0&&e!=="."&&e!=="..",$n=/^\?+([^+@!?\*\[\(]*)?$/,An=([e,t=""])=>{let s=qe([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},Nn=([e,t=""])=>{let s=Xe([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},Rn=([e,t=""])=>{let s=Xe([e]);return t?n=>s(n)&&n.endsWith(t):s},jn=([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:"/"}},In=Je==="win32"?He.win32.sep:He.posix.sep;v.sep=In;var R=Symbol("globstar **");v.GLOBSTAR=R;var Ln="[^/]",Mn=Ln+"*?",Vn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Bn="(?:(?!(?:\\/|^)\\.).)*?",_n=(e,t={})=>s=>v(s,e,t);v.filter=_n;var N=(e,t={})=>Object.assign({},e,t),Dn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return v;let t=v;return Object.assign((n,i,r={})=>t(n,i,N(e,r)),{Minimatch:class extends t.Minimatch{constructor(i,r={}){super(i,N(e,r))}static defaults(i){return t.defaults(N(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,r,o={}){super(i,r,N(e,o))}static fromGlob(i,r={}){return t.AST.fromGlob(i,N(e,r))}},unescape:(n,i={})=>t.unescape(n,N(e,i)),escape:(n,i={})=>t.escape(n,N(e,i)),filter:(n,i={})=>t.filter(n,N(e,i)),defaults:n=>t.defaults(N(e,n)),makeRe:(n,i={})=>t.makeRe(n,N(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,N(e,i)),match:(n,i,r={})=>t.match(n,i,N(e,r)),sep:t.sep,GLOBSTAR:R})};v.defaults=Dn;var Ze=(e,t={})=>(q(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:De(e,{max:t.braceExpandMax}));v.braceExpand=Ze;var Fn=(e,t={})=>new z(e,t).makeRe();v.makeRe=Fn;var Pn=(e,t,s={})=>{let n=new z(t,s);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};v.match=Pn;var Ge=/[?*]|[+@!]\(.*?\)|\[|\]/,Wn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),z=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,s={}){q(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,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=r[0]===""&&r[1]===""&&(r[2]==="?"||!Ge.test(r[2]))&&!Ge.test(r[3]),c=/^[a-z]:/i.test(r[0]);if(l)return[...r.slice(0,4),...r.slice(4).map(u=>this.parse(u))];if(c)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 a=n[i+1],l=n[i+2],c=n[i+3];if(a!==".."||!l||l==="."||l===".."||!c||c==="."||c==="..")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 a=n[o];o===1&&a===""&&n[0]===""||(a==="."||a==="")&&(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=[],a="";for(;i<t.length&&r<s.length;)if(t[i]===s[r])o.push(a==="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(a==="b")return!1;a="a",o.push(t[i]),i++,r++}else if(s[r]==="*"&&t[i]&&(this.options.dot||!t[i].startsWith("."))&&t[i]!=="**"){if(a==="a")return!1;a="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 d=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),b=!d&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),T=typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0]),O=!T&&s[0]===""&&s[1]===""&&s[2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3]),m=b?3:d?0:void 0,S=O?3:T?0:void 0;if(typeof m=="number"&&typeof S=="number"){let[x,w]=[t[m],s[S]];x.toLowerCase()===w.toLowerCase()&&(s[S]=x,S>m?s=s.slice(S):m>S&&(t=t.slice(m)))}}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,a=0,l=t.length,c=s.length;o<l&&a<c;o++,a++){this.debug("matchOne loop");var u=s[a],f=t[o];if(this.debug(s,u,f),u===!1)return!1;if(u===R){this.debug("GLOBSTAR",[s,u,f]);var h=o,p=a+1;if(p===c){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(;h<l;){var g=t[h];if(this.debug(`
|
|
8
|
+
`+" ".repeat(t))}};var C;(function(e){e.DEFAULT={allowTrailingComma:!1}})(C||(C={}));function Oe(e,t=[],s=C.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,a,u)=>{t.push({error:l,offset:a,length:u})}},s),i[0]}function $e(e,t,s=C.DEFAULT){let n=K(e,!1),i=[],r=0;function o(k){return k?()=>r===0&&k(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function c(k){return k?E=>r===0&&k(E,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function l(k){return k?E=>r===0&&k(E,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}function a(k){return k?()=>{r>0?r++:k(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice())===!1&&(r=1)}:()=>!0}function u(k){return k?()=>{r>0&&r--,r===0&&k(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}let f=a(t.onObjectBegin),h=l(t.onObjectProperty),p=u(t.onObjectEnd),g=a(t.onArrayBegin),d=u(t.onArrayEnd),b=l(t.onLiteralValue),T=c(t.onSeparator),O=o(t.onComment),m=c(t.onError),S=s&&s.disallowComments,x=s&&s.allowTrailingComma;function w(){for(;;){let k=n.scan();switch(n.getTokenError()){case 4:y(14);break;case 5:y(15);break;case 3:y(13);break;case 1:S||y(11);break;case 2:y(12);break;case 6:y(16);break}switch(k){case 12:case 13:S?y(10):O();break;case 16:y(1);break;case 15:case 14:break;default:return k}}}function y(k,E=[],Te=[]){if(m(k),E.length+Te.length>0){let Y=n.getToken();for(;Y!==17;){if(E.indexOf(Y)!==-1){w();break}else if(Te.indexOf(Y)!==-1)break;Y=w()}}}function xe(k){let E=n.getTokenValue();return k?b(E):(h(E),i.push(E)),w(),!0}function xt(){switch(n.getToken()){case 11:let k=n.getTokenValue(),E=Number(k);isNaN(E)&&(y(2),E=0),b(E);break;case 7:b(null);break;case 8:b(!0);break;case 9:b(!1);break;default:return!1}return w(),!0}function Tt(){return n.getToken()!==10?(y(3,[],[2,5]),!1):(xe(!1),n.getToken()===6?(T(":"),w(),le()||y(4,[],[2,5])):y(5,[],[2,5]),i.pop(),!0)}function vt(){f(),w();let k=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(k||y(4,[],[]),T(","),w(),n.getToken()===2&&x)break}else k&&y(6,[],[]);Tt()||y(4,[],[2,5]),k=!0}return p(),n.getToken()!==2?y(7,[2],[]):w(),!0}function Et(){g(),w();let k=!0,E=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(E||y(4,[],[]),T(","),w(),n.getToken()===4&&x)break}else E&&y(6,[],[]);k?(i.push(0),k=!1):i[i.length-1]++,le()||y(4,[],[4,5]),E=!0}return d(),k||i.pop(),n.getToken()!==4?y(8,[4],[]):w(),!0}function le(){switch(n.getToken()){case 3:return Et();case 1:return vt();case 10:return xe(!0);default:return xt()}}return w(),n.getToken()===17?s.allowEmptyContent?!0:(y(4,[],[]),!1):le()?(n.getToken()!==17&&y(9,[],[]),!0):(y(4,[],[]),!1)}var Ae;(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"})(Ae||(Ae={}));var Ne;(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"})(Ne||(Ne={}));var ee=Oe;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 ge=j(require("path"));var ae=(e,t,s)=>{let n=e instanceof RegExp?Ie(e,s):e,i=t instanceof RegExp?Ie(t,s):t,r=n!==null&&i!=null&&Wt(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)}},Ie=(e,t)=>{let s=t.match(e);return s?s[0]:null},Wt=(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",Me="\0OPEN"+Math.random()+"\0",ue="\0CLOSE"+Math.random()+"\0",Ve="\0COMMA"+Math.random()+"\0",Be="\0PERIOD"+Math.random()+"\0",zt=new RegExp(Le,"g"),Ut=new RegExp(Me,"g"),Ht=new RegExp(ue,"g"),Gt=new RegExp(Ve,"g"),qt=new RegExp(Be,"g"),Xt=/\\\\/g,Jt=/\\{/g,Zt=/\\}/g,Qt=/\\,/g,Yt=/\\./g,Kt=1e5;function fe(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Ct(e){return e.replace(Xt,Le).replace(Jt,Me).replace(Zt,ue).replace(Qt,Ve).replace(Yt,Be)}function en(e){return e.replace(zt,"\\").replace(Ut,"{").replace(Ht,"}").replace(Gt,",").replace(qt,".")}function _e(e){if(!e)return[""];let t=[],s=ae("{","}",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 De(e,t={}){if(!e)return[];let{max:s=Kt}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),G(Ct(e),s,!0).map(en)}function tn(e){return"{"+e+"}"}function nn(e){return/^-?0\d/.test(e)}function sn(e,t){return e<=t}function rn(e,t){return e>=t}function G(e,t,s){let n=[],i=ae("{","}",e);if(!i)return[e];let r=i.pre,o=i.post.length?G(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+ue+i.post,G(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=G(f[0],t,!1).map(tn),f.length===1))return o.map(p=>i.pre+f[0]+p);let h;if(a&&f[0]!==void 0&&f[1]!==void 0){let p=fe(f[0]),g=fe(f[1]),d=Math.max(f[0].length,f[1].length),b=f.length===3&&f[2]!==void 0?Math.abs(fe(f[2])):1,T=sn;g<p&&(b*=-1,T=rn);let m=f.some(nn);h=[];for(let S=p;T(S,g);S+=b){let x;if(l)x=String.fromCharCode(S),x==="\\"&&(x="");else if(x=String(S),m){let w=d-x.length;if(w>0){let y=new Array(w+1).join("0");S<0?x="-"+y+x.slice(1):x=y+x}}h.push(x)}}else{h=[];for(let p=0;p<f.length;p++)h.push.apply(h,G(f[p],t,!1))}for(let p=0;p<h.length;p++)for(let g=0;g<o.length&&n.length<t;g++){let d=r+h[p]+o[g];(!s||a||d)&&n.push(d)}}return n}var q=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var on={"[: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]},X=e=>e.replace(/[[\]\\-]/g,"\\$&"),ln=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Fe=e=>e.join(""),Pe=(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 d=e.charAt(r);if((d==="!"||d==="^")&&r===s+1){a=!0,r++;continue}if(d==="]"&&o&&!l){u=r+1;break}if(o=!0,d==="\\"&&!l){l=!0,r++;continue}if(d==="["&&!l){for(let[b,[T,O,m]]of Object.entries(on))if(e.startsWith(b,r)){if(f)return["$.",!1,e.length-s,!0];r+=b.length,m?i.push(T):n.push(T),c=c||O;continue e}}if(l=!1,f){d>f?n.push(X(f)+"-"+X(d)):d===f&&n.push(X(d)),f="",r++;continue}if(e.startsWith("-]",r+1)){n.push(X(d+"-")),r+=2;continue}if(e.startsWith("-",r+1)){f=d,r+=2;continue}n.push(X(d)),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 d=n[0].length===2?n[0].slice(-1):n[0];return[ln(d),!1,u-s,!1]}let h="["+(a?"^":"")+Fe(n)+"]",p="["+(a?"":"^")+Fe(i)+"]";return[n.length&&i.length?"("+h+"|"+p+")":n.length?h:p,c,u-s,!0]};var I=(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 cn=new Set(["!","?","+","*","@"]),We=e=>cn.has(e),an="(?!(?:^|/)\\.\\.?(?:$|/))",te="(?!\\.)",fn=new Set(["[","."]),un=new Set(["..","."]),pn=new Set("().*{}+?[]^$\\!"),hn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),pe="[^/]",ze=pe+"*?",Ue=pe+"+?",W=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 p=n,g="";for(;p<t.length;){let d=t.charAt(p++);if(r||d==="\\"){r=!r,g+=d;continue}if(o){p===c+1?(d==="^"||d==="!")&&(l=!0):d==="]"&&!(p===c+2&&l)&&(o=!1),g+=d;continue}else if(d==="["){o=!0,c=p,l=!1,g+=d;continue}if(!i.noext&&We(d)&&t.charAt(p)==="("){s.push(g),g="";let b=new e(d,s);p=e.#f(t,b,p,i),s.push(b);continue}g+=d}return s.push(g),p}let a=n+1,u=new e(null,s),f=[],h="";for(;a<t.length;){let p=t.charAt(a++);if(r||p==="\\"){r=!r,h+=p;continue}if(o){a===c+1?(p==="^"||p==="!")&&(l=!0):p==="]"&&!(a===c+2&&l)&&(o=!1),h+=p;continue}else if(p==="["){o=!0,c=a,l=!1,h+=p;continue}if(We(p)&&t.charAt(a)==="("){u.push(h),h="";let g=new e(p,u);u.push(g),a=e.#f(t,g,a,i);continue}if(p==="|"){u.push(h),h="",f.push(u),u=new e(null,s);continue}if(p===")")return h===""&&s.#e.length===0&&(s.#u=!0),u.push(h),h="",s.push(...f,u),a;h+=p}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(p=>typeof p!="string"),a=this.#e.map(p=>{let[g,d,b,T]=typeof p=="string"?e.#g(p,this.#s,l):p.toRegExpSource(t);return this.#s=this.#s||b,this.#r=this.#r||T,g}).join(""),u="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&un.has(this.#e[0]))){let g=fn,d=s&&g.has(a.charAt(0))||a.startsWith("\\.")&&g.has(a.charAt(2))||a.startsWith("\\.\\.")&&g.has(a.charAt(4)),b=!s&&!t&&g.has(a.charAt(0));u=d?an:b?te:""}let f="";return this.isEnd()&&this.#n.#l&&this.#t?.type==="!"&&(f="(?:$|\\/)"),[u+a+f,I(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,I(this.toString()),!1,!1]}let o=!n||t||s||!te?"":this.#p(!0);o===r&&(o=""),o&&(r=`(?:${r})(?:${o})*?`);let c="";if(this.type==="!"&&this.#u)c=(this.isStart()&&!s?te:"")+Ue;else{let l=this.type==="!"?"))"+(this.isStart()&&!s&&!t?te:"")+ze+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&o?")":this.type==="*"&&o?")?":`)${this.type}`;c=i+r+l}return[c,I(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+=(pn.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,h,p]=Pe(t,l);if(h){r+=u,o=o||f,l+=h-1,s=s||p;continue}}if(a==="?"){r+=pe,s=!0;continue}r+=hn(a)}return[r,I(t),!!s,o]}};var he=(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={})=>(q(t),!s.nocomment&&t.charAt(0)==="#"?!1:new z(t,s).match(e)),gn=/^\*+([^+@!?\*\[\(]*)$/,dn=e=>t=>!t.startsWith(".")&&t.endsWith(e),mn=e=>t=>t.endsWith(e),yn=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),bn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),kn=/^\*+\.\*+$/,wn=e=>!e.startsWith(".")&&e.includes("."),Sn=e=>e!=="."&&e!==".."&&e.includes("."),xn=/^\.\*+$/,Tn=e=>e!=="."&&e!==".."&&e.startsWith("."),vn=/^\*+$/,En=e=>e.length!==0&&!e.startsWith("."),On=e=>e.length!==0&&e!=="."&&e!=="..",$n=/^\?+([^+@!?\*\[\(]*)?$/,An=([e,t=""])=>{let s=qe([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},Nn=([e,t=""])=>{let s=Xe([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},Rn=([e,t=""])=>{let s=Xe([e]);return t?n=>s(n)&&n.endsWith(t):s},jn=([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:"/"}},In=Je==="win32"?He.win32.sep:He.posix.sep;v.sep=In;var R=Symbol("globstar **");v.GLOBSTAR=R;var Ln="[^/]",Mn=Ln+"*?",Vn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Bn="(?:(?!(?:\\/|^)\\.).)*?",_n=(e,t={})=>s=>v(s,e,t);v.filter=_n;var N=(e,t={})=>Object.assign({},e,t),Dn=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return v;let t=v;return Object.assign((n,i,r={})=>t(n,i,N(e,r)),{Minimatch:class extends t.Minimatch{constructor(i,r={}){super(i,N(e,r))}static defaults(i){return t.defaults(N(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,r,o={}){super(i,r,N(e,o))}static fromGlob(i,r={}){return t.AST.fromGlob(i,N(e,r))}},unescape:(n,i={})=>t.unescape(n,N(e,i)),escape:(n,i={})=>t.escape(n,N(e,i)),filter:(n,i={})=>t.filter(n,N(e,i)),defaults:n=>t.defaults(N(e,n)),makeRe:(n,i={})=>t.makeRe(n,N(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,N(e,i)),match:(n,i,r={})=>t.match(n,i,N(e,r)),sep:t.sep,GLOBSTAR:R})};v.defaults=Dn;var Ze=(e,t={})=>(q(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:De(e,{max:t.braceExpandMax}));v.braceExpand=Ze;var Fn=(e,t={})=>new z(e,t).makeRe();v.makeRe=Fn;var Pn=(e,t,s={})=>{let n=new z(t,s);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};v.match=Pn;var Ge=/[?*]|[+@!]\(.*?\)|\[|\]/,Wn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),z=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,s={}){q(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 d=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),b=!d&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),T=typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0]),O=!T&&s[0]===""&&s[1]===""&&s[2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3]),m=b?3:d?0:void 0,S=O?3:T?0:void 0;if(typeof m=="number"&&typeof S=="number"){let[x,w]=[t[m],s[S]];x.toLowerCase()===w.toLowerCase()&&(s[S]=x,S>m?s=s.slice(S):m>S&&(t=t.slice(m)))}}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===R){this.debug("GLOBSTAR",[s,u,f]);var h=o,p=c+1;if(p===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(;h<l;){var g=t[h];if(this.debug(`
|
|
9
9
|
globstar while`,t,h,s,p,g),this.matchOne(t.slice(h),s.slice(p),n))return this.debug("globstar found match!",h,l,g),!0;if(g==="."||g===".."||!i.dot&&g.charAt(0)==="."){this.debug("dot detected!",t,h,s,p);break}this.debug("globstar swallow a segment, and continue"),h++}return!!(n&&(this.debug(`
|
|
10
|
-
>>> no match, partial?`,t,h,s,p),h===l))}let d;if(typeof u=="string"?(d=f===u,this.debug("string match",u,f,d)):(d=u.test(f),this.debug("pattern match",u,f,d)),!d)return!1}if(o===l&&a===c)return!0;if(o===l)return n;if(a===c)return o===l-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return Ze(this.pattern,this.options)}parse(t){q(t);let s=this.options;if(t==="**")return R;if(t==="")return"";let n,i=null;(n=t.match(vn))?i=s.dot?On:En:(n=t.match(gn))?i=(s.nocase?s.dot?bn:yn:s.dot?mn:dn)(n[1]):(n=t.match($n))?i=(s.nocase?s.dot?Nn:An:s.dot?Rn:jn)(n):(n=t.match(kn))?i=s.dot?Sn:wn:(n=t.match(xn))&&(i=Tn);let r=W.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?Mn:s.dot?Vn:Bn,i=new Set(s.nocase?["i"]:[]),r=t.map(l=>{let c=l.map(f=>{if(f instanceof RegExp)for(let h of f.flags.split(""))i.add(h);return typeof f=="string"?Wn(f):f===R?R:f._src});c.forEach((f,h)=>{let p=c[h+1],g=c[h-1];f!==R||g===R||(g===void 0?p!==void 0&&p!==R?c[h+1]="(?:\\/|"+n+"\\/)?"+p:c[h]=n:p===void 0?c[h-1]=g+"(?:\\/|\\/"+n+")?":p!==R&&(c[h-1]=g+"(?:\\/|\\/"+n+"\\/)"+p,c[h+1]=R))});let u=c.filter(f=>f!==R);if(this.partial&&u.length>=1){let f=[];for(let h=1;h<=u.length;h++)f.push(u.slice(0,h).join("/"));return"(?:"+f.join("|")+")"}return u.join("/")}).join("|"),[o,a]=t.length>1?["(?:",")"]:["",""];r="^"+o+r+a+"$",this.partial&&(r="^(?:\\/|"+o+r.slice(1,-1)+a+")$"),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 a=i.length-2;!o&&a>=0;a--)o=i[a];for(let a=0;a<r.length;a++){let l=r[a],c=i;if(n.matchBase&&l.length===1&&(c=[o]),this.matchOne(c,l,s))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return v.defaults(t).Minimatch}};v.AST=W;v.Minimatch=z;v.escape=ge;v.unescape=I;var ne="pickety.json",U=["ts","tsx","js","jsx","mjs","cjs"],zn=`**/*.{${U.join(",")}}`,se=new Set(["node_modules",".git",".next","dist","out","build",".turbo",".cache",".nx","coverage"]);function $(e){let t=e.replace(/\\/g,"/");return/^[a-zA-Z]:/.test(t)&&(t=t[0].toLowerCase()+t.slice(1)),t}function J(e,t){return de.relative(e,t).replace(/\\/g,"/")}function Qe(e,t){return v(e,t)||e===t}function ie(e,t){return e==="instability"?t.toFixed(2):String(t)}function Ye(e,t,s){let n=me(e);return{allow:e.allow??!1,severity:e.severity??s,name:e.name??`rule[${t}]`,effectiveImporter:n?.path||e.importer||"*",isOnly:e.only||!!e.containedTo,isAllowStyle:(e.allow??!1)||!!e.containedTo||e.only}}function L(e,t,s){return!!(Qe(e,s)||s.includes("/")&&(v(t,s)||v(t,`**/${s}`)||v(t,`**/${s}/**`)))}function me(e){if(e.containedTo)return typeof e.containedTo=="object"?e.containedTo:{path:e.containedTo}}function B(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 a=e.get(o);if(a){for(let l of a)if(!s.has(l))r(l);else if(n.has(l)){let c=i.indexOf(l);c!==-1&&t.push([...i.slice(c),l])}}n.delete(o),i.pop()}for(let o of e.keys())s.has(o)||r(o);return t}function Ce(e,t,s,n){if(typeof e.containedTo=="object"&&e.containedTo!==null){let i=e.containedTo;if(typeof i.path!="string"&&n.push({message:`Rule #${t}: "containedTo.path" is required and must be a string`,path:`${s}.containedTo.path`}),i.unless!==void 0)if(typeof i.unless!="object"||i.unless===null||Array.isArray(i.unless))n.push({message:`Rule #${t}: "containedTo.unless" must be an object`,path:`${s}.containedTo.unless`});else{let r=i.unless;Object.keys(r).length===0&&n.push({message:`Rule #${t}: "containedTo.unless" must not be empty`,path:`${s}.containedTo.unless`}),typeof e.imports=="string"&&!e.imports.match(/\$[\w-]+/)&&n.push({message:`Rule #${t}: "containedTo.unless" requires "imports" to contain at least one $variable`,path:`${s}.containedTo.unless`});for(let[a,l]of Object.entries(r))a.startsWith("$")||n.push({message:`Rule #${t}: "containedTo.unless" key "${a}" must start with $`,path:`${s}.containedTo.unless`}),typeof l!="string"&&n.push({message:`Rule #${t}: "containedTo.unless.${a}" must be a string`,path:`${s}.containedTo.unless.${a}`})}}else typeof e.containedTo!="string"&&n.push({message:`Rule #${t}: "containedTo" must be a string or object with a "path" property`,path:`${s}.containedTo`})}function et(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((a,l)=>{let c=`rules.module-boundaries.rules[${l}]`;if(typeof a!="object"||a===null){t.push({message:`Rule #${l} must be an object`,path:c});return}let u=a,f=typeof u.containedTo=="string"||typeof u.containedTo=="object"&&u.containedTo!==null;typeof u.importer!="string"&&!f&&t.push({message:`Rule #${l}: "importer" or "containedTo" is required`,path:c}),u.importer!==void 0&&typeof u.importer!="string"&&t.push({message:`Rule #${l}: "importer" must be a string`,path:`${c}.importer`}),typeof u.imports!="string"&&t.push({message:`Rule #${l}: "imports" is required and must be a string`,path:`${c}.imports`}),u.allow!==void 0&&typeof u.allow!="boolean"&&t.push({message:`Rule #${l}: "allow" must be a boolean`,path:`${c}.allow`}),u.only!==void 0&&typeof u.only!="boolean"&&t.push({message:`Rule #${l}: "only" must be a boolean`,path:`${c}.only`}),u.containedTo!==void 0&&Ce(u,l,c,t),u.message!==void 0&&typeof u.message!="string"&&t.push({message:`Rule #${l}: "message" must be a string`,path:`${c}.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:`${c}.severity`}),u.name!==void 0&&typeof u.name!="string"&&t.push({message:`Rule #${l}: "name" must be a string`,path:`${c}.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:`${c}.maxViolations`}),o.push(u)}),{severity:r,rules:o}}function tt(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 a=s[r];a!==void 0&&(typeof a!="number"||!Number.isInteger(a)||a<1?t.push({message:`"health.${o}" must be a positive integer`,path:`health.${o}`}):n[r]=a)}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 nt(e){let t=[];if(typeof e!="object"||e===null)return{ok:!1,errors:[{message:"Configuration must be a JSON object"}]};let s=e,n=Un(s.modules,t),i=et(s.rules,t),r=Hn(s["boundary-diagrams"],t),o=tt(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 Un(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 Hn(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 it(e){let t=st.join(e,ne);if(!re.existsSync(t))return{ok:!1,errors:[{message:`File not found: ${ne}`}]};try{let s=re.readFileSync(t,"utf-8"),n;try{n=ee(s)}catch(i){return{ok:!1,errors:[{message:`pickety.json is not valid JSONC: ${i instanceof Error?i.message:String(i)}`}]}}return nt(n)}catch(s){return{ok:!1,errors:[{message:`Failed to read pickety.json: ${s instanceof Error?s.message:String(s)}`}]}}}var oe=j(require("fs")),M=j(require("path"));function rt(e,t){if(t<0)return[];let s=[],n;try{n=oe.readdirSync(e,{withFileTypes:!0})}catch{return s}for(let i of n)!se.has(i.name)&&i.isFile()&&/^tsconfig(\..+)?\.json$/.test(i.name)&&s.push(M.join(e,i.name));for(let i of n)!se.has(i.name)&&i.isDirectory()&&s.push(...rt(M.join(e,i.name),t-1));return s}function ot(e){let t={},s=rt(e,4);for(let n of s)try{let i=oe.readFileSync(n,"utf-8"),o=ee(i).compilerOptions;if(!o?.paths)continue;let a=M.dirname(n),l=M.relative(e,a),c=o.baseUrl||".";for(let[u,f]of Object.entries(o.paths))if(Array.isArray(f)&&f.length>0){let h=f[0];t[u]||(t[u]=$(M.join(l,c,h)))}}catch{}return t}var ke=j(require("path"));var V=j(require("path"));var at=U.map(e=>`.${e}`),Gn=at.map(e=>`index${e}`),lt=/(\/\*[\s\S]*?\*\/|\/\/.*)|(['"`](?:\\.|[^'"`])*['"`])|((?:import|export)\s+(?:[\s\S]*?from\s+)?['"`]([^'"`]+)['"`])|(import\s*\(\s*['"`]([^'"`]+)['"`]\s*\))/gm;function qn(e){let t=[],s=e.split(`
|
|
11
|
-
`),n=[],i=0;for(let
|
|
10
|
+
>>> no match, partial?`,t,h,s,p),h===l))}let d;if(typeof u=="string"?(d=f===u,this.debug("string match",u,f,d)):(d=u.test(f),this.debug("pattern match",u,f,d)),!d)return!1}if(o===l&&c===a)return!0;if(o===l)return n;if(c===a)return o===l-1&&t[o]==="";throw new Error("wtf?")}braceExpand(){return Ze(this.pattern,this.options)}parse(t){q(t);let s=this.options;if(t==="**")return R;if(t==="")return"";let n,i=null;(n=t.match(vn))?i=s.dot?On:En:(n=t.match(gn))?i=(s.nocase?s.dot?bn:yn:s.dot?mn:dn)(n[1]):(n=t.match($n))?i=(s.nocase?s.dot?Nn:An:s.dot?Rn:jn)(n):(n=t.match(kn))?i=s.dot?Sn:wn:(n=t.match(xn))&&(i=Tn);let r=W.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?Mn:s.dot?Vn:Bn,i=new Set(s.nocase?["i"]:[]),r=t.map(l=>{let a=l.map(f=>{if(f instanceof RegExp)for(let h of f.flags.split(""))i.add(h);return typeof f=="string"?Wn(f):f===R?R:f._src});a.forEach((f,h)=>{let p=a[h+1],g=a[h-1];f!==R||g===R||(g===void 0?p!==void 0&&p!==R?a[h+1]="(?:\\/|"+n+"\\/)?"+p:a[h]=n:p===void 0?a[h-1]=g+"(?:\\/|\\/"+n+")?":p!==R&&(a[h-1]=g+"(?:\\/|\\/"+n+"\\/)"+p,a[h+1]=R))});let u=a.filter(f=>f!==R);if(this.partial&&u.length>=1){let f=[];for(let h=1;h<=u.length;h++)f.push(u.slice(0,h).join("/"));return"(?:"+f.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],a=i;if(n.matchBase&&l.length===1&&(a=[o]),this.matchOne(a,l,s))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return v.defaults(t).Minimatch}};v.AST=W;v.Minimatch=z;v.escape=he;v.unescape=I;var de="pickety.json",U=["ts","tsx","js","jsx","mjs","cjs"],zn=`**/*.{${U.join(",")}}`,ne=new Set(["node_modules",".git",".next","dist","out","build",".turbo",".cache",".nx","coverage"]);function $(e){let t=e.replace(/\\/g,"/");return/^[a-zA-Z]:/.test(t)&&(t=t[0].toLowerCase()+t.slice(1)),t}function J(e,t){return ge.relative(e,t).replace(/\\/g,"/")}function Qe(e,t){return v(e,t)||e===t}function se(e,t){return e==="instability"?t.toFixed(2):String(t)}function Ye(e,t,s){let n=me(e);return{allow:e.allow??!1,severity:e.severity??s,name:e.name??`rule[${t}]`,effectiveImporter:n?.path||e.importer||"*",isOnly:e.only||!!e.containedTo,isAllowStyle:(e.allow??!1)||!!e.containedTo||e.only}}function L(e,t,s){return!!(Qe(e,s)||s.includes("/")&&(v(t,s)||v(t,`**/${s}`)||v(t,`**/${s}/**`)))}function me(e){if(e.containedTo)return typeof e.containedTo=="object"?e.containedTo:{path:e.containedTo}}function B(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 a=i.indexOf(l);a!==-1&&t.push([...i.slice(a),l])}}n.delete(o),i.pop()}for(let o of e.keys())s.has(o)||r(o);return t}function Ce(e,t,s,n){if(typeof e.containedTo=="object"&&e.containedTo!==null){let i=e.containedTo;if(typeof i.path!="string"&&n.push({message:`Rule #${t}: "containedTo.path" is required and must be a string`,path:`${s}.containedTo.path`}),i.unless!==void 0)if(typeof i.unless!="object"||i.unless===null||Array.isArray(i.unless))n.push({message:`Rule #${t}: "containedTo.unless" must be an object`,path:`${s}.containedTo.unless`});else{let r=i.unless;Object.keys(r).length===0&&n.push({message:`Rule #${t}: "containedTo.unless" must not be empty`,path:`${s}.containedTo.unless`}),typeof e.imports=="string"&&!e.imports.match(/\$[\w-]+/)&&n.push({message:`Rule #${t}: "containedTo.unless" requires "imports" to contain at least one $variable`,path:`${s}.containedTo.unless`});for(let[c,l]of Object.entries(r))c.startsWith("$")||n.push({message:`Rule #${t}: "containedTo.unless" key "${c}" must start with $`,path:`${s}.containedTo.unless`}),typeof l!="string"&&n.push({message:`Rule #${t}: "containedTo.unless.${c}" must be a string`,path:`${s}.containedTo.unless.${c}`})}}else typeof e.containedTo!="string"&&n.push({message:`Rule #${t}: "containedTo" must be a string or object with a "path" property`,path:`${s}.containedTo`})}function et(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 a=`rules.module-boundaries.rules[${l}]`;if(typeof c!="object"||c===null){t.push({message:`Rule #${l} must be an object`,path:a});return}let u=c,f=typeof u.containedTo=="string"||typeof u.containedTo=="object"&&u.containedTo!==null;typeof u.importer!="string"&&!f&&t.push({message:`Rule #${l}: "importer" or "containedTo" is required`,path:a}),u.importer!==void 0&&typeof u.importer!="string"&&t.push({message:`Rule #${l}: "importer" must be a string`,path:`${a}.importer`}),typeof u.imports!="string"&&t.push({message:`Rule #${l}: "imports" is required and must be a string`,path:`${a}.imports`}),u.allow!==void 0&&typeof u.allow!="boolean"&&t.push({message:`Rule #${l}: "allow" must be a boolean`,path:`${a}.allow`}),u.only!==void 0&&typeof u.only!="boolean"&&t.push({message:`Rule #${l}: "only" must be a boolean`,path:`${a}.only`}),u.containedTo!==void 0&&Ce(u,l,a,t),u.message!==void 0&&typeof u.message!="string"&&t.push({message:`Rule #${l}: "message" must be a string`,path:`${a}.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:`${a}.severity`}),u.name!==void 0&&typeof u.name!="string"&&t.push({message:`Rule #${l}: "name" must be a string`,path:`${a}.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:`${a}.maxViolations`}),o.push(u)}),{severity:r,rules:o}}function tt(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 nt(e){let t=[];if(typeof e!="object"||e===null)return{ok:!1,errors:[{message:"Configuration must be a JSON object"}]};let s=e,n=Un(s.modules,t),i=et(s.rules,t),r=Hn(s["boundary-diagrams"],t),o=tt(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 Un(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 Hn(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 it(e){let t=st.join(e,de);if(!ie.existsSync(t))return{ok:!0,config:void 0};try{let s=ie.readFileSync(t,"utf-8"),n;try{n=ee(s)}catch(i){return{ok:!1,errors:[{message:`pickety.json is not valid JSONC: ${i instanceof Error?i.message:String(i)}`}]}}return nt(n)}catch(s){return{ok:!1,errors:[{message:`Failed to read pickety.json: ${s instanceof Error?s.message:String(s)}`}]}}}var re=j(require("fs")),M=j(require("path"));function rt(e,t){if(t<0)return[];let s=[],n;try{n=re.readdirSync(e,{withFileTypes:!0})}catch{return s}for(let i of n)!ne.has(i.name)&&i.isFile()&&/^tsconfig(\..+)?\.json$/.test(i.name)&&s.push(M.join(e,i.name));for(let i of n)!ne.has(i.name)&&i.isDirectory()&&s.push(...rt(M.join(e,i.name),t-1));return s}function ot(e){let t={},s=rt(e,4);for(let n of s)try{let i=re.readFileSync(n,"utf-8"),o=ee(i).compilerOptions;if(!o?.paths)continue;let c=M.dirname(n),l=M.relative(e,c),a=o.baseUrl||".";for(let[u,f]of Object.entries(o.paths))if(Array.isArray(f)&&f.length>0){let h=f[0];t[u]||(t[u]=$(M.join(l,a,h)))}}catch{}return t}var ke=j(require("path"));var V=j(require("path"));var ct=U.map(e=>`.${e}`),Gn=ct.map(e=>`index${e}`),lt=/(\/\*[\s\S]*?\*\/|\/\/.*)|(['"`](?:\\.|[^'"`])*['"`])|((?:import|export)\s+(?:[\s\S]*?from\s+)?['"`]([^'"`]+)['"`])|(import\s*\(\s*['"`]([^'"`]+)['"`]\s*\))/gm;function qn(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 a=1;a<n.length&&!(n[a]>c);a++)l=a;return{line:l,character:c-n[l]}},o;for(lt.lastIndex=0;(o=lt.exec(e))!==null;){let[c,l,a,u,f,h,p]=o;if(!(l||a)){if(u&&f){let g=r(o.index);t.push({specifier:f,line:g.line,character:g.character,length:u.length})}else if(h&&p){let g=r(o.index);t.push({specifier:p,line:g.line,character:g.character,length:h.length})}}}return t}function Xn(e,t,s){let{knownFiles:n,root:i,aliases:r}=s;for(let[o,c]of Object.entries(r))if(o.endsWith("/*")){let l=o.slice(0,-2),a=c.endsWith("/*")?c.slice(0,-2):c==="*"?"./":c;if(e.startsWith(l)){let u=e.replace(l,a);return ye(V.resolve(i,u),n)}}else if(e===o)return ye(V.resolve(i,c),n);if(e.startsWith(".")){let o=V.dirname(t),c=V.resolve(o,e);return ye(c,n)}}function ye(e,t){let s=$(e);if(t.has(s))return s;for(let n of ct){let i=s+n;if(t.has(i))return i}for(let n of Gn){let i=s+"/"+n;if(t.has(i))return i}}function A(e,t,s){let n=$(V.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 oe(e,t,s){let n=qn(t),i=[];for(let r of n){let o=Xn(r.specifier,e,s);o&&i.push({statement:r,resolvedPath:o})}return i}function at(e){return e.match(/\$[\w-]+/g)||[]}function be(e,t,s){let n=e.split("/"),i=t.split("/"),r=0,o=n.filter(l=>l!=="**").length,c=i.length-o;for(let l=r;l<=c;l++){let a=ft(n,i,l,s);if(a)return a}}function ft(e,t,s,n){let i={},r=s;for(let o=0;o<e.length;o++){let c=e[o];if(c==="**"){let f=e.slice(o+1);if(f.length===0)return i;for(let h=r;h<=t.length-f.length;h++){let p=ft(f,t,h,n);if(p)return{...i,...p}}return}if(r>=t.length)return;let l=c,a=[];for(let f of n)l.includes(f)&&(l=l.replace(f,`__VAR_${a.length}__`),a.push(f));l=l.replace(/[.+?^{}()|[\]\\]/g,"\\$&"),l=l.replace(/\*/g,"[^/]*");for(let f=0;f<a.length;f++)l=l.replace(`__VAR_${f}__`,"([^/]+)");let u=t[r].match(new RegExp(`^${l}$`));if(!u)return;for(let f=0;f<a.length;f++)i[a[f]]=u[f+1];r++}return i}function Z(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 ut(e,t,s,n,i,r,o,c,l,a,u,f,h){if(s){let p=be(e.imports,u,t);if(p){if(Jn(e,p))return;let g=Z(i,t,p);if(!L(c,l,g)){let b=e.message||`Module "${c}" is not allowed to import from "${a}" (contained to "${g}")`;return B(f,h,o,b,r,c,a)}}}else{let p=be(i,l,t);if(!p)return;if(n){let g=Z(e.imports,t,"*"),d=Z(e.imports,t,p),b=L(a,u,g),T=L(a,u,d);if(b&&!T){let O=e.message||`Import must match scoped pattern "${d}"`;return B(f,h,o,O,r,c,a)}}else{let g=Z(e.imports,t,p);if(L(a,u,g)){let b=e.message||`Module "${c}" cannot import from "${a}"`;return B(f,h,o,b,r,c,a)}}}}function Jn(e,t){let s=me(e);if(s&&s.unless){let n=Object.entries(s.unless);return n.length>0&&n.every(([i,r])=>t[i]===r)}return!1}function pt(e,t,s,n,i,r,o,c,l){let{allow:a,severity:u,name:f,effectiveImporter:h,isOnly:p}=Ye(e,t,s),g=at(p?e.imports:h);if(g.length>0)return ut(e,g,p,a,h,u,f,n,i,r,o,c,l);let d=L(n,i,h),b=L(r,o,e.imports);if(p){if(b&&!d){let T=e.message||(e.containedTo?`Import is restricted: "${r}" is contained to "${h}"`:`Module "${r}" can only be imported by "${h}"`);return B(c,l,f,T,u,n,r)}}else if(d&&b&&!a){let T=e.message||`Module "${n}" cannot import from "${r}"`;return B(c,l,f,T,u,n,r)}}function ht(e,t,s,n){let i=[],{modules:r}=s,{severity:o,rules:c}=s.rules["module-boundaries"],{root:l}=n,a=A(e,r,l);if(!a)return[];let u=$(ke.relative(l,e)),f=oe(e,t,n);for(let{statement:h,resolvedPath:p}of f){let g=A(p,r,l);if(!g)continue;let d=$(ke.relative(l,p));c.forEach((b,T)=>{let O=pt(b,T,o,a,u,g,d,e,h);O&&i.push(O)})}return i}function gt(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 we(e,t,s){let n=new Set,i=oe(e,t,s),r=$(e);for(let{resolvedPath:o}of i)o&&o!==r&&n.add(o);return n}var Q=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 a=A(l,s,n);a&&o.add(a)}let c=new Set;for(let l of r){let a=A(l,s,n);a&&c.add(a)}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=A(i,t,s);if(o){n.has(o)||n.set(o,new Set);for(let c of r){let l=A(c,t,s);l&&l!==o&&n.get(o).add(l)}}}return n}clear(){this.dependents.clear(),this.dependencies.clear()}};function dt(e,t,s){let{root:n,knownFiles:i}=s,r=e.getModuleLevelGraph(t,n),o=Object.keys(t),c=new Map;for(let f of o)c.set(f,0);for(let f of i){let h=A(f,t,n);h&&c.set(h,(c.get(h)??0)+1)}let l=new Map;for(let f of o)l.set(f,0);for(let[,f]of r)for(let h of f)l.set(h,(l.get(h)??0)+1);let a=Zn(r,o),u=o.map(f=>{let h=l.get(f)??0,p=r.get(f)?.size??0,g=h+p;return{moduleName:f,fileCount:c.get(f)??0,afferentCoupling:h,efferentCoupling:p,instability:g===0?0:p/g,dependencyDepth:a.get(f)??0}});return u.sort((f,h)=>f.instability-h.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 mt(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 yt(e,t){let s=J(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 bt(e,t,s,n){let i=J(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
|
|
14
|
-
Transitive dependents (${o.size} file${o.size===1?"":"s"} across ${
|
|
15
|
-
Affected modules: ${[...
|
|
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,
|
|
13
|
+
`);return}console.log(` Direct dependents (${r.size} file${r.size===1?"":"s"}):`);for(let l of r){let a=A(l,s.modules,n)??"(unmatched)",u=J(n,l);console.log(` ${u} (${a})`)}let c=new Set;for(let l of o){let a=A(l,s.modules,n);a&&c.add(a)}o.size>r.size&&(console.log(`
|
|
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 kt(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(se("instability",o.instability),n[4]),r(String(o.dependencyDepth),n[5])].join(" "),a=t.filter(u=>u.moduleName===o.moduleName);if(a.length>0){let u=a.map(f=>{let h=se(f.metric,f.threshold);return`exceeds max${f.metric.charAt(0).toUpperCase()+f.metric.slice(1)} (${h})`});l+=" \u2190 "+u.join(", ")}console.log(l)}}function Qn(e){let t=e.slice(2),s=t[0],n=process.cwd(),i=t.indexOf("--root");i!==-1&&t[i+1]&&(n=_.resolve(t[i+1]));let r=s==="impact"&&t[1]&&!t[1].startsWith("--")?_.resolve(n,t[1]):void 0;return{command:s,root:n,target:r}}var Yn=new Set(U.map(e=>`.${e}`));function Kn(e){let t=D.readdirSync(e,{recursive:!0,withFileTypes:!0}),s=new Set;for(let n of t){if(!n.isFile())continue;let i=_.join(n.parentPath,n.name);i.includes("node_modules")||Yn.has(_.extname(n.name))&&s.add($(i))}return s}function wt(){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 Se(e){let t=it(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)}t.config||(console.log("No pickety.json found. Skipping check."),process.exit(0));let s=Kn(e),n=ot(e);return{config:t.config,ctx:{root:e,knownFiles:s,aliases:n}}}function St(e){let t=new Q;for(let s of e.knownFiles)try{let n=D.readFileSync(s,"utf-8"),i=we(s,n,e);t.updateFile(s,i)}catch{continue}return t}function Cn(e){let{config:t,ctx:s}=Se(e),n=new Q,i=[];for(let u of s.knownFiles)try{let f=D.readFileSync(u,"utf-8"),h=ht(u,f,t,s);i.push(...h);let p=we(u,f,s);n.updateFile(u,p)}catch{continue}let r=gt(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(yt(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,a=r.filter(u=>u.severity==="warn").length;console.log(""),console.log(`Found ${r.length} violation(s): ${l} error(s), ${a} warning(s)`),process.exit(l>0?1:0)}function es(e,t){t||(console.error("Usage: pickety impact <file> [--root <path>]"),process.exit(1)),D.existsSync(t)||(console.error(`File not found: ${t}`),process.exit(1));let{config:s,ctx:n}=Se(e),i=St(n);bt(t,i,s,e)}function ts(e){let{config:t,ctx:s}=Se(e),n=St(s),i=dt(n,t.modules,s),r=t.health?mt(i,t.health):[];kt(i,r),r.length>0?(console.log(`
|
|
17
17
|
${r.length} threshold violation(s) found.`),process.exit(1)):(console.log(`
|
|
18
18
|
All modules within configured thresholds.`),process.exit(0))}function ns(){let{command:e,root:t,target:s}=Qn(process.argv);switch((!e||e==="--help"||e==="-h")&&(wt(),process.exit(0)),e){case"check":Cn(t);break;case"impact":es(t,s);break;case"health":ts(t);break;default:console.error(`Unknown command: "${e}"`),wt(),process.exit(1)}}ns();
|
package/out/extension.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";var In=Object.create;var $e=Object.defineProperty;var Ln=Object.getOwnPropertyDescriptor;var Pn=Object.getOwnPropertyNames;var Dn=Object.getPrototypeOf,Nn=Object.prototype.hasOwnProperty;var Cn=(e,t)=>{for(var s in t)$e(e,s,{get:t[s],enumerable:!0})},wt=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Pn(t))!Nn.call(e,i)&&i!==s&&$e(e,i,{get:()=>t[i],enumerable:!(n=Ln(t,i))||n.enumerable});return e};var x=(e,t,s)=>(s=e!=null?In(Dn(e)):{},wt(t||!e||!e.__esModule?$e(s,"default",{value:e,enumerable:!0}):s,e)),jn=e=>wt($e({},"__esModule",{value:!0}),e);var si={};Cn(si,{activate:()=>ti,deactivate:()=>ni});module.exports=jn(si);var V=x(require("vscode"));var F=x(require("vscode"));var oe=x(require("vscode")),Ie=x(require("fs"));var Oe=x(require("path"));var et=(e,t,s)=>{let n=e instanceof RegExp?xt(e,s):e,i=t instanceof RegExp?xt(t,s):t,o=n!==null&&i!=null&&Fn(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)}},xt=(e,t)=>{let s=t.match(e);return s?s[0]:null},Fn=(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 St="\0SLASH"+Math.random()+"\0",Tt="\0OPEN"+Math.random()+"\0",nt="\0CLOSE"+Math.random()+"\0",Et="\0COMMA"+Math.random()+"\0",$t="\0PERIOD"+Math.random()+"\0",_n=new RegExp(St,"g"),Vn=new RegExp(Tt,"g"),Wn=new RegExp(nt,"g"),Bn=new RegExp(Et,"g"),Hn=new RegExp($t,"g"),Gn=/\\\\/g,zn=/\\{/g,Un=/\\}/g,qn=/\\,/g,Jn=/\\./g,Xn=1e5;function tt(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Qn(e){return e.replace(Gn,St).replace(zn,Tt).replace(Un,nt).replace(qn,Et).replace(Jn,$t)}function Zn(e){return e.replace(_n,"\\").replace(Vn,"{").replace(Wn,"}").replace(Bn,",").replace(Hn,".")}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 Ot(e,t={}){if(!e)return[];let{max:s=Xn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),me(Qn(e),s,!0).map(Zn)}function Yn(e){return"{"+e+"}"}function Kn(e){return/^-?0\d/.test(e)}function es(e,t){return e<=t}function ts(e,t){return e>=t}function me(e,t,s){let n=[],i=et("{","}",e);if(!i)return[e];let o=i.pre,r=i.post.length?me(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+nt+i.post,me(e,t,!0)):[e];let u;if(l)u=i.body.split(/\.\./);else if(u=At(i.body),u.length===1&&u[0]!==void 0&&(u=me(u[0],t,!1).map(Yn),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=tt(u[0]),h=tt(u[1]),m=Math.max(u[0].length,u[1].length),k=u.length===3&&u[2]!==void 0?Math.abs(tt(u[2])):1,S=es;h<d&&(k*=-1,S=ts);let y=u.some(Kn);f=[];for(let w=d;S(w,h);w+=k){let b;if(a)b=String.fromCharCode(w),b==="\\"&&(b="");else if(b=String(w),y){let v=m-b.length;if(v>0){let g=new Array(v+1).join("0");w<0?b="-"+g+b.slice(1):b=g+b}}f.push(b)}}else{f=[];for(let d=0;d<u.length;d++)f.push.apply(f,me(u[d],t,!1))}for(let d=0;d<f.length;d++)for(let h=0;h<r.length&&n.length<t;h++){let m=o+f[d]+r[h];(!s||l||m)&&n.push(m)}}return n}var ye=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var ns={"[: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]},be=e=>e.replace(/[[\]\\-]/g,"\\$&"),ss=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Rt=e=>e.join(""),Mt=(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 m=e.charAt(o);if((m==="!"||m==="^")&&o===s+1){l=!0,o++;continue}if(m==="]"&&r&&!a){p=o+1;break}if(r=!0,m==="\\"&&!a){a=!0,o++;continue}if(m==="["&&!a){for(let[k,[S,A,y]]of Object.entries(ns))if(e.startsWith(k,o)){if(u)return["$.",!1,e.length-s,!0];o+=k.length,y?i.push(S):n.push(S),c=c||A;continue e}}if(a=!1,u){m>u?n.push(be(u)+"-"+be(m)):m===u&&n.push(be(m)),u="",o++;continue}if(e.startsWith("-]",o+1)){n.push(be(m+"-")),o+=2;continue}if(e.startsWith("-",o+1)){u=m,o+=2;continue}n.push(be(m)),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 m=n[0].length===2?n[0].slice(-1):n[0];return[ss(m),!1,p-s,!1]}let f="["+(l?"^":"")+Rt(n)+"]",d="["+(l?"":"^")+Rt(i)+"]";return[n.length&&i.length?"("+f+"|"+d+")":n.length?f:d,c,p-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 is=new Set(["!","?","+","*","@"]),It=e=>is.has(e),os="(?!(?:^|/)\\.\\.?(?:$|/))",Ae="(?!\\.)",rs=new Set(["[","."]),as=new Set(["..","."]),cs=new Set("().*{}+?[]^$\\!"),ls=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),st="[^/]",Lt=st+"*?",Pt=st+"+?",te=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,h="";for(;d<t.length;){let m=t.charAt(d++);if(o||m==="\\"){o=!o,h+=m;continue}if(r){d===c+1?(m==="^"||m==="!")&&(a=!0):m==="]"&&!(d===c+2&&a)&&(r=!1),h+=m;continue}else if(m==="["){r=!0,c=d,a=!1,h+=m;continue}if(!i.noext&&It(m)&&t.charAt(d)==="("){s.push(h),h="";let k=new e(m,s);d=e.#p(t,k,d,i),s.push(k);continue}h+=m}return s.push(h),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(It(d)&&t.charAt(l)==="("){p.push(f),f="";let h=new e(d,p);p.push(h),l=e.#p(t,h,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[h,m,k,S]=typeof d=="string"?e.#h(d,this.#s,a):d.toRegExpSource(t);return this.#s=this.#s||k,this.#o=this.#o||S,h}).join(""),p="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&as.has(this.#e[0]))){let h=rs,m=s&&h.has(l.charAt(0))||l.startsWith("\\.")&&h.has(l.charAt(2))||l.startsWith("\\.\\.")&&h.has(l.charAt(4)),k=!s&&!t&&h.has(l.charAt(0));p=m?os:k?Ae:""}let u="";return this.isEnd()&&this.#n.#a&&this.#t?.type==="!"&&(u="(?:$|\\/)"),[p+l+u,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||!Ae?"":this.#f(!0);r===o&&(r=""),r&&(o=`(?:${o})(?:${r})*?`);let c="";if(this.type==="!"&&this.#u)c=(this.isStart()&&!s?Ae:"")+Pt;else{let a=this.type==="!"?"))"+(this.isStart()&&!s&&!t?Ae:"")+Lt+")":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+=(cs.has(l)?"\\":"")+l;continue}if(l==="*"){if(c)continue;c=!0,o+=n&&/^[*]+$/.test(t)?Pt:Lt,s=!0;continue}else c=!1;if(l==="\\"){a===t.length-1?o+="\\\\":i=!0;continue}if(l==="["){let[p,u,f,d]=Mt(t,a);if(f){o+=p,r=r||u,a+=f-1,s=s||d;continue}}if(l==="?"){o+=st,s=!0;continue}o+=ls(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 E=(e,t,s={})=>(ye(t),!s.nocomment&&t.charAt(0)==="#"?!1:new ne(t,s).match(e)),ps=/^\*+([^+@!?\*\[\(]*)$/,us=e=>t=>!t.startsWith(".")&&t.endsWith(e),fs=e=>t=>t.endsWith(e),ds=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),hs=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),gs=/^\*+\.\*+$/,ms=e=>!e.startsWith(".")&&e.includes("."),ys=e=>e!=="."&&e!==".."&&e.includes("."),bs=/^\.\*+$/,vs=e=>e!=="."&&e!==".."&&e.startsWith("."),ks=/^\*+$/,ws=e=>e.length!==0&&!e.startsWith("."),xs=e=>e.length!==0&&e!=="."&&e!=="..",Ss=/^\?+([^+@!?\*\[\(]*)?$/,Ts=([e,t=""])=>{let s=Ct([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},Es=([e,t=""])=>{let s=jt([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},$s=([e,t=""])=>{let s=jt([e]);return t?n=>s(n)&&n.endsWith(t):s},As=([e,t=""])=>{let s=Ct([e]);return t?n=>s(n)&&n.endsWith(t):s},Ct=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},jt=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},Ft=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Dt={win32:{sep:"\\"},posix:{sep:"/"}},Os=Ft==="win32"?Dt.win32.sep:Dt.posix.sep;E.sep=Os;var P=Symbol("globstar **");E.GLOBSTAR=P;var Rs="[^/]",Ms=Rs+"*?",Is="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Ls="(?:(?!(?:\\/|^)\\.).)*?",Ps=(e,t={})=>s=>E(s,e,t);E.filter=Ps;var L=(e,t={})=>Object.assign({},e,t),Ds=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return E;let t=E;return Object.assign((n,i,o={})=>t(n,i,L(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,L(e,o))}static defaults(i){return t.defaults(L(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,r={}){super(i,o,L(e,r))}static fromGlob(i,o={}){return t.AST.fromGlob(i,L(e,o))}},unescape:(n,i={})=>t.unescape(n,L(e,i)),escape:(n,i={})=>t.escape(n,L(e,i)),filter:(n,i={})=>t.filter(n,L(e,i)),defaults:n=>t.defaults(L(e,n)),makeRe:(n,i={})=>t.makeRe(n,L(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,L(e,i)),match:(n,i,o={})=>t.match(n,i,L(e,o)),sep:t.sep,GLOBSTAR:P})};E.defaults=Ds;var _t=(e,t={})=>(ye(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Ot(e,{max:t.braceExpandMax}));E.braceExpand=_t;var Ns=(e,t={})=>new ne(e,t).makeRe();E.makeRe=Ns;var Cs=(e,t,s={})=>{let n=new ne(t,s);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};E.match=Cs;var Nt=/[?*]|[+@!]\(.*?\)|\[|\]/,js=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ne=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,s={}){ye(t),s=s||{},this.options=s,this.pattern=t,this.platform=s.platform||Ft,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 m=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),k=!m&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),S=typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0]),A=!S&&s[0]===""&&s[1]===""&&s[2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3]),y=k?3:m?0:void 0,w=A?3:S?0:void 0;if(typeof y=="number"&&typeof w=="number"){let[b,v]=[t[y],s[w]];b.toLowerCase()===v.toLowerCase()&&(s[w]=b,w>y?s=s.slice(w):y>w&&(t=t.slice(y)))}}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===P){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 h=t[f];if(this.debug(`
|
|
2
|
-
globstar while`,t,
|
|
3
|
-
>>> no match, partial?`,t,
|
|
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
|
|
1
|
+
"use strict";var In=Object.create;var $e=Object.defineProperty;var Ln=Object.getOwnPropertyDescriptor;var Pn=Object.getOwnPropertyNames;var Nn=Object.getPrototypeOf,Dn=Object.prototype.hasOwnProperty;var Cn=(e,t)=>{for(var s in t)$e(e,s,{get:t[s],enumerable:!0})},St=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Pn(t))!Dn.call(e,i)&&i!==s&&$e(e,i,{get:()=>t[i],enumerable:!(n=Ln(t,i))||n.enumerable});return e};var S=(e,t,s)=>(s=e!=null?In(Nn(e)):{},St(t||!e||!e.__esModule?$e(s,"default",{value:e,enumerable:!0}):s,e)),jn=e=>St($e({},"__esModule",{value:!0}),e);var si={};Cn(si,{activate:()=>ti,deactivate:()=>ni});module.exports=jn(si);var V=S(require("vscode"));var F=S(require("vscode"));var oe=S(require("vscode")),Le=S(require("fs"));var Oe=S(require("path"));var tt=(e,t,s)=>{let n=e instanceof RegExp?Tt(e,s):e,i=t instanceof RegExp?Tt(t,s):t,o=n!==null&&i!=null&&Fn(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)}},Tt=(e,t)=>{let s=t.match(e);return s?s[0]:null},Fn=(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 f=n.pop();f!==void 0&&(c=[f,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 Et="\0SLASH"+Math.random()+"\0",At="\0OPEN"+Math.random()+"\0",st="\0CLOSE"+Math.random()+"\0",$t="\0COMMA"+Math.random()+"\0",Rt="\0PERIOD"+Math.random()+"\0",_n=new RegExp(Et,"g"),Vn=new RegExp(At,"g"),Wn=new RegExp(st,"g"),Bn=new RegExp($t,"g"),Hn=new RegExp(Rt,"g"),Gn=/\\\\/g,zn=/\\{/g,Un=/\\}/g,qn=/\\,/g,Jn=/\\./g,Xn=1e5;function nt(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Qn(e){return e.replace(Gn,Et).replace(zn,At).replace(Un,st).replace(qn,$t).replace(Jn,Rt)}function Zn(e){return e.replace(_n,"\\").replace(Vn,"{").replace(Wn,"}").replace(Bn,",").replace(Hn,".")}function Ot(e){if(!e)return[""];let t=[],s=tt("{","}",e);if(!s)return e.split(",");let{pre:n,body:i,post:o}=s,r=n.split(",");r[r.length-1]+="{"+i+"}";let c=Ot(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=Xn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),me(Qn(e),s,!0).map(Zn)}function Yn(e){return"{"+e+"}"}function Kn(e){return/^-?0\d/.test(e)}function es(e,t){return e<=t}function ts(e,t){return e>=t}function me(e,t,s){let n=[],i=tt("{","}",e);if(!i)return[e];let o=i.pre,r=i.post.length?me(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+st+i.post,me(e,t,!0)):[e];let f;if(l)f=i.body.split(/\.\./);else if(f=Ot(i.body),f.length===1&&f[0]!==void 0&&(f=me(f[0],t,!1).map(Yn),f.length===1))return r.map(d=>i.pre+f[0]+d);let u;if(l&&f[0]!==void 0&&f[1]!==void 0){let d=nt(f[0]),h=nt(f[1]),g=Math.max(f[0].length,f[1].length),b=f.length===3&&f[2]!==void 0?Math.abs(nt(f[2])):1,x=es;h<d&&(b*=-1,x=ts);let y=f.some(Kn);u=[];for(let w=d;x(w,h);w+=b){let v;if(a)v=String.fromCharCode(w),v==="\\"&&(v="");else if(v=String(w),y){let k=g-v.length;if(k>0){let m=new Array(k+1).join("0");w<0?v="-"+m+v.slice(1):v=m+v}}u.push(v)}}else{u=[];for(let d=0;d<f.length;d++)u.push.apply(u,me(f[d],t,!1))}for(let d=0;d<u.length;d++)for(let h=0;h<r.length&&n.length<t;h++){let g=o+u[d]+r[h];(!s||l||g)&&n.push(g)}}return n}var ye=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var ns={"[: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]},be=e=>e.replace(/[[\]\\-]/g,"\\$&"),ss=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),It=e=>e.join(""),Lt=(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,f="";e:for(;o<e.length;){let g=e.charAt(o);if((g==="!"||g==="^")&&o===s+1){l=!0,o++;continue}if(g==="]"&&r&&!a){p=o+1;break}if(r=!0,g==="\\"&&!a){a=!0,o++;continue}if(g==="["&&!a){for(let[b,[x,$,y]]of Object.entries(ns))if(e.startsWith(b,o)){if(f)return["$.",!1,e.length-s,!0];o+=b.length,y?i.push(x):n.push(x),c=c||$;continue e}}if(a=!1,f){g>f?n.push(be(f)+"-"+be(g)):g===f&&n.push(be(g)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(be(g+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=g,o+=2;continue}n.push(be(g)),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 g=n[0].length===2?n[0].slice(-1):n[0];return[ss(g),!1,p-s,!1]}let u="["+(l?"^":"")+It(n)+"]",d="["+(l?"":"^")+It(i)+"]";return[n.length&&i.length?"("+u+"|"+d+")":n.length?u:d,c,p-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 is=new Set(["!","?","+","*","@"]),Pt=e=>is.has(e),os="(?!(?:^|/)\\.\\.?(?:$|/))",Re="(?!\\.)",rs=new Set(["[","."]),as=new Set(["..","."]),cs=new Set("().*{}+?[]^$\\!"),ls=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),it="[^/]",Nt=it+"*?",Dt=it+"+?",te=class e{type;#n;#s;#o=!1;#e=[];#t;#r;#c;#a=!1;#i;#l;#f=!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,h="";for(;d<t.length;){let g=t.charAt(d++);if(o||g==="\\"){o=!o,h+=g;continue}if(r){d===c+1?(g==="^"||g==="!")&&(a=!0):g==="]"&&!(d===c+2&&a)&&(r=!1),h+=g;continue}else if(g==="["){r=!0,c=d,a=!1,h+=g;continue}if(!i.noext&&Pt(g)&&t.charAt(d)==="("){s.push(h),h="";let b=new e(g,s);d=e.#p(t,b,d,i),s.push(b);continue}h+=g}return s.push(h),d}let l=n+1,p=new e(null,s),f=[],u="";for(;l<t.length;){let d=t.charAt(l++);if(o||d==="\\"){o=!o,u+=d;continue}if(r){l===c+1?(d==="^"||d==="!")&&(a=!0):d==="]"&&!(l===c+2&&a)&&(r=!1),u+=d;continue}else if(d==="["){r=!0,c=l,a=!1,u+=d;continue}if(Pt(d)&&t.charAt(l)==="("){p.push(u),u="";let h=new e(d,p);p.push(h),l=e.#p(t,h,l,i);continue}if(d==="|"){p.push(u),u="",f.push(p),p=new e(null,s);continue}if(d===")")return u===""&&s.#e.length===0&&(s.#f=!0),p.push(u),u="",s.push(...f,p),l;u+=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[h,g,b,x]=typeof d=="string"?e.#h(d,this.#s,a):d.toRegExpSource(t);return this.#s=this.#s||b,this.#o=this.#o||x,h}).join(""),p="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&as.has(this.#e[0]))){let h=rs,g=s&&h.has(l.charAt(0))||l.startsWith("\\.")&&h.has(l.charAt(2))||l.startsWith("\\.\\.")&&h.has(l.charAt(4)),b=!s&&!t&&h.has(l.charAt(0));p=g?os:b?Re:""}let f="";return this.isEnd()&&this.#n.#a&&this.#t?.type==="!"&&(f="(?:$|\\/)"),[p+l+f,z(l),this.#s=!!this.#s,this.#o]}let n=this.type==="*"||this.type==="+",i=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#u(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||!Re?"":this.#u(!0);r===o&&(r=""),r&&(o=`(?:${o})(?:${r})*?`);let c="";if(this.type==="!"&&this.#f)c=(this.isStart()&&!s?Re:"")+Dt;else{let a=this.type==="!"?"))"+(this.isStart()&&!s&&!t?Re:"")+Nt+")":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]}#u(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+=(cs.has(l)?"\\":"")+l;continue}if(l==="*"){if(c)continue;c=!0,o+=n&&/^[*]+$/.test(t)?Dt:Nt,s=!0;continue}else c=!1;if(l==="\\"){a===t.length-1?o+="\\\\":i=!0;continue}if(l==="["){let[p,f,u,d]=Lt(t,a);if(u){o+=p,r=r||f,a+=u-1,s=s||d;continue}}if(l==="?"){o+=it,s=!0;continue}o+=ls(l)}return[o,z(t),!!s,r]}};var ot=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!1}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var E=(e,t,s={})=>(ye(t),!s.nocomment&&t.charAt(0)==="#"?!1:new ne(t,s).match(e)),ps=/^\*+([^+@!?\*\[\(]*)$/,fs=e=>t=>!t.startsWith(".")&&t.endsWith(e),us=e=>t=>t.endsWith(e),ds=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),hs=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),gs=/^\*+\.\*+$/,ms=e=>!e.startsWith(".")&&e.includes("."),ys=e=>e!=="."&&e!==".."&&e.includes("."),bs=/^\.\*+$/,vs=e=>e!=="."&&e!==".."&&e.startsWith("."),ks=/^\*+$/,ws=e=>e.length!==0&&!e.startsWith("."),xs=e=>e.length!==0&&e!=="."&&e!=="..",Ss=/^\?+([^+@!?\*\[\(]*)?$/,Ts=([e,t=""])=>{let s=Ft([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},Es=([e,t=""])=>{let s=_t([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},As=([e,t=""])=>{let s=_t([e]);return t?n=>s(n)&&n.endsWith(t):s},$s=([e,t=""])=>{let s=Ft([e]);return t?n=>s(n)&&n.endsWith(t):s},Ft=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},_t=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},Vt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Ct={win32:{sep:"\\"},posix:{sep:"/"}},Rs=Vt==="win32"?Ct.win32.sep:Ct.posix.sep;E.sep=Rs;var P=Symbol("globstar **");E.GLOBSTAR=P;var Os="[^/]",Ms=Os+"*?",Is="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Ls="(?:(?!(?:\\/|^)\\.).)*?",Ps=(e,t={})=>s=>E(s,e,t);E.filter=Ps;var L=(e,t={})=>Object.assign({},e,t),Ns=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return E;let t=E;return Object.assign((n,i,o={})=>t(n,i,L(e,o)),{Minimatch:class extends t.Minimatch{constructor(i,o={}){super(i,L(e,o))}static defaults(i){return t.defaults(L(e,i)).Minimatch}},AST:class extends t.AST{constructor(i,o,r={}){super(i,o,L(e,r))}static fromGlob(i,o={}){return t.AST.fromGlob(i,L(e,o))}},unescape:(n,i={})=>t.unescape(n,L(e,i)),escape:(n,i={})=>t.escape(n,L(e,i)),filter:(n,i={})=>t.filter(n,L(e,i)),defaults:n=>t.defaults(L(e,n)),makeRe:(n,i={})=>t.makeRe(n,L(e,i)),braceExpand:(n,i={})=>t.braceExpand(n,L(e,i)),match:(n,i,o={})=>t.match(n,i,L(e,o)),sep:t.sep,GLOBSTAR:P})};E.defaults=Ns;var Wt=(e,t={})=>(ye(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Mt(e,{max:t.braceExpandMax}));E.braceExpand=Wt;var Ds=(e,t={})=>new ne(e,t).makeRe();E.makeRe=Ds;var Cs=(e,t,s={})=>{let n=new ne(t,s);return e=e.filter(i=>n.match(i)),n.options.nonull&&!e.length&&e.push(t),e};E.match=Cs;var jt=/[?*]|[+@!]\(.*?\)|\[|\]/,js=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ne=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,s={}){ye(t),s=s||{},this.options=s,this.pattern=t,this.platform=s.platform||Vt,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]==="?"||!jt.test(o[2]))&&!jt.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 g=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),b=!g&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),x=typeof s[0]=="string"&&/^[a-z]:$/i.test(s[0]),$=!x&&s[0]===""&&s[1]===""&&s[2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3]),y=b?3:g?0:void 0,w=$?3:x?0:void 0;if(typeof y=="number"&&typeof w=="number"){let[v,k]=[t[y],s[w]];v.toLowerCase()===k.toLowerCase()&&(s[w]=v,w>y?s=s.slice(w):y>w&&(t=t.slice(y)))}}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],f=t[r];if(this.debug(s,p,f),p===!1)return!1;if(p===P){this.debug("GLOBSTAR",[s,p,f]);var u=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(;u<a;){var h=t[u];if(this.debug(`
|
|
2
|
+
globstar while`,t,u,s,d,h),this.matchOne(t.slice(u),s.slice(d),n))return this.debug("globstar found match!",u,a,h),!0;if(h==="."||h===".."||!i.dot&&h.charAt(0)==="."){this.debug("dot detected!",t,u,s,d);break}this.debug("globstar swallow a segment, and continue"),u++}return!!(n&&(this.debug(`
|
|
3
|
+
>>> no match, partial?`,t,u,s,d),u===a))}let g;if(typeof p=="string"?(g=f===p,this.debug("string match",p,f,g)):(g=p.test(f),this.debug("pattern match",p,f,g)),!g)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 Wt(this.pattern,this.options)}parse(t){ye(t);let s=this.options;if(t==="**")return P;if(t==="")return"";let n,i=null;(n=t.match(ks))?i=s.dot?xs:ws:(n=t.match(ps))?i=(s.nocase?s.dot?hs:ds:s.dot?us:fs)(n[1]):(n=t.match(Ss))?i=(s.nocase?s.dot?Es:Ts:s.dot?As:$s)(n):(n=t.match(gs))?i=s.dot?ys:ms:(n=t.match(bs))&&(i=vs);let o=te.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?Ms:s.dot?Is:Ls,i=new Set(s.nocase?["i"]:[]),o=t.map(a=>{let l=a.map(f=>{if(f instanceof RegExp)for(let u of f.flags.split(""))i.add(u);return typeof f=="string"?js(f):f===P?P:f._src});l.forEach((f,u)=>{let d=l[u+1],h=l[u-1];f!==P||h===P||(h===void 0?d!==void 0&&d!==P?l[u+1]="(?:\\/|"+n+"\\/)?"+d:l[u]=n:d===void 0?l[u-1]=h+"(?:\\/|\\/"+n+")?":d!==P&&(l[u-1]=h+"(?:\\/|\\/"+n+"\\/)"+d,l[u+1]=P))});let p=l.filter(f=>f!==P);if(this.partial&&p.length>=1){let f=[];for(let u=1;u<=p.length;u++)f.push(p.slice(0,u).join("/"));return"(?:"+f.join("|")+")"}return p.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 E.defaults(t).Minimatch}};E.AST=te;E.Minimatch=ne;E.escape=ot;E.unescape=z;var C="pickety.json",Me=["ts","tsx","js","jsx","mjs","cjs"],X=`**/*.{${Me.join(",")}}`,se=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 Ie(e,t){return Oe.relative(e,t).replace(/\\/g,"/")}function Bt(e,t){return E(e,t)||e===t}function ie(e){return Oe.join(e,C)}function W(e,t){return e==="instability"?t.toFixed(2):String(t)}async function Ht(e,t){let s=ie(e);if(Le.existsSync(s)&&await oe.window.showWarningMessage("pickety.json already exists. Overwrite?","Yes","No")!=="Yes")return;Le.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)),oe.window.showInformationMessage("Pickety: pickety.json created.");let i=await oe.workspace.openTextDocument(s);await oe.window.showTextDocument(i),t()}var lt=S(require("vscode"));var q=S(require("path"));function ve(e,t,s){let n=rt(e);return{allow:e.allow??!1,severity:e.severity??s,name:e.name??`rule[${t}]`,effectiveImporter:n?.path||e.importer||"*",isOnly:e.only||!!e.containedTo,isAllowStyle:(e.allow??!1)||!!e.containedTo||e.only}}function U(e,t,s){return!!(Bt(e,s)||s.includes("/")&&(E(t,s)||E(t,`**/${s}`)||E(t,`**/${s}/**`)))}function rt(e){if(e.containedTo)return typeof e.containedTo=="object"?e.containedTo:{path:e.containedTo}}function Q(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 Gt(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 Ut=Me.map(e=>`.${e}`),Fs=Ut.map(e=>`index${e}`),zt=/(\/\*[\s\S]*?\*\/|\/\/.*)|(['"`](?:\\.|[^'"`])*['"`])|((?:import|export)\s+(?:[\s\S]*?from\s+)?['"`]([^'"`]+)['"`])|(import\s*\(\s*['"`]([^'"`]+)['"`]\s*\))/gm;function _s(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(zt.lastIndex=0;(r=zt.exec(e))!==null;){let[c,a,l,p,f,u,d]=r;if(!(a||l)){if(p&&f){let h=o(r.index);t.push({specifier:f,line:h.line,character:h.character,length:p.length})}else if(u&&d){let h=o(r.index);t.push({specifier:d,line:h.line,character:h.character,length:u.length})}}}return t}function Vs(e,t,s){let{knownFiles:n,root:i,aliases:o}=s;for(let[r,c]of Object.entries(o))if(r.endsWith("/*")){let a=r.slice(0,-2),l=c.endsWith("/*")?c.slice(0,-2):c==="*"?"./":c;if(e.startsWith(a)){let p=e.replace(a,l);return at(q.resolve(i,p),n)}}else if(e===r)return at(q.resolve(i,c),n);if(e.startsWith(".")){let r=q.dirname(t),c=q.resolve(r,e);return at(c,n)}}function at(e,t){let s=A(e);if(t.has(s))return s;for(let n of Ut){let i=s+n;if(t.has(i))return i}for(let n of Fs){let i=s+"/"+n;if(t.has(i))return i}}function N(e,t,s){let n=A(q.relative(s,e));for(let[i,o]of Object.entries(t)){let r=o.endsWith("/*")?o.slice(0,-2)+"/**/*":o;if(E(n,r)||E(n,o))return i}}function Pe(e,t,s){let n=_s(t),i=[];for(let o of n){let r=Vs(o.specifier,e,s);r&&i.push({statement:o,resolvedPath:r})}return i}function re(e,t,s){let{root:n,knownFiles:i}=s,o=e.getModuleLevelGraph(t,n),r=Object.keys(t),c=new Map;for(let f of r)c.set(f,0);for(let f of i){let u=N(f,t,n);u&&c.set(u,(c.get(u)??0)+1)}let a=new Map;for(let f of r)a.set(f,0);for(let[,f]of o)for(let u of f)a.set(u,(a.get(u)??0)+1);let l=Ws(o,r),p=r.map(f=>{let u=a.get(f)??0,d=o.get(f)?.size??0,h=u+d;return{moduleName:f,fileCount:c.get(f)??0,afferentCoupling:u,efferentCoupling:d,instability:h===0?0:d/h,dependencyDepth:l.get(f)??0}});return p.sort((f,u)=>f.instability-u.instability),p}function Ws(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 qt(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 H=S(require("fs")),B=S(require("path"));function Ne(e,t,s){let n=e["boundary-diagrams"];if(!n)return;let i="picket-boundaries.mermaid",o;if(typeof n=="string"){let l=B.resolve(t,n);try{H.existsSync(l)&&H.statSync(l).isDirectory()?o=B.join(l,i):o=l}catch{o=l}}else o=B.join(t,i);let r=A(B.resolve(t));if(!A(B.resolve(o)).startsWith(r+"/")){console.error(`Pickety: Diagram output path "${n}" escapes the workspace root. Ignoring.`);return}let a=Bs(e,s);try{let l=B.dirname(o);return H.existsSync(l)||H.mkdirSync(l,{recursive:!0}),H.writeFileSync(o,a,"utf-8"),o}catch(l){console.error(`Pickety: Failed to write Mermaid diagram to ${o}`,l);return}}function ct(e){return e.replace(/"/g,"#quot;").replace(/\[/g,"#lsqb;").replace(/\]/g,"#rsqb;").replace(/\|/g,"#vert;").replace(/</g,"#lt;").replace(/>/g,"#gt;")}function Bs(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 h of t)r.set(h.moduleName,h);s.push(""),s.push(" %% Node Styles"),s.push(" classDef module fill:#f1f5f9,stroke:#64748b,stroke-width:2px;"),s.push(" classDef external fill:#ffffff,stroke:#94a3b8,stroke-width:1px,stroke-dasharray: 5 5;");let c=new Map,a=new Set(Object.keys(n));i.forEach((h,g)=>{let{effectiveImporter:b}=ve(h,g,o);a.add(b),a.add(h.imports)}),a.forEach(h=>{let g=h.split("/"),b=g.length>1?g[0]:"Base";c.has(b)||c.set(b,[]),c.get(b).push(h)});let l=new Map,p=0,f=h=>(l.has(h)||l.set(h,`n${p++}`),l.get(h));c.forEach((h,g)=>{s.push(""),s.push(` subgraph c${p++} [" ${ct(g)} "]`),h.forEach(b=>{let x=f(b),$=!!n[b],y=r.get(b),w=ct(b);y&&(w+=`<br/><small>Ca:${y.afferentCoupling} Ce:${y.efferentCoupling} I:${y.instability.toFixed(2)}</small>`);let v=b.includes("$")?`(["${w}"])`:`["${w}"]`,k=$?"module":"external";s.push(` ${x}${v}:::${k}`)}),s.push(" end")}),s.push(""),s.push(" %% Boundary Rules");let u=[],d=0;return i.forEach((h,g)=>{let{allow:b,name:x,effectiveImporter:$,isAllowStyle:y,isOnly:w}=ve(h,g,o),v=f($),k=f(h.imports),m=y?"-->":"-.->",D=b?"ALLOW":"DENY",he=h.message||`${D}: ${x}`;s.push(` ${v} ${m}|"${ct(he)}"| ${k}`);let ge=y?"#22c55e":"#ef4444",Ye=w?"4px":"2px",Ke=y?"":",stroke-dasharray:5";u.push(` linkStyle ${d++} stroke:${ge},stroke-width:${Ye}${Ke}`)}),s.concat(u).join(`
|
|
5
|
+
`)}var Jt=S(require("vscode"));function ae(e){return e?!0:(Jt.window.showErrorMessage("Pickety: No active configuration. Check pickety.json for errors."),!1)}function Xt(e,t,s){if(!ae(e))return;let n=re(t,e.modules,s),i=Ne(e,s.root,n);i?lt.window.showInformationMessage(`Pickety: Generated boundary diagram at ${i}`):lt.window.showErrorMessage("Pickety: Failed to generate diagram. Is 'boundary-diagrams' enabled in pickety.json?")}var je=S(require("vscode"));var Z;function Zt(e,t){if(Z){Z.reveal(),Z.webview.html=Qt(e,t);return}Z=je.window.createWebviewPanel("picketyHealth","Pickety: Module Health",je.ViewColumn.One,{enableScripts:!1}),Z.webview.html=Qt(e,t),Z.onDidDispose(()=>{Z=void 0})}function De(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 Ce(e,t){return t===void 0?"":e>t?"exceeds":e>=t*.8?"approaching":""}function Qt(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">
|
|
@@ -115,13 +115,13 @@ globstar while`,t,f,s,d,h),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,p=r.instability,
|
|
118
|
+
${e.map((r,c)=>{let a=r.afferentCoupling/s,l=r.efferentCoupling/n,p=r.instability,f=r.dependencyDepth/i,u=Ce(r.afferentCoupling,t?.maxAfferentCoupling),d=Ce(r.efferentCoupling,t?.maxEfferentCoupling),h=Ce(r.instability,t?.maxInstability),g=Ce(r.dependencyDepth,t?.maxDepth);return`<tr${c%2===1?' class="alt"':""}>
|
|
119
119
|
<td class="module-name">${Hs(r.moduleName)}</td>
|
|
120
120
|
<td class="num">${r.fileCount}</td>
|
|
121
|
-
<td class="num ${
|
|
122
|
-
<td class="num ${d}" style="${
|
|
123
|
-
<td class="num ${h}" style="${
|
|
124
|
-
<td class="num ${
|
|
121
|
+
<td class="num ${u}" style="${De(a)}">${W("ca",r.afferentCoupling)}</td>
|
|
122
|
+
<td class="num ${d}" style="${De(l)}">${W("ce",r.efferentCoupling)}</td>
|
|
123
|
+
<td class="num ${h}" style="${De(p)}">${W("instability",r.instability)}</td>
|
|
124
|
+
<td class="num ${g}" style="${De(f)}">${W("depth",r.dependencyDepth)}</td>
|
|
125
125
|
</tr>`}).join(`
|
|
126
126
|
`)}
|
|
127
127
|
</tbody>
|
|
@@ -136,18 +136,18 @@ globstar while`,t,f,s,d,h),this.matchOne(t.slice(f),s.slice(d),n))return this.de
|
|
|
136
136
|
`:""}
|
|
137
137
|
</div>
|
|
138
138
|
</body>
|
|
139
|
-
</html>`}function Hs(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function
|
|
140
|
-
`;break;case 114:y+="\r";break;case 116:y+=" ";break;case 117:let
|
|
141
|
-
`),c++,l=n,r=14;switch(y){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=
|
|
142
|
-
`+" ".repeat(t)),"\r":new Array(
|
|
143
|
-
`+" ".repeat(t))}," ":{"\n":new Array(
|
|
144
|
-
`+" ".repeat(t)),"\r":new Array(
|
|
145
|
-
`+" ".repeat(t))}},
|
|
139
|
+
</html>`}function Hs(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Yt(e,t,s){if(!ae(e))return;let n=re(t,e.modules,s);Zt(n,e.health)}var j=S(require("vscode")),Kt=S(require("path"));async function en(e,t,s){let n=s.root,i=j.window.activeTextEditor;if(!i){j.window.showErrorMessage("Pickety: No active file.");return}if(!ae(e))return;let o=A(i.document.uri.fsPath),r=t.getTransitiveDependents(o);if(r.size===0){j.window.showInformationMessage("Pickety: No dependents found for this file.");return}let c=new Map;for(let u of r){let d=N(u,e.modules,n)??"(unmatched)";c.has(d)||c.set(d,[]),c.get(d).push(Ie(n,u))}let a=[];for(let[u,d]of c){a.push({label:u,kind:j.QuickPickItemKind.Separator});for(let h of d)a.push({label:h,description:u})}let l=Ie(n,o),p=c.size,f=await j.window.showQuickPick(a,{title:`Impact: ${l} (${r.size} files across ${p} modules)`,placeHolder:"Select a file to open"});if(f&&f.kind!==j.QuickPickItemKind.Separator){let u=Kt.join(n,f.label),d=await j.workspace.openTextDocument(u);await j.window.showTextDocument(d)}}var O=S(require("vscode")),mt=S(require("path")),yt=S(require("fs"));function we(e,t=!1){let s=e.length,n=0,i="",o=0,r=16,c=0,a=0,l=0,p=0,f=0;function u(y,w){let v=0,k=0;for(;v<y||!w;){let m=e.charCodeAt(n);if(m>=48&&m<=57)k=k*16+m-48;else if(m>=65&&m<=70)k=k*16+m-65+10;else if(m>=97&&m<=102)k=k*16+m-97+10;else break;n++,v++}return v<y&&(k=-1),k}function d(y){n=y,i="",o=0,r=16,f=0}function h(){let y=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&ce(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&ce(e.charCodeAt(n)))for(n++;n<e.length&&ce(e.charCodeAt(n));)n++;else return f=3,e.substring(y,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&&ce(e.charCodeAt(n))){for(n++;n<e.length&&ce(e.charCodeAt(n));)n++;w=n}else f=3;return e.substring(y,w)}function g(){let y="",w=n;for(;;){if(n>=s){y+=e.substring(w,n),f=2;break}let v=e.charCodeAt(n);if(v===34){y+=e.substring(w,n),n++;break}if(v===92){if(y+=e.substring(w,n),n++,n>=s){f=2;break}switch(e.charCodeAt(n++)){case 34:y+='"';break;case 92:y+="\\";break;case 47:y+="/";break;case 98:y+="\b";break;case 102:y+="\f";break;case 110:y+=`
|
|
140
|
+
`;break;case 114:y+="\r";break;case 116:y+=" ";break;case 117:let m=u(4,!0);m>=0?y+=String.fromCharCode(m):f=4;break;default:f=5}w=n;continue}if(v>=0&&v<=31)if(ke(v)){y+=e.substring(w,n),f=2;break}else f=6;n++}return y}function b(){if(i="",f=0,o=n,a=c,p=l,n>=s)return o=s,r=17;let y=e.charCodeAt(n);if(pt(y)){do n++,i+=String.fromCharCode(y),y=e.charCodeAt(n);while(pt(y));return r=15}if(ke(y))return n++,i+=String.fromCharCode(y),y===13&&e.charCodeAt(n)===10&&(n++,i+=`
|
|
141
|
+
`),c++,l=n,r=14;switch(y){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=g(),r=10;case 47:let w=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<s&&!ke(e.charCodeAt(n));)n++;return i=e.substring(w,n),r=12}if(e.charCodeAt(n+1)===42){n+=2;let v=s-1,k=!1;for(;n<v;){let m=e.charCodeAt(n);if(m===42&&e.charCodeAt(n+1)===47){n+=2,k=!0;break}n++,ke(m)&&(m===13&&e.charCodeAt(n)===10&&n++,c++,l=n)}return k||(n++,f=1),i=e.substring(w,n),r=13}return i+=String.fromCharCode(y),n++,r=16;case 45:if(i+=String.fromCharCode(y),n++,n===s||!ce(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+=h(),r=11;default:for(;n<s&&x(y);)n++,y=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(y),n++,r=16}}function x(y){if(pt(y)||ke(y))return!1;switch(y){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function $(){let y;do y=b();while(y>=12&&y<=15);return y}return{setPosition:d,getPosition:()=>n,scan:t?$:b,getToken:()=>r,getTokenValue:()=>i,getTokenOffset:()=>o,getTokenLength:()=>n-o,getTokenStartLine:()=>a,getTokenStartCharacter:()=>o-p,getTokenError:()=>f}}function pt(e){return e===32||e===9}function ke(e){return e===10||e===13}function ce(e){return e>=48&&e<=57}var tn;(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"})(tn||(tn={}));var I=new Array(20).fill(0).map((e,t)=>" ".repeat(t)),le=200,ft={" ":{"\n":new Array(le).fill(0).map((e,t)=>`
|
|
142
|
+
`+" ".repeat(t)),"\r":new Array(le).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(le).fill(0).map((e,t)=>`\r
|
|
143
|
+
`+" ".repeat(t))}," ":{"\n":new Array(le).fill(0).map((e,t)=>`
|
|
144
|
+
`+" ".repeat(t)),"\r":new Array(le).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(le).fill(0).map((e,t)=>`\r
|
|
145
|
+
`+" ".repeat(t))}},nn=[`
|
|
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&&!xe(e,o-1);)o--;let v=c;for(;v<e.length&&!xe(e,v);)v++;i=e.substring(o,v),n=zs(i,s)}else i=e,n=0,o=0,r=0,c=e.length;let a=Us(s,e),l=nn.includes(a),p=0,f=0,u;s.insertSpaces?u=I[s.tabSize||4]??pe(I[1],s.tabSize||4):u=" ";let d=u===" "?" ":" ",h=we(i,!1),g=!1;function b(){if(p>1)return pe(a,p)+pe(u,n+f);let v=u.length*(n+f);return!l||v>ft[d][a].length?a+pe(u,n+f):v<=0?a:ft[d][a][v]}function x(){let v=h.scan();for(p=0;v===15||v===14;)v===14&&s.keepLines?p+=1:v===14&&(p=1),v=h.scan();return g=v===16||h.getTokenError()!==0,v}let $=[];function y(v,k,m){!g&&(!t||k<c&&m>r)&&e.substring(k,m)!==v&&$.push({offset:k,length:m-k,content:v})}let w=x();if(s.keepLines&&p>0&&y(pe(a,p),0,0),w!==17){let v=h.getTokenOffset()+o,k=u.length*n<20&&s.insertSpaces?I[u.length*n]:pe(u,n);y(k,o,v)}for(;w!==17;){let v=h.getTokenOffset()+h.getTokenLength()+o,k=x(),m="",D=!1;for(;p===0&&(k===12||k===13);){let ge=h.getTokenOffset()+o;y(I[1],v,ge),v=h.getTokenOffset()+h.getTokenLength()+o,D=k===12,m=D?b():"",k=x()}if(k===2)w!==1&&f--,s.keepLines&&p>0||!s.keepLines&&w!==1?m=b():s.keepLines&&(m=I[1]);else if(k===4)w!==3&&f--,s.keepLines&&p>0||!s.keepLines&&w!==3?m=b():s.keepLines&&(m=I[1]);else{switch(w){case 3:case 1:f++,s.keepLines&&p>0||!s.keepLines?m=b():m=I[1];break;case 5:s.keepLines&&p>0||!s.keepLines?m=b():m=I[1];break;case 12:m=b();break;case 13:p>0?m=b():D||(m=I[1]);break;case 6:s.keepLines&&p>0?m=b():D||(m=I[1]);break;case 10:s.keepLines&&p>0?m=b():k===6&&!D&&(m="");break;case 7:case 8:case 9:case 11:case 2:case 4:s.keepLines&&p>0?m=b():(k===12||k===13)&&!D?m=I[1]:k!==5&&k!==17&&(g=!0);break;case 16:g=!0;break}p>0&&(k===12||k===13)&&(m=b())}k===17&&(s.keepLines&&p>0?m=b():m=s.insertFinalNewline?a:"");let he=h.getTokenOffset()+o;y(m,v,he),w=k}return $}function pe(e,t){let s="";for(let n=0;n<t;n++)s+=e;return s}function zs(e,t){let s=0,n=0,i=t.tabSize||4;for(;s<e.length;){let o=e.charAt(s);if(o===I[1])n++;else if(o===" ")n+=i;else break;s++}return Math.floor(n/i)}function Us(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 xe;(function(e){e.DEFAULT={allowTrailingComma:!1}})(xe||(xe={}));function tn(e,t=[],s=xe.DEFAULT){let n=null,i=[],o=[];function r(a){Array.isArray(i)?i.push(a):n!==null&&(i[n]=a)}return ut(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 Fe(e,t=[],s=xe.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}ut(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:Js(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 Se(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 ut(e,t,s=xe.DEFAULT){let n=ke(e,!1),i=[],o=0;function r(T){return T?()=>o===0&&T(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function c(T){return T?O=>o===0&&T(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function a(T){return T?O=>o===0&&T(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}function l(T){return T?()=>{o>0?o++:T(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice())===!1&&(o=1)}:()=>!0}function p(T){return T?()=>{o>0&&o--,o===0&&T(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}let u=l(t.onObjectBegin),f=a(t.onObjectProperty),d=p(t.onObjectEnd),h=l(t.onArrayBegin),m=p(t.onArrayEnd),k=a(t.onLiteralValue),S=c(t.onSeparator),A=r(t.onComment),y=c(t.onError),w=s&&s.disallowComments,b=s&&s.allowTrailingComma;function v(){for(;;){let T=n.scan();switch(n.getTokenError()){case 4:g(14);break;case 5:g(15);break;case 3:g(13);break;case 1:w||g(11);break;case 2:g(12);break;case 6:g(16);break}switch(T){case 12:case 13:w?g(10):A();break;case 16:g(1);break;case 15:case 14:break;default:return T}}}function g(T,O=[],kt=[]){if(y(T),O.length+kt.length>0){let Ee=n.getToken();for(;Ee!==17;){if(O.indexOf(Ee)!==-1){v();break}else if(kt.indexOf(Ee)!==-1)break;Ee=v()}}}function C(T){let O=n.getTokenValue();return T?k(O):(f(O),i.push(O)),v(),!0}function ge(){switch(n.getToken()){case 11:let T=n.getTokenValue(),O=Number(T);isNaN(O)&&(g(2),O=0),k(O);break;case 7:k(null);break;case 8:k(!0);break;case 9:k(!1);break;default:return!1}return v(),!0}function Ye(){return n.getToken()!==10?(g(3,[],[2,5]),!1):(C(!1),n.getToken()===6?(S(":"),v(),Ke()||g(4,[],[2,5])):g(5,[],[2,5]),i.pop(),!0)}function Rn(){u(),v();let T=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(T||g(4,[],[]),S(","),v(),n.getToken()===2&&b)break}else T&&g(6,[],[]);Ye()||g(4,[],[2,5]),T=!0}return d(),n.getToken()!==2?g(7,[2],[]):v(),!0}function Mn(){h(),v();let T=!0,O=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(O||g(4,[],[]),S(","),v(),n.getToken()===4&&b)break}else O&&g(6,[],[]);T?(i.push(0),T=!1):i[i.length-1]++,Ke()||g(4,[],[4,5]),O=!0}return m(),T||i.pop(),n.getToken()!==4?g(8,[4],[]):v(),!0}function Ke(){switch(n.getToken()){case 3:return Mn();case 1:return Rn();case 10:return C(!0);default:return ge()}}return v(),n.getToken()===17?s.allowEmptyContent?!0:(g(4,[],[]),!1):Ke()?(n.getToken()!==17&&g(9,[],[]),!0):(g(4,[],[]),!1)}function Js(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 nn(e,t,s,n){let i=t.slice(),r=Fe(e,[]),c,a;for(;i.length>0&&(a=i.pop(),c=Se(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=Se(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 K(e,{offset:u,length:f-u,content:""},n)}else return K(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 K(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 K(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],h=d.offset+d.length,m=c.offset+c.length;f={offset:h,length:m-2-h,content:""}}else f={offset:u.offset,length:c.children[p+1].offset-u.offset,content:""};return K(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 K(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 K(e,{offset:r?r.offset:0,length:r?r.length:0,content:JSON.stringify(s)},n)}}function K(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&&!we(n,i-1);)i--;for(;o<n.length&&!we(n,o);)o++}let r=pt(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 sn;(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"})(sn||(sn={}));var on;(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"})(on||(on={}));var _e=tn,an=Fe,Ve=Se;var rn;(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"})(rn||(rn={}));function cn(e,t,s,n){return nn(e,t,s,n)}async function ln(e,t){let s=ht.join(e,D);if(!gt.existsSync(s))return;let n=await R.workspace.openTextDocument(R.Uri.file(s)),i=await R.window.showTextDocument(n),o=n.getText(),r=an(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 R.Selection(l,l),i.revealRange(new R.Range(l,l),R.TextEditorRevealType.InCenter)}}async function pn(e,t,s){let n=ht.join(e,D);if(!gt.existsSync(n))return;let i=await R.workspace.openTextDocument(R.Uri.file(n)),o=i.getText(),r=cn(o,["rules","module-boundaries","rules",-1],{importer:t,imports:s,allow:!0,name:`allow-${t}-to-${s}`},{formattingOptions:{insertSpaces:!0,tabSize:2}}),c=new R.WorkspaceEdit;for(let a of r)c.replace(i.uri,new R.Range(i.positionAt(a.offset),i.positionAt(a.offset+a.length)),a.content);await R.workspace.applyEdit(c),await i.save(),R.window.showInformationMessage(`Added exception: Allow '${s}' in '${t}'`)}function un(e,t,s,n){e.subscriptions.push(F.commands.registerCommand("pickety.refresh",()=>{t.reload(),t.reloadAliases(),F.window.showInformationMessage("Pickety: Configuration refreshed")})),e.subscriptions.push(F.commands.registerCommand("pickety.generateDiagram",()=>qt(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(F.commands.registerCommand("pickety.showImpact",()=>Yt(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(F.commands.registerCommand("pickety.showHealth",()=>Qt(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(F.commands.registerCommand("pickety.goToRule",(i,o)=>ln(i,o))),e.subscriptions.push(F.commands.registerCommand("pickety.allowImport",(i,o,r)=>pn(i,o,r))),e.subscriptions.push(F.commands.registerCommand("pickety.init",()=>Wt(n,()=>t.reload())))}var G=x(require("vscode"));var mn=x(require("path")),We=x(require("fs"));function fn(e,t,s,n){if(typeof e.containedTo=="object"&&e.containedTo!==null){let i=e.containedTo;if(typeof i.path!="string"&&n.push({message:`Rule #${t}: "containedTo.path" is required and must be a string`,path:`${s}.containedTo.path`}),i.unless!==void 0)if(typeof i.unless!="object"||i.unless===null||Array.isArray(i.unless))n.push({message:`Rule #${t}: "containedTo.unless" must be an object`,path:`${s}.containedTo.unless`});else{let o=i.unless;Object.keys(o).length===0&&n.push({message:`Rule #${t}: "containedTo.unless" must not be empty`,path:`${s}.containedTo.unless`}),typeof e.imports=="string"&&!e.imports.match(/\$[\w-]+/)&&n.push({message:`Rule #${t}: "containedTo.unless" requires "imports" to contain at least one $variable`,path:`${s}.containedTo.unless`});for(let[c,a]of Object.entries(o))c.startsWith("$")||n.push({message:`Rule #${t}: "containedTo.unless" key "${c}" must start with $`,path:`${s}.containedTo.unless`}),typeof a!="string"&&n.push({message:`Rule #${t}: "containedTo.unless.${c}" must be a string`,path:`${s}.containedTo.unless.${c}`})}}else typeof e.containedTo!="string"&&n.push({message:`Rule #${t}: "containedTo" must be a string or object with a "path" property`,path:`${s}.containedTo`})}function dn(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,u=typeof p.containedTo=="string"||typeof p.containedTo=="object"&&p.containedTo!==null;typeof p.importer!="string"&&!u&&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&&fn(p,a,l,t),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 hn(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 gn(e){let t=[];if(typeof e!="object"||e===null)return{ok:!1,errors:[{message:"Configuration must be a JSON object"}]};let s=e,n=Zs(s.modules,t),i=dn(s.rules,t),o=Ys(s["boundary-diagrams"],t),r=hn(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 Zs(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 Ys(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 yn(e){let t=mn.join(e,D);if(!We.existsSync(t))return{ok:!1,errors:[{message:`File not found: ${D}`}]};try{let s=We.readFileSync(t,"utf-8"),n;try{n=_e(s)}catch(i){return{ok:!1,errors:[{message:`pickety.json is not valid JSONC: ${i instanceof Error?i.message:String(i)}`}]}}return gn(n)}catch(s){return{ok:!1,errors:[{message:`Failed to read pickety.json: ${s instanceof Error?s.message:String(s)}`}]}}}var Be=x(require("fs")),J=x(require("path"));function bn(e,t){if(t<0)return[];let s=[],n;try{n=Be.readdirSync(e,{withFileTypes:!0})}catch{return s}for(let i of n)!se.has(i.name)&&i.isFile()&&/^tsconfig(\..+)?\.json$/.test(i.name)&&s.push(J.join(e,i.name));for(let i of n)!se.has(i.name)&&i.isDirectory()&&s.push(...bn(J.join(e,i.name),t-1));return s}function vn(e){let t={},s=bn(e,4);for(let n of s)try{let i=Be.readFileSync(n,"utf-8"),r=_e(i).compilerOptions;if(!r?.paths)continue;let c=J.dirname(n),a=J.relative(e,c),l=r.baseUrl||".";for(let[p,u]of Object.entries(r.paths))if(Array.isArray(u)&&u.length>0){let f=u[0];t[p]||(t[p]=$(J.join(a,l,f)))}}catch{}return t}var He=class{constructor(t){this.workspaceRoot=t;this.registerWatchers()}config;aliases={};_onConfigChanged=new G.EventEmitter;onConfigChanged=this._onConfigChanged.event;_onAliasesChanged=new G.EventEmitter;onAliasesChanged=this._onAliasesChanged.event;disposables=[];getConfig(){return this.config}getAliases(){return this.aliases}reload(){let t=yn(this.workspaceRoot);this.config=t.ok?t.config:void 0,this._onConfigChanged.fire(t)}reloadAliases(){this.aliases=vn(this.workspaceRoot),this._onAliasesChanged.fire(this.aliases)}registerWatchers(){let t=G.workspace.createFileSystemWatcher(new G.RelativePattern(this.workspaceRoot,D));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=G.workspace.createFileSystemWatcher(new G.RelativePattern(this.workspaceRoot,"**/tsconfig*.json"));this.disposables.push(s);let n=i=>i.fsPath.split(/[\\/]/).some(r=>se.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 Ue=x(require("vscode")),kn=x(require("fs"));function mt(e,t,s){let n=new Set,i=Pe(e,t,s),o=$(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=N(a,s,n);l&&r.add(l)}let c=new Set;for(let a of o){let l=N(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=N(i,t,s);if(r){n.has(r)||n.set(r,new Set);for(let c of o){let a=N(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(Q,"**/node_modules/**");return this.knownFiles=new Set(t.map(s=>$(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=$(t);this.knownFiles.add(i);try{let o=mt(i,s,n);this.importGraph.updateFile(i,o)}catch{}}removeFile(t){let s=$(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=kn.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 Bt(n)}computeHealthViolations(t,s){if(!t.health||this.isLargeWorkspace)return[];this.ensureGraphReady(s);let n=re(this.importGraph,t.modules,s);return zt(n,t.health)}};var ee=x(require("vscode")),qe=class{item;constructor(t){this.item=ee.window.createStatusBarItem(ee.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 ee.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 ee.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=x(require("vscode")),fe=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 M=x(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 M.Range(i.line,i.character,i.line,i.character+i.length),r=i.severity==="error"?M.DiagnosticSeverity.Error:M.DiagnosticSeverity.Warning,c=new M.Diagnostic(o,i.message,r);return c.source="pickety",i.ruleName&&(c.code={value:i.ruleName,target:M.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 M.Diagnostic(new M.Range(0,0,0,100),`Circular dependency detected: ${o}`,M.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=W(i.metric,i.value),r=W(i.metric,i.threshold),c=new M.Diagnostic(new M.Range(0,0,0,100),`Module "${i.moduleName}" has ${i.metric} of ${o} (max: ${r})`,M.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 X=x(require("vscode"));var vt=x(require("path"));function wn(e){return e.match(/\$[\w-]+/g)||[]}function bt(e,t,s){let n=e.split("/"),i=t.split("/"),o=0,r=n.filter(a=>a!=="**").length,c=i.length-r;for(let a=o;a<=c;a++){let l=xn(n,i,a,s);if(l)return l}}function xn(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=xn(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 Te(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}function Sn(e,t,s,n,i,o,r,c,a,l,p,u,f){if(s){let d=bt(e.imports,p,t);if(d){if(Ks(e,d))return;let h=Te(i,t,d);if(!U(c,a,h)){let k=e.message||`Module "${c}" is not allowed to import from "${l}" (contained to "${h}")`;return Z(u,f,r,k,o,c,l)}}}else{let d=bt(i,a,t);if(!d)return;if(n){let h=Te(e.imports,t,"*"),m=Te(e.imports,t,d),k=U(l,p,h),S=U(l,p,m);if(k&&!S){let A=e.message||`Import must match scoped pattern "${m}"`;return Z(u,f,r,A,o,c,l)}}else{let h=Te(e.imports,t,d);if(U(l,p,h)){let k=e.message||`Module "${c}" cannot import from "${l}"`;return Z(u,f,r,k,o,c,l)}}}}function Ks(e,t){let s=ot(e);if(s&&s.unless){let n=Object.entries(s.unless);return n.length>0&&n.every(([i,o])=>t[i]===o)}return!1}function Tn(e,t,s,n,i,o,r,c,a){let{allow:l,severity:p,name:u,effectiveImporter:f,isOnly:d}=Le(e,t,s),h=wn(d?e.imports:f);if(h.length>0)return Sn(e,h,d,l,f,p,u,n,i,o,r,c,a);let m=U(n,i,f),k=U(o,r,e.imports);if(d){if(k&&!m){let S=e.message||(e.containedTo?`Import is restricted: "${o}" is contained to "${f}"`:`Module "${o}" can only be imported by "${f}"`);return Z(c,a,u,S,p,n,o)}}else if(m&&k&&!l){let S=e.message||`Module "${n}" cannot import from "${o}"`;return Z(c,a,u,S,p,n,o)}}function En(e,t,s,n){let i=[],{modules:o}=s,{severity:r,rules:c}=s.rules["module-boundaries"],{root:a}=n,l=N(e,o,a);if(!l)return[];let p=$(vt.relative(a,e)),u=Pe(e,t,n);for(let{statement:f,resolvedPath:d}of u){let h=N(d,o,a);if(!h)continue;let m=$(vt.relative(a,d));c.forEach((k,S)=>{let A=Tn(k,S,r,l,p,h,m,e,f);A&&i.push(A)})}return i}function $n(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}})}var _=x(require("vscode")),An=x(require("path"));function On(e,t,s,n){s.appendLine("Pickety: Configuration error(s) found:");let i=_.Uri.file(An.join(t,D)),o=e.map(r=>{s.appendLine(` - ${r.message}${r.path?` (at ${r.path})`:""}`);let c=new _.Range(0,0,0,100),a=new _.Diagnostic(c,r.message,_.DiagnosticSeverity.Error);return a.source="pickety",r.path&&(a.code=r.path),a});n.set(i,o),_.window.showErrorMessage("Pickety: Configuration error. Check the Problems panel or Output channel for details.")}var Xe=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=fe.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=De(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||On(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 X.workspace.textDocuments)this.isSourceFile(r)&&s.push({uri:r.uri,violations:this.checkDocument(r,t)});let n=s.flatMap(r=>r.violations),i=$n(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 En(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=X.Uri.file(ie(this.workspaceRoot));this.diagnosticManager.setCircularDiagnostics(n,s)}checkHealthThresholds(t){let s=this.analysisService.computeHealthViolations(t,this.analysisService.getWorkspaceContext()),n=X.Uri.file(ie(this.workspaceRoot));this.diagnosticManager.setHealthDiagnostics(n,s)}registerEventListeners(){this.disposables.push(X.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(X.workspace.onDidOpenTextDocument(s=>this.analyzeDocument(s)));let t=X.workspace.createFileSystemWatcher(Q);this.disposables.push(t),t.onDidCreate(s=>{this.analysisService.getKnownFiles().add($(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 de=x(require("vscode")),Qe=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 de.CodeAction(`Go to Pickety rule: ${r}`,de.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 de.CodeAction(`Allow imports from '${a.targetModule}' in '${a.sourceModule}'`,de.CodeActionKind.QuickFix);l.command={command:"pickety.allowImport",title:"Allow Import",arguments:[this.workspaceRoot,a.sourceModule,a.targetModule]},i.push(l)}}return i}};var he=x(require("vscode"));var Ze=class{constructor(t,s,n){this.importGraph=t;this.workspaceRoot=s;this.configRef=n}_onDidChangeCodeLenses=new he.EventEmitter;onDidChangeCodeLenses=this._onDidChangeCodeLenses.event;refresh(){this._onDidChangeCodeLenses.fire()}provideCodeLenses(t){let s=this.configRef.config;if(!s)return[];let n=$(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 he.Range(0,0,0,0);return[new he.CodeLens(r,{title:o.join(" | "),command:"pickety.showImpact",tooltip:"Show full impact analysis for this file"})]}dispose(){this._onDidChangeCodeLenses.dispose()}};var ei=[];async function ti(e){let t=fe.getInstance();t.logEvent("extension_activate");let s=V.window.createOutputChannel("Pickety");e.subscriptions.push(s),t.setOutputChannel(s);let n=V.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=V.languages.createDiagnosticCollection("pickety");e.subscriptions.push(c);let a=new Je(c);e.subscriptions.push(a);let l=new Qe(n);e.subscriptions.push(V.languages.registerCodeActionsProvider({scheme:"file",language:"*"},l,{providedCodeActionKinds:[V.CodeActionKind.QuickFix]}));let p=new Ze(o.getImportGraph(),n,{config:void 0});e.subscriptions.push(p);let u=new Xe(e,i,o,a,r,s,n);u.setCodeLensProvider(p),e.subscriptions.push(u),p.configRef=u.configRef,e.subscriptions.push(V.languages.registerCodeLensProvider({scheme:"file",pattern:Q},p)),un(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 ni(){ei.forEach(e=>e.dispose())}0&&(module.exports={activate,deactivate});
|
|
152
|
+
`}function xe(e,t){return`\r
|
|
153
|
+
`.indexOf(e.charAt(t))!==-1}var Se;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Se||(Se={}));function sn(e,t=[],s=Se.DEFAULT){let n=null,i=[],o=[];function r(a){Array.isArray(i)?i.push(a):n!==null&&(i[n]=a)}return dt(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 Fe(e,t=[],s=Se.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}dt(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:Js(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 Te(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 dt(e,t,s=Se.DEFAULT){let n=we(e,!1),i=[],o=0;function r(T){return T?()=>o===0&&T(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function c(T){return T?R=>o===0&&T(R,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function a(T){return T?R=>o===0&&T(R,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice()):()=>!0}function l(T){return T?()=>{o>0?o++:T(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>i.slice())===!1&&(o=1)}:()=>!0}function p(T){return T?()=>{o>0&&o--,o===0&&T(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}let f=l(t.onObjectBegin),u=a(t.onObjectProperty),d=p(t.onObjectEnd),h=l(t.onArrayBegin),g=p(t.onArrayEnd),b=a(t.onLiteralValue),x=c(t.onSeparator),$=r(t.onComment),y=c(t.onError),w=s&&s.disallowComments,v=s&&s.allowTrailingComma;function k(){for(;;){let T=n.scan();switch(n.getTokenError()){case 4:m(14);break;case 5:m(15);break;case 3:m(13);break;case 1:w||m(11);break;case 2:m(12);break;case 6:m(16);break}switch(T){case 12:case 13:w?m(10):$();break;case 16:m(1);break;case 15:case 14:break;default:return T}}}function m(T,R=[],xt=[]){if(y(T),R.length+xt.length>0){let Ae=n.getToken();for(;Ae!==17;){if(R.indexOf(Ae)!==-1){k();break}else if(xt.indexOf(Ae)!==-1)break;Ae=k()}}}function D(T){let R=n.getTokenValue();return T?b(R):(u(R),i.push(R)),k(),!0}function he(){switch(n.getToken()){case 11:let T=n.getTokenValue(),R=Number(T);isNaN(R)&&(m(2),R=0),b(R);break;case 7:b(null);break;case 8:b(!0);break;case 9:b(!1);break;default:return!1}return k(),!0}function ge(){return n.getToken()!==10?(m(3,[],[2,5]),!1):(D(!1),n.getToken()===6?(x(":"),k(),et()||m(4,[],[2,5])):m(5,[],[2,5]),i.pop(),!0)}function Ye(){f(),k();let T=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(T||m(4,[],[]),x(","),k(),n.getToken()===2&&v)break}else T&&m(6,[],[]);ge()||m(4,[],[2,5]),T=!0}return d(),n.getToken()!==2?m(7,[2],[]):k(),!0}function Ke(){h(),k();let T=!0,R=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(R||m(4,[],[]),x(","),k(),n.getToken()===4&&v)break}else R&&m(6,[],[]);T?(i.push(0),T=!1):i[i.length-1]++,et()||m(4,[],[4,5]),R=!0}return g(),T||i.pop(),n.getToken()!==4?m(8,[4],[]):k(),!0}function et(){switch(n.getToken()){case 3:return Ke();case 1:return Ye();case 10:return D(!0);default:return he()}}return k(),n.getToken()===17?s.allowEmptyContent?!0:(m(4,[],[]),!1):et()?(n.getToken()!==17&&m(9,[],[]),!0):(m(4,[],[]),!1)}function Js(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 on(e,t,s,n){let i=t.slice(),r=Fe(e,[]),c,a;for(;i.length>0&&(a=i.pop(),c=Te(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=Te(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),f,u=l.parent.offset+l.parent.length;if(p>0){let d=c.children[p-1];f=d.offset+d.length}else f=c.offset+1,c.children.length>1&&(u=c.children[1].offset);return Y(e,{offset:f,length:u-f,content:""},n)}else return Y(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)}`,f=n.getInsertionIndex?n.getInsertionIndex(c.children.map(d=>d.children[0].value)):c.children.length,u;if(f>0){let d=c.children[f-1];u={offset:d.offset+d.length,length:0,content:","+p}}else c.children.length===0?u={offset:c.offset+1,length:0,content:p}:u={offset:c.offset+1,length:0,content:p+","};return Y(e,u,n)}}else if(c.type==="array"&&typeof a=="number"&&Array.isArray(c.children)){let l=a;if(l===-1){let p=`${JSON.stringify(s)}`,f;if(c.children.length===0)f={offset:c.offset+1,length:0,content:p};else{let u=c.children[c.children.length-1];f={offset:u.offset+u.length,length:0,content:","+p}}return Y(e,f,n)}else if(s===void 0&&c.children.length>=0){let p=a,f=c.children[p],u;if(c.children.length===1)u={offset:c.offset+1,length:c.length-2,content:""};else if(c.children.length-1===p){let d=c.children[p-1],h=d.offset+d.length,g=c.offset+c.length;u={offset:h,length:g-2-h,content:""}}else u={offset:f.offset,length:c.children[p+1].offset-f.offset,content:""};return Y(e,u,n)}else if(s!==void 0){let p,f=`${JSON.stringify(s)}`;if(!n.isArrayInsertion&&c.children.length>a){let u=c.children[a];p={offset:u.offset,length:u.length,content:f}}else if(c.children.length===0||a===0)p={offset:c.offset+1,length:0,content:c.children.length===0?f:f+","};else{let u=a>c.children.length?c.children.length:a,d=c.children[u-1];p={offset:d.offset+d.length,length:0,content:","+f}}return Y(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 Y(e,{offset:r?r.offset:0,length:r?r.length:0,content:JSON.stringify(s)},n)}}function Y(e,t,s){if(!s.formattingOptions)return[t];let n=ht(e,t),i=t.offset,o=t.offset+t.content.length;if(t.length===0||t.content.length===0){for(;i>0&&!xe(n,i-1);)i--;for(;o<n.length&&!xe(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=ht(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 ht(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}var rn;(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"})(rn||(rn={}));var an;(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"})(an||(an={}));var _e=sn,ln=Fe,Ve=Te;var cn;(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"})(cn||(cn={}));function pn(e,t,s,n){return on(e,t,s,n)}async function fn(e,t){let s=mt.join(e,C);if(!yt.existsSync(s))return;let n=await O.workspace.openTextDocument(O.Uri.file(s)),i=await O.window.showTextDocument(n),o=n.getText(),r=ln(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 un(e,t,s){let n=mt.join(e,C);if(!yt.existsSync(n))return;let i=await O.workspace.openTextDocument(O.Uri.file(n)),o=i.getText(),r=pn(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 dn(e,t,s,n){e.subscriptions.push(F.commands.registerCommand("pickety.refresh",()=>{t.reload(),t.reloadAliases(),F.window.showInformationMessage("Pickety: Configuration refreshed")})),e.subscriptions.push(F.commands.registerCommand("pickety.generateDiagram",()=>Xt(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(F.commands.registerCommand("pickety.showImpact",()=>en(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(F.commands.registerCommand("pickety.showHealth",()=>Yt(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(F.commands.registerCommand("pickety.goToRule",(i,o)=>fn(i,o))),e.subscriptions.push(F.commands.registerCommand("pickety.allowImport",(i,o,r)=>un(i,o,r))),e.subscriptions.push(F.commands.registerCommand("pickety.init",()=>Ht(n,()=>t.reload())))}var G=S(require("vscode"));var bn=S(require("path")),We=S(require("fs"));function hn(e,t,s,n){if(typeof e.containedTo=="object"&&e.containedTo!==null){let i=e.containedTo;if(typeof i.path!="string"&&n.push({message:`Rule #${t}: "containedTo.path" is required and must be a string`,path:`${s}.containedTo.path`}),i.unless!==void 0)if(typeof i.unless!="object"||i.unless===null||Array.isArray(i.unless))n.push({message:`Rule #${t}: "containedTo.unless" must be an object`,path:`${s}.containedTo.unless`});else{let o=i.unless;Object.keys(o).length===0&&n.push({message:`Rule #${t}: "containedTo.unless" must not be empty`,path:`${s}.containedTo.unless`}),typeof e.imports=="string"&&!e.imports.match(/\$[\w-]+/)&&n.push({message:`Rule #${t}: "containedTo.unless" requires "imports" to contain at least one $variable`,path:`${s}.containedTo.unless`});for(let[c,a]of Object.entries(o))c.startsWith("$")||n.push({message:`Rule #${t}: "containedTo.unless" key "${c}" must start with $`,path:`${s}.containedTo.unless`}),typeof a!="string"&&n.push({message:`Rule #${t}: "containedTo.unless.${c}" must be a string`,path:`${s}.containedTo.unless.${c}`})}}else typeof e.containedTo!="string"&&n.push({message:`Rule #${t}: "containedTo" must be a string or object with a "path" property`,path:`${s}.containedTo`})}function gn(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,f=typeof p.containedTo=="string"||typeof p.containedTo=="object"&&p.containedTo!==null;typeof p.importer!="string"&&!f&&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&&hn(p,a,l,t),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 mn(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 yn(e){let t=[];if(typeof e!="object"||e===null)return{ok:!1,errors:[{message:"Configuration must be a JSON object"}]};let s=e,n=Zs(s.modules,t),i=gn(s.rules,t),o=Ys(s["boundary-diagrams"],t),r=mn(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 Zs(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 Ys(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 vn(e){let t=bn.join(e,C);if(!We.existsSync(t))return{ok:!0,config:void 0};try{let s=We.readFileSync(t,"utf-8"),n;try{n=_e(s)}catch(i){return{ok:!1,errors:[{message:`pickety.json is not valid JSONC: ${i instanceof Error?i.message:String(i)}`}]}}return yn(n)}catch(s){return{ok:!1,errors:[{message:`Failed to read pickety.json: ${s instanceof Error?s.message:String(s)}`}]}}}var Be=S(require("fs")),J=S(require("path"));function kn(e,t){if(t<0)return[];let s=[],n;try{n=Be.readdirSync(e,{withFileTypes:!0})}catch{return s}for(let i of n)!se.has(i.name)&&i.isFile()&&/^tsconfig(\..+)?\.json$/.test(i.name)&&s.push(J.join(e,i.name));for(let i of n)!se.has(i.name)&&i.isDirectory()&&s.push(...kn(J.join(e,i.name),t-1));return s}function wn(e){let t={},s=kn(e,4);for(let n of s)try{let i=Be.readFileSync(n,"utf-8"),r=_e(i).compilerOptions;if(!r?.paths)continue;let c=J.dirname(n),a=J.relative(e,c),l=r.baseUrl||".";for(let[p,f]of Object.entries(r.paths))if(Array.isArray(f)&&f.length>0){let u=f[0];t[p]||(t[p]=A(J.join(a,l,u)))}}catch{}return t}var He=class{constructor(t){this.workspaceRoot=t;this.registerWatchers()}config;aliases={};_onConfigChanged=new G.EventEmitter;onConfigChanged=this._onConfigChanged.event;_onAliasesChanged=new G.EventEmitter;onAliasesChanged=this._onAliasesChanged.event;disposables=[];getConfig(){return this.config}getAliases(){return this.aliases}reload(){let t=vn(this.workspaceRoot);this.config=t.ok?t.config:void 0,this._onConfigChanged.fire(t)}reloadAliases(){this.aliases=wn(this.workspaceRoot),this._onAliasesChanged.fire(this.aliases)}registerWatchers(){let t=G.workspace.createFileSystemWatcher(new G.RelativePattern(this.workspaceRoot,C));this.disposables.push(t),t.onDidChange(()=>this.reload()),t.onDidCreate(()=>this.reload()),t.onDidDelete(()=>{this.config=void 0,this._onConfigChanged.fire({ok:!0,config:void 0})});let s=G.workspace.createFileSystemWatcher(new G.RelativePattern(this.workspaceRoot,"**/tsconfig*.json"));this.disposables.push(s);let n=i=>i.fsPath.split(/[\\/]/).some(r=>se.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 Ue=S(require("vscode")),xn=S(require("fs"));function bt(e,t,s){let n=new Set,i=Pe(e,t,s),o=A(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=N(a,s,n);l&&r.add(l)}let c=new Set;for(let a of o){let l=N(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=N(i,t,s);if(r){n.has(r)||n.set(r,new Set);for(let c of o){let a=N(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(X,"**/node_modules/**");return this.knownFiles=new Set(t.map(s=>A(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=A(t);this.knownFiles.add(i);try{let o=bt(i,s,n);this.importGraph.updateFile(i,o)}catch{}}removeFile(t){let s=A(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=xn.readFileSync(s,"utf-8"),i=bt(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 Gt(n)}computeHealthViolations(t,s){if(!t.health||this.isLargeWorkspace)return[];this.ensureGraphReady(s);let n=re(this.importGraph,t.modules,s);return qt(n,t.health)}};var K=S(require("vscode")),qe=class{item;constructor(t){this.item=K.window.createStatusBarItem(K.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 K.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 K.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 vt=S(require("vscode")),fe=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(!vt.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(!vt.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 M=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 M.Range(i.line,i.character,i.line,i.character+i.length),r=i.severity==="error"?M.DiagnosticSeverity.Error:M.DiagnosticSeverity.Warning,c=new M.Diagnostic(o,i.message,r);return c.source="pickety",i.ruleName&&(c.code={value:i.ruleName,target:M.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 M.Diagnostic(new M.Range(0,0,0,100),`Circular dependency detected: ${o}`,M.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=W(i.metric,i.value),r=W(i.metric,i.threshold),c=new M.Diagnostic(new M.Range(0,0,0,100),`Module "${i.moduleName}" has ${i.metric} of ${o} (max: ${r})`,M.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 ee=S(require("vscode"));var wt=S(require("path"));function Sn(e){return e.match(/\$[\w-]+/g)||[]}function kt(e,t,s){let n=e.split("/"),i=t.split("/"),o=0,r=n.filter(a=>a!=="**").length,c=i.length-r;for(let a=o;a<=c;a++){let l=Tn(n,i,a,s);if(l)return l}}function Tn(e,t,s,n){let i={},o=s;for(let r=0;r<e.length;r++){let c=e[r];if(c==="**"){let f=e.slice(r+1);if(f.length===0)return i;for(let u=o;u<=t.length-f.length;u++){let d=Tn(f,t,u,n);if(d)return{...i,...d}}return}if(o>=t.length)return;let a=c,l=[];for(let f of n)a.includes(f)&&(a=a.replace(f,`__VAR_${l.length}__`),l.push(f));a=a.replace(/[.+?^{}()|[\]\\]/g,"\\$&"),a=a.replace(/\*/g,"[^/]*");for(let f=0;f<l.length;f++)a=a.replace(`__VAR_${f}__`,"([^/]+)");let p=t[o].match(new RegExp(`^${a}$`));if(!p)return;for(let f=0;f<l.length;f++)i[l[f]]=p[f+1];o++}return i}function Ee(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}function En(e,t,s,n,i,o,r,c,a,l,p,f,u){if(s){let d=kt(e.imports,p,t);if(d){if(Ks(e,d))return;let h=Ee(i,t,d);if(!U(c,a,h)){let b=e.message||`Module "${c}" is not allowed to import from "${l}" (contained to "${h}")`;return Q(f,u,r,b,o,c,l)}}}else{let d=kt(i,a,t);if(!d)return;if(n){let h=Ee(e.imports,t,"*"),g=Ee(e.imports,t,d),b=U(l,p,h),x=U(l,p,g);if(b&&!x){let $=e.message||`Import must match scoped pattern "${g}"`;return Q(f,u,r,$,o,c,l)}}else{let h=Ee(e.imports,t,d);if(U(l,p,h)){let b=e.message||`Module "${c}" cannot import from "${l}"`;return Q(f,u,r,b,o,c,l)}}}}function Ks(e,t){let s=rt(e);if(s&&s.unless){let n=Object.entries(s.unless);return n.length>0&&n.every(([i,o])=>t[i]===o)}return!1}function An(e,t,s,n,i,o,r,c,a){let{allow:l,severity:p,name:f,effectiveImporter:u,isOnly:d}=ve(e,t,s),h=Sn(d?e.imports:u);if(h.length>0)return En(e,h,d,l,u,p,f,n,i,o,r,c,a);let g=U(n,i,u),b=U(o,r,e.imports);if(d){if(b&&!g){let x=e.message||(e.containedTo?`Import is restricted: "${o}" is contained to "${u}"`:`Module "${o}" can only be imported by "${u}"`);return Q(c,a,f,x,p,n,o)}}else if(g&&b&&!l){let x=e.message||`Module "${n}" cannot import from "${o}"`;return Q(c,a,f,x,p,n,o)}}function $n(e,t,s,n){let i=[],{modules:o}=s,{severity:r,rules:c}=s.rules["module-boundaries"],{root:a}=n,l=N(e,o,a);if(!l)return[];let p=A(wt.relative(a,e)),f=Pe(e,t,n);for(let{statement:u,resolvedPath:d}of f){let h=N(d,o,a);if(!h)continue;let g=A(wt.relative(a,d));c.forEach((b,x)=>{let $=An(b,x,r,l,p,h,g,e,u);$&&i.push($)})}return i}function Rn(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}})}var _=S(require("vscode")),On=S(require("path"));function Mn(e,t,s,n){s.appendLine("Pickety: Configuration error(s) found:");let i=_.Uri.file(On.join(t,C)),o=e.map(r=>{s.appendLine(` - ${r.message}${r.path?` (at ${r.path})`:""}`);let c=new _.Range(0,0,0,100),a=new _.Diagnostic(c,r.message,_.DiagnosticSeverity.Error);return a.source="pickety",r.path&&(a.code=r.path),a});n.set(i,o),_.window.showErrorMessage("Pickety: Configuration error. Check the Problems panel or Output channel for details.")}var Xe=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()}telemetry=fe.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=Ne(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||Mn(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 ee.workspace.textDocuments)this.isSourceFile(r)&&s.push({uri:r.uri,violations:this.checkDocument(r,t)});let n=s.flatMap(r=>r.violations),i=Rn(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 $n(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=ee.Uri.file(ie(this.workspaceRoot));this.diagnosticManager.setCircularDiagnostics(n,s)}checkHealthThresholds(t){let s=this.analysisService.computeHealthViolations(t,this.analysisService.getWorkspaceContext()),n=ee.Uri.file(ie(this.workspaceRoot));this.diagnosticManager.setHealthDiagnostics(n,s)}registerEventListeners(){this.disposables.push(ee.workspace.onDidSaveTextDocument(s=>{this.isSourceFile(s)&&(this.analysisService.updateFile(s.uri.fsPath,s.getText(),this.analysisService.getWorkspaceContext()),this.analyzeDocument(s),this.codeLensProvider?.refresh())}));let t=ee.workspace.createFileSystemWatcher(X);this.disposables.push(t),t.onDidCreate(s=>{this.analysisService.getKnownFiles().add(A(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.disposables.forEach(t=>t.dispose())}};var ue=S(require("vscode")),Qe=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 ue.CodeAction(`Go to Pickety rule: ${r}`,ue.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 ue.CodeAction(`Allow imports from '${a.targetModule}' in '${a.sourceModule}'`,ue.CodeActionKind.QuickFix);l.command={command:"pickety.allowImport",title:"Allow Import",arguments:[this.workspaceRoot,a.sourceModule,a.targetModule]},i.push(l)}}return i}};var de=S(require("vscode"));var Ze=class{constructor(t,s,n){this.importGraph=t;this.workspaceRoot=s;this.configRef=n}_onDidChangeCodeLenses=new de.EventEmitter;onDidChangeCodeLenses=this._onDidChangeCodeLenses.event;refresh(){this._onDidChangeCodeLenses.fire()}provideCodeLenses(t){let s=this.configRef.config;if(!s)return[];let n=A(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 de.Range(0,0,0,0);return[new de.CodeLens(r,{title:o.join(" | "),command:"pickety.showImpact",tooltip:"Show full impact analysis for this file"})]}dispose(){this._onDidChangeCodeLenses.dispose()}};var ei=[];async function ti(e){let t=fe.getInstance();t.logEvent("extension_activate");let s=V.window.createOutputChannel("Pickety");e.subscriptions.push(s),t.setOutputChannel(s);let n=V.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=V.languages.createDiagnosticCollection("pickety");e.subscriptions.push(c);let a=new Je(c);e.subscriptions.push(a);let l=new Qe(n);e.subscriptions.push(V.languages.registerCodeActionsProvider({scheme:"file",language:"*"},l,{providedCodeActionKinds:[V.CodeActionKind.QuickFix]}));let p=new Ze(o.getImportGraph(),n,{config:void 0});e.subscriptions.push(p);let f=new Xe(e,i,o,a,r,s,n);f.setCodeLensProvider(p),e.subscriptions.push(f),p.configRef=f.configRef,e.subscriptions.push(V.languages.registerCodeLensProvider({scheme:"file",pattern:X},p)),dn(e,i,o,n),i.onConfigChanged(u=>f.handleConfigResult(u)),o.onAnalysisReady(()=>{s.appendLine(`Pickety: Analysis complete. Found ${o.getKnownFiles().size} files.`),f.analyzeOpenEditors()}),i.reload(),i.reloadAliases()}function ni(){ei.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.2.1",
|
|
9
9
|
"publisher": "DanSerio",
|
|
10
10
|
"icon": "resources/icon.png",
|
|
11
11
|
"license": "MIT",
|
|
@@ -119,6 +119,7 @@
|
|
|
119
119
|
"pretest": "npm run compile-tests && npm run compile && npm run lint",
|
|
120
120
|
"lint": "eslint src",
|
|
121
121
|
"test": "vscode-test",
|
|
122
|
+
"test:fixture": "vscode-test --label all-tests",
|
|
122
123
|
"test:core": "npm run compile-tests && mocha --ui tdd out/test/core/**/*.test.js",
|
|
123
124
|
"release:patch": "npm version patch && git push --follow-tags",
|
|
124
125
|
"release:minor": "npm version minor && git push --follow-tags",
|