var background=(function(){function e(e){return e==null||typeof e==`function`?{main:e}:e}async function t(e){let[t]=await chrome.tabs.query({active:!0,currentWindow:!0}),n=t?.id;if(!n)return null;try{return await chrome.tabs.sendMessage(n,e)}catch{return await chrome.scripting.executeScript({target:{tabId:n},files:[`content-scripts/content.js`]}),await new Promise(e=>setTimeout(e,100)),chrome.tabs.sendMessage(n,e)}}var n=e(()=>{chrome.runtime.onMessage.addListener(e=>{if(e.type===`TOGGLE`)return(async()=>{let n=(await t(e))?.enabled??!1;return await chrome.storage.local.set({enabled:n}),{enabled:n}})();if(e.type===`GET_STATE`)return(async()=>{let n=await t(e);return{enabled:n?.enabled??!1,squatCount:n?.squatCount??0}})()})});globalThis.browser?.runtime?.id?globalThis.browser:globalThis.chrome;var r=class{constructor(e){if(e===`<all_urls>`)this.isAllUrls=!0,this.protocolMatches=[...r.PROTOCOLS],this.hostnameMatch=`*`,this.pathnameMatch=`*`;else{let t=/(.*):\/\/(.*?)(\/.*)/.exec(e);if(t==null)throw new a(e,`Incorrect format`);let[n,r,i,c]=t;o(e,r),s(e,i),this.protocolMatches=r===`*`?[`http`,`https`]:[r],this.hostnameMatch=i,this.pathnameMatch=c}}includes(e){if(this.isAllUrls)return!0;let t=typeof e==`string`?new URL(e):e instanceof Location?new URL(e.href):e;return!!this.protocolMatches.find(e=>{if(e===`http`)return this.isHttpMatch(t);if(e===`https`)return this.isHttpsMatch(t);if(e===`file`)return this.isFileMatch(t);if(e===`ftp`)return this.isFtpMatch(t);if(e===`urn`)return this.isUrnMatch(t)})}isHttpMatch(e){return e.protocol===`http:`&&this.isHostPathMatch(e)}isHttpsMatch(e){return e.protocol===`https:`&&this.isHostPathMatch(e)}isHostPathMatch(e){if(!this.hostnameMatch||!this.pathnameMatch)return!1;let t=[this.convertPatternToRegex(this.hostnameMatch),this.convertPatternToRegex(this.hostnameMatch.replace(/^\*\./,``))],n=this.convertPatternToRegex(this.pathnameMatch);return!!t.find(t=>t.test(e.hostname))&&n.test(e.pathname)}isFileMatch(e){throw Error(`Not implemented: file:// pattern matching. Open a PR to add support`)}isFtpMatch(e){throw Error(`Not implemented: ftp:// pattern matching. Open a PR to add support`)}isUrnMatch(e){throw Error(`Not implemented: urn:// pattern matching. Open a PR to add support`)}convertPatternToRegex(e){let t=this.escapeForRegex(e).replace(/\\\*/g,`.*`);return RegExp(`^${t}$`)}escapeForRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}},i=r;i.PROTOCOLS=[`http`,`https`,`file`,`ftp`,`urn`];var a=class extends Error{constructor(e,t){super(`Invalid match pattern "${e}": ${t}`)}};function o(e,t){if(!i.PROTOCOLS.includes(t)&&t!==`*`)throw new a(e,`${t} not a valid protocol (${i.PROTOCOLS.join(`, `)})`)}function s(e,t){if(t.includes(`:`))throw new a(e,`Hostname cannot include a port`);if(t.includes(`*`)&&t.length>1&&!t.startsWith(`*.`))throw new a(e,`If using a wildcard (*), it must go at the start of the hostname`)}var c={debug:(...e)=>([...e],void 0),log:(...e)=>([...e],void 0),warn:(...e)=>([...e],void 0),error:(...e)=>([...e],void 0)},l;try{l=n.main(),l instanceof Promise&&console.warn(`The background's main() function return a promise, but it must be synchronous`)}catch(e){throw c.error(`The background crashed on startup!`),e}return l})();