(()=>{var e={};e.id=6902,e.ids=[6902],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 a(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:()=>a,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")},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")},79648:(e,r,t)=>{"use strict";t.r(r),t.d(r,{patchFetch:()=>x,routeModule:()=>k,serverHooks:()=>y,workAsyncStorage:()=>f,workUnitAsyncStorage:()=>g});var s={};t.r(s),t.d(s,{GET:()=>h});var a=t(96559),i=t(48088),n=t(37719),p=t(32190),o=t(43205),c=t.n(o),u=t(96330),l=t(12909);let d=new u.PrismaClient,m=(0,l.u)();async function h(e){try{let r,t=(0,l.V)(e);if(!t)return p.NextResponse.json({error:"Authorization token gerekli"},{status:401});try{r=c().verify(t,m)}catch(e){return p.NextResponse.json({error:"Ge\xe7ersiz token"},{status:401})}let s=await d.user.findUnique({where:{id:r.userId},include:{company:{include:{companyMarketplaces:{include:{marketplace:!0,companyMarketplaceShippingFees:!0}}}},userMarketplacePermissions:{include:{companyMarketplace:{include:{marketplace:!0}}}}}});if(!s)return await d.$disconnect(),p.NextResponse.json({error:"Kullanıcı bulunamadı"},{status:404});let a=s.userMarketplacePermissions.map(e=>e.companyMarketplaceId),i=s.company.companyMarketplaces.filter(e=>a.includes(e.id)||s.isAdmin),n=new Map;i.forEach(e=>{n.has(e.marketplaceId)||n.set(e.marketplaceId,{marketplaceId:e.marketplaceId,marketplaceName:e.marketplace.name,companyMarketplaces:[]}),n.get(e.marketplaceId).companyMarketplaces.push(e)});let o=await Promise.all(Array.from(n.values()).map(async e=>{let r=[];e.companyMarketplaces.forEach(e=>{e.companyMarketplaceShippingFees&&e.companyMarketplaceShippingFees.forEach(e=>{r.push({desi:e.desi,shippingFee:e.shippingFee})})});let t=await d.marketplaceShippingDefaultFee.findMany({where:{marketplaceId:e.marketplaceId},orderBy:{desi:"asc"}}),s=new Map;t.forEach(e=>{s.set(e.desi,{shippingFee:e.shippingFee,isCustom:!1})}),r.forEach(e=>{s.has(e.desi)&&!1!==s.get(e.desi).isCustom||s.set(e.desi,{shippingFee:e.shippingFee,isCustom:!0})});let a=new Set;t.forEach(e=>a.add(e.desi)),r.forEach(e=>a.add(e.desi));let i=Array.from(a).sort((e,r)=>e-r),n=(i.length>0?i:Array.from({length:10},(e,r)=>r+1)).map(e=>{let r=s.get(e)||{shippingFee:0,isCustom:!1};return{desi:e,shippingFee:r.shippingFee,isCustom:r.isCustom}});return{marketplaceId:e.marketplaceId,marketplaceName:e.marketplaceName,fees:n}}));return await d.$disconnect(),p.NextResponse.json({shippingFees:o})}catch(e){return console.error("Shipping fees fetch error:",e),await d.$disconnect(),p.NextResponse.json({error:"Sunucu hatası"},{status:500})}}let k=new a.AppRouteRouteModule({definition:{kind:i.RouteKind.APP_ROUTE,page:"/api/shipping-fees/route",pathname:"/api/shipping-fees",filename:"route",bundlePath:"app/api/shipping-fees/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/shipping-fees/route.ts",nextConfigOutput:"standalone",userland:s}),{workAsyncStorage:f,workUnitAsyncStorage:g,serverHooks:y}=k;function x(){return(0,n.patchFetch)({workAsyncStorage:f,workUnitAsyncStorage:g})}},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(79648));module.exports=s})();