var l=Object.defineProperty;var i=(r,t)=>l(r,"name",{value:t,configurable:!0});import p from"debug";import s from"lodash";var u,a=class{static{i(this,"Debug")}debugers=new Map;filter;name="debug";async install(t){let{ultra:e}=t;return s.isNil(u)&&(u=t.Buffer),e.emitter.on("error",n=>{let o=f(n);e.emitter.emit("debug","error",m(o)),console.error(o)}),e.emitter.on("debug",(n,o,...g)=>{if(!(this.filter?.(n,o,...g)??!0))return;let c=this.debugers.get(n)??p(`ultra:${n}`);this.debugers.has(n)||this.debugers.set(n,c),c(o,...g)}),this}};((globalThis??{}).ChameleonUltraJS??{}).Debug=a;var y=["address","args","code","data","dest","errno","info","message","name","path","port","positions","reason","response.data","response.headers","response.status","source","stack","status","statusCode","statusMessage","syscall"];function f(r){return{...s.pick(r,y),...s.isNil(r.originalError)?{}:{originalError:f(r.originalError)}}}i(f,"errToJson");function d(r){let t=new Set;return s.cloneDeepWith(r,e=>{if(s.isObject(e)&&!s.isEmpty(e)){if(t.has(e))return"[Circular]";t.add(e)}if(u?.isBuffer(e))return{type:"Buffer",hex:e.toString("hex")};if(typeof e=="bigint")return e.toString();if(e instanceof Error)return f(e);if(e instanceof Map)return s.fromPairs([...e.entries()]);if(e instanceof Set)return[...e.values()];if(e instanceof Date)return e.toISOString()})}i(d,"stringifyClone");function h(r,t){if(r.length>1&&r[0]==="_")return;let e=this?._censored??[];for(let n of e)s.hasIn(this,n)&&s.set(this,n,"[Censored]");return delete this?._censored,this[r]}i(h,"stringifyReplacer");function m(r,t){return JSON.stringify(d(r),h,t)}i(m,"jsonStringify");export{a as default,f as errToJson,m as jsonStringify,d as stringifyClone,h as stringifyReplacer};
//# sourceMappingURL=Debug.mjs.map