import{b as e,e as t}from"./p-2ade684f.js";import{i as s}from"./p-add8f9c6.js";const i=new class{constructor(){this.listeners=[],this.listenKeyPress()}register(e){e.map((e=>e.eventName||(e.eventName="keyup"))),this.listeners=this.listeners.concat(e)}deregister(e){this.listeners=this.listeners.filter((t=>!e.includes(t)))}listenKeyPress(){document.addEventListener("keydown",(e=>{this.invokeListeners("keydown",e)})),document.addEventListener("keyup",(e=>{this.invokeListeners("keyup",e)}))}invokeListeners(e,t){this.listeners.filter((s=>s.eventName===e&&this.shouldInvokeListener(s,t))).forEach((e=>{e.preventDefault&&t.preventDefault(),e.callback(t)}))}shouldInvokeListener(i,o){let n="";o.code?n=o.code:o.key&&"Unidentified"!==o.key&&(n=o.key);let r=[],c=[];const d=Array.isArray(i.keyCode)?i.keyCode.includes(n):i.keyCode===n;if(!d)return!1;"function"==typeof i.activeElementInScope?r=i.activeElementInScope():"object"==typeof i.activeElementInScope&&(r=i.activeElementInScope),"function"==typeof i.activeElementOutScope?c=i.activeElementOutScope():"object"==typeof i.activeElementOutScope&&(c=i.activeElementOutScope);const u=!i.activeElementInScope||r.some((s=>e(t(document,!0),s)));if(!u)return!1;const f=!i.activeElementOutScope||c.every((s=>!e(t(document,!0),s))),h=!s(i.modifierPressed)||i.modifierPressed===this.isModifierPressed(o),a=!s(i.shiftKey)||i.shiftKey===o.shiftKey;return d&&u&&f&&h&&a}isModifierPressed(e){return/Mac|iPhone|iPad/.test(navigator.userAgent)?e.metaKey:e.ctrlKey}};export{i as K}