"use strict";exports.id=3704,exports.ids=[3704],exports.modules={83704:(e,a,t)=>{t.d(a,{A:()=>g});vars=t(29021),r=t.n(s),i=t(96052),l=t(33873),n=t.n(l),o=t(67580),d=t(30944),u=t(68829),c=t(98e3),m=t(49941);asyncfunction_({user:e,social_platform:a,invitation:t,database:s,additionalFields:r,useLocal:i}){letl=s||"datasquirel",n=`SELECT * FROM \`${l}\`.\`users\` WHERE email=? AND social_id=? AND social_platform=?`,o=[e.email,e.social_id,a],u=await(0,d.A)({database:l,queryString:n,queryValuesArray:o,useLocal:i});if(!u?.[0])return{success:!1,payload:null};letc=Math.random().toString(36).substring(2)+"-"+Math.random().toString(36).substring(2),_={id:u[0].id,first_name:u[0].first_name,last_name:u[0].last_name,username:u[0].username,user_type:u[0].user_type,email:u[0].email,social_id:u[0].social_id,image:u[0].image,image_thumbnail:u[0].image_thumbnail,verification_status:u[0].verification_status,social_login:u[0].social_login,social_platform:u[0].social_platform,csrf_k:c,logged_in_status:!0,date:Date.now()};returnr?.[0]&&r.forEach(e=>{_[e]=u[0][e]}),t&&(!s||s?.match(/^datasquirel$/))&&(0,m.A)({query:t,user:_,useLocal:i}),{success:!0,payload:_,csrf:c}}asyncfunctiong({database:e,social_id:a,email:t,social_platform:s,payload:l,invitation:m,supEmail:g,additionalFields:p,useLocal:E}){try{lety=[a.toString(),s],A=await(0,d.A)({database:e||"datasquirel",queryString:"SELECT * FROM datasquirel.users WHERE social_id = ? AND social_login='1' AND social_platform = ? ",queryValuesArray:y,useLocal:E});if(A&&A[0])returnawait_({user:A[0],social_platform:s,invitation:m,database:e,additionalFields:p,useLocal:E});letS=t||g||null;if(!S)return{success:!1,payload:null,msg:"No Email Present"};letf=`SELECT * FROM datasquirel.users WHERE email='${S}'`,b=await(0,d.A)({database:e||"datasquirel",queryString:f,useLocal:E});if(b&&b[0])return{success:!1,payload:null,msg:"This Email is already taken"};letD=[S,s,a],h=await(0,d.A)({database:e||"datasquirel",queryString:"SELECT * FROM datasquirel.users WHERE email=? AND social_login='1' AND social_platform=? AND social_id=?",queryValuesArray:D,useLocal:E});if(h&&h[0])returnawait_({user:l,social_platform:s,invitation:m,database:e,additionalFields:p,useLocal:E});letR=(0,u.A)({data:a.toString()}),v={social_login:"1",verification_status:g?"0":"1",password:R};Object.keys(l).forEach(e=>{v[e]=l[e]});letN=await(0,c.A)({dbContext:e?"Dsql User":void0,paradigm:e?"Full Access":void0,dbFullName:e||"datasquirel",tableName:"users",duplicateColumnName:"email",duplicateColumnValue:S,data:{...v,email:S},useLocal:E});if(!N?.insertId)returnconsole.log("Social User Failed to insert in 'handleSocialDb.ts' backend function =>",N),{success:!1,payload:null,msg:"Social User Failed to insert in 'handleSocialDb.ts' backend function"};{e||await(0,o.A)({userId:N.insertId,useLocal:E});leta=`SELECT * FROM datasquirel.users WHERE id='${N.insertId}'`,t=await(0,d.A)({database:e||"datasquirel",queryString:a,useLocal:E});if(!t||!t[0])return{success:!1,payload:null,msg:"User Insertion Failed!"};if(g&&e?.match(/^datasquirel$/)){lete=(0,u.A)({data:JSON.stringify({id:N.insertId,email:g,dateCode:Date.now()})});(0,i.A)({to:g,subject:"Verify Email Address",text:"Please click the link to verify your email address",html:r().readFileSync("./email/send-email-verification-link.html","utf8").replace(/{{host}}/,process.env.DSQL_HOST||"").replace(/{{token}}/,e||"")}).then(()=>{})}letl=process.env.DSQL_STATIC_SERVER_DIR;if(!l)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-${N.insertId}`,a=n().join(l,`images/user-images/user-${N.insertId}`);r().mkdirSync(e),r().mkdirSync(a),r().writeFileSync(`${e}/main.json`,JSON.stringify([]),"utf8")}returnawait_({user:t[0],social_platform:s,invitation:m,database:e,additionalFields:p,useLocal:E})}}catch(e){returnconsole.log("ERROR in 'handleSocialDb.ts' backend function =>",e.message),{success:!1,payload:null,msg:e.message}}}},49941:(e,a,t)=>{t.d(a,{A:()=