(()=>{var e={};e.id=3771,e.ids=[3771],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,t,r)=>{"use strict";function a(){let e=process.env.JWT_SECRET;if(!e)throw Error("JWT_SECRET is not set");return e}function s(e){let t=e.headers.get("authorization");if(t&&t.startsWith("Bearer "))return t.slice(7);let r=e.cookies.get("admin_token")?.value;if(r)return r;let a=e.cookies.get("token")?.value;return a||null}r.d(t,{V:()=>s,u:()=>a})},17989:(e,t,r)=>{"use strict";r.r(t),r.d(t,{patchFetch:()=>I,routeModule:()=>f,serverHooks:()=>y,workAsyncStorage:()=>x,workUnitAsyncStorage:()=>v});var a={};r.r(a),r.d(a,{PUT:()=>m});var s=r(96559),n=r(48088),i=r(37719),o=r(32190),u=r(43205),p=r.n(u),c=r(96330),d=r(12909);let l=new c.PrismaClient,k=(0,d.u)();async function g(e){let t=(0,d.V)(e);if(!t)return null;try{let e=p().verify(t,k);if(e.isGlobalAdmin&&e.globalAdminId)return e}catch{}return null}async function m(e,{params:t}){try{if(!await g(e))return o.NextResponse.json({error:"Unauthorized"},{status:401});let r=parseInt(t.id),a=parseInt(t.packageId);if(isNaN(r)||isNaN(a))return o.NextResponse.json({error:"Invalid company ID or package ID"},{status:400});let{packageId:s,price:n,maxProducts:i,frequencyMinutes:u,maxConcurrentWorkers:p,maxStores:c,status:d,packageEndDate:k}=await e.json(),m=await l.companyPackage.findFirst({where:{id:a,companyId:r}});if(!m)return o.NextResponse.json({error:"Company package not found or does not belong to this company"},{status:404});if(void 0!==s&&s!==m.packageId){if(!await l.package.findUnique({where:{id:parseInt(s)}}))return o.NextResponse.json({error:"Package not found"},{status:404});let e=new Date;if(await l.companyPackage.findFirst({where:{companyId:r,packageId:parseInt(s),packageEndDate:{gte:e},id:{not:a},status:!0}}))return o.NextResponse.json({error:"Bu şirket i\xe7in bu paket t\xfcr\xfcnden zaten aktif bir paket mevcut"},{status:400})}let f={};void 0!==s&&(f.packageId=parseInt(s)),void 0!==n&&(f.price=null!==n?parseFloat(n):null),void 0!==i&&(f.maxProducts=null!==i?parseInt(i):null),void 0!==u&&(f.frequencyMinutes=null!==u?parseInt(u):null),void 0!==p&&(f.maxConcurrentWorkers=null!==p?parseInt(p):null),void 0!==c&&(f.maxStores=null!==c?parseInt(c):null),void 0!==d&&(f.status=!!d),void 0!==k&&(f.packageEndDate=new Date(k));let x=await l.companyPackage.update({where:{id:a},data:f,include:{package:!0,company:{select:{id:!0,name:!0}}}});return o.NextResponse.json({message:"Package updated successfully",companyPackage:x})}catch(e){return console.error("Update company package error:",e),o.NextResponse.json({error:"Server error"},{status:500})}}let f=new s.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/admin/companies/[id]/packages/[packageId]/route",pathname:"/api/admin/companies/[id]/packages/[packageId]",filename:"route",bundlePath:"app/api/admin/companies/[id]/packages/[packageId]/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/admin/companies/[id]/packages/[packageId]/route.ts",nextConfigOutput:"standalone",userland:a}),{workAsyncStorage:x,workUnitAsyncStorage:v,serverHooks:y}=f;function I(){return(0,i.patchFetch)({workAsyncStorage:x,workUnitAsyncStorage:v})}},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")},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 t=require("../../../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),a=t.X(0,[4447,580,3205],()=>r(17989));module.exports=a})();