"use strict";(()=>{var e={};e.id=1671,e.ids=[1671,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")},63037:(e,r,t)=>{t.r(r),t.d(r,{originalPathname:()=>v,patchFetch:()=>g,requestAsyncStorage:()=>m,routeModule:()=>p,serverHooks:()=>f,staticGenerationAsyncStorage:()=>h});var a={};t.r(a),t.d(a,{GET:()=>c,dynamic:()=>l});var i=t(49303),n=t(88716),s=t(60670),o=t(87070),d=t(3040),u=t(72331);let l="force-dynamic";async function c(e,{params:r}){let t=await (0,d.kT)(e);if(!t)return(0,d.yr)();try{let e=await u.default.order.findFirst({where:{id:r.id,userId:t.id},include:{vipProduct:{select:{gameName:!0,productName:!0}},digitalProduct:{select:{name:!0}}}});if(!e)return o.NextResponse.json({success:!1,error:"Order tidak ditemukan"},{status:404});return o.NextResponse.json({success:!0,data:{orderId:e.id,status:e.status,productType:e.productType,productName:e.vipProduct?`${e.vipProduct.gameName} - ${e.vipProduct.productName}`:e.digitalProduct?.name||"Unknown",price:e.price,targetId:e.targetId,deliveryData:"SUCCESS"===e.status?e.deliveryData:null,createdAt:e.createdAt}})}catch(e){return o.NextResponse.json({success:!1,error:"Gagal cek order"},{status:500})}}let p=new i.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/h2h/v1/orders/[id]/route",pathname:"/api/h2h/v1/orders/[id]",filename:"route",bundlePath:"app/api/h2h/v1/orders/[id]/route"},resolvedPagePath:"C:\\Users\\akmal\\OneDrive\\Documents\\AmaneNime Topup\\amanenime-topup\\app\\api\\h2h\\v1\\orders\\[id]\\route.ts",nextConfigOutput:"standalone",userland:a}),{requestAsyncStorage:m,staticGenerationAsyncStorage:h,serverHooks:f}=p,v="/api/h2h/v1/orders/[id]/route";function g(){return(0,s.patchFetch)({serverHooks:f,staticGenerationAsyncStorage:h})}},3040:(e,r,t)=>{t.d(r,{_4:()=>d,kT:()=>s,yr:()=>o});var a=t(87070),i=t(72331);let n=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 t=await i.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(),s=n.get(r),o="USER"===t.user.role?30:120;if(s&&s.resetAt>a){if(s.count>=o)return console.warn(`[H2H] Rate limit exceeded for key ${t.id} (Role: ${t.user.role})`),null;s.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 i.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 d(){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:()=>i});var a=t(53524);let i=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",i=process.env.DB_NAME||"amanenime_topup";return`mysql://${e}:${r}@${t}:${a}/${i}`})()}},log:["error"]}),n=i}};var r=require("../../../../../../webpack-runtime.js");r.C(e);var t=e=>r(r.s=e),a=r.X(0,[8948,5972],()=>t(63037));module.exports=a})();