"use strict";(()=>{var e={};e.id=9532,e.ids=[9532],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")},86868:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>g,patchFetch:()=>j,requestAsyncStorage:()=>x,routeModule:()=>l,serverHooks:()=>f,staticGenerationAsyncStorage:()=>h});var o={};t.r(o),t.d(o,{GET:()=>d,POST:()=>c});var s=t(49303),n=t(88716),i=t(60670),a=t(87070),u=t(94925),p=t(30721);let m=(0,t(43895).h)("api/memos");async function d(e,{params:r}){try{let e=(0,u.getDbInstance)();if(!(0,p.gU)(e,r.id))return a.NextResponse.json({error:`Worktree '${r.id}' not found`},{status:404});let t=(0,p.Db)(e,r.id);return a.NextResponse.json({memos:t},{status:200})}catch(e){return m.error("error-fetching-memos:",{error:e instanceof Error?e.message:String(e)}),a.NextResponse.json({error:"Failed to fetch memos"},{status:500})}}async function c(e,{params:r}){try{let t;let o=(0,u.getDbInstance)();if(!(0,p.gU)(o,r.id))return a.NextResponse.json({error:`Worktree '${r.id}' not found`},{status:404});let{title:s,content:n,position:i}=await e.json().catch(()=>({}));if(void 0!==s&&s.length>100)return a.NextResponse.json({error:"title must be 100 characters or less"},{status:400});if(void 0!==n&&n.length>1e4)return a.NextResponse.json({error:"content must be 10000 characters or less"},{status:400});let m=(0,p.Db)(o,r.id);if(m.length>=5)return a.NextResponse.json({error:"Maximum memo limit (5) reached"},{status:400});if(void 0!==i&&"number"==typeof i)t=i;else{let e=new Set(m.map(e=>e.position));for(t=0;e.has(t)&&t<5;)t++}let d=(0,p.dD)(o,r.id,{title:s,content:n,position:t});return a.NextResponse.json({memo:d},{status:201})}catch(e){return m.error("error-creating-memo:",{error:e instanceof Error?e.message:String(e)}),a.NextResponse.json({error:"Failed to create memo"},{status:500})}}let l=new s.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/worktrees/[id]/memos/route",pathname:"/api/worktrees/[id]/memos",filename:"route",bundlePath:"app/api/worktrees/[id]/memos/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/worktrees/[id]/memos/route.ts",nextConfigOutput:"",userland:o}),{requestAsyncStorage:x,staticGenerationAsyncStorage:h,serverHooks:f}=l,g="/api/worktrees/[id]/memos/route";function j(){return(0,i.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:h})}}};var r=require("../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),o=r.X(0,[8948,5972,3895,4925,721],()=>t(86868));module.exports=o})();