"use strict";(()=>{var e={};e.id=2434,e.ids=[2434],e.modules={53524:e=>{e.exports=require("@prisma/client")},30517:e=>{e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},25528:e=>{e.exports=require("next/dist\\client\\components\\action-async-storage.external.js")},91877:e=>{e.exports=require("next/dist\\client\\components\\request-async-storage.external.js")},25319:e=>{e.exports=require("next/dist\\client\\components\\static-generation-async-storage.external.js")},39491:e=>{e.exports=require("assert")},14300:e=>{e.exports=require("buffer")},32081:e=>{e.exports=require("child_process")},6113:e=>{e.exports=require("crypto")},9523:e=>{e.exports=require("dns")},82361:e=>{e.exports=require("events")},57147:e=>{e.exports=require("fs")},13685:e=>{e.exports=require("http")},95687:e=>{e.exports=require("https")},41808:e=>{e.exports=require("net")},22037:e=>{e.exports=require("os")},71017:e=>{e.exports=require("path")},63477:e=>{e.exports=require("querystring")},12781:e=>{e.exports=require("stream")},24404:e=>{e.exports=require("tls")},57310:e=>{e.exports=require("url")},73837:e=>{e.exports=require("util")},59796:e=>{e.exports=require("zlib")},46161:(e,t,r)=>{r.r(t),r.d(t,{headerHooks:()=>f,originalPathname:()=>w,requestAsyncStorage:()=>q,routeModule:()=>x,serverHooks:()=>h,staticGenerationAsyncStorage:()=>g,staticGenerationBailout:()=>y});var s={};r.r(s),r.d(s,{GET:()=>m,POST:()=>c}),r(95655);var i=r(83323),a=r(54647),n=r(66886),o=r(30953),u=r(3471),p=r(69542),l=r(82280);async function m(){let e=await (0,u.getServerSession)(p.L);if(!e)return new n.Z("Unauthorized",{status:401});try{let e=await o._.systemSetting.findMany({where:{key:{in:["smtp_host","smtp_port","smtp_user","smtp_pass","smtp_from","admin_emails"]}}}),t={};return e.forEach(e=>{t[e.key]=e.value}),n.Z.json(t)}catch(e){return console.error("[SETTINGS_GET]",e),new n.Z("Internal Error",{status:500})}}async function c(e){let t=await (0,u.getServerSession)(p.L);if(!t)return new n.Z("Unauthorized",{status:401});try{let r=await e.json(),{action:s,...i}=r;if("test"===s){let{to:e}=i,r=await o._.systemSetting.findUnique({where:{key:"admin_emails"}}),s=r?.value?r.value.split(",").map(e=>e.trim()):[],a=e?[e]:s;0===a.length&&t.user?.email&&a.push(t.user.email);let u=await l.y.sendEmail(a,"Test Email from MusaFoods","<h1>It Works!</h1><p>Your email configuration is correct.</p>");if(u)return n.Z.json({success:!0,message:"Test email sent successfully"});return n.Z.json({success:!1,message:"Failed to send test email"},{status:500})}let a=Object.entries(i).map(([e,t])=>o._.systemSetting.upsert({where:{key:e},update:{value:String(t)},create:{key:e,value:String(t)}}));return await o._.$transaction(a),n.Z.json({success:!0})}catch(e){return console.error("[SETTINGS_POST]",e),new n.Z("Internal Error",{status:500})}}let d=i.AppRouteRouteModule,x=new d({definition:{kind:a.x.APP_ROUTE,page:"/api/admin/settings/email/route",pathname:"/api/admin/settings/email",filename:"route",bundlePath:"app/api/admin/settings/email/route"},resolvedPagePath:"D:\\Code\\MusaFoods_New\\musafoods\\app\\api\\admin\\settings\\email\\route.ts",nextConfigOutput:"standalone",userland:s}),{requestAsyncStorage:q,staticGenerationAsyncStorage:g,serverHooks:h,headerHooks:f,staticGenerationBailout:y}=x,w="/api/admin/settings/email/route"}};var t=require("../../../../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[4650,9727,3497,6886,3330,6161,2280,9542],()=>r(46161));module.exports=s})();