"use strict";(()=>{vare={};e.id=8675,e.ids=[8675],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")},54356:(e,r,t)=>{t.r(r),t.d(r,{config:()=>b,default:()=>y,routeModule:()=>E});vara={};t.r(a),t.d(a,{default:()=>g});vars=t(89947),n=t(2706),l=t(96762),i=t(30944),o=t(4820),u=t(21724),d=t(98e3);functionc(e){returne?e.split("-").filter(e=>""!==e).map(e=>e.substr(0,1).toUpperCase()+e.substr(1).toLowerCase()).join(" "):null}asyncfunctionm({userId:e,database:r}){try{if(!e){console.log("No user Id provided");return}lett=(0,o.A)({userId:e});if(!t)throwError("User schema data not found!");leta=t.filter(e=>e.dbFullName===r.db_full_name)[0],s=await(0,i.A)({database:r.db_full_name,queryString:`SHOW TABLES FROM ${r.db_full_name}`});if(!s)throwError("No Existing Tables");for(lett=0;t<s.length;t++){letn=s[t],l=Object.values(n)[0];await(0,d.A)({dbFullName:"datasquirel",tableName:"user_database_tables",data:{user_id:e,db_id:r.id,db_slug:r.db_slug,table_name:c(l),table_slug:l}});leto={tableName:l,tableFullName:c(l)||"",fields:[],indexes:[]},u=await(0,i.A)({database:r.db_full_name,queryString:`SHOW COLUMNS FROM ${r.db_full_name}.${l}`});if(u)for(lete=0;e<u.length;e++){let{Field:r,Type:t,Null:a,Key:s,Default:n,Extra:l}=u[e],i={fieldName:r,dataType:t.toUpperCase()};a?.match(/^no$/i)&&(i.notNullValue=!0),s?.match(/^pri$/i)&&(i.primaryKey=!0),n?.toString()?.match(/./)&&(i.defaultValue=n),n?.toString()?.match(/timestamp/i)&&(deletei.defaultValue,i.defaultValueLiteral=n),l?.toString()?.match(/auto_increment/i)&&(i.autoIncrement=!0),o.fields.push(i)}letm=await(0,i.A)({database:r.db_full_name,queryString:`SHOW INDEXES FROM ${r.db_full_name}.${l}`});if(m)for(lete=0;e<m.length;e++){let{Table:r,Key_name:t,Column_name:a,Null:s,Index_type:n,Index_comment:l}=m[e];if(!l?.match(/^schema_index$/))continue;leti={indexType:n?.match(/fulltext/i)?"fullText":"regular",indexName:t,indexTableFields:[]},d=u?.filter(e=>e.Field===a)[0],c=o.indexes?.filter(e=>e.indexName==t);c&&c[0]?c[0].indexTableFields?.push({value:a,dataType:d.Type.toUpperCase()}):(i.indexTableFields=[{value:a,dataType:d.Type.toUpperCase()}],o.indexes?.push(i))}a.tables.push(o)}return(0,u.A)({schemaData:t,userId:e}),!0}catch(e){returnconsole.log(e),!1}}varp=t(67619),_=t(69842);letf=t(29021),h=t(21820),{execSync:S}=t(79646);asyncfunctiong(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=await(0,_.A)(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{database:a,fileBase64:s}=e.body;a?.db_full_name?.match(/datasquirel_user_.*/)||r.json({success:!1,msg:"Unauthorized"});try{lete=`user-${t.id}-temp-sql`,n=h.platform().match(/win/i)?"'C:\\Program Files\\MySQL\\MySQL Server 8.0\\bin\\mysql.exe'":"mysql";f.writeFileSync(`./.tmp/${e}.sql`,s,"base64");letl={cwd:process.cwd()};h.platform().match(/win/i)&&(l.shell="bash.exe"),S(`${n} -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`,l);leti=awaitm({database:a,userId:t.id});r.json({success:!!i})}catch(e){console.log(e),(0,p.default)({component:"/api/importDatabase/catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Import Failed!"})}}lety=(0,l.M)(a,"default"),b=(0,l.M)(a,"config"),E=news.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/importDatabase",pathname:"/api/importDatabase",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){try{let{keyCookieName:n,csrfCookieName:o}=(0,i.A)();if(!e.cookies?.[n]?.match(/./))throwError("Request Cookies not Found!");letu=(0,s.A)({encryptedString:e.cookies[n]});if(!u)throwError("Cou