"use strict";(()=>{var e={};e.id=7258,e.ids=[7258],e.modules={76102:e=>{e.exports=require("@moduletrace/datasquirel/dist/client")},39383:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/actions/users/user-auth")},65967:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson")},93726:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy")},30889:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},9973:e=>{e.exports=require("serverless-mysql")},96762:(e,s)=>{Object.defineProperty(s,"M",{enumerable:!0,get:function(){return function e(s,r){return r in s?s[r]:"then"in s&&"function"==typeof s.then?s.then(s=>e(s,r)):"function"==typeof s&&"default"===r?s:void 0}}})},45310:(e,s,r)=>{r.r(s),r.d(s,{config:()=>S,default:()=>d,routeModule:()=>l});var _={};r.r(_),r.d(_,{default:()=>u});var a=r(89947),t=r(2706),n=r(96762),o=r(48786),i=r(69842);async function u(e,s){if("GET"!==e.method)return s.json({msg:"Failed!"});let{user:r}=await (0,i.A)(e,s);if(!r)return s.json({success:!1,msg:"Unauthorized"});let _=await (0,o.A)(`
        SELECT
            user_users.user_id,user_users.database_access,user_users.user_id,user_users.user_priviledge,users.first_name,users.last_name,users.email,users.image_thumbnail
        FROM
            user_users JOIN users ON user_users.user_id=users.id
        WHERE
            user_users.invited_user_id='${r.id}'
    `),a=[];if(_&&_[0])for(let e=0;e<_.length;e++){let s=_[e],{database_access:r,user_id:t,user_priviledge:n}=s;if(!r?.match(/./))continue;let i=await (0,o.A)(`SELECT * FROM user_databases WHERE (${r.split("|").map(e=>`db_slug='${e}'`).join(" OR ")}) AND user_id=${t}`);for(let e=0;e<i.length;e++){let r=i[e];a.push({id:r.id,user_id:s.user_id,first_name:s.first_name,last_name:s.last_name,email:s.email,image_thumbnail:s.image_thumbnail,db_name:r.db_name,db_slug:r.db_slug,db_full_name:r.db_full_name,db_image:r.db_image,db_description:r.db_description,date_created:r.date_created,user_priviledge:n})}}s.json({success:!0,databases:a})}let d=(0,n.M)(_,"default"),S=(0,n.M)(_,"config"),l=new a.PagesAPIRouteModule({definition:{kind:t.A.PAGES_API,page:"/api/getDelegatedDatabases",pathname:"/api/getDelegatedDatabases",bundlePath:"",filename:""},userland:_})},55153:(e,s,r)=>{r.d(s,{On:()=>a.a,_n:()=>n}),r(76102);var _=r(65967),a=r.n(_);r(30889);var t=r(93726);let n=r.n(t)()},69842:(e,s,r)=>{r.d(s,{A:()=>n});var _=r(39383),a=r.n(_),t=r(55153);async function n(e,s,r,_){let n=a()({req:e,level:r?"deep":void 0}),o={DSQL_REMOTE_SQL_HOST:process.env.DSQL_REMOTE_SQL_HOST,DSQL_SU_USER_ID:process.env.DSQL_SU_USER_ID,DSQL_HOST_ENV:process.env.DSQL_HOST_ENV,DSQL_HOST:process.env.DSQL_HOST,DSQL_STATIC_HOST:process.env.DSQL_STATIC_HOST,DSQL_GOOGLE_CLIENT_ID:process.env.DSQL_GOOGLE_CLIENT_ID,DSQL_TINY_MCE_API_KEY:process.env.DSQL_TINY_MCE_API_KEY};return _&&n.payload?.id&&(0,t._n)(process.env.DSQL_SU_USER_ID)!==n.payload.id?{user:null,appData:o}:{user:n.payload,appData:o}}},48786:(e,s,r)=>{r.d(s,{A:()=>a});var _=r(7447);async function a(...e){let s=(0,_.A)();try{if(!s)throw Error("No Connection provided to DB_HANDLER function!");let r=await s.query(...e);return JSON.parse(JSON.stringify(r))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await s?.end()}}},7447:(e,s,r)=>{r.d(s,{A:()=>t});var _=r(9973),a=r.n(_);function t(e){return global.DSQL_USE_LOCAL||e?.local?global.DSQL_DB_CONN||a()({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||a()({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||a()({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||a()({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"}})}},2706:(e,s)=>{Object.defineProperty(s,"A",{enumerable:!0,get:function(){return r}});var r=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,s,r)=>{e.exports=r(75600)}};var s=require("../../webpack-api-runtime.js");s.C(e);var r=s(s.s=45310);module.exports=r})();