import{E as at,e as Mu}from"./index-Cy9UOSCT.js";import{a6 as ls,aa as Pu,d as Vu,t as Du,Q as Yu,s as Nu,p as Fu,o as Ws,b as Ms,g as Hu}from"./index-bVOhw2NF.js";function Ps(s,o){var i=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);o&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable})),i.push.apply(i,t)}return i}function Pe(s){for(var o=1;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function W(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function cs(s,o){if(o&&(typeof o=="object"||typeof o=="function"))return o;if(o!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return W(s)}function re(s){var o=Uu();return function(){var t=ae(s),e;if(o){var r=ae(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return cs(this,e)}}function Ku(s,o){for(;!Object.prototype.hasOwnProperty.call(s,o)&&(s=ae(s),s!==null););return s}function ce(){return typeof Reflect<"u"&&Reflect.get?ce=Reflect.get.bind():ce=function(o,i,t){var e=Ku(o,i);if(e){var r=Object.getOwnPropertyDescriptor(e,i);return r.get?r.get.call(arguments.length<3?o:t):r.value}},ce.apply(this,arguments)}function xt(s){return Ou(s)||Au(s)||zu(s)||Bu()}function Ou(s){if(Array.isArray(s))return Mn(s)}function Au(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function zu(s,o){if(s){if(typeof s=="string")return Mn(s,o);var i=Object.prototype.toString.call(s).slice(8,-1);if(i==="Object"&&s.constructor&&(i=s.constructor.name),i==="Map"||i==="Set")return Array.from(s);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Mn(s,o)}}function Mn(s,o){(o==null||o>s.length)&&(o=s.length);for(var i=0,t=new Array(o);i-1,an={info:"color: #525252; background-color: #90ee90;",error:"color: #525252; background-color: red;",warn:"color: #525252; background-color: yellow; "},on="%c[xgplayer]",pe={config:{debug:ju?3:0},logInfo:function(o){for(var i,t=arguments.length,e=new Array(t>1?t-1:0),r=1;r=3&&(i=console).log.apply(i,[on,an.info,o].concat(e))},logWarn:function(o){for(var i,t=arguments.length,e=new Array(t>1?t-1:0),r=1;r=1&&(i=console).warn.apply(i,[on,an.warn,o].concat(e))},logError:function(o){var i;if(!(this.config.debug<1)){for(var t=this.config.debug>=2?"trace":"error",e=arguments.length,r=new Array(e>1?e-1:0),n=1;n0&&arguments[0]!==void 0?arguments[0]:"div",o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},t=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"",e=document.createElement(s);return e.className=t,e.innerHTML=o,Object.keys(i).forEach(function(r){var n=r,a=i[r];s==="video"||s==="audio"||s==="live-video"?a&&e.setAttribute(n,a):e.setAttribute(n,a)}),e};S.createDomFromHtml=function(s){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"";try{var t=document.createElement("div");t.innerHTML=s;var e=t.children;return t=null,e.length>0?(e=e[0],i&&S.addClass(e,i),o&&Object.keys(o).forEach(function(r){e.setAttribute(r,o[r])}),e):null}catch(r){return pe.logError("util.createDomFromHtml",r),null}};S.hasClass=function(s,o){if(!s||!o)return!1;try{return Array.prototype.some.call(s.classList,function(t){return t===o})}catch{var i=s.className&&nt(s.className)==="object"?s.getAttribute("class"):s.className;return i&&!!i.match(new RegExp("(\\s|^)"+o+"(\\s|$)"))}};S.addClass=function(s,o){if(!(!s||!o))try{o.replace(/(^\s+|\s+$)/g,"").split(/\s+/g).forEach(function(i){i&&s.classList.add(i)})}catch{S.hasClass(s,o)||(s.className&&nt(s.className)==="object"?s.setAttribute("class",s.getAttribute("class")+" "+o):s.className+=" "+o)}};S.removeClass=function(s,o){if(!(!s||!o))try{o.replace(/(^\s+|\s+$)/g,"").split(/\s+/g).forEach(function(i){i&&s.classList.remove(i)})}catch{S.hasClass(s,o)&&o.split(/\s+/g).forEach(function(t){var e=new RegExp("(\\s|^)"+t+"(\\s|$)");s.className&&nt(s.className)==="object"?s.setAttribute("class",s.getAttribute("class").replace(e," ")):s.className=s.className.replace(e," ")})}};S.toggleClass=function(s,o){s&&o.split(/\s+/g).forEach(function(i){S.hasClass(s,i)?S.removeClass(s,i):S.addClass(s,i)})};S.classNames=function(){for(var s=arguments,o=[],i=function(r){S.typeOf(s[r])==="String"?o.push(s[r]):S.typeOf(s[r])==="Object"&&Object.keys(s[r]).map(function(n){s[r][n]&&o.push(n)})},t=0;t0&&arguments[0]!==void 0?arguments[0]:document,o=arguments.length>1?arguments[1]:void 0,i;try{i=s.querySelector(o)}catch(t){pe.logError("util.findDom",t),o.indexOf("#")===0&&(i=s.getElementById(o.slice(1)))}return i};S.getCss=function(s,o){return s.currentStyle?s.currentStyle[o]:document.defaultView.getComputedStyle(s,!1)[o]};S.padStart=function(s,o,i){for(var t=String(i),e=o>>0,r=Math.ceil(e/t.length),n=[],a=String(s);r--;)n.push(t);return n.join("").substring(0,e-a.length)+a};S.format=function(s){if(window.isNaN(s))return"";s=Math.round(s);var o=S.padStart(Math.floor(s/3600),2,0),i=S.padStart(Math.floor((s-o*3600)/60),2,0),t=S.padStart(Math.floor(s-o*3600-i*60),2,0);return(o==="00"?[i,t]:[o,i,t]).join(":")};S.event=function(s){if(s.touches){var o=s.touches[0]||s.changedTouches[0];s.clientX=o.clientX||0,s.clientY=o.clientY||0,s.offsetX=o.pageX-o.target.offsetLeft,s.offsetY=o.pageY-o.target.offsetTop}s._target=s.target||s.srcElement};S.typeOf=function(s){return Object.prototype.toString.call(s).match(/([^\s.*]+)(?=]$)/g)[0]};S.deepCopy=function(s,o){if(S.typeOf(o)==="Object"&&S.typeOf(s)==="Object")return Object.keys(o).forEach(function(i){S.typeOf(o[i])==="Object"&&!(o[i]instanceof Node)?s[i]===void 0||s[i]===void 0?s[i]=o[i]:S.deepCopy(s[i],o[i]):S.typeOf(o[i])==="Array"?s[i]=S.typeOf(s[i])==="Array"?s[i].concat(o[i]):o[i]:s[i]=o[i]}),s};S.deepMerge=function(s,o){return Object.keys(o).map(function(i){if(S.typeOf(o[i])==="Array"&&S.typeOf(s[i])==="Array"){if(S.typeOf(s[i])==="Array"){var t;(t=s[i]).push.apply(t,xt(o[i]))}}else S.typeOf(s[i])===S.typeOf(o[i])&&s[i]!==null&&S.typeOf(s[i])==="Object"&&!(o[i]instanceof window.Node)?S.deepMerge(s[i],o[i]):o[i]!==null&&(s[i]=o[i])}),s};S.getBgImage=function(s){var o=(s.currentStyle||window.getComputedStyle(s,null)).backgroundImage;if(!o||o==="none")return"";var i=document.createElement("a");return i.href=o.replace(/url\("|"\)/g,""),i.href};S.copyDom=function(s){if(s&&s.nodeType===1){var o=document.createElement(s.tagName);return Array.prototype.forEach.call(s.attributes,function(i){o.setAttribute(i.name,i.value)}),s.innerHTML&&(o.innerHTML=s.innerHTML),o}else return""};S.setInterval=function(s,o,i,t){s._interval[o]||(s._interval[o]=window.setInterval(i.bind(s),t))};S.clearInterval=function(s,o){clearInterval(s._interval[o]),s._interval[o]=null};S.setTimeout=function(s,o,i){s._timers||(s._timers=[]);var t=setTimeout(function(){o(),S.clearTimeout(s,t)},i);return s._timers.push(t),t};S.clearTimeout=function(s,o){var i=s._timers;if(S.typeOf(i)==="Array"){for(var t=0;t-1&&t.indexOf(u)>-1?(r=parseFloat(i.slice(0,i.indexOf(u)).trim()),n=parseFloat(t.slice(0,t.indexOf(u)).trim()),a=u,!1):!0}),e.style.width="".concat(r).concat(a),e.style.height="".concat(n).concat(a),e.style.backgroundSize="".concat(r).concat(a," ").concat(n).concat(a),s==="start"?e.style.margin="-".concat(n/2).concat(a," auto auto -").concat(r/2).concat(a):e.style.margin="auto 5px auto 5px"}return e};S.Hex2RGBA=function(s,o){var i=[];if(/^\#[0-9A-F]{3}$/i.test(s)){var t="#";s.replace(/[0-9A-F]/ig,function(e){t+=e+e}),s=t}return/^#[0-9A-F]{6}$/i.test(s)?(s.replace(/[0-9A-F]{2}/ig,function(e){i.push(parseInt(e,16))}),"rgba(".concat(i.join(","),", ").concat(o,")")):"rgba(255, 255, 255, 0.1)"};S.getFullScreenEl=function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement};S.checkIsFunction=function(s){return s&&typeof s=="function"};S.checkIsObject=function(s){return s!==null&&nt(s)==="object"};S.hide=function(s){s.style.display="none"};S.show=function(s,o){s.style.display=o||"block"};S.isUndefined=function(s){if(typeof s>"u"||s===null)return!0};S.isNotNull=function(s){return s!=null};S.setStyleFromCsstext=function(s,o){if(o)if(S.typeOf(o)==="String"){var i=o.replace(/\s+/g,"").split(";");i.map(function(t){if(t){var e=t.split(":");e.length>1&&(s.style[e[0]]=e[1])}})}else Object.keys(o).map(function(t){s.style[t]=o[t]})};function qu(s,o){for(var i=0,t=o.length;i-1)return!0;return!1}S.filterStyleFromText=function(s){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:["width","height","top","left","bottom","right","position","z-index","padding","margin","transform"],i=s.style.cssText;if(!i)return{};var t=i.replace(/\s+/g,"").split(";"),e={},r={};return t.map(function(n){if(n){var a=n.split(":");a.length>1&&(qu(a[0],o)?e[a[0]]=a[1]:r[a[0]]=a[1])}}),s.setAttribute("style",""),Object.keys(r).map(function(n){s.style[n]=r[n]}),e};S.getStyleFromCsstext=function(s){var o=s.style.cssText;if(!o)return{};var i=o.replace(/\s+/g,"").split(";"),t={};return i.map(function(e){if(e){var r=e.split(":");r.length>1&&(t[r[0]]=r[1])}}),t};S.preloadImg=function(s){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){};if(s){var t=new window.Image;t.onload=function(e){t=null,o&&o(e)},t.onerror=function(e){t=null,i&&i(e)},t.src=s}};S.stopPropagation=function(s){s&&s.stopPropagation()};S.scrollTop=function(){return window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0};S.scrollLeft=function(){return window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0};S.checkTouchSupport=function(){return"ontouchstart"in window};S.getBuffered2=function(s){for(var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5,i=[],t=0;ta&&(e[n-1].end=i[r].end):e.push(i[r])}else e.push(i[r])}else e=i;return new $u(e)};S.getEventPos=function(s){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;return s.touches&&s.touches.length>0&&(s=s.touches[0]),{x:s.x/o,y:s.y/o,clientX:s.clientX/o,clientY:s.clientY/o,offsetX:s.offsetX/o,offsetY:s.offsetY/o,pageX:s.pageX/o,pageY:s.pageY/o}};S.requestAnimationFrame=function(s){var o=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(o)return o(s)};S.getHostFromUrl=function(s){if(S.typeOf(s)!=="String")return"";var o=s.split("/"),i="";return o.length>3&&o[2]&&(i=o[2]),i};S.cancelAnimationFrame=function(s){var o=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.cancelRequestAnimationFrame;o&&o(s)};S.isMSE=function(s){return s.media&&(s=s.media),!s||!(s instanceof HTMLMediaElement)?!1:/^blob/.test(s.currentSrc)||/^blob/.test(s.src)};S.isBlob=function(s){return typeof s=="string"&&/^blob/.test(s)};S.generateSessionId=function(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,o=new Date().getTime();try{s=parseInt(s)}catch{s=0}o+=s,window.performance&&typeof window.performance.now=="function"&&(o+=parseInt(window.performance.now()));var i="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=(o+Math.random()*16)%16|0;return o=Math.floor(o/16),(t==="x"?e:e&3|8).toString(16)});return i};S.createEvent=function(s){var o;return typeof window.Event=="function"?o=new Event(s):(o=document.createEvent("Event"),o.initEvent(s,!0,!0)),o};S.adjustTimeByDuration=function(s,o,i){return!o||!s?s:s>o||i&&s0&&arguments[0]!==void 0?arguments[0]:{x:0,y:0,scale:1,rotate:0},o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",i={scale:"".concat(s.scale||1),translate:"".concat(s.x||0,"%, ").concat(s.y||0,"%"),rotate:"".concat(s.rotate||0,"deg")},t=Object.keys(i);return t.forEach(function(e){var r=new RegExp("".concat(e,"\\([^\\(]+\\)"),"g"),n="".concat(e,"(").concat(i[e],")");r.test(o)?(r.lastIndex=-1,o=o.replace(r,n)):o+="".concat(n," ")}),o};S.convertDeg=function(s){return Math.abs(s)<=1?s*360:s%360};S.getIndexByTime=function(s,o){var i=o.length,t=-1;if(i<1)return t;if(s<=o[0].end||i<2)t=0;else if(s>o[i-1].end)t=i-1;else for(var e=1;eo[e-1].end&&s<=o[e].end){t=e;break}return t};S.getOffsetCurrentTime=function(s,o){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:-1,t=-1;if(i>=0&&i=n&&s<=a?s-l:s>a&&t>=e-1?a:-1};S.getCurrentTimeByOffset=function(s,o){var i=-1;if(!o||o.length<0)return s;for(var t=0;t=o||D<0||d&&p>=r}function w(){var I=Date.now();if(_(I))return Z(I);a=g(w,k(I))}function Z(I){return a=void 0,h&&t?m(I):(t=e=void 0,n)}function C(){a!==void 0&&y(a),l=0,t=u=e=a=void 0}function R(){return a===void 0?n:Z(Date.now())}function E(){return a!==void 0}function P(){for(var I=Date.now(),D=_(I),p=arguments.length,v=new Array(p),b=0;b"u")return"";var s=navigator.userAgent.toLowerCase(),o={ie:/rv:([\d.]+)\) like gecko/,firefox:/firefox\/([\d.]+)/,chrome:/chrome\/([\d.]+)/,opera:/opera.([\d.]+)/,safari:/version\/([\d.]+).*safari/};return[].concat(Object.keys(o).filter(function(i){return o[i].test(s)}))[0]},get os(){if(typeof navigator>"u")return{};var s=navigator.userAgent,o=/(?:Windows Phone)/.test(s),i=/(?:SymbianOS)/.test(s)||o,t=/(?:Android)/.test(s),e=/(?:Firefox)/.test(s),r=/(?:iPad|PlayBook)/.test(s)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,n=r||t&&!/(?:Mobile)/.test(s)||e&&/(?:Tablet)/.test(s),a=/(?:iPhone)/.test(s)&&!n,u=!a&&!t&&!i&&!n;return{isTablet:n,isPhone:a,isIpad:r,isIos:a||r,isAndroid:t,isPc:u,isSymbian:i,isWindowsPhone:o,isFireFox:e}},get osVersion(){if(typeof navigator>"u")return 0;var s=navigator.userAgent,o="";/(?:iPhone)|(?:iPad|PlayBook)/.test(s)?o=Ds.ios:o=Ds.android;var i=o?o.exec(s):[];if(i&&i.length>=3){var t=i[2].split(".");return t.length>0?parseInt(t[0]):0}return 0},get isWeixin(){if(typeof navigator>"u")return!1;var s=/(micromessenger)\/([\d.]+)/,o=s.exec(navigator.userAgent.toLocaleLowerCase());return!!o},isSupportMP4:function(){var o={isSupport:!1,mime:""};if(typeof document>"u")return o;if(this.supportResult)return this.supportResult;var i=document.createElement("video");return typeof i.canPlayType=="function"&&nl.map(function(t){i.canPlayType('video/mp4; codecs="'.concat(t,'"'))==="probably"&&(o.isSupport=!0,o.mime+="||".concat(t))}),this.supportResult=o,i=null,o},isMSESupport:function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"';if(typeof MediaSource>"u"||!MediaSource)return!1;try{return MediaSource.isTypeSupported(o)}catch(i){return this._logger.error(o,i),!1}},isHevcSupported:function(){return typeof MediaSource>"u"||!MediaSource.isTypeSupported?!1:MediaSource.isTypeSupported('video/mp4;codecs="hev1.1.6.L120.90"')||MediaSource.isTypeSupported('video/mp4;codecs="hev1.2.4.L120.90"')||MediaSource.isTypeSupported('video/mp4;codecs="hev1.3.E.L120.90"')||MediaSource.isTypeSupported('video/mp4;codecs="hev1.4.10.L120.90"')},probeConfigSupported:function(o){var i={supported:!1,smooth:!1,powerEfficient:!1};if(!o||typeof navigator>"u")return Promise.resolve(i);if(navigator.mediaCapabilities&&navigator.mediaCapabilities.decodingInfo)return navigator.mediaCapabilities.decodingInfo(o);var t=o.video||{},e=o.audio||{};try{var r=MediaSource.isTypeSupported(t.contentType),n=MediaSource.isTypeSupported(e.contentType);return Promise.resolve({supported:r&&n,smooth:!1,powerEfficient:!1})}catch{return Promise.resolve(i)}}},Pn="3.0.20",Ys={1:"media",2:"media",3:"media",4:"media",5:"media",6:"media"},Ns={1:5101,2:5102,3:5103,4:5104,5:5105,6:5106},Lt=q(function s(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{errorType:"",errorCode:0,errorMessage:"",originError:"",ext:{},mediaError:null};$(this,s);var t=o&&o.i18n?o.i18n.ERROR_TYPES:null;if(o.media){var e=i.mediaError?i.mediaError:o.media.error||{},r=o.duration,n=o.currentTime,a=o.ended,u=o.src,l=o.currentSrc,c=o.media,d=c.readyState,h=c.networkState,f=i.errorCode||e.code;Ns[f]&&(f=Ns[f]);var m={playerVersion:Pn,currentTime:n,duration:r,ended:a,readyState:d,networkState:h,src:u||l,errorType:i.errorType,errorCode:f,message:i.errorMessage||e.message,mediaError:e,originError:i.originError?i.originError.stack:"",host:S.getHostFromUrl(u||l)};return i.ext&&Object.keys(i.ext).map(function(k){m[k]=i.ext[k]}),m}else if(arguments.length>1){for(var g={playerVersion:Pn,domain:document.domain},y=["errorType","currentTime","duration","networkState","readyState","src","currentSrc","ended","errd","errorCode","mediaError"],L=0;L0&&arguments[0]!==void 0?arguments[0]:this.media;this._evHandlers||(this._evHandlers=ko.map(function(n){var a="on".concat(n.charAt(0).toUpperCase()).concat(n.slice(1));return typeof e[a]=="function"&&e.on(n,e[a]),V({},n,pl(n,e))})),this._evHandlers.forEach(function(n){var a=Object.keys(n)[0];r.addEventListener(a,n[a],!1)})}},{key:"detachVideoEvents",value:function(){var e=this,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.media;this._evHandlers.forEach(function(n){var a=Object.keys(n)[0];r.removeEventListener(a,n[a],!1)}),this._evHandlers.forEach(function(n){var a=Object.keys(n)[0],u="on".concat(a.charAt(0).toUpperCase()).concat(a.slice(1));typeof e[u]=="function"&&e.off(a,e[u])}),this._evHandlers=null}},{key:"_attachSourceEvents",value:function(e,r){var n=this;e.removeAttribute("src"),e.load(),r.forEach(function(d,h){n.media.appendChild(S.createDom("source","",{src:"".concat(d.src),type:"".concat(d.type||""),"data-index":h+1}))});var a=e.children;if(a){this._videoSourceCount=a.length,this._videoSourceIndex=a.length,this._vLoadeddata=function(d){n.emit(Lo,{src:d.target.currentSrc,host:S.getHostFromUrl(d.target.currentSrc)})};for(var u=null,l=0;l=n._videoSourceCount){var f={code:4,message:"sources_load_error"};u?u.error(d,f):n.errorHandler("error",f)}var m=Ys[4];n.emit(So,new Lt(n,{errorType:m,errorCode:4,errorMessage:"sources_load_error",mediaError:{code:4,message:"sources_load_error"},src:d.target.src}))});for(var c=0;c0;)e.removeChild(r[0]);this._vLoadeddata&&e.removeEventListener("loadeddata",this._vLoadeddata)}}},{key:"errorHandler",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(this.media&&(this.media.error||r)){var n=this.media.error||r,a=n.code?Ys[n.code]:"other",u=n.message;this.media.currentSrc||(u="empty_src",n={code:6,message:u}),this.emit(e,new Lt(this,{errorType:a,errorCode:n.code,errorMessage:n.message||"",mediaError:n}))}}},{key:"destroy",value:function(){this.media&&(this.media.pause&&(this.media.pause(),this.media.muted=!0),this.media.removeAttribute("src"),this.media.load()),this._currentTime=0,this._duration=0,this.mediaConfig=null;for(var e in this._interval)Object.prototype.hasOwnProperty.call(this._interval,e)&&(clearInterval(this._interval[e]),this._interval[e]=null);this.detachVideoEvents(),this.media=null,this.mediaEventMiddleware={},this.removeAllListeners()}},{key:"video",get:function(){return this.media},set:function(e){this.media=e}},{key:"play",value:function(){var e=this.media?this.media.play():null;return e}},{key:"pause",value:function(){this.media&&this.media.pause()}},{key:"load",value:function(){this.media&&this.media.load()}},{key:"canPlayType",value:function(e){return this.media?this.media.canPlayType(e):!1}},{key:"getBufferedRange",value:function(e){var r=[0,0];if(!this.media)return r;e||(e=this.media.buffered);var n=this.media.currentTime;if(e)for(var a=0,u=e.length;a=this.currentTime)return{start:r.start(n),end:r.end(n)};return e}},{key:"crossOrigin",get:function(){return this.media?this.media.crossOrigin:""},set:function(e){this.media&&(this.media.crossOrigin=e)}},{key:"currentSrc",get:function(){return this.media?this.media.currentSrc:""},set:function(e){this.media&&(this.media.currentSrc=e)}},{key:"currentTime",get:function(){return this.media?this.media.currentTime!==void 0?this.media.currentTime:this._currentTime:0},set:function(e){this.media&&(this.media.currentTime=e)}},{key:"defaultMuted",get:function(){return this.media?this.media.defaultMuted:!1},set:function(e){this.media&&(this.media.defaultMuted=e)}},{key:"duration",get:function(){return this._duration}},{key:"ended",get:function(){return this.media?this.media.ended:!1}},{key:"error",get:function(){return this.media.error}},{key:"errorNote",get:function(){var e=this.media.error;if(!e)return"";var r=["MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED"];return r[this.media.error.code-1]}},{key:"loop",get:function(){return this.media?this.media.loop:!1},set:function(e){this.media&&(this.media.loop=e)}},{key:"muted",get:function(){return this.media?this.media.muted:!1},set:function(e){!this.media||this.media.muted===e||(this._lastMuted=this.media.muted,this.media.muted=e)}},{key:"networkState",get:function(){return this.media.networkState}},{key:"paused",get:function(){return this.media?this.media.paused:!0}},{key:"playbackRate",get:function(){return this.media?this.media.playbackRate:0},set:function(e){!this.media||e===1/0||(this.media.defaultPlaybackRate=e,this.media.playbackRate=e)}},{key:"played",get:function(){return this.media?this.media.played:null}},{key:"preload",get:function(){return this.media?this.media.preload:!1},set:function(e){this.media&&(this.media.preload=e)}},{key:"readyState",get:function(){return this.media.readyState}},{key:"seekable",get:function(){return this.media?this.media.seekable:!1}},{key:"seeking",get:function(){return this.media?this.media.seeking:!1}},{key:"src",get:function(){return this.media?this.media.src:""},set:function(e){if(this.media){if(this.emit(Bt,e),this.emit(Li),this._currentTime=0,this._duration=0,S.isMSE(this.media)){this.onWaiting();return}this._detachSourceEvents(this.media),S.typeOf(e)==="Array"?this._attachSourceEvents(this.media,e):e?this.media.src=e:this.media.removeAttribute("src"),this.load()}}},{key:"volume",get:function(){return this.media?this.media.volume:0},set:function(e){e===1/0||!this.media||(this.media.volume=e)}},{key:"aspectRatio",get:function(){return this.media?this.media.videoWidth/this.media.videoHeight:0}},{key:"addInnerOP",value:function(e){this._internalOp[e]=!0}},{key:"removeInnerOP",value:function(e){delete this._internalOp[e]}},{key:"emit",value:function(e,r){for(var n,a=arguments.length,u=new Array(a>2?a-2:0),l=2;l2?a-2:0),l=2;l2?a-2:0),l=2;l2?a-2:0),l=2;l0&&arguments[0]!==void 0?arguments[0]:{name:"xgplayer",version:1,db:null,ojstore:{name:"xg-m4a",keypath:"vid"}};$(this,s),this.indexedDB=window.indexedDB||window.webkitindexedDB,this.IDBKeyRange=window.IDBKeyRange||window.webkitIDBKeyRange,this.myDB=o}return q(s,[{key:"openDB",value:function(i){var t=this,e=this,r=this.myDB.version||1,n=e.indexedDB.open(e.myDB.name,r);n.onerror=function(a){},n.onsuccess=function(a){t.myDB.db=a.target.result,i.call(e)},n.onupgradeneeded=function(a){var u=a.target.result;a.target.transaction,u.objectStoreNames.contains(e.myDB.ojstore.name)||u.createObjectStore(e.myDB.ojstore.name,{keyPath:e.myDB.ojstore.keypath})}}},{key:"deletedb",value:function(){var i=this;i.indexedDB.deleteDatabase(this.myDB.name)}},{key:"closeDB",value:function(){this.myDB.db.close()}},{key:"addData",value:function(i,t){for(var e=this.myDB.db.transaction(i,"readwrite").objectStore(i),r,n=0;n3?t-3:0),r=3;r2&&arguments[2]!==void 0?arguments[2]:{pre:null,next:null};return this.__hooks||(this.__hooks={}),!this.__hooks[s]&&(this.__hooks[s]=null),(function(){var t=arguments,e=this;if(i.pre)try{var r;(r=i.pre).call.apply(r,[this].concat(Array.prototype.slice.call(arguments)))}catch(a){throw a.message="[pluginName: ".concat(this.pluginName,":").concat(s,":pre error] >> ").concat(a.message),a}if(this.__hooks&&this.__hooks[s])try{var n=Vt(this,s,o);n?n.then?n.then(function(a){a!==!1&&vr.apply(void 0,[e,o,i.next].concat(xt(t)))}).catch(function(a){throw a}):vr.apply(void 0,[this,o,i.next].concat(Array.prototype.slice.call(arguments))):n===void 0&&vr.apply(void 0,[this,o,i.next].concat(Array.prototype.slice.call(arguments)))}catch(a){throw a.message="[pluginName: ".concat(this.pluginName,":").concat(s,"] >> ").concat(a.message),a}else vr.apply(void 0,[this,o,i.next].concat(Array.prototype.slice.call(arguments)))}).bind(this)}function _o(s,o){var i=this.__hooks;if(!i||!Array.isArray(i[s]))return-1;for(var t=i[s],e=0;e1?i-1:0),e=1;e1?i-1:0),e=1;e1&&arguments[1]!==void 0?arguments[1]:[];s.__hooks={},o&&o.map(function(i){s.__hooks[i]=null}),Object.defineProperty(s,"hooks",{get:function(){return s.__hooks&&Object.keys(s.__hooks).map(function(t){if(s.__hooks[t])return t})}})}function Eo(s){s.__hooks=null}function Vt(s,o,i){for(var t=arguments.length,e=new Array(t>3?t-3:0),r=3;r3?f-3:0),g=3;g1?e-1:0),n=1;n2&&arguments[2]!==void 0?arguments[2]:{};if(this.player){var r=Pe(Pe({},e),{},{pluginName:this.pluginName});this.player.emitUserAction(i,t,r)}}},{key:"hook",value:function(i,t){return Pr.call.apply(Pr,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"useHooks",value:function(i,t){for(var e=arguments.length,r=new Array(e>2?e-2:0),n=2;n2?e-2:0),n=2;n1&&arguments[1]!==void 0?arguments[1]:{},e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"";if(this.player)return e&&(t.pluginName=e),this.player.registerPlugin({plugin:i,options:t})}},{key:"getPlugin",value:function(i){return this.player?this.player.getPlugin(i):null}},{key:"__destroy",value:function(){var i=this,t=this.player,e=this.pluginName;this.offAll(),S.clearAllTimers(this),S.checkIsFunction(this.destroy)&&this.destroy(),["player","playerConfig","pluginName","logger","__args","__hooks"].map(function(r){i[r]=null}),t.unRegisterPlugin(e),Eo(this)}}],[{key:"defineGetterOrSetter",value:function(i,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&Object.defineProperty(i,e,t[e])}},{key:"defineMethod",value:function(i,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&typeof t[e]=="function"&&Object.defineProperty(i,e,{configurable:!0,value:t[e]})}},{key:"defaultConfig",get:function(){return{}}},{key:"pluginName",get:function(){return"pluginName"}}]),s}(),yl=9;if(typeof Element<"u"&&!Element.prototype.matches){var Ii=Element.prototype;Ii.matches=Ii.matchesSelector||Ii.mozMatchesSelector||Ii.msMatchesSelector||Ii.oMatchesSelector||Ii.webkitMatchesSelector}function bl(s,o){for(;s&&s.nodeType!==yl;){if(typeof s.matches=="function"&&s.matches(o))return s;s=s.parentNode}}var Sl=bl,Ll=Sl;function cn(s,o,i,t,e){var r=kl.apply(this,arguments);return s.addEventListener(i,r,e),{destroy:function(){s.removeEventListener(i,r,e)}}}function Zl(s,o,i,t,e){return typeof s.addEventListener=="function"?cn.apply(null,arguments):typeof i=="function"?cn.bind(null,document).apply(null,arguments):(typeof s=="string"&&(s=document.querySelectorAll(s)),Array.prototype.map.call(s,function(r){return cn(r,o,i,t,e)}))}function kl(s,o,i,t){return function(e){e.delegateTarget=Ll(e.target,o),e.delegateTarget&&t.call(s,e)}}var Tl=Zl;const As=ls(Tl);var wl={CONTROLS:"controls",ROOT:"root"},xe={ROOT:"root",ROOT_LEFT:"rootLeft",ROOT_RIGHT:"rootRight",ROOT_TOP:"rootTop",CONTROLS_LEFT:"controlsLeft",CONTROLS_RIGTH:"controlsRight",CONTROLS_RIGHT:"controlsRight",CONTROLS_CENTER:"controlsCenter",CONTROLS:"controls"},zs={ICON_DISABLE:"xg-icon-disable",ICON_HIDE:"xg-icon-hide"};function dn(s){return s?s.indexOf&&/^(?:http|data:|\/)/.test(s):!1}function _l(s,o){return nt(s)==="object"&&s.class&&typeof s.class=="string"?"".concat(o," ").concat(s.class):o}function Cl(s,o){return nt(s)==="object"&&s.attr&&nt(s.attr)==="object"&&Object.keys(s.attr).map(function(i){o[i]=s.attr[i]}),o}function Bs(s,o){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"",t=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},e=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"",r=null;if(s instanceof window.Element)return S.addClass(s,i),Object.keys(t).map(function(n){s.setAttribute(n,t[n])}),s;if(dn(s)||dn(s.url))return t.src=dn(s)?s:s.url||"",r=S.createDom(s.tag||"img","",t,"xg-img ".concat(i)),r;if(typeof s=="function")try{return r=s(),r instanceof window.Element?(S.addClass(r,i),Object.keys(t).map(function(n){r.setAttribute(n,t[n])}),r):(pe.logWarn("warn>>icons.".concat(o," in config of plugin named [").concat(e,"] is a function mast return an Element Object")),null)}catch(n){return pe.logError("Plugin named [".concat(e,"]:createIcon"),n),null}return typeof s=="string"?S.createDomFromHtml(s,t,i):(pe.logWarn("warn>>icons.".concat(o," in config of plugin named [").concat(e,"] is invalid")),null)}function El(s,o){var i=o.config.icons||o.playerConfig.icons;Object.keys(s).map(function(t){var e=s[t],r=e&&e.class?e.class:"",n=e&&e.attr?e.attr:{},a=null;i&&i[t]&&(r=_l(i[t],r),n=Cl(i[t],n),a=Bs(i[t],t,r,n,o.pluginName)),!a&&e&&(a=Bs(e.icon?e.icon:e,n,r,{},o.pluginName)),o.icons[t]=a})}function xl(s,o){Object.keys(s).map(function(i){Object.defineProperty(o.langText,i,{get:function(){var e=o.lang,r=o.i18n;return r[i]?r[i]:s[i]&&s[i][e]||""}})})}var Le=function(s){ie(i,s);var o=re(i);function i(){var t,e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return $(this,i),t=o.call(this,e),t.__delegates=[],t}return q(i,[{key:"__init",value:function(e){if(ce(ae(i.prototype),"__init",this).call(this,e),!!e.root){var r=e.root,n=null;this.icons={},this.root=null,this.parent=null;var a=this.registerIcons()||{};El(a,this),this.langText={};var u=this.registerLanguageTexts()||{};xl(u,this);var l="";try{l=this.render()}catch(h){throw pe.logError("Plugin:".concat(this.pluginName,":render"),h),new Error("Plugin:".concat(this.pluginName,":render:").concat(h.message))}if(l)n=i.insert(l,r,e.index),n.setAttribute("data-index",e.index);else if(e.tag)n=S.createDom(e.tag,"",e.attr,e.name),n.setAttribute("data-index",e.index),r.appendChild(n);else return;this.root=n,this.parent=r;var c=this.config.attr||{},d=this.config.style||{};this.setAttr(c),this.setStyle(d),this.config.index&&this.root.setAttribute("data-index",this.config.index),this.__registerChildren()}}},{key:"__registerChildren",value:function(){var e=this;if(this.root){this._children=[];var r=this.children();r&&nt(r)==="object"&&Object.keys(r).length>0&&Object.keys(r).map(function(n){var a=n,u=r[a],l={root:e.root},c,d;typeof u=="function"?(c=e.config[a]||{},d=u):nt(u)==="object"&&typeof u.plugin=="function"&&(c=u.options?S.deepCopy(e.config[a]||{},u.options):e.config[a]||{},d=u.plugin),l.config=c,c.index!==void 0&&(l.index=c.index),c.root&&(l.root=c.root),e.registerPlugin(d,l,a)})}}},{key:"updateLang",value:function(e){e||(e=this.lang);function r(l,c){for(var d=0;d0?r(l.children[d],c):c(l.children[d])}var n=this.root,a=this.i18n,u=this.langText;n&&r(n,function(l){var c=l.getAttribute&&l.getAttribute("lang-key");if(c){var d=a[c.toUpperCase()]||u[c];d&&(l.innerHTML=typeof d=="function"?d(e):d)}})}},{key:"lang",get:function(){return this.player.lang}},{key:"changeLangTextKey",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",n=this.i18n||{},a=this.langText;e.setAttribute&&e.setAttribute("lang-key",r);var u=n[r]||a[r]||"";u&&(e.innerHTML=u)}},{key:"plugins",value:function(){return this._children}},{key:"disable",value:function(){this.config.disable=!0,S.addClass(this.find(".xgplayer-icon"),zs.ICON_DISABLE)}},{key:"enable",value:function(){this.config.disable=!1,S.removeClass(this.find(".xgplayer-icon"),zs.ICON_DISABLE)}},{key:"children",value:function(){return{}}},{key:"registerPlugin",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"";r.root=r.root||this.root;var a=ce(ae(i.prototype),"registerPlugin",this).call(this,e,r,n);return this._children.push(a),a}},{key:"registerIcons",value:function(){return{}}},{key:"registerLanguageTexts",value:function(){return{}}},{key:"find",value:function(e){if(this.root)return this.root.querySelector(e)}},{key:"bind",value:function(e,r,n){var a=this;if(arguments.length<3&&typeof r=="function")Array.isArray(e)?e.forEach(function(l){a.bindEL(l,r)}):this.bindEL(e,r);else{var u=i.delegate.call(this,this.root,e,r,n);this.__delegates=this.__delegates.concat(u)}}},{key:"unbind",value:function(e,r){var n=this;if(arguments.length<3&&typeof r=="function")Array.isArray(e)?e.forEach(function(l){n.unbindEL(l,r)}):this.unbindEL(e,r);else for(var a="".concat(e,"_").concat(r),u=0;u2&&arguments[2]!==void 0?arguments[2]:!1;this.root&&"on".concat(e)in this.root&&typeof r=="function"&&this.root.addEventListener(e,r,n)}},{key:"unbindEL",value:function(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;this.root&&"on".concat(e)in this.root&&typeof r=="function"&&this.root.removeEventListener(e,r,n)}},{key:"show",value:function(e){if(this.root){this.root.style.display=e!==void 0?e:"block";var r=window.getComputedStyle(this.root,null),n=r.getPropertyValue("display");if(n==="none")return this.root.style.display="block"}}},{key:"hide",value:function(){this.root&&(this.root.style.display="none")}},{key:"appendChild",value:function(e,r){if(!this.root)return null;if(arguments.length<2&&arguments[0]instanceof window.Element)return this.root.appendChild(arguments[0]);if(!r||!(r instanceof window.Element))return null;try{return typeof e=="string"?this.find(e).appendChild(r):e.appendChild(r)}catch(n){return pe.logError("Plugin:appendChild",n),null}}},{key:"render",value:function(){return""}},{key:"destroy",value:function(){}},{key:"__destroy",value:function(){var e=this,r=this.player;this.__delegates.map(function(n){n.destroy()}),this.__delegates=[],this._children instanceof Array&&(this._children.map(function(n){r.unRegisterPlugin(n.pluginName)}),this._children=null),this.root&&(this.root.hasOwnProperty("remove")?this.root.remove():this.root.parentNode&&this.root.parentNode.removeChild(this.root)),ce(ae(i.prototype),"__destroy",this).call(this),this.icons={},["root","parent"].map(function(n){e[n]=null})}}],[{key:"insert",value:function(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=r.children.length,u=Number(n),l=e instanceof window.Node;if(a){for(var c=0,d=null,h="";c=u){h="beforebegin";break}else f4&&arguments[4]!==void 0?arguments[4]:!1,l=[];if(e instanceof window.Node&&typeof a=="function")if(Array.isArray(n))n.forEach(function(d){var h=As(e,r,d,a,u);h.key="".concat(r,"_").concat(d),l.push(h)});else{var c=As(e,r,n,a,u);c.key="".concat(r,"_").concat(n),l.push(c)}return l}},{key:"ROOT_TYPES",get:function(){return wl}},{key:"POSITIONS",get:function(){return xe}}]),i}(Ue),Rl=function(){function s(){var o=this;if($(this,s),V(this,"__trigger",function(i){var t=new Date().getTime();o.timeStamp=t;for(var e=0;e-1?this.__handlers[n].handler=t:this.__handlers.push({target:i,handler:t,playerId:e})}}},{key:"unObserver",value:function(i){var t=-1;this.__handlers.map(function(r,n){i===r.target&&(t=n)});try{var e;(e=this.observer)===null||e===void 0||e.unobserve(i)}catch{}t>-1&&this.__handlers.splice(t,1)}},{key:"destroyObserver",value:function(){var i;(i=this.observer)===null||i===void 0||i.disconnect(),this.observer=null,this.__handlers=null}},{key:"__runHandler",value:function(i){for(var t=this.__handlers,e=0;e2&&arguments[2]!==void 0?arguments[2]:{};if(!(!o||!i||typeof i!="function"||i.prototype===void 0)){var e=o._pluginInfoId;if(!(!e||!this.pluginGroup[e])){this.pluginGroup[e]._plugins||(this.pluginGroup[e]._plugins={});var r=this.pluginGroup[e]._plugins,n=this.pluginGroup[e]._originalOptions;t.player=o;var a=t.pluginName||i.pluginName;if(!a)throw new Error("The property pluginName is necessary");if(i.isSupported&&!i.isSupported(o.config.mediaType,o.config.codecType)){console.warn("not supported plugin [".concat(a,"]"));return}t.config||(t.config={});for(var u=Object.keys(n),l=0;l"u"&&(t.config[h]=i.defaultConfig[h])}),t.root?typeof t.root=="string"&&(t.root=o[t.root]):t.root=o.root,t.index=t.config.index||0;try{r[a.toLowerCase()]&&(this.unRegister(e,a.toLowerCase()),console.warn("the is one plugin with same pluginName [".concat(a,"] exist, destroy the old instance")));var d=new i(t);return r[a.toLowerCase()]=d,r[a.toLowerCase()].func=i,d&&typeof d.afterCreate=="function"&&d.afterCreate(),d}catch(h){throw console.error(h),h}}}},unRegister:function(o,i){o._pluginInfoId&&(o=o._pluginInfoId),i=i.toLowerCase();try{var t=this.pluginGroup[o]._plugins[i];t&&(t.pluginName&&t.__destroy(),delete this.pluginGroup[o]._plugins[i])}catch(e){console.error("[unRegister:".concat(i,"] cgid:[").concat(o,"] error"),e)}},deletePlugin:function(o,i){var t=o._pluginInfoId;t&&this.pluginGroup[t]&&this.pluginGroup[t]._plugins&&delete this.pluginGroup[t]._plugins[i]},getPlugins:function(o){var i=o._pluginInfoId;return i&&this.pluginGroup[i]?this.pluginGroup[i]._plugins:{}},findPlugin:function(o,i){var t=o._pluginInfoId;if(!t||!this.pluginGroup[t])return null;var e=i.toLowerCase();return this.pluginGroup[t]._plugins[e]},beforeInit:function(o){var i=this;function t(e){return!e||!e.then?new Promise(function(r){r()}):e}return new Promise(function(e){if(i.pluginGroup){var r;return o._loadingPlugins&&o._loadingPlugins.length?r=Promise.all(o._loadingPlugins):r=Promise.resolve(),r.then(function(){var n=o._pluginInfoId;if(!i.pluginGroup[n]){e();return}var a=i.pluginGroup[n]._plugins,u=[];Object.keys(a).forEach(function(l){if(a[l]&&a[l].beforePlayerInit)try{var c=a[l].beforePlayerInit();u.push(t(c))}catch(d){throw u.push(t(null)),d}}),Promise.all([].concat(u)).then(function(){e()}).catch(function(l){console.error(l),e()})})}})},afterInit:function(o){var i=o._pluginInfoId;if(!(!i||!this.pluginGroup[i])){var t=this.pluginGroup[i]._plugins;Object.keys(t).forEach(function(e){t[e]&&t[e].afterPlayerInit&&t[e].afterPlayerInit()})}},setLang:function(o,i){var t=i._pluginInfoId;if(!(!t||!this.pluginGroup[t])){var e=this.pluginGroup[t]._plugins;Object.keys(e).forEach(function(r){if(e[r].updateLang)e[r].updateLang(o);else try{e[r].lang=o}catch{console.warn("".concat(r," setLang"))}})}},reRender:function(o){var i=this,t=o._pluginInfoId;if(!(!t||!this.pluginGroup[t])){var e=[],r=this.pluginGroup[t]._plugins;Object.keys(r).forEach(function(n){n!=="controls"&&r[n]&&(e.push({plugin:r[n].func,options:r[n].__args}),i.unRegister(t,n))}),e.forEach(function(n){i.register(o,n.plugin,n.options)})}},onPluginsReady:function(o){var i=o._pluginInfoId;if(!(!i||!this.pluginGroup[i])){var t=this.pluginGroup[i]._plugins||{};Object.keys(t).forEach(function(e){t[e].onPluginsReady&&typeof t[e].onPluginsReady=="function"&&t[e].onPluginsReady()})}},destroy:function(o){var i=o._pluginInfoId;if(this.pluginGroup[i]){Gl(o.root);for(var t=this.pluginGroup[i]._plugins,e=0,r=Object.keys(t);e1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;if(this.root){var a=e.defaultConfig||{};if(!r.root){var u=r.position?r.position:r.config&&r.config.position?r.config.position:a.position;switch(u){case xe.CONTROLS_LEFT:r.root=this.left;break;case xe.CONTROLS_RIGHT:r.root=this.right;break;case xe.CONTROLS_CENTER:r.root=this.center;break;case xe.CONTROLS:r.root=this.root;break;default:r.root=this.left}return ce(ae(i.prototype),"registerPlugin",this).call(this,e,r,n)}}}},{key:"destroy",value:function(){le.device!=="mobile"&&(this.unbind("mouseenter",this.onMouseEnter),this.unbind("mouseleave",this.onMouseLeave))}},{key:"render",value:function(){var e=this.config,r=e.mode,n=e.autoHide,a=e.initShow,u=e.disable;if(!u){var l=S.classNames({"xgplayer-controls":!0},{"flex-controls":r==="flex"},{"bottom-controls":r==="bottom"},V({},A.CONTROLS_AUTOHIDE,n),{"xgplayer-controls-initshow":a||!n});return' `)}}}],[{key:"pluginName",get:function(){return"controls"}},{key:"defaultConfig",get:function(){return{disable:!1,autoHide:!0,mode:"",initShow:!1}}}]),i}(Le),Ml={LANG:"en",TEXT:{ERROR_TYPES:{network:{code:1,msg:"video download error"},mse:{code:2,msg:"stream append error"},parse:{code:3,msg:"parsing error"},format:{code:4,msg:"wrong format"},decoder:{code:5,msg:"decoding error"},runtime:{code:6,msg:"grammatical errors"},timeout:{code:7,msg:"play timeout"},other:{code:8,msg:"other errors"}},HAVE_NOTHING:"There is no information on whether audio/video is ready",HAVE_METADATA:"Audio/video metadata is ready ",HAVE_CURRENT_DATA:"Data about the current play location is available, but there is not enough data to play the next frame/millisecond",HAVE_FUTURE_DATA:"Current and at least one frame of data is available",HAVE_ENOUGH_DATA:"The available data is sufficient to start playing",NETWORK_EMPTY:"Audio/video has not been initialized",NETWORK_IDLE:"Audio/video is active and has been selected for resources, but no network is used",NETWORK_LOADING:"The browser is downloading the data",NETWORK_NO_SOURCE:"No audio/video source was found",MEDIA_ERR_ABORTED:"The fetch process is aborted by the user",MEDIA_ERR_NETWORK:"An error occurred while downloading",MEDIA_ERR_DECODE:"An error occurred while decoding",MEDIA_ERR_SRC_NOT_SUPPORTED:"Audio/video is not supported",REPLAY:"Replay",ERROR:"Network is offline",PLAY_TIPS:"Play",PAUSE_TIPS:"Pause",PLAYNEXT_TIPS:"Play next",DOWNLOAD_TIPS:"Download",ROTATE_TIPS:"Rotate",RELOAD_TIPS:"Reload",FULLSCREEN_TIPS:"Fullscreen",EXITFULLSCREEN_TIPS:"Exit fullscreen",CSSFULLSCREEN_TIPS:"Cssfullscreen",EXITCSSFULLSCREEN_TIPS:"Exit cssfullscreen",TEXTTRACK:"Caption",PIP:"PIP",SCREENSHOT:"Screenshot",LIVE:"LIVE",OFF:"Off",OPEN:"Open",MINI_DRAG:"Click and hold to drag",MINISCREEN:"Miniscreen",REFRESH_TIPS:"Please Try",REFRESH:"Refresh",FORWARD:"forward",LIVE_TIP:"Live"}},yt={lang:{},langKeys:[],textKeys:[]};function ir(s,o){return Object.keys(o).forEach(function(i){var t=S.typeOf(o[i]),e=S.typeOf(s[i]);if(t==="Array"){var r;e!=="Array"&&(s[i]=[]),(r=s[i]).push.apply(r,xt(o[i]))}else t==="Object"?(e!=="Object"&&(s[i]={}),ir(s[i],o[i])):s[i]=o[i]}),s}function xo(){Object.keys(yt.lang.en).map(function(s){yt.textKeys[s]=s})}function Pl(s,o){var i=[];if(o||(o=yt),!!o.lang){S.typeOf(s)!=="Array"?i=Object.keys(s).map(function(r){var n=r==="zh"?"zh-cn":r;return{LANG:n,TEXT:s[r]}}):i=s;var t=o,e=t.lang;i.map(function(r){r.LANG==="zh"&&(r.LANG="zh-cn"),e[r.LANG]?ir(e[r.LANG]||{},r.TEXT||{}):vs(r,o)}),xo()}}function vs(s,o){var i=s.LANG;if(o||(o=yt),!!o.lang){var t=s.TEXT||{};i==="zh"&&(i="zh-cn"),o.lang[i]?ir(o.lang[i],t):(o.langKeys.push(i),o.lang[i]=t),xo()}}function Vl(s){var o,i={lang:{},langKeys:[],textKeys:{},pId:s};return ir(i.lang,yt.lang),(o=i.langKeys).push.apply(o,xt(yt.langKeys)),ir(i.textKeys,yt.textKeys),i}vs(Ml);var Ui={get textKeys(){return yt.textKeys},get langKeys(){return yt.langKeys},get lang(){var s={};return yt.langKeys.map(function(o){s[o]=yt.lang[o]}),yt.lang["zh-cn"]&&(s.zh=yt.lang["zh-cn"]||{}),s},extend:Pl,use:vs,init:Vl},ye={INITIAL:1,READY:2,ATTACHING:3,ATTACHED:4,NOTALLOW:5,RUNNING:6,ENDED:7,DESTROYED:8},js=["ERROR","INITIAL","READY","ATTACHING","ATTACHED","NOTALLOW","RUNNING","ENDED","DESTROYED"],ct={},hn=null,Ro=function(s){ie(i,s);var o=re(i);function i(){return $(this,i),o.apply(this,arguments)}return q(i,[{key:"add",value:function(e){e&&(ct[e.playerId]=e,Object.keys(ct).length===1&&this.setActive(e.playerId,!0))}},{key:"remove",value:function(e){e&&(e.isUserActive,delete ct[e.playerId])}},{key:"_iterate",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;for(var n in ct)if(Object.prototype.hasOwnProperty.call(ct,n)){var a=ct[n];if(r){if(e(a))break}else e(a)}}},{key:"forEach",value:function(e){this._iterate(e)}},{key:"find",value:function(e){var r=null;return this._iterate(function(n){var a=e(n);return a&&(r=n),a},!0),r}},{key:"findAll",value:function(e){var r=[];return this._iterate(function(n){e(n)&&r.push(n)}),r}},{key:"setActive",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(ct[e])return r?this.forEach(function(n){e===n.playerId?(n.isUserActive=!0,n.isInstNext=!1):n.isUserActive=!1}):ct[e].isUserActive=r,e}},{key:"getActiveId",value:function(){for(var e=Object.keys(ct),r=0;r1&&arguments[1]!==void 0?arguments[1]:!0;if(ct[e])return r?this.forEach(function(n){e===n.playerId?(n.isUserActive=!1,n.isInstNext=!0):n.isInstNext=!1}):ct[e].isInstNext=r,e}}],[{key:"getInstance",value:function(){return hn||(hn=new i),hn}}]),i}(Mu.EventEmitter);function Dl(s){for(var o=Object.keys(ct),i=0;i=0&&n&&(e.config.presets[a]=n)}else n&&e.config.presets.push(n);e.userTimer=null,e.waitTimer=null,e.handleSource=!0,e._state=ye.INITIAL,e.isAd=!1,e.isError=!1,e._hasStart=!1,e.isSeeking=!1,e.isCanplay=!1,e._useAutoplay=!1,e.__startTime=-1,e.rotateDeg=0,e.isActive=!1,e.fullscreen=!1,e.cssfullscreen=!1,e.isRotateFullscreen=!1,e._fullscreenEl=null,e.timeSegments=[],e._cssfullscreenEl=null,e.curDefinition=null,e._orgCss="",e._fullScreenOffset=null,e._videoHeight=0,e._videoWidth=0,e.videoPos={pi:1,scale:0,rotate:-1,x:0,y:0,h:-1,w:-1,vy:0,vx:0},e.sizeInfo={width:0,height:0,left:0,top:0},e._accPlayed={t:0,acc:0,loopAcc:0},e._offsetInfo={currentTime:-1,duration:0},e.innerContainer=null,e.controls=null,e.topBar=null,e.root=null,e.__i18n=Ui.init(e._pluginInfoId),le.os.isAndroid&&le.osVersion>0&&le.osVersion<6&&(e.config.autoplay=!1),e.database=new gl,e.isUserActive=!1,e._onceSeekCanplay=null,e._isPauseBeforeSeek=0,e.innerStates={isActiveLocked:!1},e.instManager=ii;var u=e._initDOM();if(!u)return console.error(new Error("can't find the dom which id is ".concat(e.config.id," or this.config.el does not exist"))),cs(e);var l=e.config,c=l.definition,d=c===void 0?{}:c,h=l.url;if(!h&&d.list&&d.list.length>0){var f=d.list.find(function(m){return m.definition&&m.definition===d.defaultDefinition});f||(d.defaultDefinition=d.list[0].definition,f=d.list[0]),e.config.url=f.url,e.curDefinition=f}return e._bindEvents(),e._registerPresets(),e._registerPlugins(),Ke.onPluginsReady(W(e)),e.getInitDefinition(),e.setState(ye.READY),S.setTimeout(W(e),function(){e.emit(ms)},0),e.onReady&&e.onReady(),(e.config.videoInit||e.config.autoplay)&&(!e.hasStart||e.state0?this._attachSourceEvents(this.media,e):!this.media.src||this.media.src!==e?this.media.src=e:e||this.media.removeAttribute("src")),S.typeOf(this.config.volume)==="Number"&&(this.volume=this.config.volume);var n=this.innerContainer?this.innerContainer:this.root;this.media instanceof window.Element&&!n.contains(this.media)&&n.insertBefore(this.media,n.firstChild);var a=this.media.readyState;pe.logInfo("_startInit readyState",a),this.config.autoplay&&(!S.isMSE(this.media)&&this.load(),(le.os.isIpad||le.os.isPhone)&&this.mediaPlay());var u=this.config.startTime;this.__startTime=u>0?u:-1,this.config.startTime=0,a>=2&&this.duration>0?this.canPlayFunc():this.on(At,this.canPlayFunc),(!this.hasStart||this.state0&&arguments[0]!==void 0?arguments[0]:!0;this._loadingPlugins=[];var n=this.config.ignores||[],a=this.config.plugins||[],u=this.config.i18n||[];r&&Ui.extend(u,this.__i18n);var l=n.join("||").toLowerCase().split("||"),c=this.plugins;a.forEach(function(d){try{var h=d.plugin?d.plugin.pluginName:d.pluginName;if(h&&l.indexOf(h.toLowerCase())>-1)return null;if(!r&&c[h.toLowerCase()])return;if(d.lazy&&d.loader){var f=Ke.lazyRegister(e,d);d.forceBeforeInit&&(f.then(function(){e._loadingPlugins.splice(e._loadingPlugins.indexOf(f),1)}).catch(function(m){pe.logError("_registerPlugins:loadingPlugin",m),e._loadingPlugins.splice(e._loadingPlugins.indexOf(f),1)}),e._loadingPlugins.push(f));return}return e.registerPlugin(d)}catch(m){pe.logError("_registerPlugins:",m)}})}},{key:"_registerPresets",value:function(){var e=this;this.config.presets.forEach(function(r){Il(e,r)})}},{key:"_getRootByPosition",value:function(e){var r=null;switch(e){case xe.ROOT_RIGHT:this.rightBar||(this.rightBar=S.createPositionBar("xg-right-bar",this.root)),r=this.rightBar;break;case xe.ROOT_LEFT:this.leftBar||(this.leftBar=S.createPositionBar("xg-left-bar",this.root)),r=this.leftBar;break;case xe.ROOT_TOP:this.topBar||(this.topBar=S.createPositionBar("xg-top-bar",this.root),this.config.topBarAutoHide&&S.addClass(this.topBar,A.TOP_BAR_AUTOHIDE)),r=this.topBar;break;default:r=this.innerContainer||this.root;break}return r}},{key:"registerPlugin",value:function(e,r){var n=Ke.formatPluginInfo(e,r),a=n.PLUFGIN,u=n.options,l=this.config.plugins,c=Ke.checkPluginIfExits(a.pluginName,l);!c&&l.push(a);var d=Ke.getRootByConfig(a.pluginName,this.config);d.root&&(u.root=d.root),d.position&&(u.position=d.position);var h=u.position?u.position:u.config&&u.config.position||a.defaultConfig&&a.defaultConfig.position;if(!u.root&&typeof h=="string"&&h.indexOf("controls")>-1){var f;return(f=this.controls)===null||f===void 0?void 0:f.registerPlugin(a,u,a.pluginName)}return u.root||(u.root=this._getRootByPosition(h)),Ke.register(this,a,u)}},{key:"deregister",value:function(e){typeof e=="string"?Ke.unRegister(this,e):e instanceof Ue&&Ke.unRegister(this,e.pluginName)}},{key:"unRegisterPlugin",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;this.deregister(e),r&&this.removePluginFromConfig(e)}},{key:"removePluginFromConfig",value:function(e){var r;if(typeof e=="string"?r=e:e instanceof Ue&&(r=e.pluginName),!!r)for(var n=this.config.plugins.length-1;n>-1;n--){var a=this.config.plugins[n];if(a.pluginName.toLowerCase()===r.toLowerCase()){this.config.plugins.splice(n,1);break}}}},{key:"plugins",get:function(){return Ke.getPlugins(this)}},{key:"getPlugin",value:function(e){var r=Ke.findPlugin(this,e);return r&&r.pluginName?r:null}},{key:"addClass",value:function(e){this.root&&(S.hasClass(this.root,e)||S.addClass(this.root,e))}},{key:"removeClass",value:function(e){this.root&&S.removeClass(this.root,e)}},{key:"hasClass",value:function(e){if(this.root)return S.hasClass(this.root,e)}},{key:"setAttribute",value:function(e,r){this.root&&this.root.setAttribute(e,r)}},{key:"removeAttribute",value:function(e,r){this.root&&this.root.removeAttribute(e,r)}},{key:"start",value:function(e){var r=this;if(!(this.state>ye.ATTACHING))return!e&&!this.config.url&&this.getInitDefinition(),this.hasStart=!0,this.setState(ye.ATTACHING),this._registerPlugins(!1),Ke.beforeInit(this).then(function(){if(r.config){e||(e=r.url||r.config.url);var n=r._preProcessUrl(e),a=r._startInit(n.url);return a}}).catch(function(n){throw n.fileName="player",n.lineNumber="236",pe.logError("start:beforeInit:",n),n})}},{key:"switchURL",value:function(e,r){var n=this,a=e;S.typeOf(e)==="Object"&&(a=e.url),a=this._preProcessUrl(a).url;var u=this.currentTime;this.__startTime=u;var l=this.paused&&!this.isError;return this.src=a,new Promise(function(c,d){var h=function(g){n.off("timeupdate",f),n.off("canplay",f),d(g)},f=function(){n._seekToStartTime(),l&&n.pause(),n.off("error",h),c(!0)};if(n.once("error",h),!a){n.errorHandler("error",{code:6,message:"empty_src"});return}le.os.isAndroid?n.once("timeupdate",f):n.once("canplay",f),n.play()})}},{key:"videoPlay",value:function(){this.mediaPlay()}},{key:"mediaPlay",value:function(){var e=this;if(!this.hasStart&&this.state>>>playPromise.then"),e.setState(ye.RUNNING),e.emit(yi))}).catch(function(n){if(pe.logWarn(">>>>playPromise.catch",n.name),e.media&&e.media.error){e.onError(),e.removeClass(A.ENTER);return}n.name==="NotAllowedError"&&(e._errorTimer=S.setTimeout(e,function(){e._errorTimer=null,e.emit(ps),e.addClass(A.NOT_ALLOW_AUTOPLAY),e.removeClass(A.ENTER),e.pause(),e.setState(ye.NOTALLOW)},0))}):(pe.logWarn("video.play not return promise"),this.statethis.duration?parseInt(this.duration,10):e,!this._isPauseBeforeSeek&&(this._isPauseBeforeSeek=this.paused?2:1),this._onceSeekCanplay&&this.off(zt,this._onceSeekCanplay),this._onceSeekCanplay=function(){switch(n.removeClass(A.ENTER),n.isSeeking=!1,c){case"play":n.play();break;case"pause":n.pause();break;default:n._isPauseBeforeSeek>1||n.paused?n.pause():n.play()}n._isPauseBeforeSeek=0,n._onceSeekCanplay=null},this.once(zt,this._onceSeekCanplay),this.state0&&n.defaultDefinition&&n.list.map(function(u){u.definition===n.defaultDefinition&&(e.config.url=u.url,e.curDefinition=u)})}},{key:"changeDefinition",value:function(e,r){var n=this,a=this.config.definition;if(Array.isArray(a==null?void 0:a.list)&&a.list.forEach(function(l){(e==null?void 0:e.definition)===l.definition&&(n.curDefinition=l)}),e!=null&&e.bitrate&&typeof e.bitrate!="number"&&(e.bitrate=parseInt(e.bitrate,10)||0),this.emit(zr,{from:r,to:e}),!this.hasStart){this.config.url=e.url;return}var u=this.switchURL(e.url,Pe({seamless:a.seamless!==!1&&typeof MediaSource<"u"&&typeof MediaSource.isTypeSupported=="function"},e));u&&u.then?u.then(function(){n.emit(Ir,{from:r,to:e})}):this.emit(Ir,{from:r,to:e})}},{key:"reload",value:function(){this.load(),this.reloadFunc=function(){this.play()},this.once(jt,this.reloadFunc)}},{key:"resetState",value:function(){var e=this,r=A.NOT_ALLOW_AUTOPLAY,n=A.PLAYING,a=A.NO_START,u=A.PAUSED,l=A.REPLAY,c=A.ENTER,d=A.ENDED,h=A.ERROR,f=A.LOADING,m=[r,n,a,u,l,c,d,h,f];this.hasStart=!1,this.isError=!1,this._useAutoplay=!1,this.mediaPause(),this._accPlayed.acc=0,this._accPlayed.t=0,this._accPlayed.loopAcc=0,m.forEach(function(g){e.removeClass(g)}),this.addClass(A.NO_START),this.emit(Br)}},{key:"reset",value:function(){var e=this,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0;this.resetState();var a=this.plugins;if(a&&(r.map(function(l){e.deregister(l)}),n)){var u=Js();Object.keys(this.config).keys(function(l){e.config[l]!=="undefined"&&(l==="plugins"||l==="presets"||l==="el"||l==="id")&&(e.config[l]=u[l])})}}},{key:"destroy",value:function(){var e,r=this,n=this.innerContainer,a=this.root,u=this.media;if(!(!a||!u)){if(this.hasStart=!1,this._useAutoplay=!1,a.removeAttribute(mi),this.updateAcc("destroy"),this._unbindEvents(),this._detachSourceEvents(this.media),S.clearAllTimers(this),this.emit(ji),(e=ii)===null||e===void 0||e.remove(this),Ke.destroy(this),Eo(this),ce(ae(i.prototype),"destroy",this).call(this),this.fullscreen&&this._fullscreenEl===this.root&&this.exitFullscreen(),n)for(var l=n.children,c=0;c0?a.className=d.filter(function(h){return h.indexOf("xgplayer")<0}).join(" "):a.className="",this.removeAttribute("data-xgfill"),["isSeeking","isCanplay","isActive","cssfullscreen","fullscreen"].forEach(function(h){r[h]=!1})}}},{key:"replay",value:function(){var e=this;this.removeClass(A.ENDED),this.currentTime=0,this.isSeeking=!1,Vt(this,"replay",function(){e.once(zt,function(){var r=e.mediaPlay();r&&r.catch&&r.catch(function(n){console.log(n)})}),e.emit(tr),e.onPlay()})}},{key:"retry",value:function(){var e=this;this.removeClass(A.ERROR),this.addClass(A.LOADING),Vt(this,"retry",function(){var r=e.currentTime,n=e.config.url,a=S.isMSE(e.media)?{url:n}:e._preProcessUrl(n);e.src=a.url,!e.config.isLive&&(e.currentTime=r),e.once(At,function(){e.mediaPlay()})})}},{key:"changeFullStyle",value:function(e,r,n,a){e&&(a||(a=A.PARENT_FULLSCREEN),this._orgCss||(this._orgCss=S.filterStyleFromText(e)),S.addClass(e,n),r&&r!==e&&!this._orgPCss&&(this._orgPCss=S.filterStyleFromText(r),S.addClass(r,a),r.setAttribute(mi,this.playerId)))}},{key:"recoverFullStyle",value:function(e,r,n,a){a||(a=A.PARENT_FULLSCREEN),this._orgCss&&(S.setStyleFromCsstext(e,this._orgCss),this._orgCss=""),S.removeClass(e,n),r&&r!==e&&this._orgPCss&&(S.setStyleFromCsstext(r,this._orgPCss),this._orgPCss="",S.removeClass(r,a),r.removeAttribute(mi))}},{key:"getFullscreen",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.config.fullscreenTarget,r=this.root,n=this.media;(e==="video"||e==="media")&&(e=this[e]),e||(e=r),this._fullScreenOffset={top:S.scrollTop(),left:S.scrollLeft()},this._fullscreenEl=e,this._fullActionFrom="get";var a=S.getFullScreenEl();if(a===this._fullscreenEl)return this.onFullscreenChange(),Promise.resolve();try{for(var u=0;u0&&arguments[0]!==void 0?arguments[0]:this.config.fullscreenTarget;this.isRotateFullscreen?this.exitRotateFullscreen():this.fullscreen&&this.exitFullscreen();var r=e?"".concat(A.INNER_FULLSCREEN," ").concat(A.CSS_FULLSCREEN):A.CSS_FULLSCREEN;this.changeFullStyle(this.root,e,r);var n=this.config.fullscreen,a=n===void 0?{}:n,u=a.useCssFullscreen===!0||typeof a.useCssFullscreen=="function"&&a.useCssFullscreen();u&&(this.fullscreen=!0,this.emit(Ot,!0)),this._cssfullscreenEl=e,this.cssfullscreen=!0,this.emit(Xr,!0)}},{key:"exitCssFullscreen",value:function(){var e=this._cssfullscreenEl?"".concat(A.INNER_FULLSCREEN," ").concat(A.CSS_FULLSCREEN):A.CSS_FULLSCREEN;if(!this.fullscreen)this.recoverFullStyle(this.root,this._cssfullscreenEl,e);else{var r=this.config.fullscreen,n=r===void 0?{}:r,a=n.useCssFullscreen===!0||typeof n.useCssFullscreen=="function"&&n.useCssFullscreen();a?(this.recoverFullStyle(this.root,this._cssfullscreenEl,e),this.fullscreen=!1,this.emit(Ot,!1)):this.removeClass(e)}this._cssfullscreenEl=null,this.cssfullscreen=!1,this.emit(Xr,!1)}},{key:"getRotateFullscreen",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.config.fullscreenTarget;this.cssfullscreen&&this.exitCssFullscreen(e);var r=e?"".concat(A.INNER_FULLSCREEN," ").concat(A.ROTATE_FULLSCREEN):A.ROTATE_FULLSCREEN;this._fullscreenEl=e||this.root,this.changeFullStyle(this.root,e,r,A.PARENT_ROTATE_FULLSCREEN),this.isRotateFullscreen=!0,this.fullscreen=!0,this.setRotateDeg(90),this._rootStyle=this.root.getAttribute("style"),this.root.style.width="".concat(window.innerHeight,"px"),this.emit(Ot,!0)}},{key:"exitRotateFullscreen",value:function(e){var r=this._fullscreenEl!==this.root?"".concat(A.INNER_FULLSCREEN," ").concat(A.ROTATE_FULLSCREEN):A.ROTATE_FULLSCREEN;this.recoverFullStyle(this.root,this._fullscreenEl,r,A.PARENT_ROTATE_FULLSCREEN),this.isRotateFullscreen=!1,this.fullscreen=!1,this.setRotateDeg(0),this.emit(Ot,!1),this._rootStyle&&(this.root.style.style=this._rootStyle,this._rootStyle=!1)}},{key:"setRotateDeg",value:function(e){window.orientation===90||window.orientation===-90?this.rotateDeg=0:this.rotateDeg=e}},{key:"focus",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{autoHide:!this.config.closeDelayBlur,delay:this.config.inactive};if(this.isActive){this.onFocus(e);return}this.emit(fs,Pe({paused:this.paused,ended:this.ended},e))}},{key:"blur",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{ignorePaused:!1};if(!this.isActive){this.onBlur(e);return}this._clearUserTimer(),this.emit(co,Pe({paused:this.paused,ended:this.ended},e))}},{key:"onFocus",value:function(){var e=this,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{autoHide:!0,delay:3e3},n=this.innerStates;if(this.isActive=!0,this.removeClass(A.INACTIVE),this._clearUserTimer(),r.isLock!==void 0&&(n.isActiveLocked=r.isLock),r.autoHide===!1||r.isLock===!0||n.isActiveLocked){this._clearUserTimer();return}var a=r&&r.delay?r.delay:this.config.inactive;this.userTimer=S.setTimeout(this,function(){e.userTimer=null,e.blur()},a)}},{key:"onBlur",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=e.ignorePaused,n=r===void 0?!1:r;if(!this.innerStates.isActiveLocked){var a=this.config.closePauseVideoFocus;this.isActive=!1,(n||a||!this.paused&&!this.ended)&&this.addClass(A.INACTIVE)}}},{key:"onEmptied",value:function(){this.updateAcc("emptied")}},{key:"onCanplay",value:function(){this.removeClass(A.ENTER),this.removeClass(A.ERROR),this.removeClass(A.LOADING),this.isCanplay=!0,this.waitTimer&&S.clearTimeout(this,this.waitTimer)}},{key:"onLoadeddata",value:function(){var e=this;this.isError=!1,this.isSeeking=!1,this.__startTime>0&&(this.duration>0?this._seekToStartTime():this.once($t,function(){e._seekToStartTime()}))}},{key:"onLoadstart",value:function(){this.removeClass(A.ERROR),this.isCanplay=!1}},{key:"onPlay",value:function(){this.state===ye.ENDED&&this.setState(ye.RUNNING),this.removeClass(A.PAUSED),this.ended&&this.removeClass(A.ENDED),!this.config.closePlayVideoFocus&&this.focus()}},{key:"onPause",value:function(){this.addClass(A.PAUSED),this.updateAcc("pause"),this.config.closePauseVideoFocus||(this._clearUserTimer(),this.focus())}},{key:"onEnded",value:function(){this.updateAcc("ended"),this.addClass(A.ENDED),this.setState(ye.ENDED)}},{key:"onError",value:function(){this.isError=!0,this.updateAcc("error"),this.removeClass(A.NOT_ALLOW_AUTOPLAY),this.removeClass(A.NO_START),this.removeClass(A.ENTER),this.removeClass(A.LOADING),this.addClass(A.ERROR)}},{key:"onSeeking",value:function(){this.isSeeking||this.updateAcc("seeking"),this.isSeeking=!0,this.addClass(A.SEEKING)}},{key:"onSeeked",value:function(){this.isSeeking=!1,this.waitTimer&&S.clearTimeout(this,this.waitTimer),this.removeClass(A.LOADING),this.removeClass(A.SEEKING)}},{key:"onWaiting",value:function(){var e=this;this.waitTimer&&S.clearTimeout(this,this.waitTimer),this.updateAcc("waiting"),this.waitTimer=S.setTimeout(this,function(){e.addClass(A.LOADING),e.emit(po),S.clearTimeout(e,e.waitTimer),e.waitTimer=null},this.config.minWaitDelay)}},{key:"onPlaying",value:function(){var e=this;this.isError=!1;var r=A.NO_START,n=A.PAUSED,a=A.ENDED,u=A.ERROR,l=A.REPLAY,c=A.LOADING,d=[r,n,a,u,l,c];d.forEach(function(h){e.removeClass(h)}),!this._accPlayed.t&&!this.paused&&!this.ended&&(this._accPlayed.t=new Date().getTime())}},{key:"onTimeupdate",value:function(){!this._videoHeight&&this.media.videoHeight&&this.resize(),(this.waitTimer||this.hasClass(A.LOADING))&&this.media.readyState>2&&(this.removeClass(A.LOADING),S.clearTimeout(this,this.waitTimer),this.waitTimer=null),!this.paused&&this.state===ye.NOTALLOW&&this.duration&&(this.setState(ye.RUNNING),this.emit(yi)),!this._accPlayed.t&&!this.paused&&!this.ended&&(this._accPlayed.t=new Date().getTime())}},{key:"onVolumechange",value:function(){S.typeOf(this.config.volume)==="Number"&&(this.config.volume=this.volume)}},{key:"onRatechange",value:function(){this.config.defaultPlaybackRate=this.playbackRate}},{key:"emitUserAction",value:function(e,r,n){if(!(!this.media||!r||!e)){var a=S.typeOf(e)==="String"?e:e.type||"";n.props&&S.typeOf(n.props)!=="Array"&&(n.props=[n.props]),this.emit(Mr,Pe({eventType:a,action:r,currentTime:this.currentTime,duration:this.duration,ended:this.ended,event:e},n))}}},{key:"updateAcc",value:function(e){if(this._accPlayed.t){var r=new Date().getTime()-this._accPlayed.t;this._accPlayed.acc+=r,this._accPlayed.t=0,(e==="ended"||this.ended)&&(this._accPlayed.loopAcc=this._accPlayed.acc)}}},{key:"checkBuffer",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{startDiff:0,endDiff:0},n=r||{},a=n.startDiff,u=a===void 0?0:a,l=n.endDiff,c=l===void 0?0:l,d=this.media.buffered;if(!d||d.length===0||!this.duration)return!0;for(var h=e||this.media.currentTime||.2,f=d.length,m=0;mh)return!0;return!1}},{key:"resizePosition",value:function(){var e=this.videoPos,r=e.vy,n=e.vx,a=e.h,u=e.w,l=this.videoPos.rotate;if(!(l<0&&a<0&&u<0)){var c=this.videoPos._pi;if(!c&&this.media.videoHeight&&(c=this.media.videoWidth/this.media.videoHeight*100),!!c){this.videoPos.pi=c,l=l<0?0:l;var d={rotate:l},h=0,f=0,m=1,g=Math.abs(l/90),y=this.root,L=this.innerContainer,k=y.offsetWidth,_=L?L.offsetHeight:y.offsetHeight,w=_,Z=k;if(g%2===0)m=a>0?100/a:u>0?100/u:1,d.scale=m,h=r>0?(100-a)/2-r:0,d.y=g===2?0-h:h,f=n>0?(100-u)/2-n:0,d.x=g===2?0-f:f,this.media.style.width="".concat(Z,"px"),this.media.style.height="".concat(w,"px");else if(g%2===1){Z=_,w=k;var C=_-k;f=-C/2/Z*100,d.x=g===3?f+r/2:f-r/2,h=C/2/w*100,d.y=g===3?h+n/2:h-n/2,d.scale=m,this.media.style.width="".concat(Z,"px"),this.media.style.height="".concat(w,"px")}var R=S.getTransformStyle(d,this.media.style.transform||this.media.style.webkitTransform);this.media.style.transform=R,this.media.style.webkitTransform=R}}}},{key:"position",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{h:0,y:0,x:0,w:0};if(!(!this.media||!e||!e.h)){var r=this.videoPos;r.h=e.h*100||0,r.w=e.w*100||0,r.vx=e.x*100||0,r.vy=e.y*100||0,this.resizePosition()}}},{key:"setConfig",value:function(e){var r=this;e&&Object.keys(e).map(function(n){if(n!=="plugins"){r.config[n]=e[n];var a=r.plugins[n.toLowerCase()];a&&S.typeOf(a.setConfig)==="Function"&&a.setConfig(e[n])}})}},{key:"playNext",value:function(e){var r=this;this.resetState(),this.setConfig(e),this._currentTime=0,this._duration=0,Vt(this,"playnext",function(){r.start(),r.emit(Wr,e)})}},{key:"resize",value:function(){var e=this;if(this.media){var r=this.root.getBoundingClientRect();this.sizeInfo.width=r.width,this.sizeInfo.height=r.height,this.sizeInfo.left=r.left,this.sizeInfo.top=r.top;var n=this.media,a=n.videoWidth,u=n.videoHeight,l=this.config,c=l.fitVideoSize,d=l.videoFillMode;if((d==="fill"||d==="cover"||d==="contain")&&this.setAttribute("data-xgfill",d),!(!u||!a)){this._videoHeight=u,this._videoWidth=a;var h=this.controls&&this.innerContainer?this.controls.root.getBoundingClientRect().height:0,f=r.width,m=r.height-h,g=parseInt(a/u*1e3,10),y=parseInt(f/m*1e3,10),L=f,k=m,_={};c==="auto"&&y>g||c==="fixWidth"?(k=f/g*1e3,this.config.fluid?_.paddingTop="".concat(k*100/L,"%"):_.height="".concat(k+h,"px")):(c==="auto"&&yg)&&this.setAttribute("data-xgfill","cover");var w={videoScale:g,vWidth:L,vHeight:k,cWidth:L,cHeight:k+h};this.resizePosition(),this.emit(ui,w)}}}},{key:"updateObjectPosition",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(this.media.updateObjectPosition){this.media.updateObjectPosition(e,r);return}this.media.style.objectPosition="".concat(e*100,"% ").concat(r*100,"%")}},{key:"setState",value:function(e){pe.logInfo("setState","state from:".concat(js[this.state]," to:").concat(js[e])),this._state=e}},{key:"_preProcessUrl",value:function(e,r){var n=this.config,a=n.preProcessUrl,u=n.preProcessUrlOptions,l=Object.assign({},u,r);return!S.isBlob(e)&&typeof a=="function"?a(e,l):{url:e}}},{key:"_seekToStartTime",value:function(){this.__startTime>0&&this.duration>0&&(this.currentTime=this.__startTime>this.duration?this.duration:this.__startTime,this.__startTime=-1)}},{key:"state",get:function(){return this._state}},{key:"isFullscreen",get:function(){return this.fullscreen}},{key:"isCssfullScreen",get:function(){return this.cssfullscreen}},{key:"hasStart",get:function(){return this._hasStart},set:function(e){typeof e=="boolean"&&(this._hasStart=e,e===!1&&this.setState(ye.READY),this.emit("hasstart"))}},{key:"isPlaying",get:function(){return this._state===ye.RUNNING||this._state===ye.ENDED},set:function(e){e?this.setState(ye.RUNNING):this._state>=ye.RUNNING&&this.setState(ye.ATTACHED)}},{key:"definitionList",get:function(){return!this.config||!this.config.definition?[]:this.config.definition.list||[]},set:function(e){var r=this,n=this.config.definition,a=null,u=null;n.list=e,this.emit("resourceReady",e),e.forEach(function(l){var c;((c=r.curDefinition)===null||c===void 0?void 0:c.definition)===l.definition&&(a=l),n.defaultDefinition===l.definition&&(u=l)}),!u&&e.length>0&&(u=e[0]),a?this.changeDefinition(a):u&&this.changeDefinition(u)}},{key:"videoFrameInfo",get:function(){var e={total:0,dropped:0,corrupted:0,droppedRate:0,droppedDuration:0};if(!this.media||!this.media.getVideoPlaybackQuality)return e;var r=this.media.getVideoPlaybackQuality();return e.dropped=r.droppedVideoFrames||0,e.total=r.totalVideoFrames||0,e.corrupted=r.corruptedVideoFrames||0,e.total>0&&(e.droppedRate=e.dropped/e.total*100,e.droppedDuration=parseInt(this.cumulateTime/e.total*e.dropped,0)),e}},{key:"lang",get:function(){return this.config.lang},set:function(e){var r=Ui.langKeys.filter(function(n){return n===e});if(r.length===0&&e!=="zh"){console.error("Sorry, set lang fail, because the language [".concat(e,"] is not supported now, list of all supported languages is [").concat(Ui.langKeys.join(),"] "));return}this.config.lang=e,Ke.setLang(e,this)}},{key:"i18n",get:function(){var e=this.config.lang;return e==="zh"&&(e="zh-cn"),this.__i18n.lang[e]||this.__i18n.lang.en}},{key:"i18nKeys",get:function(){return this.__i18n.textKeys||{}}},{key:"version",get:function(){return Pn}},{key:"playerId",get:function(){return this._pluginInfoId}},{key:"url",get:function(){return this.__url||this.config.url},set:function(e){this.__url=e}},{key:"poster",get:function(){return this.plugins.poster?this.plugins.poster.config.poster:this.config.poster},set:function(e){this.plugins.poster&&this.plugins.poster.update(e)}},{key:"readyState",get:function(){return ce(ae(i.prototype),"readyState",this)}},{key:"error",get:function(){var e=ce(ae(i.prototype),"error",this);return this.i18n[e]||e}},{key:"networkState",get:function(){return ce(ae(i.prototype),"networkState",this)}},{key:"fullscreenChanging",get:function(){return this._fullScreenOffset!==null}},{key:"cumulateTime",get:function(){var e=this._accPlayed,r=e.acc,n=e.t;return n?new Date().getTime()-n+r:r}},{key:"zoom",get:function(){return this.config.zoom},set:function(e){this.config.zoom=e}},{key:"videoRotateDeg",get:function(){return this.videoPos.rotate},set:function(e){e=S.convertDeg(e),!(e%90!==0||e===this.videoPos.rotate)&&(this.videoPos.rotate=e,this.resizePosition())}},{key:"avgSpeed",get:function(){return $s},set:function(e){$s=e}},{key:"realTimeSpeed",get:function(){return Qs},set:function(e){Qs=e}},{key:"offsetCurrentTime",get:function(){return this._offsetInfo.currentTime||0},set:function(e){this._offsetInfo.currentTime=e}},{key:"offsetDuration",get:function(){return this._offsetInfo.duration||0},set:function(e){this._offsetInfo.duration=e||0}},{key:"hook",value:function(e,r){return Pr.call.apply(Pr,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"useHooks",value:function(e,r){return Vr.call.apply(Vr,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"removeHooks",value:function(e,r){return Dr.call.apply(Dr,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"usePluginHooks",value:function(e,r,n){for(var a=arguments.length,u=new Array(a>3?a-3:0),l=3;l3?a-3:0),l=3;l0&&n&&!a&&(pe.logInfo("[xgLogger]".concat(this.player.playerId," emitLog_firstFrame"),e),this._state.isFFLoading=!1,this._state.isFFSend=!0,this.emitLog(ri.FIRST_FRAME,{fvt:this.fvt,costTime:this.fvt,vt:this.vt,startCostTime:this.startCostTime,loadedCostTime:this.loadedCostTime}))}},{key:"_startWaitTimeout",value:function(){var e=this;this._waittTimer&&S.clearTimeout(this,this._waittTimer),this._waittTimer=S.setTimeout(this,function(){e.suspendWaitingStatus("timeout"),S.clearTimeout(e,e._waittTimer),e._waittTimer=null},this.config.waitTimeout)}},{key:"endState",value:function(e){this.suspendWaitingStatus(e),this.suspendSeekingStatus(e)}},{key:"suspendSeekingStatus",value:function(e){if(this.seekingStart){var r=et(),n=r-this.seekingStart;this.seekingStart=0,this.emitLog(ri.SEEK_END,{end:r,costTime:n,endType:e})}}},{key:"suspendWaitingStatus",value:function(e){if(this._waitTimer&&(S.clearTimeout(this,this._waitTimer),this._waitTimer=null),this._waittTimer&&(S.clearTimeout(this,this._waittTimer),this._waittTimer=null),this._isWaiting=!1,!!this.waitingStart){var r=et(),n=r-this.waitingStart,a=r-this.fixedWaitingStart,u=this.config.waitTimeout;this._isWaiting=!1,this.waitingStart=0,this.fixedWaitingStart=0,this.emitLog(ri.WAIT_END,{fixedCostTime:a>u?u:a,costTime:n>u?u:n,type:e==="loadeddata"?1:this._waitType,endType:this._waitType===2?"seek":e})}}},{key:"emitLog",value:function(e,r){var n=this.player;this.emit(bo,Pe({t:et(),host:S.getHostFromUrl(n.currentSrc),vtype:n.vtype,eventType:e,currentTime:this.player.currentTime,readyState:n.video.readyState,networkState:n.video.networkState},r))}}],[{key:"pluginName",get:function(){return"xgLogger"}},{key:"defaultConfig",get:function(){return{waitTimeout:1e4}}}]),i}(Le);function Fl(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}var Hl=function(s){ie(i,s);var o=re(i);function i(){return $(this,i),o.apply(this,arguments)}return q(i,[{key:"registerIcons",value:function(){return{replay:Fl}}},{key:"afterCreate",value:function(){var e=this;Le.insert(this.icons.replay,this.root,0),this.__handleReplay=this.hook("replayClick",function(){e.player.replay()},{pre:function(n){n.preventDefault(),n.stopPropagation()}}),this.bind(".xgplayer-replay",["click","touchend"],this.__handleReplay),this.on(wi,function(){if(e.playerConfig.loop||S.addClass(e.player.root,"replay"),!e.config.disable){e.show();var r=e.root.querySelector("path");if(r){var n=window.getComputedStyle(r).getPropertyValue("transform");if(typeof n=="string"&&n.indexOf("none")>-1)return null;r.setAttribute("transform",n)}}}),this.on(bt,function(){e.hide()})}},{key:"handleReplay",value:function(e){e.preventDefault(),e.stopPropagation(),this.player.replay(),S.removeClass(this.player.root,"replay")}},{key:"show",value:function(e){this.config.disable||(this.root.style.display="flex")}},{key:"enable",value:function(){this.config.disable=!1}},{key:"disable",value:function(){this.config.disable=!0,this.hide()}},{key:"destroy",value:function(){this.unbind(".xgplayer-replay",["click","touchend"],this.__handleReplay)}},{key:"render",value:function(){return` ').concat(this.i18n.REPLAY,` `)}}],[{key:"pluginName",get:function(){return"replay"}},{key:"defaultConfig",get:function(){return{disable:!1}}}]),i}(Le),Ul=function(s){ie(i,s);var o=re(i);function i(){return $(this,i),o.apply(this,arguments)}return q(i,[{key:"isEndedShow",get:function(){return this.config.isEndedShow},set:function(e){this.config.isEndedShow=e}},{key:"hide",value:function(){S.addClass(this.root,"hide")}},{key:"show",value:function(e){S.removeClass(this.root,"hide")}},{key:"beforeCreate",value:function(e){typeof e.player.config.poster=="string"&&(e.config.poster=e.player.config.poster)}},{key:"afterCreate",value:function(){var e=this;this.on(wi,function(){e.isEndedShow&&S.removeClass(e.root,"hide")}),this.config.hideCanplay?(this.once(ft,function(){e.onTimeUpdate()}),this.on(Bt,function(){S.removeClass(e.root,"hide"),S.addClass(e.root,"xg-showplay"),e.once(ft,function(){e.onTimeUpdate()})})):this.on(bt,function(){S.addClass(e.root,"hide")})}},{key:"setConfig",value:function(e){var r=this;Object.keys(e).forEach(function(a){r.config[a]=e[a]});var n=this.config.poster;this.update(n)}},{key:"onTimeUpdate",value:function(){var e=this;this.player.currentTime?S.removeClass(this.root,"xg-showplay"):this.once(ft,function(){e.onTimeUpdate()})}},{key:"update",value:function(e){e&&(this.config.poster=e,this.root.style.backgroundImage="url(".concat(e,")"))}},{key:"getBgSize",value:function(e){var r="";switch(e){case"cover":r="cover";break;case"contain":r="contain";break;case"fixHeight":r="auto 100%";break;default:r=""}return r?"background-size: ".concat(r,";"):""}},{key:"render",value:function(){var e=this.config,r=e.poster,n=e.hideCanplay,a=e.fillMode,u=e.notHidden,l=this.getBgSize(a),c=r?"background-image:url(".concat(r,");").concat(l):l,d=u?"xg-not-hidden":n?"xg-showplay":"";return' `)}}],[{key:"pluginName",get:function(){return"poster"}},{key:"defaultConfig",get:function(){return{isEndedShow:!0,hideCanplay:!1,notHidden:!1,poster:"",fillMode:"fixWidth"}}}]),i}(Le);function gs(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}function ys(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}var Mt={};function Kl(s,o){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{start:null,end:null};return Mt[s]&&window.clearTimeout(Mt[s].id),Mt[s]={},i.start&&i.start(),Mt[s].id=window.setTimeout(function(){i.end&&i.end(),window.clearTimeout(Mt[s].id),delete Mt[s]},o),Mt[s].id}function qs(s){if(s){window.clearTimeout(s);return}Object.keys(Mt).map(function(o){window.clearTimeout(Mt[o].id),delete Mt[o]})}var Ol=function(s){ie(i,s);var o=re(i);function i(t){var e;return $(this,i),e=o.call(this,t),V(W(e),"onPlayerReset",function(){e.autoPlayStart=!1;var r=e.config.mode==="auto"?"auto-hide":"hide";e.setAttr("data-state","play"),S.removeClass(e.root,r),e.show()}),V(W(e),"onAutoplayStart",function(){if(!e.autoPlayStart){var r=e.config.mode==="auto"?"auto-hide":"hide";S.addClass(e.root,r),e.autoPlayStart=!0,e.toggleTo("play")}}),e.autoPlayStart=!1,e}return q(i,[{key:"afterCreate",value:function(){var e=this.playerConfig;this.initIcons(),this.listenEvents(),this.bindClickEvents(),e.autoplay||this.show()}},{key:"listenEvents",value:function(){var e=this,r=this.player,n=this.playerConfig;this.once(ms,function(){n&&(n.lang&&n.lang==="en"?S.addClass(r.root,"lang-is-en"):n.lang==="jp"&&S.addClass(r.root,"lang-is-jp"))}),this.on(yi,this.onAutoplayStart),this.on(ps,function(){var a=e.config.mode==="auto"?"auto-hide":"hide";e.setAttr("data-state","play"),S.removeClass(e.root,a),e.show()}),this.on(bt,function(){e.toggleTo("play")}),this.on(Ji,function(){e.toggleTo("pause")}),this.on(Br,function(){e.onPlayerReset()})}},{key:"bindClickEvents",value:function(){var e=this;this.clickHandler=this.hook("startClick",this.switchPausePlay,{pre:function(n){n.cancelable&&n.preventDefault(),n.stopPropagation();var a=e.player.paused;e.emitUserAction(n,"switch_play_pause",{props:"paused",from:a,to:!a})}}),this.bind(["click","touchend"],this.clickHandler)}},{key:"registerIcons",value:function(){return{startPlay:{icon:gs,class:"xg-icon-play"},startPause:{icon:ys,class:"xg-icon-pause"}}}},{key:"initIcons",value:function(){var e=this.icons;this.appendChild("xg-start-inner",e.startPlay),this.appendChild("xg-start-inner",e.startPause)}},{key:"hide",value:function(){S.addClass(this.root,"hide")}},{key:"show",value:function(e){S.removeClass(this.root,"hide")}},{key:"focusHide",value:function(){S.addClass(this.root,"focus-hide")}},{key:"recover",value:function(){S.removeClass(this.root,"focus-hide")}},{key:"switchStatus",value:function(e){e?this.setAttr("data-state",this.player.paused?"pause":"play"):this.setAttr("data-state",this.player.paused?"play":"pause")}},{key:"animate",value:function(e){var r=this;this._animateId=Kl("pauseplay",400,{start:function(){S.addClass(r.root,"interact"),r.show(),r.switchStatus(!0)},end:function(){S.removeClass(r.root,"interact"),!e&&r.hide(),r._animateId=null}})}},{key:"endAnimate",value:function(){S.removeClass(this.root,"interact"),qs(this._animateId),this._animateId=null}},{key:"switchPausePlay",value:function(e){var r=this.player;if(e.cancelable&&e.preventDefault(),e.stopPropagation(),!(r.state `)}}],[{key:"pluginName",get:function(){return"start"}},{key:"defaultConfig",get:function(){return{isShowPause:!1,isShowEnd:!1,disableAnimate:!1,mode:"hide"}}}]),i}(Le),Al=function(s){ie(i,s);var o=re(i);function i(){return $(this,i),o.apply(this,arguments)}return q(i,[{key:"render",value:function(){var e=this.config.innerHtml,r=S.createDom("xg-enter","",{},"xgplayer-enter");if(e&&e instanceof window.HTMLElement)r.appendChild(e);else if(e&&typeof e=="string")r.innerHTML=e;else{for(var n="",a=1;a<=12;a++)n+='
');r.innerHTML='
'.concat(n,"
")}return r}}],[{key:"pluginName",get:function(){return"enter"}},{key:"defaultConfig",get:function(){return{innerHtml:"",logo:""}}}]),i}(Le);function li(s,o,i){try{return'
`).concat(s.i18n[o],`
`)}catch{return'
'}}var ea=function(s){ie(i,s);var o=re(i);function i(){return $(this,i),o.apply(this,arguments)}return q(i,[{key:"afterCreate",value:function(){this.getMini=this.getMini.bind(this),this.exitMini=this.exitMini.bind(this),this.bind("click",this.getMini)}},{key:"getMini",value:function(){this.config.onClick&&this.config.onClick()}},{key:"exitMini",value:function(){this.config.onClick&&this.config.onClick()}},{key:"destroy",value:function(){this.unbind(["click","touchend"],this.getMini)}},{key:"render",value:function(){var e="MINISCREEN";return`
').concat(this.i18n[e],`
`)}}],[{key:"pluginName",get:function(){return"miniscreenIcon"}},{key:"defaultConfig",get:function(){return{position:xe.CONTROLS_RIGHT,index:10}}}]),i}(Le);function ta(s){var o=parseFloat(s),i=s.indexOf("%")===-1&&!Number.isNaN(o);return i&&o}var bs=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],Xo=bs.length;function zl(){for(var s={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},o=0;o1&&arguments[1]!==void 0?arguments[1]:{};return $(this,i),e=o.call(this),e.isEnabled=!0,e.isDragging=!1,e.isDown=!1,e.position={},e.downPoint={},e.dragPoint={x:0,y:0},e.startPos={x:0,y:0},e._root=t instanceof Element?t:document.querySelector(t),e._handlerDom=r.handle instanceof Element?r.handle:document.querySelector(r.handle),!e._root||!e._handlerDom?cs(e):(e._bindStartEvent(),e)}return q(i,[{key:"_bindStartEvent",value:function(){var e=this;"ontouchstart"in window?this._startKey="touchstart":this._startKey="mousedown",this["on".concat(this._startKey)]=this["on".concat(this._startKey)].bind(this),this._handlerDom.addEventListener(this._startKey,this["on".concat(this._startKey)]),ra[this._startKey].map(function(r){e["on".concat(r)]=e["on".concat(r)].bind(e)})}},{key:"_unbindStartEvent",value:function(){this._handlerDom.removeEventListener(this._startKey,this["on".concat(this._startKey)])}},{key:"_bindPostStartEvents",value:function(e){var r=this;if(e){var n=ra[this._startKey];n.map(function(a){window.addEventListener(a,r["on".concat(a)])}),this._boundPointerEvents=n}}},{key:"_unbindPostStartEvents",value:function(){var e=this;this._boundPointerEvents&&(this._boundPointerEvents.map(function(r){window.removeEventListener(r,e["on".concat(r)])}),delete this._boundPointerEvents)}},{key:"enable",value:function(){this.isEnabled=!0}},{key:"disable",value:function(){this.isEnabled=!1,this.isDragging&&this.onUp()}},{key:"onDocUp",value:function(e){this.onUp()}},{key:"animate",value:function(){var e=this;this.isDragging&&(this.positionDrag(),window.requestAnimationFrame(function(){e.animate()}))}},{key:"positionDrag",value:function(){var e="translate3d(".concat(this.dragPoint.x,"px, ").concat(this.dragPoint.y,"px, 0)");this._root.style.transform=e,this._root.style.webKitTransform=e}},{key:"setLeftTop",value:function(){this._root.style.left=this.position.x+"px",this._root.style.top=this.position.y+"px"}},{key:"onmousedown",value:function(e){this.dragStart(e,e)}},{key:"onmousemove",value:function(e){this.dragMove(e,e)}},{key:"onmouseup",value:function(e){this.dragEnd(e,e)}},{key:"ontouchstart",value:function(e){var r=e.changedTouches[0];this.dragStart(e,r),this.touchIdentifier=r.pointerId!==void 0?r.pointerId:r.identifier,e.preventDefault()}},{key:"ontouchmove",value:function(e){var r=fn(e.changedTouches,this.touchIdentifier);r&&this.dragMove(e,r)}},{key:"ontouchend",value:function(e){var r=fn(e.changedTouches,this.touchIdentifier);r&&this.dragEnd(e,r),e.preventDefault()}},{key:"ontouchcancel",value:function(e){var r=fn(e.changedTouches,this.touchIdentifier);r&&this.dragCancel(e,r)}},{key:"dragStart",value:function(e,r){if(!(!this._root||this.isDown||!this.isEnabled)){this.downPoint=r,this.dragPoint.x=0,this.dragPoint.y=0,this._getPosition();var n=ia(this._root);this.startPos.x=this.position.x,this.startPos.y=this.position.y,this.startPos.maxY=window.innerHeight-n.height,this.startPos.maxX=window.innerWidth-n.width,this.setLeftTop(),this.isDown=!0,this._bindPostStartEvents(e)}}},{key:"dragRealStart",value:function(e,r){this.isDragging=!0,this.animate(),this.emit(mn.START,this.startPos)}},{key:"dragEnd",value:function(e,r){this._root&&(this._unbindPostStartEvents(),this.isDragging&&(this._root.style.transform="",this.setLeftTop(),this.emit(mn.ENDED)),this.presetInfo())}},{key:"_dragPointerMove",value:function(e,r){var n={x:r.pageX-this.downPoint.pageX,y:r.pageY-this.downPoint.pageY};return!this.isDragging&&this.hasDragStarted(n)&&this.dragRealStart(e,r),n}},{key:"dragMove",value:function(e,r){if(e=e||window.event,!!this.isDown){var n=this.startPos,a=n.x,u=n.y,l=this._dragPointerMove(e,r),c=l.x,d=l.y;c=this.checkContain("x",c,a),d=this.checkContain("y",d,u),this.position.x=a+c,this.position.y=u+d,this.dragPoint.x=c,this.dragPoint.y=d,this.emit(mn.MOVE,this.position)}}},{key:"dragCancel",value:function(e,r){this.dragEnd(e,r)}},{key:"presetInfo",value:function(){this.isDragging=!1,this.startPos={x:0,y:0},this.dragPoint={x:0,y:0},this.isDown=!1}},{key:"destroy",value:function(){this._unbindStartEvent(),this._unbindPostStartEvents(),this.isDragging&&this.dragEnd(),this.removeAllListeners(),this._handlerDom=null}},{key:"hasDragStarted",value:function(e){return Math.abs(e.x)>3||Math.abs(e.y)>3}},{key:"checkContain",value:function(e,r,n){return r+n<0?0-n:e==="x"&&r+n>this.startPos.maxX?this.startPos.maxX-n:e==="y"&&r+n>this.startPos.maxY?this.startPos.maxY-n:r}},{key:"_getPosition",value:function(){var e=window.getComputedStyle(this._root),r=this._getPositionCoord(e.left,"width"),n=this._getPositionCoord(e.top,"height");this.position.x=Number.isNaN(r)?0:r,this.position.y=Number.isNaN(n)?0:n,this._addTransformPosition(e)}},{key:"_addTransformPosition",value:function(e){var r=e.transform;if(r.indexOf("matrix")===0){var n=r.split(","),a=r.indexOf("matrix3d")===0?12:4,u=parseInt(n[a],10),l=parseInt(n[a+1],10);this.position.x+=u,this.position.y+=l}}},{key:"_getPositionCoord",value:function(e,r){if(e.indexOf("%")!==-1){var n=ia(this._root.parentNode);return n?parseFloat(e)/100*n[r]:0}return parseInt(e,10)}}]),i}(at),jl=function(s){ie(i,s);var o=re(i);function i(t){var e;$(this,i),e=o.call(this,t),V(W(e),"onCancelClick",function(a){e.exitMini(),e.isClose=!0}),V(W(e),"onCenterClick",function(a){var u=W(e),l=u.player;l.paused?l.play():l.pause()}),V(W(e),"onScroll",function(a){if(!(!window.scrollY&&window.scrollY!==0||Math.abs(window.scrollY-e.pos.scrollY)<50)){var u=parseInt(S.getCss(e.player.root,"height"));u+=e.config.scrollTop,e.pos.scrollY=window.scrollY,window.scrollY>u+5?!e.isMini&&!e.isClose&&e.getMini():window.scrollY<=u&&(e.isMini&&e.exitMini(),e.isClose=!1)}}),e.isMini=!1,e.isClose=!1;var r=W(e),n=r.config;return e.pos={left:n.left<0?window.innerWidth-n.width-20:n.left,top:n.top<0?window.innerHeight-n.height-20:n.top,height:e.config.height,width:e.config.width,scrollY:window.scrollY||0},e.lastStyle=null,e}return q(i,[{key:"beforeCreate",value:function(e){typeof e.player.config.mini=="boolean"&&(e.config.isShowIcon=e.player.config.mini)}},{key:"afterCreate",value:function(){var e=this;this.initIcons(),this.on(Ji,function(){e.setAttr("data-state","pause")}),this.on(bt,function(){e.setAttr("data-state","play")})}},{key:"onPluginsReady",value:function(){var e=this,r=this.player,n=this.config;if(!n.disable){if(this.config.isShowIcon){var a={config:{onClick:function(){e.getMini()}}};r.controls.registerPlugin(ea,a,ea.pluginName)}var u=S.checkTouchSupport()?"touchend":"click";this.bind(".mini-cancel-btn",u,this.onCancelClick),this.bind(".play-icon",u,this.onCenterClick),this.config.disableDrag||(this._draggabilly=new Jl(this.player.root,{handle:this.root})),this.config.isScrollSwitch&&window.addEventListener("scroll",this.onScroll)}}},{key:"registerIcons",value:function(){return{play:{icon:gs,class:"xg-icon-play"},pause:{icon:ys,class:"xg-icon-pause"}}}},{key:"initIcons",value:function(){var e=this.icons;this.appendChild(".play-icon",e.play),this.appendChild(".play-icon",e.pause)}},{key:"getMini",value:function(){var e=this;if(!this.isMini){var r=this.player,n=this.playerConfig,a=this.config.target||this.player.root;this.lastStyle={},S.addClass(r.root,"xgplayer-mini"),["width","height","top","left"].map(function(u){e.lastStyle[u]=a.style[u],a.style[u]="".concat(e.pos[u],"px")}),n.fluid&&(a.style["padding-top"]=""),this.emit(Gr,!0),r.isMini=this.isMini=!0}}},{key:"exitMini",value:function(){var e=this;if(!this.isMini)return!1;var r=this.player,n=this.playerConfig,a=this.config.target||this.player.root;S.removeClass(r.root,"xgplayer-mini"),this.lastStyle&&Object.keys(this.lastStyle).map(function(u){a.style[u]=e.lastStyle[u]}),this.lastStyle=null,n.fluid&&(r.root.style.width="100%",r.root.style.height="0",r.root.style["padding-top"]="".concat(n.height*100/n.width,"%")),this.emit(Gr,!1),this.isMini=r.isMini=!1}},{key:"destroy",value:function(){window.removeEventListener("scroll",this.onScroll);var e=S.checkTouchSupport()?"touchend":"click";this.unbind(".mini-cancel-btn",e,this.onCancelClick),this.unbind(".play-icon",e,this.onCenterClick),this._draggabilly&&this._draggabilly.destroy(),this._draggabilly=null,this.exitMini()}},{key:"render",value:function(){if(!this.config.disable)return` `.concat(li(this,"MINI_DRAG",this.playerConfig.isHideTips),`
`)}}],[{key:"pluginName",get:function(){return"miniscreen"}},{key:"defaultConfig",get:function(){return{index:10,disable:!1,width:320,height:180,left:-1,top:-1,isShowIcon:!1,isScrollSwitch:!1,scrollTop:0,disableDrag:!1}}}]),i}(Le),gr={mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mousemove:"onMouseMove"},pn=["videoClick","videoDbClick"],vn=function(s){ie(i,s);var o=re(i);function i(){var t;$(this,i);for(var e=arguments.length,r=new Array(e),n=0;n0&&r.replay():r.paused?r.play():r.pause()}},{key:"onContextmenu",value:function(e){e=e||window.event,e.preventDefault&&e.preventDefault(),e.stopPropagation?e.stopPropagation():(e.returnValue=!1,e.cancelBubble=!0)}},{key:"destroy",value:function(){var e=this,r=this.player,n=r.video,a=r.root;this.clickTimer&&clearTimeout(this.clickTimer),a.removeEventListener("click",this.onVideoClick,!1),a.removeEventListener("dblclick",this.onVideoDblClick,!1),n.removeEventListener("contextmenu",this.onContextmenu,!1),Object.keys(gr).map(function(u){a.removeEventListener(u,e[gr[u]],!1)})}}],[{key:"pluginName",get:function(){return"pc"}},{key:"defaultConfig",get:function(){return{}}}]),i}(Ue),ni={PRESS:"press",PRESS_END:"pressend",DOUBlE_CLICK:"doubleclick",CLICK:"click",TOUCH_MOVE:"touchmove",TOUCH_START:"touchstart",TOUCH_END:"touchend"},Ql={start:"touchstart",end:"touchend",move:"touchmove",cancel:"touchcancel"},$l={start:"mousedown",end:"mouseup",move:"mousemove",cancel:"mouseleave"};function na(s){return s&&s.length>0?s[s.length-1]:null}function ql(){return{pressDelay:600,dbClickDelay:200,disablePress:!1,disableDbClick:!1,miniStep:2,needPreventDefault:!0}}var ec=function(){function s(o){var i=this,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{eventType:"touch"};$(this,s),V(this,"onTouchStart",function(e){var r=i._pos,n=i.root,a=na(e.touches);r.x=a?parseInt(a.pageX,10):e.pageX,r.y=a?parseInt(a.pageX,10):e.pageX,r.start=!0,i.__setPress(e),n.addEventListener(i.events.end,i.onTouchEnd),n.addEventListener(i.events.cancel,i.onTouchCancel),n.addEventListener(i.events.move,i.onTouchMove),i.trigger(ni.TOUCH_START,e)}),V(this,"onTouchCancel",function(e){i.onTouchEnd(e)}),V(this,"onTouchEnd",function(e){var r=i._pos,n=i.root;i.__clearPress(),n.removeEventListener(i.events.cancel,i.onTouchCancel),n.removeEventListener(i.events.end,i.onTouchEnd),n.removeEventListener(i.events.move,i.onTouchMove),e.moving=r.moving,e.press=r.press,r.press&&i.trigger(ni.PRESS_END,e),i.trigger(ni.TOUCH_END,e),!r.press&&!r.moving&&i.__setDb(e),r.press=!1,r.start=!1,r.moving=!1}),V(this,"onTouchMove",function(e){var r=i._pos,n=i.config,a=na(e.touches),u=a?parseInt(a.pageX,10):e.pageX,l=a?parseInt(a.pageY,10):e.pageX,c=u-r.x,d=l-r.y;Math.abs(d)=0&&this.__handlers[i].splice(r,1)}}},{key:"trigger",value:function(i,t){this.__handlers[i]&&this.__handlers[i].map(function(e){try{e(t)}catch(r){console.error("trigger>>:".concat(i),r)}})}},{key:"destroy",value:function(){var i=this,t={touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart"};Object.keys(t).forEach(function(e){i.root.removeEventListener(e,i[t[e]])})}}]),s}();function tc(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}var Wi={AUTO:"auto",SEEKING:"seeking",PLAYBACK:"playbackrate",LIGHT:""},gn=["videoClick","videoDbClick"],ic=function(s){ie(i,s);var o=re(i);function i(t){var e;return $(this,i),e=o.call(this,t),V(W(e),"onTouchStart",function(r){var n=W(e),a=n.player,u=n.config,l=n.pos,c=n.playerConfig,d=e.getTouche(r);if(d&&!u.disableGesture&&e.duration>0&&!a.ended){l.isStart=!0,e.timer&&clearTimeout(e.timer),S.checkIsFunction(c.disableSwipeHandler)&&c.disableSwipeHandler(),e.find(".xg-dur").innerHTML=S.format(e.duration);var h=e.root.getBoundingClientRect();a.rotateDeg===90?(l.top=h.left,l.left=h.top,l.width=h.height,l.height=h.width):(l.top=h.top,l.left=h.left,l.width=h.width,l.height=h.height);var f=parseInt(d.pageX-l.left,10),m=parseInt(d.pageY-l.top,10);l.x=a.rotateDeg===90?m:f,l.y=a.rotateDeg===90?f:m,l.scopeL=u.scopeL*l.width,l.scopeR=(1-u.scopeR)*l.width,l.scopeM1=l.width*(1-u.scopeM)/2,l.scopeM2=l.width-l.scopeM1}}),V(W(e),"onTouchMove",function(r){var n=e.getTouche(r),a=W(e),u=a.pos,l=a.config,c=a.player;if(!(!n||l.disableGesture||!e.duration||!u.isStart)){var d=l.miniMoveStep,h=l.hideControlsActive,f=parseInt(n.pageX-u.left,10),m=parseInt(n.pageY-u.top,10),g=c.rotateDeg===90?m:f,y=c.rotateDeg===90?f:m;if(Math.abs(g-u.x)>d||Math.abs(y-u.y)>d){var L=g-u.x,k=y-u.y,_=u.scope;if(_===-1&&(_=e.checkScope(g,y,L,k,u),_===0&&(h?c.blur():c.focus({autoHide:!1}),!u.time&&(u.time=parseInt(c.currentTime*1e3,10)+e.timeOffset*1e3)),u.scope=_),_===-1||_>0&&!l.gestureY||_===0&&!l.gestureX)return;e.executeMove(L,k,_,u.width,u.height),u.x=g,u.y=y}}}),V(W(e),"onTouchEnd",function(r){var n=W(e),a=n.player,u=n.pos,l=n.playerConfig;if(setTimeout(function(){a.getPlugin("progress")&&a.getPlugin("progress").resetSeekState()},10),!!u.isStart){u.scope>-1&&r.cancelable&&r.preventDefault();var c=e.config,d=c.disableGesture,h=c.gestureX;!d&&h?e.endLastMove(u.scope):u.time=0,u.scope=-1,e.resetPos(),S.checkIsFunction(l.enableSwipeHandler)&&l.enableSwipeHandler(),e.changeAction(Wi.AUTO)}}),V(W(e),"onRootTouchMove",function(r){e.config.disableGesture||!e.config.gestureX||e.checkIsRootTarget(r)&&(r.stopPropagation(),e.pos.isStart?e.onTouchMove(r):e.onTouchStart(r))}),V(W(e),"onRootTouchEnd",function(r){e.pos.scope>-1&&e.onTouchEnd(r)}),e.pos={isStart:!1,x:0,y:0,time:0,volume:0,rate:1,light:0,width:0,height:0,scopeL:0,scopeR:0,scopeM1:0,scopeM2:0,scope:-1},e.timer=null,e}return q(i,[{key:"duration",get:function(){return this.playerConfig.customDuration||this.player.duration}},{key:"timeOffset",get:function(){return this.playerConfig.timeOffset||0}},{key:"registerIcons",value:function(){return{seekTipIcon:{icon:tc,class:"xg-seek-pre"}}}},{key:"afterCreate",value:function(){var e=this;gn.map(function(h){e.__hooks[h]=null});var r=this.playerConfig,n=this.config,a=this.player;r.closeVideoDblclick===!0&&(n.closedbClick=!0),this.resetPos(),S.isUndefined(r.disableGesture)||(n.disableGesture=!!r.disableGesture),this.appendChild(".xg-seek-icon",this.icons.seekTipIcon),this.xgMask=S.createDom("xg-mask","",{},"xgmask"),a.root.appendChild(this.xgMask),this.initCustomStyle(),this.registerThumbnail();var u=this.domEventType==="mouse"?"mouse":"touch";this.touch=new ec(this.root,{eventType:u,needPreventDefault:!this.config.disableGesture}),this.root.addEventListener("contextmenu",function(h){h.preventDefault()}),a.root.addEventListener("touchmove",this.onRootTouchMove,!0),a.root.addEventListener("touchend",this.onRootTouchEnd,!0),a.root.addEventListener("touchcancel",this.onRootTouchEnd,!0);var l=this.player.controls;l&&l.center&&(l.center.addEventListener("touchmove",this.onRootTouchMove,!0),l.center.addEventListener("touchend",this.onRootTouchEnd,!0),l.center.addEventListener("touchcancel",this.onRootTouchEnd,!0)),this.on($t,function(){var h=e.player,f=e.config;h.duration>0&&h.duration*1e30&&(e.pos.time=0)});var c={touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",press:"onPress",pressend:"onPressEnd",click:"onClick",doubleclick:"onDbClick"};if(Object.keys(c).map(function(h){e.touch.on(h,function(f){e[c[h]](f)})}),!n.disableActive){var d=a.plugins.progress;d&&(d.addCallBack("dragmove",function(h){e.activeSeekNote(h.currentTime,h.forward)}),["dragend","click"].forEach(function(h){d.addCallBack(h,function(){e.changeAction(Wi.AUTO)})}))}}},{key:"registerThumbnail",value:function(){var e=this.player,r=e.plugins.thumbnail;if(r&&r.usable){this.thumbnail=r.createThumbnail(null,"mobile-thumbnail");var n=this.find(".time-preview");n.insertBefore(this.thumbnail,n.children[0])}}},{key:"initCustomStyle",value:function(){var e=this.playerConfig||{},r=e.commonStyle,n=r.playedColor,a=r.progressColor,u=r.timePreviewStyle,l=r.curTimeColor,c=r.durationColor;if(n&&(this.find(".xg-curbar").style.backgroundColor=n),a&&(this.find(".xg-bar").style.backgroundColor=a),u){var d=this.find(".time-preview");Object.keys(u).forEach(function(m){d.style[m]=u[m]})}var h=l||n,f=c;h&&(this.find(".xg-cur").style.color=h),f&&(this.find(".xg-dur").style.color=f),this.config.disableTimeProgress&&S.addClass(this.find(".xg-timebar"),"hide")}},{key:"resetPos",value:function(){var e=this;this.pos?(this.pos.isStart=!1,this.pos.scope=-1,["x","y","width","height","scopeL","scopeR","scopeM1","scopeM2"].map(function(r){e.pos[r]=0})):this.pos={isStart:!1,x:0,y:0,volume:0,rate:1,light:0,width:0,height:0,scopeL:0,scopeR:0,scopeM1:0,scopeM2:0,scope:-1,time:0}}},{key:"changeAction",value:function(e){var r=this.player,n=this.root;n.setAttribute("data-xg-action",e);var a=r.plugins.start;a&&a.recover()}},{key:"getTouche",value:function(e){var r=this.player.rotateDeg,n=e.touches&&e.touches.length>0?e.touches[e.touches.length-1]:e;return r===0?{pageX:n.pageX,pageY:n.pageY}:{pageX:n.pageX,pageY:n.pageY}}},{key:"checkScope",value:function(e,r,n,a,u){var l=u.width,c=-1;if(e<0||e>l)return c;var d=Math.abs(a===0?n:n/a);return Math.abs(n)>0&&d>=1.73&&e>u.scopeM1&&eu.scopeR?2:3),c}},{key:"executeMove",value:function(e,r,n,a,u){switch(n){case 0:this.updateTime(e/a*this.config.scopeM);break;case 1:this.updateBrightness(r/u);break;case 2:le.os.isIos||this.updateVolume(r/u);break}}},{key:"endLastMove",value:function(e){var r=this,n=this.pos,a=this.player,u=this.config,l=(n.time-this.timeOffset)/1e3;switch(e){case 0:a.seek(Number(l).toFixed(1)),u.hideControlsEnd?a.blur():a.focus(),this.timer=setTimeout(function(){r.pos.time=0},500);break}this.changeAction(Wi.AUTO)}},{key:"checkIsRootTarget",value:function(e){var r=this.player.plugins||{};return r.progress&&r.progress.root.contains(e.target)?!1:r.start&&r.start.root.contains(e.target)||r.controls&&r.controls.root.contains(e.target)}},{key:"sendUseAction",value:function(e){var r=this.player.paused;this.emitUserAction(e,"switch_play_pause",{prop:"paused",from:r,to:!r})}},{key:"clickHandler",value:function(e){var r=this.player,n=this.config,a=this.playerConfig;if(r.state=ye.RUNNING&&(this.sendUseAction(S.createEvent("dblclick")),this.switchPlayPause())}},{key:"onClick",value:function(e){var r=this,n=this.player;Vt(this,gn[0],function(a,u){r.clickHandler(u.e)},{e,paused:n.paused})}},{key:"onDbClick",value:function(e){var r=this,n=this.player;Vt(this,gn[1],function(a,u){r.dbClickHandler(u.e)},{e,paused:n.paused})}},{key:"onPress",value:function(e){var r=this.pos,n=this.config,a=this.player;n.disablePress||(r.rate=this.player.playbackRate,this.emitUserAction("press","change_rate",{prop:"playbackRate",from:a.playbackRate,to:n.pressRate}),a.playbackRate=n.pressRate,this.changeAction(Wi.PLAYBACK))}},{key:"onPressEnd",value:function(e){var r=this.pos,n=this.config,a=this.player;n.disablePress||(this.emitUserAction("pressend","change_rate",{prop:"playbackRate",from:a.playbackRate,to:r.rate}),a.playbackRate=r.rate,r.rate=1,this.changeAction(Wi.AUTO))}},{key:"updateTime",value:function(e){var r=this.player,n=this.config,a=this.player.duration;e=Number(e.toFixed(4));var u=parseInt(e*n.moveDuration,10)+this.timeOffset;u+=this.pos.time,u=u<0?0:u>a*1e3?a*1e3-200:u,r.getPlugin("time")&&r.getPlugin("time").updateTime(u/1e3),r.getPlugin("progress")&&r.getPlugin("progress").updatePercent(u/1e3/this.duration,!0),this.activeSeekNote(u/1e3,e>0),n.isTouchingSeek&&r.seek(Number((u-this.timeOffset)/1e3).toFixed(1)),this.pos.time=u}},{key:"updateVolume",value:function(e){this.player.rotateDeg&&(e=-e);var r=this.player,n=this.pos;if(e=parseInt(e*100,10),n.volume+=e,!(Math.abs(n.volume)<10)){var a=parseInt(r.volume*10,10)-parseInt(n.volume/10,10);a=a>10?10:a<1?0:a,r.volume=a/10,n.volume=0}}},{key:"updateBrightness",value:function(e){var r=this.pos,n=this.config,a=this.xgMask;if(n.darkness){this.player.rotateDeg&&(e=-e);var u=r.light+.8*e;u=u>n.maxDarkness?n.maxDarkness:u<0?0:u,a&&(a.style.backgroundColor="rgba(0,0,0,".concat(u,")")),r.light=u}}},{key:"activeSeekNote",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=this.player,a=this.config,u=!(this.duration!==1/0&&this.duration>0);if(!(!e||typeof e!="number"||u||a.disableActive)){e<0?e=0:e>n.duration&&(e=n.duration-.2),this.changeAction(Wi.SEEKING);var l=n.plugins.start;l&&l.focusHide(),this.find(".xg-dur").innerHTML=S.format(this.duration),this.find(".xg-cur").innerHTML=S.format(e),this.find(".xg-curbar").style.width="".concat(e/this.duration*100,"%"),r?S.removeClass(this.find(".xg-seek-show"),"xg-back"):S.addClass(this.find(".xg-seek-show"),"xg-back"),this.updateThumbnails(e)}}},{key:"updateThumbnails",value:function(e){var r=this.player,n=r.plugins.thumbnail;n&&n.usable&&this.thumbnail&&n.update(this.thumbnail,e,160,90)}},{key:"switchPlayPause",value:function(){var e=this.player;if(e.state
00:00 / 00:00
`).concat(this.config.pressRate,"X").concat(this.i18n.FORWARD,`
`)}}],[{key:"pluginName",get:function(){return"mobile"}},{key:"defaultConfig",get:function(){return{index:0,disableGesture:!1,gestureX:!0,gestureY:!0,gradient:"normal",isTouchingSeek:!1,miniMoveStep:5,miniYPer:5,scopeL:.25,scopeR:.25,scopeM:.9,pressRate:2,darkness:!0,maxDarkness:.8,disableActive:!1,disableTimeProgress:!1,hideControlsActive:!1,hideControlsEnd:!1,moveDuration:60*6*1e3,closedbClick:!1,disablePress:!0,disableSeekIcon:!1,focusVideoClick:!1}}}]),i}(Le);function rc(s){s.preventDefault(),s.returnValue=!1}function sa(s){var o=s.tagName;return!!(o==="INPUT"||o==="TEXTAREA"||s.isContentEditable)}var aa=function(s){ie(i,s);var o=re(i);function i(){var t;$(this,i);for(var e=arguments.length,r=new Array(e),n=0;n0&&a-u>r*.9)}},{key:"checkCode",value:function(e,r){var n=this,a=!1;return Object.keys(this.keyCodeMap).map(function(u){n.keyCodeMap[u]&&e===n.keyCodeMap[u].keyCode&&!n.keyCodeMap[u].disable&&(a=!r||r&&!n.keyCodeMap[u].noBodyTarget)}),a}},{key:"downVolume",value:function(e){var r=this.player;if(!(r.volume<=0)){var n=parseFloat((r.volume-.1).toFixed(1)),a={volume:{from:r.volume,to:n}};this.emitUserAction(e,"change_volume",{props:a}),n>=0?r.volume=n:r.volume=0}}},{key:"upVolume",value:function(e){var r=this.player;if(!(r.volume>=1)){var n=parseFloat((r.volume+.1).toFixed(1)),a={volume:{from:r.volume,to:n}};this.emitUserAction(e,"change_volume",{props:a}),n<=1?r.volume=n:r.volume=1}}},{key:"seek",value:function(e){var r=this.player,n=r.currentTime,a=r.offsetCurrentTime,u=r.duration,l=r.offsetDuration,c=r.timeSegments,d=a>-1?a:n,h=l||u,f=e.repeat&&this.seekStep>=4?parseInt(this.seekStep/2,10):this.seekStep;d+f<=h?d=d+f:d=h;var m=S.getCurrentTimeByOffset(d,c),g={currentTime:{from:n,to:m}};this.emitUserAction(e,"seek",{props:g}),this.player.currentTime=m}},{key:"seekBack",value:function(e){var r=this.player,n=r.currentTime,a=r.offsetCurrentTime,u=r.timeSegments,l=e.repeat?parseInt(this.seekStep/2,10):this.seekStep,c=a>-1?a:n,d=c-l;d<0&&(d=0),d=S.getCurrentTimeByOffset(d,u);var h={currentTime:{from:n,to:d}};this.emitUserAction(e,"seek",{props:h}),this.player.currentTime=d}},{key:"changePlaybackRate",value:function(e){var r=this._keyState,n=this.config,a=this.player;r.playbackRate===0&&(r.playbackRate=a.playbackRate,a.playbackRate=n.playbackRate)}},{key:"playPause",value:function(e){var r=this.player;r&&(this.emitUserAction(e,"switch_play_pause"),r.paused?r.play():r.pause())}},{key:"exitFullscreen",value:function(e){var r=this.player,n=r.fullscreen,a=r.cssfullscreen;n&&(this.emitUserAction("keyup","switch_fullscreen",{prop:"fullscreen",from:n,to:!n}),r.exitFullscreen()),a&&(this.emitUserAction("keyup","switch_css_fullscreen",{prop:"cssfullscreen",from:a,to:!a}),r.exitCssFullscreen())}},{key:"handleKeyDown",value:function(e){var r=this._keyState;if(e.repeat){r.isPress=!0;var n=Date.now();if(n-r.tt<200)return;r.tt=n}this.handleKeyCode(e.keyCode,e,r.isPress)}},{key:"handleKeyUp",value:function(e){var r=this._keyState;r.playbackRate>0&&(this.player.playbackRate=r.playbackRate,r.playbackRate=0),r.isKeyDown=!1,r.isPress=!1,r.tt=0}},{key:"handleKeyCode",value:function(e,r,n){for(var a=Object.keys(this.keyCodeMap),u=0;u `,"image/svg+xml").firstChild}var sc=function(s){ie(i,s);var o=re(i);function i(){return $(this,i),o.apply(this,arguments)}return q(i,[{key:"registerIcons",value:function(){return{loadingIcon:nc}}},{key:"afterCreate",value:function(){this.appendChild("xg-loading-inner",this.icons.loadingIcon)}},{key:"render",value:function(){return` `}}],[{key:"pluginName",get:function(){return"loading"}},{key:"defaultConfig",get:function(){return{position:xe.ROOT}}}]),i}(Le),ac=[{tag:"xg-cache",className:"xgplayer-progress-cache",styleKey:"cachedColor"},{tag:"xg-played",className:"xgplayer-progress-played",styleKey:"playedColor"}],oc=function(){function s(o){$(this,s),this.fragments=o.fragments||[],this.fragments.length===0&&this.fragments.push({percent:1}),this._callBack=o.actionCallback,this.fragConfig={fragFocusClass:o.fragFocusClass||"inner-focus-point",fragAutoFocus:!!o.fragAutoFocus,fragClass:o.fragClass||""},this.style=o.style||{playedColor:"",cachedColor:"",progressColor:""},this.duration=0,this.cachedIndex=0,this.playedIndex=0,this.focusIndex=-1}return q(s,[{key:"updateDuration",value:function(i){var t=this;this.duration=i;var e=0,r=this.fragments;this.fragments=r.map(function(n){return n.start=parseInt(e,10),n.end=parseInt(e+n.percent*t.duration,10),n.duration=parseInt(n.percent*t.duration,10),e+=n.percent*t.duration,n})}},{key:"updateProgress",value:function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"played",t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{newIndex:0,curIndex:0,millisecond:0},e=this.progressList,r=this.fragments;if(!(e.length<1)){var n=t.newIndex,a=t.curIndex,u=t.millisecond;n!==a&&e.map(function(d,h){hn&&(d[i].style.width=0)});var l=r[n],c=u===0?0:(u-l.start)/l.duration;e[n][i].style.width=c<0?0:"".concat(c*100,"%")}}},{key:"updateFocus",value:function(i){if(!(!this.fragConfig.fragAutoFocus||this.fragments.length<2)){if(!i){if(this.focusIndex>-1){this.unHightLight(this.focusIndex);var t={index:-1,preIndex:this.focusIndex,fragment:null};this._callBack&&this._callBack(t),this.focusIndex=-1}return}var e=this.findIndex(i.currentTime*1e3,this.focusIndex);if(e>=0&&e!==this.focusIndex){this.focusIndex>-1&&this.unHightLight(this.focusIndex),this.setHightLight(e);var r={index:e,preIndex:this.focusIndex,fragment:this.fragments[this.focusIndex]};this.focusIndex=e,this._callBack&&this._callBack(r)}}}},{key:"update",value:function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{cached:0,played:0},t=arguments.length>1?arguments[1]:void 0;if(!this.duration||parseInt(t*1e3,10)!==this.duration){if(!t&&t!==0)return;this.updateDuration(parseInt(t*1e3,10))}var e=this.playedIndex,r=this.cachedIndex;if(S.typeOf(i.played)!=="Undefined"){var n=this.findIndex(i.played*1e3,e);if(n<0)return;this.updateProgress("played",{newIndex:n,curIndex:e,millisecond:parseInt(i.played*1e3,10)}),this.playedIndex=n}if(S.typeOf(i.cached)!=="Undefined"){var a=this.findIndex(i.cached*1e3,r);if(a<0)return;this.updateProgress("cached",{newIndex:a,curIndex:r,millisecond:parseInt(i.cached*1e3,10)}),this.cachedIndex=a}}},{key:"findIndex",value:function(i,t){var e=this.fragments;if(!e||e.length===0)return-1;if(e.length===1)return 0;if(t>-1&&te[t].start&&ie[e.length-1].start)return e.length-1;for(var r=0;re[r].start&&i<=e[r].end){t=r;break}return t}},{key:"findHightLight",value:function(){for(var i=this.root.children,t=0;t=t.length?null:{dom:t[i],pos:t[i].getBoundingClientRect()}}},{key:"unHightLight",value:function(){for(var i=this.root.children,t=0;t0;)this.root.removeChild(e[0]);this.render()}}},{key:"render",value:function(){var i=this,t=this.style.progressColor;if(this.root||(this.root=S.createDom("xg-inners","",{},"progress-list")),this.fragments){var e=this.fragConfig,r=e.fragClass,n=e.fragFocusClass;this.progressList=this.fragments.map(function(a){var u=S.createDom("xg-inner","",{style:t?"background:".concat(t,"; flex: ").concat(a.percent):"flex: ".concat(a.percent)},"".concat(a.isFocus?n:""," xgplayer-progress-inner ").concat(r));return i.root.appendChild(u),ac.forEach(function(l){u.appendChild(S.createDom(l.tag,"",{style:l.styleKey?"background: ".concat(i.style[l.styleKey],"; width:0;"):"width:0;"},l.className))}),{cached:u.children[0],played:u.children[1]}})}return this.root}}]),s}(),oa={POINT:"inner-focus-point",HIGHLIGHT:"inner-focus-highlight"},uc=function(s){ie(i,s);var o=re(i);function i(t){var e;return $(this,i),e=o.call(this,t),V(W(e),"onMoveOnly",function(r,n){var a=W(e),u=a.pos,l=a.config,c=a.player,d=n;if(r){S.event(r);var h=S.getEventPos(r,c.zoom),f=c.rotateDeg===90?h.clientY:h.clientX;if(u.moving&&Math.abs(u.x-f)=0?r:n+this.timeOffset}},{key:"changeState",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.useable=e}},{key:"show",value:function(e){this.root&&(this.root.style.display="flex")}},{key:"_initInner",value:function(){var e=this,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};(!r||r.length===0)&&(r=[{percent:1}]);var a=Pe(Pe({fragments:r},n),{},{actionCallback:function(l){e.emitUserAction("fragment_focus","fragment_focus",l)}});this.innerList?this.innerList.reset(a):(this.innerList=new oc(a),this.outer.insertBefore(this.innerList.render(),this.outer.children[0]),["findHightLight","unHightLight","setHightLight","findFragment"].map(function(u){e[u]=e.innerList[u].bind(e.innerList)}))}},{key:"_updateInnerFocus",value:function(e){this.innerList&&this.innerList.updateFocus(e)}},{key:"afterCreate",value:function(){if(!(this.config.disable||this.playerConfig.isLive)){this.pos={x:0,y:0,moving:!1,isDown:!1,isEnter:!1,isLocked:!1},this.outer=this.find("xg-outer");var e=this.config,r=e.fragFocusClass,n=e.fragAutoFocus,a=e.fragClass;this._initInner(this.config.fragments,{fragFocusClass:r,fragAutoFocus:n,fragClass:a,style:this.playerConfig.commonStyle||{}}),le.device==="mobile"&&(this.config.isDraggingSeek=!1,this.isMobile=!0),this.progressBtn=this.find(".xgplayer-progress-btn"),this.listenEvents(),this.bindDomEvents(),this.initCustomStyle()}}},{key:"listenEvents",value:function(){var e=this;this.on($t,function(){e.onMouseLeave()}),this.on(ft,function(){e.onTimeupdate()}),this.on(zt,function(){e.onTimeupdate(),e.onCacheUpdate()}),this.on(lo,function(){e.onCacheUpdate()}),this.on(wi,function(){e.onCacheUpdate(!0),e.onTimeupdate(!0),e._state.now=0}),this.on(Ci,function(){e.onReset()}),this.on(ui,function(){e.onVideoResize()})}},{key:"setConfig",value:function(e){var r=this,n=null;Object.keys(e).forEach(function(a){r.config[a]=e[a],a==="fragments"&&(n=e[a])}),n&&this._initInner(n,e)}},{key:"initCustomStyle",value:function(){var e=this.playerConfig||{},r=e.commonStyle,n=r.sliderBtnStyle,a=this.progressBtn;n&&(typeof n=="string"?a.style.boxShadow=n:nt(n)==="object"&&Object.keys(n).map(function(u){a.style[u]=n[u]}))}},{key:"triggerCallbacks",value:function(e,r,n){this.__dragCallBacks.length>0&&this.__dragCallBacks.map(function(a){if(a&&a.handler&&a.type===e)try{a.handler(r,n)}catch(u){console.error("[XGPLAYER][triggerCallbacks] ".concat(a," error"),u)}})}},{key:"addCallBack",value:function(e,r){r&&typeof r=="function"&&this.__dragCallBacks.push({type:e,handler:r})}},{key:"removeCallBack",value:function(e,r){var n=this.__dragCallBacks,a=-1;n.map(function(u,l){u&&u.type===e&&u.handler===r&&(a=l)}),a>-1&&n.splice(a,1)}},{key:"unlock",value:function(){var e=this.player,r=this.pos;if(r.isEnter=!1,r.isLocked=!1,!e.isMini){if(this.unbind("mousemove",this.onMoveOnly),r.isDown){this.unbind("mouseleave",this.onMouseLeave);return}this.blur()}}},{key:"bindDomEvents",value:function(){var e=this.player.config;this._mouseDownHandlerHook=this.hook("dragstart",this._mouseDownHandler),this._mouseUpHandlerHook=this.hook("dragend",this._mouseUpHandler),this._mouseMoveHandlerHook=this.hook("drag",this._mouseMoveHandler),(this.domEventType==="touch"||this.domEventType==="compatible")&&this.root.addEventListener("touchstart",this.onMouseDown),(this.domEventType==="mouse"||this.domEventType==="compatible")&&(this.bind("mousedown",this.onMouseDown),e.isMobileSimulateMode!=="mobile"&&this.bind("mouseenter",this.onMouseEnter),this.bind("mouseover",this.onMouseOver),this.bind("mouseout",this.onMouseOut),this.player.root.addEventListener("click",this.onBodyClick,!0))}},{key:"focus",value:function(){this.player.controls.pauseAutoHide(),S.addClass(this.root,"active")}},{key:"blur",value:function(){this._disableBlur||(this.player.controls.recoverAutoHide(),S.removeClass(this.root,"active"))}},{key:"disableBlur",value:function(){this._disableBlur=!0}},{key:"enableBlur",value:function(){this._disableBlur=!1}},{key:"updateWidth",value:function(e,r,n,a){var u=this.config,l=this.player;if(!(u.isCloseClickSeek&&a===0)){var c=r=r>=l.duration?l.duration-u.endedDiff:Number(r).toFixed(1);this.updatePercent(n),this.updateTime(e),!(a===1&&(!u.isDraggingSeek||l.config.mediaType==="audio"))&&(this._state.now=c,this._state.direc=c>l.currentTime?0:1,l.seek(c))}}},{key:"computeTime",value:function(e,r){var n=this.player,a=this.root.getBoundingClientRect(),u=a.width,l=a.height,c=a.top,d=a.left,h,f,m=r;n.rotateDeg===90?(h=l,f=c):(h=u,f=d);var g=m-f;g=g>h?h:g<0?0:g;var y=g/h;y=y<0?0:y>1?1:y;var L=parseInt(y*this.offsetDuration*1e3,10)/1e3,k=S.getCurrentTimeByOffset(L,n.timeSegments);return{percent:y,currentTime:L,seekTime:k,offset:g,width:h,left:f,e}}},{key:"updateTime",value:function(e){var r=this.player,n=this.duration;e>n?e=n:e<0&&(e=0);var a=r.plugins.time;a&&a.updateTime(e)}},{key:"resetSeekState",value:function(){this.isProgressMoving=!1;var e=this.player.plugins.time;e&&e.resetActive()}},{key:"updatePercent",value:function(e,r){if(this.isProgressMoving=!0,!this.config.disable){e=e>1?1:e<0?0:e,this.progressBtn.style.left="".concat(e*100,"%"),this.innerList.update({played:e*this.offsetDuration},this.offsetDuration);var n=this.player.plugins.miniprogress;n&&n.update({played:e*this.offsetDuration},this.offsetDuration)}}},{key:"onTimeupdate",value:function(e){var r=this.player,n=this._state,a=this.offsetDuration;if(!(r.isSeeking&&r.media.seeking||this.isProgressMoving||!r.hasStart)){if(n.now>-1){var u=parseInt(n.now*1e3,10)-parseInt(r.currentTime*1e3,10);if(n.direc===0&&u>300||n.direc===1&&u>-300){n.now=-1;return}else n.now=-1}var l=this.currentTime;l=S.adjustTimeByDuration(l,a,e),this.innerList.update({played:l},a),this.progressBtn.style.left="".concat(l/a*100,"%")}}},{key:"onCacheUpdate",value:function(e){var r=this.player,n=this.duration;if(r){var a=r.bufferedPoint.end;a=S.adjustTimeByDuration(a,n,e),this.innerList.update({cached:a},n)}}},{key:"onReset",value:function(){this.innerList.update({played:0,cached:0},0),this.progressBtn.style.left="0%"}},{key:"destroy",value:function(){var e=this.player;this.thumbnailPlugin=null,this.innerList.destroy(),this.innerList=null;var r=this.domEventType;(r==="touch"||r==="compatible")&&(this.root.removeEventListener("touchstart",this.onMouseDown),this.root.removeEventListener("touchmove",this.onMouseMove),this.root.removeEventListener("touchend",this.onMouseUp),this.root.removeEventListener("touchcancel",this.onMouseUp)),(r==="mouse"||r==="compatible")&&(this.unbind("mousedown",this.onMouseDown),this.unbind("mouseenter",this.onMouseEnter),this.unbind("mousemove",this.onMoveOnly),this.unbind("mouseleave",this.onMouseLeave),document.removeEventListener("mousemove",this.onMouseMove,!1),document.removeEventListener("mouseup",this.onMouseUp,!1),e.root.removeEventListener("click",this.onBodyClick,!0))}},{key:"render",value:function(){if(!(this.config.disable||this.playerConfig.isLive)){var e=this.player.controls?this.player.controls.config.mode:"",r=e==="bottom"?"xgplayer-progress-bottom":"";return` `)}}}],[{key:"pluginName",get:function(){return"progress"}},{key:"defaultConfig",get:function(){return{position:xe.CONTROLS_CENTER,index:0,disable:!1,isDraggingSeek:!0,closeMoveSeek:!1,isPauseMoving:!1,isCloseClickSeek:!1,fragments:[{percent:1}],fragFocusClass:oa.POINT,fragClass:"",fragAutoFocus:!1,miniMoveStep:5,miniStartStep:2,onMoveStart:function(){},onMoveEnd:function(){},endedDiff:.2}}},{key:"FRAGMENT_FOCUS_CLASS",get:function(){return oa}}]),i}(Le),Ei=function(s){ie(i,s);var o=re(i);function i(){var t;$(this,i);for(var e=arguments.length,r=new Array(e),n=0;n
`.concat(li(this,"PLAY_TIPS",this.playerConfig.isHideTips),` `)}}],[{key:"pluginName",get:function(){return"play"}},{key:"defaultConfig",get:function(){return{position:xe.CONTROLS_LEFT,index:0,disable:!1}}}]),i}(Ei);function cc(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}var dc=function(s){ie(i,s);var o=re(i);function i(){return $(this,i),o.apply(this,arguments)}return q(i,[{key:"afterCreate",value:function(){var e=this;this.initIcons(),this.onClick=function(r){r.preventDefault(),r.stopPropagation(),e.config.onClick(r)},this.bind(["click","touchend"],this.onClick)}},{key:"registerIcons",value:function(){return{screenBack:{icon:cc,class:"xg-fullscreen-back"}}}},{key:"initIcons",value:function(){var e=this.icons;this.appendChild(this.root,e.screenBack)}},{key:"show",value:function(){S.addClass(this.root,"show")}},{key:"hide",value:function(){S.removeClass(this.root,"show")}},{key:"render",value:function(){return` `}}],[{key:"pluginName",get:function(){return"topbackicon"}},{key:"defaultConfig",get:function(){return{position:xe.ROOT_TOP,index:0}}}]),i}(Le);function hc(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}function fc(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}var mc=function(s){ie(i,s);var o=re(i);function i(){var t;$(this,i);for(var e=arguments.length,r=new Array(e),n=0;n1&&this.lockScreen(n.lockOrientationType))}},{key:"animate",value:function(e){e?this.setAttr("data-state","full"):this.setAttr("data-state","normal"),this.topBackIcon&&(e?(this.topBackIcon.show(),this.hide()):(this.topBackIcon.hide(),this.show()))}},{key:"render",value:function(){if(!this.config.disable){var e="FULLSCREEN_TIPS";return`
`.concat(li(this,e,this.playerConfig.isHideTips),`
`)}}},{key:"lockScreen",value:function(e){try{screen.orientation.lock(e).catch(function(r){})}catch{}}},{key:"unlockScreen",value:function(){try{screen.orientation.unlock().catch(function(e){})}catch{}}}],[{key:"pluginName",get:function(){return"fullscreen"}},{key:"defaultConfig",get:function(){return{position:xe.CONTROLS_RIGHT,index:0,useCssFullscreen:!1,rotateFullscreen:!1,useScreenOrientation:!1,lockOrientationType:"landscape",switchCallback:null,target:null,disable:!1,needBackIcon:!1}}}]),i}(Ei),pc=function(s){ie(i,s);var o=re(i);function i(t){var e;return $(this,i),e=o.call(this,t),e.isActiving=!1,e}return q(i,[{key:"duration",get:function(){var e=this.player,r=e.offsetDuration,n=e.duration;return this.playerConfig.customDuration||r||n}},{key:"currentTime",get:function(){var e=this.player,r=e.offsetCurrentTime,n=e.currentTime;return r>=0?r:n}},{key:"timeOffset",get:function(){return this.playerConfig.timeOffset||0}},{key:"afterCreate",value:function(){var e=this.player.controls.config.mode;this.mode=e==="flex"?"flex":"normal",!this.config.disable&&(this.mode==="flex"&&(this.createCenterTime(),this.root.style.display="none"),this.durationDom=this.find(".time-duration"),this.timeDom=this.find(".time-current"),this.listenEvents())}},{key:"listenEvents",value:function(){var e=this;this.on([$t,zt,ft],function(r){r.eventName==="durationchange"&&(e.isActiving=!1),e.onTimeUpdate()}),this.on(wi,function(){e.onTimeUpdate(!0)}),this.on(Ci,function(){e.onReset()})}},{key:"show",value:function(e){if(this.mode==="flex"){this.centerCurDom&&(this.centerCurDom.style.display="block"),this.centerDurDom&&(this.centerDurDom.style.display="block");return}this.root.style.display="block"}},{key:"hide",value:function(){if(this.mode==="flex"){this.centerCurDom&&(this.centerCurDom.style.display="none"),this.centerDurDom&&(this.centerDurDom.style.display="none");return}this.root.style.display="none"}},{key:"onTimeUpdate",value:function(e){var r=this.player,n=this.config,a=this.duration;if(!(n.disable||this.isActiving||!r.hasStart)){var u=this.currentTime+this.timeOffset;u=S.adjustTimeByDuration(u,a,e),this.mode==="flex"?(this.centerCurDom.innerHTML=this.minWidthTime(S.format(u)),a!==1/0&&a>0&&(this.centerDurDom.innerHTML=S.format(a))):(this.timeDom.innerHTML=this.minWidthTime(S.format(u)),a!==1/0&&a>0&&(this.durationDom.innerHTML=S.format(a)))}}},{key:"onReset",value:function(){this.mode==="flex"?(this.centerCurDom.innerHTML=this.minWidthTime(S.format(0)),this.centerDurDom.innerHTML=S.format(0)):(this.timeDom.innerHTML=this.minWidthTime(S.format(0)),this.durationDom.innerHTML=S.format(0))}},{key:"createCenterTime",value:function(){var e=this.player;if(!(!e.controls||!e.controls.center)){var r=e.controls.center;this.centerCurDom=S.createDom("xg-icon","00:00",{},"xgplayer-time xg-time-left"),this.centerDurDom=S.createDom("xg-icon","00:00",{},"xgplayer-time xg-time-right"),r.children.length>0?r.insertBefore(this.centerCurDom,r.children[0]):r.appendChild(this.centerCurDom),r.appendChild(this.centerDurDom)}}},{key:"afterPlayerInit",value:function(){var e=this.config;if(this.duration===1/0||this.playerConfig.isLive?(S.hide(this.durationDom),S.hide(this.timeDom),S.hide(this.find(".time-separator")),S.show(this.find(".time-live-tag"))):S.hide(this.find(".time-live-tag")),e.hide){this.hide();return}this.show()}},{key:"changeLiveState",value:function(e){e?(S.hide(this.durationDom),S.hide(this.timeDom),S.hide(this.find(".time-separator")),S.show(this.find(".time-live-tag"))):(S.hide(this.find(".time-live-tag")),S.show(this.find(".time-separator")),S.show(this.durationDom),S.show(this.timeDom))}},{key:"updateTime",value:function(e){if(this.isActiving=!0,!(!e&&e!==0||e>this.duration)){if(this.mode==="flex"){this.centerCurDom.innerHTML=this.minWidthTime(S.format(e));return}this.timeDom.innerHTML=this.minWidthTime(S.format(e))}}},{key:"minWidthTime",value:function(e){return e.split(":").map(function(r){return''.concat(r,"")}).join(":")}},{key:"resetActive",value:function(){var e=this,r=this.player,n=function(){e.isActiving=!1};this.off(zt,n),r.isSeeking&&r.media.seeking?this.once(zt,n):this.isActiving=!1}},{key:"destroy",value:function(){var e=this.player.controls.center;this.centerCurDom&&e.removeChild(this.centerCurDom),this.centerCurDom=null,this.centerDurDom&&e.removeChild(this.centerDurDom),this.centerDurDom=null}},{key:"render",value:function(){if(!this.config.disable)return` 00:00 / 00:00 `.concat(this.i18n.LIVE_TIP,` `)}}],[{key:"pluginName",get:function(){return"time"}},{key:"defaultConfig",get:function(){return{position:xe.CONTROLS_LEFT,index:2,disable:!1}}}]),i}(Le),vc=function(s){ie(i,s);var o=re(i);function i(){var t;$(this,i);for(var e=arguments.length,r=new Array(e),n=0;n0&&(t.player.currentTime=t.curPos.start)}}),V(W(t),"_onTimeupdate",function(){var a=t.player,u=a.currentTime,l=a.timeSegments;if(t._checkIfEnabled(l)){var c=l.length;t.lastCurrentTime=u;var d=S.getIndexByTime(u,l);d!==t.curIndex&&t.changeIndex(d,l);var h=S.getOffsetCurrentTime(u,l,d);if(t.player.offsetCurrentTime=h,!!t.curPos){var f=t.curPos,m=f.start,g=f.end;ug&&d>=c-1&&t.player.pause()}}}),V(W(t),"_onSeeking",function(){var a=t.player,u=a.currentTime,l=a.timeSegments;if(t._checkIfEnabled(l))if(ul[l.length-1].end)t.player.currentTime=l[l.length-1].end;else{var c=S.getIndexByTime(u,l);if(c>=0){var d=t.getSeekTime(u,t.lastCurrentTime,c,l);d>=0&&(t.player.currentTime=d)}}}),V(W(t),"_onPlay",function(){var a=t.player,u=a.currentTime,l=a.timeSegments;t._checkIfEnabled(l)&&u>=l[l.length-1].end&&(t.player.currentTime=l[0].start)}),t}return q(i,[{key:"afterCreate",value:function(){this.curIndex=-1,this.curPos=null,this.lastCurrentTime=0,this.updateSegments(),this.on($t,this._onDurationChange),this.on(jt,this._onLoadedData),this.on(ft,this._onTimeupdate),this.on(gi,this._onSeeking),this.on(bt,this._onPlay)}},{key:"setConfig",value:function(e){var r=this;if(e){var n=Object.keys(e);n.length<1||(n.forEach(function(a){r.config[a]=e[a]}),this.updateSegments())}}},{key:"updateSegments",value:function(){var e=this.config,r=e.disable,n=e.segments,a=this.player;if(r||!n||n.length===0)a.timeSegments=[],a.offsetDuration=0,a.offsetCurrentTime=-1;else{var u=this.formatTimeSegments(n,a.duration);a.timeSegments=u,a.offsetDuration=u.length>0?u[u.length-1].duration:0}}},{key:"formatTimeSegments",value:function(e,r){var n=[];return e?(e.sort(function(a,u){return a.start-u.start}),e.forEach(function(a,u){var l={};if(l.start=a.start<0?0:a.start,l.end=r>0&&a.end>r?r:a.end,!(r>0&&l.start>r)){n.push(l);var c=l.end-l.start;if(u===0)l.offset=a.start,l.cTime=0,l.segDuration=c,l.duration=c;else{var d=n[u-1];l.offset=d.offset+(l.start-d.end),l.cTime=d.duration+d.cTime,l.segDuration=c,l.duration=d.duration+c}}}),n):[]}},{key:"getSeekTime",value:function(e,r,n,a){var u=-1,l=a[n],c=l.start,d=l.end;if(e>=c&&e<=d)return u;var h=e-r;if(h<0&&ec?r-c:0;return u=n-1>=0?a[n-1].end+h+f:0,u}return-1}},{key:"_checkIfEnabled",value:function(e){return!(!e||e.length<1)}},{key:"changeIndex",value:function(e,r){this.curIndex=e,e>=0&&r.length>0?this.curPos=r[e]:this.curPos=null}}],[{key:"pluginName",get:function(){return"TimeSegmentsControls"}},{key:"defaultConfig",get:function(){return{disable:!0,segments:[]}}}]),i}(Ue);function gc(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}function yc(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}function bc(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}var Sc=function(s){ie(i,s);var o=re(i);function i(){var t;$(this,i);for(var e=arguments.length,r=new Array(e),n=0;nd.barH||t.updateVolumePos(m,a)}}),V(W(t),"onBarMouseUp",function(a){S.event(a),document.removeEventListener("mouseup",t.onBarMouseUp);var u=W(t),l=u._d;l.isStart=!1,l.isMoving=!1}),V(W(t),"onMouseenter",function(a){t._d.isActive=!0,t.focus(),t.emit("icon_mouseenter",{pluginName:t.pluginName})}),V(W(t),"onMouseleave",function(a){t._d.isActive=!1,t.unFocus(100,!1,a),t.emit("icon_mouseleave",{pluginName:t.pluginName})}),V(W(t),"onVolumeChange",function(a){if(t.player){var u=t.player,l=u.muted,c=u.volume;t._d.isMoving||(t.find(".xgplayer-drag").style.height=l||c===0?"4px":"".concat(c*100,"%"),t.config.showValueLabel&&t.updateVolumeValue()),t.animate(l,c)}}),t}return q(i,[{key:"registerIcons",value:function(){return{volumeSmall:{icon:yc,class:"xg-volume-small"},volumeLarge:{icon:gc,class:"xg-volume"},volumeMuted:{icon:bc,class:"xg-volume-mute"}}}},{key:"afterCreate",value:function(){var e=this;if(this._timerId=null,this._d={isStart:!1,isMoving:!1,isActive:!1},!this.config.disable){this.initIcons();var r=this.playerConfig,n=r.commonStyle,a=r.volume;n.volumeColor&&(this.find(".xgplayer-drag").style.backgroundColor=n.volumeColor),this.changeMutedHandler=this.hook("mutedChange",function(u){e.changeMuted(u)},{pre:function(l){l.preventDefault(),l.stopPropagation()}}),this._onMouseenterHandler=this.hook("mouseenter",this.onMouseenter),this._onMouseleaveHandler=this.hook("mouseleave",this.onMouseleave),le.device!=="mobile"&&this.playerConfig.isMobileSimulateMode!=="mobile"&&(this.bind("mouseenter",this._onMouseenterHandler),this.bind(["blur","mouseleave"],this._onMouseleaveHandler),this.bind(".xgplayer-slider","mousedown",this.onBarMousedown),this.bind(".xgplayer-slider","mousemove",this.onBarMouseMove),this.bind(".xgplayer-slider","mouseup",this.onBarMouseUp)),this.bind(".xgplayer-icon",["touchend","click"],this.changeMutedHandler),this.on(oo,this.onVolumeChange),this.once(jt,this.onVolumeChange),S.typeOf(a)!=="Number"&&(this.player.volume=this.config.default),this.onVolumeChange()}}},{key:"updateVolumePos",value:function(e,r){var n=this.player,a=this.find(".xgplayer-drag"),u=this.find(".xgplayer-bar");if(!(!u||!a)){var l=parseInt(e/u.getBoundingClientRect().height*1e3,10);a.style.height="".concat(e,"px");var c=Math.max(Math.min(l/1e3,1),0),d={volume:{from:n.volume,to:c}};n.muted&&(d.muted={from:!0,to:!1}),this.emitUserAction(r,"change_volume",{muted:n.muted,volume:n.volume,props:d}),n.volume=Math.max(Math.min(l/1e3,1),0),n.muted&&(n.muted=!1),this.config.showValueLabel&&this.updateVolumeValue()}}},{key:"updateVolumeValue",value:function(){var e=this.player,r=e.volume,n=e.muted,a=this.find(".xgplayer-value-label"),u=Math.max(Math.min(r,1),0);a.innerText=n?0:Math.round(u*100)}},{key:"focus",value:function(){var e=this.player;e.focus({autoHide:!1}),this._timerId&&(S.clearTimeout(this,this._timerId),this._timerId=null),S.addClass(this.root,"slide-show")}},{key:"unFocus",value:function(){var e=this,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:100,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,a=arguments.length>2?arguments[2]:void 0,u=this._d,l=this.player;u.isActive||(this._timerId&&(S.clearTimeout(this,this._timerId),this._timerId=null),this._timerId=S.setTimeout(this,function(){u.isActive||(n?l.blur():l.focus(),S.removeClass(e.root,"slide-show"),u.isStart&&e.onBarMouseUp(a)),e._timerId=null},r))}},{key:"changeMuted",value:function(e){e&&e.stopPropagation();var r=this.player,n=this._d;n.isStart&&this.onBarMouseUp(e),this.emitUserAction(e,"change_muted",{muted:r.muted,volume:r.volume,props:{muted:{from:r.muted,to:!r.muted}}}),r.volume>0&&(r.muted=!r.muted),r.volume<.01&&(r.volume=this.config.miniVolume)}},{key:"animate",value:function(e,r){e||r===0?this.setAttr("data-state","mute"):r<.5&&this.icons.volumeSmall?this.setAttr("data-state","small"):this.setAttr("data-state","normal")}},{key:"initIcons",value:function(){var e=this.icons;this.appendChild(".xgplayer-icon",e.volumeSmall),this.appendChild(".xgplayer-icon",e.volumeLarge),this.appendChild(".xgplayer-icon",e.volumeMuted)}},{key:"destroy",value:function(){this._timerId&&(S.clearTimeout(this,this._timerId),this._timerId=null),this.unbind("mouseenter",this.onMouseenter),this.unbind(["blur","mouseleave"],this.onMouseleave),this.unbind(".xgplayer-slider","mousedown",this.onBarMousedown),this.unbind(".xgplayer-slider","mousemove",this.onBarMouseMove),this.unbind(".xgplayer-slider","mouseup",this.onBarMouseUp),document.removeEventListener("mouseup",this.onBarMouseUp),this.unbind(".xgplayer-icon",le.device==="mobile"?"touchend":"click",this.changeMutedHandler)}},{key:"render",value:function(){if(!this.config.disable){var e=this.config.default||this.player.volume,r=this.config.showValueLabel;return`
`.concat(r?'
'.concat(e*100,"
"):"",`
`)}}}],[{key:"pluginName",get:function(){return"volume"}},{key:"defaultConfig",get:function(){return{position:xe.CONTROLS_RIGHT,index:1,disable:!1,showValueLabel:!1,default:.6,miniVolume:.2}}}]),i}(Le);function Lc(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}var Zc=function(s){ie(i,s);var o=re(i);function i(t){var e;return $(this,i),e=o.call(this,t),e.rotateDeg=e.config.rotateDeg||0,e}return q(i,[{key:"afterCreate",value:function(){var e=this;if(!this.config.disable){ce(ae(i.prototype),"afterCreate",this).call(this),this.appendChild(".xgplayer-icon",this.icons.rotate),this.onBtnClick=this.onBtnClick.bind(this),this.bind(".xgplayer-icon",["click","touchend"],this.onBtnClick),this.on(ui,function(){e.rotateDeg&&e.config.innerRotate&&S.setTimeout(e,function(){e.updateRotateDeg(e.rotateDeg,e.config.innerRotate)},100)});var r=this.player.root;this.rootWidth=r.style.width||r.offsetWidth||r.clientWidth,this.rootHeight=r.style.height||r.offsetHeight||r.clientHeight,this.rotateDeg&&this.updateRotateDeg(this.rotateDeg,this.config.innerRotate)}}},{key:"destroy",value:function(){ce(ae(i.prototype),"destroy",this).call(this),this.unbind(".xgplayer-icon",["click","touchend"],this.onBtnClick)}},{key:"onBtnClick",value:function(e){e.preventDefault(),e.stopPropagation(),this.emitUserAction(e,"rotate"),this.rotate(this.config.clockwise,this.config.innerRotate,1)}},{key:"updateRotateDeg",value:function(e,r){if(e||(e=0),r){this.player.videoRotateDeg=e;return}var n=this.player,a=this.rootWidth,u=this.rootHeight,l=n.root,c=n.innerContainer,d=n.media,h=l.offsetWidth,f=c&&r?c.offsetHeight:l.offsetHeight,m=a,g=u,y=0,L=0;(e===.75||e===.25)&&(m="".concat(f,"px"),g="".concat(h,"px"),y=-(f-h)/2,L=-(h-f)/2);var k="translate(".concat(y,"px,").concat(L,"px) rotate(").concat(e,"turn)"),_={transformOrigin:"center center",transform:k,webKitTransform:k,height:g,width:m},w=r?d:l,Z=r?n.getPlugin("poster"):null;Object.keys(_).map(function(C){w.style[C]=_[C],Z&&Z.root&&(Z.root.style[C]=_[C])})}},{key:"rotate",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,a=this.player;this.rotateDeg||(this.rotateDeg=0);var u=e?1:-1;this.rotateDeg=(this.rotateDeg+1+u*.25*n)%1,this.updateRotateDeg(this.rotateDeg,r),a.emit(vo,this.rotateDeg*360)}},{key:"registerIcons",value:function(){return{rotate:Lc}}},{key:"render",value:function(){if(!this.config.disable)return`
`.concat(li(this,"ROTATE_TIPS",this.playerConfig.isHideTips),`
`)}}],[{key:"pluginName",get:function(){return"rotate"}},{key:"defaultConfig",get:function(){return{position:xe.CONTROLS_RIGHT,index:6,innerRotate:!0,clockwise:!1,rotateDeg:0,disable:!1}}}]),i}(Ei);function kc(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}function Tc(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}var Mi={PIP:"picture-in-picture",INLINE:"inline",FULLSCREEN:"fullscreen"},wc=function(s){ie(i,s);var o=re(i);function i(){var t;$(this,i);for(var e=arguments.length,r=new Array(e),n=0;n
`.concat(li(this,"PIP",this.playerConfig.isHideTips),` `)}}],[{key:"pluginName",get:function(){return"pip"}},{key:"defaultConfig",get:function(){return{position:xe.CONTROLS_RIGHT,index:6,showIcon:!1,preferDocument:!1,width:void 0,height:void 0,docPiPNode:void 0,docPiPStyle:void 0}}},{key:"checkWebkitSetPresentationMode",value:function(e){return typeof e.webkitSetPresentationMode=="function"}}]),i}(Ei);function _c(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}var Cc=function(s){ie(i,s);var o=re(i);function i(t){var e;return $(this,i),e=o.call(this,t),V(W(e),"playNext",function(r){var n=W(e),a=n.player;r.preventDefault(),r.stopPropagation(),e.idx+1
`.concat(li(this,"PLAYNEXT_TIPS",this.playerConfig.isHideTips),` `)}}],[{key:"pluginName",get:function(){return"playNext"}},{key:"defaultConfig",get:function(){return{position:xe.CONTROLS_LEFT,index:1,url:null,urlList:[]}}}]),i}(Le),Go={exports:{}};(function(s,o){(function(i,t){s.exports=t()})(Pu,function(){return function i(t,e,r){var n=window,a="application/octet-stream",u=r||a,l=t,c=!e&&!r&&l,d=document.createElement("a"),h=function(R){return String(R)},f=n.Blob||n.MozBlob||n.WebKitBlob||h,m=e||"download",g,y;if(f=f.call?f.bind(n):Blob,String(this)==="true"&&(l=[l,u],u=l[0],l=l[1]),c&&c.length<2048&&(m=c.split("/").pop().split("?")[0],d.href=c,d.href.indexOf(c)!==-1)){var L=new XMLHttpRequest;return L.open("GET",c,!0),L.responseType="blob",L.onload=function(R){i(R.target.response,m,a)},setTimeout(function(){L.send()},0),L}if(/^data:([\w+-]+\/[\w+.-]+)?[,;]/.test(l))if(l.length>1024*1024*1.999&&f!==h)l=Z(l),u=l.type||a;else return navigator.msSaveBlob?navigator.msSaveBlob(Z(l),m):C(l);else if(/([\x80-\xff])/.test(l)){var k=0,_=new Uint8Array(l.length),w=_.length;for(k;k `,"image/svg+xml").firstChild}var Xc=function(s){ie(i,s);var o=re(i);function i(t){var e;return $(this,i),e=o.call(this,t),V(W(e),"download",function(r){if(!e.isLock){e.emitUserAction(r,"download");var n=e.playerConfig.url,a="";S.typeOf(n)==="String"?a=n:S.typeOf(n)==="Array"&&n.length>0&&(a=n[0].src);var u=e.getAbsoluteURL(a);xc(u),e.isLock=!0,e.timer=window.setTimeout(function(){e.isLock=!1,window.clearTimeout(e.timer),e.timer=null},300)}}),e.timer=null,e.isLock=!1,e}return q(i,[{key:"afterCreate",value:function(){ce(ae(i.prototype),"afterCreate",this).call(this),!this.config.disable&&(this.appendChild(".xgplayer-icon",this.icons.download),this._handler=this.hook("click",this.download,{pre:function(r){r.preventDefault(),r.stopPropagation()}}),this.bind(["click","touchend"],this._handler))}},{key:"registerIcons",value:function(){return{download:Rc}}},{key:"getAbsoluteURL",value:function(e){if(!e.match(/^https?:\/\//)){var r=document.createElement("div");r.innerHTML='x'),e=r.firstChild.href}return e}},{key:"destroy",value:function(){ce(ae(i.prototype),"destroy",this).call(this),this.unbind(["click","touchend"],this.download),window.clearTimeout(this.timer),this.timer=null}},{key:"render",value:function(){if(!this.config.disable)return`
`.concat(li(this,"DOWNLOAD_TIPS",this.playerConfig.isHideTips),`
`)}}],[{key:"pluginName",get:function(){return"download"}},{key:"defaultConfig",get:function(){return{position:xe.CONTROLS_RIGHT,index:3,disable:!0}}}]),i}(Ei),Gc=function(s){ie(i,s);var o=re(i);function i(){return $(this,i),o.apply(this,arguments)}return q(i,[{key:"beforeCreate",value:function(e){typeof e.player.config.screenShot=="boolean"&&(e.config.disable=!e.player.config.screenShot)}},{key:"afterCreate",value:function(){ce(ae(i.prototype),"afterCreate",this).call(this),this.appendChild(".xgplayer-icon",this.icons.screenshotIcon);var e=this.config;this.initSize=function(r){e.fitVideo&&(e.width=r.vWidth,e.height=r.vHeight)},this.once(ui,this.initSize)}},{key:"onPluginsReady",value:function(){this.show(),this.onClickBtn=this.onClickBtn.bind(this),this.bind(["click","touchend"],this.onClickBtn)}},{key:"saveScreenShot",value:function(e,r){var n=document.createElement("a");n.href=e,n.download=r;var a;try{typeof MouseEvent<"u"?a=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window}):(a=document.createEvent("MouseEvents"),a.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null))}catch(u){console.error("MouseEvent unsupported",u)}a&&n.dispatchEvent(a)}},{key:"createCanvas",value:function(e,r){var n=document.createElement("canvas"),a=n.getContext("2d");this.canvasCtx=a,this.canvas=n,n.width=e||this.config.width,n.height=r||this.config.height,a.imageSmoothingEnabled=!0,a.imageSmoothingEnabled&&(a.imageSmoothingQuality="high")}},{key:"onClickBtn",value:function(e){var r=this;e.preventDefault(),e.stopPropagation(),this.emitUserAction(e,"shot");var n=this.config;this.shot(n.width,n.height).then(function(a){r.emit(go,a),n.saveImg&&r.saveScreenShot(a,n.name+n.format)})}},{key:"shot",value:function(e,r){var n=this,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{quality:.92,type:"image/png"},u=this.config,l=this.player,c=a.quality||u.quality,d=a.type||u.type;return new Promise(function(h,f){var m=null,g;if(l.media.canvas)m=l.media.canvas;else{n.canvas?(n.canvas.width=e||u.width,n.canvas.height=r||u.height):n.createCanvas(e,r),m=n.canvas,g=n.canvasCtx;var y=l.media.videoWidth/l.media.videoHeight,L=m.width/m.height,k=0,_=0,w=l.media.videoWidth,Z=l.media.videoHeight,C,R,E,P;y>L?(E=m.width,P=m.width/y,C=0,R=Math.round((m.height-P)/2)):y===L?(E=m.width,P=m.height,C=0,R=0):y
`).concat(this.icons.screenshotIcon?"":'').concat(this.i18n[r],""),`
`)}}}],[{key:"pluginName",get:function(){return"screenShot"}},{key:"defaultConfig",get:function(){return{position:xe.CONTROLS_RIGHT,index:5,quality:.92,type:"image/png",format:".png",width:600,height:337,saveImg:!0,fitVideo:!0,disable:!1,name:"screenshot"}}}]),i}(Ei),Ic=function(){function s(o){$(this,s),this.config=o.config,this.parent=o.root,this.root=S.createDom("ul","",{},"xg-options-list xg-list-slide-scroll ".concat(this.config.className)),o.root.appendChild(this.root);var i=this.config.maxHeight;i&&this.setStyle({maxHeight:i}),this.onItemClick=this.onItemClick.bind(this),this.renderItemList();var t=this.config.domEventType==="touch"?"touchend":"click";this._delegates=Le.delegate.call(this,this.root,"li",t,this.onItemClick)}return q(s,[{key:"renderItemList",value:function(i){var t=this,e=this.config,r=this.root;i?e.data=i:i=e.data,e.style&&Object.keys(e.style).map(function(n){r.style[n]=e[n]}),i.length>0&&(this.attrKeys=Object.keys(i[0])),this.root.innerHTML="",i.map(function(n,a){var u=n.selected?"option-item selected":"option-item";n["data-index"]=a,t.root.appendChild(S.createDom("li","".concat(n.showText,""),n,u))})}},{key:"onItemClick",value:function(i){i.delegateTarget||(i.delegateTarget=i.target);var t=i.delegateTarget;if(t&&S.hasClass(t,"selected"))return!1;var e=typeof this.config.onItemClick=="function"?this.config.onItemClick:null,r=this.root.querySelector(".selected");S.addClass(t,"selected"),r&&S.removeClass(r,"selected"),e(i,{from:r?this.getAttrObj(r,this.attrKeys):null,to:this.getAttrObj(t,this.attrKeys)})}},{key:"getAttrObj",value:function(i,t){if(!i||!t)return{};var e={};t.map(function(n){e[n]=i.getAttribute(n)});var r=i.getAttribute("data-index");return r&&(e.index=Number(r)),e}},{key:"show",value:function(){S.removeClass(this.root,"hide"),S.addClass(this.root,"active")}},{key:"hide",value:function(){S.removeClass(this.root,"active"),S.addClass(this.root,"hide")}},{key:"setStyle",value:function(i){var t=this;Object.keys(i).forEach(function(e){t.root.style[e]=i[e]})}},{key:"destroy",value:function(){this._delegates&&(this._delegates.map(function(i){i.destroy&&i.destroy()}),this._delegates=null),this.root.innerHTML=null,this.parent.removeChild(this.root),this.root=null}}]),s}(),It={SIDE:"side",MIDDLE:"middle",DEFAULT:"default"},Pi={CLICK:"click",HOVER:"hover"};function Wc(s,o){return s===It.SIDE?o===xe.CONTROLS_LEFT?"xg-side-list xg-left-side":"xg-side-list xg-right-side":""}var hi=le.device==="mobile",Yr=function(s){ie(i,s);var o=re(i);function i(t){var e;return $(this,i),e=o.call(this,t),V(W(e),"onEnter",function(r){r.stopPropagation(),e.emit("icon_mouseenter",{pluginName:e.pluginName}),e.switchActiveState(r)}),V(W(e),"switchActiveState",function(r){r.stopPropagation();var n=e.config.toggleMode;n===Pi.CLICK?e.toggle(!e.isActive):e.toggle(!0)}),V(W(e),"onLeave",function(r){r.stopPropagation(),e.emit("icon_mouseleave",{pluginName:e.pluginName}),e.config.listType!==It.SIDE&&e.isActive&&e.toggle(!1)}),V(W(e),"onListEnter",function(r){e.enterType=2}),V(W(e),"onListLeave",function(r){e.enterType=0,e.isActive&&e.toggle(!1)}),e.isIcons=!1,e.isActive=!1,e.curValue=null,e.curIndex=0,e}return q(i,[{key:"updateLang",value:function(e){this.renderItemList(this.config.list,this.curIndex)}},{key:"afterCreate",value:function(){var e=this,r=this.config;this.initIcons(),hi=hi||this.domEventType==="touch",hi&&le.device==="mobile"&&r.listType===It.DEFAULT&&(r.listType=It.SIDE),r.hidePortrait&&S.addClass(this.root,"portrait"),this.on([ui,Ot],function(){e._resizeList()}),this.once(At,function(){r.list&&r.list.length>0&&(e.renderItemList(r.list),e.show())}),hi&&this.on(fs,function(){e.isActive&&(e.optionsList&&e.optionsList.hide(),e.isActive=!1)}),hi?(r.toggleMode=Pi.CLICK,this.activeEvent="touchend"):this.activeEvent=r.toggleMode===Pi.CLICK?"click":"mouseenter",r.toggleMode===Pi.CLICK?this.bind(this.activeEvent,this.switchActiveState):(this.bind(this.activeEvent,this.onEnter),this.bind("mouseleave",this.onLeave)),this.isIcons&&this.bind("click",this.onIconClick)}},{key:"initIcons",value:function(){var e=this,r=this.icons,n=Object.keys(r),a=!1;n.length>0&&(n.forEach(function(u){e.appendChild(".xgplayer-icon",r[u]),!a&&(a=r[u])}),this.isIcons=a),!a&&(this.appendChild(".xgplayer-icon",S.createDom("span","",{},"icon-text")),S.addClass(this.find(".xgplayer-icon"),"btn-text"))}},{key:"show",value:function(e){!this.config.list||this.config.list.length<2||S.addClass(this.root,"show")}},{key:"hide",value:function(){S.removeClass(this.root,"show")}},{key:"getTextByLang",value:function(e,r,n){if(e===void 0)return"";var a=this.config.list;!n&&(n=this.player.lang),r=!r||S.isUndefined(e[r])?"text":r,typeof e=="number"&&(e=a[e]);try{return nt(e[r])==="object"?e[r][n]||e[r].en:e[r]}catch(u){return console.warn(u),""}}},{key:"toggle",value:function(e){if(!(e===this.isActive||this.config.disable)){var r=this.player.controls,n=this.config.listType;e?(n===It.SIDE?r.blur():r.focus(),this.optionsList&&this.optionsList.show()):(n===It.SIDE?r.focus():r.focusAwhile(),this.optionsList&&this.optionsList.hide()),this.isActive=e}}},{key:"onItemClick",value:function(e,r){e.stopPropagation();var n=this.config,a=n.listType,u=n.list;this.curIndex=r.to.index,this.curItem=u[this.curIndex],this.changeCurrentText();var l=this.config.isItemClickHide;(l||hi||a===It.SIDE)&&this.toggle(!1)}},{key:"onIconClick",value:function(e){}},{key:"changeCurrentText",value:function(){if(!this.isIcons){var e=this.config.list,r=this.curIndex
`)}}],[{key:"pluginName",get:function(){return"optionsIcon"}},{key:"defaultConfig",get:function(){return{position:xe.CONTROLS_RIGHT,index:100,list:[],listType:"default",listStyle:{},hidePortrait:!0,isShowIcon:!1,isItemClickHide:!0,toggleMode:Pi.HOVER,heightLimit:!0}}}]),i}(Le),Mc=function(s){ie(i,s);var o=re(i);function i(t){var e;return $(this,i),e=o.call(this,t),e.curTime=0,e.isPaused=!0,e}return q(i,[{key:"beforeCreate",value:function(e){var r=e.config.list;Array.isArray(r)&&r.length>0&&(e.config.list=r.map(function(n){return!n.text&&n.name&&(n.text=n.name),n.text||(n.text=n.definition),n}))}},{key:"afterCreate",value:function(){var e=this;ce(ae(i.prototype),"afterCreate",this).call(this),this.on("resourceReady",function(r){e.changeDefinitionList(r)}),this.on(zr,function(r){e.renderItemList(e.config.list,r.to)}),this.player.definitionList.length<2&&this.hide()}},{key:"show",value:function(e){!this.config.list||this.config.list.length<2||S.addClass(this.root,"show")}},{key:"initDefinition",value:function(){var e=this.config,r=e.list,n=e.defaultDefinition;if(r.length>0){var a=null;r.map(function(u){u.definition===n&&(a=u)}),a||(a=r[0]),this.changeDefinition(a)}}},{key:"renderItemList",value:function(){var e=this,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.config.list||[],n=arguments.length>1?arguments[1]:void 0,a=n&&n.definition?n.definition:this.config.defaultDefinition;n&&r.forEach(function(c){c.selected=!1});var u=0,l=r.map(function(c,d){var h=Pe(Pe({},c),{},{showText:e.getTextByLang(c)||c.definition,selected:!1});return(c.selected||c.definition&&c.definition==a)&&(h.selected=!0,u=d),h});ce(ae(i.prototype),"renderItemList",this).call(this,l,u)}},{key:"changeDefinitionList",value:function(e){Array.isArray(e)&&(this.config.list=e.map(function(r){return!r.text&&r.name&&(r.text=r.name),r.text||(r.text=r.definition),r}),this.renderItemList(),this.config.list.length<2?this.hide():this.show())}},{key:"changeDefinition",value:function(e,r){this.player.changeDefinition(e,r)}},{key:"onItemClick",value:function(e,r){var n=this.player.definitionList;ce(ae(i.prototype),"onItemClick",this).apply(this,arguments),this.emitUserAction(e,"change_definition",{from:r.from,to:r.to});for(var a=0;a `,"image/svg+xml").firstChild}function Dc(){return new DOMParser().parseFromString(` `,"image/svg+xml").firstChild}var ua=function(s){ie(i,s);var o=re(i);function i(){return $(this,i),o.apply(this,arguments)}return q(i,[{key:"beforeCreate",value:function(e){typeof e.player.config.cssFullscreen=="boolean"&&(e.config.disable=!e.player.config.cssFullscreen)}},{key:"afterCreate",value:function(){var e=this;ce(ae(i.prototype),"afterCreate",this).call(this),!this.config.disable&&(this.config.target&&(this.playerConfig.fullscreenTarget=this.config.target),this.initIcons(),this.on(Xr,function(r){e.animate(r)}),this.btnClick=this.btnClick.bind(this),this.handleCssFullscreen=this.hook("cssFullscreen_change",this.btnClick,{pre:function(n){n.preventDefault(),n.stopPropagation()}}),this.bind(["click","touchend"],this.handleCssFullscreen))}},{key:"initIcons",value:function(){var e=this.icons,r=this.find(".xgplayer-icon");r.appendChild(e.cssFullscreen),r.appendChild(e.exitCssFullscreen)}},{key:"btnClick",value:function(e){e.preventDefault(),e.stopPropagation();var r=this.player.isCssfullScreen;this.emitUserAction(e,"switch_cssfullscreen",{cssfullscreen:r}),r?this.player.exitCssFullscreen():this.player.getCssFullscreen()}},{key:"animate",value:function(e){this.root&&(e?this.setAttr("data-state","full"):this.setAttr("data-state","normal"),this.switchTips(e))}},{key:"switchTips",value:function(e){var r=this.i18nKeys,n=this.find(".xg-tips");n&&this.changeLangTextKey(n,e?r.EXITCSSFULLSCREEN_TIPS:r.CSSFULLSCREEN_TIPS)}},{key:"registerIcons",value:function(){return{cssFullscreen:{icon:Vc,class:"xg-get-cssfull"},exitCssFullscreen:{icon:Dc,class:"xg-exit-cssfull"}}}},{key:"destroy",value:function(){ce(ae(i.prototype),"destroy",this).call(this),this.unbind(["click","touchend"],this.btnClick)}},{key:"render",value:function(){if(!this.config.disable)return`
`.concat(li(this,"CSSFULLSCREEN_TIPS",this.playerConfig.isHideTips),`
`)}}],[{key:"pluginName",get:function(){return"cssFullscreen"}},{key:"defaultConfig",get:function(){return{position:xe.CONTROLS_RIGHT,index:1,disable:!1,target:null}}}]),i}(Ei),Yc=function(s){ie(i,s);var o=re(i);function i(){return $(this,i),o.apply(this,arguments)}return q(i,[{key:"afterCreate",value:function(){var e=this;this.clickHandler=this.hook("errorRetry",this.errorRetry,{pre:function(n){n.preventDefault(),n.stopPropagation()}}),this.onError=this.hook("showError",this.handleError),this.bind(".xgplayer-error-refresh","click",this.clickHandler),this.on(_i,function(r){e.onError(r)})}},{key:"errorRetry",value:function(e){this.emitUserAction(e,"error_retry",{}),this.player.retry()}},{key:"handleError",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=this.player,n=e.errorType,a=r.errorNote?this.i18n[r.errorNote]:"";if(!a)switch(n){case"decoder":a=this.i18n.MEDIA_ERR_DECODE;break;case"network":a=this.i18n.MEDIA_ERR_NETWORK;break;default:a=this.i18n.MEDIA_ERR_SRC_NOT_SUPPORTED}this.find(".xgplayer-error-text").innerHTML=a,this.find(".xgplayer-error-tips").innerHTML="".concat(this.i18n.REFRESH_TIPS,'').concat(this.i18n.REFRESH,"")}},{key:"destroy",value:function(){this.unbind(".xgplayer-error-refresh","click",this.clickHandler)}},{key:"render",value:function(){return`
`}}],[{key:"pluginName",get:function(){return"error"}}]),i}(Le),Nc=function(s){ie(i,s);var o=re(i);function i(){return $(this,i),o.apply(this,arguments)}return q(i,[{key:"afterCreate",value:function(){var e=this;this.intervalId=0,this.customConfig=null,this.bind(".highlight",["click","touchend"],function(r){(e.config.onClick||e.customOnClick)&&(r.preventDefault(),r.stopPropagation(),e.customOnClick?e.customOnClick(r):e.config.onClick(r))}),this.player.showPrompt=function(){e.showPrompt.apply(e,arguments)},this.player.hidePrompt=function(){e.hide()}}},{key:"setStyle",value:function(e){var r=this;Object.keys(e).map(function(n){r.root.style[n]=e[n]})}},{key:"showPrompt",value:function(e){var r=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){};if(e){this.customOnClick=a;var u=this.config.interval;this.intervalId&&(clearTimeout(this.intervalId),this.intervalId=null),S.addClass(this.root,"show"),n.mode==="arrow"&&S.addClass(this.root,"arrow"),typeof e=="string"?this.find(".xgplayer-prompt-detail").innerHTML=e:this.find(".xgplayer-prompt-detail").innerHTML="".concat(e.text||"")+"".concat(e.highlight?''.concat(e.highlight,""):""),n.style&&this.setStyle(n.style);var l=typeof n.autoHide=="boolean"?n.autoHide:this.config.autoHide;if(l){var c=n.interval||u;this.intervalId=setTimeout(function(){r.hide()},c)}}}},{key:"hide",value:function(){S.removeClass(this.root,"show"),S.removeClass(this.root,"arrow"),this.root.removeAttribute("style"),this.customOnClick=null}},{key:"render",value:function(){return' `)}}],[{key:"pluginName",get:function(){return"prompt"}},{key:"defaultConfig",get:function(){return{interval:3e3,style:{},mode:"arrow",autoHide:!0,detail:{text:"",highlight:""},onClick:function(){}}}}]),i}(Le),la={time:0,text:"",id:1,duration:1,color:"#fff",style:{},width:6,height:6};function Io(s){Object.keys(la).map(function(o){s[o]===void 0&&(s[o]=la[o])})}var ca={_updateDotDom:function(o,i){if(i){var t=this.calcuPosition(o.time,o.duration),e=o.style||{};e.left="".concat(t.left,"%"),e.width="".concat(t.width,"%"),i.setAttribute("data-text",o.text),i.setAttribute("data-time",o.time),t.isMini?S.addClass(i,"mini"):S.removeClass(i,"mini"),Object.keys(e).map(function(r){i.style[r]=e[r]})}},initDots:function(){var o=this;this._ispots.map(function(i){o.createDot(i,!1)}),this.ispotsInit=!0},createDot:function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,t=this.player.plugins.progress;if(t&&(i&&(Io(o),this._ispots.push(o)),!(!this.ispotsInit&&i))){var e=this.calcuPosition(o.time,o.duration),r=o.style||{};r.left="".concat(e.left,"%"),r.width="".concat(e.width,"%");var n="xgspot_".concat(o.id," xgplayer-spot");e.isMini&&(n+=" mini");var a=o.template?'
'.concat(o.template,"
"):"",u=S.createDom("xg-spot",a,{"data-text":o.text,"data-time":o.time,"data-id":o.id},n);Object.keys(r).map(function(l){u.style[l]=r[l]}),t.outer&&t.outer.appendChild(u),this.positionDot(u,o.id)}},findDot:function(o){if(this.player.plugins.progress){var i=this._ispots.filter(function(t,e){return t.id===o});return i.length>0?i[0]:null}},updateDot:function(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,t=this.player.plugins.progress;if(t){var e=this.findDot(o.id);if(e&&Object.keys(o).map(function(n){e[n]=o[n]}),!!this.ispotsInit){var r=t.find('xg-spot[data-id="'.concat(o.id,'"]'));r&&(this._updateDotDom(o,r),i&&this.showDot(o.id))}}},deleteDot:function(o){var i=this._ispots,t=this.player.plugins.progress;if(t){for(var e=[],r=0;r=0;a--)if(i.splice(e[a],1),this.ispotsInit){var u=t.find('xg-spot[data-id="'.concat(o,'"]'));u&&u.parentElement.removeChild(u)}}},deleteAllDots:function(){var o=this.player.plugins.progress;if(o){if(!this.ispotsInit){this._ispots=[];return}for(var i=o.root.getElementsByTagName("xg-spot"),t=i.length-1;t>=0;t--)o.outer.removeChild(i[t]);this._ispots=[]}},updateAllDots:function(){var o=this,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=this.player.plugins.progress;if(t){if(!this.ispotsInit){this._ispots=i;return}this._ispots=[];var e=t.root.getElementsByTagName("xg-spot"),r=e.length;if(r>i.length)for(var n=r-1;n>i.length-1;n--)t.outer.removeChild(e[n]);i.forEach(function(a,u){u0&&e.hide();var a=e.player.plugins.progress;a&&a.disableBlur(),e._curDot.addEventListener("mouseleave",e.onDotMouseLeave)}}),e._ispots=[],e.videoPreview=null,e.videothumbnail=null,e.thumbnail=null,e.timeStr="",e._state={now:0,f:!1},e}return q(i,[{key:"beforeCreate",value:function(e){var r=e.player.plugins.progress;r&&(e.root=r.root)}},{key:"afterCreate",value:function(){var e=this;this._curDot=null,this.handlerSpotClick=this.hook("spotClick",function(r,n){n.seekTime&&e.player.seek(n.seekTime)}),this.transformTimeHook=this.hook("transformTime",function(r){e.setTimeContent(S.format(r))}),Fc(this),this.on($t,function(){e.show()}),this.config.disable&&this.disable(),this.extTextRoot=this.find(".xg-spot-ext-text")}},{key:"setConfig",value:function(e){var r=this;e&&Object.keys(e).map(function(n){r.config[n]=e[n]})}},{key:"onPluginsReady",value:function(){var e=this.player;e.plugins.progress&&(this.previewLine=this.find(".xg-spot-line"),this.timePoint=this.find(".xgplayer-progress-point"),this.timeText=this.find(".xg-spot-time"),this.tipText=this.find(".spot-inner-text"),this._hasThumnail=!1,this.registerThumbnail(),this.bindEvents())}},{key:"bindEvents",value:function(){var e=this,r=this.player.plugins.progress;if(r&&(Object.keys(Vi).map(function(a){e[Vi[a]]=e[Vi[a]].bind(e),r.addCallBack(a,e[Vi[a]])}),le.device!=="mobile")){this.bind(".xg-spot-info","mousemove",this.onMousemove),this.bind(".xg-spot-info","mousedown",this.onMousedown),this.bind(".xg-spot-info","mouseup",this.onMouseup);var n=this.hook("previewClick",function(){});this.handlerPreviewClick=function(a){a.stopPropagation(),n(parseInt(e._state.now*1e3,10)/1e3,a)},this.bind(".xg-spot-content","mouseup",this.handlerPreviewClick)}}},{key:"onProgressMove",value:function(e,r){this.config.disable||!this.player.duration||this.updatePosition(e.offset,e.width,e.currentTime,e.e)}},{key:"onProgressDragStart",value:function(e){this.config.disable||!this.player.duration||(this.isDrag=!0,this.videoPreview&&S.addClass(this.videoPreview,"show"))}},{key:"onProgressDragEnd",value:function(e){this.config.disable||!this.player.duration||(this.isDrag=!1,this.videoPreview&&S.removeClass(this.videoPreview,"show"))}},{key:"onProgressClick",value:function(e,r){this.config.disable||S.hasClass(r.target,"xgplayer-spot")&&(r.stopPropagation(),r.preventDefault(),["time","id","text"].map(function(n){e[n]=r.target.getAttribute("data-".concat(n))}),e.time&&(e.time=Number(e.time)),this.handlerSpotClick(r,e))}},{key:"updateLinePos",value:function(e,r){var n=this.root,a=this.previewLine,u=this.player,l=this.config,c=u.controls.mode,d=c==="flex",h=n.getBoundingClientRect().width;if(!(!h&&this._hasThumnail)){h=this._hasThumnail&&hr-h&&!d?(m=f-(r-h),f=r-h):m=0,m!==void 0&&(a.style.transform="translateX(".concat(m.toFixed(2),"px)")),n.style.transform="translateX(".concat(f.toFixed(2),"px) translateZ(0)")}}},{key:"updateTimeText",value:function(e){var r=this.timeText,n=this.timePoint;r.innerHTML=e,!this.thumbnail&&(n.innerHTML=e)}},{key:"updatePosition",value:function(e,r,n,a){var u=this.root,l=this.config,c=this._state;if(u){c.now=n,this.transformTimeHook(n);var d=this.timeStr;a&&a.target&&S.hasClass(a.target,"xgplayer-spot")?(this.showTips(a.target.getAttribute("data-text"),!1,d),this.focusDot(a.target),c.f=!0,l.isFocusDots&&c.f&&(c.now=parseInt(a.target.getAttribute("data-time"),10))):l.defaultText?(c.f=!1,this.showTips(l.defaultText,!0,d)):(c.f=!1,this.hideTips("")),this.updateTimeText(d),this.updateThumbnails(c.now),this.updateLinePos(e,r)}}},{key:"setTimeContent",value:function(e){this.timeStr=e}},{key:"updateThumbnails",value:function(e){var r=this.player,n=this.videoPreview,a=this.config,u=r.plugins.thumbnail;if(u&&u.usable){this.thumbnail&&u.update(this.thumbnail,e,a.width,a.height);var l=n&&n.getBoundingClientRect();this.videothumbnail&&u.update(this.videothumbnail,e,l.width,l.height)}}},{key:"registerThumbnail",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(le.device!=="mobile"){var r=this.player,n=this.config,a=r.getPlugin("thumbnail");if(a&&a.setConfig(e),!a||!a.usable||!n.isShowThumbnail){S.addClass(this.root,"short-line no-thumbnail");return}else S.removeClass(this.root,"short-line no-thumbnail");n.mode==="short"&&S.addClass(this.root,"short-line"),this._hasThumnail=!0;var u=this.find(".xg-spot-thumbnail");this.thumbnail=a.createThumbnail(u,"progress-thumbnail"),n.isShowCoverPreview&&(this.videoPreview=S.createDom("xg-video-preview","",{},"xgvideo-preview"),r.root.appendChild(this.videoPreview),this.videothumbnail=a.createThumbnail(this.videoPreview,"xgvideo-thumbnail")),this.updateThumbnails(0)}}},{key:"calcuPosition",value:function(e,r){var n=this.player.plugins.progress,a=this.player,u=n.root.getBoundingClientRect().width,l=a.duration/u*6;return e+r>a.duration&&(r=a.duration-e),e/a.duration*100,r/a.duration,{left:e/a.duration*100,width:r/a.duration*100,isMini:r2&&arguments[2]!==void 0?arguments[2]:"";S.addClass(this.root,"no-timepoint"),e&&(S.addClass(this.find(".xg-spot-content"),"show-text"),r&&this.config.mode==="production"?(S.addClass(this.root,"product"),this.tipText.textContent=e):(S.removeClass(this.root,"product"),this.tipText.textContent=this._hasThumnail?e:"".concat(n," ").concat(e)))}},{key:"hideTips",value:function(){S.removeClass(this.root,"no-timepoint"),this.tipText.textContent="",S.removeClass(this.find(".xg-spot-content"),"show-text"),S.removeClass(this.root,"product")}},{key:"hide",value:function(){S.addClass(this.root,"hide")}},{key:"show",value:function(e){S.removeClass(this.root,"hide")}},{key:"enable",value:function(){var e=this.config,r=this.playerConfig;this.config.disable=!1,this.show(),!this.thumbnail&&e.isShowThumbnail&&this.registerThumbnail(r.thumbnail||{})}},{key:"disable",value:function(){this.config.disable=!0,this.hide()}},{key:"destroy",value:function(){var e=this,r=this.player.plugins.progress;r&&Object.keys(Vi).map(function(n){r.removeCallBack(n,e[Vi[n]])}),this.videothumbnail=null,this.thumbnail=null,this.videoPreview&&this.player.root.removeChild(this.videoPreview),this.unbind(".xg-spot-info","mousemove",this.onMousemove),this.unbind(".xg-spot-info","mousedown",this.onMousedown),this.unbind(".xg-spot-info","mouseup",this.onMouseup),this.unbind(".xg-spot-content","mouseup",this.handlerPreviewClick)}},{key:"render",value:function(){return le.device==="mobile"||this.playerConfig.isMobileSimulateMode==="mobile"?"":'
00:00
`)}}],[{key:"pluginName",get:function(){return"progresspreview"}},{key:"defaultConfig",get:function(){return{index:1,miniWidth:6,ispots:[],defaultText:"",isFocusDots:!0,isHideThumbnailHover:!0,isShowThumbnail:!0,isShowCoverPreview:!1,mode:"",disable:!1,width:160,height:90}}}]),i}(Le),Uc=function(s){ie(i,s);var o=re(i);function i(t){var e;return $(this,i),e=o.call(this,t),e.ratio=1,e.interval=null,e._preloadMark={},e}return q(i,[{key:"afterCreate",value:function(){var e=this;this.usable&&this.initThumbnail(),this.on([$t],function(){var r=e.config,n=r.pic_num,a=r.interval;e.usable&&(e.interval=a>0?a:Math.round(e.player.duration*1e3/n)/1e3)})}},{key:"setConfig",value:function(e){var r=this;if(e){var n=Object.keys(e);n.length<1||(n.forEach(function(a){r.config[a]=e[a]}),this.usable&&this.initThumbnail())}}},{key:"usable",get:function(){var e=this.config,r=e.urls,n=e.pic_num;return r&&r.length>0&&n>0}},{key:"initThumbnail",value:function(){var e=this.config,r=e.width,n=e.height,a=e.pic_num,u=e.interval;this.ratio=r/n*100,this.interval=u||Math.round(this.player.duration/a),this._preloadMark={}}},{key:"getUrlByIndex",value:function(e){return e>=0&&e0&&u.push(e-1),u.push(e),e>0&&e=0&&l1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=this.config,u=a.pic_num,l=a.row,c=a.col,d=a.width,h=a.height;this.interval=Math.round(this.player.duration/u);var f=Math.ceil(e/this.interval);f=f>u?u:f;var m=f0?Math.ceil(g/c)-1:0,L=g>0?g-y*c-1:0,k=0,_=0;if(r&&n){var w=r/n;w2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,u=arguments.length>4&&arguments[4]!==void 0?arguments[4]:"",l=this.config,c=l.pic_num,d=l.urls;if(!(c<=0||!d||d.length===0)){var h=this.getPosition(r,n,a);this.preload(h.urlIndex),Object.keys(h.style).map(function(f){e.style[f]=h.style[f]}),Object.keys(u).map(function(f){e.style[f]=u[f]})}}},{key:"changeConfig",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.setConfig(e)}},{key:"createThumbnail",value:function(e,r){var n=S.createDom("xg-thumbnail","",{},"thumbnail ".concat(r));return e&&e.appendChild(n),n}}],[{key:"pluginName",get:function(){return"thumbnail"}},{key:"defaultConfig",get:function(){return{isShow:!1,urls:[],pic_num:0,col:0,row:0,height:90,width:160,scale:1,className:"",hidePortrait:!1}}}]),i}(Le);function yn(s){return s?"background:".concat(s,";"):""}var Kc=function(s){ie(i,s);var o=re(i);function i(){var t;$(this,i);for(var e=arguments.length,r=new Array(e),n=0;n=0?r:n}},{key:"afterCreate",value:function(){var e=this;this.root&&(this.on(ft,this.onTimeupdate),this.on(Ci,function(){e.reset()}))}},{key:"reset",value:function(){this.update({played:0,cached:0},0)}},{key:"update",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{cached:0,played:0},r=arguments.length>1?arguments[1]:void 0;!r||!this.root||(e.cached&&(this.find("xg-mini-progress-cache").style.width="".concat(e.cached/r*100,"%")),e.played&&(this.find("xg-mini-progress-played").style.width="".concat(e.played/r*100,"%")))}},{key:"render",value:function(){var e=this.playerConfig,r=e.commonStyle,n=e.miniprogress;if(n){var a=this.config,u=a.mode,l=a.height,c={cached:yn(r.cachedColor),played:yn(r.playedColor),progress:yn(r.progressColor),height:l>0&&l!==2?"height: ".concat(l,"px;"):""},d=u==="show"?"xg-mini-progress-show":"";return' `)}}}],[{key:"pluginName",get:function(){return"MiniProgress"}},{key:"defaultConfig",get:function(){return{mode:"auto",height:2}}}]),i}(Le),Di={REAL_TIME:"realtime",FIRST_FRAME:"firstframe",FRAME_RATE:"framerate",POSTER:"poster"};function Oc(){try{return parseInt(window.performance.now(),10)}catch{return new Date().getTime()}}function Ac(){try{var s=document.createElement("canvas").getContext;return!!s}catch{return!1}}var yr=null,zc=function(s){ie(i,s);var o=re(i);function i(){var t;$(this,i);for(var e=arguments.length,r=new Array(e),n=0;n0)t.renderOnce(),t._frameCount--;else{t._isLoaded=!0,t.off(ft,t.renderOnTimeupdate);var u=t.config.startInterval;!t.player.paused&&t._checkIfCanStart()&&t.start(0,u)}}),V(W(t),"start",function(a,u){var l=t.player.video,c=Oc(),d=t.checkVideoIsSupport(l);!d||!t.canvasCtx||(u||(u=t.interval),t.stop(),l.videoWidth&&l.videoHeight&&(t.videoPI=l.videoHeight>0?parseInt(l.videoWidth/l.videoHeight*100,10):0,(t.config.mode===Di.REAL_TIME||c-t.preTime>=u)&&(l&&l.videoWidth&&t.update(d,t.videoPI),t.preTime=c)),t.frameId=t._loopType==="timer"?S.setTimeout(W(t),t.start,u):S.requestAnimationFrame(t.start))}),V(W(t),"stop",function(){t.frameId&&(t._loopType==="timer"?S.clearTimeout(W(t),t.frameId):S.cancelAnimationFrame(t.frameId),t.frameId=null)}),t}return q(i,[{key:"afterCreate",value:function(){var e=this;this.playerConfig.dynamicBg===!0&&(this.config.disable=!1),i.isSupport||(this.config.disable=!0);var r=this.config,n=r.disable,a=r.mode,u=r.frameRate;n||(this._pos={width:0,height:0,rwidth:0,rheight:0,x:0,y:0,pi:0},this.isStart=!1,this._isLoaded=!1,this.videoPI=0,this.preTime=0,this.interval=parseInt(1e3/u,10),this.canvas=null,this.canvasCtx=null,this._frameCount=0,this._loopType=this.config.mode!==Di.REAL_TIME&&this.interval>=1e3?"timer":"animation",this.once(cr,function(){e.player&&(e.init(),e.renderByPoster(),e.player.paused||e.start())}),a!==Di.POSTER&&(a!==Di.FIRST_FRAME&&(this.on(Ci,function(){e.stop()}),this.on(bt,function(){var l=e.config.startInterval;e._checkIfCanStart()&&e.start(0,l)}),this.on(Ji,function(){e.stop()})),this.on(jt,this.onLoadedData),this.on(hs,function(){e._isLoaded=!1,e.stop()}),document.addEventListener("visibilitychange",this.onVisibilitychange)))}},{key:"setConfig",value:function(e){var r=this;Object.keys(e).forEach(function(n){n==="root"&&e[n]!==r.config[n]?r.reRender(e[n]):n==="frameRate"?r.interval=parseInt(1e3/e[n],10):n==="disable"&&e[n]&&r.stop(),r.config[n]=e[n]})}},{key:"init",value:function(e){var r=this.player,n=this.config;this.canvasFilter=i.supportCanvasFilter();try{var a=e||n.root;a||(a=n.isInnerRender&&r.innerContainer||r.root),a.insertAdjacentHTML("afterbegin",'
`)),this.root=a.children[0],this.canvas=this.find("canvas"),this.canvasFilter||(this.canvas.style.filter=n.filter,this.canvas.style.webkitFilter=n.filter),this.mask=this.find("xgmask"),n.addMask&&(this.mask.style.background=n.maskBg),this.canvasCtx=this.canvas.getContext("2d")}catch(u){pe.logError("plugin:DynamicBg",u)}}},{key:"reRender",value:function(e){var r=this.config.disable;if(!(!r&&!this.root)){this.stop();var n=this.root?this.root.parentElement:null;if(n!==e&&n.removeChild(this.root),!e){this.root=null;return}this.init(e),this.renderOnce();var a=this.config.startInterval;this._checkIfCanStart()&&this.start(0,a)}}},{key:"checkVideoIsSupport",value:function(e){if(!e)return null;var r=e&&e instanceof window.HTMLVideoElement?e:e.canvas?e.canvas:e.flyVideo?e.flyVideo:null;if(r&&!(le.browser==="safari"&&S.isMSE(r)))return r;var n=r?r.tagName.toLowerCase():"";return n==="canvas"||n==="img"?r:null}},{key:"renderByPoster",value:function(){var e=this.playerConfig.poster;if(e){var r=S.typeOf(e)==="String"?e:S.typeOf(e.poster)==="String"?e.poster:null;this.updateImg(r)}}},{key:"_checkIfCanStart",value:function(){var e=this.config.mode;return this._isLoaded&&!this.player.paused&&e!==Di.FIRST_FRAME&&e!==Di.POSTER}},{key:"renderOnce",value:function(){var e=this.player.video;if(!(!e.videoWidth||!e.videoHeight)){this.videoPI=parseInt(e.videoWidth/e.videoHeight*100,10);var r=this.checkVideoIsSupport(e);r&&this.update(r,this.videoPI)}}},{key:"updateImg",value:function(e){var r=this;if(e){var n=this.canvas.getBoundingClientRect(),a=n.width,u=n.height,l=new window.Image;l.onload=function(){if(!(!r.canvas||r.frameId||r.isStart)){r.canvas.height=u,r.canvas.width=a;var c=parseInt(a/u*100,10);r.update(l,c),l=null}},l.src=e}}},{key:"update",value:function(e,r){if(!(!this.canvas||!this.canvasCtx||!r))try{var n=this._pos,a=this.config,u=this.canvas.getBoundingClientRect(),l=u.width,c=u.height;if(l!==n.width||c!==n.height||n.pi!==r){var d=parseInt(l/c*100,10);n.pi=r,n.width!==l&&(n.width=this.canvas.width=l),n.height!==c&&(n.height=this.canvas.height=c);var h=c,f=l;dr&&(h=parseInt(l*100/r,10)),n.rwidth=f*a.multiple,n.rheight=h*a.multiple,n.x=(l-n.rwidth)/2,n.y=(c-n.rheight)/2}this.canvasFilter&&(this.canvasCtx.filter=a.filter),this.canvasCtx.drawImage(e,n.x,n.y,n.rwidth,n.rheight)}catch(m){pe.logError("plugin:DynamicBg",m)}}},{key:"destroy",value:function(){this.stop(),document.removeEventListener("visibilitychange",this.onVisibilitychange),this.canvasCtx=null,this.canvas=null}},{key:"render",value:function(){return""}}],[{key:"pluginName",get:function(){return"dynamicBg"}},{key:"defaultConfig",get:function(){return{isInnerRender:!1,disable:!0,index:-1,mode:"framerate",frameRate:10,filter:"blur(50px)",startFrameCount:2,startInterval:0,addMask:!0,multiple:1.2,maskBg:"rgba(0,0,0,0.7)"}}},{key:"isSupport",get:function(){return typeof yr=="boolean"||(yr=Ac()),yr}},{key:"supportCanvasFilter",value:function(){return!(le.browser==="safari"||le.browser==="firefox")}}]),i}(Le),Bc={LANG:"zh-cn",TEXT:{ERROR_TYPES:{network:{code:1,msg:"视频下载错误"},mse:{code:2,msg:"流追加错误"},parse:{code:3,msg:"解析错误"},format:{code:4,msg:"格式错误"},decoder:{code:5,msg:"解码错误"},runtime:{code:6,msg:"语法错误"},timeout:{code:7,msg:"播放超时"},other:{code:8,msg:"其他错误"}},HAVE_NOTHING:"没有关于音频/视频是否就绪的信息",HAVE_METADATA:"音频/视频的元数据已就绪",HAVE_CURRENT_DATA:"关于当前播放位置的数据是可用的,但没有足够的数据来播放下一帧/毫秒",HAVE_FUTURE_DATA:"当前及至少下一帧的数据是可用的",HAVE_ENOUGH_DATA:"可用数据足以开始播放",NETWORK_EMPTY:"音频/视频尚未初始化",NETWORK_IDLE:"音频/视频是活动的且已选取资源,但并未使用网络",NETWORK_LOADING:"浏览器正在下载数据",NETWORK_NO_SOURCE:"未找到音频/视频来源",MEDIA_ERR_ABORTED:"取回过程被用户中止",MEDIA_ERR_NETWORK:"网络错误",MEDIA_ERR_DECODE:"解码错误",MEDIA_ERR_SRC_NOT_SUPPORTED:"不支持的音频/视频格式",REPLAY:"重播",ERROR:"网络连接似乎出现了问题",PLAY_TIPS:"播放",PAUSE_TIPS:"暂停",PLAYNEXT_TIPS:"下一集",DOWNLOAD_TIPS:"下载",ROTATE_TIPS:"旋转",RELOAD_TIPS:"重新载入",FULLSCREEN_TIPS:"进入全屏",EXITFULLSCREEN_TIPS:"退出全屏",CSSFULLSCREEN_TIPS:"进入样式全屏",EXITCSSFULLSCREEN_TIPS:"退出样式全屏",TEXTTRACK:"字幕",PIP:"画中画",SCREENSHOT:"截图",LIVE:"正在直播",OFF:"关闭",OPEN:"开启",MINI_DRAG:"点击按住可拖动视频",MINISCREEN:"小屏幕",REFRESH_TIPS:"请试试",REFRESH:"刷新",FORWARD:"快进中",LIVE_TIP:"直播"}},Qi="info",bn=To,Jc=function(s){ie(i,s);var o=re(i);function i(){var t;$(this,i);for(var e=arguments.length,r=new Array(e),n=0;ny)){var L=g-f,k=L<=d;Lr&&(l===0||a[l-1].end-r<=n)){u=l;break}}return u}},{key:"_getBuffered",value:function(e){if(!e)return[];for(var r=[],n=0;nu.jumpCntMax||t.timer||u.useWaitingTimeoutJump===!1||(t.timer=setTimeout(t.onJump,u.waitingTime*1e3))}),V(W(t),"onJump",function(){var a=W(t),u=a.player,l=a.config;if(clearTimeout(t.timer),t.timer=null,!(t.jumpCnt>l.jumpCntMax||l.useWaitingTimeoutJump===!1)&&!(u.media.paused&&u.media.currentTime!==0&&t.hasPlayed)){t.jumpSize=l.jumpSize*(t.jumpCnt+1),t.jumpCnt===l.jumpSize&&t.jumpSize<6&&(t.jumpSize=6);var c=u.currentTime+t.jumpSize,d=u.media.duration;c>d||(t.jumpCnt++,u.currentTime=c)}}),t}return q(i,[{key:"afterCreate",value:function(){var e=this,r=this.config,n=r.useWaitingTimeoutJump,a=r.jumpSize;n!==!1&&(this.hasPlayed=!1,this.jumpCnt=0,this.timer=null,this.jumpSize=a,this.on(Li,this.onWaiting),this.on([ds,At],function(){clearTimeout(e.timer),e.timer=null,e.jumpSize=e.config.jumpSize}),this.on(bt,function(){e.hasPlayed=!0}))}}],[{key:"pluginName",get:function(){return"waitingTimeoutJump"}},{key:"defaultConfig",get:function(){return{useWaitingTimeoutJump:!1,waitingTime:15,jumpSize:2,jumpCntMax:4}}}]),i}(Le),Yi="cdn",br=["cdn"],Qc=function(s){ie(i,s);var o=re(i);function i(){var t;$(this,i);for(var e=arguments.length,r=new Array(e),n=0;n0&&arguments[0]!==void 0?arguments[0]:Yi;if(!t.speedListCache||!t.speedListCache[a]||t.speedListCache[a].length<=0)return 0;var u=0;return t.speedListCache[a].map(function(l){u+=l}),Math.floor(u/t.speedListCache[a].length)}),V(W(t),"startTimer",function(){S.isMSE(t.player.video)||(t.initSpeedList(),t.cnt=0,t.timer=setTimeout(t.testSpeed,t.config.testTimeStep))}),V(W(t),"initSpeedList",function(){t.speedListCache={},br.forEach(function(a){t.speedListCache[a]=[]})}),V(W(t),"_onRealSpeedChange",function(a){a.speed&&t.appendList(a.speed,a.type||Yi)}),V(W(t),"testSpeed",function(){if(clearTimeout(t.timer),t.timer=null,!(!t.player||!t.config.openSpeed)){var a=t.config,u=a.url,l=a.loadSize,c=a.testCnt,d=a.testTimeStep,h=u+(u.indexOf("?")<0?"?testst=":"&testst=")+Date.now();if(!(t.cnt>=c)){t.cnt++;try{var f=new Date().getTime(),m=null,g=new XMLHttpRequest;t.xhr=g,g.open("GET",h);var y={},L=Math.floor(Math.random()*10);y.Range="bytes="+L+"-"+(l+L),y&&Object.keys(y).forEach(function(k){g.setRequestHeader(k,y[k])}),g.onreadystatechange=function(){if(g.readyState===4){t.xhr=null,m=new Date().getTime();var k=g.getResponseHeader("Content-Length")/1024*8,_=Math.round(k*1e3/(m-f));t.appendList(_),t.timer=setTimeout(t.testSpeed,d)}},g.send()}catch(k){console.error(k)}}}}),V(W(t),"appendList",function(a){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Yi;if(!(!t.speedListCache||!t.speedListCache[u])){var l=t.config.saveSpeedMax;t.speedListCache[u].length>=l&&t.speedListCache[u].shift(),t.speedListCache[u].push(a);var c=W(t),d=c.player;d&&(u===Yi?d.realTimeSpeed=a:d[t.getSpeedName("realTime",u)]=a),t.updateSpeed(u)}}),V(W(t),"updateSpeed",function(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Yi,u=t.getSpeed(a),l=W(t),c=l.player;if(c)if(a===Yi)(!c.avgSpeed||u!==c.avgSpeed)&&(c.avgSpeed=u,c.emit(Vn,{speed:u,realTimeSpeed:c.realTimeSpeed}));else{var d=t.getSpeedName("avg",a);(!c[d]||u!==c[d])&&(c[d]=u,c.emit(Vn,{speed:u,realTimeSpeed:c.realTimeSpeed}))}}),t}return q(i,[{key:"afterCreate",value:function(){var e=this.config,r=e.openSpeed,n=e.addSpeedTypeList;(n==null?void 0:n.length)>0&&br.push.apply(br,xt(n)),this.initSpeedList(),this.on("real_time_speed",this._onRealSpeedChange),this.timer=null,this.cnt=0,this.xhr=null,r&&this.on([jt,tr],this.startTimer)}},{key:"getSpeedName",value:function(e,r){return e+"Speed"+r.toUpperCase()}},{key:"openSpeed",get:function(){return this.config.openSpeed},set:function(e){if(this.config.openSpeed=e,!e&&this.timer){clearTimeout(this.timer),this.timer=null;return}if(this.config.openSpeed){if(this.timer)return;this.timer=setTimeout(this.testSpeed,this.config.testTimeStep)}}},{key:"destroy",value:function(){var e=this;this.off("real_time_speed",this._onRealSpeedChange),this.off([jt,tr],this.startTimer),br.forEach(function(r){e.speedListCache&&e.speedListCache[r]&&(e.speedListCache[r]=[])}),this.speedListCache&&(this.speedListCache={}),clearTimeout(this.timer),this.timer=null,this.xhr&&this.xhr.readyState!==4&&(this.xhr.cancel&&this.xhr.cancel(),this.xhr=null)}}],[{key:"pluginName",get:function(){return"testspeed"}},{key:"defaultConfig",get:function(){return{openSpeed:!1,testCnt:3,loadSize:200*1024,testTimeStep:3e3,url:"",saveSpeedMax:5,addSpeedTypeList:[]}}}]),i}(Le),$c=function(s){ie(i,s);var o=re(i);function i(){return $(this,i),o.apply(this,arguments)}return q(i,[{key:"afterCreate",value:function(){var e=this,r=this.player,n=this.config,a=r.media||r.video;if(this.timer=null,this._lastDecodedFrames=0,this._currentStuckCount=0,this._lastCheckPoint=null,this._payload=[],!n.disabled){var u=a.getVideoPlaybackQuality;u&&(this.on(bt,function(){e._startTick()}),this.on(Ji,function(){e._stopTick()}),this.on(wi,function(){e._stopTick()}),this.on(Ci,function(){e._stopTick()}))}}},{key:"_startTick",value:function(){var e=this;this._stopTick(),this._timer=setTimeout(function(){e._checkDecodeFPS(),e._startTick()},this.config.tick)}},{key:"_stopTick",value:function(){clearTimeout(this._timer),this._timer=null}},{key:"_checkBuffer",value:function(e,r){for(var n=!1,a=[],u=0;u=this.config.stuckCount&&(this.emit(wo,this._payload),this._reset())):this._reset())}}},{key:"_reset",value:function(){this._payload=[],this._currentStuckCount=0}},{key:"_checkDecodeFPS",value:function(){var e=this.player.media||this.player.video;if(e){var r=e.getVideoPlaybackQuality(),n=r.totalVideoFrames,a=r.droppedVideoFrames,u=performance.now();if(n&&this._lastCheckPoint){var l=n-this._lastDecodedFrames,c=u-this._lastCheckPoint;this._checkStuck(l,n,a,c)}this._lastDecodedFrames=n,this._lastCheckPoint=u}}},{key:"destroy",value:function(){this._stopTick()}}],[{key:"pluginName",get:function(){return"FpsDetect"}},{key:"defaultConfig",get:function(){return{disabled:!1,tick:1e3,stuckCount:3,reportFrame:0}}}]),i}(Le);Ui.use(Bc);var qc=q(function s(o,i){var t,e,r;$(this,s);var n=i&&i.isMobileSimulateMode==="mobile",a=i.isLive,u=a?[]:[vc,uc,Kc,Hc,pc],l=[].concat(u,[lc,mc,Zc,Cc,Mc,Pc,Xc,Gc,Sc,wc]),c=[Hl,Ul,Ol,sc,Al,Yc,Nc,Uc,jl];this.plugins=[Jc,Nl].concat(xt(l),c,[Wo,jc]);var d=n?"mobile":le.device;switch(d){case"pc":(t=this.plugins).push.apply(t,[aa,vn,ua,Qc,$c]);break;case"mobile":(e=this.plugins).push.apply(e,[ic]);break;default:(r=this.plugins).push.apply(r,[aa,vn,ua])}(le.os.isIpad||d==="pc")&&this.plugins.push(zc),le.os.isIpad&&this.plugins.push(vn),this.ignores=[],this.i18n=[]}),Xt=function(s){ie(i,s);var o=re(i);function i(){return $(this,i),o.apply(this,arguments)}return q(i)}(Jr);V(Xt,"defaultPreset",qc);V(Xt,"Util",S);V(Xt,"Sniffer",le);V(Xt,"Errors",Lt);V(Xt,"Events",ml);V(Xt,"Plugin",Le);V(Xt,"BasePlugin",Ue);V(Xt,"I18N",Ui);V(Xt,"STATE_CLASS",A);V(Xt,"InstManager",Ro);function da(s,o){var i=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);o&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable})),i.push.apply(i,t)}return i}function si(s){for(var o=1;o=0;--x){var T=this.tryEntries[x],X=T.completion;if(T.tryLoc==="root")return b("end");if(T.tryLoc<=this.prev){var M=i.call(T,"catchLoc"),F=i.call(T,"finallyLoc");if(M&&F){if(this.prev=0;--b){var x=this.tryEntries[b];if(x.tryLoc<=this.prev&&i.call(x,"finallyLoc")&&this.prev=0;--v){var b=this.tryEntries[v];if(b.finallyLoc===p)return this.complete(b.completion,b.afterLoc),E(b),d}},catch:function(p){for(var v=this.tryEntries.length-1;v>=0;--v){var b=this.tryEntries[v];if(b.tryLoc===p){var x=b.completion;if(x.type==="throw"){var T=x.arg;E(b)}return T}}throw new Error("illegal catch attempt")},delegateYield:function(p,v,b){return this.delegate={iterator:I(p),resultName:v,nextLoc:b},this.method==="next"&&(this.arg=void 0),d}},s}function ha(s,o,i,t,e,r,n){try{var a=s[r](n),u=a.value}catch(l){i(l);return}a.done?o(u):Promise.resolve(u).then(t,e)}function je(s){return function(){var o=this,i=arguments;return new Promise(function(t,e){var r=s.apply(o,i);function n(u){ha(r,t,e,n,a,"next",u)}function a(u){ha(r,t,e,n,a,"throw",u)}n(void 0)})}}function xi(s,o){if(!(s instanceof o))throw new TypeError("Cannot call a class as a function")}function fa(s,o){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Ne(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function td(s,o){if(o&&(typeof o=="object"||typeof o=="function"))return o;if(o!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ne(s)}function Ls(s){var o=ed();return function(){var t=Nr(s),e;if(o){var r=Nr(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return td(this,e)}}function id(s,o){if(typeof s!="object"||s===null)return s;var i=s[Symbol.toPrimitive];if(i!==void 0){var t=i.call(s,o||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(s)}function Mo(s){var o=id(s,"string");return typeof o=="symbol"?o:String(o)}var Zs={};Object.defineProperty(Zs,"__esModule",{value:!0});Zs.default=function(s){for(var o=0,i=arguments.length,t=Array(i>1?i-1:0),e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function cd(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function dd(s,o){if(o&&(typeof o=="object"||typeof o=="function"))return o;if(o!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return cd(s)}function Vo(s){var o=ld();return function(){var t=Fr(s),e;if(o){var r=Fr(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return dd(this,e)}}function hd(s,o){return md(s)||ud(s,o)||ks(s,o)||gd()}function Qe(s){return fd(s)||pd(s)||ks(s)||vd()}function fd(s){if(Array.isArray(s))return Fn(s)}function md(s){if(Array.isArray(s))return s}function pd(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function ks(s,o){if(s){if(typeof s=="string")return Fn(s,o);var i=Object.prototype.toString.call(s).slice(8,-1);if(i==="Object"&&s.constructor&&(i=s.constructor.name),i==="Map"||i==="Set")return Array.from(s);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Fn(s,o)}}function Fn(s,o){(o==null||o>s.length)&&(o=s.length);for(var i=0,t=new Array(o);i=s.length?{done:!0}:{done:!1,value:s[t++]}},e:function(u){throw u},f:e}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var r=!0,n=!1,a;return{s:function(){i=i.call(s)},n:function(){var u=i.next();return r=u.done,u},e:function(u){n=!0,a=u},f:function(){try{!r&&i.return!=null&&i.return()}finally{if(n)throw a}}}}function bd(s,o){if(typeof s!="object"||s===null)return s;var i=s[Symbol.toPrimitive];if(i!==void 0){var t=i.call(s,o||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(s)}function Do(s){var o=bd(s,"string");return typeof o=="symbol"?o:String(o)}var ai={VIDEO:"video",AUDIO:"audio",METADATA:"metadata"},Yt={AV1:"av1",AVC:"avc",HEVC:"hevc"},Me={AAC:"aac",G711PCMA:"g7110a",G711PCMU:"g7110m",OPUS:"opus"},Ge={LARGE_AV_SHIFT:"LARGE_AV_SHIFT",LARGE_VIDEO_GAP:"LARGE_VIDEO_GAP",LARGE_VIDEO_GAP_BETWEEN_CHUNK:"LARGE_VIDEO_GAP_BETWEEN_CHUNK",LARGE_AUDIO_GAP:"LARGE_AUDIO_GAP",AUDIO_FILLED:"AUDIO_FILLED",AUDIO_DROPPED:"AUDIO_DROPPED"},jr=function(){function s(){Ze(this,s),N(this,"id",1),N(this,"type",ai.VIDEO),N(this,"codecType",Yt.AVC),N(this,"pid",-1),N(this,"hvcC",void 0),N(this,"codec",""),N(this,"timescale",0),N(this,"formatTimescale",0),N(this,"sequenceNumber",0),N(this,"baseMediaDecodeTime",0),N(this,"baseDts",0),N(this,"duration",0),N(this,"warnings",[]),N(this,"samples",[]),N(this,"pps",[]),N(this,"sps",[]),N(this,"vps",[]),N(this,"fpsNum",0),N(this,"fpsDen",0),N(this,"sarRatio",[]),N(this,"width",0),N(this,"height",0),N(this,"nalUnitSize",4),N(this,"present",!1),N(this,"isVideoEncryption",!1),N(this,"isAudioEncryption",!1),N(this,"isVideo",!0),N(this,"lastKeyFrameDts",0),N(this,"kid",null),N(this,"pssh",null),N(this,"ext",void 0)}return ke(s,[{key:"reset",value:function(){this.sequenceNumber=this.width=this.height=this.fpsDen=this.fpsNum=this.duration=this.baseMediaDecodeTime=this.timescale=0,this.codec="",this.present=!1,this.pid=-1,this.pps=[],this.sps=[],this.vps=[],this.sarRatio=[],this.samples=[],this.warnings=[],this.hvcC=null}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var i=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-i.dts+t.duration}return 0}},{key:"exist",value:function(){return/av01/.test(this.codec)?!0:!!(this.pps.length&&this.sps.length&&this.codec)}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isVideoEncryption}}]),s}(),Qr=function(){function s(){Ze(this,s),N(this,"id",2),N(this,"type",ai.AUDIO),N(this,"codecType",Me.AAC),N(this,"pid",-1),N(this,"codec",""),N(this,"sequenceNumber",0),N(this,"sampleDuration",0),N(this,"timescale",0),N(this,"formatTimescale",0),N(this,"baseMediaDecodeTime",0),N(this,"duration",0),N(this,"warnings",[]),N(this,"samples",[]),N(this,"baseDts",0),N(this,"sampleSize",16),N(this,"sampleRate",0),N(this,"channelCount",0),N(this,"objectType",0),N(this,"sampleRateIndex",0),N(this,"config",[]),N(this,"present",!1),N(this,"isVideoEncryption",!1),N(this,"isAudioEncryption",!1),N(this,"kid",null),N(this,"ext",void 0)}return ke(s,[{key:"reset",value:function(){this.sequenceNumber=0,this.timescale=0,this.sampleDuration=0,this.sampleRate=0,this.channelCount=0,this.baseMediaDecodeTime=0,this.present=!1,this.pid=-1,this.codec="",this.samples=[],this.config=[],this.warnings=[]}},{key:"exist",value:function(){return!!(this.sampleRate&&this.channelCount&&this.codec&&(this.codecType===Me.AAC||this.codecType===Me.G711PCMA||this.codecType===Me.G711PCMU||this.codecType===Me.OPUS))}},{key:"hasSample",value:function(){return!!this.samples.length}},{key:"isEncryption",get:function(){return this.isAudioEncryption}},{key:"firstDts",get:function(){return this.samples.length?this.samples[0].dts:null}},{key:"firstPts",get:function(){return this.samples.length?this.samples[0].pts:null}},{key:"samplesDuration",get:function(){if(this.samples.length>0){var i=this.samples[0],t=this.samples[this.samples.length-1];return t.dts-i.dts+t.duration}return 0}}]),s}(),Ai=function(){function s(o,i,t){Ze(this,s),N(this,"flag",{}),N(this,"keyframe",!1),N(this,"gopId",0),N(this,"duration",0),N(this,"size",0),N(this,"units",[]),N(this,"chromaFormat",420),this.originPts=this.pts=o,this.originDts=this.dts=i,t&&(this.units=t)}return ke(s,[{key:"cts",get:function(){return this.pts-this.dts}},{key:"setToKeyframe",value:function(){this.keyframe=!0,this.flag.dependsOn=2,this.flag.isNonSyncSample=0}}]),s}(),Rt=ke(function s(o,i,t,e){Ze(this,s),N(this,"duration",1024),N(this,"flag",{dependsOn:2,isNonSyncSample:0}),N(this,"keyframe",!0),this.originPts=this.pts=this.dts=o,this.data=i,this.size=i.byteLength,this.sampleOffset=e,t&&(this.duration=t)}),Yo=ke(function s(o,i){Ze(this,s),N(this,"time",0),this.data=o,this.originPts=this.pts=i}),Sd=function(s){Po(i,s);var o=Vo(i);function i(){return Ze(this,i),o.apply(this,arguments)}return ke(i)}(Yo),No=function(s){Po(i,s);var o=Vo(i);function i(){return Ze(this,i),o.apply(this,arguments)}return ke(i)}(Yo),$r=function(){function s(){Ze(this,s),N(this,"id",3),N(this,"type",ai.METADATA),N(this,"timescale",0),N(this,"flvScriptSamples",[]),N(this,"seiSamples",[])}return ke(s,[{key:"exist",value:function(){return!!((this.flvScriptSamples.length||this.seiSamples.length)&&this.timescale)}},{key:"reset",value:function(){this.timescale=0,this.flvScriptSamples=[],this.seiSamples=[]}},{key:"hasSample",value:function(){return!!(this.flvScriptSamples.length||this.seiSamples.length)}}]),s}(),Zi=function(){function s(o){Ze(this,s),this.name=o||"",this._prefix="[".concat(this.name,"]")}return ke(s,[{key:"warn",value:function(){var i;if(!s.disabled){for(var t=arguments.length,e=new Array(t),r=0;r=e)){var n=r,a=[],u=(i[r+2]&60)>>>2,l=s.FREQ[u];if(!l)throw new Error("Invalid sampling index: ".concat(u));for(var c=((i[r+2]&192)>>>6)+1,d=(i[r+2]&1)<<2|(i[r+3]&192)>>>6,h=s._getConfig(u,d,c),f=h.config,m=h.codec,g,y,L=0,k=s.getFrameDuration(l);r+7>5,!y||e-r=e?void 0:i.subarray(r),frames:a,samplingFrequencyIndex:u,sampleRate:l,objectType:c,channelCount:d,codec:m,config:f,originCodec:"mp4a.40.".concat(c)}}}},{key:"parseAudioSpecificConfig",value:function(i){if(i.length){var t=i[0]>>>3,e=(i[0]&7)<<1|i[1]>>>7,r=(i[1]&120)>>>3,n=s.FREQ[e];if(n){var a=s._getConfig(e,r,t),u=a.config,l=a.codec;return{samplingFrequencyIndex:e,sampleRate:n,objectType:t,channelCount:r,config:u,codec:l,originCodec:"mp4a.40.".concat(t)}}}}},{key:"getFrameDuration",value:function(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4;return 1024*t/i}},{key:"_getConfig",value:function(i,t,e){var r=[],n,a;return Ld?i>=6?(n=5,a=i-3):(n=2,a=i):Zd?(n=2,a=i):(n=e===2||e===5?e:5,a=i,i>=6?a=i-3:t===1&&(n=2,a=i)),r[0]=n<<3,r[0]|=(i&14)>>1,r[1]=(i&1)<<7,r[1]|=t<<3,n===5&&(r[1]|=(a&14)>>1,r[2]=(a&1)<<7,r[2]|=8,r[3]=0),{config:r,codec:"mp4a.40.".concat(n)}}},{key:"getSilentFrame",value:function(i,t){switch(i){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(t===6)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224]);break;default:if(t===1)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===2)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(t===3)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);break}}}]),s}();N(Zt,"FREQ",[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350]);var Hn=function(){function s(){Ze(this,s)}return ke(s,null,[{key:"getFrameDuration",value:function(i){return 20}},{key:"parseHeaderPackets",value:function(i){if(i.length){for(var t=new DataView(i.buffer,i.byteOffset,i.byteLength),e="",r=0;r<8;r++)e+=String.fromCodePoint(i[r]);if(e!=="OpusHead")throw new Error("Invalid Opus MagicSignature");var n=i[9];console.log("Pre-skip",i[10],i[11]);var a=t.getUint32(12,!0),u=t.getInt16(16,!0);if(a){var l="opus",c="opus",d=new Uint8Array(i.buffer,i.byteOffset+8,i.byteLength-8);return{outputGain:u,sampleRate:a,channelCount:n,config:d,codec:l,originCodec:c}}}}}]),s}(),kd=500,pa=3,Sn=1e3,Ln=5e3,Td=1e3,wd=200,va=5e3,ga=5,_d=function(){function s(o,i,t){Ze(this,s),this.videoTrack=o,this.audioTrack=i,this.metadataTrack=t,this._baseDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastVideoDuration=0,this._keyFrameInNextChunk=!1,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0}return ke(s,[{key:"fix",value:function(){var i=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;t=Math.round(t*1e3);var n=this.videoTrack,a=this.audioTrack;(e||!r)&&(this._videoLastSample=null,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=0,this._videoTimestampBreak=0,this._lastAudioExceptionGapDot=-1/0,this._lastAudioExceptionOverlapDot=-1/0,this._lastAudioExceptionLargeGapDot=-1/0,this._lastVideoExceptionLargeGapDot=-1/0,this._lastVideoExceptionChunkFirstDtsDot=-1/0),e&&!r&&(this._baseDtsInited=!1),this._baseDtsInited||this._calculateBaseDts(a,n),!r&&t&&(this._audioNextPts=this._videoNextDts=t);var u=this._baseDtsInited&&(this._videoTimestampBreak||!this.videoTrack.exist())&&(this._audioTimestampBreak||!this.audioTrack.exist());if(u&&this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(a),this._keyFrameInNextChunk=!1,this._fixVideo(n),this.metadataTrack.exist()){var l=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(c){c.pts=c.originPts-i._baseDts,c.time=Math.max(0,c.pts)/l}),this.metadataTrack.flvScriptSamples.forEach(function(c){c.pts=c.originPts-i._baseDts,c.time=Math.max(0,c.pts)/l})}n.samples.length&&(n.baseMediaDecodeTime=n.samples[0].dts),a.samples.length&&(a.baseMediaDecodeTime=a.samples[0].pts*a.timescale/1e3)}},{key:"_fixVideo",value:function(i){var t=this,e=i.samples;if(e.length){e.forEach(function(k){k.dts-=t._baseDts,k.pts-=t._baseDts,k.keyframe&&(t._keyFrameInNextChunk=!0)});var r;if(i.fpsNum&&i.fpsDen)r=i.timescale*(i.fpsDen/i.fpsNum);else if(i.length>1){var n=i.samples[0],a=i.samples[e.length-1];r=Math.floor((a.dts-n.dts)/(e.length-1))}else r=this._lastVideoDuration||40;var u=e.pop();if(this._videoLastSample&&e.unshift(this._videoLastSample),this._videoLastSample=u,!!e.length){if(this._videoNextDts===void 0){var l=e[0];this._videoNextDts=l.dts}var c=e.length,d=0,h=e[0],f=this._videoNextDts-h.dts;if(Math.abs(f)>wd){if(Math.abs(h.dts-this._lastVideoExceptionChunkFirstDtsDot)>va){var m;this._lastVideoExceptionChunkFirstDtsDot=h.dts,i.warnings.push({type:Ge.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts,firstSampleDts:h.dts,nextSampleDts:(m=e[1])===null||m===void 0?void 0:m.dts,sampleDuration:f})}this._videoTimestampBreak>=ga?(this._videoNextDts=h.dts,this._videoTimestampBreak=0):(h.dts+=f,h.pts+=f,this.audioTrack.exist()||(this._videoTimestampBreak=1))}for(var g=0;gTd||d<0)&&(this._videoTimestampBreak++,Math.abs(y-this._lastVideoExceptionLargeGapDot)>va&&(this._lastVideoExceptionLargeGapDot=y,i.warnings.push({type:Ge.LARGE_VIDEO_GAP,time:y/i.timescale,dts:y,originDts:e[g].originDts,nextDts:this._videoNextDts,sampleDuration:d,refSampleDuration:r})),d=r),e[g].duration=d,this._videoNextDts+=d,this._lastVideoDuration=d}}}}},{key:"_fixAudio",value:function(i){var t=this,e=i.samples;e.length&&(e.forEach(function(r){r.dts=r.pts-=t._baseDts}),this._doFixAudioInternal(i,e,1e3))}},{key:"_calculateBaseDts",value:function(i,t){var e=i.samples,r=t.samples;if(!e.length&&!r.length)return!1;var n=1/0,a=1/0;e.length&&(i.baseDts=n=e[0].pts),r.length&&(t.baseDts=a=r[0].dts),this._baseDts=Math.min(n,a);var u=a-n;return Number.isFinite(u)&&Math.abs(u)>kd&&t.warnings.push({type:Ge.LARGE_AV_SHIFT,videoBaseDts:a,audioBasePts:n,baseDts:this._baseDts,delta:u}),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){var i=this._calculateBaseDts(this.audioTrack,this.videoTrack);i&&(this.audioTrack.exist()?this.videoTrack.exist()?this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts):this._baseDts-=this._audioNextPts:this._baseDts-=this._videoNextDts,this._videoTimestampBreak=0,this._audioTimestampBreak=0)}},{key:"_doFixAudioInternal",value:function(i,t,e){if(!i.sampleDuration)switch(i.codecType){case Me.AAC:{i.sampleDuration=Zt.getFrameDuration(i.timescale,e);break}case Me.OPUS:{i.sampleDuration=Hn.getFrameDuration(i.samples,e);break}case Me.G711PCMA:case Me.G711PCMU:{i.sampleDuration=this._getG711Duration(i);break}default:console.error("can't fix audio codecType:",i.codecType);break}var r=i.sampleDuration,n=i.codecType===Me.OPUS?20:i.codecType===Me.AAC?1024:r*i.timescale/1e3;if(this._audioNextPts===void 0){var a=t[0];this._audioNextPts=a.pts}for(var u=0;u=ga&&this._keyFrameInNextChunk&&(l=this._audioNextPts=c.dts,d=0,this._audioTimestampBreak=0),!this._audioTimestampBreak&&d>=pa*r&&d<=Sn&&!Fo){var h=this._getSilentFrame(i)||t[0].data.subarray(),f=Math.floor(d/r);Math.abs(c.pts-this._lastAudioExceptionGapDot)>Ln&&(this._lastAudioExceptionGapDot=c.pts,i.warnings.push({type:Ge.AUDIO_FILLED,pts:c.pts,originPts:c.originPts,count:f,nextPts:l,refSampleDuration:r}));for(var m=0;m=-1*Sn)Math.abs(c.pts-this._lastAudioExceptionOverlapDot)>Ln&&(this._lastAudioExceptionOverlapDot=c.pts,i.warnings.push({type:Ge.AUDIO_DROPPED,pts:c.pts,originPts:c.originPts,nextPts:l,refSampleDuration:r})),t.splice(u,1),u--;else{if(Math.abs(d)>Sn&&(this._audioTimestampBreak++,Math.abs(c.pts-this._lastAudioExceptionLargeGapDot)>Ln&&(this._lastAudioExceptionLargeGapDot=c.pts,i.warnings.push({type:Ge.LARGE_AUDIO_GAP,time:c.pts/1e3,pts:c.pts,originPts:c.originPts,nextPts:l,sampleDuration:d,refSampleDuration:r}))),i.codecType===Me.OPUS){var y=t[t.length-1];y&&(y.duration=c.pts-y.pts)}else c.dts=c.pts=l,c.duration=n;this._audioNextPts+=r}}}},{key:"_getG711Duration",value:function(i){var t=i.sampleSize,e=i.channelCount,r=i.sampleRate,n=i.samples[0];if(n)return n.data.byteLength*2/e/(t/8)/r*1e3}},{key:"_getSilentFrame",value:function(i){return i.codecType===Me.AAC?Zt.getSilentFrame(i.codec,i.channelCount):new Uint8Array(8*i.sampleDuration*i.channelCount)}}]),s}();function ht(){for(var s=arguments.length,o=new Array(s),i=0;i1&&arguments[1]!==void 0?arguments[1]:0;return(s[o]<<8)+(s[o+1]||0)}function Ed(s){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(s[o]<<16)+(s[o+1]<<8)+(s[o+2]||0)}function z(s){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(s[o]<<24>>>0)+(s[o+1]<<16)+(s[o+2]<<8)+(s[o+3]||0)}function fi(s){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return z(s,o)*Cd+z(s,o+4)}function Ho(s){for(var o="avc1.",i,t=0;t<3;t++)i=s[t].toString(16),i.length<2&&(i="0".concat(i)),o+=i;return o}function xd(s){var o="";if(s.forEach(function(e){o+=Rd(e)}),o.length<=32)for(var i=32-o.length,t=0;t=t)return[];for(var n=[];r1&&arguments[1]!==void 0?arguments[1]:4;if(!(i.length<4)){for(var e=i.length,r=[],n=0,a;n+t>>=8),n+=t,!!a){if(n+a>e)break;r.push(i.subarray(n,n+a)),n+=a}return r}}},{key:"parseSEI",value:function(i,t){for(var e=i.length,r=t?2:1,n=0,a=0,u="";i[r]===255;)n+=255,r++;for(n+=i[r++];i[r]===255;)a+=255,r++;if(a+=i[r++],n===5&&e>r+16)for(var l=0;l<16;l++)u+=i[r].toString(16),r++;return{payload:i.subarray(r,r+a),type:n,size:a,uuid:u}}},{key:"removeEPB",value:function(i){for(var t=i.byteLength,e=[],r=1;ri)this._word<<=i,this._bitsAvailable-=i;else{i-=this._bitsAvailable;var t=Math.floor(i/8);i-=t*8,this._bytesAvailable-=t,this._loadWord(),this._word<<=i,this._bitsAvailable-=i}}},{key:"readBits",value:function(i){if(i>32)throw new Error("Cannot read more than 32 bits");var t=Math.min(this._bitsAvailable,i),e=this._word>>>32-t;return this._bitsAvailable-=t,this._bitsAvailable>0?this._word<<=t:this._bytesAvailable>0&&this._loadWord(),t=i-t,t>0&&this._bitsAvailable?e<>>i)return this._word<<=i,this._bitsAvailable-=i,i;return this._loadWord(),i+this.skipLZ()}},{key:"skipUEG",value:function(){this.skipBits(1+this.skipLZ())}},{key:"readUEG",value:function(){var i=this.skipLZ();return this.readBits(i+1)-1}},{key:"readEG",value:function(){var i=this.readUEG();return 1&i?1+i>>>1:-1*(i>>>1)}},{key:"readBool",value:function(){return this.readBits(1)===1}},{key:"readUByte",value:function(){return this.readBits(8)}},{key:"skipScalingList",value:function(i){for(var t=8,e=8,r,n=0;n1&&arguments[1]!==void 0?arguments[1]:{};if(!(i.length<23)){t=t||{};for(var e=(i[21]&3)+1,r,n,a=[],u=[],l=[],c=23,d=i[22],h,f,m,g=0;g1&&arguments[1]!==void 0?arguments[1]:{};t=t||{};var e=new Un(i);e.readUByte(),e.readUByte(),e.readBits(4);var r=e.readBits(3);t.numTemporalLayers=Math.max(r+1,t.numTemporalLayers||0),t.temporalIdNested=e.readBits(1),s._parseProfileTierLevel(e,r,t),e.readUEG();var n=t.chromaFormatIdc=e.readUEG(),a=420;n<=3&&(a=[0,420,422,444][n]);var u=0;n===3&&(u=e.readBits(1));var l=e.readUEG(),c=e.readUEG(),d=e.readBits(1),h,f,m,g;if(d===1&&(h=e.readUEG(),f=e.readUEG(),m=e.readUEG(),g=e.readUEG()),t.bitDepthLumaMinus8=e.readUEG(),t.bitDepthChromaMinus8=e.readUEG(),d===1){var y=(n===1||n===2)&&u===0?2:1,L=n===1&&u===0?2:1;l-=y*(f+h),c-=L*(g+m)}return{codec:"hev1.1.6.L93.B0",width:l,height:c,chromaFormat:a,hvcC:t}}},{key:"_parseProfileTierLevel",value:function(i,t,e){var r=e.generalTierFlag||0;e.generalProfileSpace=i.readBits(2),e.generalTierFlag=Math.max(i.readBits(1),r),e.generalProfileIdc=Math.max(i.readBits(5),e.generalProfileIdc||0),e.generalProfileCompatibilityFlags=i.readBits(32),e.generalConstraintIndicatorFlags=[i.readBits(8),i.readBits(8),i.readBits(8),i.readBits(8),i.readBits(8),i.readBits(8)];var n=i.readBits(8);ri.bitsAvailable)throw new Error("maxSubLayersMinus inavlid size ".concat(t));for(var l=0;l0&&i.readBits((8-t)*2);for(var c=0;c=128){t.push(String.fromCharCode(a&65535)),r+=2;continue}}}else if(e[r]<240){if(s._checkContinuation(e,r,2)){var u=(e[r]&15)<<12|(e[r+1]&63)<<6|e[r+2]&63;if(u>=2048&&(u&63488)!==55296){t.push(String.fromCharCode(u&65535)),r+=3;continue}}}else if(e[r]<248&&s._checkContinuation(e,r,3)){var l=(e[r]&7)<<18|(e[r+1]&63)<<12|(e[r+2]&63)<<6|e[r+3]&63;if(l>65536&&l<1114112){l-=65536,t.push(String.fromCharCode(l>>>10|55296)),t.push(String.fromCharCode(l&1023|56320)),r+=4;continue}}}t.push("�"),++r}return t.join("")}},{key:"_checkContinuation",value:function(i,t,e){var r=i;if(t+e0&&(a=ba.decode(new Uint8Array(i.buffer,i.byteOffset+r,v))),r+=v}break;default:r=t;break}return{data:a,size:r,isEnd:n}}},{key:"_parseString",value:function(i){var t=i.getUint16(0),e="";return t>0&&(e=ba.decode(new Uint8Array(i.buffer,i.byteOffset+2,t))),{data:e,size:2+t}}},{key:"_parseObject",value:function(i){if(!(i.byteLength<3)){var t=s._parseString(i),e=s._parseValue(new DataView(i.buffer,i.byteOffset+t.size,i.byteLength-t.size));return{data:{name:t.data,value:e.data},size:t.size+e.size,isEnd:e.isEnd}}}}]),s}(),Gt={MP3:2,G711A:7,G711M:8,AAC:10,OPUS:13},kt=new Zi("FlvDemuxer"),Ko=function(){function s(o,i,t){Ze(this,s),N(this,"_headerParsed",!1),N(this,"_remainingData",null),N(this,"_gopId",0),N(this,"_needAddMetaBeforeKeyFrameNal",!0),this.videoTrack=o||new jr,this.audioTrack=i||new Qr,this.metadataTrack=t||new $r,this._fixer=new _d(this.videoTrack,this.audioTrack,this.metadataTrack)}return ke(s,[{key:"demux",value:function(i){var t,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=arguments.length>3?arguments[3]:void 0,a=this.audioTrack,u=this.videoTrack,l=this.metadataTrack;if((e||!r)&&(this._remainingData=null),e&&(this._headerParsed=!1),e?(u.reset(),a.reset(),l.reset()):(u.samples=[],a.samples=[],l.seiSamples=[],l.flvScriptSamples=[],u.warnings=[],a.warnings=[],this._remainingData&&(i=ht(this._remainingData,i),this._remainingData=null)),!i.length)return{videoTrack:u,audioTrack:a,metadataTrack:l};var c=0;if(!this._headerParsed){if(!s.probe(i))throw new Error("Invalid flv file");a.present=(i[4]&4)>>>2!==0,u.present=(i[4]&1)!==0,this._headerParsed=!0,c=z(i,5)+4}for(var d=i.length,h,f,m,g,y;c+15d));)m=(i[c+7]<<24>>>0)+(i[c+4]<<16)+(i[c+5]<<8)+i[c+6],c+=11,g=i.subarray(c,c+f),h===8?this._parseAudio(g,m):h===9?(n&&(this.seamlessLoadingSwitching=!0),this._parseVideo(g,m)):h===18?this._parseScript(g,m):kt.warn("Invalid tag type: ".concat(h)),c+=f,y=z(i,c),y!==11+f&&kt.warn("Invalid PrevTagSize ".concat(y," (").concat(11+f,")")),c+=4;c>>4,r=this.audioTrack;if(e!==Gt.AAC&&e!==Gt.G711A&&e!==Gt.G711M&&e!==Gt.OPUS){kt.warn("Unsupported sound format: ".concat(e)),r.reset();return}if(e!==Gt.AAC&&e!==Gt.OPUS){var n=(i[0]&12)>>2,a=(i[0]&2)>>1,u=i[0]&1;r.sampleRate=s.AUDIO_RATE[n],r.sampleSize=a?16:8,r.channelCount=u+1}switch(e){case Gt.G711A:case Gt.G711M:this._parseG711(i,t,e);break;case Gt.AAC:this._parseAac(i,t);break;case Gt.OPUS:this._parseOpus(i,t);break}}}},{key:"_parseOpus",value:function(i,t){var e=this.audioTrack,r=i[1];switch(e.codecType=Me.OPUS,r){case 0:{var n=Hn.parseHeaderPackets(i.subarray(2));n?(e.codec=n.codec,e.channelCount=n.channelCount,e.sampleRate=n.sampleRate,e.config=n.config,e.sampleDuration=Hn.getFrameDuration([],e.timescale)):(e.reset(),kt.warn("Cannot parse AudioSpecificConfig",i));break}case 1:{if(t==null)return;var a=new Rt(t,i.subarray(2),e.sampleDuration);e.samples.push(a);break}default:kt.warn("Unknown OpusPacketType: ".concat(r))}}},{key:"_parseG711",value:function(i,t,e){var r=this.audioTrack;r.codecType=e===7?Me.G711PCMA:Me.G711PCMU,r.sampleRate=8e3,r.codec=r.codecType,r.samples.push(new Rt(t,i.subarray(1)))}},{key:"_parseAac",value:function(i,t){var e=this.audioTrack;if(e.codecType=Me.AAC,i[1]===0){var r=Zt.parseAudioSpecificConfig(i.subarray(2));r?(e.codec=r.codec,e.channelCount=r.channelCount,e.sampleRate=r.sampleRate,e.config=r.config,e.objectType=r.objectType,e.sampleRateIndex=r.samplingFrequencyIndex):(e.reset(),kt.warn("Cannot parse AudioSpecificConfig",i))}else if(i[1]===1){if(t==null)return;e.samples.push(new Rt(t,i.subarray(2)))}else kt.warn("Unknown AACPacketType: ".concat(i[1]))}},{key:"_parseVideo",value:function(i,t){var e=this;if(!(i.length<6)){var r=(i[0]&240)>>>4,n=i[0]&15,a=this.videoTrack;if(n!==7&&n!==12){a.reset(),kt.warn("Unsupported codecId: ".concat(n));return}var u=n===12;a.codecType=u?Yt.HEVC:Yt.AVC;var l=i[1],c=(i[2]<<16|i[3]<<8|i[4])<<8>>8;if(l===0){var d=i.subarray(5),h=u?Kn.parseHEVCDecoderConfigurationRecord(d):Uo.parseAVCDecoderConfigurationRecord(d);if(h){var f=h.hvcC,m=h.sps,g=h.ppsArr,y=h.spsArr,L=h.vpsArr,k=h.nalUnitSize;f&&(a.hvcC=a.hvcC||f),m&&(a.codec=m.codec,a.width=m.width,a.height=m.height,a.sarRatio=m.sarRatio,a.fpsNum=m.fpsNum,a.fpsDen=m.fpsDen),y.length&&(a.sps=y),g.length&&(a.pps=g),L&&L.length&&(a.vps=L),k&&(a.nalUnitSize=k)}else kt.warn("Cannot parse ".concat(u?"HEVC":"AVC","DecoderConfigurationRecord"),i)}else if(l===1){var _=Et.parseAvcC(i.subarray(5),a.nalUnitSize);if(_=this._checkAddMetaNalToUnits(u,_,a),_&&_.length){var w=new Ai(t+c,t,_);if(this.seamlessLoadingSwitching&&t>>1&63:Z[0]&31;switch(C){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!u&&C!==5||u&&C===5)break;w.setToKeyframe();break;case 6:case 39:case 40:if(!u&&C!==6||u&&C===6)break;e.metadataTrack.seiSamples.push(new No(Et.parseSEI(Et.removeEPB(Z),u),t+c));break}}),w.keyframe&&this._gopId++,w.gopId=this._gopId}else kt.warn("Cannot parse NALUs",i)}else l===2||kt.warn("Unknown AVCPacketType: ".concat(l))}}},{key:"_checkAddMetaNalToUnits",value:function(i,t,e){if(!i||!this._needAddMetaBeforeKeyFrameNal)return this._needAddMetaBeforeKeyFrameNal=!1,t;var r=t.map(function(n){return n[0]>>>1&63});return r.includes(32)?(this._needAddMetaBeforeKeyFrameNal=!1,t):(t.unshift(e.pps[0]),t.unshift(e.sps[0]),t.unshift(e.vps[0]),t.filter(Boolean))}},{key:"_parseScript",value:function(i,t){this.metadataTrack.flvScriptSamples.push(new Sd(Gd.parse(i),t))}}],[{key:"probe",value:function(i){return i[0]!==70||i[1]!==76||i[2]!==86||i[3]!==1?!1:z(i,5)>=9}}]),s}();N(Ko,"AUDIO_RATE",[5500,11e3,22e3,44e3]);var Id=9e4/2,Sa=3,Sr=9e4,kn=5*9e4,Tn=9e4,Wd=9e4/2,Md=9e4*5,Pd=function(){function s(o,i,t,e){Ze(this,s),this.videoTrack=o,this.audioTrack=i,this.metadataTrack=t,this._baseDts=-1,this._baseVideoDts=-1,this._baseAudioDts=-1,this._baseDtsInited=!1,this._audioNextPts=void 0,this._videoNextDts=void 0,this._audioTimestampBreak=!1,this._videoTimestampBreak=!1,this._lastAudioExceptionGapDot=0,this._lastAudioExceptionOverlapDot=0,this._lastAudioExceptionLargeGapDot=0,this._needForceFixLargeGap=e==null?void 0:e.forceFixLargeGap,this._largeGapThreshold=(e==null?void 0:e.largeGapThreshold)||Md}return ke(s,[{key:"fix",value:function(){var i=this,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;t=Math.round(t*9e4);var n=this.videoTrack,a=this.audioTrack,u=n.samples,l=a.samples;if(!(!u.length&&!l.length)){var c=u[0],d=l[0],h=0;if(u.length&&l.length&&(h=c.dts-d.pts),this._baseDtsInited||this._calculateBaseDts(this.audioTrack,this.videoTrack),e&&(this._calculateBaseDts(this.audioTrack,this.videoTrack),this._baseDts-=t,this._baseAudioDts-=t,this._baseVideoDts-=t),!r){this._videoNextDts=h>0?t+h:t,this._audioNextPts=h>0?t:t-h,this._needForceFixLargeGap&&(this._videoNextDts=0,this._audioNextPts=0);var f=c?c.dts-this._baseDts-this._videoNextDts:0,m=d?d.pts-this._baseDts-this._audioNextPts:0;Math.abs(f||m)>Tn&&(this._calculateBaseDts(this.audioTrack,this.videoTrack),this._baseDts-=t)}if(this._resetBaseDtsWhenStreamBreaked(),this._fixAudio(a),this._fixVideo(n),this.metadataTrack.exist()){var g=this.metadataTrack.timescale;this.metadataTrack.seiSamples.forEach(function(y){y.pts=y.originPts-i._baseDts,y.time=Math.max(0,y.pts)/g})}n.samples.length&&(n.baseMediaDecodeTime=n.samples[0].dts),a.samples.length&&(a.baseMediaDecodeTime=a.samples[0].pts*a.timescale/9e4)}}},{key:"_fixVideo",value:function(i){var t=this,e=i.samples;if(e.length){if(e.forEach(function(R){R.dts-=t._needForceFixLargeGap?t._baseVideoDts:t._baseDts,R.pts-=t._needForceFixLargeGap?t._baseVideoDts:t._baseDts}),this._videoNextDts===void 0){var r=e[0];this._videoNextDts=r.dts}var n=e.length,a=0,u=e[0],l=e[1],c=this._videoNextDts-u.dts;if(Math.abs(c)>Wd){var d;if(i.warnings.push({type:Ge.LARGE_VIDEO_GAP_BETWEEN_CHUNK,nextDts:this._videoNextDts/90,firstSampleDts:u.dts/90,nextSampleDts:(((d=e[1])===null||d===void 0?void 0:d.dts)||0)/90,sampleDuration:c/90}),u.dts+=c,u.pts+=c,l&&Math.abs(l.dts-u.dts)>Tn)this._videoTimestampBreak=!0,e.forEach(function(R,E){E!==0&&(R.dts+=c,R.pts+=c)});else for(var h=1;hTn||a<0){this._videoTimestampBreak=!0,a=this._audioTimestampBreak?y:Math.max(a,30*90);var C=this._audioNextPts||0;Z&&Z.dts>C&&(a=y),i.warnings.push({type:Ge.LARGE_VIDEO_GAP,time:w/i.timescale,dts:w,originDts:e[_].originDts,nextDts:this._videoNextDts,sampleDuration:a,refSampleDuration:y})}e[_].duration=a,this._videoNextDts+=a}}}},{key:"_fixAudio",value:function(i){var t=this,e=i.samples;e.length&&(e.forEach(function(r){r.pts-=t._needForceFixLargeGap?t._baseAudioDts:t._baseDts,r.dts=r.pts}),this._doFixAudioInternal(i,e,9e4))}},{key:"_calculateBaseDts",value:function(i,t){var e=i.samples,r=t.samples;if(!e.length&&!r.length)return!1;var n=1/0,a=1/0;e.length&&(i.baseDts=n=e[0].pts,this._baseAudioDts=n),r.length&&(t.baseDts=a=r[0].dts,this._baseVideoDts=a),this._baseDts=Math.min(n,a);var u=a-n,l=!1;return Number.isFinite(u)&&Math.abs(u)>Id&&t.warnings.push({type:Ge.LARGE_AV_SHIFT,videoBaseDts:a,audioBasePts:n,baseDts:this._baseDts,delta:u}),Number.isFinite(u)&&Math.abs(u)>this._largeGapThreshold*Sr&&(l=!0),this._baseDtsInited||(l&&this._needForceFixLargeGap?this._needForceFixLargeGap=!0:this._needForceFixLargeGap=!1),this._baseDtsInited=!0,!0}},{key:"_resetBaseDtsWhenStreamBreaked",value:function(){if(this._baseDtsInited&&this._videoTimestampBreak&&this._audioTimestampBreak){var i=this._calculateBaseDts(this.audioTrack,this.videoTrack);if(!i)return;this._baseDts-=Math.min(this._audioNextPts,this._videoNextDts),this._audioLastSample=null,this._videoLastSample=null,this._videoTimestampBreak=!1,this._audioTimestampBreak=!1}}},{key:"_doFixAudioInternal",value:function(i,t,e){i.sampleDuration||(i.sampleDuration=Zt.getFrameDuration(i.timescale,e));var r=i.sampleDuration;if(this._audioNextPts===void 0){var n=t[0];this._audioNextPts=n.pts}for(var a=0;a=Sa*r&&c<=Sr&&!Fo){var d=Zt.getSilentFrame(i.codec,i.channelCount)||t[0].data.subarray(),h=Math.floor(c/r);Math.abs(l.pts-this._lastAudioExceptionGapDot)>kn&&(this._lastAudioExceptionGapDot=l.pts),i.warnings.push({type:Ge.AUDIO_FILLED,pts:l.pts/90,originPts:l.originPts,count:h,nextPts:u/90,refSampleDuration:r});for(var f=0;f=-1*Sr?(Math.abs(l.pts-this._lastAudioExceptionOverlapDot)>kn&&(this._lastAudioExceptionOverlapDot=l.pts,i.warnings.push({type:Ge.AUDIO_DROPPED,pts:l.pts/90,originPts:l.originPts,nextPts:u/90,refSampleDuration:r})),t.splice(a,1),a--):(Math.abs(c)>=Sr&&(this._audioTimestampBreak=!0,Math.abs(l.pts-this._lastAudioExceptionLargeGapDot)>kn&&(this._lastAudioExceptionLargeGapDot=l.pts,i.warnings.push({type:Ge.LARGE_AUDIO_GAP,time:l.pts/1e3,pts:l.pts/90,originPts:l.originPts,nextPts:u/90,sampleDuration:c,refSampleDuration:r}))),l.dts=l.pts=u,this._audioNextPts+=r)}}}]),s}(),Tt=new Zi("TsDemuxer"),Oo=function(){function s(o,i,t){var e=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};Ze(this,s),N(this,"_pmtId",-1),N(this,"_remainingPacketData",null),N(this,"_videoPesData",[]),N(this,"_audioPesData",[]),N(this,"_gopId",0),this.videoTrack=o||new jr,this.audioTrack=i||new Qr,this.metadataTrack=t||new $r,this._fixer=new Pd(this.videoTrack,this.audioTrack,this.metadataTrack,e)}return ke(s,[{key:"demux",value:function(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=this.audioTrack,n=this.videoTrack,a=this.metadataTrack;t&&(this._pmtId=-1,n.reset(),r.reset(),a.reset()),!e||t?(this._remainingPacketData=null,this._videoPesData=[],this._audioPesData=[]):(n.samples=[],r.samples=[],a.seiSamples=[],n.warnings=[],r.warnings=[],this._remainingPacketData&&(i=ht(this._remainingPacketData,i),this._remainingPacketData=null));var u=i.length,l=u%188;l&&(this._remainingPacketData=i.subarray(u-l),u-=l);for(var c=n.pid,d=r.pid,h=0;h>4,y=void 0;if(g>1){if(y=h+5+i[h+4],y===h+188)continue}else y=h+4;switch(m){case 0:f&&(y+=i[y]+1),this._pmtId=(i[y+10]&31)<<8|i[y+11];break;case this._pmtId:{f&&(y+=i[y]+1);var L=y+3+((i[y+1]&15)<<8|i[y+2])-4,k=(i[y+10]&15)<<8|i[y+11];for(y+=12+k;y>>1&63:l[0]&31;switch(c){case 5:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:if(!a&&c!==5||a&&c===5)break;u.setToKeyframe(),r._gopId++;break;case 6:case 39:case 40:if(!a&&c!==6||a&&c===6)break;r.metadataTrack.seiSamples.push(new No(Et.parseSEI(Et.removeEPB(l),a),t));return;case 32:if(!a)break;if(!n.vps.length){var d=Kn.parseVPS(Et.removeEPB(l),n.hvcC);n.hvcC=n.hvcC||d,n.vps=[l]}break;case 7:case 33:if(!a&&c!==7||a&&c===7)break;if(!n.sps.length){var h=Et.removeEPB(l),f=a?Kn.parseSPS(h,n.hvcC):Uo.parseSPS(h);n.sps=[l],n.hvcC=n.hvcC||f.hvcC,n.codec=f.codec,n.width=f.width,n.height=f.height,n.sarRatio=f.sarRatio,n.fpsNum=f.fpsNum,n.fpsDen=f.fpsDen}break;case 8:case 34:if(!a&&c!==8||a&&c===8)break;n.pps.length||(n.pps=[l]);break;case 9:case 35:break;case 38:if(a){for(var m=!1,g=2;gi.length-6)){var n,a,u=i[7];return u&192&&(n=(i[9]&14)*536870912+(i[10]&255)*4194304+(i[11]&254)*16384+(i[12]&255)*128+(i[13]&254)/2,u&64?(a=(i[14]&14)*536870912+(i[15]&255)*4194304+(i[16]&254)*16384+(i[17]&255)*128+(i[18]&254)/2,n-a>60*9e4&&(n=a)):a=n),{data:i.subarray(9+t),pts:n,dts:a}}}}}}]),s}(),wn=function(){function s(o,i,t){Ze(this,s),this.dv=new DataView(o),this.start=this.offset=i||this.dv.byteOffset,this.end=t?this.start+t:this.start+this.dv.byteLength}return ke(s,[{key:"buffer",get:function(){return this.dv.buffer}},{key:"unreadLength",get:function(){return Math.max(this.end-this.offset,0)}},{key:"size",get:function(){return this.end-this.start}},{key:"readFloat",value:function(i){var t=0;switch(i){case 4:t=this.dv.getFloat32(this.offset);break;case 8:t=this.dv.getFloat64(this.offset);break;default:throw new Error("read ".concat(i,"-byte float is not supported"))}return this.offset+=i,t}},{key:"back",value:function(i){this.offset-=i}},{key:"skip",value:function(i){this.offset+=i}},{key:"readInt",value:function(i){var t=this.offset;switch(this.offset+=i,i){case 1:return this.dv.getInt8(t);case 2:return this.dv.getInt16(t);case 4:return this.dv.getInt32(t);default:throw new Error("read ".concat(i,"-byte integers is not supported"))}}},{key:"read",value:function(i){var t=this.offset;switch(this.offset+=i,i){case 1:return this.dv.getUint8(t);case 2:return this.dv.getUint16(t);case 3:return(this.dv.getUint16(t)<<8)+this.dv.getUint8(t+2);case 4:return this.dv.getUint32(t);default:return this.back(i-4),this.read(i-4)+this.dv.getUint32(t)*Math.pow(256,i-4)}}},{key:"write",value:function(i,t){var e=this.offset;switch(this.offset+=i,i){case 1:return this.dv.setUint8(e,t);case 2:return this.dv.setUint16(e,t);case 3:return this.dv.setUint8(e,t>>>16),this.dv.setUint16(e+1,65535&t);case 4:return this.dv.setUint32(e,t);default:throw new Error("write ".concat(i,"-byte integers is not supported"))}}},{key:"readToBuffer",value:function(i){var t;return this.offset||i?t=this.dv.buffer.slice(this.offset,i?this.offset+i:this.end):t=this.dv.buffer,this.offset+=t.byteLength,t}},{key:"readToUint8",value:function(i){var t=new Uint8Array(this.dv.buffer,this.offset,i||this.unreadLength);return this.offset+=t.byteLength,t}},{key:"readString",value:function(i){for(var t=0,e="";t=0){var e=0,r=0;if(this.offset+=i,this.size>31){for(;r>>t&e}}throw new Error("the number of the read operation exceeds the total length limit of bits")}}],[{key:"fromByte",value:function(i,t){return new s(i.read(t),t<<3)}}]),s}(),se=function(){function s(){Ze(this,s)}return ke(s,null,[{key:"findBox",value:function(i,t){var e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=[];if(!i)return r;for(var n=0,a="",u=0;i.length>7;){if(n=z(i),a=String.fromCharCode.apply(null,i.subarray(4,8)),u=8,n===1?(n=fi(i,8),u+=8):n||(n=i.length),!t[0]||a===t[0]){var l=i.subarray(0,n);if(t.length<2)r.push({start:e,size:n,headerSize:u,type:a,data:l});else return s.findBox(l.subarray(u),t.slice(1),e+u)}e+=n,i=i.subarray(n)}return r}},{key:"tfhd",value:function(i){return ne(i,!0,function(t,e){t.trackId=z(e);var r=4,n=t.flags&255&1,a=t.flags&255&2,u=t.flags&255&8,l=t.flags&255&16,c=t.flags&255&32;n&&(r+=4,t.baseDataOffset=z(e,r),r+=4),a&&(t.sampleDescriptionIndex=z(e,r),r+=4),u&&(t.defaultSampleDuration=z(e,r),r+=4),l&&(t.defaultSampleSize=z(e,r),r+=4),c&&(t.defaultSampleFlags=z(e,r))})}},{key:"sidx",value:function(i){return ne(i,!0,function(t,e){var r=0;t.reference_ID=z(e,r),r+=4,t.timescale=z(e,r),r+=4,t.version===0?(t.earliest_presentation_time=z(e,r),r+=4,t.first_offset=z(e,r),r+=4):(t.earliest_presentation_time=fi(e,r),r+=8,t.first_offset=fi(e,r),r+=8),r+=2,t.references=[];var n=Ce(e,r);r+=2;for(var a=0;a>31&1,u.referenced_size=l&2147483647,u.subsegment_duration=z(e,r),r+=4,l=z(e,r),r+=4,u.starts_with_SAP=l>>31&1,u.SAP_type=l>>28&7,u.SAP_delta_time=l&268435455}})}},{key:"moov",value:function(i){return ne(i,!1,function(t,e,r){t.mvhd=s.mvhd(s.findBox(e,["mvhd"],r)[0]),t.trak=s.findBox(e,["trak"],r).map(function(n){return s.trak(n)}),t.pssh=s.pssh(s.findBox(e,["pssh"],r)[0])})}},{key:"mvhd",value:function(i){return ne(i,!0,function(t,e){var r=0;t.version===1?(t.timescale=z(e,16),t.duration=fi(e,20),r+=28):(t.timescale=z(e,8),t.duration=z(e,12),r+=16),t.nextTrackId=z(e,r+76)})}},{key:"trak",value:function(i){return ne(i,!1,function(t,e,r){t.tkhd=s.tkhd(s.findBox(e,["tkhd"],r)[0]),t.mdia=s.mdia(s.findBox(e,["mdia"],r)[0])})}},{key:"tkhd",value:function(i){return ne(i,!0,function(t,e){var r=wn.fromUint8(e);t.version===1?(r.read(8),r.read(8),t.trackId=r.read(4),r.read(4),t.duration=r.read(8)):(r.read(4),r.read(4),t.trackId=r.read(4),r.read(4),t.duration=r.read(4)),r.skip(16),t.matrix=[];for(var n=0;n<36;n++)t.matrix.push(r.read(1));r.back(36);for(var a=[],u=0,l;u<3;u++)a.push(Zn(r.readInt(2),r.readInt(2))),a.push(Zn(r.readInt(2),r.readInt(2))),l=r.readInt(4),a.push(Zn(l>>30,l&1073741823));t.rotation=Xd(a),t.width=r.read(4),t.height=r.read(4)})}},{key:"mdia",value:function(i){return ne(i,!1,function(t,e,r){t.mdhd=s.mdhd(s.findBox(e,["mdhd"],r)[0]),t.hdlr=s.hdlr(s.findBox(e,["hdlr"],r)[0]),t.minf=s.minf(s.findBox(e,["minf"],r)[0])})}},{key:"mdhd",value:function(i){return ne(i,!0,function(t,e){var r=0;t.version===1?(t.timescale=z(e,16),t.duration=fi(e,20),r+=28):(t.timescale=z(e,8),t.duration=z(e,12),r+=16);var n=Ce(e,r);t.language=String.fromCharCode((n>>10&31)+96,(n>>5&31)+96,(n&31)+96)})}},{key:"hdlr",value:function(i){return ne(i,!0,function(t,e){t.version===0&&(t.handlerType=String.fromCharCode.apply(null,e.subarray(4,8)))})}},{key:"minf",value:function(i){return ne(i,!1,function(t,e,r){t.vmhd=s.vmhd(s.findBox(e,["vmhd"],r)[0]),t.smhd=s.smhd(s.findBox(e,["smhd"],r)[0]),t.stbl=s.stbl(s.findBox(e,["stbl"],r)[0])})}},{key:"vmhd",value:function(i){return ne(i,!0,function(t,e){t.graphicsmode=Ce(e),t.opcolor=[Ce(e,2),Ce(e,4),Ce(e,6)]})}},{key:"smhd",value:function(i){return ne(i,!0,function(t,e){t.balance=Ce(e)})}},{key:"stbl",value:function(i){return ne(i,!1,function(t,e,r){var n,a,u;t.stsd=s.stsd(s.findBox(e,["stsd"],r)[0]),t.stts=s.stts(s.findBox(e,["stts"],r)[0]),t.ctts=s.ctts(s.findBox(e,["ctts"],r)[0]),t.stsc=s.stsc(s.findBox(e,["stsc"],r)[0]),t.stsz=s.stsz(s.findBox(e,["stsz"],r)[0]),t.stco=s.stco(s.findBox(e,["stco"],r)[0]),t.stco||(t.co64=s.co64(s.findBox(e,["co64"],r)[0]),t.stco=t.co64);var l=(n=t.stsd.entries[0])===null||n===void 0||(a=n.sinf)===null||a===void 0||(u=a.schi)===null||u===void 0?void 0:u.tenc.default_IV_size;t.stss=s.stss(s.findBox(e,["stss"],r)[0]),t.senc=s.senc(s.findBox(e,["senc"],r)[0],l)})}},{key:"senc",value:function(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:8;return ne(i,!0,function(e,r){var n=0,a=z(r,n);n+=4,e.samples=[];for(var u=0;u0){var l=z(e,a);a+=4;for(var c=0;c<(""+l).length;c++)for(var d=0;d<16;d++){var h=e[a];a+=1,r.push(Cn(h))}}var f=z(e,a);t.data_size=f,a+=4,t.kid=r,t.system_id=n,t.buffer=e})}},{key:"stsd",value:function(i){return ne(i,!0,function(t,e,r){t.entryCount=z(e),t.entries=s.findBox(e.subarray(4),[],r+4).map(function(n){switch(n.type){case"av01":return s.av01(n);case"avc1":case"avc2":case"avc3":case"avc4":return s.avc1(n);case"hvc1":case"hev1":return s.hvc1(n);case"mp4a":return s.mp4a(n);case"alaw":case"ulaw":return s.alaw(n);case"enca":return ne(n,!1,function(a,u,l){a.channelCount=Ce(u,16),a.samplesize=Ce(u,18),a.sampleRate=z(u,24)/65536,u=u.subarray(28),a.sinf=s.sinf(s.findBox(u,["sinf"],l)[0]),a.esds=s.esds(s.findBox(u,["esds"],l)[0])});case"encv":return ne(n,!1,function(a,u,l){a.width=Ce(u,24),a.height=Ce(u,26),a.horizresolution=z(u,28),a.vertresolution=z(u,32),u=u.subarray(78),a.sinf=s.sinf(s.findBox(u,["sinf"],l)[0]),a.avcC=s.avcC(s.findBox(u,["avcC"],l)[0]),a.hvcC=s.hvcC(s.findBox(u,["hvcC"],l)[0]),a.pasp=s.pasp(s.findBox(u,["pasp"],l)[0])})}}).filter(Boolean)})}},{key:"tenc",value:function(i){return ne(i,!1,function(t,e){var r=6;t.default_IsEncrypted=e[r],r+=1,t.default_IV_size=e[r],r+=1,t.default_KID=[];for(var n=0;n<16;n++)t.default_KID.push(Cn(e[r])),r+=1})}},{key:"schi",value:function(i){return ne(i,!1,function(t,e,r){t.tenc=s.tenc(s.findBox(e,["tenc"],r)[0])})}},{key:"sinf",value:function(i){return ne(i,!1,function(t,e,r){t.schi=s.schi(s.findBox(e,["schi"],r)[0]),t.frma=s.frma(s.findBox(e,["frma"],r)[0])})}},{key:"frma",value:function(i){return ne(i,!1,function(t,e){t.data_format="";for(var r=0;r<4;r++)t.data_format+=String.fromCharCode(e[r])})}},{key:"colr",value:function(i){return ne(i,!1,function(t,e){var r=wn.fromUint8(e);t.data=i.data,t.colorType=r.readString(4),t.colorType==="nclx"?(t.colorPrimaries=r.read(2),t.transferCharacteristics=r.read(2),t.matrixCoefficients=r.read(2),t.fullRangeFlag=r.read(1)>>7):(t.colorType==="rICC"||t.colorType==="prof")&&(t.iccProfile=e.readToUint8())})}},{key:"av01",value:function(i){return ne(i,!1,function(t,e,r){var n=_n(t,e),a=e.subarray(n);r+=n,t.av1C=s.av1C(s.findBox(a,["av1C"],r)[0]),t.colr=s.colr(s.findBox(a,["colr"],r)[0])})}},{key:"av1C",value:function(i){return ne(i,!1,function(t,e){t.data=i.data;var r=wn.fromUint8(e),n=Vd.fromByte(r,4);t.marker=n.read(1),t.version=n.read(7),t.seqProfile=n.read(3),t.seqLevelIdx0=n.read(5),t.seqTier0=n.read(1),t.highBitdepth=n.read(1),t.twelveBit=n.read(1),t.monochrome=n.read(1),t.chromaSubsamplingX=n.read(1),t.chromaSubsamplingY=n.read(1),t.chromaSamplePosition=n.read(2),t.reserved=n.read(3),t.initialPresentationDelayPresent=n.read(1),t.initialPresentationDelayPresent?t.initialPresentationDelayMinusOne=n.read(4):t.initialPresentationDelayMinusOne=0,t.configOBUs=r.readToUint8();var a;t.seqLevelIdx0===2&&t.highBitdepth===1?a=t.twelveBit===1?"12":"10":t.seqProfile<=2&&(a=t.highBitdepth===1?"10":"08"),t.codec=["av01",t.seqProfile,(t.seqLevelIdx0<10?"0"+t.seqLevelIdx0:t.seqLevelIdx0)+(t.seqTier0?"H":"M"),a].join(".")})}},{key:"avc1",value:function(i){return ne(i,!1,function(t,e,r){var n=_n(t,e),a=e.subarray(n);r+=n,t.avcC=s.avcC(s.findBox(a,["avcC"],r)[0]),t.pasp=s.pasp(s.findBox(a,["pasp"],r)[0])})}},{key:"avcC",value:function(i){return ne(i,!1,function(t,e){t.data=i.data,t.configurationVersion=e[0],t.AVCProfileIndication=e[1],t.profileCompatibility=e[2],t.AVCLevelIndication=e[3],t.codec=Ho([e[1],e[2],e[3]]),t.lengthSizeMinusOne=e[4]&3,t.spsLength=e[5]&31,t.sps=[];for(var r=6,n=0;n>6,t.generalTierFlag=(r&32)>>5,t.generalProfileIdc=r&31,t.generalProfileCompatibility=z(e,2),t.generalConstraintIndicatorFlags=e.subarray(6,12),t.generalLevelIdc=e[12],t.avgFrameRate=Ce(e,19),t.numOfArrays=e[22],t.vps=[],t.sps=[],t.pps=[];for(var n=23,a=0,u=0,l=0,c=0;c>3;c===31&&l.length>=2&&(c=32+((l[0]&7)<<3)+((l[1]&224)>>5)),t.objectType=c,t.codec+=c.toString(16),t.codec[t.codec.length-1]==="."&&(t.codec=t.codec.substring(0,t.codec.length-1));return}else{t.codec[t.codec.length-1]==="."&&(t.codec=t.codec.substring(0,t.codec.length-1));return}}})}},{key:"alaw",value:function(i){return ne(i,!1,function(t,e){Za(t,e)})}},{key:"stts",value:function(i){return ne(i,!0,function(t,e){for(var r=z(e),n=[],a=4,u=0;ul&&n&1&&(t.dataOffset=-(~z(e,l)+1),l+=4),a>l&&n&4&&(t.firstSampleFlags=z(e,l),l+=4),t.samples=[],a>l)for(var c,d=0;d>>2,dependsOn:i[0]&3,isDependedOn:(i[1]&192)>>>6,hasRedundancy:(i[1]&48)>>>4,paddingValue:(i[1]&14)>>>1,isNonSyncSample:i[1]&1,degradationPriority:i[2]<<8|i[3]}}},{key:"moovToTrack",value:function(i,t,e){var r,n,a=i.trak;if(!(!a||!a.length)){var u=a.find(function(sn){var ci,di;return((ci=sn.mdia)===null||ci===void 0||(di=ci.hdlr)===null||di===void 0?void 0:di.handlerType)==="vide"}),l=a.find(function(sn){var ci,di;return((ci=sn.mdia)===null||ci===void 0||(di=ci.hdlr)===null||di===void 0?void 0:di.handlerType)==="soun"});if(u&&t){var c,d,h,f,m,g,y,L=t,k=(c=u.tkhd)===null||c===void 0?void 0:c.trackId;k!=null&&(L.id=u.tkhd.trackId),L.tkhdDuration=u.tkhd.duration,L.mvhdDurtion=i.mvhd.duration,L.mvhdTimecale=i.mvhd.timescale,L.timescale=L.formatTimescale=u.mdia.mdhd.timescale,L.duration=u.mdia.mdhd.duration||L.mvhdDurtion/L.mvhdTimecale*L.timescale,L.rotation=u.tkhd.rotation,L.matrix=u.tkhd.matrix;var _=u.mdia.minf.stbl.stsd.entries[0];if(L.width=_.width,L.height=_.height,_.pasp&&(L.sarRatio=[_.pasp.hSpacing,_.pasp.vSpacing]),_.av1C)L.codecType=Yt.AV1,L.codec=_.av1C.codec,L.av1C=_.av1C.data,L.colr=_.colr.data;else if(_.hvcC)L.codecType=Yt.HEVC,L.codec=_.hvcC.codec,L.vps=_.hvcC.vps,L.sps=_.hvcC.sps,L.pps=_.hvcC.pps,L.hvcC=_.hvcC.data;else if(_.avcC)L.codec=_.avcC.codec,L.sps=_.avcC.sps,L.pps=_.avcC.pps;else throw new Error("unknown video stsd entry");if(L.present=!0,L.ext={},L.ext.stss=(d=u.mdia)===null||d===void 0||(h=d.minf)===null||h===void 0||(f=h.stbl)===null||f===void 0?void 0:f.stss,L.ext.ctts=(m=u.mdia)===null||m===void 0||(g=m.minf)===null||g===void 0||(y=g.stbl)===null||y===void 0?void 0:y.ctts,_&&_.type==="encv"){var w,Z,C,R,E,P,I,D;L.isVideoEncryption=!0,_.default_KID=(w=_.sinf)===null||w===void 0||(Z=w.schi)===null||Z===void 0?void 0:Z.tenc.default_KID,_.default_IsEncrypted=(C=_.sinf)===null||C===void 0||(R=C.schi)===null||R===void 0?void 0:R.tenc.default_IsEncrypted,_.default_IV_size=(E=_.sinf)===null||E===void 0||(P=E.schi)===null||P===void 0?void 0:P.tenc.default_IV_size,L.videoSenc=u.mdia.minf.stbl.senc&&u.mdia.minf.stbl.senc.samples,_.data_format=(I=_.sinf)===null||I===void 0||(D=I.frma)===null||D===void 0?void 0:D.data_format,L.useEME=i.useEME,L.kidValue=i.kidValue,L.pssh=i.pssh,L.encv=_}}if(l&&e){var p,v,b,x,T,X,M,F,Y,U=e,te=(p=l.tkhd)===null||p===void 0?void 0:p.trackId;te!=null&&(U.id=l.tkhd.trackId),U.tkhdDuration=l.tkhd.duration,U.mvhdDurtion=i.mvhd.duration,U.mvhdTimecale=i.mvhd.timescale,U.timescale=U.formatTimescale=l.mdia.mdhd.timescale,U.duration=l.mdia.mdhd.duration||U.mvhdDurtion/U.mvhdTimecale*U.timescale;var O=l.mdia.minf.stbl.stsd.entries[0];switch(U.sampleSize=O.sampleSize,U.sampleRate=O.sampleRate,U.channelCount=O.channelCount,U.present=!0,O.type){case"alaw":U.codecType=U.codec=Me.G711PCMA,U.sampleRate=8e3;break;case"ulaw":U.codecType=U.codec=Me.G711PCMU,U.sampleRate=8e3;break;default:U.sampleDuration=Zt.getFrameDuration(U.sampleRate,U.timescale),U.sampleRateIndex=Zt.getRateIndexByRate(U.sampleRate),U.objectType=((r=O.esds)===null||r===void 0?void 0:r.objectType)||2,O.esds&&(U.config=Array.from(O.esds.config)),U.codec=((n=O.esds)===null||n===void 0?void 0:n.codec)||"mp4a.40.2";break}if(U.sampleDuration=Zt.getFrameDuration(U.sampleRate,U.timescale),U.objectType=((v=O.esds)===null||v===void 0?void 0:v.objectType)||2,O.esds&&(O.esds.config?U.config=Array.from(O.esds.config):console.warn("esds config is null")),U.codec=((b=O.esds)===null||b===void 0?void 0:b.codec)||"mp4a.40.2",U.sampleRateIndex=Zt.getRateIndexByRate(U.sampleRate),U.ext={},U.ext.stss=(x=l.mdia)===null||x===void 0||(T=x.minf)===null||T===void 0||(X=T.stbl)===null||X===void 0?void 0:X.stss,U.ext.ctts=(M=l.mdia)===null||M===void 0||(F=M.minf)===null||F===void 0||(Y=F.stbl)===null||Y===void 0?void 0:Y.ctts,U.present=!0,O&&O.type==="enca"){var _e,We,qe,Re,ti,be,Nt,St;U.isAudioEncryption=!0,O.data_format=(_e=O.sinf)===null||_e===void 0||(We=_e.frma)===null||We===void 0?void 0:We.data_format,O.default_KID=(qe=O.sinf)===null||qe===void 0||(Re=qe.schi)===null||Re===void 0?void 0:Re.tenc.default_KID,O.default_IsEncrypted=(ti=O.sinf)===null||ti===void 0||(be=ti.schi)===null||be===void 0?void 0:be.tenc.default_IsEncrypted,O.default_IV_size=(Nt=O.sinf)===null||Nt===void 0||(St=Nt.schi)===null||St===void 0?void 0:St.tenc.default_IV_size,U.audioSenc=l.mdia.minf.stbl.senc&&l.mdia.minf.stbl.senc.samples,U.useEME=i.useEME,U.kidValue=i.kidValue,U.enca=O}}if(e&&(e.isVideoEncryption=t?t.isVideoEncryption:!1),t&&(t.isAudioEncryption=e?e.isAudioEncryption:!1),t!=null&&t.encv||e!=null&&e.enca){var Ft,nn,Xs=t==null||(Ft=t.encv)===null||Ft===void 0?void 0:Ft.default_KID,Gs=e==null||(nn=e.enca)===null||nn===void 0?void 0:nn.default_KID,Is=Xs||Gs?(Xs||Gs).join(""):null;t&&(t.kid=Is),e&&(e.kid=Is)}return t&&(t.flags=3841),e&&(e.flags=1793),{videoTrack:t,audioTrack:e}}}},{key:"evaluateDefaultDuration",value:function(i,t,e){var r,n=t==null||(r=t.samples)===null||r===void 0?void 0:r.length;if(!n)return 1024;var a=1024*n/t.timescale;return a*i.timescale/e}},{key:"moofToSamples",value:function(i,t,e){var r={};return i.mfhd&&(t&&(t.sequenceNumber=i.mfhd.sequenceNumber),e&&(e.sequenceNumber=i.mfhd.sequenceNumber)),i.traf.forEach(function(n){var a=n.tfhd,u=n.tfdt,l=n.trun;if(!(!a||!l)){u&&(t&&t.id===a.trackId&&(t.baseMediaDecodeTime=u.baseMediaDecodeTime),e&&e.id===a.trackId&&(e.baseMediaDecodeTime=u.baseMediaDecodeTime));var c=a.defaultSampleSize||0,d=a.defaultSampleDuration||s.evaluateDefaultDuration(t,e,l.samples.length||l.sampleCount),h=l.dataOffset||0,f=0,m=-1;if(!l.samples.length&&l.sampleCount){r[a.trackId]=[];for(var g=0;g>>0!==65536},y.keyframe&&(m++,y.gopId=m),f+=y.duration,h+=y.size,y})}}),r}},{key:"moovToSamples",value:function(i){var t=i.trak;if(!(!t||!t.length)){var e=t.find(function(I){var D,p;return((D=I.mdia)===null||D===void 0||(p=D.hdlr)===null||p===void 0?void 0:p.handlerType)==="vide"}),r=t.find(function(I){var D,p;return((D=I.mdia)===null||D===void 0||(p=D.hdlr)===null||p===void 0?void 0:p.handlerType)==="soun"});if(!(!e&&!r)){var n,a;if(e){var u,l,c=(u=e.mdia)===null||u===void 0||(l=u.minf)===null||l===void 0?void 0:l.stbl;if(!c)return;var d=c.stts,h=c.stsc,f=c.stsz,m=c.stco,g=c.stss,y=c.ctts;if(!d||!h||!f||!m||!g)return;n=La(d,h,f,m,y,g)}if(r){var L,k,_,w=(L=r.mdia)===null||L===void 0||(k=L.minf)===null||k===void 0?void 0:k.stbl;if(!w)return;var Z=(_=r.mdia.mdhd)===null||_===void 0?void 0:_.timescale,C=w.stts,R=w.stsc,E=w.stsz,P=w.stco;if(!Z||!C||!R||!E||!P)return;a=La(C,R,E,P)}return{videoSamples:n,audioSamples:a}}}}}]),s}();function La(s,o,i,t,e,r){var n=[],a=e==null?void 0:e.entries,u=o.entries,l=t.entries,c=i.entrySizes,d=r==null?void 0:r.entries,h;d&&(h={},d.forEach(function(R){h[R-1]=!0}));var f;a&&(f=[],a.forEach(function(R){for(var E=R.count,P=R.offset,I=0;I=C&&(_++,C=u[_+1]?u[_+1].firstChunk-1:1/0),Z+=u[_].samplesPerChunk)}),n}function _n(s,o){return s.dataReferenceIndex=Ce(o,6),s.width=Ce(o,24),s.height=Ce(o,26),s.horizresolution=z(o,28),s.vertresolution=z(o,32),s.frameCount=Ce(o,40),s.depth=Ce(o,74),78}function Za(s,o){return s.dataReferenceIndex=Ce(o,6),s.channelCount=Ce(o,16),s.sampleSize=Ce(o,18),s.sampleRate=z(o,24)/65536,28}function ne(s,o,i){if(s){if(s.size!==s.data.length)throw new Error("box ".concat(s.type," size !== data.length"));var t={start:s.start,size:s.size,headerSize:s.headerSize,type:s.type};return o&&(t.version=s.data[s.headerSize],t.flags=Ed(s.data,s.headerSize+1),t.headerSize+=4),i(t,s.data.subarray(t.headerSize),t.start+t.headerSize),t}}var Dd=function(o,i,t){for(var e=String(t),r=i>>0,n=Math.ceil(r/e.length),a=[],u=String(o);n--;)a.push(e);return a.join("").substring(0,r-u.length)+u},Cn=function(){for(var o=[],i=arguments.length,t=new Array(i),e=0;ethis.__lastRemainDataStart&&t+i.byteLength>f;if(m){var g=i.subarray(this.__lastRemainData.byteLength+this.__lastRemainDataStart-t);d=ht(this.__lastRemainData,g),h=this.__lastRemainDataStart,this.__lastRemainData=null}else this.__lastRemainData=null,this.__lastRemainDataStart=0,this.__nextMoofStart=-1}if(!e){var y=se.findBox(d,["moov"])[0];if(!y)throw new Error("cannot found moov box");e=se.moov(y)}if(d){var L=h+d.byteLength;!u&&!l&&se.moovToTrack(e,n,a);var k=[];this.__nextMoofStart<0?se.findBox(d,["moof"],h).forEach(function(R){return k.push(R)}):this.__nextMoofStart>=h&&this.__nextMoofStart<=L-8&&se.findBox(d.subarray(this.__nextMoofStart-h),["moof"],this.__nextMoofStart).forEach(function(R){return k.push(R)}),k.filter(function(R){return R.size<=R.data.length}).forEach(function(R){var E=se.moof(R);r.__nextMoofStart=E.start+Math.max.apply(Math,Qe(E.traf.map(function(P){return P.trun.samples.reduce(function(I,D){return I+D.size},P.trun.dataOffset||0)}))),r.__loadedMoofWraps.push({start:E.start,nextMoofStart:r.__nextMoofStart,moof:E}),r.__loadedMoofWraps.sort(function(P,I){return P.start-I.start})});var _=yd(this.__loadedMoofWraps),w;try{var Z=function(){var E=w.value;if(E.start>L||E.nextMoofStartL)return!0;var X=new Ai((x.pts||x.dts)+D,x.dts+D);X.duration=x.duration,X.gopId=x.gopId,x.keyframe&&X.setToKeyframe();var M=d.subarray(T-h,T-h+x.size);if(X.data=M,!c)for(var F=0,Y=M.length-1;FL)return!0;var X=d.subarray(T-h,T-h+x.size);a.samples.push(new Rt(x.dts+p,X,x.duration)),r.__lastRemainDataStart=T+x.size}})})};for(_.s();!(w=_.n()).done;)var C=Z()}catch(R){_.e(R)}finally{_.f()}}return this.__lastRemainDataStart>h&&this.__lastRemainDataStart1?i-1:0),e=1;e>8&255,i&255])}},{key:"writeUint32",value:function(i){return new Uint8Array([i>>24,i>>16&255,i>>8&255,i&255])}}]),s}(),ka=Math.pow(2,32)-1,de=function(){function s(){Ze(this,s)}return ke(s,null,[{key:"box",value:function(i){for(var t=arguments.length,e=new Array(t>1?t-1:0),r=1;r>24&255,a[1]=n>>16&255,a[2]=n>>8&255,a[3]=n&255,a.set(i,4);var u=8;return e.forEach(function(l){a.set(l,u),u+=l.byteLength}),a}},{key:"ftyp",value:function(i){var t=i.find(function(e){return e.type===ai.VIDEO&&e.codecType===Yt.HEVC});return t?s.FTYPHEV1:s.FTYPAVC1}},{key:"initSegment",value:function(i){var t=s.ftyp(i),e=ht(t,s.moov(i));return e}},{key:"pssh",value:function(i){var t=new Uint8Array([1,0,0,0].concat([16,119,239,236,192,178,77,2,172,227,60,30,82,226,251,75],[0,0,0,1],ya(i.kid),[0,0,0,0]));return s.box(s.types.pssh,t)}},{key:"moov",value:function(i){if(i[0].useEME&&(i[0].encv||i[0].enca)){i[0].pssh||(i[0].pssh={kid:i[0].kid});var t=this.pssh(i[0].pssh);return s.box.apply(s,[s.types.moov,s.mvhd(i[0].mvhdDurtion||i[0].duration,i[0].mvhdTimecale||i[0].timescale),s.mvex(i)].concat(Qe(i.map(function(e){return s.trak(e)})),[t]))}else return s.box.apply(s,[s.types.moov,s.mvhd(i[0].mvhdDurtion||i[0].duration,i[0].mvhdTimecale||i[0].timescale)].concat(Qe(i.map(function(e){return s.trak(e)})),[s.mvex(i)]))}},{key:"mvhd",value:function(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,e=s.box(s.types.mvhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255,i>>24&255,i>>16&255,i>>8&255,i&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]));return e}},{key:"trak",value:function(i){var t=s.box(s.types.trak,s.tkhd(i.id,i.tkhdDuration||0,i.width,i.height),s.mdia(i));return t}},{key:"tkhd",value:function(i,t){var e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,n=s.box(s.types.tkhd,new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,i>>24&255,i>>16&255,i>>8&255,i&255,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,e>>8&255,e&255,0,0,r>>8&255,r&255,0,0]));return n}},{key:"mdia",value:function(i){var t=s.box(s.types.mdia,s.mdhd(i.duration,i.timescale),s.hdlr(i.type),s.minf(i));return t}},{key:"mdhd",value:function(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:9e4,e=s.box(s.types.mdhd,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,t>>24&255,t>>16&255,t>>8&255,t&255,i>>24&255,i>>16&255,i>>8&255,i&255,85,196,0,0]));return e}},{key:"hdlr",value:function(i){var t=s.box(s.types.hdlr,s.HDLR_TYPES[i]);return t}},{key:"minf",value:function(i){var t=s.box(s.types.minf,i.type===ai.VIDEO?s.VMHD:s.SMHD,s.DINF,s.stbl(i));return t}},{key:"stbl",value:function(i){var t=[];i&&i.ext&&i.ext.stss&&t.push(s.stss(i.ext.stss.entries));var e=s.box(s.types.stbl,s.stsd(i),s.STTS,t[0],s.STSC,s.STSZ,s.STCO);return e}},{key:"stsd",value:function(i){var t;i.type==="audio"?i.useEME&&i.enca?t=s.enca(i):i.codecType===Me.OPUS?t=s.opus(i):t=s.mp4a(i):i.useEME&&i.encv?t=s.encv(i):i.av1C?t=s.av01(i):t=s.avc1hev1(i);var e=s.box(s.types.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),t);return e}},{key:"enca",value:function(i){var t=i.enca.channelCount,e=i.enca.sampleRate,r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t,0,16,0,0,0,0,e>>8&255,e&255,0,0]),n=s.esds(i.config),a=s.sinf(i.enca);return s.box(s.types.enca,r,n,a)}},{key:"encv",value:function(i){var t,e,r=i.sps.length>0?i.sps[0]:[],n=i.pps.length>0?i.pps[0]:[],a=i.width,u=i.height,l=i.sarRatio[0],c=i.sarRatio[1],d=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a>>8&255,a&255,u>>8&255,u&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),h=new Uint8Array((t=(e=[1,r[1],r[2],r[3],255,225,r.length>>>8&255,r.length&255]).concat.apply(e,Qe(r)).concat([1,n.length>>>8&255,n.length&255])).concat.apply(t,Qe(n))),f=new Uint8Array([0,0,88,57,0,15,200,192,0,4,86,72]),m=s.sinf(i.encv),g=new Uint8Array([l>>24,l>>16&255,l>>8&255,l&255,c>>24,c>>16&255,c>>8&255,c&255]);return s.box(s.types.encv,d,s.box(s.types.avcC,h),s.box(s.types.btrt,f),m,s.box(s.types.pasp,g))}},{key:"schi",value:function(i){var t=new Uint8Array([]),e=s.tenc(i);return s.box(s.types.schi,t,e)}},{key:"tenc",value:function(i){var t=new Uint8Array([0,0,0,0,0,0,i.default_IsEncrypted&255,i.default_IV_size&255].concat(ya(i.default_KID)));return s.box(s.types.tenc,t)}},{key:"sinf",value:function(i){var t=new Uint8Array([]),e=new Uint8Array([i.data_format.charCodeAt(0),i.data_format.charCodeAt(1),i.data_format.charCodeAt(2),i.data_format.charCodeAt(3)]),r=new Uint8Array([0,0,0,0,99,101,110,99,0,1,0,0]),n=s.schi(i);return s.box(s.types.sinf,t,s.box(s.types.frma,e),s.box(s.types.schm,r),n)}},{key:"av01",value:function(i){return s.box(s.types.av01,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i.width>>8&255,i.width&255,i.height>>8&255,i.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),i.av1C,i.colr)}},{key:"avc1hev1",value:function(i){var t=i.codecType===Yt.HEVC,e=t?s.types.hvc1:s.types.avc1,r=t?s.hvcC(i):s.avcC(i),n=[new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,i.width>>8&255,i.width&255,i.height>>8&255,i.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),r];return t?n.push(s.box(s.types.fiel,new Uint8Array([1,0]))):i.sarRatio&&i.sarRatio.length>1&&n.push(s.pasp(i.sarRatio)),s.box.apply(s,[e].concat(n))}},{key:"avcC",value:function(i){var t,e,r=[],n=[],a;return i.sps.forEach(function(u){a=u.byteLength,r.push(a>>>8&255),r.push(a&255),r.push.apply(r,Qe(u))}),i.pps.forEach(function(u){a=u.byteLength,n.push(a>>>8&255),n.push(a&255),n.push.apply(n,Qe(u))}),s.box(s.types.avcC,new Uint8Array((t=(e=[1,r[3],r[4],r[5],255,224|i.sps.length]).concat.apply(e,r).concat([i.pps.length])).concat.apply(t,n)))}},{key:"hvcC",value:function(i){var t=i.hvcC;if(t instanceof ArrayBuffer||t instanceof Uint8Array)return t;var e=i.vps,r=i.sps,n=i.pps,a;if(t){var u=t.generalProfileCompatibilityFlags,l=t.generalConstraintIndicatorFlags,c=(e.length&&1)+(r.length&&1)+(n.length&&1);a=[1,t.generalProfileSpace<<6|t.generalTierFlag<<5|t.generalProfileIdc,u>>>24,u>>>16,u>>>8,u,l[0],l[1],l[2],l[3],l[4],l[5],t.generalLevelIdc,240,0,252,t.chromaFormatIdc|252,t.bitDepthLumaMinus8|248,t.bitDepthChromaMinus8|248,0,0,t.numTemporalLayers<<3|t.temporalIdNested<<2|3,c];var d=function(f){var m;a.push(f.length>>8,f.length),(m=a).push.apply(m,Qe(f))};e.length&&(a.push(160,0,e.length),e.forEach(d)),r.length&&(a.push(161,0,r.length),r.forEach(d)),n.length&&(a.push(162,0,n.length),n.forEach(d))}else a=[1,1,96,0,0,0,144,0,0,0,0,0,93,240,0,252,253,248,248,0,0,15,3,160,0,1,0,24,64,1,12,1,255,255,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,153,152,9,161,0,1,0,45,66,1,1,1,96,0,0,3,0,144,0,0,3,0,0,3,0,93,160,2,128,128,45,22,89,153,164,147,43,154,128,128,128,130,0,0,3,0,2,0,0,3,0,50,16,162,0,1,0,7,68,1,193,114,180,98,64];return s.box(s.types.hvcC,new Uint8Array(a))}},{key:"pasp",value:function(i){var t=hd(i,2),e=t[0],r=t[1];return s.box(s.types.pasp,new Uint8Array([e>>24,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255]))}},{key:"mp4a",value:function(i){return s.box(s.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount,0,16,0,0,0,0,i.sampleRate>>8&255,i.sampleRate&255,0,0]),i.config.length?s.esds(i.config):void 0)}},{key:"esds",value:function(i){var t=i.length,e=s.box(s.types.esds,new Uint8Array([0,0,0,0,3,23+t,0,0,0,4,15+t,64,21,0,6,0,0,0,218,192,0,0,218,192,5].concat([t]).concat(i).concat([6,1,2])));return e}},{key:"opus",value:function(i){var t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount,0,16,0,0,0,0,i.sampleRate>>8&255,i.sampleRate&255,0,0]),e=i.config.length?s.dOps(i):[];return s.box(s.types.Opus,t,e)}},{key:"dOps",value:function(i){if(i.config)return i.config[4]=i.sampleRate>>>24&255,i.config[5]=i.sampleRate>>>16&255,i.config[6]=i.sampleRate>>>8&255,i.config[7]=i.sampleRate&255,s.box(s.types.dOps,i.config)}},{key:"mvex",value:function(i){var t=s.box.apply(s,[s.types.mvex].concat(Qe(i.map(function(e){return s.trex(e.id)}))));return t}},{key:"trex",value:function(i){var t=s.box(s.types.trex,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]));return t}},{key:"trex1",value:function(i){var t=s.box(s.types.trex,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255,0,0,0,1,0,0,2,0,0,0,0,0,0,1,0,0]));return t}},{key:"trex2",value:function(i){var t=s.box(s.types.trex,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255,0,0,0,1,0,0,4,0,0,0,0,0,2,0,0,0]));return t}},{key:"moof",value:function(i){var t=s.box.apply(s,[s.types.moof,s.mfhd(i[0].samples?i[0].samples[0].gopId:0)].concat(Qe(i.map(function(e){return s.traf(e)}))));return t}},{key:"mfhd",value:function(i){var t=s.box(s.types.mfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255]));return t}},{key:"traf",value:function(i){var t=s.tfhd(i.id),e=s.tfdt(i,i.baseMediaDecodeTime),r=0,n;if(i.isVideo&&i.videoSenc&&(n=i.videoSenc,n.forEach(function(v){r=r+8,v.subsamples&&v.subsamples.length&&(r=r+2,r=r+v.subsamples.length*6)})),i.videoSencLength=r,!i.useEME||!i.isVideoEncryption&&!i.isAudioEncryption){var a=s.sdtp(i),u=76;return s.box(s.types.traf,t,e,a,s.trun(i.samples,a.byteLength+u))}else if(i.isVideoEncryption)if(i.isVideo){var l=s.saiz(i),c=s.saio(i),d=s.trun1(i),h=s.senc(i),f=s.box(s.types.traf,t,e,l,c,d,h);return f}else if(i.isAudioEncryption){var y=s.sbgp(),L=s.saiz(i),k=s.saio(i),_=s.senc(i),w=s.trun1(i),Z=s.box(s.types.traf,t,e,y,L,k,_,w);return Z}else{var m=s.sbgp(),g=s.trun1(i);return s.box(s.types.traf,t,e,m,g)}else if(i.isVideo){var C=s.trun1(i);return s.box(s.types.traf,t,e,C)}else{var R=s.sbgp(),E=s.saiz(i),P=s.saio(i),I=s.senc(i),D=s.trun1(i),p=s.box(s.types.traf,t,e,R,E,P,I,D);return p}}},{key:"sdtp",value:function(i){var t=new Fe;return i.samples.forEach(function(e){t.write(new Uint8Array(i.isVideo?[e.keyframe?32:16]:[16]))}),s.box(s.types.sdtp,this.extension(0,0),t.buffer)}},{key:"trun1",value:function(i){var t=new Fe,e=Fe.writeUint32(i.samples.length),r=null;if(i.isVideo){var n=i.videoSencLength;r=Fe.writeUint32(i.samples.length*16+n+149),!i.isVideoEncryption&&i.isAudioEncryption&&(r=Fe.writeUint32(i.samples.length*16+92))}else{var a=i.samples.length*12+124;i.isAudioEncryption&&(a=i.samples.length*12+8*i.audioSenc.length+177),r=Fe.writeUint32(a)}return i.samples.forEach(function(u){t.write(Fe.writeUint32(u.duration)),t.write(Fe.writeUint32(u.size)),t.write(Fe.writeUint32(u.keyframe?33554432:65536)),i.isVideo&&t.write(Fe.writeUint32(u.cts?u.cts:0))}),s.box(s.types.trun,this.extension(0,i.flags),e,r,t.buffer)}},{key:"senc",value:function(i){var t=new Fe,e=i.samples.length,r=i.isVideo?16:8,n=i.isVideo?2:0,a=[],u=0;return i.isVideo?(a=i.videoSenc,u=i.videoSencLength):a=i.audioSenc,u=u||r*e,t.write(Fe.writeUint32(16+u),s.types.senc,this.extension(0,n)),t.write(Fe.writeUint32(e)),a.forEach(function(l){for(var c=0;c>24&255,t>>16&255,t>>8&255,t&255]);return s.box(s.types.saio,e)}},{key:"saiz",value:function(i){var t=i.samples.length,e=new Uint8Array([0,0,0,0,16,t>>24&255,t>>16&255,t>>8&255,t&255]);return s.box(s.types.saiz,e)}},{key:"sbgp",value:function(){var i=new Uint8Array([114,111,108,108,0,0,0,1,0,0,1,25,0,0,0,1]);return s.box(s.types.sbgp,this.extension(0,0),i)}},{key:"extension",value:function(i,t){return new Uint8Array([i,t>>16&255,t>>8&255,t&255])}},{key:"tfhd",value:function(i){return s.box(s.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,i&255]))}},{key:"tfdt",value:function(i,t){var e=Math.floor(t/(ka+1)),r=Math.floor(t%(ka+1));return i.useEME&&(i.isVideoEncryption||i.isAudioEncryption)?s.box(s.types.tfdt,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])):s.box(s.types.tfdt,new Uint8Array([1,0,0,0,e>>24,e>>16&255,e>>8&255,e&255,r>>24,r>>16&255,r>>8&255,r&255]))}},{key:"trun",value:function(i,t){var e=i.length,r=12+16*e;t+=8+r;var n=new Uint8Array(r);n.set([0,0,15,1,e>>>24&255,e>>>16&255,e>>>8&255,e&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0);for(var a=0;a>>24&255,l>>>16&255,l>>>8&255,l&255,c>>>24&255,c>>>16&255,c>>>8&255,c&255,h.isLeading<<2|(h.dependsOn===null||h.dependsOn===void 0?1:h.dependsOn),h.isDependedOn<<6|h.hasRedundancy<<4|h.paddingValue<<1|(h.isNonSyncSample===null||h.isNonSyncSample===void 0?1:h.isNonSyncSample),h.degradationPriority&61440,h.degradationPriority&15,m>>>24&255,m>>>16&255,m>>>8&255,m&255],12+16*a)}return s.box(s.types.trun,n)}},{key:"moovMP4",value:function(i){return s.box.apply(s,[s.types.moov,s.mvhd(i[0].duration,i[0].timescale)].concat(Qe(i.map(function(t){return s.trackMP4(t)}))))}},{key:"trackMP4",value:function(i){return s.box(s.types.trak,s.tkhd(i.id,i.duration,i.width,i.height),s.mdiaMP4(i))}},{key:"mdiaMP4",value:function(i){return s.box(s.types.mdia,s.mdhd(i.duration,i.timescale),s.hdlr(i.type),s.minfMP4(i))}},{key:"minfMP4",value:function(i){return s.box(s.types.minf,i.type===ai.VIDEO?s.VMHD:s.SMHD,s.DINF,s.stblMP4(i))}},{key:"stblMP4",value:function(i){var t=i.ext,e=[s.stsd(i),s.stts(t.stts),s.stsc(t.stsc),s.stsz(t.stsz),s.stco(t.stco)];return t.stss.length&&e.push(s.stss(t.stss)),t.ctts.length&&e.push(s.ctts(t.ctts)),s.box.apply(s,[s.types.stbl].concat(e))}},{key:"stts",value:function(i){var t=i.length,e=new Uint8Array(8*t),r=0;return i.forEach(function(n){var a=n.value,u=n.count;e.set([u>>24,u>>16&255,u>>8&255,u&255,a>>24,a>>16&255,a>>8&255,a&255],r),r+=8}),s.box(s.types.stts,ht(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),e))}},{key:"stsc",value:function(i){var t=i.length,e=new Uint8Array(12*t),r=0;return i.forEach(function(n){var a=n.firstChunk,u=n.samplesPerChunk,l=n.sampleDescIndex;e.set([a>>24,a>>16&255,a>>8&255,a&255,u>>24,u>>16&255,u>>8&255,u&255,l>>24,l>>16&255,l>>8&255,l&255],r),r+=12}),s.box(s.types.stsc,ht(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),e))}},{key:"stsz",value:function(i){var t=i.length,e=new Uint8Array(4*t),r=0;return i.forEach(function(n){e.set([n>>24,n>>16&255,n>>8&255,n&255],r),r+=4}),s.box(s.types.stsz,ht(new Uint8Array([0,0,0,0,0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),e))}},{key:"stco",value:function(i){var t=i.length,e=new Uint8Array(4*t),r=0;return i.forEach(function(n){e.set([n>>24,n>>16&255,n>>8&255,n&255],r),r+=4}),s.box(s.types.stco,ht(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),e))}},{key:"stss",value:function(i){var t=i.length,e=new Uint8Array(4*t),r=0;return i.forEach(function(n){e.set([n>>24,n>>16&255,n>>8&255,n&255],r),r+=4}),s.box(s.types.stss,ht(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),e))}},{key:"ctts",value:function(i){var t=i.length,e=new Uint8Array(8*t),r=0;return i.forEach(function(n){var a=n.value,u=n.count;e.set([u>>24,u>>16&255,u>>8&255,u&255,a>>24,a>>16&255,a>>8&255,a&255],r),r+=8}),s.box(s.types.ctts,ht(new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255]),e))}},{key:"styp",value:function(){return s.box(s.types.styp,new Uint8Array([109,115,100,104,0,0,0,0,109,115,100,104,109,115,105,120]))}},{key:"sidx",value:function(i){var t=i.timescale,e=i.samples[0].duration,r=e*i.samples.length,n=i.samples[0].sampleOffset*e,a=8;i.samples.forEach(function(h){a+=h.size});var u=0;if(i.isVideo){var l=0,c;i.videoSenc&&(c=i.videoSenc),i.isVideo&&c.forEach(function(h){l=l+8,h.subsamples&&h.subsamples.length&&(l=l+2,l=l+h.subsamples.length*6)}),i.videoSencLength=l,u=a+141+i.samples.length*16+l,i.useEME&&i.isAudioEncryption&&!i.isVideoEncryption&&(u=a+i.samples.length*16+84)}else u=a+116+i.samples.length*12,i.useEME&&i.isAudioEncryption&&(u=a+169+i.samples.length*12+8*i.audioSenc.length);var d=new Uint8Array([0,0,0,0,0,0,0,i.id&255,t>>24&255,t>>16&255,t>>8&255,t&255,n>>24&255,n>>16&255,n>>8&255,n&255,0,0,0,0,0,0,0,1,0,u>>16&255,u>>8&255,u&255,r>>24&255,r>>16&255,r>>8&255,r&255,144,0,0,0]);return s.box(s.types.sidx,d)}},{key:"mdat",value:function(i){var t=s.box(s.types.mdat,i);return t}}]),s}();N(de,"types",["Opus","dOps","av01","av1C","avc1","avcC","hvc1","hvcC","dinf","dref","esds","ftyp","hdlr","mdat","mdhd","mdia","mfhd","minf","moof","moov","mp4a","mvex","mvhd","pasp","stbl","stco","stsc","stsd","stsz","stts","tfdt","tfhd","traf","trak","trex","tkhd","vmhd","smhd","ctts","stss","styp","pssh","sidx","sbgp","saiz","saio","senc","trun","encv","enca","sinf","btrt","frma","tenc","schm","schi","mehd","fiel","sdtp"].reduce(function(s,o){return s[o]=[o.charCodeAt(0),o.charCodeAt(1),o.charCodeAt(2),o.charCodeAt(3)],s},Object.create(null)));N(de,"HDLR_TYPES",{video:new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),audio:new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0])});N(de,"FTYPAVC1",de.box(de.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,97,118,99,49])));N(de,"FTYPHEV1",de.box(de.types.ftyp,new Uint8Array([105,115,111,109,0,0,0,1,105,115,111,109,104,101,118,49])));N(de,"DINF",de.box(de.types.dinf,de.box(de.types.dref,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]))));N(de,"VMHD",de.box(de.types.vmhd,new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])));N(de,"SMHD",de.box(de.types.smhd,new Uint8Array([0,0,0,0,0,0,0,0])));N(de,"StblTable",new Uint8Array([0,0,0,0,0,0,0,0]));N(de,"STTS",de.box(de.types.stts,de.StblTable));N(de,"STSC",de.box(de.types.stsc,de.StblTable));N(de,"STSZ",de.box(de.types.stsz,new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0])));N(de,"STCO",de.box(de.types.stco,de.StblTable));var ws=function(){function s(o,i){Ze(this,s),this.name=o||"",this._prefix="[".concat(this.name,"]"),s.disabled=i}return ke(s,[{key:"debug",value:function(){var i;if(!s.disabled){for(var t=arguments.length,e=new Array(t),r=0;r0&&arguments[0]!==void 0?arguments[0]:!1,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},e=this.videoTrack,r=this.audioTrack,n=e.exist(),a=r.exist(),u,l,c,d=[];i&&(t&&t.initMerge?(n&&d.push(this.videoTrack),a&&d.push(this.audioTrack),c=de.initSegment(d)):(n&&(u=de.initSegment([this.videoTrack])),a&&(l=de.initSegment([this.audioTrack]))));var h,f;return n&&e.hasSample()&&(h=this._remuxVideo()),a&&r.hasSample()&&(f=this._remuxAudio()),e.samples=[],r.samples=[],{initSegment:c,videoInitSegment:u,audioInitSegment:l,videoSegment:h,audioSegment:f}}},{key:"_remuxVideo",value:function(){var i=this.videoTrack;this.forceFirstIDR&&(i.samples[0].flag={dependsOn:2,isNonSyncSample:0});var t=i.samples,e=/av01/.test(i.codec),r=0;e?t.forEach(function(_){r+=_.data.byteLength}):t.forEach(function(_){r+=_.units.reduce(function(w,Z){return w+Z.byteLength},0),r+=_.units.length*4});var n=new Uint8Array(r);if(e)for(var a=0,u=t.length,l=0,c;a>>2]|=t[n]<<24-n%4*8;this.words=r,this.sigBytes=e}else this.words=o,this.sigBytes=i}static random(o){const i=[],t=e=>{let r=e,n=987654321;const a=4294967295;return()=>{n=36969*(n&65535)+(n>>16)&a,r=18e3*(r&65535)+(r>>16)&a;let u=(n<<16)+r&a;return u/=4294967296,u+=.5,u*(Math.random()>.5?1:-1)}};for(let e=0,r;e>>2]>>>24-n%4*8&255;i[e+n>>>2]|=a<<24-(e+n)%4*8}else for(let n=0;n>>2]=t[n>>>2];return this.sigBytes+=r,this}clamp(){const{words:o,sigBytes:i}=this;o[i>>>2]&=4294967295<<32-i%4*8,o.length=Math.ceil(i/4)}clone(){const o=super.clone.call(this);return o.words=this.words.slice(0),o}}const On={stringify(s){const{words:o,sigBytes:i}=s,t=[];for(let e=0;e>>2]>>>24-e%4*8&255;t.push((r>>>4).toString(16)),t.push((r&15).toString(16))}return t.join("")},parse(s){const o=s.length,i=[];for(let t=0;t>>3]|=parseInt(s.substr(t,2),16)<<24-t%8*4;return new st(i,o/2)}},Ta={stringify(s){const{words:o,sigBytes:i}=s,t=[];for(let e=0;e>>2]>>>24-e%4*8&255;t.push(String.fromCharCode(r))}return t.join("")},parse(s){const o=s.length,i=[];for(let t=0;t>>2]|=(s.charCodeAt(t)&255)<<24-t%4*8;return new st(i,o)}},zo={stringify(s){try{return decodeURIComponent(escape(Ta.stringify(s)))}catch{throw new Error("Malformed UTF-8 data")}},parse(s){return Ta.parse(unescape(encodeURIComponent(s)))}};class Bo extends rt{constructor(){super(),this._minBufferSize=0}reset(){this._data=new st,this._nDataBytes=0}_append(o){let i=o;typeof i=="string"&&(i=zo.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes}_process(o){let i;const{_data:t,blockSize:e}=this,r=t.words,n=t.sigBytes,a=e*4;let u=n/a;o?u=Math.ceil(u):u=Math.max((u|0)-this._minBufferSize,0);const l=u*e,c=Math.min(l*4,n);if(l){for(let d=0;dnew o(t).finalize(i)}static _createHmacHelper(o){return(i,t)=>new Fd(o,t).finalize(i)}reset(){super.reset.call(this),this._doReset()}update(o){return this._append(o),this._process(),this}finalize(o){return o&&this._append(o),this._doFinalize()}}class Fd extends rt{constructor(o,i){super();const t=new o;this._hasher=t;let e=i;typeof e=="string"&&(e=zo.parse(e));const r=t.blockSize,n=r*4;e.sigBytes>n&&(e=t.finalize(i)),e.clamp();const a=e.clone();this._oKey=a;const u=e.clone();this._iKey=u;const l=a.words,c=u.words;for(let d=0;d{const t=[];let e=0;for(let r=0;r>>6-r%4*2,u=n|a;t[e>>>2]|=u<<24-e%4*8,e+=1}return st.create(t,e)},wa={stringify(s){const{words:o,sigBytes:i}=s,t=this._map;s.clamp();const e=[];for(let n=0;n>>2]>>>24-n%4*8&255,u=o[n+1>>>2]>>>24-(n+1)%4*8&255,l=o[n+2>>>2]>>>24-(n+2)%4*8&255,c=a<<16|u<<8|l;for(let d=0;d<4&&n+d*.75>>6*(3-d)&63))}const r=t.charAt(64);if(r)for(;e.length%4;)e.push(r);return e.join("")},parse(s){let o=s.length;const i=this._map;let t=this._reverseMap;if(!t){this._reverseMap=[],t=this._reverseMap;for(let r=0;r{const a=s+(o&i|~o&t)+e+n;return(a<>>32-r)+o},Ae=(s,o,i,t,e,r,n)=>{const a=s+(o&t|i&~t)+e+n;return(a<>>32-r)+o},ze=(s,o,i,t,e,r,n)=>{const a=s+(o^i^t)+e+n;return(a<>>32-r)+o},Be=(s,o,i,t,e,r,n)=>{const a=s+(i^(o|~t))+e+n;return(a<>>32-r)+o};class Ud extends Nd{_doReset(){this._hash=new st([1732584193,4023233417,2562383102,271733878])}_doProcessBlock(o,i){const t=o;for(let P=0;P<16;P+=1){const I=i+P,D=o[I];t[I]=(D<<8|D>>>24)&16711935|(D<<24|D>>>8)&4278255360}const e=this._hash.words,r=t[i+0],n=t[i+1],a=t[i+2],u=t[i+3],l=t[i+4],c=t[i+5],d=t[i+6],h=t[i+7],f=t[i+8],m=t[i+9],g=t[i+10],y=t[i+11],L=t[i+12],k=t[i+13],_=t[i+14],w=t[i+15];let Z=e[0],C=e[1],R=e[2],E=e[3];Z=Oe(Z,C,R,E,r,7,j[0]),E=Oe(E,Z,C,R,n,12,j[1]),R=Oe(R,E,Z,C,a,17,j[2]),C=Oe(C,R,E,Z,u,22,j[3]),Z=Oe(Z,C,R,E,l,7,j[4]),E=Oe(E,Z,C,R,c,12,j[5]),R=Oe(R,E,Z,C,d,17,j[6]),C=Oe(C,R,E,Z,h,22,j[7]),Z=Oe(Z,C,R,E,f,7,j[8]),E=Oe(E,Z,C,R,m,12,j[9]),R=Oe(R,E,Z,C,g,17,j[10]),C=Oe(C,R,E,Z,y,22,j[11]),Z=Oe(Z,C,R,E,L,7,j[12]),E=Oe(E,Z,C,R,k,12,j[13]),R=Oe(R,E,Z,C,_,17,j[14]),C=Oe(C,R,E,Z,w,22,j[15]),Z=Ae(Z,C,R,E,n,5,j[16]),E=Ae(E,Z,C,R,d,9,j[17]),R=Ae(R,E,Z,C,y,14,j[18]),C=Ae(C,R,E,Z,r,20,j[19]),Z=Ae(Z,C,R,E,c,5,j[20]),E=Ae(E,Z,C,R,g,9,j[21]),R=Ae(R,E,Z,C,w,14,j[22]),C=Ae(C,R,E,Z,l,20,j[23]),Z=Ae(Z,C,R,E,m,5,j[24]),E=Ae(E,Z,C,R,_,9,j[25]),R=Ae(R,E,Z,C,u,14,j[26]),C=Ae(C,R,E,Z,f,20,j[27]),Z=Ae(Z,C,R,E,k,5,j[28]),E=Ae(E,Z,C,R,a,9,j[29]),R=Ae(R,E,Z,C,h,14,j[30]),C=Ae(C,R,E,Z,L,20,j[31]),Z=ze(Z,C,R,E,c,4,j[32]),E=ze(E,Z,C,R,f,11,j[33]),R=ze(R,E,Z,C,y,16,j[34]),C=ze(C,R,E,Z,_,23,j[35]),Z=ze(Z,C,R,E,n,4,j[36]),E=ze(E,Z,C,R,l,11,j[37]),R=ze(R,E,Z,C,h,16,j[38]),C=ze(C,R,E,Z,g,23,j[39]),Z=ze(Z,C,R,E,k,4,j[40]),E=ze(E,Z,C,R,r,11,j[41]),R=ze(R,E,Z,C,u,16,j[42]),C=ze(C,R,E,Z,d,23,j[43]),Z=ze(Z,C,R,E,m,4,j[44]),E=ze(E,Z,C,R,L,11,j[45]),R=ze(R,E,Z,C,w,16,j[46]),C=ze(C,R,E,Z,a,23,j[47]),Z=Be(Z,C,R,E,r,6,j[48]),E=Be(E,Z,C,R,h,10,j[49]),R=Be(R,E,Z,C,_,15,j[50]),C=Be(C,R,E,Z,c,21,j[51]),Z=Be(Z,C,R,E,L,6,j[52]),E=Be(E,Z,C,R,u,10,j[53]),R=Be(R,E,Z,C,g,15,j[54]),C=Be(C,R,E,Z,n,21,j[55]),Z=Be(Z,C,R,E,f,6,j[56]),E=Be(E,Z,C,R,w,10,j[57]),R=Be(R,E,Z,C,d,15,j[58]),C=Be(C,R,E,Z,k,21,j[59]),Z=Be(Z,C,R,E,l,6,j[60]),E=Be(E,Z,C,R,y,10,j[61]),R=Be(R,E,Z,C,a,15,j[62]),C=Be(C,R,E,Z,m,21,j[63]),e[0]=e[0]+Z|0,e[1]=e[1]+C|0,e[2]=e[2]+R|0,e[3]=e[3]+E|0}_doFinalize(){const o=this._data,i=o.words,t=this._nDataBytes*8,e=o.sigBytes*8;i[e>>>5]|=128<<24-e%32;const r=Math.floor(t/4294967296),n=t;i[(e+64>>>9<<4)+15]=(r<<8|r>>>24)&16711935|(r<<24|r>>>8)&4278255360,i[(e+64>>>9<<4)+14]=(n<<8|n>>>24)&16711935|(n<<24|n>>>8)&4278255360,o.sigBytes=(i.length+1)*4,this._process();const a=this._hash,u=a.words;for(let l=0;l<4;l+=1){const c=u[l];u[l]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360}return a}clone(){const o=super.clone.call(this);return o._hash=this._hash.clone(),o}}class Kd extends rt{constructor(o){super(),this.cfg=Object.assign(new rt,{keySize:128/32,hasher:Ud,iterations:1},o)}compute(o,i){let t;const{cfg:e}=this,r=e.hasher.create(),n=st.create(),a=n.words,{keySize:u,iterations:l}=e;for(;a.lengthtypeof t=="string"?$o:Oi;return{encrypt(t,e,r){return i(e).encrypt(o,t,e,r)},decrypt(t,e,r){return i(e).decrypt(o,t,e,r)}}}reset(){super.reset.call(this),this._doReset()}process(o){return this._append(o),this._process()}finalize(o){return o&&this._append(o),this._doFinalize()}}dr._ENC_XFORM_MODE=1;dr._DEC_XFORM_MODE=2;dr.keySize=128/32;dr.ivSize=128/32;class Jo extends rt{constructor(o,i){super(),this._cipher=o,this._iv=i}static createEncryptor(o,i){return this.Encryptor.create(o,i)}static createDecryptor(o,i){return this.Decryptor.create(o,i)}}function jo(s,o,i){const t=s;let e;const r=this._iv;r?(e=r,this._iv=void 0):e=this._prevBlock;for(let n=0;n>>2]&255;o.sigBytes-=i}};class Qo extends dr{constructor(o,i,t){super(o,i,Object.assign({mode:rr,padding:Od},t)),this.blockSize=128/32}reset(){let o;super.reset.call(this);const{cfg:i}=this,{iv:t,mode:e}=i;this._xformMode===this.constructor._ENC_XFORM_MODE?o=e.createEncryptor:(o=e.createDecryptor,this._minBufferSize=1),this._mode=o.call(e,this,t&&t.words),this._mode.__creator=o}_doProcessBlock(o,i){this._mode.processBlock(o,i)}_doFinalize(){let o;const{padding:i}=this.cfg;return this._xformMode===this.constructor._ENC_XFORM_MODE?(i.pad(this._data,this.blockSize),o=this._process(!0)):(o=this._process(!0),i.unpad(o)),o}}class en extends rt{constructor(o){super(),this.mixIn(o)}toString(o){return(o||this.formatter).stringify(this)}}const Ad={stringify(s){let o;const{ciphertext:i,salt:t}=s;return t?o=st.create([1398893684,1701076831]).concat(t).concat(i):o=i,o.toString(wa)},parse(s){let o;const i=wa.parse(s),t=i.words;return t[0]===1398893684&&t[1]===1701076831&&(o=st.create(t.slice(2,4)),t.splice(0,4),i.sigBytes-=16),en.create({ciphertext:i,salt:o})}};class Oi extends rt{static encrypt(o,i,t,e){const r=Object.assign(new rt,this.cfg,e),n=o.createEncryptor(t,r),a=n.finalize(i),u=n.cfg;return en.create({ciphertext:a,key:t,iv:u.iv,algorithm:o,mode:u.mode,padding:u.padding,blockSize:n.blockSize,formatter:r.format})}static decrypt(o,i,t,e){let r=i;const n=Object.assign(new rt,this.cfg,e);return r=this._parse(r,n.format),o.createDecryptor(t,n).finalize(r.ciphertext)}static _parse(o,i){return typeof o=="string"?i.parse(o,this):o}}Oi.cfg=Object.assign(new rt,{format:Ad});const zd={execute(s,o,i,t){let e=t;e||(e=st.random(64/8));const r=Kd.create({keySize:o+i}).compute(s,e),n=st.create(r.words.slice(o),i*4);return r.sigBytes=o*4,en.create({key:r,iv:n,salt:e})}};class $o extends Oi{static encrypt(o,i,t,e){const r=Object.assign(new rt,this.cfg,e),n=r.kdf.execute(t,o.keySize,o.ivSize);r.iv=n.iv;const a=Oi.encrypt.call(this,o,i,n.key,r);return a.mixIn(n),a}static decrypt(o,i,t,e){let r=i;const n=Object.assign(new rt,this.cfg,e);r=this._parse(r,n.format);const a=n.kdf.execute(t,o.keySize,o.ivSize,r.salt);return n.iv=a.iv,Oi.decrypt.call(this,o,r,a.key,n)}}$o.cfg=Object.assign(Oi.cfg,{kdf:zd});const lt=[],qo=[],eu=[],tu=[],iu=[],ru=[],An=[],zn=[],Bn=[],Jn=[],_t=[];for(let s=0;s<256;s+=1)s<128?_t[s]=s<<1:_t[s]=s<<1^283;let wt=0,Ht=0;for(let s=0;s<256;s+=1){let o=Ht^Ht<<1^Ht<<2^Ht<<3^Ht<<4;o=o>>>8^o&255^99,lt[wt]=o,qo[o]=wt;const i=_t[wt],t=_t[i],e=_t[t];let r=_t[o]*257^o*16843008;eu[wt]=r<<24|r>>>8,tu[wt]=r<<16|r>>>16,iu[wt]=r<<8|r>>>24,ru[wt]=r,r=e*16843009^t*65537^i*257^wt*16843008,An[o]=r<<24|r>>>8,zn[o]=r<<16|r>>>16,Bn[o]=r<<8|r>>>24,Jn[o]=r,wt?(wt=i^_t[_t[_t[e^i]]],Ht^=_t[_t[Ht]]):(Ht=1,wt=Ht)}const Bd=[0,1,2,4,8,16,32,64,128,27,54];class nu extends Qo{_doReset(){let o;if(this._nRounds&&this._keyPriorReset===this._key)return;this._keyPriorReset=this._key;const i=this._keyPriorReset,t=i.words,e=i.sigBytes/4;this._nRounds=e+6;const n=(this._nRounds+1)*4;this._keySchedule=[];const a=this._keySchedule;for(let l=0;l6&&l%e===4&&(o=lt[o>>>24]<<24|lt[o>>>16&255]<<16|lt[o>>>8&255]<<8|lt[o&255]):(o=o<<8|o>>>24,o=lt[o>>>24]<<24|lt[o>>>16&255]<<16|lt[o>>>8&255]<<8|lt[o&255],o^=Bd[l/e|0]<<24),a[l]=a[l-e]^o);this._invKeySchedule=[];const u=this._invKeySchedule;for(let l=0;l>>24]]^zn[lt[o>>>16&255]]^Bn[lt[o>>>8&255]]^Jn[lt[o&255]]}}encryptBlock(o,i){this._doCryptBlock(o,i,this._keySchedule,eu,tu,iu,ru,lt)}decryptBlock(o,i){const t=o;let e=t[i+1];t[i+1]=t[i+3],t[i+3]=e,this._doCryptBlock(t,i,this._invKeySchedule,An,zn,Bn,Jn,qo),e=t[i+1],t[i+1]=t[i+3],t[i+3]=e}_doCryptBlock(o,i,t,e,r,n,a,u){const l=o,c=this._nRounds;let d=l[i]^t[0],h=l[i+1]^t[1],f=l[i+2]^t[2],m=l[i+3]^t[3],g=4;for(let w=1;w>>24]^r[h>>>16&255]^n[f>>>8&255]^a[m&255]^t[g];g+=1;const C=e[h>>>24]^r[f>>>16&255]^n[m>>>8&255]^a[d&255]^t[g];g+=1;const R=e[f>>>24]^r[m>>>16&255]^n[d>>>8&255]^a[h&255]^t[g];g+=1;const E=e[m>>>24]^r[d>>>16&255]^n[h>>>8&255]^a[f&255]^t[g];g+=1,d=Z,h=C,f=R,m=E}const y=(u[d>>>24]<<24|u[h>>>16&255]<<16|u[f>>>8&255]<<8|u[m&255])^t[g];g+=1;const L=(u[h>>>24]<<24|u[f>>>16&255]<<16|u[m>>>8&255]<<8|u[d&255])^t[g];g+=1;const k=(u[f>>>24]<<24|u[m>>>16&255]<<16|u[d>>>8&255]<<8|u[h&255])^t[g];g+=1;const _=(u[m>>>24]<<24|u[d>>>16&255]<<16|u[h>>>8&255]<<8|u[f&255])^t[g];g+=1,l[i]=y,l[i+1]=L,l[i+2]=k,l[i+3]=_}}nu.keySize=256/32;const Jd=Qo._createHelper(nu);class nr extends Jo{}nr.Encryptor=class extends nr{processBlock(s,o){const i=s,t=this._cipher,{blockSize:e}=t,r=this._iv;let n=this._counter;r&&(this._counter=r.slice(0),n=this._counter,this._iv=void 0);const a=n.slice(0);t.encryptBlock(a,0),n[e-1]=n[e-1]+1|0;for(let u=0;u>>24,r===i||(e[r++]=(a&16711680)>>>16,r===i)||(e[r++]=(a&65280)>>>8,r===i))break;e[r++]=a&255}return e},decoderAESCTRData:function(o,i,t){if(o.videoSenc){var e=o.kidValue,r=o.videoSenc;o.samples.forEach(function(u,l){var c=r[l],d=u.data,h=[],f=[],m=c.InitializationVector;if(c.subsamples&&c.subsamples.length)c.subsamples.forEach(function(_){var w=_.BytesOfClearData+_.BytesOfProtectedData,Z=d.slice(0,w);h.push(Z.slice(0,_.BytesOfClearData)),f.push(Z.slice(_.BytesOfClearData)),d=d.slice(w)});else{var g=u.size;h.push(d.slice(0,0)),f.push(d.slice(0,g)),d=d.slice(g)}var y=new Fe;y.write.apply(y,f);var L=t?t(y.buffer,e,m):Er.decryptWordArray(y.buffer,e,m),k=new Fe;h.forEach(function(_,w){var Z=f[w].length,C=L.slice(0,Z);k.write(_),k.write(C),L=L.slice(Z)}),o.samples[l].data=k.buffer})}if(i.audioSenc){var n=i.kidValue,a=i.audioSenc;i.samples.forEach(function(u,l){var c=a[l],d=t?t(u.data,n,c.InitializationVector):Er.decryptWordArray(u.data,n,c.InitializationVector);i.samples[l].data=d})}}},_a=20,Qd=function(){function s(o,i,t,e){var r=this;Ze(this,s),N(this,"_videoSamples",[]),N(this,"_audioSamples",[]),N(this,"_lastRemainBuffer",[]),N(this,"_lastRemainBufferStartPos",0),this.videoTrack=new jr,this.audioTrack=new Qr,this.metadataTrack=t||new $r,this.log=new ws("MP4Demuxer",e&&e.openLog?!e.openLog:!0),o&&o.forEach(function(n){var a;(a=r._videoSamples).push.apply(a,Qe(n.frames))}),i&&i.forEach(function(n){var a;(a=r._audioSamples).push.apply(a,Qe(n.frames))})}return ke(s,[{key:"parseSamples",value:function(i){if(!i)throw new Error("moov is required");if(!this.videoTrack.codec&&!this.audioTrack.codec&&(se.moovToTrack(i,this.videoTrack,this.audioTrack),this.videoSenc=this.videoTrack.videoSenc,this.audioSenc=this.audioTrack.audioSenc),!this._audioSamples.length&&!this._videoSamples.length){var t=se.moovToSamples(i);if(!t)throw new Error("cannot parse samples from moov box");this._videoSamples=t.videoSamples||[],this._audioSamples=t.audioSamples||[]}}},{key:"demux",value:function(i,t,e,r,n){this.parseSamples(n);var a=this.videoTrack,u=this.audioTrack;a.samples=[],u.samples=[];var l,c,d;if(e){for(var h,f=0,m=e[0],g=e[1];m<=g;m++){if(l=this._videoSamples[m],!l)throw new Error("cannot found video frame #".concat(m));d=l.offset-t,c=i.subarray(d,d+l.size),h=new Ai(l.pts||l.dts,l.dts),h.duration=l.duration,h.gopId=l.gopId,l.keyframe&&h.setToKeyframe();for(var y=0,L=c.length-1;y0&&t>this._lastRemainBufferStartPos&&t<=this._lastRemainBufferStartPos+this._lastRemainBuffer.byteLength)for(var c=0;c<_a;)try{var d=this._lastRemainBuffer.subarray(0,t-this._lastRemainBufferStartPos),h=new Uint8Array(i.byteLength+d.byteLength);h.set(d,0),h.set(new Uint8Array(i),d.byteLength),i=h,t-=d.byteLength,this._lastRemainBuffer=null,this._lastRemainBufferStartPos=0;break}catch(v){if(c<_a)c++;else throw new Error("new Uint8Array error:,"+v.errorMessage)}var f=this.videoTrack,m=this.audioTrack;f.samples=[],m.samples=[],f.videoSenc=null,m.audioSenc=null;var g,y,L,k=0,_=0;if(this._videoSamples.length>0&&e.length>0){for(var w,Z=i.byteLength+t,C=e[0];C<=e[1];C++){if(g=this._videoSamples[C],!g)throw new Error("cannot found video frame #".concat(C));g.offset>=t&&g.offset+g.size<=Z&&(L=g.offset-t,k=L+g.size,y=i.subarray(L,k),w=new Ai(g.pts||g.dts,g.dts),w.duration=g.duration,w.gopId=g.gopId,w.sampleOffset=g.index,g.keyframe&&w.setToKeyframe(),w.data=y,w.size=g.size,f.samples.push(w))}f.samples.length>0&&(f.gopId=f.samples[0].gopId,f.baseMediaDecodeTime=f.samples[0].dts,f.startPts=f.samples[0].pts/f.timescale,f.endPts=f.samples[f.samples.length-1].pts/f.timescale,this.videoSenc&&(f.videoSenc=this.videoSenc.slice(f.samples[0].sampleOffset,f.samples[0].sampleOffset+f.samples.length),f.kidValue=u))}if(this._audioSamples.length>0&&r.length>0){for(var R=r[0];R<=r[1];R++){if(g=this._audioSamples[R],!g)throw new Error("cannot found video frame #".concat(R));g.offset>=t&&g.offset+g.size<=i.byteLength+t&&(L=g.offset-t,_=L+g.size,y=i.subarray(L,_),m.samples.push(new Rt(g.dts,y,g.duration,g.index)))}m.samples.length>0&&(m.gopId=m.samples[0].gopId||f.gopId,m.baseMediaDecodeTime=m.samples[0].dts,m.startPts=m.samples[0].pts/m.timescale,m.endPts=m.samples[m.samples.length-1].pts/m.timescale,this.audioSenc&&(m.audioSenc=this.audioSenc.slice(m.samples[0].sampleOffset,m.samples[0].sampleOffset+m.samples.length),m.kidValue=u))}this.decoderData(f,m,l);for(var E=0,P=0;P0?this._lastRemainBufferStartPos=t+i.byteLength-this._lastRemainBuffer.byteLength:this._lastRemainBufferStartPos=0,{videoTrack:f,audioTrack:m,metadataTrack:this.metadataTrack}}},{key:"reset",value:function(){this._videoSamples=[],this._audioSamples=[],this._lastRemainBuffer=null,this._lastRemainBufferStartPos=0,this.videoTrack.reset(),this.audioTrack.reset(),this.metadataTrack.reset()}},{key:"decoderData",value:function(i,t,e){i.useEME||t.useEME||Er.decoderAESCTRData(i,t,e)}}],[{key:"probe",value:function(i){return se.probe(i)}}]),s}(),su="3.0.20";function Ca(s,o){var i=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);o&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable})),i.push.apply(i,t)}return i}function sr(s){for(var o=1;o=0;--x){var T=this.tryEntries[x],X=T.completion;if(T.tryLoc==="root")return b("end");if(T.tryLoc<=this.prev){var M=i.call(T,"catchLoc"),F=i.call(T,"finallyLoc");if(M&&F){if(this.prev=0;--b){var x=this.tryEntries[b];if(x.tryLoc<=this.prev&&i.call(x,"finallyLoc")&&this.prev=0;--v){var b=this.tryEntries[v];if(b.finallyLoc===p)return this.complete(b.completion,b.afterLoc),E(b),d}},catch:function(p){for(var v=this.tryEntries.length-1;v>=0;--v){var b=this.tryEntries[v];if(b.tryLoc===p){var x=b.completion;if(x.type==="throw"){var T=x.arg;E(b)}return T}}throw new Error("illegal catch attempt")},delegateYield:function(p,v,b){return this.delegate={iterator:I(p),resultName:v,nextLoc:b},this.method==="next"&&(this.arg=void 0),d}},s}function ki(s){"@babel/helpers - typeof";return ki=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},ki(s)}function Ea(s,o,i,t,e,r,n){try{var a=s[r](n),u=a.value}catch(l){i(l);return}a.done?o(u):Promise.resolve(u).then(t,e)}function Jt(s){return function(){var o=this,i=arguments;return new Promise(function(t,e){var r=s.apply(o,i);function n(u){Ea(r,t,e,n,a,"next",u)}function a(u){Ea(r,t,e,n,a,"throw",u)}n(void 0)})}}function mt(s,o){if(!(s instanceof o))throw new TypeError("Cannot call a class as a function")}function xa(s,o){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function xr(s,o,i){return au()?xr=Reflect.construct.bind():xr=function(e,r,n){var a=[null];a.push.apply(a,r);var u=Function.bind.apply(e,a),l=new u;return n&&ar(l,n.prototype),l},xr.apply(null,arguments)}function $d(s){return Function.toString.call(s).indexOf("[native code]")!==-1}function Hr(s){var o=typeof Map=="function"?new Map:void 0;return Hr=function(t){if(t===null||!$d(t))return t;if(typeof t!="function")throw new TypeError("Super expression must either be null or a function");if(typeof o<"u"){if(o.has(t))return o.get(t);o.set(t,e)}function e(){return xr(t,arguments,Ti(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),ar(e,t)},Hr(s)}function qd(s,o){if(s==null)return{};var i={},t=Object.keys(s),e,r;for(r=0;r=0)&&(i[e]=s[e]);return i}function eh(s,o){if(s==null)return{};var i=qd(s,o),t,e;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);for(e=0;e=0)&&Object.prototype.propertyIsEnumerable.call(s,t)&&(i[t]=s[t])}return i}function ee(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function th(s,o){if(o&&(typeof o=="object"||typeof o=="function"))return o;if(o!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ee(s)}function fr(s){var o=au();return function(){var t=Ti(s),e;if(o){var r=Ti(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return th(this,e)}}function ih(s,o){for(;!Object.prototype.hasOwnProperty.call(s,o)&&(s=Ti(s),s!==null););return s}function Rr(){return typeof Reflect<"u"&&Reflect.get?Rr=Reflect.get.bind():Rr=function(o,i,t){var e=ih(o,i);if(e){var r=Object.getOwnPropertyDescriptor(e,i);return r.get?r.get.call(arguments.length<3?o:t):r.value}},Rr.apply(this,arguments)}function rh(s,o){if(s){if(typeof s=="string")return Ra(s,o);var i=Object.prototype.toString.call(s).slice(8,-1);if(i==="Object"&&s.constructor&&(i=s.constructor.name),i==="Map"||i==="Set")return Array.from(s);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return Ra(s,o)}}function Ra(s,o){(o==null||o>s.length)&&(o=s.length);for(var i=0,t=new Array(o);i=s.length?{done:!0}:{done:!1,value:s[t++]}},e:function(u){throw u},f:e}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var r=!0,n=!1,a;return{s:function(){i=i.call(s)},n:function(){var u=i.next();return r=u.done,u},e:function(u){n=!0,a=u},f:function(){try{!r&&i.return!=null&&i.return()}finally{if(n)throw a}}}}function sh(s,o){if(typeof s!="object"||s===null)return s;var i=s[Symbol.toPrimitive];if(i!==void 0){var t=i.call(s,o||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(s)}function ou(s){var o=sh(s,"string");return typeof o=="symbol"?o:String(o)}var Xe=function(){function s(){mt(this,s)}return pt(s,null,[{key:"start",value:function(i){return!i||!i.length||i.length===1&&i.end(0)-i.start(0)<1e-6||i.length===1&&i.start(0)<0?0:i.start(0)}},{key:"end",value:function(i){return!i||!i.length||i.length===1&&i.end(0)-i.start(0)<1e-6?0:i.end(i.length-1)}},{key:"get",value:function(i){if(i)try{return i.buffered}catch{}}},{key:"buffers",value:function(i,t){if(!i||!i.length)return[];for(var e=[],r=0,n=i.length;rl&&(u[1]=d)}else e.push([i.start(r),i.end(r)])}}return e}},{key:"totalLength",value:function(i){return!i||!i.length?0:i.reduce(function(t,e){return t+=e[1]-e[0]},0)}},{key:"info",value:function(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(!i||!i.length)return{start:0,end:0,buffers:[]};for(var r=0,n=0,a=0,u=0,l=0,c=0,d=0,h=s.buffers(i,e),f=0,m=h.length;f=g[0]&&t<=g[1])r=g[0],n=g[1],a=f;else if(t+eg[1]&&(c=g[0],d=g[1])}return{start:r,end:n,index:a,buffers:h,nextStart:u,nextEnd:l,prevStart:c,prevEnd:d,currentTime:t,behind:t-r,remaining:n?n-t:0,length:s.totalLength&&s.totalLength(h)}}},{key:"isBuffered",value:function(i,t){if(i){var e=s.get(i);if(e!=null&&e.length){for(var r=0;r=e.start(r)&&t<=e.end(r))return!0}}return!1}}]),s}(),ah=typeof window<"u",ot,B={MANIFEST:"manifest",NETWORK:"network",NETWORK_TIMEOUT:"network_timeout",NETWORK_FORBIDDEN:"network_forbidden",NETWORK_NOTFOUND:"network_notfound",NETWROK_RANGE_NOT_SATISFIABLE:"network_range_not_satisfiable",DEMUX:"demux",REMUX:"remux",MEDIA:"media",DRM:"drm",OTHER:"other",RUNTIME:"runtime",SUB_TYPES:{FLV:"FLV",HLS:"HLS",MP4:"MP4",FMP4:"FMP4",MSE_ADD_SB:"MSE_ADD_SB",MSE_APPEND_BUFFER:"MSE_APPEND_BUFFER",MSE_OTHER:"MSE_OTHER",MSE_FULL:"MSE_FULL",MSE_CHANGE_TYPE:"MSE_CHANGE_TYPE",OPTION:"OPTION",DASH:"DASH",LICENSE:"LICENSE",CUSTOM_LICENSE:"CUSTOM_LICENSE",MSE_HIJACK:"MSE_HIJACK",EME_HIJACK:"EME_HIJACK",SIDX:"SIDX",NO_CANPLAY_ERROR:"NO_CANPLAY_ERROR",BUFFERBREAK_ERROR:"BUFFERBREAK_ERROR",WAITING_TIMEOUT_ERROR:"WAITING_TIMEOUT_ERROR",MEDIA_ERR_ABORTED:"MEDIA_ERR_ABORTED",MEDIA_ERR_NETWORK:"MEDIA_ERR_NETWORK",MEDIA_ERR_DECODE:"MEDIA_ERR_DECODE",MEDIA_ERR_SRC_NOT_SUPPORTED:"MEDIA_ERR_SRC_NOT_SUPPORTED",MEDIA_ERR_CODEC_NOT_SUPPORTED:"MEDIA_ERR_CODEC_NOT_SUPPORTED",MEDIA_ERR_URL_EMPTY:"MEDIA_ERR_URL_EMPTY"}},Ie=(ot={},H(ot,B.MANIFEST,{HLS:1100,DASH:1200}),H(ot,B.NETWORK,2100),H(ot,B.NETWORK_TIMEOUT,2101),H(ot,B.NETWORK_FORBIDDEN,2103),H(ot,B.NETWORK_NOTFOUND,2104),H(ot,B.NETWROK_RANGE_NOT_SATISFIABLE,2116),H(ot,B.DEMUX,{FLV:3100,HLS:3200,MP4:3300,FMP4:3400,SIDX:3410}),H(ot,B.REMUX,{FMP4:4100,MP4:4200}),H(ot,B.MEDIA,{MEDIA_ERR_ABORTED:5101,MEDIA_ERR_NETWORK:5102,MEDIA_ERR_DECODE:5103,MEDIA_ERR_SRC_NOT_SUPPORTED:5104,MEDIA_ERR_CODEC_NOT_SUPPORTED:5105,MEDIA_ERR_URL_EMPTY:5106,MSE_ADD_SB:5200,MSE_APPEND_BUFFER:5201,MSE_OTHER:5202,MSE_FULL:5203,MSE_HIJACK:5204,MSE_CHANGE_TYPE:5205,EME_HIJACK:5301}),H(ot,B.DRM,{LICENSE:7100,CUSTOM_LICENSE:7200}),H(ot,B.OTHER,8e3),H(ot,B.RUNTIME,{NO_CANPLAY_ERROR:9001,BUFFERBREAK_ERROR:9002,WAITING_TIMEOUT_ERROR:9003}),ot),we=function(s){hr(i,s);var o=fr(i);function i(t,e,r,n,a){var u;return mt(this,i),u=o.call(this,a||(r==null?void 0:r.message)),u.errorType=t===B.NETWORK_TIMEOUT?B.NETWORK:t,u.originError=r,u.ext=n,u.errorCode=Ie[t][e]||Ie[t],u.errorMessage=u.message,u.errorCode||(u.errorType=B.OTHER,u.errorCode=Ie[u.errorType]),u}return pt(i,null,[{key:"create",value:function(e,r,n,a,u){return e instanceof i?e:(e instanceof Error&&(n=e,e=""),e||(e=B.OTHER),new i(e,r,n,a,u))}},{key:"network",value:function(e){var r;return new i(e!=null&&e.isTimeout?B.NETWORK_TIMEOUT:B.NETWORK,null,e instanceof Error?e:null,{url:e==null?void 0:e.url,response:e==null?void 0:e.response,httpCode:e==null||(r=e.response)===null||r===void 0?void 0:r.status})}}]),i}(Hr(Error)),Lr={DEBUG:1,LOG:2,WARN:3,ERROR:4},oh=200*1024,uh=["Boolean","Number","String","Undefined","Null","Date","Object"],$e=function(){function s(o,i){mt(this,s),this.name=o||"",this._prefix="[".concat(this.name,"]"),this.logCacheLevel=(i==null?void 0:i.logCacheLevel)||3,this.logMaxSize=(i==null?void 0:i.logMaxSize)||oh,this.logSize=0,this.logTextArray=[]}return pt(s,[{key:"debug",value:function(){for(var i,t=arguments.length,e=new Array(t),r=0;r1?e-1:0),n=1;n=this.logCacheLevel&&(this.logSize+=t.length,this.logTextArray.push(t)),this.logSize>this.logMaxSize){var u=this.logTextArray.shift();this.logSize-=u.length}}}},{key:"getLogCache",value:function(){var i=this.logTextArray.join(` `);return this.reset(),i}},{key:"reset",value:function(){this.logTextArray=[],this.logSize=0}},{key:"table",value:function(){var i;s.disabled||(console.group(this._prefix),(i=console).table.apply(i,arguments),console.groupEnd())}},{key:"setLogLevel",value:function(i){this.logCacheLevel=i}}],[{key:"enable",value:function(){s.disabled=!1}},{key:"disable",value:function(){s.disabled=!0}}]),s}();H($e,"disabled",!0);function $i(){return new Date().toLocaleString()}function lh(s){if(ki(s)!=="object")return s;var o=Object.prototype.toString.call(s).slice(8,-1);switch(o){case"Array":case"Uint8Array":case"ArrayBuffer":return o+"["+s.length+"]";case"Object":return"{}";default:return o}}function uu(s,o,i){i||(i=1),o||(o=2);var t={};if(!s||ki(s)!=="object")return s;var e=Object.prototype.toString.call(s).slice(8,-1);if(!uh.includes(e))return e;if(!(i>o)){for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&(i===o?t[r]=lh(s[r]):ki(s[r])==="object"?t[r]=uu(s[r],o,i+1):t[r]=s[r]);return t}}function Fi(){var s,o,i=new Promise(function(t,e){s=t,o=e});return i.used=!1,i.resolve=function(){return i.used=!0,s.apply(void 0,arguments)},i.reject=function(){return i.used=!0,o.apply(void 0,arguments)},i}function Ni(){try{return parseInt(performance.now(),10)}catch{return new Date().getTime()}}var ch={stringify:function(o){try{return JSON.stringify(o)}catch{return""}},parse:function(o){try{return JSON.parse(o)}catch{return}}};function Xa(){var s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;try{return ah?s&&typeof ManagedMediaSource<"u"?ManagedMediaSource:window.MediaSource:null}catch{}}function En(s){return/ManagedMediaSource/gi.test(Object.prototype.toString.call(s))}function dh(s){var o=[];if(s instanceof TimeRanges)for(var i=0;i0))}),t}},{key:"url",get:function(){return this._url}},{key:"duration",get:function(){var i;return((i=this.mediaSource)===null||i===void 0?void 0:i.duration)||-1}},{key:"isEnded",get:function(){return this.mediaSource?this.mediaSource.readyState==="ended":!1}},{key:"streaming",get:function(){return En(this.mediaSource)?this.mediaSource.streaming:!0}},{key:"isFull",value:function(i){return i?this._mseFullFlag[i]:this._mseFullFlag[s.VIDEO]}},{key:"updateDuration",value:function(i){var t=this,e=this.mediaSource&&this.mediaSource.duration>i;if(this.mediaSource&&this.mediaSource.duration>i){var r=0;if(Object.keys(this._sourceBuffer).forEach(function(n){try{r=Math.max(t.bufferEnd(n)||0,r)}catch{}}),i=1,a=r.readyState==="open",n&&a)try{r.endOfStream()}catch{}Object.keys(this._sourceBuffer).forEach(function(c){try{r.removeSourceBuffer(e._sourceBuffer[c])}catch{}}),En(r)&&(r.removeEventListener("startstreaming",this._onStartStreaming),r.removeEventListener("endstreaming",this._onEndStreaming))}if(this.media){this.media.disableRemotePlayback=!1,this.media.removeAttribute("src");try{this.media.load()}catch{}this.media=null}this.mediaSource=null,this._openPromise=Fi(),this._queue=Object.create(null),this._sourceBuffer=Object.create(null);case 8:case"end":return l.stop()}},t,this)}));function i(){return o.apply(this,arguments)}return i}()},{key:"createSource",value:function(i,t){if(!(this._sourceBuffer[i]||!this.mediaSource)){var e;try{e=this._sourceBuffer[i]=this.mediaSource.addSourceBuffer(t)}catch(r){throw new we(B.MEDIA,B.SUB_TYPES.MSE_ADD_SB,r)}e.mimeType=t,e.addEventListener("updateend",this._onSBUpdateEnd.bind(this,i)),e.addEventListener("error",this._onSBUpdateError.bind(this,i))}}},{key:"changeType",value:function(i,t){var e=this,r=this._sourceBuffer[i];return!this.mediaSource||!r||r.mimeType===t?Promise.resolve():typeof r.changeType!="function"?Promise.reject(new we(B.MEDIA,B.SUB_TYPES.MSE_CHANGE_TYPE,new Error("changeType is not a function"))):this._enqueueOp(i,function(){try{r.changeType(t)}catch(n){throw new we(B.MEDIA,B.SUB_TYPES.MSE_CHANGE_TYPE,n)}r.mimeType=t,e._onSBUpdateEnd(i)},"changeType",{mimeType:t})}},{key:"createOrChangeSource",value:function(i,t){return this.createSource(i,t),this.changeType(i,t)}},{key:"append",value:function(i,t,e){var r=this;return!t||!t.byteLength||!this._sourceBuffer[i]?Promise.resolve():this._enqueueOp(i,function(){var n;!r.mediaSource||r.media.error||(r._logger.debug("MSE APPEND START",e),r._opst=Ni(),(n=r._sourceBuffer[i])===null||n===void 0||n.appendBuffer(t))},Zr.APPEND,e)}},{key:"remove",value:function(i,t,e,r){var n=this,a=!1;return this._mseFullFlag[i]&&(a=!0),this._enqueueOp(i,function(){if(!(!n.mediaSource||n.media.error)){var u=n._sourceBuffer[i];if(t>=e||!u){n._onSBUpdateEnd(i);return}n._opst=Ni(),n._logger.debug("MSE REMOVE START",i,t,e,r),u.remove(t,e)}},Zr.REMOVE,r,a)}},{key:"clearBuffer",value:function(i,t){var e=this,r;return Object.keys(this._sourceBuffer).forEach(function(n){r=e.remove(n,i,t)}),r||Promise.resolve()}},{key:"clearAllBuffer",value:function(){var i=this,t;return Object.keys(this._sourceBuffer).forEach(function(e){var r=i._sourceBuffer[e];t=i.remove(e,0,Xe.end(Xe.get(r)))}),t}},{key:"clearOpQueues",value:function(i,t){var e;this._logger.debug("MSE clearOpQueue START");var r=this._queue[i];if(t&&r){this._queue[i]=[];return}if(!(!r||!r[i]||r.length<5)){var n=[];r.forEach(function(a){a.context&&a.context.isinit&&n.push(a)}),this._queue[i]=r.slice(0,2),n.length>0&&(e=this._queue[i]).push.apply(e,n)}}},{key:"endOfStream",value:function(i){var t=this;return!this.mediaSource||this.mediaSource.readyState!=="open"?Promise.resolve():this._enqueueBlockingOp(function(){var e=t.mediaSource;!e||e.readyState!=="open"||(t._logger.debug("MSE endOfStream START"),i?e.endOfStream(i):e.endOfStream())},"endOfStream")}},{key:"setLiveSeekableRange",value:function(i,t){var e=this.mediaSource;i<0||t=0?(this._mseFullFlag[i]=!0,e.context&&ki(e.context)==="object"&&(e.context.isFull=!0),this._logger.error("[MSE error], context,",e.context," ,name,",e.opName,",err,SourceBuffer is full"),e.promise.reject(new we(B.MEDIA,B.SUB_TYPES.MSE_FULL,r))):(this._logger.error(r),e.promise.reject(r.constructor===we?r:new we(B.MEDIA,B.SUB_TYPES.MSE_OTHER,r)),t.shift(),this._startQueue(i))}}}},{key:"setTimeoffset",value:function(i,t,e){var r=this;return this._enqueueOp(i,function(){t<0&&(t+=.001),r._sourceBuffer[i].timestampOffset=t,r._onSBUpdateEnd(i)},"setTimeoffset",e)}},{key:"abort",value:function(i,t){var e=this;return this.isOpened?this._enqueueOp(i,function(){e._sourceBuffer[i].abort(),e._onSBUpdateEnd(i)},"abort",t):Promise.resolve()}}],[{key:"isSupported",value:function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:'video/mp4; codecs="avc1.42E01E,mp4a.40.2"',t=Xa();if(!t)return!1;try{return t.isTypeSupported(i)}catch(e){return this._logger.error(i,e),!1}}},{key:"isMMSOnly",value:function(){return typeof ManagedMediaSource<"u"&&typeof MediaSource>"u"}},{key:"getDefaultConfig",value:function(){return{openLog:!1,preferMMS:!1}}}]),s}();H(Ee,"VIDEO","video");H(Ee,"AUDIO","audio");var vi={FETCH:"fetch",XHR:"xhr"},or={ARRAY_BUFFER:"arraybuffer",TEXT:"text",JSON:"json"},Dt=function(s){hr(i,s);var o=fr(i);function i(t,e,r,n){var a;return mt(this,i),a=o.call(this,n),H(ee(a),"retryCount",0),H(ee(a),"isTimeout",!1),H(ee(a),"loaderType",vi.FETCH),H(ee(a),"startTime",0),H(ee(a),"endTime",0),H(ee(a),"options",{}),a.url=t,a.request=e,a.response=r,a}return pt(i)}(Hr(Error)),lu=Object.prototype.toString;function hh(s){return s!==null&&ki(s)==="object"}function Ga(s){if(lu.call(s)!=="[object Object]")return!1;var o=Object.getPrototypeOf(s);return o===null||o===Object.prototype}function fh(s){return lu.call(s)==="[object Date]"}function cu(s){if(!(!s||s[0]===null||s[0]===void 0||s[0]===0&&(s[1]===null||s[1]===void 0))){var o="bytes="+s[0]+"-";return s[1]&&(o+=s[1]),o}}function Ia(s){return encodeURIComponent(s).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function du(s,o){if(s){if(!o)return s;var i,t=Object.keys(o).map(function(r){if(i=o[r],i!=null)return Array.isArray(i)?r=r+"[]":i=[i],i.map(function(n){return fh(n)?n=n.toISOString():hh(n)&&(n=JSON.stringify(n)),"".concat(Ia(r),"=").concat(Ia(n))}).join("&")}).filter(Boolean).join("&");if(t){var e=s.indexOf("#");e!==-1&&(s=s.slice(0,e)),s+=(s.indexOf("?")===-1?"?":"&")+t}return s}}function jn(s,o,i,t,e,r,n,a,u,l,c){e=e!=null?parseFloat(e):null,t=parseInt(t||"0",10),Number.isNaN(t)&&(t=0);var d={range:u,vid:l,index:a,contentLength:t,age:e,startTime:r,firstByteTime:n,endTime:Date.now(),priOptions:c};return{data:s,done:o,options:d,response:i}}function Qn(s,o){return Math.round(s*8*1e3/o/1024)}var K={ERROR:"error",TTFB:"core.ttfb",LOAD_START:"core.loadstart",LOAD_RESPONSE_HEADERS:"core.loadresponseheaders",LOAD_COMPLETE:"core.loadcomplete",LOAD_RETRY:"core.loadretry",SOURCEBUFFER_CREATED:"core.sourcebuffercreated",MEDIASOURCE_OPENED:"core.mediasourceopened",ANALYZE_DURATION_EXCEEDED:"core.analyzedurationexceeded",APPEND_BUFFER:"core.appendbuffer",REMOVE_BUFFER:"core.removebuffer",BUFFEREOS:"core.buffereos",KEYFRAME:"core.keyframe",CHASEFRAME:"core.chaseframe",METADATA_PARSED:"core.metadataparsed",SEI:"core.sei",SEI_IN_TIME:"core.seiintime",FLV_SCRIPT_DATA:"core.flvscriptdata",LOWDECODE:"core.lowdecode",SWITCH_URL_SUCCESS:"core.switchurlsuccess",SWITCH_URL_FAILED:"core.switchurlfailed",SPEED:"core.speed",HLS_MANIFEST_LOADED:"core.hlsmanifestloaded",HLS_LEVEL_LOADED:"core.hlslevelloaded",DEMUXED_TRACK:"core.demuxedtrack",STREAM_EXCEPTION:"core.streamexception",LARGE_AV_FIRST_FRAME_GAP_DETECT:"LARGE_AV_FIRST_FRAME_GAP_DETECT",LARGE_VIDEO_DTS_GAP_DETECT:"LARGE_VIDEO_DTS_GAP_DETECT",LARGE_AUDIO_DTS_GAP_DETECT:"LARGE_AUDIO_DTS_GAP_DETECT",AUDIO_GAP_DETECT:"AUDIO_GAP_DETECT",AUDIO_OVERLAP_DETECT:"AUDIO_OVERLAP_DETECT",MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT:"MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT",REAL_TIME_SPEED:"real_time_speed"},Wa=2*1024*1024,$n=function(s){hr(i,s);var o=fr(i);function i(){var t;return mt(this,i),t=o.call(this),H(ee(t),"_abortController",null),H(ee(t),"_timeoutTimer",null),H(ee(t),"_reader",null),H(ee(t),"_response",null),H(ee(t),"_aborted",!1),H(ee(t),"_index",-1),H(ee(t),"_range",null),H(ee(t),"_receivedLength",0),H(ee(t),"_running",!1),H(ee(t),"_logger",null),H(ee(t),"_vid",""),H(ee(t),"_onProcessMinLen",0),H(ee(t),"_onCancel",null),H(ee(t),"_priOptions",null),t}return pt(i,[{key:"load",value:function(e){var r,n=this,a=e.url,u=e.vid,l=e.timeout,c=e.responseType,d=e.onProgress,h=e.index,f=e.onTimeout,m=e.onCancel,g=e.range,y=e.transformResponse,L=e.request,k=e.params,_=e.logger,w=e.method,Z=e.headers,C=e.body,R=e.mode,E=e.credentials,P=e.cache,I=e.redirect,D=e.referrer,p=e.referrerPolicy,v=e.onProcessMinLen,b=e.priOptions;this._logger=_,this._aborted=!1,this._onProcessMinLen=v,this._onCancel=m,this._abortController=typeof AbortController<"u"&&new AbortController,this._running=!0,this._index=h,this._range=g||[0,0],this._vid=u||a,this._priOptions=b||{};var x={method:w,headers:Z,body:C,mode:R,credentials:E,cache:P,redirect:I,referrer:D,referrerPolicy:p,signal:(r=this._abortController)===null||r===void 0?void 0:r.signal},T=!1;clearTimeout(this._timeoutTimer),a=du(a,k);var X=cu(g);X&&(L?Z=L.headers:Z=x.headers=x.headers||(Headers?new Headers:{}),Headers&&Z instanceof Headers?Z.append("Range",X):Z.Range=X),l&&(this._timeoutTimer=setTimeout(function(){if(T=!0,n.cancel(),f){var F=new Dt(a,x,null,"timeout");F.isTimeout=!0,f(F,{index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions})}},l));var M=Date.now();return this._logger.debug("[fetch load start], index,",h,",range,",g),new Promise(function(F,Y){fetch(L||a,L?void 0:x).then(function(){var U=Jt(Ve().mark(function te(O){var _e,We,qe,Re;return Ve().wrap(function(be){for(;;)switch(be.prev=be.next){case 0:if(clearTimeout(n._timeoutTimer),n._response=O,!(n._aborted||!n._running)){be.next=4;break}return be.abrupt("return");case 4:if(y&&(O=y(O,a)||O),O.ok){be.next=7;break}throw new Dt(a,x,O,"bad network response");case 7:if(_e=Date.now(),c!==or.TEXT){be.next=15;break}return be.next=11,O.text();case 11:We=be.sent,n._running=!1,be.next=37;break;case 15:if(c!==or.JSON){be.next=22;break}return be.next=18,O.json();case 18:We=be.sent,n._running=!1,be.next=37;break;case 22:if(!d){be.next=29;break}return n.resolve=F,n.reject=Y,n._loadChunk(O,d,M,_e),be.abrupt("return");case 29:return be.next=31,O.arrayBuffer();case 31:We=be.sent,We=new Uint8Array(We),n._running=!1,qe=Date.now()-M,Re=Qn(We.byteLength,qe),n.emit(K.REAL_TIME_SPEED,{speed:Re,len:We.byteLength,time:qe,vid:n._vid,index:n._index,range:n._range,priOptions:n._priOptions});case 37:n._logger.debug("[fetch load end], index,",h,",range,",g),F(jn(We,!0,O,O.headers.get("Content-Length"),O.headers.get("age"),M,_e,h,g,n._vid,n._priOptions));case 39:case"end":return be.stop()}},te)}));return function(te){return U.apply(this,arguments)}}()).catch(function(U){var te;clearTimeout(n._timeoutTimer),n._running=!1,!(n._aborted&&!T)&&(U=U instanceof Dt?U:new Dt(a,x,null,(te=U)===null||te===void 0?void 0:te.message),U.startTime=M,U.endTime=Date.now(),U.isTimeout=T,U.options={index:n._index,range:n._range,vid:n._vid,priOptions:n._priOptions},Y(U))})})}},{key:"cancel",value:function(){var t=Jt(Ve().mark(function r(){return Ve().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._aborted){a.next=2;break}return a.abrupt("return");case 2:if(this._aborted=!0,this._running=!1,!this._response){a.next=14;break}if(a.prev=5,!this._reader){a.next=9;break}return a.next=9,this._reader.cancel();case 9:a.next=13;break;case 11:a.prev=11,a.t0=a.catch(5);case 13:this._response=this._reader=null;case 14:if(this._abortController){try{this._abortController.abort()}catch{}this._abortController=null}this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions});case 16:case"end":return a.stop()}},r,this,[[5,11]])}));function e(){return t.apply(this,arguments)}return e}()},{key:"_loadChunk",value:function(e,r,n,a){var u=this;if(!e.body||!e.body.getReader){this._running=!1;var l=new Dt(e.url,"",e,"onProgress of bad response.body.getReader");l.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this.reject(l);return}this._onProcessMinLen>0&&(this._cache=new Uint8Array(Wa),this._writeIdx=0);var c=this._reader=e.body.getReader(),d,h,f,m=function(){var g=Jt(Ve().mark(function y(){var L,k,_,w,Z,C,R,E;return Ve().wrap(function(I){for(;;)switch(I.prev=I.next){case 0:return h=Date.now(),I.prev=1,I.next=4,c.read();case 4:d=I.sent,f=Date.now(),I.next=13;break;case 8:return I.prev=8,I.t0=I.catch(1),f=Date.now(),u._aborted||(u._running=!1,I.t0.options={index:u._index,range:u._range,vid:u._vid,priOptions:u._priOptions},u.reject(I.t0)),I.abrupt("return");case 13:if(k=((L=u._range)===null||L===void 0?void 0:L.length)>0?u._range[0]:0,_=k+u._receivedLength,!u._aborted){I.next=19;break}return u._running=!1,r(void 0,!1,{range:[_,_],vid:u._vid,index:u._index,startTime:h,endTime:f,st:n,firstByteTime:a,priOptions:u._priOptions},e),I.abrupt("return");case 19:w=d.value?d.value.byteLength:0,u._receivedLength+=w,u._logger.debug("【fetchLoader,onProgress call】,task,",u._range,", start,",_,", end,",k+u._receivedLength,", done,",d.done),u._onProcessMinLen>0?u._writeIdx+w>=u._onProcessMinLen||d.done?(Z=new Uint8Array(u._writeIdx+w),Z.set(u._cache.slice(0,u._writeIdx),0),w>0&&Z.set(d.value,u._writeIdx),u._writeIdx=0,u._logger.debug("【fetchLoader,onProgress enough】,done,",d.done,",len,",Z.byteLength,", writeIdx,",u._writeIdx)):w>0&&u._writeIdx+w0&&(C=new Uint8Array(u._writeIdx+w+2048),u._logger.debug("【fetchLoader,onProgress extra start】,size,",u._writeIdx+w+2048,", datalen,",w,", writeIdx,",u._writeIdx),C.set(u._cache.slice(0,u._writeIdx),0),w>0&&C.set(d.value,u._writeIdx),u._writeIdx+=w,delete u._cache,u._cache=C,u._logger.debug("【fetchLoader,onProgress extra end】,len,",w,", writeIdx,",u._writeIdx)):Z=d.value,(Z&&Z.byteLength>0||d.done)&&r(Z,d.done,{range:[u._range[0]+u._receivedLength-(Z?Z.byteLength:0),u._range[0]+u._receivedLength],vid:u._vid,index:u._index,startTime:h,endTime:f,st:n,firstByteTime:a,priOptions:u._priOptions},e),d.done?(R=Date.now()-n,E=Qn(u._receivedLength,R),u.emit(K.REAL_TIME_SPEED,{speed:E,len:u._receivedLength,time:R,vid:u._vid,index:u._index,range:u._range,priOptions:u._priOptions}),u._running=!1,u._logger.debug("[fetchLoader onProgress end],task,",u._range,",done,",d.done),u.resolve(jn(d,!0,e,e.headers.get("Content-Length"),e.headers.get("age"),n,a,u._index,u._range,u._vid,u._priOptions))):m();case 25:case"end":return I.stop()}},y,null,[[1,8]])}));return function(){return g.apply(this,arguments)}}();m()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}}],[{key:"isSupported",value:function(){return typeof fetch<"u"}}]),i}(at);function mh(s){return sr({loaderType:vi.FETCH,retry:0,retryDelay:0,timeout:0,request:null,onTimeout:void 0,onProgress:void 0,onRetryError:void 0,transformRequest:void 0,transformResponse:void 0,transformError:void 0,responseType:or.TEXT,range:void 0,url:"",params:void 0,method:"GET",headers:{},body:void 0,mode:void 0,credentials:void 0,cache:void 0,redirect:void 0,referrer:void 0,referrerPolicy:void 0,integrity:void 0,onProcessMinLen:0},s)}var ph=function(s){hr(i,s);var o=fr(i);function i(){var t;return mt(this,i),t=o.call(this),H(ee(t),"_xhr",null),H(ee(t),"_aborted",!1),H(ee(t),"_timeoutTimer",null),H(ee(t),"_range",null),H(ee(t),"_receivedLength",0),H(ee(t),"_url",null),H(ee(t),"_onProgress",null),H(ee(t),"_index",-1),H(ee(t),"_headers",null),H(ee(t),"_currentChunkSizeKB",384),H(ee(t),"_timeout",null),H(ee(t),"_xhr",null),H(ee(t),"_withCredentials",null),H(ee(t),"_startTime",-1),H(ee(t),"_loadCompleteResolve",null),H(ee(t),"_loadCompleteReject",null),H(ee(t),"_runing",!1),H(ee(t),"_logger",!1),H(ee(t),"_vid",""),H(ee(t),"_responseType",void 0),H(ee(t),"_credentials",void 0),H(ee(t),"_method",void 0),H(ee(t),"_transformResponse",void 0),H(ee(t),"_firstRtt",void 0),H(ee(t),"_onCancel",null),H(ee(t),"_priOptions",null),t}return pt(i,[{key:"load",value:function(e){var r=this;clearTimeout(this._timeoutTimer),this._logger=e.logger,this._range=e.range,this._onProgress=e.onProgress,this._index=e.index,this._headers=e.headers,this._withCredentials=e.credentials==="include"||e.credentials==="same-origin",this._body=e.body||null,e.method&&(this._method=e.method),this._timeout=e.timeout||null,this._runing=!0,this._vid=e.vid||e.url,this._responseType=e.responseType,this._firstRtt=-1,this._onTimeout=e.onTimeout,this._onCancel=e.onCancel,this._request=e.request,this._priOptions=e.priOptions||{},this._logger.debug("【xhrLoader task】, range",this._range),this._url=du(e.url,e.params);var n=Date.now();return new Promise(function(a,u){r._loadCompleteResolve=a,r._loadCompleteReject=u,r._startLoad()}).catch(function(a){if(clearTimeout(r._timeoutTimer),r._runing=!1,!r._aborted)throw a=a instanceof Dt?a:new Dt(r._url,r._request),a.startTime=n,a.endTime=Date.now(),a.options={index:r._index,vid:r._vid,priOptions:r._priOptions},a})}},{key:"_startLoad",value:function(){var e=null;if(this._responseType===or.ARRAY_BUFFER&&this._range&&this._range.length>1)if(this._onProgress){this._firstRtt=-1;var r=this._currentChunkSizeKB*1024,n=this._range[0]+this._receivedLength,a=this._range[1];r],tast :",this._range,", SubRange, ",e)}else e=this._range,this._logger.debug("[xhr_loader->],tast :",this._range,", allRange, ",e);this._internalOpen(e)}},{key:"_internalOpen",value:function(e){var r=this;try{this._startTime=Date.now();var n=this._xhr=new XMLHttpRequest;n.open(this._method||"GET",this._url,!0),n.responseType=this._responseType,this._timeout&&(n.timeout=this._timeout),n.withCredentials=this._withCredentials,n.onload=this._onLoad.bind(this),n.onreadystatechange=this._onReadyStatechange.bind(this),n.onerror=function(l){var c,d,h;r._running=!1;var f=new Dt(r._url,r._request,l==null||(c=l.currentTarget)===null||c===void 0?void 0:c.response,"xhr.onerror.status:"+(l==null||(d=l.currentTarget)===null||d===void 0?void 0:d.status)+",statusText,"+(l==null||(h=l.currentTarget)===null||h===void 0?void 0:h.statusText));f.options={index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions},r._loadCompleteReject(f)},n.ontimeout=function(l){r.cancel();var c=new Dt(r._url,r._request,{status:408},"timeout");r._onTimeout&&(c.isTimeout=!0,r._onTimeout(c,{index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions})),c.options={index:r._index,range:r._range,vid:r._vid,priOptions:r._priOptions},r._loadCompleteReject(c)};var a=this._headers||{},u=cu(e);u&&(a.Range=u),a&&Object.keys(a).forEach(function(l){n.setRequestHeader(l,a[l])}),this._logger.debug("[xhr.send->] tast,",this._range,",load sub range, ",e),n.send(this._body)}catch(l){l.options={index:this._index,range:e,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(l)}}},{key:"_onReadyStatechange",value:function(e){var r=e.target;r.readyState===2&&this._firstRtt<0&&(this._firstRtt=Date.now())}},{key:"_onLoad",value:function(e){var r,n=e.target.status;if(n<200||n>299){var a=new Dt(this._url,null,sr(sr({},e.target.response),{},{status:n}),"bad response,status:"+n);return a.options={index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions},this._loadCompleteReject(a)}var u=null,l=!1,c,d=((r=this._range)===null||r===void 0?void 0:r.length)>0?this._range[0]:0;if(this._responseType===or.ARRAY_BUFFER){var h,f=new Uint8Array(e.target.response);if(c=d+this._receivedLength,f&&f.byteLength>0){this._receivedLength+=f.byteLength;var m=Date.now()-this._startTime,g=Qn(this._receivedLength,m);this.emit(K.REAL_TIME_SPEED,{speed:g,len:this._receivedLength,time:m,vid:this._vid,index:this._index,range:[c,d+this._receivedLength],priOptions:this._priOptions})}u=f,((h=this._range)===null||h===void 0?void 0:h.length)>1&&this._range[1]&&this._receivedLength], tast :",this._range,", start",c,"end ",d+this._receivedLength,",dataLen,",f?f.byteLength:0,",receivedLength",this._receivedLength,",index,",this._index,", done,",l)}else l=!0,u=e.target.response;var y={ok:n>=200&&n<300,status:n,statusText:this._xhr.statusText,url:this._xhr.responseURL,headers:this._getHeaders(this._xhr),body:this._xhr.response};this._transformResponse&&(y=this._transformResponse(y,this._url)||y),this._onProgress&&this._onProgress(u,l,{index:this._index,vid:this._vid,range:[c,d+this._receivedLength],startTime:this._startTime,endTime:Date.now(),priOptions:this._priOptions},y),l?(this._runing=!1,this._loadCompleteResolve&&this._loadCompleteResolve(jn(this._onProgress?null:u,l,y,y.headers["content-length"],y.headers.age,this._startTime,this._firstRtt,this._index,this._range,this._vid,this._priOptions))):this._startLoad()}},{key:"cancel",value:function(){if(!this._aborted&&(this._aborted=!0,this._runing=!1,Rr(Ti(i.prototype),"removeAllListeners",this).call(this),this._onCancel&&this._onCancel({index:this._index,range:this._range,vid:this._vid,priOptions:this._priOptions}),this._xhr))return this._xhr.abort()}},{key:"receiveLen",get:function(){return this._receivedLength}},{key:"running",get:function(){return this._running},set:function(e){this._running=e}},{key:"_getHeaders",value:function(e){var r=e.getAllResponseHeaders().trim().split(`\r `),n={},a=nh(r),u;try{for(a.s();!(u=a.n()).done;){var l=u.value,c=l.split(": ");n[c[0].toLowerCase()]=c.slice(1).join(": ")}}catch(d){a.e(d)}finally{a.f()}return n}}],[{key:"isSupported",value:function(){return typeof XMLHttpRequest<"u"}}]),i}(at),vh=["retry","retryDelay","onRetryError","transformError"],gh=function(){function s(o,i){mt(this,s),this.promise=Fi(),this.alive=!!i.onProgress,!i.logger&&(i.logger=new $e("Loader")),this._loaderType=o,this._loader=o===vi.FETCH&&typeof fetch<"u"?new $n:new ph,this._config=i,this._retryCount=0,this._retryTimer=null,this._canceled=!1,this._retryCheckFunc=i.retryCheckFunc,this._logger=i.logger}return pt(s,[{key:"exec",value:function(){var i=this,t=this._config,e=t.retry,r=t.retryDelay,n=t.onRetryError,a=t.transformError,u=eh(t,vh),l=function(){var c=Jt(Ve().mark(function d(){var h,f,m;return Ve().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.prev=0,y.next=3,i._loader.load(u);case 3:h=y.sent,i.promise.resolve(h),y.next=27;break;case 7:if(y.prev=7,y.t0=y.catch(0),i._loader.running=!1,i._logger.debug("[task request catch err]",y.t0),!i._canceled){y.next=13;break}return y.abrupt("return");case 13:if(y.t0.loaderType=i._loaderType,y.t0.retryCount=i._retryCount,f=y.t0,a&&(f=a(f)||f),n&&i._retryCount>0&&n(f,i._retryCount,{index:u.index,vid:u.vid,range:u.range,priOptions:u.priOptions}),i._retryCount++,m=!0,i._retryCheckFunc&&(m=i._retryCheckFunc(y.t0)),!(m&&i._retryCount<=e)){y.next=26;break}return clearTimeout(i._retryTimer),i._logger.debug("[task request setTimeout],retry",i._retryCount,",retry range,",u.range),i._retryTimer=setTimeout(l,r),y.abrupt("return");case 26:i.promise.reject(f);case 27:case"end":return y.stop()}},d,null,[[0,7]])}));return function(){return c.apply(this,arguments)}}();return l(),this.promise}},{key:"cancel",value:function(){var o=Jt(Ve().mark(function t(){return Ve().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return clearTimeout(this._retryTimer),this._canceled=!0,this._loader.running=!1,r.abrupt("return",this._loader.cancel());case 4:case"end":return r.stop()}},t,this)}));function i(){return o.apply(this,arguments)}return i}()},{key:"running",get:function(){return this._loader&&this._loader.running}},{key:"loader",get:function(){return this._loader}}]),s}();function hu(s){return s&&!s.paused&&!s.ended&&s.playbackRate!==0&&s.readyState!==0}function fu(s){if(!s)return{};if(typeof s.getVideoPlaybackQuality=="function"){var o=s.getVideoPlaybackQuality();return{droppedVideoFrames:o.droppedVideoFrames||o.corruptedVideoFrames,totalVideoFrames:o.totalVideoFrames,creationTime:o.creationTime}}return{droppedVideoFrames:s.webkitDroppedFrameCount,totalVideoFrames:s.webkitDecodedFrameCount,creationTime:performance.now()}}function bi(){for(var s=arguments.length,o=new Array(s),i=0;i0&&arguments[0]!==void 0?arguments[0]:0;return new Promise(function(o){return setTimeout(o,s)})}var oi=function(s){hr(i,s);var o=fr(i);function i(t){var e;return mt(this,i),e=o.call(this,t),H(ee(e),"type",vi.FETCH),H(ee(e),"_queue",[]),H(ee(e),"_alive",[]),H(ee(e),"_currentTask",null),H(ee(e),"_finnalUrl",""),H(ee(e),"_config",void 0),e._config=mh(t),(e._config.loaderType===vi.XHR||!$n.isSupported())&&(e.type=vi.XHR),e.log=t.logger,e}return pt(i,[{key:"isFetch",value:function(){return this.type===vi.FETCH}},{key:"load",value:function(e){var r=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};typeof e=="string"||!e?n.url=e||n.url||this._config.url:n=e,n=Object.assign({},this._config,n),n.params&&(n.params=Object.assign({},n.params)),n.headers&&Ga(n.headers)&&(n.headers=Object.assign({},n.headers)),n.body&&Ga(n.body)&&(n.body=Object.assign({},n.body)),n.transformRequest&&(n=n.transformRequest(n)||n),n.logger=this.log;var a=new gh(this.type,n);return a.loader.on(K.REAL_TIME_SPEED,function(u){r.emit(K.REAL_TIME_SPEED,u)}),this._queue.push(a),this._queue.length===1&&(!this._currentTask||!this._currentTask.running)&&this._processTask(),a.promise}},{key:"cancel",value:function(){var t=Jt(Ve().mark(function r(){var n;return Ve().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return n=this._queue.map(function(l){return l.cancel()}).concat(this._alive.map(function(l){return l.cancel()})),this._currentTask&&n.push(this._currentTask.cancel()),this._queue=[],this._alive=[],u.next=6,Promise.all(n);case 6:return u.next=8,yh();case 8:case"end":return u.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()},{key:"_processTask",value:function(){var e=this;if(this._currentTask=this._queue.shift(),!!this._currentTask){this._currentTask.alive&&this._alive.push(this._currentTask);var r=this._currentTask.exec().catch(function(n){});r&&typeof r.finally=="function"&&r.finally(function(){var n,a;(n=e._currentTask)!==null&&n!==void 0&&n.alive&&((a=e._alive)===null||a===void 0?void 0:a.length)>0&&(e._alive=e._alive.filter(function(u){return u&&u!==e._currentTask})),e._processTask()})}}}],[{key:"isFetchSupport",value:function(){return $n.isSupported()}}]),i}(at),mu=function(){function s(){mt(this,s),H(this,"_prevCurrentTime",0)}return pt(s,[{key:"do",value:function(i){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,e=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;if(i){var n=i.currentTime,a=0;if(this._prevCurrentTime===n){var u=Xe.info(Xe.get(i),n);if(!u.buffers.length)return;e&&u.nextStart||u.nextStart&&u.nextStart-nr&&!i.seeking&&(a=n+.1)}this._prevCurrentTime=n,a&&n!==a&&(i.currentTime=a)}}}]),s}(),pu=function(){function s(o){var i=this;mt(this,s),H(this,"_seiSet",new Set),this.emitter=o,o.on(K.SEI,function(t){t&&i._seiSet.add(t)})}return pt(s,[{key:"throw",value:function(i,t){var e=this;if(!(i==null||!this._seiSet.size)){var r=i-.2,n=i+.2,a=[];this._seiSet.forEach(function(u){u.time>=r&&u.time<=n&&a.push(u)}),a.forEach(function(u){e._seiSet.delete(u),e.emitter.emit(K.SEI_IN_TIME,u)}),t&&this._seiSet.forEach(function(u){u.timen&&(this._chunkCache=this._chunkCache.slice(-n))}}},{key:"getAvgSpeed",value:function(){var i;if(!this._chunkCache.length&&!this._speeds.length)return 0;if(this._speeds.length)return this._speeds.reduce(function(a,u){return a+=u})/this._speeds.length;var t=this._chunkCache[this._chunkCache.length-1],e=performance.now()-t.timestamp;e>(((i=this._opts)===null||i===void 0?void 0:i.longtimeNoReceived)||Zh)&&this._chunkCache.push({size:0,duration:e,timestamp:performance.now()});var r=this._chunkCache.reduce(function(a,u){return a+=u.size},0),n=this._chunkCache.reduce(function(a,u){return a+=u.duration},0);return 8e3*r/n}},{key:"getLatestSpeed",value:function(){return!this._chunkCache.length&&!this._speeds.length?0:this._speeds.length?this._speeds[this._speeds.length-1]:this._chunkSpeed}},{key:"getTotalSize",value:function(){return this._totalSize}},{key:"getTotalCost",value:function(){return this._totalCost}},{key:"reset",value:function(){this._chunkCache=[],this._speeds=[],this._totalSize=0,this._totalCost=0}}]),s}(),Ma=function(){function s(o){mt(this,s),H(this,"encodeType",""),H(this,"audioCodec",""),H(this,"videoCodec",""),H(this,"domain",""),H(this,"fps",0),H(this,"bitrate",0),H(this,"width",0),H(this,"height",0),H(this,"samplerate",0),H(this,"channelCount",0),H(this,"gop",0),H(this,"_bitsAccumulateSize",0),H(this,"_bitsAccumulateDuration",0),H(this,"_startGopId",-1),this._timescale=o}return pt(s,[{key:"getStats",value:function(){return{encodeType:this.encodeType,audioCodec:this.audioCodec,videoCodec:this.videoCodec,domain:this.domain,fps:this.fps,bitrate:this.bitrate,width:this.width,height:this.height,samplerate:this.samplerate,channelCount:this.channelCount,gop:this.gop}}},{key:"setEncodeType",value:function(i){this.encodeType=i}},{key:"setFpsFromScriptData",value:function(i){var t,e=i.data,r=e==null||(t=e.onMetaData)===null||t===void 0?void 0:t.framerate;r&&r>0&&r<100&&(this.fps=r)}},{key:"setVideoMeta",value:function(i){if(this.width=i.width,this.height=i.height,this.videoCodec=i.codec,this.encodeType=i.codecType,i.fpsNum&&i.fpsDen){var t=i.fpsNum/i.fpsDen;t>0&&t<100&&(this.fps=t)}}},{key:"setAudioMeta",value:function(i){this.audioCodec=i.codec,this.samplerate=i.sampleRate,this.channelCount=i.channelCount}},{key:"setDomain",value:function(i){this.domain=i.split("/").slice(2,3)[0]}},{key:"updateBitrate",value:function(i){var t=this;if((!this.fps||this.fps>=100)&&i.length){var e=i.reduce(function(r,n){return r+=n.duration},0)/i.length;this.fps=Math.round(this._timescale/e)}i.forEach(function(r){t._startGopId===-1&&(t._startGopId=r.gopId),r.gopId===t._startGopId&&t.gop++,t._bitsAccumulateDuration+=r.duration/(t._timescale/1e3),t._bitsAccumulateSize+=r.units.reduce(function(n,a){return n+=a.length},0),t._bitsAccumulateDuration>=1e3&&(t.bitrate=t._bitsAccumulateSize*8,t._bitsAccumulateDuration=0,t._bitsAccumulateSize=0)})}}]),s}(),gu=function(){function s(o){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e3;mt(this,s),H(this,"_core",null),H(this,"_samples",[]),this._core=o,this._timescale=i,this._stats=new Ma(i),this._bindEvents()}return pt(s,[{key:"getStats",value:function(){var i,t,e,r,n,a,u,l,c,d,h,f=((i=this._core)===null||i===void 0?void 0:i.media)||{},m=f.currentTime,g=m===void 0?0:m,y=f.decodeFps,L=y===void 0?0:y;return sr(sr({},this._stats.getStats()),{},{downloadSpeed:((t=this._core)===null||t===void 0||(e=t.speedInfo)===null||e===void 0?void 0:e.call(t).speed)||0,avgSpeed:((r=this._core)===null||r===void 0||(n=r.speedInfo)===null||n===void 0?void 0:n.call(r).avgSpeed)||0,totalReceivedByte:((a=this._core)===null||a===void 0||(u=a.speedInfo)===null||u===void 0?void 0:u.call(a).totalSize)||0,totalReceivedCost:((l=this._core)===null||l===void 0||(c=l.speedInfo)===null||c===void 0?void 0:c.call(l).totalCost)||0,currentTime:g,bufferEnd:((d=this._core)===null||d===void 0||(h=d.bufferInfo())===null||h===void 0?void 0:h.remaining)||0,decodeFps:L})}},{key:"_bindEvents",value:function(){var i=this;this._core.on(K.DEMUXED_TRACK,function(t){var e=t.videoTrack;return i._stats.updateBitrate(e.samples)}),this._core.on(K.FLV_SCRIPT_DATA,function(t){i._stats.setFpsFromScriptData(t)}),this._core.on(K.METADATA_PARSED,function(t){t.type==="video"?i._stats.setVideoMeta(t.track):i._stats.setAudioMeta(t.track)}),this._core.on(K.TTFB,function(t){i._stats.setDomain(t.responseUrl)})}},{key:"reset",value:function(){this._samples=[],this._stats=new Ma(this._timescale)}}]),s}(),Ct={416:Ie[B.NETWROK_RANGE_NOT_SATISFIABLE],403:Ie[B.NETWORK_FORBIDDEN],404:Ie[B.NETWORK_NOTFOUND],timeout:Ie[B.NETWORK_TIMEOUT],"4xx":"".concat(Ie[B.NETWORK],"4XX"),"5xx":"".concat(Ie[B.NETWORK],"5XX"),networkError:Ie[B.NETWORK],contentError:"".concat(Ie[B.NETWORK],"contentError"),mse:Ie[B.MEDIA][B.SUB_TYPES.MSE_OTHER],mseOpen:Ie[B.MEDIA][B.SUB_TYPES.MSE_ADD_SB],mseAppend:Ie[B.MEDIA][B.SUB_TYPES.MSE_APPEND_BUFFER],mse_hijack:Ie[B.MEDIA][B.SUB_TYPES.MSE_HIJACK],eme_hijack:Ie[B.MEDIA][B.SUB_TYPES.EME_HIJACK],metaError:Ie[B.DEMUX][B.SUB_TYPES.MP4],muxError:Ie[B.REMUX][B.SUB_TYPES.FMP4],other:Ie[B.OTHER],waitTimeout:Ie[B.RUNTIME][B.SUB_TYPES.BUFFERBREAK_ERROR],waitTimeoutWithHidden:Ie[B.RUNTIME][B.SUB_TYPES.WAITING_TIMEOUT_ERROR],drm:Ie[B.DRM][B.SUB_TYPES.LICENSE]},Hi=B;function kh(s){return Ct[s]||s}var Th=Ri(function s(o,i,t){xi(this,s);var e=0,r=0;t&&t.range&&t.range.length>1&&(e=t.range[0],r=t.range[1]);var n=kh(i);return{errorCode:n,errorType:o,errorMessage:(t==null?void 0:t.httpText)||(t==null?void 0:t.message),url:t==null?void 0:t.url,httpCode:i,version:su,rangeStart:e,rangeEnd:r,ext:t,mediaError:{code:n,message:(t==null?void 0:t.httpText)||(t==null?void 0:t.message)}}}),wh=Ri(function s(o,i,t){return xi(this,s),{errorCode:i,errorType:o,version:su,errorMessage:t.msg,ext:t,mediaError:{code:i,message:t.msg}}}),Pt={};Pt.nowTime=function(){try{return parseInt(performance.now(),10)}catch{return new Date().getTime()}};Pt.concatData=function(s,o){var i=[],t=0;s&&i.push(s),o&&i.push(o),i.every(function(n){return n&&(t+=n.byteLength),!0});var e=new Uint8Array(t),r=0;return i.every(function(n){return n&&(e.set(n,r),r+=n.byteLength),!0}),e};function _h(s,o){var i=s==null?null:typeof Symbol<"u"&&s[Symbol.iterator]||s["@@iterator"];if(i!=null){var t,e,r,n,a=[],u=!0,l=!1;try{if(r=(i=i.call(s)).next,o!==0)for(;!(u=(t=r.call(i)).done)&&(a.push(t.value),a.length!==o);u=!0);}catch(c){l=!0,e=c}finally{try{if(!u&&i.return!=null&&(n=i.return(),Object(n)!==n))return}finally{if(l)throw e}}return a}}function Pa(s,o){var i=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);o&&(t=t.filter(function(e){return Object.getOwnPropertyDescriptor(s,e).enumerable})),i.push.apply(i,t)}return i}function qn(s){for(var o=1;o=0;--x){var T=this.tryEntries[x],X=T.completion;if(T.tryLoc==="root")return b("end");if(T.tryLoc<=this.prev){var M=i.call(T,"catchLoc"),F=i.call(T,"finallyLoc");if(M&&F){if(this.prev=0;--b){var x=this.tryEntries[b];if(x.tryLoc<=this.prev&&i.call(x,"finallyLoc")&&this.prev=0;--v){var b=this.tryEntries[v];if(b.finallyLoc===p)return this.complete(b.completion,b.afterLoc),E(b),d}},catch:function(p){for(var v=this.tryEntries.length-1;v>=0;--v){var b=this.tryEntries[v];if(b.tryLoc===p){var x=b.completion;if(x.type==="throw"){var T=x.arg;E(b)}return T}}throw new Error("illegal catch attempt")},delegateYield:function(p,v,b){return this.delegate={iterator:I(p),resultName:v,nextLoc:b},this.method==="next"&&(this.arg=void 0),d}},s}function Va(s,o,i,t,e,r,n){try{var a=s[r](n),u=a.value}catch(l){i(l);return}a.done?o(u):Promise.resolve(u).then(t,e)}function ut(s){return function(){var o=this,i=arguments;return new Promise(function(t,e){var r=s.apply(o,i);function n(u){Va(r,t,e,n,a,"next",u)}function a(u){Va(r,t,e,n,a,"throw",u)}n(void 0)})}}function Cs(s,o){if(!(s instanceof o))throw new TypeError("Cannot call a class as a function")}function Ch(s,o){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Rh(s,o){if(s==null)return{};var i={},t=Object.keys(s),e,r;for(r=0;r=0)&&(i[e]=s[e]);return i}function Xh(s,o){if(s==null)return{};var i=Rh(s,o),t,e;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);for(e=0;e=0)&&Object.prototype.propertyIsEnumerable.call(s,t)&&(i[t]=s[t])}return i}function vt(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Gh(s,o){if(o&&(typeof o=="object"||typeof o=="function"))return o;if(o!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return vt(s)}function Ih(s){var o=xh();return function(){var t=Ur(s),e;if(o){var r=Ur(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return Gh(this,e)}}function Wh(s,o){return Vh(s)||_h(s,o)||yu(s,o)||Nh()}function Mh(s){return Ph(s)||Dh(s)||yu(s)||Yh()}function Ph(s){if(Array.isArray(s))return ts(s)}function Vh(s){if(Array.isArray(s))return s}function Dh(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function yu(s,o){if(s){if(typeof s=="string")return ts(s,o);var i=Object.prototype.toString.call(s).slice(8,-1);if(i==="Object"&&s.constructor&&(i=s.constructor.name),i==="Map"||i==="Set")return Array.from(s);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return ts(s,o)}}function ts(s,o){(o==null||o>s.length)&&(o=s.length);for(var i=0,t=new Array(o);i=p&&(P++,p=f[P+1]?f[P+1].firstChunk-1:1/0),D+=f[P].samplesPerChunk)});var x=c.length;if(!x||n&&!c[0].keyframe)return[];var T=[],X=[],M=0,F,Y=0,U=function(Nt){var St;F=X[X.length-1],T.push({index:T.length,startTime:((St=T[T.length-1])===null||St===void 0?void 0:St.endTime)||X[0].startTime/o,endTime:(F.startTime+F.duration)/o,duration:Nt,range:[X[0].offset,F.offset+F.size],frames:X}),M=0,X=[]};if(n)for(var te=s*o,O=0,_e=d.length;O<_e;O++){var We;M+=h[O],(We=X).push.apply(We,Mh(d[O])),O+1<_e?(O===0||M>te)&&U(M/o):U(M/o)}else{u=u||[];for(var qe=u[0]||s,Re=0;Re=x||ti+Y>=qe)&&(Y+=ti-qe,U(ti),qe=u[T.length]||s)}}return T}function Na(s,o){var i="",t="",e=0,r=0,n=0,a=0,u=0,l=0,c=0;s.mvhd&&(u=s.mvhd.duration/s.mvhd.timescale);var d=s.trak;if(d){var h=d.find(function(T){var X,M;return((X=T.mdia)===null||X===void 0||(M=X.hdlr)===null||M===void 0?void 0:M.handlerType)==="vide"}),f=d.find(function(T){var X,M;return((X=T.mdia)===null||X===void 0||(M=X.hdlr)===null||M===void 0?void 0:M.handlerType)==="soun"}),m=null,g;if(h){var y,L,k;if(m=(y=h.mdia)===null||y===void 0||(L=y.minf)===null||L===void 0||(k=L.stbl)===null||k===void 0?void 0:k.stsd.entries[0],m){var _,w,Z;if(e=m.width,r=m.height,l=(_=h.mdia)===null||_===void 0||(w=_.mdhd)===null||w===void 0?void 0:w.timescale,i=(Z=m.avcC||m.hvcC||m.av1C)===null||Z===void 0?void 0:Z.codec,m.type==="encv"){var C,R;g=(C=m.sinf)===null||C===void 0||(R=C.schi)===null||R===void 0?void 0:R.tenc.default_KID}}}if(f){var E,P,I;if(m=(E=f.mdia)===null||E===void 0||(P=E.minf)===null||P===void 0||(I=P.stbl)===null||I===void 0?void 0:I.stsd.entries[0],m){var D,p,v;if(n=m.channelCount,a=m.sampleRate,t=(D=m.esds)===null||D===void 0?void 0:D.codec,c=(p=f.mdia)===null||p===void 0||(v=p.mdhd)===null||v===void 0?void 0:v.timescale,m.type==="enca"){var b,x;g=g||((b=m.sinf)===null||b===void 0||(x=b.schi)===null||x===void 0?void 0:x.tenc.default_KID)}}}return{kid:g?g.join(""):null,videoCodec:i,audioCodec:t,width:e,height:r,videoTimescale:l,audioChannelCount:n,audioSampleRate:a,duration:u,audioTimescale:c,moov:s,isFragmentMP4:o}}}function Fa(s){return typeof s=="number"&&!Number.isNaN(s)}var Kh=["vid","cache"],Oh=function(s){Eh(i,s);var o=Ih(i);function i(t){var e;Cs(this,i),e=o.call(this),dt(vt(e),"vid",""),dt(vt(e),"url",""),dt(vt(e),"meta",{}),dt(vt(e),"downloadInfo",[]),dt(vt(e),"videoSegments",[]),dt(vt(e),"audioSegments",[]),dt(vt(e),"cache",null),dt(vt(e),"_currentSegmentIndex",-1),dt(vt(e),"_currentLoadingSegmentIndex",-1),dt(vt(e),"buffer",void 0),dt(vt(e),"_error",void 0),dt(vt(e),"_transformError",function(l){return l}),e._config=Hh(t);var r=e._config,n=r.vid,a=r.cache,u=Xh(r,Kh);return e.cache=a||new Uh,e.vid=n||u.url,e.url=u.url,u.transformError=e._transformError,e.logger=new $e("MP4Loader_"+e.vid),t.openLog&&$e.enable(),u.logger=e.logger,e._loader=new oi(u),e._loader.on(K.REAL_TIME_SPEED,function(l){e.emit(K.REAL_TIME_SPEED,l)}),e}return Es(i,[{key:"isMetaLoaded",get:function(){return this.videoSegments.length||this.audioSegments.length}},{key:"setCurrentSegment",value:function(e){Fa(e)&&(this._currentSegmentIndex=e)}},{key:"isLastSegment",value:function(e){if(Fa(e)){var r,n,a=((r=this.videoSegments[this.videoSegments.length-1])===null||r===void 0?void 0:r.index)||((n=this.audioSegments[this.audioSegments.length-1])===null||n===void 0?void 0:n.index)||0;return e>=a}return!1}},{key:"isSegmentLoading",value:function(e){return e===this._currentLoadingSegmentIndex}},{key:"changeUrl",value:function(){var t=ut(Te().mark(function r(n){var a,u,l,c=arguments;return Te().wrap(function(h){for(;;)switch(h.prev=h.next){case 0:return a=c.length>1&&c[1]!==void 0?c[1]:n,u=c.length>2?c[2]:void 0,l=c.length>3?c[3]:void 0,h.next=5,this.reset(l);case 5:n&&(this.url=n),a&&(this.vid=a),u&&(this._config.moovEnd=u);case 8:case"end":return h.stop()}},r,this)}));function e(r){return t.apply(this,arguments)}return e}()},{key:"getOrLoadMeta",value:function(){var t=ut(Te().mark(function r(n){return Te().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.isMetaLoaded){u.next=3;break}return u.next=3,this.loadMeta(n);case 3:return u.abrupt("return",this.meta);case 4:case"end":return u.stop()}},r,this)}));function e(r){return t.apply(this,arguments)}return e}()},{key:"loadMetaProcess",value:function(){var t=ut(Te().mark(function r(n,a,u,l){var c=this,d,h,f,m;return Te().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return d=Wh(a,2),h=d[0],f=d[1],this._error=!1,this.logger.debug("[loadMetaProcess start], range,",[h,f]),m=function(){var L=ut(Te().mark(function k(_,w,Z){var C,R,E,P,I,D,p,v,b,x,T,X,M;return Te().wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:if(c.meta&&Z!==null&&Z!==void 0&&Z.range&&Z.range.length>0&&Z.range[1]>=f&&(w=!0,c.logger.debug("[loadMetaProcess],data done,setstate true,[",h,f,"]")),w&&Z!==null&&Z!==void 0&&Z.range&&Z.range.length>0&&Z.range[1]0&&u(_,w,Z),!(c.meta.moov||c._error)){Y.next=6;break}return Y.abrupt("return");case 6:if(!(_&&_.byteLength>0)){Y.next=51;break}if(c.buffer=bi(c.buffer,_),C=se.findBox(c.buffer,["moov"])[0],C){Y.next=23;break}if(R=se.findBox(c.buffer,["mdat"])[0],!w){Y.next=23;break}if(R){Y.next=18;break}return c._error=!0,u(null,w,Z,{err:"cannot find moov or mdat box"}),Y.abrupt("return");case 18:return E=R.start+R.size,Y.next=21,c.loadData([E,""],n,l);case 21:P=Y.sent,P&&(C=se.findBox(P.data,["moov"])[0]);case 23:if(!(C&&w&&C.size>C.data.length)){Y.next=27;break}return c.logger.debug("[loadMetaProcess],moov not all, range,",Z.range[1],",dataLen,",c.buffer.byteLength,", state,",w),Y.next=27,c.loadMetaProcess(n,[Z.range[1],C.start+C.size-1],u);case 27:if(!(C&&C.size<=C.data.length&&!c.meta.moov)){Y.next=51;break}if(I=se.moov(C),I){Y.next=33;break}return c._error=!0,u(null,w,Z,{err:"cannot parse moov box"}),Y.abrupt("return");case 33:if(D=xn(I,c._config.segmentDuration),p=function(){var U=ut(Te().mark(function te(O){var _e,We;return Te().wrap(function(Re){for(;;)switch(Re.prev=Re.next){case 0:if(_e=se.findBox(c.buffer,[O])[0],!_e){Re.next=11;break}if(!(_e.size>_e.data.length)){Re.next=10;break}return Re.next=5,c.loadData([_e.start,_e.start+_e.size-1],n,l);case 5:if(We=Re.sent,!We){Re.next=8;break}return Re.abrupt("return",se.findBox(We.data,[O])[0]);case 8:Re.next=11;break;case 10:return Re.abrupt("return",_e);case 11:case"end":return Re.stop()}},te)}));return function(O){return U.apply(this,arguments)}}(),v=!1,D&&D.videoSegments.length&&D.audioSegments.length){Y.next=41;break}return Y.next=39,p("sidx");case 39:b=Y.sent,b&&(x=se.sidx(b),x&&(D=Da(I,x),v=!0));case 41:if(D){Y.next=45;break}return c._error=!0,u(null,w,Z,{err:"cannot parse segments"}),Y.abrupt("return");case 45:c.meta=Na(I,v),T=D,X=T.videoSegments,M=T.audioSegments,c.videoSegments=X,c.audioSegments=M,c.logger.debug("[loadMetaProcess] moov ok"),u(void 0,w,{meta:{meta:c.meta,videoSegments:X,audioSegments:M}});case 51:case"end":return Y.stop()}},k)}));return function(_,w,Z){return L.apply(this,arguments)}}(),y.next=6,this.loadData([h,f||this._config.moovEnd],n,qn({onProgress:m},l));case 6:case"end":return y.stop()}},r,this)}));function e(r,n,a,u){return t.apply(this,arguments)}return e}()},{key:"loadMeta",value:function(){var t=ut(Te().mark(function r(n,a,u){var l,c,d,h,f,m,g,y,L,k,_,w,Z,C;return Te().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return l=[],this.logger.debug("[loadMeta start]"),E.next=4,this.loadData([0,a||this._config.moovEnd],n,u);case 4:if(c=E.sent,c){E.next=7;break}return E.abrupt("return");case 7:if(l.push(c),d=se.findBox(c.data,["moov"])[0],d){E.next=23;break}if(h=se.findBox(c.data,["mdat"])[0],h){E.next=13;break}throw new kr("cannot find moov or mdat box",c.data);case 13:return f=h.start+h.size,E.next=16,this.loadData([f],n,u);case 16:if(c=E.sent,c){E.next=19;break}return E.abrupt("return");case 19:if(l.push(c),d=se.findBox(c.data,["moov"],f)[0],d){E.next=23;break}throw new kr("cannot find moov box",c.data);case 23:if(!(d.size>d.data.length)){E.next=31;break}return E.next=26,this.loadData([c.data.length,d.start+d.size-1],n,u);case 26:if(c=E.sent,c){E.next=29;break}return E.abrupt("return");case 29:l.push(c),d.data=bi(d.data,c.data);case 31:if(m=se.moov(d),m){E.next=34;break}throw new kr("cannot parse moov box",d.data);case 34:if(g=xn(m,this._config.segmentDuration),g){E.next=37;break}throw new kr("cannot parse segments",d.data);case 37:return g.videoSegments.length&&g.audioSegments.length||(L=se.findBox(this.buffer,["moof"])[0],k=se.findBox(this.buffer,["sidx"])[0],L&&L.size<=L.data.length&&k&&(_=se.moof(L),y=se.sidx(k),_&&y&&(g=Da(m,y)))),this.meta=Na(m,y),w=g,Z=w.videoSegments,C=w.audioSegments,this.videoSegments=Z,this.audioSegments=C,this.logger.debug("[load moov end!!!!!]"),E.abrupt("return",{meta:this.meta,videoSegments:Z,audioSegments:C,responses:l});case 44:case"end":return E.stop()}},r,this)}));function e(r,n,a){return t.apply(this,arguments)}return e}()},{key:"loadCacheMeta",value:function(e,r){var n=e.moov,a=xn(n,this._config.segmentDuration),u=a.videoSegments,l=a.audioSegments;this.videoSegments=u,this.audioSegments=l,this._currentSegmentIndex=r,this.meta=e}},{key:"getSegmentByTime",value:function(e){var r,n;return this.videoSegments.length?(r=this.videoSegments.find(function(a){return a.startTime<=e&&a.endTime>e}),r&&(n=this.audioSegments[r.index])):n=this.audioSegments.find(function(a){return a.startTime<=e&&a.endTime>e}),{video:r,audio:n}}},{key:"loadSegmentByTime",value:function(){var t=ut(Te().mark(function r(n,a){var u,l,c,d,h,f=arguments;return Te().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(u=f.length>2&&f[2]!==void 0?f[2]:!0,l=f.length>3&&f[3]!==void 0?f[3]:{},this.isMetaLoaded){g.next=5;break}return g.next=5,this.loadMeta(a);case 5:return c=this.getSegmentByTime(n),d=c.video,h=c.audio,g.abrupt("return",this._loadSegment(d,h,a,u,l));case 7:case"end":return g.stop()}},r,this)}));function e(r,n){return t.apply(this,arguments)}return e}()},{key:"loadNextSegment",value:function(){var t=ut(Te().mark(function r(n){var a,u,l,c,d=arguments;return Te().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(a=d.length>1&&d[1]!==void 0?d[1]:!0,u=d.length>2&&d[2]!==void 0?d[2]:{},this.isMetaLoaded){f.next=5;break}return f.next=5,this.loadMeta();case 5:return l=this.videoSegments[this._currentSegmentIndex+1],c=this.audioSegments[this._currentSegmentIndex+1],f.abrupt("return",this._loadSegment(l,c,n,a,u));case 8:case"end":return f.stop()}},r,this)}));function e(r){return t.apply(this,arguments)}return e}()},{key:"preload",value:function(){var t=ut(Te().mark(function r(n){var a=this,u,l,c,d,h,f,m;return Te().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.isMetaLoaded){y.next=3;break}return y.next=3,this.loadMeta(!0);case 3:if(!(!n||n<0)){y.next=5;break}return y.abrupt("return");case 5:if(u=this.getSegmentByTime(n),l=u.video,c=u.audio,d=Math.max((l==null?void 0:l.index)||0,(c==null?void 0:c.index)||0),d){y.next=9;break}return y.abrupt("return");case 9:return h=this.videoSegments.slice(0,d),f=this.audioSegments.slice(0,d),m=function(){var L=ut(Te().mark(function k(_){return Te().wrap(function(Z){for(;;)switch(Z.prev=Z.next){case 0:if(!(_>d)){Z.next=2;break}return Z.abrupt("return");case 2:return Z.next=4,a._loadSegment(h[_],f[_],!0,!1);case 4:return Z.next=6,m(_+1);case 6:case"end":return Z.stop()}},k)}));return function(_){return L.apply(this,arguments)}}(),y.next=14,m(0);case 14:case"end":return y.stop()}},r,this)}));function e(r){return t.apply(this,arguments)}return e}()},{key:"cancel",value:function(){return this._loader.cancel()}},{key:"reset",value:function(){var t=ut(Te().mark(function r(){var n,a=arguments;return Te().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(n=a.length>0&&a[0]!==void 0?a[0]:!1,n){l.next=5;break}return this.logger.debug("[MP4loader reset func call loader.cancel]"),l.next=5,this._loader.cancel();case 5:this.vid=this.url="",this.meta={},this.downloadInfo=[],this.videoSegments=[],this.audioSegments=[],this._currentSegmentIndex=-1,this._currentLoadingSegmentIndex=-1;case 12:case"end":return l.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()},{key:"destroy",value:function(){var t=ut(Te().mark(function r(){return Te().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this.reset();case 2:this.cache.clear();case 3:case"end":return a.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()},{key:"_loadSegment",value:function(){var t=ut(Te().mark(function r(n,a,u,l,c){var d,h;return Te().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:if(!(!n&&!a)){m.next=2;break}return m.abrupt("return");case 2:return d=(n==null?void 0:n.index)||(a==null?void 0:a.index)||0,this._currentLoadingSegmentIndex=d,m.prev=4,m.next=7,this.loadData([Math.min((n==null?void 0:n.range[0])||1/0,(a==null?void 0:a.range[0])||1/0),Math.max((n==null?void 0:n.range[1])||0,(a==null?void 0:a.range[1])||0)],u,c);case 7:h=m.sent;case 8:return m.prev=8,this._currentLoadingSegmentIndex=-1,m.finish(8);case 11:if(h){m.next=13;break}return m.abrupt("return");case 13:return l&&(this._currentSegmentIndex=d),h.video=n,h.audio=a,m.abrupt("return",h);case 17:case"end":return m.stop()}},r,this,[[4,,8,11]])}));function e(r,n,a,u,l){return t.apply(this,arguments)}return e}()},{key:"loadData",value:function(){var t=ut(Te().mark(function r(n,a,u){var l,c,d,h;return Te().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return l=this._getCacheKey(n),m.next=3,this.cache.get(l);case 3:if(c=m.sent,c){m.next=11;break}return h=u&&u.url?u.url:this.url,m.next=8,this._loader.load(h,qn({range:n,vid:this.vid},u));case 8:d=m.sent,m.next=12;break;case 11:d={data:c,state:!0,options:{fromCache:!0,range:n,vid:this.vid}};case 12:if(d){m.next=14;break}return m.abrupt("return");case 14:return c||(d.data&&this.downloadInfo.push({startTime:d.startTime,endTime:d.endTime,size:d.data.byteLength,range:n}),this.downloadInfo&&this.downloadInfo.length>this._config.maxDownloadInfoSize&&(this.downloadInfo=this.downloadInfo.slice(-this._config.maxDownloadInfoSize))),m.abrupt("return",d);case 17:case"end":return m.stop()}},r,this)}));function e(r,n,a){return t.apply(this,arguments)}return e}()},{key:"_getCacheKey",value:function(e){return(this.vid||this.url)+":"+e}}]),i}(at),Su=Jh(),Ah=er();jh();function zh(){try{return typeof localStorage<"u"&&"setItem"in window.localStorage&&!!window.localStorage.setItem}catch{return!1}}function Bh(){var s="_localstorage_support_test";try{return window.localStorage.setItem(s,!0),window.localStorage.removeItem(s),!1}catch{return!0}}function er(){if(Su)try{return!!window.localStorage.getItem("playerlog")}catch{return!1}return!1}function Jh(){return zh()&&!Bh()}function Lu(s){for(var o,i=arguments.length,t=new Array(i>1?i-1:0),e=1;e0&&(d=r.timeRange[c.index].range,d&&c.range[1]>=d[1]&&!l&&(l=!0),r.log("[mp4.loadFragment onprogressDataArrive ] receive data, >>> index,",c.index,",range,",JSON.stringify(c.range),", dataLen,",u.byteLength),r._mux(u,c.range[0],c.index,l)),l&&(r.timeRange[c.index].downloaded=!0,r.bufferLoadedPos=-1,r.log("[FragLoadDowned],fragmentIdx,",c.index,",rangeEnd,",c.range[1]));case 2:case"end":return f.stop()}},a)}));return function(a,u,l){return n.apply(this,arguments)}}()),r.url=t,r.options=i.getDefaultConfig(),Object.keys(e).map(function(n){e[n]!==void 0&&e[n]!==null&&(r.options[n]=e[n])}),r.timeRange=[],r.CHUNK_SIZE=r.options.chunkSize,r.bufferLoaded=new Uint8Array(0),r.bufferLoadedPos=0,r.meta=null,r.videoTrak=null,r.audioTrak=null,r.canDownload=!0,r._loadSuccessCallBack=null,r._isPending=!1,r._metaLoading=!1,r.MP4Loader=new Oh(si(si({segmentDuration:r.options.segmentDuration,url:t,vid:e.vid,retry:r.options.retryCount,retryDelay:r.options.retryDelay,timeout:r.options.timeout},e.reqOptions),{},{openLog:er()})),r.fMP4Demuxer=null,r.MP4Demuxer=null,r.FMP4Remuxer=null,r._needInitSegment=!0,r._switchBitRate=!1,r.enableWorker=r.options.enableWorker,r.enableWorker&&typeof Worker<"u")try{r.workerSequence=0,r.transmuxerWorkerControl=new $h({id:r.workerSequence,codecType:e.codecType,supportHevc:r.options.supportHevc,openLog:er()}),r.transmuxerWorkerControl.on("transmux",function(n){var a=n.args;r.log("[transmuxerworker end] ,range, ",JSON.stringify(a.range),",dataLen,",a.buffer.byteLength,a.context),r._loadSuccessCallBack&&r._loadSuccessCallBack(a)})}catch(n){r.log("Error in worker:",n),r.enableWorker=!1,r.transmuxerWorkerControl=null}return r.enableWorker||(r.MP4Demuxer=null,r.FMP4Remuxer=null),r.seekTime=-1,r.changeBitRateTime=-1,r}return Ri(i,[{key:"changeBitRate",value:function(){var t=je(ve().mark(function r(n){return ve().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.url=n.url,u.next=3,this.MP4Loader.changeUrl(this.url,this.options.vid+Date.now(),this.CHUNK_SIZE);case 3:this._switchBitRate=!0,this.log("[switchBitrate] changeUrl, bitRate,",this.url);case 5:case"end":return u.stop()}},r,this)}));function e(r){return t.apply(this,arguments)}return e}()},{key:"log",value:function(e){for(var r=this.options,n=r&&r.vid?"[MP4] ".concat(r.vid," ").concat(e):"[MP4] ".concat(e),a=arguments.length,u=new Array(a>1?a-1:0),l=1;le.length)for(var a=e.length;a0&&c[0]!==void 0?c[0]:!0,h.prev=1,this._metaLoading=!0,this.log("getMetaInfo start"),this.bufferLoaded=new Uint8Array(0),u=0,l=function(){var f=je(ve().mark(function m(g,y,L){var k;return ve().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:n.log("getMetaInfo onProgressHandle, dataLen,",g?g.byteLength:-1,", state,",y,",range,",JSON.stringify(L.range)),g&&L.range[0]===u&&(n.bufferLoaded=od(Uint8Array,n.bufferLoaded,new Uint8Array(g)),u+=g.byteLength),L.meta&&!n.meta&&(k=L.meta,n.videoTrak=k.videoSegments,n.audioTrak=k.audioSegments,n.timeRange=n.getTimeRange(),n.meta=si(si({},k.meta),{},{ext:{videoTrak:n.videoTrak,audioTrak:n.audioTrak}}),k.bufferLoaded=n.bufferLoaded,n.log("meta reach"),a&&n.emit(tt.META_READY,n.meta)),n.meta&&y&&(n.log("[getMetaInfo req end]"),n._metaLoading=!1),n.meta&&(g||y)&&(n.log("emit moov_req_progress"),n.emit(tt.MOOV_REQ_PROGRESS));case 5:case"end":return w.stop()}},m)}));return function(g,y,L){return f.apply(this,arguments)}}(),h.next=9,this.MP4Loader.loadMetaProcess(this.MP4Loader.cache,[0,this.CHUNK_SIZE],l);case 9:h.next=15;break;case 11:h.prev=11,h.t0=h.catch(1),console.error("[MP4] trigger errorHandler getMetaInfo",h.t0===null||h.t0===void 0?void 0:h.t0.message),this.loadError(h.t0,"getMetaInfo");case 15:case"end":return h.stop()}},r,this,[[1,11]])}));function e(){return t.apply(this,arguments)}return e}()},{key:"getFragmentIdx",value:function(e){var r,n;if(this.videoTrak.length){if(r=this.videoTrak.find(function(u){return u.startTime<=e&&u.endTime>e}),n=this.audioTrak.find(function(u){return u.startTime<=e&&u.endTime>e}),r&&n)return Math.min(r.index,n.index);if(r||n)return r?r.index:n.index;var a=Number.MAX_VALUE;return this.videoTrak&&this.videoTrak.length>0&&(a=this.videoTrak.length-1),this.audioTrak&&this.audioTrak.length>0&&(a=Math.min(this.audioTrak.length-1,a)),a}else return n=this.audioTrak.find(function(u){return u.startTime<=e&&u.endTime>e}),n?n.index:0}},{key:"_checkHasMeta",value:function(){var t=je(ve().mark(function r(){var n;return ve().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.log(" loadMeta start"),this._metaLoading=!0,u.next=4,this.MP4Loader.loadMeta(this.MP4Loader.cache,Math.round(this.CHUNK_SIZE/2));case 4:return n=u.sent,this._metaLoading=!1,this.videoTrak=n.videoSegments,this.audioTrak=n.audioSegments,this.meta=si(si({},n.meta),{},{ext:{videoTrak:this.videoTrak,audioTrak:this.audioTrak}}),this.timeRange=this.getTimeRange(),this.bufferLoaded=new Uint8Array(0),n.bufferLoaded=this.bufferLoaded,u.abrupt("return",!0);case 13:case"end":return u.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()},{key:"resetFragmentLoadState",value:function(e){for(var r=0;r=this.videoTrak.length-1&&(d=-1),this.audioTrak&&e>=this.audioTrak.length-1&&(h=-1);var f=[Math.min(((r=l)===null||r===void 0?void 0:r.range[0])||1/0,((n=c)===null||n===void 0?void 0:n.range[0])||1/0),Math.max(((a=l)===null||a===void 0?void 0:a.range[1])+d||0,((u=c)===null||u===void 0?void 0:u.range[1])+h||0)];return e=this.videoTrak.length?this.audioTrak[n].startTime:this.videoTrak[n].startTime,", fragIndex,",n),h.next=5,this._checkHasMeta();case 5:u=h.sent,this.changeBitRateTime>0&&(this.timeRange[n].startTime<=this.changeBitRateTime&&this.changeBitRateTime0?(c=this.getSubRange(n,this.seekTime,l),this.loadFragment(n,c),this.seekTime=-1):this.loadFragment(n,l);case 17:case"end":return h.stop()}},r,this)}));function e(r,n){return t.apply(this,arguments)}return e}()},{key:"getSubRange",value:function(e,r,n){var a=n[0],u=n[0],l=1,c=!1;if(this.log(">>>>>getSubRange time,",r,JSON.stringify(n)),this.videoTrak){var d=e>>>>getSubRange video, no frames"),n;var h=d.frames.filter(ef),f=this.meta.videoTimescale,m=h[0].startTime/f;this.log(">>>>>getSubRange video, startTime,",d.startTime,",endTime,",d.endTime);for(var g=0;g>>>>getSubRange video keyFrameList, startTime,",h[g].startTime/f,",range,",h[g].offset);for(;l>>>>getSubRange video end, startTime,",m,",endTime,",y,",startRange,",a,", keyFrameIndex,",l-1);break}m=y}!c&&m<=r&&r>>>>getSubRange video last, startTime,",m,",endTime,",d.endTime,",startRange,",a))}if(l=1,this.audioTrak){var L=e>>>>getSubRange video, no frames"),n;var k=L.frames,_=this.meta.audioTimescale;l=Math.floor((r*_-k[0].startTime)/L.frames[0].duration),l=Math.min(k.length-1,l);for(var w=l>0?k[l-1].startTime/_:k[0].startTime/_;l>=0&&l0&&w>r){l-=1,w=k[l].startTime/_;continue}var Z=(k[l].startTime+k[l].duration)/_;if(w<=r&&r>>>>getSubRange audio end, startTime,",w,",endTime,",Z,",startRange,",u,", index,",l);break}w=Z,l++}}var C=[Math.min(u,a),n[1]];return this.log(">>>>>getSubRange finalRange ",JSON.stringify(C),",oldRange,",JSON.stringify(n)),C}},{key:"_mux",value:function(e,r,n,a){var u=this.getSamplesRange(n,"video"),l=this.getSamplesRange(n,"audio"),c=[r,r+e.byteLength];if(this.transmuxerWorkerControl&&!this.meta.isFragmentMP4){var d={range:c,state:a,fragIndex:n};this.log("[transmuxerworker start] ,range, ",JSON.stringify(c),",dataLen,",e.byteLength,d),this.transmuxerWorkerControl.transmux(this.workerSequence,e,r,u,l,this.meta.moov,this.useEME,this.kidValue,d)}else try{var h;this.meta.isFragmentMP4?(this.fMP4Demuxer||(this.fMP4Demuxer=new Ao),h=this.fMP4Demuxer.demuxPart(e,r,this.meta.moov)):(this.MP4Demuxer||(this.MP4Demuxer=new Qd(this.videoTrak,this.audioTrak,null,{openLog:er()})),h=this.MP4Demuxer.demuxPart(e,r,u,l,this.meta.moov,this.useEME,this.kidValue)),!this.FMP4Remuxer&&(!this.checkCodecH265()||this.options.supportHevc)&&(this.FMP4Remuxer=new _s(h.videoTrack,h.audioTrack,{openLog:er()}));var f;this.log("[mux], videoTimeRange,",h.videoTrack?[h.videoTrack.startPts,h.videoTrack.endPts]:null,",audioTimeRange,",h.audioTrack?[h.audioTrack.startPts,h.audioTrack.endPts]:null);var m=Math.min(h.videoTrack.startPts,h.audioTrack.startPts),g=Math.max(h.videoTrack.endPts,h.audioTrack.endPts),y=[m,g];if(this.FMP4Remuxer){var L=this.FMP4Remuxer.remux(this._needInitSegment,{initMerge:!0,range:c});L.initSegment&&(this._needInitSegment=!1);var k=Pt.concatData(L.audioSegment,L.videoSegment);f={buffer:k,range:c,state:a,context:{range:c,fragIndex:n,timeRange:y},initSeg:L.initSegment}}else f={videoTrack:h.videoTrack,audioTrack:h.audioTrack,buffer:null,range:c,state:a,context:{range:c,fragIndex:n,timeRange:y}};this._loadSuccessCallBack&&this._loadSuccessCallBack(f)}catch(w){console.error("mux err:",w);var _=new wh(Hi.remux,Ct.muxError,{msg:JSON.stringify(w)});this.errorHandler(_,"mux",{fragIndex:n,range:[r,r+e.byteLength]})}}},{key:"getSamplesRange",value:function(e,r){var n=[];switch(r){case"video":if(this.videoTrak&&e0&&a[0]===0&&a[1]===0||this.timeRange[n].isLoading)){f.next=2;break}return f.abrupt("return");case 2:if(this.log("[MP4.loadFragment] ,fragIndex,",n,",range ",a,",len ,",a[1]-a[0],", bufferLoaded_Len,",this.bufferLoaded.byteLength),!(a.length>=2&&a[1]&&a[1]>0&&a[1]<=this.bufferLoaded.byteLength)){f.next=13;break}this.timeRange[n].isLoading=!0,u=Math.max(a[0],this.bufferLoadedPos),l=new Uint8Array(this.bufferLoaded.slice(u,a[1])),this.log("[mp4.loadFragment] has all data: ",u,a[1]),this.timeRange[n].downloaded=!0,this.bufferLoadedPos=-1,this._mux(l,u,n,!0),f.next=34;break;case 13:if(!(a.length>=2&&a[0]&&a[0]<=this.bufferLoaded.byteLength)){f.next=29;break}if(this.timeRange[n].isLoading){f.next=27;break}if(c=Math.max(a[0],this.bufferLoadedPos),d=new Uint8Array(this.bufferLoaded.slice(c,a[1])),!(d.byteLength>0)){f.next=22;break}return this.bufferLoadedPos=c+d.byteLength,this.log("[mp4.loadFragment] has part data: ",c,c+d.byteLength),this._mux(d,c,n,a[1]<=this.bufferLoadedPos),f.abrupt("return");case 22:if(!(!this._metaLoading&&!this.timeRange[n].isLoading)){f.next=27;break}return this.log("[mp4.loadFragment] ready to load part data >>> ",this.bufferLoaded.byteLength,a[1]),this.timeRange[n].isLoading=!0,f.next=27,this.startLoad([this.bufferLoaded.byteLength,a[1]],n);case 27:f.next=34;break;case 29:if(!((!this._metaLoading||a[0]>=this.CHUNK_SIZE)&&!this.timeRange[n].isLoading)){f.next=34;break}return this.timeRange[n].isLoading=!0,this.log("[mp4.loadFragment],ready to load all data ,segmentIdx, ",n,",range >>> ",JSON.stringify(a)),f.next=34,this.startLoad(a,n);case 34:case"end":return f.stop()}},r,this)}));function e(r,n){return t.apply(this,arguments)}return e}()},{key:"startLoad",value:function(){var t=je(ve().mark(function r(n,a){return ve().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.prev=0,l.next=3,this.MP4Loader.loadData(n,this.MP4Loader.cache,{index:a,onProgress:this.onprogressDataArrive,onProcessMinLen:this.options.onProcessMinLen});case 3:l.next=9;break;case 5:l.prev=5,l.t0=l.catch(0),console.error("[MP4] trigger errorHandler getMetaInfo",l.t0===null||l.t0===void 0?void 0:l.t0.message),this.loadError(l.t0,"loadFragment",{range:n,fragIndex:a});case 9:case"end":return l.stop()}},r,this,[[0,5]])}));function e(r,n){return t.apply(this,arguments)}return e}()},{key:"loadError",value:function(e,r,n){var a;!e.response&&(e.response={}),e.isTimeout?e.response.status="timeout":e!=null&&(a=e.response)!==null&&a!==void 0&&a.status||(e.response.status="networkError"),this.errorHandler(e,r,n)}},{key:"cancelLoading",value:function(){var t=je(ve().mark(function r(){return ve().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,this.MP4Loader;case 2:if(a.t0=a.sent,!a.t0){a.next=5;break}this.MP4Loader.cancel();case 5:case"end":return a.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()},{key:"update",value:function(e){this.url=e}},{key:"checkCodecH265",value:function(){var e=this.meta&&(this.meta.videoCodec.indexOf("hvc1")>-1||this.meta.videoCodec.indexOf("hev1")>-1);return e}},{key:"destroy",value:function(){this.hasDestroyed||(this.resetTansmuxer(),this.transmuxerWorkerControl&&this.transmuxerWorkerControl.destroy(),this._isPending=!1,this._metaLoading=!1,this.bufferLoadedPos=0,this.bufferLoaded=new Uint8Array(0),this.MP4Loader&&(this.MP4Loader.cancel(),this.MP4Loader.destroy()),this.hasDestroyed=!0)}},{key:"resetTansmuxer",value:function(){this.MP4Demuxer&&this.MP4Demuxer.reset(),this.MP4Demuxer=null,this.FMP4Remuxer&&this.FMP4Remuxer.reset(),this.FMP4Remuxer=null,this.transmuxerWorkerControl&&this.transmuxerWorkerControl.reset()}}],[{key:"getDefaultConfig",value:function(){return{segmentDuration:5,onProcessMinLen:1024,chunkSize:8e5,retryCount:3,retryDelay:1e3,timeout:3e3,enableWorker:!1,playerId:"",vid:"",ext:{}}}}]),i}(at);function ef(s){if(s.keyframe)return s}var tf=function(){function s(o){xi(this,s),this.onTick_=o,this.cancelPending_=null}return Ri(s,[{key:"tickAfter",value:function(i){var t=this,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;this.stop();var r=!0,n=null;this.cancelPending_=function(){window.clearTimeout(n),r=!1};var a=function(){r&&(t.onTick_(),e&&e())};return n=window.setTimeout(a,i*1e3),this}},{key:"tickEvery",value:function(i){var t=this;this.tickAfter(i,function(){t.tickEvery(i)})}},{key:"stop",value:function(){this.cancelPending_&&(this.cancelPending_(),this.cancelPending_=null)}}]),s}(),rf=function(){function s(){xi(this,s);var o,i,t=new Promise(function(r,n){o=r,i=n}),e=t;return e.resolve=function(r){o(r),e.state="fulfilled"},e.reject=function(r){i(r),e.state="rejected",e.isBreak=r==="DESTROYED"},e.state="pending",e}return Ri(s,[{key:"resolve",value:function(i){}},{key:"reject",value:function(i){}}]),s}(),nf="DESTROYED",Ua=null,Rn=null,Ka=null,Oa=null,sf=function(s){Ss(i,s);var o=Ls(i);function i(t){var e;return xi(this,i),e=o.call(this,t),gt(Ne(e),"_onMp4DataCallBack",function(){e._isMseInit&&e._onTimeUpdate()}),gt(Ne(e),"_onMp4MetaReady",function(r){var n=Ne(e),a=n.config,u=e.mp4.checkCodecH265();try{if(u&&!e.config.supportHevc){var l="browser not support HEVC",c=new Lt(e.player,{errorType:"runtime",errorTypeCode:Hi.runtime,errorCode:Ct.h265Error,errorMessage:l,vid:a.vid,mediaError:{code:Ct.h265Error,message:l}});e._errorHandler(c)}else e._initMse(r),e._initPromise.resolve()}catch(h){var d=new Lt(e.player,{errorType:"runtime",errorTypeCode:Hi.runtime,errorCode:Ct.mse,errorMessage:h==null?void 0:h.message,vid:a.vid,mediaError:{code:Ct.other1,message:h==null?void 0:h.message}});e._errorHandler(d);return}e._loadData()}),gt(Ne(e),"_onMp4Error",function(r){var n=e.playerConfig.vid;console.error("[Index] _onMp4Error",n,r),e._errorHandler(r)}),gt(Ne(e),"_loadDataSuccess",function(r){if(!(e.isDestroy||!e.mse)){e.log("[loadFragment] _loadDataSuccess ",JSON.stringify(r.context.range),",dataLen,",r.buffer?r.buffer.byteLength:0,r.state);try{r.initSeg&&(e._appendInitSeg(r.initSeg),(!r.buffer||r.buffer.byteLength<1)&&(e.log("no data, must load data"),e._onTimeUpdate()));var n=r.buffer,a=r.state,u=r.context;if(e.mse&&a&&(!n||n.byteLength<=0)&&u.fragIndex===e.mp4.timeRange.length-1){var l=e.player.buffered;l&&l.length>0&&(e.bufferEndTime=l.end(l.length-1)),e._isEnded(),e.log("loaded ended !!!==>>>",JSON.stringify(u.range),", fragIndex,",u.fragIndex,", bufferEndTime,",e.bufferEndTime,",meta_duration,",e.mp4.meta.duration)}if(e.mse&&a&&u.fragIndex===e.mp4.timeRange.length-1&&(!n||n.byteLength<=0)){var c=e.player.buffered;c&&c.length>0&&(e.bufferEndTime=c.end(c.length-1)),e._isEnded(),e.log("load ended !!!==>>>",e.playerConfig.vid,JSON.stringify(u.range),", fragIndex,",u.fragIndex,", bufferEndTime,",e.bufferEndTime,",meta_duration,",e.mp4.meta.duration)}n&&e.mse&&n&&n.byteLength>0&&e._appendBuffer(Ee.VIDEO,n,u,a)}catch(h){e.log("appendBuffer error",h);var d=new Lt(e.player,{errorType:"runtime",errorTypeCode:Hi.runtime,errorCode:Ct.mse,vid:e.player.config.vid,errorMessage:h.message,mediaError:{code:Ct.mse,message:h.message}});e._errorHandler(d)}r!=null&&r.state&&e._onTimeUpdate()}}),gt(Ne(e),"_onWaiting",function(){var r=Ne(e),n=r.player,a=r.config;clearTimeout(e._waitInBufferTimer),e._waitInBufferTimer=null;var u=n.currentTime,l=n.bufferedPoint;l.end>0&&l.end-n.currentTime>=2&&e._waitAdjustTimeCnt0)){k.next=25;break}if(d=!0,!(u.meta.duration-c.end<.5)){k.next=17;break}return e._startProgress(),e.log("[seeking in buffered range], buffer end,",c.end,", duration,",u.meta.duration),k.abrupt("return");case 17:if(h=u.getFragmentIdx(c.end),e._curLoadSegmentIdx!==h){k.next=22;break}return e._startProgress(),e.log("[seeking in buffered range], seek fragIndex is current load segmentIdx",h),k.abrupt("return");case 22:u.seekTime=c.end,h<0&&(h=e._curLoadSegmentIdx),e.log("[seeking in buffered range], seekTime ",l,",bufferRange,",c.start,"-",c.end,", fragIndex,",h);case 25:return d||(u.seekTime=l,h=u.getFragmentIdx(l),h<0&&(h=e._curLoadSegmentIdx),e.log("[seekTime out buffer range], curTime,",l,", Idx,",h),f=Ne(e),m=f.mse,m&&m.isFull()&&(g=a.buffered2.bufferedList,y=g[g.length-1],m.clearOpQueues(Ee.VIDEO),e._checkRemoveSourceBuffer([y.start,y.end],a.currentTime,!0,!0))),k.next=28,u.cancelLoading();case 28:u.resetFragmentLoadState(h),e._curLoadSegmentIdx=h,e._onTimeUpdate(),e._startProgress(),e._isEnded();case 33:case"end":return k.stop()}},r)}))),gt(Ne(e),"changeDefineCanPlay",function(r,n,a,u){var l=Ne(e),c=l.player;if(c.ended){c.currentTime=0;return}e.log("[oldChangeDefinition],this._changeDefState,",e._changeDefState),c.currentTime=e._changeDefState?e._changeDefState.currentTime:r;var d=e._changeDefState?e._changeDefState.paused:n;d?c.pause():c.play(),e._changeDefState=null,c.emit(Ir,{from:a,to:u})}),gt(Ne(e),"changeDefinition",function(){var r=je(ve().mark(function n(a,u){var l,c,d,h,f,m,g;return ve().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(l=Ne(e),c=l.player,d=l.config,h=l.mp4,u||(u=c.curDefinition),e._MSEError=!1,!d.witchBitRateWay){L.next=6;break}return e.oldChangeDefinition(a,u),L.abrupt("return");case 6:if(c.emit(zr,{from:u,to:a}),f=c.currentTime,m=h.getFragmentIdx(f),m<0&&(m=e._curLoadSegmentIdx),e.log("switchBitrate:point,fragIndex,",m,",startTime,",h.timeRange[m].startTime,",currentTime,",c.currentTime),!h){L.next=16;break}return e.mp4.changeBitRateTime=f,L.next=15,h.cancelLoading();case 15:h._metaLoading&&(h._metaLoading=!1);case 16:return e._removeBuffeEndTime=h.timeRange[m].startTime,e._isChangeDefinition=!0,g=c.getBufferedRange(c.buffered),g[1]>0&&g[1]-c.currentTime>5&&(e.mse.clearOpQueues(Ee.VIDEO),e.mse.remove(Ee.VIDEO,c.currentTime+5,g[1])),e.log("switchBitrate: resetFragmentLoadState,",m),h.resetFragmentLoadState(m),e._curLoadSegmentIdx=m,L.next=25,e.mp4.changeBitRate(a);case 25:e._onTimeUpdate(),c.emit("RESOLUTION_UPDATE",a);case 27:case"end":return L.stop()}},n)}));return function(n,a){return r.apply(this,arguments)}}()),gt(Ne(e),"_replayHook",function(){var r;return(r=e.player)===null||r===void 0||r.play(),!1}),gt(Ne(e),"_retryHook",function(){return e.beforePlayerInit(),!1}),e.mp4=null,e.mse=null,e._waitAdjustTimeCnt=0,e._lastCheckTime=Pt.nowTime(),e._removeBuffeEndTime=0,e._pendingPromises=[],e}return Ri(i,[{key:"afterCreate",value:function(){var e=this;window.__mp4player=this;try{Ue.defineGetterOrSetter(this.player,{__url:{get:function(){try{return e.mse?e.mse.url:e.config.url}catch{return null}}}})}catch{}this._proxyPlayer()}},{key:"attachEvents",value:function(){this.off(gi,this._onSeeking),this.on(gi,this._onSeeking),this.on(Li,this._onWaiting),this.off(Bt,this.switchURL),this.on(Bt,this.switchURL)}},{key:"detachEvents",value:function(){this.off(gi,this._onSeeking),this.off(Li,this._onWaiting),this.off(Bt,this.switchURL)}},{key:"_proxyPlayer",value:function(){var e=this;typeof this.player.playNext=="function"&&(Ua=this.player.playNext),this.player.playNext=function(){e.playNext.apply(e,arguments)},Rn=this.player._startInit,Oa=this.player.switchURL,Ka=this.player.changeDefinition,this.player._startInit=this._playerStartInit.bind(this),this.player.switchURL=this.switchURL.bind(this),this.player.changeDefinition=this.changeDefinition.bind(this),this.player.removeHooks("replay",this._replayHook),this.player.removeHooks("retry",this._retryHook)}},{key:"_playerStartInit",value:function(e){var r=this,n=this.config,a=this.playerConfig;n.supportHevc===void 0&&le!=null&&le.isHevcSupported&&le.isHevcSupported()&&(n.supportHevc=!0);var u=this.initMp4();this._initPromise=u,this._addPendingPromise(this._initPromise),this.mse&&S.typeOf(e)==="String"&&/^blob/.test(e)&&e!==this.mse.url&&(e=a.url),u.then(function(){r.mse&&(e=r.mse.url),r.attachEvents(),r._startProgress()}).catch(function(l){var c=r._initPromise?r._initPromise.isBreak:!1;if(!(r.isDestroy||c)){var d=l;d.errorCode||(d=new Lt(r.player,{errorType:Hi.RUNTIME,errorCode:(l==null?void 0:l.errorCode)||Ct.other,vid:r.playerConfig.vid,errorMessage:(l==null?void 0:l.errorMessage)||(l==null?void 0:l.message),mediaError:{code:(l==null?void 0:l.httpCode)||Ct.other,message:(l==null?void 0:l.errorMessage)||(l==null?void 0:l.message),errorType:l==null?void 0:l.errorType}}),d.url=e),r.useVideoLoad=!0,r.player.vtype="MP4_1",r.player.emit("playCatch",r.player.vtype,d)}}).finally(function(){if(r._initPromise){var l=r._initPromise.isBreak;l||(r._initPromise&&r._removePendingPromise(r._initPromise),r._initPromise=null,!r.isDestroy&&!l&&Rn.call(r.player,e))}})}},{key:"initMp4",value:function(){var e=this,r=this.player;r.config.vid||(r.config.vid=Date.now());var n=new rf;return this.mp4&&(this.mp4.off(tt.META_READY,this._onMp4MetaReady),this.mp4.off(tt.ERROR,this._onMp4Error),this.mp4.off(tt.MOOV_REQ_PROGRESS,this._onMp4DataCallBack),this.mp4.destroy(),this.mp4=null),this.mp4=new qh(r.config.url,si(si({},this.config),{},{vid:r.config.vid})),this.mp4.on(tt.META_READY,this._onMp4MetaReady),this.mp4.on(tt.ERROR,this._onMp4Error),this.mp4.on(tt.MOOV_REQ_PROGRESS,this._onMp4DataCallBack),this.mp4.on(tt.UPDATE_LOAD_IDX,function(a){e._curLoadSegmentIdx=a,e.log("[update curLoadSegmentIdx]",a)}),this.mp4.init(),n}},{key:"setConfig",value:function(e){this.config=Object.assign(this.config,e)}},{key:"playNext",value:function(e){var r=this.player;this._defInited=!1,r.resetState(),r._currentTime=0,r._duration=0,r.isPlaying=!1,this._MSEError=!1,r.pause(),this._reset(),r.setConfig(e),this.log("[Index] playNext",e),r.play(),this.emit("playnext")}},{key:"checkDegrade",value:function(e){var r=this.config.closeDowngrade;return!r||e.httpCode==="networkError"}},{key:"_errorHandler",value:function(e){var r,n=this.player,a=this.config;if(!(!n||this.useVideoLoad)){!e.url&&(r=this.mp4)!==null&&r!==void 0&&r.url&&(e.url=this.mp4.url);var u=n.paused;console.error("final error !!!!, ",a.vid,e),this.player.vtype="MP4_2",this.player.emit("playCatch",this.player.vtype,e);var l=this.checkDegrade(e);if(l)this._initPromise?this._removeAndRejectInitPromise(e):this._startDegradedPlayback(e,u);else{this.player.pause(),this._reset();var c=n.currentTime;this.destroyMSE(),n.currentTime=c,this.emit("error",e)}}}},{key:"_startDegradedPlayback",value:function(e,r){var n=this;console.log(">>>_startDegradedPlayback");var a=this.player,u=this.playerConfig;this.useVideoLoad=!0,this.destroyMSE(),this._currentTime=a.currentTime,this.__onmetadataHandle=function(){n._currentTime&&(a.currentTime=n._currentTime),r?n.player.pause():n.player.play(),a.media.removeEventListener("loadedmetadata",n.__onmetadataHandle),n.__onmetadataHandle=null},a.media.addEventListener("loadedmetadata",this.__onmetadataHandle);var l=u.url;a.media.src=l}},{key:"_addPendingPromise",value:function(e){this._pendingPromises.push(e)}},{key:"_removePendingPromise",value:function(e){var r=this._pendingPromises.indexOf(e);r>-1&&this._pendingPromises.splice(r,1)}},{key:"_cancelPendingPromises",value:function(){this._pendingPromises.length>0&&this._pendingPromises.forEach(function(e){e.reject(nf)}),this._pendingPromises=[]}},{key:"_removeAndRejectInitPromise",value:function(e){this._initPromise&&(this._removePendingPromise(this._initPromise),this._initPromise.reject(e))}},{key:"_initMse",value:function(){var t=je(ve().mark(function r(n){var a=this,u,l,c,d,h;return ve().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:if(!this.mse){m.next=4;break}return m.next=3,this.mse.unbindMedia();case 3:this.mse=null;case 4:u=!!n.videoCodec,l=!!n.audioCodec,u&&l?c='video/mp4; codecs="'.concat(n.videoCodec,', mp4a.40.5"'):u?c='video/mp4; codecs="'.concat(n.videoCodec,'"'):c='video/mp4; codecs="mp4a.40.5"',d=gt({},Ee.VIDEO,{mimeType:"video/mp4",codec:c}),this.mse=new Ee,h=this.mse.bindMedia(this.player.video),h.then(function(){var g=Object.keys(d);try{for(var y=0;y1e3&&(this._lastCheckTime=Pt.nowTime(),this._loadStuckCheck(),this._checkRemoveSourceBuffer(c,a.currentTime));var d=a.paused?a.currentTime+u.minBufferLength:a.currentTime+u.maxBufferLength;c[1]-d<0&&l.every(function(h,f){if(h.downloaded)return!0;if(!e._isChangeDefinition&&h.endTime-h.startTime>1&&e._isInBuffer(h))return h.downloaded=!0,h.isLoading=!0,e.log("onTimeUpdate, ".concat(f," download segment, has buffer"),h.startTime,h.endTime),!0;h.startTime-a.currentTime>>, ",f,",IdxTimeRange, ",h.startTime,"-",h.endTime,",buffEnd, ",c[1],",playCurTime,",a.currentTime,", bufferLen,",c[1]-a.currentTime,",bufferRangeList,",e.player.buffered2?e.player.buffered2.bufferedList:null),e._loadData())}),this._isEnded()}this.checkRemoveOldBitrateBuffer()}}},{key:"checkRemoveOldBitrateBuffer",value:function(){var e=this.mse,r=this.player;e&&this._removeBuffeEndTime>0&&r.currentTime>this._removeBuffeEndTime+1&&(this.log("remove old bitrate buffer",this._removeBuffeEndTime),e.remove(Ee.VIDEO,0,this._removeBuffeEndTime-1),this._removeBuffeEndTime=0)}},{key:"_isInBuffer",value:function(e){for(var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=!1,a=this.player.video.buffered,u=0;u>>",n.context?n.context:null,", costTime,",n.costtime)})}},{key:"_appendBuffer",value:function(e,r){var n=this,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},u=arguments.length>3?arguments[3]:void 0,l=this.mse,c=this.config;l.append(e,r,{vid:c.vid,fragIndex:a.fragIndex,range:a.range,dataLen:r.byteLength,state:u}).then(function(d){if(n.log("player appendBuffer end ==>>>",d.context?d.context:null,", costTime,",d.costtime,", opt,",d.name,",bufferRange,",n.player.getBufferedRange()),n.mse&&a.state&&a.fragIndex===n.mp4.timeRange.length-1){var h=n.player.buffered;h&&h.length>0&&(n.bufferEndTime=h.end(h.length-1)),n._isEnded(),n.log("loaded ended !!!==>>>",a.range,", fragIndex,",a.fragIndex,", bufferEndTime,",n.bufferEndTime,",meta_duration,",n.mp4.meta.duration)}}).catch(function(d){if(console.log("[MSE error]",d),d&&l!==null&&l!==void 0&&l.isFull()){var h=n.player.getBufferedRange(n.player.buffered2);n._checkRemoveSourceBuffer(h,n.player.currentTime,!0)}})}},{key:"_checkRemoveSourceBuffer",value:function(e,r,n){var a=this,u=this.mse,l=this.mp4,c=this.player;if(!(!u||!l||!c)&&(n&&(clearTimeout(this._removeBufferTimer),this._removeBufferTimer=null),e||(e=c.getBufferedRange(c.buffered2)),r||(r=c.currentTime),!(!n&&Pt.nowTime()-this._checkRemoveBufferLastTime<=this.config.removeBufferLen||this.endofstream)&&(this._checkRemoveBufferLastTime=Pt.nowTime(),e&&e[0]>=0&&(r-e[0]>this.config.removeBufferLen||u.isFull())))){var d=e[1],h=l.getFragmentIdx(d);if(h>=0&&l.timeRange[h].startTime>>",e[0],f),u.remove(Ee.VIDEO,e[0],f)):u.isFull()&&!this._removeBufferTimer&&(this._removeBufferTimer=setTimeout(function(){a._checkRemoveSourceBuffer(null,null,!0)},10*1e3))}}}},{key:"_isEnded",value:function(){var e=this.player,r=this.mp4,n=e.bufferedPoint,a=n?n.end:0;return!this.endofstream&&this.mse&&r.meta.duration-e.currentTime<.5&&(this.log("[check player isEnded],deal mse.endOfStream, currentTime,",e.currentTime,", bufferend,",a,", duration,",r.meta.duration),this.endofstream=!0,this.mse.endOfStream()),r&&r.meta&&r.meta.duration-e.currentTime<.5?(this._stopProgress(),this.log("[check player isEnded],stopProgress and endOfStream,currentTime, ",e.currentTime,", bufferend,",a,", duration,",r.meta.duration),this.mse&&this.mse.endOfStream(),!0):!1}},{key:"switchURL",value:function(e){this.changeDefinition(e)}},{key:"oldChangeDefinition",value:function(e,r){var n=this,a=this.config,u=this.player;this.log("[oldChangeDefinition],currentTime,",u.currentTime,",from,",r,",to,",e);var l=u.currentTime,c=u.paused;this._changeDefState||(this._changeDefState={currentTime:l,paused:c},this.log("[oldChangeDefinition],currentTime,",u.currentTime,",pause,",c)),u.config.url=e.url,a.focusUserDefinition=!0,u.currentTime=0,u.pause(),this._reset(),this._isMseInit=!1,this._changeDefineCanPlay&&u.off("canplay",this._changeDefineCanPlay),this._changeDefineCanPlay=function(){n.changeDefineCanPlay(l,c,r,e),n._changeDefineCanPlay=null},u.once("canplay",this._changeDefineCanPlay),this.player.video.load(),this.initMp4()}},{key:"_loadStuckCheck",value:function(){var e=this,r=this.config,n=this.player;r.disableBufferBreakCheck||(n.currentTime-(this._lastCurrentTime||0)>.1||n.paused?(this._bufferBreakFlag===1||this._bufferBreakFlag===2)&&(this.log("视频没有卡死,重置卡死标记"),this._bufferBreakFlag=0,clearTimeout(this._bufferBreakTimer),this._bufferBreakFlag=null):this._bufferBreakFlag||(this._bufferBreakFlag=1,this.log("卡死计时开始! 持续".concat(r.waitingTimeOut,"毫秒则确认卡死")),this._bufferBreakTimer=setTimeout(function(){e.isDestroy||(e._bufferBreakFlag===1&&(e._bufferBreakFlag=2,e.log("确认卡死!!!"),e._errorHandler(new Lt(e.player,{errorType:"runtime",errorTypeCode:Hi.runtime,errorCode:Ct.waitTimeout,errorMessage:"wait_timeout",vid:r.vid}))),e._bufferBreakTimer=null)},r.waitingTimeOut)),this._lastCurrentTime=n.currentTime)}},{key:"isDestroy",get:function(){return!this.player}},{key:"_stopProgress",value:function(){this._hasStartProgress=!1,this._requestTimer&&(this._requestTimer.stop(),this._requestTimer=null),this._bufferBreakTimer&&(clearTimeout(this._bufferBreakTimer),this._bufferBreakTimer=null,this._bufferBreakFlag=void 0)}},{key:"_startProgress",value:function(){var e=this;this._hasStartProgress||(this._stopProgress(),this._requestTimer=new tf(function(){e._requestTimer&&e._onTimeUpdate()}),this._requestTimer.tickEvery(this.config.tickInSeconds),this._hasStartProgress=!0)}},{key:"log",value:function(e){for(var r=this.playerConfig,n=r&&r.vid?"[Index]".concat(r.vid," ").concat(e):"[Index] ".concat(e),a=arguments.length,u=new Array(a>1?a-1:0),l=1;l=0;--x){var T=this.tryEntries[x],X=T.completion;if(T.tryLoc==="root")return b("end");if(T.tryLoc<=this.prev){var M=i.call(T,"catchLoc"),F=i.call(T,"finallyLoc");if(M&&F){if(this.prev=0;--b){var x=this.tryEntries[b];if(x.tryLoc<=this.prev&&i.call(x,"finallyLoc")&&this.prev=0;--v){var b=this.tryEntries[v];if(b.finallyLoc===p)return this.complete(b.completion,b.afterLoc),E(b),d}},catch:function(p){for(var v=this.tryEntries.length-1;v>=0;--v){var b=this.tryEntries[v];if(b.tryLoc===p){var x=b.completion;if(x.type==="throw"){var T=x.arg;E(b)}return T}}throw new Error("illegal catch attempt")},delegateYield:function(p,v,b){return this.delegate={iterator:I(p),resultName:v,nextLoc:b},this.method==="next"&&(this.arg=void 0),d}},s}function is(s){"@babel/helpers - typeof";return is=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},is(s)}function za(s,o,i,t,e,r,n){try{var a=s[r](n),u=a.value}catch(l){i(l);return}a.done?o(u):Promise.resolve(u).then(t,e)}function He(s){return function(){var o=this,i=arguments;return new Promise(function(t,e){var r=s.apply(o,i);function n(u){za(r,t,e,n,a,"next",u)}function a(u){za(r,t,e,n,a,"throw",u)}n(void 0)})}}function mr(s,o){if(!(s instanceof o))throw new TypeError("Cannot call a class as a function")}function Ba(s,o){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function oe(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function of(s,o){if(o&&(typeof o=="object"||typeof o=="function"))return o;if(o!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return oe(s)}function Tu(s){var o=af();return function(){var t=Kr(s),e;if(o){var r=Kr(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return of(this,e)}}function uf(s,o){if(typeof s!="object"||s===null)return s;var i=s[Symbol.toPrimitive];if(i!==void 0){var t=i.call(s,o||"default");if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(s)}function wu(s){var o=uf(s,"string");return typeof o=="symbol"?o:String(o)}var lf=function(){function s(){mr(this,s),Q(this,"_ttfb",0),Q(this,"_demuxStart",0),Q(this,"_demuxEnd",0),Q(this,"_demuxCost",0),Q(this,"_remuxStart",0),Q(this,"_remuxEnd",0),Q(this,"_remuxCost",0),Q(this,"_appendStart",0),Q(this,"_appendEnd",0),Q(this,"_appendCost",0)}return pr(s,[{key:"set",value:function(i,t){this["_".concat(i)]=t}},{key:"start",value:function(i){this["_".concat(i,"Start")]=Date.now()}},{key:"end",value:function(i){this["_".concat(i,"End")]=Date.now(),this["_".concat(i,"Cost")]=this["_".concat(i,"Cost")]+(this["_".concat(i,"End")]-this["_".concat(i,"Start")])}},{key:"transferCost",get:function(){return{ttfbCost:this._ttfb,demuxCost:this._demuxCost,remuxCost:this._remuxCost,appendCost:this._appendCost}}}]),s}(),pi={TTFB:"ttfb",DEMUX:"demux",REMUX:"remux",APPEND:"append"},Ut=new $e("BufferService"),cf=function(){function s(o,i){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};mr(this,s),Q(this,"flv",null),Q(this,"_demuxer",new Ko),Q(this,"_remuxer",null),Q(this,"_mse",null),Q(this,"_softVideo",null),Q(this,"_sourceCreated",!1),Q(this,"_needInitSegment",!0),Q(this,"_discontinuity",!0),Q(this,"_contiguous",!1),Q(this,"_initSegmentId",""),Q(this,"_cachedBuffer",null),Q(this,"_demuxStartTime",0),Q(this,"_opts",null),this.flv=o,this._opts=t,i?this._softVideo=i:(this._remuxer=new _s(this._demuxer.videoTrack,this._demuxer.audioTrack),this._mse=new Ee(null,{preferMMS:typeof t.preferMMS=="boolean"?t.preferMMS:!!t.perferMMS}),this._mse.bindMedia(o.media))}return pr(s,[{key:"baseDts",get:function(){var i,t;return(i=this._demuxer)===null||i===void 0||(t=i._fixer)===null||t===void 0?void 0:t._baseDts}},{key:"blobUrl",get:function(){var i;return(i=this._mse)===null||i===void 0?void 0:i.url}},{key:"isFull",value:function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ee.VIDEO;return this._mse.isFull(i)}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!0,this._initSegmentId=""}},{key:"unContiguous",value:function(i){this._contiguous=!1,this._demuxStartTime=i}},{key:"reset",value:function(){var o=He(fe().mark(function t(){var e,r=arguments;return fe().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(e=r.length>0&&r[0]!==void 0?r[0]:!1,!(this._mse&&!e)){a.next=6;break}return a.next=4,this._mse.unbindMedia();case 4:return a.next=6,this._mse.bindMedia(this.flv.media);case 6:this._needInitSegment=!0,this._discontinuity=!0,this._contiguous=!1,this._sourceCreated=!1,this._initSegmentId="",this.resetSeamlessSwitchStats();case 12:case"end":return a.stop()}},t,this)}));function i(){return o.apply(this,arguments)}return i}()},{key:"resetSeamlessSwitchStats",value:function(){this.seamlessLoadingSwitch=null,this.seamlessLoadingSwitching=!1,this._demuxer&&(this._demuxer.seamlessLoadingSwitching=!1)}},{key:"endOfStream",value:function(){var o=He(fe().mark(function t(){return fe().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(!this._mse){r.next=7;break}if(!this._sourceCreated){r.next=5;break}return r.next=4,this._mse.endOfStream();case 4:this.flv.emit(K.BUFFEREOS);case 5:r.next=8;break;case 7:this._softVideo&&this._softVideo.endOfStream();case 8:case"end":return r.stop()}},t,this)}));function i(){return o.apply(this,arguments)}return i}()},{key:"updateDuration",value:function(){var o=He(fe().mark(function t(e){return fe().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:if(!this._mse){n.next=7;break}if(this._mse.isOpened){n.next=4;break}return n.next=4,this._mse.open();case 4:return Ut.debug("update duration",e),n.next=7,this._mse.updateDuration(e);case 7:case"end":return n.stop()}},t,this)}));function i(t){return o.apply(this,arguments)}return i}()},{key:"destroy",value:function(){var o=He(fe().mark(function t(){return fe().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(!this._mse){r.next=3;break}return r.next=3,this._mse.unbindMedia();case 3:this._mse=null,this._softVideo=null,this._demuxer=null,this._remuxer=null;case 7:case"end":return r.stop()}},t,this)}));function i(){return o.apply(this,arguments)}return i}()},{key:"appendBuffer",value:function(){var o=He(fe().mark(function t(e){var r=this,n,a,u,l,c,d,h,f,m,g,y,L,k,_,w,Z,C;return fe().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:if(n=!1,this._cachedBuffer&&(e=bi(this._cachedBuffer,e),this._cachedBuffer=null),a=this._demuxer,!(!e||!e.length||!a)){E.next=5;break}return E.abrupt("return");case 5:E.prev=5,this.flv._transferCost.start(pi.DEMUX),a.demuxAndFix(e,this.seamlessLoadingSwitching||this._discontinuity,this._contiguous,this._demuxStartTime,this.seamlessLoadingSwitching),this.seamlessLoadingSwitching=!1,this.flv._transferCost.end(pi.DEMUX),E.next=15;break;case 12:throw E.prev=12,E.t0=E.catch(5),new we(B.DEMUX,B.SUB_TYPES.FLV,E.t0);case 15:if(u=a.videoTrack,l=a.audioTrack,c=a.metadataTrack,!this.seamlessLoadingSwitch){E.next=25;break}if(d=u.samples.findIndex(function(P){return P.originDts===u.lastKeyFrameDts}),!(d>=0)){E.next=25;break}return u.samples.splice(d),E.next=22,this.seamlessLoadingSwitch();case 22:this.seamlessLoadingSwitch=null,e=null,n=!0;case 25:if(h=u.exist(),f=l.exist(),this._opts.onlyAudio&&(h=!1,u.present=!1),this._opts.onlyVideo&&(f=!1,l.present=!1),!(!h&&u.present||!f&&l.present)){E.next=42;break}if(m=0,g=h?u:f?l:void 0,g&&g.samples.length&&(m=(g.samples[g.samples.length-1].originPts-g.samples[0].originPts)/g.timescale*1e3),!(m>this._opts.analyzeDuration)){E.next=40;break}Ut.warn("analyze duration exceeded, ".concat(m,"ms"),g),u.present=h,l.present=f,this.flv.emit(K.ANALYZE_DURATION_EXCEEDED,{duration:m}),E.next=42;break;case 40:return this._cachedBuffer=e,E.abrupt("return");case 42:if(y=u.type,L=l.type,this._fireEvents(u,l,c),n||(this._discontinuity=!1,this._contiguous=!0,this._demuxStartTime=0),k=this._mse,_=function(){var I;if((I=r.flv)!==null&&I!==void 0&&I.emit){var D;(D=r.flv)===null||D===void 0||D.emit(K.APPEND_BUFFER,{})}},this.flv.emit(K.DEMUXED_TRACK,{videoTrack:u}),w="".concat(u.codec,"/").concat(u.width,"/").concat(u.height,"/").concat(l.codec,"/").concat(l.config),w!==this._initSegmentId&&(this._needInitSegment=!0,this._initSegmentId=w,this._emitMetaParsedEvent(u,l)),!k){E.next=81;break}if(this._sourceCreated){E.next=59;break}return E.next=55,k.open();case 55:h&&(Ut.log("codec: video/mp4;codecs=".concat(u.codec)),k.createSource(y,"video/mp4;codecs=".concat(u.codec))),f&&(Ut.log("codec: audio/mp4;codecs=".concat(l.codec)),k.createSource(L,"audio/mp4;codecs=".concat(l.codec))),this._sourceCreated=!0,this.flv.emit(K.SOURCEBUFFER_CREATED);case 59:E.prev=59,this._needInitSegment&&!this._opts.mseLowLatency&&(u.duration=this._opts.durationForMSELowLatencyOff*u.timescale,l.duration=this._opts.durationForMSELowLatencyOff*f.timescale),this.flv._transferCost.start(pi.REMUX),Z=this._remuxer.remux(this._needInitSegment),this.flv._transferCost.end(pi.REMUX),E.next=69;break;case 66:throw E.prev=66,E.t1=E.catch(59),new we(B.REMUX,B.SUB_TYPES.FMP4,E.t1);case 69:if(!(this._needInitSegment&&!Z.videoInitSegment&&!Z.audioInitSegment)){E.next=71;break}return E.abrupt("return");case 71:return this._needInitSegment=!1,C=[],Z.videoInitSegment&&C.push(k.append(y,Z.videoInitSegment)),Z.audioInitSegment&&C.push(k.append(L,Z.audioInitSegment)),Z.videoSegment&&C.push(k.append(y,Z.videoSegment)),Z.audioSegment&&C.push(k.append(L,Z.audioSegment)),this.flv._transferCost.start(pi.APPEND),E.abrupt("return",Promise.all(C).then(_).then(function(){r.flv._transferCost.end(pi.APPEND),_()}));case 81:this._softVideo&&(this._softVideo.appendBuffer(u,l),_());case 82:case"end":return E.stop()}},t,this,[[5,12],[59,66]])}));function i(t){return o.apply(this,arguments)}return i}()},{key:"evictBuffer",value:function(){var o=He(fe().mark(function t(e){var r=this,n,a,u,l;return fe().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(n=this.flv.media,!(!this._mse||!this._demuxer||!n||!e||e<0)){d.next=3;break}return d.abrupt("return");case 3:if(a=n.currentTime,u=a-e,!(u<=0)){d.next=7;break}return d.abrupt("return");case 7:if(l=Xe.start(Xe.get(n)),!(l+1>=u)){d.next=10;break}return d.abrupt("return");case 10:return d.abrupt("return",this._mse.clearBuffer(0,u).then(function(){return r.flv.emit(K.REMOVE_BUFFER,{removeEnd:u})}));case 11:case"end":return d.stop()}},t,this)}));function i(t){return o.apply(this,arguments)}return i}()},{key:"_emitMetaParsedEvent",value:function(i,t){i.exist()&&this.flv.emit(K.METADATA_PARSED,{type:"video",track:i,meta:{codec:i.codec,timescale:i.timescale,width:i.width,height:i.height,sarRatio:i.sarRatio,baseDts:i.baseDts}}),t.exist()&&this.flv.emit(K.METADATA_PARSED,{type:"audio",track:t,meta:{codec:t.codec,channelCount:t.channelCount,sampleRate:t.sampleRate,timescale:t.timescale,baseDts:t.baseDts}}),Ut.debug("track parsed",i,t)}},{key:"_fireEvents",value:function(i,t,e){var r=this;Ut.debug("videoTrack samples count: ".concat(i.samples.length,", audioTrack samples count: ").concat(t.samples.length)),e.flvScriptSamples.forEach(function(n){r.flv.emit(K.FLV_SCRIPT_DATA,n),Ut.debug("flvScriptData",n)}),i.samples.forEach(function(n){n.keyframe&&r.flv.emit(K.KEYFRAME,{pts:n.originPts})}),i.warnings.forEach(function(n){var a;switch(n.type){case Ge.LARGE_AV_SHIFT:a=K.LARGE_AV_FIRST_FRAME_GAP_DETECT;break;case Ge.LARGE_VIDEO_GAP:a=K.LARGE_VIDEO_DTS_GAP_DETECT;break;case Ge.LARGE_VIDEO_GAP_BETWEEN_CHUNK:a=K.MAX_DTS_DELTA_WITH_NEXT_SEGMENT_DETECT;break}a&&r.flv.emit(K.STREAM_EXCEPTION,it(it({},n),{},{type:a})),Ut.warn("video exception",n)}),t.warnings.forEach(function(n){var a;switch(n.type){case Ge.LARGE_AUDIO_GAP:a=K.LARGE_AUDIO_DTS_GAP_DETECT;break;case Ge.AUDIO_FILLED:a=K.AUDIO_GAP_DETECT;break;case Ge.AUDIO_DROPPED:a=K.AUDIO_OVERLAP_DETECT;break}a&&r.flv.emit(K.STREAM_EXCEPTION,it(it({},n),{},{type:a})),Ut.warn("audio exception",n)}),e.seiSamples.forEach(function(n){r.flv.emit(K.SEI,it(it({},n),{},{sei:{code:n.data.type,content:n.data.payload,dts:n.pts}}))})}}]),s}();function df(s){var o=it({retryCount:3,retryDelay:1e3,disconnectRetryCount:0,loadTimeout:1e4,maxReaderInterval:5e3,preloadTime:5,defaultVodLoadSize:1e7,isLive:!1,softDecode:!1,bufferBehind:10,maxJumpDistance:3,analyzeDuration:2e4,seamlesslyReload:!1,keepStatusAfterSwitch:!0,onlyVideo:!1,onlyAudio:!1,preferMMS:!1,mseLowLatency:!0,durationForMSELowLatencyOff:6,chunkCountForSpeed:50,skipChunkSize:1e3,longtimeNoReceived:3e3,enableStartGapJump:!0},s);return o.isLive&&o.preloadTime&&(o.maxLatency||(o.maxLatency=o.preloadTime*2),o.targetLatency||(o.targetLatency=o.preloadTime),(o.disconnectTime===null||o.disconnectTime===void 0)&&(o.disconnectTime=o.maxLatency)),o}function Ja(s,o){var i=0,t=s.length-1,e=0,r=0,n=t;for(o=s[e]&&ou.disconnectTime&&e.disconnect()}}}}),Q(oe(e),"_onPlay",function(){var r,n,a=e._opts.softDecode||((r=e.media)===null||r===void 0||(n=r.buffered)===null||n===void 0?void 0:n.length);if(e.isLive){!e._loading&&a&&e.replay(void 0,!0);return}var u=e.bufferInfo();(u.start||u.nextStart)>Tr&&e._tick()}),Q(oe(e),"_onLoadeddata",function(){e.isLive&&!e._opts.mseLowLatency&&e.media.duration!==1/0&&e._bufferService.updateDuration(1/0).catch(function(r){})}),Q(oe(e),"_onSeeking",He(fe().mark(function r(){return fe().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:!e.isLive&&e.seekable&&(e._preLoadEndPoint=-1,e._checkPreload());case 1:case"end":return a.stop()}},r)}))),Q(oe(e),"_onTimeupdate",function(){if(e.media){var r=e._opts,n=e.media.currentTime;if(r.isLive&&r.maxLatency&&r.targetLatency){var a=Xe.end(Xe.get(e.media)),u=a-n;u>=r.maxLatency&&(e.media.currentTime=a-r.targetLatency,e.emit(K.CHASEFRAME,{currentTime:e.media.currentTime,latency:r.targetLatency}))}e._seiService.throw(n,!0),!(r.isLive||!e.seekable||e._loading)&&e._checkPreload()}}),Q(oe(e),"_onWaiting",function(){e.isLive&&!e._loading&&e._disconnectRetryCount&&(e._disconnectRetryCount--,e.load())}),Q(oe(e),"_onBufferUpdate",function(){if(!e._opts.isLive){var r=e.bufferInfo(),n=r.end,a=r.nextEnd;Math.abs((n||a)-e.media.duration)<1&&(e._end(),e.media.readyState<=2&&e._tick())}}),Q(oe(e),"_checkPreload",He(fe().mark(function r(){var n,a,u,l,c,d,h,f,m,g;return fe().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:if(n=e.bufferInfo(),a=n.remaining,u=a===void 0?0:a,l=e._opts,c=e._keyframes.filepositions,d=e._keyframes.times,h=e.media.currentTime,!(u0&&arguments[0]!==void 0?arguments[0]:Tr;return Xe.info(Xe.get(this.media),(e=this.media)===null||e===void 0?void 0:e.currentTime,r)}},{key:"playbackQuality",value:function(){return fu(this.media)}},{key:"load",value:function(){var t=He(fe().mark(function r(n){var a,u=arguments;return fe().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(a=u.length>1&&u[1]!==void 0?u[1]:!1,this._bufferService){c.next=3;break}return c.abrupt("return");case 3:return c.next=5,this._reset(a);case 5:this._loadData(n,this._opts.isLive?[]:[0,this._opts.defaultVodLoadSize]),clearTimeout(this._tickTimer),this._tickTimer=setTimeout(this._tick,this._tickInterval);case 8:case"end":return c.stop()}},r,this)}));function e(r){return t.apply(this,arguments)}return e}()},{key:"replay",value:function(){var t=He(fe().mark(function r(){var n=this,a,u,l=arguments;return fe().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(a=l.length>0&&l[0]!==void 0?l[0]:this._opts.seamlesslyReload,u=l.length>1?l[1]:void 0,this.media){d.next=4;break}return d.abrupt("return");case 4:if(this._resetDisconnectCount(),!a){d.next=11;break}return d.next=8,this._clear();case 8:setTimeout(function(){n._seamlessSwitching=!0,n._loadData(n._opts.url),n._bufferService.seamlessSwitch()}),d.next=13;break;case 11:return d.next=13,this.load();case 13:return d.abrupt("return",this.media.play(!u).catch(function(){}));case 14:case"end":return d.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()},{key:"disconnect",value:function(){var e;return Wt.debug("disconnect!"),(e=this._bufferService)===null||e===void 0||e.resetSeamlessSwitchStats(),this._clear()}},{key:"switchURL",value:function(){var t=He(fe().mark(function r(n,a){var u=this;return fe().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(this._bufferService){c.next=2;break}return c.abrupt("return");case 2:if(this._resetDisconnectCount(),!(this._loading&&a)){c.next=6;break}return this._bufferService.seamlessLoadingSwitch=function(){var d=He(fe().mark(function h(f){return fe().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,u._clear();case 2:u._bufferService.seamlessLoadingSwitching=!0,u._urlSwitching=!0,u._seamlessSwitching=!0,u._bufferService.seamlessSwitch(),u._loadData(n);case 7:case"end":return g.stop()}},h)}));return function(h){return d.apply(this,arguments)}}(),c.abrupt("return");case 6:if(!(!a||!this._opts.isLive)){c.next=11;break}return c.next=9,this.load(n);case 9:return this._urlSwitching=!0,c.abrupt("return",this.media.play(!0).catch(function(){}));case 11:return c.next=13,this._clear();case 13:setTimeout(function(){u._urlSwitching=!0,u._seamlessSwitching=!0,u._loadData(n),u._bufferService.seamlessSwitch()});case 14:case"end":return c.stop()}},r,this)}));function e(r,n){return t.apply(this,arguments)}return e}()},{key:"destroy",value:function(){var t=He(fe().mark(function r(){return fe().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.media){a.next=2;break}return a.abrupt("return");case 2:return this.removeAllListeners(),this._seiService.reset(),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),this.media.removeEventListener("waiting",this._onWaiting),this.media.removeEventListener("progress",this._onBufferUpdate),a.next=12,Promise.all([this._clear(),this._bufferService.destroy()]);case 12:this.media=null,this._bufferService=null;case 14:case"end":return a.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()},{key:"_emitError",value:function(e){var r,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;Wt.table(e),Wt.error(e),Wt.error((r=this.media)===null||r===void 0?void 0:r.error),this._urlSwitching&&(this._urlSwitching=!1,this._seamlessSwitching=!1,this.emit(K.SWITCH_URL_FAILED,e)),this.emit(K.ERROR,e),n&&(this._seiService.reset(),this._end())}},{key:"_reset",value:function(){var t=He(fe().mark(function r(){var n,a=arguments;return fe().wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return n=a.length>0&&a[0]!==void 0?a[0]:!1,this._seiService.reset(),this._bandwidthService.reset(),this._stats.reset(),l.next=6,this._clear();case 6:return l.next=8,this._bufferService.reset(n);case 8:case"end":return l.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()},{key:"_loadData",value:function(){var t=He(fe().mark(function r(n,a){var u;return fe().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(n&&(this._opts.url=n),u=n=this._opts.url,n){c.next=4;break}throw new Error("Source url is missing");case 4:if(this._opts.preProcessUrl&&(u=this._opts.preProcessUrl(n).url),this._mediaLoader.finnalUrl=u,this.emit(K.LOAD_START,{url:u,seamlessSwitching:this._seamlessSwitching}),Wt.debug("load data, loading:",this._loading,u),!this._loading){c.next=11;break}return c.next=11,this._mediaLoader.cancel();case 11:return this._loading=!0,c.prev=12,c.next=15,this._mediaLoader.load({url:u,range:a});case 15:c.next=21;break;case 17:return c.prev=17,c.t0=c.catch(12),this._loading=!1,c.abrupt("return",this._emitError(we.network(c.t0),!1));case 21:case"end":return c.stop()}},r,this,[[12,17]])}));function e(r,n){return t.apply(this,arguments)}return e}()},{key:"_clear",value:function(){var t=He(fe().mark(function r(){return fe().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._mediaLoader){a.next=3;break}return a.next=3,this._mediaLoader.cancel();case 3:clearTimeout(this._maxChunkWaitTimer),clearTimeout(this._tickTimer),this._loading=!1,this._firstProgressEmit=!1;case 7:case"end":return a.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()}],[{key:"isSupported",value:function(e){return!e||e==="video"||e==="audio"?Ee.isSupported():typeof WebAssembly<"u"}},{key:"enableLogger",value:function(){$e.enable(),Zi.enable()}},{key:"disableLogger",value:function(){$e.disable(),Zi.disable()}}]),i}(at);try{localStorage.getItem("xgd")?ur.enableLogger():ur.disableLogger()}catch{}var ff=function(){function s(o,i){var t=this;mr(this,s),Q(this,"_onLowDecode",function(){var e,r,n,a,u=t._opts,l=u.media,c=u.innerDegrade,d=u.backupURL;(e=t._plugin)===null||e===void 0||(r=e.player)===null||r===void 0||r.emit("lowdecode",l.degradeInfo),(n=t._plugin)===null||n===void 0||(a=n.player)===null||a===void 0||a.emit("core_event",it(it({},l.degradeInfo),{},{eventName:K.LOWDECODE})),(c===1||c===3)&&d&&t._degrade(d)}),Q(this,"_degrade",function(e){var r=t._plugin.player,n=r.video;if((n==null?void 0:n.TAG)==="MVideo"){var a=r.video.degradeVideo;r.video=a,n.degrade(e),e&&(r.config.url=e);var u=r.root.firstChild;u.TAG==="MVideo"&&r.root.replaceChild(a,u);var l=t._plugin.constructor.pluginName.toLowerCase();r.unRegisterPlugin(l),r.once("canplay",function(){r.play()})}}),Q(this,"forceDegradeToVideo",function(e){var r=t._opts.innerDegrade;(r===1||r===3)&&t._degrade(e)}),this._opts=o,this._plugin=i,this._init()}return pr(s,[{key:"_init",value:function(){var i=this._opts,t=i.media,e=i.isLive,r=i.preloadTime,n=i.innerDegrade,a=i.decodeMode;if(t){if(!e&&t.setPlayMode){t.setPlayMode("VOD");return}n&&t.setAttribute("innerdegrade",n),r&&t.setAttribute("preloadtime",r),t.setDecodeMode&&t.setDecodeMode(a),this._bindEvents()}}},{key:"_bindEvents",value:function(){var i=this._opts.media;i.addEventListener("lowdecode",this._onLowDecode)}},{key:"destroy",value:function(){var i,t;(i=this._opts)===null||i===void 0||(t=i.media)===null||t===void 0||t.removeEventListener("lowdecode",this._onLowDecode),this._plugin=null}}]),s}(),_u=function(s){ku(i,s);var o=Tu(i);function i(){var t;mr(this,i);for(var e=arguments.length,r=new Array(e),n=0;n=0;--x){var T=this.tryEntries[x],X=T.completion;if(T.tryLoc==="root")return b("end");if(T.tryLoc<=this.prev){var M=i.call(T,"catchLoc"),F=i.call(T,"finallyLoc");if(M&&F){if(this.prev=0;--b){var x=this.tryEntries[b];if(x.tryLoc<=this.prev&&i.call(x,"finallyLoc")&&this.prev=0;--v){var b=this.tryEntries[v];if(b.finallyLoc===p)return this.complete(b.completion,b.afterLoc),E(b),d}},catch:function(p){for(var v=this.tryEntries.length-1;v>=0;--v){var b=this.tryEntries[v];if(b.tryLoc===p){var x=b.completion;if(x.type==="throw"){var T=x.arg;E(b)}return T}}throw new Error("illegal catch attempt")},delegateYield:function(p,v,b){return this.delegate={iterator:I(p),resultName:v,nextLoc:b},this.method==="next"&&(this.arg=void 0),d}},s}function lr(s){"@babel/helpers - typeof";return lr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(o){return typeof o}:function(o){return o&&typeof Symbol=="function"&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},lr(s)}function Qa(s,o,i,t,e,r,n){try{var a=s[r](n),u=a.value}catch(l){i(l);return}a.done?o(u):Promise.resolve(u).then(t,e)}function me(s){return function(){var o=this,i=arguments;return new Promise(function(t,e){var r=s.apply(o,i);function n(u){Qa(r,t,e,n,a,"next",u)}function a(u){Qa(r,t,e,n,a,"throw",u)}n(void 0)})}}function De(s,o){if(!(s instanceof o))throw new TypeError("Cannot call a class as a function")}function $a(s,o){for(var i=0;i"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function vf(s,o){if(s==null)return{};var i={},t=Object.keys(s),e,r;for(r=0;r=0)&&(i[e]=s[e]);return i}function ss(s,o){if(s==null)return{};var i=vf(s,o),t,e;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(s);for(e=0;e=0)&&Object.prototype.propertyIsEnumerable.call(s,t)&&(i[t]=s[t])}return i}function ue(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function gf(s,o){if(o&&(typeof o=="object"||typeof o=="function"))return o;if(o!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ue(s)}function rn(s){var o=pf();return function(){var t=Or(s),e;if(o){var r=Or(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return gf(this,e)}}function Qt(s,o){return Sf(s)||mf(s,o)||Cu(s,o)||kf()}function yf(s){return bf(s)||Lf(s)||Cu(s)||Zf()}function bf(s){if(Array.isArray(s))return as(s)}function Sf(s){if(Array.isArray(s))return s}function Lf(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function Cu(s,o){if(s){if(typeof s=="string")return as(s,o);var i=Object.prototype.toString.call(s).slice(8,-1);if(i==="Object"&&s.constructor&&(i=s.constructor.name),i==="Map"||i==="Set")return Array.from(s);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return as(s,o)}}function as(s,o){(o==null||o>s.length)&&(o=s.length);for(var i=0,t=new Array(o);i0&&u[0]!==void 0?u[0]:0,n=u.length>1&&u[1]!==void 0?u[1]:1/0,a=this.hls.media,!(!this._mse||!a||r<0||n=this._mse.duration)){c.next=5;break}return c.abrupt("return");case 5:return c.abrupt("return",this._mse.clearBuffer(r,n).then(function(){return e.hls.emit(K.REMOVE_BUFFER,{start:r,end:n,removeEnd:n})}));case 6:case"end":return c.stop()}},t,this)}));function i(){return o.apply(this,arguments)}return i}()},{key:"evictBuffer",value:function(){var o=me(J().mark(function t(e){var r,n,a,u;return J().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:if(r=this.hls.media,!(!this._mse||!r||!e||e<0)){c.next=3;break}return c.abrupt("return");case 3:if(n=r.currentTime,a=n-e,!(a<=0)){c.next=7;break}return c.abrupt("return");case 7:if(u=Xe.start(Xe.get(r)),!(u+1>=a)){c.next=10;break}return c.abrupt("return");case 10:return c.abrupt("return",this.removeBuffer(0,a));case 11:case"end":return c.stop()}},t,this)}));function i(t){return o.apply(this,arguments)}return i}()},{key:"clearAllBuffer",value:function(){var o=me(J().mark(function t(){return J().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(!this._mse){r.next=2;break}return r.abrupt("return",this._mse.clearAllBuffer());case 2:case"end":return r.stop()}},t,this)}));function i(){return o.apply(this,arguments)}return i}()},{key:"decryptBuffer",value:function(i,t){return this._decryptor.decrypt(i,t)}},{key:"reset",value:function(){var o=me(J().mark(function t(){var e,r=arguments;return J().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(e=r.length>0&&r[0]!==void 0?r[0]:!1,!(this._mse&&!e)){a.next=8;break}return this._transmuxer=null,this._sourceCreated=!1,a.next=6,this._mse.unbindMedia();case 6:return a.next=8,this._mse.bindMedia(this.hls.media);case 8:this._needInitSegment=!0,this._directAppend=!1;case 10:case"end":return a.stop()}},t,this)}));function i(){return o.apply(this,arguments)}return i}()},{key:"endOfStream",value:function(){var o=me(J().mark(function t(){return J().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(!this._mse){r.next=5;break}if(!this._sourceCreated){r.next=5;break}return r.next=4,this._mse.endOfStream();case 4:this.hls.emit(K.BUFFEREOS);case 5:this._softVideo&&this._softVideo.endOfStream();case 6:case"end":return r.stop()}},t,this)}));function i(){return o.apply(this,arguments)}return i}()},{key:"setLiveSeekableRange",value:function(){var o=me(J().mark(function t(e,r){return J().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:this._mse&&this._mse.setLiveSeekableRange(e,r);case 1:case"end":return a.stop()}},t,this)}));function i(t,e){return o.apply(this,arguments)}return i}()},{key:"detachMedia",value:function(){var o=me(J().mark(function t(){return J().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:if(!this._mse){r.next=3;break}return r.next=3,this._mse.unbindMedia();case 3:case"end":return r.stop()}},t,this)}));function i(){return o.apply(this,arguments)}return i}()},{key:"destroy",value:function(){var o=me(J().mark(function t(){var e;return J().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return(e=this._decryptor)===null||e===void 0||e.destroy(),n.next=3,this.detachMedia();case 3:this._decryptor=null,this._mse=null,this._softVideo=null;case 6:case"end":return n.stop()}},t,this)}));function i(){return o.apply(this,arguments)}return i}()},{key:"_createMseSource",value:function(i,t){eo.debug("create mse source, videoCodec=".concat(i,", audioCodec=").concat(t));var e=this._mse;e&&(i&&(e.createSource(Ee.VIDEO,"video/mp4;codecs=".concat(i)),this._sourceCreated=!0),t&&(e.createSource(Ee.AUDIO,"audio/mp4;codecs=".concat(t)),this._sourceCreated=!0),this.hls.emit(K.SOURCEBUFFER_CREATED))}},{key:"_handleCodecChange",value:function(i,t){var e=[],r=this._mse,n=[{type:Ee.VIDEO,codecs:i==null?void 0:i.codec},{type:Ee.AUDIO,codecs:t==null?void 0:t.codec}];return n.filter(function(a){return!!a.codecs}).forEach(function(a){var u=a.type,l=a.codecs,c=r.getSourceBuffer(u);if(c){var d=l.split(",")[0];new RegExp(d,"ig").test(c.mimeType)||e.push(r.changeType(u,"".concat(u,"/mp4;codecs=").concat(l)))}}),e}},{key:"seamlessSwitch",value:function(){this._needInitSegment=!0}},{key:"isFull",value:function(){var i,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ee.VIDEO;return(i=this._mse)===null||i===void 0?void 0:i.isFull(t)}}]),s}();function xf(s){var o=(s==null?void 0:s.media)||document.createElement("video");return ge(ge({maxPlaylistSize:50,retryCount:3,retryDelay:1e3,pollRetryCount:2,loadTimeout:1e4,manifestLoadTimeout:1e4,preloadTime:30,softDecode:!1,bufferBehind:10,maxJumpDistance:3,startTime:0,useLowLatency:!0,targetLatency:10,maxLatency:20,allowedStreamTrackChange:!0,seiInTime:!1,manifestList:[],minSegmentsStartPlay:3,preferMMS:!1,preferMMSStreaming:!1,mseLowLatency:!0,fixerConfig:{forceFixLargeGap:!1,largeGapThreshold:5}},s),{},{media:o})}var Rf=Ye(function s(){De(this,s),G(this,"version",0),G(this,"streams",[]),G(this,"isMaster",!0)}),xu={Audio:"AUDIO",Video:"VIDEO",SubTitle:"SUBTITLE",ClosedCaptions:"CLOSED-CAPTIONS"},wr={CLEAR_KEY:"org.w3.clearkey",FAIRPLAY:["urn:uuid:94ce86fb-07ff-4f43-adb8-93d2fa968ca2","com.apple.streamingkeydelivery"],WIDEVINE:["urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine.alpha","com.widevine"],PLAYREADY:["urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95","com.microsoft.playready"]};function Ru(s){for(var o=[],i=0;i>8*(15-t)&255}}},{key:"isSegmentEncrypted",value:function(){var i=this.method;return i==="AES-128"}},{key:"isValidKeySystem",value:function(){var i=Ru([wr.CLEAR_KEY,wr.FAIRPLAY,wr.WIDEVINE,wr.PLAYREADY]).indexOf(this.keyFormat)>-1;if(!i)return!1;var t=["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)>-1;return!!t}},{key:"isSupported",value:function(){return this.method?this.isSegmentEncrypted()?!0:!!this.isValidKeySystem():!1}}]),s}(),Pf=/^#(EXT[^:]*)(?::(.*))?$/,to=/([^=]+)=(?:"([^"]*)"|([^",]*))(?:,|$)/g,Vf=/^(?:[a-zA-Z0-9+\-.]+:)?\/\//,Df=/^((?:[a-zA-Z0-9+\-.]+:)?\/\/[^/?#]*)?([^?#]*\/)?/;function Yf(s){return s.split(/[\r\n]/).map(function(o){return o.trim()}).filter(Boolean)}function Xu(s){var o=s.match(Pf);if(!(!o||!o[1]))return[o[1].replace("EXT-X-",""),o[2]]}function Kt(s){for(var o={},i=to.exec(s);i;)o[i[1]]=i[2]||i[3],i=to.exec(s);return o}function Ki(s,o){if(!o||!s||Vf.test(s))return s;var i=Df.exec(o);return i?s[0]==="/"?i[1]+s:i[1]+i[2]+s:s}var Nf={audio:[/^mp4a/,/^vorbis$/,/^opus$/,/^flac$/,/^[ae]c-3$/],video:[/^avc/,/^hev/,/^hvc/,/^vp0?[89]/,/^av1$/],text:[/^vtt$/,/^wvtt/,/^stpp/]};function Gn(s,o){var i=Nf[s];if(!(!i||!o||!o.length)){for(var t=0;t=0)&&(s.END_ON_NEXT!=="YES"||!!s.CLASS)&&(!s.CUE||!r.pre&&!r.post||r.pre!==r.post)&&(s.CLASS!=="com.apple.hls.interstitial"||"X-ASSET-URI"in s||"X-ASSET-LIST"in s)}function Hf(s,o){return(s?s.split(/[ ,]+/):[]).reduce(function(i,t){return i[t.toLowerCase()]=!0,i},o)}function Uf(s,o){for(var i=new Rf,t=0,e,r=[],n=[];e=s[t++];){var a=Xu(e);if(a){var u=Qt(a,2),l=u[0],c=u[1];if(l==="VERSION")i.version=parseInt(c);else if(l==="MEDIA"&&c){var d=Kt(c),h=void 0;switch(d.TYPE){case"AUDIO":h=new Xf;break;case"SUBTITLES":h=new Gf;break;default:h=new xs}h.url=Ki(d.URI,o),h.default=d.DEFAULT==="YES",h.autoSelect=d.AUTOSELECT==="YES",h.group=d["GROUP-ID"],h.name=d.NAME,h.lang=d.LANGUAGE,d.CHANNELS&&(h.channels=Number(d.CHANNELS.split("/")[0]),Number.isNaN(h.channels)&&(h.channels=0)),d.TYPE==="AUDIO"&&d.URI&&r.push(h),d.TYPE==="SUBTITLES"&&n.push(h)}else if(l==="STREAM-INF"&&c){var f=new If,m=Kt(c);if(f.bitrate=parseInt(m["AVERAGE-BANDWIDTH"]||m.BANDWIDTH),f.name=m.NAME,f.url=Ki(s[t++],o),m.RESOLUTION){var g=m.RESOLUTION.split("x"),y=Qt(g,2),L=y[0],k=y[1];f.width=parseInt(L),f.height=parseInt(k)}if(m.CODECS){var _=m.CODECS.split(/[ ,]+/).filter(Boolean);f.videoCodec=Gn("video",_),f.audioCodec=Gn("audio",_),f.textCodec=Gn("text",_)}f.audioGroup=m.AUDIO,f.subtitleGroup=m.SUBTITLES,i.streams.push(f)}}}return i.streams.forEach(function(w,Z){w.id=Z}),r.length&&(r.forEach(function(w,Z){w.id=Z}),i.streams.forEach(function(w){w.audioGroup&&(w.audioStreams=r.filter(function(Z){return Z.group===w.audioGroup}))})),n.length&&(n.forEach(function(w,Z){w.id=Z}),i.streams.forEach(function(w){w.subtitleGroup&&(w.subtitleStreams=n.filter(function(Z){return Z.group===w.subtitleGroup}))})),i}function Kf(s,o,i){var t=new Wf;t.url=o;for(var e=new _r(o),r=null,n=null,a=0,u=0,l=0,c=0,d,h=!1,f=0;d=s[c++];){if(d[0]!=="#"){if(t.lowLatency){u++;continue}e.sn=u,e.cc=l,e.url=Ki(d,o),n&&(e.key=n.clone(u)),r&&(e.initSegment=r),t.segments.push(e),e=new _r(o),u++;continue}var m=Xu(d);if(m){var g=Qt(m,2),y=g[0],L=g[1];switch(y){case"VERSION":t.version=parseInt(L);break;case"PLAYLIST-TYPE":t.type=L==null?void 0:L.toUpperCase();break;case"TARGETDURATION":t.targetDuration=parseFloat(L);break;case"PART-INF":{i&&(t.lowLatency=!0);var k=Kt(L);k["PART-TARGET"]&&(t.partTargetDuration=parseFloat(k["PART-TARGET"]))}break;case"SERVER-CONTROL":{var _=Kt(L);t.canBlockReload=_["CAN-BLOCK-RELOAD"]==="YES",t.partHoldBack=parseFloat(_["PART-HOLD-BACK"]||0),t.canSkipUntil=parseFloat(_["CAN-SKIP-UNTIL"]||0),t.canSkipDateRanges=_["CAN-SKIP-DATERANGES"]==="YES"}break;case"ENDLIST":h=!0;break;case"MEDIA-SEQUENCE":u=t.startSN=parseInt(L);break;case"DISCONTINUITY-SEQUENCE":l=t.startCC=parseInt(L);break;case"DISCONTINUITY":l++;break;case"BYTERANGE":e.setByteRange(L,t.segments[t.segments.length-1]);break;case"PART":{if(!t.lowLatency)break;var w=Kt(L);e.duration=parseFloat(w.DURATION),e.independent=w.INDEPENDENT==="YES",e.sn=u,e.cc=l,e.partIndex=f,e.start=a,e.duration=parseFloat(w.DURATION),a+=e.duration,e.url=Ki(w.URI,o),n&&(e.key=n.clone(u)),r&&(e.initSegment=r),t.segments.push(e),e=new _r(o),f++}break;case"PRELOAD-HINT":break;case"PROGRAM-DATE-TIME":e.dataTime=L;break;case"EXTINF":{if(t.lowLatency){f=0;break}var Z=L.split(","),C=Qt(Z,2),R=C[0],E=C[1];e.start=a,e.duration=parseFloat(R),a+=e.duration,e.title=E}break;case"KEY":{var P=Kt(L);if(P.METHOD==="NONE"){n=null;break}if(n=new Mf,n.method=P.METHOD,n.url=/^blob:/.test(P.URI)?P.URI:Ki(P.URI,o),n.keyFormat=P.KEYFORMAT||"identity",n.keyFormatVersions=P.KEYFORMATVERSIONS,!n.isSupported())throw new Error("encrypt ".concat(P.METHOD,"/").concat(P.KEYFORMAT," is not supported"));if(P.IV){var I=P.IV.slice(2);I=(I.length&1?"0":"")+I,n.iv=new Uint8Array(I.length/2);for(var D=0,p=I.length/2;D0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0,e=arguments.length>2?arguments[2]:void 0;if(!i.includes("#EXTM3U"))throw new Error("Invalid m3u8 file");var r=Yf(i);return s.isMediaPlaylist(i)?Kf(r,t,e):Uf(r,t)}},{key:"isMediaPlaylist",value:function(i){return i.includes("#EXTINF:")||i.includes("#EXT-X-TARGETDURATION:")}}]),s}(),Of=function(){function s(o){var i=this;De(this,s),G(this,"_emitOnLoaded",function(u,l){var c=u.response,d=u.options,h=d||{},f=h.firstByteTime,m=h.startTime,g=h.endTime,y=h.contentLength,L=g-m;i.hls.emit(K.SPEED,{time:L,byteLength:y,url:l}),i.hls.emit(K.LOAD_COMPLETE,{url:l,elapsed:L||0}),i.hls.emit(K.TTFB,{url:l,responseUrl:c.url,elapsed:f-m}),i.hls.emit(K.LOAD_RESPONSE_HEADERS,{headers:c.headers,url:l})}),G(this,"_onLoaderRetry",function(u,l){i.hls.emit(he.LOAD_RETRY,{error:we.network(u),retryTime:l})}),this.hls=o,this._timer=null,this._useLowLatency=o.config.useLowLatency;var t=this.hls.config,e=t.retryCount,r=t.retryDelay,n=t.manifestLoadTimeout,a=t.fetchOptions;this._loader=new oi(ge(ge({},a),{},{responseType:"text",retry:e,retryDelay:r,timeout:n,onRetryError:this._onLoaderRetry})),this._audioLoader=new oi(ge(ge({},a),{},{responseType:"text",retry:e,retryDelay:r,timeout:n,onRetryError:this._onLoaderRetry})),this._subtitleLoader=new oi(ge(ge({},a),{},{responseType:"text",retry:e,retryDelay:r,timeout:n,onRetryError:this._onLoaderRetry}))}return Ye(s,[{key:"load",value:function(){var o=me(J().mark(function t(e,r,n){var a,u,l,c,d,h,f,m,g,y,L,k,_,w,Z,C,R,E,P,I;return J().wrap(function(p){for(;;)switch(p.prev=p.next){case 0:return a=[this._loader.load(e)],r&&a.push(this._audioLoader.load(r)),n&&a.push(this._subtitleLoader.load(n)),p.prev=3,p.next=6,Promise.all(a);case 6:if(m=p.sent,g=Qt(m,3),y=g[0],L=g[1],k=g[2],y){p.next=13;break}return p.abrupt("return",[]);case 13:this._emitOnLoaded(y,e),u=y.data,d=y.response.url||e,r?(l=L==null?void 0:L.data,c=k==null?void 0:k.data,h=(L==null||(_=L.response)===null||_===void 0?void 0:_.url)||r,f=(k==null||(w=k.response)===null||w===void 0?void 0:w.url)||n,l&&this._emitOnLoaded(L,r),c&&this._emitOnLoaded(k,n)):(c=L==null?void 0:L.data,f=(L==null||(Z=L.response)===null||Z===void 0?void 0:Z.url)||n,c&&this._emitOnLoaded(L,n)),p.next=22;break;case 19:throw p.prev=19,p.t0=p.catch(3),we.network(p.t0);case 22:if(C=this.hls.config.onPreM3U8Parse,p.prev=23,C&&(u=C(u)||u,l&&(l=C(l,!0)||l),c&&(c=C(c,!0)||c)),R=Cr.parse(u,d,this._useLowLatency),!(((I=R)===null||I===void 0?void 0:I.live)===!1&&R.segments&&!R.segments.length)){p.next=28;break}throw new Error("empty segments list");case 28:l&&(E=Cr.parse(l,h,this._useLowLatency)),c&&(P=Cr.parse(c,f,this._useLowLatency)),p.next=35;break;case 32:throw p.prev=32,p.t1=p.catch(23),new we(B.MANIFEST,B.SUB_TYPES.HLS,p.t1);case 35:return R&&(R.isMaster?this.hls.emit(he.HLS_MANIFEST_LOADED,{playlist:R}):this.hls.emit(he.HLS_LEVEL_LOADED,{playlist:R})),p.abrupt("return",[R,E,P]);case 37:case"end":return p.stop()}},t,this,[[3,19],[23,32]])}));function i(t,e,r){return o.apply(this,arguments)}return i}()},{key:"parseText",value:function(i,t){var e=this.hls.config.onPreM3U8Parse,r;try{var n;if(e&&(i=e(i)||i),r=Cr.parse(i,t,this._useLowLatency),((n=r)===null||n===void 0?void 0:n.live)===!1&&r.segments&&!r.segments.length)throw new Error("empty segments list")}catch(a){throw new we(B.MANIFEST,B.SUB_TYPES.HLS,a)}return r&&(r.isMaster?this.hls.emit(he.HLS_MANIFEST_LOADED,{playlist:r}):this.hls.emit(he.HLS_LEVEL_LOADED,{playlist:r})),[r]}},{key:"poll",value:function(i,t,e,r,n,a){var u=this;clearTimeout(this._timer),a=a||3e3;var l=this.hls.config.pollRetryCount,c=function(){var d=me(J().mark(function h(){var f;return J().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return clearTimeout(u._timer),g.prev=1,g.next=4,u.load(i,t,e);case 4:if(f=g.sent,f[0]){g.next=7;break}return g.abrupt("return");case 7:l=u.hls.config.pollRetryCount,r(f[0],f[1],f[2]),g.next=15;break;case 11:g.prev=11,g.t0=g.catch(1),l--,l<=0&&n(g.t0);case 15:u._timer=setTimeout(c,a);case 16:case"end":return g.stop()}},h,null,[[1,11]])}));return function(){return d.apply(this,arguments)}}();this._timer=setTimeout(c,a)}},{key:"stopPoll",value:function(){return clearTimeout(this._timer),this.cancel()}},{key:"cancel",value:function(){return Promise.all([this._loader.cancel(),this._audioLoader.cancel()])}}]),s}();function Gu(s,o,i){return o>i&&(i=o),Math.min(Math.max(s,o),i)}var In=new $e("playlist"),io=function(){function s(o,i,t){De(this,s),G(this,"live",void 0),G(this,"id",0),G(this,"bitrate",0),G(this,"width",0),G(this,"height",0),G(this,"name",""),G(this,"url",""),G(this,"audioCodec",""),G(this,"videoCodec",""),G(this,"textCodec",""),G(this,"startCC",0),G(this,"endCC",0),G(this,"startSN",0),G(this,"endSN",-1),G(this,"totalDuration",0),G(this,"targetDuration",0),G(this,"partTargetDuration",0),G(this,"canSkipUntil",0),G(this,"canSkipDateRanges",!1),G(this,"skippedSegments",0),G(this,"canBlockReload",!1),G(this,"partHoldBack",0),G(this,"lowLatency",!1),G(this,"endPartIndex",0),G(this,"snDiff",null),G(this,"segments",[]),G(this,"audioStreams",[]),G(this,"subtitleStreams",[]),G(this,"closedCaptions",[]),G(this,"currentAudioStream",null),G(this,"currentSubtitleStream",null),this.update(this._setLLPlaybackPoint(o),i,t)}return Ye(s,[{key:"lastSegment",get:function(){return this.segments.length?this.segments[this.segments.length-1]:null}},{key:"segmentDuration",get:function(){var i;return this.targetDuration||((i=this.segments[0])===null||i===void 0?void 0:i.duration)||0}},{key:"liveEdge",get:function(){return this.endTime},set:function(i){this.endTime=i}},{key:"endTime",get:function(){var i;return((i=this.lastSegment)===null||i===void 0?void 0:i.end)||0},set:function(i){var t=this.lastSegment;t&&(t.duration=i-t.start)}},{key:"currentSubtitleEndSn",get:function(){var i;return((i=this.currentSubtitleStream)===null||i===void 0?void 0:i.endSN)||0}},{key:"clearOldSegment",value:function(i,t){return this.currentAudioStream&&this._clearSegments(i,t),this._clearSegments(i,t)}},{key:"getAudioSegment",value:function(i){if(!(!i||!this.currentAudioStream)){var t=i.sn-this.snDiff;return this.currentAudioStream.segments.find(function(e){return e.sn===t})}}},{key:"update",value:function(i,t){this.url=i.url,Array.isArray(i.segments)?((this.live===null||this.live===void 0)&&(this.live=i.live),this._updateSegments(i,this),this.startCC=i.startCC,this.endCC=i.endCC,this.startSN=i.startSN,this.endSN=i.endSN||-1,this.totalDuration=i.totalDuration,this.targetDuration=i.targetDuration,this.live=i.live,this.lowLatency=i.lowLatency,this.canBlockReload=i.canBlockReload,this.canSkipDateRanges=i.canSkipDateRanges,this.canSkipUntil=i.canSkipUntil,this.partHoldBack=i.partHoldBack,this.partTargetDuration=i.partTargetDuration,this.skippedSegments=i.skippedSegments,this.endPartIndex=i.endPartIndex,t&&this.currentAudioStream&&Array.isArray(t.segments)&&(this._updateSegments(t,this.currentAudioStream),(this.snDiff===null||this.snDiff===void 0)&&i.segments.length&&t.segments.length&&(this.snDiff=i.segments[0].sn-t.segments[0].sn))):(this.id=i.id,this.bitrate=i.bitrate,this.width=i.width,this.height=i.height,this.name=i.name,this.audioCodec=i.audioCodec,this.videoCodec=i.videoCodec,this.textCodec=i.textCodec,this.audioStreams=i.audioStreams,this.subtitleStreams=i.subtitleStreams,!this.currentAudioStream&&this.audioStreams.length&&(this.currentAudioStream=this.audioStreams.find(function(e){return e.default})||this.audioStreams[0]),!this.currentSubtitleStream&&this.subtitleStreams.length&&(this.currentSubtitleStream=this.subtitleStreams.find(function(e){return e.default})||this.subtitleStreams[0]))}},{key:"updateSubtitle",value:function(i){var t=this;if(i&&this.currentSubtitleStream&&Array.isArray(i.segments)){var e=this._updateSegments(i,this.currentSubtitleStream),r=this.currentSubtitleStream.segments;if(r.length>100&&(this.currentSubtitleStream.segments=r.slice(100)),!!e)return e.map(function(n){return{sn:n.sn,url:n.url,duration:n.duration,start:n.start,end:n.end,lang:t.currentSubtitleStream.lang}})}}},{key:"switchSubtitle",value:function(i){var t=this.subtitleStreams.find(function(r){return r.lang===i}),e=this.currentSubtitleStream;t&&(this.currentSubtitleStream=t,e.segments=[])}},{key:"_setLLPlaybackPoint",value:function(i){if(!i.lowLatency||!i.segments.length)return i;for(var t=i.totalDuration-i.partHoldBack,e=i.segments,r=0,n=0,a=e.length;n=i){e=n;break}return e>t&&(e=t),e&&(this.segments=this.segments.slice(e),this.currentAudioStream&&(this.currentAudioStream.segments=this.currentAudioStream.segments.slice(e))),t-e}},{key:"_updateSegments",value:function(i,t){var e=t.segments;if(this.live){var r,n=i.lowLatency,a=e[e.length-1],u=(r=a==null?void 0:a.sn)!==null&&r!==void 0?r:-1,l=(a==null?void 0:a.partIndex)||0,c=u endSN:").concat(i.endSN,", partIndex:").concat(i.endPartIndex));var d=i.segments.findIndex(function(y){return y.sn===u&&y.partIndex===l}),h=d<0?i.segments:i.segments.slice(d+1);if(e.length&&h.length){var f=a.end,m=f;h.forEach(function(y){y.start=f,f=y.end}),In.log("liveEdge: ".concat(m," -> ").concat(f));var g=(a==null?void 0:a.cc)||-1;g>h[0].cc&&h.forEach(function(y){return y.cc+=g})}return t.endSN=i.endSN,t.segments=e.concat(h),h}}else t.segments=i.segments}}]),s}(),Af=function(){function s(o){De(this,s),G(this,"streams",[]),G(this,"currentStream",null),G(this,"dvrWindow",0),G(this,"_segmentPointer",-1),this.hls=o}return Ye(s,[{key:"lowLatency",get:function(){var i;return(i=this.currentStream)===null||i===void 0?void 0:i.lowLatency}},{key:"lastSegment",get:function(){var i;return(i=this.currentStream)===null||i===void 0?void 0:i.lastSegment}},{key:"currentSegment",get:function(){var i;return(i=this.currentSegments)===null||i===void 0?void 0:i[this._segmentPointer]}},{key:"nextSegment",get:function(){var i;return(i=this.currentSegments)===null||i===void 0?void 0:i[this._segmentPointer+1]}},{key:"currentSegments",get:function(){var i;return(i=this.currentStream)===null||i===void 0?void 0:i.segments}},{key:"currentSubtitleEndSn",get:function(){var i;return(i=this.currentStream)===null||i===void 0?void 0:i.currentSubtitleEndSn}},{key:"liveEdge",get:function(){var i;return(i=this.currentStream)===null||i===void 0?void 0:i.liveEdge},set:function(i){this.currentStream&&(this.currentStream.liveEdge=i)}},{key:"totalDuration",get:function(){var i;return((i=this.currentStream)===null||i===void 0?void 0:i.totalDuration)||0}},{key:"seekRange",get:function(){var i=this.currentSegments;if(!(!i||!i.length))return[i[0].start,i[i.length-1].end]}},{key:"nbSegments",get:function(){var i;return((i=this.currentSegments)===null||i===void 0?void 0:i.length)||0}},{key:"isEmpty",get:function(){var i;return!((i=this.currentSegments)!==null&&i!==void 0&&i.length)}},{key:"isLive",get:function(){var i;return(i=this.currentStream)===null||i===void 0?void 0:i.live}},{key:"hadSegmentLoaded",get:function(){return this._segmentPointer!==-1}},{key:"hasSubtitle",get:function(){var i;return!!((i=this.currentStream)!==null&&i!==void 0&&i.currentSubtitleStream)}},{key:"getAudioSegment",value:function(i){var t;return(t=this.currentStream)===null||t===void 0?void 0:t.getAudioSegment(i)}},{key:"moveSegmentPointer",value:function(i){var t;i==null&&(i=this._segmentPointer+1),this._segmentPointer=Gu(i,-1,(t=this.currentSegments)===null||t===void 0?void 0:t.length)}},{key:"reset",value:function(){this.streams=[],this.currentStream=null,this.dvrWindow=0,this._segmentPointer=-1}},{key:"getSegmentByIndex",value:function(i){var t;return(t=this.currentSegments)===null||t===void 0?void 0:t[i]}},{key:"setNextSegmentByIndex",value:function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;this._segmentPointer=i-1}},{key:"setNextSegmentBySN",value:function(){var i,t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=(i=this.currentSegments)===null||i===void 0?void 0:i.findIndex(function(r){return r.sn===t});return e!==-1&&this.setNextSegmentByIndex(e+1),e}},{key:"findSegmentIndexByTime",value:function(i){var t=this.currentSegments;if(t){for(var e=0,r=t.length,n;e=n.start&&i=i});r.forEach(function(n){n.start=t,t=n.end})}},{key:"switchSubtitle",value:function(i){var t;(t=this.currentStream)===null||t===void 0||t.switchSubtitle(i)}},{key:"clearOldSegment",value:function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:50,t=this.currentStream;if(!(!this.dvrWindow||!t)){var e=t.endTime-this.dvrWindow;if(!(e<=0)){var r=t.segments;r.length<=i||(this._segmentPointer=t.clearOldSegment(e,this._segmentPointer))}}}},{key:"checkSegmentTrackChange",value:function(i,t){var e=this.findSegmentIndexByTime(i),r=this.getSegmentByIndex(e);if(r&&!(!r.hasAudio&&!r.hasVideo)){if(t!==2&&r.hasAudio&&r.hasVideo)return r;if(!(r.end-i>.3)){var n=this.getSegmentByIndex(e+1);if(n&&!(!n.hasAudio&&!n.hasVideo)&&(n.hasAudio!==r.hasAudio||n.hasVideo!==r.hasVideo))return n}}}},{key:"feedbackLiveEdge",value:function(i,t){var e,r=this.currentSegments;if(r){var n=((e=this.lastSegment)===null||e===void 0?void 0:e.sn)===i.sn;if(n){this.liveEdge=t;return}this.updateSegmentsRanges(i.sn+1,t)}}}]),s}(),zf=function(){function s(o){var i=this;De(this,s),G(this,"error",null),G(this,"_emitOnLoaded",function(u,l){var c=u.data,d=u.response,h=u.options,f=h||{},m=f.firstByteTime,g=f.startTime,y=f.endTime,L=f.contentLength,k=y-g;i._bandwidthService.addRecord(L||c.byteLength,k),i.hls.emit(K.SPEED,{time:k,byteLength:L,url:l}),i.hls.emit(K.LOAD_COMPLETE,{url:l,elapsed:k||0}),i.hls.emit(K.TTFB,{url:l,responseUrl:d.url,elapsed:m-g}),i.hls.emit(K.LOAD_RESPONSE_HEADERS,{headers:d.headers,url:l})}),G(this,"_onLoaderRetry",function(u,l){i.hls.emit(K.LOAD_RETRY,{error:we.network(u),retryTime:l})}),this.hls=o,this._bandwidthService=new vu,this._mapCache={},this._keyCache={};var t=this.hls.config,e=t.retryCount,r=t.retryDelay,n=t.loadTimeout,a=t.fetchOptions;this._segmentLoader=new oi(ge(ge({},a),{},{responseType:"arraybuffer",retry:e,retryDelay:r,timeout:n,onRetryError:this._onLoaderRetry})),this._audioSegmentLoader=new oi(ge(ge({},a),{},{responseType:"arraybuffer",retry:e,retryDelay:r,timeout:n,onRetryError:this._onLoaderRetry})),this._keyLoader=new oi(ge(ge({},a),{},{responseType:"arraybuffer",retry:e,retryDelay:r,timeout:n,onRetryError:this._onLoaderRetry}))}return Ye(s,[{key:"speedInfo",value:function(){return{speed:this._bandwidthService.getLatestSpeed(),avgSpeed:this._bandwidthService.getAvgSpeed()}}},{key:"load",value:function(i,t,e){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:e,n=[];return i&&(n[0]=this.loadVideoSegment(i,e)),t&&(n[1]=this.loadAudioSegment(t,r)),Promise.all(n)}},{key:"loadVideoSegment",value:function(i,t){return this._loadSegment(this._segmentLoader,i,t)}},{key:"loadAudioSegment",value:function(i,t){return this._loadSegment(this._audioSegmentLoader,i,t)}},{key:"_loadSegment",value:function(){var o=me(J().mark(function t(e,r,n){var a=this,u,l,c,d,h,f,m,g,y,L,k,_,w,Z,C;return J().wrap(function(E){for(;;)switch(E.prev=E.next){case 0:return m=[],this.hls.emit(K.LOAD_START,{url:r.url}),m[0]=e.load(r.url),n&&r.initSegment&&(y=r.initSegment.url,l=this._mapCache[y],l||(this.hls.emit(K.LOAD_START,{url:y}),m[1]=e.load(y).then(function(P){if(P){var I=Object.keys(a._mapCache);I>30&&(a._mapCache={}),l=a._mapCache[y]=P.data,a._emitOnLoaded(P,y)}})),L=(g=r.initSegment.key)===null||g===void 0?void 0:g.url,L&&(f=r.initSegment.key.iv,h=this._keyCache[L],h||(this.hls.emit(K.LOAD_START,{url:L}),m[2]=this._keyLoader.load(L).then(function(P){P&&(h=a._keyCache[L]=P.data,a._emitOnLoaded(P,L))})))),k=(u=r.key)===null||u===void 0?void 0:u.url,k&&r.key.isSegmentEncrypted()&&(d=r.key.iv,c=this._keyCache[k],c||(this.hls.emit(K.LOAD_START,{url:k}),m[3]=this._keyLoader.load(k).then(function(P){P&&(c=a._keyCache[k]=P.data,a._emitOnLoaded(P,k))}))),E.next=8,Promise.all(m);case 8:if(_=E.sent,w=Qt(_,1),Z=w[0],Z){E.next=13;break}return E.abrupt("return");case 13:return C=Z.data,this._emitOnLoaded(Z,r.url),E.abrupt("return",{data:C,map:l,key:c,mapKey:h,keyIv:d,mapKeyIv:f});case 16:case"end":return E.stop()}},t,this)}));function i(t,e,r){return o.apply(this,arguments)}return i}()},{key:"reset",value:function(){this.error=null,this._mapCache={},this._keyCache={},this._bandwidthService.reset()}},{key:"cancel",value:function(){var o=me(J().mark(function t(){return J().wrap(function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,Promise.all([this._keyLoader.cancel(),this._segmentLoader.cancel(),this._audioSegmentLoader.cancel()]);case 2:case"end":return r.stop()}},t,this)}));function i(){return o.apply(this,arguments)}return i}()}]),s}(),Je=new $e("hls"),zi=function(s){tn(i,s);var o=rn(i);function i(t){var e;return De(this,i),e=o.call(this),G(ue(e),"version",i.version),G(ue(e),"media",null),G(ue(e),"config",null),G(ue(e),"_manifestLoader",null),G(ue(e),"_segmentLoader",null),G(ue(e),"_playlist",null),G(ue(e),"_bufferService",null),G(ue(e),"_gapService",null),G(ue(e),"_seiService",null),G(ue(e),"_stats",null),G(ue(e),"_prevSegSn",null),G(ue(e),"_prevSegCc",null),G(ue(e),"_tickTimer",null),G(ue(e),"_tickInterval",500),G(ue(e),"_segmentProcessing",!1),G(ue(e),"_reloadOnPlay",!1),G(ue(e),"_switchUrlOpts",null),G(ue(e),"_isProcessQuotaExceeded",!1),G(ue(e),"_loadSegment",me(J().mark(function r(){var n,a,u,l,c,d,h,f,m;return J().wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!(e._segmentProcessing||!e.media)){y.next=2;break}return y.abrupt("return");case 2:if(n=e._playlist,a=n.nextSegment,u=n.lastSegment,l=ue(e),c=l.config,d=.016,h=Math.min(Math.max((u==null?void 0:u.duration)-d/2||0,d),.1),a){y.next=8;break}return y.abrupt("return");case 8:if(e.isLive){y.next=18;break}if(f=e.bufferInfo(),e.media.paused&&!e.media.currentTime&&(f=e.bufferInfo(f.nextStart||.5)),m=Math.abs(f.end-e.media.duration)=c.preloadTime||m)){y.next=15;break}return e._tryEos(),y.abrupt("return");case 15:if(!(c.preferMMSStreaming&&!e._bufferService.msStreaming)){y.next=17;break}return y.abrupt("return");case 17:!e._urlSwitching&&e._prevSegSn!==a.sn-1&&f.end&&Math.abs(a.start-f.end)>1&&e._playlist.setNextSegmentByIndex(e._playlist.findSegmentIndexByTime(f.end+.1));case 18:return y.abrupt("return",e._loadSegmentDirect());case 19:case"end":return y.stop()}},r)}))),G(ue(e),"_onLoadeddata",function(){e.isLive&&!e.config.mseLowLatency&&e.media.duration!==1/0&&e._bufferService.updateDuration(1/0).catch(function(r){})}),G(ue(e),"_onPlay",me(J().mark(function r(){return J().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(e.media.seeking&&e.media.currentTime===0)){a.next=3;break}return Je.debug("replay currentTime 0, return"),a.abrupt("return");case 3:if(clearTimeout(e._disconnectTimer),!e._reloadOnPlay){a.next=9;break}e._reloadOnPlay=!1,e.replay(!0),a.next=12;break;case 9:return a.next=11,e._loadSegment();case 11:e._startTick();case 12:case"end":return a.stop()}},r)}))),G(ue(e),"_onPause",function(){if(e.isLive){if(!e._reloadOnPlay){var r=e.config.disconnectTime;if(r==null&&(r=e._playlist.dvrWindow),!Number.isFinite(r))return;clearTimeout(e._disconnectTimer),e._disconnectTimer=setTimeout(function(){e._reloadOnPlay=!0,e._clear()},r||0)}}else e._stopTick()}),G(ue(e),"_onSeeking",me(J().mark(function r(){var n,a,u,l,c,d,h;return J().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:if(e.media){m.next=2;break}return m.abrupt("return");case 2:if(e._onCheckQuotaExceeded(),n=e.media.currentTime,a=e._playlist.seekRange,!a){m.next=10;break}if(u=Gu(n,a[0],e.isLive?a[1]:e.media.duration),!(u>=0&&Math.abs(n-u)>=.1)){m.next=10;break}return e.media.currentTime=u,m.abrupt("return");case 10:if(l=e._playlist.currentSegment,c=Xe.info(Xe.get(e.media),n,.1),!l){m.next=17;break}if(!(c.end&&Math.abs(c.end-l.end)<.2)){m.next=15;break}return m.abrupt("return");case 15:if(!(e.isLive&&c.end)){m.next=17;break}return m.abrupt("return");case 17:if(d=e._playlist.findSegmentIndexByTime(n),h=e._playlist.getSegmentByIndex(d),!(d==null||!h||e._segmentProcessing&&h===e._playlist.nextSegment)){m.next=21;break}return m.abrupt("return");case 21:return Je.debug("seek to",n,h),e._playlist.setNextSegmentByIndex(d),e._stopTick(),m.next=26,e._segmentLoader.cancel();case 26:if(e._segmentProcessing=!1,!(!c.end||e.isLive)){m.next=30;break}return m.next=30,e._loadSegmentDirect(!0);case 30:e._startTick();case 31:case"end":return m.stop()}},r)}))),G(ue(e),"_onTimeupdate",function(){if(e.media){var r=e.config;if(r.isLive&&r.maxLatency&&r.targetLatency&&e.media){var n=e._playlist.liveEdge;if(!n)return;var a=n-e.media.currentTime;a>=r.maxLatency&&(Je.debug("latency jump, currentTime:".concat(e.media.currentTime,", liveEdge:").concat(n,", latency=").concat(a)),e.media.currentTime=n-r.targetLatency)}if(r.seiInTime){var u;(u=e._seiService)===null||u===void 0||u.throw(e.media.currentTime)}e.config.allowedStreamTrackChange&&!e.config.softDecode&&e._checkStreamTrackChange(e.media.currentTime)}}),G(ue(e),"_tick",function(){if(e.media){e._startTick();var r=e.media,n=Xe.get(r),a=e._segmentLoader.error;if(e._onCheckQuotaExceeded(),e._isProcessQuotaExceeded&&(e._bufferService.isFull()||(e._isProcessQuotaExceeded=!1,e._segmentProcessing=!1)),a){var u=.5;(!r.readyState||e.bufferInfo(u).remaining<1)&&(a.fatal=!0,e._emitError(we.network(a)));return}Xe.end(n)>=.1&&r.readyState&&(hu(r)?(e._loadSegment(),e._gapService&&e._gapService.do(r,e.config.maxJumpDistance,e.isLive)):r.readyState<2&&e._gapService&&e._gapService.do(r,e.config.maxJumpDistance,r.currentTime?e.isLive:!0)),e.isLive||e._tryEos()}}),e.config=t=xf(t),e.media=e.config.media,e._manifestLoader=new Of(ue(e)),e._segmentLoader=new zf(ue(e)),e._playlist=new Af(ue(e)),e._bufferService=new Ef(ue(e)),t.seiInTime&&(e._seiService=new pu(ue(e))),t.softDecode||(e._gapService=new mu),e._stats=new gu(ue(e),9e4),e.media.addEventListener("loadeddata",e._onLoadeddata),e.media.addEventListener("play",e._onPlay),e.media.addEventListener("pause",e._onPause),e.media.addEventListener("seeking",e._onSeeking),e.media.addEventListener("timeupdate",e._onTimeupdate),e}return Ye(i,[{key:"isLive",get:function(){return this._playlist.isLive}},{key:"streams",get:function(){return this._playlist.streams}},{key:"currentStream",get:function(){return this._playlist.currentStream}},{key:"hasSubtitle",get:function(){return this._playlist.hasSubtitle}},{key:"totalDuration",get:function(){return this._playlist.totalDuration}},{key:"baseDts",get:function(){var e;return(e=this._bufferService)===null||e===void 0?void 0:e.baseDts}},{key:"abrSwitchPoint",get:function(){var e=this._urlSwitching?this._playlist.currentSegment:this._playlist.nextSegment;return e?e.start+e.duration/2:null}},{key:"speedInfo",value:function(){return this._segmentLoader.speedInfo()}},{key:"bufferInfo",value:function(){var e,r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:.1;return Xe.info(Xe.get(this.media),(e=this.media)===null||e===void 0?void 0:e.currentTime,r)}},{key:"getStats",value:function(){return this._stats.getStats()}},{key:"playbackQuality",value:function(){return fu(this.media)}},{key:"load",value:function(){var t=me(J().mark(function r(){var n,a,u,l=arguments;return J().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return n=l.length>0&&l[0]!==void 0?l[0]:"",a=l.length>1&&l[1]!==void 0?l[1]:{},u=typeof a=="boolean"?a:!!(a!=null&&a.reuseMse),lr(a)==="object"&&a!==null&&a!==void 0&&a.clearSwitchStatus&&(this._urlSwitching=!1,this._switchUrlOpts=null,this.config.startTime=void 0),n&&(this.config.url=n),n=this.config.url,d.next=8,this._reset(u);case 8:return d.next=10,this._loadData(n);case 10:this._startTick();case 11:case"end":return d.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()},{key:"_loadData",value:function(){var t=me(J().mark(function r(n){var a,u,l,c,d,h,f,m,g,y,L,k,_;return J().wrap(function(Z){for(;;)switch(Z.prev=Z.next){case 0:try{n&&(n=n.trim())}catch{}if(n){Z.next=3;break}throw this._emitError(new we(B.OTHER,B.SUB_TYPES.OPTION,null,null,"m3u8 url is missing"));case 3:return Z.next=5,this._loadM3U8(n);case 5:if(a=Z.sent,u=this._playlist.currentStream,!this._urlSwitching){Z.next=23;break}if(!this.isLive){Z.next=14;break}l=this._playlist.setNextSegmentBySN(this._prevSegSn),Je.log("segment nb=".concat(this._prevSegSn," index of ").concat(l," in the new playlist")),l===-1&&(this._prevSegCc=null,this._prevSegSn=null),Z.next=23;break;case 14:if(u.bitrate===0&&(c=this._switchUrlOpts)!==null&&c!==void 0&&c.bitrate&&(u.bitrate=(f=this._switchUrlOpts)===null||f===void 0?void 0:f.bitrate),m=typeof((d=this._switchUrlOpts)===null||d===void 0?void 0:d.startTime)=="number"?(h=this._switchUrlOpts)===null||h===void 0?void 0:h.startTime:this._getSeamlessSwitchPoint(),this.config.startTime=m,g=this._playlist.findSegmentIndexByTime(m),y=this._playlist.getSegmentByIndex(g+1),!y){Z.next=23;break}return L=y.start,Z.next=23,this._bufferService.removeBuffer(L);case 23:if(a){Z.next=25;break}return Z.abrupt("return");case 25:if(!this.isLive){Z.next=36;break}if(this._bufferService.setLiveSeekableRange(0,4294967295),Je.log("totalDuration first time got:",this._playlist.totalDuration),Je.log("nb segments got:",this._playlist.nbSegments),this.config.targetLatency1&&m[1]!==void 0?m[1]:{},u={seamless:!1,startTime:0,bitrate:0},y.t0=lr(a),y.next=y.t0==="number"?5:y.t0==="boolean"?7:y.t0==="object"?9:11;break;case 5:return a={startTime:a},y.abrupt("break",12);case 7:return a={seamless:a},y.abrupt("break",12);case 9:for(l in a)(a[l]===void 0||a[l]===null)&&delete a[l];return y.abrupt("break",12);case 11:throw"unsupported switchURL args: ".concat(a);case 12:if(a=Object.assign({},u,a),c=a,d=c.seamless,h=c.startTime,this.config.url=n,this.config.startTime=h,this._switchUrlOpts=a,d){y.next=38;break}if(y.prev=18,!this.config.softDecode){y.next=23;break}y.t1=this.load(n),y.next=26;break;case 23:return y.next=25,this.load(n);case 25:y.t1=y.sent;case 26:f=y.t1,y.next=33;break;case 29:throw y.prev=29,y.t2=y.catch(18),this.emit(he.SWITCH_URL_FAILED,y.t2),y.t2;case 33:return this._reloadOnPlay=!1,f&&this.emit(he.SWITCH_URL_SUCCESS,{url:n}),y.abrupt("return",this.media.play(!0));case 38:return this._urlSwitching=!0,this.isLive||(this._prevSegSn=null,this._prevSegCc=null),this._playlist.reset(),this._bufferService.seamlessSwitch(),y.next=44,this._clear();case 44:return y.next=46,this._loadData(n);case 46:this._startTick();case 47:this._switchUrlOpts=null;case 48:case"end":return y.stop()}},r,this,[[18,29]])}));function e(r){return t.apply(this,arguments)}return e}()},{key:"switchStream",value:function(){var t=me(J().mark(function r(n){var a,u,l,c,d,h=arguments;return J().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:if(a=h.length>1&&h[1]!==void 0?h[1]:!0,u=this.currentStream,l=this.streams,!(!u||u.id===n||!l||l.length<2)){m.next=5;break}return m.abrupt("return");case 5:if(c=l.find(function(g){return g.id===n}),c){m.next=8;break}return m.abrupt("return");case 8:return m.prev=8,m.next=11,this._clear();case 11:if(!a){m.next=14;break}return m.next=14,this._bufferService.clearAllBuffer();case 14:m.next=19;break;case 16:throw m.prev=16,m.t0=m.catch(8),this._emitError(we.create(m.t0));case 19:if(u.currentAudioStream&&c.audioStreams.length>2&&(d=u.currentAudioStream.id,c.currentAudioStream=c.audioStreams.find(function(g){return g.id===d})||c.currentAudioStream),this._playlist.currentStream=c,m.prev=21,!(this.isLive||!c.segments.length)){m.next=25;break}return m.next=25,this._refreshM3U8();case 25:return this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(this.media.currentTime)||0),this._prevSegCc=null,m.next=29,this._loadSegmentDirect();case 29:m.next=35;break;case 31:throw m.prev=31,m.t1=m.catch(21),this._playlist.currentStream=u,m.t1;case 35:return this._startTick(),m.abrupt("return",c);case 37:case"end":return m.stop()}},r,this,[[8,16],[21,31]])}));function e(r){return t.apply(this,arguments)}return e}()},{key:"switchAudioStream",value:function(){var t=me(J().mark(function r(n){var a,u,l,c,d=arguments;return J().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(a=d.length>1&&d[1]!==void 0?d[1]:!0,u=this.currentStream,u){f.next=4;break}return f.abrupt("return");case 4:if(l=u.currentAudioStream,!(!l||l.id===n||u.audioStreams.length<2)){f.next=7;break}return f.abrupt("return");case 7:if(c=u.audioStreams.find(function(m){return m.id===n}),c){f.next=10;break}return f.abrupt("return");case 10:return f.prev=10,f.next=13,this._clear();case 13:if(!a){f.next=16;break}return f.next=16,this._bufferService.clearAllBuffer();case 16:f.next=21;break;case 18:throw f.prev=18,f.t0=f.catch(10),this._emitError(we.create(f.t0));case 21:if(u.currentAudioStream=c,f.prev=22,!(this.isLive||!c.segments.length)){f.next=26;break}return f.next=26,this._refreshM3U8();case 26:return this._playlist.setNextSegmentByIndex(this._playlist.findSegmentIndexByTime(this.media.currentTime)||0),this._prevSegCc=null,f.next=30,this._loadSegmentDirect();case 30:f.next=36;break;case 32:throw f.prev=32,f.t1=f.catch(22),u.currentAudioStream=l,f.t1;case 36:return this._startTick(),f.abrupt("return",c);case 38:case"end":return f.stop()}},r,this,[[10,18],[22,32]])}));function e(r){return t.apply(this,arguments)}return e}()},{key:"switchSubtitleStream",value:function(){var t=me(J().mark(function r(n){return J().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this._playlist.switchSubtitle(n),u.next=3,this._manifestLoader.stopPoll();case 3:return u.next=5,this._refreshM3U8();case 5:case"end":return u.stop()}},r,this)}));function e(r){return t.apply(this,arguments)}return e}()},{key:"detachMedia",value:function(){var t=me(J().mark(function r(){return J().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!this._bufferService){a.next=3;break}return a.next=3,this._bufferService.detachMedia();case 3:case"end":return a.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()},{key:"destroy",value:function(){var t=me(J().mark(function r(){var n;return J().wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.media){u.next=2;break}return u.abrupt("return");case 2:return this.removeAllListeners(),this._playlist.reset(),this._segmentLoader.reset(),(n=this._seiService)===null||n===void 0||n.reset(),this.media.removeEventListener("loadeddata",this._onLoadeddata),this.media.removeEventListener("play",this._onPlay),this.media.removeEventListener("pause",this._onPause),this.media.removeEventListener("seeking",this._onSeeking),this.media.removeEventListener("timeupdate",this._onTimeupdate),u.next=13,Promise.all([this._clear(),this._bufferService.destroy()]);case 13:this.media=null;case 14:case"end":return u.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()},{key:"_loadM3U8",value:function(){var t=me(J().mark(function r(n){var a,u,l,c,d,h,f;return J().wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(g.prev=0,c=(u=this.config.manifestList)===null||u===void 0||(l=u.filter(function(y){return y.url===n})[0])===null||l===void 0?void 0:l.manifest,!c){g.next=6;break}g.t0=this._manifestLoader.parseText(c,n),g.next=9;break;case 6:return g.next=8,this._manifestLoader.load(n);case 8:g.t0=g.sent;case 9:d=g.t0,h=Qt(d,1),a=h[0],g.next=17;break;case 14:throw g.prev=14,g.t1=g.catch(0),this._emitError(we.create(g.t1));case 17:if(a){g.next=19;break}return g.abrupt("return");case 19:if(this._playlist.upsertPlaylist(a),!a.isMaster){g.next=24;break}return(f=this._playlist.currentStream.subtitleStreams)!==null&&f!==void 0&&f.length&&this.emit(he.SUBTITLE_PLAYLIST,{list:this._playlist.currentStream.subtitleStreams}),g.next=24,this._refreshM3U8();case 24:return this.emit(he.STREAM_PARSED),g.abrupt("return",a);case 26:case"end":return g.stop()}},r,this,[[0,14]])}));function e(r){return t.apply(this,arguments)}return e}()},{key:"_refreshM3U8",value:function(){var e,r,n=this,a=this._playlist.currentStream;if(!a||!a.url)throw this._emitError(we.create(null,null,new Error("m3u8 url is not defined")));var u=a.url,l=(e=a.currentAudioStream)===null||e===void 0?void 0:e.url,c=(r=a.currentSubtitleStream)===null||r===void 0?void 0:r.url;return this._manifestLoader.load(u,l,c).then(function(d){var h=Qt(d,3),f=h[0],m=h[1],g=h[2];f&&(n._playlist.upsertPlaylist(f,m,g),n.isLive&&n._pollM3U8(u,l,c))}).catch(function(d){throw n._emitError(we.create(d))})}},{key:"_pollM3U8",value:function(e,r,n){var a=this,u=this._playlist.isEmpty,l;if(this._playlist.lowLatency)l=(this._playlist.currentStream.partTargetDuration||0)*1e3;else{var c;l=(((c=this._playlist.lastSegment)===null||c===void 0?void 0:c.duration)||0)*1e3}this._manifestLoader.poll(e,r,n,function(d,h,f){a._playlist.upsertPlaylist(d,h,f),a._playlist.clearOldSegment();var m=d&&u&&!a._playlist.isEmpty;(m||!a._playlist.hadSegmentLoaded&&a._playlist.nbSegments>=a.config.minSegmentsStartPlay)&&a._loadSegment(),u&&(u=a._playlist.isEmpty)},function(d){a._emitError(we.create(d))},l)}},{key:"_loadSegmentDirect",value:function(){var t=me(J().mark(function r(n){var a,u,l,c,d,h;return J().wrap(function(m){for(;;)switch(m.prev=m.next){case 0:if(a=this._playlist.nextSegment,a){m.next=3;break}return m.abrupt("return");case 3:return u=!1,l=null,m.prev=5,this._segmentProcessing=!0,Je.log("load segment, sn:".concat(a.sn,", [").concat(a.start,", ").concat(a.end,"], partIndex:").concat(a.partIndex)),m.next=10,this._reqAndBufferSegment(a,this._playlist.getAudioSegment(a));case 10:u=m.sent,m.next=16;break;case 13:m.prev=13,m.t0=m.catch(5),l=m.t0;case 16:return m.prev=16,this._segmentProcessing=!1,m.finish(16);case 19:if(!l){m.next=26;break}if(!this._bufferService.isFull()){m.next=25;break}return Je.log("load segment, sn:".concat(a.sn,", partIndex:").concat(a.partIndex)),this._segmentProcessing=!0,this._isProcessQuotaExceeded=!0,m.abrupt("return",!1);case 25:return m.abrupt("return",this._emitError(we.create(l)));case 26:return u&&(d=this.bufferInfo().end,this.isLive&&!this.media.seeking&&d&&Math.abs(a.end-d)>1&&(Je.warn("segment: ".concat(a.sn," expected end=").concat(a.end,", real end=").concat(d)),this._playlist.feedbackLiveEdge(a,d)),h=((c=this._playlist.currentStream)===null||c===void 0?void 0:c.url)===a.parentUrl,this._urlSwitching&&!h&&(Je.warn("pre playlist segment appended!"),this._bufferService.seamlessSwitch()),this.isLive&&this._urlSwitching&&h&&(this._urlSwitching=!1,this.emit(he.SWITCH_URL_SUCCESS,{url:this.config.url})),this._playlist.moveSegmentPointer(),a.isLast?this._end():n||this._loadSegment()),m.abrupt("return",u);case 28:case"end":return m.stop()}},r,this,[[5,13,16,19]])}));function e(r){return t.apply(this,arguments)}return e}()},{key:"_reqAndBufferSegment",value:function(){var t=me(J().mark(function r(n,a){var u,l,c,d,h,f,m,g,y,L,k;return J().wrap(function(w){for(;;)switch(w.prev=w.next){case 0:return l=n?n.cc:a.cc,c=this._prevSegCc!==l,d=[],w.prev=3,w.next=6,this._segmentLoader.load(n,a,c);case 6:d=w.sent,w.next=14;break;case 9:throw w.prev=9,w.t0=w.catch(3),w.t0.fatal=!1,this._segmentLoader.error=w.t0,w.t0;case 14:if(d[0]){w.next=16;break}return w.abrupt("return");case 16:return w.next=18,(u=this._bufferService).decryptBuffer.apply(u,yf(d));case 18:if(h=w.sent,h){w.next=21;break}return w.abrupt("return");case 21:return f=n?n.sn:a.sn,m=n?n.start:a.start,g=this._playlist.currentStream,this._bufferService.createSource(h[0],h[1],g==null?void 0:g.videoCodec,g==null?void 0:g.audioCodec),y=Date.now(),L=this._prevSegSn===f-1,this.isLive&&this._urlSwitching&&(k=this.bufferInfo().end,this._playlist.updateSegmentsRanges(f,k),Je.warn("update the new playlist liveEdge, segment id=".concat(f,", buffer start=").concat(k,", liveEdge=").concat(this._playlist.liveEdge)),m=k),w.next=30,this._bufferService.appendBuffer(n,a,h[0],h[1],c,L,m);case 30:return this.emit(he.APPEND_COST,{elapsed:Date.now()-y,url:n.url}),w.next=33,this._bufferService.evictBuffer(this.config.bufferBehind);case 33:return this._prevSegCc=l,this._prevSegSn=f,w.abrupt("return",!0);case 36:case"end":return w.stop()}},r,this,[[3,9]])}));function e(r,n){return t.apply(this,arguments)}return e}()},{key:"_onCheckQuotaExceeded",value:function(){var t=me(J().mark(function r(){var n,a,u,l,c,d;return J().wrap(function(f){for(;;)switch(f.prev=f.next){case 0:n=this.media.currentTime,a=this.media.buffered,u=!1,l=0;case 4:if(!(l=n&&n0)){f.next=17;break}return f.next=17,this._bufferService.removeBuffer(0,d-c);case 17:case"end":return f.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()},{key:"_checkStreamTrackChange",value:function(e){var r=this._playlist.checkSegmentTrackChange(e,this._bufferService.nbSb);r&&this.switchURL(this.config.url,r.start+.2)}},{key:"_clear",value:function(){var t=me(J().mark(function r(){return J().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return clearTimeout(this._disconnectTimer),this._stopTick(),a.next=4,Promise.all([this._segmentLoader.cancel(),this._manifestLoader.stopPoll()]);case 4:this._segmentProcessing=!1;case 5:case"end":return a.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()},{key:"_reset",value:function(){var t=me(J().mark(function r(){var n,a,u=arguments;return J().wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return a=u.length>0&&u[0]!==void 0?u[0]:!1,this._reloadOnPlay=!1,this._prevSegSn=null,this._prevSegCc=null,this._switchUrlOpts=null,this._playlist.reset(),this._segmentLoader.reset(),(n=this._seiService)===null||n===void 0||n.reset(),this._stats.reset(),c.next=11,this._clear();case 11:return c.abrupt("return",this._bufferService.reset(a));case 12:case"end":return c.stop()}},r,this)}));function e(){return t.apply(this,arguments)}return e}()},{key:"_end",value:function(){this._clear(),this._bufferService.endOfStream(),(this.media.readyState<=2||this.media.buffered.length>1)&&this._startTick()}},{key:"_stopTick",value:function(){this._tickTimer&&clearTimeout(this._tickTimer),this._tickTimer=null}},{key:"_startTick",value:function(){this._stopTick(),this._tickTimer=setTimeout(this._tick,this._tickInterval)}},{key:"_emitError",value:function(e){var r,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(((r=e.originError)===null||r===void 0?void 0:r.fatal)===!1)Je.warn(e);else{var a,u,l;Je.table(e),Je.error(e),Je.error((a=this.media)===null||a===void 0?void 0:a.error),(u=this.media)!==null&&u!==void 0&&u.readyState&&this.media.pause(),this._stopTick(),this._urlSwitching&&(this._urlSwitching=!1,this.emit(he.SWITCH_URL_FAILED,e)),this.emit(he.ERROR,e),n&&this._end(),(l=this._seiService)===null||l===void 0||l.reset()}return e}},{key:"_getSeamlessSwitchPoint",value:function(){var e=this.media,r=e.currentTime;if(!e.paused){var n,a=this._playlist.findSegmentIndexByTime(e.currentTime),u=this._playlist.getSegmentByIndex(a),l=(n=this._stats)===null||n===void 0?void 0:n.getStats().downloadSpeed;if(l&&u){var c=u.duration*this._playlist.currentStream.bitrate/l+1;r+=c}else r+=5}return r}},{key:"_tryEos",value:function(){var e,r,n=this.media,a=this._playlist,u=a.nextSegment,l=a.lastSegment,c=(!u||l&&Xe.isBuffered(n,l.start+l.duration/2))&&n.readyState&&n.duration>0&&((e=this._bufferService)===null||e===void 0?void 0:e.msIsOpened)&&!((r=this._bufferService)!==null&&r!==void 0&&r.msHasOpTasks);if(c){var d=this.bufferInfo();n.paused&&!n.currentTime&&(d=this.bufferInfo(d.nextStart||.5));var h=Math.abs(d.end-n.duration)<.1||!this.isLive&&l&&d.end>=l.start+l.duration;h&&this._bufferService.endOfStream()}}}],[{key:"isSupported",value:function(e){return!e||e==="video"||e==="audio"?Ee.isSupported():typeof WebAssembly<"u"}},{key:"enableLogger",value:function(){$e.enable(),Zi.enable()}},{key:"disableLogger",value:function(){$e.disable(),Zi.disable()}}]),i}(at);G(zi,"version","3.0.20");try{localStorage.getItem("xgd")?zi.enableLogger():zi.disableLogger()}catch{}var Bf=function(){function s(o,i){var t=this;De(this,s),G(this,"_opts",null),G(this,"_plugin",null),G(this,"_onLowDecode",function(){var e,r,n,a,u=t._opts,l=u.media,c=u.innerDegrade;(e=t._plugin)===null||e===void 0||(r=e.player)===null||r===void 0||r.emit("lowdecode",l.degradeInfo),(n=t._plugin)===null||n===void 0||(a=n.player)===null||a===void 0||a.emit("core_event",ge(ge({},l.degradeInfo),{},{eventName:he.LOWDECODE})),c===1&&t._degrade(l.src)}),G(this,"_degrade",function(e){var r=t._plugin.player,n=r.video;if(!(n&&n.TAG!=="MVideo")){var a=r.video.degradeVideo;r.video=a,n.degrade(e),e&&(r.config.url=e);var u=r.root.firstChild;u.TAG==="MVideo"&&r.root.replaceChild(a,u);var l=t._plugin.constructor.pluginName.toLowerCase();r.unRegisterPlugin(l),r.once("canplay",function(){r.play()})}}),G(this,"forceDegradeToVideo",function(e){var r=t._opts.innerDegrade;r===1&&t._degrade(e)}),this._opts=o,this._plugin=i,this._init()}return Ye(s,[{key:"_init",value:function(){var i=this._opts,t=i.media,e=i.preloadTime,r=i.innerDegrade,n=i.isLive;if(t){if(!n&&t.setPlayMode){t.setPlayMode("VOD");return}r&&t.setAttribute("innerdegrade",r),e&&t.setAttribute("preloadtime",e),this._bindEvents()}}},{key:"_bindEvents",value:function(){var i=this._opts.media;i.addEventListener("lowdecode",this._onLowDecode)}},{key:"destroy",value:function(){var i,t;(i=this._opts)===null||i===void 0||(t=i.media)===null||t===void 0||t.removeEventListener("lowdecode",this._onLowDecode),this._plugin=null}}]),s}(),Jf=["currentTime"];function jf(s,o){var i=o.player,t=i.currentTime,e={startTime:t};switch(lr(s)){case"boolean":e.seamless=s;break;case"object":{var r=s.currentTime,n=ss(s,Jf);Object.assign(e,n),typeof r=="number"&&(e.startTime=r);break}}return e}var Rs=function(s){tn(i,s);var o=rn(i);function i(){var t;De(this,i);for(var e=arguments.length,r=new Array(e),n=0;n"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Si(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Iu(s,o){if(o&&(typeof o=="object"||typeof o=="function"))return o;if(o!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Si(s)}function Gi(s){var o=Qf();return function(){var t=Ar(s),e;if(o){var r=Ar(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return Iu(this,e)}}function $f(s,o){if(s){if(typeof s=="string")return no(s,o);var i=Object.prototype.toString.call(s).slice(8,-1);if(i==="Object"&&s.constructor&&(i=s.constructor.name),i==="Map"||i==="Set")return Array.from(s);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return no(s,o)}}function no(s,o){(o==null||o>s.length)&&(o=s.length);for(var i=0,t=new Array(o);i=s.length?{done:!0}:{done:!1,value:s[t++]}},e:function(u){throw u},f:e}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var r=!0,n=!1,a;return{s:function(){i=i.call(s)},n:function(){var u=i.next();return r=u.done,u},e:function(u){n=!0,a=u},f:function(){try{!r&&i.return!=null&&i.return()}finally{if(n)throw a}}}}function em(s,o){if(typeof s!="object"||s===null)return s;var i=s[Symbol.toPrimitive];if(i!==void 0){var t=i.call(s,o);if(typeof t!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}function tm(s){var o=em(s,"string");return typeof o=="symbol"?o:String(o)}var Se={};Se.ArrayBufferToString=function(s){for(var o="",i=new Uint8Array(s),t=0;t2&&arguments[2]!==void 0?arguments[2]:[];if(s.type!==o){if(s&&s.subBox){var t=s.subBox.filter(function(e){return e.type===o});t.length?t.forEach(function(e){return i.push(e)}):s.subBox.forEach(function(e){return Se.findBox(e,o,i)})}}else i.push(s);return i=[].concat(i),i.length>1?i:i[0]};Se.padStart=function(s,o,i){for(var t=String(i),e=o>>0,r=Math.ceil(e/t.length),n=[],a=String(s);r--;)n.push(t);return n.join("").substring(0,e-a.length)+a};Se.durationConvert=function(s){var o=0,i=0,t=0;return s=s.slice(s.indexOf("PT")+2),s.indexOf("H")>-1&&s.indexOf("M")>-1&&s.indexOf("S")>-1?(o=parseFloat(s.slice(0,s.indexOf("H"))),i=parseFloat(s.slice(s.indexOf("H")+1,s.indexOf("M"))),t=parseFloat(s.slice(s.indexOf("M")+1,s.indexOf("S")))):s.indexOf("H")<0&&s.indexOf("M")>0&&s.indexOf("S")>-1?(i=parseFloat(s.slice(0,s.indexOf("M"))),t=parseFloat(s.slice(s.indexOf("M")+1,s.indexOf("S")))):s.indexOf("H")<0&&s.indexOf("M")<0&&s.indexOf("S")>-1&&(t=parseFloat(s.slice(0,s.indexOf("S")))),o*3600+i*60+t};Se.preFixInterge=function(s,o){return(Array(o).join(0)+s).slice(-o)};Se.toHex=function(){for(var s=[],o=arguments.length,i=new Array(o),t=0;t0&&arguments[0]!==void 0?arguments[0]:{},i=o.url,t=o.method,e=t===void 0?"GET":t,r=o.type,n=r===void 0?"arraybuffer":r,a=o.data,u=a===void 0?{}:a;return qt(this,s),new Promise(function(l,c){var d=new window.XMLHttpRequest,h=e.toUpperCase(),f=[];n&&(d.responseType=n);for(var m in u)Object.prototype.hasOwnProperty.call(u,m)&&f.push("k=".concat(u[m]));if(h==="GET")d.open(h,"".concat(i,"?").concat(f.join("&"))),d.send();else if(h==="post")i.indexOf("data:application/json;base64")===0?(d.open(h,i,!0),d.timeout=0,d.withCredentials=!1,d.send(f)):(d.open(h,i),d.setRequestHeader("Content-type","application/x-www-form-urlencoded"),d.send(f.join("&")));else throw new Error("xhr ".concat(h," is not supported"));d.onload=function(){d.status===200||d.status===206?l(d):c(d)},d.onerror=function(){c(d)}})}),rm=function(){function s(){qt(this,s)}return ei(s,null,[{key:"parse",value:function(i){var t=s.parseXmlString(i);return t!=null?s.parseDOMChildren(t):null}},{key:"parseXmlString",value:function(i){if(i===void 0)return null;var t,e=new window.DOMParser;try{t=e.parseFromString(i,"text/xml"),t.getElementsByTagNameNS("*","parsererror").length>0&&(t=null)}catch{t=null}return t}},{key:"parseDOMChildren",value:function(i,t){if(i.nodeType===Node.DOCUMENT_NODE){for(var e={},r=i.childNodes,n=0;n-1&&(p.id=(parseInt(h[h.length-1])+1).toString()),h.push(p.id);var b="",x=[],T=0,X=0,M=e.slice(0,e.lastIndexOf("/")+1)+m;p.mimeType&&(k=p.mimeType),p.mimeType&&(k=p.mimeType),k==="video/mp4"?(p.codecs&&(_=p.codecs),p.width&&(w=parseFloat(p.width)),p.height&&(Z=parseFloat(p.height)),p.maxWidth&&(C=parseFloat(p.maxWidth)),p.maxHeight&&(R=parseFloat(p.maxHeight)),p.frameRate&&(E=parseFloat(p.frameRate)),p.sar&&(P=p.sar),p.startWithSAP&&(I=p.startWithSAP),p.bandwidth&&(D=parseFloat(p.bandwidth))):k==="audio/mp4"&&(p.codecs&&(_=p.codecs),p.startWithSAP&&(I=p.startWithSAP),p.bandwidth&&(D=parseFloat(p.bandwidth))),p.BaseURL&&p.BaseURL.length>0&&(M+=p.BaseURL[0]);var F;y.SegmentTemplate&&y.SegmentTemplate.length>0&&(F=y.SegmentTemplate[0]),p.SegmentTemplate&&p.SegmentTemplate.length>0&&(F=p.SegmentTemplate[0]);var Y=!1;if((y.ContentProtection||p.ContentProtection)&&(Y=!0),F){b=F.initialization,T=parseFloat(F.timescale),X=parseFloat(F.duration);for(var U=X/T,te=parseInt(F.startNumber),O=te+Math.ceil(r.duration/U)-1,_e=te;_e<=O;_e++){var We=U*(_e-te),qe=U*(_e-te+1);_e===O&&(U=r.duration-U*(O-te),qe=r.duration),x.push({idx:_e,start:We,end:qe,url:M+F.media.replace("$RepresentationID$",p.id).replace("$Number%04d$",Se.preFixInterge(_e,4)),downloaded:!1,segmentDuration:U})}}k==="video/mp4"?r.mediaList.video.push({id:p.id,baseURL:M,initSegment:M+b.replace("$RepresentationID$",p.id),inited:!1,mediaSegments:x,mimeType:k,codecs:_,width:w,height:Z,maxWidth:C,maxHeight:R,frameRate:E,sar:P,startWithSAP:I,bandwidth:D,timescale:T,duration:X,encrypted:Y}):k==="audio/mp4"&&r.mediaList.audio.push({id:p.id,baseURL:M,initSegment:M+b.replace("$RepresentationID$",p.id),inited:!1,mediaSegments:x,mimeType:k,codecs:_,startWithSAP:I,bandwidth:D,timescale:T,duration:X,encrypted:Y})})}),["video","audio"].forEach(function(y){r.mediaList[y].selectedIdx=0,r.mediaList[y].sort(function(L,k){return L.bandwidth-k.bandwidth})}),u({meta:n,segments:a})}else l(new Error("parse error"))}).catch(function(c){console.error(c),l(c)})})}},{key:"init",value:function(e){var r=this;this.fetch(e).then(function(n){r.type=n.meta.TYPE.toLocaleLowerCase(),r.emit("ready")},function(){console.log("mpd init reject"),["video","audio"].forEach(function(n){r.mediaList[n]=[]}),r.retry++,r.retry2&&arguments[2]!==void 0?arguments[2]:{},a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"";return qt(this,i),n.version=Wu,r=o.call(this,t,e,n),r.url=a,r}return ei(i)}(Lt),om=function(s){Xi(i,s);var o=Gi(i);function i(){var t;qt(this,i),t=o.call(this);var e=Si(t);return t.codecs=[],t.sourceBuffer={},t.mediaSource=new MediaSource,t.url=URL.createObjectURL(t.mediaSource),t.queue={},t.updating=!1,t.mediaSource.addEventListener("sourceopen",function(){e.emit("sourceopen")}),t.mediaSource.addEventListener("sourceclose",function(){e.emit("sourceclose")}),t}return ei(i,[{key:"state",get:function(){return this.mediaSource.readyState}},{key:"duration",get:function(){return this.mediaSource.duration},set:function(e){this.mediaSource.duration=e}},{key:"addSourceBuffer",value:function(e){var r=this;this.codecs.push(e);var n=this.mediaSource.addSourceBuffer(e);this.sourceBuffer[e]=n,n.addEventListener("error",function(a){r.emit("error",new am("mse","",{line:16,handle:"[MSE] constructor sourceopen",msg:a.message}))}),n.addEventListener("updateend",function(a){if(r.emit(e+" updateend"),r.queue[e]&&S.typeOf(r.queue[e])==="Array"){var u=r.queue[e].shift();u&&(n.updating===!1&&r.state==="open"?n.appendBuffer(u):r.queue[e].unshift(u))}})}},{key:"appendBuffer",value:function(e,r){var n=this.sourceBuffer[e];return n.updating===!1&&this.state==="open"?(n.appendBuffer(r),!0):(this.queue[e]||(this.queue[e]=[]),this.queue[e].push(r),!1)}},{key:"removeBuffer",value:function(e,r,n){this.sourceBuffer[e].updating===!1&&this.state==="open"&&this.sourceBuffer[e].remove(r,n)}},{key:"endOfStream",value:function(){this.state==="open"&&this.mediaSource.endOfStream()}}],[{key:"isSupported",value:function(e){return window.MediaSource&&window.MediaSource.isTypeSupported(e)}}]),i}(at),um=function(s){Xi(i,s);var o=Gi(i);function i(t){var e;return qt(this,i),e=o.call(this),e.drm=t,e.KEYSYSTEM_TYPE="",e.keys={},e.drm.clearKeys&&(e.KEYSYSTEM_TYPE="org.w3.clearkey",e.keys=e.drm.clearKeys),e.options=[],e.ensurePromise=void 0,e}return ei(i,[{key:"setOptions",value:function(){var e=[{contentType:'video/mp4; codecs="avc1.42E01E"'},{contentType:'video/webm; codecs="vp8"'}],r={videoCapabilities:e},n={videoCapabilities:e,persistentState:"required",sessionTypes:["persistent-license"]};this.options=[n,r]}},{key:"bail",value:function(e){return function(r){console.log(e+(r?" "+r:""))}}},{key:"UpdateSessionFunc",value:function(e){var r=this;return function(n){var a=[],u=[];Object.keys(e).forEach(function(d){var h=e[d],f=Se.fromHex(d),m=Se.fromHex(h),g={kty:"oct",kid:Se.toBase64(f,!1),k:Se.toBase64(m,!1)};a.push(g),u.push(g.kid)});var l={keys:a},c=JSON.stringify(l);n.target.update(Se.StringToArrayBuffer(c)).then(function(){},r.bail(" MediaKeySession update failed"))}}},{key:"KeysChange",value:function(e){var r=e.target,n=r.keyStatuses,a=qf(n.entries()),u;try{for(a.s();!(u=a.n()).done;)var l=u.value,c=l[0],d=l[1],h=Se.Base64ToHex(window.btoa(Se.ArrayBufferToString(c)))}catch(f){a.e(f)}finally{a.f()}}},{key:"EnsureMediaKeysCreated",value:function(e,r,n){var a=this;return this.ensurePromise?this.ensurePromise:(this.ensurePromise=navigator.requestMediaKeySystemAccess(r,n).then(function(u){return u.createMediaKeys()},a.bail(" Failed to request key system access.")).then(function(u){return e.setMediaKeys(u)},a.bail(" failed to create MediaKeys object")),this.ensurePromise)}},{key:"SetupEME",value:function(e,r){var n=this;e.sessions=[],this.on("encrypted",function(){var a="keyids",u=JSON.stringify({kids:["0123456789abcdef0123456789abcdef"]}),l=new Uint8Array(Se.toUTF8(u));n.EnsureMediaKeysCreated(e,n.KEYSYSTEM_TYPE,n.options).then(function(){var c=e.mediaKeys.createSession();return e.sessions.push(c),c.addEventListener("message",n.UpdateSessionFunc(n.keys)),c.addEventListener("keystatuseschange",n.KeysChange),c.generateRequest(a,l.buffer)},n.bail(" failed to ensure MediaKeys on HTMLMediaElement")).then(function(){},n.bail(" Failed to generate request."))})}}]),i}(at),lm=function(s){Xi(i,s);var o=Gi(i);function i(t){var e,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return qt(this,i),e=o.call(this),e.mse=void 0,e.url=t,e.inited=!1,n&&(e.video=n),r.dashOpts&&r.dashOpts.drm&&(e.eme=new um(r.dashOpts.drm)),e}return ei(i,[{key:"getData",value:function(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0];return new Promise(function(n,a){var u=new Bi(e,n,r);u.once("error",function(l){self.emit("error",l)})})}},{key:"init",value:function(e){var r=this,n=new sm(e);this.mpd=n;var a=this,u,l,c;return new Promise(function(d,h){n.once("ready",function(){a.type=n.type,l=n.mediaList.video,c=n.mediaList.audio,a.eme&&(a.eme.setOptions("".concat(l[l.selectedIdx].mimeType,'; codecs="').concat(l[l.selectedIdx].codecs,'"'),"".concat(c[c.selectedIdx].mimeType,'; codecs="').concat(c[c.selectedIdx].codecs,'"')),a.eme.SetupEME(a.video)),u=new om,u.on("sourceopen",function(){["video","audio"].forEach(function(f){var m=n.mediaList[f];m[m.selectedIdx]&&(u.addSourceBuffer("".concat(m[m.selectedIdx].mimeType,';codecs="').concat(m[m.selectedIdx].codecs,'"')),a.getData(m[m.selectedIdx].initSegment,m[m.selectedIdx].initSegmentRange).then(function(g){u.appendBuffer("".concat(m[0].mimeType,';codecs="').concat(m[0].codecs,'"'),g),u.once("".concat(m[m.selectedIdx].mimeType,';codecs="').concat(m[m.selectedIdx].codecs,'" updateend'),function(){m[m.selectedIdx].inited=!0,u.emit("updateend")})}))})}),u.on("updateend",function(f){l[l.selectedIdx]&&l[l.selectedIdx].inited&&c[c.selectedIdx]&&c[c.selectedIdx].inited&&(a.inited=!0,(l[l.selectedIdx].encrypted||c[c.selectedIdx].encrypted)&&a.eme.emit("encrypted"),a.type==="vod"&&(a.seek(0),a.emit("startPlay")))}),u.on("error",function(f){h(f),console.log("mse error")}),a.mse=u,d(u)}),n.once("end",function(){r.type==="live"&&a.mse.endOfStream()})})}},{key:"seek",value:function(e){var r=this,n=this.mpd.seek(e);["video","audio"].forEach(function(a){n[a]&&n[a].length>0&&n[a].every(function(u){return u.downloaded||new Bi(u.url,function(l){if(l==="Not Found"){if(u.tryTimes||(u.tryTimes=0),u.tryTimes++,u.tryTimes<=2)return!0}else r.mse.appendBuffer("".concat(r.mpd.mediaList[a][0].mimeType,';codecs="').concat(r.mpd.mediaList[a][0].codecs,'"'),new Uint8Array(l));var c=u.idx,d=r.mpd.mediaList[a];d[d.selectedIdx].mediaSegments.every(function(h){return h.idx!==c?!0:(h.downloaded=!0,!1)})},u.range),!0})})}}]),i}(at),cm=function(o,i){i.vid=o.config.vid,i.url=o.src,i.errd&&os(i.errd)==="object"&&o.dash&&(i.errd.url=o.dash.url,i.url=o.dash.url),o.emit("DATA_REPORT",i),i.errt==="network"&&o.config._backupURL?o.src=o.config._backupURL:o.src=o.config._mainURL,o.switchURL=null,o._replay=null},dm=function(s){Xi(i,s);var o=Gi(i);function i(t){var e;return qt(this,i),e=o.call(this,t),e.definitions=[],e.destroy=e.destroy.bind(Si(e)),e.timeUpdate=e.timeUpdate.bind(Si(e)),e.replay=e.replay.bind(Si(e)),e.initEvents(),e}return ei(i,[{key:"initEvents",value:function(){this.on(ji,this.destroy),this.on(ft,this.timeUpdate),this.on(tr,this.replay)}},{key:"beforePlayerInit",value:function(){var e=this,r=this.player,n=this.playerConfig;if(this.config.drm&&!navigator.requestMediaKeySystemAccess){console.log("EME API is not supported. Enable pref media.eme.enabled to true in about:config");return}var a=new lm(n.url,n,r.video);return a.init(n.url).then(function(u){e.definitions.length||(a.mpd.mediaList.video.forEach(function(c){e.definitions.push({name:c.height+"P",url:c.id,selected:!1})}),e.definitions[0].selected=!0),r.emit("resourceReady",e.definitions);var l=u;e.dash=a,e.mse=l,a.on("error",function(c){cm(r,c)}),a.once("startPlay",function(){e.progressTimer=setInterval(function(){e.timeUpdate()},300)});try{Ue.defineGetterOrSetter(e.player,{__url:{get:function(){return e.mse.url}}})}catch{}})}},{key:"loadData",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.player.currentTime,r=this.dash,n=this.findRangeForPlaybackTime(e),a=n&&n.end||e;a>e+15||r.seek(a)}},{key:"download",value:function(){this.dash.download()}},{key:"findRangeForPlaybackTime",value:function(e){var r=this.player,n=r.buffered;if(n){for(var a=0;a=e)return{start:n.start(a),end:n.end(a)}}}},{key:"switchURL",value:function(e){var r=this.player;r.config.url=e,r.hasStart=!1,r.paused?r.start(e):(r.pause(),r.once("pause",function(){r.start(e)}),r.once("canplay",function(){r.play()})),r.once("canplay",function(){r.currentTime=0})}},{key:"timeUpdate",value:function(){var e=this.player,r=this.dash;this.loadData(e.currentTime+1),this.isEnded(e,r)}},{key:"switchBW",value:function(e){var r=this,n=this.dash;e=e.split("/")[e.split("/").length-1];var a=n.mpd.mediaList.video,u=a.selectedIdx;a.every(function(c,d){return c.id===e?(u=d,n.getData(a[u].initSegment,a[u].initSegmentRange).then(function(h){l(h)}),!1):!0});var l=function(d){var h=r.player,f=h.currentTime,m=a[a.selectedIdx].mediaSegments.find(function(L){return L.start-f>6}),g=m.start,y=h.getBufferedRange()[1];y-g>0&&Ue.Sniffer.browser!=="safari"&&h.mse.removeBuffer("".concat(a[0].mimeType,';codecs="').concat(a[0].codecs,'"'),g,y),a[a.selectedIdx].mediaSegments.every(function(L){return L.downloaded=!1,!0}),r.mse.appendBuffer("".concat(a[0].mimeType,';codecs="').concat(a[0].codecs,'"'),d),r.mse.once("".concat(a[0].mimeType,';codecs="').concat(a[0].codecs,'" updateend'),function(){a[u].inited=!0,a.selectedIdx=u,r.loadData((m.start+m.end)/2)})}}},{key:"replay",value:function(){var e=this.player;Bi.clear();var r=this.dash.mpd.mediaList.video.selectedIdx;this.definitions[r].selected=!0,e.hasStart=!1,e.start(),this.once(cr,function(){e.play()})}},{key:"isEnded",value:function(){var e=this.dash,r=this.player,n=this.mse;if(e.type==="vod"&&r.duration-r.currentTime<2){var a=r.getBufferedRange();r.currentTime-a[1]<.1&&(n.endOfStream(),this.progressTimer&&(clearInterval(this.progressTimer),this.progressTimer=null))}}},{key:"destroy",value:function(){this.dash&&window.clearTimeout(this.dash.mpd.timer),this.progressTimer&&clearInterval(this.progressTimer)}}],[{key:"pluginName",get:function(){return"DashPlugin"}}]),i}(Ue);const hm=Vu({name:"EsVideo",components:{},props:{options:{type:Object,default:()=>({})},element:{type:Object,default:()=>({})}},emits:["updateValue","update:eventData"],setup(s){let o=null;function i(){const e={id:`video-${s.element.id}`,plugins:[],...s.options};s.options.mode==="mp4"?e.plugins.push(sf):s.options.mode==="flv"?e.plugins.push(_u):s.options.mode==="hls"?e.plugins.push(Rs):s.options.mode==="mpeg-dash"&&e.plugins.push(dm),o=new Xt(e),new Function("config","player",s.options.codeConfig)(e,o)}function t(){o&&(o.destroy(),o=null)}return Du(()=>s.options,e=>{e.url?Yu(()=>{t(),i()}):t()},{immediate:!0,deep:!0}),{url:Nu(s.options.url)}}}),fm=["id"],mm={key:0,style:{width:"100%",height:"100%",display:"flex","justify-content":"center","align-items":"center",border:"1px solid #00ffff","box-sizing":"border-box",color:"#F5A623"}};function pm(s,o,i,t,e,r){return Ws(),Ms("div",{id:`video-${s.element.id}`,style:{width:"100%",height:"100%"}},[s.url?Hu("",!0):(Ws(),Ms("div",mm," 暂无内容 "))],8,fm)}const ym=Fu(hm,[["render",pm]]);export{ym as default};