export class ElementActivationController {
    host;
    config;
    constructor(host, config) {
        this.host = host;
        this.config = config;
    }
    hostDidLoad() {
        if (!this.host.el.hasAttribute('tabindex')) {
            console.warn('Interactive element does not have a tabindex attribute!', this.host.el);
        }
        this.host.el.addEventListener('keydown', this.handleKeyDown.bind(this));
        this.host.el.addEventListener('click', this.handleActivation.bind(this));
    }
    handleKeyDown = (event) => {
        if ((this.config?.keys ?? ['Enter', ' ']).includes(event.key)) {
            event.preventDefault();
            this.handleActivation(event);
        }
    };
    handleActivation = (event) => {
        this.host.lmvzActivation.emit();
        if (this.config?.localHandler) {
            this.config.localHandler(event);
        }
    };
}
