"use strict";(()=>{var e={};e.id=2628,e.ids=[2628],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")},84770:e=>{e.exports=require("crypto")},80023:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>f,patchFetch:()=>R,requestAsyncStorage:()=>x,routeModule:()=>v,serverHooks:()=>h,staticGenerationAsyncStorage:()=>w});var s={};t.r(s),t.d(s,{GET:()=>l,POST:()=>c,PUT:()=>m,dynamic:()=>d});var a=t(49303),n=t(88716),o=t(60670),i=t(87070),u=t(72331),p=t(98691);let d="force-dynamic";async function l(e){try{let{searchParams:r}=new URL(e.url),t=r.get("search")||"",s=await u._.user.findMany({where:{OR:[{username:{contains:t}},{email:{contains:t}}]},select:{id:!0,username:!0,email:!0,role:!0,coins:!0,vipLevel:!0,vipExpiresAt:!0,createdAt:!0,image:!0,phoneNumber:!0},orderBy:{createdAt:"desc"},take:50});return i.NextResponse.json({users:s})}catch(e){return console.error("Failed to fetch users:",e),i.NextResponse.json({error:"Internal Server Error"},{status:500})}}async function c(e){try{let{username:r,email:t,password:s,role:a,coins:n,vipLevel:o}=await e.json();if(!r||!s)return i.NextResponse.json({error:"Username and password required"},{status:400});if(await u._.user.findUnique({where:{username:r}}))return i.NextResponse.json({error:"Username already exists"},{status:400});let d=await (0,p.vp)(s,12),l=await u._.user.create({data:{username:r,email:t,password:d,role:a||"USER",coins:parseInt(n)||0,vipLevel:parseInt(o)||0}});return i.NextResponse.json(l)}catch(e){return console.error("Failed to create user:",e),i.NextResponse.json({error:"Internal Server Error"},{status:500})}}async function m(e){try{let{id:r,coins:t,vipLevel:s,role:a,password:n}=await e.json();if(!r)return i.NextResponse.json({error:"User ID required"},{status:400});let o={};void 0!==t&&(o.coins=parseInt(t)),void 0!==s&&(o.vipLevel=parseInt(s)),a&&(o.role=a),n&&(o.password=await (0,p.vp)(n,12));let d=await u._.user.update({where:{id:r},data:o});return i.NextResponse.json({user:d})}catch(e){return console.error("Failed to update user:",e),i.NextResponse.json({error:"Internal Server Error"},{status:500})}}let v=new a.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/admin/users/route",pathname:"/api/admin/users",filename:"route",bundlePath:"app/api/admin/users/route"},resolvedPagePath:"C:\\Users\\MSI\\Downloads\\film\\app\\api\\admin\\users\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:x,staticGenerationAsyncStorage:w,serverHooks:h}=v,f="/api/admin/users/route";function R(){return(0,o.patchFetch)({serverHooks:h,staticGenerationAsyncStorage:w})}},72331:(e,r,t)=>{t.d(r,{_:()=>a});var s=t(53524);let a=global.prisma||new s.PrismaClient}};var r=require("../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),s=r.X(0,[8948,5972,8691],()=>t(80023));module.exports=s})();