"use strict";(()=>{var e={};e.id=6771,e.ids=[6771],e.modules={53524:e=>{e.exports=require("@prisma/client")},72934:e=>{e.exports=require("next/dist/client/components/action-async-storage.external.js")},54580:e=>{e.exports=require("next/dist/client/components/request-async-storage.external.js")},45869:e=>{e.exports=require("next/dist/client/components/static-generation-async-storage.external.js")},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")},6113:e=>{e.exports=require("crypto")},6005:e=>{e.exports=require("node:crypto")},98589:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>g,patchFetch:()=>b,requestAsyncStorage:()=>h,routeModule:()=>m,serverHooks:()=>f,staticGenerationAsyncStorage:()=>x});var s={};t.r(s),t.d(s,{POST:()=>d,dynamic:()=>p});var n=t(49303),o=t(88716),i=t(60670),a=t(87070),u=t(13538),l=t(5710),c=t(53524);let p="force-dynamic";async function d(e){try{let{userId:r,role:t}=(0,l.v0)();if(!r)return(0,l.Hs)();if("student"!==t)return(0,l.ID)();let{clubId:s}=await e.json();if(!s)return(0,l.yw)("clubId is required");if(await u.Z.schoolClubMember.findFirst({where:{clubId:s,userId:r}}))return(0,l.yw)("Already a member or request pending");let n=await u.Z.schoolClubMember.create({data:{clubId:s,userId:r,role:c.SchoolClubRole.PENDING}});return a.NextResponse.json(n,{status:201})}catch(e){return(0,l.I3)(e)}}let m=new n.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/school-life/club-membership/join/route",pathname:"/api/school-life/club-membership/join",filename:"route",bundlePath:"app/api/school-life/club-membership/join/route"},resolvedPagePath:"C:\\School Management System\\Working\\V2\\src\\app\\api\\school-life\\club-membership\\join\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:h,staticGenerationAsyncStorage:x,serverHooks:f}=m,g="/api/school-life/club-membership/join/route";function b(){return(0,i.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:x})}},49303:(e,r,t)=>{e.exports=t(30517)},5710:(e,r,t)=>{t.d(r,{Hs:()=>i,I3:()=>l,ID:()=>a,v0:()=>o,yw:()=>u});var s=t(26501),n=t(87070);function o(){let{userId:e,sessionClaims:r}=(0,s.d)();return{userId:e,role:r?.metadata?.role}}function i(){return n.NextResponse.json({message:"Unauthorized"},{status:401})}function a(){return n.NextResponse.json({message:"Forbidden"},{status:403})}function u(e){return n.NextResponse.json({message:e},{status:400})}function l(e){return console.error(e),n.NextResponse.json({message:"Internal Server Error"},{status:500})}},26501:(e,r,t)=>{t.d(r,{d:()=>n});var s=t(78459);function n(){try{let{userId:e,sessionClaims:r}=(0,s.I)();return{userId:e,sessionClaims:r,isBuildPhase:!1}}catch(e){if(e instanceof Error&&(e.message.includes("DYNAMIC_SERVER_USAGE")||e.message.includes("Dynamic server usage")||e.message.includes("headers")))return console.warn("[DeploymentGuard] Build-phase detected — auth() skipped."),{userId:null,sessionClaims:null,isBuildPhase:!0};throw e}}},13538:(e,r,t)=>{t.d(r,{Z:()=>n});var s=t(53524);let n=globalThis.prisma??new s.PrismaClient({log:["error"],datasources:{db:{url:process.env.DATABASE_URL}}})}};var r=require("../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8948,7070,8459],()=>t(98589));module.exports=s})();