"use strict";(()=>{var e={};e.id=6392,e.ids=[6392],e.modules={85890:e=>{e.exports=require("better-sqlite3")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},84770:e=>{e.exports=require("crypto")},92048:e=>{e.exports=require("fs")},20629:e=>{e.exports=require("fs/promises")},19801:e=>{e.exports=require("os")},55315:e=>{e.exports=require("path")},36658:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>x,patchFetch:()=>w,requestAsyncStorage:()=>h,routeModule:()=>f,serverHooks:()=>y,staticGenerationAsyncStorage:()=>m});var o={};r.r(o),r.d(o,{GET:()=>p});var i=r(49303),n=r(88716),s=r(60670),a=r(87070),u=r(94925),d=r(30721),c=r(18163);let l=(0,r(43895).h)("api/tree");async function p(e,{params:t}){try{let e=(0,u.getDbInstance)(),r=(0,d.gU)(e,t.id);if(!r){let e=(0,c.dq)(t.id);return a.NextResponse.json({error:e.error},{status:e.status})}let o=await (0,c.Lu)(r.path);return a.NextResponse.json(o)}catch(t){l.error("error-reading-directory:",{error:t instanceof Error?t.message:String(t)});let e=(0,c.GT)(t);return a.NextResponse.json({error:e.error},{status:e.status})}}let f=new i.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/worktrees/[id]/tree/route",pathname:"/api/worktrees/[id]/tree",filename:"route",bundlePath:"app/api/worktrees/[id]/tree/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/worktrees/[id]/tree/route.ts",nextConfigOutput:"",userland:o}),{requestAsyncStorage:h,staticGenerationAsyncStorage:m,serverHooks:y}=f,x="/api/worktrees/[id]/tree/route";function w(){return(0,s.patchFetch)({serverHooks:y,staticGenerationAsyncStorage:m})}},18163:(e,t,r)=>{r.d(t,{GT:()=>c,Lu:()=>d,W:()=>p,bB:()=>s,bS:()=>a,dq:()=>l});var o=r(20629),i=r(55315);let n=[".git",".env",".env.*","node_modules",".DS_Store","Thumbs.db","*.pem","*.key",".env.local",".env.development",".env.production",".env.test"],s={MAX_ITEMS_PER_DIR:500,MAX_DEPTH:10,MAX_FILE_SIZE_PREVIEW:1048576};function a(e){for(let t of n){if(t===e)return!0;if(t.startsWith("*.")){let r=t.slice(1);if(e.endsWith(r))return!0}if(t.endsWith(".*")){let r=t.slice(0,-2);if(e.startsWith(r+"."))return!0}}return!1}async function u(e){try{return(await (0,o.readdir)(e)).filter(e=>!a(e)).length}catch{return 0}}async function d(e,t=""){let r;let n=t?(0,i.join)(e,t):e;try{r=await (0,o.stat)(n)}catch{throw Error(`Directory not found: ${t||"(root)"}`)}if(!r.isDirectory())throw Error(`Path is not a directory: ${t}`);let d=await (0,o.readdir)(n),c=[];for(let e of d){if(a(e))continue;let t=(0,i.join)(n,e);try{let r=await (0,o.lstat)(t);if(r.isSymbolicLink())continue;if(r.isDirectory()){let r=await u(t);c.push({name:e,type:"directory",itemCount:r})}else if(r.isFile()){let t=(0,i.extname)(e),o={name:e,type:"file",size:r.size,birthtime:r.birthtime.toISOString()};t&&t.length>1&&(o.extension=t.slice(1)),c.push(o)}}catch{continue}if(c.length>=s.MAX_ITEMS_PER_DIR)break}let l=[...c].sort((e,t)=>e.type!==t.type?"directory"===e.type?-1:1:e.name.toLowerCase().localeCompare(t.name.toLowerCase())),p=null;if(t){let e=(0,i.dirname)(t);p="."===e?"":e}return{path:t,name:t?(0,i.basename)(t):"",items:l,parentPath:p}}function c(e){let t=e instanceof Error?e.message:"Unknown error";return t.includes("not found")?{error:"Directory not found",status:404}:t.includes("not a directory")?{error:"Path is not a directory",status:400}:{error:"Failed to read directory",status:500}}function l(e){return{error:`Worktree '${e}' not found`,status:404}}function p(e="Invalid path"){return{error:`Access denied: ${e}`,status:403}}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),o=t.X(0,[8948,5972,3895,4925,721],()=>r(36658));module.exports=o})();