"use strict";(()=>{var e={};e.id=5695,e.ids=[5695],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")},78893:e=>{e.exports=require("buffer")},61282:e=>{e.exports=require("child_process")},84770:e=>{e.exports=require("crypto")},17702:e=>{e.exports=require("events")},92048:e=>{e.exports=require("fs")},20629:e=>{e.exports=require("fs/promises")},32615:e=>{e.exports=require("http")},35240:e=>{e.exports=require("https")},98216:e=>{e.exports=require("net")},19801:e=>{e.exports=require("os")},55315:e=>{e.exports=require("path")},76162:e=>{e.exports=require("stream")},82452:e=>{e.exports=require("tls")},17360:e=>{e.exports=require("url")},21764:e=>{e.exports=require("util")},71568:e=>{e.exports=require("zlib")},80134:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>w,patchFetch:()=>N,requestAsyncStorage:()=>j,routeModule:()=>h,serverHooks:()=>R,staticGenerationAsyncStorage:()=>I});var o={};t.r(o),t.d(o,{GET:()=>v,POST:()=>y});var s=t(49303),n=t(88716),i=t(60670),a=t(87070),u=t(94925),l=t(30721),d=t(50550),p=t(46155),c=t(83513),x=t(87946);let f=(0,t(43895).h)("api/auto-yes"),b=c.tK;function m(e,r){let t={enabled:e?.enabled??!1,expiresAt:e?.enabled?e.expiresAt:null};return void 0!==r&&(t.pollingStarted=r),t}function q(e){let r=(0,u.getDbInstance)();return(0,l.gU)(r,e)?null:a.NextResponse.json({error:`Worktree '${e}' not found`},{status:404})}function g(e){return!!e&&b.includes(e)}async function v(e,{params:r}){try{if(!(0,p.m$)(r.id))return a.NextResponse.json({error:"Invalid worktree ID format"},{status:400});let t=q(r.id);if(t)return t;let o=new URL(e.url).searchParams.get("cliToolId");if(o){if(!g(o))return a.NextResponse.json({error:"Invalid cliToolId"},{status:400});let e=(0,d.bq)(r.id,o);return a.NextResponse.json(m(e))}let s=(0,d.TI)(r.id),n={};for(let e of s){let t=(0,d.Z7)(e);if(!t)continue;let o=(0,d.bq)(r.id,t);n[t]=m(o)}let i=(0,d.bq)(r.id,"claude");return a.NextResponse.json({...m(i),agents:n})}catch(e){return f.error("error-getting-auto-yes-state:",{error:e instanceof Error?e.message:String(e)}),a.NextResponse.json({error:"Failed to get auto-yes state"},{status:500})}}async function y(e,{params:r}){try{let t,o,s;if(!(0,p.m$)(r.id))return a.NextResponse.json({error:"Invalid worktree ID format"},{status:400});let n=q(r.id);if(n)return n;try{t=await e.json()}catch{return a.NextResponse.json({error:"Invalid JSON body"},{status:400})}if("boolean"!=typeof t.enabled)return a.NextResponse.json({error:"enabled must be a boolean"},{status:400});let i=x.Ad;if(t.enabled&&void 0!==t.duration){if(!(0,x.l1)(t.duration))return a.NextResponse.json({error:"Invalid duration value. Allowed values: 3600000, 10800000, 28800000"},{status:400});i=t.duration}if(t.enabled&&void 0!==t.stopPattern){let e="string"==typeof t.stopPattern?t.stopPattern.trim():"";if(e){let r=(0,x.go)(e);if(!r.valid)return a.NextResponse.json({error:r.error},{status:400});o=e}}if(void 0!==t.cliToolId&&!g(t.cliToolId))return a.NextResponse.json({error:"Invalid cliToolId"},{status:400});let u=t.cliToolId??"claude",l=!1;if(t.enabled){s=(0,d.bY)(r.id,u,!0,i,o);let e=(0,d.w)(r.id,u);l=e.started,e.started||f.warn("polling-not-started:")}else if(t.cliToolId){s=(0,d.bY)(r.id,u,!1);let e=(0,d.Kk)(r.id,u);(0,d.Qz)(e)}else{for(let e of(0,d.TI)(r.id)){let t=(0,d.Z7)(e);t&&(0,d.bY)(r.id,t,!1)}(0,d._1)(r.id),s={enabled:!1,enabledAt:0,expiresAt:0}}return a.NextResponse.json(m(s,l))}catch(e){return f.error("error-setting-auto-yes-state:",{error:e instanceof Error?e.message:String(e)}),a.NextResponse.json({error:"Failed to set auto-yes state"},{status:500})}}let h=new s.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/worktrees/[id]/auto-yes/route",pathname:"/api/worktrees/[id]/auto-yes",filename:"route",bundlePath:"app/api/worktrees/[id]/auto-yes/route"},resolvedPagePath:"/home/runner/work/CommandMate/CommandMate/src/app/api/worktrees/[id]/auto-yes/route.ts",nextConfigOutput:"",userland:o}),{requestAsyncStorage:j,staticGenerationAsyncStorage:I,serverHooks:R}=h,w="/api/worktrees/[id]/auto-yes/route";function N(){return(0,i.patchFetch)({serverHooks:R,staticGenerationAsyncStorage:I})}}};var r=require("../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),o=r.X(0,[8948,5972,3853,4893,2509,3895,4925,721,9228,550],()=>t(80134));module.exports=o})();