"use strict";(()=>{var e={};e.id=635,e.ids=[635],e.modules={846:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},4870:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},3295:e=>{e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},9294:e=>{e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},3033:e=>{e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},9646:e=>{e.exports=require("child_process")},9748:e=>{e.exports=require("fs/promises")},1820:e=>{e.exports=require("os")},3873:e=>{e.exports=require("path")},8354:e=>{e.exports=require("util")},9416:(e,r,t)=>{t.r(r),t.d(r,{patchFetch:()=>m,routeModule:()=>f,serverHooks:()=>j,workAsyncStorage:()=>g,workUnitAsyncStorage:()=>h});var s={};t.r(s),t.d(s,{GET:()=>d,POST:()=>x});var a=t(2706),i=t(8203),o=t(5994),n=t(9187),u=t(9269),p=t(9748),c=t(3873),l=t(1820);async function d(e){let r=e.nextUrl.searchParams,t=r.get("deviceId"),s=r.get("path")||"/";if(!t)return n.NextResponse.json({error:"Device ID is required"},{status:400});try{let e=u.J.getInstance(),r=await e.listFiles(t,s);return n.NextResponse.json({files:r})}catch(e){return console.error("Error listing files:",e),n.NextResponse.json({error:e instanceof Error?e.message:"Failed to list files"},{status:500})}}async function x(e){let r=await e.formData(),t=r.get("deviceId"),s=r.get("path"),a=r.get("action");if(!t)return n.NextResponse.json({error:"Device ID is required"},{status:400});if(!s)return n.NextResponse.json({error:"Path is required"},{status:400});let i=u.J.getInstance();try{switch(a){case"upload":{let e=r.get("file");if(!e)return n.NextResponse.json({error:"File is required"},{status:400});let a=Buffer.from(await e.arrayBuffer()),o=(0,c.join)((0,l.tmpdir)(),e.name);return await (0,p.writeFile)(o,a),await i.uploadFile(t,o,s),await (0,p.unlink)(o),n.NextResponse.json({success:!0})}case"createDir":return await i.createDirectory(t,s),n.NextResponse.json({success:!0});case"delete":return await i.deleteFile(t,s),n.NextResponse.json({success:!0});default:return n.NextResponse.json({error:"Invalid action specified"},{status:400})}}catch(e){return console.error("Error handling file operation:",e),n.NextResponse.json({error:e instanceof Error?e.message:"Operation failed"},{status:500})}}let f=new a.AppRouteRouteModule({definition:{kind:i.RouteKind.APP_ROUTE,page:"/api/files/route",pathname:"/api/files",filename:"route",bundlePath:"app/api/files/route"},resolvedPagePath:"/Users/saleeh/codes/appmaker/adb-web/src/app/api/files/route.ts",nextConfigOutput:"",userland:s}),{workAsyncStorage:g,workUnitAsyncStorage:h,serverHooks:j}=f;function m(){return(0,o.patchFetch)({workAsyncStorage:g,workUnitAsyncStorage:h})}}};var r=require("../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[994,452,577],()=>t(9416));module.exports=s})();