"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")},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")},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}}})},58240:(e,r,t)=>{t.r(r),t.d(r,{config:()=>N,default:()=>E,routeModule:()=>A});varn={};t.r(n),t.d(n,{default:()=>y});vars=t(89947),a=t(2706),i=t(96762),o=t(48786);letl=require("node-fetch");varu=t.n(l),c=t(9288),d=t.n(c),f=t(67619);asyncfunctionp({imageSourceUrl:e,imageWritePath:r,maxSize:t,sourceType:n}){try{asyncfunctions(){letr;if(n?.match("url")){if(e.match(/^http/i)){lett=awaitu()(e,{});r=awaitt.buffer()}elser=`./public${e}`}elsen?.match("base64")&&(r=Buffer.from(e,"base64"));returnr}leta=awaits(),i=t||650,o=d()(a),{width:l,height:c,format:f}=awaito.metadata();if(l&&c&&l>i){lete=i/l;o.resize(i,Math.round(c*e),{fit:"cover"})}f&&o.toFormat(f,{quality:80}),awaito.toFile(r)}catch(e){(0,f.default)({component:"functions/backend/fsWriteImageToDisk",message:e.message})}}var_=t(69842),g=t(33873),m=t.n(g),S=t(79646),h=t(30802);asyncfunctiony(e,r){if("POST"!==e.method)returnr.json({user:null,msg:"Registration Failed!"});lett=await(0,_.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{first_name:n,last_name:s,image:a}=e.body;try{lete=(await(0,o.A)(`SELECT image FROM users WHERE id='${t.id}'`))[0].image===a,i=process.env.DSQL_STATIC_SERVER_DIR;if(!i)throwconsole.log("Static File ENV not Found!"),Error("No Static Path!");letl=m().join(i,`images/user-images/user-${t.id}/user-${t.id}-profile.jpg`),u=m().join(i,`images/user-images/user-${t.id}/user-${t.id}-profile-thumbnail.jpg`);e||(awaitp({imageSourceUrl:"string"==typeofa?a:a.imageBase64,imageWritePath:l,sourceType:"string"==typeofa?"url":"base64"}),awaitp({imageSourceUrl:"string"==typeofa?a:a.imageBase64,imageWritePath:u,maxSize:250,sourceType:"string"==typeofa?"url":"base64"}),(0,S.execSync)(`chmod 644 ${l}${u}`));letc=l.replace(i,process.env.DSQL_STATIC_HOST||""),d=u.replace(i,process.env.DSQL_STATIC_HOST||"");await(0,h.A)({dbFullName:"datasquirel",tableName:"users",identifierColumnName:"id",identifierValue:t.id,data:{first_name:n,last_name:s,image:c,image_thumbnail:d}}),await(0,h.A)({dbFullName:"datasquirel",tableName:"user_users",identifierColumnName:"invited_user_id",identifierValue:t.id,data:{first_name:n,last_name:s,image:c,image_thumbnail:d}}),r.json({user:!0})}catch(e){(0,f.default)({component:"/api/updateUser/main-catch-error",message:e.message,user:t}),r.json({user:null})}}letE=(0,i.M)(n,"default"),N=(0,i.M)(n,"config"),A=news.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/updateUser",pathname:"/api/updateUser",bundlePath:"",filename:""},userland:n})},69842:(e,r,t)=>{t.d(r,{A:()=>l});varn=t(48786),s=t(95969),a=t(29021),i=t.n(a),o=t(89159);asyncfunctionl(e,r,t){try{let{keyCookieName:a,csrfCookieName:l}=(0,o.A)();if(!e.cookies?.[a]?.match(/./))throwError("Request Cookies not Found!");letu=(0,s.A)({encryptedString:e.cookies[a]});if(!u)throwError("Couldn't decrypt auth cookie!");letc=JSON.parse(u);if(!c.csrf_k)throwError("No `csrf_k` present in user Object!");if(t&&!Object.keys(e.headers).find(e=>e.includes(c.csrf_k)))throwError("Deep Auth Failed. `csrf` key not found in request headers!");letd=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!d)throwError("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable.");if(t&&!i().existsSync(`${d}/${c.csrf_k}`))throwError("Key not found in Auth Keys Folder!");if(0==c.verification_status&&!t){lete=await(0,n.A)(`SELECT verification_status FROM use