UNPKG

@uploadcare/uc-video

Version:

Uploadcare's UCVideo solution for adaptive bitrate streaming

12 lines (11 loc) 760 kB
(function(Ci,ui){typeof exports=="object"&&typeof module<"u"?ui(exports):typeof define=="function"&&define.amd?define(["exports"],ui):(Ci=typeof globalThis<"u"?globalThis:Ci||self,ui(Ci["uc-video"]={}))})(this,(function(Ci){"use strict";var ui=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function js(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function vf(s){if(Object.prototype.hasOwnProperty.call(s,"__esModule"))return s;var e=s.default;if(typeof e=="function"){var t=function i(){var r=!1;try{r=this instanceof i}catch{}return r?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(s).forEach(function(i){var r=Object.getOwnPropertyDescriptor(s,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return s[i]}})}),t}var Jn,rl;function Tr(){if(rl)return Jn;rl=1;var s;return typeof window<"u"?s=window:typeof ui<"u"?s=ui:typeof self<"u"?s=self:s={},Jn=s,Jn}var yf=Tr();const w=js(yf),_f=vf(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Zn,nl;function al(){if(nl)return Zn;nl=1;var s=typeof ui<"u"?ui:typeof window<"u"?window:{},e=_f,t;return typeof document<"u"?t=document:(t=s["__GLOBAL_DOCUMENT_CACHE@4"],t||(t=s["__GLOBAL_DOCUMENT_CACHE@4"]=e)),Zn=t,Zn}var bf=al();const se=js(bf);var xr={exports:{}},ea={exports:{}},ol;function Tf(){return ol||(ol=1,(function(s){function e(){return s.exports=e=Object.assign?Object.assign.bind():function(t){for(var i=1;i<arguments.length;i++){var r=arguments[i];for(var n in r)({}).hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},s.exports.__esModule=!0,s.exports.default=s.exports,e.apply(null,arguments)}s.exports=e,s.exports.__esModule=!0,s.exports.default=s.exports})(ea)),ea.exports}var ta,ll;function xf(){if(ll)return ta;ll=1,ta=e;var s=Object.prototype.toString;function e(t){if(!t)return!1;var i=s.call(t);return i==="[object Function]"||typeof t=="function"&&i!=="[object RegExp]"||typeof window<"u"&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)}return ta}var ia,ul;function Sf(){if(ul)return ia;ul=1;function s(r,n){var a=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(a)return(a=a.call(r)).next.bind(a);if(Array.isArray(r)||(a=e(r))||n){a&&(r=a);var l=0;return function(){return l>=r.length?{done:!0}:{done:!1,value:r[l++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function e(r,n){if(r){if(typeof r=="string")return t(r,n);var a=Object.prototype.toString.call(r).slice(8,-1);if(a==="Object"&&r.constructor&&(a=r.constructor.name),a==="Map"||a==="Set")return Array.from(r);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return t(r,n)}}function t(r,n){(n==null||n>r.length)&&(n=r.length);for(var a=0,l=new Array(n);a<n;a++)l[a]=r[a];return l}var i=(function(){function r(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1}var n=r.prototype;return n.getIsEnabled=function(){return this.enabled_},n.enable=function(){this.enabled_=!0},n.disable=function(){this.enabled_=!1},n.reset=function(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1},n.addInterceptor=function(l,c){this.typeToInterceptorsMap_.has(l)||this.typeToInterceptorsMap_.set(l,new Set);var f=this.typeToInterceptorsMap_.get(l);return f.has(c)?!1:(f.add(c),!0)},n.removeInterceptor=function(l,c){var f=this.typeToInterceptorsMap_.get(l);return f&&f.has(c)?(f.delete(c),!0):!1},n.clearInterceptorsByType=function(l){var c=this.typeToInterceptorsMap_.get(l);return c?(this.typeToInterceptorsMap_.delete(l),this.typeToInterceptorsMap_.set(l,new Set),!0):!1},n.clear=function(){return this.typeToInterceptorsMap_.size?(this.typeToInterceptorsMap_=new Map,!0):!1},n.getForType=function(l){return this.typeToInterceptorsMap_.get(l)||new Set},n.execute=function(l,c){for(var f=this.getForType(l),g=s(f),y;!(y=g()).done;){var k=y.value;try{c=k(c)}catch{}}return c},r})();return ia=i,ia}var sa,cl;function Ef(){if(cl)return sa;cl=1;var s=(function(){function t(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1}var i=t.prototype;return i.getIsEnabled=function(){return this.enabled_},i.enable=function(){this.enabled_=!0},i.disable=function(){this.enabled_=!1},i.reset=function(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1},i.getMaxAttempts=function(){return this.maxAttempts_},i.setMaxAttempts=function(n){this.maxAttempts_=n},i.getDelayFactor=function(){return this.delayFactor_},i.setDelayFactor=function(n){this.delayFactor_=n},i.getFuzzFactor=function(){return this.fuzzFactor_},i.setFuzzFactor=function(n){this.fuzzFactor_=n},i.getInitialDelay=function(){return this.initialDelay_},i.setInitialDelay=function(n){this.initialDelay_=n},i.createRetry=function(n){var a=n===void 0?{}:n,l=a.maxAttempts,c=a.delayFactor,f=a.fuzzFactor,g=a.initialDelay;return new e({maxAttempts:l||this.maxAttempts_,delayFactor:c||this.delayFactor_,fuzzFactor:f||this.fuzzFactor_,initialDelay:g||this.initialDelay_})},t})(),e=(function(){function t(r){this.maxAttempts_=r.maxAttempts,this.delayFactor_=r.delayFactor,this.fuzzFactor_=r.fuzzFactor,this.currentDelay_=r.initialDelay,this.currentAttempt_=1}var i=t.prototype;return i.moveToNextAttempt=function(){this.currentAttempt_++;var n=this.currentDelay_*this.delayFactor_;this.currentDelay_=this.currentDelay_+n},i.shouldRetry=function(){return this.currentAttempt_<this.maxAttempts_},i.getCurrentDelay=function(){return this.currentDelay_},i.getCurrentMinPossibleDelay=function(){return(1-this.fuzzFactor_)*this.currentDelay_},i.getCurrentMaxPossibleDelay=function(){return(1+this.fuzzFactor_)*this.currentDelay_},i.getCurrentFuzzedDelay=function(){var n=this.getCurrentMinPossibleDelay(),a=this.getCurrentMaxPossibleDelay();return n+Math.random()*(a-n)},t})();return sa=s,sa}var ra,dl;function Cf(){if(dl)return ra;dl=1;var s=Tr(),e=function(r,n){return n===void 0&&(n=!1),function(a,l,c){if(a){r(a);return}if(l.statusCode>=400&&l.statusCode<=599){var f=c;if(n)if(s.TextDecoder){var g=t(l.headers&&l.headers["content-type"]);try{f=new TextDecoder(g).decode(c)}catch{}}else f=String.fromCharCode.apply(null,new Uint8Array(c));r({cause:f});return}r(null,c)}};function t(i){return i===void 0&&(i=""),i.toLowerCase().split(";").reduce(function(r,n){var a=n.split("="),l=a[0],c=a[1];return l.trim()==="charset"?c.trim():r},"utf-8")}return ra=e,ra}var hl;function Af(){if(hl)return xr.exports;hl=1;var s=Tr(),e=Tf(),t=xf(),i=Sf(),r=Ef();f.httpHandler=Cf(),f.requestInterceptorsStorage=new i,f.responseInterceptorsStorage=new i,f.retryManager=new r;var n=function(O){var _={};return O&&O.trim().split(` `).forEach(function(j){var B=j.indexOf(":"),M=j.slice(0,B).trim().toLowerCase(),P=j.slice(B+1).trim();typeof _[M]>"u"?_[M]=P:Array.isArray(_[M])?_[M].push(P):_[M]=[_[M],P]}),_};xr.exports=f,xr.exports.default=f,f.XMLHttpRequest=s.XMLHttpRequest||k,f.XDomainRequest="withCredentials"in new f.XMLHttpRequest?f.XMLHttpRequest:s.XDomainRequest,a(["get","put","post","patch","head","delete"],function(C){f[C==="delete"?"del":C]=function(O,_,j){return _=c(O,_,j),_.method=C.toUpperCase(),g(_)}});function a(C,O){for(var _=0;_<C.length;_++)O(C[_])}function l(C){for(var O in C)if(C.hasOwnProperty(O))return!1;return!0}function c(C,O,_){var j=C;return t(O)?(_=O,typeof C=="string"&&(j={uri:C})):j=e({},O,{uri:C}),j.callback=_,j}function f(C,O,_){return O=c(C,O,_),g(O)}function g(C){if(typeof C.callback>"u")throw new Error("callback argument missing");if(C.requestType&&f.requestInterceptorsStorage.getIsEnabled()){var O={uri:C.uri||C.url,headers:C.headers||{},body:C.body,metadata:C.metadata||{},retry:C.retry,timeout:C.timeout},_=f.requestInterceptorsStorage.execute(C.requestType,O);C.uri=_.uri,C.headers=_.headers,C.body=_.body,C.metadata=_.metadata,C.retry=_.retry,C.timeout=_.timeout}var j=!1,B=function(Z,J,te){j||(j=!0,C.callback(Z,J,te))};function M(){F.readyState===4&&!f.responseInterceptorsStorage.getIsEnabled()&&setTimeout(L,0)}function P(){var W=void 0;if(F.response?W=F.response:W=F.responseText||y(F),Q)try{W=JSON.parse(W)}catch{}return W}function $(W){if(clearTimeout(ie),clearTimeout(C.retryTimeout),W instanceof Error||(W=new Error(""+(W||"Unknown XMLHttpRequest Error"))),W.statusCode=0,!K&&f.retryManager.getIsEnabled()&&C.retry&&C.retry.shouldRetry()){C.retryTimeout=setTimeout(function(){C.retry.moveToNextAttempt(),C.xhr=F,g(C)},C.retry.getCurrentFuzzedDelay());return}if(C.requestType&&f.responseInterceptorsStorage.getIsEnabled()){var Z={headers:re.headers||{},body:re.body,responseUrl:F.responseURL,responseType:F.responseType},J=f.responseInterceptorsStorage.execute(C.requestType,Z);re.body=J.body,re.headers=J.headers}return B(W,re)}function L(){if(!K){var W;clearTimeout(ie),clearTimeout(C.retryTimeout),C.useXDR&&F.status===void 0?W=200:W=F.status===1223?204:F.status;var Z=re,J=null;if(W!==0?(Z={body:P(),statusCode:W,method:E,headers:{},url:b,rawRequest:F},F.getAllResponseHeaders&&(Z.headers=n(F.getAllResponseHeaders()))):J=new Error("Internal XMLHttpRequest Error"),C.requestType&&f.responseInterceptorsStorage.getIsEnabled()){var te={headers:Z.headers||{},body:Z.body,responseUrl:F.responseURL,responseType:F.responseType},ee=f.responseInterceptorsStorage.execute(C.requestType,te);Z.body=ee.body,Z.headers=ee.headers}return B(J,Z,Z.body)}}var F=C.xhr||null;F||(C.cors||C.useXDR?F=new f.XDomainRequest:F=new f.XMLHttpRequest);var z,K,b=F.url=C.uri||C.url,E=F.method=C.method||"GET",U=C.body||C.data,V=F.headers=C.headers||{},q=!!C.sync,Q=!1,ie,re={body:void 0,headers:{},statusCode:0,method:E,url:b,rawRequest:F};if("json"in C&&C.json!==!1&&(Q=!0,V.accept||V.Accept||(V.Accept="application/json"),E!=="GET"&&E!=="HEAD"&&(V["content-type"]||V["Content-Type"]||(V["Content-Type"]="application/json"),U=JSON.stringify(C.json===!0?U:C.json))),F.onreadystatechange=M,F.onload=L,F.onerror=$,F.onprogress=function(){},F.onabort=function(){K=!0,clearTimeout(C.retryTimeout)},F.ontimeout=$,F.open(E,b,!q,C.username,C.password),q||(F.withCredentials=!!C.withCredentials),!q&&C.timeout>0&&(ie=setTimeout(function(){if(!K){K=!0,F.abort("timeout");var W=new Error("XMLHttpRequest timeout");W.code="ETIMEDOUT",$(W)}},C.timeout)),F.setRequestHeader)for(z in V)V.hasOwnProperty(z)&&F.setRequestHeader(z,V[z]);else if(C.headers&&!l(C.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in C&&(F.responseType=C.responseType),"beforeSend"in C&&typeof C.beforeSend=="function"&&C.beforeSend(F),F.send(U||null),F}function y(C){try{if(C.responseType==="document")return C.responseXML;var O=C.responseXML&&C.responseXML.documentElement.nodeName==="parsererror";if(C.responseType===""&&!O)return C.responseXML}catch{}return null}function k(){}return xr.exports}var wf=Af();const fl=js(wf);var na={exports:{}},aa,pl;function Df(){if(pl)return aa;pl=1;var s=al(),e=Object.create||(function(){function b(){}return function(E){if(arguments.length!==1)throw new Error("Object.create shim only accepts one parameter.");return b.prototype=E,new b}})();function t(b,E){this.name="ParsingError",this.code=b.code,this.message=E||b.message}t.prototype=e(Error.prototype),t.prototype.constructor=t,t.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}};function i(b){function E(V,q,Q,ie){return(V|0)*3600+(q|0)*60+(Q|0)+(ie|0)/1e3}var U=b.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);return U?U[3]?E(U[1],U[2],U[3].replace(":",""),U[4]):U[1]>59?E(U[1],U[2],0,U[4]):E(0,U[1],U[2],U[4]):null}function r(){this.values=e(null)}r.prototype={set:function(b,E){!this.get(b)&&E!==""&&(this.values[b]=E)},get:function(b,E,U){return U?this.has(b)?this.values[b]:E[U]:this.has(b)?this.values[b]:E},has:function(b){return b in this.values},alt:function(b,E,U){for(var V=0;V<U.length;++V)if(E===U[V]){this.set(b,E);break}},integer:function(b,E){/^-?\d+$/.test(E)&&this.set(b,parseInt(E,10))},percent:function(b,E){return E.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(E=parseFloat(E),E>=0&&E<=100)?(this.set(b,E),!0):!1}};function n(b,E,U,V){var q=V?b.split(V):[b];for(var Q in q)if(typeof q[Q]=="string"){var ie=q[Q].split(U);if(ie.length===2){var re=ie[0].trim(),W=ie[1].trim();E(re,W)}}}function a(b,E,U){var V=b;function q(){var re=i(b);if(re===null)throw new t(t.Errors.BadTimeStamp,"Malformed timestamp: "+V);return b=b.replace(/^[^\sa-zA-Z-]+/,""),re}function Q(re,W){var Z=new r;n(re,function(J,te){switch(J){case"region":for(var ee=U.length-1;ee>=0;ee--)if(U[ee].id===te){Z.set(J,U[ee].region);break}break;case"vertical":Z.alt(J,te,["rl","lr"]);break;case"line":var fe=te.split(","),me=fe[0];Z.integer(J,me),Z.percent(J,me)&&Z.set("snapToLines",!1),Z.alt(J,me,["auto"]),fe.length===2&&Z.alt("lineAlign",fe[1],["start","center","end"]);break;case"position":fe=te.split(","),Z.percent(J,fe[0]),fe.length===2&&Z.alt("positionAlign",fe[1],["start","center","end"]);break;case"size":Z.percent(J,te);break;case"align":Z.alt(J,te,["start","center","end","left","right"]);break}},/:/,/\s/),W.region=Z.get("region",null),W.vertical=Z.get("vertical","");try{W.line=Z.get("line","auto")}catch{}W.lineAlign=Z.get("lineAlign","start"),W.snapToLines=Z.get("snapToLines",!0),W.size=Z.get("size",100);try{W.align=Z.get("align","center")}catch{W.align=Z.get("align","middle")}try{W.position=Z.get("position","auto")}catch{W.position=Z.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},W.align)}W.positionAlign=Z.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},W.align)}function ie(){b=b.replace(/^\s+/,"")}if(ie(),E.startTime=q(),ie(),b.substr(0,3)!=="-->")throw new t(t.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '-->'): "+V);b=b.substr(3),ie(),E.endTime=q(),ie(),Q(b,E)}var l=s.createElement&&s.createElement("textarea"),c={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},f={white:"rgba(255,255,255,1)",lime:"rgba(0,255,0,1)",cyan:"rgba(0,255,255,1)",red:"rgba(255,0,0,1)",yellow:"rgba(255,255,0,1)",magenta:"rgba(255,0,255,1)",blue:"rgba(0,0,255,1)",black:"rgba(0,0,0,1)"},g={v:"title",lang:"lang"},y={rt:"ruby"};function k(b,E){function U(){if(!E)return null;function me(he){return E=E.substr(he.length),he}var ve=E.match(/^([^<]*)(<[^>]*>?)?/);return me(ve[1]?ve[1]:ve[2])}function V(me){return l.innerHTML=me,me=l.textContent,l.textContent="",me}function q(me,ve){return!y[ve.localName]||y[ve.localName]===me.localName}function Q(me,ve){var he=c[me];if(!he)return null;var Ke=b.document.createElement(he),tt=g[me];return tt&&ve&&(Ke[tt]=ve.trim()),Ke}for(var ie=b.document.createElement("div"),re=ie,W,Z=[];(W=U())!==null;){if(W[0]==="<"){if(W[1]==="/"){Z.length&&Z[Z.length-1]===W.substr(2).replace(">","")&&(Z.pop(),re=re.parentNode);continue}var J=i(W.substr(1,W.length-2)),te;if(J){te=b.document.createProcessingInstruction("timestamp",J),re.appendChild(te);continue}var ee=W.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!ee||(te=Q(ee[1],ee[3]),!te)||!q(re,te))continue;if(ee[2]){var fe=ee[2].split(".");fe.forEach(function(me){var ve=/^bg_/.test(me),he=ve?me.slice(3):me;if(f.hasOwnProperty(he)){var Ke=ve?"background-color":"color",tt=f[he];te.style[Ke]=tt}}),te.className=fe.join(" ")}Z.push(ee[1]),re.appendChild(te),re=te;continue}re.appendChild(b.document.createTextNode(V(W)))}return ie}var C=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function O(b){for(var E=0;E<C.length;E++){var U=C[E];if(b>=U[0]&&b<=U[1])return!0}return!1}function _(b){var E=[],U="",V;if(!b||!b.childNodes)return"ltr";function q(re,W){for(var Z=W.childNodes.length-1;Z>=0;Z--)re.push(W.childNodes[Z])}function Q(re){if(!re||!re.length)return null;var W=re.pop(),Z=W.textContent||W.innerText;if(Z){var J=Z.match(/^.*(\n|\r)/);return J?(re.length=0,J[0]):Z}if(W.tagName==="ruby")return Q(re);if(W.childNodes)return q(re,W),Q(re)}for(q(E,b);U=Q(E);)for(var ie=0;ie<U.length;ie++)if(V=U.charCodeAt(ie),O(V))return"rtl";return"ltr"}function j(b){if(typeof b.line=="number"&&(b.snapToLines||b.line>=0&&b.line<=100))return b.line;if(!b.track||!b.track.textTrackList||!b.track.textTrackList.mediaElement)return-1;for(var E=b.track,U=E.textTrackList,V=0,q=0;q<U.length&&U[q]!==E;q++)U[q].mode==="showing"&&V++;return++V*-1}function B(){}B.prototype.applyStyles=function(b,E){E=E||this.div;for(var U in b)b.hasOwnProperty(U)&&(E.style[U]=b[U])},B.prototype.formatStyle=function(b,E){return b===0?0:b+E};function M(b,E,U){B.call(this),this.cue=E,this.cueDiv=k(b,E.text);var V={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:E.vertical===""?"horizontal-tb":E.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(V,this.cueDiv),this.div=b.document.createElement("div"),V={direction:_(this.cueDiv),writingMode:E.vertical===""?"horizontal-tb":E.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:E.align==="middle"?"center":E.align,font:U.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(V),this.div.appendChild(this.cueDiv);var q=0;switch(E.positionAlign){case"start":case"line-left":q=E.position;break;case"center":q=E.position-E.size/2;break;case"end":case"line-right":q=E.position-E.size;break}E.vertical===""?this.applyStyles({left:this.formatStyle(q,"%"),width:this.formatStyle(E.size,"%")}):this.applyStyles({top:this.formatStyle(q,"%"),height:this.formatStyle(E.size,"%")}),this.move=function(Q){this.applyStyles({top:this.formatStyle(Q.top,"px"),bottom:this.formatStyle(Q.bottom,"px"),left:this.formatStyle(Q.left,"px"),right:this.formatStyle(Q.right,"px"),height:this.formatStyle(Q.height,"px"),width:this.formatStyle(Q.width,"px")})}}M.prototype=e(B.prototype),M.prototype.constructor=M;function P(b){var E,U,V,q;if(b.div){U=b.div.offsetHeight,V=b.div.offsetWidth,q=b.div.offsetTop;var Q=(Q=b.div.childNodes)&&(Q=Q[0])&&Q.getClientRects&&Q.getClientRects();b=b.div.getBoundingClientRect(),E=Q?Math.max(Q[0]&&Q[0].height||0,b.height/Q.length):0}this.left=b.left,this.right=b.right,this.top=b.top||q,this.height=b.height||U,this.bottom=b.bottom||q+(b.height||U),this.width=b.width||V,this.lineHeight=E!==void 0?E:b.lineHeight}P.prototype.move=function(b,E){switch(E=E!==void 0?E:this.lineHeight,b){case"+x":this.left+=E,this.right+=E;break;case"-x":this.left-=E,this.right-=E;break;case"+y":this.top+=E,this.bottom+=E;break;case"-y":this.top-=E,this.bottom-=E;break}},P.prototype.overlaps=function(b){return this.left<b.right&&this.right>b.left&&this.top<b.bottom&&this.bottom>b.top},P.prototype.overlapsAny=function(b){for(var E=0;E<b.length;E++)if(this.overlaps(b[E]))return!0;return!1},P.prototype.within=function(b){return this.top>=b.top&&this.bottom<=b.bottom&&this.left>=b.left&&this.right<=b.right},P.prototype.overlapsOppositeAxis=function(b,E){switch(E){case"+x":return this.left<b.left;case"-x":return this.right>b.right;case"+y":return this.top<b.top;case"-y":return this.bottom>b.bottom}},P.prototype.intersectPercentage=function(b){var E=Math.max(0,Math.min(this.right,b.right)-Math.max(this.left,b.left)),U=Math.max(0,Math.min(this.bottom,b.bottom)-Math.max(this.top,b.top)),V=E*U;return V/(this.height*this.width)},P.prototype.toCSSCompatValues=function(b){return{top:this.top-b.top,bottom:b.bottom-this.bottom,left:this.left-b.left,right:b.right-this.right,height:this.height,width:this.width}},P.getSimpleBoxPosition=function(b){var E=b.div?b.div.offsetHeight:b.tagName?b.offsetHeight:0,U=b.div?b.div.offsetWidth:b.tagName?b.offsetWidth:0,V=b.div?b.div.offsetTop:b.tagName?b.offsetTop:0;b=b.div?b.div.getBoundingClientRect():b.tagName?b.getBoundingClientRect():b;var q={left:b.left,right:b.right,top:b.top||V,height:b.height||E,bottom:b.bottom||V+(b.height||E),width:b.width||U};return q};function $(b,E,U,V){function q(he,Ke){for(var tt,He=new P(he),it=1,Ct=0;Ct<Ke.length;Ct++){for(;he.overlapsOppositeAxis(U,Ke[Ct])||he.within(U)&&he.overlapsAny(V);)he.move(Ke[Ct]);if(he.within(U))return he;var Qe=he.intersectPercentage(U);it>Qe&&(tt=new P(he),it=Qe),he=new P(He)}return tt||He}var Q=new P(E),ie=E.cue,re=j(ie),W=[];if(ie.snapToLines){var Z;switch(ie.vertical){case"":W=["+y","-y"],Z="height";break;case"rl":W=["+x","-x"],Z="width";break;case"lr":W=["-x","+x"],Z="width";break}var J=Q.lineHeight,te=J*Math.round(re),ee=U[Z]+J,fe=W[0];Math.abs(te)>ee&&(te=te<0?-1:1,te*=Math.ceil(ee/J)*J),re<0&&(te+=ie.vertical===""?U.height:U.width,W=W.reverse()),Q.move(fe,te)}else{var me=Q.lineHeight/U.height*100;switch(ie.lineAlign){case"center":re-=me/2;break;case"end":re-=me;break}switch(ie.vertical){case"":E.applyStyles({top:E.formatStyle(re,"%")});break;case"rl":E.applyStyles({left:E.formatStyle(re,"%")});break;case"lr":E.applyStyles({right:E.formatStyle(re,"%")});break}W=["+y","-x","+x","-y"],Q=new P(E)}var ve=q(Q,W);E.move(ve.toCSSCompatValues(U))}function L(){}L.StringDecoder=function(){return{decode:function(b){if(!b)return"";if(typeof b!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(b))}}},L.convertCueToDOMTree=function(b,E){return!b||!E?null:k(b,E)};var F=.05,z="sans-serif",K="1.5%";return L.processCues=function(b,E,U){if(!b||!E||!U)return null;for(;U.firstChild;)U.removeChild(U.firstChild);var V=b.document.createElement("div");V.style.position="absolute",V.style.left="0",V.style.right="0",V.style.top="0",V.style.bottom="0",V.style.margin=K,U.appendChild(V);function q(J){for(var te=0;te<J.length;te++)if(J[te].hasBeenReset||!J[te].displayState)return!0;return!1}if(!q(E)){for(var Q=0;Q<E.length;Q++)V.appendChild(E[Q].displayState);return}var ie=[],re=P.getSimpleBoxPosition(V),W=Math.round(re.height*F*100)/100,Z={font:W+"px "+z};(function(){for(var J,te,ee=0;ee<E.length;ee++)te=E[ee],J=new M(b,te,Z),V.appendChild(J.div),$(b,J,re,ie),te.displayState=J.div,ie.push(P.getSimpleBoxPosition(J))})()},L.Parser=function(b,E,U){U||(U=E,E={}),E||(E={}),this.window=b,this.vttjs=E,this.state="INITIAL",this.buffer="",this.decoder=U||new TextDecoder("utf8"),this.regionList=[]},L.Parser.prototype={reportOrThrowError:function(b){if(b instanceof t)this.onparsingerror&&this.onparsingerror(b);else throw b},parse:function(b){var E=this;b&&(E.buffer+=E.decoder.decode(b,{stream:!0}));function U(){for(var J=E.buffer,te=0;te<J.length&&J[te]!=="\r"&&J[te]!==` `;)++te;var ee=J.substr(0,te);return J[te]==="\r"&&++te,J[te]===` `&&++te,E.buffer=J.substr(te),ee}function V(J){var te=new r;if(n(J,function(fe,me){switch(fe){case"id":te.set(fe,me);break;case"width":te.percent(fe,me);break;case"lines":te.integer(fe,me);break;case"regionanchor":case"viewportanchor":var ve=me.split(",");if(ve.length!==2)break;var he=new r;if(he.percent("x",ve[0]),he.percent("y",ve[1]),!he.has("x")||!he.has("y"))break;te.set(fe+"X",he.get("x")),te.set(fe+"Y",he.get("y"));break;case"scroll":te.alt(fe,me,["up"]);break}},/=/,/\s/),te.has("id")){var ee=new(E.vttjs.VTTRegion||E.window.VTTRegion);ee.width=te.get("width",100),ee.lines=te.get("lines",3),ee.regionAnchorX=te.get("regionanchorX",0),ee.regionAnchorY=te.get("regionanchorY",100),ee.viewportAnchorX=te.get("viewportanchorX",0),ee.viewportAnchorY=te.get("viewportanchorY",100),ee.scroll=te.get("scroll",""),E.onregion&&E.onregion(ee),E.regionList.push({id:te.get("id"),region:ee})}}function q(J){var te=new r;n(J,function(ee,fe){switch(ee){case"MPEGT":te.integer(ee+"S",fe);break;case"LOCA":te.set(ee+"L",i(fe));break}},/[^\d]:/,/,/),E.ontimestampmap&&E.ontimestampmap({MPEGTS:te.get("MPEGTS"),LOCAL:te.get("LOCAL")})}function Q(J){J.match(/X-TIMESTAMP-MAP/)?n(J,function(te,ee){te==="X-TIMESTAMP-MAP"&&q(ee)},/=/):n(J,function(te,ee){te==="Region"&&V(ee)},/:/)}try{var ie;if(E.state==="INITIAL"){if(!/\r\n|\n/.test(E.buffer))return this;ie=U();var re=ie.match(/^WEBVTT([ \t].*)?$/);if(!re||!re[0])throw new t(t.Errors.BadSignature);E.state="HEADER"}for(var W=!1;E.buffer;){if(!/\r\n|\n/.test(E.buffer))return this;switch(W?W=!1:ie=U(),E.state){case"HEADER":/:/.test(ie)?Q(ie):ie||(E.state="ID");continue;case"NOTE":ie||(E.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(ie)){E.state="NOTE";break}if(!ie)continue;E.cue=new(E.vttjs.VTTCue||E.window.VTTCue)(0,0,"");try{E.cue.align="center"}catch{E.cue.align="middle"}if(E.state="CUE",ie.indexOf("-->")===-1){E.cue.id=ie;continue}case"CUE":try{a(ie,E.cue,E.regionList)}catch(J){E.reportOrThrowError(J),E.cue=null,E.state="BADCUE";continue}E.state="CUETEXT";continue;case"CUETEXT":var Z=ie.indexOf("-->")!==-1;if(!ie||Z&&(W=!0)){E.oncue&&E.oncue(E.cue),E.cue=null,E.state="ID";continue}E.cue.text&&(E.cue.text+=` `),E.cue.text+=ie.replace(/\u2028/g,` `).replace(/u2029/g,` `);continue;case"BADCUE":ie||(E.state="ID");continue}}}catch(J){E.reportOrThrowError(J),E.state==="CUETEXT"&&E.cue&&E.oncue&&E.oncue(E.cue),E.cue=null,E.state=E.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this},flush:function(){var b=this;try{if(b.buffer+=b.decoder.decode(),(b.cue||b.state==="HEADER")&&(b.buffer+=` `,b.parse()),b.state==="INITIAL")throw new t(t.Errors.BadSignature)}catch(E){b.reportOrThrowError(E)}return b.onflush&&b.onflush(),this}},aa=L,aa}var oa,ml;function kf(){if(ml)return oa;ml=1;var s="auto",e={"":1,lr:1,rl:1},t={start:1,center:1,end:1,left:1,right:1,auto:1,"line-left":1,"line-right":1};function i(a){if(typeof a!="string")return!1;var l=e[a.toLowerCase()];return l?a.toLowerCase():!1}function r(a){if(typeof a!="string")return!1;var l=t[a.toLowerCase()];return l?a.toLowerCase():!1}function n(a,l,c){this.hasBeenReset=!1;var f="",g=!1,y=a,k=l,C=c,O=null,_="",j=!0,B="auto",M="start",P="auto",$="auto",L=100,F="center";Object.defineProperties(this,{id:{enumerable:!0,get:function(){return f},set:function(z){f=""+z}},pauseOnExit:{enumerable:!0,get:function(){return g},set:function(z){g=!!z}},startTime:{enumerable:!0,get:function(){return y},set:function(z){if(typeof z!="number")throw new TypeError("Start time must be set to a number.");y=z,this.hasBeenReset=!0}},endTime:{enumerable:!0,get:function(){return k},set:function(z){if(typeof z!="number")throw new TypeError("End time must be set to a number.");k=z,this.hasBeenReset=!0}},text:{enumerable:!0,get:function(){return C},set:function(z){C=""+z,this.hasBeenReset=!0}},region:{enumerable:!0,get:function(){return O},set:function(z){O=z,this.hasBeenReset=!0}},vertical:{enumerable:!0,get:function(){return _},set:function(z){var K=i(z);if(K===!1)throw new SyntaxError("Vertical: an invalid or illegal direction string was specified.");_=K,this.hasBeenReset=!0}},snapToLines:{enumerable:!0,get:function(){return j},set:function(z){j=!!z,this.hasBeenReset=!0}},line:{enumerable:!0,get:function(){return B},set:function(z){if(typeof z!="number"&&z!==s)throw new SyntaxError("Line: an invalid number or illegal string was specified.");B=z,this.hasBeenReset=!0}},lineAlign:{enumerable:!0,get:function(){return M},set:function(z){var K=r(z);K?(M=K,this.hasBeenReset=!0):console.warn("lineAlign: an invalid or illegal string was specified.")}},position:{enumerable:!0,get:function(){return P},set:function(z){if(z<0||z>100)throw new Error("Position must be between 0 and 100.");P=z,this.hasBeenReset=!0}},positionAlign:{enumerable:!0,get:function(){return $},set:function(z){var K=r(z);K?($=K,this.hasBeenReset=!0):console.warn("positionAlign: an invalid or illegal string was specified.")}},size:{enumerable:!0,get:function(){return L},set:function(z){if(z<0||z>100)throw new Error("Size must be between 0 and 100.");L=z,this.hasBeenReset=!0}},align:{enumerable:!0,get:function(){return F},set:function(z){var K=r(z);if(!K)throw new SyntaxError("align: an invalid or illegal alignment string was specified.");F=K,this.hasBeenReset=!0}}}),this.displayState=void 0}return n.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)},oa=n,oa}var la,gl;function If(){if(gl)return la;gl=1;var s={"":!0,up:!0};function e(r){if(typeof r!="string")return!1;var n=s[r.toLowerCase()];return n?r.toLowerCase():!1}function t(r){return typeof r=="number"&&r>=0&&r<=100}function i(){var r=100,n=3,a=0,l=100,c=0,f=100,g="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return r},set:function(y){if(!t(y))throw new Error("Width must be between 0 and 100.");r=y}},lines:{enumerable:!0,get:function(){return n},set:function(y){if(typeof y!="number")throw new TypeError("Lines must be set to a number.");n=y}},regionAnchorY:{enumerable:!0,get:function(){return l},set:function(y){if(!t(y))throw new Error("RegionAnchorX must be between 0 and 100.");l=y}},regionAnchorX:{enumerable:!0,get:function(){return a},set:function(y){if(!t(y))throw new Error("RegionAnchorY must be between 0 and 100.");a=y}},viewportAnchorY:{enumerable:!0,get:function(){return f},set:function(y){if(!t(y))throw new Error("ViewportAnchorY must be between 0 and 100.");f=y}},viewportAnchorX:{enumerable:!0,get:function(){return c},set:function(y){if(!t(y))throw new Error("ViewportAnchorX must be between 0 and 100.");c=y}},scroll:{enumerable:!0,get:function(){return g},set:function(y){var k=e(y);k===!1?console.warn("Scroll: an invalid or illegal string was specified."):g=k}}})}return la=i,la}var vl;function jf(){if(vl)return na.exports;vl=1;var s=Tr(),e=na.exports={WebVTT:Df(),VTTCue:kf(),VTTRegion:If()};s.vttjs=e,s.WebVTT=e.WebVTT;var t=e.VTTCue,i=e.VTTRegion,r=s.VTTCue,n=s.VTTRegion;return e.shim=function(){s.VTTCue=t,s.VTTRegion=i},e.restore=function(){s.VTTCue=r,s.VTTRegion=n},s.VTTCue||e.shim(),na.exports}var Pf=jf();const yl=js(Pf);function Ne(){return Ne=Object.assign?Object.assign.bind():function(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},Ne.apply(null,arguments)}var _l="https://example.com",Sr=function(e,t){if(/^[a-z]+:/i.test(t))return t;/^data:/.test(e)&&(e=w.location&&w.location.href||"");var i=/^\/\//.test(e),r=!w.location&&!/\/\//i.test(e);e=new w.URL(e,w.location||_l);var n=new URL(t,e);return r?n.href.slice(_l.length):i?n.href.slice(n.protocol.length):n.href},ua=(function(){function s(){this.listeners={}}var e=s.prototype;return e.on=function(i,r){this.listeners[i]||(this.listeners[i]=[]),this.listeners[i].push(r)},e.off=function(i,r){if(!this.listeners[i])return!1;var n=this.listeners[i].indexOf(r);return this.listeners[i]=this.listeners[i].slice(0),this.listeners[i].splice(n,1),n>-1},e.trigger=function(i){var r=this.listeners[i];if(r)if(arguments.length===2)for(var n=r.length,a=0;a<n;++a)r[a].call(this,arguments[1]);else for(var l=Array.prototype.slice.call(arguments,1),c=r.length,f=0;f<c;++f)r[f].apply(this,l)},e.dispose=function(){this.listeners={}},e.pipe=function(i){this.on("data",function(r){i.push(r)})},s})(),Lf=function(e){return w.atob?w.atob(e):Buffer.from(e,"base64").toString("binary")};function bl(s){for(var e=Lf(s),t=new Uint8Array(e.length),i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}class Of extends ua{constructor(){super(),this.buffer=""}push(e){let t;for(this.buffer+=e,t=this.buffer.indexOf(` `);t>-1;t=this.buffer.indexOf(` `))this.trigger("data",this.buffer.substring(0,t)),this.buffer=this.buffer.substring(t+1)}}const Rf=" ",ca=function(s){const e=/([0-9.]*)?@?([0-9.]*)?/.exec(s||""),t={};return e[1]&&(t.length=parseInt(e[1],10)),e[2]&&(t.offset=parseInt(e[2],10)),t},Mf=function(){const t="(?:"+"[^=]*"+")=(?:"+'"[^"]*"|[^,]*'+")";return new RegExp("(?:^|,)("+t+")")},rt=function(s){const e={};if(!s)return e;const t=s.split(Mf());let i=t.length,r;for(;i--;)t[i]!==""&&(r=/([^=]*)=(.*)/.exec(t[i]).slice(1),r[0]=r[0].replace(/^\s+|\s+$/g,""),r[1]=r[1].replace(/^\s+|\s+$/g,""),r[1]=r[1].replace(/^['"](.*)['"]$/g,"$1"),e[r[0]]=r[1]);return e},Tl=s=>{const e=s.split("x"),t={};return e[0]&&(t.width=parseInt(e[0],10)),e[1]&&(t.height=parseInt(e[1],10)),t};class Nf extends ua{constructor(){super(),this.customParsers=[],this.tagMappers=[]}push(e){let t,i;if(e=e.trim(),e.length===0)return;if(e[0]!=="#"){this.trigger("data",{type:"uri",uri:e});return}this.tagMappers.reduce((n,a)=>{const l=a(e);return l===e?n:n.concat([l])},[e]).forEach(n=>{for(let a=0;a<this.customParsers.length;a++)if(this.customParsers[a].call(this,n))return;if(n.indexOf("#EXT")!==0){this.trigger("data",{type:"comment",text:n.slice(1)});return}if(n=n.replace("\r",""),t=/^#EXTM3U/.exec(n),t){this.trigger("data",{type:"tag",tagType:"m3u"});return}if(t=/^#EXTINF:([0-9\.]*)?,?(.*)?$/.exec(n),t){i={type:"tag",tagType:"inf"},t[1]&&(i.duration=parseFloat(t[1])),t[2]&&(i.title=t[2]),this.trigger("data",i);return}if(t=/^#EXT-X-TARGETDURATION:([0-9.]*)?/.exec(n),t){i={type:"tag",tagType:"targetduration"},t[1]&&(i.duration=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-VERSION:([0-9.]*)?/.exec(n),t){i={type:"tag",tagType:"version"},t[1]&&(i.version=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-MEDIA-SEQUENCE:(\-?[0-9.]*)?/.exec(n),t){i={type:"tag",tagType:"media-sequence"},t[1]&&(i.number=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-DISCONTINUITY-SEQUENCE:(\-?[0-9.]*)?/.exec(n),t){i={type:"tag",tagType:"discontinuity-sequence"},t[1]&&(i.number=parseInt(t[1],10)),this.trigger("data",i);return}if(t=/^#EXT-X-PLAYLIST-TYPE:(.*)?$/.exec(n),t){i={type:"tag",tagType:"playlist-type"},t[1]&&(i.playlistType=t[1]),this.trigger("data",i);return}if(t=/^#EXT-X-BYTERANGE:(.*)?$/.exec(n),t){i=Ne(ca(t[1]),{type:"tag",tagType:"byterange"}),this.trigger("data",i);return}if(t=/^#EXT-X-ALLOW-CACHE:(YES|NO)?/.exec(n),t){i={type:"tag",tagType:"allow-cache"},t[1]&&(i.allowed=!/NO/.test(t[1])),this.trigger("data",i);return}if(t=/^#EXT-X-MAP:(.*)$/.exec(n),t){if(i={type:"tag",tagType:"map"},t[1]){const a=rt(t[1]);a.URI&&(i.uri=a.URI),a.BYTERANGE&&(i.byterange=ca(a.BYTERANGE))}this.trigger("data",i);return}if(t=/^#EXT-X-STREAM-INF:(.*)$/.exec(n),t){i={type:"tag",tagType:"stream-inf"},t[1]&&(i.attributes=rt(t[1]),i.attributes.RESOLUTION&&(i.attributes.RESOLUTION=Tl(i.attributes.RESOLUTION)),i.attributes.BANDWIDTH&&(i.attributes.BANDWIDTH=parseInt(i.attributes.BANDWIDTH,10)),i.attributes["FRAME-RATE"]&&(i.attributes["FRAME-RATE"]=parseFloat(i.attributes["FRAME-RATE"])),i.attributes["PROGRAM-ID"]&&(i.attributes["PROGRAM-ID"]=parseInt(i.attributes["PROGRAM-ID"],10))),this.trigger("data",i);return}if(t=/^#EXT-X-MEDIA:(.*)$/.exec(n),t){i={type:"tag",tagType:"media"},t[1]&&(i.attributes=rt(t[1])),this.trigger("data",i);return}if(t=/^#EXT-X-ENDLIST/.exec(n),t){this.trigger("data",{type:"tag",tagType:"endlist"});return}if(t=/^#EXT-X-DISCONTINUITY/.exec(n),t){this.trigger("data",{type:"tag",tagType:"discontinuity"});return}if(t=/^#EXT-X-PROGRAM-DATE-TIME:(.*)$/.exec(n),t){i={type:"tag",tagType:"program-date-time"},t[1]&&(i.dateTimeString=t[1],i.dateTimeObject=new Date(t[1])),this.trigger("data",i);return}if(t=/^#EXT-X-KEY:(.*)$/.exec(n),t){i={type:"tag",tagType:"key"},t[1]&&(i.attributes=rt(t[1]),i.attributes.IV&&(i.attributes.IV.substring(0,2).toLowerCase()==="0x"&&(i.attributes.IV=i.attributes.IV.substring(2)),i.attributes.IV=i.attributes.IV.match(/.{8}/g),i.attributes.IV[0]=parseInt(i.attributes.IV[0],16),i.attributes.IV[1]=parseInt(i.attributes.IV[1],16),i.attributes.IV[2]=parseInt(i.attributes.IV[2],16),i.attributes.IV[3]=parseInt(i.attributes.IV[3],16),i.attributes.IV=new Uint32Array(i.attributes.IV))),this.trigger("data",i);return}if(t=/^#EXT-X-START:(.*)$/.exec(n),t){i={type:"tag",tagType:"start"},t[1]&&(i.attributes=rt(t[1]),i.attributes["TIME-OFFSET"]=parseFloat(i.attributes["TIME-OFFSET"]),i.attributes.PRECISE=/YES/.test(i.attributes.PRECISE)),this.trigger("data",i);return}if(t=/^#EXT-X-CUE-OUT-CONT:(.*)?$/.exec(n),t){i={type:"tag",tagType:"cue-out-cont"},t[1]?i.data=t[1]:i.data="",this.trigger("data",i);return}if(t=/^#EXT-X-CUE-OUT:(.*)?$/.exec(n),t){i={type:"tag",tagType:"cue-out"},t[1]?i.data=t[1]:i.data="",this.trigger("data",i);return}if(t=/^#EXT-X-CUE-IN:?(.*)?$/.exec(n),t){i={type:"tag",tagType:"cue-in"},t[1]?i.data=t[1]:i.data="",this.trigger("data",i);return}if(t=/^#EXT-X-SKIP:(.*)$/.exec(n),t&&t[1]){i={type:"tag",tagType:"skip"},i.attributes=rt(t[1]),i.attributes.hasOwnProperty("SKIPPED-SEGMENTS")&&(i.attributes["SKIPPED-SEGMENTS"]=parseInt(i.attributes["SKIPPED-SEGMENTS"],10)),i.attributes.hasOwnProperty("RECENTLY-REMOVED-DATERANGES")&&(i.attributes["RECENTLY-REMOVED-DATERANGES"]=i.attributes["RECENTLY-REMOVED-DATERANGES"].split(Rf)),this.trigger("data",i);return}if(t=/^#EXT-X-PART:(.*)$/.exec(n),t&&t[1]){i={type:"tag",tagType:"part"},i.attributes=rt(t[1]),["DURATION"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=parseFloat(i.attributes[a]))}),["INDEPENDENT","GAP"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=/YES/.test(i.attributes[a]))}),i.attributes.hasOwnProperty("BYTERANGE")&&(i.attributes.byterange=ca(i.attributes.BYTERANGE)),this.trigger("data",i);return}if(t=/^#EXT-X-SERVER-CONTROL:(.*)$/.exec(n),t&&t[1]){i={type:"tag",tagType:"server-control"},i.attributes=rt(t[1]),["CAN-SKIP-UNTIL","PART-HOLD-BACK","HOLD-BACK"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=parseFloat(i.attributes[a]))}),["CAN-SKIP-DATERANGES","CAN-BLOCK-RELOAD"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=/YES/.test(i.attributes[a]))}),this.trigger("data",i);return}if(t=/^#EXT-X-PART-INF:(.*)$/.exec(n),t&&t[1]){i={type:"tag",tagType:"part-inf"},i.attributes=rt(t[1]),["PART-TARGET"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=parseFloat(i.attributes[a]))}),this.trigger("data",i);return}if(t=/^#EXT-X-PRELOAD-HINT:(.*)$/.exec(n),t&&t[1]){i={type:"tag",tagType:"preload-hint"},i.attributes=rt(t[1]),["BYTERANGE-START","BYTERANGE-LENGTH"].forEach(function(a){if(i.attributes.hasOwnProperty(a)){i.attributes[a]=parseInt(i.attributes[a],10);const l=a==="BYTERANGE-LENGTH"?"length":"offset";i.attributes.byterange=i.attributes.byterange||{},i.attributes.byterange[l]=i.attributes[a],delete i.attributes[a]}}),this.trigger("data",i);return}if(t=/^#EXT-X-RENDITION-REPORT:(.*)$/.exec(n),t&&t[1]){i={type:"tag",tagType:"rendition-report"},i.attributes=rt(t[1]),["LAST-MSN","LAST-PART"].forEach(function(a){i.attributes.hasOwnProperty(a)&&(i.attributes[a]=parseInt(i.attributes[a],10))}),this.trigger("data",i);return}if(t=/^#EXT-X-DATERANGE:(.*)$/.exec(n),t&&t[1]){i={type:"tag",tagType:"daterange"},i.attributes=rt(t[1]),["ID","CLASS"].forEach(function(l){i.attributes.hasOwnProperty(l)&&(i.attributes[l]=String(i.attributes[l]))}),["START-DATE","END-DATE"].forEach(function(l){i.attributes.hasOwnProperty(l)&&(i.attributes[l]=new Date(i.attributes[l]))}),["DURATION","PLANNED-DURATION"].forEach(function(l){i.attributes.hasOwnProperty(l)&&(i.attributes[l]=parseFloat(i.attributes[l]))}),["END-ON-NEXT"].forEach(function(l){i.attributes.hasOwnProperty(l)&&(i.attributes[l]=/YES/i.test(i.attributes[l]))}),["SCTE35-CMD"," SCTE35-OUT","SCTE35-IN"].forEach(function(l){i.attributes.hasOwnProperty(l)&&(i.attributes[l]=i.attributes[l].toString(16))});const a=/^X-([A-Z]+-)+[A-Z]+$/;for(const l in i.attributes){if(!a.test(l))continue;const c=/[0-9A-Fa-f]{6}/g.test(i.attributes[l]),f=/^\d+(\.\d+)?$/.test(i.attributes[l]);i.attributes[l]=c?i.attributes[l].toString(16):f?parseFloat(i.attributes[l]):String(i.attributes[l])}this.trigger("data",i);return}if(t=/^#EXT-X-INDEPENDENT-SEGMENTS/.exec(n),t){this.trigger("data",{type:"tag",tagType:"independent-segments"});return}if(t=/^#EXT-X-I-FRAMES-ONLY/.exec(n),t){this.trigger("data",{type:"tag",tagType:"i-frames-only"});return}if(t=/^#EXT-X-CONTENT-STEERING:(.*)$/.exec(n),t){i={type:"tag",tagType:"content-steering"},i.attributes=rt(t[1]),this.trigger("data",i);return}if(t=/^#EXT-X-I-FRAME-STREAM-INF:(.*)$/.exec(n),t){i={type:"tag",tagType:"i-frame-playlist"},i.attributes=rt(t[1]),i.attributes.URI&&(i.uri=i.attributes.URI),i.attributes.BANDWIDTH&&(i.attributes.BANDWIDTH=parseInt(i.attributes.BANDWIDTH,10)),i.attributes.RESOLUTION&&(i.attributes.RESOLUTION=Tl(i.attributes.RESOLUTION)),i.attributes["AVERAGE-BANDWIDTH"]&&(i.attributes["AVERAGE-BANDWIDTH"]=parseInt(i.attributes["AVERAGE-BANDWIDTH"],10)),i.attributes["FRAME-RATE"]&&(i.attributes["FRAME-RATE"]=parseFloat(i.attributes["FRAME-RATE"])),this.trigger("data",i);return}if(t=/^#EXT-X-DEFINE:(.*)$/.exec(n),t){i={type:"tag",tagType:"define"},i.attributes=rt(t[1]),this.trigger("data",i);return}this.trigger("data",{type:"tag",data:n.slice(4)})})}addParser({expression:e,customType:t,dataParser:i,segment:r}){typeof i!="function"&&(i=n=>n),this.customParsers.push(n=>{if(e.exec(n))return this.trigger("data",{type:"custom",data:i(n),customType:t,segment:r}),!0})}addTagMapper({expression:e,map:t}){const i=r=>e.test(r)?t(r):r;this.tagMappers.push(i)}}const Bf=s=>s.toLowerCase().replace(/-(\w)/g,e=>e[1].toUpperCase()),ci=function(s){const e={};return Object.keys(s).forEach(function(t){e[Bf(t)]=s[t]}),e},da=function(s){const{serverControl:e,targetDuration:t,partTargetDuration:i}=s;if(!e)return;const r="#EXT-X-SERVER-CONTROL",n="holdBack",a="partHoldBack",l=t&&t*3,c=i&&i*2;t&&!e.hasOwnProperty(n)&&(e[n]=l,this.trigger("info",{message:`${r} defaulting HOLD-BACK to targetDuration * 3 (${l}).`})),l&&e[n]<l&&(this.trigger("warn",{message:`${r} clamping HOLD-BACK (${e[n]}) to targetDuration * 3 (${l})`}),e[n]=l),i&&!e.hasOwnProperty(a)&&(e[a]=i*3,this.trigger("info",{message:`${r} defaulting PART-HOLD-BACK to partTargetDuration * 3 (${e[a]}).`})),i&&e[a]<c&&(this.trigger("warn",{message:`${r} clamping PART-HOLD-BACK (${e[a]}) to partTargetDuration * 2 (${c}).`}),e[a]=c)};class Ff extends ua{constructor(e={}){super(),this.lineStream=new Of,this.parseStream=new Nf,this.lineStream.pipe(this.parseStream),this.mainDefinitions=e.mainDefinitions||{},this.params=new URL(e.uri,"https://a.com").searchParams,this.lastProgramDateTime=null;const t=this,i=[];let r={},n,a,l=!1;const c=function(){},f={AUDIO:{},VIDEO:{},"CLOSED-CAPTIONS":{},SUBTITLES:{}},g="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";let y=0;this.manifest={allowCache:!0,discontinuityStarts:[],dateRanges:[],iFramePlaylists:[],segments:[]};let k=0,C=0;const O={};this.on("end",()=>{r.uri||!r.parts&&!r.preloadHints||(!r.map&&n&&(r.map=n),!r.key&&a&&(r.key=a),!r.timeline&&typeof y=="number"&&(r.timeline=y),this.manifest.preloadSegment=r)}),this.parseStream.on("data",function(_){let j,B;if(t.manifest.definitions){for(const M in t.manifest.definitions)if(_.uri&&(_.uri=_.uri.replace(`{$${M}}`,t.manifest.definitions[M])),_.attributes)for(const P in _.attributes)typeof _.attributes[P]=="string"&&(_.attributes[P]=_.attributes[P].replace(`{$${M}}`,t.manifest.definitions[M]))}({tag(){({version(){_.version&&(this.manifest.version=_.version)},"allow-cache"(){this.manifest.allowCache=_.allowed,"allowed"in _||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange(){const M={};"length"in _&&(r.byterange=M,M.length=_.length,"offset"in _||(_.offset=k)),"offset"in _&&(r.byterange=M,M.offset=_.offset),k=M.offset+M.length},endlist(){this.manifest.endList=!0},inf(){"mediaSequence"in this.manifest||(this.manifest.mediaSequence=0,this.trigger("info",{message:"defaulting media sequence to zero"})),"discontinuitySequence"in this.manifest||(this.manifest.discontinuitySequence=0,this.trigger("info",{message:"defaulting discontinuity sequence to zero"})),_.title&&(r.title=_.title),_.duration>0&&(r.duration=_.duration),_.duration===0&&(r.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=i},key(){if(!_.attributes){this.trigger("warn",{message:"ignoring key declaration without attribute list"});return}if(_.attributes.METHOD==="NONE"){a=null;return}if(!_.attributes.URI){this.trigger("warn",{message:"ignoring key declaration without URI"});return}if(_.attributes.KEYFORMAT==="com.apple.streamingkeydelivery"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.apple.fps.1_0"]={attributes:_.attributes};return}if(_.attributes.KEYFORMAT==="com.microsoft.playready"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.microsoft.playready"]={uri:_.attributes.URI};return}if(_.attributes.KEYFORMAT===g){if(["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(_.attributes.METHOD)===-1){this.trigger("warn",{message:"invalid key method provided for Widevine"});return}if(_.attributes.METHOD==="SAMPLE-AES-CENC"&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),_.attributes.URI.substring(0,23)!=="data:text/plain;base64,"){this.trigger("warn",{message:"invalid key URI provided for Widevine"});return}if(!(_.attributes.KEYID&&_.attributes.KEYID.substring(0,2)==="0x")){this.trigger("warn",{message:"invalid key ID provided for Widevine"});return}this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.widevine.alpha"]={attributes:{schemeIdUri:_.attributes.KEYFORMAT,keyId:_.attributes.KEYID.substring(2)},pssh:bl(_.attributes.URI.split(",")[1])};return}_.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),a={method:_.attributes.METHOD||"AES-128",uri:_.attributes.URI},typeof _.attributes.IV<"u"&&(a.iv=_.attributes.IV)},"media-sequence"(){if(!isFinite(_.number)){this.trigger("warn",{message:"ignoring invalid media sequence: "+_.number});return}this.manifest.mediaSequence=_.number},"discontinuity-sequence"(){if(!isFinite(_.number)){this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+_.number});return}this.manifest.discontinuitySequence=_.number,y=_.number},"playlist-type"(){if(!/VOD|EVENT/.test(_.playlistType)){this.trigger("warn",{message:"ignoring unknown playlist type: "+_.playlist});return}this.manifest.playlistType=_.playlistType},map(){n={},_.uri&&(n.uri=_.uri),_.byterange&&(n.byterange=_.byterange),a&&(n.key=a)},"stream-inf"(){if(this.manifest.playlists=i,this.manifest.mediaGroups=this.manifest.mediaGroups||f,!_.attributes){this.trigger("warn",{message:"ignoring empty stream-inf attributes"});return}r.attributes||(r.attributes={}),Ne(r.attributes,_.attributes)},media(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||f,!(_.attributes&&_.attributes.TYPE&&_.attributes["GROUP-ID"]&&_.attributes.NAME)){this.trigger("warn",{message:"ignoring incomplete or missing media group"});return}const M=this.manifest.mediaGroups[_.attributes.TYPE];M[_.attributes["GROUP-ID"]]=M[_.attributes["GROUP-ID"]]||{},j=M[_.attributes["GROUP-ID"]],B={default:/yes/i.test(_.attributes.DEFAULT)},B.default?B.autoselect=!0:B.autoselect=/yes/i.test(_.attributes.AUTOSELECT),_.attributes.LANGUAGE&&(B.language=_.attributes.LANGUAGE),_.attributes.URI&&(B.uri=_.attributes.URI),_.attributes["INSTREAM-ID"]&&(B.instreamId=_.attributes["INSTREAM-ID"]),_.attributes.CHARACTERISTICS&&(B.characteristics=_.attributes.CHARACTERISTICS),_.attributes.FORCED&&(B.forced=/yes/i.test(_.attributes.FORCED)),j[_.attributes.NAME]=B},discontinuity(){y+=1,r.discontinuity=!0,this.manifest.discontinuityStarts.push(i.length)},"program-date-time"(){typeof this.manifest.dateTimeString>"u"&&(this.manifest.dateTimeString=_.dateTimeString,this.manifest.dateTimeObject=_.dateTimeObject),r.dateTimeString=_.dateTimeString,r.dateTimeObject=_.dateTimeObject;const{lastProgramDateTime:M}=this;this.lastProgramDateTime=new Date(_.dateTimeString).getTime(),M===null&&this.manifest.segments.reduceRight((P,$)=>($.programDateTime=P-$.duration*1e3,$.programDateTime),this.lastProgramDateTime)},targetduration(){if(!isFinite(_.duration)||_.duration<0){this.trigger("warn",{message:"ignoring invalid target duration: "+_.duration});return}this.manifest.targetDuration=_.duration,da.call(this,this.manifest)},start(){if(!_.attributes||isNaN(_.attributes["TIME-OFFSET"])){this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"});return}this.manifest.start={timeOffset:_.attributes["TIME-OFFSET"],precise:_.attributes.PRECISE}},"cue-out"(){r.cueOut=_.data},"cue-out-cont"(){r.cueOutCont=_.data},"cue-in"(){r.cueIn=_.data},skip(){this.manifest.skip=ci(_.attributes),this.warnOnMissingAttributes_("#EXT-X-SKIP",_.attributes,["SKIPPED-SEGMENTS"])},part(){l=!0;const M=this.manifes