import{f as c,i as m}from"./region-DAq9HKph.js";const l="_shade_li6jm_1",u="_box_li6jm_8",a={shade:l,box:u};let i=!1;function v(){if(i)return;i=!0;const e=document.createElement("div");e.className=a.shade;const t=document.createElement("div");t.className=a.box;let o=null;document.body.append(e,t);const d=()=>{e.remove(),t.remove(),i=!1,document.removeEventListener("keydown",r,!0)},r=n=>{n.key==="Escape"&&(chrome.runtime.sendMessage({kind:"region-cancelled"}),d())};document.addEventListener("keydown",r,!0),e.addEventListener("mousedown",n=>{o={clientX:n.clientX,clientY:n.clientY}}),e.addEventListener("mousemove",n=>{if(!o)return;const s=c(o,n,window.devicePixelRatio||1);t.style.left=`${s.x}px`,t.style.top=`${s.y}px`,t.style.width=`${s.w}px`,t.style.height=`${s.h}px`}),e.addEventListener("mouseup",n=>{if(!o)return;const s=c(o,n,window.devicePixelRatio||1);if(d(),m(s)){chrome.runtime.sendMessage({kind:"region-cancelled"});return}chrome.runtime.sendMessage({kind:"region-selected",region:s})})}chrome.runtime.onMessage.addListener(e=>(e.kind==="start-region-select"&&v(),!1));
