import{D as f}from"./api-D2MZ7O5A.js";import{S as r}from"./storage-pXeRtiJs.js";(function(){function h(a){return(a||"").replace(/\s+/g," ").trim()}function l(){return new Promise(a=>{chrome.storage.sync.get([r.API_KEY,r.ACCESS_TOKEN,r.USER_ID,r.SELECTED_PROJECT,r.MEMORY_ENABLED],t=>{a({hasCreds:!!(t[r.API_KEY]||t[r.ACCESS_TOKEN]),apiKey:t[r.API_KEY],accessToken:t[r.ACCESS_TOKEN],userId:t[r.USER_ID]||f,projectId:t[r.SELECTED_PROJECT],projectName:null,platformBaseUrl:null,defaultCategory:null,memoryEnabled:t[r.MEMORY_ENABLED]!==!1})})})}function s(a,t){const n=h(t);!n||n.length<2||l().then(async e=>{!e.hasCreds||e.memoryEnabled===!1||await new Promise(o=>{try{chrome.storage.sync.get([r.TRACK_SEARCHES],u=>{o(u[r.TRACK_SEARCHES]===!0)})}catch{o(!1)}})})}function i(){const a=location.hostname||"",t=location.pathname||"",n=new URLSearchParams(location.search||"");if(/(^|\.)google\./.test(a)&&t.startsWith("/search")){const e=n.get("q");e&&s("Google",e);return}if(a.endsWith("bing.com")&&(t==="/search"||t==="/")){const e=n.get("q");e&&s("Bing",e);return}if(a==="search.brave.com"&&(t==="/search"||t==="/images")){const e=n.get("q");e&&s("Brave",e);return}if(a==="search.arc.net"&&(t==="/search"||t.startsWith("/search"))){const e=n.get("q")||n.get("query");e&&s("Arc",e);return}}function E(){const a=history.pushState.bind(history),t=history.replaceState.bind(history),n=()=>{try{i()}catch{return}};history.pushState=function(e,c,o){a(e,c,o),n()},history.replaceState=function(e,c,o){t(e,c,o),n()},window.addEventListener("popstate",n)}i(),E()})();
