"use strict";(()=>{var e={};e.id=1589,e.ids=[1589],e.modules={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")},78893:e=>{e.exports=require("buffer")},61282:e=>{e.exports=require("child_process")},84770:e=>{e.exports=require("crypto")},80665:e=>{e.exports=require("dns")},17702:e=>{e.exports=require("events")},92048:e=>{e.exports=require("fs")},32615:e=>{e.exports=require("http")},35240:e=>{e.exports=require("https")},98216:e=>{e.exports=require("net")},19801:e=>{e.exports=require("os")},55315:e=>{e.exports=require("path")},76162:e=>{e.exports=require("stream")},82452:e=>{e.exports=require("tls")},17360:e=>{e.exports=require("url")},21764:e=>{e.exports=require("util")},71568:e=>{e.exports=require("zlib")},66326:(e,t,a)=>{a.r(t),a.d(t,{originalPathname:()=>g,patchFetch:()=>h,requestAsyncStorage:()=>c,routeModule:()=>u,serverHooks:()=>m,staticGenerationAsyncStorage:()=>f});var r={};a.r(r),a.d(r,{POST:()=>p});var i=a(49303),n=a(88716),s=a(60670),o=a(87070),l=a(73218),d=a(6350);async function p(e){try{let{superAdmin:t,error:a}=await (0,l.WC)("email_settings:write");if(a)return a;let{to:r}=await e.json();if(!r||"string"!=typeof r)return o.NextResponse.json({error:"Email tujuan harus diisi"},{status:400});return await (0,d.Yb)({to:r,subject:"Test Email - RestoMenu",html:`
        <div style="font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; max-width: 600px; margin: 0 auto; padding: 40px 20px;">
          <div style="background-color: #ea580c; padding: 24px; border-radius: 12px 12px 0 0; text-align: center;">
            <h1 style="margin: 0; color: #ffffff; font-size: 24px; font-weight: 700;">RestoMenu</h1>
          </div>
          <div style="background-color: #ffffff; padding: 32px; border: 1px solid #e5e7eb; border-top: none; border-radius: 0 0 12px 12px;">
            <h2 style="margin: 0 0 16px; color: #111827; font-size: 20px;">Test Email Berhasil!</h2>
            <p style="margin: 0 0 16px; color: #374151; font-size: 16px; line-height: 1.6;">
              Jika Anda menerima email ini, konfigurasi SMTP Anda sudah benar dan berfungsi dengan baik.
            </p>
            <p style="margin: 0; color: #6b7280; font-size: 14px;">
              Email ini dikirim dari panel admin RestoMenu.
            </p>
          </div>
        </div>
      `}),o.NextResponse.json({message:"Test email berhasil dikirim ke "+r})}catch(e){return o.NextResponse.json({error:"Gagal mengirim email: "+(e.message||"Unknown error")},{status:500})}}let u=new i.AppRouteRouteModule({definition:{kind:n.x.APP_ROUTE,page:"/api/superadmin/email-settings/test/route",pathname:"/api/superadmin/email-settings/test",filename:"route",bundlePath:"app/api/superadmin/email-settings/test/route"},resolvedPagePath:"D:\\PROJECT\\resto-saas\\src\\app\\api\\superadmin\\email-settings\\test\\route.ts",nextConfigOutput:"",userland:r}),{requestAsyncStorage:c,staticGenerationAsyncStorage:f,serverHooks:m}=u,g="/api/superadmin/email-settings/test/route";function h(){return(0,s.patchFetch)({serverHooks:m,staticGenerationAsyncStorage:f})}},8194:(e,t,a)=>{a.d(t,{_:()=>i});let r=require("@prisma/client"),i=globalThis.prisma??new r.PrismaClient},6350:(e,t,a)=>{a.d(t,{W:()=>o,Yb:()=>n,cl:()=>s,y5:()=>l});var r=a(55245),i=a(56811);async function n({to:e,subject:t,html:a}){let n=await (0,i.$X)(),s=r.createTransport({host:n.smtp_host,port:parseInt(n.smtp_port||"587"),secure:"true"===n.smtp_secure,auth:{user:n.smtp_user,pass:n.smtp_pass}}),o=n.smtp_from_name||"RestoMenu",l=n.smtp_from_email||n.smtp_user;await s.sendMail({from:`"${o}" <${l}>`,to:e,subject:t,html:a})}function s(){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t="";for(let a=0;a<64;a++)t+=e.charAt(Math.floor(Math.random()*e.length));return t}function o(e,t){return`
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Reset Password Anda</title>
</head>
<body style="margin: 0; padding: 0; background-color: #f9fafb; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;">
  <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f9fafb; padding: 40px 0;">
    <tr>
      <td align="center">
        <table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);">
          <!-- Header -->
          <tr>
            <td style="background-color: #ea580c; padding: 32px 40px; text-align: center;">
              <h1 style="margin: 0; color: #ffffff; font-size: 24px; font-weight: 700;">RestoMenu</h1>
            </td>
          </tr>
          <!-- Body -->
          <tr>
            <td style="padding: 40px;">
              <h2 style="margin: 0 0 16px; color: #111827; font-size: 22px; font-weight: 700;">Reset Password Anda</h2>
              <p style="margin: 0 0 24px; color: #374151; font-size: 16px; line-height: 1.6;">
                Halo ${e},
              </p>
              <p style="margin: 0 0 32px; color: #374151; font-size: 16px; line-height: 1.6;">
                Kami menerima permintaan untuk mengatur ulang password akun RestoMenu Anda. Klik tombol di bawah ini untuk membuat password baru.
              </p>
              <!-- Button -->
              <table width="100%" cellpadding="0" cellspacing="0">
                <tr>
                  <td align="center" style="padding-bottom: 32px;">
                    <a href="${t}" style="display: inline-block; background-color: #ea580c; color: #ffffff; text-decoration: none; padding: 14px 40px; border-radius: 8px; font-size: 16px; font-weight: 600;">
                      Reset Password
                    </a>
                  </td>
                </tr>
              </table>
              <p style="margin: 0 0 8px; color: #6b7280; font-size: 14px; line-height: 1.6;">
                Atau salin dan tempel link berikut di browser Anda:
              </p>
              <p style="margin: 0 0 24px; color: #ea580c; font-size: 14px; line-height: 1.6; word-break: break-all;">
                ${t}
              </p>
              <div style="border-top: 1px solid #e5e7eb; padding-top: 24px; margin-top: 8px;">
                <p style="margin: 0; color: #9ca3af; font-size: 13px; line-height: 1.6;">
                  Link berlaku 1 jam. Jika Anda tidak meminta reset password, abaikan email ini. Password Anda tidak akan berubah.
                </p>
              </div>
            </td>
          </tr>
          <!-- Footer -->
          <tr>
            <td style="background-color: #f9fafb; padding: 24px 40px; text-align: center; border-top: 1px solid #e5e7eb;">
              <p style="margin: 0; color: #9ca3af; font-size: 12px;">
                Powered by <a href="https://restomenu.id" style="color: #ea580c; text-decoration: none; font-weight: 600;">restomenu.id</a>
              </p>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</body>
</html>
`}function l(e,t){return`
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Verifikasi Email Anda</title>
</head>
<body style="margin: 0; padding: 0; background-color: #f9fafb; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;">
  <table width="100%" cellpadding="0" cellspacing="0" style="background-color: #f9fafb; padding: 40px 0;">
    <tr>
      <td align="center">
        <table width="600" cellpadding="0" cellspacing="0" style="background-color: #ffffff; border-radius: 12px; overflow: hidden; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);">
          <!-- Header -->
          <tr>
            <td style="background-color: #ea580c; padding: 32px 40px; text-align: center;">
              <h1 style="margin: 0; color: #ffffff; font-size: 24px; font-weight: 700;">RestoMenu</h1>
            </td>
          </tr>
          <!-- Body -->
          <tr>
            <td style="padding: 40px;">
              <h2 style="margin: 0 0 16px; color: #111827; font-size: 22px; font-weight: 700;">Verifikasi Email Anda</h2>
              <p style="margin: 0 0 24px; color: #374151; font-size: 16px; line-height: 1.6;">
                Halo ${e},
              </p>
              <p style="margin: 0 0 32px; color: #374151; font-size: 16px; line-height: 1.6;">
                Terima kasih telah mendaftar di RestoMenu. Silakan klik tombol di bawah ini untuk memverifikasi alamat email Anda.
              </p>
              <!-- Button -->
              <table width="100%" cellpadding="0" cellspacing="0">
                <tr>
                  <td align="center" style="padding-bottom: 32px;">
                    <a href="${t}" style="display: inline-block; background-color: #ea580c; color: #ffffff; text-decoration: none; padding: 14px 40px; border-radius: 8px; font-size: 16px; font-weight: 600;">
                      Verifikasi Email
                    </a>
                  </td>
                </tr>
              </table>
              <p style="margin: 0 0 8px; color: #6b7280; font-size: 14px; line-height: 1.6;">
                Atau salin dan tempel link berikut di browser Anda:
              </p>
              <p style="margin: 0 0 24px; color: #ea580c; font-size: 14px; line-height: 1.6; word-break: break-all;">
                ${t}
              </p>
              <div style="border-top: 1px solid #e5e7eb; padding-top: 24px; margin-top: 8px;">
                <p style="margin: 0; color: #9ca3af; font-size: 13px; line-height: 1.6;">
                  Link berlaku 24 jam. Jika Anda tidak merasa mendaftar di RestoMenu, abaikan email ini.
                </p>
              </div>
            </td>
          </tr>
          <!-- Footer -->
          <tr>
            <td style="background-color: #f9fafb; padding: 24px 40px; text-align: center; border-top: 1px solid #e5e7eb;">
              <p style="margin: 0; color: #9ca3af; font-size: 12px;">
                Powered by <a href="https://restomenu.id" style="color: #ea580c; text-decoration: none; font-weight: 600;">restomenu.id</a>
              </p>
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
</body>
</html>
`}},56811:(e,t,a)=>{a.d(t,{$X:()=>s,Km:()=>n,Rx:()=>o,ks:()=>l});var r=a(8194);let i={payment_fee_mode:"percentage",payment_fee_amount:"2.5",payment_enabled:"true",min_withdrawal:"50000",affiliate_commission_rate:"10",affiliate_enabled:"true",affiliate_min_withdrawal:"50000",email_verification_enabled:"false",smtp_host:"",smtp_port:"587",smtp_user:"",smtp_pass:"",smtp_from_email:"",smtp_from_name:"RestoMenu",smtp_secure:"false"};async function n(e){let t=await r._.platformSetting.findUnique({where:{key:e}});return t?.value??i[e]??""}async function s(){let e=await r._.platformSetting.findMany(),t={...i};for(let a of e)t[a.key]=a.value;return t}async function o(e){let t=Object.entries(e).map(([e,t])=>r._.platformSetting.upsert({where:{key:e},update:{value:t},create:{key:e,value:t}}));await r._.$transaction(t)}function l(e,t,a){let r=parseFloat(a)||0,i=0;i=Math.min(i="percentage"===t?Math.round(e*r/100):Math.round(r),e);let n=e-i;return{fee:i,tenantAmount:n}}},73218:(e,t,a)=>{a.d(t,{KV:()=>u,TM:()=>p,WC:()=>c});var r=a(41482),i=a.n(r),n=a(71615),s=a(87070),o=a(8194),l=a(579);let d=process.env.JWT_SECRET||"fallback-secret-change-me";function p(e){return i().sign({...e,isSuperAdmin:!0},d,{expiresIn:"7d"})}async function u(){let e=await (0,n.cookies)(),t=e.get("sa_token")?.value;if(!t)return null;let a=function(e){try{let t=i().verify(e,d);if(!t.isSuperAdmin)return null;return t}catch{return null}}(t);if(!a)return null;let r=await o._.superAdmin.findUnique({where:{id:a.superAdminId}});return r&&r.isActive?r:null}async function c(e){let t=await u();return t?(0,l.Fs)(t.role,e)?{superAdmin:t,error:null}:{superAdmin:null,error:s.NextResponse.json({error:"Anda tidak memiliki akses untuk fitur ini"},{status:403})}:{superAdmin:null,error:s.NextResponse.json({error:"Tidak terautentikasi"},{status:401})}}},579:(e,t,a)=>{a.d(t,{Fs:()=>n,j$:()=>r});let r=Object.values({SUPERADMIN:"superadmin",ADMIN:"admin",FINANCE:"finance",SUPPORT:"support",CONTENT:"content",VIEWER:"viewer"}),i={superadmin:["dashboard:read","plans:read","plans:write","tenants:read","tenants:write","subscriptions:read","subscriptions:write","payment_settings:read","payment_settings:write","withdrawals:read","withdrawals:write","tickets:read","tickets:write","cms:read","cms:write","staff:read","staff:write","affiliates:read","affiliates:write","email_settings:read","email_settings:write"],admin:["dashboard:read","plans:read","plans:write","tenants:read","tenants:write","subscriptions:read","subscriptions:write","payment_settings:read","payment_settings:write","withdrawals:read","withdrawals:write","tickets:read","tickets:write","cms:read","cms:write","affiliates:read","affiliates:write","email_settings:read","email_settings:write"],finance:["dashboard:read","subscriptions:read","payment_settings:read","payment_settings:write","withdrawals:read","withdrawals:write","affiliates:read"],support:["dashboard:read","tenants:read","tickets:read","tickets:write"],content:["dashboard:read","cms:read","cms:write"],viewer:["dashboard:read"]};function n(e,t){let a=i[e];return!!a&&a.includes(t)}}};var t=require("../../../../../webpack-runtime.js");t.C(e);var a=e=>t(t.s=e),r=t.X(0,[8948,5972,4261,5245],()=>a(66326));module.exports=r})();