@uploadcare/uc-video
Version:
Uploadcare's UCVideo solution for adaptive bitrate streaming
18 lines (17 loc) • 702 kB
JavaScript
(function(Ei,oi){typeof exports=="object"&&typeof module<"u"?oi(exports):typeof define=="function"&&define.amd?define(["exports"],oi):(Ei=typeof globalThis<"u"?globalThis:Ei||self,oi(Ei["uc-video"]={}))})(this,function(Ei){"use strict";var oi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Is(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function yf(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 Yn,nu;function Tr(){if(nu)return Yn;nu=1;var s;return typeof window<"u"?s=window:typeof oi<"u"?s=oi:typeof self<"u"?s=self:s={},Yn=s,Yn}var Tf=Tr();const D=Is(Tf),vf=yf(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var Qn,au;function ou(){if(au)return Qn;au=1;var s=typeof oi<"u"?oi:typeof window<"u"?window:{},e=vf,t;return typeof document<"u"?t=document:(t=s["__GLOBAL_DOCUMENT_CACHE@4"],t||(t=s["__GLOBAL_DOCUMENT_CACHE@4"]=e)),Qn=t,Qn}var bf=ou();const se=Is(bf);var vr={exports:{}},Jn={exports:{}},uu;function xf(){return uu||(uu=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}(Jn)),Jn.exports}var Zn,lu;function Sf(){if(lu)return Zn;lu=1,Zn=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 Zn}var ea,cu;function Ef(){if(cu)return ea;cu=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 u=0;return function(){return u>=r.length?{done:!0}:{done:!1,value:r[u++]}}}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,u=new Array(n);a<n;a++)u[a]=r[a];return u}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(u,c){this.typeToInterceptorsMap_.has(u)||this.typeToInterceptorsMap_.set(u,new Set);var f=this.typeToInterceptorsMap_.get(u);return f.has(c)?!1:(f.add(c),!0)},n.removeInterceptor=function(u,c){var f=this.typeToInterceptorsMap_.get(u);return f&&f.has(c)?(f.delete(c),!0):!1},n.clearInterceptorsByType=function(u){var c=this.typeToInterceptorsMap_.get(u);return c?(this.typeToInterceptorsMap_.delete(u),this.typeToInterceptorsMap_.set(u,new Set),!0):!1},n.clear=function(){return this.typeToInterceptorsMap_.size?(this.typeToInterceptorsMap_=new Map,!0):!1},n.getForType=function(u){return this.typeToInterceptorsMap_.get(u)||new Set},n.execute=function(u,c){for(var f=this.getForType(u),g=s(f),y;!(y=g()).done;){var I=y.value;try{c=I(c)}catch{}}return c},r}();return ea=i,ea}var ta,du;function Cf(){if(du)return ta;du=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,u=a.maxAttempts,c=a.delayFactor,f=a.fuzzFactor,g=a.initialDelay;return new e({maxAttempts:u||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 ta=s,ta}var ia,hu;function Af(){if(hu)return ia;hu=1;var s=Tr(),e=function(r,n){return n===void 0&&(n=!1),function(a,u,c){if(a){r(a);return}if(u.statusCode>=400&&u.statusCode<=599){var f=c;if(n)if(s.TextDecoder){var g=t(u.headers&&u.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("="),u=a[0],c=a[1];return u.trim()==="charset"?c.trim():r},"utf-8")}return ia=e,ia}var fu;function Df(){if(fu)return vr.exports;fu=1;var s=Tr(),e=xf(),t=Sf(),i=Ef(),r=Cf();f.httpHandler=Af(),f.requestInterceptorsStorage=new i,f.responseInterceptorsStorage=new i,f.retryManager=new r;/**
* @license
* slighly modified parse-headers 2.0.2 <https://github.com/kesla/parse-headers/>
* Copyright (c) 2014 David Björklund
* Available under the MIT license
* <https://github.com/kesla/parse-headers/blob/master/LICENCE>
*/var n=function(R){var T={};return R&&R.trim().split(`
`).forEach(function(P){var F=P.indexOf(":"),N=P.slice(0,F).trim().toLowerCase(),L=P.slice(F+1).trim();typeof T[N]>"u"?T[N]=L:Array.isArray(T[N])?T[N].push(L):T[N]=[T[N],L]}),T};vr.exports=f,vr.exports.default=f,f.XMLHttpRequest=s.XMLHttpRequest||I,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(R,T,P){return T=c(R,T,P),T.method=C.toUpperCase(),g(T)}});function a(C,R){for(var T=0;T<C.length;T++)R(C[T])}function u(C){for(var R in C)if(C.hasOwnProperty(R))return!1;return!0}function c(C,R,T){var P=C;return t(R)?(T=R,typeof C=="string"&&(P={uri:C})):P=e({},R,{uri:C}),P.callback=T,P}function f(C,R,T){return R=c(C,R,T),g(R)}function g(C){if(typeof C.callback>"u")throw new Error("callback argument missing");if(C.requestType&&f.requestInterceptorsStorage.getIsEnabled()){var R={uri:C.uri||C.url,headers:C.headers||{},body:C.body,metadata:C.metadata||{},retry:C.retry,timeout:C.timeout},T=f.requestInterceptorsStorage.execute(C.requestType,R);C.uri=T.uri,C.headers=T.headers,C.body=T.body,C.metadata=T.metadata,C.retry=T.retry,C.timeout=T.timeout}var P=!1,F=function(Z,J,te){P||(P=!0,C.callback(Z,J,te))};function N(){U.readyState===4&&!f.responseInterceptorsStorage.getIsEnabled()&&setTimeout(O,0)}function L(){var X=void 0;if(U.response?X=U.response:X=U.responseText||y(U),Q)try{X=JSON.parse(X)}catch{}return X}function z(X){if(clearTimeout(ie),clearTimeout(C.retryTimeout),X instanceof Error||(X=new Error(""+(X||"Unknown XMLHttpRequest Error"))),X.statusCode=0,!Y&&f.retryManager.getIsEnabled()&&C.retry&&C.retry.shouldRetry()){C.retryTimeout=setTimeout(function(){C.retry.moveToNextAttempt(),C.xhr=U,g(C)},C.retry.getCurrentFuzzedDelay());return}if(C.requestType&&f.responseInterceptorsStorage.getIsEnabled()){var Z={headers:re.headers||{},body:re.body,responseUrl:U.responseURL,responseType:U.responseType},J=f.responseInterceptorsStorage.execute(C.requestType,Z);re.body=J.body,re.headers=J.headers}return F(X,re)}function O(){if(!Y){var X;clearTimeout(ie),clearTimeout(C.retryTimeout),C.useXDR&&U.status===void 0?X=200:X=U.status===1223?204:U.status;var Z=re,J=null;if(X!==0?(Z={body:L(),statusCode:X,method:E,headers:{},url:v,rawRequest:U},U.getAllResponseHeaders&&(Z.headers=n(U.getAllResponseHeaders()))):J=new Error("Internal XMLHttpRequest Error"),C.requestType&&f.responseInterceptorsStorage.getIsEnabled()){var te={headers:Z.headers||{},body:Z.body,responseUrl:U.responseURL,responseType:U.responseType},ee=f.responseInterceptorsStorage.execute(C.requestType,te);Z.body=ee.body,Z.headers=ee.headers}return F(J,Z,Z.body)}}var U=C.xhr||null;U||(C.cors||C.useXDR?U=new f.XDomainRequest:U=new f.XMLHttpRequest);var V,Y,v=U.url=C.uri||C.url,E=U.method=C.method||"GET",q=C.body||C.data,j=U.headers=C.headers||{},H=!!C.sync,Q=!1,ie,re={body:void 0,headers:{},statusCode:0,method:E,url:v,rawRequest:U};if("json"in C&&C.json!==!1&&(Q=!0,j.accept||j.Accept||(j.Accept="application/json"),E!=="GET"&&E!=="HEAD"&&(j["content-type"]||j["Content-Type"]||(j["Content-Type"]="application/json"),q=JSON.stringify(C.json===!0?q:C.json))),U.onreadystatechange=N,U.onload=O,U.onerror=z,U.onprogress=function(){},U.onabort=function(){Y=!0,clearTimeout(C.retryTimeout)},U.ontimeout=z,U.open(E,v,!H,C.username,C.password),H||(U.withCredentials=!!C.withCredentials),!H&&C.timeout>0&&(ie=setTimeout(function(){if(!Y){Y=!0,U.abort("timeout");var X=new Error("XMLHttpRequest timeout");X.code="ETIMEDOUT",z(X)}},C.timeout)),U.setRequestHeader)for(V in j)j.hasOwnProperty(V)&&U.setRequestHeader(V,j[V]);else if(C.headers&&!u(C.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in C&&(U.responseType=C.responseType),"beforeSend"in C&&typeof C.beforeSend=="function"&&C.beforeSend(U),U.send(q||null),U}function y(C){try{if(C.responseType==="document")return C.responseXML;var R=C.responseXML&&C.responseXML.documentElement.nodeName==="parsererror";if(C.responseType===""&&!R)return C.responseXML}catch{}return null}function I(){}return vr.exports}var wf=Df();const pu=Is(wf);var sa={exports:{}},ra,mu;function If(){if(mu)return ra;mu=1;var s=ou(),e=Object.create||function(){function v(){}return function(E){if(arguments.length!==1)throw new Error("Object.create shim only accepts one parameter.");return v.prototype=E,new v}}();function t(v,E){this.name="ParsingError",this.code=v.code,this.message=E||v.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(v){function E(j,H,Q,ie){return(j|0)*3600+(H|0)*60+(Q|0)+(ie|0)/1e3}var q=v.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);return q?q[3]?E(q[1],q[2],q[3].replace(":",""),q[4]):q[1]>59?E(q[1],q[2],0,q[4]):E(0,q[1],q[2],q[4]):null}function r(){this.values=e(null)}r.prototype={set:function(v,E){!this.get(v)&&E!==""&&(this.values[v]=E)},get:function(v,E,q){return q?this.has(v)?this.values[v]:E[q]:this.has(v)?this.values[v]:E},has:function(v){return v in this.values},alt:function(v,E,q){for(var j=0;j<q.length;++j)if(E===q[j]){this.set(v,E);break}},integer:function(v,E){/^-?\d+$/.test(E)&&this.set(v,parseInt(E,10))},percent:function(v,E){return E.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(E=parseFloat(E),E>=0&&E<=100)?(this.set(v,E),!0):!1}};function n(v,E,q,j){var H=j?v.split(j):[v];for(var Q in H)if(typeof H[Q]=="string"){var ie=H[Q].split(q);if(ie.length===2){var re=ie[0].trim(),X=ie[1].trim();E(re,X)}}}function a(v,E,q){var j=v;function H(){var re=i(v);if(re===null)throw new t(t.Errors.BadTimeStamp,"Malformed timestamp: "+j);return v=v.replace(/^[^\sa-zA-Z-]+/,""),re}function Q(re,X){var Z=new r;n(re,function(J,te){switch(J){case"region":for(var ee=q.length-1;ee>=0;ee--)if(q[ee].id===te){Z.set(J,q[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/),X.region=Z.get("region",null),X.vertical=Z.get("vertical","");try{X.line=Z.get("line","auto")}catch{}X.lineAlign=Z.get("lineAlign","start"),X.snapToLines=Z.get("snapToLines",!0),X.size=Z.get("size",100);try{X.align=Z.get("align","center")}catch{X.align=Z.get("align","middle")}try{X.position=Z.get("position","auto")}catch{X.position=Z.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},X.align)}X.positionAlign=Z.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},X.align)}function ie(){v=v.replace(/^\s+/,"")}if(ie(),E.startTime=H(),ie(),v.substr(0,3)!=="-->")throw new t(t.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '-->'): "+j);v=v.substr(3),ie(),E.endTime=H(),ie(),Q(v,E)}var u=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 I(v,E){function q(){if(!E)return null;function me(he){return E=E.substr(he.length),he}var _e=E.match(/^([^<]*)(<[^>]*>?)?/);return me(_e[1]?_e[1]:_e[2])}function j(me){return u.innerHTML=me,me=u.textContent,u.textContent="",me}function H(me,_e){return!y[_e.localName]||y[_e.localName]===me.localName}function Q(me,_e){var he=c[me];if(!he)return null;var Ye=v.document.createElement(he),tt=g[me];return tt&&_e&&(Ye[tt]=_e.trim()),Ye}for(var ie=v.document.createElement("div"),re=ie,X,Z=[];(X=q())!==null;){if(X[0]==="<"){if(X[1]==="/"){Z.length&&Z[Z.length-1]===X.substr(2).replace(">","")&&(Z.pop(),re=re.parentNode);continue}var J=i(X.substr(1,X.length-2)),te;if(J){te=v.document.createProcessingInstruction("timestamp",J),re.appendChild(te);continue}var ee=X.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!ee||(te=Q(ee[1],ee[3]),!te)||!H(re,te))continue;if(ee[2]){var fe=ee[2].split(".");fe.forEach(function(me){var _e=/^bg_/.test(me),he=_e?me.slice(3):me;if(f.hasOwnProperty(he)){var Ye=_e?"background-color":"color",tt=f[he];te.style[Ye]=tt}}),te.className=fe.join(" ")}Z.push(ee[1]),re.appendChild(te),re=te;continue}re.appendChild(v.document.createTextNode(j(X)))}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 R(v){for(var E=0;E<C.length;E++){var q=C[E];if(v>=q[0]&&v<=q[1])return!0}return!1}function T(v){var E=[],q="",j;if(!v||!v.childNodes)return"ltr";function H(re,X){for(var Z=X.childNodes.length-1;Z>=0;Z--)re.push(X.childNodes[Z])}function Q(re){if(!re||!re.length)return null;var X=re.pop(),Z=X.textContent||X.innerText;if(Z){var J=Z.match(/^.*(\n|\r)/);return J?(re.length=0,J[0]):Z}if(X.tagName==="ruby")return Q(re);if(X.childNodes)return H(re,X),Q(re)}for(H(E,v);q=Q(E);)for(var ie=0;ie<q.length;ie++)if(j=q.charCodeAt(ie),R(j))return"rtl";return"ltr"}function P(v){if(typeof v.line=="number"&&(v.snapToLines||v.line>=0&&v.line<=100))return v.line;if(!v.track||!v.track.textTrackList||!v.track.textTrackList.mediaElement)return-1;for(var E=v.track,q=E.textTrackList,j=0,H=0;H<q.length&&q[H]!==E;H++)q[H].mode==="showing"&&j++;return++j*-1}function F(){}F.prototype.applyStyles=function(v,E){E=E||this.div;for(var q in v)v.hasOwnProperty(q)&&(E.style[q]=v[q])},F.prototype.formatStyle=function(v,E){return v===0?0:v+E};function N(v,E,q){F.call(this),this.cue=E,this.cueDiv=I(v,E.text);var j={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(j,this.cueDiv),this.div=v.document.createElement("div"),j={direction:T(this.cueDiv),writingMode:E.vertical===""?"horizontal-tb":E.vertical==="lr"?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:E.align==="middle"?"center":E.align,font:q.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(j),this.div.appendChild(this.cueDiv);var H=0;switch(E.positionAlign){case"start":case"line-left":H=E.position;break;case"center":H=E.position-E.size/2;break;case"end":case"line-right":H=E.position-E.size;break}E.vertical===""?this.applyStyles({left:this.formatStyle(H,"%"),width:this.formatStyle(E.size,"%")}):this.applyStyles({top:this.formatStyle(H,"%"),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")})}}N.prototype=e(F.prototype),N.prototype.constructor=N;function L(v){var E,q,j,H;if(v.div){q=v.div.offsetHeight,j=v.div.offsetWidth,H=v.div.offsetTop;var Q=(Q=v.div.childNodes)&&(Q=Q[0])&&Q.getClientRects&&Q.getClientRects();v=v.div.getBoundingClientRect(),E=Q?Math.max(Q[0]&&Q[0].height||0,v.height/Q.length):0}this.left=v.left,this.right=v.right,this.top=v.top||H,this.height=v.height||q,this.bottom=v.bottom||H+(v.height||q),this.width=v.width||j,this.lineHeight=E!==void 0?E:v.lineHeight}L.prototype.move=function(v,E){switch(E=E!==void 0?E:this.lineHeight,v){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}},L.prototype.overlaps=function(v){return this.left<v.right&&this.right>v.left&&this.top<v.bottom&&this.bottom>v.top},L.prototype.overlapsAny=function(v){for(var E=0;E<v.length;E++)if(this.overlaps(v[E]))return!0;return!1},L.prototype.within=function(v){return this.top>=v.top&&this.bottom<=v.bottom&&this.left>=v.left&&this.right<=v.right},L.prototype.overlapsOppositeAxis=function(v,E){switch(E){case"+x":return this.left<v.left;case"-x":return this.right>v.right;case"+y":return this.top<v.top;case"-y":return this.bottom>v.bottom}},L.prototype.intersectPercentage=function(v){var E=Math.max(0,Math.min(this.right,v.right)-Math.max(this.left,v.left)),q=Math.max(0,Math.min(this.bottom,v.bottom)-Math.max(this.top,v.top)),j=E*q;return j/(this.height*this.width)},L.prototype.toCSSCompatValues=function(v){return{top:this.top-v.top,bottom:v.bottom-this.bottom,left:this.left-v.left,right:v.right-this.right,height:this.height,width:this.width}},L.getSimpleBoxPosition=function(v){var E=v.div?v.div.offsetHeight:v.tagName?v.offsetHeight:0,q=v.div?v.div.offsetWidth:v.tagName?v.offsetWidth:0,j=v.div?v.div.offsetTop:v.tagName?v.offsetTop:0;v=v.div?v.div.getBoundingClientRect():v.tagName?v.getBoundingClientRect():v;var H={left:v.left,right:v.right,top:v.top||j,height:v.height||E,bottom:v.bottom||j+(v.height||E),width:v.width||q};return H};function z(v,E,q,j){function H(he,Ye){for(var tt,je=new L(he),it=1,Et=0;Et<Ye.length;Et++){for(;he.overlapsOppositeAxis(q,Ye[Et])||he.within(q)&&he.overlapsAny(j);)he.move(Ye[Et]);if(he.within(q))return he;var Qe=he.intersectPercentage(q);it>Qe&&(tt=new L(he),it=Qe),he=new L(je)}return tt||je}var Q=new L(E),ie=E.cue,re=P(ie),X=[];if(ie.snapToLines){var Z;switch(ie.vertical){case"":X=["+y","-y"],Z="height";break;case"rl":X=["+x","-x"],Z="width";break;case"lr":X=["-x","+x"],Z="width";break}var J=Q.lineHeight,te=J*Math.round(re),ee=q[Z]+J,fe=X[0];Math.abs(te)>ee&&(te=te<0?-1:1,te*=Math.ceil(ee/J)*J),re<0&&(te+=ie.vertical===""?q.height:q.width,X=X.reverse()),Q.move(fe,te)}else{var me=Q.lineHeight/q.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}X=["+y","-x","+x","-y"],Q=new L(E)}var _e=H(Q,X);E.move(_e.toCSSCompatValues(q))}function O(){}O.StringDecoder=function(){return{decode:function(v){if(!v)return"";if(typeof v!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(v))}}},O.convertCueToDOMTree=function(v,E){return!v||!E?null:I(v,E)};var U=.05,V="sans-serif",Y="1.5%";return O.processCues=function(v,E,q){if(!v||!E||!q)return null;for(;q.firstChild;)q.removeChild(q.firstChild);var j=v.document.createElement("div");j.style.position="absolute",j.style.left="0",j.style.right="0",j.style.top="0",j.style.bottom="0",j.style.margin=Y,q.appendChild(j);function H(J){for(var te=0;te<J.length;te++)if(J[te].hasBeenReset||!J[te].displayState)return!0;return!1}if(!H(E)){for(var Q=0;Q<E.length;Q++)j.appendChild(E[Q].displayState);return}var ie=[],re=L.getSimpleBoxPosition(j),X=Math.round(re.height*U*100)/100,Z={font:X+"px "+V};(function(){for(var J,te,ee=0;ee<E.length;ee++)te=E[ee],J=new N(v,te,Z),j.appendChild(J.div),z(v,J,re,ie),te.displayState=J.div,ie.push(L.getSimpleBoxPosition(J))})()},O.Parser=function(v,E,q){q||(q=E,E={}),E||(E={}),this.window=v,this.vttjs=E,this.state="INITIAL",this.buffer="",this.decoder=q||new TextDecoder("utf8"),this.regionList=[]},O.Parser.prototype={reportOrThrowError:function(v){if(v instanceof t)this.onparsingerror&&this.onparsingerror(v);else throw v},parse:function(v){var E=this;v&&(E.buffer+=E.decoder.decode(v,{stream:!0}));function q(){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 j(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 _e=me.split(",");if(_e.length!==2)break;var he=new r;if(he.percent("x",_e[0]),he.percent("y",_e[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 H(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){switch(te){case"X-TIMESTAMP-MAP":H(ee);break}},/=/):n(J,function(te,ee){switch(te){case"Region":j(ee);break}},/:/)}try{var ie;if(E.state==="INITIAL"){if(!/\r\n|\n/.test(E.buffer))return this;ie=q();var re=ie.match(/^WEBVTT([ \t].*)?$/);if(!re||!re[0])throw new t(t.Errors.BadSignature);E.state="HEADER"}for(var X=!1;E.buffer;){if(!/\r\n|\n/.test(E.buffer))return this;switch(X?X=!1:ie=q(),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&&(X=!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 v=this;try{if(v.buffer+=v.decoder.decode(),(v.cue||v.state==="HEADER")&&(v.buffer+=`
`,v.parse()),v.state==="INITIAL")throw new t(t.Errors.BadSignature)}catch(E){v.reportOrThrowError(E)}return v.onflush&&v.onflush(),this}},ra=O,ra}var na,gu;function kf(){if(gu)return na;gu=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 u=e[a.toLowerCase()];return u?a.toLowerCase():!1}function r(a){if(typeof a!="string")return!1;var u=t[a.toLowerCase()];return u?a.toLowerCase():!1}function n(a,u,c){this.hasBeenReset=!1;var f="",g=!1,y=a,I=u,C=c,R=null,T="",P=!0,F="auto",N="start",L="auto",z="auto",O=100,U="center";Object.defineProperties(this,{id:{enumerable:!0,get:function(){return f},set:function(V){f=""+V}},pauseOnExit:{enumerable:!0,get:function(){return g},set:function(V){g=!!V}},startTime:{enumerable:!0,get:function(){return y},set:function(V){if(typeof V!="number")throw new TypeError("Start time must be set to a number.");y=V,this.hasBeenReset=!0}},endTime:{enumerable:!0,get:function(){return I},set:function(V){if(typeof V!="number")throw new TypeError("End time must be set to a number.");I=V,this.hasBeenReset=!0}},text:{enumerable:!0,get:function(){return C},set:function(V){C=""+V,this.hasBeenReset=!0}},region:{enumerable:!0,get:function(){return R},set:function(V){R=V,this.hasBeenReset=!0}},vertical:{enumerable:!0,get:function(){return T},set:function(V){var Y=i(V);if(Y===!1)throw new SyntaxError("Vertical: an invalid or illegal direction string was specified.");T=Y,this.hasBeenReset=!0}},snapToLines:{enumerable:!0,get:function(){return P},set:function(V){P=!!V,this.hasBeenReset=!0}},line:{enumerable:!0,get:function(){return F},set:function(V){if(typeof V!="number"&&V!==s)throw new SyntaxError("Line: an invalid number or illegal string was specified.");F=V,this.hasBeenReset=!0}},lineAlign:{enumerable:!0,get:function(){return N},set:function(V){var Y=r(V);Y?(N=Y,this.hasBeenReset=!0):console.warn("lineAlign: an invalid or illegal string was specified.")}},position:{enumerable:!0,get:function(){return L},set:function(V){if(V<0||V>100)throw new Error("Position must be between 0 and 100.");L=V,this.hasBeenReset=!0}},positionAlign:{enumerable:!0,get:function(){return z},set:function(V){var Y=r(V);Y?(z=Y,this.hasBeenReset=!0):console.warn("positionAlign: an invalid or illegal string was specified.")}},size:{enumerable:!0,get:function(){return O},set:function(V){if(V<0||V>100)throw new Error("Size must be between 0 and 100.");O=V,this.hasBeenReset=!0}},align:{enumerable:!0,get:function(){return U},set:function(V){var Y=r(V);if(!Y)throw new SyntaxError("align: an invalid or illegal alignment string was specified.");U=Y,this.hasBeenReset=!0}}}),this.displayState=void 0}return n.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)},na=n,na}var aa,_u;function Pf(){if(_u)return aa;_u=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,u=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 u},set:function(y){if(!t(y))throw new Error("RegionAnchorX must be between 0 and 100.");u=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 I=e(y);I===!1?console.warn("Scroll: an invalid or illegal string was specified."):g=I}}})}return aa=i,aa}var yu;function Of(){if(yu)return sa.exports;yu=1;var s=Tr(),e=sa.exports={WebVTT:If(),VTTCue:kf(),VTTRegion:Pf()};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(),sa.exports}var Lf=Of();const Tu=Is(Lf);function Be(){return Be=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},Be.apply(null,arguments)}var vu="https://example.com",br=function(e,t){if(/^[a-z]+:/i.test(t))return t;/^data:/.test(e)&&(e=D.location&&D.location.href||"");var i=/^\/\//.test(e),r=!D.location&&!/\/\//i.test(e);e=new D.URL(e,D.location||vu);var n=new URL(t,e);return r?n.href.slice(vu.length):i?n.href.slice(n.protocol.length):n.href},oa=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 u=Array.prototype.slice.call(arguments,1),c=r.length,f=0;f<c;++f)r[f].apply(this,u)},e.dispose=function(){this.listeners={}},e.pipe=function(i){this.on("data",function(r){i.push(r)})},s}(),Rf=function(e){return D.atob?D.atob(e):Buffer.from(e,"base64").toString("binary")};function bu(s){for(var e=Rf(s),t=new Uint8Array(e.length),i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}/*! @name m3u8-parser @version 7.2.0 @license Apache-2.0 */class Mf extends oa{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 Nf=" ",ua=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},Bf=function(){const t="(?:"+"[^=]*"+")=(?:"+'"[^"]*"|[^,]*'+")";return new RegExp("(?:^|,)("+t+")")},rt=function(s){const e={};if(!s)return e;const t=s.split(Bf());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},xu=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 Ff extends oa{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 u=a(e);return u===e?n:n.concat([u])},[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=Be(ua(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=ua(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=xu(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(Nf)),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=ua(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 u=a==="BYTERANGE-LENGTH"?"length":"offset";i.attributes.byterange=i.attributes.byterange||{},i.attributes.byterange[u]=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(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=String(i.attributes[u]))}),["START-DATE","END-DATE"].forEach(function(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=new Date(i.attributes[u]))}),["DURATION","PLANNED-DURATION"].forEach(function(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=parseFloat(i.attributes[u]))}),["END-ON-NEXT"].forEach(function(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=/YES/i.test(i.attributes[u]))}),["SCTE35-CMD"," SCTE35-OUT","SCTE35-IN"].forEach(function(u){i.attributes.hasOwnProperty(u)&&(i.attributes[u]=i.attributes[u].toString(16))});const a=/^X-([A-Z]+-)+[A-Z]+$/;for(const u in i.attributes){if(!a.test(u))continue;const c=/[0-9A-Fa-f]{6}/g.test(i.attributes[u]),f=/^\d+(\.\d+)?$/.test(i.attributes[u]);i.attributes[u]=c?i.attributes[u].toString(16):f?parseFloat(i.attributes[u]):String(i.attributes[u])}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=xu(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 Uf=s=>s.toLowerCase().replace(/-(\w)/g,e=>e[1].toUpperCase()),ui=function(s){const e={};return Object.keys(s).forEach(function(t){e[Uf(t)]=s[t]}),e},la=function(s){const{serverControl:e,targetDuration:t,partTargetDuration:i}=s;if(!e)return;const r="#EXT-X-SERVER-CONTROL",n="holdBack",a="partHoldBack",u=t&&t*3,c=i&&i*2;t&&!e.hasOwnProperty(n)&&(e[n]=u,this.trigger("info",{message:`${r} defaulting HOLD-BACK to targetDuration * 3 (${u}).`})),u&&e[n]<u&&(this.trigger("warn",{message:`${r} clamping HOLD-BACK (${e[n]}) to targetDuration * 3 (${u})`}),e[n]=u),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 qf extends oa{constructor(e={}){super(),this.lineStream=new Mf,this.parseStream=new Ff,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,u=!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 I=0,C=0;const R={};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(T){let P,F;if(t.manifest.definitions){for(const N in t.manifest.definitions)if(T.uri&&(T.uri=T.uri.replace(`{$${N}}`,t.manifest.definitions[N])),T.attributes)for(const L in T.attributes)typeof T.attributes[L]=="string"&&(T.attributes[L]=T.attributes[L].replace(`{$${N}}`,t.manifest.definitions[N]))}({tag(){({version(){T.version&&(this.manifest.version=T.version)},"allow-cache"(){this.manifest.allowCache=T.allowed,"allowed"in T||(this.trigger("info",{message:"defaulting allowCache to YES"}),this.manifest.allowCache=!0)},byterange(){const N={};"length"in T&&(r.byterange=N,N.length=T.length,"offset"in T||(T.offset=I)),"offset"in T&&(r.byterange=N,N.offset=T.offset),I=N.offset+N.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"})),T.title&&(r.title=T.title),T.duration>0&&(r.duration=T.duration),T.duration===0&&(r.duration=.01,this.trigger("info",{message:"updating zero segment duration to a small value"})),this.manifest.segments=i},key(){if(!T.attributes){this.trigger("warn",{message:"ignoring key declaration without attribute list"});return}if(T.attributes.METHOD==="NONE"){a=null;return}if(!T.attributes.URI){this.trigger("warn",{message:"ignoring key declaration without URI"});return}if(T.attributes.KEYFORMAT==="com.apple.streamingkeydelivery"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.apple.fps.1_0"]={attributes:T.attributes};return}if(T.attributes.KEYFORMAT==="com.microsoft.playready"){this.manifest.contentProtection=this.manifest.contentProtection||{},this.manifest.contentProtection["com.microsoft.playready"]={uri:T.attributes.URI};return}if(T.attributes.KEYFORMAT===g){if(["SAMPLE-AES","SAMPLE-AES-CTR","SAMPLE-AES-CENC"].indexOf(T.attributes.METHOD)===-1){this.trigger("warn",{message:"invalid key method provided for Widevine"});return}if(T.attributes.METHOD==="SAMPLE-AES-CENC"&&this.trigger("warn",{message:"SAMPLE-AES-CENC is deprecated, please use SAMPLE-AES-CTR instead"}),T.attributes.URI.substring(0,23)!=="data:text/plain;base64,"){this.trigger("warn",{message:"invalid key URI provided for Widevine"});return}if(!(T.attributes.KEYID&&T.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:T.attributes.KEYFORMAT,keyId:T.attributes.KEYID.substring(2)},pssh:bu(T.attributes.URI.split(",")[1])};return}T.attributes.METHOD||this.trigger("warn",{message:"defaulting key method to AES-128"}),a={method:T.attributes.METHOD||"AES-128",uri:T.attributes.URI},typeof T.attributes.IV<"u"&&(a.iv=T.attributes.IV)},"media-sequence"(){if(!isFinite(T.number)){this.trigger("warn",{message:"ignoring invalid media sequence: "+T.number});return}this.manifest.mediaSequence=T.number},"discontinuity-sequence"(){if(!isFinite(T.number)){this.trigger("warn",{message:"ignoring invalid discontinuity sequence: "+T.number});return}this.manifest.discontinuitySequence=T.number,y=T.number},"playlist-type"(){if(!/VOD|EVENT/.test(T.playlistType)){this.trigger("warn",{message:"ignoring unknown playlist type: "+T.playlist});return}this.manifest.playlistType=T.playlistType},map(){n={},T.uri&&(n.uri=T.uri),T.byterange&&(n.byterange=T.byterange),a&&(n.key=a)},"stream-inf"(){if(this.manifest.playlists=i,this.manifest.mediaGroups=this.manifest.mediaGroups||f,!T.attributes){this.trigger("warn",{message:"ignoring empty stream-inf attributes"});return}r.attributes||(r.attributes={}),Be(r.attributes,T.attributes)},media(){if(this.manifest.mediaGroups=this.manifest.mediaGroups||f,!(T.attributes&&T.attributes.TYPE&&T.attributes["GROUP-ID"]&&T.attributes.NAME)){this.trigger("warn",{message:"ignoring incomplete or missing media group"});return}const N=this.manifest.mediaGroups[T.attributes.TYPE];N[T.attributes["GROUP-ID"]]=N[T.attributes["GROUP-ID"]]||{},P=N[T.attributes["GROUP-ID"]],F={default:/yes/i.test(T.attributes.DEFAULT)},F.default?F.autoselect=!0:F.autoselect=/yes/i.test(T.attributes.AUTOSELECT),T.attributes.LANGUAGE&&(F.language=T.attributes.LANGUAGE),T.attributes.URI&&(F.uri=T.attributes.URI),T.attributes["INSTREAM-ID"]&&(F.instreamId=T.attributes["INSTREAM-ID"]),T.attributes.CHARACTERISTICS&&(F.characteristics=T.attributes.CHARACTERISTICS),T.attributes.FORCED&&(F.forced=/yes/i.test(T.attributes.FORCED)),P[T.attributes.NAME]=F},discontinuity(){y+=1,r.discontinuity=!0,this.manifest.discontinuityStarts.push(i.length)},"program-date-time"(){typeof this.manifest.dateTimeString>"u"&&(this.manifest.dateTimeString=T.dateTimeString,this.manifest.dateTimeObject=T.dateTimeObject),r.dateTimeString=T.dateTimeString,r.dateTimeObject=T.dateTimeObject;const{lastProgramDateTime:N}=this;this.lastProgramDateTime=new Date(T.dateTimeString).getTime(),N===null&&this.manifest.segments.reduceRight((L,z)=>(z.programDateTime=L-z.duration*1e3,z.programDateTime),this.lastProgramDateTime)},targetduration(){if(!isFinite(T.duration)||T.duration<0){this.trigger("warn",{message:"ignoring invalid target duration: "+T.duration});return}this.manifest.targetDuration=T.duration,la.call(this,this.manifest)},start(){if(!T.attributes||isNaN(T.attributes["TIME-OFFSET"])){this.trigger("warn",{message:"ignoring start declaration without appropriate attribute list"});return}this.manifest.start={tim