"use strict";(()=>{vare={};e.id=460,e.ids=[460],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")},55511:e=>{e.exports=require("crypto")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")},14373:(e,r,t)=>{t.r(r),t.d(r,{config:()=>f,default:()=>m,routeModule:()=>S});vars={};t.r(s),t.d(s,{default:()=>g});vara=t(89947),i=t(2706),o=t(96762),l=t(96771),n=t.n(l),d=t(47670),u=t.n(d);t(51348),t(21339);letc=t(73677),_=t(39831),p=t(48225),E=t(6420);asyncfunctiong(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=awaitE(e,r,!0);if(!t)returnr.json({success:!1,msg:"User Auth Failed"});let{tableName:s,payload:a,tableSchema:i,dbSlug:o,dbId:l,delegated:d}=e.body;try{letd=await_({databaseSlug:o,request:e,user:t,query:e.query});if(!awaitc({user:t,confirmedDelegetedUser:d,database:o,table:s,dbId:l,priviledgeRegex:/Update Entries/i}))returnr.json({success:!1,msg:"Unauthorized"});letp=d?.rootUserId?`datasquirel_user_${d.rootUserId}_${o}`:`datasquirel_user_${t.id}_${o}`,E=awaitu()({dbContext:"Dsql User",paradigm:"Full Access",dbFullName:p,tableName:s,data:a,tableSchema:i});if(!E.insertId)throwconsole.log("Table Insertion Failed =>",E),Error(E?.error||"Table Insertion Failed");awaitn()({dbName:p,entryId:E.insertId,entryOrder:a.order,tableName:s,tableSchema:i}),r.json({success:!0})}catch(e){p({component:"/api/addTableEntry/catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!",err:e.message})}}letm=(0,o.M)(s,"default"),f=(0,o.M)(s,"config"),S=newa.PagesAPIRouteModule({definition:{kind:i.A.PAGES_API,page:"/api/addTableEntry",pathname:"/api/addTableEntry",bundlePath:"",filename:""},userland:s})},73677:(e,r,t)=>{lets=t(51348),a=t(48225);e.exports=asyncfunction({user:e,confirmedDelegetedUser:r,database:t,table:i,priviledgeRegex:o,dbId:l}){letn,d;try{r?.delegated?(n=awaits("SELECT priviledge FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=? AND `database`=? AND `table`=?",[r.rootUserId,e.id,t,i]),d=n[0]?.priviledge?.match(o)):(n=awaits("SELECT table_slug FROM user_database_tables WHERE user_id=? AND table_slug=? AND db_id=?",[e.id,i,l]),d=!0)}catch(r){a({component:"checkUserRights",message:r.message,user:e})}return!!n&&!!n[0]&&!!d}},39831:(e,r,t)=>{t(81630);lets=t(72835);e.exports=asyncfunction({request:e,databaseSlug:r,user:t,query:a}){try{leti=t.id,o=null;if(!a?.delegated)return{dbUserId:i};letl=a.dbUserId,n=`${process.env.DSQL_USER_DB_PREFIX}${l}_${r}`,d=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${n}`;try{if(!e.cookies?.[d])throwError("Cookie not present");lett=s({encryptedString:e.cookies[d]});if(!t)throwError("Invalid Token");if((o=JSON.parse(t)).databaseSlug===r)return{dbUserId:i=o.rootUserId,rootUserId:o.rootUserId,rootUserName:o.rootUserName,rootUserEmail:o.rootUserEmail,rootUserImage:o.rootUserImage,databaseFullName:o.databaseFullName,databaseSlug:o.databaseSlug,allowedTables:o.allowedTables,priviledges:o.priviledges,database:o.databaseSlug,delegated:!0}}catch(e){}return{dbUserId:i}}catch(e){returnnull}}},96771:(e,r,t)=>{lets=t(21339);e.exports=asyncfunction({dbName:e,entryId:r,entryOrder:t,tableName:a,tableSchema:i}){try{if(i.fields.find(e=>!!e.fieldName?.match(/^order$/i))&&t){leti=awaits({database:e,paradigm:"Full Access",queryString:`SELECT * FROM ${a} WHERE \`order\` = '${t}' AND id != ?`,queryValues:[String(r)]});if(!i?.[0])throwError("No Existing Order");awaits({database:e,paradigm:"Full Access",queryString:`UPDATE ${a} SET \`order\` = \`order\` + 1 WHERE \`order\` >= ${t} AND id != ?`,queryValues:[String(r)]})}return!0}catch(e){return!1}}},6420:(e,r,t)=>{t(81630);lets=t(51348),a=t(72835),i=t(29021),o=t(31341);asyncfunctionl(e,r,t,l){let{keyCookieName:n,csrfCookieName:d}=o();if(!e.cookies?.[n]?.match(/./))returnnull;letu=a({enc