"use strict";(()=>{var e={};e.id=4552,e.ids=[4552],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")},19801:e=>{e.exports=require("os")},55315:e=>{e.exports=require("path")},68360:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>f,patchFetch:()=>h,requestAsyncStorage:()=>c,routeModule:()=>l,serverHooks:()=>x,staticGenerationAsyncStorage:()=>g});var s={};r.r(s),r.d(s,{GET:()=>m});var o=r(49303),n=r(88716),a=r(60670),i=r(87070),u=r(97425),p=r(75748),d=r(83513);async function m(e,{params:t}){try{let r=(0,u.getDbInstance)();if(!(0,p.gU)(r,t.id))return i.NextResponse.json({error:`Worktree '${t.id}' not found`},{status:404});let{searchParams:s}=new URL(e.url),o=s.get("before"),n=s.get("limit"),a=s.get("cliTool"),m=o?new Date(o):void 0,l=n?parseInt(n,10):50;if(a&&!d.tK.includes(a))return i.NextResponse.json({error:`Invalid cliTool parameter (must be one of: ${d.tK.join(", ")})`},{status:400});if(isNaN(l)||l<1||l>100)return i.NextResponse.json({error:"Invalid limit parameter (must be 1-100)"},{status:400});let c=[...(0,p._U)(r,t.id,m,l,a).filter(e=>e.content&&""!==e.content.trim())].sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime());return i.NextResponse.json(c,{status:200})}catch(e){return console.error("Error fetching messages:",e),i.NextResponse.json({error:"Failed to fetch messages"},{status:500})}}let l=new o.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/worktrees/[id]/messages/route",pathname:"/api/worktrees/[id]/messages",filename:"route",bundlePath:"app/api/worktrees/[id]/messages/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/worktrees/[id]/messages/route.ts",nextConfigOutput:"",userland:s}),{requestAsyncStorage:c,staticGenerationAsyncStorage:g,serverHooks:x}=l,f="/api/worktrees/[id]/messages/route";function h(){return(0,a.patchFetch)({serverHooks:x,staticGenerationAsyncStorage:g})}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[8948,5972,7425],()=>r(68360));module.exports=s})();