"use strict";(()=>{vare={};e.id=2221,e.ids=[2221],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")},81630:e=>{e.exports=require("http")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){returnfunctione(r,t){returntinr?r[t]:"then"inr&&"function"==typeofr.then?r.then(r=>e(r,t)):"function"==typeofr&&"default"===t?r:void0}}})},58301:(e,r,t)=>{t.r(r),t.d(r,{config:()=>S,default:()=>_,routeModule:()=>f});vars={};t.r(s),t.d(s,{default:()=>p});vara=t(89947),n=t(2706),o=t(96762);t(39831);vari=t(48225),l=t.n(i),c=t(6420),u=t.n(c);letd=t(29021);asyncfunctionp(e,r){if("GET"!==e.method)returnr.json({msg:"Failed!"});lett=awaitu()(e,r);if(!t)returnr.json({success:!1,msg:"Unauthorized"});try{lete=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/main.json`,s=JSON.parse(d.readFileSync(e,"utf8"));r.json({success:!0,schemaData:s})}catch(e){l()({component:"/api/getUserSchemaData/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Couldn't read schema data"})}}let_=(0,o.M)(s,"default"),S=(0,o.M)(s,"config"),f=newa.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/getUserSchemaData",pathname:"/api/getUserSchemaData",bundlePath:"",filename:""},userland:s})},39831:(e,r,t)=>{t(81630);lets=t(72835);e.exports=asyncfunction({request:e,databaseSlug:r,user:t,query:a}){try{letn=t.id,o=null;if(!a?.delegated)return{dbUserId:n};leti=a.dbUserId,l=`${process.env.DSQL_USER_DB_PREFIX}${i}_${r}`,c=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${l}`;try{if(!e.cookies?.[c])throwError("Cookie not present");lett=s({encryptedString:e.cookies[c]});if(!t)throwError("Invalid Token");if((o=JSON.parse(t)).databaseSlug===r)return{dbUserId:n=o.rootUserId,rootUserId:o.rootUserId,rootUserName:o.rootUserName,rootUserEmail:o.rootUserEmail,rootUserImage:o.rootUserImage,databaseFullName:o.databaseFullName,databaseSlug:o.databaseSlug,allowedTables:o.allowedTables,priviledges:o.priviledges,database:o.databaseSlug,delegated:!0}}catch(e){}return{dbUserId:n}}catch(e){returnnull}}},6420:(e,r,t)=>{t(81630);lets=t(51348),a=t(72835),n=t(29021),o=t(31341);asyncfunctioni(e,r,t,i){let{keyCookieName:l,csrfCookieName:c}=o();if(!e.cookies?.[l]?.match(/./))returnnull;letu=a({encryptedString:e.cookies[l]});if(!u)returnnull;letd=JSON.parse(u);if(!d.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${d.csrf_k}`)))returnnull;letp=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!p)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(t&&!n.existsSync(`${p}/${d.csrf_k}`))returnnull;if(0==d.verification_status&&!t){lete=awaits(`SELECT verification_status FROM users WHERE id='${d.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnd?.date&&Date.now()-d.date>6048e5?null:d}e.exports=i},31341:e=>{e.exports=function(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",s=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",a=r;e?.userId&&(a+=`user_${e.userId}_`),e?.database&&(a+=`${e.database}_`),a+=t;letn=r;returne?.userId&&(n+=`user_${e.userId}_`),e?.database&&(n+=`${e.database}_`),{keyCookieName:a,csrfCookieName:n+=s}}},48225:(e,r,t)=>{lets=t(29021),{IncomingMessage:a}=t(81630);e.exports=asyncfunction({user:e,message:r,component:t,noMail:a,req:n}){leto=newDate,i=(()=>{if(!n)returnnull;try{lete=n.headers["x-forwarded-for"],r=n.headers["x-real-ip"],t=n.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],a=t||s||r||n.socket.remoteAddress;if(!a)returnnull;returnString(a)}catch(e){returnnull}})();try{leta=`🚀 SERVER ERROR ===========================