"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")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},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}}})},96257:(e,r,t)=>{t.r(r),t.d(r,{config:()=>p,default:()=>E,routeModule:()=>m});vars={};t.r(s),t.d(s,{default:()=>_});varn=t(89947),a=t(2706),o=t(96762),i=t(29021),l=t.n(i),u=t(48786),c=t(67619),d=t(69842),f=t(14160);asyncfunction_(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=await(0,d.A)(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");await(0,f.A)(`DROP DATABASE \`${a}\``),await(0,u.A)("DELETE FROM user_databases WHERE id = ?",[s]),await(0,u.A)("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(l().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),l().writeFileSync(`${s}`,JSON.stringify(n),"utf8"),r.json({success:!0})}catch(e){(0,c.default)({component:"/api/deleteUserDatabase/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"File Updates Failed"})}}letE=(0,o.M)(s,"default"),p=(0,o.M)(s,"config"),m=newn.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/deleteUserDatabase",pathname:"/api/deleteUserDatabase",bundlePath:"",filename:""},userland:s})},69842:(e,r,t)=>{t.d(r,{A:()=>l});vars=t(48786),n=t(95969),a=t(29021),o=t.n(a),i=t(89159);asyncfunctionl(e,r,t){try{let{keyCookieName:a,csrfCookieName:l}=(0,i.A)();if(!e.cookies?.[a]?.match(/./))throwError("Request Cookies not Found!");letu=(0,n.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&&!o().existsSync(`${d}/${c.csrf_k}`))throwError("Key not found in Auth Keys Folder!");if(0==c.verification_status&&!t){lete=await(0,s.A)(`SELECT verification_status FROM users WHERE id='${c.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}if(c?.date&&Date.now()-c.date>6048e5)throwError("Key expired!");returnc}catch(e){returnconsole.log(`userAuth Error: ${e.message}`),null}}},89159:(e,r,t)=>{t.d(r,{A:()=>s});functions(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}}},14160:(e,r,t)=>{t.d(r,{A:()=>i});vars=t(29021),n=t.n(s),a=t(67619),o=t(47546);asyncfunctioni(e){letr;"production".match(/dev/)&&n().appendFileSync("./.tmp/sqlQuery.sql",e+"\n"+Date()+"\n\n\n","utf8");try{r=await(0,o.A)(e)}catch(e){(0,a.default)({component:"noDatabaseDbHandler",message:e.message}),console.log("ERRORinn