"use strict";(()=>{vare={};e.id=5757,e.ids=[5757],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")},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}}})},96332:(e,r,t)=>{t.r(r),t.d(r,{config:()=>p,default:()=>f,routeModule:()=>m});vara={};t.r(a),t.d(a,{default:()=>_});vars=t(89947),n=t(2706),l=t(96762),i=t(30944),o=t(67619),c=t(69842),u=t(48786);letd=t(29021);asyncfunction_(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=await(0,c.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});leta=e.body,{id:s,user_id:n,table_name:l,table_slug:_,table_description:f}=a.table,{db_full_name:p}=a.database;await(0,i.A)({database:p,queryString:`DROP TABLE \`${p}\`.\`${_}\``});letm=s?[s]:[_,t.id,a.database.id];await(0,u.A)(s?"DELETE FROM user_database_tables WHERE id=?":"DELETE FROM user_database_tables WHERE table_slug=? AND user_id=? AND db_id=?",m);try{lete;leta=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/main.json`,s=JSON.parse(d.readFileSync(a,"utf8")),n=s.filter((e,r)=>{if(e.dbFullName===p)return!0}),l=n[0].tables.filter((r,t)=>{if(r?.tableName===_)returne=t,!0});if(l[0].childTable){lete;letr=s.filter(e=>e.dbFullName===l[0].childTableDbFullName)[0].tables.filter(e=>{if(e.tableName===l[0].childTableName)return!0})[0];r.childrenTables?.filter((r,t)=>{r.tableName===_&&(e=t)}),"number"==typeofe&&r.childrenTables?.splice(e,1)}if(n[0].tables.splice(e,1),n[0].childrenDatabases)for(lete=0;e<n[0].childrenDatabases.length;e++){letr=n[0].childrenDatabases[e];try{lete=s.filter(e=>e.dbFullName===r.dbFullName)[0];e.tables=n[0].tables,await(0,u.A)("DELETE FROM user_database_tables WHERE table_slug=? AND user_id=? AND db_slug=?",[_,t.id,e.dbSlug])}catch(e){(0,o.default)({component:"/api/deleteUserTable/lines-125-128",message:e.message,user:t})}}d.writeFileSync(`${a}`,JSON.stringify(s),"utf8"),r.json({success:!0})}catch(e){(0,o.default)({component:"/api/deleteUserTable/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"File Updates Failed"})}}letf=(0,l.M)(a,"default"),p=(0,l.M)(a,"config"),m=news.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/deleteUserTable",pathname:"/api/deleteUserTable",bundlePath:"",filename:""},userland:a})},69842:(e,r,t)=>{t.d(r,{A:()=>o});vara=t(48786),s=t(95969),n=t(29021),l=t.n(n),i=t(89159);asyncfunctiono(e,r,t){let{keyCookieName:n,csrfCookieName:o}=(0,i.A)();if(!e.cookies?.[n]?.match(/./))returnnull;letc=(0,s.A)({encryptedString:e.cookies[n]});if(!c)returnnull;letu=JSON.parse(c);if(!u.csrf_k||t&&!Object.keys(e.headers).find(e=>e.includes(u.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&&!l().existsSync(`${d}/${u.csrf_k}`))returnnull;if(0==u.verification_status&&!t){lete=await(0,a.A)(`SELECT verification_status FROM users WHERE id='${u.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}returnu?.date&&Date.now()-u.date>6048e5?null:u}},89159:(e,r,t)=>{t.d(r,{A:()=>a});functiona(e){letr=process.env.DSQL_COOKIES_PREFIX||"dsql_",t=process.env.DSQL_COOKIES_KEY_NAME||"key",a=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_user_\d+_/,""),l=r;e?.userId&&(l+=`user_${e.userId}_`),n&&(l+=`${n}_`),l+=t;leti=r;e?.userId&&(i+=`user_${e.userId}_`),n&&(i+=`${n}_`),i+=a;leto=r;returne?.userId&&(o+=`user_${e.userId}_`),n&&(o+=`${n}_`),{keyCookieName:l,csrfCookieName:i,oneTimeCodeName:o+=s}}},43775:(e,r,t)=>{t.d(r,{A:()=>n});vara=t(95969)