!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MSPlayer={})}(this,function(_){"use strict";var x=function(e,t){return(x=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(e,t){e.__proto__=t}:function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}))(e,t)};var C=function(){return(C=Object.assign||function(e){for(var t,i=1,n=arguments.length;io[0]&&t[1]`):fe)})}const V=ge,me=/^(\d+)x(\d+)$/,ye=/(.+?)=(".*?"|.*?)(?:,|$)/g;class be{constructor(e){for(const t in e="string"==typeof e?be.parseAttrList(e):e)e.hasOwnProperty(t)&&("X-"===t.substring(0,2)&&(this.clientAttrs=this.clientAttrs||[],this.clientAttrs.push(t)),this[t]=e[t])}decimalInteger(e){e=parseInt(this[e],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(e){if(this[e]){var t=(1&(t=(this[e]||"0x").slice(2)).length?"0":"")+t,i=new Uint8Array(t.length/2);for(let e=0;eNumber.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){e=this[e];return e?parseFloat(e):t}enumeratedString(e){return this[e]}bool(e){return"YES"===this[e]}decimalResolution(e){e=me.exec(this[e]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(e){var t,i={};for(ye.lastIndex=0;null!==(t=ye.exec(e));){let e=t[2];0===e.indexOf('"')&&e.lastIndexOf('"')===e.length-1&&(e=e.slice(1,-1)),i[t[1].trim()]=e}return i}}class Ee{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){var i=t.attr;for(const n in i)if(Object.prototype.hasOwnProperty.call(e,n)&&e[n]!==i[n]){V.warn(`DATERANGE tag attribute: "${n}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=n;break}e=ue(new be({}),i,e)}this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr&&(t=new Date(this.attr["END-DATE"]),B(t.getTime()))&&(this._endDate=t)}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){var e;return this._endDate||(null!==(e=this.duration)?new Date(this._startDate.getTime()+1e3*e):null)}get duration(){if("DURATION"in this.attr){var e=this.attr.decimalFloatingPoint("DURATION");if(B(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&B(this.startDate.getTime())&&(null===this.duration||0<=this.duration)&&(!this.endOnNext||!!this.class)}}class Se{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var Te="audio",we="video",Me="audiovideo";class Ae{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[Te]:null,[we]:null,[Me]:null},this.baseurl=e}setByteRange(e,t){var e=e.split("@",2),i=[];1===e.length?i[0]=t?t.byteRangeEndOffset:0:i[0]=parseInt(e[1]),i[1]=parseInt(e[0])+i[0],this._byteRange=i}get byteRange(){return this._byteRange||[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=se.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class Le extends Ae{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Se,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=e}get decryptdata(){var e=this["levelkeys"];if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){var e;return null!==this.programDateTime&&B(this.programDateTime)?(e=B(this.duration)?this.duration:0,this.programDateTime+1e3*e):null}get encrypted(){if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){var e=Object.keys(this.levelkeys),t=e.length;if(1e.endSN||0e.charCodeAt(0))}function _e(e){function t(e,t,i){var n=e[t];e[t]=e[i],e[i]=n}t(e,0,3),t(e,1,2),t(e,4,5),t(e,6,7)}function xe(e){var t,i,e=e.split(":");let n=null;return"data"===e[0]&&2===e.length&&2===(t=(e=e[1].split(";"))[e.length-1].split(",")).length&&(i="base64"===t[0],t=t[1],n=i?(e.splice(-1,1),ke(t)):(i=Ce(i=t).subarray(0,16),(e=new Uint8Array(16)).set(i,16-i.length),e)),n}function Ce(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}var f={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Re="org.w3.clearkey",Pe="com.apple.streamingkeydelivery",Ne="com.microsoft.playready",Oe="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function Be(e){switch(e){case Pe:return f.FAIRPLAY;case Ne:return f.PLAYREADY;case Oe:return f.WIDEVINE;case Re:return f.CLEARKEY}}var Fe="edef8ba979d64acea3c827dcd51d21ed";function Ue(e){switch(e){case f.FAIRPLAY:return Pe;case f.PLAYREADY:return Ne;case f.WIDEVINE:return Oe;case f.CLEARKEY:return Re}}function ze(e){const{drmSystems:t,widevineLicenseUrl:i}=e;e=t?[f.FAIRPLAY,f.WIDEVINE,f.PLAYREADY,f.CLEARKEY].filter(e=>!!t[e]):[];return!e[f.WIDEVINE]&&i&&e.push(f.WIDEVINE),e}const Ze="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function je(e,t,i){return Uint8Array.prototype.slice?e.slice(t,i):new Uint8Array(Array.prototype.slice.call(e,t,i))}const Ge=(e,t)=>t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128,Ve=(e,t)=>t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128,Ye=(e,t)=>{var i=t;let n=0;for(;Ge(e,t);){n+=10;var r=He(e,t+6);n+=r,Ve(e,t+10)&&(n+=10),t+=n}if(0{var i=(127&e[t])<<21;return(i|=(127&e[t+1])<<14)|(127&e[t+2])<<7|127&e[t+3]},We=e=>{var t=Qe(e);for(let e=0;ee&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info,Qe=e=>{let t=0;for(var i,n=[];Ge(e,t);){for(var r=He(e,t+6),a=(t+=10)+r;t+8{if(e.type==="PRIV")return qe(e);else if(e.type[0]==="W")return Je(e);return Xe(e)})(s);o&&n.push(o),t+=s.size+10}Ve(e,t)&&(t+=10)}return n},qe=e=>{var t,i;if(!(e.size<2))return t=$e(e.data,!0),i=new Uint8Array(e.data.subarray(t.length+1)),{key:e.type,info:t,data:i.buffer}},Xe=e=>{var t,i;if(!(e.size<2))return"TXXX"===e.type?(t=1,t+=(i=$e(e.data.subarray(1),!0)).length+1,t=$e(e.data.subarray(t)),{key:e.type,info:i,data:t}):(i=$e(e.data.subarray(1)),{key:e.type,data:i})},Je=e=>{var t,i;return"WXXX"===e.type?e.size<2?void 0:(t=1,t+=(i=$e(e.data.subarray(1),!0)).length+1,t=$e(e.data.subarray(t)),{key:e.type,info:i,data:t}):(i=$e(e.data),{key:e.type,data:i})},$e=(e,t=!1)=>{var i,n=function(){et||void 0===self.TextDecoder||(et=new self.TextDecoder("utf-8"));return et}();if(n)return n=n.decode(e),t?-1!==(i=n.indexOf("\0"))?n.substring(0,i):n:n.replace(/\0/g,"");var r,a,s=e.length;let o,l="",u=0;for(;u>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:l+=String.fromCharCode(r);break;case 12:case 13:o=e[u++],l+=String.fromCharCode((31&r)<<6|63&o);break;case 14:o=e[u++],a=e[u++],l+=String.fromCharCode((15&r)<<12|(63&o)<<6|(63&a)<<0)}}return l};let et;const tt={hexDump:function(i){let n="";for(let t=0;t>24,e[t+1]=i>>16&255,e[t+2]=i>>8&255,e[t+3]=255&i}function I(t,i){var n=[];if(i.length){var r=t.byteLength;for(let e=0;e{var t=L(e,4),t=i[t];t&&(t.default={duration:L(e,12),flags:L(e,20)})}),i}function dt(e){var t=I(e,["schm"])[0];if(t){t=at(t.subarray(4,8));if("cbcs"===t||"cenc"===t)return I(e,["schi","tenc"])[0]}return V.error("[eme] missing 'schm' box"),null}function ct(e,t){let i=0,n=0,r=0;var a=I(e,["moof","traf"]);for(let e=0;e>>31)return V.warn("SIDX has hierarchical references (not supported)"),null;l=L(t,o);o+=4,i.push({referenceSize:u,subsegmentDuration:l,info:{duration:l/r,start:a,end:a+u-1}}),a+=u,o+=4,n=o}return{earliestPresentationTime:0,timescale:r,version:e,referencesCount:s,references:i}}(p[e]);null!=g&&g.references&&(t+=g.references.reduce((e,t)=>e+t.info.duration||0,0))}return t}}function ht(e,t){var i=new Uint8Array(e.length+t.length);return i.set(e),i.set(t,e.length),i}function ft(E,S){const T=[],w=S.samples,M=S.timescale,u=S.id;let A=!1;return I(w,["moof"]).map(e=>{const b=e.byteOffset-8;I(e,["traf"]).map(l=>{var e=I(l,["tfdt"]).map(e=>{var t=e[0];let i=L(e,4);return(i=1===t?(i*=Math.pow(2,32))+L(e,8):i)/M})[0];return void 0!==e&&(E=e),I(l,["tfhd"]).map(e=>{var t=L(e,4),i=16777215&L(e,0),n=0!=(1&i),r=0!=(2&i),a=0!=(8&i);let m=0;var s=0!=(16&i);let y=0;i=0!=(32&i);let o=8;t===u&&(n&&(o+=8),r&&(o+=4),a&&(m=L(e,o),o+=4),s&&(y=L(e,o),o+=4),i&&(o+=4),"video"===S.type&&(A=function(e){if(!e)return!1;var t=e.indexOf("."),e=t<0?e:e.substring(0,t);return"hvc1"===e||"hev1"===e||"dvh1"===e||"dvhe"===e}(S.codec)),I(l,["trun"]).map(t=>{var i=t[0],e=16777215&L(t,0);let n=0;var r=0!=(256&e);let a=0;var s=0!=(512&e);let o=0;var l=0!=(1024&e),u=0!=(2048&e);let d=0;var c,h,f=L(t,4);let p=8,g=(0!=(1&e)&&(n=L(t,p),p+=4),0!=(4&e)&&(p+=4),n+b);for(let e=0;e>1&63)||40==c:6==(31&h))&&pt(w.subarray(g,g+v),A?2:1,E+d/M,T),g+=v,e+=v+4}}E+=a/M}}))})})}),T}function pt(e,t,i,n){var r=gt(e);let a=0,s=(a+=t,0),o=0,l=!1,u=0;for(;a=r.length)&&(u=r[a++],s+=u,255===u););for(o=0;!(a>=r.length)&&(u=r[a++],o+=u,255===u););var d=r.length-a;if(!l&&4===s&&ad)break}}function gt(e){var t=e.byteLength,i=[];let n=1;for(;n>24&255,h[1]=e>>16&255,h[2]=e>>8&255,h[3]=255&e,h.set(u,4),t=0,e=8;t>8*(15-e)&255;return i}(t),new yt(this.method,this.uri,"identity",this.keyFormatVersions,t);var i=xe(this.uri);if(i)switch(this.keyFormat){case Oe:22<=(this.pssh=i).length&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case Ne:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]),n=(this.pssh=vt(n,null,i),new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2)),n=String.fromCharCode.apply(null,Array.from(n)),n=n.substring(n.indexOf("<"),n.length),n=(new DOMParser).parseFromString(n,"text/xml").getElementsByTagName("KID")[0];n&&(n=n.childNodes[0]?n.childNodes[0].nodeValue:n.getAttribute("VALUE"))&&(_e(n=ke(n).subarray(0,16)),this.keyId=n);break;default:{let e=i.subarray(0,16);16!==e.length&&((n=new Uint8Array(16)).set(e,16-e.length),e=n),this.keyId=e;break}}if(!this.keyId||16!==this.keyId.byteLength){let e=mt[this.uri];e||(t=Object.keys(mt).length%Number.MAX_SAFE_INTEGER,e=new Uint8Array(16),new DataView(e.buffer,12,4).setUint32(0,t),mt[this.uri]=e),this.keyId=e}return this}}const bt=/\{\$([a-zA-Z0-9-_]+)\}/g;function Et(e){return bt.test(e)}function St(t,i,n){if(null!==t.variableList||t.hasVariableRefs)for(let e=n.length;e--;){var r=n[e],a=i[r];a&&(i[r]=Tt(t,a))}}function Tt(n,e){if(null!==n.variableList||n.hasVariableRefs){const r=n.variableList;return e.replace(bt,e=>{var t=e.substring(2,e.length-1),i=null==r?void 0:r[t];return void 0===i?(n.playlistParsingError||(n.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${t}"`)),e):i})}return e}function wt(t,e,i){let n=t.variableList;n||(t.variableList=n={});let r,a;if("QUERYPARAM"in e){r=e.QUERYPARAM;try{var s=new self.URL(i).searchParams;if(!s.has(r))throw new Error(`"${r}" does not match any query parameter in URI: "${i}"`);a=s.get(r)}catch(e){t.playlistParsingError||(t.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+e.message))}}else r=e.NAME,a=e.VALUE;r in n?t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):n[r]=a||""}function Mt(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}const At={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},Lt=Mt();function It(e,t){return null!=(t=null==Lt?void 0:Lt.isTypeSupported(`${t||"video"}/mp4;codecs="${e}"`))&&t}const Dt=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,kt=/#EXT-X-MEDIA:(.*)/g,_t=/^#EXT(?:INF|-X-TARGETDURATION):/m,xt=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Ct=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class Rt{static findGroup(t,i){for(let e=0;e{const t=n.filter(e=>{return e=e,t=i,!!(t=At[t])&&!0===t[e.slice(0,4)];var t});var e;t.length&&(e=t.filter(e=>0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0)),r[i+"Codec"]=(0-1===t.indexOf(e)))}),r.unknownCodecs=n}((a.CODECS||"").split(/[ ,]+/).filter(e=>e),s),s.videoCodec&&-1!==s.videoCodec.indexOf("avc1")&&(s.videoCodec=Rt.convertAVC1ToAVCOTI(s.videoCodec)),null!=(o=s.unknownCodecs)&&o.length||r.push(s),n.levels.push(s)}else if(i[3]){var a=i[3],l=i[4];switch(a){case"SESSION-DATA":var u=new be(l),d=(St(n,u,["DATA-ID","LANGUAGE","VALUE","URI"]),u["DATA-ID"]);d&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[d]=u);break;case"SESSION-KEY":d=Pt(l,t,n);d.encrypted&&d.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(d)):V.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${l}"`);break;case"DEFINE":u=new be(l);St(n,u,["NAME","VALUE","QUERYPARAM"]),wt(n,u,t);break;case"CONTENT-STEERING":var c=new be(l);St(n,c,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:Rt.resolve(c["SERVER-URI"],t),pathwayId:c["PATHWAY-ID"]||"."};break;case"START":n.startTimeOffset=Nt(l)}}var h=0({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:r.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]};let s=0;for(kt.lastIndex=0;null!==(u=kt.exec(e));){var o,l,u=new be(u[1]),d=u.TYPE;d&&(o=a[d],l=n[d]||[],n[d]=l,St(i,u,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]),d={attrs:u,bitrate:0,id:s++,groupId:u["GROUP-ID"]||"",instreamId:u["INSTREAM-ID"],name:u.NAME||u.LANGUAGE||"",type:d,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:u.LANGUAGE,url:u.URI?Rt.resolve(u.URI,t):""},null!=o&&o.length&&(Ot(d,u=Rt.findGroup(o,d.groupId)||o[0],"audioCodec"),Ot(d,u,"textCodec")),l.push(d))}return n}static parseLevelPlaylist(e,t,i,n,r,O){var a=new De(t),s=a.fragments;let o=null,l=0,u=0,d=0,c=0,h=null,f=new Le(n,t),p,g,v,m=-1,y=!1;for(xt.lastIndex=0,a.m3u8=e,a.hasVariableRefs=Et(e);null!==(p=xt.exec(e));){y&&(y=!1,(f=new Le(n,t)).start=d,f.sn=l,f.cc=c,f.level=i,o)&&(f.initSegment=o,f.rawProgramDateTime=o.rawProgramDateTime,o.rawProgramDateTime=null);var b=p[1];if(b){f.duration=parseFloat(b);var E=(" "+p[2]).slice(1);f.title=E||null,f.tagList.push(E?["INF",b,E]:["INF",b])}else if(p[3])B(f.duration)&&(f.start=d,v&&Ut(f,v,a),f.sn=l,f.level=i,f.cc=c,f.urlId=r,s.push(f),E=(" "+p[3]).slice(1),f.relurl=Tt(a,E),Bt(f,h),h=f,d+=f.duration,l++,u=0,y=!0);else if(p[4]){b=(" "+p[4]).slice(1);h?f.setByteRange(b,h):f.setByteRange(b)}else if(p[5])f.rawProgramDateTime=(" "+p[5]).slice(1),f.tagList.push(["PROGRAM-DATE-TIME",f.rawProgramDateTime]),-1===m&&(m=s.length);else if(p=p[0].match(Ct)){for(g=1;gt[e].isCommonEncryption)||i.push(e)}var zt="manifest",Zt="level",jt="audioTrack",Gt="subtitleTrack",y="main",Vt="audio",Yt="subtitle";function Ht(e){e=e.type;switch(e){case jt:return Vt;case Gt:return Yt;default:return y}}function Wt(e,t){let i=e.url;return i=void 0!==i&&0!==i.indexOf("data:")?i:t.url}class Kt{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){var e=this["hls"];e.on(Z.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Z.LEVEL_LOADING,this.onLevelLoading,this),e.on(Z.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(Z.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){var e=this["hls"];e.off(Z.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Z.LEVEL_LOADING,this.onLevelLoading,this),e.off(Z.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(Z.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){var t=this.hls.config,i=t.pLoader,n=t.loader,i=new(i||n)(t);return this.loaders[e.type]=i}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){t=t.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:zt,url:t,deliveryDirectives:null})}onLevelLoading(e,t){var{id:t,level:i,url:n,deliveryDirectives:r}=t;this.load({id:t,level:i,responseType:"text",type:Zt,url:n,deliveryDirectives:r})}onAudioTrackLoading(e,t){var{id:t,groupId:i,url:n,deliveryDirectives:r}=t;this.load({id:t,groupId:i,level:null,responseType:"text",type:jt,url:n,deliveryDirectives:r})}onSubtitleTrackLoading(e,t){var{id:t,groupId:i,url:n,deliveryDirectives:r}=t;this.load({id:t,groupId:i,level:null,responseType:"text",type:Gt,url:n,deliveryDirectives:r})}load(t){var i=this.hls.config;let e=this.getInternalLoader(t);if(e){var n=e.context;if(n&&n.url===t.url)return void V.trace("[playlist-loader]: playlist request ongoing");V.log("[playlist-loader]: aborting previous loader for type: "+t.type),e.abort()}let r;if(r=t.type===zt?i.manifestLoadPolicy.default:ue({},i.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),e=this.createInternalLoader(t),null!=(n=t.deliveryDirectives)&&n.part){let e;t.type===Zt&&null!==t.level?e=this.hls.levels[t.level].details:t.type===jt&&null!==t.id?e=this.hls.audioTracks[t.id].details:t.type===Gt&&null!==t.id&&(e=this.hls.subtitleTracks[t.id].details),e&&(i=e.partTarget,n=e.targetduration,i)&&n&&(i=1e3*Math.max(3*i,.8*n),r=ue({},r,{maxTimeToFirstByteMs:Math.min(i,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(i,r.maxTimeToFirstByteMs)}))}n=r.errorRetry||r.timeoutRetry||{},i={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:n.maxNumRetry||0,retryDelay:n.retryDelayMs||0,maxRetryDelay:n.maxRetryDelayMs||0};e.load(t,i,{onSuccess:(e,t,i,n)=>{var r=this.getInternalLoader(i),a=(this.resetInternalLoader(i.type),e.data);0!==a.indexOf("#EXTM3U")?this.handleManifestParsingError(e,i,new Error("no EXTM3U delimiter"),n||null,t):(t.parsing.start=performance.now(),Rt.isMediaPlaylist(a)?this.handleTrackOrLevelPlaylist(e,t,i,n||null,r):this.handleMasterPlaylist(e,t,i,n))},onError:(e,t,i,n)=>{this.handleNetworkError(t,i,!1,e,n)},onTimeout:(e,t,i)=>{this.handleNetworkError(t,i,!0,void 0,e)}})}handleMasterPlaylist(e,t,i,n){var r,a,s,o,l,u=this.hls,d=e.data,c=Wt(e,i),h=Rt.parseMasterPlaylist(d,c);h.playlistParsingError?this.handleManifestParsingError(e,i,h.playlistParsingError,n,t):({contentSteering:e,levels:i,sessionData:r,sessionKeys:a,startTimeOffset:s,variableList:o}=h,{AUDIO:d=[],SUBTITLES:h,"CLOSED-CAPTIONS":l}=(this.variableList=o,Rt.parseMasterPlaylistMedia(d,c,h)),d.length&&!d.some(e=>!e.url)&&i[0].audioCodec&&!i[0].attrs.AUDIO&&(V.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),d.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new be({}),bitrate:0,url:""})),u.trigger(Z.MANIFEST_LOADED,{levels:i,audioTracks:d,subtitles:h,captions:l,contentSteering:e,url:c,stats:t,networkDetails:n,sessionData:r,sessionKeys:a,startTimeOffset:s,variableList:o}))}handleTrackOrLevelPlaylist(e,t,i,n,r){var a=this.hls,{id:s,level:o,type:l}=i,u=Wt(e,i),s=B(s)?s:0,o=B(o)?o:s,d=Ht(i),o=Rt.parseLevelPlaylist(e.data,u,o,d,s,this.variableList);l===zt&&(d={attrs:new be({}),bitrate:0,details:o,name:"",url:u},a.trigger(Z.MANIFEST_LOADED,{levels:[d],audioTracks:[],url:u,stats:t,networkDetails:n,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})),t.parsing.end=performance.now(),i.levelDetails=o,this.handlePlaylistLoaded(o,e,t,i,n,r)}handleManifestParsingError(e,t,i,n,r){this.hls.trigger(Z.ERROR,{type:j.NETWORK_ERROR,details:G.MANIFEST_PARSING_ERROR,fatal:t.type===zt,url:e.url,err:i,error:i,reason:i.message,response:e,context:t,networkDetails:n,stats:r})}handleNetworkError(e,t,i=!1,n,r){let a=`A network ${i?"timeout":"error"+(n?" (status "+n.code+")":"")} occurred while loading `+e.type;e.type===Zt?a+=`: ${e.level} id: `+e.id:e.type!==jt&&e.type!==Gt||(a+=` id: ${e.id} group-id: "${e.groupId}"`);var s=new Error(a);V.warn("[playlist-loader]: "+a);let o=G.UNKNOWN,l=!1;var u=this.getInternalLoader(e);switch(e.type){case zt:o=i?G.MANIFEST_LOAD_TIMEOUT:G.MANIFEST_LOAD_ERROR,l=!0;break;case Zt:o=i?G.LEVEL_LOAD_TIMEOUT:G.LEVEL_LOAD_ERROR,l=!1;break;case jt:o=i?G.AUDIO_TRACK_LOAD_TIMEOUT:G.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case Gt:o=i?G.SUBTITLE_TRACK_LOAD_TIMEOUT:G.SUBTITLE_LOAD_ERROR,l=!1}u&&this.resetInternalLoader(e.type);u={type:j.NETWORK_ERROR,details:o,fatal:l,url:e.url,loader:u,context:e,error:s,networkDetails:t,stats:r};n&&(s=(null==t?void 0:t.url)||e.url,u.response=le({url:s,data:void 0},n)),this.hls.trigger(Z.ERROR,u)}handlePlaylistLoaded(e,t,i,n,r,a){var s=this.hls,{type:o,level:l,id:u,groupId:d,deliveryDirectives:c}=n,h=Wt(t,n),f=Ht(n),p="number"==typeof n.level&&f===y?l:void 0;if(e.fragments.length){e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));var l=e.playlistParsingError;if(l)s.trigger(Z.ERROR,{type:j.NETWORK_ERROR,details:G.LEVEL_PARSING_ERROR,fatal:!1,url:h,error:l,reason:l.message,response:t,context:n,level:p,parent:f,networkDetails:r,stats:i});else switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),o){case zt:case Zt:s.trigger(Z.LEVEL_LOADED,{details:e,level:p||0,id:u||0,stats:i,networkDetails:r,deliveryDirectives:c});break;case jt:s.trigger(Z.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:d||"",stats:i,networkDetails:r,deliveryDirectives:c});break;case Gt:s.trigger(Z.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:d||"",stats:i,networkDetails:r,deliveryDirectives:c})}}else l=new Error("No Segments found in Playlist"),s.trigger(Z.ERROR,{type:j.NETWORK_ERROR,details:G.LEVEL_EMPTY_ERROR,fatal:!1,url:h,error:l,reason:l.message,response:t,context:n,level:p,parent:f,networkDetails:r,stats:i})}}function Qt(e,t){let i;try{i=new Event("addtrack")}catch(e){(i=document.createEvent("Event")).initEvent("addtrack",!1,!1)}i.track=e,t.dispatchEvent(i)}function qt(t,i){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(i.id))try{if(t.addCue(i),!t.cues.getCueById(i.id))throw new Error("addCue is failed for: "+i)}catch(e){V.debug("[texttrack-utils]: "+e);try{var n=new self.TextTrackCue(i.startTime,i.endTime,i.text);n.id=i.id,t.addCue(n)}catch(e){V.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+e)}}"disabled"===e&&(t.mode=e)}function Xt(t){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(let e=t.cues.length;e--;)t.removeCue(t.cues[e]);"disabled"===e&&(t.mode=e)}function Jt(t,e,i,n){var r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&0e[i].endTime)return-1;let n=0,r=i;for(;n<=r;){var a=Math.floor((r+n)/2);if(te[a].startTime&&n=n&&o.endTime<=r)a.push(o);else if(o.startTime>r)return a}return a}(t.cues,e,i);for(let e=0;e{var e=ii();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function ai(e,t){return e.getTime()/1e3-t}class si{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){var e=this["hls"];e.on(Z.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Z.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Z.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Z.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(Z.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Z.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){var e=this["hls"];e.off(Z.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Z.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Z.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Z.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(Z.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Z.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(Xt(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){e=this.getID3Track(e.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;eri?ri:t)-l<=0&&(t=l+.25);for(let e=0;ee.type===$t&&o:"video"===n?e=>e.type===ti&&s:e=>e.type===$t&&o||e.type===ti&&s)}}}onLevelUpdated(e,{details:t}){if(this.media&&t.hasProgramDateTime&&this.hls.config.enableDateRangeMetadataCues){const{dateRangeCuesAppended:f,id3Track:p}=this,g=t["dateRanges"],v=Object.keys(g);if(p){var i=Object.keys(f).filter(e=>!v.includes(e));for(let e=i.length;e--;){const m=i[e];Object.keys(f[m].cues).forEach(e=>{p.removeCue(f[m].cues[e])}),delete f[m]}}t=t.fragments[t.fragments.length-1];if(0!==v.length&&B(null==t?void 0:t.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));var n=t.programDateTime/1e3-t.start,r=ii();for(let e=0;e{var i=g[t];return i.class===y.class&&i.id!==t&&i.startDate>y.startDate&&e.push(i),e},[]).sort((e,t)=>e.startDate.getTime()-t.startDate.getTime())[0])&&(i=ai(u.startDate,n),t=!0),Object.keys(y.attr));for(let e=0;ethis.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){var{config:e,levelDetails:t}=this;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){var e=this["levelDetails"];if(null===e)return null;var{holdBack:e,partHoldBack:t,targetduration:i}=e,{liveSyncDuration:n,liveSyncDurationCount:r,lowLatencyMode:a}=this.config,s=this.hls.userConfig;let o=a&&t||e;return(o=s.liveSyncDuration||s.liveSyncDurationCount||0===o?void 0!==n?n:r*i:o)+Math.min(+this.stallCount,i)}get liveSyncPosition(){var e,t=this.estimateLiveEdge(),i=this.targetLatency,n=this.levelDetails;return null===t||null===i||null===n?null:(e=n.edge,t=t-i-this.edgeStalled,i=e-n.totalduration,e=e-(this.config.lowLatencyMode&&n.partTarget||n.targetduration),Math.min(Math.max(i,t),e))}get drift(){var e=this["levelDetails"];return null===e?1:e.drift}get edgeStalled(){var e,t=this["levelDetails"];return null===t?0:(e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration),Math.max(t.age-e,0))}get forwardBufferLength(){var e,{media:t,levelDetails:i}=this;return t&&i?((e=t.buffered.length)?t.buffered.end(e-1):i.edge)-this.currentTime:0}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(Z.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Z.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(Z.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Z.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(Z.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(Z.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Z.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(Z.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Z.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(Z.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){(this.levelDetails=t).advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){t.details===G.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(t=this.levelDetails))&&t.live&&V.warn("[playback-rate-controller]: Stall detected, adjusting target latency")}timeupdate(){var e,t,i,{media:n,levelDetails:r}=this;n&&r&&(this.currentTime=n.currentTime,null!==(t=this.computeLatency()))&&(this._latency=t,{lowLatencyMode:i,maxLiveSyncPlaybackRate:e}=this.config,i)&&1!==e&&null!==(i=this.targetLatency)&&(t=t-i,i=Math.min(this.maxLatency,i+r.targetduration),r.live&&te).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(e){e%=this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}get audioGroupId(){var e;return null==(e=this.audioGroupIds)?void 0:e[this.urlId]}get textGroupId(){var e;return null==(e=this.textGroupIds)?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}}function pi(i,n){var r=n.startPTS;if(B(r)){let e=0,t;(t=n.sn>i.sn?(e=r-i.start,i):(e=i.start-r,n)).duration!==e&&(t.duration=e)}else n.sn>i.sn?i.cc===n.cc&&i.minEndPTS?n.start=i.start+(i.minEndPTS-i.start):n.start=i.start+i.duration:n.start=Math.max(i.start-n.duration,0)}function gi(e,t,i,n,r,a){n-i<=0&&(V.warn("Fragment should have a positive duration",t),n=i+t.duration,a=r+t.duration);let s=i,o=n;var l=t.startPTS,u=t.endPTS,d=(B(l)&&(d=Math.abs(l-i),B(t.deltaPTS)?t.deltaPTS=Math.max(d,t.deltaPTS):t.deltaPTS=d,s=Math.max(i,l),i=Math.min(i,l),r=Math.min(r,t.startDTS),o=Math.min(n,u),n=Math.max(n,u),a=Math.max(a,t.endDTS)),i-t.start),l=(0!==t.start&&(t.start=i),t.duration=n-t.start,t.startPTS=i,t.maxStartPTS=s,t.startDTS=r,t.endPTS=n,t.minEndPTS=o,t.endDTS=a,t.sn);if(!e||le.endSN)return 0;let c;var u=l-e.startSN,h=e.fragments;for(h[u]=t,c=u;0{e.relurl&&(a=e.cc-t.cc),B(e.startPTS)&&B(e.endPTS)&&(t.start=t.startPTS=e.startPTS,t.startDTS=e.startDTS,t.maxStartPTS=e.maxStartPTS,t.endPTS=e.endPTS,t.endDTS=e.endDTS,t.minEndPTS=e.minEndPTS,t.duration=e.endPTS-e.startPTS,t.duration&&(s=t),i.PTSKnown=i.alignedSliding=!0),t.elementaryStreams=e.elementaryStreams,t.loader=e.loader,t.stats=e.stats,t.urlId=e.urlId,e.initSegment&&(t.initSegment=e.initSegment,n=e.initSegment)},d=l.skippedSegments,c=Math.max(o.startSN,l.startSN)-l.startSN,h=(o.fragmentHint?1:0)+(d?l.endSN:Math.min(o.endSN,l.endSN))-l.startSN,f=l.startSN-o.startSN,p=l.fragmentHint?l.fragments.concat(l.fragmentHint):l.fragments,g=o.fragmentHint?o.fragments.concat(o.fragmentHint):o.fragments;for(let t=c;t<=h;t++){var v=g[f+t];let e=p[t];d&&!e&&t{var t;e.initSegment&&e.initSegment.relurl!==(null==(t=n)?void 0:t.relurl)||(e.initSegment=n)}),i.skippedSegments)if(i.deltaUpdateFailed=i.fragments.some(e=>!e),i.deltaUpdateFailed){V.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=i.skippedSegments;e--;)i.fragments.shift();i.startSN=i.fragments[0].sn,i.startCC=i.fragments[0].cc}else i.canSkipDateRanges&&(i.dateRanges=function(e,i,t){const n=ue({},e);t&&t.forEach(e=>{delete n[e]});return Object.keys(i).forEach(e=>{var t=new Ee(i[e].attr,n[e]);t.isValid?n[e]=t:V.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(i[e].attr)}"`)}),n}(e.dateRanges,i.dateRanges,i.recentlyRemovedDateranges));var m=i.fragments;if(a){V.warn("discontinuity sliding from playlist, take drift into account");for(let e=0;e{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats};if(y&&b){let i=0;for(let e=0,t=y.length;e<=t;e++){var S=y[e],T=b[e+i];S&&T&&S.index===T.index&&S.fragment.sn===T.fragment.sn?E(S,T):i--}}s?gi(i,s,s.startPTS,s.endPTS,s.startDTS,s.endDTS):mi(e,i),m.length&&(i.totalduration=i.edge-m[0].start),i.driftStartTime=e.driftStartTime,i.driftStart=e.driftStart;o=i.advancedDateTime;i.advanced&&o?(c=i.edge,i.driftStart||(i.driftStartTime=o,i.driftStart=c),i.driftEndTime=o,i.driftEnd=c):(i.driftEndTime=e.driftEndTime,i.driftEnd=e.driftEnd,i.advancedDateTime=e.advancedDateTime)}function mi(e,t){var i=t.startSN+t.skippedSegments-e.startSN,e=e.fragments;i<0||i>=e.length||yi(t,e[i].start)}function yi(t,i){if(i){var n=t.fragments;for(let e=t.skippedSegments;ee?0:(t=Math.min(t,i.duration+(i.deltaPTS||0)),i.start+i.duration-t<=e?1:i.start-t>e&&i.start?-1:0)}var _i=0,xi=2,Ci=5,Ri=0,Pi=1,Ni=2;class Oi{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=V.log.bind(V,t+":"),this.warn=V.warn.bind(V,t+":"),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(n,r){var a=null==r?void 0:r.renditionReports;if(a){let i=-1;for(let e=0;er.partTarget&&(e+=1),new hi(o,0<=e?e:void 0,ui)}}}loadPlaylist(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)}playlistLoaded(e,r,a){var{details:s,stats:o}=r,l=self.performance.now(),u=o.loading.first?Math.max(0,l-o.loading.first):0;if(s.advancedDateTime=Date.now()-u,s.live||null!=a&&a.live){if(s.reloaded(a),a&&this.log(`live playlist ${e} `+(s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED")),a&&0a.tuneInGoal?(this.warn(`CDN Tune-in goal increased from: ${a.tuneInGoal} to: ${e} with playlist age: `+s.age),e=0):(c=Math.floor(e/s.targetduration),i+=c,void 0!==n&&(h=Math.round(e%s.targetduration/s.partTarget),n+=h),this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${d.toFixed(2)}s goal: ${e} skip sn ${c} to part `+n)),s.tuneInGoal=e),t=this.getDeliveryDirectives(s,r.deliveryDirectives,i,n),u||!f)return void this.loadPlaylist(t)}else(s.canBlockReload||s.canSkipUntil)&&(t=this.getDeliveryDirectives(s,r.deliveryDirectives,i,n));a=this.hls.mainForwardBufferInfo,h=a?a.end-a.len:0,d=function(e,t){let i=1e3*e.targetduration;return e.updated?(e=e.fragments).length&&4*i>t&&(t=1e3*e[e.length-1].duration)this.requestScheduled+d&&(this.requestScheduled=o.loading.start),void 0!==i&&s.canBlockReload?this.requestScheduled=o.loading.first+d-(1e3*s.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+dthis.loadPlaylist(t),c)}}else this.clearTimer()}getDeliveryDirectives(e,t,i,n){let r=function(e,t){var{canSkipUntil:e,canSkipDateRanges:i,endSN:n}=e;return e&&(void 0!==t?t-n:0)=s.maxNumRetry)return!1;i&&null!=(i=e.context)&&i.deliveryDirectives?(this.warn(`Retrying playlist loading ${a+1}/${s.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist()):(i=wi(s,a),this.timer=self.setTimeout(()=>this.loadPlaylist(),i),this.warn(`Retrying playlist loading ${a+1}/${s.maxNumRetry} after "${t}" in ${i}ms`)),e.levelRetry=!0,n.resolved=!0}return r}}let Bi;class Fi extends Oi{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){var e=this["hls"];e.on(Z.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Z.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Z.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Z.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Z.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(Z.FRAG_LOADED,this.onFragLoaded,this),e.on(Z.ERROR,this.onError,this)}_unregisterListeners(){var e=this["hls"];e.off(Z.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Z.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Z.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Z.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Z.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(Z.FRAG_LOADED,this.onFragLoaded,this),e.off(Z.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const o=[],l={};let u;t.levels.forEach(e=>{var t=e.attrs,{AUDIO:i,CODECS:t,"FRAME-RATE":n,"PATHWAY-ID":r,RESOLUTION:a,SUBTITLES:s}=(-1!==(null==(i=e.audioCodec)?void 0:i.indexOf("mp4a.40.34"))&&(Bi=Bi||/chrome|firefox/i.test(navigator.userAgent))&&(e.audioCodec=void 0),t),r=`${r||"."}-`+e.bitrate+`-${a}-${n}-`+t;(u=l[r])?u.addFallback(e):(u=new fi(e),l[r]=u,o.push(u)),Ui(u,"audio",i),Ui(u,"text",s)}),this.filterAndSortMediaOptions(o,t)}filterAndSortMediaOptions(e,i){let n=[],r=[],a=!1,s=!1,o=!1,l=e.filter(({audioCodec:e,videoCodec:t,width:i,height:n,unknownCodecs:r})=>(a=a||!(!i||!n),s=s||!!t,o=o||!!e,!(null!=r&&r.length)&&(!e||It(e,"audio"))&&(!t||It(t,"video"))));if(0===(l=(a||s)&&o?l.filter(({videoCodec:e,width:t,height:i})=>!!e||!(!t||!i)):l).length)Promise.resolve().then(()=>{var e;this.hls&&(e=new Error("no level with compatible codecs found in manifest"),this.hls.trigger(Z.ERROR,{type:j.MEDIA_ERROR,details:G.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:i.url,error:e,reason:e.message}))});else{i.audioTracks&&zi(n=i.audioTracks.filter(e=>!e.audioCodec||It(e.audioCodec,"audio"))),i.subtitles&&zi(r=i.subtitles);var u=l.slice(0);l.sort((e,t)=>e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"]?(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1:e.bitrate!==t.bitrate?e.bitrate-t.bitrate:e.attrs["FRAME-RATE"]!==t.attrs["FRAME-RATE"]?e.attrs.decimalFloatingPoint("FRAME-RATE")-t.attrs.decimalFloatingPoint("FRAME-RATE"):e.attrs.SCORE!==t.attrs.SCORE?e.attrs.decimalFloatingPoint("SCORE")-t.attrs.decimalFloatingPoint("SCORE"):a&&e.height!==t.height?e.height-t.height:0);let t=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==u.length)for(let e=0;e!!e.url)};this.hls.trigger(Z.MANIFEST_PARSED,e),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(e){var t=this._levels;if(0!==t.length){if(e<0||e>=t.length){var i=new Error("invalid level idx"),n=e<0;if(this.hls.trigger(Z.ERROR,{type:j.OTHER_ERROR,details:G.LEVEL_SWITCH_ERROR,level:e,fatal:n,error:i,reason:i.message}),n)return;e=Math.min(e,t.length-1)}var i=this.currentLevelIndex,n=this.currentLevel,r=n?n.attrs["PATHWAY-ID"]:void 0,t=t[e],a=t.attrs["PATHWAY-ID"];this.currentLevelIndex=e,this.currentLevel=t,i===e&&t.details&&n&&r===a||(this.log(`Switching to level ${e}${a?" with Pathway "+a:""} from level `+i+(r?" with Pathway "+r:"")),delete(a=ue({},t,{level:e,maxBitrate:t.maxBitrate,attrs:t.attrs,uri:t.uri,urlId:t.urlId}))._attrs,delete a._urlId,this.hls.trigger(Z.LEVEL_SWITCHING,a),(i=t.details)&&!i.live)||(r=this.switchParams(t.uri,null==n?void 0:n.details),this.loadPlaylist(r))}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){var e;return void 0===this._startLevel?void 0!==(e=this.hls.config.startLevel)?e:this._firstLevel:this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){!t.fatal&&t.context&&t.context.type===Zt&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){void 0!==t&&t.type===y&&void 0!==(t=this._levels[t.level])&&(t.loadError=0)}onLevelLoaded(e,t){var{level:i,details:n}=t,r=this._levels[i];r?i===this.currentLevelIndex?(0===r.fragmentError&&(r.loadError=0),this.playlistLoaded(i,t,r.details)):null!=(r=t.deliveryDirectives)&&r.skip&&(n.deltaUpdateFailed=!0):(this.warn("Invalid level index "+i),null!=(r=t.deliveryDirectives)&&r.skip&&(n.deltaUpdateFailed=!0))}onAudioTrackSwitched(e,t){var i=this.currentLevel;if(i){var n=this.hls.audioTracks[t.id].groupId;if(i.audioGroupIds&&i.audioGroupId!==n){let t=-1;for(let e=0;et!==n;var e=this._levels.filter((e,t)=>!(t===i&&(1{e=e.details;null!=e&&e.fragments&&e.fragments.forEach(e=>{e.level=t})}),this._levels=t}}function Ui(e,t,i){i&&("audio"===t?(e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds[e.url.length-1]=i):"text"===t&&(e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds[e.url.length-1]=i))}function zi(e){const i={};e.forEach(e=>{var t=e.groupId||"";e.id=i[t]=i[t]||0,i[t]++})}var Zi="NOT_LOADED",ji="APPENDING",Gi="PARTIAL",Vi="OK";class Yi{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){var e=this["hls"];e.on(Z.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Z.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Z.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){var e=this["hls"];e.off(Z.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Z.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Z.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){var i=this.activePartLists[e];if(i)for(let e=i.length;e--;){var n=i[e];if(!n)break;var r=n.end;if(n.start<=t&&null!==r&&t<=r)return n}return this.getBufferedFrag(t,e)}getBufferedFrag(t,i){var n=this["fragments"],r=Object.keys(n);for(let e=r.length;e--;){var a=n[r[e]];if((null==a?void 0:a.body.type)===i&&a.buffered){a=a.body;if(a.start<=t&&t<=a.end)return a}}return null}detectEvictedFragments(i,n,r,e){this.timeRanges&&(this.timeRanges[i]=n);const a=(null==e?void 0:e.fragment.sn)||-1;Object.keys(this.fragments).forEach(e=>{const t=this.fragments[e];!t||a>=t.body.sn||(t.buffered||t.loaded?(e=t.range[i])&&e.time.some(e=>{e=!this.isTimeBuffered(e.startPTS,e.endPTS,n);return e&&this.removeFragment(t.body),e}):t.body.type===r&&this.removeFragment(t.body))})}detectPartialFragments(e){const n=this.timeRanges,{frag:r,part:a}=e;if(n&&"initSegment"!==r.sn){e=Wi(r);const s=this.fragments[e];if(!(!s||s.buffered&&r.gap)){const o=!r.relurl;Object.keys(n).forEach(e=>{var t,i=r.elementaryStreams[e];i&&(t=n[e],i=o||!0===i.partial,s.range[e]=this.getBufferedTimes(r,a,i,t))}),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,(s.body.endList=r.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),Hi(s)||this.removeParts(r.sn-1,r.type)):this.removeFragment(s.body)}}}removeParts(t,e){var i=this.activePartLists[e];i&&(this.activePartLists[e]=i.filter(e=>e.fragment.sn>=t))}fragBuffered(e,t){var i=Wi(e);let n=this.fragments[i];!n&&t&&(n=this.fragments[i]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap)&&(this.hasGaps=!0),n&&(n.loaded=null,n.buffered=!0)}getBufferedTimes(e,t,i,n){var r={time:[],partial:i},a=e.start,s=e.end,o=e.minEndPTS||s,l=e.maxStartPTS||a;for(let e=0;e{e=l[e];e&&Hi(e)&&(r=e.body.start-o,a=e.body.end+o,t>=r)&&t<=a&&(n=Math.min(t-r,a-t),s<=n)&&(i=e.body,s=n)}),i}isEndListAppended(e){e=this.endListFragments[e];return void 0!==e&&(e.buffered||Hi(e))}getState(e){e=Wi(e),e=this.fragments[e];return e?e.buffered?Hi(e)?Gi:Vi:ji:Zi}isTimeBuffered(t,i,n){var r,a;for(let e=0;e{var t=r[e];this.detectEvictedFragments(e,t,a,n)})}}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){e=Wi(e);return!!this.fragments[e]}hasParts(e){return!(null==(e=this.activePartLists[e])||!e.length)}removeFragmentsInRange(i,n,r,a,s){a&&!this.hasGaps||Object.keys(this.fragments).forEach(e=>{var t,e=this.fragments[e];!e||(t=e.body).type!==r||a&&!t.gap||t.starti&&(e.buffered||s)&&this.removeFragment(t)})}removeFragment(e){var t=Wi(e),i=(e.stats.loaded=0,e.clearElementaryStreamInfo(),this.activePartLists[e.type]);if(i){const n=e.sn;this.activePartLists[e.type]=i.filter(e=>e.fragment.sn!==n)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Hi(e){var t;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(t=e.range.audio)?void 0:t.partial)||(null==(t=e.range.audiovideo)?void 0:t.partial))}function Wi(e){return`${e.type}_${e.level}_${e.urlId}_`+e.sn}const Ki=Math.pow(2,17);class Qi{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(o,l){const u=o.url;if(!u)return Promise.reject(new Ji({type:j.NETWORK_ERROR,details:G.FRAG_LOAD_ERROR,fatal:!1,frag:o,error:new Error("Fragment does not have a "+(u?"part list":"url")),networkDetails:null}));this.abort();const i=this.config,d=i.fLoader,c=i.loader;return new Promise((a,r)=>{if(this.loader&&this.loader.destroy(),o.gap){if(o.tagList.some(e=>"GAP"===e[0]))return void r(Xi(o));o.gap=!1}const s=this.loader=o.loader=new(d||c)(i);var e=qi(o),t=Mi(i.fragLoadPolicy.default);const n={loadPolicy:t,timeout:t.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===o.sn?1/0:Ki};o.stats=s.stats,s.load(e,n,{onSuccess:(e,t,i,n)=>{this.resetLoader(o,s);let r=e.data;i.resetIV&&o.decryptdata&&(o.decryptdata.iv=new Uint8Array(r.slice(0,16)),r=r.slice(16)),a({frag:o,part:null,payload:r,networkDetails:n})},onError:(e,t,i,n)=>{this.resetLoader(o,s),r(new Ji({type:j.NETWORK_ERROR,details:G.FRAG_LOAD_ERROR,fatal:!1,frag:o,response:le({url:u,data:void 0},e),error:new Error(`HTTP Error ${e.code} `+e.text),networkDetails:i,stats:n}))},onAbort:(e,t,i)=>{this.resetLoader(o,s),r(new Ji({type:j.NETWORK_ERROR,details:G.INTERNAL_ABORTED,fatal:!1,frag:o,error:new Error("Aborted"),networkDetails:i,stats:e}))},onTimeout:(e,t,i)=>{this.resetLoader(o,s),r(new Ji({type:j.NETWORK_ERROR,details:G.FRAG_LOAD_TIMEOUT,fatal:!1,frag:o,error:new Error(`Timeout after ${n.timeout}ms`),networkDetails:i,stats:e}))},onProgress:(e,t,i,n)=>{l&&l({frag:o,part:null,payload:i,networkDetails:n})}})})}loadPart(l,u,d){this.abort();const t=this.config,i=t.fLoader,c=t.loader;return new Promise((r,a)=>{if(this.loader&&this.loader.destroy(),l.gap||u.gap)a(Xi(l,u));else{const s=this.loader=l.loader=new(i||c)(t),o=qi(l,u);var e=Mi(t.fragLoadPolicy.default);const n={loadPolicy:e,timeout:e.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Ki};u.stats=s.stats,s.load(o,n,{onSuccess:(e,t,i,n)=>{this.resetLoader(l,s),this.updateStatsFromPart(l,u);e={frag:l,part:u,payload:e.data,networkDetails:n};d(e),r(e)},onError:(e,t,i,n)=>{this.resetLoader(l,s),a(new Ji({type:j.NETWORK_ERROR,details:G.FRAG_LOAD_ERROR,fatal:!1,frag:l,part:u,response:le({url:o.url,data:void 0},e),error:new Error(`HTTP Error ${e.code} `+e.text),networkDetails:i,stats:n}))},onAbort:(e,t,i)=>{l.stats.aborted=u.stats.aborted,this.resetLoader(l,s),a(new Ji({type:j.NETWORK_ERROR,details:G.INTERNAL_ABORTED,fatal:!1,frag:l,part:u,error:new Error("Aborted"),networkDetails:i,stats:e}))},onTimeout:(e,t,i)=>{this.resetLoader(l,s),a(new Ji({type:j.NETWORK_ERROR,details:G.FRAG_LOAD_TIMEOUT,fatal:!1,frag:l,part:u,error:new Error(`Timeout after ${n.timeout}ms`),networkDetails:i,stats:e}))}})}})}updateStatsFromPart(e,t){var i=e.stats,n=t.stats,r=n.total,e=(i.loaded+=n.loaded,r?(r=((e=Math.round(e.duration/t.duration))-(t=Math.min(Math.round(i.loaded/r),e)))*Math.round(i.loaded/t),i.total=i.loaded+r):i.total=Math.max(i.loaded,i.total),i.loading),t=n.loading;e.start?e.first+=t.first-t.start:(e.start=t.start,e.first=t.first),e.end=t.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function qi(i,n=null){var r=n||i,n={frag:i,part:n,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},a=r.byteRangeStartOffset,r=r.byteRangeEndOffset;if(B(a)&&B(r)){let e=a,t=r;"initSegment"===i.sn&&"AES-128"===(null==(i=i.decryptdata)?void 0:i.method)&&((i=r-a)%16&&(t=r+(16-i%16)),0!==a)&&(n.resetIV=!0,e=a-16),n.rangeStart=e,n.rangeEnd=t}return n}function Xi(e,t){var i=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:j.MEDIA_ERROR,details:G.FRAG_GAP,fatal:!1,frag:e,error:i,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new Ji(i)}class Ji extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class $i{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const i in this.keyUriToKeyInfo){var t=this.keyUriToKeyInfo[i].loader;if(t){if(e&&e!==t.context.frag.type)return;t.abort()}}}detach(){for(const t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=G.KEY_LOAD_ERROR,i,n,r){return new Ji({type:j.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:r,error:i,networkDetails:n})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){var{sn:i,cc:n}=e;for(let e=0;e{r.setKeyFormat(e)});break}}}}load(t){return!t.decryptdata&&t.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(t).then(e=>this.loadInternal(t,e)):this.loadInternal(t)}loadInternal(t,e){e&&t.setKeyFormat(e);const i=t.decryptdata;if(!i)return e=new Error(e?"Expected frag.decryptdata to be defined after setting format "+e:"Missing decryption data on fragment in onKeyLoading"),Promise.reject(this.createKeyLoadError(t,G.KEY_LOAD_ERROR,e));var n,e=i.uri;if(!e)return Promise.reject(this.createKeyLoadError(t,G.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${e}"`)));let r=this.keyUriToKeyInfo[e];if(null!=(n=r)&&n.decryptdata.key)return i.key=r.decryptdata.key,Promise.resolve({frag:t,keyInfo:r});if(null!=(n=r)&&n.keyLoadPromise)switch(null==(n=r.mediaKeySessionContext)?void 0:n.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return r.keyLoadPromise.then(e=>(i.key=e.keyInfo.decryptdata.key,{frag:t,keyInfo:r}))}switch(r=this.keyUriToKeyInfo[e]={decryptdata:i,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},i.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===i.keyFormat?this.loadKeyHTTP(r,t):this.loadKeyEME(r,t);case"AES-128":return this.loadKeyHTTP(r,t);default:return Promise.reject(this.createKeyLoadError(t,G.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${i.method}"`)))}}loadKeyEME(t,e){const i={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){e=this.emeController.loadKey(i);if(e)return(t.keyLoadPromise=e.then(e=>(t.mediaKeySessionContext=e,i))).catch(e=>{throw t.keyLoadPromise=null,e})}return Promise.resolve(i)}loadKeyHTTP(i,a){const n=this.config;const l=new n.loader(n);return a.keyLoader=i.loader=l,i.keyLoadPromise=new Promise((s,o)=>{const r={keyInfo:i,frag:a,responseType:"arraybuffer",url:i.decryptdata.uri};var e=n.keyLoadPolicy.default,e={loadPolicy:e,timeout:e.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},t={onSuccess:(e,t,i,n)=>{var{frag:i,keyInfo:r,url:a}=i;if(!i.decryptdata||r!==this.keyUriToKeyInfo[a])return o(this.createKeyLoadError(i,G.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),n));r.decryptdata.key=i.decryptdata.key=new Uint8Array(e.data),i.keyLoader=null,r.loader=null,s({frag:i,keyInfo:r})},onError:(e,t,i,n)=>{this.resetLoader(t),o(this.createKeyLoadError(a,G.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key `+e.text),i,le({url:r.url,data:void 0},e)))},onTimeout:(e,t,i)=>{this.resetLoader(t),o(this.createKeyLoadError(a,G.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,t,i)=>{this.resetLoader(t),o(this.createKeyLoadError(a,G.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};l.load(r,e,t)})}resetLoader(e){var{frag:e,keyInfo:t,url:i}=e,n=t.loader;e.keyLoader===n&&(e.keyLoader=null,t.loader=null),delete this.keyUriToKeyInfo[i],n&&n.destroy()}}const en={length:0,start:()=>0,end:()=>0};class b{static isBuffered(e,t){try{if(e){var i=b.getBuffered(e);for(let e=0;e=i.start(e)&&t<=i.end(e))return!0}}catch(e){}return!1}static bufferInfo(t,i,n){try{if(t){var r=b.getBuffered(t),a=[];let e;for(e=0;ea&&(r[s-1].end=t[e].end):r.push(t[e])}else r=t;let o=0,l,u=i,d=i;for(let e=0;ei.startCC||e&&e.cc>>8^255&g^99,v=c[t[e[h]=g]=h],m=c[v],y=c[m],b=257*c[g]^16843008*g;n[h]=b<<24|b>>>8,r[h]=b<<16|b>>>16,a[h]=b<<8|b>>>24,s[h]=b,b=16843009*y^65537*m^257*v^16843008*h,o[g]=b<<24|b>>>8,l[g]=b<<16|b>>>16,u[g]=b<<8|b>>>24,d[g]=b,h?(h=v^c[c[c[y^v]]],f^=c[c[f]]):h=f=1}}expandKey(r){var a=this.uint8ArrayToUint32Array_(r);let e=!0,t=0;for(;t{return r?(this.logOnce("WebCrypto AES decrypt"),new un(r,new Uint8Array(n)).decrypt(t.buffer,e)):Promise.reject(new Error("web crypto not initialized"))}).catch(e=>(V.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${e.name}: `+e.message),this.onWebCryptoError(t,i,n)))}onWebCryptoError(e,t,i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,i);e=this.flush();if(e)return e.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;var i=e.length-e.length%16;return i!==e.length&&(t=je(e,0,i),this.remainderData=je(e,i)),t}logOnce(e){this.logEnabled&&(V.log("[decrypter]: "+e),this.logEnabled=!1)}}const fn={toString:function(t){let i="";var n=t.length;for(let e=0;en.end)&&(r=r{this.fragContextChanged(i)?(this.warn(`Fragment ${i.sn}${e.part?" p: "+e.part.index:""} of level ${i.level} was dropped during download.`),this.fragmentTracker.removeFragment(i)):(i.stats.chunkCount++,this._handleFragmentLoadProgress(e))}).then(e=>{var t;e&&(t=this.state,this.fragContextChanged(i)?t!==E.FRAG_LOADING&&(this.fragCurrent||t!==E.PARSING)||(this.fragmentTracker.removeFragment(i),this.state=E.IDLE):("payload"in e&&(this.log(`Loaded fragment ${i.sn} of level `+i.level),this.hls.trigger(Z.FRAG_LOADED,e)),this._handleFragmentLoadComplete(e)))}).catch(e=>{this.state!==E.STOPPED&&this.state!==E.ERROR&&(this.warn(e),this.resetFragmentLoading(i))})}clearTrackerIfNeeded(e){var t,i=this["fragmentTracker"];i.getState(e)===ji?(t=e.type,t=this.getFwdBufferInfo(this.mediaBuffer,t),t=Math.max(e.duration,t?t.len:this.config.maxBufferLength),this.reduceMaxBufferLength(t)&&i.removeFragment(e)):0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?i.removeAllFragments():i.hasParts(e.type)&&(i.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),i.getState(e)===Gi)&&i.removeFragment(e)}checkLiveUpdate(e){var t;e.updated&&!e.live&&(t=e.fragments[e.fragments.length-1],this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})),e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,i=null){e-t&&(e={startOffset:e,endOffset:t,type:i},this.hls.trigger(Z.BUFFER_FLUSHING,e))}_loadInitSegment(a,r){this._doFragLoad(a,r).then(e=>{if(e&&!this.fragContextChanged(a)&&this.levels)return e;throw new Error("init load aborted")}).then(i=>{const n=this["hls"];var e=i["payload"],t=a.decryptdata;if(e&&0{throw n.trigger(Z.ERROR,{type:j.MEDIA_ERROR,details:G.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:a}),e}).then(e=>{var t=self.performance.now();return n.trigger(Z.FRAG_DECRYPTED,{frag:a,payload:e,stats:{tstart:r,tdecrypt:t}}),i.payload=e,i})}return i}).then(e=>{var{fragCurrent:t,hls:i,levels:n}=this;if(!n)throw new Error("init load aborted, missing levels");n=a.stats;this.state=E.IDLE,r.fragmentError=0,a.data=new Uint8Array(e.payload),n.parsing.start=n.buffering.start=self.performance.now(),n.parsing.end=n.buffering.end=self.performance.now(),e.frag===t&&i.trigger(Z.FRAG_BUFFERED,{stats:n,frag:t,part:null,id:a.type}),this.tick()}).catch(e=>{this.state!==E.STOPPED&&this.state!==E.ERROR&&(this.warn(e),this.resetFragmentLoading(a))})}fragContextChanged(e){var t=this["fragCurrent"];return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId}fragBufferedComplete(e,t){var i=this.mediaBuffer||this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===y?"level":"track"} ${e.level} (frag:[${(null!=(t=e.startPTS)?t:NaN).toFixed(3)}-${(null!=(t=e.endPTS)?t:NaN).toFixed(3)}] > buffer:${i?fn.toString(b.getBuffered(i)):"(detached)"})`),this.state=E.IDLE,i&&(!this.loadedmetadata&&e.type==y&&i.buffered.length&&(null==(t=this.fragCurrent)?void 0:t.sn)===(null==(e=this.fragPrevious)?void 0:e.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){var t,i,n=this["transmuxer"];n&&({frag:e,part:t,partsLoaded:i}=e,i=!i||0===i.length||i.some(e=>!e),e=new tn(e.level,e.sn,e.stats.chunkCount+1,0,t?t.index:-1,!i),n.flush(e))}_handleFragmentLoadProgress(e){}_doFragLoad(t,i,n=null,r){var a=null==i?void 0:i.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let s=null;if(!t.encrypted||null!=(o=t.decryptdata)&&o.key?!t.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(t,a.encryptedFragments):(this.log(`Loading key for ${t.sn} of [${a.startSN}-${a.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} `+t.level),this.state=E.KEY_LOADING,this.fragCurrent=t,s=this.keyLoader.load(t).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(Z.KEY_LOADED,e),this.state===E.KEY_LOADING&&(this.state=E.IDLE),e}),this.hls.trigger(Z.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(s=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),n=Math.max(t.start,n||0),this.config.lowLatencyMode&&"initSegment"!==t.sn){var o=a.partList;if(o&&r){n>t.end&&a.fragmentHint&&(t=a.fragmentHint);var l=this.getNextPart(o,t,n);if(-1!e||this.fragContextChanged(e.frag)?null:this.doFragPartsLoad(t,d,i,r)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(t,d,i,r).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(Z.FRAG_LOADING,{frag:t,part:d,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):e}if(!t.url||this.loadedEndOfParts(o,n))return Promise.resolve(null)}}this.log(`Loading fragment ${t.sn} cc: ${t.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${t.level}, target: `+parseFloat(n.toFixed(3))),B(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=E.FRAG_LOADING;const u=this.config.progressive;let e;return e=u&&s?s.then(e=>!e||this.fragContextChanged(null==e?void 0:e.frag)?null:this.fragmentLoader.load(t,r)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(t,u?r:void 0),s]).then(([e])=>(!u&&e&&r&&r(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(Z.FRAG_LOADING,{frag:t,targetBufferTime:n}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):e}doFragPartsLoad(o,i,l,u){return new Promise((n,e)=>{var t;const r=[],a=null==(t=l.details)?void 0:t.partList,s=i=>{this.fragmentLoader.loadPart(o,i,u).then(e=>{var t=(r[i.index]=e).part,e=(this.hls.trigger(Z.FRAG_LOADED,e),bi(l,o.sn,i.index+1)||Ei(a,o.sn,i.index+1));if(!e)return n({frag:o,part:t,partsLoaded:r});s(e)}).catch(e)};s(i)})}handleFragLoadError(e){var t;return"data"in e?(t=e.data,e.data&&t.details===G.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(Z.ERROR,t)):this.hls.trigger(Z.ERROR,{type:j.OTHER_ERROR,details:G.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0}),null}_handleTransmuxerFlush(e){var t,i,n,r=this.getCurrentContext(e);r&&this.state===E.PARSING?({frag:r,part:t,level:i}=r,n=self.performance.now(),r.stats.parsing.end=n,t&&(t.stats.parsing.end=n),this.updateLevelTiming(r,t,i,e.partial)):this.fragCurrent||this.state===E.STOPPED||this.state===E.ERROR||(this.state=E.IDLE)}getCurrentContext(e){var t,i,n,r,{levels:a,fragCurrent:s}=this,{level:e,sn:o,part:l}=e;return null!=a&&a[e]?(a=a[e],(r=(l=-1i&&this.flushMainBuffer(n,e.start)):this.flushMainBuffer(0,e.start))}getFwdBufferInfo(e,t){var i=this.getLoadPosition();return B(i)?this.getFwdBufferInfoAtPos(e,i,t):null}getFwdBufferInfoAtPos(e,t,i){var n=this["config"]["maxBufferHole"],r=b.bufferInfo(e,t,n);if(0===r.len&&void 0!==r.nextStart){i=this.fragmentTracker.getBufferedFrag(t,i);if(i&&r.nextStart=e&&(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0)}getAppendedFrag(e,t=0){e=this.fragmentTracker.getAppendedFrag(e,y);return e&&"fragment"in e?e.fragment:e}getNextFragment(e,t){var i=t.fragments,n=i.length;if(!n)return null;var r=this["config"],a=i[0].start;let s;if(t.live){var o=r.initialLiveManifestSize;if(nt}getNextFragmentLoopLoading(e,t,i,n,r){var a=e.gap,t=this.getNextFragment(this.nextLoadPosition,t);if(null===t)return t;if(e=t,a&&e&&!e.gap&&i.nextStart){t=this.getFwdBufferInfoAtPos(this.mediaBuffer||this.media,i.nextStart,n);if(null!==t&&i.len+t.len>=r)return this.log(`buffer full after gaps in "${n}" playlist starting at sn: `+e.sn),null}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(i,n,r){let a=-1,s=!1,o=!0;for(let e=0,t=i.length;ee.start&&e.loaded}getInitialLiveFragment(e,t){var i,n,r=this.fragPrevious;let a=null;return r?(e.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),a=Ii(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),a||((i=r.sn+1)>=e.startSN&&i<=e.endSN&&(i=t[i-e.startSN],r.cc===i.cc)&&(a=i,this.log("Live playlist, switching playlist, load frag with next SN: "+a.sn)),a)||(a=(i=t,n=r.cc,Li.search(i,e=>e.ccn?-1:0)))&&this.log("Live playlist, switching playlist, load frag with same CC: "+a.sn)):null!==(t=this.hls.liveSyncPosition)&&(a=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e)),a}getFragmentAtPosition(e,t,i){var n=this["config"];let r=this["fragPrevious"],{fragments:a,endSN:s}=i;var o=i["fragmentHint"],l=n.maxFragLookUpTolerance,u=i.partList,n=!!(n.lowLatencyMode&&null!=u&&u.length&&o);n&&o&&!this.bitrateTest&&(a=a.concat(o),s=o.sn);let d;return(d=ed.sn)&&r&&d.level===r.level&&(e=a[1+o],d=d.sn=r-a.maxFragLookUpTolerance&&i<=n,null!==t)&&s.duration>t&&(i${e.startSN} prev-sn: ${o?o.sn:"na"} fragments: `+s),r):i):(this.warn("No fragments in live playlist"),0)}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let i=this.startPosition;var n,r;-1!==(i=i `+(null==(i=this.fragCurrent)?void 0:i.url)):((i=t.details===G.FRAG_GAP)&&this.fragmentTracker.fragBuffered(o,!0),{action:s,retryCount:r=0,retryConfig:a}=(n=t.errorAction)||{},n&&s===Ci&&a?(this.resetStartWhenNotLoaded(null!=(s=this.levelLastLoaded)?s:o.level),s=wi(a,r),this.warn(`Fragment ${o.sn} of ${e} ${o.level} errored with ${t.details}, retrying loading ${r+1}/${a.maxNumRetry} in ${s}ms`),n.resolved=!0,this.retryDate=self.performance.now()+s,this.state=E.FRAG_LOADING_WAITING_RETRY):a&&n?(this.resetFragmentErrors(e),r{var i,n=r.elementaryStreams[t];return n?(i=n.endPTS-n.startPTS)<=0?(this.warn(`Could not parse fragment ${r.sn} ${t} duration reliably (${i})`),e||!1):(i=s?0:gi(o,r,n.startPTS,n.endPTS,n.startDTS,n.endDTS),this.hls.trigger(Z.LEVEL_PTS_UPDATED,{details:o,level:a,drift:i,type:t,frag:r,start:n.startPTS,end:n.endPTS}),!0):e},!1))a.fragmentError=0;else if(null===(null==(t=this.transmuxer)?void 0:t.error)){var t=new Error(`Found no media in fragment ${r.sn} of level ${r.level} resetting transmuxer to fallback to playlist timing`);if(0===a.fragmentError&&(a.fragmentError++,r.gap=!0,this.fragmentTracker.removeFragment(r),this.fragmentTracker.fragBuffered(r,!0)),this.warn(t.message),this.hls.trigger(Z.ERROR,{type:j.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:r,reason:`Found no media in msn ${r.sn} of level "${a.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=E.PARSED,this.hls.trigger(Z.FRAG_PARSED,{frag:r,part:e})}else this.warn("level.details undefined")}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(e=null!=(e=this.levelLastLoaded)?e:null==(e=this.fragCurrent)?void 0:e.level)?e:0),this.resetLoadingState())}set state(e){var t=this._state;t!==e&&(this._state=e,this.log(t+"->"+e))}get state(){return this._state}}function gn(){return self.SourceBuffer||self.WebKitSourceBuffer}function vn(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class mn{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,i,n){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,i){}demux(e,t){this.cachedData&&(e=ht(this.cachedData,e),this.cachedData=null);let i=Ye(e,0),n=i?i.length:0,r;var a,s,o=this._audioTrack,l=this._id3Track,u=i?We(i):void 0,d=e.length;for((null===this.basePTS||0===this.frameIndex&&B(u))&&(this.basePTS=yn(u,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),i&&0{return B(e)?90*e:9e4*t+(i?9e4*i.baseTime/i.timescale:0)};function bn(e,t){return 255===e[t]&&240==(246&e[t+1])}function En(e,t){return 1&e[t+1]?7:9}function Sn(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function Tn(e,t){return t+1>>6),(60&t[i+2])>>>2);if(!(d.length-1>>6,V.log(`manifest codec:${n}, ADTS type:${r}, samplingIndex:`+c),a=/firefox/i.test(l)?6<=c?(r=5,o=new Array(4),c-3):(r=2,o=new Array(2),c):-1!==l.indexOf("android")?(r=2,o=new Array(2),c):(r=5,o=new Array(4),n&&(-1!==n.indexOf("mp4a.40.29")||-1!==n.indexOf("mp4a.40.5"))||!n&&6<=c?c-3:((n&&-1!==n.indexOf("mp4a.40.2")&&(6<=c&&1==s||/vivaldi/i.test(l))||!n&&1==s)&&(r=2,o=new Array(2)),c)),o[0]=r<<3,o[0]|=(14&c)>>1,o[1]|=(1&c)<<7,o[1]|=s<<3,5===r&&(o[1]|=(14&a)>>1,o[2]=(1&a)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:d[c],channelCount:s,codec:"mp4a.40."+r,manifestCodec:u};e.trigger(Z.ERROR,{type:j.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+c})}(t,i,n,r))&&(e.config=t.config,e.samplerate=t.samplerate,e.channelCount=t.channelCount,e.codec=t.codec,e.manifestCodec=t.manifestCodec,V.log(`parsed codec:${e.codec}, rate:${t.samplerate}, channels:`+t.channelCount))}function Mn(e){return 9216e4/e}function An(e,t,i,n,r){var a,s,n=n+r*Mn(e.samplerate),r=function(e,t){var i=En(e,t);if(t+i<=e.length){e=Sn(e,t)-i;if(0t.length)&&(a=Rn(t,i))&&i+a.frameLength<=t.length?(n=n+r*(9e4*a.samplesPerFrame/a.sampleRate),r={unit:t.subarray(i,i+a.frameLength),pts:n,dts:n},e.config=[],e.channelCount=a.channelCount,e.samplerate=a.sampleRate,e.samples.push(r),{sample:r,length:a.frameLength,missing:0}):void 0}function Rn(e,t){var i,n,r,a,s,o=e[t+1]>>3&3,l=e[t+1]>>1&3,u=e[t+2]>>4&15,d=e[t+2]>>2&3;if(1!=o&&0!=u&&15!=u&&3!=d)return s=e[t+2]>>1&1,i=e[t+3]>>6,n=3==o?3-l:3==l?3:4,n=1e3*Dn[14*n+u-1],u=3==o?0:2==o?1:2,u=kn[3*u+d],d=3==i?1:2,a=8*(o=_n[o][l])*(r=xn[l]),o=Math.floor(o*n/u+s)*r,null===In&&(s=(navigator.userAgent||"").match(/Chrome\/(\d+)/i),In=s?parseInt(s[1]):0),!!In&&In<=87&&2==l&&224e3<=n&&0==i&&(e[t+3]=128|e[t+3]),{sampleRate:u,channelCount:d,frameLength:o,samplesPerFrame:a}}function Pn(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function Nn(e,t){return t+1e||(e=(e-=this.bitsAvailable)-((t=e>>3)<<3),this.bytesAvailable-=t,this.loadWord()),this.word<<=e,this.bitsAvailable-=e}readBits(e){var t=Math.min(this.bitsAvailable,e),i=this.word>>>32-t;if(32>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){var e=this.skipLZ();return this.readBits(e+1)-1}readEG(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(t){let i=8,n=8;var r;for(let e=0;e{e=new Uint8Array(e);r.set(e,16),this.decrypter.isSync()||this.decryptAacSamples(t,i+1,n)}))}decryptAacSamples(e,t,i){for(;;t++){if(t>=e.length)return void i();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,i),!this.decrypter.isSync()))return}}getAvcEncryptedData(t){var e=16*Math.floor((t.length-48)/160)+16,i=new Int8Array(e);let n=0;for(let e=32;e{a.data=this.getAvcDecryptedUnit(s,e),this.decrypter.isSync()||this.decryptAvcSamples(t,i,n+1,r)})}decryptAvcSamples(e,t,i,n){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,i=0){if(t>=e.length)return void n();for(var r=e[t].units;!(i>=r.length);i++){var a=r[i];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(e,t,i,n,a),this.decrypter.isSync())))return}}}}const Fn=188;class Un{constructor(e,t,i){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=i}static probe(e){e=Un.syncOffset(e);return 0s))return i}o++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:rt[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,i,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=Un.createTrack("video"),this._audioTrack=Un.createTrack("audio",n),this._id3Track=Un.createTrack("id3"),this._txtTrack=Un.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=i,this._duration=n}resetTimeStamp(){}resetContiguity(){var{_audioTrack:e,_avcTrack:t,_id3Track:i}=this;e&&(e.pesData=null),t&&(t.pesData=null),i&&(i.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(i,e,n=!1,t=!1){n||(this.sampleAes=null);let r;var a=this._avcTrack,s=this._audioTrack,o=this._id3Track,l=this._txtTrack;let u=a.pid,d=a.pesData,c=s.pid,h=o.pid,f=s.pesData,p=o.pesData,g=null,v=this.pmtParsed,m=this._pmtId,y=i.length;if(this.remainderData&&(i=ht(this.remainderData,i),y=i.length,this.remainderData=null),y>4){if((e=t+5+i[t+4])===t+Fn)continue}else e=t+4;switch(w){case u:T&&(d&&(r=jn(d))&&this.parseAVCPES(a,l,r,!1),d={data:[],size:0}),d&&(d.data.push(i.subarray(e,t+Fn)),d.size+=t+Fn-e);break;case c:if(T){if(f&&(r=jn(f)))switch(s.segmentCodec){case"aac":this.parseAACPES(s,r);break;case"mp3":this.parseMPEGPES(s,r)}f={data:[],size:0}}f&&(f.data.push(i.subarray(e,t+Fn)),f.size+=t+Fn-e);break;case h:T&&(p&&(r=jn(p))&&this.parseID3PES(o,r),p={data:[],size:0}),p&&(p.data.push(i.subarray(e,t+Fn)),p.size+=t+Fn-e);break;case 0:T&&(e+=i[e]+1),m=this._pmtId=(M=i,b=e,(31&M[b+10])<<8|M[b+11]);break;case m:T&&(e+=i[e]+1);var M=function(e,t,i,n){var r={audio:-1,avc:-1,id3:-1,segmentCodec:"aac"},a=(15&e[t+1])<<8|e[t+2],s=t+3+a-4,a=(15&e[t+10])<<8|e[t+11];t+=12+a;for(;t{const{audioTrack:t,videoTrack:i}=n;t.samples&&"aac"===t.segmentCodec?r.decryptAacSamples(t.samples,0,()=>{i.samples?r.decryptAvcSamples(i.samples,0,0,()=>{e(n)}):e(n)}):i.samples&&r.decryptAvcSamples(i.samples,0,0,()=>{e(n)})})}destroy(){this._duration=0}parseAVCPES(a,i,s,e){var t=this.parseAVCNALu(a,s.data);let o=this.avcSample,l,u=!1;s.data=null,o&&t.length&&!a.audFound&&(Gn(o,a),o=this.avcSample=zn(!1,s.pts,s.dts,"")),t.forEach(t=>{switch(t.type){case 1:{let e=!1;l=!0;var n=t.data;u&&4e.size-6)return null;var l=r[7];192&l&&(a=536870912*(14&r[9])+4194304*(255&r[10])+16384*(254&r[11])+128*(255&r[12])+(254&r[13])/2,64&l?(s=536870912*(14&r[14])+4194304*(255&r[15])+16384*(254&r[16])+128*(255&r[17])+(254&r[18])/2,54e5e){i-=e;continue}r=r.subarray(i),e-=i,i=0}u.set(r,n),n+=e}return t&&(t-=l+3),{data:u,pts:a,dts:s,len:t}}}function Gn(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var i=t.samples,n=i.length;if(!n)return void t.dropped++;i=i[n-1];e.pts=i.pts,e.dts=i.dts}t.samples.push(e)}e.debug.length&&V.log(e.pts+"/"+e.dts+":"+e.debug)}class Vn{static getSilentFrame(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)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(6===t)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])}else{if(1===t)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(2===t)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(3===t)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])}}}const Yn=Math.pow(2,32)-1;class Y{static init(){Y.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]};let e;for(e in Y.types)Y.types.hasOwnProperty(e)&&(Y.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);var t=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]),i=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]),t=(Y.HDLR_TYPES={video:t,audio:i},new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1])),i=new Uint8Array([0,0,0,0,0,0,0,0]),i=(Y.STTS=Y.STSC=Y.STCO=i,Y.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Y.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Y.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),Y.STSD=new Uint8Array([0,0,0,0,0,0,0,1]),new Uint8Array([105,115,111,109])),n=new Uint8Array([97,118,99,49]),r=new Uint8Array([0,0,0,1]);Y.FTYP=Y.box(Y.types.ftyp,i,r,i,n),Y.DINF=Y.box(Y.types.dinf,Y.box(Y.types.dref,t))}static box(e,...t){let i=8,n=t.length;for(var r=n;n--;)i+=t[n].byteLength;var a=new Uint8Array(i);for(a[0]=i>>24&255,a[1]=i>>16&255,a[2]=i>>8&255,a[3]=255&i,a.set(e,4),n=0,i=8;n>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,t>>24,t>>16&255,t>>8&255,255&t,85,196,0,0]))}static mdia(e){return Y.box(Y.types.mdia,Y.mdhd(e.timescale,e.duration),Y.hdlr(e.type),Y.minf(e))}static mfhd(e){return Y.box(Y.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?Y.box(Y.types.minf,Y.box(Y.types.smhd,Y.SMHD),Y.DINF,Y.stbl(e)):Y.box(Y.types.minf,Y.box(Y.types.vmhd,Y.VMHD),Y.DINF,Y.stbl(e))}static moof(e,t,i){return Y.box(Y.types.moof,Y.mfhd(e),Y.traf(i,t))}static moov(e){let t=e.length;for(var i=[];t--;)i[t]=Y.trak(e[t]);return Y.box.apply(null,[Y.types.moov,Y.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(Y.mvex(e)))}static mvex(e){let t=e.length;for(var i=[];t--;)i[t]=Y.trex(e[t]);return Y.box.apply(null,[Y.types.mvex,...i])}static mvhd(e,t){t*=e;var i=Math.floor(t/(1+Yn)),t=Math.floor(t%(1+Yn)),e=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,t>>24,t>>16&255,t>>8&255,255&t,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 Y.box(Y.types.mvhd,e)}static sdtp(e){var t,i=e.samples||[],n=new Uint8Array(4+i.length);let r;for(r=0;r>>8&255),t.push(255&a),t=t.concat(Array.prototype.slice.call(r));for(n=0;n>>8&255),i.push(255&a),i=i.concat(Array.prototype.slice.call(r));var s=Y.box(Y.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(i))),o=e.width,l=e.height,u=e.pixelRatio[0],d=e.pixelRatio[1];return Y.box(Y.types.avc1,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,o>>8&255,255&o,l>>8&255,255&l,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]),s,Y.box(Y.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Y.box(Y.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,255&u,d>>24,d>>16&255,d>>8&255,255&d])))}static esds(e){var t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static mp4a(e){var t=e.samplerate;return Y.box(Y.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),Y.box(Y.types.esds,Y.esds(e)))}static mp3(e){var t=e.samplerate;return Y.box(Y.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]))}static stsd(e){return"audio"===e.type?"mp3"===e.segmentCodec&&"mp3"===e.codec?Y.box(Y.types.stsd,Y.STSD,Y.mp3(e)):Y.box(Y.types.stsd,Y.STSD,Y.mp4a(e)):Y.box(Y.types.stsd,Y.STSD,Y.avc1(e))}static tkhd(e){var t=e.id,i=e.duration*e.timescale,n=e.width,e=e.height,r=Math.floor(i/(1+Yn)),i=Math.floor(i%(1+Yn));return Y.box(Y.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,0,0,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,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,e>>8&255,255&e,0,0]))}static traf(e,t){var i=Y.sdtp(e),n=e.id,r=Math.floor(t/(1+Yn)),t=Math.floor(t%(1+Yn));return Y.box(Y.types.traf,Y.box(Y.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),Y.box(Y.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,t>>24,t>>16&255,t>>8&255,255&t])),Y.trun(e,i.length+16+20+8+16+8+8),i)}static trak(e){return e.duration=e.duration||4294967295,Y.box(Y.types.trak,Y.tkhd(e),Y.mdia(e))}static trex(e){e=e.id;return Y.box(Y.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){var i,n,r,a,s=e.samples||[],o=s.length,l=12+16*o,u=new Uint8Array(l);let d;for(u.set(["video"===e.type?1:0,0,15,1,o>>>24&255,o>>>16&255,o>>>8&255,255&o,(t+=8+l)>>>24&255,t>>>16&255,t>>>8&255,255&t],0),d=0;d>>24&255,i>>>16&255,i>>>8&255,255&i,n>>>24&255,n>>>16&255,n>>>8&255,255&n,r.isLeading<<2|r.dependsOn,r.isDependedOn<<6|r.hasRedundancy<<4|r.paddingValue<<1|r.isNonSync,61440&r.degradPrio,15&r.degradPrio,a>>>24&255,a>>>16&255,a>>>8&255,255&a],12+16*d);return Y.box(Y.types.trun,u)}static initSegment(e){Y.types||Y.init();var e=Y.moov(e),t=new Uint8Array(Y.FTYP.byteLength+e.byteLength);return t.set(Y.FTYP),t.set(e,Y.FTYP.byteLength),t}}Y.types=void 0,Y.HDLR_TYPES=void 0,Y.STTS=void 0,Y.STSC=void 0,Y.STCO=void 0,Y.STSZ=void 0,Y.VMHD=void 0,Y.SMHD=void 0,Y.STSD=void 0,Y.FTYP=void 0,Y.DINF=void 0;const Hn=9e4;function Wn(e,t,i=1,n=!1){e=e*t*i;return n?Math.round(e):e}function Kn(e,t=!1){return Wn(e,1e3,1/Hn,t)}let Qn=null,qn=null;class Xn{constructor(e,t,i,n=0){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=i,this.ISGenerated=!1,null===Qn&&(e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i),Qn=e?parseInt(e[1]):0),null===qn&&(t=navigator.userAgent.match(/Safari\/(\d+)/i),qn=t?parseInt(t[1]):0)}destroy(){}resetTimeStamp(e){V.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){V.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){V.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let n=!1;e=e.reduce((e,t)=>{var i=t.pts-e;return i<-4294967296?(n=!0,Jn(e,t.pts)):0=a[0].pts)&&(h=u,i=a[0].pts-N,a[0].dts=h,a[0].pts=i,V.log(`Video: First PTS/DTS adjusted: ${Kn(i,!0)}/${Kn(h,!0)}, delta: ${Kn(N,!0)} ms`)),h=Math.max(0,h);let b=0,E=0;for(let e=0;e0<=e.pts)).length)return;g=0===n?0:t&&!h?Math.max(0,v):f[0].pts}if("aac"===r.segmentCodec){var y=this.config.maxAudioFramesDrift;for(let i=0,n=g;ie.pts-t.pts);var e=t.samples;return t.samples=[],{samples:e}}}class tr{constructor(e,t,i,n){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=i,this.cts=n,this.flags=new ir(e)}}class ir{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}}function nr(e,t){e=null==e?void 0:e.codec;return e&&4{t=function(e){var t=e[0];let i="",n="",r=0,a=0,s=0,o=0,l=0,u=0;if(0===t){for(;"\0"!==at(e.subarray(u,u+1));)i+=at(e.subarray(u,u+1)),u+=1;for(i+=at(e.subarray(u,u+1)),u+=1;"\0"!==at(e.subarray(u,u+1));)n+=at(e.subarray(u,u+1)),u+=1;n+=at(e.subarray(u,u+1)),u+=1,r=L(e,12),a=L(e,16),o=L(e,20),l=L(e,24),u=28}else if(1===t){u+=4,r=L(e,u);var t=L(e,u+=4),d=L(e,u+=4);for(u+=4,s=2**32*t+d,de(s)||(s=Number.MAX_SAFE_INTEGER,V.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=L(e,u),u+=4,l=L(e,u),u+=4;"\0"!==at(e.subarray(u,u+1));)i+=at(e.subarray(u,u+1)),u+=1;for(i+=at(e.subarray(u,u+1)),u+=1;"\0"!==at(e.subarray(u,u+1));)n+=at(e.subarray(u,u+1)),u+=1;n+=at(e.subarray(u,u+1)),u+=1}return t=e.subarray(u,e.byteLength),{schemeIdUri:i,value:n,timeScale:r,presentationTime:s,presentationTimeDelta:a,eventDuration:o,id:l,payload:t}}(t);if(Ln.test(t.schemeIdUri)){var i=B(t.presentationTime)?t.presentationTime/t.timeScale:n+t.presentationTimeDelta/t.timeScale;let e=4294967295===t.eventDuration?Number.POSITIVE_INFINITY:t.eventDuration/t.timeScale;e<=.001&&(e=Number.POSITIVE_INFINITY);t=t.payload;r.samples.push({data:t,len:t.byteLength,dts:i,pts:i,type:ti,duration:e})}}),r}demuxSampleAes(e,t,i){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},remux:class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,i,n){this.audioCodec=t,this.videoCodec=i,this.generateInitSegment(function(e,t){if(e&&t){const n=t.keyId;n&&t.isCommonEncryption&&I(e,["moov","trak"]).forEach(e=>{e=I(e,["mdia","minf","stbl","stsd"])[0].subarray(8);let t=I(e,["enca"]);const i=0{I(i?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{var t,e=dt(e);e&&!(t=e.subarray(8,24)).some(e=>0!==e)&&(V.log(`[eme] Patching keyId in 'enc${i?"a":"v"}>sinf>>tenc' box: ${tt.hexDump(t)} -> `+tt.hexDump(n)),e.set(n,8))})})})}return e}(e,n)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:i}=this;var n,r;null!=e&&e.byteLength?(n=this.initData=ut(e),t=t||nr(n.audio,Te),i=i||nr(n.video,we),r={},n.audio&&n.video?r.audiovideo={container:"video/mp4",codec:t+","+i,initSegment:e,id:"main"}:n.audio?r.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:n.video?r.video={container:"video/mp4",codec:i,initSegment:e,id:"main"}:V.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=r):(this.initTracks=void 0,this.initData=void 0)}remux(i,n,r,a,s,o){let{initPTS:l,lastEndTime:u}=this;var d={audio:void 0,video:void 0,text:a,id3:r,initSegment:void 0},n=(B(u)||(u=this.lastEndTime=s||0),n.samples);if(null!=n&&n.length){var c={initPTS:void 0,timescale:1};let t=this.initData;if(null!=(g=t)&&g.length||(this.generateInitSegment(n),t=this.initData),null!=(g=t)&&g.length){this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var h,f,p,g=ct(n,t),v=(h=t,I(n,["moof","traf"]).reduce((e,t)=>{const n=I(t,["tfdt"])[0],r=n[0];t=I(t,["tfhd"]).reduce((t,i)=>{i=L(i,4),i=h[i];if(i){let e=L(n,4);if(1===r){if(e===it)return V.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;e=(e*=1+it)+L(n,8)}i=i.timescale||9e4,i=e/i;if(B(i)&&(null===t||in}(l,v,s,g)||c.timescale!==l.timescale&&o)&&(c.initPTS=v-s,l&&1===l.timescale&&V.warn("Adjusting initPTS by "+(c.initPTS-l.baseTime)),this.initPTS=l={baseTime:c.initPTS,timescale:1}),i?v-l.baseTime/l.timescale:u),i=o+g,v=(f=t,p=l.baseTime/l.timescale,I(n,["moof","traf"]).forEach(t=>{I(t,["tfhd"]).forEach(e=>{e=L(e,4),e=f[e];if(e){const r=e.timescale||9e4;I(t,["tfdt"]).forEach(e=>{var t,i=e[0];let n=L(e,4);0===i?(n-=p*r,lt(e,4,n=Math.max(n,0))):(n=(n=(n*=Math.pow(2,32))+L(e,8))-p*r,n=Math.max(n,0),i=Math.floor(n/(1+it)),t=Math.floor(n%(1+it)),lt(e,4,i),lt(e,8,t))})}})}),0=i.length?void 0:!((r=Sn(i,n))<=a)&&((a=n+r)===i.length||Tn(i,a)))return V.log("ADTS sync word found !"),!0}return!1}canParse(e,t){return(t=t)+5<(e=e).length&&bn(e,t)&&Sn(e,t)<=e.length-t}appendFrame(e,t,i){wn(e,this.observer,t,i,e.manifestCodec);e=An(e,t,i,this.basePTS,this.frameIndex);if(e&&0===e.missing)return e}},remux:Xn},{demux:class extends mn{resetInitSegment(e,t,i,n){super.resetInitSegment(e,t,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:n,inputTimeScale:9e4,dropped:0}}static probe(t){if(t){let e=(Ye(t,0)||[]).length;for(var i=t.length;e{e=this.push(e,null,i);return this.decryptionPromise=null,e}),this.decryptionPromise;{let e=v.softwareDecrypt(a,g.key.buffer,g.iv.buffer);var m=-1this.flush(t));const a=[];var r=n["timeOffset"],{demuxer:i,remuxer:n}=(i&&(n=i.flush())&&a.push(this.push(n,null,t)),this);return i&&n?lr(n=i.flush(r))?n.then(e=>(this.flushRemux(a,e,t),a)):(this.flushRemux(a,n,t),a):(e.executeEnd=rr(),[or(t)])}flushRemux(e,t,i){var{audioTrack:t,videoTrack:n,id3Track:r,textTrack:a}=t,{accurateTimeOffset:s,timeOffset:o}=this.currentTransmuxState,t=(V.log(`[transmuxer.ts]: Flushed fragment ${i.sn}${-1{return{remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,i,n,!1,this.id),chunkMeta:r}})}configureTransmuxer(i){var{config:e,observer:t,typeSupported:n,vendor:r}=this;let a;for(let e=0,t=ar.length;e({remuxResult:{},chunkMeta:e});function lr(e){return"then"in e&&e.then instanceof Function}class ur{constructor(e,t,i,n,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=i,this.duration=n,this.defaultInitPts=r||null}}class dr{constructor(e,t,i,n,r,a){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=i,this.trackSwitch=n,this.timeOffset=r,this.initSegmentChange=a}}var cr,hr,e={exports:{}};function fr(){}function pr(e,t,i){this.fn=e,this.context=t,this.once=i||!1}function gr(e,t,i,n,r){if("function"!=typeof i)throw new TypeError("The listener must be a function");i=new pr(i,n||e,r),n=hr?hr+t:t;return e._events[n]?e._events[n].fn?e._events[n]=[e._events[n],i]:e._events[n].push(i):(e._events[n]=i,e._eventsCount++),e}function vr(e,t){0==--e._eventsCount?e._events=new fr:delete e._events[t]}function mr(){this._events=new fr,this._eventsCount=0}i=e,cr=Object.prototype.hasOwnProperty,hr="~",Object.create&&(fr.prototype=Object.create(null),(new fr).__proto__||(hr=!1)),mr.prototype.eventNames=function(){var e,t,i=[];if(0===this._eventsCount)return i;for(t in e=this._events)cr.call(e,t)&&i.push(hr?t.slice(1):t);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},mr.prototype.listeners=function(e){var e=hr?hr+e:e,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var i=0,n=t.length,r=new Array(n);i!1};class Er{constructor(e,t,i,n){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const r=e.config;this.hls=e,this.id=t,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=i,this.onFlush=n;var a,s,e=(e,t)=>{(t=t||{}).frag=this.frag,t.id=this.id,e===Z.ERROR&&(this.error=t.error),this.hls.trigger(e,t)},i=(this.observer=new yr,this.observer.on(Z.FRAG_DECRYPTED,e),this.observer.on(Z.ERROR,e),{mp4:br.isTypeSupported("video/mp4"),mpeg:br.isTypeSupported("audio/mpeg"),mp3:br.isTypeSupported('audio/mp4; codecs="mp3"')}),n=navigator.vendor;if(this.useWorker&&"undefined"!=typeof Worker&&(r.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__)){try{r.workerPath?(V.log(`loading Web Worker ${r.workerPath} for "${t}"`),this.workerContext=(s=r.workerPath,s=new self.URL(s,self.location.href).href,{worker:new self.Worker(s),scriptURL:s})):(V.log(`injecting Web Worker for "${t}"`),this.workerContext=(a=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),a=self.URL.createObjectURL(a),{worker:new self.Worker(a),objectURL:a})),this.onwmsg=e=>this.onWorkerMessage(e);var o=this.workerContext["worker"];o.addEventListener("message",this.onwmsg),o.onerror=e=>{e=new Error(`${e.message} (${e.filename}:${e.lineno})`);r.enableWorker=!1,V.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(Z.ERROR,{type:j.OTHER_ERROR,details:G.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:e})},o.postMessage({cmd:"init",typeSupported:i,vendor:n,id:t,config:JSON.stringify(r)})}catch(e){V.warn(`Error setting up "${t}" Web Worker, fallback to inline`,e),this.resetWorker(),this.error=null,this.transmuxer=new sr(this.observer,i,r,n,t)}return}this.transmuxer=new sr(this.observer,i,r,n,t)}resetWorker(){var e,t;this.workerContext&&({worker:e,objectURL:t}=this.workerContext,t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null)}destroy(){this.workerContext?(this.resetWorker(),this.onwmsg=void 0):(e=this.transmuxer)&&(e.destroy(),this.transmuxer=null);var e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,i,n,r,a,s,o,l,u){var d=(l.transmuxing.start=self.performance.now(),this)["transmuxer"],c=(a||r).start,h=r.decryptdata,f=this.frag,p=!(f&&r.cc===f.cc),g=!(f&&l.level===f.level),v=f?l.sn-f.sn:-1,m=this.part?l.part-this.part.index:-1,y=0==v&&1{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,l,"transmuxer-interface push error")})):(d.async=!1,this.handleTransmuxComplete(m)))}flush(t){t.transmuxing.start=self.performance.now();var i=this["transmuxer"];if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(i){let e=i.flush(t);lr(e)||i.async?(e=lr(e)?e:Promise.resolve(e)).then(e=>{this.handleFlushResult(e,t)}).catch(e=>{this.transmuxerError(e,t,"transmuxer-interface flush error")}):this.handleFlushResult(e,t)}}transmuxerError(e,t,i){this.hls&&(this.error=e,this.hls.trigger(Z.ERROR,{type:j.MEDIA_ERROR,details:G.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:i}))}handleFlushResult(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}onWorkerMessage(e){var t=e.data,i=this.hls;switch(t.event){case"init":var n=null==(n=this.workerContext)?void 0:n.objectURL;n&&self.URL.revokeObjectURL(n);break;case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":V[t.data.logType]&&V[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,i.trigger(t.event,t.data)}}configureTransmuxer(e){var t=this["transmuxer"];this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}class Sr{constructor(e,t,i,n){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=i,this.hls=n}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){var{config:i,media:n,stalled:r}=this;if(null!==n){var{currentTime:a,seeking:s}=n,o=this.seeking&&!s,l=!this.seeking&&s;if(this.seeking=s,a!==e)this.moved=!0,null!==r&&(this.stallReported&&(e=self.performance.now()-r,V.warn(`playback not stuck anymore @${a}, after ${Math.round(e)}ms`),this.stallReported=!1),this.stalled=null,this.nudgeRetry=0);else if(l||o)this.stalled=null;else if(!(n.paused&&!s||n.ended||0===n.playbackRate)&&b.getBuffered(n).length){e=b.bufferInfo(n,a,0),l=0i.maxBufferHole||e.nextStart&&e.nextStart-r1e3*i.highBufferWatchdogPeriod&&(V.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}}_reportStall(e){var{hls:t,media:i,stallReported:n}=this;!n&&i&&(this.stallReported=!0,n=new Error(`Playback stalling at @${i.currentTime} due to low buffer (${JSON.stringify(e)})`),V.warn(n.message),t.trigger(Z.ERROR,{type:j.MEDIA_ERROR,details:G.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len}))}_trySkipBufferHole(t){var{config:e,hls:i,media:n}=this;if(null!==n){var r=n.currentTime,a=b.bufferInfo(n,r,0),s=re.maxBufferHole){var u=this["fragmentTracker"];let e=!1;if(!(e=0===r&&(o=u.getAppendedFrag(0,y))&&sr.end&&(this.backtrackFragment=null);var o,s=this.backtrackFragment?this.backtrackFragment.start:r.end;let e=this.getNextFragment(s,a);this.couldBacktrack&&!this.fragPrevious&&e&&"initSegment"!==e.sn&&this.fragmentTracker.getState(e)!==Vi?(n=(null!=(n=this.backtrackFragment)?n:e).sn-a.startSN,(n=a.fragments[n-1])&&e.cc===n.cc&&(e=n,this.fragmentTracker.removeFragment(n))):this.backtrackFragment&&r.len&&(this.backtrackFragment=null),e&&this.isLoopLoading(e,s)&&(e.gap||(o=((n=this.audioOnly&&!this.altAudio?Te:we)===we?this.videoBuffer:this.mediaBuffer)||this.media)&&this.afterBufferFlushed(o,n,y),e=this.getNextFragmentLoopLoading(e,a,r,y,t)),e&&(!e.initSegment||e.initSegment.data||this.bitrateTest||(e=e.initSegment),this.loadFragment(e,i,s))}}}}}}loadFragment(e,t,i){var n=this.fragmentTracker.getState(e);this.fragCurrent=e,n===Zi||n===Gi?"initSegment"===e.sn?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,i)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,y)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){var{levels:t,media:i}=this;if(null!=i&&i.readyState){let e;var n=this.getAppendedFrag(i.currentTime),n=(n&&1{(r=e.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(i=!0),-1!==r.indexOf("mp4a.40.5"))&&(n=!0)}),this.audioCodecSwitch=i&&n&&!("function"==typeof(null==(a=gn())||null==(a=a.prototype)?void 0:a.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){var i=this["levels"];i&&this.state===E.IDLE&&(!(i=i[t.level]).details||i.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(i.details))&&(this.state=E.WAITING_LEVEL)}onLevelLoaded(e,t){var i=this["levels"],n=t.level,r=t.details,a=r.totalduration;if(i){this.log(`Level ${n} loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""}, cc [${r.startCC}, ${r.endCC}] duration:`+a);a=i[n],i=this.fragCurrent;!i||this.state!==E.FRAG_LOADING&&this.state!==E.FRAG_LOADING_WAITING_RETRY||i.level===t.level&&i.urlId===a.urlId||!i.loader||this.abortCurrentFrag();let e=0;if(r.live||null!=(t=a.details)&&t.live){if(this.checkLiveUpdate(r),r.deltaUpdateFailed)return;e=this.alignPlaylists(r,a.details)}if(a.details=r,this.levelLastLoaded=n,this.hls.trigger(Z.LEVEL_UPDATED,{details:r,level:n}),this.state===E.WAITING_LEVEL){if(this.waitForCdnTuneIn(r))return;this.state=E.IDLE}this.startFragRequested?r.live&&this.synchronizeToLiveEdge(r):this.setStartPosition(r,e),this.tick()}else this.warn("Levels were reset while loading level "+n)}_handleFragmentLoadProgress(e){var t,i,n,r,a,s,o,{frag:e,part:l,payload:u}=e,d=this["levels"];d?(t=(d=d[e.level]).details)?(i=d.videoCodec,n=t.PTSKnown||!t.live,r=null==(r=e.initSegment)?void 0:r.data,d=this._getAudioCodec(d),a=this.transmuxer=this.transmuxer||new Er(this.hls,y,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),o=-1!==(s=l?l.index:-1),s=new tn(e.level,e.sn,e.stats.chunkCount,u.byteLength,s,o),o=this.initPTS[e.cc],a.push(u,r,d,i,e,l,t.totalduration,n,s,o)):(this.warn(`Dropping fragment ${e.sn} of level ${e.level} after level details were reset`),this.fragmentTracker.removeFragment(e)):this.warn(`Levels were reset while fragment load was in progress. Fragment ${e.sn} of level ${e.level} will not be buffered`)}onAudioTrackSwitching(e,t){var i,n=this.altAudio;!t.url&&(this.mediaBuffer!==this.media?(this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media,(i=this.fragCurrent)&&(this.log("Switching to main audio track, cancel main fragment load"),i.abortRequests(),this.fragmentTracker.removeFragment(i)),this.resetTransmuxer(),this.resetLoadingState()):this.audioOnly&&this.resetTransmuxer(),i=this.hls,n&&(i.trigger(Z.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),i.trigger(Z.AUDIO_TRACK_SWITCHED,t))}onAudioTrackSwitched(e,t){var i,t=t.id,t=!!this.hls.audioTracks[t].url;t&&(i=this.videoBuffer)&&this.mediaBuffer!==i&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=i),this.altAudio=t,this.tick()}onBufferCreated(e,t){var i=t.tracks;let n,r,a=!1;for(const o in i){var s=i[o];"main"===s.id?(r=o,n=s,"video"===o&&(s=i[o])&&(this.videoBuffer=s.buffer)):a=!0}a&&n?(this.log(`Alternate track found, use ${r}.buffered to schedule main fragment loading`),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){var i,{frag:t,part:n}=t;t&&t.type!==y||(this.fragContextChanged(t)?(this.warn(`Fragment ${t.sn}${n?" p: "+n.index:""} of level ${t.level} finished buffering, but was aborted. state: `+this.state),this.state===E.PARSED&&(this.state=E.IDLE)):(i=(n||t).stats,this.fragLastKbps=Math.round(8*i.total/(i.buffering.end-i.loading.first)),"initSegment"!==t.sn&&(this.fragPrevious=t),this.fragBufferedComplete(t,n)))}onError(e,t){var i;if(t.fatal)this.state=E.ERROR;else switch(t.details){case G.FRAG_GAP:case G.FRAG_PARSING_ERROR:case G.FRAG_DECRYPT_ERROR:case G.FRAG_LOAD_ERROR:case G.FRAG_LOAD_TIMEOUT:case G.KEY_LOAD_ERROR:case G.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(y,t);break;case G.LEVEL_LOAD_ERROR:case G.LEVEL_LOAD_TIMEOUT:case G.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==E.WAITING_LEVEL||(null==(i=t.context)?void 0:i.type)!==Zt||(this.state=E.IDLE);break;case G.BUFFER_FULL_ERROR:t.parent&&"main"===t.parent&&this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case G.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}checkBuffer(){var e,{media:t,gapController:i}=this;t&&i&&t.readyState&&(!this.loadedmetadata&&b.getBuffered(t).length||(e=this.state!==E.IDLE?this.fragCurrent:null,i.poll(this.lastCurrentTime,e)),this.lastCurrentTime=t.currentTime)}onFragLoadEmergencyAborted(){this.state=E.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){var i;(t!==Te||this.audioOnly&&!this.altAudio)&&(i=(t===we?this.videoBuffer:this.mediaBuffer)||this.media,this.afterBufferFlushed(i,t,y))}onLevelsUpdated(e,t){this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){var t=this["media"];if(t){var i,n=t.currentTime;let e=this.startPosition;0<=e&&n{var t,i=this["hls"];e&&!this.fragContextChanged(n)&&(r.fragmentError=0,this.state=E.IDLE,this.startFragRequested=!1,this.bitrateTest=!1,(t=n.stats).parsing.start=t.parsing.end=t.buffering.start=t.buffering.end=self.performance.now(),i.trigger(Z.FRAG_LOADED,e),n.bitrateTest=!1)})}_handleTransmuxComplete(e){var t="main",i=this["hls"],{remuxResult:e,chunkMeta:n}=e,r=this.getCurrentContext(n);if(r){var{frag:r,part:a,level:s}=r,{video:o,text:l,id3:u,initSegment:d}=e,c=s["details"],h=this.altAudio?void 0:e.audio;if(this.fragContextChanged(r))this.fragmentTracker.removeFragment(r);else{if(this.state=E.PARSING,d&&(null!=d&&d.tracks&&(f=r.initSegment||r,this._bufferInitSegment(s,d.tracks,f,n),i.trigger(Z.FRAG_PARSING_INIT_SEGMENT,{frag:f,id:t,tracks:d.tracks})),s=d.initPTS,f=d.timescale,B(s))&&(this.initPTS[r.cc]={baseTime:s,timescale:f},i.trigger(Z.INIT_PTS_FOUND,{frag:r,id:t,initPTS:s,timescale:f})),o&&c&&"initSegment"!==r.sn){var d=c.fragments[r.sn-1-c.startSN],s=r.sn===c.startSN,f=!d||r.cc>d.cc;if(!1!==e.independent){var{startPTS:d,endPTS:e,startDTS:p,endDTS:g}=o;if(a)a.elementaryStreams[o.type]={startPTS:d,endPTS:e,startDTS:p,endDTS:g};else if(o.firstKeyFrame&&o.independent&&1===n.id&&!f&&(this.couldBacktrack=!0),o.dropped&&o.independent){var v=this.getMainFwdBufferInfo(),v=(v?v.end:this.getLoadPosition())+this.config.maxBufferHole,m=o.firstKeyFramePTS||d;if(!s&&v{var t=i[e].initSegment;null!=t&&t.byteLength&&this.hls.trigger(Z.BUFFER_APPENDING,{type:e,data:t,frag:n,part:null,chunkMeta:r,parent:n.type})}),this.tick()}}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer||this.media,y)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=E.IDLE}checkFragmentChanged(){var e,t=this.media;let i=null;t&&1=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}class Ar{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){var{chunks:e,dataLength:t}=this;let i;return e.length?(i=1===e.length?e[0]:function(t,e){var i=new Uint8Array(e);let n=0;for(let e=0;et[e]!==i[e])}(t[e].attrs,i[e].attrs))return!1;return!0}class Ir{constructor(n){this.buffered=void 0;const t=(e,t,i)=>{if(i-1<(t>>>=0))throw new DOMException(`Failed to execute '${e}' on 'TimeRanges': The index provided (${t}) is greater than the maximum bound (${i})`);return n[t][e]};this.buffered={get length(){return n.length},end(e){return t("end",e,n.length)},start(e){return t("start",e,n.length)}}}}function Dr(t){var i=[];for(let e=0;e{t=e}),n={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(n,e),i}executeNext(t){var{buffers:i,queues:n}=this,i=i[t],n=n[t];if(n.length){var r=n[0];try{r.execute()}catch(e){V.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),r.onError(e),null!=i&&i.updating||(n.shift(),this.executeNext(t))}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const _r=Mt(),xr=/([ha]vc.)(?:\.[^.,]+)+/;function Cr(e){let t=e;return Rr.hasOwnProperty(e)&&(t=Rr[e]),String.fromCharCode(t)}const Rr={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},Pr=100,Nr={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Or={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Br={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Fr={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ur=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class zr{constructor(){this.time=null,this.verboseLevel=0}log(e,t){this.verboseLevel>=e&&(t="function"==typeof t?t():t,V.log(this.time+` [${e}] `+t))}}function Zr(t){var i=[];for(let e=0;ePr&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Pr)}moveCursor(e){var t=this.pos+e;if(1=Pr?this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}clearFromPos(e){let t;for(t=e;t"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){var e;null===this.nrRollUpRows?this.logger.log(3,"roll_up but nrRollUpRows not set yet"):(this.logger.log(1,()=>this.getDisplayText()),e=this.currRow+1-this.nrRollUpRows,(e=this.rows.splice(e,1)[0]).clear(),this.rows.splice(this.currRow,0,e),this.logger.log(2,"Rolling up"))}getDisplayText(t){t=t||!1;var i=[];let e="";var n;for(let e=0;e<15;e++){var r=this.rows[e].getTextString();r&&(n=e+1,i.push(t?"Row "+n+": '"+r+"'":r.trim()))}return e=0"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(t){for(let e=0;ee+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory)&&this.outputDataUpdate()}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){var e;this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode&&(e=this.displayedMemory,this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())),this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){var t={flash:!1};t.underline=e%2==1,t.italics=46<=e,t.italics?t.foreground="white":(e=Math.floor(e/2)-16,t.foreground=["white","green","blue","cyan","red","yellow","magenta"][e]),this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){var t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){!this.outputFilter||this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e)}}class Wr{constructor(e,t,i){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var n=new zr;this.channels=[null,new Hr(e,t,n),new Hr(e+1,i,n)],this.cmdHistory=qr(),this.logger=n}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let i;let n=!1;this.logger.time=e;for(let e=0;e ("+Zr([a,s])+")"),(i=(i=(i=(i=this.parseCmd(a,s))||this.parseMidrow(a,s))||this.parsePAC(a,s))||this.parseBackgroundAttributes(a,s))||(n=this.parseChars(a,s))&&((r=this.currentChannel)&&0e)&&(this.startTime=e),this.endTime=t,this.screen=i,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Jr=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;const b=["","lr","rl"],t=["start","middle","end","left","right"];function E(e,t){return"string"==typeof t&&!!Array.isArray(e)&&(t=t.toLowerCase(),!!~e.indexOf(t))&&t}function S(e){return E(t,e)}function T(e){let t=1;for(;t/gi,"\n")}class sa{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new $r,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const n=this;function i(){var e=n.buffer;let t=0;for(e=aa(e);t>>0).toString()};function da(e,t,i){return ua(e.toString())+ua(t.toString())+ua(i)}function ca(e,o,l,u,d,t,i){const n=new sa;var r,a,e=$e(new Uint8Array(e)).trim().replace(la,"\n").split("\n");const c=[],h=o?([r,a=1]=[o.baseTime,o.timescale],Wn(r,Hn,1/a)):0;let s="00:00.000",f=0,p=0,g,v=!0;n.oncue=function(e){var i=l[u];let t=l.ccOffset;var n,r=(f-h)/9e4;if(null!=i&&i.new)if(void 0!==p)t=l.ccOffset=i.start;else{var a=l;i=u;var s=r;let e=a[i],t=a[e.prevCC];if(!t||!t.new&&e.new)a.ccOffset=a.presentationOffset=e.start,e.new=!1;else{for(;null!=(n=t)&&n.new;)a.ccOffset+=e.start-t.start,e.new=!1,t=a[(e=t).prevCC];a.presentationOffset=s}}if(r){if(!o)return void(g=new Error("Missing initPTS for VTT MPEGTS"));t=r-l.presentationOffset}i=e.endTime-e.startTime,s=Jn(9e4*(e.startTime+t-p),9e4*d)/9e4,e.startTime=Math.max(s,0),e.endTime=Math.max(s+i,0),r=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(r)),e.id||(e.id=da(e.startTime,e.endTime,r)),0{if(v){if(oa(e,"X-TIMESTAMP-MAP=")){v=!1,e.slice(16).split(",").forEach(e=>{oa(e,"LOCAL:")?s=e.slice(6):oa(e,"MPEGTS:")&&(f=parseInt(e.slice(7)))});try{p=function(e){var t=parseInt(e.slice(-3)),i=parseInt(e.slice(-6,-4)),n=parseInt(e.slice(-9,-7)),r=9$e(e));[t,r,a=1,s=!1]=[t.baseTime,1,t.timescale];const o=Wn(t,r,1/a,s);try{e.forEach(e=>i(function(e,a){const t=new DOMParser,i=t.parseFromString(e,"text/xml"),n=i.getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");const r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},s=Object.keys(r).reduce((e,t)=>(e[t]=n.getAttribute("ttp:"+t)||r[t],e),{}),o="preserve"!==n.getAttribute("xml:space"),l=ya(ma(n,"styling","style")),u=ya(ma(n,"layout","region")),d=ma(n,"body","[begin]");return[].map.call(d,e=>{var t=function n(e,r){return[].slice.call(e.childNodes).reduce((e,t,i)=>{return"br"===t.nodeName&&i?e+"\n":null!=(i=t.childNodes)&&i.length?n(t,r):r?e+t.textContent.trim().replace(/\s+/g," "):e+t.textContent},"")}(e,o);if(!t||!e.hasAttribute("begin"))return null;var i=Sa(e.getAttribute("begin"),s),n=Sa(e.getAttribute("dur"),s);let r=Sa(e.getAttribute("end"),s);if(null===i)throw Ea(e);if(null===r){if(null===n)throw Ea(e);r=i+n}n=new Jr(i-a,r-a,t),n.id=da(n.startTime,n.endTime,n.text),i=u[e.getAttribute("region")],t=function(n,r,e){const a="http://www.w3.org/ns/ttml#styling";let s=null;var t=null!=n&&n.hasAttribute("style")?n.getAttribute("style"):null;t&&e.hasOwnProperty(t)&&(s=e[t]);return["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((e,t)=>{var i=ba(r,a,t)||ba(n,a,t)||ba(s,a,t);return i&&(e[t]=i),e},{})}(i,l[e.getAttribute("style")],l),i=t.textAlign;return i&&((e=ga[i])&&(n.lineAlign=e),n.align=i),ue(n,t),n}).filter(e=>null!==e)}(e,o)))}catch(e){n(e)}}}function ma(e,t,i){e=e.getElementsByTagName(t)[0];return e?[].slice.call(e.querySelectorAll(i)):[]}function ya(e){return e.reduce((e,t)=>{var i=t.getAttribute("xml:id");return i&&(e[i]=t),e},{})}function ba(e,t,i){return e&&e.hasAttributeNS(t,i)?e.getAttributeNS(t,i):null}function Ea(e){return new Error("Could not parse ttml timestamp "+e)}function Sa(e,t){if(!e)return null;let i=ea(e);var n,r,a;return null===i&&(fa.test(e)?i=(n=e,r=t,n=fa.exec(n),a=(0|n[4])+(0|n[5])/r.subFrameRate,3600*(0|n[1])+60*(0|n[2])+(0|n[3])+a/r.frameRate):pa.test(e)&&(i=function(e,t){var e=pa.exec(e),i=Number(e[1]),e=e[2];switch(e){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),i}function Ta(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class wa{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){var e=this["hls"];e.on(Z.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(Z.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Z.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Z.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Z.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){var e=this["hls"];e.off(Z.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(Z.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Z.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Z.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Z.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){t=this.hls.levels[t.droppedLevel];this.isLevelAllowed(t)&&this.restrictedLevels.push({bitrate:t.bitrate,height:t.height,width:t.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null}onManifestParsed(e,t){var i=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,i.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){var e,t;this.media&&0this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping)}getMaxLevel(i){var e=this.hls.levels;return e.length?(e=e.filter((e,t)=>this.isLevelAllowed(e)&&t<=i),this.clientRect=null,wa.getMaxLevelByMediaSize(e,this.mediaWidth,this.mediaHeight)):-1}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){var e,t,i;return this.clientRect||(t={width:0,height:0},(e=this.media)&&(i=e.getBoundingClientRect(),t.width=i.width,t.height=i.height,t.width||t.height||(t.width=i.right-i.left||e.width||0,t.height=i.bottom-i.top||e.height||0)),this.clientRect=t)}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}isLevelAllowed(t){return!this.restrictedLevels.some(e=>t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height)}static getMaxLevelByMediaSize(t,i,n){if(null==t||!t.length)return-1;var r;let a=t.length-1;for(let e=0;e=i||s.height>=n)&&(s=s,!(r=t[e+1])||s.width!==r.width||s.height!==r.height)){a=e;break}}return a}}const Ma="[eme]";class Aa{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=Aa.CDMCleanupPromise?[Aa.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=V.debug.bind(V,Ma),this.log=V.log.bind(V,Ma),this.warn=V.warn.bind(V,Ma),this.error=V.error.bind(V,Ma),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();var e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(Z.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Z.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Z.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Z.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(Z.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Z.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Z.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Z.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){var{drmSystems:t,widevineLicenseUrl:i}=this.config,t=t[e];if(t)return t.licenseUrl;if(e===f.WIDEVINE&&i)return i;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){var t=this.config["drmSystems"],t=t[e];if(t)return t.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){var t=this.hls.levels,i=(e,t,i)=>!!e&&i.indexOf(e)===t;const s=t.map(e=>e.audioCodec).filter(i),o=t.map(e=>e.videoCodec).filter(i);return s.length+o.length===0&&o.push("avc1.42e01e"),new Promise((n,r)=>{const a=t=>{const i=t.shift();this.getMediaKeysPromise(i,s,o).then(e=>n({keySystem:i,mediaKeys:e})).catch(e=>{t.length?a(t):e instanceof La?r(e):r(new La({type:j.KEY_SYSTEM_ERROR,details:G.KEY_SYSTEM_NO_ACCESS,error:e,fatal:!0},e.message))})};a(e)})}requestMediaKeySystemAccess(e,t){var i=this.config["requestMediaKeySystemAccessFunc"];if("function"==typeof i)return i(e,t);{let e="Configured requestMediaKeySystemAccess is not a function "+i;return null===Ze&&"http:"===self.location.protocol&&(e="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(e))}}getMediaKeysPromise(n,e,t){e=function(e,t,i,n){let r;switch(e){case f.FAIRPLAY:r=["cenc","sinf"];break;case f.WIDEVINE:case f.PLAYREADY:r=["cenc"];break;case f.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+e)}var a=r,s=n;return[a={initDataTypes:a,persistentState:s.persistentState||"not-allowed",distinctiveIdentifier:s.distinctiveIdentifier||"not-allowed",sessionTypes:s.sessionTypes||[s.sessionType||"temporary"],audioCapabilities:t.map(e=>({contentType:`audio/mp4; codecs="${e}"`,robustness:s.audioRobustness||"",encryptionScheme:s.audioEncryptionScheme||null})),videoCapabilities:i.map(e=>({contentType:`video/mp4; codecs="${e}"`,robustness:s.videoRobustness||"",encryptionScheme:s.videoEncryptionScheme||null}))}]}(n,e,t,this.config.drmSystemOptions);const i=this.keySystemAccessPromises[n];let r=null==i?void 0:i.keySystemAccess;if(r)return r.then(()=>i.mediaKeys);{this.log(`Requesting encrypted media "${n}" key-system access with config: `+JSON.stringify(e)),r=this.requestMediaKeySystemAccess(n,e);const a=this.keySystemAccessPromises[n]={keySystemAccess:r};return r.catch(e=>{this.log(`Failed to obtain access to key-system "${n}": `+e)}),r.then(e=>{this.log(`Access for key-system "${e.keySystem}" obtained`);const i=this.fetchServerCertificate(n);return this.log(`Create media-keys for "${n}"`),a.mediaKeys=e.createMediaKeys().then(t=>(this.log(`Media-keys created for "${n}"`),i.then(e=>e?this.setMediaKeysServerCertificate(t,n,e):t))),a.mediaKeys.catch(e=>{this.error(`Failed to create media-keys for "${n}"}: `+e)}),a.mediaKeys})}}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:i}){this.log(`Creating key-system session "${t}" keyId: `+tt.hexDump(e.keyId||[]));var n=i.createSession(),e={decryptdata:e,keySystem:t,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(e),e}renewKeySession(e){var t,i,n=e.decryptdata;n.pssh?(t=this.createMediaKeySessionContext(e),i=this.getKeyIdString(n),this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(t,"cenc",n.pssh,"expired")):this.warn("Could not renew expired session. Missing pssh initData."),this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return tt.hexDump(e.keyId)}updateKeySession(e,t){var i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyID ${tt.hexDump((null==(e=e.decryptdata)?void 0:e.keyId)||[])} } (data length: ${t&&t.byteLength})`),i.update(t)}selectKeySystemFormat(e){var t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats `+t.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(r){return new Promise((i,n)=>{const t=ze(this.config);var e=r.map(Be).filter(e=>!!e&&-1!==t.indexOf(e));return this.getKeySystemSelectionPromise(e).then(({keySystem:e})=>{var t=Ue(e);t?i(t):n(new Error(`Unable to find format for key-system "${e}"`))}).catch(n)})}loadKey(e){const n=e.keyInfo.decryptdata;var t=this.getKeyIdString(n);const r=`(keyId: ${t} format: "${n.keyFormat}" method: ${n.method} uri: ${n.uri})`;this.log("Starting session for key "+r);let i=this.keyIdToKeySessionPromise[t];return i||(i=this.keyIdToKeySessionPromise[t]=this.getKeySystemForKeyPromise(n).then(({keySystem:t,mediaKeys:i})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key `+r),this.attemptSetMediaKeys(t,i).then(()=>{this.throwIfDestroyed();var e=this.createMediaKeySessionContext({keySystem:t,mediaKeys:i,decryptdata:n});return this.generateRequestWithPreferredKeySession(e,"cenc",n.pssh,"playlist-key")})))).catch(e=>this.handleError(e)),i}throwIfDestroyed(e=0){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof La?this.hls.trigger(Z.ERROR,e.data):this.hls.trigger(Z.ERROR,{type:j.KEY_SYSTEM_ERROR,details:G.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){var t=this.getKeyIdString(e),t=this.keyIdToKeySessionPromise[t];return t||(e=(t=Be(e.keyFormat))?[t]:ze(this.config),this.attemptKeySystemAccess(e))}getKeySystemSelectionPromise(e){if(0===(e=e.length?e:ze(this.config)).length)throw new La({type:j.KEY_SYSTEM_ERROR,details:G.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(e)}_onMediaEncrypted(t){const{initDataType:a,initData:s}=t;if(this.debug(`"${t.type}" event: init data type: "${a}"`),null!==s){let r,e;if("sinf"===a&&this.config.drmSystems[f.FAIRPLAY]){t=at(new Uint8Array(s));try{var i=ke(JSON.parse(t).sinf),n=dt(new Uint8Array(i));if(!n)return;r=n.subarray(8,24),e=f.FAIRPLAY}catch(e){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{t=function(t){if(!(t instanceof ArrayBuffer)||t.byteLength<32)return null;var i={version:0,systemId:"",kids:null,data:null},e=new DataView(t),n=e.getUint32(0);if(t.byteLength!==n&&44>>24,1this.generateRequestWithPreferredKeySession(h,a,s,"encrypted-event-key-match"));break}}}(t=t||(o[c]=this.getKeySystemSelectionPromise([e]).then(({keySystem:t,mediaKeys:i})=>{var e;this.throwIfDestroyed();const n=new yt("ISO-23001-7",c,null!=(e=Ue(t))?e:"");return n.pssh=new Uint8Array(s),n.keyId=r,this.attemptSetMediaKeys(t,i).then(()=>{this.throwIfDestroyed();var e=this.createMediaKeySessionContext({decryptdata:n,keySystem:t,mediaKeys:i});return this.generateRequestWithPreferredKeySession(e,a,s,"encrypted-event-no-match")})}))).catch(e=>this.handleError(e))}}}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const i=this.setMediaKeysQueue.slice(),n=(this.log(`Setting media-keys for "${e}"`),Promise.all(i).then(()=>{if(this.media)return this.media.setMediaKeys(t);throw new Error("Attempted to set mediaKeys without media element attached")}));return this.setMediaKeysQueue.push(n),n.then(()=>{this.log(`Media-keys set for "${e}"`),i.push(n),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===i.indexOf(e))})}generateRequestWithPreferredKeySession(n,e,t,i){var r=null==(r=this.config.drmSystems)||null==(r=r[n.keySystem])?void 0:r.generateRequest;if(r)try{var a=r.call(this.hls,e,t,n);if(!a)throw new Error("Invalid response from configured generateRequest filter");e=a.initDataType,t=n.decryptdata.pssh=a.initData?new Uint8Array(a.initData):null}catch(e){if(this.warn(e.message),null!=(r=this.hls)&&r.config.debug)throw e}if(null===t)return this.log(`Skipping key-session request for "${i}" (no initData)`),Promise.resolve(n);const s=this.getKeyIdString(n.decryptdata),o=(this.log(`Generating key-session request for "${i}": ${s} (init data type: ${e} length: ${t?t.byteLength:null})`),new yr),l=(n.mediaKeysSession.onmessage=e=>{var t,i=n.mediaKeysSession;i?({messageType:e,message:t}=e,this.log(`"${e}" message event for session "${i.sessionId}" message size: `+t.byteLength),"license-request"===e||"license-renewal"===e?this.renewLicense(n,t).catch(e=>{this.handleError(e),o.emit("error",e)}):"license-release"===e?n.keySystem===f.FAIRPLAY&&(this.updateKeySession(n,Ce("acknowledged")),this.removeSession(n)):this.warn(`unhandled media key message type "${e}"`)):o.emit("error",new Error("invalid state"))},n.mediaKeysSession.onkeystatuseschange=e=>{var t;n.mediaKeysSession?(this.onKeyStatusChange(n),t=n.keyStatus,o.emit("keyStatus",t),"expired"===t&&(this.warn(n.keySystem+" expired for key "+s),this.renewKeySession(n))):o.emit("error",new Error("invalid state"))},new Promise((t,i)=>{o.on("error",i),o.on("keyStatus",e=>{e.startsWith("usable")?t():"output-restricted"===e?i(new La({type:j.KEY_SYSTEM_ERROR,details:G.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===e?i(new La({type:j.KEY_SYSTEM_ERROR,details:G.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${e}"`)):"expired"===e?i(new Error("key expired while generating request")):this.warn(`unhandled key status change "${e}"`)})}));return n.mediaKeysSession.generateRequest(e,t).then(()=>{var e;this.log(`Request generated for key-session "${null==(e=n.mediaKeysSession)?void 0:e.sessionId}" keyId: `+s)}).catch(e=>{throw new La({type:j.KEY_SYSTEM_ERROR,details:G.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},"Error generating key-session request: "+e)}).then(()=>l).catch(e=>{throw o.removeAllListeners(),this.removeSession(n),e}).then(()=>(o.removeAllListeners(),n))}onKeyStatusChange(i){i.mediaKeysSession.keyStatuses.forEach((e,t)=>{this.log(`key status change "${e}" for keyStatuses keyId: ${tt.hexDump("buffer"in t?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t))} session keyId: ${tt.hexDump(new Uint8Array(i.decryptdata.keyId||[]))} uri: `+i.decryptdata.uri),i.keyStatus=e})}fetchServerCertificate(o){const i=this.config;const n=new i.loader(i),l=this.getServerCertificateUrl(o);return l?(this.log(`Fetching serverCertificate for "${o}"`),new Promise((r,a)=>{const s={responseType:"arraybuffer",url:l};var e=i.certLoadPolicy.default,e={loadPolicy:e,timeout:e.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},t={onSuccess:(e,t,i,n)=>{r(e.data)},onError:(e,t,i,n)=>{a(new La({type:j.KEY_SYSTEM_ERROR,details:G.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:i,response:le({url:s.url,data:void 0},e)},`"${o}" certificate request failed (${l}). Status: ${e.code} (${e.text})`))},onTimeout:(e,t,i)=>{a(new La({type:j.KEY_SYSTEM_ERROR,details:G.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:i,response:{url:s.url,data:void 0}},`"${o}" certificate request timed out (${l})`))},onAbort:(e,t,i)=>{a(new Error("aborted"))}};n.load(s,e,t)})):Promise.resolve()}setMediaKeysServerCertificate(n,r,a){return new Promise((t,i)=>{n.setServerCertificate(a).then(e=>{this.log(`setServerCertificate ${e?"success":"not supported by CDM"} (${null==a?void 0:a.byteLength}) on "${r}"`),t(n)}).catch(e=>{i(new La({type:j.KEY_SYSTEM_ERROR,details:G.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then(e=>this.updateKeySession(t,new Uint8Array(e)).catch(e=>{throw new La({type:j.KEY_SYSTEM_ERROR,details:G.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:!0},e.message)}))}setupLicenseXHR(t,i,n,r){const a=this.config.licenseXhrSetup;return a?Promise.resolve().then(()=>{if(n.decryptdata)return a.call(this.hls,t,i,n,r);throw new Error("Key removed")}).catch(e=>{if(n.decryptdata)return t.open("POST",i,!0),a.call(this.hls,t,i,n,r);throw e}).then(e=>{return t.readyState||t.open("POST",i,!0),{xhr:t,licenseChallenge:e||r}}):(t.open("POST",i,!0),Promise.resolve({xhr:t,licenseChallenge:r}))}requestLicense(a,s){const o=this.config.keyLoadPolicy.default;return new Promise((i,e)=>{const n=this.getLicenseServerUrl(a.keySystem),r=(this.log("Sending license request to URL: "+n),new XMLHttpRequest);r.responseType="arraybuffer",r.onreadystatechange=()=>{if(!this.hls||!a.mediaKeysSession)return e(new Error("invalid state"));if(4===r.readyState)if(200===r.status){this._requestLicenseFailureCount=0;let e=r.response;this.log("License received "+(e instanceof ArrayBuffer?e.byteLength:e));var t=this.config.licenseResponseCallback;if(t)try{e=t.call(this.hls,r,n,a)}catch(e){this.error(e)}i(e)}else{var t=o.errorRetry,t=t?t.maxNumRetry:0;this._requestLicenseFailureCount++,this._requestLicenseFailureCount>t||400<=r.status&&r.status<500?e(new La({type:j.KEY_SYSTEM_ERROR,details:G.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:{url:n,data:void 0,code:r.status,text:r.statusText}},`License Request XHR failed (${n}). Status: ${r.status} (${r.statusText})`)):(t=t-this._requestLicenseFailureCount+1,this.warn(`Retrying license request, ${t} attempts left`),this.requestLicense(a,s).then(i,e))}},a.licenseXhr&&a.licenseXhr.readyState!==XMLHttpRequest.DONE&&a.licenseXhr.abort(),a.licenseXhr=r,this.setupLicenseXHR(r,n,a,s).then(({xhr:e,licenseChallenge:t})=>{e.send(t)})})}onMediaAttached(e,t){this.config.emeEnabled&&(t=t.media,(this.media=t).addEventListener("encrypted",this.onMediaEncrypted),t.addEventListener("waitingforkey",this.onWaitingForKey))}onMediaDetached(){const t=this.media,e=this.mediaKeySessions,i=(t&&(t.removeEventListener("encrypted",this.onMediaEncrypted),t.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},yt.clearKeyUriToKeyIdMap(),e.length);Aa.CDMCleanupPromise=Promise.all(e.map(e=>this.removeSession(e)).concat(null==t?void 0:t.setMediaKeys(null).catch(e=>{this.log(`Could not clear media keys: ${e}. media.src: `+(null==t?void 0:t.src))}))).then(()=>{i&&(this.log("finished closing key sessions and clearing media keys"),e.length=0)}).catch(e=>{this.log(`Could not close sessions and clear media keys: ${e}. media.src: `+(null==t?void 0:t.src))})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){t&&this.config.emeEnabled&&(this.keyFormatPromise||(t=t.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]),this.log("Selecting key-system from session-keys "+t.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(t)))}removeSession(e){const{mediaKeysSession:t,licenseXhr:i}=e;if(t)return this.log("Remove licenses and keys and close session "+t.sessionId),t.onmessage=null,t.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0,-1<(e=this.mediaKeySessions.indexOf(e))&&this.mediaKeySessions.splice(e,1),t.remove().catch(e=>{this.log("Could not remove session: "+e)}).then(()=>t.close()).catch(e=>{this.log("Could not close session: "+e)})}}Aa.CDMCleanupPromise=void 0;class La extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),(this.data=e).err=e.error}}var Ia="m",Da="a",ka="v",_a="av",xa="i",Ca="tt";class Ra{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:Ia,su:!this.initialized})}catch(e){V.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{var t=e.frag,i=this.hls.levels[t.level],n=this.getObjectType(t),r={d:1e3*t.duration,ot:n};n!==ka&&n!==Da&&n!=_a||(r.br=i.bitrate/1e3,r.tb=this.getTopBandwidth(n)/1e3,r.bl=this.getBufferLength(n)),this.apply(e,r)}catch(e){V.warn("Could not generate segment CMCD data.",e)}},this.hls=e;var e=this.config=e.config,t=e["cmcd"];null!=t&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=t.sessionId||Ra.uuid(),this.cid=t.contentId,this.useHeaders=!0===t.useHeaders,this.registerListeners())}registerListeners(){var e=this.hls;e.on(Z.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Z.MEDIA_DETACHED,this.onMediaDetached,this),e.on(Z.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){var e=this.hls;e.off(Z.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Z.MEDIA_DETACHED,this.onMediaDetached,this),e.off(Z.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var i;this.audioBuffer=null==(i=t.tracks.audio)?void 0:i.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer}createData(){var e;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){ue(t,this.createData());var i=t.ot===xa||t.ot===ka||t.ot===_a;this.starved&&i&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering),this.useHeaders?(i=Ra.toHeaders(t),Object.keys(i).length&&(e.headers||(e.headers={}),ue(e.headers,i))):(i=Ra.toQuery(t))&&(e.url=Ra.appendQueryToUri(e.url,i))}getObjectType(e){var t=e["type"];return"subtitle"===t?Ca:"initSegment"===e.sn?xa:"audio"===t?Da:"main"===t?this.hls.audioTracks.length?ka:_a:void 0}getTopBandwidth(e){let t=0,i;var n=this.hls;for(const r of i=e===Da?n.audioTracks:(e=-1<(e=n.maxAutoLevel)?e+1:n.levels.length,n.levels.slice(0,e)))r.bitrate>t&&(t=r.bitrate);return 0Math.round(e);var n=e=>100*t(e/100),r={br:t,d:t,bl:n,dl:n,mtp:n,nor:e=>encodeURIComponent(e),rtp:n,tb:t};for(const s of Object.keys(e||{}).sort()){let t=e[s];if((a=t,!Number.isNaN(a)&&null!=a&&""!==a&&!1!==a)&&!("v"===s&&1===t||"pr"==s&&1===t)){var a=r[s],a=typeof(t=a?a(t):t);let e;e="ot"===s||"sf"===s||"st"===s?s+"="+t:"boolean"==a?s:"number"==a?s+"="+t:s+"="+JSON.stringify(t),i.push(e)}}return i.join(",")}static toHeaders(e){var t={},i=["Object","Request","Session","Status"],n=[{},{},{},{}],r={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const s of Object.keys(e))n[null!=r[s]?r[s]:1][s]=e[s];for(let e=0;e{var e=t.filter(e=>e.groupId===i).map(e=>{var t=ue({},e);return t.details=void 0,t.attrs=new be(t.attrs),t.url=t.attrs.URI=Na(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),t.groupId=t.attrs["GROUP-ID"]=n[i],t.attrs["PATHWAY-ID"]=a,t});t.push(...e)})}function Na(e,t,i,n){const{HOST:r,PARAMS:a,[i]:s}=n;let o;t&&(o=null==s?void 0:s[t])&&(e=o);const l=new self.URL(e);return r&&!o&&(l.host=r),a&&Object.keys(a).sort().forEach(e=>{e&&l.searchParams.set(e,a[e])}),l.href}const Oa=/^age:\s*[\d.]+\s*$/im;class Ba{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new Se,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){var e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState)&&(this.stats.aborted=!0,e.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,i){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=i,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(e){const i=this.loader=new self.XMLHttpRequest,n=this.stats,r=(n.loading.first=0,n.loaded=0,n.aborted=!1,this.xhrSetup);r?Promise.resolve().then(()=>{if(!this.stats.aborted)return r(i,t.url)}).catch(e=>(i.open("GET",t.url,!0),r(i,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(i,t,e)}).catch(e=>{this.callbacks.onError({code:i.status,text:e.message},t,i,n)}):this.openAndSendXhr(i,t,e)}}openAndSendXhr(e,t,i){e.readyState||e.open("GET",t.url,!0);var n=this.context.headers,{maxTimeToFirstByteMs:r,maxLoadTimeMs:a}=i.loadPolicy;if(n)for(const s in n)e.setRequestHeader(s,n[s]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),i.timeout=r&&B(r)?r:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),i.timeout),e.send()}readystatechange(){var e,t,i,n,{context:r,loader:a,stats:s}=this;r&&a&&(t=a.readyState,e=this.config,s.aborted||2<=t&&(0===s.loading.first&&(s.loading.first=Math.max(self.performance.now(),s.loading.start),e.timeout!==e.loadPolicy.maxLoadTimeMs)&&(self.clearTimeout(this.requestTimeout),e.timeout=e.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),e.loadPolicy.maxLoadTimeMs-(s.loading.first-s.loading.start))),4===t)&&(self.clearTimeout(this.requestTimeout),a.onreadystatechange=null,a.onprogress=null,t=a.status,n="text"!==a.responseType,200<=t&&t<300&&(n&&a.response||null!==a.responseText)?(s.loading.end=Math.max(self.performance.now(),s.loading.first),n=n?a.response:a.responseText,i="arraybuffer"===a.responseType?n.byteLength:n.length,s.loaded=s.total=i,s.bwEstimate=8e3*s.total/(s.loading.end-s.loading.first),this.callbacks&&((i=this.callbacks.onProgress)&&i(s,r,n,a),this.callbacks)&&(i={url:a.responseURL,data:n,code:t},this.callbacks.onSuccess(i,s,r,a))):Ai(n=e.loadPolicy.errorRetry,s.retry,!1,t)?this.retry(n):(V.error(t+" while loading "+r.url),this.callbacks.onError({code:t,text:a.statusText},r,a,s))))}loadtimeout(){var e=null==(e=this.config)?void 0:e.loadPolicy.timeoutRetry;Ai(e,this.stats.retry,!0)?this.retry(e):(V.warn("timeout while loading "+this.context.url),(e=this.callbacks)&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader)))}retry(e){var{context:t,stats:i}=this;this.retryDelay=wi(e,i.retry),i.retry++,V.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t.url}, retrying ${i.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){var t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;var t;return this.loader&&Oa.test(this.loader.getAllResponseHeaders())&&(t=this.loader.getResponseHeader("age"),e=t?parseFloat(t):null),e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const Fa=/(\d+)-(\d+)\/(\d+)/;class Ua{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||za,this.controller=new self.AbortController,this.stats=new Se}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){var e=this.response;null!=e&&e.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(n,r,a){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();var e=function(e,t){t={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(ue({},e.headers))};e.rangeEnd&&t.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1));return t}(n,this.controller.signal);const o=a.onProgress,l="arraybuffer"===n.responseType,u=l?"byteLength":"length",{maxTimeToFirstByteMs:t,maxLoadTimeMs:d}=r.loadPolicy;this.context=n,this.config=r,this.callbacks=a,this.request=this.fetchSetup(n,e),self.clearTimeout(this.requestTimeout),r.timeout=t&&B(t)?t:d,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),a.onTimeout(s,n,this.response)},r.timeout),self.fetch(this.request).then(e=>{this.response=this.loader=e;var t,i=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),r.timeout=d,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),a.onTimeout(s,n,this.response)},d-(i-s.loading.start)),e.ok)return s.loading.first=i,s.total=function(e){var t=e.get("Content-Range");if(t){t=function(e){e=Fa.exec(e);if(e)return parseInt(e[2])-parseInt(e[1])+1}(t);if(B(t))return t}t=e.get("Content-Length");if(t)return parseInt(t)}(e.headers)||s.total,o&&B(r.highWaterMark)?this.loadProgressively(e,s,n,r.highWaterMark,o):l?e.arrayBuffer():"json"===n.responseType?e.json():e.text();throw{status:i,statusText:t}=e,new Za(t||"fetch, bad network response",i,e)}).then(e=>{var t=this["response"],i=(self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first),e[u]),i=(i&&(s.loaded=s.total=i),{url:t.url,data:e,code:t.status});o&&!B(r.highWaterMark)&&o(s,n,e,t),a.onSuccess(i,s,n,t)}).catch(e=>{var t,i;self.clearTimeout(this.requestTimeout),s.aborted||(t=e&&e.code||0,i=e?e.message:null,a.onError({code:t,text:i},n,e?e.details:null,s))})}getCacheAge(){let e=null;var t;return this.response&&(t=this.response.headers.get("age"),e=t?parseFloat(t):null),e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(i,n,r,a=0,s){const o=new Ar,e=i.body.getReader(),l=()=>e.read().then(e=>{var t;return e.done?(o.dataLength&&s(n,r,o.flush(),i),Promise.resolve(new ArrayBuffer(0))):(t=(e=e.value).length,n.loaded+=t,t=a&&s(n,r,o.flush(),i)):s(n,r,e,i),l())}).catch(()=>Promise.reject());return l()}}function za(e,t){return new self.Request(e.url,t)}class Za extends Error{constructor(e,t,i){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=i}}const ja=/\s/,Ga={newCue(t,i,n,r){var a,s=[];let o,l,u;var d,c=self.VTTCue||self.TextTrackCue;for(let e=0;e"auto"===e.line||"auto"===t.line?0:8qt(t,e))),s}};const Va=le(le({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Ba,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0;e=(this.hls=e).config;this.bwEstimator=new Mr(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){var e=this["hls"];e.on(Z.FRAG_LOADING,this.onFragLoading,this),e.on(Z.FRAG_LOADED,this.onFragLoaded,this),e.on(Z.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Z.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Z.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){var e=this["hls"];e.off(Z.FRAG_LOADING,this.onFragLoading,this),e.off(Z.FRAG_LOADED,this.onFragLoaded,this),e.off(Z.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Z.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Z.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,t){var i=t.frag;this.ignoreFragment(i)||(this.fragCurrent=i,this.partCurrent=null!=(i=t.part)?i:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,t){this.clearTimer()}getTimeToLoadFrag(e,t,i,n){return e+i/t+(n?this.lastLevelLoadSec:0)}onLevelLoaded(e,t){var i=this.hls.config,{total:n,bwEstimate:r}=t.stats;B(n)&&B(r)&&(this.lastLevelLoadSec=8*n/r),t.details.live?this.bwEstimator.update(i.abrEwmaSlowLive,i.abrEwmaFastLive):this.bwEstimator.update(i.abrEwmaSlowVoD,i.abrEwmaFastVoD)}_abandonRulesCheck(){var{fragCurrent:i,partCurrent:n,hls:r}=this,{autoLevelEnabled:a,media:s}=r;if(i&&s){var o=performance.now(),l=(n||i).stats,u=(n||i).duration,o=o-l.loading.start;if(l.aborted||l.loaded&&l.loaded===l.total||0===i.level)this.clearTimer(),this._nextAutoLevel=-1;else if(a&&!s.paused&&s.playbackRate&&s.readyState){a=r.mainForwardBufferInfo;if(null!==a){var d=this.bwEstimator.getEstimateTTFB(),s=Math.abs(s.playbackRate);if(!(o<=Math.max(d,u/(2*s)*1e3))){var c=a.len/s;if(!(2*u/s<=c)){var a=l.loading.first?l.loading.first-l.loading.start:-1,s=l.loaded&&-1p;t--){var y=f[t].maxBitrate;if((e=this.getTimeToLoadFrag(d/1e3,m,u*y,!f[t].details))=g||e>10*u||(r.nextLoadLevel=t,s?this.bwEstimator.sample(o-Math.min(d,a),l.loaded):this.bwEstimator.sampleTTFB(o),this.clearTimer(),V.warn(`[abr] Fragment ${i.sn}${n?" part "+n.index:""} of level ${i.level} is loading too slowly; Time to underbuffer: ${c.toFixed(3)} s Estimated load time for current fragment: ${g.toFixed(3)} s Estimated load time for down switch fragment: ${e.toFixed(3)} s TTFB estimate: ${a} Current BW estimate: ${B(h)?(h/1024).toFixed(3):"Unknown"} Kb/s New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s Aborting and switching to level `+t),i.loader&&(this.fragCurrent=this.partCurrent=null,i.abortRequests()),r.trigger(Z.FRAG_LOAD_EMERGENCY_ABORTED,{frag:i,part:n,stats:l}))}}}}}}}onFragLoaded(e,{frag:t,part:i}){var n,r,a,s=(i||t).stats;t.type===y&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),this.ignoreFragment(t)||(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate&&(r=(i||t).duration,n=((a=this.hls.levels[t.level]).loaded?a.loaded.bytes:0)+s.loaded,r=(a.loaded?a.loaded.duration:0)+r,a.loaded={bytes:n,duration:r},a.realBitrate=Math.round(8*n/r)),t.bitrateTest&&(a={stats:s,frag:t,part:i,id:t.type},this.onFragBuffered(Z.FRAG_BUFFERED,a),t.bitrateTest=!1))}onFragBuffered(e,t){var i,{frag:t,part:n}=t,n=(null!=n&&n.stats.loaded?n:t).stats;n.aborted||this.ignoreFragment(t)||(i=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB()),this.bwEstimator.sample(i,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),t.bitrateTest?this.bitrateTestDelay=i/1e3:this.bitrateTestDelay=0)}ignoreFragment(e){return e.type!==y||"initSegment"===e.sn}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){var e=this._nextAutoLevel,t=this.bwEstimator;if(-1!==e&&!t.canEstimate())return e;let i=this.getNextABRAutoLevel();if(-1!==e){t=this.hls.levels;if(t.length>Math.max(e,i)&&t[e].loadError<=t[i].loadError)return e}return i=-1!==e?Math.min(e,i):i}getNextABRAutoLevel(){var e,{fragCurrent:t,partCurrent:i,hls:n}=this,{maxAutoLevel:r,config:a,minAutoLevel:s,media:o}=n,i=i?i.duration:t?t.duration:0,t=o&&0!==o.playbackRate?Math.abs(o.playbackRate):1,o=this.bwEstimator?this.bwEstimator.getEstimate():a.abrEwmaDefaultEstimate,n=n.mainForwardBufferInfo,n=(n?n.len:0)/t,t=this.findBestLevel(o,s,r,n,a.abrBandWidthFactor,a.abrBandWidthUpFactor);if(0<=t)return t;V.trace(`[abr] ${n?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let l=i?Math.min(i,a.maxStarvationDelay):a.maxStarvationDelay,u=a.abrBandWidthFactor,d=a.abrBandWidthUpFactor;return n||(e=this.bitrateTestDelay)&&(i=i?Math.min(i,a.maxLoadingDelay):a.maxLoadingDelay,l=i-e,V.trace(`[abr] bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*l)} ms`),u=d=1),t=this.findBestLevel(o,s,r,n+l,u,d),Math.max(t,0)}findBestLevel(i,e,n,r,a,s){var t,{fragCurrent:o,partCurrent:l,lastLoadedFragLevel:u}=this,d=this.hls["levels"],c=d[u],h=!(null==c||null==(t=c.details)||!t.live),f=null==c?void 0:c.codecSet,p=l?l.duration:o?o.duration:0,g=this.bwEstimator.getEstimateTTFB()/1e3;let v=e,m=-1;for(let t=n;t>=e;t--){var y=d[t];if(!y||f&&y.codecSet!==f)y&&(v=Math.min(t,v),m=Math.max(t,m));else{-1!==m&&V.trace(`[abr] Skipped level(s) ${v}-${m} with CODECS:"${d[m].attrs.CODECS}"; not compatible with "${c.attrs.CODECS}"`);var y=y.details,b=(l?null==y?void 0:y.partTarget:null==y?void 0:y.averagetargetduration)||p;let e;e=t<=u?a*i:s*i;var E=d[t].maxBitrate,y=this.getTimeToLoadFrag(g,e,E*b,void 0===y);if(V.trace(`[abr] level:${t} adjustedbw-bitrate:${Math.round(e-E)} avgDuration:${b.toFixed(1)} maxFetchDuration:${r.toFixed(1)} fetchDuration:`+y.toFixed(1)),e>E&&(0===y||!B(y)||h&&!this.bitrateTestDelay||y{var{media:e,mediaSource:t}=this;V.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(Z.MEDIA_ATTACHED,{media:e})),t&&t.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{V.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{V.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{var{media:e,_objectUrl:t}=this;e&&e.src!==t&&V.error(`Media element src was set while attaching MediaSource (${t} > ${e.src})`)},this.hls=e,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return 0{var e=this.sourceBuffer[t];try{e&&(this.removeBufferListeners(t),this.mediaSource&&this.mediaSource.removeSourceBuffer(e),this.sourceBuffer[t]=void 0)}catch(e){V.warn(`[buffer-controller]: Failed to reset the ${t} buffer`,e)}}),this._initSourceBuffer()}onBufferCodecs(e,u){const d=this.getSourceBufferTypes().length;Object.keys(u).forEach(e=>{var t,i,n,r,a,s,o,l;d?(t=this.tracks[e])&&"function"==typeof t.buffer.changeType&&({id:i,codec:n,levelCodec:r,container:a,metadata:s}=u[e],(o=(t.levelCodec||t.codec).replace(xr,"$1"))!==(l=(r||n).replace(xr,"$1")))&&(this.appendChangeType(e,a+";codecs="+(r||n)),V.log(`[buffer-controller]: switching codec ${o} to `+l),this.tracks[e]={buffer:t.buffer,codec:n,container:a,levelCodec:r,metadata:s,id:i}):this.pendingTracks[e]=u[e]}),d||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())}appendChangeType(t,i){const n=this["operationQueue"];n.append({execute:()=>{var e=this.sourceBuffer[t];e&&(V.log(`[buffer-controller]: changing ${t} sourceBuffer type to `+i),e.changeType(i)),n.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:e=>{V.warn(`[buffer-controller]: Failed to change ${t} SourceBuffer type`,e)}},t)}onBufferAppending(e,t){const{hls:i,operationQueue:n,tracks:r}=this,{data:a,type:s,frag:o,part:l,chunkMeta:u}=t,d=u.buffering[s];t=self.performance.now();d.start=t;const c=o.stats.buffering,h=l?l.stats.buffering:null;0===c.start&&(c.start=t),h&&0===h.start&&(h.start=t);t=r.audio;let f=!1;"audio"===s&&"audio/mpeg"===(null==t?void 0:t.container)&&(f=!this.lastMpegAudioChunk||1===u.id||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);const p=o.start;n.append({execute:()=>{var e,t;d.executeStart=self.performance.now(),f&&(e=this.sourceBuffer[s])&&(t=p-e.timestampOffset,.1<=Math.abs(t))&&(V.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${p} (delta: ${t}) sn: ${o.sn})`),e.timestampOffset=p),this.appendExecutor(a,s)},onStart:()=>{},onComplete:()=>{var e=self.performance.now(),t=(d.executeEnd=d.end=e,0===c.first&&(c.first=e),h&&0===h.first&&(h.first=e),this)["sourceBuffer"],i={};for(const s in t)i[s]=b.getBuffered(t[s]);this.appendError=0,this.hls.trigger(Z.BUFFER_APPENDED,{type:s,frag:o,part:l,chunkMeta:u,parent:o.type,timeRanges:i})},onError:e=>{V.error(`[buffer-controller]: Error encountered while trying to append to the ${s} SourceBuffer`,e);var t={type:j.MEDIA_ERROR,parent:o.type,details:G.BUFFER_APPEND_ERROR,frag:o,part:l,chunkMeta:u,error:e,err:e,fatal:!1};e.code===DOMException.QUOTA_EXCEEDED_ERR?t.details=G.BUFFER_FULL_ERROR:(this.appendError++,t.details=G.BUFFER_APPEND_ERROR,this.appendError>i.config.appendErrorMaxRetry&&(V.error(`[buffer-controller]: Failed ${i.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),t.fatal=!0)),i.trigger(Z.ERROR,t)}},s)}onBufferFlushing(e,i){const t=this["operationQueue"],n=t=>({execute:this.removeExecutor.bind(this,t,i.startOffset,i.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(Z.BUFFER_FLUSHED,{type:t})},onError:e=>{V.warn(`[buffer-controller]: Failed to remove from ${t} SourceBuffer`,e)}});i.type?t.append(n(i.type),i.type):this.getSourceBufferTypes().forEach(e=>{t.append(n(e),e)})}onFragParsed(e,t){const{frag:i,part:n}=t;var t=[],r=(n||i).elementaryStreams;r[Me]?t.push("audiovideo"):(r[Te]&&t.push("audio"),r[we]&&t.push("video"));0===t.length&&V.warn(`Fragments must have at least one ElementaryStreamType set. type: ${i.type} level: ${i.level} sn: `+i.sn),this.blockBuffers(()=>{var e=self.performance.now(),e=(i.stats.buffering.end=e,n&&(n.stats.buffering.end=e),(n||i).stats);this.hls.trigger(Z.FRAG_BUFFERED,{frag:i,part:n,stats:e,id:i.type})},t)}onFragChanged(e,t){this.flushBackBuffer()}onBufferEos(e,n){this.getSourceBufferTypes().reduce((e,t)=>{var i=this.sourceBuffer[t];return!i||n.type&&n.type!==t||(i.ending=!0,i.ended)||(i.ended=!0,V.log(`[buffer-controller]: ${t} sourceBuffer now EOS`)),e&&!(i&&!i.ended)},!0)&&(V.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(e=>{e=this.sourceBuffer[e];e&&(e.ending=!1)});var e=this["mediaSource"];e&&"open"===e.readyState?(V.log("[buffer-controller]: Calling mediaSource.endOfStream()"),e.endOfStream()):e&&V.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+e.readyState)}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:n,details:r,media:e,sourceBuffer:a}=this;if(e&&null!==r){var t=this.getSourceBufferTypes();if(t.length){var i=r.live&&null!==n.config.liveBackBufferLength?n.config.liveBackBufferLength:n.config.backBufferLength;if(B(i)&&!(i<0)){const s=e.currentTime,o=r.levelTargetDuration;i=Math.max(i,o);const l=Math.floor(s/o)*o-i;t.forEach(e=>{var t=a[e];if(t){var i=b.getBuffered(t);if(0i.start(0)){if(n.trigger(Z.BACK_BUFFER_REACHED,{bufferEnd:l}),r.live)n.trigger(Z.LIVE_BACK_BUFFER_REACHED,{bufferEnd:l});else if(t.ended&&i.end(i.length-1)-s<2*o)return void V.info(`[buffer-controller]: Cannot flush ${e} back buffer while SourceBuffer is in ended state`);n.trigger(Z.BUFFER_FLUSHING,{startOffset:0,endOffset:l,type:e})}}})}}}}updateMediaElementDuration(){var e,t,i,n,r,a;this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState&&({details:e,hls:t,media:r,mediaSource:i}=this,n=e.fragments[0].start+e.totalduration,r=r.duration,a=B(i.duration)?i.duration:0,e.live&&t.config.liveDurationInfinity?(V.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(e)):(a{t.executeNext(e)})):(n=new Error("could not create source buffer for media codec(s)"),this.hls.trigger(Z.ERROR,{type:j.MEDIA_ERROR,details:G.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:n,reason:n.message})))}createSourceBuffers(e){var{sourceBuffer:t,mediaSource:i}=this;if(!i)throw Error("createSourceBuffers called when mediaSource was null");for(const l in e)if(!t[l]){var n=e[l];if(!n)throw Error(`source buffer exists for track ${l}, however track does not`);var r=n.levelCodec||n.codec,a=n.container+";codecs="+r;V.log(`[buffer-controller]: creating sourceBuffer(${a})`);try{var s=t[l]=i.addSourceBuffer(a),o=l;this.addBufferListener(o,"updatestart",this._onSBUpdateStart),this.addBufferListener(o,"updateend",this._onSBUpdateEnd),this.addBufferListener(o,"error",this._onSBUpdateError),this.tracks[l]={buffer:s,codec:r,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(e){V.error("[buffer-controller]: error while trying to add sourceBuffer: "+e.message),this.hls.trigger(Z.ERROR,{type:j.MEDIA_ERROR,details:G.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:a})}}}_onSBUpdateStart(e){var t=this["operationQueue"];t.current(e).onStart()}_onSBUpdateEnd(e){var t=this["operationQueue"];t.current(e).onComplete(),t.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var i=new Error(e+" SourceBuffer error"),i=(V.error("[buffer-controller]: "+i,t),this.hls.trigger(Z.ERROR,{type:j.MEDIA_ERROR,details:G.BUFFER_APPENDING_ERROR,error:i,fatal:!1}),this.operationQueue.current(e));i&&i.onError(t)}removeExecutor(e,t,i){var{media:n,mediaSource:r,operationQueue:a,sourceBuffer:s}=this,s=s[e];n&&r&&s?(n=B(n.duration)?n.duration:1/0,r=B(r.duration)?r.duration:1/0,(t=Math.max(0,t))<(i=Math.min(i,n,r))&&!s.ending?(s.ended=!1,V.log(`[buffer-controller]: Removing [${t},${i}] from the ${e} SourceBuffer`),s.remove(t,i)):a.shiftAndExecuteNext(e)):(V.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e))}appendExecutor(e,t){var{operationQueue:i,sourceBuffer:n}=this,n=n[t];n?(n.ended=!1,n.appendBuffer(e)):(V.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),i.shiftAndExecuteNext(t))}blockBuffers(e,t=this.getSourceBufferTypes()){if(t.length){const n=this["operationQueue"];var i=t.map(e=>n.appendBlocker(e));Promise.all(i).then(()=>{e(),t.forEach(e=>{var t=this.sourceBuffer[e];null!=t&&t.updating||n.shiftAndExecuteNext(e)})})}else V.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e)}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,i){var n=this.sourceBuffer[e];n&&(i=i.bind(this,e),this.listeners[e].push({event:t,listener:i}),n.addEventListener(t,i))}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(e=>{t.removeEventListener(e.event,e.listener)})}},capLevelController:wa,errorController:class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=V.log.bind(V,"[info]:"),this.warn=V.warn.bind(V,"[warning]:"),this.error=V.error.bind(V,"[error]:"),this.registerListeners()}registerListeners(){var e=this.hls;e.on(Z.ERROR,this.onError,this),e.on(Z.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Z.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){var e=this.hls;e&&(e.off(Z.ERROR,this.onError,this),e.off(Z.ERROR,this.onErrorOut,this),e.off(Z.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Z.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return(null==e?void 0:e.type)===y?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){if(!t.fatal){var i,n=this.hls,r=t.context;switch(t.details){case G.FRAG_LOAD_ERROR:case G.FRAG_LOAD_TIMEOUT:case G.KEY_LOAD_ERROR:case G.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case G.FRAG_PARSING_ERROR:if(null!=(a=t.frag)&&a.gap)return void(t.errorAction={action:_i,flags:Ri});case G.FRAG_GAP:case G.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=xi);case G.LEVEL_EMPTY_ERROR:case G.LEVEL_PARSING_ERROR:var a=t.parent===y?t.level:n.loadLevel;return void(t.details===G.LEVEL_EMPTY_ERROR&&null!=(s=t.context)&&null!=(s=s.levelDetails)&&s.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,a)));case G.LEVEL_LOAD_ERROR:case G.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==r?void 0:r.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,r.level)));case G.AUDIO_TRACK_LOAD_ERROR:case G.AUDIO_TRACK_LOAD_TIMEOUT:case G.SUBTITLE_LOAD_ERROR:case G.SUBTITLE_TRACK_LOAD_TIMEOUT:if(r){var s=n.levels[n.loadLevel];if(s&&(r.type===jt&&r.groupId===s.audioGroupId||r.type===Gt&&r.groupId===s.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=xi,void(t.errorAction.flags=Pi)}return;case G.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var a=n.levels[n.loadLevel],s=null==a?void 0:a.attrs["HDCP-LEVEL"];return void(s&&(t.errorAction={action:xi,flags:Ni,hdcpLevel:s}));case G.BUFFER_ADD_CODEC_ERROR:case G.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(a=t.level)?a:n.loadLevel));case G.INTERNAL_EXCEPTION:case G.BUFFER_APPENDING_ERROR:case G.BUFFER_APPEND_ERROR:case G.BUFFER_FULL_ERROR:case G.LEVEL_SWITCH_ERROR:case G.BUFFER_STALLED_ERROR:case G.BUFFER_SEEK_OVER_HOLE:case G.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:_i,flags:Ri})}t.type===j.KEY_SYSTEM_ERROR&&(i=this.getVariantLevelIndex(t.frag),t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,i))}}getPlaylistRetryOrSwitchAction(e,t){var i=Ti(this.hls.config.playlistLoadPolicy,e),n=this.playlistError++,r=null==(r=e.response)?void 0:r.code;return Ai(i,n,Si(e),r)?{action:Ci,flags:Ri,retryConfig:i,retryCount:n}:(r=this.getLevelSwitchAction(e,t),i&&(r.retryConfig=i,r.retryCount=n),r)}getFragRetryOrSwitchAction(e){var t=this.hls,i=this.getVariantLevelIndex(e.frag),n=t.levels[i],{fragLoadPolicy:r,keyLoadPolicy:a}=t.config,a=Ti(e.details.startsWith("key")?a:r,e),r=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(n){e.details!==G.FRAG_GAP&&n.fragmentError++;n=null==(t=e.response)?void 0:t.code;if(Ai(a,r,Si(e),n))return{action:Ci,flags:Ri,retryConfig:a,retryCount:r}}t=this.getLevelSwitchAction(e,i);return a&&(t.retryConfig=a,t.retryCount=r),t}getLevelSwitchAction(i,e){var n=this.hls,r=(null==e&&(e=n.loadLevel),this.hls.levels[e]);if(r&&(r.loadError++,n.autoLevelEnabled)){let t=-1;var{levels:a,loadLevel:s,minAutoLevel:o,maxAutoLevel:l}=n,u=null==(e=i.frag)?void 0:e.type,{type:d,groupId:c}=null!=(e=i.context)?e:{};for(let e=a.length;e--;){var h=(e+s)%a.length;if(h!==s&&o<=h&&h<=l&&0===a[h].loadError){var f=a[h];if(i.details===G.FRAG_GAP&&i.frag){var p=a[h].details;if(p){p=Di(i.frag,p.fragments,i.frag.start);if(null!=p&&p.gap)continue}}else{if(d===jt&&c===f.audioGroupId||d===Gt&&c===f.textGroupId)continue;if(u===Vt&&r.audioGroupId===f.audioGroupId||u===Yt&&r.textGroupId===f.textGroupId)continue}t=h;break}}if(-13*n.targetduration)return 1}return}(l,t,n[o]))return this.warn(`Switching to Redundant Stream ${1+u}/${s}: "${a.url[u]}" after `+t.details),this.playlistError=0,i.levels.forEach(e=>{e.urlId=u}),i.nextLoadLevel=r,!0}return!1}penalizeRendition(e,t){var i=this["penalizedRenditions"],n=i[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};n.lastErrorPerfMs=performance.now(),n.errors.push(t),n.details=e.details,i[e.urlId]=n}},fpsController:class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(Z.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(Z.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){var i=this.hls.config;i.capLevelOnFPSDrop&&(t=t.media instanceof self.HTMLVideoElement?t.media:null,(this.media=t)&&"function"==typeof t.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),i.fpsDroppedMonitoringPeriod))}checkFPS(e,t,i){var n,r,a,s,o=performance.now();t&&(this.lastTime&&(s=o-this.lastTime,n=i-this.lastDroppedFrames,r=t-this.lastDecodedFrames,s=1e3*n/s,(a=this.hls).trigger(Z.FPS_DROP,{currentDropped:n,currentDecoded:r,totalDroppedFrames:i}),0a.config.fpsDroppedMonitoringThreshold*r&&(s=a.currentLevel,V.warn("drop FPS ratio greater than max allowed value for currentLevel: "+s),0=s)&&(s-=1,a.trigger(Z.FPS_DROP_LEVEL_CAPPING,{level:s,droppedLevel:a.currentLevel}),a.autoLevelCapping=s,this.streamController.nextLevelSwitch()),this.lastTime=o,this.lastDroppedFrames=i,this.lastDecodedFrames=t)}checkFPSInterval(){var e,t=this.media;t&&(this.isVideoPlaybackQualityAvailable?(e=t.getVideoPlaybackQuality(),this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)):this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount))}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Ze,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:Ga,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends pn{constructor(e,t,i){super(e,t,i,"[subtitle-stream-controller]",Yt),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){var e=this["hls"];e.on(Z.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Z.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Z.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Z.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Z.ERROR,this.onError,this),e.on(Z.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Z.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Z.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Z.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(Z.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Z.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){var e=this["hls"];e.off(Z.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Z.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Z.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Z.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Z.ERROR,this.onError,this),e.off(Z.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Z.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Z.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Z.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(Z.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Z.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=E.IDLE,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,i){var{frag:i,success:n}=i;if(this.fragPrevious=i,this.state=E.IDLE,n){var r=this.tracksBuffered[this.currentTrackId];if(r){let t;var a=i.start;for(let e=0;e=r[e].start&&a<=r[e].end){t=r[e];break}n=i.start+i.duration;t?t.end=n:(t={start:a,end:n},r.push(t)),this.fragmentTracker.fragBuffered(i)}}}onBufferFlushing(e,t){var{startOffset:i,endOffset:n}=t;if(0===i&&n!==Number.POSITIVE_INFINITY){const r=n-1;r<=0||(t.endOffsetSubtitles=Math.max(0,r),this.tracksBuffered.forEach(t=>{for(let e=0;enew fi(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{e=new fi(e);return this.tracksBuffered[e.id]=[],e}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Yt),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){this.currentTrackId=t.id,this.levels.length&&-1!==this.currentTrackId?(null!=(t=this.levels[this.currentTrackId])&&t.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,t&&this.setInterval(500)):this.clearInterval()}onSubtitleTrackLoaded(e,t){var{details:t,id:i}=t,{currentTrackId:n,levels:r}=this;if(r.length){var a=r[n];if(!(i>=r.length||i!==n)&&a){this.mediaBuffer=this.mediaBufferTimeRanges;let e=0;if(t.live||null!=(r=a.details)&&r.live){n=this.mainDetails;if(t.deltaUpdateFailed||!n)return;r=n.fragments[0];a.details?0===(e=this.alignPlaylists(t,a.details))&&r&&yi(t,e=r.start):t.hasProgramDateTime&&n.hasProgramDateTime?(ln(t,n),e=t.fragments[0].start):r&&yi(t,e=r.start)}a.details=t,this.levelLastLoaded=i,this.startFragRequested||!this.mainDetails&&t.live||this.setStartPosition(a.details,e),this.tick(),t.live&&!this.fragCurrent&&this.media&&this.state===E.IDLE&&!Di(null,t.fragments,this.media.currentTime,0)&&(this.warn("Subtitle playlist not aligned with playback"),a.details=void 0)}}}_handleFragmentLoadComplete(e){const{frag:i,payload:t}=e;e=i.decryptdata;const n=this.hls;if(!this.fragContextChanged(i)&&t&&0{throw n.trigger(Z.ERROR,{type:j.MEDIA_ERROR,details:G.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:i}),e}).then(e=>{var t=performance.now();n.trigger(Z.FRAG_DECRYPTED,{frag:i,payload:e,stats:{tstart:r,tdecrypt:t}})}).catch(e=>{this.warn(e.name+": "+e.message),this.state=E.IDLE})}}doTick(){if(this.media){if(this.state===E.IDLE){var{currentTrackId:t,levels:i}=this,t=i[t];if(i.length&&t&&t.details){var i=this["config"],n=this.getLoadPosition(),{end:n,len:r}=b.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,i.maxBufferHole),a=this.getFwdBufferInfo(this.media,y),s=t.details,a=this.getMaxBufferLength(null==a?void 0:a.len)+s.levelTargetDuration;if(!(athis.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,-1{Xt(e)}),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){var i,{id:n,details:r}=t,a=this["trackId"],a=this.tracksInGroup[a];a?(i=a.details,a.details=t.details,this.log(`subtitle track ${n} loaded [${r.startSN}-${r.endSN}]`),n===this.trackId&&this.playlistLoaded(n,t,i)):this.warn("Invalid subtitle track id "+n)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){e=this.hls.levels[e];if(null!=e&&e.textGroupIds){const r=e.textGroupIds[e.urlId];var t,i,n,e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.groupId!==r?(t=this.tracks.filter(e=>!r||e.groupId===r),this.tracksInGroup=t,i=this.findTrackId(null==e?void 0:e.name)||this.findTrackId(),this.groupId=r||null,n={subtitleTracks:t},this.log(`Updating subtitle tracks, ${t.length} track(s) found in "${r}" group-id`),this.hls.trigger(Z.SUBTITLE_TRACKS_UPDATED,n),-1!==i&&this.setSubtitleTrack(i,e)):this.shouldReloadPlaylist(e)&&this.setSubtitleTrack(this.trackId,e)}}findTrackId(t){var i=this.tracksInGroup;for(let e=0;ee.groupId===this.groupId),-1===e?[].slice.call(i).forEach(e=>{e.mode="disabled"}):(i=t[n])&&(i.mode="disabled"),n=t[e])&&(n.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,t){var i,n,r,a,s,o=this.tracksInGroup;this.media?(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(-1===e||null!=(i=o[e])&&i.details)||e<-1||e>=o.length||(this.clearTimer(),i=o[e],this.log("Switching to subtitle-track "+e+(i?` "${i.name}" lang:${i.lang} group:`+i.groupId:"")),this.trackId=e,i?({id:o,groupId:n="",name:r,type:a,url:s}=i,this.hls.trigger(Z.SUBTITLE_TRACK_SWITCH,{id:o,groupId:n,name:r,type:a,url:s}),o=this.switchParams(i.url,null==t?void 0:t.details),this.loadPlaylist(o)):this.hls.trigger(Z.SUBTITLE_TRACK_SWITCH,{id:e}))):this.queuedDefaultTrack=e}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){let t=-1;var i=Dr(this.media.textTracks);for(let e=0;e{this.onFragLoaded(Z.FRAG_LOADED,e)}))}getExistingTrack(t){var i=this["media"];if(i)for(let e=0;e{Xt(t[e]),delete t[e]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=Ta(),this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){var e=this["media"];if(e){var t=e.textTracks;if(t)for(let e=0;ee.textCodec===ha);if(this.config.enableWebVTT||i&&this.config.enableIMSC1)if(Lr(this.tracks,t))this.tracks=t;else if(this.textTracks=[],this.tracks=t,this.config.renderTextTracksNatively){const s=this.media?this.media.textTracks:null;this.tracks.forEach((i,e)=>{let n;if(s&&e({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e})),this.hls.trigger(Z.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:i}))}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){var t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),e=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&e)return"captions"}return"subtitles"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{var t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);t&&(t="textTrack"+t[1],t=this.captionsProperties[t])&&(t.label=e.name,e.lang&&(t.languageCode=e.lang),t.media=e)})}closedCaptionsForLevel(e){e=this.hls.levels[e.level];return null==e?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){var i,{cea608Parser1:n,cea608Parser2:r,lastSn:a,lastPartIndex:s}=this;this.enabled&&n&&r&&t.frag.type===y&&(i=t.frag.sn,t=null!=(t=null==t||null==(t=t.part)?void 0:t.index)?t:-1,i===a+1||i===a&&t===s+1||(n.reset(),r.reset()),this.lastSn=i,this.lastPartIndex=t)}onFragLoaded(e,t){var i,n,{frag:r,payload:a}=t;r.type===Yt&&(a.byteLength?(i=r.decryptdata,n="stats"in t,null!=i&&i.encrypted&&!n||(i=this.tracks[r.level],(n=this.vttCCs)[r.cc]||(n[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),i&&i.textCodec===ha?this._parseIMSC1(r,a):this._parseVTTs(t))):this.hls.trigger(Z.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")}))}_parseIMSC1(t,e){const i=this.hls;va(e,this.initPTS[t.cc],e=>{this._appendCues(e,t.level),i.trigger(Z.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},e=>{V.log("Failed to parse IMSC1: "+e),i.trigger(Z.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})})}_parseVTTs(i){var e;const{frag:n,payload:r}=i,{initPTS:t,unparsedVttFrags:a}=this,s=t.length-1;if(t[n.cc]||-1!=s){const o=this.hls;ca(null!=(e=n.initSegment)&&e.data?ht(n.initSegment.data,new Uint8Array(r)):r,this.initPTS[n.cc],this.vttCCs,n.cc,n.start,e=>{this._appendCues(e,n.level),o.trigger(Z.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:n})},e=>{var t="Missing initPTS for VTT MPEGTS"===e.message;t?a.push(i):this._fallbackToIMSC1(n,r),V.log("Failed to parse VTT cue: "+e),t&&s>n.cc||o.trigger(Z.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:e})})}else a.push(i)}_fallbackToIMSC1(e,t){const i=this.tracks[e.level];i.textCodec||va(t,this.initPTS[e.cc],()=>{i.textCodec=ha,this._parseIMSC1(e,t)},()=>{i.textCodec="wvtt"})}_appendCues(e,t){var i=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];r&&"disabled"!==r.mode&&e.forEach(e=>qt(r,e))}else{var n=this.tracks[t];n&&(n=n.default?"default":"subtitles"+t,i.trigger(Z.CUES_PARSED,{type:"subtitles",cues:e,track:n}))}}onFragDecrypted(e,t){var i=t["frag"];i.type===Yt&&this.onFragLoaded(Z.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){var{cea608Parser1:i,cea608Parser2:n}=this;if(this.enabled&&i&&n){var{frag:t,samples:r}=t;if(t.type!==y||"NONE"!==this.closedCaptionsForLevel(t))for(let e=0;eJt(s[e],t,i))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==n){const o=this["textTracks"];Object.keys(o).forEach(e=>Jt(o[e],t,n))}}}extractCea608Data(t){var i=[[],[]],n=31&t[0];let r=2;for(let e=0;ed||s.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),a.currentTime=d+.05),this.getNextFragment(e,r)),i=!1;if(t&&this.isLoopLoading(t,e)&&(i=!!t.gap,t=this.getNextFragmentLoopLoading(t,r,s,y,c)),t){u=n&&t.start>n.end+r.targetduration;if(u||(null==n||!n.len)&&s.len){l=this.getAppendedFrag(t.start,y);if(null===l)return;if(i=i||!!l.gap||!!u&&0===n.len,u&&!i||i&&s.nextStart&&s.nextStartnew fi(e))}onAudioTrackSwitching(e,t){var i=!!t.url,n=(this.trackId=t.id,this)["fragCurrent"];n&&(n.abortRequests(),this.removeUnbufferedFrags(n.start)),this.resetLoadingState(),i?this.setInterval(100):this.resetTransmuxer(),i?(this.switchingTrack=t,this.state=E.IDLE):(this.switchingTrack=null,this.bufferedTrack=t,this.state=E.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(Z.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){if(null==this.mainDetails)this.cachedTrackLoadedData=t;else{var i=this["levels"],{details:t,id:n}=t;if(i){this.log(`Track ${n} loaded [${t.startSN},${t.endSN}]${t.lastPartSn?`[part-${t.lastPartSn}-${t.lastPartIndex}]`:""},duration:`+t.totalduration);i=i[n];let e=0;if(t.live||null!=(r=i.details)&&r.live){this.checkLiveUpdate(t);var r=this.mainDetails;if(t.deltaUpdateFailed||!r)return;e=!i.details&&t.hasProgramDateTime&&r.hasProgramDateTime?(ln(t,r),t.fragments[0].start):this.alignPlaylists(t,i.details)}i.details=t,this.levelLastLoaded=n,this.startFragRequested||!this.mainDetails&&t.live||this.setStartPosition(i.details,e),this.state!==E.WAITING_TRACK||this.waitForCdnTuneIn(t)||(this.state=E.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+n)}}_handleFragmentLoadProgress(t){var{frag:t,part:i,payload:n}=t,{config:r,trackId:a,levels:s}=this;if(s){s=s[a];if(s){var o=s.details;if(o){r=r.defaultAudioCodec||s.audioCodec||"mp4a.40.2";let e=this.transmuxer;e=e||(this.transmuxer=new Er(this.hls,Vt,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var l,u,s=this.initPTS[t.cc],d=null==(d=t.initSegment)?void 0:d.data;void 0!==s?(u=-1!==(l=i?i.index:-1),l=new tn(t.level,t.sn,t.stats.chunkCount,n.byteLength,l,u),e.push(n,d,r,"",t,i,o.totalduration,!1,l,s)):(this.log(`Unknown video PTS for cc ${t.cc}, waiting for video PTS before demuxing audio frag ${t.sn} of [${o.startSN} ,${o.endSN}],track `+a),u=(this.waitingData=this.waitingData||{frag:t,part:i,cache:new Ar,complete:!1})["cache"],u.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=E.WAITING_INIT_PTS)}else this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(t.start)}else this.warn("Audio track is undefined on fragment load progress")}else this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${t.sn} of level ${t.level} will not be buffered`)}_handleFragmentLoadComplete(e){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){var i=t.tracks.audio;i&&(this.mediaBuffer=i.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){var i,{frag:t,part:n}=t;t.type!==Vt?this.loadedmetadata||t.type!==y||(i=this.videoBuffer||this.media)&&b.getBuffered(i).length&&(this.loadedmetadata=!0):this.fragContextChanged(t)?this.warn(`Fragment ${t.sn}${n?" p: "+n.index:""} of level ${t.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: `+(this.switchingTrack?this.switchingTrack.name:"false")):("initSegment"!==t.sn&&(this.fragPrevious=t,i=this.switchingTrack)&&(this.bufferedTrack=i,this.switchingTrack=null,this.hls.trigger(Z.AUDIO_TRACK_SWITCHED,le({},i))),this.fragBufferedComplete(t,n))}onError(e,t){var i;if(t.fatal)this.state=E.ERROR;else switch(t.details){case G.FRAG_GAP:case G.FRAG_PARSING_ERROR:case G.FRAG_DECRYPT_ERROR:case G.FRAG_LOAD_ERROR:case G.FRAG_LOAD_TIMEOUT:case G.KEY_LOAD_ERROR:case G.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(Vt,t);break;case G.AUDIO_TRACK_LOAD_ERROR:case G.AUDIO_TRACK_LOAD_TIMEOUT:case G.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==E.WAITING_TRACK||(null==(i=t.context)?void 0:i.type)!==jt||(this.state=E.IDLE);break;case G.BUFFER_FULL_ERROR:t.parent&&"audio"===t.parent&&this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case G.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushed(e,{type:t}){t===Te&&(this.bufferFlushed=!0,this.state===E.ENDED)&&(this.state=E.IDLE)}_handleTransmuxComplete(e){var t,i,n,r,a,s,o,l,u=this["hls"],{remuxResult:e,chunkMeta:d}=e,c=this.getCurrentContext(d);c?({frag:c,part:t,level:i}=c,i=i.details,{audio:e,text:n,id3:r,initSegment:o}=e,this.fragContextChanged(c)||!i?this.fragmentTracker.removeFragment(c):(this.state=E.PARSING,this.switchingTrack&&e&&this.completeAudioSwitch(this.switchingTrack),null!=o&&o.tracks&&(a=c.initSegment||c,this._bufferInitSegment(o.tracks,a,d),u.trigger(Z.FRAG_PARSING_INIT_SEGMENT,{frag:a,id:"audio",tracks:o.tracks})),e&&({startPTS:a,endPTS:o,startDTS:l,endDTS:s}=e,t&&(t.elementaryStreams[Te]={startPTS:a,endPTS:o,startDTS:l,endDTS:s}),c.setElementaryStreamInfo(Te,a,o,l,s),this.bufferFragmentData(e,c,t,d)),null!=r&&null!=(a=r.samples)&&a.length&&(o=ue({id:"audio",frag:c,details:i},r),u.trigger(Z.FRAG_PARSING_METADATA,o)),n&&(l=ue({id:"audio",frag:c,details:i},n),u.trigger(Z.FRAG_PARSING_USERDATA,l)))):this.resetWhenMissingContext(d)}_bufferInitSegment(e,t,i){var n;this.state===E.PARSING&&(e.video&&delete e.video,n=e.audio)&&(n.levelCodec=n.codec,n.id="audio",this.log(`Init audio buffer, container:${n.container}, codecs[parsed]=[${n.codec}]`),this.hls.trigger(Z.BUFFER_CODECS,e),null!=(e=n.initSegment)&&e.byteLength&&(n={type:"audio",frag:t,part:null,chunkMeta:i,parent:t.type,data:e},this.hls.trigger(Z.BUFFER_APPENDING,n)),this.tick())}loadFragment(e,t,i){var n=this.fragmentTracker.getState(e);this.fragCurrent=e,this.switchingTrack||n===Zi||n===Gi?"initSegment"===e.sn?this._loadInitSegment(e,t):null!=(n=t.details)&&n.live&&!this.initPTS[e.cc]?(this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level `+this.trackId),this.state=E.WAITING_INIT_PTS):(this.startFragRequested=!0,super.loadFragment(e,t,i)):this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){var{hls:t,media:i,bufferedTrack:n}=this,n=null==n?void 0:n.attrs,r=e.attrs;i&&n&&(n.CHANNELS!==r.CHANNELS||n.NAME!==r.NAME||n.LANGUAGE!==r.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(Z.AUDIO_TRACK_SWITCHED,le({},e))}},audioTrackController:class extends Oi{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){var e=this["hls"];e.on(Z.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Z.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Z.LEVEL_LOADING,this.onLevelLoading,this),e.on(Z.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Z.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Z.ERROR,this.onError,this)}unregisterListeners(){var e=this["hls"];e.off(Z.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Z.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Z.LEVEL_LOADING,this.onLevelLoading,this),e.off(Z.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Z.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Z.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){var i,{id:n,groupId:r,details:a}=t,s=this.tracksInGroup[n];s&&s.groupId===r?(i=s.details,s.details=t.details,this.log(`audio-track ${n} "${s.name}" lang:${s.lang} group:${r} loaded [${a.startSN}-${a.endSN}]`),n===this.trackId&&this.playlistLoaded(n,t,i)):this.warn(`Track with id:${n} and group:${r} not found in active group `+s.groupId)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){var t,e=this.hls.levels[e];if(null!=e&&e.audioGroupIds){const i=e.audioGroupIds[e.urlId];this.groupId!==i?(this.groupId=i||null,e=this.tracks.filter(e=>!i||e.groupId===i),this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),t={audioTracks:this.tracksInGroup=e},this.log(`Updating audio tracks, ${e.length} track(s) found in group:`+i),this.hls.trigger(Z.AUDIO_TRACKS_UPDATED,t),this.selectInitialTrack()):this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}}onError(e,t){!t.fatal&&t.context&&t.context.type===jt&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(t))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){var t,i,n,r=this.tracksInGroup;e<0||e>=r.length?this.warn("Invalid id passed to audio-track controller"):(this.clearTimer(),t=this.currentTrack,r[this.trackId],{groupId:i,name:n}=r=r[e],this.log(`Switching to audio-track ${e} "${n}" lang:${r.lang} group:`+i),this.trackId=e,this.currentTrack=r,this.selectDefaultTrack=!1,this.hls.trigger(Z.AUDIO_TRACK_SWITCHING,le({},r)),r.details&&!r.details.live||(n=this.switchParams(r.url,null==t?void 0:t.details),this.loadPlaylist(n)))}selectInitialTrack(){var e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);-1!=t?this.setAudioTrack(t):(t=new Error(`No track found for running audio group-ID: ${this.groupId} track count: `+e.length),this.warn(t.message),this.hls.trigger(Z.ERROR,{type:j.MEDIA_ERROR,details:G.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t}))}findTrackId(t){var i=this.tracksInGroup;for(let e=0;ee!==t))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){t=t.contentSteering;null!==t&&(this.pathwayId=t.pathwayId,this.uri=t.uri,this.started)&&this.startLoad()}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){t=t.errorAction;if((null==t?void 0:t.action)===xi&&t.flags===Pi){let e=this.pathwayPriority;var i=this.pathwayId;this.penalizedPathways[i]||(this.penalizedPathways[i]=performance.now()),(e=!e&&this.levels?this.levels.reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[]):e)&&1t===e.pathwayId)}updatePathwayPriority(t){this.pathwayPriority=t;const i=this.penalizedPathways,n=performance.now();Object.keys(i).forEach(e=>{3e5{const{ID:r,"BASE-ID":t,"URI-REPLACEMENT":a}=e;i.some(e=>e.pathwayId===r)||(e=this.getLevelsForPathway(t).map(e=>{var t=ue({},e),e=(t.details=void 0,t.url=Na(e.uri,e.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),new be(e.attrs)),i=(e["PATHWAY-ID"]=r,e.AUDIO&&e.AUDIO+"_clone_"+r),n=e.SUBTITLES&&e.SUBTITLES+"_clone_"+r,e=(i&&(s[e.AUDIO]=i,e.AUDIO=i),n&&(o[e.SUBTITLES]=n,e.SUBTITLES=n),t.attrs=e,new fi(t));return Ui(e,"audio",i),Ui(e,"text",n),e}),i.push(...e),Pa(this.audioTracks,s,a,r),Pa(this.subtitleTracks,o,a,r))})}}loadSteeringManifest(t){var e=this.hls.config,i=e.loader;this.loader&&this.loader.destroy(),this.loader=new i(e);let s;try{s=new self.URL(t)}catch(e){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+t)}"data:"!==s.protocol&&(i=0|(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate),s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+i));t={responseType:"json",url:s.href},i=e.steeringManifestLoadPolicy.default,e=i.errorRetry||i.timeoutRetry||{},i={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:e.maxNumRetry||0,retryDelay:e.retryDelayMs||0,maxRetryDelay:e.maxRetryDelayMs||0},e={onSuccess:(t,e,i,n)=>{this.log(`Loaded steering manifest: "${s}"`);t=t.data;if(1!==t.VERSION)this.log(`Steering VERSION ${t.VERSION} not supported!`);else{this.updated=performance.now(),this.timeToLoad=t.TTL;var{"RELOAD-URI":t,"PATHWAY-CLONES":r,"PATHWAY-PRIORITY":a}=t;if(t)try{this.uri=new self.URL(t,s).href}catch(e){return this.enabled=!1,void this.log("Failed to parse Steering Manifest RELOAD-URI: "+t)}this.scheduleRefresh(this.uri||i.url),r&&this.clonePathways(r),a&&this.updatePathwayPriority(a)}},onError:(t,i,e,n)=>{if(this.log(`Error loading steering manifest: ${t.code} ${t.text} (${i.url})`),this.stopLoad(),410===t.code)this.enabled=!1,this.log(`Steering manifest ${i.url} no longer available`);else{let e=1e3*this.timeToLoad;429===t.code?("function"==typeof(null==(t=this.loader)?void 0:t.getResponseHeader)&&(t=t.getResponseHeader("Retry-After"))&&(e=1e3*parseFloat(t)),this.log(`Steering manifest ${i.url} rate limited`)):this.scheduleRefresh(this.uri||i.url,e)}},onTimeout:(e,t,i)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log("Requesting steering manifest: "+s),this.loader.load(t,i,e)}scheduleRefresh(e,t=1e3*this.timeToLoad){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(e)},t)}}});function Ya(i){return i&&"object"==typeof i?Array.isArray(i)?i.map(Ya):Object.keys(i).reduce((e,t)=>(e[t]=Ya(i[t]),e),{}):i}function Ha(e){var t=e.loader;t!==Ua&&t!==Ba?(V.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=Ua,e.progressive=!0,e.enableSoftwareAES=!0,V.log("[config]: Progressive streaming enabled, using FetchLoader"))}class p{static get version(){return"1.4.13"}static isSupported(){return!!(t=Mt())&&(e=gn(),t=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),e=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove,!!t)&&!!e;var e,t}static get Events(){return Z}static get ErrorTypes(){return j}static get ErrorDetails(){return G}static get DefaultConfig(){return p.defaultConfig||Va}static set DefaultConfig(e){p.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new yr,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null;var t=e.debug||!1,i="Hls instance";if(self.console&&!0===t||"object"==typeof t){ve(t,"debug","log","info","warn","error");try{ge.log(`Debug logs enabled for "${i}" in hls.js version 1.4.13`)}catch(e){ge=pe}}else ge=pe;var t=this.config=function(e,l){if((l.liveSyncDurationCount||l.liveMaxLatencyDurationCount)&&(l.liveSyncDuration||l.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==l.liveMaxLatencyDurationCount&&(void 0===l.liveSyncDurationCount||l.liveMaxLatencyDurationCount<=l.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==l.liveMaxLatencyDuration&&(void 0===l.liveSyncDuration||l.liveMaxLatencyDuration<=l.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const u=Ya(e),t=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(r=>{const a=`${"level"===r?"playlist":r}LoadPolicy`,s=void 0===l[a],o=[];t.forEach(e=>{var t=r+"Loading"+e,i=l[t];if(void 0!==i&&s){o.push(t);var n=u[a].default;switch(l[a]={default:n},e){case"TimeOut":n.maxLoadTimeMs=i,n.maxTimeToFirstByteMs=i;break;case"MaxRetry":n.errorRetry.maxNumRetry=i,n.timeoutRetry.maxNumRetry=i;break;case"RetryDelay":n.errorRetry.retryDelayMs=i,n.timeoutRetry.retryDelayMs=i;break;case"MaxRetryTimeout":n.errorRetry.maxRetryDelayMs=i,n.timeoutRetry.maxRetryDelayMs=i}}}),o.length&&V.warn(`hls.js config: "${o.join('", "')}" setting(s) are deprecated, use "${a}": `+JSON.stringify(l[a]))}),le(le({},u),l)}(p.DefaultConfig,e),{abrController:i,bufferController:e,capLevelController:n,errorController:r,fpsController:a}=(this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&Ha(t),t),r=new r(this),i=this.abrController=new i(this),e=this.bufferController=new e(this),n=this.capLevelController=new n(this),a=new a(this),s=new Kt(this),o=new si(this),l=t.contentSteeringController,l=l?new l(this):null,u=this.levelController=new Fi(this,l),d=new Yi(this),c=new $i(this.config),h=this.streamController=new Tr(this,d,c),s=(n.setStreamController(h),a.setStreamController(h),[s,u,h]),u=(l&&s.splice(1,0,l),this.networkControllers=s,[i,e,n,a,o,d]),h=(this.audioTrackController=this.createController(t.audioTrackController,s),t.audioStreamController),l=(h&&s.push(new h(this,d,c)),this.subtitleTrackController=this.createController(t.subtitleTrackController,s),t.subtitleStreamController),i=(l&&s.push(new l(this,d,c)),this.createController(t.timelineController,u),c.emeController=this.emeController=this.createController(t.emeController,u),this.cmcdController=this.createController(t.cmcdController,u),this.latencyController=this.createController(oi,u),this.coreComponents=u,s.push(r),r.onErrorOut);"function"==typeof i&&this.on(Z.ERROR,i,r)}createController(e,t){return e?(e=new e(this),t&&t.push(e),e):null}on(e,t,i=this){this._emitter.on(e,t,i)}once(e,t,i=this){this._emitter.once(e,t,i)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,i=this,n){this._emitter.off(e,t,i,n)}listeners(e){return this._emitter.listeners(e)}emit(e,t,i){return this._emitter.emit(e,t,i)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){V.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.trigger(Z.ERROR,{type:j.OTHER_ERROR,details:G.INTERNAL_EXCEPTION,fatal:!1,event:t,error:e})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){V.log("destroy"),this.trigger(Z.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;var e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){V.log("attachMedia"),this._media=e,this.trigger(Z.MEDIA_ATTACHING,{media:e})}detachMedia(){V.log("detachMedia"),this.trigger(Z.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();var t=this.media,i=this.url,n=this.url=se.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});V.log("loadSource:"+n),t&&i&&(i!==n||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(Z.MANIFEST_LOADING,{url:e})}startLoad(t=-1){V.log(`startLoad(${t})`),this.networkControllers.forEach(e=>{e.startLoad(t)})}stopLoad(){V.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){V.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){V.log("recoverMediaError");var e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){var e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){V.log("set currentLevel:"+e),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){V.log("set nextLevel:"+e),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){V.log("set loadLevel:"+e),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){V.log("set firstLevel:"+e),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){V.log("set startLevel:"+e),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){e=!!e;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){var e=this.abrController["bwEstimator"];return e?e.getEstimate():NaN}get ttfbEstimate(){var e=this.abrController["bwEstimator"];return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(V.log("set autoLevelCapping:"+e),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){-1=i)return e}return 0}get maxAutoLevel(){var{levels:t,autoLevelCapping:e,maxHdcpLevel:i}=this;let n;if(n=-1===e&&t&&t.length?t.length-1:e,i)for(let e=n;e--;){var r=t[e].attrs["HDCP-LEVEL"];if(r&&r<=i)return e}return n}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){var e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){var e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){var t=this.audioTrackController;t&&(t.audioTrack=e)}get subtitleTracks(){var e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){var e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){var t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){var e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){var t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}p.defaultConfig=void 0;function Wa(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}self,i=function(){return Q={3774:function(e,t,i){i.d(t,{J:function(){return n},c:function(){return r}});var t=i(1946),i=i(2203).Z?void 0:window,n=void 0===i?void 0:(0,t.Z)(i.MediaSource)?(0,t.Z)(i.MozMediaSource)?(0,t.Z)(i.WebKitMediaSource)?i.MSMediaSource:i.WebKitMediaSource:i.MozMediaSource:i.MediaSource,r={HAVE_NOTHING:0,HAVE_METADATA:1,HAVE_CURRENT_DATA:2,HAVE_FUTURE_DATA:3,HAVE_ENOUGH_DATA:4}},3666:function(e,t,i){i.d(t,{$u:function(){return c},SB:function(){return l},YM:function(){return a},fq:function(){return r},kD:function(){return n},lV:function(){return f},l_:function(){return h},op:function(){return u},vS:function(){return o},vU:function(){return s},yS:function(){return d}});var t=i(2203),n=!1,r=!1,a=!1,s=!1,o=!1,l=!1,u=!1,d=!1,c=!1,h=!1,f=!1;t.Z||(void 0!==window.MSInputMethodContext&&void 0!==document.documentMode?a=r=!0:"Microsoft Internet Explorer"===navigator.appName||"Netscape"===navigator.appName&&/(Trident|Edge)\//.test(navigator.userAgent)?a=!0:-1!==navigator.userAgent.toLowerCase().indexOf("edg/")?n=!0:-1!==navigator.userAgent.toLowerCase().indexOf("firefox")?s=!0:"string"==typeof navigator.platform&&/iPad|iPhone|iPod/.test(navigator.platform)?l=!0:(0<=Object.prototype.toString.call(window.HTMLElement).indexOf("Constructor")||"[object SafariRemoteNotification]"===(null==(i=null==(i=window.safari)?void 0:i.pushNotification)?void 0:i.toString()))&&(o=!0),/SamsungBrowser/.test(navigator.userAgent)&&(u=!0),-1!==navigator.userAgent.indexOf("PlayStation 5")?f=!0:/Tizen/.test(navigator.userAgent)?d=!0:/[Ww]eb[O0]S/.test(navigator.userAgent)?(c=!0,/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\/87/.test(navigator.userAgent)||/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\/79/.test(navigator.userAgent)):/[Pp]anasonic/.test(navigator.userAgent)&&(h=!0))},5767:function(e,t,i){i.d(t,{Z:function(){return n}});var a=i(3887),s=i(1946);function n(e){var t=e.textTracks;if(!(0,s.Z)(t)){for(var i=0;i=t.length||(t[i].enabled=!0)},e}(t.Z);function c(e){for(var t=0;te.length)return x.Z.warn("Compat: Unrecognized initialization data. Use as is."),[{systemId:void 0,data:e}];var r=e.subarray(i,i+n),r={systemId:(0,X.Y)(r,8),data:r};!function(e,t){for(var i=0;i=t.getLength())return e.abrupt("return");e.next=2;break;case 2:for(x.Z.info("DRM: LSS cache limit exceeded",i,t.getLength()),n=[],r=t.getAll().slice(),a=r.length-i,s=0;s=s.length)throw new P.Z("INCOMPATIBLE_KEYSYSTEMS","No key system compatible with your wanted configuration has been found in the current browser.");e.next=2;break;case 2:if(null==E.requestMediaKeySystemAccess)throw new Error("requestMediaKeySystemAccess is not implemented in your browser.");e.next=4;break;case 4:return n=s[t],r=n.keyName,i=n.keyType,n=n.keySystemOptions,r=function(e,t,i){var n=["temporary"],r="optional",a="optional";!0===i.persistentLicense&&(r="required",n.push("persistent-license")),!0===i.persistentStateRequired&&(r="required"),!0===i.distinctiveIdentifierRequired&&(a="required");var s=(u=R.Z.getCurrent()).EME_DEFAULT_AUDIO_CODECS,o=u.EME_DEFAULT_VIDEO_CODECS,l=u.EME_DEFAULT_WIDEVINE_ROBUSTNESSES,u=u.EME_DEFAULT_PLAYREADY_ROBUSTNESSES,d=(0,b.Z)(i.videoRobustnesses)?"widevine"===e?l:"com.microsoft.playready.recommendation"===t?u:[]:i.videoRobustnesses,e=(0,b.Z)(i.audioRobustnesses)?"widevine"===e?l:"com.microsoft.playready.recommendation"===t?u:[]:i.audioRobustnesses;return 0===d.length&&d.push(void 0),0===e.length&&e.push(void 0),[l={initDataTypes:["cenc"],videoCapabilities:(0,ue.Z)(d,function(t){return o.map(function(e){return void 0===t?{contentType:e}:{contentType:e,robustness:t}})}),audioCapabilities:(0,ue.Z)(e,function(t){return s.map(function(e){return void 0===t?{contentType:e}:{contentType:e,robustness:t}})}),distinctiveIdentifier:a,persistentState:r,sessionTypes:n},Object.assign(Object.assign({},l),{audioCapabilities:void 0,videoCapabilities:void 0})]}(r,i,n),x.Z.debug("DRM: Request keysystem access "+i+","+(t+1)+" of "+s.length),e.prev=7,e.next=10,E.requestMediaKeySystemAccess(i,r);case 10:return r=e.sent,x.Z.info("DRM: Found compatible keysystem",i,t+1),e.abrupt("return",{type:"create-media-key-system-access",value:{options:n,mediaKeySystemAccess:r}});case 15:if(e.prev=15,e.t0=e.catch(7),x.Z.debug("DRM: Rejected access to keysystem",i,t+1),null!==a.cancellationError)throw a.cancellationError;e.next=20;break;case 20:return e.abrupt("return",o(t+1));case 21:case"end":return e.stop()}},e,null,[[7,15]])}))).apply(this,arguments)}}var he=t(2297);function fe(t,e,i){var n;x.Z.debug("Compat: Calling generateRequest on the MediaKeySession");try{n=function(e){x.Z.info("Compat: Trying to move CENC PSSH from init data at the end of it.");for(var t=!1,i=new Uint8Array,n=new Uint8Array,r=0;re.length)throw x.Z.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");var s,o=e.subarray(r,r+a);16===e[r+12]&&119===e[r+13]&&239===e[r+14]&&236===e[r+15]&&192===e[r+16]&&178===e[r+17]&&77===e[r+18]&&2===e[r+19]&&172===e[r+20]&&227===e[r+21]&&60===e[r+22]&&30===e[r+23]&&82===e[r+24]&&226===e[r+25]&&251===e[r+26]&&75===e[r+27]?(s=null===(s=(0,he.Xj)(o))?void 0:o[s[1]],x.Z.info("Compat: CENC PSSH found with version",s),void 0===s?x.Z.warn("Compat: could not read version of CENC PSSH"):t===(1===s)?i=(0,m.zo)(i,o):1===s?(x.Z.warn("Compat: cenc version 1 encountered, removing every other cenc pssh box."),i=o,t=!0):x.Z.warn("Compat: filtering out cenc pssh box with wrong version",s)):n=(0,m.zo)(n,o),r+=a}if(r!==e.length)throw x.Z.warn("Compat: unrecognized initialization data. Cannot patch it."),new Error("Compat: unrecognized initialization data. Cannot patch it.");return(0,m.zo)(n,i)}(i)}catch(e){n=i}var r=null!=e?e:"";return t.generateRequest(r,n).catch(function(e){if(""===r&&e instanceof TypeError)return x.Z.warn('Compat: error while calling `generateRequest` with an empty initialization data type. Retrying with a default "cenc" value.',e),t.generateRequest("cenc",n);throw e})}var pe=100;function ge(){return ve.apply(this,arguments)}function ve(){return(ve=(0,y.Z)(k().mark(function e(n,t){var r;return k().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return x.Z.info("DRM: Load persisted session",t),e.next=3,n.load(t);case 3:if(!(r=e.sent)||0=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function we(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Le(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ce(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=o)throw e.t0;e.next=15;break;case 15:return"function"==typeof u&&u(e.t0,d),t=Math.min(a*Math.pow(2,d-1),s),i=(0,Fe.Z)(t),e.next=20,(0,Ue.Z)(i);case 20:return i=c(),e.abrupt("return",i);case 22:case"end":return e.stop()}},e,null,[[2,9]])}))).apply(this,arguments)}n=function(){return a=t,s=i,new Promise(function(t,i){try{x.Z.debug("DRM: Calling `getLicense`",s);var e=p.getLicense(a,s),n=(0,b.Z)(v.timeout)?1e4:v.timeout;0<=n&&(o=setTimeout(function(){i(new Je('"getLicense" timeout exceeded ('+n+" ms)"))},n)),Promise.resolve(e).then(function(e){void 0!==o&&clearTimeout(o);t(e)},r)}catch(e){r(e)}function r(e){void 0!==o&&clearTimeout(o),i(e)}});var a,s,o},r=m.signal,a=e.baseDelay,s=e.maxDelay,o=e.totalRetry,l=e.shouldRetry,u=e.onRetry,d=0,c().then(function(e){if(m.isUsed())return Promise.resolve();if((0,b.Z)(e))x.Z.info("DRM: No license given, skipping session.update");else try{return Qe(f,e)}catch(e){m.cancel(),g.onError(e)}}).catch(function(e){if(!m.isUsed()){m.cancel();var t=Ke(e);if(!(0,b.Z)(e))if(!0===e.fallbackOnLastTry)return x.Z.warn("DRM: Last `getLicense` attempt failed. Blacklisting the current session."),void g.onError(new Xe(t));g.onError(t)}})},m.signal),a()}function Ke(e){var t;return e instanceof Je?new P.Z("KEY_LOAD_TIMEOUT","The license server took too much time to respond."):(t=new P.Z("KEY_LOAD_ERROR","An error occured when calling `getLicense`."),!(0,b.Z)(e)&&(0,M.Z)(e.message)&&(t.message=e.message),t)}function Qe(){return qe.apply(this,arguments)}function qe(){return(qe=(0,y.Z)(k().mark(function e(t,i){var n;return k().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return x.Z.info("DRM: Updating MediaKeySession with message"),e.prev=1,e.next=4,t.update(i);case 4:e.next=10;break;case 6:throw e.prev=6,e.t0=e.catch(1),n=e.t0 instanceof Error?e.t0.toString():"`session.update` failed",new P.Z("KEY_UPDATE_ERROR",n);case 10:x.Z.info("DRM: MediaKeySession update succeeded.");case 11:case"end":return e.stop()}},e,null,[[1,6]])}))).apply(this,arguments)}var Xe=function(i){function n(e){var t=i.call(this)||this;return Object.setPrototypeOf((0,Be.Z)(t),n.prototype),t.sessionError=e,t}return(0,a.Z)(n,i),n}((0,i.Z)(Error)),Je=function(i){function e(e){var t=i.call(this)||this;return Object.setPrototypeOf((0,Be.Z)(t),Xe.prototype),t.message=e,t}return(0,a.Z)(e,i),e}((0,i.Z)(Error)),$e=t(9822);function et(){return(et=(0,y.Z)(k().mark(function e(t,i){var n;return k().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.setServerCertificate(i);case 3:return n=e.sent,e.abrupt("return",n);case 7:throw e.prev=7,e.t0=e.catch(0),x.Z.warn("DRM: mediaKeys.setServerCertificate returned an error",e.t0 instanceof Error?e.t0:""),n=e.t0 instanceof Error?e.t0.toString():"`setServerCertificate` error",new P.Z("LICENSE_SERVER_CERTIFICATE_ERROR",n);case 12:case"end":return e.stop()}},e,null,[[0,7]])}))).apply(this,arguments)}function tt(){return(tt=(0,y.Z)(k().mark(function e(t,i){var n;return k().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!0===I.hasOne(t))return x.Z.info("DRM: The MediaKeys already has a server certificate, skipping..."),e.abrupt("return",{type:"already-has-one"});e.next=3;break;case 3:if("function"!=typeof t.setServerCertificate)return x.Z.warn("DRM: Could not set the server certificate. mediaKeys.setServerCertificate is not a function"),e.abrupt("return",{type:"method-not-implemented"});e.next=6;break;case 6:return x.Z.info("DRM: Setting server certificate on the MediaKeys"),I.prepare(t),e.prev=8,e.next=11,function(){return et.apply(this,arguments)}(t,i);case 11:return n=e.sent,I.set(t,i),e.abrupt("return",{type:"success",value:n});case 16:return e.prev=16,e.t0=e.catch(8),n=(0,$e.Z)(e.t0)?e.t0:new P.Z("LICENSE_SERVER_CERTIFICATE_ERROR","Unknown error when setting the server certificate."),e.abrupt("return",{type:"error",value:n});case 20:case"end":return e.stop()}},e,null,[[8,16]])}))).apply(this,arguments)}var D=t(4339);var it=function(){function t(e){this._innerValues=e,this._lazyFormattedValues=null}var e=t.prototype;return e.constructRequestData=function(){return m.zo.apply(void 0,this._innerValues.map(function(e){return e.data}))},e.isCompatibleWith=function(e){e=e instanceof t?e.getFormattedValues():e;return ke(this.getFormattedValues(),e)},e.getFormattedValues=function(){return null===this._lazyFormattedValues&&(this._lazyFormattedValues=this._innerValues.slice().sort(function(e,t){return e.systemId===t.systemId?0:void 0!==e.systemId&&(void 0===t.systemId||e.systemId=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function nt(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=i.getLength()||(r=i.getLength(),x.Z.info("DRM: Too many stored persistent sessions, removing some.",r,r=r-n),i.deleteOldSessions(r)),t.add(a,E.record.getAssociatedKeyIds(),T),M=!0),void 0!==a.content&&B(a.content.manifest,e.whitelisted,e.blacklisted,[]),D._unlockInitDataQueue()},onWarning:function(e){D.trigger("warning",e)},onError:function(e){var t;e instanceof Ze?(x.Z.warn("DRM: A session's closing condition has been triggered"),D._lockInitDataQueue(),0<=(t=D._currentSessions.indexOf(E))&&D._currentSessions.splice(t),void 0!==a.content&&B(a.content.manifest,[],[],E.record.getAssociatedKeyIds()),null!=(t=s.persistentSessionsStore)&&t.delete(T.sessionId),s.loadedSessionsStore.closeSession(T).catch(function(e){e=e instanceof Error?e:"unknown error";x.Z.warn("DRM: failed to close expired session",e)}).then(function(){return D._unlockInitDataQueue()}).catch(function(e){return D._onFatalError(e)}),D._isStopped()||D.trigger("warning",e.reason)):e instanceof Xe?(E.blacklistedSessionError=e,void 0!==a.content&&(t=a.content.manifest,x.Z.info("DRM: blacklisting Representations based on protection data."),rt(t,a)),D._unlockInitDataQueue()):D._onFatalError(e)}},this._canceller.signal),void 0!==o.singleLicensePer&&"init-data"!==o.singleLicensePer||this._unlockInitDataQueue(),"created-session"===b.type)return A=a.values.constructRequestData(),e.prev=59,e.next=62,s.loadedSessionsStore.generateLicenseRequest(T,a.type,A);e.next=72;break;case 62:e.next=72;break;case 64:if(e.prev=64,e.t1=e.catch(59),null===(L=s.loadedSessionsStore.getEntryForSession(T))||"none"!==L.closingStatus.type)return 0<=(I=this._currentSessions.indexOf(E))&&this._currentSessions.splice(I,1),e.abrupt("return",Promise.resolve());e.next=71;break;case 71:throw new P.Z("KEY_GENERATE_REQUEST_ERROR",e.t1 instanceof Error?e.t1.toString():"Unknown error");case 72:return e.abrupt("return",Promise.resolve());case 73:case"end":return e.stop()}},e,this,[[59,64]])}));return function(e,t){return i.apply(this,arguments)}}(),t._tryToUseAlreadyCreatedSession=function(t,e){var i=e.stores,e=e.options,n=(0,te.Z)(this._currentSessions,function(e){return e.record.isCompatibleWith(t)});if(void 0!==n){var r=n.blacklistedSessionError;if(!(0,b.Z)(r))return void 0===t.type||void 0===t.content?x.Z.error("DRM: This initialization data has already been blacklisted but the current content is not known."):(x.Z.info("DRM: This initialization data has already been blacklisted. Blacklisting the related content."),rt(t.content.manifest,t)),!0;if(void 0!==t.keyIds)if(void 0===e.singleLicensePer||"init-data"===e.singleLicensePer?(r=n.keyStatuses.blacklisted,Se(t.keyIds,r)):(e=n.keyStatuses.whitelisted,!T(t.keyIds,e)))return void 0===t.content?x.Z.error("DRM: Cannot forbid key id, the content is unknown."):(x.Z.info("DRM: Current initialization data is linked to blacklisted keys. Marking Representations as not decipherable"),B(t.content.manifest,[],t.keyIds,[])),!0;if(null!==i.loadedSessionsStore.reuse(t))return x.Z.debug("DRM: Init data already processed. Skipping it."),!0;r=this._currentSessions.indexOf(n);-1===r?x.Z.error("DRM: Unable to remove processed init data: not found."):(x.Z.debug("DRM: A session from a processed init data is not available anymore. Re-processing it."),this._currentSessions.splice(r,1))}return!1},t._onFatalError=function(e){this._canceller.isUsed()||(e=e instanceof Error?e:new ee.Z("NONE","Unknown decryption error"),this.error=e,this._initDataQueue.length=0,this._stateData={state:D.u.Error,isMediaKeysAttached:void 0,isInitDataQueueLocked:void 0,data:null},this._canceller.cancel(),this.trigger("error",e),this._stateData.state===D.u.Error&&this.trigger("stateChange",this._stateData.state))},t._isStopped=function(){return this._stateData.state===D.u.Disposed||this._stateData.state===D.u.Error},t._processCurrentInitDataQueue=function(){for(;!1===this._stateData.isInitDataQueueLocked;){var e=this._initDataQueue.shift();if(void 0===e)return;this.onInitializationData(e)}},t._lockInitDataQueue=function(){!1===this._stateData.isInitDataQueueLocked&&(this._stateData.isInitDataQueueLocked=!0)},t._unlockInitDataQueue=function(){2!==this._stateData.isMediaKeysAttached?x.Z.error("DRM: Trying to unlock in the wrong state"):(this._stateData.isInitDataQueueLocked=!1,this._processCurrentInitDataQueue())},e}(e.Z)},4339:function(e,t,i){var n;i.d(t,{u:function(){return n}}),(i=n=n||{})[i.Initializing=0]="Initializing",i[i.WaitingForAttachment=1]="WaitingForAttachment",i[i.ReadyForContent=2]="ReadyForContent",i[i.Error=3]="Error",i[i.Disposed=4]="Disposed"},770:function(e,t){var i=new WeakMap;t.Z={setState:function(e,t){i.set(e,t)},getState:function(e){e=i.get(e);return void 0===e?null:e},clearState:function(e){i.set(e,null)}}},9372:function(e,t,i){i.d(t,{Z:function(){return a}});var n=i(4578),d=i(5767),c=i(3887),h=i(811),f=i(5095),r=i(288),t=i(9420),o=i(379),l=i(8833),p=i(7794),g=i(6199),v=i(4576),a=function(i){function e(e){var t=i.call(this)||this;return t._settings=e,t._initCanceller=new r.ZP,t}(0,n.Z)(e,i);var t=e.prototype;return t.prepare=function(){},t.start=function(i,n){var r=this,a=this._initCanceller.signal,e=this._settings,t=e.keySystems,s=e.speed,o=e.url,e=((0,d.Z)(i),new f.Z(null)),l=(e.finish(),(0,p.Z)(i,t,e,{onError:function(e){return r._onFatalError(e)},onWarning:function(e){return r.trigger("warning",e)}},a)),u=((0,v.Z)(i,function(e){return r._onFatalError(e)},a),new g.Z(n,null,s));u.addEventListener("stalled",function(e){return r.trigger("stalled",e)}),u.addEventListener("unstalled",function(){return r.trigger("unstalled",null)}),u.addEventListener("warning",function(e){return r.trigger("warning",e)}),a.register(function(){u.destroy()}),u.start(),l.onUpdate(function(e,t){"uninitialized"!==e.initializationState.type&&(t(),c.Z.info("Setting URL to HTMLMediaElement",o),i.src=o,a.register(function(){c.Z.info("Init: Removing directfile src from media element",i.src),(0,d.Z)(i)}),"awaiting-media-link"===e.initializationState.type?(e.initializationState.value.isMediaLinked.setValue(!0),l.onUpdate(function(e,t){"initialized"===e.initializationState.type&&(t(),r._seekAndPlay(i,n))},{emitCurrentValue:!0,clearSignal:a})):((0,h.Z)("initialized"===e.initializationState.type),r._seekAndPlay(i,n)))},{emitCurrentValue:!0,clearSignal:a})},t.updateContentUrls=function(e,t){throw new Error("Cannot update content URL of directfile contents")},t.dispose=function(){this._initCanceller.cancel()},t._onFatalError=function(e){this._initCanceller.cancel(),this.trigger("error",e)},t._seekAndPlay=function(t,e){var i=this,n=this._initCanceller.signal,r=this._settings,a=r.autoPlay,s=r.startAt;(0,l.Z)(t,e,function(){c.Z.debug("Init: Calculating initial time");var e=function(e,t){if(null!=t){if(null!=t.position)return t.position;if(null!=t.wallClockTime)return t.wallClockTime;if(null!=t.fromFirstPosition)return t.fromFirstPosition;e=e.duration;if(null!=e&&isFinite(e)){if("number"==typeof t.fromLastPosition)return Math.max(0,e+t.fromLastPosition);if(null!=t.percentage)return 100<=(t=t.percentage)?e:t<=0?0:e*(+t/100)}else c.Z.warn("startAt.fromLastPosition set but no known duration, beginning at 0.")}return 0}(t,s);return c.Z.debug("Init: Initial time calculated:",e),e},a,function(e){return i.trigger("warning",e)},n).autoPlayResult.then(function(){return(0,o.Z)(e,t,!0,n).onUpdate(function(e,t){e&&(t(),i.trigger("loaded",{segmentBuffersStore:null}))},{emitCurrentValue:!0,clearSignal:n})}).catch(function(e){n.isCancelled()||i._onFatalError(e)})},e}(t.K)},7117:function(l,e,t){t.d(e,{Z:function(){return Gt}});var I=t(5861),o=t(4578),e=t(4687),D=t.n(e);var O=t(6872),x=t(3714),B=t(3887),k=t(811),u=t(7733),C=t(8026),F=t(5095),U=t(288),z=t(8894),Z=t(2829),j=t(5278),G=t(5138);function p(n){var t=n.map(function(e){return Math.log(e/n[0])}),r=t.map(function(e){return e-t[0]+1}),a=(r[r.length-1]-1)/(2*n.length+10),s=1/a;return n.map(function(e,t){return function e(t){if(0===t)return 0;var i=Math.min(Math.max(1,t),n.length-1);if(n[i]===n[i-1])return e(t-1);return s*(a+(n[i]*r[i-1]-n[i-1]*r[i])/(n[i]-n[i-1]))+4}(t)})}var H=function(){function e(i){this._levelsMap=p(i).map(function(e){return e+4}),this._bitrates=i,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=6e3,B.Z.debug("ABR: Steps for buffer based chooser.",this._levelsMap.map(function(e,t){return"bufferLevel: "+e+", bitrate: "+i[t]}).join(" ,"))}var t=e.prototype;return t.onAddedSegment=function(e){var t=this._levelsMap,i=this._bitrates,n=e.bufferGap,r=e.currentBitrate,a=e.currentScore,e=e.speed;if(null==r)this._currentEstimate=i[0];else{for(var s=-1,o=0;o=t[c])return void(this._currentEstimate=i[c]);this._currentEstimate=i[0]}else{if(!(void 0!==this._lastUnsuitableQualityTimestamp&&e-this._lastUnsuitableQualityTimestamph)return e}();if(void 0!==f&&t[f]<=n)return B.Z.debug("ABR: Raising quality in BufferBasedChooser",i[f]),void(this._currentEstimate=i[f])}this._currentEstimate=r}}}},t.getLastEstimate=function(){return this._currentEstimate},e}(),V=t(3274),s=function(){function e(e){this._alpha=Math.exp(Math.log(.5)/e),this._lastEstimate=0,this._totalWeight=0}var t=e.prototype;return t.addSample=function(e,t){var i=Math.pow(this._alpha,e),t=t*(1-i)+i*this._lastEstimate;isNaN(t)||(this._lastEstimate=t,this._totalWeight+=e)},t.getEstimate=function(){var e=1-Math.pow(this._alpha,this._totalWeight);return this._lastEstimate/e},e}();function d(e){if(!(e.progress.length<5)){for(var t=new s(2),i=e.progress,n=1;n=o.outOfStarvationGap&&(B.Z.info("ABR: exit starvation mode."),this._inStarvationMode=!1):this._inStarvationMode&&(B.Z.info("ABR: exit starvation mode."),this._inStarvationMode=!1),this._inStarvationMode&&null!=(s=v(n,e,i,this._lowLatencyMode,r))&&(B.Z.info("ABR: starvation mode emergency estimate:",s),t.reset(),a=null==i?s:Math.min(s,i.bitrate)),null==a&&(a=null!=(s=t.getEstimate())?s*(this._inStarvationMode?o.starvationBitrateFactor:o.regularBitrateFactor):null!=r?r*(this._inStarvationMode?o.starvationBitrateFactor:o.regularBitrateFactor):this._initialBitrate),1=t.bitrate)&&(e=n,t=i,!!(n=this._lowLatencyMode)||(n=isFinite(e.bufferGap)?e.bufferGap:0,r=e.position.last+n,void 0===(t=(0,V.Z)(t,function(e){e=e.content;return 0r})))||(i=performance.now(),a=01.2*t)||-1.5=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function b(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);is.bitrate)return 2===this._lastAbrEstimate.algorithmType&&(null!==this._lastAbrEstimate.representation&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;var o=this._scoreCalculator.getEstimate(i);if(2!==this._lastAbrEstimate.algorithmType){if(void 0!==o&&this._canGuessHigher(a,t,o)){var l=T(e,i);if(null!==l)return l}return null}if(this._isLastGuessValidated(s,n,o)&&(B.Z.debug("ABR: Guessed Representation validated",s.bitrate),this._lastMaintanableBitrate=s.bitrate,this._consecutiveWrongGuesses=0),i.id!==s.id)return s;if(this._shouldStopGuess(i,o,a,r)){this._consecutiveWrongGuesses++,this._blockGuessesUntil=performance.now()+Math.min(15e3*this._consecutiveWrongGuesses,12e4);var u=e,d=i,c=(0,G.Z)(u,function(e){return e.id===d.id});if(c<0)B.Z.error("ABR: Current Representation not found.");else for(;0<=--c;)if(u[c].bitratethis._blockGuessesUntil&&1===i&&1.011e3*s.content.segment.duration+200)return!0;o=d(s);if(void 0!==o&&o<.8*t.bitrate)return!0}}return!1},t._isLastGuessValidated=function(e,t,i){return void 0!==i&&1===i.confidenceLevel&&1.5=e.bitrate&&(null===this._lastMaintanableBitrate||this._lastMaintanableBitratet.bitrate)return e[n];return null}var Q=function(){function e(){var e=O.Z.getCurrent(),t=e.ABR_FAST_EMA,e=e.ABR_SLOW_EMA;this._fastEWMA=new s(t),this._slowEWMA=new s(e),this._bytesSampled=0}var t=e.prototype;return t.addSample=function(e,t){var i;tr});return-1===i?e[e.length-1]:0===i?e[0]:e[i-1]}var $=new F.Z(-1),ee=($.finish(),new F.Z(0)),te=(ee.finish(),new F.Z(1/0)),ie=(te.finish(),new F.Z(void 0)),ne=(ie.finish(),new F.Z(1/0));ne.finish();var re=function(e){var y={},_=e.manualBitrates,x=e.minAutoBitrates,C=e.maxAutoBitrates,R=e.initialBitrates,P=e.throttlers,N=e.lowLatencyMode;return function(e,t,i,n,r){var a,b,E,S,T,w,M,A,L,s,o,I,D,k,l,u,d,c=e.adaptation.type,h=function(e){var t=y[e];if(null!=t)return t;B.Z.debug("ABR: Creating new BandwidthEstimator for ",e);t=new Q;return y[e]=t}(c),f=(0,j.Z)(_[c],$),p=(0,j.Z)(x[c],ee),g=(0,j.Z)(C[c],te),v=(0,j.Z)(R[c],0),c={limitWidth:(0,j.Z)(P.limitWidth[c],ie),throttleBitrate:(0,j.Z)(P.throttleBitrate[c],P.throttle[c],ne)};return a=r,b=(r={bandwidthEstimator:h,context:e,currentRepresentation:t,filters:c,initialBitrate:v,manualBitrate:f,minAutoBitrate:p,maxAutoBitrate:g,playbackObserver:n,representations:i,lowLatencyMode:N}).bandwidthEstimator,E=r.context,S=r.currentRepresentation,T=r.filters,h=r.initialBitrate,w=r.lowLatencyMode,M=r.manualBitrate,A=r.maxAutoBitrate,L=r.minAutoBitrate,s=r.playbackObserver,o=r.representations,I=new J,D=new W(null!=h?h:0,w),k=new X,l=z.Z,r={metrics:function(e){var t=e.requestDuration,i=e.segmentDuration,n=e.size,e=e.content;b.addSample(t,n),!e.segment.isInit&&(n=e.segment,e=e.representation,void 0!==i||n.complete)&&(i=null!=i?i:n.duration,I.addSample(e,t/1e3,i))},requestBegin:function(e){k.add(e)},requestProgress:function(e){k.addProgress(e)},requestEnd:function(e){k.remove(e.id)},addedSegment:function(e){l(e)}},(u=new U.ZP).linkToSignal(a),d=m(o.getValue(),u.signal),o.onUpdate(function(){var e=o.getValue();u.cancel(),(u=new U.ZP).linkToSignal(a),m(e,u.signal).onUpdate(function(e){d.setValue(e)},{clearSignal:u.signal,emitCurrentValue:!0})},{clearSignal:a}),{estimates:d,callbacks:r};function m(f,e){var p,g,v,m,y,t;return 0===f.length?new F.Z({representation:null,bitrate:void 0,knownStableBitrate:void 0,manual:!1,urgent:!0}):1===f.length?new F.Z({bitrate:void 0,representation:f[0],manual:!1,urgent:!0,knownStableBitrate:void 0}):(p=!1,g=new H(f.map(function(e){return e.bitrate})),v=new q,m=new K(I,v),y=s.getReference().getValue(),t=new F.Z(i()),s.listen(function(e){y=e,r()},{includeLastObservation:!1,clearSignal:e}),l=function(e){var t,i,n;null!==y&&(n=(t=y).position,t=t.speed,i=e.buffered,i=(0,Z.L7)(i,n.last),n=e.content.representation,e=I.getEstimate(n),n=n.bitrate,g.onAddedSegment({bufferGap:i,currentBitrate:n,currentScore:e,speed:t}),r())},e.register(function(){l=z.Z}),M.onUpdate(r,{clearSignal:e}),L.onUpdate(r,{clearSignal:e}),A.onUpdate(r,{clearSignal:e}),T.limitWidth.onUpdate(r,{clearSignal:e}),T.limitWidth.onUpdate(r,{clearSignal:e}),t);function r(){t.setValue(i())}function i(){var e,t,i,n,r,a,s,o,l,u,d,c,h=M.getValue();return 0<=h?{representation:Y(f,h,0,1/0),bitrate:void 0,knownStableBitrate:void 0,manual:!0,urgent:!0}:(u=(h=y).bufferGap,e=h.position,h=h.maximumPosition,c=T.limitWidth.getValue(),r=T.throttleBitrate.getValue(),t=S.getValue(),i=L.getValue(),n=A.getValue(),c=function(e,t,i){i<1/0&&(e=function(e,t){if(0===e.length)return[];e.sort(function(e,t){return e.bitrate-t.bitrate});var i=e[0].bitrate,n=Math.max(t,i);return-1===(t=(0,G.Z)(e,function(e){return e.bitrate>n}))?e:e.slice(0,t)}(e,i));void 0!==t&&(e=function(e,t){var i,n=e.slice().sort(function(e,t){return(0,j.Z)(e.width,0)-(0,j.Z)(t.width,0)});return void 0===(n=(0,V.Z)(n,function(e){return"number"==typeof e.width&&e.width>=t}))?e:(i="number"==typeof n.width?n.width:0,e.filter(function(e){return"number"!=typeof e.width||e.width<=i}))}(e,t));return e}(f,c,r),r=k.getRequests(),a=(d=D.getBandwidthEstimate(y,b,t,r,v.bandwidth)).bandwidthEstimate,d=d.bitrateChosen,s=null===(s=I.getLastStableRepresentation())?void 0:s.bitrate/(0u?(B.Z.debug("ABR: Choosing representation with guess-based estimation.",c.bitrate,c.id),v.update(c,a,2),{bitrate:a,representation:c,urgent:null===t||c.bitratea?(r.blockedUntil=void 0,r.isBlacklisted=!0):(s=r.errorCounter,s=Math.min(l*Math.pow(2,s-1),u),s=(0,ue.Z)(s),r.blockedUntil=performance.now()+s),e.abrupt("return",m(e.t0));case 22:case"end":return e.stop()}var t},e,null,[[0,7]])}))).apply(this,arguments)},v=function(e){return a.apply(this,arguments)},g=function(){var e;return null!==t?null===d?b(t):(e=d.getCdnPreferenceForResource(t),b(e)):void 0!==(e=p.get(null))&&e.isBlacklisted?void 0:null},null!==c.cancellationError)return e.abrupt("return",Promise.reject(c.cancellationError));e.next=9;break;case 9:if(l=i.baseDelay,u=i.maxDelay,h=i.maxRetryRegular,f=i.maxRetryOffline,n=i.onRetry,null!==t&&0===t.length&&B.Z.warn("Fetchers: no CDN given to `scheduleRequestWithCdns`."),p=new Map,void 0===(r=g()))throw new Error("No CDN to request");e.next=15;break;case 15:return e.abrupt("return",v(r));case 16:case"end":return e.stop()}},e)}))).apply(this,arguments)}function y(e,t,i){return ce(null,null,e,t,i)}function fe(e,t){var i,n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){var i;if(e)return"string"==typeof e?pe(e,t):"Map"===(i="Object"===(i=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:i)||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?pe(e,t):void 0}(e))||t&&e&&"number"==typeof e.length)return n&&(e=n),i=0,function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function pe(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=1e3*s.lifetime/10?(i=Math.min(Math.max(a,0)+r,6*a),B.Z.info("MUS: Manifest took too long to parse. Postponing next request",i,i)):i=a,n=setTimeout(function(){c.cancel(),o._triggerNextManifestRefresh(s,{enablePartialRefresh:!1,unsafeMode:d})},Math.max(i,u)),c.signal.register(function(){clearTimeout(n)}))},t._triggerNextManifestRefresh=function(l,e){var u,t,d=this,i=e.enablePartialRefresh,n=e.unsafeMode,e=l.updateUrl,r=(null!==this._prioritizedContentUrl?(u=!0,t=this._prioritizedContentUrl,this._prioritizedContentUrl=null):t=(u=!i||void 0===e)?l.getUrl():e,l.clockOffset);n?(this._consecutiveUnsafeMode+=1,B.Z.info('Init: Refreshing the Manifest in "unsafeMode" for the '+String(this._consecutiveUnsafeMode)+" consecutive time.")):0=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function me(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=this._prioritySteps.low)throw new Error("TP: the max high level priority should be given a lowerpriority number than the min low priority.")}var t=e.prototype;return t.create=function(e,t,a,s){var o,l=this;return(0,u.Z)(s,function(n,r){return o={hasEnded:!1,priority:t,trigger:function(){var t,i,e;o.hasEnded||(t=function(){e(),l._endTask(o)},i=new U.ZP,e=i.linkToSignal(s),(o.interrupter=i).signal.register(function(){o.interrupter=null,s.isCancelled()||a.beforeInterrupted()}),l._minPendingPriority=null===l._minPendingPriority?o.priority:Math.min(l._minPendingPriority,o.priority),l._pendingTasks.push(o),o.taskFn(i.signal).then(function(e){a.beforeEnded(),t(),n(e)}).catch(function(e){!s.isCancelled()&&i.isUsed()&&e instanceof U.FU||(e=e,t(),r(e))}))},taskFn:e,interrupter:null},l._canBeStartedNow(o)?(o.trigger(),l._isRunningHighPriorityTasks()&&l._interruptCancellableTasks()):l._waitingQueue.push(o),function(){return l._endTask(o)}})},t._endTask=function(e){e.hasEnded=!0;var t=r(e.taskFn,this._waitingQueue);0<=t?this._waitingQueue.splice(t,1):(t=r(e.taskFn,this._pendingTasks))<0||(this._pendingTasks.splice(t,1),0t.priority?t.priority:e},null);if(!(null===e||null!==this._minPendingPriority&&this._minPendingPriority=this._prioritySteps.low)return this._interruptPendingTask(t),this._interruptCancellableTasks()}},t._findAndRunWaitingQueueTask=function(e){return e>=this._waitingQueue.length||e<0?(B.Z.warn("TP : Tried to start a non existing task"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)},t._interruptPendingTask=function(e){var t=r(e.taskFn,this._pendingTasks);t<0?B.Z.warn("TP: Interrupting a non-existent pending task. Aborting..."):(this._pendingTasks.splice(t,1),this._waitingQueue.push(e),0===this._pendingTasks.length?this._minPendingPriority=null:this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min.apply(Math,this._pendingTasks.map(function(e){return e.priority}))),null!=(t=e.interrupter)&&t.cancel())},t._canBeStartedNow=function(e){return null===this._minPendingPriority||e.priority<=this._minPendingPriority},t._isRunningHighPriorityTasks=function(){return null!==this._minPendingPriority&&this._minPendingPriority<=this._prioritySteps.high},e}();function r(t,e){return(0,G.Z)(e,function(e){return e.taskFn===t})}var Le=function(){function e(e,t,i){var i=new ye(i),n=O.Z.getCurrent(),r=n.MIN_CANCELABLE_PRIORITY,n=n.MAX_HIGH_PRIORITY_LEVEL;this._transport=e,this._prioritizer=new Ae({prioritySteps:{high:n,low:r}}),this._cdnPrioritizer=i,this._backoffOptions=t}return e.prototype.createSegmentFetcher=function(e,t){u=e,i=this._backoffOptions,d=i.maxRetryRegular,c=i.maxRetryOffline,n=i.lowLatencyMode,i=i.requestTimeout,l=(o=O.Z.getCurrent()).DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR,r=o.DEFAULT_REQUEST_TIMEOUT,a=o.DEFAULT_MAX_REQUESTS_RETRY_ON_OFFLINE,s=o.INITIAL_BACKOFF_DELAY_BASE,o=o.MAX_BACKOFF_DELAY_BASE;var i,n,r,a,s,o,l,b,E,S,T,w,M,A,u={maxRetryRegular:"image"===u?0:null!=d?d:l,maxRetryOffline:null!=c?c:a,baseDelay:n?s.LOW_LATENCY:s.REGULAR,maxDelay:n?o.LOW_LATENCY:o.REGULAR,requestTimeout:(0,_.Z)(i)?r:i},d=this._transport[e],c=(l=d,b=this._cdnPrioritizer,E=t,T={timeout:(S=u).requestTimeout<0?void 0:S.requestTimeout},w=(0,Se.Z)(["audio","video"],e)?new we:void 0,M=l.loadSegment,A=l.parseSegment,function(){var n=(0,I.Z)(D().mark(function e(s,t,i){var n,r,a,o,l,u,d,c,h,f,p,g,v,m,y;return D().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(y=function(){var e;u||!(0,_.Z)(a)&&void 0!==a.size&&void 0!==a.requestDuration&&0=this._sourceBuffer.appendWindowEnd&&(n=r[0]+1,B.Z.debug("AVSB: pre-updating `appendWindowEnd`",n),this._sourceBuffer.appendWindowEnd=n),B.Z.debug("AVSB: setting `appendWindowStart`",r[0]),this._sourceBuffer.appendWindowStart=r[0]),void 0===r[1]?this._sourceBuffer.appendWindowEnd!==1/0&&(B.Z.debug("AVSB: re-setting `appendWindowEnd` to `Infinity`"),this._sourceBuffer.appendWindowEnd=1/0):r[1]!==this._sourceBuffer.appendWindowEnd&&(B.Z.debug("AVSB: setting `appendWindowEnd`",r[1]),this._sourceBuffer.appendWindowEnd=r[1]),null!==e.initSegmentUniqueId&&(a||!this._isLastInitSegment(e.initSegmentUniqueId))){i=this._initSegmentsMap.get(e.initSegmentUniqueId);if(void 0===i)throw new Error("Invalid initialization segment uniqueId");t.push(i),this._lastInitSegmentUniqueId=e.initSegmentUniqueId}return null!==e.chunk&&t.push(e.chunk),t},t._isLastInitSegment=function(e){return null!==this._lastInitSegmentUniqueId&&this._lastInitSegmentUniqueId===e},e}(c.C),_e=["audio","video","text","image"];function xe(e){return"audio"===e||"video"===e}var N=function(){function i(e,t){this._mediaElement=e,this._mediaSource=t,this._initializedSegmentBuffers={},this._onNativeBufferAddedOrDisabled=[]}i.isNative=xe;var e=i.prototype;return e.getBufferTypes=function(){var e=this.getNativeBufferTypes();return null==a.Z.nativeTextTracksBuffer&&null==a.Z.htmlTextTracksBuffer||e.push("text"),null!=a.Z.imageBuffer&&e.push("image"),e},e.getNativeBufferTypes=function(){return"AUDIO"===this._mediaElement.nodeName?["audio"]:["video","audio"]},e.getStatus=function(e){e=this._initializedSegmentBuffers[e];return void 0===e?{type:"uninitialized"}:null===e?{type:"disabled"}:{type:"initialized",value:e}},e.waitForUsableBuffers=function(e){var n=this;return this._areNativeBuffersUsable()?Promise.resolve():(0,u.Z)(e,function(e){function t(){var e=n._onNativeBufferAddedOrDisabled.indexOf(i);0<=e&&n._onNativeBufferAddedOrDisabled.splice(e,1)}var i=function(){n._areNativeBuffersUsable()&&(t(),e())};return n._onNativeBufferAddedOrDisabled.push(i),t})},e.disableSegmentBuffer=function(e){var t=this._initializedSegmentBuffers[e];if(null===t)B.Z.warn("SBS: The "+e+" SegmentBuffer was already disabled.");else{if(void 0!==t)throw new Error("Cannot disable an active SegmentBuffer.");this._initializedSegmentBuffers[e]=null,i.isNative(e)&&this._onNativeBufferAddedOrDisabled.forEach(function(e){return e()})}},e.createSegmentBuffer=function(e,t,i){void 0===i&&(i={});var n,r=this._initializedSegmentBuffers[e];if(xe(e)){if(null!=r)return r instanceof ke&&r.codec!==t?B.Z.warn("SB: Reusing native SegmentBuffer with codec",r.codec,"for codec",t):B.Z.info("SB: Reusing native SegmentBuffer with codec",t),r;B.Z.info("SB: Adding native SegmentBuffer with codec",t);t=new ke(e,t,this._mediaSource);return this._initializedSegmentBuffers[e]=t,this._onNativeBufferAddedOrDisabled.forEach(function(e){return e()}),t}if(null!=r)return B.Z.info("SB: Reusing a previous custom SegmentBuffer for the type",e),r;if("text"===e){if(B.Z.info("SB: Creating a new text SegmentBuffer"),"html"===i.textTrackMode){if(null==a.Z.htmlTextTracksBuffer)throw new Error("HTML Text track feature not activated");n=new a.Z.htmlTextTracksBuffer(this._mediaElement,i.textTrackElement)}else{if(null==a.Z.nativeTextTracksBuffer)throw new Error("Native Text track feature not activated");n=new a.Z.nativeTextTracksBuffer(this._mediaElement,!0===i.hideNativeSubtitle)}return this._initializedSegmentBuffers.text=n}if("image"!==e)throw B.Z.error("SB: Unknown buffer type:",e),new x.Z("BUFFER_TYPE_UNKNOWN","The player wants to create a SegmentBuffer of an unknown type.");if(null==a.Z.imageBuffer)throw new Error("Image buffer feature not activated");return B.Z.info("SB: Creating a new image SegmentBuffer"),n=new a.Z.imageBuffer,this._initializedSegmentBuffers.image=n},e.disposeSegmentBuffer=function(e){var t=this._initializedSegmentBuffers[e];null==t?B.Z.warn("SB: Trying to dispose a SegmentBuffer that does not exist"):(B.Z.info("SB: Aborting SegmentBuffer",e),t.dispose(),delete this._initializedSegmentBuffers[e])},e.disposeAll=function(){var t=this;_e.forEach(function(e){"initialized"===t.getStatus(e).type&&t.disposeSegmentBuffer(e)})},e._areNativeBuffersUsable=function(){var t=this,e=this.getNativeBufferTypes();return!e.some(function(e){return void 0===t._initializedSegmentBuffers[e]})&&!e.every(function(e){return null===t._initializedSegmentBuffers[e]})},i}(),Te=t(7473),Ce=t.n(Te),Re=t(3146),Pe=function(){function e(e){this._weakMap=new WeakMap,this._fn=e}var t=e.prototype;return t.get=function(e){var t,i=this._weakMap.get(e);return void 0===i?(t=this._fn(e),this._weakMap.set(e,t),t):i},t.destroy=function(e){this._weakMap.delete(e)},e}();function Ne(e,t){var i,n=e.segmentBuffer,r=e.playbackObserver,a=e.maxBufferBehind,s=e.maxBufferAhead;function o(){!function(){return Oe.apply(this,arguments)}(n,i,a.getValue(),s.getValue(),t).catch(function(e){e=e instanceof Error?e.message:"Unknown error";B.Z.error("Could not run BufferGarbageCollector:",e)})}r.listen(function(e){var t;i=null!=(t=e.position.pending)?t:e.position.last,o()},{includeLastObservation:!0,clearSignal:t}),a.onUpdate(o,{clearSignal:t}),s.onUpdate(o,{clearSignal:t}),o()}function Oe(){return(Oe=(0,I.Z)(D().mark(function e(t,i,n,r,a){var s,o,l,u,d,c;return D().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(isFinite(n)||isFinite(r)){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:s=[],u=(0,Z.F_)(t.getBufferedRanges(),i),o=u.innerRange,l=u.outerRanges,u=function(){if(isFinite(r)){for(var e=0;et.start&&s.push({start:i+r,end:t.end})}null!=o&&i+r=t.end?s.push(t):i>=t.end&&i-n>t.start&&i-no.start&&s.push({start:o.start,end:i-n})}}(),u(),u=0,d=s;case 9:if(u=t.end)return null;if(n.bufferedEnd>t.start)return i}return null}(r,t);if(null===e){if(null===i){if(n&&void 0!==a.end&&t.end>=a.end)return{start:void 0,end:null};var l=o.index.checkDiscontinuity(t.start);if(null!==l)return{start:void 0,end:l}}}else{l=r[e];if(void 0!==l.bufferedStart&&l.bufferedStart>t.start&&(null===i||l.infos.segment.end<=i))return u=l.bufferedStart,n||!1===o.index.awaitSegmentBetween(t.start,u)?(B.Z.debug("RS: current discontinuity encountered",s.type,l.bufferedStart),{start:void 0,end:u}):null;l=function(e,t,i){if(i<=0)B.Z.error("RS: Asked to check a discontinuity before the first chunk.");else for(var n=i;n=t.end)return null;if(0=a.end)return null;for(var d=r.length-1;0<=d;d--){var c=r[d];if(void 0===c.bufferedStart)break;if(c.bufferedStart=i.length-1?null:i[t+1],t=null;if(a=e,s=s,n=g.start,r=O.Z.getCurrent().MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT,void 0!==a.bufferedStart?!(null!==s&&void 0!==s.bufferedEnd&&a.bufferedStart-s.bufferedEnd<.1)&&nr&&(B.Z.info("Stream: The start of the wanted segment has been garbage collected",a.start,a.bufferedStart),!0):(B.Z.warn("Stream: Start of a segment unknown. Assuming it is garbage collected by default.",a.start),!0)){if(function(e,t){if(e.length<2)return 1;var i=e[e.length-1],i=null==(i=i.buffered)?void 0:i.start;if(void 0!==t&&void 0!==i&&.05s.bufferedEnd&&s.end-s.bufferedEnd>a&&(B.Z.info("Stream: The end of the wanted segment has been garbage collected",s.start,s.bufferedStart),!0):(B.Z.warn("Stream: End of a segment unknown. Assuming it is garbage collected by default.",s.end),!0)){if(function(e,t){if(e.length<2)return 1;var i=e[e.length-1],i=null==(i=i.buffered)?void 0:i.end;if(void 0!==t&&void 0!==i&&.05n||t.end+M-M&&s.end-r>-M)return!1}}var o=t*c.representation.bitrate;if(b-o<0&&(A=!0,n>g.start+T))return w=!0,L.push(e),!1;t=p(i);if(1n)return(d=d.start>n+M||function(e,t){var i=t+1,t=O.Z.getCurrent().MINIMUM_SEGMENT_SIZE,n=Math.min(1/60,t);for(;ie[i].start;)i++;return e[--i]}(E,u).endi:(e=i*t,r.bitrate>e)))}function Ze(e,t){for(var i=e-t,n=O.Z.getCurrent().SEGMENT_PRIORITIES_STEPS,r=0;r=r.end:null===s||s<=o);return{start:Math.max(e,r.start),end:Math.min(o,null!=(t=r.end)?t:1/0),hasReachedPeriodEnd:n}}(e,l,r),r=o.index.shouldRefresh(t.start,t.end),u=s.getPendingOperations().filter(function(e){return e.type===c.f.EndOfSegment}).map(function(e){return e.value}),d=function(e,t){for(var i=O.Z.getCurrent().MINIMUM_SEGMENT_SIZE,i=Math.max(1/60,i),n=e.start+i,r=e.end-i,a=[],s=t.length-1;0<=s;s--){var o,l=t[s],u=l.infos.representation;!l.partiallyPushed&&!1!==u.decipherable&&u.isSupported&&(u=l.infos.segment,o=u.time/u.timescale,u=u.complete?o+u.duration/u.timescale:l.end,nn&&l.start=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ve(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);io.end||e+in.start&&a.push({start:n.start,end:e-i}),e+i=t.start)return 0t.start)return e[i];return null}(f,i))&&(void 0===h.bufferedStart||h.bufferedStart-i.end<1)&&l.push({start:i.end-1,end:Number.MAX_VALUE}),0===(e=(0,Z.uH)(s,l)).length?{type:"continue",value:void 0}:o?{type:"flush-buffer",value:e}:{type:"clean-buffer",value:e}))}function it(e,t){var i,n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){var i;if(e)return"string"==typeof e?nt(e,t):"Map"===(i="Object"===(i=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:i)||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?nt(e,t):void 0}(e))||t&&e&&"number"==typeof e.length)return n&&(e=n),i=0,function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function nt(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=s.end&&(B.Z.debug('Stream: full "empty" AdaptationStream',r),o=!0),a.streamStatusUpdate({period:s,bufferType:r,position:e,imminentDiscontinuity:null,isEmptyStream:!0,hasFinishedLoading:o,neededSegments:[]})}n.onUpdate(l,{emitCurrentValue:!1,clearSignal:t}),i.listen(l,{includeLastObservation:!1,clearSignal:t}),l()}var at=function(e,c,h){var f,p,g=e.bufferType,v=e.content,m=e.garbageCollectors,y=e.playbackObserver,b=e.representationEstimator,E=e.segmentFetcherCreator,S=e.segmentBuffersStore,T=e.options,w=e.wantedBufferAhead,M=e.maxVideoBufferSize,A=v.period,e=new F.Z(void 0,h);function L(e,t,i){Ce()(function(){y.listen(function(){c.waitingMediaSourceReload({bufferType:g,period:A,timeOffset:e,stayInPeriod:t})},{includeLastObservation:!0,clearSignal:i})})}c.periodStreamReady({type:g,period:A,adaptationRef:e}),h.isCancelled()||(p=!0,e.onUpdate(function(d){(0,I.Z)(D().mark(function e(){var t,i,n,r,a,s,o,l,u;return D().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===d)return e.abrupt("return");e.next=2;break;case 2:if((t=new U.ZP).linkToSignal(h),null!=f&&f.cancel(),f=t,null!==d)e.next=34;else if(B.Z.info("Stream: Set no "+g+" Adaptation. P:",A.start),"initialized"!==(i=S.getStatus(g)).type)e.next=26;else{if(B.Z.info("Stream: Clearing previous "+g+" SegmentBuffer"),N.isNative(g))return e.abrupt("return",L(0,!0,t.signal));e.next=15}break;case 15:n=null!=(n=A.end)?n:1/0,A.start>n?(B.Z.warn("Stream: Can't free buffer: period's start is after its end"),e.next=24):e.next=20;break;case 20:return e.next=22,i.value.removeBuffer(A.start,n,t.signal);case 22:if(t.isUsed())return e.abrupt("return");e.next=24;break;case 24:e.next=30;break;case 26:if("uninitialized"!==i.type);else if(S.disableSegmentBuffer(g),t.isUsed())return e.abrupt("return");e.next=30;break;case 30:if(c.adaptationChange({type:g,adaptation:null,period:A}),t.isUsed())return e.abrupt("return");e.next=33;break;case 33:return e.abrupt("return",rt(y,w,g,{period:A},c,t.signal));case 34:if(r=O.Z.getCurrent(),r=r.DELTA_POSITION_AFTER_RELOAD,r=p?0:"audio"===g?r.trackSwitch.audio:"video"===g?r.trackSwitch.video:r.trackSwitch.other,p=!1,N.isNative(g)&&"disabled"===S.getStatus(g).type)return e.abrupt("return",L(r,!0,t.signal));e.next=39;break;case 39:if(B.Z.info("Stream: Updating "+g+" adaptation","A: "+d.id,"P: "+A.start),c.adaptationChange({type:g,adaptation:d,period:A}),t.isUsed())return e.abrupt("return");e.next=43;break;case 43:if(s=y.getReadyState(),a=function(e,t,i,n){var r=e.getStatus(t);if("initialized"===r.type)return B.Z.info("Stream: Reusing a previous SegmentBuffer for the type",t),r.value;r=function(e){var t=e.getPlayableRepresentations();if(0!==t.length)return t[0].getMimeTypeString();throw new x.Z("NO_PLAYABLE_REPRESENTATION","No Representation in the chosen "+e.type+" Adaptation can be played",{adaptation:e})}(i),i="text"===t?n.textTrackOptions:void 0;return e.createSegmentBuffer(t,r,i)}(S,g,d,T),s={currentTime:y.getCurrentTime(),readyState:s},"needs-reload"===(s=tt(a,A,d,s,T)).type)return e.abrupt("return",L(r,!0,t.signal));e.next=49;break;case 49:return e.next=51,S.waitForUsableBuffers(t.signal);case 51:if(t.isUsed())return e.abrupt("return");e.next=53;break;case 53:if("flush-buffer"!==s.type&&"clean-buffer"!==s.type){e.next=67;break}o=it(s.value);case 55:if((u=o()).done){e.next=63;break}return u=u.value,l=u.start,u=u.end,e.next=59,a.removeBuffer(l,u,t.signal);case 59:if(t.isUsed())return e.abrupt("return");e.next=61;break;case 61:e.next=55;break;case 63:if("flush-buffer"!==s.type);else if(c.needsBufferFlush(),t.isUsed())return e.abrupt("return");e.next=67;break;case 67:m.get(a)(t.signal),!function(e,t,i){var n=v.manifest,r=function(e,r){return e.deriveReadOnlyObserver(function(i,e){var t=new F.Z(n(),e);return i.onUpdate(function(){t.setValue(n())},{clearSignal:e,emitCurrentValue:!1}),t;function n(){var e=i.getValue(),t=r.getBufferedRanges(),t=(0,Z.L7)(t,e.position.last);return(0,C.Z)({},e,{bufferGap:t})}})}(y,t);Je({content:{manifest:n,period:A,adaptation:e},options:T,playbackObserver:r,representationEstimator:b,segmentBuffer:t,segmentFetcherCreator:E,wantedBufferAhead:w,maxVideoBufferSize:M},Object.assign(Object.assign({},c),{error:function(e){var t;if(!N.isNative(g))return B.Z.error("Stream: "+g+" Stream crashed. Aborting it.",e instanceof Error?e:""),S.disposeSegmentBuffer(g),t=(0,R.Z)(e,{defaultCode:"NONE",defaultReason:"Unknown `AdaptationStream` error"}),c.warning(t),i.isCancelled()?void 0:rt(y,w,g,{period:A},c,i);B.Z.error("Stream: "+g+" Stream crashed. Stopping playback.",e instanceof Error?e:""),c.error(e)}}),i)}(d,a,t.signal);case 69:case"end":return e.stop()}},e)}))().catch(function(e){e instanceof U.FU||(null!=f&&f.cancel(),c.error(e))})},{clearSignal:h,emitCurrentValue:!0}))};function st(e,r){if(0===r.length)return[];e.synchronizeInventory();for(var t,a=[],s=e.getInventory(),o=0;o=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function lt(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=i-5:t[0].start<=i+5}var dt=function(e,m,d,y,c,b,E,S){for(var t,T=e.manifest,i=e.initialPeriod,r=b.maxBufferAhead,a=b.maxBufferBehind,w=b.wantedBufferAhead,M=b.maxVideoBufferSize,s=(e=O.Z.getCurrent()).MAXIMUM_MAX_BUFFER_AHEAD,o=e.MAXIMUM_MAX_BUFFER_BEHIND,A=new Pe(function(t){var e=t.bufferType,i=null!=o[e]?o[e]:1/0,n=null!=s[e]?s[e]:1/0;return function(e){Ne({segmentBuffer:t,playbackObserver:m,maxBufferBehind:(0,F.l)(a,function(e){return Math.min(e,i)},e),maxBufferAhead:(0,F.l)(r,function(e){return Math.min(e,n)},e)},e)}}),n=ot(y.getBufferTypes());!(t=n()).done;)!function(h,e){var f=new Re.Z(function(e,t){return e.start-t.start}),p=!1,g=new U.ZP;g.linkToSignal(S),m.listen(function(e){var t,e=e.position,i=null!=(i=e.pending)?i:e.last;if(p&&(e=i,t=f.head(),r=f.last(),null==t||null==r||t.start>e||(null==r.end?1/0:r.end)=r.end&&(B.Z.info("Stream: Destroying PeriodStream as the current playhead moved above it",n,r.start,null!=(i=e.pending)?i:e.last,r.end),t(),a.periodStreamCleared({type:n,period:r}),l.cancel())},{clearSignal:s,includeLastObservation:!0});var e={bufferType:n,content:{manifest:T,period:r},garbageCollectors:A,maxVideoBufferSize:M,segmentFetcherCreator:c,segmentBuffersStore:y,options:b,playbackObserver:m,representationEstimator:d,wantedBufferAhead:w};var t=Object.assign(Object.assign({},a),{streamStatusUpdate:function(e){var t;e.hasFinishedLoading?null!==(t=T.getPeriodAfter(r))&&u(t):null!==o&&(B.Z.info("Stream: Destroying next PeriodStream due to current one being active",n,o.period.start),a.periodStreamCleared({type:n,period:o.period}),o.canceller.cancel(),o=null),a.streamStatusUpdate(e)},error:function(e){null!==o&&(o.canceller.cancel(),o=null),l.cancel(),a.error(e)}});at(e,t,l.signal);function u(e){if(null!==o){if(o.period.id===e.id)return;B.Z.warn("Stream: Creating next `PeriodStream` while one was already created.",n,e.id,o.period.id),a.periodStreamCleared({type:n,period:o.period}),o.canceller.cancel()}var t=new U.ZP;t.linkToSignal(s),i(n,e,a,(o={canceller:t,period:e}).canceller.signal)}}(h,e,t,g.signal)}function t(){return(t=(0,I.Z)(D().mark(function e(t){var i,n,r,a,s,o,l,u,d,c;return D().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(i=y.getStatus(h),0===(n=t.filter(function(e){return e.adaptation.type===h})).length||"initialized"!==i.type||n.every(function(e){return!0===e.representation.decipherable}))return e.abrupt("return");e.next=4;break;case 4:for(r=i.value,u=n.filter(function(e){return void 0===e.representation.decipherable}),l=n.filter(function(e){return!1===e.representation.decipherable}),a=st(r,l),s=st(r,u),p=!1,B.Z.info("Stream: Destroying all PeriodStreams for decipherability matters",h);0=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ht(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);ir.getMaximumAvailablePosition()&&(e=new x.Z("MEDIA_TIME_AFTER_MANIFEST","The current position is after the latest time announced in the Manifest."),n.trigger("warning",e))},{includeLastObservation:!0,clearSignal:a}),i.addEventListener("manifestUpdate",function(){n.trigger("durationUpdate",n._getManifestDuration()),a.isCancelled()||n._checkEndOfStream()},a),n}(0,o.Z)(e,s);var t=e.prototype;return t.getCurrentDuration=function(){return this._getManifestDuration()},t.onAdaptationChange=function(e,t,i){var n;this._manifest.isLastPeriodKnown&&(n=this._manifest.periods[this._manifest.periods.length-1],t.id!==(null==n?void 0:n.id)||"audio"!==e&&"video"!==e||("audio"===e?this._maximumPositionCalculator.updateLastAudioAdaptation(i):this._maximumPositionCalculator.updateLastVideoAdaptation(i),n=void 0!==(n=this._maximumPositionCalculator.getEndingPosition())?{isEnd:!0,duration:n}:{isEnd:!1,duration:this._maximumPositionCalculator.getMaximumAvailablePosition()},this.trigger("durationUpdate",n))),this._canceller.isUsed()||null===i&&this._addActivelyLoadedPeriod(t,e)},t.onRepresentationChange=function(e,t){this._addActivelyLoadedPeriod(t,e)},t.onPeriodCleared=function(e,t){this._removeActivelyLoadedPeriod(t,e)},t.onLastSegmentFinishedLoading=function(e){e=this._lazilyCreateActiveStreamInfo(e);e.hasFinishedLoadingLastPeriod||(e.hasFinishedLoadingLastPeriod=!0,this._checkEndOfStream())},t.onLastSegmentLoadingResume=function(e){e=this._lazilyCreateActiveStreamInfo(e);e.hasFinishedLoadingLastPeriod&&(e.hasFinishedLoadingLastPeriod=!1,this._checkEndOfStream())},t.dispose=function(){this.removeEventListener(),this._canceller.cancel()},t._addActivelyLoadedPeriod=function(e,t){t=this._lazilyCreateActiveStreamInfo(t);t.activePeriods.has(e)||(t.activePeriods.add(e),this._checkCurrentPeriod())},t._removeActivelyLoadedPeriod=function(e,t){t=this._activeStreams.get(t);void 0!==t&&t.activePeriods.has(e)&&(t.activePeriods.removeElement(e),this._checkCurrentPeriod())},t._checkCurrentPeriod=function(){var r=this;if(0!==this._allBufferTypes.length){var e=this._activeStreams.get(this._allBufferTypes[0]);if(void 0!==e)for(var t,a,i=ct(e.activePeriods.toArray());!(a=i()).done;)if(t=function(){for(var t=a.value,e=!0,i=1;i=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function St(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Bt(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function jt(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);it.end&&(e=t.end-1):e=w,{maximumPosition:S.getMaximumSafePosition(),position:{last:i.position,pending:e},duration:i.duration,paused:{last:i.paused,pending:b.getValue()||!y===i.paused?void 0:!y},readyState:i.readyState,speed:n}}function a(){i.setValue(n())}}),M=this._createRebufferingController(d,o,e,a),A=this._createContentTimeBoundariesObserver(o,u,g,I,a),k.then(function(){(0,At.Z)(d,l,!1,a).onUpdate(function(e,t){e&&(t(),r.trigger("loaded",{segmentBuffersStore:I}))},{emitCurrentValue:!0,clearSignal:a})}).catch(function(e){a.isCancelled()||r._onFatalError(e)}),L=this,dt({manifest:o,initialPeriod:p},g,h,I,f,i,{needsBufferFlush:function(){var i=l.currentTime+.001;d.setCurrentTime(i),d.listen(function(e,t){(null!==e.currentRange||e.position>i+.1)&&(t(),d.setCurrentTime(e.position+.001))},{includeLastObservation:!1,clearSignal:a})},streamStatusUpdate:function(e){var t=e.period,i=e.bufferType,n=e.imminentDiscontinuity,r=e.position;M.updateDiscontinuityInfo({period:t,bufferType:i,discontinuity:n,position:r}),a.isCancelled()||o.isLastPeriodKnown&&e.period.id===o.periods[o.periods.length-1].id&&(e.hasFinishedLoading||e.isEmptyStream?A.onLastSegmentFinishedLoading(e.bufferType):A.onLastSegmentLoadingResume(e.bufferType))},needsManifestRefresh:function(){return L._manifestFetcher.scheduleManualRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync:function(){var e=O.Z.getCurrent().OUT_OF_SYNC_MANIFEST_REFRESH_DELAY;L._manifestFetcher.scheduleManualRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:e})},lockedStream:function(e){return M.onLockedStream(e.bufferType,e.period)},adaptationChange:function(e){L.trigger("adaptationChange",e),a.isCancelled()||A.onAdaptationChange(e.type,e.period,e.adaptation)},representationChange:function(e){L.trigger("representationChange",e),a.isCancelled()||A.onRepresentationChange(e.type,e.period)},inbandEvent:function(e){return L.trigger("inbandEvents",e)},warning:function(e){return L.trigger("warning",e)},periodStreamReady:function(e){return L.trigger("periodStreamReady",e)},periodStreamCleared:function(e){A.onPeriodCleared(e.type,e.period),a.isCancelled()||L.trigger("periodStreamCleared",e)},bitrateEstimationChange:function(e){return L.trigger("bitrateEstimationChange",e)},addedSegment:function(e){return L.trigger("addedSegment",e)},needsMediaSourceReload:function(e){var t=g.getReference().getValue(),i=null!=(i=t.position.pending)?i:g.getCurrentTime(),t=null!=(t=t.paused.pending)?t:g.getIsPaused(),i=i+e.timeOffset;void 0!==e.minimumPosition&&(i=Math.max(e.minimumPosition,i)),void 0!==e.maximumPosition&&(i=Math.min(e.maximumPosition,i)),n({position:i,autoPlay:!t})},needsDecipherabilityFlush:function(){var e,t=(0,ae.Z)(l);void 0===(t=null==t?void 0:t[0])||t.indexOf("widevine")<0?(e=null!=(e=(t=g.getReference().getValue()).position.pending)?e:g.getCurrentTime(),t=null!=(t=t.paused.pending)?t:g.getIsPaused(),n({position:e,autoPlay:!t})):(t=null!=(t=(e=g.getReference().getValue()).position.pending)?t:g.getCurrentTime())+.001=i&&null!==e.currentRange&&(!(0,l.Z)()||0=p.c.HAVE_METADATA&&h(),{autoPlayResult:e,initialPlayPerformed:d,initialSeekPerformed:n};function h(){r.removeEventListener("loadedmetadata",h);var e="function"==typeof i?i():i;v.Z.info("Init: Set initial time",e),t.setCurrentTime(e),n.setValue(!0),n.finish(),(0,f.Z)()&&0===r.duration&&(e=new g.Z("MEDIA_ERR_NOT_LOADED_METADATA","Cannot load automatically: your browser falsely announced having loaded the content."),s(e)),o.isCancelled()||t.listen(function(e,t){var i,n;if(!e.seeking&&null===e.rebuffering&&1<=e.readyState)if(t(),v.Z.info("Init: Can begin to play content"),a){try{n=null!=(i=r.play())?i:Promise.resolve()}catch(e){return void(c(),u(e))}n.then(function(){if(!o.isCancelled())return d.setValue(!0),d.finish(),c(),l({type:"autoplay"})}).catch(function(e){if(c(),!o.isCancelled())if(e instanceof Error&&"NotAllowedError"===e.name){v.Z.warn("Init: Media element can't play. It may be due to browser auto-play policies.");var t=new g.Z("MEDIA_ERR_BLOCKED_AUTOPLAY","Cannot trigger auto-play automatically: your browser does not allow it.");if(s(t),!o.isCancelled())return l({type:"autoplay-blocked"})}else u(e)})}else r.autoplay&&v.Z.warn("Init: autoplay is enabled on HTML media element. Media will play as soon as possible."),d.setValue(!0),d.finish(),c(),l({type:"skipped"})},{includeLastObservation:!0,clearSignal:o})}}},7794:function(e,t,i){i.d(t,{Z:function(){return n}});var d=i(5157),c=i(7874),h=i(3887),f=i(5095),p=i(288),g=i(4339);function n(e,t,n,r,a){if(0===t.length)return u("No `keySystems` option given.");if(null===c.Z.decrypt)return u("EME feature not activated.");var s=new p.ZP,o=(s.linkToSignal(a),new f.Z({initializationState:{type:"uninitialized",value:null},drmSystemId:void 0},a)),i=c.Z.decrypt;if(!i.hasEmeApis())return u("EME API not available on the current page.");h.Z.debug("Init: Creating ContentDecryptor");var l=new i(e,t);return l.addEventListener("stateChange",function(i){var e;i===g.u.WaitingForAttachment?((e=new f.Z(!1)).onUpdate(function(e,t){e&&(t(),i===g.u.WaitingForAttachment)&&l.attach()},{clearSignal:s.signal}),o.setValue({initializationState:{type:"awaiting-media-link",value:{isMediaLinked:e}},drmSystemId:l.systemId})):i===g.u.ReadyForContent&&(o.setValue({initializationState:{type:"initialized",value:null},drmSystemId:l.systemId}),l.removeEventListener("stateChange"))}),l.addEventListener("error",function(e){s.cancel(),r.onError(e)}),l.addEventListener("warning",function(e){r.onWarning(e)}),n.onUpdate(function(e){null!==e&&l.onInitializationData(e)},{clearSignal:s.signal}),s.signal.register(function(){l.dispose()}),o;function u(i){n.onUpdate(function(e,t){null!==e&&(t(),e=new d.Z("MEDIA_IS_ENCRYPTED_ERROR",i),r.onError(e))},{clearSignal:a});var e=new f.Z({initializationState:{type:"initialized",value:null},drmSystemId:void 0});return e.finish(),e}}},6199:function(e,t,i){i.d(t,{Z:function(){return s}});var n=i(4578),S=i(3666).yS,T=i(6872),r=i(3714),w=i(3887),t=i(1959),M=i(2829),a=i(288),s=function(r){function e(e,t,i){var n=r.call(this)||this;return n._playbackObserver=e,n._manifest=t,n._speed=i,n._discontinuitiesStore=[],n._isStarted=!1,n._canceller=new a.ZP,n}(0,n.Z)(e,r);var t=e.prototype;return t.start=function(){var v,m,y,b,E=this;this._isStarted||(this._isStarted=!0,m=null,y=new o(this._playbackObserver,this._speed),this._canceller.signal.register(function(){y.dispose()}),b=null,this._playbackObserver.listen(function(e){var t=E._discontinuitiesStore,i=e.buffered,n=e.position,r=e.readyState,a=e.rebuffering,s=e.freezing,o=T.Z.getCurrent(),l=o.BUFFER_DISCONTINUITY_THRESHOLD,u=o.FORCE_DISCONTINUITY_SEEK_DELAY,d=o.FREEZING_STALLED_DELAY,c=o.UNFREEZING_SEEK_DELAY,o=o.UNFREEZING_DELTA_POSITION;if(!e.seeking&&S&&null===m&&null!==v&&e.positiond)return null===a||null!==m?y.stopRebuffering():y.startRebuffering(),void E.trigger("stalled","freezing")}else b=null;if(null===a)return y.stopRebuffering(),1===r?(c=e.seeking?null!==e.pendingInternalSeek?"internal-seek":"seeking":"not-ready",void E.trigger("stalled",c)):void E.trigger("unstalled",null);o="seeking"===a.reason&&null!==e.pendingInternalSeek?"internal-seek":a.reason;if(null!==m){h=performance.now();if(h-mi)return n;var s,o,l,u=void 0;(void 0===a.end||a.end>i)&&(s=e[r],o=s.discontinuity,s=s.position,l=o.start,o=o.end,(null!=l?l:s)-1/60<=i&&(null===o?null!==(l=t.getPeriodAfter(a))?u=l.start+1/60:w.Z.warn("Init: discontinuity at Period's end but no next Period"):if&&E._manifest.periods[p+1].start>E._playbackObserver.getCurrentTime())return g=E._manifest.periods[p+1],E._playbackObserver.setCurrentTime(g.start),void E.trigger("warning",A(f,g.start));break}}}E.trigger("stalled",o)},{includeLastObservation:!0,clearSignal:this._canceller.signal}))},t.updateDiscontinuityInfo=function(e){this._isStarted||this.start();for(var t=this._playbackObserver.getReference().getValue(),i=this._discontinuitiesStore,n=e,r=t;0a.start)return void(l(n)&&i.splice(o,0,n));l(n)&&i.push(n)}},t.onLockedStream=function(e,t){this._isStarted||this.start();var i=this._playbackObserver.getReference().getValue();!i.rebuffering||i.paused||this._speed.getValue()<=0||"audio"!==e&&"video"!==e||(e=i.position,i=null!=(i=i.rebuffering.position)?i:e,e<(e=t.start)&&Math.abs(i-e)<1&&(w.Z.warn("Init: rebuffering because of a future locked stream.\nTrying to unlock by seeking to the next Period"),this._playbackObserver.setCurrentTime(e+.001)))},t.destroy=function(){this._canceller.cancel()},e}(t.Z);function l(e){return null!==e.discontinuity}function A(e,t){return new r.Z("DISCONTINUITY_ENCOUNTERED","A discontinuity has been encountered at position "+String(e)+", seeked at position "+String(t))}var o=function(){function e(e,t){this._speedUpdateCanceller=new a.ZP,this._isRebuffering=!1,this._playbackObserver=e,this._isDisposed=!1,this._speed=t,this._updateSpeed()}var t=e.prototype;return t.startRebuffering=function(){this._isRebuffering||this._isDisposed||(this._isRebuffering=!0,this._speedUpdateCanceller.cancel(),w.Z.info("Init: Pause playback to build buffer"),this._playbackObserver.setPlaybackRate(0))},t.stopRebuffering=function(){this._isRebuffering&&!this._isDisposed&&(this._isRebuffering=!1,this._speedUpdateCanceller=new a.ZP,this._updateSpeed())},t.dispose=function(){this._speedUpdateCanceller.cancel(),this._isDisposed=!0},t._updateSpeed=function(){var t=this;this._speed.onUpdate(function(e){w.Z.info("Init: Resume playback speed",e),t._playbackObserver.setPlaybackRate(e)},{clearSignal:this._speedUpdateCanceller.signal,emitCurrentValue:!0})},e}()},4576:function(e,t,i){i.d(t,{Z:function(){return n}});var a=i(3714),s=i(1946);function n(n,r,e){function t(){var e,t,i=n.error;switch((0,s.Z)(i)||(e=i.code,t=i.message),e){case 1:return r(new a.Z("MEDIA_ERR_ABORTED",t=null!=t?t:"The fetching of the associated resource was aborted by the user's request."));case 2:return r(new a.Z("MEDIA_ERR_NETWORK",t=null!=t?t:"A network error occurred which prevented the media from being successfully fetched"));case 3:return r(new a.Z("MEDIA_ERR_DECODE",t=null!=t?t:"An error occurred while trying to decode the media resource"));case 4:return r(new a.Z("MEDIA_ERR_SRC_NOT_SUPPORTED",t=null!=t?t:"The media resource has been found to be unsuitable."));default:return r(new a.Z("MEDIA_ERR_UNKNOWN",t=null!=t?t:"The HTMLMediaElement errored due to an unknown reason."))}}e.isCancelled()||(n.addEventListener("error",t),e.register(function(){n.removeEventListener("error",t)}))}},7127:function(e,t,i){i.d(t,{Z:function(){return a}});var n=i(4578),s=i(3887),t=i(9612),r=i(4309),a=function(t){function e(){var e;return s.Z.debug("ISB: Creating ImageSegmentBuffer"),(e=t.call(this)||this).bufferType="image",e._buffered=new r.Z,e}(0,n.Z)(e,t);var i=e.prototype;return i.declareInitSegment=function(e){s.Z.warn("ISB: Declaring initialization segment for image SegmentBuffer",e)},i.freeInitSegment=function(e){s.Z.warn("ISB: Freeing initialization segment for image SegmentBuffer",e)},i.pushChunk=function(e){if(s.Z.debug("ISB: appending new data."),null!==e.data.chunk){var t=e.data,i=t.appendWindow,t=t.chunk,n=t.start,r=t.end,t=t.timescale,a=null!=(a=i[0])?a:0,i=null!=(i=i[1])?i:1/0,r=r/t,a=Math.max(a,n/t),n=Math.min(i,r);try{this._buffered.insert(a,n),null!==e.inventoryInfos&&this._segmentInventory.insertChunk(e.inventoryInfos)}catch(e){return Promise.reject(e)}}return Promise.resolve()},i.removeBuffer=function(e,t){return s.Z.info("ISB: ignored image data remove order",e,t),Promise.resolve()},i.endOfSegment=function(e){return this._segmentInventory.completeSegment(e,this._buffered),Promise.resolve()},i.getBufferedRanges=function(){return this._buffered},i.dispose=function(){s.Z.debug("ISB: disposing image SegmentBuffer"),this._buffered.remove(0,1/0)},e}(t.C)},5192:function(e,t,i){i.d(t,{Z:function(){return d}});var r=i(4578),t=i(3038),m=i(3887),y=i(5095),b=i(2203).Z?void 0:window.ResizeObserver;var E=i(6872),S=i(288),n=i(9612),a=i(4309),g=i(7874);function c(e,t){return Math.abs(e-t)<=.2}function h(e,t){for(var i=e.length-1;0<=i;i--)if(e[i].startt)return e.slice(i,e.length);return[]}function p(e,t,i){var n=Math.max(e.start,t),t=h(e.cues,t),n={start:e.start,end:n,cues:t},t=Math.min(i,e.end),i=f(e.cues,i);return[n,{start:t,end:e.end,cues:i}]}var s=function(){function e(){this._cuesBuffer=[]}var t=e.prototype;return t.get=function(e){for(var t=this._cuesBuffer,i=[],n=t.length-1;0<=n;n--){var r=t[n];if(e=r.start){for(var a=r.cues,s=0;s=a[s].start&&ee){var a,s,o=n[r];if(o.start>=i)return;if(o.end>=i)return void(e<=o.start?(o.cues=f(o.cues,i),o.start=i):(a=(s=p(o,e,i))[0],s=s[1],this._cuesBuffer[r]=a,n.splice(r+1,0,s)));o.start>=e?(n.splice(r,1),r--):(o.cues=h(o.cues,e),o.end=Math.max(e,o.start))}},t.insert=function(e,t,i){var n=this._cuesBuffer,r={start:t,end:i,cues:e};function a(e){var t=n[e];void 0===t||c(r.end,t.end)?n[e]=r:(t.start>=r.end||(t.cues=f(t.cues,r.end),t.start=r.end),n.splice(e,0,r))}for(var s,o,l=0;ld.end;);return void a(l)}if(td.end;);return void a(l)}if(c(d.end,i))return d.cues=h(d.cues,t),d.end=t,void n.splice(l+1,0,r);if(d.end>i)return s=(o=p(d,t,i))[0],o=o[1],this._cuesBuffer[l]=s,n.splice(l+1,0,r),void n.splice(l+2,0,o);d.cues=h(d.cues,t),d.end=t;for(var u=l+1,d=n[u];void 0!==d&&i>d.end;)n.splice(u,1),d=n[u];return void a(u)}n.push(r)},e}();var o=t.M4,l=t.bQ,u=t.Q$;function T(e,t){try{e.removeChild(t)}catch(e){m.Z.warn("HTSB: Can't remove text track: not in the element.")}}var d=function(n){function e(e,t){var i;return m.Z.debug("HTSB: Creating HTMLTextSegmentBuffer"),(i=n.call(this)||this).bufferType="text",i._buffered=new a.Z,i._videoElement=e,i._textTrackElement=t,i._sizeUpdateCanceller=new S.ZP,i._canceller=new S.ZP,i._buffer=new s,i._currentCues=[],i.autoRefreshSubtitles(i._canceller.signal),i}(0,r.Z)(e,n);var t=e.prototype;return t.declareInitSegment=function(e){m.Z.warn("ISB: Declaring initialization segment for image SegmentBuffer",e)},t.freeInitSegment=function(e){m.Z.warn("ISB: Freeing initialization segment for image SegmentBuffer",e)},t.pushChunk=function(e){try{this.pushChunkSync(e)}catch(e){return Promise.reject(e)}return Promise.resolve()},t.removeBuffer=function(e,t){return this.removeBufferSync(e,t),Promise.resolve()},t.endOfSegment=function(e){return this._segmentInventory.completeSegment(e,this._buffered),Promise.resolve()},t.getBufferedRanges=function(){return this._buffered},t.dispose=function(){m.Z.debug("HTSB: Disposing HTMLTextSegmentBuffer"),this._disableCurrentCues(),this._buffer.remove(0,1/0),this._buffered.remove(0,1/0),this._canceller.cancel()},t.pushChunkSync=function(e){m.Z.debug("HTSB: Appending new html text tracks");var t,i=e.data,n=i.timestampOffset,r=i.appendWindow,i=i.chunk;if(null!==i){var a,s,o=i.start,l=i.end,u=i.data,d=i.type,i=i.language,c=null!=(t=r[0])?t:0,h=null!=(t=r[1])?t:1/0,f=function(e,t,i,n){if(m.Z.debug("HTSB: Finding parser for html text tracks:",e),"function"!=typeof(e=g.Z.htmlTextTracksParsers[e]))throw new Error("no parser found for the given text track");return m.Z.debug("HTSB: Parser found, parsing..."),e=e(t,i,n),m.Z.debug("HTTB: Parsed successfully!",e.length),e}(d,u,n,i);if(0!==c&&h!==1/0){for(var p=0;p=h;)p--;for(f.splice(p,f.length),p=f.length-1;0<=p&&f[p].end>h;)f[p].end=h,p--}if(void 0!==o)a=Math.max(c,o);else{if(f.length<=0)return void m.Z.warn("HTSB: Current text tracks have no cues nor start time. Aborting");m.Z.warn("HTSB: No start time given. Guessing from cues."),a=f[0].start}if(void 0!==l)s=Math.min(h,l);else{if(f.length<=0)return void m.Z.warn("HTSB: Current text tracks have no cues nor end time. Aborting");m.Z.warn("HTSB: No end time given. Guessing from cues."),s=f[f.length-1].end}s<=a?m.Z.warn("HTSB: Invalid text track appended: ","the start time is inferior or equal to the end time."):(null!==e.inventoryInfos&&this._segmentInventory.insertChunk(e.inventoryInfos),this._buffer.insert(f,a,s),this._buffered.insert(a,s))}},t.removeBufferSync=function(e,t){m.Z.debug("HTSB: Removing html text track data",e,t),this._buffer.remove(e,t),this._buffered.remove(e,t)},t._disableCurrentCues=function(){if(this._sizeUpdateCanceller.cancel(),0=d;)p--;for(f.splice(p,f.length),p=f.length-1;0<=p&&f[p].endTime>d;)f[p].endTime=d,p--}if(void 0!==a)c=Math.max(u,a);else{if(f.length<=0)return y.Z.warn("NTSB: Current text tracks have no cues nor start time. Aborting"),Promise.resolve();y.Z.warn("NTSB: No start time given. Guessing from cues."),c=f[0].startTime}if(void 0!==s)h=Math.min(d,s);else{if(f.length<=0)return y.Z.warn("NTSB: Current text tracks have no cues nor end time. Aborting"),Promise.resolve();y.Z.warn("NTSB: No end time given. Guessing from cues."),h=f[f.length-1].endTime}if(h<=c)return y.Z.warn("NTSB: Invalid text track appended: ","the start time is inferior or equal to the end time."),Promise.resolve();if(0=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);ithis._maxHistoryLength&&(e=this._history.length-this._maxHistoryLength,this._history=this._history.splice(e))},e}();function L(e,t){var i,n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){var i;if(e)return"string"==typeof e?s(e,t):"Map"===(i="Object"===(i=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:i)||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?s(e,t):void 0}(e))||t&&e&&"number"==typeof e.length)return n&&(e=n),i=0,function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);ie.bufferedStart&&Math.abs(e.bufferedEnd-e.bufferedStart-i)<=Math.min(r,i/3))}function o(e){var t,i,n,r;if(void 0!==e.bufferedEnd&&!e.partiallyPushed)return i=e.start,i=(t=e.end)-i,n=(r=w.Z.getCurrent()).MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,r=r.MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE,Math.abs(t-e.bufferedEnd)<=n&&null!=e.bufferedStart&&e.bufferedEnd>e.bufferedStart&&Math.abs(e.bufferedEnd-e.bufferedStart-i)<=Math.min(r,i/3)}function D(e,t,i){var n=w.Z.getCurrent().MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE;void 0!==e.bufferedEnd?(e.bufferedEnd>t&&(M.Z.debug("SI: Segment partially GCed at the end",i,e.bufferedEnd,t),e.bufferedEnd=t),!e.precizeEnd&&t-e.end<=n&&o(e)&&(e.precizeEnd=!0,e.end=t)):e.precizeEnd?(M.Z.debug("SI: buffered end is precize end",i,e.end),e.bufferedEnd=e.end):t-e.end<=n?(M.Z.debug("SI: found true buffered end",i,t,e.end),e.bufferedEnd=t,o(e)&&(e.end=t,e.precizeEnd=!0)):t>e.end?(M.Z.debug("SI: range end too far from expected end",i,t,e.end),e.bufferedEnd=e.end):(M.Z.debug("SI: Segment appears immediately garbage collected at the end",i,e.bufferedEnd,t),e.bufferedEnd=t)}var l,u=function(){function e(){var e=w.Z.getCurrent(),t=e.BUFFERED_HISTORY_RETENTION_TIME,e=e.BUFFERED_HISTORY_MAXIMUM_ENTRIES;this._inventory=[],this._bufferedHistory=new n(t,e)}var t=e.prototype;return t.reset=function(){this._inventory.length=0},t.synchronizeBuffered=function(e){for(var t,i=this._inventory,n=0,r=i[0],a=w.Z.getCurrent().MINIMUM_SEGMENT_SIZE,s=null==r?void 0:r.infos.adaptation.type,o=e.length,l=0;l=a){if(p=r,f=u,c=h,h=s,t=void 0,t=w.Z.getCurrent().MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE,void 0!==p.bufferedStart?(p.bufferedStartf&&(c.precizeEnd||p.start-c.end<=t)?(M.Z.debug("SI: buffered start is end of previous segment",h,f,p.start,c.end),p.bufferedStart=c.end,I(p)&&(p.start=c.end,p.precizeStart=!0)):p.start-f<=t?(M.Z.debug("SI: found true buffered start",h,f,p.start),p.bufferedStart=f,I(p)&&(p.start=f,p.precizeStart=!0)):fd.end)return M.Z.debug("SI: Segment pushed updates the start of the next one",l,d.end,u[c].start),u[c].start=d.end,u[c].bufferedStart=void 0,void(u[c].precizeStart=u[c].precizeStart&&d.precizeEnd);M.Z.debug("SI: Segment pushed removes the next one",l,s,o,u[c].start,u[c].end),u.splice(c,1)}return}if(f.start===s){if(f.end<=o){for(M.Z.debug("SI: Segment pushed replace another one",l,s,o,f.end),this._inventory.splice(c,1,d),c+=1;cd.end)return M.Z.debug("SI: Segment pushed updates the start of the next one",l,d.end,u[c].start),u[c].start=d.end,u[c].bufferedStart=void 0,void(u[c].precizeStart=u[c].precizeStart&&d.precizeEnd);M.Z.debug("SI: Segment pushed removes the next one",l,s,o,u[c].start,u[c].end),u.splice(c,1)}return}return M.Z.debug("SI: Segment pushed ends before another with the same start",l,s,o,f.end),u.splice(c,0,d),f.start=d.end,f.bufferedStart=void 0,void(f.precizeStart=f.precizeStart&&d.precizeEnd)}if(f.end<=d.end){for(M.Z.debug("SI: Segment pushed updates end of previous one",l,s,o,f.start,f.end),this._inventory.splice(c+1,0,d),f.end=d.start,f.bufferedEnd=void 0,f.precizeEnd=f.precizeEnd&&d.precizeStart,c+=2;cd.end)return M.Z.debug("SI: Segment pushed updates the start of the next one",l,d.end,u[c].start),u[c].start=d.end,u[c].bufferedStart=void 0,void(u[c].precizeStart=u[c].precizeStart&&d.precizeEnd);M.Z.debug("SI: Segment pushed removes the next one",l,s,o,u[c].start,u[c].end),u.splice(c,1)}return}return M.Z.warn("SI: Segment pushed is contained in a previous one",l,s,o,f.start,f.end),h={partiallyPushed:f.partiallyPushed,chunkSize:f.chunkSize,splitted:!0,start:d.end,end:f.end,precizeStart:f.precizeStart&&f.precizeEnd&&d.precizeEnd,precizeEnd:f.precizeEnd,bufferedStart:void 0,bufferedEnd:f.end,infos:f.infos},f.end=d.start,f.splitted=!0,f.bufferedEnd=void 0,f.precizeEnd=f.precizeEnd&&d.precizeStart,u.splice(c+1,0,d),void u.splice(c+2,0,h)}}e=this._inventory[0];if(void 0===e)M.Z.debug("SI: first segment pushed",l,s,o),this._inventory.push(d);else if(e.start>=o)M.Z.debug("SI: Segment pushed comes before all previous ones",l,s,o,e.start),this._inventory.splice(0,0,d);else if(e.end<=o)for(M.Z.debug("SI: Segment pushed starts before and completely recovers the previous first one",l,s,o,e.start,e.end),this._inventory.splice(0,1,d);1d.end)return M.Z.debug("SI: Segment pushed updates the start of the next one",l,d.end,u[1].start),u[1].start=d.end,u[1].bufferedStart=void 0,void(u[1].precizeStart=d.precizeEnd);M.Z.debug("SI: Segment pushed removes the next one",l,s,o,u[1].start,u[1].end),u.splice(1,1)}else M.Z.debug("SI: Segment pushed start of the next one",l,s,o,e.start,e.end),e.start=o,e.bufferedStart=void 0,e.precizeStart=d.precizeEnd,this._inventory.splice(0,0,d)}}},t.completeSegment=function(e,t){if(!e.segment.isInit){for(var i=this._inventory,n=[],r=0;r=this._ranges.length)throw new Error("INDEX_SIZE_ERROR");return this._ranges[e].start},t.end=function(e){if(e>=this._ranges.length)throw new Error("INDEX_SIZE_ERROR");return this._ranges[e].end},e}()},7839:function(e,t,i){i.d(t,{Z:function(){return r}});var o=i(7326),n=i(4578),r=function(a){function s(e,t,i,n){var r=a.call(this)||this;return Object.setPrototypeOf((0,o.Z)(r),s.prototype),r.name="CustomLoaderError",r.message=e,r.canRetry=t,r.isOfflineError=i,r.xhr=n,r}return(0,n.Z)(s,a),s}((0,i(2146).Z)(Error))},5157:function(e,t,i){i.d(t,{Z:function(){return r}});var s=i(7326),n=i(4578),t=i(2146),o=i(5992),l=i(7367),r=function(r){function a(e,t,i){var n=r.call(this)||this;return Object.setPrototypeOf((0,s.Z)(n),a.prototype),n.name="EncryptedMediaError",n.type=o.ZB.ENCRYPTED_MEDIA_ERROR,n.code=e,n.message=(0,l.Z)(n.name,n.code,t),n.fatal=!1,"string"==typeof(null==i?void 0:i.keyStatuses)&&(n.keyStatuses=i.keyStatuses),n}return(0,n.Z)(a,r),a}((0,t.Z)(Error))},5992:function(e,t,i){i.d(t,{SM:function(){return a},ZB:function(){return n},br:function(){return r}});var n={NETWORK_ERROR:"NETWORK_ERROR",MEDIA_ERROR:"MEDIA_ERROR",ENCRYPTED_MEDIA_ERROR:"ENCRYPTED_MEDIA_ERROR",OTHER_ERROR:"OTHER_ERROR"},r={TIMEOUT:"TIMEOUT",ERROR_EVENT:"ERROR_EVENT",ERROR_HTTP_CODE:"ERROR_HTTP_CODE",PARSE_ERROR:"PARSE_ERROR"},a={PIPELINE_LOAD_ERROR:"PIPELINE_LOAD_ERROR",PIPELINE_PARSE_ERROR:"PIPELINE_PARSE_ERROR",INTEGRITY_ERROR:"INTEGRITY_ERROR",MANIFEST_PARSE_ERROR:"MANIFEST_PARSE_ERROR",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"MANIFEST_INCOMPATIBLE_CODECS_ERROR",MANIFEST_UPDATE_ERROR:"MANIFEST_UPDATE_ERROR",MANIFEST_UNSUPPORTED_ADAPTATION_TYPE:"MANIFEST_UNSUPPORTED_ADAPTATION_TYPE",MEDIA_STARTING_TIME_NOT_FOUND:"MEDIA_STARTING_TIME_NOT_FOUND",MEDIA_TIME_BEFORE_MANIFEST:"MEDIA_TIME_BEFORE_MANIFEST",MEDIA_TIME_AFTER_MANIFEST:"MEDIA_TIME_AFTER_MANIFEST",MEDIA_TIME_NOT_FOUND:"MEDIA_TIME_NOT_FOUND",NO_PLAYABLE_REPRESENTATION:"NO_PLAYABLE_REPRESENTATION",MEDIA_IS_ENCRYPTED_ERROR:"MEDIA_IS_ENCRYPTED_ERROR",CREATE_MEDIA_KEYS_ERROR:"CREATE_MEDIA_KEYS_ERROR",KEY_ERROR:"KEY_ERROR",KEY_STATUS_CHANGE_ERROR:"KEY_STATUS_CHANGE_ERROR",KEY_UPDATE_ERROR:"KEY_UPDATE_ERROR",KEY_LOAD_ERROR:"KEY_LOAD_ERROR",KEY_LOAD_TIMEOUT:"KEY_LOAD_TIMEOUT",KEY_GENERATE_REQUEST_ERROR:"KEY_GENERATE_REQUEST_ERROR",INCOMPATIBLE_KEYSYSTEMS:"INCOMPATIBLE_KEYSYSTEMS",INVALID_ENCRYPTED_EVENT:"INVALID_ENCRYPTED_EVENT",INVALID_KEY_SYSTEM:"INVALID_KEY_SYSTEM",LICENSE_SERVER_CERTIFICATE_ERROR:"LICENSE_SERVER_CERTIFICATE_ERROR",MULTIPLE_SESSIONS_SAME_INIT_DATA:"MULTIPLE_SESSIONS_SAME_INIT_DATA",BUFFER_APPEND_ERROR:"BUFFER_APPEND_ERROR",BUFFER_FULL_ERROR:"BUFFER_FULL_ERROR",BUFFER_TYPE_UNKNOWN:"BUFFER_TYPE_UNKNOWN",MEDIA_ERR_BLOCKED_AUTOPLAY:"MEDIA_ERR_BLOCKED_AUTOPLAY",MEDIA_ERR_PLAY_NOT_ALLOWED:"MEDIA_ERR_PLAY_NOT_ALLOWED",MEDIA_ERR_NOT_LOADED_METADATA:"MEDIA_ERR_NOT_LOADED_METADATA",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_UNKNOWN:"MEDIA_ERR_UNKNOWN",MEDIA_SOURCE_NOT_SUPPORTED:"MEDIA_SOURCE_NOT_SUPPORTED",MEDIA_KEYS_NOT_SUPPORTED:"MEDIA_KEYS_NOT_SUPPORTED",DISCONTINUITY_ENCOUNTERED:"DISCONTINUITY_ENCOUNTERED",NONE:"NONE"}},7367:function(e,t,i){function n(e,t,i){return e+" ("+t+") "+i}i.d(t,{Z:function(){return n}})},8750:function(e,t,i){i.d(t,{Z:function(){return a}});var n=i(9822),r=i(5389);function a(e,t){var i=t.defaultCode,t=t.defaultReason;return(0,n.Z)(e)?e:(e=e instanceof Error?e.toString():t,new r.Z(i,e))}},9822:function(e,t,i){i.d(t,{Z:function(){return l}});var n=i(5157),r=i(5992),a=i(3714),s=i(9362),o=i(5389);function l(e){return(e instanceof n.Z||e instanceof a.Z||e instanceof o.Z||e instanceof s.Z)&&0<=Object.keys(r.ZB).indexOf(e.type)}},3714:function(e,t,i){i.d(t,{Z:function(){return r}});var o=i(7326),n=i(4578),t=i(2146),l=i(5992),u=i(7367),r=function(a){function s(e,t,i){var n=a.call(this)||this,r=(Object.setPrototypeOf((0,o.Z)(n),s.prototype),n.name="MediaError",n.type=l.ZB.MEDIA_ERROR,n.code=e,n.message=(0,u.Z)(n.name,n.code,t),n.fatal=!1,null==i?void 0:i.adaptation);if(void 0!==r)switch(r.type){case"audio":n.trackInfo={type:"audio",track:r.toAudioTrack()};break;case"video":n.trackInfo={type:"video",track:r.toVideoTrack()};break;case"text":n.trackInfo={type:"text",track:r.toTextTrack()}}return n}return(0,n.Z)(s,a),s}((0,t.Z)(Error))},9362:function(e,t,i){i.d(t,{Z:function(){return n}});var a=i(7326),s=i(4578),t=i(2146),o=i(5992),l=i(7367),n=function(n){function r(e,t){var i=n.call(this)||this;return Object.setPrototypeOf((0,a.Z)(i),r.prototype),i.name="NetworkError",i.type=o.ZB.NETWORK_ERROR,i.xhr=void 0===t.xhr?null:t.xhr,i.url=t.url,i.status=t.status,i.errorType=t.type,i.code=e,i.message=(0,l.Z)(i.name,i.code,t.message),i.fatal=!1,i}return(0,s.Z)(r,n),r.prototype.isHttpError=function(e){return this.errorType===o.br.ERROR_HTTP_CODE&&this.status===e},r}((0,t.Z)(Error))},5389:function(e,t,i){i.d(t,{Z:function(){return n}});var a=i(7326),s=i(4578),t=i(2146),o=i(5992),l=i(7367),n=function(n){function r(e,t){var i=n.call(this)||this;return Object.setPrototypeOf((0,a.Z)(i),r.prototype),i.name="OtherError",i.type=o.ZB.OTHER_ERROR,i.code=e,i.message=(0,l.Z)(i.name,i.code,t),i.fatal=!1,i}return(0,s.Z)(r,n),r}((0,t.Z)(Error))},9105:function(e,t,i){i.d(t,{Z:function(){return r}});var o=i(7326),n=i(4578),r=function(a){function s(e,t,i,n){var r=a.call(this)||this;switch(Object.setPrototypeOf((0,o.Z)(r),s.prototype),r.name="RequestError",r.url=e,void 0!==n&&(r.xhr=n),r.status=t,r.type=i){case"TIMEOUT":r.message="The request timed out";break;case"ERROR_EVENT":r.message="An error prevented the request to be performed successfully";break;case"PARSE_ERROR":r.message="An error happened while formatting the response data";break;case"ERROR_HTTP_CODE":r.message="An HTTP status code indicating failure was received: "+String(r.status)}return r}return(0,n.Z)(s,a),s}((0,i(2146).Z)(Error))},7273:function(e,t){t.Z={dashParsers:{wasm:null,js:null},createDebugElement:null,directfile:null,decrypt:null,htmlTextTracksBuffer:null,htmlTextTracksParsers:{},imageBuffer:null,imageParser:null,mediaSourceInit:null,nativeTextTracksBuffer:null,nativeTextTracksParsers:{},transports:{}}},7874:function(e,t,i){i=i(7273);t.Z=i.Z},3887:function(e,t,i){i.d(t,{Z:function(){return r}});var n=i(8894),r=new(function(){function e(){this.error=n.Z,this.warn=n.Z,this.info=n.Z,this.debug=n.Z,this._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},this._currentLevel="NONE"}var t=e.prototype;return t.setLevel=function(e){var t,i=this._levels[e];"number"==typeof i?(t=i,this._currentLevel=e):(t=0,this._currentLevel="NONE"),this.error=t>=this._levels.ERROR?console.error.bind(console):n.Z,this.warn=t>=this._levels.WARNING?console.warn.bind(console):n.Z,this.info=t>=this._levels.INFO?console.info.bind(console):n.Z,this.debug=t>=this._levels.DEBUG?console.log.bind(console):n.Z},t.getLevel=function(){return this._currentLevel},t.hasLevel=function(e){return this._levels[e]>=this._levels[this._currentLevel]},e}())},8999:function(e,t,i){i.d(t,{r:function(){return l},Z:function(){return u}});var p=i(3887),n=i(3274),d=i(1946),c=i(7829);var r="undefined"!=typeof window&&"function"==typeof window.Set&&"function"==typeof Array.from?function(e){return Array.from(new Set(e))}:function(e){return e.filter(function(e,t,i){return i.indexOf(e)===t})},a=i(3774);var g=i(4791);function v(e,t){var i,n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){var i;if(e)return"string"==typeof e?s(e,t):"Map"===(i="Object"===(i=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:i)||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?s(e,t):void 0}(e))||t&&e&&"number"==typeof e.length)return n&&(e=n),i=0,function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=this.start&&(void 0===this.end||e=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.start&&(void 0===e.end||e.end>t)})},t.getNextPeriod=function(t){return(0,a.Z)(this.periods,function(e){return e.start>t})},t.getPeriodAfter=function(e){var t=e.end;return void 0===t||void 0===(e=(0,a.Z)(this.periods,function(e){return void 0===e.end||te.length?m.Z.error("Manifest: error when updating Periods"):(an)break;this.periods.shift()}}this.adaptations=void 0===this.periods[0]?{}:this.periods[0].adaptations,this.trigger("manifestUpdate",i)},e}(t.Z)},520:function(e,t,i){i.d(t,{K:function(){return a},z:function(){return n}});var r=i(1946);function n(e,t){return e.segment.id===t.segment.id&&e.representation.uniqueId===t.representation.uniqueId}function a(e){var t,i,n;return(0,r.Z)(e)?"":(t=e.period,i=e.adaptation,n=e.representation,e=e.segment,i.type+" P: "+t.id+" A: "+i.id+" R: "+n.id+" S: "+(e.isInit?"init":e.complete?e.time+"-"+e.duration:""+e.time))}},2689:function(e,t,i){i.d(t,{s:function(){return n}});var n=Math.pow(2,32)-1},2297:function(e,t,i){i.d(t,{Qy:function(){return h},Xj:function(){return p},iz:function(){return c},lp:function(){return u},nR:function(){return f},t_:function(){return l},vA:function(){return n}});var a=i(3887),s=i(811),d=i(6968);function o(e,t){var i,n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){var i;if(e)return"string"==typeof e?r(e,t):"Map"===(i="Object"===(i=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:i)||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?r(e,t):void 0}(e))||t&&e&&"number"==typeof e.length)return n&&(e=n),i=0,function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);ie.length))return e=l(e,t,t+16),(0,n.ci)(e)}}},4644:function(e,t,i){i.d(t,{J6:function(){return u},LD:function(){return l},MM:function(){return o},Qx:function(){return s},R0:function(){return c},Wf:function(){return n},s9:function(){return d}});var h=i(3887),g=i(6968),f=i(3635),r=i(2689),v=i(2297),m=i(6807);function y(e,t){var i,n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){var i;if(e)return"string"==typeof e?a(e,t):"Map"===(i="Object"===(i=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:i)||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?a(e,t):void 0}(e))||t&&e&&"number"==typeof e.length)return n&&(e=n),i=0,function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i>>31)throw new Error("sidx with reference_type `1` not yet implemented");var l=(0,g.pX)(e,d),d=d+4+4;s.push({time:n,duration:l,timescale:a,range:[r,r+u-1]}),n+=l,r+=u}return s}function s(e){e=(0,m.XA)(e);if(null!==e){var t,e=(0,v.t_)(e,1952867444);if(null!==e)return 1===(t=e[0])?(0,g.pV)(e,4):0===t?(0,g.pX)(e,4):void 0}}function o(e){e=(0,m.uq)(e);if(0!==e.length){for(var t=0,i=y(e);!(n=i()).done;){var n=n.value,r=(0,v.t_)(n,1953658222);if(null===r)return;var a=0,s=r[a];if(a+=1,1r.s?((i=new Uint8Array(t+8)).set((0,g.kh)(1),0),i.set(e.subarray(4,8),4),i.set((0,g.el)(t+8),8),i.set(e.subarray(8,t),16),i):(e.set((0,g.kh)(t),0),e);if(1!==n)return t<=r.s?(e.set((0,g.kh)(t),0),e):((i=new Uint8Array(t+8)).set((0,g.kh)(1),0),i.set(e.subarray(4,8),4),i.set((0,g.el)(t+8),8),i.set(e.subarray(8,t),16),i);if(t<16)throw new Error("Cannot update box length: box too short");return e.set((0,g.el)(t),8),e}function d(e){for(var t=[],i=0;i=i?n:(new Array(i+1).join("0")+n).slice(-i)}}function n(e,t,i){return t=t,i=i,-1===(e=e).indexOf("$")?e:e.replace(/\$\$/g,"$").replace(/\$RepresentationID\$/g,String(t)).replace(/\$Bandwidth(\%0(\d+)d)?\$/g,s(void 0===i?0:i))}function r(n,r){return function(e){return-1===e.indexOf("$")?e:e.replace(/\$\$/g,"$").replace(/\$Number(\%0(\d+)d)?\$/g,function(e,t,i){if(void 0===r)throw new Error("Segment number not defined in a $Number$ scheme");return s(r)(e,t,i)}).replace(/\$Time(\%0(\d+)d)?\$/g,function(e,t,i){if(void 0===n)throw new Error("Segment time not defined in a $Time$ scheme");return s(n)(e,t,i)})}}},4541:function(n,e,t){t.d(e,{Z:function(){return Be}});var r=t(7904),a=t(1946),k=t(6872),B=t(3887),F=t(3274),_=t(9829);function x(e){var t=Date.parse(e)-performance.now();if(!isNaN(t))return t;B.Z.warn("DASH Parser: Invalid clock received: ",e)}function o(e){for(var t=e.representations,i=null,n=0;n=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function V(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.length)return null;if((a=e[s]).start===r)return{prevSegmentsIdx:s,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(a.start>r)return null}else for(var l=0,u=t[0],d=r;;){var c=u.getAttribute("d"),c=null===c?null:parseInt(c,10);if(null===c||Number.isNaN(c))return null;var h=u.getAttribute("r"),h=null===h?null:parseInt(h,10);if(null!==h){if(Number.isNaN(h)||h<0)return null;if(0=t.length)return null;f=(u=t[l]).getAttribute("t"),h=null===f?null:parseInt(f,10);if(null!==h){if(Number.isNaN(h))return null;d=h}if(d===i)return{newElementsIdx:l,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(r=e.length)return B.Z.info('DASH: Cannot perform "based" update. New timeline too short'),g(e);t=t.slice(n);if(0r)return B.Z.info('DASH: Cannot perform "based" update. The new timeline has a different form at the beginning.'),g(e);void 0!==n.repeatCount&&n.repeatCount>o.repeatCount&&(o.repeatCount=n.repeatCount);for(var l=[],u=[],d=1+s;d=Math.min(t,null!=(n=this._scaledPeriodEnd)?n:1/0))return!1}return void 0===this._scaledPeriodEnd?t+i>this._scaledPeriodStart&&void 0:(0,p.gT)(e,this._index)-ithis._scaledPeriodStart},e.isSegmentStillAvailable=function(e){if(e.isInit)return!0;this._refreshTimeline(),null===this._index.timeline&&(this._index.timeline=this._getTimeline());var t=this._index,i=t.timeline,n=t.timescale,t=t.indexTimeOffset;return(0,J.Z)(e,i,n,t)},e.checkDiscontinuity=function(e){this._refreshTimeline();var t=this._index.timeline;return null===t&&(t=this._getTimeline(),this._index.timeline=t),(0,p._j)({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)},e.canBeOutOfSyncError=function(e){return!!this._isDynamic&&e instanceof Q.Z&&e.isHttpError(404)},e._replace=function(e){this._parseTimeline=e._parseTimeline,this._index=e._index,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._manifestBoundsCalculator=e._manifestBoundsCalculator,this._isLastPeriod=e._isLastPeriod},e._update=function(e){null===this._index.timeline&&(this._index.timeline=this._getTimeline()),null===e._index.timeline&&(e._index.timeline=e._getTimeline()),(0,$.Z)(this._index.timeline,e._index.timeline)&&(this._index.startNumber=e._index.startNumber),this._index.endNumber=e._index.endNumber,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._isLastPeriod=e._isLastPeriod},e.isFinished=function(){if(!this._isDynamic||!this._isLastPeriod)return!0;null===this._index.timeline&&(this._index.timeline=this._getTimeline());var e=this._index.timeline;return void 0!==this._scaledPeriodEnd&&0!==e.length&&(e=e[e.length-1],(0,p.jH)(e,null,this._scaledPeriodEnd)+s(this._index.timescale)>=this._scaledPeriodEnd)},e.isInitialized=function(){return!0},f.isTimelineIndexArgument=function(e){return"function"==typeof e.timelineParser||Array.isArray(e.timeline)},e._refreshTimeline=function(){var e;null===this._index.timeline&&(this._index.timeline=this._getTimeline()),this._isDynamic&&null!=(e=this._manifestBoundsCalculator.estimateMinimumBound())&&(e=(0,p.gT)(e,this._index),e=(0,X.Z)(this._index.timeline,e),void 0!==this._index.startNumber?this._index.startNumber+=e:void 0!==this._index.endNumber&&(this._index.startNumber=e+1))},f.getIndexEnd=function(e,t){return e.length<=0?null:Math.min((0,p.jH)(e[e.length-1],null,t),null!=t?t:1/0)},e._getTimeline=function(){if(null===this._parseTimeline)return null!==this._index.timeline?this._index.timeline:(B.Z.error("DASH: Timeline already lazily parsed."),[]);var e=this._parseTimeline();this._parseTimeline=null;var t,i=k.Z.getCurrent().MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY;return null===this._unsafelyBaseOnPreviousIndex||e.lengththis._periodStart?(i-this._periodStart)*e:0,Math.floor(i/t)*t):void 0},t._getLastSegmentStart=function(){var e,t,i,n=this._index,r=n.duration,a=n.timescale,s=n.endNumber,n=n.startNumber,n=void 0===n?1:n;return this._isDynamic?void 0!==(t=this._manifestBoundsCalculator.estimateMaximumBound())?(i=this._aggressiveMode?r/a:0,void 0!==this._scaledRelativePeriodEnd&&this._scaledRelativePeriodEnd<(t+i-this._periodStart)*this._index.timescale?(e=Math.ceil(this._scaledRelativePeriodEnd/r),((e=void 0!==s&&s-n+1=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function se(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function de(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function ge(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i","application/xml").documentElement.childNodes[0]),n.push({start:h,end:f,id:m.id,data:{type:"dash-event-stream",value:{schemeIdUri:l,timescale:u,element:p}}}))}return n}(t.children.eventStreams,a,u),n={id:o,start:a,end:r,duration:s,adaptations:c,streamEvents:d};m.unshift(n),S.lastPositionIsKnown()||(e=function(e){for(var t,i=null,n=!0,e=(0,P.Z)(e).filter(function(e){return null!=e}),r=w((0,R.Z)(e,function(e){return e}));!(t=r()).done;)for(var a=w(t.value.representations);!(s=a()).done;){var s=s.value.index.getLastAvailablePosition();null!==s&&(n=!1,"number"==typeof s)&&(i=null==i?s:Math.max(i,s))}{if(null!=i)return i;if(n)return null}return}(c),b?"number"==typeof e?(h=performance.now()/1e3,S.setLastPosition(e,h)):void 0!==(i=ye(g,a))&&(f=i[0],l=i[1],S.setLastPosition(f,l)):"number"==typeof e&&S.setLastPosition(e))}),T=p.length-1;0<=T;T--)i();g.isDynamic&&!S.lastPositionIsKnown()&&void 0!==(t=ye(g,0))&&(e=t[0],t=t[1],S.setLastPosition(e,t));var n=m;if(0===n.length)return[];for(var r=[n[0]],l=1;lu.start)&&(B.Z.warn("DASH: Updating overlapping Periods.",null==d?void 0:d.start,u.start),d.duration=u.start-d.start,d.end=u.start,!(0=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function Ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i",r=(new DOMParser).parseFromString(r,"text/xml");if(null==r||0===r.children.length)throw new Error("DASH parser: Invalid external ressources");for(var o,l,u=r.children[0].children,d=[],c=[],h=0;h=t)return i;if(-1===n.repeatCount)return i;if(0===n.repeatCount)e.shift(),i+=1;else{var r=e[1];if(void 0!==r&&r.start<=t)e.shift(),i+=1;else{if(n.duration<=0)return i;for(var a=n.start+n.duration,s=1;an.repeatCount))return r=n.repeatCount-s,n.start=a,n.repeatCount=r,i+s;e.shift(),i=n.repeatCount+1}}}return i}i.d(t,{Z:function(){return n}})},3911:function(e,t,i){i.d(t,{KF:function(){return a},PZ:function(){return n},_j:function(){return u},gT:function(){return o},jH:function(){return s},zG:function(){return l}});var r=i(1946);function a(e,t,i){var n=e.repeatCount;return 0<=n?n:(n=(0,r.Z)(t)?void 0!==i?i:Number.MAX_VALUE:t.start,Math.ceil((n-e.start)/e.duration)-1)}function s(e,t,i){var n=e.start,r=e.duration;return r<=0?n:n+(a(e,t,i)+1)*r}function o(e,t){return e*t.timescale+(null!=(e=t.indexTimeOffset)?e:0)}function l(e,t){return(e-(null!=(e=t.indexTimeOffset)?e:0))/t.timescale}function n(e,t,i){return[e*i,(e+t)*i]}function u(e,t,i){var n,r,a=e.timeline,t=o(t,e);return!(t<0)&&!((r=function(e,t){for(var i=0,n=e.length;i>>1;e[r].start<=t?i=1+r:n=r}return i-1}(a,t))<0||r>=a.length-1)&&!((n=a[r]).duration<=0)&&void 0!==(a=a[r+1])&&(r=a.start,s(n,a,i)<=t)&&te.time)return!1;if(s===e.time)return void 0===a.range?void 0===e.range:null!=e.range&&a.range[0]===e.range[0]&&a.range[1]===e.range[1];if(0<=a.repeatCount&&void 0!==a.duration)return(s=(s-a.start)/a.duration-1)%1==0&&s<=a.repeatCount}return!1}i.d(t,{Z:function(){return n}})},5505:function(e,t,i){i.d(t,{Z:function(){return n}});var d=i(3714),c=i(3887),h=i(3911);function n(e,t){if(0===e.length)e.push.apply(e,t);else{if(0===t.length)return!1;var i=e.length,n=t[0].start,r=e[i-1];if((0,h.jH)(r,t[0])n?(c.Z.warn("RepresentationIndex: Manifest update removed all previous segments"),e.splice.apply(e,[0,i].concat(t)),!0):(void 0===l.repeatCount||l.repeatCount<=0?(l.repeatCount<0&&(l.repeatCount=Math.floor((n-l.start)/l.duration)-1),e.splice.apply(e,[a+1,i-(a+1)].concat(t))):l.start+l.duration*(l.repeatCount+1)<=n?e.splice.apply(e,[a+1,i-(a+1)].concat(t)):(s=(n-l.start)/l.duration-1)%1==0&&l.duration===t[0].duration?(o=t[0].repeatCount<0?-1:t[0].repeatCount+s+1,e.splice.apply(e,[a,i-a].concat(t)),e[a].start=l.start,e[a].repeatCount=o):(c.Z.warn("RepresentationIndex: Manifest update removed previous segments"),e[a].repeatCount=Math.floor(s),e.splice.apply(e,[a+1,i-(a+1)].concat(t))),!1)}var r=e[e.length-1],u=t[t.length-1];if(void 0!==r.repeatCount&&r.repeatCount<0)return r.start>u.start?(c.Z.warn("RepresentationIndex: The new index is older than the previous one"),!1):(c.Z.warn('RepresentationIndex: The new index is "bigger" than the previous one'),e.splice.apply(e,[0,i].concat(t)),!0);r=r.start+r.duration*(r.repeatCount+1);if(u.start+u.duration*(u.repeatCount+1)<=r)return c.Z.warn("RepresentationIndex: The new index is older than the previous one"),!1;c.Z.warn('RepresentationIndex: The new index is "bigger" than the previous one'),e.splice.apply(e,[0,i].concat(t))}return!0}},5734:function(e,t,i){var T=i(6923),w=/&#([0-9]+);/g,M=/
/gi,A=/]*>([\s\S]*?)<\/style[^>]*>/i,L=/\s*

]+))?>(.*)/i,I=/]+?start="?([0-9]*)"?[^0-9]/i;function D(e){for(var t=/\.(\S+)\s*{([^}]*)}/gi,i={},n=t.exec(e);null!==n;){var r=n[1],a=function(e,t){t=new RegExp("\\s*"+t+":\\s*(\\S+);","i").exec(e);return Array.isArray(t)?t[1]:null}(n[2],"lang");null!=r&&null!=a&&(i[a]=r),n=t.exec(e)}return i}t.Z=function(e,t,i){var n,r=/]/gi,a=/]|<\/body>/gi,s=[],o=A.exec(e),o=Array.isArray(o)?o[1]:"",l=(a.exec(e),D(o)),u=null===(o=/p\s*{([^}]*)}/gi.exec(o=o))?"":o[1];if((0,T.Z)(i)&&void 0===(n=l[i]))throw new Error("sami: could not find lang "+i+" in CSS");for(;;){if(d=r.exec(e),c=a.exec(e),null===d&&null===c)break;if(null===d||null===c||d.index>=c.index)throw new Error("parse error");var d=e.slice(d.index,c.index),c=I.exec(d);if(!Array.isArray(c))throw new Error("parse error (sync time attribute)");c=+c[1];if(isNaN(c))throw new Error("parse error (sync time attribute NaN)");S=E=b=y=m=v=g=p=f=h=void 0;for(var h=d.split("\n"),f=c/1e3,p=h.length;0<=--p;){var g=L.exec(h[p]);if(Array.isArray(g)){var v=g[1],g=g[2];if(n===v)if(" "===g)s[s.length-1].end=f;else{for(var v=document.createElement("DIV"),m=(v.className="rxp-texttrack-region",document.createElement("DIV")),y=(m.className="rxp-texttrack-div",m.style.position="absolute",m.style.bottom="0",m.style.width="100%",m.style.color="#fff",m.style.textShadow="-1px -1px 0 #000,1px -1px 0 #000,-1px 1px 0 #000,1px 1px 0 #000",document.createElement("div")),b=(y.className="rxp-texttrack-p",(0,T.Z)(u)&&(y.style.cssText=u),g.split(M)),E=0;E/gi,A=/]*>([\s\S]*?)<\/style[^>]*>/i,L=/\s*

]+))?>(.*)/i,I=/]+?start="?([0-9]*)"?[^0-9]/i;function D(e){for(var t=/\.(\S+)\s*{([^}]*)}/gi,i={},n=t.exec(e);Array.isArray(n);){var r=n[1],a=function(e,t){t=new RegExp("\\s*"+t+":\\s*(\\S+);","i").exec(e);return Array.isArray(t)?t[1]:null}(n[2],"lang");null!=r&&null!=a&&(i[a]=r),n=t.exec(e)}return i}t.Z=function(e,t,i){var n,r=/]/gi,a=/]|<\/body>/gi,s=[],o=null!==(o=A.exec(e))?o[1]:"",o=(a.exec(e),D(o));if((0,T.Z)(i)&&void 0===(n=o[i]))throw new Error("sami: could not find lang "+i+" in CSS");for(;;){if(l=r.exec(e),u=a.exec(e),null===l&&null===u)break;if(null===l||null===u||l.index>=u.index)throw new Error("parse error");var l=e.slice(l.index,u.index),u=I.exec(l);if(null===u)throw new Error("parse error (sync time attribute)");var d,c,u=+u[1];if(isNaN(u))throw new Error("parse error (sync time attribute NaN)");d=c=p=f=h=void 0;for(var h=l.split("\n"),f=u/1e3,p=h.length;0<=--p;)null!==(c=L.exec(h[p]))&&(d=c[1],c=c[2],n===d)&&(" "===c?s[s.length-1].end=f:s.push({text:function(e){return e.replace(M,"\n").replace(w,function(e,t){return String.fromCharCode(Number(t))})}(c),start:f+t}))}for(var g=s,v=[],m=0;m|\u2265/g,">").replace(/\u200E/g,"‎").replace(/\u200F/g,"‏").replace(/\u00A0/g," ")):(0,h.OE)(o)?r+="\n":(0,h.jg)(o)&&o.nodeType===Node.ELEMENT_NODE&&0/,"").replace(/<([u,i,b,c])(\..*?)?(?: .*?)?>(.*?)<\/\1>/g,"<$1$2>$3"),i=(new DOMParser).parseFromString(e,"text/html").body.childNodes,n=[],r=0;r/;if(r.test(e[0]))a=e[0],i=e.slice(1,e.length);else{if(!r.test(e[1]))return null;n=e[0],a=e[1],i=e.slice(2,e.length)}r=a;var a,e=null===(r=/^([\d:.]+)[ |\t]+-->[ |\t]+([\d:.]+)[ |\t]*(.*)$/.exec(r))||(e=s(r[1]),a=s(r[2]),null==e)||null==a?null:{start:e,end:a,settings:r[3].split(/ |\t/).reduce(function(e,t){t=t.split(":");return 2===t.length&&(e[t[0]]=t[1]),e},{})};return null===e?null:{start:e.start+t,end:e.end+t,settings:e.settings,payload:i,header:n}}},360:function(e,t,i){i.d(t,{$4:function(){return o},JF:function(){return a},tq:function(){return s},yE:function(){return r}});var n=i(6923);function r(e){for(var t=0;te.length)return[i,n];var a=(0,u.Z)(n,1835295092);if(a<0)return[i,n];a=t+a+(0,l.pX)(e,a+t);if(a>e.length)return[i,n];n=Math.max(r,a),r=e.subarray(t,n);i.push(r),t=n}return[i,null]}(null!==s?(0,l.zo)(s,t):t))[0];s=t[1];for(var n=0;ne.length)return b.Z.warn("webm: impossible length"),null;for(var n=0,r=0;re.length)return b.Z.warn("webm: impossible length"),null;for(var n=(e[t]&(1<<8-i)-1)*Math.pow(2,8*(i-1)),r=1;r=Math.pow(2,8-i))return i}function B(e,t,i){for(var n=0,r=0;r(null!=(e=this.getFirstAvailablePosition())?e:0)&&void 0},t.checkDiscontinuity=function(e){return this._refreshTimeline(),(0,d._j)(this._index,e,void 0)},t.isSegmentStillAvailable=function(e){if(e.isInit)return!0;this._refreshTimeline();var t=this._index,i=t.timeline,t=t.timescale;return(0,Z.Z)(e,i,t,0)},t.canBeOutOfSyncError=function(e){return!!this._isLive&&e instanceof U.Z&&(e.isHttpError(404)||e.isHttpError(412))},t._replace=function(e){var t=this._index.timeline,i=e._index.timeline,n=this._index.timescale,r=e._index.timescale;if(this._index=e._index,this._initialScaledLastPosition=e._initialScaledLastPosition,this._indexValidityTime=e._indexValidityTime,this._scaledLiveGap=e._scaledLiveGap,0!==t.length&&0!==i.length&&n===r){var e=t[t.length-1],a=i[i.length-1],s=(0,d.jH)(a,null);if(!((0,d.jH)(e,null)<=s))for(var o=0;o=(0,d.jH)(r,null)&&(r.duration===n.duration?r.repeatCount++:i.timeline.push({duration:n.duration,start:n.time,repeatCount:0}))},t._refreshTimeline=function(){var e,t,i;null!=this._initialScaledLastPosition&&(e=this._index,t=this._timeShiftBufferDepth,i=(performance.now()-this._indexValidityTime)/1e3+this._initialScaledLastPosition/e.timescale,null!=t)&&(i=(i-t)*e.timescale,(0,z.Z)(e.timeline,i))},e}(),G=t(8999),I=t(7714),E=t(6968),D=t(6923),V=t(8026),k=t(9829),S=t(3635),Y=t(5278),H=t(2689),i={};function n(e){var t;return null!=i[e]?i[e]:(t=(0,S.tG)(e),i[e]=t)}function _(e,t){var i=t.length+8;return i<=H.s?(0,E.zo)((0,E.kh)(i),n(e),t):(0,E.zo)((0,E.kh)(1),n(e),(0,E.el)(i+8),t)}function v(e,t){return _(e,E.zo.apply(void 0,t))}var a=t(9689);function W(e){return[{systemId:"edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",privateData:(0,E.zo)([8,1,18,16],e)}]}function K(e,t){if(void 0===t&&(t=W),null===e.firstElementChild||"ProtectionHeader"!==e.firstElementChild.nodeName)throw new Error("Protection should have ProtectionHeader child");var e=e.firstElementChild,i=(0,a.K)(null===e.textContent?"":e.textContent),n=function(e){var t=(0,E.qb)(e,8),e=(0,S.wV)(e.subarray(10,t+10));if(null===(t=(new DOMParser).parseFromString(e,"application/xml").querySelector("KID")))throw new Error("Cannot parse PlayReady private data: invalid XML");return e=null===t.textContent?"":t.textContent,t=(0,S.wO)((0,a.K)(e)),(0,S.ci)(t).toLowerCase()}(i),n=(0,S.nr)(n),e=e.getAttribute("SystemID");return{keyId:n,keySystems:[{systemId:(null!==e?e:"").toLowerCase().replace(/\{|\}/g,""),privateData:i}].concat(t(n))}}function x(e,t,i){for(var n=e.firstElementChild,r=i;null!==n;)r=t(r,n.nodeName,n),n=n.nextElementSibling;return r}var Q={audio:"audio/mp4",video:"video/mp4",text:"application/ttml+xml"},p={AACL:"audio/mp4",AVC1:"video/mp4",H264:"video/mp4",TTML:"application/ttml+xml+mp4",DFXP:"application/ttml+xml+mp4"};var q=function(T){var w=void 0===(T=void 0===T?{}:T).referenceDateTime?Date.UTC(1970,0,1,0,0,0,0)/1e3:T.referenceDateTime,a=void 0===T.minRepresentationBitrate?0:T.minRepresentationBitrate,e=T.serverSyncInfos,M=void 0!==e?e.serverTimestamp-e.clientTime:void 0;function o(t,e){var i=x(t,function(e,t,i){return"CustomAttributes"===t&&e.push.apply(e,x(i,function(e,t,i){return"Attribute"===t&&(t=i.getAttribute("Name"),i=i.getAttribute("Value"),null!==t)&&null!==i&&e.push(t+"="+i),e},[])),e},[]);function n(e){e=t.getAttribute(e);return null==e?void 0:e}switch(e){case"audio":var r,a=n("AudioTag"),s=n("BitsPerSample"),o=n("Channels"),l=n("CodecPrivateData"),u=n("FourCC"),d=n("PacketSize"),c=n("SamplingRate"),h=n("Bitrate"),h=void 0===h||isNaN(parseInt(h,10))?0:parseInt(h,10);return void 0!==u&&void 0===p[u]||void 0===l?(L.Z.warn("Smooth parser: Unsupported audio codec. Ignoring quality level."),null):(r=l,r=0===(f="AACH"===(f=u)?5:(0,D.Z)(r)?(248&parseInt(r.substring(0,2),16))>>3:2)?"mp4a.40.2":"mp4a.40."+f,{audiotag:void 0!==a?parseInt(a,10):a,bitrate:h,bitsPerSample:void 0!==s?parseInt(s,10):s,channels:void 0!==o?parseInt(o,10):o,codecPrivateData:l,codecs:r,customAttributes:i,mimeType:void 0!==u?p[u]:u,packetSize:void 0!==d?parseInt(d,10):d,samplingRate:void 0!==c?parseInt(c,10):c});case"video":var f=n("CodecPrivateData"),a=n("FourCC"),h=n("MaxWidth"),s=n("MaxHeight"),o=n("Bitrate"),l=void 0===o||isNaN(parseInt(o,10))?0:parseInt(o,10);return void 0!==a&&void 0===p[a]||void 0===f?(L.Z.warn("Smooth parser: Unsupported video codec. Ignoring quality level."),null):(u=null!==(r=/00000001\d7([0-9a-fA-F]{6})/.exec(r=f))&&(0,D.Z)(r[1])?"avc1."+r[1]:"avc1.4D401E",{bitrate:l,customAttributes:i,mimeType:void 0!==a?p[a]:a,codecPrivateData:f,codecs:u,width:void 0!==h?parseInt(h,10):void 0,height:void 0!==s?parseInt(s,10):void 0});case"text":d=n("CodecPrivateData"),c=n("FourCC"),o=n("Bitrate");return{bitrate:void 0===o||isNaN(parseInt(o,10))?0:parseInt(o,10),customAttributes:i,mimeType:void 0!==c?p[c]:c,codecPrivateData:(0,Y.Z)(d,"")};default:return L.Z.error("Smooth Parser: Unrecognized StreamIndex type: "+e),null}}function A(e){var t=e.root,i=e.timescale,u=e.baseUrl,d=e.protections,c=e.timeShiftBufferDepth,h=e.manifestReceivedTime,f=e.isLive,e=t.getAttribute("Timescale"),i=null===e||isNaN(+e)?i:+e,e=t.getAttribute("Type");if(null===e)throw new Error("StreamIndex without type.");(0,I.Z)(G.r,e)||L.Z.warn("Smooth Parser: Unrecognized adaptation type:",e);var s,p=e,e=t.getAttribute("Subtype"),n=t.getAttribute("Language"),r=t.getAttribute("Url"),g=null===r?"":r,r=x(t,function(e,t,i){switch(t){case"QualityLevel":var n=o(i,p);if(null===n)return e;("video"!==p||n.bitrate>a)&&e.qualityLevels.push(n);break;case"c":e.cNodes.push(i)}return e},{qualityLevels:[],cNodes:[]}),t=r.qualityLevels,r=r.cNodes,v={timeline:(s=r).reduce(function(e,t,i){var n=t.getAttribute("d"),r=t.getAttribute("t"),t=t.getAttribute("r"),t=null!==t?+t-1:0,r=null!==r?+r:void 0,n=null!==n?+n:void 0;if(0===i)r=void 0===r||isNaN(r)?0:r;else{var a=e[i-1];if(null==r||isNaN(r)){if(null==a.duration||isNaN(a.duration))throw new Error("Smooth: Invalid CNodes. Missing timestamp.");r=a.start+a.duration*(a.repeatCount+1)}}if(null==n||isNaN(n)){a=s[i+1];if(void 0===a)return e;i=a.getAttribute("t"),a=(0,D.Z)(i)?+i:null;if(null===a)throw new Error("Can't build index timeline from Smooth Manifest.");n=a-r}return e.push({duration:n,start:r,repeatCount:t}),e},[]),timescale:i},m=((0,y.Z)(0!==t.length,"Adaptation should have at least one playable representation."),p+((0,D.Z)(n)?"_"+n:"")),r=t.map(function(e){var t,i={timeline:v.timeline,timescale:v.timescale,media:(i=e.bitrate,n=e.customAttributes,g.replace(/\{bitrate\}/g,String(i)).replace(/{CustomAttributes}/g,0>>0,r=0;r>>0,r=0;r>>0;if(0!=n)for(var r,a,i=0|i,s=0<=i?Math.min(i,n-1):Math.max(n+i,0);s=n.length)throw new Error("Unable to parse base64 string.");e=n[e];if(255===e)throw new Error("Unable to parse base64 string.");return e}function a(e){for(var t="",i=e.length,n=2;n>2])+r[(3&e[n-2])<<4|e[n-1]>>4])+r[(15&e[n-1])<<2|e[n]>>6])+r[63&e[n]];return n===i+1&&(t=(t+=r[e[n-2]>>2])+r[(3&e[n-2])<<4]+"=="),t=n===i?(t=(t+=r[e[n-2]>>2])+r[(3&e[n-2])<<4|e[n-1]>>4])+r[(15&e[n-1])<<2]+"=":t}function s(e){var t=e.length%4,i=e,e=(0!=t&&(l.Z.warn("base64ToBytes: base64 given miss padding"),i+=3==t?"=":2==t?"==":"==="),i.indexOf("="));if(-1!==e&&e>16,a[o+1]=n>>8&255,a[o+2]=255&n;return a.subarray(0,a.length-t)}},6968:function(e,t,i){function n(){for(var e,t=arguments.length,i=-1,n=0;++i>>8&255,255&e])}function u(e){return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e])}function d(e){var t=e%4294967296,e=(e-t)/4294967296;return new Uint8Array([e>>>24&255,e>>>16&255,e>>>8&255,255&e,t>>>24&255,t>>>16&255,t>>>8&255,255&t])}function c(e,t){return(e[t+0]<<0)+(e[t+1]<<8)}function h(e,t){return e[t+0]+256*e[t+1]+65536*e[t+2]+16777216*e[t+3]}function f(e){return new Uint8Array([255&e,e>>>8&255,e>>>16&255,e>>>24&255])}i.d(t,{O_:function(){return f},QI:function(){return a},XT:function(){return l},dN:function(){return h},el:function(){return d},kh:function(){return u},pV:function(){return o},pX:function(){return s},qb:function(){return c},zK:function(){return r},zo:function(){return n}})},7864:function(e,t,i){i.d(t,{Z:function(){return r}});var n=i(7733);function r(i,e){return(0,n.Z)(e,function(e){var t=setTimeout(function(){return e()},i);return function(){return clearTimeout(t)}})}},7733:function(e,t,i){function n(a,e){var s;return new Promise(function(t,i){if(null!==a.cancellationError)return i(a.cancellationError);var n=!1;function r(e){void 0!==s&&s(),i(e)}s=e(function(e){a.deregister(r),n=!0,t(e)},function(e){a.deregister(r),n=!0,i(e)}),n||a.register(r)})}i.d(t,{Z:function(){return n}})},1959:function(e,t,i){i.d(t,{Z:function(){return a}});var n=i(3887),r=i(1946),a=function(){function e(){this._listeners={}}var t=e.prototype;return t.addEventListener=function(e,t,i){var n=this,r=this._listeners[e];Array.isArray(r)?r.push(t):this._listeners[e]=[t],void 0!==i&&i.register(function(){n.removeEventListener(e,t)})},t.removeEventListener=function(e,t){var i;(0,r.Z)(e)?this._listeners={}:(i=this._listeners[e],Array.isArray(i)&&((0,r.Z)(t)||(-1!==(t=i.indexOf(t))&&i.splice(t,1),0===i.length))&&delete this._listeners[e])},t.trigger=function(e,t){e=this._listeners[e];Array.isArray(e)&&e.slice().forEach(function(e){try{e(t)}catch(e){n.Z.error("EventEmitter: listener error",e instanceof Error?e:null)}})},e}()},9592:function(e,t,i){function n(e,i){return"function"==typeof Array.prototype.flatMap?e.flatMap(i):e.reduce(function(e,t){t=i(t);return Array.isArray(t)?e.push.apply(e,t):e.push(t),e},[])}i.d(t,{Z:function(){return n}})},2572:function(e,t,i){i.d(t,{Z:function(){return r}});var n=.3;function r(e){return e*(1+(2*Math.random()-1)*n)}},908:function(e,t,i){function n(){var e="",t=-1;return function(){return++t>=Number.MAX_SAFE_INTEGER&&(e+="0",t=0),e+String(t)}}i.d(t,{Z:function(){return n}})},6923:function(e,t,i){function n(e){return"string"==typeof e&&0u&&i.push({start:u,end:a[d].start}),u=a[d].end;u=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=this._array.length)throw new Error("Invalid index.");return this._array[e]},t.toArray=function(){return this._array.slice()},t.findFirst=function(e){return(0,n.Z)(this._array,e)},t.has=function(e){return(0,r.Z)(this._array,e)},t.removeElement=function(e){e=this._array.indexOf(e);if(0<=e)return this._array.splice(e,1),e},t.head=function(){return this._array[0]},t.last=function(){return this._array[this._array.length-1]},t.shift=function(){return this._array.shift()},t.pop=function(){return this._array.pop()},e}()},9252:function(e,t,i){function n(e,t,i){return"function"==typeof String.prototype.startsWith?e.startsWith(t,i):(i="number"==typeof i?Math.max(i,0):0,e.substring(i,i+t.length)===t)}i.d(t,{Z:function(){return n}})},3635:function(e,t,i){i.d(t,{DM:function(){return g},TZ:function(){return n},ci:function(){return f},nr:function(){return u},tG:function(){return a},uR:function(){return s},wO:function(){return p},wV:function(){return r}});var c=i(3887),d=i(811),o="object"==typeof window&&"function"==typeof window.TextDecoder,h="object"==typeof window&&"function"==typeof window.TextEncoder;function n(e){for(var t=new ArrayBuffer(2*e.length),i=new Uint8Array(t),n=0;n>8&255}return i}function r(e){if(o)try{return new TextDecoder("utf-16le").decode(e)}catch(e){var t=e instanceof Error?e:"";c.Z.warn("Utils: could not use TextDecoder to parse UTF-16LE, fallbacking to another implementation",t)}for(var i="",n=0;n=t?e:new Array(t-e.length+1).join("0")+e}function s(e){if(o)try{return(new TextDecoder).decode(e)}catch(e){var t=e instanceof Error?e:"";c.Z.warn("Utils: could not use TextDecoder to parse UTF-8, fallbacking to another implementation",t)}var t=e,i=function(e){for(var t="",i=0;i>>4).toString(16))+(15&e[n]).toString(16),0A(g,i)||d||p))&&(r=!0);if(!0!==r&&(!0===n||null!==g))return s="seeking"===o||null!==g&&"seeking"===g.reason||t.seeking?"seeking":1===f?"not-ready":"buffering",null!==g&&g.reason===s?{reason:g.reason,timestamp:g.timestamp,position:m}:{reason:s,timestamp:performance.now(),position:m};return null}(i,t,{lowLatencyMode:d._lowLatencyMode,withMediaSource:d._withMediaSource})),e=function(e,t){var i=I.Z.getCurrent().MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING;if(e.freezing)return t.ended||t.paused||0===t.readyState||0===t.playbackRate||e.position!==t.position?null:e.freezing;return"timeupdate"===t.event&&void 0!==t.bufferGap&&t.bufferGap>i&&!t.ended&&!t.paused&&1<=t.readyState&&0!==t.playbackRate&&t.position===e.position?{timestamp:performance.now()}:null}(i,t),i=(0,V.Z)({},{rebuffering:r,freezing:e,pendingInternalSeek:n},t);return U.Z.hasLevel("DEBUG")&&U.Z.debug("API: current media element state tick","event",i.event,"position",i.position,"seeking",i.seeking,"internalSeek",i.pendingInternalSeek,"rebuffering",null!==i.rebuffering,"freezing",null!==i.freezing,"ended",i.ended,"paused",i.paused,"playbackRate",i.playbackRate,"readyState",i.readyState),i},r=new Y.Z(n("init"),this._canceller.signal),s=function(e){var t=n(e);U.Z.hasLevel("DEBUG")&&U.Z.debug("API: current playback timeline:\n"+function(e,t){for(var i="",n="",r=0;r=s._periods.length()||(n=s._periods.get(t),(0,Z.Z)(n.audio)||(i=n.period,n=n.audio,r=i.getSupportedAdaptations("audio"),null===(a=s._audioChoiceMemory.get(i)))||void 0!==a&&(0,G.Z)(r,a)?e(t+1):(a=R(r,o),s._audioChoiceMemory.set(i,a),n.adaptationRef.setValue(a),e(0)))})(0)},t._resetChosenTextTracks=function(){var s=this,o=C(this._preferredTextTracks);(function e(t){var i,n,r,a;t>=s._periods.length()||(n=s._periods.get(t),(0,Z.Z)(n.text)||(i=n.period,n=n.text,r=i.getSupportedAdaptations("text"),null===(a=s._textChoiceMemory.get(i)))||void 0!==a&&(0,G.Z)(r,a)?e(t+1):(a=P(r,o,s._audioChoiceMemory.get(i)),s._textChoiceMemory.set(i,a),n.adaptationRef.setValue(a),e(0)))})(0)},t._resetChosenVideoTracks=function(){var o=this,l=this._preferredVideoTracks;(function e(t){if(!(t>=o._periods.length())){var i=o._periods.get(t);if(!(0,Z.Z)(i.video)){var n,r=i.period,i=i.video,a=r.getSupportedAdaptations("video"),s=o._videoChoiceMemory.get(r);if(null!==s)return void 0!==s&&(0,G.Z)(a,s.baseAdaptation)?(n=u(s.baseAdaptation,o.trickModeTrackEnabled)).id===s.adaptation.id?void e(t+1):(o._videoChoiceMemory.set(r,{baseAdaptation:s.baseAdaptation,adaptation:n}),i.adaptationRef.setValue(n),e(0)):(null===(s=N(a,l))?(o._videoChoiceMemory.set(r,null),i.adaptationRef.setValue(null)):(n=u(s,o.trickModeTrackEnabled),o._videoChoiceMemory.set(r,{baseAdaptation:s,adaptation:n}),i.adaptationRef.setValue(n)),e(0))}e(t+1)}})(0)},e}(),ue=(0,p.Z)(),de=e.XR,ce=e.w0,he=e.it,fe=e.O0,pe=e.zU,ge=e.kJ,ve=e.Q4,(v=function(A){function e(e){void 0===e&&(e={}),o=A.call(this)||this;for(var o,e=function(e){var t,i,n,r,a,s,o,l,u,d,c,h=(T=I.Z.getCurrent()).DEFAULT_INITIAL_BITRATES,f=T.DEFAULT_LIMIT_VIDEO_WIDTH,p=T.DEFAULT_MIN_BITRATES,g=T.DEFAULT_MAX_BITRATES,v=T.DEFAULT_MAX_BUFFER_AHEAD,m=T.DEFAULT_MAX_BUFFER_BEHIND,y=T.DEFAULT_MAX_VIDEO_BUFFER_SIZE,b=T.DEFAULT_STOP_AT_END,E=T.DEFAULT_THROTTLE_WHEN_HIDDEN,S=T.DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN,T=T.DEFAULT_WANTED_BUFFER_AHEAD;if((0,Z.Z)(e.maxBufferAhead))t=v;else if(t=Number(e.maxBufferAhead),isNaN(t))throw new Error("Invalid maxBufferAhead parameter. Should be a number.");if((0,Z.Z)(e.maxBufferBehind))i=m;else if(i=Number(e.maxBufferBehind),isNaN(i))throw new Error("Invalid maxBufferBehind parameter. Should be a number.");if((0,Z.Z)(e.wantedBufferAhead))n=T;else if(n=Number(e.wantedBufferAhead),isNaN(n))throw new Error("Invalid wantedBufferAhead parameter. Should be a number.");if((0,Z.Z)(e.maxVideoBufferSize))r=y;else if(r=Number(e.maxVideoBufferSize),isNaN(r))throw new Error("Invalid maxVideoBufferSize parameter. Should be a number.");if(v=(0,Z.Z)(e.limitVideoWidth)?f:!!e.limitVideoWidth,T=!(m=(0,Z.Z)(e.throttleWhenHidden)?E:((0,D.Z)("`throttleWhenHidden` API is deprecated. Consider using `throttleVideoBitrateWhenHidden` instead."),!!e.throttleWhenHidden))&&((0,Z.Z)(e.throttleVideoBitrateWhenHidden)?S:!!e.throttleVideoBitrateWhenHidden),y=void 0!==e.preferredTextTracks?Array.isArray(e.preferredTextTracks)?e.preferredTextTracks:((0,D.Z)("Invalid `preferredTextTracks` option, it should be an Array"),[]):[],f=void 0!==e.preferredAudioTracks?Array.isArray(e.preferredAudioTracks)?e.preferredAudioTracks:((0,D.Z)("Invalid `preferredAudioTracks` option, it should be an Array"),[]):[],E=void 0!==e.preferredVideoTracks?Array.isArray(e.preferredVideoTracks)?e.preferredVideoTracks:((0,D.Z)("Invalid `preferredVideoTracks` option, it should be an Array"),[]):[],(0,Z.Z)(e.videoElement))a=document.createElement("video");else{if(!(e.videoElement instanceof HTMLMediaElement))throw new Error("Invalid videoElement parameter. Should be a HTMLMediaElement.");a=e.videoElement}if((0,Z.Z)(e.initialVideoBitrate))s=h.video;else if(s=Number(e.initialVideoBitrate),isNaN(s))throw new Error("Invalid initialVideoBitrate parameter. Should be a number.");if((0,Z.Z)(e.initialAudioBitrate))o=h.audio;else if(o=Number(e.initialAudioBitrate),isNaN(o))throw new Error("Invalid initialAudioBitrate parameter. Should be a number.");if((0,Z.Z)(e.minVideoBitrate))u=p.video;else if(u=Number(e.minVideoBitrate),isNaN(u))throw new Error("Invalid maxVideoBitrate parameter. Should be a number.");if((0,Z.Z)(e.minAudioBitrate))l=p.audio;else if(l=Number(e.minAudioBitrate),isNaN(l))throw new Error("Invalid minAudioBitrate parameter. Should be a number.");if((0,Z.Z)(e.maxVideoBitrate))c=g.video;else{if(c=Number(e.maxVideoBitrate),isNaN(c))throw new Error("Invalid maxVideoBitrate parameter. Should be a number.");if(c=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.length?{done:!0}:{done:!1,value:e[i++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function K(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e[n].mainBarContainerOrder&&(i=e[t],e[t]=e[n],e[n]=i);return e}Mo.getDefaultMainBarTemplate=function(){var e=new yo,t=(e.name=" Test Main Bar Template",new Eo({id:d.PLAY_PAUSE,visible:!0,global:!0,mainBarPosition:c.CENTER,mainBarContainerOrder:2})),t=(e.ids.push(d.PLAY_PAUSE),e.components.push(t),new Eo({id:d.UPWARD,visible:!0,global:!0,mainBarPosition:c.CENTER,mainBarContainerOrder:1})),t=(e.ids.push(d.UPWARD),e.components.push(t),new Eo({id:d.FORWARD,visible:!0,global:!0,mainBarPosition:c.CENTER,mainBarContainerOrder:3})),t=(e.ids.push(d.FORWARD),e.components.push(t),new Eo({id:d.TIMING,visible:!0,global:!1,mainBarPosition:c.LEFT,mainBarContainerOrder:0})),t=(e.ids.push(d.TIMING),e.components.push(t),new Eo({id:d.ONAIR,visible:!0,global:!1,mainBarPosition:c.LEFT,mainBarContainerOrder:0})),t=(e.ids.push(d.ONAIR),e.components.push(t),new Eo({id:d.FULLSCREEN,visible:!0,global:!0,mainBarPosition:c.RIGHT,mainBarContainerOrder:0})),t=(e.ids.push(d.FULLSCREEN),e.components.push(t),new Eo({id:d.OPTION,visible:!0,global:!0,mainBarPosition:c.RIGHT,mainBarContainerOrder:1})),t=(e.ids.push(d.OPTION),e.components.push(t),new Eo({id:d.VOLUME,visible:!0,global:!0,mainBarPosition:c.RIGHT,mainBarContainerOrder:2})),t=(e.ids.push(d.VOLUME),e.components.push(t),new Eo({id:d.NEXT_VIDEO,visible:!0,global:!1,mainBarPosition:c.CENTER,mainBarContainerOrder:4})),t=(e.ids.push(d.NEXT_VIDEO),e.components.push(t),new Eo({id:d.PREV_VIDEO,visible:!0,global:!1,mainBarPosition:c.CENTER,mainBarContainerOrder:0}));return e.ids.push(d.PREV_VIDEO),e.components.push(t),e},Mo.getAlternativeMainBarTemplate=function(){var e=new yo,t=(e.name=" Test Main Bar Template",new Eo({id:d.PLAY_PAUSE,visible:!0,global:!0,mainBarPosition:c.LEFT,mainBarContainerOrder:1})),t=(e.ids.push(d.PLAY_PAUSE),e.components.push(t),new Eo({id:d.UPWARD,visible:!1,global:!1,mainBarPosition:c.CENTER,mainBarContainerOrder:1})),t=(e.ids.push(d.UPWARD),e.components.push(t),new Eo({id:d.FORWARD,visible:!1,global:!1,mainBarPosition:c.CENTER,mainBarContainerOrder:3})),t=(e.ids.push(d.FORWARD),e.components.push(t),new Eo({id:d.TIMING,visible:!0,global:!1,mainBarPosition:c.RIGHT,mainBarContainerOrder:3})),t=(e.ids.push(d.TIMING),e.components.push(t),new Eo({id:d.ONAIR,visible:!0,global:!1,mainBarPosition:c.LEFT,mainBarContainerOrder:4})),t=(e.ids.push(d.ONAIR),e.components.push(t),new Eo({id:d.FULLSCREEN,visible:!0,global:!0,mainBarPosition:c.RIGHT,mainBarContainerOrder:0})),t=(e.ids.push(d.FULLSCREEN),e.components.push(t),new Eo({id:d.OPTION,visible:!0,global:!0,mainBarPosition:c.RIGHT,mainBarContainerOrder:1})),t=(e.ids.push(d.OPTION),e.components.push(t),new Eo({id:d.VOLUME,visible:!0,global:!0,mainBarPosition:c.LEFT,mainBarContainerOrder:3})),t=(e.ids.push(d.VOLUME),e.components.push(t),new Eo({id:d.NEXT_VIDEO,visible:!0,global:!1,mainBarPosition:c.LEFT,mainBarContainerOrder:2})),t=(e.ids.push(d.NEXT_VIDEO),e.components.push(t),new Eo({id:d.PREV_VIDEO,visible:!0,global:!1,mainBarPosition:c.LEFT,mainBarContainerOrder:0}));return e.ids.push(d.PREV_VIDEO),e.components.push(t),e};var wo=Mo;function Mo(){}var Ao,Lo=function(){this.startMute=!0,this.autoPlay=!1,this.loop=!0,this.controls=!0,this.titleOnButton=!0,this.skin=Ja.Default,this.replay=!0,this.dvrEnabled=!1,this.protocol=null,this.adsOptions=new Io,this.playerDisplayMode=Ao.Maintain,this.skinOptions=new Do,this.skinId=null,this.requestHost=null,this.contentInfo=null,this.SecurityTokenQS=null,this.customManifest=null,this.customProtocol=null,this.mainBarTemplate=new yo,this.vastURL=null,this.trimStart=null,this.trimEnd=null,this.trimFrameStart=null,this.trimEndStart=null,this.bufferLength=300,this.maxBufferLength=600},Io=function(){this.adsEnabled=!1,this.playPreRoll=!1,this.playPostRoll=!1,this.adsPosition=[]},Do=function(){this.logoPosition=Qa.TopLeft,this.mainBarColor="linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0.6))",this.seekBarColor="rgba(100, 100, 100, 0.6)",this.seekBarBufferedColor="rgba(150, 150, 150, 0.7)",this.seekBarLoadedColor="rgba(255, 20, 20, 1)",this.buttonsColor="rgba(255, 255, 255, 1.0)",this.buttonsColorHover="rgba(255, 255, 255, 1.0",this.vastUrl=null,this.alternativeContentText="LIVE is Offline",this.backgroundColorAlpha="rgba(255, 255, 255, 1.0)",this.backgroundColorBeta=null};function ko(e,t,i){var n,r;t.autoplay=null!=(n=null!=(n=null==i?void 0:i.autoPlay)?n:null==e?void 0:e.autoPlay)&&n,t.autoplay?t.startMute=!0:t.startMute=null!=(n=null!=(n=null==i?void 0:i.startMute)?n:null==e?void 0:e.startMute)&&n,t.replay=null!=(n=null==i?void 0:i.replay)&&n,t.hasLooped=null!=(n=null!=(n=null==i?void 0:i.loop)?n:null==e?void 0:e.loop)&&n,t.haveControls=null==(n=null!=(n=null==i?void 0:i.controls)?n:null==e?void 0:e.controls)||n,t.titleOnButton=null==(n=null!=(n=null==i?void 0:i.titleOnButton)?n:null==e?void 0:e.titleOnButton)||n,t.options.bufferLength=null!=(e=null==i?void 0:i.bufferLength)?e:300,t.options.maxBufferLength=null!=(n=null==i?void 0:i.maxBufferLength)?n:600,w(T.Info,"Will be used Title on Button: "+t.titleOnButton),t.options.protocol=null!=(e=null==i?void 0:i.protocol)?e:null,null==t.adsOptions&&(t.adsOptions=null!=(n=null==i?void 0:i.adsOptions)?n:new Io),t.options.playerDisplayMode=null!=(e=null==i?void 0:i.playerDisplayMode)?e:Ao.Maintain,t.options.requestHost=null!=(n=null==i?void 0:i.requestHost)?n:"127.0.0.1",t.options.trimStart=null!=(e=null==i?void 0:i.trimStart)?e:null,t.options.trimEnd=null!=(n=null==i?void 0:i.trimEnd)?n:null,t.options.forceKeyFrameOnDiscontinuity=null==(e=null==i?void 0:i.forceKeyFrameOnDiscontinuity)||e,t.options.mainBarTemplate=wo.getDefaultMainBarTemplate(),null==i||null==i.mainBarTemplate&&null==i.mainBarTemplate||((r=new yo).name=i.mainBarTemplate.name,r.ids=r.ids,i.mainBarTemplate.components.forEach(function(e){r.components.push(new Eo({id:e.id,visible:e.visible,global:e.global,mainBarPosition:e.mainBarPosition,mainBarContainerOrder:e.mainBarContainerOrder}))}),i.mainBarTemplate=r)}(i=Ao=Ao||{})[i.Fill=0]="Fill",i[i.Maintain=1]="Maintain",i[i.Fit=2]="Fit";var _o=.5;function xo(e,t){null!=e.videoEngine&&(e.videoEngine.innerHTML=""),null!=e.divPlayer&&(e.divPlayer.innerHTML="");var i,n=Ao.Maintain,r=(null!=t&&null!=t.playerDisplayMode&&(n=t.playerDisplayMode),e.resizePlayer(!0),w(T.Info,"Creating video element..."),document.createElement("video"));switch(r.id="msplayer-video",n){case Ao.Maintain:r.style.width="100%",r.style.height="100%",r.style.margin="auto",r.style.position="relative";break;case Ao.Fill:r.style.width="100%",r.style.height="100%",r.style.margin="0px",r.style.position="relative";break;case Ao.Fit:r.style.width="auto",r.style.height="100%",r.style.margin="auto",r.style.position="relative"}m.iphone()||(r.style.pointerEvents="none"),r.style.display="flex",r.style.margin="0px",r.style.padding="0px",r.controls=!1,e.videoEngine=r,e.divPlayer.appendChild(r),t=e,w(T.Info,"Appending loading element..."),(n=document.createElement("msdiv")).id="msplayer-"+t.playerGUID+"-loading",n.style.position="absolute",n.style.width="100%",n.style.height="100%",n.style.display="flex",n.style.flexDirection="column",n.style.zIndex="12",n.style.justifyItems="center",n.style.alignItems="center",n.style.justifyContent="center",n.style.alignContent="center",n.style.top="0px",n.style.left="0px",n.style.animation=_o+"s",n.style.opacity="1",n.style.background="black",(e=document.createElement("img")).id="msplayer-loading-img",e.src=s.LOADING,e.style.width="4rem",e.style.height="4rem",(i=document.createElement("msp")).style.fontSize="15px",i.innerHTML="Loading Video...",i.style.color="white",n.appendChild(e),t.divPlayer.appendChild(n)}function Co(e){var t=document.getElementById("msplayer-"+e.playerGUID+"-loading");null!=t&&(t.style.opacity="0",null!=(e=e.divPlayer))&&e.removeChild(t)}function Ro(e,t,i){var n,r,a;w(T.Error,i,t),Co(e),e=e,t=t,i=i,(n=document.createElement("msdiv")).id="msplayer-"+e.playerGUID+"-error",n.style.backgroundColor="black",n.style.position="absolute",n.style.width="100%",n.style.height="100%",n.style.display="flex",n.style.flexDirection="column",n.style.zIndex="99",n.style.justifyItems="center",n.style.alignItems="center",n.style.justifyContent="center",n.style.alignContent="center",n.style.top="0px",n.style.left="0px",n.style.animation=_o+"s",n.style.opacity="1",(r=document.createElement("img")).id="msplayer-loading-img",r.src=s.ERROR,r.style.width="4rem",r.style.height="4rem",(a=document.createElement("msp")).style.fontSize="20px",a.innerHTML=t.toString(),a.style.color="white",(t=document.createElement("msp")).style.fontSize="15px",t.innerHTML=i,t.style.color="white",n.appendChild(r),n.appendChild(a),n.appendChild(t),e.divPlayer.appendChild(n)}function Po(e){var t;w(T.Info,"DEVICE: "+m.type+" - "+m.os+" - "+m.orientation),e.deviceType=m.type,e.deviceOS=m.os,e.deviceOrientation=m.orientation,e.deviceApple=No(),t=e,m.onChangeOrientation(function(e){t.deviceOrientation=e,t.globalEventsHandler.triggerEvent("orientationChange",{msg:"New orientation is ".concat(e),orientation:e})})}function No(){return!!m.ios()}function Oo(e){var t;null!=e.rxplayerEngine&&($a.LogLevel="WARNING",e.rxplayerEngine.addEventListener("videoBitrateChange",function(e){w(T.Info,"Bitrate Changed: ".concat(e))}),e.rxplayerEngine.addEventListener("error",function(e){w(T.Error,"The player (RxPlayer) crashed: ".concat(e.message,", error type ").concat(e))}),(t=e).rxplayerEngine.addEventListener("playerStateChange",function(e){switch(e){case"STOPPED":w(T.Info,"No content is/will be playing");break;case"LOADING":w(T.Info,"A new content is currently loading: contentID: "+t.contentInfo.contentID);break;case"LOADED":case"PLAYING":case"PAUSED":case"ENDED":break;case"BUFFERING":w(T.Info,"The content is buffering new data: contentID: "+t.contentInfo.contentID);break;case"SEEKING":w(T.Info,"The content is still seeking, waiting for new data: contentID: "+t.contentInfo.contentID);break;case"RELOADING":w(T.Info,"The content is currently reloading: contentID: "+t.contentInfo.contentID);break;default:w(T.Info,"This is impossible (issue material!).")}}))}function Bo(e){var t,n;null!=e.hlsEngine&&((t=e).hlsEngine.on(p.Events.MEDIA_ATTACHED,function(){w(T.Info,"video and hls.js are now bound together !"),!M.isLiveContent(t.contentInfo.contentType)&&t.contentInfo.contentType!=S.PlaylistLoop||(t.live=!0),t.hlsEngine.on(p.Events.MANIFEST_PARSED,function(e,t){w(T.Info,"manifest loaded, found "+t.levels.length+" quality level")})}),(n=e).hlsEngine.on(p.Events.ERROR,function(e,t){var i;switch(t.details){case p.ErrorDetails.MANIFEST_LOAD_ERROR:w(T.Error,"(hls.js) Manifest loading fail because of a network error !");break;case p.ErrorDetails.MANIFEST_LOAD_TIMEOUT:w(T.Error,"(hls.js) Manifest loading fail because of a timeout !");break;case p.ErrorDetails.MANIFEST_PARSING_ERROR:w(T.Error,"(hls.js) Manifest parsing error !"),M.isLiveContent(n.contentInfo.contentType)&&(null!=(i=n.currentSkin.getOnAir())&&i.setOffline(),n.setPoster(),n.playAlternativeContent());break;case p.ErrorDetails.LEVEL_LOAD_ERROR:w(T.Error,"(hls.js) Level loading fail because of a network error !"),n.live=!1,n.goneOffline=!0,M.isLiveContent(n.contentInfo.contentType)&&(null!=(i=n.currentSkin.getOnAir())&&i.setOffline(),n.setPoster(),n.playAlternativeContent());break;case p.ErrorDetails.LEVEL_LOAD_TIMEOUT:w(T.Error,"(hls.js) Manifest loading fail because of a timeout !");break;case p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:w(T.Error,"(hls.js) Audio track loading fail because of a network error !");break;case p.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:w(T.Error,"(hls.js) Audio track loading fail because of a timeout !");break;case p.ErrorDetails.FRAG_LOAD_ERROR:w(T.Error,"(hls.js) Fragment loading fail because of a network error !"),M.isLiveContent(n.contentInfo.contentType)&&(null!=(i=n.currentSkin.getOnAir())&&i.setOffline(),n.setPoster(),n.playAlternativeContent());break;case p.ErrorDetails.FRAG_PARSING_ERROR:n.hlsEngine.stopLoad();break;case p.ErrorDetails.FRAG_LOAD_TIMEOUT:w(T.Error,"(hls.js) Fragment loading fail because of a timeout !");break;case p.ErrorDetails.KEY_LOAD_ERROR:w(T.Error,"(hls.js) Decrypt key loading fail because of a network error !");break;case p.ErrorDetails.KEY_LOAD_TIMEOUT:w(T.Error,"(hls.js) Decrypt key loading fail because of a timeout !");break;case p.ErrorDetails.BUFFER_STALLED_ERROR:w(T.Error,"(hls.js) Buffer Stalled Error!"),t.fatal&&n.hlsEngine.recoverMediaError(),M.isAudio(n.contentInfo.contentType)&&(w(T.Info,"(hls.js) Recovering from an audio buffer stalled error"),n.hlsEngine.recoverMediaError(),n.autoplay)&&n.play();break;case p.ErrorDetails.BUFFER_NUDGE_ON_STALL:w(T.Error,"(hls.js) Buffer Nudge On Stall Error!");break;case p.ErrorDetails.BUFFER_FULL_ERROR:w(T.Error,"(hls.js) Buffer Full Error!"),M.isAudio(n.contentInfo.contentType)&&(w(T.Info,"(hls.js) Recovering from an audio buffer stalled error"),n.hlsEngine.recoverMediaError(),n.autoplay)&&n.play();break;case p.ErrorDetails.BUFFER_APPEND_ERROR:w(T.Error,"(hls.js) Buffer Append Error!"),n.hlsEngine.recoverMediaError();break;case p.ErrorDetails.BUFFER_APPENDING_ERROR:w(T.Error,"(hls.js) Buffer Appending Error!"),n.hlsEngine.recoverMediaError();break;case p.ErrorDetails.BUFFER_SEEK_OVER_HOLE:w(T.Error,"(hls.js) Buffer Seek Over Hole Error!");break;default:w(T.Error,"Unhandled error \n \n Type: ".concat(t.type," \n \n ErrorDetails: ").concat(t.details," \n\n ErrorFatal: ").concat(t.fatal)),t.fatal&&(w(T.Warning,"Trying to recover from internal exception"),n.hlsEngine.startLoad(),n.hlsEngine.recoverMediaError())}}),(e=e).hlsEngine.on(p.Events.LEVEL_SWITCHING,function(e,t){w(T.Info,"level switching "+t.level)}),e.hlsEngine.on(p.Events.LEVEL_SWITCHED,function(e,t){w(T.Info,"level switched "+t.level)}))}Uo.prototype.initEngineEvents=function(){var i,e;Oo(this.player),Bo(this.player),null!=(i=this.player).videoEngine&&((e=i.videoEngine).addEventListener("canplay",function(e){var t;null==i?w(T.Error,"Listener cannot connect with player!"):(null!=(t=null==(t=i.currentSkin)?void 0:t.getBuffering())&&t.display(!1),i.isVideoStarted=!0,i.globalEventsHandler.triggerEvent("canplay",{containerID:i.divPlayer.id,msg:"The player can play"}))}),e.addEventListener("play",function(e){var t;null==i?w(T.Error,"Listener cannot connect with player!"):(null!=(t=null==(t=i.currentSkin)?void 0:t.getBuffering())&&t.display(!1),i.globalEventsHandler.triggerEvent("play",{containerID:i.divPlayer.id,msg:"The player will play"}))}),e.addEventListener("playing",function(e){var t;null==i?w(T.Error,"Listener cannot connect with player!"):(null!=(t=null==(t=i.currentSkin)?void 0:t.getBuffering())&&t.display(!1),i.globalEventsHandler.triggerEvent("playing",{containerID:i.divPlayer.id,msg:"The player is playing"}))}),e.addEventListener("pause",function(e){var t;null==i?w(T.Error,"Listener cannot connect with player!"):(null!=(t=null==(t=i.currentSkin)?void 0:t.getBuffering())&&t.display(!1),i.globalEventsHandler.triggerEvent(h.MS_PLAYER_PAUSED,{containerID:i.divPlayer.id,msg:"The player is paused"}))}),e.addEventListener("ended",function(e){var t;null==i?w(T.Error,"Listener cannot connect with player!"):(null!=(t=null==(t=i.currentSkin)?void 0:t.getBuffering())&&t.display(!1),i.globalEventsHandler.triggerEvent(h.MS_PLAYER_ENDED,{containerID:i.divPlayer.id,msg:"The player ended playing content"}))}),e.addEventListener("seeked",function(e){var t;null==i?w(T.Error,"Listener cannot connect with player!"):(null!=(t=null==(t=i.currentSkin)?void 0:t.getBuffering())&&t.display(!1),i.globalEventsHandler.triggerEvent(h.MS_PLAYER_SEEK,{containerID:i.divPlayer.id,msg:"The player is seeked"}))}),e.addEventListener("seeking",function(e){var t;null==i?w(T.Error,"Listener cannot connect with player!"):(M.isLiveContent(i.contentInfo.contentType)&&i.firstSeek&&null!=(t=null==(t=i.currentSkin)?void 0:t.getBuffering())&&t.display(!0),i.firstSeek=!0,i.globalEventsHandler.triggerEvent(h.MS_PLAYER_PAUSED,{containerID:i.divPlayer.id,msg:"The player is seeking"}))}))},Uo.prototype.createCustomEvents=function(){this.msPlayerCanPlay=new CustomEvent(h.MS_PLAYER_CANPLAY),this.events.set(h.MS_PLAYER_CANPLAY,this.msPlayerCanPlay),this.msPlayerPlaying=new CustomEvent(h.MS_PLAYER_PLAYING),this.events.set(h.MS_PLAYER_PLAYING,this.msPlayerPlaying),this.msPlayerPaused=new CustomEvent(h.MS_PLAYER_PAUSED),this.events.set(h.MS_PLAYER_PAUSED,this.msPlayerPaused),this.msPlayerEnded=new CustomEvent(h.MS_PLAYER_ENDED),this.events.set(h.MS_PLAYER_ENDED,this.msPlayerEnded),this.msPlayerMuted=new CustomEvent(h.MS_PLAYER_MUTED),this.events.set(h.MS_PLAYER_MUTED,this.msPlayerMuted),this.msPlayerUnmuted=new CustomEvent(h.MS_PLAYER_UNMUTED),this.events.set(h.MS_PLAYER_UNMUTED,this.msPlayerUnmuted),this.msPlayerAdStart=new CustomEvent(h.MS_PLAYER_AD_END),this.events.set(h.MS_PLAYER_AD_START,this.msPlayerAdStart),this.msPlayerAdEnd=new CustomEvent(h.MS_PLAYER_AD_END),this.events.set(h.MS_PLAYER_AD_END,this.msPlayerAdEnd)},Uo.prototype.triggerEvent=function(e,t){e=new CustomEvent(e,{detail:t});this.player.divPlayer.dispatchEvent(e)},Uo.prototype.trigger=function(e,t){null==this.player?w(T.Error,"Cannot call trigger on an empty player instance!!"):this.events.has(e)?(t=new CustomEvent(h.MS_PLAYER_AD_END,t),this.events.set(e,t),this.player.divPlayer.dispatchEvent(this.events.get(e))):w(T.Error,"No key event found to trigger!")},Uo.prototype.removeEventsHandlerAll=function(){this.player.divPlayer.removeEventListener(h.MS_PLAYER_AD_END,function(){}),this.player.divPlayer.removeEventListener(h.MS_PLAYER_AD_START,function(){}),this.player.divPlayer.removeEventListener(h.MS_PLAYER_CANPLAY,function(){}),this.player.divPlayer.removeEventListener(h.MS_PLAYER_ENDED,function(){}),this.player.divPlayer.removeEventListener(h.MS_PLAYER_MUTED,function(){}),this.player.divPlayer.removeEventListener(h.MS_PLAYER_PAUSED,function(){}),this.player.divPlayer.removeEventListener(h.MS_PLAYER_PLAYING,function(){}),this.player.divPlayer.removeEventListener(h.MS_PLAYER_UNMUTED,function(){}),this.player.divPlayer.removeEventListener(h.MS_PLAYER_AD_START,function(){}),this.player.divPlayer.removeEventListener(h.MS_PLAYER_AD_END,function(){})},Uo.defaultListenersGenerated=!1;var Fo=Uo;function Uo(e){this.events=new Map,this.player=e,this.initEngineEvents(),this.createCustomEvents()}zo.MS_PLAYER_CANPLAY="canplay",zo.MS_PLAYER_PLAYING="play",zo.MS_PLAYER_PAUSED="pause",zo.MS_PLAYER_ENDED="end",zo.MS_PLAYER_MUTED="mute",zo.MS_PLAYER_UNMUTED="unmute",zo.MS_PLAYER_AD_START="ad_start",zo.MS_PLAYER_AD_END="ad_end",zo.MS_PLAYER_SEEK="seek";var h=zo;function zo(){}jo.generateContentAPICall=function(e,t,i){var n;return void 0===t&&(t=null),null==(i=void 0===i?null:i)?(w(T.Error,"Request host not specified!!"),null):(n=window.location.search.slice(1).split("&").filter(function(e){return e.startsWith("token=")}).map(function(e){return e.slice(e.indexOf("=")+1)}),null==t?(w(T.Info,"API Call: "+window.location.protocol+"//"+i+"/api/v2/content/"+e+"/"),window.location.protocol+"//"+i+"/api/v2/content/"+e+(n&&0=e.videoEngine.duration-l.MAX_BUFFER_FOR_LIVE}:function(e){return e.rxplayerEngine.getPosition()>=(null!=(e=e.rxplayerEngine.getMaximumPosition())?e:0-l.MAX_BUFFER_FOR_LIVE)})(e)}(t),!1):null!=Jo&&Jo.setOffline(!1)))),i.init&&i.isVideoStarted&&(m.iphone()||(e=i,null!=Wo&&(null!=(t=e.castManager)&&t.castSessionCreated||M.isAudio(e.contentInfo.contentType)?Wo.displayPoster():M.isLiveVideo(e.contentInfo.contentType)?!e.live||e.videoEngine.paused?Wo.displayPoster():Wo.hidePoster():e.videoEngine.paused&&0==e.videoEngine.currentTime?Wo.displayPoster():Wo.hidePoster())),function(r){g(this,void 0,void 0,function(){var t,i,n;return v(this,function(e){return M.isLiveContent(r.contentInfo.contentType)||(r.isVideoEnded=el(r),el(r)&&tl(S.PlaylistOneShot,r)&&(t=r.contentInfo.playlist.currentIndex,i=r.contentInfo.playlistContents.length,n=r.replay,t=e.videoEngine.duration||!!(t&&isNaN(e.videoEngine.duration)&&e.init)}function tl(e,t){return t.contentInfo.contentType==e}function il(){rl=null}function nl(){var n,e=window;return e.google&&e.google.ima?Promise.resolve(e.google.ima):(rl||(n="https://imasdk.googleapis.com/js/sdkloader/ima3.js",(rl=new Promise(function(e,t){var i=document.createElement("script");i.async=!0,i.src=n,i.onload=e,i.onerror=t,document.body.appendChild(i)}).then(function(){return e.google.ima})).then(il).catch(il)),rl)}var rl=null,al=(sl.prototype.loadIMA=function(){return g(this,void 0,void 0,function(){var t;return v(this,function(e){switch(e.label){case 0:return this.adsScriptLoaded?[3,2]:(w(T.Info,"[ADS] Loading IMA SDK"),w(T.Info,"Will be used VAST URL: "+this.player.options.skinOptions.vastUrl),t=this,[4,nl()]);case 1:t.ima=e.sent(),this.adsScriptLoaded=!0,e.label=2;case 2:return this.videoContent=this.player.videoEngine,this.adsContainer=this.player.currentSkin.getADSContainerHTMLElement(),this.setupIMA(),[2]}})})},sl.prototype.setupIMA=function(){var t=this,e=(w(T.Info,"[ADS] Creating ads display container"),this.createAdDisplayContainer(),w(T.Info,"[ADS] Creating ads loader"),this.adsLoader=new this.ima.AdsLoader(this.adDisplayContainer),w(T.Info,"[ADS] Creating event listeners"),this.adsLoader.addEventListener(this.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,function(e){return t.onAdsManagerLoaded(e)},!1),this.adsLoader.addEventListener(this.ima.AdErrorEvent.Type.AD_ERROR,function(e){return t.onAdError(e)},!1),this.videoContent.addEventListener("ended",function(e){w(T.Info,"Content Complete"),t.adsLoader.contentComplete()}),w(T.Info,"[ADS] Requesting video ads"),new this.ima.AdsRequest);this.player.options.skinOptions.vastUrl="//"+this.player.options.skinOptions.vastUrl.replace("https:","").replace("http:","").replace("//",""),e.adTagUrl=this.player.options.skinOptions.vastUrl,this.adsLoader.requestAds(e)},sl.prototype.createAdDisplayContainer=function(){return g(this,void 0,void 0,function(){return v(this,function(e){return w(T.Info,"[ADS] Creating ad display container"),this.adDisplayContainer=new this.ima.AdDisplayContainer(this.adsContainer,this.videoContent),[2]})})},sl.prototype.resize=function(){var e=this.player.divPlayer.getBoundingClientRect().width,t=this.player.divPlayer.getBoundingClientRect().height;null==this.adsManager&&null==this.adsManager||this.adsManager.resize(e,t,this.ima.ViewMode.NORMAL)},sl.prototype.playADS=function(){w(T.Info,"[ADS] Ads will be played"),this.started=!0,this.adDisplayContainer.initialize(),w(T.Info,"[ADS] Ad resolution ".concat(this.videoContent.getBoundingClientRect().width,"x").concat(this.videoContent.getBoundingClientRect().height,'"'));try{this.adsManager.init(this.videoContent.getBoundingClientRect().width,this.videoContent.getBoundingClientRect().height,this.ima.ViewMode.NORMAL),w(T.Info,"[ADS] Ads will start now"),document.dispatchEvent(new CustomEvent(h.MS_PLAYER_AD_START)),this.adsManager.start()}catch(e){w(T.Error,"[ADS] There is a problem with VAST response"),this.videoContent.play()}},sl.prototype.onAdsManagerLoaded=function(e){var t=this,i=(w(T.Info,"[ADS] Ads Manager Loaded"),new this.ima.AdsRenderingSettings);i.restoreCustomPlaybackStateOnAdBreakComplete=!0,this.adsManager=e.getAdsManager(this.videoContent,i),this.adsManager.addEventListener(this.ima.AdEvent.Type.LOADED,function(e){return t.onAdEvent(e)}),this.adsManager.addEventListener(this.ima.AdEvent.Type.STARTED,function(e){return t.onAdEvent(e)}),this.adsManager.addEventListener(this.ima.AdEvent.Type.COMPLETE,function(e){return t.onAdEvent(e)}),this.adsManager.addEventListener(this.ima.AdErrorEvent.Type.AD_ERROR,function(e){return t.onAdError(e)}),this.adsManager.addEventListener(this.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,function(){return t.onContentPauseRequested()}),this.adsManager.addEventListener(this.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,function(){return t.onContentResumeRequested()}),this.adsManager.addEventListener(this.ima.AdEvent.Type.ALL_ADS_COMPLETED,function(e){return t.onAdEvent(e)}),this.adsManager.addEventListener(this.ima.AdEvent.Type.PAUSED,function(){return t.adsManager.resume()}),this.player.autoplay?this.playADS():this.videoContent.addEventListener("play",function(e){t.started||t.playADS()})},sl.prototype.onAdEvent=function(e){var t,i=e.getAd();switch(e.type){case this.ima.AdEvent.Type.LOADED:w(T.Info,"[ADS] Ad Loaded!"),i.isLinear()||this.videoContent.play();break;case this.ima.AdEvent.Type.STARTED:w(T.Info,"[ADS] Ad Started!"),null!=(t=this.player.globalEventsHandler)&&t.triggerEvent("adStart",{msg:"Ad Started"});break;case this.ima.AdEvent.Type.COMPLETE:w(T.Info,"[ADS] Ad Completed!"),null!=(t=this.player.globalEventsHandler)&&t.triggerEvent("adCompleted",{msg:"Ad Started"}),i.isLinear()&&clearInterval(this.intervalTimer);break;case this.ima.AdEvent.Type.ALL_ADS_COMPLETED:w(T.Info,"[ADS] All Ads Completed!"),null!=(t=this.player.globalEventsHandler)&&t.triggerEvent("allAdsCompleted",{msg:"Ad Started"})}},sl.prototype.onAdError=function(e){console.error("[ADS] Ad Error"),w(T.Error,e.getError()),null!=this.adsManager&&null!=this.adsManager&&this.adsManager.destroy()},sl.prototype.onContentPauseRequested=function(){w(T.Info,"[ADS] Content Pause Requested"),this.player.pause(),this.adsContainer.style.visibility="visible",this.adsContainer.style.opacity="1.0",this.adsManager.setVolume(this.videoContent.volume),w(T.Info,"[ADS] Will be played at volume "+this.adsManager.getVolume())},sl.prototype.onContentResumeRequested=function(){w(T.Info,"[ADS] Content Resume Requested"),this.player.play(),this.adsContainer.style.visibility="hidden",this.adsContainer.style.opacity="0.0"},sl);function sl(e){this.adsScriptLoaded=!1,this.adsContainer=null,this.postRollDisplayed=!1,this.started=!1,w(T.Info,"[ADS] Ad Manager Loaded"),this.player=e}ll.prototype.addCastSenderScript=function(){w(T.Info,"[CAST] Adding cast sender script");var e=document.createElement("script");e.setAttribute("src","//www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"),document.body.appendChild(e),ll.CAST_SENDER_SCRIPT_LOADED=!0},ll.prototype.createCastListener=function(e){var t=this;w(T.Info,"Creating cast listener"),this.player=e,window.__onGCastApiAvailable=function(e){e&&t.initializeCastApi()}},ll.prototype.initializeCastApi=function(){w(T.Info,"[CAST] Init cast API using ID: "+chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID),cast.framework.CastContext.getInstance().setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),this.remotePlayer=new cast.framework.RemotePlayer,this.remotePlayerController=new cast.framework.RemotePlayerController(this.remotePlayer),this.startCastSession()},ll.prototype.startCastSession=function(){var i=this;this.castSessionPolling=setInterval(function(){var e,t;i.castSessionCreated||(i.castSession=cast.framework.CastContext.getInstance().getCurrentSession(),e=new chrome.cast.media.MediaInfo(i.contentURL,i.contentMIME),t=new chrome.cast.media.LoadRequest(e),null==i.castSession&&null==i.castSession)||i.castSessionIsLoading||(i.castSessionIsLoading=!0,i.castSession.loadMedia(t).then(function(){w(T.Info,"[CAST] Cast session created -> "+i.castSession),w(T.Info,"[CAST] UrlContent: "+i.contentURL),i.player.setPoster(),i.castSessionCreated=!0,i.castSessionIsLoading=!1,i.player.isPaused()&&i.pause(),i.remotePlayer.currentTime=i.player.getCurrentTime(),i.remotePlayerController.seek(),i.remotePlayer.volumeLevel=i.player.getVolume(),i.remotePlayerController.setVolumeLevel(),i.updateDisplay(t)},function(e){w(T.Error,"Error code: "+e),i.castSessionIsLoading=!1}))},2500)},ll.prototype.updateDisplay=function(e){this.remotePlayer.title=this.player.contentInfo.title},ll.prototype.endCastSession=function(){this.castSession.endSession(!0),this.castSession=null,this.castSessionCreated=!1},ll.prototype.play=function(){this.castSessionCreated&&this.remotePlayer.isPaused&&this.remotePlayerController.playOrPause()},ll.prototype.pause=function(){!this.castSessionCreated||this.remotePlayer.isPaused||this.remotePlayerController.playOrPause()},ll.prototype.playPause=function(){this.castSessionCreated&&this.remotePlayerController.playOrPause()},ll.prototype.seek=function(e){this.castSessionCreated&&(this.remotePlayer.currentTime=e,this.remotePlayerController.seek())},ll.prototype.setVolume=function(e){this.castSessionCreated&&(this.remotePlayer.volumeLevel=e,this.remotePlayerController.setVolumeLevel())},ll.CAST_SENDER_SCRIPT_LOADED=!1;var ol=ll;function ll(e,t,i){this.castSessionCreated=!1,this.castSessionIsLoading=!1,ll.CAST_SENDER_SCRIPT_LOADED||this.addCastSenderScript(),this.createCastListener(e),this.contentURL=t,this.contentMIME=i}cl.prototype.createURL=function(e,t){null==e&&(e="webtools.msvdn.net"),null==t&&(t="giUyxaafR2Hb");e=window.location.protocol+"//webtools-"+e+"/image/"+t+"/poster";return e=ss.FAKE_POSTER_CALL?window.location.protocol+"//webtools-2325720d4f664ed6993afb410e1ab1ee.msvdn.net/image/giUyxaafR2Hb/poster":e},cl.createURL=function(e,t){null==e&&(e="webtools.msvdn.net"),null==t&&(t="giUyxaafR2Hb");e=window.location.protocol+"//webtools-"+e+"/image/"+t+"/poster";return e=ss.FAKE_POSTER_CALL?window.location.protocol+"//webtools-2325720d4f664ed6993afb410e1ab1ee.msvdn.net/image/giUyxaafR2Hb/poster":e},cl.prototype.createElement=function(){return this.posterDiv=document.createElement("msdiv"),this.posterDiv.classList.add("player-poster"),this.posterDiv.setAttribute("msp-id",this.player.playerGUID),this.posterDiv.style.backgroundPosition="50% 50%",this.posterDiv.style.backgroundSize="contain",this.posterDiv.style.backgroundRepeat="no-repeat",this.posterDiv.style.backgroundColor="black",this.posterDiv.style.position="absolute",this.posterDiv.style.left="0px",this.posterDiv.style.top="0px",this.posterDiv.style.width="100%",this.posterDiv.style.height="100%",this.posterDiv.style.visibility="hidden",this.posterDiv.style.opacity="0",this.posterDiv.style.zIndex="3",this.posterDiv.style.transition=l.FADE_TRANSITION_DURATION+"s",this.fetchPoster(),this.posterDiv},cl.prototype.displayPoster=function(){null!=this.posterDiv&&null!=this.posterDiv&&(this.posterDiv.style.opacity="1",this.posterDiv.style.visibility="visible")},cl.prototype.hidePoster=function(){null==this.posterDiv||null==this.posterDiv||this.player.castManager.castSessionCreated||(this.posterDiv.style.opacity="0",this.posterDiv.style.visibility="hidden")},cl.prototype.fetchPoster=function(){var t=this;fetch(this.posterURL).then(function(e){return 200==e.status?e:(t.posterDiv.style.display="none",t.posterDiv.style.visibility="hidden",t.posterDiv.style.opacity="0",null)}).then(function(e){return null==e?null:e.blob()}).then(function(n){return new Promise(function(e,t){if(null==n)return null;var i=new FileReader;i.onloadend=function(){return e(i.result)},i.onerror=t,i.readAsDataURL(n)})}).then(function(e){null!=e?(t.exists=!0,t.posterDiv.style.backgroundImage="url(".concat(e,")")):t.exists=!1})},cl.prototype.smallSize=function(){},cl.prototype.mediumSize=function(){},cl.prototype.bigSize=function(){},cl.prototype.changePosterImage=function(e){this.posterDiv.style.backgroundImage="url(".concat(e,")")};var ul,dl=cl;function cl(e,t,i){void 0===t&&(t=null),void 0===i&&(i=null),this.exists=!1,null!=t&&(this.hostname=t),null!=i&&(this.contentID=i),this.posterURL=this.createURL(this.hostname,this.contentID),this.player=e}(e=ul=ul||{})[e.Undefined=0]="Undefined",e[e.RtmpPush=1]="RtmpPush",e[e.RtspPull=2]="RtspPull",e[e.RtspPush=3]="RtspPush",e[e.UDP=4]="UDP",e[e.Icecast=5]="Icecast",e[e.RtmpPull=6]="RtmpPull",e[e.HttpPush=7]="HttpPush",e[e.HttpPull=8]="HttpPull",e[e.Srt=9]="Srt",e[e.MPEGTSoverTCP=10]="MPEGTSoverTCP",e[e.MPEGTSoverUDP=11]="MPEGTSoverUDP";fl.isNewLive=function(e){return e==ul.Srt||e==ul.MPEGTSoverUDP||e==ul.MPEGTSoverTCP};var hl=fl;function fl(){}gl.GetLiveUrlFileNameFromProtocol=function(e){switch(e){case o.HLS:return this.hlsPlaylist;case o.DASH:return this.dashManifest;default:return null}},gl.hlsPlaylist="playlist.m3u8",gl.dashManifest="manifest.mpd";var pl=gl;function gl(){}ml.generateHlsSourceFromContentID=function(e,t,i){return null!=(i=void 0===i?null:i)?"https://"+e.hostname+"/vod/"+t+"/playlist.m3u8?T="+e.T+"&"+i:"https://"+e.hostname+"/vod/"+t+"/playlist.m3u8?T="+e.T},ml.generateDashSourceFromContentID=function(e,t,i){return null!=(i=void 0===i?null:i)?"https://"+e.hostname+"/vod/"+t+"/manifest.mpd?T="+e.T+"&"+i:"https://"+e.hostname+"/vod/"+t+"/manifest.mpd?T="+e.T},ml.generateHlsSourceFromContent=function(e,t){return null!=(t=void 0===t?null:t)?"https://"+e.hostname+"/vod/"+e.contentID+"/playlist.m3u8?T="+e.T+"&"+t:"https://"+e.hostname+"/vod/"+e.contentID+"/playlist.m3u8?T="+e.T},ml.generateDashSourceFromContent=function(e,t){return null!=(t=void 0===t?null:t)?"https://"+e.hostname+"/vod/"+e.contentID+"/manifest.mpd?T="+e.T+"&"+t:"https://"+e.hostname+"/vod/"+e.contentID+"/manifest.mpd?T="+e.T},ml.generateProgressiveSourceFromContent=function(e,t){return null!=(t=void 0===t?null:t)?"https://"+e.hostname+"/vod/"+e.contentID+"/original.mp4?T="+e.T+"&"+t:"https://"+e.hostname+"/vod/"+e.contentID+"/original.mp4T="+e.T},ml.generateProgressiveAudioSourceFromContent=function(e,t){return null!=(t=void 0===t?null:t)?"https://"+e.hostname+"/vod/"+e.contentID+"/original.mp3?"+t:"https://"+e.hostname+"/vod/"+e.contentID+"/original.mp3"},ml.generateHlsSourceURLfromIndex=function(e,t,i){t=e.playlistContents[t].contentID;return null!=(i=void 0===i?null:i)?"https://"+e.hostname+"/vod/"+t+"/playlist.m3u8?T="+e.T+"&"+i:"https://"+e.hostname+"/vod/"+t+"/playlist.m3u8?T="+e.T},ml.generateDashSourceURLfromIndex=function(e,t,i){t=e.playlistContents[t].contentID;return null!=(i=void 0===i?null:i)?"https://"+e.hostname+"/vod/"+t+"/manifest.mpd?T="+e.T+"&"+i:"https://"+e.hostname+"/vod/"+t+"/manifest.mpd?T="+e.T},ml.generateProgressiveURLfromIndex=function(e,t,i){t=e.playlistContents[t].contentID;return null!=(i=void 0===i?null:i)?"https://"+e.hostname+"/vod/"+t+"/original.mp4?T="+e.T+"&"+i:"https://"+e.hostname+"/vod/"+t+"/original.mp4?T="+e.T},ml.generateLiveHlsSourceFromContent=function(e,t,i){return this.generateLiveSourceFromContent(e,o.HLS,!1,i,t=void 0===t?null:t)},ml.generateLiveDashSourceFromContent=function(e,t,i){return this.generateLiveSourceFromContent(e,o.DASH,!1,i,t=void 0===t?null:t)},ml.generateLiveHlsDVRSourceFromContent=function(e,t,i){return this.generateLiveSourceFromContent(e,o.HLS,!0,i,t=void 0===t?null:t)},ml.generateLiveDashDVRSourceFromContent=function(e,t,i){return this.generateLiveSourceFromContent(e,o.DASH,!0,i,t=void 0===t?null:t)},ml.generateLiveSourceFromContent=function(e,t,i,n,r){n=(n&&hl.isNewLive(n)?"/live/":"/live/".concat(e.liveSourceID,"/")).concat(e.contentID),t=pl.GetLiveUrlFileNameFromProtocol(t);if(null===t)throw new Error("Output type not supported");n+="/".concat(t);var t=new URL(n,"https://".concat(e.hostname)),a="",n=[];return i&&n.push("DVR"),null!=r&&n.push(r),n.forEach(function(e,t){a+=(0==t?"?":"&").concat(e)}),t.search=a,t.toString()},ml.generateTrimmedHlsSourceFromContent=function(e,t,i){return void 0===t&&(t=null),null==(i=void 0===i?null:i)&&null==t?(w(T.Error,"Can't request a trimmed source without trim params!"),null):null==i?"https://"+e.hostname+"/vod/"+e.contentID+"/".concat(t,"/").concat(e.duration,"/")+"playlist.m3u8?T="+e.T:null==t?"https://"+e.hostname+"/vod/"+e.contentID+"/0/".concat(i,"/")+"playlist.m3u8?T="+e.T:"https://"+e.hostname+"/vod/"+e.contentID+"/".concat(t,"/").concat(i,"/")+"playlist.m3u8?T="+e.T};var vl=ml;function ml(){}bl.generateConfigFromContent=function(e){var t=new es;return t.title=e.title,t.contentType=e.contentType,t.host=e.hostname,t.title=e.title,t.contentID=e.contentID,t.drmEnabled=!1,null!=e.playlist&&(t.playlistContents=e.playlistContents,t.playlistInfo=e.playlist),t.playerSettings=e.settings,t},bl.generateContentByConfig=function(e){var r,a=e.testConfig,s=e.status,t=e.delivery,o=void 0===t||t,t=e.playlistIndex,l=void 0===t?null:t,t=e.originalContentID,u=void 0===t?null:t,t=e.player,d=void 0===t?null:t,t=e.playerOptions,c=void 0===t?null:t;return g(this,void 0,void 0,function(){var t,i,n;return v(this,function(e){switch(e.label){case 0:switch((t=new ts).contentID=a.contentID,t.hostname=a.host,t.contentType=a.contentType,t.duration=Es.calcSeconds(a.duration),t.onDemandEncodingStatus=s,t.title=a.title,t.deliveryStatus=o,t.thumbnailCount=null!=(r=null==a?void 0:a.thumbnailCount)?r:30,t.defaultSkin=Ja.Default,t.settings=a.playerSettings,t.alternativeContentInfo=new is,d.options.skinOptions=new Do,w(T.Info,"Will be loaded skin: "+a.contentSkinAdvanced.name),null!=a.contentSkinAdvanced.logo&&null!=a.contentSkinAdvanced.logo?(t.logo=a.contentSkinAdvanced.logo,d.options.skinOptions.logoPosition=a.contentSkinAdvanced.logoPosition):d.options.skinOptions.logoPosition=Qa.NoLogo,d.options.skinOptions.mainBarColor=bl.generateMainBarColor(a.contentSkinAdvanced),d.options.skinOptions.seekBarColor=a.contentSkinAdvanced.colorBarEmptyAlpha,d.options.skinOptions.seekBarBufferedColor=a.contentSkinAdvanced.colorBarBufferAlpha,d.options.skinOptions.seekBarLoadedColor=a.contentSkinAdvanced.colorBarForwardingAlpha,d.options.skinOptions.buttonsColor=a.contentSkinAdvanced.buttonColorAlpha,d.options.skinOptions.buttonsColorHover=a.contentSkinAdvanced.buttonHoverColorAlpha,d.options.skinOptions.vastUrl=null!=(r=c.vastURL)?r:a.contentSkinAdvanced.vastUrl,d.options.skinOptions.backgroundColorAlpha=a.contentSkinAdvanced.backgroundColorAlpha,d.options.skinOptions.backgroundColorBeta=a.contentSkinAdvanced.backgroundColorBeta,t.T=null!=(r=a.t)?r:null,t.alternativeContentInfo=new is,null!=u&&(t.alternativeContentInfo.originalContentID=u,t.alternativeContentInfo.alternativeContentPlaying=!0),a.playerSettings.dvrEnabled&&(w(T.Info,"Content is Live DVR, swithing to proper configuration"),a.contentType=t.contentType=S.LiveEventVideoDVR),t.startDate=a.startDate,i=new rs,a.contentType){case S.OnDemandAudio:return[3,1];case S.OnDemandVideo:return[3,2];case S.LiveEventAudio:case S.LiveEventVideo:return[3,3];case S.LiveEventVideoDVR:return[3,4];case S.PlaylistLoop:return[3,5];case S.PlaylistOneShot:return[3,6]}return[3,8];case 1:return i.hls=vl.generateHlsSourceFromContent(t,null==c?void 0:c.SecurityTokenQS),i.dash=vl.generateDashSourceFromContent(t,null==c?void 0:c.SecurityTokenQS),[3,8];case 2:return i.hls=vl.generateHlsSourceFromContent(t,null==c?void 0:c.SecurityTokenQS),i.dash=vl.generateDashSourceFromContent(t,null==c?void 0:c.SecurityTokenQS),i.progressive=vl.generateProgressiveSourceFromContent(t,null==c?void 0:c.SecurityTokenQS),[3,8];case 3:return t.alternativeContentInfo.alternativeContentID=a.alternativeContentID,t.alternativeContentInfo.originalContentID=a.contentID,t.alternativeContentInfo.alternativeContentPlaying=!1,t.liveSourceID=a.liveSourceID,i.hls=vl.generateLiveHlsSourceFromContent(t,null==c?void 0:c.SecurityTokenQS,null==a?void 0:a.liveSourceType),i.dash=vl.generateLiveDashSourceFromContent(t,null==c?void 0:c.SecurityTokenQS,null==a?void 0:a.liveSourceType),[3,8];case 4:return t.alternativeContentInfo.alternativeContentID=a.alternativeContentID,t.alternativeContentInfo.originalContentID=a.contentID,t.alternativeContentInfo.alternativeContentPlaying=!1,t.liveSourceID=a.liveSourceID,i.hls=vl.generateLiveHlsDVRSourceFromContent(t,null==c?void 0:c.SecurityTokenQS,null==a?void 0:a.liveSourceType),[3,8];case 5:return d.populatePlaylistInfo(a,t,l),[3,8];case 6:return d.populatePlaylistInfo(a,t,l),n=t.playlist.currentIndex,i.hls=vl.generateHlsSourceURLfromIndex(t,n,null==c?void 0:c.SecurityTokenQS),i.dash=vl.generateDashSourceURLfromIndex(t,n,null==c?void 0:c.SecurityTokenQS),i.progressive=vl.generateProgressiveURLfromIndex(t,n,null==c?void 0:c.SecurityTokenQS),[4,this.getContentInfoFromContent(t,t.playlistContents[n].contentID,null==c?void 0:c.requestHost)];case 7:return t=e.sent(),[3,8];case 8:return t.sources=i,[2,t]}})})},bl.getContentInfoFromContent=function(r,i,a){return g(this,void 0,void 0,function(){var t,n=this;return v(this,function(e){switch(e.label){case 0:return w(T.Info,"Generating call to fetch content info from indexed contentID (POS)"),t=Zo.generateContentAPICall(i,null,a),[4,fetch(t).then(function(i){return g(n,void 0,void 0,function(){var t;return v(this,function(e){switch(e.label){case 0:return[4,i.json()];case 1:return t=e.sent(),r.title=t.playerContentInfo.title,[2]}})})}).catch(function(e){w(T.Error,e)})];case 1:return e.sent(),[2,r]}})})},bl.calculatePlaylistLoopStartingPoint=function(i,a,s){return g(this,void 0,void 0,function(){var t,n,r=this;return v(this,function(e){switch(e.label){case 0:return t=Zo.generatePlaylistLoopAPICall(a,s),n=null,[4,fetch(t).then(function(i){return g(r,void 0,void 0,function(){var t;return v(this,function(e){switch(e.label){case 0:return[4,i.json()];case 1:if(200!=(t=e.sent()).responseCode)throw new Error(t.responseMessage);return n=new Sl(t.playlistLoopModel.videoToLoad,t.playlistLoopModel.seekTime),[2]}})})}).catch(function(e){w(T.Error,e),Ro(i,Xa.PlaylistLoopError,e)})];case 1:return e.sent(),[2,n]}})})},bl.generateContentByAPI=function(t,r,a,s,o){return g(this,void 0,void 0,function(){var i,n=this;return v(this,function(e){switch(e.label){case 0:return[4,fetch(r).then(function(t){return g(n,void 0,void 0,function(){return v(this,function(e){switch(e.label){case 0:return[4,t.json()];case 1:return i=e.sent(),[2]}})})}).catch(function(e){return w(T.Error,"Coulnd't fetch data from URL: "+r),Ro(t,404,"Coulnd't fetch data from URL"),null})];case 1:return e.sent(),null!=i?200!=i.responseCode?(Ro(t,i.responseCode,i.responseMessage),[2,null]):[2,bl.generateContentByConfig({testConfig:i.playerContentInfo,status:Ka.Ready,delivery:!0,playlistIndex:a,originalContentID:s,player:t,playerOptions:o})]:[2,null]}})})},bl.getPlaylistDuration=function(o){return g(this,void 0,void 0,function(){var n,r,t,i,a,s=this;return v(this,function(e){switch(e.label){case 0:n=[],t=r=0,i=o.contentInfo.playlistContents,e.label=1;case 1:return t=i?(t=e.buffered.end(r),this.seekLoadedBar.style.width="100%",this.seekBufferedBar.style.width="100%"):(t=e.buffered.end(r),this.seekLoadedBar.style.width=n/i*100+"%",this.seekBufferedBar.style.width=t/i*100+"%")}},Al.prototype.smallSize=function(){this.seekBarWrapper.style.height="20px",this.seekBarWrapper.style.bottom="22px",this.seekBar.style.height="5px",this.seekLoadedPointer.style.height="10px",this.seekLoadedPointer.style.width="10px",this.seekLoadedPointer.style.right="-4px",this.seekLoadedPointer.style.bottom="-2px",this.adsIndicators.forEach(function(e){e.smallSize()})},Al.prototype.mediumSize=function(){this.seekBarWrapper.style.height="25px",this.seekBarWrapper.style.bottom="40px",this.seekBar.style.height="7px",this.seekLoadedPointer.style.height="15px",this.seekLoadedPointer.style.width="15px",this.seekLoadedPointer.style.right="-6px",this.seekLoadedPointer.style.bottom="-4px",this.adsIndicators.forEach(function(e){e.mediumSize()})},Al.prototype.bigSize=function(){this.seekBarWrapper.style.height="30px",this.seekBarWrapper.style.bottom="60px",this.seekLoadedPointer.style.height="18px",this.seekLoadedPointer.style.width="18px",this.seekLoadedPointer.style.right="-6px",this.seekLoadedPointer.style.bottom="-4px",this.seekBar.style.height="10px",this.adsIndicators.forEach(function(e){e.bigSize()})},Al.prototype.getADSIndicators=function(){return this.adsIndicators},Al.prototype.getSeekPointerPosition=function(){var e=(e=this.seekLoadedBar.style.width).replace("%","");return Number(e)},Al.prototype.removeADSIndicator=function(e){for(var t=0;t ([0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3})/,this.thumbnailRegexp=/^([^\n#]*)#xywh=([0-9]{1,}),([0-9]{1,}),([0-9]{1,}),([0-9]{1,})$/,this.thumbstripData=[],this.thumbstripImages=new Map,this.loaded=!1,this.hostname=t,this.contentID=i,w(T.Info,"[VTT Parser] Parsing VTT Thumbstrip"),e=e.replace("data:text/vtt;base64,","");e=atob(e);if(!e.includes("WEBVTT"))throw new Error("Parsed data is not WEB VTT!");this.parseVTT(e),this.preloadImages(t,i)}kl.prototype.getThumbstripTime=function(){return[Es.calcSeconds(this.seekTimestamp[0]),Es.calcSeconds(this.seekTimestamp[1])]};var Dl=kl;function kl(e,t,i,n){this.seekTimestamp=e,this.thumbToLoad=t,this.position=[parseInt(i[0]),parseInt(i[1])],this.dimension=[parseInt(n[0]),parseInt(n[1])]}xl.prototype.getThumbstrip=function(e,t){var i=this;e&&t&&(e=window.location.protocol+"//webtools-"+e+"/image/"+t+"/thumbstrip/vtt",ss.LOCAL_THUMBSTIRP_RESOLUTION&&(e="http://localhost/image/"+t+"/thumbstrip/vtt"),fetch(e).then(function(e){var t;return 200==e.status?(i.isVTT=!(null==(t=e.headers.get("Content-Type"))||!t.includes("text/vtt")),e):null}).then(function(e){return null==e?null:e.blob()}).then(function(n){return new Promise(function(e,t){if(null==n)return null;var i=new FileReader;i.onloadend=function(){return e(i.result)},i.onerror=t,i.readAsDataURL(n)})}).then(function(e){i.isVTT&&(i.vttParser=new Ll(e,i.player.contentInfo.hostname,i.player.contentInfo.contentID))}))},xl.prototype.createElement=function(){return this.thumbstripDiv=document.createElement("msdiv"),this.thumbstripDiv.classList.add("player-thumbstrip"),this.thumbstripDiv.setAttribute("msp-id",this.player.playerGUID),this.thumbstripDiv.style.position="absolute",this.thumbstripDiv.style.zIndex="3",this.thumbstripDiv.style.backgroundColor="rgba(0, 0, 0, 0.3)",this.thumbstripDiv.style.borderRadius="5px",this.thumbstripDiv.style.overflow="hidden",this.thumbstripDiv.style.justifyContent="center",this.thumbstripDiv.style.justifyItems="center",this.thumbstripDiv.style.alignContent="center",this.thumbstripDiv.style.alignItems="center",this.thumbstripDiv.style.display="flex",this.thumbstripDiv.style.flexDirection="column",this.thumbstripDiv.style.opacity="0",this.thumbstripDiv.style.visibility="hidden",this.thumbstripDiv.style.boxShadow="5px 5px 5px 0px rgba(0,0,0,0.5)",this.thumbstripImageDiv=document.createElement("msdiv"),this.thumbstripImageDiv.style.backgroundPosition="0px 0px",this.thumbstripImageDiv.style.backgroundSize="cover",this.displayThumbstrip||(this.thumbstripImageDiv.style.visibility="hidden",this.thumbstripImageDiv.style.display="none"),this.thumbstripTimestamp=document.createElement("msp"),this.thumbstripTimestamp.innerHTML="00 : 00",this.thumbstripTimestamp.style.color="white",this.thumbstripTimestamp.style.margin="5px",this.thumbstripTimestamp.style.fontFamily="monospace",this.thumbstripDiv.appendChild(this.thumbstripImageDiv),this.thumbstripDiv.appendChild(this.thumbstripTimestamp),this.getThumbstrip(this.hostname,this.contentID),this.thumbstripDiv},xl.prototype.smallSize=function(){var e=this.player.currentSkin.getMainBar().mainBar;this.thumbstripDiv.style.bottom=e.getBoundingClientRect().height+8+"px",this.scaleMultiplier=.8,this.thumbstripTimestamp.style.fontSize="10px",this.centerMultiplier=.5,this.targetThumbstripHeight=50,this.setThumbstripSize()},xl.prototype.mediumSize=function(){var e=this.player.currentSkin.getMainBar().mainBar;this.thumbstripDiv.style.bottom=e.getBoundingClientRect().height+8+"px",this.scaleMultiplier=.9,this.thumbstripTimestamp.style.fontSize="15px",this.centerMultiplier=.5,this.targetThumbstripHeight=70,this.setThumbstripSize()},xl.prototype.bigSize=function(){var e=this.player.currentSkin.getMainBar().mainBar;this.thumbstripDiv.style.bottom=e.getBoundingClientRect().height+8+"px",this.scaleMultiplier=1,this.thumbstripTimestamp.style.fontSize="20px",this.centerMultiplier=.5,this.targetThumbstripHeight=90,this.setThumbstripSize()},xl.prototype.setThumbstripSize=function(){var e;this.isVTT?this.targetThumbstripHeight<=this.vttTargetSize[0]?(e=this.targetThumbstripHeight/this.vttTargetSize[0],this.currThumbstripPieceWidth=this.vttTargetSize[0]*e,this.currThumbstripPieceHeight=this.vttTargetSize[1]*e):(this.currThumbstripPieceWidth=this.vttTargetSize[0],this.currThumbstripPieceHeight=this.vttTargetSize[1]):this.targetThumbstripHeight<=this.thumbstripPieceHeight?(e=this.targetThumbstripHeight/this.thumbstripPieceHeight,this.currThumbstripPieceWidth=this.thumbstripPieceWidth*e,this.currThumbstripPieceHeight=this.thumbstripPieceHeight*e):(this.currThumbstripPieceWidth=this.thumbstripPieceWidth,this.currThumbstripPieceHeight=this.thumbstripPieceHeight),this.thumbstripImageDiv.style.width=this.currThumbstripPieceWidth+"px",this.thumbstripImageDiv.style.height=this.currThumbstripPieceHeight+"px"},xl.prototype.showThumbstrip=function(e,t,i){var n=this;if(this.player.live)if(this.isVTT&&null!=(a=this.vttParser)&&a.loaded){var r=this.thumbstripDiv.getBoundingClientRect().width,a=(this.checkOverflow(this.thumbstripDiv,e-r*this.centerMultiplier/2),this.thumbstripDiv.style.visibility="visible",this.thumbstripDiv.style.opacity="1",this.thumbstripTimestamp.innerHTML=Es.calcHours(i),this.vttParser.getThumbstripByTime(i));null==a?w(T.Error,"Can't load thumbstrip"):(this.vttTargetSize=a.dimension,this.player.resizePlayer(),this.vttParser.getThumb(a,this.thumbstripImageDiv).then(function(e){n.thumbstripImageDiv.style.backgroundImage="url(".concat(e,")")}))}else{for(var r=this.thumbstripDiv.getBoundingClientRect().width,s=(this.checkOverflow(this.thumbstripDiv,e-r*this.centerMultiplier/2),this.thumbstripDiv.style.visibility="visible",this.thumbstripDiv.style.opacity="1",this.thumbstripTimestamp.innerHTML=Es.calcHours(i),100/this.player.contentInfo.thumbnailCount),o=0,l=0,u=s;u<=100;u+=s)u<=t&&(l=this.currThumbstripPieceWidth*++o);this.thumbstripImageDiv.style.backgroundPosition="right "+l+"px bottom 0px"}},xl.prototype.hideThumbstrip=function(){this.thumbstripDiv.style.opacity="0",this.thumbstripDiv.style.visibility="hidden"},xl.prototype.checkOverflow=function(e,t){var i=this.player.divPlayer.getBoundingClientRect(),i=(i.x,i.width),n=e.getBoundingClientRect().width;e.style.left=t<0?"0px":i>>0,n;for(n=0;n0)for(i=0;i=0;return(a?i?"+":"":"-")+Math.pow(10,Math.max(0,r)).toString().substr(1)+n}var se=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,oe=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,le={},ue={};function n(e,t,i,n){var r=n;if(typeof n==="string")r=function(){return this[n]()};if(e)ue[e]=r;if(t)ue[t[0]]=function(){return a(r.apply(this,arguments),t[1],t[2])};if(i)ue[i]=function(){return this.localeData().ordinal(r.apply(this,arguments),e)}}function de(e){if(e.match(/\[[\s\S]/))return e.replace(/^\[|\]$/g,"");return e.replace(/\\/g,"")}function ce(n){var r=n.match(se),e,a;for(e=0,a=r.length;e=0&&oe.test(e)){e=e.replace(oe,n);oe.lastIndex=0;i-=1}return e}var pe={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};function ge(e){var t=this._longDateFormat[e],i=this._longDateFormat[e.toUpperCase()];if(t||!i)return t;this._longDateFormat[e]=i.match(se).map(function(e){if(e==="MMMM"||e==="MM"||e==="DD"||e==="dddd")return e.slice(1);return e}).join("");return this._longDateFormat[e]}var ve="Invalid date";function me(){return this._invalidDate}var ye="%d",be=/\d{1,2}/;function Ee(e){return this._ordinal.replace("%d",e)}var Se={future:"in %s",past:"%s ago",s:"a few seconds",ss:"%d seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",w:"a week",ww:"%d weeks",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function Te(e,t,i,n){var r=this._relativeTime[i];return p(r)?r(e,t,i,n):r.replace(/%d/i,e)}function we(e,t){var i=this._relativeTime[e>0?"future":"past"];return p(i)?i(t):i.replace(/%s/i,t)}var Me={};function t(e,t){var i=e.toLowerCase();Me[i]=Me[i+"s"]=Me[t]=e}function g(e){return typeof e==="string"?Me[e]||Me[e.toLowerCase()]:undefined}function Ae(e){var t={},i,n;for(n in e)if(l(e,n)){i=g(n);if(i)t[i]=e[n]}return t}var Le={};function i(e,t){Le[e]=t}function Ie(e){var t=[],i;for(i in e)if(l(e,i))t.push({unit:i,priority:Le[i]});t.sort(function(e,t){return e.priority-t.priority});return t}function De(e){return e%4===0&&e%100!==0||e%400===0}function v(e){if(e<0)return Math.ceil(e)||0;else return Math.floor(e)}function m(e){var t=+e,i=0;if(t!==0&&isFinite(t))i=v(t);return i}function ke(t,i){return function(e){if(e!=null){xe(this,t,e);c.updateOffset(this,i);return this}else return _e(this,t)}}function _e(e,t){return e.isValid()?e._d["get"+(e._isUTC?"UTC":"")+t]():NaN}function xe(e,t,i){if(e.isValid()&&!isNaN(i))if(t==="FullYear"&&De(e.year())&&e.month()===1&&e.date()===29){i=m(i);e._d["set"+(e._isUTC?"UTC":"")+t](i,e.month(),at(i,e.month()))}else e._d["set"+(e._isUTC?"UTC":"")+t](i)}function Ce(e){e=g(e);if(p(this[e]))return this[e]();return this}function Re(e,t){if(typeof e==="object"){e=Ae(e);var i=Ie(e),n,r=i.length;for(n=0;n68?1900:2e3)};var Tt=ke("FullYear",true);function wt(){return De(this.year())}function Mt(e,t,i,n,r,a,s){var o;if(e<100&&e>=0){o=new Date(e+400,t,i,n,r,a,s);if(isFinite(o.getFullYear()))o.setFullYear(e)}else o=new Date(e,t,i,n,r,a,s);return o}function At(e){var t,i;if(e<100&&e>=0){i=Array.prototype.slice.call(arguments);i[0]=e+400;t=new Date(Date.UTC.apply(null,i));if(isFinite(t.getUTCFullYear()))t.setUTCFullYear(e)}else t=new Date(Date.UTC.apply(null,arguments));return t}function Lt(e,t,i){var n=7+t-i,r=(7+At(e,0,n).getUTCDay()-t)%7;return-r+n-1}function It(e,t,i,n,r){var a=(7+i-n)%7,s=Lt(e,n,r),o=1+7*(t-1)+a+s,l,u;if(o<=0){l=e-1;u=St(l)+o}else if(o>St(e)){l=e+1;u=o-St(e)}else{l=e;u=o}return{year:l,dayOfYear:u}}function Dt(e,t,i){var n=Lt(e.year(),t,i),r=Math.floor((e.dayOfYear()-n-1)/7)+1,a,s;if(r<1){s=e.year()-1;a=r+k(s,t,i)}else if(r>k(e.year(),t,i)){a=r-k(e.year(),t,i);s=e.year()+1}else{s=e.year();a=r}return{week:a,year:s}}function k(e,t,i){var n=Lt(e,t,i),r=Lt(e+1,t,i);return(St(e)-n+r)/7}function kt(e){return Dt(e,this._week.dow,this._week.doy).week}n("w",["ww",2],"wo","week"),n("W",["WW",2],"Wo","isoWeek"),t("week","w"),t("isoWeek","W"),i("week",5),i("isoWeek",5),b("w",y),b("ww",y,r),b("W",y),b("WW",y,r),$e(["w","ww","W","WW"],function(e,t,i,n){t[n.substr(0,1)]=m(e)});var _t={dow:0,doy:6};function xt(){return this._week.dow}function Ct(){return this._week.doy}function Rt(e){var t=this.localeData().week(this);return e==null?t:this.add((e-t)*7,"d")}function Pt(e){var t=Dt(this,1,4).week;return e==null?t:this.add((e-t)*7,"d")}function Nt(e,t){if(typeof e!=="string")return e;if(!isNaN(e))return parseInt(e,10);e=t.weekdaysParse(e);if(typeof e==="number")return e;return null}function Ot(e,t){if(typeof e==="string")return t.weekdaysParse(e)%7||7;return isNaN(e)?null:e}function Bt(e,t){return e.slice(t,7).concat(e.slice(0,t))}n("d",0,"do","day"),n("dd",0,0,function(e){return this.localeData().weekdaysMin(this,e)}),n("ddd",0,0,function(e){return this.localeData().weekdaysShort(this,e)}),n("dddd",0,0,function(e){return this.localeData().weekdays(this,e)}),n("e",0,0,"weekday"),n("E",0,0,"isoWeekday"),t("day","d"),t("weekday","e"),t("isoWeekday","E"),i("day",11),i("weekday",11),i("isoWeekday",11),b("d",y),b("e",y),b("E",y),b("dd",function(e,t){return t.weekdaysMinRegex(e)}),b("ddd",function(e,t){return t.weekdaysShortRegex(e)}),b("dddd",function(e,t){return t.weekdaysRegex(e)}),$e(["dd","ddd","dddd"],function(e,t,i,n){var r=i._locale.weekdaysParse(e,n,i._strict);if(r!=null)t.d=r;else h(i).invalidWeekday=e}),$e(["d","e","E"],function(e,t,i,n){t[n]=m(e)});var Ft="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Ut="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),zt="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Zt=Ke,jt=Ke,Gt=Ke;function Vt(e,t){var i=s(this._weekdays)?this._weekdays:this._weekdays[e&&e!==true&&this._weekdays.isFormat.test(t)?"format":"standalone"];return e===true?Bt(i,this._week.dow):e?i[e.day()]:i}function Yt(e){return e===true?Bt(this._weekdaysShort,this._week.dow):e?this._weekdaysShort[e.day()]:this._weekdaysShort}function Ht(e){return e===true?Bt(this._weekdaysMin,this._week.dow):e?this._weekdaysMin[e.day()]:this._weekdaysMin}function Wt(e,t,i){var n,r,a,s=e.toLocaleLowerCase();if(!this._weekdaysParse){this._weekdaysParse=[];this._shortWeekdaysParse=[];this._minWeekdaysParse=[];for(n=0;n<7;++n){a=d([2e3,1]).day(n);this._minWeekdaysParse[n]=this.weekdaysMin(a,"").toLocaleLowerCase();this._shortWeekdaysParse[n]=this.weekdaysShort(a,"").toLocaleLowerCase();this._weekdaysParse[n]=this.weekdays(a,"").toLocaleLowerCase()}}if(i)if(t==="dddd"){r=D.call(this._weekdaysParse,s);return r!==-1?r:null}else if(t==="ddd"){r=D.call(this._shortWeekdaysParse,s);return r!==-1?r:null}else{r=D.call(this._minWeekdaysParse,s);return r!==-1?r:null}else if(t==="dddd"){r=D.call(this._weekdaysParse,s);if(r!==-1)return r;r=D.call(this._shortWeekdaysParse,s);if(r!==-1)return r;r=D.call(this._minWeekdaysParse,s);return r!==-1?r:null}else if(t==="ddd"){r=D.call(this._shortWeekdaysParse,s);if(r!==-1)return r;r=D.call(this._weekdaysParse,s);if(r!==-1)return r;r=D.call(this._minWeekdaysParse,s);return r!==-1?r:null}else{r=D.call(this._minWeekdaysParse,s);if(r!==-1)return r;r=D.call(this._weekdaysParse,s);if(r!==-1)return r;r=D.call(this._shortWeekdaysParse,s);return r!==-1?r:null}}function Kt(e,t,i){var n,r,a;if(this._weekdaysParseExact)return Wt.call(this,e,t,i);if(!this._weekdaysParse){this._weekdaysParse=[];this._minWeekdaysParse=[];this._shortWeekdaysParse=[];this._fullWeekdaysParse=[]}for(n=0;n<7;n++){r=d([2e3,1]).day(n);if(i&&!this._fullWeekdaysParse[n]){this._fullWeekdaysParse[n]=new RegExp("^"+this.weekdays(r,"").replace(".","\\.?")+"$","i");this._shortWeekdaysParse[n]=new RegExp("^"+this.weekdaysShort(r,"").replace(".","\\.?")+"$","i");this._minWeekdaysParse[n]=new RegExp("^"+this.weekdaysMin(r,"").replace(".","\\.?")+"$","i")}if(!this._weekdaysParse[n]){a="^"+this.weekdays(r,"")+"|^"+this.weekdaysShort(r,"")+"|^"+this.weekdaysMin(r,"");this._weekdaysParse[n]=new RegExp(a.replace(".",""),"i")}if(i&&t==="dddd"&&this._fullWeekdaysParse[n].test(e))return n;else if(i&&t==="ddd"&&this._shortWeekdaysParse[n].test(e))return n;else if(i&&t==="dd"&&this._minWeekdaysParse[n].test(e))return n;else if(!i&&this._weekdaysParse[n].test(e))return n}}function Qt(e){if(!this.isValid())return e!=null?this:NaN;var t=this._isUTC?this._d.getUTCDay():this._d.getDay();if(e!=null){e=Nt(e,this.localeData());return this.add(e-t,"d")}else return t}function qt(e){if(!this.isValid())return e!=null?this:NaN;var t=(this.day()+7-this.localeData()._week.dow)%7;return e==null?t:this.add(e-t,"d")}function Xt(e){if(!this.isValid())return e!=null?this:NaN;if(e!=null){var t=Ot(e,this.localeData());return this.day(this.day()%7?t:t-7)}else return this.day()||7}function Jt(e){if(this._weekdaysParseExact){if(!l(this,"_weekdaysRegex"))ti.call(this);if(e)return this._weekdaysStrictRegex;else return this._weekdaysRegex}else{if(!l(this,"_weekdaysRegex"))this._weekdaysRegex=Zt;return this._weekdaysStrictRegex&&e?this._weekdaysStrictRegex:this._weekdaysRegex}}function $t(e){if(this._weekdaysParseExact){if(!l(this,"_weekdaysRegex"))ti.call(this);if(e)return this._weekdaysShortStrictRegex;else return this._weekdaysShortRegex}else{if(!l(this,"_weekdaysShortRegex"))this._weekdaysShortRegex=jt;return this._weekdaysShortStrictRegex&&e?this._weekdaysShortStrictRegex:this._weekdaysShortRegex}}function ei(e){if(this._weekdaysParseExact){if(!l(this,"_weekdaysRegex"))ti.call(this);if(e)return this._weekdaysMinStrictRegex;else return this._weekdaysMinRegex}else{if(!l(this,"_weekdaysMinRegex"))this._weekdaysMinRegex=Gt;return this._weekdaysMinStrictRegex&&e?this._weekdaysMinStrictRegex:this._weekdaysMinRegex}}function ti(){function e(e,t){return t.length-e.length}var t=[],i=[],n=[],r=[],a,s,o,l,u;for(a=0;a<7;a++){s=d([2e3,1]).day(a);o=E(this.weekdaysMin(s,""));l=E(this.weekdaysShort(s,""));u=E(this.weekdays(s,""));t.push(o);i.push(l);n.push(u);r.push(o);r.push(l);r.push(u)}t.sort(e);i.sort(e);n.sort(e);r.sort(e);this._weekdaysRegex=new RegExp("^("+r.join("|")+")","i");this._weekdaysShortRegex=this._weekdaysRegex;this._weekdaysMinRegex=this._weekdaysRegex;this._weekdaysStrictRegex=new RegExp("^("+n.join("|")+")","i");this._weekdaysShortStrictRegex=new RegExp("^("+i.join("|")+")","i");this._weekdaysMinStrictRegex=new RegExp("^("+t.join("|")+")","i")}function ii(){return this.hours()%12||12}function ni(){return this.hours()||24}function ri(e,t){n(e,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),t)})}function ai(e,t){return t._meridiemParse}function si(e){return(e+"").toLowerCase().charAt(0)==="p"}n("H",["HH",2],0,"hour"),n("h",["hh",2],0,ii),n("k",["kk",2],0,ni),n("hmm",0,0,function(){return""+ii.apply(this)+a(this.minutes(),2)}),n("hmmss",0,0,function(){return""+ii.apply(this)+a(this.minutes(),2)+a(this.seconds(),2)}),n("Hmm",0,0,function(){return""+this.hours()+a(this.minutes(),2)}),n("Hmmss",0,0,function(){return""+this.hours()+a(this.minutes(),2)+a(this.seconds(),2)}),ri("a",true),ri("A",false),t("hour","h"),i("hour",13),b("a",ai),b("A",ai),b("H",y),b("h",y),b("k",y),b("HH",y,r),b("hh",y,r),b("kk",y,r),b("hmm",Fe),b("hmmss",Ue),b("Hmm",Fe),b("Hmmss",Ue),S(["H","HH"],A),S(["k","kk"],function(e,t,i){var n=m(e);t[A]=n===24?0:n}),S(["a","A"],function(e,t,i){i._isPm=i._locale.isPM(e);i._meridiem=e}),S(["h","hh"],function(e,t,i){t[A]=m(e);h(i).bigHour=true}),S("hmm",function(e,t,i){var n=e.length-2;t[A]=m(e.substr(0,n));t[L]=m(e.substr(n));h(i).bigHour=true}),S("hmmss",function(e,t,i){var n=e.length-4,r=e.length-2;t[A]=m(e.substr(0,n));t[L]=m(e.substr(n,2));t[I]=m(e.substr(r));h(i).bigHour=true}),S("Hmm",function(e,t,i){var n=e.length-2;t[A]=m(e.substr(0,n));t[L]=m(e.substr(n))}),S("Hmmss",function(e,t,i){var n=e.length-4,r=e.length-2;t[A]=m(e.substr(0,n));t[L]=m(e.substr(n,2));t[I]=m(e.substr(r))});var oi,li=ke("Hours",true);function ui(e,t,i){if(e>11)return i?"pm":"PM";else return i?"am":"AM"}var di={calendar:re,longDateFormat:pe,invalidDate:ve,ordinal:ye,dayOfMonthOrdinalParse:be,relativeTime:Se,months:st,monthsShort:ot,week:_t,weekdays:Ft,weekdaysMin:zt,weekdaysShort:Ut,meridiemParse:/[ap]\.?m?\.?/i},_={},ci={},hi;function fi(e,t){var i,n=Math.min(e.length,t.length);for(i=0;i0){r=mi(a.slice(0,i).join("-"));if(r)return r;if(n&&n.length>=i&&fi(a,n)>=i-1)break;i--}t++}return hi}function vi(e){return e.match("^[^/\\\\]*$")!=null}function mi(t){var e=null,i;if(_[t]===undefined&&"object"!=="undefined"&&us&&us.exports&&vi(t))try{e=hi._abbr;i=du;i("./locale/"+t);yi(e)}catch(e){_[t]=null}return _[t]}function yi(e,t){var i;if(e){if(o(t))i=Si(e);else i=bi(e,t);if(i)hi=i;else if(typeof console!=="undefined"&&console.warn)console.warn("Locale "+e+" not found. Did you forget to load it?")}return hi._abbr}function bi(e,t){if(t!==null){var i,n=di;t.abbr=e;if(_[e]!=null){ee("defineLocaleOverride","use moment.updateLocale(localeName, config) to change "+"an existing locale. moment.defineLocale(localeName, "+"config) should only be used for creating a new locale "+"See http://momentjs.com/guides/#/warnings/define-locale/ for more info.");n=_[e]._config}else if(t.parentLocale!=null)if(_[t.parentLocale]!=null)n=_[t.parentLocale]._config;else{i=mi(t.parentLocale);if(i!=null)n=i._config;else{if(!ci[t.parentLocale])ci[t.parentLocale]=[];ci[t.parentLocale].push({name:e,config:t});return null}}_[e]=new ne(ie(n,t));if(ci[e])ci[e].forEach(function(e){bi(e.name,e.config)});yi(e);return _[e]}else{delete _[e];return null}}function Ei(e,t){if(t!=null){var i,n,r=di;if(_[e]!=null&&_[e].parentLocale!=null)_[e].set(ie(_[e]._config,t));else{n=mi(e);if(n!=null)r=n._config;t=ie(r,t);if(n==null)t.abbr=e;i=new ne(t);i.parentLocale=_[e];_[e]=i}yi(e)}else if(_[e]!=null)if(_[e].parentLocale!=null){_[e]=_[e].parentLocale;if(e===yi())yi(e)}else if(_[e]!=null)delete _[e];return _[e]}function Si(e){var t;if(e&&e._locale&&e._locale._abbr)e=e._locale._abbr;if(!e)return hi;if(!s(e)){t=mi(e);if(t)return t;e=[e]}return gi(e)}function Ti(){return $(_)}function wi(e){var t,i=e._a;if(i&&h(e).overflow===-2){t=i[w]<0||i[w]>11?w:i[M]<1||i[M]>at(i[T],i[w])?M:i[A]<0||i[A]>24||i[A]===24&&(i[L]!==0||i[I]!==0||i[tt]!==0)?A:i[L]<0||i[L]>59?L:i[I]<0||i[I]>59?I:i[tt]<0||i[tt]>999?tt:-1;if(h(e)._overflowDayOfYear&&(tM))t=M;if(h(e)._overflowWeeks&&t===-1)t=it;if(h(e)._overflowWeekday&&t===-1)t=nt;h(e).overflow=t}return e}var Mi=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ai=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Li=/Z|[+-]\d\d(?::?\d\d)?/,Ii=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,false],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,false],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,false],["YYYYDDD",/\d{7}/],["YYYYMM",/\d{6}/,false],["YYYY",/\d{4}/,false]],Di=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],ki=/^\/?Date\((-?\d+)/i,_i=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/,xi={UT:0,GMT:0,EDT:-4*60,EST:-5*60,CDT:-5*60,CST:-6*60,MDT:-6*60,MST:-7*60,PDT:-7*60,PST:-8*60};function Ci(e){var t,i,n=e._i,r=Mi.exec(n)||Ai.exec(n),a,s,o,l,u=Ii.length,d=Di.length;if(r){h(e).iso=true;for(t=0,i=u;tSt(s)||e._dayOfYear===0)h(e)._overflowDayOfYear=true;i=At(s,0,e._dayOfYear);e._a[w]=i.getUTCMonth();e._a[M]=i.getUTCDate()}for(t=0;t<3&&e._a[t]==null;++t)e._a[t]=n[t]=r[t];for(;t<7;t++)e._a[t]=n[t]=e._a[t]==null?t===2?1:0:e._a[t];if(e._a[A]===24&&e._a[L]===0&&e._a[I]===0&&e._a[tt]===0){e._nextDay=true;e._a[A]=0}e._d=(e._useUTC?At:Mt).apply(null,n);a=e._useUTC?e._d.getUTCDay():e._d.getDay();if(e._tzm!=null)e._d.setUTCMinutes(e._d.getUTCMinutes()-e._tzm);if(e._nextDay)e._a[A]=24;if(e._w&&typeof e._w.d!=="undefined"&&e._w.d!==a)h(e).weekdayMismatch=true}function Gi(e){var t,i,n,r,a,s,o,l,u;t=e._w;if(t.GG!=null||t.W!=null||t.E!=null){a=1;s=4;i=zi(t.GG,e._a[T],Dt(x(),1,4).year);n=zi(t.W,1);r=zi(t.E,1);if(r<1||r>7)l=true}else{a=e._locale._week.dow;s=e._locale._week.doy;u=Dt(x(),a,s);i=zi(t.gg,e._a[T],u.year);n=zi(t.w,u.week);if(t.d!=null){r=t.d;if(r<0||r>6)l=true}else if(t.e!=null){r=t.e+a;if(t.e<0||t.e>6)l=true}else r=a}if(n<1||n>k(i,a,s))h(e)._overflowWeeks=true;else if(l!=null)h(e)._overflowWeekday=true;else{o=It(i,n,r,a,s);e._a[T]=o.year;e._dayOfYear=o.dayOfYear}}function Vi(e){if(e._f===c.ISO_8601){Ci(e);return}if(e._f===c.RFC_2822){Fi(e);return}e._a=[];h(e).empty=true;var t=""+e._i,i,n,r,a,s,o=t.length,l=0,u,d;r=fe(e._f,e._locale).match(se)||[];d=r.length;for(i=0;i0)h(e).unusedInput.push(s);t=t.slice(t.indexOf(n)+n.length);l+=n.length}if(ue[a]){if(n)h(e).empty=false;else h(e).unusedTokens.push(a);et(a,n,e)}else if(e._strict&&!n)h(e).unusedTokens.push(a)}h(e).charsLeftOver=o-l;if(t.length>0)h(e).unusedInput.push(t);if(e._a[A]<=12&&h(e).bigHour===true&&e._a[A]>0)h(e).bigHour=undefined;h(e).parsedDateParts=e._a.slice(0);h(e).meridiem=e._meridiem;e._a[A]=Yi(e._locale,e._a[A],e._meridiem);u=h(e).era;if(u!==null)e._a[T]=e._locale.erasConvertYear(u,e._a[T]);ji(e);wi(e)}function Yi(e,t,i){var n;if(i==null)return t;if(e.meridiemHour!=null)return e.meridiemHour(t,i);else if(e.isPM!=null){n=e.isPM(i);if(n&&t<12)t+=12;if(!n&&t===12)t=0;return t}else return t}function Hi(e){var t,i,n,r,a,s,o=false,l=e._f.length;if(l===0){h(e).invalidFormat=true;e._d=new Date(NaN);return}for(r=0;rthis?this:e;else return H()});function en(e,t){var i,n;if(t.length===1&&s(t[0]))t=t[0];if(!t.length)return x();i=t[0];for(n=1;nthis.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function An(){if(!o(this._isDSTShifted))return this._isDSTShifted;var e={},t;Q(e,this);e=Qi(e);if(e._a){t=e._isUTC?d(e._a):x(e._a);this._isDSTShifted=this.isValid()&&hn(e._a,t.toArray())>0}else this._isDSTShifted=false;return this._isDSTShifted}function Ln(){return this.isValid()?!this._isUTC:false}function In(){return this.isValid()?this._isUTC:false}function Dn(){return this.isValid()?this._isUTC&&this._offset===0:false}c.updateOffset=function(){};var kn=/^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/,_n=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;function C(e,t){var i=e,n=null,r,a,s;if(dn(e))i={ms:e._milliseconds,d:e._days,M:e._months};else if(u(e)||!isNaN(+e)){i={};if(t)i[t]=+e;else i.milliseconds=+e}else if(n=kn.exec(e)){r=n[1]==="-"?-1:1;i={y:0,d:m(n[M])*r,h:m(n[A])*r,m:m(n[L])*r,s:m(n[I])*r,ms:m(cn(n[tt]*1e3))*r}}else if(n=_n.exec(e)){r=n[1]==="-"?-1:1;i={y:xn(n[2],r),M:xn(n[3],r),w:xn(n[4],r),d:xn(n[5],r),h:xn(n[6],r),m:xn(n[7],r),s:xn(n[8],r)}}else if(i==null)i={};else if(typeof i==="object"&&("from"in i||"to"in i)){s=Rn(x(i.from),x(i.to));i={};i.ms=s.milliseconds;i.M=s.months}a=new un(i);if(dn(e)&&l(e,"_locale"))a._locale=e._locale;if(dn(e)&&l(e,"_isValid"))a._isValid=e._isValid;return a}function xn(e,t){var i=e&&parseFloat(e.replace(",","."));return(isNaN(i)?0:i)*t}function Cn(e,t){var i={};i.months=t.month()-e.month()+(t.year()-e.year())*12;if(e.clone().add(i.months,"M").isAfter(t))--i.months;i.milliseconds=+t-+e.clone().add(i.months,"M");return i}function Rn(e,t){var i;if(!(e.isValid()&&t.isValid()))return{milliseconds:0,months:0};t=vn(t,e);if(e.isBefore(t))i=Cn(e,t);else{i=Cn(t,e);i.milliseconds=-i.milliseconds;i.months=-i.months}return i}function Pn(r,a){return function(e,t){var i,n;if(t!==null&&!isNaN(+t)){ee(a,"moment()."+a+"(period, number) is deprecated. Please use moment()."+a+"(number, period). "+"See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.");n=e;e=t;t=n}i=C(e,t);Nn(this,i,r);return this}}function Nn(e,t,i,n){var r=t._milliseconds,a=cn(t._days),s=cn(t._months);if(!e.isValid())return;n=n==null?true:n;if(s)gt(e,_e(e,"Month")+s*i);if(a)xe(e,"Date",_e(e,"Date")+a*i);if(r)e._d.setTime(e._d.valueOf()+r*i);if(n)c.updateOffset(e,a||s)}C.fn=un.prototype,C.invalid=ln;var On=Pn(1,"add"),Bn=Pn(-1,"subtract");function Fn(e){return typeof e==="string"||e instanceof String}function Un(e){return f(e)||Z(e)||Fn(e)||u(e)||Zn(e)||zn(e)||e===null||e===undefined}function zn(e){var t=U(e)&&!z(e),i=false,n=["years","year","y","months","month","M","days","day","d","dates","date","D","hours","hour","h","minutes","minute","m","seconds","second","s","milliseconds","millisecond","ms"],r,a,s=n.length;for(r=0;ri.valueOf();else return i.valueOf()9999)return he(i,t?"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYYYY-MM-DD[T]HH:mm:ss.SSSZ");if(p(Date.prototype.toISOString))if(t)return this.toDate().toISOString();else return new Date(this.valueOf()+this.utcOffset()*60*1e3).toISOString().replace("Z",he(i,"Z"));return he(i,t?"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]":"YYYY-MM-DD[T]HH:mm:ss.SSSZ")}function ir(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var e="moment",t="",i,n,r,a;if(!this.isLocal()){e=this.utcOffset()===0?"moment.utc":"moment.parseZone";t="Z"}i="["+e+'("]';n=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY";r="-MM-DD[T]HH:mm:ss.SSS";a=t+'[")]';return this.format(i+n+r+a)}function nr(e){if(!e)e=this.isUtc()?c.defaultFormatUtc:c.defaultFormat;var t=he(this,e);return this.localeData().postformat(t)}function rr(e,t){if(this.isValid()&&(f(e)&&e.isValid()||x(e).isValid()))return C({to:this,from:e}).locale(this.locale()).humanize(!t);else return this.localeData().invalidDate()}function ar(e){return this.from(x(),e)}function sr(e,t){if(this.isValid()&&(f(e)&&e.isValid()||x(e).isValid()))return C({from:this,to:e}).locale(this.locale()).humanize(!t);else return this.localeData().invalidDate()}function or(e){return this.to(x(),e)}function lr(e){var t;if(e===undefined)return this._locale._abbr;else{t=Si(e);if(t!=null)this._locale=t;return this}}c.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",c.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";var ur=e("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(e){if(e===undefined)return this.localeData();else return this.locale(e)});function dr(){return this._locale}var cr=1e3,hr=60*cr,fr=60*hr,pr=(365*400+97)*24*fr;function gr(e,t){return(e%t+t)%t}function vr(e,t,i){if(e<100&&e>=0)return new Date(e+400,t,i)-pr;else return new Date(e,t,i).valueOf()}function mr(e,t,i){if(e<100&&e>=0)return Date.UTC(e+400,t,i)-pr;else return Date.UTC(e,t,i)}function yr(e){var t,i;e=g(e);if(e===undefined||e==="millisecond"||!this.isValid())return this;i=this._isUTC?mr:vr;switch(e){case"year":t=i(this.year(),0,1);break;case"quarter":t=i(this.year(),this.month()-this.month()%3,1);break;case"month":t=i(this.year(),this.month(),1);break;case"week":t=i(this.year(),this.month(),this.date()-this.weekday());break;case"isoWeek":t=i(this.year(),this.month(),this.date()-(this.isoWeekday()-1));break;case"day":case"date":t=i(this.year(),this.month(),this.date());break;case"hour":t=this._d.valueOf();t-=gr(t+(this._isUTC?0:this.utcOffset()*hr),fr);break;case"minute":t=this._d.valueOf();t-=gr(t,hr);break;case"second":t=this._d.valueOf();t-=gr(t,cr);break}this._d.setTime(t);c.updateOffset(this,true);return this}function br(e){var t,i;e=g(e);if(e===undefined||e==="millisecond"||!this.isValid())return this;i=this._isUTC?mr:vr;switch(e){case"year":t=i(this.year()+1,0,1)-1;break;case"quarter":t=i(this.year(),this.month()-this.month()%3+3,1)-1;break;case"month":t=i(this.year(),this.month()+1,1)-1;break;case"week":t=i(this.year(),this.month(),this.date()-this.weekday()+7)-1;break;case"isoWeek":t=i(this.year(),this.month(),this.date()-(this.isoWeekday()-1)+7)-1;break;case"day":case"date":t=i(this.year(),this.month(),this.date()+1)-1;break;case"hour":t=this._d.valueOf();t+=fr-gr(t+(this._isUTC?0:this.utcOffset()*hr),fr)-1;break;case"minute":t=this._d.valueOf();t+=hr-gr(t,hr)-1;break;case"second":t=this._d.valueOf();t+=cr-gr(t,cr)-1;break}this._d.setTime(t);c.updateOffset(this,true);return this}function Er(){return this._d.valueOf()-(this._offset||0)*6e4}function Sr(){return Math.floor(this.valueOf()/1e3)}function Tr(){return new Date(this.valueOf())}function wr(){var e=this;return[e.year(),e.month(),e.date(),e.hour(),e.minute(),e.second(),e.millisecond()]}function Mr(){var e=this;return{years:e.year(),months:e.month(),date:e.date(),hours:e.hours(),minutes:e.minutes(),seconds:e.seconds(),milliseconds:e.milliseconds()}}function Ar(){return this.isValid()?this.toISOString():null}function Lr(){return Y(this)}function Ir(){return G({},h(this))}function Dr(){return h(this).overflow}function kr(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}function _r(e,t){var i,n,r,a=this._eras||Si("en")._eras;for(i=0,n=a.length;i=0)return a[n]}}function Cr(e,t){var i=e.since<=e.until?+1:-1;if(t===undefined)return c(e.since).year();else return c(e.since).year()+(t-e.offset)*i}function Rr(){var e,t,i,n=this.localeData().eras();for(e=0,t=n.length;ea)t=a;return $r.call(this,e,t,i,n,r)}}function $r(e,t,i,n,r){var a=It(e,t,i,n,r),s=At(a.year,0,a.dayOfYear);this.year(s.getUTCFullYear());this.month(s.getUTCMonth());this.date(s.getUTCDate());return this}function ea(e){return e==null?Math.ceil((this.month()+1)/3):this.month((e-1)*3+this.month()%3)}n("N",0,0,"eraAbbr"),n("NN",0,0,"eraAbbr"),n("NNN",0,0,"eraAbbr"),n("NNNN",0,0,"eraName"),n("NNNNN",0,0,"eraNarrow"),n("y",["y",1],"yo","eraYear"),n("y",["yy",2],0,"eraYear"),n("y",["yyy",3],0,"eraYear"),n("y",["yyyy",4],0,"eraYear"),b("N",zr),b("NN",zr),b("NNN",zr),b("NNNN",Zr),b("NNNNN",jr),S(["N","NN","NNN","NNNN","NNNNN"],function(e,t,i,n){var r=i._locale.erasParse(e,n,i._strict);if(r)h(i).era=r;else h(i).invalidEra=e}),b("y",Ge),b("yy",Ge),b("yyy",Ge),b("yyyy",Ge),b("yo",Gr),S(["y","yy","yyy","yyyy"],T),S(["yo"],function(e,t,i,n){var r;if(i._locale._eraYearOrdinalRegex)r=e.match(i._locale._eraYearOrdinalRegex);if(i._locale.eraYearOrdinalParse)t[T]=i._locale.eraYearOrdinalParse(e,r);else t[T]=parseInt(e,10)}),n(0,["gg",2],0,function(){return this.weekYear()%100}),n(0,["GG",2],0,function(){return this.isoWeekYear()%100}),Yr("gggg","weekYear"),Yr("ggggg","weekYear"),Yr("GGGG","isoWeekYear"),Yr("GGGGG","isoWeekYear"),t("weekYear","gg"),t("isoWeekYear","GG"),i("weekYear",1),i("isoWeekYear",1),b("G",Ve),b("g",Ve),b("GG",y,r),b("gg",y,r),b("GGGG",Ze,Oe),b("gggg",Ze,Oe),b("GGGGG",je,Be),b("ggggg",je,Be),$e(["gggg","ggggg","GGGG","GGGGG"],function(e,t,i,n){t[n.substr(0,2)]=m(e)}),$e(["gg","GG"],function(e,t,i,n){t[n]=c.parseTwoDigitYear(e)}),n("Q",0,"Qo","quarter"),t("quarter","Q"),i("quarter",7),b("Q",Pe),S("Q",function(e,t){t[w]=(m(e)-1)*3}),n("D",["DD",2],"Do","date"),t("date","D"),i("date",9),b("D",y),b("DD",y,r),b("Do",function(e,t){return e?t._dayOfMonthOrdinalParse||t._ordinalParse:t._dayOfMonthOrdinalParseLenient}),S(["D","DD"],M),S("Do",function(e,t){t[M]=m(e.match(y)[0])});var ta=ke("Date",true);function ia(e){var t=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return e==null?t:this.add(e-t,"d")}n("DDD",["DDDD",3],"DDDo","dayOfYear"),t("dayOfYear","DDD"),i("dayOfYear",4),b("DDD",ze),b("DDDD",Ne),S(["DDD","DDDD"],function(e,t,i){i._dayOfYear=m(e)}),n("m",["mm",2],0,"minute"),t("minute","m"),i("minute",14),b("m",y),b("mm",y,r),S(["m","mm"],L);var na=ke("Minutes",false),ra=(n("s",["ss",2],0,"second"),t("second","s"),i("second",15),b("s",y),b("ss",y,r),S(["s","ss"],I),ke("Seconds",false)),aa,sa;for(n("S",0,0,function(){return~~(this.millisecond()/100)}),n(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),n(0,["SSS",3],0,"millisecond"),n(0,["SSSS",4],0,function(){return this.millisecond()*10}),n(0,["SSSSS",5],0,function(){return this.millisecond()*100}),n(0,["SSSSSS",6],0,function(){return this.millisecond()*1e3}),n(0,["SSSSSSS",7],0,function(){return this.millisecond()*1e4}),n(0,["SSSSSSSS",8],0,function(){return this.millisecond()*1e5}),n(0,["SSSSSSSSS",9],0,function(){return this.millisecond()*1e6}),t("millisecond","ms"),i("millisecond",16),b("S",ze,Pe),b("SS",ze,r),b("SSS",ze,Ne),aa="SSSS";aa.length<=9;aa+="S")b(aa,Ge);function oa(e,t){t[tt]=m(("0."+e)*1e3)}for(aa="S";aa.length<=9;aa+="S")S(aa,oa);function la(){return this._isUTC?"UTC":""}function ua(){return this._isUTC?"Coordinated Universal Time":""}sa=ke("Milliseconds",false),n("z",0,0,"zoneAbbr"),n("zz",0,0,"zoneName");var R=q.prototype;if(R.add=On,R.calendar=Vn,R.clone=Yn,R.diff=Jn,R.endOf=br,R.format=nr,R.from=rr,R.fromNow=ar,R.to=sr,R.toNow=or,R.get=Ce,R.invalidAt=Dr,R.isAfter=Hn,R.isBefore=Wn,R.isBetween=Kn,R.isSame=Qn,R.isSameOrAfter=qn,R.isSameOrBefore=Xn,R.isValid=Lr,R.lang=ur,R.locale=lr,R.localeData=dr,R.max=$i,R.min=Ji,R.parsingFlags=Ir,R.set=Re,R.startOf=yr,R.subtract=Bn,R.toArray=wr,R.toObject=Mr,R.toDate=Tr,R.toISOString=tr,R.inspect=ir,typeof Symbol!=="undefined"&&Symbol.for!=null)R[Symbol.for("nodejs.util.inspect.custom")]=function(){return"Moment<"+this.format()+">"};function da(e){return x(e*1e3)}function ca(){return x.apply(null,arguments).parseZone()}function ha(e){return e}R.toJSON=Ar,R.toString=er,R.unix=Sr,R.valueOf=Er,R.creationData=kr,R.eraName=Rr,R.eraNarrow=Pr,R.eraAbbr=Nr,R.eraYear=Or,R.year=Tt,R.isLeapYear=wt,R.weekYear=Hr,R.isoWeekYear=Wr,R.quarter=R.quarters=ea,R.month=vt,R.daysInMonth=mt,R.week=R.weeks=Rt,R.isoWeek=R.isoWeeks=Pt,R.weeksInYear=qr,R.weeksInWeekYear=Xr,R.isoWeeksInYear=Kr,R.isoWeeksInISOWeekYear=Qr,R.date=ta,R.day=R.days=Qt,R.weekday=qt,R.isoWeekday=Xt,R.dayOfYear=ia,R.hour=R.hours=li,R.minute=R.minutes=na,R.second=R.seconds=ra,R.millisecond=R.milliseconds=sa,R.utcOffset=yn,R.utc=En,R.local=Sn,R.parseZone=Tn,R.hasAlignedHourOffset=wn,R.isDST=Mn,R.isLocal=Ln,R.isUtcOffset=In,R.isUtc=Dn,R.isUTC=Dn,R.zoneAbbr=la,R.zoneName=ua,R.dates=e("dates accessor is deprecated. Use date instead.",ta),R.months=e("months accessor is deprecated. Use month instead",vt),R.years=e("years accessor is deprecated. Use year instead",Tt),R.zone=e("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",bn),R.isDSTShifted=e("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",An);var P=ne.prototype;function fa(e,t,i,n){var r=Si(),a=d().set(n,t);return r[i](a,e)}function pa(e,t,i){if(u(e)){t=e;e=undefined}e=e||"";if(t!=null)return fa(e,t,i,"month");var n,r=[];for(n=0;n<12;n++)r[n]=fa(e,n,i,"month");return r}function ga(e,t,i,n){if(typeof e==="boolean"){if(u(t)){i=t;t=undefined}t=t||""}else{t=e;i=t;e=false;if(u(t)){i=t;t=undefined}t=t||""}var r=Si(),a=e?r._week.dow:0,s,o=[];if(i!=null)return fa(t,(i+a)%7,n,"day");for(s=0;s<7;s++)o[s]=fa(t,(s+a)%7,n,"day");return o}function va(e,t){return pa(e,t,"months")}function ma(e,t){return pa(e,t,"monthsShort")}function ya(e,t,i){return ga(e,t,i,"weekdays")}function ba(e,t,i){return ga(e,t,i,"weekdaysShort")}function Ea(e,t,i){return ga(e,t,i,"weekdaysMin")}P.calendar=ae,P.longDateFormat=ge,P.invalidDate=me,P.ordinal=Ee,P.preparse=ha,P.postformat=ha,P.relativeTime=Te,P.pastFuture=we,P.set=te,P.eras=_r,P.erasParse=xr,P.erasConvertYear=Cr,P.erasAbbrRegex=Fr,P.erasNameRegex=Br,P.erasNarrowRegex=Ur,P.months=ct,P.monthsShort=ht,P.monthsParse=pt,P.monthsRegex=bt,P.monthsShortRegex=yt,P.week=kt,P.firstDayOfYear=Ct,P.firstDayOfWeek=xt,P.weekdays=Vt,P.weekdaysMin=Ht,P.weekdaysShort=Yt,P.weekdaysParse=Kt,P.weekdaysRegex=Jt,P.weekdaysShortRegex=$t,P.weekdaysMinRegex=ei,P.isPM=si,P.meridiem=ui,yi("en",{eras:[{since:"0001-01-01",until:+Infinity,offset:1,name:"Anno Domini",narrow:"AD",abbr:"AD"},{since:"0000-12-31",until:-Infinity,offset:1,name:"Before Christ",narrow:"BC",abbr:"BC"}],dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(e){var t=e%10,i=m(e%100/10)===1?"th":t===1?"st":t===2?"nd":t===3?"rd":"th";return e+i}}),c.lang=e("moment.lang is deprecated. Use moment.locale instead.",yi),c.langData=e("moment.langData is deprecated. Use moment.localeData instead.",Si);var Sa=Math.abs;function Ta(){var e=this._data;this._milliseconds=Sa(this._milliseconds);this._days=Sa(this._days);this._months=Sa(this._months);e.milliseconds=Sa(e.milliseconds);e.seconds=Sa(e.seconds);e.minutes=Sa(e.minutes);e.hours=Sa(e.hours);e.months=Sa(e.months);e.years=Sa(e.years);return this}function wa(e,t,i,n){var r=C(t,i);e._milliseconds+=n*r._milliseconds;e._days+=n*r._days;e._months+=n*r._months;return e._bubble()}function Ma(e,t){return wa(this,e,t,1)}function Aa(e,t){return wa(this,e,t,-1)}function La(e){if(e<0)return Math.floor(e);else return Math.ceil(e)}function Ia(){var e=this._milliseconds,t=this._days,i=this._months,n=this._data,r,a,s,o,l;if(!(e>=0&&t>=0&&i>=0||e<=0&&t<=0&&i<=0)){e+=La(ka(i)+t)*864e5;t=0;i=0}n.milliseconds=e%1e3;r=v(e/1e3);n.seconds=r%60;a=v(r/60);n.minutes=a%60;s=v(a/60);n.hours=s%24;t+=v(s/24);l=v(Da(t));i+=l;t-=La(ka(l));o=v(i/12);i%=12;n.days=t;n.months=i;n.years=o;return this}function Da(e){return e*4800/146097}function ka(e){return e*146097/4800}function _a(e){if(!this.isValid())return NaN;var t,i,n=this._milliseconds;e=g(e);if(e==="month"||e==="quarter"||e==="year"){t=this._days+n/864e5;i=this._months+Da(t);switch(e){case"month":return i;case"quarter":return i/3;case"year":return i/12}}else{t=this._days+Math.round(ka(this._months));switch(e){case"week":return t/7+n/6048e5;case"day":return t+n/864e5;case"hour":return t*24+n/36e5;case"minute":return t*1440+n/6e4;case"second":return t*86400+n/1e3;case"millisecond":return Math.floor(t*864e5)+n;default:throw new Error("Unknown unit "+e)}}}function xa(){if(!this.isValid())return NaN;return this._milliseconds+this._days*864e5+this._months%12*2592e6+m(this._months/12)*31536e6}function Ca(e){return function(){return this.as(e)}}var Ra=Ca("ms"),Pa=Ca("s"),Na=Ca("m"),Oa=Ca("h"),Ba=Ca("d"),Fa=Ca("w"),Ua=Ca("M"),za=Ca("Q"),Za=Ca("y");function ja(){return C(this)}function Ga(e){e=g(e);return this.isValid()?this[e+"s"]():NaN}function Va(e){return function(){return this.isValid()?this._data[e]:NaN}}var Ya=Va("milliseconds"),Ha=Va("seconds"),Wa=Va("minutes"),Ka=Va("hours"),Qa=Va("days"),qa=Va("months"),Xa=Va("years");function Ja(){return v(this.days()/7)}var $a=Math.round,es={ss:44,s:45,m:45,h:22,d:26,w:null,M:11};function ts(e,t,i,n,r){return r.relativeTime(t||1,!!i,e,n)}function is(e,t,i,n){var r=C(e).abs(),a=$a(r.as("s")),s=$a(r.as("m")),o=$a(r.as("h")),l=$a(r.as("d")),u=$a(r.as("M")),d=$a(r.as("w")),c=$a(r.as("y")),h=a<=i.ss&&["s",a]||a0;h[4]=n;return ts.apply(null,h)}function ns(e){if(e===undefined)return $a;if(typeof e==="function"){$a=e;return true}return false}function rs(e,t){if(es[e]===undefined)return false;if(t===undefined)return es[e];es[e]=t;if(e==="s")es.ss=t-1;return true}function as(e,t){if(!this.isValid())return this.localeData().invalidDate();var i=false,n=es,r,a;if(typeof e==="object"){t=e;e=false}if(typeof e==="boolean")i=e;if(typeof t==="object"){n=Object.assign({},es,t);if(t.s!=null&&t.ss==null)n.ss=t.s-1}r=this.localeData();a=is(this,!i,n,r);if(i)a=r.pastFuture(+this,a);return r.postformat(a)}var ss=Math.abs;function os(e){return(e>0)-(e<0)||+e}function ls(){if(!this.isValid())return this.localeData().invalidDate();var e=ss(this._milliseconds)/1e3,t=ss(this._days),i=ss(this._months),n,r,a,s,o=this.asSeconds(),l,u,d,c;if(!o)return"P0D";n=v(e/60);r=v(n/60);e%=60;n%=60;a=v(i/12);i%=12;s=e?e.toFixed(3).replace(/\.?0+$/,""):"";l=o<0?"-":"";u=os(this._months)!==os(o)?"-":"";d=os(this._days)!==os(o)?"-":"";c=os(this._milliseconds)!==os(o)?"-":"";return l+"P"+(a?u+a+"Y":"")+(i?u+i+"M":"")+(t?d+t+"D":"")+(r||n||e?"T":"")+(r?c+r+"H":"")+(n?c+n+"M":"")+(e?c+s+"S":"")}var N=un.prototype;return N.isValid=on,N.abs=Ta,N.add=Ma,N.subtract=Aa,N.as=_a,N.asMilliseconds=Ra,N.asSeconds=Pa,N.asMinutes=Na,N.asHours=Oa,N.asDays=Ba,N.asWeeks=Fa,N.asMonths=Ua,N.asQuarters=za,N.asYears=Za,N.valueOf=xa,N._bubble=Ia,N.clone=ja,N.get=Ga,N.milliseconds=Ya,N.seconds=Ha,N.minutes=Wa,N.hours=Ka,N.days=Qa,N.weeks=Ja,N.months=qa,N.years=Xa,N.humanize=as,N.toISOString=ls,N.toString=ls,N.toJSON=ls,N.locale=lr,N.localeData=dr,N.toIsoString=e("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",ls),N.lang=ur,n("X",0,0,"unix"),n("x",0,0,"valueOf"),b("x",Ve),b("X",We),S("X",function(e,t,i){i._d=new Date(parseFloat(e)*1e3)}),S("x",function(e,t,i){i._d=new Date(m(e))}),c.version="2.29.4",F(x),c.fn=R,c.min=tn,c.max=nn,c.now=rn,c.utc=d,c.unix=da,c.months=va,c.isDate=Z,c.locale=yi,c.invalid=H,c.duration=C,c.isMoment=f,c.weekdays=ya,c.parseZone=ca,c.localeData=Si,c.isDuration=dn,c.monthsShort=ma,c.weekdaysMin=Ea,c.defineLocale=bi,c.updateLocale=Ei,c.locales=Ti,c.weekdaysShort=ba,c.normalizeUnits=g,c.relativeTimeRounding=ns,c.relativeTimeThreshold=rs,c.calendarFormat=Gn,c.prototype=R,c.HTML5_FMT={DATETIME_LOCAL:"YYYY-MM-DDTHH:mm",DATETIME_LOCAL_SECONDS:"YYYY-MM-DDTHH:mm:ss",DATETIME_LOCAL_MS:"YYYY-MM-DDTHH:mm:ss.SSS",DATE:"YYYY-MM-DD",TIME:"HH:mm",TIME_SECONDS:"HH:mm:ss",TIME_MS:"HH:mm:ss.SSS",WEEK:"GGGG-[W]WW",MONTH:"YYYY-MM"},c}()),hu.exports}var pu=Wa(function(n){function O(e,t){return t={exports:{}},e(t,t.exports),t.exports}function B(e){return e&&e["default"]||e}n=n&&n.hasOwnProperty("default")?n["default"]:n;var d={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},u=O(function(e){var o={};for(var t in d)if(d.hasOwnProperty(t))o[d[t]]=t;var l=e.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var i in l)if(l.hasOwnProperty(i)){if(!("channels"in l[i]))throw new Error("missing channels property: "+i);if(!("labels"in l[i]))throw new Error("missing channel labels property: "+i);if(l[i].labels.length!==l[i].channels)throw new Error("channel and label counts mismatch: "+i);var n=l[i].channels;var r=l[i].labels;delete l[i].channels;delete l[i].labels;Object.defineProperty(l[i],"channels",{value:n});Object.defineProperty(l[i],"labels",{value:r})}l.rgb.hsl=function(e){var t=e[0]/255;var i=e[1]/255;var n=e[2]/255;var r=Math.min(t,i,n);var a=Math.max(t,i,n);var s=a-r;var o;var l;var u;if(a===r)o=0;else if(t===a)o=(i-n)/s;else if(i===a)o=2+(n-t)/s;else if(n===a)o=4+(t-i)/s;o=Math.min(o*60,360);if(o<0)o+=360;u=(r+a)/2;if(a===r)l=0;else if(u<=.5)l=s/(a+r);else l=s/(2-a-r);return[o,l*100,u*100]};l.rgb.hsv=function(e){var t;var i;var n;var r;var a;var s=e[0]/255;var o=e[1]/255;var l=e[2]/255;var u=Math.max(s,o,l);var d=u-Math.min(s,o,l);var c=function(e){return(u-e)/6/d+1/2};if(d===0)r=a=0;else{a=d/u;t=c(s);i=c(o);n=c(l);if(s===u)r=n-i;else if(o===u)r=1/3+t-n;else if(l===u)r=2/3+i-t;if(r<0)r+=1;else if(r>1)r-=1}return[r*360,a*100,u*100]};l.rgb.hwb=function(e){var t=e[0];var i=e[1];var n=e[2];var r=l.rgb.hsl(e)[0];var a=1/255*Math.min(t,Math.min(i,n));n=1-1/255*Math.max(t,Math.max(i,n));return[r,a*100,n*100]};l.rgb.cmyk=function(e){var t=e[0]/255;var i=e[1]/255;var n=e[2]/255;var r;var a;var s;var o;o=Math.min(1-t,1-i,1-n);r=(1-t-o)/(1-o)||0;a=(1-i-o)/(1-o)||0;s=(1-n-o)/(1-o)||0;return[r*100,a*100,s*100,o*100]};function u(e,t){return Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2)}l.rgb.keyword=function(e){var t=o[e];if(t)return t;var i=Infinity;var n;for(var r in d)if(d.hasOwnProperty(r)){var a=d[r];var s=u(e,a);if(s.04045?Math.pow((t+.055)/1.055,2.4):t/12.92;i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92;n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var r=t*.4124+i*.3576+n*.1805;var a=t*.2126+i*.7152+n*.0722;var s=t*.0193+i*.1192+n*.9505;return[r*100,a*100,s*100]};l.rgb.lab=function(e){var t=l.rgb.xyz(e);var i=t[0];var n=t[1];var r=t[2];var a;var s;var o;i/=95.047;n/=100;r/=108.883;i=i>.008856?Math.pow(i,1/3):7.787*i+16/116;n=n>.008856?Math.pow(n,1/3):7.787*n+16/116;r=r>.008856?Math.pow(r,1/3):7.787*r+16/116;a=116*n-16;s=500*(i-n);o=200*(n-r);return[a,s,o]};l.hsl.rgb=function(e){var t=e[0]/360;var i=e[1]/100;var n=e[2]/100;var r;var a;var s;var o;var l;if(i===0){l=n*255;return[l,l,l]}if(n<.5)a=n*(1+i);else a=n+i-n*i;r=2*n-a;o=[0,0,0];for(var u=0;u<3;u++){s=t+1/3*-(u-1);if(s<0)s++;if(s>1)s--;if(6*s<1)l=r+(a-r)*6*s;else if(2*s<1)l=a;else if(3*s<2)l=r+(a-r)*(2/3-s)*6;else l=r;o[u]=l*255}return o};l.hsl.hsv=function(e){var t=e[0];var i=e[1]/100;var n=e[2]/100;var r=i;var a=Math.max(n,.01);var s;var o;n*=2;i*=n<=1?n:2-n;r*=a<=1?a:2-a;o=(n+i)/2;s=n===0?2*r/(a+r):2*i/(n+i);return[t,s*100,o*100]};l.hsv.rgb=function(e){var t=e[0]/60;var i=e[1]/100;var n=e[2]/100;var r=Math.floor(t)%6;var a=t-Math.floor(t);var s=255*n*(1-i);var o=255*n*(1-i*a);var l=255*n*(1-i*(1-a));n*=255;switch(r){case 0:return[n,l,s];case 1:return[o,n,s];case 2:return[s,n,l];case 3:return[s,o,n];case 4:return[l,s,n];case 5:return[n,s,o]}};l.hsv.hsl=function(e){var t=e[0];var i=e[1]/100;var n=e[2]/100;var r=Math.max(n,.01);var a;var s;var o;o=(2-i)*n;a=(2-i)*r;s=i*r;s/=a<=1?a:2-a;s=s||0;o/=2;return[t,s*100,o*100]};l.hwb.rgb=function(e){var t=e[0]/360;var i=e[1]/100;var n=e[2]/100;var r=i+n;var a;var s;var o;var l;if(r>1){i/=r;n/=r}a=Math.floor(6*t);s=1-n;o=6*t-a;if((a&1)!==0)o=1-o;l=i+o*(s-i);var u;var d;var c;switch(a){default:case 6:case 0:u=s;d=l;c=i;break;case 1:u=l;d=s;c=i;break;case 2:u=i;d=s;c=l;break;case 3:u=i;d=l;c=s;break;case 4:u=l;d=i;c=s;break;case 5:u=s;d=i;c=l;break}return[u*255,d*255,c*255]};l.cmyk.rgb=function(e){var t=e[0]/100;var i=e[1]/100;var n=e[2]/100;var r=e[3]/100;var a;var s;var o;a=1-Math.min(1,t*(1-r)+r);s=1-Math.min(1,i*(1-r)+r);o=1-Math.min(1,n*(1-r)+r);return[a*255,s*255,o*255]};l.xyz.rgb=function(e){var t=e[0]/100;var i=e[1]/100;var n=e[2]/100;var r;var a;var s;r=t*3.2406+i*-1.5372+n*-.4986;a=t*-.9689+i*1.8758+n*.0415;s=t*.0557+i*-.204+n*1.057;r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:r*12.92;a=a>.0031308?1.055*Math.pow(a,1/2.4)-.055:a*12.92;s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s*12.92;r=Math.min(Math.max(0,r),1);a=Math.min(Math.max(0,a),1);s=Math.min(Math.max(0,s),1);return[r*255,a*255,s*255]};l.xyz.lab=function(e){var t=e[0];var i=e[1];var n=e[2];var r;var a;var s;t/=95.047;i/=100;n/=108.883;t=t>.008856?Math.pow(t,1/3):7.787*t+16/116;i=i>.008856?Math.pow(i,1/3):7.787*i+16/116;n=n>.008856?Math.pow(n,1/3):7.787*n+16/116;r=116*i-16;a=500*(t-i);s=200*(i-n);return[r,a,s]};l.lab.xyz=function(e){var t=e[0];var i=e[1];var n=e[2];var r;var a;var s;a=(t+16)/116;r=i/500+a;s=a-n/200;var o=Math.pow(a,3);var l=Math.pow(r,3);var u=Math.pow(s,3);a=o>.008856?o:(a-16/116)/7.787;r=l>.008856?l:(r-16/116)/7.787;s=u>.008856?u:(s-16/116)/7.787;r*=95.047;a*=100;s*=108.883;return[r,a,s]};l.lab.lch=function(e){var t=e[0];var i=e[1];var n=e[2];var r;var a;var s;r=Math.atan2(n,i);a=r*360/2/Math.PI;if(a<0)a+=360;s=Math.sqrt(i*i+n*n);return[t,s,a]};l.lch.lab=function(e){var t=e[0];var i=e[1];var n=e[2];var r;var a;var s;s=n/360*2*Math.PI;r=i*Math.cos(s);a=i*Math.sin(s);return[t,r,a]};l.rgb.ansi16=function(e){var t=e[0];var i=e[1];var n=e[2];var r=1 in arguments?arguments[1]:l.rgb.hsv(e)[2];r=Math.round(r/50);if(r===0)return 30;var a=30+(Math.round(n/255)<<2|Math.round(i/255)<<1|Math.round(t/255));if(r===2)a+=60;return a};l.hsv.ansi16=function(e){return l.rgb.ansi16(l.hsv.rgb(e),e[2])};l.rgb.ansi256=function(e){var t=e[0];var i=e[1];var n=e[2];if(t===i&&i===n){if(t<8)return 16;if(t>248)return 231;return Math.round((t-8)/247*24)+232}var r=16+36*Math.round(t/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5);return r};l.ansi16.rgb=function(e){var t=e%10;if(t===0||t===7){if(e>50)t+=3.5;t=t/10.5*255;return[t,t,t]}var i=(~~(e>50)+1)*.5;var n=(t&1)*i*255;var r=(t>>1&1)*i*255;var a=(t>>2&1)*i*255;return[n,r,a]};l.ansi256.rgb=function(e){if(e>=232){var t=(e-232)*10+8;return[t,t,t]}e-=16;var i;var n=Math.floor(e/36)/5*255;var r=Math.floor((i=e%36)/6)/5*255;var a=i%6/5*255;return[n,r,a]};l.rgb.hex=function(e){var t=((Math.round(e[0])&255)<<16)+((Math.round(e[1])&255)<<8)+(Math.round(e[2])&255);var i=t.toString(16).toUpperCase();return"000000".substring(i.length)+i};l.hex.rgb=function(e){var t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];var i=t[0];if(t[0].length===3)i=i.split("").map(function(e){return e+e}).join("");var n=parseInt(i,16);var r=n>>16&255;var a=n>>8&255;var s=n&255;return[r,a,s]};l.rgb.hcg=function(e){var t=e[0]/255;var i=e[1]/255;var n=e[2]/255;var r=Math.max(Math.max(t,i),n);var a=Math.min(Math.min(t,i),n);var s=r-a;var o;var l;if(s<1)o=a/(1-s);else o=0;if(s<=0)l=0;else if(r===t)l=(i-n)/s%6;else if(r===i)l=2+(n-t)/s;else l=4+(t-i)/s+4;l/=6;l%=1;return[l*360,s*100,o*100]};l.hsl.hcg=function(e){var t=e[1]/100;var i=e[2]/100;var n=1;var r=0;if(i<.5)n=2*t*i;else n=2*t*(1-i);if(n<1)r=(i-.5*n)/(1-n);return[e[0],n*100,r*100]};l.hsv.hcg=function(e){var t=e[1]/100;var i=e[2]/100;var n=t*i;var r=0;if(n<1)r=(i-n)/(1-n);return[e[0],n*100,r*100]};l.hcg.rgb=function(e){var t=e[0]/360;var i=e[1]/100;var n=e[2]/100;if(i===0)return[n*255,n*255,n*255];var r=[0,0,0];var a=t%1*6;var s=a%1;var o=1-s;var l=0;switch(Math.floor(a)){case 0:r[0]=1;r[1]=s;r[2]=0;break;case 1:r[0]=o;r[1]=1;r[2]=0;break;case 2:r[0]=0;r[1]=1;r[2]=s;break;case 3:r[0]=0;r[1]=o;r[2]=1;break;case 4:r[0]=s;r[1]=0;r[2]=1;break;default:r[0]=1;r[1]=0;r[2]=o}l=(1-i)*n;return[(i*r[0]+l)*255,(i*r[1]+l)*255,(i*r[2]+l)*255]};l.hcg.hsv=function(e){var t=e[1]/100;var i=e[2]/100;var n=t+i*(1-t);var r=0;if(n>0)r=t/n;return[e[0],r*100,n*100]};l.hcg.hsl=function(e){var t=e[1]/100;var i=e[2]/100;var n=i*(1-t)+.5*t;var r=0;if(n>0&&n<.5)r=t/(2*n);else if(n>=.5&&n<1)r=t/(2*(1-n));return[e[0],r*100,n*100]};l.hcg.hwb=function(e){var t=e[1]/100;var i=e[2]/100;var n=t+i*(1-t);return[e[0],(n-t)*100,(1-n)*100]};l.hwb.hcg=function(e){var t=e[1]/100;var i=e[2]/100;var n=1-i;var r=n-t;var a=0;if(r<1)a=(n-r)/(1-r);return[e[0],r*100,a*100]};l.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]};l.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]};l.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]};l.gray.hsl=l.gray.hsv=function(e){return[0,0,e[0]]};l.gray.hwb=function(e){return[0,100,e[0]]};l.gray.cmyk=function(e){return[0,0,0,e[0]]};l.gray.lab=function(e){return[e[0],0,0]};l.gray.hex=function(e){var t=Math.round(e[0]/100*255)&255;var i=(t<<16)+(t<<8)+t;var n=i.toString(16).toUpperCase();return"000000".substring(n.length)+n};l.rgb.gray=function(e){var t=(e[0]+e[1]+e[2])/3;return[t/255*100]}});function F(){var e={};var t=Object.keys(u);for(var i=t.length,n=0;n1)e=Array.prototype.slice.call(arguments);return t(e)};if("conversion"in t)e.conversion=t.conversion;return e}function H(r){var e=function(e){if(e===undefined||e===null)return e;if(arguments.length>1)e=Array.prototype.slice.call(arguments);var t=r(e);if(typeof t==="object")for(var i=t.length,n=0;n=0&&t<1?de(Math.round(t*255)):"")}function ie(e,t){if(t<1||e[3]&&e[3]<1)return ne(e,t);return"rgb("+e[0]+", "+e[1]+", "+e[2]+")"}function ne(e,t){if(t===undefined)t=e[3]!==undefined?e[3]:1;return"rgba("+e[0]+", "+e[1]+", "+e[2]+", "+t+")"}function re(e,t){if(t<1||e[3]&&e[3]<1)return ae(e,t);var i=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),r=Math.round(e[2]/255*100);return"rgb("+i+"%, "+n+"%, "+r+"%)"}function ae(e,t){var i=Math.round(e[0]/255*100),n=Math.round(e[1]/255*100),r=Math.round(e[2]/255*100);return"rgba("+i+"%, "+n+"%, "+r+"%, "+(t||e[3]||1)+")"}function se(e,t){if(t<1||e[3]&&e[3]<1)return oe(e,t);return"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)"}function oe(e,t){if(t===undefined)t=e[3]!==undefined?e[3]:1;return"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+t+")"}function le(e,t){if(t===undefined)t=e[3]!==undefined?e[3]:1;return"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+(t!==undefined&&t!==1?", "+t:"")+")"}function ue(e){return ce[e.slice(0,3)]}function c(e,t,i){return Math.min(Math.max(t,e),i)}function de(e){var t=e.toString(16).toUpperCase();return t.length<2?"0"+t:t}var ce={},he;for(he in K)ce[K[he]]=he;var s=function(e){if(e instanceof s)return e;if(!(this instanceof s))return new s(e);this.valid=false;this.values={rgb:[0,0,0],hsl:[0,0,0],hsv:[0,0,0],hwb:[0,0,0],cmyk:[0,0,0,0],alpha:1};var t;if(typeof e==="string"){t=i.getRgba(e);if(t)this.setValues("rgb",t);else if(t=i.getHsla(e))this.setValues("hsl",t);else if(t=i.getHwb(e))this.setValues("hwb",t)}else if(typeof e==="object"){t=e;if(t.r!==undefined||t.red!==undefined)this.setValues("rgb",t);else if(t.l!==undefined||t.lightness!==undefined)this.setValues("hsl",t);else if(t.v!==undefined||t.value!==undefined)this.setValues("hsv",t);else if(t.w!==undefined||t.whiteness!==undefined)this.setValues("hwb",t);else if(t.c!==undefined||t.cyan!==undefined)this.setValues("cmyk",t)}};if((s.prototype={isValid:function(){return this.valid},rgb:function(){return this.setSpace("rgb",arguments)},hsl:function(){return this.setSpace("hsl",arguments)},hsv:function(){return this.setSpace("hsv",arguments)},hwb:function(){return this.setSpace("hwb",arguments)},cmyk:function(){return this.setSpace("cmyk",arguments)},rgbArray:function(){return this.values.rgb},hslArray:function(){return this.values.hsl},hsvArray:function(){return this.values.hsv},hwbArray:function(){var e=this.values;if(e.alpha!==1)return e.hwb.concat([e.alpha]);return e.hwb},cmykArray:function(){return this.values.cmyk},rgbaArray:function(){var e=this.values;return e.rgb.concat([e.alpha])},hslaArray:function(){var e=this.values;return e.hsl.concat([e.alpha])},alpha:function(e){if(e===undefined)return this.values.alpha;this.setValues("alpha",e);return this},red:function(e){return this.setChannel("rgb",0,e)},green:function(e){return this.setChannel("rgb",1,e)},blue:function(e){return this.setChannel("rgb",2,e)},hue:function(e){if(e){e%=360;e=e<0?360+e:e}return this.setChannel("hsl",0,e)},saturation:function(e){return this.setChannel("hsl",1,e)},lightness:function(e){return this.setChannel("hsl",2,e)},saturationv:function(e){return this.setChannel("hsv",1,e)},whiteness:function(e){return this.setChannel("hwb",1,e)},blackness:function(e){return this.setChannel("hwb",2,e)},value:function(e){return this.setChannel("hsv",2,e)},cyan:function(e){return this.setChannel("cmyk",0,e)},magenta:function(e){return this.setChannel("cmyk",1,e)},yellow:function(e){return this.setChannel("cmyk",2,e)},black:function(e){return this.setChannel("cmyk",3,e)},hexString:function(){return i.hexString(this.values.rgb)},rgbString:function(){return i.rgbString(this.values.rgb,this.values.alpha)},rgbaString:function(){return i.rgbaString(this.values.rgb,this.values.alpha)},percentString:function(){return i.percentString(this.values.rgb,this.values.alpha)},hslString:function(){return i.hslString(this.values.hsl,this.values.alpha)},hslaString:function(){return i.hslaString(this.values.hsl,this.values.alpha)},hwbString:function(){return i.hwbString(this.values.hwb,this.values.alpha)},keyword:function(){return i.keyword(this.values.rgb,this.values.alpha)},rgbNumber:function(){var e=this.values.rgb;return e[0]<<16|e[1]<<8|e[2]},luminosity:function(){var e=this.values.rgb;var t=[];for(var i=0;ii)return(t+.05)/(i+.05);return(i+.05)/(t+.05)},level:function(e){var t=this.contrast(e);if(t>=7.1)return"AAA";return t>=4.5?"AA":""},dark:function(){var e=this.values.rgb;var t=(e[0]*299+e[1]*587+e[2]*114)/1e3;return t<128},light:function(){return!this.dark()},negate:function(){var e=[];for(var t=0;t<3;t++)e[t]=255-this.values.rgb[t];this.setValues("rgb",e);return this},lighten:function(e){var t=this.values.hsl;t[2]+=t[2]*e;this.setValues("hsl",t);return this},darken:function(e){var t=this.values.hsl;t[2]-=t[2]*e;this.setValues("hsl",t);return this},saturate:function(e){var t=this.values.hsl;t[1]+=t[1]*e;this.setValues("hsl",t);return this},desaturate:function(e){var t=this.values.hsl;t[1]-=t[1]*e;this.setValues("hsl",t);return this},whiten:function(e){var t=this.values.hwb;t[1]+=t[1]*e;this.setValues("hwb",t);return this},blacken:function(e){var t=this.values.hwb;t[2]+=t[2]*e;this.setValues("hwb",t);return this},greyscale:function(){var e=this.values.rgb;var t=e[0]*.3+e[1]*.59+e[2]*.11;this.setValues("rgb",[t,t,t]);return this},clearer:function(e){var t=this.values.alpha;this.setValues("alpha",t-t*e);return this},opaquer:function(e){var t=this.values.alpha;this.setValues("alpha",t+t*e);return this},rotate:function(e){var t=this.values.hsl;var i=(t[0]+e)%360;t[0]=i<0?360+i:i;this.setValues("hsl",t);return this},mix:function(e,t){var i=this;var n=e;var r=t===undefined?.5:t;var a=2*r-1;var s=i.alpha()-n.alpha();var o=((a*s===-1?a:(a+s)/(1+a*s))+1)/2;var l=1-o;return this.rgb(o*i.red()+l*n.red(),o*i.green()+l*n.green(),o*i.blue()+l*n.blue()).alpha(i.alpha()*r+n.alpha()*(1-r))},toJSON:function(){return this.rgb()},clone:function(){var e=new s;var t=this.values;var i=e.values;var n,r;for(var a in t)if(t.hasOwnProperty(a)){n=t[a];r={}.toString.call(n);if(r==="[object Array]")i[a]=n.slice(0);else if(r==="[object Number]")i[a]=n;else console.error("unexpected color value:",n)}return e}}).spaces={rgb:["red","green","blue"],hsl:["hue","saturation","lightness"],hsv:["hue","saturation","value"],hwb:["hue","whiteness","blackness"],cmyk:["cyan","magenta","yellow","black"]},s.prototype.maxes={rgb:[255,255,255],hsl:[360,100,100],hsv:[360,100,100],hwb:[360,100,100],cmyk:[100,100,100,100]},s.prototype.getValues=function(e){var t=this.values;var i={};for(var n=0;n=0;r--)t.call(i,e[r],r);else for(r=0;r=1)return e;return-(Math.sqrt(1-e*e)-1)},easeOutCirc:function(e){return Math.sqrt(1-(e=e-1)*e)},easeInOutCirc:function(e){if((e/=.5)<1)return-.5*(Math.sqrt(1-e*e)-1);return.5*(Math.sqrt(1-(e-=2)*e)+1)},easeInElastic:function(e){var t=1.70158;var i=0;var n=1;if(e===0)return 0;if(e===1)return 1;if(!i)i=.3;t=i/(2*Math.PI)*Math.asin(1/n);return-(n*Math.pow(2,10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/i))},easeOutElastic:function(e){var t=1.70158;var i=0;var n=1;if(e===0)return 0;if(e===1)return 1;if(!i)i=.3;t=i/(2*Math.PI)*Math.asin(1/n);return n*Math.pow(2,-10*e)*Math.sin((e-t)*(2*Math.PI)/i)+1},easeInOutElastic:function(e){var t=1.70158;var i=0;var n=1;if(e===0)return 0;if((e/=.5)===2)return 1;if(!i)i=.45;t=i/(2*Math.PI)*Math.asin(1/n);if(e<1)return-.5*(n*Math.pow(2,10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/i));return n*Math.pow(2,-10*(e-=1))*Math.sin((e-t)*(2*Math.PI)/i)*.5+1},easeInBack:function(e){var t=1.70158;return e*e*((t+1)*e-t)},easeOutBack:function(e){var t=1.70158;return(e=e-1)*e*((t+1)*e+t)+1},easeInOutBack:function(e){var t=1.70158;if((e/=.5)<1)return.5*(e*e*(((t*=1.525)+1)*e-t));return.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:function(e){return 1-ge.easeOutBounce(1-e)},easeOutBounce:function(e){if(e<1/2.75)return 7.5625*e*e;if(e<2/2.75)return 7.5625*(e-=1.5/2.75)*e+.75;if(e<2.5/2.75)return 7.5625*(e-=2.25/2.75)*e+.9375;return 7.5625*(e-=2.625/2.75)*e+.984375},easeInOutBounce:function(e){if(e<.5)return ge.easeInBounce(e*2)*.5;return ge.easeOutBounce(e*2-1)*.5+.5}}),ve={effects:ge},f=(l.easingEffects=ge,Math.PI),me=f/180,ye=f*2,p=f/2,be=f/4,Ee=f*2/3,Se={clear:function(e){e.ctx.clearRect(0,0,e.width,e.height)},roundedRect:function(e,t,i,n,r,a){if(a){var s=Math.min(a,r/2,n/2);var o=t+s;var l=i+s;var u=t+n-s;var d=i+r-s;e.moveTo(t,l);if(ot.left-i&&e.xt.top-i&&e.y0)e.requestAnimationFrame()},advance:function(){var e=this.animations;var t,i,n,r;var a=0;while(a=n){R.callback(t.onAnimationComplete,[t],i);i.animating=false;e.splice(a,1)}else++a}}}),Ye=R.options.resolve,He=["push","pop","shift","splice","unshift"];function We(r,e){if(r._chartjs){r._chartjs.listeners.push(e);return}Object.defineProperty(r,"_chartjs",{configurable:true,enumerable:false,value:{listeners:[e]}});He.forEach(function(e){var i="onData"+e.charAt(0).toUpperCase()+e.slice(1);var n=r[e];Object.defineProperty(r,e,{configurable:true,enumerable:false,value:function(){var t=Array.prototype.slice.call(arguments);var e=n.apply(this,t);R.each(r._chartjs.listeners,function(e){if(typeof e[i]==="function")e[i].apply(e,t)});return e}})})}function Ke(t,e){var i=t._chartjs;if(!i)return;var n=i.listeners;var r=n.indexOf(e);if(r!==-1)n.splice(r,1);if(n.length>0)return;He.forEach(function(e){delete t[e]});delete t._chartjs}var Qe=function(e,t){this.initialize(e,t)},g=(R.extend(Qe.prototype,{datasetElementType:null,dataElementType:null,_datasetElementOptions:["backgroundColor","borderCapStyle","borderColor","borderDash","borderDashOffset","borderJoinStyle","borderWidth"],_dataElementOptions:["backgroundColor","borderColor","borderWidth","pointStyle"],initialize:function(e,t){var i=this;i.chart=e;i.index=t;i.linkScales();i.addElements();i._type=i.getMeta().type},updateIndex:function(e){this.index=e},linkScales:function(){var e=this;var t=e.getMeta();var i=e.chart;var n=i.scales;var r=e.getDataset();var a=i.options.scales;if(t.xAxisID===null||!(t.xAxisID in n)||r.xAxisID)t.xAxisID=r.xAxisID||a.xAxes[0].id;if(t.yAxisID===null||!(t.yAxisID in n)||r.yAxisID)t.yAxisID=r.yAxisID||a.yAxes[0].id},getDataset:function(){return this.chart.data.datasets[this.index]},getMeta:function(){return this.chart.getDatasetMeta(this.index)},getScaleForId:function(e){return this.chart.scales[e]},_getValueScaleId:function(){return this.getMeta().yAxisID},_getIndexScaleId:function(){return this.getMeta().xAxisID},_getValueScale:function(){return this.getScaleForId(this._getValueScaleId())},_getIndexScale:function(){return this.getScaleForId(this._getIndexScaleId())},reset:function(){this._update(true)},destroy:function(){if(this._data)Ke(this._data,this)},createMetaDataset:function(){var e=this;var t=e.datasetElementType;return t&&new t({_chart:e.chart,_datasetIndex:e.index})},createMetaData:function(e){var t=this;var i=t.dataElementType;return i&&new i({_chart:t.chart,_datasetIndex:t.index,_index:e})},addElements:function(){var e=this;var t=e.getMeta();var i=e.getDataset().data||[];var n=t.data;var r,a;for(r=0,a=i.length;rn)e.insertElements(n,r-n)},insertElements:function(e,t){for(var i=0;ir){a=r/t.innerRadius;e.arc(s,o,t.innerRadius-r,n+a,i-a,true)}else e.arc(s,o,r,n+Math.PI/2,i-Math.PI/2);e.closePath();e.clip()}function Xe(e,t,i,n){var r=i.endAngle;var a;if(n){i.endAngle=i.startAngle+v;qe(e,i);i.endAngle=r;if(i.endAngle===i.startAngle&&i.fullCircles){i.endAngle+=v;i.fullCircles--}}e.beginPath();e.arc(i.x,i.y,i.innerRadius,i.startAngle+v,i.startAngle,true);for(a=0;ao)r-=v;while(r=s&&r<=o;var u=a>=i.innerRadius&&a<=i.outerRadius;return l&&u}return false},getCenterPoint:function(){var e=this._view;var t=(e.startAngle+e.endAngle)/2;var i=(e.innerRadius+e.outerRadius)/2;return{x:e.x+Math.cos(t)*i,y:e.y+Math.sin(t)*i}},getArea:function(){var e=this._view;return Math.PI*((e.endAngle-e.startAngle)/(2*Math.PI))*(Math.pow(e.outerRadius,2)-Math.pow(e.innerRadius,2))},tooltipPosition:function(){var e=this._view;var t=e.startAngle+(e.endAngle-e.startAngle)/2;var i=(e.outerRadius-e.innerRadius)/2+e.innerRadius;return{x:e.x+Math.cos(t)*i,y:e.y+Math.sin(t)*i}},draw:function(){var e=this._chart.ctx;var t=this._view;var i=t.borderAlign==="inner"?.33:0;var n={x:t.x,y:t.y,innerRadius:t.innerRadius,outerRadius:Math.max(t.outerRadius-i,0),pixelMargin:i,startAngle:t.startAngle,endAngle:t.endAngle,fullCircles:Math.floor(t.circumference/v)};var r;e.save();e.fillStyle=t.backgroundColor;e.strokeStyle=t.borderColor;if(n.fullCircles){n.endAngle=n.startAngle+v;e.beginPath();e.arc(n.x,n.y,n.outerRadius,n.startAngle,n.endAngle);e.arc(n.x,n.y,n.innerRadius,n.endAngle,n.startAngle,true);e.closePath();for(r=0;re.x)t=ct(t,"left","right")}else if(e.basei?i:a,r:r.right||s<0?0:s>t?t:s,b:r.bottom||o<0?0:o>i?i:o,l:r.left||l<0?0:l>t?t:l}}function pt(e){var t=dt(e);var i=t.right-t.left;var n=t.bottom-t.top;var r=ft(e,i/2,n/2);return{outer:{x:t.left,y:t.top,w:i,h:n},inner:{x:t.left+r.l,y:t.top+r.t,w:i-r.l-r.r,h:n-r.t-r.b}}}function gt(e,t,i){var n=t===null;var r=i===null;var a=!e||n&&r?false:dt(e);return a&&(n||t>=a.left&&t<=a.right)&&(r||i>=a.top&&i<=a.bottom)}L._set("global",{elements:{rectangle:{backgroundColor:lt,borderColor:lt,borderSkipped:"bottom",borderWidth:0}}});var vt=e.extend({_type:"rectangle",draw:function(){var e=this._chart.ctx;var t=this._view;var i=pt(t);var n=i.outer;var r=i.inner;e.fillStyle=t.backgroundColor;e.fillRect(n.x,n.y,n.w,n.h);if(n.w===r.w&&n.h===r.h)return;e.save();e.beginPath();e.rect(n.x,n.y,n.w,n.h);e.clip();e.fillStyle=t.borderColor;e.rect(r.x,r.y,r.w,r.h);e.fill("evenodd");e.restore()},height:function(){var e=this._view;return e.base-e.y},inRange:function(e,t){return gt(this._view,e,t)},inLabelRange:function(e,t){var i=this._view;return ut(i)?gt(i,e,null):gt(i,null,t)},inXRange:function(e){return gt(this._view,e,null)},inYRange:function(e){return gt(this._view,null,e)},getCenterPoint:function(){var e=this._view;var t,i;if(ut(e)){t=e.x;i=(e.y+e.base)/2}else{t=(e.x+e.base)/2;i=e.y}return{x:t,y:i}},getArea:function(){var e=this._view;return ut(e)?e.width*Math.abs(e.y-e.base):e.height*Math.abs(e.x-e.base)},tooltipPosition:function(){var e=this._view;return{x:e.x,y:e.y}}}),m={},mt,yt=it,bt=ot,Et=vt,St=(m.Arc=$e,m.Line=yt,m.Point=bt,m.Rectangle=Et,R._deprecated),Tt=R.valueOrDefault;function wt(e,t){var i=e._length;var n,r,a,s;for(a=1,s=t.length;a0?Math.min(i,Math.abs(r-n)):i;n=r}return i}function Mt(e,t,i){var n=i.barThickness;var r=t.stackCount;var a=t.pixels[e];var s=R.isNullOrUndef(n)?wt(t.scale,t.pixels):-1;var o,l;if(R.isNullOrUndef(n)){o=s*i.categoryPercentage;l=i.barPercentage}else{o=n*r;l=1}return{chunk:o/r,ratio:l,start:a-o/2}}function At(e,t,i){var n=t.pixels;var r=n[e];var a=e>0?n[e-1]:null;var s=e=0&&u.min>=0?u.min:u.max;var p=u.start===undefined?u.end:u.max>=0&&u.min>=0?u.max-u.min:u.min-u.max;var g=l.length;var v,m,y,b,E,S,T;if(c||c===undefined&&h!==undefined)for(v=0;v=0&&T.max>=0?T.max:T.min;if(u.min<0&&y<0||u.max>=0&&y>0)f+=y}}b=a.getPixelForValue(f);E=a.getPixelForValue(f+p);S=E-b;if(d!==undefined&&Math.abs(S)=0&&!s||p<0&&s)E=b-d;else E=b+d}return{size:S,base:b,head:E,center:E+S/2}},calculateBarIndexPixels:function(e,t,i,n){var r=this;var a=n.barThickness==="flex"?At(t,i,n):Mt(t,i,n);var s=r.getStackIndex(e,r.getMeta().stack);var o=a.start+a.chunk*s+a.chunk/2;var l=Math.min(Tt(n.maxBarThickness,Infinity),a.chunk*a.ratio);return{base:o-l/2,head:o+l/2,center:o,size:l}},draw:function(){var e=this;var t=e.chart;var i=e._getValueScale();var n=e.getMeta().data;var r=e.getDataset();var a=n.length;var s=0;R.canvas.clipArea(t.ctx,t.chartArea);for(;s=C?-P:y<-C?P:0;var b=y+h;var E=Math.cos(y);var S=Math.sin(y);var T=Math.cos(b);var w=Math.sin(b);var M=y<=0&&b>=0||b>=P;var A=y<=N&&b>=N||b>=P+N;var L=y===-C||b>=C;var I=y<=-N&&b>=-N||b>=C+N;var D=L?-1:Math.min(E,E*c,T,T*c);var k=I?-1:Math.min(S,S*c,w,w*c);var _=M?1:Math.max(E,E*c,T,T*c);var x=A?1:Math.max(S,S*c,w,w*c);a=(_-D)/2;s=(x-k)/2;o=-(_+D)/2;l=-(x+k)/2}for(v=0,m=d.length;v0&&!isNaN(e))return P*(Math.abs(e)/t);return 0},getMaxBorderWidth:function(e){var t=this;var i=0;var n=t.chart;var r,a,s,o,l,u,d,c;if(!e)for(r=0,a=n.data.datasets.length;ri?d:i;i=c>i?c:i}}return i},setHoverStyle:function(e){var t=e._model;var i=e._options;var n=R.getHoverColor;e.$previousStyle={backgroundColor:t.backgroundColor,borderColor:t.borderColor,borderWidth:t.borderWidth};t.backgroundColor=_t(i.hoverBackgroundColor,n(i.backgroundColor));t.borderColor=_t(i.hoverBorderColor,n(i.borderColor));t.borderWidth=_t(i.hoverBorderWidth,i.borderWidth)},_getRingWeightOffset:function(e){var t=0;for(var i=0;i0&&Pt(a[s-1]._model,r)){l.controlPointPreviousX=d(l.controlPointPreviousX,r.left,r.right);l.controlPointPreviousY=d(l.controlPointPreviousY,r.top,r.bottom)}if(s0)a=e.getDatasetMeta(a[0]._datasetIndex).data;return a},"x-axis":function(e,t){return Qt(e,t,{intersect:false})},point:function(e,t){var i=o(t,e);return Ht(e,i)},nearest:function(e,t,i){var n=o(t,e);i.axis=i.axis||"xy";var r=Kt(i.axis);return Wt(e,n,i.intersect,r)},x:function(e,t,i){var n=o(t,e);var r=[];var a=false;Yt(e,function(e){if(e.inXRange(n.x))r.push(e);if(e.inRange(n.x,n.y))a=true});if(i.intersect&&!a)r=[];return r},y:function(e,t,i){var n=o(t,e);var r=[];var a=false;Yt(e,function(e){if(e.inYRange(n.y))r.push(e);if(e.inRange(n.x,n.y))a=true});if(i.intersect&&!a)r=[];return r}}},Xt=R.extend;function Jt(e,t){return R.where(e,function(e){return e.pos===t})}function $t(e,r){return e.sort(function(e,t){var i=r?t:e;var n=r?e:t;return i.weight===n.weight?i.index-n.index:i.weight-n.weight})}function ei(e){var t=[];var i,n,r;for(i=0,n=(e||[]).length;i div {\r\n\tposition: absolute;\r\n\twidth: 1000000px;\r\n\theight: 1000000px;\r\n\tleft: 0;\r\n\ttop: 0;\r\n}\r\n\r\n.chartjs-size-monitor-shrink > div {\r\n\tposition: absolute;\r\n\twidth: 200%;\r\n\theight: 200%;\r\n\tleft: 0;\r\n\ttop: 0;\r\n}\r\n"})),E="$chartjs",fi="chartjs-",pi=fi+"size-monitor",gi=fi+"render-monitor",vi=fi+"render-animation",mi=["animationstart","webkitAnimationStart"],yi={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"};function bi(e,t){var i=R.getStyle(e,t);var n=i&&i.match(/^(\d+)(\.\d+)?px$/);return n?Number(n[1]):undefined}function Ei(e,t){var i=e.style;var n=e.getAttribute("height");var r=e.getAttribute("width");e[E]={initial:{height:n,width:r,style:{display:i.display,height:i.height,width:i.width}}};i.display=i.display||"block";if(r===null||r===""){var a=bi(e,"width");if(a!==undefined)e.width=a}if(n===null||n==="")if(e.style.height==="")e.height=e.width/(t.options.aspectRatio||2);else{var s=bi(e,"height");if(a!==undefined)e.height=s}return e}var Si,Ti=function(){var e=false;try{var t=Object.defineProperty({},"passive",{get:function(){e=true}});window.addEventListener("e",null,t)}catch(e){}return e}()?{passive:true}:false;function wi(e,t,i){e.addEventListener(t,i,Ti)}function Mi(e,t,i){e.removeEventListener(t,i,Ti)}function Ai(e,t,i,n,r){return{type:e,chart:t,native:r||null,x:i!==undefined?i:null,y:n!==undefined?n:null}}function Li(e,t){var i=yi[e.type]||e.type;var n=R.getRelativePosition(e,t);return Ai(i,t,n.x,n.y,e)}function Ii(e,t){var i=false;var n=[];return function(){n=Array.prototype.slice.call(arguments);t=t||this;if(!i){i=true;R.requestAnimFrame.call(window,function(){i=false;e.apply(t,n)})}}}function Di(e){var t=document.createElement("div");t.className=e||"";return t}function ki(e){var t=1e6;var i=Di(pi);var n=Di(pi+"-expand");var r=Di(pi+"-shrink");n.appendChild(Di());r.appendChild(Di());i.appendChild(n);i.appendChild(r);i._reset=function(){n.scrollLeft=t;n.scrollTop=t;r.scrollLeft=t;r.scrollTop=t};var a=function(){i._reset();e()};wi(n,"scroll",a.bind(n,"expand"));wi(r,"scroll",a.bind(r,"shrink"));return i}function _i(t,i){var e=t[E]||(t[E]={});var n=e.renderProxy=function(e){if(e.animationName===vi)i()};R.each(mi,function(e){wi(t,e,n)});e.reflow=!!t.offsetParent;t.classList.add(gi)}function xi(t){var e=t[E]||{};var i=e.renderProxy;if(i){R.each(mi,function(e){Mi(t,e,i)});delete e.renderProxy}t.classList.remove(gi)}function Ci(i,n,r){var a=i[E]||(i[E]={});var t=a.resizer=ki(Ii(function(){if(a.resizer){var e=r.options.maintainAspectRatio&&i.parentNode;var t=e?e.clientWidth:0;n(Ai("resize",r));if(e&&e.clientWidth0){var a=e[0];if(a.label)i=a.label;else if(a.xLabel)i=a.xLabel;else if(r>0&&a.index-1)return e.split("\n");return e}function Zi(e){var t=e._xScale;var i=e._yScale||e._scale;var n=e._index;var r=e._datasetIndex;var a=e._chart.getDatasetMeta(r).controller;var s=a._getIndexScale();var o=a._getValueScale();return{xLabel:t?t.getLabelForIndex(n,r):"",yLabel:i?i.getLabelForIndex(n,r):"",label:s?""+s.getLabelForIndex(n,r):"",value:o?""+o.getLabelForIndex(n,r):"",index:n,datasetIndex:r,x:e._model.x,y:e._model.y}}function ji(e){var t=L.global;return{xPadding:e.xPadding,yPadding:e.yPadding,xAlign:e.xAlign,yAlign:e.yAlign,rtl:e.rtl,textDirection:e.textDirection,bodyFontColor:e.bodyFontColor,_bodyFontFamily:a(e.bodyFontFamily,t.defaultFontFamily),_bodyFontStyle:a(e.bodyFontStyle,t.defaultFontStyle),_bodyAlign:e.bodyAlign,bodyFontSize:a(e.bodyFontSize,t.defaultFontSize),bodySpacing:e.bodySpacing,titleFontColor:e.titleFontColor,_titleFontFamily:a(e.titleFontFamily,t.defaultFontFamily),_titleFontStyle:a(e.titleFontStyle,t.defaultFontStyle),titleFontSize:a(e.titleFontSize,t.defaultFontSize),_titleAlign:e.titleAlign,titleSpacing:e.titleSpacing,titleMarginBottom:e.titleMarginBottom,footerFontColor:e.footerFontColor,_footerFontFamily:a(e.footerFontFamily,t.defaultFontFamily),_footerFontStyle:a(e.footerFontStyle,t.defaultFontStyle),footerFontSize:a(e.footerFontSize,t.defaultFontSize),_footerAlign:e.footerAlign,footerSpacing:e.footerSpacing,footerMarginTop:e.footerMarginTop,caretSize:e.caretSize,cornerRadius:e.cornerRadius,backgroundColor:e.backgroundColor,opacity:0,legendColorBackground:e.multiKeyBackground,displayColors:e.displayColors,borderColor:e.borderColor,borderWidth:e.borderWidth}}function Gi(e,t){var i=e._chart.ctx;var n=t.yPadding*2;var r=0;var a=t.body;var s=a.reduce(function(e,t){return e+t.before.length+t.lines.length+t.after.length},0);s+=t.beforeBody.length+t.afterBody.length;var o=t.title.length;var l=t.footer.length;var u=t.titleFontSize;var d=t.bodyFontSize;var c=t.footerFontSize;n+=o*u;n+=o?(o-1)*t.titleSpacing:0;n+=o?t.titleMarginBottom:0;n+=s*d;n+=s?(s-1)*t.bodySpacing:0;n+=l?t.footerMarginTop:0;n+=l*c;n+=l?(l-1)*t.footerSpacing:0;var h=0;var f=function(e){r=Math.max(r,i.measureText(e).width+h)};i.font=R.fontString(u,t._titleFontStyle,t._titleFontFamily);R.each(t.title,f);i.font=R.fontString(d,t._bodyFontStyle,t._bodyFontFamily);R.each(t.beforeBody.concat(t.afterBody),f);h=t.displayColors?d+2:0;R.each(a,function(e){R.each(e.before,f);R.each(e.lines,f);R.each(e.after,f)});h=0;i.font=R.fontString(c,t._footerFontStyle,t._footerFontFamily);R.each(t.footer,f);r+=2*t.xPadding;return{width:r,height:n}}function Vi(e,t){var i=e._model;var n=e._chart;var r=e._chart.chartArea;var a="center";var s="center";if(i.yn.height-t.height)s="bottom";var o,l;var u,d;var c;var h=(r.left+r.right)/2;var f=(r.top+r.bottom)/2;if(s==="center"){o=function(e){return e<=h};l=function(e){return e>h}}else{o=function(e){return e<=t.width/2};l=function(e){return e>=n.width-t.width/2}}u=function(e){return e+t.width+i.caretSize+i.caretPadding>n.width};d=function(e){return e-t.width-i.caretSize-i.caretPadding<0};c=function(e){return e<=f?"top":"bottom"};if(o(i.x)){a="left";if(u(i.x)){a="center";s=c(i.y)}}else if(l(i.x)){a="right";if(d(i.x)){a="center";s=c(i.y)}}var p=e._options;return{xAlign:p.xAlign?p.xAlign:a,yAlign:p.yAlign?p.yAlign:s}}function Yi(e,t,i,n){var r=e.x;var a=e.y;var s=e.caretSize;var o=e.caretPadding;var l=e.cornerRadius;var u=i.xAlign;var d=i.yAlign;var c=s+o;var h=l+o;if(u==="right")r-=t.width;else if(u==="center"){r-=t.width/2;if(r+t.width>n.width)r=n.width-t.width;if(r<0)r=0}if(d==="top")a+=c;else if(d==="bottom")a-=t.height+c;else a-=t.height/2;if(d==="center"){if(u==="left")r+=c;else if(u==="right")r-=c}else if(u==="left")r-=h;else if(u==="right")r+=h;return{x:r,y:a}}function Hi(e,t){return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-e.xPadding:e.x+e.xPadding}function Wi(e){return T([],w(e))}var Ki,Qi,qi=e.extend({initialize:function(){this._model=ji(this._options);this._lastActive=[]},getTitle:function(){var e=this;var t=e._options;var i=t.callbacks;var n=i.beforeTitle.apply(e,arguments);var r=i.title.apply(e,arguments);var a=i.afterTitle.apply(e,arguments);var s=[];s=T(s,w(n));s=T(s,w(r));s=T(s,w(a));return s},getBeforeBody:function(){return Wi(this._options.callbacks.beforeBody.apply(this,arguments))},getBody:function(e,i){var n=this;var r=n._options.callbacks;var a=[];R.each(e,function(e){var t={before:[],lines:[],after:[]};T(t.before,w(r.beforeLabel.call(n,e,i)));T(t.lines,r.label.call(n,e,i));T(t.after,w(r.afterLabel.call(n,e,i)));a.push(t)});return a},getAfterBody:function(){return Wi(this._options.callbacks.afterBody.apply(this,arguments))},getFooter:function(){var e=this;var t=e._options.callbacks;var i=t.beforeFooter.apply(e,arguments);var n=t.footer.apply(e,arguments);var r=t.afterFooter.apply(e,arguments);var a=[];a=T(a,w(i));a=T(a,w(n));a=T(a,w(r));return a},update:function(e){var t=this;var i=t._options;var n=t._model;var r=t._model=ji(i);var a=t._active;var s=t._data;var o={xAlign:n.xAlign,yAlign:n.yAlign};var l={x:n.x,y:n.y};var u={width:n.width,height:n.height};var d={x:n.caretX,y:n.caretY};var c,h;if(a.length){r.opacity=1;var f=[];var p=[];d=zi[i.position].call(t,a,t._eventPosition);var g=[];for(c=0,h=a.length;c0)i.stroke()},draw:function(){var e=this._chart.ctx;var t=this._view;if(t.opacity===0)return;var i={width:t.width,height:t.height};var n={x:t.x,y:t.y};var r=Math.abs(t.opacity<.001)?0:t.opacity;var a=t.title.length||t.beforeBody.length||t.body.length||t.afterBody.length||t.footer.length;if(this._options.enabled&&a){e.save();e.globalAlpha=r;this.drawBackground(n,t,e,i);n.y+=t.yPadding;R.rtl.overrideTextDirection(e,t.textDirection);this.drawTitle(n,t,e);this.drawBody(n,t,e);this.drawFooter(n,t,e);R.rtl.restoreTextDirection(e,t.textDirection);e.restore()}},handleEvent:function(e){var t=this;var i=t._options;var n=false;t._lastActive=t._lastActive||[];if(e.type==="mouseout")t._active=[];else{t._active=t._chart.getElementsAtEventForMode(e,i.mode,i);if(i.reverse)t._active.reverse()}n=!R.arrayEquals(t._active,t._lastActive);if(n){t._lastActive=t._active;if(i.enabled||i.custom){t._eventPosition={x:e.x,y:e.y};t.update(true);t.pivot()}}return n}}),Xi=(qi.positioners=zi,R.valueOrDefault);function Ji(){return R.merge(Object.create(null),[].slice.call(arguments),{merger:function(e,t,i,n){if(e==="xAxes"||e==="yAxes"){var r=i[e].length;var a,s,o;if(!t[e])t[e]=[];for(a=0;a=t[e].length)t[e].push({});if(!t[e][a].type||o.type&&o.type!==t[e][a].type)R.merge(t[e][a],[Fi.getScaleDefaults(s),o]);else R.merge(t[e][a],o)}}else R._merger(e,t,i,n)}})}function $i(){return R.merge(Object.create(null),[].slice.call(arguments),{merger:function(e,t,i,n){var r=t[e]||Object.create(null);var a=i[e];if(e==="scales")t[e]=Ji(r,a);else if(e==="scale")t[e]=R.merge(r,[Fi.getScaleDefaults(a.type),a]);else R._merger(e,t,i,n)}})}function en(e){e=e||Object.create(null);var t=e.data=e.data||{};t.datasets=t.datasets||[];t.labels=t.labels||[];e.options=$i(L.global,L[e.type],e.options||{});return e}function tn(t){var e=t.options;R.each(t.scales,function(e){r.removeBox(t,e)});e=$i(L.global,L[t.config.type],e);t.options=t.config.options=e;t.ensureScalesHaveIDs();t.buildOrUpdateScales();t.tooltip._options=e.tooltips;t.tooltip.initialize()}function nn(e,t,i){var n;var r=function(e){return e.id===n};do{n=t+i++}while(R.findIndex(e,r)>=0);return n}function rn(e){return e==="top"||e==="bottom"}function an(i,n){return function(e,t){return e[i]===t[i]?e[n]-t[n]:e[i]-t[i]}}L._set("global",{elements:{},events:["mousemove","mouseout","click","touchstart","touchmove"],hover:{onHover:null,mode:"nearest",intersect:true,animationDuration:400},onClick:null,maintainAspectRatio:true,responsive:true,responsiveAnimationDuration:0});var sn=function(e,t){this.construct(e,t);return this},M=(R.extend(sn.prototype,{construct:function(e,t){var i=this;t=en(t);var n=Bi.acquireContext(e,t);var r=n&&n.canvas;var a=r&&r.height;var s=r&&r.width;i.id=R.uid();i.ctx=n;i.canvas=r;i.config=t;i.width=s;i.height=a;i.aspectRatio=a?s/a:null;i.options=t.options;i._bufferedRender=false;i._layers=[];i.chart=i;i.controller=i;sn.instances[i.id]=i;Object.defineProperty(i,"data",{get:function(){return i.config.data},set:function(e){i.config.data=e}});if(!n||!r){console.error("Failed to create chart: can't acquire context from the given item");return}i.initialize();i.update()},initialize:function(){var e=this;S.notify(e,"beforeInit");R.retinaScale(e,e.options.devicePixelRatio);e.bindEvents();if(e.options.responsive)e.resize(true);e.initToolTip();S.notify(e,"afterInit");return e},clear:function(){R.canvas.clear(this);return this},stop:function(){Ve.cancelAnimation(this);return this},resize:function(e){var t=this;var i=t.options;var n=t.canvas;var r=i.maintainAspectRatio&&t.aspectRatio||null;var a=Math.max(0,Math.floor(R.getMaximumWidth(n)));var s=Math.max(0,Math.floor(r?a/r:R.getMaximumHeight(n)));if(t.width===a&&t.height===s)return;n.width=t.width=a;n.height=t.height=s;n.style.width=a+"px";n.style.height=s+"px";R.retinaScale(t,i.devicePixelRatio);if(!e){var o={width:a,height:s};S.notify(t,"resize",[o]);if(i.onResize)i.onResize(t,o);t.stop();t.update({duration:i.responsiveAnimationDuration})}},ensureScalesHaveIDs:function(){var e=this.options;var i=e.scales||{};var t=e.scale;R.each(i.xAxes,function(e,t){if(!e.id)e.id=nn(i.xAxes,"x-axis-",t)});R.each(i.yAxes,function(e,t){if(!e.id)e.id=nn(i.yAxes,"y-axis-",t)});if(t)t.id=t.id||"scale"},buildOrUpdateScales:function(){var s=this;var e=s.options;var o=s.scales||{};var t=[];var l=Object.keys(o).reduce(function(e,t){e[t]=false;return e},{});if(e.scales)t=t.concat((e.scales.xAxes||[]).map(function(e){return{options:e,dtype:"category",dposition:"bottom"}}),(e.scales.yAxes||[]).map(function(e){return{options:e,dtype:"linear",dposition:"left"}}));if(e.scale)t.push({options:e.scale,dtype:"radialLinear",isDefault:true,dposition:"chartArea"});R.each(t,function(e){var t=e.options;var i=t.id;var n=Xi(t.type,e.dtype);if(rn(t.position)!==rn(e.dposition))t.position=e.dposition;l[i]=true;var r=null;if(i in o&&o[i].type===n){r=o[i];r.options=t;r.ctx=s.ctx;r.chart=s}else{var a=Fi.getScaleConstructor(n);if(!a)return;r=new a({id:i,type:n,options:t,ctx:s.ctx,chart:s});o[r.id]=r}r.mergeTicksOptions();if(e.isDefault)s.scale=r});R.each(l,function(e,t){if(!e)delete o[t]});s.scales=o;Fi.addScalesToLayout(this)},buildOrUpdateControllers:function(){var e=this;var t=[];var i=e.data.datasets;var n,r;for(n=0,r=i.length;n=0;--n)t.drawDataset(i[n],e);S.notify(t,"afterDatasetsDraw",[e])},drawDataset:function(e,t){var i=this;var n={meta:e,index:e.index,easingValue:t};if(S.notify(i,"beforeDatasetDraw",[n])===false)return;e.controller.draw(t);S.notify(i,"afterDatasetDraw",[n])},_drawTooltip:function(e){var t=this;var i=t.tooltip;var n={tooltip:i,easingValue:e};if(S.notify(t,"beforeTooltipDraw",[n])===false)return;i.draw();S.notify(t,"afterTooltipDraw",[n])},getElementAtEvent:function(e){return qt.modes.single(this,e)},getElementsAtEvent:function(e){return qt.modes.label(this,e,{intersect:true})},getElementsAtXAxis:function(e){return qt.modes["x-axis"](this,e,{intersect:true})},getElementsAtEventForMode:function(e,t,i){var n=qt.modes[t];if(typeof n==="function")return n(this,e,i);return[]},getDatasetAtEvent:function(e){return qt.modes.dataset(this,e,{intersect:true})},getDatasetMeta:function(e){var t=this;var i=t.data.datasets[e];if(!i._meta)i._meta={};var n=i._meta[t.id];if(!n)n=i._meta[t.id]={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:i.order||0,index:e};return n},getVisibleDatasetCount:function(){var e=0;for(var t=0,i=this.data.datasets.length;t=0;n--){var r=e[n];if(t(r))return r}};R.isNumber=function(e){return!isNaN(parseFloat(e))&&isFinite(e)};R.almostEquals=function(e,t,i){return Math.abs(e-t)=e};R.max=function(e){return e.reduce(function(e,t){if(!isNaN(t))return Math.max(e,t);return e},Number.NEGATIVE_INFINITY)};R.min=function(e){return e.reduce(function(e,t){if(!isNaN(t))return Math.min(e,t);return e},Number.POSITIVE_INFINITY)};R.sign=Math.sign?function(e){return Math.sign(e)}:function(e){e=+e;if(e===0||isNaN(e))return e;return e>0?1:-1};R.toRadians=function(e){return e*(Math.PI/180)};R.toDegrees=function(e){return e*(180/Math.PI)};R._decimalPlaces=function(e){if(!R.isFinite(e))return;var t=1;var i=0;while(Math.round(e*t)/t!==e){t*=10;i++}return i};R.getAngleFromPoint=function(e,t){var i=t.x-e.x;var n=t.y-e.y;var r=Math.sqrt(i*i+n*n);var a=Math.atan2(n,i);if(a<-.5*Math.PI)a+=2*Math.PI;return{angle:a,distance:r}};R.distanceBetweenPoints=function(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))};R.aliasPixel=function(e){return e%2===0?0:.5};R._alignPixel=function(e,t,i){var n=e.currentDevicePixelRatio;var r=i/2;return Math.round((t-r)*n)/n+r};R.splineCurve=function(e,t,i,n){var r=e.skip?t:e;var a=t;var s=i.skip?t:i;var o=Math.sqrt(Math.pow(a.x-r.x,2)+Math.pow(a.y-r.y,2));var l=Math.sqrt(Math.pow(s.x-a.x,2)+Math.pow(s.y-a.y,2));var u=o/(o+l);var d=l/(o+l);u=isNaN(u)?0:u;d=isNaN(d)?0:d;var c=n*u;var h=n*d;return{previous:{x:a.x-c*(s.x-r.x),y:a.y-c*(s.y-r.y)},next:{x:a.x+h*(s.x-r.x),y:a.y+h*(s.y-r.y)}}};R.EPSILON=Number.EPSILON||1e-14;R.splineCurveMonotone=function(e){var t=(e||[]).map(function(e){return{model:e._model,deltaK:0,mK:0}});var i=t.length;var n,r,a,s;for(n=0;n0?t[n-1]:null;s=n0?t[n-1]:null;s=n=e.length-1?e[0]:e[t+1];return t>=e.length-1?e[e.length-1]:e[t+1]};R.previousItem=function(e,t,i){if(i)return t<=0?e[e.length-1]:e[t-1];return t<=0?e[0]:e[t-1]};R.niceNum=function(e,t){var i=Math.floor(R.log10(e));var n=e/Math.pow(10,i);var r;if(t)if(n<1.5)r=1;else if(n<3)r=2;else if(n<7)r=5;else r=10;else if(n<=1)r=1;else if(n<=2)r=2;else if(n<=5)r=5;else r=10;return r*Math.pow(10,i)};R.requestAnimFrame=function(){if(typeof window==="undefined")return function(e){e()};return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){return window.setTimeout(e,1e3/60)}}();R.getRelativePosition=function(e,t){var i,n;var r=e.originalEvent||e;var a=e.target||e.srcElement;var s=a.getBoundingClientRect();var o=r.touches;if(o&&o.length>0){i=o[0].clientX;n=o[0].clientY}else{i=r.clientX;n=r.clientY}var l=parseFloat(R.getStyle(a,"padding-left"));var u=parseFloat(R.getStyle(a,"padding-top"));var d=parseFloat(R.getStyle(a,"padding-right"));var c=parseFloat(R.getStyle(a,"padding-bottom"));var h=s.right-s.left-l-d;var f=s.bottom-s.top-u-c;i=Math.round((i-s.left-l)/h*a.width/t.currentDevicePixelRatio);n=Math.round((n-s.top-u)/f*a.height/t.currentDevicePixelRatio);return{x:i,y:n}};function d(e,t,i){var n;if(typeof e==="string"){n=parseInt(e,10);if(e.indexOf("%")!==-1)n=n/100*t.parentNode[i]}else n=e;return n}function c(e){return e!==undefined&&e!==null&&e!=="none"}function t(e,t,i){var n=document.defaultView;var r=R._getParentNode(e);var a=n.getComputedStyle(e)[t];var s=n.getComputedStyle(r)[t];var o=c(a);var l=c(s);var u=Number.POSITIVE_INFINITY;if(o||l)return Math.min(o?d(a,e,i):u,l?d(s,r,i):u);return"none"}R.getConstraintWidth=function(e){return t(e,"max-width","clientWidth")};R.getConstraintHeight=function(e){return t(e,"max-height","clientHeight")};R._calculatePadding=function(e,t,i){t=R.getStyle(e,t);return t.indexOf("%")>-1?i*parseInt(t,10)/100:parseInt(t,10)};R._getParentNode=function(e){var t=e.parentNode;if(t&&t.toString()==="[object ShadowRoot]")t=t.host;return t};R.getMaximumWidth=function(e){var t=R._getParentNode(e);if(!t)return e.clientWidth;var i=t.clientWidth;var n=R._calculatePadding(t,"padding-left",i);var r=R._calculatePadding(t,"padding-right",i);var a=i-n-r;var s=R.getConstraintWidth(e);return isNaN(s)?a:Math.min(a,s)};R.getMaximumHeight=function(e){var t=R._getParentNode(e);if(!t)return e.clientHeight;var i=t.clientHeight;var n=R._calculatePadding(t,"padding-top",i);var r=R._calculatePadding(t,"padding-bottom",i);var a=i-n-r;var s=R.getConstraintHeight(e);return isNaN(s)?a:Math.min(a,s)};R.getStyle=function(e,t){return e.currentStyle?e.currentStyle[t]:document.defaultView.getComputedStyle(e,null).getPropertyValue(t)};R.retinaScale=function(e,t){var i=e.currentDevicePixelRatio=t||typeof window!=="undefined"&&window.devicePixelRatio||1;if(i===1)return;var n=e.canvas;var r=e.height;var a=e.width;n.height=r*i;n.width=a*i;e.ctx.scale(i,i);if(!n.style.height&&!n.style.width){n.style.height=r+"px";n.style.width=a+"px"}};R.fontString=function(e,t,i){return t+" "+e+"px "+i};R.longestText=function(e,t,i,n){n=n||{};var r=n.data=n.data||{};var a=n.garbageCollect=n.garbageCollect||[];if(n.font!==t){r=n.data={};a=n.garbageCollect=[];n.font=t}e.font=t;var s=0;var o=i.length;var l,u,d,c,h;for(l=0;li.length){for(l=0;ln)n=a;return n};R.numberOfLabelLines=function(e){var t=1;R.each(e,function(e){if(R.isArray(e))if(e.length>t)t=e.length});return t};R.color=!fe?function(e){console.error("Color.js not found!");return e}:function(e){if(e instanceof CanvasGradient)e=L.global.defaultColor;return fe(e)};R.getHoverColor=function(e){return e instanceof CanvasPattern||e instanceof CanvasGradient?e:R.color(e).saturate(.5).darken(.1).rgbString()}});function ln(){throw new Error("This method is not implemented: either no adapter can "+"be found or an incomplete integration was provided.")}function un(e){this.options=e||{}}R.extend(un.prototype,{formats:ln,parse:ln,format:ln,add:ln,diff:ln,startOf:ln,endOf:ln,_create:function(e){return e}}),un.override=function(e){R.extend(un.prototype,e)};var dn,cn={_date:un},hn={formatters:{values:function(e){return R.isArray(e)?e:""+e},linear:function(e,t,i){var n=i.length>3?i[2]-i[1]:i[1]-i[0];if(Math.abs(n)>1)if(e!==Math.floor(e))n=e-Math.floor(e);var r=R.log10(Math.abs(n));var a="";if(e!==0){var s=Math.max(Math.abs(i[0]),Math.abs(i[i.length-1]));if(s<1e-4){var o=R.log10(Math.abs(e));var l=Math.floor(o)-Math.floor(r);l=Math.max(Math.min(l,20),0);a=e.toExponential(l)}else{var u=-1*Math.floor(r);u=Math.max(Math.min(u,20),0);a=e.toFixed(u)}}else a="0";return a},logarithmic:function(e,t,i){var n=e/Math.pow(10,Math.floor(R.log10(e)));if(e===0)return"0";else if(n===1||n===2||n===5||t===0||t===i.length-1)return e.toExponential();return""}}},fn=R.isArray,pn=R.isNullOrUndef,gn=R.valueOrDefault,vn=R.valueAtIndexOrDefault;function mn(e,t){var i=[];var n=e.length/t;var r=0;var a=e.length;for(;ro+l)return}return a}function bn(e,r){R.each(e,function(e){var t=e.gc;var i=t.length/2;var n;if(i>r){for(n=0;na)return o}return Math.max(a,1)}function Dn(e){var t=[];var i,n;for(i=0,n=e.length;i=a||n<=1||!e.isHorizontal()){e.labelRotation=r;return}o=e._getLabelSizes();l=o.widest.width;u=o.highest.height-o.highest.offset;d=Math.min(e.maxWidth,e.chart.width-l);c=t.offset?e.maxWidth/n:d/(n-1);if(l+6>c){c=d/(n-(t.offset?.5:1));h=e.maxHeight-Sn(t.gridLines)-i.padding-Tn(t.scaleLabel);f=Math.sqrt(l*l+u*u);s=R.toDegrees(Math.min(Math.asin(Math.min((o.highest.height+6)/c,1)),Math.asin(Math.min(h/f,1))-Math.asin(u/f)));s=Math.max(r,Math.min(a,s))}e.labelRotation=s},afterCalculateTickRotation:function(){R.callback(this.options.afterCalculateTickRotation,[this])},beforeFit:function(){R.callback(this.options.beforeFit,[this])},fit:function(){var e=this;var t=e.minSize={width:0,height:0};var i=e.chart;var n=e.options;var r=n.ticks;var a=n.scaleLabel;var s=n.gridLines;var o=e._isVisible();var l=n.position==="bottom";var u=e.isHorizontal();if(u)t.width=e.maxWidth;else if(o)t.width=Sn(s)+Tn(a);if(!u)t.height=e.maxHeight;else if(o)t.height=Sn(s)+Tn(a);if(r.display&&o){var d=Mn(r);var c=e._getLabelSizes();var h=c.first;var f=c.last;var p=c.widest;var g=c.highest;var v=d.minor.lineHeight*.4;var m=r.padding;if(u){var y=e.labelRotation!==0;var b=R.toRadians(e.labelRotation);var E=Math.cos(b);var S=Math.sin(b);var T=S*p.width+E*(g.height-(y?g.offset:0))+(y?0:v);t.height=Math.min(e.maxHeight,t.height+T+m);var w=e.getPixelForTick(0)-e.left;var M=e.right-e.getPixelForTick(e.getTicks().length-1);var A,L;if(y){A=l?E*h.width+S*h.offset:S*(h.height-h.offset);L=l?S*(f.height-f.offset):E*f.width+S*f.offset}else{A=h.width/2;L=f.width/2}e.paddingLeft=Math.max((A-w)*e.width/(e.width-w),0)+3;e.paddingRight=Math.max((L-M)*e.width/(e.width-M),0)+3}else{var I=r.mirror?0:p.width+m+v;t.width=Math.min(e.maxWidth,t.width+I);e.paddingTop=h.height/2;e.paddingBottom=f.height/2}}e.handleMargins();if(u){e.width=e._length=i.width-e.margins.left-e.margins.right;e.height=t.height}else{e.width=t.width;e.height=e._length=i.height-e.margins.top-e.margins.bottom}},handleMargins:function(){var e=this;if(e.margins){e.margins.left=Math.max(e.paddingLeft,e.margins.left);e.margins.top=Math.max(e.paddingTop,e.margins.top);e.margins.right=Math.max(e.paddingRight,e.margins.right);e.margins.bottom=Math.max(e.paddingBottom,e.margins.bottom)}},afterFit:function(){R.callback(this.options.afterFit,[this])},isHorizontal:function(){var e=this.options.position;return e==="top"||e==="bottom"},isFullWidth:function(){return this.options.fullWidth},getRightValue:function(e){if(pn(e))return NaN;if((typeof e==="number"||e instanceof Number)&&!isFinite(e))return NaN;if(e)if(this.isHorizontal()){if(e.x!==undefined)return this.getRightValue(e.x)}else if(e.y!==undefined)return this.getRightValue(e.y);return e},_convertTicksToLabels:function(e){var t=this;var i,n,r;t.ticks=e.map(function(e){return e.value});t.beforeTickToLabelConversion();i=t.convertTicksToLabels(e)||t.ticks;t.afterTickToLabelConversion();for(n=0,r=e.length;nn-1?null:t.getPixelForDecimal(e*r+(i?r/2:0))},getPixelForDecimal:function(e){var t=this;if(t._reversePixels)e=1-e;return t._startPixel+e*t._length},getDecimalForPixel:function(e){var t=(e-this._startPixel)/this._length;return this._reversePixels?1-t:t},getBasePixel:function(){return this.getPixelForValue(this.getBaseValue())},getBaseValue:function(){var e=this;var t=e.min;var i=e.max;return e.beginAtZero?0:t<0&&i<0?i:t>0&&i>0?t:0},_autoSkip:function(e){var t=this;var i=t.options.ticks;var n=t._length;var r=i.maxTicksLimit||n/t._tickSize()+1;var a=i.major.enabled?Dn(e):[];var s=a.length;var o=a[0];var l=a[s-1];var u,d,c,h;if(s>r){kn(e,a,s/r);return An(e)}c=In(a,e,n,r);if(s>0){for(u=0,d=s-1;u1?(l-o)/(s-1):null;_n(e,c,R.isNullOrUndef(h)?0:o-h,o);_n(e,c,l,R.isNullOrUndef(h)?e.length:l+h);return An(e)}_n(e,c);return An(e)},_tickSize:function(){var e=this;var t=e.options.ticks;var i=R.toRadians(e.labelRotation);var n=Math.abs(Math.cos(i));var r=Math.abs(Math.sin(i));var a=e._getLabelSizes();var s=t.autoSkipPadding||0;var o=a?a.widest.width+s:0;var l=a?a.highest.height+s:0;return e.isHorizontal()?l*n>o*r?o/n:l/r:l*r=0)a=o}if(r!==undefined){o=t.indexOf(r);if(o>=0)s=o}e.minIndex=a;e.maxIndex=s;e.min=t[a];e.max=t[s]},buildTicks:function(){var e=this;var t=e._getLabels();var i=e.minIndex;var n=e.maxIndex;e.ticks=i===0&&n===t.length-1?t:t.slice(i,n+1)},getLabelForIndex:function(e,t){var i=this;var n=i.chart;if(n.getDatasetMeta(t).controller._getValueScaleId()===i.id)return i.getRightValue(n.data.datasets[t].data[e]);return i._getLabels()[e]},_configure:function(){var e=this;var t=e.options.offset;var i=e.ticks;A.prototype._configure.call(e);if(!e.isHorizontal())e._reversePixels=!e._reversePixels;if(!i)return;e._startValue=e.minIndex-(t?.5:0);e._valueRange=Math.max(i.length-(t?0:1),1)},getPixelForValue:function(e,t,i){var n=this;var r,a,s;if(!Cn(t)&&!Cn(i))e=n.chart.data.datasets[i].data[t];if(!Cn(e))r=n.isHorizontal()?e.x:e.y;if(r!==undefined||e!==undefined&&isNaN(t)){a=n._getLabels();e=R.valueOrDefault(r,e);s=a.indexOf(e);t=s!==-1?s:t;if(isNaN(t))t=e}return n.getPixelForDecimal((t-n._startValue)/n._valueRange)},getPixelForTick:function(e){var t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e],e+this.minIndex)},getValueForPixel:function(e){var t=this;var i=Math.round(t._startValue+t.getDecimalForPixel(e)*t._valueRange);return Math.min(Math.max(i,0),t.ticks.length-1)},getBasePixel:function(){return this.bottom}}),Nn,On=(Pn._defaults=Rn,R.noop),Bn=R.isNullOrUndef;function Fn(e,t){var i=[];var n=1e-14;var r=e.stepSize;var a=r||1;var s=e.maxTicks-1;var o=e.min;var l=e.max;var u=e.precision;var d=t.min;var c=t.max;var h=R.niceNum((c-d)/s/a)*a;var f,p,g,v;if(hs)h=R.niceNum(v*h/s/a)*a;if(r||Bn(u))f=Math.pow(10,R._decimalPlaces(h));else{f=Math.pow(10,u);h=Math.ceil(h*f)/f}p=Math.floor(d/h)*h;g=Math.ceil(c/h)*h;if(r){if(!Bn(o)&&R.almostWhole(o/h,h/1e3))p=o;if(!Bn(l)&&R.almostWhole(l/h,h/1e3))g=l}v=(g-p)/h;if(R.almostEquals(v,Math.round(v),h/1e3))v=Math.round(v);else v=Math.ceil(v);p=Math.round(p*f)/f;g=Math.round(g*f)/f;i.push(Bn(o)?p:o);for(var m=1;m0&&r>0)e.min=0}var a=i.min!==undefined||i.suggestedMin!==undefined;var s=i.max!==undefined||i.suggestedMax!==undefined;if(i.min!==undefined)e.min=i.min;else if(i.suggestedMin!==undefined)if(e.min===null)e.min=i.suggestedMin;else e.min=Math.min(e.min,i.suggestedMin);if(i.max!==undefined)e.max=i.max;else if(i.suggestedMax!==undefined)if(e.max===null)e.max=i.suggestedMax;else e.max=Math.max(e.max,i.suggestedMax);if(a!==s)if(e.min>=e.max)if(a)e.max=e.min+1;else e.min=e.max-1;if(e.min===e.max){e.max++;if(!i.beginAtZero)e.min--}},getTickLimit:function(){var e=this;var t=e.options.ticks;var i=t.stepSize;var n=t.maxTicksLimit;var r;if(i)r=Math.ceil(e.max/i)-Math.floor(e.min/i)+1;else{r=e._computeTickLimit();n=n||11}if(n)r=Math.min(n,r);return r},_computeTickLimit:function(){return Number.POSITIVE_INFINITY},handleDirectionalChanges:On,buildTicks:function(){var e=this;var t=e.options;var i=t.ticks;var n=e.getTickLimit();n=Math.max(2,n);var r={maxTicks:n,min:i.min,max:i.max,precision:i.precision,stepSize:R.valueOrDefault(i.fixedStepSize,i.stepSize)};var a=e.ticks=Fn(r,e);e.handleDirectionalChanges();e.max=R.max(a);e.min=R.min(a);if(i.reverse){a.reverse();e.start=e.max;e.end=e.min}else{e.start=e.min;e.end=e.max}},convertTicksToLabels:function(){var e=this;e.ticksAsNumbers=e.ticks.slice();e.zeroLineIndex=e.ticks.indexOf(0);A.prototype.convertTicksToLabels.call(e)},_configure:function(){var e=this;var t=e.getTicks();var i=e.min;var n=e.max;var r;A.prototype._configure.call(e);if(e.options.offset&&t.length){r=(n-i)/Math.max(t.length-1,1)/2;i-=r;n+=r}e._startValue=i;e._endValue=n;e._valueRange=n-i}}),zn={position:"left",ticks:{callback:hn.formatters.linear}},Zn=0,jn=1;function Gn(e,t,i){var n=[i.type,t===undefined&&i.stack===undefined?i.index:"",i.stack].join(".");if(e[n]===undefined)e[n]={pos:[],neg:[]};return e[n]}function Vn(e,t,i,n){var r=e.options;var a=r.stacked;var s=Gn(t,a,i);var o=s.pos;var l=s.neg;var u=n.length;var d,c;for(d=0;dt.length-1)return null;return this.getPixelForValue(t[e])}}),Wn,Kn=(Hn._defaults=zn,R.valueOrDefault),I=R.math.log10;function Qn(e,t){var i=[];var n=Kn(e.min,Math.pow(10,Math.floor(I(t.min))));var r=Math.floor(I(t.max));var a=Math.ceil(t.max/Math.pow(10,r));var s,o;if(n===0){s=Math.floor(I(t.minNotZero));o=Math.floor(t.minNotZero/Math.pow(10,s));i.push(n);n=o*Math.pow(10,s)}else{s=Math.floor(I(n));o=Math.floor(n/Math.pow(10,s))}var l=s<0?Math.pow(10,Math.abs(s)):1;do{i.push(n);++o;if(o===10){o=1;++s;l=s>=0?1:l}n=Math.round(o*Math.pow(10,s)*l)/l}while(s=0?e:t}var Jn=A.extend({determineDataLimits:function(){var n=this;var e=n.options;var t=n.chart;var i=t.data.datasets;var r=n.isHorizontal();function a(e){return r?e.xAxisID===n.id:e.yAxisID===n.id}var s,o,l,u,d,c;n.min=Number.POSITIVE_INFINITY;n.max=Number.NEGATIVE_INFINITY;n.minNotZero=Number.POSITIVE_INFINITY;var h=e.stacked;if(h===undefined)for(s=0;s0){var t=R.min(e);var i=R.max(e);n.min=Math.min(n.min,t);n.max=Math.max(n.max,i)}})}else for(s=0;s0)e.minNotZero=e.min;else if(e.max<1)e.minNotZero=Math.pow(10,Math.floor(I(e.max)));else e.minNotZero=i},buildTicks:function(){var e=this;var t=e.options.ticks;var i=!e.isHorizontal();var n={min:Xn(t.min),max:Xn(t.max)};var r=e.ticks=Qn(n,e);e.max=R.max(r);e.min=R.min(r);if(t.reverse){i=!i;e.start=e.max;e.end=e.min}else{e.start=e.min;e.end=e.max}if(i)r.reverse()},convertTicksToLabels:function(){this.tickValues=this.ticks.slice();A.prototype.convertTicksToLabels.call(this)},getLabelForIndex:function(e,t){return this._getScaleLabel(this.chart.data.datasets[t].data[e])},getPixelForTick:function(e){var t=this.tickValues;if(e<0||e>t.length-1)return null;return this.getPixelForValue(t[e])},_getFirstTickValue:function(e){var t=Math.floor(I(e));var i=Math.floor(e/Math.pow(10,t));return i*Math.pow(10,t)},_configure:function(){var e=this;var t=e.min;var i=0;A.prototype._configure.call(e);if(t===0){t=e._getFirstTickValue(e.minNotZero);i=Kn(e.options.ticks.fontSize,L.global.defaultFontSize)/e._length}e._startValue=I(t);e._valueOffset=i;e._valueRange=(I(e.max)-I(t))/(1-i)},getPixelForValue:function(e){var t=this;var i=0;e=+t.getRightValue(e);if(e>t.min&&e>0)i=(I(e)-t._startValue)/t._valueRange+t._valueOffset;return t.getPixelForDecimal(i)},getValueForPixel:function(e){var t=this;var i=t.getDecimalForPixel(e);return i===0&&t.min===0?0:Math.pow(10,t._startValue+(i-t._valueOffset)*t._valueRange)}}),$n,er=(Jn._defaults=qn,R.valueOrDefault),tr=R.valueAtIndexOrDefault,ir=R.options.resolve,nr={display:true,animate:true,position:"chartArea",angleLines:{display:true,color:"rgba(0,0,0,0.1)",lineWidth:1,borderDash:[],borderDashOffset:0},gridLines:{circular:false},ticks:{showLabelBackdrop:true,backdropColor:"rgba(255,255,255,0.75)",backdropPaddingY:2,backdropPaddingX:2,callback:hn.formatters.linear},pointLabels:{display:true,fontSize:10,callback:function(e){return e}}};function rr(e){var t=e.ticks;if(t.display&&e.display)return er(t.fontSize,L.global.defaultFontSize)+t.backdropPaddingY*2;return 0}function ar(e,t,i){if(R.isArray(i))return{w:R.longestText(e,e.font,i),h:i.length*t};return{w:e.measureText(i).width,h:t}}function sr(e,t,i,n,r){if(e===n||e===r)return{start:t-i/2,end:t+i/2};else if(er)return{start:t-i,end:t};return{start:t,end:t+i}}function or(e){var t=R.options._parseFont(e.options.pointLabels);var i={l:0,r:e.width,t:0,b:e.height-e.paddingTop};var n={};var r,a,s;e.ctx.font=t.string;e._pointLabelSizes=[];var o=e.chart.data.labels.length;for(r=0;ri.r){i.r=d.end;n.r=l}if(c.starti.b){i.b=c.end;n.b=l}}e.setReductions(e.drawingArea,i,n)}function lr(e){if(e===0||e===180)return"center";else if(e<180)return"left";return"right"}function ur(e,t,i,n){var r=i.y+n/2;var a,s;if(R.isArray(t))for(a=0,s=t.length;a270||e<90)i.y-=t.h}function cr(e){var t=e.ctx;var i=e.options;var n=i.pointLabels;var r=rr(i);var a=e.getDistanceFromCenterForValue(i.ticks.reverse?e.min:e.max);var s=R.options._parseFont(n);t.save();t.font=s.string;t.textBaseline="middle";for(var o=e.chart.data.labels.length-1;o>=0;o--){var l=o===0?r/2:0;var u=e.getPointPosition(o,a+l+5);var d=tr(n.fontColor,o,L.global.defaultFontColor);t.fillStyle=d;var c=e.getIndexAngle(o);var h=R.toDegrees(c);t.textAlign=lr(h);dr(h,e._pointLabelSizes[o],u);ur(t,e.pointLabels[o],u,s.lineHeight)}t.restore()}function hr(e,t,i,n){var r=e.ctx;var a=t.circular;var s=e.chart.data.labels.length;var o=tr(t.color,n-1);var l=tr(t.lineWidth,n-1);var u;if(!a&&!s||!o||!l)return;r.save();r.strokeStyle=o;r.lineWidth=l;if(r.setLineDash){r.setLineDash(t.borderDash||[]);r.lineDashOffset=t.borderDashOffset||0}r.beginPath();if(a)r.arc(e.xCenter,e.yCenter,i,0,Math.PI*2);else{u=e.getPointPosition(0,i);r.moveTo(u.x,u.y);for(var d=1;d0&&n>0?i:0)},_drawGrid:function(){var i=this;var e=i.ctx;var t=i.options;var n=t.gridLines;var r=t.angleLines;var a=er(r.lineWidth,n.lineWidth);var s=er(r.color,n.color);var o,l,u;if(t.pointLabels.display)cr(i);if(n.display)R.each(i.ticks,function(e,t){if(t!==0){l=i.getDistanceFromCenterForValue(i.ticksAsNumbers[t]);hr(i,n,l,t)}});if(r.display&&a&&s){e.save();e.lineWidth=a;e.strokeStyle=s;if(e.setLineDash){e.setLineDash(ir([r.borderDash,n.borderDash,[]]));e.lineDashOffset=ir([r.borderDashOffset,n.borderDashOffset,0])}for(o=i.chart.data.labels.length-1;o>=0;o--){l=i.getDistanceFromCenterForValue(t.ticks.reverse?i.min:i.max);u=i.getPointPosition(o,l);e.beginPath();e.moveTo(i.xCenter,i.yCenter);e.lineTo(u.x,u.y);e.stroke()}e.restore()}},_drawLabels:function(){var i=this;var n=i.ctx;var e=i.options;var r=e.ticks;if(!r.display)return;var t=i.getIndexAngle(0);var a=R.options._parseFont(r);var s=er(r.fontColor,L.global.defaultFontColor);var o,l;n.save();n.font=a.string;n.translate(i.xCenter,i.yCenter);n.rotate(t);n.textAlign="center";n.textBaseline="middle";R.each(i.ticks,function(e,t){if(t===0&&!r.reverse)return;o=i.getDistanceFromCenterForValue(i.ticksAsNumbers[t]);if(r.showLabelBackdrop){l=n.measureText(e).width;n.fillStyle=r.backdropColor;n.fillRect(-l/2-r.backdropPaddingX,-o-a.size/2-r.backdropPaddingY,l+r.backdropPaddingX*2,a.size+r.backdropPaddingY*2)}n.fillStyle=s;n.fillText(e,0,-o)});n.restore()},_drawTitle:R.noop}),gr,vr=(pr._defaults=nr,R._deprecated),mr=R.options.resolve,yr=R.valueOrDefault,br=Number.MIN_SAFE_INTEGER||-9007199254740991,Er=Number.MAX_SAFE_INTEGER||9007199254740991,Sr={millisecond:{common:true,size:1,steps:1e3},second:{common:true,size:1e3,steps:60},minute:{common:true,size:6e4,steps:60},hour:{common:true,size:36e5,steps:24},day:{common:true,size:864e5,steps:30},week:{common:false,size:6048e5,steps:4},month:{common:true,size:2628e6,steps:12},quarter:{common:false,size:7884e6,steps:4},year:{common:true,size:3154e7}},D=Object.keys(Sr);function Tr(e,t){return e-t}function wr(e){var t={};var i=[];var n,r,a;for(n=0,r=e.length;nt&&u=0&&n<=r){a=n+r>>1;s=e[a-1]||null;o=e[a];if(!s)return{lo:null,hi:o};else if(o[t]i)r=a-1;else return{lo:s,hi:o}}return{lo:o,hi:null}}function Dr(e,t,i,n){var r=Ir(e,t,i);var a=!r.lo?e[0]:!r.hi?e[e.length-2]:r.lo;var s=!r.lo?e[1]:!r.hi?e[e.length-1]:r.hi;var o=s[t]-a[t];var l=o?(i-a[t])/o:0;var u=(s[n]-a[n])*l;return a[n]+u}function kr(e,t){var i=e._adapter;var n=e.options.time;var r=n.parser;var a=r||n.format;var s=t;if(typeof r==="function")s=r(s);if(!R.isFinite(s))s=typeof a==="string"?i.parse(s,a):i.parse(s);if(s!==null)return+s;if(!r&&typeof a==="function"){s=a(t);if(!R.isFinite(s))s=i.parse(s)}return s}function _r(e,t){if(R.isNullOrUndef(t))return null;var i=e.options.time;var n=kr(e,e.getRightValue(t));if(n===null)return n;if(i.round)n=+e._adapter.startOf(n,i.round);return n}function xr(e,t,i,n){var r=D.length;var a,s,o;for(a=D.indexOf(e);a=D.indexOf(i);a--){s=D[a];if(Sr[s].common&&e._adapter.diff(r,n,s)>=t-1)return s}return D[i?D.indexOf(i):0]}function Rr(e){for(var t=D.indexOf(e)+1,i=D.length;t1e5*l)throw t+" and "+i+" are too far apart with stepSize of "+l+" "+o;for(h=d;h=0)t[l].major=true}return t}function Br(e,t,i){var n=[];var r={};var a=t.length;var s,o;for(s=0;s1?wr(o).sort(Tr):o.sort(Tr);a=Math.min(a,o[0]);s=Math.max(s,o[o.length-1])}a=_r(e,Mr(n))||a;s=_r(e,Ar(n))||s;a=a===Er?+i.startOf(Date.now(),r):a;s=s===br?+i.endOf(Date.now(),r)+1:s;e.min=Math.min(a,s);e.max=Math.max(a+1,s);e._table=[];e._timestamps={data:o,datasets:l,labels:u}},buildTicks:function(){var e=this;var t=e.min;var i=e.max;var n=e.options;var r=n.ticks;var a=n.time;var s=e._timestamps;var o=[];var l=e.getLabelCapacity(t);var u=r.source;var d=n.distribution;var c,h,f;if(u==="data"||u==="auto"&&d==="series")s=s.data;else if(u==="labels")s=s.labels;else s=Pr(e,t,i,l);if(n.bounds==="ticks"&&s.length){t=s[0];i=s[s.length-1]}t=_r(e,Mr(n))||t;i=_r(e,Ar(n))||i;for(c=0,h=s.length;c=t&&f<=i)o.push(f)}e.min=t;e.max=i;e._unit=a.unit||(r.autoSkip?xr(a.minUnit,e.min,e.max,l):Cr(e,o.length,a.minUnit,e.min,e.max));e._majorUnit=!r.major.enabled||e._unit==="year"?undefined:Rr(e._unit);e._table=Lr(e._timestamps.data,t,i,d);e._offsets=Nr(e._table,o,t,i,n);if(r.reverse)o.reverse();return Br(e,o,e._majorUnit)},getLabelForIndex:function(e,t){var i=this;var n=i._adapter;var r=i.chart.data;var a=i.options.time;var s=r.labels&&e=0&&e0?o:1}}),zr,Zr=(Ur._defaults=Fr,{category:Pn,linear:Hn,logarithmic:Jn,radialLinear:pr,time:Ur}),jr={datetime:"MMM D, YYYY, h:mm:ss a",millisecond:"h:mm:ss.SSS a",second:"h:mm:ss a",minute:"h:mm a",hour:"hA",day:"MMM D",week:"ll",month:"MMM YYYY",quarter:"[Q]Q - YYYY",year:"YYYY"},Gr=(cn._date.override(typeof n==="function"?{_id:"moment",formats:function(){return jr},parse:function(e,t){if(typeof e==="string"&&typeof t==="string")e=n(e,t);else if(!(e instanceof n))e=n(e);return e.isValid()?e.valueOf():null},format:function(e,t){return n(e).format(t)},add:function(e,t,i){return n(e).add(t,i).valueOf()},diff:function(e,t,i){return n(e).diff(n(t),i)},startOf:function(e,t,i){e=n(e);if(t==="isoWeek")return e.isoWeekday(i).valueOf();return e.startOf(t).valueOf()},endOf:function(e,t){return n(e).endOf(t).valueOf()},_create:function(e){return n(e)}}:{}),L._set("global",{plugins:{filler:{propagate:true}}}),{dataset:function(e){var t=e.fill;var i=e.chart;var n=i.getDatasetMeta(t);var r=n&&i.isDatasetVisible(t);var a=r&&n.dataset._children||[];var s=a.length||0;return!s?null:function(e,t){return t=i)return false;return a}switch(r){case"bottom":return"start";case"top":return"end";case"zero":return"origin";case"origin":case"start":case"end":return r;default:return false}}function Yr(e){var t=e.el._model||{};var i=e.el._scale||{};var n=e.fill;var r=null;var a;if(isFinite(n))return null;if(n==="start")r=t.scaleBottom===undefined?i.bottom:t.scaleBottom;else if(n==="end")r=t.scaleTop===undefined?i.top:t.scaleTop;else if(t.scaleZero!==undefined)r=t.scaleZero;else if(i.getBasePixel)r=i.getBasePixel();if(r!==undefined&&r!==null){if(r.x!==undefined&&r.y!==undefined)return r;if(R.isFinite(r)){a=i.isHorizontal();return{x:a?r:null,y:a?null:r}}}return null}function Hr(e){var t=e.el._scale;var i=t.options;var n=t.chart.data.labels.length;var r=e.fill;var a=[];var s,o,l,u,d;if(!n)return null;s=i.ticks.reverse?t.max:t.min;o=i.ticks.reverse?t.min:t.max;l=t.getPointPositionForValue(0,s);for(u=0;u0;--a)e.arc(s,o,l,i[a].angle,i[a-1].angle,true);return}e.lineTo(i[r-1].x,i[r-1].y);for(a=r-1;a>0;--a)R.canvas.lineTo(e,i[a],i[a-1],true)}function Jr(e,t,i,n,r,a){var s=t.length;var o=n.spanGaps;var l=[];var u=[];var d=0;var c=0;var h,f,p,g,v,m,y,b;e.beginPath();for(h=0,f=s;h=0;--r){n=t[r].$filler;if(!n||!n.visible)continue;a=n.el;s=a._view;o=a._children||[];l=n.mapper;u=s.backgroundColor||L.global.defaultColor;if(l&&u&&o.length){R.canvas.clipArea(i,e.chartArea);Jr(i,o,l,s,u,a._loop);R.canvas.unclipArea(i)}}}},ea=R.rtl.getRtlAdapter,t=R.noop,k=R.valueOrDefault;function ta(e,t){return e.usePointStyle&&e.boxWidth>t?t:e.boxWidth}L._set("global",{legend:{display:true,position:"top",align:"center",fullWidth:true,reverse:false,weight:1e3,onClick:function(e,t){var i=t.datasetIndex;var n=this.chart;var r=n.getDatasetMeta(i);r.hidden=r.hidden===null?!n.data.datasets[i].hidden:null;n.update()},onHover:null,onLeave:null,labels:{boxWidth:40,padding:10,generateLabels:function(i){var n=i.data.datasets;var e=i.options.legend||{};var r=e.labels&&e.labels.usePointStyle;return i._getSortedDatasetMetas().map(function(e){var t=e.controller.getStyle(r?0:undefined);return{text:n[e.index].label,fillStyle:t.backgroundColor,hidden:!i.isDatasetVisible(e.index),lineCap:t.borderCapStyle,lineDash:t.borderDash,lineDashOffset:t.borderDashOffset,lineJoin:t.borderJoinStyle,lineWidth:t.borderWidth,strokeStyle:t.borderColor,pointStyle:t.pointStyle,rotation:t.rotation,datasetIndex:e.index}},this)}}},legendCallback:function(e){var t=document.createElement("ul");var i=e.data.datasets;var n,r,a,s;t.setAttribute("class",e.id+"-legend");for(n=0,r=i.length;nl.width){c+=s+r.padding;d[d.length-(t>0?0:1)]=0}o[t]={left:0,top:0,width:n,height:s};d[d.length-1]+=n+r.padding});l.height+=c}else{var h=r.padding;var f=e.columnWidths=[];var p=e.columnHeights=[];var g=r.padding;var v=0;var m=0;R.each(e.legendItems,function(e,t){var i=ta(r,s);var n=i+s/2+a.measureText(e.text).width;if(t>0&&m+s+2*h>l.height){g+=v+r.padding;f.push(v);p.push(m);v=0;m=0}v=Math.max(v,n);m+=s+h;o[t]={left:0,top:0,width:n,height:s}});g+=v;f.push(v);p.push(m);l.width+=g}e.width=l.width;e.height=l.height},afterFit:t,isHorizontal:function(){return this.options.position==="top"||this.options.position==="bottom"},draw:function(){var o=this;var i=o.options;var l=i.labels;var e=L.global;var u=e.defaultColor;var d=e.elements.line;var c=o.height;var h=o.columnHeights;var f=o.width;var p=o.lineWidths;if(!i.display)return;var g=ea(i.rtl,o.left,o.minSize.width);var v=o.ctx;var t=k(l.fontColor,e.defaultFontColor);var n=R.options._parseFont(l);var m=n.size;var y;v.textAlign=g.textAlign("left");v.textBaseline="middle";v.lineWidth=.5;v.strokeStyle=t;v.fillStyle=t;v.font=n.string;var b=ta(l,m);var E=o.legendHitBoxes;var S=function(e,t,i){if(isNaN(b)||b<=0)return;v.save();var n=k(i.lineWidth,d.borderWidth);v.fillStyle=k(i.fillStyle,u);v.lineCap=k(i.lineCap,d.borderCapStyle);v.lineDashOffset=k(i.lineDashOffset,d.borderDashOffset);v.lineJoin=k(i.lineJoin,d.borderJoinStyle);v.lineWidth=n;v.strokeStyle=k(i.strokeStyle,u);if(v.setLineDash)v.setLineDash(k(i.lineDash,d.borderDash));if(l&&l.usePointStyle){var r=b*Math.SQRT2/2;var a=g.xPlus(e,b/2);var s=t+m/2;R.canvas.drawPoint(v,i.pointStyle,r,a,s,i.rotation)}else{v.fillRect(g.leftForLtr(e,b),t,b,m);if(n!==0)v.strokeRect(g.leftForLtr(e,b),t,b,m)}v.restore()};var T=function(e,t,i,n){var r=m/2;var a=g.xPlus(e,b+r);var s=t+r;v.fillText(i.text,a,s);if(i.hidden){v.beginPath();v.lineWidth=2;v.moveTo(a,s);v.lineTo(g.xPlus(a,n),s);v.stroke()}};var w=function(e,t){switch(i.align){case"start":return l.padding;case"end":return e-t;default:return(e-t+l.padding)/2}};var M=o.isHorizontal();if(M)y={x:o.left+w(f,p[0]),y:o.top+l.padding,line:0};else y={x:o.left+l.padding,y:o.top+w(c,h[0]),line:0};R.rtl.overrideTextDirection(o.ctx,i.textDirection);var A=m+l.padding;R.each(o.legendItems,function(e,t){var i=v.measureText(e.text).width;var n=b+m/2+i;var r=y.x;var a=y.y;g.setWidth(o.minSize.width);if(M){if(t>0&&r+n+l.padding>o.left+o.minSize.width){a=y.y+=A;y.line++;r=y.x=o.left+w(f,p[y.line])}}else if(t>0&&a+A>o.top+o.minSize.height){r=y.x=r+o.columnWidths[y.line]+l.padding;y.line++;a=y.y=o.top+w(c,h[y.line])}var s=g.x(r);S(s,a,e);E[t].left=g.leftForLtr(s,E[t].width);E[t].top=a;T(s,a,e,i);if(M)y.x+=n+l.padding;else y.y+=A});R.rtl.restoreTextDirection(o.ctx,i.textDirection)},_getLegendItemAt:function(e,t){var i=this;var n,r,a;if(e>=i.left&&e<=i.right&&t>=i.top&&t<=i.bottom){a=i.legendHitBoxes;for(n=0;n=r.left&&e<=r.left+r.width&&t>=r.top&&t<=r.top+r.height)return i.legendItems[n]}}return null},handleEvent:function(e){var t=this;var i=t.options;var n=e.type==="mouseup"?"click":e.type;var r;if(n==="mousemove"){if(!i.onHover&&!i.onLeave)return}else if(n==="click"){if(!i.onClick)return}else return;r=t._getLegendItemAt(e.x,e.y);if(n==="click"){if(r&&i.onClick)i.onClick.call(t,e.native,r)}else{if(i.onLeave&&r!==t._hoveredItem){if(t._hoveredItem)i.onLeave.call(t,e.native,t._hoveredItem);t._hoveredItem=r}if(i.onHover&&r)i.onHover.call(t,e.native,r)}}});function na(e,t){var i=new ia({ctx:e.ctx,options:t,chart:e});r.configure(e,i,t);r.addBox(e,i);e.legend=i}var ra={id:"legend",_element:ia,beforeInit:function(e){var t=e.options.legend;if(t)na(e,t)},beforeUpdate:function(e){var t=e.options.legend;var i=e.legend;if(t){R.mergeIf(t,L.global.legend);if(i){r.configure(e,i,t);i.options=t}else na(e,t)}else if(i){r.removeBox(e,i);delete e.legend}},afterEvent:function(e,t){var i=e.legend;if(i)i.handleEvent(t)}},_=R.noop,aa=(L._set("global",{title:{display:false,fontStyle:"bold",fullWidth:true,padding:10,position:"top",text:"",weight:2e3}}),e.extend({initialize:function(e){var t=this;R.extend(t,e);t.legendHitBoxes=[]},beforeUpdate:_,update:function(e,t,i){var n=this;n.beforeUpdate();n.maxWidth=e;n.maxHeight=t;n.margins=i;n.beforeSetDimensions();n.setDimensions();n.afterSetDimensions();n.beforeBuildLabels();n.buildLabels();n.afterBuildLabels();n.beforeFit();n.fit();n.afterFit();n.afterUpdate();return n.minSize},afterUpdate:_,beforeSetDimensions:_,setDimensions:function(){var e=this;if(e.isHorizontal()){e.width=e.maxWidth;e.left=0;e.right=e.width}else{e.height=e.maxHeight;e.top=0;e.bottom=e.height}e.paddingLeft=0;e.paddingTop=0;e.paddingRight=0;e.paddingBottom=0;e.minSize={width:0,height:0}},afterSetDimensions:_,beforeBuildLabels:_,buildLabels:_,afterBuildLabels:_,beforeFit:_,fit:function(){var e=this;var t=e.options;var i=e.minSize={};var n=e.isHorizontal();var r,a;if(!t.display){e.width=i.width=e.height=i.height=0;return}r=R.isArray(t.text)?t.text.length:1;a=r*R.options._parseFont(t).lineHeight+t.padding*2;e.width=i.width=n?e.maxWidth:a;e.height=i.height=n?a:e.maxHeight},afterFit:_,isHorizontal:function(){var e=this.options.position;return e==="top"||e==="bottom"},draw:function(){var e=this;var t=e.ctx;var i=e.options;if(!i.display)return;var n=R.options._parseFont(i);var r=n.lineHeight;var a=r/2+i.padding;var s=0;var o=e.top;var l=e.left;var u=e.bottom;var d=e.right;var c,h,f;t.fillStyle=R.valueOrDefault(i.fontColor,L.global.defaultFontColor);t.font=n.string;if(e.isHorizontal()){h=l+(d-l)/2;f=o+a;c=d-l}else{h=i.position==="left"?l+a:d-a;f=o+(u-o)/2;c=u-o;s=Math.PI*(i.position==="left"?-.5:.5)}t.save();t.translate(h,f);t.rotate(s);t.textAlign="center";t.textBaseline="middle";var p=i.text;if(R.isArray(p)){var g=0;for(var v=0;v= 1");this._maxFreq=e,this._calcBars()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"minDecibels",{get:function(){return this._analyzer[0].minDecibels},set:function(e){for(var t=0,i=[0,1];t= 1");this._minFreq=e,this._calcBars()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"mirror",{get:function(){return this._mirror},set:function(e){this._mirror=0|Math.sign(e),this._calcAux(),this._calcBars(),this._makeGrad()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"mode",{get:function(){return this._mode},set:function(e){var t=0|e;if(!(0<=t&&t<=10&&9!=t))throw new wu("ERR_INVALID_MODE","Invalid mode: ".concat(e));this._mode=t,this._calcAux(),this._calcBars(),this._makeGrad()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"outlineBars",{get:function(){return this._outlineBars},set:function(e){this._outlineBars=!!e,this._calcAux()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"radial",{get:function(){return this._radial},set:function(e){this._radial=!!e,this._calcAux(),this._calcBars(),this._makeGrad()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"reflexRatio",{get:function(){return this._reflexRatio},set:function(e){if((e=+e||0)<0||1<=e)throw new wu("ERR_REFLEX_OUT_OF_RANGE","Reflex ratio must be >= 0 and < 1");this._reflexRatio=e,this._calcAux(),this._makeGrad(),this._calcLeds()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"showLeds",{get:function(){return this.ledBars},set:function(e){this.ledBars=e},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"smoothing",{get:function(){return this._analyzer[0].smoothingTimeConstant},set:function(e){for(var t=0,i=[0,1];t= 1");this._minFreq=Math.min(e,t),this._maxFreq=Math.max(e,t),this._calcBars()},A.prototype.setLedParams=function(e){var t,i,n;e&&(t=0|e.maxLeds,i=+e.spaceV,n=+e.spaceH),this._ledParams=0>1;this._radius=Math.min(e.width,e.height)*(this._stereo?.375:.125)|0,this._barSpacePx=Math.min(this._barWidth-1,0>i,this._analyzerHeight=this._channelHeight*(this._isLumiBars||t?1:1-this._reflexRatio)|0,this._channelGap=i?e.height-2*this._channelHeight:0,this._analyzerWidth=e.width-n*(0!=this._mirror),this._initialX=n*(-1==this._mirror&&!t)},A.prototype._calcBars=function(){var i=this,o=this._bars=[];if(this._ready){var e=function(e){return e*i.audioCtx.sampleRate/i.fftSize||1},t=function(e,t,i,n,r,a,s){return o.push({posX:e,binLo:t,binHi:i,freqLo:n,freqHi:r,ratioLo:a,ratioHi:s,peak:[0,0],hold:[0],value:[0]})},n=this._analyzerWidth,r=this._initialX,a=this._maxFreq,s=this._minFreq;if(this._isOctaveBands){for(var l=[],u=0;u<11;u++)for(var d=0;d<24;d++){var c=Su*Math.pow(Eu,24*u+d),h=this._freqToBin(c,"floor"),f=e(h),p=e(h+1);l.push({freq:c,bin:h,ratio:(c-f)/(p-f)})}for(var g=[0,1,2,3,4,6,8,12,24][this._mode],v=0;v=this.fftSize/2){A.binHi++,A.ratioHi=0,A.freqHi=e(A.binHi);break}s<=b&&(0>1),A.ratioHi=0,A.freqHi=e(A.binHi),1A.binLo&&A.binLo>o[M-2].binHi&&(A.ratioLo=0,A.freqLo=e(A.binLo)),E=A.binHi+1),EA.binHi&&(y=0,b=e(E)),t(0,E,w,b,T,y,S))}this._barWidth=n/o.length,o.forEach(function(e,t){return e.posX=r+t*i._barWidth}),L=Math.log10(o[0].freqLo),I=n/(Math.log10(o[o.length-1].freqHi)-L)}else{this._barWidth=1;for(var L=Math.log10(s),I=n/(Math.log10(a)-L),n=this._freqToBin(s,"floor"),D=this._freqToBin(a),k=-999,_=n;_<=D;_++){var c=e(_),x=r+Math.round(I*(Math.log10(c)-L));k>1),l=o-.7*s;i.width|=0,t.fillStyle=a.strokeStyle="#000c",t.fillRect(0,0,i.width,i.height),a.arc(o,o,o-s/2,0,mu),a.lineWidth=s,a.stroke(),t.fillStyle=a.fillStyle="#fff",t.font="".concat(i.height>>1,"px sans-serif"),a.font="".concat(s>>1,"px sans-serif"),t.textAlign=a.textAlign="center";for(var u=0,d=[16,31,63,125,250,500,1e3,2e3,4e3,8e3,16e3];u>1,Q=x.height>>1,q=this._radius,X=F?Math.min(K,Q)-q:V,J=this.useCanvas,$=(0>1,s=re._analyzer[0].minDecibels,o=re._analyzer[0].maxDecibels,l=V/(o-s);_.fillStyle="#888",_.font="".concat(a,"px sans-serif"),_.textAlign="right",_.lineWidth=1;for(var u=o;sI&&(I=p[D]);I/=255,T.value[e]=I,ue+=I,0=T.peak[e]&&(T.peak[e]=I,T.hold[e]=30),J&&(O||P?_.globalAlpha=I:B&&(_.globalAlpha=re.fillAlpha),N?(I=oe(I))<0&&(I=0):I=I*X|0,F&&1==e&&(I*=-1),A=ne,L=T.posX,10==R?(E=m?0:(p[re._bars[1].binLo]/255*X*(!F||!e||-1)+I)/2,F?(0==m&&_.lineTo.apply(_,ee(0,L<0?E:I,1)),0<=L&&(_.lineTo.apply(_,ee.apply(void 0,ce(ce([],y=[L,I],!1),[1],!1))),v.push(y))):(0==m&&(-1!=Z?(y=w?p[w-1]/255*X:I,_.moveTo(H-z,n-y)):_.moveTo(H,n-(Lre._bars[m-1].posX+ne&&(L--,A++)):L+=re._barSpacePx/2),N?(b=L+ne/2,re.showBgColor&&!re.overlay&&(w=_.globalAlpha,_.beginPath(),_.moveTo(b,t),_.lineTo(b,n),_.strokeStyle="#7f7f7f22",_.globalAlpha=1,_.stroke(),_.strokeStyle=_.fillStyle,_.globalAlpha=w),_.beginPath(),_.moveTo(b,O?t:n),_.lineTo(b,O?i:n-I),_.stroke()):H<=L&&(F?ae(L,0,A,I,B):(b=L,E=O?t:n,w=A,S=O?i:-I,_.beginPath(),_.moveTo(b,E),_.lineTo(b,E+S),_.lineTo(b+w,E+S),_.lineTo(b+w,E),$(B),_.fill()))),0<(S=T.peak[e]))&&re.showPeaks&&!O&&H<=L&&L=i.peak?(i.peak=i.val,i.hold=30):0>1,-t.width>>1),_.restore()):_.drawImage(C,0,x.height-C.height)),this._frame++;a=e-this._time;1e3<=a&&(this._fps=this._frame/(a/1e3),this._frame=0,this._time=e),this.showFPS&&(r=C.height,_.font="bold ".concat(r,"px sans-serif"),_.fillStyle="#0f0",_.textAlign="right",_.fillText(Math.round(this._fps),x.width-r,2*r)),this.onCanvasDraw&&(_.save(),_.fillStyle=_.strokeStyle=this._canvasGradient,this.onCanvasDraw(this),_.restore()),this._runId=requestAnimationFrame(function(e){return n._draw(e)})},A.prototype._freqToBin=function(e,t){void 0===t&&(t="round");var i=this._analyzer[0].frequencyBinCount-1,t=Math[t](e*this.fftSize/this.audioCtx.sampleRate);return t>1,t=t.height>>1,a=Math.min(r,t),u=this._radius,d=this._gradients[this._gradient],c=d.colorStops,h="h"==d.dir,f=this._radial?e.createRadialGradient(r,t,a,r,t,u-(a-u)*this._stereo):e.createLinearGradient.apply(e,h?[n,0,n+this._analyzerWidth,0]:[0,0,0,i]);if(c)for(var p=this._stereo&&!this._splitGradient&&!h,g=function(e,t){return f.addColorStop(e,t.color||t)},v=0;v<1+p;v++)!function(a){c.forEach(function(e,t){var i,n=c.length-1,r=void 0!==e.pos?e.pos:t/n;p&&(r/=2),!s._stereo||o||s._radial||h||(r*=l,!p&&.5*lthis.videoEngine.duration-l.LIVE_SEEK_TRESHOLD?this.videoEngine.currentTime=this.videoEngine.duration-l.LIVE_SEEK_TRESHOLD:this.videoEngine.currentTime+=15,null!=(e=this.castManager)&&e.seek(this.videoEngine.currentTime))},k.prototype.upward15Sec=function(){var e;M.isNonSeekableLiveContent(this.contentInfo.contentType)||(this.videoEngine.currentTime-=15,null!=(e=this.castManager)&&e.seek(this.videoEngine.currentTime))},k.prototype.muteUnmute=function(){this.currentSkin.getVolumeButton().muteUnmute(this)},k.prototype.mute=function(){var e;this.videoEngine.volume=0,null!=(e=this.castManager)&&e.setVolume(0),null!=(e=this.currentSkin.getVolumeButton())&&e.mute(this)},k.prototype.unmute=function(){var e;this.videoEngine.volume=1,null!=(e=this.castManager)&&e.setVolume(1),null!=(e=this.currentSkin.getVolumeButton())&&e.unmute(this)},k.prototype.setVolume=function(e){var t;this.videoEngine.volume=e,null!=(t=this.castManager)&&t.setVolume(e)},k.prototype.getVolume=function(){return this.videoEngine.volume},k.prototype.isPaused=function(){return this.videoEngine.paused},k.prototype.changePoster=function(e){this.currentSkin.getPoster().changePosterImage(e)},k.prototype.stopDownload=function(){this.hlsEngine&&this.hlsEngine.stopLoad(),this.rxplayerEngine&&(this.rxplayerEngine.setWantedBufferAhead(0),this.rxplayerEngine.setMaxBufferAhead(0))},k.prototype.resumeDownload=function(){this.hlsEngine&&this.hlsEngine.startLoad(),this.rxplayerEngine&&(this.rxplayerEngine.setWantedBufferAhead(30),this.rxplayerEngine.setMaxBufferAhead(1/0))},k.prototype.getVideoDuration=function(){return M.isNonSeekableLiveContent(this.contentInfo.contentType)&&this.rxplayerEngine?this.rxplayerEngine.getMaximumPosition():this.videoEngine.duration},k.prototype.seekToLive=function(){var e;this.live&&(M.isLiveContent(this.contentInfo.contentType)?this.rxplayerEngine?this.rxplayerEngine.seekTo(this.rxplayerEngine.getMaximumPosition()-l.LIVE_SEEK_TRESHOLD):(e=this.videoEngine.duration,this.videoEngine.currentTime=e-l.LIVE_SEEK_TRESHOLD):w(T.Error,"Can't seek to LIVE a non LIVE element!!!"))},k.prototype.seekTo=function(e){var t;this.rxplayerEngine?this.rxplayerEngine.seekTo(e):this.videoEngine.currentTime=e,null!=(t=this.castManager)&&t.seek(e)},k.prototype.seekToFrame=function(e){var t;this.rxplayerEngine||this.hlsEngine&&(t=this.hlsEngine.currentLevel,this.hlsEngine.levels[t])},k.prototype.getLiveDifference=function(){return this.rxplayerEngine?this.getTotDuration()-this.rxplayerEngine.getPosition():this.getTotDuration()-this.videoEngine.currentTime},k.prototype.getCurrentTime=function(){return this.rxplayerEngine?this.rxplayerEngine.getPosition():this.videoEngine.currentTime},k.prototype.getTotDuration=function(){return this.rxplayerEngine?this.rxplayerEngine.getMaximumPosition():this.videoEngine.duration},k.prototype.getTotDVRDuration=function(){return this.rxplayerEngine?this.rxplayerEngine.getMaximumPosition():this.videoEngine.duration},k.prototype.calculateDashAvailabilityTimeShift=function(i){return g(this,void 0,void 0,function(){var t=this;return v(this,function(e){switch(e.label){case 0:return w(T.Info,"Calculating DashAvailabilityTimeShift"),[4,fetch(i).then(function(d){return g(t,void 0,void 0,function(){var t,i,n,r,a,s,o,l,u;return v(this,function(e){switch(e.label){case 0:return t=new window.DOMParser,i=(t=t).parseFromString,[4,d.text()];case 1:return u=i.apply(t,[e.sent(),"text/xml"]),u=u.getElementsByTagName("MPD")[0],u=u.getAttribute("timeShiftBufferDepth"),a=r=n=0,u.includes("H")?(o=u.split("H"),s=o[0].replace("PT",""),n=Number(s),s=o[1].split("M"),o=s[0].replace("H",""),a=Number(o),l=(l=s[1].replace("M","")).replace("S",""),r=Number(l)):u.includes("M")?(s=u.split("M"),o=s[0].replace("PT",""),a=Number(o),l=s[1].replace("S",""),r=Number(l)):u.includes("S")&&(u=(u=u.replace("PT-","")).replace("S",""),r=Number(u)),w(T.Info,"Player can seek behind for "+n+" hours and "+a+" minutes and "+r+" seconds"),ku.TIME_SHIFT_BUFFER_SIZE=360*n+60*a+r,[2]}})})}).catch(function(e){Ro(t,Xa.RetriveContentError,"Cannot retrieve manifest"),console.error(e)})];case 1:return e.sent(),[2]}})})},k.prototype.setPlaybackSpeed=function(e){this.rxplayerEngine?this.rxplayerEngine.setPlaybackRate(e):this.videoEngine.playbackRate=e},k.prototype.getPlayerAudioTracks=function(){var e=null;return this.rxplayerEngine?e=this.rxplayerEngine.getAvailableAudioTracks():this.hlsEngine&&(e=this.hlsEngine.audioTracks),e},k.prototype.getCurrentAudioTrack=function(){var e;return this.rxplayerEngine?null==(e=this.rxplayerEngine.getAudioTrack())?void 0:e.id:this.hlsEngine?this.hlsEngine.audioTrack:void 0},k.prototype.getCurrentBitrate=function(e){var t;return void 0===e&&(e=1),this.live?this.rxplayerEngine?this.rxplayerEngine.getVideoBitrate()/e:this.hlsEngine?(t=this.hlsEngine.loadLevel,this.hlsEngine.levels[t].bitrate/e):void 0:0},k.prototype.getWantedBuffer=function(){return this.rxplayerEngine?this.rxplayerEngine.getWantedBufferAhead():this.hlsEngine?this.hlsEngine.config.maxBufferLength:void 0},k.prototype.getPlayerRenditions=function(){var e=[];if(!M.isAudio(this.contentInfo.contentType)){if(this.rxplayerEngine)for(var t=this.rxplayerEngine.getVideoTrack().representations,i=0;i=t&&(this.contentInfo.playlist.currentIndex=0),t=this.contentInfo.playlist.currentIndex,[4,this.changeContentSource(this.contentInfo.contentID,t,null==(i=this.contentInfo.alternativeContentInfo)?void 0:i.originalContentID)]);case 1:return e.sent(),[2]}})})},k.prototype.getSubtitleTracks=function(){return null!=this.rxplayerEngine?(w(T.Warning,"Subtitles currently not supported using DASH"),0):null!=this.hlsEngine?this.hlsEngine.subtitleTracks.length:void 0},k.prototype.isSubtitleOn=function(){return null!=this.rxplayerEngine?(w(T.Warning,"Subtitles currently not supported using DASH"),!1):null!=this.hlsEngine?this.hlsEngine.subtitleDisplay:void 0},k.prototype.showSubtitles=function(e){null!=this.rxplayerEngine&&w(T.Warning,"Subtitles currently not supported using DASH"),null!=this.hlsEngine&&(this.hlsEngine.subtitleDisplay=e,this.hlsEngine.subtitleTrack=e?this.hlsEngine.subtitleTracks[0].id:-1)},k.prototype.restartPlaylist=function(){var i;return g(this,void 0,void 0,function(){var t;return v(this,function(e){switch(e.label){case 0:return this.init=!1,this.stopDownload(),this.contentInfo.playlist.currentIndex=0,t=this.contentInfo.playlist.currentIndex,[4,this.changeContentSource(this.contentInfo.contentID,t,null==(i=this.contentInfo.alternativeContentInfo)?void 0:i.originalContentID)];case 1:return e.sent(),[2]}})})},k.prototype.prevPlaylistVideoSource=function(){var i;return g(this,void 0,void 0,function(){var t;return v(this,function(e){switch(e.label){case 0:return(t=this.contentInfo.playlistContents.length,this.contentInfo.contentType==S.PlaylistOneShot&&0==this.contentInfo.playlist.currentIndex)?(w(T.Warning,"[one-shot]Cannot play previous video since currently playing the first one"),[2]):(this.init=!1,this.stopDownload(),this.contentInfo.playlist.currentIndex--,this.contentInfo.playlist.currentIndex<0&&(this.contentInfo.playlist.currentIndex=t-1),t=this.contentInfo.playlist.currentIndex,[4,this.changeContentSource(this.contentInfo.contentID,t,null==(i=this.contentInfo.alternativeContentInfo)?void 0:i.originalContentID)]);case 1:return e.sent(),[2]}})})},k.prototype.populatePlaylistInfo=function(e,t,i){void 0===i&&(i=null),t.playlist=new ns,t.playlistContents=e.playlistContents,t.playlist.currentIndex=null==i?0:i},k.prototype.restartVideoPlayback=function(){return g(this,void 0,void 0,function(){return v(this,function(e){switch(e.label){case 0:return(this.stopDownload(),this.contentInfo.alternativeContentInfo.alternativeContentPlaying)?[3,2]:(w(T.Watch,"The player with ID "+this.divPlayer.id+" will be regenerated to replay the source"),w(T.Watch,"Will be played content ID "+this.contentInfo.contentID),[4,this.changeContentSource(this.contentInfo.contentID,0,null)]);case 1:return e.sent(),[3,4];case 2:return w(T.Watch,"The player with ID "+this.divPlayer.id+" will be regenerated to replay the alternative source"),[4,this.changeContentSource(this.contentInfo.contentID,0,this.contentInfo.alternativeContentInfo.originalContentID)];case 3:e.sent(),e.label=4;case 4:return[2]}})})},k.prototype.playAlternativeContent=function(){return g(this,void 0,void 0,function(){return v(this,function(e){switch(e.label){case 0:return null==this.contentInfo.alternativeContentInfo.alternativeContentID?[3,2]:(this.stopDownload(),this.autoplay=!0,this.options.autoPlay=!0,this.options.titleOnButton,w(T.Watch,"The current live event is down, playing alternative content..."),w(T.Watch,"Will be played Content ID"+this.contentInfo.alternativeContentInfo.alternativeContentID),[4,this.changeContentSource(this.contentInfo.alternativeContentInfo.alternativeContentID,0,this.contentInfo.alternativeContentInfo.originalContentID)]);case 1:return e.sent(),[3,3];case 2:w(T.Info,"No alternative content to play, displaying poster and setting LIVE offline"),this.setPoster(),e.label=3;case 3:return[2]}})})},k.prototype.setPoster=function(){this.currentSkin.getPoster().displayPoster()},k.prototype.playOriginalContent=function(t){return void 0===t&&(t=!0),g(this,void 0,void 0,function(){return v(this,function(e){switch(e.label){case 0:return(w(T.Watch,"Alternative content is playing: "+this.contentInfo.alternativeContentInfo.alternativeContentPlaying),this.autoplay=t,this.options.autoPlay=t,this.contentInfo.alternativeContentInfo.alternativeContentPlaying)?(this.stopDownload(),w(T.Watch,"The original content is live again, playing original content"),[4,this.changeContentSource(this.contentInfo.alternativeContentInfo.originalContentID,0,null)]):[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})})},k.prototype.replayContent=function(e){this.autoplay=e=void 0===e?!0:e,this.options.autoPlay=e,this.changeContentSource(this.contentInfo.contentID,null,null)},k.prototype.getMetrics=function(){var e,t;return null==this.rxplayerEngine&&null!=this.hlsEngine?(e=new Nu,t=this.hlsEngine.currentLevel,t=this.hlsEngine.levels[t],e.audioCodec=t.audioCodec,e.videoCodec=t.videoCodec,e.videoBitrate=t.bitrate,e.videoWidth=t.width,e.videoHeight=t.height,e.playerWidth=this.divPlayer.getBoundingClientRect().width,e.playerHeight=this.divPlayer.getBoundingClientRect().height,e.currentTime=this.getCurrentTime(),e):null},k.prototype.setAudioTrackById=function(e){null!=this.rxplayerEngine?w(T.Warning,"Currently not supported over DASH"):null!=this.hlsEngine&&(this.hlsEngine.audioTrack=e)},k.prototype.changeContentSource=function(o,l,u){var d;return void 0===l&&(l=0),void 0===u&&(u=null),g(this,void 0,void 0,function(){var t,i,n,r,a,s;return v(this,function(e){switch(e.label){case 0:return this.init=!1,this.isVideoStarted=!1,this.live=!0,this.goneOffline=!1,clearInterval(this.timer),t=new Pu,M.isLiveContent(this.contentInfo.contentType)&&(t.liveUrlContent=this.liveUrlContent),null!=this.currentSkin&&null!=this.currentSkin&&(i=this.currentSkin.getFullscreenButton(),t.fullScreen=null!=(d=null==i?void 0:i.fullscreenStatus)&&d),this.hlsEngine&&(t.volume=this.videoEngine.volume,this.hlsEngine.stopLoad(),this.hlsEngine.destroy()),this.rxplayerEngine&&(t.volume=this.rxplayerEngine.getVolume(),this.rxplayerEngine.stop(),this.rxplayerEngine.dispose()),this.divPlayer.innerHTML="",m.iphone()||(t.currentVolume=this.currentSkin.getVolumeButton().currentVolume),ku.createPlayerDOM(this,this.divPlayer.id),xo(this,this.options),i=Zo.generateContentAPICall(o,this.currentSkinId,this.options.requestHost),n=this,[4,yl.generateContentByAPI(this,i,l,u,this.options)];case 1:return n.contentInfo=e.sent(),null==this.contentInfo||null==this.contentInfo?[2,null]:this.contentInfo.contentType!=S.PlaylistLoop?[3,4]:[4,yl.calculatePlaylistLoopStartingPoint(this,o,this.options.requestHost)];case 2:return a=e.sent(),this.contentInfo.sources.hls=vl.generateHlsSourceFromContentID(this.contentInfo,a.contentID,this.options.SecurityTokenQS),this.contentInfo.sources.dash=vl.generateDashSourceFromContentID(this.contentInfo,a.contentID,this.options.SecurityTokenQS),ku.PL_SEEK_TIME=a.startTime,r=this,[4,yl.getContentInfoFromContent(this.contentInfo,a.contentID,this.options.requestHost)];case 3:r.contentInfo=e.sent(),e.label=4;case 4:return this.contentInfo.contentType==S.PlaylistLoop?this.options.autoPlay=!0:this.options.autoPlay=this.autoplay,this.options.startMute=this.startMute,this.options.controls=this.haveControls,this.options.titleOnButton=this.titleOnButton,this.options.skinId=this.currentSkinId,this.options.replay=this.replay,ko(this.contentInfo.settings,this,this.options),this.contentInfo.contentType!=S.PlaylistLoop&&this.contentInfo.contentType!=S.PlaylistOneShot||!1!==this.contentInfo.settings.autoPlay||(this.startMute=!1),Po(this),M.isLiveContent(this.contentInfo.contentType)||Co(this),ws.loadFont(bs.OPEN_SANS),m.iphone()?(w(T.Info,"Skin won't be loaded, using native player (iOS devices only)"),this.contentInfo.contentType!=S.PlaylistLoop&&(a=this.contentInfo.hostname,s=this.contentInfo.contentID,s=dl.createURL(a,s),this.videoEngine.poster=s)):ku.loadSkin(this),s=ku.checkProtocolErogation(this),this.urlContent=s,w(T.Info,"Pre-Erogating content..."),[4,Fu(this.contentInfo.protocol,s,this,t)];case 5:return e.sent(),[2]}})})};var Ru=k;function k(){this.init=!1,this.live=!0,this.goneOffline=!1,this.firstSeek=!1,this.hlsEngine=new p,this.rxplayerEngine=new $a,this.startMute=!0,this.autoplay=!1,this.hasLooped=!0,this.haveControls=!0,this.replay=!1,this.titleOnButton=!0,this.currentSkinId=null,this.options=new Lo,this.isVideoStarted=!1,this.isAutoRendition=!0,this.globalEventsHandler=null,this.eventsHandlerAttached=!1,this.stopSeekEvent=!1,this.urlContent=null,this.liveUrlContent=null,this.playerGUID=this.newGuid()}var Pu=function(){},Nu=function(){},Ou=(Bu.injectPlayerCSS=function(e){var t,i;document.getElementById(this.cssID)||(t=document.getElementsByTagName("head")[0],(i=document.createElement("style")).id=this.cssID,i.innerHTML="\n .player-mainbar * ::-webkit-scrollbar {\n display: none;\n }\n \n .player-mainbar * {\n -ms-overflow-style: none;\n }\n\n .player-central-area * {\n -webkit-tap-highlight-color: transparent\n }\n ",i.media="all",t.appendChild(i))},Bu.cssID="msplayer-style",Bu);function Bu(){}function Fu(t,i,n,r){return void 0===r&&(r=null),g(this,void 0,void 0,function(){return v(this,function(e){switch(e.label){case 0:return n.contentInfo.contentType!=S.LiveEventVideoDVR||t!=o.DASH?[3,2]:[4,n.calculateDashAvailabilityTimeShift(n.contentInfo.sources.dash)];case 1:e.sent(),e.label=2;case 2:return w(T.Info,"Erogating content..."),w(T.Info,i),[4,function(i,n,r,a){void 0===a&&(a=null);return g(this,void 0,void 0,function(){var t;return v(this,function(e){switch(e.label){case 0:switch(w(T.Info,"Requested protocol ".concat(o[i])),i){case o.HLS:p.isSupported()?(w(T.Info,"Using engine: HLS.js"),t={forceKeyFrameOnDiscontinuity:r.options.forceKeyFrameOnDiscontinuity,xhrSetup:function(e){var t;document.referrer&&((t=document.referrer).indexOf("http")<0&&(t=location.protocol+"//"+document.referrer),e.setRequestHeader("X-MS-OriginalReferer",t))}},r.hlsEngine=new p(t),r.hlsEngine.config.debug=!0,w(T.Info,"HLS Configuration - set BufferLength: "+r.options.bufferLength+" - MaxBufferLength: "+r.options.maxBufferLength),r.hlsEngine.config.maxBufferLength=r.options.bufferLength,r.hlsEngine.config.maxMaxBufferLength=r.options.maxBufferLength,r.hlsEngine.startLevel=-1,r.hlsEngine.loadLevel=-1,r.hlsEngine.config.maxStarvationDelay=1,r.hlsEngine.config.maxFragLookUpTolerance=1,r.hlsEngine.loadSource(n),r.hlsEngine.attachMedia(r.videoEngine),r.hlsEngine.on(p.Events.MANIFEST_PARSED,function(){r.autoplay&&(r.startMute&&(r.videoEngine.volume=0),r.videoEngine.play()),r.hlsEngine.startLoad()})):r.videoEngine.canPlayType("application/vnd.apple.mpegurl")&&(w(T.Info,"Will be using HTML5 Video Engine"),r.videoEngine.src=n,r.videoEngine.playsInline=!0,r.videoEngine.controls=r.haveControls,r.autoplay)&&(r.videoEngine.autoplay=!0,r.videoEngine.muted=!0),null!=r.rxplayerEngine&&null!=r.rxplayerEngine&&(r.rxplayerEngine.dispose(),r.rxplayerEngine=null);break;case o.DASH:w(T.Info,"Will be using RxPlayer"),r.rxplayerEngine=new $a({videoElement:r.videoEngine}),r.rxplayerEngine.loadVideo({url:n,transport:"dash",autoPlay:r.autoplay}),r.rxplayerEngine.log.setLevel("INFO"),w(T.Info,"Video Duration: "+r.videoEngine.duration),r.videoEngine.duration<=30?(w(T.Watch,"A really short video is going to be displayed using RxPlayer"),w(T.Watch,"Decreasing buffer size to prevent loop calls"),r.rxplayerEngine.setWantedBufferAhead(10)):(r.rxplayerEngine.setWantedBufferAhead(30),r.rxplayerEngine.setMaxBufferAhead(40)),null!=r.hlsEngine&&null!=r.hlsEngine&&(r.hlsEngine.destroy(),r.hlsEngine=null);break;case o.HSS:r.rxplayerEngine=new $a({videoElement:r.videoEngine}),r.rxplayerEngine.loadVideo({url:n,transport:"smooth",autoPlay:r.autoplay});break;case o.PROGRESSIVE:new $a({videoElement:r.videoEngine}).loadVideo({url:n,transport:"directfile",autoPlay:r.autoplay});break;default:return Ro(r,Xa.InvalidProtocol,"Protocol not supported: "+o[i]+" (".concat(i,")")),[2]}return w(T.Info,"MainStreaming Player Loaded"),r.init=!0,r.globalEventsHandler=new Fo(r),r.haveControls&&(r.keyboardEventHandler=new Yo(r)),w(T.Info,"Post Erogating content..."),[4,function(i,t,n){var r,a;void 0===n&&(n=null);return g(this,void 0,void 0,function(){return v(this,function(e){switch(e.label){case 0:return(i.contentInfo.contentType==S.PlaylistLoop&&i.videoEngine.addEventListener("loadeddata",function(e){w(T.Info,"Seeking PL to: "+ku.PL_SEEK_TIME),i.rxplayerEngine?i.rxplayerEngine.seekTo(ku.PL_SEEK_TIME):i.videoEngine.currentTime=ku.PL_SEEK_TIME}),M.isLiveContent(i.contentInfo.contentType)&&Co(i),i.autoplay||null!=i.currentSkin&&null!=i.currentSkin&&i.currentSkin.getPoster().displayPoster(),$o(i),Go.needsHeartBeat(i)&&(w(T.Info,"Live manifest URL: "+i.liveUrlContent),Go.heartbeatPolling(i)),i.castManager=new ol(i,t,"mpd"),Ou.injectPlayerCSS(i),i.resizePlayer(!0),null==i.options.skinOptions.vastUrl||null==i.options.skinOptions.vastUrl||""==i.options.skinOptions.vastUrl)?[3,2]:(i.adManager=new al(i),[4,i.adManager.loadIMA()]);case 1:e.sent(),e.label=2;case 2:return M.isLiveContent(i.contentInfo.contentType)?[4,Go.heartbeatFetch(i)]:[3,4];case 3:e.sent(),Go.isLive()?i.live=!0:(i.live=!1,l.LIVE_OFFLINE_POSTER_SHOWN=!0,null!=i.currentSkin&&null!=i.currentSkin&&(null!=(r=i.currentSkin.getOnAir())&&r.setOffline(),i.setPoster()),i.contentInfo.alternativeContentInfo.alternativeContentPlaying||i.playAlternativeContent()),e.label=4;case 4:return null!=n&&(null!=i.currentSkin&&null!=i.currentSkin&&(null!=(r=i.currentSkin.getVolumeButton())&&r.setVolume(n.volume),n.volume<=0)&&(i.setVolume(n.currentVolume),null!=(a=i.currentSkin.getVolumeButton()))&&a.mute(i),n.fullScreen)&&null!=i.currentSkin&&null!=i.currentSkin&&null!=i.currentSkin.getFullscreenButton()&&i.currentSkin.getFullscreenButton().enterFS(i.divPlayer),null!=n&&null!=n.liveUrlContent&&null!=n.liveUrlContent&&(i.liveUrlContent=n.liveUrlContent),M.isAudio(i.contentInfo.contentType)&&(i.autoplay?i.videoEngine.onvolumechange=function(e){var t;null!=(t=i.currentSkin.getAudioEQ())&&t.started||i.currentSkin.getAudioEQ().audioEQStart()}:i.videoEngine.onplay=function(e){var t;null!=(t=i.currentSkin.getAudioEQ())&&t.started||i.currentSkin.getAudioEQ().audioEQStart()}),i.globalEventsHandler.triggerEvent("firstload",{msg:"The player has been loaded correctly",inst:i}),[2,i]}})})}(r,n,a)];case 1:return[2,e.sent()]}})})}(t,i,n,r)];case 3:return[2,e.sent()]}})})}function Uu(e){if(null!=e)return null!=e.keyboardEventHandler&&null!=e.keyboardEventHandler&&(e.keyboardEventHandler=null),null!=e.globalEventsHandler&&null!=e.globalEventsHandler&&(e.globalEventsHandler=null),null!=e.hlsEngine&&(e.pause(),e.hlsEngine.stopLoad(),e.hlsEngine.destroy()),null!=e.rxplayerEngine&&(e.pause(),e.rxplayerEngine.pause(),e.rxplayerEngine.stop(),e.rxplayerEngine.dispose()),e.videoEngine.innerHTML="",e.rxplayerEngine=null,e.hlsEngine=null,e.init=!1,!(e=null)}_.PreErogation=Fu,_.SetHeartBeatContentLive=function(e){Go.heartbeatLive(e)},_.Startup=function(e){var l,u=e.domID,d=e.contentID,t=e.oldPlayer,c=void 0===t?null:t,h=void 0===(t=e.playlistIndex)?null:t,f=void 0===(t=e.originalContentID)?null:t;e.contentInfo;var p=void 0===(t=e.playerOptions)?null:t;return e.customManifest,g(this,void 0,void 0,function(){var t,i,n,r,a,s,o;return v(this,function(e){switch(e.label){case 0:return(null==d&&w(T.Error,"Cannot load MainStreaming Player without contentID!!"),w(T.Info,"Loading MainStreaming Player V"+as.version),w(T.Info,"Player will be attached to ID: "+u),(t=null)!=c&&(Uu(c),c=null),(t=new Ru).init=!1,ku.createPlayerDOM(t,u),null==p.customManifest||""==p.customManifest||null==p.customManifest)?[3,2]:null==(i=qa.calculateProtocol(t,p.customManifest,p.customProtocol))?[2,null]:(t.options=new Lo,t.options.adsOptions=new Io,t.options.adsOptions.adsEnabled=!1,xo(t,t.options),w(T.Info,"Loading default contentInfo"),t.contentInfo=new ts,t.contentInfo.contentType=S.Undefined,w(T.Info,"Loading default font..."),ws.loadFont(bs.OPEN_SANS),Co(t),ko(t.contentInfo.settings,t,p),t.contentInfo.title="Custom Content",Po(t),w(T.Info,"Loading default skin..."),t.currentSkin=new Du(t),t.currentSkin.generateSkin(),w(T.Info,"Pre-Erogating content..."),[4,Fu(i,p.customManifest,t)]);case 1:return[2,e.sent()];case 2:return(xo(t,p),null!=p.contentInfo)?[3,4]:(w(T.Info,"Retriving content information from API"),i=Zo.generateContentAPICall(d,null==p?void 0:p.skinId,null==p?void 0:p.requestHost),n=t,[4,yl.generateContentByAPI(t,i,h,f,p)]);case 3:return n.contentInfo=e.sent(),[3,6];case 4:return w(T.Info,"Retriving content information from embedded config"),r=t,[4,yl.generateContentByConfig({testConfig:p.contentInfo,status:Ka.Ready,player:t,playlistIndex:h,originalContentID:f,playerOptions:p})];case 5:r.contentInfo=e.sent(),e.label=6;case 6:return t.currentSkinId=null!=(l=null==p?void 0:p.skinId)?l:null,ko(t.contentInfo.settings,t,p),Po(t),null==t.contentInfo||null==t.contentInfo?[2,null]:t.contentInfo.contentType!=S.PlaylistLoop?[3,9]:[4,yl.calculatePlaylistLoopStartingPoint(t,d,p.requestHost)];case 7:return s=e.sent(),t.contentInfo.sources.hls=vl.generateHlsSourceFromContentID(t.contentInfo,s.contentID,p.SecurityTokenQS),t.contentInfo.sources.dash=vl.generateDashSourceFromContentID(t.contentInfo,s.contentID,p.SecurityTokenQS),ku.PL_SEEK_TIME=s.startTime,a=t,[4,yl.getContentInfoFromContent(t.contentInfo,s.contentID,t.options.requestHost)];case 8:a.contentInfo=e.sent(),e.label=9;case 9:return M.isLiveContent(t.contentInfo.contentType)||Co(t),ws.loadFont(bs.OPEN_SANS),m.iphone()?(w(T.Info,"Skin won't be loaded, using native player (iOS devices only)"),t.contentInfo.contentType!=S.PlaylistLoop&&(s=t.contentInfo.hostname,o=t.contentInfo.contentID,o=dl.createURL(s,o),t.videoEngine.poster=o)):ku.loadSkin(t),o=ku.checkProtocolErogation(t),M.isLiveContent(t.contentInfo.contentType)&&(t.liveUrlContent=o),w(T.Info,"Pre-Erogating content..."),[4,Fu(t.contentInfo.protocol,o,t)];case 10:return[2,e.sent()]}})})},_.dispose=Uu}); //# sourceMappingURL=_playerV2.js.map