"use strict";(()=>{vare={};e.id=1132,e.ids=[1132],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")},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,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){returnfunctione(r,t){returntinr?r[t]:"then"inr&&"function"==typeofr.then?r.then(r=>e(r,t)):"function"==typeofr&&"default"===t?r:void0}}})},82595:(e,r,t)=>{t.r(r),t.d(r,{config:()=>D,default:()=>y,routeModule:()=>b});vars={};t.r(s),t.d(s,{default:()=>h});vara=t(89947),n=t(2706),o=t(96762),i=t(96771),l=t.n(i),u=t(73677),d=t.n(u),c=t(39831),p=t.n(c),_=t(77538),S=t.n(_),f=t(6420),m=t.n(f),g=t(33364),E=t.n(g);asyncfunctionh(e,r){if("POST"!==e.method)returnr.json({msg:"Failed!"});lett=awaitm()(e,r,!0);if(!t)returnr.json({success:!1,msg:"Unauthorized"});let{dbSlug:s,tableName:a,payload:n,entryId:o,tableSchema:i,delegated:u,dbId:c}=e.body;deleten.id,deleten.uuid,deleten.date_created,deleten.date_created_code,deleten.date_created_timestamp,deleten.date_updated,deleten.date_updated_code,deleten.date_updated_timestamp;try{letu=awaitp()({databaseSlug:s,request:e,user:t,query:e.query}),_=u?.rootUserId?`datasquirel_user_${u.rootUserId}_${s}`:`datasquirel_user_${t.id}_${s}`;if(!awaitd()({user:t,confirmedDelegetedUser:u,database:s,table:a,dbId:c,priviledgeRegex:/Update Entries/i}))returnr.json({success:!1,msg:"Unauthorized"});letS=awaitE()({dbContext:"Dsql User",paradigm:"Full Access",dbFullName:_,tableName:a,identifierColumnName:"id",identifierValue:o,data:n,tableSchema:i});if(S?.error)throwError(S.error);if(!S)throwError("No result returned!");awaitl()({dbName:_,entryId:o,entryOrder:n.order,tableName:a,tableSchema:i}),r.json({success:!0,payload:S})}catch(e){S()({component:"/api/updateTableEntry/main-catch-error",message:e.message,user:t}),r.json({success:!1,msg:"Database Files could not be written!",err:e.message})}}lety=(0,o.M)(s,"default"),D=(0,o.M)(s,"config"),b=newa.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/updateTableEntry",pathname:"/api/updateTableEntry",bundlePath:"",filename:""},userland:s})},73677:(e,r,t)=>{lets=t(51348),a=t(77538);e.exports=asyncfunction({user:e,confirmedDelegetedUser:r,database:t,table:n,priviledgeRegex:o,dbId:i}){letl,u;try{r?.delegated?(l=awaits("SELECT priviledge FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=? AND `database`=? AND `table`=?",[r.rootUserId,e.id,t,n]),u=l[0]?.priviledge?.match(o)):(l=awaits("SELECT table_slug FROM user_database_tables WHERE user_id=? AND table_slug=? AND db_id=?",[e.id,n,i]),u=!0)}catch(r){a({component:"checkUserRights",message:r.message,user:e})}return!!l&&!!l[0]&&!!u}},39831:(e,r,t)=>{t(81630);lets=t(72907);e.exports=asyncfunction({request:e,databaseSlug:r,user:t,query:a}){try{letn=t.id,o=null;if(!a?.delegated)return{dbUserId:n};leti=a.dbUserId,l=`${process.env.DSQL_USER_DB_PREFIX}${i}_${r}`,u=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${l}`;try{if(!e.cookies?.[u])throwError("Cookie not present");lett=s(e.cookies[u]);if(!t)throwError("Invalid Token");if((o=JSON.parse(t)).databaseSlug===r)return{dbUserId:n=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:n}}catch(e){returnnull}}},96771:(e,r,t)=>{lets=t(21339);e.exports=asyncfunction({dbName:e,entryId:r,entryOrder:t,tableName:a,tableSchema:n}){try{if(n.fields.find(e=>!!e.fieldName?.match(/^order$/i))&&t){letn=awaits({database:e,paradigm:"Full Access",queryString:`SELECT * FROM ${a} WHERE \`order\` = '${t}' AND id != ?`,queryValues:[String(r)]});if(!n?.[0])throwError
${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},6420:(e,r,t)=>{t(81630);let s=t(51348),a=t(72907),n=t(29021);async function o(e,r,t,o){if(!e.cookies?.datasquirelAuthKey?.match(/./))return null;let i=a(e.cookies.datasquirelAuthKey);if(!i)return null;let l=JSON.parse(i);if(!l.csrf_k||t&&!e.headers["x-csrf-auth"]?.match(RegExp(`${l.csrf_k}`)))return null;let u=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!u)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(t&&!n.existsSync(`${u}/${l.csrf_k}`))return null;if(0==l.verification_status&&!t){let e=await s(`SELECTverification_statusFROMusersWHEREid='${l.id}'`);e&&e[0]&&1==e[0].verification_status&&r.setHeader("Set-Cookie",["user_refresh=1"])}return l?.date&&Date.now()-l.date>6048e5?null:l}e.exports=o},33364:(e,r,t)=>{let s=t(82703),a=t(72583),n=t(16570),o=t(51348),i=t(21339);async function l({dbContext:e,paradigm:r,dbFullName:t,tableName:l,data:u,tableSchema:d,identifierColumnName:c,identifierValue:p,encryptionKey:_,encryptionSalt:S}){if(!u||!Object.keys(u).length)return null;let f=!e?.match(/dsql.user/i)&&(!t||!!t.match(/^datasquirel$/)),m=f?o:i,g=Object.keys(u),E=[],h=[];for(let e=0;e<g.length;e++)try{let r=g[e],t=u[r],o=d?d?.fields?.filter(e=>e.fieldName===r):null,i=o&&o[0]?o[0]:null;if(null==t||void 0==t)continue;i?.richText&&(t=a(t,n)),i?.encrypted&&(t=s(t,_,S)),"object"==typeof t&&(t=JSON.stringify(t)),i?.pattern&&!new RegExp(i.pattern,i.patternFlags||"").test(t)&&(console.log("DSQL: Pattern not matched =>",t),t=""),"string"==typeof t&&t.match(/^null$/i)&&(t={toSqlString:function(){return"NULL"}}),"string"!=typeof t||t.match(/./i)||(t={toSqlString:function(){return"NULL"}}),E.push(`\`${r}\`=?`),"number"==typeoft?h.push(String(t)):h.push(t)}catch(e){console.log("DSQL: Error in parsing data keys in update function =>",e.message);continue}E.push(`date_updated='${Date()}'`),E.push(`date_updated_code='${Date.now()}'`);lety=`UPDATE ${l} SET ${E.join(",")} WHERE \`${c}\`=?`;returnh.push(p),f?awaitm(y,h):awaitm({paradigm:r,database:t,queryString:y,queryValues:h})}e.exports=l},72907:(e,r,t)=>{let{scryptSync:s,createDecipheriv:a}=t(55511),{Buffer:n}=t(79428);e.exports=e=>{letr=a("aes-192-cbc",s(process.env.DSQL_ENCRYPTION_PASSWORD||"",process.env.DSQL_ENCRYPTION_SALT||"",24),n.alloc(16,0));try{lett=r.update(e,"hex","utf8");returnt+=r.final("utf8")}catch(e){returnnull}}},82703:(e,r,t)=>{let{scryptSync:s,createCipheriv:a}=t(55511),{Buffer:n}=t(79428),o=t(48225);e.exports=(e,r,t)=>{leti=a("aes-192-cbc",s(r||process.env.DSQL_ENCRYPTION_PASSWORD||"",t||process.env.DSQL_ENCRYPTION_SALT||"",24),n.alloc(16,0));try{letr=i.update(e,"utf8","hex");returnr+=i.final("hex")}catch(e){returno({component:"encrypt",message:e.message}),null}}},16570:e=>{e.exports={allowedTags:["b","i","em","strong","a","p","span","ul","ol","li","h1","h2","h3","h4","h5","h6","img","div","button","pre","code","br"],allowedAttributes:{a:["href"],img:["src","alt","width","height","class","style"],"*":["style","class"]}}},48225:(e,r,t)=>{lets=t(29021);e.exports=asyncfunction({user:e,message:r,component:t,noMail:a}){letn=`🚀 SERVER ERROR ===========================