"use strict";(()=>{var e={};e.id=4367,e.ids=[4367],e.modules={53524:e=>{e.exports=require("@prisma/client")},20399:e=>{e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},57400:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>v,patchFetch:()=>x,requestAsyncStorage:()=>m,routeModule:()=>p,serverHooks:()=>g,staticGenerationAsyncStorage:()=>c});var n={};r.r(n),r.d(n,{POST:()=>d,dynamic:()=>l});var s=r(49303),o=r(88716),a=r(60670),u=r(87070),i=r(13538);let l="force-dynamic";async function d(e){try{let t=e.headers.get("Authorization"),r=process.env.ATLAS_DEVICE_API_KEY;if(r&&(t?.startsWith("Bearer ")?t.slice(7):"")!==r)return u.NextResponse.json({error:"Unauthorized"},{status:401});let{code:n,deviceId:s,vectorStored:o}=await e.json();if(!n)return u.NextResponse.json({error:"Bad Request",message:"code is required"},{status:400});let a=await i.Z.enrollmentToken.findUnique({where:{code:String(n)},include:{student:{select:{id:!0,name:!0,surname:!0}}}});if(!a)return u.NextResponse.json({error:"Invalid",message:"Token not found"},{status:404});if(a.used)return u.NextResponse.json({error:"Used",message:"Token has already been used"},{status:410});if(new Date>a.expiresAt)return u.NextResponse.json({error:"Expired",message:"Token has expired"},{status:410});return await i.Z.enrollmentToken.update({where:{id:a.id},data:{used:!0}}),console.log(`[Enrollment] Completed for ${a.student.name} ${a.student.surname} (${a.studentId}) via device ${s||"unknown"}. Vector stored: ${o?"yes":"no"}`),u.NextResponse.json({message:"Enrollment completed successfully",studentId:a.studentId,studentName:`${a.student.name} ${a.student.surname}`},{status:200})}catch(e){return console.error("[Enrollment Complete] Error:",e),u.NextResponse.json({error:"Internal Server Error",message:String(e)},{status:500})}}let p=new s.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/v1/enrollment/complete/route",pathname:"/api/v1/enrollment/complete",filename:"route",bundlePath:"app/api/v1/enrollment/complete/route"},resolvedPagePath:"C:\\School Management System\\Working\\V2\\src\\app\\api\\v1\\enrollment\\complete\\route.ts",nextConfigOutput:"standalone",userland:n}),{requestAsyncStorage:m,staticGenerationAsyncStorage:c,serverHooks:g}=p,v="/api/v1/enrollment/complete/route";function x(){return(0,a.patchFetch)({serverHooks:g,staticGenerationAsyncStorage:c})}},49303:(e,t,r)=>{e.exports=r(30517)},13538:(e,t,r)=>{r.d(t,{Z:()=>s});var n=r(53524);let s=globalThis.prisma??new n.PrismaClient({log:["error"],datasources:{db:{url:process.env.DATABASE_URL}}})}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),n=t.X(0,[8948,7070],()=>r(57400));module.exports=n})();