"use strict";exports.id=4385,exports.ids=[4385],exports.modules={14385:(e,a,t)=>{lets=t(29021),r=t(59474),i=t(33873),l=t(5194),n=t(57638),o=t(20503),d=t(47670),u=t(86041);e.exports=asyncfunction({database:e,social_id:a,email:t,social_platform:c,payload:_,invitation:m,supEmail:p,additionalFields:g,useLocal:E}){try{letS=[a.toString(),c],f=awaitn({database:e||"datasquirel",queryString:"SELECT * FROM users WHERE social_id = ? AND social_login='1' AND social_platform = ? ",queryValuesArray:S,useLocal:E});if(f&&f[0])returnawaitu({user:f[0],social_platform:c,invitation:m,database:e,additionalFields:g,useLocal:E});lety=t||p||null;if(!y)return{success:!1,payload:null,msg:"No Email Present"};letb=`SELECT * FROM users WHERE email='${y}'`,D=awaitn({database:e||"datasquirel",queryString:b,useLocal:E});if(D&&D[0])return{success:!1,payload:null,msg:"This Email is already taken"};leth=[y,c,a],R=awaitn({database:e||"datasquirel",queryString:"SELECT * FROM users WHERE email=? AND social_login='1' AND social_platform=? AND social_id=?",queryValuesArray:h,useLocal:E});if(R&&R[0])returnawaitu({user:_,social_platform:c,invitation:m,database:e,additionalFields:g,useLocal:E});letA=o({data:a.toString()}),v={social_login:"1",verification_status:p?"0":"1",password:A};Object.keys(_).forEach(e=>{v[e]=_[e]});letL=awaitd({dbContext:e?"Dsql User":void0,paradigm:e?"Full Access":void0,dbFullName:e||"datasquirel",tableName:"users",duplicateColumnName:"email",duplicateColumnValue:y,data:{...v,email:y},useLocal:E});if(!L?.insertId)returnconsole.log("Social User Failed to insert in 'handleSocialDb.js' backend function =>",L),{success:!1,payload:null,msg:"Social User Failed to insert in 'handleSocialDb.js' backend function"};{e||awaitl({userId:L.insertId,useLocal:E});leta=`SELECT * FROM users WHERE id='${L.insertId}'`,t=awaitn({database:e||"datasquirel",queryString:a,useLocal:E});if(!t||!t[0])return{success:!1,payload:null,msg:"User Insertion Failed!"};if(p&&e?.match(/^datasquirel$/)){lete=o({data:JSON.stringify({id:L.insertId,email:p,dateCode:Date.now()})});r({to:p,subject:"Verify Email Address",text:"Please click the link to verify your email address",html:s.readFileSync("./email/send-email-verification-link.html","utf8").replace(/{{host}}/,process.env.DSQL_HOST||"").replace(/{{token}}/,e||"")}).then(e=>{})}letd=process.env.DSQL_STATIC_SERVER_DIR;if(!d)returnconsole.log("Static File ENV not Found!"),{success:!1,payload:null,msg:"Static File ENV not Found!"};if(!e||e?.match(/^datasquirel$/)){lete=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${L.insertId}`,a=i.join(d,`images/user-images/user-${L.insertId}`);s.mkdirSync(e),s.mkdirSync(a),s.writeFileSync(`${e}/main.json`,JSON.stringify([]),"utf8")}returnawaitu({user:t[0],social_platform:c,invitation:m,database:e,additionalFields:g,useLocal:E})}}catch(e){returnconsole.log("ERROR in 'handleSocialDb.js' backend function =>",e.message),{success:!1,payload:null,msg:e.message}}}},86041:(e,a,t)=>{lets=t(44767),{ServerResponse:r}=t(81630),i=t(57638);asyncfunctionl({user:e,social_platform:a,invitation:t,database:r,additionalFields:l,useLocal:n}){leto=[e.email,e.social_id,a],d=awaiti({database:r||"datasquirel",queryString:"SELECT * FROM users WHERE email=? AND social_id=? AND social_platform=?",queryValuesArray:o,useLocal:n});if(!d?.[0])return{success:!1,payload:null};letu=Math.random().toString(36).substring(2)+"-"+Math.random().toString(36).substring(2),c={id:d[0].id,first_name:d[0].first_name,last_name:d[0].last_name,username:d[0].username,user_type:d[0].user_type,email:d[0].email,social_id:d[0].social_id,image:d[0].image,image_thumbnail:d[0].image_thumbnail,verification_status:d[0].verification_status,social_login:d[0].social_login,social_platform:d[0].social_platform,csrf_k:u,logged_in_status:!0,date:Date.now()};returnl?.[0]&&l.forEach(e=>{c[e]=d[0][e]}),t&&(!r||r?.match(/^datasquirel$/))&&s({query:t,user:c,useLocal:n}),{success:!0,payload:c,csrf:u}}t(20503),t(31341),e.exports=l},44767:(e,a,t)=>{lets=t(48225),r=t(51348),i=t(47670),l=t(44900);e.exports=asyncfunction({query:e,us