"use strict";(()=>{vare={};e.id=3e3,e.ids=[3e3],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")},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}}})},47389:(e,r,t)=>{t.r(r),t.d(r,{config:()=>D,default:()=>m,routeModule:()=>g});vars={};t.r(s),t.d(s,{default:()=>E});varn=t(89947),a=t(2706),o=t(96762),i=t(51348),l=t.n(i),c=t(48225),u=t.n(c),d=t(6420),_=t.n(d),p=t(51926),f=t.n(p);letS=t(29021);asyncfunctionE(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=await_()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{id:s,db_slug:n,db_full_name:a}=e.body;if(!a.match(`user_${t.id}_`))throwError("Database doesn't belong to user");awaitf()(`DROP DATABASE \`${a}\``),awaitl()("DELETE FROM user_databases WHERE id = ?",[s]),awaitl()("DELETE FROM user_users WHERE user_id = ? AND `database` = ?",[t.id,n]);try{lete;lets=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/main.json`,n=JSON.parse(S.readFileSync(s,"utf8")),o=n.filter((r,t)=>{if(r.dbFullName===a)returne=t,!0});if(o[0].childDatabase){lete=n.filter(e=>e.dbFullName===o[0].childDatabaseDbFullName)[0],r=e.childrenDatabases?.findIndex(e=>e.dbFullName===o[0].childDatabaseDbFullName);e.childrenDatabases&&"number"==typeofr&&e.childrenDatabases.splice(r,1)}n.splice(e,1),S.writeFileSync(`${s}`,JSON.stringify(n),"utf8"),r.json({success:!0})}catch(e){u()({component:"/api/deleteUserDatabase/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"File Updates Failed"})}}letm=(0,o.M)(s,"default"),D=(0,o.M)(s,"config"),g=newn.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/deleteUserDatabase",pathname:"/api/deleteUserDatabase",bundlePath:"",filename:""},userland:s})},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;letd=JSON.parse(u);if(!d.csrf_k||t&&!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(t&&!a.existsSync(`${_}/${d.csrf_k}`))returnnull;if(0==d.verification_status&&!t){lete=awaits(`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=i},31341:e=>{e.exports=function(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",s=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",n=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",a=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),o=r;e?.userId&&(o+=`user_${e.userId}_`),a&&(o+=`${a}_`),o+=t;leti=r;e?.userId&&(i+=`user_${e.userId}_`),a&&(i+=`${a}_`),i+=s;letl=r;returne?.userId&&(l+=`user_${e.userId}_`),a&&(l+=`${a}_`),{keyCookieName:o,csrfCookieName:i,oneTimeCodeName:l+=n}}},51926:(e,r,t)=>{lets=t(29021),n=t(48225),a=t(45356);e.exports=asyncfunction(e){letr;"production".match(/dev/)&&s.appendFileSync("./.tmp/sqlQuery.sql",e+"\n"+Date()+"\n\n\n","utf8");try{r=awaita(e)}catch(e){n({component:"noDatabaseDbHandler",message:e.message}),console.log("ERROR in noDatabaseDbHandler =>",e.message)}returnr||null}},48225:(e,r,t)=>{lets=t(29021),{IncomingMessage:n}=t(81630);e.exports=asyncfunction({user:e,message:r,component:t,noMail:n,req:a}){leto=newDate,i=(()=>{if(!a)returnnull;try{lete=a.headers["x-forwarded-for"],r=a.headers["x-real-ip"],t=a