/* Socket Lib - Built with esbuild */
var U=Object.create;var h=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var L=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var W=(n,t)=>{for(var e in t)h(n,e,{get:t[e],enumerable:!0})},S=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of G(t))!T.call(n,o)&&o!==e&&h(n,o,{get:()=>t[o],enumerable:!(i=j(t,o))||i.enumerable});return n};var I=(n,t,e)=>(e=n!=null?U(L(n)):{},S(t||!n||!n.__esModule?h(e,"default",{value:n,enumerable:!0}):e,n)),J=n=>S(h({},"__esModule",{value:!0}),n);var Y={};W(Y,{debug:()=>z,debugCache:()=>M,debugCacheNs:()=>q,debugDir:()=>F,debugDirNs:()=>v,debugLog:()=>K,debugLogNs:()=>B,debugNs:()=>A,debuglog:()=>V,debugtime:()=>X,isDebug:()=>Q,isDebugNs:()=>P});module.exports=J(Y);var m=require("#constants/process"),E=require("#env/debug"),a=require("#env/socket"),g=I(require("./external/@socketregistry/is-unicode-supported")),f=I(require("./external/debug")),d=require("./logger"),H=require("./objects"),D=require("./strings");const $=Reflect.apply,_=new Map;function C(n){let t=_.get(n);return t||(!(0,E.getDebug)()&&(0,a.getSocketDebug)()&&(n==="error"||n==="notice")&&f.default.enable(n),t=(0,f.default)(n),t.log=R,_.set(n,t),t)}let x;function N(){return x===void 0&&(x=require("node:util")),x}function b(n=3){let t="";const e=Error.captureStackTrace;if(typeof e=="function"){const i={};e(i,b);const o=i.stack;if(typeof o=="string"){let u=0,c=0;for(let s=0,{length:l}=o;s<l;s+=1)if(o[s]===`
`)if(u+=1,u<n)c=s+1;else{const r=o.slice(c,s).trimStart(),w=/(?<=^at\s+).*?(?=\s+\(|$)/.exec(r)?.[0];if(w&&(t=w.replace(/^(?:async|bound|get|new|set)\s+/,""),t.startsWith("Object."))){const k=t.slice(7);(0,H.hasOwn)(Object,k)||(t=k)}break}}}return t}function R(...n){const t=N(),e=f.default.inspectOpts?{...f.default.inspectOpts,showHidden:f.default.inspectOpts.showHidden===null?void 0:f.default.inspectOpts.showHidden,depth:f.default.inspectOpts.depth===null||typeof f.default.inspectOpts.depth=="boolean"?void 0:f.default.inspectOpts.depth}:{};$(d.logger.info,d.logger,[t.formatWithOptions(e,...n)])}function y(n){return n!==null&&typeof n=="object"?{__proto__:null,...n}:{__proto__:null,namespaces:n}}function O(n){if(!(0,a.getSocketDebug)())return!1;if(typeof n!="string"||!n||n==="*")return!0;const t=n.trim().replace(/\s+/g,",").split(",").filter(Boolean),e=[],i=[];for(const o of t)o.startsWith("-")?i.push(o.slice(1)):e.push(o);return e.length&&!e.some(o=>C(o).enabled)?!1:i.every(o=>!C(o).enabled)}function v(n,t,e){const i=y(n),{namespaces:o}=i;if(!O(o))return;const u=b(4)||"anonymous";p===void 0&&(p=(0,g.default)()?"\u25B8":">");let c=e;if(c===void 0){const r=f.default.inspectOpts;r&&(c={...r,showHidden:r.showHidden===null?void 0:r.showHidden,depth:r.depth===null||typeof r.depth=="boolean"?null:r.depth})}const s=i.spinner||(0,m.getSpinner)(),l=s?.isSpinning;s?.stop(),d.logger.info(`[DEBUG] ${u} ${p} object inspection:`),d.logger.dir(t,e),l&&s?.start()}let p;function A(n,...t){const e=y(n),{namespaces:i}=e;if(!O(i))return;const o=b(4)||"anonymous";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const u=t.at(0),c=typeof u=="string"?[(0,D.applyLinePrefix)(`${o?`${o} ${p} `:""}${u}`,{prefix:"[DEBUG] "}),...t.slice(1)]:t,s=e.spinner||(0,m.getSpinner)(),l=s?.isSpinning;s?.stop(),$(d.logger.info,d.logger,c),l&&s?.start()}function B(n,...t){const e=y(n),{namespaces:i}=e;if(!O(i))return;const o=b(4)||"anonymous";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const u=t.at(0),c=typeof u=="string"?[(0,D.applyLinePrefix)(`${o?`${o} ${p} `:""}${u}`,{prefix:"[DEBUG] "}),...t.slice(1)]:[`[DEBUG] ${o} ${p}`,...t],s=e.spinner||(0,m.getSpinner)(),l=s?.isSpinning;s?.stop(),$(d.logger.info,d.logger,c),l&&s?.start()}function q(n,t,e,i){const o=y(n),{namespaces:u}=o;if(!O(u))return;const c=b(4)||"cache";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const s=`[CACHE] ${c} ${p} ${t}: ${e}`,l=i!==void 0?[s,i]:[s],r=o.spinner||(0,m.getSpinner)(),w=r?.isSpinning;r?.stop(),$(d.logger.info,d.logger,l),w&&r?.start()}function M(n,t,e){if(!(0,a.getSocketDebug)())return;const i=b(3)||"cache";p===void 0&&(p=(0,g.default)()?"\u25B8":">");const o=`[CACHE] ${i} ${p} ${n}: ${t}`;console.log(...e!==void 0?[o,e]:[o])}function P(n){return!!(0,a.getSocketDebug)()&&O(n)}function z(...n){A("*",...n)}function F(n,t){v("*",n,t)}function K(...n){B("*",...n)}function Q(){return!!(0,a.getSocketDebug)()}function V(n){return N().debuglog(n)}function X(n){const t=N();let e;const i=()=>{if(e===void 0)e=Date.now();else{const o=Date.now()-e;t.debuglog("time")(`${n}: ${o}ms`),e=void 0}};return i.start=()=>{e=Date.now()},i.end=()=>{if(e!==void 0){const o=Date.now()-e;t.debuglog("time")(`${n}: ${o}ms`),e=void 0}},i}0&&(module.exports={debug,debugCache,debugCacheNs,debugDir,debugDirNs,debugLog,debugLogNs,debugNs,debuglog,debugtime,isDebug,isDebugNs});
//# sourceMappingURL=debug.js.map
