"use strict";(()=>{var e={};e.id=4416,e.ids=[4416,2331],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")},11162:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>g,patchFetch:()=>v,requestAsyncStorage:()=>m,routeModule:()=>p,serverHooks:()=>f,staticGenerationAsyncStorage:()=>h});var a={};t.r(a),t.d(a,{GET:()=>c,dynamic:()=>d});var s=t(49303),n=t(88716),i=t(60670),o=t(87070),u=t(3040),l=t(72331);let d="force-dynamic";async function c(e){if(!await (0,u.kT)(e))return(0,u.yr)();try{let{searchParams:r}=new URL(e.url),t=r.get("slug");if(t){let e=await l.default.gameCategory.findUnique({where:{slug:t,isActive:!0},include:{products:{where:{isActive:!0,status:!0},select:{id:!0,productName:!0,sellPrice:!0,description:!0,server:!0},orderBy:{sellPrice:"asc"}}}});if(!e)return o.NextResponse.json({success:!1,error:"Kategori tidak ditemukan"},{status:404});return o.NextResponse.json({success:!0,data:e})}let a=await l.default.gameCategory.findMany({where:{isActive:!0},select:{id:!0,name:!0,slug:!0,thumbnail:!0},orderBy:{sortOrder:"asc"}});return o.NextResponse.json({success:!0,data:a})}catch(e){return o.NextResponse.json({success:!1,error:"Gagal memuat data"},{status:500})}}let p=new s.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/h2h/v1/games/route",pathname:"/api/h2h/v1/games",filename:"route",bundlePath:"app/api/h2h/v1/games/route"},resolvedPagePath:"C:\\Users\\akmal\\OneDrive\\Documents\\AmaneNime Topup\\amanenime-topup\\app\\api\\h2h\\v1\\games\\route.ts",nextConfigOutput:"standalone",userland:a}),{requestAsyncStorage:m,staticGenerationAsyncStorage:h,serverHooks:f}=p,g="/api/h2h/v1/games/route";function v(){return(0,i.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:h})}},3040:(e,r,t)=>{t.d(r,{_4:()=>u,kT:()=>i,yr:()=>o});var a=t(87070),s=t(72331);let n=new Map;async function i(e){let r=e.headers.get("x-api-key")||e.headers.get("authorization")?.replace("Bearer ","")||e.nextUrl.searchParams.get("api_key");if(!r)return null;let t=await s.default.apiKey.findUnique({where:{key:r,isActive:!0},include:{user:{select:{id:!0,name:!0,email:!0,balance:!0,role:!0,isBanned:!0}}}});if(!t||!t.user||t.user.isBanned)return null;let a=Date.now(),i=n.get(r),o="USER"===t.user.role?30:120;if(i&&i.resetAt>a){if(i.count>=o)return console.warn(`[H2H] Rate limit exceeded for key ${t.id} (Role: ${t.user.role})`),null;i.count++}else n.set(r,{count:1,resetAt:a+6e4});if(t.ipWhitelist)try{let r=JSON.parse(t.ipWhitelist);if(r.length>0){let a=e.headers.get("x-forwarded-for")?.split(",")[0]?.trim()||e.headers.get("x-real-ip")||"0.0.0.0";if(!r.includes(a))return console.warn(`[H2H] IP blocked: ${a} not in whitelist for key ${t.id}`),null}}catch{}return await s.default.apiKey.update({where:{id:t.id},data:{lastUsedAt:new Date}}).catch(()=>{}),{id:t.user.id,name:t.user.name,email:t.user.email,balance:Number(t.user.balance),role:t.user.role,apiKeyId:t.id}}function o(e="API Key tidak valid atau tidak aktif"){return a.NextResponse.json({success:!1,error:e},{status:401})}function u(){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=Array.from({length:8},()=>e[Math.floor(Math.random()*e.length)]).join(""),t=Array.from({length:16},()=>e[Math.floor(Math.random()*e.length)]).join(""),a=Array.from({length:8},()=>e[Math.floor(Math.random()*e.length)]).join("");return`ANK-${r}-${t}-${a}`}},72331:(e,r,t)=>{t.r(r),t.d(r,{default:()=>n,prisma:()=>s});var a=t(53524);let s=globalThis.prisma??new a.PrismaClient({datasources:{db:{url:(()=>{if(process.env.DATABASE_URL)return process.env.DATABASE_URL;let e=process.env.DB_USER||"root",r=process.env.DB_PASSWORD||"",t=process.env.DB_HOST||"127.0.0.1",a=process.env.DB_PORT||"3306",s=process.env.DB_NAME||"amanenime_topup";return`mysql://${e}:${r}@${t}:${a}/${s}`})()}},log:["error"]}),n=s}};var r=require("../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[8948,5972],()=>t(11162));module.exports=a})();