exports.id=9141,exports.ids=[9141],exports.modules={20903:(a,b,c)=>{"use strict";let d;c.d(b,{db:()=>h});var e=c(38491);let f=global.db||(d=function(a){let b={host:process.env.DB_HOST||"127.0.0.1",port:Number(process.env.DB_PORT||3306),user:process.env.DB_USER||"",password:process.env.DB_PASS||"",database:process.env.DB_NAME||""};if(!a)return b;try{let c=a.match(/^mysql:\/\/([^:]+):([^@]*)@([^:/]+)(?::(\d+))?\/([^?]+)/);if(!c)return b;return{host:c[3],port:c[4]?Number(c[4]):3306,user:decodeURIComponent(c[1]),password:c[2]?decodeURIComponent(c[2]):"",database:c[5]}}catch{return b}}(process.env.DATABASE_URL),e.createPool({host:d.host,port:d.port,user:d.user,password:d.password,database:d.database,waitForConnections:!0,connectionLimit:3,queueLimit:0,charset:"utf8mb4",timezone:"+07:00",enableKeepAlive:!0,keepAliveInitialDelay:0}));function g(a){if(!a||0===Object.keys(a).length)return{sql:"",params:[]};let b=[],c=[];if(Array.isArray(a.OR)&&a.OR.length>0){let d=[];for(let b of a.OR){let{sql:a,params:e}=g(b);a&&(d.push(a.replace(/^ WHERE /,"")),c.push(...e))}d.length>0&&b.push(`(${d.join(" OR ")})`)}if(Array.isArray(a.AND)&&a.AND.length>0){let d=[];for(let b of a.AND){let{sql:a,params:e}=g(b);a&&(d.push(a.replace(/^ WHERE /,"")),c.push(...e))}d.length>0&&b.push(`(${d.join(" AND ")})`)}for(let[d,e]of Object.entries(a))if("OR"!==d&&"AND"!==d)if(null==e)b.push(`\`${d}\` IS NULL`);else if("object"!=typeof e||Array.isArray(e))Array.isArray(e)?(b.push(`\`${d}\` IN (${e.map(()=>"?").join(", ")})`),c.push(...e)):(b.push(`\`${d}\` = ?`),c.push(e));else for(let[a,f]of Object.entries(e))switch(a){case"contains":b.push(`\`${d}\` LIKE ?`),c.push(`%${f}%`);break;case"startsWith":b.push(`\`${d}\` LIKE ?`),c.push(`${f}%`);break;case"endsWith":b.push(`\`${d}\` LIKE ?`),c.push(`%${f}`);break;case"equals":default:b.push(`\`${d}\` = ?`),c.push(f);break;case"not":null===f?b.push(`\`${d}\` IS NOT NULL`):(b.push(`\`${d}\` != ?`),c.push(f));break;case"in":Array.isArray(f)&&0===f.length?b.push("1=0"):(b.push(`\`${d}\` IN (${f.map(()=>"?").join(", ")})`),c.push(...f));break;case"notIn":Array.isArray(f)&&0===f.length?b.push("1=1"):(b.push(`\`${d}\` NOT IN (${f.map(()=>"?").join(", ")})`),c.push(...f));break;case"lt":b.push(`\`${d}\` < ?`),c.push(f);break;case"lte":b.push(`\`${d}\` <= ?`),c.push(f);break;case"gt":b.push(`\`${d}\` > ?`),c.push(f);break;case"gte":b.push(`\`${d}\` >= ?`),c.push(f)}return{sql:b.length?` WHERE ${b.join(" AND ")}`:"",params:c}}let h={async findMany(a,b={}){let{sql:c,params:d}=g(b.where),e=`SELECT * FROM \`${a}\`${c}`;if(b.orderBy){let a=(Array.isArray(b.orderBy)?b.orderBy:[b.orderBy]).map(a=>Object.entries(a).map(([a,b])=>`\`${a}\` ${b.toUpperCase()}`).join(", ")).join(", ");e+=` ORDER BY ${a}`}void 0!==b.take&&(e+=` LIMIT ${Number(b.take)}`),void 0!==b.skip&&(e+=` OFFSET ${Number(b.skip)}`);let[h]=await f.query(e,d);return h},async findFirst(a,b={}){let{sql:c,params:d}=g(b.where),e=`SELECT * FROM \`${a}\`${c}`;if(b.orderBy){let a=Object.entries(b.orderBy).map(([a,b])=>`\`${a}\` ${b.toUpperCase()}`).join(", ");e+=` ORDER BY ${a}`}e+=" LIMIT 1";let[h]=await f.query(e,d);return h[0]??null},async findUnique(a,b,c="id"){let[d]=await f.query(`SELECT * FROM \`${a}\` WHERE \`${c}\` = ? LIMIT 1`,[b]);return d[0]??null},async create(a,b){let c=Object.keys(b),d=c.map(a=>b[a]),e=`INSERT INTO \`${a}\` (\`${c.join("`,`")}\`) VALUES (${c.map(()=>"?").join(", ")})`,[g]=await f.query(e,d);return g},async insertGetId(a,b){let c=Object.keys(b),d=c.map(a=>b[a]),e=`INSERT INTO \`${a}\` (\`${c.join("`,`")}\`) VALUES (${c.map(()=>"?").join(", ")})`,[g]=await f.query(e,d);return b.id??g.insertId},async update(a,b,c){let d=[],e=[];for(let[a,b]of Object.entries(c))b&&"object"==typeof b&&!Array.isArray(b)&&"increment"in b?(d.push(`\`${a}\` = \`${a}\` + ?`),e.push(b.increment)):(d.push(`\`${a}\` = ?`),e.push(b));let{sql:h,params:i}=g(b),j=`UPDATE \`${a}\` SET ${d.join(", ")}${h}`,[k]=await f.query(j,[...e,...i]);return k},async remove(a,b){let{sql:c,params:d}=g(b),e=`DELETE FROM \`${a}\`${c}`,[h]=await f.query(e,d);return h},async count(a,b){let{sql:c,params:d}=g(b),e=`SELECT COUNT(*) AS c FROM \`${a}\`${c}`,[h]=await f.query(e,d);return Number(h[0]?.c??0)},async raw(a,b){let[c]=await f.query(a,b);return c}}},28303:a=>{function b(a){var b=Error("Cannot find module '"+a+"'");throw b.code="MODULE_NOT_FOUND",b}b.keys=()=>[],b.resolve=b,b.id=28303,a.exports=b}};