"use strict";(()=>{var e={};e.id=4702,e.ids=[4702],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")},12140:(e,t,r)=>{r.r(t),r.d(t,{originalPathname:()=>g,patchFetch:()=>y,requestAsyncStorage:()=>x,routeModule:()=>m,serverHooks:()=>f,staticGenerationAsyncStorage:()=>h});var s={};r.r(s),r.d(s,{GET:()=>d,POST:()=>p,dynamic:()=>l});var n=r(49303),o=r(88716),a=r(60670),i=r(87070),u=r(13538),c=r(5710);let l="force-dynamic";async function d(e){try{let{userId:e}=(0,c.v0)();if(!e)return(0,c.Hs)();let t=await u.Z.schoolClub.findMany({include:{_count:{select:{members:!0,events:!0}}},orderBy:{name:"asc"}});return i.NextResponse.json(t)}catch(e){return(0,c.I3)(e)}}async function p(e){try{let{userId:t,role:r}=(0,c.v0)();if(!t)return(0,c.Hs)();if("admin"!==r)return(0,c.ID)();let{name:s,description:n}=await e.json();if(!s)return(0,c.yw)("Name is required");let o=await u.Z.schoolClub.create({data:{name:s,description:n}});return i.NextResponse.json(o,{status:201})}catch(e){return(0,c.I3)(e)}}let m=new n.AppRouteRouteModule({definition:{kind:o.x.APP_ROUTE,page:"/api/school-life/clubs/route",pathname:"/api/school-life/clubs",filename:"route",bundlePath:"app/api/school-life/clubs/route"},resolvedPagePath:"C:\\School Management System\\Working\\V2\\src\\app\\api\\school-life\\clubs\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:x,staticGenerationAsyncStorage:h,serverHooks:f}=m,g="/api/school-life/clubs/route";function y(){return(0,a.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:h})}},49303:(e,t,r)=>{e.exports=r(30517)},5710:(e,t,r)=>{r.d(t,{Hs:()=>a,I3:()=>c,ID:()=>i,v0:()=>o,yw:()=>u});var s=r(26501),n=r(87070);function o(){let{userId:e,sessionClaims:t}=(0,s.d)();return{userId:e,role:t?.metadata?.role}}function a(){return n.NextResponse.json({message:"Unauthorized"},{status:401})}function i(){return n.NextResponse.json({message:"Forbidden"},{status:403})}function u(e){return n.NextResponse.json({message:e},{status:400})}function c(e){return console.error(e),n.NextResponse.json({message:"Internal Server Error"},{status:500})}},26501:(e,t,r)=>{r.d(t,{d:()=>n});var s=r(78459);function n(){try{let{userId:e,sessionClaims:t}=(0,s.I)();return{userId:e,sessionClaims:t,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,t,r)=>{r.d(t,{Z:()=>n});var s=r(53524);let n=globalThis.prisma??new s.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),s=t.X(0,[8948,7070,8459],()=>r(12140));module.exports=s})();