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