!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.artplayer={})}(this,function(t){"use strict";"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function e(t,e){return t(e={exports:{}},e.exports),e.exports}var o=e(function(n){function i(t,e){return n.exports=i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},i(t,e)}n.exports=i}),r=e(function(i){function r(t,e,n){return!function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?i.exports=r=function(t,e,n){var i=[null];i.push.apply(i,e);var r=new(Function.bind.apply(t,i));return n&&o(r,n.prototype),r}:i.exports=r=Reflect.construct,r.apply(null,arguments)}i.exports=r});var n=function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e\n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
×
\n
\n
\n
\n
\n
[x]
\n
\n \n ',n.$player=n.$container.querySelector(".artplayer-video-player"),n.$video=n.$container.querySelector(".artplayer-video"),n.$subtitle=n.$container.querySelector(".artplayer-subtitle"),n.$bottom=n.$container.querySelector(".artplayer-bottom"),n.$progress=n.$container.querySelector(".artplayer-progress"),n.$controls=n.$container.querySelector(".artplayer-controls"),n.$controlsLeft=n.$container.querySelector(".artplayer-controls-left"),n.$controlsRight=n.$container.querySelector(".artplayer-controls-right"),n.$layers=n.$container.querySelector(".artplayer-layers"),n.$danmu=n.$container.querySelector(".artplayer-danmu"),n.$loading=n.$container.querySelector(".artplayer-loading"),n.$notice=n.$container.querySelector(".artplayer-notice"),n.$noticeInner=n.$container.querySelector(".artplayer-notice-inner"),n.$mask=n.$container.querySelector(".artplayer-mask"),n.$setting=n.$container.querySelector(".artplayer-setting"),n.$settingInner=n.$container.querySelector(".artplayer-setting-inner"),n.$settingBody=n.$container.querySelector(".artplayer-setting-body"),n.$settingClose=n.$container.querySelector(".artplayer-setting-close"),n.$info=n.$container.querySelector(".artplayer-info"),n.$infoPanel=n.$container.querySelector(".artplayer-info-panel"),n.$infoClose=n.$container.querySelector(".artplayer-info-close")},A={"zh-cn":{"About author":"关于作者","Video info":"视频统计信息",Close:"关闭","Video load failed":"视频加载失败",Volume:"音量",Play:"播放",Pause:"暂停",Rate:"速度",Mute:"静音",Reconnect:"重新连接","Hide subtitle":"隐藏字幕","Show subtitle":"显示字幕","Hide danmu":"隐藏弹幕","Show danmu":"显示弹幕",Screenshot:"截图","Play speed":"播放速度","Aspect ratio":"画面比例",Default:"默认",Normal:"正常","Switch video":"切换","Switch subtitle":"切换字幕",Fullscreen:"全屏","Exit fullscreen":"退出全屏","Web fullscreen":"网页全屏","Exit web fullscreen":"退出网页全屏",Common:"常规","Hide setting":"隐藏设置","Show setting":"显示设置"},"zh-tw":{"About author":"關於作者","Video info":"影片統計訊息",Close:"關閉","Video load failed":"影片載入失敗",Volume:"音量",Play:"播放",Pause:"暫停",Rate:"速度",Mute:"靜音",Reconnect:"重新連接","Hide subtitle":"隱藏字幕","Show subtitle":"顯示字幕","Hide danmu":"隱藏彈幕","Show danmu":"顯示彈幕",Screenshot:"截圖","Play speed":"播放速度","Aspect ratio":"畫面比例",Default:"默認",Normal:"正常","Switch video":"切換","Switch subtitle":"切換字幕",Fullscreen:"全屏","Exit fullscreen":"退出全屏","Web fullscreen":"網頁全屏","Exit web fullscreen":"退出網頁全屏",Common:"常規","Hide setting":"隱藏設置","Show setting":"顯示設置"}},M=function(){function n(t){var e=t.option;R(this,n),this.option=e,this.init()}return c(n,[{key:"init",value:function(){this.language=A[this.option.lang.toLowerCase()]||{}}},{key:"get",value:function(t){return this.language[t]||t}},{key:"update",value:function(t){A=t(A),this.init()}}]),n}();function V(s,t){Object.defineProperty(t,"volume",{value:function(t){var e,n,i,r=s.refs.$video,o=s.i18n,a=s.notice;return void 0!==t&&(r.volume=j(t,0,1),a.show("".concat(o.get("Volume"),": ").concat(parseInt(100*r.volume))),0!==r.volume&&(e="volume",n=r.volume,i=Object.assign({},x(),v({},e,n)),localStorage.setItem("artplayer_settings",JSON.stringify(i))),s.emit("volume",r.volume)),r.volume||0}})}var O=function t(e){var n,i,r,o,a,s,c,l,u,d,h,f,p,v,y,m,g,b,w,$,x,k,S,E,C,L,T,P,A,M,O;R(this,t),this.reconnectTime=0,this.maxReconnectTime=5,i=(n=e).option,r=n.refs.$video,Object.keys(i.moreVideoAttr).forEach(function(t){r[t]=i.moreVideoAttr[t]}),r.volume=j(i.volume,0,1),r.poster=i.poster,r.autoplay=i.autoplay,r.src=i.url,a=this,s=(o=e).option,c=o.events.proxy,l=o.refs,u=l.$player,d=l.$video,h=o.i18n,f=o.notice,p=!1,c(d,"click",function(){a.toggle()}),z.video.events.forEach(function(t){c(d,t,function(t){o.emit("video:".concat(t.type),t)})}),o.on("video:loadstart",function(){o.loading.show()}),o.on("video:loadeddata",function(){o.loading.hide()}),o.on("video:waiting",function(){o.loading.show()}),o.on("video:seeking",function(){o.loading.show()}),o.on("video:canplay",function(){p||(p=!0,o.emit("firstCanplay")),o.controls.show(),o.mask.show(),o.loading.hide(),s.autoplay&&a.play()}),o.on("video:playing",function(){o.isPlaying=!0,o.controls.hide(),o.mask.hide()}),o.on("video:pause",function(){o.isPlaying=!1,o.controls.show(),o.mask.show()}),o.on("video:ended",function(){o.isPlaying=!1,o.controls.show(),o.mask.show(),s.loop&&(a.seek(0),a.play())}),o.on("video:error",function(){a.reconnectTime\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n',playBig:'\n \n \n \n \n',play:'\n \n',pause:'\n \n',volume:'\n \n',volumeClose:'\n \n \n',subtitle:'\n \n \n',screenshot:'\n\t\n\t\t\n\t\n\n',danmu:'\r\n\t\r\n\r\n',setting:'\n \n \n',fullscreen:'\r\n\r\n\t\r\n\t\t\r\n\t\r\n\r\n\r\n\t\r\n\t\t\r\n\t\r\n\r\n\r\n\t\r\n\t\t\r\n\t\r\n\r\n\r\n\t\r\n\t\t\r\n\t\r\n\r\n\r\n',fullscreenWeb:'\r\n\t\r\n\t\r\n\t\r\n\t\r\n\t\r\n\r\n'},U={},Object.keys(N).forEach(function(t){var e=document.createElement("div");e.innerHTML='').concat(N[t],"");var n=D(e.childNodes,1);U[t]=n[0]}),U),Z=function(){function e(t){R(this,e),this.option=t}return c(e,[{key:"apply",value:function(t,e){var n=this,i=t.events.proxy,r=t.i18n,o=t.danmu;this.$danmu=w(e,Y.danmu),k(this.$danmu,r.get("Hide danmu")),i(e,"click",function(){o.isOpen?(o.hide(),H(n.$danmu,"opacity","1"),k(n.$danmu,r.get("Show danmu"))):(o.show(),H(n.$danmu,"opacity","0.8"),k(n.$danmu,r.get("Hide danmu")))})}}]),e}(),G=e(function(t){var o,e,n,i,r,a;o="undefined"!=typeof window&&void 0!==window.document?window.document:{},e=t.exports,n="undefined"!=typeof Element&&"ALLOW_KEYBOARD_INPUT"in Element,i=function(){for(var t,e=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],n=0,i=e.length,r={};n\n
\n
\n
\n
\n
\n \n ')),this.$loaded=e.querySelector(".art-progress-loaded"),this.$played=e.querySelector(".art-progress-played"),this.$highlight=e.querySelector(".art-progress-highlight"),this.$indicator=e.querySelector(".art-progress-indicator"),this.$tip=e.querySelector(".art-progress-tip"),this.set("loaded",this.getLoaded()),i.forEach(function(t){var e=Number(t.time)/s.duration;w(r.$highlight,''))}),this.art.on("video:progress",function(){r.set("loaded",r.getLoaded())}),this.art.on("video:timeupdate",function(){r.set("played",r.getPlayed())}),this.art.on("video:ended",function(){r.set("played",1)}),a(e,"mousemove",function(t){H(r.$tip,"display","block"),-1this.$control.clientWidth-r/2?H(this.$tip,"left","".concat(this.$control.clientWidth-r,"px")):H(this.$tip,"left","".concat(n-r/2,"px"))}},{key:"getPlayed",value:function(){var t=this.art.refs.$video;return t.currentTime/t.duration}},{key:"getLoaded",value:function(){var t=this.art.refs.$video;return t.buffered.length?t.buffered.end(t.buffered.length-1)/t.duration:0}},{key:"getPosFromEvent",value:function(t){var e=this.art.refs,n=e.$video,i=e.$progress,r=i.getBoundingClientRect().left,o=j(t.x-r,0,i.clientWidth),a=o/i.clientWidth*n.duration;return{second:a,time:q(a),width:o,percentage:j(o/i.clientWidth,0,1)}}},{key:"set",value:function(t,e){H(this["$".concat(t)],"width","".concat(100*e,"%")),"played"===t&&H(this.$indicator,"left","calc(".concat(100*e,"% - 6.5px)"))}}]),e}(),et=function(){function e(t){R(this,e),this.option=t}return c(e,[{key:"apply",value:function(t,e){var n=this,i=t.events.proxy,r=t.i18n,o=t.subtitle;this.$subtitle=w(e,Y.subtitle),k(this.$subtitle,r.get("Hide subtitle")),i(e,"click",function(){o.isOpen?(o.hide(),H(n.$subtitle,"opacity","1"),k(n.$subtitle,r.get("Show subtitle")),t.emit("subtitle:hide")):(o.show(),H(n.$subtitle,"opacity","0.8"),k(n.$subtitle,r.get("Hide subtitle")),t.emit("subtitle:show"))})}}]),e}(),nt=function(){function e(t){R(this,e),this.option=t}return c(e,[{key:"apply",value:function(t,e){var n=this;this.art=t,(this.$control=e).innerHTML="00:00 / 00:00",this.art.on("video:canplay",function(){n.getTime()}),this.art.on("video:timeupdate",function(){n.getTime()}),this.art.on("video:seeking",function(){n.getTime()})}},{key:"getTime",value:function(){var t=this.art.player;this.$control.innerHTML="".concat(q(t.currentTime())," / ").concat(q(t.duration()))}}]),e}(),it=function(){function e(t){R(this,e),this.option=t,this.isDroging=!1}return c(e,[{key:"apply",value:function(t,e){this.art=t,this.$control=e,this.init()}},{key:"init",value:function(){var e=this,t=this.art,n=t.events.proxy,i=t.player,r=t.i18n;this.$volume=w(this.$control,Y.volume),this.$volumeClose=w(this.$control,Y.volumeClose),this.$volumePanel=w(this.$control,'
'),this.$volumeHandle=w(this.$volumePanel,'
'),k(this.$volume,r.get("Mute")),H(this.$volumeClose,"display","none");var o=x("volume");this.setVolumeHandle(o),i.volume(o),n(this.$volume,"click",function(){H(e.$volume,"display","none"),H(e.$volumeClose,"display","block"),i.volume(0)}),n(this.$volumeClose,"click",function(){H(e.$volume,"display","block"),H(e.$volumeClose,"display","none"),i.volume(x("volume"))}),n(this.$control,"mouseenter",function(){e.$volumePanel.classList.add("art-volume-panel-hover"),setTimeout(function(){e.setVolumeHandle(i.volume())},200)}),n(this.$control,"mouseleave",function(){e.$volumePanel.classList.remove("art-volume-panel-hover")}),n(this.$volumePanel,"click",function(t){e.volumeChangeFromEvent(t)}),n(this.$volumeHandle,"mousedown",function(){e.isDroging=!0}),n(this.$volumeHandle,"mousemove",function(t){e.isDroging&&e.volumeChangeFromEvent(t)}),n(document,"mouseup",function(){e.isDroging&&(e.isDroging=!1)}),this.art.on("video:volumechange",function(){var t=i.volume();e.setVolumeHandle(t),0===t?(H(e.$volume,"display","none"),H(e.$volumeClose,"display","block")):(H(e.$volume,"display","block"),H(e.$volumeClose,"display","none"))})}},{key:"volumeChangeFromEvent",value:function(t){var e=this.art.player,n=this.$volumePanel.getBoundingClientRect(),i=n.left,r=n.width,o=this.$volumeHandle.getBoundingClientRect().width,a=j(t.x-i-o/2,0,r-o/2)/(r-o);e.volume(a)}},{key:"setVolumeHandle",value:function(){var t=0n.clientWidth-s/2?H(this.$control,"left","".concat(n.clientWidth-s,"px")):H(this.$control,"left","".concat(i-s/2,"px"))}}]),e}(),at=function(){function e(t){R(this,e),this.option=t}return c(e,[{key:"apply",value:function(t,e){var n=this;this.art=t;var i=this.art,r=i.events.proxy,o=i.i18n,a=i.notice;this.$screenshot=w(e,Y.screenshot),k(this.$screenshot,o.get("Screenshot")),r(this.$screenshot,"click",function(){try{n.captureFrame(),t.emit("screenshot")}catch(t){a.show(t)}})}},{key:"captureFrame",value:function(){var t=this.art.refs.$video,e=document.createElement("canvas");e.width=t.videoWidth,e.height=t.videoHeight,e.getContext("2d").drawImage(t,0,0);var n=e.toDataURL("image/png"),i=document.createElement("a");H(i,"display","none"),i.href=n,i.download="ArtPlayer_".concat(q(t.currentTime),".png"),document.body.appendChild(i),i.click(),document.body.removeChild(i)}}]),e}(),st=function(){function e(t){R(this,e),this.option=t,this.playIndex=-1}return c(e,[{key:"apply",value:function(t,e){var o=this,a=t.option,n=t.events,i=n.proxy,r=n.hover,s=t.player,c=a.quality.find(function(t){return t.default})||a.quality[0];this.playIndex=a.quality.indexOf(c);var l=w(e,'
'.concat(c.name,"
")),u=a.quality.map(function(t,e){return'
').concat(t.name,"
")}).join(""),d=w(e,'
'.concat(u,"
"));r(e,function(){e.classList.add("hover")},function(){e.classList.remove("hover")}),i(d,"click",function(t){var e=Number(t.target.dataset.index),n=a.quality[e],i=n.url,r=n.name;i&&r&&o.playIndex!==e&&(s.switch(i,r),l.innerHTML=r,o.playIndex=e)})}}]),e}(),ct=0,lt=function(){function n(t){var e=this;R(this,n),this.art=t,this.$map={},this.art.on("firstCanplay",function(){e.init(),e.mount()})}return c(n,[{key:"init",value:function(){var e=this;this.add(new tt({name:"progress",disable:!1,position:"top",index:10})),this.add(new ot({name:"thumbnails",disable:!this.art.option.thumbnails.url,position:"top",index:20})),this.add(new Q({name:"playAndPause",disable:!1,position:"left",index:10})),this.add(new it({name:"volume",disable:!1,position:"left",index:20})),this.add(new nt({name:"time",disable:!1,position:"left",index:30})),this.add(new st({name:"quality",disable:0===this.art.option.quality.length,position:"right",index:10})),this.add(new Z({name:"danmu",disable:!1,position:"right",index:20})),this.add(new at({name:"screenshot",disable:!this.art.option.screenshot,position:"right",index:30})),this.add(new et({name:"subtitle",disable:!this.art.option.subtitle.url,position:"right",index:40})),this.add(new rt({name:"setting",disable:!this.art.option.setting,position:"right",index:50})),this.add(new X({name:"pip",disable:!this.art.option.pip,position:"right",index:60})),this.add(new K({name:"fullscreenWeb",disable:!this.art.option.fullscreenWeb,position:"right",index:70})),this.add(new J({name:"fullscreen",disable:!this.art.option.fullscreen,position:"right",index:80})),this.art.option.controls.forEach(function(t){e.add(t)})}},{key:"add",value:function(t){var e=t.option;if(e&&!e.disable){ct++;var n=e.name||t.constructor.name.toLowerCase()||"control".concat(ct),i=document.createElement("div");i.setAttribute("class","art-control art-control-".concat(n)),i.dataset.controlIndex=e.index||ct,this.commonMethod(t),(this.$map[e.position]||(this.$map[e.position]=[])).push(i),t.apply&&t.apply(this.art,i),this[n]=t}}},{key:"mount",value:function(){var t=this,e=this.art.refs,n=e.$progress,i=e.$controlsLeft,r=e.$controlsRight;Object.keys(this.$map).forEach(function(e){t.$map[e].sort(function(t,e){return Number(t.dataset.controlIndex)-Number(e.dataset.controlIndex)}).forEach(function(t){switch(e){case"top":w(n,t);break;case"left":w(i,t);break;case"right":w(r,t)}})})}},{key:"commonMethod",value:function(t){var e=this;Object.defineProperty(t,"hide",{value:function(){H(t.option.$control,"display","none"),e.art.emit("control:hide",t.option.$control)}}),Object.defineProperty(t,"show",{value:function(){H(t.option.$control,"display","block"),e.art.emit("control:show",t.option.$control)}})}},{key:"show",value:function(){this.art.refs.$player.classList.add("artplayer-controls-show")}},{key:"hide",value:function(){this.art.refs.$player.classList.remove("artplayer-controls-show")}}]),n}();function ut(t){var e=t.option,n=t.i18n,i=t.player,r=t.contextmenu;return{disable:!e.playbackRate,name:"playbackRate",index:10,html:"\n ".concat(n.get("Play speed"),':\n 0.5\n 0.75\n ').concat(n.get("Normal"),'\n 1.25\n 1.5\n 2.0\n '),click:function(t){var e=t.target,n=e.dataset.rate;n&&(i.playbackRate(Number(n)),F(e).forEach(function(t){return t.classList.remove("current")}),e.classList.add("current"),r.hide())}}}function dt(t){var e=t.option,n=t.i18n,i=t.player,r=t.contextmenu;return{disable:!e.aspectRatio,name:"aspectRatio",index:20,html:"\n ".concat(n.get("Aspect ratio"),':\n ').concat(n.get("Default"),'\n 4:3\n 16:9\n '),click:function(t){var e=t.target,n=e.dataset.ratio;n&&(i.aspectRatio(n.split(":")),F(e).forEach(function(t){return t.classList.remove("current")}),e.classList.add("current"),r.hide())}}}function ht(t){return{disable:!1,name:"info",index:30,html:t.i18n.get("Video info"),click:function(){t.info.show(),t.contextmenu.hide()}}}var ft={disable:!1,name:"version",index:40,html:'ArtPlayer 1.0.0'};function pt(t){return{disable:!1,name:"close",index:50,html:t.i18n.get("Close"),click:function(){t.contextmenu.hide()}}}var vt=0,yt=function(){function e(t){R(this,e),this.art=t,this.init()}return c(e,[{key:"init",value:function(){var e=this,t=this.art,n=t.option,i=t.refs,r=t.events.proxy;n.contextmenu.push(ut,dt,ht,ft,pt),r(i.$player,"contextmenu",function(t){t.preventDefault(),i.$contextmenu||e.creatMenu(),e.show(),e.setPos(t)}),r(i.$player,"click",function(t){i.$contextmenu&&!t.path.includes(i.$contextmenu)&&e.hide()})}},{key:"creatMenu",value:function(){var i=this,t=this.art,e=t.option,n=t.refs,r=t.events.proxy;n.$contextmenu=document.createElement("div"),n.$contextmenu.classList.add("artplayer-contextmenu"),e.contextmenu.filter(function(t){return!t.disable}).map(function(t){vt++;var e="function"==typeof t?t(i.art):t,n=document.createElement("div");return n.dataset.artMenuId=e.index||vt,n.setAttribute("class","art-menu art-menu-".concat(e.name||vt)),w(n,e.html),$(n,e.style||{}),e.click&&r(n,"click",function(t){t.preventDefault(),e.click.call(i,t),i.art.emit("contextmenu:click",n)}),i["$".concat(e.name||vt)]=n}).sort(function(t,e){return Number(t.dataset.artMenuId)-Number(e.dataset.artMenuId)}).forEach(function(t){w(n.$contextmenu,t)}),w(n.$player,n.$contextmenu)}},{key:"setPos",value:function(t){var e=this.art.refs,n=t.clientX,i=t.clientY,r=e.$player.getBoundingClientRect(),o=r.height,a=r.width,s=r.left,c=r.top,l=e.$contextmenu.getBoundingClientRect(),u=l.height,d=l.width,h=n-s,f=i-c;s+a\n
Player version:
\n
1.0.0
\n \n '),t.push('\n
\n
Video url:
\n
\n
\n '),t.push('\n
\n
Video type:
\n
\n
\n '),t.push('\n
\n
Video size:
\n
\n
\n '),t.push('\n
\n
Video volume:
\n
\n
\n '),t.push('\n
\n
Video time:
\n
\n
\n '),t.push('\n
\n
Video duration:
\n
\n
\n '),t.push('\n
\n
Video resolution:
\n
\n x \n
\n
\n '),t.join("")}},{key:"getHeader",value:function(){var t=this.art.refs,e=t.$infoPanel,n=t.$video.src,i=Array.from(e.querySelectorAll("[data-head]"));i.forEach(function(t){t.innerHTML="loading..."}),fetch(n,{method:"HEAD"}).then(function(n){i.forEach(function(t){var e=n.headers.get(t.dataset.head);t.innerHTML=void 0!==e?e:"unknown"})}).catch(function(){i.forEach(function(t){t.innerHTML="unknown"})})}},{key:"readInfo",value:function(){var t=this.art.refs,e=t.$infoPanel,n=t.$video;Array.from(e.querySelectorAll("[data-video]")).forEach(function(t){var e=n[t.dataset.video];t.innerHTML=void 0!==e?e:"unknown"})}},{key:"loop",value:function(){var t=this;this.readInfo(),this.timer=setTimeout(function(){t.readInfo(),t.loop()},1e3)}},{key:"hide",value:function(){var t=this.art.refs.$info;H(t,"display","none"),clearTimeout(this.timer),this.art.emit("info:hide",t)}}]),e}(),bt=function(){function n(t){R(this,n),this.art=t,this.isOpen=!0;var e=this.art.option.subtitle.url;e&&(this.checkExt(e),this.init())}return c(n,[{key:"init",value:function(){var i=this,t=this.art,e=t.events.proxy,n=t.option.subtitle,r=t.refs,o=r.$video,a=r.$subtitle;$(a,n.style||{});var s=document.createElement("track");s.default=!0,s.kind="metadata",this.load(n.url).then(function(t){if(s.src=t,o.appendChild(s),i.art.refs.$track=s,o.textTracks&&o.textTracks[0]){var n=D(o.textTracks,1)[0];e(n,"cuechange",function(){var t=D(n.activeCues,1)[0];if(a.innerHTML="",t){var e=document.createElement("div");e.appendChild(t.getCueAsHTML()),a.innerHTML=e.innerHTML.split(/\r?\n/).map(function(t){return"

".concat(t,"

")}).join("")}i.art.emit("subtitle:update",a)})}})}},{key:"load",value:function(e){var n,i=this,r=this.art.notice;return fetch(e).then(function(t){return n=t.headers.get("Content-Type"),t.text()}).then(function(t){return/x-subrip/gi.test(n)?i.srtToVtt(t):e}).catch(function(t){throw r.show(t),t})}},{key:"srtToVtt",value:function(t){var e="WEBVTT \r\n\r\n".concat(t.replace(/\{\\([ibu])\}/g,"").replace(/\{\\([ibu])1\}/g,"<$1>").replace(/\{([ibu])\}/g,"<$1>").replace(/\{\/([ibu])\}/g,"").replace(/(\d\d:\d\d:\d\d),(\d\d\d)/g,"$1.$2").concat("\r\n\r\n"));return URL.createObjectURL(new Blob([e],{type:"text/vtt"}))}},{key:"checkExt",value:function(t){var e=function t(e){return e.includes("?")?t(e.split("?")[0]):e.includes("#")?t(e.split("#")[0]):e.trim().toLowerCase().split(".").pop()}(t);b("vtt"===e||"srt"===e,"'subtitle.url' option require 'vtt' or 'srt' format, but got '".concat(e,"'."))}},{key:"show",value:function(){var t=this.art,e=t.refs.$subtitle,n=t.i18n,i=t.notice;H(e,"display","block"),this.isOpen=!0,i.show(n.get("Show subtitle")),this.art.emit("subtitle:show",e)}},{key:"hide",value:function(){var t=this.art,e=t.refs.$subtitle,n=t.i18n,i=t.notice;H(e,"display","none"),this.isOpen=!1,i.show(n.get("Hide subtitle")),this.art.emit("subtitle:hide",e)}},{key:"switch",value:function(e){var n=this,i=1'.concat(this.art.i18n.get(i),"")),w(r,'
'),this.$settings.push(r),t.apply&&t.apply(this.art,r),this[n]=t}}},{key:"mount",value:function(){var e=this;this.$settings.sort(function(t,e){return Number(t.dataset.settingIndex)-Number(e.dataset.settingIndex)}).forEach(function(t){w(e.art.refs.$settingBody,t)})}},{key:"show",value:function(){var t=this.art,e=t.refs.$setting,n=t.i18n,i=t.notice;H(e,"display","flex"),this.isOpen=!0,i.show(n.get("Show setting")),this.art.emit("setting:show",e)}},{key:"hide",value:function(){var t=this.art,e=t.refs.$setting,n=t.i18n,i=t.notice;H(e,"display","none"),this.isOpen=!1,i.show(n.get("Hide setting")),this.art.emit("setting:hide",e)}}]),e}(),At=0,Mt=[],Ot=function(t){function n(t){var e;return R(this,n),(e=h(this,f(n).call(this))).emit("init:start"),e.option=function t(){for(var e=function(t){return null!==t&&"object"===d(t)},n={},i=arguments.length,r=new Array(i),o=0;o