/*! For license information please see website.components.video.visitor.js.LICENSE.txt */ websiteComponents.loader.define("website.components.video.visitor",[],()=>(()=>{var e,t,r={60280(e){var t=/^([^=]+)=([^;]*)$/,r=e.exports=function(e,r){e||(e={}),"string"==typeof e&&(e={cookie:e}),void 0===e.cookie&&(e.cookie=""),!1!==r&&(r=!0);var i=function(e){return e},n=r?escape:i,s=r?unescape:i;return{get:function(r){for(var i=e.cookie.split(/;\s*/),n=0;n0&&void 0!==arguments[0]?arguments[0]:{};return function(e,t){return Object.keys(t).forEach(function(r){t[r].forEach(function(t){var i=t.fulfilledHandler,n=t.rejectedHandler;e.interceptors[r]&&e.interceptors[r].use(i,n)})}),e}(n.default.create(),e)},e.exports=t.default},84634(e,t,r){"use strict";var i=r(28632);r(79506),r(56680),r(12426),r(49347),r(87241),r(36269),Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=i(r(19733)),s=i(r(72169)),o=i(r(91965)),a=i(r(68630)),l=i(r(87266)),c=i(r(42507)),u=i(r(52531));var d="b375e5ec-dfc6-4fcc-ad63-58063a0cc4a2",h=function(e){(0,o.default)(i,e);var t,r=(t=i,function(){var e,r=(0,l.default)(t);if(function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()){var i=(0,l.default)(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return(0,a.default)(this,e)});function i(e,t,o){var a;(0,n.default)(this,i);var l="".concat(e," (").concat(null==o?void 0:o.message,")");return a=r.call(this,l),(0,u.default)((0,s.default)(a),"_classId",d),(0,u.default)((0,s.default)(a),"functionName",null),(0,u.default)((0,s.default)(a),"cause",null),(0,u.default)((0,s.default)(a),"request",null),(0,u.default)((0,s.default)(a),"config",null),(0,u.default)((0,s.default)(a),"response",null),a.name=a.constructor.name,a.functionName=t,a.cause=o,o&&o.isAxiosError&&(a.request=o.request,a.config=o.config,a.response=o.response||null),a}return i}((0,c.default)(Error));t.default=h,(0,u.default)(h,"isApiError",function(e){return(null==e?void 0:e._classId)===d}),e.exports=t.default},59958(e,t,r){"use strict";var i=r(28632);Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"ApiError",{enumerable:!0,get:function(){return n.default}});var n=i(r(84634))},83900(e,t,r){"use strict";var i=r(28632),n=r(11435);Object.defineProperty(t,"Ay",{enumerable:!0,get:function(){return o.default}}),t.sO=void 0,n(r(53679)),n(r(17057));var s=n(r(59958));t.sO=s;i(r(6894));var o=i(r(33041))},33041(e,t,r){"use strict";var i=r(11435),n=r(28632);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=n(r(6894)),o=i(r(17057)),a=(0,s.default)({request:[o.crumbInterceptor],response:[]});t.default=a,e.exports=t.default},47315(e,t,r){"use strict";r(49347),r(17298),r(41744),Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.crumbInterceptor=void 0;var i=r(53679),n={fulfilledHandler:function(e){return e&&e.url&&e.url.startsWith("/api/")&&(e.headers[i.crumbKey]=(0,i.getCrumbValue)()),e},rejectedHandler:function(e){return Promise.reject(e)}};t.crumbInterceptor=n;var s=n;t.default=s},17057(e,t,r){"use strict";var i=r(28632);Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"crumbInterceptor",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(t,"paramsSerializerInterceptor",{enumerable:!0,get:function(){return s.default}});var n=i(r(47315)),s=i(r(31340))},31340(e,t,r){"use strict";var i=r(28632);r(88792),r(49347),r(17298),Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.paramsSerializerInterceptor=void 0;var n=i(r(27527)),s={fulfilledHandler:function(e){return e&&e.params&&Object.keys(e.params).length&&(e.paramsSerializer=function(e){return n.default.stringify(e,{arrayFormat:"repeat"})}),e},rejectedHandler:function(e){return Promise.reject(e)}};t.paramsSerializerInterceptor=s;var o=s;t.default=o},67426(e,t,r){"use strict";var i=r(28632);Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=i(r(10532)).default;t.default=n,e.exports=t.default},47899(e,t,r){e.exports=function(e){var t={};function r(i){if(t[i])return t[i].exports;var n=t[i]={i,l:!1,exports:{}};return e[i].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(i,n,function(t){return e[t]}.bind(null,n));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=10)}([function(e,t){var r=/^([^=]+)=([^;]*)$/;if(t=e.exports=function(e,t){e||(e={}),"string"==typeof e&&(e={cookie:e}),void 0===e.cookie&&(e.cookie=""),!1!==t&&(t=!0);var i=function(e){return e},n=t?escape:i,s=t?unescape:i;return{get:function(t){for(var i=e.cookie.split(/;\s*/),n=0;n0&&void 0!==arguments[0])||arguments[0];if("undefined"!=typeof window){if(window._sessionInfo)return window._sessionInfo;try{var t=localStorage.getItem(a),r=sessionStorage.getItem(o),s=null===r,c=null===t||"true"===r,d=n.default.get(l);return localStorage.setItem(a,"true"),s&&(c?sessionStorage.setItem(o,"true"):sessionStorage.setItem(o,"false")),!d&&e&&(d=(0,i.default)(),u(l,d)),window._sessionInfo={isFirstLanding:s,isFirstSession:c,sessionId:d},window._sessionInfo}catch(e){return console.warn("Unable access local/session storage."),{isFirstLanding:!1,isFirstSession:!1}}}};var i=s(r(1)),n=s(r(4));function s(e){return e&&e.__esModule?e:{default:e}}var o="SS_IS_FIRST_SESSION",a="SS_HAS_LANDED",l="SS_SESSION_ID",c=["squarespace.com","squarespace.net","sqsp.net"],u=function(e,t){var r=void 0;c.forEach(function(e){window.location.hostname.indexOf(e)>-1&&(r=e)}),r=r||window.location.hostname,n.default.set(e,t,{domain:r,path:"/",secure:window.location.protocol.indexOf("https")>-1})}},function(e,t,r){var i=r(2),n=r(3);e.exports=function(e,t,r){var s=t&&r||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||i)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var a=0;a<16;++a)t[s+a]=o[a];return t||n(o)}},function(e,t){var r="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(r){var i=new Uint8Array(16);e.exports=function(){return r(i),i}}else{var n=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)3&t||(e=4294967296*Math.random()),n[t]=e>>>((3&t)<<3)&255;return n}}},function(e,t){for(var r=[],i=0;i<256;++i)r[i]=(i+256).toString(16).substr(1);e.exports=function(e,t){var i=t||0,n=r;return[n[e[i++]],n[e[i++]],n[e[i++]],n[e[i++]],"-",n[e[i++]],n[e[i++]],"-",n[e[i++]],n[e[i++]],"-",n[e[i++]],n[e[i++]],"-",n[e[i++]],n[e[i++]],n[e[i++]],n[e[i++]],n[e[i++]],n[e[i++]]].join("")}},function(e,t){var r=/^([^=]+)=([^;]*)$/;if(t=e.exports=function(e,t){e||(e={}),"string"==typeof e&&(e={cookie:e}),void 0===e.cookie&&(e.cookie=""),!1!==t&&(t=!0);var i=function(e){return e},n=t?escape:i,s=t?unescape:i;return{get:function(t){for(var i=e.cookie.split(/;\s*/),n=0;n0&&c>l&&(c=l);for(var u=0;u=0?(d=g.substr(0,m),h=g.substr(m+1)):(d=g,h=""),f=decodeURIComponent(d),p=decodeURIComponent(h),i(o,f)?n(o[f])?o[f].push(p):o[f]=[o[f],p]:o[f]=p}return o};var n=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},function(e,t,r){"use strict";var i=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};e.exports=function(e,t,r,a){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?s(o(e),function(o){var a=encodeURIComponent(i(o))+r;return n(e[o])?s(e[o],function(e){return a+encodeURIComponent(i(e))}).join(t):a+encodeURIComponent(i(e[o]))}).join(t):a?encodeURIComponent(i(a))+r+encodeURIComponent(i(e)):""};var n=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function s(e,t){if(e.map)return e.map(t);for(var r=[],i=0;i>>((3&t)<<3)&255;return n}}},function(e,t){for(var r=[],i=0;i<256;++i)r[i]=(i+256).toString(16).substr(1);e.exports=function(e,t){var i=t||0,n=r;return[n[e[i++]],n[e[i++]],n[e[i++]],n[e[i++]],"-",n[e[i++]],n[e[i++]],"-",n[e[i++]],n[e[i++]],"-",n[e[i++]],n[e[i++]],"-",n[e[i++]],n[e[i++]],n[e[i++]],n[e[i++]],n[e[i++]],n[e[i++]]].join("")}},function(e,t,r){"use strict";r.r(t),r.d(t,"ClientConfig",function(){}),r.d(t,"EventSource",function(){return n}),r.d(t,"SourceEnvironment",function(){return i}),r.d(t,"default",function(){return x}),r.d(t,"SiteVisitorClient",function(){return R}),r(5);var i,n,s=r(0),o=r.n(s),a=r(1),l=r.n(a),c=r(2),u=r.n(c);function d(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};if(!1===this._config.fireEvents)return Promise.resolve();var t=this._generatePayload(e);return this._config.validateMode?this._validateEvent(t):this._config.url?t?this._config.useBeacon?this._sendBeacon(t):this._sendXhr(t):Promise.reject(new Error("no payload")):Promise.resolve()}},{key:"_getAnalyticsId",value:function(){var e=function(e){return e&&"null"!==e?e:null},t=e(o.a.get(this._config.storageKey)),r=e(this._getLocalStorageItem()),i=e(this._analyticsId),n=t||r||i||u()();return this._config.setAnalyticsCookie&&this._setAnalyticsId(n),n}},{key:"_getLocalStorageItem",value:function(){var e=!1,t=localStorage.getItem(this._config.expirationKey);return t&&(e=new Date>new Date(t)),e?(localStorage.removeItem(this._config.storageKey),localStorage.removeItem(this._config.expirationKey),null):localStorage.getItem(this._config.storageKey)}},{key:"_getNormalizedPathname",value:function(){var e=window.location.pathname;return"/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),e}},{key:"_generatePayload",value:function(e){return e}},{key:"_log",value:function(e){this._config.logging&&console.log(e)}},{key:"_sendBeacon",value:function(e){var t=new Blob([l.a.stringify(e)],{type:"application/x-www-form-urlencoded"});return navigator.sendBeacon(this._config.url,t),Promise.resolve()}},{key:"_sendXhr",value:function(e,t){var r=this;t=t||this._config.url;var i=new XMLHttpRequest,n=JSON.stringify(e),s=new Set([200,202]);return new Promise(function(e,o){i.open("POST",t,!0),i.setRequestHeader("Content-Type","application/json"),i.send(n),i.addEventListener("readystatechange",function(){4===i.readyState&&(s.has(i.status)?e():(r._warn("Error tracking event: HTTP Status ".concat(i.status)),o(new Error("Error tracking event: HTTP Status ".concat(i.status)))))})})}},{key:"_setAnalyticsId",value:function(e){this._analyticsId=e;var t=this._config.cookie,r=t.path,i=t.secure,n=window.location.hostname;this._config.cookie.domains.forEach(function(e){window.location.hostname.indexOf(e)>-1&&(n=e)});var s=new Date;s.setDate(s.getDate()+this._config.cookie.daysToStore);var a=s.toUTCString();try{if(o.a.set(this._config.storageKey,e,{domain:n,expires:a,path:r,secure:i}),document.cookie.indexOf(this._config.storageKey)!==document.cookie.lastIndexOf(this._config.storageKey)){var l=new Date(0).toUTCString();o.a.set(this._config.storageKey,null,{expires:l})}localStorage.setItem(this._config.storageKey,e),localStorage.setItem(this._config.expirationKey,a)}catch(e){this._warn("Unable to store analyticsId")}}},{key:"_validateEvent",value:function(e){return Promise.resolve(e)}},{key:"_warn",value:function(e){this._config.logging&&console.warn(e)}}],r&&d(t.prototype,r),e}(),p=r(3),g=r(4);function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function v(e){for(var t=1;t1&&void 0!==arguments[1]?arguments[1]:{};A(this,s),t=n.call(this);var o={devBaseDomainUrl:"https://clanker-events.stage.sqsp.net",cookie:{daysToStore:390,domains:["squarespace.com","squarespace.net","sqsp.net"],path:"/",secure:window.location.protocol.indexOf("https")>-1},expirationKey:"SS_ANALYTICS_EXPIRATION",fireEvents:!0,logging:!1,sourceEnvironment:i.DEV,storageKey:"SS_ANALYTICS_ID",url:"https://clanker-events.stage.sqsp.net/api/v1/clanker/events",useBeacon:!0,validateMode:!1,setAnalyticsCookie:!0};return t._config=E(o,e),t._defaultPayload=r,"sendBeacon"in navigator||(t._config.useBeacon=!1),t._config.url=t._generateUrl(),t}return t=s,r=[{key:"_generatePayload",value:function(e){var t=new Date,r=this._config.setAnalyticsCookie,i=Object(p.getSessionInfo)(r),n=v({},this._defaultPayload,{},e),s=n.context_website_id,a=n.custom_schema_name,l=n.destination_url,c=n.member_account_id,u=n.object_identifier,d=n.resolved_locale,h=n.website_locale,f=n.member_account_locale,m=function(e,t){if(null==e)return{};var r,i,n=function(e,t){if(null==e)return{};var r,i,n={},s=Object.keys(e);for(i=0;i=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}(n,["context_website_id","custom_schema_name","destination_url","member_account_id","object_identifier","resolved_locale","website_locale","member_account_locale"]),y={analytics_id:this._getAnalyticsId(),browser_language:navigator.language,browser_window_height:Math.round(window.innerHeight)||null,browser_window_width:Math.round(window.innerWidth)||null,client_name:"Javascript Pipeline 2.0 Event Tracker Client",client_version:g.a,marketing_id:o.a.get("SS_MID")||null,page_host:window.location.hostname,page_path:this._getNormalizedPathname(),page_query_params:window.location.search,page_referrer_url:document.referrer,session_id:i.sessionId||null,enduser_user_agent:navigator.userAgent,event_occurrence_timestamp:t.getTime(),browser_locale:navigator.language};this._warnOfOverwrittenFields(n,y);var b=a||this._config.customSchemaName,E={eventContent:v({},m,{},y,{custom_schema_name:b,source_environment:this._config.sourceEnvironment,context_website_id:s||null,destination_url:l||null,member_account_id:c||null,object_identifier:u||null,resolved_locale:d||document.documentElement.lang||"en-US",website_locale:h||null,member_account_locale:f||null}),eventSchemaName:b};return this._config.logging&&this._log({payload:v({},E)}),E.eventContent=JSON.stringify(E.eventContent),E}},{key:"_warnOfOverwrittenFields",value:function(e,t){var r=this;Object.keys(e).forEach(function(i){e.hasOwnProperty(i)&&t.hasOwnProperty(i)&&r._warn("".concat(i," is auto populated by @sqs/track-events/v2 and was overwritten"))})}},{key:"_generateUrl",value:function(){var e=this._config,t=e.sourceEnvironment,r=e.devBaseDomainUrl,n="";switch(t){case i.DEV:n="".concat(r,"/api/v1/clanker/events");break;case i.QA:case i.STAGING:n="https://clanker-events.stage.sqsp.net/api/v1/clanker/events";break;case i.PROD:n="https://clanker-events.squarespace.com/api/v1/clanker/events";break;default:this._warn("sourceEnvironment needs to be set to one of dev, staging, or prod"),n=""}return n}},{key:"spawnTracker",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=E({},this._defaultPayload,e);return new s(this._config,t)}},{key:"_validateEvent",value:function(e){var t="".concat(this._config.devBaseDomainUrl,"/api/v1/clanker/validate-event-content/").concat(this._config.customSchemaName);return this._sendXhr(e.eventContent,t)}}],r&&T(t.prototype,r),s}(f),R=function(e){w(r,e);var t=k(r);function r(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return A(this,r),t.call(this,v({},e,{setAnalyticsCookie:!1}),i)}return r}(x)}])},10532(e,t,r){e.exports=r(88338)},96747(e,t,r){"use strict";var i=r(34457),n=r(93395),s=r(31441),o=r(24417),a=r(12412),l=r(34903),c=r(57051),u=r(63184);e.exports=function(e){return new Promise(function(t,r){var d=e.data,h=e.headers,f=e.responseType;i.isFormData(d)&&delete h["Content-Type"];var p=new XMLHttpRequest;if(e.auth){var g=e.auth.username||"",m=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";h.Authorization="Basic "+btoa(g+":"+m)}var y=a(e.baseURL,e.url);function v(){if(p){var i="getAllResponseHeaders"in p?l(p.getAllResponseHeaders()):null,s={data:f&&"text"!==f&&"json"!==f?p.response:p.responseText,status:p.status,statusText:p.statusText,headers:i,config:e,request:p};n(t,r,s),p=null}}if(p.open(e.method.toUpperCase(),o(y,e.params,e.paramsSerializer),!0),p.timeout=e.timeout,"onloadend"in p?p.onloadend=v:p.onreadystatechange=function(){p&&4===p.readyState&&(0!==p.status||p.responseURL&&0===p.responseURL.indexOf("file:"))&&setTimeout(v)},p.onabort=function(){p&&(r(u("Request aborted",e,"ECONNABORTED",p)),p=null)},p.onerror=function(){r(u("Network Error",e,null,p)),p=null},p.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(u(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",p)),p=null},i.isStandardBrowserEnv()){var b=(e.withCredentials||c(y))&&e.xsrfCookieName?s.read(e.xsrfCookieName):void 0;b&&(h[e.xsrfHeaderName]=b)}"setRequestHeader"in p&&i.forEach(h,function(e,t){void 0===d&&"content-type"===t.toLowerCase()?delete h[t]:p.setRequestHeader(t,e)}),i.isUndefined(e.withCredentials)||(p.withCredentials=!!e.withCredentials),f&&"json"!==f&&(p.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&p.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&p.upload&&p.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){p&&(p.abort(),r(e),p=null)}),d||(d=null),p.send(d)})}},88338(e,t,r){"use strict";var i=r(34457),n=r(53383),s=r(504),o=r(36208);function a(e){var t=new s(e),r=n(s.prototype.request,t);return i.extend(r,s.prototype,t),i.extend(r,t),r}var l=a(r(31572));l.Axios=s,l.create=function(e){return a(o(l.defaults,e))},l.Cancel=r(79161),l.CancelToken=r(94408),l.isCancel=r(92481),l.all=function(e){return Promise.all(e)},l.spread=r(52239),l.isAxiosError=r(47336),e.exports=l,e.exports.default=l},79161(e){"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},94408(e,t,r){"use strict";var i=r(79161);function n(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var r=this;e(function(e){r.reason||(r.reason=new i(e),t(r.reason))})}n.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},n.source=function(){var e;return{token:new n(function(t){e=t}),cancel:e}},e.exports=n},92481(e){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},504(e,t,r){"use strict";var i=r(34457),n=r(24417),s=r(54322),o=r(385),a=r(36208),l=r(61864),c=l.validators;function u(e){this.defaults=e,this.interceptors={request:new s,response:new s}}u.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&l.assertOptions(t,{silentJSONParsing:c.transitional(c.boolean,"1.0.0"),forcedJSONParsing:c.transitional(c.boolean,"1.0.0"),clarifyTimeoutError:c.transitional(c.boolean,"1.0.0")},!1);var r=[],i=!0;this.interceptors.request.forEach(function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(i=i&&t.synchronous,r.unshift(t.fulfilled,t.rejected))});var n,s=[];if(this.interceptors.response.forEach(function(e){s.push(e.fulfilled,e.rejected)}),!i){var u=[o,void 0];for(Array.prototype.unshift.apply(u,r),u=u.concat(s),n=Promise.resolve(e);u.length;)n=n.then(u.shift(),u.shift());return n}for(var d=e;r.length;){var h=r.shift(),f=r.shift();try{d=h(d)}catch(e){f(e);break}}try{n=o(d)}catch(e){return Promise.reject(e)}for(;s.length;)n=n.then(s.shift(),s.shift());return n},u.prototype.getUri=function(e){return e=a(this.defaults,e),n(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},i.forEach(["delete","get","head","options"],function(e){u.prototype[e]=function(t,r){return this.request(a(r||{},{method:e,url:t,data:(r||{}).data}))}}),i.forEach(["post","put","patch"],function(e){u.prototype[e]=function(t,r,i){return this.request(a(i||{},{method:e,url:t,data:r}))}}),e.exports=u},54322(e,t,r){"use strict";var i=r(34457);function n(){this.handlers=[]}n.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},n.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},n.prototype.forEach=function(e){i.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=n},12412(e,t,r){"use strict";var i=r(43468),n=r(61457);e.exports=function(e,t){return e&&!i(t)?n(e,t):t}},63184(e,t,r){"use strict";var i=r(72460);e.exports=function(e,t,r,n,s){var o=new Error(e);return i(o,t,r,n,s)}},385(e,t,r){"use strict";var i=r(34457),n=r(96134),s=r(92481),o=r(31572);function a(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return a(e),e.headers=e.headers||{},e.data=n.call(e,e.data,e.headers,e.transformRequest),e.headers=i.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),i.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]}),(e.adapter||o.adapter)(e).then(function(t){return a(e),t.data=n.call(e,t.data,t.headers,e.transformResponse),t},function(t){return s(t)||(a(e),t&&t.response&&(t.response.data=n.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},72460(e){"use strict";e.exports=function(e,t,r,i,n){return e.config=t,r&&(e.code=r),e.request=i,e.response=n,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},36208(e,t,r){"use strict";var i=r(34457);e.exports=function(e,t){t=t||{};var r={},n=["url","method","data"],s=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function l(e,t){return i.isPlainObject(e)&&i.isPlainObject(t)?i.merge(e,t):i.isPlainObject(t)?i.merge({},t):i.isArray(t)?t.slice():t}function c(n){i.isUndefined(t[n])?i.isUndefined(e[n])||(r[n]=l(void 0,e[n])):r[n]=l(e[n],t[n])}i.forEach(n,function(e){i.isUndefined(t[e])||(r[e]=l(void 0,t[e]))}),i.forEach(s,c),i.forEach(o,function(n){i.isUndefined(t[n])?i.isUndefined(e[n])||(r[n]=l(void 0,e[n])):r[n]=l(void 0,t[n])}),i.forEach(a,function(i){i in t?r[i]=l(e[i],t[i]):i in e&&(r[i]=l(void 0,e[i]))});var u=n.concat(s).concat(o).concat(a),d=Object.keys(e).concat(Object.keys(t)).filter(function(e){return-1===u.indexOf(e)});return i.forEach(d,c),r}},93395(e,t,r){"use strict";var i=r(63184);e.exports=function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(i("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}},96134(e,t,r){"use strict";var i=r(34457),n=r(31572);e.exports=function(e,t,r){var s=this||n;return i.forEach(r,function(r){e=r.call(s,e,t)}),e}},31572(e,t,r){"use strict";var i=r(34457),n=r(5015),s=r(72460),o={"Content-Type":"application/x-www-form-urlencoded"};function a(e,t){!i.isUndefined(e)&&i.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var l,c={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(l=r(96747)),l),transformRequest:[function(e,t){return n(t,"Accept"),n(t,"Content-Type"),i.isFormData(e)||i.isArrayBuffer(e)||i.isBuffer(e)||i.isStream(e)||i.isFile(e)||i.isBlob(e)?e:i.isArrayBufferView(e)?e.buffer:i.isURLSearchParams(e)?(a(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):i.isObject(e)||t&&"application/json"===t["Content-Type"]?(a(t,"application/json"),function(e){if(i.isString(e))try{return(0,JSON.parse)(e),i.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,o=!r&&"json"===this.responseType;if(o||n&&i.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw s(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};i.forEach(["delete","get","head"],function(e){c.headers[e]={}}),i.forEach(["post","put","patch"],function(e){c.headers[e]=i.merge(o)}),e.exports=c},53383(e){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),i=0;i=0)return;o[t]="set-cookie"===t?(o[t]?o[t]:[]).concat([r]):o[t]?o[t]+", "+r:r}}),o):o}},52239(e){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},61864(e,t,r){"use strict";var i=r(17431),n={};["object","boolean","number","function","string","symbol"].forEach(function(e,t){n[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});var s={},o=i.version.split(".");function a(e,t){for(var r=t?t.split("."):o,i=e.split("."),n=0;n<3;n++){if(r[n]>i[n])return!0;if(r[n]0;){var s=i[n],o=t[s];if(o){var a=e[s],l=void 0===a||o(a,s,e);if(!0!==l)throw new TypeError("option "+s+" must be "+l)}else if(!0!==r)throw Error("Unknown option "+s)}},validators:n}},34457(e,t,r){"use strict";var i=r(53383),n=Object.prototype.toString;function s(e){return"[object Array]"===n.call(e)}function o(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function l(e){if("[object Object]"!==n.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return"[object Function]"===n.call(e)}function u(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),s(e))for(var r=0,i=e.length;r-1?n([r]):r}},20456(){!function(){if("undefined"!=typeof window)try{var e=new window.CustomEvent("test",{cancelable:!0});if(e.preventDefault(),!0!==e.defaultPrevented)throw new Error("Could not prevent default")}catch(e){var t=function(e,t){var r,i;return(t=t||{}).bubbles=!!t.bubbles,t.cancelable=!!t.cancelable,(r=document.createEvent("CustomEvent")).initCustomEvent(e,t.bubbles,t.cancelable,t.detail),i=r.preventDefault,r.preventDefault=function(){i.call(this);try{Object.defineProperty(this,"defaultPrevented",{get:function(){return!0}})}catch(e){this.defaultPrevented=!0}},r};t.prototype=window.Event.prototype,window.CustomEvent=t}}()},61449(e,t,r){"use strict";var i,n=r(45312),s=r(3492);try{i=[].__proto__===Array.prototype}catch(e){if(!e||"object"!=typeof e||!("code"in e)||"ERR_PROTO_ACCESS"!==e.code)throw e}var o=!!i&&s&&s(Object.prototype,"__proto__"),a=Object,l=a.getPrototypeOf;e.exports=o&&"function"==typeof o.get?n([o.get]):"function"==typeof l&&function(e){return l(null==e?e:a(e))}},29173(e){"use strict";var t=Object.defineProperty||!1;if(t)try{t({},"a",{value:1})}catch(e){t=!1}e.exports=t},81101(e){"use strict";e.exports=EvalError},99183(e){"use strict";e.exports=Error},17570(e){"use strict";e.exports=RangeError},9898(e){"use strict";e.exports=ReferenceError},17388(e){"use strict";e.exports=SyntaxError},57379(e){"use strict";e.exports=TypeError},74585(e){"use strict";e.exports=URIError},10029(e){"use strict";e.exports=Object},51777(e){"use strict";var t=Object.prototype.toString,r=Math.max,i=function(e,t){for(var r=[],i=0;i1&&"boolean"!=typeof t)throw new u('"allowMissing" argument must be a boolean');if(null===H(/^%?[^%]*%?$/,e))throw new c("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(e){var t=V(e,0,1),r=V(e,-1);if("%"===t&&"%"!==r)throw new c("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new c("invalid intrinsic syntax, expected opening `%`");var i=[];return $(e,G,function(e,t,r,n){i[i.length]=r?$(n,K,"$1"):t||e}),i}(e),i=r.length>0?r[0]:"",n=W("%"+i+"%",t),s=n.name,o=n.value,a=!1,l=n.alias;l&&(i=l[0],j(r,U([0,1],l)));for(var d=1,h=!0;d=r.length){var m=A(o,f);o=(h=!!m)&&"get"in m&&!("originalValue"in m.get)?m.get:o[f]}else h=B(o,f),o=o[f];h&&!a&&(O[s]=o)}}return o}},48819(e,t,r){"use strict";var i=r(10029);e.exports=i.getPrototypeOf||null},22517(e){"use strict";e.exports="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null},31611(e,t,r){"use strict";var i=r(22517),n=r(48819),s=r(61449);e.exports=i?function(e){return i(e)}:n?function(e){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new TypeError("getProto: not an object");return n(e)}:s?function(e){return s(e)}:null},64656(e){"use strict";e.exports=Object.getOwnPropertyDescriptor},3492(e,t,r){"use strict";var i=r(64656);if(i)try{i([],"length")}catch(e){i=null}e.exports=i},87657(e,t,r){"use strict";var i="undefined"!=typeof Symbol&&Symbol,n=r(38123);e.exports=function(){return"function"==typeof i&&"function"==typeof Symbol&&"symbol"==typeof i("foo")&&"symbol"==typeof Symbol("bar")&&n()}},38123(e){"use strict";e.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var e={},t=Symbol("test"),r=Object(t);if("string"==typeof t)return!1;if("[object Symbol]"!==Object.prototype.toString.call(t))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var i in e[t]=42,e)return!1;if("function"==typeof Object.keys&&0!==Object.keys(e).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(e).length)return!1;var n=Object.getOwnPropertySymbols(e);if(1!==n.length||n[0]!==t)return!1;if(!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var s=Object.getOwnPropertyDescriptor(e,t);if(42!==s.value||!0!==s.enumerable)return!1}return!0}},37533(e,t,r){"use strict";var i=Function.prototype.call,n=Object.prototype.hasOwnProperty,s=r(13583);e.exports=s.call(i,n)},29895(e){"use strict";e.exports=Math.abs},72153(e){"use strict";e.exports=Math.floor},15518(e){"use strict";e.exports=Number.isNaN||function(e){return e!=e}},90457(e){"use strict";e.exports=Math.max},21179(e){"use strict";e.exports=Math.min},55985(e){"use strict";e.exports=Math.pow},88639(e){"use strict";e.exports=Math.round},55738(e,t,r){"use strict";var i=r(15518);e.exports=function(e){return i(e)||0===e?e:e<0?-1:1}},24922(e,t,r){var i="function"==typeof Map&&Map.prototype,n=Object.getOwnPropertyDescriptor&&i?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,s=i&&n&&"function"==typeof n.get?n.get:null,o=i&&Map.prototype.forEach,a="function"==typeof Set&&Set.prototype,l=Object.getOwnPropertyDescriptor&&a?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,c=a&&l&&"function"==typeof l.get?l.get:null,u=a&&Set.prototype.forEach,d="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,h="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,f="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,p=Boolean.prototype.valueOf,g=Object.prototype.toString,m=Function.prototype.toString,y=String.prototype.match,v=String.prototype.slice,b=String.prototype.replace,E=String.prototype.toUpperCase,A=String.prototype.toLowerCase,T=RegExp.prototype.test,w=Array.prototype.concat,S=Array.prototype.join,k=Array.prototype.slice,L=Math.floor,x="function"==typeof BigInt?BigInt.prototype.valueOf:null,R=Object.getOwnPropertySymbols,P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,I="function"==typeof Symbol&&"object"==typeof Symbol.iterator,C="function"==typeof Symbol&&Symbol.toStringTag&&(Symbol.toStringTag,1)?Symbol.toStringTag:null,_=Object.prototype.propertyIsEnumerable,O=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function D(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||T.call(/e/,t))return t;var r=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var i=e<0?-L(-e):L(e);if(i!==e){var n=String(i),s=v.call(t,n.length+1);return b.call(n,r,"$&_")+"."+b.call(b.call(s,/([0-9]{3})/g,"$&_"),/_$/,"")}}return b.call(t,r,"$&_")}var M=r(22179),N=M.custom,F=K(N)?N:null,B={__proto__:null,double:'"',single:"'"},U={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};function j(e,t,r){var i=r.quoteStyle||t,n=B[i];return n+e+n}function $(e){return b.call(String(e),/"/g,""")}function V(e){return!C||!("object"==typeof e&&(C in e||void 0!==e[C]))}function H(e){return"[object Array]"===z(e)&&V(e)}function G(e){return"[object RegExp]"===z(e)&&V(e)}function K(e){if(I)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!P)return!1;try{return P.call(e),!0}catch(e){}return!1}e.exports=function e(t,r,i,n){var a=r||{};if(q(a,"quoteStyle")&&!q(B,a.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(q(a,"maxStringLength")&&("number"==typeof a.maxStringLength?a.maxStringLength<0&&a.maxStringLength!==1/0:null!==a.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var l=!q(a,"customInspect")||a.customInspect;if("boolean"!=typeof l&&"symbol"!==l)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(q(a,"indent")&&null!==a.indent&&"\t"!==a.indent&&!(parseInt(a.indent,10)===a.indent&&a.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(q(a,"numericSeparator")&&"boolean"!=typeof a.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var g=a.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return X(t,a);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var E=String(t);return g?D(t,E):E}if("bigint"==typeof t){var T=String(t)+"n";return g?D(t,T):T}var L=void 0===a.depth?5:a.depth;if(void 0===i&&(i=0),i>=L&&L>0&&"object"==typeof t)return H(t)?"[Array]":"[Object]";var R,N=function(e,t){var r;if("\t"===e.indent)r="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;r=S.call(Array(e.indent+1)," ")}return{base:r,prev:S.call(Array(t+1),r)}}(a,i);if(void 0===n)n=[];else if(Y(n,t)>=0)return"[Circular]";function U(t,r,s){if(r&&(n=k.call(n)).push(r),s){var o={depth:a.depth};return q(a,"quoteStyle")&&(o.quoteStyle=a.quoteStyle),e(t,o,i+1,n)}return e(t,a,i+1,n)}if("function"==typeof t&&!G(t)){var W=function(e){if(e.name)return e.name;var t=y.call(m.call(e),/^function\s*([\w$]+)/);return t?t[1]:null}(t),Q=re(t,U);return"[Function"+(W?": "+W:" (anonymous)")+"]"+(Q.length>0?" { "+S.call(Q,", ")+" }":"")}if(K(t)){var ie=I?b.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):P.call(t);return"object"!=typeof t||I?ie:J(ie)}if((R=t)&&"object"==typeof R&&("undefined"!=typeof HTMLElement&&R instanceof HTMLElement||"string"==typeof R.nodeName&&"function"==typeof R.getAttribute)){for(var ne="<"+A.call(String(t.nodeName)),se=t.attributes||[],oe=0;oe"}if(H(t)){if(0===t.length)return"[]";var ae=re(t,U);return N&&!function(e){for(var t=0;t=0)return!1;return!0}(ae)?"["+te(ae,N)+"]":"[ "+S.call(ae,", ")+" ]"}if(function(e){return"[object Error]"===z(e)&&V(e)}(t)){var le=re(t,U);return"cause"in Error.prototype||!("cause"in t)||_.call(t,"cause")?0===le.length?"["+String(t)+"]":"{ ["+String(t)+"] "+S.call(le,", ")+" }":"{ ["+String(t)+"] "+S.call(w.call("[cause]: "+U(t.cause),le),", ")+" }"}if("object"==typeof t&&l){if(F&&"function"==typeof t[F]&&M)return M(t,{depth:L-i});if("symbol"!==l&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!s||!e||"object"!=typeof e)return!1;try{s.call(e);try{c.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var ce=[];return o&&o.call(t,function(e,r){ce.push(U(r,t,!0)+" => "+U(e,t))}),ee("Map",s.call(t),ce,N)}if(function(e){if(!c||!e||"object"!=typeof e)return!1;try{c.call(e);try{s.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var ue=[];return u&&u.call(t,function(e){ue.push(U(e,t))}),ee("Set",c.call(t),ue,N)}if(function(e){if(!d||!e||"object"!=typeof e)return!1;try{d.call(e,d);try{h.call(e,h)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return Z("WeakMap");if(function(e){if(!h||!e||"object"!=typeof e)return!1;try{h.call(e,h);try{d.call(e,d)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return Z("WeakSet");if(function(e){if(!f||!e||"object"!=typeof e)return!1;try{return f.call(e),!0}catch(e){}return!1}(t))return Z("WeakRef");if(function(e){return"[object Number]"===z(e)&&V(e)}(t))return J(U(Number(t)));if(function(e){if(!e||"object"!=typeof e||!x)return!1;try{return x.call(e),!0}catch(e){}return!1}(t))return J(U(x.call(t)));if(function(e){return"[object Boolean]"===z(e)&&V(e)}(t))return J(p.call(t));if(function(e){return"[object String]"===z(e)&&V(e)}(t))return J(U(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&t===globalThis||"undefined"!=typeof globalThis&&t===globalThis)return"{ [object globalThis] }";if(!function(e){return"[object Date]"===z(e)&&V(e)}(t)&&!G(t)){var de=re(t,U),he=O?O(t)===Object.prototype:t instanceof Object||t.constructor===Object,fe=t instanceof Object?"":"null prototype",pe=!he&&C&&Object(t)===t&&C in t?v.call(z(t),8,-1):fe?"Object":"",ge=(he||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(pe||fe?"["+S.call(w.call([],pe||[],fe||[]),": ")+"] ":"");return 0===de.length?ge+"{}":N?ge+"{"+te(de,N)+"}":ge+"{ "+S.call(de,", ")+" }"}return String(t)};var W=Object.prototype.hasOwnProperty||function(e){return e in this};function q(e,t){return W.call(e,t)}function z(e){return g.call(e)}function Y(e,t){if(e.indexOf)return e.indexOf(t);for(var r=0,i=e.length;rt.maxStringLength){var r=e.length-t.maxStringLength,i="... "+r+" more character"+(r>1?"s":"");return X(v.call(e,0,t.maxStringLength),t)+i}var n=U[t.quoteStyle||"single"];return n.lastIndex=0,j(b.call(b.call(e,n,"\\$1"),/[\x00-\x1f]/g,Q),"single",t)}function Q(e){var t=e.charCodeAt(0),r={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return r?"\\"+r:"\\x"+(t<16?"0":"")+E.call(t.toString(16))}function J(e){return"Object("+e+")"}function Z(e){return e+" { ? }"}function ee(e,t,r,i){return e+" ("+t+") {"+(i?te(r,i):S.call(r,", "))+"}"}function te(e,t){if(0===e.length)return"";var r="\n"+t.prev+t.base;return r+S.call(e,","+r)+"\n"+t.prev}function re(e,t){var r=H(e),i=[];if(r){i.length=e.length;for(var n=0;n(r=100/l.width*(n.clientX-l.left))?r=0:100r?r-=(100-2*r)*c:50t){var r=function(e){var t="".concat(e).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0}(t);return parseFloat(e.toFixed(r))}return Math.round(e/t)*t}(r/100*(o-s),a)}},{key:"set",value:function(t){e.enabled&&f.event(t)&&!t.target.disabled&&(t.preventDefault(),t.target.value=this.get(t),function(e,t){if(e&&t){var r=new Event(t,{bubbles:!0});e.dispatchEvent(r)}}(t.target,"touchend"===t.type?"change":"input"))}}],[{key:"setup",value:function(t){var r=1null!=e?e.constructor:null,m=(e,t)=>Boolean(e&&t&&e instanceof t),y=e=>null==e,v=e=>g(e)===Object,b=e=>g(e)===String,E=e=>"function"==typeof e,A=e=>Array.isArray(e),T=e=>m(e,NodeList),w=e=>y(e)||(b(e)||A(e)||T(e))&&!e.length||v(e)&&!Object.keys(e).length;var S=y,k=v,L=e=>g(e)===Number&&!Number.isNaN(e),x=b,R=e=>g(e)===Boolean,P=E,I=A,C=T,_=e=>null!==e&&"object"==typeof e&&1===e.nodeType&&"object"==typeof e.style&&"object"==typeof e.ownerDocument,O=e=>m(e,Event),D=e=>m(e,KeyboardEvent),M=e=>m(e,TextTrack)||!y(e)&&b(e.kind),N=e=>m(e,Promise)&&E(e.then),F=e=>{if(m(e,window.URL))return!0;if(!b(e))return!1;let t=e;e.startsWith("http://")&&e.startsWith("https://")||(t=`http://${e}`);try{return!w(new URL(t).hostname)}catch(e){return!1}},B=w;const U=(()=>{const e=document.createElement("span"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},r=Object.keys(t).find(t=>void 0!==e.style[t]);return!!x(r)&&t[r]})();function j(e,t){setTimeout(()=>{try{e.hidden=!0,e.offsetHeight,e.hidden=!1}catch(e){}},t)}var $={isIE:Boolean(window.document.documentMode),isEdge:/Edge/g.test(navigator.userAgent),isWebKit:"WebkitAppearance"in document.documentElement.style&&!/Edge/g.test(navigator.userAgent),isIPhone:/iPhone|iPod/gi.test(navigator.userAgent)&&navigator.maxTouchPoints>1,isIPadOS:"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1,isIos:/iPad|iPhone|iPod/gi.test(navigator.userAgent)&&navigator.maxTouchPoints>1};function V(e,t){return t.split(".").reduce((e,t)=>e&&e[t],e)}function H(e={},...t){if(!t.length)return e;const r=t.shift();return k(r)?(Object.keys(r).forEach(t=>{k(r[t])?(Object.keys(e).includes(t)||Object.assign(e,{[t]:{}}),H(e[t],r[t])):Object.assign(e,{[t]:r[t]})}),H(e,...t)):e}function G(e,t){const r=e.length?e:[e];Array.from(r).reverse().forEach((e,r)=>{const i=r>0?t.cloneNode(!0):t,n=e.parentNode,s=e.nextSibling;i.appendChild(e),s?n.insertBefore(i,s):n.appendChild(i)})}function K(e,t){_(e)&&!B(t)&&Object.entries(t).filter(([,e])=>!S(e)).forEach(([t,r])=>e.setAttribute(t,r))}function W(e,t,r){const i=document.createElement(e);return k(t)&&K(i,t),x(r)&&(i.innerText=r),i}function q(e,t,r,i){_(t)&&t.appendChild(W(e,r,i))}function z(e){C(e)||I(e)?Array.from(e).forEach(z):_(e)&&_(e.parentNode)&&e.parentNode.removeChild(e)}function Y(e){if(!_(e))return;let{length:t}=e.childNodes;for(;t>0;)e.removeChild(e.lastChild),t-=1}function X(e,t){return _(t)&&_(t.parentNode)&&_(e)?(t.parentNode.replaceChild(e,t),e):null}function Q(e,t){if(!x(e)||B(e))return{};const r={},i=H({},t);return e.split(",").forEach(e=>{const t=e.trim(),n=t.replace(".",""),s=t.replace(/[[\]]/g,"").split("="),[o]=s,a=s.length>1?s[1].replace(/["']/g,""):"";switch(t.charAt(0)){case".":x(i.class)?r.class=`${i.class} ${n}`:r.class=n;break;case"#":r.id=t.replace("#","");break;case"[":r[o]=a}}),H(i,r)}function J(e,t){if(!_(e))return;let r=t;R(r)||(r=!e.hidden),e.hidden=r}function Z(e,t,r){if(C(e))return Array.from(e).map(e=>Z(e,t,r));if(_(e)){let i="toggle";return void 0!==r&&(i=r?"add":"remove"),e.classList[i](t),e.classList.contains(t)}return!1}function ee(e,t){return _(e)&&e.classList.contains(t)}function te(e,t){const{prototype:r}=Element;return(r.matches||r.webkitMatchesSelector||r.mozMatchesSelector||r.msMatchesSelector||function(){return Array.from(document.querySelectorAll(t)).includes(this)}).call(e,t)}function re(e){return this.elements.container.querySelectorAll(e)}function ie(e){return this.elements.container.querySelector(e)}function ne(e=null,t=!1){_(e)&&e.focus({preventScroll:!0,focusVisible:t})}const se={"audio/ogg":"vorbis","audio/wav":"1","video/webm":"vp8, vorbis","video/mp4":"avc1.42E01E, mp4a.40.2","video/ogg":"theora"},oe={audio:"canPlayType"in document.createElement("audio"),video:"canPlayType"in document.createElement("video"),check(e,t){const r=oe[e]||"html5"!==t;return{api:r,ui:r&&oe.rangeInput}},pip:!($.isIPhone||!P(W("video").webkitSetPresentationMode)&&(!document.pictureInPictureEnabled||W("video").disablePictureInPicture)),airplay:P(window.WebKitPlaybackTargetAvailabilityEvent),playsinline:"playsInline"in document.createElement("video"),mime(e){if(B(e))return!1;const[t]=e.split("/");let r=e;if(!this.isHTML5||t!==this.type)return!1;Object.keys(se).includes(r)&&(r+=`; codecs="${se[e]}"`);try{return Boolean(r&&this.media.canPlayType(r).replace(/no/,""))}catch(e){return!1}},textTracks:"textTracks"in document.createElement("video"),rangeInput:(()=>{const e=document.createElement("input");return e.type="range","range"===e.type})(),touch:"ontouchstart"in document.documentElement,transitions:!1!==U,reducedMotion:"matchMedia"in window&&window.matchMedia("(prefers-reduced-motion)").matches},ae=(()=>{let e=!1;try{const t=Object.defineProperty({},"passive",{get:()=>(e=!0,null)});window.addEventListener("test",null,t),window.removeEventListener("test",null,t)}catch(e){}return e})();function le(e,t,r,i=!1,n=!0,s=!1){if(!e||!("addEventListener"in e)||B(t)||!P(r))return;const o=t.split(" ");let a=s;ae&&(a={passive:n,capture:s}),o.forEach(t=>{this&&this.eventListeners&&i&&this.eventListeners.push({element:e,type:t,callback:r,options:a}),e[i?"addEventListener":"removeEventListener"](t,r,a)})}function ce(e,t="",r,i=!0,n=!1){le.call(this,e,t,r,!0,i,n)}function ue(e,t="",r,i=!0,n=!1){le.call(this,e,t,r,!1,i,n)}function de(e,t="",r,i=!0,n=!1){const s=(...o)=>{ue(e,t,s,i,n),r.apply(this,o)};le.call(this,e,t,s,!0,i,n)}function he(e,t="",r=!1,i={}){if(!_(e)||B(t))return;const n=new CustomEvent(t,{bubbles:r,detail:{...i,plyr:this}});e.dispatchEvent(n)}function fe(){this&&this.eventListeners&&(this.eventListeners.forEach(e=>{const{element:t,type:r,callback:i,options:n}=e;t.removeEventListener(r,i,n)}),this.eventListeners=[])}function pe(){return new Promise(e=>this.ready?setTimeout(e,0):ce.call(this,this.elements.container,"ready",e)).then(()=>{})}function ge(e){N(e)&&e.then(null,()=>{})}function me(e){return I(e)?e.filter((t,r)=>e.indexOf(t)===r):e}function ye(e,t){return I(e)&&e.length?e.reduce((e,r)=>Math.abs(r-t)({...e,[t/r]:[t,r]}),{});function Ee(e){return!!(I(e)||x(e)&&e.includes(":"))&&(I(e)?e:e.split(":")).map(Number).every(L)}function Ae(e){if(!I(e)||!e.every(L))return null;const[t,r]=e,i=(e,t)=>0===t?e:i(t,e%t),n=i(t,r);return[t/n,r/n]}function Te(e){const t=e=>Ee(e)?e.split(":").map(Number):null;let r=t(e);if(null===r&&(r=t(this.config.ratio)),null===r&&!B(this.embed)&&I(this.embed.ratio)&&({ratio:r}=this.embed),null===r&&this.isHTML5){const{videoWidth:e,videoHeight:t}=this.media;r=[e,t]}return Ae(r)}function we(e){if(!this.isVideo)return{};const{wrapper:t}=this.elements,r=Te.call(this,e);if(!I(r))return{};const[i,n]=Ae(r),s=100/i*n;if(ve(`aspect-ratio: ${i}/${n}`)?t.style.aspectRatio=`${i}/${n}`:t.style.paddingBottom=`${s}%`,this.isVimeo&&!this.config.vimeo.premium&&this.supported.ui){const e=100/this.media.offsetWidth*parseInt(window.getComputedStyle(this.media).paddingBottom,10),r=(e-s)/(e/50);this.fullscreen.active?t.style.paddingBottom=null:this.media.style.transform=`translateY(-${r}%)`}else this.isHTML5&&t.classList.add(this.config.classNames.videoFixedRatio);return{padding:s,ratio:r}}function Se(e,t,r=.05){const i=e/t,n=ye(Object.keys(be),i);return Math.abs(n-i)<=r?be[n]:[e,t]}const ke={getSources(){return this.isHTML5?Array.from(this.media.querySelectorAll("source")).filter(e=>{const t=e.getAttribute("type");return!!B(t)||oe.mime.call(this,t)}):[]},getQualityOptions(){return this.config.quality.forced?this.config.quality.options:ke.getSources.call(this).map(e=>Number(e.getAttribute("size"))).filter(Boolean)},setup(){if(!this.isHTML5)return;const e=this;e.options.speed=e.config.speed.options,B(this.config.ratio)||we.call(e),Object.defineProperty(e.media,"quality",{get(){const t=ke.getSources.call(e).find(t=>t.getAttribute("src")===e.source);return t&&Number(t.getAttribute("size"))},set(t){if(e.quality!==t){if(e.config.quality.forced&&P(e.config.quality.onChange))e.config.quality.onChange(t);else{const r=ke.getSources.call(e).find(e=>Number(e.getAttribute("size"))===t);if(!r)return;const{currentTime:i,paused:n,preload:s,readyState:o,playbackRate:a}=e.media;e.media.src=r.getAttribute("src"),("none"!==s||o)&&(e.once("loadedmetadata",()=>{e.speed=a,e.currentTime=i,n||ge(e.play())}),e.media.load())}he.call(e,e.media,"qualitychange",!1,{quality:t})}}})},cancelRequests(){this.isHTML5&&(z(ke.getSources.call(this)),this.media.setAttribute("src",this.config.blankVideo),this.media.load(),this.debug.log("Cancelled network requests"))}};function Le(e,...t){return B(e)?e:e.toString().replace(/{(\d+)}/g,(e,r)=>t[r].toString())}const xe=(e="",t="",r="")=>e.replace(new RegExp(t.toString().replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1"),"g"),r.toString()),Re=(e="")=>e.toString().replace(/\w\S*/g,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase());function Pe(e){const t=document.createElement("div");return t.appendChild(e),t.innerHTML}const Ie={pip:"PIP",airplay:"AirPlay",html5:"HTML5",vimeo:"Vimeo",youtube:"YouTube"},Ce={get(e="",t={}){if(B(e)||B(t))return"";let r=V(t.i18n,e);if(B(r))return Object.keys(Ie).includes(e)?Ie[e]:"";const i={"{seektime}":t.seekTime,"{title}":t.title};return Object.entries(i).forEach(([e,t])=>{r=xe(r,e,t)}),r}};class _e{constructor(t){e(this,"get",e=>{if(!_e.supported||!this.enabled)return null;const t=window.localStorage.getItem(this.key);if(B(t))return null;const r=JSON.parse(t);return x(e)&&e.length?r[e]:r}),e(this,"set",e=>{if(!_e.supported||!this.enabled)return;if(!k(e))return;let t=this.get();B(t)&&(t={}),H(t,e);try{window.localStorage.setItem(this.key,JSON.stringify(t))}catch(e){}}),this.enabled=t.config.storage.enabled,this.key=t.config.storage.key}static get supported(){try{if(!("localStorage"in window))return!1;const e="___test";return window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0}catch(e){return!1}}}function Oe(e,t="text"){return new Promise((r,i)=>{try{const i=new XMLHttpRequest;if(!("withCredentials"in i))return;i.addEventListener("load",()=>{if("text"===t)try{r(JSON.parse(i.responseText))}catch(e){r(i.responseText)}else r(i.response)}),i.addEventListener("error",()=>{throw new Error(i.status)}),i.open("GET",e,!0),i.responseType=t,i.send()}catch(e){i(e)}})}function De(e,t){if(!x(e))return;const r="cache",i=x(t);let n=!1;const s=()=>null!==document.getElementById(t),o=(e,t)=>{e.innerHTML=t,i&&s()||document.body.insertAdjacentElement("afterbegin",e)};if(!i||!s()){const s=_e.supported,a=document.createElement("div");if(a.setAttribute("hidden",""),i&&a.setAttribute("id",t),s){const e=window.localStorage.getItem(`${r}-${t}`);if(n=null!==e,n){const t=JSON.parse(e);o(a,t.content)}}Oe(e).then(e=>{if(!B(e)){if(s)try{window.localStorage.setItem(`${r}-${t}`,JSON.stringify({content:e}))}catch(e){}o(a,e)}}).catch(()=>{})}}const Me=e=>Math.trunc(e/60/60%60,10);function Ne(e=0,t=!1,r=!1){if(!L(e))return Ne(void 0,t,r);const i=e=>`0${e}`.slice(-2);let n=Me(e);const s=(e=>Math.trunc(e/60%60,10))(e),o=(e=>Math.trunc(e%60,10))(e);return n=t||n>0?`${n}:`:"",`${r&&e>0?"-":""}${n}${i(s)}:${i(o)}`}const Fe={getIconUrl(){const e=new URL(this.config.iconUrl,window.location),t=window.location.host?window.location.host:window.top.location.host,r=e.host!==t||$.isIE&&!window.svg4everybody;return{url:this.config.iconUrl,cors:r}},findElements(){try{return this.elements.controls=ie.call(this,this.config.selectors.controls.wrapper),this.elements.buttons={play:re.call(this,this.config.selectors.buttons.play),pause:ie.call(this,this.config.selectors.buttons.pause),restart:ie.call(this,this.config.selectors.buttons.restart),rewind:ie.call(this,this.config.selectors.buttons.rewind),fastForward:ie.call(this,this.config.selectors.buttons.fastForward),mute:ie.call(this,this.config.selectors.buttons.mute),pip:ie.call(this,this.config.selectors.buttons.pip),airplay:ie.call(this,this.config.selectors.buttons.airplay),settings:ie.call(this,this.config.selectors.buttons.settings),captions:ie.call(this,this.config.selectors.buttons.captions),fullscreen:ie.call(this,this.config.selectors.buttons.fullscreen)},this.elements.progress=ie.call(this,this.config.selectors.progress),this.elements.inputs={seek:ie.call(this,this.config.selectors.inputs.seek),volume:ie.call(this,this.config.selectors.inputs.volume)},this.elements.display={buffer:ie.call(this,this.config.selectors.display.buffer),currentTime:ie.call(this,this.config.selectors.display.currentTime),duration:ie.call(this,this.config.selectors.display.duration)},_(this.elements.progress)&&(this.elements.display.seekTooltip=this.elements.progress.querySelector(`.${this.config.classNames.tooltip}`)),!0}catch(e){return this.debug.warn("It looks like there is a problem with your custom controls HTML",e),this.toggleNativeControls(!0),!1}},createIcon(e,t){const r="http://www.w3.org/2000/svg",i=Fe.getIconUrl.call(this),n=`${i.cors?"":i.url}#${this.config.iconPrefix}`,s=document.createElementNS(r,"svg");K(s,H(t,{"aria-hidden":"true",focusable:"false"}));const o=document.createElementNS(r,"use"),a=`${n}-${e}`;return"href"in o&&o.setAttributeNS("http://www.w3.org/1999/xlink","href",a),o.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a),s.appendChild(o),s},createLabel(e,t={}){const r=Ce.get(e,this.config);return W("span",{...t,class:[t.class,this.config.classNames.hidden].filter(Boolean).join(" ")},r)},createBadge(e){if(B(e))return null;const t=W("span",{class:this.config.classNames.menu.value});return t.appendChild(W("span",{class:this.config.classNames.menu.badge},e)),t},createButton(e,t){const r=H({},t);let i=function(e=""){let t=e.toString();return t=function(e=""){let t=e.toString();return t=xe(t,"-"," "),t=xe(t,"_"," "),t=Re(t),xe(t," ","")}(t),t.charAt(0).toLowerCase()+t.slice(1)}(e);const n={element:"button",toggle:!1,label:null,icon:null,labelPressed:null,iconPressed:null};switch(["element","icon","label"].forEach(e=>{Object.keys(r).includes(e)&&(n[e]=r[e],delete r[e])}),"button"!==n.element||Object.keys(r).includes("type")||(r.type="button"),Object.keys(r).includes("class")?r.class.split(" ").some(e=>e===this.config.classNames.control)||H(r,{class:`${r.class} ${this.config.classNames.control}`}):r.class=this.config.classNames.control,e){case"play":n.toggle=!0,n.label="play",n.labelPressed="pause",n.icon="play",n.iconPressed="pause";break;case"mute":n.toggle=!0,n.label="mute",n.labelPressed="unmute",n.icon="volume",n.iconPressed="muted";break;case"captions":n.toggle=!0,n.label="enableCaptions",n.labelPressed="disableCaptions",n.icon="captions-off",n.iconPressed="captions-on";break;case"fullscreen":n.toggle=!0,n.label="enterFullscreen",n.labelPressed="exitFullscreen",n.icon="enter-fullscreen",n.iconPressed="exit-fullscreen";break;case"play-large":r.class+=` ${this.config.classNames.control}--overlaid`,i="play",n.label="play",n.icon="play";break;default:B(n.label)&&(n.label=i),B(n.icon)&&(n.icon=e)}const s=W(n.element);return n.toggle?(s.appendChild(Fe.createIcon.call(this,n.iconPressed,{class:"icon--pressed"})),s.appendChild(Fe.createIcon.call(this,n.icon,{class:"icon--not-pressed"})),s.appendChild(Fe.createLabel.call(this,n.labelPressed,{class:"label--pressed"})),s.appendChild(Fe.createLabel.call(this,n.label,{class:"label--not-pressed"}))):(s.appendChild(Fe.createIcon.call(this,n.icon)),s.appendChild(Fe.createLabel.call(this,n.label))),H(r,Q(this.config.selectors.buttons[i],r)),K(s,r),"play"===i?(I(this.elements.buttons[i])||(this.elements.buttons[i]=[]),this.elements.buttons[i].push(s)):this.elements.buttons[i]=s,s},createRange(e,t){const r=W("input",H(Q(this.config.selectors.inputs[e]),{type:"range",min:0,max:100,step:.01,value:0,autocomplete:"off",role:"slider","aria-label":Ce.get(e,this.config),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":0},t));return this.elements.inputs[e]=r,Fe.updateRangeFill.call(this,r),p.setup(r),r},createProgress(e,t){const r=W("progress",H(Q(this.config.selectors.display[e]),{min:0,max:100,value:0,role:"progressbar","aria-hidden":!0},t));if("volume"!==e){r.appendChild(W("span",null,"0"));const t={played:"played",buffer:"buffered"}[e],i=t?Ce.get(t,this.config):"";r.innerText=`% ${i.toLowerCase()}`}return this.elements.display[e]=r,r},createTime(e,t){const r=Q(this.config.selectors.display[e],t),i=W("div",H(r,{class:`${r.class?r.class:""} ${this.config.classNames.display.time} `.trim(),"aria-label":Ce.get(e,this.config),role:"timer"}),"00:00");return this.elements.display[e]=i,i},bindMenuItemShortcuts(e,t){ce.call(this,e,"keydown keyup",r=>{if(![" ","ArrowUp","ArrowDown","ArrowRight"].includes(r.key))return;if(r.preventDefault(),r.stopPropagation(),"keydown"===r.type)return;const i=te(e,'[role="menuitemradio"]');if(!i&&[" ","ArrowRight"].includes(r.key))Fe.showMenuPanel.call(this,t,!0);else{let t;" "!==r.key&&("ArrowDown"===r.key||i&&"ArrowRight"===r.key?(t=e.nextElementSibling,_(t)||(t=e.parentNode.firstElementChild)):(t=e.previousElementSibling,_(t)||(t=e.parentNode.lastElementChild)),ne.call(this,t,!0))}},!1),ce.call(this,e,"keyup",e=>{"Return"===e.key&&Fe.focusFirstMenuItem.call(this,null,!0)})},createMenuItem({value:e,list:t,type:r,title:i,badge:n=null,checked:s=!1}){const o=Q(this.config.selectors.inputs[r]),a=W("button",H(o,{type:"button",role:"menuitemradio",class:`${this.config.classNames.control} ${o.class?o.class:""}`.trim(),"aria-checked":s,value:e})),l=W("span");l.innerHTML=i,_(n)&&l.appendChild(n),a.appendChild(l),Object.defineProperty(a,"checked",{enumerable:!0,get:()=>"true"===a.getAttribute("aria-checked"),set(e){e&&Array.from(a.parentNode.children).filter(e=>te(e,'[role="menuitemradio"]')).forEach(e=>e.setAttribute("aria-checked","false")),a.setAttribute("aria-checked",e?"true":"false")}}),this.listeners.bind(a,"click keyup",t=>{if(!D(t)||" "===t.key){switch(t.preventDefault(),t.stopPropagation(),a.checked=!0,r){case"language":this.currentTrack=Number(e);break;case"quality":this.quality=e;break;case"speed":this.speed=parseFloat(e)}Fe.showMenuPanel.call(this,"home",D(t))}},r,!1),Fe.bindMenuItemShortcuts.call(this,a,r),t.appendChild(a)},formatTime(e=0,t=!1){return L(e)?Ne(e,Me(this.duration)>0,t):e},updateTimeDisplay(e=null,t=0,r=!1){_(e)&&L(t)&&(e.innerText=Fe.formatTime(t,r))},updateVolume(){this.supported.ui&&(_(this.elements.inputs.volume)&&Fe.setRange.call(this,this.elements.inputs.volume,this.muted?0:this.volume),_(this.elements.buttons.mute)&&(this.elements.buttons.mute.pressed=this.muted||0===this.volume))},setRange(e,t=0){_(e)&&(e.value=t,Fe.updateRangeFill.call(this,e))},updateProgress(e){if(!this.supported.ui||!O(e))return;let t=0;const r=(e,t)=>{const r=L(t)?t:0,i=_(e)?e:this.elements.display.buffer;if(_(i)){i.value=r;const e=i.getElementsByTagName("span")[0];_(e)&&(e.childNodes[0].nodeValue=r)}};if(e)switch(e.type){case"timeupdate":case"seeking":case"seeked":i=this.currentTime,n=this.duration,t=0===i||0===n||Number.isNaN(i)||Number.isNaN(n)?0:(i/n*100).toFixed(2),"timeupdate"===e.type&&Fe.setRange.call(this,this.elements.inputs.seek,t);break;case"playing":case"progress":r(this.elements.display.buffer,100*this.buffered)}var i,n},updateRangeFill(e){const t=O(e)?e.target:e;if(_(t)&&"range"===t.getAttribute("type")){if(te(t,this.config.selectors.inputs.seek)){t.setAttribute("aria-valuenow",this.currentTime);const e=Fe.formatTime(this.currentTime),r=Fe.formatTime(this.duration),i=Ce.get("seekLabel",this.config);t.setAttribute("aria-valuetext",i.replace("{currentTime}",e).replace("{duration}",r))}else if(te(t,this.config.selectors.inputs.volume)){const e=100*t.value;t.setAttribute("aria-valuenow",e),t.setAttribute("aria-valuetext",`${e.toFixed(1)}%`)}else t.setAttribute("aria-valuenow",t.value);($.isWebKit||$.isIPadOS)&&t.style.setProperty("--value",t.value/t.max*100+"%")}},updateSeekTooltip(e){var t,r;if(!this.config.tooltips.seek||!_(this.elements.inputs.seek)||!_(this.elements.display.seekTooltip)||0===this.duration)return;const i=this.elements.display.seekTooltip,n=`${this.config.classNames.tooltip}--visible`,s=e=>Z(i,n,e);if(this.touch)return void s(!1);let o=0;const a=this.elements.progress.getBoundingClientRect();if(O(e))o=100/a.width*(e.pageX-a.left);else{if(!ee(i,n))return;o=parseFloat(i.style.left,10)}o<0?o=0:o>100&&(o=100);const l=this.duration/100*o;i.innerText=Fe.formatTime(l);const c=null===(t=this.config.markers)||void 0===t||null===(r=t.points)||void 0===r?void 0:r.find(({time:e})=>e===Math.round(l));c&&i.insertAdjacentHTML("afterbegin",`${c.label}
`),i.style.left=`${o}%`,O(e)&&["mouseenter","mouseleave"].includes(e.type)&&s("mouseenter"===e.type)},timeUpdate(e){const t=!_(this.elements.display.duration)&&this.config.invertTime;Fe.updateTimeDisplay.call(this,this.elements.display.currentTime,t?this.duration-this.currentTime:this.currentTime,t),e&&"timeupdate"===e.type&&this.media.seeking||Fe.updateProgress.call(this,e)},durationUpdate(){if(!this.supported.ui||!this.config.invertTime&&this.currentTime)return;if(this.duration>=2**32)return J(this.elements.display.currentTime,!0),void J(this.elements.progress,!0);_(this.elements.inputs.seek)&&this.elements.inputs.seek.setAttribute("aria-valuemax",this.duration);const e=_(this.elements.display.duration);!e&&this.config.displayDuration&&this.paused&&Fe.updateTimeDisplay.call(this,this.elements.display.currentTime,this.duration),e&&Fe.updateTimeDisplay.call(this,this.elements.display.duration,this.duration),this.config.markers.enabled&&Fe.setMarkers.call(this),Fe.updateSeekTooltip.call(this)},toggleMenuButton(e,t){J(this.elements.settings.buttons[e],!t)},updateSetting(e,t,r){const i=this.elements.settings.panels[e];let n=null,s=t;if("captions"===e)n=this.currentTrack;else{if(n=B(r)?this[e]:r,B(n)&&(n=this.config[e].default),!B(this.options[e])&&!this.options[e].includes(n))return void this.debug.warn(`Unsupported value of '${n}' for ${e}`);if(!this.config[e].options.includes(n))return void this.debug.warn(`Disabled value of '${n}' for ${e}`)}if(_(s)||(s=i&&i.querySelector('[role="menu"]')),!_(s))return;this.elements.settings.buttons[e].querySelector(`.${this.config.classNames.menu.value}`).innerHTML=Fe.getLabel.call(this,e,n);const o=s&&s.querySelector(`[value="${n}"]`);_(o)&&(o.checked=!0)},getLabel(e,t){switch(e){case"speed":return 1===t?Ce.get("normal",this.config):`${t}×`;case"quality":if(L(t)){const e=Ce.get(`qualityLabel.${t}`,this.config);return e.length?e:`${t}p`}return Re(t);case"captions":return je.getLabel.call(this);default:return null}},setQualityMenu(e){if(!_(this.elements.settings.panels.quality))return;const t="quality",r=this.elements.settings.panels.quality.querySelector('[role="menu"]');I(e)&&(this.options.quality=me(e).filter(e=>this.config.quality.options.includes(e)));const i=!B(this.options.quality)&&this.options.quality.length>1;if(Fe.toggleMenuButton.call(this,t,i),Y(r),Fe.checkMenu.call(this),!i)return;const n=e=>{const t=Ce.get(`qualityBadge.${e}`,this.config);return t.length?Fe.createBadge.call(this,t):null};this.options.quality.sort((e,t)=>{const r=this.config.quality.options;return r.indexOf(e)>r.indexOf(t)?1:-1}).forEach(e=>{Fe.createMenuItem.call(this,{value:e,list:r,type:t,title:Fe.getLabel.call(this,"quality",e),badge:n(e)})}),Fe.updateSetting.call(this,t,r)},setCaptionsMenu(){if(!_(this.elements.settings.panels.captions))return;const e="captions",t=this.elements.settings.panels.captions.querySelector('[role="menu"]'),r=je.getTracks.call(this),i=Boolean(r.length);if(Fe.toggleMenuButton.call(this,e,i),Y(t),Fe.checkMenu.call(this),!i)return;const n=r.map((e,r)=>({value:r,checked:this.captions.toggled&&this.currentTrack===r,title:je.getLabel.call(this,e),badge:e.language&&Fe.createBadge.call(this,e.language.toUpperCase()),list:t,type:"language"}));n.unshift({value:-1,checked:!this.captions.toggled,title:Ce.get("disabled",this.config),list:t,type:"language"}),n.forEach(Fe.createMenuItem.bind(this)),Fe.updateSetting.call(this,e,t)},setSpeedMenu(){if(!_(this.elements.settings.panels.speed))return;const e="speed",t=this.elements.settings.panels.speed.querySelector('[role="menu"]');this.options.speed=this.options.speed.filter(e=>e>=this.minimumSpeed&&e<=this.maximumSpeed);const r=!B(this.options.speed)&&this.options.speed.length>1;Fe.toggleMenuButton.call(this,e,r),Y(t),Fe.checkMenu.call(this),r&&(this.options.speed.forEach(r=>{Fe.createMenuItem.call(this,{value:r,list:t,type:e,title:Fe.getLabel.call(this,"speed",r)})}),Fe.updateSetting.call(this,e,t))},checkMenu(){const{buttons:e}=this.elements.settings,t=!B(e)&&Object.values(e).some(e=>!e.hidden);J(this.elements.settings.menu,!t)},focusFirstMenuItem(e,t=!1){if(this.elements.settings.popup.hidden)return;let r=e;_(r)||(r=Object.values(this.elements.settings.panels).find(e=>!e.hidden));const i=r.querySelector('[role^="menuitem"]');ne.call(this,i,t)},toggleMenu(e){const{popup:t}=this.elements.settings,r=this.elements.buttons.settings;if(!_(t)||!_(r))return;const{hidden:i}=t;let n=i;if(R(e))n=e;else if(D(e)&&"Escape"===e.key)n=!1;else if(O(e)){const i=P(e.composedPath)?e.composedPath()[0]:e.target,s=t.contains(i);if(s||!s&&e.target!==r&&n)return}r.setAttribute("aria-expanded",n),J(t,!n),Z(this.elements.container,this.config.classNames.menu.open,n),n&&D(e)?Fe.focusFirstMenuItem.call(this,null,!0):n||i||ne.call(this,r,D(e))},getMenuSize(e){const t=e.cloneNode(!0);t.style.position="absolute",t.style.opacity=0,t.removeAttribute("hidden"),e.parentNode.appendChild(t);const r=t.scrollWidth,i=t.scrollHeight;return z(t),{width:r,height:i}},showMenuPanel(e="",t=!1){const r=this.elements.container.querySelector(`#plyr-settings-${this.id}-${e}`);if(!_(r))return;const i=r.parentNode,n=Array.from(i.children).find(e=>!e.hidden);if(oe.transitions&&!oe.reducedMotion){i.style.width=`${n.scrollWidth}px`,i.style.height=`${n.scrollHeight}px`;const e=Fe.getMenuSize.call(this,r),t=e=>{e.target===i&&["width","height"].includes(e.propertyName)&&(i.style.width="",i.style.height="",ue.call(this,i,U,t))};ce.call(this,i,U,t),i.style.width=`${e.width}px`,i.style.height=`${e.height}px`}J(n,!0),J(r,!1),Fe.focusFirstMenuItem.call(this,r,t)},setDownloadUrl(){const e=this.elements.buttons.download;_(e)&&e.setAttribute("href",this.download)},create(e){const{bindMenuItemShortcuts:t,createButton:r,createProgress:i,createRange:n,createTime:s,setQualityMenu:o,setSpeedMenu:a,showMenuPanel:l}=Fe;this.elements.controls=null,I(this.config.controls)&&this.config.controls.includes("play-large")&&this.elements.container.appendChild(r.call(this,"play-large"));const c=W("div",Q(this.config.selectors.controls.wrapper));this.elements.controls=c;const u={class:"plyr__controls__item"};return me(I(this.config.controls)?this.config.controls:[]).forEach(o=>{if("restart"===o&&c.appendChild(r.call(this,"restart",u)),"rewind"===o&&c.appendChild(r.call(this,"rewind",u)),"play"===o&&c.appendChild(r.call(this,"play",u)),"fast-forward"===o&&c.appendChild(r.call(this,"fast-forward",u)),"progress"===o){const t=W("div",{class:`${u.class} plyr__progress__container`}),r=W("div",Q(this.config.selectors.progress));if(r.appendChild(n.call(this,"seek",{id:`plyr-seek-${e.id}`})),r.appendChild(i.call(this,"buffer")),this.config.tooltips.seek){const e=W("span",{class:this.config.classNames.tooltip},"00:00");r.appendChild(e),this.elements.display.seekTooltip=e}this.elements.progress=r,t.appendChild(this.elements.progress),c.appendChild(t)}if("current-time"===o&&c.appendChild(s.call(this,"currentTime",u)),"duration"===o&&c.appendChild(s.call(this,"duration",u)),"mute"===o||"volume"===o){let{volume:t}=this.elements;if(_(t)&&c.contains(t)||(t=W("div",H({},u,{class:`${u.class} plyr__volume`.trim()})),this.elements.volume=t,c.appendChild(t)),"mute"===o&&t.appendChild(r.call(this,"mute")),"volume"===o&&!$.isIos&&!$.isIPadOS){const r={max:1,step:.05,value:this.config.volume};t.appendChild(n.call(this,"volume",H(r,{id:`plyr-volume-${e.id}`})))}}if("captions"===o&&c.appendChild(r.call(this,"captions",u)),"settings"===o&&!B(this.config.settings)){const i=W("div",H({},u,{class:`${u.class} plyr__menu`.trim(),hidden:""}));i.appendChild(r.call(this,"settings",{"aria-haspopup":!0,"aria-controls":`plyr-settings-${e.id}`,"aria-expanded":!1}));const n=W("div",{class:"plyr__menu__container",id:`plyr-settings-${e.id}`,hidden:""}),s=W("div"),o=W("div",{id:`plyr-settings-${e.id}-home`}),a=W("div",{role:"menu"});o.appendChild(a),s.appendChild(o),this.elements.settings.panels.home=o,this.config.settings.forEach(r=>{const i=W("button",H(Q(this.config.selectors.buttons.settings),{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--forward`,role:"menuitem","aria-haspopup":!0,hidden:""}));t.call(this,i,r),ce.call(this,i,"click",()=>{l.call(this,r,!1)});const n=W("span",null,Ce.get(r,this.config)),o=W("span",{class:this.config.classNames.menu.value});o.innerHTML=e[r],n.appendChild(o),i.appendChild(n),a.appendChild(i);const c=W("div",{id:`plyr-settings-${e.id}-${r}`,hidden:""}),u=W("button",{type:"button",class:`${this.config.classNames.control} ${this.config.classNames.control}--back`});u.appendChild(W("span",{"aria-hidden":!0},Ce.get(r,this.config))),u.appendChild(W("span",{class:this.config.classNames.hidden},Ce.get("menuBack",this.config))),ce.call(this,c,"keydown",e=>{"ArrowLeft"===e.key&&(e.preventDefault(),e.stopPropagation(),l.call(this,"home",!0))},!1),ce.call(this,u,"click",()=>{l.call(this,"home",!1)}),c.appendChild(u),c.appendChild(W("div",{role:"menu"})),s.appendChild(c),this.elements.settings.buttons[r]=i,this.elements.settings.panels[r]=c}),n.appendChild(s),i.appendChild(n),c.appendChild(i),this.elements.settings.popup=n,this.elements.settings.menu=i}if("pip"===o&&oe.pip&&c.appendChild(r.call(this,"pip",u)),"airplay"===o&&oe.airplay&&c.appendChild(r.call(this,"airplay",u)),"download"===o){const e=H({},u,{element:"a",href:this.download,target:"_blank"});this.isHTML5&&(e.download="");const{download:t}=this.config.urls;!F(t)&&this.isEmbed&&H(e,{icon:`logo-${this.provider}`,label:this.provider}),c.appendChild(r.call(this,"download",e))}"fullscreen"===o&&c.appendChild(r.call(this,"fullscreen",u))}),this.isHTML5&&o.call(this,ke.getQualityOptions.call(this)),a.call(this),c},inject(){if(this.config.loadSprite){const e=Fe.getIconUrl.call(this);e.cors&&De(e.url,"sprite-plyr")}this.id=Math.floor(1e4*Math.random());let e=null;this.elements.controls=null;const t={id:this.id,seektime:this.config.seekTime,title:this.config.title};let r,i=!0;if(P(this.config.controls)&&(this.config.controls=this.config.controls.call(this,t)),this.config.controls||(this.config.controls=[]),_(this.config.controls)||x(this.config.controls)?e=this.config.controls:(e=Fe.create.call(this,{id:this.id,seektime:this.config.seekTime,speed:this.speed,quality:this.quality,captions:je.getLabel.call(this)}),i=!1),i&&x(this.config.controls)&&(e=(e=>{let r=e;return Object.entries(t).forEach(([e,t])=>{r=xe(r,`{${e}}`,t)}),r})(e)),x(this.config.selectors.controls.container)&&(r=document.querySelector(this.config.selectors.controls.container)),_(r)||(r=this.elements.container),r[_(e)?"insertAdjacentElement":"insertAdjacentHTML"]("afterbegin",e),_(this.elements.controls)||Fe.findElements.call(this),!B(this.elements.buttons)){const e=e=>{const t=this.config.classNames.controlPressed;e.setAttribute("aria-pressed","false"),Object.defineProperty(e,"pressed",{configurable:!0,enumerable:!0,get:()=>ee(e,t),set(r=!1){Z(e,t,r),e.setAttribute("aria-pressed",r?"true":"false")}})};Object.values(this.elements.buttons).filter(Boolean).forEach(t=>{I(t)||C(t)?Array.from(t).filter(Boolean).forEach(e):e(t)})}if($.isEdge&&j(r),this.config.tooltips.controls){const{classNames:e,selectors:t}=this.config,r=`${t.controls.wrapper} ${t.labels} .${e.hidden}`,i=re.call(this,r);Array.from(i).forEach(e=>{Z(e,this.config.classNames.hidden,!1),Z(e,this.config.classNames.tooltip,!0)})}},setMediaMetadata(){try{"mediaSession"in navigator&&(navigator.mediaSession.metadata=new window.MediaMetadata({title:this.config.mediaMetadata.title,artist:this.config.mediaMetadata.artist,album:this.config.mediaMetadata.album,artwork:this.config.mediaMetadata.artwork}))}catch(e){}},setMarkers(){var e,t;if(!this.duration||this.elements.markers)return;const r=null===(e=this.config.markers)||void 0===e||null===(t=e.points)||void 0===t?void 0:t.filter(({time:e})=>e>0&&eZ(s,o,e);r.forEach(e=>{const t=W("span",{class:this.config.classNames.marker},""),r=e.time/this.duration*100+"%";s&&(t.addEventListener("mouseenter",()=>{e.label||(s.style.left=r,s.innerHTML=e.label,a(!0))}),t.addEventListener("mouseleave",()=>{a(!1)})),t.addEventListener("click",()=>{this.currentTime=e.time}),t.style.left=r,n.appendChild(t)}),i.appendChild(n),this.config.tooltips.seek||(s=W("span",{class:this.config.classNames.tooltip},""),i.appendChild(s)),this.elements.markers={points:n,tip:s},this.elements.progress.appendChild(i)}};function Be(e,t=!0){let r=e;if(t){const e=document.createElement("a");e.href=r,r=e.href}try{return new URL(r)}catch(e){return null}}function Ue(e){const t=new URLSearchParams;return k(e)&&Object.entries(e).forEach(([e,r])=>{t.set(e,r)}),t}const je={setup(){if(!this.supported.ui)return;if(!this.isVideo||this.isYouTube||this.isHTML5&&!oe.textTracks)return void(I(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&Fe.setCaptionsMenu.call(this));var e,t;if(_(this.elements.captions)||(this.elements.captions=W("div",Q(this.config.selectors.captions)),this.elements.captions.setAttribute("dir","auto"),e=this.elements.captions,t=this.elements.wrapper,_(e)&&_(t)&&t.parentNode.insertBefore(e,t.nextSibling)),$.isIE&&window.URL){const e=this.media.querySelectorAll("track");Array.from(e).forEach(e=>{const t=e.getAttribute("src"),r=Be(t);null!==r&&r.hostname!==window.location.href.hostname&&["http:","https:"].includes(r.protocol)&&Oe(t,"blob").then(t=>{e.setAttribute("src",window.URL.createObjectURL(t))}).catch(()=>{z(e)})})}const r=me((navigator.languages||[navigator.language||navigator.userLanguage||"en"]).map(e=>e.split("-")[0]));let i=(this.storage.get("language")||this.config.captions.language||"auto").toLowerCase();"auto"===i&&([i]=r);let n=this.storage.get("captions");if(R(n)||({active:n}=this.config.captions),Object.assign(this.captions,{toggled:!1,active:n,language:i,languages:r}),this.isHTML5){const e=this.config.captions.update?"addtrack removetrack":"removetrack";ce.call(this,this.media.textTracks,e,je.update.bind(this))}setTimeout(je.update.bind(this),0)},update(){const e=je.getTracks.call(this,!0),{active:t,language:r,meta:i,currentTrackNode:n}=this.captions,s=Boolean(e.find(e=>e.language===r));this.isHTML5&&this.isVideo&&e.filter(e=>!i.get(e)).forEach(e=>{this.debug.log("Track added",e),i.set(e,{default:"showing"===e.mode}),"showing"===e.mode&&(e.mode="hidden"),ce.call(this,e,"cuechange",()=>je.updateCues.call(this))}),(s&&this.language!==r||!e.includes(n))&&(je.setLanguage.call(this,r),je.toggle.call(this,t&&s)),this.elements&&Z(this.elements.container,this.config.classNames.captions.enabled,!B(e)),I(this.config.controls)&&this.config.controls.includes("settings")&&this.config.settings.includes("captions")&&Fe.setCaptionsMenu.call(this)},toggle(e,t=!0){if(!this.supported.ui)return;const{toggled:r}=this.captions,i=this.config.classNames.captions.active,n=S(e)?!r:e;if(n!==r){if(t||(this.captions.active=n,this.storage.set({captions:n})),!this.language&&n&&!t){const e=je.getTracks.call(this),t=je.findTrack.call(this,[this.captions.language,...this.captions.languages],!0);return this.captions.language=t.language,void je.set.call(this,e.indexOf(t))}this.elements.buttons.captions&&(this.elements.buttons.captions.pressed=n),Z(this.elements.container,i,n),this.captions.toggled=n,Fe.updateSetting.call(this,"captions"),he.call(this,this.media,n?"captionsenabled":"captionsdisabled")}setTimeout(()=>{n&&this.captions.toggled&&(this.captions.currentTrackNode.mode="hidden")})},set(e,t=!0){const r=je.getTracks.call(this);if(-1!==e)if(L(e))if(e in r){if(this.captions.currentTrack!==e){this.captions.currentTrack=e;const i=r[e],{language:n}=i||{};this.captions.currentTrackNode=i,Fe.updateSetting.call(this,"captions"),t||(this.captions.language=n,this.storage.set({language:n})),this.isVimeo&&this.embed.enableTextTrack(n),he.call(this,this.media,"languagechange")}je.toggle.call(this,!0,t),this.isHTML5&&this.isVideo&&je.updateCues.call(this)}else this.debug.warn("Track not found",e);else this.debug.warn("Invalid caption argument",e);else je.toggle.call(this,!1,t)},setLanguage(e,t=!0){if(!x(e))return void this.debug.warn("Invalid language argument",e);const r=e.toLowerCase();this.captions.language=r;const i=je.getTracks.call(this),n=je.findTrack.call(this,[r]);je.set.call(this,i.indexOf(n),t)},getTracks(e=!1){return Array.from((this.media||{}).textTracks||[]).filter(t=>!this.isHTML5||e||this.captions.meta.has(t)).filter(e=>["captions","subtitles"].includes(e.kind))},findTrack(e,t=!1){const r=je.getTracks.call(this),i=e=>Number((this.captions.meta.get(e)||{}).default),n=Array.from(r).sort((e,t)=>i(t)-i(e));let s;return e.every(e=>(s=n.find(t=>t.language===e),!s)),s||(t?n[0]:void 0)},getCurrentTrack(){return je.getTracks.call(this)[this.currentTrack]},getLabel(e){let t=e;return!M(t)&&oe.textTracks&&this.captions.toggled&&(t=je.getCurrentTrack.call(this)),M(t)?B(t.label)?B(t.language)?Ce.get("enabled",this.config):e.language.toUpperCase():t.label:Ce.get("disabled",this.config)},updateCues(e){if(!this.supported.ui)return;if(!_(this.elements.captions))return void this.debug.warn("No captions element to render to");if(!S(e)&&!Array.isArray(e))return void this.debug.warn("updateCues: Invalid input",e);let t=e;if(!t){const e=je.getCurrentTrack.call(this);t=Array.from((e||{}).activeCues||[]).map(e=>e.getCueAsHTML()).map(Pe)}const r=t.map(e=>e.trim()).join("\n");if(r!==this.elements.captions.innerHTML){Y(this.elements.captions);const e=W("span",Q(this.config.selectors.caption));e.innerHTML=r,this.elements.captions.appendChild(e),he.call(this,this.media,"cuechange")}}},$e={enabled:!0,title:"",debug:!1,autoplay:!1,autopause:!0,playsinline:!0,seekTime:10,volume:1,muted:!1,duration:null,displayDuration:!0,invertTime:!0,toggleInvert:!0,ratio:null,clickToPlay:!0,hideControls:!0,resetOnEnd:!1,disableContextMenu:!0,loadSprite:!0,iconPrefix:"plyr",iconUrl:"https://cdn.plyr.io/3.7.8/plyr.svg",blankVideo:"https://cdn.plyr.io/static/blank.mp4",quality:{default:576,options:[4320,2880,2160,1440,1080,720,576,480,360,240],forced:!1,onChange:null},loop:{active:!1},speed:{selected:1,options:[.5,.75,1,1.25,1.5,1.75,2,4]},keyboard:{focused:!0,global:!1},tooltips:{controls:!1,seek:!0},captions:{active:!1,language:"auto",update:!1},fullscreen:{enabled:!0,fallback:!0,iosNative:!1},storage:{enabled:!0,key:"plyr"},controls:["play-large","play","progress","current-time","mute","volume","captions","settings","pip","airplay","fullscreen"],settings:["captions","quality","speed"],i18n:{restart:"Restart",rewind:"Rewind {seektime}s",play:"Play",pause:"Pause",fastForward:"Forward {seektime}s",seek:"Seek",seekLabel:"{currentTime} of {duration}",played:"Played",buffered:"Buffered",currentTime:"Current time",duration:"Duration",volume:"Volume",mute:"Mute",unmute:"Unmute",enableCaptions:"Enable captions",disableCaptions:"Disable captions",download:"Download",enterFullscreen:"Enter fullscreen",exitFullscreen:"Exit fullscreen",frameTitle:"Player for {title}",captions:"Captions",settings:"Settings",pip:"PIP",menuBack:"Go back to previous menu",speed:"Speed",normal:"Normal",quality:"Quality",loop:"Loop",start:"Start",end:"End",all:"All",reset:"Reset",disabled:"Disabled",enabled:"Enabled",advertisement:"Ad",qualityBadge:{2160:"4K",1440:"HD",1080:"HD",720:"HD",576:"SD",480:"SD"}},urls:{download:null,vimeo:{sdk:"https://player.vimeo.com/api/player.js",iframe:"https://player.vimeo.com/video/{0}?{1}",api:"https://vimeo.com/api/oembed.json?url={0}"},youtube:{sdk:"https://www.youtube.com/iframe_api",api:"https://noembed.com/embed?url=https://www.youtube.com/watch?v={0}"},googleIMA:{sdk:"https://imasdk.googleapis.com/js/sdkloader/ima3.js"}},listeners:{seek:null,play:null,pause:null,restart:null,rewind:null,fastForward:null,mute:null,volume:null,captions:null,download:null,fullscreen:null,pip:null,airplay:null,speed:null,quality:null,loop:null,language:null},events:["ended","progress","stalled","playing","waiting","canplay","canplaythrough","loadstart","loadeddata","loadedmetadata","timeupdate","volumechange","play","pause","error","seeking","seeked","emptied","ratechange","cuechange","download","enterfullscreen","exitfullscreen","captionsenabled","captionsdisabled","languagechange","controlshidden","controlsshown","ready","statechange","qualitychange","adsloaded","adscontentpause","adscontentresume","adstarted","adsmidpoint","adscomplete","adsallcomplete","adsimpression","adsclick"],selectors:{editable:"input, textarea, select, [contenteditable]",container:".plyr",controls:{container:null,wrapper:".plyr__controls"},labels:"[data-plyr]",buttons:{play:'[data-plyr="play"]',pause:'[data-plyr="pause"]',restart:'[data-plyr="restart"]',rewind:'[data-plyr="rewind"]',fastForward:'[data-plyr="fast-forward"]',mute:'[data-plyr="mute"]',captions:'[data-plyr="captions"]',download:'[data-plyr="download"]',fullscreen:'[data-plyr="fullscreen"]',pip:'[data-plyr="pip"]',airplay:'[data-plyr="airplay"]',settings:'[data-plyr="settings"]',loop:'[data-plyr="loop"]'},inputs:{seek:'[data-plyr="seek"]',volume:'[data-plyr="volume"]',speed:'[data-plyr="speed"]',language:'[data-plyr="language"]',quality:'[data-plyr="quality"]'},display:{currentTime:".plyr__time--current",duration:".plyr__time--duration",buffer:".plyr__progress__buffer",loop:".plyr__progress__loop",volume:".plyr__volume--display"},progress:".plyr__progress",captions:".plyr__captions",caption:".plyr__caption"},classNames:{type:"plyr--{0}",provider:"plyr--{0}",video:"plyr__video-wrapper",embed:"plyr__video-embed",videoFixedRatio:"plyr__video-wrapper--fixed-ratio",embedContainer:"plyr__video-embed__container",poster:"plyr__poster",posterEnabled:"plyr__poster-enabled",ads:"plyr__ads",control:"plyr__control",controlPressed:"plyr__control--pressed",playing:"plyr--playing",paused:"plyr--paused",stopped:"plyr--stopped",loading:"plyr--loading",hover:"plyr--hover",tooltip:"plyr__tooltip",cues:"plyr__cues",marker:"plyr__progress__marker",hidden:"plyr__sr-only",hideControls:"plyr--hide-controls",isTouch:"plyr--is-touch",uiSupported:"plyr--full-ui",noTransition:"plyr--no-transition",display:{time:"plyr__time"},menu:{value:"plyr__menu__value",badge:"plyr__badge",open:"plyr--menu-open"},captions:{enabled:"plyr--captions-enabled",active:"plyr--captions-active"},fullscreen:{enabled:"plyr--fullscreen-enabled",fallback:"plyr--fullscreen-fallback"},pip:{supported:"plyr--pip-supported",active:"plyr--pip-active"},airplay:{supported:"plyr--airplay-supported",active:"plyr--airplay-active"},previewThumbnails:{thumbContainer:"plyr__preview-thumb",thumbContainerShown:"plyr__preview-thumb--is-shown",imageContainer:"plyr__preview-thumb__image-container",timeContainer:"plyr__preview-thumb__time-container",scrubbingContainer:"plyr__preview-scrubbing",scrubbingContainerShown:"plyr__preview-scrubbing--is-shown"}},attributes:{embed:{provider:"data-plyr-provider",id:"data-plyr-embed-id",hash:"data-plyr-embed-hash"}},ads:{enabled:!1,publisherId:"",tagUrl:""},previewThumbnails:{enabled:!1,src:""},vimeo:{byline:!1,portrait:!1,title:!1,speed:!0,transparent:!1,customControls:!0,referrerPolicy:null,premium:!1},youtube:{rel:0,showinfo:0,iv_load_policy:3,modestbranding:1,customControls:!0,noCookie:!1},mediaMetadata:{title:"",artist:"",album:"",artwork:[]},markers:{enabled:!1,points:[]}},Ve="picture-in-picture",He={html5:"html5",youtube:"youtube",vimeo:"vimeo"},Ge="video",Ke=()=>{};class We{constructor(e=!1){this.enabled=window.console&&e,this.enabled&&this.log("Debugging enabled")}get log(){return this.enabled?Function.prototype.bind.call(console.log,console):Ke}get warn(){return this.enabled?Function.prototype.bind.call(console.warn,console):Ke}get error(){return this.enabled?Function.prototype.bind.call(console.error,console):Ke}}class qe{constructor(t){e(this,"onChange",()=>{if(!this.supported)return;const e=this.player.elements.buttons.fullscreen;_(e)&&(e.pressed=this.active);const t=this.target===this.player.media?this.target:this.player.elements.container;he.call(this.player,t,this.active?"enterfullscreen":"exitfullscreen",!0)}),e(this,"toggleFallback",(e=!1)=>{if(e?this.scrollPosition={x:window.scrollX??0,y:window.scrollY??0}:window.scrollTo(this.scrollPosition.x,this.scrollPosition.y),document.body.style.overflow=e?"hidden":"",Z(this.target,this.player.config.classNames.fullscreen.fallback,e),$.isIos){let t=document.head.querySelector('meta[name="viewport"]');const r="viewport-fit=cover";t||(t=document.createElement("meta"),t.setAttribute("name","viewport"));const i=x(t.content)&&t.content.includes(r);e?(this.cleanupViewport=!i,i||(t.content+=`,${r}`)):this.cleanupViewport&&(t.content=t.content.split(",").filter(e=>e.trim()!==r).join(","))}this.onChange()}),e(this,"trapFocus",e=>{if($.isIos||$.isIPadOS||!this.active||"Tab"!==e.key)return;const t=document.activeElement,r=re.call(this.player,"a[href], button:not(:disabled), input:not(:disabled), [tabindex]"),[i]=r,n=r[r.length-1];t!==n||e.shiftKey?t===i&&e.shiftKey&&(n.focus(),e.preventDefault()):(i.focus(),e.preventDefault())}),e(this,"update",()=>{if(this.supported){let e;e=this.forceFallback?"Fallback (forced)":qe.nativeSupported?"Native":"Fallback",this.player.debug.log(`${e} fullscreen enabled`)}else this.player.debug.log("Fullscreen not supported and fallback disabled");Z(this.player.elements.container,this.player.config.classNames.fullscreen.enabled,this.supported)}),e(this,"enter",()=>{this.supported&&($.isIos&&this.player.config.fullscreen.iosNative?this.player.isVimeo?this.player.embed.requestFullscreen():this.target.webkitEnterFullscreen():!qe.nativeSupported||this.forceFallback?this.toggleFallback(!0):this.prefix?B(this.prefix)||this.target[`${this.prefix}Request${this.property}`]():this.target.requestFullscreen({navigationUI:"hide"}))}),e(this,"exit",()=>{if(this.supported)if($.isIos&&this.player.config.fullscreen.iosNative)this.player.isVimeo?this.player.embed.exitFullscreen():this.target.webkitEnterFullscreen(),ge(this.player.play());else if(!qe.nativeSupported||this.forceFallback)this.toggleFallback(!1);else if(this.prefix){if(!B(this.prefix)){const e="moz"===this.prefix?"Cancel":"Exit";document[`${this.prefix}${e}${this.property}`]()}}else(document.cancelFullScreen||document.exitFullscreen).call(document)}),e(this,"toggle",()=>{this.active?this.exit():this.enter()}),this.player=t,this.prefix=qe.prefix,this.property=qe.property,this.scrollPosition={x:0,y:0},this.forceFallback="force"===t.config.fullscreen.fallback,this.player.elements.fullscreen=t.config.fullscreen.container&&function(e,t){const{prototype:r}=Element;return(r.closest||function(){let e=this;do{if(te.matches(e,t))return e;e=e.parentElement||e.parentNode}while(null!==e&&1===e.nodeType);return null}).call(e,t)}(this.player.elements.container,t.config.fullscreen.container),ce.call(this.player,document,"ms"===this.prefix?"MSFullscreenChange":`${this.prefix}fullscreenchange`,()=>{this.onChange()}),ce.call(this.player,this.player.elements.container,"dblclick",e=>{_(this.player.elements.controls)&&this.player.elements.controls.contains(e.target)||this.player.listeners.proxy(e,this.toggle,"fullscreen")}),ce.call(this,this.player.elements.container,"keydown",e=>this.trapFocus(e)),this.update()}static get nativeSupported(){return!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled)}get useNative(){return qe.nativeSupported&&!this.forceFallback}static get prefix(){if(P(document.exitFullscreen))return"";let e="";return["webkit","moz","ms"].some(t=>!(!P(document[`${t}ExitFullscreen`])&&!P(document[`${t}CancelFullScreen`])||(e=t,0))),e}static get property(){return"moz"===this.prefix?"FullScreen":"Fullscreen"}get supported(){return[this.player.config.fullscreen.enabled,this.player.isVideo,qe.nativeSupported||this.player.config.fullscreen.fallback,!this.player.isYouTube||qe.nativeSupported||!$.isIos||this.player.config.playsinline&&!this.player.config.fullscreen.iosNative].every(Boolean)}get active(){if(!this.supported)return!1;if(!qe.nativeSupported||this.forceFallback)return ee(this.target,this.player.config.classNames.fullscreen.fallback);const e=this.prefix?this.target.getRootNode()[`${this.prefix}${this.property}Element`]:this.target.getRootNode().fullscreenElement;return e&&e.shadowRoot?e===this.target.getRootNode().host:e===this.target}get target(){return $.isIos&&this.player.config.fullscreen.iosNative?this.player.media:this.player.elements.fullscreen??this.player.elements.container}}function ze(e,t=1){return new Promise((r,i)=>{const n=new Image,s=()=>{delete n.onload,delete n.onerror,(n.naturalWidth>=t?r:i)(n)};Object.assign(n,{onload:s,onerror:s,src:e})})}const Ye={addStyleHook(){Z(this.elements.container,this.config.selectors.container.replace(".",""),!0),Z(this.elements.container,this.config.classNames.uiSupported,this.supported.ui)},toggleNativeControls(e=!1){e&&this.isHTML5?this.media.setAttribute("controls",""):this.media.removeAttribute("controls")},build(){if(this.listeners.media(),!this.supported.ui)return this.debug.warn(`Basic support only for ${this.provider} ${this.type}`),void Ye.toggleNativeControls.call(this,!0);_(this.elements.controls)||(Fe.inject.call(this),this.listeners.controls()),Ye.toggleNativeControls.call(this),this.isHTML5&&je.setup.call(this),this.volume=null,this.muted=null,this.loop=null,this.quality=null,this.speed=null,Fe.updateVolume.call(this),Fe.timeUpdate.call(this),Fe.durationUpdate.call(this),Ye.checkPlaying.call(this),Z(this.elements.container,this.config.classNames.pip.supported,oe.pip&&this.isHTML5&&this.isVideo),Z(this.elements.container,this.config.classNames.airplay.supported,oe.airplay&&this.isHTML5),Z(this.elements.container,this.config.classNames.isTouch,this.touch),this.ready=!0,setTimeout(()=>{he.call(this,this.media,"ready")},0),Ye.setTitle.call(this),this.poster&&Ye.setPoster.call(this,this.poster,!1).catch(()=>{}),this.config.duration&&Fe.durationUpdate.call(this),this.config.mediaMetadata&&Fe.setMediaMetadata.call(this)},setTitle(){let e=Ce.get("play",this.config);if(x(this.config.title)&&!B(this.config.title)&&(e+=`, ${this.config.title}`),Array.from(this.elements.buttons.play||[]).forEach(t=>{t.setAttribute("aria-label",e)}),this.isEmbed){const e=ie.call(this,"iframe");if(!_(e))return;const t=B(this.config.title)?"video":this.config.title,r=Ce.get("frameTitle",this.config);e.setAttribute("title",r.replace("{title}",t))}},togglePoster(e){Z(this.elements.container,this.config.classNames.posterEnabled,e)},setPoster(e,t=!0){return t&&this.poster?Promise.reject(new Error("Poster already set")):(this.media.setAttribute("data-poster",e),this.elements.poster.removeAttribute("hidden"),pe.call(this).then(()=>ze(e)).catch(t=>{throw e===this.poster&&Ye.togglePoster.call(this,!1),t}).then(()=>{if(e!==this.poster)throw new Error("setPoster cancelled by later call to setPoster")}).then(()=>(Object.assign(this.elements.poster.style,{backgroundImage:`url('${e}')`,backgroundSize:""}),Ye.togglePoster.call(this,!0),e)))},checkPlaying(e){Z(this.elements.container,this.config.classNames.playing,this.playing),Z(this.elements.container,this.config.classNames.paused,this.paused),Z(this.elements.container,this.config.classNames.stopped,this.stopped),Array.from(this.elements.buttons.play||[]).forEach(e=>{Object.assign(e,{pressed:this.playing}),e.setAttribute("aria-label",Ce.get(this.playing?"pause":"play",this.config))}),O(e)&&"timeupdate"===e.type||Ye.toggleControls.call(this)},checkLoading(e){this.loading=["stalled","waiting"].includes(e.type),clearTimeout(this.timers.loading),this.timers.loading=setTimeout(()=>{Z(this.elements.container,this.config.classNames.loading,this.loading),Ye.toggleControls.call(this)},this.loading?250:0)},toggleControls(e){const{controls:t}=this.elements;if(t&&this.config.hideControls){const r=this.touch&&this.lastSeekTime+2e3>Date.now();this.toggleControls(Boolean(e||this.loading||this.paused||t.pressed||t.hover||r))}},migrateStyles(){Object.values({...this.media.style}).filter(e=>!B(e)&&x(e)&&e.startsWith("--plyr")).forEach(e=>{this.elements.container.style.setProperty(e,this.media.style.getPropertyValue(e)),this.media.style.removeProperty(e)}),B(this.media.style)&&this.media.removeAttribute("style")}};class Xe{constructor(t){e(this,"firstTouch",()=>{const{player:e}=this,{elements:t}=e;e.touch=!0,Z(t.container,e.config.classNames.isTouch,!0)}),e(this,"global",(e=!0)=>{const{player:t}=this;t.config.keyboard.global&&le.call(t,window,"keydown keyup",this.handleKey,e,!1),le.call(t,document.body,"click",this.toggleMenu,e),de.call(t,document.body,"touchstart",this.firstTouch)}),e(this,"container",()=>{const{player:e}=this,{config:t,elements:r,timers:i}=e;!t.keyboard.global&&t.keyboard.focused&&ce.call(e,r.container,"keydown keyup",this.handleKey,!1),ce.call(e,r.container,"mousemove mouseleave touchstart touchmove enterfullscreen exitfullscreen",t=>{const{controls:n}=r;n&&"enterfullscreen"===t.type&&(n.pressed=!1,n.hover=!1);let s=0;["touchstart","touchmove","mousemove"].includes(t.type)&&(Ye.toggleControls.call(e,!0),s=e.touch?3e3:2e3),clearTimeout(i.controls),i.controls=setTimeout(()=>Ye.toggleControls.call(e,!1),s)});const n=()=>{if(!e.isVimeo||e.config.vimeo.premium)return;const t=r.wrapper,{active:i}=e.fullscreen,[n,s]=Te.call(e),o=ve(`aspect-ratio: ${n} / ${s}`);if(!i)return void(o?(t.style.width=null,t.style.height=null):(t.style.maxWidth=null,t.style.margin=null));const[a,l]=[Math.max(document.documentElement.clientWidth||0,window.innerWidth||0),Math.max(document.documentElement.clientHeight||0,window.innerHeight||0)],c=a/l>n/s;o?(t.style.width=c?"auto":"100%",t.style.height=c?"100%":"auto"):(t.style.maxWidth=c?l/s*n+"px":null,t.style.margin=c?"0 auto":null)},s=()=>{clearTimeout(i.resized),i.resized=setTimeout(n,50)};ce.call(e,r.container,"enterfullscreen exitfullscreen",t=>{const{target:i}=e.fullscreen;i===r.container&&(!e.isEmbed&&B(e.config.ratio)||(n(),("enterfullscreen"===t.type?ce:ue).call(e,window,"resize",s)))})}),e(this,"media",()=>{const{player:e}=this,{elements:t}=e;if(ce.call(e,e.media,"timeupdate seeking seeked",t=>Fe.timeUpdate.call(e,t)),ce.call(e,e.media,"durationchange loadeddata loadedmetadata",t=>Fe.durationUpdate.call(e,t)),ce.call(e,e.media,"ended",()=>{e.isHTML5&&e.isVideo&&e.config.resetOnEnd&&(e.restart(),e.pause())}),ce.call(e,e.media,"progress playing seeking seeked",t=>Fe.updateProgress.call(e,t)),ce.call(e,e.media,"volumechange",t=>Fe.updateVolume.call(e,t)),ce.call(e,e.media,"playing play pause ended emptied timeupdate",t=>Ye.checkPlaying.call(e,t)),ce.call(e,e.media,"waiting canplay seeked playing",t=>Ye.checkLoading.call(e,t)),e.supported.ui&&e.config.clickToPlay&&!e.isAudio){const r=ie.call(e,`.${e.config.classNames.video}`);if(!_(r))return;ce.call(e,t.container,"click",i=>{([t.container,r].includes(i.target)||r.contains(i.target))&&(e.touch&&e.config.hideControls||(e.ended?(this.proxy(i,e.restart,"restart"),this.proxy(i,()=>{ge(e.play())},"play")):this.proxy(i,()=>{ge(e.togglePlay())},"play")))})}e.supported.ui&&e.config.disableContextMenu&&ce.call(e,t.wrapper,"contextmenu",e=>{e.preventDefault()},!1),ce.call(e,e.media,"volumechange",()=>{e.storage.set({volume:e.volume,muted:e.muted})}),ce.call(e,e.media,"ratechange",()=>{Fe.updateSetting.call(e,"speed"),e.storage.set({speed:e.speed})}),ce.call(e,e.media,"qualitychange",t=>{Fe.updateSetting.call(e,"quality",null,t.detail.quality)}),ce.call(e,e.media,"ready qualitychange",()=>{Fe.setDownloadUrl.call(e)});const r=e.config.events.concat(["keyup","keydown"]).join(" ");ce.call(e,e.media,r,r=>{let{detail:i={}}=r;"error"===r.type&&(i=e.media.error),he.call(e,t.container,r.type,!0,i)})}),e(this,"proxy",(e,t,r)=>{const{player:i}=this,n=i.config.listeners[r];let s=!0;P(n)&&(s=n.call(i,e)),!1!==s&&P(t)&&t.call(i,e)}),e(this,"bind",(e,t,r,i,n=!0)=>{const{player:s}=this,o=s.config.listeners[i],a=P(o);ce.call(s,e,t,e=>this.proxy(e,r,i),n&&!a)}),e(this,"controls",()=>{const{player:e}=this,{elements:t}=e,r=$.isIE?"change":"input";if(t.buttons.play&&Array.from(t.buttons.play).forEach(t=>{this.bind(t,"click",()=>{ge(e.togglePlay())},"play")}),this.bind(t.buttons.restart,"click",e.restart,"restart"),this.bind(t.buttons.rewind,"click",()=>{e.lastSeekTime=Date.now(),e.rewind()},"rewind"),this.bind(t.buttons.fastForward,"click",()=>{e.lastSeekTime=Date.now(),e.forward()},"fastForward"),this.bind(t.buttons.mute,"click",()=>{e.muted=!e.muted},"mute"),this.bind(t.buttons.captions,"click",()=>e.toggleCaptions()),this.bind(t.buttons.download,"click",()=>{he.call(e,e.media,"download")},"download"),this.bind(t.buttons.fullscreen,"click",()=>{e.fullscreen.toggle()},"fullscreen"),this.bind(t.buttons.pip,"click",()=>{e.pip="toggle"},"pip"),this.bind(t.buttons.airplay,"click",e.airplay,"airplay"),this.bind(t.buttons.settings,"click",t=>{t.stopPropagation(),t.preventDefault(),Fe.toggleMenu.call(e,t)},null,!1),this.bind(t.buttons.settings,"keyup",t=>{[" ","Enter"].includes(t.key)&&("Enter"!==t.key?(t.preventDefault(),t.stopPropagation(),Fe.toggleMenu.call(e,t)):Fe.focusFirstMenuItem.call(e,null,!0))},null,!1),this.bind(t.settings.menu,"keydown",t=>{"Escape"===t.key&&Fe.toggleMenu.call(e,t)}),this.bind(t.inputs.seek,"mousedown mousemove",e=>{const r=t.progress.getBoundingClientRect(),i=100/r.width*(e.pageX-r.left);e.currentTarget.setAttribute("seek-value",i)}),this.bind(t.inputs.seek,"mousedown mouseup keydown keyup touchstart touchend",t=>{const r=t.currentTarget,i="play-on-seeked";if(D(t)&&!["ArrowLeft","ArrowRight"].includes(t.key))return;e.lastSeekTime=Date.now();const n=r.hasAttribute(i),s=["mouseup","touchend","keyup"].includes(t.type);n&&s?(r.removeAttribute(i),ge(e.play())):!s&&e.playing&&(r.setAttribute(i,""),e.pause())}),$.isIos){const t=re.call(e,'input[type="range"]');Array.from(t).forEach(e=>this.bind(e,r,e=>j(e.target)))}this.bind(t.inputs.seek,r,t=>{const r=t.currentTarget;let i=r.getAttribute("seek-value");B(i)&&(i=r.value),r.removeAttribute("seek-value"),e.currentTime=i/r.max*e.duration},"seek"),this.bind(t.progress,"mouseenter mouseleave mousemove",t=>Fe.updateSeekTooltip.call(e,t)),this.bind(t.progress,"mousemove touchmove",t=>{const{previewThumbnails:r}=e;r&&r.loaded&&r.startMove(t)}),this.bind(t.progress,"mouseleave touchend click",()=>{const{previewThumbnails:t}=e;t&&t.loaded&&t.endMove(!1,!0)}),this.bind(t.progress,"mousedown touchstart",t=>{const{previewThumbnails:r}=e;r&&r.loaded&&r.startScrubbing(t)}),this.bind(t.progress,"mouseup touchend",t=>{const{previewThumbnails:r}=e;r&&r.loaded&&r.endScrubbing(t)}),$.isWebKit&&Array.from(re.call(e,'input[type="range"]')).forEach(t=>{this.bind(t,"input",t=>Fe.updateRangeFill.call(e,t.target))}),e.config.toggleInvert&&!_(t.display.duration)&&this.bind(t.display.currentTime,"click",()=>{0!==e.currentTime&&(e.config.invertTime=!e.config.invertTime,Fe.timeUpdate.call(e))}),this.bind(t.inputs.volume,r,t=>{e.volume=t.target.value},"volume"),this.bind(t.controls,"mouseenter mouseleave",r=>{t.controls.hover=!e.touch&&"mouseenter"===r.type}),t.fullscreen&&Array.from(t.fullscreen.children).filter(e=>!e.contains(t.container)).forEach(r=>{this.bind(r,"mouseenter mouseleave",r=>{t.controls&&(t.controls.hover=!e.touch&&"mouseenter"===r.type)})}),this.bind(t.controls,"mousedown mouseup touchstart touchend touchcancel",e=>{t.controls.pressed=["mousedown","touchstart"].includes(e.type)}),this.bind(t.controls,"focusin",()=>{const{config:r,timers:i}=e;Z(t.controls,r.classNames.noTransition,!0),Ye.toggleControls.call(e,!0),setTimeout(()=>{Z(t.controls,r.classNames.noTransition,!1)},0);const n=this.touch?3e3:4e3;clearTimeout(i.controls),i.controls=setTimeout(()=>Ye.toggleControls.call(e,!1),n)}),this.bind(t.inputs.volume,"wheel",t=>{const r=t.webkitDirectionInvertedFromDevice,[i,n]=[t.deltaX,-t.deltaY].map(e=>r?-e:e),s=Math.sign(Math.abs(i)>Math.abs(n)?i:n);e.increaseVolume(s/50);const{volume:o}=e.media;(1===s&&o<1||-1===s&&o>0)&&t.preventDefault()},"volume",!1)}),this.player=t,this.lastKey=null,this.focusTimer=null,this.lastKeyDown=null,this.handleKey=this.handleKey.bind(this),this.toggleMenu=this.toggleMenu.bind(this),this.firstTouch=this.firstTouch.bind(this)}handleKey(e){const{player:t}=this,{elements:r}=t,{key:i,type:n,altKey:s,ctrlKey:o,metaKey:a,shiftKey:l}=e,c="keydown"===n,u=c&&i===this.lastKey;var d;if(!(s||o||a||l)&&i)if(c){const n=document.activeElement;if(_(n)){const{editable:i}=t.config.selectors,{seek:s}=r.inputs;if(n!==s&&te(n,i))return;if(" "===e.key&&te(n,'button, [role^="menuitem"]'))return}switch([" ","ArrowLeft","ArrowUp","ArrowRight","ArrowDown","0","1","2","3","4","5","6","7","8","9","c","f","k","l","m"].includes(i)&&(e.preventDefault(),e.stopPropagation()),i){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":u||(d=parseInt(i,10),t.currentTime=t.duration/10*d);break;case" ":case"k":u||ge(t.togglePlay());break;case"ArrowUp":t.increaseVolume(.1);break;case"ArrowDown":t.decreaseVolume(.1);break;case"m":u||(t.muted=!t.muted);break;case"ArrowRight":t.forward();break;case"ArrowLeft":t.rewind();break;case"f":t.fullscreen.toggle();break;case"c":u||t.toggleCaptions();break;case"l":t.loop=!t.loop}"Escape"===i&&!t.fullscreen.usingNative&&t.fullscreen.active&&t.fullscreen.toggle(),this.lastKey=i}else this.lastKey=null}toggleMenu(e){Fe.toggleMenu.call(this.player,e)}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self&&self;var Qe=function(e,t){return function(e){e.exports=function(){var e=function(){},t={},r={},i={};function n(e,t){e=e.push?e:[e];var n,s,o,a=[],l=e.length,c=l;for(n=function(e,r){r.length&&a.push(e),--c||t(a)};l--;)s=e[l],(o=r[s])?n(s,o):(i[s]=i[s]||[]).push(n)}function s(e,t){if(e){var n=i[e];if(r[e]=t,n)for(;n.length;)n[0](e,t),n.splice(0,1)}}function o(t,r){t.call&&(t={success:t}),r.length?(t.error||e)(r):(t.success||e)(t)}function a(t,r,i,n){var s,o,l=document,c=i.async,u=(i.numRetries||0)+1,d=i.before||e,h=t.replace(/[\?|#].*$/,""),f=t.replace(/^(css|img)!/,"");n=n||0,/(^css!|\.css$)/.test(h)?((o=l.createElement("link")).rel="stylesheet",o.href=f,(s="hideFocus"in o)&&o.relList&&(s=0,o.rel="preload",o.as="style")):/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(h)?(o=l.createElement("img")).src=f:((o=l.createElement("script")).src=t,o.async=void 0===c||c),o.onload=o.onerror=o.onbeforeload=function(e){var l=e.type[0];if(s)try{o.sheet.cssText.length||(l="e")}catch(e){18!=e.code&&(l="e")}if("e"==l){if((n+=1){Qe(e,{success:t,error:r})})}function Ze(e){e&&!this.embed.hasPlayed&&(this.embed.hasPlayed=!0),this.media.paused===e&&(this.media.paused=!e,he.call(this,this.media,e?"play":"pause"))}const et={setup(){const e=this;Z(e.elements.wrapper,e.config.classNames.embed,!0),e.options.speed=e.config.speed.options,we.call(e),k(window.Vimeo)?et.ready.call(e):Je(e.config.urls.vimeo.sdk).then(()=>{et.ready.call(e)}).catch(t=>{e.debug.warn("Vimeo SDK (player.js) failed to load",t)})},ready(){const e=this,t=e.config.vimeo,{premium:r,referrerPolicy:i,...n}=t;let s=e.media.getAttribute("src"),o="";B(s)?(s=e.media.getAttribute(e.config.attributes.embed.id),o=e.media.getAttribute(e.config.attributes.embed.hash)):o=function(e){const t=e.match(/^.*(vimeo.com\/|video\/)(\d+)(\?.*&*h=|\/)+([\d,a-f]+)/);return t&&5===t.length?t[4]:null}(s);const a=o?{h:o}:{};r&&Object.assign(n,{controls:!1,sidedock:!1});const l=Ue({loop:e.config.loop.active,autoplay:e.autoplay,muted:e.muted,gesture:"media",playsinline:e.config.playsinline,...a,...n}),c=B(u=s)?null:L(Number(u))?u:u.match(/^.*(vimeo.com\/|video\/)(\d+).*/)?RegExp.$2:u;var u;const d=W("iframe"),h=Le(e.config.urls.vimeo.iframe,c,l);if(d.setAttribute("src",h),d.setAttribute("allowfullscreen",""),d.setAttribute("allow",["autoplay","fullscreen","picture-in-picture","encrypted-media","accelerometer","gyroscope"].join("; ")),B(i)||d.setAttribute("referrerPolicy",i),r||!t.customControls)d.setAttribute("data-poster",e.poster),e.media=X(d,e.media);else{const t=W("div",{class:e.config.classNames.embedContainer,"data-poster":e.poster});t.appendChild(d),e.media=X(t,e.media)}t.customControls||Oe(Le(e.config.urls.vimeo.api,h)).then(t=>{!B(t)&&t.thumbnail_url&&Ye.setPoster.call(e,t.thumbnail_url).catch(()=>{})}),e.embed=new window.Vimeo.Player(d,{autopause:e.config.autopause,muted:e.muted}),e.media.paused=!0,e.media.currentTime=0,e.supported.ui&&e.embed.disableTextTrack(),e.media.play=()=>(Ze.call(e,!0),e.embed.play()),e.media.pause=()=>(Ze.call(e,!1),e.embed.pause()),e.media.stop=()=>{e.pause(),e.currentTime=0};let{currentTime:f}=e.media;Object.defineProperty(e.media,"currentTime",{get:()=>f,set(t){const{embed:r,media:i,paused:n,volume:s}=e,o=n&&!r.hasPlayed;i.seeking=!0,he.call(e,i,"seeking"),Promise.resolve(o&&r.setVolume(0)).then(()=>r.setCurrentTime(t)).then(()=>o&&r.pause()).then(()=>o&&r.setVolume(s)).catch(()=>{})}});let p=e.config.speed.selected;Object.defineProperty(e.media,"playbackRate",{get:()=>p,set(t){e.embed.setPlaybackRate(t).then(()=>{p=t,he.call(e,e.media,"ratechange")}).catch(()=>{e.options.speed=[1]})}});let{volume:g}=e.config;Object.defineProperty(e.media,"volume",{get:()=>g,set(t){e.embed.setVolume(t).then(()=>{g=t,he.call(e,e.media,"volumechange")})}});let{muted:m}=e.config;Object.defineProperty(e.media,"muted",{get:()=>m,set(t){const r=!!R(t)&&t;e.embed.setMuted(!!r||e.config.muted).then(()=>{m=r,he.call(e,e.media,"volumechange")})}});let y,{loop:v}=e.config;Object.defineProperty(e.media,"loop",{get:()=>v,set(t){const r=R(t)?t:e.config.loop.active;e.embed.setLoop(r).then(()=>{v=r})}}),e.embed.getVideoUrl().then(t=>{y=t,Fe.setDownloadUrl.call(e)}).catch(e=>{this.debug.warn(e)}),Object.defineProperty(e.media,"currentSrc",{get:()=>y}),Object.defineProperty(e.media,"ended",{get:()=>e.currentTime===e.duration}),Promise.all([e.embed.getVideoWidth(),e.embed.getVideoHeight()]).then(t=>{const[r,i]=t;e.embed.ratio=Se(r,i),we.call(this)}),e.embed.setAutopause(e.config.autopause).then(t=>{e.config.autopause=t}),e.embed.getVideoTitle().then(t=>{e.config.title=t,Ye.setTitle.call(this)}),e.embed.getCurrentTime().then(t=>{f=t,he.call(e,e.media,"timeupdate")}),e.embed.getDuration().then(t=>{e.media.duration=t,he.call(e,e.media,"durationchange")}),e.embed.getTextTracks().then(t=>{e.media.textTracks=t,je.setup.call(e)}),e.embed.on("cuechange",({cues:t=[]})=>{const r=t.map(e=>function(e){const t=document.createDocumentFragment(),r=document.createElement("div");return t.appendChild(r),r.innerHTML=e,t.firstChild.innerText}(e.text));je.updateCues.call(e,r)}),e.embed.on("loaded",()=>{e.embed.getPaused().then(t=>{Ze.call(e,!t),t||he.call(e,e.media,"playing")}),_(e.embed.element)&&e.supported.ui&&e.embed.element.setAttribute("tabindex",-1)}),e.embed.on("bufferstart",()=>{he.call(e,e.media,"waiting")}),e.embed.on("bufferend",()=>{he.call(e,e.media,"playing")}),e.embed.on("play",()=>{Ze.call(e,!0),he.call(e,e.media,"playing")}),e.embed.on("pause",()=>{Ze.call(e,!1)}),e.embed.on("timeupdate",t=>{e.media.seeking=!1,f=t.seconds,he.call(e,e.media,"timeupdate")}),e.embed.on("progress",t=>{e.media.buffered=t.percent,he.call(e,e.media,"progress"),1===parseInt(t.percent,10)&&he.call(e,e.media,"canplaythrough"),e.embed.getDuration().then(t=>{t!==e.media.duration&&(e.media.duration=t,he.call(e,e.media,"durationchange"))})}),e.embed.on("seeked",()=>{e.media.seeking=!1,he.call(e,e.media,"seeked")}),e.embed.on("ended",()=>{e.media.paused=!0,he.call(e,e.media,"ended")}),e.embed.on("error",t=>{e.media.error=t,he.call(e,e.media,"error")}),t.customControls&&setTimeout(()=>Ye.build.call(e),0)}};function tt(e){e&&!this.embed.hasPlayed&&(this.embed.hasPlayed=!0),this.media.paused===e&&(this.media.paused=!e,he.call(this,this.media,e?"play":"pause"))}function rt(e){return e.noCookie?"https://www.youtube-nocookie.com":"http:"===window.location.protocol?"http://www.youtube.com":void 0}const it={setup(){if(Z(this.elements.wrapper,this.config.classNames.embed,!0),k(window.YT)&&P(window.YT.Player))it.ready.call(this);else{const e=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{P(e)&&e(),it.ready.call(this)},Je(this.config.urls.youtube.sdk).catch(e=>{this.debug.warn("YouTube API failed to load",e)})}},getTitle(e){Oe(Le(this.config.urls.youtube.api,e)).then(e=>{if(k(e)){const{title:t,height:r,width:i}=e;this.config.title=t,Ye.setTitle.call(this),this.embed.ratio=Se(i,r)}we.call(this)}).catch(()=>{we.call(this)})},ready(){const e=this,t=e.config.youtube,r=e.media&&e.media.getAttribute("id");if(!B(r)&&r.startsWith("youtube-"))return;let i=e.media.getAttribute("src");B(i)&&(i=e.media.getAttribute(this.config.attributes.embed.id));const n=B(s=i)?null:s.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/)?RegExp.$2:s;var s;const o=W("div",{id:`${e.provider}-${Math.floor(1e4*Math.random())}`,"data-poster":t.customControls?e.poster:void 0});if(e.media=X(o,e.media),t.customControls){const t=e=>`https://i.ytimg.com/vi/${n}/${e}default.jpg`;ze(t("maxres"),121).catch(()=>ze(t("sd"),121)).catch(()=>ze(t("hq"))).then(t=>Ye.setPoster.call(e,t.src)).then(t=>{t.includes("maxres")||(e.elements.poster.style.backgroundSize="cover")}).catch(()=>{})}e.embed=new window.YT.Player(e.media,{videoId:n,host:rt(t),playerVars:H({},{autoplay:e.config.autoplay?1:0,hl:e.config.hl,controls:e.supported.ui&&t.customControls?0:1,disablekb:1,playsinline:e.config.playsinline&&!e.config.fullscreen.iosNative?1:0,cc_load_policy:e.captions.active?1:0,cc_lang_pref:e.config.captions.language,widget_referrer:window?window.location.href:null},t),events:{onError(t){if(!e.media.error){const r=t.data,i={2:"The request contains an invalid parameter value. For example, this error occurs if you specify a video ID that does not have 11 characters, or if the video ID contains invalid characters, such as exclamation points or asterisks.",5:"The requested content cannot be played in an HTML5 player or another error related to the HTML5 player has occurred.",100:"The video requested was not found. This error occurs when a video has been removed (for any reason) or has been marked as private.",101:"The owner of the requested video does not allow it to be played in embedded players.",150:"The owner of the requested video does not allow it to be played in embedded players."}[r]||"An unknown error occurred";e.media.error={code:r,message:i},he.call(e,e.media,"error")}},onPlaybackRateChange(t){const r=t.target;e.media.playbackRate=r.getPlaybackRate(),he.call(e,e.media,"ratechange")},onReady(r){if(P(e.media.play))return;const i=r.target;it.getTitle.call(e,n),e.media.play=()=>{tt.call(e,!0),i.playVideo()},e.media.pause=()=>{tt.call(e,!1),i.pauseVideo()},e.media.stop=()=>{i.stopVideo()},e.media.duration=i.getDuration(),e.media.paused=!0,e.media.currentTime=0,Object.defineProperty(e.media,"currentTime",{get:()=>Number(i.getCurrentTime()),set(t){e.paused&&!e.embed.hasPlayed&&e.embed.mute(),e.media.seeking=!0,he.call(e,e.media,"seeking"),i.seekTo(t)}}),Object.defineProperty(e.media,"playbackRate",{get:()=>i.getPlaybackRate(),set(e){i.setPlaybackRate(e)}});let{volume:s}=e.config;Object.defineProperty(e.media,"volume",{get:()=>s,set(t){s=t,i.setVolume(100*s),he.call(e,e.media,"volumechange")}});let{muted:o}=e.config;Object.defineProperty(e.media,"muted",{get:()=>o,set(t){const r=R(t)?t:o;o=r,i[r?"mute":"unMute"](),i.setVolume(100*s),he.call(e,e.media,"volumechange")}}),Object.defineProperty(e.media,"currentSrc",{get:()=>i.getVideoUrl()}),Object.defineProperty(e.media,"ended",{get:()=>e.currentTime===e.duration});const a=i.getAvailablePlaybackRates();e.options.speed=a.filter(t=>e.config.speed.options.includes(t)),e.supported.ui&&t.customControls&&e.media.setAttribute("tabindex",-1),he.call(e,e.media,"timeupdate"),he.call(e,e.media,"durationchange"),clearInterval(e.timers.buffering),e.timers.buffering=setInterval(()=>{e.media.buffered=i.getVideoLoadedFraction(),(null===e.media.lastBuffered||e.media.lastBufferedYe.build.call(e),50)},onStateChange(r){const i=r.target;switch(clearInterval(e.timers.playing),e.media.seeking&&[1,2].includes(r.data)&&(e.media.seeking=!1,he.call(e,e.media,"seeked")),r.data){case-1:he.call(e,e.media,"timeupdate"),e.media.buffered=i.getVideoLoadedFraction(),he.call(e,e.media,"progress");break;case 0:tt.call(e,!1),e.media.loop?(i.stopVideo(),i.playVideo()):he.call(e,e.media,"ended");break;case 1:t.customControls&&!e.config.autoplay&&e.media.paused&&!e.embed.hasPlayed?e.media.pause():(tt.call(e,!0),he.call(e,e.media,"playing"),e.timers.playing=setInterval(()=>{he.call(e,e.media,"timeupdate")},50),e.media.duration!==i.getDuration()&&(e.media.duration=i.getDuration(),he.call(e,e.media,"durationchange")));break;case 2:e.muted||e.embed.unMute(),tt.call(e,!1);break;case 3:he.call(e,e.media,"waiting")}he.call(e,e.elements.container,"statechange",!1,{code:r.data})}}})}},nt={setup(){this.media?(Z(this.elements.container,this.config.classNames.type.replace("{0}",this.type),!0),Z(this.elements.container,this.config.classNames.provider.replace("{0}",this.provider),!0),this.isEmbed&&Z(this.elements.container,this.config.classNames.type.replace("{0}","video"),!0),this.isVideo&&(this.elements.wrapper=W("div",{class:this.config.classNames.video}),G(this.media,this.elements.wrapper),this.elements.poster=W("div",{class:this.config.classNames.poster}),this.elements.wrapper.appendChild(this.elements.poster)),this.isHTML5?ke.setup.call(this):this.isYouTube?it.setup.call(this):this.isVimeo&&et.setup.call(this)):this.debug.warn("No media element found!")}};class st{constructor(t){e(this,"load",()=>{this.enabled&&(k(window.google)&&k(window.google.ima)?this.ready():Je(this.player.config.urls.googleIMA.sdk).then(()=>{this.ready()}).catch(()=>{this.trigger("error",new Error("Google IMA SDK failed to load"))}))}),e(this,"ready",()=>{var e;this.enabled||((e=this).manager&&e.manager.destroy(),e.elements.displayContainer&&e.elements.displayContainer.destroy(),e.elements.container.remove()),this.startSafetyTimer(12e3,"ready()"),this.managerPromise.then(()=>{this.clearSafetyTimer("onAdsManagerLoaded()")}),this.listeners(),this.setupIMA()}),e(this,"setupIMA",()=>{this.elements.container=W("div",{class:this.player.config.classNames.ads}),this.player.elements.container.appendChild(this.elements.container),google.ima.settings.setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED),google.ima.settings.setLocale(this.player.config.ads.language),google.ima.settings.setDisableCustomPlaybackForIOS10Plus(this.player.config.playsinline),this.elements.displayContainer=new google.ima.AdDisplayContainer(this.elements.container,this.player.media),this.loader=new google.ima.AdsLoader(this.elements.displayContainer),this.loader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e=>this.onAdsManagerLoaded(e),!1),this.loader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,e=>this.onAdError(e),!1),this.requestAds()}),e(this,"requestAds",()=>{const{container:e}=this.player.elements;try{const t=new google.ima.AdsRequest;t.adTagUrl=this.tagUrl,t.linearAdSlotWidth=e.offsetWidth,t.linearAdSlotHeight=e.offsetHeight,t.nonLinearAdSlotWidth=e.offsetWidth,t.nonLinearAdSlotHeight=e.offsetHeight,t.forceNonLinearFullSlot=!1,t.setAdWillPlayMuted(!this.player.muted),this.loader.requestAds(t)}catch(e){this.onAdError(e)}}),e(this,"pollCountdown",(e=!1)=>{if(!e)return clearInterval(this.countdownTimer),void this.elements.container.removeAttribute("data-badge-text");this.countdownTimer=setInterval(()=>{const e=Ne(Math.max(this.manager.getRemainingTime(),0)),t=`${Ce.get("advertisement",this.player.config)} - ${e}`;this.elements.container.setAttribute("data-badge-text",t)},100)}),e(this,"onAdsManagerLoaded",e=>{if(!this.enabled)return;const t=new google.ima.AdsRenderingSettings;t.restoreCustomPlaybackStateOnAdBreakComplete=!0,t.enablePreloading=!0,this.manager=e.getAdsManager(this.player,t),this.cuePoints=this.manager.getCuePoints(),this.manager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,e=>this.onAdError(e)),Object.keys(google.ima.AdEvent.Type).forEach(e=>{this.manager.addEventListener(google.ima.AdEvent.Type[e],e=>this.onAdEvent(e))}),this.trigger("loaded")}),e(this,"addCuePoints",()=>{B(this.cuePoints)||this.cuePoints.forEach(e=>{if(0!==e&&-1!==e&&e{const{container:t}=this.player.elements,r=e.getAd(),i=e.getAdData();switch((e=>{he.call(this.player,this.player.media,`ads${e.replace(/_/g,"").toLowerCase()}`)})(e.type),e.type){case google.ima.AdEvent.Type.LOADED:this.trigger("loaded"),this.pollCountdown(!0),r.isLinear()||(r.width=t.offsetWidth,r.height=t.offsetHeight);break;case google.ima.AdEvent.Type.STARTED:this.manager.setVolume(this.player.volume);break;case google.ima.AdEvent.Type.ALL_ADS_COMPLETED:this.player.ended?this.loadAds():this.loader.contentComplete();break;case google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED:this.pauseContent();break;case google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED:this.pollCountdown(),this.resumeContent();break;case google.ima.AdEvent.Type.LOG:i.adError&&this.player.debug.warn(`Non-fatal ad error: ${i.adError.getMessage()}`)}}),e(this,"onAdError",e=>{this.cancel(),this.player.debug.warn("Ads error",e)}),e(this,"listeners",()=>{const{container:e}=this.player.elements;let t;this.player.on("canplay",()=>{this.addCuePoints()}),this.player.on("ended",()=>{this.loader.contentComplete()}),this.player.on("timeupdate",()=>{t=this.player.currentTime}),this.player.on("seeked",()=>{const e=this.player.currentTime;B(this.cuePoints)||this.cuePoints.forEach((r,i)=>{t{this.manager&&this.manager.resize(e.offsetWidth,e.offsetHeight,google.ima.ViewMode.NORMAL)})}),e(this,"play",()=>{const{container:e}=this.player.elements;this.managerPromise||this.resumeContent(),this.managerPromise.then(()=>{this.manager.setVolume(this.player.volume),this.elements.displayContainer.initialize();try{this.initialized||(this.manager.init(e.offsetWidth,e.offsetHeight,google.ima.ViewMode.NORMAL),this.manager.start()),this.initialized=!0}catch(e){this.onAdError(e)}}).catch(()=>{})}),e(this,"resumeContent",()=>{this.elements.container.style.zIndex="",this.playing=!1,ge(this.player.media.play())}),e(this,"pauseContent",()=>{this.elements.container.style.zIndex=3,this.playing=!0,this.player.media.pause()}),e(this,"cancel",()=>{this.initialized&&this.resumeContent(),this.trigger("error"),this.loadAds()}),e(this,"loadAds",()=>{this.managerPromise.then(()=>{this.manager&&this.manager.destroy(),this.managerPromise=new Promise(e=>{this.on("loaded",e),this.player.debug.log(this.manager)}),this.initialized=!1,this.requestAds()}).catch(()=>{})}),e(this,"trigger",(e,...t)=>{const r=this.events[e];I(r)&&r.forEach(e=>{P(e)&&e.apply(this,t)})}),e(this,"on",(e,t)=>(I(this.events[e])||(this.events[e]=[]),this.events[e].push(t),this)),e(this,"startSafetyTimer",(e,t)=>{this.player.debug.log(`Safety timer invoked from: ${t}`),this.safetyTimer=setTimeout(()=>{this.cancel(),this.clearSafetyTimer("startSafetyTimer()")},e)}),e(this,"clearSafetyTimer",e=>{S(this.safetyTimer)||(this.player.debug.log(`Safety timer cleared from: ${e}`),clearTimeout(this.safetyTimer),this.safetyTimer=null)}),this.player=t,this.config=t.config.ads,this.playing=!1,this.initialized=!1,this.elements={container:null,displayContainer:null},this.manager=null,this.loader=null,this.cuePoints=null,this.events={},this.safetyTimer=null,this.countdownTimer=null,this.managerPromise=new Promise((e,t)=>{this.on("loaded",e),this.on("error",t)}),this.load()}get enabled(){const{config:e}=this;return this.player.isHTML5&&this.player.isVideo&&e.enabled&&(!B(e.publisherId)||F(e.tagUrl))}get tagUrl(){const{config:e}=this;return F(e.tagUrl)?e.tagUrl:`https://go.aniview.com/api/adserver6/vast/?${Ue({AV_PUBLISHERID:"58c25bb0073ef448b1087ad6",AV_CHANNELID:"5a0458dc28a06145e4519d21",AV_URL:window.location.hostname,cb:Date.now(),AV_WIDTH:640,AV_HEIGHT:480,AV_CDIM2:e.publisherId})}`}}function ot(e=0,t=0,r=255){return Math.min(Math.max(e,t),r)}const at=e=>{const t=[];return e.split(/\r\n\r\n|\n\n|\r\r/).forEach(e=>{const r={};e.split(/\r\n|\n|\r/).forEach(e=>{if(L(r.startTime)){if(!B(e.trim())&&B(r.text)){const t=e.trim().split("#xywh=");[r.text]=t,t[1]&&([r.x,r.y,r.w,r.h]=t[1].split(","))}}else{const t=e.match(/([0-9]{2})?:?([0-9]{2}):([0-9]{2}).([0-9]{2,3})( ?--> ?)([0-9]{2})?:?([0-9]{2}):([0-9]{2}).([0-9]{2,3})/);t&&(r.startTime=60*Number(t[1]||0)*60+60*Number(t[2])+Number(t[3])+Number(`0.${t[4]}`),r.endTime=60*Number(t[6]||0)*60+60*Number(t[7])+Number(t[8])+Number(`0.${t[9]}`))}}),r.text&&t.push(r)}),t},lt=(e,t)=>{const r={};return e>t.width/t.height?(r.width=t.width,r.height=1/e*t.width):(r.height=t.height,r.width=e*t.height),r};class ct{constructor(t){e(this,"load",()=>{this.player.elements.display.seekTooltip&&(this.player.elements.display.seekTooltip.hidden=this.enabled),this.enabled&&this.getThumbnails().then(()=>{this.enabled&&(this.render(),this.determineContainerAutoSizing(),this.listeners(),this.loaded=!0)})}),e(this,"getThumbnails",()=>new Promise(e=>{const{src:t}=this.player.config.previewThumbnails;if(B(t))throw new Error("Missing previewThumbnails.src config attribute");const r=()=>{this.thumbnails.sort((e,t)=>e.height-t.height),this.player.debug.log("Preview thumbnails",this.thumbnails),e()};if(P(t))t(e=>{this.thumbnails=e,r()});else{const e=(x(t)?[t]:t).map(e=>this.getThumbnail(e));Promise.all(e).then(r)}})),e(this,"getThumbnail",e=>new Promise(t=>{Oe(e).then(r=>{const i={frames:at(r),height:null,urlPrefix:""};i.frames[0].text.startsWith("/")||i.frames[0].text.startsWith("http://")||i.frames[0].text.startsWith("https://")||(i.urlPrefix=e.substring(0,e.lastIndexOf("/")+1));const n=new Image;n.onload=()=>{i.height=n.naturalHeight,i.width=n.naturalWidth,this.thumbnails.push(i),t()},n.src=i.urlPrefix+i.frames[0].text})})),e(this,"startMove",e=>{if(this.loaded&&O(e)&&["touchmove","mousemove"].includes(e.type)&&this.player.media.duration){if("touchmove"===e.type)this.seekTime=this.player.media.duration*(this.player.elements.inputs.seek.value/100);else{var t,r;const i=this.player.elements.progress.getBoundingClientRect(),n=100/i.width*(e.pageX-i.left);this.seekTime=this.player.media.duration*(n/100),this.seekTime<0&&(this.seekTime=0),this.seekTime>this.player.media.duration-1&&(this.seekTime=this.player.media.duration-1),this.mousePosX=e.pageX,this.elements.thumb.time.innerText=Ne(this.seekTime);const s=null===(t=this.player.config.markers)||void 0===t||null===(r=t.points)||void 0===r?void 0:r.find(({time:e})=>e===Math.round(this.seekTime));s&&this.elements.thumb.time.insertAdjacentHTML("afterbegin",`${s.label}
`)}this.showImageAtCurrentTime()}}),e(this,"endMove",()=>{this.toggleThumbContainer(!1,!0)}),e(this,"startScrubbing",e=>{(S(e.button)||!1===e.button||0===e.button)&&(this.mouseDown=!0,this.player.media.duration&&(this.toggleScrubbingContainer(!0),this.toggleThumbContainer(!1,!0),this.showImageAtCurrentTime()))}),e(this,"endScrubbing",()=>{this.mouseDown=!1,Math.ceil(this.lastTime)===Math.ceil(this.player.media.currentTime)?this.toggleScrubbingContainer(!1):de.call(this.player,this.player.media,"timeupdate",()=>{this.mouseDown||this.toggleScrubbingContainer(!1)})}),e(this,"listeners",()=>{this.player.on("play",()=>{this.toggleThumbContainer(!1,!0)}),this.player.on("seeked",()=>{this.toggleThumbContainer(!1)}),this.player.on("timeupdate",()=>{this.lastTime=this.player.media.currentTime})}),e(this,"render",()=>{this.elements.thumb.container=W("div",{class:this.player.config.classNames.previewThumbnails.thumbContainer}),this.elements.thumb.imageContainer=W("div",{class:this.player.config.classNames.previewThumbnails.imageContainer}),this.elements.thumb.container.appendChild(this.elements.thumb.imageContainer);const e=W("div",{class:this.player.config.classNames.previewThumbnails.timeContainer});this.elements.thumb.time=W("span",{},"00:00"),e.appendChild(this.elements.thumb.time),this.elements.thumb.imageContainer.appendChild(e),_(this.player.elements.progress)&&this.player.elements.progress.appendChild(this.elements.thumb.container),this.elements.scrubbing.container=W("div",{class:this.player.config.classNames.previewThumbnails.scrubbingContainer}),this.player.elements.wrapper.appendChild(this.elements.scrubbing.container)}),e(this,"destroy",()=>{this.elements.thumb.container&&this.elements.thumb.container.remove(),this.elements.scrubbing.container&&this.elements.scrubbing.container.remove()}),e(this,"showImageAtCurrentTime",()=>{this.mouseDown?this.setScrubbingContainerSize():this.setThumbContainerSizeAndPos();const e=this.thumbnails[0].frames.findIndex(e=>this.seekTime>=e.startTime&&this.seekTime<=e.endTime),t=e>=0;let r=0;this.mouseDown||this.toggleThumbContainer(t),t&&(this.thumbnails.forEach((t,i)=>{this.loadedImages.includes(t.frames[e].text)&&(r=i)}),e!==this.showingThumb&&(this.showingThumb=e,this.loadImage(r)))}),e(this,"loadImage",(e=0)=>{const t=this.showingThumb,r=this.thumbnails[e],{urlPrefix:i}=r,n=r.frames[t],s=r.frames[t].text,o=i+s;if(this.currentImageElement&&this.currentImageElement.dataset.filename===s)this.showImage(this.currentImageElement,n,e,t,s,!1),this.currentImageElement.dataset.index=t,this.removeOldImages(this.currentImageElement);else{this.loadingImage&&this.usingSprites&&(this.loadingImage.onload=null);const r=new Image;r.src=o,r.dataset.index=t,r.dataset.filename=s,this.showingThumbFilename=s,this.player.debug.log(`Loading image: ${o}`),r.onload=()=>this.showImage(r,n,e,t,s,!0),this.loadingImage=r,this.removeOldImages(r)}}),e(this,"showImage",(e,t,r,i,n,s=!0)=>{this.player.debug.log(`Showing thumb: ${n}. num: ${i}. qual: ${r}. newimg: ${s}`),this.setImageSizeAndOffset(e,t),s&&(this.currentImageContainer.appendChild(e),this.currentImageElement=e,this.loadedImages.includes(n)||this.loadedImages.push(n)),this.preloadNearby(i,!0).then(this.preloadNearby(i,!1)).then(this.getHigherQuality(r,e,t,n))}),e(this,"removeOldImages",e=>{Array.from(this.currentImageContainer.children).forEach(t=>{if("img"!==t.tagName.toLowerCase())return;const r=this.usingSprites?500:1e3;if(t.dataset.index!==e.dataset.index&&!t.dataset.deleting){t.dataset.deleting=!0;const{currentImageContainer:e}=this;setTimeout(()=>{e.removeChild(t),this.player.debug.log(`Removing thumb: ${t.dataset.filename}`)},r)}})}),e(this,"preloadNearby",(e,t=!0)=>new Promise(r=>{setTimeout(()=>{const i=this.thumbnails[0].frames[e].text;if(this.showingThumbFilename===i){let n;n=t?this.thumbnails[0].frames.slice(e):this.thumbnails[0].frames.slice(0,e).reverse();let s=!1;n.forEach(e=>{const t=e.text;if(t!==i&&!this.loadedImages.includes(t)){s=!0,this.player.debug.log(`Preloading thumb filename: ${t}`);const{urlPrefix:e}=this.thumbnails[0],i=e+t,n=new Image;n.src=i,n.onload=()=>{this.player.debug.log(`Preloaded thumb filename: ${t}`),this.loadedImages.includes(t)||this.loadedImages.push(t),r()}}}),s||r()}},300)})),e(this,"getHigherQuality",(e,t,r,i)=>{if(e{this.showingThumbFilename===i&&(this.player.debug.log(`Showing higher quality thumb for: ${i}`),this.loadImage(e+1))},300)}}),e(this,"toggleThumbContainer",(e=!1,t=!1)=>{const r=this.player.config.classNames.previewThumbnails.thumbContainerShown;this.elements.thumb.container.classList.toggle(r,e),!e&&t&&(this.showingThumb=null,this.showingThumbFilename=null)}),e(this,"toggleScrubbingContainer",(e=!1)=>{const t=this.player.config.classNames.previewThumbnails.scrubbingContainerShown;this.elements.scrubbing.container.classList.toggle(t,e),e||(this.showingThumb=null,this.showingThumbFilename=null)}),e(this,"determineContainerAutoSizing",()=>{(this.elements.thumb.imageContainer.clientHeight>20||this.elements.thumb.imageContainer.clientWidth>20)&&(this.sizeSpecifiedInCSS=!0)}),e(this,"setThumbContainerSizeAndPos",()=>{const{imageContainer:e}=this.elements.thumb;if(this.sizeSpecifiedInCSS){if(e.clientHeight>20&&e.clientWidth<20){const t=Math.floor(e.clientHeight*this.thumbAspectRatio);e.style.width=`${t}px`}else if(e.clientHeight<20&&e.clientWidth>20){const t=Math.floor(e.clientWidth/this.thumbAspectRatio);e.style.height=`${t}px`}}else{const t=Math.floor(this.thumbContainerHeight*this.thumbAspectRatio);e.style.height=`${this.thumbContainerHeight}px`,e.style.width=`${t}px`}this.setThumbContainerPos()}),e(this,"setThumbContainerPos",()=>{const e=this.player.elements.progress.getBoundingClientRect(),t=this.player.elements.container.getBoundingClientRect(),{container:r}=this.elements.thumb,i=t.left-e.left+10,n=t.right-e.left-r.clientWidth-10,s=this.mousePosX-e.left-r.clientWidth/2,o=ot(s,i,n);r.style.left=`${o}px`,r.style.setProperty("--preview-arrow-offset",s-o+"px")}),e(this,"setScrubbingContainerSize",()=>{const{width:e,height:t}=lt(this.thumbAspectRatio,{width:this.player.media.clientWidth,height:this.player.media.clientHeight});this.elements.scrubbing.container.style.width=`${e}px`,this.elements.scrubbing.container.style.height=`${t}px`}),e(this,"setImageSizeAndOffset",(e,t)=>{if(!this.usingSprites)return;const r=this.thumbContainerHeight/t.h;e.style.height=e.naturalHeight*r+"px",e.style.width=e.naturalWidth*r+"px",e.style.left=`-${t.x*r}px`,e.style.top=`-${t.y*r}px`}),this.player=t,this.thumbnails=[],this.loaded=!1,this.lastMouseMoveTime=Date.now(),this.mouseDown=!1,this.loadedImages=[],this.elements={thumb:{},scrubbing:{}},this.load()}get enabled(){return this.player.isHTML5&&this.player.isVideo&&this.player.config.previewThumbnails.enabled}get currentImageContainer(){return this.mouseDown?this.elements.scrubbing.container:this.elements.thumb.imageContainer}get usingSprites(){return Object.keys(this.thumbnails[0].frames[0]).includes("w")}get thumbAspectRatio(){return this.usingSprites?this.thumbnails[0].frames[0].w/this.thumbnails[0].frames[0].h:this.thumbnails[0].width/this.thumbnails[0].height}get thumbContainerHeight(){if(this.mouseDown){const{height:e}=lt(this.thumbAspectRatio,{width:this.player.media.clientWidth,height:this.player.media.clientHeight});return e}return this.sizeSpecifiedInCSS?this.elements.thumb.imageContainer.clientHeight:Math.floor(this.player.media.clientWidth/this.thumbAspectRatio/4)}get currentImageElement(){return this.mouseDown?this.currentScrubbingImageElement:this.currentThumbnailImageElement}set currentImageElement(e){this.mouseDown?this.currentScrubbingImageElement=e:this.currentThumbnailImageElement=e}}const ut={insertElements(e,t){x(t)?q(e,this.media,{src:t}):I(t)&&t.forEach(t=>{q(e,this.media,t)})},change(e){V(e,"sources.length")?(ke.cancelRequests.call(this),this.destroy.call(this,()=>{this.options.quality=[],z(this.media),this.media=null,_(this.elements.container)&&this.elements.container.removeAttribute("class");const{sources:t,type:r}=e,[{provider:i=He.html5,src:n}]=t,s="html5"===i?r:"div",o="html5"===i?{}:{src:n};Object.assign(this,{provider:i,type:r,supported:oe.check(r,i,this.config.playsinline),media:W(s,o)}),this.elements.container.appendChild(this.media),R(e.autoplay)&&(this.config.autoplay=e.autoplay),this.isHTML5&&(this.config.crossorigin&&this.media.setAttribute("crossorigin",""),this.config.autoplay&&this.media.setAttribute("autoplay",""),B(e.poster)||(this.poster=e.poster),this.config.loop.active&&this.media.setAttribute("loop",""),this.config.muted&&this.media.setAttribute("muted",""),this.config.playsinline&&this.media.setAttribute("playsinline","")),Ye.addStyleHook.call(this),this.isHTML5&&ut.insertElements.call(this,"source",t),this.config.title=e.title,nt.setup.call(this),this.isHTML5&&Object.keys(e).includes("tracks")&&ut.insertElements.call(this,"track",e.tracks),(this.isHTML5||this.isEmbed&&!this.supported.ui)&&Ye.build.call(this),this.isHTML5&&this.media.load(),B(e.previewThumbnails)||(Object.assign(this.config.previewThumbnails,e.previewThumbnails),this.previewThumbnails&&this.previewThumbnails.loaded&&(this.previewThumbnails.destroy(),this.previewThumbnails=null),this.config.previewThumbnails.enabled&&(this.previewThumbnails=new ct(this))),this.fullscreen.update()},!0)):this.debug.warn("Invalid source format")}};class dt{constructor(t,r){if(e(this,"play",()=>P(this.media.play)?(this.ads&&this.ads.enabled&&this.ads.managerPromise.then(()=>this.ads.play()).catch(()=>ge(this.media.play())),this.media.play()):null),e(this,"pause",()=>this.playing&&P(this.media.pause)?this.media.pause():null),e(this,"togglePlay",e=>(R(e)?e:!this.playing)?this.play():this.pause()),e(this,"stop",()=>{this.isHTML5?(this.pause(),this.restart()):P(this.media.stop)&&this.media.stop()}),e(this,"restart",()=>{this.currentTime=0}),e(this,"rewind",e=>{this.currentTime-=L(e)?e:this.config.seekTime}),e(this,"forward",e=>{this.currentTime+=L(e)?e:this.config.seekTime}),e(this,"increaseVolume",e=>{const t=this.media.muted?0:this.volume;this.volume=t+(L(e)?e:0)}),e(this,"decreaseVolume",e=>{this.increaseVolume(-e)}),e(this,"airplay",()=>{oe.airplay&&this.media.webkitShowPlaybackTargetPicker()}),e(this,"toggleControls",e=>{if(this.supported.ui&&!this.isAudio){const t=ee(this.elements.container,this.config.classNames.hideControls),r=void 0===e?void 0:!e,i=Z(this.elements.container,this.config.classNames.hideControls,r);if(i&&I(this.config.controls)&&this.config.controls.includes("settings")&&!B(this.config.settings)&&Fe.toggleMenu.call(this,!1),i!==t){const e=i?"controlshidden":"controlsshown";he.call(this,this.media,e)}return!i}return!1}),e(this,"on",(e,t)=>{ce.call(this,this.elements.container,e,t)}),e(this,"once",(e,t)=>{de.call(this,this.elements.container,e,t)}),e(this,"off",(e,t)=>{ue(this.elements.container,e,t)}),e(this,"destroy",(e,t=!1)=>{if(!this.ready)return;const r=()=>{document.body.style.overflow="",this.embed=null,t?(Object.keys(this.elements).length&&(z(this.elements.buttons.play),z(this.elements.captions),z(this.elements.controls),z(this.elements.wrapper),this.elements.buttons.play=null,this.elements.captions=null,this.elements.controls=null,this.elements.wrapper=null),P(e)&&e()):(fe.call(this),ke.cancelRequests.call(this),X(this.elements.original,this.elements.container),he.call(this,this.elements.original,"destroyed",!0),P(e)&&e.call(this.elements.original),this.ready=!1,setTimeout(()=>{this.elements=null,this.media=null},200))};this.stop(),clearTimeout(this.timers.loading),clearTimeout(this.timers.controls),clearTimeout(this.timers.resized),this.isHTML5?(Ye.toggleNativeControls.call(this,!0),r()):this.isYouTube?(clearInterval(this.timers.buffering),clearInterval(this.timers.playing),null!==this.embed&&P(this.embed.destroy)&&this.embed.destroy(),r()):this.isVimeo&&(null!==this.embed&&this.embed.unload().then(r),setTimeout(r,200))}),e(this,"supports",e=>oe.mime.call(this,e)),this.timers={},this.ready=!1,this.loading=!1,this.failed=!1,this.touch=oe.touch,this.media=t,x(this.media)&&(this.media=document.querySelectorAll(this.media)),(window.jQuery&&this.media instanceof jQuery||C(this.media)||I(this.media))&&(this.media=this.media[0]),this.config=H({},$e,dt.defaults,r||{},(()=>{try{return JSON.parse(this.media.getAttribute("data-plyr-config"))}catch(e){return{}}})()),this.elements={container:null,fullscreen:null,captions:null,buttons:{},display:{},progress:{},inputs:{},settings:{popup:null,menu:null,panels:{},buttons:{}}},this.captions={active:null,currentTrack:-1,meta:new WeakMap},this.fullscreen={active:!1},this.options={speed:[],quality:[]},this.debug=new We(this.config.debug),this.debug.log("Config",this.config),this.debug.log("Support",oe),S(this.media)||!_(this.media))return void this.debug.error("Setup failed: no suitable element passed");if(this.media.plyr)return void this.debug.warn("Target already setup");if(!this.config.enabled)return void this.debug.error("Setup failed: disabled by config");if(!oe.check().api)return void this.debug.error("Setup failed: no support");const i=this.media.cloneNode(!0);i.autoplay=!1,this.elements.original=i;const n=this.media.tagName.toLowerCase();let s=null,o=null;switch(n){case"div":if(s=this.media.querySelector("iframe"),_(s)){if(o=Be(s.getAttribute("src")),this.provider=function(e){return/^(https?:\/\/)?(www\.)?(youtube\.com|youtube-nocookie\.com|youtu\.?be)\/.+$/.test(e)?He.youtube:/^https?:\/\/player.vimeo.com\/video\/\d{0,9}(?=\b|\/)/.test(e)?He.vimeo:null}(o.toString()),this.elements.container=this.media,this.media=s,this.elements.container.className="",o.search.length){const e=["1","true"];e.includes(o.searchParams.get("autoplay"))&&(this.config.autoplay=!0),e.includes(o.searchParams.get("loop"))&&(this.config.loop.active=!0),this.isYouTube?(this.config.playsinline=e.includes(o.searchParams.get("playsinline")),this.config.youtube.hl=o.searchParams.get("hl")):this.config.playsinline=!0}}else this.provider=this.media.getAttribute(this.config.attributes.embed.provider),this.media.removeAttribute(this.config.attributes.embed.provider);if(B(this.provider)||!Object.values(He).includes(this.provider))return void this.debug.error("Setup failed: Invalid provider");this.type=Ge;break;case"video":case"audio":this.type=n,this.provider=He.html5,this.media.hasAttribute("crossorigin")&&(this.config.crossorigin=!0),this.media.hasAttribute("autoplay")&&(this.config.autoplay=!0),(this.media.hasAttribute("playsinline")||this.media.hasAttribute("webkit-playsinline"))&&(this.config.playsinline=!0),this.media.hasAttribute("muted")&&(this.config.muted=!0),this.media.hasAttribute("loop")&&(this.config.loop.active=!0);break;default:return void this.debug.error("Setup failed: unsupported type")}this.supported=oe.check(this.type,this.provider),this.supported.api?(this.eventListeners=[],this.listeners=new Xe(this),this.storage=new _e(this),this.media.plyr=this,_(this.elements.container)||(this.elements.container=W("div"),G(this.media,this.elements.container)),Ye.migrateStyles.call(this),Ye.addStyleHook.call(this),nt.setup.call(this),this.config.debug&&ce.call(this,this.elements.container,this.config.events.join(" "),e=>{this.debug.log(`event: ${e.type}`)}),this.fullscreen=new qe(this),(this.isHTML5||this.isEmbed&&!this.supported.ui)&&Ye.build.call(this),this.listeners.container(),this.listeners.global(),this.config.ads.enabled&&(this.ads=new st(this)),this.isHTML5&&this.config.autoplay&&this.once("canplay",()=>ge(this.play())),this.lastSeekTime=0,this.config.previewThumbnails.enabled&&(this.previewThumbnails=new ct(this))):this.debug.error("Setup failed: no support")}get isHTML5(){return this.provider===He.html5}get isEmbed(){return this.isYouTube||this.isVimeo}get isYouTube(){return this.provider===He.youtube}get isVimeo(){return this.provider===He.vimeo}get isVideo(){return this.type===Ge}get isAudio(){return"audio"===this.type}get playing(){return Boolean(this.ready&&!this.paused&&!this.ended)}get paused(){return Boolean(this.media.paused)}get stopped(){return Boolean(this.paused&&0===this.currentTime)}get ended(){return Boolean(this.media.ended)}set currentTime(e){if(!this.duration)return;const t=L(e)&&e>0;this.media.currentTime=t?Math.min(e,this.duration):0,this.debug.log(`Seeking to ${this.currentTime} seconds`)}get currentTime(){return Number(this.media.currentTime)}get buffered(){const{buffered:e}=this.media;return L(e)?e:e&&e.length&&this.duration>0?e.end(0)/this.duration:0}get seeking(){return Boolean(this.media.seeking)}get duration(){const e=parseFloat(this.config.duration),t=(this.media||{}).duration,r=L(t)&&t!==1/0?t:0;return e||r}set volume(e){let t=e;x(t)&&(t=Number(t)),L(t)||(t=this.storage.get("volume")),L(t)||({volume:t}=this.config),t>1&&(t=1),t<0&&(t=0),this.config.volume=t,this.media.volume=t,!B(e)&&this.muted&&t>0&&(this.muted=!1)}get volume(){return Number(this.media.volume)}set muted(e){let t=e;R(t)||(t=this.storage.get("muted")),R(t)||(t=this.config.muted),this.config.muted=t,this.media.muted=t}get muted(){return Boolean(this.media.muted)}get hasAudio(){return!this.isHTML5||!!this.isAudio||Boolean(this.media.mozHasAudio)||Boolean(this.media.webkitAudioDecodedByteCount)||Boolean(this.media.audioTracks&&this.media.audioTracks.length)}set speed(e){let t=null;L(e)&&(t=e),L(t)||(t=this.storage.get("speed")),L(t)||(t=this.config.speed.selected);const{minimumSpeed:r,maximumSpeed:i}=this;t=ot(t,r,i),this.config.speed.selected=t,setTimeout(()=>{this.media&&(this.media.playbackRate=t)},0)}get speed(){return Number(this.media.playbackRate)}get minimumSpeed(){return this.isYouTube?Math.min(...this.options.speed):this.isVimeo?.5:.0625}get maximumSpeed(){return this.isYouTube?Math.max(...this.options.speed):this.isVimeo?2:16}set quality(e){const t=this.config.quality,r=this.options.quality;if(!r.length)return;let i=[!B(e)&&Number(e),this.storage.get("quality"),t.selected,t.default].find(L),n=!0;if(!r.includes(i)){const e=ye(r,i);this.debug.warn(`Unsupported quality option: ${i}, using ${e} instead`),i=e,n=!1}t.selected=i,this.media.quality=i,n&&this.storage.set({quality:i})}get quality(){return this.media.quality}set loop(e){const t=R(e)?e:this.config.loop.active;this.config.loop.active=t,this.media.loop=t}get loop(){return Boolean(this.media.loop)}set source(e){ut.change.call(this,e)}get source(){return this.media.currentSrc}get download(){const{download:e}=this.config.urls;return F(e)?e:this.source}set download(e){F(e)&&(this.config.urls.download=e,Fe.setDownloadUrl.call(this))}set poster(e){this.isVideo?Ye.setPoster.call(this,e,!1).catch(()=>{}):this.debug.warn("Poster can only be set for video")}get poster(){return this.isVideo?this.media.getAttribute("poster")||this.media.getAttribute("data-poster"):null}get ratio(){if(!this.isVideo)return null;const e=Ae(Te.call(this));return I(e)?e.join(":"):e}set ratio(e){this.isVideo?x(e)&&Ee(e)?(this.config.ratio=Ae(e),we.call(this)):this.debug.error(`Invalid aspect ratio specified (${e})`):this.debug.warn("Aspect ratio can only be set for video")}set autoplay(e){this.config.autoplay=R(e)?e:this.config.autoplay}get autoplay(){return Boolean(this.config.autoplay)}toggleCaptions(e){je.toggle.call(this,e,!1)}set currentTrack(e){je.set.call(this,e,!1),je.setup.call(this)}get currentTrack(){const{toggled:e,currentTrack:t}=this.captions;return e?t:-1}set language(e){je.setLanguage.call(this,e,!1)}get language(){return(je.getCurrentTrack.call(this)||{}).language}set pip(e){if(!oe.pip)return;const t=R(e)?e:!this.pip;P(this.media.webkitSetPresentationMode)&&this.media.webkitSetPresentationMode(t?Ve:"inline"),P(this.media.requestPictureInPicture)&&(!this.pip&&t?this.media.requestPictureInPicture():this.pip&&!t&&document.exitPictureInPicture())}get pip(){return oe.pip?B(this.media.webkitPresentationMode)?this.media===document.pictureInPictureElement:this.media.webkitPresentationMode===Ve:null}setPreviewThumbnails(e){this.previewThumbnails&&this.previewThumbnails.loaded&&(this.previewThumbnails.destroy(),this.previewThumbnails=null),Object.assign(this.config.previewThumbnails,e),this.config.previewThumbnails.enabled&&(this.previewThumbnails=new ct(this))}static supported(e,t){return oe.check(e,t)}static loadSprite(e,t){return De(e,t)}static setup(e,t={}){let r=null;return x(e)?r=Array.from(document.querySelectorAll(e)):C(e)?r=Array.from(e):I(e)&&(r=e.filter(_)),B(r)?null:r.map(e=>new dt(e,t))}}var ht;return dt.defaults=(ht=$e,JSON.parse(JSON.stringify(ht))),dt}())},14643(e){"use strict";var t=String.prototype.replace,r=/%20/g,i="RFC3986";e.exports={default:i,formatters:{RFC1738:function(e){return t.call(e,r,"+")},RFC3986:function(e){return String(e)}},RFC1738:"RFC1738",RFC3986:i}},27527(e,t,r){"use strict";var i=r(66302),n=r(81504),s=r(14643);e.exports={formats:s,parse:n,stringify:i}},81504(e,t,r){"use strict";var i=r(52850),n=Object.prototype.hasOwnProperty,s=Array.isArray,o={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,charset:"utf-8",charsetSentinel:!1,comma:!1,decodeDotInKeys:!1,decoder:i.decode,delimiter:"&",depth:5,duplicates:"combine",ignoreQueryPrefix:!1,interpretNumericEntities:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictDepth:!1,strictMerge:!0,strictNullHandling:!1,throwOnLimitExceeded:!1},a=function(e){return e.replace(/&#(\d+);/g,function(e,t){return String.fromCharCode(parseInt(t,10))})},l=function(e,t,r){if(e&&"string"==typeof e&&t.comma&&e.indexOf(",")>-1)return e.split(",");if(t.throwOnLimitExceeded&&r>=t.arrayLimit)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(1===t.arrayLimit?"":"s")+" allowed in an array.");return e},c=function(e,t,r,s){if(e){var o=function(e,t){var r=t.allowDots?e.replace(/\.([^.[]+)/g,"[$1]"):e;if(t.depth<=0){if(!t.plainObjects&&n.call(Object.prototype,r)&&!t.allowPrototypes)return;return[r]}var i=/(\[[^[\]]*])/g,s=/(\[[^[\]]*])/.exec(r),o=s?r.slice(0,s.index):r,a=[];if(o){if(!t.plainObjects&&n.call(Object.prototype,o)&&!t.allowPrototypes)return;a[a.length]=o}for(var l=0;null!==(s=i.exec(r))&&l0&&"[]"===e[e.length-1]){var o=e.slice(0,-1).join("");s=Array.isArray(t)&&t[o]?t[o].length:0}for(var a=n?t:l(t,r,s),c=e.length-1;c>=0;--c){var u,d=e[c];if("[]"===d&&r.parseArrays)u=i.isOverflow(a)?a:r.allowEmptyArrays&&(""===a||r.strictNullHandling&&null===a)?[]:i.combine([],a,r.arrayLimit,r.plainObjects);else{u=r.plainObjects?{__proto__:null}:{};var h="["===d.charAt(0)&&"]"===d.charAt(d.length-1)?d.slice(1,-1):d,f=r.decodeDotInKeys?h.replace(/%2E/g,"."):h,p=parseInt(f,10),g=!isNaN(p)&&d!==f&&String(p)===f&&p>=0&&r.parseArrays;if(r.parseArrays||""!==f)if(g&&pu)throw new RangeError("Parameter limit exceeded. Only "+u+" parameter"+(1===u?"":"s")+" allowed.");var h,f=-1,p=t.charset;if(t.charsetSentinel)for(h=0;h-1&&(m=s(m)?[m]:m),t.comma&&s(m)&&m.length>t.arrayLimit){if(t.throwOnLimitExceeded)throw new RangeError("Array limit exceeded. Only "+t.arrayLimit+" element"+(1===t.arrayLimit?"":"s")+" allowed in an array.");m=i.combine([],m,t.arrayLimit,t.plainObjects)}if(null!==g){var E=n.call(r,g);E&&("combine"===t.duplicates||y.indexOf("[]=")>-1)?r[g]=i.combine(r[g],m,t.arrayLimit,t.plainObjects):E&&"last"!==t.duplicates||(r[g]=m)}}return r}(e,r):e,d=r.plainObjects?{__proto__:null}:{},h=Object.keys(u),f=0;f0?L.join(",")||null:void 0}];else if(l(m))C=m;else{var O=Object.keys(L);C=y?O.sort(y):O}var D=h?String(r).replace(/\./g,"%2E"):String(r),M=o&&l(L)&&1===L.length?D+"[]":D;if(a&&l(L)&&0===L.length)return M+"[]";for(var N=0;N0?A+E:""}},52850(e,t,r){"use strict";var i=r(14643),n=r(15717),s=Object.prototype.hasOwnProperty,o=Array.isArray,a=n(),l=function(e,t){return a.set(e,t),e},c=function(e){return a.has(e)},u=function(e){return a.get(e)},d=function(e,t){a.set(e,t)},h=function(){for(var e=[],t=0;t<256;++t)e[e.length]="%"+((t<16?"0":"")+t.toString(16)).toUpperCase();return e}(),f=function(e,t){for(var r=t&&t.plainObjects?{__proto__:null}:{},i=0;ir?l(f(s,{plainObjects:i}),s.length-1):s},compact:function(e){for(var t=[{obj:{o:e},prop:"o"}],r=[],i=0;i1;){var t=e.pop(),r=t.obj[t.prop];if(o(r)){for(var i=[],n=0;n=p?o.slice(l,l+p):o,u=[],d=0;d=48&&f<=57||f>=65&&f<=90||f>=97&&f<=122||s===i.RFC1738&&(40===f||41===f)?u[u.length]=c.charAt(d):f<128?u[u.length]=h[f]:f<2048?u[u.length]=h[192|f>>6]+h[128|63&f]:f<55296||f>=57344?u[u.length]=h[224|f>>12]+h[128|f>>6&63]+h[128|63&f]:(d+=1,f=65536+((1023&f)<<10|1023&c.charCodeAt(d)),u[u.length]=h[240|f>>18]+h[128|f>>12&63]+h[128|f>>6&63]+h[128|63&f])}a+=u.join("")}return a},isBuffer:function(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))},isOverflow:c,isRegExp:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},markOverflow:l,maybeMap:function(e,t){if(o(e)){for(var r=[],i=0;ii.arrayLimit)return l(f(t.concat(r),i),n);t[n]=r}else{if(!t||"object"!=typeof t)return[t,r];if(c(t)){var a=u(t)+1;t[a]=r,d(t,a)}else{if(i&&i.strictMerge)return[t,r];(i&&(i.plainObjects||i.allowPrototypes)||!s.call(Object.prototype,r))&&(t[r]=!0)}}return t}if(!t||"object"!=typeof t){if(c(r)){for(var h=Object.keys(r),p=i&&i.plainObjects?{__proto__:null,0:t}:{0:t},g=0;gi.arrayLimit?l(f(m,i),m.length-1):m}var y=t;return o(t)&&!o(r)&&(y=f(t,i)),o(t)&&o(r)?(r.forEach(function(r,n){if(s.call(t,n)){var o=t[n];o&&"object"==typeof o&&r&&"object"==typeof r?t[n]=e(o,r,i):t[t.length]=r}else t[n]=r}),t):Object.keys(r).reduce(function(t,n){var o=r[n];if(s.call(t,n)?t[n]=e(t[n],o,i):t[n]=o,c(r)&&!c(t)&&l(t,u(r)),c(t)){var a=parseInt(n,10);String(a)===n&&a>=0&&a>u(t)&&d(t,a)}return t},y)}}},82185(e){var t=function(e){"use strict";var t,r=Object.prototype,i=r.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},s="function"==typeof Symbol?Symbol:{},o=s.iterator||"@@iterator",a=s.asyncIterator||"@@asyncIterator",l=s.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function u(e,t,r,i){var s=t&&t.prototype instanceof y?t:y,o=Object.create(s.prototype),a=new I(i||[]);return n(o,"_invoke",{value:L(e,r,a)}),o}function d(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var h="suspendedStart",f="suspendedYield",p="executing",g="completed",m={};function y(){}function v(){}function b(){}var E={};c(E,o,function(){return this});var A=Object.getPrototypeOf,T=A&&A(A(C([])));T&&T!==r&&i.call(T,o)&&(E=T);var w=b.prototype=y.prototype=Object.create(E);function S(e){["next","throw","return"].forEach(function(t){c(e,t,function(e){return this._invoke(t,e)})})}function k(e,t){function r(n,s,o,a){var l=d(e[n],e,s);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==typeof u&&i.call(u,"__await")?t.resolve(u.__await).then(function(e){r("next",e,o,a)},function(e){r("throw",e,o,a)}):t.resolve(u).then(function(e){c.value=e,o(c)},function(e){return r("throw",e,o,a)})}a(l.arg)}var s;n(this,"_invoke",{value:function(e,i){function n(){return new t(function(t,n){r(e,i,t,n)})}return s=s?s.then(n,n):n()}})}function L(e,r,i){var n=h;return function(s,o){if(n===p)throw new Error("Generator is already running");if(n===g){if("throw"===s)throw o;return{value:t,done:!0}}for(i.method=s,i.arg=o;;){var a=i.delegate;if(a){var l=x(a,i);if(l){if(l===m)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if(n===h)throw n=g,i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);n=p;var c=d(e,r,i);if("normal"===c.type){if(n=i.done?g:f,c.arg===m)continue;return{value:c.arg,done:i.done}}"throw"===c.type&&(n=g,i.method="throw",i.arg=c.arg)}}}function x(e,r){var i=r.method,n=e.iterator[i];if(n===t)return r.delegate=null,"throw"===i&&e.iterator.return&&(r.method="return",r.arg=t,x(e,r),"throw"===r.method)||"return"!==i&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+i+"' method")),m;var s=d(n,e.iterator,r.arg);if("throw"===s.type)return r.method="throw",r.arg=s.arg,r.delegate=null,m;var o=s.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function R(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function P(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(R,this),this.reset(!0)}function C(e){if(null!=e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,s=function r(){for(;++n=0;--s){var o=this.tryEntries[s],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var l=i.call(o,"catchLoc"),c=i.call(o,"finallyLoc");if(l&&c){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),P(r),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var i=r.completion;if("throw"===i.type){var n=i.arg;P(r)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,i){return this.delegate={iterator:C(e),resultName:r,nextLoc:i},"next"===this.method&&(this.arg=t),m}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}},9552(e,t,r){"use strict";var i=r(24922),n=r(57379),s=function(e,t,r){for(var i,n=e;null!=(i=n.next);n=i)if(i.key===t)return n.next=i.next,r||(i.next=e.next,e.next=i),i};e.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new n("Side channel does not contain "+i(e))},delete:function(t){var r=e&&e.next,i=function(e,t){if(e)return s(e,t,!0)}(e,t);return i&&r&&r===i&&(e=void 0),!!i},get:function(t){return function(e,t){if(e){var r=s(e,t);return r&&r.value}}(e,t)},has:function(t){return function(e,t){return!!e&&!!s(e,t)}(e,t)},set:function(t,r){e||(e={next:void 0}),function(e,t,r){var i=s(e,t);i?i.value=r:e.next={key:t,next:e.next,value:r}}(e,t,r)}};return t}},41085(e,t,r){"use strict";var i=r(40703),n=r(15298),s=r(24922),o=r(57379),a=i("%Map%",!0),l=n("Map.prototype.get",!0),c=n("Map.prototype.set",!0),u=n("Map.prototype.has",!0),d=n("Map.prototype.delete",!0),h=n("Map.prototype.size",!0);e.exports=!!a&&function(){var e,t={assert:function(e){if(!t.has(e))throw new o("Side channel does not contain "+s(e))},delete:function(t){if(e){var r=d(e,t);return 0===h(e)&&(e=void 0),r}return!1},get:function(t){if(e)return l(e,t)},has:function(t){return!!e&&u(e,t)},set:function(t,r){e||(e=new a),c(e,t,r)}};return t}},52468(e,t,r){"use strict";var i=r(40703),n=r(15298),s=r(24922),o=r(41085),a=r(57379),l=i("%WeakMap%",!0),c=n("WeakMap.prototype.get",!0),u=n("WeakMap.prototype.set",!0),d=n("WeakMap.prototype.has",!0),h=n("WeakMap.prototype.delete",!0);e.exports=l?function(){var e,t,r={assert:function(e){if(!r.has(e))throw new a("Side channel does not contain "+s(e))},delete:function(r){if(l&&r&&("object"==typeof r||"function"==typeof r)){if(e)return h(e,r)}else if(o&&t)return t.delete(r);return!1},get:function(r){return l&&r&&("object"==typeof r||"function"==typeof r)&&e?c(e,r):t&&t.get(r)},has:function(r){return l&&r&&("object"==typeof r||"function"==typeof r)&&e?d(e,r):!!t&&t.has(r)},set:function(r,i){l&&r&&("object"==typeof r||"function"==typeof r)?(e||(e=new l),u(e,r,i)):o&&(t||(t=o()),t.set(r,i))}};return r}:o},15717(e,t,r){"use strict";var i=r(57379),n=r(24922),s=r(9552),o=r(41085),a=r(52468)||o||s;e.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new i("Side channel does not contain "+n(e))},delete:function(t){return!!e&&e.delete(t)},get:function(t){return e&&e.get(t)},has:function(t){return!!e&&e.has(t)},set:function(t,r){e||(e=a()),e.set(t,r)}};return t}},12233(){!function(e){var t=function(){try{return!!Symbol.iterator}catch(e){return!1}}(),r=function(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t&&(r[Symbol.iterator]=function(){return r}),r},i=function(e){return encodeURIComponent(e).replace(/%20/g,"+")},n=function(e){return decodeURIComponent(String(e).replace(/\+/g," "))};(function(){try{var t=e.URLSearchParams;return"a=1"===new t("?a=1").toString()&&"function"==typeof t.prototype.set&&"function"==typeof t.prototype.entries}catch(e){return!1}})()||function(){var n=function(e){Object.defineProperty(this,"_entries",{writable:!0,value:{}});var t=typeof e;if("undefined"===t);else if("string"===t)""!==e&&this._fromString(e);else if(e instanceof n){var r=this;e.forEach(function(e,t){r.append(t,e)})}else{if(null===e||"object"!==t)throw new TypeError("Unsupported input's type for URLSearchParams");if("[object Array]"===Object.prototype.toString.call(e))for(var i=0;it[0]?1:0}),e._entries&&(e._entries={});for(var r=0;r1?n(i.slice(1).join("=")):"")}})}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:this),function(e){if(function(){try{var t=new e.URL("b","http://a");return t.pathname="c d","http://a/c%20d"===t.href&&t.searchParams}catch(e){return!1}}()||function(){var t=e.URL,r=function(t,r){"string"!=typeof t&&(t=String(t)),r&&"string"!=typeof r&&(r=String(r));var i,n=document;if(r&&(void 0===e.location||r!==e.location.href)){!!window.MSInputMethodContext&&!!document.documentMode&&(r=r.toLowerCase()),(i=(n=document.implementation.createHTMLDocument("")).createElement("base")).href=r,n.head.appendChild(i);try{if(0!==i.href.indexOf(r))throw new Error(i.href)}catch(e){throw new Error("URL unable to set base "+r+" due to "+e)}}var s=n.createElement("a");s.href=t,i&&(n.body.appendChild(s),s.href=s.href);var o=n.createElement("input");if(o.type="url",o.value=t,":"===s.protocol||!/:/.test(s.href)||!o.checkValidity()&&!r)throw new TypeError("Invalid URL");Object.defineProperty(this,"_anchorElement",{value:s});var a=new e.URLSearchParams(this.search),l=!0,c=!0,u=this;["append","delete","set"].forEach(function(e){var t=a[e];a[e]=function(){t.apply(a,arguments),l&&(c=!1,u.search=a.toString(),c=!0)}}),Object.defineProperty(this,"searchParams",{value:a,enumerable:!0});var d=void 0;Object.defineProperty(this,"_updateSearchParams",{enumerable:!1,configurable:!1,writable:!1,value:function(){this.search!==d&&(d=this.search,c&&(l=!1,this.searchParams._fromString(this.search),l=!0))}})},i=r.prototype;["hash","host","hostname","port","protocol"].forEach(function(e){!function(e){Object.defineProperty(i,e,{get:function(){return this._anchorElement[e]},set:function(t){this._anchorElement[e]=t},enumerable:!0})}(e)}),Object.defineProperty(i,"search",{get:function(){return this._anchorElement.search},set:function(e){this._anchorElement.search=e,this._updateSearchParams()},enumerable:!0}),Object.defineProperties(i,{toString:{get:function(){var e=this;return function(){return e.href}}},href:{get:function(){return this._anchorElement.href.replace(/\?$/,"")},set:function(e){this._anchorElement.href=e,this._updateSearchParams()},enumerable:!0},pathname:{get:function(){return this._anchorElement.pathname.replace(/(^\/?)/,"/")},set:function(e){this._anchorElement.pathname=e},enumerable:!0},origin:{get:function(){var e={"http:":80,"https:":443,"ftp:":21}[this._anchorElement.protocol],t=this._anchorElement.port!=e&&""!==this._anchorElement.port;return this._anchorElement.protocol+"//"+this._anchorElement.hostname+(t?":"+this._anchorElement.port:"")},enumerable:!0},password:{get:function(){return""},set:function(e){},enumerable:!0},username:{get:function(){return""},set:function(e){},enumerable:!0}}),r.createObjectURL=function(e){return t.createObjectURL.apply(t,arguments)},r.revokeObjectURL=function(e){return t.revokeObjectURL.apply(t,arguments)},e.URL=r}(),void 0!==e.location&&!("origin"in e.location)){var t=function(){return e.location.protocol+"//"+e.location.hostname+(e.location.port?":"+e.location.port:"")};try{Object.defineProperty(e.location,"origin",{get:t,enumerable:!0})}catch(r){setInterval(function(){e.location.origin=t()},100)}}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:this)},22179(){},57922(e){e.exports=function(e,t){this.v=e,this.k=t},e.exports.__esModule=!0,e.exports.default=e.exports},72169(e){e.exports=function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e},e.exports.__esModule=!0,e.exports.default=e.exports},19733(e){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},87172(e,t,r){var i=r(75600),n=r(96238);e.exports=function(e,t,r){if(i())return Reflect.construct.apply(null,arguments);var s=[null];s.push.apply(s,t);var o=new(e.bind.apply(e,s));return r&&n(o,r.prototype),o},e.exports.__esModule=!0,e.exports.default=e.exports},52531(e,t,r){var i=r(36866);e.exports=function(e,t,r){return(t=i(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.__esModule=!0,e.exports.default=e.exports},87266(e){function t(r){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},91965(e,t,r){var i=r(96238);e.exports=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&i(e,t)},e.exports.__esModule=!0,e.exports.default=e.exports},28632(e){e.exports=function(e){return e&&e.__esModule?e:{default:e}},e.exports.__esModule=!0,e.exports.default=e.exports},11435(e,t,r){var i=r(31948).default;function n(t,r){if("function"==typeof WeakMap)var s=new WeakMap,o=new WeakMap;return(e.exports=n=function(e,t){if(!t&&e&&e.__esModule)return e;var r,n,a={__proto__:null,default:e};if(null===e||"object"!=i(e)&&"function"!=typeof e)return a;if(r=t?o:s){if(r.has(e))return r.get(e);r.set(e,a)}for(var l in e)"default"!==l&&{}.hasOwnProperty.call(e,l)&&((n=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,l))&&(n.get||n.set)?r(a,l,n):a[l]=e[l]);return a},e.exports.__esModule=!0,e.exports.default=e.exports)(t,r)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports},62554(e){e.exports=function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}},e.exports.__esModule=!0,e.exports.default=e.exports},75600(e){function t(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(r){}return(e.exports=t=function(){return!!r},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},68630(e,t,r){var i=r(31948).default,n=r(72169);e.exports=function(e,t){if(t&&("object"==i(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return n(e)},e.exports.__esModule=!0,e.exports.default=e.exports},41143(e,t,r){var i=r(60448);function n(){var t,r,s="function"==typeof Symbol?Symbol:{},o=s.iterator||"@@iterator",a=s.toStringTag||"@@toStringTag";function l(e,n,s,o){var a=n&&n.prototype instanceof u?n:u,l=Object.create(a.prototype);return i(l,"_invoke",function(e,i,n){var s,o,a,l=0,u=n||[],d=!1,h={p:0,n:0,v:t,a:f,f:f.bind(t,4),d:function(e,r){return s=e,o=0,a=t,h.n=r,c}};function f(e,i){for(o=e,a=i,r=0;!d&&l&&!n&&r3?(n=p===i)&&(a=s[(o=s[4])?5:(o=3,3)],s[4]=s[5]=t):s[0]<=f&&((n=e<2&&fi||i>p)&&(s[4]=e,s[5]=i,h.n=p,o=0))}if(n||e>1)return c;throw d=!0,i}return function(n,u,p){if(l>1)throw TypeError("Generator is already running");for(d&&1===u&&f(u,p),o=u,a=p;(r=o<2?t:a)||!d;){s||(o?o<3?(o>1&&(h.n=-1),f(o,a)):h.n=a:h.v=a);try{if(l=2,s){if(o||(n="next"),r=s[n]){if(!(r=r.call(s,a)))throw TypeError("iterator result is not an object");if(!r.done)return r;a=r.value,o<2&&(o=0)}else 1===o&&(r=s.return)&&r.call(s),o<2&&(a=TypeError("The iterator does not provide a '"+n+"' method"),o=1);s=t}else if((r=(d=h.n<0)?a:e.call(i,h))!==c)break}catch(e){s=t,o=1,a=e}finally{l=1}}return{value:r,done:d}}}(e,s,o),!0),l}var c={};function u(){}function d(){}function h(){}r=Object.getPrototypeOf;var f=[][o]?r(r([][o]())):(i(r={},o,function(){return this}),r),p=h.prototype=u.prototype=Object.create(f);function g(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,i(e,a,"GeneratorFunction")),e.prototype=Object.create(p),e}return d.prototype=h,i(p,"constructor",h),i(h,"constructor",d),d.displayName="GeneratorFunction",i(h,a,"GeneratorFunction"),i(p),i(p,a,"Generator"),i(p,o,function(){return this}),i(p,"toString",function(){return"[object Generator]"}),(e.exports=n=function(){return{w:l,m:g}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports},32275(e,t,r){var i=r(41361);e.exports=function(e,t,r,n,s){var o=i(e,t,r,n,s);return o.next().then(function(e){return e.done?e.value:o.next()})},e.exports.__esModule=!0,e.exports.default=e.exports},41361(e,t,r){var i=r(41143),n=r(44273);e.exports=function(e,t,r,s,o){return new n(i().w(e,t,r,s),o||Promise)},e.exports.__esModule=!0,e.exports.default=e.exports},44273(e,t,r){var i=r(57922),n=r(60448);e.exports=function e(t,r){function s(e,n,o,a){try{var l=t[e](n),c=l.value;return c instanceof i?r.resolve(c.v).then(function(e){s("next",e,o,a)},function(e){s("throw",e,o,a)}):r.resolve(c).then(function(e){l.value=e,o(l)},function(e){return s("throw",e,o,a)})}catch(e){a(e)}}var o;this.next||(n(e.prototype),n(e.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),n(this,"_invoke",function(e,t,i){function n(){return new r(function(t,r){s(e,i,t,r)})}return o=o?o.then(n,n):n()},!0)},e.exports.__esModule=!0,e.exports.default=e.exports},60448(e){function t(r,i,n,s){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}e.exports=t=function(e,r,i,n){function s(r,i){t(e,r,function(e){return this._invoke(r,i,e)})}r?o?o(e,r,{value:i,enumerable:!n,configurable:!n,writable:!n}):e[r]=i:(s("next",0),s("throw",1),s("return",2))},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,i,n,s)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},27051(e){e.exports=function(e){var t=Object(e),r=[];for(var i in t)r.unshift(i);return function e(){for(;r.length;)if((i=r.pop())in t)return e.value=i,e.done=!1,e;return e.done=!0,e}},e.exports.__esModule=!0,e.exports.default=e.exports},58771(e,t,r){var i=r(57922),n=r(41143),s=r(32275),o=r(41361),a=r(44273),l=r(27051),c=r(70009);function u(){"use strict";var t=n(),r=t.m(u),d=(Object.getPrototypeOf?Object.getPrototypeOf(r):r.__proto__).constructor;function h(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))}var f={throw:1,return:2,break:3,continue:3};function p(e){var t,r;return function(i){t||(t={stop:function(){return r(i.a,2)},catch:function(){return i.v},abrupt:function(e,t){return r(i.a,f[e],t)},delegateYield:function(e,n,s){return t.resultName=n,r(i.d,c(e),s)},finish:function(e){return r(i.f,e)}},r=function(e,r,n){i.p=t.prev,i.n=t.next;try{return e(r,n)}finally{t.next=i.n}}),t.resultName&&(t[t.resultName]=i.v,t.resultName=void 0),t.sent=i.v,t.next=i.n;try{return e.call(this,t)}finally{i.p=t.prev,i.n=t.next}}}return(e.exports=u=function(){return{wrap:function(e,r,i,n){return t.w(p(e),r,i,n&&n.reverse())},isGeneratorFunction:h,mark:t.m,awrap:function(e,t){return new i(e,t)},AsyncIterator:a,async:function(e,t,r,i,n){return(h(t)?o:s)(p(e),t,r,i,n)},keys:l,values:c}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=u,e.exports.__esModule=!0,e.exports.default=e.exports},70009(e,t,r){var i=r(31948).default;e.exports=function(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw new TypeError(i(e)+" is not iterable")},e.exports.__esModule=!0,e.exports.default=e.exports},96238(e){function t(r,i){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,i)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},65031(e,t,r){var i=r(31948).default;e.exports=function(e,t){if("object"!=i(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=i(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)},e.exports.__esModule=!0,e.exports.default=e.exports},36866(e,t,r){var i=r(31948).default,n=r(65031);e.exports=function(e){var t=n(e,"string");return"symbol"==i(t)?t:t+""},e.exports.__esModule=!0,e.exports.default=e.exports},31948(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},42507(e,t,r){var i=r(87266),n=r(96238),s=r(62554),o=r(87172);function a(t){var r="function"==typeof Map?new Map:void 0;return e.exports=a=function(e){if(null===e||!s(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return o(e,arguments,i(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),n(t,e)},e.exports.__esModule=!0,e.exports.default=e.exports,a(t)}e.exports=a,e.exports.__esModule=!0,e.exports.default=e.exports},94758(e,t,r){var i=r(58771)();e.exports=i;try{regeneratorRuntime=i}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}},18522(e,t,r){"use strict";var i=r(97157),n=r(93447),s=TypeError;e.exports=function(e){if(i(e))return e;throw new s(n(e)+" is not a function")}},34412(e,t,r){"use strict";var i=r(2173),n=r(93447),s=TypeError;e.exports=function(e){if(i(e))return e;throw new s(n(e)+" is not a constructor")}},49362(e,t,r){"use strict";var i=r(70005),n=String,s=TypeError;e.exports=function(e){if(i(e))return e;throw new s("Can't set "+n(e)+" as a prototype")}},4085(e,t,r){"use strict";var i=r(56547),n=r(65416),s=r(94401).f,o=i("unscopables"),a=Array.prototype;void 0===a[o]&&s(a,o,{configurable:!0,value:n(null)}),e.exports=function(e){a[o][e]=!0}},65397(e,t,r){"use strict";var i=r(54087).charAt;e.exports=function(e,t,r){return t+(r?i(e,t).length:1)}},10983(e,t,r){"use strict";var i=r(95881),n=TypeError;e.exports=function(e,t){if(i(t,e))return e;throw new n("Incorrect invocation")}},82007(e,t,r){"use strict";var i=r(70930),n=String,s=TypeError;e.exports=function(e){if(i(e))return e;throw new s(n(e)+" is not an object")}},10051(e){"use strict";e.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView},28308(e,t,r){"use strict";var i=r(70383);e.exports=i(function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}})},1508(e,t,r){"use strict";var i,n,s,o=r(10051),a=r(20092),l=r(98896),c=r(97157),u=r(70930),d=r(47121),h=r(98731),f=r(93447),p=r(96091),g=r(13368),m=r(27402),y=r(95881),v=r(22995),b=r(45047),E=r(56547),A=r(59008),T=r(92733),w=T.enforce,S=T.get,k=l.Int8Array,L=k&&k.prototype,x=l.Uint8ClampedArray,R=x&&x.prototype,P=k&&v(k),I=L&&v(L),C=Object.prototype,_=l.TypeError,O=E("toStringTag"),D=A("TYPED_ARRAY_TAG"),M="TypedArrayConstructor",N=o&&!!b&&"Opera"!==h(l.opera),F=!1,B={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},U={BigInt64Array:8,BigUint64Array:8},j=function(e){var t=v(e);if(u(t)){var r=S(t);return r&&d(r,M)?r[M]:j(t)}},$=function(e){if(!u(e))return!1;var t=h(e);return d(B,t)||d(U,t)};for(i in B)(s=(n=l[i])&&n.prototype)?w(s)[M]=n:N=!1;for(i in U)(s=(n=l[i])&&n.prototype)&&(w(s)[M]=n);if((!N||!c(P)||P===Function.prototype)&&(P=function(){throw new _("Incorrect invocation")},N))for(i in B)l[i]&&b(l[i],P);if((!N||!I||I===C)&&(I=P.prototype,N))for(i in B)l[i]&&b(l[i].prototype,I);if(N&&v(R)!==I&&b(R,I),a&&!d(I,O))for(i in F=!0,m(I,O,{configurable:!0,get:function(){return u(this)?this[D]:void 0}}),B)l[i]&&p(l[i],D,i);e.exports={NATIVE_ARRAY_BUFFER_VIEWS:N,TYPED_ARRAY_TAG:F&&D,aTypedArray:function(e){if($(e))return e;throw new _("Target is not a typed array")},aTypedArrayConstructor:function(e){if(c(e)&&(!b||y(P,e)))return e;throw new _(f(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,r,i){if(a){if(r)for(var n in B){var s=l[n];if(s&&d(s.prototype,e))try{delete s.prototype[e]}catch(r){try{s.prototype[e]=t}catch(e){}}}I[e]&&!r||g(I,e,r?t:N&&L[e]||t,i)}},exportTypedArrayStaticMethod:function(e,t,r){var i,n;if(a){if(b){if(r)for(i in B)if((n=l[i])&&d(n,e))try{delete n[e]}catch(e){}if(P[e]&&!r)return;try{return g(P,e,r?t:N&&P[e]||t)}catch(e){}}for(i in B)!(n=l[i])||n[e]&&!r||g(n,e,t)}},getTypedArrayConstructor:j,isView:function(e){if(!u(e))return!1;var t=h(e);return"DataView"===t||d(B,t)||d(U,t)},isTypedArray:$,TypedArray:P,TypedArrayPrototype:I}},32410(e,t,r){"use strict";var i=r(98896),n=r(3712),s=r(20092),o=r(10051),a=r(7934),l=r(96091),c=r(27402),u=r(51303),d=r(70383),h=r(10983),f=r(45707),p=r(47214),g=r(58640),m=r(46449),y=r(90554),v=r(22995),b=r(45047),E=r(39269),A=r(96496),T=r(23855),w=r(13884),S=r(7023),k=r(92733),L=a.PROPER,x=a.CONFIGURABLE,R="ArrayBuffer",P="DataView",I="prototype",C="Wrong index",_=k.getterFor(R),O=k.getterFor(P),D=k.set,M=i[R],N=M,F=N&&N[I],B=i[P],U=B&&B[I],j=Object.prototype,$=i.Array,V=i.RangeError,H=n(E),G=n([].reverse),K=y.pack,W=y.unpack,q=function(e){return[255&e]},z=function(e){return[255&e,e>>8&255]},Y=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},X=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},Q=function(e){return K(m(e),23,4)},J=function(e){return K(e,52,8)},Z=function(e,t,r){c(e[I],t,{configurable:!0,get:function(){return r(this)[t]}})},ee=function(e,t,r,i){var n=O(e),s=g(r),o=!!i;if(s+t>n.byteLength)throw new V(C);var a=n.bytes,l=s+n.byteOffset,c=A(a,l,l+t);return o?c:G(c)},te=function(e,t,r,i,n,s){var o=O(e),a=g(r),l=i(+n),c=!!s;if(a+t>o.byteLength)throw new V(C);for(var u=o.bytes,d=a+o.byteOffset,h=0;h>24)},setUint8:function(e,t){ne(this,e,t<<24>>24)}},{unsafe:!0})}else F=(N=function(e){h(this,F);var t=g(e);D(this,{type:R,bytes:H($(t),0),byteLength:t}),s||(this.byteLength=t,this.detached=!1)})[I],U=(B=function(e,t,r){h(this,U),h(e,F);var i=_(e),n=i.byteLength,o=f(t);if(o<0||o>n)throw new V("Wrong offset");if(o+(r=void 0===r?n-o:p(r))>n)throw new V("Wrong length");D(this,{type:P,buffer:e,byteLength:r,byteOffset:o,bytes:i.bytes}),s||(this.buffer=e,this.byteLength=r,this.byteOffset=o)})[I],s&&(Z(N,"byteLength",_),Z(B,"buffer",O),Z(B,"byteLength",O),Z(B,"byteOffset",O)),u(U,{getInt8:function(e){return ee(this,1,e)[0]<<24>>24},getUint8:function(e){return ee(this,1,e)[0]},getInt16:function(e){var t=ee(this,2,e,arguments.length>1&&arguments[1]);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=ee(this,2,e,arguments.length>1&&arguments[1]);return t[1]<<8|t[0]},getInt32:function(e){return X(ee(this,4,e,arguments.length>1&&arguments[1]))},getUint32:function(e){return X(ee(this,4,e,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(e){return W(ee(this,4,e,arguments.length>1&&arguments[1]),23)},getFloat64:function(e){return W(ee(this,8,e,arguments.length>1&&arguments[1]),52)},setInt8:function(e,t){te(this,1,e,q,t)},setUint8:function(e,t){te(this,1,e,q,t)},setInt16:function(e,t){te(this,2,e,z,t,arguments.length>2&&arguments[2])},setUint16:function(e,t){te(this,2,e,z,t,arguments.length>2&&arguments[2])},setInt32:function(e,t){te(this,4,e,Y,t,arguments.length>2&&arguments[2])},setUint32:function(e,t){te(this,4,e,Y,t,arguments.length>2&&arguments[2])},setFloat32:function(e,t){te(this,4,e,Q,t,arguments.length>2&&arguments[2])},setFloat64:function(e,t){te(this,8,e,J,t,arguments.length>2&&arguments[2])}});S(N,R),S(B,P),e.exports={ArrayBuffer:N,DataView:B}},41589(e,t,r){"use strict";var i=r(50437),n=r(8810),s=r(39942),o=r(85646),a=Math.min;e.exports=[].copyWithin||function(e,t){var r=i(this),l=s(r),c=n(e,l),u=n(t,l),d=arguments.length>2?arguments[2]:void 0,h=a((void 0===d?l:n(d,l))-u,l-c),f=1;for(u0;)u in r?r[c]=r[u]:o(r,c),c+=f,u+=f;return r}},39269(e,t,r){"use strict";var i=r(50437),n=r(8810),s=r(39942);e.exports=function(e){for(var t=i(this),r=s(t),o=arguments.length,a=n(o>1?arguments[1]:void 0,r),l=o>2?arguments[2]:void 0,c=void 0===l?r:n(l,r);c>a;)t[a++]=e;return t}},61611(e,t,r){"use strict";var i=r(86045).forEach,n=r(19190)("forEach");e.exports=n?[].forEach:function(e){return i(this,e,arguments.length>1?arguments[1]:void 0)}},98618(e,t,r){"use strict";var i=r(39942);e.exports=function(e,t,r){for(var n=0,s=arguments.length>2?r:i(t),o=new e(s);s>n;)o[n]=t[n++];return o}},33868(e,t,r){"use strict";var i=r(81024),n=r(91661),s=r(50437),o=r(80815),a=r(33505),l=r(2173),c=r(39942),u=r(43648),d=r(75919),h=r(63153),f=r(59667),p=Array;e.exports=function(e){var t=s(e),r=l(this),g=arguments.length,m=g>1?arguments[1]:void 0,y=void 0!==m;y&&(m=i(m,g>2?arguments[2]:void 0));var v,b,E,A,T,w,S=f(t),k=0;if(!S||this===p&&a(S))for(v=c(t),b=r?new this(v):p(v);v>k;k++)w=y?m(t[k],k):t[k],u(b,k,w);else for(b=r?new this:[],T=(A=h(t,S)).next;!(E=n(T,A)).done;k++)w=y?o(A,m,[E.value,k],!0):E.value,u(b,k,w);return d(b,k),b}},69457(e,t,r){"use strict";var i=r(65317),n=r(8810),s=r(39942),o=function(e){return function(t,r,o){var a=i(t),l=s(a);if(0===l)return!e&&-1;var c,u=n(o,l);if(e&&r!=r){for(;l>u;)if((c=a[u++])!=c)return!0}else for(;l>u;u++)if((e||u in a)&&a[u]===r)return e||u||0;return!e&&-1}};e.exports={includes:o(!0),indexOf:o(!1)}},86045(e,t,r){"use strict";var i=r(81024),n=r(33151),s=r(50437),o=r(39942),a=r(26445),l=r(43648),c=function(e){var t=1===e,r=2===e,c=3===e,u=4===e,d=6===e,h=7===e,f=5===e||d;return function(p,g,m){for(var y,v,b=s(p),E=n(b),A=o(E),T=i(g,m),w=0,S=0,k=t?a(p,A):r||h?a(p,0):void 0;A>w;w++)if((f||w in E)&&(v=T(y=E[w],w,b),e))if(t)l(k,w,v);else if(v)switch(e){case 3:return!0;case 5:return y;case 6:return w;case 2:l(k,S++,y)}else switch(e){case 4:return!1;case 7:l(k,S++,y)}return d?-1:c||u?u:k}};e.exports={forEach:c(0),map:c(1),filter:c(2),some:c(3),every:c(4),find:c(5),findIndex:c(6),filterReject:c(7)}},82443(e,t,r){"use strict";var i=r(97321),n=r(65317),s=r(45707),o=r(39942),a=r(19190),l=Math.min,c=[].lastIndexOf,u=!!c&&1/[1].lastIndexOf(1,-0)<0,d=a("lastIndexOf"),h=u||!d;e.exports=h?function(e){if(u)return i(c,this,arguments)||0;var t=n(this),r=o(t);if(0===r)return-1;var a=r-1;for(arguments.length>1&&(a=l(a,s(arguments[1]))),a<0&&(a=r+a);a>=0;a--)if(a in t&&t[a]===e)return a||0;return-1}:c},35125(e,t,r){"use strict";var i=r(70383),n=r(56547),s=r(54863),o=n("species");e.exports=function(e){return s>=51||!i(function(){var t=[];return(t.constructor={})[o]=function(){return{foo:1}},1!==t[e](Boolean).foo})}},19190(e,t,r){"use strict";var i=r(70383);e.exports=function(e,t){var r=[][e];return!!r&&i(function(){r.call(null,t||function(){return 1},1)})}},10222(e,t,r){"use strict";var i=r(18522),n=r(50437),s=r(33151),o=r(39942),a=TypeError,l="Reduce of empty array with no initial value",c=function(e){return function(t,r,c,u){var d=n(t),h=s(d),f=o(d);if(i(r),0===f&&c<2)throw new a(l);var p=e?f-1:0,g=e?-1:1;if(c<2)for(;;){if(p in h){u=h[p],p+=g;break}if(p+=g,e?p<0:f<=p)throw new a(l)}for(;e?p>=0:f>p;p+=g)p in h&&(u=r(u,h[p],p,d));return u}};e.exports={left:c(!1),right:c(!0)}},75919(e,t,r){"use strict";var i=r(20092),n=r(48600),s=TypeError,o=Object.getOwnPropertyDescriptor,a=i&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}();e.exports=a?function(e,t){if(n(e)&&!o(e,"length").writable)throw new s("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t}},96496(e,t,r){"use strict";var i=r(3712);e.exports=i([].slice)},35656(e,t,r){"use strict";var i=r(96496),n=Math.floor,s=function(e,t){var r=e.length;if(r<8)for(var o,a,l=1;l0;)e[a]=e[--a];a!==l++&&(e[a]=o)}else for(var c=n(r/2),u=s(i(e,0,c),t),d=s(i(e,c),t),h=u.length,f=d.length,p=0,g=0;p1?arguments[1]:void 0);t=t?t.next:r.first;)for(i(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!b(this,e)}}),s(h,r?{get:function(e){var t=b(this,e);return t&&t.value},set:function(e,t){return v(this,0===e?0:e,t)}}:{add:function(e){return v(this,e=0===e?0:e,e)}}),f&&n(h,"size",{configurable:!0,get:function(){return g(this).size}}),d},setStrong:function(e,t,r){var i=t+" Iterator",n=y(t),s=y(i);u(e,t,function(e,t){m(this,{type:i,target:e,state:n(e),kind:t,last:null})},function(){for(var e=s(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;return e.target&&(e.last=r=r?r.next:e.state.first)?d("keys"===t?r.key:"values"===t?r.value:[r.key,r.value],!1):(e.target=null,d(void 0,!0))},r?"entries":"values",!r,!0),h(t)}}},76569(e,t,r){"use strict";var i=r(3712),n=r(51303),s=r(3787).getWeakData,o=r(10983),a=r(82007),l=r(57157),c=r(70930),u=r(67708),d=r(86045),h=r(47121),f=r(92733),p=f.set,g=f.getterFor,m=d.find,y=d.findIndex,v=i([].splice),b=0,E=function(e){return e.frozen||(e.frozen=new A)},A=function(){this.entries=[]},T=function(e,t){return m(e.entries,function(e){return e[0]===t})};A.prototype={get:function(e){var t=T(this,e);if(t)return t[1]},has:function(e){return!!T(this,e)},set:function(e,t){var r=T(this,e);r?r[1]=t:this.entries.push([e,t])},delete:function(e){var t=y(this.entries,function(t){return t[0]===e});return~t&&v(this.entries,t,1),!!~t}},e.exports={getConstructor:function(e,t,r,i){var d=e(function(e,n){o(e,f),p(e,{type:t,id:b++,frozen:null}),l(n)||u(n,e[i],{that:e,AS_ENTRIES:r})}),f=d.prototype,m=g(t),y=function(e,t,r){var i=m(e),n=s(a(t),!0);return!0===n?E(i).set(t,r):n[i.id]=r,e};return n(f,{delete:function(e){var t=m(this);if(!c(e))return!1;var r=s(e);return!0===r?E(t).delete(e):r&&h(r,t.id)&&delete r[t.id]},has:function(e){var t=m(this);if(!c(e))return!1;var r=s(e);return!0===r?E(t).has(e):r&&h(r,t.id)}}),n(f,r?{get:function(e){var t=m(this);if(c(e)){var r=s(e);if(!0===r)return E(t).get(e);if(r)return r[t.id]}},set:function(e,t){return y(this,e,t)}}:{add:function(e){return y(this,e,!0)}}),d}}},23332(e,t,r){"use strict";var i=r(45286),n=r(98896),s=r(3712),o=r(96812),a=r(13368),l=r(3787),c=r(67708),u=r(10983),d=r(97157),h=r(57157),f=r(70930),p=r(70383),g=r(86076),m=r(7023),y=r(23855);e.exports=function(e,t,r){var v=-1!==e.indexOf("Map"),b=-1!==e.indexOf("Weak"),E=v?"set":"add",A=n[e],T=A&&A.prototype,w=A,S={},k=function(e){var t=s(T[e]);a(T,e,"add"===e?function(e){return t(this,0===e?0:e),this}:"delete"===e?function(e){return!(b&&!f(e))&&t(this,0===e?0:e)}:"get"===e?function(e){return b&&!f(e)?void 0:t(this,0===e?0:e)}:"has"===e?function(e){return!(b&&!f(e))&&t(this,0===e?0:e)}:function(e,r){return t(this,0===e?0:e,r),this})};if(o(e,!d(A)||!(b||T.forEach&&!p(function(){(new A).entries().next()}))))w=r.getConstructor(t,e,v,E),l.enable();else if(o(e,!0)){var L=new w,x=L[E](b?{}:-0,1)!==L,R=p(function(){L.has(1)}),P=g(function(e){new A(e)}),I=!b&&p(function(){for(var e=new A,t=5;t--;)e[E](t,t);return!e.has(-0)});P||((w=t(function(e,t){u(e,T);var r=y(new A,e,w);return h(t)||c(t,r[E],{that:r,AS_ENTRIES:v}),r})).prototype=T,T.constructor=w),(R||I)&&(k("delete"),k("has"),v&&k("get")),(I||x)&&k(E),b&&T.clear&&delete T.clear}return S[e]=w,i({global:!0,constructor:!0,forced:w!==A},S),m(w,e),b||r.setStrong(w,e,v),w}},13884(e,t,r){"use strict";var i=r(47121),n=r(47495),s=r(3059),o=r(94401);e.exports=function(e,t,r){for(var a=n(t),l=o.f,c=s.f,u=0;u"+l+""}},2545(e){"use strict";e.exports=function(e,t){return{value:e,done:t}}},96091(e,t,r){"use strict";var i=r(20092),n=r(94401),s=r(36788);e.exports=i?function(e,t,r){return n.f(e,t,s(1,r))}:function(e,t,r){return e[t]=r,e}},36788(e){"use strict";e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},43648(e,t,r){"use strict";var i=r(20092),n=r(94401),s=r(36788);e.exports=function(e,t,r){i?n.f(e,t,s(0,r)):e[t]=r}},86904(e,t,r){"use strict";var i=r(82007),n=r(25054),s=TypeError;e.exports=function(e){if(i(this),"string"===e||"default"===e)e="string";else if("number"!==e)throw new s("Incorrect hint");return n(this,e)}},27402(e,t,r){"use strict";var i=r(9659),n=r(94401);e.exports=function(e,t,r){return r.get&&i(r.get,t,{getter:!0}),r.set&&i(r.set,t,{setter:!0}),n.f(e,t,r)}},13368(e,t,r){"use strict";var i=r(97157),n=r(94401),s=r(9659),o=r(58905);e.exports=function(e,t,r,a){a||(a={});var l=a.enumerable,c=void 0!==a.name?a.name:t;if(i(r)&&s(r,c,a),a.global)l?e[t]=r:o(t,r);else{try{a.unsafe?e[t]&&(l=!0):delete e[t]}catch(e){}l?e[t]=r:n.f(e,t,{value:r,enumerable:!1,configurable:!a.nonConfigurable,writable:!a.nonWritable})}return e}},51303(e,t,r){"use strict";var i=r(13368);e.exports=function(e,t,r){for(var n in t)i(e,n,t[n],r);return e}},58905(e,t,r){"use strict";var i=r(98896),n=Object.defineProperty;e.exports=function(e,t){try{n(i,e,{value:t,configurable:!0,writable:!0})}catch(r){i[e]=t}return t}},85646(e,t,r){"use strict";var i=r(93447),n=TypeError;e.exports=function(e,t){if(!delete e[t])throw new n("Cannot delete property "+i(t)+" of "+i(e))}},20092(e,t,r){"use strict";var i=r(70383);e.exports=!i(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})},59047(e,t,r){"use strict";var i=r(98896),n=r(70930),s=i.document,o=n(s)&&n(s.createElement);e.exports=function(e){return o?s.createElement(e):{}}},24213(e){"use strict";var t=TypeError;e.exports=function(e){if(e>9007199254740991)throw t("Maximum allowed index exceeded");return e}},67448(e){"use strict";e.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},91760(e,t,r){"use strict";var i=r(59047)("span").classList,n=i&&i.constructor&&i.constructor.prototype;e.exports=n===Object.prototype?void 0:n},66631(e){"use strict";e.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},87165(e,t,r){"use strict";var i=r(99943).match(/firefox\/(\d+)/i);e.exports=!!i&&+i[1]},14675(e,t,r){"use strict";var i=r(99943);e.exports=/MSIE|Trident/.test(i)},66009(e,t,r){"use strict";var i=r(99943);e.exports=/ipad|iphone|ipod/i.test(i)&&"undefined"!=typeof Pebble},98040(e,t,r){"use strict";var i=r(99943);e.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(i)},75313(e,t,r){"use strict";var i=r(45511);e.exports="NODE"===i},24900(e,t,r){"use strict";var i=r(99943);e.exports=/web0s(?!.*chrome)/i.test(i)},99943(e,t,r){"use strict";var i=r(98896).navigator,n=i&&i.userAgent;e.exports=n?String(n):""},54863(e,t,r){"use strict";var i,n,s=r(98896),o=r(99943),a=s.process,l=s.Deno,c=a&&a.versions||l&&l.version,u=c&&c.v8;u&&(n=(i=u.split("."))[0]>0&&i[0]<4?1:+(i[0]+i[1])),!n&&o&&(!(i=o.match(/Edge\/(\d+)/))||i[1]>=74)&&(i=o.match(/Chrome\/(\d+)/))&&(n=+i[1]),e.exports=n},15047(e,t,r){"use strict";var i=r(99943).match(/AppleWebKit\/(\d+)\./);e.exports=!!i&&+i[1]},45511(e,t,r){"use strict";var i=r(98896),n=r(99943),s=r(55792),o=function(e){return n.slice(0,e.length)===e};e.exports=o("Bun/")?"BUN":o("Cloudflare-Workers")?"CLOUDFLARE":o("Deno/")?"DENO":o("Node.js/")?"NODE":i.Bun&&"string"==typeof Bun.version?"BUN":i.Deno&&"object"==typeof Deno.version?"DENO":"process"===s(i.process)?"NODE":i.window&&i.document?"BROWSER":"REST"},45286(e,t,r){"use strict";var i=r(98896),n=r(3059).f,s=r(96091),o=r(13368),a=r(58905),l=r(13884),c=r(96812);e.exports=function(e,t){var r,u,d,h,f,p=e.target,g=e.global,m=e.stat;if(r=g?i:m?i[p]||a(p,{}):i[p]&&i[p].prototype)for(u in t){if(h=t[u],d=e.dontCallGetSet?(f=n(r,u))&&f.value:r[u],!c(g?u:p+(m?".":"#")+u,e.forced)&&void 0!==d){if(typeof h==typeof d)continue;l(h,d)}(e.sham||d&&d.sham)&&s(h,"sham",!0),o(r,u,h,e)}}},70383(e){"use strict";e.exports=function(e){try{return!!e()}catch(e){return!0}}},13084(e,t,r){"use strict";r(94391);var i=r(91661),n=r(13368),s=r(53435),o=r(70383),a=r(56547),l=r(96091),c=a("species"),u=RegExp.prototype;e.exports=function(e,t,r,d){var h=a(e),f=!o(function(){var t={};return t[h]=function(){return 7},7!==""[e](t)}),p=f&&!o(function(){var t=!1,r=/a/;if("split"===e){var i={};i[c]=function(){return r},(r={constructor:i,flags:""})[h]=/./[h]}return r.exec=function(){return t=!0,null},r[h](""),!t});if(!f||!p||r){var g=/./[h],m=t(h,""[e],function(e,t,r,n,o){var a=t.exec;return a===s||a===u.exec?f&&!o?{done:!0,value:i(g,t,r,n)}:{done:!0,value:i(e,r,t,n)}:{done:!1}});n(String.prototype,e,m[0]),n(u,h,m[1])}d&&l(u[h],"sham",!0)}},76099(e,t,r){"use strict";var i=r(48600),n=r(39942),s=r(24213),o=r(81024),a=r(43648),l=function(e,t,r,c,u,d,h,f){for(var p,g,m=u,y=0,v=!!h&&o(h,f);y0&&i(p)?(g=n(p),m=l(e,t,p,g,m,d-1)-1):(s(m+1),a(e,m,p)),m++),y++;return m};e.exports=l},78552(e,t,r){"use strict";var i=r(70383);e.exports=!i(function(){return Object.isExtensible(Object.preventExtensions({}))})},97321(e,t,r){"use strict";var i=r(11896),n=Function.prototype,s=n.apply,o=n.call;e.exports="object"==typeof Reflect&&Reflect.apply||(i?o.bind(s):function(){return o.apply(s,arguments)})},81024(e,t,r){"use strict";var i=r(89412),n=r(18522),s=r(11896),o=i(i.bind);e.exports=function(e,t){return n(e),void 0===t?e:s?o(e,t):function(){return e.apply(t,arguments)}}},11896(e,t,r){"use strict";var i=r(70383);e.exports=!i(function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})},42038(e,t,r){"use strict";var i=r(3712),n=r(18522),s=r(70930),o=r(47121),a=r(96496),l=r(11896),c=Function,u=i([].concat),d=i([].join),h={};e.exports=l?c.bind:function(e){var t=n(this),r=t.prototype,i=a(arguments,1),l=function(){var r=u(i,a(arguments));return this instanceof l?function(e,t,r){if(!o(h,t)){for(var i=[],n=0;n]*>)/g,u=/\$([$&'`]|\d{1,2})/g;e.exports=function(e,t,r,i,d,h){var f=r+e.length,p=i.length,g=u;return void 0!==d&&(d=n(d),g=c),a(h,g,function(n,a){var c;switch(o(a,0)){case"$":return"$";case"&":return e;case"`":return l(t,0,r);case"'":return l(t,f);case"<":c=d[l(a,1,-1)];break;default:var u=+a;if(0===u)return n;if(u>p){var h=s(u/10);return 0===h?n:h<=p?void 0===i[h-1]?o(a,1):i[h-1]+o(a,1):n}c=i[u-1]}return void 0===c?"":c})}},98896(e){"use strict";var t=function(e){return e&&e.Math===Math&&e};e.exports=t("object"==typeof globalThis&&globalThis)||t("object"==typeof window&&window)||t("object"==typeof self&&self)||t("object"==typeof globalThis&&globalThis)||t("object"==typeof this&&this)||function(){return this}()||Function("return this")()},47121(e,t,r){"use strict";var i=r(3712),n=r(50437),s=i({}.hasOwnProperty);e.exports=Object.hasOwn||function(e,t){return s(n(e),t)}},30885(e){"use strict";e.exports={}},3669(e){"use strict";e.exports=function(e,t){try{1===arguments.length?console.error(e):console.error(e,t)}catch(e){}}},7293(e,t,r){"use strict";var i=r(97671);e.exports=i("document","documentElement")},1821(e,t,r){"use strict";var i=r(20092),n=r(70383),s=r(59047);e.exports=!i&&!n(function(){return 7!==Object.defineProperty(s("div"),"a",{get:function(){return 7}}).a})},90554(e){"use strict";var t=Array,r=Math.abs,i=Math.pow,n=Math.floor,s=Math.log,o=Math.LN2;e.exports={pack:function(e,a,l){var c,u,d,h=t(l),f=8*l-a-1,p=(1<>1,m=23===a?i(2,-24)-i(2,-77):0,y=e<0||0===e&&1/e<0?1:0,v=0;for((e=r(e))!=e||e===1/0?(u=e!=e?1:0,c=p):(c=n(s(e)/o),e*(d=i(2,-c))<1&&(c--,d*=2),(e+=c+g>=1?m/d:m*i(2,1-g))*d>=2&&(c++,d/=2),c+g>=p?(u=0,c=p):c+g>=1?(u=(e*d-1)*i(2,a),c+=g):(u=e*i(2,g-1)*i(2,a),c=0));a>=8;)h[v++]=255&u,u/=256,a-=8;for(c=c<0;)h[v++]=255&c,c/=256,f-=8;return h[v-1]|=128*y,h},unpack:function(e,t){var r,n=e.length,s=8*n-t-1,o=(1<>1,l=s-7,c=n-1,u=e[c--],d=127&u;for(u>>=7;l>0;)d=256*d+e[c--],l-=8;for(r=d&(1<<-l)-1,d>>=-l,l+=t;l>0;)r=256*r+e[c--],l-=8;if(0===d)d=1-a;else{if(d===o)return r?NaN:u?-1/0:1/0;r+=i(2,t),d-=a}return(u?-1:1)*r*i(2,d-t)}}},33151(e,t,r){"use strict";var i=r(3712),n=r(70383),s=r(55792),o=Object,a=i("".split);e.exports=n(function(){return!o("z").propertyIsEnumerable(0)})?function(e){return"String"===s(e)?a(e,""):o(e)}:o},23855(e,t,r){"use strict";var i=r(97157),n=r(70930),s=r(45047);e.exports=function(e,t,r){var o,a;return s&&i(o=t.constructor)&&o!==r&&n(a=o.prototype)&&a!==r.prototype&&s(e,a),e}},60026(e,t,r){"use strict";var i=r(3712),n=r(97157),s=r(31853),o=i(Function.toString);n(s.inspectSource)||(s.inspectSource=function(e){return o(e)}),e.exports=s.inspectSource},3787(e,t,r){"use strict";var i=r(45286),n=r(3712),s=r(30885),o=r(70930),a=r(47121),l=r(94401).f,c=r(28064),u=r(92650),d=r(52348),h=r(59008),f=r(78552),p=!1,g=h("meta"),m=0,y=function(e){l(e,g,{value:{objectID:"O"+m++,weakData:{}}})},v=e.exports={enable:function(){v.enable=function(){},p=!0;var e=c.f,t=n([].splice),r={};r[g]=1,e(r).length&&(c.f=function(r){for(var i=e(r),n=0,s=i.length;nv;v++)if((E=I(e[v]))&&c(g,E))return E;return new p(!1)}m=u(e,y)}for(A=k?e.next:m.next;!(T=n(A,m)).done;){try{E=I(T.value)}catch(e){h(m,"throw",e)}if("object"==typeof E&&E&&c(g,E))return E}return new p(!1)}},69491(e,t,r){"use strict";var i=r(91661),n=r(82007),s=r(1806);e.exports=function(e,t,r){var o,a;n(e);try{if(!(o=s(e,"return"))){if("throw"===t)throw r;return r}o=i(o,e)}catch(e){a=!0,o=e}if("throw"===t)throw r;if(a)throw o;return n(o),r}},65626(e,t,r){"use strict";var i=r(66889).IteratorPrototype,n=r(65416),s=r(36788),o=r(7023),a=r(35149),l=function(){return this};e.exports=function(e,t,r,c){var u=t+" Iterator";return e.prototype=n(i,{next:s(+!c,r)}),o(e,u,!1,!0),a[u]=l,e}},36e3(e,t,r){"use strict";var i=r(45286),n=r(91661),s=r(20027),o=r(7934),a=r(97157),l=r(65626),c=r(22995),u=r(45047),d=r(7023),h=r(96091),f=r(13368),p=r(56547),g=r(35149),m=r(66889),y=o.PROPER,v=o.CONFIGURABLE,b=m.IteratorPrototype,E=m.BUGGY_SAFARI_ITERATORS,A=p("iterator"),T="keys",w="values",S="entries",k=function(){return this};e.exports=function(e,t,r,o,p,m,L){l(r,t,o);var x,R,P,I=function(e){if(e===p&&M)return M;if(!E&&e&&e in O)return O[e];switch(e){case T:case w:case S:return function(){return new r(this,e)}}return function(){return new r(this)}},C=t+" Iterator",_=!1,O=e.prototype,D=O[A]||O["@@iterator"]||p&&O[p],M=!E&&D||I(p),N="Array"===t&&O.entries||D;if(N&&(x=c(N.call(new e)))!==Object.prototype&&x.next&&(s||c(x)===b||(u?u(x,b):a(x[A])||f(x,A,k)),d(x,C,!0,!0),s&&(g[C]=k)),y&&p===w&&D&&D.name!==w&&(!s&&v?h(O,"name",w):(_=!0,M=function(){return n(D,this)})),p)if(R={values:I(w),keys:m?M:I(T),entries:I(S)},L)for(P in R)(E||_||!(P in O))&&f(O,P,R[P]);else i({target:t,proto:!0,forced:E||_},R);return s&&!L||O[A]===M||f(O,A,M,{name:p}),g[t]=M,R}},66889(e,t,r){"use strict";var i,n,s,o=r(70383),a=r(97157),l=r(70930),c=r(65416),u=r(22995),d=r(13368),h=r(56547),f=r(20027),p=h("iterator"),g=!1;[].keys&&("next"in(s=[].keys())?(n=u(u(s)))!==Object.prototype&&(i=n):g=!0),!l(i)||o(function(){var e={};return i[p].call(e)!==e})?i={}:f&&(i=c(i)),a(i[p])||d(i,p,function(){return this}),e.exports={IteratorPrototype:i,BUGGY_SAFARI_ITERATORS:g}},35149(e){"use strict";e.exports={}},39942(e,t,r){"use strict";var i=r(47214);e.exports=function(e){return i(e.length)}},9659(e,t,r){"use strict";var i=r(3712),n=r(70383),s=r(97157),o=r(47121),a=r(20092),l=r(7934).CONFIGURABLE,c=r(60026),u=r(92733),d=u.enforce,h=u.get,f=String,p=Object.defineProperty,g=i("".slice),m=i("".replace),y=i([].join),v=a&&!n(function(){return 8!==p(function(){},"length",{value:8}).length}),b=String(String).split("String"),E=e.exports=function(e,t,r){"Symbol("===g(f(t),0,7)&&(t="["+m(f(t),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!o(e,"name")||l&&e.name!==t)&&(a?p(e,"name",{value:t,configurable:!0}):e.name=t),v&&r&&o(r,"arity")&&e.length!==r.arity&&p(e,"length",{value:r.arity});try{r&&o(r,"constructor")&&r.constructor?a&&p(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var i=d(e);return o(i,"source")||(i.source=y(b,"string"==typeof t?t:"")),e};Function.prototype.toString=E(function(){return s(this)&&h(this).source||c(this)},"toString")},83282(e){"use strict";var t=Math.expm1,r=Math.exp;e.exports=!t||t(10)>22025.465794806718||t(10)<22025.465794806718||-2e-17!==t(-2e-17)?function(e){var t=+e;return 0===t?t:t>-1e-6&&t<1e-6?t+t*t/2:r(t)-1}:t},61852(e,t,r){"use strict";var i=r(94502),n=r(1362),s=Math.abs;e.exports=function(e,t,r,o){var a=+e,l=s(a),c=i(a);if(lr||d!=d?c*(1/0):c*d}},46449(e,t,r){"use strict";var i=r(61852);e.exports=Math.fround||function(e){return i(e,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)}},95660(e){"use strict";var t=Math.log,r=Math.LOG10E;e.exports=Math.log10||function(e){return t(e)*r}},37260(e){"use strict";var t=Math.log;e.exports=Math.log1p||function(e){var r=+e;return r>-1e-8&&r<1e-8?r-r*r/2:t(1+r)}},61595(e){"use strict";var t=Math.log,r=Math.LN2;e.exports=Math.log2||function(e){return t(e)/r}},1362(e){"use strict";var t=4503599627370496;e.exports=function(e){return e+t-t}},94502(e){"use strict";e.exports=Math.sign||function(e){var t=+e;return 0===t||t!=t?t:t<0?-1:1}},17749(e){"use strict";var t=Math.ceil,r=Math.floor;e.exports=Math.trunc||function(e){var i=+e;return(i>0?r:t)(i)}},69251(e,t,r){"use strict";var i,n,s,o,a,l=r(98896),c=r(9981),u=r(81024),d=r(4201).set,h=r(70313),f=r(98040),p=r(66009),g=r(24900),m=r(75313),y=l.MutationObserver||l.WebKitMutationObserver,v=l.document,b=l.process,E=l.Promise,A=c("queueMicrotask");if(!A){var T=new h,w=function(){var e,t;for(m&&(e=b.domain)&&e.exit();t=T.get();)try{t()}catch(e){throw T.head&&i(),e}e&&e.enter()};f||m||g||!y||!v?!p&&E&&E.resolve?((o=E.resolve(void 0)).constructor=E,a=u(o.then,o),i=function(){a(w)}):m?i=function(){b.nextTick(w)}:(d=u(d,l),i=function(){d(w)}):(n=!0,s=v.createTextNode(""),new y(w).observe(s,{characterData:!0}),i=function(){s.data=n=!n}),A=function(e){T.head||i(),T.add(e)}}e.exports=A},99547(e,t,r){"use strict";var i=r(70383);e.exports=!i(function(){var e="9007199254740993",t=JSON.rawJSON(e);return!JSON.isRawJSON(t)||JSON.stringify(t)!==e})},63419(e,t,r){"use strict";var i=r(18522),n=TypeError,s=function(e){var t,r;this.promise=new e(function(e,i){if(void 0!==t||void 0!==r)throw new n("Bad Promise constructor");t=e,r=i}),this.resolve=i(t),this.reject=i(r)};e.exports.f=function(e){return new s(e)}},31151(e,t,r){"use strict";var i=r(75364),n=TypeError;e.exports=function(e){if(i(e))throw new n("The method doesn't accept regular expressions");return e}},18248(e,t,r){"use strict";var i=r(98896).isFinite;e.exports=Number.isFinite||function(e){return"number"==typeof e&&i(e)}},49632(e,t,r){"use strict";var i=r(98896),n=r(70383),s=r(3712),o=r(55135),a=r(92810).trim,l=r(45132),c=s("".charAt),u=i.parseFloat,d=i.Symbol,h=d&&d.iterator,f=1/u(l+"-0")!=-1/0||h&&!n(function(){u(Object(h))});e.exports=f?function(e){var t=a(o(e)),r=u(t);return 0===r&&"-"===c(t,0)?-0:r}:u},81903(e,t,r){"use strict";var i=r(98896),n=r(70383),s=r(3712),o=r(55135),a=r(92810).trim,l=r(45132),c=i.parseInt,u=i.Symbol,d=u&&u.iterator,h=/^[+-]?0x/i,f=s(h.exec),p=8!==c(l+"08")||22!==c(l+"0x16")||d&&!n(function(){c(Object(d))});e.exports=p?function(e,t){var r=a(o(e));return c(r,t>>>0||(f(h,r)?16:10))}:c},28901(e,t,r){"use strict";var i=r(20092),n=r(3712),s=r(91661),o=r(70383),a=r(30320),l=r(14309),c=r(89269),u=r(50437),d=r(33151),h=Object.assign,f=Object.defineProperty,p=n([].concat);e.exports=!h||o(function(){if(i&&1!==h({b:1},h(f({},"a",{enumerable:!0,get:function(){f(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},r=Symbol("assign detection"),n="abcdefghijklmnopqrst";return e[r]=7,n.split("").forEach(function(e){t[e]=e}),7!==h({},e)[r]||a(h({},t)).join("")!==n})?function(e,t){for(var r=u(e),n=arguments.length,o=1,h=l.f,f=c.f;n>o;)for(var g,m=d(arguments[o++]),y=h?p(a(m),h(m)):a(m),v=y.length,b=0;v>b;)g=y[b++],i&&!s(f,m,g)||(r[g]=m[g]);return r}:h},65416(e,t,r){"use strict";var i,n=r(82007),s=r(46673),o=r(66631),a=r(30885),l=r(7293),c=r(59047),u=r(8183),d="prototype",h="script",f=u("IE_PROTO"),p=function(){},g=function(e){return"<"+h+">"+e+""},m=function(e){e.write(g("")),e.close();var t=e.parentWindow.Object;return e=null,t},y=function(){try{i=new ActiveXObject("htmlfile")}catch(e){}var e,t,r;y="undefined"!=typeof document?document.domain&&i?m(i):(t=c("iframe"),r="java"+h+":",t.style.display="none",l.appendChild(t),t.src=String(r),(e=t.contentWindow.document).open(),e.write(g("document.F=Object")),e.close(),e.F):m(i);for(var n=o.length;n--;)delete y[d][o[n]];return y()};a[f]=!0,e.exports=Object.create||function(e,t){var r;return null!==e?(p[d]=n(e),r=new p,p[d]=null,r[f]=e):r=y(),void 0===t?r:s.f(r,t)}},46673(e,t,r){"use strict";var i=r(20092),n=r(44350),s=r(94401),o=r(82007),a=r(65317),l=r(30320);t.f=i&&!n?Object.defineProperties:function(e,t){o(e);for(var r,i=a(t),n=l(t),c=n.length,u=0;c>u;)s.f(e,r=n[u++],i[r]);return e}},94401(e,t,r){"use strict";var i=r(20092),n=r(1821),s=r(44350),o=r(82007),a=r(93881),l=TypeError,c=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d="enumerable",h="configurable",f="writable";t.f=i?s?function(e,t,r){if(o(e),t=a(t),o(r),"function"==typeof e&&"prototype"===t&&"value"in r&&f in r&&!r[f]){var i=u(e,t);i&&i[f]&&(e[t]=r.value,r={configurable:h in r?r[h]:i[h],enumerable:d in r?r[d]:i[d],writable:!1})}return c(e,t,r)}:c:function(e,t,r){if(o(e),t=a(t),o(r),n)try{return c(e,t,r)}catch(e){}if("get"in r||"set"in r)throw new l("Accessors not supported");return"value"in r&&(e[t]=r.value),e}},3059(e,t,r){"use strict";var i=r(20092),n=r(91661),s=r(89269),o=r(36788),a=r(65317),l=r(93881),c=r(47121),u=r(1821),d=Object.getOwnPropertyDescriptor;t.f=i?d:function(e,t){if(e=a(e),t=l(t),u)try{return d(e,t)}catch(e){}if(c(e,t))return o(!n(s.f,e,t),e[t])}},92650(e,t,r){"use strict";var i=r(55792),n=r(65317),s=r(28064).f,o=r(96496),a="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];e.exports.f=function(e){return a&&"Window"===i(e)?function(e){try{return s(e)}catch(e){return o(a)}}(e):s(n(e))}},28064(e,t,r){"use strict";var i=r(35764),n=r(66631).concat("length","prototype");t.f=Object.getOwnPropertyNames||function(e){return i(e,n)}},14309(e,t){"use strict";t.f=Object.getOwnPropertySymbols},22995(e,t,r){"use strict";var i=r(47121),n=r(97157),s=r(50437),o=r(8183),a=r(45347),l=o("IE_PROTO"),c=Object,u=c.prototype;e.exports=a?c.getPrototypeOf:function(e){var t=s(e);if(i(t,l))return t[l];var r=t.constructor;return n(r)&&t instanceof r?r.prototype:t instanceof c?u:null}},52348(e,t,r){"use strict";var i=r(70383),n=r(70930),s=r(55792),o=r(28308),a=Object.isExtensible,l=i(function(){a(1)});e.exports=l||o?function(e){return!!n(e)&&(!o||"ArrayBuffer"!==s(e))&&(!a||a(e))}:a},95881(e,t,r){"use strict";var i=r(3712);e.exports=i({}.isPrototypeOf)},35764(e,t,r){"use strict";var i=r(3712),n=r(47121),s=r(65317),o=r(69457).indexOf,a=r(30885),l=i([].push);e.exports=function(e,t){var r,i=s(e),c=0,u=[];for(r in i)!n(a,r)&&n(i,r)&&l(u,r);for(;t.length>c;)n(i,r=t[c++])&&(~o(u,r)||l(u,r));return u}},30320(e,t,r){"use strict";var i=r(35764),n=r(66631);e.exports=Object.keys||function(e){return i(e,n)}},89269(e,t){"use strict";var r={}.propertyIsEnumerable,i=Object.getOwnPropertyDescriptor,n=i&&!r.call({1:2},1);t.f=n?function(e){var t=i(this,e);return!!t&&t.enumerable}:r},64039(e,t,r){"use strict";var i=r(20027),n=r(98896),s=r(70383),o=r(15047);e.exports=i||!s(function(){if(!(o&&o<535)){var e=Math.random();__defineSetter__.call(null,e,function(){}),delete n[e]}})},45047(e,t,r){"use strict";var i=r(51554),n=r(70930),s=r(20118),o=r(49362);e.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=i(Object.prototype,"__proto__","set"))(r,[]),t=r instanceof Array}catch(e){}return function(r,i){return s(r),o(i),n(r)?(t?e(r,i):r.__proto__=i,r):r}}():void 0)},1429(e,t,r){"use strict";var i=r(20092),n=r(70383),s=r(3712),o=r(22995),a=r(30320),l=r(65317),c=s(r(89269).f),u=s([].push),d=i&&n(function(){var e=Object.create(null);return e[2]=2,!c(e,2)}),h=function(e){return function(t){for(var r,n=l(t),s=a(n),h=d&&null===o(n),f=s.length,p=0,g=[];f>p;)r=s[p++],i&&!(h?r in n:c(n,r))||u(g,e?[r,n[r]]:n[r]);return g}};e.exports={entries:h(!0),values:h(!1)}},96651(e,t,r){"use strict";var i=r(27964),n=r(98731);e.exports=i?{}.toString:function(){return"[object "+n(this)+"]"}},25054(e,t,r){"use strict";var i=r(91661),n=r(97157),s=r(70930),o=TypeError;e.exports=function(e,t){var r,a;if("string"===t&&n(r=e.toString)&&!s(a=i(r,e)))return a;if(n(r=e.valueOf)&&!s(a=i(r,e)))return a;if("string"!==t&&n(r=e.toString)&&!s(a=i(r,e)))return a;throw new o("Can't convert object to primitive value")}},47495(e,t,r){"use strict";var i=r(97671),n=r(3712),s=r(28064),o=r(14309),a=r(82007),l=n([].concat);e.exports=i("Reflect","ownKeys")||function(e){var t=s.f(a(e)),r=o.f;return r?l(t,r(e)):t}},23480(e,t,r){"use strict";var i=r(3712),n=r(47121),s=SyntaxError,o=parseInt,a=String.fromCharCode,l=i("".charAt),c=i("".slice),u=i(/./.exec),d={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":"\n","\\r":"\r","\\t":"\t"},h=/^[\da-f]{4}$/i,f=/^[\u0000-\u001F]$/;e.exports=function(e,t){for(var r=!0,i="";t0&&(!f.multiline||f.multiline&&"\n"!==v(k,f.lastIndex-1))&&(I="(?: "+I+")",_=" "+_,C++),r=new RegExp("^(?:"+I+")",P)),S&&(r=new RegExp("^"+I+"$(?!\\s)",P)),T&&(i=f.lastIndex),n=s(m,R?r:f,_),R?n?(n.input=A(n.input,C),n[0]=A(n[0],C),n.index=f.lastIndex,f.lastIndex+=n[0].length):f.lastIndex=0:T&&n&&(f.lastIndex=f.global?n.index+n[0].length:i),S&&n&&n.length>1&&s(g,n[0],r,function(){for(o=1;ob)","g");return"b"!==e.exec("b").groups.a||"bc"!=="b".replace(e,"$c")})},20118(e,t,r){"use strict";var i=r(57157),n=TypeError;e.exports=function(e){if(i(e))throw new n("Can't call method on "+e);return e}},9981(e,t,r){"use strict";var i=r(98896),n=r(20092),s=Object.getOwnPropertyDescriptor;e.exports=function(e){if(!n)return i[e];var t=s(i,e);return t&&t.value}},70462(e){"use strict";e.exports=Object.is||function(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}},19552(e,t,r){"use strict";var i,n=r(98896),s=r(97321),o=r(97157),a=r(45511),l=r(99943),c=r(96496),u=r(32076),d=n.Function,h=/MSIE .\./.test(l)||"BUN"===a&&((i=n.Bun.version.split(".")).length<3||"0"===i[0]&&(i[1]<3||"3"===i[1]&&"0"===i[2]));e.exports=function(e,t){var r=t?2:1;return h?function(i,n){var a=u(arguments.length,1)>r,l=o(i)?i:d(i),h=a?c(arguments,r):[],f=a?function(){s(l,this,h)}:l;return t?e(f,n):e(f)}:e}},28833(e,t,r){"use strict";var i=r(97671),n=r(27402),s=r(56547),o=r(20092),a=s("species");e.exports=function(e){var t=i(e);o&&t&&!t[a]&&n(t,a,{configurable:!0,get:function(){return this}})}},7023(e,t,r){"use strict";var i=r(94401).f,n=r(47121),s=r(56547)("toStringTag");e.exports=function(e,t,r){e&&!r&&(e=e.prototype),e&&!n(e,s)&&i(e,s,{configurable:!0,value:t})}},8183(e,t,r){"use strict";var i=r(4961),n=r(59008),s=i("keys");e.exports=function(e){return s[e]||(s[e]=n(e))}},31853(e,t,r){"use strict";var i=r(20027),n=r(98896),s=r(58905),o="__core-js_shared__",a=e.exports=n[o]||s(o,{});(a.versions||(a.versions=[])).push({version:"3.48.0",mode:i?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.48.0/LICENSE",source:"https://github.com/zloirock/core-js"})},4961(e,t,r){"use strict";var i=r(31853);e.exports=function(e,t){return i[e]||(i[e]=t||{})}},63749(e,t,r){"use strict";var i=r(82007),n=r(34412),s=r(57157),o=r(56547)("species");e.exports=function(e,t){var r,a=i(e).constructor;return void 0===a||s(r=i(a)[o])?t:n(r)}},76869(e,t,r){"use strict";var i=r(70383);e.exports=function(e){return i(function(){var t=""[e]('"');return t!==t.toLowerCase()||t.split('"').length>3})}},54087(e,t,r){"use strict";var i=r(3712),n=r(45707),s=r(55135),o=r(20118),a=i("".charAt),l=i("".charCodeAt),c=i("".slice),u=function(e){return function(t,r){var i,u,d=s(o(t)),h=n(r),f=d.length;return h<0||h>=f?e?"":void 0:(i=l(d,h))<55296||i>56319||h+1===f||(u=l(d,h+1))<56320||u>57343?e?a(d,h):i:e?c(d,h,h+2):u-56320+(i-55296<<10)+65536}};e.exports={codeAt:u(!1),charAt:u(!0)}},1799(e,t,r){"use strict";var i=r(99943);e.exports=/Version\/10(?:\.\d+){1,2}(?: [\w./]+)?(?: Mobile\/\w+)? Safari\//.test(i)},10341(e,t,r){"use strict";var i=r(3712),n=r(47214),s=r(55135),o=r(79485),a=r(20118),l=i(o),c=i("".slice),u=Math.ceil,d=function(e){return function(t,r,i){var o,d,h=s(a(t)),f=n(r),p=h.length,g=void 0===i?" ":s(i);return f<=p||""===g?h:((d=l(g,u((o=f-p)/g.length))).length>o&&(d=c(d,0,o)),e?h+d:d+h)}};e.exports={start:d(!1),end:d(!0)}},71605(e,t,r){"use strict";var i=r(3712),n=2147483647,s=/[^\0-\u007E]/,o=/[.\u3002\uFF0E\uFF61]/g,a="Overflow: input needs wider integers to process",l=RangeError,c=i(o.exec),u=Math.floor,d=String.fromCharCode,h=i("".charCodeAt),f=i([].join),p=i([].push),g=i("".replace),m=i("".split),y=i("".toLowerCase),v=function(e){return e+22+75*(e<26)},b=function(e,t,r){var i=0;for(e=r?u(e/700):e>>1,e+=u(e/t);e>455;)e=u(e/35),i+=36;return u(i+36*e/(e+38))},E=function(e){var t=[];e=function(e){for(var t=[],r=0,i=e.length;r=55296&&n<=56319&&r=o&&iu((n-c)/A))throw new l(a);for(c+=(E-o)*A,o=E,r=0;rn)throw new l(a);if(i===o){for(var T=c,w=36;;){var S=w<=g?1:w>=g+26?26:w-g;if(T0;(a>>>=1)&&(t+=t))1&a&&(r+=t);return r}},95298(e,t,r){"use strict";var i=r(92810).end,n=r(70866);e.exports=n("trimEnd")?function(){return i(this)}:"".trimEnd},70866(e,t,r){"use strict";var i=r(7934).PROPER,n=r(70383),s=r(45132);e.exports=function(e){return n(function(){return!!s[e]()||"​…᠎"!=="​…᠎"[e]()||i&&s[e].name!==e})}},56223(e,t,r){"use strict";var i=r(92810).start,n=r(70866);e.exports=n("trimStart")?function(){return i(this)}:"".trimStart},92810(e,t,r){"use strict";var i=r(3712),n=r(20118),s=r(55135),o=r(45132),a=i("".replace),l=RegExp("^["+o+"]+"),c=RegExp("(^|[^"+o+"])["+o+"]+$"),u=function(e){return function(t){var r=s(n(t));return 1&e&&(r=a(r,l,"")),2&e&&(r=a(r,c,"$1")),r}};e.exports={start:u(1),end:u(2),trim:u(3)}},10719(e,t,r){"use strict";var i=r(54863),n=r(70383),s=r(98896).String;e.exports=!!Object.getOwnPropertySymbols&&!n(function(){var e=Symbol("symbol detection");return!s(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&i&&i<41})},3634(e,t,r){"use strict";var i=r(91661),n=r(97671),s=r(56547),o=r(13368);e.exports=function(){var e=n("Symbol"),t=e&&e.prototype,r=t&&t.valueOf,a=s("toPrimitive");t&&!t[a]&&o(t,a,function(e){return i(r,this)},{arity:1})}},24336(e,t,r){"use strict";var i=r(10719);e.exports=i&&!!Symbol.for&&!!Symbol.keyFor},4201(e,t,r){"use strict";var i,n,s,o,a=r(98896),l=r(97321),c=r(81024),u=r(97157),d=r(47121),h=r(70383),f=r(7293),p=r(96496),g=r(59047),m=r(32076),y=r(98040),v=r(75313),b=a.setImmediate,E=a.clearImmediate,A=a.process,T=a.Dispatch,w=a.Function,S=a.MessageChannel,k=a.String,L=0,x={},R="onreadystatechange";h(function(){i=a.location});var P=function(e){if(d(x,e)){var t=x[e];delete x[e],t()}},I=function(e){return function(){P(e)}},C=function(e){P(e.data)},_=function(e){a.postMessage(k(e),i.protocol+"//"+i.host)};b&&E||(b=function(e){m(arguments.length,1);var t=u(e)?e:w(e),r=p(arguments,1);return x[++L]=function(){l(t,void 0,r)},n(L),L},E=function(e){delete x[e]},v?n=function(e){A.nextTick(I(e))}:T&&T.now?n=function(e){T.now(I(e))}:S&&!y?(o=(s=new S).port2,s.port1.onmessage=C,n=c(o.postMessage,o)):a.addEventListener&&u(a.postMessage)&&!a.importScripts&&i&&"file:"!==i.protocol&&!h(_)?(n=_,a.addEventListener("message",C,!1)):n=R in g("script")?function(e){f.appendChild(g("script"))[R]=function(){f.removeChild(this),P(e)}}:function(e){setTimeout(I(e),0)}),e.exports={set:b,clear:E}},18680(e,t,r){"use strict";var i=r(3712);e.exports=i(1.1.valueOf)},8810(e,t,r){"use strict";var i=r(45707),n=Math.max,s=Math.min;e.exports=function(e,t){var r=i(e);return r<0?n(r+t,0):s(r,t)}},9918(e,t,r){"use strict";var i=r(66841),n=TypeError;e.exports=function(e){var t=i(e,"number");if("number"==typeof t)throw new n("Can't convert number to bigint");return BigInt(t)}},58640(e,t,r){"use strict";var i=r(45707),n=r(47214),s=RangeError;e.exports=function(e){if(void 0===e)return 0;var t=i(e),r=n(t);if(t!==r)throw new s("Wrong length or index");return r}},65317(e,t,r){"use strict";var i=r(33151),n=r(20118);e.exports=function(e){return i(n(e))}},45707(e,t,r){"use strict";var i=r(17749);e.exports=function(e){var t=+e;return t!=t||0===t?0:i(t)}},47214(e,t,r){"use strict";var i=r(45707),n=Math.min;e.exports=function(e){var t=i(e);return t>0?n(t,9007199254740991):0}},50437(e,t,r){"use strict";var i=r(20118),n=Object;e.exports=function(e){return n(i(e))}},40997(e,t,r){"use strict";var i=r(35158),n=RangeError;e.exports=function(e,t){var r=i(e);if(r%t)throw new n("Wrong offset");return r}},35158(e,t,r){"use strict";var i=r(45707),n=RangeError;e.exports=function(e){var t=i(e);if(t<0)throw new n("The argument can't be less than 0");return t}},66841(e,t,r){"use strict";var i=r(91661),n=r(70930),s=r(54709),o=r(1806),a=r(25054),l=r(56547),c=TypeError,u=l("toPrimitive");e.exports=function(e,t){if(!n(e)||s(e))return e;var r,l=o(e,u);if(l){if(void 0===t&&(t="default"),r=i(l,e,t),!n(r)||s(r))return r;throw new c("Can't convert object to primitive value")}return void 0===t&&(t="number"),a(e,t)}},93881(e,t,r){"use strict";var i=r(66841),n=r(54709);e.exports=function(e){var t=i(e,"string");return n(t)?t:t+""}},27964(e,t,r){"use strict";var i={};i[r(56547)("toStringTag")]="z",e.exports="[object z]"===String(i)},55135(e,t,r){"use strict";var i=r(98731),n=String;e.exports=function(e){if("Symbol"===i(e))throw new TypeError("Cannot convert a Symbol value to a string");return n(e)}},16991(e){"use strict";var t=Math.round;e.exports=function(e){var r=t(e);return r<0?0:r>255?255:255&r}},93447(e){"use strict";var t=String;e.exports=function(e){try{return t(e)}catch(e){return"Object"}}},55679(e,t,r){"use strict";var i=r(45286),n=r(98896),s=r(91661),o=r(20092),a=r(18645),l=r(1508),c=r(32410),u=r(10983),d=r(36788),h=r(96091),f=r(36247),p=r(47214),g=r(58640),m=r(40997),y=r(16991),v=r(93881),b=r(47121),E=r(98731),A=r(70930),T=r(54709),w=r(65416),S=r(95881),k=r(45047),L=r(28064).f,x=r(55491),R=r(86045).forEach,P=r(28833),I=r(27402),C=r(94401),_=r(3059),O=r(98618),D=r(92733),M=r(23855),N=D.get,F=D.set,B=D.enforce,U=C.f,j=_.f,$=n.RangeError,V=c.ArrayBuffer,H=V.prototype,G=c.DataView,K=l.NATIVE_ARRAY_BUFFER_VIEWS,W=l.TYPED_ARRAY_TAG,q=l.TypedArray,z=l.TypedArrayPrototype,Y=l.isTypedArray,X="BYTES_PER_ELEMENT",Q="Wrong length",J=function(e,t){I(e,t,{configurable:!0,get:function(){return N(this)[t]}})},Z=function(e){var t;return S(H,e)||"ArrayBuffer"===(t=E(e))||"SharedArrayBuffer"===t},ee=function(e,t){return Y(e)&&!T(t)&&t in e&&f(+t)&&t>=0},te=function(e,t){return t=v(t),ee(e,t)?d(2,e[t]):j(e,t)},re=function(e,t,r){return t=v(t),!(ee(e,t)&&A(r)&&b(r,"value"))||b(r,"get")||b(r,"set")||r.configurable||b(r,"writable")&&!r.writable||b(r,"enumerable")&&!r.enumerable?U(e,t,r):(e[t]=r.value,e)};o?(K||(_.f=te,C.f=re,J(z,"buffer"),J(z,"byteOffset"),J(z,"byteLength"),J(z,"length")),i({target:"Object",stat:!0,forced:!K},{getOwnPropertyDescriptor:te,defineProperty:re}),e.exports=function(e,t,r){var o=e.match(/\d+/)[0]/8,l=e+(r?"Clamped":"")+"Array",c="get"+e,d="set"+e,f=n[l],v=f,b=v&&v.prototype,E={},T=function(e,t){U(e,t,{get:function(){return function(e,t){var r=N(e);return r.view[c](t*o+r.byteOffset,!0)}(this,t)},set:function(e){return function(e,t,i){var n=N(e);n.view[d](t*o+n.byteOffset,r?y(i):i,!0)}(this,t,e)},enumerable:!0})};K?a&&(v=t(function(e,t,r,i){return u(e,b),M(A(t)?Z(t)?void 0!==i?new f(t,m(r,o),i):void 0!==r?new f(t,m(r,o)):new f(t):Y(t)?O(v,t):s(x,v,t):new f(g(t)),e,v)}),k&&k(v,q),R(L(f),function(e){e in v||h(v,e,f[e])}),v.prototype=b):(v=t(function(e,t,r,i){u(e,b);var n,a,l,c=0,d=0;if(A(t)){if(!Z(t))return Y(t)?O(v,t):s(x,v,t);n=t,d=m(r,o);var h=t.byteLength;if(void 0===i){if(h%o)throw new $(Q);if((a=h-d)<0)throw new $(Q)}else if((a=p(i)*o)+d>h)throw new $(Q);l=a/o}else l=g(t),n=new V(a=l*o);for(F(e,{buffer:n,byteOffset:d,byteLength:a,length:l,view:new G(n)});c1?arguments[1]:void 0,S=void 0!==w,k=c(A);if(k&&!u(k))for(b=(v=l(A,k)).next,A=[];!(y=n(b,v)).done;)A.push(y.value);for(S&&T>2&&(w=i(w,arguments[2])),r=a(A),p=new(h(E))(r),g=d(p),t=0;r>t;t++)m=S?w(A[t],t):A[t],p[t]=g?f(m):+m;return p}},59008(e,t,r){"use strict";var i=r(3712),n=0,s=Math.random(),o=i(1.1.toString);e.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+o(++n+s,36)}},10984(e,t,r){"use strict";var i=r(70383),n=r(56547),s=r(20092),o=r(20027),a=n("iterator");e.exports=!i(function(){var e=new URL("b?a=1&b=2&c=3","https://a"),t=e.searchParams,r=new URLSearchParams("a=1&a=2&b=3"),i="";return e.pathname="c%20d",t.forEach(function(e,r){t.delete("b"),i+=r+e}),r.delete("a",2),r.delete("b",void 0),o&&(!e.toJSON||!r.has("a",1)||r.has("a",2)||!r.has("a",void 0)||r.has("b"))||!t.size&&(o||!s)||!t.sort||"https://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[a]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==i||"x"!==new URL("https://x",void 0).host})},30736(e,t,r){"use strict";var i=r(10719);e.exports=i&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},44350(e,t,r){"use strict";var i=r(20092),n=r(70383);e.exports=i&&n(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype})},32076(e){"use strict";var t=TypeError;e.exports=function(e,r){if(e=51||!n(function(){var e=[];return e[m]=!1,e.concat()[0]!==e}),v=function(e){if(!o(e))return!1;var t=e[m];return void 0!==t?!!t:s(e)};i({target:"Array",proto:!0,arity:1,forced:!y||!f("concat")},{concat:function(e){var t,r,i,n,s,o=a(this),f=h(o,0),p=0;for(t=-1,i=arguments.length;t1?arguments[1]:void 0)}})},55076(e,t,r){"use strict";var i=r(45286),n=r(86045).findIndex,s=r(4085),o="findIndex",a=!0;o in[]&&Array(1)[o](function(){a=!1}),i({target:"Array",proto:!0,forced:a},{findIndex:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0)}}),s(o)},62065(e,t,r){"use strict";var i=r(45286),n=r(86045).find,s=r(4085),o="find",a=!0;o in[]&&Array(1)[o](function(){a=!1}),i({target:"Array",proto:!0,forced:a},{find:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0)}}),s(o)},2334(e,t,r){"use strict";var i=r(45286),n=r(76099),s=r(18522),o=r(50437),a=r(39942),l=r(26445);i({target:"Array",proto:!0},{flatMap:function(e){var t,r=o(this),i=a(r);return s(e),t=l(r,0),n(t,r,r,i,0,1,e,arguments.length>1?arguments[1]:void 0),t}})},75745(e,t,r){"use strict";var i=r(45286),n=r(76099),s=r(50437),o=r(39942),a=r(45707),l=r(26445);i({target:"Array",proto:!0},{flat:function(){var e=arguments.length?arguments[0]:void 0,t=s(this),r=o(t),i=l(t,0);return n(i,t,t,r,0,void 0===e?1:a(e)),i}})},21501(e,t,r){"use strict";var i=r(45286),n=r(61611);i({target:"Array",proto:!0,forced:[].forEach!==n},{forEach:n})},93066(e,t,r){"use strict";var i=r(45286),n=r(33868);i({target:"Array",stat:!0,forced:!r(86076)(function(e){Array.from(e)})},{from:n})},18439(e,t,r){"use strict";var i=r(45286),n=r(69457).includes,s=r(70383),o=r(4085);i({target:"Array",proto:!0,forced:s(function(){return!Array(1).includes()})},{includes:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0)}}),o("includes")},22080(e,t,r){"use strict";var i=r(65317),n=r(4085),s=r(35149),o=r(92733),a=r(94401).f,l=r(36e3),c=r(2545),u=r(20027),d=r(20092),h="Array Iterator",f=o.set,p=o.getterFor(h);e.exports=l(Array,"Array",function(e,t){f(this,{type:h,target:i(e),index:0,kind:t})},function(){var e=p(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,c(void 0,!0);switch(e.kind){case"keys":return c(r,!1);case"values":return c(t[r],!1)}return c([r,t[r]],!1)},"values");var g=s.Arguments=s.Array;if(n("keys"),n("values"),n("entries"),!u&&d&&"values"!==g.name)try{a(g,"name",{value:"values"})}catch(e){}},6(e,t,r){"use strict";var i=r(45286),n=r(3712),s=r(33151),o=r(65317),a=r(19190),l=n([].join);i({target:"Array",proto:!0,forced:s!==Object||!a("join",",")},{join:function(e){return l(o(this),void 0===e?",":e)}})},21278(e,t,r){"use strict";var i=r(45286),n=r(86045).map;i({target:"Array",proto:!0,forced:!r(35125)("map")},{map:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0)}})},99227(e,t,r){"use strict";var i=r(45286),n=r(70383),s=r(2173),o=r(43648),a=r(75919),l=Array;i({target:"Array",stat:!0,forced:n(function(){function e(){}return!(l.of.call(e)instanceof e)})},{of:function(){for(var e=0,t=arguments.length,r=new(s(this)?this:l)(t);t>e;)o(r,e,arguments[e++]);return a(r,t),r}})},60398(e,t,r){"use strict";var i=r(45286),n=r(48600),s=r(2173),o=r(70930),a=r(8810),l=r(39942),c=r(65317),u=r(43648),d=r(75919),h=r(56547),f=r(35125),p=r(96496),g=f("slice"),m=h("species"),y=Array,v=Math.max;i({target:"Array",proto:!0,forced:!g},{slice:function(e,t){var r,i,h,f=c(this),g=l(f),b=a(e,g),E=a(void 0===t?g:t,g);if(n(f)&&(r=f.constructor,(s(r)&&(r===y||n(r.prototype))||o(r)&&null===(r=r[m]))&&(r=void 0),r===y||void 0===r))return p(f,b,E);for(i=new(void 0===r?y:r)(v(E-b,0)),h=0;b3)){if(p)return!0;if(m)return m<603;var e,t,r,i,n="";for(e=65;e<76;e++){switch(t=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(i=0;i<47;i++)y.push({k:t+i,v:r})}for(y.sort(function(e,t){return t.v-e.v}),i=0;ic(r)?1:-1}}(e)),r=a(n),i=0;iE-i+r;m--)h(b,m-1)}else if(r>i)for(m=E-i;m>A;m--)v=m+r-1,(y=m+i-1)in b?b[v]=b[y]:h(b,v);for(m=0;m94906265.62425156?o(t)+l:n(t-1+a(t-1)*a(t+1))}})},55878(e,t,r){"use strict";var i=r(45286),n=Math.asinh,s=Math.log,o=Math.sqrt;i({target:"Math",stat:!0,forced:!(n&&1/n(0)>0)},{asinh:function e(t){var r=+t;return isFinite(r)&&0!==r?r<0?-e(-r):s(r+o(r*r+1)):r}})},53781(e,t,r){"use strict";var i=r(45286),n=Math.atanh,s=Math.log;i({target:"Math",stat:!0,forced:!(n&&1/n(-0)<0)},{atanh:function(e){var t=+e;return 0===t?t:s((1+t)/(1-t))/2}})},92332(e,t,r){"use strict";var i=r(45286),n=r(94502),s=Math.abs,o=Math.pow;i({target:"Math",stat:!0},{cbrt:function(e){var t=+e;return n(t)*o(s(t),1/3)}})},2789(e,t,r){"use strict";var i=r(45286),n=Math.floor,s=Math.log,o=Math.LOG2E;i({target:"Math",stat:!0},{clz32:function(e){var t=e>>>0;return t?31-n(s(t+.5)*o):32}})},46962(e,t,r){"use strict";var i=r(45286),n=r(83282),s=Math.cosh,o=Math.abs,a=Math.E;i({target:"Math",stat:!0,forced:!s||s(710)===1/0},{cosh:function(e){var t=n(o(e)-1)+1;return(t+1/(t*a*a))*(a/2)}})},60382(e,t,r){"use strict";var i=r(45286),n=r(83282);i({target:"Math",stat:!0,forced:n!==Math.expm1},{expm1:n})},11789(e,t,r){"use strict";r(45286)({target:"Math",stat:!0},{fround:r(46449)})},89917(e,t,r){"use strict";var i=r(45286),n=Math.hypot,s=Math.abs,o=Math.sqrt;i({target:"Math",stat:!0,arity:2,forced:!!n&&n(1/0,NaN)!==1/0},{hypot:function(e,t){for(var r,i,n=0,a=0,l=arguments.length,c=0;a0?(i=r/c)*i:r;return c===1/0?1/0:c*o(n)}})},26056(e,t,r){"use strict";var i=r(45286),n=r(70383),s=Math.imul;i({target:"Math",stat:!0,forced:n(function(){return-5!==s(4294967295,5)||2!==s.length})},{imul:function(e,t){var r=65535,i=+e,n=+t,s=r&i,o=r&n;return 0|s*o+((r&i>>>16)*o+s*(r&n>>>16)<<16>>>0)}})},59968(e,t,r){"use strict";r(45286)({target:"Math",stat:!0},{log10:r(95660)})},18368(e,t,r){"use strict";r(45286)({target:"Math",stat:!0},{log1p:r(37260)})},8215(e,t,r){"use strict";r(45286)({target:"Math",stat:!0},{log2:r(61595)})},56330(e,t,r){"use strict";r(45286)({target:"Math",stat:!0},{sign:r(94502)})},86889(e,t,r){"use strict";var i=r(45286),n=r(70383),s=r(83282),o=Math.abs,a=Math.exp,l=Math.E;i({target:"Math",stat:!0,forced:n(function(){return-2e-17!==Math.sinh(-2e-17)})},{sinh:function(e){var t=+e;return o(t)<1?(s(t)-s(-t))/2:(a(t-1)-a(-t-1))*(l/2)}})},65170(e,t,r){"use strict";var i=r(45286),n=r(83282),s=Math.exp;i({target:"Math",stat:!0},{tanh:function(e){var t=+e,r=n(t),i=n(-t);return r===1/0?1:i===1/0?-1:(r-i)/(s(t)+s(-t))}})},30991(e,t,r){"use strict";r(7023)(Math,"Math",!0)},59801(e,t,r){"use strict";r(45286)({target:"Math",stat:!0},{trunc:r(17749)})},43996(e,t,r){"use strict";var i=r(45286),n=r(20027),s=r(20092),o=r(98896),a=r(63247),l=r(3712),c=r(96812),u=r(47121),d=r(23855),h=r(95881),f=r(54709),p=r(66841),g=r(70383),m=r(28064).f,y=r(3059).f,v=r(94401).f,b=r(18680),E=r(92810).trim,A="Number",T=o[A],w=a[A],S=T.prototype,k=o.TypeError,L=l("".slice),x=l("".charCodeAt),R=c(A,!T(" 0o1")||!T("0b1")||T("+0x1")),P=function(e){var t,r=arguments.length<1?0:T(function(e){var t=p(e,"number");return"bigint"==typeof t?t:function(e){var t,r,i,n,s,o,a,l,c=p(e,"number");if(f(c))throw new k("Cannot convert a Symbol value to a number");if("string"==typeof c&&c.length>2)if(c=E(c),43===(t=x(c,0))||45===t){if(88===(r=x(c,2))||120===r)return NaN}else if(48===t){switch(x(c,1)){case 66:case 98:i=2,n=49;break;case 79:case 111:i=8,n=55;break;default:return+c}for(o=(s=L(c,2)).length,a=0;an)return NaN;return parseInt(s,i)}return+c}(t)}(e));return h(S,t=this)&&g(function(){b(t)})?d(Object(r),this,P):r};P.prototype=S,R&&!n&&(S.constructor=P),i({global:!0,constructor:!0,wrap:!0,forced:R},{Number:P});var I=function(e,t){for(var r,i=s?m(t):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),n=0;i.length>n;n++)u(t,r=i[n])&&!u(e,r)&&v(e,r,y(t,r))};n&&w&&I(a[A],w),(R||n)&&I(a[A],T)},5326(e,t,r){"use strict";r(45286)({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{EPSILON:Math.pow(2,-52)})},52452(e,t,r){"use strict";r(45286)({target:"Number",stat:!0},{isFinite:r(18248)})},42701(e,t,r){"use strict";r(45286)({target:"Number",stat:!0},{isInteger:r(36247)})},24006(e,t,r){"use strict";r(45286)({target:"Number",stat:!0},{isNaN:function(e){return e!=e}})},9565(e,t,r){"use strict";var i=r(45286),n=r(36247),s=Math.abs;i({target:"Number",stat:!0},{isSafeInteger:function(e){return n(e)&&s(e)<=9007199254740991}})},62217(e,t,r){"use strict";r(45286)({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991})},60739(e,t,r){"use strict";r(45286)({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MIN_SAFE_INTEGER:-9007199254740991})},85700(e,t,r){"use strict";var i=r(45286),n=r(49632);i({target:"Number",stat:!0,forced:Number.parseFloat!==n},{parseFloat:n})},63555(e,t,r){"use strict";var i=r(45286),n=r(81903);i({target:"Number",stat:!0,forced:Number.parseInt!==n},{parseInt:n})},6204(e,t,r){"use strict";var i=r(45286),n=r(3712),s=r(45707),o=r(18680),a=r(79485),l=r(70383),c=RangeError,u=String,d=Math.floor,h=n(a),f=n("".slice),p=n(1.1.toFixed),g=function(e,t,r){return 0===t?r:t%2==1?g(e,t-1,r*e):g(e*e,t/2,r)},m=function(e,t,r){for(var i=-1,n=r;++i<6;)n+=t*e[i],e[i]=n%1e7,n=d(n/1e7)},y=function(e,t){for(var r=6,i=0;--r>=0;)i+=e[r],e[r]=d(i/t),i=i%t*1e7},v=function(e){for(var t=6,r="";--t>=0;)if(""!==r||0===t||0!==e[t]){var i=u(e[t]);r=""===r?i:r+h("0",7-i.length)+i}return r};i({target:"Number",proto:!0,forced:l(function(){return"0.000"!==p(8e-5,3)||"1"!==p(.9,0)||"1.25"!==p(1.255,2)||"1000000000000000128"!==p(0xde0b6b3a7640080,0)})||!l(function(){p({})})},{toFixed:function(e){var t,r,i,n,a=o(this),l=s(e),d=[0,0,0,0,0,0],p="",b="0";if(l<0||l>20)throw new c("Incorrect fraction digits");if(a!=a)return"NaN";if(a<=-1e21||a>=1e21)return u(a);if(a<0&&(p="-",a=-a),a>1e-21)if(r=(t=function(e){for(var t=0,r=e;r>=4096;)t+=12,r/=4096;for(;r>=2;)t+=1,r/=2;return t}(a*g(2,69,1))-69)<0?a*g(2,-t,1):a/g(2,t,1),r*=4503599627370496,(t=52-t)>0){for(m(d,0,r),i=l;i>=7;)m(d,1e7,0),i-=7;for(m(d,g(10,i,1),0),i=t-1;i>=23;)y(d,1<<23),i-=23;y(d,1<0?p+((n=b.length)<=l?"0."+h("0",l-n)+b:f(b,0,n-l)+"."+f(b,n-l)):p+b}})},35853(e,t,r){"use strict";var i=r(45286),n=r(28901);i({target:"Object",stat:!0,arity:2,forced:Object.assign!==n},{assign:n})},55843(e,t,r){"use strict";var i=r(45286),n=r(20092),s=r(64039),o=r(18522),a=r(50437),l=r(94401);n&&i({target:"Object",proto:!0,forced:s},{__defineGetter__:function(e,t){l.f(a(this),e,{get:o(t),enumerable:!0,configurable:!0})}})},69383(e,t,r){"use strict";var i=r(45286),n=r(20092),s=r(64039),o=r(18522),a=r(50437),l=r(94401);n&&i({target:"Object",proto:!0,forced:s},{__defineSetter__:function(e,t){l.f(a(this),e,{set:o(t),enumerable:!0,configurable:!0})}})},92818(e,t,r){"use strict";var i=r(45286),n=r(1429).entries;i({target:"Object",stat:!0},{entries:function(e){return n(e)}})},89403(e,t,r){"use strict";var i=r(45286),n=r(78552),s=r(70383),o=r(70930),a=r(3787).onFreeze,l=Object.freeze;i({target:"Object",stat:!0,forced:s(function(){l(1)}),sham:!n},{freeze:function(e){return l&&o(e)?l(a(e)):e}})},5201(e,t,r){"use strict";var i=r(45286),n=r(67708),s=r(43648);i({target:"Object",stat:!0},{fromEntries:function(e){var t={};return n(e,function(e,r){s(t,e,r)},{AS_ENTRIES:!0}),t}})},36027(e,t,r){"use strict";var i=r(45286),n=r(70383),s=r(65317),o=r(3059).f,a=r(20092);i({target:"Object",stat:!0,forced:!a||n(function(){o(1)}),sham:!a},{getOwnPropertyDescriptor:function(e,t){return o(s(e),t)}})},78382(e,t,r){"use strict";var i=r(45286),n=r(20092),s=r(47495),o=r(65317),a=r(3059),l=r(43648);i({target:"Object",stat:!0,sham:!n},{getOwnPropertyDescriptors:function(e){for(var t,r,i=o(e),n=a.f,c=s(i),u={},d=0;c.length>d;)void 0!==(r=n(i,t=c[d++]))&&l(u,t,r);return u}})},87448(e,t,r){"use strict";var i=r(45286),n=r(70383),s=r(92650).f;i({target:"Object",stat:!0,forced:n(function(){return!Object.getOwnPropertyNames(1)})},{getOwnPropertyNames:s})},47197(e,t,r){"use strict";var i=r(45286),n=r(10719),s=r(70383),o=r(14309),a=r(50437);i({target:"Object",stat:!0,forced:!n||s(function(){o.f(1)})},{getOwnPropertySymbols:function(e){var t=o.f;return t?t(a(e)):[]}})},24155(e,t,r){"use strict";var i=r(45286),n=r(70383),s=r(50437),o=r(22995),a=r(45347);i({target:"Object",stat:!0,forced:n(function(){o(1)}),sham:!a},{getPrototypeOf:function(e){return o(s(e))}})},90452(e,t,r){"use strict";var i=r(45286),n=r(52348);i({target:"Object",stat:!0,forced:Object.isExtensible!==n},{isExtensible:n})},65443(e,t,r){"use strict";var i=r(45286),n=r(70383),s=r(70930),o=r(55792),a=r(28308),l=Object.isFrozen;i({target:"Object",stat:!0,forced:a||n(function(){l(1)})},{isFrozen:function(e){return!s(e)||!(!a||"ArrayBuffer"!==o(e))||!!l&&l(e)}})},21741(e,t,r){"use strict";var i=r(45286),n=r(70383),s=r(70930),o=r(55792),a=r(28308),l=Object.isSealed;i({target:"Object",stat:!0,forced:a||n(function(){l(1)})},{isSealed:function(e){return!s(e)||!(!a||"ArrayBuffer"!==o(e))||!!l&&l(e)}})},53636(e,t,r){"use strict";r(45286)({target:"Object",stat:!0},{is:r(70462)})},88792(e,t,r){"use strict";var i=r(45286),n=r(50437),s=r(30320);i({target:"Object",stat:!0,forced:r(70383)(function(){s(1)})},{keys:function(e){return s(n(e))}})},29844(e,t,r){"use strict";var i=r(45286),n=r(20092),s=r(64039),o=r(50437),a=r(93881),l=r(22995),c=r(3059).f;n&&i({target:"Object",proto:!0,forced:s},{__lookupGetter__:function(e){var t,r=o(this),i=a(e);do{if(t=c(r,i))return t.get}while(r=l(r))}})},10128(e,t,r){"use strict";var i=r(45286),n=r(20092),s=r(64039),o=r(50437),a=r(93881),l=r(22995),c=r(3059).f;n&&i({target:"Object",proto:!0,forced:s},{__lookupSetter__:function(e){var t,r=o(this),i=a(e);do{if(t=c(r,i))return t.set}while(r=l(r))}})},74559(e,t,r){"use strict";var i=r(45286),n=r(70930),s=r(3787).onFreeze,o=r(78552),a=r(70383),l=Object.preventExtensions;i({target:"Object",stat:!0,forced:a(function(){l(1)}),sham:!o},{preventExtensions:function(e){return l&&n(e)?l(s(e)):e}})},17861(e,t,r){"use strict";var i=r(45286),n=r(70930),s=r(3787).onFreeze,o=r(78552),a=r(70383),l=Object.seal;i({target:"Object",stat:!0,forced:a(function(){l(1)}),sham:!o},{seal:function(e){return l&&n(e)?l(s(e)):e}})},49347(e,t,r){"use strict";var i=r(27964),n=r(13368),s=r(96651);i||n(Object.prototype,"toString",s,{unsafe:!0})},97970(e,t,r){"use strict";var i=r(45286),n=r(1429).values;i({target:"Object",stat:!0},{values:function(e){return n(e)}})},5571(e,t,r){"use strict";var i=r(45286),n=r(91661),s=r(18522),o=r(63419),a=r(17055),l=r(67708);i({target:"Promise",stat:!0,forced:r(86329)},{all:function(e){var t=this,r=o.f(t),i=r.resolve,c=r.reject,u=a(function(){var r=s(t.resolve),o=[],a=0,u=1;l(e,function(e){var s=a++,l=!1;u++,n(r,t,e).then(function(e){l||(l=!0,o[s]=e,--u||i(o))},c)}),--u||i(o)});return u.error&&c(u.value),r.promise}})},26531(e,t,r){"use strict";var i=r(45286),n=r(20027),s=r(23892).CONSTRUCTOR,o=r(23254),a=r(97671),l=r(97157),c=r(13368),u=o&&o.prototype;if(i({target:"Promise",proto:!0,forced:s,real:!0},{catch:function(e){return this.then(void 0,e)}}),!n&&l(o)){var d=a("Promise").prototype.catch;u.catch!==d&&c(u,"catch",d,{unsafe:!0})}},46196(e,t,r){"use strict";var i,n,s,o,a=r(45286),l=r(20027),c=r(75313),u=r(98896),d=r(63247),h=r(91661),f=r(13368),p=r(45047),g=r(7023),m=r(28833),y=r(18522),v=r(97157),b=r(70930),E=r(10983),A=r(63749),T=r(4201).set,w=r(69251),S=r(3669),k=r(17055),L=r(70313),x=r(92733),R=r(23254),P=r(23892),I=r(63419),C="Promise",_=P.CONSTRUCTOR,O=P.REJECTION_EVENT,D=P.SUBCLASSING,M=x.getterFor(C),N=x.set,F=R&&R.prototype,B=R,U=F,j=u.TypeError,$=u.document,V=u.process,H=I.f,G=H,K=!!($&&$.createEvent&&u.dispatchEvent),W="unhandledrejection",q=function(e){var t;return!(!b(e)||!v(t=e.then))&&t},z=function(e,t){var r,i,n,s=t.value,o=1===t.state,a=o?e.ok:e.fail,l=e.resolve,c=e.reject,u=e.domain;try{a?(o||(2===t.rejection&&Z(t),t.rejection=1),!0===a?r=s:(u&&u.enter(),r=a(s),u&&(u.exit(),n=!0)),r===e.promise?c(new j("Promise-chain cycle")):(i=q(r))?h(i,r,l,c):l(r)):c(s)}catch(e){u&&!n&&u.exit(),c(e)}},Y=function(e,t){e.notified||(e.notified=!0,w(function(){for(var r,i=e.reactions;r=i.get();)z(r,e);e.notified=!1,t&&!e.rejection&&Q(e)}))},X=function(e,t,r){var i,n;K?((i=$.createEvent("Event")).promise=t,i.reason=r,i.initEvent(e,!1,!0),u.dispatchEvent(i)):i={promise:t,reason:r},!O&&(n=u["on"+e])?n(i):e===W&&S("Unhandled promise rejection",r)},Q=function(e){h(T,u,function(){var t,r=e.facade,i=e.value;if(J(e)&&(t=k(function(){c?V.emit("unhandledRejection",i,r):X(W,r,i)}),e.rejection=c||J(e)?2:1,t.error))throw t.value})},J=function(e){return 1!==e.rejection&&!e.parent},Z=function(e){h(T,u,function(){var t=e.facade;c?V.emit("rejectionHandled",t):X("rejectionhandled",t,e.value)})},ee=function(e,t,r){return function(i){e(t,i,r)}},te=function(e,t,r){e.done||(e.done=!0,r&&(e=r),e.value=t,e.state=2,Y(e,!0))},re=function(e,t,r){if(!e.done){e.done=!0,r&&(e=r);try{if(e.facade===t)throw new j("Promise can't be resolved itself");var i=q(t);i?w(function(){var r={done:!1};try{h(i,t,ee(re,r,e),ee(te,r,e))}catch(t){te(r,t,e)}}):(e.value=t,e.state=1,Y(e,!1))}catch(t){te({done:!1},t,e)}}};if(_&&(U=(B=function(e){E(this,U),y(e),h(i,this);var t=M(this);try{e(ee(re,t),ee(te,t))}catch(e){te(t,e)}}).prototype,(i=function(e){N(this,{type:C,done:!1,notified:!1,parent:!1,reactions:new L,rejection:!1,state:0,value:null})}).prototype=f(U,"then",function(e,t){var r=M(this),i=H(A(this,B));return r.parent=!0,i.ok=!v(e)||e,i.fail=v(t)&&t,i.domain=c?V.domain:void 0,0===r.state?r.reactions.add(i):w(function(){z(i,r)}),i.promise}),n=function(){var e=new i,t=M(e);this.promise=e,this.resolve=ee(re,t),this.reject=ee(te,t)},I.f=H=function(e){return e===B||e===s?new n(e):G(e)},!l&&v(R)&&F!==Object.prototype)){o=F.then,D||f(F,"then",function(e,t){var r=this;return new B(function(e,t){h(o,r,e,t)}).then(e,t)},{unsafe:!0});try{delete F.constructor}catch(e){}p&&p(F,U)}a({global:!0,constructor:!0,wrap:!0,forced:_},{Promise:B}),s=d.Promise,g(B,C,!1,!0),m(C)},48895(e,t,r){"use strict";var i=r(45286),n=r(20027),s=r(23254),o=r(70383),a=r(97671),l=r(97157),c=r(63749),u=r(65326),d=r(13368),h=s&&s.prototype;if(i({target:"Promise",proto:!0,real:!0,forced:!!s&&o(function(){h.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=c(this,a("Promise")),r=l(e);return this.then(r?function(r){return u(t,e()).then(function(){return r})}:e,r?function(r){return u(t,e()).then(function(){throw r})}:e)}}),!n&&l(s)){var f=a("Promise").prototype.finally;h.finally!==f&&d(h,"finally",f,{unsafe:!0})}},17298(e,t,r){"use strict";r(46196),r(5571),r(26531),r(98799),r(62153),r(65e3)},98799(e,t,r){"use strict";var i=r(45286),n=r(91661),s=r(18522),o=r(63419),a=r(17055),l=r(67708);i({target:"Promise",stat:!0,forced:r(86329)},{race:function(e){var t=this,r=o.f(t),i=r.reject,c=a(function(){var o=s(t.resolve);l(e,function(e){n(o,t,e).then(r.resolve,i)})});return c.error&&i(c.value),r.promise}})},62153(e,t,r){"use strict";var i=r(45286),n=r(63419);i({target:"Promise",stat:!0,forced:r(23892).CONSTRUCTOR},{reject:function(e){var t=n.f(this);return(0,t.reject)(e),t.promise}})},65e3(e,t,r){"use strict";var i=r(45286),n=r(97671),s=r(20027),o=r(23254),a=r(23892).CONSTRUCTOR,l=r(65326),c=n("Promise"),u=s&&!a;i({target:"Promise",stat:!0,forced:s||a},{resolve:function(e){return l(u&&this===c?o:this,e)}})},17700(e,t,r){"use strict";var i=r(45286),n=r(97321),s=r(18522),o=r(82007);i({target:"Reflect",stat:!0,forced:!r(70383)(function(){Reflect.apply(function(){})})},{apply:function(e,t,r){return n(s(e),t,o(r))}})},87241(e,t,r){"use strict";var i=r(45286),n=r(97671),s=r(97321),o=r(42038),a=r(34412),l=r(82007),c=r(70930),u=r(65416),d=r(70383),h=n("Reflect","construct"),f=Object.prototype,p=[].push,g=d(function(){function e(){}return!(h(function(){},[],e)instanceof e)}),m=!d(function(){h(function(){})}),y=g||m;i({target:"Reflect",stat:!0,forced:y,sham:y},{construct:function(e,t){a(e),l(t);var r=arguments.length<3?e:a(arguments[2]);if(m&&!g)return h(e,t,r);if(e===r){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var i=[null];return s(p,i,t),new(s(o,e,i))}var n=r.prototype,d=u(c(n)?n:f),y=s(e,d,t);return c(y)?y:d}})},54211(e,t,r){"use strict";var i=r(45286),n=r(20092),s=r(82007),o=r(93881),a=r(94401);i({target:"Reflect",stat:!0,forced:r(70383)(function(){Reflect.defineProperty(a.f({},1,{value:1}),1,{value:2})}),sham:!n},{defineProperty:function(e,t,r){s(e);var i=o(t);s(r);try{return a.f(e,i,r),!0}catch(e){return!1}}})},23275(e,t,r){"use strict";var i=r(45286),n=r(82007),s=r(3059).f;i({target:"Reflect",stat:!0},{deleteProperty:function(e,t){var r=s(n(e),t);return!(r&&!r.configurable)&&delete e[t]}})},59001(e,t,r){"use strict";var i=r(45286),n=r(20092),s=r(82007),o=r(3059);i({target:"Reflect",stat:!0,sham:!n},{getOwnPropertyDescriptor:function(e,t){return o.f(s(e),t)}})},58837(e,t,r){"use strict";var i=r(45286),n=r(82007),s=r(22995);i({target:"Reflect",stat:!0,sham:!r(45347)},{getPrototypeOf:function(e){return s(n(e))}})},25064(e,t,r){"use strict";var i=r(45286),n=r(91661),s=r(70930),o=r(82007),a=r(53199),l=r(3059),c=r(22995);i({target:"Reflect",stat:!0},{get:function e(t,r){var i,u,d=arguments.length<3?t:arguments[2];return o(t)===d?t[r]:(i=l.f(t,r))?a(i)?i.value:void 0===i.get?void 0:n(i.get,d):s(u=c(t))?e(u,r,d):void 0}})},88700(e,t,r){"use strict";r(45286)({target:"Reflect",stat:!0},{has:function(e,t){return t in e}})},30538(e,t,r){"use strict";var i=r(45286),n=r(82007),s=r(52348);i({target:"Reflect",stat:!0},{isExtensible:function(e){return n(e),s(e)}})},20190(e,t,r){"use strict";r(45286)({target:"Reflect",stat:!0},{ownKeys:r(47495)})},23993(e,t,r){"use strict";var i=r(45286),n=r(97671),s=r(82007);i({target:"Reflect",stat:!0,sham:!r(78552)},{preventExtensions:function(e){s(e);try{var t=n("Object","preventExtensions");return t&&t(e),!0}catch(e){return!1}}})},38345(e,t,r){"use strict";var i=r(45286),n=r(82007),s=r(49362),o=r(45047);o&&i({target:"Reflect",stat:!0},{setPrototypeOf:function(e,t){n(e),s(t);try{return o(e,t),!0}catch(e){return!1}}})},37228(e,t,r){"use strict";var i=r(45286),n=r(91661),s=r(82007),o=r(70930),a=r(53199),l=r(70383),c=r(94401),u=r(3059),d=r(22995),h=r(36788);i({target:"Reflect",stat:!0,forced:l(function(){var e=function(){},t=c.f(new e,"a",{configurable:!0});return!1!==Reflect.set(e.prototype,"a",1,t)})},{set:function e(t,r,i){var l,f,p,g=arguments.length<4?t:arguments[3],m=u.f(s(t),r);if(!m){if(o(f=d(t)))return e(f,r,i,g);m=h(0)}if(a(m)){if(!1===m.writable||!o(g))return!1;if(l=u.f(g,r)){if(l.get||l.set||!1===l.writable)return!1;l.value=i,c.f(g,r,l)}else c.f(g,r,h(0,i))}else{if(void 0===(p=m.set))return!1;n(p,g,i)}return!0}})},74576(e,t,r){"use strict";var i=r(20092),n=r(98896),s=r(3712),o=r(96812),a=r(23855),l=r(96091),c=r(65416),u=r(28064).f,d=r(95881),h=r(75364),f=r(55135),p=r(56410),g=r(35597),m=r(95776),y=r(13368),v=r(70383),b=r(47121),E=r(92733).enforce,A=r(28833),T=r(56547),w=r(90755),S=r(494),k=T("match"),L=n.RegExp,x=L.prototype,R=n.SyntaxError,P=s(x.exec),I=s("".charAt),C=s("".replace),_=s("".indexOf),O=s("".slice),D=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,M=/a/g,N=/a/g,F=new L(M)!==M,B=g.MISSED_STICKY,U=g.UNSUPPORTED_Y;if(o("RegExp",i&&(!F||B||w||S||v(function(){return N[k]=!1,L(M)!==M||L(N)===N||"/a/i"!==String(L(M,"i"))})))){for(var j=function(e,t){var r,i,n,s,o,u,g=d(x,this),m=h(e),y=void 0===t,v=[],A=e;if(!g&&m&&y&&e.constructor===j)return e;if((m||d(x,e))&&(e=e.source,y&&(t=p(A))),e=void 0===e?"":f(e),t=void 0===t?"":f(t),A=e,w&&"dotAll"in M&&(i=!!t&&_(t,"s")>-1)&&(t=C(t,/s/g,"")),r=t,B&&"sticky"in M&&(n=!!t&&_(t,"y")>-1)&&U&&(t=C(t,/y/g,"")),S&&(s=function(e){for(var t,r=e.length,i=0,n="",s=[],o=c(null),a=!1,l=!1,u=0,d="";i"===t&&l:if(""===d||b(o,d))throw new R("Invalid capture group name");o[d]=!0,s[s.length]=[d,u],l=!1,d="";continue}l?d+=t:n+=t}return[n,s]}(e),e=s[0],v=s[1]),o=a(L(e,t),g?this:x,j),(i||n||v.length)&&(u=E(o),i&&(u.dotAll=!0,u.raw=j(function(e){for(var t,r=e.length,i=0,n="",s=!1;iV;)m(j,L,$[V++]);x.constructor=j,j.prototype=x,y(n,"RegExp",j,{constructor:!0})}A("RegExp")},94391(e,t,r){"use strict";var i=r(45286),n=r(53435);i({target:"RegExp",proto:!0,forced:/./.exec!==n},{exec:n})},62327(e,t,r){"use strict";var i=r(20092),n=r(27402),s=r(85357),o=r(29083);i&&!s.correct&&(n(RegExp.prototype,"flags",{configurable:!0,get:o}),s.correct=!0)},36269(e,t,r){"use strict";var i=r(7934).PROPER,n=r(13368),s=r(82007),o=r(55135),a=r(70383),l=r(56410),c="toString",u=RegExp.prototype,d=u[c],h=a(function(){return"/a/b"!==d.call({source:"a",flags:"b"})}),f=i&&d.name!==c;(h||f)&&n(u,c,function(){var e=s(this);return"/"+o(e.source)+"/"+o(l(e))},{unsafe:!0})},15013(e,t,r){"use strict";r(23332)("Set",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},r(67850))},93383(e,t,r){"use strict";r(15013)},25603(e,t,r){"use strict";var i=r(45286),n=r(58504);i({target:"String",proto:!0,forced:r(76869)("anchor")},{anchor:function(e){return n(this,"a","name",e)}})},69002(e,t,r){"use strict";var i=r(45286),n=r(58504);i({target:"String",proto:!0,forced:r(76869)("big")},{big:function(){return n(this,"big","","")}})},86546(e,t,r){"use strict";var i=r(45286),n=r(58504);i({target:"String",proto:!0,forced:r(76869)("blink")},{blink:function(){return n(this,"blink","","")}})},23457(e,t,r){"use strict";var i=r(45286),n=r(58504);i({target:"String",proto:!0,forced:r(76869)("bold")},{bold:function(){return n(this,"b","","")}})},39012(e,t,r){"use strict";var i=r(45286),n=r(54087).codeAt;i({target:"String",proto:!0},{codePointAt:function(e){return n(this,e)}})},22825(e,t,r){"use strict";var i,n=r(45286),s=r(89412),o=r(3059).f,a=r(47214),l=r(55135),c=r(31151),u=r(20118),d=r(27788),h=r(20027),f=s("".slice),p=Math.min,g=d("endsWith");n({target:"String",proto:!0,forced:!(!h&&!g&&(i=o(String.prototype,"endsWith"),i&&!i.writable)||g)},{endsWith:function(e){var t=l(u(this));c(e);var r=arguments.length>1?arguments[1]:void 0,i=t.length,n=void 0===r?i:p(a(r),i),s=l(e);return f(t,n-s.length,n)===s}})},50730(e,t,r){"use strict";var i=r(45286),n=r(58504);i({target:"String",proto:!0,forced:r(76869)("fixed")},{fixed:function(){return n(this,"tt","","")}})},11964(e,t,r){"use strict";var i=r(45286),n=r(58504);i({target:"String",proto:!0,forced:r(76869)("fontcolor")},{fontcolor:function(e){return n(this,"font","color",e)}})},98394(e,t,r){"use strict";var i=r(45286),n=r(58504);i({target:"String",proto:!0,forced:r(76869)("fontsize")},{fontsize:function(e){return n(this,"font","size",e)}})},5881(e,t,r){"use strict";var i=r(45286),n=r(3712),s=r(8810),o=RangeError,a=String.fromCharCode,l=String.fromCodePoint,c=n([].join);i({target:"String",stat:!0,arity:1,forced:!!l&&1!==l.length},{fromCodePoint:function(e){for(var t,r=[],i=arguments.length,n=0;i>n;){if(t=+arguments[n++],s(t,1114111)!==t)throw new o(t+" is not a valid code point");r[n]=t<65536?a(t):a(55296+((t-=65536)>>10),t%1024+56320)}return c(r,"")}})},13171(e,t,r){"use strict";var i=r(45286),n=r(3712),s=r(31151),o=r(20118),a=r(55135),l=r(27788),c=n("".indexOf);i({target:"String",proto:!0,forced:!l("includes")},{includes:function(e){return!!~c(a(o(this)),a(s(e)),arguments.length>1?arguments[1]:void 0)}})},14749(e,t,r){"use strict";var i=r(45286),n=r(58504);i({target:"String",proto:!0,forced:r(76869)("italics")},{italics:function(){return n(this,"i","","")}})},52740(e,t,r){"use strict";var i=r(54087).charAt,n=r(55135),s=r(92733),o=r(36e3),a=r(2545),l="String Iterator",c=s.set,u=s.getterFor(l);o(String,"String",function(e){c(this,{type:l,string:n(e),index:0})},function(){var e,t=u(this),r=t.string,n=t.index;return n>=r.length?a(void 0,!0):(e=i(r,n),t.index+=e.length,a(e,!1))})},70762(e,t,r){"use strict";var i=r(45286),n=r(58504);i({target:"String",proto:!0,forced:r(76869)("link")},{link:function(e){return n(this,"a","href",e)}})},11937(e,t,r){"use strict";var i=r(91661),n=r(3712),s=r(13084),o=r(82007),a=r(70930),l=r(47214),c=r(55135),u=r(20118),d=r(1806),h=r(65397),f=r(56410),p=r(95450),g=n("".indexOf);s("match",function(e,t,r){return[function(t){var r=u(this),n=a(t)?d(t,e):void 0;return n?i(n,t,r):new RegExp(t)[e](c(r))},function(e){var i=o(this),n=c(e),s=r(t,i,n);if(s.done)return s.value;var a=c(f(i));if(-1===g(a,"g"))return p(i,n);var u=-1!==g(a,"u");i.lastIndex=0;for(var d,m=[],y=0;null!==(d=p(i,n));){var v=c(d[0]);m[y]=v,""===v&&(i.lastIndex=h(n,l(i.lastIndex),u)),y++}return 0===y?null:m}]})},9029(e,t,r){"use strict";var i=r(45286),n=r(10341).end;i({target:"String",proto:!0,forced:r(1799)},{padEnd:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0)}})},15596(e,t,r){"use strict";var i=r(45286),n=r(10341).start;i({target:"String",proto:!0,forced:r(1799)},{padStart:function(e){return n(this,e,arguments.length>1?arguments[1]:void 0)}})},32994(e,t,r){"use strict";var i=r(45286),n=r(3712),s=r(65317),o=r(50437),a=r(55135),l=r(39942),c=n([].push),u=n([].join);i({target:"String",stat:!0},{raw:function(e){var t=s(o(e).raw),r=l(t);if(!r)return"";for(var i=arguments.length,n=[],d=0;;){if(c(n,a(t[d++])),d===r)return u(n,"");d=_&&(C+=L(a,_,N)+D,_=N+M.length)}return C+L(a,_)}]},!!a(function(){var e=/./;return e.exec=function(){var e=[];return e.groups={a:"7"},e},"7"!=="".replace(e,"$")})||!R||P)},14754(e,t,r){"use strict";var i=r(91661),n=r(13084),s=r(82007),o=r(70930),a=r(20118),l=r(70462),c=r(55135),u=r(1806),d=r(95450);n("search",function(e,t,r){return[function(t){var r=a(this),n=o(t)?u(t,e):void 0;return n?i(n,t,r):new RegExp(t)[e](c(r))},function(e){var i=s(this),n=c(e),o=r(t,i,n);if(o.done)return o.value;var a=i.lastIndex;l(a,0)||(i.lastIndex=0);var u=d(i,n);return l(i.lastIndex,a)||(i.lastIndex=a),null===u?-1:u.index}]})},21339(e,t,r){"use strict";var i=r(45286),n=r(58504);i({target:"String",proto:!0,forced:r(76869)("small")},{small:function(){return n(this,"small","","")}})},29480(e,t,r){"use strict";var i=r(91661),n=r(3712),s=r(13084),o=r(82007),a=r(70930),l=r(20118),c=r(63749),u=r(65397),d=r(47214),h=r(55135),f=r(1806),p=r(95450),g=r(35597),m=r(70383),y=g.UNSUPPORTED_Y,v=Math.min,b=n([].push),E=n("".slice),A=!m(function(){var e=/(?:)/,t=e.exec;e.exec=function(){return t.apply(this,arguments)};var r="ab".split(e);return 2!==r.length||"a"!==r[0]||"b"!==r[1]}),T="c"==="abbc".split(/(b)*/)[1]||4!=="test".split(/(?:)/,-1).length||2!=="ab".split(/(?:ab)*/).length||4!==".".split(/(.?)(.?)/).length||".".split(/()()/).length>1||"".split(/.?/).length;s("split",function(e,t,r){var n="0".split(void 0,0).length?function(e,r){return void 0===e&&0===r?[]:i(t,this,e,r)}:t;return[function(t,r){var s=l(this),o=a(t)?f(t,e):void 0;return o?i(o,t,s,r):i(n,h(s),t,r)},function(e,i){var s=o(this),a=h(e);if(!T){var l=r(n,s,a,i,n!==t);if(l.done)return l.value}var f=c(s,RegExp),g=s.unicode,m=(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.unicode?"u":"")+(y?"g":"y"),A=new f(y?"^(?:"+s.source+")":s,m),w=void 0===i?4294967295:i>>>0;if(0===w)return[];if(0===a.length)return null===p(A,a)?[a]:[];for(var S=0,k=0,L=[];k1?arguments[1]:void 0,t.length)),i=l(e);return f(t,r,r+i.length)===i}})},96532(e,t,r){"use strict";var i=r(45286),n=r(58504);i({target:"String",proto:!0,forced:r(76869)("strike")},{strike:function(){return n(this,"strike","","")}})},29342(e,t,r){"use strict";var i=r(45286),n=r(58504);i({target:"String",proto:!0,forced:r(76869)("sub")},{sub:function(){return n(this,"sub","","")}})},3780(e,t,r){"use strict";var i=r(45286),n=r(58504);i({target:"String",proto:!0,forced:r(76869)("sup")},{sup:function(){return n(this,"sup","","")}})},73298(e,t,r){"use strict";r(63889);var i=r(45286),n=r(95298);i({target:"String",proto:!0,name:"trimEnd",forced:"".trimEnd!==n},{trimEnd:n})},79622(e,t,r){"use strict";var i=r(45286),n=r(56223);i({target:"String",proto:!0,name:"trimStart",forced:"".trimLeft!==n},{trimLeft:n})},63889(e,t,r){"use strict";var i=r(45286),n=r(95298);i({target:"String",proto:!0,name:"trimEnd",forced:"".trimRight!==n},{trimRight:n})},67631(e,t,r){"use strict";r(79622);var i=r(45286),n=r(56223);i({target:"String",proto:!0,name:"trimStart",forced:"".trimStart!==n},{trimStart:n})},89754(e,t,r){"use strict";var i=r(45286),n=r(92810).trim;i({target:"String",proto:!0,forced:r(70866)("trim")},{trim:function(){return n(this)}})},32700(e,t,r){"use strict";r(90111)("asyncIterator")},30233(e,t,r){"use strict";var i=r(45286),n=r(98896),s=r(91661),o=r(3712),a=r(20027),l=r(20092),c=r(10719),u=r(70383),d=r(47121),h=r(95881),f=r(82007),p=r(65317),g=r(93881),m=r(55135),y=r(36788),v=r(65416),b=r(30320),E=r(28064),A=r(92650),T=r(14309),w=r(3059),S=r(94401),k=r(46673),L=r(89269),x=r(13368),R=r(27402),P=r(4961),I=r(8183),C=r(30885),_=r(59008),O=r(56547),D=r(34991),M=r(90111),N=r(3634),F=r(7023),B=r(92733),U=r(86045).forEach,j=I("hidden"),$="Symbol",V="prototype",H=B.set,G=B.getterFor($),K=Object[V],W=n.Symbol,q=W&&W[V],z=n.RangeError,Y=n.TypeError,X=n.QObject,Q=w.f,J=S.f,Z=A.f,ee=L.f,te=o([].push),re=P("symbols"),ie=P("op-symbols"),ne=P("wks"),se=!X||!X[V]||!X[V].findChild,oe=function(e,t,r){var i=Q(K,t);i&&delete K[t],J(e,t,r),i&&e!==K&&J(K,t,i)},ae=l&&u(function(){return 7!==v(J({},"a",{get:function(){return J(this,"a",{value:7}).a}})).a})?oe:J,le=function(e,t){var r=re[e]=v(q);return H(r,{type:$,tag:e,description:t}),l||(r.description=t),r},ce=function(e,t,r){e===K&&ce(ie,t,r),f(e);var i=g(t);return f(r),d(re,i)?(r.enumerable?(d(e,j)&&e[j][i]&&(e[j][i]=!1),r=v(r,{enumerable:y(0,!1)})):(d(e,j)||J(e,j,y(1,v(null))),e[j][i]=!0),ae(e,i,r)):J(e,i,r)},ue=function(e,t){f(e);var r=p(t),i=b(r).concat(pe(r));return U(i,function(t){l&&!s(de,r,t)||ce(e,t,r[t])}),e},de=function(e){var t=g(e),r=s(ee,this,t);return!(this===K&&d(re,t)&&!d(ie,t))&&(!(r||!d(this,t)||!d(re,t)||d(this,j)&&this[j][t])||r)},he=function(e,t){var r=p(e),i=g(t);if(r!==K||!d(re,i)||d(ie,i)){var n=Q(r,i);return!n||!d(re,i)||d(r,j)&&r[j][i]||(n.enumerable=!0),n}},fe=function(e){var t=Z(p(e)),r=[];return U(t,function(e){d(re,e)||d(C,e)||te(r,e)}),r},pe=function(e){var t=e===K,r=Z(t?ie:p(e)),i=[];return U(r,function(e){!d(re,e)||t&&!d(K,e)||te(i,re[e])}),i};c||(W=function(){if(h(q,this))throw new Y("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?m(arguments[0]):void 0,t=_(e),r=function(e){var i=void 0===this?n:this;i===K&&s(r,ie,e),d(i,j)&&d(i[j],t)&&(i[j][t]=!1);var o=y(1,e);try{ae(i,t,o)}catch(e){if(!(e instanceof z))throw e;oe(i,t,o)}};return l&&se&&ae(K,t,{configurable:!0,set:r}),le(t,e)},x(q=W[V],"toString",function(){return G(this).tag}),x(W,"withoutSetter",function(e){return le(_(e),e)}),L.f=de,S.f=ce,k.f=ue,w.f=he,E.f=A.f=fe,T.f=pe,D.f=function(e){return le(O(e),e)},l&&(R(q,"description",{configurable:!0,get:function(){return G(this).description}}),a||x(K,"propertyIsEnumerable",de,{unsafe:!0}))),i({global:!0,constructor:!0,wrap:!0,forced:!c,sham:!c},{Symbol:W}),U(b(ne),function(e){M(e)}),i({target:$,stat:!0,forced:!c},{useSetter:function(){se=!0},useSimple:function(){se=!1}}),i({target:"Object",stat:!0,forced:!c,sham:!l},{create:function(e,t){return void 0===t?v(e):ue(v(e),t)},defineProperty:ce,defineProperties:ue,getOwnPropertyDescriptor:he}),i({target:"Object",stat:!0,forced:!c},{getOwnPropertyNames:fe}),N(),F(W,$),C[j]=!0},98215(e,t,r){"use strict";var i=r(45286),n=r(20092),s=r(98896),o=r(3712),a=r(47121),l=r(97157),c=r(95881),u=r(55135),d=r(27402),h=r(13884),f=s.Symbol,p=f&&f.prototype;if(n&&l(f)&&(!("description"in p)||void 0!==f().description)){var g={},m=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:u(arguments[0]),t=c(p,this)?new f(e):void 0===e?f():f(e);return""===e&&(g[t]=!0),t};h(m,f),m.prototype=p,p.constructor=m;var y="Symbol(description detection)"===String(f("description detection")),v=o(p.valueOf),b=o(p.toString),E=/^Symbol\((.*)\)[^)]+$/,A=o("".replace),T=o("".slice);d(p,"description",{configurable:!0,get:function(){var e=v(this);if(a(g,e))return"";var t=b(e),r=y?T(t,7,-1):A(t,E,"$1");return""===r?void 0:r}}),i({global:!0,constructor:!0,forced:!0},{Symbol:m})}},73206(e,t,r){"use strict";var i=r(45286),n=r(97671),s=r(47121),o=r(55135),a=r(4961),l=r(24336),c=a("string-to-symbol-registry"),u=a("symbol-to-string-registry");i({target:"Symbol",stat:!0,forced:!l},{for:function(e){var t=o(e);if(s(c,t))return c[t];var r=n("Symbol")(t);return c[t]=r,u[r]=t,r}})},85393(e,t,r){"use strict";r(90111)("hasInstance")},23192(e,t,r){"use strict";r(90111)("isConcatSpreadable")},22435(e,t,r){"use strict";r(90111)("iterator")},41427(e,t,r){"use strict";r(30233),r(73206),r(73284),r(27622),r(47197)},73284(e,t,r){"use strict";var i=r(45286),n=r(47121),s=r(54709),o=r(93447),a=r(4961),l=r(24336),c=a("symbol-to-string-registry");i({target:"Symbol",stat:!0,forced:!l},{keyFor:function(e){if(!s(e))throw new TypeError(o(e)+" is not a symbol");if(n(c,e))return c[e]}})},80868(e,t,r){"use strict";r(90111)("match")},74677(e,t,r){"use strict";r(90111)("replace")},61177(e,t,r){"use strict";r(90111)("search")},59483(e,t,r){"use strict";r(90111)("species")},97809(e,t,r){"use strict";r(90111)("split")},71508(e,t,r){"use strict";var i=r(90111),n=r(3634);i("toPrimitive"),n()},32349(e,t,r){"use strict";var i=r(97671),n=r(90111),s=r(7023);n("toStringTag"),s(i("Symbol"),"Symbol")},62806(e,t,r){"use strict";r(90111)("unscopables")},30254(e,t,r){"use strict";var i=r(3712),n=r(1508),s=i(r(41589)),o=n.aTypedArray;(0,n.exportTypedArrayMethod)("copyWithin",function(e,t){return s(o(this),e,t,arguments.length>2?arguments[2]:void 0)})},68954(e,t,r){"use strict";var i=r(1508),n=r(86045).every,s=i.aTypedArray;(0,i.exportTypedArrayMethod)("every",function(e){return n(s(this),e,arguments.length>1?arguments[1]:void 0)})},40340(e,t,r){"use strict";var i=r(1508),n=r(39269),s=r(9918),o=r(98731),a=r(91661),l=r(3712),c=r(70383),u=i.aTypedArray,d=i.exportTypedArrayMethod,h=l("".slice);d("fill",function(e){var t=arguments.length;u(this);var r="Big"===h(o(this),0,3)?s(e):+e;return a(n,this,r,t>1?arguments[1]:void 0,t>2?arguments[2]:void 0)},c(function(){var e=0;return new Int8Array(2).fill({valueOf:function(){return e++}}),1!==e}))},12339(e,t,r){"use strict";var i=r(1508),n=r(86045).filter,s=r(88108),o=i.aTypedArray;(0,i.exportTypedArrayMethod)("filter",function(e){var t=n(o(this),e,arguments.length>1?arguments[1]:void 0);return s(this,t)})},99091(e,t,r){"use strict";var i=r(1508),n=r(86045).findIndex,s=i.aTypedArray;(0,i.exportTypedArrayMethod)("findIndex",function(e){return n(s(this),e,arguments.length>1?arguments[1]:void 0)})},12798(e,t,r){"use strict";var i=r(1508),n=r(86045).find,s=i.aTypedArray;(0,i.exportTypedArrayMethod)("find",function(e){return n(s(this),e,arguments.length>1?arguments[1]:void 0)})},94354(e,t,r){"use strict";r(55679)("Float32",function(e){return function(t,r,i){return e(this,t,r,i)}})},13081(e,t,r){"use strict";r(55679)("Float64",function(e){return function(t,r,i){return e(this,t,r,i)}})},24614(e,t,r){"use strict";var i=r(1508),n=r(86045).forEach,s=i.aTypedArray;(0,i.exportTypedArrayMethod)("forEach",function(e){n(s(this),e,arguments.length>1?arguments[1]:void 0)})},25641(e,t,r){"use strict";var i=r(18645);(0,r(1508).exportTypedArrayStaticMethod)("from",r(55491),i)},35104(e,t,r){"use strict";var i=r(1508),n=r(69457).includes,s=i.aTypedArray;(0,i.exportTypedArrayMethod)("includes",function(e){return n(s(this),e,arguments.length>1?arguments[1]:void 0)})},6923(e,t,r){"use strict";var i=r(1508),n=r(69457).indexOf,s=i.aTypedArray;(0,i.exportTypedArrayMethod)("indexOf",function(e){return n(s(this),e,arguments.length>1?arguments[1]:void 0)})},23035(e,t,r){"use strict";r(55679)("Int16",function(e){return function(t,r,i){return e(this,t,r,i)}})},30021(e,t,r){"use strict";r(55679)("Int32",function(e){return function(t,r,i){return e(this,t,r,i)}})},42130(e,t,r){"use strict";r(55679)("Int8",function(e){return function(t,r,i){return e(this,t,r,i)}})},43783(e,t,r){"use strict";var i=r(98896),n=r(70383),s=r(3712),o=r(1508),a=r(22080),l=r(56547)("iterator"),c=i.Uint8Array,u=s(a.values),d=s(a.keys),h=s(a.entries),f=o.aTypedArray,p=o.exportTypedArrayMethod,g=c&&c.prototype,m=!n(function(){g[l].call([1])}),y=!!g&&g.values&&g[l]===g.values&&"values"===g.values.name,v=function(){return u(f(this))};p("entries",function(){return h(f(this))},m),p("keys",function(){return d(f(this))},m),p("values",v,m||!y,{name:"values"}),p(l,v,m||!y,{name:"values"})},44793(e,t,r){"use strict";var i=r(1508),n=r(3712),s=i.aTypedArray,o=i.exportTypedArrayMethod,a=n([].join);o("join",function(e){return a(s(this),e)})},44076(e,t,r){"use strict";var i=r(1508),n=r(97321),s=r(82443),o=i.aTypedArray;(0,i.exportTypedArrayMethod)("lastIndexOf",function(e){var t=arguments.length;return n(s,o(this),t>1?[e,arguments[1]]:[e])})},60531(e,t,r){"use strict";var i=r(1508),n=r(86045).map,s=r(88108),o=i.aTypedArray;(0,i.exportTypedArrayMethod)("map",function(e){var t=n(o(this),e,arguments.length>1?arguments[1]:void 0);return s(this,t)})},35752(e,t,r){"use strict";var i=r(1508),n=r(18645),s=i.aTypedArrayConstructor;(0,i.exportTypedArrayStaticMethod)("of",function(){for(var e=0,t=arguments.length,r=new(s(this))(t);t>e;)r[e]=arguments[e++];return r},n)},56344(e,t,r){"use strict";var i=r(1508),n=r(10222).right,s=i.aTypedArray;(0,i.exportTypedArrayMethod)("reduceRight",function(e){var t=arguments.length;return n(s(this),e,t,t>1?arguments[1]:void 0)})},96871(e,t,r){"use strict";var i=r(1508),n=r(10222).left,s=i.aTypedArray;(0,i.exportTypedArrayMethod)("reduce",function(e){var t=arguments.length;return n(s(this),e,t,t>1?arguments[1]:void 0)})},19643(e,t,r){"use strict";var i=r(1508),n=i.aTypedArray,s=i.exportTypedArrayMethod,o=Math.floor;s("reverse",function(){for(var e,t=this,r=n(t).length,i=o(r/2),s=0;s1?arguments[1]:void 0,1),r=l(e);if(m)return n(f,this,r,t);var i=this.length,s=o(r),c=0;if(s+t>i)throw new u("Wrong length");for(;cn;)c[n]=r[n++];return c},n(function(){new Int8Array(1).slice()}))},34245(e,t,r){"use strict";var i=r(1508),n=r(86045).some,s=i.aTypedArray;(0,i.exportTypedArrayMethod)("some",function(e){return n(s(this),e,arguments.length>1?arguments[1]:void 0)})},31173(e,t,r){"use strict";var i=r(98896),n=r(89412),s=r(70383),o=r(18522),a=r(35656),l=r(1508),c=r(87165),u=r(14675),d=r(54863),h=r(15047),f=l.aTypedArray,p=l.exportTypedArrayMethod,g=i.Uint16Array,m=g&&n(g.prototype.sort),y=!(!m||s(function(){m(new g(2),null)})&&s(function(){m(new g(2),{})})),v=!!m&&!s(function(){if(d)return d<74;if(c)return c<67;if(u)return!0;if(h)return h<602;var e,t,r=new g(516),i=Array(516);for(e=0;e<516;e++)t=e%4,r[e]=515-e,i[e]=e-2*t+3;for(m(r,function(e,t){return(e/4|0)-(t/4|0)}),e=0;e<516;e++)if(r[e]!==i[e])return!0});p("sort",function(e){return void 0!==e&&o(e),v?m(this,e):a(f(this),function(e){return function(t,r){return void 0!==e?+e(t,r)||0:r!=r?-1:t!=t?1:0===t&&0===r?1/t>0&&1/r<0?1:-1:t>r}}(e))},!v||y)},48966(e,t,r){"use strict";var i=r(1508),n=r(47214),s=r(8810),o=i.aTypedArray,a=i.getTypedArrayConstructor;(0,i.exportTypedArrayMethod)("subarray",function(e,t){var r=o(this),i=r.length,l=s(e,i);return new(a(r))(r.buffer,r.byteOffset+l*r.BYTES_PER_ELEMENT,n((void 0===t?i:s(t,i))-l))})},88717(e,t,r){"use strict";var i=r(98896),n=r(97321),s=r(1508),o=r(70383),a=r(96496),l=i.Int8Array,c=s.aTypedArray,u=s.exportTypedArrayMethod,d=[].toLocaleString,h=!!l&&o(function(){d.call(new l(1))});u("toLocaleString",function(){return n(d,h?a(c(this)):c(this),a(arguments))},o(function(){return[1,2].toLocaleString()!==new l([1,2]).toLocaleString()})||!o(function(){l.prototype.toLocaleString.call([1,2])}))},31812(e,t,r){"use strict";var i=r(1508).exportTypedArrayMethod,n=r(70383),s=r(98896),o=r(3712),a=s.Uint8Array,l=a&&a.prototype||{},c=[].toString,u=o([].join);n(function(){c.call({})})&&(c=function(){return u(this)});var d=l.toString!==c;i("toString",c,d)},44282(e,t,r){"use strict";r(55679)("Uint16",function(e){return function(t,r,i){return e(this,t,r,i)}})},57308(e,t,r){"use strict";r(55679)("Uint32",function(e){return function(t,r,i){return e(this,t,r,i)}})},34881(e,t,r){"use strict";r(55679)("Uint8",function(e){return function(t,r,i){return e(this,t,r,i)}})},23526(e,t,r){"use strict";r(55679)("Uint8",function(e){return function(t,r,i){return e(this,t,r,i)}},!0)},44962(e,t,r){"use strict";var i,n=r(78552),s=r(98896),o=r(3712),a=r(51303),l=r(3787),c=r(23332),u=r(76569),d=r(70930),h=r(92733).enforce,f=r(70383),p=r(87534),g=Object,m=Array.isArray,y=g.isExtensible,v=g.isFrozen,b=g.isSealed,E=g.freeze,A=g.seal,T=!s.ActiveXObject&&"ActiveXObject"in s,w=function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},S=c("WeakMap",w,u),k=S.prototype,L=o(k.set);if(p)if(T){i=u.getConstructor(w,"WeakMap",!0),l.enable();var x=o(k.delete),R=o(k.has),P=o(k.get);a(k,{delete:function(e){if(d(e)&&!y(e)){var t=h(this);return t.frozen||(t.frozen=new i),x(this,e)||t.frozen.delete(e)}return x(this,e)},has:function(e){if(d(e)&&!y(e)){var t=h(this);return t.frozen||(t.frozen=new i),R(this,e)||t.frozen.has(e)}return R(this,e)},get:function(e){if(d(e)&&!y(e)){var t=h(this);return t.frozen||(t.frozen=new i),R(this,e)?P(this,e):t.frozen.get(e)}return P(this,e)},set:function(e,t){if(d(e)&&!y(e)){var r=h(this);r.frozen||(r.frozen=new i),R(this,e)?L(this,e,t):r.frozen.set(e,t)}else L(this,e,t);return this}})}else n&&f(function(){var e=E([]);return L(new S,e,1),!v(e)})&&a(k,{set:function(e,t){var r;return m(e)&&(v(e)?r=E:b(e)&&(r=A)),L(this,e,t),r&&r(e),this}})},1628(e,t,r){"use strict";r(44962)},85064(e,t,r){"use strict";r(23332)("WeakSet",function(e){return function(){return e(this,arguments.length?arguments[0]:void 0)}},r(76569))},6878(e,t,r){"use strict";r(85064)},97424(e,t,r){"use strict";var i=r(45286),n=r(98896),s=r(4201).clear;i({global:!0,bind:!0,enumerable:!0,forced:n.clearImmediate!==s},{clearImmediate:s})},90620(e,t,r){"use strict";var i=r(98896),n=r(67448),s=r(91760),o=r(61611),a=r(96091),l=function(e){if(e&&e.forEach!==o)try{a(e,"forEach",o)}catch(t){e.forEach=o}};for(var c in n)n[c]&&l(i[c]&&i[c].prototype);l(s)},59993(e,t,r){"use strict";var i=r(98896),n=r(67448),s=r(91760),o=r(22080),a=r(96091),l=r(7023),c=r(56547)("iterator"),u=o.values,d=function(e,t){if(e){if(e[c]!==u)try{a(e,c,u)}catch(t){e[c]=u}if(l(e,t,!0),n[t])for(var r in o)if(e[r]!==o[r])try{a(e,r,o[r])}catch(t){e[r]=o[r]}}};for(var h in n)d(i[h]&&i[h].prototype,h);d(s,"DOMTokenList")},75640(e,t,r){"use strict";r(97424),r(96781)},8874(e,t,r){"use strict";var i=r(45286),n=r(98896),s=r(69251),o=r(18522),a=r(32076),l=r(70383),c=r(20092);i({global:!0,enumerable:!0,dontCallGetSet:!0,forced:l(function(){return c&&1!==Object.getOwnPropertyDescriptor(n,"queueMicrotask").value.length})},{queueMicrotask:function(e){a(arguments.length,1),s(o(e))}})},96781(e,t,r){"use strict";var i=r(45286),n=r(98896),s=r(4201).set,o=r(19552),a=n.setImmediate?o(s,!1):s;i({global:!0,bind:!0,enumerable:!0,forced:n.setImmediate!==a},{setImmediate:a})},71862(e,t,r){"use strict";r(22080),r(5881);var i=r(45286),n=r(98896),s=r(9981),o=r(97671),a=r(91661),l=r(3712),c=r(20092),u=r(10984),d=r(13368),h=r(27402),f=r(51303),p=r(7023),g=r(65626),m=r(92733),y=r(10983),v=r(97157),b=r(47121),E=r(81024),A=r(98731),T=r(82007),w=r(70930),S=r(55135),k=r(65416),L=r(36788),x=r(63153),R=r(59667),P=r(2545),I=r(32076),C=r(56547),_=r(35656),O=C("iterator"),D="URLSearchParams",M=D+"Iterator",N=m.set,F=m.getterFor(D),B=m.getterFor(M),U=s("fetch"),j=s("Request"),$=s("Headers"),V=j&&j.prototype,H=$&&$.prototype,G=n.TypeError,K=n.encodeURIComponent,W=String.fromCharCode,q=o("String","fromCodePoint"),z=parseInt,Y=l("".charAt),X=l([].join),Q=l([].push),J=l("".replace),Z=l([].shift),ee=l([].splice),te=l("".split),re=l("".slice),ie=l(/./.exec),ne=/\+/g,se=/^[0-9a-f]+$/i,oe=function(e,t){var r=re(e,t,t+2);return ie(se,r)?z(r,16):NaN},ae=function(e){for(var t=0,r=128;r>0&&0!==(e&r);r>>=1)t++;return t},le=function(e){var t=null;switch(e.length){case 1:t=e[0];break;case 2:t=(31&e[0])<<6|63&e[1];break;case 3:t=(15&e[0])<<12|(63&e[1])<<6|63&e[2];break;case 4:t=(7&e[0])<<18|(63&e[1])<<12|(63&e[2])<<6|63&e[3]}return t>1114111?null:t},ce=function(e){for(var t=(e=J(e,ne," ")).length,r="",i=0;it){r+="%",i++;continue}var s=oe(e,i+1);if(s!=s){r+=n,i++;continue}i+=2;var o=ae(s);if(0===o)n=W(s);else{if(1===o||o>4){r+="�",i++;continue}for(var a=[s],l=1;lt||"%"!==Y(e,i));){var c=oe(e,i+1);if(c!=c){i+=3;break}if(c>191||c<128)break;Q(a,c),i+=2,l++}if(a.length!==o){r+="�";continue}var u=le(a);null===u?r+="�":n=q(u)}}r+=n,i++}return r},ue=/[!'()~]|%20/g,de={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},he=function(e){return de[e]},fe=function(e){return J(K(e),ue,he)},pe=g(function(e,t){N(this,{type:M,target:F(e).entries,index:0,kind:t})},D,function(){var e=B(this),t=e.target,r=e.index++;if(!t||r>=t.length)return e.target=null,P(void 0,!0);var i=t[r];switch(e.kind){case"keys":return P(i.key,!1);case"values":return P(i.value,!1)}return P([i.key,i.value],!1)},!0),ge=function(e){this.entries=[],this.url=null,void 0!==e&&(w(e)?this.parseObject(e):this.parseQuery("string"==typeof e?"?"===Y(e,0)?re(e,1):e:S(e)))};ge.prototype={type:D,bindURL:function(e){this.url=e,this.update()},parseObject:function(e){var t,r,i,n,s,o,l,c=this.entries,u=R(e);if(u)for(r=(t=x(e,u)).next;!(i=a(r,t)).done;){if(s=(n=x(T(i.value))).next,(o=a(s,n)).done||(l=a(s,n)).done||!a(s,n).done)throw new G("Expected sequence with length 2");Q(c,{key:S(o.value),value:S(l.value)})}else for(var d in e)b(e,d)&&Q(c,{key:d,value:S(e[d])})},parseQuery:function(e){if(e)for(var t,r,i=this.entries,n=te(e,"&"),s=0;s0?arguments[0]:void 0));c||(this.size=e.entries.length)},ye=me.prototype;if(f(ye,{append:function(e,t){var r=F(this);I(arguments.length,2),Q(r.entries,{key:S(e),value:S(t)}),c||this.size++,r.updateURL()},delete:function(e){for(var t=F(this),r=I(arguments.length,1),i=t.entries,n=S(e),s=r<2?void 0:arguments[1],o=void 0===s?s:S(s),a=0;at.key?1:-1}),e.updateURL()},forEach:function(e){for(var t,r=F(this).entries,i=E(e,arguments.length>1?arguments[1]:void 0),n=0;n1?Ee(arguments[1]):{})}}),v(j)){var Ae=function(e){return y(this,V),new j(e,arguments.length>1?Ee(arguments[1]):{})};V.constructor=Ae,Ae.prototype=V,i({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Ae})}}e.exports={URLSearchParams:me,getState:F}},98344(e,t,r){"use strict";r(71862)},79230(e,t,r){"use strict";r(52740);var i,n=r(45286),s=r(20092),o=r(10984),a=r(98896),l=r(81024),c=r(3712),u=r(13368),d=r(27402),h=r(10983),f=r(47121),p=r(28901),g=r(33868),m=r(96496),y=r(54087).codeAt,v=r(71605),b=r(55135),E=r(7023),A=r(32076),T=r(71862),w=r(92733),S=w.set,k=w.getterFor("URL"),L=T.URLSearchParams,x=T.getState,R=a.URL,P=a.TypeError,I=a.parseInt,C=Math.floor,_=Math.pow,O=c("".charAt),D=c(/./.exec),M=c([].join),N=c(1.1.toString),F=c([].pop),B=c([].push),U=c("".replace),j=c([].shift),$=c("".split),V=c("".slice),H=c("".toLowerCase),G=c([].unshift),K="Invalid scheme",W="Invalid host",q="Invalid port",z=/[a-z]/i,Y=/[\d+-.a-z]/i,X=/\d/,Q=/^0x/i,J=/^[0-7]+$/,Z=/^\d+$/,ee=/^[\da-f]+$/i,te=/[\0\t\n\r #%/:<>?@[\\\]^|]/,re=/[\0\t\n\r #/:<>?@[\\\]^|]/,ie=/^[\u0000-\u0020]+/,ne=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,se=/[\t\n\r]/g,oe=function(e){var t,r,i,n;if("number"==typeof e){for(t=[],r=0;r<4;r++)G(t,e%256),e=C(e/256);return M(t,".")}if("object"==typeof e){for(t="",i=function(e){for(var t=null,r=1,i=null,n=0,s=0;s<8;s++)0!==e[s]?(n>r&&(t=i,r=n),i=null,n=0):(null===i&&(i=s),++n);return n>r?i:t}(e),r=0;r<8;r++)n&&0===e[r]||(n&&(n=!1),i===r?(t+=r?":":"::",n=!0):(t+=N(e[r],16),r<7&&(t+=":")));return"["+t+"]"}return e},ae={},le=p({},ae,{" ":1,'"':1,"<":1,">":1,"`":1}),ce=p({},le,{"#":1,"?":1,"{":1,"}":1}),ue=p({},ce,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),de=function(e,t){var r=y(e,0);return r>32&&r<127&&!f(t,e)?e:encodeURIComponent(e)},he={ftp:21,file:null,http:80,https:443,ws:80,wss:443},fe=function(e,t){var r;return 2===e.length&&D(z,O(e,0))&&(":"===(r=O(e,1))||!t&&"|"===r)},pe=function(e){var t;return e.length>1&&fe(V(e,0,2))&&(2===e.length||"/"===(t=O(e,2))||"\\"===t||"?"===t||"#"===t)},ge=function(e){return"."===e||"%2e"===H(e)},me=function(e){return".."===(e=H(e))||"%2e."===e||".%2e"===e||"%2e%2e"===e},ye={},ve={},be={},Ee={},Ae={},Te={},we={},Se={},ke={},Le={},xe={},Re={},Pe={},Ie={},Ce={},_e={},Oe={},De={},Me={},Ne={},Fe={},Be=function(e,t,r){var i,n,s,o=b(e);if(t){if(n=this.parse(o))throw new P(n);this.searchParams=null}else{if(void 0!==r&&(i=new Be(r,!0)),n=this.parse(o,null,i))throw new P(n);(s=x(new L)).bindURL(this),this.searchParams=s}};Be.prototype={type:"URL",parse:function(e,t,r){var n,s,o,a,l=this,c=t||ye,u=0,d="",h=!1,p=!1,y=!1;for(e=b(e),t||(l.scheme="",l.username="",l.password="",l.host=null,l.port=null,l.path=[],l.query=null,l.fragment=null,l.cannotBeABaseURL=!1,e=U(e,ie,""),e=U(e,ne,"$1")),e=U(e,se,""),n=g(e);u<=n.length;){switch(s=n[u],c){case ye:if(!s||!D(z,s)){if(t)return K;c=be;continue}d+=H(s),c=ve;break;case ve:if(s&&(D(Y,s)||"+"===s||"-"===s||"."===s))d+=H(s);else{if(":"!==s){if(t)return K;d="",c=be,u=0;continue}if(t&&(l.isSpecial()!==f(he,d)||"file"===d&&(l.includesCredentials()||null!==l.port)||"file"===l.scheme&&!l.host))return;if(l.scheme=d,t)return void(l.isSpecial()&&he[l.scheme]===l.port&&(l.port=null));d="","file"===l.scheme?c=Ie:l.isSpecial()&&r&&r.scheme===l.scheme?c=Ee:l.isSpecial()?c=Se:"/"===n[u+1]?(c=Ae,u++):(l.cannotBeABaseURL=!0,B(l.path,""),c=Me)}break;case be:if(!r||r.cannotBeABaseURL&&"#"!==s)return K;if(r.cannotBeABaseURL&&"#"===s){l.scheme=r.scheme,l.path=m(r.path),l.query=r.query,l.fragment="",l.cannotBeABaseURL=!0,c=Fe;break}c="file"===r.scheme?Ie:Te;continue;case Ee:if("/"!==s||"/"!==n[u+1]){c=Te;continue}c=ke,u++;break;case Ae:if("/"===s){c=Le;break}c=De;continue;case Te:if(l.scheme=r.scheme,s===i)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=m(r.path),l.query=r.query;else if("/"===s||"\\"===s&&l.isSpecial())c=we;else if("?"===s)l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=m(r.path),l.query="",c=Ne;else{if("#"!==s){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=m(r.path),l.path.length--,c=De;continue}l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,l.path=m(r.path),l.query=r.query,l.fragment="",c=Fe}break;case we:if(!l.isSpecial()||"/"!==s&&"\\"!==s){if("/"!==s){l.username=r.username,l.password=r.password,l.host=r.host,l.port=r.port,c=De;continue}c=Le}else c=ke;break;case Se:if(c=ke,"/"!==s||"/"!==O(d,u+1))continue;u++;break;case ke:if("/"!==s&&"\\"!==s){c=Le;continue}break;case Le:if("@"===s){h&&(d="%40"+d),h=!0,o=g(d);for(var v=0;v65535)return q;l.port=l.isSpecial()&&T===he[l.scheme]?null:T,d=""}if(t)return;c=Oe;continue}return q}d+=s;break;case Ie:if(l.scheme="file","/"===s||"\\"===s)c=Ce;else{if(!r||"file"!==r.scheme){c=De;continue}switch(s){case i:l.host=r.host,l.path=m(r.path),l.query=r.query;break;case"?":l.host=r.host,l.path=m(r.path),l.query="",c=Ne;break;case"#":l.host=r.host,l.path=m(r.path),l.query=r.query,l.fragment="",c=Fe;break;default:pe(M(m(n,u),""))||(l.host=r.host,l.path=m(r.path),l.shortenPath()),c=De;continue}}break;case Ce:if("/"===s||"\\"===s){c=_e;break}r&&"file"===r.scheme&&!pe(M(m(n,u),""))&&(fe(r.path[0],!0)?B(l.path,r.path[0]):l.host=r.host),c=De;continue;case _e:if(s===i||"/"===s||"\\"===s||"?"===s||"#"===s){if(!t&&fe(d))c=De;else if(""===d){if(l.host="",t)return;c=Oe}else{if(a=l.parseHost(d))return a;if("localhost"===l.host&&(l.host=""),t)return;d="",c=Oe}continue}d+=s;break;case Oe:if(l.isSpecial()){if(c=De,"/"!==s&&"\\"!==s)continue}else if(t||"?"!==s)if(t||"#"!==s){if(s!==i&&(c=De,"/"!==s))continue}else l.fragment="",c=Fe;else l.query="",c=Ne;break;case De:if(s===i||"/"===s||"\\"===s&&l.isSpecial()||!t&&("?"===s||"#"===s)){if(me(d)?(l.shortenPath(),"/"===s||"\\"===s&&l.isSpecial()||B(l.path,"")):ge(d)?"/"===s||"\\"===s&&l.isSpecial()||B(l.path,""):("file"===l.scheme&&!l.path.length&&fe(d)&&(l.host&&(l.host=""),d=O(d,0)+":"),B(l.path,d)),d="","file"===l.scheme&&(s===i||"?"===s||"#"===s))for(;l.path.length>1&&""===l.path[0];)j(l.path);"?"===s?(l.query="",c=Ne):"#"===s&&(l.fragment="",c=Fe)}else d+=de(s,ce);break;case Me:"?"===s?(l.query="",c=Ne):"#"===s?(l.fragment="",c=Fe):s!==i&&(l.path[0]+=de(s,ae));break;case Ne:t||"#"!==s?s!==i&&("'"===s&&l.isSpecial()?l.query+="%27":l.query+="#"===s?"%23":de(s,ae)):(l.fragment="",c=Fe);break;case Fe:s!==i&&(l.fragment+=de(s,le))}u++}},parseHost:function(e){var t,r,i;if("["===O(e,0)){if("]"!==O(e,e.length-1))return W;if(t=function(e){var t,r,i,n,s,o,a,l=[0,0,0,0,0,0,0,0],c=0,u=null,d=0,h=function(){return O(e,d)};if(":"===h()){if(":"!==O(e,1))return;d+=2,u=++c}for(;h();){if(8===c)return;if(":"!==h()){for(t=r=0;r<4&&D(ee,h());)t=16*t+I(h(),16),d++,r++;if("."===h()){if(0===r)return;if(d-=r,c>6)return;for(i=0;h();){if(n=null,i>0){if(!("."===h()&&i<4))return;d++}if(!D(X,h()))return;for(;D(X,h());){if(s=I(h(),10),null===n)n=s;else{if(0===n)return;n=10*n+s}if(n>255)return;d++}l[c]=256*l[c]+n,2!==++i&&4!==i||c++}if(4!==i)return;break}if(":"===h()){if(d++,!h())return}else if(h())return;l[c++]=t}else{if(null!==u)return;d++,u=++c}}if(null!==u)for(o=c-u,c=7;0!==c&&o>0;)a=l[c],l[c--]=l[u+o-1],l[u+--o]=a;else if(8!==c)return;return l}(V(e,1,-1)),!t)return W;this.host=t}else if(this.isSpecial()){if(e=v(e),D(te,e))return W;if(t=function(e){var t,r,i,n,s,o,a,l=$(e,".");if(l.length&&""===l[l.length-1]&&l.length--,(t=l.length)>4)return e;for(r=[],i=0;i1&&"0"===O(n,0)&&(s=D(Q,n)?16:8,n=V(n,8===s?1:2)),""===n)o=0;else{if(!D(10===s?Z:8===s?J:ee,n))return e;o=I(n,s)}B(r,o)}for(i=0;i=_(256,5-t))return null}else if(o>255)return null;for(a=F(r),i=0;i1?arguments[1]:void 0,i=S(t,new Be(e,!1,r));s||(t.href=i.serialize(),t.origin=i.getOrigin(),t.protocol=i.getProtocol(),t.username=i.getUsername(),t.password=i.getPassword(),t.host=i.getHost(),t.hostname=i.getHostname(),t.port=i.getPort(),t.pathname=i.getPathname(),t.search=i.getSearch(),t.searchParams=i.getSearchParams(),t.hash=i.getHash())},je=Ue.prototype,$e=function(e,t){return{get:function(){return k(this)[e]()},set:t&&function(e){return k(this)[t](e)},configurable:!0,enumerable:!0}};if(s&&(d(je,"href",$e("serialize","setHref")),d(je,"origin",$e("getOrigin")),d(je,"protocol",$e("getProtocol","setProtocol")),d(je,"username",$e("getUsername","setUsername")),d(je,"password",$e("getPassword","setPassword")),d(je,"host",$e("getHost","setHost")),d(je,"hostname",$e("getHostname","setHostname")),d(je,"port",$e("getPort","setPort")),d(je,"pathname",$e("getPathname","setPathname")),d(je,"search",$e("getSearch","setSearch")),d(je,"searchParams",$e("getSearchParams")),d(je,"hash",$e("getHash","setHash"))),u(je,"toJSON",function(){return k(this).serialize()},{enumerable:!0}),u(je,"toString",function(){return k(this).serialize()},{enumerable:!0}),R){var Ve=R.createObjectURL,He=R.revokeObjectURL;Ve&&u(Ue,"createObjectURL",l(Ve,R)),He&&u(Ue,"revokeObjectURL",l(He,R))}E(Ue,"URL"),n({global:!0,constructor:!0,forced:!o,sham:!s},{URL:Ue})},32848(e,t,r){"use strict";r(79230)},76568(e,t,r){"use strict";var i=r(45286),n=r(91661);i({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return n(URL.prototype.toString,this)}})},94066(e,t,r){"use strict";function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}r.d(t,{A:()=>i})},17431(e){"use strict";e.exports=JSON.parse('{"name":"axios","version":"0.21.4","description":"Promise based HTTP client for the browser and node.js","main":"index.js","scripts":{"test":"grunt test","start":"node ./sandbox/server.js","build":"NODE_ENV=production grunt build","preversion":"npm test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json","postversion":"git push && git push --tags","examples":"node ./examples/server.js","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","fix":"eslint --fix lib/**/*.js"},"repository":{"type":"git","url":"https://github.com/axios/axios.git"},"keywords":["xhr","http","ajax","promise","node"],"author":"Matt Zabriskie","license":"MIT","bugs":{"url":"https://github.com/axios/axios/issues"},"homepage":"https://axios-http.com","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"jsdelivr":"dist/axios.min.js","unpkg":"dist/axios.min.js","typings":"./index.d.ts","dependencies":{"follow-redirects":"^1.14.0"},"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}]}')}},i={};function n(e){var t=i[e];if(void 0!==t)return t.exports;var s=i[e]={exports:{}};return r[e].call(s.exports,s,s.exports,n),s.exports}n.m=r,n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.f={},n.e=e=>Promise.all(Object.keys(n.f).reduce((t,r)=>(n.f[r](e,t),t),[])),n.u=e=>e+".js",n.miniCssF=e=>{},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},t="website-component-definitions:",n.l=(r,i,s,o)=>{if(e[r])e[r].push(i);else{var a,l;if(void 0!==s)for(var c=document.getElementsByTagName("script"),u=0;u{a.onerror=a.onload=null,clearTimeout(f);var n=e[r];if(delete e[r],a.parentNode&&a.parentNode.removeChild(a),n&&n.forEach(e=>e(i)),t)return t(i)},f=setTimeout(h.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=h.bind(null,a.onerror),a.onload=h.bind(null,a.onload),l&&document.head.appendChild(a)}},n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var e;globalThis.importScripts&&(e=globalThis.location+"");var t=globalThis.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var i=r.length-1;i>-1&&(!e||!/^http(s?):/.test(e));)e=r[i--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e})(),(()=>{var e={403:0,8018:0};n.f.j=(t,r)=>{var i=n.o(e,t)?e[t]:void 0;if(0!==i)if(i)r.push(i[2]);else{var s=new Promise((r,n)=>i=e[t]=[r,n]);r.push(i[2]=s);var o=n.p+n.u(t),a=new Error;n.l(o,r=>{if(n.o(e,t)&&(0!==(i=e[t])&&(e[t]=void 0),i)){var s=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src;a.message="Loading chunk "+t+" failed.\n("+s+": "+o+")",a.name="ChunkLoadError",a.type=s,a.request=o,i[1](a)}},"chunk-"+t,t)}};var t=(t,r)=>{var i,s,[o,a,l]=r,c=0;if(o.some(t=>0!==e[t])){for(i in a)n.o(a,i)&&(n.m[i]=a[i]);l&&l(n)}for(t&&t(r);c{"use strict";n.r(s),n.d(s,{Visitor:()=>hl,default:()=>fl});var e=n(94066);function t(t){var r=function(t){if("object"!=(0,e.A)(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,"string");if("object"!=(0,e.A)(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==(0,e.A)(r)?r:r+""}function r(e,r,i){return(r=t(r))in e?Object.defineProperty(e,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[r]=i,e}let i=!1,o=!1,a=!1,l=!1;"undefined"!=typeof window&&"CSS"in window&&"function"==typeof CSS.supports&&(i="Animation"in window,"ViewTimeline"in window&&CSS.supports("animation-range","entry 0% exit 100%"),a="registerProperty"in CSS,CSS.supports("animation-timing-function","linear(0, 0.25 75%, 1)"));const c=i&&a,u=()=>window.__sqsAnimationRuntime;function d(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function h(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const f="[object String]",p="[object Number]",g="[object Boolean]",m="[object Arguments]",y="[object Object]";function v(e){return null==e||"object"!=typeof e&&"function"!=typeof e}function b(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function E(e,t,r,i=new Map,n=void 0){const s=n?.(e,t,r,i);if(void 0!==s)return s;if(v(e))return e;if(i.has(e))return i.get(e);if(Array.isArray(e)){const t=new Array(e.length);i.set(e,t);for(let s=0;s{const o=t?.(r,i,n,s);if(void 0!==o)return o;if("object"==typeof e){if(h(e)===y&&"function"!=typeof e.constructor){const t={};return s.set(e,t),A(t,e,n,s),t}switch(Object.prototype.toString.call(e)){case p:case f:case g:{const t=new e.constructor(e?.valueOf());return A(t,e),t}case m:{const t={};return A(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}}})}(e)}function w(e){return"__proto__"===e}function S(e){return null!==e&&"object"==typeof e&&"[object Arguments]"===h(e)}function k(e){return"object"==typeof e&&null!==e}function L(e){return k(e)&&function(e){return null!=e&&"function"!=typeof e&&function(e){return Number.isSafeInteger(e)&&e>=0}(e.length)}(e)}function x(e){if("object"!=typeof e)return!1;if(null==e)return!1;if(null===Object.getPrototypeOf(e))return!0;if("[object Object]"!==Object.prototype.toString.call(e)){const t=e[Symbol.toStringTag];return null!=t&&(!!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable&&e.toString()===`[object ${t}]`)}let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function R(e){return b(e)}function P(e,t,r,i){if(v(e)&&(e=Object(e)),null==t||"object"!=typeof t)return e;if(i.has(t))return function(e){if(v(e))return e;if(Array.isArray(e)||b(e)||e instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer)return e.slice(0);const t=Object.getPrototypeOf(e);if(null==t)return Object.assign(Object.create(t),e);const r=t.constructor;if(e instanceof Date||e instanceof Map||e instanceof Set)return new r(e);if(e instanceof RegExp){const t=new r(e);return t.lastIndex=e.lastIndex,t}if(e instanceof DataView)return new r(e.buffer.slice(0));if(e instanceof Error){let t;return t=e instanceof AggregateError?new r(e.errors,e.message,{cause:e.cause}):new r(e.message,{cause:e.cause}),t.stack=e.stack,Object.assign(t,e),t}if("undefined"!=typeof File&&e instanceof File)return new r([e],e.name,{type:e.type,lastModified:e.lastModified});if("object"==typeof e){const r=Object.create(t);return Object.assign(r,e)}return e}(i.get(t));if(i.set(t,e),Array.isArray(t)){t=t.slice();for(let e=0;e(e.maxWidth?parseInt(e.maxWidth):1/0)-(t.maxWidth?parseInt(t.maxWidth):1/0)),r=document.documentElement.clientWidth;return t.find(e=>{if((null!=e&&e.maxWidth?parseInt(e.maxWidth):Number.MAX_SAFE_INTEGER)>r)return e})??e[0]??null}function _(e,t){if(!t||null==e||!e.breakpointOverrides)return e;const r=e.breakpointOverrides[t.id];return r?function(e,...t){return function(e,...t){const r=t.slice(0,-1),i=t[t.length-1];let n=e;for(let e=0;e1&&void 0!==arguments[1]&&arguments[1];if(r(this,"componentId",""),r(this,"processedValue",null),r(this,"previousBreakpoint",null),r(this,"resizeListener",null),r(this,"handlePrefersReducedMotionChange",e=>{e?(this.destroyAnimations(),this.detachResizeListener()):(this.parseBlockData(),this.attachResizeListener(),this.createAnimations())}),this.root=e,this.root=e,!c)return void this.removePrerender();this.componentId=(null===(t=this.root.closest("[data-website-component-id]"))||void 0===t?void 0:t.dataset.websiteComponentId)??"";const a=null===(i=this.root.parentElement)||void 0===i?void 0:i.classList.contains("pseudo-engine__block");o||a||(this.prefersReducedMotionUnsub=null===(n=u())||void 0===n||null===(s=n.registerReducedMotionChangeHandler)||void 0===s?void 0:s.call(n,this.handlePrefersReducedMotionChange),window.matchMedia("(prefers-reduced-motion: reduce)").matches||this.attachResizeListener())}processBreakpointOverrideValue(){var e,t;this.overridesData||this.parseBlockData();const r=null===(e=this.overridesData)||void 0===e?void 0:e.websitesBreakpoints;if(null===(t=this.overridesData)||void 0===t||!t.isOverridesEnabled||!r)return;const i=C(r);this.processedValue=_(this.blockData,i)}removePrerender(){var e;null===(e=this.root.querySelector("style[data-block-animations-prerender]"))||void 0===e||e.remove()}parseBlockData(){const e=this.root.querySelector(`script[data-block-animations="${this.componentId||""}"]`);if(!e)return this.blockData={animations:[],transforms:{},componentId:this.componentId},void(this.overridesData={isOverridesEnabled:!1,websitesBreakpoints:void 0});const t=JSON.parse(String(e.textContent)),{isOverridesEnabled:r,websitesBreakpoints:i,...n}=t;this.overridesData={isOverridesEnabled:r,websitesBreakpoints:i},this.blockData=n,this.processBreakpointOverrideValue()}attachResizeListener(){var e,t;if(this.resizeListener)return;this.blockData||this.parseBlockData();const r=null===(e=this.overridesData)||void 0===e?void 0:e.websitesBreakpoints;var i;null!==(t=this.overridesData)&&void 0!==t&&t.isOverridesEnabled&&r&&(null!==(i=this.previousBreakpoint)&&void 0!==i&&i.id||(this.previousBreakpoint=C(r)),this.resizeListener=()=>{var e;const t=C(r);if((null===(e=this.previousBreakpoint)||void 0===e?void 0:e.id)!==(null==t?void 0:t.id)){if(this.previousBreakpoint=t,this.processBreakpointOverrideValue(),!this.root.isConnected)return;this.destroyAnimationTriggers(),this.createAnimations()}},window.addEventListener("resize",this.resizeListener))}detachResizeListener(){this.resizeListener&&(window.removeEventListener("resize",this.resizeListener),this.resizeListener=null,this.previousBreakpoint=null)}createAnimations(){var e,t;c&&this.blockData&&(this.processBreakpointOverrideValue(),this.processedValue?null===(e=u())||void 0===e||e.createAnimationTriggers(this.processedValue):null===(t=u())||void 0===t||t.createAnimationTriggers(this.blockData))}destroyAnimationTriggers(){const e=u();this.processedValue?null==e||e.destroyAnimationTriggers(this.processedValue):null==e||e.destroyAnimationTriggers(this.blockData)}destroyAnimations(){var e;null===(e=this.prefersReducedMotionUnsub)||void 0===e||e.call(this),this.blockData&&this.destroyAnimationTriggers()}updateBlockData(e,t){e&&(this.blockData||this.parseBlockData(),this.blockData={...this.blockData||{},...e},this.overridesData.websitesBreakpoints=t,this.overridesData.isOverridesEnabled=!!t,this.processBreakpointOverrideValue())}getBlockData(){var e;return this.blockData||this.parseBlockData(),null!==(e=this.overridesData)&&void 0!==e&&e.isOverridesEnabled&&(this.processBreakpointOverrideValue(),this.processedValue)?this.processedValue:this.blockData}}const D=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const r=document.createElement("div");return r.className=e,r.textContent=t,r},M=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"*";const i=e instanceof HTMLIFrameElement?e:e.querySelector("iframe"),n=null==i?void 0:i.contentWindow;if(!n)return!1;const s="string"==typeof t?t:JSON.stringify(t);try{return n.postMessage(s,r),!0}catch{return!1}};class N{constructor(e,t){r(this,"isPlaying",!1),r(this,"handleResetEvent",()=>{this.resetVideo()}),this.wrapper=e,this.isEditable=t,this.wrapper.addEventListener(N.RESET_EVENT,this.handleResetEvent)}dispatchResetToOtherVideos(){document.querySelectorAll(N.VIDEO_WRAPPER).forEach(e=>{e!==this.wrapper&&e.dispatchEvent(new CustomEvent(N.RESET_EVENT))})}}r(N,"RESET_EVENT","video:reset"),r(N,"VIDEO_WRAPPER",".sqs-video-wrapper");const F={invalidVideo:"Invalid video embed.",invalidThumbnail:"Custom featured images only available with embedded videos. Go back into embed settings to turn off featured images."};class B extends N{constructor(e,t){super(e,t),r(this,"videoNode",null),r(this,"overlay",null),r(this,"playIcon",null),r(this,"providerName",""),r(this,"playVideo",()=>{if(this.overlay&&this.videoNode)switch(this.isPlaying=!0,this.overlay.after(this.videoNode),this.videoNode.style.opacity="1",this.overlay.style.opacity="0",this.dispatchResetToOtherVideos(),this.providerName){case"Vimeo":M(this.videoNode,{method:"play",value:"true"});break;case"YouTube":M(this.videoNode,{event:"command",func:"playVideo",args:""})}}),r(this,"keyboardPlayVideo",e=>{const t="Enter"===e.key,r=" "===e.key||"Spacebar"===e.key;(t||r)&&(e.preventDefault(),this.playVideo())}),this.load()}load(){const e=this.wrapper.querySelector("img");if(this.videoNode||(this.videoNode=this.loadVideoData()),!this.videoNode||!this.isValidVideo()){const t=this.loadLocalizedStrings(),r=null!==this.wrapper.closest(".sqs-block-video"),i=e&&!r?t.invalidThumbnail:t.invalidVideo;return this.wrapper.replaceChildren(this.invalidMessage(i)),void(this.videoNode=null)}e&&window.ImageLoader?(window.ImageLoader.load(e,{load:!0}),this.overlay=this.wrapper.querySelector(".sqs-video-overlay"),this.overlay&&(this.overlay.style.opacity="1",this.setProviderProperties(),this.isEditable||this.setupPlayHandlers())):(this.wrapper.querySelector(":scope > .intrinsic > .intrinsic-inner")??this.wrapper).append(this.videoNode)}loadLocalizedStrings(){var e;const t=this.wrapper.closest("[data-localized]"),r=null==t||null===(e=t.dataset)||void 0===e?void 0:e.localized;if(!r)return F;try{const e=JSON.parse(r);return{invalidVideo:e.invalidVideo??F.invalidVideo,invalidThumbnail:e.invalidThumbnail??F.invalidThumbnail}}catch{return F}}invalidMessage(e){const t=D("sqs-video-invalid-wrapper"),r=D("state-message",e);return t.appendChild(r)}loadVideoData(){const e=this.wrapper.dataset.html;if(!e)return null;const t=document.createElement("div");return t.innerHTML=e.trim(),t.firstElementChild}isValidVideo(){var e,t;if(this.videoNode instanceof HTMLIFrameElement)return!0;if(null!==(e=this.videoNode)&&void 0!==e&&e.querySelector("iframe"))return!0;if(this.videoNode instanceof HTMLObjectElement)return!0;const r=null===(t=this.videoNode)||void 0===t?void 0:t.querySelector("object");return!!r&&!!r.querySelector("embed")}resetVideo(){if(this.videoNode){switch(this.providerName){case"Vimeo":M(this.videoNode,{method:"pause",value:"true"});break;case"YouTube":M(this.videoNode,{event:"command",func:"pauseVideo",args:""})}this.isPlaying&&this.overlay&&(this.overlay.style.opacity="1",this.videoNode.style.opacity="0",this.isPlaying=!1,setTimeout(()=>{var e;null===(e=this.videoNode)||void 0===e||e.remove(),this.clearPlayHandlers(),this.load()},1e3))}}setProviderProperties(){const e=this.videoNode,t={autoplay:"1"};this.providerName=this.wrapper.dataset.providerName||"","YouTube"===this.providerName&&(t.enablejsapi="1"),e.src=((e,t)=>{try{const r=new URL(e);for(const[e,i]of Object.entries(t))null===i?r.searchParams.delete(e):r.searchParams.set(e,i);return r.toString()}catch{return e}})(e.src,t)}setupPlayHandlers(){var e;this.overlay&&this.videoNode&&(this.overlay.addEventListener("click",this.playVideo),this.playIcon=this.overlay.querySelector(".sqs-video-icon"),null===(e=this.playIcon)||void 0===e||e.addEventListener("keydown",this.keyboardPlayVideo))}clearPlayHandlers(){var e,t;null===(e=this.overlay)||void 0===e||e.removeEventListener("click",this.playVideo),null===(t=this.playIcon)||void 0===t||t.removeEventListener("keydown",this.keyboardPlayVideo)}}n(41427),n(98215),n(32700),n(85393),n(23192),n(22435),n(80868),n(74677),n(61177),n(59483),n(97809),n(71508),n(32349),n(62806),n(79506),n(69219),n(30843),n(64648),n(62065),n(55076),n(75745),n(2334),n(93066),n(18439),n(22080),n(6),n(21278),n(99227),n(60398),n(20590),n(52454),n(7914),n(91546),n(18029),n(94567),n(30740),n(10477),n(12426),n(64651),n(19089),n(44209),n(55878),n(53781),n(92332),n(2789),n(46962),n(60382),n(11789),n(89917),n(26056),n(59968),n(18368),n(8215),n(56330),n(86889),n(65170),n(30991),n(59801),n(43996),n(5326),n(52452),n(42701),n(24006),n(9565),n(62217),n(60739),n(85700),n(63555),n(6204),n(35853),n(55843),n(69383),n(92818),n(89403),n(5201),n(36027),n(78382),n(87448),n(24155),n(53636),n(90452),n(65443),n(21741),n(88792),n(29844),n(10128),n(74559),n(17861),n(49347),n(97970),n(17298),n(48895),n(17700),n(87241),n(54211),n(23275),n(25064),n(59001),n(58837),n(88700),n(30538),n(20190),n(23993),n(37228),n(38345),n(74576),n(94391),n(62327),n(36269),n(93383),n(39012),n(22825),n(5881),n(13171),n(52740),n(11937),n(9029),n(15596),n(32994),n(57581),n(60560),n(14754),n(29480),n(41744),n(89754),n(73298),n(67631),n(25603),n(69002),n(86546),n(23457),n(50730),n(11964),n(98394),n(14749),n(70762),n(21339),n(96532),n(29342),n(3780),n(94354),n(13081),n(42130),n(23035),n(30021),n(34881),n(23526),n(44282),n(57308),n(30254),n(68954),n(40340),n(12339),n(12798),n(99091),n(24614),n(25641),n(35104),n(6923),n(43783),n(44793),n(44076),n(60531),n(35752),n(96871),n(56344),n(19643),n(37245),n(82239),n(34245),n(31173),n(48966),n(88717),n(31812),n(1628),n(6878),n(90620),n(59993),n(75640),n(8874),n(32848),n(76568),n(98344),n(82185),n(20456),n(12233);var U=function(e,t){return e.replace("{variant}",t)},j=function(e,t){return t||U(e,"thumbnail")},$="full",V="VIDEO_ABORTED_BY_USER",H="VIDEO_COULD_NOT_BE_ACCESSED",G="VIDEO_COULD_NOT_BE_DECODED",K="VIDEO_COULD_NOT_BE_PLAYED",W="VIDEO_PLAYBACK_DRIVER_UNSUPPORTED",q="VIDEO_PLAYER_INVALID_CONFIGURATION",z="VIDEO_PLAYER_UNKNOWN_MEDIA_ERROR",Y="VIDEO_PLAYER_UNEXPECTED_ERROR",X="VIDEO_PLAYER_UNAUTHORIZED";function Q(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function J(e,r){for(var i=0;i=t||(i.segmentData=de.endPositionUpdated(i.segmentData,e),i.options.onSendProgressEvent(fe(fe({},i.segmentData),{},{progressTriggerReason:"paused",currentPosition:e})),i.segmentData=de.startPositionUpdated(i.segmentData,e))}),r(this,"onEnd",function(e){i.segmentData=de.endPositionUpdated(i.segmentData,e),i.options.onSendProgressEvent(fe(fe({},i.segmentData),{},{progressTriggerReason:"ended",currentPosition:e}))}),r(this,"onPlayerAbandoned",function(){i.segmentData.progressEndPosition-i.segmentData.progressStartPosition>0&&(i.options.onSendProgressEvent(fe(fe({},i.segmentData),{},{progressTriggerReason:le,currentPosition:i.segmentData.progressEndPosition})),i.segmentData=de.startPositionUpdated(i.segmentData,i.segmentData.progressEndPosition))}),r(this,"onNewViewSessionId",function(e){i.viewSessionId=e}),this.options=t,this.viewSessionId=t.initialViewSessionId,this.segmentData=de.makeSegmentForNewSession(this.viewSessionId,0)}return Z(e,[{key:"onSeeked",value:function(e,t){if(this.hasPlayed){var r=e/t,i=this.segmentData.progressEndPosition/t>=1;i&&0===r||this.options.onSendProgressEvent(fe(fe({},this.segmentData),{},{progressTriggerReason:"seeked",currentPosition:e})),this.segmentData=de.startPositionUpdated(this.segmentData,e),i&&r<1&&(this.viewSessionId=this.options.requestNewSession(),this.segmentData=de.makeSegmentForNewSession(this.viewSessionId,e))}else this.segmentData=de.makeSegmentForNewSession(this.viewSessionId,e)}}],[{key:"shouldReportSegment",value:function(t){return t.progressEndPosition-t.progressStartPosition>=e.ReportAfterSecondsViewed}},{key:"isSeeking",value:function(t,r){return Math.abs(t-r.progressEndPosition)>=e.SeekTimeBufferInSeconds}}])}();r(pe,"SeekTimeBufferInSeconds",1.5),r(pe,"ReportAfterSecondsViewed",10);var ge=Z(function e(t){var i=this;Q(this,e),r(this,"isPlayerReady",!1),r(this,"hasViewedPlayer",!1),r(this,"onReady",function(){i.isPlayerReady=!0}),r(this,"onPlayerViewed",function(){!i.hasViewedPlayer&&i.isPlayerReady&&(i.options.onSendViewEvent({viewSessionId:i.viewSessionId}),i.hasViewedPlayer=!0)}),r(this,"onNewViewSessionId",function(e){i.viewSessionId=e}),this.options=t,this.viewSessionId=t.initialViewSessionId}),me=Z(function e(){Q(this,e)},[{key:"makeEventHooks",value:function(){var e=this;return{onReady:function(){return e.onReady()},onPlay:function(t,r){return e.onPlay(t,r)},onTimeUpdate:function(t,r){return e.onTimeUpdate(t,r)},onPause:function(t,r){return e.onPause(t,r)},onEnd:function(t,r){return e.onEnd(t,r)},onSeek:function(t,r){return e.onSeek(t,r)},onPaywallCtaClick:function(){return e.onPaywallCtaClick()}}}},{key:"onReady",value:function(){this.trackers.forEach(function(e){var t;return null===(t=e.onReady)||void 0===t?void 0:t.call(e)})}},{key:"onPlay",value:function(e,t){this.trackers.forEach(function(r){var i;return null===(i=r.onPlay)||void 0===i?void 0:i.call(r,e,t)})}},{key:"onTimeUpdate",value:function(e,t){this.trackers.forEach(function(r){var i;return null===(i=r.onTimeUpdate)||void 0===i?void 0:i.call(r,e,t)})}},{key:"onPause",value:function(e,t){this.trackers.forEach(function(r){var i;return null===(i=r.onPause)||void 0===i?void 0:i.call(r,e,t)})}},{key:"onEnd",value:function(e,t){this.trackers.forEach(function(r){var i;return null===(i=r.onEnd)||void 0===i?void 0:i.call(r,e,t)})}},{key:"onSeek",value:function(e,t){this.trackers.forEach(function(r){var i;return null===(i=r.onSeek)||void 0===i?void 0:i.call(r,e,t)})}},{key:"onPaywallCtaClick",value:function(){this.trackers.forEach(function(e){var t;return null===(t=e.onPaywallCtaClick)||void 0===t?void 0:t.call(e)})}},{key:"onNewSessionId",value:function(e){this.trackers.forEach(function(t){var r;return null===(r=t.onNewViewSessionId)||void 0===r?void 0:r.call(t,e)})}}]);function ye(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=Array(t);rr?this.setEmbedWrapperStyles(r):this.clearEmbedWrapperStyles()}},{key:"setEmbedWrapperStyles",value:function(e){this.embedWrapper&&(this.embedWrapper.classList.add(this.embedWrapperClassName),this.embedWrapper.style.width="".concat(e,"px"))}},{key:"clearEmbedWrapperStyles",value:function(){this.embedWrapper&&(this.embedWrapper.classList.remove(this.embedWrapperClassName),this.embedWrapper.style.width="")}}]);function Ce(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function _e(e){for(var t=1;tNumber.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(1&t.length?"0":"")+t;const r=new Uint8Array(t.length/2);for(let e=0;eNumber.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return"YES"===this[e]}decimalResolution(e){const t=it.exec(this[e]);if(null!==t)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const r={};for(nt.lastIndex=0;null!==(t=nt.exec(e));){let e=t[2];0===e.indexOf('"')&&e.lastIndexOf('"')===e.length-1&&(e=e.slice(1,-1)),r[t[1].trim()]=e}return r}}function ot(e){return"ID"!==e&&"CLASS"!==e&&"START-DATE"!==e&&"DURATION"!==e&&"END-DATE"!==e&&"END-ON-NEXT"!==e}function at(e){return"SCTE35-OUT"===e||"SCTE35-IN"===e}class lt{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const r=t.attr;for(const t in r)if(Object.prototype.hasOwnProperty.call(e,t)&&e[t]!==r[t]){rt.warn(`DATERANGE tag attribute: "${t}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=t;break}e=We(new st({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const e=new Date(this.attr["END-DATE"]);qe(e.getTime())&&(this._endDate=e)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return null!==e?new Date(this._startDate.getTime()+1e3*e):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(qe(e))return e}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isValid(){return!!this.id&&!this._badValueForSameId&&qe(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class ct{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var ut="audio",dt="video",ht="audiovideo";class ft{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[ut]:null,[dt]:null,[ht]:null},this.baseurl=e}setByteRange(e,t){const r=e.split("@",2),i=[];1===r.length?i[0]=t?t.byteRangeEndOffset:0:i[0]=parseInt(r[1]),i[1]=parseInt(r[0])+i[0],this._byteRange=i}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Ve.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class pt extends ft{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new ct,this.urlId=0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.type=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const e=this.levelkeys.identity;if(e)this._decryptdata=e.getDecryptData(this.sn);else{const e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;if(!qe(this.programDateTime))return null;const e=qe(this.duration)?this.duration:0;return this.programDateTime+1e3*e}get encrypted(){var e;if(null!=(e=this._decryptdata)&&e.encrypted)return!0;if(this.levelkeys){const e=Object.keys(this.levelkeys),t=e.length;if(t>1||1===t&&this.levelkeys[e[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;null==(e=this.loader)||e.abort(),null==(t=this.keyLoader)||t.abort()}setElementaryStreamInfo(e,t,r,i,n,s=!1){const{elementaryStreams:o}=this,a=o[e];a?(a.startPTS=Math.min(a.startPTS,t),a.endPTS=Math.max(a.endPTS,r),a.startDTS=Math.min(a.startDTS,i),a.endDTS=Math.max(a.endDTS,n)):o[e]={startPTS:t,endPTS:r,startDTS:i,endDTS:n,partial:s}}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[ut]=null,e[dt]=null,e[ht]=null}}class gt extends ft{constructor(e,t,r,i,n){super(r),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.stats=new ct,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=i;const s=e.enumeratedString("BYTERANGE");s&&this.setByteRange(s,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}}class mt{constructor(e){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e)return this.advanced=!0,void(this.updated=!0);const t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||0===t&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*e.misses):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return!!this.fragments.length&&qe(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?1e3*(this.driftEnd-this.driftStart)/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return null!=(e=this.fragments)&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return null!=(e=this.partList)&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function yt(e){return Uint8Array.from(atob(e),e=>e.charCodeAt(0))}function vt(e){return Uint8Array.from(unescape(encodeURIComponent(e)),e=>e.charCodeAt(0))}var bt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},Et="org.w3.clearkey",At="com.apple.streamingkeydelivery",Tt="com.microsoft.playready",wt="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function St(e){switch(e){case At:return bt.FAIRPLAY;case Tt:return bt.PLAYREADY;case wt:return bt.WIDEVINE;case Et:return bt.CLEARKEY}}var kt="edef8ba979d64acea3c827dcd51d21ed";function Lt(e){switch(e){case bt.FAIRPLAY:return At;case bt.PLAYREADY:return Tt;case bt.WIDEVINE:return wt;case bt.CLEARKEY:return Et}}function xt(e){const{drmSystems:t,widevineLicenseUrl:r}=e,i=t?[bt.FAIRPLAY,bt.WIDEVINE,bt.PLAYREADY,bt.CLEARKEY].filter(e=>!!t[e]):[];return!i[bt.WIDEVINE]&&r&&i.push(bt.WIDEVINE),i}const Rt="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function Pt(e,t,r){return Uint8Array.prototype.slice?e.slice(t,r):new Uint8Array(Array.prototype.slice.call(e,t,r))}const It=(e,t)=>t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128,Ct=(e,t)=>t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128,_t=(e,t)=>{const r=t;let i=0;for(;It(e,t);)i+=10,i+=Ot(e,t+6),Ct(e,t+10)&&(i+=10),t+=i;if(i>0)return e.subarray(r,r+i)},Ot=(e,t)=>{let r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3],r},Dt=(e,t)=>It(e,t)&&Ot(e,t+6)+10<=e.length-t,Mt=e=>e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info,Nt=e=>{const t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=Ot(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}},Ft=e=>{let t=0;const r=[];for(;It(e,t);){const i=Ot(e,t+6);t+=10;const n=t+i;for(;t+8"PRIV"===e.type?Ut(e):"W"===e.type[0]?$t(e):jt(e),Ut=e=>{if(e.size<2)return;const t=Ht(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}},jt=e=>{if(e.size<2)return;if("TXXX"===e.type){let t=1;const r=Ht(e.data.subarray(t),!0);t+=r.length+1;const i=Ht(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=Ht(e.data.subarray(1));return{key:e.type,data:t}},$t=e=>{if("WXXX"===e.type){if(e.size<2)return;let t=1;const r=Ht(e.data.subarray(t),!0);t+=r.length+1;const i=Ht(e.data.subarray(t));return{key:e.type,info:r,data:i}}const t=Ht(e.data);return{key:e.type,data:t}},Vt=e=>{if(8===e.data.byteLength){const t=new Uint8Array(e.data),r=1&t[3];let i=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return i/=45,r&&(i+=47721858.84),Math.round(i)}},Ht=(e,t=!1)=>{const r=Kt();if(r){const i=r.decode(e);if(t){const e=i.indexOf("\0");return-1!==e?i.substring(0,e):i}return i.replace(/\0/g,"")}const i=e.length;let n,s,o,a="",l=0;for(;l>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(n);break;case 12:case 13:s=e[l++],a+=String.fromCharCode((31&n)<<6|63&s);break;case 14:s=e[l++],o=e[l++],a+=String.fromCharCode((15&n)<<12|(63&s)<<6|63&o)}}return a};let Gt;function Kt(){return Gt||void 0===self.TextDecoder||(Gt=new self.TextDecoder("utf-8")),Gt}const Wt=function(e){let t="";for(let r=0;r>24,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function tr(e,t){const r=[];if(!t.length)return r;const i=e.byteLength;for(let n=0;n1?n+s:i;if(Xt(e.subarray(n+4,n+8))===t[0])if(1===t.length)r.push(e.subarray(n+8,o));else{const i=tr(e.subarray(n+8,o),t.slice(1));i.length&&zt.apply(r,i)}n=o}return r}function rr(e){const t=[],r=e[0];let i=8;const n=Jt(e,i);i+=4,i+=0===r?8:16,i+=2;let s=e.length+0;const o=Qt(e,i);i+=2;for(let r=0;r>>31)return rt.warn("SIDX has hierarchical references (not supported)"),null;const l=Jt(e,r);r+=4,t.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/n,start:s,end:s+a-1}}),s+=a,r+=4,i=r}return{earliestPresentationTime:0,timescale:n,version:r,referencesCount:o,references:t}}function ir(e){const t=[],r=tr(e,["moov","trak"]);for(let e=0;e{const r=Jt(e,4),i=t[r];i&&(i.default={duration:Jt(e,12),flags:Jt(e,20)})}),t}function nr(e){const t=tr(e,["schm"])[0];if(t){const r=Xt(t.subarray(4,8));if("cbcs"===r||"cenc"===r)return tr(e,["schi","tenc"])[0]}return rt.error("[eme] missing 'schm' box"),null}function sr(e){const t=Jt(e,0);let r=8;1&t&&(r+=4),4&t&&(r+=4);let i=0;const n=Jt(e,4);for(let s=0;s{const l=a.byteOffset-8;tr(a,["traf"]).map(a=>{const c=tr(a,["tfdt"]).map(e=>{const t=e[0];let r=Jt(e,4);return 1===t&&(r*=Math.pow(2,32),r+=Jt(e,8)),r/n})[0];return void 0!==c&&(e=c),tr(a,["tfhd"]).map(c=>{const u=Jt(c,4),d=16777215&Jt(c,0);let h=0;const f=!!(16&d);let p=0;const g=!!(32&d);let m=8;u===s&&(!!(1&d)&&(m+=8),!!(2&d)&&(m+=4),!!(8&d)&&(h=Jt(c,m),m+=4),f&&(p=Jt(c,m),m+=4),g&&(m+=4),"video"===t.type&&(o=function(e){if(!e)return!1;const t=e.indexOf("."),r=t<0?e:e.substring(0,t);return"hvc1"===r||"hev1"===r||"dvh1"===r||"dvhe"===r}(t.codec)),tr(a,["trun"]).map(s=>{const a=s[0],c=16777215&Jt(s,0),u=!!(1&c);let d=0;const f=!!(4&c),g=!!(256&c);let m=0;const y=!!(512&c);let v=0;const b=!!(1024&c),E=!!(2048&c);let A=0;const T=Jt(s,4);let w=8;u&&(d=Jt(s,w),w+=4),f&&(w+=4);let S=d+l;for(let l=0;l>1&63;return 39===e||40===e}return 6==(31&t)}function cr(e,t,r,i){const n=ur(e);let s=0;s+=t;let o=0,a=0,l=!1,c=0;for(;s=n.length)break;c=n[s++],o+=c}while(255===c);a=0;do{if(s>=n.length)break;c=n[s++],a+=c}while(255===c);const e=n.length-s;if(!l&&4===o&&s16){const e=[];for(let t=0;t<16;t++){const r=n[s++].toString(16);e.push(1==r.length?"0"+r:r),3!==t&&5!==t&&7!==t&&9!==t||e.push("-")}const t=a-16,l=new Uint8Array(t);for(let e=0;ee)break}}function ur(e){const t=e.byteLength,r=[];let i=1;for(;i>8*(15-r)&255;return t}(e);return new hr(this.method,this.uri,"identity",this.keyFormatVersions,t)}const t=function(e){const t=e.split(":");let r=null;if("data"===t[0]&&2===t.length){const e=t[1].split(";"),i=e[e.length-1].split(",");if(2===i.length){const t="base64"===i[0],n=i[1];t?(e.splice(-1,1),r=yt(n)):r=function(e){const t=vt(e).subarray(0,16),r=new Uint8Array(16);return r.set(t,16-t.length),r}(n)}}return r}(this.uri);if(t)switch(this.keyFormat){case wt:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case Tt:{const e=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(e,t,r){if(16!==e.byteLength)throw new RangeError("Invalid system id");let i,n,s;if(t){i=1,n=new Uint8Array(16*t.length);for(let e=0;e0?(s=new Uint8Array(4),t.length>0&&new DataView(s.buffer).setUint32(0,t.length,!1)):s=new Uint8Array;const o=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(o.buffer).setUint32(0,r.byteLength,!1),function(e,...t){const r=t.length;let i=8,n=r;for(;n--;)i+=t[n].byteLength;const s=new Uint8Array(i);for(s[0]=i>>24&255,s[1]=i>>16&255,s[2]=i>>8&255,s[3]=255&i,s.set(e,4),n=0,i=8;n{const i=t.substring(2,t.length-1),n=null==r?void 0:r[i];return void 0===n?(e.playlistParsingError||(e.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)),t):n})}return t}function yr(e,t,r){let i,n,s=e.variableList;if(s||(e.variableList=s={}),"QUERYPARAM"in t){i=t.QUERYPARAM;try{const e=new self.URL(r).searchParams;if(!e.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${r}"`);n=e.get(i)}catch(t){e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${t.message}`))}}else i=t.NAME,n=t.VALUE;i in s?e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):s[i]=n||""}function vr(e,t,r){const i=t.IMPORT;if(r&&i in r){let t=e.variableList;t||(e.variableList=t={}),t[i]=r[i]}else e.playlistParsingError||(e.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}function br(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}const Er={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},Ar=br();function Tr(e,t){var r;return null!=(r=null==Ar?void 0:Ar.isTypeSupported(`${t||"video"}/mp4;codecs="${e}"`))&&r}const wr=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Sr=/#EXT-X-MEDIA:(.*)/g,kr=/^#EXT(?:INF|-X-TARGETDURATION):/m,Lr=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),xr=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class Rr{static findGroup(e,t){for(let r=0;r2){let e=t.shift()+".";return e+=parseInt(t.shift()).toString(16),e+=("000"+parseInt(t.shift()).toString(16)).slice(-4),e}return e}static resolve(e,t){return Ve.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return kr.test(e)}static parseMasterPlaylist(e,t){const r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:pr(e)},i=[];let n;for(wr.lastIndex=0;null!=(n=wr.exec(e));)if(n[1]){var s;const e=new st(n[1]);gr(r,e,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const o=mr(r,n[2]),a={attrs:e,bitrate:e.decimalInteger("AVERAGE-BANDWIDTH")||e.decimalInteger("BANDWIDTH"),name:e.NAME,url:Rr.resolve(o,t)},l=e.decimalResolution("RESOLUTION");l&&(a.width=l.width,a.height=l.height),Cr((e.CODECS||"").split(/[ ,]+/).filter(e=>e),a),a.videoCodec&&-1!==a.videoCodec.indexOf("avc1")&&(a.videoCodec=Rr.convertAVC1ToAVCOTI(a.videoCodec)),null!=(s=a.unknownCodecs)&&s.length||i.push(a),r.levels.push(a)}else if(n[3]){const e=n[3],i=n[4];switch(e){case"SESSION-DATA":{const e=new st(i);gr(r,e,["DATA-ID","LANGUAGE","VALUE","URI"]);const t=e["DATA-ID"];t&&(null===r.sessionData&&(r.sessionData={}),r.sessionData[t]=e);break}case"SESSION-KEY":{const e=Pr(i,t,r);e.encrypted&&e.isSupported()?(null===r.sessionKeys&&(r.sessionKeys=[]),r.sessionKeys.push(e)):rt.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":{const e=new st(i);gr(r,e,["NAME","VALUE","QUERYPARAM"]),yr(r,e,t)}break;case"CONTENT-STEERING":{const e=new st(i);gr(r,e,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:Rr.resolve(e["SERVER-URI"],t),pathwayId:e["PATHWAY-ID"]||"."};break}case"START":r.startTimeOffset=Ir(i)}}const o=i.length>0&&i.length({id:e.attrs.AUDIO,audioCodec:e.audioCodec})),SUBTITLES:s.map(e=>({id:e.attrs.SUBTITLES,textCodec:e.textCodec})),"CLOSED-CAPTIONS":[]};let a=0;for(Sr.lastIndex=0;null!==(i=Sr.exec(e));){const e=new st(i[1]),s=e.TYPE;if(s){const i=o[s],l=n[s]||[];n[s]=l,gr(r,e,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const c={attrs:e,bitrate:0,id:a++,groupId:e["GROUP-ID"]||"",instreamId:e["INSTREAM-ID"],name:e.NAME||e.LANGUAGE||"",type:s,default:e.bool("DEFAULT"),autoselect:e.bool("AUTOSELECT"),forced:e.bool("FORCED"),lang:e.LANGUAGE,url:e.URI?Rr.resolve(e.URI,t):""};if(null!=i&&i.length){const e=Rr.findGroup(i,c.groupId)||i[0];_r(c,e,"audioCodec"),_r(c,e,"textCodec")}l.push(c)}}return n}static parseLevelPlaylist(e,t,r,i,n,s){const o=new mt(t),a=o.fragments;let l,c,u,d=null,h=0,f=0,p=0,g=0,m=null,y=new pt(i,t),v=-1,b=!1;for(Lr.lastIndex=0,o.m3u8=e,o.hasVariableRefs=pr(e);null!==(l=Lr.exec(e));){b&&(b=!1,y=new pt(i,t),y.start=p,y.sn=h,y.cc=g,y.level=r,d&&(y.initSegment=d,y.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null));const e=l[1];if(e){y.duration=parseFloat(e);const t=(" "+l[2]).slice(1);y.title=t||null,y.tagList.push(t?["INF",e,t]:["INF",e])}else if(l[3]){if(qe(y.duration)){y.start=p,u&&Mr(y,u,o),y.sn=h,y.level=r,y.cc=g,y.urlId=n,a.push(y);const e=(" "+l[3]).slice(1);y.relurl=mr(o,e),Or(y,m),m=y,p+=y.duration,h++,f=0,b=!0}}else if(l[4]){const e=(" "+l[4]).slice(1);m?y.setByteRange(e,m):y.setByteRange(e)}else if(l[5])y.rawProgramDateTime=(" "+l[5]).slice(1),y.tagList.push(["PROGRAM-DATE-TIME",y.rawProgramDateTime]),-1===v&&(v=a.length);else{if(l=l[0].match(xr),!l){rt.warn("No matches on slow regex match for level playlist!");continue}for(c=1;c0&&e.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=e.optionalFloat("PART-HOLD-BACK",0),o.holdBack=e.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const e=new st(n);o.partTarget=e.decimalFloatingPoint("PART-TARGET");break}case"PART":{let e=o.partList;e||(e=o.partList=[]);const r=f>0?e[e.length-1]:void 0,i=f++,s=new st(n);gr(o,s,["BYTERANGE","URI"]);const a=new gt(s,y,t,i,r);e.push(a),y.duration+=a.duration;break}case"PRELOAD-HINT":{const e=new st(n);gr(o,e,["URI"]),o.preloadHint=e;break}case"RENDITION-REPORT":{const e=new st(n);gr(o,e,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(e);break}default:rt.warn(`line parsed but not handled: ${l}`)}}}m&&!m.relurl?(a.pop(),p-=m.duration,o.partList&&(o.fragmentHint=m)):o.partList&&(Or(y,m),y.cc=g,o.fragmentHint=y,u&&Mr(y,u,o));const E=a.length,A=a[0],T=a[E-1];if(p+=o.skippedSegments*o.targetduration,p>0&&E&&T){o.averagetargetduration=p/E;const e=T.sn;o.endSN="initSegment"!==e?e:0,o.live||(T.endList=!0),A&&(o.startCC=A.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(p+=o.fragmentHint.duration),o.totalduration=p,o.endCC=g,v>0&&function(e,t){let r=e[t];for(let i=t;i--;){const t=e[i];if(!t)return;t.programDateTime=r.programDateTime-1e3*t.duration,r=t}}(a,v),o}}function Pr(e,t,r){var i,n;const s=new st(e);gr(r,s,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const o=null!=(i=s.METHOD)?i:"",a=s.URI,l=s.hexadecimalInteger("IV"),c=s.KEYFORMATVERSIONS,u=null!=(n=s.KEYFORMAT)?n:"identity";a&&s.IV&&!l&&rt.error(`Invalid IV: ${s.IV}`);const d=a?Rr.resolve(a,t):"",h=(c||"1").split("/").map(Number).filter(Number.isFinite);return new hr(o,d,u,h,l)}function Ir(e){const t=new st(e).decimalFloatingPoint("TIME-OFFSET");return qe(t)?t:null}function Cr(e,t){["video","audio","text"].forEach(r=>{const i=e.filter(e=>function(e,t){const r=Er[t];return!!r&&!0===r[e.slice(0,4)]}(e,r));if(i.length){const n=i.filter(e=>0===e.lastIndexOf("avc1",0)||0===e.lastIndexOf("mp4a",0));t[`${r}Codec`]=n.length>0?n[0]:i[0],e=e.filter(e=>-1===i.indexOf(e))}}),t.unknownCodecs=e}function _r(e,t,r){const i=t[r];i&&(e[r]=i)}function Or(e,t){e.rawProgramDateTime?e.programDateTime=Date.parse(e.rawProgramDateTime):null!=t&&t.programDateTime&&(e.programDateTime=t.endProgramDateTime),qe(e.programDateTime)||(e.programDateTime=null,e.rawProgramDateTime=null)}function Dr(e,t,r,i){e.relurl=t.URI,t.BYTERANGE&&e.setByteRange(t.BYTERANGE),e.level=r,e.sn="initSegment",i&&(e.levelkeys=i),e.initSegment=null}function Mr(e,t,r){e.levelkeys=t;const{encryptedFragments:i}=r;i.length&&i[i.length-1].levelkeys===t||!Object.keys(t).some(e=>t[e].isCommonEncryption)||i.push(e)}var Nr="manifest",Fr="level",Br="audioTrack",Ur="subtitleTrack",jr="main",$r="audio",Vr="subtitle";function Hr(e){const{type:t}=e;switch(t){case Br:return $r;case Ur:return Vr;default:return jr}}function Gr(e,t){let r=e.url;return void 0!==r&&0!==r.indexOf("data:")||(r=t.url),r}class Kr{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Xe.LEVEL_LOADING,this.onLevelLoading,this),e.on(Xe.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(Xe.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Xe.LEVEL_LOADING,this.onLevelLoading,this),e.off(Xe.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(Xe.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,r=t.pLoader,i=t.loader,n=new(r||i)(t);return this.loaders[e.type]=n,n}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:Nr,url:r,deliveryDirectives:null})}onLevelLoading(e,t){const{id:r,level:i,url:n,deliveryDirectives:s}=t;this.load({id:r,level:i,responseType:"text",type:Fr,url:n,deliveryDirectives:s})}onAudioTrackLoading(e,t){const{id:r,groupId:i,url:n,deliveryDirectives:s}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:Br,url:n,deliveryDirectives:s})}onSubtitleTrackLoading(e,t){const{id:r,groupId:i,url:n,deliveryDirectives:s}=t;this.load({id:r,groupId:i,level:null,responseType:"text",type:Ur,url:n,deliveryDirectives:s})}load(e){var t;const r=this.hls.config;let i,n=this.getInternalLoader(e);if(n){const t=n.context;if(t&&t.url===e.url)return void rt.trace("[playlist-loader]: playlist request ongoing");rt.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),n.abort()}if(i=e.type===Nr?r.manifestLoadPolicy.default:We({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(e),null!=(t=e.deliveryDirectives)&&t.part){let t;if(e.type===Fr&&null!==e.level?t=this.hls.levels[e.level].details:e.type===Br&&null!==e.id?t=this.hls.audioTracks[e.id].details:e.type===Ur&&null!==e.id&&(t=this.hls.subtitleTracks[e.id].details),t){const e=t.partTarget,r=t.targetduration;if(e&&r){const t=1e3*Math.max(3*e,.8*r);i=We({},i,{maxTimeToFirstByteMs:Math.min(t,i.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(t,i.maxTimeToFirstByteMs)})}}}const s=i.errorRetry||i.timeoutRetry||{},o={loadPolicy:i,timeout:i.maxLoadTimeMs,maxRetry:s.maxNumRetry||0,retryDelay:s.retryDelayMs||0,maxRetryDelay:s.maxRetryDelayMs||0},a={onSuccess:(e,t,r,i)=>{const n=this.getInternalLoader(r);this.resetInternalLoader(r.type);const s=e.data;0===s.indexOf("#EXTM3U")?(t.parsing.start=performance.now(),Rr.isMediaPlaylist(s)?this.handleTrackOrLevelPlaylist(e,t,r,i||null,n):this.handleMasterPlaylist(e,t,r,i)):this.handleManifestParsingError(e,r,new Error("no EXTM3U delimiter"),i||null,t)},onError:(e,t,r,i)=>{this.handleNetworkError(t,r,!1,e,i)},onTimeout:(e,t,r)=>{this.handleNetworkError(t,r,!0,void 0,e)}};n.load(e,o,a)}handleMasterPlaylist(e,t,r,i){const n=this.hls,s=e.data,o=Gr(e,r),a=Rr.parseMasterPlaylist(s,o);if(a.playlistParsingError)return void this.handleManifestParsingError(e,r,a.playlistParsingError,i,t);const{contentSteering:l,levels:c,sessionData:u,sessionKeys:d,startTimeOffset:h,variableList:f}=a;this.variableList=f;const{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":m}=Rr.parseMasterPlaylistMedia(s,o,a);p.length&&(p.some(e=>!e.url)||!c[0].audioCodec||c[0].attrs.AUDIO||(rt.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new st({}),bitrate:0,url:""}))),n.trigger(Xe.MANIFEST_LOADED,{levels:c,audioTracks:p,subtitles:g,captions:m,contentSteering:l,url:o,stats:t,networkDetails:i,sessionData:u,sessionKeys:d,startTimeOffset:h,variableList:f})}handleTrackOrLevelPlaylist(e,t,r,i,n){const s=this.hls,{id:o,level:a,type:l}=r,c=Gr(e,r),u=qe(o)?o:0,d=qe(a)?a:u,h=Hr(r),f=Rr.parseLevelPlaylist(e.data,c,d,h,u,this.variableList);if(l===Nr){const e={attrs:new st({}),bitrate:0,details:f,name:"",url:c};s.trigger(Xe.MANIFEST_LOADED,{levels:[e],audioTracks:[],url:c,stats:t,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=f,this.handlePlaylistLoaded(f,e,t,r,i,n)}handleManifestParsingError(e,t,r,i,n){this.hls.trigger(Xe.ERROR,{type:Qe.NETWORK_ERROR,details:Je.MANIFEST_PARSING_ERROR,fatal:t.type===Nr,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:i,stats:n})}handleNetworkError(e,t,r=!1,i,n){let s=`A network ${r?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading ${e.type}`;e.type===Fr?s+=`: ${e.level} id: ${e.id}`:e.type!==Br&&e.type!==Ur||(s+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(s);rt.warn(`[playlist-loader]: ${s}`);let a=Je.UNKNOWN,l=!1;const c=this.getInternalLoader(e);switch(e.type){case Nr:a=r?Je.MANIFEST_LOAD_TIMEOUT:Je.MANIFEST_LOAD_ERROR,l=!0;break;case Fr:a=r?Je.LEVEL_LOAD_TIMEOUT:Je.LEVEL_LOAD_ERROR,l=!1;break;case Br:a=r?Je.AUDIO_TRACK_LOAD_TIMEOUT:Je.AUDIO_TRACK_LOAD_ERROR,l=!1;break;case Ur:a=r?Je.SUBTITLE_TRACK_LOAD_TIMEOUT:Je.SUBTITLE_LOAD_ERROR,l=!1}c&&this.resetInternalLoader(e.type);const u={type:Qe.NETWORK_ERROR,details:a,fatal:l,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(i){const r=(null==t?void 0:t.url)||e.url;u.response=Ge({url:r,data:void 0},i)}this.hls.trigger(Xe.ERROR,u)}handlePlaylistLoaded(e,t,r,i,n,s){const o=this.hls,{type:a,level:l,id:c,groupId:u,deliveryDirectives:d}=i,h=Gr(t,i),f=Hr(i),p="number"==typeof i.level&&f===jr?l:void 0;if(!e.fragments.length){const e=new Error("No Segments found in Playlist");return void o.trigger(Xe.ERROR,{type:Qe.NETWORK_ERROR,details:Je.LEVEL_EMPTY_ERROR,fatal:!1,url:h,error:e,reason:e.message,response:t,context:i,level:p,parent:f,networkDetails:n,stats:r})}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const g=e.playlistParsingError;if(g)o.trigger(Xe.ERROR,{type:Qe.NETWORK_ERROR,details:Je.LEVEL_PARSING_ERROR,fatal:!1,url:h,error:g,reason:g.message,response:t,context:i,level:p,parent:f,networkDetails:n,stats:r});else switch(e.live&&s&&(s.getCacheAge&&(e.ageHeader=s.getCacheAge()||0),s.getCacheAge&&!isNaN(e.ageHeader)||(e.ageHeader=0)),a){case Nr:case Fr:o.trigger(Xe.LEVEL_LOADED,{details:e,level:p||0,id:c||0,stats:r,networkDetails:n,deliveryDirectives:d});break;case Br:o.trigger(Xe.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:d});break;case Ur:o.trigger(Xe.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:r,networkDetails:n,deliveryDirectives:d})}}}function Wr(e,t){let r;try{r=new Event("addtrack")}catch(e){r=document.createEvent("Event"),r.initEvent("addtrack",!1,!1)}r.track=e,t.dispatchEvent(r)}function qr(e,t){const r=e.mode;if("disabled"===r&&(e.mode="hidden"),e.cues&&!e.cues.getCueById(t.id))try{if(e.addCue(t),!e.cues.getCueById(t.id))throw new Error(`addCue is failed for: ${t}`)}catch(r){rt.debug(`[texttrack-utils]: ${r}`);try{const r=new self.TextTrackCue(t.startTime,t.endTime,t.text);r.id=t.id,e.addCue(r)}catch(e){rt.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${e}`)}}"disabled"===r&&(e.mode=r)}function zr(e){const t=e.mode;if("disabled"===t&&(e.mode="hidden"),e.cues)for(let t=e.cues.length;t--;)e.removeCue(e.cues[t]);"disabled"===t&&(e.mode=t)}function Yr(e,t,r,i){const n=e.mode;if("disabled"===n&&(e.mode="hidden"),e.cues&&e.cues.length>0){const n=function(e,t,r){const i=[],n=function(e,t){if(te[r].endTime)return-1;let i=0,n=r;for(;i<=n;){const s=Math.floor((n+i)/2);if(te[s].startTime&&i-1)for(let s=n,o=e.length;s=t&&n.endTime<=r)i.push(n);else if(n.startTime>r)return i}return i}(e.cues,t,r);for(let t=0;t{const e=Jr();try{e&&new e(0,Number.POSITIVE_INFINITY,"")}catch(e){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function ti(e,t){return e.getTime()/1e3-t}function ri(e){return Uint8Array.from(e.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class ii{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(Xe.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Xe.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Xe.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(Xe.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Xe.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(Xe.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Xe.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Xe.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(Xe.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Xe.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(zr(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;tei&&(i=ei),i-r<=0&&(i=r+.25);for(let e=0;ee.type===Xr&&a:"video"===i?e=>e.type===Qr&&o:e=>e.type===Xr&&a||e.type===Qr&&o,Yr(n,t,r,e)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:r,id3Track:i}=this,{dateRanges:n}=t,s=Object.keys(n);if(i){const e=Object.keys(r).filter(e=>!s.includes(e));for(let t=e.length;t--;){const n=e[t];Object.keys(r[n].cues).forEach(e=>{i.removeCue(r[n].cues[e])}),delete r[n]}}const o=t.fragments[t.fragments.length-1];if(0===s.length||!qe(null==o?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=o.programDateTime/1e3-o.start,l=Jr();for(let e=0;e{const r=n[t];return r.class===i.class&&r.id!==t&&r.startDate>i.startDate&&e.push(r),e},[]).sort((e,t)=>e.startDate.getTime()-t.startDate.getTime())[0];e&&(h=ti(e.startDate,a),u=!0)}const p=Object.keys(i.attr);for(let e=0;ethis.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(null===e)return null;const{holdBack:t,partHoldBack:r,targetduration:i}=e,{liveSyncDuration:n,liveSyncDurationCount:s,lowLatencyMode:o}=this.config,a=this.hls.userConfig;let l=o&&r||t;(a.liveSyncDuration||a.liveSyncDurationCount||0===l)&&(l=void 0!==n?n:s*i);const c=i;return l+Math.min(1*this.stallCount,c)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(null===e||null===t||null===r)return null;const i=r.edge,n=e-t-this.edgeStalled,s=i-r.totalduration,o=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(s,n),o)}get drift(){const{levelDetails:e}=this;return null===e?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(null===e)return 0;const t=3*(this.config.lowLatencyMode&&e.partTarget||e.targetduration);return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e,levelDetails:t}=this;if(!e||!t)return 0;const r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(Xe.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Xe.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(Xe.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Xe.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(Xe.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(Xe.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Xe.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(Xe.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Xe.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(Xe.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===Je.BUFFER_STALLED_ERROR&&(this.stallCount++,null!=(r=this.levelDetails)&&r.live&&rt.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const r=this.computeLatency();if(null===r)return;this._latency=r;const{lowLatencyMode:i,maxLiveSyncPlaybackRate:n}=this.config;if(!i||1===n)return;const s=this.targetLatency;if(null===s)return;const o=r-s,a=o.05&&this.forwardBufferLength>1){const t=Math.min(2,Math.max(1,n)),r=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(t,Math.max(1,r))}else 1!==e.playbackRate&&0!==e.playbackRate&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return null===e?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return null===e?null:e-this.currentTime}}const si=["NONE","TYPE-0","TYPE-1",null];class oi{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){const t=new self.URL(e);return void 0!==this.msn&&t.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class ai{constructor(e){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.unknownCodecs=e.unknownCodecs,this.codecSet=[e.videoCodec,e.audioCodec].filter(e=>e).join(",").replace(/\.[^.,]+/g,"")}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get attrs(){return this._attrs[this._urlId]}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get uri(){return this.url[this._urlId]||""}get urlId(){return this._urlId}set urlId(e){const t=e%this.url.length;this._urlId!==t&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=t)}get audioGroupId(){var e;return null==(e=this.audioGroupIds)?void 0:e[this.urlId]}get textGroupId(){var e;return null==(e=this.textGroupIds)?void 0:e[this.urlId]}addFallback(e){this.url.push(e.url),this._attrs.push(e.attrs)}}function li(e,t){const r=t.startPTS;if(qe(r)){let i,n=0;t.sn>e.sn?(n=r-e.start,i=e):(n=e.start-r,i=t),i.duration!==n&&(i.duration=n)}else t.sn>e.sn?e.cc===t.cc&&e.minEndPTS?t.start=e.start+(e.minEndPTS-e.start):t.start=e.start+e.duration:t.start=Math.max(e.start-t.duration,0)}function ci(e,t,r,i,n,s){i-r<=0&&(rt.warn("Fragment should have a positive duration",t),i=r+t.duration,s=n+t.duration);let o=r,a=i;const l=t.startPTS,c=t.endPTS;if(qe(l)){const e=Math.abs(l-r);qe(t.deltaPTS)?t.deltaPTS=Math.max(e,t.deltaPTS):t.deltaPTS=e,o=Math.max(r,l),r=Math.min(r,l),n=Math.min(n,t.startDTS),a=Math.min(i,c),i=Math.max(i,c),s=Math.max(s,t.endDTS)}const u=r-t.start;0!==t.start&&(t.start=r),t.duration=i-t.start,t.startPTS=r,t.maxStartPTS=o,t.startDTS=n,t.endPTS=i,t.minEndPTS=a,t.endDTS=s;const d=t.sn;if(!e||de.endSN)return 0;let h;const f=d-e.startSN,p=e.fragments;for(p[f]=t,h=f;h>0;h--)li(p[h],p[h-1]);for(h=f;h=i.length||di(t,i[r].start)}function di(e,t){if(t){const r=e.fragments;for(let i=e.skippedSegments;i499)}(i)||!!r)}const bi=function(e,t){let r=0,i=e.length-1,n=null,s=null;for(;r<=i;){n=(r+i)/2|0,s=e[n];const o=t(s);if(o>0)r=n+1;else{if(!(o<0))return s;i=n-1}}return null};function Ei(e,t,r=0,i=0){let n=null;if(e?n=t[e.sn-t[0].sn+1]||null:0===r&&0===t[0].start&&(n=t[0]),n&&0===Ai(r,i,n))return n;const s=bi(t,Ai.bind(null,r,i));return!s||s===e&&n?n:s}function Ai(e=0,t=0,r){if(r.start<=e&&r.start+r.duration>e)return 0;const i=Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=e?1:r.start-i>e&&r.start?-1:0}function Ti(e,t,r){const i=1e3*Math.min(t,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>e}function wi(e,t,r){if(performance.now()-e.lastErrorPerfMs>3e5)return!0;const i=e.details;if(t.details===Je.FRAG_GAP&&i&&t.frag){const e=t.frag.start,r=Ei(null,i.fragments,e);if(r&&!r.gap)return!0}if(r&&e.errors.length3*i.targetduration)return!0}return!1}class Si{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=rt.log.bind(rt,`${t}:`),this.warn=rt.warn.bind(rt,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){clearTimeout(this.timer),this.timer=-1}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t){const r=null==t?void 0:t.renditionReports;if(r){let i=-1;for(let n=0;n=0&&e>t.partTarget&&(s+=1)}return new oi(n,s>=0?s:void 0,"")}}}loadPlaylist(e){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){const{details:i,stats:n}=t,s=self.performance.now(),o=n.loading.first?Math.max(0,s-n.loading.first):0;if(i.advancedDateTime=Date.now()-o,i.live||null!=r&&r.live){if(i.reloaded(r),r&&this.log(`live playlist ${e} ${i.advanced?"REFRESHED "+i.lastPartSn+"-"+i.lastPartIndex:i.updated?"UPDATED":"MISSED"}`),r&&i.fragments.length>0&&function(e,t){let r=null;const i=e.fragments;for(let e=i.length-1;e>=0;e--){const t=i[e].initSegment;if(t){r=t;break}}e.fragmentHint&&delete e.fragmentHint.endPTS;let n,s=0;if(function(e,t,r){const i=t.skippedSegments,n=Math.max(e.startSN,t.startSN)-t.startSN,s=(e.fragmentHint?1:0)+(i?t.endSN:Math.min(e.endSN,t.endSN))-t.startSN,o=t.startSN-e.startSN,a=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,l=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments;for(let e=n;e<=s;e++){const n=l[o+e];let s=a[e];i&&!s&&e{e.relurl&&(s=e.cc-i.cc),qe(e.startPTS)&&qe(e.endPTS)&&(i.start=i.startPTS=e.startPTS,i.startDTS=e.startDTS,i.maxStartPTS=e.maxStartPTS,i.endPTS=e.endPTS,i.endDTS=e.endDTS,i.minEndPTS=e.minEndPTS,i.duration=e.endPTS-e.startPTS,i.duration&&(n=i),t.PTSKnown=t.alignedSliding=!0),i.elementaryStreams=e.elementaryStreams,i.loader=e.loader,i.stats=e.stats,i.urlId=e.urlId,e.initSegment&&(i.initSegment=e.initSegment,r=e.initSegment)}),r&&(t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments).forEach(e=>{var t;e.initSegment&&e.initSegment.relurl!==(null==(t=r)?void 0:t.relurl)||(e.initSegment=r)}),t.skippedSegments)if(t.deltaUpdateFailed=t.fragments.some(e=>!e),t.deltaUpdateFailed){rt.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let e=t.skippedSegments;e--;)t.fragments.shift();t.startSN=t.fragments[0].sn,t.startCC=t.fragments[0].cc}else t.canSkipDateRanges&&(t.dateRanges=function(e,t,r){const i=We({},e);return r&&r.forEach(e=>{delete i[e]}),Object.keys(t).forEach(e=>{const r=new lt(t[e].attr,i[e]);r.isValid?i[e]=r:rt.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(t[e].attr)}"`)}),i}(e.dateRanges,t.dateRanges,t.recentlyRemovedDateranges));const o=t.fragments;if(s){rt.warn("discontinuity sliding from playlist, take drift into account");for(let e=0;e{t.elementaryStreams=e.elementaryStreams,t.stats=e.stats}),n?ci(t,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):ui(e,t),o.length&&(t.totalduration=t.edge-o[0].start),t.driftStartTime=e.driftStartTime,t.driftStart=e.driftStart;const a=t.advancedDateTime;if(t.advanced&&a){const e=t.edge;t.driftStart||(t.driftStartTime=a,t.driftStart=e),t.driftEndTime=a,t.driftEnd=e}else t.driftEndTime=e.driftEndTime,t.driftEnd=e.driftEnd,t.advancedDateTime=e.advancedDateTime}(r,i),!this.canLoad||!i.live)return;let o,a,l;if(i.canBlockReload&&i.endSN&&i.advanced){const e=this.hls.config.lowLatencyMode,n=i.lastPartSn,s=i.endSN,c=i.lastPartIndex,u=n===s;-1!==c?(a=u?s+1:n,l=u?e?0:c:c+1):a=s+1;const d=i.age,h=d+i.ageHeader;let f=Math.min(h-i.partTarget,1.5*i.targetduration);if(f>0){if(r&&f>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${f} with playlist age: ${i.age}`),f=0;else{const e=Math.floor(f/i.targetduration);a+=e,void 0!==l&&(l+=Math.round(f%i.targetduration/i.partTarget)),this.log(`CDN Tune-in age: ${i.ageHeader}s last advanced ${d.toFixed(2)}s goal: ${f} skip sn ${e} to part ${l}`)}i.tuneInGoal=f}if(o=this.getDeliveryDirectives(i,t.deliveryDirectives,a,l),e||!u)return void this.loadPlaylist(o)}else(i.canBlockReload||i.canSkipUntil)&&(o=this.getDeliveryDirectives(i,t.deliveryDirectives,a,l));const c=this.hls.mainForwardBufferInfo,u=c?c.end-c.len:0,d=function(e,t=1/0){let r=1e3*e.targetduration;if(e.updated){const i=e.fragments,n=4;if(i.length&&r*n>t){const e=1e3*i[i.length-1].duration;ethis.requestScheduled+d&&(this.requestScheduled=n.loading.start),void 0!==a&&i.canBlockReload?this.requestScheduled=n.loading.first+d-(1e3*i.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+dthis.loadPlaylist(o),h)}else this.clearTimer()}getDeliveryDirectives(e,t,r,i){let n=function(e,t){const{canSkipUntil:r,canSkipDateRanges:i,endSN:n}=e;return r&&(void 0!==t?t-n:0)=o.maxNumRetry)return!1;if(r&&null!=(l=e.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${s+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const e=mi(o,s);this.timer=self.setTimeout(()=>this.loadPlaylist(),e),this.warn(`Retrying playlist loading ${s+1}/${o.maxNumRetry} after "${t}" in ${e}ms`)}e.levelRetry=!0,i.resolved=!0}return a}}let ki;class Li extends Si{constructor(e,t){super(e,"[level-controller]"),this._levels=[],this._firstLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Xe.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(Xe.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Xe.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(Xe.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(Xe.FRAG_LOADED,this.onFragLoaded,this),e.on(Xe.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Xe.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(Xe.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Xe.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(Xe.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(Xe.FRAG_LOADED,this.onFragLoaded,this),e.off(Xe.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}startLoad(){this._levels.forEach(e=>{e.loadError=0,e.fragmentError=0}),super.startLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]}onManifestLoading(e,t){this.resetLevels()}onManifestLoaded(e,t){const r=[],i={};let n;t.levels.forEach(e=>{var t;const s=e.attrs;-1!==(null==(t=e.audioCodec)?void 0:t.indexOf("mp4a.40.34"))&&(ki||(ki=/chrome|firefox/i.test(navigator.userAgent)),ki&&(e.audioCodec=void 0));const{AUDIO:o,CODECS:a,"FRAME-RATE":l,"PATHWAY-ID":c,RESOLUTION:u,SUBTITLES:d}=s,h=`${c||"."}-${e.bitrate}-${u}-${l}-${a}`;n=i[h],n?n.addFallback(e):(n=new ai(e),i[h]=n,r.push(n)),xi(n,"audio",o),xi(n,"text",d)}),this.filterAndSortMediaOptions(r,t)}filterAndSortMediaOptions(e,t){let r=[],i=[],n=!1,s=!1,o=!1,a=e.filter(({audioCodec:e,videoCodec:t,width:r,height:i,unknownCodecs:a})=>(n||(n=!(!r||!i)),s||(s=!!t),o||(o=!!e),!(null!=a&&a.length)&&(!e||Tr(e,"audio"))&&(!t||Tr(t,"video"))));if((n||s)&&o&&(a=a.filter(({videoCodec:e,width:t,height:r})=>!!e||!(!t||!r))),0===a.length)return void Promise.resolve().then(()=>{if(this.hls){const e=new Error("no level with compatible codecs found in manifest");this.hls.trigger(Xe.ERROR,{type:Qe.MEDIA_ERROR,details:Je.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:e,reason:e.message})}});t.audioTracks&&(r=t.audioTracks.filter(e=>!e.audioCodec||Tr(e.audioCodec,"audio")),Ri(r)),t.subtitles&&(i=t.subtitles,Ri(i));const l=a.slice(0);a.sort((e,t)=>e.attrs["HDCP-LEVEL"]!==t.attrs["HDCP-LEVEL"]?(e.attrs["HDCP-LEVEL"]||"")>(t.attrs["HDCP-LEVEL"]||"")?1:-1:e.bitrate!==t.bitrate?e.bitrate-t.bitrate:e.attrs["FRAME-RATE"]!==t.attrs["FRAME-RATE"]?e.attrs.decimalFloatingPoint("FRAME-RATE")-t.attrs.decimalFloatingPoint("FRAME-RATE"):e.attrs.SCORE!==t.attrs.SCORE?e.attrs.decimalFloatingPoint("SCORE")-t.attrs.decimalFloatingPoint("SCORE"):n&&e.height!==t.height?e.height-t.height:0);let c=l[0];if(this.steering&&(a=this.steering.filterParsedLevels(a),a.length!==l.length))for(let e=0;e!!e.url)};this.hls.trigger(Xe.MANIFEST_PARSED,d),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return 0===this._levels.length?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(0===t.length)return;if(e<0||e>=t.length){const r=new Error("invalid level idx"),i=e<0;if(this.hls.trigger(Xe.ERROR,{type:Qe.OTHER_ERROR,details:Je.LEVEL_SWITCH_ERROR,level:e,fatal:i,error:r,reason:r.message}),i)return;e=Math.min(e,t.length-1)}const r=this.currentLevelIndex,i=this.currentLevel,n=i?i.attrs["PATHWAY-ID"]:void 0,s=t[e],o=s.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=s,r===e&&s.details&&i&&n===o)return;this.log(`Switching to level ${e}${o?" with Pathway "+o:""} from level ${r}${n?" with Pathway "+n:""}`);const a=We({},s,{level:e,maxBitrate:s.maxBitrate,attrs:s.attrs,uri:s.uri,urlId:s.urlId});delete a._attrs,delete a._urlId,this.hls.trigger(Xe.LEVEL_SWITCHING,a);const l=s.details;if(!l||l.live){const e=this.switchParams(s.uri,null==i?void 0:i.details);this.loadPlaylist(e)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,void 0===this._startLevel&&(this._startLevel=e),-1!==e&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(void 0===this._startLevel){const e=this.hls.config.startLevel;return void 0!==e?e:this._firstLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){!t.fatal&&t.context&&t.context.type===Fr&&t.context.level===this.level&&this.checkRetry(t)}onFragLoaded(e,{frag:t}){if(void 0!==t&&t.type===jr){const e=this._levels[t.level];void 0!==e&&(e.loadError=0)}}onLevelLoaded(e,t){var r;const{level:i,details:n}=t,s=this._levels[i];var o;if(!s)return this.warn(`Invalid level index ${i}`),void(null!=(o=t.deliveryDirectives)&&o.skip&&(n.deltaUpdateFailed=!0));i===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0),this.playlistLoaded(i,t,s.details)):null!=(r=t.deliveryDirectives)&&r.skip&&(n.deltaUpdateFailed=!0)}onAudioTrackSwitched(e,t){const r=this.currentLevel;if(!r)return;const i=this.hls.audioTracks[t.id].groupId;if(r.audioGroupIds&&r.audioGroupId!==i){let e=-1;for(let t=0;tr!==t,i=this._levels.filter((i,n)=>n!==e||(i.url.length>1&&void 0!==t?(i.url=i.url.filter(r),i.audioGroupIds&&(i.audioGroupIds=i.audioGroupIds.filter(r)),i.textGroupIds&&(i.textGroupIds=i.textGroupIds.filter(r)),i.urlId=0,!0):(this.steering&&this.steering.removeLevel(i),!1)));this.hls.trigger(Xe.LEVELS_UPDATED,{levels:i})}onLevelsUpdated(e,{levels:t}){t.forEach((e,t)=>{const{details:r}=e;null!=r&&r.fragments&&r.fragments.forEach(e=>{e.level=t})}),this._levels=t}}function xi(e,t,r){r&&("audio"===t?(e.audioGroupIds||(e.audioGroupIds=[]),e.audioGroupIds[e.url.length-1]=r):"text"===t&&(e.textGroupIds||(e.textGroupIds=[]),e.textGroupIds[e.url.length-1]=r))}function Ri(e){const t={};e.forEach(e=>{const r=e.groupId||"";e.id=t[r]=t[r]||0,t[r]++})}var Pi="NOT_LOADED",Ii="APPENDING",Ci="PARTIAL",_i="OK";class Oi{constructor(e){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(Xe.BUFFER_APPENDED,this.onBufferAppended,this),e.on(Xe.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Xe.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(Xe.BUFFER_APPENDED,this.onBufferAppended,this),e.off(Xe.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Xe.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const r=this.activePartLists[t];if(r)for(let t=r.length;t--;){const i=r[t];if(!i)break;const n=i.end;if(i.start<=e&&null!==n&&e<=n)return i}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:r}=this,i=Object.keys(r);for(let n=i.length;n--;){const s=r[i[n]];if((null==s?void 0:s.body.type)===t&&s.buffered){const t=s.body;if(t.start<=e&&e<=t.end)return t}}return null}detectEvictedFragments(e,t,r,i){this.timeRanges&&(this.timeRanges[e]=t);const n=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(i=>{const s=this.fragments[i];if(!s)return;if(n>=s.body.sn)return;if(!s.buffered&&!s.loaded)return void(s.body.type===r&&this.removeFragment(s.body));const o=s.range[e];o&&o.time.some(e=>{const r=!this.isTimeBuffered(e.startPTS,e.endPTS,t);return r&&this.removeFragment(s.body),r})})}detectPartialFragments(e){const t=this.timeRanges,{frag:r,part:i}=e;if(!t||"initSegment"===r.sn)return;const n=Mi(r),s=this.fragments[n];if(!s||s.buffered&&r.gap)return;const o=!r.relurl;Object.keys(t).forEach(e=>{const n=r.elementaryStreams[e];if(!n)return;const a=t[e],l=o||!0===n.partial;s.range[e]=this.getBufferedTimes(r,i,l,a)}),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,(s.body.endList=r.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),Di(s)||this.removeParts(r.sn-1,r.type)):this.removeFragment(s.body)}removeParts(e,t){const r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(t=>t.fragment.sn>=e))}fragBuffered(e,t){const r=Mi(e);let i=this.fragments[r];!i&&t&&(i=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)}getBufferedTimes(e,t,r,i){const n={time:[],partial:r},s=e.start,o=e.end,a=e.minEndPTS||o,l=e.maxStartPTS||s;for(let e=0;e=t&&a<=r){n.time.push({startPTS:Math.max(s,i.start(e)),endPTS:Math.min(o,i.end(e))});break}if(st)n.partial=!0,n.time.push({startPTS:Math.max(s,i.start(e)),endPTS:Math.min(o,i.end(e))});else if(o<=t)break}return n}getPartialFragment(e){let t,r,i,n=null,s=0;const{bufferPadding:o,fragments:a}=this;return Object.keys(a).forEach(l=>{const c=a[l];c&&Di(c)&&(r=c.body.start-o,i=c.body.end+o,e>=r&&e<=i&&(t=Math.min(e-r,i-e),s<=t&&(n=c.body,s=t)))}),n}isEndListAppended(e){const t=this.endListFragments[e];return void 0!==t&&(t.buffered||Di(t))}getState(e){const t=Mi(e),r=this.fragments[t];return r?r.buffered?Di(r)?Ci:_i:Ii:Pi}isTimeBuffered(e,t,r){let i,n;for(let s=0;s=i&&t<=n)return!0;if(t<=i)return!1}return!1}onFragLoaded(e,t){const{frag:r,part:i}=t;if("initSegment"===r.sn||r.bitrateTest)return;const n=i?null:t,s=Mi(r);this.fragments[s]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:r,part:i,timeRanges:n}=t;if("initSegment"===r.sn)return;const s=r.type;if(i){let e=this.activePartLists[s];e||(this.activePartLists[s]=e=[]),e.push(i)}this.timeRanges=n,Object.keys(n).forEach(e=>{const t=n[e];this.detectEvictedFragments(e,t,s,i)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=Mi(e);return!!this.fragments[t]}hasParts(e){var t;return!(null==(t=this.activePartLists[e])||!t.length)}removeFragmentsInRange(e,t,r,i,n){i&&!this.hasGaps||Object.keys(this.fragments).forEach(s=>{const o=this.fragments[s];if(!o)return;const a=o.body;a.type!==r||i&&!a.gap||a.starte&&(o.buffered||n)&&this.removeFragment(a)})}removeFragment(e){const t=Mi(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const r=this.activePartLists[e.type];if(r){const t=e.sn;this.activePartLists[e.type]=r.filter(e=>e.fragment.sn!==t)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Di(e){var t,r,i;return e.buffered&&(e.body.gap||(null==(t=e.range.video)?void 0:t.partial)||(null==(r=e.range.audio)?void 0:r.partial)||(null==(i=e.range.audiovideo)?void 0:i.partial))}function Mi(e){return`${e.type}_${e.level}_${e.urlId}_${e.sn}`}const Ni=Math.pow(2,17);class Fi{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const r=e.url;if(!r)return Promise.reject(new ji({type:Qe.NETWORK_ERROR,details:Je.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error("Fragment does not have a "+(r?"part list":"url")),networkDetails:null}));this.abort();const i=this.config,n=i.fLoader,s=i.loader;return new Promise((o,a)=>{if(this.loader&&this.loader.destroy(),e.gap){if(e.tagList.some(e=>"GAP"===e[0]))return void a(Ui(e));e.gap=!1}const l=this.loader=e.loader=n?new n(i):new s(i),c=Bi(e),u=yi(i.fragLoadPolicy.default),d={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===e.sn?1/0:Ni};e.stats=l.stats,l.load(c,d,{onSuccess:(t,r,i,n)=>{this.resetLoader(e,l);let s=t.data;i.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),o({frag:e,part:null,payload:s,networkDetails:n})},onError:(t,i,n,s)=>{this.resetLoader(e,l),a(new ji({type:Qe.NETWORK_ERROR,details:Je.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:Ge({url:r,data:void 0},t),error:new Error(`HTTP Error ${t.code} ${t.text}`),networkDetails:n,stats:s}))},onAbort:(t,r,i)=>{this.resetLoader(e,l),a(new ji({type:Qe.NETWORK_ERROR,details:Je.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:i,stats:t}))},onTimeout:(t,r,i)=>{this.resetLoader(e,l),a(new ji({type:Qe.NETWORK_ERROR,details:Je.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${d.timeout}ms`),networkDetails:i,stats:t}))},onProgress:(r,i,n,s)=>{t&&t({frag:e,part:null,payload:n,networkDetails:s})}})})}loadPart(e,t,r){this.abort();const i=this.config,n=i.fLoader,s=i.loader;return new Promise((o,a)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap)return void a(Ui(e,t));const l=this.loader=e.loader=n?new n(i):new s(i),c=Bi(e,t),u=yi(i.fragLoadPolicy.default),d={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Ni};t.stats=l.stats,l.load(c,d,{onSuccess:(i,n,s,a)=>{this.resetLoader(e,l),this.updateStatsFromPart(e,t);const c={frag:e,part:t,payload:i.data,networkDetails:a};r(c),o(c)},onError:(r,i,n,s)=>{this.resetLoader(e,l),a(new ji({type:Qe.NETWORK_ERROR,details:Je.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:Ge({url:c.url,data:void 0},r),error:new Error(`HTTP Error ${r.code} ${r.text}`),networkDetails:n,stats:s}))},onAbort:(r,i,n)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,l),a(new ji({type:Qe.NETWORK_ERROR,details:Je.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:n,stats:r}))},onTimeout:(r,i,n)=>{this.resetLoader(e,l),a(new ji({type:Qe.NETWORK_ERROR,details:Je.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${d.timeout}ms`),networkDetails:n,stats:r}))}})})}updateStatsFromPart(e,t){const r=e.stats,i=t.stats,n=i.total;if(r.loaded+=i.loaded,n){const i=Math.round(e.duration/t.duration),s=Math.min(Math.round(r.loaded/n),i),o=(i-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);const s=r.loading,o=i.loading;s.start?s.first+=o.first-o.start:(s.start=o.start,s.first=o.first),s.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function Bi(e,t=null){const r=t||e,i={frag:e,part:t,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},n=r.byteRangeStartOffset,s=r.byteRangeEndOffset;if(qe(n)&&qe(s)){var o;let t=n,r=s;if("initSegment"===e.sn&&"AES-128"===(null==(o=e.decryptdata)?void 0:o.method)){const e=s-n;e%16&&(r=s+(16-e%16)),0!==n&&(i.resetIV=!0,t=n-16)}i.rangeStart=t,i.rangeEnd=r}return i}function Ui(e,t){const r=new Error(`GAP ${e.gap?"tag":"attribute"} found`),i={type:Qe.MEDIA_ERROR,details:Je.FRAG_GAP,fatal:!1,frag:e,error:r,networkDetails:null};return t&&(i.part=t),(t||e).stats.aborted=!0,new ji(i)}class ji extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class $i{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const t in this.keyUriToKeyInfo){const r=this.keyUriToKeyInfo[t].loader;if(r){if(e&&e!==r.context.frag.type)return;r.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=Je.KEY_LOAD_ERROR,r,i,n){return new ji({type:Qe.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:i})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:r,cc:i}=e;for(let e=0;e{n.setKeyFormat(e)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,i;t&&e.setKeyFormat(t);const n=e.decryptdata;if(!n){const r=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,Je.KEY_LOAD_ERROR,r))}const s=n.uri;if(!s)return Promise.reject(this.createKeyLoadError(e,Je.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${s}"`)));let o=this.keyUriToKeyInfo[s];if(null!=(r=o)&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});var a;if(null!=(i=o)&&i.keyLoadPromise)switch(null==(a=o.mediaKeySessionContext)?void 0:a.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(t=>(n.key=t.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}switch(o=this.keyUriToKeyInfo[s]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===n.keyFormat?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,Je.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){const r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const t=this.emeController.loadKey(r);if(t)return(e.keyLoadPromise=t.then(t=>(e.mediaKeySessionContext=t,r))).catch(t=>{throw e.keyLoadPromise=null,t})}return Promise.resolve(r)}loadKeyHTTP(e,t){const r=this.config,i=new(0,r.loader)(r);return t.keyLoader=e.loader=i,e.keyLoadPromise=new Promise((n,s)=>{const o={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},a=r.keyLoadPolicy.default,l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(e,t,r,i)=>{const{frag:o,keyInfo:a,url:l}=r;if(!o.decryptdata||a!==this.keyUriToKeyInfo[l])return s(this.createKeyLoadError(o,Je.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),i));a.decryptdata.key=o.decryptdata.key=new Uint8Array(e.data),o.keyLoader=null,a.loader=null,n({frag:o,keyInfo:a})},onError:(e,r,i,n)=>{this.resetLoader(r),s(this.createKeyLoadError(t,Je.KEY_LOAD_ERROR,new Error(`HTTP Error ${e.code} loading key ${e.text}`),i,Ge({url:o.url,data:void 0},e)))},onTimeout:(e,r,i)=>{this.resetLoader(r),s(this.createKeyLoadError(t,Je.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(e,r,i)=>{this.resetLoader(r),s(this.createKeyLoadError(t,Je.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};i.load(o,l,c)})}resetLoader(e){const{frag:t,keyInfo:r,url:i}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[i],n&&n.destroy()}}class Vi{constructor(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(e){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}const Hi={length:0,start:()=>0,end:()=>0};class Gi{static isBuffered(e,t){try{if(e){const r=Gi.getBuffered(e);for(let e=0;e=r.start(e)&&t<=r.end(e))return!0}}catch(e){}return!1}static bufferInfo(e,t,r){try{if(e){const i=Gi.getBuffered(e),n=[];let s;for(s=0;ss&&(i[n-1].end=e[t].end):i.push(e[t])}else i.push(e[t])}else i=e;let n,s=0,o=t,a=t;for(let e=0;e=l&&t>>8^255&r^99,e[f]=r,t[r]=f;const a=h[f],g=h[a],m=h[g];let y=257*h[r]^16843008*r;i[f]=y<<24|y>>>8,n[f]=y<<16|y>>>16,s[f]=y<<8|y>>>24,o[f]=y,y=16843009*m^65537*g^257*a^16843008*f,l[r]=y<<24|y>>>8,c[r]=y<<16|y>>>16,u[r]=y<<8|y>>>24,d[r]=y,f?(f=a^h[h[h[m^a]]],p^=h[h[p]]):f=p=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let r=!0,i=0;for(;ii?(this.logOnce("WebCrypto AES decrypt"),new Xi(i,new Uint8Array(r)).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))).catch(i=>(rt.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${i.name}: ${i.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);const i=this.flush();if(i)return i.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const r=e.length-e.length%16;return r!==e.length&&(t=Pt(e,0,r),this.remainderData=Pt(e,r)),t}logOnce(e){this.logEnabled&&(rt.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const en="STOPPED",tn="IDLE",rn="KEY_LOADING",nn="FRAG_LOADING",sn="FRAG_LOADING_WAITING_RETRY",on="WAITING_TRACK",an="PARSING",ln="PARSED",cn="ENDED",un="ERROR",dn="WAITING_INIT_PTS",hn="WAITING_LEVEL";class fn extends Vi{constructor(e,t,r,i,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=en,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.loadedmetadata=!1,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=i,this.log=rt.log.bind(rt,`${i}:`),this.warn=rt.warn.bind(rt,`${i}:`),this.hls=e,this.fragmentLoader=new Fi(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Zi(e.config),e.on(Xe.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;null!=e&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=en}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const r=t.partList;if(null!=r&&r.length){const e=r[r.length-1];return Gi.isBuffered(this.media,e.start+e.duration/2)}const i=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(i)}getLevelDetails(){var e;if(this.levels&&null!==this.levelLastLoaded)return null==(e=this.levels[this.levelLastLoaded])?void 0:e.details}onMediaAttached(e,t){const r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);const i=this.config;this.levels&&i.autoStartLoad&&this.state===en&&this.startLoad(i.startPosition)}onMediaDetaching(){const e=this.media;null!=e&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:r,mediaBuffer:i,state:n}=this,s=r?r.currentTime:0,o=Gi.bufferInfo(i||r,s,e.maxBufferHole);if(this.log(`media seeking to ${qe(s)?s.toFixed(3):s}, state: ${n}`),this.state===cn)this.resetLoadingState();else if(t){const r=e.maxFragLookUpTolerance,i=t.start-r,n=t.start+t.duration+r;if(!o.len||no.end){const e=s>n;(s{if(this.fragContextChanged(e))return this.warn(`Fragment ${e.sn}${t.part?" p: "+t.part.index:""} of level ${e.level} was dropped during download.`),void this.fragmentTracker.removeFragment(e);e.stats.chunkCount++,this._handleFragmentLoadProgress(t)}).then(t=>{if(!t)return;const r=this.state;this.fragContextChanged(e)?(r===nn||!this.fragCurrent&&r===an)&&(this.fragmentTracker.removeFragment(e),this.state=tn):("payload"in t&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(Xe.FRAG_LOADED,t)),this._handleFragmentLoadComplete(t))}).catch(t=>{this.state!==en&&this.state!==un&&(this.warn(t),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:r}=this;if(r.getState(e)===Ii){const t=e.type,i=this.getFwdBufferInfo(this.mediaBuffer,t),n=Math.max(e.duration,i?i.len:this.config.maxBufferLength);this.reduceMaxBufferLength(n)&&r.removeFragment(e)}else 0===(null==(t=this.mediaBuffer)?void 0:t.buffered.length)?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===Ci&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){if(!(e-t))return;const i={startOffset:e,endOffset:t,type:r};this.hls.trigger(Xe.BUFFER_FLUSHING,i)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(t=>{if(!t||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return t}).then(t=>{const{hls:r}=this,{payload:i}=t,n=e.decryptdata;if(i&&i.byteLength>0&&n&&n.key&&n.iv&&"AES-128"===n.method){const s=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer).catch(t=>{throw r.trigger(Xe.ERROR,{type:Qe.MEDIA_ERROR,details:Je.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t}).then(i=>{const n=self.performance.now();return r.trigger(Xe.FRAG_DECRYPTED,{frag:e,payload:i,stats:{tstart:s,tdecrypt:n}}),t.payload=i,t})}return t}).then(r=>{const{fragCurrent:i,hls:n,levels:s}=this;if(!s)throw new Error("init load aborted, missing levels");const o=e.stats;this.state=tn,t.fragmentError=0,e.data=new Uint8Array(r.payload),o.parsing.start=o.buffering.start=self.performance.now(),o.parsing.end=o.buffering.end=self.performance.now(),r.frag===i&&n.trigger(Xe.FRAG_BUFFERED,{stats:o,frag:i,part:null,id:e.type}),this.tick()}).catch(t=>{this.state!==en&&this.state!==un&&(this.warn(t),this.resetFragmentLoading(e))})}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.level!==t.level||e.sn!==t.sn||e.urlId!==t.urlId}fragBufferedComplete(e,t){var r,i,n,s;const o=this.mediaBuffer?this.mediaBuffer:this.media;this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===jr?"level":"track"} ${e.level} (frag:[${(null!=(r=e.startPTS)?r:NaN).toFixed(3)}-${(null!=(i=e.endPTS)?i:NaN).toFixed(3)}] > buffer:${o?function(e){let t="";const r=e.length;for(let i=0;i!e),o=new Ki(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!s);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,i){var n;const s=null==t?void 0:t.details;if(!this.levels||!s)throw new Error(`frag load aborted, missing level${s?"":" detail"}s`);let o=null;if(!e.encrypted||null!=(n=e.decryptdata)&&n.key?!e.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(e,s.encryptedFragments):(this.log(`Loading key for ${e.sn} of [${s.startSN}-${s.endSN}], ${"[stream-controller]"===this.logPrefix?"level":"track"} ${e.level}`),this.state=rn,this.fragCurrent=e,o=this.keyLoader.load(e).then(e=>{if(!this.fragContextChanged(e.frag))return this.hls.trigger(Xe.KEY_LOADED,e),this.state===rn&&(this.state=tn),e}),this.hls.trigger(Xe.KEY_LOADING,{frag:e}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&"initSegment"!==e.sn){const n=s.partList;if(n&&i){r>e.end&&s.fragmentHint&&(e=s.fragmentHint);const a=this.getNextPart(n,e,r);if(a>-1){const l=n[a];let c;return this.log(`Loading part sn: ${e.sn} p: ${l.index} cc: ${e.cc} of playlist [${s.startSN}-${s.endSN}] parts [0-${a}-${n.length-1}] ${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=l.start+l.duration,this.state=nn,c=o?o.then(r=>!r||this.fragContextChanged(r.frag)?null:this.doFragPartsLoad(e,l,t,i)).catch(e=>this.handleFragLoadError(e)):this.doFragPartsLoad(e,l,t,i).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(Xe.FRAG_LOADING,{frag:e,part:l,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!e.url||this.loadedEndOfParts(n,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${s?"of ["+s.startSN+"-"+s.endSN+"] ":""}${"[stream-controller]"===this.logPrefix?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),qe(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=nn;const a=this.config.progressive;let l;return l=a&&o?o.then(t=>!t||this.fragContextChanged(null==t?void 0:t.frag)?null:this.fragmentLoader.load(e,i)).catch(e=>this.handleFragLoadError(e)):Promise.all([this.fragmentLoader.load(e,a?i:void 0),o]).then(([e])=>(!a&&e&&i&&i(e),e)).catch(e=>this.handleFragLoadError(e)),this.hls.trigger(Xe.FRAG_LOADING,{frag:e,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):l}doFragPartsLoad(e,t,r,i){return new Promise((n,s)=>{var o;const a=[],l=null==(o=r.details)?void 0:o.partList,c=t=>{this.fragmentLoader.loadPart(e,t,i).then(i=>{a[t.index]=i;const s=i.part;this.hls.trigger(Xe.FRAG_LOADED,i);const o=hi(r,e.sn,t.index+1)||fi(l,e.sn,t.index+1);if(!o)return n({frag:e,part:s,partsLoaded:a});c(o)}).catch(s)};c(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===Je.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(Xe.ERROR,t)}else this.hls.trigger(Xe.ERROR,{type:Qe.OTHER_ERROR,details:Je.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==an)return void(this.fragCurrent||this.state===en||this.state===un||(this.state=tn));const{frag:r,part:i,level:n}=t,s=self.performance.now();r.stats.parsing.end=s,i&&(i.stats.parsing.end=s),this.updateLevelTiming(r,i,n,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:r}=this,{level:i,sn:n,part:s}=e;if(null==t||!t[i])return this.warn(`Levels object was unset while buffering fragment ${n} of level ${i}. The current chunk will not be buffered.`),null;const o=t[i],a=s>-1?hi(o,n,s):null,l=a?a.fragment:function(e,t,r){if(null==e||!e.details)return null;const i=e.details;let n=i.fragments[t-i.startSN];return n||(n=i.fragmentHint,n&&n.sn===t?n:ts&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){const r=this.getLoadPosition();return qe(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){const{config:{maxBufferHole:i}}=this,n=Gi.bufferInfo(e,t,i);if(0===n.len&&void 0!==n.nextStart){const s=this.fragmentTracker.getBufferedFrag(t,r);if(s&&n.nextStart=r&&(t.maxMaxBufferLength/=2,this.warn(`Reduce max buffer length to ${t.maxMaxBufferLength}s`),!0)}getAppendedFrag(e,t=jr){const r=this.fragmentTracker.getAppendedFrag(e,jr);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){const r=t.fragments,i=r.length;if(!i)return null;const{config:n}=this,s=r[0].start;let o;if(t.live){const s=n.initialLiveManifestSize;if(it}getNextFragmentLoopLoading(e,t,r,i,n){const s=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(null===o)return o;if(e=o,s&&e&&!e.gap&&r.nextStart){const t=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i);if(null!==t&&r.len+t.len>=n)return this.log(`buffer full after gaps in "${i}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return null==e||!e.initSegment||null!=e&&e.initSegment.data||this.bitrateTest?e:e.initSegment}getNextPart(e,t,r){let i=-1,n=!1,s=!0;for(let o=0,a=e.length;o-1&&rr.start&&r.loaded}getInitialLiveFragment(e,t){const r=this.fragPrevious;let i=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),i=function(e,t,r){if(null===t||!Array.isArray(e)||!e.length||!qe(t))return null;if(t<(e[0].programDateTime||0))return null;if(t>=(e[e.length-1].endProgramDateTime||0))return null;r=r||0;for(let i=0;i=e.startSN&&n<=e.endSN){const s=t[n-e.startSN];r.cc===s.cc&&(i=s,this.log(`Live playlist, switching playlist, load frag with next SN: ${i.sn}`))}i||(i=function(e,t){return bi(e,e=>e.cct?-1:0)}(t,r.cc),i&&this.log(`Live playlist, switching playlist, load frag with same CC: ${i.sn}`))}}else{const t=this.hls.liveSyncPosition;null!==t&&(i=this.getFragmentAtPosition(t,this.bitrateTest?e.fragmentEnd:e.edge,e))}return i}getFragmentAtPosition(e,t,r){const{config:i}=this;let{fragPrevious:n}=this,{fragments:s,endSN:o}=r;const{fragmentHint:a}=r,l=i.maxFragLookUpTolerance,c=r.partList,u=!!(i.lowLatencyMode&&null!=c&&c.length&&a);let d;if(u&&a&&!this.bitrateTest&&(s=s.concat(a),o=a.sn),d=et-l?0:l):s[s.length-1],d){const e=d.sn-r.startSN,t=this.fragmentTracker.getState(d);if((t===_i||t===Ci&&d.gap)&&(n=d),n&&d.sn===n.sn&&(!u||c[0].fragment.sn>d.sn)&&n&&d.level===n.level){const t=s[e+1];d=d.sn=s-t.maxFragLookUpTolerance&&n<=o;if(null!==i&&r.duration>i&&(nr.startCC||e&&e.cc${e.startSN} prev-sn: ${n?n.sn:"na"} fragments: ${o}`),r}return a}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,3*e.partTarget)}setStartPosition(e,t){let r=this.startPosition;if(r ${null==(i=this.fragCurrent)?void 0:i.url}`);const n=t.details===Je.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(r,!0);const s=t.errorAction,{action:o,retryCount:a=0,retryConfig:l}=s||{};if(s&&5===o&&l){var c;this.resetStartWhenNotLoaded(null!=(c=this.levelLastLoaded)?c:r.level);const i=mi(l,a);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${a+1}/${l.maxNumRetry} in ${i}ms`),s.resolved=!0,this.retryDate=self.performance.now()+i,this.state=sn}else l&&s?(this.resetFragmentErrors(e),a.5;i&&this.reduceMaxBufferLength(r.len);const n=!i;return n&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===$r&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==en&&(this.state=tn)}afterBufferFlushed(e,t,r){if(!e)return;const i=Gi.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,i,r),this.state===cn&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=tn}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=this.levels?this.levels[e].details:null;null!=t&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){var t;this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(null!=(t=this.levelLastLoaded)?t:e.level),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,i){var n;const s=r.details;if(s){if(Object.keys(e.elementaryStreams).reduce((t,n)=>{const o=e.elementaryStreams[n];if(o){const a=o.endPTS-o.startPTS;if(a<=0)return this.warn(`Could not parse fragment ${e.sn} ${n} duration reliably (${a})`),t||!1;const l=i?0:ci(s,e,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return this.hls.trigger(Xe.LEVEL_PTS_UPDATED,{details:s,level:r,drift:l,type:n,frag:e,start:o.startPTS,end:o.endPTS}),!0}return t},!1))r.fragmentError=0;else if(null===(null==(n=this.transmuxer)?void 0:n.error)){const t=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(0===r.fragmentError&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(t.message),this.hls.trigger(Xe.ERROR,{type:Qe.MEDIA_ERROR,details:Je.FRAG_PARSING_ERROR,fatal:!1,error:t,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=ln,this.hls.trigger(Xe.FRAG_PARSED,{frag:e,part:t})}else this.warn("level.details undefined")}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){var t,r,i;"demuxerWorker"===e.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(t=null!=(r=this.levelLastLoaded)?r:null==(i=this.fragCurrent)?void 0:i.level)?t:0),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}function pn(){return self.SourceBuffer||self.WebKitSourceBuffer}function gn(e="",t=9e4){return{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}class mn{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(e,t,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=or(this.cachedData,e),this.cachedData=null);let r,i=_t(e,0),n=i?i.length:0;const s=this._audioTrack,o=this._id3Track,a=i?(e=>{const t=Ft(e);for(let e=0;e0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Xr,duration:Number.POSITIVE_INFINITY});nqe(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0);function vn(e,t){return 255===e[t]&&240==(246&e[t+1])}function bn(e,t){return 1&e[t+1]?7:9}function En(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function An(e,t){return t+1=e.length)return!1;const i=En(e,t);if(i<=r)return!1;const n=t+i;return n===e.length||An(e,n)}return!1}function wn(e,t,r,i,n){if(!e.samplerate){const s=function(e,t,r,i){let n,s,o,a;const l=navigator.userAgent.toLowerCase(),c=i,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=((192&t[r+2])>>>6)+1;const d=(60&t[r+2])>>>2;if(!(d>u.length-1))return o=(1&t[r+2])<<2,o|=(192&t[r+3])>>>6,rt.log(`manifest codec:${i}, ADTS type:${n}, samplingIndex:${d}`),/firefox/i.test(l)?d>=6?(n=5,a=new Array(4),s=d-3):(n=2,a=new Array(2),s=d):-1!==l.indexOf("android")?(n=2,a=new Array(2),s=d):(n=5,a=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&d>=6?s=d-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(d>=6&&1===o||/vivaldi/i.test(l))||!i&&1===o)&&(n=2,a=new Array(2)),s=d)),a[0]=n<<3,a[0]|=(14&d)>>1,a[1]|=(1&d)<<7,a[1]|=o<<3,5===n&&(a[1]|=(14&s)>>1,a[2]=(1&s)<<7,a[2]|=8,a[3]=0),{config:a,samplerate:u[d],channelCount:o,codec:"mp4a.40."+n,manifestCodec:c};e.trigger(Xe.ERROR,{type:Qe.MEDIA_ERROR,details:Je.FRAG_PARSING_ERROR,fatal:!0,reason:`invalid ADTS sampling index:${d}`})}(t,r,i,n);if(!s)return;e.config=s.config,e.samplerate=s.samplerate,e.channelCount=s.channelCount,e.codec=s.codec,e.manifestCodec=s.manifestCodec,rt.log(`parsed codec:${e.codec}, rate:${s.samplerate}, channels:${s.channelCount}`)}}function Sn(e){return 9216e4/e}function kn(e,t,r,i,n){const s=i+n*Sn(e.samplerate),o=function(e,t){const r=bn(e,t);if(t+r<=e.length){const i=En(e,t)-r;if(i>0)return{headerLength:r,frameLength:i}}}(t,r);let a;if(o){const{frameLength:i,headerLength:n}=o,l=n+i,c=Math.max(0,r+l-t.length);c?(a=new Uint8Array(l-n),a.set(t.subarray(r+n,t.length),0)):a=t.subarray(r+n,r+l);const u={unit:a,pts:s};return c||e.samples.push(u),{sample:u,length:l,missing:c}}const l=t.length-r;return a=new Uint8Array(l),a.set(t.subarray(r,t.length),0),{sample:{unit:a,pts:s},length:l,missing:-1}}const Ln=/\/emsg[-/]ID3/i;let xn=null;const Rn=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],Pn=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],In=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Cn=[0,1,1,4];function _n(e,t,r,i,n){if(r+24>t.length)return;const s=On(t,r);if(s&&r+s.frameLength<=t.length){const o=i+n*(9e4*s.samplesPerFrame/s.sampleRate),a={unit:t.subarray(r,r+s.frameLength),pts:o,dts:o};return e.config=[],e.channelCount=s.channelCount,e.samplerate=s.sampleRate,e.samples.push(a),{sample:a,length:s.frameLength,missing:0}}}function On(e,t){const r=e[t+1]>>3&3,i=e[t+1]>>1&3,n=e[t+2]>>4&15,s=e[t+2]>>2&3;if(1!==r&&0!==n&&15!==n&&3!==s){const o=e[t+2]>>1&1,a=e[t+3]>>6,l=1e3*Rn[14*(3===r?3-i:3===i?3:4)+n-1],c=Pn[3*(3===r?0:2===r?1:2)+s],u=3===a?1:2,d=In[r][i],h=Cn[i],f=8*d*h,p=Math.floor(d*l/c+o)*h;if(null===xn){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);xn=e?parseInt(e[1]):0}return!!xn&&xn<=87&&2===i&&l>=224e3&&0===a&&(e[t+3]=128|e[t+3]),{sampleRate:c,channelCount:u,frameLength:p,samplesPerFrame:f}}}function Dn(e,t){return!(255!==e[t]||224&~e[t+1]||!(6&e[t+1]))}function Mn(e,t){return t+1e?(this.word<<=e,this.bitsAvailable-=e):(t=(e-=this.bitsAvailable)>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const r=this.word>>>32-t;if(e>32&&rt.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return t=e-t,t>0&&this.bitsAvailable?r<>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t,r=8,i=8;for(let n=0;n{const s=new Uint8Array(n);i.set(s,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32||(this.decryptAacSample(e,t,r),this.decrypter.isSync())))return}}getAvcEncryptedData(e){const t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t);let i=0;for(let t=32;t{n.data=this.getAvcDecryptedUnit(s,o),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,i)})}decryptAvcSamples(e,t,r,i){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void i();const n=e[t].units;for(;!(r>=n.length);r++){const s=n[r];if(!(s.data.length<=48||1!==s.type&&5!==s.type||(this.decryptAvcSample(e,t,r,i,s),this.decrypter.isSync())))return}}}}const Un=188;class jn{constructor(e,t,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=e,this.config=t,this.typeSupported=r}static probe(e){const t=jn.syncOffset(e);return t>0&&rt.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),-1!==t}static syncOffset(e){const t=e.length;let r=Math.min(940,e.length-Un)+1,i=0;for(;i1&&(0===s&&o>2||a+Un>r))return s}i++}return-1}static createTrack(e,t){return{container:"video"===e||"audio"===e?"video/mp2t":void 0,type:e,id:Yt[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===e?t:void 0}}resetInitSegment(e,t,r,i){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=jn.createTrack("video"),this._audioTrack=jn.createTrack("audio",i),this._id3Track=jn.createTrack("id3"),this._txtTrack=jn.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=i}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_avcTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null}demux(e,t,r=!1,i=!1){let n;r||(this.sampleAes=null);const s=this._avcTrack,o=this._audioTrack,a=this._id3Track,l=this._txtTrack;let c=s.pid,u=s.pesData,d=o.pid,h=a.pid,f=o.pesData,p=a.pesData,g=null,m=this.pmtParsed,y=this._pmtId,v=e.length;if(this.remainderData&&(v=(e=or(this.remainderData,e)).length,this.remainderData=null),v>4>1){if(E=t+5+e[t+4],E===t+Un)continue}else E=t+4;switch(v){case c:i&&(u&&(n=Kn(u))&&this.parseAVCPES(s,l,n,!1),u={data:[],size:0}),u&&(u.data.push(e.subarray(E,t+Un)),u.size+=t+Un-E);break;case d:if(i){if(f&&(n=Kn(f)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n)}f={data:[],size:0}}f&&(f.data.push(e.subarray(E,t+Un)),f.size+=t+Un-E);break;case h:i&&(p&&(n=Kn(p))&&this.parseID3PES(a,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(E,t+Un)),p.size+=t+Un-E);break;case 0:i&&(E+=e[E]+1),y=this._pmtId=Hn(e,E);break;case y:{i&&(E+=e[E]+1);const n=Gn(e,E,this.typeSupported,r);c=n.avc,c>0&&(s.pid=c),d=n.audio,d>0&&(o.pid=d,o.segmentCodec=n.segmentCodec),h=n.id3,h>0&&(a.pid=h),null===g||m||(rt.warn(`MPEG-TS PMT found at ${t} after unknown PID '${g}'. Backtracking to sync byte @${b} to parse all TS packets.`),g=null,t=b-188),m=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=v}}else E++;if(E>0){const e=new Error(`Found ${E} TS packet/s that do not start with 0x47`);this.observer.emit(Xe.ERROR,Xe.ERROR,{type:Qe.MEDIA_ERROR,details:Je.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message})}s.pesData=u,o.pesData=f,a.pesData=p;const A={audioTrack:o,videoTrack:s,id3Track:a,textTrack:l};return i&&this.extractRemainingSamples(A),A}flush(){const{remainderData:e}=this;let t;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:r,id3Track:i,textTrack:n}=e,s=r.pesData,o=t.pesData,a=i.pesData;let l;if(s&&(l=Kn(s))?(this.parseAVCPES(r,n,l,!0),r.pesData=null):r.pesData=s,o&&(l=Kn(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,l);break;case"mp3":this.parseMPEGPES(t,l)}t.pesData=null}else null!=o&&o.size&&rt.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;a&&(l=Kn(a))?(this.parseID3PES(i,l),i.pesData=null):i.pesData=a}demuxSampleAes(e,t,r){const i=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new Bn(this.observer,this.config,t);return this.decrypt(i,n)}decrypt(e,t){return new Promise(r=>{const{audioTrack:i,videoTrack:n}=e;i.samples&&"aac"===i.segmentCodec?t.decryptAacSamples(i.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAVCPES(e,t,r,i){const n=this.parseAVCNALu(e,r.data);let s,o=this.avcSample,a=!1;r.data=null,o&&n.length&&!e.audFound&&(Wn(o,e),o=this.avcSample=$n(!1,r.pts,r.dts,"")),n.forEach(i=>{var n;switch(i.type){case 1:{let t=!1;s=!0;const n=i.data;if(a&&n.length>4){const e=new Fn(n).readSliceType();2!==e&&4!==e&&7!==e&&9!==e||(t=!0)}var l;t&&null!=(l=o)&&l.frame&&!o.key&&(Wn(o,e),o=this.avcSample=null),o||(o=this.avcSample=$n(!0,r.pts,r.dts,"")),o.frame=!0,o.key=t;break}case 5:s=!0,null!=(n=o)&&n.frame&&!o.key&&(Wn(o,e),o=this.avcSample=null),o||(o=this.avcSample=$n(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:s=!0,cr(i.data,1,r.pts,t.samples);break;case 7:if(s=!0,a=!0,!e.sps){const t=i.data,r=new Fn(t).readSPS();e.width=r.width,e.height=r.height,e.pixelRatio=r.pixelRatio,e.sps=[t],e.duration=this._duration;const n=t.subarray(1,4);let s="avc1.";for(let e=0;e<3;e++){let t=n[e].toString(16);t.length<2&&(t="0"+t),s+=t}e.codec=s}break;case 8:s=!0,e.pps||(e.pps=[i.data]);break;case 9:s=!1,e.audFound=!0,o&&Wn(o,e),o=this.avcSample=$n(!1,r.pts,r.dts,"");break;case 12:s=!0;break;default:s=!1,o&&(o.debug+="unknown NAL "+i.type+" ")}o&&s&&o.units.push(i)}),i&&o&&(Wn(o,e),this.avcSample=null)}getLastNalUnit(e){var t;let r,i=this.avcSample;if(i&&0!==i.units.length||(i=e[e.length-1]),null!=(t=i)&&t.units){const e=i.units;r=e[e.length-1]}return r}parseAVCNALu(e,t){const r=t.byteLength;let i=e.naluState||0;const n=i,s=[];let o,a,l,c=0,u=-1,d=0;for(-1===i&&(u=0,d=31&t[0],i=0,c=1);c=0){const e={data:t.subarray(u,c-i-1),type:d};s.push(e)}else{const r=this.getLastNalUnit(e.samples);if(r&&(n&&c<=4-n&&r.state&&(r.data=r.data.subarray(0,r.data.byteLength-n)),a=c-i-1,a>0)){const e=new Uint8Array(r.data.byteLength+a);e.set(r.data,0),e.set(t.subarray(0,a),r.data.byteLength),r.data=e,r.state=0}}c=0&&i>=0){const e={data:t.subarray(u,r),type:d,state:i};s.push(e)}if(0===s.length){const r=this.getLastNalUnit(e.samples);if(r){const e=new Uint8Array(r.data.byteLength+t.byteLength);e.set(r.data,0),e.set(t,r.data.byteLength),r.data=e}}return e.naluState=i,s}parseAACPES(e,t){let r=0;const i=this.aacOverFlow;let n,s,o,a=t.data;if(i){this.aacOverFlow=null;const t=i.missing,n=i.sample.unit.byteLength;if(-1===t){const e=new Uint8Array(n+a.byteLength);e.set(i.sample.unit,0),e.set(a,n),a=e}else{const s=n-t;i.sample.unit.set(a.subarray(0,t),s),e.samples.push(i.sample),r=i.missing}}for(n=r,s=a.length;n1;){const e=new Uint8Array(a[0].length+a[1].length);e.set(a[0]),e.set(a[1],a[0].length),a[0]=e,a.splice(1,1)}if(t=a[0],1===(t[0]<<16)+(t[1]<<8)+t[2]){if(r=(t[4]<<8)+t[5],r&&r>e.size-6)return null;const l=t[7];192&l&&(n=536870912*(14&t[9])+4194304*(255&t[10])+16384*(254&t[11])+128*(255&t[12])+(254&t[13])/2,64&l?(s=536870912*(14&t[14])+4194304*(255&t[15])+16384*(254&t[16])+128*(255&t[17])+(254&t[18])/2,n-s>54e5&&(rt.warn(`${Math.round((n-s)/9e4)}s delta between PTS and DTS, align them`),n=s)):s=n),i=t[8];let c=i+9;if(e.size<=c)return null;e.size-=c;const u=new Uint8Array(e.size);for(let e=0,r=a.length;er){c-=r;continue}t=t.subarray(c),r-=c,c=0}u.set(t,o),o+=r}return r&&(r-=i+3),{data:u,pts:n,dts:s,len:r}}return null}function Wn(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){const r=t.samples,i=r.length;if(!i)return void t.dropped++;{const t=r[i-1];e.pts=t.pts,e.dts=t.dts}}t.samples.push(e)}e.debug.length&&rt.log(e.pts+"/"+e.dts+":"+e.debug)}class qn{static getSilentFrame(e,t){if("mp4a.40.2"===e){if(1===t)return new Uint8Array([0,200,0,128,35,128]);if(2===t)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===t)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===t)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===t)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}const zn=Math.pow(2,32)-1;class Yn{static init(){let e;for(e in Yn.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},Yn.types)Yn.types.hasOwnProperty(e)&&(Yn.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),r=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);Yn.HDLR_TYPES={video:t,audio:r};const i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);Yn.STTS=Yn.STSC=Yn.STCO=n,Yn.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),Yn.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),Yn.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),Yn.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const s=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),a=new Uint8Array([0,0,0,1]);Yn.FTYP=Yn.box(Yn.types.ftyp,s,a,s,o),Yn.DINF=Yn.box(Yn.types.dinf,Yn.box(Yn.types.dref,i))}static box(e,...t){let r=8,i=t.length;const n=i;for(;i--;)r+=t[i].byteLength;const s=new Uint8Array(r);for(s[0]=r>>24&255,s[1]=r>>16&255,s[2]=r>>8&255,s[3]=255&r,s.set(e,4),i=0,r=8;i>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))}static mdia(e){return Yn.box(Yn.types.mdia,Yn.mdhd(e.timescale,e.duration),Yn.hdlr(e.type),Yn.minf(e))}static mfhd(e){return Yn.box(Yn.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))}static minf(e){return"audio"===e.type?Yn.box(Yn.types.minf,Yn.box(Yn.types.smhd,Yn.SMHD),Yn.DINF,Yn.stbl(e)):Yn.box(Yn.types.minf,Yn.box(Yn.types.vmhd,Yn.VMHD),Yn.DINF,Yn.stbl(e))}static moof(e,t,r){return Yn.box(Yn.types.moof,Yn.mfhd(e),Yn.traf(r,t))}static moov(e){let t=e.length;const r=[];for(;t--;)r[t]=Yn.trak(e[t]);return Yn.box.apply(null,[Yn.types.moov,Yn.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(Yn.mvex(e)))}static mvex(e){let t=e.length;const r=[];for(;t--;)r[t]=Yn.trex(e[t]);return Yn.box.apply(null,[Yn.types.mvex,...r])}static mvhd(e,t){t*=e;const r=Math.floor(t/(zn+1)),i=Math.floor(t%(zn+1)),n=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,r>>24,r>>16&255,r>>8&255,255&r,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return Yn.box(Yn.types.mvhd,n)}static sdtp(e){const t=e.samples||[],r=new Uint8Array(4+t.length);let i,n;for(i=0;i>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(r));for(t=0;t>>8&255),s.push(255&i),s=s.concat(Array.prototype.slice.call(r));const o=Yn.box(Yn.types.avcC,new Uint8Array([1,n[3],n[4],n[5],255,224|e.sps.length].concat(n).concat([e.pps.length]).concat(s))),a=e.width,l=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return Yn.box(Yn.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,a>>8&255,255&a,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,Yn.box(Yn.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),Yn.box(Yn.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,u>>24,u>>16&255,u>>8&255,255&u])))}static esds(e){const t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static mp4a(e){const t=e.samplerate;return Yn.box(Yn.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]),Yn.box(Yn.types.esds,Yn.esds(e)))}static mp3(e){const t=e.samplerate;return Yn.box(Yn.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,255&t,0,0]))}static stsd(e){return"audio"===e.type?"mp3"===e.segmentCodec&&"mp3"===e.codec?Yn.box(Yn.types.stsd,Yn.STSD,Yn.mp3(e)):Yn.box(Yn.types.stsd,Yn.STSD,Yn.mp4a(e)):Yn.box(Yn.types.stsd,Yn.STSD,Yn.avc1(e))}static tkhd(e){const t=e.id,r=e.duration*e.timescale,i=e.width,n=e.height,s=Math.floor(r/(zn+1)),o=Math.floor(r%(zn+1));return Yn.box(Yn.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,n>>8&255,255&n,0,0]))}static traf(e,t){const r=Yn.sdtp(e),i=e.id,n=Math.floor(t/(zn+1)),s=Math.floor(t%(zn+1));return Yn.box(Yn.types.traf,Yn.box(Yn.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),Yn.box(Yn.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,s>>24,s>>16&255,s>>8&255,255&s])),Yn.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,Yn.box(Yn.types.trak,Yn.tkhd(e),Yn.mdia(e))}static trex(e){const t=e.id;return Yn.box(Yn.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const r=e.samples||[],i=r.length,n=12+16*i,s=new Uint8Array(n);let o,a,l,c,u,d;for(t+=8+n,s.set(["video"===e.type?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,t>>>24&255,t>>>16&255,t>>>8&255,255&t],0),o=0;o>>24&255,l>>>16&255,l>>>8&255,255&l,c>>>24&255,c>>>16&255,c>>>8&255,255&c,u.isLeading<<2|u.dependsOn,u.isDependedOn<<6|u.hasRedundancy<<4|u.paddingValue<<1|u.isNonSync,61440&u.degradPrio,15&u.degradPrio,d>>>24&255,d>>>16&255,d>>>8&255,255&d],12+16*o);return Yn.box(Yn.types.trun,s)}static initSegment(e){Yn.types||Yn.init();const t=Yn.moov(e),r=new Uint8Array(Yn.FTYP.byteLength+t.byteLength);return r.set(Yn.FTYP),r.set(t,Yn.FTYP.byteLength),r}}function Xn(e,t,r=1,i=!1){const n=e*t*r;return i?Math.round(n):n}function Qn(e,t=!1){return Xn(e,1e3,1/9e4,t)}Yn.types=void 0,Yn.HDLR_TYPES=void 0,Yn.STTS=void 0,Yn.STSC=void 0,Yn.STCO=void 0,Yn.STSZ=void 0,Yn.VMHD=void 0,Yn.SMHD=void 0,Yn.STSD=void 0,Yn.FTYP=void 0,Yn.DINF=void 0;let Jn,Zn=null,es=null;class ts{constructor(e,t,r,i=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,null===Zn){const e=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Zn=e?parseInt(e[1]):0}if(null===es){const e=navigator.userAgent.match(/Safari\/(\d+)/i);es=e?parseInt(e[1]):0}}destroy(){}resetTimeStamp(e){rt.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){rt.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){rt.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1}getVideoStartPts(e){let t=!1;const r=e.reduce((e,r)=>{const i=r.pts-e;return i<-4294967296?(t=!0,rs(e,r.pts)):i>0?e:r.pts},e[0].pts);return t&&rt.debug("PTS rollover detected"),r}remux(e,t,r,i,n,s,o,a){let l,c,u,d,h,f,p=n,g=n;const m=e.pid>-1,y=t.pid>-1,v=t.samples.length,b=e.samples.length>0,E=o&&v>0||v>1;if((!m||b)&&(!y||E)||this.ISGenerated||o){this.ISGenerated||(u=this.generateIS(e,t,n,s));const r=this.isVideoContiguous;let i,o=-1;if(E&&(o=function(e){for(let t=0;t0){rt.warn(`[mp4-remuxer]: Dropped ${o} out of ${v} video samples due to a missing keyframe`);const e=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(o),t.dropped+=o,g+=(t.samples[0].pts-e)/t.inputTimeScale,i=g}else-1===o&&(rt.warn(`[mp4-remuxer]: No keyframe found out of ${v} video samples`),f=!1);if(this.ISGenerated){if(b&&E){const r=this.getVideoStartPts(t.samples),i=(rs(e.samples[0].pts,r)-r)/t.inputTimeScale;p+=Math.max(0,i),g+=Math.max(0,-i)}if(b){if(e.samplerate||(rt.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(e,t,n,s)),c=this.remuxAudio(e,p,this.isAudioContiguous,s,y||E||a===$r?g:void 0),E){const i=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(rt.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(e,t,n,s)),l=this.remuxVideo(t,g,r,i)}}else E&&(l=this.remuxVideo(t,g,r,0));l&&(l.firstKeyFrame=o,l.independent=-1!==o,l.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(h=is(r,n,this._initPTS,this._initDTS)),i.samples.length&&(d=ns(i,n,this._initPTS))),{audio:c,video:l,initSegment:u,independent:f,text:d,id3:h}}generateIS(e,t,r,i){const n=e.samples,s=t.samples,o=this.typeSupported,a={},l=this._initPTS;let c,u,d,h=!l||i,f="audio/mp4";if(h&&(c=u=1/0),e.config&&n.length&&(e.timescale=e.samplerate,"mp3"===e.segmentCodec&&(o.mpeg?(f="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3")),a.audio={id:"audio",container:f,codec:e.codec,initSegment:"mp3"===e.segmentCodec&&o.mpeg?new Uint8Array(0):Yn.initSegment([e]),metadata:{channelCount:e.channelCount}},h&&(d=e.inputTimeScale,l&&d===l.timescale?h=!1:c=u=n[0].pts-Math.round(d*r))),t.sps&&t.pps&&s.length&&(t.timescale=t.inputTimeScale,a.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:Yn.initSegment([t]),metadata:{width:t.width,height:t.height}},h))if(d=t.inputTimeScale,l&&d===l.timescale)h=!1;else{const e=this.getVideoStartPts(s),t=Math.round(d*r);u=Math.min(u,rs(s[0].dts,e)-t),c=Math.min(c,e-t)}if(Object.keys(a).length)return this.ISGenerated=!0,h?(this._initPTS={baseTime:c,timescale:d},this._initDTS={baseTime:u,timescale:d}):c=d=void 0,{tracks:a,initPTS:c,timescale:d}}remuxVideo(e,t,r,i){const n=e.inputTimeScale,s=e.samples,o=[],a=s.length,l=this._initPTS;let c,u,d=this.nextAvcDts,h=8,f=this.videoSampleDuration,p=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,m=!1;r&&null!==d||(d=t*n-(s[0].pts-rs(s[0].dts,s[0].pts)));const y=l.baseTime*n/l.timescale;for(let e=0;e0?e-1:e].dts&&(m=!0)}m&&s.sort(function(e,t){const r=e.dts-t.dts,i=e.pts-t.pts;return r||i}),c=s[0].dts,u=s[s.length-1].dts;const v=u-c,b=v?Math.round(v/(a-1)):f||e.inputTimeScale/30;if(r){const e=c-d,t=e>b,r=e<-1;if((t||r)&&(t?rt.warn(`AVC: ${Qn(e,!0)} ms (${e}dts) hole between fragments detected, filling it`):rt.warn(`AVC: ${Qn(-e,!0)} ms (${e}dts) overlapping between fragments detected`),!r||d>=s[0].pts)){c=d;const t=s[0].pts-e;s[0].dts=c,s[0].pts=t,rt.log(`Video: First PTS/DTS adjusted: ${Qn(t,!0)}/${Qn(c,!0)}, delta: ${Qn(e,!0)} ms`)}}c=Math.max(0,c);let E=0,A=0;for(let e=0;e0?t.dts-s[e-1].dts:b;if(l=e>0?t.pts-s[e-1].pts:b,r.stretchShortVideoTrack&&null!==this.nextAudioPts){const e=Math.floor(r.maxBufferHole*n),s=(i?p+i*n:this.nextAudioPts)-t.pts;s>e?(f=s-o,f<0?f=o:k=!0,rt.log(`[mp4-remuxer]: It is approximately ${s/90} ms to the next segment; using duration ${f/90} ms for the last video frame.`)):f=o}else f=o}const u=Math.round(t.pts-t.dts);L=Math.min(L,f),R=Math.max(R,f),x=Math.min(x,l),P=Math.max(P,l),o.push(new ss(t.key,f,c,u))}if(o.length)if(Zn){if(Zn<70){const e=o[0].flags;e.dependsOn=2,e.isNonSync=0}}else if(es&&P-x0&&(i&&Math.abs(m-g)<9e3||Math.abs(rs(f[0].pts-y,m)-g)<20*l),f.forEach(function(e){e.pts=rs(e.pts-y,m)}),!r||g<0){if(f=f.filter(e=>e.pts>=0),!f.length)return;g=0===n?0:i&&!h?Math.max(0,m):f[0].pts}if("aac"===e.segmentCodec){const t=this.config.maxAudioFramesDrift;for(let r=0,i=g;r=t*l&&c<1e4&&h){let t=Math.round(a/l);i=o-t*l,i<0&&(t--,i+=l),0===r&&(this.nextAudioPts=g=i),rt.warn(`[mp4-remuxer]: Injecting ${t} audio frame @ ${(i/s).toFixed(3)}s due to ${Math.round(1e3*a/s)} ms gap.`);for(let s=0;s0))return;A+=p;try{v=new Uint8Array(A)}catch(e){return void this.observer.emit(Xe.ERROR,Xe.ERROR,{type:Qe.MUX_ERROR,details:Je.REMUX_ALLOC_ERROR,fatal:!1,error:e,bytes:A,reason:`fail allocating audio mdat ${A}`})}u||(new DataView(v.buffer).setUint32(0,A),v.set(Yn.types.mdat,4))}v.set(n,p);const l=n.byteLength;p+=l,d.push(new ss(!0,a,l,0)),E=s}const w=d.length;if(!w)return;const S=d[d.length-1];this.nextAudioPts=g=E+o*S.duration;const k=u?new Uint8Array(0):Yn.moof(e.sequenceNumber++,b/o,We({},e,{samples:d}));e.samples=[];const L=b/s,x=g/s,R={data1:k,data2:v,startPTS:L,endPTS:x,startDTS:L,endDTS:x,type:"audio",hasAudio:!0,hasVideo:!1,nb:w};return this.isAudioContiguous=!0,R}remuxEmptyAudio(e,t,r,i){const n=e.inputTimeScale,s=n/(e.samplerate?e.samplerate:n),o=this.nextAudioPts,a=this._initDTS,l=9e4*a.baseTime/a.timescale,c=(null!==o?o:i.startDTS*n)+l,u=i.endDTS*n+l,d=1024*s,h=Math.ceil((u-c)/d),f=qn.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(rt.warn("[mp4-remuxer]: remux empty Audio"),!f)return void rt.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");const p=[];for(let e=0;e4294967296;)e+=r;return e}function is(e,t,r,i){const n=e.samples.length;if(!n)return;const s=e.inputTimeScale;for(let o=0;oe.pts-t.pts);const s=e.samples;return e.samples=[],{samples:s}}class ss{constructor(e,t,r,i){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=i,this.flags=new os(e)}}class os{constructor(e){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=e?2:1,this.isNonSync=e?0:1}}function as(e,t){const r=null==e?void 0:e.codec;return r&&r.length>4?r:"hvc1"===r||"hev1"===r?"hvc1.1.6.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||t===dt?"avc1.42e01e":"mp4a.40.5"}try{Jn=self.performance.now.bind(self.performance)}catch(e){rt.debug("Unable to use Performance API on this environment"),Jn="undefined"!=typeof self&&self.Date.now}const ls=[{demux:class{constructor(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}resetTimeStamp(){}resetInitSegment(e,t,r,i){const n=this.videoTrack=gn("video",1),s=this.audioTrack=gn("audio",1),o=this.txtTrack=gn("text",1);if(this.id3Track=gn("id3",1),this.timeOffset=0,null==e||!e.byteLength)return;const a=ir(e);if(a.video){const{id:e,timescale:t,codec:r}=a.video;n.id=e,n.timescale=o.timescale=t,n.codec=r}if(a.audio){const{id:e,timescale:t,codec:r}=a.audio;s.id=e,s.timescale=t,s.codec=r}o.id=Yt.text,n.sampleDuration=0,n.duration=s.duration=i}resetContiguity(){this.remainderData=null}static probe(e){return tr(e=e.length>16384?e.subarray(0,16384):e,["moof"]).length>0}demux(e,t){this.timeOffset=t;let r=e;const i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=or(this.remainderData,e));const t=function(e){const t={valid:null,remainder:null},r=tr(e,["moof"]);if(!r)return t;if(r.length<2)return t.remainder=e,t;const i=r[r.length-1];return t.valid=Pt(e,0,i.byteOffset-8),t.remainder=Pt(e,i.byteOffset-8),t}(r);this.remainderData=t.remainder,i.samples=t.valid||new Uint8Array}else i.samples=r;const s=this.extractID3Track(i,t);return n.samples=ar(t,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const i=this.extractID3Track(t,this.timeOffset);return r.samples=ar(e,t),{videoTrack:t,audioTrack:gn(),id3Track:i,textTrack:gn()}}extractID3Track(e,t){const r=this.id3Track;if(e.samples.length){const i=tr(e.samples,["emsg"]);i&&i.forEach(e=>{const i=function(e){const t=e[0];let r="",i="",n=0,s=0,o=0,a=0,l=0,c=0;if(0===t){for(;"\0"!==Xt(e.subarray(c,c+1));)r+=Xt(e.subarray(c,c+1)),c+=1;for(r+=Xt(e.subarray(c,c+1)),c+=1;"\0"!==Xt(e.subarray(c,c+1));)i+=Xt(e.subarray(c,c+1)),c+=1;i+=Xt(e.subarray(c,c+1)),c+=1,n=Jt(e,12),s=Jt(e,16),a=Jt(e,20),l=Jt(e,24),c=28}else if(1===t){c+=4,n=Jt(e,c),c+=4;const t=Jt(e,c);c+=4;const s=Jt(e,c);for(c+=4,o=2**32*t+s,ze(o)||(o=Number.MAX_SAFE_INTEGER,rt.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),a=Jt(e,c),c+=4,l=Jt(e,c),c+=4;"\0"!==Xt(e.subarray(c,c+1));)r+=Xt(e.subarray(c,c+1)),c+=1;for(r+=Xt(e.subarray(c,c+1)),c+=1;"\0"!==Xt(e.subarray(c,c+1));)i+=Xt(e.subarray(c,c+1)),c+=1;i+=Xt(e.subarray(c,c+1)),c+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:o,presentationTimeDelta:s,eventDuration:a,id:l,payload:e.subarray(c,e.byteLength)}}(e);if(Ln.test(i.schemeIdUri)){const e=qe(i.presentationTime)?i.presentationTime/i.timeScale:t+i.presentationTimeDelta/i.timeScale;let n=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;n<=.001&&(n=Number.POSITIVE_INFINITY);const s=i.payload;r.samples.push({data:s,len:s.byteLength,dts:e,pts:e,type:Qr,duration:n})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}},remux:class{constructor(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,i){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(function(e,t){if(!e||!t)return e;const r=t.keyId;return r&&t.isCommonEncryption&&tr(e,["moov","trak"]).forEach(e=>{const t=tr(e,["mdia","minf","stbl","stsd"])[0].subarray(8);let i=tr(t,["enca"]);const n=i.length>0;n||(i=tr(t,["encv"])),i.forEach(e=>{tr(n?e.subarray(28):e.subarray(78),["sinf"]).forEach(e=>{const t=nr(e);if(t){const e=t.subarray(8,24);e.some(e=>0!==e)||(rt.log(`[eme] Patching keyId in 'enc${n?"a":"v"}>sinf>>tenc' box: ${Wt(e)} -> ${Wt(r)}`),t.set(r,8))}})})}),e}(e,i)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(null==e||!e.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const i=this.initData=ir(e);t||(t=as(i.audio,ut)),r||(r=as(i.video,dt));const n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:rt.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,r,i,n,s){var o,a;let{initPTS:l,lastEndTime:c}=this;const u={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};qe(c)||(c=this.lastEndTime=n||0);const d=t.samples;if(null==d||!d.length)return u;const h={initPTS:void 0,timescale:1};let f=this.initData;if(null!=(o=f)&&o.length||(this.generateInitSegment(d),f=this.initData),null==(a=f)||!a.length)return rt.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(h.tracks=this.initTracks,this.emitInitSegment=!1);const p=function(e,t){let r=0,i=0,n=0;const s=tr(e,["moof","traf"]);for(let e=0;ee+t.info.duration||0,0))}return t}return i||n}(d,f),g=function(e,t){return tr(t,["moof","traf"]).reduce((t,r)=>{const i=tr(r,["tfdt"])[0],n=i[0],s=tr(r,["tfhd"]).reduce((t,r)=>{const s=Jt(r,4),o=e[s];if(o){let e=Jt(i,4);if(1===n){if(e===qt)return rt.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),t;e*=qt+1,e+=Jt(i,8)}const r=e/(o.timescale||9e4);if(qe(r)&&(null===t||rn}(l,m,n,p)||h.timescale!==l.timescale&&s)&&(h.initPTS=m-n,l&&1===l.timescale&&rt.warn("Adjusting initPTS by "+(h.initPTS-l.baseTime)),this.initPTS=l={baseTime:h.initPTS,timescale:1});const y=e?m-l.baseTime/l.timescale:c,v=y+p;!function(e,t,r){tr(t,["moof","traf"]).forEach(t=>{tr(t,["tfhd"]).forEach(i=>{const n=Jt(i,4),s=e[n];if(!s)return;const o=s.timescale||9e4;tr(t,["tfdt"]).forEach(e=>{const t=e[0];let i=Jt(e,4);if(0===t)i-=r*o,i=Math.max(i,0),er(e,4,i);else{i*=Math.pow(2,32),i+=Jt(e,8),i-=r*o,i=Math.max(i,0);const t=Math.floor(i/(qt+1)),n=Math.floor(i%(qt+1));er(e,4,t),er(e,8,n)}})})})}(f,d,l.baseTime/l.timescale),p>0?this.lastEndTime=v:(rt.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const b=!!f.audio,E=!!f.video;let A="";b&&(A+="audio"),E&&(A+="video");const T={data1:d,startPTS:y,startDTS:y,endPTS:v,endDTS:v,type:A,hasAudio:b,hasVideo:E,nb:1,dropped:0};return u.audio="audio"===T.type?T:void 0,u.video="audio"!==T.type?T:void 0,u.initSegment=h,u.id3=is(r,n,l,l),i.samples.length&&(u.text=ns(i,n,l)),u}}},{demux:jn,remux:ts},{demux:class extends mn{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,i){super.resetInitSegment(e,t,r,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:i,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;let t=(_t(e,0)||[]).length;for(let r=e.length;t0&&null!=t&&null!=t.key&&null!==t.iv&&null!=t.method&&(r=t),r}(s,t);if(b&&"AES-128"===b.method){const e=this.getDecrypter();if(!e.isSync())return this.decryptionPromise=e.webCryptoDecrypt(s,b.key.buffer,b.iv.buffer).then(e=>{const t=this.push(e,null,r);return this.decryptionPromise=null,t}),this.decryptionPromise;{let t=e.softwareDecrypt(s,b.key.buffer,b.iv.buffer);if(r.part>-1&&(t=e.flush()),!t)return n.executeEnd=Jn(),us(r);s=new Uint8Array(t)}}const E=this.needsProbing(c,u);if(E){const e=this.configureTransmuxer(s);if(e)return rt.warn(`[transmuxer] ${e.message}`),this.observer.emit(Xe.ERROR,Xe.ERROR,{type:Qe.MEDIA_ERROR,details:Je.FRAG_PARSING_ERROR,fatal:!1,error:e,reason:e.message}),n.executeEnd=Jn(),us(r)}(c||u||f||E)&&this.resetInitSegment(v,p,g,y,t),(c||f||E)&&this.resetInitialTimestamp(m),l||this.resetContiguity();const A=this.transmux(s,b,h,d,r),T=this.currentTransmuxState;return T.contiguous=!0,T.discontinuity=!1,T.trackSwitch=!1,n.executeEnd=Jn(),A}flush(e){const t=e.transmuxing;t.executeStart=Jn();const{decrypter:r,currentTransmuxState:i,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));const s=[],{timeOffset:o}=i;if(r){const t=r.flush();t&&s.push(this.push(t,null,e))}const{demuxer:a,remuxer:l}=this;if(!a||!l)return t.executeEnd=Jn(),[us(e)];const c=a.flush(o);return ds(c)?c.then(t=>(this.flushRemux(s,t,e),s)):(this.flushRemux(s,c,e),s)}flushRemux(e,t,r){const{audioTrack:i,videoTrack:n,id3Track:s,textTrack:o}=t,{accurateTimeOffset:a,timeOffset:l}=this.currentTransmuxState;rt.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);const c=this.remuxer.remux(i,n,s,o,l,a,!0,this.id);e.push({remuxResult:c,chunkMeta:r}),r.transmuxing.executeEnd=Jn()}resetInitialTimestamp(e){const{demuxer:t,remuxer:r}=this;t&&r&&(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;e&&t&&(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,i,n){const{demuxer:s,remuxer:o}=this;s&&o&&(s.resetInitSegment(e,t,r,i),o.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,i,n){let s;return s=t&&"SAMPLE-AES"===t.method?this.transmuxSampleAes(e,t,r,i,n):this.transmuxUnencrypted(e,r,i,n),s}transmuxUnencrypted(e,t,r,i){const{audioTrack:n,videoTrack:s,id3Track:o,textTrack:a}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,s,o,a,t,r,!1,this.id),chunkMeta:i}}transmuxSampleAes(e,t,r,i,n){return this.demuxer.demuxSampleAes(e,t,r).then(e=>({remuxResult:this.remuxer.remux(e.audioTrack,e.videoTrack,e.id3Track,e.textTrack,r,i,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){const{config:t,observer:r,typeSupported:i,vendor:n}=this;let s;for(let t=0,r=ls.length;t({remuxResult:{},chunkMeta:e});function ds(e){return"then"in e&&e.then instanceof Function}class hs{constructor(e,t,r,i,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=i,this.defaultInitPts=n||null}}class fs{constructor(e,t,r,i,n,s){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=i,this.timeOffset=n,this.initSegmentChange=s}}var ps={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,r="~";function i(){}function n(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,i,s,o){if("function"!=typeof i)throw new TypeError("The listener must be a function");var a=new n(i,s||e,o),l=r?r+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],a]:e._events[l].push(a):(e._events[l]=a,e._eventsCount++),e}function o(e,t){0===--e._eventsCount?e._events=new i:delete e._events[t]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,i,n=[];if(0===this._eventsCount)return n;for(i in e=this._events)t.call(e,i)&&n.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},a.prototype.listeners=function(e){var t=r?r+e:e,i=this._events[t];if(!i)return[];if(i.fn)return[i.fn];for(var n=0,s=i.length,o=new Array(s);n!1};class ys{constructor(e,t,r,i){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=i;const s=(e,t)=>{(t=t||{}).frag=this.frag,t.id=this.id,e===Xe.ERROR&&(this.error=t.error),this.hls.trigger(e,t)};this.observer=new gs,this.observer.on(Xe.FRAG_DECRYPTED,s),this.observer.on(Xe.ERROR,s);const o={mp4:ms.isTypeSupported("video/mp4"),mpeg:ms.isTypeSupported("audio/mpeg"),mp3:ms.isTypeSupported('audio/mp4; codecs="mp3"')},a=navigator.vendor;if(!this.useWorker||"undefined"==typeof Worker||!n.workerPath&&"function"!=typeof __HLS_WORKER_BUNDLE__)this.transmuxer=new cs(this.observer,o,n,a,t);else try{n.workerPath?(rt.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=function(e){const t=new self.URL(e,self.location.href).href;return{worker:new self.Worker(t),scriptURL:t}}(n.workerPath)):(rt.log(`injecting Web Worker for "${t}"`),this.workerContext=function(){const e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),t=self.URL.createObjectURL(e);return{worker:new self.Worker(t),objectURL:t}}()),this.onwmsg=e=>this.onWorkerMessage(e);const{worker:e}=this.workerContext;e.addEventListener("message",this.onwmsg),e.onerror=e=>{const r=new Error(`${e.message} (${e.filename}:${e.lineno})`);n.enableWorker=!1,rt.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(Xe.ERROR,{type:Qe.OTHER_ERROR,details:Je.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:r})},e.postMessage({cmd:"init",typeSupported:o,vendor:a,id:t,config:JSON.stringify(n)})}catch(e){rt.warn(`Error setting up "${t}" Web Worker, fallback to inline`,e),this.resetWorker(),this.error=null,this.transmuxer=new cs(this.observer,o,n,a,t)}}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const e=this.transmuxer;e&&(e.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,i,n,s,o,a,l,c){var u,d;l.transmuxing.start=self.performance.now();const{transmuxer:h}=this,f=s?s.start:n.start,p=n.decryptdata,g=this.frag,m=!(g&&n.cc===g.cc),y=!(g&&l.level===g.level),v=g?l.sn-g.sn:-1,b=this.part?l.part-this.part.index:-1,E=0===v&&l.id>1&&l.id===(null==g?void 0:g.stats.chunkCount),A=!y&&(1===v||0===v&&(1===b||E&&b<=0)),T=self.performance.now();(y||v||0===n.stats.parsing.start)&&(n.stats.parsing.start=T),!s||!b&&A||(s.stats.parsing.start=T);const w=!(g&&(null==(u=n.initSegment)?void 0:u.url)===(null==(d=g.initSegment)?void 0:d.url)),S=new fs(m,A,a,y,f,w);if(!A||m||w){rt.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${l.sn} p: ${l.part} level: ${l.level} id: ${l.id}\n discontinuity: ${m}\n trackSwitch: ${y}\n contiguous: ${A}\n accurateTimeOffset: ${a}\n timeOffset: ${f}\n initSegmentChange: ${w}`);const e=new hs(r,i,t,o,c);this.configureTransmuxer(e)}if(this.frag=n,this.part=s,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:l,state:S},e instanceof ArrayBuffer?[e]:[]);else if(h){const t=h.push(e,p,l,S);ds(t)?(h.async=!0,t.then(e=>{this.handleTransmuxComplete(e)}).catch(e=>{this.transmuxerError(e,l,"transmuxer-interface push error")})):(h.async=!1,this.handleTransmuxComplete(t))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);ds(r)||t.async?(ds(r)||(r=Promise.resolve(r)),r.then(t=>{this.handleFlushResult(t,e)}).catch(t=>{this.transmuxerError(t,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(Xe.ERROR,{type:Qe.MEDIA_ERROR,details:Je.FRAG_PARSING_ERROR,chunkMeta:t,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(e=>{this.handleTransmuxComplete(e)}),this.onFlush(t)}onWorkerMessage(e){const t=e.data,r=this.hls;switch(t.event){case"init":{var i;const e=null==(i=this.workerContext)?void 0:i.objectURL;e&&self.URL.revokeObjectURL(e);break}case"transmuxComplete":this.handleTransmuxComplete(t.data);break;case"flush":this.onFlush(t.data);break;case"workerLog":rt[t.data.logType]&&rt[t.data.logType](t.data.message);break;default:t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data)}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}class vs{constructor(e,t,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=i}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:r,media:i,stalled:n}=this;if(null===i)return;const{currentTime:s,seeking:o}=i,a=this.seeking&&!o,l=!this.seeking&&o;if(this.seeking=o,s!==e){if(this.moved=!0,null!==n){if(this.stallReported){const e=self.performance.now()-n;rt.warn(`playback not stuck anymore @${s}, after ${Math.round(e)}ms`),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}return}if(l||a)return void(this.stalled=null);if(i.paused&&!o||i.ended||0===i.playbackRate||!Gi.getBuffered(i).length)return;const c=Gi.bufferInfo(i,s,0),u=c.len>0,d=c.nextStart||0;if(!u&&!d)return;if(o){const e=c.len>2,r=!d||t&&t.start<=s||d-s>2&&!this.fragmentTracker.getPartialFragment(s);if(e||r)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var h;const e=Math.max(d,c.start||0)-s,t=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,r=(null==t||null==(h=t.details)?void 0:h.live)?2*t.details.targetduration:2,i=this.fragmentTracker.getPartialFragment(s);if(e>0&&(e<=r||i))return void this._trySkipBufferHole(i)}const f=self.performance.now();if(null===n)return void(this.stalled=f);const p=f-n;if(!o&&p>=250&&(this._reportStall(c),!this.media))return;const g=Gi.bufferInfo(i,s,r.maxBufferHole);this._tryFixBufferStall(g,p)}_tryFixBufferStall(e,t){const{config:r,fragmentTracker:i,media:n}=this;if(null===n)return;const s=n.currentTime,o=i.getPartialFragment(s);(!o||!this._trySkipBufferHole(o)&&this.media)&&(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-s1e3*r.highBufferWatchdogPeriod&&(rt.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:r,stallReported:i}=this;if(!i&&r){this.stallReported=!0;const i=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);rt.warn(i.message),t.trigger(Xe.ERROR,{type:Qe.MEDIA_ERROR,details:Je.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:r,media:i}=this;if(null===i)return 0;const n=i.currentTime,s=Gi.bufferInfo(i,n,0),o=n0&&s.len<1&&i.readyState<3,c=o-n;if(c>0&&(a||l)){if(c>t.maxBufferHole){const{fragmentTracker:t}=this;let r=!1;if(0===n){const e=t.getAppendedFrag(0,jr);e&&o1?(e=0,this.bitrateTest=!0):e=r.nextAutoLevel),this.level=r.nextLoadLevel=e,this.loadedmetadata=!1}t>0&&-1===e&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=tn,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=en}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case hn:{var e;const{levels:t,level:r}=this,i=null==t||null==(e=t[r])?void 0:e.details;if(i&&(!i.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(i))break;this.state=tn;break}if(this.hls.nextLoadLevel!==this.level){this.state=tn;break}break}case sn:{var t;const e=self.performance.now(),r=this.retryDate;(!r||e>=r||null!=(t=this.media)&&t.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=tn)}}this.state===tn&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:r,media:i}=this,{config:n,nextLoadLevel:s}=e;if(null===t||!i&&(this.startFragRequested||!n.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;if(null==r||!r[s])return;const o=r[s],a=this.getMainFwdBufferInfo();if(null===a)return;const l=this.getLevelDetails();if(l&&this._streamEnded(a,l)){const e={};return this.altAudio&&(e.type="video"),this.hls.trigger(Xe.BUFFER_EOS,e),void(this.state=cn)}e.loadLevel!==s&&-1===e.manualLevel&&this.log(`Adapting to level ${s} from level ${this.level}`),this.level=e.nextLoadLevel=s;const c=o.details;if(!c||this.state===hn||c.live&&this.levelLastLoaded!==s)return this.level=s,void(this.state=hn);const u=a.len,d=this.getMaxBufferLength(o.maxBitrate);if(u>=d)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const h=this.backtrackFragment?this.backtrackFragment.start:a.end;let f=this.getNextFragment(h,c);if(this.couldBacktrack&&!this.fragPrevious&&f&&"initSegment"!==f.sn&&this.fragmentTracker.getState(f)!==_i){var p;const e=(null!=(p=this.backtrackFragment)?p:f).sn-c.startSN,t=c.fragments[e-1];t&&f.cc===t.cc&&(f=t,this.fragmentTracker.removeFragment(t))}else this.backtrackFragment&&a.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){const e=this.audioOnly&&!this.altAudio?ut:dt,t=(e===dt?this.videoBuffer:this.mediaBuffer)||this.media;t&&this.afterBufferFlushed(t,e,jr)}f=this.getNextFragmentLoopLoading(f,c,a,jr,d)}f&&(!f.initSegment||f.initSegment.data||this.bitrateTest||(f=f.initSegment),this.loadFragment(f,o,h))}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);this.fragCurrent=e,i===Pi||i===Ci?"initSegment"===e.sn?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,jr)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(null!=t&&t.readyState){let r;const i=this.getAppendedFrag(t.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);const n=this.getLevelDetails();if(null!=n&&n.live){const e=this.getMainFwdBufferInfo();if(!e||e.len<2*n.targetduration)return}if(!t.paused&&e){const t=e[this.hls.nextLoadLevel],i=this.fragLastKbps;r=i&&this.fragCurrent?this.fragCurrent.duration*t.maxBitrate/(1e3*i)+1:0}else r=0;const s=this.getBufferedFrag(t.currentTime+r);if(s){const e=this.followingBufferedFrag(s);if(e){this.abortCurrentFrag();const t=e.maxStartPTS?e.maxStartPTS:e.start,r=e.duration,i=Math.max(s.end,t+Math.min(Math.max(r-this.config.maxFragLookUpTolerance,.5*r),.75*r));this.flushMainBuffer(i,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case rn:case nn:case sn:case an:case ln:this.state=tn}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new vs(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;qe(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const r=this.getMainFwdBufferInfo();null!==r&&0!==r.len?this.tick():this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`)}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(Xe.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1}onManifestParsed(e,t){let r,i=!1,n=!1;t.levels.forEach(e=>{r=e.audioCodec,r&&(-1!==r.indexOf("mp4a.40.2")&&(i=!0),-1!==r.indexOf("mp4a.40.5")&&(n=!0))}),this.audioCodecSwitch=i&&n&&!function(){var e;const t=pn();return"function"==typeof(null==t||null==(e=t.prototype)?void 0:e.changeType)}(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:r}=this;if(!r||this.state!==tn)return;const i=r[t.level];(!i.details||i.details.live&&this.levelLastLoaded!==t.level||this.waitForCdnTuneIn(i.details))&&(this.state=hn)}onLevelLoaded(e,t){var r;const{levels:i}=this,n=t.level,s=t.details,o=s.totalduration;if(!i)return void this.warn(`Levels were reset while loading level ${n}`);this.log(`Level ${n} loaded [${s.startSN},${s.endSN}]${s.lastPartSn?`[part-${s.lastPartSn}-${s.lastPartIndex}]`:""}, cc [${s.startCC}, ${s.endCC}] duration:${o}`);const a=i[n],l=this.fragCurrent;!l||this.state!==nn&&this.state!==sn||l.level===t.level&&l.urlId===a.urlId||!l.loader||this.abortCurrentFrag();let c=0;if(s.live||null!=(r=a.details)&&r.live){if(this.checkLiveUpdate(s),s.deltaUpdateFailed)return;c=this.alignPlaylists(s,a.details)}if(a.details=s,this.levelLastLoaded=n,this.hls.trigger(Xe.LEVEL_UPDATED,{details:s,level:n}),this.state===hn){if(this.waitForCdnTuneIn(s))return;this.state=tn}this.startFragRequested?s.live&&this.synchronizeToLiveEdge(s):this.setStartPosition(s,c),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:r,part:i,payload:n}=e,{levels:s}=this;if(!s)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);const o=s[r.level],a=o.details;if(!a)return this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),void this.fragmentTracker.removeFragment(r);const l=o.videoCodec,c=a.PTSKnown||!a.live,u=null==(t=r.initSegment)?void 0:t.data,d=this._getAudioCodec(o),h=this.transmuxer=this.transmuxer||new ys(this.hls,jr,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,p=-1!==f,g=new Ki(r.level,r.sn,r.stats.chunkCount,n.byteLength,f,p),m=this.initPTS[r.cc];h.push(n,u,d,l,r,i,a.totalduration,c,g,m)}onAudioTrackSwitching(e,t){const r=this.altAudio;if(!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const e=this.fragCurrent;e&&(this.log("Switching to main audio track, cancel main fragment load"),e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const e=this.hls;r&&(e.trigger(Xe.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),e.trigger(Xe.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const r=t.id,i=!!this.hls.audioTracks[r].url;if(i){const e=this.videoBuffer;e&&this.mediaBuffer!==e&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=e)}this.altAudio=i,this.tick()}onBufferCreated(e,t){const r=t.tracks;let i,n,s=!1;for(const e in r){const t=r[e];if("main"===t.id){if(n=e,i=t,"video"===e){const t=r[e];t&&(this.videoBuffer=t.buffer)}}else s=!0}s&&i?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:r,part:i}=t;if(r&&r.type!==jr)return;if(this.fragContextChanged(r))return this.warn(`Fragment ${r.sn}${i?" p: "+i.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===ln&&(this.state=tn));const n=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}onError(e,t){var r;if(t.fatal)this.state=un;else switch(t.details){case Je.FRAG_GAP:case Je.FRAG_PARSING_ERROR:case Je.FRAG_DECRYPT_ERROR:case Je.FRAG_LOAD_ERROR:case Je.FRAG_LOAD_TIMEOUT:case Je.KEY_LOAD_ERROR:case Je.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(jr,t);break;case Je.LEVEL_LOAD_ERROR:case Je.LEVEL_LOAD_TIMEOUT:case Je.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==hn||(null==(r=t.context)?void 0:r.type)!==Fr||(this.state=tn);break;case Je.BUFFER_FULL_ERROR:if(!t.parent||"main"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case Je.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}checkBuffer(){const{media:e,gapController:t}=this;if(e&&t&&e.readyState){if(this.loadedmetadata||!Gi.getBuffered(e).length){const e=this.state!==tn?this.fragCurrent:null;t.poll(this.lastCurrentTime,e)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=tn,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==ut||this.audioOnly&&!this.altAudio){const e=(t===dt?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(e,t,jr)}}onLevelsUpdated(e,t){this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let r=this.startPosition;if(r>=0&&t0&&(n{const{hls:i}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=tn,this.startFragRequested=!1,this.bitrateTest=!1;const n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),i.trigger(Xe.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const r="main",{hls:i}=this,{remuxResult:n,chunkMeta:s}=e,o=this.getCurrentContext(s);if(!o)return void this.resetWhenMissingContext(s);const{frag:a,part:l,level:c}=o,{video:u,text:d,id3:h,initSegment:f}=n,{details:p}=c,g=this.altAudio?void 0:n.audio;if(this.fragContextChanged(a))this.fragmentTracker.removeFragment(a);else{if(this.state=an,f){if(null!=f&&f.tracks){const e=a.initSegment||a;this._bufferInitSegment(c,f.tracks,e,s),i.trigger(Xe.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:r,tracks:f.tracks})}const e=f.initPTS,t=f.timescale;qe(e)&&(this.initPTS[a.cc]={baseTime:e,timescale:t},i.trigger(Xe.INIT_PTS_FOUND,{frag:a,id:r,initPTS:e,timescale:t}))}if(u&&p&&"initSegment"!==a.sn){const e=p.fragments[a.sn-1-p.startSN],t=a.sn===p.startSN,r=!e||a.cc>e.cc;if(!1!==n.independent){const{startPTS:e,endPTS:i,startDTS:n,endDTS:o}=u;if(l)l.elementaryStreams[u.type]={startPTS:e,endPTS:i,startDTS:n,endDTS:o};else if(u.firstKeyFrame&&u.independent&&1===s.id&&!r&&(this.couldBacktrack=!0),u.dropped&&u.independent){const n=this.getMainFwdBufferInfo(),s=(n?n.end:this.getLoadPosition())+this.config.maxBufferHole,l=u.firstKeyFramePTS?u.firstKeyFramePTS:e;if(!t&&s{const n=t[e].initSegment;null!=n&&n.byteLength&&this.hls.trigger(Xe.BUFFER_APPENDING,{type:e,data:n,frag:r,part:null,chunkMeta:i,parent:r.type})}),this.tick()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,jr)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=tn}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&!1===e.seeking){const r=e.currentTime;if(Gi.isBuffered(e,r)?t=this.getAppendedFrag(r):Gi.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;const e=this.fragPlaying,r=t.level;e&&t.sn===e.sn&&e.level===r&&t.urlId===e.urlId||(this.fragPlaying=t,this.hls.trigger(Xe.FRAG_CHANGED,{frag:t}),e&&e.level===r||this.hls.trigger(Xe.LEVEL_SWITCHED,{level:r}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,r=this.currentFrag;if(r&&qe(t)&&qe(r.programDateTime)){const e=r.programDateTime+1e3*(t-r.start);return new Date(e)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class Es{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){const r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class As{constructor(e,t,r,i=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new Es(e),this.fast_=new Es(t),this.defaultTTFB_=i,this.ttfb_=new Es(e)}update(e,t){const{slow_:r,fast_:i,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new Es(e,r.getEstimate(),r.getTotalWeight())),i.halfLife!==t&&(this.fast_=new Es(t,i.getEstimate(),i.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Es(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){const r=(e=Math.max(e,this.minDelayMs_))/1e3,i=8*t/r;this.fast_.sample(r,i),this.slow_.sample(r,i)}sampleTTFB(e){const t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}destroy(){}}class Ts{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let r;return e.length?(r=1===e.length?e[0]:function(e,t){const r=new Uint8Array(t);let i=0;for(let t=0;te[r]!==t[r])}class ks{constructor(e){this.buffered=void 0;const t=(t,r,i)=>{if((r>>>=0)>i-1)throw new DOMException(`Failed to execute '${t}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${i})`);return e[r][t]};this.buffered={get length(){return e.length},end:r=>t("end",r,e.length),start:r=>t("start",r,e.length)}}}function Ls(e){const t=[];for(let r=0;r{t=e}),i={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(i,e),r}executeNext(e){const{buffers:t,queues:r}=this,i=t[e],n=r[e];if(n.length){const t=n[0];try{t.execute()}catch(r){rt.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),t.onError(r),null!=i&&i.updating||(n.shift(),this.executeNext(e))}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const Rs=br(),Ps=/([ha]vc.)(?:\.[^.,]+)+/,Is={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},Cs=function(e){let t=e;return Is.hasOwnProperty(e)&&(t=Is[e]),String.fromCharCode(t)},_s=15,Os=100,Ds={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Ms={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Ns={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Fs={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Bs=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Us{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const r="function"==typeof t?t():t;rt.log(`${this.time} [${e}] ${r}`)}}}const js=function(e){const t=[];for(let r=0;rOs&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Os)}moveCursor(e){const t=this.pos+e;if(e>1)for(let e=this.pos+1;e=144&&this.backSpace();const t=Cs(e);this.pos>=Os?this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1))}clearFromPos(e){let t;for(t=e;t"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let r="",i=-1;for(let r=0;r<_s;r++){const n=this.rows[r].getTextString();n&&(i=r+1,e?t.push("Row "+i+": '"+n+"'"):t.push(n.trim()))}return t.length>0&&(r=e?"["+t.join(" | ")+"]":t.join("\n")),r}getTextAndFormat(){return this.rows}}class Ks{constructor(e,t,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new Gs(r),this.nonDisplayedMemory=new Gs(r),this.lastOutputScreen=new Gs(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let t=0;tt+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2==1,t.italics=e>=46,t.italics)t.foreground="white";else{const r=Math.floor(e/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=i[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;null!==t&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t):this.cueStartTime=t,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class Ws{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;const i=new Us;this.channels=[null,new Ks(e,t,i),new Ks(e+1,r,i)],this.cmdHistory={a:null,b:null},this.logger=i}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){let r,i,n,s=!1;this.logger.time=e;for(let e=0;e ("+js([i,n])+")"),r=this.parseCmd(i,n),r||(r=this.parseMidrow(i,n)),r||(r=this.parsePAC(i,n)),r||(r=this.parseBackgroundAttributes(i,n)),!r&&(s=this.parseChars(i,n),s)){const e=this.currentChannel;e&&e>0?this.channels[e].insertChars(s):this.logger.log(2,"No channel found yet. TEXT-MODE?")}r||s||this.logger.log(2,"Couldn't parse cleaned data "+js([i,n])+" orig: "+js([t[e],t[e+1]]))}}parseCmd(e,t){const{cmdHistory:r}=this;if(!((20===e||28===e||21===e||29===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=33&&t<=35))return!1;if(zs(e,t,r))return qs(null,null,r),this.logger.log(3,"Repeated command ("+js([e,t])+") is dropped"),!0;const i=20===e||21===e||23===e?1:2,n=this.channels[i];return 20===e||21===e||28===e||29===e?32===t?n.ccRCL():33===t?n.ccBS():34===t?n.ccAOF():35===t?n.ccAON():36===t?n.ccDER():37===t?n.ccRU(2):38===t?n.ccRU(3):39===t?n.ccRU(4):40===t?n.ccFON():41===t?n.ccRDC():42===t?n.ccTR():43===t?n.ccRTD():44===t?n.ccEDM():45===t?n.ccCR():46===t?n.ccENM():47===t&&n.ccEOC():n.ccTO(t-32),qs(e,t,r),this.currentChannel=i,!0}parseMidrow(e,t){let r=0;if((17===e||25===e)&&t>=32&&t<=47){if(r=17===e?1:2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const i=this.channels[r];return!!i&&(i.ccMIDROW(t),this.logger.log(3,"MIDROW ("+js([e,t])+")"),!0)}return!1}parsePAC(e,t){let r;const i=this.cmdHistory;if(!((e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127||(16===e||24===e)&&t>=64&&t<=95))return!1;if(zs(e,t,i))return qs(null,null,i),!0;const n=e<=23?1:2;r=t>=64&&t<=95?1===n?Ds[e]:Ns[e]:1===n?Ms[e]:Fs[e];const s=this.channels[n];return!!s&&(s.setPAC(this.interpretPAC(r,t)),qs(e,t,i),this.currentChannel=n,!0)}interpretPAC(e,t){let r;const i={color:null,italics:!1,indent:null,underline:!1,row:e};return r=t>95?t-96:t-64,i.underline=!(1&~r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i}parseChars(e,t){let r,i=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let e;e=17===n?t+80:18===n?t+112:t+144,this.logger.log(2,"Special char '"+Cs(e)+"' in channel "+r),i=[e]}else e>=32&&e<=127&&(i=0===t?[e]:[e,t]);if(i){const r=js(i);this.logger.log(3,"Char codes = "+r.join(",")),qs(e,t,this.cmdHistory)}return i}parseBackgroundAttributes(e,t){if(!((16===e||24===e)&&t>=32&&t<=47||(23===e||31===e)&&t>=45&&t<=47))return!1;let r;const i={};16===e||24===e?(r=Math.floor((t-32)/2),i.background=Bs[r],t%2==1&&(i.background=i.background+"_semi")):45===t?i.background="transparent":(i.foreground="black",47===t&&(i.underline=!0));const n=e<=23?1:2;return this.channels[n].setBkgData(i),qs(e,t,this.cmdHistory),!0}reset(){for(let e=0;ee)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var Xs=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;const e=["","lr","rl"],t=["start","middle","end","left","right"];function r(e,t){if("string"!=typeof t)return!1;if(!Array.isArray(e))return!1;const r=t.toLowerCase();return!!~e.indexOf(r)&&r}function i(e){return r(t,e)}function n(e,...t){let r=1;for(;r100)throw new Error("Position must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"positionAlign",n({},l,{get:function(){return E},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(a,"size",n({},l,{get:function(){return A},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");A=e,this.hasBeenReset=!0}})),Object.defineProperty(a,"align",n({},l,{get:function(){return T},set:function(e){const t=i(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");T=t,this.hasBeenReset=!0}})),a.displayState=void 0}return s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}();class Qs{decode(e,t){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function Js(e){function t(e,t,r,i){return 3600*(0|e)+60*(0|t)+(0|r)+parseFloat(i||0)}const r=e.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?t(r[2],r[3],0,r[4]):t(r[1],r[2],r[3],r[4]):null}class Zs{constructor(){this.values=Object.create(null)}set(e,t){this.get(e)||""===t||(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let i=0;i=0&&r<=100)return this.set(e,r),!0}return!1}}function eo(e,t,r,i){const n=i?e.split(i):[e];for(const e in n){if("string"!=typeof n[e])continue;const i=n[e].split(r);2===i.length&&t(i[0],i[1])}}const to=new Xs(0,0,""),ro="middle"===to.align?"middle":"center";function io(e,t,r){const i=e;function n(){const t=Js(e);if(null===t)throw new Error("Malformed timestamp: "+i);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function s(){e=e.replace(/^\s+/,"")}if(s(),t.startTime=n(),s(),"--\x3e"!==e.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);e=e.slice(3),s(),t.endTime=n(),s(),function(e,t){const i=new Zs;eo(e,function(e,t){let n;switch(e){case"region":for(let n=r.length-1;n>=0;n--)if(r[n].id===t){i.set(e,r[n].region);break}break;case"vertical":i.alt(e,t,["rl","lr"]);break;case"line":n=t.split(","),i.integer(e,n[0]),i.percent(e,n[0])&&i.set("snapToLines",!1),i.alt(e,n[0],["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",ro,"end"]);break;case"position":n=t.split(","),i.percent(e,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",ro,"end","line-left","line-right","auto"]);break;case"size":i.percent(e,t);break;case"align":i.alt(e,t,["start",ro,"end","left","right"])}},/:/,/\s/),t.region=i.get("region",null),t.vertical=i.get("vertical","");let n=i.get("line","auto");"auto"===n&&-1===to.line&&(n=-1),t.line=n,t.lineAlign=i.get("lineAlign","start"),t.snapToLines=i.get("snapToLines",!0),t.size=i.get("size",100),t.align=i.get("align",ro);let s=i.get("position","auto");"auto"===s&&50===to.position&&(s="start"===t.align||"left"===t.align?0:"end"===t.align||"right"===t.align?100:50),t.position=s}(e,t)}function no(e){return e.replace(//gi,"\n")}class so{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Qs,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;function r(){let e=t.buffer,r=0;for(e=no(e);r>>0).toString()};function co(e,t,r){return lo(e.toString())+lo(t.toString())+lo(r)}const uo="stpp.ttml.im1t",ho=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,fo=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,po={left:"start",center:"center",right:"end",start:"start",end:"end"};function go(e,t,r,i){const n=tr(new Uint8Array(e),["mdat"]);if(0===n.length)return void i(new Error("Could not parse IMSC1 mdat"));const s=n.map(e=>Ht(e)),o=function(e,t,r=1,i=!1){return Xn(e,t,1/r,i)}(t.baseTime,1,t.timescale);try{s.forEach(e=>r(function(e,t){const r=(new DOMParser).parseFromString(e,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(i).reduce((e,t)=>(e[t]=r.getAttribute(`ttp:${t}`)||i[t],e),{}),s="preserve"!==r.getAttribute("xml:space"),o=yo(mo(r,"styling","style")),a=yo(mo(r,"layout","region")),l=mo(r,"body","[begin]");return[].map.call(l,e=>{const r=vo(e,s);if(!r||!e.hasAttribute("begin"))return null;const i=Ao(e.getAttribute("begin"),n),l=Ao(e.getAttribute("dur"),n);let c=Ao(e.getAttribute("end"),n);if(null===i)throw Eo(e);if(null===c){if(null===l)throw Eo(e);c=i+l}const u=new Xs(i-t,c-t,r);u.id=co(u.startTime,u.endTime,u.text);const d=function(e,t,r){const i="http://www.w3.org/ns/ttml#styling";let n=null;const s=null!=e&&e.hasAttribute("style")?e.getAttribute("style"):null;return s&&r.hasOwnProperty(s)&&(n=r[s]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((r,s)=>{const o=bo(t,i,s)||bo(e,i,s)||bo(n,i,s);return o&&(r[s]=o),r},{})}(a[e.getAttribute("region")],o[e.getAttribute("style")],o),{textAlign:h}=d;if(h){const e=po[h];e&&(u.lineAlign=e),u.align=h}return We(u,d),u}).filter(e=>null!==e)}(e,o)))}catch(e){i(e)}}function mo(e,t,r){const i=e.getElementsByTagName(t)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function yo(e){return e.reduce((e,t)=>{const r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function vo(e,t){return[].slice.call(e.childNodes).reduce((e,r,i)=>{var n;return"br"===r.nodeName&&i?e+"\n":null!=(n=r.childNodes)&&n.length?vo(r,t):t?e+r.textContent.trim().replace(/\s+/g," "):e+r.textContent},"")}function bo(e,t,r){return e&&e.hasAttributeNS(t,r)?e.getAttributeNS(t,r):null}function Eo(e){return new Error(`Could not parse ttml timestamp ${e}`)}function Ao(e,t){if(!e)return null;let r=Js(e);return null===r&&(ho.test(e)?r=function(e,t){const r=ho.exec(e),i=(0|r[4])+(0|r[5])/t.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/t.frameRate}(e,t):fo.test(e)&&(r=function(e,t){const r=fo.exec(e),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/t.frameRate;case"t":return i/t.tickRate}return i}(e,t))),r}function To(e,t){return!!e&&e.label===t.name&&!(e.textTrack1||e.textTrack2)}function wo(e,t,r,i){return Math.min(t,i)-Math.max(e,r)}class So{constructor(e){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(Xe.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(Xe.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Xe.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Xe.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Xe.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(Xe.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(Xe.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Xe.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Xe.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Xe.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null}onManifestParsed(e,t){const r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){const e=this.hls.levels;if(e.length){const t=this.hls;t.autoLevelCapping=this.getMaxLevel(e.length-1),t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const r=t.filter((t,r)=>this.isLevelAllowed(t)&&r<=e);return this.clientRect=null,So.getMaxLevelByMediaSize(r,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const e=this.media,t={width:0,height:0};if(e){const r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,t.width||t.height||(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch(e){}return e}isLevelAllowed(e){return!this.restrictedLevels.some(t=>e.bitrate===t.bitrate&&e.width===t.width&&e.height===t.height)}static getMaxLevelByMediaSize(e,t,r){if(null==e||!e.length)return-1;const i=(e,t)=>!t||e.width!==t.width||e.height!==t.height;let n=e.length-1;for(let s=0;s=t||o.height>=r)&&i(o,e[s+1])){n=s;break}}return n}}const ko="[eme]";class Lo{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=Lo.CDMCleanupPromise?[Lo.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=rt.debug.bind(rt,ko),this.log=rt.log.bind(rt,ko),this.warn=rt.warn.bind(rt,ko),this.error=rt.error.bind(rt,ko),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(Xe.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(Xe.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(Xe.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(Xe.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(Xe.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(Xe.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(Xe.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(Xe.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:r}=this.config,i=t[e];if(i)return i.licenseUrl;if(e===bt.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,r=(e,t,r)=>!!e&&r.indexOf(e)===t,i=t.map(e=>e.audioCodec).filter(r),n=t.map(e=>e.videoCodec).filter(r);return i.length+n.length===0&&n.push("avc1.42e01e"),new Promise((t,r)=>{const s=e=>{const o=e.shift();this.getMediaKeysPromise(o,i,n).then(e=>t({keySystem:o,mediaKeys:e})).catch(t=>{e.length?s(e):r(t instanceof xo?t:new xo({type:Qe.KEY_SYSTEM_ERROR,details:Je.KEY_SYSTEM_NO_ACCESS,error:t,fatal:!0},t.message))})};s(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:r}=this.config;if("function"!=typeof r){let e=`Configured requestMediaKeySystemAccess is not a function ${r}`;return null===Rt&&"http:"===self.location.protocol&&(e=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(e))}return r(e,t)}getMediaKeysPromise(e,t,r){const i=function(e,t,r,i){let n;switch(e){case bt.FAIRPLAY:n=["cenc","sinf"];break;case bt.WIDEVINE:case bt.PLAYREADY:n=["cenc"];break;case bt.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${e}`)}return function(e,t,r,i){return[{initDataTypes:e,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:t.map(e=>({contentType:`audio/mp4; codecs="${e}"`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:r.map(e=>({contentType:`video/mp4; codecs="${e}"`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}(n,t,r,i)}(e,t,r,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e];let s=null==n?void 0:n.keySystemAccess;if(!s){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(i)}`),s=this.requestMediaKeySystemAccess(e,i);const t=this.keySystemAccessPromises[e]={keySystemAccess:s};return s.catch(t=>{this.log(`Failed to obtain access to key-system "${e}": ${t}`)}),s.then(r=>{this.log(`Access for key-system "${r.keySystem}" obtained`);const i=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),t.mediaKeys=r.createMediaKeys().then(t=>(this.log(`Media-keys created for "${e}"`),i.then(r=>r?this.setMediaKeysServerCertificate(t,e,r):t))),t.mediaKeys.catch(t=>{this.error(`Failed to create media-keys for "${e}"}: ${t}`)}),t.mediaKeys})}return s.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${Wt(e.keyId||[])}`);const i=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const r=this.createMediaKeySessionContext(e),i=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(null===e.keyId)throw new Error("keyId is null");return Wt(e.keyId)}updateKeySession(e,t){var r;const i=e.mediaKeysSession;return this.log(`Updating key-session "${i.sessionId}" for keyID ${Wt((null==(r=e.decryptdata)?void 0:r.keyId)||[])}\n } (data length: ${t?t.byteLength:t})`),i.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{const i=xt(this.config),n=e.map(St).filter(e=>!!e&&-1!==i.indexOf(e));return this.getKeySystemSelectionPromise(n).then(({keySystem:e})=>{const i=Lt(e);i?t(i):r(new Error(`Unable to find format for key-system "${e}"`))}).catch(r)})}loadKey(e){const t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),i=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${i}`);let n=this.keyIdToKeySessionPromise[r];return n||(n=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:r,mediaKeys:n})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${i}`),this.attemptSetMediaKeys(r,n).then(()=>{this.throwIfDestroyed();const e=this.createMediaKeySessionContext({keySystem:r,mediaKeys:n,decryptdata:t});return this.generateRequestWithPreferredKeySession(e,"cenc",t.pssh,"playlist-key")}))),n.catch(e=>this.handleError(e))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof xo?this.hls.trigger(Xe.ERROR,e.data):this.hls.trigger(Xe.ERROR,{type:Qe.KEY_SYSTEM_ERROR,details:Je.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){const t=St(e.keyFormat),r=t?[t]:xt(this.config);return this.attemptKeySystemAccess(r)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=xt(this.config)),0===e.length)throw new xo({type:Qe.KEY_SYSTEM_ERROR,details:Je.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:r}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),null===r)return;let i,n;if("sinf"===t&&this.config.drmSystems[bt.FAIRPLAY]){const e=Xt(new Uint8Array(r));try{const t=yt(JSON.parse(e).sinf),r=nr(new Uint8Array(t));if(!r)return;i=r.subarray(8,24),n=bt.FAIRPLAY}catch(e){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{const e=function(e){if(!(e instanceof ArrayBuffer)||e.byteLength<32)return null;const t={version:0,systemId:"",kids:null,data:null},r=new DataView(e),i=r.getUint32(0);if(e.byteLength!==i&&i>44)return null;if(1886614376!==r.getUint32(4))return null;if(t.version=r.getUint32(8)>>>24,t.version>1)return null;t.systemId=Wt(new Uint8Array(e,12,16));const n=r.getUint32(28);if(0===t.version){if(i-32this.generateRequestWithPreferredKeySession(n,t,r,"encrypted-event-key-match"));break}}l||(l=o[s]=this.getKeySystemSelectionPromise([n]).then(({keySystem:e,mediaKeys:n})=>{var o;this.throwIfDestroyed();const a=new hr("ISO-23001-7",s,null!=(o=Lt(e))?o:"");return a.pssh=new Uint8Array(r),a.keyId=i,this.attemptSetMediaKeys(e,n).then(()=>{this.throwIfDestroyed();const i=this.createMediaKeySessionContext({decryptdata:a,keySystem:e,mediaKeys:n});return this.generateRequestWithPreferredKeySession(i,t,r,"encrypted-event-no-match")})})),l.catch(e=>this.handleError(e))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const i=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(i),i.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(i),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(e=>-1===r.indexOf(e))})}generateRequestWithPreferredKeySession(e,t,r,i){var n,s;const o=null==(n=this.config.drmSystems)||null==(s=n[e.keySystem])?void 0:s.generateRequest;if(o)try{const i=o.call(this.hls,t,r,e);if(!i)throw new Error("Invalid response from configured generateRequest filter");t=i.initDataType,r=e.decryptdata.pssh=i.initData?new Uint8Array(i.initData):null}catch(e){var a;if(this.warn(e.message),null!=(a=this.hls)&&a.config.debug)throw e}if(null===r)return this.log(`Skipping key-session request for "${i}" (no initData)`),Promise.resolve(e);const l=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${i}": ${l} (init data type: ${t} length: ${r?r.byteLength:null})`);const c=new gs;e.mediaKeysSession.onmessage=t=>{const r=e.mediaKeysSession;if(!r)return void c.emit("error",new Error("invalid state"));const{messageType:i,message:n}=t;this.log(`"${i}" message event for session "${r.sessionId}" message size: ${n.byteLength}`),"license-request"===i||"license-renewal"===i?this.renewLicense(e,n).catch(e=>{this.handleError(e),c.emit("error",e)}):"license-release"===i?e.keySystem===bt.FAIRPLAY&&(this.updateKeySession(e,vt("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${i}"`)},e.mediaKeysSession.onkeystatuseschange=t=>{if(!e.mediaKeysSession)return void c.emit("error",new Error("invalid state"));this.onKeyStatusChange(e);const r=e.keyStatus;c.emit("keyStatus",r),"expired"===r&&(this.warn(`${e.keySystem} expired for key ${l}`),this.renewKeySession(e))};const u=new Promise((e,t)=>{c.on("error",t),c.on("keyStatus",r=>{r.startsWith("usable")?e():"output-restricted"===r?t(new xo({type:Qe.KEY_SYSTEM_ERROR,details:Je.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):"internal-error"===r?t(new xo({type:Qe.KEY_SYSTEM_ERROR,details:Je.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${r}"`)):"expired"===r?t(new Error("key expired while generating request")):this.warn(`unhandled key status change "${r}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var t;this.log(`Request generated for key-session "${null==(t=e.mediaKeysSession)?void 0:t.sessionId}" keyId: ${l}`)}).catch(e=>{throw new xo({type:Qe.KEY_SYSTEM_ERROR,details:Je.KEY_SYSTEM_NO_SESSION,error:e,fatal:!1},`Error generating key-session request: ${e}`)}).then(()=>u).catch(t=>{throw c.removeAllListeners(),this.removeSession(e),t}).then(()=>(c.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Wt("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${Wt(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,r=new(0,t.loader)(t),i=this.getServerCertificateUrl(e);return i?(this.log(`Fetching serverCertificate for "${e}"`),new Promise((n,s)=>{const o={responseType:"arraybuffer",url:i},a=t.certLoadPolicy.default,l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(e,t,r,i)=>{n(e.data)},onError:(t,r,n,a)=>{s(new xo({type:Qe.KEY_SYSTEM_ERROR,details:Je.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:Ge({url:o.url,data:void 0},t)},`"${e}" certificate request failed (${i}). Status: ${t.code} (${t.text})`))},onTimeout:(t,r,n)=>{s(new xo({type:Qe.KEY_SYSTEM_ERROR,details:Je.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:n,response:{url:o.url,data:void 0}},`"${e}" certificate request timed out (${i})`))},onAbort:(e,t,r)=>{s(new Error("aborted"))}};r.load(o,l,c)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((i,n)=>{e.setServerCertificate(r).then(n=>{this.log(`setServerCertificate ${n?"success":"not supported by CDM"} (${null==r?void 0:r.byteLength}) on "${t}"`),i(e)}).catch(e=>{n(new xo({type:Qe.KEY_SYSTEM_ERROR,details:Je.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:e,fatal:!0},e.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(t=>this.updateKeySession(e,new Uint8Array(t)).catch(e=>{throw new xo({type:Qe.KEY_SYSTEM_ERROR,details:Je.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:e,fatal:!0},e.message)}))}setupLicenseXHR(e,t,r,i){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,i)}).catch(s=>{if(!r.decryptdata)throw s;return e.open("POST",t,!0),n.call(this.hls,e,t,r,i)}).then(r=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:r||i})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:i}))}requestLicense(e,t){const r=this.config.keyLoadPolicy.default;return new Promise((i,n)=>{const s=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${s}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(4===o.readyState)if(200===o.status){this._requestLicenseFailureCount=0;let t=o.response;this.log(`License received ${t instanceof ArrayBuffer?t.byteLength:t}`);const r=this.config.licenseResponseCallback;if(r)try{t=r.call(this.hls,o,s,e)}catch(e){this.error(e)}i(t)}else{const a=r.errorRetry,l=a?a.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>l||o.status>=400&&o.status<500)n(new xo({type:Qe.KEY_SYSTEM_ERROR,details:Je.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:s,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${s}). Status: ${o.status} (${o.statusText})`));else{const r=l-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${r} attempts left`),this.requestLicense(e,t).then(i,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,s,e,t).then(({xhr:e,licenseChallenge:t})=>{e.send(t)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},hr.clearKeyUriToKeyIdMap();const r=t.length;Lo.CDMCleanupPromise=Promise.all(t.map(e=>this.removeSession(e)).concat(null==e?void 0:e.setMediaKeys(null).catch(t=>{this.log(`Could not clear media keys: ${t}. media.src: ${null==e?void 0:e.src}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(t=>{this.log(`Could not close sessions and clear media keys: ${t}. media.src: ${null==e?void 0:e.src}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(t&&this.config.emeEnabled&&!this.keyFormatPromise){const e=t.reduce((e,t)=>(-1===e.indexOf(t.keyFormat)&&e.push(t.keyFormat),e),[]);this.log(`Selecting key-system from session-keys ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),t.onmessage=null,t.onkeystatuseschange=null,r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const i=this.mediaKeySessions.indexOf(e);return i>-1&&this.mediaKeySessions.splice(i,1),t.remove().catch(e=>{this.log(`Could not remove session: ${e}`)}).then(()=>t.close()).catch(e=>{this.log(`Could not close session: ${e}`)})}}}Lo.CDMCleanupPromise=void 0;class xo extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}var Ro="a",Po="av";class Io{constructor(e){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=e=>{try{this.apply(e,{ot:"m",su:!this.initialized})}catch(e){rt.warn("Could not generate manifest CMCD data.",e)}},this.applyFragmentData=e=>{try{const t=e.frag,r=this.hls.levels[t.level],i=this.getObjectType(t),n={d:1e3*t.duration,ot:i};"v"!==i&&i!==Ro&&i!=Po||(n.br=r.bitrate/1e3,n.tb=this.getTopBandwidth(i)/1e3,n.bl=this.getBufferLength(i)),this.apply(e,n)}catch(e){rt.warn("Could not generate segment CMCD data.",e)}},this.hls=e;const t=this.config=e.config,{cmcd:r}=t;null!=r&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||Io.uuid(),this.cid=r.contentId,this.useHeaders=!0===r.useHeaders,this.registerListeners())}registerListeners(){const e=this.hls;e.on(Xe.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Xe.MEDIA_DETACHED,this.onMediaDetached,this),e.on(Xe.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(Xe.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Xe.MEDIA_DETACHED,this.onMediaDetached,this),e.off(Xe.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(e,t){var r,i;this.audioBuffer=null==(r=t.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(i=t.tracks.video)?void 0:i.buffer}createData(){var e;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:null==(e=this.media)?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){We(t,this.createData());const r="i"===t.ot||"v"===t.ot||t.ot===Po;if(this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),null==t.su&&(t.su=this.buffering),this.useHeaders){const r=Io.toHeaders(t);if(!Object.keys(r).length)return;e.headers||(e.headers={}),We(e.headers,r)}else{const r=Io.toQuery(t);if(!r)return;e.url=Io.appendQueryToUri(e.url,r)}}getObjectType(e){const{type:t}=e;return"subtitle"===t?"tt":"initSegment"===e.sn?"i":"audio"===t?Ro:"main"===t?this.hls.audioTracks.length?"v":Po:void 0}getTopBandwidth(e){let t,r=0;const i=this.hls;if(e===Ro)t=i.audioTracks;else{const e=i.maxAutoLevel,r=e>-1?e+1:i.levels.length;t=i.levels.slice(0,r)}for(const e of t)e.bitrate>r&&(r=e.bitrate);return r>0?r:NaN}getBufferLength(e){const t=this.hls.media,r=e===Ro?this.audioBuffer:this.videoBuffer;return r&&t?1e3*Gi.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len:NaN}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,i){t(e),this.loader.load(e,r,i)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(e){this.loader=void 0,this.loader=new r(e)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(e,r,i){t(e),this.loader.load(e,r,i)}}}static uuid(){const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}static serialize(e){const t=[],r=e=>!Number.isNaN(e)&&null!=e&&""!==e&&!1!==e,i=e=>Math.round(e),n=e=>100*i(e/100),s={br:i,d:i,bl:n,dl:n,mtp:n,nor:e=>encodeURIComponent(e),rtp:n,tb:i},o=Object.keys(e||{}).sort();for(const i of o){let n=e[i];if(!r(n))continue;if("v"===i&&1===n)continue;if("pr"==i&&1===n)continue;const o=s[i];o&&(n=o(n));const a=typeof n;let l;l="ot"===i||"sf"===i||"st"===i?`${i}=${n}`:"boolean"===a?i:"number"===a?`${i}=${n}`:`${i}=${JSON.stringify(n)}`,t.push(l)}return t.join(",")}static toHeaders(e){const t=Object.keys(e),r={},i=["Object","Request","Session","Status"],n=[{},{},{},{}],s={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3};for(const r of t)n[null!=s[r]?s[r]:1][r]=e[r];for(let e=0;e{const s=e.filter(e=>e.groupId===n).map(e=>{const s=We({},e);return s.details=void 0,s.attrs=new st(s.attrs),s.url=s.attrs.URI=_o(e.url,e.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),s.groupId=s.attrs["GROUP-ID"]=t[n],s.attrs["PATHWAY-ID"]=i,s});e.push(...s)})}function _o(e,t,r,i){const{HOST:n,PARAMS:s,[r]:o}=i;let a;t&&(a=null==o?void 0:o[t],a&&(e=a));const l=new self.URL(e);return n&&!a&&(l.host=n),s&&Object.keys(s).sort().forEach(e=>{e&&l.searchParams.set(e,s[e])}),l.href}const Oo=/^age:\s*[\d.]+\s*$/im;class Do{constructor(e){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=e&&e.xhrSetup||null,this.stats=new ct,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,4!==e.readyState&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e)return;const r=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!this.stats.aborted)return n(r,t.url)}).catch(e=>(r.open("GET",t.url,!0),n(r,t.url))).then(()=>{this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(e=>{this.callbacks.onError({code:r.status,text:e.message},t,r,i)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);const i=this.context.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:s}=r.loadPolicy;if(i)for(const t in i)e.setRequestHeader(t,i[t]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&qe(n)?n:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:r}=this;if(!e||!t)return;const i=t.readyState,n=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const i=t.status,s="text"!==t.responseType;if(i>=200&&i<300&&(s&&t.response||null!==t.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);const n=s?t.response:t.responseText,o="arraybuffer"===t.responseType?n.byteLength:n.length;if(r.loaded=r.total=o,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;const a=this.callbacks.onProgress;if(a&&a(r,e,n,t),!this.callbacks)return;const l={url:t.responseURL,data:n,code:i};this.callbacks.onSuccess(l,r,e,t)}else{const s=n.loadPolicy.errorRetry;vi(s,r.retry,!1,i)?this.retry(s):(rt.error(`${i} while loading ${e.url}`),this.callbacks.onError({code:i,text:t.statusText},e,t,r))}}}loadtimeout(){var e;const t=null==(e=this.config)?void 0:e.loadPolicy.timeoutRetry;if(vi(t,this.stats.retry,!0))this.retry(t);else{rt.warn(`timeout while loading ${this.context.url}`);const e=this.callbacks;e&&(this.abortInternal(),e.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:r}=this;this.retryDelay=mi(e,r.retry),r.retry++,rt.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t.url}, retrying ${r.retry}/${e.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Oo.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}const Mo=/(\d+)-(\d+)\/(\d+)/;class No{constructor(e){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=e.fetchSetup||Fo,this.controller=new self.AbortController,this.stats=new ct}destroy(){this.loader=this.callbacks=null,this.abortInternal()}abortInternal(){const e=this.response;null!=e&&e.ok||(this.stats.aborted=!0,this.controller.abort())}abort(){var e;this.abortInternal(),null!=(e=this.callbacks)&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){const i=this.stats;if(i.loading.start)throw new Error("Loader can only be used once.");i.loading.start=self.performance.now();const n=function(e,t){const r={method:"GET",mode:"cors",credentials:"same-origin",signal:t,headers:new self.Headers(We({},e.headers))};return e.rangeEnd&&r.headers.set("Range","bytes="+e.rangeStart+"-"+String(e.rangeEnd-1)),r}(e,this.controller.signal),s=r.onProgress,o="arraybuffer"===e.responseType,a=o?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:c}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=l&&qe(l)?l:c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(i,e,this.response)},t.timeout),self.fetch(this.request).then(n=>{this.response=this.loader=n;const a=Math.max(self.performance.now(),i.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(i,e,this.response)},c-(a-i.loading.start)),!n.ok){const{status:e,statusText:t}=n;throw new Bo(t||"fetch, bad network response",e,n)}return i.loading.first=a,i.total=function(e){const t=e.get("Content-Range");if(t){const e=function(e){const t=Mo.exec(e);if(t)return parseInt(t[2])-parseInt(t[1])+1}(t);if(qe(e))return e}const r=e.get("Content-Length");if(r)return parseInt(r)}(n.headers)||i.total,s&&qe(t.highWaterMark)?this.loadProgressively(n,i,e,t.highWaterMark,s):o?n.arrayBuffer():"json"===e.responseType?n.json():n.text()}).then(n=>{const{response:o}=this;self.clearTimeout(this.requestTimeout),i.loading.end=Math.max(self.performance.now(),i.loading.first);const l=n[a];l&&(i.loaded=i.total=l);const c={url:o.url,data:n,code:o.status};s&&!qe(t.highWaterMark)&&s(i,e,n,o),r.onSuccess(c,i,e,o)}).catch(t=>{if(self.clearTimeout(this.requestTimeout),i.aborted)return;const n=t&&t.code||0,s=t?t.message:null;r.onError({code:n,text:s},e,t?t.details:null,i)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,i=0,n){const s=new Ts,o=e.body.getReader(),a=()=>o.read().then(o=>{if(o.done)return s.dataLength&&n(t,r,s.flush(),e),Promise.resolve(new ArrayBuffer(0));const l=o.value,c=l.length;return t.loaded+=c,c=i&&n(t,r,s.flush(),e)):n(t,r,l,e),a()}).catch(()=>Promise.reject());return a()}}function Fo(e,t){return new self.Request(e.url,t)}class Bo extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}const Uo=/\s/,jo={newCue(e,t,r,i){const n=[];let s,o,a,l,c;const u=self.VTTCue||self.TextTrackCue;for(let h=0;h=16?l--:l++;const i=no(c.trim()),f=co(t,r,i);null!=e&&null!=(d=e.cues)&&d.getCueById(f)||(o=new u(t,r,i),o.id=f,o.line=h+1,o.align="left",o.position=10+Math.min(80,10*Math.floor(8*l/32)),n.push(o))}return e&&n.length&&(n.sort((e,t)=>"auto"===e.line||"auto"===t.line?0:e.line>8&&t.line>8?t.line-e.line:e.line-t.line),n.forEach(t=>qr(e,t))),n}},$o=Ge(Ge({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Do,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class{constructor(e){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=e;const t=e.config;this.bwEstimator=new As(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate),this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(Xe.FRAG_LOADING,this.onFragLoading,this),e.on(Xe.FRAG_LOADED,this.onFragLoaded,this),e.on(Xe.FRAG_BUFFERED,this.onFragBuffered,this),e.on(Xe.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Xe.LEVEL_LOADED,this.onLevelLoaded,this)}unregisterListeners(){const{hls:e}=this;e.off(Xe.FRAG_LOADING,this.onFragLoading,this),e.off(Xe.FRAG_LOADED,this.onFragLoaded,this),e.off(Xe.FRAG_BUFFERED,this.onFragBuffered,this),e.off(Xe.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Xe.LEVEL_LOADED,this.onLevelLoaded,this)}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null}onFragLoading(e,t){var r;const i=t.frag;this.ignoreFragment(i)||(this.fragCurrent=i,this.partCurrent=null!=(r=t.part)?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))}onLevelSwitching(e,t){this.clearTimer()}getTimeToLoadFrag(e,t,r,i){return e+r/t+(i?this.lastLevelLoadSec:0)}onLevelLoaded(e,t){const r=this.hls.config,{total:i,bwEstimate:n}=t.stats;qe(i)&&qe(n)&&(this.lastLevelLoadSec=8*i/n),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}_abandonRulesCheck(){const{fragCurrent:e,partCurrent:t,hls:r}=this,{autoLevelEnabled:i,media:n}=r;if(!e||!n)return;const s=performance.now(),o=t?t.stats:e.stats,a=t?t.duration:e.duration,l=s-o.loading.start;if(o.aborted||o.loaded&&o.loaded===o.total||0===e.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!i||n.paused||!n.playbackRate||!n.readyState)return;const c=r.mainForwardBufferInfo;if(null===c)return;const u=this.bwEstimator.getEstimateTTFB(),d=Math.abs(n.playbackRate);if(l<=Math.max(u,a/(2*d)*1e3))return;const h=c.len/d;if(h>=2*a/d)return;const f=o.loading.first?o.loading.first-o.loading.start:-1,p=o.loaded&&f>-1,g=this.bwEstimator.getEstimate(),{levels:m,minAutoLevel:y}=r,v=m[e.level],b=o.total||Math.max(o.loaded,Math.round(a*v.maxBitrate/8));let E=l-f;E<1&&p&&(E=Math.min(l,8*o.loaded/g));const A=p?1e3*o.loaded/E:0,T=A?(b-o.loaded)/A:8*b/g+u/1e3;if(T<=h)return;const w=A?8*A:g;let S,k=Number.POSITIVE_INFINITY;for(S=e.level-1;S>y;S--){const e=m[S].maxBitrate;if(k=this.getTimeToLoadFrag(u/1e3,w,a*e,!m[S].details),k=T||k>10*a||(r.nextLoadLevel=S,p?this.bwEstimator.sample(l-Math.min(u,f),o.loaded):this.bwEstimator.sampleTTFB(l),this.clearTimer(),rt.warn(`[abr] Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} is loading too slowly;\n Time to underbuffer: ${h.toFixed(3)} s\n Estimated load time for current fragment: ${T.toFixed(3)} s\n Estimated load time for down switch fragment: ${k.toFixed(3)} s\n TTFB estimate: ${f}\n Current BW estimate: ${qe(g)?(g/1024).toFixed(3):"Unknown"} Kb/s\n New BW estimate: ${(this.bwEstimator.getEstimate()/1024).toFixed(3)} Kb/s\n Aborting and switching to level ${S}`),e.loader&&(this.fragCurrent=this.partCurrent=null,e.abortRequests()),r.trigger(Xe.FRAG_LOAD_EMERGENCY_ABORTED,{frag:e,part:t,stats:o}))}onFragLoaded(e,{frag:t,part:r}){const i=r?r.stats:t.stats;if(t.type===jr&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),this.lastLoadedFragLevel=t.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){const e=r?r.duration:t.duration,n=this.hls.levels[t.level],s=(n.loaded?n.loaded.bytes:0)+i.loaded,o=(n.loaded?n.loaded.duration:0)+e;n.loaded={bytes:s,duration:o},n.realBitrate=Math.round(8*s/o)}if(t.bitrateTest){const e={stats:i,frag:t,part:r,id:t.type};this.onFragBuffered(Xe.FRAG_BUFFERED,e),t.bitrateTest=!1}}}onFragBuffered(e,t){const{frag:r,part:i}=t,n=null!=i&&i.stats.loaded?i.stats:r.stats;if(n.aborted)return;if(this.ignoreFragment(r))return;const s=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(s,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=s/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==jr||"initSegment"===e.sn}clearTimer(){self.clearInterval(this.timer)}get nextAutoLevel(){const e=this._nextAutoLevel,t=this.bwEstimator;if(-1!==e&&!t.canEstimate())return e;let r=this.getNextABRAutoLevel();if(-1!==e){const t=this.hls.levels;if(t.length>Math.max(e,r)&&t[e].loadError<=t[r].loadError)return e}return-1!==e&&(r=Math.min(e,r)),r}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:i,config:n,minAutoLevel:s,media:o}=r,a=t?t.duration:e?e.duration:0,l=o&&0!==o.playbackRate?Math.abs(o.playbackRate):1,c=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,u=r.mainForwardBufferInfo,d=(u?u.len:0)/l;let h=this.findBestLevel(c,s,i,d,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(h>=0)return h;rt.trace(`[abr] ${d?"rebuffering expected":"buffer is empty"}, finding optimal quality level`);let f=a?Math.min(a,n.maxStarvationDelay):n.maxStarvationDelay,p=n.abrBandWidthFactor,g=n.abrBandWidthUpFactor;if(!d){const e=this.bitrateTestDelay;e&&(f=(a?Math.min(a,n.maxLoadingDelay):n.maxLoadingDelay)-e,rt.trace(`[abr] bitrate test took ${Math.round(1e3*e)}ms, set first fragment max fetchDuration to ${Math.round(1e3*f)} ms`),p=g=1)}return h=this.findBestLevel(c,s,i,d+f,p,g),Math.max(h,0)}findBestLevel(e,t,r,i,n,s){var o;const{fragCurrent:a,partCurrent:l,lastLoadedFragLevel:c}=this,{levels:u}=this.hls,d=u[c],h=!(null==d||null==(o=d.details)||!o.live),f=null==d?void 0:d.codecSet,p=l?l.duration:a?a.duration:0,g=this.bwEstimator.getEstimateTTFB()/1e3;let m=t,y=-1;for(let o=r;o>=t;o--){const t=u[o];if(!t||f&&t.codecSet!==f){t&&(m=Math.min(o,m),y=Math.max(o,y));continue}-1!==y&&rt.trace(`[abr] Skipped level(s) ${m}-${y} with CODECS:"${u[y].attrs.CODECS}"; not compatible with "${d.attrs.CODECS}"`);const r=t.details,a=(l?null==r?void 0:r.partTarget:null==r?void 0:r.averagetargetduration)||p;let v;v=o<=c?n*e:s*e;const b=u[o].maxBitrate,E=this.getTimeToLoadFrag(g,v,b*a,void 0===r);if(rt.trace(`[abr] level:${o} adjustedbw-bitrate:${Math.round(v-b)} avgDuration:${a.toFixed(1)} maxFetchDuration:${i.toFixed(1)} fetchDuration:${E.toFixed(1)}`),v>b&&(0===E||!qe(E)||h&&!this.bitrateTestDelay||E{const{media:e,mediaSource:t}=this;rt.log("[buffer-controller]: Media source opened"),e&&(e.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(Xe.MEDIA_ATTACHED,{media:e})),t&&t.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{rt.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=()=>{rt.log("[buffer-controller]: Media source ended")},this._onMediaEmptied=()=>{const{media:e,_objectUrl:t}=this;e&&e.src!==t&&rt.error(`Media element src was set while attaching MediaSource (${t} > ${e.src})`)},this.hls=e,this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null}registerListeners(){const{hls:e}=this;e.on(Xe.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(Xe.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Xe.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Xe.BUFFER_RESET,this.onBufferReset,this),e.on(Xe.BUFFER_APPENDING,this.onBufferAppending,this),e.on(Xe.BUFFER_CODECS,this.onBufferCodecs,this),e.on(Xe.BUFFER_EOS,this.onBufferEos,this),e.on(Xe.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Xe.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(Xe.FRAG_PARSED,this.onFragParsed,this),e.on(Xe.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(Xe.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(Xe.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Xe.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Xe.BUFFER_RESET,this.onBufferReset,this),e.off(Xe.BUFFER_APPENDING,this.onBufferAppending,this),e.off(Xe.BUFFER_CODECS,this.onBufferCodecs,this),e.off(Xe.BUFFER_EOS,this.onBufferEos,this),e.off(Xe.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Xe.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(Xe.FRAG_PARSED,this.onFragParsed,this),e.off(Xe.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new xs(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,rt.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){const r=this.media=t.media;if(r&&Rs){const e=this.mediaSource=new Rs;e.addEventListener("sourceopen",this._onMediaSourceOpen),e.addEventListener("sourceended",this._onMediaSourceEnded),e.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(e),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(rt.log("[buffer-controller]: media source detaching"),"open"===t.readyState)try{t.endOfStream()}catch(e){rt.warn(`[buffer-controller]: onMediaDetaching: ${e.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),e.src===r?(e.removeAttribute("src"),e.load()):rt.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(Xe.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{const t=this.sourceBuffer[e];try{t&&(this.removeBufferListeners(e),this.mediaSource&&this.mediaSource.removeSourceBuffer(t),this.sourceBuffer[e]=void 0)}catch(t){rt.warn(`[buffer-controller]: Failed to reset the ${e} buffer`,t)}}),this._initSourceBuffer()}onBufferCodecs(e,t){const r=this.getSourceBufferTypes().length;Object.keys(t).forEach(e=>{if(r){const r=this.tracks[e];if(r&&"function"==typeof r.buffer.changeType){const{id:i,codec:n,levelCodec:s,container:o,metadata:a}=t[e],l=(r.levelCodec||r.codec).replace(Ps,"$1"),c=(s||n).replace(Ps,"$1");if(l!==c){const t=`${o};codecs=${s||n}`;this.appendChangeType(e,t),rt.log(`[buffer-controller]: switching codec ${l} to ${c}`),this.tracks[e]={buffer:r.buffer,codec:n,container:o,levelCodec:s,metadata:a,id:i}}}}else this.pendingTracks[e]=t[e]}),r||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())}appendChangeType(e,t){const{operationQueue:r}=this,i={execute:()=>{const i=this.sourceBuffer[e];i&&(rt.log(`[buffer-controller]: changing ${e} sourceBuffer type to ${t}`),i.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:t=>{rt.warn(`[buffer-controller]: Failed to change ${e} SourceBuffer type`,t)}};r.append(i,e)}onBufferAppending(e,t){const{hls:r,operationQueue:i,tracks:n}=this,{data:s,type:o,frag:a,part:l,chunkMeta:c}=t,u=c.buffering[o],d=self.performance.now();u.start=d;const h=a.stats.buffering,f=l?l.stats.buffering:null;0===h.start&&(h.start=d),f&&0===f.start&&(f.start=d);const p=n.audio;let g=!1;"audio"===o&&"audio/mpeg"===(null==p?void 0:p.container)&&(g=!this.lastMpegAudioChunk||1===c.id||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);const m=a.start,y={execute:()=>{if(u.executeStart=self.performance.now(),g){const e=this.sourceBuffer[o];if(e){const t=m-e.timestampOffset;Math.abs(t)>=.1&&(rt.log(`[buffer-controller]: Updating audio SourceBuffer timestampOffset to ${m} (delta: ${t}) sn: ${a.sn})`),e.timestampOffset=m)}}this.appendExecutor(s,o)},onStart:()=>{},onComplete:()=>{const e=self.performance.now();u.executeEnd=u.end=e,0===h.first&&(h.first=e),f&&0===f.first&&(f.first=e);const{sourceBuffer:t}=this,r={};for(const e in t)r[e]=Gi.getBuffered(t[e]);this.appendError=0,this.hls.trigger(Xe.BUFFER_APPENDED,{type:o,frag:a,part:l,chunkMeta:c,parent:a.type,timeRanges:r})},onError:e=>{rt.error(`[buffer-controller]: Error encountered while trying to append to the ${o} SourceBuffer`,e);const t={type:Qe.MEDIA_ERROR,parent:a.type,details:Je.BUFFER_APPEND_ERROR,frag:a,part:l,chunkMeta:c,error:e,err:e,fatal:!1};e.code===DOMException.QUOTA_EXCEEDED_ERR?t.details=Je.BUFFER_FULL_ERROR:(this.appendError++,t.details=Je.BUFFER_APPEND_ERROR,this.appendError>r.config.appendErrorMaxRetry&&(rt.error(`[buffer-controller]: Failed ${r.config.appendErrorMaxRetry} times to append segment in sourceBuffer`),t.fatal=!0)),r.trigger(Xe.ERROR,t)}};i.append(y,o)}onBufferFlushing(e,t){const{operationQueue:r}=this,i=e=>({execute:this.removeExecutor.bind(this,e,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(Xe.BUFFER_FLUSHED,{type:e})},onError:t=>{rt.warn(`[buffer-controller]: Failed to remove from ${e} SourceBuffer`,t)}});t.type?r.append(i(t.type),t.type):this.getSourceBufferTypes().forEach(e=>{r.append(i(e),e)})}onFragParsed(e,t){const{frag:r,part:i}=t,n=[],s=i?i.elementaryStreams:r.elementaryStreams;s[ht]?n.push("audiovideo"):(s[ut]&&n.push("audio"),s[dt]&&n.push("video")),0===n.length&&rt.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(()=>{const e=self.performance.now();r.stats.buffering.end=e,i&&(i.stats.buffering.end=e);const t=i?i.stats:r.stats;this.hls.trigger(Xe.FRAG_BUFFERED,{frag:r,part:i,stats:t,id:r.type})},n)}onFragChanged(e,t){this.flushBackBuffer()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((e,r)=>{const i=this.sourceBuffer[r];return!i||t.type&&t.type!==r||(i.ending=!0,i.ended||(i.ended=!0,rt.log(`[buffer-controller]: ${r} sourceBuffer now EOS`))),e&&!(i&&!i.ended)},!0)&&(rt.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(e=>{const t=this.sourceBuffer[e];t&&(t.ending=!1)});const{mediaSource:e}=this;e&&"open"===e.readyState?(rt.log("[buffer-controller]: Calling mediaSource.endOfStream()"),e.endOfStream()):e&&rt.info(`[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: ${e.readyState}`)}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}flushBackBuffer(){const{hls:e,details:t,media:r,sourceBuffer:i}=this;if(!r||null===t)return;const n=this.getSourceBufferTypes();if(!n.length)return;const s=t.live&&null!==e.config.liveBackBufferLength?e.config.liveBackBufferLength:e.config.backBufferLength;if(!qe(s)||s<0)return;const o=r.currentTime,a=t.levelTargetDuration,l=Math.max(s,a),c=Math.floor(o/a)*a-l;n.forEach(r=>{const n=i[r];if(n){const i=Gi.getBuffered(n);if(i.length>0&&c>i.start(0)){if(e.trigger(Xe.BACK_BUFFER_REACHED,{bufferEnd:c}),t.live)e.trigger(Xe.LIVE_BACK_BUFFER_REACHED,{bufferEnd:c});else if(n.ended&&i.end(i.length-1)-o<2*a)return void rt.info(`[buffer-controller]: Cannot flush ${r} back buffer while SourceBuffer is in ended state`);e.trigger(Xe.BUFFER_FLUSHING,{startOffset:0,endOffset:c,type:r})}}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||"open"!==this.mediaSource.readyState)return;const{details:e,hls:t,media:r,mediaSource:i}=this,n=e.fragments[0].start+e.totalduration,s=r.duration,o=qe(i.duration)?i.duration:0;e.live&&t.config.liveDurationInfinity?(rt.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>s||!qe(s))&&(rt.log(`[buffer-controller]: Updating Media Source duration to ${n.toFixed(3)}`),i.duration=n)}updateSeekableRange(e){const t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&null!=t&&t.setLiveSeekableRange){const i=Math.max(0,r[0].start),n=Math.max(i,i+e.totalduration);t.setLiveSeekableRange(i,n)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,i=Object.keys(r).length;if(i&&!e||2===i){this.createSourceBuffers(r),this.pendingTracks={};const e=this.getSourceBufferTypes();if(e.length)this.hls.trigger(Xe.BUFFER_CREATED,{tracks:this.tracks}),e.forEach(e=>{t.executeNext(e)});else{const e=new Error("could not create source buffer for media codec(s)");this.hls.trigger(Xe.ERROR,{type:Qe.MEDIA_ERROR,details:Je.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:e,reason:e.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(const i in e)if(!t[i]){const n=e[i];if(!n)throw Error(`source buffer exists for track ${i}, however track does not`);const s=n.levelCodec||n.codec,o=`${n.container};codecs=${s}`;rt.log(`[buffer-controller]: creating sourceBuffer(${o})`);try{const e=t[i]=r.addSourceBuffer(o),a=i;this.addBufferListener(a,"updatestart",this._onSBUpdateStart),this.addBufferListener(a,"updateend",this._onSBUpdateEnd),this.addBufferListener(a,"error",this._onSBUpdateError),this.tracks[i]={buffer:e,codec:s,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(e){rt.error(`[buffer-controller]: error while trying to add sourceBuffer: ${e.message}`),this.hls.trigger(Xe.ERROR,{type:Qe.MEDIA_ERROR,details:Je.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:e,mimeType:o})}}}_onSBUpdateStart(e){const{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){const{operationQueue:t}=this;t.current(e).onComplete(),t.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){const r=new Error(`${e} SourceBuffer error`);rt.error(`[buffer-controller]: ${r}`,t),this.hls.trigger(Xe.ERROR,{type:Qe.MEDIA_ERROR,details:Je.BUFFER_APPENDING_ERROR,error:r,fatal:!1});const i=this.operationQueue.current(e);i&&i.onError(t)}removeExecutor(e,t,r){const{media:i,mediaSource:n,operationQueue:s,sourceBuffer:o}=this,a=o[e];if(!i||!n||!a)return rt.warn(`[buffer-controller]: Attempting to remove from the ${e} SourceBuffer, but it does not exist`),void s.shiftAndExecuteNext(e);const l=qe(i.duration)?i.duration:1/0,c=qe(n.duration)?n.duration:1/0,u=Math.max(0,t),d=Math.min(r,l,c);d>u&&!a.ending?(a.ended=!1,rt.log(`[buffer-controller]: Removing [${u},${d}] from the ${e} SourceBuffer`),a.remove(u,d)):s.shiftAndExecuteNext(e)}appendExecutor(e,t){const{operationQueue:r,sourceBuffer:i}=this,n=i[t];if(!n)return rt.warn(`[buffer-controller]: Attempting to append to the ${t} SourceBuffer, but it does not exist`),void r.shiftAndExecuteNext(t);n.ended=!1,n.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length)return rt.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(e);const{operationQueue:r}=this,i=t.map(e=>r.appendBlocker(e));Promise.all(i).then(()=>{e(),t.forEach(e=>{const t=this.sourceBuffer[e];null!=t&&t.updating||r.shiftAndExecuteNext(e)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){const i=this.sourceBuffer[e];if(!i)return;const n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),i.addEventListener(t,n)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(e=>{t.removeEventListener(e.event,e.listener)})}},capLevelController:So,errorController:class{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=rt.log.bind(rt,"[info]:"),this.warn=rt.warn.bind(rt,"[warning]:"),this.error=rt.error.bind(rt,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(Xe.ERROR,this.onError,this),e.on(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Xe.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(Xe.ERROR,this.onError,this),e.off(Xe.ERROR,this.onErrorOut,this),e.off(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Xe.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){this.playlistError=0}stopLoad(){}getVariantLevelIndex(e){return(null==e?void 0:e.type)===jr?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,i;if(t.fatal)return;const n=this.hls,s=t.context;switch(t.details){case Je.FRAG_LOAD_ERROR:case Je.FRAG_LOAD_TIMEOUT:case Je.KEY_LOAD_ERROR:case Je.KEY_LOAD_TIMEOUT:return void(t.errorAction=this.getFragRetryOrSwitchAction(t));case Je.FRAG_PARSING_ERROR:if(null!=(r=t.frag)&&r.gap)return void(t.errorAction={action:0,flags:0});case Je.FRAG_GAP:case Je.FRAG_DECRYPT_ERROR:return t.errorAction=this.getFragRetryOrSwitchAction(t),void(t.errorAction.action=2);case Je.LEVEL_EMPTY_ERROR:case Je.LEVEL_PARSING_ERROR:{var o,a;const e=t.parent===jr?t.level:n.loadLevel;t.details===Je.LEVEL_EMPTY_ERROR&&null!=(o=t.context)&&null!=(a=o.levelDetails)&&a.live?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,e):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e))}return;case Je.LEVEL_LOAD_ERROR:case Je.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==s?void 0:s.level)&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,s.level)));case Je.AUDIO_TRACK_LOAD_ERROR:case Je.AUDIO_TRACK_LOAD_TIMEOUT:case Je.SUBTITLE_LOAD_ERROR:case Je.SUBTITLE_TRACK_LOAD_TIMEOUT:if(s){const e=n.levels[n.loadLevel];if(e&&(s.type===Br&&s.groupId===e.audioGroupId||s.type===Ur&&s.groupId===e.textGroupId))return t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=2,void(t.errorAction.flags=1)}return;case Je.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const e=n.levels[n.loadLevel],r=null==e?void 0:e.attrs["HDCP-LEVEL"];r&&(t.errorAction={action:2,flags:2,hdcpLevel:r})}return;case Je.BUFFER_ADD_CODEC_ERROR:case Je.REMUX_ALLOC_ERROR:return void(t.errorAction=this.getLevelSwitchAction(t,null!=(i=t.level)?i:n.loadLevel));case Je.INTERNAL_EXCEPTION:case Je.BUFFER_APPENDING_ERROR:case Je.BUFFER_APPEND_ERROR:case Je.BUFFER_FULL_ERROR:case Je.LEVEL_SWITCH_ERROR:case Je.BUFFER_STALLED_ERROR:case Je.BUFFER_SEEK_OVER_HOLE:case Je.BUFFER_NUDGE_ON_STALL:return void(t.errorAction={action:0,flags:0})}if(t.type===Qe.KEY_SYSTEM_ERROR){const e=this.getVariantLevelIndex(t.frag);return t.levelRetry=!1,void(t.errorAction=this.getLevelSwitchAction(t,e))}}getPlaylistRetryOrSwitchAction(e,t){var r;const i=gi(this.hls.config.playlistLoadPolicy,e),n=this.playlistError++,s=null==(r=e.response)?void 0:r.code;if(vi(i,n,pi(e),s))return{action:5,flags:0,retryConfig:i,retryCount:n};const o=this.getLevelSwitchAction(e,t);return i&&(o.retryConfig=i,o.retryCount=n),o}getFragRetryOrSwitchAction(e){const t=this.hls,r=this.getVariantLevelIndex(e.frag),i=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:s}=t.config,o=gi(e.details.startsWith("key")?s:n,e),a=t.levels.reduce((e,t)=>e+t.fragmentError,0);if(i){var l;e.details!==Je.FRAG_GAP&&i.fragmentError++;const t=null==(l=e.response)?void 0:l.code;if(vi(o,a,pi(e),t))return{action:5,flags:0,retryConfig:o,retryCount:a}}const c=this.getLevelSwitchAction(e,r);return o&&(c.retryConfig=o,c.retryCount=a),c}getLevelSwitchAction(e,t){const r=this.hls;null==t&&(t=r.loadLevel);const i=this.hls.levels[t];if(i&&(i.loadError++,r.autoLevelEnabled)){var n,s;let t=-1;const{levels:o,loadLevel:a,minAutoLevel:l,maxAutoLevel:c}=r,u=null==(n=e.frag)?void 0:n.type,{type:d,groupId:h}=null!=(s=e.context)?s:{};for(let r=o.length;r--;){const n=(r+a)%o.length;if(n!==a&&n>=l&&n<=c&&0===o[n].loadError){const r=o[n];if(e.details===Je.FRAG_GAP&&e.frag){const t=o[n].details;if(t){const r=Ei(e.frag,t.fragments,e.frag.start);if(null!=r&&r.gap)continue}}else{if(d===Br&&h===r.audioGroupId||d===Ur&&h===r.textGroupId)continue;if(u===$r&&i.audioGroupId===r.audioGroupId||u===Vr&&i.textGroupId===r.textGroupId)continue}t=n;break}}if(t>-1&&r.loadLevel!==t)return e.levelRetry=!0,this.playlistError=0,{action:2,flags:0,nextAutoLevel:t}}return{action:2,flags:1}}onErrorOut(e,t){var r;switch(null==(r=t.errorAction)?void 0:r.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(t),t.errorAction.resolved||t.details===Je.FRAG_GAP||(t.fatal=!0)}t.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(e){const t=this.hls,r=e.errorAction;if(!r)return;const{flags:i,hdcpLevel:n,nextAutoLevel:s}=r;switch(i){case 0:this.switchLevel(e,s);break;case 1:r.resolved||(r.resolved=this.redundantFailover(e));break;case 2:n&&(t.maxHdcpLevel=si[si.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`)}r.resolved||this.switchLevel(e,s)}switchLevel(e,t){void 0!==t&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}redundantFailover(e){const{hls:t,penalizedRenditions:r}=this,i=e.parent===jr?e.level:t.loadLevel,n=t.levels[i],s=n.url.length,o=e.frag?e.frag.urlId:n.urlId;n.urlId!==o||e.frag&&!n.details||this.penalizeRendition(n,e);for(let a=1;a{e.urlId=l}),t.nextLoadLevel=i,!0}return!1}penalizeRendition(e,t){const{penalizedRenditions:r}=this,i=r[e.urlId]||{lastErrorPerfMs:0,errors:[],details:void 0};i.lastErrorPerfMs=performance.now(),i.errors.push(t),i.details=e.details,r[e.urlId]=i}},fpsController:class{constructor(e){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(Xe.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(Xe.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const r=this.hls.config;if(r.capLevelOnFPSDrop){const e=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=e,e&&"function"==typeof e.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){const i=performance.now();if(t){if(this.lastTime){const e=i-this.lastTime,n=r-this.lastDroppedFrames,s=t-this.lastDecodedFrames,o=1e3*n/e,a=this.hls;if(a.trigger(Xe.FPS_DROP,{currentDropped:n,currentDecoded:s,totalDroppedFrames:r}),o>0&&n>a.config.fpsDroppedMonitoringThreshold*s){let e=a.currentLevel;rt.warn("drop FPS ratio greater than max allowed value for currentLevel: "+e),e>0&&(-1===a.autoLevelCapping||a.autoLevelCapping>=e)&&(e-=1,a.trigger(Xe.FPS_DROP_LEVEL_CAPPING,{level:e,droppedLevel:a.currentLevel}),a.autoLevelCapping=e,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:Rt,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:jo,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends fn{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",Vr),this.levels=[],this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;e.on(Xe.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Xe.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Xe.LEVEL_LOADED,this.onLevelLoaded,this),e.on(Xe.ERROR,this.onError,this),e.on(Xe.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(Xe.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(Xe.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Xe.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(Xe.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(Xe.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(Xe.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Xe.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Xe.LEVEL_LOADED,this.onLevelLoaded,this),e.off(Xe.ERROR,this.onError,this),e.off(Xe.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(Xe.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(Xe.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Xe.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(Xe.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(Xe.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=tn,this.setInterval(500),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:r,success:i}=t;if(this.fragPrevious=r,this.state=tn,!i)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let s;const o=r.start;for(let e=0;e=n[e].start&&o<=n[e].end){s=n[e];break}const a=r.start+r.duration;s?s.end=a:(s={start:o,end:a},n.push(s)),this.fragmentTracker.fragBuffered(r)}onBufferFlushing(e,t){const{startOffset:r,endOffset:i}=t;if(0===r&&i!==Number.POSITIVE_INFINITY){const e=i-1;if(e<=0)return;t.endOffsetSubtitles=Math.max(0,e),this.tracksBuffered.forEach(t=>{for(let r=0;rnew ai(e)):(this.tracksBuffered=[],this.levels=t.map(e=>{const t=new ai(e);return this.tracksBuffered[t.id]=[],t}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,Vr),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(e,t){if(this.currentTrackId=t.id,!this.levels.length||-1===this.currentTrackId)return void this.clearInterval();const r=this.levels[this.currentTrackId];null!=r&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(500)}onSubtitleTrackLoaded(e,t){var r;const{details:i,id:n}=t,{currentTrackId:s,levels:o}=this;if(!o.length)return;const a=o[s];if(n>=o.length||n!==s||!a)return;this.mediaBuffer=this.mediaBufferTimeRanges;let l=0;if(i.live||null!=(r=a.details)&&r.live){const e=this.mainDetails;if(i.deltaUpdateFailed||!e)return;const t=e.fragments[0];a.details?(l=this.alignPlaylists(i,a.details),0===l&&t&&(l=t.start,di(i,l))):i.hasProgramDateTime&&e.hasProgramDateTime?(Yi(i,e),l=i.fragments[0].start):t&&(l=t.start,di(i,l))}a.details=i,this.levelLastLoaded=n,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(a.details,l),this.tick(),i.live&&!this.fragCurrent&&this.media&&this.state===tn&&(Ei(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),a.details=void 0))}_handleFragmentLoadComplete(e){const{frag:t,payload:r}=e,i=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&i&&i.key&&i.iv&&"AES-128"===i.method){const e=performance.now();this.decrypter.decrypt(new Uint8Array(r),i.key.buffer,i.iv.buffer).catch(e=>{throw n.trigger(Xe.ERROR,{type:Qe.MEDIA_ERROR,details:Je.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e}).then(r=>{const i=performance.now();n.trigger(Xe.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:e,tdecrypt:i}})}).catch(e=>{this.warn(`${e.name}: ${e.message}`),this.state=tn})}}doTick(){if(this.media){if(this.state===tn){const{currentTrackId:e,levels:t}=this,r=t[e];if(!t.length||!r||!r.details)return;const{config:i}=this,n=this.getLoadPosition(),s=Gi.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,i.maxBufferHole),{end:o,len:a}=s,l=this.getFwdBufferInfo(this.media,jr),c=r.details;if(a>this.getMaxBufferLength(null==l?void 0:l.len)+c.levelTargetDuration)return;const u=c.fragments,d=u.length,h=c.edge;let f=null;const p=this.fragPrevious;if(oh-e?0:e;f=Ei(p,u,Math.max(u[0].start,o),t),!f&&p&&p.startthis.onTextTracksChanged(),this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes(this.trackId)}registerListeners(){const{hls:e}=this;e.on(Xe.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(Xe.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Xe.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Xe.LEVEL_LOADING,this.onLevelLoading,this),e.on(Xe.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Xe.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(Xe.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Xe.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(Xe.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Xe.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Xe.LEVEL_LOADING,this.onLevelLoading,this),e.off(Xe.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Xe.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(Xe.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,e)}onMediaDetaching(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Ls(this.media.textTracks).forEach(e=>{zr(e)}),this.subtitleTrack=-1,this.media=null)}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:r,details:i}=t,{trackId:n}=this,s=this.tracksInGroup[n];if(!s)return void this.warn(`Invalid subtitle track id ${r}`);const o=s.details;s.details=t.details,this.log(`subtitle track ${r} loaded [${i.startSN}-${i.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(null==t||!t.textGroupIds)return;const r=t.textGroupIds[t.urlId],i=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==r){const e=this.tracks.filter(e=>!r||e.groupId===r);this.tracksInGroup=e;const t=this.findTrackId(null==i?void 0:i.name)||this.findTrackId();this.groupId=r||null;const n={subtitleTracks:e};this.log(`Updating subtitle tracks, ${e.length} track(s) found in "${r}" group-id`),this.hls.trigger(Xe.SUBTITLE_TRACKS_UPDATED,n),-1!==t&&this.setSubtitleTrack(t,i)}else this.shouldReloadPlaylist(i)&&this.setSubtitleTrack(this.trackId,i)}findTrackId(e){const t=this.tracksInGroup;for(let r=0;re.groupId===this.groupId);if(-1===e)[].slice.call(i).forEach(e=>{e.mode="disabled"});else{const e=n[r];e&&(e.mode="disabled")}const s=n[e];s&&(s.mode=this.subtitleDisplay?"showing":"hidden")}setSubtitleTrack(e,t){var r;const i=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=e);if(this.trackId!==e&&this.toggleTrackModes(e),this.trackId===e&&(-1===e||null!=(r=i[e])&&r.details)||e<-1||e>=i.length)return;this.clearTimer();const n=i[e];if(this.log(`Switching to subtitle-track ${e}`+(n?` "${n.name}" lang:${n.lang} group:${n.groupId}`:"")),this.trackId=e,n){const{id:e,groupId:r="",name:i,type:s,url:o}=n;this.hls.trigger(Xe.SUBTITLE_TRACK_SWITCH,{id:e,groupId:r,name:i,type:s,url:o});const a=this.switchParams(n.url,null==t?void 0:t.details);this.loadPlaylist(a)}else this.hls.trigger(Xe.SUBTITLE_TRACK_SWITCH,{id:e})}onTextTracksChanged(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let e=-1;const t=Ls(this.media.textTracks);for(let r=0;r=0&&(i[0]=Math.min(i[0],t),i[1]=Math.max(i[1],r),s=!0,o/(r-t)>.5))return}if(s||n.push([t,r]),this.config.renderTextTracksNatively){const n=this.captionsTracks[e];this.Cues.newCue(n,t,r,i)}else{const n=this.Cues.newCue(null,t,r,i);this.hls.trigger(Xe.CUES_PARSED,{type:"captions",cues:n,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:i,timescale:n}){const{unparsedVttFrags:s}=this;"main"===r&&(this.initPTS[t.cc]={baseTime:i,timescale:n}),s.length&&(this.unparsedVttFrags=[],s.forEach(e=>{this.onFragLoaded(Xe.FRAG_LOADED,e)}))}getExistingTrack(e){const{media:t}=this;if(t)for(let r=0;r{zr(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let e=0;ee.textCodec===uo);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(ws(this.tracks,r))return void(this.tracks=r);if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const e=this.media?this.media.textTracks:null;this.tracks.forEach((t,r)=>{let i;if(e&&r({label:e.name,kind:e.type.toLowerCase(),default:e.default,subtitleTrack:e}));this.hls.trigger(Xe.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:e})}}}_captionsOrSubtitlesFromCharacteristics(e){if(e.attrs.CHARACTERISTICS){const t=/transcribes-spoken-dialog/gi.test(e.attrs.CHARACTERISTICS),r=/describes-music-and-sound/gi.test(e.attrs.CHARACTERISTICS);if(t&&r)return"captions"}return"subtitles"}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(e=>{const t=/(?:CC|SERVICE)([1-4])/.exec(e.instreamId);if(!t)return;const r=`textTrack${t[1]}`,i=this.captionsProperties[r];i&&(i.label=e.name,e.lang&&(i.languageCode=e.lang),i.media=e)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return null==t?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){const{cea608Parser1:r,cea608Parser2:i,lastSn:n,lastPartIndex:s}=this;if(this.enabled&&r&&i&&t.frag.type===jr){var o,a;const e=t.frag.sn,l=null!=(o=null==t||null==(a=t.part)?void 0:a.index)?o:-1;e===n+1||e===n&&l===s+1||(r.reset(),i.reset()),this.lastSn=e,this.lastPartIndex=l}}onFragLoaded(e,t){const{frag:r,payload:i}=t;if(r.type===Vr)if(i.byteLength){const e=r.decryptdata,n="stats"in t;if(null==e||!e.encrypted||n){const e=this.tracks[r.level],n=this.vttCCs;n[r.cc]||(n[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),e&&e.textCodec===uo?this._parseIMSC1(r,i):this._parseVTTs(t)}}else this.hls.trigger(Xe.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;go(t,this.initPTS[e.cc],t=>{this._appendCues(t,e.level),r.trigger(Xe.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},t=>{rt.log(`Failed to parse IMSC1: ${t}`),r.trigger(Xe.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:t})})}_parseVTTs(e){var t;const{frag:r,payload:i}=e,{initPTS:n,unparsedVttFrags:s}=this,o=n.length-1;if(!n[r.cc]&&-1===o)return void s.push(e);const a=this.hls;!function(e,t,r,i,n,s,o){const a=new so,l=Ht(new Uint8Array(e)).trim().replace(oo,"\n").split("\n"),c=[],u=t?function(e,t=1){return Xn(e,9e4,1/t)}(t.baseTime,t.timescale):0;let d,h="00:00.000",f=0,p=0,g=!0;a.oncue=function(e){const s=r[i];let o=r.ccOffset;const a=(f-u)/9e4;if(null!=s&&s.new&&(void 0!==p?o=r.ccOffset=s.start:function(e,t,r){let i=e[t],n=e[i.prevCC];if(!n||!n.new&&i.new)return e.ccOffset=e.presentationOffset=i.start,void(i.new=!1);for(;null!=(s=n)&&s.new;){var s;e.ccOffset+=i.start-n.start,i.new=!1,i=n,n=e[i.prevCC]}e.presentationOffset=r}(r,i,a)),a){if(!t)return void(d=new Error("Missing initPTS for VTT MPEGTS"));o=a-r.presentationOffset}const l=e.endTime-e.startTime,h=rs(9e4*(e.startTime+o-p),9e4*n)/9e4;e.startTime=Math.max(h,0),e.endTime=Math.max(h+l,0);const g=e.text.trim();e.text=decodeURIComponent(encodeURIComponent(g)),e.id||(e.id=co(e.startTime,e.endTime,g)),e.endTime>0&&c.push(e)},a.onparsingerror=function(e){d=e},a.onflush=function(){d?o(d):s(c)},l.forEach(e=>{if(g){if(ao(e,"X-TIMESTAMP-MAP=")){g=!1,e.slice(16).split(",").forEach(e=>{ao(e,"LOCAL:")?h=e.slice(6):ao(e,"MPEGTS:")&&(f=parseInt(e.slice(7)))});try{p=function(e){let t=parseInt(e.slice(-3));const r=parseInt(e.slice(-6,-4)),i=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!(qe(t)&&qe(r)&&qe(i)&&qe(n)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=6e4*i,t+=36e5*n,t}(h)/1e3}catch(e){d=e}return}""===e&&(g=!1)}a.parse(e+"\n")}),a.flush()}(null!=(t=r.initSegment)&&t.data?or(r.initSegment.data,new Uint8Array(i)):i,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,e=>{this._appendCues(e,r.level),a.trigger(Xe.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},t=>{const n="Missing initPTS for VTT MPEGTS"===t.message;n?s.push(e):this._fallbackToIMSC1(r,i),rt.log(`Failed to parse VTT cue: ${t}`),n&&o>r.cc||a.trigger(Xe.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:t})})}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||go(t,this.initPTS[e.cc],()=>{r.textCodec=uo,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){const r=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];if(!r||"disabled"===r.mode)return;e.forEach(e=>qr(r,e))}else{const i=this.tracks[t];if(!i)return;const n=i.default?"default":"subtitles"+t;r.trigger(Xe.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:r}=t;r.type===Vr&&this.onFragLoaded(Xe.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){const{cea608Parser1:r,cea608Parser2:i}=this;if(!this.enabled||!r||!i)return;const{frag:n,samples:s}=t;if(n.type!==jr||"NONE"!==this.closedCaptionsForLevel(n))for(let e=0;eYr(e[i],t,r))}if(this.config.renderTextTracksNatively&&0===t&&void 0!==i){const{textTracks:e}=this;Object.keys(e).forEach(r=>Yr(e[r],t,i))}}}extractCea608Data(e){const t=[[],[]],r=31&e[0];let i=2;for(let n=0;n0&&-1===e?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=tn):(this.loadedmetadata=!1,this.state=on),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case tn:this.doTickIdle();break;case on:{var e;const{levels:t,trackId:r}=this,i=null==t||null==(e=t[r])?void 0:e.details;if(i){if(this.waitForCdnTuneIn(i))break;this.state=dn}break}case sn:{var t;const e=performance.now(),r=this.retryDate;(!r||e>=r||null!=(t=this.media)&&t.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=tn);break}case dn:{const e=this.waitingData;if(e){const{frag:t,part:r,cache:i,complete:n}=e;if(void 0!==this.initPTS[t.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=nn;const e={frag:t,part:r,payload:i.flush(),networkDetails:null};this._handleFragmentLoadProgress(e),n&&super._handleFragmentLoadComplete(e)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${t.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const e=this.getLoadPosition(),r=Gi.bufferInfo(this.mediaBuffer,e,this.config.maxBufferHole);Ai(r.end,this.config.maxFragLookUpTolerance,t)<0&&(this.log(`Waiting fragment cc (${t.cc}) @ ${t.start} cancelled because another fragment at ${r.end} is needed`),this.clearWaitingFragment())}}else this.state=tn}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=tn)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;null!=e&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:t,media:r,trackId:i}=this,n=e.config;if(null==t||!t[i])return;if(!r&&(this.startFragRequested||!n.startFragPrefetch))return;const s=t[i],o=s.details;if(!o||o.live&&this.levelLastLoaded!==i||this.waitForCdnTuneIn(o))return void(this.state=on);const a=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&a&&(this.bufferFlushed=!1,this.afterBufferFlushed(a,ut,$r));const l=this.getFwdBufferInfo(a,$r);if(null===l)return;const{bufferedTrack:c,switchingTrack:u}=this;if(!u&&this._streamEnded(l,o))return e.trigger(Xe.BUFFER_EOS,{type:"audio"}),void(this.state=cn);const d=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,jr),h=l.len,f=this.getMaxBufferLength(null==d?void 0:d.len);if(h>=f&&!u)return;const p=o.fragments[0].start;let g=l.end;if(u&&r){const e=this.getLoadPosition();c&&u.attrs!==c.attrs&&(g=e),o.PTSKnown&&ep||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=p+.05)}let m=this.getNextFragment(g,o),y=!1;if(m&&this.isLoopLoading(m,g)&&(y=!!m.gap,m=this.getNextFragmentLoopLoading(m,o,l,jr,f)),!m)return void(this.bufferFlushed=!0);const v=d&&m.start>d.end+o.targetduration;if(v||(null==d||!d.len)&&l.len){const e=this.getAppendedFrag(m.start,jr);if(null===e)return;if(y||(y=!!e.gap||!!v&&0===d.len),v&&!y||y&&l.nextStart&&l.nextStartnew ai(e))}onAudioTrackSwitching(e,t){const r=!!t.url;this.trackId=t.id;const{fragCurrent:i}=this;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),r?this.setInterval(100):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=tn):(this.switchingTrack=null,this.bufferedTrack=t,this.state=en),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,null!==this.cachedTrackLoadedData&&(this.hls.trigger(Xe.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(null==this.mainDetails)return void(this.cachedTrackLoadedData=t);const{levels:i}=this,{details:n,id:s}=t;if(!i)return void this.warn(`Audio tracks were reset while loading level ${s}`);this.log(`Track ${s} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const o=i[s];let a=0;if(n.live||null!=(r=o.details)&&r.live){this.checkLiveUpdate(n);const e=this.mainDetails;if(n.deltaUpdateFailed||!e)return;!o.details&&n.hasProgramDateTime&&e.hasProgramDateTime?(Yi(n,e),a=n.fragments[0].start):a=this.alignPlaylists(n,o.details)}o.details=n,this.levelLastLoaded=s,this.startFragRequested||!this.mainDetails&&n.live||this.setStartPosition(o.details,a),this.state!==on||this.waitForCdnTuneIn(n)||(this.state=tn),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:r,part:i,payload:n}=e,{config:s,trackId:o,levels:a}=this;if(!a)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);const l=a[o];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const c=l.details;if(!c)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(r.start);const u=s.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let d=this.transmuxer;d||(d=this.transmuxer=new ys(this.hls,$r,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const h=this.initPTS[r.cc],f=null==(t=r.initSegment)?void 0:t.data;if(void 0!==h){const e=!1,t=i?i.index:-1,s=-1!==t,o=new Ki(r.level,r.sn,r.stats.chunkCount,n.byteLength,t,s);d.push(n,f,u,"",r,i,c.totalduration,e,o,h)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);const{cache:e}=this.waitingData=this.waitingData||{frag:r,part:i,cache:new Ts,complete:!1};e.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=dn}}_handleFragmentLoadComplete(e){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){const r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){const{frag:r,part:i}=t;if(r.type===$r)if(this.fragContextChanged(r))this.warn(`Fragment ${r.sn}${i?" p: "+i.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if("initSegment"!==r.sn){this.fragPrevious=r;const e=this.switchingTrack;e&&(this.bufferedTrack=e,this.switchingTrack=null,this.hls.trigger(Xe.AUDIO_TRACK_SWITCHED,Ge({},e)))}this.fragBufferedComplete(r,i)}else if(!this.loadedmetadata&&r.type===jr){const e=this.videoBuffer||this.media;e&&Gi.getBuffered(e).length&&(this.loadedmetadata=!0)}}onError(e,t){var r;if(t.fatal)this.state=un;else switch(t.details){case Je.FRAG_GAP:case Je.FRAG_PARSING_ERROR:case Je.FRAG_DECRYPT_ERROR:case Je.FRAG_LOAD_ERROR:case Je.FRAG_LOAD_TIMEOUT:case Je.KEY_LOAD_ERROR:case Je.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError($r,t);break;case Je.AUDIO_TRACK_LOAD_ERROR:case Je.AUDIO_TRACK_LOAD_TIMEOUT:case Je.LEVEL_PARSING_ERROR:t.levelRetry||this.state!==on||(null==(r=t.context)?void 0:r.type)!==Br||(this.state=tn);break;case Je.BUFFER_FULL_ERROR:if(!t.parent||"audio"!==t.parent)return;this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case Je.INTERNAL_EXCEPTION:this.recoverWorkerError(t)}}onBufferFlushed(e,{type:t}){t===ut&&(this.bufferFlushed=!0,this.state===cn&&(this.state=tn))}_handleTransmuxComplete(e){var t;const r="audio",{hls:i}=this,{remuxResult:n,chunkMeta:s}=e,o=this.getCurrentContext(s);if(!o)return void this.resetWhenMissingContext(s);const{frag:a,part:l,level:c}=o,{details:u}=c,{audio:d,text:h,id3:f,initSegment:p}=n;if(!this.fragContextChanged(a)&&u){if(this.state=an,this.switchingTrack&&d&&this.completeAudioSwitch(this.switchingTrack),null!=p&&p.tracks){const e=a.initSegment||a;this._bufferInitSegment(p.tracks,e,s),i.trigger(Xe.FRAG_PARSING_INIT_SEGMENT,{frag:e,id:r,tracks:p.tracks})}if(d){const{startPTS:e,endPTS:t,startDTS:r,endDTS:i}=d;l&&(l.elementaryStreams[ut]={startPTS:e,endPTS:t,startDTS:r,endDTS:i}),a.setElementaryStreamInfo(ut,e,t,r,i),this.bufferFragmentData(d,a,l,s)}if(null!=f&&null!=(t=f.samples)&&t.length){const e=We({id:r,frag:a,details:u},f);i.trigger(Xe.FRAG_PARSING_METADATA,e)}if(h){const e=We({id:r,frag:a,details:u},h);i.trigger(Xe.FRAG_PARSING_USERDATA,e)}}else this.fragmentTracker.removeFragment(a)}_bufferInitSegment(e,t,r){if(this.state!==an)return;e.video&&delete e.video;const i=e.audio;if(!i)return;i.levelCodec=i.codec,i.id="audio",this.log(`Init audio buffer, container:${i.container}, codecs[parsed]=[${i.codec}]`),this.hls.trigger(Xe.BUFFER_CODECS,e);const n=i.initSegment;if(null!=n&&n.byteLength){const e={type:"audio",frag:t,part:null,chunkMeta:r,parent:t.type,data:n};this.hls.trigger(Xe.BUFFER_APPENDING,e)}this.tick()}loadFragment(e,t,r){const i=this.fragmentTracker.getState(e);var n;this.fragCurrent=e,this.switchingTrack||i===Pi||i===Ci?"initSegment"===e.sn?this._loadInitSegment(e,t):null!=(n=t.details)&&n.live&&!this.initPTS[e.cc]?(this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=dn):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}completeAudioSwitch(e){const{hls:t,media:r,bufferedTrack:i}=this,n=null==i?void 0:i.attrs,s=e.attrs;r&&n&&(n.CHANNELS!==s.CHANNELS||n.NAME!==s.NAME||n.LANGUAGE!==s.LANGUAGE)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio")),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(Xe.AUDIO_TRACK_SWITCHED,Ge({},e))}},audioTrackController:class extends Si{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.on(Xe.MANIFEST_PARSED,this.onManifestParsed,this),e.on(Xe.LEVEL_LOADING,this.onLevelLoading,this),e.on(Xe.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(Xe.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(Xe.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(Xe.MANIFEST_LOADING,this.onManifestLoading,this),e.off(Xe.MANIFEST_PARSED,this.onManifestParsed,this),e.off(Xe.LEVEL_LOADING,this.onLevelLoading,this),e.off(Xe.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(Xe.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(Xe.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:r,groupId:i,details:n}=t,s=this.tracksInGroup[r];if(!s||s.groupId!==i)return void this.warn(`Track with id:${r} and group:${i} not found in active group ${s.groupId}`);const o=s.details;s.details=t.details,this.log(`audio-track ${r} "${s.name}" lang:${s.lang} group:${i} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(null==t||!t.audioGroupIds)return;const r=t.audioGroupIds[t.urlId];if(this.groupId!==r){this.groupId=r||null;const e=this.tracks.filter(e=>!r||e.groupId===r);this.selectDefaultTrack&&!e.some(e=>e.default)&&(this.selectDefaultTrack=!1),this.tracksInGroup=e;const t={audioTracks:e};this.log(`Updating audio tracks, ${e.length} track(s) found in group:${r}`),this.hls.trigger(Xe.AUDIO_TRACKS_UPDATED,t),this.selectInitialTrack()}else this.shouldReloadPlaylist(this.currentTrack)&&this.setAudioTrack(this.trackId)}onError(e,t){!t.fatal&&t.context&&t.context.type===Br&&t.context.id===this.trackId&&t.context.groupId===this.groupId&&(this.requestScheduled=-1,this.checkRetry(t))}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length)return void this.warn("Invalid id passed to audio-track controller");this.clearTimer();const r=this.currentTrack;t[this.trackId];const i=t[e],{groupId:n,name:s}=i;if(this.log(`Switching to audio-track ${e} "${s}" lang:${i.lang} group:${n}`),this.trackId=e,this.currentTrack=i,this.selectDefaultTrack=!1,this.hls.trigger(Xe.AUDIO_TRACK_SWITCHING,Ge({},i)),i.details&&!i.details.live)return;const o=this.switchParams(i.url,null==r?void 0:r.details);this.loadPlaylist(o)}selectInitialTrack(){const e=this.tracksInGroup,t=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==t)this.setAudioTrack(t);else{const t=new Error(`No track found for running audio group-ID: ${this.groupId} track count: ${e.length}`);this.warn(t.message),this.hls.trigger(Xe.ERROR,{type:Qe.MEDIA_ERROR,details:Je.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:t})}}findTrackId(e){const t=this.tracksInGroup;for(let r=0;rt!==e))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(e,t){const{contentSteering:r}=t;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:r}=t;if(2===(null==r?void 0:r.action)&&1===r.flags){let e=this.pathwayPriority;const t=this.pathwayId;this.penalizedPathways[t]||(this.penalizedPathways[t]=performance.now()),!e&&this.levels&&(e=this.levels.reduce((e,t)=>(-1===e.indexOf(t.pathwayId)&&e.push(t.pathwayId),e),[])),e&&e.length>1&&(this.updatePathwayPriority(e),r.resolved=this.pathwayId!==t)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(0===t.length){const r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return null===this.levels?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){let t;this.pathwayPriority=e;const r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach(e=>{i-r[e]>3e5&&delete r[e]});for(let i=0;i0){this.log(`Setting Pathway to "${n}"`),this.pathwayId=n,this.hls.trigger(Xe.LEVELS_UPDATED,{levels:t});const e=this.hls.levels[s];o&&e&&this.levels&&(e.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&e.bitrate!==o.bitrate&&this.log(`Unstable Pathways change from bitrate ${o.bitrate} to ${e.bitrate}`),this.hls.nextLoadLevel=s);break}}}clonePathways(e){const t=this.levels;if(!t)return;const r={},i={};e.forEach(e=>{const{ID:n,"BASE-ID":s,"URI-REPLACEMENT":o}=e;if(t.some(e=>e.pathwayId===n))return;const a=this.getLevelsForPathway(s).map(e=>{const t=We({},e);t.details=void 0,t.url=_o(e.uri,e.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",o);const s=new st(e.attrs);s["PATHWAY-ID"]=n;const a=s.AUDIO&&`${s.AUDIO}_clone_${n}`,l=s.SUBTITLES&&`${s.SUBTITLES}_clone_${n}`;a&&(r[s.AUDIO]=a,s.AUDIO=a),l&&(i[s.SUBTITLES]=l,s.SUBTITLES=l),t.attrs=s;const c=new ai(t);return xi(c,"audio",a),xi(c,"text",l),c});t.push(...a),Co(this.audioTracks,r,o,n),Co(this.subtitleTracks,i,o,n)})}loadSteeringManifest(e){const t=this.hls.config,r=t.loader;let i;this.loader&&this.loader.destroy(),this.loader=new r(t);try{i=new self.URL(e)}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${e}`)}if("data:"!==i.protocol){const e=0|(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate);i.searchParams.set("_HLS_pathway",this.pathwayId),i.searchParams.set("_HLS_throughput",""+e)}const n={responseType:"json",url:i.href},s=t.steeringManifestLoadPolicy.default,o=s.errorRetry||s.timeoutRetry||{},a={loadPolicy:s,timeout:s.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},l={onSuccess:(e,t,r,n)=>{this.log(`Loaded steering manifest: "${i}"`);const s=e.data;if(1!==s.VERSION)return void this.log(`Steering VERSION ${s.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=s.TTL;const{"RELOAD-URI":o,"PATHWAY-CLONES":a,"PATHWAY-PRIORITY":l}=s;if(o)try{this.uri=new self.URL(o,i).href}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${o}`)}this.scheduleRefresh(this.uri||r.url),a&&this.clonePathways(a),l&&this.updatePathwayPriority(l)},onError:(e,t,r,i)=>{if(this.log(`Error loading steering manifest: ${e.code} ${e.text} (${t.url})`),this.stopLoad(),410===e.code)return this.enabled=!1,void this.log(`Steering manifest ${t.url} no longer available`);let n=1e3*this.timeToLoad;if(429===e.code){const e=this.loader;if("function"==typeof(null==e?void 0:e.getResponseHeader)){const t=e.getResponseHeader("Retry-After");t&&(n=1e3*parseFloat(t))}return void this.log(`Steering manifest ${t.url} rate limited`)}this.scheduleRefresh(this.uri||t.url,n)},onTimeout:(e,t,r)=>{this.log(`Timeout loading steering manifest (${t.url})`),this.scheduleRefresh(this.uri||t.url)}};this.log(`Requesting steering manifest: ${i}`),this.loader.load(n,a,l)}scheduleRefresh(e,t=1e3*this.timeToLoad){self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout(()=>{this.loadSteeringManifest(e)},t)}}});function Vo(e){return e&&"object"==typeof e?Array.isArray(e)?e.map(Vo):Object.keys(e).reduce((t,r)=>(t[r]=Vo(e[r]),t),{}):e}class Ho{static get version(){return"1.4.13"}static isSupported(){return function(){const e=br();if(!e)return!1;const t=pn(),r=e&&"function"==typeof e.isTypeSupported&&e.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove;return!!r&&!!i}()}static get Events(){return Xe}static get ErrorTypes(){return Qe}static get ErrorDetails(){return Je}static get DefaultConfig(){return Ho.defaultConfig?Ho.defaultConfig:$o}static set DefaultConfig(e){Ho.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new gs,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,function(e){if(self.console&&!0===e||"object"==typeof e){!function(e,...t){t.forEach(function(t){tt[t]=e[t]?e[t].bind(e):function(e){const t=self.console[e];return t?t.bind(self.console,`[${e}] >`):Ze}(t)})}(e,"debug","log","info","warn","error");try{tt.log('Debug logs enabled for "Hls instance" in hls.js version 1.4.13')}catch(e){tt=et}}else tt=et}(e.debug||!1);const t=this.config=function(e,t){if((t.liveSyncDurationCount||t.liveMaxLatencyDurationCount)&&(t.liveSyncDuration||t.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==t.liveMaxLatencyDurationCount&&(void 0===t.liveSyncDurationCount||t.liveMaxLatencyDurationCount<=t.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==t.liveMaxLatencyDuration&&(void 0===t.liveSyncDuration||t.liveMaxLatencyDuration<=t.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const r=Vo(e),i=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(e=>{const n=`${"level"===e?"playlist":e}LoadPolicy`,s=void 0===t[n],o=[];i.forEach(i=>{const a=`${e}Loading${i}`,l=t[a];if(void 0!==l&&s){o.push(a);const e=r[n].default;switch(t[n]={default:e},i){case"TimeOut":e.maxLoadTimeMs=l,e.maxTimeToFirstByteMs=l;break;case"MaxRetry":e.errorRetry.maxNumRetry=l,e.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":e.errorRetry.retryDelayMs=l,e.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":e.errorRetry.maxRetryDelayMs=l,e.timeoutRetry.maxRetryDelayMs=l}}}),o.length&&rt.warn(`hls.js config: "${o.join('", "')}" setting(s) are deprecated, use "${n}": ${JSON.stringify(t[n])}`)}),Ge(Ge({},r),t)}(Ho.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,t.progressive&&function(e){const t=e.loader;t!==No&&t!==Do?(rt.log("[config]: Custom loader detected, cannot enable progressive streaming"),e.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(e){}return!1}()&&(e.loader=No,e.progressive=!0,e.enableSoftwareAES=!0,rt.log("[config]: Progressive streaming enabled, using FetchLoader"))}(t);const{abrController:r,bufferController:i,capLevelController:n,errorController:s,fpsController:o}=t,a=new s(this),l=this.abrController=new r(this),c=this.bufferController=new i(this),u=this.capLevelController=new n(this),d=new o(this),h=new Kr(this),f=new ii(this),p=t.contentSteeringController,g=p?new p(this):null,m=this.levelController=new Li(this,g),y=new Oi(this),v=new $i(this.config),b=this.streamController=new bs(this,y,v);u.setStreamController(b),d.setStreamController(b);const E=[h,m,b];g&&E.splice(1,0,g),this.networkControllers=E;const A=[l,c,u,d,f,y];this.audioTrackController=this.createController(t.audioTrackController,E);const T=t.audioStreamController;T&&E.push(new T(this,y,v)),this.subtitleTrackController=this.createController(t.subtitleTrackController,E);const w=t.subtitleStreamController;w&&E.push(new w(this,y,v)),this.createController(t.timelineController,A),v.emeController=this.emeController=this.createController(t.emeController,A),this.cmcdController=this.createController(t.cmcdController,A),this.latencyController=this.createController(ni,A),this.coreComponents=A,E.push(a);const S=a.onErrorOut;"function"==typeof S&&this.on(Xe.ERROR,S,a)}createController(e,t){if(e){const r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,i){this._emitter.off(e,t,r,i)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(t){rt.error("An internal error happened while handling event "+e+'. Error message: "'+t.message+'". Here is a stacktrace:',t),this.trigger(Xe.ERROR,{type:Qe.OTHER_ERROR,details:Je.INTERNAL_EXCEPTION,fatal:!1,event:e,error:t})}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){rt.log("destroy"),this.trigger(Xe.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach(e=>e.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(e=>e.destroy()),this.coreComponents.length=0;const e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){rt.log("attachMedia"),this._media=e,this.trigger(Xe.MEDIA_ATTACHING,{media:e})}detachMedia(){rt.log("detachMedia"),this.trigger(Xe.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,r=this.url,i=this.url=Ve.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});rt.log(`loadSource:${i}`),t&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(Xe.MANIFEST_LOADING,{url:e})}startLoad(e=-1){rt.log(`startLoad(${e})`),this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){rt.log("stopLoad"),this.networkControllers.forEach(e=>{e.stopLoad()})}swapAudioCodec(){rt.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){rt.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e,t=0){this.levelController.removeLevel(e,t)}get levels(){return this.levelController.levels||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){rt.log(`set currentLevel:${e}`),this.loadLevel=e,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){rt.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){rt.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){rt.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){return this.levelController.startLevel}set startLevel(e){rt.log(`set startLevel:${e}`),-1!==e&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(rt.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e)}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){si.indexOf(e)>-1&&(this._maxHdcpLevel=e)}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const r=e.length;for(let i=0;i=t)return i;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this;let i;if(i=-1===t&&e&&e.length?e.length-1:t,r)for(let t=i;t--;){const i=e[t].attrs["HDCP-LEVEL"];if(i&&i<=r)return t}return i}get nextAutoLevel(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)}set nextAutoLevel(e){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,e)}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return!!e&&e.subtitleDisplay}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}Ho.defaultConfig=void 0;var Go=n(83900),Ko=n(10532),Wo=n.n(Ko),qo=Z(function e(t,i){Q(this,e),r(this,"errorContainerClassName","video-player__error"),r(this,"errorMessageElementClassName","video-player__error-message"),this.player=t,this.message=i,this.errorMessageElement=this.createErrorMessageElement()},[{key:"destroy",value:function(){var e;null===(e=this.errorMessageElement)||void 0===e||e.remove()}},{key:"createErrorMessageElement",value:function(){var e=this.player.elements.container,t=document.createElement("div"),r=document.createElement("p");return t.classList.add(this.errorContainerClassName),r.classList.add(this.errorMessageElementClassName),r.innerText=this.message,t.appendChild(r),null==e||e.appendChild(t),t}}]),zo=Z(function e(t,i){var n=this;Q(this,e),r(this,"handleError",function(e){var t=ae.fromError(e);if(n.handleVideoPlayerError(t),t.code===Y)throw e;console.error(e)}),r(this,"handleMediaError",function(e){var t=ae.fromPlayerMedia(e.media);if(n.handleVideoPlayerError(t),t.code===Y)throw t;console.error(t)}),r(this,"handleVideoPlayerError",function(e){var t=n.mapCodeToMessage(e.code);t&&n.showErrorMessageScreen(t)}),r(this,"showErrorMessageScreen",function(e){n.errorMessageScreen=new qo(n.player,e)}),this.player=t,this.isExternalProvider=i,this.translation=t.config.i18n,i||this.player.on("error",function(e){return n.handleMediaError(e.detail.plyr)})},[{key:"destroy",value:function(){var e;null===(e=this.errorMessageScreen)||void 0===e||e.destroy()}},{key:"mapCodeToMessage",value:function(e){return new Map([[V,this.translation.videoAbortedByUser],[H,this.translation.videoCouldNotBeAccessed],[G,this.translation.videoCouldNotBeDecoded],[K,this.translation.videoCouldNotBePlayed],[W,this.translation.videoCouldNotBePlayed],[X,this.translation.unauthorizedAccess],[q,this.translation.videoCouldNotBePlayed],[Y,this.translation.unexpectedError]]).get(e)}}]),Yo=function(e){return(null==e?void 0:e.code)===X};function Xo(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}var Qo=function(){function e(){Q(this,e),r(this,"cancelTokenSource",null)}return Z(e,[{key:"resolve",value:(i=Ae(we().mark(function t(r){return we().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.requestPlaylist(r);case 3:return t.abrupt("return",t.sent);case 6:if(t.prev=6,t.t0=t.catch(0),!Wo().isAxiosError(t.t0)){t.next=14;break}if(!e.isAuthError(t.t0)){t.next=11;break}return t.abrupt("return",this.resolveWithAuth(r));case 11:throw e.buildApiError(t.t0);case 14:throw t.t0;case 15:case"end":return t.stop()}},t,this,[[0,6]])})),function(e){return i.apply(this,arguments)})},{key:"destroy",value:function(){var e;null===(e=this.cancelTokenSource)||void 0===e||e.cancel(),this.cancelTokenSource=null}},{key:"resolveWithAuth",value:(t=Ae(we().mark(function t(r){var i;return we().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,this.requestAuthToken();case 3:return i=t.sent,t.next=6,this.requestPlaylist(r,i);case 6:return t.abrupt("return",t.sent);case 9:if(t.prev=9,t.t0=t.catch(0),!Wo().isAxiosError(t.t0)){t.next=17;break}if(!e.isAuthError(t.t0)){t.next=14;break}throw new ae(X);case 14:throw e.buildApiError(t.t0);case 17:throw t.t0;case 18:case"end":return t.stop()}},t,this,[[0,9]])})),function(e){return t.apply(this,arguments)})},{key:"requestPlaylist",value:function(e,t){var i;return null===(i=this.cancelTokenSource)||void 0===i||i.cancel(),this.cancelTokenSource=Wo().CancelToken.source(),Go.Ay.get(e,function(e){for(var t=1;ti[e].bitrate?r:e},0)})}},{key:"handleErrors",value:function(){var e=this;this.hlsJs.on(Ho.Events.ERROR,function(t,r){if(r.fatal)switch(r.type){case Ho.ErrorTypes.NETWORK_ERROR:e.hlsJs.startLoad();break;case Ho.ErrorTypes.MEDIA_ERROR:e.handleMediaError(r);break;default:e.errorHandler.handleError(r)}})}},{key:"handleMediaError",value:function(e){this.hasMediaErrorOccurred?this.errorHandler.handleError(e):(this.hasMediaErrorOccurred=!0,this.hlsJs.recoverMediaError())}}]),ia=Z(function e(t){Q(this,e),r(this,"playlistLoader",new Qo);var i=t.player,n=t.thumbnailSrc,s=t.errorHandler,o=t.onUnauthorizedError;this.player=i,n&&(this.player.poster=n),this.initVideo(t).catch(function(e){o&&Yo(e)?o():s.handleError(e)})},[{key:"destroy",value:function(){this.playlistLoader.destroy()}},{key:"onReady",value:(Zo=Ae(we().mark(function e(){var t=this;return we().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.player.duration){e.next=2;break}return e.abrupt("return",Promise.resolve());case 2:return e.next=4,new Promise(function(e){var r=function(){t.player.media.removeEventListener("loadedmetadata",r),e()};t.player.media.addEventListener("loadedmetadata",r)});case 4:case"end":return e.stop()}},e,this)})),function(){return Zo.apply(this,arguments)})},{key:"initVideo",value:function(){var e=Ae(we().mark(function e(t){var r,i,n,s,o;return we().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.src,i=t.videoElement,e.next=3,this.playlistLoader.resolve(r);case 3:n=e.sent,s=URL.createObjectURL(n),(o=document.createElement("source")).setAttribute("src",s),o.setAttribute("type","application/x-mpegURL"),i.appendChild(o),this.setHighestQuality();case 10:case"end":return e.stop()}},e,this)}));return function(t){return e.apply(this,arguments)}}()},{key:"setHighestQuality",value:function(){}}]),na=Z(function e(t,r){Q(this,e),this.videoProvider=t;var i=r.src,n=r.thumbnailSrc;this.videoProvider=t;var s=this.createPlyrSourceInfo(i,n);r.player.source=s},[{key:"destroy",value:function(){}},{key:"onReady",value:function(){return Promise.resolve()}},{key:"createPlyrSourceInfo",value:function(e,t){return{type:"video",sources:[{src:e,provider:this.videoProvider}],poster:t}}}]),sa=r(r({},Oe.YouTube,["youtube.com","youtube-nocookie.com","youtu.be"]),Oe.Vimeo,["vimeo.com"]),oa=Z(function e(t,i){var n=this;Q(this,e),r(this,"vimeoButtonClassName","video-player--vimeo-button"),r(this,"maxContainerWidth",225),r(this,"maxContainerHeight",127),this.videoPlayerElement=i,t.provider===De.Vimeo&&t.once("ready",function(){n.resizeObserver=new ResizeObserver(function(){return n.toggleVimeoPlayButtonClassName()}),n.resizeObserver.observe(i)})},[{key:"destroy",value:function(){var e;null===(e=this.resizeObserver)||void 0===e||e.disconnect(),this.removeVimeoPlayButtonClassName()}},{key:"toggleVimeoPlayButtonClassName",value:function(){var e=this.videoPlayerElement.clientWidth,t=this.videoPlayerElement.clientHeight;e=r?t.videoPlayerElement.classList.add(n):i\n \n \n '.concat('\n \n \n \n \n \n',"\n ").concat('\n \n \n \n \n \n \n \n \n \n \n',"\n ").concat('\n \n \n \n \n \n \n \n \n \n \n',"\n ").concat('\n \n \n \n \n \n',"\n ").concat('\n \n \n \n \n \n \n \n \n \n \n',"\n ").concat('\n \n \n \n',"\n ").concat('\n \n \n \n',"\n ").concat('\n \n \n \n',"\n ").concat('\n \n \n \n',"\n ").concat('\n \n \n \n \n \n \n \n \n',"\n ").concat('\n \n \n \n \n',"\n \n"),_a=Z(function e(t,i){Q(this,e),r(this,"iconsClassName","video-player__icons"),r(this,"iconsElement",null),i.length>0&&(this.iconsElement=this.createIconSpriteElement(),t.appendChild(this.iconsElement))},[{key:"destroy",value:function(){var e;null===(e=this.iconsElement)||void 0===e||e.remove()}},{key:"createIconSpriteElement",value:function(){var e=document.createElement("div");return e.classList.add(this.iconsClassName),e.innerHTML=Ca,e}}]),Oa=Z(function e(t,i){Q(this,e),r(this,"className","video-player__navigation-indicator"),r(this,"showClassName","".concat(this.className,"--show"));var n="http://www.w3.org/2000/svg",s=document.createElement("div"),o=document.createElementNS(n,"svg"),a=document.createElementNS(n,"use"),l="#".concat("video-player__icon","-").concat(t),c="".concat(this.className,"--").concat(t);s.classList.add(this.className,c),"href"in a&&a.setAttributeNS("http://www.w3.org/1999/xlink","href",l),a.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l),o.appendChild(a),s.appendChild(o),this.element=s,i.appendChild(s)},[{key:"show",value:function(){this.element.classList.add(this.showClassName)}},{key:"hide",value:function(){this.element.classList.remove(this.showClassName)}}]),Da=function(e){return e.Backward="backward",e.Forward="forward",e}({}),Ma=Z(function e(t,i,n){var s,o,a=this;Q(this,e),r(this,"navigationIndicatorsClassName","video-player__navigation-indicators"),r(this,"hideIndicatorTimeoutMs",1e3),r(this,"navigationIndicatorsElement",null),r(this,"backwardNavigationIndicator",null),r(this,"forwardNavigationIndicator",null),r(this,"plyrContainer",null),r(this,"toggleNavigationIndicatorListener",function(e){var t=e.key;if(a.player.seeking)switch(t){case"ArrowLeft":a.handleBackwardNavigationIndicator();break;case"ArrowRight":a.handleForwardNavigationIndicator()}}),this.player=t;var l,c=i.includes(xe.NavigationIndicators),u=Boolean((null===(s=n.keyboard)||void 0===s?void 0:s.focused)||(null===(o=n.keyboard)||void 0===o?void 0:o.global));c&&u&&(this.plyrContainer=t.elements.container,this.navigationIndicatorsElement=this.createNavigationIndicatorsElement(),null===(l=this.plyrContainer)||void 0===l||l.appendChild(this.navigationIndicatorsElement),this.subscribeEvents())},[{key:"destroy",value:function(){var e;this.unsubscribeEvents(),null===(e=this.navigationIndicatorsElement)||void 0===e||e.remove()}},{key:"createNavigationIndicatorsElement",value:function(){var e=document.createElement("div");return e.classList.add(this.navigationIndicatorsClassName),this.createNavigationIndicators(e),e}},{key:"createNavigationIndicators",value:function(e){this.backwardNavigationIndicator=new Oa(Da.Backward,e),this.forwardNavigationIndicator=new Oa(Da.Forward,e)}},{key:"subscribeEvents",value:function(){var e;null===(e=this.plyrContainer)||void 0===e||e.addEventListener("keydown",this.toggleNavigationIndicatorListener)}},{key:"unsubscribeEvents",value:function(){var e;null===(e=this.plyrContainer)||void 0===e||e.removeEventListener("keydown",this.toggleNavigationIndicatorListener)}},{key:"handleBackwardNavigationIndicator",value:function(){var e,t,r=this;window.clearTimeout(this.hideIndicatorTimer),null===(e=this.forwardNavigationIndicator)||void 0===e||e.hide(),null===(t=this.backwardNavigationIndicator)||void 0===t||t.show(),this.hideIndicatorTimer=window.setTimeout(function(){var e;return null===(e=r.backwardNavigationIndicator)||void 0===e?void 0:e.hide()},this.hideIndicatorTimeoutMs)}},{key:"handleForwardNavigationIndicator",value:function(){var e,t,r=this;window.clearTimeout(this.hideIndicatorTimer),null===(e=this.backwardNavigationIndicator)||void 0===e||e.hide(),null===(t=this.forwardNavigationIndicator)||void 0===t||t.show(),this.hideIndicatorTimer=window.setTimeout(function(){var e;return null===(e=r.forwardNavigationIndicator)||void 0===e?void 0:e.hide()},this.hideIndicatorTimeoutMs)}}]),Na=Z(function e(t,r){Q(this,e),this.onHeightUpdated=r;var i=t.elements.controls;i&&(this.controlsObserver=this.observeControls(i),this.updateHeight(i))},[{key:"destroy",value:function(){var e;null===(e=this.controlsObserver)||void 0===e||e.disconnect()}},{key:"observeControls",value:function(e){var t=this,r=new ResizeObserver(function(){return t.updateHeight(e)});return r.observe(e),r}},{key:"updateHeight",value:function(e){var t=Array.from(e.querySelectorAll(".plyr__controls__item")).filter(function(e){var t=window.getComputedStyle(e);return"none"!==t.display&&"hidden"!==t.visibility}).map(function(t){return e.clientHeight-t.offsetTop}),r=Math.max.apply(Math,be(t));this.onHeightUpdated(r)}}]),Fa=Z(function e(t){Q(this,e),this.player=t},[{key:"destroy",value:function(){this.updateStyles({transform:"",bottom:"",skipTransition:!0})}},{key:"updateHeight",value:function(e){this.updateStyles({transform:"translateY(-".concat(e,"px)"),bottom:"-".concat(e,"px"),skipTransition:!0})}},{key:"updateStyles",value:function(e){var t=this.player.elements.controls;if(t){var r=t.style.transition;e.skipTransition&&(t.style.transition="none"),t.style.transform=e.transform,t.style.bottom=e.bottom,e.skipTransition&&(t.offsetHeight,t.style.transition=r)}}}]),Ba=function(){function e(t,r){Q(this,e);var i=r.length>0,n=t.elements.controls;i&&t.elements.container&&n&&(this.blockerElement=this.createBlockerElement(),t.elements.container.appendChild(this.blockerElement))}return Z(e,[{key:"destroy",value:function(){var e;null===(e=this.blockerElement)||void 0===e||e.remove()}},{key:"updateHeight",value:function(e){this.blockerElement&&(this.blockerElement.style.height="".concat(e,"px"))}},{key:"createBlockerElement",value:function(){var t=document.createElement("div");return t.classList.add(e.blockerClassName),t}}])}();r(Ba,"blockerClassName","video-player__controls-blocker");var Ua=Z(function e(t){var i,n=this;Q(this,e),r(this,"observers",[]);var s=t.elements.settings.popup;if(s){var o=null===(i=t.elements.settings.buttons.speed)||void 0===i?void 0:i.querySelector(".plyr__menu__value"),a=[].concat(be(Array.from(s.querySelectorAll(e.SpeedLabelsSelector))),be(o?[o]:[]));a.forEach(function(e){return n.formatElement(e)}),this.observers=a.map(function(e){return n.observeLabel(e)})}},[{key:"destroy",value:function(){this.observers.forEach(function(e){return e.disconnect()}),this.observers=[]}},{key:"formatElement",value:function(e){var t=this.format(e.textContent);t!==e.textContent&&(e.textContent=t)}},{key:"format",value:function(e){return e&&"×"===e.slice(-1)?"".concat(parseFloat(e),"x"):e}},{key:"observeLabel",value:function(e){var t=this,r=new MutationObserver(function(){return t.formatElement(e)});return r.observe(e,{characterData:!1,attributes:!1,childList:!0,subtree:!1}),r}}]);r(Ua,"SpeedLabelsSelector","button[data-plyr=speed] > span");var ja=Z(function e(t,i,n){var s,o,a=this;Q(this,e),r(this,"hideVolumeTimeoutMs",1e3),r(this,"showVolumeSliderClassName","video-player__volume--menu-open"),r(this,"setFocusOnContainer",function(){var e;return null===(e=a.player.elements.container)||void 0===e?void 0:e.focus()}),this.player=t;var l,c=n.includes(xe.Volume),u=Boolean((null===(s=i.keyboard)||void 0===s?void 0:s.focused)||(null===(o=i.keyboard)||void 0===o?void 0:o.global));c&&u&&(this.player.on("volumechange",function(){return a.showVolumeOnChange()}),null===(l=this.player.elements.inputs.volume)||void 0===l||l.addEventListener("click",this.setFocusOnContainer))},[{key:"destroy",value:function(){var e;null===(e=this.player.elements.inputs.volume)||void 0===e||e.removeEventListener("click",this.setFocusOnContainer),this.clearHideTimeout()}},{key:"clearHideTimeout",value:function(){void 0!==this.hideTimeout&&window.clearTimeout(this.hideTimeout),this.hideTimeout=void 0}},{key:"showVolumeOnChange",value:function(){var e=this;this.isMuted()||(this.isSliderVisible()&&void 0!==this.hideTimeout||!this.isSliderVisible())&&(this.clearHideTimeout(),this.hideTimeout=window.setTimeout(function(){return e.hideVolumeSlider()},this.hideVolumeTimeoutMs),this.showVolumeSlider())}},{key:"isMuted",value:function(){return this.player.muted}},{key:"isSliderVisible",value:function(){var e,t=this.player.elements.inputs.volume;return Boolean(t&&"visible"===window.getComputedStyle(t).visibility||(null===(e=this.player.elements.container)||void 0===e?void 0:e.classList.contains(this.showVolumeSliderClassName)))}},{key:"showVolumeSlider",value:function(){var e,t;this.isSliderVisible()||(this.player.toggleControls(!1),null===(e=this.player.elements.buttons.mute)||void 0===e||e.focus(),null===(t=this.player.elements.container)||void 0===t||t.classList.add(this.showVolumeSliderClassName))}},{key:"hideVolumeSlider",value:function(){var e;this.clearHideTimeout(),this.isSliderVisible()&&(this.setFocusOnContainer(),null===(e=this.player.elements.container)||void 0===e||e.classList.remove(this.showVolumeSliderClassName))}}]),$a=Z(function e(t,i,n,s,o){var a=this;Q(this,e),r(this,"unsubscribeFocusOnPlyrContainer",function(){var e=a.getPlayButtons();null==e||e.forEach(function(e){return e.removeEventListener("click",a.focusOnPlyrContainerListener)})}),r(this,"focusOnPlyrContainerListener",function(){var e;return null===(e=a.player.elements.container)||void 0===e?void 0:e.focus()}),this.player=t,this.plyrOptions=i,this.videoPlayerControls=n,this.videoPlayerElement=s,this.isExternalProvider=o,this.icons=new _a(s,n),this.plyrLoadingIndicator=new ma(t,o,n),this.volumeSliderToggler=new ja(t,i,n),this.speedLabelsFormatter=new Ua(t),this.controlsInteractionBlocker=new Ba(t,n),this.controlsHideOffsetSetter=new Fa(t),this.controlsHeightObserver=new Na(t,function(e){var t,r;null===(t=a.controlsInteractionBlocker)||void 0===t||t.updateHeight(e),null===(r=a.controlsHideOffsetSetter)||void 0===r||r.updateHeight(e)}),this.clickToPlay=new Ia(t,i),this.vimeoPlayButton=new oa(t,s),t.once("ready",function(){a.movePlayButtonAsTheFirstUIElement(),a.togglePlayButtonIcon(),a.navigationIndicators=new Ma(t,n,i)})},[{key:"destroy",value:function(){var e,t,r,i,n,s,o,a,l;null===(e=this.clickToPlay)||void 0===e||e.destroy(),null===(t=this.controlsInteractionBlocker)||void 0===t||t.destroy(),null===(r=this.controlsHideOffsetSetter)||void 0===r||r.destroy(),null===(i=this.controlsHeightObserver)||void 0===i||i.destroy(),null===(n=this.icons)||void 0===n||n.destroy(),null===(s=this.plyrLoadingIndicator)||void 0===s||s.destroy(),null===(o=this.volumeSliderToggler)||void 0===o||o.destroy(),null===(a=this.speedLabelsFormatter)||void 0===a||a.destroy(),null===(l=this.navigationIndicators)||void 0===l||l.destroy(),this.vimeoPlayButton.destroy(),this.unsubscribeFocusOnPlyrContainer()}},{key:"movePlayButtonAsTheFirstUIElement",value:function(){var e=this.getPlayButtons(),t=null==e?void 0:e.find(function(e){return e.classList.contains("plyr__control--overlaid")}),r=this.player.elements.container,i=this.player.elements.controls;t&&(null==r||r.insertBefore(t,i))}},{key:"togglePlayButtonIcon",value:function(){var e=this,t=this.getPlayButtons();if(this.player&&t){var r=function(e){return t.forEach(function(t){return function(e,t){var r=e.querySelector("use");r&&r.setAttribute("href","#video-player__icon-".concat(t))}(t,e)})};this.player.on("play",function(){return r("pause")}),this.player.on("pause",function(){return r("play")}),this.player.on("seeking",function(){return e.player.playing?r("pause"):r("play")}),this.player.on("ended",function(){return r("replay")}),this.subscribeFocusOnPlyrContainer(t)}}},{key:"getPlayButtons",value:function(){var e,t=null===(e=this.player)||void 0===e?void 0:e.elements.buttons.play;return t?Array.isArray(t)?t:[t]:null}},{key:"subscribeFocusOnPlyrContainer",value:function(e){var t=this;e.forEach(function(e){return e.addEventListener("click",t.focusOnPlyrContainerListener)})}}]);const Va={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let Ha;const Ga=new Uint8Array(16);function Ka(){if(!Ha&&(Ha="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ha))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ha(Ga)}const Wa=[];for(let e=0;e<256;++e)Wa.push((e+256).toString(16).slice(1));const qa=function(e,t,r){if(Va.randomUUID&&!t&&!e)return Va.randomUUID();const i=(e=e||{}).random||(e.rng||Ka)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=i[e];return t}return function(e,t=0){return Wa[e[t+0]]+Wa[e[t+1]]+Wa[e[t+2]]+Wa[e[t+3]]+"-"+Wa[e[t+4]]+Wa[e[t+5]]+"-"+Wa[e[t+6]]+Wa[e[t+7]]+"-"+Wa[e[t+8]]+Wa[e[t+9]]+"-"+Wa[e[t+10]]+Wa[e[t+11]]+Wa[e[t+12]]+Wa[e[t+13]]+Wa[e[t+14]]+Wa[e[t+15]]}(i)};var za=function(){function e(){Q(this,e)}return Z(e,null,[{key:"getSessionId",value:function(){if(!e.sessionId){var t,r=Pa.getOptions();e.sessionId=null!==(t=null==r?void 0:r.sessionId)&&void 0!==t?t:e.createSessionId()}return e.sessionId}},{key:"createSessionId",value:function(){var e=qa();return Pa.setOption("sessionId",e),e}}])}();function Ya(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}var Xa=function(){function e(t,i){var n,s=this;Q(this,e),r(this,"thumbnail",null),r(this,"ui",null),r(this,"playbackDriver",null),r(this,"embedAspectRatio",null),r(this,"videoPlayerErrorHandler",null),r(this,"videoProvider",null),r(this,"loadingScreen",null),r(this,"paywall",null),this.videoPlayerElement=t,Date.now(),za.getSessionId();var o=i.environment,a=i.src,l=i.options,c=i.thumbnailSrc,u=i.events;this.videoPlayerElement.videoPlayer=this,this.breakpointsSetter=new wa(this.videoPlayerElement,function(){var e,t;return null!==(e=null===(t=s.player)||void 0===t?void 0:t.elements.container)&&void 0!==e?e:null});var d=this.createVideoElement(t,l),h=null!==(n=null==l?void 0:l.controls)&&void 0!==n?n:e.DefaultControls,f=this.createPlyrOptions(function(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:window;return/\.(sqsp|squarespace)\.net$/.test(function(){var e,t,r,i,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window;return"string"==typeof n?new URL(n).hostname:null!==(e=null!==(t=null===(r=n.Static)||void 0===r||null===(r=r.SQUARESPACE_CONTEXT)||void 0===r?void 0:r.appDomain)&&void 0!==t?t:null===(i=n.location)||void 0===i?void 0:i.host)&&void 0!==e?e:""}(e))}()?tl.SourceEnvironment.STAGING:tl.SourceEnvironment.PROD;this.tracker=new il({customSchemaName:e.VideoAnalyticsSchema,sourceEnvironment:t},{event_source:tl.EventSource.WEB})},[{key:"track",value:function(e){this.tracker.track(e)}}]);r(nl,"VideoAnalyticsSchema","VideoAnalytics");const sl=nl;function ol(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,i)}return r}function al(e){for(var t=1;te,n=null!==(t=null===(r=o.videoContext)||void 0===r||null===(r=r.videoPlayerOptions)||void 0===r?void 0:r.loop)&&void 0!==t&&t;return i&&n}),o.videoPlayerElement=e,o.videoContext=i,o.viewSessionId=qa(),o.videoEventsClient=new sl,o.trackers=[new pe({initialViewSessionId:o.viewSessionId,requestNewSession:o.handleRequestNewSession,onSendProgressEvent:o.handleSendProgressEvent}),new ge({initialViewSessionId:o.viewSessionId,onSendViewEvent:o.handleSendViewEvent})],o.removePageHiddenListeners=(u=o.handlePageHidden,d=function(e){var t=e.type;("visibilitychange"===t&&"hidden"===document.visibilityState||"visibilitychange"!==t)&&u()},document.addEventListener("visibilitychange",d),window.addEventListener("pagehide",d),window.addEventListener("beforeunload",d),function(){document.removeEventListener("visibilitychange",d),window.removeEventListener("pagehide",d),window.removeEventListener("beforeunload",d)}),o.canAutoplayStartPlayback=null!==(n=null==i||null===(s=i.videoPlayerOptions)||void 0===s?void 0:s.autoPlay)&&void 0!==n&&n,o.videoPlayerElement.addEventListener("click",o.handleManualStartPlayback),o}return ie(t,e),Z(t,[{key:"destroy",value:function(){var e;this.handlePageHidden(),this.removePageHiddenListeners(),null===(e=this.playerElementObserver)||void 0===e||e.disconnect(),this.videoPlayerElement.removeEventListener("click",this.handleManualStartPlayback)}},{key:"makeEventOptions",value:function(){var e,r,i,n,s,o,a,l,c,u,d,h=this.videoContext,f=h.websiteId,p=h.websiteLocale,g=h.memberAccountId,m=h.memberAccountLocale,y=h.projectRoles,v=h.libraryId,b=h.assetId,E=h.assetDestination,A=h.contentCollectionId,T=h.contentItemId,w=h.videoPlayerOptions,S=Za().get(t.SiteUserInfoCookieName),k=S&&null!==(e=JSON.parse(S).siteUserId)&&void 0!==e?e:null,L=Za().get(t.SsCvrCookieName),x=null!==(r=null===(i=this.videoPlayerElement.videoPlayer)||void 0===i?void 0:i.isMuted)&&void 0!==r?r:null,R=null!==(n=null===(s=this.videoPlayerElement.videoPlayer)||void 0===s?void 0:s.volume)&&void 0!==n?n:null,P=this.getPlaybackStartReason();return{client_guid:qa(),event_owner_team:"video",product_area:"website",actor:"user",object_type:"video",context_website_id:f,website_locale:p,member_account_id:g,member_account_locale:m,project_roles:y,site_user_id:k,library_id:v,asset_id:b,asset_destination:E,content_collection_id:A,content_item_id:T,player_version:"2.6.2",ss_cvr:L,enduser_date_time:(u=new Date,d=u.getTimezoneOffset()/60*-1,u.getFullYear()+"-"+el(u.getMonth()+1,2)+"-"+el(u.getDate(),2)+"T"+el(u.getHours(),2)+":"+el(u.getMinutes(),2)+":"+el(u.getSeconds(),2)+"."+el(u.getMilliseconds(),3)+(d<0?"-"+el(100*Math.abs(d),4):d>0?"+"+el(100*d,4):"Z")),enduser_time_zone:null===(o=Intl)||void 0===o||null===(o=o.DateTimeFormat())||void 0===o||null===(o=o.resolvedOptions())||void 0===o?void 0:o.timeZone,is_loop_option_enabled:null!==(a=null==w?void 0:w.loop)&&void 0!==a?a:null,is_autoplay_option_enabled:null!==(l=null==w?void 0:w.autoPlay)&&void 0!==l?l:null,is_muted_option_enabled:null!==(c=null==w?void 0:w.muted)&&void 0!==c?c:null,is_muted:x,volume:R,playback_start_reason:P}}},{key:"getPlaybackStartReason",value:function(){var e,t,r,i,n,s,o,a,l=null!==(e=null===(t=this.videoPlayerElement.videoPlayer)||void 0===t?void 0:t.isPlaying)&&void 0!==e&&e,c=this.isStarted(),u=null!==(r=(null===(i=this.videoPlayerElement.videoPlayer)||void 0===i?void 0:i.isPaused)&&c)&&void 0!==r&&r,d=null!==(n=null===(s=this.videoPlayerElement.videoPlayer)||void 0===s?void 0:s.isEnded)&&void 0!==n&&n,h=null!==(o=null===(a=this.videoContext)||void 0===a||null===(a=a.videoPlayerOptions)||void 0===a?void 0:a.autoPlay)&&void 0!==o&&o,f=this.canAutoplayStartPlayback&&(l||u),p=d&&h&&!this.canManualStartPlayback,g=this.canLoopStartPlayback&&c,m=this.canManualStartPlayback&&(l||d||u);return p||f?"autoplay":g?"loop":m?"manual":null}},{key:"isStarted",value:function(){var e,t;return(null!==(e=null===(t=this.videoPlayerElement.videoPlayer)||void 0===t?void 0:t.currentTime)&&void 0!==e?e:0)>0}}])}(me);r(ul,"SiteUserInfoCookieName","SiteUserInfo"),r(ul,"SsCvrCookieName","ss_cvr");class dl extends N{constructor(e,t){e.parentElement&&(super(e.parentElement,t),r(this,"player",null),r(this,"video",null),r(this,"thumbnail",null),r(this,"settings",{muted:!1,autoPlay:!1,loop:!1,controls:$}),r(this,"videoPlayerOptions",null),r(this,"videoPlayerContext",null),r(this,"videoPlayer",null),this.player=e,this.video=this.parseJson(this.wrapper.dataset.configVideo??""),this.thumbnail=this.parseJson(this.wrapper.dataset.configThumbnail??""),this.settings=this.parseJson(this.wrapper.dataset.configSettings??"")??this.settings,this.video&&(this.videoPlayerOptions=this.getVideoPlayerOptions(),this.videoPlayerContext=this.getVideoPlayerContext(),this.videoPlayer=this.createPlayerWithTracker()))}resetVideo(){}parseJson(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}getVideoPlayerOptions(){var e;return{language:window.Static.SQUARESPACE_CONTEXT.website.language,thumbnailFocalPoint:null===(e=this.thumbnail)||void 0===e?void 0:e.mediaFocalPoint,storage:!this.settings.muted,...this.settings}}getVideoPlayerContext(){var e;if(!this.video)throw new Error("getVideoPlayerContext called without a video");return{squarespaceContext:window.Static.SQUARESPACE_CONTEXT,videoAssetDetails:this.video,assetDestination:"video-block",contentCollectionId:this.parseJson((null===(e=this.wrapper)||void 0===e?void 0:e.dataset.configCollectionId)??""),contentItemId:this.video.id}}createPlayerWithTracker(){var e;if(!(this.player&&this.video&&this.videoPlayerContext&&this.videoPlayerOptions))return null;const t=this.getVideoActivityTracker(),r=this.video.alexandriaUrl??"",i=(null===(e=this.thumbnail)||void 0===e?void 0:e.assetUrl)??"",n={src:(c=this.video,U(c.alexandriaUrl,"playlist.m3u8")),thumbnailSrc:j(r,i),events:t?t.makeEventHooks():void 0,environment:(l=null!==(s=null!==(o=null===(a=window.Static)||void 0===a||null===(a=a.SQUARESPACE_CONTEXT)||void 0===a?void 0:a.appDomain)&&void 0!==o?o:window.location.host)&&void 0!==s?s:"",/dev\.(sqsp|squarespace)\.net$/.test(l)||/localhost(:[0-9]+)?$/.test(l)?"DEV":/qa[0-9]+\.(sqsp|squarespace)\.net$/.test(l)?"QA":/stage\.(sqsp|squarespace)\.net$/.test(l)?"STAGING":"PRODUCTION"),context:this.videoPlayerContext,options:this.videoPlayerOptions};var s,o,a,l,c;return{videoActivityTracker:t,videoPlayer:new Xa(this.player,n)}}getVideoActivityTracker(){if(this.isEditable||this.settings.autoPlay||!this.videoPlayerContext||!this.videoPlayerOptions||!this.player)return null;const e=(s=(t={...this.videoPlayerContext,videoPlayerOptions:this.videoPlayerOptions}).squarespaceContext,o=t.videoAssetDetails,a=t.assetDestination,l=t.contentCollectionId,c=t.contentItemId,u=t.videoPlayerOptions,{websiteId:s.website.id,websiteLocale:s.website.language,memberAccountId:(null===(r=s.authenticatedAccount)||void 0===r?void 0:r.id)||null,memberAccountLocale:(null===(i=s.authenticatedAccount)||void 0===i?void 0:i.preferredLocale)||null,projectRoles:(n=s.permissions,n?Object.keys(n.permissions).map(Number):null),libraryId:o.alexandriaLibraryId,assetId:o.systemDataId,assetDestination:a,contentCollectionId:l,contentItemId:c,durationSeconds:o.durationSeconds,videoPlayerOptions:u});var t,r,i,n,s,o,a,l,c,u;return new ul(this.player,e)}}class hl{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];r(this,"videoPlayer",null),this.root=e,this.isEditable=t,this.animationVisitor=new O(e,t),this.render()}render(){const e=this.getEmbedPlayerElement();if(e)return void(this.videoPlayer=new B(e,this.isEditable));const t=this.getNativeVideoPlayerElement();t&&(this.videoPlayer=new dl(t,this.isEditable))}updateDescription(e){const t=this.root.querySelector(".video-caption");t&&(t.innerHTML=e)}getNativeVideoPlayerElement(){return this.root.querySelector(".native-video-player")}getEmbedPlayerElement(){return this.root.querySelector(N.VIDEO_WRAPPER)}}const fl=function(e){return new hl(e,arguments.length>1&&void 0!==arguments[1]&&arguments[1])}})(),s})());