(function(){const c={debug:10,log:20,warn:30,error:40,none:100},s=()=>{try{return globalThis.SiteConfig&&globalThis.SiteConfig.LOG_LEVEL||"none"}catch{return"none"}},f=()=>{try{return!!(globalThis.SiteConfig&&globalThis.SiteConfig.LOG_MIRROR_TO_BG)}catch{return!1}},l=typeof window>"u"||!globalThis.document;function t(n){return(c[n]||100)>=(c[s()]||100)}function g(n){if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};try{const e=new WeakSet,r=JSON.stringify(n,(a,o)=>{if(typeof o=="function")return`[Function ${o.name||"anonymous"}]`;if(typeof o=="symbol")return o.toString();if(typeof o=="object"&&o!==null){if(e.has(o))return"[Circular]";e.add(o)}return o});return JSON.parse(r)}catch{try{return String(n)}catch{return"[unserializable]"}}}function i(n,e,r){if(!(!f()||l))try{if(!(globalThis.chrome&&chrome.runtime&&chrome.runtime.sendMessage))return;const a=(r||[]).map(g),o=typeof location<"u"&&location&&location.href?location.href:"";chrome.runtime.sendMessage({type:"LOG_MIRROR",level:n,prefix:e||"",args:a,pageUrl:o,ts:Date.now()})}catch{}}function u(n=""){const e=n?String(n):"";return{debug:(...r)=>{if(t("debug")){try{console.debug(e,...r)}catch{}i("debug",e,r)}},log:(...r)=>{if(t("log")){try{console.log(e,...r)}catch{}i("log",e,r)}},warn:(...r)=>{if(t("warn")){try{console.warn(e,...r)}catch{}i("warn",e,r)}},error:(...r)=>{if(t("error")){try{console.error(e,...r)}catch{}i("error",e,r)}},level:()=>s()}}globalThis.Logger={createLogger:u}})();
