"use strict";(()=>{vare={};e.id=4371,e.ids=[4371],e.modules={60818:e=>{e.exports=require("dotenv")},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")},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}}})},56363:(e,t,r)=>{r.r(t),r.d(t,{config:()=>A,default:()=>v,routeModule:()=>L});vars={};r.r(s),r.d(s,{default:()=>y});vara=r(89947),n=r(2706),o=r(96762),l=r(51348),i=r.n(l),c=r(73677),u=r.n(c),d=r(39831),_=r.n(d),p=r(48225),S=r.n(p),f=r(6420),g=r.n(f),E=r(33364),D=r.n(E),m=r(19261),b=r.n(m);leth=r(29021);r(33873);let{execSync:N}=r(79646);asyncfunctiony(e,t){if("POST"!==e.method)returnt.json({msg:"Failed!"});letr=awaitg()(e,t,!0);if(!r)returnt.json({success:!1,msg:"Unauthorized"});let{dbFullName:s,dbSlug:a,dbId:n,tableNameOld:o,payload:l,delegated:c}=e.body,{tableName:d,tableFullName:p,tableDescription:f}=l;if(!d?.match(/./)||d.match(/[^a-zA-Z0-9-_]/))returnt.json({success:!1,msg:"Bad Input"});try{letl=await_()({databaseSlug:a,request:e,user:r,query:e.query});if(!awaitu()({user:r,confirmedDelegetedUser:l,database:a,table:o,dbId:n,priviledgeRegex:/Edit Table/i}))returnconsole.log("User Unauthorized"),t.json({success:!1,msg:"Unauthorized"});letg=l?.rootUserId?l.rootUserId:r.id,E=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${g}/main.json`,m=JSON.parse(h.readFileSync(E,"utf8")),N=m.filter(e=>e.dbFullName===s)[0].tables.filter((e,t)=>{if(e.tableName===o)return!0});if(N&&N[0])N[0].tableName=d,N[0].tableNameOld=o,N[0].tableFullName=p,f&&(N[0].tableDescription=f),N[0].childrenTables&&N[0].childrenTables.forEach(e=>{try{m.filter(t=>t.dbFullName===e.dbNameFull)[0].tables.filter(t=>{if(t.tableName===e.tableName)return!0})[0].childTableName=d}catch(e){S()({component:"/api/updateUserTable/lines-131-138",message:e.message,user:r})}});elsethrowError("Table Does not exist");h.writeFileSync(`${E}`,JSON.stringify(m),"utf8"),awaitD()({dbFullName:"datasquirel",tableName:"user_database_tables",identifierColumnName:"table_slug",identifierValue:o,data:{table_name:p,table_slug:d,table_description:f}}),c&&l&&awaiti()("UPDATE delegated_user_tables SET `table`=? WHERE delegated_user_id=? AND root_user_id=? AND `table`=? AND `database`=?",[d,r.id,l.rootUserId,o,a]);lety=s.replace(/[^a-z\_0-9]/g,"");awaitb()({userId:g,targetDatabase:y}),t.json({success:!0})}catch(e){S()({component:"/api/updateUserTable/main-catch-error",message:e.message,user:r}),t.json({success:!1,msg:"Database Files could not be written!"})}}letv=(0,o.M)(s,"default"),A=(0,o.M)(s,"config"),L=newa.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/updateUserTable",pathname:"/api/updateUserTable",bundlePath:"",filename:""},userland:s})},73677:(e,t,r)=>{lets=r(51348),a=r(48225);e.exports=asyncfunction({user:e,confirmedDelegetedUser:t,database:r,table:n,priviledgeRegex:o,dbId:l}){leti,c;try{t?.delegated?(i=awaits("SELECT priviledge FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=? AND `database`=? AND `table`=?",[t.rootUserId,e.id,r,n]),c=i[0]?.priviledge?.match(o)):(i=awaits("SELECT table_slug FROM user_database_tables WHERE user_id=? AND table_slug=? AND db_id=?",[e.id,n,l]),c=!0)}catch(t){a({component:"checkUserRights",message:t.message,user:e})}return!!i&&!!i[0]&&!!c}},39831:(e,t,r)=>{r(81630);lets=r(72835);e.exports=asyncfunction({request:e,databaseSlug:t,user:r,query:a}){try{letn=r.id,o=null;if(!a?.delegated)return{dbUserId:n};letl=a.dbUserId,i=`${process.env.DSQL_USER_DB_PREFIX}${l}_${t}`,c=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${i}`;try{if(!e.cookies?.[c])throwError("Cookieno