"use strict";(()=>{vare={};e.id=3040,e.ids=[3040],e.modules={27825:e=>{e.exports=require("lodash")},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")},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(){returnfunctione(r,t){returntinr?r[t]:"then"inr&&"function"==typeofr.then?r.then(r=>e(r,t)):"function"==typeofr&&"default"===t?r:void0}}})},0:(e,r,t)=>{t.r(r),t.d(r,{config:()=>y,default:()=>h,routeModule:()=>D});vars={};t.r(s),t.d(s,{default:()=>g});varn=t(89947),o=t(2706),a=t(96762),i=t(2258),l=t.n(i),u=t(48225),c=t.n(u),d=t(6420),_=t.n(d),p=t(27825),f=t.n(p),S=t(51348),E=t.n(S);t(29021),t(33873);let{execSync:m}=t(79646);asyncfunctiong(e,r){if("GET"!==e.method)returnr.json({msg:"Failed!"});lett=await_()(e,r);if(!t)returnr.json({success:!1,msg:"Unauthorized"});lets=e.query.dbUserId;e.query.delegated;try{if(!s)throwError("No Root user Id Found!");lete=awaitE()("SELECT * FROM datasquirel.delegated_user_tables WHERE delegated_user_id=? AND root_user_id=?",[String(t.id),String(s)]),n=l()({userId:String(s)});if(!n)throwError("Root user schema not found!");leto=[];e.forEach(e=>{letr=o.findIndex(r=>r.dbSlug===e.database),t=n.find(r=>r.dbSlug===e.database);if(t){lets=o[r]?o[r]:{...t,tables:[]},n=f().cloneDeep(t.tables).find(r=>r.tableName===e.table);n&&o[r]?o[r]={...s,tables:[...o[r].tables,n]}:n&&!o[r]&&o.push({...t,tables:[n]})}}),r.json({success:!0,payload:o})}catch(e){console.log("ERROR:",e.message),c()({component:"/api/get-authorized-databases",message:e.message,user:t}),r.json({success:!1,msg:e.message})}}leth=(0,a.M)(s,"default"),y=(0,a.M)(s,"config"),D=newn.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/get-authorized-databases",pathname:"/api/get-authorized-databases",bundlePath:"",filename:""},userland:s})},6420:(e,r,t)=>{t(81630);lets=t(51348),n=t(72835),o=t(29021),a=t(31341);asyncfunctioni(e,r,t,i){let{keyCookieName:l,csrfCookieName:u}=a();if(!e.cookies?.[l]?.match(/./))returnnull;letc=n({encryptedString:e.cookies[l]});if(!c)returnnull;letd=JSON.parse(c);if(!d.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${d.csrf_k}`)))returnnull;let_=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!_)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(t&&!o.existsSync(`${_}/${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",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+=t;leti=r;e?.userId&&(i+=`user_${e.userId}_`),o&&(i+=`${o}_`),i+=s;letl=r;returne?.userId&&(l+=`user_${e.userId}_`),o&&(l+=`${o}_`),{keyCookieName:a,csrfCookieName:i,oneTimeCodeName:l+=n}}},2258:(e,r,t)=>{lets=t(48225),n=t(29021),o=t(33873);e.exports=function({userId:e}){try{letr=o.resolve(process.cwd(),`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${e}/main.json`);returnJSON.parse(n.readFileSync(r,"utf-8"))}catch(e){returns({component:"grabUserSchemaData",message:e.message}),null}}},48225:(e,r,t)=>{lets=t(29021),{IncomingMessage:n}=t(81630);e.exports=asyncfunction({user:e,message:r,component:t,noMail:n,req:o}){leta=newDate,i=(()=>{if(!o)returnnull;try{lete=o.headers["x-forwarded-for"],r=o.headers["x-real-ip"],t=o.headers["cf-connecting-ip"],s=A