(()=>{var e={};e.id=1612,e.ids=[1612],e.modules={3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},5486:e=>{"use strict";e.exports=require("bcrypt")},10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12909:(e,r,t)=>{"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 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 a=e.cookies.get("token")?.value;return a||null}t.d(r,{V:()=>s,u:()=>a})},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")},74884:(e,r,t)=>{"use strict";t.r(r),t.d(r,{patchFetch:()=>v,routeModule:()=>h,serverHooks:()=>w,workAsyncStorage:()=>y,workUnitAsyncStorage:()=>f});var a={};t.r(a),t.d(a,{POST:()=>x});var s=t(96559),n=t(48088),i=t(37719),o=t(32190),u=t(96330),p=t(5486),c=t.n(p),l=t(43205),m=t.n(l),d=t(12909);let k=new u.PrismaClient,g=(0,d.u)();async function x(e){try{let{firstName:r,lastName:t,phone:a,email:s,password:n}=await e.json();if(!r||!t||!a||!s||!n)return o.NextResponse.json({error:"T\xfcm alanlar gereklidir"},{status:400});if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s))return o.NextResponse.json({error:"Ge\xe7erli bir email adresi giriniz"},{status:400});if(n.length<8)return o.NextResponse.json({error:"Şifre en az 8 karakter olmalıdır"},{status:400});if(await k.user.findUnique({where:{email:s}}))return o.NextResponse.json({error:"Bu email ile kayıtlı kullanıcı mevcut"},{status:409});let i=await c().hash(n,10),u=`${r} ${t}`.trim()||"Yeni Şirket",p=`${u} - ${Date.now()}`,l=await k.company.create({data:{name:p,contactPerson:`${r} ${t}`,phone:a,email:s}}),d=await k.user.create({data:{email:s,password:i,name:r,surname:t,phoneNumber:a,companyId:l.id,isAdmin:!0},include:{company:{include:{companyPackages:{where:{status:!0},include:{package:!0}},companyMarketplaces:{include:{marketplace:!0}}}}}}),x=m().sign({userId:d.id,email:d.email,companyId:d.companyId},g,{expiresIn:"7d"}),h=d.company.companyMarketplaces.map(e=>({id:e.id,name:e.name,marketplaceId:e.marketplace.id,marketplaceName:e.marketplace.name.toLowerCase(),bgColor:e.marketplace.bgColor,icon:e.marketplace.icon})),y={message:"Hesap başarıyla oluşturuldu",access_token:x,user:{id:d.id,email:d.email,name:d.name,surname:d.surname,image:null,company:{id:d.company.id,name:d.company.name,packages:d.company.companyPackages.map(e=>({name:e.package.name,packageEndDate:e.packageEndDate.toISOString()})),marketplaces:h,authorizedMarketplaces:h.map(e=>e.id)}}},f=o.NextResponse.json(y);return f.cookies.set("token",x,{httpOnly:!0,sameSite:"lax",path:"/",secure:!0,maxAge:604800}),f}catch(e){return console.error("Register error:",e),o.NextResponse.json({error:"Sunucu hatası"},{status:500})}}let h=new s.AppRouteRouteModule({definition:{kind:n.RouteKind.APP_ROUTE,page:"/api/auth/register/route",pathname:"/api/auth/register",filename:"route",bundlePath:"app/api/auth/register/route"},resolvedPagePath:"/Users/mustafaseyhan/Project/PazarAnalist/src/app/api/auth/register/route.ts",nextConfigOutput:"standalone",userland:a}),{workAsyncStorage:y,workUnitAsyncStorage:f,serverHooks:w}=h;function v(){return(0,i.patchFetch)({workAsyncStorage:y,workUnitAsyncStorage:f})}},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),a=r.X(0,[4447,580,3205],()=>t(74884));module.exports=a})();