"use strict";(()=>{var e={};e.id=5989,e.ids=[5989],e.modules={27825:e=>{e.exports=require("lodash")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},79428:e=>{e.exports=require("buffer")},79646:e=>{e.exports=require("child_process")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,o){return o in r?r[o]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,o)):"function"==typeof r&&"default"===o?r:void 0}}})},89106:(e,r,o)=>{o.r(r),o.d(r,{config:()=>P,default:()=>g,routeModule:()=>S});var n={};o.r(n),o.d(n,{default:()=>_});var t=o(89947),s=o(2706),i=o(96762),u=o(33873),c=o.n(u),l=o(19131),a=o.n(l),p=o(27825),d=o.n(p);let{execSync:f}=o(79646),E=o(29021);async function _(e,r){if("POST"!==e.method)return r.json({success:!1,msg:"Wrong Method"});let o=await a()(e);if(!o?.logged_in_status)return r.json({success:!1,log:"No Logs"});try{let o=c().join(process.cwd(),".env"),n=E.readFileSync(o,"utf-8"),t=RegExp(`${d().escapeRegExp(e.body.key)}=.*`);n.match(t);let s=n.replace(t,`${e.body.key}=${e.body.value}`);E.writeFileSync(o,s,"utf-8"),r.json({success:!0})}catch(e){console.log("updating Env error =>",e.message),r.json({success:!1,error:e.message})}}let g=(0,i.M)(n,"default"),P=(0,i.M)(n,"config"),S=new t.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/admin/updateEnv",pathname:"/api/admin/updateEnv",bundlePath:"",filename:""},userland:n})},19131:(e,r,o)=>{let{IncomingMessage:n}=o(81630),t=o(72835),s=o(31341);e.exports=async function(e){let{keyCookieName:r,csrfCookieName:o}=s(),n=`${r}_su`;if(!e.cookies?.[n])return console.log("No auth key cookie found"),null;let i=t({encryptedString:e.cookies[n]});if(!i)return console.log("No user payload found"),null;let u=JSON.parse(i);return u.password!==process.env.DSQL_USER_KEY?(console.log("Invalid password"),null):u.authKey!==process.env.DSQL_SPECIAL_KEY?(console.log("Invalid auth key"),null):u}},31341:e=>{e.exports=function(){let e=process.env.DSQL_COOKIES_PREFIX||"dsql_";return{keyCookieName:e+(process.env.DSQL_COOKIES_KEY_NAME||"key"),csrfCookieName:e+(process.env.DSQL_COOKIES_CSRF_NAME||"csrf")}}},72835:(e,r,o)=>{let{scryptSync:n,createDecipheriv:t}=o(55511),{Buffer:s}=o(79428);e.exports=({encryptedString:e,encryptionKey:r,encryptionSalt:o})=>{if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let i=r||process.env.DSQL_ENCRYPTION_PASSWORD,u=o||process.env.DSQL_ENCRYPTION_SALT,c=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!i?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!u?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let l=t("aes-192-cbc",n(i,u,c),s.alloc(16,0));try{let r=l.update(e,"hex","utf8");return r+=l.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},2706:(e,r)=>{var o;Object.defineProperty(r,"A",{enumerable:!0,get:function(){return o}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(o||(o={}))},89947:(e,r,o)=>{e.exports=o(75600)}};var r=require("../../../webpack-api-runtime.js");r.C(e);var o=r(r.s=89106);module.exports=o})();