"use strict";(()=>{vare={};e.id=8675,e.ids=[8675],e.modules={27825:e=>{e.exports=require("lodash")},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")},81630:e=>{e.exports=require("http")},21820:e=>{e.exports=require("os")},33873:e=>{e.exports=require("path")},75588:(e,t,r)=>{r.r(t),r.d(t,{config:()=>h,default:()=>g,routeModule:()=>y});vara={};r.r(a),r.d(a,{default:()=>S});vars=r(89947),l=r(2706),n=r(96762),i=r(72350),o=r.n(i),u=r(48225),c=r.n(u),d=r(6420),p=r.n(d);letm=r(29021),_=r(21820),{execSync:f}=r(79646);asyncfunctionS(e,t){if("POST"!==e.method)returnt.json({msg:"Failed!"});letr=awaitp()(e,t,!0);if(!r)returnt.json({success:!1,msg:"Unauthorized"});let{database:a,fileBase64:s}=e.body;a?.db_full_name?.match(/datasquirel_user_.*/)||t.json({success:!1,msg:"Unauthorized"});try{lete=`user-${r.id}-temp-sql`,l=_.platform().match(/win/i)?"'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysql.exe'":"mysql";m.writeFileSync(`./.tmp/${e}.sql`,s,"base64");letn={cwd:process.cwd()};_.platform().match(/win/i)&&(n.shell="bash.exe"),f(`${l} -u ${process.env.DSQL_DB_USERNAME} -h ${process.env.DSQL_DB_HOST} -p${process.env.DSQL_DB_PASSWORD}${a.db_full_name} < .tmp/${e}.sql`,n);leti=awaito()({database:a,userId:r.id});t.json({success:!!i})}catch(e){console.log(e),c()({component:"/api/importDatabase/catch-error",message:e.message,user:r}),t.json({success:!1,msg:"Import Failed!"})}}letg=(0,n.M)(a,"default"),h=(0,n.M)(a,"config"),y=news.PagesAPIRouteModule({definition:{kind:l.A.PAGES_API,page:"/api/importDatabase",pathname:"/api/importDatabase",bundlePath:"",filename:""},userland:a})},72350:(e,t,r)=>{leta=r(57638),{default:s}=r(2258),{default:l}=r(78634),n=r(47670),i=r(24256);e.exports=asyncfunction({userId:e,database:t}){try{if(!e){console.log("No user Id provided");return}letr=s({userId:e});if(!r)throwError("User schema data not found!");leto=r.filter(e=>e.dbFullName===t.db_full_name)[0],u=awaita({database:t.db_full_name,queryString:"SHOW TABLES"});if(!u)throwError("No Existing Tables");for(letr=0;r<u.length;r++){lets=u[r],l=Object.values(s)[0];awaitn({dbFullName:"datasquirel",tableName:"user_database_tables",data:{user_id:e,db_id:t.id,db_slug:t.db_slug,table_name:i(l),table_slug:l}});letc={tableName:l,tableFullName:i(l)||"",fields:[],indexes:[]},d=awaita({database:t.db_full_name,queryString:`SHOW COLUMNS FROM ${l}`});if(d)for(lete=0;e<d.length;e++){let{Field:t,Type:r,Null:a,Key:s,Default:l,Extra:n}=d[e],i={fieldName:t,dataType:r.toUpperCase()};a?.match(/^no$/i)&&(i.notNullValue=!0),s?.match(/^pri$/i)&&(i.primaryKey=!0),l?.toString()?.match(/./)&&(i.defaultValue=l),l?.toString()?.match(/timestamp/i)&&(deletei.defaultValue,i.defaultValueLiteral=l),n?.toString()?.match(/auto_increment/i)&&(i.autoIncrement=!0),c.fields.push(i)}letp=awaita({database:t.db_full_name,queryString:`SHOW INDEXES FROM ${l}`});if(p)for(lete=0;e<p.length;e++){let{Table:t,Key_name:r,Column_name:a,Null:s,Index_type:l,Index_comment:n}=p[e];if(!n?.match(/^schema_index$/))continue;leti={indexType:l?.match(/fulltext/i)?"fullText":"regular",indexName:r,indexTableFields:[]},o=d?.filter(e=>e.Field===a)[0],u=c.indexes?.filter(e=>e.indexName==r);u&&u[0]?u[0].indexTableFields?.push({value:a,dataType:o.Type.toUpperCase()}):(i.indexTableFields=[{value:a,dataType:o.Type.toUpperCase()}],c.indexes?.push(i))}o.tables.push(c)}returnl({schemaData:r,userId:e}),!0}catch(e){returnconsole.log(e),!1}}},6420:(e,t,r)=>{r(81630);leta=r(51348),s=r(72835),l=r(29021),n=r(31341);asyncfunctioni(e,t,r,i){let{keyCookieName:o,csrfCookieName:u}=n();if(!e.cookies?.[o]?.match(/./))returnnull;letc=s({encryptedString:e.cookies[o]});if(!c)returnnull;letd=JSON.parse(c);if(!d.csrf_k||r&&!e.headers["x-csrf-auth"]?.match(RegExp(`${d.csrf_k}`)))returnnull;letp=process.env.DSQL_USER