@omfalos/mokosh 0.3.3 → 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/dist/cli.mjs CHANGED
@@ -1,47 +1,47 @@
1
1
  #!/usr/bin/env node
2
- var Nt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var u=(t,e)=>()=>(t&&(e=t(t=0)),e);var wa=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);import Ea from"path";import{fileURLToPath as Fa}from"url";var Ta,Na,f,l=u(()=>{"use strict";Ta=()=>Fa(import.meta.url),Na=()=>Ea.dirname(Ta()),f=Na()});function Oe(t){wn.push(t)}function En(t){return[...Pa,...wn].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}function Ge(t){Fn.push(t)}function ue(){return[...Ia,...Fn]}function _e(t){Tn.push(t)}function Pt(){return[...Da,...Tn]}function It(t){Nn=t}function Dt(){return Nn}var Pa,wn,Ia,Fn,Da,Tn,Nn,re=u(()=>{"use strict";l();Pa=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],wn=[];Ia=[".test.",".spec.","-test.","-spec."],Fn=[];Da=["jest","vitest","playwright","cypress","@testing-library/"],Tn=[];Nn=.8});import Mt from"fs";import Pn from"path";function ne(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let n=Pn.resolve(t);return Mt.existsSync(n)?n.endsWith(".json")?In(n):e?Dn(n):{}:{}}for(let n of Ma){let o=Pn.resolve(t,n);if(Mt.existsSync(o)){if(n.endsWith(".json"))return In(o);if(e)return Dn(o)}}return{}}function In(t){return JSON.parse(Mt.readFileSync(t,"utf-8"))}function Dn(t){let e=Nt(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function At(t){for(let e of t.configMatchers??[])Oe(e);for(let e of t.testPatterns??[])Ge(e);for(let e of t.testLibraries??[])_e(e);t.barrelThreshold!==void 0&&It(t.barrelThreshold)}function I(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases}}var Ma,Rt=u(()=>{"use strict";l();re();Ma=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"]});var J,Lt,je=u(()=>{"use strict";l();J=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],Lt=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature",".md",".mdx"]});import ym from"fs";import bm from"path";var Mn=u(()=>{"use strict";l()});var We,An=u(()=>{"use strict";l();We={serialize(t){let e=["graph TD"],r=new Set;for(let n of t.nodes.values()){let o=`"${n.path}"`;for(let s of n.imports){if(!s.toPath)continue;let i=`"${s.toPath}"`,a=`${n.path} -> ${s.toPath}`;if(!r.has(a)){let c=s.isStyle?"-- styles -->":"-->";e.push(` ${o} ${c} ${i}`),r.add(a)}}}return e.join(`
3
- `)}}});var Rn=u(()=>{"use strict";l();An()});import Ln from"fs";import Ra from"path";function Ot(t,e){let r=t.replace(/^\.\//,"");if(e.nodes.has(r))return r;let n=r.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(n)?n:null}function On(t,e){if(typeof t=="string")return Ot(t,e);if(t&&typeof t=="object"){let r=t;for(let n of["import","require","default"]){let o=On(r[n],e);if(o)return o}}return null}function La(t){if(!t)return"unknown";let e=t.trimStart();return e.startsWith("interface ")?"interface":e.startsWith("class ")?"class":e.startsWith("enum ")?"enum":e.startsWith("type ")?"type":e.startsWith("namespace ")?"namespace":e.startsWith("const ")||e.startsWith("let ")||e.startsWith("var ")||e.startsWith("readonly ")?"const":e.startsWith("(")||e.startsWith("async ")||e.startsWith("function ")||e.includes("=>")?"function":"unknown"}function Oa(t,e){let r=new Set,n=new Set,o=[...e];for(;o.length;){let s=o.shift();if(n.has(s))continue;n.add(s);let i=t.nodes.get(s);if(i){for(let a of i.exports)r.add(a.name);for(let a of i.imports){if(a.type!=="re-export"||a.isExternal||!a.toPath)continue;if(!a.symbols?.length||a.symbols.includes("*")){let p=t.nodes.get(a.toPath);if(p)for(let m of p.exports)r.add(m.name);o.push(a.toPath)}else for(let p of a.symbols)r.add(p)}}}return r}function Gt(t,e){let r=[],n=Ra.join(e,"package.json");if(Ln.existsSync(n))try{let o=JSON.parse(Ln.readFileSync(n,"utf8"));if(o.exports&&typeof o.exports=="object"&&!Array.isArray(o.exports))for(let s of Object.values(o.exports)){let i=On(s,t);i&&!r.includes(i)&&r.push(i)}else if(typeof o.exports=="string"){let s=Ot(o.exports,t);s&&r.push(s)}if(r.length===0)for(let s of[o.main,o.module].filter(Boolean)){let i=Ot(s,t);i&&!r.includes(i)&&r.push(i)}}catch{}if(r.length===0){for(let o of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(o)){r.push(o);break}}return r}function Ga(t,e){let r=new Set(e);for(let n of e)t.traverse(n,o=>(r.add(o.path),!0),{direction:"outgoing"});return r}function _a(t,e,r){let n=new Map;for(let o of e){if(r.includes(o))continue;let s=t.nodes.get(o);if(!s)continue;let i=s.category==="barrel";for(let a of s.exports){let c=n.get(a.name),p=!!(a.signature||a.doc);(!c||p&&!i)&&n.set(a.name,{file:o,symbol:a})}}return n}function ja(t,e,r,n){let o=[];for(let s of t){let i=e.get(s),a=n.flatMap(d=>r.nodes.get(d)?.exports??[]).find(d=>d.name===s),c=i?.symbol??a,p=i?.file??n.find(d=>r.nodes.get(d)?.exports.some(y=>y.name===s))??n[0],m={name:s,definedIn:p,kind:La(c?.signature)};c?.doc&&(m.doc=c.doc),c?.signature&&(m.signature=c.signature),o.push(m)}return o.sort((s,i)=>s.name.localeCompare(i.name)),o}function Wa(t,e,r){let n=c=>t.nodes.get(c)?.category==="test",o=[...e].filter(c=>!r.includes(c)&&!n(c)),s=[...t.nodes.keys()].filter(c=>!e.has(c)),i=s.filter(c=>!n(c)),a=s.filter(c=>n(c));return{internalFiles:o,unreachableFromEntry:i,testFiles:a}}function _t(t,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let p of e)if(!t.nodes.has(p))throw new Error(`Entry point not found in graph: ${p}`);let r=Ga(t,e),n=_a(t,r,e),o=Oa(t,e),s=ja(o,n,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:c}=Wa(t,r,e);return{entryPoints:e,publicExports:s,internalFiles:i,unreachableFromEntry:a,testFiles:c}}var jt=u(()=>{"use strict";l()});function Wt(t,e){let r=null,n=[];for(let s of t.nodes.values()){s.exports.some(i=>i.name===e)&&(r=s.path);for(let i of s.callEdges??[])i.to===e&&n.push({file:s.path,callerFunction:i.from})}let o=[];if(r){let s=t.nodes.get(r);for(let i of s?.callEdges??[])i.from===e&&o.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:r,callers:n,callees:o}}var zt=u(()=>{"use strict";l()});import Rm from"fs";import Om from"path";function Gn(t){let e=[...t.nodes.entries()].sort(([n],[o])=>n.localeCompare(o)).map(([n,o])=>`${n}:${o.mtime}:${o.size}`).join("|"),r=2166136261;for(let n=0;n<e.length;n++)r^=e.charCodeAt(n),r=Math.imul(r,16777619)>>>0;return r.toString(16).padStart(8,"0")}function $t(t){let e=new Map;for(let r of t.nodes.keys()){let n=[];t.traverse(r,o=>(o.path!==r&&n.push(o.path),!0),{direction:"incoming"}),e.set(r,n)}return{impact:e,graphHash:Gn(t)}}function Bt(t,e){return t.impact.get(e)??[]}var Ut=u(()=>{"use strict";l()});import ze from"fs";import za from"path";import{load as _n}from"js-yaml";function jn(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function $a(t){return t.replace(/:$/,"").split(",").map(e=>{let r=e.trim();return r.startsWith('"')&&(r=r.slice(1)),r.endsWith('"')&&(r=r.slice(0,-1)),jn(r)}).filter(Boolean)}function Ba(t,e){let r=t.startsWith("/")?t.slice(1):t,n=r.lastIndexOf("@");return n>0?{name:r.substring(0,n),version:e||r.substring(n+1)}:{name:r,version:e}}function Ua(t){try{let e=_n(t),r={dependencies:{}};for(let[n,o]of Object.entries(e))if(!(n==="__metadata"||!o?.version))for(let s of n.split(", ")){let i=jn(s);i&&(r.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}return r}catch{return null}}function Ja(t){let e={dependencies:{}};for(let r of t.split(/\n\n+/)){let n=r.split(`
4
- `).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(n.length<2)continue;let o=n[0];if(!o||o.startsWith(" "))continue;let s=$a(o);if(s.length===0)continue;let a=n.find(c=>c.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let c of s)e.dependencies[c]={version:a}}return e}function Ka(t){let e=ze.readFileSync(t,"utf-8"),r=JSON.parse(e),n={dependencies:{}};if(r.packages)for(let[o,s]of Object.entries(r.packages)){if(!o.startsWith("node_modules/"))continue;let i=o.replace("node_modules/","");i.includes("node_modules/")||(n.dependencies[i]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}else if(r.dependencies)for(let[o,s]of Object.entries(r.dependencies))n.dependencies[o]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}};return n}function Ha(t){let e=ze.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=Ua(e);if(r!==null)return r}return Ja(e)}function Va(t){let e=ze.readFileSync(t,"utf-8"),r={dependencies:{}};try{let n=_n(e);if(n.packages)for(let[o,s]of Object.entries(n.packages)){let{name:i,version:a}=Ba(o,s.version);i&&(r.dependencies[i]={version:a,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}if(n.dependencies)for(let[o,s]of Object.entries(n.dependencies)){if(r.dependencies[o])continue;let i=typeof s=="string"?s:s.version;r.dependencies[o]={version:i||""}}}catch{}return r}function Wn(t){let e={"package-lock.json":Ka,"yarn.lock":Ha,"pnpm-lock.yaml":Va},r=Jt.map(n=>[n,e[n]]);for(let[n,o]of r){let s=za.join(t,n);if(ze.existsSync(s))return o(s)}return null}var Jt,Kt=u(()=>{"use strict";l();Jt=["package-lock.json","yarn.lock","pnpm-lock.yaml"]});function zn(t){return Qa.has(t)?"style":"code"}var Qa,$n=u(()=>{"use strict";l();Qa=new Set(["css","scss","less","stylus"])});function Ya(t){let e=5381;for(let r=0;r<t.length;r++)e=e*33+t.charCodeAt(r)>>>0;return e.toString(36)}function Xa(t,e){let r=[];for(let n=0;n<=t.length-e;n++)r.push(Ya(t.slice(n,n+e).map(o=>o.text).join(" ")));return r}function qa(t,e,r){let n=t.get(e.file),o=t.get(r.file);if(!n||!o)return 0;let s=0;for(;e.windowIndex+s+1<n.length&&r.windowIndex+s+1<o.length&&n[e.windowIndex+s+1]===o[r.windowIndex+s+1];)s++;return s}function Za(t,e,r){if(e.windowIndex===0||r.windowIndex===0)return!0;let n=t.get(e.file),o=t.get(r.file);return!n||!o?!0:n[e.windowIndex-1]!==o[r.windowIndex-1]}function $e(t){return`${t.file}#${t.startLine}#${t.endLine}`}function tc(t,e,r){let n=0;for(let o=e;o<e+r;o++)ec.has(t[o].text)&&n++;return n/r}function Bn(t,e,r,n=.5,o=rc){let s=new Map,i=new Map,a=new Map;for(let{file:S,tokens:C}of t){if(C.length<e)continue;i.set(S,C);let k=Xa(C,e);s.set(S,k);for(let b=0;b<k.length;b++){let v={file:S,windowIndex:b},P=a.get(k[b]);P?P.push(v):a.set(k[b],[v])}}let c=[],p=0;for(let S of a.values())if(!(S.length<2)){if(S.length>o){p++;continue}for(let C=0;C<S.length;C++)for(let k=C+1;k<S.length;k++){let b=S[C],v=S[k];if(b.file===v.file&&b.windowIndex===v.windowIndex||!Za(s,b,v))continue;let P=qa(s,b,v),A=e+P,te=i.get(b.file);if(tc(te,b.windowIndex,A)>n)continue;if(b.file===v.file){let[va,ka]=b.windowIndex<v.windowIndex?[b,v]:[v,b];if(va.windowIndex+A>ka.windowIndex)continue}let me=i.get(v.file),Ft={file:b.file,startLine:te[b.windowIndex].line,endLine:te[b.windowIndex+A-1].line},Tt={file:v.file,startLine:me[v.windowIndex].line,endLine:me[v.windowIndex+A-1].line},kn=Math.min(Ft.endLine-Ft.startLine+1,Tt.endLine-Tt.startLine+1);kn<r||c.push({occA:Ft,occB:Tt,lines:kn,tokens:A})}}let m=new Ht,d=new Map;for(let{occA:S,occB:C}of c){let k=$e(S),b=$e(C);d.set(k,S),d.set(b,C),m.union(k,b)}let y=new Map;for(let S of d.keys()){let C=m.root(S),k=y.get(C);k?k.add(S):y.set(C,new Set([S]))}let x=[];for(let S of y.values()){if(S.size<2)continue;let C=[...S].map(v=>d.get(v)),k=0,b=e;for(let v of c)!S.has($e(v.occA))||!S.has($e(v.occB))||v.lines>k&&(k=v.lines,b=v.tokens);x.push({occurrences:C,lines:k,tokens:b})}return{groups:x.sort((S,C)=>C.lines-S.lines),skippedBuckets:p}}var Ht,ec,rc,Un=u(()=>{"use strict";l();Ht=class{parent=new Map;find(e){this.parent.has(e)||this.parent.set(e,e);let r=e;for(;this.parent.get(r)!==r;)r=this.parent.get(r);let n=e;for(;n!==r;){let o=this.parent.get(n);this.parent.set(n,r),n=o}return r}union(e,r){let n=this.find(e),o=this.find(r);n!==o&&this.parent.set(n,o)}root(e){return this.find(e)}};ec=new Set(["{","}",":",",","[","]"]);rc=400});import Kn from"postcss";import*as nc from"postcss-less";function Jn(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function sc(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function ic(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let s=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=Hn.has(s)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...Jn(i)?{isExternal:!0}:{}}}let n=t.match(/^url\(['"]?([^'")]+)['"]?\)/),o=n?n[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return o?{fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static",...Jn(o)?{isExternal:!0}:{}}:null}function ac(t,e){let r=[],n=/url\(['"]?([^'")]+)['"]?\)/g,o=n.exec(t);for(;o!==null;){let s=o[1]?.trim()??"";sc(s)&&r.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!0,type:"static"}),o=n.exec(t)}return r}function Vn(t,e){let r=[];return t.walk(n=>{if(n.type==="atrule"&&n.name==="import"){let o=ic(n.params,e);o&&r.push(o)}n.type==="decl"&&r.push(...ac(n.value,e))}),r}function cc(t){return t.replace(/(?<!:)\/\/.*/g,"")}function lc(t,e){let r=[],n=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,o=n.exec(t);for(;o!==null;){let s=o[1]?.trim()??"",i=o[2]??"";if(i){let a=Hn.has(s)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}o=n.exec(t)}return r}function Be(t,e){let r=Kn.parse(cc(t));return{imports:Vn(r,e),root:r}}function pc(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type!=="atrule")continue;let{value:o}=n;if(o===void 0)continue;let s=n.name;s&&(e.push({name:s}),r.push({name:s,kind:"variable"}))}return{exports:e,tags:r}}function Ue(t,e){try{let r=oc.parse(t),{exports:n,tags:o}=pc(r);return{imports:Vn(r,e),root:r,exports:n,tags:o}}catch{return{imports:lc(t,e),root:Kn.parse(""),exports:[],tags:[]}}}var oc,Hn,Vt=u(()=>{"use strict";l();oc=nc,Hn=new Set(["reference","inline"])});import{parse as fc}from"postcss-scss";function Qn(t){return t.startsWith("_")||t.startsWith("-")}function mc(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function uc(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],o=t.match(/\bas\s+(\S+)/)?.[1];return o!==void 0?{specifier:r,alias:o}:{specifier:r}}function gc(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type==="decl"&&n.prop.startsWith("$")){let o=n.prop.slice(1);if(!o||Qn(o))continue;e.push({name:o}),r.push({name:o,kind:"variable"});continue}if(n.type==="atrule"&&(n.name==="mixin"||n.name==="function")){let s=n.params.match(/^([\w-]+)/)?.[1];if(!s||Qn(s))continue;let i=n.params.trim();e.push(i.includes("(")?{name:s,signature:i}:{name:s}),r.push({name:s,kind:"function"})}}return{exports:e,tags:r}}function Je(t,e){let r=fc(t),n=[];r.walk(i=>{if(i.type!=="atrule")return;let{name:a,params:c}=i;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:p,alias:m}=uc(c);if(!p)return;let d={fromPath:e,toPath:"",rawSpecifier:p,isStyle:!0,type:a==="forward"?"re-export":"static",...mc(p)?{isExternal:!0}:{}};m&&(d.symbols=[m]),n.push(d)});let{exports:o,tags:s}=gc(r);return{imports:n,root:r,exports:o,tags:s}}var Qt=u(()=>{"use strict";l()});function dc(t){return t.trim().replace(/\s+/g," ")}function hc(t){try{return t.fileType==="scss"?Je(t.source,t.file).root:t.fileType==="less"?Ue(t.source,t.file).root:t.fileType==="css"?Be(t.source,t.file).root:void 0}catch{return}}function yc(t){let e=hc(t);if(!e)return[];let r=[];return e.walkRules(n=>{let o=n.nodes?.filter(m=>m.type==="decl")??[];if(o.length===0)return;let s=o[0],i=o[o.length-1],a=n.source?.start?.line??s?.source?.start?.line,c=i?.source?.end?.line??i?.source?.start?.line??a;if(a===void 0||c===void 0)return;let p=o.map(m=>`${m.prop.trim().toLowerCase()}:${dc(m.value)}`).join(";");r.push({file:t.file,startLine:a,endLine:c,lines:c-a+1,signature:p,declCount:o.length})}),r}function Yn(t,e,r=2){let n=new Map;for(let s of t)for(let i of yc(s)){if(i.declCount<r||i.lines<e)continue;let a=n.get(i.signature);a?a.push(i):n.set(i.signature,[i])}let o=[];for(let s of n.values())for(let i=0;i<s.length;i++)for(let a=i+1;a<s.length;a++){let c=s[i],p=s[a];if(c.file===p.file&&c.startLine===p.startLine&&c.endLine===p.endLine)continue;let m={file:c.file,startLine:c.startLine,endLine:c.endLine},d={file:p.file,startLine:p.startLine,endLine:p.endLine};o.push({occurrences:[m,d],lines:Math.min(c.lines,p.lines),tokens:c.declCount,family:"style"})}return o.sort((s,i)=>i.lines-s.lines)}var Xn=u(()=>{"use strict";l();Vt();Qt()});function qn(t,e,r){let n=t.slice(e,r).replace(/[^\n]/g," ");return t.slice(0,e)+n+t.slice(r)}function bc(t,e){if(!e)return t;let r=t;for(let[n,o]of e.block??[]){let s=0;for(;;){let i=r.indexOf(n,s);if(i===-1)break;let a=r.indexOf(o,i+n.length),c=a===-1?r.length:a+o.length;r=qn(r,i,c),s=c}}for(let n of e.line??[]){let o=0;for(;;){let s=r.indexOf(n,o);if(s===-1)break;let i=r.indexOf(`
5
- `,s),a=i===-1?r.length:i;r=qn(r,s,a),o=a}}return r}function eo(t,e,r=!0){let n=bc(t,xc[e]),o=[],s=1,i=0;Yt.lastIndex=0;let a=Yt.exec(n);for(;a!==null;){for(let m=i;m<a.index;m++)n[m]===`
6
- `&&s++;i=a.index;let c=a[0],p=c;Cc.test(c)&&!kc.has(c)?p="ID":r&&(Zn.test(c)||vc.test(c))&&(p=Zn.test(c)?"NUM":"STR"),o.push({text:p,line:s});for(let m=i;m<a.index+c.length;m++)n[m]===`
7
- `&&s++;i=a.index+c.length,a=Yt.exec(n)}return o}var xc,Sc,Yt,Cc,Zn,vc,kc,to=u(()=>{"use strict";l();xc={typescript:{line:["//"],block:[["/*","*/"]]},javascript:{line:["//"],block:[["/*","*/"]]},go:{line:["//"],block:[["/*","*/"]]},css:{block:[["/*","*/"]]},scss:{line:["//"],block:[["/*","*/"]]},less:{line:["//"],block:[["/*","*/"]]},stylus:{line:["//"],block:[["/*","*/"]]},python:{line:["#"]},gherkin:{line:["#"]},coffeescript:{line:["#"],block:[["###","###"]]},livescript:{line:["#"],block:[["###","###"]]},lua:{line:["--"],block:[["--[[","]]"]]},markdown:{block:[["<!--","-->"]]}};Sc=["===","!==","...","=>","==","!=","<=",">=","&&","||","::","->","..","+=","-=","*=","/="],Yt=new RegExp(`${Sc.map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}|[A-Za-z_$][A-Za-z0-9_$]*|\\d+(?:\\.\\d+)?|"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`|\\S`,"g"),Cc=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Zn=/^\d+(?:\.\d+)?$/,vc=/^(".*"|'.*'|`.*`)$/s,kc=new Set(["if","else","elif","for","while","do","switch","case","default","break","continue","return","function","def","class","struct","interface","const","let","var","local","import","export","from","package","try","catch","except","finally","throw","raise","new","this","self","end","then","yield","async","await","nil","null","None","true","false","True","False","and","or","not","in","of","is"])});import{readFile as wc}from"fs/promises";import Ke from"path";import Ec from"piscina";function Nc(t){return Jt.includes(Ke.basename(t))}function Pc(t,e){if(e.length===0)return!1;let r=new Set(e);return t.split(Ke.sep).some(n=>r.has(n))}async function Xt(t,e,r={}){let{minLines:n=6,windowSize:o=15,ignoreLiterals:s=!0,maxPunctuationRatio:i=.5,maxBucketSize:a,limit:c=50,ignoreDirs:p=J,parallelTokenizing:m=!0}=r,d=[...t.nodes.values()].filter(x=>!Nc(x.path)&&!Pc(x.path,p)),y=Ic(m,d.length);try{let x=[],S=new Map;await Promise.all(d.map(async b=>{let v;try{v=await wc(Ke.join(e,b.path),"utf8")}catch{return}if(Tc.has(b.type)){x.push({file:b.path,source:v,fileType:b.type});return}let P=zn(b.type),A=y?await y.run({source:v,fileType:b.type,ignoreLiterals:s}):eo(v,b.type,s),te={file:b.path,tokens:A},me=S.get(P);me?me.push(te):S.set(P,[te])}));let C=Yn(x,n),k=0;for(let[b,v]of S){let P=Bn(v,o,n,i,a);k+=P.skippedBuckets;for(let A of P.groups)C.push({...A,family:b})}return{groups:C.sort((b,v)=>v.lines-b.lines).slice(0,c),skippedBuckets:k}}finally{y&&await y.destroy()}}function Ic(t,e){if(t===!1)return null;let r=typeof t=="object"?t:{},n=r.minFiles??Fc;if(e<n)return null;try{return new Ec({filename:Ke.join(f,"duplication-worker.js"),...r.maxThreads!==void 0?{maxThreads:r.maxThreads}:{}})}catch(o){return process.stderr.write(`
2
+ var wt=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var m=(t,e)=>()=>(t&&(e=t(t=0)),e);var Ta=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);import Fa from"path";import{fileURLToPath as Na}from"url";var Pa,Ia,u,l=m(()=>{"use strict";Pa=()=>Na(import.meta.url),Ia=()=>Fa.dirname(Pa()),u=Ia()});function Oe(t){Sn.push(t)}function Cn(t){return[...Da,...Sn].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}function Ge(t){kn.push(t)}function ue(){return[...Ma,...kn]}function _e(t){vn.push(t)}function Et(){return[...Aa,...vn]}function Tt(t){wn=t}function Ft(){return wn}var Da,Sn,Ma,kn,Aa,vn,wn,re=m(()=>{"use strict";l();Da=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],Sn=[];Ma=[".test.",".spec.","-test.","-spec."],kn=[];Aa=["jest","vitest","playwright","cypress","@testing-library/"],vn=[];wn=.8});import Nt from"fs";import En from"path";function ne(t,{allowJs:e=!0,isExplicitPath:r=!1}={}){if(r){let n=En.resolve(t);return Nt.existsSync(n)?n.endsWith(".json")?Tn(n):e?Fn(n):{}:{}}for(let n of La){let o=En.resolve(t,n);if(Nt.existsSync(o)){if(n.endsWith(".json"))return Tn(o);if(e)return Fn(o)}}return{}}function Tn(t){return JSON.parse(Nt.readFileSync(t,"utf-8"))}function Fn(t){let e=wt(t);return e&&typeof e=="object"&&"default"in e&&(e=e.default),typeof e=="function"?e({}):e}function Pt(t){for(let e of t.configMatchers??[])Oe(e);for(let e of t.testPatterns??[])Ge(e);for(let e of t.testLibraries??[])_e(e);t.barrelThreshold!==void 0&&Tt(t.barrelThreshold)}function N(t){return{gitStats:t?.gitStats??!1,parallelParsing:t?.parallelParsing,pathAliases:t?.pathAliases}}var La,It=m(()=>{"use strict";l();re();La=["mokosh.config.js","mokosh.config.cjs","mokosh.config.json"]});var J,Dt,je=m(()=>{"use strict";l();J=["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"],Dt=[".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".go",".feature",".md",".mdx"]});import du from"fs";import yu from"path";var Nn=m(()=>{"use strict";l()});var We,Pn=m(()=>{"use strict";l();We={serialize(t){let e=["graph TD"],r=new Set;for(let n of t.nodes.values()){let o=`"${n.path}"`;for(let s of n.imports){if(!s.toPath)continue;let i=`"${s.toPath}"`,a=`${n.path} -> ${s.toPath}`;if(!r.has(a)){let c=s.isStyle?"-- styles -->":"-->";e.push(` ${o} ${c} ${i}`),r.add(a)}}}return e.join(`
3
+ `)}}});var In=m(()=>{"use strict";l();Pn()});import Dn from"fs";import Oa from"path";function Mt(t,e){let r=t.replace(/^\.\//,"");if(e.nodes.has(r))return r;let n=r.replace(/^dist\//,"src/").replace(/\.(js|mjs|cjs)$/,".ts");return e.nodes.has(n)?n:null}function Mn(t,e){if(typeof t=="string")return Mt(t,e);if(t&&typeof t=="object"){let r=t;for(let n of["import","require","default"]){let o=Mn(r[n],e);if(o)return o}}return null}function Ga(t){if(!t)return"unknown";let e=t.trimStart();return e.startsWith("interface ")?"interface":e.startsWith("class ")?"class":e.startsWith("enum ")?"enum":e.startsWith("type ")?"type":e.startsWith("namespace ")?"namespace":e.startsWith("const ")||e.startsWith("let ")||e.startsWith("var ")||e.startsWith("readonly ")?"const":e.startsWith("(")||e.startsWith("async ")||e.startsWith("function ")||e.includes("=>")?"function":"unknown"}function _a(t,e){let r=new Set,n=new Set,o=[...e];for(;o.length;){let s=o.shift();if(n.has(s))continue;n.add(s);let i=t.nodes.get(s);if(i){for(let a of i.exports)r.add(a.name);for(let a of i.imports){if(a.type!=="re-export"||a.isExternal||!a.toPath)continue;if(!a.symbols?.length||a.symbols.includes("*")){let p=t.nodes.get(a.toPath);if(p)for(let f of p.exports)r.add(f.name);o.push(a.toPath)}else for(let p of a.symbols)r.add(p)}}}return r}function At(t,e){let r=[],n=Oa.join(e,"package.json");if(Dn.existsSync(n))try{let o=JSON.parse(Dn.readFileSync(n,"utf8"));if(o.exports&&typeof o.exports=="object"&&!Array.isArray(o.exports))for(let s of Object.values(o.exports)){let i=Mn(s,t);i&&!r.includes(i)&&r.push(i)}else if(typeof o.exports=="string"){let s=Mt(o.exports,t);s&&r.push(s)}if(r.length===0)for(let s of[o.main,o.module].filter(Boolean)){let i=Mt(s,t);i&&!r.includes(i)&&r.push(i)}}catch{}if(r.length===0){for(let o of["src/index.ts","src/index.js","index.ts","index.js"])if(t.nodes.has(o)){r.push(o);break}}return r}function ja(t,e){let r=new Set(e);for(let n of e)t.traverse(n,o=>(r.add(o.path),!0),{direction:"outgoing"});return r}function Wa(t,e,r){let n=new Map;for(let o of e){if(r.includes(o))continue;let s=t.nodes.get(o);if(!s)continue;let i=s.category==="barrel";for(let a of s.exports){let c=n.get(a.name),p=!!(a.signature||a.doc);(!c||p&&!i)&&n.set(a.name,{file:o,symbol:a})}}return n}function za(t,e,r,n){let o=[];for(let s of t){let i=e.get(s),a=n.flatMap(d=>r.nodes.get(d)?.exports??[]).find(d=>d.name===s),c=i?.symbol??a,p=i?.file??n.find(d=>r.nodes.get(d)?.exports.some(y=>y.name===s))??n[0],f={name:s,definedIn:p,kind:Ga(c?.signature)};c?.doc&&(f.doc=c.doc),c?.signature&&(f.signature=c.signature),o.push(f)}return o.sort((s,i)=>s.name.localeCompare(i.name)),o}function $a(t,e,r){let n=c=>t.nodes.get(c)?.category==="test",o=[...e].filter(c=>!r.includes(c)&&!n(c)),s=[...t.nodes.keys()].filter(c=>!e.has(c)),i=s.filter(c=>!n(c)),a=s.filter(c=>n(c));return{internalFiles:o,unreachableFromEntry:i,testFiles:a}}function Lt(t,e){if(e.length===0)throw new Error("buildApiSurface requires at least one entry point");for(let p of e)if(!t.nodes.has(p))throw new Error(`Entry point not found in graph: ${p}`);let r=ja(t,e),n=Wa(t,r,e),o=_a(t,e),s=za(o,n,t,e),{internalFiles:i,unreachableFromEntry:a,testFiles:c}=$a(t,r,e);return{entryPoints:e,publicExports:s,internalFiles:i,unreachableFromEntry:a,testFiles:c}}var Rt=m(()=>{"use strict";l()});function Ot(t,e){let r=null,n=[];for(let s of t.nodes.values()){s.exports.some(i=>i.name===e)&&(r=s.path);for(let i of s.callEdges??[])i.to===e&&n.push({file:s.path,callerFunction:i.from})}let o=[];if(r){let s=t.nodes.get(r);for(let i of s?.callEdges??[])i.from===e&&o.push({file:i.toFile,calleeFunction:i.to})}return{functionName:e,definedIn:r,callers:n,callees:o}}var Gt=m(()=>{"use strict";l()});import Mu from"fs";import Lu from"path";function An(t){let e=[...t.nodes.entries()].sort(([n],[o])=>n.localeCompare(o)).map(([n,o])=>`${n}:${o.mtime}:${o.size}`).join("|"),r=2166136261;for(let n=0;n<e.length;n++)r^=e.charCodeAt(n),r=Math.imul(r,16777619)>>>0;return r.toString(16).padStart(8,"0")}function _t(t){let e=new Map;for(let r of t.nodes.keys()){let n=[];t.traverse(r,o=>(o.path!==r&&n.push(o.path),!0),{direction:"incoming"}),e.set(r,n)}return{impact:e,graphHash:An(t)}}function jt(t,e){return t.impact.get(e)??[]}var Wt=m(()=>{"use strict";l()});import ze from"fs";import Ba from"path";import{load as Ln}from"js-yaml";function Rn(t){let e=t.lastIndexOf("@");return e>0?t.substring(0,e):t}function Ua(t){return t.replace(/:$/,"").split(",").map(e=>{let r=e.trim();return r.startsWith('"')&&(r=r.slice(1)),r.endsWith('"')&&(r=r.slice(0,-1)),Rn(r)}).filter(Boolean)}function Ja(t,e){let r=t.startsWith("/")?t.slice(1):t,n=r.lastIndexOf("@");return n>0?{name:r.substring(0,n),version:e||r.substring(n+1)}:{name:r,version:e}}function Ka(t){try{let e=Ln(t),r={dependencies:{}};for(let[n,o]of Object.entries(e))if(!(n==="__metadata"||!o?.version))for(let s of n.split(", ")){let i=Rn(s);i&&(r.dependencies[i]={version:o.version,...o.dependencies!==void 0&&{dependencies:o.dependencies}})}return r}catch{return null}}function Ha(t){let e={dependencies:{}};for(let r of t.split(/\n\n+/)){let n=r.split(`
4
+ `).filter(c=>c.trim().length>0&&!c.trim().startsWith("#"));if(n.length<2)continue;let o=n[0];if(!o||o.startsWith(" "))continue;let s=Ua(o);if(s.length===0)continue;let a=n.find(c=>c.trim().startsWith('version "'))?.match(/version "(.*?)"/)?.[1]??"";for(let c of s)e.dependencies[c]={version:a}}return e}function Va(t){let e=ze.readFileSync(t,"utf-8"),r=JSON.parse(e),n={dependencies:{}};if(r.packages)for(let[o,s]of Object.entries(r.packages)){if(!o.startsWith("node_modules/"))continue;let i=o.replace("node_modules/","");i.includes("node_modules/")||(n.dependencies[i]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}else if(r.dependencies)for(let[o,s]of Object.entries(r.dependencies))n.dependencies[o]={version:s.version,...s.dependencies!==void 0&&{dependencies:s.dependencies}};return n}function Qa(t){let e=ze.readFileSync(t,"utf-8");if(e.includes("__metadata:")){let r=Ka(e);if(r!==null)return r}return Ha(e)}function Ya(t){let e=ze.readFileSync(t,"utf-8"),r={dependencies:{}};try{let n=Ln(e);if(n.packages)for(let[o,s]of Object.entries(n.packages)){let{name:i,version:a}=Ja(o,s.version);i&&(r.dependencies[i]={version:a,...s.dependencies!==void 0&&{dependencies:s.dependencies}})}if(n.dependencies)for(let[o,s]of Object.entries(n.dependencies)){if(r.dependencies[o])continue;let i=typeof s=="string"?s:s.version;r.dependencies[o]={version:i||""}}}catch{}return r}function On(t){let e={"package-lock.json":Va,"yarn.lock":Qa,"pnpm-lock.yaml":Ya},r=zt.map(n=>[n,e[n]]);for(let[n,o]of r){let s=Ba.join(t,n);if(ze.existsSync(s))return o(s)}return null}var zt,$t=m(()=>{"use strict";l();zt=["package-lock.json","yarn.lock","pnpm-lock.yaml"]});function Gn(t){return Xa.has(t)?"style":"code"}var Xa,_n=m(()=>{"use strict";l();Xa=new Set(["css","scss","less","stylus"])});import Wn from"postcss";import*as qa from"postcss-less";function jn(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function ec(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function tc(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let s=r[1]?.trim()??"",i=r[2]??"";if(!i)return null;let a=zn.has(s)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a,...jn(i)?{isExternal:!0}:{}}}let n=t.match(/^url\(['"]?([^'")]+)['"]?\)/),o=n?n[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return o?{fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static",...jn(o)?{isExternal:!0}:{}}:null}function rc(t,e){let r=[],n=/url\(['"]?([^'")]+)['"]?\)/g,o=n.exec(t);for(;o!==null;){let s=o[1]?.trim()??"";ec(s)&&r.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!0,type:"static"}),o=n.exec(t)}return r}function $n(t,e){let r=[];return t.walk(n=>{if(n.type==="atrule"&&n.name==="import"){let o=tc(n.params,e);o&&r.push(o)}n.type==="decl"&&r.push(...rc(n.value,e))}),r}function nc(t){return t.replace(/(?<!:)\/\/.*/g,"")}function oc(t,e){let r=[],n=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,o=n.exec(t);for(;o!==null;){let s=o[1]?.trim()??"",i=o[2]??"";if(i){let a=zn.has(s)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:a})}o=n.exec(t)}return r}function $e(t,e){let r=Wn.parse(nc(t));return{imports:$n(r,e),root:r}}function sc(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type!=="atrule")continue;let{value:o}=n;if(o===void 0)continue;let s=n.name;s&&(e.push({name:s}),r.push({name:s,kind:"variable"}))}return{exports:e,tags:r}}function Be(t,e){try{let r=Za.parse(t),{exports:n,tags:o}=sc(r);return{imports:$n(r,e),root:r,exports:n,tags:o}}catch{return{imports:oc(t,e),root:Wn.parse(""),exports:[],tags:[]}}}var Za,zn,Bt=m(()=>{"use strict";l();Za=qa,zn=new Set(["reference","inline"])});import{parse as ic}from"postcss-scss";function Bn(t){return t.startsWith("_")||t.startsWith("-")}function ac(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function cc(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],o=t.match(/\bas\s+(\S+)/)?.[1];return o!==void 0?{specifier:r,alias:o}:{specifier:r}}function lc(t){let e=[],r=[];for(let n of t.nodes??[]){if(n.type==="decl"&&n.prop.startsWith("$")){let o=n.prop.slice(1);if(!o||Bn(o))continue;e.push({name:o}),r.push({name:o,kind:"variable"});continue}if(n.type==="atrule"&&(n.name==="mixin"||n.name==="function")){let s=n.params.match(/^([\w-]+)/)?.[1];if(!s||Bn(s))continue;let i=n.params.trim();e.push(i.includes("(")?{name:s,signature:i}:{name:s}),r.push({name:s,kind:"function"})}}return{exports:e,tags:r}}function Ue(t,e){let r=ic(t),n=[];r.walk(i=>{if(i.type!=="atrule")return;let{name:a,params:c}=i;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:p,alias:f}=cc(c);if(!p)return;let d={fromPath:e,toPath:"",rawSpecifier:p,isStyle:!0,type:a==="forward"?"re-export":"static",...ac(p)?{isExternal:!0}:{}};f&&(d.symbols=[f]),n.push(d)});let{exports:o,tags:s}=lc(r);return{imports:n,root:r,exports:o,tags:s}}var Ut=m(()=>{"use strict";l()});function pc(t){return t.trim().replace(/\s+/g," ")}function fc(t){try{return t.fileType==="scss"?Ue(t.source,t.file).root:t.fileType==="less"?Be(t.source,t.file).root:t.fileType==="css"?$e(t.source,t.file).root:void 0}catch{return}}function uc(t){let e=fc(t);if(!e)return[];let r=[];return e.walkRules(n=>{let o=n.nodes?.filter(f=>f.type==="decl")??[];if(o.length===0)return;let s=o[0],i=o[o.length-1],a=n.source?.start?.line??s?.source?.start?.line,c=i?.source?.end?.line??i?.source?.start?.line??a;if(a===void 0||c===void 0)return;let p=o.map(f=>`${f.prop.trim().toLowerCase()}:${pc(f.value)}`).join(";");r.push({file:t.file,startLine:a,endLine:c,lines:c-a+1,signature:p,declCount:o.length})}),r}function Un(t,e,r=2){let n=new Map;for(let s of t)for(let i of uc(s)){if(i.declCount<r||i.lines<e)continue;let a=n.get(i.signature);a?a.push(i):n.set(i.signature,[i])}let o=[];for(let s of n.values())for(let i=0;i<s.length;i++)for(let a=i+1;a<s.length;a++){let c=s[i],p=s[a];if(c.file===p.file&&c.startLine===p.startLine&&c.endLine===p.endLine)continue;let f={file:c.file,startLine:c.startLine,endLine:c.endLine},d={file:p.file,startLine:p.startLine,endLine:p.endLine};o.push({occurrences:[f,d],lines:Math.min(c.lines,p.lines),tokens:c.declCount,family:"style"})}return o.sort((s,i)=>i.lines-s.lines)}var Jn=m(()=>{"use strict";l();Bt();Ut()});function Kn(t){let e=t.length,r=[],n=[{lcpLength:0,low:0}];for(let o=1;o<e;o++){let s=o-1;for(;t[o]<n[n.length-1].lcpLength;){let i=n.pop();r.push({lcpLength:i.lcpLength,low:i.low,high:o-1}),s=i.low}t[o]>n[n.length-1].lcpLength&&n.push({lcpLength:t[o],low:s})}for(;n.length>1;){let o=n.pop();r.push({lcpLength:o.lcpLength,low:o.low,high:e-1})}return r}var Hn=m(()=>{"use strict";l()});function Vn(t,e,r){let n=0;for(let o=e;o<e+r;o++)mc.has(t[o].text)&&n++;return n/r}var mc,Qn=m(()=>{"use strict";l();mc=new Set(["{","}",":",",","[","]"])});function Yn(t){let e=t.length;if(e===0)return[];let r=Array.from({length:e},(s,i)=>i),n=new Array(e);{let s=[...new Set(t)].sort(),i=new Map(s.map((a,c)=>[a,c]));for(let a=0;a<e;a++)n[a]=i.get(t[a])}let o=new Array(e).fill(0);for(let s=1;s<e;s*=2){let i=a=>a+s<e?n[a+s]:-1;r.sort((a,c)=>{let p=n[a]-n[c];return p!==0?p:i(a)-i(c)}),o[r[0]]=0;for(let a=1;a<e;a++){let c=r[a-1],p=r[a],f=n[c]===n[p],d=i(c)===i(p);o[p]=o[c]+(f&&d?0:1)}if([n,o]=[o,n],n[r[e-1]]===e-1)break}return r}function Xn(t,e){let r=t.length,n=new Array(r).fill(0);if(r===0)return n;let o=new Array(r);for(let i=0;i<r;i++)o[e[i]]=i;let s=0;for(let i=0;i<r;i++){let a=o[i];if(a>0){let c=e[a-1];for(;i+s<r&&c+s<r&&t[i+s]===t[c+s];)s++;n[a]=s,s>0&&s--}else s=0}return n}var qn=m(()=>{"use strict";l()});function Zn(t,e,r,n=.5){let o=[],s=[],i=new Map;for(let{file:d,tokens:y}of t)if(y.length!==0){i.set(d,y);for(let x=0;x<y.length;x++)o.push(y[x].text),s.push({file:d,localIndex:x});o.push(` ${d}`),s.push({file:d,localIndex:-1})}if(o.length===0)return[];let a=Yn(o),c=Xn(o,a),p=Kn(c),f=[];for(let d of p){let y=gc(d,a,s,i,e,r,n);y&&f.push(y)}return f.sort((d,y)=>y.lines-d.lines)}function gc(t,e,r,n,o,s,i){if(t.lcpLength<o)return;let a=[];for(let x=t.low;x<=t.high;x++){let v=r[e[x]];v.localIndex!==-1&&a.push(v)}if(a.length<2||!dc(a,n))return;let c=hc(a,t.lcpLength);if(c.length<2)return;let p=c[0],f=n.get(p.file);if(Vn(f,p.localIndex,t.lcpLength)>i)return;let d=c.map(({file:x,localIndex:v})=>{let C=n.get(x);return{file:x,startLine:C[v].line,endLine:C[v+t.lcpLength-1].line}}),y=Math.min(...d.map(x=>x.endLine-x.startLine+1));if(!(y<s))return{occurrences:d,lines:y,tokens:t.lcpLength}}function dc(t,e){let r=null;for(let{file:n,localIndex:o}of t){if(o===0)return!0;let i=e.get(n)[o-1].text;if(r===null)r=i;else if(r!==i)return!0}return!1}function hc(t,e){let r=new Map;for(let{file:o,localIndex:s}of t){let i=r.get(o);i?i.push(s):r.set(o,[s])}let n=[];for(let[o,s]of r){s.sort((a,c)=>a-c);let i=Number.NEGATIVE_INFINITY;for(let a of s)a>=i&&(n.push({file:o,localIndex:a}),i=a+e)}return n}var eo=m(()=>{"use strict";l();Hn();Qn();qn()});function to(t,e,r){let n=t.slice(e,r).replace(/[^\n]/g," ");return t.slice(0,e)+n+t.slice(r)}function xc(t,e){if(!e)return t;let r=t;for(let[n,o]of e.block??[]){let s=0;for(;;){let i=r.indexOf(n,s);if(i===-1)break;let a=r.indexOf(o,i+n.length),c=a===-1?r.length:a+o.length;r=to(r,i,c),s=c}}for(let n of e.line??[]){let o=0;for(;;){let s=r.indexOf(n,o);if(s===-1)break;let i=r.indexOf(`
5
+ `,s),a=i===-1?r.length:i;r=to(r,s,a),o=a}}return r}function no(t,e,r=!0){let n=xc(t,yc[e]),o=[],s=1,i=0;Jt.lastIndex=0;let a=Jt.exec(n);for(;a!==null;){for(let f=i;f<a.index;f++)n[f]===`
6
+ `&&s++;i=a.index;let c=a[0],p=c;Sc.test(c)&&!kc.has(c)?p="ID":r&&(ro.test(c)||Cc.test(c))&&(p=ro.test(c)?"NUM":"STR"),o.push({text:p,line:s});for(let f=i;f<a.index+c.length;f++)n[f]===`
7
+ `&&s++;i=a.index+c.length,a=Jt.exec(n)}return o}var yc,bc,Jt,Sc,ro,Cc,kc,oo=m(()=>{"use strict";l();yc={typescript:{line:["//"],block:[["/*","*/"]]},javascript:{line:["//"],block:[["/*","*/"]]},go:{line:["//"],block:[["/*","*/"]]},css:{block:[["/*","*/"]]},scss:{line:["//"],block:[["/*","*/"]]},less:{line:["//"],block:[["/*","*/"]]},stylus:{line:["//"],block:[["/*","*/"]]},python:{line:["#"]},gherkin:{line:["#"]},coffeescript:{line:["#"],block:[["###","###"]]},livescript:{line:["#"],block:[["###","###"]]},lua:{line:["--"],block:[["--[[","]]"]]},markdown:{block:[["<!--","-->"]]}};bc=["===","!==","...","=>","==","!=","<=",">=","&&","||","::","->","..","+=","-=","*=","/="],Jt=new RegExp(`${bc.map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}|[A-Za-z_$][A-Za-z0-9_$]*|\\d+(?:\\.\\d+)?|"(?:\\\\.|[^"\\\\])*"|'(?:\\\\.|[^'\\\\])*'|\`(?:\\\\.|[^\`\\\\])*\`|\\S`,"g"),Sc=/^[A-Za-z_$][A-Za-z0-9_$]*$/,ro=/^\d+(?:\.\d+)?$/,Cc=/^(".*"|'.*'|`.*`)$/s,kc=new Set(["if","else","elif","for","while","do","switch","case","default","break","continue","return","function","def","class","struct","interface","const","let","var","local","import","export","from","package","try","catch","except","finally","throw","raise","new","this","self","end","then","yield","async","await","nil","null","None","true","false","True","False","and","or","not","in","of","is"])});import{readFile as so}from"fs/promises";import me from"path";import vc from"piscina";function Tc(t){return zt.includes(me.basename(t))}function Fc(t,e){if(e.length===0)return!1;let r=new Set(e);return t.split(me.sep).some(n=>r.has(n))}async function Kt(t,e,r={}){let{minLines:n=6,windowSize:o=15,ignoreLiterals:s=!0,maxPunctuationRatio:i=.5,limit:a=50,ignoreDirs:c=J,parallelTokenizing:p=!0,tokenCache:f}=r,d=[...t.nodes.values()].filter(x=>!Tc(x.path)&&!Fc(x.path,c)),y=Nc(p,d.length);try{let x=[],v=new Map;if(await Promise.all(d.map(async b=>{if(Ec.has(b.type)){let te;try{te=await so(me.join(e,b.path),"utf8")}catch{return}x.push({file:b.path,source:te,fileType:b.type});return}let w=f?.get(b.path),G=w&&w.mtime===b.mtime&&w.size===b.size&&w.ignoreLiterals===s,O;if(G)O=w.tokens;else{let te;try{te=await so(me.join(e,b.path),"utf8")}catch{return}O=y?await y.run({source:te,fileType:b.type,ignoreLiterals:s}):no(te,b.type,s),f?.set(b.path,{mtime:b.mtime,size:b.size,ignoreLiterals:s,tokens:O})}let U=Gn(b.type),xn={file:b.path,tokens:O},bn=v.get(U);bn?bn.push(xn):v.set(U,[xn])})),f){let b=new Set(d.map(w=>w.path));for(let w of f.keys())b.has(w)||f.delete(w)}let C=Un(x,n);for(let[b,w]of v)for(let G of Zn(w,o,n,i))C.push({...G,family:b});return{groups:C.sort((b,w)=>w.lines-b.lines).slice(0,a)}}finally{y&&await y.destroy()}}function Nc(t,e){if(t===!1)return null;let r=typeof t=="object"?t:{},n=r.minFiles??wc;if(e<n)return null;try{return new vc({filename:me.join(u,"duplication-worker.js"),...r.maxThreads!==void 0?{maxThreads:r.maxThreads}:{}})}catch(o){return process.stderr.write(`
8
8
  Warning: failed to start duplicate-detection worker pool, falling back to synchronous tokenizing: ${o}
9
- `),null}}var Fc,Tc,qt=u(()=>{"use strict";l();je();Kt();$n();Un();Xn();to();Fc=20,Tc=new Set(["css","scss","less"])});import He from"path";function Dc(t){let e=new Map;for(let[r,n]of t){let o=n.imports.filter(s=>s.toPath&&!s.isExternal).length;o>0&&e.set(r,o)}return e}function Mc(t,e,r){let n=new Map;for(let[o,s]of e){if(s<r)continue;let i=t.get(o);if(!i||i.category==="test"||i.category==="barrel")continue;let a=He.extname(o),c=He.basename(o,a),p=c==="index"?He.basename(He.dirname(o)):c;n.set(o,{path:o,outDegree:s,tag:`feature:${p}`})}return n}function K(t,e){let r=e?.minOutDegree??5;return Mc(t,Dc(t),r)}var Ve=u(()=>{"use strict";l()});function Rc(t,e){let r=new Map;for(let n of e.values()){let o=new Set;t.traverse(n.path,s=>(s.path!==n.path&&o.add(s.path),!0),{direction:"outgoing"}),r.set(n.path,o)}return r}function Lc(t,e,r,n){let o=new Map;for(let[s]of t){if(e.has(s))continue;let i=null;for(let a of e.values())r.get(a.path)?.has(s)&&(!i||n(a,i)<0)&&(i=a);i&&o.set(s,i.path)}return o}function Oc(t,e){let r=new Map;for(let n of t.values()){let o=n.tag.replace("feature:",""),s=[];for(let[i,a]of e)a===n.path&&s.push(i);r.set(o,{hub:n.path,outDegree:n.outDegree,files:s})}return r}function Gc(t,e,r){let n=[];for(let o of t.keys())!e.has(o)&&!r.has(o)&&n.push(o);return n}function ge(t,e){let r=e?.detectFn??K,n=e?.hubComparator??Ac,o=r(t.nodes,e),s=Rc(t,o),i=Lc(t.nodes,o,s,n);return{features:Oc(o,i),unassigned:Gc(t.nodes,o,i)}}var Ac,Qe=u(()=>{"use strict";l();Ve();Ac=(t,e)=>t.outDegree-e.outDegree});function Zt(t){let e=new Map;for(let r of t.nodes.values())e.set(r.type,(e.get(r.type)??0)+1);return[...e.entries()].map(([r,n])=>({type:r,fileCount:n,exportsTracked:ro.has(r),importSymbolsTracked:no.has(r),callEdgesTracked:Ye.has(r)})).sort((r,n)=>n.fileCount-r.fileCount)}var ro,no,Ye,er=u(()=>{"use strict";l();ro=new Set(["typescript","javascript","python","go","scss","less","lua","coffeescript"]),no=new Set(["typescript","javascript","python"]),Ye=new Set(["typescript","javascript","go","python"])});var de,oo=u(()=>{"use strict";l();de=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let r=new Set(this.nodes.keys());return e.filter(n=>!r.has(n))}findHighExportUsage(e){let r=[];for(let n of this.nodes.values()){if(n.maxExportUsage===void 0||n.maxExportUsage<e)continue;let o=n.imports.reduce((s,i)=>(i.exportUsageRatio??0)>(s?.exportUsageRatio??0)?i:s,null);r.push({path:n.path,maxExportUsage:n.maxExportUsage,tightestDep:o?.toPath??""})}return r.sort((n,o)=>o.maxExportUsage-n.maxExportUsage)}findCycles(){let e=[],r=new Set,n=new Set,o=[],s=i=>{r.add(i),n.add(i),o.push(i);let a=this.nodes.get(i);if(a){for(let c of a.imports)if(!(!c.toPath||c.isExternal))if(n.has(c.toPath)){let p=o.indexOf(c.toPath);e.push([...o.slice(p),c.toPath])}else r.has(c.toPath)||s(c.toPath)}n.delete(i),o.pop()};for(let i of this.nodes.keys())r.has(i)||s(i);return e}}});var R,he=u(()=>{"use strict";l();oo();R=class t{constructor(e){this.nodes=e}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(e){let r=new Map;for(let n of e.nodes)r.set(n.path,n);return new t(r)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.imports)if(n.toPath){let o=e.get(n.toPath)||[];o.push(r.path),e.set(n.toPath,o)}return this._incomingEdgesCache=e,e}dfs(e,r,n,o){let s=new Set,i=n.maxDepth??1/0,a=(c,p,m)=>{if(p>i||s.has(c))return;let d=this.nodes.get(c);if(d&&(s.add(c),r(d,p,m)!==!1))for(let y of o(c))a(y,p+1,c)};a(e,0,null)}traverse(e,r,n={}){let o=n.direction??"outgoing",s=o==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,r,n,i=>o==="outgoing"?this.nodes.get(i)?.imports.map(a=>a.toPath).filter(Boolean)??[]:s?.get(i)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.callEdges??[]){let o=e.get(n.toFile)??[];o.push(r.path),e.set(n.toFile,o)}return this._callIncomingCache=e,e}traverseCalls(e,r,n={}){let o=n.direction??"outgoing",s=o==="incoming"?this.getCallIncomingCache():null;this.dfs(e,r,n,i=>o==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:s?.get(i)??[])}getCallers(e){let r=[];return this.traverseCalls(e,n=>(n.path!==e&&r.push(n.path),!0),{direction:"incoming",maxDepth:1}),r}getCallEdgesFor(e){return this.nodes.get(e)?.callEdges??[]}getNeighbors(e){let r=this.nodes.get(e);return r?r.imports.map(n=>this.nodes.get(n.toPath)).filter(n=>n!==void 0):[]}findUnusedFiles(e){return new de(this.nodes).findUnusedFiles(e)}findCycles(){return new de(this.nodes).findCycles()}}});var H,Xe=u(()=>{"use strict";l();H=class{affectedSymbols=new Map;constructor(e,r){this.affectedSymbols.set(e,new Set(["default",...r]))}updateAffectedSymbols(e,r){let n=this.affectedSymbols.get(r)||new Set,o=e.imports.find(c=>c.toPath===r);if(!o)return!1;let s=o.symbols||["*"],i=new Set;for(let c of s)(c==="*"||n.has("*")||n.has(c))&&i.add("*");if(i.size===0)return!1;let a=this.affectedSymbols.get(e.path)||new Set;for(let c of i)a.add(c);return this.affectedSymbols.set(e.path,a),!0}}});function V(t,e){let r=t.nodes.get(e);if(r)return{category:r.category,exports:r.exports.map(n=>n.name)}}function tr(t,e,r=1){let n=[];return t.traverse(e,(o,s,i)=>{if(o.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(c=>c.toPath===o.path):void 0;return n.push({path:o.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),n}function ye(t,e){let r=[];return t.traverse(e,n=>{if(n.path===e)return!0;let o=n.imports.find(s=>s.toPath===e);return r.push({path:n.path,...o?.symbols?{symbols:o.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function rr(t,e,r={}){let{testsOnly:n=!1,changedSymbols:o}=r,s=o?new H(e,o):null,i=[];return t.traverse(e,(a,c,p)=>{if(a.path===e)return!0;if(s&&p&&!s.updateAffectedSymbols(a,p))return!1;let m=a.category==="test"||a.tags.some(d=>d.name==="test");return(!n||m)&&i.push(a.path),!0},{direction:"incoming"}),i}function nr(t,e,r={}){let{depth:n=1,withEdgeDetail:o=!1}=r,s=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return o&&(a.edges=(i.callEdges??[]).filter(c=>c.toFile===e).map(c=>({from:c.from,to:c.to}))),s.push(a),!0},{direction:"incoming",maxDepth:n}),s}function or(t,e={}){let{metric:r="cognitiveComplexity",threshold:n=10,limit:o=20}=e;return[...t.nodes.values()].flatMap(s=>(s.functions??[]).filter(i=>i[r]>=n).map(i=>({file:s.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((s,i)=>i[r]-s[r]).slice(0,o)}function sr(t){return{nodes:t.nodes.map(r=>({path:r.path,type:r.type,category:r.category,exports:r.exports.map(n=>n.name),tags:r.tags.filter(n=>n.kind==="comment-marker"||n.kind==="import").map(n=>n.name),importsFiles:r.imports.filter(n=>!n.isExternal&&n.toPath).map(n=>n.toPath),...r.description!==void 0&&{description:r.description},...r.testedBy!==void 0&&{testedBy:r.testedBy},...r.coveragePct!==void 0&&{coveragePct:r.coveragePct},...r.avgExportUsage!==void 0&&{avgExportUsage:r.avgExportUsage},...r.maxExportUsage!==void 0&&{maxExportUsage:r.maxExportUsage}})),cycles:t.cycles}}function ir(t){let e=t.getPackageDependencies(),r=Array.from(t.packages.values()).map(({graph:n,pkg:o})=>({name:o.name,relativeRoot:o.relativeRoot,nodeCount:n.nodes.size,dependsOn:e.get(o.name)??[]}));return{monorepoType:t.type,packageCount:r.length,packages:r}}function ar(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}var cr=u(()=>{"use strict";l();Xe()});function so(t){if(t.category==="test")return"test";if(t.category==="config")return"config";if(t.category==="type-only")return"types";let e=t.path;return E(e,"component")||E(e,"components")?"component":E(e,"controller")||E(e,"controllers")?"controller":E(e,"middleware")?"middleware":E(e,"router")||E(e,"routes")||E(e,"route")?"router":E(e,"store")||E(e,"stores")?"store":E(e,"service")||E(e,"services")?"service":E(e,"handler")||E(e,"handlers")?"handler":E(e,"adapter")||E(e,"adapters")?"adapter":E(e,"plugin")||E(e,"plugins")?"plugin":E(e,"api")?"api":E(e,"cli")||E(e,"commands")||xe(e)==="cli"?"cli":E(e,"util")||E(e,"utils")||E(e,"helper")||E(e,"helpers")?"util":E(e,"model")||E(e,"models")||xe(e)==="model"?"model":E(e,"parser")||E(e,"parsers")||xe(e)==="parser"?"parser":xe(e)==="builder"?"builder":xe(e)==="resolver"?"resolver":"other"}function E(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function xe(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var io=u(()=>{"use strict";l()});function lr(t,e){let r=ge(t,e),n=new Map;for(let[s,i]of r.features){for(let a of i.files)n.set(a,s);n.set(i.hub,s)}let o=new Map;for(let s of t.nodes.values()){let i=n.get(s.path);o.set(s.path,{path:s.path,role:so(s),...s.description?{description:s.description}:{},exports:s.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return o}var pr=u(()=>{"use strict";l();Qe();io()});function fr(t,e){let r=[];for(let n of t.nodes.values())if(n.exports.some(o=>o.name===e))if(Ye.has(n.type)){let o=[];for(let s of t.nodes.values())for(let i of s.callEdges??[])i.to===e&&o.push({file:s.path,callerFunction:i.from});r.push({path:n.path,category:n.category,precision:"call",callers:o})}else{let o=ye(t,n.path).map(s=>({file:s.path,...s.symbols?{symbols:s.symbols}:{}}));r.push({path:n.path,category:n.category,precision:"file-level",importers:o})}return r}var ao=u(()=>{"use strict";l();er();cr()});function _c(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function jc(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function mr(t){let e=new Map;for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript"))for(let o of n.exports){if(!jc(o,n.category))continue;let s=`${n.path}::${o.name}`;e.set(s,{name:o.name,file:n.path,kind:_c(o.signature),...o.doc?{doc:o.doc}:{}})}let r=[];for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript")){for(let o of n.imports)if(!(!o.toPath||o.isExternal||!o.symbols?.length))for(let s of o.symbols)e.has(`${o.toPath}::${s}`)&&r.push({fromFile:n.path,toType:s,toFile:o.toPath})}return{types:e,edges:r}}function ur(t,e){let r=null;for(let s of t.types.values())if(s.name===e){r=s;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let n=new Set,o=new Map;for(let s of t.edges)if(s.toType===e&&s.toFile===r.file&&n.add(s.fromFile),s.fromFile===r.file){let i=t.types.get(`${s.toFile}::${s.toType}`);i&&o.set(`${i.file}::${i.name}`,i)}return{type:r,usedByFiles:Array.from(n),uses:Array.from(o.values())}}var gr=u(()=>{"use strict";l()});import co from"fs";import Qu from"path";function lo(t){try{return co.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function qe(t){try{return co.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Ze=u(()=>{"use strict";l()});import be from"fs";import L from"path";function dr(t,e){let r=L.join(e,"package.json");if(!be.existsSync(r))return null;let n={};try{n=JSON.parse(be.readFileSync(r,"utf-8"))}catch{return null}let o=n.name;return o?{name:o,root:e,relativeRoot:L.relative(t,e),entryPoints:Wc(e,n)}:null}function Wc(t,e){let r=[];if(e.exports){let o=e.exports;if(typeof o=="string")r.push(L.join(t,o));else if(typeof o=="object"&&o!==null){let s=o["."];if(typeof s=="string")r.push(L.join(t,s));else if(typeof s=="object"&&s!==null){let i=s.import??s.require??s.default;typeof i=="string"&&r.push(L.join(t,i))}}}e.main&&r.push(L.join(t,e.main));for(let o of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(L.join(t,o));let n=r.filter(qe);return n.length>0?n.slice(0,1):r.slice(0,1)}function oe(t,e){let r=[],n=new Set;for(let o of e){let s=o.replace(/\/$/,"").replace(/^\.\//,"");zc(t,s,n,r)}return r}function zc(t,e,r,n){if(!e.includes("*")){$c(t,e,r,n);return}let o=e.split("/");o.includes("**")?Bc(t,o,r,n):Uc(t,o,r,n)}function $c(t,e,r,n){let o=L.join(t,e);if(r.has(o)||!lo(o))return;r.add(o);let s=dr(t,o);s&&n.push(s)}function Bc(t,e,r,n){let o=L.join(t,e[0]==="**"?"":e[0]??"");po(t,o,r,n)}function Uc(t,e,r,n){let o=e.findIndex(a=>a.includes("*")),s=L.join(t,...e.slice(0,o)),i;try{i=be.readdirSync(s,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=L.join(s,a.name);if(r.has(c))continue;r.add(c);let p=dr(t,c);p&&n.push(p)}}function po(t,e,r,n){let o;try{o=be.readdirSync(e,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name==="node_modules"||s.name.startsWith("."))continue;let i=L.join(e,s.name);if(be.existsSync(L.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=dr(t,i);a&&n.push(a)}else po(t,i,r,n)}}var et=u(()=>{"use strict";l();Ze();Ze()});import hr from"fs";import fo from"path";var mo,uo=u(()=>{"use strict";l();et();mo={type:"npm",detect(t){let e=fo.join(t,"package.json");if(!hr.existsSync(e))return null;let r;try{r=JSON.parse(hr.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||hr.existsSync(fo.join(t,"yarn.lock")))return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:oe(t,n)}}});import se from"fs";import D from"path";function ho(t,e,r,n){if(n>4)return[];let o;try{o=se.readdirSync(e,{withFileTypes:!0})}catch{return[]}let s=[];for(let i of o){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let c=D.join(e,a);se.existsSync(D.join(c,"project.json"))&&!r.has(c)?(r.add(c),s.push(c)):s.push(...ho(t,c,r,n+1))}return s}function Jc(t,e,r){let n={};try{n=JSON.parse(se.readFileSync(r,"utf-8"))}catch{return null}let o=n.name,s,i,a=D.join(e,"package.json");if(se.existsSync(a))try{let c=JSON.parse(se.readFileSync(a,"utf-8"));o=c.name??o,s=c.main,i=c.exports}catch{}return o?{name:o,root:e,relativeRoot:D.relative(t,e),entryPoints:Kc(e,n,s,i)}:null}function Kc(t,e,r,n){let o=[],s=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(s){let a=D.resolve(t,"../..");o.push(D.resolve(a,s)),o.push(D.resolve(t,s))}if(n){let a=n;if(typeof a=="string")o.push(D.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&o.push(D.join(t,c))}}if(r&&o.push(D.join(t,r)),e.sourceRoot){let a=D.resolve(t,"../.."),c=D.resolve(a,e.sourceRoot);o.push(D.join(c,"index.ts"),D.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])o.push(D.join(t,a));let i=o.filter(qe);return i.length>0?i.slice(0,1):o.slice(0,1)}var go,yo=u(()=>{"use strict";l();Ze();go={type:"nx",detect(t){return se.existsSync(D.join(t,"nx.json"))?ho(t,t,new Set,0).map(r=>Jc(t,r,D.join(r,"project.json"))).filter(r=>r!==null):null}}});import xo from"fs";import Hc from"path";import{load as Vc}from"js-yaml";var bo,So=u(()=>{"use strict";l();et();bo={type:"pnpm",detect(t){let e=Hc.join(t,"pnpm-workspace.yaml");if(!xo.existsSync(e))return null;let r=[];try{r=Vc(xo.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return oe(t,r)}}});import Qc from"fs";import Yc from"path";var Co,vo=u(()=>{"use strict";l();Co={type:"turborepo",detect(t){return Qc.existsSync(Yc.join(t,"turbo.json"))?[]:null}}});import yr from"fs";import ko from"path";var wo,Eo=u(()=>{"use strict";l();et();wo={type:"yarn",detect(t){if(!yr.existsSync(ko.join(t,"yarn.lock")))return null;let e=ko.join(t,"package.json");if(!yr.existsSync(e))return null;let r;try{r=JSON.parse(yr.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r)return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:oe(t,n)}}});function W(t){Fo.push(t)}function To(){return Fo}var Fo,tt=u(()=>{"use strict";l();Fo=[]});import Xc from"path";function xr(t,e=To()){let r=Xc.resolve(t),n=new Map,o=[];for(let i of e){let a=i.detect(r);if(a!==null){o.push(i.type);for(let c of a)n.has(c.name)||n.set(c.name,c)}}if(o.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let s=Array.from(n.values());return{root:r,type:o[0],types:o,packages:s,packageMap:new Map(s.map(i=>[i.name,i]))}}var br=u(()=>{"use strict";l();uo();yo();So();vo();Eo();tt();tt();W(Co);W(go);W(bo);W(wo);W(mo)});var Se,Sr=u(()=>{"use strict";l();he();Se=class t{constructor(e,r){this.monorepoRoot=e;this.type=r}monorepoRoot;type;packages=new Map;addPackage(e,r){this.packages.set(e.name,{graph:r,pkg:e})}getPackageForFile(e){for(let{pkg:r}of this.packages.values())if(e===r.relativeRoot||e.startsWith(`${r.relativeRoot}/`))return r}getPackageDependencies(){let e=new Map;for(let{graph:r,pkg:n}of this.packages.values()){let o=new Set;for(let s of r.nodes.values())for(let i of s.imports)i.isWorkspace&&i.workspacePackage&&o.add(i.workspacePackage);e.set(n.name,[...o])}return e}getAffectedAcrossPackages(e){let r=this.getPackageForFile(e);if(!r)return[];let n=this.packages.get(r.name);if(!n)return[];let o=[];n.graph.traverse(e,s=>(s.path!==e&&o.push({file:s.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:s,pkg:i}of this.packages.values())if(i.name!==r.name)for(let a of s.nodes.values())a.imports.some(p=>p.isWorkspace&&p.workspacePackage===r.name)&&o.push({file:a.path,package:i.name});return o}serialize(){return{monorepoRoot:this.monorepoRoot,type:this.type,packages:Array.from(this.packages.values()).map(({graph:e,pkg:r})=>({pkg:{name:r.name,relativeRoot:r.relativeRoot,entryPoints:r.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let r=new t(e.monorepoRoot,e.type);for(let{pkg:n,nodes:o}of e.packages){let s=new Map(o.map(a=>[a.path,a])),i=new R(s);r.packages.set(n.name,{graph:i,pkg:{...n,root:""}})}return r}}});function ie(t,e){No.set(t,e)}function Po(t){return No.get(t)}var No,Ce=u(()=>{"use strict";l();No=new Map});function Io(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function qc(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function ve(t,e,r){return Fl.every(n=>n(t,e,r))}var Zc,el,tl,rl,nl,ol,sl,il,al,cl,ll,pl,fl,ml,ul,gl,dl,hl,yl,xl,bl,Sl,Cl,vl,kl,wl,El,Fl,Cr=u(()=>{"use strict";l();Zc=(t,e)=>!e.category||Io(t.category,e.category),el=(t,e)=>!e.type||Io(t.type,e.type),tl=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,rl=(t,e)=>!e.path||qc(t.path,e.path),nl=(t,e)=>e.isExternal===void 0?!0:t.imports.some(n=>n.isExternal)===e.isExternal,ol=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let r=e.tags.filter(o=>!o.startsWith("!")),n=e.tags.filter(o=>o.startsWith("!")).map(o=>o.slice(1));return!(r.length>0&&!r.some(o=>t.tags.some(s=>s.name===o))||n.some(o=>t.tags.some(s=>s.name===o)))},sl=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(n=>n.name===r)),il=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),al=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(o=>o.includes(e.importedBy)),cl=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,ll=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,pl=(t,e)=>e.minSize===void 0||t.size>=e.minSize,fl=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,ml=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,ul=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,gl=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,dl=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,hl=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,yl=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,xl=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,bl=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,Sl=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,Cl=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,vl=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,kl=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,wl=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,El=(t,e,r)=>!e.any?.length||e.any.some(n=>ve(t,n,r)),Fl=[Zc,el,tl,rl,nl,ol,sl,il,al,cl,ll,pl,fl,ml,ul,gl,dl,hl,yl,xl,bl,Sl,Cl,vl,kl,wl,El]});function rt(t,e){let r=new Map;if(e.importedBy!==void 0){for(let i of t.nodes)for(let a of i.imports)if(a.toPath){let c=r.get(a.toPath)??[];c.push(i.path),r.set(a.toPath,c)}}let n=t.nodes.filter(i=>ve(i,e,r)),o=new Set(n.map(i=>i.path)),s=n.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||o.has(a.toPath))}));if(e.sort){let i=e.sortDir==="asc"?-1:1;s.sort((a,c)=>{let p=0;return e.sort==="size"?p=c.size-a.size:e.sort==="imports"?p=c.imports.length-a.imports.length:e.sort==="commitCount90d"?p=(c.commitCount90d??0)-(a.commitCount90d??0):e.sort==="exportUsage"?p=(c.avgExportUsage??0)-(a.avgExportUsage??0):e.sort==="complexity"?p=(c.complexity??0)-(a.complexity??0):e.sort==="cognitiveComplexity"&&(p=(c.cognitiveComplexity??0)-(a.cognitiveComplexity??0)),p*i})}return e.limit!==void 0&&s.splice(e.limit),{nodes:s,cycles:t.cycles?.filter(i=>i.every(a=>o.has(a)))??void 0}}var Do=u(()=>{"use strict";l();Cr();Cr()});function Mo(t,e){let r=e.indexOf(":");if(r===-1)return;let n=e.slice(0,r).trim().toLowerCase(),o=e.slice(r+1).trim();if(!(!n||!o))switch(n){case"category":t.category=o;break;case"type":t.type=o;break;case"tag":case"tags":o.includes("+")?t.allTags=[...t.allTags??[],...o.split("+")]:t.tags=[...t.tags??[],o];break;case"path":t.path=o;break;case"external":t.isExternal=o.toLowerCase()==="true";break;case"importsfile":t.importsFile=o;break;case"importedby":t.importedBy=o;break;case"minimports":t.minImports=parseInt(o,10);break;case"maximports":t.maxImports=parseInt(o,10);break;case"minsize":t.minSize=parseInt(o,10);break;case"maxsize":t.maxSize=parseInt(o,10);break;case"sort":t.sort=o;break;case"sortdir":t.sortDir=o.toLowerCase()==="asc"?"asc":"desc";break;case"limit":t.limit=parseInt(o,10);break;case"hasdocstring":t.hasDocstring=o.toLowerCase()!=="false";break;case"mincoverage":t.minCoverage=parseInt(o,10);break;case"maxcoverage":t.maxCoverage=parseInt(o,10);break;case"minexportusage":t.minExportUsage=parseFloat(o);break;case"maxexportusage":t.maxExportUsage=parseFloat(o);break;case"mincomplexity":t.minComplexity=parseInt(o,10);break;case"maxcomplexity":t.maxComplexity=parseInt(o,10);break;case"mincognitivecomplexity":t.minCognitiveComplexity=parseInt(o,10);break;case"maxcognitivecomplexity":t.maxCognitiveComplexity=parseInt(o,10);break;case"mincommits":t.minCommits=parseInt(o,10);break;case"maxcommits":t.maxCommits=parseInt(o,10);break;case"isdocumented":t.isDocumented=o.toLowerCase()!=="false";break;case"isstale":t.isStale=o.toLowerCase()!=="false";break;case"lastauthor":t.lastAuthor=o;break}}function Tl(t){let e=[];for(let r of t.split("|")){let n=r.trim();if(!n)continue;let o={};Mo(o,n),Object.keys(o).length>0&&e.push(o)}return e}function nt(t){let e={},r=t.split(",");for(let n of r){let o=n.trim();if(o.toLowerCase().startsWith("any(")&&o.endsWith(")")){let s=o.slice(4,-1),i=Tl(s);i.length>0&&(e.any=[...e.any??[],...i]);continue}Mo(e,n)}return e}var Ao=u(()=>{"use strict";l()});var Ro=u(()=>{"use strict";l();Do();Ao()});import Nl from"path";import N from"typescript";function Q(t,e){let r=t[e];if(r===void 0)throw new Error(`Index ${e} out of bounds (length ${t.length})`);return r}function vr(t){let e=[];for(let r of t.statements){if(!N.isExpressionStatement(r))continue;let n=r.expression;if(!N.isCallExpression(n))continue;let o=n.expression;N.isIdentifier(o)&&Lo.has(o.text)&&e.push(n),N.isPropertyAccessExpression(o)&&N.isIdentifier(o.expression)&&Lo.has(o.expression.text)&&e.push(n)}return e}function kr(t,e,r){for(let n of t.arguments){if(!N.isObjectLiteralExpression(n))continue;let o=n.properties.find(s=>N.isPropertyAssignment(s)&&N.isIdentifier(s.name)&&s.name.text===e);if(!(!o||!N.isArrayLiteralExpression(o.initializer)))return o.initializer.elements.filter(N.isStringLiteral).map(s=>s.text)}return null}function wr(t,e,r,n){if(t.arguments.length===0)return null;for(let s=1;s<t.arguments.length;s++){let i=Q(t.arguments,s);if(!N.isObjectLiteralExpression(i))continue;let a=i.properties.find(p=>N.isPropertyAssignment(p)&&N.isIdentifier(p.name)&&p.name.text===e);if(a)return{start:a.initializer.getStart(n),end:a.initializer.getEnd(),text:r};let c=i.getEnd()-1;return{start:c,end:c,text:`${i.properties.length>0?", ":""}${e}: ${r}`}}let o=Q(t.arguments,t.arguments.length-1);return{start:o.getStart(n),end:o.getStart(n),text:`{ ${e}: ${r} }, `}}function Er(t,e,r){let n=t.arguments;for(let o=1;o<n.length;o++){let s=Q(n,o);if(!N.isObjectLiteralExpression(s))continue;let i=s.properties.findIndex(c=>N.isPropertyAssignment(c)&&N.isIdentifier(c.name)&&c.name.text===e);if(i<0)continue;if(s.properties.length===1)return{start:Q(n,o-1).getEnd(),end:s.getEnd(),text:""};let a=Q(s.properties,i);return i===s.properties.length-1?{start:Q(s.properties,i-1).getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:Q(s.properties,i+1).getStart(r),text:""}}return null}function Fr(t,e){let r=[...e].sort((o,s)=>s.start-o.start),n=t;for(let o of r)n=n.slice(0,o.start)+o.text+n.slice(o.end);return n}function Tr(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}function Pl(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function ot(t,e,r,n){let o=N.createSourceFile(Nl.basename(t),e,N.ScriptTarget.Latest,!0),s=vr(o),[i]=s;if(!i)return e;let a=kr(i,n,o),c=[...r].sort();if(a!==null&&JSON.stringify(Pl(a).sort())===JSON.stringify(c))return e;let p=Tr(c.map(d=>`@${d}`)),m=s.flatMap(d=>{let y=r.length===0?Er(d,n,o):wr(d,n,p,o);return y?[y]:[]});return m.length>0?Fr(e,m):e}var Lo,j,ae=u(()=>{"use strict";l();Lo=new Set(["describe","test","it"]);j=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import Il from"path";var st,Oo=u(()=>{"use strict";l();ae();st=class{name="cypress";canHandle(e){return j.has(Il.extname(e).toLowerCase())}apply(e,r,n){return ot(e,r,n,"tags")}}});import Dl from"path";function Ml(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
9
+ `),null}}var wc,Ec,Ht=m(()=>{"use strict";l();je();$t();_n();Jn();eo();oo();wc=20,Ec=new Set(["css","scss","less"])});import Je from"path";function Pc(t){let e=new Map;for(let[r,n]of t){let o=n.imports.filter(s=>s.toPath&&!s.isExternal).length;o>0&&e.set(r,o)}return e}function Ic(t,e,r){let n=new Map;for(let[o,s]of e){if(s<r)continue;let i=t.get(o);if(!i||i.category==="test"||i.category==="barrel")continue;let a=Je.extname(o),c=Je.basename(o,a),p=c==="index"?Je.basename(Je.dirname(o)):c;n.set(o,{path:o,outDegree:s,tag:`feature:${p}`})}return n}function K(t,e){let r=e?.minOutDegree??5;return Ic(t,Pc(t),r)}var Ke=m(()=>{"use strict";l()});function Mc(t,e){let r=new Map;for(let n of e.values()){let o=new Set;t.traverse(n.path,s=>(s.path!==n.path&&o.add(s.path),!0),{direction:"outgoing"}),r.set(n.path,o)}return r}function Ac(t,e,r,n){let o=new Map;for(let[s]of t){if(e.has(s))continue;let i=null;for(let a of e.values())r.get(a.path)?.has(s)&&(!i||n(a,i)<0)&&(i=a);i&&o.set(s,i.path)}return o}function Lc(t,e){let r=new Map;for(let n of t.values()){let o=n.tag.replace("feature:",""),s=[];for(let[i,a]of e)a===n.path&&s.push(i);r.set(o,{hub:n.path,outDegree:n.outDegree,files:s})}return r}function Rc(t,e,r){let n=[];for(let o of t.keys())!e.has(o)&&!r.has(o)&&n.push(o);return n}function ge(t,e){let r=e?.detectFn??K,n=e?.hubComparator??Dc,o=r(t.nodes,e),s=Mc(t,o),i=Ac(t.nodes,o,s,n);return{features:Lc(o,i),unassigned:Rc(t.nodes,o,i)}}var Dc,He=m(()=>{"use strict";l();Ke();Dc=(t,e)=>t.outDegree-e.outDegree});function Vt(t){let e=new Map;for(let r of t.nodes.values())e.set(r.type,(e.get(r.type)??0)+1);return[...e.entries()].map(([r,n])=>({type:r,fileCount:n,exportsTracked:io.has(r),importSymbolsTracked:ao.has(r),callEdgesTracked:Ve.has(r)})).sort((r,n)=>n.fileCount-r.fileCount)}var io,ao,Ve,Qt=m(()=>{"use strict";l();io=new Set(["typescript","javascript","python","go","scss","less","lua","coffeescript"]),ao=new Set(["typescript","javascript","python"]),Ve=new Set(["typescript","javascript","go","python"])});var de,co=m(()=>{"use strict";l();de=class{constructor(e){this.nodes=e}nodes;findUnusedFiles(e){let r=new Set(this.nodes.keys());return e.filter(n=>!r.has(n))}findHighExportUsage(e){let r=[];for(let n of this.nodes.values()){if(n.maxExportUsage===void 0||n.maxExportUsage<e)continue;let o=n.imports.reduce((s,i)=>(i.exportUsageRatio??0)>(s?.exportUsageRatio??0)?i:s,null);r.push({path:n.path,maxExportUsage:n.maxExportUsage,tightestDep:o?.toPath??""})}return r.sort((n,o)=>o.maxExportUsage-n.maxExportUsage)}findCycles(){let e=[],r=new Set,n=new Set,o=[],s=i=>{r.add(i),n.add(i),o.push(i);let a=this.nodes.get(i);if(a){for(let c of a.imports)if(!(!c.toPath||c.isExternal))if(n.has(c.toPath)){let p=o.indexOf(c.toPath);e.push([...o.slice(p),c.toPath])}else r.has(c.toPath)||s(c.toPath)}n.delete(i),o.pop()};for(let i of this.nodes.keys())r.has(i)||s(i);return e}}});var D,he=m(()=>{"use strict";l();co();D=class t{constructor(e){this.nodes=e}nodes;_incomingEdgesCache=null;_callIncomingCache=null;serialize(){return{nodes:Array.from(this.nodes.values())}}static deserialize(e){let r=new Map;for(let n of e.nodes)r.set(n.path,n);return new t(r)}getIncomingEdgesMap(){if(this._incomingEdgesCache)return this._incomingEdgesCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.imports)if(n.toPath){let o=e.get(n.toPath)||[];o.push(r.path),e.set(n.toPath,o)}return this._incomingEdgesCache=e,e}dfs(e,r,n,o){let s=new Set,i=n.maxDepth??1/0,a=(c,p,f)=>{if(p>i||s.has(c))return;let d=this.nodes.get(c);if(d&&(s.add(c),r(d,p,f)!==!1))for(let y of o(c))a(y,p+1,c)};a(e,0,null)}traverse(e,r,n={}){let o=n.direction??"outgoing",s=o==="incoming"?this.getIncomingEdgesMap():null;this.dfs(e,r,n,i=>o==="outgoing"?this.nodes.get(i)?.imports.map(a=>a.toPath).filter(Boolean)??[]:s?.get(i)??[])}getCallIncomingCache(){if(this._callIncomingCache)return this._callIncomingCache;let e=new Map;for(let r of this.nodes.values())for(let n of r.callEdges??[]){let o=e.get(n.toFile)??[];o.push(r.path),e.set(n.toFile,o)}return this._callIncomingCache=e,e}traverseCalls(e,r,n={}){let o=n.direction??"outgoing",s=o==="incoming"?this.getCallIncomingCache():null;this.dfs(e,r,n,i=>o==="outgoing"?this.nodes.get(i)?.callEdges?.map(a=>a.toFile)??[]:s?.get(i)??[])}getCallers(e){let r=[];return this.traverseCalls(e,n=>(n.path!==e&&r.push(n.path),!0),{direction:"incoming",maxDepth:1}),r}getCallEdgesFor(e){return this.nodes.get(e)?.callEdges??[]}getNeighbors(e){let r=this.nodes.get(e);return r?r.imports.map(n=>this.nodes.get(n.toPath)).filter(n=>n!==void 0):[]}findUnusedFiles(e){return new de(this.nodes).findUnusedFiles(e)}findCycles(){return new de(this.nodes).findCycles()}}});var H,Qe=m(()=>{"use strict";l();H=class{affectedSymbols=new Map;constructor(e,r){this.affectedSymbols.set(e,new Set(["default",...r]))}updateAffectedSymbols(e,r){let n=this.affectedSymbols.get(r)||new Set,o=e.imports.find(c=>c.toPath===r);if(!o)return!1;let s=o.symbols||["*"],i=new Set;for(let c of s)(c==="*"||n.has("*")||n.has(c))&&i.add("*");if(i.size===0)return!1;let a=this.affectedSymbols.get(e.path)||new Set;for(let c of i)a.add(c);return this.affectedSymbols.set(e.path,a),!0}}});function V(t,e){let r=t.nodes.get(e);if(r)return{category:r.category,exports:r.exports.map(n=>n.name)}}function Yt(t,e,r=1){let n=[];return t.traverse(e,(o,s,i)=>{if(o.path===e)return!0;let a=i?t.nodes.get(i)?.imports.find(c=>c.toPath===o.path):void 0;return n.push({path:o.path,...a?.symbols?{symbols:a.symbols}:{}}),!0},{direction:"outgoing",maxDepth:r}),n}function ye(t,e){let r=[];return t.traverse(e,n=>{if(n.path===e)return!0;let o=n.imports.find(s=>s.toPath===e);return r.push({path:n.path,...o?.symbols?{symbols:o.symbols}:{}}),!0},{direction:"incoming",maxDepth:1}),r}function Xt(t,e,r={}){let{testsOnly:n=!1,changedSymbols:o}=r,s=o?new H(e,o):null,i=[];return t.traverse(e,(a,c,p)=>{if(a.path===e)return!0;if(s&&p&&!s.updateAffectedSymbols(a,p))return!1;let f=a.category==="test"||a.tags.some(d=>d.name==="test");return(!n||f)&&i.push(a.path),!0},{direction:"incoming"}),i}function qt(t,e,r={}){let{depth:n=1,withEdgeDetail:o=!1}=r,s=[];return t.traverseCalls(e,i=>{if(i.path===e)return!0;let a={file:i.path};return o&&(a.edges=(i.callEdges??[]).filter(c=>c.toFile===e).map(c=>({from:c.from,to:c.to}))),s.push(a),!0},{direction:"incoming",maxDepth:n}),s}function Zt(t,e={}){let{metric:r="cognitiveComplexity",threshold:n=10,limit:o=20}=e;return[...t.nodes.values()].flatMap(s=>(s.functions??[]).filter(i=>i[r]>=n).map(i=>({file:s.path,name:i.name,line:i.line,complexity:i.complexity,cognitiveComplexity:i.cognitiveComplexity}))).sort((s,i)=>i[r]-s[r]).slice(0,o)}function er(t){return{nodes:t.nodes.map(r=>({path:r.path,type:r.type,category:r.category,exports:r.exports.map(n=>n.name),tags:r.tags.filter(n=>n.kind==="comment-marker"||n.kind==="import").map(n=>n.name),importsFiles:r.imports.filter(n=>!n.isExternal&&n.toPath).map(n=>n.toPath),...r.description!==void 0&&{description:r.description},...r.testedBy!==void 0&&{testedBy:r.testedBy},...r.coveragePct!==void 0&&{coveragePct:r.coveragePct},...r.avgExportUsage!==void 0&&{avgExportUsage:r.avgExportUsage},...r.maxExportUsage!==void 0&&{maxExportUsage:r.maxExportUsage}})),cycles:t.cycles}}function tr(t){let e=t.getPackageDependencies(),r=Array.from(t.packages.values()).map(({graph:n,pkg:o})=>({name:o.name,relativeRoot:o.relativeRoot,nodeCount:n.nodes.size,dependsOn:e.get(o.name)??[]}));return{monorepoType:t.type,packageCount:r.length,packages:r}}function rr(t){return[...t.nodes.values()].some(e=>e.coveragePct!==void 0)}var nr=m(()=>{"use strict";l();Qe()});function lo(t){if(t.category==="test")return"test";if(t.category==="config")return"config";if(t.category==="type-only")return"types";let e=t.path;return k(e,"component")||k(e,"components")?"component":k(e,"controller")||k(e,"controllers")?"controller":k(e,"middleware")?"middleware":k(e,"router")||k(e,"routes")||k(e,"route")?"router":k(e,"store")||k(e,"stores")?"store":k(e,"service")||k(e,"services")?"service":k(e,"handler")||k(e,"handlers")?"handler":k(e,"adapter")||k(e,"adapters")?"adapter":k(e,"plugin")||k(e,"plugins")?"plugin":k(e,"api")?"api":k(e,"cli")||k(e,"commands")||xe(e)==="cli"?"cli":k(e,"util")||k(e,"utils")||k(e,"helper")||k(e,"helpers")?"util":k(e,"model")||k(e,"models")||xe(e)==="model"?"model":k(e,"parser")||k(e,"parsers")||xe(e)==="parser"?"parser":xe(e)==="builder"?"builder":xe(e)==="resolver"?"resolver":"other"}function k(t,e){return t.includes(`/${e}/`)||t.includes(`/${e}.`)}function xe(t){let e=t.slice(t.lastIndexOf("/")+1);return e.slice(0,e.lastIndexOf("."))||e}var po=m(()=>{"use strict";l()});function or(t,e){let r=ge(t,e),n=new Map;for(let[s,i]of r.features){for(let a of i.files)n.set(a,s);n.set(i.hub,s)}let o=new Map;for(let s of t.nodes.values()){let i=n.get(s.path);o.set(s.path,{path:s.path,role:lo(s),...s.description?{description:s.description}:{},exports:s.exports.map(a=>a.name),...i?{featureHub:i}:{}})}return o}var sr=m(()=>{"use strict";l();He();po()});function ir(t,e){let r=[];for(let n of t.nodes.values())if(n.exports.some(o=>o.name===e))if(Ve.has(n.type)){let o=[];for(let s of t.nodes.values())for(let i of s.callEdges??[])i.to===e&&o.push({file:s.path,callerFunction:i.from});r.push({path:n.path,category:n.category,precision:"call",callers:o})}else{let o=ye(t,n.path).map(s=>({file:s.path,...s.symbols?{symbols:s.symbols}:{}}));r.push({path:n.path,category:n.category,precision:"file-level",importers:o})}return r}var fo=m(()=>{"use strict";l();Qt();nr()});function Oc(t){return t?t.startsWith("interface ")?"interface":t.startsWith("class ")?"class":t.startsWith("enum ")?"enum":"type":"type"}function Gc(t,e){if(e==="type-only")return!0;let r=t.signature??"";return r.startsWith("interface ")||r.startsWith("class ")||r.startsWith("enum ")}function ar(t){let e=new Map;for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript"))for(let o of n.exports){if(!Gc(o,n.category))continue;let s=`${n.path}::${o.name}`;e.set(s,{name:o.name,file:n.path,kind:Oc(o.signature),...o.doc?{doc:o.doc}:{}})}let r=[];for(let n of t.nodes.values())if(!(n.type!=="typescript"&&n.type!=="javascript")){for(let o of n.imports)if(!(!o.toPath||o.isExternal||!o.symbols?.length))for(let s of o.symbols)e.has(`${o.toPath}::${s}`)&&r.push({fromFile:n.path,toType:s,toFile:o.toPath})}return{types:e,edges:r}}function cr(t,e){let r=null;for(let s of t.types.values())if(s.name===e){r=s;break}if(!r)return{type:null,usedByFiles:[],uses:[]};let n=new Set,o=new Map;for(let s of t.edges)if(s.toType===e&&s.toFile===r.file&&n.add(s.fromFile),s.fromFile===r.file){let i=t.types.get(`${s.toFile}::${s.toType}`);i&&o.set(`${i.file}::${i.name}`,i)}return{type:r,usedByFiles:Array.from(n),uses:Array.from(o.values())}}var lr=m(()=>{"use strict";l()});import uo from"fs";import rg from"path";function mo(t){try{return uo.statSync(t,{throwIfNoEntry:!1})?.isDirectory()===!0}catch{return!1}}function Ye(t){try{return uo.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Xe=m(()=>{"use strict";l()});import be from"fs";import M from"path";function pr(t,e){let r=M.join(e,"package.json");if(!be.existsSync(r))return null;let n={};try{n=JSON.parse(be.readFileSync(r,"utf-8"))}catch{return null}let o=n.name;return o?{name:o,root:e,relativeRoot:M.relative(t,e),entryPoints:_c(e,n)}:null}function _c(t,e){let r=[];if(e.exports){let o=e.exports;if(typeof o=="string")r.push(M.join(t,o));else if(typeof o=="object"&&o!==null){let s=o["."];if(typeof s=="string")r.push(M.join(t,s));else if(typeof s=="object"&&s!==null){let i=s.import??s.require??s.default;typeof i=="string"&&r.push(M.join(t,i))}}}e.main&&r.push(M.join(t,e.main));for(let o of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"])r.push(M.join(t,o));let n=r.filter(Ye);return n.length>0?n.slice(0,1):r.slice(0,1)}function oe(t,e){let r=[],n=new Set;for(let o of e){let s=o.replace(/\/$/,"").replace(/^\.\//,"");jc(t,s,n,r)}return r}function jc(t,e,r,n){if(!e.includes("*")){Wc(t,e,r,n);return}let o=e.split("/");o.includes("**")?zc(t,o,r,n):$c(t,o,r,n)}function Wc(t,e,r,n){let o=M.join(t,e);if(r.has(o)||!mo(o))return;r.add(o);let s=pr(t,o);s&&n.push(s)}function zc(t,e,r,n){let o=M.join(t,e[0]==="**"?"":e[0]??"");go(t,o,r,n)}function $c(t,e,r,n){let o=e.findIndex(a=>a.includes("*")),s=M.join(t,...e.slice(0,o)),i;try{i=be.readdirSync(s,{withFileTypes:!0})}catch{return}for(let a of i){if(!a.isDirectory())continue;let c=M.join(s,a.name);if(r.has(c))continue;r.add(c);let p=pr(t,c);p&&n.push(p)}}function go(t,e,r,n){let o;try{o=be.readdirSync(e,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name==="node_modules"||s.name.startsWith("."))continue;let i=M.join(e,s.name);if(be.existsSync(M.join(i,"package.json"))&&!r.has(i)){r.add(i);let a=pr(t,i);a&&n.push(a)}else go(t,i,r,n)}}var qe=m(()=>{"use strict";l();Xe();Xe()});import fr from"fs";import ho from"path";var yo,xo=m(()=>{"use strict";l();qe();yo={type:"npm",detect(t){let e=ho.join(t,"package.json");if(!fr.existsSync(e))return null;let r;try{r=JSON.parse(fr.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r||fr.existsSync(ho.join(t,"yarn.lock")))return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:oe(t,n)}}});import se from"fs";import P from"path";function So(t,e,r,n){if(n>4)return[];let o;try{o=se.readdirSync(e,{withFileTypes:!0})}catch{return[]}let s=[];for(let i of o){if(!i.isDirectory())continue;let a=i.name;if(a.startsWith(".")||a==="node_modules"||a==="dist"||a===".nx")continue;let c=P.join(e,a);se.existsSync(P.join(c,"project.json"))&&!r.has(c)?(r.add(c),s.push(c)):s.push(...So(t,c,r,n+1))}return s}function Bc(t,e,r){let n={};try{n=JSON.parse(se.readFileSync(r,"utf-8"))}catch{return null}let o=n.name,s,i,a=P.join(e,"package.json");if(se.existsSync(a))try{let c=JSON.parse(se.readFileSync(a,"utf-8"));o=c.name??o,s=c.main,i=c.exports}catch{}return o?{name:o,root:e,relativeRoot:P.relative(t,e),entryPoints:Uc(e,n,s,i)}:null}function Uc(t,e,r,n){let o=[],s=e.targets?.build?.options?.main??e.targets?.build?.options?.entryFile;if(s){let a=P.resolve(t,"../..");o.push(P.resolve(a,s)),o.push(P.resolve(t,s))}if(n){let a=n;if(typeof a=="string")o.push(P.join(t,a));else if(typeof a=="object"&&a!==null){let c=a["."];typeof c=="string"&&o.push(P.join(t,c))}}if(r&&o.push(P.join(t,r)),e.sourceRoot){let a=P.resolve(t,"../.."),c=P.resolve(a,e.sourceRoot);o.push(P.join(c,"index.ts"),P.join(c,"index.tsx"))}for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx"])o.push(P.join(t,a));let i=o.filter(Ye);return i.length>0?i.slice(0,1):o.slice(0,1)}var bo,Co=m(()=>{"use strict";l();Xe();bo={type:"nx",detect(t){return se.existsSync(P.join(t,"nx.json"))?So(t,t,new Set,0).map(r=>Bc(t,r,P.join(r,"project.json"))).filter(r=>r!==null):null}}});import ko from"fs";import Jc from"path";import{load as Kc}from"js-yaml";var vo,wo=m(()=>{"use strict";l();qe();vo={type:"pnpm",detect(t){let e=Jc.join(t,"pnpm-workspace.yaml");if(!ko.existsSync(e))return null;let r=[];try{r=Kc(ko.readFileSync(e,"utf-8"))?.packages??[]}catch{return null}return oe(t,r)}}});import Hc from"fs";import Vc from"path";var Eo,To=m(()=>{"use strict";l();Eo={type:"turborepo",detect(t){return Hc.existsSync(Vc.join(t,"turbo.json"))?[]:null}}});import ur from"fs";import Fo from"path";var No,Po=m(()=>{"use strict";l();qe();No={type:"yarn",detect(t){if(!ur.existsSync(Fo.join(t,"yarn.lock")))return null;let e=Fo.join(t,"package.json");if(!ur.existsSync(e))return null;let r;try{r=JSON.parse(ur.readFileSync(e,"utf-8")).workspaces}catch{return null}if(!r)return null;let n=Array.isArray(r)?r:r.packages??[];return n.length===0?null:oe(t,n)}}});function j(t){Io.push(t)}function Do(){return Io}var Io,Ze=m(()=>{"use strict";l();Io=[]});import Qc from"path";function mr(t,e=Do()){let r=Qc.resolve(t),n=new Map,o=[];for(let i of e){let a=i.detect(r);if(a!==null){o.push(i.type);for(let c of a)n.has(c.name)||n.set(c.name,c)}}if(o.length===0)return{root:r,type:"none",types:[],packages:[],packageMap:new Map};let s=Array.from(n.values());return{root:r,type:o[0],types:o,packages:s,packageMap:new Map(s.map(i=>[i.name,i]))}}var gr=m(()=>{"use strict";l();xo();Co();wo();To();Po();Ze();Ze();j(Eo);j(bo);j(vo);j(No);j(yo)});var Se,dr=m(()=>{"use strict";l();he();Se=class t{constructor(e,r){this.monorepoRoot=e;this.type=r}monorepoRoot;type;packages=new Map;addPackage(e,r){this.packages.set(e.name,{graph:r,pkg:e})}getPackageForFile(e){for(let{pkg:r}of this.packages.values())if(e===r.relativeRoot||e.startsWith(`${r.relativeRoot}/`))return r}getPackageDependencies(){let e=new Map;for(let{graph:r,pkg:n}of this.packages.values()){let o=new Set;for(let s of r.nodes.values())for(let i of s.imports)i.isWorkspace&&i.workspacePackage&&o.add(i.workspacePackage);e.set(n.name,[...o])}return e}getAffectedAcrossPackages(e){let r=this.getPackageForFile(e);if(!r)return[];let n=this.packages.get(r.name);if(!n)return[];let o=[];n.graph.traverse(e,s=>(s.path!==e&&o.push({file:s.path,package:r.name}),!0),{direction:"incoming"});for(let{graph:s,pkg:i}of this.packages.values())if(i.name!==r.name)for(let a of s.nodes.values())a.imports.some(p=>p.isWorkspace&&p.workspacePackage===r.name)&&o.push({file:a.path,package:i.name});return o}serialize(){return{monorepoRoot:this.monorepoRoot,type:this.type,packages:Array.from(this.packages.values()).map(({graph:e,pkg:r})=>({pkg:{name:r.name,relativeRoot:r.relativeRoot,entryPoints:r.entryPoints},nodes:Array.from(e.nodes.values())}))}}static deserialize(e){let r=new t(e.monorepoRoot,e.type);for(let{pkg:n,nodes:o}of e.packages){let s=new Map(o.map(a=>[a.path,a])),i=new D(s);r.packages.set(n.name,{graph:i,pkg:{...n,root:""}})}return r}}});function ie(t,e){Mo.set(t,e)}function Ao(t){return Mo.get(t)}var Mo,Ce=m(()=>{"use strict";l();Mo=new Map});function Lo(t,e){return e.startsWith("!")?t!==e.slice(1):t===e}function Yc(t,e){return e.startsWith("!")?!t.includes(e.slice(1)):t.includes(e)}function ke(t,e,r){return wl.every(n=>n(t,e,r))}var Xc,qc,Zc,el,tl,rl,nl,ol,sl,il,al,cl,ll,pl,fl,ul,ml,gl,dl,hl,yl,xl,bl,Sl,Cl,kl,vl,wl,hr=m(()=>{"use strict";l();Xc=(t,e)=>!e.category||Lo(t.category,e.category),qc=(t,e)=>!e.type||Lo(t.type,e.type),Zc=(t,e)=>e.lastAuthor?e.lastAuthor.startsWith("!")?t.lastAuthor!==e.lastAuthor.slice(1):t.lastAuthor!==void 0&&t.lastAuthor===e.lastAuthor:!0,el=(t,e)=>!e.path||Yc(t.path,e.path),tl=(t,e)=>e.isExternal===void 0?!0:t.imports.some(n=>n.isExternal)===e.isExternal,rl=(t,e)=>{if(!e.tags||e.tags.length===0)return!0;let r=e.tags.filter(o=>!o.startsWith("!")),n=e.tags.filter(o=>o.startsWith("!")).map(o=>o.slice(1));return!(r.length>0&&!r.some(o=>t.tags.some(s=>s.name===o))||n.some(o=>t.tags.some(s=>s.name===o)))},nl=(t,e)=>!e.allTags?.length||e.allTags.every(r=>t.tags.some(n=>n.name===r)),ol=(t,e)=>!e.importsFile||t.imports.some(r=>r.toPath?.includes(e.importsFile)),sl=(t,e,r)=>e.importedBy===void 0?!0:(r?.get(t.path)??[]).some(o=>o.includes(e.importedBy)),il=(t,e)=>e.minImports===void 0||t.imports.length>=e.minImports,al=(t,e)=>e.maxImports===void 0||t.imports.length<=e.maxImports,cl=(t,e)=>e.minSize===void 0||t.size>=e.minSize,ll=(t,e)=>e.maxSize===void 0||t.size<=e.maxSize,pl=(t,e)=>e.hasDocstring===void 0||!!t.description===e.hasDocstring,fl=(t,e)=>e.isDocumented===void 0||!!t.documentedBy?.length===e.isDocumented,ul=(t,e)=>e.isStale===void 0||!!t.staleFor?.length===e.isStale,ml=(t,e)=>e.minCoverage===void 0||(t.coveragePct??101)>=e.minCoverage,gl=(t,e)=>e.maxCoverage===void 0||(t.coveragePct??0)<=e.maxCoverage,dl=(t,e)=>e.minExportUsage===void 0||(t.avgExportUsage??-1)>=e.minExportUsage,hl=(t,e)=>e.maxExportUsage===void 0||(t.avgExportUsage??0)<=e.maxExportUsage,yl=(t,e)=>e.minComplexity===void 0||(t.complexity??-1/0)>=e.minComplexity,xl=(t,e)=>e.maxComplexity===void 0||(t.complexity??0)<=e.maxComplexity,bl=(t,e)=>e.minCognitiveComplexity===void 0||(t.cognitiveComplexity??-1/0)>=e.minCognitiveComplexity,Sl=(t,e)=>e.maxCognitiveComplexity===void 0||(t.cognitiveComplexity??0)<=e.maxCognitiveComplexity,Cl=(t,e)=>e.minCommits===void 0||(t.commitCount90d??-1/0)>=e.minCommits,kl=(t,e)=>e.maxCommits===void 0||(t.commitCount90d??0)<=e.maxCommits,vl=(t,e,r)=>!e.any?.length||e.any.some(n=>ke(t,n,r)),wl=[Xc,qc,Zc,el,tl,rl,nl,ol,sl,il,al,cl,ll,pl,fl,ul,ml,gl,dl,hl,yl,xl,bl,Sl,Cl,kl,vl]});function et(t,e){let r=new Map;if(e.importedBy!==void 0){for(let i of t.nodes)for(let a of i.imports)if(a.toPath){let c=r.get(a.toPath)??[];c.push(i.path),r.set(a.toPath,c)}}let n=t.nodes.filter(i=>ke(i,e,r)),o=new Set(n.map(i=>i.path)),s=n.map(i=>({...i,imports:i.imports.filter(a=>!a.toPath||o.has(a.toPath))}));if(e.sort){let i=e.sortDir==="asc"?-1:1;s.sort((a,c)=>{let p=0;return e.sort==="size"?p=c.size-a.size:e.sort==="imports"?p=c.imports.length-a.imports.length:e.sort==="commitCount90d"?p=(c.commitCount90d??0)-(a.commitCount90d??0):e.sort==="exportUsage"?p=(c.avgExportUsage??0)-(a.avgExportUsage??0):e.sort==="complexity"?p=(c.complexity??0)-(a.complexity??0):e.sort==="cognitiveComplexity"&&(p=(c.cognitiveComplexity??0)-(a.cognitiveComplexity??0)),p*i})}return e.limit!==void 0&&s.splice(e.limit),{nodes:s,cycles:t.cycles?.filter(i=>i.every(a=>o.has(a)))??void 0}}var Ro=m(()=>{"use strict";l();hr();hr()});function Oo(t,e){let r=e.indexOf(":");if(r===-1)return;let n=e.slice(0,r).trim().toLowerCase(),o=e.slice(r+1).trim();if(!(!n||!o))switch(n){case"category":t.category=o;break;case"type":t.type=o;break;case"tag":case"tags":o.includes("+")?t.allTags=[...t.allTags??[],...o.split("+")]:t.tags=[...t.tags??[],o];break;case"path":t.path=o;break;case"external":t.isExternal=o.toLowerCase()==="true";break;case"importsfile":t.importsFile=o;break;case"importedby":t.importedBy=o;break;case"minimports":t.minImports=parseInt(o,10);break;case"maximports":t.maxImports=parseInt(o,10);break;case"minsize":t.minSize=parseInt(o,10);break;case"maxsize":t.maxSize=parseInt(o,10);break;case"sort":t.sort=o;break;case"sortdir":t.sortDir=o.toLowerCase()==="asc"?"asc":"desc";break;case"limit":t.limit=parseInt(o,10);break;case"hasdocstring":t.hasDocstring=o.toLowerCase()!=="false";break;case"mincoverage":t.minCoverage=parseInt(o,10);break;case"maxcoverage":t.maxCoverage=parseInt(o,10);break;case"minexportusage":t.minExportUsage=parseFloat(o);break;case"maxexportusage":t.maxExportUsage=parseFloat(o);break;case"mincomplexity":t.minComplexity=parseInt(o,10);break;case"maxcomplexity":t.maxComplexity=parseInt(o,10);break;case"mincognitivecomplexity":t.minCognitiveComplexity=parseInt(o,10);break;case"maxcognitivecomplexity":t.maxCognitiveComplexity=parseInt(o,10);break;case"mincommits":t.minCommits=parseInt(o,10);break;case"maxcommits":t.maxCommits=parseInt(o,10);break;case"isdocumented":t.isDocumented=o.toLowerCase()!=="false";break;case"isstale":t.isStale=o.toLowerCase()!=="false";break;case"lastauthor":t.lastAuthor=o;break}}function El(t){let e=[];for(let r of t.split("|")){let n=r.trim();if(!n)continue;let o={};Oo(o,n),Object.keys(o).length>0&&e.push(o)}return e}function tt(t){let e={},r=t.split(",");for(let n of r){let o=n.trim();if(o.toLowerCase().startsWith("any(")&&o.endsWith(")")){let s=o.slice(4,-1),i=El(s);i.length>0&&(e.any=[...e.any??[],...i]);continue}Oo(e,n)}return e}var Go=m(()=>{"use strict";l()});var _o=m(()=>{"use strict";l();Ro();Go()});import Tl from"path";import F from"typescript";function Q(t,e){let r=t[e];if(r===void 0)throw new Error(`Index ${e} out of bounds (length ${t.length})`);return r}function yr(t){let e=[];for(let r of t.statements){if(!F.isExpressionStatement(r))continue;let n=r.expression;if(!F.isCallExpression(n))continue;let o=n.expression;F.isIdentifier(o)&&jo.has(o.text)&&e.push(n),F.isPropertyAccessExpression(o)&&F.isIdentifier(o.expression)&&jo.has(o.expression.text)&&e.push(n)}return e}function xr(t,e,r){for(let n of t.arguments){if(!F.isObjectLiteralExpression(n))continue;let o=n.properties.find(s=>F.isPropertyAssignment(s)&&F.isIdentifier(s.name)&&s.name.text===e);if(!(!o||!F.isArrayLiteralExpression(o.initializer)))return o.initializer.elements.filter(F.isStringLiteral).map(s=>s.text)}return null}function br(t,e,r,n){if(t.arguments.length===0)return null;for(let s=1;s<t.arguments.length;s++){let i=Q(t.arguments,s);if(!F.isObjectLiteralExpression(i))continue;let a=i.properties.find(p=>F.isPropertyAssignment(p)&&F.isIdentifier(p.name)&&p.name.text===e);if(a)return{start:a.initializer.getStart(n),end:a.initializer.getEnd(),text:r};let c=i.getEnd()-1;return{start:c,end:c,text:`${i.properties.length>0?", ":""}${e}: ${r}`}}let o=Q(t.arguments,t.arguments.length-1);return{start:o.getStart(n),end:o.getStart(n),text:`{ ${e}: ${r} }, `}}function Sr(t,e,r){let n=t.arguments;for(let o=1;o<n.length;o++){let s=Q(n,o);if(!F.isObjectLiteralExpression(s))continue;let i=s.properties.findIndex(c=>F.isPropertyAssignment(c)&&F.isIdentifier(c.name)&&c.name.text===e);if(i<0)continue;if(s.properties.length===1)return{start:Q(n,o-1).getEnd(),end:s.getEnd(),text:""};let a=Q(s.properties,i);return i===s.properties.length-1?{start:Q(s.properties,i-1).getEnd(),end:a.getEnd(),text:""}:{start:a.getStart(r),end:Q(s.properties,i+1).getStart(r),text:""}}return null}function Cr(t,e){let r=[...e].sort((o,s)=>s.start-o.start),n=t;for(let o of r)n=n.slice(0,o.start)+o.text+n.slice(o.end);return n}function kr(t){return`[${t.map(e=>JSON.stringify(e)).join(", ")}]`}function Fl(t){return t.map(e=>e.startsWith("@")?e.slice(1):e)}function rt(t,e,r,n){let o=F.createSourceFile(Tl.basename(t),e,F.ScriptTarget.Latest,!0),s=yr(o),[i]=s;if(!i)return e;let a=xr(i,n,o),c=[...r].sort();if(a!==null&&JSON.stringify(Fl(a).sort())===JSON.stringify(c))return e;let p=kr(c.map(d=>`@${d}`)),f=s.flatMap(d=>{let y=r.length===0?Sr(d,n,o):br(d,n,p,o);return y?[y]:[]});return f.length>0?Cr(e,f):e}var jo,_,ae=m(()=>{"use strict";l();jo=new Set(["describe","test","it"]);_=new Set([".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"])});import Nl from"path";var nt,Wo=m(()=>{"use strict";l();ae();nt=class{name="cypress";canHandle(e){return _.has(Nl.extname(e).toLowerCase())}apply(e,r,n){return rt(e,r,n,"tags")}}});import Pl from"path";function Il(t){return`${["# <mokosh-tags>",...t.map(e=>`@${e}`),"# </mokosh-tags>"].join(`
10
10
  `)}
11
11
 
12
- `}function Al(t){let e=new Set;Pr.lastIndex=0;let r=Pr.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=Pr.exec(t);return e}var Nr,Pr,it,Go=u(()=>{"use strict";l();Nr=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,Pr=/^@([a-zA-Z0-9_-]+)/gm;it=class{name="gherkin";canHandle(e){return Dl.extname(e).toLowerCase()===".feature"}apply(e,r,n){let o=r.replace(Nr,""),s=Al(o),i=n.filter(c=>!s.has(c)),a=i.length>0?Ml(i):"";return Nr.test(r)?r.replace(Nr,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}}});function _o(t,e){let r=t.replace(/\\/g,"/"),n=e.replace(/\\/g,"/"),o="";for(let s=0;s<r.length;s++){let i=r[s];i==="*"?r[s+1]==="*"?(o+=".*",s++):o+="[^/]*":i==="?"?o+="[^/]":i!==void 0&&(o+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${o}$`).test(n)}var jo=u(()=>{"use strict";l()});import Rl from"path";function Ol(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
13
- `}function Gl(t){let e=Ir.exec(t);if(!e)return null;let r=e[0]??"",n=/mokosh_([a-zA-Z0-9_-]+)/g,o=[],s=n.exec(r);for(;s!==null;)s[1]&&o.push(s[1]),s=n.exec(r);return o}var Ir,Ll,at,Wo=u(()=>{"use strict";l();Ir=/^\/\/go:build mokosh_[^\n]+\n/m,Ll=/^package\s+\S+/m;at=class{name="go";canHandle(e){return Rl.basename(e).endsWith("_test.go")}apply(e,r,n){let o=Gl(r),s=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return r;if(n.length===0)return r.replace(Ir,"");let i=Ol(s);if(o!==null)return r.replace(Ir,i);let a=Ll.exec(r);if(!a)return r;let c=a.index;return`${r.slice(0,c)+i}
14
- ${r.slice(c)}`}}});import _l from"path";function Wl(t){return`${["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
12
+ `}function Dl(t){let e=new Set;wr.lastIndex=0;let r=wr.exec(t);for(;r!==null;)r[1]&&e.add(r[1]),r=wr.exec(t);return e}var vr,wr,ot,zo=m(()=>{"use strict";l();vr=/# <mokosh-tags>[\s\S]*?# <\/mokosh-tags>\n*/,wr=/^@([a-zA-Z0-9_-]+)/gm;ot=class{name="gherkin";canHandle(e){return Pl.extname(e).toLowerCase()===".feature"}apply(e,r,n){let o=r.replace(vr,""),s=Dl(o),i=n.filter(c=>!s.has(c)),a=i.length>0?Il(i):"";return vr.test(r)?r.replace(vr,a):a?r.replace(/^(Feature:)/m,`${a}$1`):r}}});function $o(t,e){let r=t.replace(/\\/g,"/"),n=e.replace(/\\/g,"/"),o="";for(let s=0;s<r.length;s++){let i=r[s];i==="*"?r[s+1]==="*"?(o+=".*",s++):o+="[^/]*":i==="?"?o+="[^/]":i!==void 0&&(o+=i.replace(/[.+^${}()|[\]\\]/g,"\\$&"))}return new RegExp(`^${o}$`).test(n)}var Bo=m(()=>{"use strict";l()});import Ml from"path";function Ll(t){return`//go:build ${t.map(r=>`mokosh_${r}`).join(" || ")}
13
+ `}function Rl(t){let e=Er.exec(t);if(!e)return null;let r=e[0]??"",n=/mokosh_([a-zA-Z0-9_-]+)/g,o=[],s=n.exec(r);for(;s!==null;)s[1]&&o.push(s[1]),s=n.exec(r);return o}var Er,Al,st,Uo=m(()=>{"use strict";l();Er=/^\/\/go:build mokosh_[^\n]+\n/m,Al=/^package\s+\S+/m;st=class{name="go";canHandle(e){return Ml.basename(e).endsWith("_test.go")}apply(e,r,n){let o=Rl(r),s=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return r;if(n.length===0)return r.replace(Er,"");let i=Ll(s);if(o!==null)return r.replace(Er,i);let a=Al.exec(r);if(!a)return r;let c=a.index;return`${r.slice(0,c)+i}
14
+ ${r.slice(c)}`}}});import Ol from"path";function _l(t){return`${["/**",...t.map(e=>` * @group ${e}`)," */"].join(`
15
15
  `)}
16
16
 
17
- `}function zl(t){let e=[];Dr.lastIndex=0;let r=Dr.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=Dr.exec(t);return e}var jl,Dr,ct,zo=u(()=>{"use strict";l();ae();jl=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Dr=/^ \* @group (.+)$/gm;ct=class{name="jest";canHandle(e){return j.has(_l.extname(e).toLowerCase())}apply(e,r,n){let o=jl.exec(r),s=o?zl(o[0]):null,i=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(i))return r;let a=o?r.slice(o[0].length):r;return n.length===0?a:Wl(i)+a}}});import $l from"path";var lt,$o=u(()=>{"use strict";l();ae();lt=class{name="playwright";canHandle(e){return j.has($l.extname(e).toLowerCase())}apply(e,r,n){return ot(e,r,n,"tag")}}});import Bl from"path";function Jl(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function Kl(t){let e=Mr.exec(t);if(!e)return null;let r=e[0],n=[],o=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,s=o.exec(r);for(;s!==null;)s[1]&&n.push(s[1]),s=o.exec(r);return n}function Hl(t){let e=t.split(`
18
- `),r=-1;return e.forEach((o,s)=>{(o.trimStart().startsWith("import ")||o.trimStart().startsWith("from "))&&(r=s)}),r<0?0:e.slice(0,r+1).reduce((o,s)=>o+s.length+1,0)}var Mr,Ul,pt,Bo=u(()=>{"use strict";l();Mr=/^pytestmark\s*=\s*.+$/m,Ul=/^import pytest\s*$/m;pt=class{name="pytest";canHandle(e){return Bl.extname(e).toLowerCase()===".py"}apply(e,r,n){let o=Kl(r),s=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return r;if(n.length===0)return r.replace(Mr,"").replace(/\n{3,}/g,`
17
+ `}function jl(t){let e=[];Tr.lastIndex=0;let r=Tr.exec(t);for(;r!==null;)r[1]&&e.push(r[1]),r=Tr.exec(t);return e}var Gl,Tr,it,Jo=m(()=>{"use strict";l();ae();Gl=/^\/\*\*\n(?: \* @group .+\n)+ \*\/\n+/,Tr=/^ \* @group (.+)$/gm;it=class{name="jest";canHandle(e){return _.has(Ol.extname(e).toLowerCase())}apply(e,r,n){let o=Gl.exec(r),s=o?jl(o[0]):null,i=[...n].sort();if(s!==null&&JSON.stringify([...s].sort())===JSON.stringify(i))return r;let a=o?r.slice(o[0].length):r;return n.length===0?a:_l(i)+a}}});import Wl from"path";var at,Ko=m(()=>{"use strict";l();ae();at=class{name="playwright";canHandle(e){return _.has(Wl.extname(e).toLowerCase())}apply(e,r,n){return rt(e,r,n,"tag")}}});import zl from"path";function Bl(t){let e=t.map(r=>`pytest.mark.${r}`).join(", ");return t.length===1?`pytestmark = pytest.mark.${t[0]}`:`pytestmark = [${e}]`}function Ul(t){let e=Fr.exec(t);if(!e)return null;let r=e[0],n=[],o=/pytest\.mark\.([a-zA-Z0-9_-]+)/g,s=o.exec(r);for(;s!==null;)s[1]&&n.push(s[1]),s=o.exec(r);return n}function Jl(t){let e=t.split(`
18
+ `),r=-1;return e.forEach((o,s)=>{(o.trimStart().startsWith("import ")||o.trimStart().startsWith("from "))&&(r=s)}),r<0?0:e.slice(0,r+1).reduce((o,s)=>o+s.length+1,0)}var Fr,$l,ct,Ho=m(()=>{"use strict";l();Fr=/^pytestmark\s*=\s*.+$/m,$l=/^import pytest\s*$/m;ct=class{name="pytest";canHandle(e){return zl.extname(e).toLowerCase()===".py"}apply(e,r,n){let o=Ul(r),s=[...n].sort();if(o!==null&&JSON.stringify([...o].sort())===JSON.stringify(s))return r;if(n.length===0)return r.replace(Fr,"").replace(/\n{3,}/g,`
19
19
 
20
- `);let i=Jl(s);if(o!==null)return r.replace(Mr,i);let a=Ul.test(r),c=Hl(r),p=r.slice(0,c),m=r.slice(c),d=a?"":`import pytest
20
+ `);let i=Bl(s);if(o!==null)return r.replace(Fr,i);let a=$l.test(r),c=Jl(r),p=r.slice(0,c),f=r.slice(c),d=a?"":`import pytest
21
21
  `,y=p.endsWith(`
22
22
 
23
23
  `)?"":`
24
24
  `;return`${p+y+d+i}
25
- ${m}`}}});import Uo from"path";import Jo from"typescript";var Vl,ft,Ko=u(()=>{"use strict";l();ae();Vl=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,ft=class{name="vitest";canHandle(e){return j.has(Uo.extname(e).toLowerCase())}apply(e,r,n){let o=r.replace(Vl,""),s=Jo.createSourceFile(Uo.basename(e),o,Jo.ScriptTarget.Latest,!0),i=vr(s),[a]=i;if(!a)return o;let c=kr(a,"tags",s),p=[...n].sort();if(c!==null&&JSON.stringify([...c].sort())===JSON.stringify(p))return o;let m=i.flatMap(d=>{let y=n.length===0?Er(d,"tags",s):wr(d,"tags",Tr(p),s);return y?[y]:[]});return m.length>0?Fr(o,m):o}}});import Ar from"path";import mt from"typescript";function Yl(t){let e=mt.createSourceFile("detect.ts",t,mt.ScriptTarget.Latest,!0);for(let r of e.statements){if(!mt.isImportDeclaration(r)||!mt.isStringLiteral(r.moduleSpecifier))continue;let n=Ql[r.moduleSpecifier.text];if(n)return n}return null}function Vo(t="vitest",e={},r=process.cwd()){return[new it,new pt,new at,new Rr(r,t,Object.entries(e))]}function Qo(t,e){return e.find(r=>r.canHandle(t))??null}var Ho,Ql,Rr,Yo=u(()=>{"use strict";l();Oo();Go();jo();Wo();zo();$o();Bo();ae();Ko();Ho={vitest:()=>new ft,playwright:()=>new lt,cypress:()=>new st,jest:()=>new ct},Ql={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};Rr=class{constructor(e,r,n){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=n}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return j.has(Ar.extname(e).toLowerCase())}apply(e,r,n){let o=Yl(r)??this.matchOverride(e)??this.defaultFramework;return(Ho[o]??Ho.vitest)().apply(e,r,n)}matchOverride(e){let r=Ar.relative(this.rootDir,e).split(Ar.sep).join("/");for(let[n,o]of this.frameworkOverrides)if(_o(n,r))return o;return null}}});import Xo from"fs/promises";import Xl from"path";async function tp(t,e,r,n){let o;try{o=await Xo.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let s=Qo(t,n);if(!s)return{path:t,status:"unchanged"};let i=s.apply(t,o,e);return i===o?{path:t,status:"unchanged"}:(r||await Xo.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function Lr(t,e,r){let n=ne(e),o=n.tagApplier?.framework??"vitest",s=n.tagApplier?.frameworkOverrides??{},i=Vo(o,s,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let c of t.nodes.values()){if(c.category!=="test")continue;let p=new Set,m=[];for(let x of c.tags)Zl.has(x.kind)&&ql.test(x.name)&&(ep.has(x.name.toLowerCase())||p.has(x.name)||(p.add(x.name),m.push(x.name)));m.sort();let d=Xl.resolve(e,c.path),y=await tp(d,m,r.dryRun,i);y.path=c.path,a.files.push(y),y.status==="updated"?a.updated++:y.status==="unchanged"?a.unchanged++:a.errors++}return a}var ql,Zl,ep,qo=u(()=>{"use strict";l();Rt();Yo();ql=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,Zl=new Set(["import"]),ep=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"])});var ut,Or=u(()=>{"use strict";l();ut=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}}});import{execFileSync as Gr}from"child_process";function ts(t,e){let r="",n=0;for(let o of t.split(`
26
- `)){if(o.startsWith("\0")){let[,c,p]=o.slice(1).split(" ");r=c??"",n=p?Number(p)*1e3:0;continue}if(o==="")continue;let s=o.split(" "),i=s[0];if(!i)continue;let a=i.startsWith("R")||i.startsWith("C")?s[2]:s[1];a&&e(a,r,n)}}function rs(t){let e=new Map;try{let r=Gr("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${Zo}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:es});ts(r,(n,o,s)=>{let i=e.get(n);if(i){i.commitCount90d+=1;return}e.set(n,{commitCount90d:1,lastAuthor:o||void 0,lastCommitAt:s||void 0})})}catch{return e}try{let r=Gr("git",["-C",t,"log","--name-status","-M",`--format=${Zo}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:es});ts(r,(n,o,s)=>{e.has(n)||e.set(n,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:s||void 0})})}catch{}return e}var gt,Zo,es,_r=u(()=>{"use strict";l();gt=class{getChangedFiles(){try{let r=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"]].flatMap(n=>{try{return Gr("git",n,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
27
- `).map(s=>s.trim()).filter(s=>s!=="")}catch{return[]}});return Array.from(new Set(r))}catch(e){return console.error("Error getting git diff:",e),[]}}},Zo="%x00%H%x09%ae%x09%at",es=256*1024*1024});import ns from"path";function z(t){switch(ns.extname(t).toLowerCase()){case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".ts":case".tsx":return"typescript";case".css":return"css";case".scss":case".sass":return"scss";case".less":return"less";case".styl":return"stylus";case".coffee":return"coffeescript";case".ls":return"livescript";case".lua":return"lua";case".py":return"python";case".go":return"go";case".java":case".cpp":case".cc":case".cxx":case".c":return"unknown";case".feature":return"gherkin";case".md":case".mdx":return"markdown";default:return"unknown"}}function O(t){let e=ns.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var $=u(()=>{"use strict";l()});function B(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function ce(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=r.exec(t);for(;n!==null;)n[1]&&e.add(n[1]),n=r.exec(t);return e}function le(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}var dt=u(()=>{"use strict";l()});import rp from"coffeescript";function ss(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return B(t.value)}}function Y(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function np(t,e){let r=ss(e.source);return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:O(r),type:"static"}:null}function op(t,e){let r=e.variable?.base?.value==="require",n=ss(e.args?.[0]?.base);return!r||!n?null:{fromPath:t,toPath:"",rawSpecifier:n,isStyle:O(n),type:"require"}}function os(t,e){if(e)return[{name:e}];let r=t.value;if(r?.constructor?.name==="Class"){let o=Y(r.variable);return o?[{name:o}]:[]}if(r?.base?.constructor?.name==="Obj"&&Array.isArray(r.base.properties))return r.base.properties.map(o=>Y(o.variable)??Y(o)).filter(o=>!!o).map(o=>({name:o}));let n=Y(r);return n?[{name:n}]:[]}function sp(t){if(Array.isArray(t.specifiers))return t.specifiers.map(r=>r.identifier??r.original?.value).filter(r=>!!r).map(r=>({name:r}));let e=Y(t.variable)??Y(t.variable?.base);return e?[{name:e}]:[]}function ip(t,e,r,n){let o=e.constructor?.name;if(o==="ImportDeclaration"){let s=np(t,e);s&&r.push(s)}else if(o==="Call"){let s=op(t,e);s&&r.push(s)}else if(o==="Assign"){let s=Y(e.variable?.base),i=e.variable?.properties?.[0]?.name?.value;s==="module"&&i==="exports"?n.push(...os(e,void 0)):s==="exports"&&typeof i=="string"&&n.push(...os(e,i))}else o==="ExportNamedDeclaration"&&e.clause?n.push(...sp(e.clause)):o==="ExportDefaultDeclaration"&&n.push({name:"default"})}function jr(t,e,r,n){if(!(!e||typeof e!="object")){ip(t,e,r,n);for(let o in e){if(o==="locationData")continue;let s=e[o];if(!(!s||typeof s!="object"))if(Array.isArray(s))for(let i of s)jr(t,i,r,n);else jr(t,s,r,n)}}}function is(t,e){let r=ce(e),n=le(t,r),o=[],s=[];try{jr(t,rp.nodes(e),o,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var as=u(()=>{"use strict";l();$();dt()});import{AstBuilder as ap,GherkinClassicTokenMatcher as cp,Parser as lp}from"@cucumber/gherkin";import{IdGenerator as pp}from"@cucumber/messages";function Wr(t,e){let r=new Set;try{let n=new ap(fp),o=new cp,i=new lp(n,o).parse(e);i.feature&&(i.feature.tags.forEach(a=>{r.add(a.name.startsWith("@")?a.name.slice(1):a.name)}),i.feature.children.forEach(a=>{a.scenario&&(a.scenario.tags.forEach(c=>{r.add(c.name.startsWith("@")?c.name.slice(1):c.name)}),a.scenario.examples.forEach(c=>{c.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})),a.rule&&a.rule.children.forEach(c=>{c.scenario&&c.scenario.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})}))}catch(n){console.warn(`[GherkinParser] Failed to parse ${t}:`,n)}return{imports:[],exports:[],tags:Array.from(r).map(n=>({name:n,kind:"comment-marker"})),category:"test"}}var fp,cs=u(()=>{"use strict";l();Ce();fp=pp.uuid();ie("gherkin",Wr)});function X(t){let e=[],r=t.firstChild;for(;r;)e.push(r),r=r.nextSibling;return e}function ke(t,e){let r=1;for(let n=0;n<e&&n<t.length;n++)t[n]===`
28
- `&&r++;return r}var zr=u(()=>{"use strict";l()});function mp(t,e){let r=1;function n(o){switch(o.type.name){case"IfStatement":case"ForStatement":r++;break;case"Case":{o.firstChild?.type.name==="case"&&r++;break}case"LogicOp":{let i=e.slice(o.from,o.to);(i==="&&"||i==="||")&&r++;break}}let s=o.firstChild;for(;s;)n(s),s=s.nextSibling}return n(t),r}function up(t,e){let r=0;function n(o,s,i){let a=o.type.name;if(a==="IfStatement"){r+=i?1:1+s;let m=X(o),d=i?s:s+1,y=m[1];y&&y.type.name!=="Block"&&n(y,d,!1);let x=m.find(C=>C.type.name==="Block");x&&n(x,d,!1);let S=m.findIndex(C=>C.type.name==="else");if(S>=0){let C=m[S+1];C?.type.name==="IfStatement"?n(C,s,!0):C&&(r+=1,n(C,s+1,!1))}return}if(a==="ForStatement"||a==="SwitchStatement"||a==="SelectStatement"){r+=1+s;let m=o.firstChild;for(;m;)n(m,s+1,!1),m=m.nextSibling;return}if(a==="LogicOp"){let m=e.slice(o.from,o.to);(m==="&&"||m==="||")&&(r+=1)}if(s>0&&a==="FunctionLiteral"){r+=1+s;let m=o.firstChild;for(;m;)n(m,s+1,!1),m=m.nextSibling;return}let p=o.firstChild;for(;p;)n(p,s,!1),p=p.nextSibling}return n(t,0,!1),r}function ht(t,e){return{complexity:mp(t,e),cognitiveComplexity:up(t,e)}}function $r(t,e){let n=t.getChild("Parameters")?.getChild("Parameter"),o=n?.getChild("TypeName")??n?.getChild("PointerType")?.getChild("TypeName");return o?e.slice(o.from,o.to):void 0}function ls(t,e){let r=[],n=t.cursor();do if(n.name==="FunctionDecl"){let o=n.node.getChild("DefName");if(o){let s=e.slice(o.from,o.to),{complexity:i,cognitiveComplexity:a}=ht(n.node,e);r.push({name:s,line:ke(e,n.from),complexity:i,cognitiveComplexity:a})}}else if(n.name==="MethodDecl"){let o=n.node.getChild("FieldName");if(o){let s=e.slice(o.from,o.to),i=$r(n.node,e),a=i?`${i}.${s}`:s,{complexity:c,cognitiveComplexity:p}=ht(n.node,e);r.push({name:a,line:ke(e,n.from),complexity:c,cognitiveComplexity:p})}}while(n.next());return r}var ps=u(()=>{"use strict";l();zr()});import gp from"path";import{parser as dp}from"@lezer/go";function ms(t,e){let r=[],n=new Map,o=new Set,s=new Set,i=new Map,a=dp.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let k=e.slice(c.from,c.to),b=k.match(hp);b?.[1]&&o.add(b[1]);let v=k.match(yp);v&&fs(v[1],s);let P=k.match(xp);P&&fs(P[1],s);break}case"ImportSpec":{let k=c.node.getChild("String");if(k){let v=e.slice(k.from,k.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:v,isExternal:!0,isStyle:!1,type:"static"});let P=c.node.getChild("DefName"),A=P?e.slice(P.from,P.to):v.split("/").pop();A&&A!=="_"&&A!=="."&&i.set(A,v)}break}case"FunctionDecl":case"MethodDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let k=c.node.getChild("DefName")??c.node.getChild("FieldName")??c.node.getChild("TypeSpec")?.getChild("DefName")??c.node.getChild("VarSpec")?.getChild("DefName")??c.node.getChild("ConstSpec")?.getChild("DefName");if(k){let b=e.slice(k.from,k.to);b!=="_"&&/^[A-Z]/.test(b)&&!n.has(b)&&n.set(b,{name:b})}break}}while(c.next());let p=r.some(k=>k.rawSpecifier==="testing"),m=gp.basename(t).endsWith("_test.go")||o.has("test")||p?"test":"logic",d=new Set([...o,...s]),{complexity:y,cognitiveComplexity:x}=ht(a.topNode,e),S=ls(a,e),C=m==="test"?[]:bp(a,e,i);return{imports:r,exports:Array.from(n.values()),tags:Array.from(d).map(k=>({name:k,kind:"comment-marker"})),category:m,rawCallEdges:C,complexity:y,cognitiveComplexity:x,...S.length>0?{functions:S}:{}}}function bp(t,e,r){let n=[];function o(i,a){if(i.type.name==="CallExpr"){let p=i.firstChild;if(p?.type.name==="SelectorExpr"){let m=p.firstChild,d=p.getChild("FieldName");if(m?.type.name==="VariableName"&&d){let y=e.slice(m.from,m.to),x=r.get(y);if(x){let S=e.slice(d.from,d.to);n.push({from:a,to:S,toSpecifier:x})}}}}let c=i.firstChild;for(;c;)o(c,a),c=c.nextSibling}let s=t.cursor();do if(s.name==="FunctionDecl"){let i=s.node.getChild("DefName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to);/^[A-Z]/.test(c)&&o(a,c)}}else if(s.name==="MethodDecl"){let i=s.node.getChild("FieldName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to),p=$r(s.node,e);o(a,p?`${p}.${c}`:c)}}while(s.next());return n}function fs(t,e){for(let r of t.split(/[\s,&|!()]+/)){let n=r.trim();n&&n!=="ignore"&&e.add(n)}}var hp,yp,xp,us=u(()=>{"use strict";l();ps();hp=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,yp=/^\/\/go:build\s+(.+)$/,xp=/^\/\/\s*\+build\s+(.+)$/});import Sp from"livescript";function q(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function Cp(t){if(!t)return[];if(t.constructor?.name==="Class"){let r=q(t.title);return r?[{name:r}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(r=>q(r.key)??q(r.val)).filter(r=>!!r).map(r=>({name:r}));let e=q(t);return e?[{name:e}]:[]}function vp(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let r=t.left,n=q(r.head),s=r.tails?.[0]?.key?.name;if(n==="module"&&s==="exports")return Cp(t.right);if(n==="exports"&&typeof s=="string")return[{name:s}];if(r.head?.verb==="out"&&typeof s=="string")return[{name:s}]}if(e==="Import"&&t.left?.verb==="out"){let r=t.right;if(r?.constructor?.name==="Obj"&&Array.isArray(r.items))return r.items.map(n=>q(n.val)??q(n.key)).filter(n=>!!n).map(n=>({name:n}))}return[]}function wp(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let n=t.right?.value;if(typeof n=="string"){let o=B(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:O(o),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let n=t.tails?.[0];if(n?.constructor?.name==="Call"||n?.type==="Call"){let o=n.args?.[0]?.value;if(typeof o=="string"){let s=B(o);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:O(s),type:"require"}}}}return null}function Br(t,e,r){if(!t||typeof t!="object")return[];let n=[],o=wp(t,e);o&&n.push(o),r.push(...vp(t));for(let s in t){if(kp.has(s))continue;let i=t[s];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)n.push(...Br(a,e,r));else n.push(...Br(i,e,r))}return n}function gs(t,e){let r=ce(e),n=le(t,r),o=[],s=[];try{o=Br(Sp.ast(e),t,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var kp,ds=u(()=>{"use strict";l();$();dt();kp=new Set(["first_line","first_column","last_line","last_column","line","column"])});import Ep from"luaparse";function Fp(t,e){let r=[];function n(o){if(!(!o||typeof o!="object")){if((o.type==="CallExpression"||o.type==="StringCallExpression")&&o.base?.type==="Identifier"&&o.base?.name==="require"){let s;if(o.type==="CallExpression"){let i=o.arguments?.[0];i?.type==="StringLiteral"&&(s=B(i.raw))}else if(o.type==="StringCallExpression"){let i=o.argument;i?.type==="StringLiteral"&&(s=B(i.raw))}s&&r.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:O(s),type:"require"})}for(let s in o){if(s==="loc")continue;let i=o[s];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)n(a);else n(i)}}}return n(t),r}function Tp(t){let e=new Set;for(let r of t)r.type==="LocalStatement"&&r.variables.forEach((n,o)=>{r.init[o]?.type==="TableConstructorExpression"&&e.add(n.name)});return e}function Np(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let r=e.arguments[0];if(r?.type!=="TableConstructorExpression")return[];let n=[];for(let o of r.fields)o.type==="TableKeyString"&&n.push({name:o.key.name});return n}function Pp(t){let e=t.body,r=Tp(e),n=Np(e);for(let s of e)if(s.type==="FunctionDeclaration")s.identifier?.type==="MemberExpression"?s.identifier.base.type==="Identifier"&&r.has(s.identifier.base.name)&&n.push({name:s.identifier.identifier.name}):s.identifier?.type==="Identifier"&&!s.isLocal&&n.push({name:s.identifier.name});else if(s.type==="AssignmentStatement")for(let i of s.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&r.has(i.base.name)&&n.push({name:i.identifier.name});let o=new Set;return n.filter(s=>o.has(s.name)?!1:(o.add(s.name),!0))}function hs(t,e){let r=ce(e),n=le(t,r),o=[],s=[];try{let i=Ep.parse(e);o=Fp(i,t),s=Pp(i)}catch{}return{imports:o,exports:s,tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:n}}var ys=u(()=>{"use strict";l();$();dt()});async function Ap(){return xs??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),xs}function Rp(t){let e=t.trim();return e.length===0||e.startsWith("#")||Ip.some(r=>e.startsWith(r))}function Lp(t,e){let r=t.match(Mp);return r?r.map(n=>({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!1,type:"static"})):[]}function bs(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!Rp(t.url)&&r.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static"}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&r.push(...Lp(t.value,e)),Array.isArray(t.children))for(let n of t.children)bs(n,e,r)}async function Ss(t,e){let n=(await Ap()).parse(e),o=[];bs(n,t,o);let s=new Set;return{imports:o.filter(a=>s.has(a.rawSpecifier)?!1:(s.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var Ip,Dp,Mp,xs,Cs=u(()=>{"use strict";l();Ip=["http://","https://","mailto:","//"],Dp="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Mp=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${Dp})\\b`,"g")});function Op(t){let e=1;function r(n){switch(n.type.name){case"IfStatement":{e+=X(n).filter(s=>s.type.name==="if"||s.type.name==="elif").length;break}case"TryStatement":{e+=X(n).filter(s=>s.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let o=n.firstChild;for(;o;)r(o),o=o.nextSibling}return r(t),e}function Gp(t){let e=0;function r(n,o){let s=n.type.name;if(s==="IfStatement"){let c=X(n),p=0,m=0;for(;m<c.length;){let d=c[m];if(d?.type.name==="if"||d?.type.name==="elif"){let y=p>0;e+=y?1:1+o;let x=y?o:o+1,S=c[m+1],C=c[m+2];S&&r(S,x),C&&r(C,x),p++,m+=3}else if(d?.type.name==="else"){e+=1;let y=c[m+1];y&&r(y,o+1),m+=2}else m++}return}if(s==="TryStatement"){let c=X(n),p=0;for(;p<c.length;){let m=c[p];if(m?.type.name==="except"){for(e+=1+o,p++;p<c.length&&c[p]?.type.name!=="Body";)r(c[p],o),p++;p<c.length&&(r(c[p],o),p++)}else m?.type.name==="Body"&&r(m,o),p++}return}if(s==="ForStatement"||s==="WhileStatement"){e+=1+o;let c=n.firstChild;for(;c;)r(c,o+1),c=c.nextSibling;return}if((s==="ConditionalExpression"||s==="and"||s==="or")&&(e+=1),o>0&&(s==="FunctionDefinition"||s==="LambdaExpression")){e+=1+o;let c=n.firstChild;for(;c;)r(c,o+1),c=c.nextSibling;return}let a=n.firstChild;for(;a;)r(a,o),a=a.nextSibling}return r(t,0),e}function Ur(t){return{complexity:Op(t),cognitiveComplexity:Gp(t)}}function vs(t,e){let r=[];function n(i,a){let{complexity:c,cognitiveComplexity:p}=Ur(i);r.push({name:a,line:ke(e,i.from),complexity:c,cognitiveComplexity:p})}function o(i){let a=i.firstChild;for(;a;)s(a),a=a.nextSibling}function s(i){if(i.type.name==="ClassDefinition"){let a=i.getChild("VariableName"),c=a?e.slice(a.from,a.to):void 0,p=i.getChild("Body");if(p){let m=p.firstChild;for(;m;){if(m.type.name==="FunctionDefinition"){let d=m.getChild("VariableName"),y=d?e.slice(d.from,d.to):void 0;y&&n(m,c?`${c}.${y}`:y),o(m)}else s(m);m=m.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&n(i,e.slice(a.from,a.to)),o(i);return}o(i)}return s(t.topNode),r}var ks=u(()=>{"use strict";l();zr()});import _p from"path";import{parser as jp}from"@lezer/python";function ws(t,e){let r=[],n=[],o=new Set,s=_p.basename(t).toLowerCase(),i=jp.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let x=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);x?.[1]&&o.add(x[1]);break}case"ImportStatement":{for(let x of zp(a.node,e,t))r.push(x);break}case"FunctionDefinition":case"ClassDefinition":{let x=a.node.parent;if(x?.name==="Script"||x?.name==="DecoratedStatement"&&x.parent?.name==="Script"){let C=a.node.getChild("VariableName");C&&n.push({name:e.slice(C.from,C.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let x=a.node.firstChild;x?.name==="VariableName"&&n.push({name:e.slice(x.from,x.to)})}break}}while(a.next());let c=Hp(s,r,o);c==="test"&&o.add("test");let{complexity:p,cognitiveComplexity:m}=Ur(i.topNode),d=vs(i,e),y=c==="test"?[]:Kp(i,e);return{imports:r,exports:n,tags:Array.from(o).map(x=>({name:x,kind:"comment-marker"})),category:c,rawCallEdges:y,complexity:p,cognitiveComplexity:m,...d.length>0?{functions:d}:{}}}function zp(t,e,r){let n=t.firstChild;return n?n.name==="from"?$p(t,e,r):Bp(t,e,r):[]}function $p(t,e,r){let n=t.firstChild;if(!n)return[];let o=n.nextSibling;for(;o&&o.name!=="import";)o=o.nextSibling;if(!o)return[];let s=e.slice(n.to,o.from).trim(),i=Up(o.nextSibling,e);if(!i.length)return[];let a=0;for(;a<s.length&&s[a]===".";)a++;let c=s.slice(a);if(a===0)return[we(r,s,i,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[we(r,p+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[we(r,p.slice(0,-1),["*"],!1)]:i.map(m=>we(r,p+m,[m],!1))}function Bp(t,e,r){let n=[],o=t.firstChild?.nextSibling??null;for(;o;){if(o.name==="VariableName"){let s=e.slice(o.from,o.to);for(;o.nextSibling?.name==="."&&o.nextSibling.nextSibling?.name==="VariableName";)o=o.nextSibling.nextSibling,s+=`.${e.slice(o.from,o.to)}`;o.nextSibling?.name==="as"&&(o=o.nextSibling.nextSibling??o.nextSibling),n.push(we(r,s,["*"],!0))}o=o.nextSibling}return n}function Up(t,e){let r=[],n=t;for(;n;)n.name==="*"?r.push("*"):n.name==="VariableName"&&(r.push(e.slice(n.from,n.to)),n.nextSibling?.name==="as"&&(n=n.nextSibling.nextSibling??n.nextSibling)),n=n.nextSibling;return r}function Jp(t,e){let r=new Map,n=t.cursor();do{if(n.name!=="ImportStatement")continue;let s=n.node.firstChild;if(s?.type.name!=="from")continue;let i=s.nextSibling;for(;i&&i.type.name!=="import";)i=i.nextSibling;if(!i)continue;let a=e.slice(s.to,i.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let p=a.slice(c),m=c<=1?"./":"../".repeat(c-1),d=i.nextSibling;for(;d;){if(d.type.name==="VariableName"){let y=e.slice(d.from,d.to),x=y;if(d.nextSibling?.type.name==="as"){let C=d.nextSibling.nextSibling;C?.type.name==="VariableName"&&(x=e.slice(C.from,C.to),d=C)}let S=c===0?a:p?m+p.replace(/\./g,"/"):m+y;r.set(x,S)}d=d.nextSibling}}while(n.next());return r}function Kp(t,e){let r=Jp(t,e),n=[];function o(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let m=a.firstChild,d=e.slice(m.from,m.to),y=r.get(d);y&&n.push({from:c,to:d,toSpecifier:y})}let p=a.firstChild;for(;p;)o(p,c),p=p.nextSibling}function s(a){let c=a.firstChild;for(;c;)i(c),c=c.nextSibling}function i(a){if(a.type.name==="ClassDefinition"){let c=a.getChild("VariableName"),p=c?e.slice(c.from,c.to):void 0,m=a.getChild("Body");if(m){let d=m.firstChild;for(;d;){if(d.type.name==="FunctionDefinition"){let y=d.getChild("VariableName"),x=y?e.slice(y.from,y.to):void 0;x&&o(d,p?`${p}.${x}`:x)}else i(d);d=d.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&o(a,e.slice(c.from,c.to));return}s(a)}return i(t.topNode),n}function we(t,e,r,n){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:n,type:"static",symbols:r.length>0?r:void 0}}function Hp(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(n=>Wp.has(n.rawSpecifier))?"test":"logic"}var Wp,Es=u(()=>{"use strict";l();ks();Wp=new Set(["pytest","unittest","nose","hypothesis"])});import w from"typescript";function Vp(t){let e=1;function r(n){switch(n.kind){case w.SyntaxKind.IfStatement:case w.SyntaxKind.ConditionalExpression:case w.SyntaxKind.ForStatement:case w.SyntaxKind.ForInStatement:case w.SyntaxKind.ForOfStatement:case w.SyntaxKind.WhileStatement:case w.SyntaxKind.DoStatement:case w.SyntaxKind.CatchClause:case w.SyntaxKind.CaseClause:e++;break;case w.SyntaxKind.BinaryExpression:{let o=n.operatorToken.kind;(o===w.SyntaxKind.AmpersandAmpersandToken||o===w.SyntaxKind.BarBarToken||o===w.SyntaxKind.QuestionQuestionToken)&&e++;break}}w.forEachChild(n,r)}return r(t),e}function Qp(t){let e=0;function r(n,o,s){if(w.isIfStatement(n)){e+=s?1:1+o;let a=s?o:o+1;r(n.expression,a,!1),r(n.thenStatement,a,!1),n.elseStatement&&(w.isIfStatement(n.elseStatement)?r(n.elseStatement,o,!0):(e+=1,r(n.elseStatement,o+1,!1)));return}if(w.isForStatement(n)||w.isForInStatement(n)||w.isForOfStatement(n)||w.isWhileStatement(n)||w.isDoStatement(n)||w.isSwitchStatement(n)){e+=1+o,w.forEachChild(n,a=>r(a,o+1,!1));return}if(w.isCatchClause(n)){e+=1+o,w.forEachChild(n,a=>r(a,o,!1));return}if(w.isConditionalExpression(n)&&(e+=1),w.isBinaryExpression(n)){let a=n.operatorToken.kind;(a===w.SyntaxKind.AmpersandAmpersandToken||a===w.SyntaxKind.BarBarToken||a===w.SyntaxKind.QuestionQuestionToken)&&(e+=1)}if(o>0&&(w.isFunctionDeclaration(n)||w.isFunctionExpression(n)||w.isArrowFunction(n))){e+=1+o,w.forEachChild(n,a=>r(a,o+1,!1));return}w.forEachChild(n,a=>r(a,o,!1))}return r(t,0,!1),e}function Jr(t){return{complexity:Vp(t),cognitiveComplexity:Qp(t)}}var Fs=u(()=>{"use strict";l()});import T from"typescript";function Ts(t,e){Yp(t,e),qp(t,e),Zp(t,e),ef(t,e)}function Yp(t,e){if((T.isFunctionDeclaration(t)||T.isVariableDeclaration(t))&&t.name&&T.isIdentifier(t.name)&&Xp(t)){let r;if(T.isFunctionDeclaration(t))r="function";else{let n=t.initializer;r=n&&(T.isArrowFunction(n)||T.isFunctionExpression(n))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function Xp(t){if(T.isFunctionDeclaration(t))return T.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&T.isSourceFile(e.parent)}function qp(t,e){if(!T.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let n of r)e.tags.add({name:n.substring(1),kind:"comment-marker"})}function Zp(t,e){if(!T.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=t.getFullText(),o=r.exec(n);for(;o!==null;)o[1]&&e.tags.add({name:o[1],kind:"comment-marker"}),o=r.exec(n)}function ef(t,e){if(T.isCallExpression(t)&&tf(t.expression))for(let r of t.arguments)T.isObjectLiteralExpression(r)&&rf(r,e)}function tf(t){return T.isIdentifier(t)?Kr.has(t.text):!!(T.isPropertyAccessExpression(t)&&(Kr.has(t.name.text)||T.isIdentifier(t.expression)&&Kr.has(t.expression.text)))}function rf(t,e){for(let r of t.properties){if(!T.isPropertyAssignment(r)||!T.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:n}=r,o=T.isArrayLiteralExpression(n)?n.elements.filter(T.isStringLiteral):r.name.text==="tag"&&T.isStringLiteral(n)?[n]:[];for(let s of o)e.tags.add({name:s.text.replace(/^@/,""),kind:"comment-marker"})}}var Kr,Ns=u(()=>{"use strict";l();Kr=new Set(["test","describe","it"])});import Ps from"path";import h from"typescript";function Hr(t,e,r){let n=[],o=new Map,s=new Set,i=h.createSourceFile(t,e,h.ScriptTarget.Latest,!0,r==="typescript"?h.ScriptKind.TSX:h.ScriptKind.JSX),a={filePath:t,imports:n,exports:o,tags:s,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=C=>{af(C,a),h.forEachChild(C,c)};c(i);let p=xf(t,a);(p==="test"||p==="barrel")&&s.add({name:p,kind:"comment-marker"}),p!=="test"&&bf(a,i);let m=i.statements[0],d=m?Ds(m):void 0,{complexity:y,cognitiveComplexity:x}=Jr(i),S=nf(i);return{imports:n,exports:Array.from(o.values()),tags:Array.from(s),category:p,rawCallEdges:a.rawCallEdges??[],complexity:y,cognitiveComplexity:x,...S.length>0?{functions:S}:{},...d!==void 0?{description:d}:{}}}function nf(t){let e=[],r=(o,s)=>{let{complexity:i,cognitiveComplexity:a}=Jr(s),c=t.getLineAndCharacterOfPosition(s.getStart(t)).line+1;e.push({name:o,line:c,complexity:i,cognitiveComplexity:a})},n=(o,s)=>{if(h.isFunctionDeclaration(o)&&o.name&&o.body?r(o.name.text,o):h.isVariableDeclaration(o)&&h.isIdentifier(o.name)&&o.initializer&&(h.isArrowFunction(o.initializer)||h.isFunctionExpression(o.initializer))?r(o.name.text,o.initializer):s&&h.isMethodDeclaration(o)&&h.isIdentifier(o.name)&&o.body?r(`${s}.${o.name.text}`,o):s&&h.isConstructorDeclaration(o)&&o.body?r(`${s}.constructor`,o):s&&h.isGetAccessorDeclaration(o)&&h.isIdentifier(o.name)&&o.body?r(`${s}.get ${o.name.text}`,o):s&&h.isSetAccessorDeclaration(o)&&h.isIdentifier(o.name)&&o.body&&r(`${s}.set ${o.name.text}`,o),h.isClassDeclaration(o)&&o.name){let i=o.name.text;h.forEachChild(o,a=>n(a,i));return}h.forEachChild(o,i=>n(i,s))};return n(t,void 0),e}function Is(t,e,r,n){let o={name:t},s=Ds(r);s!==void 0&&(o.doc=s);let i=of(e);i!==void 0&&(o.flags=i);let a=sf(e,n);return a!==void 0&&(o.signature=a),o}function Ds(t){let e=h.getJSDocCommentsAndTags(t);for(let r of e)if(h.isJSDoc(r)&&r.comment)return h.getTextOfJSDocComment(r.comment)||void 0}function of(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=h.getJSDocTags(t).map(n=>n.tagName.text).filter(n=>e.has(n));return r.length>0?r:void 0}function sf(t,e){let r=h.createPrinter({removeComments:!0}),n=o=>r.printNode(h.EmitHint.Unspecified,o,e);if(h.isFunctionDeclaration(t)||h.isMethodDeclaration(t)){let o=t.parameters.map(n).join(", "),s=t.type?n(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${o}) => ${s}`}if(h.isVariableDeclaration(t)){if(t.type)return n(t.type);if(t.initializer&&(h.isArrowFunction(t.initializer)||h.isFunctionExpression(t.initializer))){let o=t.initializer,s=o.parameters.map(n).join(", "),i=o.type?n(o.type):"unknown";return`(${s}) => ${i}`}return}if(h.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(h.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(h.isTypeAliasDeclaration(t))return n(t.type);if(h.isEnumDeclaration(t))return`enum ${t.name.text}`}function af(t,e){cf(t,e),lf(t,e),ff(t,e),mf(t,e),yf(t,e),Ts(t,e)}function cf(t,e){if(!h.isSourceFile(t))return;let r=t.statements.filter(n=>!h.isEmptyStatement(n));e.totalStatements=r.length,e.exportStatements=r.filter(n=>h.isExportDeclaration(n)||h.isExportAssignment(n)||Vr(n)).length}function lf(t,e){if(h.isJsxElement(t)||h.isJsxSelfClosingElement(t)||h.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(h.isFunctionDeclaration(t)||h.isMethodDeclaration(t)||h.isArrowFunction(t)||h.isClassDeclaration(t)||h.isVariableStatement(t)||h.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}h.isExportDeclaration(t)&&!pf(t)&&(e.hasTypesOnly=!1)}function pf(t){return t.isTypeOnly?!0:!t.exportClause||!h.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function ff(t,e){if(!h.isImportDeclaration(t)||!t.moduleSpecifier||!h.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(h.isNamedImports(t.importClause.namedBindings))for(let o of t.importClause.namedBindings.elements)r.push(o.name.text);else h.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let n=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:O(t.moduleSpecifier.text),type:n,symbols:r.length>0?r:void 0})}function mf(t,e){h.isExportDeclaration(t)?uf(t,e):h.isExportAssignment(t)?e.exports.set("default",{name:"default"}):Vr(t)&&hf(t,e)}function uf(t,e){if(t.moduleSpecifier&&h.isStringLiteral(t.moduleSpecifier))gf(t,t.moduleSpecifier.text,e);else if(t.exportClause&&h.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let n=r.name.text;e.exports.set(n,{name:n})}}function gf(t,e,r){let n=df(t),o={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:O(e),type:"re-export"};n.length>0&&(o.symbols=n),r.imports.push(o)}function df(t){return t.exportClause?h.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function hf(t,e){if((h.isFunctionDeclaration(t)||h.isClassDeclaration(t)||h.isInterfaceDeclaration(t)||h.isTypeAliasDeclaration(t)||h.isEnumDeclaration(t))&&t.name){let n=t.name.text;e.exports.set(n,Is(n,t,t,e.sourceFile));return}if(h.isVariableStatement(t)){for(let n of t.declarationList.declarations)if(h.isIdentifier(n.name)){let o=n.name.text;e.exports.set(o,Is(o,n,t,e.sourceFile))}}}function yf(t,e){if(!h.isCallExpression(t))return;let r=t.arguments[0];!r||!h.isStringLiteral(r)||(t.expression.kind===h.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:O(r.text),type:"dynamic"}):h.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:O(r.text),type:"require"}))}function xf(t,e){let r=Ps.basename(t).toLowerCase(),n=Ps.extname(t).toLowerCase();return ue().some(s=>r.includes(s))?"test":En(r)?"config":e.imports.some(s=>Pt().some(i=>s.rawSpecifier.includes(i)))?"test":n===".tsx"||n===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>Dt()?"barrel":"logic"}function Vr(t){return h.canHaveModifiers(t)&&h.getModifiers(t)?.some(e=>e.kind===h.SyntaxKind.ExportKeyword)===!0}function bf(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let n=new Map;for(let o of e.statements){if(!h.isImportDeclaration(o)||!h.isStringLiteral(o.moduleSpecifier))continue;let s=o.moduleSpecifier.text,i=o.importClause;if(i&&(i.name&&n.set(i.name.text,s),i.namedBindings&&h.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)n.set(a.name.text,s)}if(n.size!==0)for(let o of e.statements){let s=Cf(o);if(s){let i=vf(o);i&&yt(i,s,n,r);continue}h.isClassDeclaration(o)&&o.name&&Sf(o,o.name.text,n,r)}}function Sf(t,e,r,n){for(let o of t.members)h.isMethodDeclaration(o)&&o.body&&h.isIdentifier(o.name)?yt(o.body,`${e}.${o.name.text}`,r,n):h.isConstructorDeclaration(o)&&o.body&&yt(o.body,`${e}.constructor`,r,n)}function Cf(t){if(Vr(t)){if(h.isFunctionDeclaration(t)&&t.name)return t.name.text;if(h.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(h.isIdentifier(e.name)&&e.initializer&&(h.isArrowFunction(e.initializer)||h.isFunctionExpression(e.initializer)))return e.name.text}}}function vf(t){if(h.isFunctionDeclaration(t))return t.body;if(h.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(h.isArrowFunction(e.initializer)||h.isFunctionExpression(e.initializer)))return e.initializer}}function yt(t,e,r,n){if(h.isCallExpression(t)&&h.isIdentifier(t.expression)){let o=t.expression.text,s=r.get(o);s&&!n.some(i=>i.from===e&&i.to===o&&i.toSpecifier===s)&&n.push({from:e,to:o,toSpecifier:s})}h.forEachChild(t,o=>yt(o,e,r,n))}var Ms=u(()=>{"use strict";l();re();Fs();$();Ns()});function xt(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(n=>{if(n.type==="rule")return r=!0,!1}),r?"ui":"barrel"}var As=u(()=>{"use strict";l()});function Rs(t,e){let r=[],n=/@require\s+['"]([^'"]+)['"]/g,o=n.exec(t);for(;o!==null;){let i=o[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),o=n.exec(t)}let s=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(o=s.exec(t);o!==null;){let i=o[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),o=s.exec(t)}return r}function Ls(t,e){if(e.length===0)return"ui";try{let r=Nt("stylus");return new r.Parser(t).parse().nodes.some(s=>s.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}var Os=u(()=>{"use strict";l()});function Ee(t,e){let r=z(t);if(r==="stylus"){let s=Rs(e,t);return{imports:s,exports:[],tags:[],category:Ls(e,s)}}if(r==="scss"){let{imports:s,root:i,exports:a,tags:c}=Je(e,t);return{imports:s,exports:a,tags:c,category:xt(i,s)}}if(r==="less"){let{imports:s,root:i,exports:a,tags:c}=Ue(e,t);return{imports:s,exports:a,tags:c,category:xt(i,s)}}let{imports:n,root:o}=Be(e,t);return{imports:n,exports:[],tags:[],category:xt(o,n)}}var Gs=u(()=>{"use strict";l();$();As();Vt();Qt();Os()});async function _s(t,e){let r=z(t),n=Po(r);return n?n(t,e):{imports:[],exports:[],tags:[],category:"other"}}var js=u(()=>{"use strict";l();$();as();cs();us();ds();ys();Cs();Es();Ms();Ce();Gs();re();$();Ce();for(let[t,e]of[["javascript",(r,n)=>Hr(r,n,"javascript")],["typescript",(r,n)=>Hr(r,n,"typescript")],["css",Ee],["scss",Ee],["less",Ee],["stylus",Ee],["coffeescript",is],["livescript",gs],["lua",hs],["python",ws],["go",ms],["gherkin",Wr],["markdown",Ss]])ie(t,e)});import Ws from"path";function $s(t,e){for(let r of t.values()){let n=e.get(r.path);n!==void 0&&(r.coveragePct=n)}}function Bs(t,e){for(let r of t)if(r.isExternal){let n=r.rawSpecifier.startsWith("@")?r.rawSpecifier.split("/").slice(0,2).join("/"):r.rawSpecifier.split("/")[0];n&&!e.some(o=>o.name===n)&&e.push({name:n,kind:"library"})}}function Us(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports){if(r.isExternal||!r.toPath)continue;let n=t.get(r.toPath);n&&(n.category!=="logic"&&n.category!=="barrel"||(n.testedBy??=[],n.testedBy.includes(e.path)||n.testedBy.push(e.path)))}}function Js(t){for(let e of t.values())if(e.type==="markdown")for(let r of e.imports){if(r.isExternal||!r.toPath)continue;let n=t.get(r.toPath);!n||n===e||(n.documentedBy??=[],n.documentedBy.includes(e.path)||n.documentedBy.push(e.path),n.category==="logic"&&(n.lastCommitAt??0)>(e.lastCommitAt??0)&&(e.staleFor??=[],e.staleFor.includes(n.path)||e.staleFor.push(n.path)))}}function zs(t){return Math.round(t*1e4)/1e4}function Ks(t){for(let e of t.values()){let r=[];for(let n of e.imports){if(n.isExternal||!n.toPath)continue;let o=t.get(n.toPath);if(!o||o.exports.length===0)continue;let s;if(n.symbols===void 0){if(n.type==="side-effect")continue;s=1}else n.symbols.includes("*")?s=1:s=n.symbols.length/o.exports.length;n.exportUsageRatio=zs(Math.min(1,s)),r.push(n.exportUsageRatio)}r.length>0&&(e.avgExportUsage=zs(r.reduce((n,o)=>n+o,0)/r.length),e.maxExportUsage=Math.max(...r))}}function Qr(t,e,r){e&&(t.some(n=>n.name===e&&n.kind===r)||t.push({name:e,kind:r}))}function kf(t,e){let r=e.toPath,n=Ws.basename(r,Ws.extname(r)).replace(/\.(test|spec)$/,"");Qr(t.tags,n,"import")}function wf(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)Qr(t.tags,r,"import")}function Ef(t,e,r){let n=r.get(e.toPath);if(!(!n||n.category==="test"))for(let o of n.tags)o.kind==="comment-marker"&&Qr(t.tags,o.name,"comment-marker")}function Hs(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports)!r.toPath||r.isExternal||(kf(e,r),wf(e,r),Ef(e,r,t))}var Vs=u(()=>{"use strict";l()});import Xs from"fs";import pe from"path";function Ff(t,e){let r=t.split(`
29
- `),n=null,o=new Map,s=!1;for(let i of r){let a=i.trim();if(a.startsWith("module ")){n=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){s=!0;continue}if(s&&a===")"){s=!1;continue}if(s&&a.includes("=>")){Qs(a,e,o);continue}!s&&/^replace\s+/.test(a)&&a.includes("=>")&&Qs(a.replace(/^replace\s+/,""),e,o)}return{mod:n,replaces:o}}function Qs(t,e,r){let[n,o]=t.split("=>").map(a=>a.trim());if(!n||!o)return;let s=n.split(/\s+/)[0];if(!o.startsWith(".")&&!o.startsWith("/"))return;let i=pe.isAbsolute(o)?o:pe.resolve(e,o);r.set(s,i)}function Ys(t){let e;try{e=Xs.readdirSync(t,{withFileTypes:!0})}catch{return null}let r=e.filter(n=>n.isFile()&&n.name.endsWith(".go")&&!n.name.endsWith("_test.go")).map(n=>({path:pe.join(t,n.name),isExternal:!1})).sort((n,o)=>n.path.localeCompare(o.path));return r.length>0?r:null}var Fe,qs=u(()=>{"use strict";l();Fe=class{extensions=[".go"];goModCache=new Map;resolve(e,r,n,o){let{mod:s,replaces:i}=this.readGoMod(n);if(!s)return null;let a=this.applyReplace(r,i,n);if(a!==void 0)return Ys(a);if(r!==s&&!r.startsWith(`${s}/`))return null;let c=r.slice(s.length).replace(/^\//,"");return c?Ys(pe.join(n,c)):null}readGoMod(e){let r=this.goModCache.get(e);if(r!==void 0)return r;let n={mod:null,replaces:new Map};try{let o=Xs.readFileSync(pe.join(e,"go.mod"),"utf-8"),s=Ff(o,e);return this.goModCache.set(e,s),s}catch{return this.goModCache.set(e,n),n}}applyReplace(e,r,n){for(let[o,s]of r){if(e===o)return s;if(e.startsWith(`${o}/`)){let i=e.slice(o.length+1);return pe.join(s,i)}}}}});import Tf from"fs";import Yr from"path";var Te,Zs=u(()=>{"use strict";l();Te=class{extensions=[".lua"];resolve(e,r,n,o){let s=r.replace(/\./g,Yr.sep),i=[n,Yr.join(n,"lib")];for(let a of i){if(!Tf.existsSync(a))continue;let c=o(Yr.join(a,"_dummy.lua"),s);if(c)return[c]}return null}}});import Nf from"path";var Ne,ei=u(()=>{"use strict";l();Ne=class{extensions=[".md",".mdx"];resolve(e,r,n,o){let s=o(Nf.join(n,"_dummy"),`./${r}`);return s?[s]:null}}});import Pf from"fs";import Xr from"path";function ti(t){try{return Pf.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Pe,ri=u(()=>{"use strict";l();Pe=class{extensions=[".py"];resolve(e,r,n,o){let s=r.replace(/\./g,Xr.sep),i=Xr.join(n,`${s}.py`);if(ti(i))return[{path:i,isExternal:!1}];let a=Xr.join(n,s,"__init__.py");return ti(a)?[{path:a,isExternal:!1}]:null}}});import ni from"path";var If,Ie,oi=u(()=>{"use strict";l();If=["~","http://","https://","//","data:","sass:"],Ie=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,n,o){if(If.some(m=>r.startsWith(m)))return null;let s=o(e,r);if(s)return[s];let i=ni.dirname(r),a=ni.basename(r),c=i==="."?`_${a}`:`${i}/_${a}`,p=o(e,c);return p?[p]:null}}});var si=u(()=>{"use strict";l();qs();Zs();ei();ri();oi()});import bt from"fs";import U from"path";var Z,qr=u(()=>{"use strict";l();si();Z=class{constructor(e,r={}){this.rootDir=e;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[e],this.pathAliases=r.pathAliases,this.langResolvers=r.langResolvers??[new Pe,new Te,new Fe,new Ie,new Ne]}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolveAll(e,r){let n=this.resolvePathAlias(r);if(n)return[n];if(r.startsWith(".")||r.startsWith("/")){let i=this.resolveLocalPath(e,r);return i?[i]:[]}let o=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,o);if(a)return a}let s=this.resolveWorkspaceImport(r);return s?[s]:[{path:r,isExternal:!0}]}resolve(e,r){let n=this.resolvePathAlias(r);if(n)return n;if(r.startsWith(".")||r.startsWith("/"))return this.resolveLocalPath(e,r);let o=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,o);if(a)return a[0]??null}let s=this.resolveWorkspaceImport(r);return s||{path:r,isExternal:!0}}resolveLocalPath(e,r){let n=U.dirname(e),o=r.startsWith("/")?r:U.resolve(n,r),s=!o.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=o.match(/\.(js|mjs|cjs)$/);if(a){let c=o.slice(0,-a[0].length);for(let p of[".ts",".tsx"]){let m=this.tryExtensions(c,p,s);if(m)return m}}for(let c of i){let p=this.tryExtensions(o,c,s);if(p)return p}return s?{path:o,isExternal:!0}:null}tryExtensions(e,r,n){let o=e+r;if(this.isFile(o))return{path:o,isExternal:n};let s=U.join(e,`index${r}`);if(this.isFile(s))return{path:s,isExternal:n};if(r===".py"){let i=U.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:n}}return null}isFile(e){try{return bt.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let r in this.pathAliases){let n=this.matchAliasPattern(r,e),o=this.pathAliases[r];if(n&&o){let s=this.tryAliasSubstitutions(o,n[1]||"");if(s)return s}}for(let r of this.tsconfigSearchPaths){let n=U.join(r,"tsconfig.json");if(bt.existsSync(n))try{let s=JSON.parse(bt.readFileSync(n,"utf-8")).compilerOptions?.paths;if(!s)continue;for(let i in s){let a=this.matchAliasPattern(i,e);if(a){let c=this.tryAliasSubstitutions(s[i],a[1]||"",r);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,r){let n=this.aliasRegexCache.get(e);if(!n){let o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");n=new RegExp(`^${o}$`),this.aliasRegexCache.set(e,n)}return r.match(n)}tryAliasSubstitutions(e,r,n=this.rootDir){let o=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let s of e){let i=s.replace("*",r),a=U.resolve(n,i);for(let c of o){let p=this.tryExtensions(a,c,!1);if(p)return p}}return null}resolveWorkspaceImport(e){if(this.workspaceMap.size===0)return null;for(let[r,n]of this.workspaceMap){if(e!==r&&!e.startsWith(`${r}/`))continue;let o=e.slice(r.length),s={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!o){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=U.join(n,a);try{if(bt.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...s,path:c}}catch{}}return{...s,path:n}}let i=this.resolveLocalPath(U.join(n,"_dummy"),o.slice(1));return i?{...s,path:i.path}:null}return null}}});import De from"fs";import M from"path";import Df from"piscina";function Rf(t,e){if(t.length===0)return e;let r=t.map(i=>M.dirname(i).split(M.sep)),n=r[0]??[];for(let i of r.slice(1)){let a=0;for(;a<n.length&&a<i.length&&n[a]===i[a];)a++;n=n.slice(0,a)}let o=n.join(M.sep)||M.sep,s=M.relative(e,o);return s.startsWith("..")||M.isAbsolute(s)?e:o}var Mf,ii,Af,Me,ai=u(()=>{"use strict";l();_r();re();Kt();js();Vs();he();qr();Mf=["tests","test","__tests__","specs","spec"],ii=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),Af=20;Me=class{constructor(e,r=null,n,o,s=!1,i=new Map,a=!0){this.rootDir=e;this.enableGitStats=s;this.coverageMap=i;this.parallelParsing=a;this.previousGraph=r,this.resolver=n||new Z(e),this.lockFile=Wn(e),o&&(this.progressCallback=o)}rootDir;enableGitStats;coverageMap;parallelParsing;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;async build(e){let r=e.map(n=>M.isAbsolute(n)?n:M.resolve(this.rootDir,n));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=rs(this.rootDir));try{for(let n of r)this.enqueue(n);return await this.drain(),await this.processTestFiles(Rf(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
25
+ ${f}`}}});import Vo from"path";import Qo from"typescript";var Kl,lt,Yo=m(()=>{"use strict";l();ae();Kl=/\/\/ <mokosh-tags>[\s\S]*?\/\/ <\/mokosh-tags>\n*/,lt=class{name="vitest";canHandle(e){return _.has(Vo.extname(e).toLowerCase())}apply(e,r,n){let o=r.replace(Kl,""),s=Qo.createSourceFile(Vo.basename(e),o,Qo.ScriptTarget.Latest,!0),i=yr(s),[a]=i;if(!a)return o;let c=xr(a,"tags",s),p=[...n].sort();if(c!==null&&JSON.stringify([...c].sort())===JSON.stringify(p))return o;let f=i.flatMap(d=>{let y=n.length===0?Sr(d,"tags",s):br(d,"tags",kr(p),s);return y?[y]:[]});return f.length>0?Cr(o,f):o}}});import Nr from"path";import pt from"typescript";function Vl(t){let e=pt.createSourceFile("detect.ts",t,pt.ScriptTarget.Latest,!0);for(let r of e.statements){if(!pt.isImportDeclaration(r)||!pt.isStringLiteral(r.moduleSpecifier))continue;let n=Hl[r.moduleSpecifier.text];if(n)return n}return null}function qo(t="vitest",e={},r=process.cwd()){return[new ot,new ct,new st,new Pr(r,t,Object.entries(e))]}function Zo(t,e){return e.find(r=>r.canHandle(t))??null}var Xo,Hl,Pr,es=m(()=>{"use strict";l();Wo();zo();Bo();Uo();Jo();Ko();Ho();ae();Yo();Xo={vitest:()=>new lt,playwright:()=>new at,cypress:()=>new nt,jest:()=>new it},Hl={"@playwright/test":"playwright",cypress:"cypress","@jest/globals":"jest",vitest:"vitest"};Pr=class{constructor(e,r,n){this.rootDir=e;this.defaultFramework=r;this.frameworkOverrides=n}rootDir;defaultFramework;frameworkOverrides;name="auto";canHandle(e){return _.has(Nr.extname(e).toLowerCase())}apply(e,r,n){let o=Vl(r)??this.matchOverride(e)??this.defaultFramework;return(Xo[o]??Xo.vitest)().apply(e,r,n)}matchOverride(e){let r=Nr.relative(this.rootDir,e).split(Nr.sep).join("/");for(let[n,o]of this.frameworkOverrides)if($o(n,r))return o;return null}}});import ts from"fs/promises";import Ql from"path";async function Zl(t,e,r,n){let o;try{o=await ts.readFile(t,"utf8")}catch(a){return{path:t,status:"error",error:String(a)}}let s=Zo(t,n);if(!s)return{path:t,status:"unchanged"};let i=s.apply(t,o,e);return i===o?{path:t,status:"unchanged"}:(r||await ts.writeFile(t,i,"utf8"),{path:t,status:"updated"})}async function Ir(t,e,r){let n=ne(e),o=n.tagApplier?.framework??"vitest",s=n.tagApplier?.frameworkOverrides??{},i=qo(o,s,e),a={updated:0,unchanged:0,errors:0,files:[]};for(let c of t.nodes.values()){if(c.category!=="test")continue;let p=new Set,f=[];for(let x of c.tags)Xl.has(x.kind)&&Yl.test(x.name)&&(ql.has(x.name.toLowerCase())||p.has(x.name)||(p.add(x.name),f.push(x.name)));f.sort();let d=Ql.resolve(e,c.path),y=await Zl(d,f,r.dryRun,i);y.path=c.path,a.files.push(y),y.status==="updated"?a.updated++:y.status==="unchanged"?a.unchanged++:a.errors++}return a}var Yl,Xl,ql,rs=m(()=>{"use strict";l();It();es();Yl=/^[a-zA-Z][a-zA-Z0-9_-]{1,}$/,Xl=new Set(["import"]),ql=new Set(["common","fixture","fixtures","helper","helpers","index","main","mock","mocks","setup","shared","spec","test","tests","types","util","utils"])});var ft,Dr=m(()=>{"use strict";l();ft=class{isTestNode(e){return e.category==="test"||e.tags.some(r=>r.name==="test")}}});import{execFileSync as Mr}from"child_process";function ss(t,e){let r="",n=0;for(let o of t.split(`
26
+ `)){if(o.startsWith("\0")){let[,c,p]=o.slice(1).split(" ");r=c??"",n=p?Number(p)*1e3:0;continue}if(o==="")continue;let s=o.split(" "),i=s[0];if(!i)continue;let a=i.startsWith("R")||i.startsWith("C")?s[2]:s[1];a&&e(a,r,n)}}function is(t){let e=new Map;try{let r=Mr("git",["-C",t,"log","--since=90 days ago","--name-status","-M",`--format=${ns}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:os});ss(r,(n,o,s)=>{let i=e.get(n);if(i){i.commitCount90d+=1;return}e.set(n,{commitCount90d:1,lastAuthor:o||void 0,lastCommitAt:s||void 0})})}catch{return e}try{let r=Mr("git",["-C",t,"log","--name-status","-M",`--format=${ns}`],{encoding:"utf-8",stdio:["ignore","pipe","ignore"],maxBuffer:os});ss(r,(n,o,s)=>{e.has(n)||e.set(n,{commitCount90d:0,lastAuthor:void 0,lastCommitAt:s||void 0})})}catch{}return e}var ut,ns,os,Ar=m(()=>{"use strict";l();ut=class{getChangedFiles(){try{let r=[["diff","--name-only"],["diff","--cached","--name-only"],["ls-files","--others","--exclude-standard"]].flatMap(n=>{try{return Mr("git",n,{encoding:"utf-8",stdio:["ignore","pipe","ignore"]}).split(`
27
+ `).map(s=>s.trim()).filter(s=>s!=="")}catch{return[]}});return Array.from(new Set(r))}catch(e){return console.error("Error getting git diff:",e),[]}}},ns="%x00%H%x09%ae%x09%at",os=256*1024*1024});import as from"path";function W(t){switch(as.extname(t).toLowerCase()){case".js":case".jsx":case".mjs":case".cjs":return"javascript";case".ts":case".tsx":return"typescript";case".css":return"css";case".scss":case".sass":return"scss";case".less":return"less";case".styl":return"stylus";case".coffee":return"coffeescript";case".ls":return"livescript";case".lua":return"lua";case".py":return"python";case".go":return"go";case".java":case".cpp":case".cc":case".cxx":case".c":return"unknown";case".feature":return"gherkin";case".md":case".mdx":return"markdown";default:return"unknown"}}function A(t){let e=as.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}var z=m(()=>{"use strict";l()});function $(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function ce(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=r.exec(t);for(;n!==null;)n[1]&&e.add(n[1]),n=r.exec(t);return e}function le(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}var mt=m(()=>{"use strict";l()});import ep from"coffeescript";function ls(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return $(t.value)}}function Y(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function tp(t,e){let r=ls(e.source);return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:A(r),type:"static"}:null}function rp(t,e){let r=e.variable?.base?.value==="require",n=ls(e.args?.[0]?.base);return!r||!n?null:{fromPath:t,toPath:"",rawSpecifier:n,isStyle:A(n),type:"require"}}function cs(t,e){if(e)return[{name:e}];let r=t.value;if(r?.constructor?.name==="Class"){let o=Y(r.variable);return o?[{name:o}]:[]}if(r?.base?.constructor?.name==="Obj"&&Array.isArray(r.base.properties))return r.base.properties.map(o=>Y(o.variable)??Y(o)).filter(o=>!!o).map(o=>({name:o}));let n=Y(r);return n?[{name:n}]:[]}function np(t){if(Array.isArray(t.specifiers))return t.specifiers.map(r=>r.identifier??r.original?.value).filter(r=>!!r).map(r=>({name:r}));let e=Y(t.variable)??Y(t.variable?.base);return e?[{name:e}]:[]}function op(t,e,r,n){let o=e.constructor?.name;if(o==="ImportDeclaration"){let s=tp(t,e);s&&r.push(s)}else if(o==="Call"){let s=rp(t,e);s&&r.push(s)}else if(o==="Assign"){let s=Y(e.variable?.base),i=e.variable?.properties?.[0]?.name?.value;s==="module"&&i==="exports"?n.push(...cs(e,void 0)):s==="exports"&&typeof i=="string"&&n.push(...cs(e,i))}else o==="ExportNamedDeclaration"&&e.clause?n.push(...np(e.clause)):o==="ExportDefaultDeclaration"&&n.push({name:"default"})}function Lr(t,e,r,n){if(!(!e||typeof e!="object")){op(t,e,r,n);for(let o in e){if(o==="locationData")continue;let s=e[o];if(!(!s||typeof s!="object"))if(Array.isArray(s))for(let i of s)Lr(t,i,r,n);else Lr(t,s,r,n)}}}function ps(t,e){let r=ce(e),n=le(t,r),o=[],s=[];try{Lr(t,ep.nodes(e),o,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var fs=m(()=>{"use strict";l();z();mt()});import{AstBuilder as sp,GherkinClassicTokenMatcher as ip,Parser as ap}from"@cucumber/gherkin";import{IdGenerator as cp}from"@cucumber/messages";function Rr(t,e){let r=new Set;try{let n=new sp(lp),o=new ip,i=new ap(n,o).parse(e);i.feature&&(i.feature.tags.forEach(a=>{r.add(a.name.startsWith("@")?a.name.slice(1):a.name)}),i.feature.children.forEach(a=>{a.scenario&&(a.scenario.tags.forEach(c=>{r.add(c.name.startsWith("@")?c.name.slice(1):c.name)}),a.scenario.examples.forEach(c=>{c.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})),a.rule&&a.rule.children.forEach(c=>{c.scenario&&c.scenario.tags.forEach(p=>{r.add(p.name.startsWith("@")?p.name.slice(1):p.name)})})}))}catch(n){console.warn(`[GherkinParser] Failed to parse ${t}:`,n)}return{imports:[],exports:[],tags:Array.from(r).map(n=>({name:n,kind:"comment-marker"})),category:"test"}}var lp,us=m(()=>{"use strict";l();Ce();lp=cp.uuid();ie("gherkin",Rr)});function X(t){let e=[],r=t.firstChild;for(;r;)e.push(r),r=r.nextSibling;return e}function ve(t,e){let r=1;for(let n=0;n<e&&n<t.length;n++)t[n]===`
28
+ `&&r++;return r}var Or=m(()=>{"use strict";l()});function pp(t,e){let r=1;function n(o){switch(o.type.name){case"IfStatement":case"ForStatement":r++;break;case"Case":{o.firstChild?.type.name==="case"&&r++;break}case"LogicOp":{let i=e.slice(o.from,o.to);(i==="&&"||i==="||")&&r++;break}}let s=o.firstChild;for(;s;)n(s),s=s.nextSibling}return n(t),r}function fp(t,e){let r=0;function n(o,s,i){let a=o.type.name;if(a==="IfStatement"){r+=i?1:1+s;let f=X(o),d=i?s:s+1,y=f[1];y&&y.type.name!=="Block"&&n(y,d,!1);let x=f.find(C=>C.type.name==="Block");x&&n(x,d,!1);let v=f.findIndex(C=>C.type.name==="else");if(v>=0){let C=f[v+1];C?.type.name==="IfStatement"?n(C,s,!0):C&&(r+=1,n(C,s+1,!1))}return}if(a==="ForStatement"||a==="SwitchStatement"||a==="SelectStatement"){r+=1+s;let f=o.firstChild;for(;f;)n(f,s+1,!1),f=f.nextSibling;return}if(a==="LogicOp"){let f=e.slice(o.from,o.to);(f==="&&"||f==="||")&&(r+=1)}if(s>0&&a==="FunctionLiteral"){r+=1+s;let f=o.firstChild;for(;f;)n(f,s+1,!1),f=f.nextSibling;return}let p=o.firstChild;for(;p;)n(p,s,!1),p=p.nextSibling}return n(t,0,!1),r}function gt(t,e){return{complexity:pp(t,e),cognitiveComplexity:fp(t,e)}}function Gr(t,e){let n=t.getChild("Parameters")?.getChild("Parameter"),o=n?.getChild("TypeName")??n?.getChild("PointerType")?.getChild("TypeName");return o?e.slice(o.from,o.to):void 0}function ms(t,e){let r=[],n=t.cursor();do if(n.name==="FunctionDecl"){let o=n.node.getChild("DefName");if(o){let s=e.slice(o.from,o.to),{complexity:i,cognitiveComplexity:a}=gt(n.node,e);r.push({name:s,line:ve(e,n.from),complexity:i,cognitiveComplexity:a})}}else if(n.name==="MethodDecl"){let o=n.node.getChild("FieldName");if(o){let s=e.slice(o.from,o.to),i=Gr(n.node,e),a=i?`${i}.${s}`:s,{complexity:c,cognitiveComplexity:p}=gt(n.node,e);r.push({name:a,line:ve(e,n.from),complexity:c,cognitiveComplexity:p})}}while(n.next());return r}var gs=m(()=>{"use strict";l();Or()});import up from"path";import{parser as mp}from"@lezer/go";function hs(t,e){let r=[],n=new Map,o=new Set,s=new Set,i=new Map,a=mp.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let b=e.slice(c.from,c.to),w=b.match(gp);w?.[1]&&o.add(w[1]);let G=b.match(dp);G&&ds(G[1],s);let O=b.match(hp);O&&ds(O[1],s);break}case"ImportSpec":{let b=c.node.getChild("String");if(b){let G=e.slice(b.from,b.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:G,isExternal:!0,isStyle:!1,type:"static"});let O=c.node.getChild("DefName"),U=O?e.slice(O.from,O.to):G.split("/").pop();U&&U!=="_"&&U!=="."&&i.set(U,G)}break}case"FunctionDecl":case"MethodDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let b=c.node.getChild("DefName")??c.node.getChild("FieldName")??c.node.getChild("TypeSpec")?.getChild("DefName")??c.node.getChild("VarSpec")?.getChild("DefName")??c.node.getChild("ConstSpec")?.getChild("DefName");if(b){let w=e.slice(b.from,b.to);w!=="_"&&/^[A-Z]/.test(w)&&!n.has(w)&&n.set(w,{name:w})}break}}while(c.next());let p=r.some(b=>b.rawSpecifier==="testing"),f=up.basename(t).endsWith("_test.go")||o.has("test")||p?"test":"logic",d=new Set([...o,...s]),{complexity:y,cognitiveComplexity:x}=gt(a.topNode,e),v=ms(a,e),C=f==="test"?[]:yp(a,e,i);return{imports:r,exports:Array.from(n.values()),tags:Array.from(d).map(b=>({name:b,kind:"comment-marker"})),category:f,rawCallEdges:C,complexity:y,cognitiveComplexity:x,...v.length>0?{functions:v}:{}}}function yp(t,e,r){let n=[];function o(i,a){if(i.type.name==="CallExpr"){let p=i.firstChild;if(p?.type.name==="SelectorExpr"){let f=p.firstChild,d=p.getChild("FieldName");if(f?.type.name==="VariableName"&&d){let y=e.slice(f.from,f.to),x=r.get(y);if(x){let v=e.slice(d.from,d.to);n.push({from:a,to:v,toSpecifier:x})}}}}let c=i.firstChild;for(;c;)o(c,a),c=c.nextSibling}let s=t.cursor();do if(s.name==="FunctionDecl"){let i=s.node.getChild("DefName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to);/^[A-Z]/.test(c)&&o(a,c)}}else if(s.name==="MethodDecl"){let i=s.node.getChild("FieldName"),a=s.node.getChild("Block");if(i&&a){let c=e.slice(i.from,i.to),p=Gr(s.node,e);o(a,p?`${p}.${c}`:c)}}while(s.next());return n}function ds(t,e){for(let r of t.split(/[\s,&|!()]+/)){let n=r.trim();n&&n!=="ignore"&&e.add(n)}}var gp,dp,hp,ys=m(()=>{"use strict";l();gs();gp=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,dp=/^\/\/go:build\s+(.+)$/,hp=/^\/\/\s*\+build\s+(.+)$/});import xp from"livescript";function q(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function bp(t){if(!t)return[];if(t.constructor?.name==="Class"){let r=q(t.title);return r?[{name:r}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(r=>q(r.key)??q(r.val)).filter(r=>!!r).map(r=>({name:r}));let e=q(t);return e?[{name:e}]:[]}function Sp(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let r=t.left,n=q(r.head),s=r.tails?.[0]?.key?.name;if(n==="module"&&s==="exports")return bp(t.right);if(n==="exports"&&typeof s=="string")return[{name:s}];if(r.head?.verb==="out"&&typeof s=="string")return[{name:s}]}if(e==="Import"&&t.left?.verb==="out"){let r=t.right;if(r?.constructor?.name==="Obj"&&Array.isArray(r.items))return r.items.map(n=>q(n.val)??q(n.key)).filter(n=>!!n).map(n=>({name:n}))}return[]}function kp(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let n=t.right?.value;if(typeof n=="string"){let o=$(n);return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:A(o),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let n=t.tails?.[0];if(n?.constructor?.name==="Call"||n?.type==="Call"){let o=n.args?.[0]?.value;if(typeof o=="string"){let s=$(o);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:A(s),type:"require"}}}}return null}function _r(t,e,r){if(!t||typeof t!="object")return[];let n=[],o=kp(t,e);o&&n.push(o),r.push(...Sp(t));for(let s in t){if(Cp.has(s))continue;let i=t[s];if(!(!i||typeof i!="object"))if(Array.isArray(i))for(let a of i)n.push(..._r(a,e,r));else n.push(..._r(i,e,r))}return n}function xs(t,e){let r=ce(e),n=le(t,r),o=[],s=[];try{o=_r(xp.ast(e),t,s)}catch{}let i=new Set,a=s.filter(c=>i.has(c.name)?!1:(i.add(c.name),!0));return{imports:o,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:n}}var Cp,bs=m(()=>{"use strict";l();z();mt();Cp=new Set(["first_line","first_column","last_line","last_column","line","column"])});import vp from"luaparse";function wp(t,e){let r=[];function n(o){if(!(!o||typeof o!="object")){if((o.type==="CallExpression"||o.type==="StringCallExpression")&&o.base?.type==="Identifier"&&o.base?.name==="require"){let s;if(o.type==="CallExpression"){let i=o.arguments?.[0];i?.type==="StringLiteral"&&(s=$(i.raw))}else if(o.type==="StringCallExpression"){let i=o.argument;i?.type==="StringLiteral"&&(s=$(i.raw))}s&&r.push({fromPath:e,toPath:"",rawSpecifier:s,isStyle:A(s),type:"require"})}for(let s in o){if(s==="loc")continue;let i=o[s];if(i&&typeof i=="object")if(Array.isArray(i))for(let a of i)n(a);else n(i)}}}return n(t),r}function Ep(t){let e=new Set;for(let r of t)r.type==="LocalStatement"&&r.variables.forEach((n,o)=>{r.init[o]?.type==="TableConstructorExpression"&&e.add(n.name)});return e}function Tp(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let r=e.arguments[0];if(r?.type!=="TableConstructorExpression")return[];let n=[];for(let o of r.fields)o.type==="TableKeyString"&&n.push({name:o.key.name});return n}function Fp(t){let e=t.body,r=Ep(e),n=Tp(e);for(let s of e)if(s.type==="FunctionDeclaration")s.identifier?.type==="MemberExpression"?s.identifier.base.type==="Identifier"&&r.has(s.identifier.base.name)&&n.push({name:s.identifier.identifier.name}):s.identifier?.type==="Identifier"&&!s.isLocal&&n.push({name:s.identifier.name});else if(s.type==="AssignmentStatement")for(let i of s.variables)i.type==="MemberExpression"&&i.base.type==="Identifier"&&r.has(i.base.name)&&n.push({name:i.identifier.name});let o=new Set;return n.filter(s=>o.has(s.name)?!1:(o.add(s.name),!0))}function Ss(t,e){let r=ce(e),n=le(t,r),o=[],s=[];try{let i=vp.parse(e);o=wp(i,t),s=Fp(i)}catch{}return{imports:o,exports:s,tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:n}}var Cs=m(()=>{"use strict";l();z();mt()});async function Dp(){return ks??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),ks}function Mp(t){let e=t.trim();return e.length===0||e.startsWith("#")||Np.some(r=>e.startsWith(r))}function Ap(t,e){let r=t.match(Ip);return r?r.map(n=>({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!1,type:"static"})):[]}function vs(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!Mp(t.url)&&r.push({fromPath:e,toPath:"",rawSpecifier:t.url,isStyle:!1,type:"static"}),(t.type==="code"||t.type==="inlineCode")&&typeof t.value=="string"&&r.push(...Ap(t.value,e)),Array.isArray(t.children))for(let n of t.children)vs(n,e,r)}async function ws(t,e){let n=(await Dp()).parse(e),o=[];vs(n,t,o);let s=new Set;return{imports:o.filter(a=>s.has(a.rawSpecifier)?!1:(s.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}var Np,Pp,Ip,ks,Es=m(()=>{"use strict";l();Np=["http://","https://","mailto:","//"],Pp="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",Ip=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${Pp})\\b`,"g")});function Lp(t){let e=1;function r(n){switch(n.type.name){case"IfStatement":{e+=X(n).filter(s=>s.type.name==="if"||s.type.name==="elif").length;break}case"TryStatement":{e+=X(n).filter(s=>s.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let o=n.firstChild;for(;o;)r(o),o=o.nextSibling}return r(t),e}function Rp(t){let e=0;function r(n,o){let s=n.type.name;if(s==="IfStatement"){let c=X(n),p=0,f=0;for(;f<c.length;){let d=c[f];if(d?.type.name==="if"||d?.type.name==="elif"){let y=p>0;e+=y?1:1+o;let x=y?o:o+1,v=c[f+1],C=c[f+2];v&&r(v,x),C&&r(C,x),p++,f+=3}else if(d?.type.name==="else"){e+=1;let y=c[f+1];y&&r(y,o+1),f+=2}else f++}return}if(s==="TryStatement"){let c=X(n),p=0;for(;p<c.length;){let f=c[p];if(f?.type.name==="except"){for(e+=1+o,p++;p<c.length&&c[p]?.type.name!=="Body";)r(c[p],o),p++;p<c.length&&(r(c[p],o),p++)}else f?.type.name==="Body"&&r(f,o),p++}return}if(s==="ForStatement"||s==="WhileStatement"){e+=1+o;let c=n.firstChild;for(;c;)r(c,o+1),c=c.nextSibling;return}if((s==="ConditionalExpression"||s==="and"||s==="or")&&(e+=1),o>0&&(s==="FunctionDefinition"||s==="LambdaExpression")){e+=1+o;let c=n.firstChild;for(;c;)r(c,o+1),c=c.nextSibling;return}let a=n.firstChild;for(;a;)r(a,o),a=a.nextSibling}return r(t,0),e}function jr(t){return{complexity:Lp(t),cognitiveComplexity:Rp(t)}}function Ts(t,e){let r=[];function n(i,a){let{complexity:c,cognitiveComplexity:p}=jr(i);r.push({name:a,line:ve(e,i.from),complexity:c,cognitiveComplexity:p})}function o(i){let a=i.firstChild;for(;a;)s(a),a=a.nextSibling}function s(i){if(i.type.name==="ClassDefinition"){let a=i.getChild("VariableName"),c=a?e.slice(a.from,a.to):void 0,p=i.getChild("Body");if(p){let f=p.firstChild;for(;f;){if(f.type.name==="FunctionDefinition"){let d=f.getChild("VariableName"),y=d?e.slice(d.from,d.to):void 0;y&&n(f,c?`${c}.${y}`:y),o(f)}else s(f);f=f.nextSibling}}return}if(i.type.name==="FunctionDefinition"){let a=i.getChild("VariableName");a&&n(i,e.slice(a.from,a.to)),o(i);return}o(i)}return s(t.topNode),r}var Fs=m(()=>{"use strict";l();Or()});import Op from"path";import{parser as Gp}from"@lezer/python";function Ns(t,e){let r=[],n=[],o=new Set,s=Op.basename(t).toLowerCase(),i=Gp.parse(e),a=i.cursor();do switch(a.name){case"Comment":{let x=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);x?.[1]&&o.add(x[1]);break}case"ImportStatement":{for(let x of jp(a.node,e,t))r.push(x);break}case"FunctionDefinition":case"ClassDefinition":{let x=a.node.parent;if(x?.name==="Script"||x?.name==="DecoratedStatement"&&x.parent?.name==="Script"){let C=a.node.getChild("VariableName");C&&n.push({name:e.slice(C.from,C.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let x=a.node.firstChild;x?.name==="VariableName"&&n.push({name:e.slice(x.from,x.to)})}break}}while(a.next());let c=Jp(s,r,o);c==="test"&&o.add("test");let{complexity:p,cognitiveComplexity:f}=jr(i.topNode),d=Ts(i,e),y=c==="test"?[]:Up(i,e);return{imports:r,exports:n,tags:Array.from(o).map(x=>({name:x,kind:"comment-marker"})),category:c,rawCallEdges:y,complexity:p,cognitiveComplexity:f,...d.length>0?{functions:d}:{}}}function jp(t,e,r){let n=t.firstChild;return n?n.name==="from"?Wp(t,e,r):zp(t,e,r):[]}function Wp(t,e,r){let n=t.firstChild;if(!n)return[];let o=n.nextSibling;for(;o&&o.name!=="import";)o=o.nextSibling;if(!o)return[];let s=e.slice(n.to,o.from).trim(),i=$p(o.nextSibling,e);if(!i.length)return[];let a=0;for(;a<s.length&&s[a]===".";)a++;let c=s.slice(a);if(a===0)return[we(r,s,i,!0)];let p=a===1?"./":"../".repeat(a-1);return c?[we(r,p+c.replace(/\./g,"/"),i,!1)]:i[0]==="*"?[we(r,p.slice(0,-1),["*"],!1)]:i.map(f=>we(r,p+f,[f],!1))}function zp(t,e,r){let n=[],o=t.firstChild?.nextSibling??null;for(;o;){if(o.name==="VariableName"){let s=e.slice(o.from,o.to);for(;o.nextSibling?.name==="."&&o.nextSibling.nextSibling?.name==="VariableName";)o=o.nextSibling.nextSibling,s+=`.${e.slice(o.from,o.to)}`;o.nextSibling?.name==="as"&&(o=o.nextSibling.nextSibling??o.nextSibling),n.push(we(r,s,["*"],!0))}o=o.nextSibling}return n}function $p(t,e){let r=[],n=t;for(;n;)n.name==="*"?r.push("*"):n.name==="VariableName"&&(r.push(e.slice(n.from,n.to)),n.nextSibling?.name==="as"&&(n=n.nextSibling.nextSibling??n.nextSibling)),n=n.nextSibling;return r}function Bp(t,e){let r=new Map,n=t.cursor();do{if(n.name!=="ImportStatement")continue;let s=n.node.firstChild;if(s?.type.name!=="from")continue;let i=s.nextSibling;for(;i&&i.type.name!=="import";)i=i.nextSibling;if(!i)continue;let a=e.slice(s.to,i.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let p=a.slice(c),f=c<=1?"./":"../".repeat(c-1),d=i.nextSibling;for(;d;){if(d.type.name==="VariableName"){let y=e.slice(d.from,d.to),x=y;if(d.nextSibling?.type.name==="as"){let C=d.nextSibling.nextSibling;C?.type.name==="VariableName"&&(x=e.slice(C.from,C.to),d=C)}let v=c===0?a:p?f+p.replace(/\./g,"/"):f+y;r.set(x,v)}d=d.nextSibling}}while(n.next());return r}function Up(t,e){let r=Bp(t,e),n=[];function o(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let f=a.firstChild,d=e.slice(f.from,f.to),y=r.get(d);y&&n.push({from:c,to:d,toSpecifier:y})}let p=a.firstChild;for(;p;)o(p,c),p=p.nextSibling}function s(a){let c=a.firstChild;for(;c;)i(c),c=c.nextSibling}function i(a){if(a.type.name==="ClassDefinition"){let c=a.getChild("VariableName"),p=c?e.slice(c.from,c.to):void 0,f=a.getChild("Body");if(f){let d=f.firstChild;for(;d;){if(d.type.name==="FunctionDefinition"){let y=d.getChild("VariableName"),x=y?e.slice(y.from,y.to):void 0;x&&o(d,p?`${p}.${x}`:x)}else i(d);d=d.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&o(a,e.slice(c.from,c.to));return}s(a)}return i(t.topNode),n}function we(t,e,r,n){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:n,type:"static",symbols:r.length>0?r:void 0}}function Jp(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(n=>_p.has(n.rawSpecifier))?"test":"logic"}var _p,Ps=m(()=>{"use strict";l();Fs();_p=new Set(["pytest","unittest","nose","hypothesis"])});import S from"typescript";function Kp(t){let e=1;function r(n){switch(n.kind){case S.SyntaxKind.IfStatement:case S.SyntaxKind.ConditionalExpression:case S.SyntaxKind.ForStatement:case S.SyntaxKind.ForInStatement:case S.SyntaxKind.ForOfStatement:case S.SyntaxKind.WhileStatement:case S.SyntaxKind.DoStatement:case S.SyntaxKind.CatchClause:case S.SyntaxKind.CaseClause:e++;break;case S.SyntaxKind.BinaryExpression:{let o=n.operatorToken.kind;(o===S.SyntaxKind.AmpersandAmpersandToken||o===S.SyntaxKind.BarBarToken||o===S.SyntaxKind.QuestionQuestionToken)&&e++;break}}S.forEachChild(n,r)}return r(t),e}function Hp(t){let e=0;function r(n,o,s){if(S.isIfStatement(n)){e+=s?1:1+o;let a=s?o:o+1;r(n.expression,a,!1),r(n.thenStatement,a,!1),n.elseStatement&&(S.isIfStatement(n.elseStatement)?r(n.elseStatement,o,!0):(e+=1,r(n.elseStatement,o+1,!1)));return}if(S.isForStatement(n)||S.isForInStatement(n)||S.isForOfStatement(n)||S.isWhileStatement(n)||S.isDoStatement(n)||S.isSwitchStatement(n)){e+=1+o,S.forEachChild(n,a=>r(a,o+1,!1));return}if(S.isCatchClause(n)){e+=1+o,S.forEachChild(n,a=>r(a,o,!1));return}if(S.isConditionalExpression(n)&&(e+=1),S.isBinaryExpression(n)){let a=n.operatorToken.kind;(a===S.SyntaxKind.AmpersandAmpersandToken||a===S.SyntaxKind.BarBarToken||a===S.SyntaxKind.QuestionQuestionToken)&&(e+=1)}if(o>0&&(S.isFunctionDeclaration(n)||S.isFunctionExpression(n)||S.isArrowFunction(n))){e+=1+o,S.forEachChild(n,a=>r(a,o+1,!1));return}S.forEachChild(n,a=>r(a,o,!1))}return r(t,0,!1),e}function Wr(t){return{complexity:Kp(t),cognitiveComplexity:Hp(t)}}var Is=m(()=>{"use strict";l()});import T from"typescript";function Ds(t,e){Vp(t,e),Yp(t,e),Xp(t,e),qp(t,e)}function Vp(t,e){if((T.isFunctionDeclaration(t)||T.isVariableDeclaration(t))&&t.name&&T.isIdentifier(t.name)&&Qp(t)){let r;if(T.isFunctionDeclaration(t))r="function";else{let n=t.initializer;r=n&&(T.isArrowFunction(n)||T.isFunctionExpression(n))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function Qp(t){if(T.isFunctionDeclaration(t))return T.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&T.isSourceFile(e.parent)}function Yp(t,e){if(!T.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let n of r)e.tags.add({name:n.substring(1),kind:"comment-marker"})}function Xp(t,e){if(!T.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,n=t.getFullText(),o=r.exec(n);for(;o!==null;)o[1]&&e.tags.add({name:o[1],kind:"comment-marker"}),o=r.exec(n)}function qp(t,e){if(T.isCallExpression(t)&&Zp(t.expression))for(let r of t.arguments)T.isObjectLiteralExpression(r)&&ef(r,e)}function Zp(t){return T.isIdentifier(t)?zr.has(t.text):!!(T.isPropertyAccessExpression(t)&&(zr.has(t.name.text)||T.isIdentifier(t.expression)&&zr.has(t.expression.text)))}function ef(t,e){for(let r of t.properties){if(!T.isPropertyAssignment(r)||!T.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:n}=r,o=T.isArrayLiteralExpression(n)?n.elements.filter(T.isStringLiteral):r.name.text==="tag"&&T.isStringLiteral(n)?[n]:[];for(let s of o)e.tags.add({name:s.text.replace(/^@/,""),kind:"comment-marker"})}}var zr,Ms=m(()=>{"use strict";l();zr=new Set(["test","describe","it"])});import As from"path";import h from"typescript";function $r(t,e,r){let n=[],o=new Map,s=new Set,i=h.createSourceFile(t,e,h.ScriptTarget.Latest,!0,r==="typescript"?h.ScriptKind.TSX:h.ScriptKind.JSX),a={filePath:t,imports:n,exports:o,tags:s,rawCallEdges:[],sourceFile:i,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=C=>{of(C,a),h.forEachChild(C,c)};c(i);let p=hf(t,a);(p==="test"||p==="barrel")&&s.add({name:p,kind:"comment-marker"}),p!=="test"&&yf(a,i);let f=i.statements[0],d=f?Rs(f):void 0,{complexity:y,cognitiveComplexity:x}=Wr(i),v=tf(i);return{imports:n,exports:Array.from(o.values()),tags:Array.from(s),category:p,rawCallEdges:a.rawCallEdges??[],complexity:y,cognitiveComplexity:x,...v.length>0?{functions:v}:{},...d!==void 0?{description:d}:{}}}function tf(t){let e=[],r=(o,s)=>{let{complexity:i,cognitiveComplexity:a}=Wr(s),c=t.getLineAndCharacterOfPosition(s.getStart(t)).line+1;e.push({name:o,line:c,complexity:i,cognitiveComplexity:a})},n=(o,s)=>{if(h.isFunctionDeclaration(o)&&o.name&&o.body?r(o.name.text,o):h.isVariableDeclaration(o)&&h.isIdentifier(o.name)&&o.initializer&&(h.isArrowFunction(o.initializer)||h.isFunctionExpression(o.initializer))?r(o.name.text,o.initializer):s&&h.isMethodDeclaration(o)&&h.isIdentifier(o.name)&&o.body?r(`${s}.${o.name.text}`,o):s&&h.isConstructorDeclaration(o)&&o.body?r(`${s}.constructor`,o):s&&h.isGetAccessorDeclaration(o)&&h.isIdentifier(o.name)&&o.body?r(`${s}.get ${o.name.text}`,o):s&&h.isSetAccessorDeclaration(o)&&h.isIdentifier(o.name)&&o.body&&r(`${s}.set ${o.name.text}`,o),h.isClassDeclaration(o)&&o.name){let i=o.name.text;h.forEachChild(o,a=>n(a,i));return}h.forEachChild(o,i=>n(i,s))};return n(t,void 0),e}function Ls(t,e,r,n){let o={name:t},s=Rs(r);s!==void 0&&(o.doc=s);let i=rf(e);i!==void 0&&(o.flags=i);let a=nf(e,n);return a!==void 0&&(o.signature=a),o}function Rs(t){let e=h.getJSDocCommentsAndTags(t);for(let r of e)if(h.isJSDoc(r)&&r.comment)return h.getTextOfJSDocComment(r.comment)||void 0}function rf(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=h.getJSDocTags(t).map(n=>n.tagName.text).filter(n=>e.has(n));return r.length>0?r:void 0}function nf(t,e){let r=h.createPrinter({removeComments:!0}),n=o=>r.printNode(h.EmitHint.Unspecified,o,e);if(h.isFunctionDeclaration(t)||h.isMethodDeclaration(t)){let o=t.parameters.map(n).join(", "),s=t.type?n(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${o}) => ${s}`}if(h.isVariableDeclaration(t)){if(t.type)return n(t.type);if(t.initializer&&(h.isArrowFunction(t.initializer)||h.isFunctionExpression(t.initializer))){let o=t.initializer,s=o.parameters.map(n).join(", "),i=o.type?n(o.type):"unknown";return`(${s}) => ${i}`}return}if(h.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(h.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(h.isTypeAliasDeclaration(t))return n(t.type);if(h.isEnumDeclaration(t))return`enum ${t.name.text}`}function of(t,e){sf(t,e),af(t,e),lf(t,e),pf(t,e),df(t,e),Ds(t,e)}function sf(t,e){if(!h.isSourceFile(t))return;let r=t.statements.filter(n=>!h.isEmptyStatement(n));e.totalStatements=r.length,e.exportStatements=r.filter(n=>h.isExportDeclaration(n)||h.isExportAssignment(n)||Br(n)).length}function af(t,e){if(h.isJsxElement(t)||h.isJsxSelfClosingElement(t)||h.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(h.isFunctionDeclaration(t)||h.isMethodDeclaration(t)||h.isArrowFunction(t)||h.isClassDeclaration(t)||h.isVariableStatement(t)||h.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}h.isExportDeclaration(t)&&!cf(t)&&(e.hasTypesOnly=!1)}function cf(t){return t.isTypeOnly?!0:!t.exportClause||!h.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function lf(t,e){if(!h.isImportDeclaration(t)||!t.moduleSpecifier||!h.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(h.isNamedImports(t.importClause.namedBindings))for(let o of t.importClause.namedBindings.elements)r.push(o.name.text);else h.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let n=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:A(t.moduleSpecifier.text),type:n,symbols:r.length>0?r:void 0})}function pf(t,e){h.isExportDeclaration(t)?ff(t,e):h.isExportAssignment(t)?e.exports.set("default",{name:"default"}):Br(t)&&gf(t,e)}function ff(t,e){if(t.moduleSpecifier&&h.isStringLiteral(t.moduleSpecifier))uf(t,t.moduleSpecifier.text,e);else if(t.exportClause&&h.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let n=r.name.text;e.exports.set(n,{name:n})}}function uf(t,e,r){let n=mf(t),o={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:A(e),type:"re-export"};n.length>0&&(o.symbols=n),r.imports.push(o)}function mf(t){return t.exportClause?h.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function gf(t,e){if((h.isFunctionDeclaration(t)||h.isClassDeclaration(t)||h.isInterfaceDeclaration(t)||h.isTypeAliasDeclaration(t)||h.isEnumDeclaration(t))&&t.name){let n=t.name.text;e.exports.set(n,Ls(n,t,t,e.sourceFile));return}if(h.isVariableStatement(t)){for(let n of t.declarationList.declarations)if(h.isIdentifier(n.name)){let o=n.name.text;e.exports.set(o,Ls(o,n,t,e.sourceFile))}}}function df(t,e){if(!h.isCallExpression(t))return;let r=t.arguments[0];!r||!h.isStringLiteral(r)||(t.expression.kind===h.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:A(r.text),type:"dynamic"}):h.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:A(r.text),type:"require"}))}function hf(t,e){let r=As.basename(t).toLowerCase(),n=As.extname(t).toLowerCase();return ue().some(s=>r.includes(s))?"test":Cn(r)?"config":e.imports.some(s=>Et().some(i=>s.rawSpecifier.includes(i)))?"test":n===".tsx"||n===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>Ft()?"barrel":"logic"}function Br(t){return h.canHaveModifiers(t)&&h.getModifiers(t)?.some(e=>e.kind===h.SyntaxKind.ExportKeyword)===!0}function yf(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let n=new Map;for(let o of e.statements){if(!h.isImportDeclaration(o)||!h.isStringLiteral(o.moduleSpecifier))continue;let s=o.moduleSpecifier.text,i=o.importClause;if(i&&(i.name&&n.set(i.name.text,s),i.namedBindings&&h.isNamedImports(i.namedBindings)))for(let a of i.namedBindings.elements)n.set(a.name.text,s)}if(n.size!==0)for(let o of e.statements){let s=bf(o);if(s){let i=Sf(o);i&&dt(i,s,n,r);continue}h.isClassDeclaration(o)&&o.name&&xf(o,o.name.text,n,r)}}function xf(t,e,r,n){for(let o of t.members)h.isMethodDeclaration(o)&&o.body&&h.isIdentifier(o.name)?dt(o.body,`${e}.${o.name.text}`,r,n):h.isConstructorDeclaration(o)&&o.body&&dt(o.body,`${e}.constructor`,r,n)}function bf(t){if(Br(t)){if(h.isFunctionDeclaration(t)&&t.name)return t.name.text;if(h.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(h.isIdentifier(e.name)&&e.initializer&&(h.isArrowFunction(e.initializer)||h.isFunctionExpression(e.initializer)))return e.name.text}}}function Sf(t){if(h.isFunctionDeclaration(t))return t.body;if(h.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(h.isArrowFunction(e.initializer)||h.isFunctionExpression(e.initializer)))return e.initializer}}function dt(t,e,r,n){if(h.isCallExpression(t)&&h.isIdentifier(t.expression)){let o=t.expression.text,s=r.get(o);s&&!n.some(i=>i.from===e&&i.to===o&&i.toSpecifier===s)&&n.push({from:e,to:o,toSpecifier:s})}h.forEachChild(t,o=>dt(o,e,r,n))}var Os=m(()=>{"use strict";l();re();Is();z();Ms()});function ht(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(n=>{if(n.type==="rule")return r=!0,!1}),r?"ui":"barrel"}var Gs=m(()=>{"use strict";l()});function _s(t,e){let r=[],n=/@require\s+['"]([^'"]+)['"]/g,o=n.exec(t);for(;o!==null;){let i=o[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"require"}),o=n.exec(t)}let s=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(o=s.exec(t);o!==null;){let i=o[1];i&&r.push({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static"}),o=s.exec(t)}return r}function js(t,e){if(e.length===0)return"ui";try{let r=wt("stylus");return new r.Parser(t).parse().nodes.some(s=>s.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}var Ws=m(()=>{"use strict";l()});function Ee(t,e){let r=W(t);if(r==="stylus"){let s=_s(e,t);return{imports:s,exports:[],tags:[],category:js(e,s)}}if(r==="scss"){let{imports:s,root:i,exports:a,tags:c}=Ue(e,t);return{imports:s,exports:a,tags:c,category:ht(i,s)}}if(r==="less"){let{imports:s,root:i,exports:a,tags:c}=Be(e,t);return{imports:s,exports:a,tags:c,category:ht(i,s)}}let{imports:n,root:o}=$e(e,t);return{imports:n,exports:[],tags:[],category:ht(o,n)}}var zs=m(()=>{"use strict";l();z();Gs();Bt();Ut();Ws()});async function $s(t,e){let r=W(t),n=Ao(r);return n?n(t,e):{imports:[],exports:[],tags:[],category:"other"}}var Bs=m(()=>{"use strict";l();z();fs();us();ys();bs();Cs();Es();Ps();Os();Ce();zs();re();z();Ce();for(let[t,e]of[["javascript",(r,n)=>$r(r,n,"javascript")],["typescript",(r,n)=>$r(r,n,"typescript")],["css",Ee],["scss",Ee],["less",Ee],["stylus",Ee],["coffeescript",ps],["livescript",xs],["lua",Ss],["python",Ns],["go",hs],["gherkin",Rr],["markdown",ws]])ie(t,e)});import Us from"path";function Ks(t,e){for(let r of t.values()){let n=e.get(r.path);n!==void 0&&(r.coveragePct=n)}}function Hs(t,e){for(let r of t)if(r.isExternal){let n=r.rawSpecifier.startsWith("@")?r.rawSpecifier.split("/").slice(0,2).join("/"):r.rawSpecifier.split("/")[0];n&&!e.some(o=>o.name===n)&&e.push({name:n,kind:"library"})}}function Vs(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports){if(r.isExternal||!r.toPath)continue;let n=t.get(r.toPath);n&&(n.category!=="logic"&&n.category!=="barrel"||(n.testedBy??=[],n.testedBy.includes(e.path)||n.testedBy.push(e.path)))}}function Qs(t){for(let e of t.values())if(e.type==="markdown")for(let r of e.imports){if(r.isExternal||!r.toPath)continue;let n=t.get(r.toPath);!n||n===e||(n.documentedBy??=[],n.documentedBy.includes(e.path)||n.documentedBy.push(e.path),n.category==="logic"&&(n.lastCommitAt??0)>(e.lastCommitAt??0)&&(e.staleFor??=[],e.staleFor.includes(n.path)||e.staleFor.push(n.path)))}}function Js(t){return Math.round(t*1e4)/1e4}function Ys(t){for(let e of t.values()){let r=[];for(let n of e.imports){if(n.isExternal||!n.toPath)continue;let o=t.get(n.toPath);if(!o||o.exports.length===0)continue;let s;if(n.symbols===void 0){if(n.type==="side-effect")continue;s=1}else n.symbols.includes("*")?s=1:s=n.symbols.length/o.exports.length;n.exportUsageRatio=Js(Math.min(1,s)),r.push(n.exportUsageRatio)}r.length>0&&(e.avgExportUsage=Js(r.reduce((n,o)=>n+o,0)/r.length),e.maxExportUsage=Math.max(...r))}}function Ur(t,e,r){e&&(t.some(n=>n.name===e&&n.kind===r)||t.push({name:e,kind:r}))}function Cf(t,e){let r=e.toPath,n=Us.basename(r,Us.extname(r)).replace(/\.(test|spec)$/,"");Ur(t.tags,n,"import")}function kf(t,e){if(!(!e.symbols||e.symbols.includes("*")))for(let r of e.symbols)Ur(t.tags,r,"import")}function vf(t,e,r){let n=r.get(e.toPath);if(!(!n||n.category==="test"))for(let o of n.tags)o.kind==="comment-marker"&&Ur(t.tags,o.name,"comment-marker")}function Xs(t){for(let e of t.values())if(e.category==="test")for(let r of e.imports)!r.toPath||r.isExternal||(Cf(e,r),kf(e,r),vf(e,r,t))}var qs=m(()=>{"use strict";l()});import ti from"fs";import pe from"path";function wf(t,e){let r=t.split(`
29
+ `),n=null,o=new Map,s=!1;for(let i of r){let a=i.trim();if(a.startsWith("module ")){n=a.slice(7).trim();continue}if(/^replace\s*\(/.test(a)){s=!0;continue}if(s&&a===")"){s=!1;continue}if(s&&a.includes("=>")){Zs(a,e,o);continue}!s&&/^replace\s+/.test(a)&&a.includes("=>")&&Zs(a.replace(/^replace\s+/,""),e,o)}return{mod:n,replaces:o}}function Zs(t,e,r){let[n,o]=t.split("=>").map(a=>a.trim());if(!n||!o)return;let s=n.split(/\s+/)[0];if(!o.startsWith(".")&&!o.startsWith("/"))return;let i=pe.isAbsolute(o)?o:pe.resolve(e,o);r.set(s,i)}function ei(t){let e;try{e=ti.readdirSync(t,{withFileTypes:!0})}catch{return null}let r=e.filter(n=>n.isFile()&&n.name.endsWith(".go")&&!n.name.endsWith("_test.go")).map(n=>({path:pe.join(t,n.name),isExternal:!1})).sort((n,o)=>n.path.localeCompare(o.path));return r.length>0?r:null}var Te,ri=m(()=>{"use strict";l();Te=class{extensions=[".go"];goModCache=new Map;resolve(e,r,n,o){let{mod:s,replaces:i}=this.readGoMod(n);if(!s)return null;let a=this.applyReplace(r,i,n);if(a!==void 0)return ei(a);if(r!==s&&!r.startsWith(`${s}/`))return null;let c=r.slice(s.length).replace(/^\//,"");return c?ei(pe.join(n,c)):null}readGoMod(e){let r=this.goModCache.get(e);if(r!==void 0)return r;let n={mod:null,replaces:new Map};try{let o=ti.readFileSync(pe.join(e,"go.mod"),"utf-8"),s=wf(o,e);return this.goModCache.set(e,s),s}catch{return this.goModCache.set(e,n),n}}applyReplace(e,r,n){for(let[o,s]of r){if(e===o)return s;if(e.startsWith(`${o}/`)){let i=e.slice(o.length+1);return pe.join(s,i)}}}}});import Ef from"fs";import Jr from"path";var Fe,ni=m(()=>{"use strict";l();Fe=class{extensions=[".lua"];resolve(e,r,n,o){let s=r.replace(/\./g,Jr.sep),i=[n,Jr.join(n,"lib")];for(let a of i){if(!Ef.existsSync(a))continue;let c=o(Jr.join(a,"_dummy.lua"),s);if(c)return[c]}return null}}});import Tf from"path";var Ne,oi=m(()=>{"use strict";l();Ne=class{extensions=[".md",".mdx"];resolve(e,r,n,o){let s=o(Tf.join(n,"_dummy"),`./${r}`);return s?[s]:null}}});import Ff from"fs";import Kr from"path";function si(t){try{return Ff.statSync(t,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}var Pe,ii=m(()=>{"use strict";l();Pe=class{extensions=[".py"];resolve(e,r,n,o){let s=r.replace(/\./g,Kr.sep),i=Kr.join(n,`${s}.py`);if(si(i))return[{path:i,isExternal:!1}];let a=Kr.join(n,s,"__init__.py");return si(a)?[{path:a,isExternal:!1}]:null}}});import ai from"path";var Nf,Ie,ci=m(()=>{"use strict";l();Nf=["~","http://","https://","//","data:","sass:"],Ie=class{extensions=[".css",".scss",".sass",".less",".styl"];resolve(e,r,n,o){if(Nf.some(f=>r.startsWith(f)))return null;let s=o(e,r);if(s)return[s];let i=ai.dirname(r),a=ai.basename(r),c=i==="."?`_${a}`:`${i}/_${a}`,p=o(e,c);return p?[p]:null}}});var li=m(()=>{"use strict";l();ri();ni();oi();ii();ci()});import yt from"fs";import B from"path";var Z,Hr=m(()=>{"use strict";l();li();Z=class{constructor(e,r={}){this.rootDir=e;this.workspaceMap=r.workspaceMap??new Map,this.tsconfigSearchPaths=r.tsconfigSearchPaths??[e],this.pathAliases=r.pathAliases,this.langResolvers=r.langResolvers??[new Pe,new Fe,new Te,new Ie,new Ne]}rootDir;workspaceMap;tsconfigSearchPaths;pathAliases;langResolvers;resolveAll(e,r){let n=this.resolvePathAlias(r);if(n)return[n];if(r.startsWith(".")||r.startsWith("/")){let i=this.resolveLocalPath(e,r);return i?[i]:[]}let o=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,o);if(a)return a}let s=this.resolveWorkspaceImport(r);return s?[s]:[{path:r,isExternal:!0}]}resolve(e,r){let n=this.resolvePathAlias(r);if(n)return n;if(r.startsWith(".")||r.startsWith("/"))return this.resolveLocalPath(e,r);let o=(i,a)=>this.resolveLocalPath(i,a);for(let i of this.langResolvers)if(i.extensions.some(a=>e.endsWith(a))){let a=i.resolve(e,r,this.rootDir,o);if(a)return a[0]??null}let s=this.resolveWorkspaceImport(r);return s||{path:r,isExternal:!0}}resolveLocalPath(e,r){let n=B.dirname(e),o=r.startsWith("/")?r:B.resolve(n,r),s=!o.startsWith(this.rootDir),i=["",".ts",".tsx",".js",".jsx",".mjs",".cjs",".css",".scss",".sass",".less",".styl",".coffee",".ls",".lua",".py",".feature",".md",".mdx"],a=o.match(/\.(js|mjs|cjs)$/);if(a){let c=o.slice(0,-a[0].length);for(let p of[".ts",".tsx"]){let f=this.tryExtensions(c,p,s);if(f)return f}}for(let c of i){let p=this.tryExtensions(o,c,s);if(p)return p}return s?{path:o,isExternal:!0}:null}tryExtensions(e,r,n){let o=e+r;if(this.isFile(o))return{path:o,isExternal:n};let s=B.join(e,`index${r}`);if(this.isFile(s))return{path:s,isExternal:n};if(r===".py"){let i=B.join(e,"__init__.py");if(this.isFile(i))return{path:i,isExternal:n}}return null}isFile(e){try{return yt.statSync(e,{throwIfNoEntry:!1})?.isFile()===!0}catch{return!1}}resolvePathAlias(e){if(this.pathAliases)for(let r in this.pathAliases){let n=this.matchAliasPattern(r,e),o=this.pathAliases[r];if(n&&o){let s=this.tryAliasSubstitutions(o,n[1]||"");if(s)return s}}for(let r of this.tsconfigSearchPaths){let n=B.join(r,"tsconfig.json");if(yt.existsSync(n))try{let s=JSON.parse(yt.readFileSync(n,"utf-8")).compilerOptions?.paths;if(!s)continue;for(let i in s){let a=this.matchAliasPattern(i,e);if(a){let c=this.tryAliasSubstitutions(s[i],a[1]||"",r);if(c)return c}}}catch{}}return null}aliasRegexCache=new Map;matchAliasPattern(e,r){let n=this.aliasRegexCache.get(e);if(!n){let o=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace("\\*","(.*)");n=new RegExp(`^${o}$`),this.aliasRegexCache.set(e,n)}return r.match(n)}tryAliasSubstitutions(e,r,n=this.rootDir){let o=["",".ts",".tsx",".js",".jsx",".coffee",".ls",".lua",".feature"];for(let s of e){let i=s.replace("*",r),a=B.resolve(n,i);for(let c of o){let p=this.tryExtensions(a,c,!1);if(p)return p}}return null}resolveWorkspaceImport(e){if(this.workspaceMap.size===0)return null;for(let[r,n]of this.workspaceMap){if(e!==r&&!e.startsWith(`${r}/`))continue;let o=e.slice(r.length),s={path:"",isExternal:!1,isWorkspace:!0,workspacePackage:r};if(!o){for(let a of["src/index.ts","src/index.tsx","index.ts","index.tsx","index.js"]){let c=B.join(n,a);try{if(yt.statSync(c,{throwIfNoEntry:!1})?.isFile())return{...s,path:c}}catch{}}return{...s,path:n}}let i=this.resolveLocalPath(B.join(n,"_dummy"),o.slice(1));return i?{...s,path:i.path}:null}return null}}});import De from"fs";import I from"path";import Pf from"piscina";function Mf(t,e){if(t.length===0)return e;let r=t.map(i=>I.dirname(i).split(I.sep)),n=r[0]??[];for(let i of r.slice(1)){let a=0;for(;a<n.length&&a<i.length&&n[a]===i[a];)a++;n=n.slice(0,a)}let o=n.join(I.sep)||I.sep,s=I.relative(e,o);return s.startsWith("..")||I.isAbsolute(s)?e:o}var If,pi,Df,Me,fi=m(()=>{"use strict";l();Ar();re();$t();Bs();qs();he();Hr();If=["tests","test","__tests__","specs","spec"],pi=new Set(["node_modules",".git","dist","build",".next",".cache","mokosh-cache","coverage"]),Df=20;Me=class{constructor(e,r=null,n,o,s=!1,i=new Map,a=!0){this.rootDir=e;this.enableGitStats=s;this.coverageMap=i;this.parallelParsing=a;this.previousGraph=r,this.resolver=n||new Z(e),this.lockFile=On(e),o&&(this.progressCallback=o)}rootDir;enableGitStats;coverageMap;parallelParsing;graph={nodes:new Map};visited=new Set;queue=[];previousGraph=null;resolver;lockFile=null;progressCallback;pool=null;gitStatsMap=null;async build(e){let r=e.map(n=>I.isAbsolute(n)?n:I.resolve(this.rootDir,n));await this.initPool(),this.enableGitStats&&(this.gitStatsMap=is(this.rootDir));try{for(let n of r)this.enqueue(n);return await this.drain(),await this.processTestFiles(Mf(r,this.rootDir)),await this.processDocFiles(),this.progressCallback&&this.visited.size>=100&&process.stderr.write(`
30
30
  Done. Total processed: ${this.visited.size} nodes.
31
- `),Hs(this.graph.nodes),Us(this.graph.nodes),Ks(this.graph.nodes),Js(this.graph.nodes),this.coverageMap.size>0&&$s(this.graph.nodes,this.coverageMap),new R(this.graph.nodes)}finally{this.pool&&(await this.pool.destroy(),this.pool=null)}}async initPool(){if(this.parallelParsing===!1)return;let e=typeof this.parallelParsing=="object"?this.parallelParsing:{},r=e.minFiles??Af;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r)))try{let n=M.join(f,"parse-worker.js");this.pool=new Df({filename:n,...e.maxThreads!==void 0?{maxThreads:e.maxThreads}:{}})}catch(n){process.stderr.write(`
31
+ `),Xs(this.graph.nodes),Vs(this.graph.nodes),Ys(this.graph.nodes),Qs(this.graph.nodes),this.coverageMap.size>0&&Ks(this.graph.nodes,this.coverageMap),new D(this.graph.nodes)}finally{this.pool&&(await this.pool.destroy(),this.pool=null)}}async initPool(){if(this.parallelParsing===!1)return;let e=typeof this.parallelParsing=="object"?this.parallelParsing:{},r=e.minFiles??Df;if(!(r>0&&!this.hasAtLeastFiles(this.rootDir,r)))try{let n=I.join(u,"parse-worker.js");this.pool=new Pf({filename:n,...e.maxThreads!==void 0?{maxThreads:e.maxThreads}:{}})}catch(n){process.stderr.write(`
32
32
  Warning: failed to start parse worker pool, falling back to synchronous parsing: ${n}
33
- `),this.pool=null}}hasAtLeastFiles(e,r){let n=0,o=[e];for(;o.length>0;){let s=o.pop();if(s===void 0)continue;let i;try{i=De.readdirSync(s,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())ii.has(a.name)||o.push(M.join(s,a.name));else if(a.isFile()&&(n++,n>=r))return!0}return n>=r}async processTestFiles(e){let r=ue(),n=s=>r.some(i=>s.name.includes(i));this.walkProject(e,n);let o=e;for(;o!==this.rootDir;){let s=M.dirname(o);if(s===o)break;for(let i of Mf){let a=M.join(s,i);try{De.statSync(a).isDirectory()&&this.walkProject(a,n)}catch{}}o=s}await this.drain()}async processDocFiles(){this.walkProject(this.rootDir,e=>e.name.endsWith(".md")||e.name.endsWith(".mdx")),await this.drain()}walkProject(e,r){let n;try{n=De.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of n){let s=M.join(e,o.name);o.isDirectory()?ii.has(o.name)||this.walkProject(s,r):o.isFile()&&r(o)&&this.enqueue(s)}}enqueue(e){this.visited.has(e)||(this.visited.add(e),this.showProgress(),this.queue.push(e))}async drain(){for(;this.queue.length>0;){let e=this.queue;this.queue=[],await Promise.all(e.map(r=>this.finishFile(r)))}}async finishFile(e){let r=De.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let n=M.relative(this.rootDir,e),o=await this.getNode(e,n,r);o.imports=await this.resolveImports(e,o.imports),Bs(o.imports,o.tags),this.graph.nodes.set(o.path,o)}async getNode(e,r,n){let o=this.previousGraph?.nodes.get(r);if(o&&o.mtime===n.mtimeMs&&o.size===n.size)return{...o};let s=await this.tryParse(e,r);if(!s)return this.makeStubNode(e,r,n);let i=this.resolveCallEdges(e,s.rawCallEdges),a=this.buildNode(e,r,n,s,i);return this.attachGitStats(a,r),a}async tryParse(e,r){let n=De.readFileSync(e,"utf-8");try{return await this.parseContent(e,n)}catch(o){return process.stderr.write(`
33
+ `),this.pool=null}}hasAtLeastFiles(e,r){let n=0,o=[e];for(;o.length>0;){let s=o.pop();if(s===void 0)continue;let i;try{i=De.readdirSync(s,{withFileTypes:!0})}catch{continue}for(let a of i)if(a.isDirectory())pi.has(a.name)||o.push(I.join(s,a.name));else if(a.isFile()&&(n++,n>=r))return!0}return n>=r}async processTestFiles(e){let r=ue(),n=s=>r.some(i=>s.name.includes(i));this.walkProject(e,n);let o=e;for(;o!==this.rootDir;){let s=I.dirname(o);if(s===o)break;for(let i of If){let a=I.join(s,i);try{De.statSync(a).isDirectory()&&this.walkProject(a,n)}catch{}}o=s}await this.drain()}async processDocFiles(){this.walkProject(this.rootDir,e=>e.name.endsWith(".md")||e.name.endsWith(".mdx")),await this.drain()}walkProject(e,r){let n;try{n=De.readdirSync(e,{withFileTypes:!0})}catch{return}for(let o of n){let s=I.join(e,o.name);o.isDirectory()?pi.has(o.name)||this.walkProject(s,r):o.isFile()&&r(o)&&this.enqueue(s)}}enqueue(e){this.visited.has(e)||(this.visited.add(e),this.showProgress(),this.queue.push(e))}async drain(){for(;this.queue.length>0;){let e=this.queue;this.queue=[],await Promise.all(e.map(r=>this.finishFile(r)))}}async finishFile(e){let r=De.statSync(e,{throwIfNoEntry:!1});if(!r?.isFile())return;let n=I.relative(this.rootDir,e),o=await this.getNode(e,n,r);o.imports=await this.resolveImports(e,o.imports),Hs(o.imports,o.tags),this.graph.nodes.set(o.path,o)}async getNode(e,r,n){let o=this.previousGraph?.nodes.get(r);if(o&&o.mtime===n.mtimeMs&&o.size===n.size)return{...o};let s=await this.tryParse(e,r);if(!s)return this.makeStubNode(e,r,n);let i=this.resolveCallEdges(e,s.rawCallEdges),a=this.buildNode(e,r,n,s,i);return this.attachGitStats(a,r),a}async tryParse(e,r){let n=De.readFileSync(e,"utf-8");try{return await this.parseContent(e,n)}catch(o){return process.stderr.write(`
34
34
  Warning: failed to parse ${r}: ${o}
35
- `),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):_s(e,r)}makeStubNode(e,r,n){return{path:r,type:z(e),category:"other",imports:[],exports:[],tags:[],mtime:n.mtimeMs,size:n.size}}resolveCallEdges(e,r){let n=[];for(let o of r??[])try{let s=this.resolver.resolve(e,o.toSpecifier);s&&!s.isExternal&&n.push({from:o.from,to:o.to,toFile:M.relative(this.rootDir,s.path)})}catch{}return n}buildNode(e,r,n,o,s){let{imports:i,exports:a,tags:c,category:p,description:m,complexity:d,cognitiveComplexity:y,functions:x}=o;return{path:r,type:z(e),category:p,imports:i,exports:a,tags:c,mtime:n.mtimeMs,size:n.size,...m!==void 0?{description:m}:{},...s.length>0?{callEdges:s}:{},...d!==void 0?{complexity:d}:{},...y!==void 0?{cognitiveComplexity:y}:{},...x!==void 0?{functions:x}:{}}}attachGitStats(e,r){let n=this.gitStatsMap?.get(r);n&&(e.commitCount90d=n.commitCount90d,n.lastAuthor!==void 0&&(e.lastAuthor=n.lastAuthor),n.lastCommitAt!==void 0&&(e.lastCommitAt=n.lastCommitAt))}async resolveImports(e,r){let n=[];for(let o of r){let s=this.resolver.resolveAll(e,o.rawSpecifier);if(s.length!==0)for(let i of s){let a={...o,toPath:i.isExternal?i.path:M.relative(this.rootDir,i.path),isExternal:i.isExternal};i.isWorkspace&&(a.isWorkspace=!0,a.workspacePackage=i.workspacePackage),i.isExternal?this.attachLockfileVersion(a):this.enqueue(i.path),n.push(a)}}return n}attachLockfileVersion(e){if(!this.lockFile)return;let r=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],n=r?this.lockFile.dependencies[r]:void 0;n&&(e.version=n.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}}});var ci=u(()=>{"use strict";l();jt();ai();zt();Ut();qt();Ve();Qe();he();qr();pr();Xe();gr();br();Sr()});var Zr=u(()=>{"use strict";l();ci()});function li(t,e){return{identifier:e?.identifier??new ut,featureMap:e?.featureDetection===!1?new Map:K(t.nodes,e?.featureDetection??void 0)}}function pi(t,e,r,n,o){for(let s of e){let i=t.nodes.get(s);if(!i)continue;let a=new H(s,["*",...i.exports.map(c=>c.name)]);t.traverse(s,(c,p,m)=>{if(!m)return!0;if(!a.updateAffectedSymbols(c,m))return!1;if(p>0){let d=r.get(c.path);if(d)return n(d),!1}return o(c),!0},{direction:"incoming"})}}function en(t,e,r){let{identifier:n,featureMap:o}=li(t,r),s=new Set;for(let i of e){let a=o.get(i);a&&s.add(a.tag)}return pi(t,e,o,i=>s.add(i.tag),i=>{if(n.isTestNode(i))for(let a of i.tags)s.add(a.name)}),Array.from(s)}function tn(t,e,r){let{identifier:n,featureMap:o}=li(t,r),s=new Set;return pi(t,e,o,()=>{},i=>{n.isTestNode(i)&&s.add(i.path)}),Array.from(s)}var fi=u(()=>{"use strict";l();Zr();Or()});var mi=u(()=>{"use strict";l();qo();Or();fi()});import Lf from"fs";import Ae from"path";async function G(t,e,r=null,n={}){let o=n.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},s=Ae.resolve(t);return await new Me(s,r,n.pathAliases?new Z(s,{pathAliases:n.pathAliases}):void 0,o,n.gitStats??!1,n.coverageMap??new Map,n.parallelParsing??!0).build(e)}async function ui(t,e={}){let r=Ae.resolve(t),n=xr(r),o=e.packages?n.packages.filter(a=>e.packages?.includes(a.name)||e.packages?.includes(a.relativeRoot)):n.packages,s=new Map(n.packages.map(a=>[a.name,a.root])),i=new Se(r,n.type);for(let a of o){let c=e.silent?void 0:d=>{process.stderr.write(`[${a.name}] Processed ${d} files...\r`)},m=await new Me(r,null,new Z(r,{workspaceMap:s,tsconfigSearchPaths:[a.root,r],pathAliases:e.pathAliases}),c,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,m)}return i}function _(t,e={}){let r=[],n=new Set([...e.ignoreDirs??J,...e.additionalIgnoreDirs??[]]),o=new Set([...e.extensions??Lt,...e.additionalExtensions??[]]);function s(i){try{let a=Lf.readdirSync(i,{withFileTypes:!0});for(let c of a){let p=Ae.join(i,c.name);c.isDirectory()?n.has(c.name)||s(p):c.isFile()&&o.has(Ae.extname(c.name).toLowerCase())&&r.push(Ae.relative(t,p))}}catch{}}return s(t),r}var F=u(()=>{"use strict";l();Rt();je();Mn();Rn();jt();zt();Ut();qt();Ve();Qe();er();he();cr();pr();ao();Xe();gr();br();tt();Sr();re();Ce();Ro();mi();je();Zr()});var St,Ct,rn=u(()=>{"use strict";l();St="mokosh-cache",Ct="graph.json"});import Re from"path";import{parseArgs as Of}from"util";function Gf(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return Re.resolve(t[e+1]);return process.cwd()}function fe(t){return t?parseInt(t,10):void 0}function gi(t){return t?t.split(",").map(e=>e.trim()):void 0}function jf(t){let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(n!==void 0)if(!n.startsWith("--"))e.push(n);else if(_f.has(n)){let o=t[r+1];o!==void 0&&!o.startsWith("--")&&(e.push(n,o),r++)}else n.slice(2)in nn&&e.push(n)}return e}function di(t){let e=Gf(t),r=Re.join(Re.resolve(e,St),Ct),{values:n,positionals:o}=Of({args:jf(t),allowPositionals:!0,options:nn}),s=n.cache,i=n.config,a=n.metric;return{rootDir:e,cachePath:s?Re.resolve(e,s):r,configPath:i?Re.resolve(e,i):void 0,query:n.query,file:n.file,typeFilter:n.type,functionName:n.function,filterPaths:gi(n.paths),featureThreshold:fe(n["feature-threshold"]),minOutDegree:fe(n["min-out-degree"]),mermaid:n.mermaid??!1,proposeTags:n["propose-tags"]??!1,plain:n.plain??!1,affectedTests:n["affected-tests"]??!1,detectFeatures:n["detect-features"]??!1,findUnused:n["find-unused"]??!1,excludeTests:n["exclude-tests"]??!1,checkCycles:n["check-cycles"]??!1,checkDocDrift:n["check-doc-drift"]??!1,findUncovered:n["find-uncovered"]??!1,listTags:n["list-tags"]??!1,callers:n.callers??!1,silent:n.silent??!1,queryHelp:n["query-help"]??!1,help:t.length===0||(n.help??!1),typeGraph:n["type-graph"]??!1,moduleResponsibility:n["module-responsibility"]??!1,featureGraph:n["feature-graph"]??!1,callGraph:n["call-graph"]??!1,findSymbol:n["find-symbol"]??!1,apiSurface:n["api-surface"]??!1,applyTags:n["apply-tags"]??!1,dryRun:n["dry-run"]??!1,initSkill:n["init-skill"]??!1,initConfig:n["init-config"]??!1,force:n.force??!1,dependencies:n.dependencies??!1,dependents:n.dependents??!1,affected:n.affected??!1,testsOnly:n["tests-only"]??!1,changedSymbols:gi(n["changed-symbols"]),cached:n.cached??!1,depth:fe(n.depth),withMeta:n["with-meta"]??!1,withEdgeDetail:n["with-edge-detail"]??!1,findComplexFunctions:n["find-complex-functions"]??!1,metric:a==="complexity"||a==="cognitiveComplexity"?a:void 0,complexityThreshold:fe(n["complexity-threshold"]),limit:fe(n.limit),findDuplicates:n["find-duplicates"]??!1,minDuplicateLines:fe(n["min-duplicate-lines"]),workspacePackages:n["workspace-packages"]??!1,workspaceAffected:n["workspace-affected"]??!1,clearCache:n["clear-cache"]??!1,slim:n.slim??!1,watch:n.watch??!1,entryPoints:o}}var nn,_f,hi=u(()=>{"use strict";l();rn();nn={root:{type:"string"},cache:{type:"string"},config:{type:"string"},query:{type:"string"},file:{type:"string"},type:{type:"string"},paths:{type:"string"},function:{type:"string"},"feature-threshold":{type:"string"},"min-out-degree":{type:"string"},mermaid:{type:"boolean"},"propose-tags":{type:"boolean"},plain:{type:"boolean"},"affected-tests":{type:"boolean"},"detect-features":{type:"boolean"},"find-unused":{type:"boolean"},"exclude-tests":{type:"boolean"},"check-cycles":{type:"boolean"},"check-doc-drift":{type:"boolean"},"find-uncovered":{type:"boolean"},"list-tags":{type:"boolean"},callers:{type:"boolean"},silent:{type:"boolean"},"query-help":{type:"boolean"},help:{type:"boolean"},"type-graph":{type:"boolean"},"module-responsibility":{type:"boolean"},"feature-graph":{type:"boolean"},"call-graph":{type:"boolean"},"find-symbol":{type:"boolean"},"api-surface":{type:"boolean"},"apply-tags":{type:"boolean"},"dry-run":{type:"boolean"},"init-skill":{type:"boolean"},"init-config":{type:"boolean"},force:{type:"boolean"},dependencies:{type:"boolean"},dependents:{type:"boolean"},affected:{type:"boolean"},"tests-only":{type:"boolean"},"changed-symbols":{type:"string"},cached:{type:"boolean"},depth:{type:"string"},"with-meta":{type:"boolean"},"with-edge-detail":{type:"boolean"},"find-complex-functions":{type:"boolean"},metric:{type:"string"},"complexity-threshold":{type:"string"},limit:{type:"string"},"find-duplicates":{type:"boolean"},"min-duplicate-lines":{type:"string"},"workspace-packages":{type:"boolean"},"workspace-affected":{type:"boolean"},"clear-cache":{type:"boolean"},slim:{type:"boolean"},watch:{type:"boolean"}},_f=new Set(Object.entries(nn).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function on(t){let{graph:e,file:r,testsOnly:n,changedSymbols:o,cached:s,withMeta:i}=t;r||(console.error("Error: --affected requires --file <path>"),process.exit(1));let a=m=>i?m.map(d=>({path:d,...V(e,d)})):m;if(s){let m=$t(e),d=Bt(m,r),y=n?d.filter(S=>e.nodes.get(S)?.category==="test"):d,x=a(y);console.log(JSON.stringify({file:r,affected:x,count:x.length},null,2));return}let c=rr(e,r,{testsOnly:n,changedSymbols:o}),p=a(c);console.log(JSON.stringify({file:r,affected:p,count:p.length},null,2))}var yi=u(()=>{"use strict";l();F()});import sn from"path";function ee(t){return t.filter(e=>{let r=sn.basename(e).toLowerCase();return Wf.some(n=>r.includes(n))})}function vt(t){return new gt().getChangedFiles().map(e=>sn.relative(t,sn.resolve(t,e)))}var Wf,kt=u(()=>{"use strict";l();_r();Wf=[".test.",".spec.","-test.","-spec."]});async function xi(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,rawConfig:s}=t,i=vt(r);if(![...e.nodes.values()].some(p=>ee([p.path]).length>0)){let p=_(r,n);e=await G(r,ee(p),e,I(s))}let c=tn(e,i,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(c.join(`
36
- `))}var bi=u(()=>{"use strict";l();F();kt()});async function Si(t){let{graph:e,rootDir:r,entryPoints:n}=t,o=n.length?n:Gt(e,r);o.length===0&&(console.error("Error: No entry points found. Pass entry points as positional args or ensure package.json has a main/exports field."),process.exit(1));let s=_t(e,o);console.log(JSON.stringify(s,null,2))}var Ci=u(()=>{"use strict";l();F()});async function vi(t){let{graph:e}=t,{rootDir:r,scanOptions:n,dryRun:o,plain:s,rawConfig:i}=t;if(s||console.log(o?"Dry run: computing tag changes...":"Applying tags to test files..."),e.nodes.size===0){let c=_(r,n);e=await G(r,ee(c),e,I(i))}let a=await Lr(e,r,{dryRun:o});console.log(JSON.stringify(a,null,2))}var ki=u(()=>{"use strict";l();F();kt()});async function wi(t){let{graph:e,functionName:r}=t;r||(console.error("Error: --call-graph requires --function <name>"),process.exit(1));let n=Wt(e,r);console.log(JSON.stringify(n,null,2))}var Ei=u(()=>{"use strict";l();F()});async function an(t){let{graph:e,file:r,plain:n,depth:o,withEdgeDetail:s}=t;r||(console.error("Error: --callers requires --file <path>"),process.exit(1));let i=nr(e,r,{depth:o??1,withEdgeDetail:s});console.log(n?i.map(a=>a.file).join(`
37
- `):JSON.stringify({file:r,callers:i,count:i.length},null,2))}var Fi=u(()=>{"use strict";l();F()});async function cn(t){let{graph:e}=t,r=e.findCycles();if(r.length>0){process.stderr.write(`Found ${r.length} cycle(s):
35
+ `),null}}parseContent(e,r){return this.pool?this.pool.run({filePath:e,content:r}):$s(e,r)}makeStubNode(e,r,n){return{path:r,type:W(e),category:"other",imports:[],exports:[],tags:[],mtime:n.mtimeMs,size:n.size}}resolveCallEdges(e,r){let n=[];for(let o of r??[])try{let s=this.resolver.resolve(e,o.toSpecifier);s&&!s.isExternal&&n.push({from:o.from,to:o.to,toFile:I.relative(this.rootDir,s.path)})}catch{}return n}buildNode(e,r,n,o,s){let{imports:i,exports:a,tags:c,category:p,description:f,complexity:d,cognitiveComplexity:y,functions:x}=o;return{path:r,type:W(e),category:p,imports:i,exports:a,tags:c,mtime:n.mtimeMs,size:n.size,...f!==void 0?{description:f}:{},...s.length>0?{callEdges:s}:{},...d!==void 0?{complexity:d}:{},...y!==void 0?{cognitiveComplexity:y}:{},...x!==void 0?{functions:x}:{}}}attachGitStats(e,r){let n=this.gitStatsMap?.get(r);n&&(e.commitCount90d=n.commitCount90d,n.lastAuthor!==void 0&&(e.lastAuthor=n.lastAuthor),n.lastCommitAt!==void 0&&(e.lastCommitAt=n.lastCommitAt))}async resolveImports(e,r){let n=[];for(let o of r){let s=this.resolver.resolveAll(e,o.rawSpecifier);if(s.length!==0)for(let i of s){let a={...o,toPath:i.isExternal?i.path:I.relative(this.rootDir,i.path),isExternal:i.isExternal};i.isWorkspace&&(a.isWorkspace=!0,a.workspacePackage=i.workspacePackage),i.isExternal?this.attachLockfileVersion(a):this.enqueue(i.path),n.push(a)}}return n}attachLockfileVersion(e){if(!this.lockFile)return;let r=e.rawSpecifier.startsWith("@")?e.rawSpecifier.split("/").slice(0,2).join("/"):e.rawSpecifier.split("/")[0],n=r?this.lockFile.dependencies[r]:void 0;n&&(e.version=n.version)}showProgress(){this.progressCallback&&this.visited.size%100===0&&this.progressCallback(this.visited.size)}}});var ui=m(()=>{"use strict";l();Rt();fi();Gt();Wt();Ht();Ke();He();he();Hr();sr();Qe();lr();gr();dr()});var Vr=m(()=>{"use strict";l();ui()});function mi(t,e){return{identifier:e?.identifier??new ft,featureMap:e?.featureDetection===!1?new Map:K(t.nodes,e?.featureDetection??void 0)}}function gi(t,e,r,n,o){for(let s of e){let i=t.nodes.get(s);if(!i)continue;let a=new H(s,["*",...i.exports.map(c=>c.name)]);t.traverse(s,(c,p,f)=>{if(!f)return!0;if(!a.updateAffectedSymbols(c,f))return!1;if(p>0){let d=r.get(c.path);if(d)return n(d),!1}return o(c),!0},{direction:"incoming"})}}function Qr(t,e,r){let{identifier:n,featureMap:o}=mi(t,r),s=new Set;for(let i of e){let a=o.get(i);a&&s.add(a.tag)}return gi(t,e,o,i=>s.add(i.tag),i=>{if(n.isTestNode(i))for(let a of i.tags)s.add(a.name)}),Array.from(s)}function Yr(t,e,r){let{identifier:n,featureMap:o}=mi(t,r),s=new Set;return gi(t,e,o,()=>{},i=>{n.isTestNode(i)&&s.add(i.path)}),Array.from(s)}var di=m(()=>{"use strict";l();Vr();Dr()});var hi=m(()=>{"use strict";l();rs();Dr();di()});import Af from"fs";import Ae from"path";async function L(t,e,r=null,n={}){let o=n.silent?void 0:a=>{process.stderr.write(`Processed ${a} files...\r`)},s=Ae.resolve(t);return await new Me(s,r,n.pathAliases?new Z(s,{pathAliases:n.pathAliases}):void 0,o,n.gitStats??!1,n.coverageMap??new Map,n.parallelParsing??!0).build(e)}async function yi(t,e={}){let r=Ae.resolve(t),n=mr(r),o=e.packages?n.packages.filter(a=>e.packages?.includes(a.name)||e.packages?.includes(a.relativeRoot)):n.packages,s=new Map(n.packages.map(a=>[a.name,a.root])),i=new Se(r,n.type);for(let a of o){let c=e.silent?void 0:d=>{process.stderr.write(`[${a.name}] Processed ${d} files...\r`)},f=await new Me(r,null,new Z(r,{workspaceMap:s,tsconfigSearchPaths:[a.root,r],pathAliases:e.pathAliases}),c,e.gitStats??!1,new Map,e.parallelParsing??!0).build(a.entryPoints);i.addPackage(a,f)}return i}function R(t,e={}){let r=[],n=new Set([...e.ignoreDirs??J,...e.additionalIgnoreDirs??[]]),o=new Set([...e.extensions??Dt,...e.additionalExtensions??[]]);function s(i){try{let a=Af.readdirSync(i,{withFileTypes:!0});for(let c of a){let p=Ae.join(i,c.name);c.isDirectory()?n.has(c.name)||s(p):c.isFile()&&o.has(Ae.extname(c.name).toLowerCase())&&r.push(Ae.relative(t,p))}}catch{}}return s(t),r}var E=m(()=>{"use strict";l();It();je();Nn();In();Rt();Gt();Wt();Ht();Ke();He();Qt();he();nr();sr();fo();Qe();lr();gr();Ze();dr();re();Ce();_o();hi();je();Vr()});var xt,bt,Xr=m(()=>{"use strict";l();xt="mokosh-cache",bt="graph.json"});import Le from"path";import{parseArgs as Lf}from"util";function Rf(t){for(let e=0;e<t.length;e++)if(t[e]==="--root"&&t[e+1])return Le.resolve(t[e+1]);return process.cwd()}function fe(t){return t?parseInt(t,10):void 0}function xi(t){return t?t.split(",").map(e=>e.trim()):void 0}function Gf(t){let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(n!==void 0)if(!n.startsWith("--"))e.push(n);else if(Of.has(n)){let o=t[r+1];o!==void 0&&!o.startsWith("--")&&(e.push(n,o),r++)}else n.slice(2)in qr&&e.push(n)}return e}function bi(t){let e=Rf(t),r=Le.join(Le.resolve(e,xt),bt),{values:n,positionals:o}=Lf({args:Gf(t),allowPositionals:!0,options:qr}),s=n.cache,i=n.config,a=n.metric;return{rootDir:e,cachePath:s?Le.resolve(e,s):r,configPath:i?Le.resolve(e,i):void 0,query:n.query,file:n.file,typeFilter:n.type,functionName:n.function,filterPaths:xi(n.paths),featureThreshold:fe(n["feature-threshold"]),minOutDegree:fe(n["min-out-degree"]),mermaid:n.mermaid??!1,proposeTags:n["propose-tags"]??!1,plain:n.plain??!1,affectedTests:n["affected-tests"]??!1,detectFeatures:n["detect-features"]??!1,findUnused:n["find-unused"]??!1,excludeTests:n["exclude-tests"]??!1,checkCycles:n["check-cycles"]??!1,checkDocDrift:n["check-doc-drift"]??!1,findUncovered:n["find-uncovered"]??!1,listTags:n["list-tags"]??!1,callers:n.callers??!1,silent:n.silent??!1,queryHelp:n["query-help"]??!1,help:t.length===0||(n.help??!1),typeGraph:n["type-graph"]??!1,moduleResponsibility:n["module-responsibility"]??!1,featureGraph:n["feature-graph"]??!1,callGraph:n["call-graph"]??!1,findSymbol:n["find-symbol"]??!1,apiSurface:n["api-surface"]??!1,applyTags:n["apply-tags"]??!1,dryRun:n["dry-run"]??!1,initSkill:n["init-skill"]??!1,initConfig:n["init-config"]??!1,force:n.force??!1,dependencies:n.dependencies??!1,dependents:n.dependents??!1,affected:n.affected??!1,testsOnly:n["tests-only"]??!1,changedSymbols:xi(n["changed-symbols"]),cached:n.cached??!1,depth:fe(n.depth),withMeta:n["with-meta"]??!1,withEdgeDetail:n["with-edge-detail"]??!1,findComplexFunctions:n["find-complex-functions"]??!1,metric:a==="complexity"||a==="cognitiveComplexity"?a:void 0,complexityThreshold:fe(n["complexity-threshold"]),limit:fe(n.limit),findDuplicates:n["find-duplicates"]??!1,minDuplicateLines:fe(n["min-duplicate-lines"]),workspacePackages:n["workspace-packages"]??!1,workspaceAffected:n["workspace-affected"]??!1,clearCache:n["clear-cache"]??!1,slim:n.slim??!1,watch:n.watch??!1,entryPoints:o}}var qr,Of,Si=m(()=>{"use strict";l();Xr();qr={root:{type:"string"},cache:{type:"string"},config:{type:"string"},query:{type:"string"},file:{type:"string"},type:{type:"string"},paths:{type:"string"},function:{type:"string"},"feature-threshold":{type:"string"},"min-out-degree":{type:"string"},mermaid:{type:"boolean"},"propose-tags":{type:"boolean"},plain:{type:"boolean"},"affected-tests":{type:"boolean"},"detect-features":{type:"boolean"},"find-unused":{type:"boolean"},"exclude-tests":{type:"boolean"},"check-cycles":{type:"boolean"},"check-doc-drift":{type:"boolean"},"find-uncovered":{type:"boolean"},"list-tags":{type:"boolean"},callers:{type:"boolean"},silent:{type:"boolean"},"query-help":{type:"boolean"},help:{type:"boolean"},"type-graph":{type:"boolean"},"module-responsibility":{type:"boolean"},"feature-graph":{type:"boolean"},"call-graph":{type:"boolean"},"find-symbol":{type:"boolean"},"api-surface":{type:"boolean"},"apply-tags":{type:"boolean"},"dry-run":{type:"boolean"},"init-skill":{type:"boolean"},"init-config":{type:"boolean"},force:{type:"boolean"},dependencies:{type:"boolean"},dependents:{type:"boolean"},affected:{type:"boolean"},"tests-only":{type:"boolean"},"changed-symbols":{type:"string"},cached:{type:"boolean"},depth:{type:"string"},"with-meta":{type:"boolean"},"with-edge-detail":{type:"boolean"},"find-complex-functions":{type:"boolean"},metric:{type:"string"},"complexity-threshold":{type:"string"},limit:{type:"string"},"find-duplicates":{type:"boolean"},"min-duplicate-lines":{type:"string"},"workspace-packages":{type:"boolean"},"workspace-affected":{type:"boolean"},"clear-cache":{type:"boolean"},slim:{type:"boolean"},watch:{type:"boolean"}},Of=new Set(Object.entries(qr).filter(([,t])=>t.type==="string").map(([t])=>`--${t}`))});async function Zr(t){let{graph:e,file:r,testsOnly:n,changedSymbols:o,cached:s,withMeta:i}=t;r||(console.error("Error: --affected requires --file <path>"),process.exit(1));let a=f=>i?f.map(d=>({path:d,...V(e,d)})):f;if(s){let f=_t(e),d=jt(f,r),y=n?d.filter(v=>e.nodes.get(v)?.category==="test"):d,x=a(y);console.log(JSON.stringify({file:r,affected:x,count:x.length},null,2));return}let c=Xt(e,r,{testsOnly:n,changedSymbols:o}),p=a(c);console.log(JSON.stringify({file:r,affected:p,count:p.length},null,2))}var Ci=m(()=>{"use strict";l();E()});import en from"path";function ee(t){return t.filter(e=>{let r=en.basename(e).toLowerCase();return _f.some(n=>r.includes(n))})}function St(t){return new ut().getChangedFiles().map(e=>en.relative(t,en.resolve(t,e)))}var _f,Ct=m(()=>{"use strict";l();Ar();_f=[".test.",".spec.","-test.","-spec."]});async function ki(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,rawConfig:s}=t,i=St(r);if(![...e.nodes.values()].some(p=>ee([p.path]).length>0)){let p=R(r,n);e=await L(r,ee(p),e,N(s))}let c=Yr(e,i,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(c.join(`
36
+ `))}var vi=m(()=>{"use strict";l();E();Ct()});async function wi(t){let{graph:e,rootDir:r,entryPoints:n}=t,o=n.length?n:At(e,r);o.length===0&&(console.error("Error: No entry points found. Pass entry points as positional args or ensure package.json has a main/exports field."),process.exit(1));let s=Lt(e,o);console.log(JSON.stringify(s,null,2))}var Ei=m(()=>{"use strict";l();E()});async function Ti(t){let{graph:e}=t,{rootDir:r,scanOptions:n,dryRun:o,plain:s,rawConfig:i}=t;if(s||console.log(o?"Dry run: computing tag changes...":"Applying tags to test files..."),e.nodes.size===0){let c=R(r,n);e=await L(r,ee(c),e,N(i))}let a=await Ir(e,r,{dryRun:o});console.log(JSON.stringify(a,null,2))}var Fi=m(()=>{"use strict";l();E();Ct()});async function Ni(t){let{graph:e,functionName:r}=t;r||(console.error("Error: --call-graph requires --function <name>"),process.exit(1));let n=Ot(e,r);console.log(JSON.stringify(n,null,2))}var Pi=m(()=>{"use strict";l();E()});async function tn(t){let{graph:e,file:r,plain:n,depth:o,withEdgeDetail:s}=t;r||(console.error("Error: --callers requires --file <path>"),process.exit(1));let i=qt(e,r,{depth:o??1,withEdgeDetail:s});console.log(n?i.map(a=>a.file).join(`
37
+ `):JSON.stringify({file:r,callers:i,count:i.length},null,2))}var Ii=m(()=>{"use strict";l();E()});async function rn(t){let{graph:e}=t,r=e.findCycles();if(r.length>0){process.stderr.write(`Found ${r.length} cycle(s):
38
38
  `);for(let n of r)process.stderr.write(` ${n.join(" \u2192 ")}
39
- `);process.exit(1)}console.log("No cycles detected.")}var Ti=u(()=>{"use strict";l()});async function ln(t){let{graph:e}=t,r=[...e.nodes.values()].filter(n=>n.type==="markdown"&&n.staleFor&&n.staleFor.length>0).map(n=>({doc:n.path,staleFor:n.staleFor}));if(r.length>0){process.stderr.write(`Found ${r.length} doc(s) that may be out of date:
39
+ `);process.exit(1)}console.log("No cycles detected.")}var Di=m(()=>{"use strict";l()});async function nn(t){let{graph:e}=t,r=[...e.nodes.values()].filter(n=>n.type==="markdown"&&n.staleFor&&n.staleFor.length>0).map(n=>({doc:n.path,staleFor:n.staleFor}));if(r.length>0){process.stderr.write(`Found ${r.length} doc(s) that may be out of date:
40
40
  `);for(let{doc:n,staleFor:o}of r)process.stderr.write(` ${n} \u2014 references changed more recently: ${o.join(", ")}
41
- `);process.exit(1)}console.log("No doc drift detected.")}var Ni=u(()=>{"use strict";l()});import Pi from"fs";function Ii(t){Pi.existsSync(t)?(Pi.unlinkSync(t),console.log(`Cache cleared: ${t}`)):console.log(`No cache file present at ${t}`)}var Di=u(()=>{"use strict";l()});async function pn(t){let{graph:e,file:r,depth:n,withMeta:o}=t;r||(console.error("Error: --dependencies requires --file <path>"),process.exit(1));let s=tr(e,r,n??1),i=o?s.map(a=>({...a,...V(e,a.path)})):s;console.log(JSON.stringify({file:r,dependencies:i},null,2))}var Mi=u(()=>{"use strict";l();F()});async function fn(t){let{graph:e,file:r,withMeta:n}=t;r||(console.error("Error: --dependents requires --file <path>"),process.exit(1));let o=ye(e,r),s=n?o.map(i=>({...i,...V(e,i.path)})):o;console.log(JSON.stringify({file:r,dependents:s},null,2))}var Ai=u(()=>{"use strict";l();F()});async function Ri(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,rawConfig:s}=t;if(e.nodes.size===0){let c=_(r,n);e=await G(r,c,e,I(s))}let i=K(e.nodes,o!==void 0?{minOutDegree:o}:void 0),a=Array.from(i.values()).sort((c,p)=>p.outDegree-c.outDegree);console.log(JSON.stringify({features:a},null,2))}var Li=u(()=>{"use strict";l();F()});async function Oi(t){let{graph:e}=t,{rootDir:r,scanOptions:n,minOutDegree:o,rawConfig:s}=t;if(e.nodes.size===0){let c=_(r,n);e=await G(r,c,e,I(s))}let i=ge(e,o!==void 0?{minOutDegree:o}:void 0),a=Object.fromEntries(i.features);console.log(JSON.stringify({features:a,unassigned:i.unassigned},null,2))}var Gi=u(()=>{"use strict";l();F()});async function mn(t){let{graph:e,metric:r,complexityThreshold:n,limit:o}=t,s=n??10,i=or(e,{metric:r,threshold:s,limit:o});console.log(JSON.stringify({metric:r??"cognitiveComplexity",threshold:s,functions:i,count:i.length},null,2))}var _i=u(()=>{"use strict";l();F()});async function un(t){let{graph:e,rootDir:r,scanOptions:n,minDuplicateLines:o,limit:s}=t,i=o??6,a=[...n.ignoreDirs??J,...n.additionalIgnoreDirs??[]],{groups:c,skippedBuckets:p}=await Xt(e,r,{minLines:i,limit:s,ignoreDirs:a});console.log(JSON.stringify({minLines:i,groups:c,count:c.length,skippedBuckets:p},null,2))}var ji=u(()=>{"use strict";l();F()});async function Wi(t){let{graph:e,functionName:r,plain:n}=t;r||(console.error("Error: --find-symbol requires --function <name>"),process.exit(1));let o=fr(e,r);console.log(n?o.map(s=>s.path).join(`
42
- `):JSON.stringify({name:r,matches:o,count:o.length},null,2))}var zi=u(()=>{"use strict";l();F()});async function gn(t){let{graph:e,featureThreshold:r,rawConfig:n,plain:o}=t,s=r??n.coverageThreshold??80;if(!ar(e)){console.log(JSON.stringify({error:"No coverage data available. Set coverageReportPath in mokosh.config and rebuild the graph."},null,2));return}let i=[...e.nodes.values()].filter(a=>a.category!=="test"&&a.category!=="config").filter(a=>a.coveragePct!==void 0&&a.coveragePct<s).map(a=>({file:a.path,coveragePct:a.coveragePct}));console.log(o?i.map(a=>a.file).join(`
43
- `):JSON.stringify({threshold:s,uncovered:i,count:i.length},null,2))}var $i=u(()=>{"use strict";l();F()});import zf from"path";function Bf(t){let e=zf.basename(t).toLowerCase();return $f.some(r=>e.includes(r))}async function Bi(t){let{graph:e,rootDir:r,scanOptions:n,excludeTests:o}=t,s=_(r,n),i=e.findUnusedFiles(s);o&&(i=i.filter(a=>!Bf(a))),console.log(JSON.stringify({unusedFiles:i},null,2))}var $f,Ui=u(()=>{"use strict";l();F();$f=[".test.",".spec.","-test.","-spec.",".stories."]});async function dn(t){let{graph:e,queryStr:r,mermaidOutput:n,slim:o}=t,s=e.serialize();if(r){let c=nt(r);s=rt(s,c)}if(n){let c=R.deserialize(s);console.log(We.serialize(c));return}let i=e.findCycles();i.length>0&&(s.cycles=i);let a=Zt(e);console.log(JSON.stringify(o?{...sr(s),languageCoverage:a}:{...s,languageCoverage:a},null,2))}var Ji=u(()=>{"use strict";l();F()});import Uf from"fs";import hn from"path";function wt(t,e,r){let n=t;for(let o=0;o<6;o++){let s=hn.join(n,"templates",...e);if(Uf.existsSync(hn.join(s,r)))return s;let i=hn.dirname(n);if(i===n)break;n=i}throw new Error(`Could not locate mokosh templates/${e.join("/")}`)}var yn=u(()=>{"use strict";l()});import Ki from"fs";import Hi from"path";function Vi(t,e=process.cwd()){let r=wt(f,["config"],"mokosh.config.js"),n=Hi.join(r,"mokosh.config.js"),o=Hi.join(e,"mokosh.config.js");if(Ki.existsSync(o)&&!t){console.log("skipped mokosh.config.js (already exists, use --force to overwrite)");return}Ki.copyFileSync(n,o),console.log("wrote mokosh.config.js")}var Qi=u(()=>{"use strict";l();yn()});import xn from"fs";import Et from"path";function Yi(t,e=process.cwd()){let r=wt(f,["skill"],"SKILL.md");for(let n of Jf){let o=Et.join(r,n.templateFile),s=Et.join(e,...n.destPath),i=Et.join(...n.destPath);if(xn.existsSync(s)&&!t){console.log(`skipped ${i} (already exists, use --force to overwrite)`);continue}xn.mkdirSync(Et.dirname(s),{recursive:!0}),xn.copyFileSync(o,s),console.log(`wrote ${i}`)}}var Jf,Xi=u(()=>{"use strict";l();yn();Jf=[{templateFile:"SKILL.md",destPath:[".claude","skills","mokosh","SKILL.md"]},{templateFile:"mokosh.md",destPath:[".claude","commands","mokosh.md"]}]});async function bn(t){let{graph:e,plain:r}=t,n=new Map;for(let s of e.nodes.values())for(let i of s.tags)n.set(i.name,(n.get(i.name)??0)+1);let o=[...n.entries()].map(([s,i])=>({name:s,count:i})).sort((s,i)=>i.count-s.count);console.log(r?o.map(s=>s.name).join(`
44
- `):JSON.stringify({tags:o,count:o.length},null,2))}var qi=u(()=>{"use strict";l()});async function Zi(t){let{graph:e,filterPaths:r,minOutDegree:n}=t,o=lr(e,n!==void 0?{minOutDegree:n}:void 0);if(r?.length){let s=r.map(i=>o.get(i)).filter(Boolean);console.log(JSON.stringify({count:s.length,modules:s},null,2))}else{let s=Array.from(o.values());console.log(JSON.stringify({count:s.length,modules:s},null,2))}}var ea=u(()=>{"use strict";l();F()});async function ta(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,plain:s,rawConfig:i}=t;s||console.log("Proposing test tags based on git diff...");let a=vt(r);if(e.nodes.size===0){let p=_(r,n);e=await G(r,ee(p),e,I(i))}let c=en(e,a,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(s?c.join(" "):JSON.stringify({proposedTags:c},null,2))}var ra=u(()=>{"use strict";l();F();kt()});async function na(t){let{graph:e,typeFilter:r}=t,n=mr(e);if(r){let o=ur(n,r);console.log(JSON.stringify(o,null,2))}else{let o=Array.from(n.types.values());console.log(JSON.stringify({count:o.length,types:o},null,2))}}var oa=u(()=>{"use strict";l();F()});function sa(t,e){let r=t.getAffectedAcrossPackages(e);console.log(JSON.stringify({file:e,affected:r,count:r.length},null,2))}var ia=u(()=>{"use strict";l()});function aa(t){console.log(JSON.stringify(ir(t),null,2))}var ca=u(()=>{"use strict";l();F()});import Sn from"path";function Kf(t,e,r,n){return t!==e?t:r?Sn.resolve(n,r):e}function la(t){let{rootDir:e,entryPoints:r,cachePath:n,configPath:o}=t,s=o?ne(o,{isExplicitPath:!0}):ne(e),i=Sn.join(Sn.resolve(e,St),Ct),a=r.length>0?r:s.entryPoints??[],c=Kf(n,i,s.cachePath,e),p={...s.ignoreDirs!==void 0&&{additionalIgnoreDirs:s.ignoreDirs},...s.extensions!==void 0&&{additionalExtensions:s.extensions}};return{rootDir:e,resolvedEntryPoints:a,resolvedCachePath:c,scanOptions:p,rawConfig:s}}var pa=u(()=>{"use strict";l();F();rn()});import Le from"fs";import Hf from"path";function fa(t){if(!Le.existsSync(t))return null;let e=Le.readFileSync(t,"utf-8");return R.deserialize(JSON.parse(e))}function Cn(t,e){let r=Hf.dirname(e);Le.existsSync(r)||Le.mkdirSync(r,{recursive:!0}),Le.writeFileSync(e,JSON.stringify(t.serialize(),null,2))}async function vn(t,e,r,n={silent:!1,...I(void 0)}){return G(t,e,r,n)}var ma=u(()=>{"use strict";l();F()});var ua,ga,da=u(()=>{"use strict";l();ua=`
41
+ `);process.exit(1)}console.log("No doc drift detected.")}var Mi=m(()=>{"use strict";l()});import Ai from"fs";function Li(t){Ai.existsSync(t)?(Ai.unlinkSync(t),console.log(`Cache cleared: ${t}`)):console.log(`No cache file present at ${t}`)}var Ri=m(()=>{"use strict";l()});async function on(t){let{graph:e,file:r,depth:n,withMeta:o}=t;r||(console.error("Error: --dependencies requires --file <path>"),process.exit(1));let s=Yt(e,r,n??1),i=o?s.map(a=>({...a,...V(e,a.path)})):s;console.log(JSON.stringify({file:r,dependencies:i},null,2))}var Oi=m(()=>{"use strict";l();E()});async function sn(t){let{graph:e,file:r,withMeta:n}=t;r||(console.error("Error: --dependents requires --file <path>"),process.exit(1));let o=ye(e,r),s=n?o.map(i=>({...i,...V(e,i.path)})):o;console.log(JSON.stringify({file:r,dependents:s},null,2))}var Gi=m(()=>{"use strict";l();E()});async function _i(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,rawConfig:s}=t;if(e.nodes.size===0){let c=R(r,n);e=await L(r,c,e,N(s))}let i=K(e.nodes,o!==void 0?{minOutDegree:o}:void 0),a=Array.from(i.values()).sort((c,p)=>p.outDegree-c.outDegree);console.log(JSON.stringify({features:a},null,2))}var ji=m(()=>{"use strict";l();E()});async function Wi(t){let{graph:e}=t,{rootDir:r,scanOptions:n,minOutDegree:o,rawConfig:s}=t;if(e.nodes.size===0){let c=R(r,n);e=await L(r,c,e,N(s))}let i=ge(e,o!==void 0?{minOutDegree:o}:void 0),a=Object.fromEntries(i.features);console.log(JSON.stringify({features:a,unassigned:i.unassigned},null,2))}var zi=m(()=>{"use strict";l();E()});async function an(t){let{graph:e,metric:r,complexityThreshold:n,limit:o}=t,s=n??10,i=Zt(e,{metric:r,threshold:s,limit:o});console.log(JSON.stringify({metric:r??"cognitiveComplexity",threshold:s,functions:i,count:i.length},null,2))}var $i=m(()=>{"use strict";l();E()});async function cn(t){let{graph:e,rootDir:r,scanOptions:n,minDuplicateLines:o,limit:s}=t,i=o??6,a=[...n.ignoreDirs??J,...n.additionalIgnoreDirs??[]],{groups:c}=await Kt(e,r,{minLines:i,limit:s,ignoreDirs:a});console.log(JSON.stringify({minLines:i,groups:c,count:c.length},null,2))}var Bi=m(()=>{"use strict";l();E()});async function Ui(t){let{graph:e,functionName:r,plain:n}=t;r||(console.error("Error: --find-symbol requires --function <name>"),process.exit(1));let o=ir(e,r);console.log(n?o.map(s=>s.path).join(`
42
+ `):JSON.stringify({name:r,matches:o,count:o.length},null,2))}var Ji=m(()=>{"use strict";l();E()});async function ln(t){let{graph:e,featureThreshold:r,rawConfig:n,plain:o}=t,s=r??n.coverageThreshold??80;if(!rr(e)){console.log(JSON.stringify({error:"No coverage data available. Set coverageReportPath in mokosh.config and rebuild the graph."},null,2));return}let i=[...e.nodes.values()].filter(a=>a.category!=="test"&&a.category!=="config").filter(a=>a.coveragePct!==void 0&&a.coveragePct<s).map(a=>({file:a.path,coveragePct:a.coveragePct}));console.log(o?i.map(a=>a.file).join(`
43
+ `):JSON.stringify({threshold:s,uncovered:i,count:i.length},null,2))}var Ki=m(()=>{"use strict";l();E()});import jf from"path";function zf(t){let e=jf.basename(t).toLowerCase();return Wf.some(r=>e.includes(r))}async function Hi(t){let{graph:e,rootDir:r,scanOptions:n,excludeTests:o}=t,s=R(r,n),i=e.findUnusedFiles(s);o&&(i=i.filter(a=>!zf(a))),console.log(JSON.stringify({unusedFiles:i},null,2))}var Wf,Vi=m(()=>{"use strict";l();E();Wf=[".test.",".spec.","-test.","-spec.",".stories."]});async function pn(t){let{graph:e,queryStr:r,mermaidOutput:n,slim:o}=t,s=e.serialize();if(r){let c=tt(r);s=et(s,c)}if(n){let c=D.deserialize(s);console.log(We.serialize(c));return}let i=e.findCycles();i.length>0&&(s.cycles=i);let a=Vt(e);console.log(JSON.stringify(o?{...er(s),languageCoverage:a}:{...s,languageCoverage:a},null,2))}var Qi=m(()=>{"use strict";l();E()});import $f from"fs";import fn from"path";function kt(t,e,r){let n=t;for(let o=0;o<6;o++){let s=fn.join(n,"templates",...e);if($f.existsSync(fn.join(s,r)))return s;let i=fn.dirname(n);if(i===n)break;n=i}throw new Error(`Could not locate mokosh templates/${e.join("/")}`)}var un=m(()=>{"use strict";l()});import Yi from"fs";import Xi from"path";function qi(t,e=process.cwd()){let r=kt(u,["config"],"mokosh.config.js"),n=Xi.join(r,"mokosh.config.js"),o=Xi.join(e,"mokosh.config.js");if(Yi.existsSync(o)&&!t){console.log("skipped mokosh.config.js (already exists, use --force to overwrite)");return}Yi.copyFileSync(n,o),console.log("wrote mokosh.config.js")}var Zi=m(()=>{"use strict";l();un()});import mn from"fs";import vt from"path";function ea(t,e=process.cwd()){let r=kt(u,["skill"],"SKILL.md");for(let n of Bf){let o=vt.join(r,n.templateFile),s=vt.join(e,...n.destPath),i=vt.join(...n.destPath);if(mn.existsSync(s)&&!t){console.log(`skipped ${i} (already exists, use --force to overwrite)`);continue}mn.mkdirSync(vt.dirname(s),{recursive:!0}),mn.copyFileSync(o,s),console.log(`wrote ${i}`)}}var Bf,ta=m(()=>{"use strict";l();un();Bf=[{templateFile:"SKILL.md",destPath:[".claude","skills","mokosh","SKILL.md"]},{templateFile:"mokosh.md",destPath:[".claude","commands","mokosh.md"]}]});async function gn(t){let{graph:e,plain:r}=t,n=new Map;for(let s of e.nodes.values())for(let i of s.tags)n.set(i.name,(n.get(i.name)??0)+1);let o=[...n.entries()].map(([s,i])=>({name:s,count:i})).sort((s,i)=>i.count-s.count);console.log(r?o.map(s=>s.name).join(`
44
+ `):JSON.stringify({tags:o,count:o.length},null,2))}var ra=m(()=>{"use strict";l()});async function na(t){let{graph:e,filterPaths:r,minOutDegree:n}=t,o=or(e,n!==void 0?{minOutDegree:n}:void 0);if(r?.length){let s=r.map(i=>o.get(i)).filter(Boolean);console.log(JSON.stringify({count:s.length,modules:s},null,2))}else{let s=Array.from(o.values());console.log(JSON.stringify({count:s.length,modules:s},null,2))}}var oa=m(()=>{"use strict";l();E()});async function sa(t){let{graph:e}=t,{rootDir:r,scanOptions:n,featureThreshold:o,plain:s,rawConfig:i}=t;s||console.log("Proposing test tags based on git diff...");let a=St(r);if(e.nodes.size===0){let p=R(r,n);e=await L(r,ee(p),e,N(i))}let c=Qr(e,a,{...o!==void 0&&{featureDetection:{minOutDegree:o}}});console.log(s?c.join(" "):JSON.stringify({proposedTags:c},null,2))}var ia=m(()=>{"use strict";l();E();Ct()});async function aa(t){let{graph:e,typeFilter:r}=t,n=ar(e);if(r){let o=cr(n,r);console.log(JSON.stringify(o,null,2))}else{let o=Array.from(n.types.values());console.log(JSON.stringify({count:o.length,types:o},null,2))}}var ca=m(()=>{"use strict";l();E()});function la(t,e){let r=t.getAffectedAcrossPackages(e);console.log(JSON.stringify({file:e,affected:r,count:r.length},null,2))}var pa=m(()=>{"use strict";l()});function fa(t){console.log(JSON.stringify(tr(t),null,2))}var ua=m(()=>{"use strict";l();E()});import dn from"path";function Uf(t,e,r,n){return t!==e?t:r?dn.resolve(n,r):e}function ma(t){let{rootDir:e,entryPoints:r,cachePath:n,configPath:o}=t,s=o?ne(o,{isExplicitPath:!0}):ne(e),i=dn.join(dn.resolve(e,xt),bt),a=r.length>0?r:s.entryPoints??[],c=Uf(n,i,s.cachePath,e),p={...s.ignoreDirs!==void 0&&{additionalIgnoreDirs:s.ignoreDirs},...s.extensions!==void 0&&{additionalExtensions:s.extensions}};return{rootDir:e,resolvedEntryPoints:a,resolvedCachePath:c,scanOptions:p,rawConfig:s}}var ga=m(()=>{"use strict";l();E();Xr()});import Re from"fs";import Jf from"path";function da(t){if(!Re.existsSync(t))return null;let e=Re.readFileSync(t,"utf-8");return D.deserialize(JSON.parse(e))}function hn(t,e){let r=Jf.dirname(e);Re.existsSync(r)||Re.mkdirSync(r,{recursive:!0}),Re.writeFileSync(e,JSON.stringify(t.serialize(),null,2))}async function yn(t,e,r,n={silent:!1,...N(void 0)}){return L(t,e,r,n)}var ha=m(()=>{"use strict";l();E()});var ya,xa,ba=m(()=>{"use strict";l();ya=`
45
45
  Usage: mokosh [options] <entry-point1> <entry-point2> ...
46
46
 
47
47
  Options:
@@ -128,7 +128,7 @@ Notes:
128
128
  server only loads JSON config (allowJs: false) for security. This is intentional.
129
129
  --workspace-packages/--workspace-affected require explicit opt-in (unlike MCP's analyze tool,
130
130
  which auto-detects a monorepo when entryPoints is empty); other commands remain single-package.
131
- `,ga=`
131
+ `,xa=`
132
132
  Query filter reference (--query "key:value,key:value,...")
133
133
  All keys are case-insensitive. Multiple keys are AND'd together.
134
134
 
@@ -251,5 +251,5 @@ COMMON PATTERNS
251
251
 
252
252
  Large TypeScript logic files:
253
253
  --query "type:typescript,category:logic,sort:size,limit:5"
254
- `});var ha,ya=u(()=>{"use strict";l();ha=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/});import Vf from"fs";function xa(t,e,r){let n=null,o=!1,s=!1,i=async()=>{if(o){s=!0;return}o=!0;try{await r()}finally{o=!1,s&&(s=!1,i())}};i();let a=null;try{a=Vf.watch(t,{recursive:!0},(c,p)=>{!p||ha.test(p)||(n&&clearTimeout(n),n=setTimeout(()=>{i()},e))})}catch(c){console.error(`Warning: unable to watch ${t}: ${c.message}`)}process.on("SIGINT",()=>{n&&clearTimeout(n),a?.close(),process.exit(0)})}var ba=u(()=>{"use strict";l();ya()});function Yf(t){t.help&&(console.log(ua),process.exit(0)),t.queryHelp&&(console.log(ga),process.exit(0)),t.initSkill&&(Yi(t.force),process.exit(0)),t.initConfig&&(Vi(t.force),process.exit(0)),t.clearCache&&(Ii(t.cachePath),process.exit(0))}async function Xf(t,e,r){if(!t.workspacePackages&&!t.workspaceAffected)return!1;t.watch&&(console.error("Error: --watch is not supported with --workspace-packages/--workspace-affected"),process.exit(1));let n=await ui(r,I(e.rawConfig));return t.workspacePackages?aa(n):(t.file||(console.error("Error: --workspace-affected requires --file <path>"),process.exit(1)),sa(n,t.file)),!0}function qf(t){return t.proposeTags||t.affectedTests||t.applyTags||t.callers||t.dependencies||t.dependents||t.affected||t.findUncovered||t.listTags||t.findComplexFunctions||t.findDuplicates||t.typeGraph||t.moduleResponsibility||t.callGraph||t.findSymbol||t.apiSurface}function Zf(t){let r=[{name:"--propose-tags",flag:t.proposeTags,handler:ta},{name:"--apply-tags",flag:t.applyTags,handler:vi},{name:"--affected-tests",flag:t.affectedTests,handler:xi},{name:"--detect-features",flag:t.detectFeatures,handler:Ri},{name:"--find-unused",flag:t.findUnused,handler:Bi},{name:"--check-cycles",flag:t.checkCycles,handler:cn},{name:"--check-doc-drift",flag:t.checkDocDrift,handler:ln},{name:"--find-uncovered",flag:t.findUncovered,handler:gn},{name:"--list-tags",flag:t.listTags,handler:bn},{name:"--callers",flag:t.callers,handler:an},{name:"--dependencies",flag:t.dependencies,handler:pn},{name:"--dependents",flag:t.dependents,handler:fn},{name:"--affected",flag:t.affected,handler:on},{name:"--find-complex-functions",flag:t.findComplexFunctions,handler:mn},{name:"--find-duplicates",flag:t.findDuplicates,handler:un},{name:"--type-graph",flag:t.typeGraph,handler:na},{name:"--module-responsibility",flag:t.moduleResponsibility,handler:Zi},{name:"--feature-graph",flag:t.featureGraph,handler:Oi},{name:"--call-graph",flag:t.callGraph,handler:wi},{name:"--find-symbol",flag:t.findSymbol,handler:Wi},{name:"--api-surface",flag:t.apiSurface,handler:Si}].filter(n=>n.flag);return r.length>1&&(console.error(`Error: conflicting flags: ${r.map(n=>n.name).join(", ")} (pass only one command flag)`),process.exit(1)),r[0]?.handler??dn}async function em(t,e,r,n,o,s,i){Qf.has(t)||(console.error("Error: --watch is only supported with the default output, --query, --callers, --dependencies, --dependents, --affected, --find-uncovered, --find-complex-functions, --find-duplicates, --check-cycles, --check-doc-drift, and --list-tags"),process.exit(1)),xa(r,300,async()=>{let a=await vn(r,n,e.graph,{silent:s,...I(i)});Cn(a,o),console.log(`--- rebuilt at ${new Date().toISOString()} ---`),await t({...e,graph:a})})}async function Sa(){let t=process.argv.slice(2),e=di(t);Yf(e);let r=la(e);At(r.rawConfig);let{rootDir:n,resolvedEntryPoints:o,resolvedCachePath:s,scanOptions:i}=r;if(await Xf(e,r,n))return;let a=qf(e),c=fa(s)??new R(new Map);(o.length>0||!a)&&(o.length===0&&!a&&!e.findUnused&&!e.detectFeatures&&!e.checkCycles&&!e.checkDocDrift&&(console.error("Error: No entry points provided"),process.exit(1)),c=await vn(n,o,c,{silent:e.silent,...I(r.rawConfig)}),Cn(c,s));let p={graph:c,rootDir:n,entryPoints:o.map(d=>d.replace(`${n}/`,"")),scanOptions:i,rawConfig:r.rawConfig,featureThreshold:e.featureThreshold,queryStr:e.query,mermaidOutput:e.mermaid,plain:e.plain,excludeTests:e.excludeTests,file:e.file,typeFilter:e.typeFilter,filterPaths:e.filterPaths,minOutDegree:e.minOutDegree,functionName:e.functionName,dryRun:e.dryRun,depth:e.depth,cached:e.cached,changedSymbols:e.changedSymbols,withMeta:e.withMeta,withEdgeDetail:e.withEdgeDetail,metric:e.metric,complexityThreshold:e.complexityThreshold,limit:e.limit,slim:e.slim,testsOnly:e.testsOnly,minDuplicateLines:e.minDuplicateLines},m=Zf(e);if(e.watch){await em(m,p,n,o,s,e.silent,r.rawConfig);return}await m(p)}var Qf,Ca=u(()=>{"use strict";l();F();hi();yi();bi();Ci();ki();Ei();Fi();Ti();Ni();Di();Mi();Ai();Li();Gi();_i();ji();zi();$i();Ui();Ji();Qi();Xi();qi();ea();ra();oa();ia();ca();pa();ma();da();ba();Qf=new Set([dn,an,pn,fn,on,gn,mn,un,cn,ln,bn])});var tm=wa(()=>{l();Ca();Sa().catch(t=>{console.error(t),process.exit(1)})});export default tm();
254
+ `});var Sa,Ca=m(()=>{"use strict";l();Sa=/(?:^|[/\\])(?:node_modules|\.git|dist|build|coverage)(?:[/\\]|$)/});import Kf from"fs";function ka(t,e,r){let n=null,o=!1,s=!1,i=async()=>{if(o){s=!0;return}o=!0;try{await r()}finally{o=!1,s&&(s=!1,i())}};i();let a=null;try{a=Kf.watch(t,{recursive:!0},(c,p)=>{!p||Sa.test(p)||(n&&clearTimeout(n),n=setTimeout(()=>{i()},e))})}catch(c){console.error(`Warning: unable to watch ${t}: ${c.message}`)}process.on("SIGINT",()=>{n&&clearTimeout(n),a?.close(),process.exit(0)})}var va=m(()=>{"use strict";l();Ca()});function Vf(t){t.help&&(console.log(ya),process.exit(0)),t.queryHelp&&(console.log(xa),process.exit(0)),t.initSkill&&(ea(t.force),process.exit(0)),t.initConfig&&(qi(t.force),process.exit(0)),t.clearCache&&(Li(t.cachePath),process.exit(0))}async function Qf(t,e,r){if(!t.workspacePackages&&!t.workspaceAffected)return!1;t.watch&&(console.error("Error: --watch is not supported with --workspace-packages/--workspace-affected"),process.exit(1));let n=await yi(r,N(e.rawConfig));return t.workspacePackages?fa(n):(t.file||(console.error("Error: --workspace-affected requires --file <path>"),process.exit(1)),la(n,t.file)),!0}function Yf(t){return t.proposeTags||t.affectedTests||t.applyTags||t.callers||t.dependencies||t.dependents||t.affected||t.findUncovered||t.listTags||t.findComplexFunctions||t.findDuplicates||t.typeGraph||t.moduleResponsibility||t.callGraph||t.findSymbol||t.apiSurface}function Xf(t){let r=[{name:"--propose-tags",flag:t.proposeTags,handler:sa},{name:"--apply-tags",flag:t.applyTags,handler:Ti},{name:"--affected-tests",flag:t.affectedTests,handler:ki},{name:"--detect-features",flag:t.detectFeatures,handler:_i},{name:"--find-unused",flag:t.findUnused,handler:Hi},{name:"--check-cycles",flag:t.checkCycles,handler:rn},{name:"--check-doc-drift",flag:t.checkDocDrift,handler:nn},{name:"--find-uncovered",flag:t.findUncovered,handler:ln},{name:"--list-tags",flag:t.listTags,handler:gn},{name:"--callers",flag:t.callers,handler:tn},{name:"--dependencies",flag:t.dependencies,handler:on},{name:"--dependents",flag:t.dependents,handler:sn},{name:"--affected",flag:t.affected,handler:Zr},{name:"--find-complex-functions",flag:t.findComplexFunctions,handler:an},{name:"--find-duplicates",flag:t.findDuplicates,handler:cn},{name:"--type-graph",flag:t.typeGraph,handler:aa},{name:"--module-responsibility",flag:t.moduleResponsibility,handler:na},{name:"--feature-graph",flag:t.featureGraph,handler:Wi},{name:"--call-graph",flag:t.callGraph,handler:Ni},{name:"--find-symbol",flag:t.findSymbol,handler:Ui},{name:"--api-surface",flag:t.apiSurface,handler:wi}].filter(n=>n.flag);return r.length>1&&(console.error(`Error: conflicting flags: ${r.map(n=>n.name).join(", ")} (pass only one command flag)`),process.exit(1)),r[0]?.handler??pn}async function qf(t,e,r,n,o,s,i){Hf.has(t)||(console.error("Error: --watch is only supported with the default output, --query, --callers, --dependencies, --dependents, --affected, --find-uncovered, --find-complex-functions, --find-duplicates, --check-cycles, --check-doc-drift, and --list-tags"),process.exit(1)),ka(r,300,async()=>{let a=await yn(r,n,e.graph,{silent:s,...N(i)});hn(a,o),console.log(`--- rebuilt at ${new Date().toISOString()} ---`),await t({...e,graph:a})})}async function wa(){let t=process.argv.slice(2),e=bi(t);Vf(e);let r=ma(e);Pt(r.rawConfig);let{rootDir:n,resolvedEntryPoints:o,resolvedCachePath:s,scanOptions:i}=r;if(await Qf(e,r,n))return;let a=Yf(e),c=da(s)??new D(new Map);(o.length>0||!a)&&(o.length===0&&!a&&!e.findUnused&&!e.detectFeatures&&!e.checkCycles&&!e.checkDocDrift&&(console.error("Error: No entry points provided"),process.exit(1)),c=await yn(n,o,c,{silent:e.silent,...N(r.rawConfig)}),hn(c,s));let p={graph:c,rootDir:n,entryPoints:o.map(d=>d.replace(`${n}/`,"")),scanOptions:i,rawConfig:r.rawConfig,featureThreshold:e.featureThreshold,queryStr:e.query,mermaidOutput:e.mermaid,plain:e.plain,excludeTests:e.excludeTests,file:e.file,typeFilter:e.typeFilter,filterPaths:e.filterPaths,minOutDegree:e.minOutDegree,functionName:e.functionName,dryRun:e.dryRun,depth:e.depth,cached:e.cached,changedSymbols:e.changedSymbols,withMeta:e.withMeta,withEdgeDetail:e.withEdgeDetail,metric:e.metric,complexityThreshold:e.complexityThreshold,limit:e.limit,slim:e.slim,testsOnly:e.testsOnly,minDuplicateLines:e.minDuplicateLines},f=Xf(e);if(e.watch){await qf(f,p,n,o,s,e.silent,r.rawConfig);return}await f(p)}var Hf,Ea=m(()=>{"use strict";l();E();Si();Ci();vi();Ei();Fi();Pi();Ii();Di();Mi();Ri();Oi();Gi();ji();zi();$i();Bi();Ji();Ki();Vi();Qi();Zi();ta();ra();oa();ia();ca();pa();ua();ga();ha();ba();va();Hf=new Set([pn,tn,on,sn,Zr,ln,an,cn,rn,nn,gn])});var Zf=Ta(()=>{l();Ea();wa().catch(t=>{console.error(t),process.exit(1)})});export default Zf();
255
255
  //# sourceMappingURL=cli.mjs.map