routeweb 0.1.1 → 0.1.3
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/index.js +42 -5
- package/dist/public/assets/{SearchModal-B0C7wJfG.js → SearchModal-FE7UTYzy.js} +1 -1
- package/dist/public/assets/{TesterDrawer-7pr3VKRs.js → TesterDrawer--T5ETDwa.js} +1 -1
- package/dist/public/assets/index-MvsnPaMs.js +36 -0
- package/dist/public/index.html +1 -1
- package/package.json +2 -2
- package/dist/public/assets/index-Co71Z6SJ.js +0 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "routeweb",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Zero-config static API route mapper, 60fps visualizer, OpenAPI generator, and MCP server for 6 languages.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@types/node": "^22.13.10",
|
|
42
42
|
"tsup": "^8.4.0",
|
|
43
43
|
"typescript": "^5.8.2",
|
|
44
|
-
"@routeweb/core": "0.1.
|
|
44
|
+
"@routeweb/core": "0.1.3"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "tsup",
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SearchModal-B0C7wJfG.js","assets/react-D71YmLB6.js","assets/vendor-DBc_8COV.js","assets/graph-Dp3lBNo7.js","assets/TesterDrawer-7pr3VKRs.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var gn=Object.defineProperty;var xn=(n,t,r)=>t in n?gn(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var ue=(n,t,r)=>xn(n,typeof t!="symbol"?t+"":t,r);import{a as X,j as L,b as bn}from"./react-D71YmLB6.js";import{f as Ie,P as Fe,p as wn,S as vn,w as En,T as $n,_ as jn,U as Sn,R as An,r as Pn,C as _n}from"./graph-Dp3lBNo7.js";import{_ as nt,l as Nn,P as kn,M as Mn,g as Tn,L as Cn,S as ut,C as In,F as Fn,h as Rn,j as zn,k as On,m as Dn,E as Ln,n as Zn,N as rn,G as qn,o as Gn,q as Wn,r as Hn,K as Bn,W as Un,w as Vn,R as Kn,x as Jn,y as Yn}from"./vendor-DBc_8COV.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const u of document.querySelectorAll('link[rel="modulepreload"]'))s(u);new MutationObserver(u=>{for(const f of u)if(f.type==="childList")for(const E of f.addedNodes)E.tagName==="LINK"&&E.rel==="modulepreload"&&s(E)}).observe(document,{childList:!0,subtree:!0});function r(u){const f={};return u.integrity&&(f.integrity=u.integrity),u.referrerPolicy&&(f.referrerPolicy=u.referrerPolicy),u.crossOrigin==="use-credentials"?f.credentials="include":u.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function s(u){if(u.ep)return;u.ep=!0;const f=r(u);fetch(u.href,f)}})();const Xn="modulepreload",Qn=function(n){return"/"+n},_t={},on=function(t,r,s){let u=Promise.resolve();if(r&&r.length>0){let E=function($){return Promise.all($.map(A=>Promise.resolve(A).then(j=>({status:"fulfilled",value:j}),j=>({status:"rejected",reason:j}))))};document.getElementsByTagName("link");const x=document.querySelector("meta[property=csp-nonce]"),b=(x==null?void 0:x.nonce)||(x==null?void 0:x.getAttribute("nonce"));u=E(r.map($=>{if($=Qn($),$ in _t)return;_t[$]=!0;const A=$.endsWith(".css"),j=A?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${$}"]${j}`))return;const w=document.createElement("link");if(w.rel=A?"stylesheet":Xn,A||(w.as="script"),w.crossOrigin="",w.href=$,b&&w.setAttribute("nonce",b),document.head.appendChild(w),A)return new Promise((M,D)=>{w.addEventListener("load",M),w.addEventListener("error",()=>D(new Error(`Unable to preload CSS for ${$}`)))})}))}function f(E){const x=new Event("vite:preloadError",{cancelable:!0});if(x.payload=E,window.dispatchEvent(x),!x.defaultPrevented)throw E}return u.then(E=>{for(const x of E||[])x.status==="rejected"&&f(x.reason);return t().catch(f)})};function an(n){return n.replace(/\\/g,"/").replace(/\/+/g,"/")}function oe(n){const r=an(n).split("/"),s=[];for(const u of r)!u||u==="."||(u===".."?s.length>0&&s[s.length-1]!==".."&&s.pop():s.push(u));return s.join("/")}function Re(n){const t=an(n),r=t.lastIndexOf("/");return r<=0?"":t.slice(0,r)}function le(...n){return oe(n.filter(Boolean).join("/"))}function ne(n,t){const r=n==="/"?"":n.replace(/\/+$/,""),s=t==="/"?"":t.replace(/^\/+/,"");if(!r&&!s)return"/";if(!r)return"/"+s;if(!s)return r.startsWith("/")?r:"/"+r;const u=`${r}/${s}`.replace(/\/+/g,"/");return u.startsWith("/")?u:"/"+u}function fe(n){const t=[],r=/:([A-Za-z0-9_]+)/g;let s;for(;(s=r.exec(n))!==null;)t.includes(s[1])||t.push(s[1]);return t}function me(n){const t=n.split("/").filter(Boolean);return t.length===0?"/":t[0].toLowerCase()==="api"&&t.length>=2&&/^v\d+$/i.test(t[1])&&t.length>=3?`/api/${t[1]}/${t[2]}`:t[0].toLowerCase()==="api"&&t.length>=2?`/api/${t[1]}`:`/${t[0]}`}var Nt=[".ts",".tsx",".js",".jsx",".mjs",".cjs"];function es(n){let t="",r=!1,s=!1,u=0;for(;u<n.length;){const f=n[u],E=n[u+1];if(r){t+=f,s?s=!1:f==="\\"?s=!0:f==='"'&&(r=!1),u++;continue}if(f==='"'){r=!0,t+=f,u++;continue}if(f==="/"&&E==="/"){for(;u<n.length&&n[u]!==`
|
|
3
|
-
`;)u++;continue}if(f==="/"&&E==="*"){for(u+=2;u<n.length&&!(n[u]==="*"&&n[u+1]==="/");)u++;u+=2;continue}t+=f,u++}return t.replace(/,\s*([}\]])/g,"$1")}function ct(n){if(typeof n=="string")return[n];if(Array.isArray(n))return n.flatMap(ct);if(n&&typeof n=="object"){const t=n,r=["import","node","default","require"],s=[];for(const u of r)u in t&&s.push(...ct(t[u]));for(const[u,f]of Object.entries(t))r.includes(u)||s.push(...ct(f));return s}return[]}function et(n){const t=new Map;for(const r of n){const s=oe(r.path);if(s==="tsconfig.json"||s.endsWith("/tsconfig.json"))try{const u=JSON.parse(es(r.content));if(u.compilerOptions){const f=Re(s),E=t.get(f);t.set(f,{baseDir:f,baseUrl:u.compilerOptions.baseUrl,paths:u.compilerOptions.paths,packageImports:E==null?void 0:E.packageImports})}}catch{}else if(s==="package.json"||s.endsWith("/package.json"))try{const u=JSON.parse(r.content);if(u.imports&&typeof u.imports=="object"){const f=Re(s),E={};for(const[x,b]of Object.entries(u.imports)){const $=ct(b);$.length>0&&(E[x]=$)}if(Object.keys(E).length>0){const x=t.get(f);t.set(f,{baseDir:f,baseUrl:x==null?void 0:x.baseUrl,paths:x==null?void 0:x.paths,packageImports:E})}}}catch{}}return t}function ts(n,t){let r=Re(oe(n));for(;;){const s=t.get(r);if(s)return s;if(!r)break;r=Re(r)}return t.get("")}function st(n,t){const r=oe(n);if(t.has(r))return r;const s=r.match(/\.(m|c)?jsx?$/);if(s){const u=r.slice(0,-s[0].length);for(const f of[".ts",".tsx",".mts",".cts"])if(t.has(u+f))return u+f}for(const u of Nt)if(t.has(r+u))return r+u;for(const u of Nt){const f=le(r,`index${u}`);if(t.has(f))return f}return null}function Ce(n,t,r,s){if(!t)return null;if(t.startsWith(".")){const b=Re(n),$=le(b,t);return st($,r)}const u=s instanceof Map?ts(n,s):s;if(!u)return null;const f=(b,$)=>{if(!b)return null;for(const[A,j]of Object.entries(b))if(A.includes("*")){const[w,M]=A.split("*");if(t.startsWith(w)&&t.endsWith(M)){const D=t.slice(w.length,t.length-M.length);for(const P of j){const q=P.replace("*",D),B=$?le($,q):oe(q),V=st(B,r);if(V)return V}}}else if(t===A)for(const w of j){const M=$?le($,w):oe(w),D=st(M,r);if(D)return D}return null};if(t.startsWith("#")&&u.packageImports){const b=f(u.packageImports,u.baseDir);if(b)return b}const E=u.baseUrl?le(u.baseDir,u.baseUrl):u.baseDir,x=f(u.paths,E);if(x)return x;if(u.baseUrl){const b=le(E,t),$=st(b,r);if($)return $}return null}function ns(n){var j;const t=n.nodes.filter(w=>w.type==="route"),r=((j=n.metadata.unresolved)==null?void 0:j.length)??n.metadata.unresolvedMounts.length;if(t.length===0){const w=`# ${n.metadata.repoName} (${n.metadata.framework})
|
|
4
|
-
No routes detected across ${n.metadata.scannedFiles} files.`;return r>0?`${w}
|
|
5
|
-
|
|
6
|
-
⚠ ${r} route-like calls could not be fully resolved (run with --debug for details)`:w}const s=[],u=n.metadata.detectedPort?` | port: ${n.metadata.detectedPort}`:"";s.push(`# ${n.metadata.repoName} (${n.metadata.framework} | ${t.length} routes | ${n.metadata.scannedFiles} files${u})`);const f=new Map;for(const w of t)for(const M of w.middlewares??[])f.set(M,(f.get(M)??0)+1);const E=Math.max(2,Math.ceil(t.length*.8)),x=new Set(Array.from(f.entries()).filter(([,w])=>w>=E).map(([w])=>w));x.size>0&&s.push(`# Global middleware: [${Array.from(x).join(", ")}]`);const b=[...t].sort((w,M)=>{const D=(w.fullPath??"").localeCompare(M.fullPath??"");return D!==0?D:(w.method??"").localeCompare(M.method??"")}),$=b.map(w=>`${(w.method??"GET").padEnd(6)} ${w.fullPath??"/"}`),A=Math.min(48,Math.max(...$.map(w=>w.length)));for(let w=0;w<b.length;w++){const M=b[w],D=$[w].padEnd(A),P=(M.middlewares??[]).filter(v=>!x.has(v)),q=P.length>0?`[${P.join(", ")}]`:"[]",B=`${M.controller??"handler"} (${M.controllerFile??M.file}:${M.controllerLine??M.line})`,V=[];M.pathParams&&M.pathParams.length>0&&V.push(`params: {${M.pathParams.join(", ")}}`),M.queryParams&&M.queryParams.length>0&&V.push(`query: {${M.queryParams.join(", ")}}`),M.bodyFields&&M.bodyFields.length>0&&V.push(`body: {${M.bodyFields.join(", ")}}`),M.partial&&V.push("partial: prefix may be missing");const T=V.length>0?` | ${V.join(" | ")}`:"";s.push(`${D} -> ${q} -> ${B}${T}`)}return r>0&&(s.push(""),s.push(`⚠ ${r} route-like calls could not be fully resolved (run with --debug for details)`)),s.join(`
|
|
7
|
-
`)}var ss=["auth","authenticate","isauthenticated","requireauth","verifyjwt","jwt","protect","guard","authguard","permission","preauthorize","secured","rolesallowed","login_required","depends","bearer"];typeof nt=="function"?nt:nt.default??nt;function rs(n){try{return Nn.parse(n,{sourceType:"unambiguous",errorRecovery:!0,plugins:["typescript","jsx","decorators-legacy","classProperties","classPrivateProperties","classPrivateMethods","dynamicImport","optionalChaining","nullishCoalescingOperator","topLevelAwait"]})}catch{return null}}function ge(n){return n?n.type==="Identifier"?n.name:n.type==="StringLiteral"?n.value:null:null}function We(n,t,r){var j,w,M,D,P,q,B,V,T,v,p,c,y,m,e,l,d,i;const s=rs(n.content);if(!s)return null;const u=new Map,f=new Map,E=[],x=new Map,b=new Set,$=(o,a,h)=>{a==="express"&&(h==="default"||h==="*")&&b.add(o),u.set(o,{localName:o,sourceSpecifier:a,resolvedFile:Ce(n.path,a,t,r),importedName:h})};for(const o of s.program.body)if(o.type==="ImportDeclaration"){const a=o.source.value;for(const h of o.specifiers)if(h.type==="ImportDefaultSpecifier")$(h.local.name,a,"default");else if(h.type==="ImportNamespaceSpecifier")$(h.local.name,a,"*");else if(h.type==="ImportSpecifier"){const g=ge(h.imported)??h.local.name;$(h.local.name,a,g)}}else if(o.type==="ExportNamedDeclaration"){if(o.source){const a=Ce(n.path,o.source.value,t,r);for(const h of o.specifiers)if(h.type==="ExportSpecifier"){const g=ge(h.exported)??"",N=ge(h.local)??g;E.push({resolvedFile:a,exportedName:g,importedName:N})}}else if(o.declaration){const a=o.declaration;if(a.type==="FunctionDeclaration"&&a.id)x.set(a.id.name,a),f.set(a.id.name,{name:a.id.name,node:a,line:((j=a.loc)==null?void 0:j.start.line)??1});else if(a.type==="ClassDeclaration"&&a.id)x.set(a.id.name,a),f.set(a.id.name,{name:a.id.name,node:a,line:((w=a.loc)==null?void 0:w.start.line)??1});else if(a.type==="VariableDeclaration")for(const h of a.declarations)h.id.type==="Identifier"&&h.init&&(x.set(h.id.name,h.init),f.set(h.id.name,{name:h.id.name,node:h.init,line:((M=h.loc)==null?void 0:M.start.line)??1}))}else for(const a of o.specifiers)if(a.type==="ExportSpecifier"){const h=a.local.name,g=ge(a.exported)??h,N=x.get(h);N?f.set(g,{name:g,node:N,line:((D=N.loc)==null?void 0:D.start.line)??((P=a.loc)==null?void 0:P.start.line)??1}):f.set(g,{name:g,node:a.local,line:((q=a.loc)==null?void 0:q.start.line)??1})}}else if(o.type==="ExportAllDeclaration"){const a=Ce(n.path,o.source.value,t,r);E.push({resolvedFile:a,exportedName:"*",importedName:"*"})}else if(o.type==="ExportDefaultDeclaration"){const a=o.declaration;if(a.type==="Identifier"){const h=x.get(a.name)??a;f.set("default",{name:"default",localName:a.name,node:h,line:((B=h.loc)==null?void 0:B.start.line)??((V=o.loc)==null?void 0:V.start.line)??1})}else f.set("default",{name:"default",node:a,line:((T=a.loc)==null?void 0:T.start.line)??((v=o.loc)==null?void 0:v.start.line)??1})}else if(o.type==="FunctionDeclaration"&&o.id)x.set(o.id.name,o);else if(o.type==="ClassDeclaration"&&o.id)x.set(o.id.name,o);else if(o.type==="VariableDeclaration")for(const a of o.declarations){if(!a.init)continue;const h=ze(a.init);if(h){if(a.id.type==="Identifier")$(a.id.name,h,"default");else if(a.id.type==="ObjectPattern"){for(const g of a.id.properties)if(g.type==="ObjectProperty"){const N=ge(g.key),S=g.value.type==="Identifier"?g.value.name:N;N&&S&&$(S,h,N)}}}else a.id.type==="Identifier"&&x.set(a.id.name,a.init)}else if(o.type==="ExpressionStatement"&&o.expression.type==="AssignmentExpression"){const{left:a,right:h}=o.expression;if(a.type==="MemberExpression"){const g=a.object.type==="Identifier"?a.object.name:null,N=ge(a.property);if(g==="module"&&N==="exports"){const S=h.type==="Identifier"?h.name:void 0,R=h.type==="Identifier"?x.get(h.name)??h:h;if(f.set("default",{name:"default",localName:S,node:R,line:((p=R.loc)==null?void 0:p.start.line)??((c=o.loc)==null?void 0:c.start.line)??1}),R.type==="ObjectExpression"){for(const O of R.properties)if(O.type==="ObjectProperty"){const z=ge(O.key);if(z){const G=O.value.type==="Identifier"?x.get(O.value.name)??O.value:O.value;f.set(z,{name:z,node:G,line:((y=G.loc)==null?void 0:y.start.line)??((m=O.loc)==null?void 0:m.start.line)??1})}}}}else if(g==="exports"&&N){const S=h.type==="Identifier"?x.get(h.name)??h:h;f.set(N,{name:N,node:S,line:((e=S.loc)==null?void 0:e.start.line)??((l=o.loc)==null?void 0:l.start.line)??1})}else if(a.object.type==="MemberExpression"&&a.object.object.type==="Identifier"&&a.object.object.name==="module"&&ge(a.object.property)==="exports"&&N){const S=h.type==="Identifier"?x.get(h.name)??h:h;f.set(N,{name:N,node:S,line:((d=S.loc)==null?void 0:d.start.line)??((i=o.loc)==null?void 0:i.start.line)??1})}}}const A=o=>{if(!(!o||typeof o!="object")){if(o.type==="VariableDeclarator"&&o.init){const a=ze(o.init);if(a){if(o.id.type==="Identifier"&&!u.has(o.id.name))$(o.id.name,a,"default");else if(o.id.type==="ObjectPattern"){for(const h of o.id.properties)if(h.type==="ObjectProperty"){const g=ge(h.key),N=h.value.type==="Identifier"?h.value.name:g;g&&N&&!u.has(N)&&$(N,a,g)}}}}for(const a of Object.keys(o)){if(a==="loc"||a==="start"||a==="end"||a==="extra")continue;const h=o[a];if(Array.isArray(h))for(const g of h)g&&typeof g=="object"&&"type"in g&&A(g);else h&&typeof h=="object"&&"type"in h&&A(h)}}};return A(s.program),{path:n.path,ast:s,imports:u,exports:f,reExports:E,locals:x,expressImports:b}}function ze(n){var t;return n.type==="CallExpression"&&n.callee.type==="Identifier"&&n.callee.name==="require"&&((t=n.arguments[0])==null?void 0:t.type)==="StringLiteral"?n.arguments[0].value:n.type==="MemberExpression"?ze(n.object):null}function ln(n,t=0){if(t>3||n.type==="FunctionDeclaration"||n.type==="FunctionExpression"||n.type==="ArrowFunctionExpression"||n.type==="ObjectMethod"||n.type==="ClassMethod")return n;if(n.type==="CallExpression"){for(const r of n.arguments)if(r.type==="FunctionExpression"||r.type==="ArrowFunctionExpression")return r;for(const r of n.arguments)if(r.type!=="SpreadElement"){const s=ln(r,t+1);if(s!==r)return s}}return n}function Pt(n){const t=new Set,r=new Set,s=new Set,u=ln(n);if(u.type!=="FunctionDeclaration"&&u.type!=="FunctionExpression"&&u.type!=="ArrowFunctionExpression"&&u.type!=="ObjectMethod"&&u.type!=="ClassMethod")return{pathParams:[],queryParams:[],bodyFields:[]};let f="req";const E=u.params[0];(E==null?void 0:E.type)==="Identifier"&&(f=E.name);const x=(j,w)=>{w&&!w.startsWith("_")&&j.add(w)},b=j=>{if(j.type==="LogicalExpression")return b(j.left);if(j.type==="MemberExpression"&&j.object.type==="Identifier"&&j.object.name===f){const w=ge(j.property);if(w==="params"||w==="query"||w==="body")return w}return null},$=j=>j==="params"?t:j==="query"?r:s,A=j=>{if(!(!j||typeof j!="object")){if(j.type==="MemberExpression"){const w=b(j.object);if(w){const M=ge(j.property);x($(w),M)}}if(j.type==="VariableDeclarator"&&j.init&&j.id.type==="ObjectPattern"){const w=b(j.init);if(w){const M=$(w);for(const D of j.id.properties)D.type==="ObjectProperty"&&x(M,ge(D.key))}}for(const w of Object.keys(j)){if(w==="loc"||w==="start"||w==="end"||w==="extra")continue;const M=j[w];if(Array.isArray(M))for(const D of M)D&&typeof D=="object"&&"type"in D&&A(D);else M&&typeof M=="object"&&"type"in M&&A(M)}}};return A(u.body),{pathParams:Array.from(t),queryParams:Array.from(r),bodyFields:Array.from(s)}}var _e=new Set(["get","post","put","patch","delete","options","head","all"]),dt=/\.(ts|tsx|js|jsx|mjs|cjs)$/i,cn=/(\.test\.|\.spec\.|__tests__|__mocks__)/i;function de(n){let t=n;for(;t.type==="TSAsExpression"||t.type==="TSSatisfiesExpression"||t.type==="TSTypeAssertion"||t.type==="ParenthesizedExpression";)t=t.expression;return t}function ie(n){return n?n.type==="Identifier"?n.name:n.type==="StringLiteral"?n.value:null:null}function Ge(n){if(n.type==="Identifier")return n.name;if(n.type==="MemberExpression"){const t=Ge(n.object),r=ie(n.property)??"";return t?`${t}.${r}`:r}return n.type==="CallExpression"?Ge(n.callee):"anonymous"}function os(n,t){for(const r of n){const s=oe(r.path);if(s===".env"||s===".env.example"){const u=r.content.match(/^\s*PORT\s*=\s*(\d+)/m);if(u)return Number(u[1])}}for(const r of t)r.ast.program.body.map(s=>s).length;for(const r of n){if(!dt.test(r.path))continue;const s=r.content.match(/\.listen\(\s*(\d{2,5})\b/);if(s)return Number(s[1]);const u=r.content.match(/\b(?:PORT|port)\b\s*=\s*(?:process\.env\.PORT\s*\|\|\s*)?(\d{2,5})\b/);if(u)return Number(u[1])}}function is(n){const{fileSet:t,tsConfig:r,parsedMap:s}=n,u=(x,b,$=0)=>{var A,j,w,M,D,P,q,B,V,T;if($>8)return null;if(b.type==="Identifier"){const v=x.imports.get(b.name);if(v&&v.resolvedFile){const c=s.get(v.resolvedFile);if(!c)return null;if(v.importedName==="*")return{file:c,node:c.ast.program,name:b.name,line:1};const y=c.exports.get(v.importedName);if(y)return y.node.type==="Identifier"&&y.node.name!==b.name?u(c,y.node,$+1)??{file:c,node:y.node,name:v.importedName,line:y.line}:{file:c,node:y.node,name:v.importedName==="default"?b.name:v.importedName,localName:y.localName,line:y.line};for(const m of c.reExports)if(m.resolvedFile&&(m.exportedName==="*"||m.exportedName===v.importedName)){const e=s.get(m.resolvedFile);if(e){const l=m.exportedName==="*"?v.importedName:m.importedName,d=e.exports.get(l);if(d)return d.node.type==="Identifier"&&d.node.name!==l?u(e,d.node,$+1)??{file:e,node:d.node,name:l,localName:d.localName,line:d.line}:{file:e,node:d.node,name:l,localName:d.localName,line:d.line}}}return v.importedName==="default"&&c.exports.size>0?{file:c,node:c.ast.program,name:b.name,line:1}:null}const p=x.locals.get(b.name);return p?{file:x,node:p,name:b.name,line:((A=p.loc)==null?void 0:A.start.line)??1}:null}if(b.type==="MemberExpression"){const v=ie(b.property);if(!v)return null;if(b.object.type==="ThisExpression")for(const l of x.locals.values()){const d=de(l);if(d.type==="ClassDeclaration"||d.type==="ClassExpression")for(const i of d.body.body){if((i.type==="ClassMethod"||i.type==="ClassProperty")&&ie(i.key)===v){const o=i.type==="ClassProperty"&&i.value?i.value:i;return{file:x,node:o,name:`${((j=d.id)==null?void 0:j.name)??"this"}.${v}`,line:((w=i.loc)==null?void 0:w.start.line)??1}}if(i.type==="ClassMethod"){for(const o of i.body.body)if(o.type==="ExpressionStatement"&&o.expression.type==="AssignmentExpression"&&o.expression.left.type==="MemberExpression"&&o.expression.left.object.type==="ThisExpression"&&ie(o.expression.left.property)===v){const a=o.expression.right,h=a.type==="NewExpression"?u(x,a.callee,$+1):null;return h||{file:x,node:a,name:`${((M=d.id)==null?void 0:M.name)??"this"}.${v}`,line:((D=o.loc)==null?void 0:D.start.line)??1}}}}}const p=ze(b.object);if(p){const l=Ce(x.path,p,t,r);if(l){const d=s.get(l),i=d==null?void 0:d.exports.get(v);if(d&&i)return{file:d,node:i.node,name:v,line:i.line}}}const c=u(x,b.object,$+1);if(!c)return null;let y=c,m=de(y.node);if(m.type==="NewExpression"){const l=u(y.file,m.callee,$+1);l&&(y=l,m=de(l.node))}if(m.type==="ClassDeclaration"||m.type==="ClassExpression"){if(v==="router")return{file:y.file,node:m,name:y.name,line:((P=m.loc)==null?void 0:P.start.line)??1};let l={file:y.file,node:m,name:y.name},d=0;for(;l&&d<5;){for(const i of l.node.body.body)if((i.type==="ClassMethod"||i.type==="ClassProperty")&&ie(i.key)===v){const o=i.type==="ClassProperty"&&i.value?i.value:i;return{file:l.file,node:o,name:`${l.name}.${v}`,line:((q=i.loc)==null?void 0:q.start.line)??1}}if(l.node.superClass){const i=u(l.file,l.node.superClass,$+1+d),o=i?de(i.node):null;if(i&&o&&(o.type==="ClassDeclaration"||o.type==="ClassExpression")){l={file:i.file,node:o,name:i.name},d++;continue}}l=null}}if(m.type==="Program"){const l=c.file.exports.get(v);if(l)return{file:c.file,node:l.node,name:`${c.name}.${v}`,line:l.line}}if(m.type==="ObjectExpression")for(const l of m.properties){if(l.type==="ObjectProperty"&&ie(l.key)===v){if(l.value.type==="Identifier"||l.value.type==="MemberExpression"){const i=u(c.file,l.value,$+1);if(i)return i}const d=l.value.type==="Identifier"?c.file.locals.get(l.value.name)??l.value:l.value;return{file:c.file,node:d,name:`${c.name}.${v}`,line:((B=d.loc)==null?void 0:B.start.line)??((V=l.loc)==null?void 0:V.start.line)??1}}if(l.type==="ObjectMethod"&&ie(l.key)===v)return{file:c.file,node:l,name:`${c.name}.${v}`,line:((T=l.loc)==null?void 0:T.start.line)??1}}const e=c.file.exports.get(v);if(e){if(e.node.type==="Identifier"){const l=u(c.file,e.node,$+1);if(l)return l}return{file:c.file,node:e.node,name:`${c.name}.${v}`,localName:e.localName,line:e.line}}}if(b.type==="NewExpression")return u(x,b.callee,$+1);if(b.type==="CallExpression"){if(b.callee.type==="MemberExpression"&&b.callee.object.type==="Identifier"&&b.callee.object.name==="Object"&&ie(b.callee.property)==="assign"&&b.arguments[0]&&b.arguments[0].type!=="SpreadElement")return u(x,b.arguments[0],$+1);if(b.callee.type==="MemberExpression"&&ie(b.callee.property)==="bind")return u(x,b.callee.object,$+1);let v=ze(b);if(!v&&b.callee.type==="Identifier"&&b.callee.name==="require"&&b.arguments[0]){const c=b.arguments[0],y=f(x,c);if(y)v=y;else if(c.type==="CallExpression"&&c.callee.type==="MemberExpression"&&ie(c.callee.property)==="join"){const m=[];for(const e of c.arguments)if(e.type==="Identifier"&&e.name==="__dirname")m.push(".");else{const l=f(x,e);l!==null&&m.push(l)}m.length>0&&(v=m.join("/"))}}if(v){const c=Ce(x.path,v,t,r);if(c){const y=s.get(c);if(y){const m=y.exports.get("default");if(m)return m.node.type==="CallExpression"&&m.node.callee.type==="MemberExpression"&&m.node.callee.object.type==="Identifier"&&m.node.callee.object.name==="Object"&&ie(m.node.callee.property)==="assign"&&m.node.arguments[0]?u(y,m.node.arguments[0],$+1)??{file:y,node:m.node,name:v,localName:m.localName,line:m.line}:{file:y,node:m.node,name:v,localName:m.localName,line:m.line}}}}const p=u(x,b.callee,$+1);if(p&&(p.node.type==="FunctionDeclaration"||p.node.type==="FunctionExpression"||p.node.type==="ArrowFunctionExpression"))return p}return null},f=(x,b,$=0)=>{if(!b||$>8)return null;const A=de(b);if(A.type==="StringLiteral")return A.value;if(A.type==="NumericLiteral")return String(A.value);if(A.type==="RegExpLiteral")return`/${A.pattern}/`;if(A.type==="TemplateLiteral"){let j="";for(let w=0;w<A.quasis.length;w++)if(j+=A.quasis[w].value.cooked??A.quasis[w].value.raw,w<A.expressions.length){const M=f(x,A.expressions[w],$+1);if(M===null)return null;j+=M}return j}if(A.type==="BinaryExpression"&&A.operator==="+"){const j=f(x,A.left,$+1),w=f(x,A.right,$+1);return j!==null&&w!==null?j+w:null}if(A.type==="Identifier"||A.type==="MemberExpression"){const j=u(x,A);if(j)return f(j.file,j.node,$+1)}return null};return{resolveSymbol:u,resolveStringExpr:f,resolveStringOrArrayValues:(x,b)=>{if(!b)return null;const $=de(b),A=f(x,$);if(A!==null)return[A];if($.type==="ArrayExpression"){const j=[];for(const w of $.elements)if(w&&w.type!=="SpreadElement"){const M=f(x,w);M!==null&&j.push(M)}return j.length>0?j:null}return null}}}function as(n,t){const{fileSet:r}=n,{resolveSymbol:s,resolveStringExpr:u,resolveStringOrArrayValues:f}=t,E=(A,j)=>{var M;let w=j;for(;w.type==="CallExpression"&&w.callee.type==="MemberExpression";){const D=ie(w.callee.property);if(D==="Router"&&w.callee.object.type==="Identifier"&&A.expressImports.has(w.callee.object.name))return!0;if(D==="use"||D==="route"||_e.has(D??"")){w=w.callee.object;continue}break}if(w.type==="CallExpression"){const D=w.callee;if(D.type==="Identifier"&&D.name==="Router"&&((M=A.imports.get("Router"))==null?void 0:M.sourceSpecifier)==="express"||D.type==="MemberExpression"&&D.object.type==="Identifier"&&A.expressImports.has(D.object.name)&&ie(D.property)==="Router")return!0}return!1},x=new Map,b=A=>{const j=x.get(A.path);if(j)return j;const w=new Set,M=new Set,D=(V,T)=>{if(!T)return;const v=de(T);if(v.type==="CallExpression"){const p=v.callee;p.type==="Identifier"&&A.expressImports.has(p.name)?w.add(V):E(A,v)&&M.add(V)}};for(const[V,T]of A.locals.entries())D(V,T);const P=V=>{if(!(!V||typeof V!="object")){if(V.type==="VariableDeclarator"&&V.id.type==="Identifier"&&V.init)D(V.id.name,V.init);else if(V.type==="AssignmentExpression"&&V.left.type==="MemberExpression"&&V.left.object.type==="ThisExpression"){const T=ie(V.left.property);T&&D(`this.${T}`,V.right)}else if(V.type==="ClassProperty"&&V.value){const T=ie(V.key);T&&D(`this.${T}`,V.value)}for(const T of Object.keys(V)){if(T==="loc"||T==="start"||T==="end"||T==="extra")continue;const v=V[T];if(Array.isArray(v))for(const p of v)p&&typeof p=="object"&&"type"in p&&P(p);else v&&typeof v=="object"&&"type"in v&&P(v)}}};P(A.ast.program);const q=A.exports.get("default");q&&E(A,q.node)&&M.add("__default_router__");const B={apps:w,routers:M};return x.set(A.path,B),B},$=(A,j,w,M)=>{const D=[],P=p=>{var c;if(!M)return p;if(p.type==="Identifier"&&((c=M.identMap)!=null&&c.has(p.name)))return M.identMap.get(p.name);if(M.computedPropMap&&p.type==="MemberExpression"&&p.computed&&p.property.type==="Identifier"&&M.computedPropMap.has(p.property.name))return M.computedPropMap.get(p.property.name);if(p.type==="BinaryExpression"&&p.operator==="+"){const y=P(p.left),m=P(p.right);if(y!==p.left||m!==p.right)return{...p,left:y,right:m}}if(p.type==="CallExpression"&&p.callee.type==="Identifier"&&p.callee.name==="require"&&p.arguments[0]){const y=P(p.arguments[0]);if(y!==p.arguments[0])return{...p,arguments:[y,...p.arguments.slice(1)]}}if(M.paramName&&M.props&&p.type==="MemberExpression"&&p.object.type==="Identifier"&&p.object.name===M.paramName){const y=ie(p.property);if(y&&M.props.has(y))return M.props.get(y)}return p},q=(p,c,y)=>{var l,d;if(!c)return!1;const m=de(p);if(m.type==="CallExpression"&&m.callee.type==="MemberExpression"&&m.callee.object.type==="Identifier"&&m.callee.object.name==="Object"&&ie(m.callee.property)==="entries"&&m.arguments[0]&&c.type==="ArrayPattern"&&((l=c.elements[0])==null?void 0:l.type)==="Identifier"&&((d=c.elements[1])==null?void 0:d.type)==="Identifier"){const i=c.elements[0].name,o=c.elements[1].name,a=de(m.arguments[0]),h=a.type==="ObjectExpression"?a:(()=>{const g=s(A,a);return g?de(g.node):null})();if((h==null?void 0:h.type)==="ObjectExpression"){for(const g of h.properties)if(g.type==="ObjectProperty"){const N=ie(g.key);if(N){const S=new Map([[i,{type:"StringLiteral",value:N}],[o,g.value]]);D.push(...$(A,y,w,{identMap:S}))}}return!0}}if(m.type==="CallExpression"&&m.callee.type==="MemberExpression"&&m.callee.object.type==="Identifier"&&m.callee.object.name==="Object"&&ie(m.callee.property)==="keys"&&m.arguments[0]&&c.type==="Identifier"){const i=c.name,o=de(m.arguments[0]),a=o.type==="ObjectExpression"?o:(()=>{const h=s(A,o);return h?de(h.node):null})();if((a==null?void 0:a.type)==="ObjectExpression"){for(const h of a.properties)if(h.type==="ObjectProperty"){const g=ie(h.key);if(g){const N=new Map([[i,{type:"StringLiteral",value:g}]]),S=new Map([[i,h.value]]);D.push(...$(A,y,w,{identMap:N,computedPropMap:S}))}}return!0}}if(m.type==="CallExpression"&&(m.callee.type==="MemberExpression"&&ie(m.callee.property)==="readdirSync"||m.callee.type==="Identifier"&&m.callee.name==="readdirSync")&&m.arguments[0]&&c.type==="Identifier"){const i=m.arguments[0];let o=null;if(i.type==="CallExpression"&&i.callee.type==="MemberExpression"&&ie(i.callee.property)==="join"){const a=[];for(const h of i.arguments){if(h.type==="Identifier"&&h.name==="__dirname")continue;const g=u(A,h);g!==null&&a.push(g)}a.length>0&&(o=a.join("/"))}else i.type==="BinaryExpression"&&i.operator==="+"&&i.left.type==="Identifier"&&i.left.name==="__dirname"?o=u(A,i.right):o=u(A,i);if(o!==null){const a=oe(le(Re(A.path),o)),h=a?`${a}/`:"",g=Array.from(r).filter(N=>N!==A.path&&N.startsWith(h)&&!N.slice(h.length).includes("/")&&dt.test(N)&&!cn.test(N));for(const N of g){const S=N.slice(h.length),R=new Map([[c.name,{type:"StringLiteral",value:S}]]);D.push(...$(A,y,w,{identMap:R}))}return!0}}const e=m.type==="ArrayExpression"?m:(()=>{const i=s(A,m);return i?de(i.node):null})();if((e==null?void 0:e.type)==="ArrayExpression"&&c.type==="Identifier"){for(const i of e.elements)if((i==null?void 0:i.type)==="ObjectExpression"){const o=new Map;for(const a of i.properties)if(a.type==="ObjectProperty"){const h=ie(a.key);h&&o.set(h,a.value)}D.push(...$(A,y,w,{paramName:c.name,props:o}))}return!0}return!1},B=p=>{if(p.type==="ThisExpression"&&w.has("this"))return"this";if(p.type==="Identifier"&&w.has(p.name))return p.name;if(p.type==="MemberExpression"&&p.object.type==="ThisExpression"){const c=ie(p.property);if(c&&w.has(`this.${c}`))return`this.${c}`}return null},V=p=>{var m;const c=[];let y=p;for(;y.type==="CallExpression"&&y.callee.type==="MemberExpression";){const e=ie(y.callee.property);if(!e)return null;if(e==="route"){const l=B(y.callee.object);if(l){const d=u(A,P(y.arguments[0]));return{routerName:l,pathArg:d??void 0,dynamicPath:d===null,chain:c.reverse()}}return null}if(_e.has(e))c.push({methodName:e,args:y.arguments.map(P),line:((m=y.loc)==null?void 0:m.start.line)??1}),y=y.callee.object;else return null}return null},T=p=>{var l,d,i,o,a,h,g,N,S,R,O;const c=p.type==="AwaitExpression"?p.argument:p;if(c.type!=="CallExpression")return;if(c.callee.type==="MemberExpression"&&ie(c.callee.property)==="forEach"&&c.arguments[0]&&(c.arguments[0].type==="ArrowFunctionExpression"||c.arguments[0].type==="FunctionExpression")){const z=c.arguments[0],G=z.body.type==="BlockStatement"?z.body.body:[{type:"ExpressionStatement",expression:z.body}];if(q(c.callee.object,z.params[0],G))return}if(c.callee.type==="MemberExpression"&&ie(c.callee.property)==="route"&&B(c.callee.object)&&((l=c.arguments[0])==null?void 0:l.type)==="ObjectExpression"){const z=c.arguments[0];let G=null,W,H,_;for(const C of z.properties){if(C.type!=="ObjectProperty")continue;const F=ie(C.key);F==="method"?G=u(A,C.value):F==="path"?W=C.value:F==="handler"?H=C.value:F==="middleware"&&(_=C.value)}if(G&&_e.has(G.toLowerCase())&&H){const C=f(A,W),F=[];if(_&&F.push(_),F.push(H),C)for(const k of C)D.push({kind:"method",objectName:"this",methodName:G.toLowerCase(),pathArg:k,dynamicPath:!1,args:F,line:((d=c.loc)==null?void 0:d.start.line)??1});return}}if(c.callee.type==="MemberExpression"&&ie(c.callee.property)==="route"&&((i=c.arguments[0])==null?void 0:i.type)==="ObjectExpression"){const z=B(c.callee.object);if(z){const G=c.arguments[0];let W=null,H,_,C;for(const F of G.properties)if(F.type==="ObjectProperty"){const k=ie(F.key);k==="method"?W=((o=u(A,F.value))==null?void 0:o.toLowerCase())??null:k==="path"?H=F.value:k==="handler"?_=F.value:k==="middleware"&&(C=F.value)}if(W&&_e.has(W)&&_){const F=u(A,H),k=[];C&&k.push(C),k.push(_),D.push({kind:"method",objectName:z,methodName:W,pathArg:F??void 0,dynamicPath:F===null,args:k,line:((a=c.loc)==null?void 0:a.start.line)??1});return}}}if(c.callee.type==="MemberExpression"&&ie(c.callee.property)==="route"&&((h=c.arguments[0])==null?void 0:h.type)==="ObjectExpression"){const z=B(c.callee.object);if(z){const G=c.arguments[0];let W=null,H,_,C;for(const F of G.properties)if(F.type==="ObjectProperty"){const k=ie(F.key);k==="method"?W=((g=u(A,F.value))==null?void 0:g.toLowerCase())??null:k==="path"?H=F.value:k==="handler"?_=F.value:k==="middleware"&&(C=F.value)}if(W&&_e.has(W)&&_){const F=u(A,H),k=[];C&&k.push(C),k.push(_),D.push({kind:"method",objectName:z,methodName:W,pathArg:F??void 0,dynamicPath:F===null,args:k,line:((N=c.loc)==null?void 0:N.start.line)??1});return}}}const y=V(c);if(y&&y.chain.length>0){D.push({kind:"route-chain",objectName:y.routerName,methodName:"route",pathArg:y.pathArg,dynamicPath:y.dynamicPath,args:[],line:((S=c.loc)==null?void 0:S.start.line)??1,chainCalls:y.chain});return}if((z=>{var _;const G=[];let W=z;for(;W.type==="CallExpression"&&W.callee.type==="MemberExpression";){const C=ie(W.callee.property);if(!C||C!=="use"&&!_e.has(C))break;G.push({methodName:C,args:W.arguments.map(P),line:((_=W.loc)==null?void 0:_.start.line)??1}),W=W.callee.object}if(G.length===0)return!1;let H=B(W);if(!H){if(w.has("__default_router__")&&E(A,W)&&!(W.type==="CallExpression"&&W.callee.type==="MemberExpression"&&G.length===0))H="__default_router__";else if(W.type==="CallExpression"&&E(A,W)){for(const C of w)if(A.locals.get(C)===z){H=C;break}}}if(!H)return!1;for(const C of G.reverse())if(C.methodName==="use"){const F=C.args[0],k=f(A,F);if(k)for(const I of k)D.push({kind:"use",objectName:H,methodName:"use",pathArg:I,args:C.args.slice(1),line:C.line});else D.push({kind:"use",objectName:H,methodName:"use",pathArg:void 0,args:C.args,line:C.line})}else if(_e.has(C.methodName)){const F=C.args[0],k=f(A,F);if(k)for(const I of k)D.push({kind:"method",objectName:H,methodName:C.methodName,pathArg:I,dynamicPath:!1,args:C.args.slice(1),line:C.line});else D.push({kind:"method",objectName:H,methodName:C.methodName,pathArg:void 0,dynamicPath:!0,args:C.args.slice(1),line:C.line})}return!0})(c))return;for(let z=0;z<c.arguments.length;z++){const G=c.arguments[z];if(G.type==="Identifier"&&w.has(G.name)){D.push({kind:"delegate",objectName:G.name,methodName:"delegate",args:[],line:((R=c.loc)==null?void 0:R.start.line)??1,delegateCallee:c.callee,delegateArgIndex:z});return}if(G.type==="ObjectExpression"){for(const W of G.properties)if(W.type==="ObjectProperty"&&W.value.type==="Identifier"&&w.has(W.value.name)){const H=ie(W.key);if(H){D.push({kind:"delegate",objectName:W.value.name,methodName:"delegate",args:[],line:((O=c.loc)==null?void 0:O.start.line)??1,delegateCallee:c.callee,delegateArgIndex:z,delegatePropKey:H});return}}}}let e=c;for(;e.type==="CallExpression";){for(const z of e.arguments)(z.type==="ArrowFunctionExpression"||z.type==="FunctionExpression")&&z.body.type==="BlockStatement"&&v(z.body);if(e.callee.type==="MemberExpression")e=e.callee.object;else break}},v=p=>{var c,y,m;if(p){if(p.type==="ExpressionStatement")p.expression.type==="AssignmentExpression"&&(p.expression.right.type==="ArrowFunctionExpression"||p.expression.right.type==="FunctionExpression")&&p.expression.right.body.type==="BlockStatement"?v(p.expression.right.body):T(p.expression);else if(p.type==="BlockStatement")for(const e of p.body)v(e);else if(p.type==="IfStatement")v(p.consequent),v(p.alternate);else if(p.type==="TryStatement")v(p.block),p.handler&&v(p.handler.body),v(p.finalizer);else if(p.type==="ForOfStatement"){let e;p.left.type==="VariableDeclaration"?e=(c=p.left.declarations[0])==null?void 0:c.id:(p.left.type==="Identifier"||p.left.type==="ArrayPattern")&&(e=p.left);const l=p.body.type==="BlockStatement"?p.body.body:[p.body];q(p.right,e,l)||v(p.body)}else if(p.type==="ForStatement"||p.type==="ForInStatement"||p.type==="WhileStatement")v(p.body);else if(p.type==="FunctionDeclaration"&&p.body)(p.params.some(l=>l.type==="Identifier"&&w.has(l.name))||w.size>0)&&v(p.body);else if(p.type==="ClassDeclaration")for(const e of p.body.body)e.type==="ClassMethod"&&v(e.body);else if(p.type==="ExportNamedDeclaration"&&p.declaration)v(p.declaration);else if(p.type==="ReturnStatement"&&p.argument)T(p.argument);else if(p.type==="ExportDefaultDeclaration")w.has("__default_router__")&&p.declaration.type==="CallExpression"?T(p.declaration):p.declaration.type==="ClassDeclaration"?v(p.declaration):(p.declaration.type==="FunctionDeclaration"||p.declaration.type==="FunctionExpression"||p.declaration.type==="ArrowFunctionExpression")&&((y=p.declaration.body)==null?void 0:y.type)==="BlockStatement"&&v(p.declaration.body);else if(p.type==="VariableDeclaration")for(const e of p.declarations)e.id.type==="Identifier"&&w.has(e.id.name)&&((m=e.init)==null?void 0:m.type)==="CallExpression"&&E(A,e.init)&&T(e.init),e.init&&(e.init.type==="ArrowFunctionExpression"||e.init.type==="FunctionExpression")&&e.init.body.type==="BlockStatement"&&(e.init.params.some(d=>d.type==="Identifier"&&w.has(d.name))||w.size>0)&&v(e.init.body)}};for(const p of j)v(p);return D};return{isExpressRouterCreation:E,getRouterVarsInFile:b,collectCallsInBlock:$}}function ls(n,t,r){const{nodes:s,addNode:u,addEdge:f}=n,{resolveSymbol:E}=t,{isExpressRouterCreation:x,getRouterVarsInFile:b}=r,$=w=>{const M=[];for(const D of w)if(D.type==="ArrayExpression")for(const P of D.elements)P&&P.type!=="SpreadElement"&&M.push(...$([P]));else D.type!=="SpreadElement"&&M.push(D);return M};return{flattenArgNodes:$,isRouterSymbol:w=>{if(!w)return null;const{apps:M,routers:D}=b(w.file),P=w.localName??w.name;if(D.has(P)||M.has(P))return P;if(w.node.type==="ClassMethod"&&w.node.kind==="get")return"this";if(x(w.file,w.node))return D.has("__default_router__")?"__default_router__":P;if(w.node.type==="ClassDeclaration"||w.node.type==="ClassExpression"){let q=w.node,B=w.file;for(let V=0;V<4&&q;V++){const{routers:T,apps:v}=b(B);if(T.has("this.app")||T.has("this.router")||v.has("this.app"))return"this";if(q.superClass){const p=E(B,q.superClass,1),c=p?de(p.node):null;if(p&&c&&(c.type==="ClassDeclaration"||c.type==="ClassExpression")){q=c,B=p.file;continue}}break}}if(w.node.type==="FunctionDeclaration"||w.node.type==="FunctionExpression"||w.node.type==="ArrowFunctionExpression"){if(w.node.body.type==="BlockStatement"){for(const q of w.node.body.body)if(q.type==="ReturnStatement"&&q.argument){if(q.argument.type==="Identifier"&&D.has(q.argument.name))return q.argument.name;if(x(w.file,q.argument))return"__default_router__"}}else if(x(w.file,w.node.body))return"__default_router__"}return null},registerRoute:(w,M,D,P,q,B,V)=>{var W,H,_;const T=$(P);if(T.length===0)return;const v=T[T.length-1],p=T.slice(0,-1),c=[...V];for(const C of p){const F=Ge(C);c.includes(F)||c.push(F);const k=`mw:${F}`;u({id:k,type:"middleware",label:F,file:q.path,line:((W=C.loc)==null?void 0:W.start.line)??B})}let y="inlineHandler",m=q.path,e=((H=v.loc)==null?void 0:H.start.line)??B,l=v;if(v.type!=="ArrowFunctionExpression"&&v.type!=="FunctionExpression"){let C=v;C.type==="CallExpression"&&/^(?:.*asyncHandler|catchAsync)$/i.test(Ge(C.callee))&&C.arguments[0]&&C.arguments[0].type!=="SpreadElement"&&(C=C.arguments[0]),y=Ge(C);const F=E(q,C);F&&(l=F.node,m=F.file.path,e=F.line)}const d=Pt(l),i=(C,F)=>{if(!C)return;const k=de(C);if(k.type==="ObjectExpression"){for(const I of k.properties)if(I.type==="ObjectProperty"){const Z=ie(I.key);Z&&F.add(Z)}}else k.type==="CallExpression"&&k.callee.type==="MemberExpression"&&ie(k.callee.property)==="object"&&k.arguments[0]&&i(k.arguments[0],F)},o=new Set(d.bodyFields),a=new Set(d.queryParams),h=new Set(d.pathParams);for(const C of p)if(C.type==="CallExpression"&&((_=C.arguments[0])==null?void 0:_.type)==="ObjectExpression"){for(const F of C.arguments[0].properties)if(F.type==="ObjectProperty"){const k=ie(F.key);k==="body"?i(F.value,o):k==="query"?i(F.value,a):k==="params"&&i(F.value,h)}}const g=Array.from(new Set([...fe(D),...h])),N=Array.from(a),S=Array.from(o),R=me(D),O=`route:${M}:${D}`,z=s.get(O);z?(z.middlewares=Array.from(new Set([...z.middlewares??[],...c])),z.pathParams=Array.from(new Set([...z.pathParams??[],...g])),z.queryParams=Array.from(new Set([...z.queryParams??[],...N])),z.bodyFields=Array.from(new Set([...z.bodyFields??[],...S])),y!=="inlineHandler"&&(z.controller=y,z.controllerFile=m,z.controllerLine=e)):u({id:O,type:"route",label:`${M} ${D}`,file:q.path,line:B,method:M,fullPath:D,pathParams:g,queryParams:N,bodyFields:S,group:R,middlewares:c,controller:y,controllerFile:m,controllerLine:e}),f({id:`edge:${w}->${O}`,source:w,target:O,type:"handles"});for(const C of c){const F=`mw:${C}`;s.has(F)||u({id:F,type:"middleware",label:C,file:q.path,line:B}),f({id:`edge:${O}->${F}`,source:O,target:F,type:"uses"})}const G=`ctrl:${m}:${y}:${e}`;u({id:G,type:"controller",label:y,file:m,line:e}),f({id:`edge:${O}->${G}`,source:O,target:G,type:"calls"})}}}var cs=class{constructor(){ue(this,"name","express")}detect(n){const t=n.find(r=>oe(r.path)==="package.json");return t&&/"express"\s*:/.test(t.content)?!0:n.some(r=>dt.test(r.path)&&/from\s+['"]express['"]|require\(['"]express['"]\)/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(g=>({path:oe(g.path),content:g.content})),u=s.filter(g=>dt.test(g.path)&&!cn.test(g.path)),f=new Set(s.map(g=>g.path)),E=et(s),x=new Map;for(const g of u){const N=We(g,f,E);N&&x.set(g.path,N)}const b=Array.from(x.values()),$=os(s,b),A=new Map,j=new Map,w=[],M=g=>{A.has(g.id)||A.set(g.id,g)},D=g=>{j.has(g.id)||j.set(g.id,g)},P={fileSet:f,tsConfig:E,parsedMap:x,nodes:A,addNode:M,addEdge:D},q=is(P),B=as(P,q),V=ls(P,q,B),{resolveSymbol:T}=q,{getRouterVarsInFile:v,collectCallsInBlock:p}=B,{flattenArgNodes:c,isRouterSymbol:y,registerRoute:m}=V,e=new Set,l=(g,N,S,R,O,z)=>{const G=`${g.path}:${Array.from(N).join(",")}:${O}`;if(e.has(G))return;e.add(G);const W=p(g,S,N),H=[...z];for(const _ of W)if(_.kind==="use"){const C=_.pathArg?ne(O,_.pathArg):O,F=c(_.args),k=[...H];for(const I of F){const Z=T(g,I),U=y(Z);if(Z&&U){const J=`router:${Z.file.path}:${C||"/"}`;M({id:J,type:"router",label:C||Z.name,file:Z.file.path,line:Z.line}),D({id:`edge:${R}->${J}`,source:R,target:J,type:"mounts",label:_.pathArg??"/"});let K=Z.file,Q=Z.file.ast.program.body;if(I.type==="MemberExpression"&&I.object.type==="NewExpression"){const re=T(g,I.object.callee);re&&(re.node.type==="ClassDeclaration"||re.node.type==="ClassExpression")&&(K=re.file,Q=re.file.ast.program.body)}const te=new Set([U]);Z.node.type==="ClassDeclaration"||Z.node.type==="ClassExpression"?(Q=[Z.node],te.add("this"),te.add("this.app"),te.add("this.router")):(Z.node.type==="FunctionDeclaration"||Z.node.type==="FunctionExpression"||Z.node.type==="ArrowFunctionExpression")&&(Z.node.body.type==="BlockStatement"?Q=Z.node.body.body:Q=[{type:"ExpressionStatement",expression:Z.node.body}]),l(K,te,Q,J,C,k)}else if(I.type==="CallExpression"&&I.callee.type==="MemberExpression"&&ie(I.callee.property)==="readdirSync")w.push(`${g.path}:${_.line} (dynamic fs.readdirSync mount)`);else{const J=Ge(I);J&&J!=="anonymous"&&!J.startsWith("express.")&&!k.includes(J)&&(k.push(J),_.pathArg||H.push(J))}}}else if(_.kind==="delegate"&&_.delegateCallee&&_.delegateArgIndex!==void 0){const C=T(g,_.delegateCallee);if(C&&(C.node.type==="FunctionDeclaration"||C.node.type==="FunctionExpression"||C.node.type==="ArrowFunctionExpression")&&C.node.body.type==="BlockStatement"){const F=C.node.params[_.delegateArgIndex];let k=null;if(!_.delegatePropKey&&(F==null?void 0:F.type)==="Identifier")k=F.name;else if(_.delegatePropKey&&(F==null?void 0:F.type)==="ObjectPattern"){for(const I of F.properties)if(I.type==="ObjectProperty"&&ie(I.key)===_.delegatePropKey&&I.value.type==="Identifier"){k=I.value.name;break}}k&&l(C.file,new Set([k]),C.node.body.body,R,O,H)}}else if(_.kind==="method"){if(_.dynamicPath||_.pathArg===void 0){w.push(`${g.path}:${_.line} (dynamic route path)`);continue}const C=ne(O,_.pathArg),F=_.methodName.toUpperCase();m(R,F,C,_.args,g,_.line,H)}else if(_.kind==="route-chain"&&_.chainCalls){if(_.dynamicPath||_.pathArg===void 0){w.push(`${g.path}:${_.line} (dynamic .route() path)`);continue}const C=ne(O,_.pathArg);for(const F of _.chainCalls){const k=F.methodName.toUpperCase();m(R,k,C,F.args,g,F.line,H)}}},d=[];for(const g of b){const{apps:N}=v(g);N.size>0&&d.push({pf:g,apps:N})}const i=new Set;if(d.length>1)for(const{pf:g}of d)for(const N of g.imports.values())N.resolvedFile&&i.add(N.resolvedFile);const o=d.filter(g=>!i.has(g.pf.path)),a=o.length>0?o:d;if(a.length>0)for(const{pf:g,apps:N}of a){const S=`entry:${g.path}`;M({id:S,type:"entry",label:g.path,file:g.path,line:1}),l(g,N,g.ast.program.body,S,"",[])}else for(const g of b){const{routers:N}=v(g);if(N.size>0){const S=`router:${g.path}:/`;M({id:S,type:"router",label:g.path,file:g.path,line:1}),l(g,N,g.ast.program.body,S,"",[])}}const h=Math.round((performance.now()-r)*100)/100;return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"express-app",framework:"express",detectedPort:$,scannedFiles:u.length,scanDurationMs:h,unresolvedMounts:w},nodes:Array.from(A.values()),edges:Array.from(j.values())}}},ht=new Set(["get","post","put","patch","delete","options","head","all"]),kt=/\.(ts|tsx|js|jsx|mjs|cjs)$/i,Mt=/(\.test\.|\.spec\.|__tests__|__mocks__)/i;function we(n){let t=n;for(;t.type==="TSAsExpression"||t.type==="TSSatisfiesExpression"||t.type==="TSTypeAssertion"||t.type==="ParenthesizedExpression";)t=t.expression;return t}function ye(n){return n?n.type==="Identifier"?n.name:n.type==="StringLiteral"?n.value:null:null}function Je(n){if(n.type==="Identifier")return n.name;if(n.type==="MemberExpression"){const t=Je(n.object),r=ye(n.property)??"";return t?`${t}.${r}`:r}return n.type==="CallExpression"?Je(n.callee):"anonymous"}function ps(n){var E;const t=new Set,r=new Set,s=new Set;if(n.type!=="FunctionDeclaration"&&n.type!=="FunctionExpression"&&n.type!=="ArrowFunctionExpression"&&n.type!=="ObjectMethod"&&n.type!=="ClassMethod")return{pathParams:[],queryParams:[],bodyFields:[]};const u=((E=n.params[0])==null?void 0:E.type)==="Identifier"?n.params[0].name:"c",f=x=>{var b;if(!(!x||typeof x!="object")){if(x.type==="CallExpression"&&x.callee.type==="MemberExpression"&&x.callee.object.type==="MemberExpression"&&x.callee.object.object.type==="Identifier"&&x.callee.object.object.name===u&&ye(x.callee.object.property)==="req"){const $=ye(x.callee.property),A=x.arguments[0],j=(A==null?void 0:A.type)==="StringLiteral"?A.value:null;$==="param"&&j?t.add(j):($==="query"||$==="queries")&&j&&r.add(j)}if(x.type==="VariableDeclarator"&&x.init&&x.id.type==="ObjectPattern"){const $=x.init.type==="AwaitExpression"?x.init.argument:x.init;if($.type==="CallExpression"&&$.callee.type==="MemberExpression"&&$.callee.object.type==="MemberExpression"&&$.callee.object.object.type==="Identifier"&&$.callee.object.object.name===u&&ye($.callee.object.property)==="req"){const A=ye($.callee.property);let j=null;if(A==="json"||A==="parseBody")j=s;else if(A==="query"||A==="queries")j=r;else if(A==="param")j=t;else if(A==="valid"&&((b=$.arguments[0])==null?void 0:b.type)==="StringLiteral"){const w=$.arguments[0].value;w==="json"||w==="form"?j=s:w==="query"?j=r:w==="param"&&(j=t)}if(j){for(const w of x.id.properties)if(w.type==="ObjectProperty"){const M=ye(w.key);M&&j.add(M)}}}}for(const $ of Object.keys(x)){if($==="loc"||$==="start"||$==="end"||$==="extra")continue;const A=x[$];if(Array.isArray(A))for(const j of A)j&&typeof j=="object"&&"type"in j&&f(j);else A&&typeof A=="object"&&"type"in A&&f(A)}}};return f(n.body),{pathParams:Array.from(t),queryParams:Array.from(r),bodyFields:Array.from(s)}}var us=class{constructor(){ue(this,"name","hono")}detect(n){const t=n.find(r=>oe(r.path)==="package.json");return t&&/"(?:hono|@hono\/[^"]+)"\s*:/.test(t.content)?!0:n.some(r=>kt.test(r.path)&&!Mt.test(r.path)&&/from\s+['"](?:hono(?:\/[^'"]*)?|@hono\/[^'"]+)['"]|require\(\s*['"](?:hono(?:\/[^'"]*)?|@hono\/[^'"]+)['"]\s*\)/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(e=>({path:oe(e.path),content:e.content})),u=s.filter(e=>kt.test(e.path)&&!Mt.test(e.path)),f=new Set(s.map(e=>e.path)),E=et(s),x=new Map;for(const e of u){const l=We(e,f,E);l&&x.set(e.path,l)}const b=Array.from(x.values()),$=new Map,A=new Map,j=[],w=e=>{$.has(e.id)||$.set(e.id,e)},M=e=>{A.has(e.id)||A.set(e.id,e)},D=(e,l,d=0)=>{var o,a;if(d>8)return null;const i=we(l);if(i.type==="Identifier"){const h=e.imports.get(i.name);if(h!=null&&h.resolvedFile){const N=x.get(h.resolvedFile);if(!N)return null;if(h.importedName==="*")return{file:N,node:N.ast.program,name:i.name,line:1};const S=N.exports.get(h.importedName);if(S)return S.node.type==="Identifier"&&S.node.name!==i.name?D(N,S.node,d+1)??{file:N,node:S.node,name:h.importedName,localName:S.localName,line:S.line}:{file:N,node:S.node,name:h.importedName==="default"?i.name:h.importedName,localName:S.localName,line:S.line};for(const R of N.reExports)if(R.resolvedFile&&(R.exportedName==="*"||R.exportedName===h.importedName)){const O=x.get(R.resolvedFile),z=R.exportedName==="*"?h.importedName:R.importedName,G=O==null?void 0:O.exports.get(z);if(O&&G)return{file:O,node:G.node,name:z,localName:G.localName,line:G.line}}}const g=e.locals.get(i.name);if(g)return{file:e,node:g,name:i.name,line:((o=g.loc)==null?void 0:o.start.line)??1}}if(i.type==="MemberExpression"){const h=ye(i.property);if(!h)return null;const g=D(e,i.object,d+1);if(!g)return null;const N=we(g.node);if(N.type==="Program"){const S=g.file.exports.get(h);if(S)return{file:g.file,node:S.node,name:`${g.name}.${h}`,line:S.line}}if(N.type==="ObjectExpression"){for(const S of N.properties)if(S.type==="ObjectProperty"&&ye(S.key)===h)return{file:g.file,node:S.value,name:`${g.name}.${h}`,line:((a=S.loc)==null?void 0:a.start.line)??1}}}if(i.type==="CallExpression"){const h=D(e,i.callee,d+1);if(h&&(h.node.type==="FunctionDeclaration"||h.node.type==="FunctionExpression"||h.node.type==="ArrowFunctionExpression"))return h}return null},P=(e,l,d=0)=>{if(!l||d>8)return null;const i=we(l);if(i.type==="StringLiteral")return i.value;if(i.type==="TemplateLiteral"){let o="";for(let a=0;a<i.quasis.length;a++)if(o+=i.quasis[a].value.cooked??i.quasis[a].value.raw,a<i.expressions.length){const h=P(e,i.expressions[a],d+1);if(h===null)return null;o+=h}return o}if(i.type==="BinaryExpression"&&i.operator==="+"){const o=P(e,i.left,d+1),a=P(e,i.right,d+1);return o!==null&&a!==null?o+a:null}if(i.type==="Identifier"||i.type==="MemberExpression"){const o=D(e,i);if(o)return P(o.file,o.node,d+1)}return null},q=(e,l,d=0)=>{if(d>4)return{isHono:!1};let i=we(l),o;for(;i.type==="CallExpression"&&i.callee.type==="MemberExpression";){const a=ye(i.callee.property);if(a==="basePath"){o=P(e,i.arguments[0])??o,i=we(i.callee.object);continue}if(a==="route"||a==="use"||a==="on"||a==="openapi"||ht.has(a??"")){i=we(i.callee.object);continue}break}if(i.type==="NewExpression"&&i.callee.type==="Identifier"){const a=e.imports.get(i.callee.name);if(a&&(a.sourceSpecifier==="hono"||a.sourceSpecifier.startsWith("hono/")||a.sourceSpecifier==="@hono/zod-openapi"))return{isHono:!0,basePath:o};if(i.callee.name==="Hono"||i.callee.name==="OpenAPIHono")return{isHono:!0,basePath:o}}if(i.type==="CallExpression"&&i.callee.type==="MemberExpression"&&ye(i.callee.property)==="createApp")return{isHono:!0,basePath:o};if(i.type==="CallExpression"){const a=D(e,i.callee);if(a&&(a.node.type==="FunctionDeclaration"||a.node.type==="FunctionExpression"||a.node.type==="ArrowFunctionExpression")){if(a.node.body.type==="BlockStatement"){for(const h of a.node.body.body)if(h.type==="ReturnStatement"&&h.argument){if(q(a.file,h.argument,d+1).isHono)return{isHono:!0,basePath:o};if(h.argument.type==="Identifier"){const g=a.file.locals.get(h.argument.name);if(g&&q(a.file,g,d+1).isHono)return{isHono:!0,basePath:o}}}}else if(q(a.file,a.node.body,d+1).isHono)return{isHono:!0,basePath:o}}}return{isHono:!1}},B=e=>{const l=new Map,d=o=>{if(!(!o||typeof o!="object")){if(o.type==="VariableDeclarator"&&o.id.type==="Identifier"&&o.init){const a=q(e,o.init);a.isHono&&l.set(o.id.name,a.basePath)}for(const a of Object.keys(o)){if(a==="loc"||a==="start"||a==="end"||a==="extra")continue;const h=o[a];if(Array.isArray(h))for(const g of h)g&&typeof g=="object"&&"type"in g&&d(g);else h&&typeof h=="object"&&"type"in h&&d(h)}}};d(e.ast.program);const i=e.exports.get("default");if(i){const o=q(e,i.node);o.isHono&&l.set("__default_hono__",o.basePath)}return l},V=(e,l,d,i,o,a,h)=>{var k;if(i.length===0)return;const g=i[i.length-1],N=i.slice(0,-1),S=[...h];for(const I of N){const Z=Je(I);Z&&Z!=="anonymous"&&!S.includes(Z)&&S.push(Z)}let R="inlineHandler",O=o.path,z=((k=g.loc)==null?void 0:k.start.line)??a,G=g;if(g.type!=="ArrowFunctionExpression"&&g.type!=="FunctionExpression"){R=Je(g);const I=D(o,g);I&&(G=I.node,O=I.file.path,z=I.line)}const W=ps(G),H=Array.from(new Set([...fe(d),...W.pathParams])),_=me(d),C=`route:${l}:${d}`;w({id:C,type:"route",label:`${l} ${d}`,file:o.path,line:a,method:l,fullPath:d,pathParams:H,queryParams:W.queryParams,bodyFields:W.bodyFields,group:_,middlewares:S,controller:R,controllerFile:O,controllerLine:z}),M({id:`edge:${e}->${C}`,source:e,target:C,type:"handles"});for(const I of S){const Z=`mw:${I}`;w({id:Z,type:"middleware",label:I,file:o.path,line:a}),M({id:`edge:${C}->${Z}`,source:C,target:Z,type:"uses"})}const F=`ctrl:${O}:${R}:${z}`;w({id:F,type:"controller",label:R,file:O,line:z}),M({id:`edge:${C}->${F}`,source:C,target:F,type:"calls"})},T=new Set,v=(e,l,d,i,o,a)=>{const h=`${e.path}:${Array.from(l).join(",")}:${o}`;if(T.has(h))return;T.add(h);const g=[...a],N=(R,O)=>{var C,F,k;const z=I=>O&&I.type==="Identifier"&&O.has(I.name)?O.get(I.name):I;if(R.callee.type==="MemberExpression"&&ye(R.callee.property)==="forEach"&&R.arguments[0]&&(R.arguments[0].type==="ArrowFunctionExpression"||R.arguments[0].type==="FunctionExpression")){const I=R.arguments[0],Z=I.params[0],U=we(R.callee.object),J=U.type==="ArrayExpression"?{node:U}:D(e,U),K=J?we(J.node):null;if((K==null?void 0:K.type)==="ArrayExpression"&&(Z==null?void 0:Z.type)==="Identifier"){const Q=I.body.type==="BlockStatement"?I.body.body:[{type:"ExpressionStatement",expression:I.body}];for(const te of K.elements)if(te&&te.type!=="SpreadElement"){const re=new Map([[Z.name,te]]);for(const ae of Q)ae.type==="ExpressionStatement"&&ae.expression.type==="CallExpression"&&N(ae.expression,re)}return}}const G=[];let W=R;for(;W.type==="CallExpression"&&W.callee.type==="MemberExpression";){const I=ye(W.callee.property);if(!I||I!=="route"&&I!=="use"&&I!=="on"&&I!=="openapi"&&I!=="basePath"&&!ht.has(I))break;G.push({methodName:I,args:W.arguments.map(z),line:((C=W.loc)==null?void 0:C.start.line)??1}),W=we(W.callee.object)}if(G.length===0)return;let H=!1;if(W.type==="Identifier"&&l.has(W.name))H=!0;else if(l.has("__default_hono__")&&q(e,W).isHono)H=!0;else for(const I of l)if(e.locals.get(I)===R){H=!0;break}if(!H)return;let _=o;for(const I of G.reverse())if(I.methodName==="basePath"){const Z=P(e,I.args[0]);Z&&(_=ne(_,Z))}else if(I.methodName==="use"){const U=P(e,I.args[0])!==null?I.args.slice(1):I.args;for(const J of U){const K=Je(J);K&&K!=="anonymous"&&!g.includes(K)&&g.push(K)}}else if(I.methodName==="route"){const Z=P(e,I.args[0]),U=I.args[1];if(Z!==null&&U){const J=ne(_,Z),K=D(e,U);if(K){const Q=B(K.file),te=K.localName??K.name,re=Q.has(te)?te:Q.has("__default_hono__")?"__default_hono__":null;if(re){const ae=Q.get(re),Y=ae?ne(J,ae):J,se=`router:${K.file.path}:${Y||"/"}`;w({id:se,type:"router",label:Y||K.name,file:K.file.path,line:K.line}),M({id:`edge:${i}->${se}`,source:i,target:se,type:"mounts",label:Z});const ee=(K.node.type==="FunctionDeclaration"||K.node.type==="FunctionExpression"||K.node.type==="ArrowFunctionExpression")&&K.node.body.type==="BlockStatement"?K.node.body.body:K.file.ast.program.body;v(K.file,new Set([re]),ee,se,Y,g)}else j.push(`${e.path}:${I.line} (unresolved Hono .route() target)`)}else j.push(`${e.path}:${I.line} (unresolved Hono .route() target)`)}else j.push(`${e.path}:${I.line} (dynamic Hono .route() mount)`)}else if(I.methodName==="on"){const Z=I.args[0],U=[];if((Z==null?void 0:Z.type)==="StringLiteral")U.push(Z.value.toUpperCase());else if((Z==null?void 0:Z.type)==="ArrayExpression")for(const K of Z.elements)(K==null?void 0:K.type)==="StringLiteral"&&U.push(K.value.toUpperCase());const J=P(e,I.args[1]);if(J!==null&&U.length>0){const K=ne(_,J);for(const Q of U)V(i,Q,K,I.args.slice(2),e,I.line,g)}}else if(I.methodName==="openapi"){const Z=I.args[0]?D(e,I.args[0]):null;if(Z&&Z.node.type==="CallExpression"&&((F=Z.node.arguments[0])==null?void 0:F.type)==="ObjectExpression"){let U=null,J=null;for(const K of Z.node.arguments[0].properties)if(K.type==="ObjectProperty"){const Q=ye(K.key);Q==="method"&&(U=((k=P(Z.file,K.value))==null?void 0:k.toUpperCase())??null),Q==="path"&&(J=P(Z.file,K.value))}if(U&&J!==null){const K=ne(_,J.replace(/\{([^}]+)\}/g,":$1"));V(i,U,K,I.args.slice(1),e,I.line,g)}}}else if(ht.has(I.methodName)){const Z=P(e,I.args[0]);if(Z!==null){const U=ne(_,Z);V(i,I.methodName.toUpperCase(),U,I.args.slice(1),e,I.line,g)}else j.push(`${e.path}:${I.line} (dynamic Hono route path)`)}},S=R=>{var O,z;if(R)if(R.type==="ExpressionStatement"){const G=R.expression.type==="AwaitExpression"?R.expression.argument:R.expression;G.type==="CallExpression"&&N(G)}else if(R.type==="BlockStatement")for(const G of R.body)S(G);else if(R.type==="IfStatement")S(R.consequent),S(R.alternate);else if(R.type==="VariableDeclaration")for(const G of R.declarations)((O=G.init)==null?void 0:O.type)==="CallExpression"&&N(G.init);else R.type==="ExportDefaultDeclaration"?R.declaration.type==="CallExpression"?N(R.declaration):(R.declaration.type==="FunctionDeclaration"||R.declaration.type==="FunctionExpression"||R.declaration.type==="ArrowFunctionExpression")&&((z=R.declaration.body)==null?void 0:z.type)==="BlockStatement"&&S(R.declaration.body):R.type==="FunctionDeclaration"&&R.body&&S(R.body)};for(const R of d)S(R)},p=[];for(const e of b){const l=B(e);l.size>0&&p.push({pf:e,apps:l})}const c=new Set;if(p.length>1)for(const{pf:e}of p)for(const l of e.imports.values())l.resolvedFile&&c.add(l.resolvedFile);const y=p.filter(e=>!c.has(e.pf.path)),m=y.length>0?y:p;for(const{pf:e,apps:l}of m){const d=`entry:${e.path}`;w({id:d,type:"entry",label:e.path,file:e.path,line:1});for(const[i,o]of l.entries())v(e,new Set([i]),e.ast.program.body,d,o??"",[])}return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"hono-app",framework:"hono",scannedFiles:u.length,scanDurationMs:Math.round((performance.now()-r)*100)/100,unresolvedMounts:j},nodes:Array.from($.values()),edges:Array.from(A.values())}}},ds=new Set(["get","post","put","patch","delete","options","head","all"]),Tt=/\.(ts|tsx|js|jsx|mjs|cjs)$/i,Ct=/(\.test\.|\.spec\.|__tests__|__mocks__)/i;function De(n){let t=n;for(;t.type==="TSAsExpression"||t.type==="TSSatisfiesExpression"||t.type==="TSTypeAssertion"||t.type==="ParenthesizedExpression";)t=t.expression;return t}function he(n){return n?n.type==="Identifier"?n.name:n.type==="StringLiteral"?n.value:null:null}function Le(n){if(n.type==="Identifier")return n.name;if(n.type==="MemberExpression"){const t=Le(n.object),r=he(n.property)??"";return t?`${t}.${r}`:r}return n.type==="CallExpression"?Le(n.callee):"anonymous"}function yt(n,t){if(!n)return;const r=De(n);if(r.type==="ObjectExpression"){for(const s of r.properties)if(s.type==="ObjectProperty"&&he(s.key)==="properties"){const u=De(s.value);if(u.type==="ObjectExpression"){for(const f of u.properties)if(f.type==="ObjectProperty"){const E=he(f.key);E&&t.add(E)}}}}}var fs=class{constructor(){ue(this,"name","fastify")}detect(n){const t=n.find(r=>oe(r.path)==="package.json");return t&&/"fastify"\s*:/.test(t.content)?!0:n.some(r=>Tt.test(r.path)&&!Ct.test(r.path)&&/from\s+['"]fastify['"]|require\(\s*['"]fastify['"]\s*\)/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(v=>({path:oe(v.path),content:v.content})),u=s.filter(v=>Tt.test(v.path)&&!Ct.test(v.path)),f=new Set(s.map(v=>v.path)),E=et(s),x=new Map;for(const v of u){const p=We(v,f,E);p&&x.set(v.path,p)}const b=Array.from(x.values()),$=new Map,A=new Map,j=[],w=v=>{$.has(v.id)||$.set(v.id,v)},M=v=>{A.has(v.id)||A.set(v.id,v)},D=(v,p,c=0)=>{var m,e,l;if(c>8)return null;const y=De(p);if(y.type==="Identifier"){const d=v.imports.get(y.name);if(d!=null&&d.resolvedFile){const o=x.get(d.resolvedFile);if(!o)return null;if(d.importedName==="*")return{file:o,node:o.ast.program,name:y.name,line:1};const a=o.exports.get(d.importedName);if(a)return a.node.type==="Identifier"&&a.node.name!==y.name?D(o,a.node,c+1)??{file:o,node:a.node,name:d.importedName,localName:a.localName,line:a.line}:{file:o,node:a.node,name:d.importedName==="default"?y.name:d.importedName,localName:a.localName,line:a.line}}const i=v.locals.get(y.name);if(i)return{file:v,node:i,name:y.name,line:((m=i.loc)==null?void 0:m.start.line)??1}}if(y.type==="MemberExpression"){const d=he(y.property);if(!d)return null;const i=D(v,y.object,c+1);if(!i)return null;const o=De(i.node);if(o.type==="Program"){const a=i.file.exports.get(d);if(a)return{file:i.file,node:a.node,name:`${i.name}.${d}`,line:a.line}}if(o.type==="ObjectExpression"){for(const a of o.properties)if(a.type==="ObjectProperty"&&he(a.key)===d)return{file:i.file,node:a.value,name:`${i.name}.${d}`,line:((e=a.loc)==null?void 0:e.start.line)??1}}}if(y.type==="CallExpression"){const d=ze(y);if(d){const i=Ce(v.path,d,f,E),o=i?x.get(i):void 0,a=o==null?void 0:o.exports.get("default");if(o&&a)return{file:o,node:a.node,name:d,localName:a.localName,line:a.line}}if(y.arguments[0]&&y.arguments[0].type!=="SpreadElement"){const i=y.arguments[0];if(i.type==="FunctionExpression"||i.type==="ArrowFunctionExpression")return{file:v,node:i,name:Le(y.callee),line:((l=i.loc)==null?void 0:l.start.line)??1}}}return null},P=(v,p,c=0)=>{if(!p||c>8)return null;const y=De(p);if(y.type==="StringLiteral")return y.value;if(y.type==="TemplateLiteral"){let m="";for(let e=0;e<y.quasis.length;e++)if(m+=y.quasis[e].value.cooked??y.quasis[e].value.raw,e<y.expressions.length){const l=P(v,y.expressions[e],c+1);if(l===null)return null;m+=l}return m}if(y.type==="BinaryExpression"&&y.operator==="+"){const m=P(v,y.left,c+1),e=P(v,y.right,c+1);return m!==null&&e!==null?m+e:null}if(y.type==="Identifier"||y.type==="MemberExpression"){const m=D(v,y);if(m)return P(m.file,m.node,c+1)}return null},q=v=>{const p=new Set,c=new Set;for(const[m,e]of v.imports.entries())e.sourceSpecifier==="fastify"&&(e.importedName==="default"||e.importedName==="*")&&c.add(m);const y=m=>{if(!(!m||typeof m!="object")){if(m.type==="VariableDeclarator"&&m.id.type==="Identifier"&&m.init){const e=De(m.init);e.type==="CallExpression"&&e.callee.type==="Identifier"&&c.has(e.callee.name)&&p.add(m.id.name)}for(const e of Object.keys(m)){if(e==="loc"||e==="start"||e==="end"||e==="extra")continue;const l=m[e];if(Array.isArray(l))for(const d of l)d&&typeof d=="object"&&"type"in d&&y(d);else l&&typeof l=="object"&&"type"in l&&y(l)}}};return y(v.ast.program),p},B=(v,p,c,y,m,e,l,d)=>{var F;const i=[...d],o=new Set,a=new Set,h=new Set;if(m){for(const k of m.properties)if(k.type==="ObjectProperty"){const I=he(k.key);if(I==="preHandler"||I==="onRequest")if(k.value.type==="ArrayExpression")for(const Z of k.value.elements)Z&&Z.type!=="SpreadElement"&&i.push(Le(Z));else i.push(Le(k.value));else if(I==="schema"&&k.value.type==="ObjectExpression"){for(const Z of k.value.properties)if(Z.type==="ObjectProperty"){const U=he(Z.key);U==="body"?yt(Z.value,o):U==="querystring"||U==="query"?yt(Z.value,a):U==="params"&&yt(Z.value,h)}}}}let g="inlineHandler",N=e.path,S=((F=y.loc)==null?void 0:F.start.line)??l,R=y;if(y.type!=="ArrowFunctionExpression"&&y.type!=="FunctionExpression"&&y.type!=="ObjectMethod"){g=Le(y);const k=D(e,y);k&&(R=k.node,N=k.file.path,S=k.line)}const O=Pt(R),z=Array.from(new Set([...fe(c),...O.pathParams,...h])),G=Array.from(new Set([...O.queryParams,...a])),W=Array.from(new Set([...O.bodyFields,...o])),H=me(c),_=`route:${p}:${c}`;w({id:_,type:"route",label:`${p} ${c}`,file:e.path,line:l,method:p,fullPath:c,pathParams:z,queryParams:G,bodyFields:W,group:H,middlewares:i,controller:g,controllerFile:N,controllerLine:S}),M({id:`edge:${v}->${_}`,source:v,target:_,type:"handles"});for(const k of i){const I=`mw:${k}`;w({id:I,type:"middleware",label:k,file:e.path,line:l}),M({id:`edge:${_}->${I}`,source:_,target:I,type:"uses"})}const C=`ctrl:${N}:${g}:${S}`;w({id:C,type:"controller",label:g,file:N,line:S}),M({id:`edge:${_}->${C}`,source:_,target:C,type:"calls"})},V=new Set,T=(v,p,c,y,m,e)=>{const l=`${v.path}:${Array.from(p).join(",")}:${m}`;if(V.has(l))return;V.add(l);const d=o=>{var g,N,S,R,O,z,G;if(o.callee.type!=="MemberExpression"||o.callee.object.type!=="Identifier"||!p.has(o.callee.object.name))return;const a=he(o.callee.property),h=((g=o.loc)==null?void 0:g.start.line)??1;if(a){if(a==="register"){const W=o.arguments[0],H=((N=o.arguments[1])==null?void 0:N.type)==="ObjectExpression"?o.arguments[1]:null;let _="",C;if(H){for(const k of H.properties)if(k.type==="ObjectProperty"){const I=he(k.key);if(I==="prefix"&&(_=P(v,k.value)??""),I==="dir"&&(C=k.value),I==="options"&&k.value.type==="ObjectExpression")for(const Z of k.value.properties)Z.type==="ObjectProperty"&&he(Z.key)==="prefix"&&(_=P(v,Z.value)??_)}}const F=_?ne(m,_):m;if(C){let k=null;if(C.type==="CallExpression"&&(C.callee.type==="MemberExpression"&&he(C.callee.property)==="join"||C.callee.type==="Identifier"&&C.callee.name==="join")){const I=[];for(const Z of C.arguments){if(Z.type==="Identifier"&&Z.name==="__dirname")continue;const U=P(v,Z);U!==null&&I.push(U)}I.length>0&&(k=I.join("/"))}else k=P(v,C);if(k){const I=oe(le(Re(v.path),k)),Z=I?`${I}/`:"";for(const U of b)if(U.path.startsWith(Z)){const J=U.exports.get("default");let K=J==null?void 0:J.node;if((K==null?void 0:K.type)==="CallExpression"&&K.arguments[0]&&K.arguments[0].type!=="SpreadElement"&&(K=K.arguments[0]),K&&(K.type==="FunctionDeclaration"||K.type==="FunctionExpression"||K.type==="ArrowFunctionExpression")&&K.body.type==="BlockStatement"){const Q=((S=K.params[0])==null?void 0:S.type)==="Identifier"?K.params[0].name:"fastify",te=`router:${U.path}:${F||"/"}`;w({id:te,type:"router",label:F||U.path,file:U.path,line:(J==null?void 0:J.line)??1}),M({id:`edge:${y}->${te}`,source:y,target:te,type:"mounts"}),T(U,new Set([Q]),K.body.body,te,F,e)}}return}}if(W){const k=D(v,W);if(k&&(k.node.type==="FunctionDeclaration"||k.node.type==="FunctionExpression"||k.node.type==="ArrowFunctionExpression")&&k.node.body.type==="BlockStatement"){const I=((R=k.node.params[0])==null?void 0:R.type)==="Identifier"?k.node.params[0].name:"fastify",Z=`router:${k.file.path}:${F||"/"}`;w({id:Z,type:"router",label:F||k.name,file:k.file.path,line:k.line}),M({id:`edge:${y}->${Z}`,source:y,target:Z,type:"mounts",label:_||"/"}),T(k.file,new Set([I]),k.node.body.body,Z,F,e)}else j.push(`${v.path}:${((O=o.loc)==null?void 0:O.start.line)??1} (unresolved Fastify plugin)`)}return}if(a==="route"&&((z=o.arguments[0])==null?void 0:z.type)==="ObjectExpression"){const W=o.arguments[0];let H=[],_=null,C;for(const F of W.properties)if(F.type==="ObjectProperty"){const k=he(F.key);if(k==="method")if(F.value.type==="ArrayExpression")for(const I of F.value.elements){const Z=P(v,I);Z&&H.push(Z.toUpperCase())}else{const I=P(v,F.value);I&&H.push(I.toUpperCase())}else k==="url"||k==="path"?_=P(v,F.value):k==="handler"&&(C=F.value)}else F.type==="ObjectMethod"&&he(F.key)==="handler"&&(C=F);if(_!==null&&C&&H.length>0){const F=ne(m,_);for(const k of H)B(y,k,F,C,W,v,h,e)}return}if(ds.has(a)){const W=P(v,o.arguments[0]);if(W===null){j.push(`${v.path}:${h} (dynamic Fastify route path)`);return}const H=ne(m,W),_=((G=o.arguments[1])==null?void 0:G.type)==="ObjectExpression"?o.arguments[1]:null,C=_?o.arguments[2]:o.arguments[1];C&&B(y,a.toUpperCase(),H,C,_,v,h,e)}}},i=o=>{if(o){if(o.type==="ExpressionStatement"){const a=o.expression.type==="AwaitExpression"?o.expression.argument:o.expression;a.type==="CallExpression"&&d(a)}else if(o.type==="BlockStatement")for(const a of o.body)i(a);else if(o.type==="IfStatement")i(o.consequent),i(o.alternate);else if(o.type==="FunctionDeclaration"&&o.body)i(o.body);else if(o.type==="VariableDeclaration")for(const a of o.declarations)a.init&&(a.init.type==="ArrowFunctionExpression"||a.init.type==="FunctionExpression")&&a.init.body.type==="BlockStatement"&&i(a.init.body)}};for(const o of c)i(o)};for(const v of b){const p=q(v);if(p.size>0){const c=`entry:${v.path}`;w({id:c,type:"entry",label:v.path,file:v.path,line:1}),T(v,p,v.ast.program.body,c,"",[])}}return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"fastify-app",framework:"fastify",scannedFiles:u.length,scanDurationMs:Math.round((performance.now()-r)*100)/100,unresolvedMounts:j},nodes:Array.from($.values()),edges:Array.from(A.values())}}},It={Get:"GET",Post:"POST",Put:"PUT",Patch:"PATCH",Delete:"DELETE",Options:"OPTIONS",Head:"HEAD",All:"ALL"},gt=/\.(ts|tsx|js|jsx|mjs|cjs)$/i,Ft=/(\.test\.|\.spec\.|__tests__|__mocks__)/i;function Ye(n){return n?n.type==="Identifier"?n.name:n.type==="StringLiteral"?n.value:null:null}function pt(n){return n?n.type==="StringLiteral"?n.value:n.type==="TemplateLiteral"&&n.expressions.length===0?n.quasis.map(t=>t.value.cooked??t.value.raw).join(""):null:null}function ft(n){if(n.type==="Identifier")return n.name;if(n.type==="MemberExpression"){const t=ft(n.object),r=Ye(n.property)??"";return t?`${t}.${r}`:r}return n.type==="CallExpression"?ft(n.callee):"anonymous"}function Rt(n){if(n.expression.type!=="CallExpression")return[""];const t=n.expression.arguments[0];if(!t)return[""];const r=pt(t);if(r!==null)return[r];if(t.type==="ArrayExpression"){const s=[];for(const u of t.elements)if(u&&u.type!=="SpreadElement"){const f=pt(u);f!==null&&s.push(f)}return s.length>0?s:[""]}if(t.type==="ObjectExpression"){for(const s of t.properties)if(s.type==="ObjectProperty"&&Ye(s.key)==="path"){const u=pt(s.value);if(u!==null)return[u]}}return[""]}function xt(n){return n.expression.type==="CallExpression"&&n.expression.callee.type==="Identifier"?n.expression.callee.name:n.expression.type==="Identifier"?n.expression.name:null}var ms=class{constructor(){ue(this,"name","nestjs")}detect(n){const t=n.find(r=>oe(r.path)==="package.json");return t&&/"@nestjs\/(?:common|core)"\s*:/.test(t.content)?!0:n.some(r=>gt.test(r.path)&&!Ft.test(r.path)&&/from\s+['"]@nestjs\/common['"]/.test(r.content))}scan(n,t){var V,T,v,p,c,y,m;const r=performance.now(),s=n.map(e=>({path:oe(e.path),content:e.content})),u=s.filter(e=>gt.test(e.path)&&!Ft.test(e.path)),f=new Set(s.map(e=>e.path)),E=et(s),x=new Map;for(const e of u){const l=We(e,f,E);l&&x.set(e.path,l)}const b=Array.from(x.values()),$=new Map,A=new Map,j=e=>{$.has(e.id)||$.set(e.id,e)},w=e=>{A.has(e.id)||A.set(e.id,e)},M=new Map;for(const e of b)for(const l of e.ast.program.body){const d=l.type==="ExportNamedDeclaration"&&l.declaration?l.declaration:l;if(d.type==="ClassDeclaration"&&d.id){const i=[];for(const o of d.body.body)if(o.type==="ClassProperty"){const a=Ye(o.key);a&&i.push(a)}i.length>0&&M.set(d.id.name,i)}else if(d.type==="TSInterfaceDeclaration"){const i=[];for(const o of d.body.body)if(o.type==="TSPropertySignature"){const a=Ye(o.key);a&&i.push(a)}i.length>0&&M.set(d.id.name,i)}}let D="",P="main.ts",q;for(const e of s){if(!gt.test(e.path))continue;const l=e.content.match(/\.setGlobalPrefix\(\s*['"`]([^'"`]+)['"`]/);l&&(D=l[1],P=e.path);const d=e.content.match(/\.listen\(\s*(\d{2,5})\b/);d&&!q&&(q=Number(d[1]))}const B=`entry:${P}`;j({id:B,type:"entry",label:P,file:P,line:1});for(const e of b)for(const l of e.ast.program.body){const d=l.type==="ExportNamedDeclaration"&&l.declaration||l.type==="ExportDefaultDeclaration"&&l.declaration.type==="ClassDeclaration"?l.declaration:l;if(d.type!=="ClassDeclaration"||!((V=d.decorators)!=null&&V.length))continue;let i=null;const o=[];for(const h of d.decorators){const g=xt(h);if(g==="Controller")i=Rt(h);else if((g==="UseGuards"||g==="UseInterceptors"||g==="UsePipes")&&h.expression.type==="CallExpression")for(const N of h.expression.arguments)N.type!=="SpreadElement"&&o.push(ft(N))}if(!i)continue;const a=((T=d.id)==null?void 0:T.name)??"Controller";for(const h of i){const g=ne(D,h),N=`router:${e.path}:${a}:${g||"/"}`;j({id:N,type:"router",label:g||a,file:e.path,line:((v=d.loc)==null?void 0:v.start.line)??1}),w({id:`edge:${B}->${N}`,source:B,target:N,type:"mounts",label:g||"/"});for(const S of d.body.body){if(S.type!=="ClassMethod"||!((p=S.decorators)!=null&&p.length))continue;const R=[],O=[...o];for(const F of S.decorators){const k=xt(F);if(k&&k in It)R.push({method:It[k],paths:Rt(F)});else if((k==="UseGuards"||k==="UseInterceptors"||k==="UsePipes")&&F.expression.type==="CallExpression")for(const I of F.expression.arguments)I.type!=="SpreadElement"&&O.push(ft(I))}if(R.length===0)continue;const z=new Set,G=new Set,W=new Set;for(const F of S.params)if(!(F.type!=="Identifier"||!((c=F.decorators)!=null&&c.length)))for(const k of F.decorators){const I=xt(k),Z=k.expression.type==="CallExpression"?pt(k.expression.arguments[0]):null;if(I==="Param"&&Z)z.add(Z);else if(I==="Query"&&Z)G.add(Z);else if(I==="Body"){if(Z)W.add(Z);else if(((y=F.typeAnnotation)==null?void 0:y.type)==="TSTypeAnnotation"&&F.typeAnnotation.typeAnnotation.type==="TSTypeReference"&&F.typeAnnotation.typeAnnotation.typeName.type==="Identifier"){const U=F.typeAnnotation.typeAnnotation.typeName.name;for(const J of M.get(U)??[])W.add(J)}}}const H=Ye(S.key)??"handler",_=`${a}.${H}`,C=((m=S.loc)==null?void 0:m.start.line)??1;for(const F of R)for(const k of F.paths){const I=ne(g,k),Z=Array.from(new Set([...fe(I),...z])),U=`route:${F.method}:${I}`;j({id:U,type:"route",label:`${F.method} ${I}`,file:e.path,line:C,method:F.method,fullPath:I,pathParams:Z,queryParams:Array.from(G),bodyFields:Array.from(W),group:me(I),middlewares:O,controller:_,controllerFile:e.path,controllerLine:C}),w({id:`edge:${N}->${U}`,source:N,target:U,type:"handles"});for(const K of O){const Q=`mw:${K}`;j({id:Q,type:"middleware",label:K,file:e.path,line:C}),w({id:`edge:${U}->${Q}`,source:U,target:Q,type:"uses"})}const J=`ctrl:${e.path}:${_}:${C}`;j({id:J,type:"controller",label:_,file:e.path,line:C}),w({id:`edge:${U}->${J}`,source:U,target:J,type:"calls"})}}}}return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"nestjs-app",framework:"nestjs",detectedPort:q,scannedFiles:u.length,scanDurationMs:Math.round((performance.now()-r)*100)/100,unresolvedMounts:[]},nodes:Array.from($.values()),edges:Array.from(A.values())}}},zt=new Set(["get","post","put","patch","delete","del","options","head","all"]),Ot=/\.(ts|tsx|js|jsx|mjs|cjs)$/i,Dt=/(\.test\.|\.spec\.|__tests__|__mocks__)/i;function He(n){let t=n;for(;t.type==="TSAsExpression"||t.type==="TSSatisfiesExpression"||t.type==="TSTypeAssertion"||t.type==="ParenthesizedExpression";)t=t.expression;return t}function be(n){return n?n.type==="Identifier"?n.name:n.type==="StringLiteral"?n.value:null:null}function Xe(n){if(n.type==="Identifier")return n.name;if(n.type==="MemberExpression"){const t=Xe(n.object),r=be(n.property)??"";return t?`${t}.${r}`:r}return n.type==="CallExpression"?Xe(n.callee):"anonymous"}function hs(n){var x;const t=new Set,r=new Set,s=new Set;if(n.type!=="FunctionDeclaration"&&n.type!=="FunctionExpression"&&n.type!=="ArrowFunctionExpression"&&n.type!=="ObjectMethod"&&n.type!=="ClassMethod")return{pathParams:[],queryParams:[],bodyFields:[]};const u=((x=n.params[0])==null?void 0:x.type)==="Identifier"?n.params[0].name:"ctx",f=b=>{if(b.type==="LogicalExpression")return f(b.left);if(b.type==="MemberExpression"&&b.object.type==="Identifier"&&b.object.name===u){const $=be(b.property);if($==="params")return t;if($==="query")return r}if(b.type==="MemberExpression"&&b.object.type==="MemberExpression"&&b.object.object.type==="Identifier"&&b.object.object.name===u&&be(b.object.property)==="request"){const $=be(b.property);if($==="body")return s;if($==="query")return r}return null},E=b=>{if(!(!b||typeof b!="object")){if(b.type==="MemberExpression"){const $=f(b.object),A=be(b.property);$&&A&&$.add(A)}if(b.type==="VariableDeclarator"&&b.init&&b.id.type==="ObjectPattern"){const $=f(b.init);if($){for(const A of b.id.properties)if(A.type==="ObjectProperty"){const j=be(A.key);j&&$.add(j)}}}for(const $ of Object.keys(b)){if($==="loc"||$==="start"||$==="end"||$==="extra")continue;const A=b[$];if(Array.isArray(A))for(const j of A)j&&typeof j=="object"&&"type"in j&&E(j);else A&&typeof A=="object"&&"type"in A&&E(A)}}};return E(n.body),{pathParams:Array.from(t),queryParams:Array.from(r),bodyFields:Array.from(s)}}var ys=class{constructor(){ue(this,"name","koa")}detect(n){const t=n.find(r=>oe(r.path)==="package.json");return t&&/"(?:koa|@koa\/router|koa-router)"\s*:/.test(t.content)?!0:n.some(r=>Ot.test(r.path)&&!Dt.test(r.path)&&/(?:from\s+['"](?:koa|@koa\/router|koa-router)['"]|require\(\s*['"](?:koa|@koa\/router|koa-router)['"]\s*\))/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(p=>({path:oe(p.path),content:p.content})),u=s.filter(p=>Ot.test(p.path)&&!Dt.test(p.path)),f=new Set(s.map(p=>p.path)),E=et(s),x=new Map;for(const p of u){const c=We(p,f,E);c&&x.set(p.path,c)}const b=Array.from(x.values()),$=new Map,A=new Map,j=[],w=p=>{$.has(p.id)||$.set(p.id,p)},M=p=>{A.has(p.id)||A.set(p.id,p)},D=(p,c,y=0)=>{var e;if(y>8)return null;const m=He(c);if(m.type==="Identifier"){const l=p.imports.get(m.name);if(l!=null&&l.resolvedFile){const i=x.get(l.resolvedFile);if(!i)return null;if(l.importedName==="*")return{file:i,node:i.ast.program,name:m.name,line:1};const o=i.exports.get(l.importedName);if(o)return{file:i,node:o.node,name:l.importedName==="default"?m.name:l.importedName,localName:o.localName,line:o.line}}const d=p.locals.get(m.name);if(d)return{file:p,node:d,name:m.name,line:((e=d.loc)==null?void 0:e.start.line)??1}}if(m.type==="MemberExpression"){const l=be(m.property);if(!l)return null;const d=D(p,m.object,y+1);if(!d)return null;if(He(d.node).type==="Program"){const o=d.file.exports.get(l);if(o)return{file:d.file,node:o.node,name:`${d.name}.${l}`,line:o.line}}}if(m.type==="CallExpression"){if(m.callee.type==="MemberExpression"&&be(m.callee.property)==="routes")return D(p,m.callee.object,y+1);const l=ze(m);if(l){const d=Ce(p.path,l,f,E),i=d?x.get(d):void 0,o=i==null?void 0:i.exports.get("default");if(i&&o)return{file:i,node:o.node,name:l,localName:o.localName,line:o.line}}}return null},P=(p,c,y=0)=>{if(!c||y>8)return null;const m=He(c);if(m.type==="StringLiteral")return m.value;if(m.type==="TemplateLiteral"){let e="";for(let l=0;l<m.quasis.length;l++)if(e+=m.quasis[l].value.cooked??m.quasis[l].value.raw,l<m.expressions.length){const d=P(p,m.expressions[l],y+1);if(d===null)return null;e+=d}return e}if(m.type==="BinaryExpression"&&m.operator==="+"){const e=P(p,m.left,y+1),l=P(p,m.right,y+1);return e!==null&&l!==null?e+l:null}if(m.type==="Identifier"||m.type==="MemberExpression"){const e=D(p,m);if(e)return P(e.file,e.node,y+1)}return null},q=p=>{const c=new Set,y=new Map,m=new Set,e=new Set;for(const[d,i]of p.imports.entries())i.sourceSpecifier==="koa"&&m.add(d),(i.sourceSpecifier==="@koa/router"||i.sourceSpecifier==="koa-router")&&e.add(d);const l=d=>{if(!(!d||typeof d!="object")){if(d.type==="VariableDeclarator"&&d.id.type==="Identifier"&&d.init){const i=He(d.init);if(i.type==="NewExpression"&&i.callee.type==="Identifier"){if(m.has(i.callee.name))c.add(d.id.name);else if(e.has(i.callee.name)){let o="";const a=i.arguments[0];if((a==null?void 0:a.type)==="ObjectExpression")for(const h of a.properties)h.type==="ObjectProperty"&&be(h.key)==="prefix"&&(o=P(p,h.value)??"");y.set(d.id.name,o)}}}for(const i of Object.keys(d)){if(i==="loc"||i==="start"||i==="end"||i==="extra")continue;const o=d[i];if(Array.isArray(o))for(const a of o)a&&typeof a=="object"&&"type"in a&&l(a);else o&&typeof o=="object"&&"type"in o&&l(o)}}};return l(p.ast.program),{apps:c,routers:y}},B=(p,c,y,m,e,l,d)=>{var W;if(m.length===0)return;const i=m[m.length-1],o=m.slice(0,-1),a=[...d];for(const H of o){const _=Xe(H);_&&_!=="anonymous"&&!a.includes(_)&&a.push(_)}let h="inlineHandler",g=e.path,N=((W=i.loc)==null?void 0:W.start.line)??l,S=i;if(i.type!=="ArrowFunctionExpression"&&i.type!=="FunctionExpression"){h=Xe(i);const H=D(e,i);H&&(S=H.node,g=H.file.path,N=H.line)}const R=hs(S),O=Array.from(new Set([...fe(y),...R.pathParams])),z=`route:${c}:${y}`;w({id:z,type:"route",label:`${c} ${y}`,file:e.path,line:l,method:c,fullPath:y,pathParams:O,queryParams:R.queryParams,bodyFields:R.bodyFields,group:me(y),middlewares:a,controller:h,controllerFile:g,controllerLine:N}),M({id:`edge:${p}->${z}`,source:p,target:z,type:"handles"});for(const H of a){const _=`mw:${H}`;w({id:_,type:"middleware",label:H,file:e.path,line:l}),M({id:`edge:${z}->${_}`,source:z,target:_,type:"uses"})}const G=`ctrl:${g}:${h}:${N}`;w({id:G,type:"controller",label:h,file:g,line:N}),M({id:`edge:${z}->${G}`,source:z,target:G,type:"calls"})},V=new Set,T=(p,c,y,m,e,l)=>{const d=`${p.path}:${Array.from(c).join(",")}:${e}`;if(V.has(d))return;V.add(d);let i=e;const o=[...l],a=g=>{var R;const N=[];let S=g;for(;S.type==="CallExpression"&&S.callee.type==="MemberExpression";){const O=be(S.callee.property);if(!O||O!=="use"&&O!=="prefix"&&!zt.has(O))break;N.push({methodName:O,args:S.arguments,line:((R=S.loc)==null?void 0:R.start.line)??1}),S=He(S.callee.object)}if(N.length!==0&&!(S.type!=="Identifier"||!c.has(S.name))){for(const O of N.reverse())if(O.methodName==="prefix"){const z=P(p,O.args[0]);z!==null&&(i=ne(i,z))}else if(O.methodName==="use"){const z=P(p,O.args[0]),G=z?ne(i,z):i,W=z?O.args.slice(1):O.args;for(const H of W){if(H.type==="CallExpression"&&H.callee.type==="MemberExpression"&&be(H.callee.property)==="allowedMethods")continue;const _=D(p,H);if(_){const{routers:F}=q(_.file),k=_.localName??_.name;if(F.has(k)){const I=F.get(k)??"",Z=I?ne(G,I):G,U=`router:${_.file.path}:${Z||"/"}`;w({id:U,type:"router",label:Z||_.name,file:_.file.path,line:_.line}),M({id:`edge:${m}->${U}`,source:m,target:U,type:"mounts"}),T(_.file,new Set([k]),_.file.ast.program.body,U,Z,o);continue}}const C=Xe(H);C&&C!=="anonymous"&&!o.includes(C)&&o.push(C)}}else if(zt.has(O.methodName)){const z=O.methodName==="del"?"DELETE":O.methodName.toUpperCase();let G=0;const W=P(p,O.args[0]),H=P(p,O.args[1]);W!==null&&!W.startsWith("/")&&H!==null&&H.startsWith("/")&&(G=1);const _=P(p,O.args[G]);if(_===null){j.push(`${p.path}:${O.line} (dynamic Koa route path)`);continue}const C=ne(i,_);B(m,z,C,O.args.slice(G+1),p,O.line,o)}}},h=g=>{if(g)if(g.type==="ExpressionStatement"){const N=g.expression.type==="AwaitExpression"?g.expression.argument:g.expression;if(N.type==="CallExpression"){a(N);let S=N;for(;S.type==="CallExpression";){for(const R of S.arguments)(R.type==="ArrowFunctionExpression"||R.type==="FunctionExpression")&&R.body.type==="BlockStatement"&&h(R.body);if(S.callee.type==="MemberExpression")S=S.callee.object;else break}}}else if(g.type==="BlockStatement")for(const N of g.body)h(N);else g.type==="IfStatement"?(h(g.consequent),h(g.alternate)):g.type==="FunctionDeclaration"&&g.body&&h(g.body)};for(const g of y)h(g)},v=[];for(const p of b){const{apps:c}=q(p);c.size>0&&v.push({pf:p,apps:c})}if(v.length>0)for(const{pf:p,apps:c}of v){const y=`entry:${p.path}`;w({id:y,type:"entry",label:p.path,file:p.path,line:1}),T(p,c,p.ast.program.body,y,"",[])}else for(const p of b){const{routers:c}=q(p);for(const[y,m]of c.entries()){const e=`router:${p.path}:${m||"/"}`;w({id:e,type:"router",label:m||p.path,file:p.path,line:1}),T(p,new Set([y]),p.ast.program.body,e,m,[])}}return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"koa-app",framework:"koa",scannedFiles:u.length,scanDurationMs:Math.round((performance.now()-r)*100)/100,unresolvedMounts:j},nodes:Array.from($.values()),edges:Array.from(A.values())}}},Lt=/(?:^|.*\/)(?:src\/)?app\/(?:(.*)\/)?route\.(ts|tsx|js|jsx|mjs|cjs)$/i,Zt=/(?:^|.*\/)(?:src\/)?pages\/api\/(.+)\.(ts|tsx|js|jsx|mjs|cjs)$/i,gs=/(?:^|\/)next\.config\.(js|mjs|ts|cjs)$/i,$t=new Set(["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"]);function Ze(n){return n?n.type==="Identifier"?n.name:n.type==="StringLiteral"?n.value:null:null}function qt(n){const t=[];for(const r of n){if(!r||r.startsWith("(")&&r.endsWith(")")||r.startsWith("@"))continue;const s=r.match(/^\[{1,2}\.\.\.([^\]]+)\]{1,2}$/);if(s){t.push(`*${s[1]}`);continue}const u=r.match(/^\[([^\]]+)\]$/);if(u){t.push(`:${u[1]}`);continue}t.push(r)}return"/"+t.join("/")}function xs(n){const t=new Set,r=new Set,s=u=>{var f;if(!(!u||typeof u!="object")){if(u.type==="CallExpression"&&u.callee.type==="MemberExpression"&&Ze(u.callee.property)==="get"&&((f=u.arguments[0])==null?void 0:f.type)==="StringLiteral"){const E=u.callee.object;(E.type==="Identifier"&&E.name==="searchParams"||E.type==="MemberExpression"&&Ze(E.property)==="searchParams")&&t.add(u.arguments[0].value)}if(u.type==="VariableDeclarator"&&u.init&&u.id.type==="ObjectPattern"){const E=u.init.type==="AwaitExpression"?u.init.argument:u.init;if(E.type==="CallExpression"&&E.callee.type==="MemberExpression"&&Ze(E.callee.property)==="json"){for(const x of u.id.properties)if(x.type==="ObjectProperty"){const b=Ze(x.key);b&&r.add(b)}}}for(const E of Object.keys(u)){if(E==="loc"||E==="start"||E==="end"||E==="extra")continue;const x=u[E];if(Array.isArray(x))for(const b of x)b&&typeof b=="object"&&"type"in b&&s(b);else x&&typeof x=="object"&&"type"in x&&s(x)}}};return s(n),{queryParams:Array.from(t),bodyFields:Array.from(r)}}function bs(n){const t=new Set,r=s=>{var u;if(!(!s||typeof s!="object")){if(s.type==="BinaryExpression"&&(s.operator==="==="||s.operator==="=="||s.operator==="!=="||s.operator==="!=")){const f=(E,x)=>{if(E.type==="MemberExpression"&&Ze(E.property)==="method"&&x.type==="StringLiteral"){const b=x.value.toUpperCase();$t.has(b)&&t.add(b)}};f(s.left,s.right),f(s.right,s.left)}else if(s.type==="SwitchStatement"&&s.discriminant.type==="MemberExpression"&&Ze(s.discriminant.property)==="method"){for(const f of s.cases)if(((u=f.test)==null?void 0:u.type)==="StringLiteral"){const E=f.test.value.toUpperCase();$t.has(E)&&t.add(E)}}for(const f of Object.keys(s)){if(f==="loc"||f==="start"||f==="end"||f==="extra")continue;const E=s[f];if(Array.isArray(E))for(const x of E)x&&typeof x=="object"&&"type"in x&&r(x);else E&&typeof E=="object"&&"type"in E&&r(E)}}};return r(n.ast.program),t.size>0?Array.from(t):["ALL"]}var ws=class{constructor(){ue(this,"name","nextjs")}detect(n){return n.some(r=>(oe(r.path)==="package.json"||oe(r.path).endsWith("/package.json"))&&/"next"\s*:/.test(r.content))?n.some(r=>{const s=oe(r.path);return Lt.test(s)||Zt.test(s)}):!1}scan(n,t){const r=performance.now(),s=n.map(P=>({path:oe(P.path),content:P.content})),u=new Set(s.map(P=>P.path));let f="";for(const P of s)if(gs.test(P.path)){const q=P.content.match(/\bbasePath\s*:\s*['"`]([^'"`]+)['"`]/);if(q){f=q[1];break}}const E=new Map,x=new Map,b=P=>{E.has(P.id)||E.set(P.id,P)},$=P=>{x.has(P.id)||x.set(P.id,P)},A="entry:nextjs-app-router",j="entry:nextjs-pages-router";let w=!1,M=!1,D=0;for(const P of s){const q=P.path.match(Lt),B=q?null:P.path.match(Zt);if(!q&&!B)continue;const V=We(P,u);if(V){if(D++,q){w||(w=!0,b({id:A,type:"entry",label:"app/ (App Router)",file:P.path,line:1}));const T=q[1]?q[1].split("/"):[],v=qt(T),p=f?ne(f,v):v,c=me(p);for(const[y,m]of V.exports.entries()){const e=y.toUpperCase();if(!$t.has(e))continue;const l=e,d=xs(m.node),i=fe(p),o=`route:${l}:${p}`;b({id:o,type:"route",label:`${l} ${p}`,file:P.path,line:m.line,method:l,fullPath:p,pathParams:i,queryParams:d.queryParams,bodyFields:d.bodyFields,group:c,middlewares:[],controller:y,controllerFile:P.path,controllerLine:m.line}),$({id:`edge:${A}->${o}`,source:A,target:o,type:"handles"})}}else if(B){M||(M=!0,b({id:j,type:"entry",label:"pages/api/ (Pages Router)",file:P.path,line:1}));const T=B[1].split("/");T[T.length-1]==="index"&&T.pop();const v=ne("/api",qt(T)),p=f?ne(f,v):v,c=me(p),y=V.exports.get("default"),m=y?Pt(y.node):{pathParams:[],queryParams:[],bodyFields:[]},e=bs(V),l=Array.from(new Set([...fe(p),...m.pathParams]));for(const d of e){const i=`route:${d}:${p}`;b({id:i,type:"route",label:`${d} ${p}`,file:P.path,line:(y==null?void 0:y.line)??1,method:d,fullPath:p,pathParams:l,queryParams:m.queryParams,bodyFields:m.bodyFields,group:c,middlewares:[],controller:(y==null?void 0:y.localName)??"handler",controllerFile:P.path,controllerLine:(y==null?void 0:y.line)??1}),$({id:`edge:${j}->${i}`,source:j,target:i,type:"handles"})}}}}return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"nextjs-app",framework:"nextjs",scannedFiles:D,scanDurationMs:Math.round((performance.now()-r)*100)/100,unresolvedMounts:[]},nodes:Array.from(E.values()),edges:Array.from(x.values())}}},Gt=/(?:^|\/)(?:tests?|__tests__)\/|test_[^/]+\.py$|_test\.py$/i,vs=new Set(["get","post","put","patch","delete","options","head"]);function bt(n,t,r){let s=n.includes("/")?n.slice(0,n.lastIndexOf("/")):"",u=t.modulePath;if(u.startsWith(".")){let x=0;for(;u[x]===".";)x++;for(let b=1;b<x;b++)s=s.includes("/")?s.slice(0,s.lastIndexOf("/")):"";u=u.slice(x)}else s="";const f=u?u.replace(/\./g,"/"):"",E=[];if(s&&f)E.push(le(s,`${f}.py`),le(s,`${f}/__init__.py`));else if(f){E.push(`${f}.py`,`${f}/__init__.py`);for(const x of r)(x.endsWith(`/${f}.py`)||x.endsWith(`/${f}/__init__.py`))&&E.push(x)}else s&&E.push(le(s,"__init__.py"));for(const x of E){const b=oe(x);if(r.has(b))return b}return null}function rt(n){const t=[],r=/Depends\(\s*([A-Za-z_][A-Za-z0-9_.]*)/g;let s;for(;(s=r.exec(n))!==null;)t.includes(s[1])||t.push(s[1]);return t}function ot(n,t){let r=0,s=null,u=!1;for(let f=t;f<n.length;f++){const E=n[f];if(s){u?u=!1:E==="\\"?u=!0:E===s&&(s=null);continue}if(E==='"'||E==="'"){s=E;continue}if(E==="(")r++;else if(E===")"&&(r--,r===0))return{content:n.slice(t+1,f),endIdx:f}}return{content:n.slice(t+1),endIdx:n.length-1}}function Wt(n,t){let r=1;for(let s=0;s<t&&s<n.length;s++)n[s]===`
|
|
8
|
-
`&&r++;return r}var Es=class{constructor(){ue(this,"name","fastapi")}detect(n){return n.some(r=>{const s=oe(r.path);return(s==="requirements.txt"||s==="pyproject.toml"||s==="Pipfile")&&/\bfastapi\b/i.test(r.content)})?!0:n.some(r=>r.path.endsWith(".py")&&!Gt.test(r.path)&&/(?:from\s+fastapi\b|import\s+fastapi\b)/.test(r.content))}scan(n,t){var V;const r=performance.now(),s=n.map(T=>({path:oe(T.path),content:T.content})).filter(T=>T.path.endsWith(".py")&&!Gt.test(T.path)),u=new Set(s.map(T=>T.path)),f=new Map,E=new Map;for(const T of s){const v=/^[ \t]*([A-Za-z_][A-Za-z0-9_]*)(?:\s*:\s*str)?\s*=\s*['"]([^'"]*)['"]/gm;let p;for(;(p=v.exec(T.content))!==null;)p[2].startsWith("/")&&E.set(p[1],p[2]);const c=/^class\s+([A-Za-z_][A-Za-z0-9_]*)\s*\([^)]*(?:BaseModel|SQLModel|Schema)[^)]*\)\s*:/gm;let y;for(;(y=c.exec(T.content))!==null;){const m=y[1],e=T.content.slice(y.index+y[0].length),l=[];for(const d of e.split(`
|
|
9
|
-
`)){if(d.trim()===""||d.trim().startsWith("#"))continue;if(!/^\s+/.test(d))break;const i=d.match(/^\s+([a-z_][a-zA-Z0-9_]*)\s*:/);i&&i[1]!=="model_config"&&l.push(i[1])}l.length>0&&f.set(m,l)}}const x=new Map;for(const T of s){const v=new Map,p=new Map,c=[],y=[],m=T.content,e=/^\s*from\s+(\.{0,3}[A-Za-z0-9_.]*)\s+import\s+([^\n#]+)/gm;let l;for(;(l=e.exec(m))!==null;){const S=l[1],R=l[2].replace(/[()]/g,"").split(",");for(const O of R){const z=O.trim();if(!z)continue;const G=z.match(/^([A-Za-z0-9_*]+)\s+as\s+([A-Za-z0-9_]+)$/);G?v.set(G[2],{modulePath:S,importedName:G[1]}):/^[A-Za-z0-9_]+$/.test(z)&&v.set(z,{modulePath:S,importedName:z})}}const d=S=>{const R=S.match(/^['"]([^'"]*)['"]$/);if(R)return R[1].replace(/\{([^:}]+)(?::[^}]+)?\}/g,":$1");const O=S.match(/^f['"]([^'"]*)['"]$/);if(O)return O[1].replace(/\{([A-Za-z_][A-Za-z0-9_.]*)\}/g,(H,_)=>{const C=E.get(_.split(".").pop());return C!==void 0?C:H}).replace(/\{([^:}]+)(?::[^}]+)?\}/g,":$1");const z=S.split(".").pop();return(E.get(z)??"").replace(/\{([^:}]+)(?::[^}]+)?\}/g,":$1")},i=/^[ \t]*([A-Za-z_][A-Za-z0-9_]*)\s*(?::[^=\n]+)?=\s*(FastAPI|APIRouter[A-Za-z0-9_]*)\s*\(/gm;let o;for(;(o=i.exec(m))!==null;){const S=o[1],R=o[2],{content:O}=ot(m,o.index+o[0].length-1),z=O.match(/prefix\s*=\s*(f?['"][^'"]*['"]|[A-Za-z_][A-Za-z0-9_.]*)/);p.set(S,{varName:S,prefix:z?d(z[1]):"",dependencies:rt(O),isApp:R==="FastAPI"})}const a=/\b([A-Za-z_][A-Za-z0-9_]*)\.include_router\s*\(/g;let h;for(;(h=a.exec(m))!==null;){const S=h[1],{content:R}=ot(m,h.index+h[0].length-1),O=((V=R.split(",")[0])==null?void 0:V.trim().split(/\s+/)[0])??"",z=R.match(/prefix\s*=\s*(f?['"][^'"]*['"]|[A-Za-z_][A-Za-z0-9_.]*)/),G=z?d(z[1]):"";O&&c.push({parentVar:S,targetExpr:O,prefix:G,dependencies:rt(R),line:Wt(m,h.index)})}const g=/@([A-Za-z_][A-Za-z0-9_]*)\.(get|post|put|patch|delete|options|head|api_route)\s*\(/g;let N;for(;(N=g.exec(m))!==null;){const S=N[1],R=N[2].toLowerCase(),{content:O,endIdx:z}=ot(m,N.index+N[0].length-1),G=O.match(/^\s*['"]([^'"]*)['"]/);if(!G)continue;const W=G[1].replace(/\{([^:}]+)(?::[^}]+)?\}/g,":$1"),H=[];if(R==="api_route"){const U=O.match(/methods\s*=\s*\[([^\]]+)\]/);if(U)for(const J of U[1].split(",")){const K=J.replace(/['"\s]/g,"").toUpperCase();K&&H.push(K)}H.length===0&&H.push("GET")}else vs.has(R)&&H.push(R.toUpperCase());const C=m.slice(z+1).match(/(?:async\s+)?def\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/),F=C?C[1]:"handler",k=rt(O),I=[],Z=[];if(C&&C.index!==void 0){const U=z+1+C.index+C[0].length-1,J=ot(m,U).content;for(const Q of rt(J))k.includes(Q)||k.push(Q);const K=new Set(fe(W));for(const Q of J.split(",")){const te=Q.trim();if(!te||te.startsWith("*"))continue;const re=te.match(/^([A-Za-z_][A-Za-z0-9_]*)(?:\s*:\s*([^=]+))?(?:\s*=\s*(.+))?$/);if(!re)continue;const ae=re[1],Y=(re[2]??"").trim(),se=(re[3]??"").trim();if(!(ae==="self"||ae==="cls"||se.includes("Depends("))&&!/^(?:Request|Response|BackgroundTasks|WebSocket|Session|AsyncSession)$/.test(Y))if(se.includes("Body("))Z.push(ae);else if(f.has(Y))for(const ee of f.get(Y))Z.includes(ee)||Z.push(ee);else!K.has(ae)&&(se.includes("Query(")||/^(?:str|int|float|bool|Optional\[)/.test(Y))&&I.push(ae)}}y.push({targetVar:S,methods:H,path:W,handlerName:F,line:Wt(m,N.index),middlewares:k,queryParams:I,bodyFields:Z})}for(const S of y)p.has(S.targetVar)||p.set(S.targetVar,{varName:S.targetVar,prefix:"",dependencies:[],isApp:!1});x.set(T.path,{path:T.path,imports:v,routers:p,includes:c,routes:y})}const b=new Map,$=new Map,A=[],j=T=>{b.has(T.id)||b.set(T.id,T)},w=T=>{$.has(T.id)||$.set(T.id,T)},M=(T,v)=>{if(T.routers.has(v))return{file:T,varName:v};const p=v.split("."),c=T.imports.get(p[0]);if(c){let y=null;if(p.length>1&&c.importedName!=="*"){const e=c.modulePath?`${c.modulePath}.${c.importedName}`:c.importedName;y=bt(T.path,{modulePath:e},u)}if(y||(y=bt(T.path,c,u)),!y&&c.importedName!=="*"){const e=c.modulePath?`${c.modulePath}.${c.importedName}`:c.importedName;y=bt(T.path,{modulePath:e},u)}const m=y?x.get(y):void 0;if(m){const e=p.length>1?p[1]:c.importedName;if(m.routers.has(e))return{file:m,varName:e};if(m.routers.size===1){const l=Array.from(m.routers.keys())[0];return{file:m,varName:l}}}}return null},D=new Set,P=new Set,q=(T,v,p,c,y,m=!1)=>{const e=`${T.path}:${v}:${c}`;if(D.has(e))return;D.add(e),P.add(`${T.path}:${v}`);const l=T.routers.get(v),d=l!=null&&l.prefix?ne(c,l.prefix):c,i=Array.from(new Set([...y,...(l==null?void 0:l.dependencies)??[]]));for(const o of T.routes){if(o.targetVar!==v)continue;const a=ne(d,o.path),h=fe(a),g=Array.from(new Set([...i,...o.middlewares])),N=me(a);for(const S of o.methods){const R=`route:${S}:${a}`;j({id:R,type:"route",label:`${S} ${a}`,file:T.path,line:o.line,method:S,fullPath:a,pathParams:h,queryParams:o.queryParams,bodyFields:o.bodyFields,group:N,middlewares:g,controller:o.handlerName,controllerFile:T.path,controllerLine:o.line,...m?{partial:!0}:{}}),w({id:`edge:${p}->${R}`,source:p,target:R,type:"handles"});for(const z of g){const G=`mw:${z}`;j({id:G,type:"middleware",label:z,file:T.path,line:o.line}),w({id:`edge:${R}->${G}`,source:R,target:G,type:"uses"})}const O=`ctrl:${T.path}:${o.handlerName}:${o.line}`;j({id:O,type:"controller",label:o.handlerName,file:T.path,line:o.line}),w({id:`edge:${R}->${O}`,source:R,target:O,type:"calls"})}}for(const o of T.includes){if(o.parentVar!==v)continue;const a=M(T,o.targetExpr);if(!a){A.push(`${T.path}:${o.line} -> ${o.targetExpr}`);continue}const h=o.prefix?ne(d,o.prefix):d,g=`router:${a.file.path}:${h||"/"}`;j({id:g,type:"router",label:h||a.varName,file:a.file.path,line:1}),w({id:`edge:${p}->${g}`,source:p,target:g,type:"mounts"}),q(a.file,a.varName,g,h,Array.from(new Set([...i,...o.dependencies])))}},B=[];for(const T of x.values())for(const v of T.routers.values())v.isApp&&B.push({pf:T,varName:v.varName});if(B.length>0)for(const{pf:T,varName:v}of B){const p=`entry:${T.path}`;j({id:p,type:"entry",label:T.path,file:T.path,line:1}),q(T,v,p,"",[])}for(const T of x.values())for(const v of T.routers.values())if(!v.isApp&&!P.has(`${T.path}:${v.varName}`)){const p=`router:${T.path}:${v.prefix||"/"}`;j({id:p,type:"router",label:v.prefix||T.path,file:T.path,line:1}),q(T,v.varName,p,"",[],B.length>0)}return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"fastapi-app",framework:"fastapi",scannedFiles:s.length,scanDurationMs:Math.round((performance.now()-r)*100)/100,unresolvedMounts:A},nodes:Array.from(b.values()),edges:Array.from($.values())}}},Ht=/(?:^|\/)(?:tests?|__tests__)\/|test_[^/]+\.py$|_test\.py$/i,$s=new Set(["get","post","put","patch","delete","options","head"]);function Bt(n,t,r){let s=n.includes("/")?n.slice(0,n.lastIndexOf("/")):"",u=t.modulePath;if(u.startsWith(".")){let x=0;for(;u[x]===".";)x++;for(let b=1;b<x;b++)s=s.includes("/")?s.slice(0,s.lastIndexOf("/")):"";u=u.slice(x)}else s="";const f=u?u.replace(/\./g,"/"):"",E=[];if(s&&f)E.push(le(s,`${f}.py`),le(s,`${f}/__init__.py`));else if(f){E.push(`${f}.py`,`${f}/__init__.py`);for(const x of r)(x.endsWith(`/${f}.py`)||x.endsWith(`/${f}/__init__.py`))&&E.push(x)}else s&&E.push(le(s,"__init__.py"));for(const x of E){const b=oe(x);if(r.has(b))return b}return null}function Ut(n,t){let r=1;for(let s=0;s<t&&s<n.length;s++)n[s]===`
|
|
10
|
-
`&&r++;return r}var js=class{constructor(){ue(this,"name","flask")}detect(n){return n.some(r=>{const s=oe(r.path);return(s==="requirements.txt"||s==="pyproject.toml"||s==="Pipfile")&&/\bflask\b/i.test(r.content)})?!0:n.some(r=>r.path.endsWith(".py")&&!Ht.test(r.path)&&/(?:from\s+flask\b|import\s+flask\b)/.test(r.content))}scan(n,t){var D;const r=performance.now(),s=n.map(P=>({path:oe(P.path),content:P.content})).filter(P=>P.path.endsWith(".py")&&!Ht.test(P.path)),u=new Set(s.map(P=>P.path)),f=new Map;for(const P of s){const q=new Map,B=new Map,V=[],T=[],v=P.content,p=/^\s*from\s+(\.{0,3}[A-Za-z0-9_.]*)\s+import\s+([^\n#]+)/gm;let c;for(;(c=p.exec(v))!==null;){const o=c[1];for(const a of c[2].replace(/[()]/g,"").split(",")){const h=a.trim();if(!h)continue;const g=h.match(/^([A-Za-z0-9_*]+)\s+as\s+([A-Za-z0-9_]+)$/);g?q.set(g[2],{modulePath:o,importedName:g[1]}):/^[A-Za-z0-9_]+$/.test(h)&&q.set(h,{modulePath:o,importedName:h})}}const y=/^[ \t]*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(Flask|Blueprint)\s*\(([^)]*)\)/gm;let m;for(;(m=y.exec(v))!==null;){const o=m[3].match(/url_prefix\s*=\s*['"]([^'"]*)['"]/);B.set(m[1],{varName:m[1],urlPrefix:o?o[1]:"",isApp:m[2]==="Flask"})}const e=/\b([A-Za-z_][A-Za-z0-9_]*)\.register_blueprint\s*\(([^)]*)\)/g;let l;for(;(l=e.exec(v))!==null;){const o=((D=l[2].split(",")[0])==null?void 0:D.trim())??"",a=l[2].match(/url_prefix\s*=\s*['"]([^'"]*)['"]/);o&&V.push({parentVar:l[1],bpExpr:o,urlPrefix:a?a[1]:"",line:Ut(v,l.index)})}const d=/@([A-Za-z_][A-Za-z0-9_]*)\.(route|get|post|put|patch|delete|options|head)\s*\(([^)]*)\)/g;let i;for(;(i=d.exec(v))!==null;){const o=i[1],a=i[2].toLowerCase(),h=i[3],g=h.match(/^\s*['"]([^'"]*)['"]/);if(!g)continue;const N=g[1].replace(/<(?:[^:>]+:)?([^>]+)>/g,":$1"),S=[];if(a==="route"){const z=h.match(/methods\s*=\s*\[([^\]]+)\]/);if(z)for(const G of z[1].split(",")){const W=G.replace(/['"\s]/g,"").toUpperCase();W&&S.push(W)}S.length===0&&S.push("GET")}else $s.has(a)&&S.push(a.toUpperCase());const O=v.slice(i.index+i[0].length).match(/(?:async\s+)?def\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/);T.push({targetVar:o,methods:S,path:N,handlerName:O?O[1]:"handler",line:Ut(v,i.index)})}f.set(P.path,{path:P.path,imports:q,routers:B,registers:V,routes:T})}const E=new Map,x=new Map,b=P=>{E.has(P.id)||E.set(P.id,P)},$=P=>{x.has(P.id)||x.set(P.id,P)},A=new Set,j=new Set,w=(P,q,B,V)=>{const T=`${P.path}:${q}:${V}`;if(A.has(T))return;A.add(T),j.add(`${P.path}:${q}`);const v=P.routers.get(q),p=v!=null&&v.urlPrefix?ne(V,v.urlPrefix):V;for(const c of P.routes){if(c.targetVar!==q)continue;const y=ne(p,c.path),m=fe(y),e=me(y);for(const l of c.methods){const d=`route:${l}:${y}`;b({id:d,type:"route",label:`${l} ${y}`,file:P.path,line:c.line,method:l,fullPath:y,pathParams:m,queryParams:[],bodyFields:[],group:e,middlewares:[],controller:c.handlerName,controllerFile:P.path,controllerLine:c.line}),$({id:`edge:${B}->${d}`,source:B,target:d,type:"handles"});const i=`ctrl:${P.path}:${c.handlerName}:${c.line}`;b({id:i,type:"controller",label:c.handlerName,file:P.path,line:c.line}),$({id:`edge:${d}->${i}`,source:d,target:i,type:"calls"})}}for(const c of P.registers){if(c.parentVar!==q)continue;let y,m=c.bpExpr;if(P.routers.has(c.bpExpr))y=P;else{const d=P.imports.get(c.bpExpr);if(d){let i=Bt(P.path,d,u);if(!i&&d.importedName!=="*"){const o=d.modulePath?`${d.modulePath}.${d.importedName}`:d.importedName;i=Bt(P.path,{modulePath:o},u)}i&&(y=f.get(i),m=d.importedName)}}if(!y||!y.routers.has(m))continue;const e=c.urlPrefix?ne(p,c.urlPrefix):p,l=`router:${y.path}:${e||"/"}`;b({id:l,type:"router",label:e||m,file:y.path,line:1}),$({id:`edge:${B}->${l}`,source:B,target:l,type:"mounts"}),w(y,m,l,e)}},M=[];for(const P of f.values())for(const q of P.routers.values())q.isApp&&M.push({pf:P,varName:q.varName});if(M.length>0)for(const{pf:P,varName:q}of M){const B=`entry:${P.path}`;b({id:B,type:"entry",label:P.path,file:P.path,line:1}),w(P,q,B,"")}for(const P of f.values())for(const q of P.routers.values())if(!q.isApp&&!j.has(`${P.path}:${q.varName}`)){const B=`router:${P.path}:${q.urlPrefix||"/"}`;b({id:B,type:"router",label:q.urlPrefix||P.path,file:P.path,line:1}),w(P,q.varName,B,"")}return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"flask-app",framework:"flask",scannedFiles:s.length,scanDurationMs:Math.round((performance.now()-r)*100)/100,unresolvedMounts:[]},nodes:Array.from(E.values()),edges:Array.from(x.values())}}},Vt=/(?:^|\/)(?:tests?|__tests__)\/|test_[^/]+\.py$|_test\.py$/i,pn=new Set(["get","post","put","patch","delete","options","head"]);function qe(n,t){let r=1;for(let s=0;s<t&&s<n.length;s++)n[s]===`
|
|
11
|
-
`&&r++;return r}function Ss(n){return n.replace(/#[^\n]*/g,t=>" ".repeat(t.length))}function jt(n,t,r,s){if(n[t]!==r)return null;let u=0,f=null;for(let E=t;E<n.length;E++){const x=n[E];if(f){if(x==="\\"){E++;continue}x===f&&(f=null);continue}if(x==='"'||x==="'"){f=x;continue}if(x===r)u++;else if(x===s&&(u--,u===0))return{text:n.slice(t+1,E),endIdx:E}}return null}function Qe(n){const t=[];let r=0,s=0,u=0,f=null,E=0;for(let b=0;b<n.length;b++){const $=n[b];if(f){if($==="\\"){b++;continue}$===f&&(f=null);continue}if($==='"'||$==="'"){f=$;continue}if($==="(")r++;else if($===")")r--;else if($==="[")s++;else if($==="]")s--;else if($==="{")u++;else if($==="}")u--;else if($===","&&r===0&&s===0&&u===0){const A=n.slice(E,b).trim();A&&t.push(A),E=b+1}}const x=n.slice(E).trim();return x&&t.push(x),t}function $e(n){const t=n.trim().match(/^[rfbuRFBU]{0,2}(['"])([\s\S]*)\1$/);return t?t[2]:null}function As(n,t){let r=n.trim();return t?(r=r.replace(/^\^/,"").replace(/\$$/,""),r=r.replace(/\/\?$/,""),r=r.replace(/\(\?P<([A-Za-z_][A-Za-z0-9_]*)>[^)]*\)/g,":$1"),r=r.replace(/\\([./\-_])/g,"$1")):r=r.replace(/<(?:[A-Za-z_][A-Za-z0-9_]*:)?([A-Za-z_][A-Za-z0-9_]*)>/g,":$1"),r?r.startsWith("/")?r:`/${r}`:"/"}function Be(n,t,r){let s=n.includes("/")?n.slice(0,n.lastIndexOf("/")):"",u=t.modulePath;if(u.startsWith(".")){let b=0;for(;u[b]===".";)b++;for(let $=1;$<b;$++)s=s.includes("/")?s.slice(0,s.lastIndexOf("/")):"";u=u.slice(b)}else s="";const f=u?u.replace(/\./g,"/"):"",E=t.importedName&&t.importedName!=="*"?t.importedName:"",x=[];if(s&&f)E&&x.push(le(s,`${f}/${E}.py`),le(s,`${f}/${E}/__init__.py`)),x.push(le(s,`${f}.py`),le(s,`${f}/__init__.py`));else if(f){if(E){x.push(`${f}/${E}.py`,`${f}/${E}/__init__.py`);for(const b of r)(b.endsWith(`/${f}/${E}.py`)||b.endsWith(`/${f}/${E}/__init__.py`))&&x.push(b)}x.push(`${f}.py`,`${f}/__init__.py`);for(const b of r)(b.endsWith(`/${f}.py`)||b.endsWith(`/${f}/__init__.py`))&&x.push(b)}else s&&(E&&x.push(le(s,`${E}.py`),le(s,`${E}/__init__.py`)),x.push(le(s,"__init__.py")));for(const b of x){const $=oe(b);if(r.has($))return $}return null}function it(n,t){const r=n.replace(/\./g,"/"),s=[`${r}.py`,`${r}/__init__.py`];for(const u of s){const f=oe(u);if(t.has(f))return f}for(const u of t)if(u.endsWith(`/${r}.py`)||u.endsWith(`/${r}/__init__.py`))return u;return null}function Ps(n){const t=new Map,r=/^[ \t]*from\s+([.\w]+)\s+import\s+\(([^)]+)\)|^[ \t]*from\s+([.\w]+)\s+import\s+([^\n#]+)/gm;let s;for(;(s=r.exec(n))!==null;){const f=s[1]||s[3],E=(s[2]||s[4]||"").split(",");for(const x of E){const b=x.trim();if(!b||b==="*")continue;const $=b.match(/^([A-Za-z_][A-Za-z0-9_]*)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/);if($)t.set($[2],{modulePath:f,importedName:$[1]});else{const A=b.split(/\s+/)[0];/^[A-Za-z_][A-Za-z0-9_]*$/.test(A)&&t.set(A,{modulePath:f,importedName:A})}}}const u=/^[ \t]*import\s+([^\n#]+)/gm;for(;(s=u.exec(n))!==null;)for(const f of s[1].split(",")){const E=f.trim(),x=E.match(/^([.\w]+)\s+as\s+([A-Za-z_][A-Za-z0-9_]*)$/);if(x)t.set(x[2],{modulePath:x[1],importedName:"*"});else if(/^[.\w]+$/.test(E)){const b=E.split(".")[0];t.set(b,{modulePath:E,importedName:"*"})}}return t}function St(n,t,r){const s=[],u=/\b(path|re_path|url)\s*\(/g;let f;for(;(f=u.exec(n))!==null;){const b=f[1],$=b==="re_path"||b==="url",A=f.index+f[0].length-1,j=jt(n,A,"(",")");if(!j)continue;const w=Qe(j.text);if(w.length<2){u.lastIndex=j.endIdx+1;continue}let M=$e(w[0]);if(M===null&&w[0].includes("route=")){const T=w[0].match(/route\s*=\s*([rfbuRFBU]{0,2}['"][^'"]*['"])/);T&&(M=$e(T[1]))}if(M===null){u.lastIndex=j.endIdx+1;continue}const D=As(M,$);let P=w[1].replace(/^view\s*=\s*/,"").trim(),q;for(const T of w.slice(2)){const v=T.match(/^name\s*=\s*(['"])([^'"]+)\1$/);v&&(q=v[2])}const B=qe(r,t+f.index),V=P.match(/^include\s*\(([\s\S]*)\)$/);if(V){const T=V[1].trim(),p=Qe(T)[0]??"";if(p.startsWith("[")){const c=p.slice(1,-1);s.push({kind:"inline",pattern:D,targetExpr:P,name:q,line:B,inlineEntries:St(c,t+f.index,r)})}else if($e(p)===null&&/\.urls\b/.test(p))s.push({kind:"router_urls",pattern:D,targetExpr:p,name:q,line:B});else{const c=p.match(/^\(\s*([^,]+)\s*,/),y=c?c[1].trim():p;$e(y)===null&&/\.urls\b/.test(y)?s.push({kind:"router_urls",pattern:D,targetExpr:y,name:q,line:B}):s.push({kind:"include",pattern:D,targetExpr:y,name:q,line:B})}}else s.push({kind:"view",pattern:D,targetExpr:P,name:q,line:B});u.lastIndex=j.endIdx+1}const E=/([A-Za-z_][A-Za-z0-9_]*)\.urls\b/g;let x;for(;(x=E.exec(n))!==null;){const b=n.slice(Math.max(0,x.index-20),x.index);/include\s*\(\s*$/.test(b)||s.push({kind:"router_urls",pattern:"/",targetExpr:`${x[1]}.urls`,line:qe(r,t+x.index)})}return s}function at(n){const t=[],r=/['"]([A-Za-z]+)['"]/g;let s;for(;(s=r.exec(n))!==null;){const u=s[1].toLowerCase();pn.has(u)&&t.push(u.toUpperCase())}return t}function _s(n){const t=n.split(".").pop()??n;return t==="ListCreateAPIView"?["GET","POST"]:t==="RetrieveUpdateDestroyAPIView"?["GET","PUT","PATCH","DELETE"]:t==="RetrieveUpdateAPIView"?["GET","PUT","PATCH"]:t==="RetrieveDestroyAPIView"?["GET","DELETE"]:t==="ListAPIView"||t==="RetrieveAPIView"||t==="TemplateView"||t==="ListView"||t==="DetailView"||t==="RedirectView"?["GET"]:t==="CreateAPIView"?["POST"]:t==="UpdateAPIView"?["PUT","PATCH"]:t==="DestroyAPIView"?["DELETE"]:[]}function Ns(n){const t=Ss(n.content),r=Ps(t),s=[],u=/\burlpatterns\s*(?:\+?=)\s*/g;let f;for(;(f=u.exec(t))!==null;){const l=f.index+f[0].length;if(t[l]==="["){const d=jt(t,l,"[","]");d&&s.push(...St(d.text,l+1,t))}else{const d=t.indexOf(`
|
|
12
|
-
`,l),o=t.slice(l,d===-1?t.length:d).match(/^([A-Za-z_][A-Za-z0-9_]*)\.urls\b/);o&&s.push({kind:"router_urls",pattern:"/",targetExpr:`${o[1]}.urls`,line:qe(t,f.index)})}}s.length===0&&(/(?:^|\/)urls\.py$/.test(n.path)||/\b(?:path|re_path)\s*\(/.test(t))&&/\b(?:from\s+django|include|path|re_path)\b/.test(t)&&s.push(...St(t,0,t));const E=new Set,x=/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(?:[\w.]+\.)?(?:DefaultRouter|SimpleRouter)\s*\(/gm;let b;for(;(b=x.exec(t))!==null;)E.add(b[1]);const $=[],A=/\b([A-Za-z_][A-Za-z0-9_]*)\.register\s*\(/g;let j;for(;(j=A.exec(t))!==null;){const l=j.index+j[0].length-1,d=jt(t,l,"(",")");if(!d)continue;const i=Qe(d.text);if(i.length<2)continue;const o=$e(i[0].replace(/^prefix\s*=\s*/,""));if(o===null)continue;const a=i[1].replace(/^viewset\s*=\s*/,"").trim();let h;for(const g of i.slice(2)){const N=g.match(/^basename\s*=\s*(['"])([^'"]+)\1$/);N&&(h=N[2])}$.push({routerVar:j[1],prefix:o.startsWith("/")?o:`/${o}`,viewSetExpr:a,basename:h,line:qe(t,j.index)})}const w=new Map,M=t.split(`
|
|
13
|
-
`),D=/^class\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:\(([^)]*)\))?\s*:/;let P=null,q=[];for(let l=0;l<M.length;l++){const d=M[l],i=d.trim();if(!i)continue;const o=d.length-d.trimStart().length;if(o===0){if(i.startsWith("@")){q.push(i);continue}const a=i.match(D);if(a){const h=a[2]?a[2].split(",").map(g=>g.trim()).filter(Boolean):[];P={name:a[1],bases:h,httpMethods:[],actions:[],viewSetActions:new Set,permissionClasses:[],line:l+1},w.set(a[1],P),q=[];continue}!i.startsWith("def ")&&!i.startsWith("async def ")&&(P=null,q=[])}if(o===0){const a=i.match(/^(?:async\s+)?def\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/);if(a){P=null;const h=[],g=q.slice();q=[];for(const N of g)if(N.startsWith("@api_view")){const S=at(N);h.push(...S.length>0?S:["GET"])}if(h.length===0){let N=l+1;for(;N<M.length;){const G=M[N];if(G.trim()&&G.length-G.trimStart().length===0)break;N++}const S=M.slice(l+1,N).join(`
|
|
14
|
-
`),R=new Set,O=/request\.method\s*(?:==|in)\s*(?:\[([^\]]+)\]|['"]([A-Za-z]+)['"])/g;let z;for(;(z=O.exec(S))!==null;){const G=at(z[1]||`'${z[2]}'`);for(const W of G)R.add(W)}R.size>0?h.push(...R):h.push("GET")}At.set(a[1],{name:a[1],methods:Array.from(new Set(h)),decorators:g.map(N=>N.replace(/^@/,"").split("(")[0]),line:l+1});continue}}if(P&&o>0){if(i.startsWith("@")){q.push(i);continue}const a=i.match(/^(?:async\s+)?def\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/);if(a){const h=a[1],g=q.slice();q=[],pn.has(h)&&P.httpMethods.push(h.toUpperCase()),["list","create","retrieve","update","partial_update","destroy"].includes(h)&&P.viewSetActions.add(h);for(const N of g)if(N.startsWith("@action")){const S=N.match(/detail\s*=\s*(True|False)/),R=S?S[1]==="True":!1,O=N.match(/methods\s*=\s*\[([^\]]+)\]/),z=O?at(O[1]):["GET"],G=N.match(/url_path\s*=\s*['"]([^'"]+)['"]/),W=G?G[1]:h;P.actions.push({name:h,detail:R,methods:z.length>0?z:["GET"],urlPath:W,line:l+1})}}else{q=[];const h=i.match(/^serializer_class\s*=\s*([A-Za-z_][A-Za-z0-9_]*)/);h&&(P.serializerClass=h[1]);const g=i.match(/^permission_classes\s*=\s*\[([^\]]+)\]/);g&&(P.permissionClasses=g[1].split(",").map(N=>N.trim()).filter(Boolean))}}}const B=new Set,V=new Set,T=/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*NinjaAPI\s*\(/gm;let v;for(;(v=T.exec(t))!==null;)B.add(v[1]);const p=/^([A-Za-z_][A-Za-z0-9_]*)\s*=\s*Router\s*\(/gm;for(;(v=p.exec(t))!==null;)V.add(v[1]);const c=[],y=/@([A-Za-z_][A-Za-z0-9_]*)\.(get|post|put|patch|delete|api_operation)\s*\(([^)]*)\)[\s\S]*?(?:async\s+)?def\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/g;for(;(v=y.exec(t))!==null;){const l=v[1];if(!B.has(l)&&!V.has(l))continue;const d=Qe(v[3]),i=d[0]?$e(d[0])??"/":"/",o=v[2]==="api_operation"?at(d[0]||""):[v[2].toUpperCase()];c.push({targetVar:l,methods:o.length>0?o:["GET"],path:i.startsWith("/")?i:`/${i}`,handlerName:v[4],line:qe(t,v.index)})}const m=[],e=/\b([A-Za-z_][A-Za-z0-9_]*)\.add_router\s*\(([^)]+)\)/g;for(;(v=e.exec(t))!==null;){const l=Qe(v[2]);if(l.length<2)continue;const d=$e(l[0])??"/";m.push({parentVar:v[1],prefix:d.startsWith("/")?d:`/${d}`,childExpr:l[1].trim(),line:qe(t,v.index)})}return{path:n.path,imports:r,urlEntries:s,routerVars:E,routerRegs:$,classes:w,funcs:At,ninjaApis:B,ninjaRouters:V,ninjaRoutes:c,ninjaMounts:m}}var At;function ks(n){return At=new Map,Ns(n)}var Ms=class{constructor(){ue(this,"name","django")}detect(n){return n.some(s=>oe(s.path).endsWith("manage.py")&&/django|DJANGO_SETTINGS_MODULE/.test(s.content))||n.some(s=>{const u=oe(s.path);return(u==="requirements.txt"||u==="pyproject.toml"||u==="Pipfile")&&/\b(?:django|djangorestframework|django-ninja)\b/i.test(s.content)})?!0:n.some(s=>s.path.endsWith(".py")&&!Vt.test(s.path)&&/(?:from\s+django\.|import\s+django\b|from\s+rest_framework\b|from\s+ninja\b)/.test(s.content))}scan(n,t){const r=performance.now(),s=n.map(e=>({path:oe(e.path),content:e.content})).filter(e=>e.path.endsWith(".py")&&!Vt.test(e.path)),u=new Set(s.map(e=>e.path)),f=new Map;for(const e of s)f.set(e.path,ks(e));const E=[],x=[],b=new Set,$=new Set,A=[],j=e=>{b.has(e.id)||(b.add(e.id),E.push(e))},w=e=>{$.has(e.id)||($.add(e.id),x.push(e))};let M=null;for(const e of s){const l=e.content.match(/ROOT_URLCONF\s*=\s*['"]([.\w]+)['"]/);if(l&&(M=it(l[1],u),M))break}const D=new Set;for(const e of f.values())for(const l of e.urlEntries)if(l.kind==="include"){const d=$e(l.targetExpr),i=d?it(d,u):(()=>{const o=e.imports.get(l.targetExpr.split(".")[0]);return o?Be(e.path,o,u):null})();i&&D.add(i)}const P=[];if(M)P.push(M);else{for(const e of f.values())(e.urlEntries.length>0||e.ninjaApis.size>0)&&!D.has(e.path)&&P.push(e.path);if(P.length===0){const e=s.find(l=>/(?:^|\/)urls\.py$/.test(l.path));e&&P.push(e.path)}}const q=new Set,B=new Set,V=(e,l)=>{let d=l.trim(),i=!1;const o=d.match(/^([.\w]+)\.as_view\s*\(/);o&&(d=o[1],i=!0);const a=d.split("."),h=f.get(e);if(!h)return{file:e,symbol:d,isAsView:i};if(a.length===1){const N=h.imports.get(a[0]);if(N){const S=Be(e,N,u);if(S)return{file:S,symbol:N.importedName==="*"?a[0]:N.importedName,isAsView:i}}return{file:e,symbol:a[0],isAsView:i}}const g=h.imports.get(a[0]);if(g){const N=Be(e,g,u);if(N)return{file:N,symbol:a[a.length-1],isAsView:i};if(g.importedName==="*"){const S=`${g.modulePath}.${a.slice(1,-1).join(".")}`.replace(/\.$/,""),R=it(S,u);if(R)return{file:R,symbol:a[a.length-1],isAsView:i}}}return{file:e,symbol:a[a.length-1],isAsView:i}},T=(e,l,d,i,o,a,h)=>{var S,R;const g=d||"/",N=`route:${l}:${g}`;j({id:N,type:"route",label:`${l} ${g}`,file:i,line:o,method:l,fullPath:g,pathParams:fe(g),group:me(g),middlewares:(S=h==null?void 0:h.middlewares)!=null&&S.length?h.middlewares:void 0,bodyFields:(R=h==null?void 0:h.bodyFields)!=null&&R.length?h.bodyFields:void 0,controller:(h==null?void 0:h.controller)??a,controllerFile:(h==null?void 0:h.controllerFile)??i,controllerLine:(h==null?void 0:h.controllerLine)??o}),w({id:`edge:${e}->${N}`,source:e,target:N,type:"handles"})},v=(e,l,d,i)=>{var _;const o=C=>C.endsWith("/")?C:`${C}/`,a=o(ne(l,d.prefix)),h=o(ne(a,":id")),g=V(i,d.viewSetExpr),N=f.get(g.file),S=N==null?void 0:N.classes.get(g.symbol),R=(_=S==null?void 0:S.permissionClasses)!=null&&_.length?S.permissionClasses:void 0,O=S!=null&&S.serializerClass?[S.serializerClass]:void 0,z=S?g.file:i,G=S?S.line:d.line,W=(S==null?void 0:S.bases.some(C=>/ReadOnlyModelViewSet/.test(C)))??!1,H=(S==null?void 0:S.bases.some(C=>/ModelViewSet/.test(C)))??!1;if(S&&S.viewSetActions.size>0&&!H?(S.viewSetActions.has("list")&&T(e,"GET",a,z,G,`${g.symbol}.list`,{middlewares:R,bodyFields:O}),S.viewSetActions.has("create")&&T(e,"POST",a,z,G,`${g.symbol}.create`,{middlewares:R,bodyFields:O}),S.viewSetActions.has("retrieve")&&T(e,"GET",h,z,G,`${g.symbol}.retrieve`,{middlewares:R,bodyFields:O}),S.viewSetActions.has("update")&&T(e,"PUT",h,z,G,`${g.symbol}.update`,{middlewares:R,bodyFields:O}),S.viewSetActions.has("partial_update")&&T(e,"PATCH",h,z,G,`${g.symbol}.partial_update`,{middlewares:R,bodyFields:O}),S.viewSetActions.has("destroy")&&T(e,"DELETE",h,z,G,`${g.symbol}.destroy`,{middlewares:R,bodyFields:O})):W?(T(e,"GET",a,z,G,`${g.symbol}.list`,{middlewares:R,bodyFields:O}),T(e,"GET",h,z,G,`${g.symbol}.retrieve`,{middlewares:R,bodyFields:O})):(T(e,"GET",a,z,G,`${g.symbol}.list`,{middlewares:R,bodyFields:O}),T(e,"POST",a,z,G,`${g.symbol}.create`,{middlewares:R,bodyFields:O}),T(e,"GET",h,z,G,`${g.symbol}.retrieve`,{middlewares:R,bodyFields:O}),T(e,"PUT",h,z,G,`${g.symbol}.update`,{middlewares:R,bodyFields:O}),T(e,"PATCH",h,z,G,`${g.symbol}.partial_update`,{middlewares:R,bodyFields:O}),T(e,"DELETE",h,z,G,`${g.symbol}.destroy`,{middlewares:R,bodyFields:O})),S)for(const C of S.actions){const F=C.detail?h:a,k=o(ne(F,C.urlPath));for(const I of C.methods)T(e,I,k,z,C.line,`${g.symbol}.${C.name}`,{middlewares:R,bodyFields:O})}},p=(e,l,d,i)=>{const o=i.replace(/\.urls$/,"").trim(),a=f.get(d);if(!a)return;let h=d,g=a.routerRegs.filter(N=>N.routerVar===o);if(g.length===0){const N=o.split("."),S=a.imports.get(N[0]);if(S){const R=Be(d,S,u);if(R&&f.has(R)){h=R;const O=f.get(R),z=S.importedName==="*"?N[N.length-1]:S.importedName;g=O.routerRegs.filter(G=>G.routerVar===z)}}}B.add(`${h}:${o}`);for(const N of g)v(e,l,N,h)},c=(e,l,d,i)=>{for(const o of i){const a=ne(l,o.pattern);if(o.kind==="inline"&&o.inlineEntries){const h=`router:${d}:${a}:${o.line}`;j({id:h,type:"router",label:o.pattern,file:d,line:o.line}),w({id:`edge:${e}->${h}`,source:e,target:h,type:"mounts",label:o.pattern}),c(h,a,d,o.inlineEntries)}else if(o.kind==="include"){const h=$e(o.targetExpr);let g=null;if(h)g=it(h,u);else{const N=f.get(d),S=N==null?void 0:N.imports.get(o.targetExpr.split(".")[0]);S&&(g=Be(d,S,u))}if(g&&f.has(g)){const N=`router:${g}:${a}`;if(j({id:N,type:"router",label:o.pattern,file:g,line:o.line}),w({id:`edge:${e}->${N}`,source:e,target:N,type:"mounts",label:o.pattern}),!q.has(`${g}@${a}`)){q.add(`${g}@${a}`);const S=f.get(g);c(N,a,g,S.urlEntries)}}else A.push(`${d}:${o.line} -> ${o.targetExpr}`)}else if(o.kind==="router_urls")p(e,a,d,o.targetExpr);else if(o.kind==="view"){if(o.targetExpr.endsWith(".urls")){const R=o.targetExpr.replace(/\.urls$/,"").trim(),O=V(d,R),z=f.get(O.file);if(z!=null&&z.ninjaApis.has(O.symbol)){y(e,a,O.file,O.symbol);continue}p(e,a,d,o.targetExpr);continue}const h=V(d,o.targetExpr),g=f.get(h.file),N=g==null?void 0:g.classes.get(h.symbol),S=g==null?void 0:g.funcs.get(h.symbol);if(N){const R=N.bases.flatMap(_s),O=Array.from(new Set([...N.httpMethods,...R])),z=O.length>0?O:["GET"],G=N.permissionClasses.length?N.permissionClasses:void 0,W=N.serializerClass?[N.serializerClass]:void 0;for(const H of z)T(e,H,a,h.file,N.line,h.symbol,{middlewares:G,bodyFields:W})}else if(S){const R=S.decorators.filter(O=>O!=="api_view");for(const O of S.methods)T(e,O,a,h.file,S.line,h.symbol,{middlewares:R})}else T(e,"GET",a,d,o.line,o.targetExpr)}}},y=(e,l,d,i)=>{const o=f.get(d);if(o){for(const a of o.ninjaRoutes){if(a.targetVar!==i)continue;const h=ne(l,a.path);for(const g of a.methods)T(e,g,h,d,a.line,a.handlerName)}for(const a of o.ninjaMounts){if(a.parentVar!==i)continue;const h=ne(l,a.prefix),g=V(d,a.childExpr);y(e,h,g.file,g.symbol)}}};for(const e of P){const l=`entry:${e}`;j({id:l,type:"entry",label:e,file:e,line:1}),q.add(`${e}@/`);const d=f.get(e);c(l,"/",e,d.urlEntries);for(const i of d.ninjaApis)y(l,"/",e,i)}for(const e of f.values()){if(!Array.from(q).some(d=>d.startsWith(`${e.path}@`))&&e.urlEntries.length>0){const d=`entry:${e.path}`;j({id:d,type:"entry",label:e.path,file:e.path,line:1}),q.add(`${e.path}@/`),c(d,"/",e.path,e.urlEntries)}for(const d of e.routerRegs)if(!B.has(`${e.path}:${d.routerVar}`)){const i=`entry:${e.path}`;j({id:i,type:"entry",label:e.path,file:e.path,line:1}),v(i,"/",d,e.path)}}const m=Number((performance.now()-r).toFixed(2));return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"unknown",framework:"django",scannedFiles:n.length,scanDurationMs:m,unresolvedMounts:A},nodes:E,edges:x}}},Kt=/(?:^|\/)(?:tests?|__tests__|vendor)\/|_test\.go$/i,Ts={GET:"GET",Get:"GET",POST:"POST",Post:"POST",PUT:"PUT",Put:"PUT",PATCH:"PATCH",Patch:"PATCH",DELETE:"DELETE",Delete:"DELETE",OPTIONS:"OPTIONS",Options:"OPTIONS",HEAD:"HEAD",Head:"HEAD",Any:"ALL",All:"ALL"};function Oe(n,t){let r=1;for(let s=0;s<t&&s<n.length;s++)n[s]===`
|
|
15
|
-
`&&r++;return r}function Cs(n){let t="",r=null;for(let s=0;s<n.length;s++){const u=n[s];if(r){if(t+=u,r!=="`"&&u==="\\"&&s+1<n.length){t+=n[++s];continue}u===r&&(r=null);continue}if(u==='"'||u==="'"||u==="`"){r=u,t+=u;continue}if(u==="/"&&n[s+1]==="/"){for(;s<n.length&&n[s]!==`
|
|
16
|
-
`;)t+=" ",s++;s<n.length&&(t+=`
|
|
17
|
-
`);continue}if(u==="/"&&n[s+1]==="*"){for(t+=" ",s+=2;s<n.length&&!(n[s]==="*"&&n[s+1]==="/");)t+=n[s]===`
|
|
18
|
-
`?`
|
|
19
|
-
`:" ",s++;s<n.length&&(t+=" ",s++);continue}t+=u}return t}function Ne(n,t,r,s){if(n[t]!==r)return null;let u=0,f=null;for(let E=t;E<n.length;E++){const x=n[E];if(f){if(f!=="`"&&x==="\\"){E++;continue}x===f&&(f=null);continue}if(x==='"'||x==="'"||x==="`"){f=x;continue}if(x===r)u++;else if(x===s&&(u--,u===0))return{text:n.slice(t+1,E),endIdx:E}}return null}function ke(n){const t=[];let r=0,s=0,u=0,f=null,E=0;for(let b=0;b<n.length;b++){const $=n[b];if(f){if(f!=="`"&&$==="\\"){b++;continue}$===f&&(f=null);continue}if($==='"'||$==="'"||$==="`"){f=$;continue}if($==="(")r++;else if($===")")r--;else if($==="[")s++;else if($==="]")s--;else if($==="{")u++;else if($==="}")u--;else if($===","&&r===0&&s===0&&u===0){const A=n.slice(E,b).trim();A&&t.push(A),E=b+1}}const x=n.slice(E).trim();return x&&t.push(x),t}function je(n){const t=n.trim(),r=t.match(/^"([^"\\]*(?:\\.[^"\\]*)*)"$/)||t.match(/^`([^`]*)`$/);return r?r[1]:null}function Ae(n){let t=n.trim();return t=t.replace(/\{([A-Za-z_][A-Za-z0-9_]*)(?::[^}]*|\.\.\.)?\}/g,":$1"),t?t.startsWith("/")?t:`/${t}`:"/"}function Is(n){const t=n.trim(),r=t.match(/^(GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD)\s+(.+)$/i);return r?{method:r[1].toUpperCase(),path:Ae(r[2])}:{method:"GET",path:Ae(t)}}function ve(n){const t=n.trim();return t.match(/^func\s*\(/)?"anonymous":t.replace(/\([^)]*\)$/,"").trim()||"handler"}function Fs(n){const t=n.map(r=>r.content).join(`
|
|
20
|
-
`);return/github\.com\/gin-gonic\/gin/.test(t)?"gin":/github\.com\/labstack\/echo/.test(t)?"echo":/github\.com\/gofiber\/fiber/.test(t)?"fiber":/github\.com\/go-chi\/chi/.test(t)?"chi":/github\.com\/gorilla\/mux/.test(t)?"gorilla-mux":"go-http"}var Rs=class{constructor(){ue(this,"name","go")}detect(n){return n.some(r=>oe(r.path).endsWith("go.mod")&&/(?:github\.com\/(?:gin-gonic\/gin|labstack\/echo|gofiber\/fiber|go-chi\/chi|gorilla\/mux)|golang\.org)/i.test(r.content))?!0:n.some(r=>r.path.endsWith(".go")&&!Kt.test(r.path)&&/(?:github\.com\/(?:gin-gonic\/gin|labstack\/echo|gofiber\/fiber|go-chi\/chi|gorilla\/mux)|http\.(?:HandleFunc|NewServeMux|Handle)\s*\()/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(c=>({path:oe(c.path),content:c.content})).filter(c=>c.path.endsWith(".go")&&!Kt.test(c.path)),u=Fs(n),f=[],E=[],x=new Set,b=new Set,$=c=>{x.has(c.id)||(x.add(c.id),f.push(c))},A=c=>{b.has(c.id)||(b.add(c.id),E.push(c))},j=new Map,w=/(?:\*?gin\.(?:Engine|RouterGroup|IRouter|IRoutes)|\*?echo\.(?:Echo|Group)|fiber\.Router|\*?fiber\.App|chi\.Router|\*?mux\.Router|\*?http\.ServeMux)/,M=new Map,D=new Map;for(const c of s){const y=Cs(c.content);M.set(c.path,y);const m=y.match(/^\s*package\s+([A-Za-z_][A-Za-z0-9_]*)/m),e=m?m[1]:"main";D.set(c.path,e);const l=/\bfunc\s*(?:\([^)]+\)\s*)?([A-Za-z_][A-Za-z0-9_]*)\s*\(([^)]*)\)/g;let d;for(;(d=l.exec(y))!==null;){const i=d[1],o=d[2],a=d.index+d[0].length;let h=y.indexOf("{",a);if(h===-1)continue;const g=Ne(y,h,"{","}");if(!g)continue;const N=[];for(const O of ke(o))if(w.test(O)){const z=O.replace(w,"").trim().split(/\s*,\s*/);for(const G of z)/^[A-Za-z_][A-Za-z0-9_]*$/.test(G)&&N.push(G)}const S={name:i,pkg:e,file:c.path,line:Oe(y,d.index),routerParams:N,body:g.text,bodyStartIdx:h+1},R=j.get(i)??[];R.push(S),j.set(i,R),l.lastIndex=g.endIdx+1}}const P=(c,y,m,e,l,d,i)=>{const o=m||"/",a=`route:${y}:${o}`;$({id:a,type:"route",label:`${y} ${o}`,file:e,line:l,method:y,fullPath:o,pathParams:fe(o),group:me(o),middlewares:i!=null&&i.length?i:void 0,controller:d,controllerFile:e,controllerLine:l}),A({id:`edge:${c}->${a}`,source:c,target:a,type:"handles"})},q=new Set,B=(c,y,m,e,l,d)=>{const i=new Map(l),o=/\b([A-Za-z_][A-Za-z0-9_]*)\s*:?=\s*(?:gin\.(?:Default|New)|echo\.New|fiber\.New|chi\.New(?:Router)?|mux\.NewRouter|http\.NewServeMux)\s*\(/g;let a;for(;(a=o.exec(c))!==null;){const F=a[1];i.has(F)||i.set(F,{varName:F,prefix:"/",middlewares:[],nodeId:d})}const h=/\b([A-Za-z_][A-Za-z0-9_]*)\s*:?=\s*([A-Za-z_][A-Za-z0-9_]*)\.(?:Group|PathPrefix)\s*\(/g;let g;for(;(g=h.exec(c))!==null;){const F=g[1],k=g[2],I=g.index+g[0].length-1,Z=Ne(c,I,"(",")");if(!Z)continue;const U=ke(Z.text),J=U[0]?je(U[0]):null;if(J===null)continue;const K=i.get(k)??{prefix:"/",middlewares:[],nodeId:d},Q=ne(K.prefix,Ae(J)),te=[...K.middlewares,...U.slice(1).map(ve)],re=`router:${e}:${Q}:${Oe(m,y+g.index)}`;$({id:re,type:"router",label:J,file:e,line:Oe(m,y+g.index)}),A({id:`edge:${K.nodeId}->${re}`,source:K.nodeId,target:re,type:"mounts",label:J}),i.set(F,{varName:F,prefix:Q,middlewares:te,nodeId:re})}const N=/\b([A-Za-z_][A-Za-z0-9_]*)\.Use\s*\(/g;let S;for(;(S=N.exec(c))!==null;){const F=i.get(S[1]);if(!F)continue;const k=S.index+S[0].length-1,I=Ne(c,k,"(",")");if(I)for(const Z of ke(I.text))F.middlewares.push(ve(Z))}const R=/\b([A-Za-z_][A-Za-z0-9_]*)\.(Route|Group)\s*\(/g,O=[];let z;for(;(z=R.exec(c))!==null;){const F=z[1],k=z[2],I=z.index+z[0].length-1,Z=Ne(c,I,"(",")");if(!Z)continue;const U=ke(Z.text),J=k==="Route"?U[1]:U[0];if(!J||!/^func\s*\(/.test(J.trim()))continue;const K=i.get(F)??{prefix:"/",middlewares:[],nodeId:d},Q=k==="Route"&&U[0]?je(U[0])??"/":"/",te=ne(K.prefix,Ae(Q)),re=J.match(/^func\s*\(\s*([A-Za-z_][A-Za-z0-9_]*)/),ae=re?re[1]:F,Y=J.indexOf("{"),se=Y!==-1?Ne(J,Y,"{","}"):null;if(se){const ee=`router:${e}:${te}:${Oe(m,y+z.index)}`;$({id:ee,type:"router",label:Q,file:e,line:Oe(m,y+z.index)}),A({id:`edge:${K.nodeId}->${ee}`,source:K.nodeId,target:ee,type:"mounts",label:Q});const ce=new Map(i);ce.set(ae,{varName:ae,prefix:te,middlewares:[...K.middlewares],nodeId:ee}),O.push([I,Z.endIdx]),B(se.text,y+z.index,m,e,ce,d)}R.lastIndex=Z.endIdx+1}const G=F=>O.some(([k,I])=>F>=k&&F<=I),W=/\b([A-Za-z_][A-Za-z0-9_]*)\.(GET|Get|POST|Post|PUT|Put|PATCH|Patch|DELETE|Delete|OPTIONS|Options|HEAD|Head|Any|All|HandleFunc|Handle|Add|Method)\s*\(/g;let H;for(;(H=W.exec(c))!==null;){if(G(H.index))continue;const F=H[1],k=H[2],I=H.index+H[0].length-1,Z=Ne(c,I,"(",")");if(!Z)continue;const U=ke(Z.text),J=Oe(m,y+H.index),K=i.get(F)??{prefix:"/",middlewares:[],nodeId:d};if(k==="Add"||k==="Method"||k==="Handle"&&U.length>=3&&je(U[1])!==null){const Q=U[0]?je(U[0]):null,te=U[1]?je(U[1]):null;if(Q&&te!==null){const re=Q.toUpperCase()||"GET",ae=ne(K.prefix,Ae(te)),Y=U[2]?ve(U[2]):"handler",se=[...K.middlewares,...U.slice(3).map(ve)];P(K.nodeId,re,ae,e,J,Y,se)}}else if(k==="HandleFunc"||k==="Handle"){const Q=U[0]?je(U[0]):null;if(Q!==null){const re=c.slice(Z.endIdx+1,Z.endIdx+80).match(/^\s*\.Methods\s*\(([^)]+)\)/);if(re){const ae=ne(K.prefix,Ae(Q)),Y=U[1]?ve(U[1]):"handler",se=re[1].match(/"([A-Za-z]+)"/g)??[];for(const ee of se){const ce=ee.replace(/"/g,"").toUpperCase();P(K.nodeId,ce,ae,e,J,Y,K.middlewares)}}else{const ae=Is(Q),Y=ne(K.prefix,ae.path),se=U[1]?ve(U[1]):"handler";P(K.nodeId,ae.method,Y,e,J,se,K.middlewares)}}}else{const Q=Ts[k]??"GET",te=U[0]?je(U[0]):null;if(te!==null){const re=ne(K.prefix,Ae(te)),ae=U.length>=2?ve(U[U.length-1]):"handler",Y=U.length>2?[...K.middlewares,...U.slice(1,-1).map(ve)]:K.middlewares;P(K.nodeId,Q,re,e,J,ae,Y)}}W.lastIndex=Z.endIdx+1}const _=/\b(?:([A-Za-z_][A-Za-z0-9_]*)\.)?([A-Za-z_][A-Za-z0-9_]*)\s*\(/g;let C;for(;(C=_.exec(c))!==null;){if(G(C.index))continue;const F=C[2],k=j.get(F);if(!k||k.length===0)continue;const I=C.index+C[0].length-1,Z=Ne(c,I,"(",")");if(!Z)continue;const U=ke(Z.text);for(let J=0;J<U.length;J++){const K=U[J].trim();let Q=i.get(K);if(!Q){const te=K.match(/^([A-Za-z_][A-Za-z0-9_]*)\.(?:Group|PathPrefix)\s*\(([\s\S]*)\)$/);if(te){const re=i.get(te[1]),ae=ke(te[2]),Y=ae[0]?je(ae[0]):null;re&&Y!==null&&(Q={varName:K,prefix:ne(re.prefix,Ae(Y)),middlewares:[...re.middlewares,...ae.slice(1).map(ve)],nodeId:re.nodeId})}}if(Q)for(const te of k){if(te.routerParams.length===0)continue;const re=te.routerParams[0],ae=`${te.file}:${te.name}@${Q.prefix}`;if(q.has(ae))continue;q.add(ae);const Y=M.get(te.file)??te.body,se=new Map;se.set(re,{varName:re,prefix:Q.prefix,middlewares:[...Q.middlewares],nodeId:Q.nodeId}),B(te.body,te.bodyStartIdx,Y,te.file,se,d)}}}},V=s.filter(c=>/\bfunc\s+main\s*\(/.test(M.get(c.path)??"")),T=[...V,...s.filter(c=>!V.includes(c))];for(const c of T){const y=M.get(c.path);if(/\b(?:gin\.(?:Default|New)|echo\.New|fiber\.New|chi\.New(?:Router)?|mux\.NewRouter|http\.(?:NewServeMux|HandleFunc|Handle))\b/.test(y)){const e=`entry:${c.path}`;$({id:e,type:"entry",label:c.path,file:c.path,line:1});const l=new Map;l.set("http",{varName:"http",prefix:"/",middlewares:[],nodeId:e}),B(y,0,y,c.path,l,e)}}for(const c of j.values())for(const y of c){if(y.routerParams.length===0||Array.from(q).some(i=>i.startsWith(`${y.file}:${y.name}@`)))continue;const e=`entry:${y.file}`;$({id:e,type:"entry",label:y.file,file:y.file,line:1});const l=M.get(y.file)??y.body,d=new Map;d.set(y.routerParams[0],{varName:y.routerParams[0],prefix:"/",middlewares:[],nodeId:e}),q.add(`${y.file}:${y.name}@/`),B(y.body,y.bodyStartIdx,l,y.file,d,e)}const v=new Set(f.filter(c=>c.type==="entry").map(c=>c.file));for(const c of s){if(v.has(c.path)||Array.from(q).some(e=>e.startsWith(`${c.path}:`)))continue;const m=M.get(c.path);if(/\.(?:GET|Get|POST|Post|PUT|Put|PATCH|Patch|DELETE|Delete|Any|All|HandleFunc)\s*\(\s*["`][^"`]*\//.test(m)){const e=`entry:${c.path}`;$({id:e,type:"entry",label:c.path,file:c.path,line:1}),B(m,0,m,c.path,new Map,e)}}const p=Number((performance.now()-r).toFixed(2));return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"unknown",framework:u,scannedFiles:n.length,scanDurationMs:p,unresolvedMounts:[]},nodes:f,edges:E}}},Jt=/(?:^|\/)(?:tests?|benches|examples|target)\/|_test\.rs$/i,Yt=new Set(["get","post","put","patch","delete","head","options"]);function Se(n,t){let r=1;for(let s=0;s<t&&s<n.length;s++)n[s]===`
|
|
21
|
-
`&&r++;return r}function zs(n){let t="",r=!1,s=0;for(let u=0;u<n.length;u++){const f=n[u];if(s>0){f==="/"&&n[u+1]==="*"?(s++,t+=" ",u++):f==="*"&&n[u+1]==="/"?(s--,t+=" ",u++):t+=f===`
|
|
22
|
-
`?`
|
|
23
|
-
`:" ";continue}if(r){if(t+=f,f==="\\"&&u+1<n.length){t+=n[++u];continue}f==='"'&&(r=!1);continue}if(f==='"'){r=!0,t+=f;continue}if(f==="/"&&n[u+1]==="/"){for(;u<n.length&&n[u]!==`
|
|
24
|
-
`;)t+=" ",u++;u<n.length&&(t+=`
|
|
25
|
-
`);continue}if(f==="/"&&n[u+1]==="*"){s=1,t+=" ",u++;continue}t+=f}return t}function Ee(n,t,r,s){if(n[t]!==r)return null;let u=0,f=!1;for(let E=t;E<n.length;E++){const x=n[E];if(f){if(x==="\\"){E++;continue}x==='"'&&(f=!1);continue}if(x==='"'){f=!0;continue}if(x===r)u++;else if(x===s&&(u--,u===0))return{text:n.slice(t+1,E),endIdx:E}}return null}function Ue(n){const t=[];let r=0,s=0,u=0,f=!1,E=0;for(let b=0;b<n.length;b++){const $=n[b];if(f){if($==="\\"){b++;continue}$==='"'&&(f=!1);continue}if($==='"'){f=!0;continue}if($==="(")r++;else if($===")")r--;else if($==="[")s++;else if($==="]")s--;else if($==="{")u++;else if($==="}")u--;else if($===","&&r===0&&s===0&&u===0){const A=n.slice(E,b).trim();A&&t.push(A),E=b+1}}const x=n.slice(E).trim();return x&&t.push(x),t}function Ve(n){const t=n.trim(),r=t.match(/^"([^"\\]*(?:\\.[^"\\]*)*)"$/)||t.match(/^r#*"([\s\S]*?)"#*$/);return r?r[1]:null}function Ke(n){let t=n.trim();return t=t.replace(/\{\*?([A-Za-z_][A-Za-z0-9_]*)(?::[^}]*)?\}/g,":$1"),t=t.replace(/<([A-Za-z_][A-Za-z0-9_]*)(?:\.\.)?>/g,":$1"),t?t.startsWith("/")?t:`/${t}`:"/"}function Os(n){const t=n.map(r=>r.content).join(`
|
|
26
|
-
`);return/\baxum\b/.test(t)?"axum":/\bactix[-_]web\b/.test(t)?"actix-web":/\brocket\b/.test(t)?"rocket":"rust"}var Ds=class{constructor(){ue(this,"name","rust")}detect(n){return n.some(r=>oe(r.path).endsWith("Cargo.toml")&&/\b(?:axum|actix-web|rocket)\b/i.test(r.content))?!0:n.some(r=>r.path.endsWith(".rs")&&!Jt.test(r.path)&&/(?:use\s+(?:axum|actix_web|rocket)|Router::new\s*\(|App::new\s*\(|rocket::build\s*\()/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(p=>({path:oe(p.path),content:p.content})).filter(p=>p.path.endsWith(".rs")&&!Jt.test(p.path)),u=Os(n),f=[],E=[],x=new Set,b=new Set,$=p=>{x.has(p.id)||(x.add(p.id),f.push(p))},A=p=>{b.has(p.id)||(b.add(p.id),E.push(p))},j=(p,c,y,m,e,l,d)=>{const i=y||"/",o=`route:${c}:${i}`;$({id:o,type:"route",label:`${c} ${i}`,file:m,line:e,method:c,fullPath:i,pathParams:fe(i),group:me(i),middlewares:void 0,controller:l,controllerFile:m,controllerLine:e}),A({id:`edge:${p}->${o}`,source:p,target:o,type:"handles"})},w=new Map,M=new Map,D=new Map;for(const p of s){const c=zs(p.content);w.set(p.path,c);const y=/((?:#\[(?:(?:actix_web|rocket)::)?(?:get|post|put|patch|delete|head|options|route)\s*\([^)]*\)\]\s*)+)(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/g;let m;for(;(m=y.exec(c))!==null;){const d=m[1],i=m[2],o=[],a=/#\[(?:(?:actix_web|rocket)::)?(get|post|put|patch|delete|head|options|route)\s*\(([^)]*)\)\]/g;let h;for(;(h=a.exec(d))!==null;){const g=h[1].toLowerCase(),N=Ue(h[2]),S=N[0]?Ve(N[0]):null;if(S===null)continue;const R=Ke(S),O=Se(c,m.index);if(g==="route"){const z=h[2].match(/method\s*=\s*"([A-Za-z]+)"/g)??[];if(z.length>0)for(const G of z){const W=G.match(/"([A-Za-z]+)"/)[1].toUpperCase();o.push({method:W,path:R,handler:i,line:O})}else o.push({method:"GET",path:R,handler:i,line:O})}else Yt.has(g)&&o.push({method:g.toUpperCase(),path:R,handler:i,line:O})}if(o.length>0){const g=M.get(i)??[];g.push({name:i,file:p.path,line:Se(c,m.index),routes:o}),M.set(i,g)}}const e=/\b(?:pub(?:\([^)]*\))?\s+)?(?:async\s+)?fn\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:<[^>]*>)?\s*\(([^)]*)\)(?:\s*->\s*([^{]+))?\s*\{/g;let l;for(;(l=e.exec(c))!==null;){const d=l[1],i=l[2],o=l[3]??"",a=l.index+l[0].length-1,h=Ee(c,a,"{","}");if(!h)continue;const g={name:d,file:p.path,line:Se(c,l.index),isServiceConfig:/ServiceConfig/.test(i),returnsRouter:/\bRouter\b/.test(o),body:h.text,bodyOffset:a+1},N=D.get(d)??[];N.push(g),D.set(d,N),e.lastIndex=h.endIdx+1}}const P=new Set,q=new Set,B=p=>{const c=[],y=/\b(?:(?:axum::)?routing::)?(get|post|put|patch|delete|options|head|any)\s*\(/g;let m;for(;(m=y.exec(p))!==null;){const e=m.index+m[0].length-1,l=Ee(p,e,"(",")");if(!l)continue;const d=m[1].toLowerCase(),i=d==="any"?"ALL":d.toUpperCase(),o=l.text.trim().replace(/\s+/g," ");c.push({method:i,handler:o||"handler"}),y.lastIndex=l.endIdx+1}return c},V=p=>{const c=[],y=/\bweb::(get|post|put|patch|delete|head|to|route)\s*\(/g;let m;for(;(m=y.exec(p))!==null;){const e=m[1].toLowerCase(),d=p.slice(m.index).match(/\.to\s*\(([^)]+)\)/),i=d?d[1].trim():"handler";if(Yt.has(e))c.push({method:e.toUpperCase(),handler:i});else if(e==="to"){const o=m.index+m[0].length-1,a=Ee(p,o,"(",")");c.push({method:"GET",handler:a?a.text.trim():"handler"})}}return c},T=(p,c,y,m,e,l)=>{const d=/\.route\s*\(/g;let i;for(;(i=d.exec(p))!==null;){const W=i.index+i[0].length-1,H=Ee(p,W,"(",")");if(!H)continue;const _=Ue(H.text),C=_[0]?Ve(_[0]):null;if(C!==null&&_[1]){const F=ne(e,Ke(C)),k=Se(y,c+i.index),I=B(_[1]);if(I.length>0)for(const Z of I)j(l,Z.method,F,m,k,Z.handler);else{const Z=V(_[1]);for(const U of Z)j(l,U.method,F,m,k,U.handler)}}d.lastIndex=H.endIdx+1}const o=/\.nest(?:_service)?\s*\(/g;let a;for(;(a=o.exec(p))!==null;){const W=a.index+a[0].length-1,H=Ee(p,W,"(",")");if(!H)continue;const _=Ue(H.text),C=_[0]?Ve(_[0]):null;if(C!==null&&_[1]){const F=ne(e,Ke(C)),k=_[1].trim(),I=k.match(/([A-Za-z_][A-Za-z0-9_]*)\s*\(/),Z=I?I[1]:k,U=D.get(Z);if(U&&U.length>0){const J=`router:${m}:${F}:${Se(y,c+a.index)}`;$({id:J,type:"router",label:C,file:m,line:Se(y,c+a.index)}),A({id:`edge:${l}->${J}`,source:l,target:J,type:"mounts",label:C});for(const K of U){const Q=`${K.file}:${K.name}@${F}`;if(q.has(Q))continue;q.add(Q);const te=w.get(K.file)??K.body;T(K.body,K.bodyOffset,te,K.file,F,J)}}}o.lastIndex=H.endIdx+1}const h=/\bweb::scope\s*\(/g;let g;for(;(g=h.exec(p))!==null;){const W=g.index+g[0].length-1,H=Ee(p,W,"(",")");if(!H)continue;const _=Ue(H.text),C=_[0]?Ve(_[0]):null;if(C!==null){const F=ne(e,Ke(C)),k=`router:${m}:${F}:${Se(y,c+g.index)}`;$({id:k,type:"router",label:C,file:m,line:Se(y,c+g.index)}),A({id:`edge:${l}->${k}`,source:l,target:k,type:"mounts",label:C});const I=p.slice(H.endIdx+1),Z=I.search(/;|\n\s*\)/),U=Z===-1?I:I.slice(0,Z);T(U,c+H.endIdx+1,y,m,F,k)}}const N=/\.service\s*\(/g;let S;for(;(S=N.exec(p))!==null;){const W=S.index+S[0].length-1,H=Ee(p,W,"(",")");if(!H)continue;const _=H.text.trim();if(!_.startsWith("web::")){const C=_.split("::").pop()??_,F=M.get(C);if(F)for(const k of F){P.add(`${k.file}:${k.name}`);for(const I of k.routes)j(l,I.method,ne(e,I.path),k.file,I.line,k.name)}}N.lastIndex=H.endIdx+1}const R=/\.configure\s*\(/g;let O;for(;(O=R.exec(p))!==null;){const W=O.index+O[0].length-1,H=Ee(p,W,"(",")");if(!H)continue;const _=H.text.trim().split("::").pop()??H.text.trim(),C=D.get(_);if(C)for(const F of C){const k=`${F.file}:${F.name}@${e}`;if(q.has(k))continue;q.add(k);const I=w.get(F.file)??F.body;T(F.body,F.bodyOffset,I,F.file,e,l)}R.lastIndex=H.endIdx+1}const z=/\.mount\s*\(/g;let G;for(;(G=z.exec(p))!==null;){const W=G.index+G[0].length-1,H=Ee(p,W,"(",")");if(!H)continue;const _=Ue(H.text),C=_[0]?Ve(_[0]):null;if(C!==null&&_[1]){const F=ne(e,Ke(C)),k=_[1].match(/routes!\s*\[([\s\S]*?)\]/);if(k){const I=k[1].split(",").map(Z=>Z.trim().split("::").pop()).filter(Boolean);for(const Z of I){const U=M.get(Z);if(U)for(const J of U){P.add(`${J.file}:${J.name}`);for(const K of J.routes)j(l,K.method,ne(F,K.path),J.file,K.line,J.name)}}}}z.lastIndex=H.endIdx+1}};for(const p of s){const c=w.get(p.path);if(/\b(?:Router::new|App::new|rocket::build)\s*\(/.test(c)||/\bfn\s+main\s*\(/.test(c)){const y=`entry:${p.path}`;$({id:y,type:"entry",label:p.path,file:p.path,line:1}),T(c,0,c,p.path,"/",y)}}for(const p of D.values())for(const c of p){if(!c.returnsRouter&&!c.isServiceConfig||Array.from(q).some(l=>l.startsWith(`${c.file}:${c.name}@`)))continue;const m=`entry:${c.file}`;$({id:m,type:"entry",label:c.file,file:c.file,line:1}),q.add(`${c.file}:${c.name}@/`);const e=w.get(c.file)??c.body;T(c.body,c.bodyOffset,e,c.file,"/",m)}for(const p of M.values())for(const c of p){if(P.has(`${c.file}:${c.name}`))continue;const y=`entry:${c.file}`;$({id:y,type:"entry",label:c.file,file:c.file,line:1});for(const m of c.routes)j(y,m.method,m.path,c.file,m.line,c.name)}const v=Number((performance.now()-r).toFixed(2));return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"unknown",framework:u,scannedFiles:n.length,scanDurationMs:v,unresolvedMounts:[]},nodes:f,edges:E}}},Xt=/(?:^|\/)(?:src\/test|tests?|__tests__|target|build)\/|Test\.(?:java|kt)$/i,Ls={GetMapping:"GET",PostMapping:"POST",PutMapping:"PUT",PatchMapping:"PATCH",DeleteMapping:"DELETE"};function Zs(n,t){let r=1;for(let s=0;s<t&&s<n.length;s++)n[s]===`
|
|
27
|
-
`&&r++;return r}function qs(n){let t="",r=!1;for(let s=0;s<n.length;s++){const u=n[s];if(r){if(t+=u,u==="\\"&&s+1<n.length){t+=n[++s];continue}u==='"'&&(r=!1);continue}if(u==='"'){r=!0,t+=u;continue}if(u==="/"&&n[s+1]==="/"){for(;s<n.length&&n[s]!==`
|
|
28
|
-
`;)t+=" ",s++;s<n.length&&(t+=`
|
|
29
|
-
`);continue}if(u==="/"&&n[s+1]==="*"){for(t+=" ",s+=2;s<n.length&&!(n[s]==="*"&&n[s+1]==="/");)t+=n[s]===`
|
|
30
|
-
`?`
|
|
31
|
-
`:" ",s++;s<n.length&&(t+=" ",s++);continue}t+=u}return t}function wt(n){const t=n.trim().replace(/\{([A-Za-z_][A-Za-z0-9_]*)(?::[^}]*)?\}/g,":$1");return t?t.startsWith("/")?t:`/${t}`:"/"}function Qt(n){const t=[],r=n.trim();if(!r)return[""];const s=r.match(/(?:value|path)\s*=\s*(\{[^}]*\}|\[[^\]]*\]|"[^"]*")/),u=s?s[1]:r;if(!s&&r.includes("=")&&!/^\s*(?:"|\{|\[)/.test(r))return[""];const f=/"([^"]*)"/g;let E;for(;(E=f.exec(u))!==null;)t.push(E[1]);return t.length>0?t:[""]}function Gs(n){const t=[],r=n.match(/method\s*=\s*(\{[^}]*\}|(?:RequestMethod\.)?(?:GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD))/);if(!r)return["GET"];const s=/\b(?:RequestMethod\.)?(GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD)\b/g;let u;for(;(u=s.exec(r[1]))!==null;)t.push(u[1]);return t.length>0?t:["GET"]}var Ws=class{constructor(){ue(this,"name","springboot")}detect(n){return n.some(r=>{const s=oe(r.path);return(s.endsWith("pom.xml")||s.endsWith("build.gradle")||s.endsWith("build.gradle.kts"))&&/spring-boot-starter-web|org\.springframework\.boot/i.test(r.content)})?!0:n.some(r=>(r.path.endsWith(".java")||r.path.endsWith(".kt"))&&!Xt.test(r.path)&&/@(?:RestController|Controller|RequestMapping|GetMapping|PostMapping)\b/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(j=>({path:oe(j.path),content:j.content})).filter(j=>(j.path.endsWith(".java")||j.path.endsWith(".kt"))&&!Xt.test(j.path)),u=[],f=[],E=new Set,x=new Set,b=j=>{E.has(j.id)||(E.add(j.id),u.push(j))},$=j=>{x.has(j.id)||(x.add(j.id),f.push(j))};for(const j of s){const w=qs(j.content);let M=j.path.split("/").pop().replace(/\.(?:java|kt)$/,""),D=["/"],P=[];const q=[],B=w.split(`
|
|
32
|
-
`);let V=[],T=!1;for(let c=0;c<B.length;c++){const y=B[c].trim();if(!y)continue;if(y.startsWith("@")){let e=y,l=(e.match(/\(/g)||[]).length,d=(e.match(/\)/g)||[]).length;for(;l>d&&c+1<B.length;){c++;const i=B[c].trim();e+=" "+i,l+=(i.match(/\(/g)||[]).length,d+=(i.match(/\)/g)||[]).length}V.push(e);continue}const m=T?null:y.match(/^(?:(?:public|open|internal|abstract|final|sealed)\s+)*(?:class|interface)\s+([A-Za-z_][A-Za-z0-9_]*)/);if(m){T=!0,M=m[1];const e=V.join(`
|
|
33
|
-
`);V=[];const l=e.match(/@RequestMapping\s*(?:\(([^)]*)\))?/);l&&l[1]&&(D=Qt(l[1]).map(wt));const d=e.match(/@(?:PreAuthorize|Secured|RolesAllowed)\s*\([^)]*\)/g);d&&(P=d.map(i=>i.replace(/^@/,"").split("(")[0]));continue}if(V.length>0){const e=V.join(`
|
|
34
|
-
`);if(/@(?:GetMapping|PostMapping|PutMapping|PatchMapping|DeleteMapping|RequestMapping)\b/.test(e)){let l=y,d=(l.match(/\(/g)||[]).length,i=(l.match(/\)/g)||[]).length;for(;d>i&&c+1<B.length;){c++;const a=B[c].trim();l+=" "+a,d+=(a.match(/\(/g)||[]).length,i+=(a.match(/\)/g)||[]).length}const o=l.match(/([A-Za-z_][A-Za-z0-9_]*)\s*\(([\s\S]*)\)/);if(o){const a=o[1],h=o[2]??"",g=/@(GetMapping|PostMapping|PutMapping|PatchMapping|DeleteMapping|RequestMapping)\s*(?:\(([^)]*)\))?/g;let N;const S=[];for(;(N=g.exec(e))!==null;){const k=N[1],I=N[2]??"",Z=Qt(I);k==="RequestMapping"?S.push({methods:Gs(I),subPaths:Z}):S.push({methods:[Ls[k]],subPaths:Z})}const R=[...P],O=e.match(/@(?:PreAuthorize|Secured|RolesAllowed)\s*\([^)]*\)/g);if(O)for(const k of O)R.push(k.replace(/^@/,"").split("(")[0]);const z=[],G=/@RequestParam(?:\s*\(\s*(?:value\s*=\s*|name\s*=\s*)?"([^"]+)"|\s*\([^)]*\))?\s+(?:[A-Za-z_<>[\]?]+\s+)?([A-Za-z_][A-Za-z0-9_]*)/g;let W;for(;(W=G.exec(h))!==null;)z.push(W[1]||W[2]);const H=[],_=/@RequestBody(?:\s+([A-Za-z_][A-Za-z0-9_<>?]*))?/g;let C;for(;(C=_.exec(h))!==null;)C[1]&&H.push(C[1]);const F=c+1;for(const k of S)for(const I of D)for(const Z of k.subPaths){const U=ne(I,wt(Z));for(const J of k.methods)q.push({method:J,fullPath:U,handler:`${M}.${a}`,line:F,middlewares:R.length?R:void 0,queryParams:z.length?z:void 0,bodyFields:H.length?H:void 0})}}}V=[]}}const v=/\b(GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD)\s*\(\s*"([^"]+)"/g;let p;for(;(p=v.exec(w))!==null;){const c=p[1],y=wt(p[2]);q.push({method:c,fullPath:y,handler:`${M}.router`,line:Zs(w,p.index)})}if(q.length>0){const c=`entry:${j.path}`;b({id:c,type:"entry",label:j.path,file:j.path,line:1});for(const y of q){const m=`route:${y.method}:${y.fullPath}`;b({id:m,type:"route",label:`${y.method} ${y.fullPath}`,file:j.path,line:y.line,method:y.method,fullPath:y.fullPath,pathParams:fe(y.fullPath),group:me(y.fullPath),middlewares:y.middlewares,queryParams:y.queryParams,bodyFields:y.bodyFields,controller:y.handler,controllerFile:j.path,controllerLine:y.line}),$({id:`edge:${c}->${m}`,source:c,target:m,type:"handles"})}}}const A=Number((performance.now()-r).toFixed(2));return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"unknown",framework:"springboot",scannedFiles:n.length,scanDurationMs:A,unresolvedMounts:[]},nodes:u,edges:f}}},en=/(?:^|\/)(?:spec|test|tests)\/|_(?:spec|test)\.rb$/i,Hs=[{action:"index",method:"GET",item:!1},{action:"create",method:"POST",item:!1},{action:"show",method:"GET",item:!0},{action:"update",method:"PATCH",item:!0},{action:"update",method:"PUT",item:!0},{action:"destroy",method:"DELETE",item:!0}],Bs=[{action:"show",method:"GET"},{action:"create",method:"POST"},{action:"update",method:"PATCH"},{action:"update",method:"PUT"},{action:"destroy",method:"DELETE"}];function lt(n){const t=[],r=/:([A-Za-z_][A-Za-z0-9_]*)|['"]([A-Za-z_][A-Za-z0-9_]*)['"]/g;let s;for(;(s=r.exec(n))!==null;)t.push(s[1]||s[2]);return t}function Us(n){return n.endsWith("ies")?`${n.slice(0,-3)}y`:n.endsWith("ses")||n.endsWith("xes")||n.endsWith("ches")||n.endsWith("shes")?n.slice(0,-2):n.endsWith("s")&&!n.endsWith("ss")?n.slice(0,-1):n}function Vs(n){let t=null;for(let r=0;r<n.length;r++){const s=n[r];if(t){if(s==="\\"){r++;continue}s===t&&(t=null);continue}if(s==="'"||s==='"'){t=s;continue}if(s==="#")return n.slice(0,r)}return n}function tn(n){const t=n.trim().replace(/\(\.:format\)/g,"");return t?t.startsWith("/")?t:`/${t}`:"/"}var Ks=class{constructor(){ue(this,"name","rails")}detect(n){return n.some(r=>oe(r.path).endsWith("config/routes.rb"))||n.some(r=>oe(r.path)==="Gemfile"&&/\b(?:rails|sinatra|grape)\b/i.test(r.content))?!0:n.some(r=>r.path.endsWith(".rb")&&!en.test(r.path)&&/Rails\.application\.routes\.draw/.test(r.content))}scan(n,t){const r=performance.now(),s=n.map(M=>({path:oe(M.path),content:M.content})).filter(M=>M.path.endsWith(".rb")&&!en.test(M.path)),u=[],f=[],E=new Set,x=new Set,b=M=>{E.has(M.id)||(E.add(M.id),u.push(M))},$=M=>{x.has(M.id)||(x.add(M.id),f.push(M))},A=(M,D,P,q,B,V)=>{const T=P||"/",v=`route:${D}:${T}`;b({id:v,type:"route",label:`${D} ${T}`,file:q,line:B,method:D,fullPath:T,pathParams:fe(T),group:me(T),controller:V,controllerFile:q,controllerLine:B}),$({id:`edge:${M}->${v}`,source:M,target:v,type:"handles"})},j=s.filter(M=>M.path.endsWith("routes.rb")||/Rails\.application\.routes\.draw/.test(M.content));for(const M of j){const D=`entry:${M.path}`;b({id:D,type:"entry",label:M.path,file:M.path,line:1});const P=[{prefix:"/",kind:"root"}],q=M.content.split(`
|
|
35
|
-
`);for(let B=0;B<q.length;B++){const V=B+1,T=Vs(q[B]).trim();if(!T)continue;const v=P[P.length-1],p=/\bdo(?:\s*\|[^|]*\|)?\s*$/.test(T);if(T==="end"){P.length>1&&P.pop();continue}const c=T.match(/^namespace\s+:([A-Za-z_][A-Za-z0-9_]*)/);if(c&&p){P.push({prefix:ne(v.prefix,`/${c[1]}`),kind:"namespace"});continue}const y=T.match(/^scope\s+(?:path:\s*)?['"]([^'"]+)['"]/);if(y&&p){P.push({prefix:ne(v.prefix,tn(y[1])),kind:"scope"});continue}if(/^scope\b/.test(T)&&p){P.push({prefix:v.prefix,kind:"scope"});continue}if(/^member\b/.test(T)&&p){P.push({prefix:ne(v.prefix,":id"),kind:"member"});continue}if(/^collection\b/.test(T)&&p){P.push({prefix:v.prefix,kind:"collection"});continue}const m=T.match(/^(resources?)\s+((?::[A-Za-z_][A-Za-z0-9_]*\s*,?\s*)+)(.*)$/);if(m){const d=m[1]==="resource",i=lt(m[2]),o=m[3]??"",a=o.match(/path:\s*['"]([^'"]+)['"]/),h=o.match(/only:\s*(?:\[([^\]]+)\]|(:[A-Za-z_]+))/),g=o.match(/except:\s*(?:\[([^\]]+)\]|(:[A-Za-z_]+))/),N=h?new Set(lt(h[1]||h[2])):null,S=g?new Set(lt(g[1]||g[2])):null;let R=v.prefix;v.kind==="resources"&&v.paramName&&(R=ne(v.prefix,`:${v.paramName}`));for(const O of i){const z=a?a[1]:O,G=ne(R,`/${z}`);if(d)for(const W of Bs)N&&!N.has(W.action)||S&&S.has(W.action)||A(D,W.method,G,M.path,V,`${O}#${W.action}`);else for(const W of Hs){if(N&&!N.has(W.action)||S&&S.has(W.action))continue;const H=W.item?ne(G,":id"):G;A(D,W.method,H,M.path,V,`${O}#${W.action}`)}p&&i.length===1&&P.push({prefix:G,kind:d?"resource":"resources",resourceName:O,paramName:`${Us(O)}_id`})}continue}const e=T.match(/^root\s+(?:to:\s*)?['"]([^'"]+)['"]/);if(e){A(D,"GET",v.prefix,M.path,V,e[1]);continue}const l=T.match(/^(get|post|put|patch|delete|options|head|match)\s+['":]([^'",\s]+)['"]?(.*)$/);if(l){const d=l[1].toLowerCase(),i=l[2],o=l[3]??"",a=o.match(/(?:to:|=>)\s*['"]([^'"]+)['"]/),h=a?a[1]:i;let g=v.prefix;v.kind==="resources"&&v.paramName&&!T.includes("on:")?g=ne(v.prefix,`:${v.paramName}`):v.kind==="resources"&&o.includes("on: :member")&&v.paramName&&(g=ne(v.prefix,":id"));const N=ne(g,tn(i));if(d==="match"){const S=o.match(/via:\s*(?:\[([^\]]+)\]|(:[A-Za-z_]+))/),R=S?lt(S[1]||S[2]):["get"];for(const O of R){const z=O==="all"?"ALL":O.toUpperCase();A(D,z,N,M.path,V,h)}}else A(D,d.toUpperCase(),N,M.path,V,h);continue}p&&P.push({prefix:v.prefix,kind:"scope"})}}const w=Number((performance.now()-r).toFixed(2));return{version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"unknown",framework:"rails",scannedFiles:n.length,scanDurationMs:w,unresolvedMounts:[]},nodes:u,edges:f}}},un=/(?:^|\/)(?:tests?|__tests__|spec|target|vendor|node_modules)\/|\.(?:test|spec)\./i;function Me(n,t){let r=1;for(let s=0;s<t&&s<n.length;s++)n[s]===`
|
|
36
|
-
`&&r++;return r}function dn(n,t){const r=new Set(t.nodes.map(E=>E.id)),s=new Set(t.edges.map(E=>E.id)),u=E=>{const x=`entry:${E}`;return r.has(x)||(r.add(x),t.nodes.push({id:x,type:"entry",label:E,file:E,line:1})),x},f=(E,x,b,$,A,j)=>{const w=u(E),M=`route:${b}:${$}`;r.has(M)||(r.add(M),t.nodes.push({id:M,type:"route",label:`${b} ${$}`,file:E,line:x,method:"ALL",fullPath:$,group:A,controller:j,controllerFile:E,controllerLine:x}));const D=`edge:${w}->${M}`;s.has(D)||(s.add(D),t.edges.push({id:D,source:w,target:M,type:"handles"}))};for(const E of n){const x=oe(E.path);if(un.test(x))continue;const b=E.content;if(x.endsWith(".proto")){const $=/\bservice\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([^}]*)\}/g;let A;for(;(A=$.exec(b))!==null;){const j=A[1],w=A[2],M=/\brpc\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(/g;let D;for(;(D=M.exec(w))!==null;)f(x,Me(b,A.index+D.index),"GRPC",`/${j}/${D[1]}`,"grpc",`${j}.${D[1]}`)}continue}if(x.endsWith(".graphql")||x.endsWith(".gql")){const $=/\btype\s+(Query|Mutation|Subscription)\s*\{([^}]*)\}/g;let A;for(;(A=$.exec(b))!==null;){const j=A[1].toUpperCase(),w=A[2],M=/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*(?:\([^)]*\))?\s*:/gm;let D;for(;(D=M.exec(w))!==null;)f(x,Me(b,A.index+D.index),`GQL:${j}`,`/${D[1]}`,"graphql",`${A[1]}.${D[1]}`)}continue}if(/\.(?:ts|tsx|js|jsx)$/.test(x)){if(/@nestjs\/graphql|type-graphql/.test(b)){const j=/@(Query|Mutation|Subscription)\s*\([^)]*\)[\s\S]{0,120}?\b([A-Za-z_][A-Za-z0-9_]*)\s*\(/g;let w;for(;(w=j.exec(b))!==null;)f(x,Me(b,w.index),`GQL:${w[1].toUpperCase()}`,`/${w[2]}`,"graphql",w[2])}if(/\b(?:initTRPC|publicProcedure|protectedProcedure|trpc)\b/.test(b)){const j=/([A-Za-z_][A-Za-z0-9_]*)\s*:\s*[A-Za-z_][A-Za-z0-9_.]*[Pp]rocedure[\s\S]{0,200}?\.(query|mutation|subscription)\s*\(/g;let w;for(;(w=j.exec(b))!==null;)f(x,Me(b,w.index),`TRPC:${w[2].toUpperCase()}`,`/${w[1]}`,"trpc",w[1])}const $=/\b(?:io|socket|wss)\.(?:on|of)\s*\(\s*['"]([^'"]+)['"]/g;let A;for(;(A=$.exec(b))!==null;){const j=A[1];j==="connection"||j==="disconnect"||j==="error"||f(x,Me(b,A.index),"WS",`/${j.replace(/^\/+/,"")}`,"websocket",j)}}if(x.endsWith(".py")){const $=/@[A-Za-z_][A-Za-z0-9_]*\.websocket\s*\(\s*['"]([^'"]+)['"]/g;let A;for(;(A=$.exec(b))!==null;){const j=A[1].startsWith("/")?A[1]:`/${A[1]}`;f(x,Me(b,A.index),"WS",j,"websocket","websocket")}}if(x.endsWith(".java")||x.endsWith(".kt")){const $=/@MessageMapping\s*\(\s*"([^"]+)"\s*\)/g;let A;for(;(A=$.exec(b))!==null;){const j=A[1].startsWith("/")?A[1]:`/${A[1]}`;f(x,Me(b,A.index),"WS",j,"websocket","MessageMapping")}}}}var Js=class{constructor(){ue(this,"name","protocols")}detect(n){return n.some(t=>!un.test(t.path)&&(t.path.endsWith(".proto")||t.path.endsWith(".graphql")||t.path.endsWith(".gql")||/\binitTRPC\b/.test(t.content)))}scan(n,t){const r=performance.now(),s={version:"1.0",metadata:{repoName:(t==null?void 0:t.repoName)??"unknown",framework:"protocols",scannedFiles:n.length,scanDurationMs:0,unresolvedMounts:[]},nodes:[],edges:[]};return dn(n,s),s.metadata.scanDurationMs=Number((performance.now()-r).toFixed(2)),s}},vt=[new Es,new js,new Ms,new Rs,new Ds,new Ws,new Ks,new ms,new us,new fs,new ys,new ws,new Js,new cs];function fn(n,t){const r=vt.find(u=>u.detect(n))??vt[vt.length-1],s=r.scan(n,t);return r.name!=="protocols"&&dn(n,s),s.metadata.unresolved||(s.metadata.unresolved=s.metadata.unresolvedMounts.map(u=>{const f=u.match(/^([^:]+):(\d+)\s*->\s*(.+)$/);if(f)return{file:f[1],line:Number(f[2]),reason:`Unresolved mount: ${f[3]}`};const E=u.match(/^([^:]+):(\d+)\s*\(([^)]+)\)(.*)$/);if(E)return{file:E[1],line:Number(E[2]),reason:`${E[3]}${E[4]}`.trim()};const x=u.match(/^([^:]+):(\d+)\s*(.*)$/);return x?{file:x[1],line:Number(x[2]),reason:x[3]||"Unresolved route/mount"}:{file:"",line:1,reason:u}})),s}const Ys={entry:{width:220,height:76},router:{width:210,height:68},route:{width:310,height:92},middleware:{width:170,height:48},controller:{width:220,height:62}};function Xs(n){return Ys[n]??{width:220,height:70}}function Qs(n,t){const r=new Set([n]),s=new Set,u=new Map,f=new Map;for(const b of t){let $=u.get(b.target);$||($=[],u.set(b.target,$)),$.push(b);let A=f.get(b.source);A||(A=[],f.set(b.source,A)),A.push(b)}const E=[n];for(;E.length>0;){const b=E.pop();for(const $ of u.get(b)??[])s.add($.id),r.has($.source)||(r.add($.source),E.push($.source))}const x=[n];for(;x.length>0;){const b=x.pop();for(const $ of f.get(b)??[])s.add($.id),r.has($.target)||(r.add($.target),x.push($.target))}return{nodeIds:r,edgeIds:s}}const nn={GET:{bg:"rgba(16,185,129,0.18)",text:"#34d399",border:"rgba(16,185,129,0.45)"},POST:{bg:"rgba(56,189,248,0.18)",text:"#38bdf8",border:"rgba(56,189,248,0.45)"},PUT:{bg:"rgba(245,158,11,0.18)",text:"#fbbf24",border:"rgba(245,158,11,0.45)"},PATCH:{bg:"rgba(249,115,22,0.18)",text:"#fb923c",border:"rgba(249,115,22,0.45)"},DELETE:{bg:"rgba(244,63,94,0.18)",text:"#fb7185",border:"rgba(244,63,94,0.45)"},OPTIONS:{bg:"rgba(161,161,170,0.18)",text:"#a1a1aa",border:"rgba(161,161,170,0.4)"},HEAD:{bg:"rgba(161,161,170,0.18)",text:"#a1a1aa",border:"rgba(161,161,170,0.4)"},ALL:{bg:"rgba(168,85,247,0.18)",text:"#c084fc",border:"rgba(168,85,247,0.45)"}};function Et(n,t,r,s,u,f){n.beginPath(),n.roundRect(t,r,s,u,f)}function Te(n,t,r){if(n.measureText(t).width<=r)return t;let s=0,u=t.length;for(;s<u;){const f=s+u+1>>1;n.measureText(t.slice(0,f)+"…").width<=r?s=f:u=f-1}return t.slice(0,s)+"…"}const er=X.forwardRef(({nodes:n,edges:t,selectedRouteId:r,onSelectRoute:s},u)=>{const f=X.useRef(null),E=X.useRef({x:80,y:80,scale:.75}),x=X.useRef(null),b=X.useRef({active:!1,moved:!1,startX:0,startY:0,origX:0,origY:0}),$=X.useRef(null),[A,j]=X.useState(!1),w=X.useMemo(()=>{const m=n.map(i=>{const o=Xs(i.type??"route");return{node:i,data:i.data,x:i.position.x,y:i.position.y,w:o.width,h:o.height}}),e=new Map(m.map(i=>[i.node.id,i])),l=new Map,d=new Map;for(const i of t){let o=l.get(i.target);o||(o=[],l.set(i.target,o)),o.push(i);let a=d.get(i.source);a||(a=[],d.set(i.source,a)),a.push(i)}return{boxes:m,boxById:e,byTarget:l,bySource:d}},[n,t]),M=X.useCallback(m=>{if(!m)return null;const e=new Set([m]),l=new Set,d=[m];for(;d.length>0;){const o=d.pop();for(const a of w.byTarget.get(o)??[])l.add(a.id),e.has(a.source)||(e.add(a.source),d.push(a.source))}const i=[m];for(;i.length>0;){const o=i.pop();for(const a of w.bySource.get(o)??[])l.add(a.id),e.has(a.target)||(e.add(a.target),i.push(a.target))}return{nodeIds:e,edgeIds:l}},[w]),D=X.useCallback(()=>{const m=f.current;if(!m)return;const e=m.getContext("2d");if(!e)return;const l=window.devicePixelRatio||1,d=m.clientWidth,i=m.clientHeight;(m.width!==Math.floor(d*l)||m.height!==Math.floor(i*l))&&(m.width=Math.floor(d*l),m.height=Math.floor(i*l));const{x:o,y:a,scale:h}=E.current;if(e.setTransform(l,0,0,l,0,0),e.fillStyle="#09090b",e.fillRect(0,0,d,i),h>.32){const _=24*h,C=(o%_+_)%_,F=(a%_+_)%_;e.fillStyle="#18181f";for(let k=C;k<d;k+=_)for(let I=F;I<i;I+=_)e.fillRect(k,I,1.3,1.3)}e.save(),e.translate(o,a),e.scale(h,h);const g=-o/h-100,N=-a/h-100,S=(d-o)/h+100,R=(i-a)/h+100,O=x.current??r,z=M(O),G=1/Math.max(h,.06),W=(_,C)=>{const F=w.boxById.get(_.source),k=w.boxById.get(_.target);if(!F||!k)return;const I=F.x+F.w/2,Z=F.y+F.h/2,U=k.x+k.w/2,J=k.y+k.h/2;if(!(Math.max(I,U)<g||Math.min(I,U)>S||Math.max(Z,J)<N||Math.min(Z,J)>R)){if(e.beginPath(),h<.32){const K=I,Q=Z,te=U,re=J;e.moveTo(K,Q),e.lineTo(te,re)}else{const K=k.x>=F.x+F.w-20,Q=K?F.x+F.w:I,te=K?k.x:U,re=Math.max(44,Math.abs(te-Q)*.45);e.moveTo(Q,Z),e.bezierCurveTo(Q+(K?re:0),Z,te-(K?re:0),J,te,J)}C?(e.strokeStyle="#10b981",e.lineWidth=h<.32?2.2*G:2.2):(e.strokeStyle=z?"rgba(113,113,122,0.1)":"rgba(113,113,122,0.32)",e.lineWidth=h<.32?.9*G:1.3),e.stroke()}};for(const _ of t)(!z||!z.edgeIds.has(_.id))&&W(_,!1);if(z)for(const _ of t)z.edgeIds.has(_.id)&&W(_,!0);const H=h>=.32;for(const _ of w.boxes){if(_.x+_.w<g||_.x>S||_.y+_.h<N||_.y>R)continue;const C=z?z.nodeIds.has(_.node.id):!1,F=z?!C:!1,k=r===_.node.id,I=_.data.type;if(e.globalAlpha=F?.16:1,!H){Et(e,_.x,_.y,_.w,_.h,10),e.fillStyle=C?"rgba(16,185,129,0.22)":"#141419",e.fill(),e.strokeStyle=k?"#38bdf8":C?"#10b981":I==="entry"?"rgba(16,185,129,0.65)":I==="router"?"rgba(56,189,248,0.45)":"rgba(255,255,255,0.28)",e.lineWidth=(C||k?2.4:1.1)*G,e.stroke(),e.globalAlpha=1;continue}if(C&&H&&(e.shadowBlur=16,e.shadowColor="rgba(16, 185, 129, 0.35)"),Et(e,_.x,_.y,_.w,_.h,11),e.fillStyle=I==="middleware"?"#19132b":I==="controller"?"#0b2027":"#101014",e.fill(),e.shadowBlur=0,k?(e.strokeStyle="#38bdf8",e.lineWidth=2):C?(e.strokeStyle="#10b981",e.lineWidth=2):(e.strokeStyle=I==="entry"?"rgba(16,185,129,0.55)":I==="router"?"rgba(56,189,248,0.42)":I==="middleware"?"rgba(167,139,250,0.42)":I==="controller"?"rgba(34,211,238,0.38)":"rgba(255,255,255,0.16)",e.lineWidth=1.1),e.stroke(),e.fillStyle=C?"#10b981":"#52525b",I!=="entry"&&(e.beginPath(),e.arc(_.x,_.y+_.h/2,3.2,0,Math.PI*2),e.fill()),(I==="entry"||I==="router"||I==="route")&&(e.beginPath(),e.arc(_.x+_.w,_.y+_.h/2,3.2,0,Math.PI*2),e.fill()),e.textBaseline="middle",I==="route"){const Z=(_.data.method??"GET").toUpperCase(),U=nn[Z]??nn.GET;Et(e,_.x+12,_.y+12,50,18,4),e.fillStyle=U.bg,e.fill(),e.strokeStyle=U.border,e.lineWidth=1,e.stroke(),e.font="bold 10px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle=U.text,e.fillText(Z,_.x+18,_.y+21),e.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle="#71717a",e.fillText(Te(e,_.data.controller??"handler",_.w-86),_.x+70,_.y+21),e.font="500 12px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle="#f4f4f5",e.fillText(Te(e,_.data.fullPath??_.data.label,_.w-24),_.x+12,_.y+49);const J=_.data.middlewares??[];J.length>0&&(e.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle="#c4b5fd",e.fillText(Te(e,J.slice(0,2).join(" · ")+(J.length>2?` +${J.length-2}`:""),_.w-24),_.x+12,_.y+72))}else I==="entry"?(e.font="bold 10px ui-sans-serif, system-ui, sans-serif",e.fillStyle="#34d399",e.fillText("ENTRY",_.x+14,_.y+22),e.font="500 12px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle="#f4f4f5",e.fillText(Te(e,_.data.label,_.w-28),_.x+14,_.y+46)):I==="router"?(e.font="bold 10px ui-sans-serif, system-ui, sans-serif",e.fillStyle="#38bdf8",e.fillText("ROUTER",_.x+12,_.y+20),e.font="600 12px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle="#f4f4f5",e.fillText(Te(e,_.data.label,_.w-24),_.x+12,_.y+40),e.font="10px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle="#71717a",e.fillText(Te(e,_.data.file,_.w-24),_.x+12,_.y+56)):(e.font="11px ui-monospace, SFMono-Regular, Menlo, monospace",e.fillStyle=I==="middleware"?"#c4b5fd":"#67e8f9",e.fillText(Te(e,_.data.label,_.w-24),_.x+12,_.y+_.h/2));e.globalAlpha=1}e.restore()},[t,M,w,r]),P=X.useCallback(()=>{$.current===null&&($.current=requestAnimationFrame(()=>{$.current=null,D()}))},[D]),q=X.useCallback(()=>{const m=f.current;if(!m||w.boxes.length===0)return;let e=1/0,l=1/0,d=-1/0,i=-1/0;for(const S of w.boxes)S.x<e&&(e=S.x),S.y<l&&(l=S.y),S.x+S.w>d&&(d=S.x+S.w),S.y+S.h>i&&(i=S.y+S.h);const o=m.clientWidth||window.innerWidth,a=m.clientHeight||window.innerHeight,h=Math.max(1,d-e),g=Math.max(1,i-l),N=Math.max(.08,Math.min(1.1,Math.min(o*.8/h,a*.8/g)));E.current={scale:N,x:o/2-(e+d)/2*N,y:a/2-(l+i)/2*N},P()},[w.boxes,P]),B=X.useCallback((m,e,l=.95)=>{const d=f.current,i=(d==null?void 0:d.clientWidth)||window.innerWidth,o=(d==null?void 0:d.clientHeight)||window.innerHeight;E.current={scale:l,x:i/2-m*l,y:o/2-e*l},P()},[P]);X.useImperativeHandle(u,()=>({fitView:q,centerOn:B}),[q,B]),X.useEffect(()=>{if(w.boxes.some(l=>l.x<-100||l.y<-100)||w.boxes.length<=100){q();return}const e=w.boxes.find(l=>l.data.type==="entry")??w.boxes[0];e?B(e.x+420,e.y+e.h/2,.58):q()},[w.boxes,B,q]),X.useEffect(()=>{P()},[r,P]),X.useEffect(()=>{const m=()=>P();return window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)},[P]);const V=(m,e)=>{const l=f.current;if(!l)return null;const d=l.getBoundingClientRect(),{x:i,y:o,scale:a}=E.current,h=(m-d.left-i)/a,g=(e-d.top-o)/a;for(let N=w.boxes.length-1;N>=0;N--){const S=w.boxes[N];if(h>=S.x&&h<=S.x+S.w&&g>=S.y&&g<=S.y+S.h)return S}return null},T=m=>{b.current={active:!0,moved:!1,startX:m.clientX,startY:m.clientY,origX:E.current.x,origY:E.current.y}},v=m=>{if(b.current.active){const d=m.clientX-b.current.startX,i=m.clientY-b.current.startY;(Math.abs(d)>3||Math.abs(i)>3)&&(b.current.moved=!0),E.current.x=b.current.origX+d,E.current.y=b.current.origY+i,P();return}const e=V(m.clientX,m.clientY),l=e?e.node.id:null;j((e==null?void 0:e.data.type)==="route"),l!==x.current&&(x.current=l,P())},p=m=>{const e=b.current.moved;if(b.current.active=!1,!e){const l=V(m.clientX,m.clientY);(l==null?void 0:l.data.type)==="route"?s(l.data):s(null)}},c=m=>{m.preventDefault();const e=f.current;if(!e)return;const l=e.getBoundingClientRect(),d=m.clientX-l.left,i=m.clientY-l.top,o=E.current,a=m.deltaY<0?1.12:.89,h=Math.max(.05,Math.min(2.5,o.scale*a));E.current={scale:h,x:d-(d-o.x)*h/o.scale,y:i-(i-o.y)*h/o.scale},P()},y=m=>{const e=f.current;if(!e)return;const l=e.clientWidth,d=e.clientHeight,i=E.current,o=Math.max(.05,Math.min(2.5,i.scale*m));E.current={scale:o,x:l/2-(l/2-i.x)*o/i.scale,y:d/2-(d/2-i.y)*o/i.scale},P()};return L.jsxs("div",{className:"relative h-full w-full",children:[L.jsx("canvas",{ref:f,onPointerDown:T,onPointerMove:v,onPointerUp:p,onPointerLeave:()=>{b.current.active=!1,x.current!==null&&(x.current=null,P())},onWheel:c,className:`h-full w-full touch-none ${A?"cursor-pointer":"cursor-grab active:cursor-grabbing"}`}),L.jsxs("div",{className:"fixed bottom-4 left-4 z-20 flex flex-col overflow-hidden rounded-xl border border-white/10 bg-zinc-950/90 shadow-xl",children:[L.jsx("button",{onClick:()=>y(1.25),title:"Zoom in",className:"p-2 text-zinc-300 hover:bg-white/10",children:L.jsx(kn,{className:"h-4 w-4"})}),L.jsx("button",{onClick:()=>y(.8),title:"Zoom out",className:"border-t border-white/10 p-2 text-zinc-300 hover:bg-white/10",children:L.jsx(Mn,{className:"h-4 w-4"})}),L.jsx("button",{onClick:q,title:"Fit view",className:"border-t border-white/10 p-2 text-zinc-300 hover:bg-white/10",children:L.jsx(Tn,{className:"h-4 w-4"})})]})]})}),sn={GET:{bg:"bg-emerald-500/15",text:"text-emerald-400",border:"border-emerald-500/35",glow:"shadow-[0_0_12px_rgba(16,185,129,0.28)]",dot:"#10b981"},POST:{bg:"bg-sky-500/15",text:"text-sky-400",border:"border-sky-500/35",glow:"shadow-[0_0_12px_rgba(56,189,248,0.28)]",dot:"#38bdf8"},PUT:{bg:"bg-amber-500/15",text:"text-amber-400",border:"border-amber-500/35",glow:"shadow-[0_0_12px_rgba(245,158,11,0.28)]",dot:"#f59e0b"},PATCH:{bg:"bg-amber-500/15",text:"text-amber-400",border:"border-amber-500/35",glow:"shadow-[0_0_12px_rgba(245,158,11,0.28)]",dot:"#f59e0b"},DELETE:{bg:"bg-rose-500/15",text:"text-rose-400",border:"border-rose-500/35",glow:"shadow-[0_0_12px_rgba(244,63,94,0.28)]",dot:"#f43f5e"},OPTIONS:{bg:"bg-zinc-500/15",text:"text-zinc-300",border:"border-zinc-500/35",glow:"",dot:"#71717a"},HEAD:{bg:"bg-zinc-500/15",text:"text-zinc-300",border:"border-zinc-500/35",glow:"",dot:"#71717a"},ALL:{bg:"bg-violet-500/15",text:"text-violet-300",border:"border-violet-500/35",glow:"",dot:"#a78bfa"}};function tr(n){return sn[(n??"GET").toUpperCase()]??sn.GET}function tt(n){return n._dimmed?"opacity-20 scale-[0.98]":"opacity-100"}const nr=X.memo(({data:n})=>{const t=n;return L.jsxs("div",{className:`w-[220px] rounded-xl border bg-zinc-950/95 px-3.5 py-2.5 transition-colors duration-150 ${t._highlighted?"border-emerald-400/70 shadow-[0_0_24px_rgba(16,185,129,0.3)]":"border-white/15 shadow-md shadow-black/50"} ${tt(t)}`,children:[L.jsxs("div",{className:"flex items-center gap-2",children:[L.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-emerald-400 shadow-[0_0_8px_#10b981]"}),L.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-emerald-400",children:"Entry"})]}),L.jsx("div",{className:"mt-1 truncate font-mono text-xs font-medium text-zinc-100",title:t.label,children:t.label}),L.jsx(Ie,{type:"source",position:Fe.Right,className:"!h-2 !w-2 !border-zinc-700 !bg-emerald-400"})]})}),sr=X.memo(({data:n})=>{const t=n;return L.jsxs("div",{className:`w-[210px] rounded-xl border bg-zinc-950/95 px-3 py-2.5 transition-colors duration-150 ${t._highlighted?"border-sky-400/70 shadow-[0_0_22px_rgba(56,189,248,0.28)]":"border-white/12 shadow-md shadow-black/40 hover:border-white/25"} ${tt(t)}`,children:[L.jsx(Ie,{type:"target",position:Fe.Left,className:"!h-2 !w-2 !border-zinc-700 !bg-zinc-400"}),L.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-sky-400/90",children:[L.jsx(Cn,{className:"h-3 w-3"}),L.jsx("span",{children:"Router"})]}),L.jsx("div",{className:"mt-1 truncate font-mono text-xs font-semibold text-zinc-100",title:t.label,children:t.label}),L.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-zinc-500",title:t.file,children:t.file}),L.jsx(Ie,{type:"source",position:Fe.Right,className:"!h-2 !w-2 !border-zinc-700 !bg-sky-400"})]})}),rr=X.memo(({data:n})=>{const t=n,r=tr(t.method),s=t.middlewares??[],u=s.slice(0,2),f=s.length-u.length;return L.jsxs("div",{className:`group w-[310px] rounded-xl border bg-zinc-950/95 px-3.5 py-2.5 transition-colors duration-150 cursor-pointer ${t._selected?"border-sky-400 ring-1 ring-sky-400/40 shadow-[0_0_28px_rgba(56,189,248,0.3)]":t._highlighted?"border-emerald-400/75 shadow-[0_0_22px_rgba(16,185,129,0.28)]":"border-white/10 shadow-md shadow-black/50 hover:border-white/25"} ${tt(t)}`,children:[L.jsx(Ie,{type:"target",position:Fe.Left,className:"!h-2 !w-2 !border-zinc-700 !bg-zinc-400"}),L.jsxs("div",{className:"flex items-center justify-between gap-2",children:[L.jsxs("div",{className:"flex items-center gap-1.5",children:[L.jsx("span",{className:`inline-flex items-center rounded-md border px-1.5 py-0.5 font-mono text-[10px] font-bold tracking-wide ${r.bg} ${r.text} ${r.border} ${r.glow}`,children:t.method??"GET"}),!!t.partial&&L.jsx("span",{className:"inline-flex items-center rounded border border-amber-500/40 bg-amber-500/10 px-1 py-0.5 font-mono text-[9px] text-amber-300",title:"Prefix may be missing (unmounted fallback)",children:"partial"})]}),L.jsx("span",{className:"truncate font-mono text-[10px] text-zinc-500",children:t.controller??"handler"})]}),L.jsx("div",{className:"mt-1.5 truncate font-mono text-xs font-medium text-zinc-100",title:t.fullPath??t.label,children:t.fullPath??t.label}),L.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1",children:[u.map(E=>L.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-violet-500/15 border border-violet-500/25 px-1.5 py-0.5 font-mono text-[9px] text-violet-300",children:[L.jsx(ut,{className:"h-2.5 w-2.5"}),E]},E)),f>0&&L.jsxs("span",{className:"rounded bg-violet-500/10 px-1.5 py-0.5 font-mono text-[9px] text-violet-400",children:["+",f]}),t.bodyFields&&t.bodyFields.length>0&&L.jsx("span",{className:"rounded bg-zinc-800/90 px-1.5 py-0.5 font-mono text-[9px] text-zinc-400",children:`{${t.bodyFields.slice(0,2).join(", ")}${t.bodyFields.length>2?"…":""}}`}),t.queryParams&&t.queryParams.length>0&&L.jsxs("span",{className:"rounded bg-zinc-800/90 px-1.5 py-0.5 font-mono text-[9px] text-zinc-400",children:["?",t.queryParams[0]]})]}),L.jsx(Ie,{type:"source",position:Fe.Right,className:"!h-2 !w-2 !border-zinc-700 !bg-zinc-400"})]})}),or=X.memo(({data:n})=>{const t=n;return L.jsxs("div",{className:`w-[170px] rounded-lg border bg-violet-950/70 px-3 py-2 transition-colors duration-150 ${t._highlighted?"border-violet-400/70 shadow-[0_0_18px_rgba(167,139,250,0.3)]":"border-violet-500/30"} ${tt(t)}`,children:[L.jsx(Ie,{type:"target",position:Fe.Left,className:"!h-1.5 !w-1.5 !border-violet-400 !bg-violet-400"}),L.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium text-violet-300",children:[L.jsx(ut,{className:"h-3 w-3 shrink-0"}),L.jsx("span",{className:"truncate font-mono",children:t.label})]})]})}),ir=X.memo(({data:n})=>{const t=n;return L.jsxs("div",{className:`w-[220px] rounded-lg border bg-cyan-950/60 px-3 py-2 transition-colors duration-150 ${t._highlighted?"border-cyan-400/70 shadow-[0_0_18px_rgba(34,211,238,0.28)]":"border-cyan-500/25"} ${tt(t)}`,children:[L.jsx(Ie,{type:"target",position:Fe.Left,className:"!h-1.5 !w-1.5 !border-cyan-400 !bg-cyan-400"}),L.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-medium text-cyan-300",children:[L.jsx(In,{className:"h-3 w-3 shrink-0"}),L.jsx("span",{className:"truncate font-mono",children:t.label})]}),L.jsxs("div",{className:"mt-0.5 flex items-center gap-1 truncate font-mono text-[9px] text-zinc-500",children:[L.jsx(Fn,{className:"h-2.5 w-2.5 shrink-0"}),L.jsxs("span",{className:"truncate",children:[t.file,":",t.line]})]})]})}),ar={entry:nr,router:sr,route:rr,middleware:or,controller:ir,model:Rn};function lr({groups:n,hiddenGroups:t,onToggleGroup:r,onShowAll:s,onIsolateGroup:u,collapsed:f,onToggleCollapse:E}){return f?L.jsxs("button",{onClick:E,title:"Expand Route Groups",className:"pointer-events-auto flex items-center gap-1.5 rounded-xl border border-white/10 bg-zinc-950/85 px-2.5 py-2 text-xs text-zinc-300 shadow-xl backdrop-blur-md hover:border-white/25",children:[L.jsx(zn,{className:"h-4 w-4"}),L.jsxs("span",{className:"font-medium",children:["Groups (",n.length,")"]})]}):L.jsxs("aside",{className:"pointer-events-auto flex max-h-[calc(100vh-110px)] w-60 flex-col rounded-2xl border border-white/10 bg-zinc-950/85 shadow-2xl shadow-black/60 backdrop-blur-md",children:[L.jsxs("div",{className:"flex items-center justify-between border-b border-white/10 px-3 py-2.5",children:[L.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-semibold text-zinc-200",children:[L.jsx(On,{className:"h-3.5 w-3.5 text-sky-400"}),L.jsx("span",{children:"Route Groups"})]}),L.jsxs("div",{className:"flex items-center gap-1",children:[t.size>0&&L.jsx("button",{onClick:s,className:"rounded px-1.5 py-0.5 text-[10px] text-sky-400 hover:bg-sky-500/10",children:"Show all"}),L.jsx("button",{onClick:E,className:"rounded p-0.5 text-zinc-400 hover:bg-white/10 hover:text-zinc-200",children:L.jsx(Dn,{className:"h-4 w-4"})})]})]}),L.jsx("div",{className:"flex-1 space-y-0.5 overflow-y-auto p-2",children:n.map(x=>{const b=t.has(x.name);return L.jsxs("div",{className:`group flex items-center justify-between rounded-lg px-2 py-1.5 text-xs transition ${b?"opacity-45":"hover:bg-white/5"}`,children:[L.jsx("button",{onClick:()=>u(x.name),title:"Click to isolate group",className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:L.jsx("span",{className:"truncate font-mono text-[11px] text-zinc-200",children:x.name})}),L.jsxs("div",{className:"flex items-center gap-1.5",children:[L.jsx("span",{className:"rounded bg-white/5 px-1.5 py-0.5 font-mono text-[10px] text-zinc-400",children:x.count}),L.jsx("button",{onClick:()=>r(x.name),title:b?"Show group":"Hide group",className:"rounded p-0.5 text-zinc-500 hover:bg-white/10 hover:text-zinc-200",children:b?L.jsx(Ln,{className:"h-3.5 w-3.5"}):L.jsx(Zn,{className:"h-3.5 w-3.5"})})]})]},x.name)})})]})}const cr=/\.(js|jsx|ts|tsx|mjs|cjs|py|go|rs|java|kt|rb|proto|graphql|gql)$/i,pr=/^(package\.json|tsconfig\.json|requirements\.txt|pyproject\.toml|go\.mod|Cargo\.toml|pom\.xml|Gemfile)$/i,ur=/(?:^|\/)(?:node_modules|dist|build|target|vendor|\.git|tests?|__tests__|spec)(?:\/|$)/i;function dr(n){const t=n.trim().replace(/\.git$/,""),r=t.match(/^https?:\/\/github\.com\/([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)/);if(r)return r[1];const s=t.match(/^([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)$/);return s?s[1]:null}async function mn(n){const t=dr(n);if(!t)throw new Error("Enter a valid GitHub URL or owner/repo slug (e.g. fastapi/fastapi).");const r=await fetch(`https://api.github.com/repos/${t}/git/trees/HEAD?recursive=1`);if(r.status===403||r.status===429)throw new Error("GitHub API rate limit reached (60 req/hr unauthenticated). Try again later or use `npx routeweb`.");if(r.status===404)throw new Error(`Repository "${t}" not found or is private.`);if(!r.ok)throw new Error(`GitHub API error (${r.status}).`);const u=((await r.json()).tree??[]).filter(b=>{if(b.type!=="blob"||(b.size??0)>25e4||ur.test(b.path))return!1;const $=b.path.split("/").pop()??"";return cr.test($)||pr.test($)}).slice(0,120),f=[],E=15;for(let b=0;b<u.length;b+=E){const $=u.slice(b,b+E),A=await Promise.all($.map(async j=>{try{const w=await fetch(`https://raw.githubusercontent.com/${t}/HEAD/${j.path}`);return w.ok?{path:j.path,content:await w.text()}:null}catch{return null}}));for(const j of A)j&&f.push(j)}const x=fn(f,{repoName:t});return{slug:t,graph:x}}const fr=new Set(["node_modules",".git","dist","build","coverage"]),mr=/\.(js|jsx|ts|tsx|mjs|cjs)$/i,hr=/^(package\.json|tsconfig\.json|\.env(\.example)?)$/i;function yr({onLoadDemo:n,onLoadScanned:t}){const r=X.useRef(null),[s,u]=X.useState(!1),[f,E]=X.useState(""),[x,b]=X.useState(null),$=async()=>{if(f.trim()){u(!0),b(null);try{const{slug:j,graph:w}=await mn(f);window.location.hash=`#gh/${j}`,t(w)}catch(j){b(j instanceof Error?j.message:String(j))}finally{u(!1)}}},A=async j=>{if(!(!j||j.length===0)){u(!0);try{const w=[];let M="local-project";for(const P of Array.from(j)){const q=P.webkitRelativePath||P.name,B=q.split("/");if(B.length>1&&(M=B[0]),B.some(p=>fr.has(p)))continue;const V=B.length>1?B.slice(1).join("/"):q,T=B[B.length-1];if(!mr.test(T)&&!hr.test(T))continue;const v=await P.text();w.push({path:V,content:v})}const D=fn(w,{repoName:M});t(D)}finally{u(!1)}}};return L.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-[#09090b]/90 p-4 backdrop-blur-md",children:L.jsxs("div",{className:"w-full max-w-lg rounded-3xl border border-white/15 bg-zinc-950/90 p-8 shadow-2xl shadow-black",children:[L.jsxs("div",{className:"flex items-center gap-3",children:[L.jsx("div",{className:"flex h-11 w-11 items-center justify-center rounded-2xl border border-white/15 bg-gradient-to-br from-emerald-500/20 to-sky-500/20",children:L.jsx(rn,{className:"h-6 w-6 text-sky-400"})}),L.jsxs("div",{children:[L.jsx("h1",{className:"text-lg font-bold tracking-tight text-zinc-100",children:"routeweb"}),L.jsx("p",{className:"text-xs text-zinc-400",children:"Zero-config Express AST mapper & interactive spider-web visualizer"})]})]}),L.jsxs("p",{className:"mt-5 text-sm leading-relaxed text-zinc-300",children:["Running in ",L.jsx("span",{className:"font-mono text-sky-400",children:"Static Web Mode"}),". Paste any public GitHub repository, drop a local folder to parse client-side, or explore the demo."]}),L.jsxs("div",{className:"mt-4 flex gap-2",children:[L.jsx("input",{type:"text",value:f,onChange:j=>E(j.target.value),onKeyDown:j=>j.key==="Enter"&&void $(),placeholder:"owner/repo or https://github.com/owner/repo",className:"flex-1 rounded-xl border border-white/15 bg-black/50 px-3 py-2 font-mono text-xs text-zinc-100 placeholder-zinc-500 focus:border-emerald-500/60 focus:outline-none"}),L.jsxs("button",{onClick:()=>void $(),disabled:s||!f.trim(),className:"flex items-center gap-1.5 rounded-xl border border-emerald-500/40 bg-emerald-500/15 px-3.5 py-2 text-xs font-semibold text-emerald-300 transition hover:bg-emerald-500/25 disabled:opacity-50",children:[L.jsx(qn,{className:"h-3.5 w-3.5"}),L.jsx("span",{children:s?"Scanning…":"Scan GitHub"})]})]}),x&&L.jsx("p",{className:"mt-2 rounded-lg border border-rose-500/30 bg-rose-500/10 px-3 py-2 text-xs text-rose-300",children:x}),L.jsxs("div",{className:"mt-6 grid grid-cols-1 gap-3 sm:grid-cols-2",children:[L.jsxs("button",{onClick:n,className:"flex items-center justify-center gap-2 rounded-xl border border-sky-500/40 bg-sky-500/15 px-4 py-3 text-sm font-semibold text-sky-300 transition hover:bg-sky-500/25",children:[L.jsx(Gn,{className:"h-4 w-4"}),L.jsx("span",{children:"Load Demo Graph"})]}),L.jsxs("button",{onClick:()=>{var j;return(j=r.current)==null?void 0:j.click()},disabled:s,className:"flex items-center justify-center gap-2 rounded-xl border border-white/15 bg-white/5 px-4 py-3 text-sm font-semibold text-zinc-100 transition hover:bg-white/10 disabled:opacity-50",children:[L.jsx(Wn,{className:"h-4 w-4 text-emerald-400"}),L.jsx("span",{children:s?"Scanning AST…":"Open Local Folder"})]}),L.jsx("input",{ref:r,type:"file",className:"hidden",webkitdirectory:"",multiple:!0,onChange:j=>void A(j.target.files)})]}),L.jsxs("div",{className:"mt-6 rounded-xl border border-white/10 bg-zinc-900/70 px-3.5 py-2.5 font-mono text-[11px] text-zinc-400",children:["$ npx routeweb . ",L.jsx("span",{className:"text-zinc-600",children:"# or --format md for AI agents"})]})]})})}const gr=["ALL","GET","POST","PUT","PATCH","DELETE"];function xr({repoName:n,routeCount:t,fileCount:r,methodFilter:s,onMethodFilterChange:u,entries:f=[],entryFilter:E="ALL",onEntryFilterChange:x,targetBaseUrl:b,onTargetBaseUrlChange:$,globalAuth:A,onGlobalAuthChange:j,layoutMode:w,onLayoutModeChange:M,middlewareMode:D,onMiddlewareModeChange:P,onOpenSearch:q,onRescan:B,onCopyMarkdown:V,isStaticMode:T,securityOnly:v=!1,onSecurityOnlyChange:p}){const[c,y]=X.useState(!1),[m,e]=X.useState(!1),[l,d]=X.useState(!1),i=()=>{V(),e(!0),setTimeout(()=>e(!1),1600)},o=async()=>{if(!(!B||l)){d(!0);try{await B()}finally{d(!1)}}};return L.jsxs("header",{className:"pointer-events-auto relative z-30 flex flex-wrap items-center justify-between gap-2 rounded-2xl border border-white/10 bg-zinc-950/85 px-3 py-2 shadow-2xl shadow-black/60 backdrop-blur-md",children:[L.jsxs("div",{className:"flex items-center gap-2.5",children:[L.jsx("div",{className:"flex h-7 w-7 items-center justify-center rounded-lg bg-gradient-to-br from-emerald-500/20 to-sky-500/20 border border-white/10",children:L.jsx(rn,{className:"h-4 w-4 text-sky-400"})}),L.jsx("div",{children:L.jsxs("div",{className:"flex items-center gap-2",children:[L.jsx("span",{className:"text-xs font-semibold tracking-tight text-zinc-100",children:n}),L.jsxs("span",{className:"rounded-full bg-white/5 border border-white/10 px-2 py-0.5 font-mono text-[10px] text-zinc-400",children:[t," routes · ",r," files"]}),f.length>1&&x&&L.jsxs("select",{value:E,onChange:a=>x(a.target.value),title:"Filter by Express entry point",className:"max-w-[175px] truncate rounded-lg border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 font-mono text-[10px] text-emerald-300 outline-none hover:border-emerald-400/50",children:[L.jsxs("option",{value:"ALL",className:"bg-zinc-950 text-zinc-200",children:["All entries (",f.length,")"]}),f.map(a=>L.jsx("option",{value:a.id,className:"bg-zinc-950 text-zinc-200",children:a.label},a.id))]})]})})]}),L.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[L.jsxs("button",{onClick:q,className:"flex items-center gap-2 rounded-lg border border-white/10 bg-white/5 px-2.5 py-1 text-xs text-zinc-400 transition hover:border-white/20 hover:text-zinc-200",children:[L.jsx(Hn,{className:"h-3.5 w-3.5"}),L.jsx("span",{className:"hidden sm:inline",children:"Search"}),L.jsx("kbd",{className:"rounded bg-zinc-900 px-1 py-0.5 font-mono text-[10px] text-zinc-500",children:"⌘K"})]}),L.jsx("div",{className:"flex items-center rounded-lg border border-white/10 bg-zinc-900/70 p-0.5",children:gr.map(a=>L.jsx("button",{onClick:()=>u(a),className:`rounded-md px-2 py-0.5 font-mono text-[10px] font-semibold transition ${s===a?"bg-white/15 text-zinc-100 shadow-sm":"text-zinc-500 hover:text-zinc-300"}`,children:a},a))}),p&&L.jsxs("button",{onClick:()=>p(!v),title:"Heuristic: show only POST/PUT/PATCH/DELETE routes without detected auth middleware",className:`flex items-center gap-1 rounded-lg border px-2 py-1 font-mono text-[10px] font-semibold transition ${v?"border-amber-500/50 bg-amber-500/15 text-amber-300":"border-white/10 bg-white/5 text-zinc-400 hover:border-white/20 hover:text-zinc-200"}`,children:[L.jsx(ut,{className:"h-3 w-3"}),L.jsx("span",{children:"Unprotected"})]})]}),L.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[L.jsx("input",{type:"text",value:b,onChange:a=>$(a.target.value),placeholder:"http://localhost:3000",title:"Target Base URL",className:"w-40 rounded-lg border border-white/10 bg-zinc-900/80 px-2.5 py-1 font-mono text-[11px] text-zinc-200 outline-none focus:border-sky-500/60"}),L.jsxs("div",{className:"relative",children:[L.jsxs("button",{onClick:()=>y(a=>!a),className:`flex items-center gap-1.5 rounded-lg border px-2.5 py-1 text-xs transition ${A?"border-emerald-500/40 bg-emerald-500/15 text-emerald-300":"border-white/10 bg-white/5 text-zinc-300 hover:border-white/20"}`,children:[L.jsx(Bn,{className:"h-3.5 w-3.5"}),L.jsx("span",{className:"hidden md:inline",children:A?"Auth Set":"Auth"})]}),c&&L.jsxs("div",{className:"absolute right-0 top-full mt-2 w-72 rounded-xl border border-white/15 bg-zinc-950/95 p-3 shadow-2xl backdrop-blur-md",children:[L.jsx("div",{className:"text-xs font-semibold text-zinc-200",children:"Global Authorization Header"}),L.jsx("p",{className:"mt-0.5 text-[11px] text-zinc-500",children:"Paste a JWT token (auto-prefixed with Bearer) or full header like Basic ..."}),L.jsx("input",{type:"text",value:A,onChange:a=>j(a.target.value),placeholder:"Paste token or Bearer <token>",className:"mt-2 w-full rounded-lg border border-white/10 bg-zinc-900 px-2.5 py-1.5 font-mono text-[11px] text-zinc-100 outline-none focus:border-sky-500/60"}),L.jsxs("div",{className:"mt-2 flex justify-end gap-1.5",children:[A&&L.jsx("button",{onClick:()=>j(""),className:"rounded-md px-2 py-1 text-[11px] text-rose-400 hover:bg-rose-500/10",children:"Clear"}),L.jsx("button",{onClick:()=>y(!1),className:"rounded-md bg-white/10 px-2.5 py-1 text-[11px] font-medium text-zinc-100 hover:bg-white/15",children:"Done"})]})]})]}),L.jsxs("div",{className:"flex items-center rounded-lg border border-white/10 bg-zinc-900/70 p-0.5",children:[L.jsxs("button",{onClick:()=>M("flow"),title:"Left-to-Right Flow",className:`flex items-center gap-1 rounded-md px-2 py-0.5 text-[11px] transition ${w==="flow"?"bg-white/15 text-zinc-100":"text-zinc-500 hover:text-zinc-300"}`,children:[L.jsx(Un,{className:"h-3 w-3"}),L.jsx("span",{className:"hidden lg:inline",children:"Flow"})]}),L.jsxs("button",{onClick:()=>M("radial"),title:"Clustered Spider Web",className:`flex items-center gap-1 rounded-md px-2 py-0.5 text-[11px] transition ${w==="radial"?"bg-white/15 text-zinc-100":"text-zinc-500 hover:text-zinc-300"}`,children:[L.jsx(Vn,{className:"h-3 w-3"}),L.jsx("span",{className:"hidden lg:inline",children:"Web"})]})]}),L.jsxs("button",{onClick:()=>P(D==="badges"?"nodes":"badges"),title:"Toggle Middleware & Controller Nodes",className:`flex items-center gap-1 rounded-lg border px-2 py-1 text-[11px] transition ${D==="nodes"?"border-violet-500/40 bg-violet-500/15 text-violet-300":"border-white/10 bg-white/5 text-zinc-400 hover:text-zinc-200"}`,children:[L.jsx(ut,{className:"h-3.5 w-3.5"}),L.jsx("span",{className:"hidden xl:inline",children:D==="nodes"?"Nodes":"Badges"})]}),!T&&B&&L.jsx("button",{onClick:o,disabled:l,title:"Rescan repository",className:"flex items-center gap-1 rounded-lg border border-white/10 bg-white/5 px-2.5 py-1 text-xs text-zinc-300 transition hover:border-white/20 hover:text-zinc-100 disabled:opacity-50",children:L.jsx(Kn,{className:`h-3.5 w-3.5 ${l?"animate-spin":""}`})}),L.jsxs("button",{onClick:i,title:"Copy Markdown API Map for AI Agents",className:"flex items-center gap-1.5 rounded-lg border border-sky-500/30 bg-sky-500/15 px-2.5 py-1 text-xs font-medium text-sky-300 transition hover:bg-sky-500/25",children:[m?L.jsx(Jn,{className:"h-3.5 w-3.5"}):L.jsx(Yn,{className:"h-3.5 w-3.5"}),L.jsx("span",{className:"hidden sm:inline",children:m?"Copied!":"Copy MD"})]})]})]})}const br={version:"1.0",metadata:{repoName:"sample-express (demo)",framework:"express",detectedPort:3001,scannedFiles:10,scanDurationMs:14.2,unresolvedMounts:[]},nodes:[{id:"entry:src/index.js",type:"entry",label:"src/index.js",file:"src/index.js",line:1},{id:"router:src/routes/v1/index.js:/api/v1",type:"router",label:"/api/v1",file:"src/routes/v1/index.js",line:1},{id:"router:src/routes/v1/auth.js:/api/v1/auth",type:"router",label:"/api/v1/auth",file:"src/routes/v1/auth.js",line:1},{id:"router:src/routes/v1/users.js:/api/v1/users",type:"router",label:"/api/v1/users",file:"src/routes/v1/users.js",line:1},{id:"router:src/routes/v1/tasks.js:/api/v1/tasks",type:"router",label:"/api/v1/tasks",file:"src/routes/v1/tasks.js",line:1},{id:"route:GET:/health",type:"route",label:"GET /health",file:"src/index.js",line:7,method:"GET",fullPath:"/health",pathParams:[],queryParams:[],bodyFields:[],group:"/health",middlewares:[],controller:"inlineHandler",controllerFile:"src/index.js",controllerLine:7},{id:"route:POST:/api/v1/auth/login",type:"route",label:"POST /api/v1/auth/login",file:"src/routes/v1/auth.js",line:7,method:"POST",fullPath:"/api/v1/auth/login",pathParams:[],queryParams:[],bodyFields:["email","password"],group:"/api/v1/auth",middlewares:["validateBody"],controller:"authController.login",controllerFile:"src/controllers/auth.js",controllerLine:3},{id:"route:POST:/api/v1/auth/register",type:"route",label:"POST /api/v1/auth/register",file:"src/routes/v1/auth.js",line:8,method:"POST",fullPath:"/api/v1/auth/register",pathParams:[],queryParams:[],bodyFields:["name","email","password"],group:"/api/v1/auth",middlewares:["validateBody"],controller:"authController.register",controllerFile:"src/controllers/auth.js",controllerLine:15},{id:"route:GET:/api/v1/users",type:"route",label:"GET /api/v1/users",file:"src/routes/v1/users.js",line:7,method:"GET",fullPath:"/api/v1/users",pathParams:[],queryParams:["role","limit"],bodyFields:[],group:"/api/v1/users",middlewares:["verifyJWT"],controller:"userController.listUsers",controllerFile:"src/controllers/users.js",controllerLine:3},{id:"route:GET:/api/v1/users/:id",type:"route",label:"GET /api/v1/users/:id",file:"src/routes/v1/users.js",line:8,method:"GET",fullPath:"/api/v1/users/:id",pathParams:["id"],queryParams:[],bodyFields:[],group:"/api/v1/users",middlewares:["verifyJWT"],controller:"userController.getUser",controllerFile:"src/controllers/users.js",controllerLine:15},{id:"route:GET:/api/v1/tasks",type:"route",label:"GET /api/v1/tasks",file:"src/routes/v1/tasks.js",line:7,method:"GET",fullPath:"/api/v1/tasks",pathParams:[],queryParams:["status","priority"],bodyFields:[],group:"/api/v1/tasks",middlewares:["verifyJWT"],controller:"taskController.listTasks",controllerFile:"src/controllers/tasks.js",controllerLine:3},{id:"route:POST:/api/v1/tasks",type:"route",label:"POST /api/v1/tasks",file:"src/routes/v1/tasks.js",line:9,method:"POST",fullPath:"/api/v1/tasks",pathParams:[],queryParams:[],bodyFields:["title","priority","assigneeId"],group:"/api/v1/tasks",middlewares:["verifyJWT","validateBody"],controller:"taskController.createTask",controllerFile:"src/controllers/tasks.js",controllerLine:11},{id:"mw:verifyJWT",type:"middleware",label:"verifyJWT",file:"src/middleware/auth.js",line:1},{id:"mw:validateBody",type:"middleware",label:"validateBody",file:"src/middleware/auth.js",line:15}],edges:[{id:"e1",source:"entry:src/index.js",target:"route:GET:/health",type:"handles"},{id:"e2",source:"entry:src/index.js",target:"router:src/routes/v1/index.js:/api/v1",type:"mounts"},{id:"e3",source:"router:src/routes/v1/index.js:/api/v1",target:"router:src/routes/v1/auth.js:/api/v1/auth",type:"mounts"},{id:"e4",source:"router:src/routes/v1/index.js:/api/v1",target:"router:src/routes/v1/users.js:/api/v1/users",type:"mounts"},{id:"e5",source:"router:src/routes/v1/index.js:/api/v1",target:"router:src/routes/v1/tasks.js:/api/v1/tasks",type:"mounts"},{id:"e6",source:"router:src/routes/v1/auth.js:/api/v1/auth",target:"route:POST:/api/v1/auth/login",type:"handles"},{id:"e7",source:"router:src/routes/v1/auth.js:/api/v1/auth",target:"route:POST:/api/v1/auth/register",type:"handles"},{id:"e8",source:"router:src/routes/v1/users.js:/api/v1/users",target:"route:GET:/api/v1/users",type:"handles"},{id:"e9",source:"router:src/routes/v1/users.js:/api/v1/users",target:"route:GET:/api/v1/users/:id",type:"handles"},{id:"e10",source:"router:src/routes/v1/tasks.js:/api/v1/tasks",target:"route:GET:/api/v1/tasks",type:"handles"},{id:"e11",source:"router:src/routes/v1/tasks.js:/api/v1/tasks",target:"route:POST:/api/v1/tasks",type:"handles"},{id:"e12",source:"route:GET:/api/v1/users",target:"mw:verifyJWT",type:"uses"},{id:"e13",source:"route:GET:/api/v1/users/:id",target:"mw:verifyJWT",type:"uses"},{id:"e14",source:"route:GET:/api/v1/tasks",target:"mw:verifyJWT",type:"uses"},{id:"e15",source:"route:POST:/api/v1/tasks",target:"mw:verifyJWT",type:"uses"},{id:"e16",source:"route:POST:/api/v1/auth/login",target:"mw:validateBody",type:"uses"},{id:"e17",source:"route:POST:/api/v1/auth/register",target:"mw:validateBody",type:"uses"},{id:"e18",source:"route:POST:/api/v1/tasks",target:"mw:validateBody",type:"uses"}]},wr=X.lazy(()=>on(()=>import("./SearchModal-B0C7wJfG.js"),__vite__mapDeps([0,1,2,3])).then(n=>({default:n.SearchModal}))),vr=X.lazy(()=>on(()=>import("./TesterDrawer-7pr3VKRs.js"),__vite__mapDeps([4,1,2,3])).then(n=>({default:n.TesterDrawer}))),Er=80;function $r(){const{fitView:n,setCenter:t}=vn(),r=X.useRef(null),s=X.useRef(null),u=X.useRef(0),[f,E]=X.useState(null),[x,b]=X.useState(!1),[$,A]=X.useState(!1),[j,w]=X.useState("http://localhost:3000"),[M,D]=X.useState(""),[P,q]=X.useState("ALL"),[B,V]=X.useState(!1),[T,v]=X.useState("ALL"),[p,c]=X.useState(new Set),[y,m]=X.useState("flow"),[e,l]=X.useState("badges"),[d,i]=X.useState(!1),[o,a]=X.useState(!1),[h,g]=X.useState(null),[N,S]=X.useState(null),[R,O,z]=En([]),[G,W,H]=$n([]);X.useEffect(()=>{let Y=!1;async function se(){try{const ee=await fetch("/api/graph"),ce=ee.headers.get("content-type")??"";if(!ee.ok||!ce.includes("application/json"))throw new Error("Static mode");const pe=await ee.json();if(Y)return;E(pe),c(new Set),b(!1),A(!1),pe.metadata.detectedPort&&w(`http://localhost:${pe.metadata.detectedPort}`);try{const Pe=await fetch("/api/config");if(Pe.ok){const xe=await Pe.json();xe.targetBaseUrl&&!Y&&w(xe.targetBaseUrl)}}catch{}}catch{if(!Y){b(!0);const ee=window.location.hash;if(ee.startsWith("#gh/")){const ce=ee.slice(4);try{const pe=await mn(ce);if(!Y){E(pe.graph),A(!1);return}}catch{}}A(!0)}}}return se(),()=>{Y=!0}},[]),X.useEffect(()=>{const Y=se=>{(se.metaKey||se.ctrlKey)&&se.key.toLowerCase()==="k"&&(se.preventDefault(),a(ee=>!ee))};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[]);const _=X.useMemo(()=>f?f.nodes.filter(Y=>Y.type==="entry").map(Y=>({id:Y.id,label:Y.label})):[],[f]),C=X.useMemo(()=>f?f.nodes.filter(Y=>Y.type==="route"):[],[f]),F=X.useMemo(()=>{const Y=new Map;for(const se of C){const ee=se.group??"/";Y.set(ee,(Y.get(ee)??0)+1)}return Array.from(Y.entries()).sort((se,ee)=>se[0].localeCompare(ee[0])).map(([se,ee])=>({name:se,count:ee}))},[C]),[k,I]=X.useState({nodes:[],edges:[]});X.useEffect(()=>{const Y=new Worker(new URL("/assets/layout.worker-BZLKpmFA.js",import.meta.url),{type:"module"});return s.current=Y,Y.onmessage=se=>{se.data.id===u.current&&I({nodes:se.data.nodes,edges:se.data.edges})},()=>{Y.terminate(),s.current=null}},[]),X.useEffect(()=>{var ee;if(!f){I({nodes:[],edges:[]});return}let Y=f;if(B){const ce=new Set(["POST","PUT","PATCH","DELETE"]),pe=new Set,Pe=f.nodes.filter(xe=>{if(xe.type!=="route")return pe.add(xe.id),!0;const hn=(xe.method??"GET").toUpperCase();return ce.has(hn)?(xe.middlewares??[]).map(mt=>mt.toLowerCase()).some(mt=>ss.some(yn=>mt.includes(yn)))?!1:(pe.add(xe.id),!0):!1});Y={...f,nodes:Pe,edges:f.edges.filter(xe=>pe.has(xe.source)&&pe.has(xe.target))}}const se=++u.current;(ee=s.current)==null||ee.postMessage({id:se,graph:Y,layoutMode:y,middlewareMode:e,methodFilter:P,entryFilter:T,hiddenGroups:Array.from(p),searchQuery:""})},[f,B,y,e,P,T,p]);const Z=k.nodes.length>Er,U=N??(h==null?void 0:h.id)??null;X.useEffect(()=>{if(Z)return;if(k.nodes.length===0){O([]),W([]);return}if(!U){O(k.nodes.map(ee=>({...ee,data:{...ee.data,_dimmed:!1,_highlighted:!1,_selected:(h==null?void 0:h.id)===ee.id}}))),W(k.edges);return}const{nodeIds:Y,edgeIds:se}=Qs(U,k.edges);O(k.nodes.map(ee=>({...ee,data:{...ee.data,_dimmed:!Y.has(ee.id),_highlighted:Y.has(ee.id),_selected:(h==null?void 0:h.id)===ee.id}}))),W(k.edges.map(ee=>{const ce=se.has(ee.id);return{...ee,animated:ce,style:{...ee.style,stroke:ce?"#10b981":"rgba(113,113,122,0.12)",strokeWidth:ce?2.2:1}}}))},[Z,k,U,h,O,W]),X.useEffect(()=>{if(!Z&&k.nodes.length>0){const Y=setTimeout(()=>{n({padding:.16,duration:350})},50);return()=>clearTimeout(Y)}},[Z,f,y,e,n,k.nodes.length]);const J=X.useCallback((Y,se)=>{const ee=se.data;ee.type==="route"&&g(ee)},[]),K=X.useCallback(Y=>{var ce;const se=Y.group??"/";p.has(se)&&c(pe=>{const Pe=new Set(pe);return Pe.delete(se),Pe}),g(Y);const ee=k.nodes.find(pe=>pe.id===Y.id);ee&&(Z?(ce=r.current)==null||ce.centerOn(ee.position.x+150,ee.position.y+45,1):t(ee.position.x+150,ee.position.y+45,{zoom:1.05,duration:400}))},[k.nodes,p,t,Z]),Q=async()=>{const Y=await fetch("/api/rescan",{method:"POST"});if(Y.ok){const se=await Y.json();E(se)}},te=()=>{f&&navigator.clipboard.writeText(ns(f))},re=Y=>{c(se=>{const ee=new Set(se);return ee.has(Y)?ee.delete(Y):ee.add(Y),ee})},ae=Y=>{c(se=>{const ee=F.map(pe=>pe.name).filter(pe=>pe!==Y);return se.size===ee.length&&!se.has(Y)?new Set:new Set(ee)})};return L.jsxs("div",{className:"relative h-screen w-screen overflow-hidden bg-[#09090b]",children:[Z?L.jsx(er,{ref:r,nodes:k.nodes,edges:k.edges,selectedRouteId:(h==null?void 0:h.id)??null,onSelectRoute:g}):L.jsxs(jn,{nodes:R,edges:G,onNodesChange:z,onEdgesChange:H,onNodeClick:J,onNodeMouseEnter:(Y,se)=>S(se.id),onNodeMouseLeave:()=>S(null),onPaneClick:()=>g(null),nodeTypes:ar,onlyRenderVisibleElements:!0,minZoom:.1,maxZoom:2,proOptions:{hideAttribution:!0},children:[L.jsx(Sn,{variant:An.Dots,gap:22,size:1.2,color:"#1c1c22"}),L.jsx(Pn,{position:"bottom-left"}),L.jsx(_n,{position:"bottom-right",nodeColor:Y=>Y.type==="entry"?"#10b981":Y.type==="router"?"#38bdf8":Y.type==="middleware"?"#a78bfa":Y.type==="controller"?"#22d3ee":"#52525b",maskColor:"rgba(9, 9, 11, 0.72)"})]}),f&&L.jsx("div",{className:"pointer-events-none fixed inset-x-3 top-3 z-30",children:L.jsx(xr,{repoName:f.metadata.repoName,routeCount:C.length,fileCount:f.metadata.scannedFiles,methodFilter:P,onMethodFilterChange:q,entries:_,entryFilter:T,onEntryFilterChange:v,targetBaseUrl:j,onTargetBaseUrlChange:w,globalAuth:M,onGlobalAuthChange:D,layoutMode:y,onLayoutModeChange:m,middlewareMode:e,onMiddlewareModeChange:l,onOpenSearch:()=>a(!0),onRescan:x?void 0:Q,onCopyMarkdown:te,isStaticMode:x,securityOnly:B,onSecurityOnlyChange:V})}),f&&F.length>0&&L.jsx("div",{className:"pointer-events-none fixed left-3 top-18 z-20",children:L.jsx(lr,{groups:F,hiddenGroups:p,onToggleGroup:re,onShowAll:()=>c(new Set),onIsolateGroup:ae,collapsed:d,onToggleCollapse:()=>i(Y=>!Y)})}),L.jsx(X.Suspense,{fallback:null,children:h&&L.jsx(vr,{route:h,targetBaseUrl:j,globalAuth:M,isStaticMode:x,onClose:()=>g(null)})}),L.jsx(X.Suspense,{fallback:null,children:o&&L.jsx(wr,{open:o,routes:C,onClose:()=>a(!1),onSelectRoute:K})}),$&&L.jsx(yr,{onLoadDemo:()=>{E(br),w("http://localhost:3001"),A(!1)},onLoadScanned:Y=>{E(Y),c(new Set),Y.metadata.detectedPort&&w(`http://localhost:${Y.metadata.detectedPort}`),A(!1)}})]})}function jr(){return L.jsx(wn,{children:L.jsx($r,{})})}bn.createRoot(document.getElementById("root")).render(L.jsx(X.StrictMode,{children:L.jsx(jr,{})}));export{tr as g};
|