"use strict";(()=>{vare={};e.id=8925,e.ids=[8925],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},34229:e=>{e.exports=require("node-fetch")},72583:e=>{e.exports=require("sanitize-html")},9973:e=>{e.exports=require("serverless-mysql")},9288:e=>{e.exports=require("sharp")},79428:e=>{e.exports=require("buffer")},79646:e=>{e.exports=require("child_process")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){returnfunctione(r,t){returntinr?r[t]:"then"inr&&"function"==typeofr.then?r.then(r=>e(r,t)):"function"==typeofr&&"default"===t?r:void0}}})},43359:(e,r,t)=>{t.r(r),t.d(r,{config:()=>v,default:()=>y,routeModule:()=>L});vars={};t.r(s),t.d(s,{default:()=>D});varn=t(89947),o=t(2706),a=t(96762),i=t(51348),l=t.n(i),c=t(17662),u=t.n(c),p=t(48225),d=t.n(p),S=t(6420),f=t.n(S),_=t(33873),m=t.n(_),g=t(79646),E=t(33364),h=t.n(E);asyncfunctionD(e,r){if("POST"!==e.method)returnr.json({user:null,msg:"Registration Failed!"});lett=awaitf()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{first_name:s,last_name:n,image:o}=e.body;try{lete=(awaitl()(`SELECT image FROM users WHERE id='${t.id}'`))[0].image===o,a=process.env.DSQL_STATIC_SERVER_DIR;if(!a)throwconsole.log("Static File ENV not Found!"),Error("No Static Path!");leti=m().join(a,`images/user-images/user-${t.id}/user-${t.id}-profile.jpg`),c=m().join(a,`images/user-images/user-${t.id}/user-${t.id}-profile-thumbnail.jpg`);e||(awaitu()({imageSourceUrl:"string"==typeofo?o:o.imageBase64,imageWritePath:i,sourceType:"string"==typeofo?"url":"base64"}),awaitu()({imageSourceUrl:"string"==typeofo?o:o.imageBase64,imageWritePath:c,maxSize:250,sourceType:"string"==typeofo?"url":"base64"}),(0,g.execSync)(`chmod 644 ${i}${c}`));letp=i.replace(a,process.env.DSQL_STATIC_HOST||""),d=c.replace(a,process.env.DSQL_STATIC_HOST||"");awaith()({dbFullName:"datasquirel",tableName:"users",identifierColumnName:"id",identifierValue:t.id,data:{first_name:s,last_name:n,image:p,image_thumbnail:d}}),awaith()({dbFullName:"datasquirel",tableName:"user_users",identifierColumnName:"invited_user_id",identifierValue:t.id,data:{first_name:s,last_name:n,image:p,image_thumbnail:d}}),r.json({user:!0})}catch(e){d()({component:"/api/updateUser/main-catch-error",message:e.message,user:t}),r.json({user:null})}}lety=(0,a.M)(s,"default"),v=(0,a.M)(s,"config"),L=newn.PagesAPIRouteModule({definition:{kind:o.A.PAGES_API,page:"/api/updateUser",pathname:"/api/updateUser",bundlePath:"",filename:""},userland:s})},17662:(e,r,t)=>{lets=t(34229),n=t(9288),o=t(48225);e.exports=asyncfunction({imageSourceUrl:e,imageWritePath:r,maxSize:t,sourceType:a}){try{asyncfunctioni(){letr;if(a?.match("url")){if(e.match(/^http/i)){lett=awaits(e,{});r=awaitt.buffer()}elser=`./public${e}`}elsea?.match("base64")&&(r=Buffer.from(e,"base64"));returnr}leto=awaiti(),l=t||650,c=n(o),{width:u,height:p,format:d}=awaitc.metadata();if(u&&p&&u>l){lete=l/u;c.resize(l,Math.round(p*e),{fit:"cover"})}d&&c.toFormat(d,{quality:80}),awaitc.toFile(r)}catch(e){o({component:"functions/backend/fsWriteImageToDisk",message:e.message})}}},6420:(e,r,t)=>{t(81630);lets=t(51348),n=t(72835),o=t(29021),a=t(31341);asyncfunctioni(e,r,t,i){let{keyCookieName:l,csrfCookieName:c}=a();if(!e.cookies?.[l]?.match(/./))returnnull;letu=n({encryptedString:e.cookies[l]});if(!u)returnnull;letp=JSON.parse(u);if(!p.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${p.csrf_k}`)))returnnull;letd=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!d)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(t&&!o.existsSync(`${d}/${p.csrf_k}`))returnnull;if(0==p.verification_status&&!t){lete=awaits(`SELECT verification_status FROM users WHERE id='${p.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnp?.date&&Date.now()-p.date>6048e5