@omfalos/mokosh 0.4.3 → 0.5.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.
@@ -1,3 +1,7 @@
1
- var Kt=(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')});import rt from"path";function M(t){switch(rt.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 C(t){let e=rt.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}import _t from"coffeescript";function v(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function L(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,i=r.exec(t);for(;i!==null;)i[1]&&e.add(i[1]),i=r.exec(t);return e}function A(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function st(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return v(t.value)}}function T(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function jt(t,e){let r=st(e.source);return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:C(r),type:"static"}:null}function Vt(t,e){let r=e.variable?.base?.value==="require",i=st(e.args?.[0]?.base);return!r||!i?null:{fromPath:t,toPath:"",rawSpecifier:i,isStyle:C(i),type:"require"}}function it(t,e){if(e)return[{name:e}];let r=t.value;if(r?.constructor?.name==="Class"){let s=T(r.variable);return s?[{name:s}]:[]}if(r?.base?.constructor?.name==="Obj"&&Array.isArray(r.base.properties))return r.base.properties.map(s=>T(s.variable)??T(s)).filter(s=>!!s).map(s=>({name:s}));let i=T(r);return i?[{name:i}]:[]}function $t(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=T(t.variable)??T(t.variable?.base);return e?[{name:e}]:[]}function zt(t,e,r,i){let s=e.constructor?.name;if(s==="ImportDeclaration"){let n=jt(t,e);n&&r.push(n)}else if(s==="Call"){let n=Vt(t,e);n&&r.push(n)}else if(s==="Assign"){let n=T(e.variable?.base),o=e.variable?.properties?.[0]?.name?.value;n==="module"&&o==="exports"?i.push(...it(e,void 0)):n==="exports"&&typeof o=="string"&&i.push(...it(e,o))}else s==="ExportNamedDeclaration"&&e.clause?i.push(...$t(e.clause)):s==="ExportDefaultDeclaration"&&i.push({name:"default"})}function z(t,e,r,i){if(!(!e||typeof e!="object")){zt(t,e,r,i);for(let s in e){if(s==="locationData")continue;let n=e[s];if(!(!n||typeof n!="object"))if(Array.isArray(n))for(let o of n)z(t,o,r,i);else z(t,n,r,i)}}}function nt(t,e){let r=L(e),i=A(t,r),s=[],n=[];try{z(t,_t.nodes(e),s,n)}catch{}let o=new Set,a=n.filter(c=>o.has(c.name)?!1:(o.add(c.name),!0));return{imports:s,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:i}}import{AstBuilder as qt,GherkinClassicTokenMatcher as Jt,Parser as Gt}from"@cucumber/gherkin";import{IdGenerator as Qt}from"@cucumber/messages";var ot=new Map;function B(t,e){ot.set(t,e)}function at(t){return ot.get(t)}var Ut=Qt.uuid();function q(t,e){let r=new Set;try{let i=new qt(Ut),s=new Jt,o=new Gt(i,s).parse(e);o.feature&&(o.feature.tags.forEach(a=>{r.add(a.name.startsWith("@")?a.name.slice(1):a.name)}),o.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(m=>{r.add(m.name.startsWith("@")?m.name.slice(1):m.name)})})),a.rule&&a.rule.children.forEach(c=>{c.scenario&&c.scenario.tags.forEach(m=>{r.add(m.name.startsWith("@")?m.name.slice(1):m.name)})})}))}catch(i){console.warn(`[GherkinParser] Failed to parse ${t}:`,i)}return{imports:[],exports:[],tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:"test"}}B("gherkin",q);import te from"path";import{parser as ee}from"@lezer/go";function I(t){let e=[],r=t.firstChild;for(;r;)e.push(r),r=r.nextSibling;return e}function W(t,e){let r=1;for(let i=0;i<e&&i<t.length;i++)t[i]===`
2
- `&&r++;return r}function Zt(t,e){let r=1;function i(s){switch(s.type.name){case"IfStatement":case"ForStatement":r++;break;case"Case":{s.firstChild?.type.name==="case"&&r++;break}case"LogicOp":{let o=e.slice(s.from,s.to);(o==="&&"||o==="||")&&r++;break}}let n=s.firstChild;for(;n;)i(n),n=n.nextSibling}return i(t),r}function lt(t,e,r,i){let s=r?1:1+e,n=I(t),o=r?e:e+1,a=n[1];a&&a.type.name!=="Block"&&(s+=R(a,o,!1,i));let c=n.find(p=>p.type.name==="Block");c&&(s+=R(c,o,!1,i));let m=n.findIndex(p=>p.type.name==="else");if(m>=0){let p=n[m+1];p?.type.name==="IfStatement"?s+=lt(p,e,!0,i):p&&(s+=1+R(p,e+1,!1,i))}return s}function ct(t,e,r){let i=1+e,s=t.firstChild;for(;s;)i+=R(s,e+1,!1,r),s=s.nextSibling;return i}function Xt(t,e,r){let i=0,s=t.firstChild;for(;s;)i+=R(s,e,!1,r),s=s.nextSibling;return i}function Ht(t,e){let r=e.slice(t.from,t.to);return r==="&&"||r==="||"}function R(t,e,r,i){let s=t.type.name;if(s==="IfStatement")return lt(t,e,r,i);if(s==="ForStatement"||s==="SwitchStatement"||s==="SelectStatement")return ct(t,e,i);let n=s==="LogicOp"&&Ht(t,i)?1:0;return e>0&&s==="FunctionLiteral"?n+ct(t,e,i):n+Xt(t,e,i)}function Yt(t,e){return R(t,0,!1,e)}function j(t,e){return{complexity:Zt(t,e),cognitiveComplexity:Yt(t,e)}}function J(t,e){let i=t.getChild("Parameters")?.getChild("Parameter"),s=i?.getChild("TypeName")??i?.getChild("PointerType")?.getChild("TypeName");return s?e.slice(s.from,s.to):void 0}function mt(t,e){let r=[],i=t.cursor();do if(i.name==="FunctionDecl"){let s=i.node.getChild("DefName");if(s){let n=e.slice(s.from,s.to),{complexity:o,cognitiveComplexity:a}=j(i.node,e);r.push({name:n,line:W(e,i.from),complexity:o,cognitiveComplexity:a})}}else if(i.name==="MethodDecl"){let s=i.node.getChild("FieldName");if(s){let n=e.slice(s.from,s.to),o=J(i.node,e),a=o?`${o}.${n}`:n,{complexity:c,cognitiveComplexity:m}=j(i.node,e);r.push({name:a,line:W(e,i.from),complexity:c,cognitiveComplexity:m})}}while(i.next());return r}var re=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,ie=/^\/\/go:build\s+(.+)$/,se=/^\/\/\s*\+build\s+(.+)$/;function ft(t,e){let r=[],i=new Map,s=new Set,n=new Set,o=new Map,a=ee.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let S=e.slice(c.from,c.to),E=S.match(re);E?.[1]&&s.add(E[1]);let P=S.match(ie);P&&pt(P[1],n);let D=S.match(se);D&&pt(D[1],n);break}case"ImportSpec":{let S=c.node.getChild("String");if(S){let P=e.slice(S.from,S.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:P,isExternal:!0,isStyle:!1,type:"static"});let D=c.node.getChild("DefName"),_=D?e.slice(D.from,D.to):P.split("/").pop();_&&_!=="_"&&_!=="."&&o.set(_,P)}break}case"FunctionDecl":case"MethodDecl":case"TypeDecl":case"VarDecl":case"ConstDecl":{let S=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(S){let E=e.slice(S.from,S.to);E!=="_"&&/^[A-Z]/.test(E)&&!i.has(E)&&i.set(E,{name:E})}break}}while(c.next());let m=r.some(S=>S.rawSpecifier==="testing"),p=te.basename(t).endsWith("_test.go")||s.has("test")||m?"test":"logic",f=new Set([...s,...n]),{complexity:x,cognitiveComplexity:g}=j(a.topNode,e),N=mt(a,e),b=p==="test"?[]:ne(a,e,o);return{imports:r,exports:Array.from(i.values()),tags:Array.from(f).map(S=>({name:S,kind:"comment-marker"})),category:p,rawCallEdges:b,complexity:x,cognitiveComplexity:g,...N.length>0?{functions:N}:{}}}function ne(t,e,r){let i=[];function s(o,a){if(o.type.name==="CallExpr"){let m=o.firstChild;if(m?.type.name==="SelectorExpr"){let p=m.firstChild,f=m.getChild("FieldName");if(p?.type.name==="VariableName"&&f){let x=e.slice(p.from,p.to),g=r.get(x);if(g){let N=e.slice(f.from,f.to);i.push({from:a,to:N,toSpecifier:g})}}}}let c=o.firstChild;for(;c;)s(c,a),c=c.nextSibling}let n=t.cursor();do if(n.name==="FunctionDecl"){let o=n.node.getChild("DefName"),a=n.node.getChild("Block");if(o&&a){let c=e.slice(o.from,o.to);/^[A-Z]/.test(c)&&s(a,c)}}else if(n.name==="MethodDecl"){let o=n.node.getChild("FieldName"),a=n.node.getChild("Block");if(o&&a){let c=e.slice(o.from,o.to),m=J(n.node,e);s(a,m?`${m}.${c}`:c)}}while(n.next());return i}function pt(t,e){for(let r of t.split(/[\s,&|!()]+/)){let i=r.trim();i&&i!=="ignore"&&e.add(i)}}import oe from"livescript";function k(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function ae(t){if(!t)return[];if(t.constructor?.name==="Class"){let r=k(t.title);return r?[{name:r}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(r=>k(r.key)??k(r.val)).filter(r=>!!r).map(r=>({name:r}));let e=k(t);return e?[{name:e}]:[]}function ce(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let r=t.left,i=k(r.head),n=r.tails?.[0]?.key?.name;if(i==="module"&&n==="exports")return ae(t.right);if(i==="exports"&&typeof n=="string")return[{name:n}];if(r.head?.verb==="out"&&typeof n=="string")return[{name:n}]}if(e==="Import"&&t.left?.verb==="out"){let r=t.right;if(r?.constructor?.name==="Obj"&&Array.isArray(r.items))return r.items.map(i=>k(i.val)??k(i.key)).filter(i=>!!i).map(i=>({name:i}))}return[]}var le=new Set(["first_line","first_column","last_line","last_column","line","column"]);function me(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let i=t.right?.value;if(typeof i=="string"){let s=v(i);return{fromPath:e,toPath:"",rawSpecifier:s,isStyle:C(s),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let i=t.tails?.[0];if(i?.constructor?.name==="Call"||i?.type==="Call"){let s=i.args?.[0]?.value;if(typeof s=="string"){let n=v(s);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:C(n),type:"require"}}}}return null}function G(t,e,r){if(!t||typeof t!="object")return[];let i=[],s=me(t,e);s&&i.push(s),r.push(...ce(t));for(let n in t){if(le.has(n))continue;let o=t[n];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let a of o)i.push(...G(a,e,r));else i.push(...G(o,e,r))}return i}function ut(t,e){let r=L(e),i=A(t,r),s=[],n=[];try{s=G(oe.ast(e),t,n)}catch{}let o=new Set,a=n.filter(c=>o.has(c.name)?!1:(o.add(c.name),!0));return{imports:s,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:i}}import pe from"luaparse";function fe(t,e){let r=[];function i(s){if(!(!s||typeof s!="object")){if((s.type==="CallExpression"||s.type==="StringCallExpression")&&s.base?.type==="Identifier"&&s.base?.name==="require"){let n;if(s.type==="CallExpression"){let o=s.arguments?.[0];o?.type==="StringLiteral"&&(n=v(o.raw))}else if(s.type==="StringCallExpression"){let o=s.argument;o?.type==="StringLiteral"&&(n=v(o.raw))}n&&r.push({fromPath:e,toPath:"",rawSpecifier:n,isStyle:C(n),type:"require"})}for(let n in s){if(n==="loc")continue;let o=s[n];if(o&&typeof o=="object")if(Array.isArray(o))for(let a of o)i(a);else i(o)}}}return i(t),r}function ue(t){let e=new Set;for(let r of t)r.type==="LocalStatement"&&r.variables.forEach((i,s)=>{r.init[s]?.type==="TableConstructorExpression"&&e.add(i.name)});return e}function ge(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let r=e.arguments[0];if(r?.type!=="TableConstructorExpression")return[];let i=[];for(let s of r.fields)s.type==="TableKeyString"&&i.push({name:s.key.name});return i}function de(t){let e=t.body,r=ue(e),i=ge(e);for(let n of e)if(n.type==="FunctionDeclaration")n.identifier?.type==="MemberExpression"?n.identifier.base.type==="Identifier"&&r.has(n.identifier.base.name)&&i.push({name:n.identifier.identifier.name}):n.identifier?.type==="Identifier"&&!n.isLocal&&i.push({name:n.identifier.name});else if(n.type==="AssignmentStatement")for(let o of n.variables)o.type==="MemberExpression"&&o.base.type==="Identifier"&&r.has(o.base.name)&&i.push({name:o.identifier.name});let s=new Set;return i.filter(n=>s.has(n.name)?!1:(s.add(n.name),!0))}function gt(t,e){let r=L(e),i=A(t,r),s=[],n=[];try{let o=pe.parse(e);s=fe(o,t),n=de(o)}catch{}return{imports:s,exports:n,tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:i}}var ye=["http://","https://","mailto:","//"],xe="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",he=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${xe})\\b`,"g"),dt;async function Se(){return dt??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),dt}function be(t){let e=t.trim();return e.length===0||e.startsWith("#")||ye.some(r=>e.startsWith(r))}function Ce(t,e){let r=t.match(he);return r?r.map(i=>({fromPath:e,toPath:"",rawSpecifier:i,isStyle:!1,type:"static"})):[]}function yt(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!be(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(...Ce(t.value,e)),Array.isArray(t.children))for(let i of t.children)yt(i,e,r)}async function xt(t,e){let i=(await Se()).parse(e),s=[];yt(i,t,s);let n=new Set;return{imports:s.filter(a=>n.has(a.rawSpecifier)?!1:(n.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}import Ie from"path";import{parser as ke}from"@lezer/python";function Ne(t){let e=1;function r(i){switch(i.type.name){case"IfStatement":{e+=I(i).filter(n=>n.type.name==="if"||n.type.name==="elif").length;break}case"TryStatement":{e+=I(i).filter(n=>n.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let s=i.firstChild;for(;s;)r(s),s=s.nextSibling}return r(t),e}function Ee(t,e){let r=0,i=I(t),s=0,n=0;for(;n<i.length;){let o=i[n];if(o?.type.name==="if"||o?.type.name==="elif"){let a=s>0;r+=a?1:1+e;let c=a?e:e+1,m=i[n+1],p=i[n+2];m&&(r+=w(m,c)),p&&(r+=w(p,c)),s++,n+=3}else if(o?.type.name==="else"){r+=1;let a=i[n+1];a&&(r+=w(a,e+1)),n+=2}else n++}return r}function we(t,e){let r=0,i=I(t),s=0;for(;s<i.length;){let n=i[s];if(n?.type.name==="except"){for(r+=1+e,s++;s<i.length&&i[s]?.type.name!=="Body";)r+=w(i[s],e),s++;s<i.length&&(r+=w(i[s],e),s++)}else n?.type.name==="Body"&&(r+=w(n,e)),s++}return r}function ht(t,e){let r=1+e,i=t.firstChild;for(;i;)r+=w(i,e+1),i=i.nextSibling;return r}function ve(t,e){let r=0,i=t.firstChild;for(;i;)r+=w(i,e),i=i.nextSibling;return r}function w(t,e){let r=t.type.name;if(r==="IfStatement")return Ee(t,e);if(r==="TryStatement")return we(t,e);if(r==="ForStatement"||r==="WhileStatement")return ht(t,e);let i=r==="ConditionalExpression"||r==="and"||r==="or"?1:0;return e>0&&(r==="FunctionDefinition"||r==="LambdaExpression")?i+ht(t,e):i+ve(t,e)}function Te(t){return w(t,0)}function Q(t){return{complexity:Ne(t),cognitiveComplexity:Te(t)}}function St(t,e){let r=[];function i(o,a){let{complexity:c,cognitiveComplexity:m}=Q(o);r.push({name:a,line:W(e,o.from),complexity:c,cognitiveComplexity:m})}function s(o){let a=o.firstChild;for(;a;)n(a),a=a.nextSibling}function n(o){if(o.type.name==="ClassDefinition"){let a=o.getChild("VariableName"),c=a?e.slice(a.from,a.to):void 0,m=o.getChild("Body");if(m){let p=m.firstChild;for(;p;){if(p.type.name==="FunctionDefinition"){let f=p.getChild("VariableName"),x=f?e.slice(f.from,f.to):void 0;x&&i(p,c?`${c}.${x}`:x),s(p)}else n(p);p=p.nextSibling}}return}if(o.type.name==="FunctionDefinition"){let a=o.getChild("VariableName");a&&i(o,e.slice(a.from,a.to)),s(o);return}s(o)}return n(t.topNode),r}var Fe=new Set(["pytest","unittest","nose","hypothesis"]);function bt(t,e){let r=[],i=[],s=new Set,n=Ie.basename(t).toLowerCase(),o=ke.parse(e),a=o.cursor();do switch(a.name){case"Comment":{let g=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);g?.[1]&&s.add(g[1]);break}case"ImportStatement":{for(let g of Pe(a.node,e,t))r.push(g);break}case"FunctionDefinition":case"ClassDefinition":{let g=a.node.parent;if(g?.name==="Script"||g?.name==="DecoratedStatement"&&g.parent?.name==="Script"){let b=a.node.getChild("VariableName");b&&i.push({name:e.slice(b.from,b.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let g=a.node.firstChild;g?.name==="VariableName"&&i.push({name:e.slice(g.from,g.to)})}break}}while(a.next());let c=Be(n,r,s);c==="test"&&s.add("test");let{complexity:m,cognitiveComplexity:p}=Q(o.topNode),f=St(o,e),x=c==="test"?[]:Me(o,e);return{imports:r,exports:i,tags:Array.from(s).map(g=>({name:g,kind:"comment-marker"})),category:c,rawCallEdges:x,complexity:m,cognitiveComplexity:p,...f.length>0?{functions:f}:{}}}function Pe(t,e,r){let i=t.firstChild;return i?i.name==="from"?De(t,e,r):Le(t,e,r):[]}function De(t,e,r){let i=t.firstChild;if(!i)return[];let s=i.nextSibling;for(;s&&s.name!=="import";)s=s.nextSibling;if(!s)return[];let n=e.slice(i.to,s.from).trim(),o=Ae(s.nextSibling,e);if(!o.length)return[];let a=0;for(;a<n.length&&n[a]===".";)a++;let c=n.slice(a);if(a===0)return[O(r,n,o,!0)];let m=a===1?"./":"../".repeat(a-1);return c?[O(r,m+c.replace(/\./g,"/"),o,!1)]:o[0]==="*"?[O(r,m.slice(0,-1),["*"],!1)]:o.map(p=>O(r,m+p,[p],!1))}function Le(t,e,r){let i=[],s=t.firstChild?.nextSibling??null;for(;s;){if(s.name==="VariableName"){let n=e.slice(s.from,s.to);for(;s.nextSibling?.name==="."&&s.nextSibling.nextSibling?.name==="VariableName";)s=s.nextSibling.nextSibling,n+=`.${e.slice(s.from,s.to)}`;s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling),i.push(O(r,n,["*"],!0))}s=s.nextSibling}return i}function Ae(t,e){let r=[],i=t;for(;i;)i.name==="*"?r.push("*"):i.name==="VariableName"&&(r.push(e.slice(i.from,i.to)),i.nextSibling?.name==="as"&&(i=i.nextSibling.nextSibling??i.nextSibling)),i=i.nextSibling;return r}function Re(t,e){let r=new Map,i=t.cursor();do{if(i.name!=="ImportStatement")continue;let n=i.node.firstChild;if(n?.type.name!=="from")continue;let o=n.nextSibling;for(;o&&o.type.name!=="import";)o=o.nextSibling;if(!o)continue;let a=e.slice(n.to,o.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let m=a.slice(c),p=c<=1?"./":"../".repeat(c-1),f=o.nextSibling;for(;f;){if(f.type.name==="VariableName"){let x=e.slice(f.from,f.to),g=x;if(f.nextSibling?.type.name==="as"){let b=f.nextSibling.nextSibling;b?.type.name==="VariableName"&&(g=e.slice(b.from,b.to),f=b)}let N=c===0?a:m?p+m.replace(/\./g,"/"):p+x;r.set(g,N)}f=f.nextSibling}}while(i.next());return r}function Me(t,e){let r=Re(t,e),i=[];function s(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let p=a.firstChild,f=e.slice(p.from,p.to),x=r.get(f);x&&i.push({from:c,to:f,toSpecifier:x})}let m=a.firstChild;for(;m;)s(m,c),m=m.nextSibling}function n(a){let c=a.firstChild;for(;c;)o(c),c=c.nextSibling}function o(a){if(a.type.name==="ClassDefinition"){let c=a.getChild("VariableName"),m=c?e.slice(c.from,c.to):void 0,p=a.getChild("Body");if(p){let f=p.firstChild;for(;f;){if(f.type.name==="FunctionDefinition"){let x=f.getChild("VariableName"),g=x?e.slice(x.from,x.to):void 0;g&&s(f,m?`${m}.${g}`:g)}else o(f);f=f.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&s(a,e.slice(c.from,c.to));return}n(a)}return o(t.topNode),i}function O(t,e,r,i){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:i,type:"static",symbols:r.length>0?r:void 0}}function Be(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(i=>Fe.has(i.rawSpecifier))?"test":"logic"}import vt from"path";import l from"typescript";var We=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],Oe=[];function Ct(t){return[...We,...Oe].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}var Ke=[".test.",".spec.","-test.","-spec."],_e=[];function U(){return[...Ke,..._e]}var je=["jest","vitest","playwright","cypress","@testing-library/"],Ve=[];function Z(){return[...je,...Ve]}var $e=.8;function X(){return $e}import u from"typescript";function ze(t){let e=1;function r(i){switch(i.kind){case u.SyntaxKind.IfStatement:case u.SyntaxKind.ConditionalExpression:case u.SyntaxKind.ForStatement:case u.SyntaxKind.ForInStatement:case u.SyntaxKind.ForOfStatement:case u.SyntaxKind.WhileStatement:case u.SyntaxKind.DoStatement:case u.SyntaxKind.CatchClause:case u.SyntaxKind.CaseClause:e++;break;case u.SyntaxKind.BinaryExpression:{let s=i.operatorToken.kind;(s===u.SyntaxKind.AmpersandAmpersandToken||s===u.SyntaxKind.BarBarToken||s===u.SyntaxKind.QuestionQuestionToken)&&e++;break}}u.forEachChild(i,r)}return r(t),e}function Et(t,e,r){let i=r?1:1+e,s=r?e:e+1;return i+=F(t.expression,s,!1),i+=F(t.thenStatement,s,!1),t.elseStatement&&(u.isIfStatement(t.elseStatement)?i+=Et(t.elseStatement,e,!0):i+=1+F(t.elseStatement,e+1,!1)),i}function Nt(t,e){let r=1+e;return u.forEachChild(t,i=>{r+=F(i,e+1,!1)}),r}function qe(t,e){let r=1+e;return u.forEachChild(t,i=>{r+=F(i,e,!1)}),r}function Je(t,e){let r=0;return u.forEachChild(t,i=>{r+=F(i,e,!1)}),r}function Ge(t){let e=t.operatorToken.kind;return e===u.SyntaxKind.AmpersandAmpersandToken||e===u.SyntaxKind.BarBarToken||e===u.SyntaxKind.QuestionQuestionToken}function F(t,e,r){if(u.isIfStatement(t))return Et(t,e,r);if(u.isForStatement(t)||u.isForInStatement(t)||u.isForOfStatement(t)||u.isWhileStatement(t)||u.isDoStatement(t)||u.isSwitchStatement(t))return Nt(t,e);if(u.isCatchClause(t))return qe(t,e);let i=0;return u.isConditionalExpression(t)&&(i+=1),u.isBinaryExpression(t)&&Ge(t)&&(i+=1),e>0&&(u.isFunctionDeclaration(t)||u.isFunctionExpression(t)||u.isArrowFunction(t))?i+Nt(t,e):i+Je(t,e)}function Qe(t){return F(t,0,!1)}function H(t){return{complexity:ze(t),cognitiveComplexity:Qe(t)}}import h from"typescript";var Y=new Set(["test","describe","it"]);function wt(t,e){Ue(t,e),Xe(t,e),He(t,e),Ye(t,e)}function Ue(t,e){if((h.isFunctionDeclaration(t)||h.isVariableDeclaration(t))&&t.name&&h.isIdentifier(t.name)&&Ze(t)){let r;if(h.isFunctionDeclaration(t))r="function";else{let i=t.initializer;r=i&&(h.isArrowFunction(i)||h.isFunctionExpression(i))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function Ze(t){if(h.isFunctionDeclaration(t))return h.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&h.isSourceFile(e.parent)}function Xe(t,e){if(!h.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let i of r)e.tags.add({name:i.substring(1),kind:"comment-marker"})}function He(t,e){if(!h.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,i=t.getFullText(),s=r.exec(i);for(;s!==null;)s[1]&&e.tags.add({name:s[1],kind:"comment-marker"}),s=r.exec(i)}function Ye(t,e){if(h.isCallExpression(t)&&tr(t.expression))for(let r of t.arguments)h.isObjectLiteralExpression(r)&&er(r,e)}function tr(t){return h.isIdentifier(t)?Y.has(t.text):!!(h.isPropertyAccessExpression(t)&&(Y.has(t.name.text)||h.isIdentifier(t.expression)&&Y.has(t.expression.text)))}function er(t,e){for(let r of t.properties){if(!h.isPropertyAssignment(r)||!h.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:i}=r,s=h.isArrayLiteralExpression(i)?i.elements.filter(h.isStringLiteral):r.name.text==="tag"&&h.isStringLiteral(i)?[i]:[];for(let n of s)e.tags.add({name:n.text.replace(/^@/,""),kind:"comment-marker"})}}function tt(t,e,r){let i=[],s=new Map,n=new Set,o=l.createSourceFile(t,e,l.ScriptTarget.Latest,!0,r==="typescript"?l.ScriptKind.TSX:l.ScriptKind.JSX),a={filePath:t,imports:i,exports:s,tags:n,rawCallEdges:[],sourceFile:o,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=b=>{nr(b,a),l.forEachChild(b,c)};c(o);let m=yr(t,a);(m==="test"||m==="barrel")&&n.add({name:m,kind:"comment-marker"}),m!=="test"&&xr(a,o);let p=o.statements[0],f=p?It(p):void 0,{complexity:x,cognitiveComplexity:g}=H(o),N=rr(o);return{imports:i,exports:Array.from(s.values()),tags:Array.from(n),category:m,rawCallEdges:a.rawCallEdges??[],complexity:x,cognitiveComplexity:g,...N.length>0?{functions:N}:{},...f!==void 0?{description:f}:{}}}function rr(t){let e=[],r=(s,n)=>{let{complexity:o,cognitiveComplexity:a}=H(n),c=t.getLineAndCharacterOfPosition(n.getStart(t)).line+1;e.push({name:s,line:c,complexity:o,cognitiveComplexity:a})},i=(s,n)=>{if(l.isFunctionDeclaration(s)&&s.name&&s.body?r(s.name.text,s):l.isVariableDeclaration(s)&&l.isIdentifier(s.name)&&s.initializer&&(l.isArrowFunction(s.initializer)||l.isFunctionExpression(s.initializer))?r(s.name.text,s.initializer):n&&l.isMethodDeclaration(s)&&l.isIdentifier(s.name)&&s.body?r(`${n}.${s.name.text}`,s):n&&l.isConstructorDeclaration(s)&&s.body?r(`${n}.constructor`,s):n&&l.isGetAccessorDeclaration(s)&&l.isIdentifier(s.name)&&s.body?r(`${n}.get ${s.name.text}`,s):n&&l.isSetAccessorDeclaration(s)&&l.isIdentifier(s.name)&&s.body&&r(`${n}.set ${s.name.text}`,s),l.isClassDeclaration(s)&&s.name){let o=s.name.text;l.forEachChild(s,a=>i(a,o));return}l.forEachChild(s,o=>i(o,n))};return i(t,void 0),e}function Tt(t,e,r,i){let s={name:t},n=It(r);n!==void 0&&(s.doc=n);let o=ir(e);o!==void 0&&(s.flags=o);let a=sr(e,i);return a!==void 0&&(s.signature=a),s}function It(t){let e=l.getJSDocCommentsAndTags(t);for(let r of e)if(l.isJSDoc(r)&&r.comment)return l.getTextOfJSDocComment(r.comment)||void 0}function ir(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=l.getJSDocTags(t).map(i=>i.tagName.text).filter(i=>e.has(i));return r.length>0?r:void 0}function sr(t,e){let r=l.createPrinter({removeComments:!0}),i=s=>r.printNode(l.EmitHint.Unspecified,s,e);if(l.isFunctionDeclaration(t)||l.isMethodDeclaration(t)){let s=t.parameters.map(i).join(", "),n=t.type?i(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${s}) => ${n}`}if(l.isVariableDeclaration(t)){if(t.type)return i(t.type);if(t.initializer&&(l.isArrowFunction(t.initializer)||l.isFunctionExpression(t.initializer))){let s=t.initializer,n=s.parameters.map(i).join(", "),o=s.type?i(s.type):"unknown";return`(${n}) => ${o}`}return}if(l.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(l.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(l.isTypeAliasDeclaration(t))return i(t.type);if(l.isEnumDeclaration(t))return`enum ${t.name.text}`}function nr(t,e){or(t,e),ar(t,e),lr(t,e),mr(t,e),dr(t,e),wt(t,e)}function or(t,e){if(!l.isSourceFile(t))return;let r=t.statements.filter(i=>!l.isEmptyStatement(i));e.totalStatements=r.length,e.exportStatements=r.filter(i=>l.isExportDeclaration(i)||l.isExportAssignment(i)||et(i)).length}function ar(t,e){if(l.isJsxElement(t)||l.isJsxSelfClosingElement(t)||l.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(l.isFunctionDeclaration(t)||l.isMethodDeclaration(t)||l.isArrowFunction(t)||l.isClassDeclaration(t)||l.isVariableStatement(t)||l.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}l.isExportDeclaration(t)&&!cr(t)&&(e.hasTypesOnly=!1)}function cr(t){return t.isTypeOnly?!0:!t.exportClause||!l.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function lr(t,e){if(!l.isImportDeclaration(t)||!t.moduleSpecifier||!l.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(l.isNamedImports(t.importClause.namedBindings))for(let s of t.importClause.namedBindings.elements)r.push(s.name.text);else l.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let i=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:C(t.moduleSpecifier.text),type:i,symbols:r.length>0?r:void 0})}function mr(t,e){l.isExportDeclaration(t)?pr(t,e):l.isExportAssignment(t)?e.exports.set("default",{name:"default"}):et(t)&&gr(t,e)}function pr(t,e){if(t.moduleSpecifier&&l.isStringLiteral(t.moduleSpecifier))fr(t,t.moduleSpecifier.text,e);else if(t.exportClause&&l.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let i=r.name.text;e.exports.set(i,{name:i})}}function fr(t,e,r){let i=ur(t),s={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:C(e),type:"re-export"};i.length>0&&(s.symbols=i),r.imports.push(s)}function ur(t){return t.exportClause?l.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function gr(t,e){if((l.isFunctionDeclaration(t)||l.isClassDeclaration(t)||l.isInterfaceDeclaration(t)||l.isTypeAliasDeclaration(t)||l.isEnumDeclaration(t))&&t.name){let i=t.name.text;e.exports.set(i,Tt(i,t,t,e.sourceFile));return}if(l.isVariableStatement(t)){for(let i of t.declarationList.declarations)if(l.isIdentifier(i.name)){let s=i.name.text;e.exports.set(s,Tt(s,i,t,e.sourceFile))}}}function dr(t,e){if(!l.isCallExpression(t))return;let r=t.arguments[0];!r||!l.isStringLiteral(r)||(t.expression.kind===l.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:C(r.text),type:"dynamic"}):l.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:C(r.text),type:"require"}))}function yr(t,e){let r=vt.basename(t).toLowerCase(),i=vt.extname(t).toLowerCase();return U().some(n=>r.includes(n))?"test":Ct(r)?"config":e.imports.some(n=>Z().some(o=>n.rawSpecifier.includes(o)))?"test":i===".tsx"||i===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>X()?"barrel":"logic"}function et(t){return l.canHaveModifiers(t)&&l.getModifiers(t)?.some(e=>e.kind===l.SyntaxKind.ExportKeyword)===!0}function xr(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let i=new Map;for(let s of e.statements){if(!l.isImportDeclaration(s)||!l.isStringLiteral(s.moduleSpecifier))continue;let n=s.moduleSpecifier.text,o=s.importClause;if(o&&(o.name&&i.set(o.name.text,n),o.namedBindings&&l.isNamedImports(o.namedBindings)))for(let a of o.namedBindings.elements)i.set(a.name.text,n)}if(i.size!==0)for(let s of e.statements){let n=Sr(s);if(n){let o=br(s);o&&V(o,n,i,r);continue}l.isClassDeclaration(s)&&s.name&&hr(s,s.name.text,i,r)}}function hr(t,e,r,i){for(let s of t.members)l.isMethodDeclaration(s)&&s.body&&l.isIdentifier(s.name)?V(s.body,`${e}.${s.name.text}`,r,i):l.isConstructorDeclaration(s)&&s.body&&V(s.body,`${e}.constructor`,r,i)}function Sr(t){if(et(t)){if(l.isFunctionDeclaration(t)&&t.name)return t.name.text;if(l.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(l.isIdentifier(e.name)&&e.initializer&&(l.isArrowFunction(e.initializer)||l.isFunctionExpression(e.initializer)))return e.name.text}}}function br(t){if(l.isFunctionDeclaration(t))return t.body;if(l.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(l.isArrowFunction(e.initializer)||l.isFunctionExpression(e.initializer)))return e.initializer}}function V(t,e,r,i){if(l.isCallExpression(t)&&l.isIdentifier(t.expression)){let s=t.expression.text,n=r.get(s);n&&!i.some(o=>o.from===e&&o.to===s&&o.toSpecifier===n)&&i.push({from:e,to:s,toSpecifier:n})}l.forEachChild(t,s=>V(s,e,r,i))}function $(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(i=>{if(i.type==="rule")return r=!0,!1}),r?"ui":"barrel"}import Ft from"postcss";import*as Cr from"postcss-less";var Nr=Cr,Pt=new Set(["reference","inline"]);function kt(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function Er(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function wr(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let n=r[1]?.trim()??"",o=r[2]??"";if(!o)return null;let a=Pt.has(n)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:a,...kt(o)?{isExternal:!0}:{}}}let i=t.match(/^url\(['"]?([^'")]+)['"]?\)/),s=i?i[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return s?{fromPath:e,toPath:"",rawSpecifier:s,isStyle:!0,type:"static",...kt(s)?{isExternal:!0}:{}}:null}function vr(t,e){let r=[],i=/url\(['"]?([^'")]+)['"]?\)/g,s=i.exec(t);for(;s!==null;){let n=s[1]?.trim()??"";Er(n)&&r.push({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!0,type:"static"}),s=i.exec(t)}return r}function Dt(t,e){let r=[];return t.walk(i=>{if(i.type==="atrule"&&i.name==="import"){let s=wr(i.params,e);s&&r.push(s)}i.type==="decl"&&r.push(...vr(i.value,e))}),r}function Tr(t){return t.replace(/(?<!:)\/\/.*/g,"")}function Ir(t,e){let r=[],i=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,s=i.exec(t);for(;s!==null;){let n=s[1]?.trim()??"",o=s[2]??"";if(o){let a=Pt.has(n)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:a})}s=i.exec(t)}return r}function Lt(t,e){let r=Ft.parse(Tr(t));return{imports:Dt(r,e),root:r}}function kr(t){let e=[],r=[];for(let i of t.nodes??[]){if(i.type!=="atrule")continue;let{value:s}=i;if(s===void 0)continue;let n=i.name;n&&(e.push({name:n}),r.push({name:n,kind:"variable"}))}return{exports:e,tags:r}}function At(t,e){try{let r=Nr.parse(t),{exports:i,tags:s}=kr(r);return{imports:Dt(r,e),root:r,exports:i,tags:s}}catch{return{imports:Ir(t,e),root:Ft.parse(""),exports:[],tags:[]}}}import{parse as Fr}from"postcss-scss";function Rt(t){return t.startsWith("_")||t.startsWith("-")}function Pr(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function Dr(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],s=t.match(/\bas\s+(\S+)/)?.[1];return s!==void 0?{specifier:r,alias:s}:{specifier:r}}function Lr(t){let e=[],r=[];for(let i of t.nodes??[]){if(i.type==="decl"&&i.prop.startsWith("$")){let s=i.prop.slice(1);if(!s||Rt(s))continue;e.push({name:s}),r.push({name:s,kind:"variable"});continue}if(i.type==="atrule"&&(i.name==="mixin"||i.name==="function")){let n=i.params.match(/^([\w-]+)/)?.[1];if(!n||Rt(n))continue;let o=i.params.trim();e.push(o.includes("(")?{name:n,signature:o}:{name:n}),r.push({name:n,kind:"function"})}}return{exports:e,tags:r}}function Mt(t,e){let r=Fr(t),i=[];r.walk(o=>{if(o.type!=="atrule")return;let{name:a,params:c}=o;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:m,alias:p}=Dr(c);if(!m)return;let f={fromPath:e,toPath:"",rawSpecifier:m,isStyle:!0,type:a==="forward"?"re-export":"static",...Pr(m)?{isExternal:!0}:{}};p&&(f.symbols=[p]),i.push(f)});let{exports:s,tags:n}=Lr(r);return{imports:i,root:r,exports:s,tags:n}}function Bt(t,e){let r=[],i=/@require\s+['"]([^'"]+)['"]/g,s=i.exec(t);for(;s!==null;){let o=s[1];o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"require"}),s=i.exec(t)}let n=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(s=n.exec(t);s!==null;){let o=s[1];o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),s=n.exec(t)}return r}function Wt(t,e){if(e.length===0)return"ui";try{let r=Kt("stylus");return new r.Parser(t).parse().nodes.some(n=>n.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}function K(t,e){let r=M(t);if(r==="stylus"){let n=Bt(e,t);return{imports:n,exports:[],tags:[],category:Wt(e,n)}}if(r==="scss"){let{imports:n,root:o,exports:a,tags:c}=Mt(e,t);return{imports:n,exports:a,tags:c,category:$(o,n)}}if(r==="less"){let{imports:n,root:o,exports:a,tags:c}=At(e,t);return{imports:n,exports:a,tags:c,category:$(o,n)}}let{imports:i,root:s}=Lt(e,t);return{imports:i,exports:[],tags:[],category:$(s,i)}}for(let[t,e]of[["javascript",(r,i)=>tt(r,i,"javascript")],["typescript",(r,i)=>tt(r,i,"typescript")],["css",K],["scss",K],["less",K],["stylus",K],["coffeescript",nt],["livescript",ut],["lua",gt],["python",bt],["go",ft],["gherkin",q],["markdown",xt]])B(t,e);async function Ot(t,e){let r=M(t),i=at(r);return i?i(t,e):{imports:[],exports:[],tags:[],category:"other"}}function Ar(t){return Ot(t.filePath,t.content)}export{Ar as default};
1
+ var se=(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')});import gt from"path";function V(t){switch(gt.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":return"java";case".kt":case".kts":return"kotlin";case".scala":case".sc":return"scala";case".groovy":case".gradle":return"groovy";case".cpp":case".cc":case".cxx":case".c":return"unknown";case".feature":return"gherkin";case".md":case".mdx":return"markdown";default:return"unknown"}}function N(t){let e=gt.extname(t).toLowerCase();return[".css",".scss",".sass",".less",".styl"].includes(e)}import ne from"coffeescript";function k(t){return t.startsWith("'")||t.startsWith('"')?t.slice(1,-1):t}function O(t){let e=new Set,r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=r.exec(t);for(;s!==null;)s[1]&&e.add(s[1]),s=r.exec(t);return e}function B(t,e){let r=t.toLowerCase();return r.includes(".test.")||r.includes(".spec.")||e.has("test")?"test":"logic"}function yt(t){if(t){if(typeof t.originalValue=="string")return t.originalValue;if(typeof t.value=="string")return k(t.value)}}function F(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function oe(t,e){let r=yt(e.source);return r?{fromPath:t,toPath:"",rawSpecifier:r,isStyle:N(r),type:"static"}:null}function ae(t,e){let r=e.variable?.base?.value==="require",s=yt(e.args?.[0]?.base);return!r||!s?null:{fromPath:t,toPath:"",rawSpecifier:s,isStyle:N(s),type:"require"}}function dt(t,e){if(e)return[{name:e}];let r=t.value;if(r?.constructor?.name==="Class"){let i=F(r.variable);return i?[{name:i}]:[]}if(r?.base?.constructor?.name==="Obj"&&Array.isArray(r.base.properties))return r.base.properties.map(i=>F(i.variable)??F(i)).filter(i=>!!i).map(i=>({name:i}));let s=F(r);return s?[{name:s}]:[]}function ce(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=F(t.variable)??F(t.variable?.base);return e?[{name:e}]:[]}function le(t,e,r,s){let i=e.constructor?.name;if(i==="ImportDeclaration"){let n=oe(t,e);n&&r.push(n)}else if(i==="Call"){let n=ae(t,e);n&&r.push(n)}else if(i==="Assign"){let n=F(e.variable?.base),o=e.variable?.properties?.[0]?.name?.value;n==="module"&&o==="exports"?s.push(...dt(e,void 0)):n==="exports"&&typeof o=="string"&&s.push(...dt(e,o))}else i==="ExportNamedDeclaration"&&e.clause?s.push(...ce(e.clause)):i==="ExportDefaultDeclaration"&&s.push({name:"default"})}function X(t,e,r,s){if(!(!e||typeof e!="object")){le(t,e,r,s);for(let i in e){if(i==="locationData")continue;let n=e[i];if(!(!n||typeof n!="object"))if(Array.isArray(n))for(let o of n)X(t,o,r,s);else X(t,n,r,s)}}}function xt(t,e){let r=O(e),s=B(t,r),i=[],n=[];try{X(t,ne.nodes(e),i,n)}catch{}let o=new Set,a=n.filter(c=>o.has(c.name)?!1:(o.add(c.name),!0));return{imports:i,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:s}}import{AstBuilder as me,GherkinClassicTokenMatcher as pe,Parser as fe}from"@cucumber/gherkin";import{IdGenerator as ue}from"@cucumber/messages";var ht=new Map;function J(t,e){ht.set(t,e)}function St(t){return ht.get(t)}var ge=ue.uuid();function Y(t,e){let r=new Set,s=i=>{for(let n of i)r.add(n.name.startsWith("@")?n.name.slice(1):n.name)};try{let i=new me(ge),n=new pe,a=new fe(i,n).parse(e);if(a.feature){s(a.feature.tags);for(let c of a.feature.children){if(c.scenario){s(c.scenario.tags);for(let l of c.scenario.examples)s(l.tags)}if(c.rule)for(let l of c.rule.children)l.scenario&&s(l.scenario.tags)}}}catch(i){console.warn(`[GherkinParser] Failed to parse ${t}:`,i)}return{imports:[],exports:[],tags:Array.from(r).map(i=>({name:i,kind:"comment-marker"})),category:"test"}}J("gherkin",Y);import Se from"path";import{parser as Ce}from"@lezer/go";function D(t){let e=[],r=t.firstChild;for(;r;)e.push(r),r=r.nextSibling;return e}function A(t,e){let r=1;for(let s=0;s<e&&s<t.length;s++)t[s]===`
2
+ `&&r++;return r}function de(t,e){let r=1;function s(i){switch(i.type.name){case"IfStatement":case"ForStatement":r++;break;case"Case":{i.firstChild?.type.name==="case"&&r++;break}case"LogicOp":{let o=e.slice(i.from,i.to);(o==="&&"||o==="||")&&r++;break}}let n=i.firstChild;for(;n;)s(n),n=n.nextSibling}return s(t),r}function bt(t,e,r,s){let i=r?1:1+e,n=D(t),o=r?e:e+1,a=n[1];a&&a.type.name!=="Block"&&(i+=$(a,o,!1,s));let c=n.find(p=>p.type.name==="Block");c&&(i+=$(c,o,!1,s));let l=n.findIndex(p=>p.type.name==="else");if(l>=0){let p=n[l+1];p?.type.name==="IfStatement"?i+=bt(p,e,!0,s):p&&(i+=1+$(p,e+1,!1,s))}return i}function Ct(t,e,r){let s=1+e,i=t.firstChild;for(;i;)s+=$(i,e+1,!1,r),i=i.nextSibling;return s}function ye(t,e,r){let s=0,i=t.firstChild;for(;i;)s+=$(i,e,!1,r),i=i.nextSibling;return s}function xe(t,e){let r=e.slice(t.from,t.to);return r==="&&"||r==="||"}function $(t,e,r,s){let i=t.type.name;if(i==="IfStatement")return bt(t,e,r,s);if(i==="ForStatement"||i==="SwitchStatement"||i==="SelectStatement")return Ct(t,e,s);let n=i==="LogicOp"&&xe(t,s)?1:0;return e>0&&i==="FunctionLiteral"?n+Ct(t,e,s):n+ye(t,e,s)}function he(t,e){return $(t,0,!1,e)}function H(t,e){return{complexity:de(t,e),cognitiveComplexity:he(t,e)}}function tt(t,e){let s=t.getChild("Parameters")?.getChild("Parameter"),i=s?.getChild("TypeName")??s?.getChild("PointerType")?.getChild("TypeName");return i?e.slice(i.from,i.to):void 0}function Nt(t,e){let r=[],s=t.cursor();do if(s.name==="FunctionDecl"){let i=s.node.getChild("DefName");if(i){let n=e.slice(i.from,i.to),{complexity:o,cognitiveComplexity:a}=H(s.node,e);r.push({name:n,line:A(e,s.from),complexity:o,cognitiveComplexity:a})}}else if(s.name==="MethodDecl"){let i=s.node.getChild("FieldName");if(i){let n=e.slice(i.from,i.to),o=tt(s.node,e),a=o?`${o}.${n}`:n,{complexity:c,cognitiveComplexity:l}=H(s.node,e);r.push({name:a,line:A(e,s.from),complexity:c,cognitiveComplexity:l})}}while(s.next());return r}var be=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/,Ne=/^\/\/go:build\s+(.+)$/,Ee=/^\/\/\s*\+build\s+(.+)$/;function wt(t,e){let r=[],s=new Map,i=new Set,n=new Set,o=new Map,a=Ce.parse(e),c=a.cursor();do switch(c.name){case"LineComment":{let b=e.slice(c.from,c.to),E=b.match(be);E?.[1]&&i.add(E[1]);let M=b.match(Ne);M&&Et(M[1],n);let _=b.match(Ee);_&&Et(_[1],n);break}case"ImportSpec":{let b=c.node.getChild("String");if(b){let M=e.slice(b.from,b.to).slice(1,-1);r.push({fromPath:t,toPath:"",rawSpecifier:M,isExternal:!0,isStyle:!1,type:"static"});let _=c.node.getChild("DefName"),G=_?e.slice(_.from,_.to):M.split("/").pop();G&&G!=="_"&&G!=="."&&o.set(G,M)}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 E=e.slice(b.from,b.to);E!=="_"&&/^[A-Z]/.test(E)&&!s.has(E)&&s.set(E,{name:E})}break}}while(c.next());let l=r.some(b=>b.rawSpecifier==="testing"),p=Se.basename(t).endsWith("_test.go")||i.has("test")||l?"test":"logic",f=new Set([...i,...n]),{complexity:u,cognitiveComplexity:d}=H(a.topNode,e),h=Nt(a,e),C=p==="test"?[]:we(a,e,o);return{imports:r,exports:Array.from(s.values()),tags:Array.from(f).map(b=>({name:b,kind:"comment-marker"})),category:p,rawCallEdges:C,complexity:u,cognitiveComplexity:d,...h.length>0?{functions:h}:{}}}function we(t,e,r){let s=[];function i(o,a){if(o.type.name==="CallExpr"){let l=o.firstChild;if(l?.type.name==="SelectorExpr"){let p=l.firstChild,f=l.getChild("FieldName");if(p?.type.name==="VariableName"&&f){let u=e.slice(p.from,p.to),d=r.get(u);if(d){let h=e.slice(f.from,f.to);s.push({from:a,to:h,toSpecifier:d})}}}}let c=o.firstChild;for(;c;)i(c,a),c=c.nextSibling}let n=t.cursor();do if(n.name==="FunctionDecl"){let o=n.node.getChild("DefName"),a=n.node.getChild("Block");if(o&&a){let c=e.slice(o.from,o.to);/^[A-Z]/.test(c)&&i(a,c)}}else if(n.name==="MethodDecl"){let o=n.node.getChild("FieldName"),a=n.node.getChild("Block");if(o&&a){let c=e.slice(o.from,o.to),l=tt(n.node,e);i(a,l?`${l}.${c}`:c)}}while(n.next());return s}function Et(t,e){for(let r of t.split(/[\s,&|!()]+/)){let s=r.trim();s&&s!=="ignore"&&e.add(s)}}var ve=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/g,ke=["org.junit","androidx.test","org.robolectric","org.mockito","org.scalatest","munit","spock.lang","io.kotest","org.spekframework"];function j(t){let e=new Set;for(let r of t.matchAll(ve))r[1]&&e.add(r[1]);return e}function I(t){let e=t.replace(/\/\*[\s\S]*?\*\//g,r=>r.replace(/[^\n]/g," "));return e=e.replace(/\/\/[^\n]*/g,r=>" ".repeat(r.length)),e}function W(t){let e=I(t),r=new Set;for(let i of e.matchAll(/@([A-Z]\w*)/g))i[1]&&r.add(i[1]);let s=new Set;for(let i of e.matchAll(/\b(?:class|object|interface|trait|enum)\s+([A-Za-z_]\w*)/g))i[1]&&s.add(i[1]);return{annotations:[...r],typeNames:[...s]}}function z(t,e){return{fromPath:t,toPath:"",rawSpecifier:e,isExternal:!0,isStyle:!1,type:"static"}}function T(t,e){return{fromPath:t,toPath:"",rawSpecifier:`${e}.*`,isExternal:!0,isStyle:!1,type:"side-effect"}}function P(t,e){let r=[];for(let s of I(t).split(`
3
+ `)){let i=s.trim();if(!i||i.startsWith("@")||i.startsWith("*"))continue;let n=i.match(/^package\s+(?:object\s+)?([\w.]+)/);if(n?.[1]){if(r.push(n[1]),!e)break;continue}if(!(e&&/^import\s/.test(i)))break}return r.length>0?r.join("."):null}var Ie=new Set(["Configuration","SpringBootApplication","EnableAutoConfiguration"]),Te=new Set(["Composable","Preview"]),Pe=new Set(["RestController","Controller","Service","Repository","Component","Entity","MappedSuperclass","Embeddable"]),Fe=["Activity","Fragment","ViewModel","Screen","Composable"];function w(t,e,r={}){let s=t.replace(/\\/g,"/"),i=s.split("/").pop()??"";if(i.endsWith(".gradle")||i==="build.gradle.kts"||i==="settings.gradle.kts")return"config";if(/\/src\/(test|androidTest|integrationTest|it)\//.test(s)||e.some(o=>ke.some(a=>o===a||o.startsWith(`${a}.`))))return"test";let n=r.annotations??[];return n.some(o=>Ie.has(o))?"config":n.some(o=>Te.has(o))||(r.typeNames??[]).some(o=>Fe.some(a=>o.endsWith(a)))?"ui":(n.some(o=>Pe.has(o)),"logic")}var De=/^\s*import\s+(static\s+)?([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,Ae=/^(?:@\w+\s+)*(?:public\s+|private\s+|protected\s+|final\s+|abstract\s+|static\s+)*(class|interface|trait|enum|def)\s+([A-Za-z_][A-Za-z0-9_]*)/;function Le(t,e){return t?e.endsWith(".*")?e.slice(0,-2)||null:e.split(".").slice(0,-1).join(".")||null:e||null}function vt(t,e){let r=j(e),i=I(e).split(`
4
+ `),n=[],o=new Set;for(let l of i){let p=l.match(De);if(p?.[2]){let u=Le(!!p[1],p[2]);u&&n.push(z(t,u));continue}let f=l.match(Ae);f?.[2]&&o.add(f[2])}let a=P(e,!1);a&&n.push(T(t,a));let c=Array.from(o,l=>({name:l}));return{imports:n,exports:c,tags:Array.from(r).map(l=>({name:l,kind:"comment-marker"})),category:w(t,n.map(l=>l.rawSpecifier),{typeNames:[...o],annotations:W(e).annotations})}}import{parser as $e}from"@lezer/java";var kt=new Set(["ForStatement","EnhancedForStatement","WhileStatement","DoStatement"]),Re=new Set(["ClassDeclaration","InterfaceDeclaration","EnumDeclaration","RecordDeclaration","AnnotationTypeDeclaration"]);function Me(t,e){let r=1;function s(i){let n=i.type.name;if(n==="IfStatement"||n==="CatchClause"||n==="TernaryExpression")r++;else if(kt.has(n))r++;else if(n==="SwitchLabel")i.firstChild?.type.name==="case"&&r++;else if(n==="LogicOp"){let a=e.slice(i.from,i.to);(a==="&&"||a==="||")&&r++}let o=i.firstChild;for(;o;)s(o),o=o.nextSibling}return s(t),r}function It(t,e,r,s){let i=r?1:1+e,n=[];for(let p=t.firstChild;p;p=p.nextSibling)n.push(p);let o=r?e:e+1,a=n[1];a&&a.type.name!=="Block"&&(i+=K(a,o,!1,s));let c=n.find(p=>p.type.name==="Block");c&&(i+=K(c,o,!1,s));let l=n.findIndex(p=>p.type.name==="else");if(l>=0){let p=n[l+1];p?.type.name==="IfStatement"?i+=It(p,e,!0,s):p&&(i+=1+K(p,e+1,!1,s))}return i}function et(t,e,r){let s=1+e,i=t.firstChild;for(;i;)s+=K(i,e+1,!1,r),i=i.nextSibling;return s}function _e(t,e,r){let s=0,i=t.firstChild;for(;i;)s+=K(i,e,!1,r),i=i.nextSibling;return s}function Oe(t,e){let r=e.slice(t.from,t.to);return r==="&&"||r==="||"}function K(t,e,r,s){let i=t.type.name;if(i==="IfStatement")return It(t,e,r,s);if(kt.has(i)||i==="SwitchStatement"||i==="CatchClause"||i==="TernaryExpression")return et(t,e,s);let n=i==="LogicOp"&&Oe(t,s)?1:0;return e>0&&i==="LambdaExpression"?n+et(t,e,s):n+_e(t,e,s)}function Be(t,e){return K(t,0,!1,e)}function rt(t,e){return{complexity:Me(t,e),cognitiveComplexity:Be(t,e)}}function it(t,e){for(let r=t.parent;r;r=r.parent)if(Re.has(r.type.name)){let s=r.getChild("Definition");if(s)return e.slice(s.from,s.to)}}function Tt(t,e){let r=[],s=t.cursor();do if(s.name==="MethodDeclaration"||s.name==="ConstructorDeclaration"){let i=s.node.getChild("Definition");if(i){let n=e.slice(i.from,i.to),o=it(s.node,e),a=o&&s.name==="MethodDeclaration"?`${o}.${n}`:n,{complexity:c,cognitiveComplexity:l}=rt(s.node,e);r.push({name:a,line:A(e,s.from),complexity:c,cognitiveComplexity:l})}}while(s.next());return r}var je=/\/\/\s*@tag\s+([a-zA-Z0-9_-]+)/;function We(t,e){let r=t.getChild("ScopedIdentifier");if(!r)return null;let s=t.getChild("static")!=null,i=t.getChild("Asterisk")!=null,n=e.slice(r.from,r.to);return s?(i||(n=n.split(".").slice(0,-1).join(".")),n?{specifier:n,wildcard:!1}:null):i?{specifier:`${n}.*`,wildcard:!0}:{specifier:n,wildcard:!1}}function ze(t){let e=new Map;for(let r of t){if(r.type==="side-effect")continue;let s=r.rawSpecifier;if(s.endsWith(".*"))continue;let i=s.split(".").pop();i&&e.set(i,s)}return e}function Ke(t,e,r){let s=[];function i(o,a){let c=o.type.name;if(c==="MethodInvocation"){let p=o.firstChild;if(p?.type.name==="Identifier"){let f=r.get(e.slice(p.from,p.to)),u=o.getChild("MethodName");f&&u&&s.push({from:a,to:e.slice(u.from,u.to),toSpecifier:f})}}else if(c==="ObjectCreationExpression"){let p=o.getChild("TypeName");if(p){let f=r.get(e.slice(p.from,p.to));f&&s.push({from:a,to:"new",toSpecifier:f})}}let l=o.firstChild;for(;l;)i(l,a),l=l.nextSibling}let n=t.cursor();do if(n.name==="MethodDeclaration"||n.name==="ConstructorDeclaration"){let o=n.node.getChild("Definition"),a=n.node.getChild("Block")??n.node.getChild("ConstructorBody");if(o&&a){let c=e.slice(o.from,o.to),l=it(n.node,e),p=l&&n.name==="MethodDeclaration"?`${l}.${c}`:c;i(a,p)}}while(n.next());return s}function Pt(t,e){let r=[],s=new Map,i=new Set,n=new Set,o;try{o=$e.parse(e)}catch{return{imports:[],exports:[],tags:[],category:w(t,[])}}let a=o.cursor();do switch(a.name){case"LineComment":{let h=e.slice(a.from,a.to).match(je);h?.[1]&&i.add(h[1]);break}case"MarkerAnnotation":case"Annotation":{let h=a.node.getChild("Identifier");h&&n.add(e.slice(h.from,h.to));break}case"ImportDeclaration":{let h=We(a.node,e);h&&r.push({fromPath:t,toPath:"",rawSpecifier:h.specifier,isExternal:!0,isStyle:!1,type:"static"});break}case"ClassDeclaration":case"InterfaceDeclaration":case"EnumDeclaration":case"AnnotationTypeDeclaration":{if(a.node.parent?.name==="Program"){let h=a.node.getChild("Definition");if(h){let C=e.slice(h.from,h.to);s.has(C)||s.set(C,{name:C})}}break}}while(a.next());let c=P(e,!1);c&&r.push(T(t,c));let l=w(t,r.map(h=>h.rawSpecifier),{typeNames:[...s.keys()],annotations:[...n]}),{complexity:p,cognitiveComplexity:f}=rt(o.topNode,e),u=Tt(o,e),d=l==="test"?[]:Ke(o,e,ze(r));return{imports:r,exports:Array.from(s.values()),tags:Array.from(i).map(h=>({name:h,kind:"comment-marker"})),category:l,rawCallEdges:d,complexity:p,cognitiveComplexity:f,...u.length>0?{functions:u}:{}}}var Ve=/^\s*import\s+([\w.]+(?:\.\*)?)(?:\s+as\s+\w+)?\s*$/,st="(?:public\\s+|internal\\s+|private\\s+|protected\\s+|open\\s+|abstract\\s+|final\\s+|sealed\\s+|data\\s+|value\\s+|inline\\s+|noinline\\s+|crossinline\\s+|external\\s+|expect\\s+|actual\\s+|suspend\\s+|operator\\s+|infix\\s+|tailrec\\s+|const\\s+|lateinit\\s+)*",Je=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${st}(?:(?:enum|annotation)\\s+)?(class|interface|object|typealias)\\s+([A-Za-z_][A-Za-z0-9_]*)`),qe=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${st}fun\\s+(?:<[^>]*>\\s*)?(?:[A-Za-z_][\\w.]*(?:<[^>]*>)?\\.)?([A-Za-z_][A-Za-z0-9_]*)\\s*[(<]`),Ze=new RegExp(`^(?:@[\\w.]+(?:\\([^)]*\\))?\\s+)*${st}(?:val|var)\\s+(?:<[^>]*>\\s*)?([A-Za-z_][A-Za-z0-9_]*)`);function Ft(t,e){let r=j(e),i=I(e).split(`
5
+ `),n=[],o=new Set;for(let l of i){let p=l.match(Ve);if(p?.[1]){n.push(z(t,p[1]));continue}let f=l.match(Je);if(f?.[2]){o.add(f[2]);continue}let u=l.match(qe);if(u?.[1]){o.add(u[1]);continue}let d=l.match(Ze);d?.[1]&&o.add(d[1])}let a=P(e,!1);a&&n.push(T(t,a));let c=Array.from(o,l=>({name:l}));return{imports:n,exports:c,tags:Array.from(r).map(l=>({name:l,kind:"comment-marker"})),category:w(t,n.map(l=>l.rawSpecifier),{typeNames:[...o],annotations:W(e).annotations})}}import Ge from"livescript";function L(t){if(t){if(typeof t.value=="string")return t.value;if(typeof t.base?.value=="string")return t.base.value}}function He(t){if(!t)return[];if(t.constructor?.name==="Class"){let r=L(t.title);return r?[{name:r}]:[]}if(t.constructor?.name==="Obj"&&Array.isArray(t.items))return t.items.map(r=>L(r.key)??L(r.val)).filter(r=>!!r).map(r=>({name:r}));let e=L(t);return e?[{name:e}]:[]}function Ue(t){let e=t.constructor?.name||t.type;if(e==="Assign"&&t.left?.constructor?.name==="Chain"){let r=t.left,s=L(r.head),n=r.tails?.[0]?.key?.name;if(s==="module"&&n==="exports")return He(t.right);if(s==="exports"&&typeof n=="string")return[{name:n}];if(r.head?.verb==="out"&&typeof n=="string")return[{name:n}]}if(e==="Import"&&t.left?.verb==="out"){let r=t.right;if(r?.constructor?.name==="Obj"&&Array.isArray(r.items))return r.items.map(s=>L(s.val)??L(s.key)).filter(s=>!!s).map(s=>({name:s}))}return[]}var Qe=new Set(["first_line","first_column","last_line","last_column","line","column"]);function Xe(t,e){let r=t.constructor?.name||t.type;if(r==="Import"){let s=t.right?.value;if(typeof s=="string"){let i=k(s);return{fromPath:e,toPath:"",rawSpecifier:i,isStyle:N(i),type:"static"}}}if(r==="Chain"&&t.head?.value==="require"){let s=t.tails?.[0];if(s?.constructor?.name==="Call"||s?.type==="Call"){let i=s.args?.[0]?.value;if(typeof i=="string"){let n=k(i);return{fromPath:e,toPath:"",rawSpecifier:n,isStyle:N(n),type:"require"}}}}return null}function nt(t,e,r){if(!t||typeof t!="object")return[];let s=[],i=Xe(t,e);i&&s.push(i),r.push(...Ue(t));for(let n in t){if(Qe.has(n))continue;let o=t[n];if(!(!o||typeof o!="object"))if(Array.isArray(o))for(let a of o)s.push(...nt(a,e,r));else s.push(...nt(o,e,r))}return s}function Dt(t,e){let r=O(e),s=B(t,r),i=[],n=[];try{i=nt(Ge.ast(e),t,n)}catch{}let o=new Set,a=n.filter(c=>o.has(c.name)?!1:(o.add(c.name),!0));return{imports:i,exports:a,tags:Array.from(r).map(c=>({name:c,kind:"comment-marker"})),category:s}}import Ye from"luaparse";function tr(t,e){let r=[];function s(i){if(!(!i||typeof i!="object")){if((i.type==="CallExpression"||i.type==="StringCallExpression")&&i.base?.type==="Identifier"&&i.base?.name==="require"){let n;if(i.type==="CallExpression"){let o=i.arguments?.[0];o?.type==="StringLiteral"&&(n=k(o.raw))}else if(i.type==="StringCallExpression"){let o=i.argument;o?.type==="StringLiteral"&&(n=k(o.raw))}n&&r.push({fromPath:e,toPath:"",rawSpecifier:n,isStyle:N(n),type:"require"})}for(let n in i){if(n==="loc")continue;let o=i[n];if(o&&typeof o=="object")if(Array.isArray(o))for(let a of o)s(a);else s(o)}}}return s(t),r}function er(t){let e=new Set;for(let r of t)r.type==="LocalStatement"&&r.variables.forEach((s,i)=>{r.init[i]?.type==="TableConstructorExpression"&&e.add(s.name)});return e}function rr(t){let e=t[t.length-1];if(e?.type!=="ReturnStatement")return[];let r=e.arguments[0];if(r?.type!=="TableConstructorExpression")return[];let s=[];for(let i of r.fields)i.type==="TableKeyString"&&s.push({name:i.key.name});return s}function ir(t){let e=t.body,r=er(e),s=rr(e);for(let n of e)if(n.type==="FunctionDeclaration")n.identifier?.type==="MemberExpression"?n.identifier.base.type==="Identifier"&&r.has(n.identifier.base.name)&&s.push({name:n.identifier.identifier.name}):n.identifier?.type==="Identifier"&&!n.isLocal&&s.push({name:n.identifier.name});else if(n.type==="AssignmentStatement")for(let o of n.variables)o.type==="MemberExpression"&&o.base.type==="Identifier"&&r.has(o.base.name)&&s.push({name:o.identifier.name});let i=new Set;return s.filter(n=>i.has(n.name)?!1:(i.add(n.name),!0))}function At(t,e){let r=O(e),s=B(t,r),i=[],n=[];try{let o=Ye.parse(e);i=tr(o,t),n=ir(o)}catch{}return{imports:i,exports:n,tags:Array.from(r).map(o=>({name:o,kind:"comment-marker"})),category:s}}var sr=["http://","https://","mailto:","//"],nr="ts|tsx|js|jsx|mjs|cjs|py|go|lua|css|scss|less|styl|coffee|ls|feature|md|mdx|json",or=new RegExp(`(?:\\.{1,2}/)?[\\w.-]+(?:/[\\w.-]+)*\\.(?:${nr})\\b`,"g"),Lt;async function ar(){return Lt??=(async()=>{let{unified:t}=await import("unified"),e=(await import("remark-parse")).default;return t().use(e)})(),Lt}function cr(t){let e=t.trim();return e.length===0||e.startsWith("#")||sr.some(r=>e.startsWith(r))}function lr(t,e){let r=t.match(or);return r?r.map(s=>({fromPath:e,toPath:"",rawSpecifier:s,isStyle:!1,type:"static"})):[]}function Rt(t,e,r){if(t.type==="link"&&typeof t.url=="string"&&!cr(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(...lr(t.value,e)),Array.isArray(t.children))for(let s of t.children)Rt(s,e,r)}async function Mt(t,e){let s=(await ar()).parse(e),i=[];Rt(s,t,i);let n=new Set;return{imports:i.filter(a=>n.has(a.rawSpecifier)?!1:(n.add(a.rawSpecifier),!0)),exports:[],tags:[],category:"other"}}import dr from"path";import{parser as yr}from"@lezer/python";function mr(t){let e=1;function r(s){switch(s.type.name){case"IfStatement":{e+=D(s).filter(n=>n.type.name==="if"||n.type.name==="elif").length;break}case"TryStatement":{e+=D(s).filter(n=>n.type.name==="except").length;break}case"ForStatement":case"WhileStatement":case"ConditionalExpression":e++;break;case"and":case"or":e++;break}let i=s.firstChild;for(;i;)r(i),i=i.nextSibling}return r(t),e}function pr(t,e){let r=0,s=D(t),i=0,n=0;for(;n<s.length;){let o=s[n];if(o?.type.name==="if"||o?.type.name==="elif"){let a=i>0;r+=a?1:1+e;let c=a?e:e+1,l=s[n+1],p=s[n+2];l&&(r+=v(l,c)),p&&(r+=v(p,c)),i++,n+=3}else if(o?.type.name==="else"){r+=1;let a=s[n+1];a&&(r+=v(a,e+1)),n+=2}else n++}return r}function fr(t,e){let r=0,s=D(t),i=0;for(;i<s.length;){let n=s[i];if(n?.type.name==="except"){for(r+=1+e,i++;i<s.length&&s[i]?.type.name!=="Body";)r+=v(s[i],e),i++;i<s.length&&(r+=v(s[i],e),i++)}else n?.type.name==="Body"&&(r+=v(n,e)),i++}return r}function _t(t,e){let r=1+e,s=t.firstChild;for(;s;)r+=v(s,e+1),s=s.nextSibling;return r}function ur(t,e){let r=0,s=t.firstChild;for(;s;)r+=v(s,e),s=s.nextSibling;return r}function v(t,e){let r=t.type.name;switch(r){case"IfStatement":return pr(t,e);case"TryStatement":return fr(t,e);case"ForStatement":case"WhileStatement":return _t(t,e);default:{let s=r==="ConditionalExpression"||r==="and"||r==="or"?1:0;return e>0&&(r==="FunctionDefinition"||r==="LambdaExpression")?s+_t(t,e):s+ur(t,e)}}}function gr(t){return v(t,0)}function ot(t){return{complexity:mr(t),cognitiveComplexity:gr(t)}}function Ot(t,e){let r=[];function s(o,a){let{complexity:c,cognitiveComplexity:l}=ot(o);r.push({name:a,line:A(e,o.from),complexity:c,cognitiveComplexity:l})}function i(o){let a=o.firstChild;for(;a;)n(a),a=a.nextSibling}function n(o){if(o.type.name==="ClassDefinition"){let a=o.getChild("VariableName"),c=a?e.slice(a.from,a.to):void 0,l=o.getChild("Body");if(l){let p=l.firstChild;for(;p;){if(p.type.name==="FunctionDefinition"){let f=p.getChild("VariableName"),u=f?e.slice(f.from,f.to):void 0;u&&s(p,c?`${c}.${u}`:u),i(p)}else n(p);p=p.nextSibling}}return}if(o.type.name==="FunctionDefinition"){let a=o.getChild("VariableName");a&&s(o,e.slice(a.from,a.to)),i(o);return}i(o)}return n(t.topNode),r}var xr=new Set(["pytest","unittest","nose","hypothesis"]);function Bt(t,e){let r=[],s=[],i=new Set,n=dr.basename(t).toLowerCase(),o=yr.parse(e),a=o.cursor();do switch(a.name){case"Comment":{let d=e.slice(a.from,a.to).match(/#\s*@tag\s+([a-zA-Z0-9_-]+)/);d?.[1]&&i.add(d[1]);break}case"ImportStatement":{for(let d of hr(a.node,e,t))r.push(d);break}case"FunctionDefinition":case"ClassDefinition":{let d=a.node.parent;if(d?.name==="Script"||d?.name==="DecoratedStatement"&&d.parent?.name==="Script"){let C=a.node.getChild("VariableName");C&&s.push({name:e.slice(C.from,C.to)})}break}case"AssignStatement":{if(a.node.parent?.name==="Script"){let d=a.node.firstChild;d?.name==="VariableName"&&s.push({name:e.slice(d.from,d.to)})}break}}while(a.next());let c=wr(n,r,i);c==="test"&&i.add("test");let{complexity:l,cognitiveComplexity:p}=ot(o.topNode),f=Ot(o,e),u=c==="test"?[]:Er(o,e);return{imports:r,exports:s,tags:Array.from(i).map(d=>({name:d,kind:"comment-marker"})),category:c,rawCallEdges:u,complexity:l,cognitiveComplexity:p,...f.length>0?{functions:f}:{}}}function hr(t,e,r){let s=t.firstChild;return s?s.name==="from"?Sr(t,e,r):Cr(t,e,r):[]}function Sr(t,e,r){let s=t.firstChild;if(!s)return[];let i=s.nextSibling;for(;i&&i.name!=="import";)i=i.nextSibling;if(!i)return[];let n=e.slice(s.to,i.from).trim(),o=br(i.nextSibling,e);if(!o.length)return[];let a=0;for(;a<n.length&&n[a]===".";)a++;let c=n.slice(a);if(a===0)return[q(r,n,o,!0)];let l=a===1?"./":"../".repeat(a-1);return c?[q(r,l+c.replace(/\./g,"/"),o,!1)]:o[0]==="*"?[q(r,l.slice(0,-1),["*"],!1)]:o.map(p=>q(r,l+p,[p],!1))}function Cr(t,e,r){let s=[],i=t.firstChild?.nextSibling??null;for(;i;){if(i.name==="VariableName"){let n=e.slice(i.from,i.to);for(;i.nextSibling?.name==="."&&i.nextSibling.nextSibling?.name==="VariableName";)i=i.nextSibling.nextSibling,n+=`.${e.slice(i.from,i.to)}`;i.nextSibling?.name==="as"&&(i=i.nextSibling.nextSibling??i.nextSibling),s.push(q(r,n,["*"],!0))}i=i.nextSibling}return s}function br(t,e){let r=[],s=t;for(;s;)s.name==="*"?r.push("*"):s.name==="VariableName"&&(r.push(e.slice(s.from,s.to)),s.nextSibling?.name==="as"&&(s=s.nextSibling.nextSibling??s.nextSibling)),s=s.nextSibling;return r}function Nr(t,e){let r=new Map,s=t.cursor();do{if(s.name!=="ImportStatement")continue;let n=s.node.firstChild;if(n?.type.name!=="from")continue;let o=n.nextSibling;for(;o&&o.type.name!=="import";)o=o.nextSibling;if(!o)continue;let a=e.slice(n.to,o.from).trim(),c=0;for(;c<a.length&&a[c]===".";)c++;let l=a.slice(c),p=c<=1?"./":"../".repeat(c-1),f=o.nextSibling;for(;f;){if(f.type.name==="VariableName"){let u=e.slice(f.from,f.to),d=u;if(f.nextSibling?.type.name==="as"){let C=f.nextSibling.nextSibling;C?.type.name==="VariableName"&&(d=e.slice(C.from,C.to),f=C)}let h=c===0?a:l?p+l.replace(/\./g,"/"):p+u;r.set(d,h)}f=f.nextSibling}}while(s.next());return r}function Er(t,e){let r=Nr(t,e),s=[];function i(a,c){if(a.type.name==="CallExpression"&&a.firstChild?.type.name==="VariableName"){let p=a.firstChild,f=e.slice(p.from,p.to),u=r.get(f);u&&s.push({from:c,to:f,toSpecifier:u})}let l=a.firstChild;for(;l;)i(l,c),l=l.nextSibling}function n(a){let c=a.firstChild;for(;c;)o(c),c=c.nextSibling}function o(a){if(a.type.name==="ClassDefinition"){let c=a.getChild("VariableName"),l=c?e.slice(c.from,c.to):void 0,p=a.getChild("Body");if(p){let f=p.firstChild;for(;f;){if(f.type.name==="FunctionDefinition"){let u=f.getChild("VariableName"),d=u?e.slice(u.from,u.to):void 0;d&&i(f,l?`${l}.${d}`:d)}else o(f);f=f.nextSibling}}return}if(a.type.name==="FunctionDefinition"){let c=a.getChild("VariableName");c&&i(a,e.slice(c.from,c.to));return}n(a)}return o(t.topNode),s}function q(t,e,r,s){return{fromPath:t,toPath:"",rawSpecifier:e,isStyle:!1,isExternal:s,type:"static",symbols:r.length>0?r:void 0}}function wr(t,e,r){return t.startsWith("test_")||t.endsWith("_test.py")?"test":t==="conftest.py"||t==="setup.py"?"config":r.has("test")||e.some(s=>xr.has(s.rawSpecifier))?"test":"logic"}var vr=/^\s*import\s+(.+?)\s*$/,kr=/^(?:@\w+\s+)*(?:private\s+|protected\s+|final\s+|sealed\s+|abstract\s+|implicit\s+|case\s+)*(class|trait|object|type|enum)\s+([A-Za-z_$][A-Za-z0-9_$]*)/;function Ir(t,e){let r=e.split("=>")[0]?.trim();return r?r==="_"||r==="*"||r==="given"?`${t}.*`:`${t}.${r}`:null}function Tr(t){let e=t.indexOf("{");if(e!==-1){let s=t.indexOf("}",e),i=t.slice(0,e).trim().replace(/\.$/,""),n=t.slice(e+1,s===-1?void 0:s);return i?n.split(",").map(o=>Ir(i,o.trim())).filter(o=>o!=null):[]}let r=[];for(let s of t.split(",")){let i=s.trim().replace(/\s+as\s+\w+$/,"");if(i)if(i.endsWith("._")||i.endsWith(".*")||i.endsWith(".given")){let n=i.replace(/\.(_|\*|given)$/,"");n&&r.push(`${n}.*`)}else r.push(i)}return r}function $t(t,e){let r=j(e),i=I(e).split(`
6
+ `),n=[],o=new Set;for(let l of i){let p=l.match(vr);if(p?.[1]){for(let u of Tr(p[1]))n.push(z(t,u));continue}let f=l.match(kr);f?.[2]&&o.add(f[2])}let a=P(e,!0);a&&n.push(T(t,a));let c=Array.from(o,l=>({name:l}));return{imports:n,exports:c,tags:Array.from(r).map(l=>({name:l,kind:"comment-marker"})),category:w(t,n.map(l=>l.rawSpecifier),{typeNames:[...o],annotations:W(e).annotations})}}import Vt from"path";import m from"typescript";var Pr=[".config.","biome.json","tsconfig.json","package.json",".prettierrc",".eslintrc"],Fr=[];function jt(t){return[...Pr,...Fr].some(e=>typeof e=="string"?t.includes(e):e instanceof RegExp?e.test(t):e(t))}var Dr=[".test.",".spec.","-test.","-spec."],Ar=[];function at(){return[...Dr,...Ar]}var Lr=["jest","vitest","playwright","cypress","@testing-library/"],Rr=[];function ct(){return[...Lr,...Rr]}var Mr=.8,_r=Mr;function lt(){return _r}import g from"typescript";function Or(t){let e=1;function r(s){switch(s.kind){case g.SyntaxKind.IfStatement:case g.SyntaxKind.ConditionalExpression:case g.SyntaxKind.ForStatement:case g.SyntaxKind.ForInStatement:case g.SyntaxKind.ForOfStatement:case g.SyntaxKind.WhileStatement:case g.SyntaxKind.DoStatement:case g.SyntaxKind.CatchClause:case g.SyntaxKind.CaseClause:e++;break;case g.SyntaxKind.BinaryExpression:{let i=s.operatorToken.kind;(i===g.SyntaxKind.AmpersandAmpersandToken||i===g.SyntaxKind.BarBarToken||i===g.SyntaxKind.QuestionQuestionToken)&&e++;break}}g.forEachChild(s,r)}return r(t),e}function zt(t,e,r){let s=r?1:1+e,i=r?e:e+1;return s+=R(t.expression,i,!1),s+=R(t.thenStatement,i,!1),t.elseStatement&&(g.isIfStatement(t.elseStatement)?s+=zt(t.elseStatement,e,!0):s+=1+R(t.elseStatement,e+1,!1)),s}function Wt(t,e){let r=1+e;return g.forEachChild(t,s=>{r+=R(s,e+1,!1)}),r}function Br(t,e){let r=1+e;return g.forEachChild(t,s=>{r+=R(s,e,!1)}),r}function $r(t,e){let r=0;return g.forEachChild(t,s=>{r+=R(s,e,!1)}),r}function jr(t){let e=t.operatorToken.kind;return e===g.SyntaxKind.AmpersandAmpersandToken||e===g.SyntaxKind.BarBarToken||e===g.SyntaxKind.QuestionQuestionToken}function R(t,e,r){if(g.isIfStatement(t))return zt(t,e,r);if(g.isForStatement(t)||g.isForInStatement(t)||g.isForOfStatement(t)||g.isWhileStatement(t)||g.isDoStatement(t)||g.isSwitchStatement(t))return Wt(t,e);if(g.isCatchClause(t))return Br(t,e);let s=0;return g.isConditionalExpression(t)&&(s+=1),g.isBinaryExpression(t)&&jr(t)&&(s+=1),e>0&&(g.isFunctionDeclaration(t)||g.isFunctionExpression(t)||g.isArrowFunction(t))?s+Wt(t,e):s+$r(t,e)}function Wr(t){return R(t,0,!1)}function mt(t){return{complexity:Or(t),cognitiveComplexity:Wr(t)}}import S from"typescript";var pt=new Set(["test","describe","it"]);function Kt(t,e){zr(t,e),Vr(t,e),Jr(t,e),qr(t,e)}function zr(t,e){if((S.isFunctionDeclaration(t)||S.isVariableDeclaration(t))&&t.name&&S.isIdentifier(t.name)&&Kr(t)){let r;if(S.isFunctionDeclaration(t))r="function";else{let s=t.initializer;r=s&&(S.isArrowFunction(s)||S.isFunctionExpression(s))?"function":"variable"}e.tags.add({name:t.name.text,kind:r})}}function Kr(t){if(S.isFunctionDeclaration(t))return S.isSourceFile(t.parent);let e=t.parent?.parent;return!!e&&S.isSourceFile(e.parent)}function Vr(t,e){if(!S.isStringLiteral(t))return;let r=t.text.match(/@[\w-]+/g);if(r)for(let s of r)e.tags.add({name:s.substring(1),kind:"comment-marker"})}function Jr(t,e){if(!S.isSourceFile(t))return;let r=/@tag\s+([a-zA-Z0-9_-]+)/g,s=t.getFullText(),i=r.exec(s);for(;i!==null;)i[1]&&e.tags.add({name:i[1],kind:"comment-marker"}),i=r.exec(s)}function qr(t,e){if(S.isCallExpression(t)&&Zr(t.expression))for(let r of t.arguments)S.isObjectLiteralExpression(r)&&Gr(r,e)}function Zr(t){return S.isIdentifier(t)?pt.has(t.text):!!(S.isPropertyAccessExpression(t)&&(pt.has(t.name.text)||S.isIdentifier(t.expression)&&pt.has(t.expression.text)))}function Gr(t,e){for(let r of t.properties){if(!S.isPropertyAssignment(r)||!S.isIdentifier(r.name)||r.name.text!=="tags"&&r.name.text!=="tag")continue;let{initializer:s}=r,i=S.isArrayLiteralExpression(s)?s.elements.filter(S.isStringLiteral):r.name.text==="tag"&&S.isStringLiteral(s)?[s]:[];for(let n of i)e.tags.add({name:n.text.replace(/^@/,""),kind:"comment-marker"})}}function ft(t,e,r){let s=[],i=new Map,n=new Set,o=m.createSourceFile(t,e,m.ScriptTarget.Latest,!0,r==="typescript"?m.ScriptKind.TSX:m.ScriptKind.JSX),a={filePath:t,imports:s,exports:i,tags:n,rawCallEdges:[],sourceFile:o,hasUI:!1,hasTypesOnly:!0,totalStatements:0,exportStatements:0},c=C=>{Xr(C,a),m.forEachChild(C,c)};c(o);let l=li(t,a);(l==="test"||l==="barrel")&&n.add({name:l,kind:"comment-marker"}),l!=="test"&&mi(a,o);let p=o.statements[0],f=p?qt(p):void 0,{complexity:u,cognitiveComplexity:d}=mt(o),h=Hr(o);return{imports:s,exports:Array.from(i.values()),tags:Array.from(n),category:l,rawCallEdges:a.rawCallEdges??[],complexity:u,cognitiveComplexity:d,...h.length>0?{functions:h}:{},...f!==void 0?{description:f}:{}}}function Hr(t){let e=[],r=(i,n)=>{let{complexity:o,cognitiveComplexity:a}=mt(n),c=t.getLineAndCharacterOfPosition(n.getStart(t)).line+1;e.push({name:i,line:c,complexity:o,cognitiveComplexity:a})},s=(i,n)=>{if(m.isFunctionDeclaration(i)&&i.name&&i.body?r(i.name.text,i):m.isVariableDeclaration(i)&&m.isIdentifier(i.name)&&i.initializer&&(m.isArrowFunction(i.initializer)||m.isFunctionExpression(i.initializer))?r(i.name.text,i.initializer):n&&m.isMethodDeclaration(i)&&m.isIdentifier(i.name)&&i.body?r(`${n}.${i.name.text}`,i):n&&m.isConstructorDeclaration(i)&&i.body?r(`${n}.constructor`,i):n&&m.isGetAccessorDeclaration(i)&&m.isIdentifier(i.name)&&i.body?r(`${n}.get ${i.name.text}`,i):n&&m.isSetAccessorDeclaration(i)&&m.isIdentifier(i.name)&&i.body&&r(`${n}.set ${i.name.text}`,i),m.isClassDeclaration(i)&&i.name){let o=i.name.text;m.forEachChild(i,a=>s(a,o));return}m.forEachChild(i,o=>s(o,n))};return s(t,void 0),e}function Jt(t,e,r,s){let i={name:t},n=qt(r);n!==void 0&&(i.doc=n);let o=Ur(e);o!==void 0&&(i.flags=o);let a=Qr(e,s);return a!==void 0&&(i.signature=a),i}function qt(t){let e=m.getJSDocCommentsAndTags(t);for(let r of e)if(m.isJSDoc(r)&&r.comment)return m.getTextOfJSDocComment(r.comment)||void 0}function Ur(t){let e=new Set(["deprecated","internal","public","alpha","beta"]),r=m.getJSDocTags(t).map(s=>s.tagName.text).filter(s=>e.has(s));return r.length>0?r:void 0}function Qr(t,e){let r=m.createPrinter({removeComments:!0}),s=i=>r.printNode(m.EmitHint.Unspecified,i,e);if(m.isFunctionDeclaration(t)||m.isMethodDeclaration(t)){let i=t.parameters.map(s).join(", "),n=t.type?s(t.type):"void";return`${t.typeParameters?`<${t.typeParameters.map(a=>a.name.text).join(", ")}>`:""}(${i}) => ${n}`}if(m.isVariableDeclaration(t)){if(t.type)return s(t.type);if(t.initializer&&(m.isArrowFunction(t.initializer)||m.isFunctionExpression(t.initializer))){let i=t.initializer,n=i.parameters.map(s).join(", "),o=i.type?s(i.type):"unknown";return`(${n}) => ${o}`}return}if(m.isClassDeclaration(t)&&t.name)return`class ${t.name.text}`;if(m.isInterfaceDeclaration(t))return`interface ${t.name.text}`;if(m.isTypeAliasDeclaration(t))return s(t.type);if(m.isEnumDeclaration(t))return`enum ${t.name.text}`}function Xr(t,e){Yr(t,e),ti(t,e),ri(t,e),ii(t,e),ci(t,e),Kt(t,e)}function Yr(t,e){if(!m.isSourceFile(t))return;let r=t.statements.filter(s=>!m.isEmptyStatement(s));e.totalStatements=r.length,e.exportStatements=r.filter(s=>m.isExportDeclaration(s)||m.isExportAssignment(s)||ut(s)).length}function ti(t,e){if(m.isJsxElement(t)||m.isJsxSelfClosingElement(t)||m.isJsxFragment(t)){e.hasUI=!0,e.hasTypesOnly=!1;return}if(m.isFunctionDeclaration(t)||m.isMethodDeclaration(t)||m.isArrowFunction(t)||m.isClassDeclaration(t)||m.isVariableStatement(t)||m.isEnumDeclaration(t)){e.hasTypesOnly=!1;return}m.isExportDeclaration(t)&&!ei(t)&&(e.hasTypesOnly=!1)}function ei(t){return t.isTypeOnly?!0:!t.exportClause||!m.isNamedExports(t.exportClause)?!1:t.exportClause.elements.every(e=>e.isTypeOnly)}function ri(t,e){if(!m.isImportDeclaration(t)||!t.moduleSpecifier||!m.isStringLiteral(t.moduleSpecifier))return;let r=[];if(t.importClause&&(t.importClause.name&&r.push("default"),t.importClause.namedBindings))if(m.isNamedImports(t.importClause.namedBindings))for(let i of t.importClause.namedBindings.elements)r.push(i.name.text);else m.isNamespaceImport(t.importClause.namedBindings)&&r.push("*");let s=r.length>0?"static":"side-effect";e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:t.moduleSpecifier.text,isStyle:N(t.moduleSpecifier.text),type:s,symbols:r.length>0?r:void 0})}function ii(t,e){m.isExportDeclaration(t)?si(t,e):m.isExportAssignment(t)?e.exports.set("default",{name:"default"}):ut(t)&&ai(t,e)}function si(t,e){if(t.moduleSpecifier&&m.isStringLiteral(t.moduleSpecifier))ni(t,t.moduleSpecifier.text,e);else if(t.exportClause&&m.isNamedExports(t.exportClause))for(let r of t.exportClause.elements){let s=r.name.text;e.exports.set(s,{name:s})}}function ni(t,e,r){let s=oi(t),i={fromPath:r.filePath,toPath:"",rawSpecifier:e,isStyle:N(e),type:"re-export"};s.length>0&&(i.symbols=s),r.imports.push(i)}function oi(t){return t.exportClause?m.isNamedExports(t.exportClause)?t.exportClause.elements.map(e=>e.name.text):[]:["*"]}function ai(t,e){if((m.isFunctionDeclaration(t)||m.isClassDeclaration(t)||m.isInterfaceDeclaration(t)||m.isTypeAliasDeclaration(t)||m.isEnumDeclaration(t))&&t.name){let s=t.name.text;e.exports.set(s,Jt(s,t,t,e.sourceFile));return}if(m.isVariableStatement(t)){for(let s of t.declarationList.declarations)if(m.isIdentifier(s.name)){let i=s.name.text;e.exports.set(i,Jt(i,s,t,e.sourceFile))}}}function ci(t,e){if(!m.isCallExpression(t))return;let r=t.arguments[0];!r||!m.isStringLiteral(r)||(t.expression.kind===m.SyntaxKind.ImportKeyword?e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:N(r.text),type:"dynamic"}):m.isIdentifier(t.expression)&&t.expression.text==="require"&&e.imports.push({fromPath:e.filePath,toPath:"",rawSpecifier:r.text,isStyle:N(r.text),type:"require"}))}function li(t,e){let r=Vt.basename(t).toLowerCase(),s=Vt.extname(t).toLowerCase();return at().some(n=>r.includes(n))?"test":jt(r)?"config":e.imports.some(n=>ct().some(o=>n.rawSpecifier.includes(o)))?"test":s===".tsx"||s===".jsx"||e.hasUI?"ui":e.hasTypesOnly&&e.totalStatements>0?"type-only":e.totalStatements>0&&e.exportStatements/e.totalStatements>lt()?"barrel":"logic"}function ut(t){return m.canHaveModifiers(t)&&m.getModifiers(t)?.some(e=>e.kind===m.SyntaxKind.ExportKeyword)===!0}function mi(t,e){let r=t.rawCallEdges??[];t.rawCallEdges=r;let s=new Map;for(let i of e.statements){if(!m.isImportDeclaration(i)||!m.isStringLiteral(i.moduleSpecifier))continue;let n=i.moduleSpecifier.text,o=i.importClause;if(o&&(o.name&&s.set(o.name.text,n),o.namedBindings&&m.isNamedImports(o.namedBindings)))for(let a of o.namedBindings.elements)s.set(a.name.text,n)}if(s.size!==0)for(let i of e.statements){let n=fi(i);if(n){let o=ui(i);o&&U(o,n,s,r);continue}m.isClassDeclaration(i)&&i.name&&pi(i,i.name.text,s,r)}}function pi(t,e,r,s){for(let i of t.members)m.isMethodDeclaration(i)&&i.body&&m.isIdentifier(i.name)?U(i.body,`${e}.${i.name.text}`,r,s):m.isConstructorDeclaration(i)&&i.body&&U(i.body,`${e}.constructor`,r,s)}function fi(t){if(ut(t)){if(m.isFunctionDeclaration(t)&&t.name)return t.name.text;if(m.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(m.isIdentifier(e.name)&&e.initializer&&(m.isArrowFunction(e.initializer)||m.isFunctionExpression(e.initializer)))return e.name.text}}}function ui(t){if(m.isFunctionDeclaration(t))return t.body;if(m.isVariableStatement(t)){for(let e of t.declarationList.declarations)if(e.initializer&&(m.isArrowFunction(e.initializer)||m.isFunctionExpression(e.initializer)))return e.initializer}}function U(t,e,r,s){if(m.isCallExpression(t)&&m.isIdentifier(t.expression)){let i=t.expression.text,n=r.get(i);n&&!s.some(o=>o.from===e&&o.to===i&&o.toSpecifier===n)&&s.push({from:e,to:i,toSpecifier:n})}m.forEachChild(t,i=>U(i,e,r,s))}function Q(t,e){if(e.length===0)return"ui";let r=!1;return t.walk(s=>{if(s.type==="rule")return r=!0,!1}),r?"ui":"barrel"}import Gt from"postcss";import*as gi from"postcss-less";var di=gi,Ht=new Set(["reference","inline"]);function Zt(t){return t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||t.startsWith("data:")}function yi(t){let e=t.trim();return e.length>0&&!e.startsWith("http://")&&!e.startsWith("https://")&&!e.startsWith("//")&&!e.startsWith("data:")&&!e.startsWith("#")}function xi(t,e){let r=t.match(/^\(([^)]+)\)\s+['"]([^'"]+)['"]/);if(r){let n=r[1]?.trim()??"",o=r[2]??"";if(!o)return null;let a=Ht.has(n)?"side-effect":"static";return{fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:a,...Zt(o)?{isExternal:!0}:{}}}let s=t.match(/^url\(['"]?([^'")]+)['"]?\)/),i=s?s[1]?.trim()??"":t.match(/^['"]([^'"]+)['"]/)?.[1]??"";return i?{fromPath:e,toPath:"",rawSpecifier:i,isStyle:!0,type:"static",...Zt(i)?{isExternal:!0}:{}}:null}function hi(t,e){let r=[],s=/url\(['"]?([^'")]+)['"]?\)/g,i=s.exec(t);for(;i!==null;){let n=i[1]?.trim()??"";yi(n)&&r.push({fromPath:e,toPath:"",rawSpecifier:n,isStyle:!0,type:"static"}),i=s.exec(t)}return r}function Ut(t,e){let r=[];return t.walk(s=>{if(s.type==="atrule"&&s.name==="import"){let i=xi(s.params,e);i&&r.push(i)}s.type==="decl"&&r.push(...hi(s.value,e))}),r}function Si(t){return t.replace(/(?<!:)\/\/.*/g,"")}function Ci(t,e){let r=[],s=/@import\s+(?:\(([^)]+)\)\s+)?['"]([^'"]+)['"]/g,i=s.exec(t);for(;i!==null;){let n=i[1]?.trim()??"",o=i[2]??"";if(o){let a=Ht.has(n)?"side-effect":"static";r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:a})}i=s.exec(t)}return r}function Qt(t,e){let r=Gt.parse(Si(t));return{imports:Ut(r,e),root:r}}function bi(t){let e=[],r=[];for(let s of t.nodes??[]){if(s.type!=="atrule")continue;let{value:i}=s;if(i===void 0)continue;let n=s.name;n&&(e.push({name:n}),r.push({name:n,kind:"variable"}))}return{exports:e,tags:r}}function Xt(t,e){try{let r=di.parse(t),{exports:s,tags:i}=bi(r);return{imports:Ut(r,e),root:r,exports:s,tags:i}}catch{return{imports:Ci(t,e),root:Gt.parse(""),exports:[],tags:[]}}}import{parse as Ni}from"postcss-scss";function Yt(t){return t.startsWith("_")||t.startsWith("-")}function Ei(t){return!!(t.startsWith("sass:")||t.startsWith("~")||t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//")||!t.startsWith(".")&&!t.startsWith("/")&&!t.startsWith("_"))}function wi(t){let e=t.match(/^['"]([^'"]+)['"]/);if(!e?.[1])return{specifier:""};let r=e[1],i=t.match(/\bas\s+(\S+)/)?.[1];return i!==void 0?{specifier:r,alias:i}:{specifier:r}}function vi(t){let e=[],r=[];for(let s of t.nodes??[]){if(s.type==="decl"&&s.prop.startsWith("$")){let i=s.prop.slice(1);if(!i||Yt(i))continue;e.push({name:i}),r.push({name:i,kind:"variable"});continue}if(s.type==="atrule"&&(s.name==="mixin"||s.name==="function")){let n=s.params.match(/^([\w-]+)/)?.[1];if(!n||Yt(n))continue;let o=s.params.trim();e.push(o.includes("(")?{name:n,signature:o}:{name:n}),r.push({name:n,kind:"function"})}}return{exports:e,tags:r}}function te(t,e){let r=Ni(t),s=[];r.walk(o=>{if(o.type!=="atrule")return;let{name:a,params:c}=o;if(a!=="import"&&a!=="use"&&a!=="forward")return;let{specifier:l,alias:p}=wi(c);if(!l)return;let f={fromPath:e,toPath:"",rawSpecifier:l,isStyle:!0,type:a==="forward"?"re-export":"static",...Ei(l)?{isExternal:!0}:{}};p&&(f.symbols=[p]),s.push(f)});let{exports:i,tags:n}=vi(r);return{imports:s,root:r,exports:i,tags:n}}function ee(t,e){let r=[],s=/@require\s+['"]([^'"]+)['"]/g,i=s.exec(t);for(;i!==null;){let o=i[1];o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"require"}),i=s.exec(t)}let n=/(?<!@)(?:import|require)\s*\(?\s*['"]([^'"]+)['"]/g;for(i=n.exec(t);i!==null;){let o=i[1];o&&r.push({fromPath:e,toPath:"",rawSpecifier:o,isStyle:!0,type:"static"}),i=n.exec(t)}return r}function re(t,e){if(e.length===0)return"ui";try{let r=se("stylus");return new r.Parser(t).parse().nodes.some(n=>n.constructor.name!=="Import")?"ui":"barrel"}catch{return t.replace(/^\s*@?(?:require|import)\b.*/gm,"").trim().length>0?"ui":"barrel"}}function Z(t,e){let r=V(t);if(r==="stylus"){let n=ee(e,t);return{imports:n,exports:[],tags:[],category:re(e,n)}}if(r==="scss"){let{imports:n,root:o,exports:a,tags:c}=te(e,t);return{imports:n,exports:a,tags:c,category:Q(o,n)}}if(r==="less"){let{imports:n,root:o,exports:a,tags:c}=Xt(e,t);return{imports:n,exports:a,tags:c,category:Q(o,n)}}let{imports:s,root:i}=Qt(e,t);return{imports:s,exports:[],tags:[],category:Q(i,s)}}for(let[t,e]of[["javascript",(r,s)=>ft(r,s,"javascript")],["typescript",(r,s)=>ft(r,s,"typescript")],["css",Z],["scss",Z],["less",Z],["stylus",Z],["coffeescript",xt],["livescript",Dt],["lua",At],["python",Bt],["go",wt],["java",Pt],["kotlin",Ft],["scala",$t],["groovy",vt],["gherkin",Y],["markdown",Mt]])J(t,e);async function ie(t,e){let r=V(t),s=St(r);return s?s(t,e):{imports:[],exports:[],tags:[],category:"other"}}function ki(t){return ie(t.filePath,t.content)}export{ki as default};
3
7
  //# sourceMappingURL=parse-worker.mjs.map