"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,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){returnfunctione(t,r){returnrint?t[r]:"then"int&&"function"==typeoft.then?t.then(t=>e(t,r)):"function"==typeoft&&"default"===r?t:void0}}})},53382:(e,t,r)=>{r.r(t),r.d(t,{config:()=>S,default:()=>m,routeModule:()=>g});varn={};r.r(n),r.d(n,{default:()=>_});vars=r(89947),a=r(2706),l=r(96762),i=r(30802),o=r(67619),c=r(69842),u=r(30944);letd=r(29021),p=r(21820);r(33873);let{execSync:f}=r(79646);asyncfunction_(e,t){if("POST"!==e.method)returnt.json({msg:"Failed!"});letr=await(0,c.A)(e,t,!0);if(!r)returnt.json({success:!1,msg:"Unauthorized"});let{id:n,db_name:s,db_slug:a,db_description:l,db_image:_,db_full_name:m,active_clone:S,active_clone_parent_db:g}=e.body;m?.match(/datasquirel_user_.*/)||t.json({success:!1,msg:"Unauthorized"});lety=`datasquirel_user_${r.id}_${a}`;if(await(0,i.A)({dbFullName:"datasquirel",tableName:"user_databases",identifierColumnName:"id",identifierValue:n,data:{db_name:s,db_slug:a,db_description:l,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",t=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`});letr={cwd:process.cwd()};p.platform().match(/win/i)&&(r.shell="bash.exe");letn=`${t} -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 => ${n}`),f(n,r),f(`${e} -u ${process.env.DSQL_DB_USERNAME} -h ${process.env.DSQL_DB_HOST} -p${process.env.DSQL_DB_PASSWORD}${y} < tmpDbFile.sql`,r),await(0,u.A)({queryString:`DROP DATABASE \`${m}\``})}catch(e){(0,o.default)({component:"/api/updateUserDatabase/lines-88-111",message:e.message,user:r})}}try{lete=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${r.id}/main.json`,n=JSON.parse(d.readFileSync(e,"utf8")),i=n.filter(e=>e.dbFullName===m);if(i[0].dbName=s,i[0].dbFullName=y,i[0].dbDescription=l,i[0].dbImage=_,i[0].dbSlug=a,S){lete=n.filter(e=>e.dbFullName===i[0].childDatabaseDbFullName)[0],t=e.childrenDatabases?.find(e=>e.dbFullName===m);t&&(t.dbFullName=y)}d.writeFileSync(`${e}`,JSON.stringify(n),"utf8"),t.json({success:!0})}catch(e){(0,o.default)({component:"/api/updateUserDatabase/main-catch-error",message:e.message,user:r}),t.json({success:!1,msg:"Database Files could not be written!"})}}letm=(0,l.M)(n,"default"),S=(0,l.M)(n,"config"),g=news.PagesAPIRouteModule({definition:{kind:a.A.PAGES_API,page:"/api/updateUserDatabase",pathname:"/api/updateUserDatabase",bundlePath:"",filename:""},userland:n})},69842:(e,t,r)=>{r.d(t,{A:()=>o});varn=r(48786),s=r(95969),a=r(29021),l=r.n(a),i=r(89159);asyncfunctiono(e,t,r){let{keyCookieName:a,csrfCookieName:o}=(0,i.A)();if(!e.cookies?.[a]?.match(/./))returnnull;letc=(0,s.A)({encryptedString:e.cookies[a]});if(!c)returnnull;letu=JSON.parse(c);if(!u.csrf_k||r&&!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(r&&!l().existsSync(`${d}/${u.csrf_k}`))returnnull;if(0==u.verification_status&&!r){lete=await(0,n.A)(`SELECT verification_status FROM users WHERE id='${u.id}'`);e&&e[0]&&1==e[0].verification_status&&t.setHeader("Set-Cookie",["user_refresh=1"])}returnu?.date&&Date.now()-u.date>6048e5?null:u}},89159:(e,t,r