"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")},79428:e=>{e.exports=require("buffer")},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}}})},38887:(e,r,t)=>{t.r(r),t.d(r,{config:()=>p,default:()=>m,routeModule:()=>f});vari={};t.r(i),t.d(i,{default:()=>_});vars=t(89947),n=t(2706),a=t(96762),o=t(48786),c=t(69842),u=t(33873),l=t.n(u);letd=t(29021);asyncfunction_(e,r){if("POST"!==e.method)returnr.json({success:!1,msg:"Failed!"});lett=await(0,c.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});leti=e.body;if(i.media_url?.match(/\.\./)||i.folder?.match(/\.\./)||i.id?.toString()?.match(/\.\./))returnr.json({success:!1,msg:"Error!",error:"Invalid url"});try{lete=i?.private==1,s=e?i?.media_path?.replace(/\@\/media/i,"")||i?.media_url.replace(/\@\/media/i,""):i?.media_path?.match(/\/user-images\/user-.*/)||i?.media_url?.match(/\/user-images\/user-.*/),n=i.folder?`/${i.folder}`:"",a=process.env.DSQL_STATIC_SERVER_DIR;if(!a)throwconsole.log("Static File ENV not Found!"),Error("No Static Path!");letc=l().join(a,"images"),u=`${process.env.DSQL_STATIC_HOST}/images/user-images/user-${t.id}`,_=`/images/user-images/user-${t.id}`,m=(e?`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/media`:c)+s,p=e?`${c}/user-images/user-${t.id}`:`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/media`;if(!d.existsSync(p))try{d.mkdirSync(p,{recursive:!0})}catch(e){console.log("LINE 88 error:",e.message)}n&&n.split("/").reduce((e,r)=>{lett=e?.match(/./)?`${e}/${r}`:p;returnd.existsSync(t)||d.mkdirSync(t,{recursive:!0}),t},"");letf=m?.match(/[^\/]+$/)?.[0];if(!f)throwError("No File Name Detected!");letS=f.split(".")[0],E=f.split(".")[1],A=e?`${u}${n?n+"/":"/"}${f}`:`@/media${n?n+"/":"/"}${f}`,v=e?`${_}${n?n+"/":"/"}${f}`:`@/media${n?n+"/":"/"}${f}`,$=p+n+"/"+f;d.copyFileSync(m,$),d.unlinkSync(m);leth=S+"_thumbnail."+E,g=m.replace(f,h),P=e?`${u}${n?n+"/":"/"}${h}`:`@/media${n?n+"/":"/"}${h}`,y=e?`${_}${n?n+"/":"/"}${h}`:`@/media${n?n+"/":"/"}${h}`;try{d.copyFileSync(g,p+n+"/"+h),d.unlinkSync(g)}catch(e){}await(0,o.A)("UPDATE user_media SET private = ?, media_url= ?, media_thumbnail_url= ?, media_path = ?, media_thumbnail_path = ? WHERE id = ?",[e?0:1,A,P,v,y,i.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)(i,"default"),p=(0,a.M)(i,"config"),f=news.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/media/addPrivateMedia",pathname:"/api/media/addPrivateMedia",bundlePath:"",filename:""},userland:i})},69842:(e,r,t)=>{t.d(r,{A:()=>c});vari=t(48786),s=t(95969),n=t(29021),a=t.n(n),o=t(89159);asyncfunctionc(e,r,t){let{keyCookieName:n,csrfCookieName:c}=(0,o.A)();if(!e.cookies?.[n]?.match(/./))returnnull;letu=(0,s.A)({encryptedString:e.cookies[n]});if(!u)returnnull;letl=JSON.parse(u);if(!l.csrf_k||t&&!Object.keys(e.headers).find(e=>e.includes(l.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}/${l.csrf_k}`))returnnull;if(0==l.verification_status&&!t){lete=await(0,i.A)(`SELECT verification_status FROM users WHERE id='${l.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnl?.date&&Date.now()-l.date>6048e5?null:l}},89159:(e,r,t)=>{t.d(r,{A:()=>i});functioni(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",i=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",s=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",n=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_use