import { __decorate } from "../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorate.js";
import { focusedElementContext } from "./focusedElementContext.js";
import { consume } from "@lit/context";
import { LitElement, css, html } from "lit";
import { customElement } from "lit/decorators.js";
import { createRef, ref } from "lit/directives/ref.js";

//#region src/gui/EFFocusOverlay.ts
let EFFocusOverlay = class EFFocusOverlay$1 extends LitElement {
	constructor(..._args) {
		super(..._args);
		this.overlay = createRef();
		this.drawOverlay = () => {
			const overlay = this.overlay.value;
			if (overlay) if (this.focusedElement) {
				overlay.style.display = "block";
				const rect = this.focusedElement.getBoundingClientRect();
				Object.assign(overlay.style, {
					top: `${rect.top}px`,
					left: `${rect.left}px`,
					width: `${rect.width}px`,
					height: `${rect.height}px`
				});
				this.animationFrame = requestAnimationFrame(this.drawOverlay);
			} else overlay.style.display = "none";
		};
	}
	static {
		this.styles = css`
    :host {
      display: block;
      position: relative;
      width: 100%;
      height: 100%;
      pointer-events: none;
    }
    .overlay {
      position: fixed;
      outline: 2px solid var(--ef-focus-overlay-color, var(--ef-color-primary));
      background: var(--ef-focus-overlay-background, var(--ef-color-primary));
      outline: 2px solid var(--ef-focus-overlay-color, var(--ef-color-primary));
      mix-blend-mode: multiply;
      opacity: 0.4;
      display: none;
    }
  `;
	}
	render() {
		return html`<div ${ref(this.overlay)} class="overlay"></div>`;
	}
	connectedCallback() {
		super.connectedCallback();
		this.drawOverlay();
	}
	disconnectedCallback() {
		super.disconnectedCallback();
		if (this.animationFrame) cancelAnimationFrame(this.animationFrame);
	}
	updated() {
		this.drawOverlay();
	}
};
__decorate([consume({
	context: focusedElementContext,
	subscribe: true
})], EFFocusOverlay.prototype, "focusedElement", void 0);
EFFocusOverlay = __decorate([customElement("ef-focus-overlay")], EFFocusOverlay);

//#endregion
export { EFFocusOverlay };
//# sourceMappingURL=EFFocusOverlay.js.map