"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:()=>h,default:()=>E,routeModule:()=>y});vars={};t.r(s),t.d(s,{default:()=>g});varn=t(89947),a=t(2706),o=t(96762),i=t(49827),l=t(77538),u=t.n(l),c=t(6420),d=t.n(c),f=t(27825),p=t.n(f),S=t(51348),_=t.n(S);t(29021),t(33873);let{execSync:m}=t(79646);asyncfunctiong(e,r){if("GET"!==e.method)returnr.json({msg:"Failed!"});lett=awaitd()(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=await_()("SELECT * FROM datasquirel.delegated_user_tables WHERE delegated_user_id=? AND root_user_id=?",[String(t.id),String(s)]),n=(0,i.default)({userId:String(s)});if(!n)throwError("Root user schema not found!");leta=[];e.forEach(e=>{letr=a.findIndex(r=>r.dbSlug===e.database),t=n.find(r=>r.dbSlug===e.database);if(t){lets=a[r]?a[r]:{...t,tables:[]},n=p().cloneDeep(t.tables).find(r=>r.tableName===e.table);n&&a[r]?a[r]={...s,tables:[...a[r].tables,n]}:n&&!a[r]&&a.push({...t,tables:[n]})}}),r.json({success:!0,payload:a})}catch(e){console.log("ERROR:",e.message),u()({component:"/api/get-authorized-databases",message:e.message,user:t}),r.json({success:!1,msg:e.message})}}letE=(0,o.M)(s,"default"),h=(0,o.M)(s,"config"),y=newn.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/get-authorized-databases",pathname:"/api/get-authorized-databases",bundlePath:"",filename:""},userland:s})},49827:(e,r,t)=>{t.r(r),t.d(r,{default:()=>o});lets=t(77538),n=t(29021),a=t(33873);functiono({userId:e}){try{letr=a.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:"/functions/backend/grabUserSchemaData",message:e.message}),null}}},77538:(e,r,t)=>{lets=t(29021),{IncomingMessage:n}=t(81630);e.exports=asyncfunction({user:e,message:r,component:t,noMail:n,req:a}){leto=newDate,i=(()=>{if(!a)returnnull;try{lete=a.headers["x-forwarded-for"],r=a.headers["x-real-ip"],t=a.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],n=t||s||r||a.socket.remoteAddress;if(!n)returnnull;returnString(n)}catch(e){returnnull}})();try{letn=`🚀 SERVER ERROR ===========================