"use strict";(()=>{vare={};e.id=2678,e.ids=[2678],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},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,s){returnsinr?r[s]:"then"inr&&"function"==typeofr.then?r.then(r=>e(r,s)):"function"==typeofr&&"default"===s?r:void0}}})},10304:(e,r,s)=>{s.r(r),s.d(r,{config:()=>f,default:()=>m,routeModule:()=>E});vart={};s.r(t),s.d(t,{default:()=>S});vari=s(89947),n=s(2706),a=s(96762),o=s(51348),c=s.n(o),u=s(6420),l=s.n(u),d=s(33873),_=s.n(d);letp=s(29021);asyncfunctionS(e,r){if("POST"!==e.method)returnr.json({success:!1,msg:"Failed!"});lets=awaitl()(e,r,!0);if(!s)returnr.json({success:!1,msg:"Unauthorized"});lett=e.body;if(t.media_url?.match(/\.\./)||t.folder?.match(/\.\./)||t.id?.toString()?.match(/\.\./))returnr.json({success:!1,msg:"Error!",error:"Invalid url"});try{lete=t?.private==1,i=e?t?.media_path?.replace(/\@\/media/i,"")||t?.media_url.replace(/\@\/media/i,""):t?.media_path?.match(/\/user-images\/user-.*/)||t?.media_url?.match(/\/user-images\/user-.*/),n=t.folder?`/${t.folder}`:"",a=process.env.DSQL_STATIC_SERVER_DIR;if(!a)throwconsole.log("Static File ENV not Found!"),Error("No Static Path!");leto=_().join(a,"images"),u=`${process.env.DSQL_STATIC_HOST}/images/user-images/user-${s.id}`,l=`/images/user-images/user-${s.id}`,d=(e?`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${s.id}/media`:o)+i,S=e?`${o}/user-images/user-${s.id}`:`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${s.id}/media`;if(!p.existsSync(S))try{p.mkdirSync(S,{recursive:!0})}catch(e){console.log("LINE 88 error:",e.message)}n&&n.split("/").reduce((e,r)=>{lets=e?.match(/./)?`${e}/${r}`:S;returnp.existsSync(s)||p.mkdirSync(s,{recursive:!0}),s},"");letm=d?.match(/[^\/]+$/)?.[0];if(!m)throwError("No File Name Detected!");letf=m.split(".")[0],E=m.split(".")[1],v=e?`${u}${n?n+"/":"/"}${m}`:`@/media${n?n+"/":"/"}${m}`,h=e?`${l}${n?n+"/":"/"}${m}`:`@/media${n?n+"/":"/"}${m}`,$=S+n+"/"+m;p.copyFileSync(d,$),p.unlinkSync(d);letP=f+"_thumbnail."+E,g=d.replace(m,P),D=e?`${u}${n?n+"/":"/"}${P}`:`@/media${n?n+"/":"/"}${P}`,A=e?`${l}${n?n+"/":"/"}${P}`:`@/media${n?n+"/":"/"}${P}`;try{p.copyFileSync(g,S+n+"/"+P),p.unlinkSync(g)}catch(e){}awaitc()("UPDATE user_media SET private = ?, media_url= ?, media_thumbnail_url= ?, media_path = ?, media_thumbnail_path = ? WHERE id = ?",[e?0:1,v,D,h,A,t.id]),r.json({success:!0,msg:"Success!"})}catch(e){console.log(e.message),r.json({success:!1,msg:"Error!",error:e})}}letm=(0,a.M)(t,"default"),f=(0,a.M)(t,"config"),E=newi.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/media/addPrivateMedia",pathname:"/api/media/addPrivateMedia",bundlePath:"",filename:""},userland:t})},6420:(e,r,s)=>{s(81630);lett=s(51348),i=s(72835),n=s(29021),a=s(31341);asyncfunctiono(e,r,s,o){let{keyCookieName:c,csrfCookieName:u}=a();if(!e.cookies?.[c]?.match(/./))returnnull;letl=i({encryptedString:e.cookies[c]});if(!l)returnnull;letd=JSON.parse(l);if(!d.csrf_k||s&&!e.headers["x-csrf-auth"]?.match(RegExp(`${d.csrf_k}`)))returnnull;let_=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!_)returnconsole.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(s&&!n.existsSync(`${_}/${d.csrf_k}`))returnnull;if(0==d.verification_status&&!s){lete=awaitt(`SELECT verification_status FROM users WHERE id='${d.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnd?.date&&Date.now()-d.date>6048e5?null:d}e.exports=o},31341:e=>{e.exports=function(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",s=process.env.DSQL_COOKIES_KEY_NAME||"key",t=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",i=e?.database||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),n=r;e?.userId&&(n+=`user_${e.user