import { Controller } from '@hotwired/stimulus';

export default class extends Controller {
    connect() {
        let timer = setTimeout(() => {
                this.element.remove();
            },
            "3000"
        );

        this.element.addEventListener('mouseout', () => timer = setTimeout(() => {
                this.element.remove();
            },
            "3000"
        ));
        this.element.addEventListener('mouseover', () => clearTimeout(timer));
        this.element.querySelector('.modal-close').addEventListener('click', () => this.element.remove());
    }
}
