(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`98855b37a3d52795063fb5f65b16b203e1f309a7`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`3721610e-92b2-4de0-9187-bb9729351e35`,e._sentryDebugIdIdentifier=`sentry-dbid-3721610e-92b2-4de0-9187-bb9729351e35`)}catch{}})();import"./chunks/element-plus-B1fHG2BL.js";import"./chunks/vue-Dx4PbTpV.js";import{a as e,f as t}from"./chunks/main-CNgG4xjc.js";import{t as n}from"./chunks/match-D-xqwulV.js";new class{currentTabId=0;currentURL=void 0;init(){!chrome.tabs||!chrome.runtime||this.setupTabEventListener()}setupTabEventListener(){chrome.tabs.onUpdated.addListener(this.handleTabOnUpdated),chrome.tabs.onActivated.addListener(this.handleTabOnActivated),chrome.runtime.onMessage.addListener(this.handleRuntimeMessage)}handleRuntimeMessage=async e=>{switch(e.action){case t.UpdateEnabledCollectionListData:await this.sendMatchData();break;case t.UpdateTabURL:this.setCurrentURL(e.url),chrome.tabs.update(this.currentTabId,{url:this.currentURL});break}};dispatchCommand=e=>{chrome.tabs.sendMessage(this.currentTabId,{action:t.DispatchCommand,command:e})};handleTabOnUpdated=async(e,t,n)=>{t.status===`complete`&&(this.setCurrentTabId(e),this.setCurrentURL(n.url),await this.sendMatchData())};handleTabOnActivated=async e=>{let t=await chrome.tabs.get(e.tabId);this.setCurrentTabId(e.tabId),this.setCurrentURL(t.url),await this.sendMatchData()};sendMatchData=async()=>{let e=await this.getMatchData();this.currentURL&&this.currentURL.startsWith(`http`)&&chrome.tabs.sendMessage(this.currentTabId,{action:t.SendMatchData,url:this.currentURL,data:e})};setCurrentTabId(e){this.currentTabId=e}setCurrentURL(t){this.currentURL=t,chrome.storage&&e.setItem(`currentURL`,this.currentURL)}getCurrentURL(){return this.currentURL}getMatchData=async()=>{if(!this.currentURL)return[];let t=await e.getItem(`enabledCollectionList`);if(!t)return[];let r=JSON.parse(t);return n(this.currentURL,r)}}().init();
//# sourceMappingURL=serviceWorker.js.map