".concat(t,"
")})).join(""),this.art.emit("subtitle:update",this.activeCue.text))}},{key:"switch",value:function(t,e){var n=this,r=this.art,i=r.i18n,o=r.notice;return this.init(t).then((function(t){return e&&(o.show="".concat(i.get("Switch subtitle"),": ").concat(e)),n.art.emit("subtitle:switch",t),t}))}},{key:"init",value:function(t){var e=this,n=this.art,r=n.notice,i=n.template,o=i.$subtitle,a=i.$track;return fetch(t).then((function(t){return t.text()})).then((function(n){switch(e.art.emit("subtitle:load",t),D(t)){case"srt":return R($(n));case"ass":return R(T(n));case"vtt":return R(n);default:return t}})).then((function(t){return o.innerHTML="",e.url===t?t:(URL.revokeObjectURL(e.url),a.src=t,t)})).catch((function(t){throw r.show=t,e.art.emit("subtitle:err",t),t}))}},{key:"url",get:function(){return this.art.template.$track.src}},{key:"textTrack",get:function(){return this.art.template.$video.textTracks[0]}},{key:"activeCue",get:function(){return this.textTrack.activeCues[0]}}]),r}(ct);var Zt=function(){function e(n){var r=this;t(this,e),this.destroyEvents=[],this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),this.loadImg=this.loadImg.bind(this),n.whitelist.state&&n.on("ready",(function(){!function(t,e){var n=t.template.$player;e.proxy(document,["click","contextmenu"],(function(e){e.composedPath().indexOf(n)>-1?(t.isFocus=!0,t.emit("focus")):(t.isFocus=!1,t.emit("blur"))}))}(n,r),function(t,e){var n=t.template.$player;e.hover(n,(function(){h(n,"art-hover"),t.emit("hoverenter")}),(function(){y(n,"art-hover"),t.emit("hoverleave")}))}(n,r),function(t,e){var n=t.template,r=n.$player,i=n.$video,o=t.player,a=N((function(){h(r,"art-hide-cursor"),y(r,"art-hover"),t.controls.show=!1}),3e3);t.on("hoverleave",(function(){o.playing&&a()})),e.proxy(r,"mousemove",(function(e){a.clearTimeout(),y(r,"art-hide-cursor"),t.controls.show=!0,!t.player.pip&&o.playing&&e.target===i&&a(),t.emit("mousemove")}))}(n,r),function(t,e){var n=t.option,r=t.player,i=t.template.$player,o=document.createElement("object");o.setAttribute("aria-hidden","true"),o.setAttribute("tabindex",-1),o.type="text/html",o.data="about:blank";var a=r.width,c=r.height,s=I((function(){r.width===a&&r.height===c||(a=r.width,c=r.height,n.autoSize&&(t.player.fullscreen||t.player.fullscreenWeb||t.player.pip?t.player.autoSize=!1:t.player.autoSize=!0),t.player.aspectRatioReset=!0,t.emit("resize",{width:r.width,height:r.height}))}),500);e.proxy(o,"load",(function(){e.proxy(o.contentDocument.defaultView,"resize",s)})),i.appendChild(o)}(n,r)}))}return n(e,[{key:"proxy",value:function(t,e,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(Array.isArray(e))return e.map((function(e){return r.proxy(t,e,n,i)}));t.addEventListener(e,n,i);var o=function(){return t.removeEventListener(e,n,i)};return this.destroyEvents.push(o),o}},{key:"hover",value:function(t,e,n){e&&this.proxy(t,"mouseenter",e),n&&this.proxy(t,"mouseleave",n)}},{key:"loadImg",value:function(t){var e=this;return new Promise((function(n,r){var i;if(t instanceof HTMLImageElement)i=t;else{if("string"!=typeof t)return r(t);(i=new Image).src=t}return i.complete?n(i):(e.proxy(i,"load",(function(){return n(i)})),e.proxy(i,"error",(function(){return r(i)})),t)}))}},{key:"destroy",value:function(){this.destroyEvents.forEach((function(t){return t()}))}}]),e}(),Yt=function(){function e(n){var r=this;t(this,e),this.keys={};var i=n.option,o=n.player,a=n.events.proxy;i.hotkey&&n.on("ready",(function(){r.add(27,(function(){o.fullscreenWeb&&(o.fullscreenWeb=!1)})),r.add(32,(function(){o.toggle=!0})),r.add(37,(function(){o.seek=o.currentTime-5})),r.add(38,(function(){o.volume+=.1})),r.add(39,(function(){o.seek=o.currentTime+5})),r.add(40,(function(){o.volume-=.1})),a(window,"keydown",(function(t){if(n.isFocus){var e=document.activeElement.tagName.toUpperCase(),i=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==i&&"true"!==i){var o=r.keys[t.keyCode];o&&(t.preventDefault(),o.forEach((function(t){return t()})),n.emit("hotkey",t))}}}))}))}return n(e,[{key:"add",value:function(t,e){this.keys[t]?this.keys[t].push(e):this.keys[t]=[e]}}]),e}(),Jt=function(e){function n(e){var r;return t(this,n),(r=a(this,c(n).call(this,e))).$parent=e.template.$layer,e.on("ready",(function(){e.option.layers.forEach((function(t){r.add(t)}))})),r}return u(n,e),n}(ct),Gt=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$loading,e.icons.loading),r}return u(n,e),n}(ct),Qt=function(){function e(n){t(this,e),this.art=n,this.time=1e3,this.timer=null}return n(e,[{key:"show",set:function(t){var e=this.art.template,n=e.$player,r=e.$noticeInner;r.innerText=t instanceof Error?t.message.trim():t,h(n,"art-notice-show"),clearTimeout(this.timer),this.timer=setTimeout((function(){r.innerText="",y(n,"art-notice-show")}),this.time)}}]),e}(),Kt=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$state,e.icons.state),r}return u(n,e),n}(ct),te=function e(n){var r=this;t(this,e);var i=Object.assign({loading:'',state:'',play:'',pause:'',volume:'',volumeClose:'',subtitle:'',screenshot:'',setting:'',fullscreen:'',fullscreenWeb:'',pip:''},n.option.icons);Object.keys(i).forEach((function(t){var e=document.createElement("i");e.classList.add("art-icon"),e.classList.add("art-icon-".concat(t)),m(e,i[t]),r[t]=e}))};function ee(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function ne(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e".concat(t,"
")})).join(""),this.art.emit("subtitle:update",this.activeCue.text))}},{key:"switch",value:function(t,e){var n=this,r=this.art,i=r.i18n,o=r.notice;return this.init(t).then((function(t){return e&&(o.show="".concat(i.get("Switch subtitle"),": ").concat(e)),n.art.emit("subtitle:switch",t),t}))}},{key:"init",value:function(t){var e=this,n=this.art,r=n.notice,i=n.template,o=i.$subtitle,a=i.$track;return fetch(t).then((function(t){return t.text()})).then((function(n){switch(e.art.emit("subtitle:load",t),T(t)){case"srt":return R($(n));case"ass":return R(C(n));case"vtt":return R(n);default:return t}})).then((function(t){return o.innerHTML="",e.url===t?t:(URL.revokeObjectURL(e.url),a.src=t,t)})).catch((function(t){throw r.show=t,e.art.emit("subtitle:err",t),t}))}},{key:"url",get:function(){return this.art.template.$track.src}},{key:"textTrack",get:function(){return this.art.template.$video.textTracks[0]}},{key:"activeCue",get:function(){return this.textTrack.activeCues[0]}}]),r}(ct);var Zt=function(){function e(n){var r=this;t(this,e),this.destroyEvents=[],this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),this.loadImg=this.loadImg.bind(this),n.whitelist.state&&n.on("ready",(function(){!function(t,e){var n=t.template.$player;e.proxy(document,["click","contextmenu"],(function(e){e.composedPath().indexOf(n)>-1?(t.isFocus=!0,t.emit("focus")):(t.isFocus=!1,t.emit("blur"))}))}(n,r),function(t,e){var n=t.template.$player;e.hover(n,(function(){h(n,"art-hover"),t.emit("hoverenter")}),(function(){y(n,"art-hover"),t.emit("hoverleave")}))}(n,r),function(t,e){var n=t.template,r=n.$player,i=n.$video,o=t.player,a=N((function(){h(r,"art-hide-cursor"),y(r,"art-hover"),t.controls.show=!1}),3e3);t.on("hoverleave",(function(){o.playing&&a()})),e.proxy(r,"mousemove",(function(e){a.clearTimeout(),y(r,"art-hide-cursor"),t.controls.show=!0,!t.player.pip&&o.playing&&e.target===i&&a(),t.emit("mousemove")}))}(n,r),function(t,e){var n=t.option,r=t.player,i=t.template.$player,o=document.createElement("object");o.setAttribute("aria-hidden","true"),o.setAttribute("tabindex",-1),o.type="text/html",o.data="about:blank";var a=r.width,c=r.height,s=I((function(){r.width===a&&r.height===c||(a=r.width,c=r.height,n.autoSize&&(t.player.fullscreen||t.player.fullscreenWeb||t.player.pip?t.player.autoSize=!1:t.player.autoSize=!0),t.player.aspectRatioReset=!0,t.emit("resize",{width:r.width,height:r.height}))}),500);e.proxy(o,"load",(function(){e.proxy(o.contentDocument.defaultView,"resize",s)})),i.appendChild(o)}(n,r)}))}return n(e,[{key:"proxy",value:function(t,e,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(Array.isArray(e))return e.map((function(e){return r.proxy(t,e,n,i)}));t.addEventListener(e,n,i);var o=function(){return t.removeEventListener(e,n,i)};return this.destroyEvents.push(o),o}},{key:"hover",value:function(t,e,n){e&&this.proxy(t,"mouseenter",e),n&&this.proxy(t,"mouseleave",n)}},{key:"loadImg",value:function(t){var e=this;return new Promise((function(n,r){var i;if(t instanceof HTMLImageElement)i=t;else{if("string"!=typeof t)return r(t);(i=new Image).src=t}return i.complete?n(i):(e.proxy(i,"load",(function(){return n(i)})),e.proxy(i,"error",(function(){return r(i)})),t)}))}},{key:"destroy",value:function(){this.destroyEvents.forEach((function(t){return t()}))}}]),e}(),Yt=function(){function e(n){var r=this;t(this,e),this.keys={};var i=n.option,o=n.player,a=n.events.proxy;i.hotkey&&n.on("ready",(function(){r.add(27,(function(){o.fullscreenWeb&&(o.fullscreenWeb=!1)})),r.add(32,(function(){o.toggle=!0})),r.add(37,(function(){o.seek=o.currentTime-5})),r.add(38,(function(){o.volume+=.1})),r.add(39,(function(){o.seek=o.currentTime+5})),r.add(40,(function(){o.volume-=.1})),a(window,"keydown",(function(t){if(n.isFocus){var e=document.activeElement.tagName.toUpperCase(),i=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==i&&"true"!==i){var o=r.keys[t.keyCode];o&&(t.preventDefault(),o.forEach((function(t){return t()})),n.emit("hotkey",t))}}}))}))}return n(e,[{key:"add",value:function(t,e){this.keys[t]?this.keys[t].push(e):this.keys[t]=[e]}}]),e}(),Jt=function(e){function n(e){var r;return t(this,n),(r=a(this,c(n).call(this,e))).$parent=e.template.$layer,e.on("ready",(function(){e.option.layers.forEach((function(t){r.add(t)}))})),r}return u(n,e),n}(ct),Gt=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$loading,e.icons.loading),r}return u(n,e),n}(ct),Qt=function(){function e(n){t(this,e),this.art=n,this.time=2e3,this.timer=null}return n(e,[{key:"show",set:function(t){var e=this.art.template,n=e.$player,r=e.$noticeInner;r.innerText=t instanceof Error?t.message.trim():t,h(n,"art-notice-show"),clearTimeout(this.timer),this.timer=setTimeout((function(){r.innerText="",y(n,"art-notice-show")}),this.time)}}]),e}(),Kt=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$state,e.icons.state),r}return u(n,e),n}(ct),te=function e(n){var r=this;t(this,e);var i=Object.assign({loading:'',state:'',play:'',pause:'',volume:'',volumeClose:'',subtitle:'',screenshot:'',setting:'',fullscreen:'',fullscreenWeb:'',pip:''},n.option.icons);Object.keys(i).forEach((function(t){var e=document.createElement("i");e.classList.add("art-icon"),e.classList.add("art-icon-".concat(t)),m(e,i[t]),r[t]=e}))};function ee(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function ne(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e${item}
`)\n .join('');\n this.art.emit('subtitle:update', this.activeCue.text);\n }\n }\n\n switch(url, name) {\n const { i18n, notice } = this.art;\n return this.init(url).then(subUrl => {\n if (name) {\n notice.show = `${i18n.get('Switch subtitle')}: ${name}`;\n }\n this.art.emit('subtitle:switch', subUrl);\n return subUrl;\n });\n }\n\n init(url) {\n const {\n notice,\n template: { $subtitle, $track },\n } = this.art;\n\n return fetch(url)\n .then(response => {\n return response.text();\n })\n .then(text => {\n this.art.emit('subtitle:load', url);\n switch (getExt(url)) {\n case 'srt':\n return vttToBlob(srtToVtt(text));\n case 'ass':\n return vttToBlob(assToVtt(text));\n case 'vtt':\n return vttToBlob(text);\n default:\n return url;\n }\n })\n .then(subUrl => {\n $subtitle.innerHTML = '';\n if (this.url === subUrl) return subUrl;\n URL.revokeObjectURL(this.url);\n $track.src = subUrl;\n return subUrl;\n })\n .catch(err => {\n notice.show = err;\n this.art.emit('subtitle:err', err);\n throw err;\n });\n }\n}\n","export default function clickInit(art, events) {\n const {\n template: { $player },\n } = art;\n events.proxy(document, ['click', 'contextmenu'], event => {\n if (event.composedPath().indexOf($player) > -1) {\n art.isFocus = true;\n art.emit('focus');\n } else {\n art.isFocus = false;\n art.emit('blur');\n }\n });\n}\n","import { addClass, removeClass } from '../utils';\n\nexport default function hoverInit(art, events) {\n const {\n template: { $player },\n } = art;\n events.hover(\n $player,\n () => {\n addClass($player, 'art-hover');\n art.emit('hoverenter');\n },\n () => {\n removeClass($player, 'art-hover');\n art.emit('hoverleave');\n },\n );\n}\n","import { debounce, addClass, removeClass } from '../utils';\n\nexport default function mousemoveInitInit(art, events) {\n const {\n template: { $player, $video },\n player,\n } = art;\n\n const autoHide = debounce(() => {\n addClass($player, 'art-hide-cursor');\n removeClass($player, 'art-hover');\n art.controls.show = false;\n }, 3000);\n\n art.on('hoverleave', () => {\n if (player.playing) {\n autoHide();\n }\n });\n\n events.proxy($player, 'mousemove', event => {\n autoHide.clearTimeout();\n removeClass($player, 'art-hide-cursor');\n art.controls.show = true;\n if (!art.player.pip && player.playing && event.target === $video) {\n autoHide();\n }\n art.emit('mousemove');\n });\n}\n","import { throttle } from '../utils';\n\nexport default function resizeInit(art, events) {\n const {\n option,\n player,\n template: { $player },\n } = art;\n\n const object = document.createElement('object');\n object.setAttribute('aria-hidden', 'true');\n object.setAttribute('tabindex', -1);\n object.type = 'text/html';\n object.data = 'about:blank';\n let playerWidth = player.width;\n let playerHeight = player.height;\n const resizeFn = throttle(() => {\n if (player.width !== playerWidth || player.height !== playerHeight) {\n playerWidth = player.width;\n playerHeight = player.height;\n if (option.autoSize) {\n if (!art.player.fullscreen && !art.player.fullscreenWeb && !art.player.pip) {\n art.player.autoSize = true;\n } else {\n art.player.autoSize = false;\n }\n }\n art.player.aspectRatioReset = true;\n art.emit('resize', {\n width: player.width,\n height: player.height,\n });\n }\n }, 500);\n\n events.proxy(object, 'load', () => {\n events.proxy(object.contentDocument.defaultView, 'resize', resizeFn);\n });\n\n $player.appendChild(object);\n}\n","import clickInit from './clickInit';\nimport hoverInit from './hoverInit';\nimport mousemoveInit from './mousemoveInit';\nimport resizeInit from './resizeInit';\n\nexport default class Events {\n constructor(art) {\n this.destroyEvents = [];\n this.proxy = this.proxy.bind(this);\n this.hover = this.hover.bind(this);\n this.loadImg = this.loadImg.bind(this);\n\n if (art.whitelist.state) {\n art.on('ready', () => {\n clickInit(art, this);\n hoverInit(art, this);\n mousemoveInit(art, this);\n resizeInit(art, this);\n });\n }\n }\n\n proxy(target, name, callback, option = {}) {\n if (Array.isArray(name)) {\n return name.map(item => this.proxy(target, item, callback, option));\n }\n\n target.addEventListener(name, callback, option);\n const destroy = () => target.removeEventListener(name, callback, option);\n this.destroyEvents.push(destroy);\n return destroy;\n }\n\n hover(target, mouseenter, mouseleave) {\n if (mouseenter) {\n this.proxy(target, 'mouseenter', mouseenter);\n }\n if (mouseleave) {\n this.proxy(target, 'mouseleave', mouseleave);\n }\n }\n\n loadImg(img) {\n return new Promise((resolve, reject) => {\n let image;\n\n if (img instanceof HTMLImageElement) {\n image = img;\n } else if (typeof img === 'string') {\n image = new Image();\n image.src = img;\n } else {\n return reject(img);\n }\n\n if (image.complete) {\n return resolve(image);\n }\n\n this.proxy(image, 'load', () => resolve(image));\n this.proxy(image, 'error', () => reject(image));\n\n return img;\n });\n }\n\n destroy() {\n this.destroyEvents.forEach(event => event());\n }\n}\n","export default class Hotkey {\n constructor(art) {\n this.keys = {};\n\n const {\n option,\n player,\n events: { proxy },\n } = art;\n\n if (option.hotkey) {\n art.on('ready', () => {\n this.add(27, () => {\n if (player.fullscreenWeb) {\n player.fullscreenWeb = false;\n }\n });\n\n this.add(32, () => {\n player.toggle = true;\n });\n\n this.add(37, () => {\n player.seek = player.currentTime - 5;\n });\n\n this.add(38, () => {\n player.volume += 0.1;\n });\n\n this.add(39, () => {\n player.seek = player.currentTime + 5;\n });\n\n this.add(40, () => {\n player.volume -= 0.1;\n });\n\n proxy(window, 'keydown', event => {\n if (art.isFocus) {\n const tag = document.activeElement.tagName.toUpperCase();\n const editable = document.activeElement.getAttribute('contenteditable');\n if (tag !== 'INPUT' && tag !== 'TEXTAREA' && editable !== '' && editable !== 'true') {\n const events = this.keys[event.keyCode];\n if (events) {\n event.preventDefault();\n events.forEach(fn => fn());\n art.emit('hotkey', event);\n }\n }\n }\n });\n });\n }\n }\n\n add(key, event) {\n if (this.keys[key]) {\n this.keys[key].push(event);\n } else {\n this.keys[key] = [event];\n }\n }\n}\n","import Component from './utils/component';\n\nexport default class Layer extends Component {\n constructor(art) {\n super(art);\n this.$parent = art.template.$layer;\n art.on('ready', () => {\n art.option.layers.forEach(item => {\n this.add(item);\n });\n });\n }\n}\n","import { append } from './utils';\nimport Component from './utils/component';\n\nexport default class Loading extends Component {\n constructor(art) {\n super(art);\n append(art.template.$loading, art.icons.loading);\n }\n}\n","import { addClass, removeClass } from './utils';\n\nexport default class Notice {\n constructor(art) {\n this.art = art;\n this.time = 1000;\n this.timer = null;\n }\n\n set show(msg) {\n const { $player, $noticeInner } = this.art.template;\n $noticeInner.innerText = msg instanceof Error ? msg.message.trim() : msg;\n addClass($player, 'art-notice-show');\n clearTimeout(this.timer);\n this.timer = setTimeout(() => {\n removeClass($player, 'art-notice-show');\n }, this.time);\n }\n}\n","import { append } from './utils';\nimport Component from './utils/component';\n\nexport default class Mask extends Component {\n constructor(art) {\n super(art);\n append(art.template.$state, art.icons.state);\n }\n}\n","import { append } from '../utils';\nimport loading from './loading.svg';\nimport state from './state.svg';\nimport play from './play.svg';\nimport pause from './pause.svg';\nimport volume from './volume.svg';\nimport volumeClose from './volume-close.svg';\nimport subtitle from './subtitle.svg';\nimport screenshot from './screenshot.svg';\nimport setting from './setting.svg';\nimport fullscreen from './fullscreen.svg';\nimport fullscreenWeb from './fullscreen-web.svg';\nimport pip from './pip.svg';\nimport prev from './prev.svg';\nimport next from './next.svg';\n\nexport default class Icons {\n constructor(art) {\n const icons = Object.assign(\n {\n loading,\n state,\n play,\n pause,\n volume,\n volumeClose,\n subtitle,\n screenshot,\n setting,\n fullscreen,\n fullscreenWeb,\n pip,\n prev,\n next,\n },\n art.option.icons,\n );\n\n Object.keys(icons).forEach(key => {\n const icon = document.createElement('i');\n icon.classList.add('art-icon');\n icon.classList.add(`art-icon-${key}`);\n append(icon, icons[key]);\n this[key] = icon;\n });\n }\n}\n","import { inverseClass, queryAll } from '../utils';\n\nexport default function flip(option) {\n return art => {\n const { i18n, player } = art;\n return {\n ...option,\n html: `\n${item}
`)\n .join('');\n this.art.emit('subtitle:update', this.activeCue.text);\n }\n }\n\n switch(url, name) {\n const { i18n, notice } = this.art;\n return this.init(url).then(subUrl => {\n if (name) {\n notice.show = `${i18n.get('Switch subtitle')}: ${name}`;\n }\n this.art.emit('subtitle:switch', subUrl);\n return subUrl;\n });\n }\n\n init(url) {\n const {\n notice,\n template: { $subtitle, $track },\n } = this.art;\n\n return fetch(url)\n .then(response => {\n return response.text();\n })\n .then(text => {\n this.art.emit('subtitle:load', url);\n switch (getExt(url)) {\n case 'srt':\n return vttToBlob(srtToVtt(text));\n case 'ass':\n return vttToBlob(assToVtt(text));\n case 'vtt':\n return vttToBlob(text);\n default:\n return url;\n }\n })\n .then(subUrl => {\n $subtitle.innerHTML = '';\n if (this.url === subUrl) return subUrl;\n URL.revokeObjectURL(this.url);\n $track.src = subUrl;\n return subUrl;\n })\n .catch(err => {\n notice.show = err;\n this.art.emit('subtitle:err', err);\n throw err;\n });\n }\n}\n","export default function clickInit(art, events) {\n const {\n template: { $player },\n } = art;\n events.proxy(document, ['click', 'contextmenu'], event => {\n if (event.composedPath().indexOf($player) > -1) {\n art.isFocus = true;\n art.emit('focus');\n } else {\n art.isFocus = false;\n art.emit('blur');\n }\n });\n}\n","import { addClass, removeClass } from '../utils';\n\nexport default function hoverInit(art, events) {\n const {\n template: { $player },\n } = art;\n events.hover(\n $player,\n () => {\n addClass($player, 'art-hover');\n art.emit('hoverenter');\n },\n () => {\n removeClass($player, 'art-hover');\n art.emit('hoverleave');\n },\n );\n}\n","import { debounce, addClass, removeClass } from '../utils';\n\nexport default function mousemoveInitInit(art, events) {\n const {\n template: { $player, $video },\n player,\n } = art;\n\n const autoHide = debounce(() => {\n addClass($player, 'art-hide-cursor');\n removeClass($player, 'art-hover');\n art.controls.show = false;\n }, 3000);\n\n art.on('hoverleave', () => {\n if (player.playing) {\n autoHide();\n }\n });\n\n events.proxy($player, 'mousemove', event => {\n autoHide.clearTimeout();\n removeClass($player, 'art-hide-cursor');\n art.controls.show = true;\n if (!art.player.pip && player.playing && event.target === $video) {\n autoHide();\n }\n art.emit('mousemove');\n });\n}\n","import { throttle } from '../utils';\n\nexport default function resizeInit(art, events) {\n const {\n option,\n player,\n template: { $player },\n } = art;\n\n const object = document.createElement('object');\n object.setAttribute('aria-hidden', 'true');\n object.setAttribute('tabindex', -1);\n object.type = 'text/html';\n object.data = 'about:blank';\n let playerWidth = player.width;\n let playerHeight = player.height;\n const resizeFn = throttle(() => {\n if (player.width !== playerWidth || player.height !== playerHeight) {\n playerWidth = player.width;\n playerHeight = player.height;\n if (option.autoSize) {\n if (!art.player.fullscreen && !art.player.fullscreenWeb && !art.player.pip) {\n art.player.autoSize = true;\n } else {\n art.player.autoSize = false;\n }\n }\n art.player.aspectRatioReset = true;\n art.emit('resize', {\n width: player.width,\n height: player.height,\n });\n }\n }, 500);\n\n events.proxy(object, 'load', () => {\n events.proxy(object.contentDocument.defaultView, 'resize', resizeFn);\n });\n\n $player.appendChild(object);\n}\n","import clickInit from './clickInit';\nimport hoverInit from './hoverInit';\nimport mousemoveInit from './mousemoveInit';\nimport resizeInit from './resizeInit';\n\nexport default class Events {\n constructor(art) {\n this.destroyEvents = [];\n this.proxy = this.proxy.bind(this);\n this.hover = this.hover.bind(this);\n this.loadImg = this.loadImg.bind(this);\n\n if (art.whitelist.state) {\n art.on('ready', () => {\n clickInit(art, this);\n hoverInit(art, this);\n mousemoveInit(art, this);\n resizeInit(art, this);\n });\n }\n }\n\n proxy(target, name, callback, option = {}) {\n if (Array.isArray(name)) {\n return name.map(item => this.proxy(target, item, callback, option));\n }\n\n target.addEventListener(name, callback, option);\n const destroy = () => target.removeEventListener(name, callback, option);\n this.destroyEvents.push(destroy);\n return destroy;\n }\n\n hover(target, mouseenter, mouseleave) {\n if (mouseenter) {\n this.proxy(target, 'mouseenter', mouseenter);\n }\n if (mouseleave) {\n this.proxy(target, 'mouseleave', mouseleave);\n }\n }\n\n loadImg(img) {\n return new Promise((resolve, reject) => {\n let image;\n\n if (img instanceof HTMLImageElement) {\n image = img;\n } else if (typeof img === 'string') {\n image = new Image();\n image.src = img;\n } else {\n return reject(img);\n }\n\n if (image.complete) {\n return resolve(image);\n }\n\n this.proxy(image, 'load', () => resolve(image));\n this.proxy(image, 'error', () => reject(image));\n\n return img;\n });\n }\n\n destroy() {\n this.destroyEvents.forEach(event => event());\n }\n}\n","export default class Hotkey {\n constructor(art) {\n this.keys = {};\n\n const {\n option,\n player,\n events: { proxy },\n } = art;\n\n if (option.hotkey) {\n art.on('ready', () => {\n this.add(27, () => {\n if (player.fullscreenWeb) {\n player.fullscreenWeb = false;\n }\n });\n\n this.add(32, () => {\n player.toggle = true;\n });\n\n this.add(37, () => {\n player.seek = player.currentTime - 5;\n });\n\n this.add(38, () => {\n player.volume += 0.1;\n });\n\n this.add(39, () => {\n player.seek = player.currentTime + 5;\n });\n\n this.add(40, () => {\n player.volume -= 0.1;\n });\n\n proxy(window, 'keydown', event => {\n if (art.isFocus) {\n const tag = document.activeElement.tagName.toUpperCase();\n const editable = document.activeElement.getAttribute('contenteditable');\n if (tag !== 'INPUT' && tag !== 'TEXTAREA' && editable !== '' && editable !== 'true') {\n const events = this.keys[event.keyCode];\n if (events) {\n event.preventDefault();\n events.forEach(fn => fn());\n art.emit('hotkey', event);\n }\n }\n }\n });\n });\n }\n }\n\n add(key, event) {\n if (this.keys[key]) {\n this.keys[key].push(event);\n } else {\n this.keys[key] = [event];\n }\n }\n}\n","import Component from './utils/component';\n\nexport default class Layer extends Component {\n constructor(art) {\n super(art);\n this.$parent = art.template.$layer;\n art.on('ready', () => {\n art.option.layers.forEach(item => {\n this.add(item);\n });\n });\n }\n}\n","import { append } from './utils';\nimport Component from './utils/component';\n\nexport default class Loading extends Component {\n constructor(art) {\n super(art);\n append(art.template.$loading, art.icons.loading);\n }\n}\n","import { addClass, removeClass } from './utils';\n\nexport default class Notice {\n constructor(art) {\n this.art = art;\n this.time = 2000;\n this.timer = null;\n }\n\n set show(msg) {\n const { $player, $noticeInner } = this.art.template;\n $noticeInner.innerText = msg instanceof Error ? msg.message.trim() : msg;\n addClass($player, 'art-notice-show');\n clearTimeout(this.timer);\n this.timer = setTimeout(() => {\n $noticeInner.innerText = '';\n removeClass($player, 'art-notice-show');\n }, this.time);\n }\n}\n","import { append } from './utils';\nimport Component from './utils/component';\n\nexport default class Mask extends Component {\n constructor(art) {\n super(art);\n append(art.template.$state, art.icons.state);\n }\n}\n","import { append } from '../utils';\nimport loading from './loading.svg';\nimport state from './state.svg';\nimport play from './play.svg';\nimport pause from './pause.svg';\nimport volume from './volume.svg';\nimport volumeClose from './volume-close.svg';\nimport subtitle from './subtitle.svg';\nimport screenshot from './screenshot.svg';\nimport setting from './setting.svg';\nimport fullscreen from './fullscreen.svg';\nimport fullscreenWeb from './fullscreen-web.svg';\nimport pip from './pip.svg';\n\nexport default class Icons {\n constructor(art) {\n const icons = Object.assign(\n {\n loading,\n state,\n play,\n pause,\n volume,\n volumeClose,\n subtitle,\n screenshot,\n setting,\n fullscreen,\n fullscreenWeb,\n pip,\n },\n art.option.icons,\n );\n\n Object.keys(icons).forEach(key => {\n const icon = document.createElement('i');\n icon.classList.add('art-icon');\n icon.classList.add(`art-icon-${key}`);\n append(icon, icons[key]);\n this[key] = icon;\n });\n }\n}\n","import { inverseClass, queryAll } from '../utils';\n\nexport default function flip(option) {\n return art => {\n const { i18n, player } = art;\n return {\n ...option,\n html: `\n".concat(t,"
")})).join(""),this.art.emit("subtitle:update",this.activeCue.text))}},{key:"switch",value:function(t,e){var n=this,r=this.art,i=r.i18n,o=r.notice;return this.init(t).then((function(t){return e&&(o.show="".concat(i.get("Switch subtitle"),": ").concat(e)),n.art.emit("subtitle:switch",t),t}))}},{key:"init",value:function(t){var e=this,n=this.art,r=n.notice,i=n.template,o=i.$subtitle,a=i.$track;return fetch(t).then((function(t){return t.text()})).then((function(n){switch(e.art.emit("subtitle:load",t),D(t)){case"srt":return R($(n));case"ass":return R(T(n));case"vtt":return R(n);default:return t}})).then((function(t){return o.innerHTML="",e.url===t?t:(URL.revokeObjectURL(e.url),a.src=t,t)})).catch((function(t){throw r.show=t,e.art.emit("subtitle:err",t),t}))}},{key:"url",get:function(){return this.art.template.$track.src}},{key:"textTrack",get:function(){return this.art.template.$video.textTracks[0]}},{key:"activeCue",get:function(){return this.textTrack.activeCues[0]}}]),r}(ct);var Zt=function(){function e(n){var r=this;t(this,e),this.destroyEvents=[],this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),this.loadImg=this.loadImg.bind(this),n.whitelist.state&&n.on("ready",(function(){!function(t,e){var n=t.template.$player;e.proxy(document,["click","contextmenu"],(function(e){e.composedPath().indexOf(n)>-1?(t.isFocus=!0,t.emit("focus")):(t.isFocus=!1,t.emit("blur"))}))}(n,r),function(t,e){var n=t.template.$player;e.hover(n,(function(){h(n,"art-hover"),t.emit("hoverenter")}),(function(){y(n,"art-hover"),t.emit("hoverleave")}))}(n,r),function(t,e){var n=t.template,r=n.$player,i=n.$video,o=t.player,a=N((function(){h(r,"art-hide-cursor"),y(r,"art-hover"),t.controls.show=!1}),3e3);t.on("hoverleave",(function(){o.playing&&a()})),e.proxy(r,"mousemove",(function(e){a.clearTimeout(),y(r,"art-hide-cursor"),t.controls.show=!0,!t.player.pip&&o.playing&&e.target===i&&a(),t.emit("mousemove")}))}(n,r),function(t,e){var n=t.option,r=t.player,i=t.template.$player,o=document.createElement("object");o.setAttribute("aria-hidden","true"),o.setAttribute("tabindex",-1),o.type="text/html",o.data="about:blank";var a=r.width,c=r.height,s=I((function(){r.width===a&&r.height===c||(a=r.width,c=r.height,n.autoSize&&(t.player.fullscreen||t.player.fullscreenWeb||t.player.pip?t.player.autoSize=!1:t.player.autoSize=!0),t.player.aspectRatioReset=!0,t.emit("resize",{width:r.width,height:r.height}))}),500);e.proxy(o,"load",(function(){e.proxy(o.contentDocument.defaultView,"resize",s)})),i.appendChild(o)}(n,r)}))}return n(e,[{key:"proxy",value:function(t,e,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(Array.isArray(e))return e.map((function(e){return r.proxy(t,e,n,i)}));t.addEventListener(e,n,i);var o=function(){return t.removeEventListener(e,n,i)};return this.destroyEvents.push(o),o}},{key:"hover",value:function(t,e,n){e&&this.proxy(t,"mouseenter",e),n&&this.proxy(t,"mouseleave",n)}},{key:"loadImg",value:function(t){var e=this;return new Promise((function(n,r){var i;if(t instanceof HTMLImageElement)i=t;else{if("string"!=typeof t)return r(t);(i=new Image).src=t}return i.complete?n(i):(e.proxy(i,"load",(function(){return n(i)})),e.proxy(i,"error",(function(){return r(i)})),t)}))}},{key:"destroy",value:function(){this.destroyEvents.forEach((function(t){return t()}))}}]),e}(),Yt=function(){function e(n){var r=this;t(this,e),this.keys={};var i=n.option,o=n.player,a=n.events.proxy;i.hotkey&&n.on("ready",(function(){r.add(27,(function(){o.fullscreenWeb&&(o.fullscreenWeb=!1)})),r.add(32,(function(){o.toggle=!0})),r.add(37,(function(){o.seek=o.currentTime-5})),r.add(38,(function(){o.volume+=.1})),r.add(39,(function(){o.seek=o.currentTime+5})),r.add(40,(function(){o.volume-=.1})),a(window,"keydown",(function(t){if(n.isFocus){var e=document.activeElement.tagName.toUpperCase(),i=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==i&&"true"!==i){var o=r.keys[t.keyCode];o&&(t.preventDefault(),o.forEach((function(t){return t()})),n.emit("hotkey",t))}}}))}))}return n(e,[{key:"add",value:function(t,e){this.keys[t]?this.keys[t].push(e):this.keys[t]=[e]}}]),e}(),Jt=function(e){function n(e){var r;return t(this,n),(r=a(this,c(n).call(this,e))).$parent=e.template.$layer,e.on("ready",(function(){e.option.layers.forEach((function(t){r.add(t)}))})),r}return u(n,e),n}(ct),Gt=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$loading,e.icons.loading),r}return u(n,e),n}(ct),Qt=function(){function e(n){t(this,e),this.art=n,this.time=1e3,this.timer=null}return n(e,[{key:"show",set:function(t){var e=this.art.template,n=e.$player,r=e.$noticeInner;r.innerText=t instanceof Error?t.message.trim():t,h(n,"art-notice-show"),clearTimeout(this.timer),this.timer=setTimeout((function(){r.innerText="",y(n,"art-notice-show")}),this.time)}}]),e}(),Kt=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$state,e.icons.state),r}return u(n,e),n}(ct),te=function e(n){var r=this;t(this,e);var i=Object.assign({loading:'',state:'',play:'',pause:'',volume:'',volumeClose:'',subtitle:'',screenshot:'',setting:'',fullscreen:'',fullscreenWeb:'',pip:''},n.option.icons);Object.keys(i).forEach((function(t){var e=document.createElement("i");e.classList.add("art-icon"),e.classList.add("art-icon-".concat(t)),m(e,i[t]),r[t]=e}))};function ee(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function ne(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e".concat(t,"
")})).join(""),this.art.emit("subtitle:update",this.activeCue.text))}},{key:"switch",value:function(t,e){var n=this,r=this.art,i=r.i18n,o=r.notice;return this.init(t).then((function(t){return e&&(o.show="".concat(i.get("Switch subtitle"),": ").concat(e)),n.art.emit("subtitle:switch",t),t}))}},{key:"init",value:function(t){var e=this,n=this.art,r=n.notice,i=n.template,o=i.$subtitle,a=i.$track;return fetch(t).then((function(t){return t.text()})).then((function(n){switch(e.art.emit("subtitle:load",t),T(t)){case"srt":return R($(n));case"ass":return R(C(n));case"vtt":return R(n);default:return t}})).then((function(t){return o.innerHTML="",e.url===t?t:(URL.revokeObjectURL(e.url),a.src=t,t)})).catch((function(t){throw r.show=t,e.art.emit("subtitle:err",t),t}))}},{key:"url",get:function(){return this.art.template.$track.src}},{key:"textTrack",get:function(){return this.art.template.$video.textTracks[0]}},{key:"activeCue",get:function(){return this.textTrack.activeCues[0]}}]),r}(ct);var Zt=function(){function e(n){var r=this;t(this,e),this.destroyEvents=[],this.proxy=this.proxy.bind(this),this.hover=this.hover.bind(this),this.loadImg=this.loadImg.bind(this),n.whitelist.state&&n.on("ready",(function(){!function(t,e){var n=t.template.$player;e.proxy(document,["click","contextmenu"],(function(e){e.composedPath().indexOf(n)>-1?(t.isFocus=!0,t.emit("focus")):(t.isFocus=!1,t.emit("blur"))}))}(n,r),function(t,e){var n=t.template.$player;e.hover(n,(function(){h(n,"art-hover"),t.emit("hoverenter")}),(function(){y(n,"art-hover"),t.emit("hoverleave")}))}(n,r),function(t,e){var n=t.template,r=n.$player,i=n.$video,o=t.player,a=N((function(){h(r,"art-hide-cursor"),y(r,"art-hover"),t.controls.show=!1}),3e3);t.on("hoverleave",(function(){o.playing&&a()})),e.proxy(r,"mousemove",(function(e){a.clearTimeout(),y(r,"art-hide-cursor"),t.controls.show=!0,!t.player.pip&&o.playing&&e.target===i&&a(),t.emit("mousemove")}))}(n,r),function(t,e){var n=t.option,r=t.player,i=t.template.$player,o=document.createElement("object");o.setAttribute("aria-hidden","true"),o.setAttribute("tabindex",-1),o.type="text/html",o.data="about:blank";var a=r.width,c=r.height,s=I((function(){r.width===a&&r.height===c||(a=r.width,c=r.height,n.autoSize&&(t.player.fullscreen||t.player.fullscreenWeb||t.player.pip?t.player.autoSize=!1:t.player.autoSize=!0),t.player.aspectRatioReset=!0,t.emit("resize",{width:r.width,height:r.height}))}),500);e.proxy(o,"load",(function(){e.proxy(o.contentDocument.defaultView,"resize",s)})),i.appendChild(o)}(n,r)}))}return n(e,[{key:"proxy",value:function(t,e,n){var r=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(Array.isArray(e))return e.map((function(e){return r.proxy(t,e,n,i)}));t.addEventListener(e,n,i);var o=function(){return t.removeEventListener(e,n,i)};return this.destroyEvents.push(o),o}},{key:"hover",value:function(t,e,n){e&&this.proxy(t,"mouseenter",e),n&&this.proxy(t,"mouseleave",n)}},{key:"loadImg",value:function(t){var e=this;return new Promise((function(n,r){var i;if(t instanceof HTMLImageElement)i=t;else{if("string"!=typeof t)return r(t);(i=new Image).src=t}return i.complete?n(i):(e.proxy(i,"load",(function(){return n(i)})),e.proxy(i,"error",(function(){return r(i)})),t)}))}},{key:"destroy",value:function(){this.destroyEvents.forEach((function(t){return t()}))}}]),e}(),Yt=function(){function e(n){var r=this;t(this,e),this.keys={};var i=n.option,o=n.player,a=n.events.proxy;i.hotkey&&n.on("ready",(function(){r.add(27,(function(){o.fullscreenWeb&&(o.fullscreenWeb=!1)})),r.add(32,(function(){o.toggle=!0})),r.add(37,(function(){o.seek=o.currentTime-5})),r.add(38,(function(){o.volume+=.1})),r.add(39,(function(){o.seek=o.currentTime+5})),r.add(40,(function(){o.volume-=.1})),a(window,"keydown",(function(t){if(n.isFocus){var e=document.activeElement.tagName.toUpperCase(),i=document.activeElement.getAttribute("contenteditable");if("INPUT"!==e&&"TEXTAREA"!==e&&""!==i&&"true"!==i){var o=r.keys[t.keyCode];o&&(t.preventDefault(),o.forEach((function(t){return t()})),n.emit("hotkey",t))}}}))}))}return n(e,[{key:"add",value:function(t,e){this.keys[t]?this.keys[t].push(e):this.keys[t]=[e]}}]),e}(),Jt=function(e){function n(e){var r;return t(this,n),(r=a(this,c(n).call(this,e))).$parent=e.template.$layer,e.on("ready",(function(){e.option.layers.forEach((function(t){r.add(t)}))})),r}return u(n,e),n}(ct),Gt=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$loading,e.icons.loading),r}return u(n,e),n}(ct),Qt=function(){function e(n){t(this,e),this.art=n,this.time=2e3,this.timer=null}return n(e,[{key:"show",set:function(t){var e=this.art.template,n=e.$player,r=e.$noticeInner;r.innerText=t instanceof Error?t.message.trim():t,h(n,"art-notice-show"),clearTimeout(this.timer),this.timer=setTimeout((function(){r.innerText="",y(n,"art-notice-show")}),this.time)}}]),e}(),Kt=function(e){function n(e){var r;return t(this,n),r=a(this,c(n).call(this,e)),m(e.template.$state,e.icons.state),r}return u(n,e),n}(ct),te=function e(n){var r=this;t(this,e);var i=Object.assign({loading:'',state:'',play:'',pause:'',volume:'',volumeClose:'',subtitle:'',screenshot:'',setting:'',fullscreen:'',fullscreenWeb:'',pip:''},n.option.icons);Object.keys(i).forEach((function(t){var e=document.createElement("i");e.classList.add("art-icon"),e.classList.add("art-icon-".concat(t)),m(e,i[t]),r[t]=e}))};function ee(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function ne(t){return function(e){var n=e.i18n,r=e.player;return function(t){for(var e=1;e