pickety 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/cli.js +15 -15
- package/out/extension.js +24 -21
- package/package.json +1 -1
- package/resources/pickety.schema.json +8 -0
package/out/cli.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
3
|
-
`;break;case 114:m+="\r";break;case 116:m+=" ";break;case 117:let b=
|
|
4
|
-
`),
|
|
2
|
+
"use strict";var zt=Object.create;var je=Object.defineProperty;var Ht=Object.getOwnPropertyDescriptor;var qt=Object.getOwnPropertyNames;var Jt=Object.getPrototypeOf,Xt=Object.prototype.hasOwnProperty;var Zt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of qt(t))!Xt.call(e,s)&&s!==r&&je(e,s,{get:()=>t[s],enumerable:!(n=Ht(t,s))||n.enumerable});return e};var j=(e,t,r)=>(r=e!=null?zt(Jt(e)):{},Zt(t||!e||!e.__esModule?je(r,"default",{value:e,enumerable:!0}):r,e));var I=j(require("fs")),U=j(require("path"));var kt=j(require("path")),pe=j(require("fs"));function re(e,t=!1){let r=e.length,n=0,s="",o=0,i=16,a=0,l=0,u=0,c=0,f=0;function p(m,k){let w=0,v=0;for(;w<m||!k;){let b=e.charCodeAt(n);if(b>=48&&b<=57)v=v*16+b-48;else if(b>=65&&b<=70)v=v*16+b-65+10;else if(b>=97&&b<=102)v=v*16+b-97+10;else break;n++,w++}return w<m&&(v=-1),v}function d(m){n=m,s="",o=0,i=16,f=0}function g(){let m=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&G(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&G(e.charCodeAt(n)))for(n++;n<e.length&&G(e.charCodeAt(n));)n++;else return f=3,e.substring(m,n);let k=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&&G(e.charCodeAt(n))){for(n++;n<e.length&&G(e.charCodeAt(n));)n++;k=n}else f=3;return e.substring(m,k)}function h(){let m="",k=n;for(;;){if(n>=r){m+=e.substring(k,n),f=2;break}let w=e.charCodeAt(n);if(w===34){m+=e.substring(k,n),n++;break}if(w===92){if(m+=e.substring(k,n),n++,n>=r){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 b=p(4,!0);b>=0?m+=String.fromCharCode(b):f=4;break;default:f=5}k=n;continue}if(w>=0&&w<=31)if(Z(w)){m+=e.substring(k,n),f=2;break}else f=6;n++}return m}function y(){if(s="",f=0,o=n,l=a,c=u,n>=r)return o=r,i=17;let m=e.charCodeAt(n);if(me(m)){do n++,s+=String.fromCharCode(m),m=e.charCodeAt(n);while(me(m));return i=15}if(Z(m))return n++,s+=String.fromCharCode(m),m===13&&e.charCodeAt(n)===10&&(n++,s+=`
|
|
4
|
+
`),a++,u=n,i=14;switch(m){case 123:return n++,i=1;case 125:return n++,i=2;case 91:return n++,i=3;case 93:return n++,i=4;case 58:return n++,i=6;case 44:return n++,i=5;case 34:return n++,s=h(),i=10;case 47:let k=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<r&&!Z(e.charCodeAt(n));)n++;return s=e.substring(k,n),i=12}if(e.charCodeAt(n+1)===42){n+=2;let w=r-1,v=!1;for(;n<w;){let b=e.charCodeAt(n);if(b===42&&e.charCodeAt(n+1)===47){n+=2,v=!0;break}n++,Z(b)&&(b===13&&e.charCodeAt(n)===10&&n++,a++,u=n)}return v||(n++,f=1),s=e.substring(k,n),i=13}return s+=String.fromCharCode(m),n++,i=16;case 45:if(s+=String.fromCharCode(m),n++,n===r||!G(e.charCodeAt(n)))return i=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return s+=g(),i=11;default:for(;n<r&&S(m);)n++,m=e.charCodeAt(n);if(o!==n){switch(s=e.substring(o,n),s){case"true":return i=8;case"false":return i=9;case"null":return i=7}return i=16}return s+=String.fromCharCode(m),n++,i=16}}function S(m){if(me(m)||Z(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 E(){let m;do m=y();while(m>=12&&m<=15);return m}return{setPosition:d,getPosition:()=>n,scan:t?E:y,getToken:()=>i,getTokenValue:()=>s,getTokenOffset:()=>o,getTokenLength:()=>n-o,getTokenStartLine:()=>l,getTokenStartCharacter:()=>o-c,getTokenError:()=>f}}function me(e){return e===32||e===9}function Z(e){return e===10||e===13}function G(e){return e>=48&&e<=57}var Le;(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"})(Le||(Le={}));var Yt=new Array(20).fill(0).map((e,t)=>" ".repeat(t)),z=200,Ct={" ":{"\n":new Array(z).fill(0).map((e,t)=>`
|
|
5
5
|
`+" ".repeat(t)),"\r":new Array(z).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(z).fill(0).map((e,t)=>`\r
|
|
6
6
|
`+" ".repeat(t))}," ":{"\n":new Array(z).fill(0).map((e,t)=>`
|
|
7
7
|
`+" ".repeat(t)),"\r":new Array(z).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(z).fill(0).map((e,t)=>`\r
|
|
8
|
-
`+" ".repeat(t))}};var re;(function(e){e.DEFAULT={allowTrailingComma:!1}})(re||(re={}));function Ve(e,t=[],r=re.DEFAULT){let n=null,s=[],o=[];function i(l){Array.isArray(s)?s.push(l):n!==null&&(s[n]=l)}return Be(e,{onObjectBegin:()=>{let l={};i(l),o.push(s),s=l,n=null},onObjectProperty:l=>{n=l},onObjectEnd:()=>{s=o.pop()},onArrayBegin:()=>{let l=[];i(l),o.push(s),s=l,n=null},onArrayEnd:()=>{s=o.pop()},onLiteralValue:i,onError:(l,u,f)=>{t.push({error:l,offset:u,length:f})}},r),s[0]}function Be(e,t,r=re.DEFAULT){let n=ne(e,!1),s=[],o=0;function i(S){return S?()=>o===0&&S(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function c(S){return S?R=>o===0&&S(R,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function l(S){return S?R=>o===0&&S(R,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>s.slice()):()=>!0}function u(S){return S?()=>{o>0?o++:S(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>s.slice())===!1&&(o=1)}:()=>!0}function f(S){return S?()=>{o>0&&o--,o===0&&S(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}let a=u(t.onObjectBegin),g=l(t.onObjectProperty),p=f(t.onObjectEnd),h=u(t.onArrayBegin),d=f(t.onArrayEnd),y=l(t.onLiteralValue),w=c(t.onSeparator),$=i(t.onComment),m=c(t.onError),k=r&&r.disallowComments,v=r&&r.allowTrailingComma;function x(){for(;;){let S=n.scan();switch(n.getTokenError()){case 4:b(14);break;case 5:b(15);break;case 3:b(13);break;case 1:k||b(11);break;case 2:b(12);break;case 6:b(16);break}switch(S){case 12:case 13:k?b(10):$();break;case 16:b(1);break;case 15:case 14:break;default:return S}}}function b(S,R=[],je=[]){if(m(S),R.length+je.length>0){let te=n.getToken();for(;te!==17;){if(R.indexOf(te)!==-1){x();break}else if(je.indexOf(te)!==-1)break;te=x()}}}function Ie(S){let R=n.getTokenValue();return S?y(R):(g(R),s.push(R)),x(),!0}function _t(){switch(n.getToken()){case 11:let S=n.getTokenValue(),R=Number(S);isNaN(R)&&(b(2),R=0),y(R);break;case 7:y(null);break;case 8:y(!0);break;case 9:y(!1);break;default:return!1}return x(),!0}function Wt(){return n.getToken()!==10?(b(3,[],[2,5]),!1):(Ie(!1),n.getToken()===6?(w(":"),x(),he()||b(4,[],[2,5])):b(5,[],[2,5]),s.pop(),!0)}function Ut(){a(),x();let S=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(S||b(4,[],[]),w(","),x(),n.getToken()===2&&v)break}else S&&b(6,[],[]);Wt()||b(4,[],[2,5]),S=!0}return p(),n.getToken()!==2?b(7,[2],[]):x(),!0}function zt(){h(),x();let S=!0,R=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(R||b(4,[],[]),w(","),x(),n.getToken()===4&&v)break}else R&&b(6,[],[]);S?(s.push(0),S=!1):s[s.length-1]++,he()||b(4,[],[4,5]),R=!0}return d(),S||s.pop(),n.getToken()!==4?b(8,[4],[]):x(),!0}function he(){switch(n.getToken()){case 3:return zt();case 1:return Ut();case 10:return Ie(!0);default:return _t()}}return x(),n.getToken()===17?r.allowEmptyContent?!0:(b(4,[],[]),!1):he()?(n.getToken()!==17&&b(9,[],[]),!0):(b(4,[],[]),!1)}var Fe;(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"})(Fe||(Fe={}));var De;(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"})(De||(De={}));var se=Ve;var _e;(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"})(_e||(_e={}));var ie=P(require("path"));var ye=(e,t,r)=>{let n=e instanceof RegExp?Ue(e,r):e,s=t instanceof RegExp?Ue(t,r):t,o=n!==null&&s!=null&&on(n,s,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+s.length)}},Ue=(e,t)=>{let r=t.match(e);return r?r[0]:null},on=(e,t,r)=>{let n,s,o,i,c,l=r.indexOf(e),u=r.indexOf(t,l+1),f=l;if(l>=0&&u>0){if(e===t)return[l,u];for(n=[],o=r.length;f>=0&&!c;){if(f===l)n.push(f),l=r.indexOf(e,f+1);else if(n.length===1){let a=n.pop();a!==void 0&&(c=[a,u])}else s=n.pop(),s!==void 0&&s<o&&(o=s,i=u),u=r.indexOf(t,f+1);f=l<u&&l>=0?l:u}n.length&&i!==void 0&&(c=[o,i])}return c};var ze="\0SLASH"+Math.random()+"\0",Ge="\0OPEN"+Math.random()+"\0",ke="\0CLOSE"+Math.random()+"\0",He="\0COMMA"+Math.random()+"\0",qe="\0PERIOD"+Math.random()+"\0",an=new RegExp(ze,"g"),ln=new RegExp(Ge,"g"),cn=new RegExp(ke,"g"),un=new RegExp(He,"g"),fn=new RegExp(qe,"g"),pn=/\\\\/g,gn=/\\{/g,dn=/\\}/g,hn=/\\,/g,mn=/\\./g,yn=1e5;function be(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function bn(e){return e.replace(pn,ze).replace(gn,Ge).replace(dn,ke).replace(hn,He).replace(mn,qe)}function kn(e){return e.replace(an,"\\").replace(ln,"{").replace(cn,"}").replace(un,",").replace(fn,".")}function Je(e){if(!e)return[""];let t=[],r=ye("{","}",e);if(!r)return e.split(",");let{pre:n,body:s,post:o}=r,i=n.split(",");i[i.length-1]+="{"+s+"}";let c=Je(o);return o.length&&(i[i.length-1]+=c.shift(),i.push.apply(i,c)),t.push.apply(t,i),t}function Xe(e,t={}){if(!e)return[];let{max:r=yn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),Z(bn(e),r,!0).map(kn)}function wn(e){return"{"+e+"}"}function xn(e){return/^-?0\d/.test(e)}function Sn(e,t){return e<=t}function vn(e,t){return e>=t}function Z(e,t,r){let n=[],s=ye("{","}",e);if(!s)return[e];let o=s.pre,i=s.post.length?Z(s.post,t,!1):[""];if(/\$$/.test(s.pre))for(let c=0;c<i.length&&c<t;c++){let l=o+"{"+s.body+"}"+i[c];n.push(l)}else{let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),u=c||l,f=s.body.indexOf(",")>=0;if(!u&&!f)return s.post.match(/,(?!,).*\}/)?(e=s.pre+"{"+s.body+ke+s.post,Z(e,t,!0)):[e];let a;if(u)a=s.body.split(/\.\./);else if(a=Je(s.body),a.length===1&&a[0]!==void 0&&(a=Z(a[0],t,!1).map(wn),a.length===1))return i.map(p=>s.pre+a[0]+p);let g;if(u&&a[0]!==void 0&&a[1]!==void 0){let p=be(a[0]),h=be(a[1]),d=Math.max(a[0].length,a[1].length),y=a.length===3&&a[2]!==void 0?Math.abs(be(a[2])):1,w=Sn;h<p&&(y*=-1,w=vn);let m=a.some(xn);g=[];for(let k=p;w(k,h);k+=y){let v;if(l)v=String.fromCharCode(k),v==="\\"&&(v="");else if(v=String(k),m){let x=d-v.length;if(x>0){let b=new Array(x+1).join("0");k<0?v="-"+b+v.slice(1):v=b+v}}g.push(v)}}else{g=[];for(let p=0;p<a.length;p++)g.push.apply(g,Z(a[p],t,!1))}for(let p=0;p<g.length;p++)for(let h=0;h<i.length&&n.length<t;h++){let d=o+g[p]+i[h];(!r||u||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 Tn={"[: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]},Y=e=>e.replace(/[[\]\\-]/g,"\\$&"),Rn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ze=e=>e.join(""),Qe=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],s=[],o=r+1,i=!1,c=!1,l=!1,u=!1,f=r,a="";e:for(;o<e.length;){let d=e.charAt(o);if((d==="!"||d==="^")&&o===r+1){u=!0,o++;continue}if(d==="]"&&i&&!l){f=o+1;break}if(i=!0,d==="\\"&&!l){l=!0,o++;continue}if(d==="["&&!l){for(let[y,[w,$,m]]of Object.entries(Tn))if(e.startsWith(y,o)){if(a)return["$.",!1,e.length-r,!0];o+=y.length,m?s.push(w):n.push(w),c=c||$;continue e}}if(l=!1,a){d>a?n.push(Y(a)+"-"+Y(d)):d===a&&n.push(Y(d)),a="",o++;continue}if(e.startsWith("-]",o+1)){n.push(Y(d+"-")),o+=2;continue}if(e.startsWith("-",o+1)){a=d,o+=2;continue}n.push(Y(d)),o++}if(f<o)return["",!1,0,!1];if(!n.length&&!s.length)return["$.",!1,e.length-r,!0];if(s.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let d=n[0].length===2?n[0].slice(-1):n[0];return[Rn(d),!1,f-r,!1]}let g="["+(u?"^":"")+Ze(n)+"]",p="["+(u?"":"^")+Ze(s)+"]";return[n.length&&s.length?"("+g+"|"+p+")":n.length?g:p,c,f-r,!0]};var L=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?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 $n=new Set(["!","?","+","*","@"]),Ye=e=>$n.has(e),En="(?!(?:^|/)\\.\\.?(?:$|/))",oe="(?!\\.)",On=new Set(["[","."]),An=new Set(["..","."]),Mn=new Set("().*{}+?[]^$\\!"),Nn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),we="[^/]",Ke=we+"*?",Ce=we+"+?",G=class e{type;#n;#r;#o=!1;#e=[];#t;#i;#l;#a=!1;#s;#c;#f=!1;constructor(t,r,n={}){this.type=t,t&&(this.#r=!0),this.#t=r,this.#n=this.#t?this.#t.#n:this,this.#s=this.#n===this?n:this.#n.#s,this.#l=this.#n===this?[]:this.#n.#l,t==="!"&&!this.#n.#a&&this.#l.push(this),this.#i=this.#t?this.#t.#e.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#e)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}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("")}#g(){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.#l.pop();){if(t.type!=="!")continue;let r=t,n=r.#t;for(;n;){for(let s=r.#i+1;!n.type&&s<n.#e.length;s++)for(let o of t.#e){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#e[s])}r=n,n=r.#t}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof e&&r.#t===this))throw new Error("invalid part: "+r);this.#e.push(r)}}toJSON(){let t=this.type===null?this.#e.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#e.map(r=>r.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.#i===0)return!0;let t=this.#t;for(let r=0;r<this.#i;r++){let n=t.#e[r];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.#i===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new e(this.type,t);for(let n of this.#e)r.copyIn(n);return r}static#u(t,r,n,s){let o=!1,i=!1,c=-1,l=!1;if(r.type===null){let p=n,h="";for(;p<t.length;){let d=t.charAt(p++);if(o||d==="\\"){o=!o,h+=d;continue}if(i){p===c+1?(d==="^"||d==="!")&&(l=!0):d==="]"&&!(p===c+2&&l)&&(i=!1),h+=d;continue}else if(d==="["){i=!0,c=p,l=!1,h+=d;continue}if(!s.noext&&Ye(d)&&t.charAt(p)==="("){r.push(h),h="";let y=new e(d,r);p=e.#u(t,y,p,s),r.push(y);continue}h+=d}return r.push(h),p}let u=n+1,f=new e(null,r),a=[],g="";for(;u<t.length;){let p=t.charAt(u++);if(o||p==="\\"){o=!o,g+=p;continue}if(i){u===c+1?(p==="^"||p==="!")&&(l=!0):p==="]"&&!(u===c+2&&l)&&(i=!1),g+=p;continue}else if(p==="["){i=!0,c=u,l=!1,g+=p;continue}if(Ye(p)&&t.charAt(u)==="("){f.push(g),g="";let h=new e(p,f);f.push(h),u=e.#u(t,h,u,s);continue}if(p==="|"){f.push(g),g="",a.push(f),f=new e(null,r);continue}if(p===")")return g===""&&r.#e.length===0&&(r.#f=!0),f.push(g),g="",r.push(...a,f),u;g+=p}return r.type=null,r.#r=void 0,r.#e=[t.substring(n-1)],u}static fromGlob(t,r={}){let n=new e(null,void 0,r);return e.#u(t,n,0,r),n}toMMPattern(){if(this!==this.#n)return this.#n.toMMPattern();let t=this.toString(),[r,n,s,o]=this.toRegExpSource();if(!(s||this.#r||this.#s.nocase&&!this.#s.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let c=(this.#s.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,c),{_src:r,_glob:t})}get options(){return this.#s}toRegExpSource(t){let r=t??!!this.#s.dot;if(this.#n===this&&this.#g(),!this.type){let l=this.isStart()&&this.isEnd()&&!this.#e.some(p=>typeof p!="string"),u=this.#e.map(p=>{let[h,d,y,w]=typeof p=="string"?e.#d(p,this.#r,l):p.toRegExpSource(t);return this.#r=this.#r||y,this.#o=this.#o||w,h}).join(""),f="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&An.has(this.#e[0]))){let h=On,d=r&&h.has(u.charAt(0))||u.startsWith("\\.")&&h.has(u.charAt(2))||u.startsWith("\\.\\.")&&h.has(u.charAt(4)),y=!r&&!t&&h.has(u.charAt(0));f=d?En:y?oe:""}let a="";return this.isEnd()&&this.#n.#a&&this.#t?.type==="!"&&(a="(?:$|\\/)"),[f+u+a,L(u),this.#r=!!this.#r,this.#o]}let n=this.type==="*"||this.type==="+",s=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#p(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString();return this.#e=[l],this.type=null,this.#r=void 0,[l,L(this.toString()),!1,!1]}let i=!n||t||r||!oe?"":this.#p(!0);i===o&&(i=""),i&&(o=`(?:${o})(?:${i})*?`);let c="";if(this.type==="!"&&this.#f)c=(this.isStart()&&!r?oe:"")+Ce;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?oe:"")+Ke+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&i?")":this.type==="*"&&i?")?":`)${this.type}`;c=s+o+l}return[c,L(o),this.#r=!!this.#r,this.#o]}#p(t){return this.#e.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,s,o,i]=r.toRegExpSource(t);return this.#o=this.#o||i,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#d(t,r,n=!1){let s=!1,o="",i=!1,c=!1;for(let l=0;l<t.length;l++){let u=t.charAt(l);if(s){s=!1,o+=(Mn.has(u)?"\\":"")+u;continue}if(u==="*"){if(c)continue;c=!0,o+=n&&/^[*]+$/.test(t)?Ce:Ke,r=!0;continue}else c=!1;if(u==="\\"){l===t.length-1?o+="\\\\":s=!0;continue}if(u==="["){let[f,a,g,p]=Qe(t,l);if(g){o+=f,i=i||a,l+=g-1,r=r||p;continue}}if(u==="?"){o+=we,r=!0;continue}o+=Nn(u)}return[o,L(t),!!r,i]}};var xe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var T=(e,t,r={})=>(Q(t),!r.nocomment&&t.charAt(0)==="#"?!1:new H(t,r).match(e)),In=/^\*+([^+@!?\*\[\(]*)$/,jn=e=>t=>!t.startsWith(".")&&t.endsWith(e),Pn=e=>t=>t.endsWith(e),Ln=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Vn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Bn=/^\*+\.\*+$/,Fn=e=>!e.startsWith(".")&&e.includes("."),Dn=e=>e!=="."&&e!==".."&&e.includes("."),_n=/^\.\*+$/,Wn=e=>e!=="."&&e!==".."&&e.startsWith("."),Un=/^\*+$/,zn=e=>e.length!==0&&!e.startsWith("."),Gn=e=>e.length!==0&&e!=="."&&e!=="..",Hn=/^\?+([^+@!?\*\[\(]*)?$/,qn=([e,t=""])=>{let r=nt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Jn=([e,t=""])=>{let r=rt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Xn=([e,t=""])=>{let r=rt([e]);return t?n=>r(n)&&n.endsWith(t):r},Zn=([e,t=""])=>{let r=nt([e]);return t?n=>r(n)&&n.endsWith(t):r},nt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},rt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},st=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",et={win32:{sep:"\\"},posix:{sep:"/"}},Qn=st==="win32"?et.win32.sep:et.posix.sep;T.sep=Qn;var M=Symbol("globstar **");T.GLOBSTAR=M;var Yn="[^/]",Kn=Yn+"*?",Cn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",er="(?:(?!(?:\\/|^)\\.).)*?",tr=(e,t={})=>r=>T(r,e,t);T.filter=tr;var A=(e,t={})=>Object.assign({},e,t),nr=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return T;let t=T;return Object.assign((n,s,o={})=>t(n,s,A(e,o)),{Minimatch:class extends t.Minimatch{constructor(s,o={}){super(s,A(e,o))}static defaults(s){return t.defaults(A(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,o,i={}){super(s,o,A(e,i))}static fromGlob(s,o={}){return t.AST.fromGlob(s,A(e,o))}},unescape:(n,s={})=>t.unescape(n,A(e,s)),escape:(n,s={})=>t.escape(n,A(e,s)),filter:(n,s={})=>t.filter(n,A(e,s)),defaults:n=>t.defaults(A(e,n)),makeRe:(n,s={})=>t.makeRe(n,A(e,s)),braceExpand:(n,s={})=>t.braceExpand(n,A(e,s)),match:(n,s,o={})=>t.match(n,s,A(e,o)),sep:t.sep,GLOBSTAR:M})};T.defaults=nr;var ot=(e,t={})=>(Q(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Xe(e,{max:t.braceExpandMax}));T.braceExpand=ot;var rr=(e,t={})=>new H(e,t).makeRe();T.makeRe=rr;var sr=(e,t,r={})=>{let n=new H(t,r);return e=e.filter(s=>n.match(s)),n.options.nonull&&!e.length&&e.push(t),e};T.match=sr;var tt=/[?*]|[+@!]\(.*?\)|\[|\]/,or=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),H=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,r={}){Q(t),r=r||{},this.options=r,this.pattern=t,this.platform=r.platform||st,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.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 r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.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 s=this.globParts.map((o,i,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!tt.test(o[2]))&&!tt.test(o[3]),u=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(f=>this.parse(f))];if(u)return[o[0],...o.slice(1).map(f=>this.parse(f))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,s),this.set=s.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let i=this.set[o];i[0]===""&&i[1]===""&&this.globParts[o][2]==="?"&&typeof i[3]=="string"&&/^[a-z]:$/i.test(i[3])&&(i[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n=0;n<t.length;n++)for(let s=0;s<t[n].length;s++)t[n][s]==="**"&&(t[n][s]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let s=n;for(;r[s+1]==="**";)s++;s!==n&&r.splice(n,s-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,s)=>{let o=n[n.length-1];return s==="**"&&o==="**"?n:s===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(s),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let s=1;s<t.length-1;s++){let o=t[s];s===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(s,1),s--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let s=t[n-1];s&&s!=="."&&s!==".."&&s!=="**"&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let s=-1;for(;(s=n.indexOf("**",s+1))!==-1;){let i=s;for(;n[i+1]==="**";)i++;i>s&&n.splice(s+1,i-s);let c=n[s+1],l=n[s+2],u=n[s+3];if(c!==".."||!l||l==="."||l===".."||!u||u==="."||u==="..")continue;r=!0,n.splice(s,1);let f=n.slice(0);f[s]="**",t.push(f),s--}if(!this.preserveMultipleSlashes){for(let i=1;i<n.length-1;i++){let c=n[i];i===1&&c===""&&n[0]===""||(c==="."||c==="")&&(r=!0,n.splice(i,1),i--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let i=n[o-1];if(i&&i!=="."&&i!==".."&&i!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let s=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(s){t[r]=[],t[n]=s;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let s=0,o=0,i=[],c="";for(;s<t.length&&o<r.length;)if(t[s]===r[o])i.push(c==="b"?r[o]:t[s]),s++,o++;else if(n&&t[s]==="**"&&r[o]===t[s+1])i.push(t[s]),s++;else if(n&&r[o]==="**"&&t[s]===r[o+1])i.push(r[o]),o++;else if(t[s]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(c==="b")return!1;c="a",i.push(t[s]),s++,o++}else if(r[o]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(c==="a")return!1;c="b",i.push(r[o]),s++,o++}else return!1;return t.length===r.length&&i}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let s=0;s<t.length&&t.charAt(s)==="!";s++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let s=this.options;if(this.isWindows){let d=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),y=!d&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),w=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),$=!w&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),m=y?3:d?0:void 0,k=$?3:w?0:void 0;if(typeof m=="number"&&typeof k=="number"){let[v,x]=[t[m],r[k]];v.toLowerCase()===x.toLowerCase()&&(r[k]=v,k>m?r=r.slice(k):m>k&&(t=t.slice(m)))}}let{optimizationLevel:o=1}=this.options;o>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:r}),this.debug("matchOne",t.length,r.length);for(var i=0,c=0,l=t.length,u=r.length;i<l&&c<u;i++,c++){this.debug("matchOne loop");var f=r[c],a=t[i];if(this.debug(r,f,a),f===!1)return!1;if(f===M){this.debug("GLOBSTAR",[r,f,a]);var g=i,p=c+1;if(p===u){for(this.debug("** at the end");i<l;i++)if(t[i]==="."||t[i]===".."||!s.dot&&t[i].charAt(0)===".")return!1;return!0}for(;g<l;){var h=t[g];if(this.debug(`
|
|
9
|
-
globstar while`,t,
|
|
10
|
-
>>> no match, partial?`,t,g,r,p),g===l))}let d;if(typeof f=="string"?(d=a===f,this.debug("string match",f,a,d)):(d=f.test(a),this.debug("pattern match",f,a,d)),!d)return!1}if(i===l&&c===u)return!0;if(i===l)return n;if(c===u)return i===l-1&&t[i]==="";throw new Error("wtf?")}braceExpand(){return ot(this.pattern,this.options)}parse(t){Q(t);let r=this.options;if(t==="**")return M;if(t==="")return"";let n,s=null;(n=t.match(Un))?s=r.dot?Gn:zn:(n=t.match(In))?s=(r.nocase?r.dot?Vn:Ln:r.dot?Pn:jn)(n[1]):(n=t.match(Hn))?s=(r.nocase?r.dot?Jn:qn:r.dot?Xn:Zn)(n):(n=t.match(Bn))?s=r.dot?Dn:Fn:(n=t.match(_n))&&(s=Wn);let o=G.fromGlob(t,this.options).toMMPattern();return s&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:s}),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 r=this.options,n=r.noglobstar?Kn:r.dot?Cn:er,s=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let u=l.map(a=>{if(a instanceof RegExp)for(let g of a.flags.split(""))s.add(g);return typeof a=="string"?or(a):a===M?M:a._src});u.forEach((a,g)=>{let p=u[g+1],h=u[g-1];a!==M||h===M||(h===void 0?p!==void 0&&p!==M?u[g+1]="(?:\\/|"+n+"\\/)?"+p:u[g]=n:p===void 0?u[g-1]=h+"(?:\\/|\\/"+n+")?":p!==M&&(u[g-1]=h+"(?:\\/|\\/"+n+"\\/)"+p,u[g+1]=M))});let f=u.filter(a=>a!==M);if(this.partial&&f.length>=1){let a=[];for(let g=1;g<=f.length;g++)a.push(f.slice(0,g).join("/"));return"(?:"+a.join("|")+")"}return f.join("/")}).join("|"),[i,c]=t.length>1?["(?:",")"]:["",""];o="^"+i+o+c+"$",this.partial&&(o="^(?:\\/|"+i+o.slice(1,-1)+c+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...s].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,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let s=this.slashSplit(t);this.debug(this.pattern,"split",s);let o=this.set;this.debug(this.pattern,"set",o);let i=s[s.length-1];if(!i)for(let c=s.length-2;!i&&c>=0;c--)i=s[c];for(let c=0;c<o.length;c++){let l=o[c],u=s;if(n.matchBase&&l.length===1&&(u=[i]),this.matchOne(u,l,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return T.defaults(t).Minimatch}};T.AST=G;T.Minimatch=H;T.escape=xe;T.unescape=L;var F="pickety.json",q=["ts","tsx","js","jsx","mjs","cjs"],ir=`**/*.{${q.join(",")}}`,ae=new Set(["node_modules",".git",".next","dist","out","build",".turbo",".cache",".nx","coverage"]);function E(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 ie.relative(e,t).replace(/\\/g,"/")}function Se(e,t){return T(e,t)||e===t}function ve(e){return ie.join(e,F)}function le(e,t){return e==="instability"?t.toFixed(2):String(t)}function ce(e){let t=0,r=0,n=0;for(let s of e)s.severity==="error"?t+=1:s.severity==="warn"?r+=1:n+=1;return{errors:t,warnings:r,info:n}}function ar(e,t,r){let n=Te(e),s=e.name??`rule[${t}]`,o=e.group,i=o?`${o}: ${s}`:s;return{allow:e.allow??!1,severity:e.severity??r,name:s,group:o,label:i,effectiveImporter:n?.path||e.importer||"*",isOnly:e.only||!!e.containedTo,isAllowStyle:(e.allow??!1)||!!e.containedTo||!!e.only}}function it(e,t,r){let n=ar(e,t,r),s=Array.isArray(e.imports)?e.imports:[e.imports];return{rule:e,...n,importPatterns:s.filter(o=>typeof o=="string")}}function N(e,t,r){let n=e.includes("[")?e.slice(0,e.indexOf("[")):e;return!!(Se(e,r)||Se(n,r)||r.includes("/")&&(T(t,r)||T(t,`**/${r}`)||T(t,`**/${r}/**`)))}function Te(e){if(e.containedTo)return typeof e.containedTo=="object"?e.containedTo:{path:e.containedTo}}function D(e,t,r,n,s,o,i,c,l){return{file:e,line:t.line,character:t.character,length:t.length,message:`[${n}] ${s} (importing "${t.specifier}")`,severity:o,ruleName:r,ruleGroup:l,sourceModule:i,targetModule:c}}function at(e){let t=[],r=new Set,n=new Set,s=[];function o(i){r.add(i),n.add(i),s.push(i);let c=e.get(i);if(c){for(let l of c)if(!r.has(l))o(l);else if(n.has(l)){let u=s.indexOf(l);u!==-1&&t.push([...s.slice(u),l])}}n.delete(i),s.pop()}for(let i of e.keys())r.has(i)||o(i);return t}var lt={modules:{app:"src/app/**",features:"src/features/**",shared:"src/shared/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"shared",imports:["app","features"],allow:!1,message:"Shared code should stay independent of app and feature modules."},{importer:"features",imports:"app",allow:!1,message:"Feature modules should not depend on the app layer."}]}}};var ct={modules:{domain:"src/domain/**",application:"src/application/**",ports:"src/ports/**",adapters:"src/adapters/**",infrastructure:"src/infrastructure/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"domain",imports:["application","ports","adapters","infrastructure"],allow:!1,message:"Domain should not depend on outer layers."},{importer:"application",imports:["adapters","infrastructure"],allow:!1,message:"Application should not depend on adapters or infrastructure."},{importer:"ports",imports:["adapters","infrastructure"],allow:!1,message:"Ports should remain independent of adapters and infrastructure."},{importer:"adapters",imports:"infrastructure",allow:!1,message:"Adapters should not depend on infrastructure."}]}}};var ut={modules:{presentation:"src/presentation/**",application:"src/application/**",domain:"src/domain/**",infrastructure:"src/infrastructure/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"domain",imports:["application","presentation","infrastructure"],allow:!1,message:"Domain should not depend on outer layers."},{importer:"application",imports:["presentation","infrastructure"],allow:!1,message:"Application should not depend on presentation or infrastructure."},{importer:"presentation",imports:"infrastructure",allow:!1,message:"Presentation should not depend directly on infrastructure."}]}}};var ft={hexagonal:ct,"feature-modules":lt,layered:ut};function ue(e){return ft[e]}function K(){return Object.keys(ft)}function pt(e,t,r,n){if(typeof e.containedTo=="object"&&e.containedTo!==null){let s=e.containedTo;if(typeof s.path!="string"&&n.push({message:`Rule #${t}: "containedTo.path" is required and must be a string`,path:`${r}.containedTo.path`}),s.unless!==void 0)if(typeof s.unless!="object"||s.unless===null||Array.isArray(s.unless))n.push({message:`Rule #${t}: "containedTo.unless" must be an object`,path:`${r}.containedTo.unless`});else{let o=s.unless;Object.keys(o).length===0&&n.push({message:`Rule #${t}: "containedTo.unless" must not be empty`,path:`${r}.containedTo.unless`}),(Array.isArray(e.imports)?e.imports.filter(u=>typeof u=="string"):typeof e.imports=="string"?[e.imports]:[]).some(u=>u.match(/\$[\w-]+/))||n.push({message:`Rule #${t}: "containedTo.unless" requires "imports" to contain at least one $variable`,path:`${r}.containedTo.unless`});for(let[u,f]of Object.entries(o))u.startsWith("$")||n.push({message:`Rule #${t}: "containedTo.unless" key "${u}" must start with $`,path:`${r}.containedTo.unless`}),typeof f!="string"&&n.push({message:`Rule #${t}: "containedTo.unless.${u}" must be a string`,path:`${r}.containedTo.unless.${u}`})}}else typeof e.containedTo!="string"&&n.push({message:`Rule #${t}: "containedTo" must be a string or object with a "path" property`,path:`${r}.containedTo`})}function I(e){return e.match(/\$[\w-]+/g)||[]}function gt(e){let t=new Set;for(let r of e)for(let n of I(r))t.add(n);return[...t]}function C(e,t,r){let n=e.split("/"),s=t.split("/"),o=0,i=n.filter(l=>l!=="**").length,c=s.length-i;for(let l=o;l<=c;l++){let u=dt(n,s,l,r);if(u)return u}}function dt(e,t,r,n){let s={},o=r;for(let i=0;i<e.length;i++){let c=e[i];if(c==="**"){let a=e.slice(i+1);if(a.length===0)return s;for(let g=o;g<=t.length-a.length;g++){let p=dt(a,t,g,n);if(p)return{...s,...p}}return}if(o>=t.length)return;let l=c,u=[];for(let a of n)l.includes(a)&&(l=l.replace(a,`__VAR_${u.length}__`),u.push(a));l=l.replace(/[.+?^{}()|[\]\\]/g,"\\$&"),l=l.replace(/\*/g,"[^/]*");for(let a=0;a<u.length;a++)l=l.replace(`__VAR_${a}__`,"([^/]+)");let f=t[o].match(new RegExp(`^${l}$`));if(!f)return;for(let a=0;a<u.length;a++)s[u[a]]=f[a+1];o++}return s}function _(e,t,r){let n=e;for(let s of t){let o=typeof r=="string"?r:r[s];n=n.replaceAll(s,o)}return n}function mt(e,t,r){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 s=e["module-boundaries"];if(s===void 0){t.push({message:'"rules.module-boundaries" is required and must be an object',path:"rules.module-boundaries"});return}if(typeof s!="object"||s===null){t.push({message:'"rules.module-boundaries" must be an object',path:"rules.module-boundaries"});return}let o=s,i="error";if(o.severity!==void 0&&(o.severity!=="error"&&o.severity!=="warn"?t.push({message:`"rules.module-boundaries.severity" must be "error" or "warn", got "${o.severity}"`,path:"rules.module-boundaries.severity"}):i=o.severity),o.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(o.rules)){t.push({message:'"rules.module-boundaries.rules" must be an array',path:"rules.module-boundaries.rules"});return}let c=[];return o.rules.forEach((l,u)=>{let f=`rules.module-boundaries.rules[${u}]`;if(typeof l!="object"||l===null){t.push({message:`Rule #${u} must be an object`,path:f});return}let a=l,g=typeof a.containedTo=="string"||typeof a.containedTo=="object"&&a.containedTo!==null;typeof a.importer!="string"&&!g&&t.push({message:`Rule #${u}: "importer" or "containedTo" is required`,path:f}),a.importer!==void 0&&typeof a.importer!="string"&&t.push({message:`Rule #${u}: "importer" must be a string`,path:`${f}.importer`});let p;if(typeof a.imports=="string")p=[a.imports];else if(Array.isArray(a.imports)){let y=a.imports.findIndex(w=>typeof w!="string");y!==-1?t.push({message:`Rule #${u}: "imports" entries must be strings`,path:`${f}.imports[${y}]`}):p=a.imports}else t.push({message:`Rule #${u}: "imports" is required and must be a string or string[]`,path:`${f}.imports`});a.allow!==void 0&&typeof a.allow!="boolean"&&t.push({message:`Rule #${u}: "allow" must be a boolean`,path:`${f}.allow`}),a.only!==void 0&&typeof a.only!="boolean"&&t.push({message:`Rule #${u}: "only" must be a boolean`,path:`${f}.only`}),a.containedTo!==void 0&&pt(a,u,f,t),a.message!==void 0&&typeof a.message!="string"&&t.push({message:`Rule #${u}: "message" must be a string`,path:`${f}.message`}),a.severity!==void 0&&a.severity!=="error"&&a.severity!=="warn"&&t.push({message:`Rule #${u}: "severity" must be "error" or "warn", got "${a.severity}"`,path:`${f}.severity`}),a.name!==void 0&&typeof a.name!="string"&&t.push({message:`Rule #${u}: "name" must be a string`,path:`${f}.name`}),a.group!==void 0&&typeof a.group!="string"&&t.push({message:`Rule #${u}: "group" must be a string`,path:`${f}.group`}),a.maxViolations!==void 0&&(typeof a.maxViolations!="number"||!Number.isInteger(a.maxViolations)||a.maxViolations<0)&&t.push({message:`Rule #${u}: "maxViolations" must be a non-negative integer`,path:`${f}.maxViolations`});let h;if(a.exports!==void 0)if(Array.isArray(a.exports)){let y=[];a.exports.forEach((w,$)=>{let m=ht(w,`${f}.exports[${$}]`,t);m&&y.push(m)}),y.length>0&&(h=y)}else{let y=ht(a.exports,`${f}.exports`,t);y&&(h=y)}if(p){let y=new Set(gt(p)),w=($,m,k)=>{let x=I($).filter(b=>!y.has(b));if(x.length>0){let b=Array.from(new Set(x));r.push({message:`Rule #${u}: ${k} references variables not present in "imports": ${b.join(", ")}`,path:m})}};typeof a.importer=="string"&&w(a.importer,`${f}.importer`,'"importer"'),typeof a.containedTo=="string"?w(a.containedTo,`${f}.containedTo`,'"containedTo"'):typeof a.containedTo=="object"&&a.containedTo!==null&&typeof a.containedTo.path=="string"&&w(a.containedTo.path,`${f}.containedTo.path`,'"containedTo.path"')}if(!p)return;let d={imports:typeof a.imports=="string"?a.imports:p};typeof a.importer=="string"&&(d.importer=a.importer),typeof a.allow=="boolean"&&(d.allow=a.allow),typeof a.only=="boolean"&&(d.only=a.only),a.containedTo!==void 0&&(typeof a.containedTo=="string"||typeof a.containedTo=="object"&&a.containedTo!==null)&&(d.containedTo=a.containedTo),typeof a.message=="string"&&(d.message=a.message),(a.severity==="error"||a.severity==="warn")&&(d.severity=a.severity),typeof a.name=="string"&&(d.name=a.name),typeof a.group=="string"&&(d.group=a.group),typeof a.maxViolations=="number"&&Number.isInteger(a.maxViolations)&&a.maxViolations>=0&&(d.maxViolations=a.maxViolations),h&&(d.exports=h),c.push(d)}),{severity:i,rules:c}}function ht(e,t,r){if(typeof e!="object"||e===null){r.push({message:`"${t}" must be an object`,path:t});return}let n=e,s=!1;if(typeof n.path!="string"&&(r.push({message:`"${t}.path" is required and must be a string`,path:`${t}.path`}),s=!0),typeof n.to!="string"&&(r.push({message:`"${t}.to" is required and must be a string`,path:`${t}.to`}),s=!0),n.message!==void 0&&typeof n.message!="string"&&(r.push({message:`"${t}.message" must be a string`,path:`${t}.message`}),s=!0),!s)return{path:n.path,to:n.to,message:typeof n.message=="string"?n.message:void 0}}function yt(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 r=e,n={},s=[{key:"maxAfferentCoupling",label:"maxAfferentCoupling"},{key:"maxEfferentCoupling",label:"maxEfferentCoupling"},{key:"maxDepth",label:"maxDepth"}];for(let{key:o,label:i}of s){let c=r[o];c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<1?t.push({message:`"health.${i}" must be a positive integer`,path:`health.${i}`}):n[o]=c)}if(r.maxInstability!==void 0){let o=r.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 bt(e){let t=[],r=[];if(typeof e!="object"||e===null)return{ok:!1,errors:[{message:"Configuration must be a JSON object"}]};let n=e,s=lr(n.modules,t),o=mt(n.rules,t,r),i=cr(n["boundary-diagrams"],t),c=yt(n.health,t),l=ur(n.warnOnUntrackedImporters,t);return t.length>0||!s||!o?r.length>0?{ok:!1,errors:t,warnings:r}:{ok:!1,errors:t}:{ok:!0,config:{modules:s,rules:{"module-boundaries":o},warnOnUntrackedImporters:l,"boundary-diagrams":i,health:c},warnings:r.length>0?r:void 0}}function lr(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 r={};for(let[n,s]of Object.entries(e))typeof s!="string"?t.push({message:`Module "${n}" pattern must be a string, got ${typeof s}`,path:`modules.${n}`}):r[n]=s;return r}function cr(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 ur(e,t){return e===void 0?!0:typeof e!="boolean"?(t.push({message:'"warnOnUntrackedImporters" must be a boolean',path:"warnOnUntrackedImporters"}),!0):e}function wt(e){let t=kt.join(e,F);if(!pe.existsSync(t))return{ok:!0,config:void 0};try{let r=pe.readFileSync(t,"utf-8"),n;try{n=se(r)}catch(s){return{ok:!1,errors:[{message:`pickety.json is not valid JSONC: ${s instanceof Error?s.message:String(s)}`}]}}if(typeof n=="object"&&n!==null){let s=n;if(s.preset!==void 0&&typeof s.preset!="string")return{ok:!1,errors:[{message:'"preset" must be a string',path:"preset"}]};if(typeof s.preset=="string"){let o=ue(s.preset);if(!o)return{ok:!1,errors:[{message:`Unknown preset "${s.preset}". Available presets: ${K().join(", ")}`,path:"preset"}]};n=dr(o,s)}}return bt(n)}catch(r){return{ok:!1,errors:[{message:`Failed to read pickety.json: ${r instanceof Error?r.message:String(r)}`}]}}}function fe(e){return typeof e=="object"&&e!==null}function fr(e,t){return t===void 0?e:!fe(t)||!e?t:{...e,...t}}function Re(e,t,r,n){r[n]!==void 0?e[n]=r[n]:t[n]!==void 0&&(e[n]=t[n])}function pr(e,t){return t===void 0?e:fe(t)?{...e,...t}:t}function gr(e,t){if(t===void 0)return e;if(!fe(t))return t;let r=t["module-boundaries"];if(!fe(r))return t;let n={...e,...t},s=e["module-boundaries"],o={...s,...r},i=Array.isArray(s.rules)?s.rules:[];return r.rules===void 0?o.rules=i:Array.isArray(r.rules)?o.rules=[...i,...r.rules]:o.rules=r.rules,n["module-boundaries"]=o,n}function dr(e,t){let r={...e,...t};r.modules=pr(e.modules,t.modules),r.rules=gr(e.rules,t.rules);let n=e;return Re(r,n,t,"warnOnUntrackedImporters"),Re(r,n,t,"boundary-diagrams"),r.health=fr(e.health,t.health),Re(r,n,t,"version"),r}var ge=P(require("fs")),V=P(require("path"));function xt(e,t){if(t<0)return[];let r=[],n;try{n=ge.readdirSync(e,{withFileTypes:!0})}catch{return r}for(let s of n)!ae.has(s.name)&&s.isFile()&&/^tsconfig(\..+)?\.json$/.test(s.name)&&r.push(V.join(e,s.name));for(let s of n)!ae.has(s.name)&&s.isDirectory()&&r.push(...xt(V.join(e,s.name),t-1));return r}function St(e){let t={},r=xt(e,4);for(let n of r)try{let s=ge.readFileSync(n,"utf-8"),i=se(s).compilerOptions;if(!i?.paths)continue;let c=V.dirname(n),l=V.relative(e,c),u=i.baseUrl||".";for(let[f,a]of Object.entries(i.paths))if(Array.isArray(a)&&a.length>0){let g=a[0];t[f]||(t[f]=E(V.join(l,u,g)))}}catch{}return t}var Ae=P(require("path"));var B=P(require("path"));var Tt=q.map(e=>`.${e}`),hr=Tt.map(e=>`index${e}`),vt=/(\/\*[\s\S]*?\*\/|\/\/.*)|(['"`](?:\\.|[^'"`])*['"`])|((?:import|export)\s+(?:[\s\S]*?from\s+)?['"`]([^'"`]+)['"`])|(import\s*\(\s*['"`]([^'"`]+)['"`]\s*\))/gm;function mr(e){let t=[],r=e.split(`
|
|
11
|
-
`),n=[],s=0;for(let
|
|
12
|
-
`)}function Lt(e,t,r){let n=e.map(
|
|
13
|
-
`),
|
|
14
|
-
`);return}console.log(` Direct dependents (${
|
|
15
|
-
Transitive dependents (${
|
|
16
|
-
Affected modules: ${[...
|
|
17
|
-
`);let r=["Module","Files","Ca","Ce","Instability","Depth"],n=[Math.max(r[0].length,...e.map(i=>i.moduleName.length)),Math.max(r[1].length,...e.map(i=>String(i.fileCount).length)),Math.max(r[2].length,...e.map(i=>String(i.afferentCoupling).length)),Math.max(r[3].length,...e.map(i=>String(i.efferentCoupling).length)),Math.max(r[4].length,11),Math.max(r[5].length,...e.map(i=>String(i.dependencyDepth).length))],s=(i,
|
|
18
|
-
${
|
|
19
|
-
All modules within configured thresholds.`),0)}function
|
|
8
|
+
`+" ".repeat(t))}};var se;(function(e){e.DEFAULT={allowTrailingComma:!1}})(se||(se={}));function Ve(e,t=[],r=se.DEFAULT){let n=null,s=[],o=[];function i(l){Array.isArray(s)?s.push(l):n!==null&&(s[n]=l)}return Be(e,{onObjectBegin:()=>{let l={};i(l),o.push(s),s=l,n=null},onObjectProperty:l=>{n=l},onObjectEnd:()=>{s=o.pop()},onArrayBegin:()=>{let l=[];i(l),o.push(s),s=l,n=null},onArrayEnd:()=>{s=o.pop()},onLiteralValue:i,onError:(l,u,c)=>{t.push({error:l,offset:u,length:c})}},r),s[0]}function Be(e,t,r=se.DEFAULT){let n=re(e,!1),s=[],o=0;function i(x){return x?()=>o===0&&x(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function a(x){return x?O=>o===0&&x(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function l(x){return x?O=>o===0&&x(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>s.slice()):()=>!0}function u(x){return x?()=>{o>0?o++:x(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>s.slice())===!1&&(o=1)}:()=>!0}function c(x){return x?()=>{o>0&&o--,o===0&&x(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}let f=u(t.onObjectBegin),p=l(t.onObjectProperty),d=c(t.onObjectEnd),g=u(t.onArrayBegin),h=c(t.onArrayEnd),y=l(t.onLiteralValue),S=a(t.onSeparator),E=i(t.onComment),m=a(t.onError),k=r&&r.disallowComments,w=r&&r.allowTrailingComma;function v(){for(;;){let x=n.scan();switch(n.getTokenError()){case 4:b(14);break;case 5:b(15);break;case 3:b(13);break;case 1:k||b(11);break;case 2:b(12);break;case 6:b(16);break}switch(x){case 12:case 13:k?b(10):E();break;case 16:b(1);break;case 15:case 14:break;default:return x}}}function b(x,O=[],Ie=[]){if(m(x),O.length+Ie.length>0){let ne=n.getToken();for(;ne!==17;){if(O.indexOf(ne)!==-1){v();break}else if(Ie.indexOf(ne)!==-1)break;ne=v()}}}function Ne(x){let O=n.getTokenValue();return x?y(O):(p(O),s.push(O)),v(),!0}function Dt(){switch(n.getToken()){case 11:let x=n.getTokenValue(),O=Number(x);isNaN(O)&&(b(2),O=0),y(O);break;case 7:y(null);break;case 8:y(!0);break;case 9:y(!1);break;default:return!1}return v(),!0}function Wt(){return n.getToken()!==10?(b(3,[],[2,5]),!1):(Ne(!1),n.getToken()===6?(S(":"),v(),he()||b(4,[],[2,5])):b(5,[],[2,5]),s.pop(),!0)}function Ut(){f(),v();let x=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(x||b(4,[],[]),S(","),v(),n.getToken()===2&&w)break}else x&&b(6,[],[]);Wt()||b(4,[],[2,5]),x=!0}return d(),n.getToken()!==2?b(7,[2],[]):v(),!0}function Gt(){g(),v();let x=!0,O=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(O||b(4,[],[]),S(","),v(),n.getToken()===4&&w)break}else O&&b(6,[],[]);x?(s.push(0),x=!1):s[s.length-1]++,he()||b(4,[],[4,5]),O=!0}return h(),x||s.pop(),n.getToken()!==4?b(8,[4],[]):v(),!0}function he(){switch(n.getToken()){case 3:return Gt();case 1:return Ut();case 10:return Ne(!0);default:return Dt()}}return v(),n.getToken()===17?r.allowEmptyContent?!0:(b(4,[],[]),!1):he()?(n.getToken()!==17&&b(9,[],[]),!0):(b(4,[],[]),!1)}var Fe;(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"})(Fe||(Fe={}));var _e;(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"})(_e||(_e={}));var oe=Ve;var De;(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"})(De||(De={}));var F=j(require("path"));var ye=(e,t,r)=>{let n=e instanceof RegExp?Ue(e,r):e,s=t instanceof RegExp?Ue(t,r):t,o=n!==null&&s!=null&&on(n,s,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+s.length)}},Ue=(e,t)=>{let r=t.match(e);return r?r[0]:null},on=(e,t,r)=>{let n,s,o,i,a,l=r.indexOf(e),u=r.indexOf(t,l+1),c=l;if(l>=0&&u>0){if(e===t)return[l,u];for(n=[],o=r.length;c>=0&&!a;){if(c===l)n.push(c),l=r.indexOf(e,c+1);else if(n.length===1){let f=n.pop();f!==void 0&&(a=[f,u])}else s=n.pop(),s!==void 0&&s<o&&(o=s,i=u),u=r.indexOf(t,c+1);c=l<u&&l>=0?l:u}n.length&&i!==void 0&&(a=[o,i])}return a};var Ge="\0SLASH"+Math.random()+"\0",ze="\0OPEN"+Math.random()+"\0",ke="\0CLOSE"+Math.random()+"\0",He="\0COMMA"+Math.random()+"\0",qe="\0PERIOD"+Math.random()+"\0",an=new RegExp(Ge,"g"),ln=new RegExp(ze,"g"),un=new RegExp(ke,"g"),cn=new RegExp(He,"g"),fn=new RegExp(qe,"g"),pn=/\\\\/g,dn=/\\{/g,gn=/\\}/g,hn=/\\,/g,mn=/\\./g,yn=1e5;function be(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function bn(e){return e.replace(pn,Ge).replace(dn,ze).replace(gn,ke).replace(hn,He).replace(mn,qe)}function kn(e){return e.replace(an,"\\").replace(ln,"{").replace(un,"}").replace(cn,",").replace(fn,".")}function Je(e){if(!e)return[""];let t=[],r=ye("{","}",e);if(!r)return e.split(",");let{pre:n,body:s,post:o}=r,i=n.split(",");i[i.length-1]+="{"+s+"}";let a=Je(o);return o.length&&(i[i.length-1]+=a.shift(),i.push.apply(i,a)),t.push.apply(t,i),t}function Xe(e,t={}){if(!e)return[];let{max:r=yn}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),Q(bn(e),r,!0).map(kn)}function wn(e){return"{"+e+"}"}function xn(e){return/^-?0\d/.test(e)}function vn(e,t){return e<=t}function Sn(e,t){return e>=t}function Q(e,t,r){let n=[],s=ye("{","}",e);if(!s)return[e];let o=s.pre,i=s.post.length?Q(s.post,t,!1):[""];if(/\$$/.test(s.pre))for(let a=0;a<i.length&&a<t;a++){let l=o+"{"+s.body+"}"+i[a];n.push(l)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),l=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),u=a||l,c=s.body.indexOf(",")>=0;if(!u&&!c)return s.post.match(/,(?!,).*\}/)?(e=s.pre+"{"+s.body+ke+s.post,Q(e,t,!0)):[e];let f;if(u)f=s.body.split(/\.\./);else if(f=Je(s.body),f.length===1&&f[0]!==void 0&&(f=Q(f[0],t,!1).map(wn),f.length===1))return i.map(d=>s.pre+f[0]+d);let p;if(u&&f[0]!==void 0&&f[1]!==void 0){let d=be(f[0]),g=be(f[1]),h=Math.max(f[0].length,f[1].length),y=f.length===3&&f[2]!==void 0?Math.abs(be(f[2])):1,S=vn;g<d&&(y*=-1,S=Sn);let m=f.some(xn);p=[];for(let k=d;S(k,g);k+=y){let w;if(l)w=String.fromCharCode(k),w==="\\"&&(w="");else if(w=String(k),m){let v=h-w.length;if(v>0){let b=new Array(v+1).join("0");k<0?w="-"+b+w.slice(1):w=b+w}}p.push(w)}}else{p=[];for(let d=0;d<f.length;d++)p.push.apply(p,Q(f[d],t,!1))}for(let d=0;d<p.length;d++)for(let g=0;g<i.length&&n.length<t;g++){let h=o+p[d]+i[g];(!r||u||h)&&n.push(h)}}return n}var Y=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Rn={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},C=e=>e.replace(/[[\]\\-]/g,"\\$&"),On=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ze=e=>e.join(""),Qe=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],s=[],o=r+1,i=!1,a=!1,l=!1,u=!1,c=r,f="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){u=!0,o++;continue}if(h==="]"&&i&&!l){c=o+1;break}if(i=!0,h==="\\"&&!l){l=!0,o++;continue}if(h==="["&&!l){for(let[y,[S,E,m]]of Object.entries(Rn))if(e.startsWith(y,o)){if(f)return["$.",!1,e.length-r,!0];o+=y.length,m?s.push(S):n.push(S),a=a||E;continue e}}if(l=!1,f){h>f?n.push(C(f)+"-"+C(h)):h===f&&n.push(C(h)),f="",o++;continue}if(e.startsWith("-]",o+1)){n.push(C(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){f=h,o+=2;continue}n.push(C(h)),o++}if(c<o)return["",!1,0,!1];if(!n.length&&!s.length)return["$.",!1,e.length-r,!0];if(s.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let h=n[0].length===2?n[0].slice(-1):n[0];return[On(h),!1,c-r,!1]}let p="["+(u?"^":"")+Ze(n)+"]",d="["+(u?"":"^")+Ze(s)+"]";return[n.length&&s.length?"("+p+"|"+d+")":n.length?p:d,a,c-r,!0]};var L=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?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 Tn=new Set(["!","?","+","*","@"]),Ye=e=>Tn.has(e),En="(?!(?:^|/)\\.\\.?(?:$|/))",ie="(?!\\.)",$n=new Set(["[","."]),Mn=new Set(["..","."]),An=new Set("().*{}+?[]^$\\!"),Pn=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),we="[^/]",Ce=we+"*?",Ke=we+"+?",H=class e{type;#n;#r;#o=!1;#e=[];#t;#i;#l;#a=!1;#s;#u;#f=!1;constructor(t,r,n={}){this.type=t,t&&(this.#r=!0),this.#t=r,this.#n=this.#t?this.#t.#n:this,this.#s=this.#n===this?n:this.#n.#s,this.#l=this.#n===this?[]:this.#n.#l,t==="!"&&!this.#n.#a&&this.#l.push(this),this.#i=this.#t?this.#t.#e.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#e)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#u!==void 0?this.#u:this.type?this.#u=this.type+"("+this.#e.map(t=>String(t)).join("|")+")":this.#u=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.#l.pop();){if(t.type!=="!")continue;let r=t,n=r.#t;for(;n;){for(let s=r.#i+1;!n.type&&s<n.#e.length;s++)for(let o of t.#e){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#e[s])}r=n,n=r.#t}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof e&&r.#t===this))throw new Error("invalid part: "+r);this.#e.push(r)}}toJSON(){let t=this.type===null?this.#e.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#e.map(r=>r.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.#i===0)return!0;let t=this.#t;for(let r=0;r<this.#i;r++){let n=t.#e[r];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.#i===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new e(this.type,t);for(let n of this.#e)r.copyIn(n);return r}static#c(t,r,n,s){let o=!1,i=!1,a=-1,l=!1;if(r.type===null){let d=n,g="";for(;d<t.length;){let h=t.charAt(d++);if(o||h==="\\"){o=!o,g+=h;continue}if(i){d===a+1?(h==="^"||h==="!")&&(l=!0):h==="]"&&!(d===a+2&&l)&&(i=!1),g+=h;continue}else if(h==="["){i=!0,a=d,l=!1,g+=h;continue}if(!s.noext&&Ye(h)&&t.charAt(d)==="("){r.push(g),g="";let y=new e(h,r);d=e.#c(t,y,d,s),r.push(y);continue}g+=h}return r.push(g),d}let u=n+1,c=new e(null,r),f=[],p="";for(;u<t.length;){let d=t.charAt(u++);if(o||d==="\\"){o=!o,p+=d;continue}if(i){u===a+1?(d==="^"||d==="!")&&(l=!0):d==="]"&&!(u===a+2&&l)&&(i=!1),p+=d;continue}else if(d==="["){i=!0,a=u,l=!1,p+=d;continue}if(Ye(d)&&t.charAt(u)==="("){c.push(p),p="";let g=new e(d,c);c.push(g),u=e.#c(t,g,u,s);continue}if(d==="|"){c.push(p),p="",f.push(c),c=new e(null,r);continue}if(d===")")return p===""&&r.#e.length===0&&(r.#f=!0),c.push(p),p="",r.push(...f,c),u;p+=d}return r.type=null,r.#r=void 0,r.#e=[t.substring(n-1)],u}static fromGlob(t,r={}){let n=new e(null,void 0,r);return e.#c(t,n,0,r),n}toMMPattern(){if(this!==this.#n)return this.#n.toMMPattern();let t=this.toString(),[r,n,s,o]=this.toRegExpSource();if(!(s||this.#r||this.#s.nocase&&!this.#s.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#s.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#s}toRegExpSource(t){let r=t??!!this.#s.dot;if(this.#n===this&&this.#d(),!this.type){let l=this.isStart()&&this.isEnd()&&!this.#e.some(d=>typeof d!="string"),u=this.#e.map(d=>{let[g,h,y,S]=typeof d=="string"?e.#g(d,this.#r,l):d.toRegExpSource(t);return this.#r=this.#r||y,this.#o=this.#o||S,g}).join(""),c="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&Mn.has(this.#e[0]))){let g=$n,h=r&&g.has(u.charAt(0))||u.startsWith("\\.")&&g.has(u.charAt(2))||u.startsWith("\\.\\.")&&g.has(u.charAt(4)),y=!r&&!t&&g.has(u.charAt(0));c=h?En:y?ie:""}let f="";return this.isEnd()&&this.#n.#a&&this.#t?.type==="!"&&(f="(?:$|\\/)"),[c+u+f,L(u),this.#r=!!this.#r,this.#o]}let n=this.type==="*"||this.type==="+",s=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#p(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let l=this.toString();return this.#e=[l],this.type=null,this.#r=void 0,[l,L(this.toString()),!1,!1]}let i=!n||t||r||!ie?"":this.#p(!0);i===o&&(i=""),i&&(o=`(?:${o})(?:${i})*?`);let a="";if(this.type==="!"&&this.#f)a=(this.isStart()&&!r?ie:"")+Ke;else{let l=this.type==="!"?"))"+(this.isStart()&&!r&&!t?ie:"")+Ce+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&i?")":this.type==="*"&&i?")?":`)${this.type}`;a=s+o+l}return[a,L(o),this.#r=!!this.#r,this.#o]}#p(t){return this.#e.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,s,o,i]=r.toRegExpSource(t);return this.#o=this.#o||i,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#g(t,r,n=!1){let s=!1,o="",i=!1,a=!1;for(let l=0;l<t.length;l++){let u=t.charAt(l);if(s){s=!1,o+=(An.has(u)?"\\":"")+u;continue}if(u==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?Ke:Ce,r=!0;continue}else a=!1;if(u==="\\"){l===t.length-1?o+="\\\\":s=!0;continue}if(u==="["){let[c,f,p,d]=Qe(t,l);if(p){o+=c,i=i||f,l+=p-1,r=r||d;continue}}if(u==="?"){o+=we,r=!0;continue}o+=Pn(u)}return[o,L(t),!!r,i]}};var xe=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var R=(e,t,r={})=>(Y(t),!r.nocomment&&t.charAt(0)==="#"?!1:new q(t,r).match(e)),Nn=/^\*+([^+@!?\*\[\(]*)$/,In=e=>t=>!t.startsWith(".")&&t.endsWith(e),jn=e=>t=>t.endsWith(e),Ln=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Vn=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Bn=/^\*+\.\*+$/,Fn=e=>!e.startsWith(".")&&e.includes("."),_n=e=>e!=="."&&e!==".."&&e.includes("."),Dn=/^\.\*+$/,Wn=e=>e!=="."&&e!==".."&&e.startsWith("."),Un=/^\*+$/,Gn=e=>e.length!==0&&!e.startsWith("."),zn=e=>e.length!==0&&e!=="."&&e!=="..",Hn=/^\?+([^+@!?\*\[\(]*)?$/,qn=([e,t=""])=>{let r=nt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Jn=([e,t=""])=>{let r=rt([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Xn=([e,t=""])=>{let r=rt([e]);return t?n=>r(n)&&n.endsWith(t):r},Zn=([e,t=""])=>{let r=nt([e]);return t?n=>r(n)&&n.endsWith(t):r},nt=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},rt=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},st=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",et={win32:{sep:"\\"},posix:{sep:"/"}},Qn=st==="win32"?et.win32.sep:et.posix.sep;R.sep=Qn;var A=Symbol("globstar **");R.GLOBSTAR=A;var Yn="[^/]",Cn=Yn+"*?",Kn="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",er="(?:(?!(?:\\/|^)\\.).)*?",tr=(e,t={})=>r=>R(r,e,t);R.filter=tr;var M=(e,t={})=>Object.assign({},e,t),nr=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return R;let t=R;return Object.assign((n,s,o={})=>t(n,s,M(e,o)),{Minimatch:class extends t.Minimatch{constructor(s,o={}){super(s,M(e,o))}static defaults(s){return t.defaults(M(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,o,i={}){super(s,o,M(e,i))}static fromGlob(s,o={}){return t.AST.fromGlob(s,M(e,o))}},unescape:(n,s={})=>t.unescape(n,M(e,s)),escape:(n,s={})=>t.escape(n,M(e,s)),filter:(n,s={})=>t.filter(n,M(e,s)),defaults:n=>t.defaults(M(e,n)),makeRe:(n,s={})=>t.makeRe(n,M(e,s)),braceExpand:(n,s={})=>t.braceExpand(n,M(e,s)),match:(n,s,o={})=>t.match(n,s,M(e,o)),sep:t.sep,GLOBSTAR:A})};R.defaults=nr;var ot=(e,t={})=>(Y(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Xe(e,{max:t.braceExpandMax}));R.braceExpand=ot;var rr=(e,t={})=>new q(e,t).makeRe();R.makeRe=rr;var sr=(e,t,r={})=>{let n=new q(t,r);return e=e.filter(s=>n.match(s)),n.options.nonull&&!e.length&&e.push(t),e};R.match=sr;var tt=/[?*]|[+@!]\(.*?\)|\[|\]/,or=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),q=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,r={}){Y(t),r=r||{},this.options=r,this.pattern=t,this.platform=r.platform||st,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.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 r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.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 s=this.globParts.map((o,i,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let l=o[0]===""&&o[1]===""&&(o[2]==="?"||!tt.test(o[2]))&&!tt.test(o[3]),u=/^[a-z]:/i.test(o[0]);if(l)return[...o.slice(0,4),...o.slice(4).map(c=>this.parse(c))];if(u)return[o[0],...o.slice(1).map(c=>this.parse(c))]}return o.map(l=>this.parse(l))});if(this.debug(this.pattern,s),this.set=s.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let i=this.set[o];i[0]===""&&i[1]===""&&this.globParts[o][2]==="?"&&typeof i[3]=="string"&&/^[a-z]:$/i.test(i[3])&&(i[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n=0;n<t.length;n++)for(let s=0;s<t[n].length;s++)t[n][s]==="**"&&(t[n][s]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let s=n;for(;r[s+1]==="**";)s++;s!==n&&r.splice(n,s-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,s)=>{let o=n[n.length-1];return s==="**"&&o==="**"?n:s===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(s),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let s=1;s<t.length-1;s++){let o=t[s];s===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(s,1),s--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let s=t[n-1];s&&s!=="."&&s!==".."&&s!=="**"&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let s=-1;for(;(s=n.indexOf("**",s+1))!==-1;){let i=s;for(;n[i+1]==="**";)i++;i>s&&n.splice(s+1,i-s);let a=n[s+1],l=n[s+2],u=n[s+3];if(a!==".."||!l||l==="."||l===".."||!u||u==="."||u==="..")continue;r=!0,n.splice(s,1);let c=n.slice(0);c[s]="**",t.push(c),s--}if(!this.preserveMultipleSlashes){for(let i=1;i<n.length-1;i++){let a=n[i];i===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(i,1),i--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let i=n[o-1];if(i&&i!=="."&&i!==".."&&i!=="**"){r=!0;let l=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...l),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let s=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(s){t[r]=[],t[n]=s;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let s=0,o=0,i=[],a="";for(;s<t.length&&o<r.length;)if(t[s]===r[o])i.push(a==="b"?r[o]:t[s]),s++,o++;else if(n&&t[s]==="**"&&r[o]===t[s+1])i.push(t[s]),s++;else if(n&&r[o]==="**"&&t[s]===r[o+1])i.push(r[o]),o++;else if(t[s]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",i.push(t[s]),s++,o++}else if(r[o]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(a==="a")return!1;a="b",i.push(r[o]),s++,o++}else return!1;return t.length===r.length&&i}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let s=0;s<t.length&&t.charAt(s)==="!";s++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let s=this.options;if(this.isWindows){let h=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),y=!h&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),S=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),E=!S&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),m=y?3:h?0:void 0,k=E?3:S?0:void 0;if(typeof m=="number"&&typeof k=="number"){let[w,v]=[t[m],r[k]];w.toLowerCase()===v.toLowerCase()&&(r[k]=w,k>m?r=r.slice(k):m>k&&(t=t.slice(m)))}}let{optimizationLevel:o=1}=this.options;o>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:r}),this.debug("matchOne",t.length,r.length);for(var i=0,a=0,l=t.length,u=r.length;i<l&&a<u;i++,a++){this.debug("matchOne loop");var c=r[a],f=t[i];if(this.debug(r,c,f),c===!1)return!1;if(c===A){this.debug("GLOBSTAR",[r,c,f]);var p=i,d=a+1;if(d===u){for(this.debug("** at the end");i<l;i++)if(t[i]==="."||t[i]===".."||!s.dot&&t[i].charAt(0)===".")return!1;return!0}for(;p<l;){var g=t[p];if(this.debug(`
|
|
9
|
+
globstar while`,t,p,r,d,g),this.matchOne(t.slice(p),r.slice(d),n))return this.debug("globstar found match!",p,l,g),!0;if(g==="."||g===".."||!s.dot&&g.charAt(0)==="."){this.debug("dot detected!",t,p,r,d);break}this.debug("globstar swallow a segment, and continue"),p++}return!!(n&&(this.debug(`
|
|
10
|
+
>>> no match, partial?`,t,p,r,d),p===l))}let h;if(typeof c=="string"?(h=f===c,this.debug("string match",c,f,h)):(h=c.test(f),this.debug("pattern match",c,f,h)),!h)return!1}if(i===l&&a===u)return!0;if(i===l)return n;if(a===u)return i===l-1&&t[i]==="";throw new Error("wtf?")}braceExpand(){return ot(this.pattern,this.options)}parse(t){Y(t);let r=this.options;if(t==="**")return A;if(t==="")return"";let n,s=null;(n=t.match(Un))?s=r.dot?zn:Gn:(n=t.match(Nn))?s=(r.nocase?r.dot?Vn:Ln:r.dot?jn:In)(n[1]):(n=t.match(Hn))?s=(r.nocase?r.dot?Jn:qn:r.dot?Xn:Zn)(n):(n=t.match(Bn))?s=r.dot?_n:Fn:(n=t.match(Dn))&&(s=Wn);let o=H.fromGlob(t,this.options).toMMPattern();return s&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:s}),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 r=this.options,n=r.noglobstar?Cn:r.dot?Kn:er,s=new Set(r.nocase?["i"]:[]),o=t.map(l=>{let u=l.map(f=>{if(f instanceof RegExp)for(let p of f.flags.split(""))s.add(p);return typeof f=="string"?or(f):f===A?A:f._src});u.forEach((f,p)=>{let d=u[p+1],g=u[p-1];f!==A||g===A||(g===void 0?d!==void 0&&d!==A?u[p+1]="(?:\\/|"+n+"\\/)?"+d:u[p]=n:d===void 0?u[p-1]=g+"(?:\\/|\\/"+n+")?":d!==A&&(u[p-1]=g+"(?:\\/|\\/"+n+"\\/)"+d,u[p+1]=A))});let c=u.filter(f=>f!==A);if(this.partial&&c.length>=1){let f=[];for(let p=1;p<=c.length;p++)f.push(c.slice(0,p).join("/"));return"(?:"+f.join("|")+")"}return c.join("/")}).join("|"),[i,a]=t.length>1?["(?:",")"]:["",""];o="^"+i+o+a+"$",this.partial&&(o="^(?:\\/|"+i+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...s].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,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let s=this.slashSplit(t);this.debug(this.pattern,"split",s);let o=this.set;this.debug(this.pattern,"set",o);let i=s[s.length-1];if(!i)for(let a=s.length-2;!i&&a>=0;a--)i=s[a];for(let a=0;a<o.length;a++){let l=o[a],u=s;if(n.matchBase&&l.length===1&&(u=[i]),this.matchOne(u,l,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return R.defaults(t).Minimatch}};R.AST=H;R.Minimatch=q;R.escape=xe;R.unescape=L;var _="pickety.json",J=["ts","tsx","js","jsx","mjs","cjs"],ir=`**/*.{${J.join(",")}}`,ae=new Set(["node_modules",".git",".next","dist","out","build",".turbo",".cache",".nx","coverage"]);function T(e){let t=e.replace(/\\/g,"/");return/^[a-zA-Z]:/.test(t)&&(t=t[0].toLowerCase()+t.slice(1)),t}function X(e,t){return F.relative(e,t).replace(/\\/g,"/")}function ve(e,t){return R(e,t)||e===t}function ar(e){return["*","?","[","]","{","}","(",")","!","+","@"].some(r=>e.includes(r))}function Se(e,t,r){if(!r||r.length===0)return!1;let n=T(F.relative(t,F.resolve(e)));return n===""||n.startsWith("..")?!1:r.some(s=>{let o=s.trim();if(!o)return!1;let i=T(o).replace(/^\.?\//,"").replace(/^\/+/,"");return(ar(i)?[i]:[i,`${i}/**`]).some(l=>R(n,l)||R(n,`**/${l}`))})}function Re(e){return F.join(e,_)}function le(e,t){return e==="instability"?t.toFixed(2):String(t)}function ue(e){let t=0,r=0,n=0;for(let s of e)s.severity==="error"?t+=1:s.severity==="warn"?r+=1:n+=1;return{errors:t,warnings:r,info:n}}function lr(e,t,r){let n=Oe(e),s=e.name??`rule[${t}]`,o=e.group,i=o?`${o}: ${s}`:s;return{allow:e.allow??!1,severity:e.severity??r,name:s,group:o,label:i,effectiveImporter:n?.path||e.importer||"*",isOnly:e.only||!!e.containedTo,isAllowStyle:(e.allow??!1)||!!e.containedTo||!!e.only}}function it(e,t,r){let n=lr(e,t,r),s=Array.isArray(e.imports)?e.imports:[e.imports];return{rule:e,...n,importPatterns:s.filter(o=>typeof o=="string")}}function P(e,t,r){let n=e.includes("[")?e.slice(0,e.indexOf("[")):e;return!!(ve(e,r)||ve(n,r)||r.includes("/")&&(R(t,r)||R(t,`**/${r}`)||R(t,`**/${r}/**`)))}function Oe(e){if(e.containedTo)return typeof e.containedTo=="object"?e.containedTo:{path:e.containedTo}}function D(e){let{filePath:t,importStmt:r,ruleName:n,ruleLabel:s,message:o,severity:i,sourceModule:a,targetModule:l,ruleGroup:u}=e;return{file:t,line:r.line,character:r.character,length:r.length,message:`[${s}] ${o} (importing "${r.specifier}")`,severity:i,ruleName:n,ruleGroup:u,sourceModule:a,targetModule:l}}function at(e){let t=[],r=new Set,n=new Set,s=[];function o(i){r.add(i),n.add(i),s.push(i);let a=e.get(i);if(a){for(let l of a)if(!r.has(l))o(l);else if(n.has(l)){let u=s.indexOf(l);u!==-1&&t.push([...s.slice(u),l])}}n.delete(i),s.pop()}for(let i of e.keys())r.has(i)||o(i);return t}var lt={modules:{app:"src/app/**",features:"src/features/**",shared:"src/shared/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"shared",imports:["app","features"],allow:!1,message:"Shared code should stay independent of app and feature modules."},{importer:"features",imports:"app",allow:!1,message:"Feature modules should not depend on the app layer."}]}}};var ut={modules:{domain:"src/domain/**",application:"src/application/**",ports:"src/ports/**",adapters:"src/adapters/**",infrastructure:"src/infrastructure/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"domain",imports:["application","ports","adapters","infrastructure"],allow:!1,message:"Domain should not depend on outer layers."},{importer:"application",imports:["adapters","infrastructure"],allow:!1,message:"Application should not depend on adapters or infrastructure."},{importer:"ports",imports:["adapters","infrastructure"],allow:!1,message:"Ports should remain independent of adapters and infrastructure."},{importer:"adapters",imports:"infrastructure",allow:!1,message:"Adapters should not depend on infrastructure."}]}}};var ct={modules:{presentation:"src/presentation/**",application:"src/application/**",domain:"src/domain/**",infrastructure:"src/infrastructure/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"domain",imports:["application","presentation","infrastructure"],allow:!1,message:"Domain should not depend on outer layers."},{importer:"application",imports:["presentation","infrastructure"],allow:!1,message:"Application should not depend on presentation or infrastructure."},{importer:"presentation",imports:"infrastructure",allow:!1,message:"Presentation should not depend directly on infrastructure."}]}}};var ft={hexagonal:ut,"feature-modules":lt,layered:ct};function ce(e){return ft[e]}function K(){return Object.keys(ft)}function pt(e){let{ruleRecord:t,index:r,rulePath:n,errors:s}=e;if(typeof t.containedTo=="object"&&t.containedTo!==null){let o=t.containedTo;if(typeof o.path!="string"&&s.push({message:`Rule #${r}: "containedTo.path" is required and must be a string`,path:`${n}.containedTo.path`}),o.unless!==void 0)if(typeof o.unless!="object"||o.unless===null||Array.isArray(o.unless))s.push({message:`Rule #${r}: "containedTo.unless" must be an object`,path:`${n}.containedTo.unless`});else{let i=o.unless;Object.keys(i).length===0&&s.push({message:`Rule #${r}: "containedTo.unless" must not be empty`,path:`${n}.containedTo.unless`}),(Array.isArray(t.imports)?t.imports.filter(c=>typeof c=="string"):typeof t.imports=="string"?[t.imports]:[]).some(c=>c.match(/\$[\w-]+/))||s.push({message:`Rule #${r}: "containedTo.unless" requires "imports" to contain at least one $variable`,path:`${n}.containedTo.unless`});for(let[c,f]of Object.entries(i))c.startsWith("$")||s.push({message:`Rule #${r}: "containedTo.unless" key "${c}" must start with $`,path:`${n}.containedTo.unless`}),typeof f!="string"&&s.push({message:`Rule #${r}: "containedTo.unless.${c}" must be a string`,path:`${n}.containedTo.unless.${c}`})}}else typeof t.containedTo!="string"&&s.push({message:`Rule #${r}: "containedTo" must be a string or object with a "path" property`,path:`${n}.containedTo`})}function N(e){return e.match(/\$[\w-]+/g)||[]}function dt(e){let t=new Set;for(let r of e)for(let n of N(r))t.add(n);return[...t]}function ee(e,t,r){let n=e.split("/"),s=t.split("/"),o=0,i=n.filter(l=>l!=="**").length,a=s.length-i;for(let l=o;l<=a;l++){let u=gt({patternSegments:n,pathSegments:s,startOffset:l,variables:r});if(u)return u}}function gt(e){let{patternSegments:t,pathSegments:r,startOffset:n,variables:s}=e,o={},i=n;for(let a=0;a<t.length;a++){let l=t[a];if(l==="**"){let p=t.slice(a+1);if(p.length===0)return o;for(let d=i;d<=r.length-p.length;d++){let g=gt({patternSegments:p,pathSegments:r,startOffset:d,variables:s});if(g)return{...o,...g}}return}if(i>=r.length)return;let u=l,c=[];for(let p of s)u.includes(p)&&(u=u.replace(p,`__VAR_${c.length}__`),c.push(p));u=u.replace(/[.+?^{}()|[\]\\]/g,"\\$&"),u=u.replace(/\*/g,"[^/]*");for(let p=0;p<c.length;p++)u=u.replace(`__VAR_${p}__`,"([^/]+)");let f=r[i].match(new RegExp(`^${u}$`));if(!f)return;for(let p=0;p<c.length;p++)o[c[p]]=f[p+1];i++}return o}function W(e,t,r){let n=e;for(let s of t){let o=typeof r=="string"?r:r[s];n=n.replaceAll(s,o)}return n}function mt(e,t,r){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 s=e["module-boundaries"];if(s===void 0){t.push({message:'"rules.module-boundaries" is required and must be an object',path:"rules.module-boundaries"});return}if(typeof s!="object"||s===null){t.push({message:'"rules.module-boundaries" must be an object',path:"rules.module-boundaries"});return}let o=s,i="error";if(o.severity!==void 0&&(o.severity!=="error"&&o.severity!=="warn"?t.push({message:`"rules.module-boundaries.severity" must be "error" or "warn", got "${o.severity}"`,path:"rules.module-boundaries.severity"}):i=o.severity),o.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(o.rules)){t.push({message:'"rules.module-boundaries.rules" must be an array',path:"rules.module-boundaries.rules"});return}let a=[];return o.rules.forEach((l,u)=>{let c=ur({rule:l,index:u,errors:t,warnings:r});c&&a.push(c)}),{severity:i,rules:a}}function ur(e){let{rule:t,index:r,errors:n,warnings:s}=e,o=`rules.module-boundaries.rules[${r}]`;if(typeof t!="object"||t===null){n.push({message:`Rule #${r} must be an object`,path:o});return}let i=t,a=cr({r:i,index:r,rulePath:o,errors:n}),l=fr({r:i,index:r,rulePath:o,errors:n});if(!l)return;let u={imports:l};a!==void 0&&(u.importer=a),typeof i.allow=="boolean"&&(u.allow=i.allow),typeof i.only=="boolean"&&(u.only=i.only),i.containedTo!==void 0&&(pt({ruleRecord:i,index:r,rulePath:o,errors:n}),u.containedTo=i.containedTo),pr({r:i,index:r,rulePath:o,errors:n,result:u});let c=dr(i,o,n);return c&&(u.exports=c),gr({r:i,index:r,rulePath:o,imports:l,warnings:s}),u}function cr(e){let{r:t,index:r,rulePath:n,errors:s}=e,o=typeof t.containedTo=="string"||typeof t.containedTo=="object"&&t.containedTo!==null;if(typeof t.importer!="string"&&!o&&s.push({message:`Rule #${r}: "importer" or "containedTo" is required`,path:n}),t.importer!==void 0){if(typeof t.importer!="string"){s.push({message:`Rule #${r}: "importer" must be a string`,path:`${n}.importer`});return}return t.importer}}function fr(e){let{r:t,index:r,rulePath:n,errors:s}=e;if(typeof t.imports=="string")return t.imports;if(Array.isArray(t.imports)){let o=t.imports.findIndex(i=>typeof i!="string");if(o!==-1){s.push({message:`Rule #${r}: "imports" entries must be strings`,path:`${n}.imports[${o}]`});return}return t.imports}s.push({message:`Rule #${r}: "imports" is required and must be a string or string[]`,path:`${n}.imports`})}function pr(e){let{r:t,index:r,rulePath:n,errors:s,result:o}=e;t.allow!==void 0&&typeof t.allow!="boolean"&&s.push({message:`Rule #${r}: "allow" must be a boolean`,path:`${n}.allow`}),t.only!==void 0&&typeof t.only!="boolean"&&s.push({message:`Rule #${r}: "only" must be a boolean`,path:`${n}.only`}),t.message!==void 0&&(typeof t.message!="string"?s.push({message:`Rule #${r}: "message" must be a string`,path:`${n}.message`}):o.message=t.message),t.severity!==void 0&&(t.severity!=="error"&&t.severity!=="warn"?s.push({message:`Rule #${r}: "severity" must be "error" or "warn", got "${t.severity}"`,path:`${n}.severity`}):o.severity=t.severity),t.name!==void 0&&(typeof t.name!="string"?s.push({message:`Rule #${r}: "name" must be a string`,path:`${n}.name`}):o.name=t.name),t.group!==void 0&&(typeof t.group!="string"?s.push({message:`Rule #${r}: "group" must be a string`,path:`${n}.group`}):o.group=t.group),t.maxViolations!==void 0&&(typeof t.maxViolations!="number"||!Number.isInteger(t.maxViolations)||t.maxViolations<0?s.push({message:`Rule #${r}: "maxViolations" must be a non-negative integer`,path:`${n}.maxViolations`}):o.maxViolations=t.maxViolations)}function dr(e,t,r){if(e.exports!==void 0){if(Array.isArray(e.exports)){let n=[];return e.exports.forEach((s,o)=>{let i=ht(s,`${t}.exports[${o}]`,r);i&&n.push(i)}),n.length>0?n:void 0}return ht(e.exports,`${t}.exports`,r)}}function gr(e){let{r:t,index:r,rulePath:n,imports:s,warnings:o}=e,i=Array.isArray(s)?s:[s],a=new Set(dt(i)),l=(u,c,f)=>{let d=N(u).filter(g=>!a.has(g));if(d.length>0){let g=Array.from(new Set(d));o.push({message:`Rule #${r}: ${f} references variables not present in "imports": ${g.join(", ")}`,path:c})}};typeof t.importer=="string"&&l(t.importer,`${n}.importer`,'"importer"'),typeof t.containedTo=="string"?l(t.containedTo,`${n}.containedTo`,'"containedTo"'):typeof t.containedTo=="object"&&t.containedTo!==null&&typeof t.containedTo.path=="string"&&l(t.containedTo.path,`${n}.containedTo.path`,'"containedTo.path"')}function ht(e,t,r){if(typeof e!="object"||e===null){r.push({message:`"${t}" must be an object`,path:t});return}let n=e,s=!1;if(typeof n.path!="string"&&(r.push({message:`"${t}.path" is required and must be a string`,path:`${t}.path`}),s=!0),typeof n.to!="string"&&(r.push({message:`"${t}.to" is required and must be a string`,path:`${t}.to`}),s=!0),n.message!==void 0&&typeof n.message!="string"&&(r.push({message:`"${t}.message" must be a string`,path:`${t}.message`}),s=!0),!s)return{path:n.path,to:n.to,message:typeof n.message=="string"?n.message:void 0}}function yt(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 r=e,n={},s=[{key:"maxAfferentCoupling",label:"maxAfferentCoupling"},{key:"maxEfferentCoupling",label:"maxEfferentCoupling"},{key:"maxDepth",label:"maxDepth"}];for(let{key:o,label:i}of s){let a=r[o];a!==void 0&&(typeof a!="number"||!Number.isInteger(a)||a<1?t.push({message:`"health.${i}" must be a positive integer`,path:`health.${i}`}):n[o]=a)}if(r.maxInstability!==void 0){let o=r.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 bt(e){let t=[],r=[];if(typeof e!="object"||e===null)return{ok:!1,errors:[{message:"Configuration must be a JSON object"}]};let n=e,s=hr(n.modules,t),o=mt(n.rules,t,r),i=mr(n["boundary-diagrams"],t),a=yt(n.health,t),l=yr(n.warnOnUntrackedImporters,t),u=br(n.ignore,t);return t.length>0||!s||!o?r.length>0?{ok:!1,errors:t,warnings:r}:{ok:!1,errors:t}:{ok:!0,config:{modules:s,rules:{"module-boundaries":o},ignore:u,warnOnUntrackedImporters:l,"boundary-diagrams":i,health:a},warnings:r.length>0?r:void 0}}function hr(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 r={};for(let[n,s]of Object.entries(e))typeof s!="string"?t.push({message:`Module "${n}" pattern must be a string, got ${typeof s}`,path:`modules.${n}`}):r[n]=s;return r}function mr(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 yr(e,t){return e===void 0?!0:typeof e!="boolean"?(t.push({message:'"warnOnUntrackedImporters" must be a boolean',path:"warnOnUntrackedImporters"}),!0):e}function br(e,t){if(e===void 0)return;if(!Array.isArray(e)){t.push({message:'"ignore" must be an array of glob patterns',path:"ignore"});return}if(e.find(n=>typeof n!="string")!==void 0){t.push({message:'"ignore" entries must be strings',path:"ignore"});return}return e}function wt(e){let t=kt.join(e,_);if(!pe.existsSync(t))return{ok:!0,config:void 0};try{let r=pe.readFileSync(t,"utf-8"),n;try{n=oe(r)}catch(s){return{ok:!1,errors:[{message:`pickety.json is not valid JSONC: ${s instanceof Error?s.message:String(s)}`}]}}if(typeof n=="object"&&n!==null){let s=n;if(s.preset!==void 0&&typeof s.preset!="string")return{ok:!1,errors:[{message:'"preset" must be a string',path:"preset"}]};if(typeof s.preset=="string"){let o=ce(s.preset);if(!o)return{ok:!1,errors:[{message:`Unknown preset "${s.preset}". Available presets: ${K().join(", ")}`,path:"preset"}]};n=Sr(o,s)}}return bt(n)}catch(r){return{ok:!1,errors:[{message:`Failed to read pickety.json: ${r instanceof Error?r.message:String(r)}`}]}}}function fe(e){return typeof e=="object"&&e!==null}function kr(e,t){return t===void 0?e:!fe(t)||!e?t:{...e,...t}}function wr(e){let{merged:t,preset:r,override:n,keys:s}=e;for(let o of s)n[o]!==void 0?t[o]=n[o]:r[o]!==void 0&&(t[o]=r[o])}function xr(e,t){return t===void 0?e:fe(t)?{...e,...t}:t}function vr(e,t){if(t===void 0)return e;if(!fe(t))return t;let r=t["module-boundaries"];if(!fe(r))return t;let n={...e,...t},s=e["module-boundaries"],o={...s,...r},i=Array.isArray(s.rules)?s.rules:[];return r.rules===void 0?o.rules=i:Array.isArray(r.rules)?o.rules=[...i,...r.rules]:o.rules=r.rules,n["module-boundaries"]=o,n}function Sr(e,t){let r={...e,...t};return r.modules=xr(e.modules,t.modules),r.rules=vr(e.rules,t.rules),wr({merged:r,preset:e,override:t,keys:["warnOnUntrackedImporters","boundary-diagrams","ignore","version"]}),r.health=kr(e.health,t.health),r}var de=j(require("fs")),V=j(require("path"));function xt(e,t){if(t<0)return[];let r=[],n;try{n=de.readdirSync(e,{withFileTypes:!0})}catch{return r}for(let s of n)!ae.has(s.name)&&s.isFile()&&/^tsconfig(\..+)?\.json$/.test(s.name)&&r.push(V.join(e,s.name));for(let s of n)!ae.has(s.name)&&s.isDirectory()&&r.push(...xt(V.join(e,s.name),t-1));return r}function vt(e){let t={},r=xt(e,4);for(let n of r)try{let s=de.readFileSync(n,"utf-8"),i=oe(s).compilerOptions;if(!i?.paths)continue;let a=V.dirname(n),l=V.relative(e,a),u=i.baseUrl||".";for(let[c,f]of Object.entries(i.paths))if(Array.isArray(f)&&f.length>0){let p=f[0];t[c]||(t[c]=T(V.join(l,u,p)))}}catch{}return t}var Me=j(require("path"));var B=j(require("path"));var Rt=J.map(e=>`.${e}`),Rr=Rt.map(e=>`index${e}`),St=/(\/\*[\s\S]*?\*\/|\/\/.*)|(['"`](?:\\.|[^'"`])*['"`])|((?:import|export)\s+(?:[\s\S]*?from\s+)?['"`]([^'"`]+)['"`])|(import\s*\(\s*['"`]([^'"`]+)['"`]\s*\))/gm;function Or(e){let t=[],r=e.split(`
|
|
11
|
+
`),n=[],s=0;for(let a of r)n.push(s),s+=a.length+1;let o=a=>{let l=0;for(let u=1;u<n.length&&!(n[u]>a);u++)l=u;return{line:l,character:a-n[l]}},i;for(St.lastIndex=0;(i=St.exec(e))!==null;){let[a,l,u,c,f,p,d]=i;if(!(l||u)){if(c&&f){let g=o(i.index);t.push({specifier:f,line:g.line,character:g.character,length:c.length})}else if(p&&d){let g=o(i.index);t.push({specifier:d,line:g.line,character:g.character,length:p.length})}}}return t}function Tr(e,t,r){let{knownFiles:n,root:s,aliases:o}=r;for(let[i,a]of Object.entries(o))if(i.endsWith("/*")){let l=i.slice(0,-2),u=a.endsWith("/*")?a.slice(0,-2):a==="*"?"./":a;if(e.startsWith(l)){let c=e.replace(l,u);return Te(B.resolve(s,c),n)}}else if(e===i)return Te(B.resolve(s,a),n);if(e.startsWith(".")){let i=B.dirname(t),a=B.resolve(i,e);return Te(a,n)}}function Te(e,t){let r=T(e);if(t.has(r))return r;for(let n of Rt){let s=r+n;if(t.has(s))return s}for(let n of Rr){let s=r+"/"+n;if(t.has(s))return s}}function Er(e){return e.endsWith("/*")?e.slice(0,-2)+"/**/*":e}function $r(e,t,r){if(t.length===0)return e;let n=t.map(s=>r[s]);return`${e}[${n.join(",")}]`}function Mr(e,t,r){let n=T(B.relative(r,e));for(let[s,o]of Object.entries(t)){let i=Er(o),a=N(o);if(a.length>0){let l=ee(i,n,a)||(i!==o?ee(o,n,a):void 0);if(l)return{name:$r(s,a,l),pattern:o,relativePath:n,variables:l};continue}if(R(n,i)||R(n,o))return{name:s,pattern:o,relativePath:n}}}function $(e,t,r){return Mr(e,t,r)?.name}function ge(e,t,r){let n=Or(t),s=[];for(let o of n){let i=Tr(o.specifier,e,r);i&&s.push({statement:o,resolvedPath:i})}return s}function Et(e){return e.isOnly?Ar(e):Pr(e)}function Ee(e){let{pattern:t,variables:r,moduleName:n,relativePath:s}=e,o=t.includes("/")?s:n;return ee(t,o,r)}function Ar(e){let{rule:t,importsPattern:r,variables:n,effectiveImporter:s,ruleSeverity:o,ruleName:i,ruleLabel:a,ruleGroup:l,ctx:u}=e,c=Ee({pattern:r,variables:n,moduleName:u.targetModule,relativePath:u.targetRelativePath});if(!c||Lr(t,c))return;let f=W(s,n,c);if(!P(u.sourceModule,u.sourceRelativePath,f)){if($e(t,u,c))return;let d=t.message||`Module "${u.sourceModule}" is not allowed to import from "${u.targetModule}" (contained to "${f}")`;return D({filePath:u.filePath,importStmt:u.importStmt,ruleName:i,ruleLabel:a,message:d,severity:o,sourceModule:u.sourceModule,targetModule:u.targetModule,ruleGroup:l})}}function Pr(e){let{rule:t,importsPattern:r,variables:n,allow:s,effectiveImporter:o,ruleSeverity:i,ruleName:a,ruleLabel:l,ruleGroup:u,ctx:c}=e,f=Ee({pattern:o,variables:n,moduleName:c.sourceModule,relativePath:c.sourceRelativePath});if(f)if(s){let p=W(r,n,"*"),d=W(r,n,f),g=P(c.targetModule,c.targetRelativePath,p),h=P(c.targetModule,c.targetRelativePath,d);if(g&&!h){let y=t.message||`Import must match scoped pattern "${d}"`;return D({filePath:c.filePath,importStmt:c.importStmt,ruleName:a,ruleLabel:l,message:y,severity:i,sourceModule:c.sourceModule,targetModule:c.targetModule,ruleGroup:u})}}else{let p=W(r,n,f);if(P(c.targetModule,c.targetRelativePath,p)){let g=t.message||`Module "${c.sourceModule}" cannot import from "${c.targetModule}"`;return D({filePath:c.filePath,importStmt:c.importStmt,ruleName:a,ruleLabel:l,message:g,severity:i,sourceModule:c.sourceModule,targetModule:c.targetModule,ruleGroup:u})}}}function Nr(e){return e?Array.isArray(e)?e:[e]:[]}var Ot=new WeakMap;function Ir(e){let t=Ot.get(e);if(t)return t;let n=Nr(e.exports).map(s=>({entry:s,pathVars:N(s.path),toVars:N(s.to)}));return Ot.set(e,n),n}function $e(e,t,r){let n=Ir(e);if(n.length===0)return!1;for(let{entry:s,pathVars:o,toVars:i}of n){let a=o.length>0?Tt({pattern:s.path,variables:o,preferred:r,moduleName:t.targetModule,relativePath:t.targetRelativePath}):{};if(o.length>0&&!a)continue;let l=i.length>0?Tt({pattern:s.to,variables:i,preferred:void 0,moduleName:t.sourceModule,relativePath:t.sourceRelativePath}):{};if(i.length>0&&!l)continue;let u=jr(a??{},l??{});if(!u)continue;let c=o.length>0?W(s.path,o,u):s.path;if(!P(t.targetModule,t.targetRelativePath,c))continue;let f=i.length>0?W(s.to,i,u):s.to;if(P(t.sourceModule,t.sourceRelativePath,f))return!0}return!1}function Tt(e){let{pattern:t,variables:r,preferred:n,moduleName:s,relativePath:o}=e;return n&&r.every(i=>n[i]!==void 0)?n:Ee({pattern:t,variables:r,moduleName:s,relativePath:o})}function jr(e,t){let r={...e};for(let[n,s]of Object.entries(t)){if(r[n]!==void 0&&r[n]!==s)return;r[n]=s}return r}function Lr(e,t){let r=Oe(e);if(r&&r.unless){let n=Object.entries(r.unless);return n.length>0&&n.every(([s,o])=>t[s]===o)}return!1}function $t(e,t){let{rule:r,allow:n,severity:s,name:o,label:i,group:a,effectiveImporter:l,isOnly:u,importPatterns:c}=e;for(let f of c){let p=N(u?f:l);if(p.length>0){let h=Et({rule:r,importsPattern:f,variables:p,isOnly:u,allow:n,effectiveImporter:l,ruleSeverity:s,ruleName:o,ruleLabel:i,ruleGroup:a,ctx:t});if(h)return h;continue}let d=P(t.sourceModule,t.sourceRelativePath,l),g=P(t.targetModule,t.targetRelativePath,f);if(u){if(g&&!d){if($e(r,t))return;let h=r.message||(r.containedTo?`Import is restricted: "${t.targetModule}" is contained to "${l}"`:`Module "${t.targetModule}" can only be imported by "${l}"`);return D({filePath:t.filePath,importStmt:t.importStmt,ruleName:o,ruleLabel:i,message:h,severity:s,sourceModule:t.sourceModule,targetModule:t.targetModule,ruleGroup:a})}}else if(d&&g&&!n){let h=r.message||`Module "${t.sourceModule}" cannot import from "${t.targetModule}"`;return D({filePath:t.filePath,importStmt:t.importStmt,ruleName:o,ruleLabel:i,message:h,severity:s,sourceModule:t.sourceModule,targetModule:t.targetModule,ruleGroup:a})}}}function Mt(e){let{filePath:t,content:r,config:n,ctx:s}=e,o=[],{modules:i}=n,{severity:a,rules:l}=n.rules["module-boundaries"],{root:u}=s,c=n.warnOnUntrackedImporters??!0,f=l.map((h,y)=>it(h,y,a)),p=$(t,i,u);if(!p)return c&&o.push({file:t,line:0,character:0,length:1,message:"This file is not covered by any declared module. Import rules will not be enforced here.",severity:"info"}),o;let d=T(Me.relative(u,t)),g=ge(t,r,s);for(let{statement:h,resolvedPath:y}of g){let S=$(y,i,u);if(!S)continue;let E=T(Me.relative(u,y)),m={sourceModule:p,sourceRelativePath:d,targetModule:S,targetRelativePath:E,filePath:t,importStmt:h};for(let k of f){let w=$t(k,m);w&&o.push(w)}}return o}function At(e,t){let r=t.rules["module-boundaries"].rules,n=new Map;if(r.forEach((o,i)=>{if(o.maxViolations!==void 0){let a=o.name??`rule[${i}]`;n.set(a,o.maxViolations)}}),n.size===0)return e;let s=new Map;for(let o of e)o.ruleName&&n.has(o.ruleName)&&s.set(o.ruleName,(s.get(o.ruleName)??0)+1);return e.map(o=>{if(!o.ruleName||!n.has(o.ruleName))return o;let i=s.get(o.ruleName)??0,a=n.get(o.ruleName),l=i<=a?"warn":"error";return l===o.severity?o:{...o,severity:l}})}function Ae(e,t,r){let n=new Set,s=ge(e,t,r),o=T(e);for(let{resolvedPath:i}of s)i&&i!==o&&n.add(i);return n}var te=class{dependents=new Map;dependencies=new Map;updateFile(t,r){let n=this.dependencies.get(t);if(n)for(let s of n)this.dependents.get(s)?.delete(t);this.dependencies.set(t,new Set(r));for(let s of r)this.dependents.has(s)||this.dependents.set(s,new Set),this.dependents.get(s).add(t)}removeFile(t){let r=this.dependencies.get(t);if(r)for(let s of r)this.dependents.get(s)?.delete(t);this.dependencies.delete(t);let n=this.dependents.get(t);if(n)for(let s of n)this.dependencies.get(s)?.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 r=new Set,n=[t],s=0;for(;s<n.length;){let o=n[s++],i=this.dependents.get(o);if(i)for(let a of i)!r.has(a)&&a!==t&&(r.add(a),n.push(a))}return r}getModuleSummary(t,r,n){let s=this.getDependents(t),o=this.getDependencies(t),i=new Set;for(let l of s){let u=$(l,r,n);u&&i.add(u)}let a=new Set;for(let l of o){let u=$(l,r,n);u&&a.add(u)}return{dependentCount:s.size,dependentModules:[...i],dependencyCount:o.size,dependencyModules:[...a]}}getModuleLevelGraph(t,r){let n=new Map;for(let[s,o]of this.dependencies){let i=$(s,t,r);if(i){n.has(i)||n.set(i,new Set);for(let a of o){let l=$(a,t,r);l&&l!==i&&n.get(i).add(l)}}}return n}clear(){this.dependents.clear(),this.dependencies.clear()}};function Pt(e,t,r){let{root:n,knownFiles:s}=r,o=e.getModuleLevelGraph(t,n),i=Object.keys(t),a=new Map;for(let f of i)a.set(f,0);for(let f of s){let p=$(f,t,n);p&&a.set(p,(a.get(p)??0)+1)}let l=new Map;for(let f of i)l.set(f,0);for(let[,f]of o)for(let p of f)l.set(p,(l.get(p)??0)+1);let u=Vr(o,i),c=i.map(f=>{let p=l.get(f)??0,d=o.get(f)?.size??0,g=p+d;return{moduleName:f,fileCount:a.get(f)??0,afferentCoupling:p,efferentCoupling:d,instability:g===0?0:d/g,dependencyDepth:u.get(f)??0}});return c.sort((f,p)=>f.instability-p.instability),c}function Vr(e,t){let r=new Map,n=new Set;function s(o){if(r.has(o))return r.get(o);if(n.has(o))return 0;n.add(o);let i=e.get(o),a=0;if(i&&i.size>0)for(let l of i)a=Math.max(a,1+s(l));return n.delete(o),r.set(o,a),a}for(let o of t)s(o);return r}function Nt(e,t){let r=[],n=[{key:"maxAfferentCoupling",label:"afferent coupling",getValue:s=>s.afferentCoupling},{key:"maxEfferentCoupling",label:"efferent coupling",getValue:s=>s.efferentCoupling},{key:"maxInstability",label:"instability",getValue:s=>s.instability},{key:"maxDepth",label:"dependency depth",getValue:s=>s.dependencyDepth}];for(let s of e)for(let o of n){let i=t[o.key],a=o.getValue(s);i!==void 0&&a>i&&r.push({moduleName:s.moduleName,metric:o.label,value:a,threshold:i})}return r}function It(e,t){let r=X(t,e.file),n=e.line+1,s=e.character+1,o=e.severity==="error"?"error":e.severity==="info"?"info":"warning";return`${r}:${n}:${s}: ${o} ${e.message}`}function jt(e){let t=new Map,r=0,n=!1;for(let o of e)o.ruleGroup?(n=!0,t.set(o.ruleGroup,(t.get(o.ruleGroup)??0)+1)):r+=1;if(!n)return;let s=[];s.push(""),s.push("Groups:");for(let[o,i]of t.entries())s.push(` ${o}: ${i}`);return r>0&&s.push(` (ungrouped): ${r}`),s.join(`
|
|
12
|
+
`)}function Lt(e,t,r){let n=e.map(c=>({file:X(r,c.file),line:c.line+1,column:c.character+1,length:c.length,message:c.message,severity:c.severity,ruleName:c.ruleName,ruleGroup:c.ruleGroup,sourceModule:c.sourceModule,targetModule:c.targetModule})),s=ue(e),o=s.errors+t.length,i=s.warnings,a=s.info,l={},u=0;for(let c of e)c.ruleGroup?l[c.ruleGroup]=(l[c.ruleGroup]??0)+1:u+=1;return u>0&&(l.ungrouped=u),{violations:n,cycles:t,summary:{violations:e.length,cycles:t.length,errors:o,warnings:i,info:a},groups:l}}function Vt(e){let{filePath:t,graph:r,config:n,root:s}=e,o=X(s,t),i=r.getDependents(t),a=r.getTransitiveDependents(t);if(console.log(`Impact analysis for ${o}:
|
|
13
|
+
`),i.size===0){console.log(` No dependents found.
|
|
14
|
+
`);return}console.log(` Direct dependents (${i.size} file${i.size===1?"":"s"}):`);for(let u of i){let c=$(u,n.modules,s)??"(unmatched)",f=X(s,u);console.log(` ${f} (${c})`)}let l=new Set;for(let u of a){let c=$(u,n.modules,s);c&&l.add(c)}a.size>i.size&&(console.log(`
|
|
15
|
+
Transitive dependents (${a.size} file${a.size===1?"":"s"} across ${l.size} module${l.size===1?"":"s"}):`),console.log(` ${[...l].join(", ")}`)),console.log(`
|
|
16
|
+
Affected modules: ${[...l].join(", ")||"none"}`),console.log("")}function Bt(e,t){console.log(`Module Health Report:
|
|
17
|
+
`);let r=["Module","Files","Ca","Ce","Instability","Depth"],n=[Math.max(r[0].length,...e.map(i=>i.moduleName.length)),Math.max(r[1].length,...e.map(i=>String(i.fileCount).length)),Math.max(r[2].length,...e.map(i=>String(i.afferentCoupling).length)),Math.max(r[3].length,...e.map(i=>String(i.efferentCoupling).length)),Math.max(r[4].length,11),Math.max(r[5].length,...e.map(i=>String(i.dependencyDepth).length))],s=(i,a)=>i.padEnd(a),o=(i,a)=>i.padStart(a);console.log(" "+r.map((i,a)=>s(i,n[a])).join(" ")),console.log(" "+n.map(i=>"\u2500".repeat(i)).join(" "));for(let i of e){let l=" "+[s(i.moduleName,n[0]),o(String(i.fileCount),n[1]),o(String(i.afferentCoupling),n[2]),o(String(i.efferentCoupling),n[3]),o(le("instability",i.instability),n[4]),o(String(i.dependencyDepth),n[5])].join(" "),u=t.filter(c=>c.moduleName===i.moduleName);if(u.length>0){let c=u.map(f=>{let p=le(f.metric,f.threshold);return`exceeds max${f.metric.charAt(0).toUpperCase()+f.metric.slice(1)} (${p})`});l+=" \u2190 "+c.join(", ")}console.log(l)}}function Br(e){let t=e.slice(2),r=t[0],n=process.cwd(),s="text",o,i=!1,a=t.indexOf("--root");a!==-1&&t[a+1]&&(n=U.resolve(t[a+1]));let l=t.indexOf("--format");if(l!==-1){let f=t[l+1];if(!f||f.startsWith("--"))return console.error('Missing value for "--format". Use "text" or "json".'),{ok:!1,exitCode:1};if(f!=="text"&&f!=="json")return console.error(`Invalid format "${f}". Use "text" or "json".`),{ok:!1,exitCode:1};s=f}let u=t.indexOf("--preset");if(u!==-1){let f=t[u+1];if(!f||f.startsWith("--"))return console.error('Missing value for "--preset".'),{ok:!1,exitCode:1};o=f}t.includes("--verbose")&&(i=!0);let c=r==="impact"&&t[1]&&!t[1].startsWith("--")?U.resolve(n,t[1]):void 0;return{ok:!0,command:r,root:n,target:c,format:s,preset:o,verbose:i}}var Fr=new Set(J.map(e=>`.${e}`));function _r(e,t){let r=I.readdirSync(e,{recursive:!0,withFileTypes:!0}),n=new Set;for(let s of r){if(!s.isFile())continue;let o=s.parentPath??s.path??e,i=U.join(o,s.name);i.includes("node_modules")||Se(i,e,t)||Fr.has(U.extname(s.name))&&n.add(T(i))}return n}function Ft(){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(" init Create a starter pickety.json"),console.log(""),console.log("Options:"),console.log(" --root <path> Workspace root (defaults to current directory)"),console.log(" --format <text|json> Output format for check (defaults to text)"),console.log(` --preset <name> Preset name for init (${K().join(", ")})`),console.log(" --verbose Log file read errors")}function Pe(e){let t=wt(e);if(!t.ok){console.error("Configuration errors:");for(let s of t.errors)console.error(` ${s.message}${s.path?` (at ${s.path})`:""}`);if(t.warnings&&t.warnings.length>0){console.warn("Configuration warnings:");for(let s of t.warnings)console.warn(` ${s.message}${s.path?` (at ${s.path})`:""}`)}return{ok:!1,exitCode:1}}if(!t.config)return console.log("No pickety.json found. Skipping check."),{ok:!1,exitCode:0};if(t.warnings&&t.warnings.length>0){console.warn("Configuration warnings:");for(let s of t.warnings)console.warn(` ${s.message}${s.path?` (at ${s.path})`:""}`)}let r=_r(e,t.config.ignore),n=vt(e);return{ok:!0,config:t.config,ctx:{root:e,knownFiles:r,aliases:n}}}function _t(e,t){let r=new te;for(let n of e.knownFiles)try{let s=I.readFileSync(n,"utf-8"),o=Ae(n,s,e);r.updateFile(n,o)}catch(s){let o=s instanceof Error?s.message:String(s);console.warn(`warning: Skipping unreadable file: ${n} (${o})`)}return r}function Dr(e,t,r){let n=Pe(e);if(!n.ok)return n.exitCode;let{config:s,ctx:o}=n,i=new te,a=[];for(let y of o.knownFiles)try{let S=I.readFileSync(y,"utf-8"),E=Mt({filePath:y,content:S,config:s,ctx:o});a.push(...E);let m=Ae(y,S,o);i.updateFile(y,m)}catch(S){let E=S instanceof Error?S.message:String(S);console.warn(`warning: Skipping unreadable file: ${y} (${E})`)}let l=At(a,s),u=i.getModuleLevelGraph(s.modules,e),c=at(u);if(t==="json"){let y=Lt(l,c,e);return console.log(JSON.stringify(y,null,2)),y.summary.errors>0?1:0}if(l.length===0&&c.length===0)return console.log("No boundary violations found."),0;for(let y of l)console.log(It(y,e));for(let y of c)console.log(`error: Circular dependency detected: ${y.join(" -> ")}`);let f=ue(l),p=f.errors+c.length,d=f.warnings,g=f.info,h=jt(l);return h&&console.log(h),console.log(""),console.log(`Found ${l.length} violation(s): ${p} error(s), ${d} warning(s), ${g} info(s)`),p>0?1:0}function Wr(e,t,r){if(!t)return console.error("Usage: pickety impact <file> [--root <path>]"),1;if(!I.existsSync(t))return console.error(`File not found: ${t}`),1;let n=Pe(e);if(!n.ok)return n.exitCode;let{config:s,ctx:o}=n,i=_t(o,r);return Vt({filePath:t,graph:i,config:s,root:e}),0}function Ur(e,t){let r=Pe(e);if(!r.ok)return r.exitCode;let{config:n,ctx:s}=r,o=_t(s,t),i=Pt(o,n.modules,s),a=n.health?Nt(i,n.health):[];return Bt(i,a),a.length>0?(console.log(`
|
|
18
|
+
${a.length} threshold violation(s) found.`),1):(console.log(`
|
|
19
|
+
All modules within configured thresholds.`),0)}function Gr(e,t){let r=Re(e);if(I.existsSync(r))return console.error(`${_} already exists at ${r}.`),1;if(t&&!ce(t))return console.error(`Unknown preset "${t}". Available presets: ${K().join(", ")}`),1;let n={$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},s=t?{$schema:n.$schema,preset:t}:n;return I.writeFileSync(r,JSON.stringify(s,null,2)),console.log(`Created ${_} at ${r}`),0}function zr(){let e=Br(process.argv);e.ok||process.exit(e.exitCode);let{command:t,root:r,target:n,format:s,preset:o,verbose:i}=e;(!t||t==="--help"||t==="-h")&&(Ft(),process.exit(0));let a=0;switch(t){case"check":a=Dr(r,s,i);break;case"impact":a=Wr(r,n,i);break;case"health":a=Ur(r,i);break;case"init":a=Gr(r,o);break;default:console.error(`Unknown command: "${t}"`),Ft(),a=1}process.exit(a)}zr();
|
package/out/extension.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";var qn=Object.create;var Pe=Object.defineProperty;var Jn=Object.getOwnPropertyDescriptor;var Xn=Object.getOwnPropertyNames;var Qn=Object.getPrototypeOf,Zn=Object.prototype.hasOwnProperty;var Yn=(e,t)=>{for(var s in t)Pe(e,s,{get:t[s],enumerable:!0})},Ot=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xn(t))!Zn.call(e,o)&&o!==s&&Pe(e,o,{get:()=>t[o],enumerable:!(n=Jn(t,o))||n.enumerable});return e};var R=(e,t,s)=>(s=e!=null?qn(Qn(e)):{},Ot(t||!e||!e.__esModule?Pe(s,"default",{value:e,enumerable:!0}):s,e)),Kn=e=>Ot(Pe({},"__esModule",{value:!0}),e);var Co={};Yn(Co,{activate:()=>Oo,deactivate:()=>Io});module.exports=Kn(Co);var _=R(require("vscode"));var B=R(require("vscode"));var re=R(require("vscode")),Le=R(require("fs"));var Oe=R(require("path"));var ot=(e,t,s)=>{let n=e instanceof RegExp?It(e,s):e,o=t instanceof RegExp?It(t,s):t,i=n!==null&&o!=null&&es(n,o,s);return i&&{start:i[0],end:i[1],pre:s.slice(0,i[0]),body:s.slice(i[0]+n.length,i[1]),post:s.slice(i[1]+o.length)}},It=(e,t)=>{let s=t.match(e);return s?s[0]:null},es=(e,t,s)=>{let n,o,i,r,c,a=s.indexOf(e),u=s.indexOf(t,a+1),p=a;if(a>=0&&u>0){if(e===t)return[a,u];for(n=[],i=s.length;p>=0&&!c;){if(p===a)n.push(p),a=s.indexOf(e,p+1);else if(n.length===1){let l=n.pop();l!==void 0&&(c=[l,u])}else o=n.pop(),o!==void 0&&o<i&&(i=o,r=u),u=s.indexOf(t,p+1);p=a<u&&a>=0?a:u}n.length&&r!==void 0&&(c=[i,r])}return c};var Ct="\0SLASH"+Math.random()+"\0",Lt="\0OPEN"+Math.random()+"\0",rt="\0CLOSE"+Math.random()+"\0",Nt="\0COMMA"+Math.random()+"\0",Dt="\0PERIOD"+Math.random()+"\0",ts=new RegExp(Ct,"g"),ns=new RegExp(Lt,"g"),ss=new RegExp(rt,"g"),os=new RegExp(Nt,"g"),is=new RegExp(Dt,"g"),rs=/\\\\/g,as=/\\{/g,cs=/\\}/g,ls=/\\,/g,us=/\\./g,ps=1e5;function it(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function fs(e){return e.replace(rs,Ct).replace(as,Lt).replace(cs,rt).replace(ls,Nt).replace(us,Dt)}function ds(e){return e.replace(ts,"\\").replace(ns,"{").replace(ss,"}").replace(os,",").replace(is,".")}function jt(e){if(!e)return[""];let t=[],s=ot("{","}",e);if(!s)return e.split(",");let{pre:n,body:o,post:i}=s,r=n.split(",");r[r.length-1]+="{"+o+"}";let c=jt(i);return i.length&&(r[r.length-1]+=c.shift(),r.push.apply(r,c)),t.push.apply(t,r),t}function Vt(e,t={}){if(!e)return[];let{max:s=ps}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),ve(fs(e),s,!0).map(ds)}function hs(e){return"{"+e+"}"}function gs(e){return/^-?0\d/.test(e)}function ms(e,t){return e<=t}function ys(e,t){return e>=t}function ve(e,t,s){let n=[],o=ot("{","}",e);if(!o)return[e];let i=o.pre,r=o.post.length?ve(o.post,t,!1):[""];if(/\$$/.test(o.pre))for(let c=0;c<r.length&&c<t;c++){let a=i+"{"+o.body+"}"+r[c];n.push(a)}else{let c=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(o.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(o.body),u=c||a,p=o.body.indexOf(",")>=0;if(!u&&!p)return o.post.match(/,(?!,).*\}/)?(e=o.pre+"{"+o.body+rt+o.post,ve(e,t,!0)):[e];let l;if(u)l=o.body.split(/\.\./);else if(l=jt(o.body),l.length===1&&l[0]!==void 0&&(l=ve(l[0],t,!1).map(hs),l.length===1))return r.map(d=>o.pre+l[0]+d);let f;if(u&&l[0]!==void 0&&l[1]!==void 0){let d=it(l[0]),h=it(l[1]),g=Math.max(l[0].length,l[1].length),b=l.length===3&&l[2]!==void 0?Math.abs(it(l[2])):1,x=ms;h<d&&(b*=-1,x=ys);let m=l.some(gs);f=[];for(let w=d;x(w,h);w+=b){let k;if(a)k=String.fromCharCode(w),k==="\\"&&(k="");else if(k=String(w),m){let v=g-k.length;if(v>0){let y=new Array(v+1).join("0");w<0?k="-"+y+k.slice(1):k=y+k}}f.push(k)}}else{f=[];for(let d=0;d<l.length;d++)f.push.apply(f,ve(l[d],t,!1))}for(let d=0;d<f.length;d++)for(let h=0;h<r.length&&n.length<t;h++){let g=i+f[d]+r[h];(!s||u||g)&&n.push(g)}}return n}var ke=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var bs={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},we=e=>e.replace(/[[\]\\-]/g,"\\$&"),vs=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Ft=e=>e.join(""),Wt=(e,t)=>{let s=t;if(e.charAt(s)!=="[")throw new Error("not in a brace expression");let n=[],o=[],i=s+1,r=!1,c=!1,a=!1,u=!1,p=s,l="";e:for(;i<e.length;){let g=e.charAt(i);if((g==="!"||g==="^")&&i===s+1){u=!0,i++;continue}if(g==="]"&&r&&!a){p=i+1;break}if(r=!0,g==="\\"&&!a){a=!0,i++;continue}if(g==="["&&!a){for(let[b,[x,T,m]]of Object.entries(bs))if(e.startsWith(b,i)){if(l)return["$.",!1,e.length-s,!0];i+=b.length,m?o.push(x):n.push(x),c=c||T;continue e}}if(a=!1,l){g>l?n.push(we(l)+"-"+we(g)):g===l&&n.push(we(g)),l="",i++;continue}if(e.startsWith("-]",i+1)){n.push(we(g+"-")),i+=2;continue}if(e.startsWith("-",i+1)){l=g,i+=2;continue}n.push(we(g)),i++}if(p<i)return["",!1,0,!1];if(!n.length&&!o.length)return["$.",!1,e.length-s,!0];if(o.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let g=n[0].length===2?n[0].slice(-1):n[0];return[vs(g),!1,p-s,!1]}let f="["+(u?"^":"")+Ft(n)+"]",d="["+(u?"":"^")+Ft(o)+"]";return[n.length&&o.length?"("+f+"|"+d+")":n.length?f:d,c,p-s,!0]};var q=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!0}={})=>s?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var ks=new Set(["!","?","+","*","@"]),Bt=e=>ks.has(e),ws="(?!(?:^|/)\\.\\.?(?:$|/))",$e="(?!\\.)",xs=new Set(["[","."]),Ss=new Set(["..","."]),Rs=new Set("().*{}+?[]^$\\!"),Es=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),at="[^/]",_t=at+"*?",Ht=at+"+?",ne=class e{type;#n;#s;#i=!1;#e=[];#t;#r;#c;#a=!1;#o;#l;#p=!1;constructor(t,s,n={}){this.type=t,t&&(this.#s=!0),this.#t=s,this.#n=this.#t?this.#t.#n:this,this.#o=this.#n===this?n:this.#n.#o,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 o=s.#r+1;!n.type&&o<n.#e.length;o++)for(let i of t.#e){if(typeof i=="string")throw new Error("string part in extglob AST??");i.copyIn(n.#e[o])}s=n,n=s.#t}}return this}push(...t){for(let s of t)if(s!==""){if(typeof s!="string"&&!(s instanceof e&&s.#t===this))throw new Error("invalid part: "+s);this.#e.push(s)}}toJSON(){let t=this.type===null?this.#e.slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...this.#e.map(s=>s.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#n||this.#n.#a&&this.#t?.type==="!")&&t.push({}),t}isStart(){if(this.#n===this)return!0;if(!this.#t?.isStart())return!1;if(this.#r===0)return!0;let t=this.#t;for(let s=0;s<this.#r;s++){let n=t.#e[s];if(!(n instanceof e&&n.type==="!"))return!1}return!0}isEnd(){if(this.#n===this||this.#t?.type==="!")return!0;if(!this.#t?.isEnd())return!1;if(!this.type)return this.#t?.isEnd();let t=this.#t?this.#t.#e.length:0;return this.#r===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let s=new e(this.type,t);for(let n of this.#e)s.copyIn(n);return s}static#u(t,s,n,o){let i=!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(i||g==="\\"){i=!i,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(!o.noext&&Bt(g)&&t.charAt(d)==="("){s.push(h),h="";let b=new e(g,s);d=e.#u(t,b,d,o),s.push(b);continue}h+=g}return s.push(h),d}let u=n+1,p=new e(null,s),l=[],f="";for(;u<t.length;){let d=t.charAt(u++);if(i||d==="\\"){i=!i,f+=d;continue}if(r){u===c+1?(d==="^"||d==="!")&&(a=!0):d==="]"&&!(u===c+2&&a)&&(r=!1),f+=d;continue}else if(d==="["){r=!0,c=u,a=!1,f+=d;continue}if(Bt(d)&&t.charAt(u)==="("){p.push(f),f="";let h=new e(d,p);p.push(h),u=e.#u(t,h,u,o);continue}if(d==="|"){p.push(f),f="",l.push(p),p=new e(null,s);continue}if(d===")")return f===""&&s.#e.length===0&&(s.#p=!0),p.push(f),f="",s.push(...l,p),u;f+=d}return s.type=null,s.#s=void 0,s.#e=[t.substring(n-1)],u}static fromGlob(t,s={}){let n=new e(null,void 0,s);return e.#u(t,n,0,s),n}toMMPattern(){if(this!==this.#n)return this.#n.toMMPattern();let t=this.toString(),[s,n,o,i]=this.toRegExpSource();if(!(o||this.#s||this.#o.nocase&&!this.#o.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let c=(this.#o.nocase?"i":"")+(i?"u":"");return Object.assign(new RegExp(`^${s}$`,c),{_src:s,_glob:t})}get options(){return this.#o}toRegExpSource(t){let s=t??!!this.#o.dot;if(this.#n===this&&this.#d(),!this.type){let a=this.isStart()&&this.isEnd()&&!this.#e.some(d=>typeof d!="string"),u=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.#i=this.#i||x,h}).join(""),p="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&Ss.has(this.#e[0]))){let h=xs,g=s&&h.has(u.charAt(0))||u.startsWith("\\.")&&h.has(u.charAt(2))||u.startsWith("\\.\\.")&&h.has(u.charAt(4)),b=!s&&!t&&h.has(u.charAt(0));p=g?ws:b?$e:""}let l="";return this.isEnd()&&this.#n.#a&&this.#t?.type==="!"&&(l="(?:$|\\/)"),[p+u+l,q(u),this.#s=!!this.#s,this.#i]}let n=this.type==="*"||this.type==="+",o=this.type==="!"?"(?:(?!(?:":"(?:",i=this.#f(s);if(this.isStart()&&this.isEnd()&&!i&&this.type!=="!"){let a=this.toString();return this.#e=[a],this.type=null,this.#s=void 0,[a,q(this.toString()),!1,!1]}let r=!n||t||s||!$e?"":this.#f(!0);r===i&&(r=""),r&&(i=`(?:${i})(?:${r})*?`);let c="";if(this.type==="!"&&this.#p)c=(this.isStart()&&!s?$e:"")+Ht;else{let a=this.type==="!"?"))"+(this.isStart()&&!s&&!t?$e:"")+_t+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&r?")":this.type==="*"&&r?")?":`)${this.type}`;c=o+i+a}return[c,q(i),this.#s=!!this.#s,this.#i]}#f(t){return this.#e.map(s=>{if(typeof s=="string")throw new Error("string type in extglob ast??");let[n,o,i,r]=s.toRegExpSource(t);return this.#i=this.#i||r,n}).filter(s=>!(this.isStart()&&this.isEnd())||!!s).join("|")}static#h(t,s,n=!1){let o=!1,i="",r=!1,c=!1;for(let a=0;a<t.length;a++){let u=t.charAt(a);if(o){o=!1,i+=(Rs.has(u)?"\\":"")+u;continue}if(u==="*"){if(c)continue;c=!0,i+=n&&/^[*]+$/.test(t)?Ht:_t,s=!0;continue}else c=!1;if(u==="\\"){a===t.length-1?i+="\\\\":o=!0;continue}if(u==="["){let[p,l,f,d]=Wt(t,a);if(f){i+=p,r=r||l,a+=f-1,s=s||d;continue}}if(u==="?"){i+=at,s=!0;continue}i+=Es(u)}return[i,q(t),!!s,r]}};var ct=(e,{windowsPathsNoEscape:t=!1,magicalBraces:s=!1}={})=>s?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var A=(e,t,s={})=>(ke(t),!s.nocomment&&t.charAt(0)==="#"?!1:new se(t,s).match(e)),Ts=/^\*+([^+@!?\*\[\(]*)$/,As=e=>t=>!t.startsWith(".")&&t.endsWith(e),Ms=e=>t=>t.endsWith(e),Ps=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),$s=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Os=/^\*+\.\*+$/,Is=e=>!e.startsWith(".")&&e.includes("."),Cs=e=>e!=="."&&e!==".."&&e.includes("."),Ls=/^\.\*+$/,Ns=e=>e!=="."&&e!==".."&&e.startsWith("."),Ds=/^\*+$/,js=e=>e.length!==0&&!e.startsWith("."),Vs=e=>e.length!==0&&e!=="."&&e!=="..",Fs=/^\?+([^+@!?\*\[\(]*)?$/,Ws=([e,t=""])=>{let s=zt([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},Bs=([e,t=""])=>{let s=qt([e]);return t?(t=t.toLowerCase(),n=>s(n)&&n.toLowerCase().endsWith(t)):s},_s=([e,t=""])=>{let s=qt([e]);return t?n=>s(n)&&n.endsWith(t):s},Hs=([e,t=""])=>{let s=zt([e]);return t?n=>s(n)&&n.endsWith(t):s},zt=([e])=>{let t=e.length;return s=>s.length===t&&!s.startsWith(".")},qt=([e])=>{let t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},Jt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Gt={win32:{sep:"\\"},posix:{sep:"/"}},Gs=Jt==="win32"?Gt.win32.sep:Gt.posix.sep;A.sep=Gs;var L=Symbol("globstar **");A.GLOBSTAR=L;var Us="[^/]",zs=Us+"*?",qs="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Js="(?:(?!(?:\\/|^)\\.).)*?",Xs=(e,t={})=>s=>A(s,e,t);A.filter=Xs;var C=(e,t={})=>Object.assign({},e,t),Qs=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return A;let t=A;return Object.assign((n,o,i={})=>t(n,o,C(e,i)),{Minimatch:class extends t.Minimatch{constructor(o,i={}){super(o,C(e,i))}static defaults(o){return t.defaults(C(e,o)).Minimatch}},AST:class extends t.AST{constructor(o,i,r={}){super(o,i,C(e,r))}static fromGlob(o,i={}){return t.AST.fromGlob(o,C(e,i))}},unescape:(n,o={})=>t.unescape(n,C(e,o)),escape:(n,o={})=>t.escape(n,C(e,o)),filter:(n,o={})=>t.filter(n,C(e,o)),defaults:n=>t.defaults(C(e,n)),makeRe:(n,o={})=>t.makeRe(n,C(e,o)),braceExpand:(n,o={})=>t.braceExpand(n,C(e,o)),match:(n,o,i={})=>t.match(n,o,C(e,i)),sep:t.sep,GLOBSTAR:L})};A.defaults=Qs;var Xt=(e,t={})=>(ke(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Vt(e,{max:t.braceExpandMax}));A.braceExpand=Xt;var Zs=(e,t={})=>new se(e,t).makeRe();A.makeRe=Zs;var Ys=(e,t,s={})=>{let n=new se(t,s);return e=e.filter(o=>n.match(o)),n.options.nonull&&!e.length&&e.push(t),e};A.match=Ys;var Ut=/[?*]|[+@!]\(.*?\)|\[|\]/,Ks=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),se=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,s={}){ke(t),s=s||{},this.options=s,this.pattern=t,this.platform=s.platform||Jt,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!s.windowsPathsNoEscape||s[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!s.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!s.nonegate,this.comment=!1,this.empty=!1,this.partial=!!s.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=s.windowsNoMagicRoot!==void 0?s.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let s of t)if(typeof s!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,s=this.options;if(!s.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],s.debug&&(this.debug=(...i)=>console.error(...i)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(i=>this.slashSplit(i));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let o=this.globParts.map((i,r,c)=>{if(this.isWindows&&this.windowsNoMagicRoot){let a=i[0]===""&&i[1]===""&&(i[2]==="?"||!Ut.test(i[2]))&&!Ut.test(i[3]),u=/^[a-z]:/i.test(i[0]);if(a)return[...i.slice(0,4),...i.slice(4).map(p=>this.parse(p))];if(u)return[i[0],...i.slice(1).map(p=>this.parse(p))]}return i.map(a=>this.parse(a))});if(this.debug(this.pattern,o),this.set=o.filter(i=>i.indexOf(!1)===-1),this.isWindows)for(let i=0;i<this.set.length;i++){let r=this.set[i];r[0]===""&&r[1]===""&&this.globParts[i][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 o=0;o<t[n].length;o++)t[n][o]==="**"&&(t[n][o]="*");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 o=n;for(;s[o+1]==="**";)o++;o!==n&&s.splice(n,o-n)}return s})}levelOneOptimize(t){return t.map(s=>(s=s.reduce((n,o)=>{let i=n[n.length-1];return o==="**"&&i==="**"?n:o===".."&&i&&i!==".."&&i!=="."&&i!=="**"?(n.pop(),n):(n.push(o),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 o=1;o<t.length-1;o++){let i=t[o];o===1&&i===""&&t[0]===""||(i==="."||i==="")&&(s=!0,t.splice(o,1),o--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(s=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let o=t[n-1];o&&o!=="."&&o!==".."&&o!=="**"&&(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 o=-1;for(;(o=n.indexOf("**",o+1))!==-1;){let r=o;for(;n[r+1]==="**";)r++;r>o&&n.splice(o+1,r-o);let c=n[o+1],a=n[o+2],u=n[o+3];if(c!==".."||!a||a==="."||a===".."||!u||u==="."||u==="..")continue;s=!0,n.splice(o,1);let p=n.slice(0);p[o]="**",t.push(p),o--}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 i=0;for(;(i=n.indexOf("..",i+1))!==-1;){let r=n[i-1];if(r&&r!=="."&&r!==".."&&r!=="**"){s=!0;let a=i===1&&n[i+1]==="**"?["."]:[];n.splice(i-1,2,...a),n.length===0&&n.push(""),i-=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 o=this.partsMatch(t[s],t[n],!this.preserveMultipleSlashes);if(o){t[s]=[],t[n]=o;break}}return t.filter(s=>s.length)}partsMatch(t,s,n=!1){let o=0,i=0,r=[],c="";for(;o<t.length&&i<s.length;)if(t[o]===s[i])r.push(c==="b"?s[i]:t[o]),o++,i++;else if(n&&t[o]==="**"&&s[i]===t[o+1])r.push(t[o]),o++;else if(n&&s[i]==="**"&&t[o]===s[i+1])r.push(s[i]),i++;else if(t[o]==="*"&&s[i]&&(this.options.dot||!s[i].startsWith("."))&&s[i]!=="**"){if(c==="b")return!1;c="a",r.push(t[o]),o++,i++}else if(s[i]==="*"&&t[o]&&(this.options.dot||!t[o].startsWith("."))&&t[o]!=="**"){if(c==="a")return!1;c="b",r.push(s[i]),o++,i++}else return!1;return t.length===s.length&&r}parseNegate(){if(this.nonegate)return;let t=this.pattern,s=!1,n=0;for(let o=0;o<t.length&&t.charAt(o)==="!";o++)s=!s,n++;n&&(this.pattern=t.slice(n)),this.negate=s}matchOne(t,s,n=!1){let o=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]),T=!x&&s[0]===""&&s[1]===""&&s[2]==="?"&&typeof s[3]=="string"&&/^[a-z]:$/i.test(s[3]),m=b?3:g?0:void 0,w=T?3:x?0:void 0;if(typeof m=="number"&&typeof w=="number"){let[k,v]=[t[m],s[w]];k.toLowerCase()===v.toLowerCase()&&(s[w]=k,w>m?s=s.slice(w):m>w&&(t=t.slice(m)))}}let{optimizationLevel:i=1}=this.options;i>=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,u=s.length;r<a&&c<u;r++,c++){this.debug("matchOne loop");var p=s[c],l=t[r];if(this.debug(s,p,l),p===!1)return!1;if(p===L){this.debug("GLOBSTAR",[s,p,l]);var f=r,d=c+1;if(d===u){for(this.debug("** at the end");r<a;r++)if(t[r]==="."||t[r]===".."||!o.dot&&t[r].charAt(0)===".")return!1;return!0}for(;f<a;){var h=t[f];if(this.debug(`
|
|
2
|
-
globstar while`,t,f,
|
|
3
|
-
>>> no match, partial?`,t,f,
|
|
4
|
-
`),n=[],
|
|
5
|
-
`)}var
|
|
1
|
+
"use strict";var Zn=Object.create;var Oe=Object.defineProperty;var Kn=Object.getOwnPropertyDescriptor;var ei=Object.getOwnPropertyNames;var ti=Object.getPrototypeOf,ni=Object.prototype.hasOwnProperty;var ii=(e,t)=>{for(var i in t)Oe(e,i,{get:t[i],enumerable:!0})},Dt=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ei(t))!ni.call(e,s)&&s!==i&&Oe(e,s,{get:()=>t[s],enumerable:!(n=Kn(t,s))||n.enumerable});return e};var S=(e,t,i)=>(i=e!=null?Zn(ti(e)):{},Dt(t||!e||!e.__esModule?Oe(i,"default",{value:e,enumerable:!0}):i,e)),si=e=>Dt(Oe({},"__esModule",{value:!0}),e);var Qs={};ii(Qs,{activate:()=>Js,deactivate:()=>Ys});module.exports=si(Qs);var G=S(require("vscode"));var _=S(require("vscode"));var le=S(require("vscode")),Le=S(require("fs"));var Z=S(require("path"));var at=(e,t,i)=>{let n=e instanceof RegExp?Lt(e,i):e,s=t instanceof RegExp?Lt(t,i):t,o=n!==null&&s!=null&&oi(n,s,i);return o&&{start:o[0],end:o[1],pre:i.slice(0,o[0]),body:i.slice(o[0]+n.length,o[1]),post:i.slice(o[1]+s.length)}},Lt=(e,t)=>{let i=t.match(e);return i?i[0]:null},oi=(e,t,i)=>{let n,s,o,r,a,c=i.indexOf(e),l=i.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(n=[],o=i.length;u>=0&&!a;){if(u===c)n.push(u),c=i.indexOf(e,u+1);else if(n.length===1){let p=n.pop();p!==void 0&&(a=[p,l])}else s=n.pop(),s!==void 0&&s<o&&(o=s,r=l),l=i.indexOf(t,u+1);u=c<l&&c>=0?c:l}n.length&&r!==void 0&&(a=[o,r])}return a};var Nt="\0SLASH"+Math.random()+"\0",jt="\0OPEN"+Math.random()+"\0",lt="\0CLOSE"+Math.random()+"\0",Vt="\0COMMA"+Math.random()+"\0",Ft="\0PERIOD"+Math.random()+"\0",ri=new RegExp(Nt,"g"),ai=new RegExp(jt,"g"),ci=new RegExp(lt,"g"),li=new RegExp(Vt,"g"),ui=new RegExp(Ft,"g"),pi=/\\\\/g,fi=/\\{/g,di=/\\}/g,gi=/\\,/g,hi=/\\./g,mi=1e5;function ct(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function yi(e){return e.replace(pi,Nt).replace(fi,jt).replace(di,lt).replace(gi,Vt).replace(hi,Ft)}function vi(e){return e.replace(ri,"\\").replace(ai,"{").replace(ci,"}").replace(li,",").replace(ui,".")}function Wt(e){if(!e)return[""];let t=[],i=at("{","}",e);if(!i)return e.split(",");let{pre:n,body:s,post:o}=i,r=n.split(",");r[r.length-1]+="{"+s+"}";let a=Wt(o);return o.length&&(r[r.length-1]+=a.shift(),r.push.apply(r,a)),t.push.apply(t,r),t}function Bt(e,t={}){if(!e)return[];let{max:i=mi}=t;return e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),ke(yi(e),i,!0).map(vi)}function bi(e){return"{"+e+"}"}function ki(e){return/^-?0\d/.test(e)}function wi(e,t){return e<=t}function xi(e,t){return e>=t}function ke(e,t,i){let n=[],s=at("{","}",e);if(!s)return[e];let o=s.pre,r=s.post.length?ke(s.post,t,!1):[""];if(/\$$/.test(s.pre))for(let a=0;a<r.length&&a<t;a++){let c=o+"{"+s.body+"}"+r[a];n.push(c)}else{let a=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(s.body),c=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(s.body),l=a||c,u=s.body.indexOf(",")>=0;if(!l&&!u)return s.post.match(/,(?!,).*\}/)?(e=s.pre+"{"+s.body+lt+s.post,ke(e,t,!0)):[e];let p;if(l)p=s.body.split(/\.\./);else if(p=Wt(s.body),p.length===1&&p[0]!==void 0&&(p=ke(p[0],t,!1).map(bi),p.length===1))return r.map(d=>s.pre+p[0]+d);let f;if(l&&p[0]!==void 0&&p[1]!==void 0){let d=ct(p[0]),g=ct(p[1]),h=Math.max(p[0].length,p[1].length),k=p.length===3&&p[2]!==void 0?Math.abs(ct(p[2])):1,P=wi;g<d&&(k*=-1,P=xi);let y=p.some(ki);f=[];for(let w=d;P(w,g);w+=k){let v;if(c)v=String.fromCharCode(w),v==="\\"&&(v="");else if(v=String(w),y){let b=h-v.length;if(b>0){let m=new Array(b+1).join("0");w<0?v="-"+m+v.slice(1):v=m+v}}f.push(v)}}else{f=[];for(let d=0;d<p.length;d++)f.push.apply(f,ke(p[d],t,!1))}for(let d=0;d<f.length;d++)for(let g=0;g<r.length&&n.length<t;g++){let h=o+f[d]+r[g];(!i||l||h)&&n.push(h)}}return n}var we=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Si={"[: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]},xe=e=>e.replace(/[[\]\\-]/g,"\\$&"),Ri=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),_t=e=>e.join(""),Gt=(e,t)=>{let i=t;if(e.charAt(i)!=="[")throw new Error("not in a brace expression");let n=[],s=[],o=i+1,r=!1,a=!1,c=!1,l=!1,u=i,p="";e:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===i+1){l=!0,o++;continue}if(h==="]"&&r&&!c){u=o+1;break}if(r=!0,h==="\\"&&!c){c=!0,o++;continue}if(h==="["&&!c){for(let[k,[P,O,y]]of Object.entries(Si))if(e.startsWith(k,o)){if(p)return["$.",!1,e.length-i,!0];o+=k.length,y?s.push(P):n.push(P),a=a||O;continue e}}if(c=!1,p){h>p?n.push(xe(p)+"-"+xe(h)):h===p&&n.push(xe(h)),p="",o++;continue}if(e.startsWith("-]",o+1)){n.push(xe(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){p=h,o+=2;continue}n.push(xe(h)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!s.length)return["$.",!1,e.length-i,!0];if(s.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!l){let h=n[0].length===2?n[0].slice(-1):n[0];return[Ri(h),!1,u-i,!1]}let f="["+(l?"^":"")+_t(n)+"]",d="["+(l?"":"^")+_t(s)+"]";return[n.length&&s.length?"("+f+"|"+d+")":n.length?f:d,a,u-i,!0]};var X=(e,{windowsPathsNoEscape:t=!1,magicalBraces:i=!0}={})=>i?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 Ei=new Set(["!","?","+","*","@"]),Ht=e=>Ei.has(e),Pi="(?!(?:^|/)\\.\\.?(?:$|/))",$e="(?!\\.)",Ti=new Set(["[","."]),Mi=new Set(["..","."]),Ai=new Set("().*{}+?[]^$\\!"),Ci=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ut="[^/]",zt=ut+"*?",Ut=ut+"+?",oe=class e{type;#n;#i;#o=!1;#e=[];#t;#r;#c;#a=!1;#s;#l;#p=!1;constructor(t,i,n={}){this.type=t,t&&(this.#i=!0),this.#t=i,this.#n=this.#t?this.#t.#n:this,this.#s=this.#n===this?n:this.#n.#s,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.#i!==void 0)return this.#i;for(let t of this.#e)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#i=!0;return this.#i}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 i=t,n=i.#t;for(;n;){for(let s=i.#r+1;!n.type&&s<n.#e.length;s++)for(let o of t.#e){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#e[s])}i=n,n=i.#t}}return this}push(...t){for(let i of t)if(i!==""){if(typeof i!="string"&&!(i instanceof e&&i.#t===this))throw new Error("invalid part: "+i);this.#e.push(i)}}toJSON(){let t=this.type===null?this.#e.slice().map(i=>typeof i=="string"?i:i.toJSON()):[this.type,...this.#e.map(i=>i.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 i=0;i<this.#r;i++){let n=t.#e[i];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 i=new e(this.type,t);for(let n of this.#e)i.copyIn(n);return i}static#u(t,i,n,s){let o=!1,r=!1,a=-1,c=!1;if(i.type===null){let d=n,g="";for(;d<t.length;){let h=t.charAt(d++);if(o||h==="\\"){o=!o,g+=h;continue}if(r){d===a+1?(h==="^"||h==="!")&&(c=!0):h==="]"&&!(d===a+2&&c)&&(r=!1),g+=h;continue}else if(h==="["){r=!0,a=d,c=!1,g+=h;continue}if(!s.noext&&Ht(h)&&t.charAt(d)==="("){i.push(g),g="";let k=new e(h,i);d=e.#u(t,k,d,s),i.push(k);continue}g+=h}return i.push(g),d}let l=n+1,u=new e(null,i),p=[],f="";for(;l<t.length;){let d=t.charAt(l++);if(o||d==="\\"){o=!o,f+=d;continue}if(r){l===a+1?(d==="^"||d==="!")&&(c=!0):d==="]"&&!(l===a+2&&c)&&(r=!1),f+=d;continue}else if(d==="["){r=!0,a=l,c=!1,f+=d;continue}if(Ht(d)&&t.charAt(l)==="("){u.push(f),f="";let g=new e(d,u);u.push(g),l=e.#u(t,g,l,s);continue}if(d==="|"){u.push(f),f="",p.push(u),u=new e(null,i);continue}if(d===")")return f===""&&i.#e.length===0&&(i.#p=!0),u.push(f),f="",i.push(...p,u),l;f+=d}return i.type=null,i.#i=void 0,i.#e=[t.substring(n-1)],l}static fromGlob(t,i={}){let n=new e(null,void 0,i);return e.#u(t,n,0,i),n}toMMPattern(){if(this!==this.#n)return this.#n.toMMPattern();let t=this.toString(),[i,n,s,o]=this.toRegExpSource();if(!(s||this.#i||this.#s.nocase&&!this.#s.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#s.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${i}$`,a),{_src:i,_glob:t})}get options(){return this.#s}toRegExpSource(t){let i=t??!!this.#s.dot;if(this.#n===this&&this.#d(),!this.type){let c=this.isStart()&&this.isEnd()&&!this.#e.some(d=>typeof d!="string"),l=this.#e.map(d=>{let[g,h,k,P]=typeof d=="string"?e.#g(d,this.#i,c):d.toRegExpSource(t);return this.#i=this.#i||k,this.#o=this.#o||P,g}).join(""),u="";if(this.isStart()&&typeof this.#e[0]=="string"&&!(this.#e.length===1&&Mi.has(this.#e[0]))){let g=Ti,h=i&&g.has(l.charAt(0))||l.startsWith("\\.")&&g.has(l.charAt(2))||l.startsWith("\\.\\.")&&g.has(l.charAt(4)),k=!i&&!t&&g.has(l.charAt(0));u=h?Pi:k?$e:""}let p="";return this.isEnd()&&this.#n.#a&&this.#t?.type==="!"&&(p="(?:$|\\/)"),[u+l+p,X(l),this.#i=!!this.#i,this.#o]}let n=this.type==="*"||this.type==="+",s=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#f(i);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let c=this.toString();return this.#e=[c],this.type=null,this.#i=void 0,[c,X(this.toString()),!1,!1]}let r=!n||t||i||!$e?"":this.#f(!0);r===o&&(r=""),r&&(o=`(?:${o})(?:${r})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!i?$e:"")+Ut;else{let c=this.type==="!"?"))"+(this.isStart()&&!i&&!t?$e:"")+zt+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&r?")":this.type==="*"&&r?")?":`)${this.type}`;a=s+o+c}return[a,X(o),this.#i=!!this.#i,this.#o]}#f(t){return this.#e.map(i=>{if(typeof i=="string")throw new Error("string type in extglob ast??");let[n,s,o,r]=i.toRegExpSource(t);return this.#o=this.#o||r,n}).filter(i=>!(this.isStart()&&this.isEnd())||!!i).join("|")}static#g(t,i,n=!1){let s=!1,o="",r=!1,a=!1;for(let c=0;c<t.length;c++){let l=t.charAt(c);if(s){s=!1,o+=(Ai.has(l)?"\\":"")+l;continue}if(l==="*"){if(a)continue;a=!0,o+=n&&/^[*]+$/.test(t)?Ut:zt,i=!0;continue}else a=!1;if(l==="\\"){c===t.length-1?o+="\\\\":s=!0;continue}if(l==="["){let[u,p,f,d]=Gt(t,c);if(f){o+=u,r=r||p,c+=f-1,i=i||d;continue}}if(l==="?"){o+=ut,i=!0;continue}o+=Ci(l)}return[o,X(t),!!i,r]}};var pt=(e,{windowsPathsNoEscape:t=!1,magicalBraces:i=!1}={})=>i?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var E=(e,t,i={})=>(we(t),!i.nocomment&&t.charAt(0)==="#"?!1:new re(t,i).match(e)),Oi=/^\*+([^+@!?\*\[\(]*)$/,$i=e=>t=>!t.startsWith(".")&&t.endsWith(e),Ii=e=>t=>t.endsWith(e),Di=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Li=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Ni=/^\*+\.\*+$/,ji=e=>!e.startsWith(".")&&e.includes("."),Vi=e=>e!=="."&&e!==".."&&e.includes("."),Fi=/^\.\*+$/,Wi=e=>e!=="."&&e!==".."&&e.startsWith("."),Bi=/^\*+$/,_i=e=>e.length!==0&&!e.startsWith("."),Gi=e=>e.length!==0&&e!=="."&&e!=="..",Hi=/^\?+([^+@!?\*\[\(]*)?$/,zi=([e,t=""])=>{let i=Jt([e]);return t?(t=t.toLowerCase(),n=>i(n)&&n.toLowerCase().endsWith(t)):i},Ui=([e,t=""])=>{let i=Yt([e]);return t?(t=t.toLowerCase(),n=>i(n)&&n.toLowerCase().endsWith(t)):i},qi=([e,t=""])=>{let i=Yt([e]);return t?n=>i(n)&&n.endsWith(t):i},Xi=([e,t=""])=>{let i=Jt([e]);return t?n=>i(n)&&n.endsWith(t):i},Jt=([e])=>{let t=e.length;return i=>i.length===t&&!i.startsWith(".")},Yt=([e])=>{let t=e.length;return i=>i.length===t&&i!=="."&&i!==".."},Qt=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",qt={win32:{sep:"\\"},posix:{sep:"/"}},Ji=Qt==="win32"?qt.win32.sep:qt.posix.sep;E.sep=Ji;var L=Symbol("globstar **");E.GLOBSTAR=L;var Yi="[^/]",Qi=Yi+"*?",Zi="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Ki="(?:(?!(?:\\/|^)\\.).)*?",es=(e,t={})=>i=>E(i,e,t);E.filter=es;var D=(e,t={})=>Object.assign({},e,t),ts=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return E;let t=E;return Object.assign((n,s,o={})=>t(n,s,D(e,o)),{Minimatch:class extends t.Minimatch{constructor(s,o={}){super(s,D(e,o))}static defaults(s){return t.defaults(D(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,o,r={}){super(s,o,D(e,r))}static fromGlob(s,o={}){return t.AST.fromGlob(s,D(e,o))}},unescape:(n,s={})=>t.unescape(n,D(e,s)),escape:(n,s={})=>t.escape(n,D(e,s)),filter:(n,s={})=>t.filter(n,D(e,s)),defaults:n=>t.defaults(D(e,n)),makeRe:(n,s={})=>t.makeRe(n,D(e,s)),braceExpand:(n,s={})=>t.braceExpand(n,D(e,s)),match:(n,s,o={})=>t.match(n,s,D(e,o)),sep:t.sep,GLOBSTAR:L})};E.defaults=ts;var Zt=(e,t={})=>(we(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Bt(e,{max:t.braceExpandMax}));E.braceExpand=Zt;var ns=(e,t={})=>new re(e,t).makeRe();E.makeRe=ns;var is=(e,t,i={})=>{let n=new re(t,i);return e=e.filter(s=>n.match(s)),n.options.nonull&&!e.length&&e.push(t),e};E.match=is;var Xt=/[?*]|[+@!]\(.*?\)|\[|\]/,ss=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),re=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,i={}){we(t),i=i||{},this.options=i,this.pattern=t,this.platform=i.platform||Qt,this.isWindows=this.platform==="win32";let n="allowWindowsEscape";this.windowsPathsNoEscape=!!i.windowsPathsNoEscape||i[n]===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!i.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!i.nonegate,this.comment=!1,this.empty=!1,this.partial=!!i.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=i.windowsNoMagicRoot!==void 0?i.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 i of t)if(typeof i!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,i=this.options;if(!i.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],i.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 s=this.globParts.map((o,r,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=o[0]===""&&o[1]===""&&(o[2]==="?"||!Xt.test(o[2]))&&!Xt.test(o[3]),l=/^[a-z]:/i.test(o[0]);if(c)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(l)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(c=>this.parse(c))});if(this.debug(this.pattern,s),this.set=s.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 s=0;s<t[n].length;s++)t[n][s]==="**"&&(t[n][s]="*");let{optimizationLevel:i=1}=this.options;return i>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):i>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(i=>{let n=-1;for(;(n=i.indexOf("**",n+1))!==-1;){let s=n;for(;i[s+1]==="**";)s++;s!==n&&i.splice(n,s-n)}return i})}levelOneOptimize(t){return t.map(i=>(i=i.reduce((n,s)=>{let o=n[n.length-1];return s==="**"&&o==="**"?n:s===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(s),n)},[]),i.length===0?[""]:i))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let i=!1;do{if(i=!1,!this.preserveMultipleSlashes){for(let s=1;s<t.length-1;s++){let o=t[s];s===1&&o===""&&t[0]===""||(o==="."||o==="")&&(i=!0,t.splice(s,1),s--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(i=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let s=t[n-1];s&&s!=="."&&s!==".."&&s!=="**"&&(i=!0,t.splice(n-1,2),n-=2)}}while(i);return t.length===0?[""]:t}firstPhasePreProcess(t){let i=!1;do{i=!1;for(let n of t){let s=-1;for(;(s=n.indexOf("**",s+1))!==-1;){let r=s;for(;n[r+1]==="**";)r++;r>s&&n.splice(s+1,r-s);let a=n[s+1],c=n[s+2],l=n[s+3];if(a!==".."||!c||c==="."||c===".."||!l||l==="."||l==="..")continue;i=!0,n.splice(s,1);let u=n.slice(0);u[s]="**",t.push(u),s--}if(!this.preserveMultipleSlashes){for(let r=1;r<n.length-1;r++){let a=n[r];r===1&&a===""&&n[0]===""||(a==="."||a==="")&&(i=!0,n.splice(r,1),r--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(i=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let r=n[o-1];if(r&&r!=="."&&r!==".."&&r!=="**"){i=!0;let c=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...c),n.length===0&&n.push(""),o-=2}}}}while(i);return t}secondPhasePreProcess(t){for(let i=0;i<t.length-1;i++)for(let n=i+1;n<t.length;n++){let s=this.partsMatch(t[i],t[n],!this.preserveMultipleSlashes);if(s){t[i]=[],t[n]=s;break}}return t.filter(i=>i.length)}partsMatch(t,i,n=!1){let s=0,o=0,r=[],a="";for(;s<t.length&&o<i.length;)if(t[s]===i[o])r.push(a==="b"?i[o]:t[s]),s++,o++;else if(n&&t[s]==="**"&&i[o]===t[s+1])r.push(t[s]),s++;else if(n&&i[o]==="**"&&t[s]===i[o+1])r.push(i[o]),o++;else if(t[s]==="*"&&i[o]&&(this.options.dot||!i[o].startsWith("."))&&i[o]!=="**"){if(a==="b")return!1;a="a",r.push(t[s]),s++,o++}else if(i[o]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(a==="a")return!1;a="b",r.push(i[o]),s++,o++}else return!1;return t.length===i.length&&r}parseNegate(){if(this.nonegate)return;let t=this.pattern,i=!1,n=0;for(let s=0;s<t.length&&t.charAt(s)==="!";s++)i=!i,n++;n&&(this.pattern=t.slice(n)),this.negate=i}matchOne(t,i,n=!1){let s=this.options;if(this.isWindows){let h=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),k=!h&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),P=typeof i[0]=="string"&&/^[a-z]:$/i.test(i[0]),O=!P&&i[0]===""&&i[1]===""&&i[2]==="?"&&typeof i[3]=="string"&&/^[a-z]:$/i.test(i[3]),y=k?3:h?0:void 0,w=O?3:P?0:void 0;if(typeof y=="number"&&typeof w=="number"){let[v,b]=[t[y],i[w]];v.toLowerCase()===b.toLowerCase()&&(i[w]=v,w>y?i=i.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:i}),this.debug("matchOne",t.length,i.length);for(var r=0,a=0,c=t.length,l=i.length;r<c&&a<l;r++,a++){this.debug("matchOne loop");var u=i[a],p=t[r];if(this.debug(i,u,p),u===!1)return!1;if(u===L){this.debug("GLOBSTAR",[i,u,p]);var f=r,d=a+1;if(d===l){for(this.debug("** at the end");r<c;r++)if(t[r]==="."||t[r]===".."||!s.dot&&t[r].charAt(0)===".")return!1;return!0}for(;f<c;){var g=t[f];if(this.debug(`
|
|
2
|
+
globstar while`,t,f,i,d,g),this.matchOne(t.slice(f),i.slice(d),n))return this.debug("globstar found match!",f,c,g),!0;if(g==="."||g===".."||!s.dot&&g.charAt(0)==="."){this.debug("dot detected!",t,f,i,d);break}this.debug("globstar swallow a segment, and continue"),f++}return!!(n&&(this.debug(`
|
|
3
|
+
>>> no match, partial?`,t,f,i,d),f===c))}let h;if(typeof u=="string"?(h=p===u,this.debug("string match",u,p,h)):(h=u.test(p),this.debug("pattern match",u,p,h)),!h)return!1}if(r===c&&a===l)return!0;if(r===c)return n;if(a===l)return r===c-1&&t[r]==="";throw new Error("wtf?")}braceExpand(){return Zt(this.pattern,this.options)}parse(t){we(t);let i=this.options;if(t==="**")return L;if(t==="")return"";let n,s=null;(n=t.match(Bi))?s=i.dot?Gi:_i:(n=t.match(Oi))?s=(i.nocase?i.dot?Li:Di:i.dot?Ii:$i)(n[1]):(n=t.match(Hi))?s=(i.nocase?i.dot?Ui:zi:i.dot?qi:Xi)(n):(n=t.match(Ni))?s=i.dot?Vi:ji:(n=t.match(Fi))&&(s=Wi);let o=oe.fromGlob(t,this.options).toMMPattern();return s&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:s}),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 i=this.options,n=i.noglobstar?Qi:i.dot?Zi:Ki,s=new Set(i.nocase?["i"]:[]),o=t.map(c=>{let l=c.map(p=>{if(p instanceof RegExp)for(let f of p.flags.split(""))s.add(f);return typeof p=="string"?ss(p):p===L?L:p._src});l.forEach((p,f)=>{let d=l[f+1],g=l[f-1];p!==L||g===L||(g===void 0?d!==void 0&&d!==L?l[f+1]="(?:\\/|"+n+"\\/)?"+d:l[f]=n:d===void 0?l[f-1]=g+"(?:\\/|\\/"+n+")?":d!==L&&(l[f-1]=g+"(?:\\/|\\/"+n+"\\/)"+d,l[f+1]=L))});let u=l.filter(p=>p!==L);if(this.partial&&u.length>=1){let p=[];for(let f=1;f<=u.length;f++)p.push(u.slice(0,f).join("/"));return"(?:"+p.join("|")+")"}return u.join("/")}).join("|"),[r,a]=t.length>1?["(?:",")"]:["",""];o="^"+r+o+a+"$",this.partial&&(o="^(?:\\/|"+r+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...s].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,i=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&i)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let s=this.slashSplit(t);this.debug(this.pattern,"split",s);let o=this.set;this.debug(this.pattern,"set",o);let r=s[s.length-1];if(!r)for(let a=s.length-2;!r&&a>=0;a--)r=s[a];for(let a=0;a<o.length;a++){let c=o[a],l=s;if(n.matchBase&&c.length===1&&(l=[r]),this.matchOne(l,c,i))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return E.defaults(t).Minimatch}};E.AST=oe;E.Minimatch=re;E.escape=pt;E.unescape=X;var N="pickety.json",Ie=["ts","tsx","js","jsx","mjs","cjs"],K=`**/*.{${Ie.join(",")}}`,ae=new Set(["node_modules",".git",".next","dist","out","build",".turbo",".cache",".nx","coverage"]);function x(e){let t=e.replace(/\\/g,"/");return/^[a-zA-Z]:/.test(t)&&(t=t[0].toLowerCase()+t.slice(1)),t}function De(e,t){return Z.relative(e,t).replace(/\\/g,"/")}function ft(e,t){return E(e,t)||e===t}function os(e){return["*","?","[","]","{","}","(",")","!","+","@"].some(i=>e.includes(i))}function J(e,t,i){if(!i||i.length===0)return!1;let n=x(Z.relative(t,Z.resolve(e)));return n===""||n.startsWith("..")?!1:i.some(s=>{let o=s.trim();if(!o)return!1;let r=x(o).replace(/^\.?\//,"").replace(/^\/+/,"");return(os(r)?[r]:[r,`${r}/**`]).some(c=>E(n,c)||E(n,`**/${c}`))})}function ce(e){return Z.join(e,N)}function z(e,t){return e==="instability"?t.toFixed(2):String(t)}async function Kt(e,t){let i=ce(e);if(Le.existsSync(i)&&await le.window.showWarningMessage("pickety.json already exists. Overwrite?","Yes","No")!=="Yes")return;Le.writeFileSync(i,JSON.stringify({$schema:"https://raw.githubusercontent.com/DanielSerio/pickety/main/resources/pickety.schema.json",modules:{features:"src/features/*",components:"src/components/**/*",utils:"src/utils/**/*"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"features",imports:"features",allow:!0,message:"Features can import from their own module."},{importer:"features",imports:"components",allow:!0},{importer:"features",imports:"utils",allow:!0}]}},"boundary-diagrams":!0},null,2)),le.window.showInformationMessage("Pickety: pickety.json created.");let s=await le.workspace.openTextDocument(i);await le.window.showTextDocument(s),t()}var mt=S(require("vscode"));var Y=S(require("path"));function Ne(e,t,i){let n=dt(e),s=e.name??`rule[${t}]`,o=e.group,r=o?`${o}: ${s}`:s;return{allow:e.allow??!1,severity:e.severity??i,name:s,group:o,label:r,effectiveImporter:n?.path||e.importer||"*",isOnly:e.only||!!e.containedTo,isAllowStyle:(e.allow??!1)||!!e.containedTo||!!e.only}}function en(e,t,i){let n=Ne(e,t,i),s=Array.isArray(e.imports)?e.imports:[e.imports];return{rule:e,...n,importPatterns:s.filter(o=>typeof o=="string")}}function W(e,t,i){let n=e.includes("[")?e.slice(0,e.indexOf("[")):e;return!!(ft(e,i)||ft(n,i)||i.includes("/")&&(E(t,i)||E(t,`**/${i}`)||E(t,`**/${i}/**`)))}function dt(e){if(e.containedTo)return typeof e.containedTo=="object"?e.containedTo:{path:e.containedTo}}function ee(e){let{filePath:t,importStmt:i,ruleName:n,ruleLabel:s,message:o,severity:r,sourceModule:a,targetModule:c,ruleGroup:l}=e;return{file:t,line:i.line,character:i.character,length:i.length,message:`[${s}] ${o} (importing "${i.specifier}")`,severity:r,ruleName:n,ruleGroup:l,sourceModule:a,targetModule:c}}function tn(e){let t=[],i=new Set,n=new Set,s=[];function o(r){i.add(r),n.add(r),s.push(r);let a=e.get(r);if(a){for(let c of a)if(!i.has(c))o(c);else if(n.has(c)){let l=s.indexOf(c);l!==-1&&t.push([...s.slice(l),c])}}n.delete(r),s.pop()}for(let r of e.keys())i.has(r)||o(r);return t}function B(e){return e.match(/\$[\w-]+/g)||[]}function nn(e){let t=new Set;for(let i of e)for(let n of B(i))t.add(n);return[...t]}function Se(e,t,i){let n=e.split("/"),s=t.split("/"),o=0,r=n.filter(c=>c!=="**").length,a=s.length-r;for(let c=o;c<=a;c++){let l=sn({patternSegments:n,pathSegments:s,startOffset:c,variables:i});if(l)return l}}function sn(e){let{patternSegments:t,pathSegments:i,startOffset:n,variables:s}=e,o={},r=n;for(let a=0;a<t.length;a++){let c=t[a];if(c==="**"){let f=t.slice(a+1);if(f.length===0)return o;for(let d=r;d<=i.length-f.length;d++){let g=sn({patternSegments:f,pathSegments:i,startOffset:d,variables:s});if(g)return{...o,...g}}return}if(r>=i.length)return;let l=c,u=[];for(let f of s)l.includes(f)&&(l=l.replace(f,`__VAR_${u.length}__`),u.push(f));l=l.replace(/[.+?^{}()|[\]\\]/g,"\\$&"),l=l.replace(/\*/g,"[^/]*");for(let f=0;f<u.length;f++)l=l.replace(`__VAR_${f}__`,"([^/]+)");let p=i[r].match(new RegExp(`^${l}$`));if(!p)return;for(let f=0;f<u.length;f++)o[u[f]]=p[f+1];r++}return o}function te(e,t,i){let n=e;for(let s of t){let o=typeof i=="string"?i:i[s];n=n.replaceAll(s,o)}return n}var rn=Ie.map(e=>`.${e}`),rs=rn.map(e=>`index${e}`),on=/(\/\*[\s\S]*?\*\/|\/\/.*)|(['"`](?:\\.|[^'"`])*['"`])|((?:import|export)\s+(?:[\s\S]*?from\s+)?['"`]([^'"`]+)['"`])|(import\s*\(\s*['"`]([^'"`]+)['"`]\s*\))/gm;function as(e){let t=[],i=e.split(`
|
|
4
|
+
`),n=[],s=0;for(let a of i)n.push(s),s+=a.length+1;let o=a=>{let c=0;for(let l=1;l<n.length&&!(n[l]>a);l++)c=l;return{line:c,character:a-n[c]}},r;for(on.lastIndex=0;(r=on.exec(e))!==null;){let[a,c,l,u,p,f,d]=r;if(!(c||l)){if(u&&p){let g=o(r.index);t.push({specifier:p,line:g.line,character:g.character,length:u.length})}else if(f&&d){let g=o(r.index);t.push({specifier:d,line:g.line,character:g.character,length:f.length})}}}return t}function cs(e,t,i){let{knownFiles:n,root:s,aliases:o}=i;for(let[r,a]of Object.entries(o))if(r.endsWith("/*")){let c=r.slice(0,-2),l=a.endsWith("/*")?a.slice(0,-2):a==="*"?"./":a;if(e.startsWith(c)){let u=e.replace(c,l);return gt(Y.resolve(s,u),n)}}else if(e===r)return gt(Y.resolve(s,a),n);if(e.startsWith(".")){let r=Y.dirname(t),a=Y.resolve(r,e);return gt(a,n)}}function gt(e,t){let i=x(e);if(t.has(i))return i;for(let n of rn){let s=i+n;if(t.has(s))return s}for(let n of rs){let s=i+"/"+n;if(t.has(s))return s}}function ls(e){return e.endsWith("/*")?e.slice(0,-2)+"/**/*":e}function us(e,t,i){if(t.length===0)return e;let n=t.map(s=>i[s]);return`${e}[${n.join(",")}]`}function ps(e,t,i){let n=x(Y.relative(i,e));for(let[s,o]of Object.entries(t)){let r=ls(o),a=B(o);if(a.length>0){let c=Se(r,n,a)||(r!==o?Se(o,n,a):void 0);if(c)return{name:us(s,a,c),pattern:o,relativePath:n,variables:c};continue}if(E(n,r)||E(n,o))return{name:s,pattern:o,relativePath:n}}}function j(e,t,i){return ps(e,t,i)?.name}function je(e,t,i){let n=as(t),s=[];for(let o of n){let r=cs(o.specifier,e,i);r&&s.push({statement:o,resolvedPath:r})}return s}function ue(e,t,i){let{root:n,knownFiles:s}=i,o=e.getModuleLevelGraph(t,n),r=Object.keys(t),a=new Map;for(let p of r)a.set(p,0);for(let p of s){let f=j(p,t,n);f&&a.set(f,(a.get(f)??0)+1)}let c=new Map;for(let p of r)c.set(p,0);for(let[,p]of o)for(let f of p)c.set(f,(c.get(f)??0)+1);let l=fs(o,r),u=r.map(p=>{let f=c.get(p)??0,d=o.get(p)?.size??0,g=f+d;return{moduleName:p,fileCount:a.get(p)??0,afferentCoupling:f,efferentCoupling:d,instability:g===0?0:d/g,dependencyDepth:l.get(p)??0}});return u.sort((p,f)=>p.instability-f.instability),u}function fs(e,t){let i=new Map,n=new Set;function s(o){if(i.has(o))return i.get(o);if(n.has(o))return 0;n.add(o);let r=e.get(o),a=0;if(r&&r.size>0)for(let c of r)a=Math.max(a,1+s(c));return n.delete(o),i.set(o,a),a}for(let o of t)s(o);return i}function an(e,t){let i=[],n=[{key:"maxAfferentCoupling",label:"afferent coupling",getValue:s=>s.afferentCoupling},{key:"maxEfferentCoupling",label:"efferent coupling",getValue:s=>s.efferentCoupling},{key:"maxInstability",label:"instability",getValue:s=>s.instability},{key:"maxDepth",label:"dependency depth",getValue:s=>s.dependencyDepth}];for(let s of e)for(let o of n){let r=t[o.key],a=o.getValue(s);r!==void 0&&a>r&&i.push({moduleName:s.moduleName,metric:o.label,value:a,threshold:r})}return i}var U=S(require("fs")),$=S(require("path"));function Ve(e,t,i){let n=e["boundary-diagrams"];if(!n)return;let s="picket-boundaries.mermaid",o;if(typeof n=="string"){let u=$.resolve(t,n);try{U.existsSync(u)&&U.statSync(u).isDirectory()?o=$.join(u,s):o=u}catch{o=u}}else o=$.join(t,s);let r=x($.resolve(t)),a=x($.resolve(o)),c=$.relative(r,a);if(c.startsWith("..")||$.isAbsolute(c)){console.error(`Pickety: Diagram output path "${n}" escapes the workspace root. Ignoring.`);return}let l=ds(e,i);try{let u=$.dirname(o);return U.existsSync(u)||U.mkdirSync(u,{recursive:!0}),U.writeFileSync(o,l,"utf-8"),o}catch(u){console.error(`Pickety: Failed to write Mermaid diagram to ${o}`,u);return}}function ht(e){return e.replace(/"/g,"#quot;").replace(/\[/g,"#lsqb;").replace(/\]/g,"#rsqb;").replace(/\|/g,"#vert;").replace(/</g,"#lt;").replace(/>/g,"#gt;")}function ds(e,t){let i=new Map;if(t)for(let o of t)i.set(o.moduleName,o);let n={config:e,healthByModule:i,lines:["graph LR"],edgeStyles:[],nodeIds:new Map,idCounter:0,edgeIndex:0,globalSeverity:e.rules["module-boundaries"].severity};gs(n);let s=hs(n);return ms(n,s),ys(n),vs(n),n.lines.concat(n.edgeStyles).join(`
|
|
5
|
+
`)}function gs(e){e.lines.push(""),e.lines.push(" %% Node Styles"),e.lines.push(" classDef module fill:#f1f5f9,stroke:#64748b,stroke-width:2px;"),e.lines.push(" classDef external fill:#ffffff,stroke:#94a3b8,stroke-width:1px,stroke-dasharray: 5 5;")}function hs(e){let t=new Map,i=new Set(Object.keys(e.config.modules));return e.config.rules["module-boundaries"].rules.forEach((s,o)=>{let{effectiveImporter:r}=Ne(s,o,e.globalSeverity);i.add(r),(Array.isArray(s.imports)?s.imports:[s.imports]).forEach(l=>{typeof l=="string"&&i.add(l)}),cn(s.exports).forEach(l=>{i.add(l.path),i.add(l.to)})}),i.forEach(s=>{let o=s.split("/"),r=o.length>1?o[0]:"Base",a=t.get(r)??[];a.push(s),t.set(r,a)}),t}function Re(e,t){return e.nodeIds.has(t)||e.nodeIds.set(t,`n${e.idCounter++}`),e.nodeIds.get(t)}function ms(e,t){t.forEach((i,n)=>{e.lines.push(""),e.lines.push(` subgraph c${e.idCounter++} [" ${ht(n)} "]`),i.forEach(s=>{let o=Re(e,s),r=!!e.config.modules[s],a=e.healthByModule.get(s),c=ht(s);a&&(c+=`<br/><small>Ca:${a.afferentCoupling} Ce:${a.efferentCoupling} I:${a.instability.toFixed(2)}</small>`);let l=s.includes("$")?`(["${c}"])`:`["${c}"]`,u=r?"module":"external";e.lines.push(` ${o}${l}:::${u}`)}),e.lines.push(" end")})}function pe(e,t){let i=t.arrow??"-->",n=t.width??"2px",s=t.dash?",stroke-dasharray:5":"";e.lines.push(` ${t.fromId} ${i}|"${ht(t.label)}"| ${t.toId}`),e.edgeStyles.push(` linkStyle ${e.edgeIndex++} stroke:${t.color},stroke-width:${n}${s}`)}function ys(e){e.lines.push(""),e.lines.push(" %% Boundary Rules");let t=e.config.rules["module-boundaries"].rules,i="#14b8a6",n="#f97316";t.forEach((s,o)=>{let{allow:r,label:a,effectiveImporter:c,isAllowStyle:l,isOnly:u}=Ne(s,o,e.globalSeverity);(Array.isArray(s.imports)?s.imports:[s.imports]).forEach(f=>{if(typeof f!="string")return;let d=Re(e,u?f:c),g=Re(e,u?c:f),h=u?s.containedTo?"CONTAINED":"ONLY":r?"ALLOW":"DENY",k=s.message||`${h}: ${a}`;pe(e,{fromId:d,toId:g,label:k,color:u?n:l?"#22c55e":"#ef4444",width:u?"4px":"2px",dash:!l&&!u,arrow:l||u?"-->":"-.->"})}),cn(s.exports).forEach(f=>{pe(e,{fromId:Re(e,f.to),toId:Re(e,f.path),label:`EXPORT: ${a}`,color:i})})})}function vs(e){e.lines.push(""),e.lines.push(" %% Legend"),e.lines.push(" subgraph Legend"),e.lines.push(' legendAllow["ALLOW"]'),e.lines.push(' legendDeny["DENY"]'),e.lines.push(' legendOnly["ONLY/CONTAINED"]'),e.lines.push(' legendExport["EXPORT EXCEPTION"]'),e.lines.push(" end"),e.lines.push(""),e.lines.push(" %% Legend Edges"),pe(e,{fromId:"legendAllow",toId:"legendDeny",label:"ALLOW",color:"#22c55e"}),pe(e,{fromId:"legendDeny",toId:"legendAllow",label:"DENY",color:"#ef4444",dash:!0,arrow:"-.->"}),pe(e,{fromId:"legendOnly",toId:"legendAllow",label:"ONLY",color:"#f97316",width:"4px"}),pe(e,{fromId:"legendExport",toId:"legendAllow",label:"EXPORT",color:"#14b8a6"})}function cn(e){return e?Array.isArray(e)?e:[e]:[]}var ln=S(require("vscode"));function fe(e){return e?!0:(ln.window.showErrorMessage("Pickety: No active configuration. Check pickety.json for errors."),!1)}function un(e,t,i){if(!fe(e))return;let n=ue(t,e.modules,i),s=Ve(e,i.root,n);s?mt.window.showInformationMessage(`Pickety: Generated boundary diagram at ${s}`):mt.window.showErrorMessage("Pickety: Failed to generate diagram. Is 'boundary-diagrams' enabled in pickety.json?")}var Be=S(require("vscode"));var ne;function fn(e,t){if(ne){ne.reveal(),ne.webview.html=pn(e,t);return}ne=Be.window.createWebviewPanel("picketyHealth","Pickety: Module Health",Be.ViewColumn.One,{enableScripts:!1}),ne.webview.html=pn(e,t),ne.onDidDispose(()=>{ne=void 0})}function Fe(e){let t=Math.max(0,Math.min(1,e));return`background-color: hsla(${Math.round((1-t)*140)}, 75%, 40%, 0.9); color: white; text-shadow: 0 1px 1px rgba(0,0,0,0.3);`}function We(e,t){return t===void 0?"":e>t?"exceeds":e>=t*.8?"approaching":""}function pn(e,t){let i=Math.max(1,...e.map(r=>r.afferentCoupling)),n=Math.max(1,...e.map(r=>r.efferentCoupling)),s=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,
|
|
119
|
-
<td class="module-name">${
|
|
118
|
+
${e.map((r,a)=>{let c=r.afferentCoupling/i,l=r.efferentCoupling/n,u=r.instability,p=r.dependencyDepth/s,f=We(r.afferentCoupling,t?.maxAfferentCoupling),d=We(r.efferentCoupling,t?.maxEfferentCoupling),g=We(r.instability,t?.maxInstability),h=We(r.dependencyDepth,t?.maxDepth);return`<tr${a%2===1?' class="alt"':""}>
|
|
119
|
+
<td class="module-name">${bs(r.moduleName)}</td>
|
|
120
120
|
<td class="num">${r.fileCount}</td>
|
|
121
|
-
<td class="num ${f}" style="${
|
|
122
|
-
<td class="num ${d}" style="${
|
|
123
|
-
<td class="num ${
|
|
124
|
-
<td class="num ${
|
|
121
|
+
<td class="num ${f}" style="${Fe(c)}">${z("ca",r.afferentCoupling)}</td>
|
|
122
|
+
<td class="num ${d}" style="${Fe(l)}">${z("ce",r.efferentCoupling)}</td>
|
|
123
|
+
<td class="num ${g}" style="${Fe(u)}">${z("instability",r.instability)}</td>
|
|
124
|
+
<td class="num ${h}" style="${Fe(p)}">${z("depth",r.dependencyDepth)}</td>
|
|
125
125
|
</tr>`}).join(`
|
|
126
126
|
`)}
|
|
127
127
|
</tbody>
|
|
@@ -136,18 +136,21 @@ 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
|
|
140
|
-
`;break;case 114:
|
|
141
|
-
`),
|
|
142
|
-
`+" ".repeat(t)),"\r":new Array(
|
|
143
|
-
`+" ".repeat(t))}," ":{"\n":new Array(
|
|
144
|
-
`+" ".repeat(t)),"\r":new Array(
|
|
145
|
-
`+" ".repeat(t))}},
|
|
139
|
+
</html>`}function bs(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function dn(e,t,i){if(!fe(e))return;let n=ue(t,e.modules,i);fn(n,e.health)}var F=S(require("vscode")),gn=S(require("path"));async function hn(e,t,i){let n=i.root,s=F.window.activeTextEditor;if(!s){F.window.showErrorMessage("Pickety: No active file.");return}if(!fe(e))return;let o=x(s.document.uri.fsPath),r=t.getTransitiveDependents(o);if(r.size===0){F.window.showInformationMessage("Pickety: No dependents found for this file.");return}let a=new Map;for(let f of r){let d=j(f,e.modules,n)??"(unmatched)";a.has(d)||a.set(d,[]),a.get(d).push(De(n,f))}let c=[];for(let[f,d]of a){c.push({label:f,kind:F.QuickPickItemKind.Separator});for(let g of d)c.push({label:g,description:f})}let l=De(n,o),u=a.size,p=await F.window.showQuickPick(c,{title:`Impact: ${l} (${r.size} files across ${u} modules)`,placeHolder:"Select a file to open"});if(p&&p.kind!==F.QuickPickItemKind.Separator){let f=gn.join(n,p.label),d=await F.workspace.openTextDocument(f);await F.window.showTextDocument(d)}}var M=S(require("vscode")),St=S(require("path")),Rt=S(require("fs"));function Pe(e,t=!1){let i=e.length,n=0,s="",o=0,r=16,a=0,c=0,l=0,u=0,p=0;function f(y,w){let v=0,b=0;for(;v<y||!w;){let m=e.charCodeAt(n);if(m>=48&&m<=57)b=b*16+m-48;else if(m>=65&&m<=70)b=b*16+m-65+10;else if(m>=97&&m<=102)b=b*16+m-97+10;else break;n++,v++}return v<y&&(b=-1),b}function d(y){n=y,s="",o=0,r=16,p=0}function g(){let y=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&de(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&de(e.charCodeAt(n)))for(n++;n<e.length&&de(e.charCodeAt(n));)n++;else return p=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&&de(e.charCodeAt(n))){for(n++;n<e.length&&de(e.charCodeAt(n));)n++;w=n}else p=3;return e.substring(y,w)}function h(){let y="",w=n;for(;;){if(n>=i){y+=e.substring(w,n),p=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>=i){p=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=f(4,!0);m>=0?y+=String.fromCharCode(m):p=4;break;default:p=5}w=n;continue}if(v>=0&&v<=31)if(Ee(v)){y+=e.substring(w,n),p=2;break}else p=6;n++}return y}function k(){if(s="",p=0,o=n,c=a,u=l,n>=i)return o=i,r=17;let y=e.charCodeAt(n);if(yt(y)){do n++,s+=String.fromCharCode(y),y=e.charCodeAt(n);while(yt(y));return r=15}if(Ee(y))return n++,s+=String.fromCharCode(y),y===13&&e.charCodeAt(n)===10&&(n++,s+=`
|
|
141
|
+
`),a++,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++,s=h(),r=10;case 47:let w=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<i&&!Ee(e.charCodeAt(n));)n++;return s=e.substring(w,n),r=12}if(e.charCodeAt(n+1)===42){n+=2;let v=i-1,b=!1;for(;n<v;){let m=e.charCodeAt(n);if(m===42&&e.charCodeAt(n+1)===47){n+=2,b=!0;break}n++,Ee(m)&&(m===13&&e.charCodeAt(n)===10&&n++,a++,l=n)}return b||(n++,p=1),s=e.substring(w,n),r=13}return s+=String.fromCharCode(y),n++,r=16;case 45:if(s+=String.fromCharCode(y),n++,n===i||!de(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 s+=g(),r=11;default:for(;n<i&&P(y);)n++,y=e.charCodeAt(n);if(o!==n){switch(s=e.substring(o,n),s){case"true":return r=8;case"false":return r=9;case"null":return r=7}return r=16}return s+=String.fromCharCode(y),n++,r=16}}function P(y){if(yt(y)||Ee(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 O(){let y;do y=k();while(y>=12&&y<=15);return y}return{setPosition:d,getPosition:()=>n,scan:t?O:k,getToken:()=>r,getTokenValue:()=>s,getTokenOffset:()=>o,getTokenLength:()=>n-o,getTokenStartLine:()=>c,getTokenStartCharacter:()=>o-u,getTokenError:()=>p}}function yt(e){return e===32||e===9}function Ee(e){return e===10||e===13}function de(e){return e>=48&&e<=57}var mn;(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"})(mn||(mn={}));var I=new Array(20).fill(0).map((e,t)=>" ".repeat(t)),ge=200,vt={" ":{"\n":new Array(ge).fill(0).map((e,t)=>`
|
|
142
|
+
`+" ".repeat(t)),"\r":new Array(ge).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(ge).fill(0).map((e,t)=>`\r
|
|
143
|
+
`+" ".repeat(t))}," ":{"\n":new Array(ge).fill(0).map((e,t)=>`
|
|
144
|
+
`+" ".repeat(t)),"\r":new Array(ge).fill(0).map((e,t)=>"\r"+" ".repeat(t)),"\r\n":new Array(ge).fill(0).map((e,t)=>`\r
|
|
145
|
+
`+" ".repeat(t))}},yn=[`
|
|
146
146
|
`,"\r",`\r
|
|
147
|
-
`];function
|
|
147
|
+
`];function bt(e,t,i){let n,s,o,r,a;if(t){for(r=t.offset,a=r+t.length,o=r;o>0&&!Te(e,o-1);)o--;let v=a;for(;v<e.length&&!Te(e,v);)v++;s=e.substring(o,v),n=ws(s,i)}else s=e,n=0,o=0,r=0,a=e.length;let c=xs(i,e),l=yn.includes(c),u=0,p=0,f;i.insertSpaces?f=I[i.tabSize||4]??he(I[1],i.tabSize||4):f=" ";let d=f===" "?" ":" ",g=Pe(s,!1),h=!1;function k(){if(u>1)return he(c,u)+he(f,n+p);let v=f.length*(n+p);return!l||v>vt[d][c].length?c+he(f,n+p):v<=0?c:vt[d][c][v]}function P(){let v=g.scan();for(u=0;v===15||v===14;)v===14&&i.keepLines?u+=1:v===14&&(u=1),v=g.scan();return h=v===16||g.getTokenError()!==0,v}let O=[];function y(v,b,m){!h&&(!t||b<a&&m>r)&&e.substring(b,m)!==v&&O.push({offset:b,length:m-b,content:v})}let w=P();if(i.keepLines&&u>0&&y(he(c,u),0,0),w!==17){let v=g.getTokenOffset()+o,b=f.length*n<20&&i.insertSpaces?I[f.length*n]:he(f,n);y(b,o,v)}for(;w!==17;){let v=g.getTokenOffset()+g.getTokenLength()+o,b=P(),m="",H=!1;for(;u===0&&(b===12||b===13);){let ot=g.getTokenOffset()+o;y(I[1],v,ot),v=g.getTokenOffset()+g.getTokenLength()+o,H=b===12,m=H?k():"",b=P()}if(b===2)w!==1&&p--,i.keepLines&&u>0||!i.keepLines&&w!==1?m=k():i.keepLines&&(m=I[1]);else if(b===4)w!==3&&p--,i.keepLines&&u>0||!i.keepLines&&w!==3?m=k():i.keepLines&&(m=I[1]);else{switch(w){case 3:case 1:p++,i.keepLines&&u>0||!i.keepLines?m=k():m=I[1];break;case 5:i.keepLines&&u>0||!i.keepLines?m=k():m=I[1];break;case 12:m=k();break;case 13:u>0?m=k():H||(m=I[1]);break;case 6:i.keepLines&&u>0?m=k():H||(m=I[1]);break;case 10:i.keepLines&&u>0?m=k():b===6&&!H&&(m="");break;case 7:case 8:case 9:case 11:case 2:case 4:i.keepLines&&u>0?m=k():(b===12||b===13)&&!H?m=I[1]:b!==5&&b!==17&&(h=!0);break;case 16:h=!0;break}u>0&&(b===12||b===13)&&(m=k())}b===17&&(i.keepLines&&u>0?m=k():m=i.insertFinalNewline?c:"");let st=g.getTokenOffset()+o;y(m,v,st),w=b}return O}function he(e,t){let i="";for(let n=0;n<t;n++)i+=e;return i}function ws(e,t){let i=0,n=0,s=t.tabSize||4;for(;i<e.length;){let o=e.charAt(i);if(o===I[1])n++;else if(o===" ")n+=s;else break;i++}return Math.floor(n/s)}function xs(e,t){for(let i=0;i<t.length;i++){let n=t.charAt(i);if(n==="\r")return i+1<t.length&&t.charAt(i+1)===`
|
|
148
148
|
`?`\r
|
|
149
149
|
`:"\r";if(n===`
|
|
150
150
|
`)return`
|
|
151
151
|
`}return e&&e.eol||`
|
|
152
|
-
`}function
|
|
153
|
-
`.indexOf(e.charAt(t))!==-1}var Te;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Te||(Te={}));function hn(e,t=[],s=Te.DEFAULT){let n=null,o=[],i=[];function r(a){Array.isArray(o)?o.push(a):n!==null&&(o[n]=a)}return yt(e,{onObjectBegin:()=>{let a={};r(a),i.push(o),o=a,n=null},onObjectProperty:a=>{n=a},onObjectEnd:()=>{o=i.pop()},onArrayBegin:()=>{let a=[];r(a),i.push(o),o=a,n=null},onArrayEnd:()=>{o=i.pop()},onLiteralValue:r,onError:(a,u,p)=>{t.push({error:a,offset:u,length:p})}},s),o[0]}function Be(e,t=[],s=Te.DEFAULT){let n={type:"array",offset:-1,length:-1,children:[],parent:void 0};function o(a){n.type==="property"&&(n.length=a-n.offset,n=n.parent)}function i(a){return n.children.push(a),a}yt(e,{onObjectBegin:a=>{n=i({type:"object",offset:a,length:-1,parent:n,children:[]})},onObjectProperty:(a,u,p)=>{n=i({type:"property",offset:u,length:-1,parent:n,children:[]}),n.children.push({type:"string",value:a,offset:u,length:p,parent:n})},onObjectEnd:(a,u)=>{o(a+u),n.length=a+u-n.offset,n=n.parent,o(a+u)},onArrayBegin:(a,u)=>{n=i({type:"array",offset:a,length:-1,parent:n,children:[]})},onArrayEnd:(a,u)=>{n.length=a+u-n.offset,n=n.parent,o(a+u)},onLiteralValue:(a,u,p)=>{i({type:ho(a),offset:u,length:p,parent:n,value:a}),o(u+p)},onSeparator:(a,u,p)=>{n.type==="property"&&(a===":"?n.colonOffset=u:a===","&&o(u))},onError:(a,u,p)=>{t.push({error:a,offset:u,length:p})}},s);let c=n.children[0];return c&&delete c.parent,c}function Ae(e,t){if(!e)return;let s=e;for(let n of t)if(typeof n=="string"){if(s.type!=="object"||!Array.isArray(s.children))return;let o=!1;for(let i of s.children)if(Array.isArray(i.children)&&i.children[0].value===n&&i.children.length===2){s=i.children[1],o=!0;break}if(!o)return}else{let o=n;if(s.type!=="array"||o<0||!Array.isArray(s.children)||o>=s.children.length)return;s=s.children[o]}return s}function yt(e,t,s=Te.DEFAULT){let n=Re(e,!1),o=[],i=0;function r(S){return S?()=>i===0&&S(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function c(S){return S?M=>i===0&&S(M,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function a(S){return S?M=>i===0&&S(M,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>o.slice()):()=>!0}function u(S){return S?()=>{i>0?i++:S(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>o.slice())===!1&&(i=1)}:()=>!0}function p(S){return S?()=>{i>0&&i--,i===0&&S(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}let l=u(t.onObjectBegin),f=a(t.onObjectProperty),d=p(t.onObjectEnd),h=u(t.onArrayBegin),g=p(t.onArrayEnd),b=a(t.onLiteralValue),x=c(t.onSeparator),T=r(t.onComment),m=c(t.onError),w=s&&s.disallowComments,k=s&&s.allowTrailingComma;function v(){for(;;){let S=n.scan();switch(n.getTokenError()){case 4:y(14);break;case 5:y(15);break;case 3:y(13);break;case 1:w||y(11);break;case 2:y(12);break;case 6:y(16);break}switch(S){case 12:case 13:w?y(10):T();break;case 16:y(1);break;case 15:case 14:break;default:return S}}}function y(S,M=[],$t=[]){if(m(S),M.length+$t.length>0){let Me=n.getToken();for(;Me!==17;){if(M.indexOf(Me)!==-1){v();break}else if($t.indexOf(Me)!==-1)break;Me=v()}}}function j(S){let M=n.getTokenValue();return S?b(M):(f(M),o.push(M)),v(),!0}function me(){switch(n.getToken()){case 11:let S=n.getTokenValue(),M=Number(S);isNaN(M)&&(y(2),M=0),b(M);break;case 7:b(null);break;case 8:b(!0);break;case 9:b(!1);break;default:return!1}return v(),!0}function ye(){return n.getToken()!==10?(y(3,[],[2,5]),!1):(j(!1),n.getToken()===6?(x(":"),v(),be()||y(4,[],[2,5])):y(5,[],[2,5]),o.pop(),!0)}function nt(){l(),v();let S=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(S||y(4,[],[]),x(","),v(),n.getToken()===2&&k)break}else S&&y(6,[],[]);ye()||y(4,[],[2,5]),S=!0}return d(),n.getToken()!==2?y(7,[2],[]):v(),!0}function st(){h(),v();let S=!0,M=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(M||y(4,[],[]),x(","),v(),n.getToken()===4&&k)break}else M&&y(6,[],[]);S?(o.push(0),S=!1):o[o.length-1]++,be()||y(4,[],[4,5]),M=!0}return g(),S||o.pop(),n.getToken()!==4?y(8,[4],[]):v(),!0}function be(){switch(n.getToken()){case 3:return st();case 1:return nt();case 10:return j(!0);default:return me()}}return v(),n.getToken()===17?s.allowEmptyContent?!0:(y(4,[],[]),!1):be()?(n.getToken()!==17&&y(9,[],[]),!0):(y(4,[],[]),!1)}function ho(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 gn(e,t,s,n){let o=t.slice(),r=Be(e,[]),c,a;for(;o.length>0&&(a=o.pop(),c=Ae(r,o),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 u=Ae(c,[a]);if(u!==void 0)if(s===void 0){if(!u.parent)throw new Error("Malformed AST");let p=c.children.indexOf(u.parent),l,f=u.parent.offset+u.parent.length;if(p>0){let d=c.children[p-1];l=d.offset+d.length}else l=c.offset+1,c.children.length>1&&(f=c.children[1].offset);return ee(e,{offset:l,length:f-l,content:""},n)}else return ee(e,{offset:u.offset,length:u.length,content:JSON.stringify(s)},n);else{if(s===void 0)return[];let p=`${JSON.stringify(a)}: ${JSON.stringify(s)}`,l=n.getInsertionIndex?n.getInsertionIndex(c.children.map(d=>d.children[0].value)):c.children.length,f;if(l>0){let d=c.children[l-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 ee(e,f,n)}}else if(c.type==="array"&&typeof a=="number"&&Array.isArray(c.children)){let u=a;if(u===-1){let p=`${JSON.stringify(s)}`,l;if(c.children.length===0)l={offset:c.offset+1,length:0,content:p};else{let f=c.children[c.children.length-1];l={offset:f.offset+f.length,length:0,content:","+p}}return ee(e,l,n)}else if(s===void 0&&c.children.length>=0){let p=a,l=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,g=c.offset+c.length;f={offset:h,length:g-2-h,content:""}}else f={offset:l.offset,length:c.children[p+1].offset-l.offset,content:""};return ee(e,f,n)}else if(s!==void 0){let p,l=`${JSON.stringify(s)}`;if(!n.isArrayInsertion&&c.children.length>a){let f=c.children[a];p={offset:f.offset,length:f.length,content:l}}else if(c.children.length===0||a===0)p={offset:c.offset+1,length:0,content:c.children.length===0?l:l+","};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:","+l}}return ee(e,p,n)}else throw new Error(`Can not ${s===void 0?"remove":n.isArrayInsertion?"insert":"modify"} Array index ${u} 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 ee(e,{offset:r?r.offset:0,length:r?r.length:0,content:JSON.stringify(s)},n)}}function ee(e,t,s){if(!s.formattingOptions)return[t];let n=bt(e,t),o=t.offset,i=t.offset+t.content.length;if(t.length===0||t.content.length===0){for(;o>0&&!Ee(n,o-1);)o--;for(;i<n.length&&!Ee(n,i);)i++}let r=mt(n,{offset:o,length:i-o},{...s.formattingOptions,keepLines:!1});for(let a=r.length-1;a>=0;a--){let u=r[a];n=bt(n,u),o=Math.min(o,u.offset),i=Math.max(i,u.offset+u.length),i+=u.content.length-u.length}let c=e.length-(n.length-i)-o;return[{offset:o,length:c,content:n.substring(o,i)}]}function bt(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}var mn;(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"})(mn||(mn={}));var yn;(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"})(yn||(yn={}));var _e=hn,vn=Be,He=Ae;var bn;(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"})(bn||(bn={}));function kn(e,t,s,n){return gn(e,t,s,n)}async function wn(e,t){let s=kt.join(e,N);if(!wt.existsSync(s))return;let n=await P.workspace.openTextDocument(P.Uri.file(s)),o=await P.window.showTextDocument(n),i=n.getText(),r=vn(i);if(!r)return;let c=-1,a=He(r,["rules","module-boundaries","rules"]);if(a&&a.children)if(typeof t=="string"&&!t.startsWith("rule[")){for(let u of a.children){let p=He(u,["name"]);if(p&&p.value===t){c=u.offset;break}}if(c===-1)for(let u of a.children){let p=He(u,["importer"]);if(p&&p.value===t){c=p.offset;break}}}else{let u=String(t).match(/rule\[(\d+)\]/),p=u?parseInt(u[1]):-1;p!==-1&&a.children[p]&&(c=a.children[p].offset)}if(c!==-1){let u=n.positionAt(c);o.selection=new P.Selection(u,u),o.revealRange(new P.Range(u,u),P.TextEditorRevealType.InCenter)}}async function xn(e,t,s){let n=kt.join(e,N);if(!wt.existsSync(n))return;let o=await P.workspace.openTextDocument(P.Uri.file(n)),i=o.getText(),r=kn(i,["rules","module-boundaries","rules",-1],{importer:t,imports:s,allow:!0,name:`allow-${t}-to-${s}`},{formattingOptions:{insertSpaces:!0,tabSize:2}}),c=new P.WorkspaceEdit;for(let a of r)c.replace(o.uri,new P.Range(o.positionAt(a.offset),o.positionAt(a.offset+a.length)),a.content);await P.workspace.applyEdit(c),await o.save(),P.window.showInformationMessage(`Added exception: Allow '${s}' in '${t}'`)}function Sn(e,t,s,n){e.subscriptions.push(B.commands.registerCommand("pickety.refresh",()=>{t.reload(),t.reloadAliases(),B.window.showInformationMessage("Pickety: Configuration refreshed")})),e.subscriptions.push(B.commands.registerCommand("pickety.generateDiagram",()=>rn(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(B.commands.registerCommand("pickety.showImpact",()=>pn(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(B.commands.registerCommand("pickety.showHealth",()=>ln(t.getConfig(),s.getImportGraph(),s.getWorkspaceContext()))),e.subscriptions.push(B.commands.registerCommand("pickety.goToRule",(o,i)=>wn(o,i))),e.subscriptions.push(B.commands.registerCommand("pickety.allowImport",(o,i,r)=>xn(o,i,r))),e.subscriptions.push(B.commands.registerCommand("pickety.init",()=>Qt(n,()=>t.reload())))}var z=R(require("vscode"));var Nn=R(require("path")),Ue=R(require("fs"));var Rn={modules:{app:"src/app/**",features:"src/features/**",shared:"src/shared/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"shared",imports:["app","features"],allow:!1,message:"Shared code should stay independent of app and feature modules."},{importer:"features",imports:"app",allow:!1,message:"Feature modules should not depend on the app layer."}]}}};var En={modules:{domain:"src/domain/**",application:"src/application/**",ports:"src/ports/**",adapters:"src/adapters/**",infrastructure:"src/infrastructure/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"domain",imports:["application","ports","adapters","infrastructure"],allow:!1,message:"Domain should not depend on outer layers."},{importer:"application",imports:["adapters","infrastructure"],allow:!1,message:"Application should not depend on adapters or infrastructure."},{importer:"ports",imports:["adapters","infrastructure"],allow:!1,message:"Ports should remain independent of adapters and infrastructure."},{importer:"adapters",imports:"infrastructure",allow:!1,message:"Adapters should not depend on infrastructure."}]}}};var Tn={modules:{presentation:"src/presentation/**",application:"src/application/**",domain:"src/domain/**",infrastructure:"src/infrastructure/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"domain",imports:["application","presentation","infrastructure"],allow:!1,message:"Domain should not depend on outer layers."},{importer:"application",imports:["presentation","infrastructure"],allow:!1,message:"Application should not depend on presentation or infrastructure."},{importer:"presentation",imports:"infrastructure",allow:!1,message:"Presentation should not depend directly on infrastructure."}]}}};var An={hexagonal:En,"feature-modules":Rn,layered:Tn};function Mn(e){return An[e]}function Pn(){return Object.keys(An)}function $n(e,t,s,n){if(typeof e.containedTo=="object"&&e.containedTo!==null){let o=e.containedTo;if(typeof o.path!="string"&&n.push({message:`Rule #${t}: "containedTo.path" is required and must be a string`,path:`${s}.containedTo.path`}),o.unless!==void 0)if(typeof o.unless!="object"||o.unless===null||Array.isArray(o.unless))n.push({message:`Rule #${t}: "containedTo.unless" must be an object`,path:`${s}.containedTo.unless`});else{let i=o.unless;Object.keys(i).length===0&&n.push({message:`Rule #${t}: "containedTo.unless" must not be empty`,path:`${s}.containedTo.unless`}),(Array.isArray(e.imports)?e.imports.filter(u=>typeof u=="string"):typeof e.imports=="string"?[e.imports]:[]).some(u=>u.match(/\$[\w-]+/))||n.push({message:`Rule #${t}: "containedTo.unless" requires "imports" to contain at least one $variable`,path:`${s}.containedTo.unless`});for(let[u,p]of Object.entries(i))u.startsWith("$")||n.push({message:`Rule #${t}: "containedTo.unless" key "${u}" must start with $`,path:`${s}.containedTo.unless`}),typeof p!="string"&&n.push({message:`Rule #${t}: "containedTo.unless.${u}" must be a string`,path:`${s}.containedTo.unless.${u}`})}}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 In(e,t,s){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 o=e["module-boundaries"];if(o===void 0){t.push({message:'"rules.module-boundaries" is required and must be an object',path:"rules.module-boundaries"});return}if(typeof o!="object"||o===null){t.push({message:'"rules.module-boundaries" must be an object',path:"rules.module-boundaries"});return}let i=o,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 c=[];return i.rules.forEach((a,u)=>{let p=`rules.module-boundaries.rules[${u}]`;if(typeof a!="object"||a===null){t.push({message:`Rule #${u} must be an object`,path:p});return}let l=a,f=typeof l.containedTo=="string"||typeof l.containedTo=="object"&&l.containedTo!==null;typeof l.importer!="string"&&!f&&t.push({message:`Rule #${u}: "importer" or "containedTo" is required`,path:p}),l.importer!==void 0&&typeof l.importer!="string"&&t.push({message:`Rule #${u}: "importer" must be a string`,path:`${p}.importer`});let d;if(typeof l.imports=="string")d=[l.imports];else if(Array.isArray(l.imports)){let b=l.imports.findIndex(x=>typeof x!="string");b!==-1?t.push({message:`Rule #${u}: "imports" entries must be strings`,path:`${p}.imports[${b}]`}):d=l.imports}else t.push({message:`Rule #${u}: "imports" is required and must be a string or string[]`,path:`${p}.imports`});l.allow!==void 0&&typeof l.allow!="boolean"&&t.push({message:`Rule #${u}: "allow" must be a boolean`,path:`${p}.allow`}),l.only!==void 0&&typeof l.only!="boolean"&&t.push({message:`Rule #${u}: "only" must be a boolean`,path:`${p}.only`}),l.containedTo!==void 0&&$n(l,u,p,t),l.message!==void 0&&typeof l.message!="string"&&t.push({message:`Rule #${u}: "message" must be a string`,path:`${p}.message`}),l.severity!==void 0&&l.severity!=="error"&&l.severity!=="warn"&&t.push({message:`Rule #${u}: "severity" must be "error" or "warn", got "${l.severity}"`,path:`${p}.severity`}),l.name!==void 0&&typeof l.name!="string"&&t.push({message:`Rule #${u}: "name" must be a string`,path:`${p}.name`}),l.group!==void 0&&typeof l.group!="string"&&t.push({message:`Rule #${u}: "group" must be a string`,path:`${p}.group`}),l.maxViolations!==void 0&&(typeof l.maxViolations!="number"||!Number.isInteger(l.maxViolations)||l.maxViolations<0)&&t.push({message:`Rule #${u}: "maxViolations" must be a non-negative integer`,path:`${p}.maxViolations`});let h;if(l.exports!==void 0)if(Array.isArray(l.exports)){let b=[];l.exports.forEach((x,T)=>{let m=On(x,`${p}.exports[${T}]`,t);m&&b.push(m)}),b.length>0&&(h=b)}else{let b=On(l.exports,`${p}.exports`,t);b&&(h=b)}if(d){let b=new Set(Kt(d)),x=(T,m,w)=>{let v=W(T).filter(y=>!b.has(y));if(v.length>0){let y=Array.from(new Set(v));s.push({message:`Rule #${u}: ${w} references variables not present in "imports": ${y.join(", ")}`,path:m})}};typeof l.importer=="string"&&x(l.importer,`${p}.importer`,'"importer"'),typeof l.containedTo=="string"?x(l.containedTo,`${p}.containedTo`,'"containedTo"'):typeof l.containedTo=="object"&&l.containedTo!==null&&typeof l.containedTo.path=="string"&&x(l.containedTo.path,`${p}.containedTo.path`,'"containedTo.path"')}if(!d)return;let g={imports:typeof l.imports=="string"?l.imports:d};typeof l.importer=="string"&&(g.importer=l.importer),typeof l.allow=="boolean"&&(g.allow=l.allow),typeof l.only=="boolean"&&(g.only=l.only),l.containedTo!==void 0&&(typeof l.containedTo=="string"||typeof l.containedTo=="object"&&l.containedTo!==null)&&(g.containedTo=l.containedTo),typeof l.message=="string"&&(g.message=l.message),(l.severity==="error"||l.severity==="warn")&&(g.severity=l.severity),typeof l.name=="string"&&(g.name=l.name),typeof l.group=="string"&&(g.group=l.group),typeof l.maxViolations=="number"&&Number.isInteger(l.maxViolations)&&l.maxViolations>=0&&(g.maxViolations=l.maxViolations),h&&(g.exports=h),c.push(g)}),{severity:r,rules:c}}function On(e,t,s){if(typeof e!="object"||e===null){s.push({message:`"${t}" must be an object`,path:t});return}let n=e,o=!1;if(typeof n.path!="string"&&(s.push({message:`"${t}.path" is required and must be a string`,path:`${t}.path`}),o=!0),typeof n.to!="string"&&(s.push({message:`"${t}.to" is required and must be a string`,path:`${t}.to`}),o=!0),n.message!==void 0&&typeof n.message!="string"&&(s.push({message:`"${t}.message" must be a string`,path:`${t}.message`}),o=!0),!o)return{path:n.path,to:n.to,message:typeof n.message=="string"?n.message:void 0}}function Cn(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={},o=[{key:"maxAfferentCoupling",label:"maxAfferentCoupling"},{key:"maxEfferentCoupling",label:"maxEfferentCoupling"},{key:"maxDepth",label:"maxDepth"}];for(let{key:i,label:r}of o){let c=s[i];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[i]=c)}if(s.maxInstability!==void 0){let i=s.maxInstability;typeof i!="number"||i<0||i>1?t.push({message:'"health.maxInstability" must be a number between 0 and 1',path:"health.maxInstability"}):n.maxInstability=i}return Object.keys(n).length>0?n:void 0}function Ln(e){let t=[],s=[];if(typeof e!="object"||e===null)return{ok:!1,errors:[{message:"Configuration must be a JSON object"}]};let n=e,o=yo(n.modules,t),i=In(n.rules,t,s),r=bo(n["boundary-diagrams"],t),c=Cn(n.health,t),a=vo(n.warnOnUntrackedImporters,t);return t.length>0||!o||!i?s.length>0?{ok:!1,errors:t,warnings:s}:{ok:!1,errors:t}:{ok:!0,config:{modules:o,rules:{"module-boundaries":i},warnOnUntrackedImporters:a,"boundary-diagrams":r,health:c},warnings:s.length>0?s:void 0}}function yo(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,o]of Object.entries(e))typeof o!="string"?t.push({message:`Module "${n}" pattern must be a string, got ${typeof o}`,path:`modules.${n}`}):s[n]=o;return s}function bo(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 vo(e,t){return e===void 0?!0:typeof e!="boolean"?(t.push({message:'"warnOnUntrackedImporters" must be a boolean',path:"warnOnUntrackedImporters"}),!0):e}function Dn(e){let t=Nn.join(e,N);if(!Ue.existsSync(t))return{ok:!0,config:void 0};try{let s=Ue.readFileSync(t,"utf-8"),n;try{n=_e(s)}catch(o){return{ok:!1,errors:[{message:`pickety.json is not valid JSONC: ${o instanceof Error?o.message:String(o)}`}]}}if(typeof n=="object"&&n!==null){let o=n;if(o.preset!==void 0&&typeof o.preset!="string")return{ok:!1,errors:[{message:'"preset" must be a string',path:"preset"}]};if(typeof o.preset=="string"){let i=Mn(o.preset);if(!i)return{ok:!1,errors:[{message:`Unknown preset "${o.preset}". Available presets: ${Pn().join(", ")}`,path:"preset"}]};n=So(i,o)}}return Ln(n)}catch(s){return{ok:!1,errors:[{message:`Failed to read pickety.json: ${s instanceof Error?s.message:String(s)}`}]}}}function Ge(e){return typeof e=="object"&&e!==null}function ko(e,t){return t===void 0?e:!Ge(t)||!e?t:{...e,...t}}function xt(e,t,s,n){s[n]!==void 0?e[n]=s[n]:t[n]!==void 0&&(e[n]=t[n])}function wo(e,t){return t===void 0?e:Ge(t)?{...e,...t}:t}function xo(e,t){if(t===void 0)return e;if(!Ge(t))return t;let s=t["module-boundaries"];if(!Ge(s))return t;let n={...e,...t},o=e["module-boundaries"],i={...o,...s},r=Array.isArray(o.rules)?o.rules:[];return s.rules===void 0?i.rules=r:Array.isArray(s.rules)?i.rules=[...r,...s.rules]:i.rules=s.rules,n["module-boundaries"]=i,n}function So(e,t){let s={...e,...t};s.modules=wo(e.modules,t.modules),s.rules=xo(e.rules,t.rules);let n=e;return xt(s,n,t,"warnOnUntrackedImporters"),xt(s,n,t,"boundary-diagrams"),s.health=ko(e.health,t.health),xt(s,n,t,"version"),s}var ze=R(require("fs")),X=R(require("path"));function jn(e,t){if(t<0)return[];let s=[],n;try{n=ze.readdirSync(e,{withFileTypes:!0})}catch{return s}for(let o of n)!oe.has(o.name)&&o.isFile()&&/^tsconfig(\..+)?\.json$/.test(o.name)&&s.push(X.join(e,o.name));for(let o of n)!oe.has(o.name)&&o.isDirectory()&&s.push(...jn(X.join(e,o.name),t-1));return s}function Vn(e){let t={},s=jn(e,4);for(let n of s)try{let o=ze.readFileSync(n,"utf-8"),r=_e(o).compilerOptions;if(!r?.paths)continue;let c=X.dirname(n),a=X.relative(e,c),u=r.baseUrl||".";for(let[p,l]of Object.entries(r.paths))if(Array.isArray(l)&&l.length>0){let f=l[0];t[p]||(t[p]=E(X.join(a,u,f)))}}catch{}return t}var qe=class{constructor(t){this.workspaceRoot=t;this.registerWatchers()}config;aliases={};_onConfigChanged=new z.EventEmitter;onConfigChanged=this._onConfigChanged.event;_onAliasesChanged=new z.EventEmitter;onAliasesChanged=this._onAliasesChanged.event;disposables=[];getConfig(){return this.config}getAliases(){return this.aliases}reload(){let t=Dn(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=z.workspace.createFileSystemWatcher(new z.RelativePattern(this.workspaceRoot,N));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=z.workspace.createFileSystemWatcher(new z.RelativePattern(this.workspaceRoot,"**/tsconfig*.json"));this.disposables.push(s);let n=o=>o.fsPath.split(/[\\/]/).some(r=>oe.has(r));s.onDidChange(o=>{n(o)||this.reloadAliases()}),s.onDidCreate(o=>{n(o)||this.reloadAliases()}),s.onDidDelete(o=>{n(o)||this.reloadAliases()})}dispose(){this.disposables.forEach(t=>t.dispose()),this._onConfigChanged.dispose(),this._onAliasesChanged.dispose()}};var Qe=R(require("vscode")),Fn=R(require("fs"));function St(e,t,s){let n=new Set,o=De(e,t,s),i=E(e);for(let{resolvedPath:r}of o)r&&r!==i&&n.add(r);return n}var Je=class{dependents=new Map;dependencies=new Map;updateFile(t,s){let n=this.dependencies.get(t);if(n)for(let o of n)this.dependents.get(o)?.delete(t);this.dependencies.set(t,new Set(s));for(let o of s)this.dependents.has(o)||this.dependents.set(o,new Set),this.dependents.get(o).add(t)}removeFile(t){let s=this.dependencies.get(t);if(s)for(let o of s)this.dependents.get(o)?.delete(t);this.dependencies.delete(t);let n=this.dependents.get(t);if(n)for(let o of n)this.dependencies.get(o)?.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 o=n.shift(),i=this.dependents.get(o);if(i)for(let r of i)!s.has(r)&&r!==t&&(s.add(r),n.push(r))}return s}getModuleSummary(t,s,n){let o=this.getDependents(t),i=this.getDependencies(t),r=new Set;for(let a of o){let u=D(a,s,n);u&&r.add(u)}let c=new Set;for(let a of i){let u=D(a,s,n);u&&c.add(u)}return{dependentCount:o.size,dependentModules:[...r],dependencyCount:i.size,dependencyModules:[...c]}}getModuleLevelGraph(t,s){let n=new Map;for(let[o,i]of this.dependencies){let r=D(o,t,s);if(r){n.has(r)||n.set(r,new Set);for(let c of i){let a=D(c,t,s);a&&a!==r&&n.get(r).add(a)}}}return n}clear(){this.dependents.clear(),this.dependencies.clear()}};var Xe=class e{constructor(t,s){this.workspaceRoot=t;this.configService=s;this.disposables.push(this.configService.onAliasesChanged(()=>{this.scanAndNotify()}))}knownFiles=new Set;importGraph=new Je;isLargeWorkspace=!1;static MAX_FILES_THRESHOLD=5e3;_onAnalysisReady=new Qe.EventEmitter;onAnalysisReady=this._onAnalysisReady.event;disposables=[];dispose(){this.disposables.forEach(t=>t.dispose()),this._onAnalysisReady.dispose()}getImportGraph(){return this.importGraph}getKnownFiles(){return this.knownFiles}checkIsLargeWorkspace(){return this.isLargeWorkspace}getWorkspaceContext(){return{root:this.workspaceRoot,knownFiles:this.knownFiles,aliases:this.configService.getAliases()}}async scan(){let t=await Qe.workspace.findFiles(Q,"**/node_modules/**");return this.knownFiles=new Set(t.map(s=>E(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 o=E(t);this.knownFiles.add(o);try{let i=St(o,s,n);this.importGraph.updateFile(o,i)}catch{}}removeFile(t){let s=E(t);this.knownFiles.delete(s),this.importGraph.removeFile(s)}ensureGraphReady(t){if(!this.isLargeWorkspace){for(let s of this.knownFiles)if(!this.importGraph.getDependencies(s).size)try{let n=Fn.readFileSync(s,"utf-8"),o=St(s,n,t);this.importGraph.updateFile(s,o)}catch{continue}}}computeCycles(t,s){if(this.isLargeWorkspace)return[];this.ensureGraphReady(s);let n=this.importGraph.getModuleLevelGraph(t.modules,this.workspaceRoot);return Yt(n)}computeHealthViolations(t,s){if(!t.health||this.isLargeWorkspace)return[];this.ensureGraphReady(s);let n=ae(this.importGraph,t.modules,s);return sn(n,t.health)}};var fe=R(require("vscode")),Ze=class{item;constructor(t){this.item=fe.window.createStatusBarItem(fe.StatusBarAlignment.Right,100),this.item.command="pickety.refresh",t.subscriptions.push(this.item)}update(t,s){if(!t){this.item.text="",this.item.tooltip="",this.item.backgroundColor=void 0,this.item.hide();return}let n=0;s.forEach((o,i)=>{n+=i.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 fe.ThemeColor("statusBarItem.errorBackground"),this.item.show()):(this.item.text="$(check) Pickety",this.item.tooltip="Architectural boundaries are secure. Click to refresh.",this.item.backgroundColor=void 0,this.item.show())}dispose(){this.item.dispose()}};var Rt=R(require("vscode")),de=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(!Rt.env.isTelemetryEnabled)return;let n=new Date().toISOString(),o=JSON.stringify({event:t,timestamp:n,...s});this.outputChannel&&this.outputChannel.appendLine(`[Telemetry] ${o}`)}logError(t,s){if(!Rt.env.isTelemetryEnabled)return;let n=t instanceof Error?t.message:t,o=t instanceof Error?t.stack:void 0;this.logEvent("error",{message:n,context:s||"unknown",stack:o||"no stack trace"})}};var $=R(require("vscode"));var Ye=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(o=>{let i=new $.Range(o.line,o.character,o.line,o.character+o.length),r=o.severity==="error"?$.DiagnosticSeverity.Error:o.severity==="info"?$.DiagnosticSeverity.Information:$.DiagnosticSeverity.Warning,c=new $.Diagnostic(i,o.message,r);return c.source="pickety",o.ruleName&&(c.code={value:o.ruleName,target:$.Uri.parse(`https://github.com/DanielSerio/pickety/blob/main/docs/rules.md#${o.ruleName}`)}),c._picketyMetadata={sourceModule:o.sourceModule,targetModule:o.targetModule},c});this.collection.set(t,n)}setCircularDiagnostics(t,s){let n=s.map(o=>{let i=o.join(" -> "),r=new $.Diagnostic(new $.Range(0,0,0,100),`Circular dependency detected: ${i}`,$.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(o=>{let i=H(o.metric,o.value),r=H(o.metric,o.threshold),c=new $.Diagnostic(new $.Range(0,0,0,100),`Module "${o.moduleName}" has ${o.metric} of ${i} (max: ${r})`,$.DiagnosticSeverity.Warning);return c.source="pickety",c.code=e.HEALTH_TAG,c});this.updateConfigDiagnostics(t,e.HEALTH_TAG,n)}updateConfigDiagnostics(t,s,n){let o=(this.collection.get(t)||[]).filter(i=>(typeof i.code=="object"?i.code?.value:i.code)!==s);this.collection.set(t,[...o,...n])}clear(){this.collection.clear()}delete(t){this.collection.delete(t)}dispose(){this.collection.dispose()}};var te=R(require("vscode"));var At=R(require("path"));function _n(e){return e.isOnly?Ro(e):Eo(e)}function Et(e,t,s,n){let o=e.includes("/")?n:s;return xe(e,o,t)}function Ro(e){let{rule:t,importsPattern:s,variables:n,effectiveImporter:o,ruleSeverity:i,ruleName:r,ruleLabel:c,ruleGroup:a,ctx:u}=e,p=Et(s,n,u.targetModule,u.targetRelativePath);if(!p||Po(t,p))return;let l=Y(o,n,p);if(!F(u.sourceModule,u.sourceRelativePath,l)){if(Tt(t,u,p))return;let d=t.message||`Module "${u.sourceModule}" is not allowed to import from "${u.targetModule}" (contained to "${l}")`;return Z(u.filePath,u.importStmt,r,c,d,i,u.sourceModule,u.targetModule,a)}}function Eo(e){let{rule:t,importsPattern:s,variables:n,allow:o,effectiveImporter:i,ruleSeverity:r,ruleName:c,ruleLabel:a,ruleGroup:u,ctx:p}=e,l=Et(i,n,p.sourceModule,p.sourceRelativePath);if(l)if(o){let f=Y(s,n,"*"),d=Y(s,n,l),h=F(p.targetModule,p.targetRelativePath,f),g=F(p.targetModule,p.targetRelativePath,d);if(h&&!g){let b=t.message||`Import must match scoped pattern "${d}"`;return Z(p.filePath,p.importStmt,c,a,b,r,p.sourceModule,p.targetModule,u)}}else{let f=Y(s,n,l);if(F(p.targetModule,p.targetRelativePath,f)){let h=t.message||`Module "${p.sourceModule}" cannot import from "${p.targetModule}"`;return Z(p.filePath,p.importStmt,c,a,h,r,p.sourceModule,p.targetModule,u)}}}function To(e){return e?Array.isArray(e)?e:[e]:[]}var Wn=new WeakMap;function Ao(e){let t=Wn.get(e);if(t)return t;let n=To(e.exports).map(o=>({entry:o,pathVars:W(o.path),toVars:W(o.to)}));return Wn.set(e,n),n}function Tt(e,t,s){let n=Ao(e);if(n.length===0)return!1;for(let{entry:o,pathVars:i,toVars:r}of n){let c=i.length>0?Bn(o.path,i,s,t.targetModule,t.targetRelativePath):{};if(i.length>0&&!c)continue;let a=r.length>0?Bn(o.to,r,void 0,t.sourceModule,t.sourceRelativePath):{};if(r.length>0&&!a)continue;let u=Mo(c??{},a??{});if(!u)continue;let p=i.length>0?Y(o.path,i,u):o.path;if(!F(t.targetModule,t.targetRelativePath,p))continue;let l=r.length>0?Y(o.to,r,u):o.to;if(F(t.sourceModule,t.sourceRelativePath,l))return!0}return!1}function Bn(e,t,s,n,o){return s&&t.every(i=>s[i]!==void 0)?s:Et(e,t,n,o)}function Mo(e,t){let s={...e};for(let[n,o]of Object.entries(t)){if(s[n]!==void 0&&s[n]!==o)return;s[n]=o}return s}function Po(e,t){let s=ut(e);if(s&&s.unless){let n=Object.entries(s.unless);return n.length>0&&n.every(([o,i])=>t[o]===i)}return!1}function Hn(e,t){let{rule:s,allow:n,severity:o,name:i,label:r,group:c,effectiveImporter:a,isOnly:u,importPatterns:p}=e;for(let l of p){let f=W(u?l:a);if(f.length>0){let g=_n({rule:s,importsPattern:l,variables:f,isOnly:u,allow:n,effectiveImporter:a,ruleSeverity:o,ruleName:i,ruleLabel:r,ruleGroup:c,ctx:t});if(g)return g;continue}let d=F(t.sourceModule,t.sourceRelativePath,a),h=F(t.targetModule,t.targetRelativePath,l);if(u){if(h&&!d){if(Tt(s,t))return;let g=s.message||(s.containedTo?`Import is restricted: "${t.targetModule}" is contained to "${a}"`:`Module "${t.targetModule}" can only be imported by "${a}"`);return Z(t.filePath,t.importStmt,i,r,g,o,t.sourceModule,t.targetModule,c)}}else if(d&&h&&!n){let g=s.message||`Module "${t.sourceModule}" cannot import from "${t.targetModule}"`;return Z(t.filePath,t.importStmt,i,r,g,o,t.sourceModule,t.targetModule,c)}}}function Gn(e,t,s,n){let o=[],{modules:i}=s,{severity:r,rules:c}=s.rules["module-boundaries"],{root:a}=n,u=s.warnOnUntrackedImporters??!0,p=c.map((h,g)=>Zt(h,g,r)),l=D(e,i,a);if(!l)return u&&o.push({file:e,line:0,character:0,length:1,message:"This file is not covered by any declared module. Import rules will not be enforced here.",severity:"info"}),o;let f=E(At.relative(a,e)),d=De(e,t,n);for(let{statement:h,resolvedPath:g}of d){let b=D(g,i,a);if(!b)continue;let x=E(At.relative(a,g)),T={sourceModule:l,sourceRelativePath:f,targetModule:b,targetRelativePath:x,filePath:e,importStmt:h};for(let m of p){let w=Hn(m,T);w&&o.push(w)}}return o}function Un(e,t){let s=t.rules["module-boundaries"].rules,n=new Map;if(s.forEach((i,r)=>{if(i.maxViolations!==void 0){let c=i.name??`rule[${r}]`;n.set(c,i.maxViolations)}}),n.size===0)return e;let o=new Map;for(let i of e)i.ruleName&&n.has(i.ruleName)&&o.set(i.ruleName,(o.get(i.ruleName)??0)+1);return e.map(i=>{if(!i.ruleName||!n.has(i.ruleName))return i;let r=o.get(i.ruleName)??0,c=n.get(i.ruleName),a=r<=c?"warn":"error";return a===i.severity?i:{...i,severity:a}})}var O=R(require("vscode")),Mt=R(require("path"));function zn(e,t,s,n){s.appendLine("Pickety: Configuration error(s) found:");let o=O.Uri.file(Mt.join(t,N)),i=e.map(r=>{s.appendLine(` - ${r.message}${r.path?` (at ${r.path})`:""}`);let c=new O.Range(0,0,0,100),a=new O.Diagnostic(c,r.message,O.DiagnosticSeverity.Error);return a.source="pickety",r.path&&(a.code=r.path),a});n.set(o,i),O.window.showErrorMessage("Pickety: Configuration error. Check the Problems panel or Output channel for details.")}function Pt(e,t,s,n){s.appendLine("Pickety: Configuration warning(s) found:");let o=O.Uri.file(Mt.join(t,N)),i=e.map(c=>{s.appendLine(` - ${c.message}${c.path?` (at ${c.path})`:""}`);let a=new O.Range(0,0,0,100),u=new O.Diagnostic(a,c.message,O.DiagnosticSeverity.Warning);return u.source="pickety",c.path&&(u.code=c.path),u}),r=n.get(o)||[];n.set(o,[...r,...i])}var Ke=class{constructor(t,s,n,o,i,r,c){this.context=t;this.configService=s;this.analysisService=n;this.diagnosticManager=o;this.statusBar=i;this.outputChannel=r;this.workspaceRoot=c;this.registerEventListeners()}telemetry=de.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"),t.warnings&&t.warnings.length>0&&Pt(t.warnings,this.workspaceRoot,this.outputChannel,this.diagnosticManager.getCollection());try{let n=je(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||(zn(t.errors,this.workspaceRoot,this.outputChannel,this.diagnosticManager.getCollection()),t.warnings&&t.warnings.length>0&&Pt(t.warnings,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 te.workspace.textDocuments)this.isSourceFile(r)&&s.push({uri:r.uri,violations:this.checkDocument(r,t)});let n=s.flatMap(r=>r.violations),o=Un(n,t),i=new Map;for(let r of o){let c=E(r.file),a=i.get(c);a?a.push(r):i.set(c,[r])}for(let r of s){let c=E(r.uri.fsPath);this.diagnosticManager.setViolations(r.uri,i.get(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 Gn(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=te.Uri.file(ie(this.workspaceRoot));this.diagnosticManager.setCircularDiagnostics(n,s)}checkHealthThresholds(t){let s=this.analysisService.computeHealthViolations(t,this.analysisService.getWorkspaceContext()),n=te.Uri.file(ie(this.workspaceRoot));this.diagnosticManager.setHealthDiagnostics(n,s)}registerEventListeners(){this.disposables.push(te.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=te.workspace.createFileSystemWatcher(Q);this.disposables.push(t),t.onDidCreate(s=>{this.analysisService.getKnownFiles().add(E(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 he=R(require("vscode")),et=class{constructor(t){this.workspaceRoot=t}provideCodeActions(t,s,n){let o=[];for(let i of n.diagnostics)if(i.source==="pickety"&&i.code){let r=typeof i.code=="object"?i.code.value:i.code,c=new he.CodeAction(`Go to Pickety rule: ${r}`,he.CodeActionKind.QuickFix);c.command={command:"pickety.goToRule",title:"Go to Rule",arguments:[this.workspaceRoot,r]},o.push(c);let a=i._picketyMetadata;if(a&&a.sourceModule&&a.targetModule){let u=new he.CodeAction(`Allow imports from '${a.targetModule}' in '${a.sourceModule}'`,he.CodeActionKind.QuickFix);u.command={command:"pickety.allowImport",title:"Allow Import",arguments:[this.workspaceRoot,a.sourceModule,a.targetModule]},o.push(u)}}return o}};var ge=R(require("vscode"));var tt=class{constructor(t,s,n){this.importGraph=t;this.workspaceRoot=s;this.configRef=n}_onDidChangeCodeLenses=new ge.EventEmitter;onDidChangeCodeLenses=this._onDidChangeCodeLenses.event;refresh(){this._onDidChangeCodeLenses.fire()}provideCodeLenses(t){let s=this.configRef.config;if(!s)return[];let n=E(t.uri.fsPath),o=this.importGraph.getModuleSummary(n,s.modules,this.workspaceRoot);if(o.dependentCount===0&&o.dependencyCount===0)return[];let i=[];if(o.dependentCount>0){let a=o.dependentModules.length===1?"1 module":`${o.dependentModules.length} modules`;i.push(`${o.dependentCount} dependent${o.dependentCount===1?"":"s"} (${a})`)}if(o.dependencyCount>0){let a=o.dependencyModules.length===1?"1 module":`${o.dependencyModules.length} modules`;i.push(`${o.dependencyCount} dependenc${o.dependencyCount===1?"y":"ies"} (${a})`)}let r=new ge.Range(0,0,0,0);return[new ge.CodeLens(r,{title:i.join(" | "),command:"pickety.showImpact",tooltip:"Show full impact analysis for this file"})]}dispose(){this._onDidChangeCodeLenses.dispose()}};var $o=[];async function Oo(e){let t=de.getInstance();t.logEvent("extension_activate");let s=_.window.createOutputChannel("Pickety");e.subscriptions.push(s),t.setOutputChannel(s);let n=_.workspace.workspaceFolders?.[0]?.uri.fsPath;if(!n){s.appendLine("Pickety: No workspace root found.");return}s.appendLine(`Pickety: Extension activated for workspace: ${n}`);let o=new qe(n);e.subscriptions.push(o);let i=new Xe(n,o);e.subscriptions.push(i);let r=new Ze(e);e.subscriptions.push(r);let c=_.languages.createDiagnosticCollection("pickety");e.subscriptions.push(c);let a=new Ye(c);e.subscriptions.push(a);let u=new et(n);e.subscriptions.push(_.languages.registerCodeActionsProvider({scheme:"file",language:"*"},u,{providedCodeActionKinds:[_.CodeActionKind.QuickFix]}));let p=new tt(i.getImportGraph(),n,{config:void 0});e.subscriptions.push(p);let l=new Ke(e,o,i,a,r,s,n);l.setCodeLensProvider(p),e.subscriptions.push(l),p.configRef=l.configRef,e.subscriptions.push(_.languages.registerCodeLensProvider({scheme:"file",pattern:Q},p)),Sn(e,o,i,n),o.onConfigChanged(f=>l.handleConfigResult(f)),i.onAnalysisReady(()=>{s.appendLine(`Pickety: Analysis complete. Found ${i.getKnownFiles().size} files.`),l.analyzeOpenEditors()}),o.reload(),o.reloadAliases()}function Io(){$o.forEach(e=>e.dispose())}0&&(module.exports={activate,deactivate});
|
|
152
|
+
`}function Te(e,t){return`\r
|
|
153
|
+
`.indexOf(e.charAt(t))!==-1}var Me;(function(e){e.DEFAULT={allowTrailingComma:!1}})(Me||(Me={}));function vn(e,t=[],i=Me.DEFAULT){let n=null,s=[],o=[];function r(c){Array.isArray(s)?s.push(c):n!==null&&(s[n]=c)}return kt(e,{onObjectBegin:()=>{let c={};r(c),o.push(s),s=c,n=null},onObjectProperty:c=>{n=c},onObjectEnd:()=>{s=o.pop()},onArrayBegin:()=>{let c=[];r(c),o.push(s),s=c,n=null},onArrayEnd:()=>{s=o.pop()},onLiteralValue:r,onError:(c,l,u)=>{t.push({error:c,offset:l,length:u})}},i),s[0]}function _e(e,t=[],i=Me.DEFAULT){let n={type:"array",offset:-1,length:-1,children:[],parent:void 0};function s(c){n.type==="property"&&(n.length=c-n.offset,n=n.parent)}function o(c){return n.children.push(c),c}kt(e,{onObjectBegin:c=>{n=o({type:"object",offset:c,length:-1,parent:n,children:[]})},onObjectProperty:(c,l,u)=>{n=o({type:"property",offset:l,length:-1,parent:n,children:[]}),n.children.push({type:"string",value:c,offset:l,length:u,parent:n})},onObjectEnd:(c,l)=>{s(c+l),n.length=c+l-n.offset,n=n.parent,s(c+l)},onArrayBegin:(c,l)=>{n=o({type:"array",offset:c,length:-1,parent:n,children:[]})},onArrayEnd:(c,l)=>{n.length=c+l-n.offset,n=n.parent,s(c+l)},onLiteralValue:(c,l,u)=>{o({type:Rs(c),offset:l,length:u,parent:n,value:c}),s(l+u)},onSeparator:(c,l,u)=>{n.type==="property"&&(c===":"?n.colonOffset=l:c===","&&s(l))},onError:(c,l,u)=>{t.push({error:c,offset:l,length:u})}},i);let a=n.children[0];return a&&delete a.parent,a}function Ae(e,t){if(!e)return;let i=e;for(let n of t)if(typeof n=="string"){if(i.type!=="object"||!Array.isArray(i.children))return;let s=!1;for(let o of i.children)if(Array.isArray(o.children)&&o.children[0].value===n&&o.children.length===2){i=o.children[1],s=!0;break}if(!s)return}else{let s=n;if(i.type!=="array"||s<0||!Array.isArray(i.children)||s>=i.children.length)return;i=i.children[s]}return i}function kt(e,t,i=Me.DEFAULT){let n=Pe(e,!1),s=[],o=0;function r(R){return R?()=>o===0&&R(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function a(R){return R?T=>o===0&&R(T,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function c(R){return R?T=>o===0&&R(T,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>s.slice()):()=>!0}function l(R){return R?()=>{o>0?o++:R(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>s.slice())===!1&&(o=1)}:()=>!0}function u(R){return R?()=>{o>0&&o--,o===0&&R(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter())}:()=>!0}let p=l(t.onObjectBegin),f=c(t.onObjectProperty),d=u(t.onObjectEnd),g=l(t.onArrayBegin),h=u(t.onArrayEnd),k=c(t.onLiteralValue),P=a(t.onSeparator),O=r(t.onComment),y=a(t.onError),w=i&&i.disallowComments,v=i&&i.allowTrailingComma;function b(){for(;;){let R=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(R){case 12:case 13:w?m(10):O();break;case 16:m(1);break;case 15:case 14:break;default:return R}}}function m(R,T=[],It=[]){if(y(R),T.length+It.length>0){let Ce=n.getToken();for(;Ce!==17;){if(T.indexOf(Ce)!==-1){b();break}else if(It.indexOf(Ce)!==-1)break;Ce=b()}}}function H(R){let T=n.getTokenValue();return R?k(T):(f(T),s.push(T)),b(),!0}function st(){switch(n.getToken()){case 11:let R=n.getTokenValue(),T=Number(R);isNaN(T)&&(m(2),T=0),k(T);break;case 7:k(null);break;case 8:k(!0);break;case 9:k(!1);break;default:return!1}return b(),!0}function ot(){return n.getToken()!==10?(m(3,[],[2,5]),!1):(H(!1),n.getToken()===6?(P(":"),b(),rt()||m(4,[],[2,5])):m(5,[],[2,5]),s.pop(),!0)}function Yn(){p(),b();let R=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(R||m(4,[],[]),P(","),b(),n.getToken()===2&&v)break}else R&&m(6,[],[]);ot()||m(4,[],[2,5]),R=!0}return d(),n.getToken()!==2?m(7,[2],[]):b(),!0}function Qn(){g(),b();let R=!0,T=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(T||m(4,[],[]),P(","),b(),n.getToken()===4&&v)break}else T&&m(6,[],[]);R?(s.push(0),R=!1):s[s.length-1]++,rt()||m(4,[],[4,5]),T=!0}return h(),R||s.pop(),n.getToken()!==4?m(8,[4],[]):b(),!0}function rt(){switch(n.getToken()){case 3:return Qn();case 1:return Yn();case 10:return H(!0);default:return st()}}return b(),n.getToken()===17?i.allowEmptyContent?!0:(m(4,[],[]),!1):rt()?(n.getToken()!==17&&m(9,[],[]),!0):(m(4,[],[]),!1)}function Rs(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 bn(e,t,i,n){let s=t.slice(),r=_e(e,[]),a,c;for(;s.length>0&&(c=s.pop(),a=Ae(r,s),a===void 0&&i!==void 0);)typeof c=="string"?i={[c]:i}:i=[i];if(a)if(a.type==="object"&&typeof c=="string"&&Array.isArray(a.children)){let l=Ae(a,[c]);if(l!==void 0)if(i===void 0){if(!l.parent)throw new Error("Malformed AST");let u=a.children.indexOf(l.parent),p,f=l.parent.offset+l.parent.length;if(u>0){let d=a.children[u-1];p=d.offset+d.length}else p=a.offset+1,a.children.length>1&&(f=a.children[1].offset);return ie(e,{offset:p,length:f-p,content:""},n)}else return ie(e,{offset:l.offset,length:l.length,content:JSON.stringify(i)},n);else{if(i===void 0)return[];let u=`${JSON.stringify(c)}: ${JSON.stringify(i)}`,p=n.getInsertionIndex?n.getInsertionIndex(a.children.map(d=>d.children[0].value)):a.children.length,f;if(p>0){let d=a.children[p-1];f={offset:d.offset+d.length,length:0,content:","+u}}else a.children.length===0?f={offset:a.offset+1,length:0,content:u}:f={offset:a.offset+1,length:0,content:u+","};return ie(e,f,n)}}else if(a.type==="array"&&typeof c=="number"&&Array.isArray(a.children)){let l=c;if(l===-1){let u=`${JSON.stringify(i)}`,p;if(a.children.length===0)p={offset:a.offset+1,length:0,content:u};else{let f=a.children[a.children.length-1];p={offset:f.offset+f.length,length:0,content:","+u}}return ie(e,p,n)}else if(i===void 0&&a.children.length>=0){let u=c,p=a.children[u],f;if(a.children.length===1)f={offset:a.offset+1,length:a.length-2,content:""};else if(a.children.length-1===u){let d=a.children[u-1],g=d.offset+d.length,h=a.offset+a.length;f={offset:g,length:h-2-g,content:""}}else f={offset:p.offset,length:a.children[u+1].offset-p.offset,content:""};return ie(e,f,n)}else if(i!==void 0){let u,p=`${JSON.stringify(i)}`;if(!n.isArrayInsertion&&a.children.length>c){let f=a.children[c];u={offset:f.offset,length:f.length,content:p}}else if(a.children.length===0||c===0)u={offset:a.offset+1,length:0,content:a.children.length===0?p:p+","};else{let f=c>a.children.length?a.children.length:c,d=a.children[f-1];u={offset:d.offset+d.length,length:0,content:","+p}}return ie(e,u,n)}else throw new Error(`Can not ${i===void 0?"remove":n.isArrayInsertion?"insert":"modify"} Array index ${l} as length is not sufficient`)}else throw new Error(`Can not add ${typeof c!="number"?"index":"property"} to parent of type ${a.type}`);else{if(i===void 0)throw new Error("Can not delete in empty document");return ie(e,{offset:r?r.offset:0,length:r?r.length:0,content:JSON.stringify(i)},n)}}function ie(e,t,i){if(!i.formattingOptions)return[t];let n=wt(e,t),s=t.offset,o=t.offset+t.content.length;if(t.length===0||t.content.length===0){for(;s>0&&!Te(n,s-1);)s--;for(;o<n.length&&!Te(n,o);)o++}let r=bt(n,{offset:s,length:o-s},{...i.formattingOptions,keepLines:!1});for(let c=r.length-1;c>=0;c--){let l=r[c];n=wt(n,l),s=Math.min(s,l.offset),o=Math.max(o,l.offset+l.length),o+=l.content.length-l.length}let a=e.length-(n.length-o)-s;return[{offset:s,length:a,content:n.substring(s,o)}]}function wt(e,t){return e.substring(0,t.offset)+t.content+e.substring(t.offset+t.length)}var kn;(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"})(kn||(kn={}));var wn;(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"})(wn||(wn={}));var Ge=vn,Sn=_e,He=Ae;var xn;(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"})(xn||(xn={}));function Rn(e,t,i,n){return bn(e,t,i,n)}async function En(e,t){let i=St.join(e,N);if(!Rt.existsSync(i))return;let n=await M.workspace.openTextDocument(M.Uri.file(i)),s=await M.window.showTextDocument(n),o=n.getText(),r=Sn(o);if(!r)return;let a=-1,c=He(r,["rules","module-boundaries","rules"]);if(c&&c.children)if(typeof t=="string"&&!t.startsWith("rule[")){for(let l of c.children){let u=He(l,["name"]);if(u&&u.value===t){a=l.offset;break}}if(a===-1)for(let l of c.children){let u=He(l,["importer"]);if(u&&u.value===t){a=u.offset;break}}}else{let l=String(t).match(/rule\[(\d+)\]/),u=l?parseInt(l[1]):-1;u!==-1&&c.children[u]&&(a=c.children[u].offset)}if(a!==-1){let l=n.positionAt(a);s.selection=new M.Selection(l,l),s.revealRange(new M.Range(l,l),M.TextEditorRevealType.InCenter)}}async function Pn(e,t,i){let n=St.join(e,N);if(!Rt.existsSync(n))return;let s=await M.workspace.openTextDocument(M.Uri.file(n)),o=s.getText(),r=Rn(o,["rules","module-boundaries","rules",-1],{importer:t,imports:i,allow:!0,name:`allow-${t}-to-${i}`},{formattingOptions:{insertSpaces:!0,tabSize:2}}),a=new M.WorkspaceEdit;for(let c of r)a.replace(s.uri,new M.Range(s.positionAt(c.offset),s.positionAt(c.offset+c.length)),c.content);await M.workspace.applyEdit(a),await s.save(),M.window.showInformationMessage(`Added exception: Allow '${i}' in '${t}'`)}function Tn(e){let{context:t,configService:i,analysisService:n,documentValidator:s,workspaceRoot:o}=e;t.subscriptions.push(_.commands.registerCommand("pickety.refresh",async()=>{i.reload(),i.reloadAliases(),await s.analyzeWorkspace(),_.window.showInformationMessage("Pickety: Workspace analysis refreshed")})),t.subscriptions.push(_.commands.registerCommand("pickety.generateDiagram",()=>un(i.getConfig(),n.getImportGraph(),n.getWorkspaceContext()))),t.subscriptions.push(_.commands.registerCommand("pickety.showImpact",()=>hn(i.getConfig(),n.getImportGraph(),n.getWorkspaceContext()))),t.subscriptions.push(_.commands.registerCommand("pickety.showHealth",()=>dn(i.getConfig(),n.getImportGraph(),n.getWorkspaceContext()))),t.subscriptions.push(_.commands.registerCommand("pickety.goToRule",(r,a)=>En(r,a))),t.subscriptions.push(_.commands.registerCommand("pickety.allowImport",(r,a,c)=>Pn(r,a,c))),t.subscriptions.push(_.commands.registerCommand("pickety.init",()=>Kt(o,()=>i.reload())))}var q=S(require("vscode"));var Fn=S(require("path")),Ue=S(require("fs"));var Mn={modules:{app:"src/app/**",features:"src/features/**",shared:"src/shared/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"shared",imports:["app","features"],allow:!1,message:"Shared code should stay independent of app and feature modules."},{importer:"features",imports:"app",allow:!1,message:"Feature modules should not depend on the app layer."}]}}};var An={modules:{domain:"src/domain/**",application:"src/application/**",ports:"src/ports/**",adapters:"src/adapters/**",infrastructure:"src/infrastructure/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"domain",imports:["application","ports","adapters","infrastructure"],allow:!1,message:"Domain should not depend on outer layers."},{importer:"application",imports:["adapters","infrastructure"],allow:!1,message:"Application should not depend on adapters or infrastructure."},{importer:"ports",imports:["adapters","infrastructure"],allow:!1,message:"Ports should remain independent of adapters and infrastructure."},{importer:"adapters",imports:"infrastructure",allow:!1,message:"Adapters should not depend on infrastructure."}]}}};var Cn={modules:{presentation:"src/presentation/**",application:"src/application/**",domain:"src/domain/**",infrastructure:"src/infrastructure/**"},rules:{"module-boundaries":{severity:"error",rules:[{importer:"domain",imports:["application","presentation","infrastructure"],allow:!1,message:"Domain should not depend on outer layers."},{importer:"application",imports:["presentation","infrastructure"],allow:!1,message:"Application should not depend on presentation or infrastructure."},{importer:"presentation",imports:"infrastructure",allow:!1,message:"Presentation should not depend directly on infrastructure."}]}}};var On={hexagonal:An,"feature-modules":Mn,layered:Cn};function $n(e){return On[e]}function In(){return Object.keys(On)}function Dn(e){let{ruleRecord:t,index:i,rulePath:n,errors:s}=e;if(typeof t.containedTo=="object"&&t.containedTo!==null){let o=t.containedTo;if(typeof o.path!="string"&&s.push({message:`Rule #${i}: "containedTo.path" is required and must be a string`,path:`${n}.containedTo.path`}),o.unless!==void 0)if(typeof o.unless!="object"||o.unless===null||Array.isArray(o.unless))s.push({message:`Rule #${i}: "containedTo.unless" must be an object`,path:`${n}.containedTo.unless`});else{let r=o.unless;Object.keys(r).length===0&&s.push({message:`Rule #${i}: "containedTo.unless" must not be empty`,path:`${n}.containedTo.unless`}),(Array.isArray(t.imports)?t.imports.filter(u=>typeof u=="string"):typeof t.imports=="string"?[t.imports]:[]).some(u=>u.match(/\$[\w-]+/))||s.push({message:`Rule #${i}: "containedTo.unless" requires "imports" to contain at least one $variable`,path:`${n}.containedTo.unless`});for(let[u,p]of Object.entries(r))u.startsWith("$")||s.push({message:`Rule #${i}: "containedTo.unless" key "${u}" must start with $`,path:`${n}.containedTo.unless`}),typeof p!="string"&&s.push({message:`Rule #${i}: "containedTo.unless.${u}" must be a string`,path:`${n}.containedTo.unless.${u}`})}}else typeof t.containedTo!="string"&&s.push({message:`Rule #${i}: "containedTo" must be a string or object with a "path" property`,path:`${n}.containedTo`})}function Nn(e,t,i){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 s=e["module-boundaries"];if(s===void 0){t.push({message:'"rules.module-boundaries" is required and must be an object',path:"rules.module-boundaries"});return}if(typeof s!="object"||s===null){t.push({message:'"rules.module-boundaries" must be an object',path:"rules.module-boundaries"});return}let o=s,r="error";if(o.severity!==void 0&&(o.severity!=="error"&&o.severity!=="warn"?t.push({message:`"rules.module-boundaries.severity" must be "error" or "warn", got "${o.severity}"`,path:"rules.module-boundaries.severity"}):r=o.severity),o.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(o.rules)){t.push({message:'"rules.module-boundaries.rules" must be an array',path:"rules.module-boundaries.rules"});return}let a=[];return o.rules.forEach((c,l)=>{let u=Ts({rule:c,index:l,errors:t,warnings:i});u&&a.push(u)}),{severity:r,rules:a}}function Ts(e){let{rule:t,index:i,errors:n,warnings:s}=e,o=`rules.module-boundaries.rules[${i}]`;if(typeof t!="object"||t===null){n.push({message:`Rule #${i} must be an object`,path:o});return}let r=t,a=Ms({r,index:i,rulePath:o,errors:n}),c=As({r,index:i,rulePath:o,errors:n});if(!c)return;let l={imports:c};a!==void 0&&(l.importer=a),typeof r.allow=="boolean"&&(l.allow=r.allow),typeof r.only=="boolean"&&(l.only=r.only),r.containedTo!==void 0&&(Dn({ruleRecord:r,index:i,rulePath:o,errors:n}),l.containedTo=r.containedTo),Cs({r,index:i,rulePath:o,errors:n,result:l});let u=Os(r,o,n);return u&&(l.exports=u),$s({r,index:i,rulePath:o,imports:c,warnings:s}),l}function Ms(e){let{r:t,index:i,rulePath:n,errors:s}=e,o=typeof t.containedTo=="string"||typeof t.containedTo=="object"&&t.containedTo!==null;if(typeof t.importer!="string"&&!o&&s.push({message:`Rule #${i}: "importer" or "containedTo" is required`,path:n}),t.importer!==void 0){if(typeof t.importer!="string"){s.push({message:`Rule #${i}: "importer" must be a string`,path:`${n}.importer`});return}return t.importer}}function As(e){let{r:t,index:i,rulePath:n,errors:s}=e;if(typeof t.imports=="string")return t.imports;if(Array.isArray(t.imports)){let o=t.imports.findIndex(r=>typeof r!="string");if(o!==-1){s.push({message:`Rule #${i}: "imports" entries must be strings`,path:`${n}.imports[${o}]`});return}return t.imports}s.push({message:`Rule #${i}: "imports" is required and must be a string or string[]`,path:`${n}.imports`})}function Cs(e){let{r:t,index:i,rulePath:n,errors:s,result:o}=e;t.allow!==void 0&&typeof t.allow!="boolean"&&s.push({message:`Rule #${i}: "allow" must be a boolean`,path:`${n}.allow`}),t.only!==void 0&&typeof t.only!="boolean"&&s.push({message:`Rule #${i}: "only" must be a boolean`,path:`${n}.only`}),t.message!==void 0&&(typeof t.message!="string"?s.push({message:`Rule #${i}: "message" must be a string`,path:`${n}.message`}):o.message=t.message),t.severity!==void 0&&(t.severity!=="error"&&t.severity!=="warn"?s.push({message:`Rule #${i}: "severity" must be "error" or "warn", got "${t.severity}"`,path:`${n}.severity`}):o.severity=t.severity),t.name!==void 0&&(typeof t.name!="string"?s.push({message:`Rule #${i}: "name" must be a string`,path:`${n}.name`}):o.name=t.name),t.group!==void 0&&(typeof t.group!="string"?s.push({message:`Rule #${i}: "group" must be a string`,path:`${n}.group`}):o.group=t.group),t.maxViolations!==void 0&&(typeof t.maxViolations!="number"||!Number.isInteger(t.maxViolations)||t.maxViolations<0?s.push({message:`Rule #${i}: "maxViolations" must be a non-negative integer`,path:`${n}.maxViolations`}):o.maxViolations=t.maxViolations)}function Os(e,t,i){if(e.exports!==void 0){if(Array.isArray(e.exports)){let n=[];return e.exports.forEach((s,o)=>{let r=Ln(s,`${t}.exports[${o}]`,i);r&&n.push(r)}),n.length>0?n:void 0}return Ln(e.exports,`${t}.exports`,i)}}function $s(e){let{r:t,index:i,rulePath:n,imports:s,warnings:o}=e,r=Array.isArray(s)?s:[s],a=new Set(nn(r)),c=(l,u,p)=>{let d=B(l).filter(g=>!a.has(g));if(d.length>0){let g=Array.from(new Set(d));o.push({message:`Rule #${i}: ${p} references variables not present in "imports": ${g.join(", ")}`,path:u})}};typeof t.importer=="string"&&c(t.importer,`${n}.importer`,'"importer"'),typeof t.containedTo=="string"?c(t.containedTo,`${n}.containedTo`,'"containedTo"'):typeof t.containedTo=="object"&&t.containedTo!==null&&typeof t.containedTo.path=="string"&&c(t.containedTo.path,`${n}.containedTo.path`,'"containedTo.path"')}function Ln(e,t,i){if(typeof e!="object"||e===null){i.push({message:`"${t}" must be an object`,path:t});return}let n=e,s=!1;if(typeof n.path!="string"&&(i.push({message:`"${t}.path" is required and must be a string`,path:`${t}.path`}),s=!0),typeof n.to!="string"&&(i.push({message:`"${t}.to" is required and must be a string`,path:`${t}.to`}),s=!0),n.message!==void 0&&typeof n.message!="string"&&(i.push({message:`"${t}.message" must be a string`,path:`${t}.message`}),s=!0),!s)return{path:n.path,to:n.to,message:typeof n.message=="string"?n.message:void 0}}function jn(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 i=e,n={},s=[{key:"maxAfferentCoupling",label:"maxAfferentCoupling"},{key:"maxEfferentCoupling",label:"maxEfferentCoupling"},{key:"maxDepth",label:"maxDepth"}];for(let{key:o,label:r}of s){let a=i[o];a!==void 0&&(typeof a!="number"||!Number.isInteger(a)||a<1?t.push({message:`"health.${r}" must be a positive integer`,path:`health.${r}`}):n[o]=a)}if(i.maxInstability!==void 0){let o=i.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 Vn(e){let t=[],i=[];if(typeof e!="object"||e===null)return{ok:!1,errors:[{message:"Configuration must be a JSON object"}]};let n=e,s=Is(n.modules,t),o=Nn(n.rules,t,i),r=Ds(n["boundary-diagrams"],t),a=jn(n.health,t),c=Ls(n.warnOnUntrackedImporters,t),l=Ns(n.ignore,t);return t.length>0||!s||!o?i.length>0?{ok:!1,errors:t,warnings:i}:{ok:!1,errors:t}:{ok:!0,config:{modules:s,rules:{"module-boundaries":o},ignore:l,warnOnUntrackedImporters:c,"boundary-diagrams":r,health:a},warnings:i.length>0?i:void 0}}function Is(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 i={};for(let[n,s]of Object.entries(e))typeof s!="string"?t.push({message:`Module "${n}" pattern must be a string, got ${typeof s}`,path:`modules.${n}`}):i[n]=s;return i}function Ds(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 Ls(e,t){return e===void 0?!0:typeof e!="boolean"?(t.push({message:'"warnOnUntrackedImporters" must be a boolean',path:"warnOnUntrackedImporters"}),!0):e}function Ns(e,t){if(e===void 0)return;if(!Array.isArray(e)){t.push({message:'"ignore" must be an array of glob patterns',path:"ignore"});return}if(e.find(n=>typeof n!="string")!==void 0){t.push({message:'"ignore" entries must be strings',path:"ignore"});return}return e}function Wn(e){let t=Fn.join(e,N);if(!Ue.existsSync(t))return{ok:!0,config:void 0};try{let i=Ue.readFileSync(t,"utf-8"),n;try{n=Ge(i)}catch(s){return{ok:!1,errors:[{message:`pickety.json is not valid JSONC: ${s instanceof Error?s.message:String(s)}`}]}}if(typeof n=="object"&&n!==null){let s=n;if(s.preset!==void 0&&typeof s.preset!="string")return{ok:!1,errors:[{message:'"preset" must be a string',path:"preset"}]};if(typeof s.preset=="string"){let o=$n(s.preset);if(!o)return{ok:!1,errors:[{message:`Unknown preset "${s.preset}". Available presets: ${In().join(", ")}`,path:"preset"}]};n=Bs(o,s)}}return Vn(n)}catch(i){return{ok:!1,errors:[{message:`Failed to read pickety.json: ${i instanceof Error?i.message:String(i)}`}]}}}function ze(e){return typeof e=="object"&&e!==null}function js(e,t){return t===void 0?e:!ze(t)||!e?t:{...e,...t}}function Vs(e){let{merged:t,preset:i,override:n,keys:s}=e;for(let o of s)n[o]!==void 0?t[o]=n[o]:i[o]!==void 0&&(t[o]=i[o])}function Fs(e,t){return t===void 0?e:ze(t)?{...e,...t}:t}function Ws(e,t){if(t===void 0)return e;if(!ze(t))return t;let i=t["module-boundaries"];if(!ze(i))return t;let n={...e,...t},s=e["module-boundaries"],o={...s,...i},r=Array.isArray(s.rules)?s.rules:[];return i.rules===void 0?o.rules=r:Array.isArray(i.rules)?o.rules=[...r,...i.rules]:o.rules=i.rules,n["module-boundaries"]=o,n}function Bs(e,t){let i={...e,...t};return i.modules=Fs(e.modules,t.modules),i.rules=Ws(e.rules,t.rules),Vs({merged:i,preset:e,override:t,keys:["warnOnUntrackedImporters","boundary-diagrams","ignore","version"]}),i.health=js(e.health,t.health),i}var qe=S(require("fs")),Q=S(require("path"));function Bn(e,t){if(t<0)return[];let i=[],n;try{n=qe.readdirSync(e,{withFileTypes:!0})}catch{return i}for(let s of n)!ae.has(s.name)&&s.isFile()&&/^tsconfig(\..+)?\.json$/.test(s.name)&&i.push(Q.join(e,s.name));for(let s of n)!ae.has(s.name)&&s.isDirectory()&&i.push(...Bn(Q.join(e,s.name),t-1));return i}function _n(e){let t={},i=Bn(e,4);for(let n of i)try{let s=qe.readFileSync(n,"utf-8"),r=Ge(s).compilerOptions;if(!r?.paths)continue;let a=Q.dirname(n),c=Q.relative(e,a),l=r.baseUrl||".";for(let[u,p]of Object.entries(r.paths))if(Array.isArray(p)&&p.length>0){let f=p[0];t[u]||(t[u]=x(Q.join(c,l,f)))}}catch{}return t}var Xe=class{constructor(t){this.workspaceRoot=t;this.registerWatchers()}config;aliases={};_onConfigChanged=new q.EventEmitter;onConfigChanged=this._onConfigChanged.event;_onAliasesChanged=new q.EventEmitter;onAliasesChanged=this._onAliasesChanged.event;disposables=[];getConfig(){return this.config}getAliases(){return this.aliases}reload(){let t=Wn(this.workspaceRoot);this.config=t.ok?t.config:void 0,this._onConfigChanged.fire(t)}reloadAliases(){this.aliases=_n(this.workspaceRoot),this._onAliasesChanged.fire(this.aliases)}registerWatchers(){let t=q.workspace.createFileSystemWatcher(new q.RelativePattern(this.workspaceRoot,N));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 i=q.workspace.createFileSystemWatcher(new q.RelativePattern(this.workspaceRoot,"**/tsconfig*.json"));this.disposables.push(i);let n=s=>s.fsPath.split(/[\\/]/).some(r=>ae.has(r));i.onDidChange(s=>{n(s)||this.reloadAliases()}),i.onDidCreate(s=>{n(s)||this.reloadAliases()}),i.onDidDelete(s=>{n(s)||this.reloadAliases()})}dispose(){this.disposables.forEach(t=>t.dispose()),this._onConfigChanged.dispose(),this._onAliasesChanged.dispose()}};var Qe=S(require("vscode")),Gn=S(require("fs"));function Et(e,t,i){let n=new Set,s=je(e,t,i),o=x(e);for(let{resolvedPath:r}of s)r&&r!==o&&n.add(r);return n}var Je=class{dependents=new Map;dependencies=new Map;updateFile(t,i){let n=this.dependencies.get(t);if(n)for(let s of n)this.dependents.get(s)?.delete(t);this.dependencies.set(t,new Set(i));for(let s of i)this.dependents.has(s)||this.dependents.set(s,new Set),this.dependents.get(s).add(t)}removeFile(t){let i=this.dependencies.get(t);if(i)for(let s of i)this.dependents.get(s)?.delete(t);this.dependencies.delete(t);let n=this.dependents.get(t);if(n)for(let s of n)this.dependencies.get(s)?.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 i=new Set,n=[t],s=0;for(;s<n.length;){let o=n[s++],r=this.dependents.get(o);if(r)for(let a of r)!i.has(a)&&a!==t&&(i.add(a),n.push(a))}return i}getModuleSummary(t,i,n){let s=this.getDependents(t),o=this.getDependencies(t),r=new Set;for(let c of s){let l=j(c,i,n);l&&r.add(l)}let a=new Set;for(let c of o){let l=j(c,i,n);l&&a.add(l)}return{dependentCount:s.size,dependentModules:[...r],dependencyCount:o.size,dependencyModules:[...a]}}getModuleLevelGraph(t,i){let n=new Map;for(let[s,o]of this.dependencies){let r=j(s,t,i);if(r){n.has(r)||n.set(r,new Set);for(let a of o){let c=j(a,t,i);c&&c!==r&&n.get(r).add(c)}}}return n}clear(){this.dependents.clear(),this.dependencies.clear()}};var Ye=class e{constructor(t,i){this.workspaceRoot=t;this.configService=i;this.disposables.push(this.configService.onAliasesChanged(()=>{this.scanAndNotify()}))}knownFiles=new Set;importGraph=new Je;isLargeWorkspace=!1;static MAX_FILES_THRESHOLD=5e3;_onAnalysisReady=new Qe.EventEmitter;onAnalysisReady=this._onAnalysisReady.event;disposables=[];dispose(){this.disposables.forEach(t=>t.dispose()),this._onAnalysisReady.dispose()}getImportGraph(){return this.importGraph}getKnownFiles(){return this.knownFiles}checkIsLargeWorkspace(){return this.isLargeWorkspace}getWorkspaceContext(){return{root:this.workspaceRoot,knownFiles:this.knownFiles,aliases:this.configService.getAliases()}}async scan(t){let i=await Qe.workspace.findFiles(K,"**/node_modules/**"),n=t??this.configService.getConfig()?.ignore;return this.knownFiles=new Set(i.map(s=>s.fsPath).filter(s=>!J(s,this.workspaceRoot,n)).map(s=>x(s))),this.isLargeWorkspace=this.knownFiles.size>e.MAX_FILES_THRESHOLD,this.importGraph.clear(),this.isLargeWorkspace}async scanAndNotify(){await this.scan(),this._onAnalysisReady.fire()}updateFile(t,i,n){let s=x(t);this.knownFiles.add(s);try{let o=Et(s,i,n);this.importGraph.updateFile(s,o)}catch{}}removeFile(t){let i=x(t);this.knownFiles.delete(i),this.importGraph.removeFile(i)}ensureGraphReady(t){if(!this.isLargeWorkspace){for(let i of this.knownFiles)if(!this.importGraph.getDependencies(i).size)try{let n=Gn.readFileSync(i,"utf-8"),s=Et(i,n,t);this.importGraph.updateFile(i,s)}catch{continue}}}computeCycles(t,i){if(this.isLargeWorkspace)return[];this.ensureGraphReady(i);let n=this.importGraph.getModuleLevelGraph(t.modules,this.workspaceRoot);return tn(n)}computeHealthViolations(t,i){if(!t.health||this.isLargeWorkspace)return[];this.ensureGraphReady(i);let n=ue(this.importGraph,t.modules,i);return an(n,t.health)}};var se=S(require("vscode")),Ze=class{item;constructor(t){this.item=se.window.createStatusBarItem(se.StatusBarAlignment.Right,100),this.item.command="pickety.refresh",t.subscriptions.push(this.item)}update(t,i){if(!t){this.item.text="",this.item.tooltip="",this.item.color=void 0,this.item.backgroundColor=void 0,this.item.hide();return}let n=0,s=0;i.forEach((r,a)=>{a.filter(c=>c.source==="pickety").forEach(c=>{c.severity===se.DiagnosticSeverity.Error?n+=1:c.severity===se.DiagnosticSeverity.Warning&&(s+=1)})});let o=n+s;o>0?(this.item.text=`$(shield) Pickety: ${o} issue(s)`,this.item.tooltip=`Found ${o} architectural violations. Click to refresh.`,this.item.color=n>0?"#ff8c00":"#f2c200",this.item.backgroundColor=void 0,this.item.show()):(this.item.text="$(check) Pickety",this.item.tooltip="Architectural boundaries are secure. Click to refresh.",this.item.color=void 0,this.item.backgroundColor=void 0,this.item.show())}dispose(){this.item.dispose()}};var Pt=S(require("vscode")),me=class e{static instance;outputChannel;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}setOutputChannel(t){this.outputChannel=t}logEvent(t,i){if(!Pt.env.isTelemetryEnabled)return;let n=new Date().toISOString(),s=JSON.stringify({event:t,timestamp:n,...i});this.outputChannel&&this.outputChannel.appendLine(`[Telemetry] ${s}`)}logError(t,i){if(!Pt.env.isTelemetryEnabled)return;let n=t instanceof Error?t.message:t,s=t instanceof Error?t.stack:void 0;this.logEvent("error",{message:n,context:i||"unknown",stack:s||"no stack trace"})}};var A=S(require("vscode"));var Ke=class e{constructor(t){this.collection=t}static CIRCULAR_TAG="pickety/circular";static HEALTH_TAG="pickety/health";getCollection(){return this.collection}setViolations(t,i){let n=i.map(s=>{let o=new A.Range(s.line,s.character,s.line,s.character+s.length),r=s.severity==="error"?A.DiagnosticSeverity.Error:s.severity==="info"?A.DiagnosticSeverity.Information:A.DiagnosticSeverity.Warning,a=new A.Diagnostic(o,s.message,r);return a.source="pickety",s.ruleName&&(a.code={value:s.ruleName,target:A.Uri.parse(`https://github.com/DanielSerio/pickety/blob/main/docs/rules.md#${s.ruleName}`)}),a._picketyMetadata={sourceModule:s.sourceModule,targetModule:s.targetModule},a});this.collection.set(t,n)}setCircularDiagnostics(t,i){let n=i.map(s=>{let o=s.join(" -> "),r=new A.Diagnostic(new A.Range(0,0,0,100),`Circular dependency detected: ${o}`,A.DiagnosticSeverity.Error);return r.source="pickety",r.code=e.CIRCULAR_TAG,r});this.updateConfigDiagnostics(t,e.CIRCULAR_TAG,n)}setHealthDiagnostics(t,i){let n=i.map(s=>{let o=z(s.metric,s.value),r=z(s.metric,s.threshold),a=new A.Diagnostic(new A.Range(0,0,0,100),`Module "${s.moduleName}" has ${s.metric} of ${o} (max: ${r})`,A.DiagnosticSeverity.Warning);return a.source="pickety",a.code=e.HEALTH_TAG,a});this.updateConfigDiagnostics(t,e.HEALTH_TAG,n)}updateConfigDiagnostics(t,i,n){let s=(this.collection.get(t)||[]).filter(o=>(typeof o.code=="object"?o.code?.value:o.code)!==i);this.collection.set(t,[...s,...n])}clear(){this.collection.clear()}delete(t){this.collection.delete(t)}dispose(){this.collection.dispose()}};var V=S(require("vscode")),$t=S(require("fs")),ye=S(require("path"));var At=S(require("path"));function Un(e){return e.isOnly?_s(e):Gs(e)}function Tt(e){let{pattern:t,variables:i,moduleName:n,relativePath:s}=e,o=t.includes("/")?s:n;return Se(t,o,i)}function _s(e){let{rule:t,importsPattern:i,variables:n,effectiveImporter:s,ruleSeverity:o,ruleName:r,ruleLabel:a,ruleGroup:c,ctx:l}=e,u=Tt({pattern:i,variables:n,moduleName:l.targetModule,relativePath:l.targetRelativePath});if(!u||qs(t,u))return;let p=te(s,n,u);if(!W(l.sourceModule,l.sourceRelativePath,p)){if(Mt(t,l,u))return;let d=t.message||`Module "${l.sourceModule}" is not allowed to import from "${l.targetModule}" (contained to "${p}")`;return ee({filePath:l.filePath,importStmt:l.importStmt,ruleName:r,ruleLabel:a,message:d,severity:o,sourceModule:l.sourceModule,targetModule:l.targetModule,ruleGroup:c})}}function Gs(e){let{rule:t,importsPattern:i,variables:n,allow:s,effectiveImporter:o,ruleSeverity:r,ruleName:a,ruleLabel:c,ruleGroup:l,ctx:u}=e,p=Tt({pattern:o,variables:n,moduleName:u.sourceModule,relativePath:u.sourceRelativePath});if(p)if(s){let f=te(i,n,"*"),d=te(i,n,p),g=W(u.targetModule,u.targetRelativePath,f),h=W(u.targetModule,u.targetRelativePath,d);if(g&&!h){let k=t.message||`Import must match scoped pattern "${d}"`;return ee({filePath:u.filePath,importStmt:u.importStmt,ruleName:a,ruleLabel:c,message:k,severity:r,sourceModule:u.sourceModule,targetModule:u.targetModule,ruleGroup:l})}}else{let f=te(i,n,p);if(W(u.targetModule,u.targetRelativePath,f)){let g=t.message||`Module "${u.sourceModule}" cannot import from "${u.targetModule}"`;return ee({filePath:u.filePath,importStmt:u.importStmt,ruleName:a,ruleLabel:c,message:g,severity:r,sourceModule:u.sourceModule,targetModule:u.targetModule,ruleGroup:l})}}}function Hs(e){return e?Array.isArray(e)?e:[e]:[]}var Hn=new WeakMap;function zs(e){let t=Hn.get(e);if(t)return t;let n=Hs(e.exports).map(s=>({entry:s,pathVars:B(s.path),toVars:B(s.to)}));return Hn.set(e,n),n}function Mt(e,t,i){let n=zs(e);if(n.length===0)return!1;for(let{entry:s,pathVars:o,toVars:r}of n){let a=o.length>0?zn({pattern:s.path,variables:o,preferred:i,moduleName:t.targetModule,relativePath:t.targetRelativePath}):{};if(o.length>0&&!a)continue;let c=r.length>0?zn({pattern:s.to,variables:r,preferred:void 0,moduleName:t.sourceModule,relativePath:t.sourceRelativePath}):{};if(r.length>0&&!c)continue;let l=Us(a??{},c??{});if(!l)continue;let u=o.length>0?te(s.path,o,l):s.path;if(!W(t.targetModule,t.targetRelativePath,u))continue;let p=r.length>0?te(s.to,r,l):s.to;if(W(t.sourceModule,t.sourceRelativePath,p))return!0}return!1}function zn(e){let{pattern:t,variables:i,preferred:n,moduleName:s,relativePath:o}=e;return n&&i.every(r=>n[r]!==void 0)?n:Tt({pattern:t,variables:i,moduleName:s,relativePath:o})}function Us(e,t){let i={...e};for(let[n,s]of Object.entries(t)){if(i[n]!==void 0&&i[n]!==s)return;i[n]=s}return i}function qs(e,t){let i=dt(e);if(i&&i.unless){let n=Object.entries(i.unless);return n.length>0&&n.every(([s,o])=>t[s]===o)}return!1}function qn(e,t){let{rule:i,allow:n,severity:s,name:o,label:r,group:a,effectiveImporter:c,isOnly:l,importPatterns:u}=e;for(let p of u){let f=B(l?p:c);if(f.length>0){let h=Un({rule:i,importsPattern:p,variables:f,isOnly:l,allow:n,effectiveImporter:c,ruleSeverity:s,ruleName:o,ruleLabel:r,ruleGroup:a,ctx:t});if(h)return h;continue}let d=W(t.sourceModule,t.sourceRelativePath,c),g=W(t.targetModule,t.targetRelativePath,p);if(l){if(g&&!d){if(Mt(i,t))return;let h=i.message||(i.containedTo?`Import is restricted: "${t.targetModule}" is contained to "${c}"`:`Module "${t.targetModule}" can only be imported by "${c}"`);return ee({filePath:t.filePath,importStmt:t.importStmt,ruleName:o,ruleLabel:r,message:h,severity:s,sourceModule:t.sourceModule,targetModule:t.targetModule,ruleGroup:a})}}else if(d&&g&&!n){let h=i.message||`Module "${t.sourceModule}" cannot import from "${t.targetModule}"`;return ee({filePath:t.filePath,importStmt:t.importStmt,ruleName:o,ruleLabel:r,message:h,severity:s,sourceModule:t.sourceModule,targetModule:t.targetModule,ruleGroup:a})}}}function Xn(e){let{filePath:t,content:i,config:n,ctx:s}=e,o=[],{modules:r}=n,{severity:a,rules:c}=n.rules["module-boundaries"],{root:l}=s,u=n.warnOnUntrackedImporters??!0,p=c.map((h,k)=>en(h,k,a)),f=j(t,r,l);if(!f)return u&&o.push({file:t,line:0,character:0,length:1,message:"This file is not covered by any declared module. Import rules will not be enforced here.",severity:"info"}),o;let d=x(At.relative(l,t)),g=je(t,i,s);for(let{statement:h,resolvedPath:k}of g){let P=j(k,r,l);if(!P)continue;let O=x(At.relative(l,k)),y={sourceModule:f,sourceRelativePath:d,targetModule:P,targetRelativePath:O,filePath:t,importStmt:h};for(let w of p){let v=qn(w,y);v&&o.push(v)}}return o}function et(e,t){let i=t.rules["module-boundaries"].rules,n=new Map;if(i.forEach((o,r)=>{if(o.maxViolations!==void 0){let a=o.name??`rule[${r}]`;n.set(a,o.maxViolations)}}),n.size===0)return e;let s=new Map;for(let o of e)o.ruleName&&n.has(o.ruleName)&&s.set(o.ruleName,(s.get(o.ruleName)??0)+1);return e.map(o=>{if(!o.ruleName||!n.has(o.ruleName))return o;let r=s.get(o.ruleName)??0,a=n.get(o.ruleName),c=r<=a?"warn":"error";return c===o.severity?o:{...o,severity:c}})}var C=S(require("vscode")),Ct=S(require("path"));function Jn(e){let{errors:t,workspaceRoot:i,outputChannel:n,diagnosticCollection:s}=e;n.appendLine("Pickety: Configuration error(s) found:");let o=C.Uri.file(Ct.join(i,N)),r=t.map(a=>{n.appendLine(` - ${a.message}${a.path?` (at ${a.path})`:""}`);let c=new C.Range(0,0,0,100),l=new C.Diagnostic(c,a.message,C.DiagnosticSeverity.Error);return l.source="pickety",a.path&&(l.code=a.path),l});s.set(o,r),C.window.showErrorMessage("Pickety: Configuration error. Check the Problems panel or Output channel for details.")}function Ot(e){let{warnings:t,workspaceRoot:i,outputChannel:n,diagnosticCollection:s}=e;n.appendLine("Pickety: Configuration warning(s) found:");let o=C.Uri.file(Ct.join(i,N)),r=t.map(c=>{n.appendLine(` - ${c.message}${c.path?` (at ${c.path})`:""}`);let l=new C.Range(0,0,0,100),u=new C.Diagnostic(l,c.message,C.DiagnosticSeverity.Warning);return u.source="pickety",c.path&&(u.code=c.path),u}),a=s.get(o)||[];s.set(o,[...a,...r])}var tt=class e{static DIAGRAM_GITIGNORE_KEY="pickety.diagramGitignoreAdded";telemetry=me.getInstance();disposables=[];codeLensProvider;configRef={config:void 0};context;configService;analysisService;diagnosticManager;statusBar;outputChannel;workspaceRoot;constructor(t){this.context=t.context,this.configService=t.configService,this.analysisService=t.analysisService,this.diagnosticManager=t.diagnosticManager,this.statusBar=t.statusBar,this.outputChannel=t.outputChannel,this.workspaceRoot=t.workspaceRoot,this.registerEventListeners()}setCodeLensProvider(t){this.codeLensProvider=t}handleConfigResult(t){this.diagnosticManager.clear();let i=t.ok?t.config:void 0;if(this.configRef.config=i,t.ok&&t.config){let n=t.config;this.outputChannel.appendLine("Pickety: Import boundaries active"),t.warnings&&t.warnings.length>0&&Ot({warnings:t.warnings,workspaceRoot:this.workspaceRoot,outputChannel:this.outputChannel,diagnosticCollection:this.diagnosticManager.getCollection()});try{let s=Ve(t.config,this.workspaceRoot);s&&(this.outputChannel.appendLine(`Pickety: Generated boundary diagram at ${s}`),this.ensureDefaultDiagramIgnored(s))}catch(s){this.outputChannel.appendLine(`Pickety: Failed to generate boundary diagram: ${s instanceof Error?s.message:String(s)}`)}this.analysisService.scan(n.ignore).then(()=>this.analyzeOpenEditors())}else t.ok||(Jn({errors:t.errors,workspaceRoot:this.workspaceRoot,outputChannel:this.outputChannel,diagnosticCollection:this.diagnosticManager.getCollection()}),t.warnings&&t.warnings.length>0&&Ot({warnings:t.warnings,workspaceRoot:this.workspaceRoot,outputChannel:this.outputChannel,diagnosticCollection:this.diagnosticManager.getCollection()}));this.statusBar.update(i,this.diagnosticManager.getCollection())}analyzeOpenEditors(){try{let t=this.configService.getConfig();if(!t)return;let i=[];for(let r of V.workspace.textDocuments)this.isSourceFile(r)&&i.push({uri:r.uri,violations:this.checkDocument(r,t)});let n=i.flatMap(r=>r.violations),s=et(n,t),o=new Map;for(let r of s){let a=x(r.file),c=o.get(a);c?c.push(r):o.set(a,[r])}for(let r of i){let a=x(r.uri.fsPath);this.diagnosticManager.setViolations(r.uri,o.get(a)??[])}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")}}async analyzeWorkspace(){let t=this.configService.getConfig();if(!t)return;await this.analysisService.scan(t.ignore);let i=this.analysisService.getWorkspaceContext(),n=[];for(let a of this.analysisService.getKnownFiles()){let c=V.Uri.file(a),l=[];try{if(J(a,this.workspaceRoot,t.ignore)){this.diagnosticManager.delete(c);continue}let u=await V.workspace.fs.readFile(c),p=Buffer.from(u).toString("utf8");l=this.checkDocumentText(a,p,t),this.analysisService.updateFile(a,p,i)}catch(u){this.telemetry.logError(u instanceof Error?u:String(u),"analyzeWorkspace")}n.push({uri:c,filePath:a,violations:l})}let s=n.flatMap(a=>a.violations),o=et(s,t),r=new Map;for(let a of o){let c=x(a.file),l=r.get(c);l?l.push(a):r.set(c,[a])}for(let a of n){let c=x(a.filePath);this.diagnosticManager.setViolations(a.uri,r.get(c)??[])}this.statusBar.update(t,this.diagnosticManager.getCollection()),setTimeout(()=>{this.checkCircularDependencies(t),this.checkHealthThresholds(t)},0)}analyzeDocument(t){let i=this.configService.getConfig();if(!i||!this.isSourceFile(t))return;if(this.hasMaxViolationsRules(i)){this.analyzeOpenEditors();return}let n=this.checkDocument(t,i);this.diagnosticManager.setViolations(t.uri,n),this.statusBar.update(i,this.diagnosticManager.getCollection())}analyzeDocumentText(t,i){let n=this.configService.getConfig();if(!n||!this.isSourceFile(t))return;if(this.hasMaxViolationsRules(n)){this.analyzeOpenEditorsWithOverride(t,i);return}let s=this.checkDocumentText(t.uri.fsPath,i,n);this.diagnosticManager.setViolations(t.uri,s),this.statusBar.update(n,this.diagnosticManager.getCollection())}checkDocument(t,i){return this.checkDocumentText(t.uri.fsPath,t.getText(),i)}checkDocumentText(t,i,n){return Xn({filePath:t,content:i,config:n,ctx:this.analysisService.getWorkspaceContext()})}hasMaxViolationsRules(t){return t.rules["module-boundaries"].rules.some(i=>i.maxViolations!==void 0)}analyzeOpenEditorsWithOverride(t,i){let n=this.configService.getConfig();if(!n)return;let s=[];for(let c of V.workspace.textDocuments)if(this.isSourceFile(c)){let l=x(c.uri.fsPath)===x(t.uri.fsPath)?i:c.getText();s.push({uri:c.uri,violations:this.checkDocumentText(c.uri.fsPath,l,n)})}let o=s.flatMap(c=>c.violations),r=et(o,n),a=new Map;for(let c of r){let l=x(c.file),u=a.get(l);u?u.push(c):a.set(l,[c])}for(let c of s){let l=x(c.uri.fsPath);this.diagnosticManager.setViolations(c.uri,a.get(l)??[])}this.statusBar.update(n,this.diagnosticManager.getCollection()),setTimeout(()=>{this.checkCircularDependencies(n),this.checkHealthThresholds(n)},0)}checkCircularDependencies(t){let i=this.analysisService.computeCycles(t,this.analysisService.getWorkspaceContext()),n=V.Uri.file(ce(this.workspaceRoot));this.diagnosticManager.setCircularDiagnostics(n,i)}checkHealthThresholds(t){let i=this.analysisService.computeHealthViolations(t,this.analysisService.getWorkspaceContext()),n=V.Uri.file(ce(this.workspaceRoot));this.diagnosticManager.setHealthDiagnostics(n,i)}registerEventListeners(){this.disposables.push(V.workspace.onDidSaveTextDocument(i=>{this.isSourceFile(i)&&(this.analysisService.updateFile(i.uri.fsPath,i.getText(),this.analysisService.getWorkspaceContext()),this.analyzeDocument(i),this.codeLensProvider?.refresh())}));let t=V.workspace.createFileSystemWatcher(K);this.disposables.push(t),t.onDidCreate(i=>{J(i.fsPath,this.workspaceRoot,this.configService.getConfig()?.ignore)||this.analysisService.getKnownFiles().add(x(i.fsPath))}),t.onDidDelete(i=>{this.analysisService.removeFile(i.fsPath),this.codeLensProvider?.refresh()}),t.onDidChange(i=>{this.handleExternalChange(i)})}async handleExternalChange(t){let i=this.configService.getConfig()?.ignore;if(J(t.fsPath,this.workspaceRoot,i))return;let n=V.workspace.textDocuments.find(s=>x(s.uri.fsPath)===x(t.fsPath));if(n)try{let s=await V.workspace.fs.readFile(t),o=Buffer.from(s).toString("utf8");this.analysisService.updateFile(n.uri.fsPath,o,this.analysisService.getWorkspaceContext()),this.analyzeDocumentText(n,o),this.codeLensProvider?.refresh()}catch(s){this.telemetry.logError(s instanceof Error?s:String(s),"handleExternalChange"),this.outputChannel.appendLine(`Pickety: Error reading changed file ${t.fsPath}: ${s instanceof Error?s.message:String(s)}`)}}isSourceFile(t){if(!["typescript","typescriptreact","javascript","javascriptreact"].includes(t.languageId))return!1;let i=this.configService.getConfig()?.ignore;return!J(t.uri.fsPath,this.workspaceRoot,i)}async ensureDefaultDiagramIgnored(t){let i=this.configService.getConfig();if(!i||i["boundary-diagrams"]!==!0||this.context.workspaceState.get(e.DIAGRAM_GITIGNORE_KEY))return;let n=ye.join(this.workspaceRoot,"picket-boundaries.mermaid"),s=x(ye.resolve(t)),o=x(ye.resolve(n));if(s!==o)return;let r=ye.join(this.workspaceRoot,".gitignore"),a="";try{a=await $t.promises.readFile(r,"utf8")}catch(u){if(!(u instanceof Error)||!("code"in u)||u.code!=="ENOENT"){this.telemetry.logError(u instanceof Error?u:String(u),"ensureDefaultDiagramIgnored");return}}let c="/picket-boundaries.mermaid";if(!/(^|\r?\n)\s*\/?picket-boundaries\.mermaid\s*(#.*)?(\r?\n|$)/.test(a)){let u=a.length>0&&!a.endsWith(`
|
|
154
|
+
`),p=`${a}${u?`
|
|
155
|
+
`:""}${c}
|
|
156
|
+
`;try{await $t.promises.writeFile(r,p,"utf8"),this.outputChannel.appendLine("Pickety: Added picket-boundaries.mermaid to .gitignore")}catch(f){this.telemetry.logError(f instanceof Error?f:String(f),"ensureDefaultDiagramIgnored");return}}await this.context.workspaceState.update(e.DIAGRAM_GITIGNORE_KEY,!0)}dispose(){this.disposables.forEach(t=>t.dispose())}};var ve=S(require("vscode")),nt=class{constructor(t){this.workspaceRoot=t}provideCodeActions(t,i,n){let s=[];for(let o of n.diagnostics)if(o.source==="pickety"&&o.code){let r=typeof o.code=="object"?o.code.value:o.code,a=new ve.CodeAction(`Go to Pickety rule: ${r}`,ve.CodeActionKind.QuickFix);a.command={command:"pickety.goToRule",title:"Go to Rule",arguments:[this.workspaceRoot,r]},s.push(a);let c=o._picketyMetadata;if(c&&c.sourceModule&&c.targetModule){let l=new ve.CodeAction(`Allow imports from '${c.targetModule}' in '${c.sourceModule}'`,ve.CodeActionKind.QuickFix);l.command={command:"pickety.allowImport",title:"Allow Import",arguments:[this.workspaceRoot,c.sourceModule,c.targetModule]},s.push(l)}}return s}};var be=S(require("vscode"));var it=class{constructor(t,i,n){this.importGraph=t;this.workspaceRoot=i;this.configRef=n}_onDidChangeCodeLenses=new be.EventEmitter;onDidChangeCodeLenses=this._onDidChangeCodeLenses.event;refresh(){this._onDidChangeCodeLenses.fire()}provideCodeLenses(t){let i=this.configRef.config;if(!i)return[];let n=x(t.uri.fsPath),s=this.importGraph.getModuleSummary(n,i.modules,this.workspaceRoot);if(s.dependentCount===0&&s.dependencyCount===0)return[];let o=[];if(s.dependentCount>0){let c=s.dependentModules.length===1?"1 module":`${s.dependentModules.length} modules`;o.push(`${s.dependentCount} dependent${s.dependentCount===1?"":"s"} (${c})`)}if(s.dependencyCount>0){let c=s.dependencyModules.length===1?"1 module":`${s.dependencyModules.length} modules`;o.push(`${s.dependencyCount} dependenc${s.dependencyCount===1?"y":"ies"} (${c})`)}let r=new be.Range(0,0,0,0);return[new be.CodeLens(r,{title:o.join(" | "),command:"pickety.showImpact",tooltip:"Show full impact analysis for this file"})]}dispose(){this._onDidChangeCodeLenses.dispose()}};var Xs=[];async function Js(e){let t=me.getInstance();t.logEvent("extension_activate");let i=G.window.createOutputChannel("Pickety");e.subscriptions.push(i),t.setOutputChannel(i);let n=G.workspace.workspaceFolders?.[0]?.uri.fsPath;if(!n){i.appendLine("Pickety: No workspace root found.");return}i.appendLine(`Pickety: Extension activated for workspace: ${n}`);let s=new Xe(n);e.subscriptions.push(s);let o=new Ye(n,s);e.subscriptions.push(o);let r=new Ze(e);e.subscriptions.push(r);let a=G.languages.createDiagnosticCollection("pickety");e.subscriptions.push(a);let c=new Ke(a);e.subscriptions.push(c);let l=new nt(n);e.subscriptions.push(G.languages.registerCodeActionsProvider({scheme:"file",language:"*"},l,{providedCodeActionKinds:[G.CodeActionKind.QuickFix]}));let u=new it(o.getImportGraph(),n,{config:void 0});e.subscriptions.push(u);let p=new tt({context:e,configService:s,analysisService:o,diagnosticManager:c,statusBar:r,outputChannel:i,workspaceRoot:n});p.setCodeLensProvider(u),e.subscriptions.push(p),u.configRef=p.configRef,e.subscriptions.push(G.languages.registerCodeLensProvider({scheme:"file",pattern:K},u)),Tn({context:e,configService:s,analysisService:o,documentValidator:p,workspaceRoot:n}),s.onConfigChanged(f=>p.handleConfigResult(f)),o.onAnalysisReady(()=>{i.appendLine(`Pickety: Analysis complete. Found ${o.getKnownFiles().size} files.`),p.analyzeOpenEditors()}),s.reload(),s.reloadAliases()}function Ys(){Xs.forEach(e=>e.dispose())}0&&(module.exports={activate,deactivate});
|
package/package.json
CHANGED
|
@@ -179,6 +179,14 @@
|
|
|
179
179
|
"description": "Emit an info diagnostic when a file does not match any declared module.",
|
|
180
180
|
"markdownDescription": "Emit an **info** diagnostic when a file does not match any declared module. These files bypass all import rules.\n\n- `true` (default): warn when a file is outside declared modules.\n- `false`: silence this diagnostic."
|
|
181
181
|
},
|
|
182
|
+
"ignore": {
|
|
183
|
+
"type": "array",
|
|
184
|
+
"description": "Glob patterns for files/directories to exclude from analysis.",
|
|
185
|
+
"markdownDescription": "Glob patterns for files/directories to exclude from analysis.\n\nExamples:\n```json\n\"ignore\": [\n \"tests/**\",\n \"**/*.spec.ts\"\n]\n```",
|
|
186
|
+
"items": {
|
|
187
|
+
"type": "string"
|
|
188
|
+
}
|
|
189
|
+
},
|
|
182
190
|
"boundary-diagrams": {
|
|
183
191
|
"oneOf": [
|
|
184
192
|
{
|