"use strict";var k=Object.create;var p=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var x=(t,o)=>{for(var s in o)p(t,s,{get:o[s],enumerable:!0})},P=(t,o,s,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of U(o))!W.call(t,n)&&n!==s&&p(t,n,{get:()=>o[n],enumerable:!(a=E(o,n))||a.enumerable});return t};var C=(t,o,s)=>(s=t!=null?k(O(t)):{},P(o||!t||!t.__esModule?p(s,"default",{value:t,enumerable:!0}):s,t)),A=t=>P(p({},"__esModule",{value:!0}),t);var q={};x(q,{createLogger:()=>T});module.exports=A(q);var D=C(require("fs")),w=require("fs"),u=C(require("path")),T=async(t={},o)=>{var y,L,h,b,S,v,F;let s=(y=t.mode)!=null?y:"memory",a=(L=t.logDir)!=null?L:".logs",n=(h=t.singleFile)!=null?h:!1,d={stdout:(S=(b=t.levels)==null?void 0:b.stdout)!=null?S:o?["debug","info","warn","error"]:["warn","error"],file:(F=(v=t.levels)==null?void 0:v.file)!=null?F:o?["info","debug","warn","error"]:["error"]};try{await w.promises.mkdir(a,{recursive:!0})}catch(e){console.warn(`Failed to create log directory: ${e}`)}let l=new Map,c=new Map,M=e=>{let r=n?"all":e;if(!c.has(r)){let g=u.default.join(a,n?"combined.log":`${e}.log`);c.set(r,D.default.createWriteStream(g,{flags:"a"}))}return c.get(r)},f=(e,r,g)=>{let i={timestamp:new Date().toISOString(),level:r,message:g};d.stdout.includes(r)&&(r==="error"?console.error:console.log)(`[${e}] [${i.timestamp}] [${r.toUpperCase()}] ${i.message}`),d.file.includes(r)&&(s==="memory"?(l.has(e)||l.set(e,[]),l.get(e).push(i)):M(e).write(`[${i.timestamp}] [${r.toUpperCase()}] ${i.message}
`))};return{info:(e,r)=>f(e,"info",r),warn:(e,r)=>f(e,"warn",r),error:(e,r)=>f(e,"error",r),debug:(e,r)=>f(e,"debug",r),flush:async()=>{if(s==="memory"){let e=new Date().toISOString().replace(/:/g,"-"),r=Array.from(l.entries()).map(async([g,i])=>{try{let m=u.default.join(a,n?`combined-${e}.log`:`${g}-${e}.log`),j=i.map($=>`[${$.timestamp}] [${$.level.toUpperCase()}] ${$.message}`);await w.promises.mkdir(u.default.dirname(m),{recursive:!0}),await w.promises.appendFile(m,j.join(`
`)+`
`)}catch(m){console.warn(`Failed to write log file for ${g}: ${m}`)}});await Promise.all(r)}for(let e of c.values())try{e.end()}catch(r){console.warn(`Failed to close log stream: ${r}`)}await new Promise(e=>setTimeout(e,10))}}};0&&(module.exports={createLogger});
