module.exports=[324725,(e,r,t)=>{r.exports=e.x("next/dist/server/app-render/after-task-async-storage.external.js",()=>require("next/dist/server/app-render/after-task-async-storage.external.js"))},193695,(e,r,t)=>{r.exports=e.x("next/dist/shared/lib/no-fallback-error.external.js",()=>require("next/dist/shared/lib/no-fallback-error.external.js"))},198840,e=>{"use strict";var r=e.i(855104);let t=["localhost","127.0.0.1","[::1]"],s=new Set(["127.0.0.1","::1","::ffff:127.0.0.1"]),n=/^c[a-z0-9]{20,30}$/;e.s(["requireLocalhost",0,function(e){let n=e.headers.get("x-forwarded-for");if(n&&!n.split(",").map(e=>e.trim()).every(e=>s.has(e)))return r.NextResponse.json({error:"Forbidden"},{status:403});let i=e.headers.get("host")??"";return t.some(e=>i.startsWith(e))?null:r.NextResponse.json({error:"Forbidden"},{status:403})},"validateProjectId",0,function(e){return n.test(e)?null:r.NextResponse.json({error:"Invalid projectId format"},{status:400})},"validateTaskId",0,function(e){return n.test(e)?null:r.NextResponse.json({error:"Invalid taskId format"},{status:400})}])},933919,(e,r,t)=>{r.exports=e.x("@prisma/client-9249dd53ac5b6a44",()=>require("@prisma/client-9249dd53ac5b6a44"))},750227,(e,r,t)=>{r.exports=e.x("node:path",()=>require("node:path"))},902157,(e,r,t)=>{r.exports=e.x("node:fs",()=>require("node:fs"))},660526,(e,r,t)=>{r.exports=e.x("node:os",()=>require("node:os"))},666680,(e,r,t)=>{r.exports=e.x("node:crypto",()=>require("node:crypto"))},924868,(e,r,t)=>{r.exports=e.x("fs/promises",()=>require("fs/promises"))},918622,(e,r,t)=>{r.exports=e.x("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js",()=>require("next/dist/compiled/next-server/app-page-turbo.runtime.prod.js"))},556704,(e,r,t)=>{r.exports=e.x("next/dist/server/app-render/work-async-storage.external.js",()=>require("next/dist/server/app-render/work-async-storage.external.js"))},832319,(e,r,t)=>{r.exports=e.x("next/dist/server/app-render/work-unit-async-storage.external.js",()=>require("next/dist/server/app-render/work-unit-async-storage.external.js"))},270406,(e,r,t)=>{r.exports=e.x("next/dist/compiled/@opentelemetry/api",()=>require("next/dist/compiled/@opentelemetry/api"))},814747,(e,r,t)=>{r.exports=e.x("path",()=>require("path"))},522734,(e,r,t)=>{r.exports=e.x("fs",()=>require("fs"))},192520,e=>{"use strict";let r;var t=e.i(750227),s=e.i(660526),n=e.i(902157);function i(){return r||(r=process.env.TOWER_DATA_DIR||(0,t.join)((0,s.homedir)(),".tower"),(0,n.existsSync)(r)||(0,n.mkdirSync)(r,{recursive:!0})),r}e.s(["getAssistantDir",0,function(){let e=(0,t.join)(i(),"assistant");return(0,n.existsSync)(e)||(0,n.mkdirSync)(e,{recursive:!0}),e},"getBackupsDir",0,function(){let e=(0,t.join)(i(),"backups");return(0,n.existsSync)(e)||(0,n.mkdirSync)(e,{recursive:!0}),e},"getExtensionsDir",0,function(){let e=(0,t.join)(i(),"extensions");return(0,n.existsSync)(e)||(0,n.mkdirSync)(e,{recursive:!0}),e},"getStorageDir",0,function(){let e=process.env.TOWER_STORAGE_DIR||function(){try{let e=(0,n.readFileSync)((0,t.join)(i(),"storage-location"),"utf-8").trim();return e.length>0?e:null}catch{return null}}(),r=e&&e.length>0?e:(0,t.join)(i(),"storage");return(0,n.existsSync)(r)||(0,n.mkdirSync)(r,{recursive:!0}),r},"getTowerDbPath",0,function(){let e;return(0,t.join)((e=(0,t.join)(i(),"database"),(0,n.existsSync)(e)||(0,n.mkdirSync)(e,{recursive:!0}),e),"tower.db")},"getTowerDir",0,i])},843793,e=>{"use strict";var r=e.i(933919);let t=globalThis.prisma??new r.PrismaClient({log:[]});process.on("SIGTERM",()=>{t.$disconnect().catch(()=>{})}),process.on("SIGINT",()=>{t.$disconnect().catch(()=>{})}),e.s(["db",0,t])},572173,e=>{"use strict";var r=e.i(843793);async function t(e,t){let s=await r.db.systemConfig.findUnique({where:{key:e}});if(!s)return t;try{return JSON.parse(s.value)}catch{return t}}e.s(["readConfigValue",0,t])},341291,e=>{"use strict";var r=e.i(666680),t=e.i(902157),s=e.i(750227),n=e.i(192520);function i(e){if(!e.startsWith((0,n.getStorageDir)()+s.sep))throw Error("Path traversal detected")}let o=new Set(["image","screenshot","img","photo","picture","clipboard","paste","untitled"]);e.s(["buildCacheFilename",0,function(e,t){let n=s.basename(e,s.extname(e)),i=r.randomUUID().replace(/-/g,"").slice(0,8),a=n.toLowerCase();if(!n||o.has(a)||/^screenshot[\s_\-]/i.test(n))return`tower_image-${i}${t}`;let c=n.replace(/[^\p{L}\p{N}]/gu,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,"");return`${c||"file"}-${i}${t}`},"ensureAssetsDir",0,function(e){let r,o=(i(r=s.join((0,n.getStorageDir)(),"assets",e)),r);return t.mkdirSync(o,{recursive:!0}),o},"getAssistantCacheDir",0,function(e="images"){let r=new Date,o=`${r.getFullYear()}-${String(r.getMonth()+1).padStart(2,"0")}`,a=s.join((0,n.getStorageDir)(),"cache","assistant",o,e);return i(a),t.mkdirSync(a,{recursive:!0}),a},"getAssistantCacheRoot",0,function(){let e=s.join((0,n.getStorageDir)(),"cache","assistant");return i(e),e}])}];

//# sourceMappingURL=%5Broot-of-the-server%5D__0omyrab._.js.map