"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),a=t(2706),o=t(96762),i=t(51348),l=t.n(i),c=t(17662),u=t.n(c),p=t(48225),d=t.n(p),_=t(6420),S=t.n(_),f=t(33873),m=t.n(f),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=awaitS()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{first_name:s,last_name:n,image:a}=e.body;try{lete=(awaitl()(`SELECT image FROM users WHERE id='${t.id}'`))[0].image===a,o=process.env.DSQL_STATIC_SERVER_DIR;if(!o)throwconsole.log("Static File ENV not Found!"),Error("No Static Path!");leti=m().join(o,`images/user-images/user-${t.id}/user-${t.id}-profile.jpg`),c=m().join(o,`images/user-images/user-${t.id}/user-${t.id}-profile-thumbnail.jpg`);e||(awaitu()({imageSourceUrl:"string"==typeofa?a:a.imageBase64,imageWritePath:i,sourceType:"string"==typeofa?"url":"base64"}),awaitu()({imageSourceUrl:"string"==typeofa?a:a.imageBase64,imageWritePath:c,maxSize:250,sourceType:"string"==typeofa?"url":"base64"}),(0,g.execSync)(`chmod 644 ${i}${c}`));letp=i.replace(o,process.env.DSQL_STATIC_HOST||""),d=c.replace(o,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,o.M)(s,"default"),v=(0,o.M)(s,"config"),L=newn.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/updateUser",pathname:"/api/updateUser",bundlePath:"",filename:""},userland:s})},17662:(e,r,t)=>{lets=t(34229),n=t(9288),a=t(48225);e.exports=asyncfunction({imageSourceUrl:e,imageWritePath:r,maxSize:t,sourceType:o}){try{asyncfunctioni(){letr;if(o?.match("url")){if(e.match(/^http/i)){lett=awaits(e,{});r=awaitt.buffer()}elser=`./public${e}`}elseo?.match("base64")&&(r=Buffer.from(e,"base64"));returnr}leta=awaiti(),l=t||650,c=n(a),{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){a({component:"functions/backend/fsWriteImageToDisk",message:e.message})}}},6420:(e,r,t)=>{t(81630);lets=t(51348),n=t(72835),a=t(29021),o=t(31341);asyncfunctioni(e,r,t,i){let{keyCookieName:l,csrfCookieName:c}=o();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&&!a.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