const S={BASE_URL:"/",DEV:!1,MODE:"production",PROD:!0,SSR:!1};var T={};const A=["VITE_ENABLE_CONSOLE_LOGS","NEXT_PUBLIC_ENABLE_CONSOLE_LOGS","ENABLE_CONSOLE_LOGS"],g=["error","warn"],R=new Set(["true","1","yes","on"]),b=new Set(["false","0","no","off"]),d={log:console.log.bind(console),info:console.info.bind(console),debug:console.debug.bind(console),warn:console.warn.bind(console),error:console.error.bind(console)};let u=I(),P=new Set(g),N=!1,f,c;function y(r){if(r!=null){if(typeof r=="boolean")return r;if(typeof r=="number")return r!==0;if(typeof r=="string"){const o=r.trim().toLowerCase();if(R.has(o))return!0;if(b.has(o))return!1}}}function m(r){try{const o=typeof process<"u"?T==null?void 0:T[r]:void 0;if(o!==void 0)return o}catch{}try{const o=typeof import.meta<"u"?S==null?void 0:S[r]:void 0;if(o!==void 0)return o}catch{}}function I(r=A,o=!1){for(const e of r){const n=m(e),t=y(n);if(t!==void 0)return t}return o}function G(r){return u||P.has(r)}function w(r,o){return r?[`[${r}]`,...o]:o}function h(r){u=r}function H(r){if(typeof r=="string")return r;try{return JSON.stringify(r)}catch{return String(r)}}function W(r,o,e){const n=new Date().toISOString(),t=o?`[${o}]`:void 0,l=e.map(H).join(" ");return[n,t,r.toUpperCase(),l].filter(Boolean).join(" ")}function p(){try{const r=typeof require<"u"?require:void 0;if(r)return r("fs")}catch{}}function U(){var r;try{return typeof globalThis.chrome<"u"?(r=globalThis.chrome)==null?void 0:r.storage:void 0}catch{}}function C(r){return!!r&&typeof r.then=="function"}function v(r=500){const o=U();if(!o){c=void 0;return}const e=n=>{d.warn("Chrome storage write error",n)};c=n=>{try{const t=["extensionLogs"],l=s=>{const E=s,D=[...Array.isArray(E==null?void 0:E.extensionLogs)?E.extensionLogs:[],n].slice(-r),L=o.local.set({extensionLogs:D},()=>{var _;typeof globalThis.chrome<"u"&&((_=globalThis.chrome.runtime)!=null&&_.lastError)&&e(globalThis.chrome.runtime.lastError)});C(L)&&L.catch(e)},O=o.local.get(t,s=>{var E;l(s),typeof globalThis.chrome<"u"&&((E=globalThis.chrome.runtime)!=null&&E.lastError)&&e(globalThis.chrome.runtime.lastError)});C(O)&&O.then(l).catch(e)}catch(t){e(t)}}}function B(r){if(!r){f=void 0;return}const o=p();if(!o){d.warn("File logging requested but fs is unavailable in this runtime"),f=void 0;return}f=e=>{o.promises.appendFile(r,`${e}
`).catch(n=>{d.warn("Failed to write log file entry",n)})}}function i(r,o){return(...e)=>{if(!G(r))return;const n=d[r];n(...w(o,e));const t=W(r,o,e);f&&f(t),c&&c(t)}}function F(r){N||(N=!0,console.log=i("log",r),console.info=i("info",r),console.debug=i("debug",r),console.warn=i("warn",r),console.error=i("error",r))}function K(r={}){return u=r.enabled??I(r.flagNames,r.defaultEnabled??!1),P=new Set(r.alwaysEnabledLevels??g),r.filePath&&!r.useStorageApi?B(r.filePath):f=void 0,r.useStorageApi?v(r.maxLogs??500):c=void 0,r.patchConsole&&F(r.namespace),u}function Y(){return u}function k(r){return{log:i("log",r),info:i("info",r),debug:i("debug",r),warn:i("warn",r),error:i("error",r),enable:()=>h(!0),disable:()=>h(!1),isEnabled:Y}}var V=(r=>(r.TOGGLE_OVERLAY="TOGGLE_OVERLAY",r.OPEN_SIDEPANEL="OPEN_SIDEPANEL",r.OPENED_SIDEPANEL="OPENED_SIDEPANEL",r.CLOSE_SIDEPANEL="CLOSE_SIDEPANEL",r.SHOW_PRODUCT="SHOW_PRODUCT",r.PROFILE_CREATED="PROFILE_CREATED",r.PROFILE_CHANGED="PROFILE_CHANGED",r.SETTINGS_UPDATED="SETTINGS_UPDATED",r.PRODUCT_ANALYZED="PRODUCT_ANALYZED",r.START_HIGHLIGHTER="START_HIGHLIGHTER",r.WAITING_FOR_HIGHLIGHTER="WAITING_FOR_HIGHLIGHTER",r.CSS_SELECTED="CSS_SELECTED",r.OPEN_TASKEDITOR="OPEN_TASKEDITOR",r.EXECUTE_TASK="EXECUTE_TASK",r.HIGHLIGHTER_CONTEXT_READY="HIGHLIGHTER_CONTEXT_READY",r.ON_SHOW_SUCCESS="ON_SHOW_SUCCESS",r.ON_SHOW_ERROR="ON_SHOW_ERROR",r.ON_SHOW_WARNING="ON_SHOW_WARNING",r.COMPANY_CREATED="COMPANY_CREATED",r.COMPANY_DELETED="COMPANY_DELETED",r))(V||{}),a=(r=>(r.CONTEXT_MENU="CONTEXT_MENU",r.SIDE_PANEL="SIDE_PANEL",r.BACKGROUND_SCRIPT="BACKGROUND_SCRIPT",r.CONTENT_SCRIPT="CONTENT_SCRIPT",r.WEB_APP="WEB_APP",r.ONLINE_APP="ONLINE_APP",r.ALL="ALL",r))(a||{});class ${passMessageToBroker(o){console.info("Should we openside panel:false");{const n=o.recipients.includes(a.CONTENT_SCRIPT),t=o.recipients.some(l=>l!==a.CONTENT_SCRIPT);n&&q(o),t&&X(o)}}}function X(r){var o;typeof chrome<"u"&&((o=chrome.runtime)!=null&&o.sendMessage)&&chrome.runtime.sendMessage(r),typeof window<"u"&&window.dispatchEvent(new CustomEvent("app-message",{detail:r}))}function q(r){var o;typeof chrome<"u"&&((o=chrome.tabs)!=null&&o.query)&&chrome.tabs.query({active:!0,currentWindow:!0},e=>{var n;if(!e||e.length===0||!((n=e[0])!=null&&n.id)){console.warn("No active tab found or tab ID is missing.");return}chrome.tabs.sendMessage(e[0].id,{message:r})})}export{$ as M,a,V as b,k as c,K as d};
