"use strict";(()=>{var e={};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:()=>_});var t={};i.r(t),i.d(t,{default:()=>o});var a=i(89947),s=i(2706),n=i(96762),d=i(69842),l=i(49941);async function o(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let i=await (0,d.A)(e,r,!0);if(!i)return r.json({success:!1,msg:"Unauthorized"});console.log("Invitation Received by current logged in user, Loggin in VIA API ...");let t=await (0,l.A)({query:e.body.query,user:i});r.json({success:!0,result:t})}let u=(0,n.M)(t,"default"),m=(0,n.M)(t,"config"),_=new a.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});var t=i(39908),a=i.n(t);async function s(e,r,i){let t=a()({req:e,level:i?"deep":void 0});return console.log(t),t.payload}},49941:(e,r,i)=>{i.d(r,{A:()=>d});var t=i(67619),a=i(48786),s=i(98e3),n=i(62050);async function d({query:e,user:r,useLocal:i}){try{let t=i?n.A:a.A,{invite:d,database_access:l,priviledge:o,email:u}=e,m=[d,u],_=await t("SELECT date_created_code FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",m);if(!_||!_[0])throw Error("No Invitation Found");let c=[d],g=await t("SELECT first_name,last_name,email FROM users WHERE id=?",c);if(g?.[0]){let e=await t("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});let e=await t("SELECT db_tables_data FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",[d,u]);if(await t("DELETE FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=?",[d,r.id]),e&&e[0]){let t=e[0].db_tables_data.split("|");for(let e=0;e{i.d(r,{A:()=>s});var t=i(29021),a=i.n(t);async function s({user:e,message:r,component:i,noMail:t,req:s}){let n=new Date,d=(()=>{if(!s)return null;try{let e=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)return null;return String(a)}catch(e){return null}})();try{let t=`🚀 SERVER ERROR =========================== Error Message: ${r} Component: ${i}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(t+=` User Id: ${e?.id} User Name: ${e?.first_name} ${e?.last_name} User Email: ${e?.email}`),s?.url&&(t+=` URL: ${s.url}`),s?.body&&(t+=` Request Body: ${JSON.stringify(s.body,null,4)}`),d&&(t+=` IP: ${d}`),t+=` Date: ${n.toDateString()} ========================================`,a().existsSync("./.tmp/error.log")||a().writeFileSync("./.tmp/error.log","","utf-8");let l=a().readFileSync("./.tmp/error.log","utf-8");a().writeFileSync("./.tmp/error.log",t),a().appendFileSync("./.tmp/error.log",` ${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}}};var r=require("../../webpack-api-runtime.js");r.C(e);var i=e=>r(r.s=e),t=r.X(0,[1251],()=>i(92145));module.exports=t})();