"use strict";(()=>{var e={};e.id=6799,e.ids=[6799],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,s){return s in r?r[s]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,s)):"function"==typeof r&&"default"===s?r:void 0}}})},74336:(e,r,s)=>{s.r(r),s.d(r,{config:()=>d,default:()=>_,routeModule:()=>p});var t={};s.r(t),s.d(t,{default:()=>i});var n=s(89947),o=s(2706),a=s(96762),l=s(30944),c=s(67619),u=s(87369);async function i(e,r){if("POST"!==e.method)return r.json({success:!1,msg:"Wrong Method"});let s=await (0,u.A)(e);if(!s?.logged_in_status)return r.json({success:!1,log:"No Logs"});let{database:t,query:n}=e.body;e.body.user;try{let e=await (0,l.A)({database:t,queryString:n});if(!e)return r.json({success:!1,msg:"Query Failed!"});r.json({success:!0,result:e})}catch(e){console.log(e.message),(0,c.A)({component:"/api/runUserDbQuery/main-catch-error",message:e.message}),r.json({success:!1})}}let _=(0,a.M)(t,"default"),d=(0,a.M)(t,"config"),p=new n.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/admin/runUserDbQuery",pathname:"/api/admin/runUserDbQuery",bundlePath:"",filename:""},userland:t})},87369:(e,r,s)=>{s.d(r,{A:()=>o});var t=s(95969),n=s(89159);async function o(e){let{keyCookieName:r,csrfCookieName:s}=(0,n.A)(),o=`${r}_su`;if(!e.cookies?.[o])return console.log("No auth key cookie found"),null;let a=(0,t.A)({encryptedString:e.cookies[o]});if(!a)return console.log("No user payload found"),null;let l=JSON.parse(a);return l.password!==process.env.DSQL_USER_KEY?(console.log("Invalid password"),null):l.authKey!==process.env.DSQL_SPECIAL_KEY?(console.log("Invalid auth key"),null):l}},89159:(e,r,s)=>{s.d(r,{A:()=>t});function t(e){let r=process.env.DSQL_COOKIES_PREFIX||"dsql_",s=process.env.DSQL_COOKIES_KEY_NAME||"key",t=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",n=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",o=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),a=r;e?.userId&&(a+=`user_${e.userId}_`),o&&(a+=`${o}_`),a+=s;let l=r;e?.userId&&(l+=`user_${e.userId}_`),o&&(l+=`${o}_`),l+=t;let c=r;return e?.userId&&(c+=`user_${e.userId}_`),o&&(c+=`${o}_`),{keyCookieName:a,csrfCookieName:l,oneTimeCodeName:c+=n}}},43775:(e,r,s)=>{s.d(r,{A:()=>o});var t=s(95969);let n=/^id$|^uuid$|^date_created$|^date_created_code$|^date_created_timestamp$|^date_updated$|^date_updated_code$|^date_updated_timestamp$/;async function o({unparsedResults:e,tableSchema:r}){let s=[];try{for(let o=0;o<e.length;o++){let a=e[o],l=Object.keys(a);for(let e=0;e<l.length;e++){let s=l[e],o=r?.fields[e];if(s?.match(n))continue;let c=a[s];("number"==typeof c||c)&&o?.encrypted&&c?.match(/./)&&(a[s]=(0,t.A)({encryptedString:c}))}s.push(a)}return s}catch(r){return console.log("ERROR in parseDbResults Function =>",r.message),e}}},67619:(e,r,s)=>{s.d(r,{A:()=>o});var t=s(29021),n=s.n(t);async function o({user:e,message:r,component:s,noMail:t,req:o}){let a=new Date,l=(()=>{if(!o)return null;try{let e=o.headers["x-forwarded-for"],r=o.headers["x-real-ip"],s=o.headers["cf-connecting-ip"],t=Array.isArray(e)?e[0]:e?.split(",")[0],n=s||t||r||o.socket.remoteAddress;if(!n)return null;return String(n)}catch(e){return null}})();try{let t=`🚀 SERVER ERROR ===========================
Error Message: ${r}
Component: ${s}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(t+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),o?.url&&(t+=`
URL: ${o.url}`),o?.body&&(t+=`
Request Body: ${JSON.stringify(o.body,null,4)}`),l&&(t+=`
IP: ${l}`),t+=`
Date: ${a.toDateString()}
========================================`,n().existsSync("./.tmp/error.log")||n().writeFileSync("./.tmp/error.log","","utf-8");let c=n().readFileSync("./.tmp/error.log","utf-8");n().writeFileSync("./.tmp/error.log",t),n().appendFileSync("./.tmp/error.log",`




${c}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},30944:(e,r,s)=>{s.d(r,{A:()=>l});var t=s(43775),n=s(67619),o=s(7447),a=s(64292);async function l({queryString:e,queryValuesArray:r,database:s,tableSchema:l,debug:c}){let u=(0,o.A)({fa:!0});global.DSQL_USE_LOCAL&&(u=(0,o.A)({local:!0})),s?.match(/^datasquirel$/)&&(u=(0,o.A)()),c&&(console.log("varDatabaseDbHandler:query:",e),console.log("varDatabaseDbHandler:values:",r),console.log("varDatabaseDbHandler:CONNECTION:",u.getConfig()));let i=await (0,a.A)(u,e,r);if(c&&console.log("varDatabaseDbHandler:results:",i),i&&l)try{return await (0,t.A)({unparsedResults:i,tableSchema:l})}catch(e){return console.log("\x1b[31mvarDatabaseDbHandler ERROR\x1b[0m =>",s,e),(0,n.A)({component:"varDatabaseDbHandler/lines-52-53",message:e.message}),null}else if(i)return i;else return null}},95969:(e,r,s)=>{s.d(r,{A:()=>a});var t=s(55511),n=s(79428),o=s(31542);function a({encryptedString:e,encryptionKey:r,encryptionSalt:s}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let{key:a,salt:l,keyLen:c,algorithm:u,bufferAllocSize:i}=(0,o.A)({encryptionKey:r});if(!a?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!l?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let _=(0,t.scryptSync)(a,l,c),d=n.Buffer.alloc(i,0),p=(0,t.createDecipheriv)(u,_,d);try{let r=p.update(e,"hex","utf8");return r+=p.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},64292:(e,r,s)=>{async function t(e,r,s){try{if(!e)throw Error("No Connection Found!");if(!r)throw Error("Query String Required!");if("string"==typeof r){let t=await e.query(n(r),s);return JSON.parse(JSON.stringify(t))}if("object"!=typeof r)return null;{let s=[];for(let t=0;t<r.length;t++)try{let o=r[t],a=await e.query(n(o.query),o.values);s.push(JSON.parse(JSON.stringify(a)))}catch(e){console.log(`connDbHandler Query Error: ${e.message}`),s.push(null)}return s}}catch(r){return console.log(`connDbHandler Error: ${r.message}`),console.log(e?.config()),null}finally{e?.end()}}function n(e){return e.replace(/\n/gm,"").replace(/ {2,}/g,"").trim()}s.d(r,{A:()=>t})},7447:(e,r,s)=>{s.d(r,{A:()=>o});var t=s(9973),n=s.n(t);function o(e){return global.DSQL_USE_LOCAL||e?.local?global.DSQL_DB_CONN||n()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.ro?global.DSQL_READ_ONLY_DB_CONN||n()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.fa?global.DSQL_FULL_ACCESS_DB_CONN||n()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):global.DSQL_DB_CONN||n()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}})}},31542:(e,r,s)=>{s.d(r,{A:()=>n});var t=s(82535);function n(e){return{key:e?.encryptionKey||process.env.DSQL_ENCRYPTION_PASSWORD,keyLen:process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24,salt:e?.encryptionSalt||process.env.DSQL_ENCRYPTION_SALT,apiKey:e?.apiKey||process.env.DSQL_API_KEY,algorithm:e?.algorithm||process.env.DSQL_ENCRYPTION_ALGORITHM||"aes-192-cbc",bufferAllocSize:e?.bufferAllocSize||(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE?(0,t.A)(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},82535:(e,r,s)=>{s.d(r,{A:()=>t});function t(e,r){try{let s=Number(e);if("number"!=typeof s||isNaN(s))return 0;if(r)return Number(s.toFixed(r));return Math.round(s)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}},2706:(e,r)=>{Object.defineProperty(r,"A",{enumerable:!0,get:function(){return s}});var s=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},89947:(e,r,s)=>{e.exports=s(75600)}};var r=require("../../../webpack-api-runtime.js");r.C(e);var s=r(r.s=74336);module.exports=s})();