/*
 * @Author: 覃伟锋 792575027@qq.com
 * @Date: 2023-01-01 20:40:15
 * @LastEditors: 覃伟锋 792575027@qq.com
 * @LastEditTime: 2023-01-01 20:40:32
 * @FilePath: \wantonly-drag\public\canvas\yanhua\static\js\fscreen.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// A manual UMD build of Fscreen: https://github.com/rafrex/fscreen

(function (global) {
    let key = {
        fullscreenEnabled: 0,
        fullscreenElement: 1,
        requestFullscreen: 2,
        exitFullscreen: 3,
        fullscreenchange: 4,
        fullscreenerror: 5,
    }
  
    let webkit = ['webkitFullscreenEnabled', 'webkitFullscreenElement', 'webkitRequestFullscreen', 'webkitExitFullscreen', 'webkitfullscreenchange', 'webkitfullscreenerror']
  
    let moz = ['mozFullScreenEnabled', 'mozFullScreenElement', 'mozRequestFullScreen', 'mozCancelFullScreen', 'mozfullscreenchange', 'mozfullscreenerror']
  
    let ms = ['msFullscreenEnabled', 'msFullscreenElement', 'msRequestFullscreen', 'msExitFullscreen', 'MSFullscreenChange', 'MSFullscreenError']
  
    // so it doesn't throw if no window or document
    let doc = typeof window !== 'undefined' && typeof window.document !== 'undefined' ? window.document : {}
  
    let vendor = 'fullscreenEnabled' in doc && Object.keys(key) || webkit[0] in doc && webkit || moz[0] in doc && moz || ms[0] in doc && ms || []
  
    let fscreen = {
        requestFullscreen: function requestFullscreen(element) {
            return element[vendor[key.requestFullscreen]]()
        },
        requestFullscreenFunction: function requestFullscreenFunction(element) {
            return element[vendor[key.requestFullscreen]]
        },
        get exitFullscreen() {
            return doc[vendor[key.exitFullscreen]].bind(doc)
        },
        addEventListener: function addEventListener(type, handler, options) {
            return doc.addEventListener(vendor[key[type]], handler, options)
        },
        removeEventListener: function removeEventListener(type, handler) {
            return doc.removeEventListener(vendor[key[type]], handler)
        },
        get fullscreenEnabled() {
            return Boolean(doc[vendor[key.fullscreenEnabled]])
        },
        set fullscreenEnabled(val) {},
        get fullscreenElement() {
            return doc[vendor[key.fullscreenElement]]
        },
        set fullscreenElement(val) {},
        get onfullscreenchange() {
            return doc[('on' + vendor[key.fullscreenchange]).toLowerCase()]
        },
        set onfullscreenchange(handler) {
            return doc[('on' + vendor[key.fullscreenchange]).toLowerCase()] = handler
        },
        get onfullscreenerror() {
            return doc[('on' + vendor[key.fullscreenerror]).toLowerCase()]
        },
        set onfullscreenerror(handler) {
            return doc[('on' + vendor[key.fullscreenerror]).toLowerCase()] = handler
        },
    }
    
    global.fscreen = fscreen
}(window))