import{g as n}from"./index-xQwnxqUU.chunk.mjs";var s=(o=>(o[o.Debug=0]="Debug",o[o.Info=1]="Info",o[o.Warn=2]="Warn",o[o.Error=3]="Error",o[o.Fatal=4]="Fatal",o))(s||{});class c{context;constructor(t){this.context=t||{}}formatMessage(t,e,r){let a="["+s[e].toUpperCase()+"] ";return r&&r.app&&(a+=r.app+": "),typeof t=="string"?a+t:(a+=`Unexpected ${t.name}`,t.message&&(a+=` "${t.message}"`),e===s.Debug&&t.stack&&(a+=`

Stack trace:
${t.stack}`),a)}log(t,e,r){if(!(typeof this.context?.level=="number"&&t<this.context?.level))switch(typeof e=="object"&&r?.error===void 0&&(r.error=e),t){case s.Debug:console.debug(this.formatMessage(e,s.Debug,r),r);break;case s.Info:console.info(this.formatMessage(e,s.Info,r),r);break;case s.Warn:console.warn(this.formatMessage(e,s.Warn,r),r);break;case s.Error:console.error(this.formatMessage(e,s.Error,r),r);break;case s.Fatal:default:console.error(this.formatMessage(e,s.Fatal,r),r);break}}debug(t,e){this.log(s.Debug,t,Object.assign({},this.context,e))}info(t,e){this.log(s.Info,t,Object.assign({},this.context,e))}warn(t,e){this.log(s.Warn,t,Object.assign({},this.context,e))}error(t,e){this.log(s.Error,t,Object.assign({},this.context,e))}fatal(t,e){this.log(s.Fatal,t,Object.assign({},this.context,e))}}function i(o){return new c(o)}class l{context;factory;constructor(t){this.context={},this.factory=t}setApp(t){return this.context.app=t,this}setLogLevel(t){return this.context.level=t,this}setUid(t){return this.context.uid=t,this}detectUser(){const t=n();return t!==null&&(this.context.uid=t.uid),this}detectLogLevel(){const t=this,e=()=>{document.readyState==="complete"||document.readyState==="interactive"?(t.context.level=window._oc_config?.loglevel??s.Warn,window._oc_debug&&(t.context.level=s.Debug),document.removeEventListener("readystatechange",e)):document.addEventListener("readystatechange",e)};return e(),this}build(){return this.context.level===void 0&&this.detectLogLevel(),this.factory(this.context)}}function h(){return new l(i)}export{h as g};
//# sourceMappingURL=index-DtbbSwig.chunk.mjs.map
