"use strict";(()=>{vare={};e.id=9785,e.ids=[9785],e.modules={39908:e=>{e.exports=require("@moduletrace/datasquirel/dist/users/user-auth")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},72583:e=>{e.exports=require("sanitize-html")},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")},92145:(e,r,i)=>{i.r(r),i.d(r,{config:()=>m,default:()=>u,routeModule:()=>_});vart={};i.r(t),i.d(t,{default:()=>o});vara=i(89947),s=i(2706),n=i(96762),d=i(69842),l=i(49941);asyncfunctiono(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});leti=await(0,d.A)(e,r,!0);if(!i)returnr.json({success:!1,msg:"Unauthorized"});console.log("Invitation Received by current logged in user, Loggin in VIA API ...");lett=await(0,l.A)({query:e.body.query,user:i});r.json({success:!0,result:t})}letu=(0,n.M)(t,"default"),m=(0,n.M)(t,"config"),_=newa.PagesAPIRouteModule({definition:{kind:s.A.PAGES_API,page:"/api/addAdminUserUser",pathname:"/api/addAdminUserUser",bundlePath:"",filename:""},userland:t})},69842:(e,r,i)=>{i.d(r,{A:()=>s});vart=i(39908),a=i.n(t);asyncfunctions(e,r,i){lett=a()({req:e,level:i?"deep":void0});returnconsole.log(t),t.payload}},49941:(e,r,i)=>{i.d(r,{A:()=>d});vart=i(67619),a=i(48786),s=i(98e3),n=i(62050);asyncfunctiond({query:e,user:r,useLocal:i}){try{lett=i?n.A:a.A,{invite:d,database_access:l,priviledge:o,email:u}=e,m=[d,u],_=awaitt("SELECT date_created_code FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",m);if(!_||!_[0])throwError("No Invitation Found");letc=[d],g=awaitt("SELECT first_name,last_name,email FROM users WHERE id=?",c);if(g?.[0]){lete=awaitt("SELECT email FROM user_users WHERE user_id=? AND invited_user_id=? AND user_type='admin' AND email=?",[d,r.id,u]);if(e?.[0])console.log("User already added");else{(0,s.A)({dbFullName:"datasquirel",tableName:"user_users",data:{user_id:d,invited_user_id:r.id,database_access:l,first_name:r.first_name,last_name:r.last_name,phone:r.phone,email:r.email,username:r.username,user_type:"admin",user_priviledge:o,image:r.image,image_thumbnail:r.image_thumbnail},useLocal:i});lete=awaitt("SELECT db_tables_data FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",[d,u]);if(awaitt("DELETE FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=?",[d,r.id]),e&&e[0]){lett=e[0].db_tables_data.split("|");for(lete=0;e<t.length;e++){let[a,n]=t[e].split("-");await(0,s.A)({dbFullName:"datasquirel",tableName:"delegated_user_tables",data:{delegated_user_id:r.id,root_user_id:d,database:a,table:n,priviledge:o},useLocal:i})}}}awaitt("UPDATE invitations SET invitation_status='Accepted' WHERE inviting_user_id=? AND invited_user_email=?",[d,u])}}catch(e){(0,t.A)({component:"addAdminUserOnLogin",message:e.message,user:r})}}},67619:(e,r,i)=>{i.d(r,{A:()=>s});vart=i(29021),a=i.n(t);asyncfunctions({user:e,message:r,component:i,noMail:t,req:s}){letn=newDate,d=(()=>{if(!s)returnnull;try{lete=s.headers["x-forwarded-for"],r=s.headers["x-real-ip"],i=s.headers["cf-connecting-ip"],t=Array.isArray(e)?e[0]:e?.split(",")[0],a=i||t||r||s.socket.remoteAddress;if(!a)returnnull;returnString(a)}catch(e){returnnull}})();try{lett=`🚀 SERVER ERROR ===========================