export class Fullscreen {
    constructor(element) {
        this.requestFullscreen = () => {
            if (this.enter) {
                this.enter();
            }
        };
        this.exitFullscreen = () => {
            if (this.exit) {
                this.exit.bind(window.document)();
            }
        };
        this.toggle = () => {
            const doc = window.document;
            const isFullscreen = doc.fullscreenElement ||
                doc.mozFullScreenElement ||
                doc.webkitFullscreenElement ||
                doc.msFullscreenElement;
            if (isFullscreen) {
                this.exitFullscreen();
            }
            else {
                this.requestFullscreen();
            }
        };
        this.enter =
            element.requestFullscreen ||
                element.msRequestFullscreen ||
                element.mozRequestFullScreen ||
                element.webkitRequestFullscreen;
        this.enter = this.enter.bind(element);
        const doc = window.document;
        this.exit =
            doc.exitFullscreen ||
                doc.msExitFullscreen ||
                doc.mozCancelFullScreen ||
                doc.webkitExitFullscreen;
    }
    isSupported() {
        return !!this.requestFullscreen;
    }
}
