"use strict";exports.id=5194,exports.ids=[5194],exports.modules={96762:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,r){return r in t?t[r]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,r)):"function"==typeof t&&"default"===r?t:void 0}}})},96551:(e,t,r)=>{r.d(t,{A:()=>i});var n=r(9288),a=r.n(n),o=r(67619),l=r(45185);async function i({imageSourceBase64:e,imageName:t,userId:r,mimeType:n,thumbnailSize:i,folder:s,isPrivate:u}){try{let o=Buffer.from(e,"base64"),c=i?parseInt(i.toString()):400,d=a()(o),p=a()(o),_=(0,l.A)({isPrivate:u,userId:r,folder:s});if(!_)return null;let{fileRootPath:f,urlRootPath:g,relativePath:m}=_,{width:S,height:h,format:y}=await d.metadata(),E=n||y;S&&h&&S>1800&&d.resize(1800,Math.round(1800/S*h),{fit:"cover"}),d.toFormat(E,{quality:80}),await d.metadata();let N=`${t}.${E}`;if(await d.toFile(f+N),S&&h&&S>c){let e=c/S;p.resize(c,Math.round(h*e),{fit:"cover"})}else S&&h&&p.resize(150,Math.round(150/S*h),{fit:"cover"});p.toFormat(E,{quality:80});let A=`${t}_thumbnail.${E}`;return await p.toFile(f+A),{urlPath:g+N,urlThumbnailPath:g+A,urlRelativePath:m+N,urlThumbnailRelativePath:m+A}}catch(e){return console.log("Write Image to Disk error =>",e.message),(0,o.A)({component:"functions/backend/fsWriteImageToDiskFromBase64",message:e.message}),null}}},45185:(e,t,r)=>{r.d(t,{A:()=>i});var n=r(29021),a=r.n(n),o=r(33873),l=r.n(o);function i({isPrivate:e,userId:t,folder:r,video:n,pathOnly:o}){"production".match(/production/);let i=process.env.DSQL_STATIC_SERVER_DIR;if(!i)return console.log("Static File ENV not Found!"),null;let s=e?`@/${n?"videos":"media"}/${r?r+"/":""}`:n?`/videos/user-videos/user-${t}/${r?r+"/":""}`:`/images/user-images/user-${t}/${r?r+"/":""}`,u=e?`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t}/media/${r?r+"/":""}`:l().join(i,s);return a().existsSync(u)||o||a().mkdirSync(u,{recursive:!0}),{fileRootPath:u,urlRootPath:e?`@/media/${r?r+"/":""}`:`${process.env.DSQL_STATIC_HOST}${s}`,relativePath:s}}},98e3:(e,t,r)=>{r.d(t,{A:()=>c});var n=r(72583),a=r.n(n),o=r(92652),l=r(30802),i=r(68829),s=r(64292),u=r(52939);async function c({dbContext:e,paradigm:t,dbFullName:r,tableName:n,data:c,tableSchema:d,duplicateColumnName:p,duplicateColumnValue:_,update:f,encryptionKey:g,encryptionSalt:m}){let S=(0,u.A)({dbContext:e,dbFullName:r}),h=S?global.DSQL_DB_CONN:global.DSQL_FULL_ACCESS_DB_CONN||global.DSQL_DB_CONN,y=S?global.DSQL_DB_CONN:global.DSQL_READ_ONLY_DB_CONN||global.DSQL_DB_CONN;if(c?.date_created_timestamp&&delete c.date_created_timestamp,c?.date_updated_timestamp&&delete c.date_updated_timestamp,c?.date_updated&&delete c.date_updated,c?.date_updated_code&&delete c.date_updated_code,c?.date_created&&delete c.date_created,c?.date_created_code&&delete c.date_created_code,p&&"string"==typeof p){let t=`SELECT * FROM ${S?"":`\`${r}\`.`}\`${n}\` WHERE \`${p}\`=?`,a=await (0,s.A)(y,t,[_]);if(a?.[0]&&!f)return null;if(a&&a[0]&&f)return await (0,l.A)({dbContext:e,dbFullName:r,tableName:n,data:c,tableSchema:d,encryptionKey:g,encryptionSalt:m,identifierColumnName:p,identifierValue:_||""})}let E=Object.keys(c),N=[],A=[];for(let e=0;ee.fieldName==t):null,l=n&&n[0]?n[0]:null;if(null==r||void 0==r||l?.dataType?.match(/int$/i)&&"string"==typeof r&&!r?.match(/./))continue;l?.encrypted&&(r=(0,i.A)({data:r,encryptionKey:g,encryptionSalt:m}),console.log("DSQL: Encrypted value =>",r));let s=/<[^>]+>/g;(l?.richText||String(r).match(s))&&(r=a()(r,o.A)),l?.pattern&&!new RegExp(l.pattern,l.patternFlags||"").test(r)&&(console.log("DSQL: Pattern not matched =>",r),r=""),N.push("`"+t+"`"),"object"==typeof r&&(r=JSON.stringify(r)),"number"==typeof r?A.push(String(r)):A.push(r)}catch(e){console.log("DSQL: Error in parsing data keys =>",e.message);continue}c?.date_created||(N.push("`date_created`"),A.push(Date())),c?.date_created_code||(N.push("`date_created_code`"),A.push(Date.now())),c?.date_updated||(N.push("`date_updated`"),A.push(Date())),c?.date_updated_code||(N.push("`date_updated_code`"),A.push(Date.now()));let D=`INSERT INTO ${S?"":`\`${r}\`.`}\`${n}\` (${N.join(",")}) VALUES (${A.map(()=>"?").join(",")})`;return await (0,s.A)(h,D,A)}},30802:(e,t,r)=>{r.d(t,{A:()=>u});var n=r(72583),a=r.n(n),o=r(92652),l=r(68829),i=r(52939),s=r(64292);async function u({dbContext:e,dbFullName:t,tableName:r,data:n,tableSchema:u,identifierColumnName:c,identifierValue:d,encryptionKey:p,encryptionSalt:_}){if(!n||!Object.keys(n).length)return null;let f=(0,i.A)({dbContext:e,dbFullName:t}),g=f?global.DSQL_DB_CONN:global.DSQL_FULL_ACCESS_DB_CONN||global.DSQL_DB_CONN;f?global.DSQL_DB_CONN:global.DSQL_READ_ONLY_DB_CONN||global.DSQL_DB_CONN;let m=Object.keys(n),S=[],h=[];for(let e=0;ee.fieldName===t):null,s=i&&i[0]?i[0]:null;if(null==r||void 0==r)continue;let c=/<[^>]+>/g;(s?.richText||String(r).match(c))&&(r=a()(r,o.A)),s?.encrypted&&(r=(0,l.A)({data:r,encryptionKey:p,encryptionSalt:_})),"object"==typeof r&&(r=JSON.stringify(r)),s?.pattern&&!new RegExp(s.pattern,s.patternFlags||"").test(r)&&(console.log("DSQL: Pattern not matched =>",r),r=""),"string"==typeof r&&r.match(/^null$/i)&&(r={toSqlString:function(){return"NULL"}}),"string"!=typeof r||r.match(/./i)||(r={toSqlString:function(){return"NULL"}}),S.push(`\`${t}\`=?`),"number"==typeof r?h.push(String(r)):h.push(r)}catch(e){console.log("DSQL: Error in parsing data keys in update function =>",e.message);continue}S.push(`date_updated='${Date()}'`),S.push(`date_updated_code='${Date.now()}'`);let y=`UPDATE ${f?"":`\`${t}\`.`}\`${r}\` SET ${S.join(",")} WHERE \`${c}\`=?`;return h.push(d),await (0,s.A)(g,y,h)}},92652:(e,t,r)=>{r.d(t,{A:()=>n});let n={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"]}}},67619:(e,t,r)=>{r.d(t,{A:()=>o});var n=r(29021),a=r.n(n);async function o({user:e,message:t,component:r,noMail:n,req:o}){let l=new Date,i=(()=>{if(!o)return null;try{let e=o.headers["x-forwarded-for"],t=o.headers["x-real-ip"],r=o.headers["cf-connecting-ip"],n=Array.isArray(e)?e[0]:e?.split(",")[0],a=r||n||t||o.socket.remoteAddress;if(!a)return null;return String(a)}catch(e){return null}})();try{let n=`🚀 SERVER ERROR =========================== Error Message: ${t} Component: ${r}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(n+=` User Id: ${e?.id} User Name: ${e?.first_name} ${e?.last_name} User Email: ${e?.email}`),o?.url&&(n+=` URL: ${o.url}`),o?.body&&(n+=` Request Body: ${JSON.stringify(o.body,null,4)}`),i&&(n+=` IP: ${i}`),n+=` Date: ${l.toDateString()} ========================================`,a().existsSync("./.tmp/error.log")||a().writeFileSync("./.tmp/error.log","","utf-8");let s=a().readFileSync("./.tmp/error.log","utf-8");a().writeFileSync("./.tmp/error.log",n),a().appendFileSync("./.tmp/error.log",` ${s}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},68829:(e,t,r)=>{r.d(t,{A:()=>l});var n=r(55511),a=r(79428),o=r(32443);function l({data:e,encryptionKey:t,encryptionSalt:r}){if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let{key:l,salt:i,keyLen:s,algorithm:u,bufferAllocSize:c}=(0,o.A)({encryptionKey:t});if(!l?.match(/.{8,}/))return console.log("Encryption key is invalid"),e;if(!i?.match(/.{8,}/))return console.log("Encryption salt is invalid"),e;let d=(0,n.scryptSync)(l,i,s),p=a.Buffer.alloc(c,0),_=(0,n.createCipheriv)(u,d,p);try{let t=_.update(e,"utf8","hex");return t+=_.final("hex")}catch(t){return console.log("Error in encrypting =>",t.message),e}}},52939:(e,t,r)=>{r.d(t,{A:()=>n});function n({dbContext:e,dbFullName:t}){return!e?.match(/dsql.user/i)&&(!!global.DSQL_USE_LOCAL||!t||!!t.match(/^datasquirel$/))}},64292:(e,t,r)=>{async function n(e,t,r){try{if(!e)throw Error("No Connection Found!");if(!t)throw Error("Query String Required!");if("string"==typeof t){let n=await e.query(a(t),r);return JSON.parse(JSON.stringify(n))}if("object"!=typeof t)return null;{let r=[];for(let n=0;nn})},32443:(e,t,r)=>{r.d(t,{A:()=>n});function n(e){return{key:e?.encryptionKey||process.env.DSQL_ENCRYPTION_PASSWORD,keyLen:process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24,salt:e?.encryptionSalt||process.env.DSQL_ENCRYPTION_SALT,apiKey:e?.apiKey||process.env.DSQL_API_KEY,algorithm:e?.algorithm||process.env.DSQL_ENCRYPTION_ALGORITHM||"aes-192-cbc",bufferAllocSize:e?.bufferAllocSize||(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE?function(e,t){try{let t=Number(e);if("number"!=typeof t||isNaN(t))return 0;return Math.round(t)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},2706:(e,t)=>{Object.defineProperty(t,"A",{enumerable:!0,get:function(){return r}});var r=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},89947:(e,t,r)=>{e.exports=r(75600)}};