(()=>{var e={};e.id=7335,e.ids=[7335],e.modules={3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12909:(e,r,t)=>{"use strict";function s(){let e=process.env.JWT_SECRET;if(!e)throw Error("JWT_SECRET is not set");return e}function n(e){let r=e.headers.get("authorization");if(r&&r.startsWith("Bearer "))return r.slice(7);let t=e.cookies.get("admin_token")?.value;if(t)return t;let s=e.cookies.get("token")?.value;return s||null}t.d(r,{V:()=>n,u:()=>s})},27910:e=>{"use strict";e.exports=require("stream")},28354:e=>{"use strict";e.exports=require("util")},29294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},44870:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},55511:e=>{"use strict";e.exports=require("crypto")},60221:(e,r,t)=>{"use strict";t.r(r),t.d(r,{patchFetch:()=>N,routeModule:()=>h,serverHooks:()=>j,workAsyncStorage:()=>k,workUnitAsyncStorage:()=>w});var s={};t.r(s),t.d(s,{DELETE:()=>v,GET:()=>x,PUT:()=>f});var n=t(96559),a=t(48088),o=t(37719),i=t(32190),u=t(43205),c=t.n(u),p=t(96330),d=t(12909);let l=new p.PrismaClient,m=(0,d.u)();async function y(e){let r=(0,d.V)(e);if(!r)return null;try{let e=c().verify(r,m);if(e.isGlobalAdmin&&e.globalAdminId)return e}catch{}return null}async function x(e,{params:r}){try{if(!await y(e))return i.NextResponse.json({error:"Unauthorized"},{status:401});let t=await Promise.resolve(r),s=parseInt(t.id);if(isNaN(s))return i.NextResponse.json({error:"Invalid company ID"},{status:400});let n=await l.company.findUnique({where:{id:s},include:{users:{include:{userMarketplacePermissions:{include:{companyMarketplace:{include:{marketplace:!0}}}},systemPermissions:!0},orderBy:{id:"desc"}},companyMarketplaces:{include:{marketplace:!0}},companyPackages:{include:{package:!0},orderBy:{id:"desc"}},products:{take:10,orderBy:{id:"desc"},include:{productMarketplaces:{include:{companyMarketplace:{include:{marketplace:!0}},productAnalyses:{take:1,orderBy:{createdAt:"desc"}}}}}},_count:{select:{users:!0,products:!0,companyMarketplaces:!0,companyPackages:!0}}}});if(!n)return i.NextResponse.json({error:"Company not found"},{status:404});return i.NextResponse.json({company:n})}catch(e){return console.error("Company detail error:",e),i.NextResponse.json({error:"Server error"},{status:500})}}async function f(e,{params:r}){try{if(!await y(e))return i.NextResponse.json({error:"Unauthorized"},{status:401});let t=await Promise.resolve(r),s=parseInt(t.id);if(isNaN(s))return i.NextResponse.json({error:"Invalid company ID"},{status:400});let{name:n,address:a,taxOffice:o,taxNumber:u,contactPerson:c,phone:p,email:d,isApproved:m}=await e.json(),x=await l.company.findUnique({where:{id:s}});if(!x)return i.NextResponse.json({error:"Company not found"},{status:404});if(n&&n!==x.name&&await l.company.findUnique({where:{name:n}}))return i.NextResponse.json({error:"Company with this name already exists"},{status:400});let f={};void 0!==n&&(f.name=n),void 0!==a&&(f.address=a),void 0!==o&&(f.taxOffice=o),void 0!==u&&(f.taxNumber=u),void 0!==c&&(f.contactPerson=c),void 0!==p&&(f.phone=p),void 0!==d&&(f.email=d),void 0!==m&&(f.isApproved=!!m);let v=await l.company.update({where:{id:s},data:f});return i.NextResponse.json({company:v})}catch(e){return console.error("Update company error:",e),i.NextResponse.json({error:"Server error",details:void 0},{status:500})}}async function v(e,{params:r}){try{if(!await y(e))return i.NextResponse.json({error:"Unauthorized"},{status:401});let t=await Promise.resolve(r),s=parseInt(t.id);if(isNaN(s))return i.NextResponse.json({error:"Invalid company ID"},{status:400});return await l.company.delete({where:{id:s}}),i.NextResponse.json({message:"Company deleted successfully"})}catch(e){return console.error("Delete company error:",e),i.NextResponse.json({error:"Server error"},{status:500})}}let h=new n.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/admin/companies/[id]/route",pathname:"/api/admin/companies/[id]",filename:"route",bundlePath:"app/api/admin/companies/[id]/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/admin/companies/[id]/route.ts",nextConfigOutput:"standalone",userland:s}),{workAsyncStorage:k,workUnitAsyncStorage:w,serverHooks:j}=h;function N(){return(0,o.patchFetch)({workAsyncStorage:k,workUnitAsyncStorage:w})}},63033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},78335:()=>{},79428:e=>{"use strict";e.exports=require("buffer")},96330:e=>{"use strict";e.exports=require("@prisma/client")},96487:()=>{}};var r=require("../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[4447,580,3205],()=>t(60221));module.exports=s})();