// src/hooks/focus/useFocusGuards.ts
import { useEffect } from "react";
var selectorName = "data-hw-focus-guard";
function FocusGuard() {
  const element = document.createElement("div");
  element.setAttribute(selectorName, "");
  element.tabIndex = 0;
  element.style.border = "none";
  element.style.outline = "none";
  element.style.boxShadow = "none";
  element.style.opacity = "0";
  element.style.position = "fixed";
  element.style.pointerEvents = "none";
  return element;
}
var FocusGuardsService = class _FocusGuardsService {
  constructor() {
    this.count = 0;
  }
  static getInstance() {
    if (!_FocusGuardsService.instance) {
      _FocusGuardsService.instance = new _FocusGuardsService();
    }
    return _FocusGuardsService.instance;
  }
  add() {
    const edgeGuards = document.querySelectorAll(`[${selectorName}]`);
    document.body.insertAdjacentElement("afterbegin", edgeGuards[0] ?? FocusGuard());
    document.body.insertAdjacentElement("beforeend", edgeGuards[1] ?? FocusGuard());
    this.count++;
  }
  remove() {
    if (this.count === 1) {
      document.querySelectorAll(`[${selectorName}]`).forEach((node) => node.remove());
    }
    this.count--;
  }
};
var useFocusGuards = () => {
  useEffect(() => {
    FocusGuardsService.getInstance().add();
    return () => {
      FocusGuardsService.getInstance().remove();
    };
  }, []);
};
export {
  useFocusGuards
};
//# sourceMappingURL=useFocusGuards.js.map