"use strict";(()=>{vare={};e.id=7214,e.ids=[7214],e.modules={75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},72583:e=>{e.exports=require("sanitize-html")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},79646:e=>{e.exports=require("child_process")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},21820:e=>{e.exports=require("os")},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}}})},53382:(e,r,t)=>{t.r(r),t.d(r,{config:()=>S,default:()=>m,routeModule:()=>g});vars={};t.r(s),t.d(s,{default:()=>_});varn=t(89947),a=t(2706),o=t(96762),i=t(30802),l=t(67619),c=t(69842),u=t(30944);letd=t(29021),p=t(21820);t(33873);let{execSync:f}=t(79646);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"});let{id:s,db_name:n,db_slug:a,db_description:o,db_image:_,db_full_name:m,active_clone:S,active_clone_parent_db:g}=e.body;m?.match(/datasquirel_user_.*/)||r.json({success:!1,msg:"Unauthorized"});lety=`datasquirel_user_${t.id}_${a}`;if(await(0,i.A)({dbFullName:"datasquirel",tableName:"user_databases",identifierColumnName:"id",identifierValue:s,data:{db_name:n,db_slug:a,db_description:o,db_image:_,db_full_name:y}}),m&&m!==y){console.log("Renaming Database");lete=p.platform().match(/win/i)?"'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysql.exe'":"mysql",r=p.platform().match(/win/i)?"'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysqldump.exe'":"mysqldump";try{await(0,u.A)({queryString:`CREATE DATABASE \`${y}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_bin`});lett={cwd:process.cwd()};p.platform().match(/win/i)&&(t.shell="bash.exe");lets=`${r} -u ${process.env.DSQL_DB_USERNAME} -h ${process.env.DSQL_DB_HOST} -p${process.env.DSQL_DB_PASSWORD}${m} > tmpDbFile.sql`;console.log(`updateUserDatabase.ts exe => ${s}`),f(s,t),f(`${e} -u ${process.env.DSQL_DB_USERNAME} -h ${process.env.DSQL_DB_HOST} -p${process.env.DSQL_DB_PASSWORD}${y} < tmpDbFile.sql`,t),await(0,u.A)({queryString:`DROP DATABASE \`${m}\``})}catch(e){(0,l.default)({component:"/api/updateUserDatabase/lines-88-111",message:e.message,user:t})}}try{lete=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/main.json`,s=JSON.parse(d.readFileSync(e,"utf8")),i=s.filter(e=>e.dbFullName===m);if(i[0].dbName=n,i[0].dbFullName=y,i[0].dbDescription=o,i[0].dbImage=_,i[0].dbSlug=a,S){lete=s.filter(e=>e.dbFullName===i[0].childDatabaseDbFullName)[0],r=e.childrenDatabases?.find(e=>e.dbFullName===m);r&&(r.dbFullName=y)}d.writeFileSync(`${e}`,JSON.stringify(s),"utf8"),r.json({success:!0})}catch(e){(0,l.default)({component:"/api/updateUserDatabase/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!"})}}letm=(0,o.M)(s,"default"),S=(0,o.M)(s,"config"),g=newn.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/updateUserDatabase",pathname:"/api/updateUserDatabase",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!");letc=(0,n.A)({encryptedString:e.cookies[a]});if(!c)throwError("Couldn't decrypt auth cookie!");letu=JSON.parse(c);if(!u.csrf_k)throwError("No `csrf_k` present in user Object!");if(t&&!Object.keys(e.headers).find(e=>e.includes(u.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}/${u.csrf_k}`))throwError("Key not found in Auth Keys Folder!");if(0==u.verification_status&&!t){lete=await(0,s.